@peerbots/face 0.0.0-stage → 0.2.0
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/README.md +30 -2
- package/dist/VizijFaceView-DEMuLMAb.d.ts +63 -0
- package/dist/chunk-EAYBAWGE.js +1487 -0
- package/dist/chunk-EAYBAWGE.js.map +1 -0
- package/dist/chunk-QGFC2GUD.js +211 -0
- package/dist/chunk-QGFC2GUD.js.map +1 -0
- package/dist/chunk-ZEXL2QPJ.js +68 -0
- package/dist/chunk-ZEXL2QPJ.js.map +1 -0
- package/dist/index.cjs +4639 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +557 -0
- package/dist/index.js +1660 -0
- package/dist/index.js.map +1 -0
- package/dist/pixi.cjs +2421 -0
- package/dist/pixi.cjs.map +1 -0
- package/dist/pixi.d.ts +33 -0
- package/dist/pixi.js +889 -0
- package/dist/pixi.js.map +1 -0
- package/dist/vizij.cjs +1556 -0
- package/dist/vizij.cjs.map +1 -0
- package/dist/vizij.d.ts +2 -0
- package/dist/vizij.js +193 -0
- package/dist/vizij.js.map +1 -0
- package/package.json +116 -4
- package/public/FaceAssets/Hugo/cheek.png +0 -0
- package/public/FaceAssets/Hugo/concerned_l.png +0 -0
- package/public/FaceAssets/Hugo/concerned_r.png +0 -0
- package/public/FaceAssets/Hugo/happy_l.png +0 -0
- package/public/FaceAssets/Hugo/happy_r.png +0 -0
- package/public/FaceAssets/Hugo/hugo_spritesheet.json +97 -0
- package/public/FaceAssets/Hugo/hugo_spritesheet.png +0 -0
- package/public/FaceAssets/Hugo/neutral_l.png +0 -0
- package/public/FaceAssets/Hugo/neutral_r.png +0 -0
- package/public/FaceAssets/Hugo/sad_l.png +0 -0
- package/public/FaceAssets/Hugo/sad_r.png +0 -0
- package/public/FaceAssets/Hugo/sleepy_l.png +0 -0
- package/public/FaceAssets/Hugo/sleepy_r.png +0 -0
- package/public/FaceAssets/Hugo/surprised_l.png +0 -0
- package/public/FaceAssets/Hugo/surprised_r.png +0 -0
- package/public/FaceAssets/Icons/Concerned.png +0 -0
- package/public/FaceAssets/Icons/Neutral.png +0 -0
- package/public/FaceAssets/Icons/Sad.png +0 -0
- package/public/FaceAssets/Icons/Sleep.png +0 -0
- package/public/FaceAssets/Icons/Surprised.png +0 -0
- package/public/FaceAssets/Misty/misty_spritesheet.json +97 -0
- package/public/FaceAssets/Misty/misty_spritesheet.png +0 -0
- package/public/FaceAssets/Robotic/robotic_spritesheet.json +97 -0
- package/public/FaceAssets/Robotic/robotic_spritesheet.png +0 -0
- package/public/FaceAssets/Vizij/Hugo.glb +0 -0
- package/public/FaceAssets/Vizij/brand.svg +15 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1660 @@
|
|
|
1
|
+
import {
|
|
2
|
+
EMOTION_EMOJIS,
|
|
3
|
+
EMOTION_EMOTICONS,
|
|
4
|
+
EMOTION_ICON_FILES,
|
|
5
|
+
emotion_mapping,
|
|
6
|
+
getEmotionEyeSpritePaths,
|
|
7
|
+
getEmotionIconPath,
|
|
8
|
+
useMessageVisualState
|
|
9
|
+
} from "./chunk-QGFC2GUD.js";
|
|
10
|
+
import {
|
|
11
|
+
DEFAULT_FACE_UI_LABELS,
|
|
12
|
+
resolveFaceUiLabels
|
|
13
|
+
} from "./chunk-ZEXL2QPJ.js";
|
|
14
|
+
import {
|
|
15
|
+
AudioAnalyzer,
|
|
16
|
+
CONNECTION_FACE_MESSAGE,
|
|
17
|
+
DEFAULT_FACE_MESSAGE,
|
|
18
|
+
FaceStoreContext,
|
|
19
|
+
FaceStoreProvider,
|
|
20
|
+
PEERBOTS_COLORS,
|
|
21
|
+
PEERBOTS_EMOTIONS,
|
|
22
|
+
TtsAudioCache,
|
|
23
|
+
audioAnalyzer,
|
|
24
|
+
availableFaces,
|
|
25
|
+
blobToArrayBuffer,
|
|
26
|
+
buildTtsCacheKey,
|
|
27
|
+
builtInFaces,
|
|
28
|
+
color_mapping,
|
|
29
|
+
createBuiltInFaces,
|
|
30
|
+
createBuiltInPixiFaces,
|
|
31
|
+
createCustomVizijFace,
|
|
32
|
+
createFaceRenderingSlice,
|
|
33
|
+
createFaceSpeechSlice,
|
|
34
|
+
createIncludedVizijFaces,
|
|
35
|
+
createPeerbotsFaceStore,
|
|
36
|
+
customFace,
|
|
37
|
+
deconstructRgba,
|
|
38
|
+
defaultFace,
|
|
39
|
+
defaultFaceSettings,
|
|
40
|
+
defaultTtsAudioCache,
|
|
41
|
+
estimateVisemesFromText,
|
|
42
|
+
findMatchingVoice,
|
|
43
|
+
font_color_mapping,
|
|
44
|
+
formatRbga,
|
|
45
|
+
formatRgba,
|
|
46
|
+
formatVoiceDisplayName,
|
|
47
|
+
getFaceCapabilities,
|
|
48
|
+
getGlobalFaceStore,
|
|
49
|
+
getLanguageName,
|
|
50
|
+
globalFaceStore,
|
|
51
|
+
hexToRgb,
|
|
52
|
+
hexToRgba,
|
|
53
|
+
includedVizijFaces,
|
|
54
|
+
interpolateColor,
|
|
55
|
+
mapVisemeToVizijTarget,
|
|
56
|
+
mergeFaceSettings,
|
|
57
|
+
normalizeAssetBaseUrl,
|
|
58
|
+
pollyVisemeToVizijPath,
|
|
59
|
+
possiblePollyVisemes,
|
|
60
|
+
rbgToRgba,
|
|
61
|
+
rgbToRgba,
|
|
62
|
+
rgbaToHex,
|
|
63
|
+
setGlobalFaceStore,
|
|
64
|
+
stopNativeSpeechSynthesis,
|
|
65
|
+
useFaceStore,
|
|
66
|
+
useFaceStoreInstance
|
|
67
|
+
} from "./chunk-EAYBAWGE.js";
|
|
68
|
+
|
|
69
|
+
// #style-inject:#style-inject
|
|
70
|
+
function styleInject(css, { insertAt } = {}) {
|
|
71
|
+
if (!css || typeof document === "undefined") return;
|
|
72
|
+
const head = document.head || document.getElementsByTagName("head")[0];
|
|
73
|
+
const style = document.createElement("style");
|
|
74
|
+
style.type = "text/css";
|
|
75
|
+
if (insertAt === "top") {
|
|
76
|
+
if (head.firstChild) {
|
|
77
|
+
head.insertBefore(style, head.firstChild);
|
|
78
|
+
} else {
|
|
79
|
+
head.appendChild(style);
|
|
80
|
+
}
|
|
81
|
+
} else {
|
|
82
|
+
head.appendChild(style);
|
|
83
|
+
}
|
|
84
|
+
if (style.styleSheet) {
|
|
85
|
+
style.styleSheet.cssText = css;
|
|
86
|
+
} else {
|
|
87
|
+
style.appendChild(document.createTextNode(css));
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// src/styles/index.css
|
|
92
|
+
styleInject('/*! tailwindcss v4.3.5 | MIT License | https://tailwindcss.com */\n@layer properties;\n@layer theme, base, components, utilities;\n@layer theme {\n :root,\n :host {\n --pbf-font-sans:\n -apple-system,\n BlinkMacSystemFont,\n "Segoe UI",\n Roboto,\n "Helvetica Neue",\n "Noto Sans",\n Arial,\n sans-serif,\n "Apple Color Emoji",\n "Segoe UI Emoji",\n "Segoe UI Symbol",\n "Noto Color Emoji";\n --pbf-font-mono:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n Monaco,\n Consolas,\n "Liberation Mono",\n "Courier New",\n monospace;\n --pbf-color-green-400: oklch(79.2% 0.209 151.711);\n --pbf-color-green-500: oklch(72.3% 0.219 149.579);\n --pbf-color-emerald-600: oklch(59.6% 0.145 163.225);\n --pbf-color-teal-700: oklch(51.1% 0.096 186.391);\n --pbf-color-sky-50: oklch(97.7% 0.013 236.62);\n --pbf-color-blue-500: oklch(62.3% 0.214 259.815);\n --pbf-color-blue-600: oklch(54.6% 0.245 262.881);\n --pbf-color-slate-50: oklch(98.4% 0.003 247.858);\n --pbf-color-slate-100: oklch(96.8% 0.007 247.896);\n --pbf-color-slate-300: oklch(86.9% 0.022 252.894);\n --pbf-color-slate-400: oklch(70.4% 0.04 256.788);\n --pbf-color-slate-600: oklch(44.6% 0.043 257.281);\n --pbf-color-slate-700: oklch(37.2% 0.044 257.287);\n --pbf-color-slate-800: oklch(27.9% 0.041 260.031);\n --pbf-color-slate-900: oklch(20.8% 0.042 265.755);\n --pbf-color-gray-50: oklch(98.5% 0.002 247.839);\n --pbf-color-gray-100: oklch(96.7% 0.003 264.542);\n --pbf-color-gray-200: oklch(92.8% 0.006 264.531);\n --pbf-color-gray-500: oklch(55.1% 0.027 264.364);\n --pbf-color-black: #000;\n --pbf-color-white: #fff;\n --pbf-spacing: 0.25rem;\n --pbf-container-lg: 32rem;\n --pbf-container-xl: 36rem;\n --pbf-text-xs: 0.75rem;\n --pbf-text-xs--line-height: calc(1 / 0.75);\n --pbf-text-sm: 0.875rem;\n --pbf-text-sm--line-height: calc(1.25 / 0.875);\n --pbf-text-lg: 1.125rem;\n --pbf-text-lg--line-height: calc(1.75 / 1.125);\n --pbf-text-2xl: 1.5rem;\n --pbf-text-2xl--line-height: calc(2 / 1.5);\n --pbf-text-4xl: 2.25rem;\n --pbf-text-4xl--line-height: calc(2.5 / 2.25);\n --pbf-font-weight-medium: 500;\n --pbf-font-weight-semibold: 600;\n --pbf-font-weight-bold: 700;\n --pbf-tracking-tight: -0.025em;\n --pbf-tracking-wide: 0.025em;\n --pbf-tracking-wider: 0.05em;\n --pbf-leading-tight: 1.25;\n --pbf-radius-md: 0.375rem;\n --pbf-radius-lg: 0.5rem;\n --pbf-ease-out: cubic-bezier(0, 0, 0.2, 1);\n --pbf-animate-ping: ping 1s cubic-bezier(0, 0, 0.2, 1) infinite;\n --pbf-default-transition-duration: 150ms;\n --pbf-default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);\n --pbf-default-font-family: var(--pbf-font-sans);\n --pbf-default-mono-font-family: var(--pbf-font-mono);\n }\n}\n@layer base {\n *,\n ::after,\n ::before,\n ::backdrop,\n ::file-selector-button {\n box-sizing: border-box;\n margin: 0;\n padding: 0;\n border: 0 solid;\n }\n html,\n :host {\n line-height: 1.5;\n -webkit-text-size-adjust: 100%;\n tab-size: 4;\n font-family: var(--pbf-default-font-family, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji");\n font-feature-settings: var(--pbf-default-font-feature-settings, normal);\n font-variation-settings: var(--pbf-default-font-variation-settings, normal);\n -webkit-tap-highlight-color: transparent;\n }\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n abbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n }\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n }\n a {\n color: inherit;\n -webkit-text-decoration: inherit;\n text-decoration: inherit;\n }\n b,\n strong {\n font-weight: bolder;\n }\n code,\n kbd,\n samp,\n pre {\n font-family: var(--pbf-default-mono-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);\n font-feature-settings: var(--pbf-default-mono-font-feature-settings, normal);\n font-variation-settings: var(--pbf-default-mono-font-variation-settings, normal);\n font-size: 1em;\n }\n small {\n font-size: 80%;\n }\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n sub {\n bottom: -0.25em;\n }\n sup {\n top: -0.5em;\n }\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n :-moz-focusring:where(:not(iframe)) {\n outline: auto;\n }\n progress {\n vertical-align: baseline;\n }\n summary {\n display: list-item;\n }\n ol,\n ul,\n menu {\n list-style: none;\n }\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n vertical-align: middle;\n }\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n button,\n input,\n select,\n optgroup,\n textarea,\n ::file-selector-button {\n font: inherit;\n font-feature-settings: inherit;\n font-variation-settings: inherit;\n letter-spacing: inherit;\n color: inherit;\n border-radius: 0;\n background-color: transparent;\n opacity: 1;\n }\n :where(select:is([multiple], [size])) optgroup {\n font-weight: bolder;\n }\n :where(select:is([multiple], [size])) optgroup option {\n padding-inline-start: 20px;\n }\n ::file-selector-button {\n margin-inline-end: 4px;\n }\n ::placeholder {\n opacity: 1;\n }\n @supports (not (-webkit-appearance: -apple-pay-button)) or (contain-intrinsic-size: 1px) {\n ::placeholder {\n color: currentcolor;\n @supports (color: color-mix(in lab, red, red)) {\n color: color-mix(in oklab, currentcolor 50%, transparent);\n }\n }\n }\n textarea {\n resize: vertical;\n }\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n ::-webkit-date-and-time-value {\n min-height: 1lh;\n text-align: inherit;\n }\n ::-webkit-datetime-edit {\n display: inline-flex;\n }\n ::-webkit-datetime-edit-fields-wrapper {\n padding: 0;\n }\n ::-webkit-datetime-edit,\n ::-webkit-datetime-edit-year-field,\n ::-webkit-datetime-edit-month-field,\n ::-webkit-datetime-edit-day-field,\n ::-webkit-datetime-edit-hour-field,\n ::-webkit-datetime-edit-minute-field,\n ::-webkit-datetime-edit-second-field,\n ::-webkit-datetime-edit-millisecond-field,\n ::-webkit-datetime-edit-meridiem-field {\n padding-block: 0;\n }\n ::-webkit-calendar-picker-indicator {\n line-height: 1;\n }\n :-moz-ui-invalid {\n box-shadow: none;\n }\n button,\n input:where([type=button], [type=reset], [type=submit]),\n ::file-selector-button {\n appearance: button;\n }\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n [hidden]:where(:not([hidden=until-found])) {\n display: none !important;\n }\n}\n@layer utilities {\n .pbf\\:pointer-events-none {\n pointer-events: none;\n }\n .pbf\\:absolute {\n position: absolute;\n }\n .pbf\\:fixed {\n position: fixed;\n }\n .pbf\\:relative {\n position: relative;\n }\n .pbf\\:top-1\\/3 {\n top: calc(1 / 3 * 100%);\n }\n .pbf\\:top-4 {\n top: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:left-1\\/2 {\n left: calc(1 / 2 * 100%);\n }\n .pbf\\:z-50 {\n z-index: 50;\n }\n .pbf\\:m-4 {\n margin: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:my-2 {\n margin-block: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:mt-1 {\n margin-top: var(--pbf-spacing);\n }\n .pbf\\:mt-2 {\n margin-top: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:mt-4 {\n margin-top: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:mt-48 {\n margin-top: calc(var(--pbf-spacing) * 48);\n }\n .pbf\\:mb-0 {\n margin-bottom: 0px;\n }\n .pbf\\:mb-1 {\n margin-bottom: var(--pbf-spacing);\n }\n .pbf\\:mb-1\\.5 {\n margin-bottom: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:mb-2 {\n margin-bottom: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:block {\n display: block;\n }\n .pbf\\:flex {\n display: flex;\n }\n .pbf\\:grid {\n display: grid;\n }\n .pbf\\:inline-flex {\n display: inline-flex;\n }\n .pbf\\:h-2 {\n height: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:h-3 {\n height: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:h-3\\.5 {\n height: calc(var(--pbf-spacing) * 3.5);\n }\n .pbf\\:h-4 {\n height: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:h-5 {\n height: calc(var(--pbf-spacing) * 5);\n }\n .pbf\\:h-6 {\n height: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:h-8 {\n height: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:h-16 {\n height: calc(var(--pbf-spacing) * 16);\n }\n .pbf\\:h-20 {\n height: calc(var(--pbf-spacing) * 20);\n }\n .pbf\\:h-full {\n height: 100%;\n }\n .pbf\\:max-h-32 {\n max-height: calc(var(--pbf-spacing) * 32);\n }\n .pbf\\:\\!w-auto {\n width: auto !important;\n }\n .pbf\\:w-2 {\n width: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:w-3 {\n width: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:w-3\\.5 {\n width: calc(var(--pbf-spacing) * 3.5);\n }\n .pbf\\:w-5 {\n width: calc(var(--pbf-spacing) * 5);\n }\n .pbf\\:w-8 {\n width: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:w-14 {\n width: calc(var(--pbf-spacing) * 14);\n }\n .pbf\\:w-16 {\n width: calc(var(--pbf-spacing) * 16);\n }\n .pbf\\:w-20 {\n width: calc(var(--pbf-spacing) * 20);\n }\n .pbf\\:w-24 {\n width: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:w-\\[80\\%\\] {\n width: 80%;\n }\n .pbf\\:w-full {\n width: 100%;\n }\n .pbf\\:max-w-lg {\n max-width: var(--pbf-container-lg);\n }\n .pbf\\:max-w-xl {\n max-width: var(--pbf-container-xl);\n }\n .pbf\\:min-w-0 {\n min-width: 0px;\n }\n .pbf\\:min-w-\\[260px\\] {\n min-width: 260px;\n }\n .pbf\\:min-w-fit {\n min-width: fit-content;\n }\n .pbf\\:flex-1 {\n flex: 1;\n }\n .pbf\\:shrink-0 {\n flex-shrink: 0;\n }\n .pbf\\:-translate-x-1\\/2 {\n --tw-translate-x: calc(calc(1 / 2 * 100%) * -1);\n translate: var(--tw-translate-x) var(--tw-translate-y);\n }\n .pbf\\:rotate-0 {\n rotate: 0deg;\n }\n .pbf\\:rotate-90 {\n rotate: 90deg;\n }\n .pbf\\:rotate-180 {\n rotate: 180deg;\n }\n .pbf\\:rotate-270 {\n rotate: 270deg;\n }\n .pbf\\:animate-ping {\n animation: var(--pbf-animate-ping);\n }\n .pbf\\:cursor-pointer {\n cursor: pointer;\n }\n .pbf\\:grid-cols-1 {\n grid-template-columns: repeat(1, minmax(0, 1fr));\n }\n .pbf\\:grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .pbf\\:flex-col {\n flex-direction: column;\n }\n .pbf\\:flex-row {\n flex-direction: row;\n }\n .pbf\\:flex-wrap {\n flex-wrap: wrap;\n }\n .pbf\\:items-center {\n align-items: center;\n }\n .pbf\\:items-start {\n align-items: flex-start;\n }\n .pbf\\:justify-around {\n justify-content: space-around;\n }\n .pbf\\:justify-between {\n justify-content: space-between;\n }\n .pbf\\:justify-center {\n justify-content: center;\n }\n .pbf\\:gap-0\\.5 {\n gap: calc(var(--pbf-spacing) * 0.5);\n }\n .pbf\\:gap-1 {\n gap: var(--pbf-spacing);\n }\n .pbf\\:gap-1\\.5 {\n gap: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:gap-2 {\n gap: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:gap-3 {\n gap: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:gap-4 {\n gap: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:gap-8 {\n gap: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:gap-16 {\n gap: calc(var(--pbf-spacing) * 16);\n }\n :where(.pbf\\:space-y-3 > :not(:last-child)) {\n --tw-space-y-reverse: 0;\n margin-block-start: calc(calc(var(--pbf-spacing) * 3) * var(--tw-space-y-reverse));\n margin-block-end: calc(calc(var(--pbf-spacing) * 3) * calc(1 - var(--tw-space-y-reverse)));\n }\n :where(.pbf\\:space-y-4 > :not(:last-child)) {\n --tw-space-y-reverse: 0;\n margin-block-start: calc(calc(var(--pbf-spacing) * 4) * var(--tw-space-y-reverse));\n margin-block-end: calc(calc(var(--pbf-spacing) * 4) * calc(1 - var(--tw-space-y-reverse)));\n }\n .pbf\\:gap-x-4 {\n column-gap: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:gap-y-2 {\n row-gap: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:overflow-hidden {\n overflow: hidden;\n }\n .pbf\\:overflow-y-auto {\n overflow-y: auto;\n }\n .pbf\\:rounded {\n border-radius: 0.25rem;\n }\n .pbf\\:rounded-full {\n border-radius: calc(infinity * 1px);\n }\n .pbf\\:rounded-lg {\n border-radius: var(--pbf-radius-lg);\n }\n .pbf\\:rounded-r-md {\n border-top-right-radius: var(--pbf-radius-md);\n border-bottom-right-radius: var(--pbf-radius-md);\n }\n .pbf\\:rounded-b-full {\n border-bottom-right-radius: calc(infinity * 1px);\n border-bottom-left-radius: calc(infinity * 1px);\n }\n .pbf\\:border {\n border-style: var(--tw-border-style);\n border-width: 1px;\n }\n .pbf\\:border-t {\n border-top-style: var(--tw-border-style);\n border-top-width: 1px;\n }\n .pbf\\:border-b {\n border-bottom-style: var(--tw-border-style);\n border-bottom-width: 1px;\n }\n .pbf\\:border-l-2 {\n border-left-style: var(--tw-border-style);\n border-left-width: 2px;\n }\n .pbf\\:border-gray-100 {\n border-color: var(--pbf-color-gray-100);\n }\n .pbf\\:border-gray-200 {\n border-color: var(--pbf-color-gray-200);\n }\n .pbf\\:border-teal-700\\/30 {\n border-color: var(--pbf-color-teal-700);\n @supports (color: color-mix(in lab, red, red)) {\n border-color: color-mix(in oklab, var(--pbf-color-teal-700) 30%, transparent);\n }\n }\n .pbf\\:bg-black {\n background-color: var(--pbf-color-black);\n }\n .pbf\\:bg-blue-500 {\n background-color: var(--pbf-color-blue-500);\n }\n .pbf\\:bg-emerald-600 {\n background-color: var(--pbf-color-emerald-600);\n }\n .pbf\\:bg-gray-50 {\n background-color: var(--pbf-color-gray-50);\n }\n .pbf\\:bg-gray-200 {\n background-color: var(--pbf-color-gray-200);\n }\n .pbf\\:bg-green-400 {\n background-color: var(--pbf-color-green-400);\n }\n .pbf\\:bg-green-500 {\n background-color: var(--pbf-color-green-500);\n }\n .pbf\\:bg-sky-50 {\n background-color: var(--pbf-color-sky-50);\n }\n .pbf\\:bg-slate-50 {\n background-color: var(--pbf-color-slate-50);\n }\n .pbf\\:bg-slate-100 {\n background-color: var(--pbf-color-slate-100);\n }\n .pbf\\:bg-slate-300 {\n background-color: var(--pbf-color-slate-300);\n }\n .pbf\\:bg-slate-400 {\n background-color: var(--pbf-color-slate-400);\n }\n .pbf\\:bg-slate-900 {\n background-color: var(--pbf-color-slate-900);\n }\n .pbf\\:bg-white {\n background-color: var(--pbf-color-white);\n }\n .pbf\\:object-contain {\n object-fit: contain;\n }\n .pbf\\:p-1\\.5 {\n padding: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:p-2 {\n padding: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:p-4 {\n padding: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:p-6 {\n padding: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:p-8 {\n padding: calc(var(--pbf-spacing) * 8);\n }\n .pbf\\:px-3 {\n padding-inline: calc(var(--pbf-spacing) * 3);\n }\n .pbf\\:px-4 {\n padding-inline: calc(var(--pbf-spacing) * 4);\n }\n .pbf\\:px-12 {\n padding-inline: calc(var(--pbf-spacing) * 12);\n }\n .pbf\\:py-0\\.5 {\n padding-block: calc(var(--pbf-spacing) * 0.5);\n }\n .pbf\\:py-1\\.5 {\n padding-block: calc(var(--pbf-spacing) * 1.5);\n }\n .pbf\\:py-2 {\n padding-block: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:pt-1 {\n padding-top: var(--pbf-spacing);\n }\n .pbf\\:pt-2 {\n padding-top: calc(var(--pbf-spacing) * 2);\n }\n .pbf\\:text-center {\n text-align: center;\n }\n .pbf\\:font-mono {\n font-family: var(--pbf-font-mono);\n }\n .pbf\\:font-sans {\n font-family: var(--pbf-font-sans);\n }\n .pbf\\:text-2xl {\n font-size: var(--pbf-text-2xl);\n line-height: var(--tw-leading, var(--pbf-text-2xl--line-height));\n }\n .pbf\\:text-4xl {\n font-size: var(--pbf-text-4xl);\n line-height: var(--tw-leading, var(--pbf-text-4xl--line-height));\n }\n .pbf\\:text-lg {\n font-size: var(--pbf-text-lg);\n line-height: var(--tw-leading, var(--pbf-text-lg--line-height));\n }\n .pbf\\:text-sm {\n font-size: var(--pbf-text-sm);\n line-height: var(--tw-leading, var(--pbf-text-sm--line-height));\n }\n .pbf\\:text-xs {\n font-size: var(--pbf-text-xs);\n line-height: var(--tw-leading, var(--pbf-text-xs--line-height));\n }\n .pbf\\:text-\\[9px\\] {\n font-size: 9px;\n }\n .pbf\\:text-\\[11px\\] {\n font-size: 11px;\n }\n .pbf\\:leading-6 {\n --tw-leading: calc(var(--pbf-spacing) * 6);\n line-height: calc(var(--pbf-spacing) * 6);\n }\n .pbf\\:leading-tight {\n --tw-leading: var(--pbf-leading-tight);\n line-height: var(--pbf-leading-tight);\n }\n .pbf\\:font-bold {\n --tw-font-weight: var(--pbf-font-weight-bold);\n font-weight: var(--pbf-font-weight-bold);\n }\n .pbf\\:font-medium {\n --tw-font-weight: var(--pbf-font-weight-medium);\n font-weight: var(--pbf-font-weight-medium);\n }\n .pbf\\:font-semibold {\n --tw-font-weight: var(--pbf-font-weight-semibold);\n font-weight: var(--pbf-font-weight-semibold);\n }\n .pbf\\:tracking-\\[0\\.2em\\] {\n --tw-tracking: 0.2em;\n letter-spacing: 0.2em;\n }\n .pbf\\:tracking-tight {\n --tw-tracking: var(--pbf-tracking-tight);\n letter-spacing: var(--pbf-tracking-tight);\n }\n .pbf\\:tracking-wide {\n --tw-tracking: var(--pbf-tracking-wide);\n letter-spacing: var(--pbf-tracking-wide);\n }\n .pbf\\:tracking-wider {\n --tw-tracking: var(--pbf-tracking-wider);\n letter-spacing: var(--pbf-tracking-wider);\n }\n .pbf\\:break-words {\n overflow-wrap: break-word;\n }\n .pbf\\:whitespace-nowrap {\n white-space: nowrap;\n }\n .pbf\\:text-blue-600 {\n color: var(--pbf-color-blue-600);\n }\n .pbf\\:text-gray-500 {\n color: var(--pbf-color-gray-500);\n }\n .pbf\\:text-slate-600 {\n color: var(--pbf-color-slate-600);\n }\n .pbf\\:text-slate-700 {\n color: var(--pbf-color-slate-700);\n }\n .pbf\\:text-slate-800 {\n color: var(--pbf-color-slate-800);\n }\n .pbf\\:text-slate-900 {\n color: var(--pbf-color-slate-900);\n }\n .pbf\\:text-teal-700 {\n color: var(--pbf-color-teal-700);\n }\n .pbf\\:text-white {\n color: var(--pbf-color-white);\n }\n .pbf\\:uppercase {\n text-transform: uppercase;\n }\n .pbf\\:italic {\n font-style: italic;\n }\n .pbf\\:opacity-75 {\n opacity: 75%;\n }\n .pbf\\:opacity-90 {\n opacity: 90%;\n }\n .pbf\\:shadow-lg {\n --tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow),\n var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow),\n var(--tw-ring-shadow),\n var(--tw-shadow);\n }\n .pbf\\:shadow-xl {\n --tw-shadow: 0 20px 25px -5px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 8px 10px -6px var(--tw-shadow-color, rgb(0 0 0 / 0.1));\n box-shadow:\n var(--tw-inset-shadow),\n var(--tw-inset-ring-shadow),\n var(--tw-ring-offset-shadow),\n var(--tw-ring-shadow),\n var(--tw-shadow);\n }\n .pbf\\:transition-all {\n transition-property: all;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:transition-colors {\n transition-property:\n color,\n background-color,\n border-color,\n outline-color,\n text-decoration-color,\n fill,\n stroke,\n --tw-gradient-from,\n --tw-gradient-via,\n --tw-gradient-to;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:transition-transform {\n transition-property:\n transform,\n translate,\n scale,\n rotate;\n transition-timing-function: var(--tw-ease, var(--pbf-default-transition-timing-function));\n transition-duration: var(--tw-duration, var(--pbf-default-transition-duration));\n }\n .pbf\\:duration-75 {\n --tw-duration: 75ms;\n transition-duration: 75ms;\n }\n .pbf\\:duration-150 {\n --tw-duration: 150ms;\n transition-duration: 150ms;\n }\n .pbf\\:duration-200 {\n --tw-duration: 200ms;\n transition-duration: 200ms;\n }\n .pbf\\:duration-300 {\n --tw-duration: 300ms;\n transition-duration: 300ms;\n }\n .pbf\\:ease-out {\n --tw-ease: var(--pbf-ease-out);\n transition-timing-function: var(--pbf-ease-out);\n }\n .pbf\\:select-none {\n -webkit-user-select: none;\n user-select: none;\n }\n @media (hover: hover) {\n :is(:where(.pbf\\:group):hover .pbf\\:group-hover\\:scale-110) {\n --tw-scale-x: 110%;\n --tw-scale-y: 110%;\n --tw-scale-z: 110%;\n scale: var(--tw-scale-x) var(--tw-scale-y);\n }\n }\n .pbf\\:last\\:border-0:last-child {\n border-style: var(--tw-border-style);\n border-width: 0px;\n }\n @media (hover: hover) {\n .pbf\\:hover\\:opacity-100:hover {\n opacity: 100%;\n }\n }\n .pbf\\:focus-visible\\:outline-none:focus-visible {\n --tw-outline-style: none;\n outline-style: none;\n }\n @media (width >= 48rem) {\n .pbf\\:md\\:h-12 {\n height: calc(var(--pbf-spacing) * 12);\n }\n .pbf\\:md\\:h-24 {\n height: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:md\\:h-28 {\n height: calc(var(--pbf-spacing) * 28);\n }\n .pbf\\:md\\:w-24 {\n width: calc(var(--pbf-spacing) * 24);\n }\n .pbf\\:md\\:w-28 {\n width: calc(var(--pbf-spacing) * 28);\n }\n .pbf\\:md\\:w-32 {\n width: calc(var(--pbf-spacing) * 32);\n }\n .pbf\\:md\\:grid-cols-2 {\n grid-template-columns: repeat(2, minmax(0, 1fr));\n }\n .pbf\\:md\\:gap-24 {\n gap: calc(var(--pbf-spacing) * 24);\n }\n }\n @media (width >= 64rem) {\n .pbf\\:lg\\:grid-cols-3 {\n grid-template-columns: repeat(3, minmax(0, 1fr));\n }\n .pbf\\:lg\\:gap-6 {\n gap: calc(var(--pbf-spacing) * 6);\n }\n }\n .pbf\\:rtl\\:border-r-2:where(:dir(rtl), [dir=rtl], [dir=rtl] *) {\n border-right-style: var(--tw-border-style);\n border-right-width: 2px;\n }\n .pbf\\:rtl\\:border-l-0:where(:dir(rtl), [dir=rtl], [dir=rtl] *) {\n border-left-style: var(--tw-border-style);\n border-left-width: 0px;\n }\n}\n@property --tw-translate-x { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-translate-y { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-translate-z { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-space-y-reverse { syntax: "*"; inherits: false; initial-value: 0; }\n@property --tw-border-style { syntax: "*"; inherits: false; initial-value: solid; }\n@property --tw-leading { syntax: "*"; inherits: false; }\n@property --tw-font-weight { syntax: "*"; inherits: false; }\n@property --tw-tracking { syntax: "*"; inherits: false; }\n@property --tw-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-shadow-color { syntax: "*"; inherits: false; }\n@property --tw-shadow-alpha { syntax: "<percentage>"; inherits: false; initial-value: 100%; }\n@property --tw-inset-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-inset-shadow-color { syntax: "*"; inherits: false; }\n@property --tw-inset-shadow-alpha { syntax: "<percentage>"; inherits: false; initial-value: 100%; }\n@property --tw-ring-color { syntax: "*"; inherits: false; }\n@property --tw-ring-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-inset-ring-color { syntax: "*"; inherits: false; }\n@property --tw-inset-ring-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-ring-inset { syntax: "*"; inherits: false; }\n@property --tw-ring-offset-width { syntax: "<length>"; inherits: false; initial-value: 0px; }\n@property --tw-ring-offset-color { syntax: "*"; inherits: false; initial-value: #fff; }\n@property --tw-ring-offset-shadow { syntax: "*"; inherits: false; initial-value: 0 0 #0000; }\n@property --tw-duration { syntax: "*"; inherits: false; }\n@property --tw-ease { syntax: "*"; inherits: false; }\n@property --tw-scale-x { syntax: "*"; inherits: false; initial-value: 1; }\n@property --tw-scale-y { syntax: "*"; inherits: false; initial-value: 1; }\n@property --tw-scale-z { syntax: "*"; inherits: false; initial-value: 1; }\n@keyframes ping {\n 75%, 100% {\n transform: scale(2);\n opacity: 0;\n }\n}\n@layer properties {\n @supports ((-webkit-hyphens: none) and (not (margin-trim: block))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {\n *,\n ::before,\n ::after,\n ::backdrop {\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-translate-z: 0;\n --tw-space-y-reverse: 0;\n --tw-border-style: solid;\n --tw-leading: initial;\n --tw-font-weight: initial;\n --tw-tracking: initial;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-color: initial;\n --tw-shadow-alpha: 100%;\n --tw-inset-shadow: 0 0 #0000;\n --tw-inset-shadow-color: initial;\n --tw-inset-shadow-alpha: 100%;\n --tw-ring-color: initial;\n --tw-ring-shadow: 0 0 #0000;\n --tw-inset-ring-color: initial;\n --tw-inset-ring-shadow: 0 0 #0000;\n --tw-ring-inset: initial;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-duration: initial;\n --tw-ease: initial;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-scale-z: 1;\n }\n }\n}\n', { insertAt: "top" });
|
|
93
|
+
|
|
94
|
+
// src/types/renderer.ts
|
|
95
|
+
var FaceRendererRegistry = class {
|
|
96
|
+
strategies = /* @__PURE__ */ new Map();
|
|
97
|
+
constructor(initialStrategies = []) {
|
|
98
|
+
for (const strategy of initialStrategies) {
|
|
99
|
+
this.register(strategy);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
register(strategy) {
|
|
103
|
+
this.strategies.set(strategy.kind, strategy);
|
|
104
|
+
}
|
|
105
|
+
unregister(kind) {
|
|
106
|
+
return this.strategies.delete(kind);
|
|
107
|
+
}
|
|
108
|
+
get(kind) {
|
|
109
|
+
return this.strategies.get(kind);
|
|
110
|
+
}
|
|
111
|
+
has(kind) {
|
|
112
|
+
return this.strategies.has(kind);
|
|
113
|
+
}
|
|
114
|
+
list() {
|
|
115
|
+
return Array.from(this.strategies.values());
|
|
116
|
+
}
|
|
117
|
+
getCapabilities(face) {
|
|
118
|
+
if (!face) {
|
|
119
|
+
return getFaceCapabilities(void 0);
|
|
120
|
+
}
|
|
121
|
+
const strategy = this.strategies.get(face.kind);
|
|
122
|
+
if (strategy?.getCapabilities) {
|
|
123
|
+
return strategy.getCapabilities(face);
|
|
124
|
+
}
|
|
125
|
+
return getFaceCapabilities(face);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// src/helpers/environment.ts
|
|
130
|
+
function isWebGLAvailable() {
|
|
131
|
+
if (typeof window === "undefined" || typeof document === "undefined") {
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const canvas = document.createElement("canvas");
|
|
136
|
+
const gl = canvas.getContext("webgl2") || canvas.getContext("webgl") || canvas.getContext("experimental-webgl");
|
|
137
|
+
return Boolean(gl);
|
|
138
|
+
} catch (err) {
|
|
139
|
+
void err;
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function isHeadlessOrTestEnvironment() {
|
|
144
|
+
if (typeof window === "undefined" || typeof navigator === "undefined") {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
const ua = navigator.userAgent || "";
|
|
148
|
+
if (ua.includes("peerbots-pa11y-ci") || ua.toLowerCase().includes("jsdom") || Boolean(navigator.webdriver) || Boolean(window.__VITEST_BROWSER__)) {
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
return !isWebGLAvailable();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/components/FaceView.tsx
|
|
155
|
+
import { lazy, Suspense } from "react";
|
|
156
|
+
|
|
157
|
+
// src/helpers/cn.ts
|
|
158
|
+
import { clsx } from "clsx";
|
|
159
|
+
import { extendTailwindMerge } from "tailwind-merge";
|
|
160
|
+
var faceTwMerge = extendTailwindMerge({
|
|
161
|
+
experimentalParseClassName({ className, parseClassName }) {
|
|
162
|
+
if (className.startsWith("pbf:")) {
|
|
163
|
+
return parseClassName(className.slice(4));
|
|
164
|
+
}
|
|
165
|
+
if (className.startsWith("pb:")) {
|
|
166
|
+
return parseClassName(className.slice(3));
|
|
167
|
+
}
|
|
168
|
+
return parseClassName(className);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
function faceCn(...inputs) {
|
|
172
|
+
return faceTwMerge(clsx(inputs));
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// src/components/FaceCaption.tsx
|
|
176
|
+
import { useEffect } from "react";
|
|
177
|
+
import { jsx } from "react/jsx-runtime";
|
|
178
|
+
function FaceCaption() {
|
|
179
|
+
const lastMessage = useFaceStore((state) => state.lastMessage);
|
|
180
|
+
const settings = useFaceStore((state) => state.faceSettings);
|
|
181
|
+
const isSpeaking = useFaceStore((state) => state.isSpeaking);
|
|
182
|
+
const { displayText, queueMessage, update } = useMessageVisualState(
|
|
183
|
+
isSpeaking,
|
|
184
|
+
{
|
|
185
|
+
msPerChar: 0,
|
|
186
|
+
persistenceDuration: 1e3
|
|
187
|
+
}
|
|
188
|
+
);
|
|
189
|
+
useEffect(() => {
|
|
190
|
+
queueMessage(lastMessage.speech);
|
|
191
|
+
}, [lastMessage.speech, queueMessage]);
|
|
192
|
+
useEffect(() => {
|
|
193
|
+
if (typeof requestAnimationFrame === "undefined") {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
let lastTime = performance.now();
|
|
197
|
+
let frameId;
|
|
198
|
+
const tick = (now) => {
|
|
199
|
+
const delta = now - lastTime;
|
|
200
|
+
lastTime = now;
|
|
201
|
+
update(delta);
|
|
202
|
+
frameId = requestAnimationFrame(tick);
|
|
203
|
+
};
|
|
204
|
+
frameId = requestAnimationFrame(tick);
|
|
205
|
+
return () => cancelAnimationFrame(frameId);
|
|
206
|
+
}, [update]);
|
|
207
|
+
if (!settings.captions || !settings.captions.enabled) {
|
|
208
|
+
return null;
|
|
209
|
+
}
|
|
210
|
+
if (!displayText || displayText.trim() === "") {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
const offsetX = settings.captions.offset?.x ?? 0;
|
|
214
|
+
const offsetY = settings.captions.offset?.y ?? 0;
|
|
215
|
+
const fontSize = settings.captions.fontSize ?? 32;
|
|
216
|
+
return /* @__PURE__ */ jsx(
|
|
217
|
+
"div",
|
|
218
|
+
{
|
|
219
|
+
role: "status",
|
|
220
|
+
"aria-live": "polite",
|
|
221
|
+
"data-testid": "face-caption",
|
|
222
|
+
className: "pbf:absolute pbf:text-center pbf:w-[80%] pbf:pointer-events-none pbf:z-50 pbf:font-sans",
|
|
223
|
+
style: {
|
|
224
|
+
top: `calc(${offsetY}% + 80%)`,
|
|
225
|
+
left: `calc(50% + ${offsetX}px)`,
|
|
226
|
+
transform: "translate(-50%, -50%)",
|
|
227
|
+
fontSize: `${fontSize}px`,
|
|
228
|
+
color: "#ffffff",
|
|
229
|
+
backgroundColor: "rgba(15, 23, 42, 0.75)",
|
|
230
|
+
padding: "0.25rem 0.75rem",
|
|
231
|
+
borderRadius: "0.75rem"
|
|
232
|
+
},
|
|
233
|
+
children: displayText
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// src/components/FaceViewSkeleton.tsx
|
|
239
|
+
import { Skeleton } from "@peerbots/core";
|
|
240
|
+
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
241
|
+
function FaceViewSkeleton({
|
|
242
|
+
label = "Loading robot face"
|
|
243
|
+
} = {}) {
|
|
244
|
+
return /* @__PURE__ */ jsxs(
|
|
245
|
+
"div",
|
|
246
|
+
{
|
|
247
|
+
role: "status",
|
|
248
|
+
"aria-label": label,
|
|
249
|
+
"data-testid": "face-view-skeleton",
|
|
250
|
+
className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:bg-sky-50 pbf:p-8 pbf:relative",
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ jsxs("div", { className: "pbf:flex pbf:w-[80%] pbf:max-w-lg pbf:min-w-[260px] pbf:justify-around pbf:absolute pbf:top-1/3 pbf:px-12", children: [
|
|
253
|
+
/* @__PURE__ */ jsx2(Skeleton, { className: "pbf:w-16 pbf:h-16 pbf:md:w-24 pbf:md:h-24 pbf:rounded-full pbf:bg-slate-300" }),
|
|
254
|
+
/* @__PURE__ */ jsx2(Skeleton, { className: "pbf:w-16 pbf:h-16 pbf:md:w-24 pbf:md:h-24 pbf:rounded-full pbf:bg-slate-300" })
|
|
255
|
+
] }),
|
|
256
|
+
/* @__PURE__ */ jsx2("div", { className: "pbf:mt-48", children: /* @__PURE__ */ jsx2(Skeleton, { className: "pbf:w-24 pbf:h-6 pbf:md:w-32 pbf:md:h-12 pbf:rounded-full pbf:bg-slate-300" }) })
|
|
257
|
+
]
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
// src/components/StaticFaceFallback.tsx
|
|
263
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
264
|
+
function StaticFaceFallback({
|
|
265
|
+
showSprites = true,
|
|
266
|
+
className
|
|
267
|
+
}) {
|
|
268
|
+
const selectedFace = useFaceStore((state) => state.selectedFace);
|
|
269
|
+
const lastMessage = useFaceStore((state) => state.lastMessage);
|
|
270
|
+
const isSpeaking = useFaceStore((state) => state.isSpeaking);
|
|
271
|
+
const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
|
|
272
|
+
const faceSettings = useFaceStore((state) => state.faceSettings);
|
|
273
|
+
const bgColor = color_mapping[lastMessage.color] ?? color_mapping["Light Blue"];
|
|
274
|
+
const fgColor = font_color_mapping[lastMessage.color] ?? font_color_mapping["Light Blue"];
|
|
275
|
+
const accessibleLabel = `${selectedFace.name} robot face, emotion ${lastMessage.emotion}, color ${lastMessage.color}${isSpeaking ? ", speaking" : ""}`;
|
|
276
|
+
const pixiSettings = faceSettings.pixiSettings;
|
|
277
|
+
const isTextDisplay = selectedFace.kind === "PixiFace" && selectedFace.type === "text";
|
|
278
|
+
const isHugoStyleAvatar = selectedFace.kind === "PixiFace" && selectedFace.type === "avatar" && (selectedFace.name === "Hugo" || selectedFace.name === "Simple");
|
|
279
|
+
const eyePaths = getEmotionEyeSpritePaths(
|
|
280
|
+
lastMessage.emotion,
|
|
281
|
+
"Hugo",
|
|
282
|
+
assetBaseUrl
|
|
283
|
+
);
|
|
284
|
+
const emotionIconPath = getEmotionIconPath(lastMessage.emotion, assetBaseUrl);
|
|
285
|
+
const textEmotionMode = pixiSettings?.emotionDisplay ?? (isTextDisplay ? selectedFace.showEmotion : "emoticon");
|
|
286
|
+
return /* @__PURE__ */ jsx3(
|
|
287
|
+
"div",
|
|
288
|
+
{
|
|
289
|
+
role: "img",
|
|
290
|
+
"aria-label": accessibleLabel,
|
|
291
|
+
"data-testid": "static-face-fallback",
|
|
292
|
+
"data-face-name": selectedFace.name,
|
|
293
|
+
"data-face-kind": selectedFace.kind,
|
|
294
|
+
"data-emotion": lastMessage.emotion,
|
|
295
|
+
"data-color": lastMessage.color,
|
|
296
|
+
"data-speaking": String(isSpeaking),
|
|
297
|
+
className: faceCn(
|
|
298
|
+
"pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:p-6 pbf:select-none pbf:transition-colors pbf:duration-200",
|
|
299
|
+
className
|
|
300
|
+
),
|
|
301
|
+
style: {
|
|
302
|
+
backgroundColor: bgColor,
|
|
303
|
+
color: fgColor
|
|
304
|
+
},
|
|
305
|
+
children: isTextDisplay ? /* @__PURE__ */ jsxs2("div", { className: "pbf:flex pbf:flex-col pbf:items-center pbf:gap-3 pbf:font-mono pbf:text-center pbf:max-w-xl", children: [
|
|
306
|
+
textEmotionMode !== "none" && /* @__PURE__ */ jsx3("span", { className: "pbf:text-4xl pbf:font-bold", "aria-hidden": "true", children: textEmotionMode === "emoji" ? EMOTION_EMOJIS[lastMessage.emotion] : EMOTION_EMOTICONS[lastMessage.emotion] }),
|
|
307
|
+
lastMessage.speech && /* @__PURE__ */ jsx3("span", { className: "pbf:text-2xl pbf:font-semibold pbf:break-words", children: lastMessage.speech })
|
|
308
|
+
] }) : showSprites && isHugoStyleAvatar ? /* @__PURE__ */ jsxs2(
|
|
309
|
+
"div",
|
|
310
|
+
{
|
|
311
|
+
className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:gap-8",
|
|
312
|
+
"aria-hidden": "true",
|
|
313
|
+
children: [
|
|
314
|
+
pixiSettings?.eyeDisplay !== "none" && /* @__PURE__ */ jsxs2("div", { className: "pbf:flex pbf:items-center pbf:justify-center pbf:gap-16 pbf:md:gap-24", children: [
|
|
315
|
+
/* @__PURE__ */ jsxs2("div", { className: "pbf:flex pbf:flex-col pbf:items-center", children: [
|
|
316
|
+
/* @__PURE__ */ jsx3(
|
|
317
|
+
"img",
|
|
318
|
+
{
|
|
319
|
+
src: eyePaths.left,
|
|
320
|
+
alt: "",
|
|
321
|
+
className: "pbf:w-20 pbf:h-20 pbf:md:w-28 pbf:md:h-28 pbf:object-contain"
|
|
322
|
+
}
|
|
323
|
+
),
|
|
324
|
+
selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ jsx3(
|
|
325
|
+
"img",
|
|
326
|
+
{
|
|
327
|
+
src: selectedFace.cheeks.path,
|
|
328
|
+
alt: "",
|
|
329
|
+
className: "pbf:w-8 pbf:h-4 pbf:object-contain pbf:mt-1"
|
|
330
|
+
}
|
|
331
|
+
)
|
|
332
|
+
] }),
|
|
333
|
+
/* @__PURE__ */ jsxs2("div", { className: "pbf:flex pbf:flex-col pbf:items-center", children: [
|
|
334
|
+
/* @__PURE__ */ jsx3(
|
|
335
|
+
"img",
|
|
336
|
+
{
|
|
337
|
+
src: eyePaths.right,
|
|
338
|
+
alt: "",
|
|
339
|
+
className: "pbf:w-20 pbf:h-20 pbf:md:w-28 pbf:md:h-28 pbf:object-contain"
|
|
340
|
+
}
|
|
341
|
+
),
|
|
342
|
+
selectedFace.cheeks && pixiSettings?.cheekDisplay !== "none" && /* @__PURE__ */ jsx3(
|
|
343
|
+
"img",
|
|
344
|
+
{
|
|
345
|
+
src: selectedFace.cheeks.path,
|
|
346
|
+
alt: "",
|
|
347
|
+
className: "pbf:w-8 pbf:h-4 pbf:object-contain pbf:mt-1"
|
|
348
|
+
}
|
|
349
|
+
)
|
|
350
|
+
] })
|
|
351
|
+
] }),
|
|
352
|
+
pixiSettings?.mouthDisplay !== "none" && /* @__PURE__ */ jsx3(
|
|
353
|
+
"div",
|
|
354
|
+
{
|
|
355
|
+
className: faceCn(
|
|
356
|
+
"pbf:rounded-b-full pbf:bg-black pbf:transition-all pbf:duration-150",
|
|
357
|
+
isSpeaking ? "pbf:w-16 pbf:h-8" : "pbf:w-14 pbf:h-3"
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
]
|
|
362
|
+
}
|
|
363
|
+
) : /* @__PURE__ */ jsxs2(
|
|
364
|
+
"div",
|
|
365
|
+
{
|
|
366
|
+
className: "pbf:flex pbf:flex-col pbf:items-center pbf:justify-center pbf:gap-3",
|
|
367
|
+
"aria-hidden": "true",
|
|
368
|
+
children: [
|
|
369
|
+
showSprites && /* @__PURE__ */ jsx3(
|
|
370
|
+
"img",
|
|
371
|
+
{
|
|
372
|
+
src: emotionIconPath,
|
|
373
|
+
alt: "",
|
|
374
|
+
className: "pbf:w-20 pbf:h-20 pbf:object-contain"
|
|
375
|
+
}
|
|
376
|
+
),
|
|
377
|
+
/* @__PURE__ */ jsxs2("span", { className: "pbf:text-sm pbf:font-semibold pbf:tracking-wide", children: [
|
|
378
|
+
selectedFace.name,
|
|
379
|
+
" \u2022 ",
|
|
380
|
+
lastMessage.emotion
|
|
381
|
+
] })
|
|
382
|
+
]
|
|
383
|
+
}
|
|
384
|
+
)
|
|
385
|
+
}
|
|
386
|
+
);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// src/components/FaceView.tsx
|
|
390
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
391
|
+
var LazyPixiFaceView = lazy(
|
|
392
|
+
() => import("./pixi.js").then((module) => ({
|
|
393
|
+
default: module.PixiFaceView
|
|
394
|
+
}))
|
|
395
|
+
);
|
|
396
|
+
var LazyVizijFaceView = lazy(
|
|
397
|
+
() => import("./vizij.js").then((module) => ({
|
|
398
|
+
default: module.VizijFaceView
|
|
399
|
+
}))
|
|
400
|
+
);
|
|
401
|
+
var pixiFaceRendererStrategy = {
|
|
402
|
+
kind: "PixiFace",
|
|
403
|
+
displayName: "PixiJS 2D Face Renderer",
|
|
404
|
+
requiresWebGL: true,
|
|
405
|
+
getCapabilities: (face) => getFaceCapabilities(face),
|
|
406
|
+
render: ({ isPreview, frozen }) => /* @__PURE__ */ jsx4(LazyPixiFaceView, { isPreview, frozen })
|
|
407
|
+
};
|
|
408
|
+
var vizijFaceRendererStrategy = {
|
|
409
|
+
kind: "Vizij",
|
|
410
|
+
displayName: "Vizij 3D WebAssembly Face Renderer",
|
|
411
|
+
requiresWebGL: true,
|
|
412
|
+
getCapabilities: (face) => getFaceCapabilities(face),
|
|
413
|
+
render: () => /* @__PURE__ */ jsx4(LazyVizijFaceView, {})
|
|
414
|
+
};
|
|
415
|
+
function createDefaultFaceRendererRegistry() {
|
|
416
|
+
const registry = new FaceRendererRegistry();
|
|
417
|
+
registry.register(pixiFaceRendererStrategy);
|
|
418
|
+
registry.register(vizijFaceRendererStrategy);
|
|
419
|
+
return registry;
|
|
420
|
+
}
|
|
421
|
+
var defaultFaceRendererRegistry = createDefaultFaceRendererRegistry();
|
|
422
|
+
function FaceView({
|
|
423
|
+
isPreview = false,
|
|
424
|
+
frozen = false,
|
|
425
|
+
renderMode = "auto",
|
|
426
|
+
showStaticSprites = true,
|
|
427
|
+
registry = defaultFaceRendererRegistry,
|
|
428
|
+
labels,
|
|
429
|
+
className
|
|
430
|
+
} = {}) {
|
|
431
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
432
|
+
const selectedFace = useFaceStore((state) => state.selectedFace);
|
|
433
|
+
const strategy = selectedFace ? registry.get(selectedFace.kind) : void 0;
|
|
434
|
+
const renderContent = () => {
|
|
435
|
+
if (!selectedFace || !strategy) {
|
|
436
|
+
return /* @__PURE__ */ jsx4(
|
|
437
|
+
"div",
|
|
438
|
+
{
|
|
439
|
+
role: "alert",
|
|
440
|
+
className: "pbf:flex pbf:items-center pbf:justify-center pbf:w-full pbf:h-full pbf:bg-slate-100 pbf:text-slate-800 pbf:text-sm pbf:p-4",
|
|
441
|
+
children: uiLabels.unknownFaceType
|
|
442
|
+
}
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
const useStaticFallback = renderMode === "static" || renderMode === "auto" && strategy.requiresWebGL && isHeadlessOrTestEnvironment();
|
|
446
|
+
if (useStaticFallback) {
|
|
447
|
+
return /* @__PURE__ */ jsx4(StaticFaceFallback, { showSprites: showStaticSprites });
|
|
448
|
+
}
|
|
449
|
+
return /* @__PURE__ */ jsx4(Suspense, { fallback: /* @__PURE__ */ jsx4(FaceViewSkeleton, { label: uiLabels.loading }), children: strategy.render({ face: selectedFace, isPreview, frozen }) });
|
|
450
|
+
};
|
|
451
|
+
return /* @__PURE__ */ jsxs3(
|
|
452
|
+
"div",
|
|
453
|
+
{
|
|
454
|
+
id: "face-view-container",
|
|
455
|
+
className: faceCn(
|
|
456
|
+
"pbf:relative pbf:w-full pbf:h-full pbf:text-center pbf:overflow-hidden",
|
|
457
|
+
className
|
|
458
|
+
),
|
|
459
|
+
children: [
|
|
460
|
+
renderContent(),
|
|
461
|
+
!isPreview && /* @__PURE__ */ jsx4(FaceCaption, {})
|
|
462
|
+
]
|
|
463
|
+
}
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// src/components/FaceAudioPrompt.tsx
|
|
468
|
+
import { useCallback } from "react";
|
|
469
|
+
import { Button, Icon } from "@peerbots/core";
|
|
470
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
471
|
+
function FaceAudioPrompt({
|
|
472
|
+
className = "",
|
|
473
|
+
position = "absolute",
|
|
474
|
+
labels,
|
|
475
|
+
onEnable
|
|
476
|
+
}) {
|
|
477
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
478
|
+
const speechAllowed = useFaceStore((state) => state.speechAllowed);
|
|
479
|
+
const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
|
|
480
|
+
const refreshVoices = useFaceStore((state) => state.refreshVoices);
|
|
481
|
+
const handleEnableAudio = useCallback(() => {
|
|
482
|
+
try {
|
|
483
|
+
if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
|
|
484
|
+
const utterance = new SpeechSynthesisUtterance(" ");
|
|
485
|
+
window.speechSynthesis.speak(utterance);
|
|
486
|
+
}
|
|
487
|
+
} catch (err) {
|
|
488
|
+
console.warn("Could not prime speechSynthesis:", err);
|
|
489
|
+
}
|
|
490
|
+
setSpeechAllowed(true);
|
|
491
|
+
void refreshVoices();
|
|
492
|
+
onEnable?.();
|
|
493
|
+
}, [setSpeechAllowed, refreshVoices, onEnable]);
|
|
494
|
+
if (speechAllowed) {
|
|
495
|
+
return null;
|
|
496
|
+
}
|
|
497
|
+
const positionClasses = position === "fixed" ? "pbf:fixed pbf:top-4 pbf:left-1/2 pbf:-translate-x-1/2 pbf:z-50" : position === "absolute" ? "pbf:absolute pbf:top-4 pbf:left-1/2 pbf:-translate-x-1/2 pbf:z-50" : "pbf:inline-flex";
|
|
498
|
+
return /* @__PURE__ */ jsx5(
|
|
499
|
+
"div",
|
|
500
|
+
{
|
|
501
|
+
className: faceCn(positionClasses, className),
|
|
502
|
+
"data-testid": "face-audio-prompt",
|
|
503
|
+
children: /* @__PURE__ */ jsxs4(
|
|
504
|
+
Button,
|
|
505
|
+
{
|
|
506
|
+
variant: "solid",
|
|
507
|
+
color: "darkblue",
|
|
508
|
+
size: "sm",
|
|
509
|
+
onClick: handleEnableAudio,
|
|
510
|
+
className: "pbf:shadow-lg pbf:px-4 pbf:py-2 pbf:flex pbf:items-center pbf:gap-2 pbf:rounded-full pbf:cursor-pointer",
|
|
511
|
+
"aria-label": uiLabels.tapToEnableSound,
|
|
512
|
+
children: [
|
|
513
|
+
/* @__PURE__ */ jsx5(Icon, { name: "play", size: "sm", className: "pbf:w-3.5 pbf:h-3.5" }),
|
|
514
|
+
/* @__PURE__ */ jsx5("span", { className: "pbf:font-semibold pbf:text-xs pbf:tracking-wide", children: uiLabels.tapToEnableSound })
|
|
515
|
+
]
|
|
516
|
+
}
|
|
517
|
+
)
|
|
518
|
+
}
|
|
519
|
+
);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// src/components/PoweredByVizij.tsx
|
|
523
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
524
|
+
function PoweredByVizij({
|
|
525
|
+
className,
|
|
526
|
+
poweredByLabel = DEFAULT_FACE_UI_LABELS.poweredBy
|
|
527
|
+
}) {
|
|
528
|
+
const assetBaseUrl = useFaceStore((state) => state.assetBaseUrl);
|
|
529
|
+
return /* @__PURE__ */ jsxs5(
|
|
530
|
+
"a",
|
|
531
|
+
{
|
|
532
|
+
href: "https://vizij.ai",
|
|
533
|
+
target: "_blank",
|
|
534
|
+
rel: "noopener noreferrer",
|
|
535
|
+
className: faceCn(
|
|
536
|
+
"pbf:inline-flex pbf:flex-col pbf:items-center pbf:gap-0.5 pbf:group pbf:transition-all pbf:hover:opacity-100 pbf:opacity-90",
|
|
537
|
+
className
|
|
538
|
+
),
|
|
539
|
+
children: [
|
|
540
|
+
/* @__PURE__ */ jsx6("span", { className: "pbf:text-[9px] pbf:font-bold pbf:text-slate-600 pbf:uppercase pbf:tracking-[0.2em] pbf:leading-tight pbf:select-none", children: poweredByLabel }),
|
|
541
|
+
/* @__PURE__ */ jsxs5("div", { className: "pbf:flex pbf:items-center pbf:gap-1.5 pbf:focus-visible:outline-none", children: [
|
|
542
|
+
/* @__PURE__ */ jsx6("div", { className: "pbf:relative pbf:w-5 pbf:h-5 pbf:group-hover:scale-110 pbf:transition-transform pbf:duration-300 pbf:ease-out", children: /* @__PURE__ */ jsx6(
|
|
543
|
+
"img",
|
|
544
|
+
{
|
|
545
|
+
src: `${assetBaseUrl}/Vizij/brand.svg`,
|
|
546
|
+
alt: "Vizij Logo",
|
|
547
|
+
className: "pbf:w-full pbf:h-full pbf:object-contain"
|
|
548
|
+
}
|
|
549
|
+
) }),
|
|
550
|
+
/* @__PURE__ */ jsx6(
|
|
551
|
+
"span",
|
|
552
|
+
{
|
|
553
|
+
style: {
|
|
554
|
+
fontFamily: "Gilroy, SFProRounded, ui-sans-serif, system-ui, sans-serif"
|
|
555
|
+
},
|
|
556
|
+
className: "pbf:text-lg pbf:font-bold pbf:tracking-tight pbf:text-teal-700",
|
|
557
|
+
children: "vizij"
|
|
558
|
+
}
|
|
559
|
+
)
|
|
560
|
+
] })
|
|
561
|
+
]
|
|
562
|
+
}
|
|
563
|
+
);
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
// src/components/FieldGroup.tsx
|
|
567
|
+
import { useId } from "react";
|
|
568
|
+
import { jsx as jsx7, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
569
|
+
function FieldGroup({
|
|
570
|
+
label,
|
|
571
|
+
icon,
|
|
572
|
+
description,
|
|
573
|
+
children,
|
|
574
|
+
className,
|
|
575
|
+
id: customId
|
|
576
|
+
}) {
|
|
577
|
+
const generatedId = useId();
|
|
578
|
+
const labelId = customId || `field-group-${generatedId}`;
|
|
579
|
+
return /* @__PURE__ */ jsxs6(
|
|
580
|
+
"div",
|
|
581
|
+
{
|
|
582
|
+
role: "group",
|
|
583
|
+
"aria-labelledby": label ? labelId : void 0,
|
|
584
|
+
className: faceCn("pbf:flex pbf:flex-col pbf:gap-1.5 pbf:w-full", className),
|
|
585
|
+
children: [
|
|
586
|
+
label && /* @__PURE__ */ jsxs6(
|
|
587
|
+
"span",
|
|
588
|
+
{
|
|
589
|
+
id: labelId,
|
|
590
|
+
className: "pbf:text-sm pbf:font-bold pbf:leading-6 pbf:text-slate-700 pbf:flex pbf:items-center pbf:gap-1",
|
|
591
|
+
children: [
|
|
592
|
+
icon && /* @__PURE__ */ jsx7("span", { className: "pbf:shrink-0", children: icon }),
|
|
593
|
+
label
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
),
|
|
597
|
+
children,
|
|
598
|
+
description && /* @__PURE__ */ jsx7("span", { className: "pbf:text-xs pbf:text-slate-600", children: description })
|
|
599
|
+
]
|
|
600
|
+
}
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
// src/components/VoiceSelector.tsx
|
|
605
|
+
import { useMemo } from "react";
|
|
606
|
+
import { Select, Field } from "@peerbots/core";
|
|
607
|
+
import { jsx as jsx8, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
608
|
+
function VoiceSelector({
|
|
609
|
+
voices,
|
|
610
|
+
selectedVoiceUri,
|
|
611
|
+
selectedLanguage,
|
|
612
|
+
onVoiceChange,
|
|
613
|
+
onLanguageChange,
|
|
614
|
+
labels,
|
|
615
|
+
className
|
|
616
|
+
}) {
|
|
617
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
618
|
+
const languages = useMemo(() => {
|
|
619
|
+
const unique = new Set(
|
|
620
|
+
voices.map((v) => getLanguageName(v.lang)).filter(Boolean)
|
|
621
|
+
);
|
|
622
|
+
if (selectedLanguage && !unique.has(selectedLanguage)) {
|
|
623
|
+
unique.add(selectedLanguage);
|
|
624
|
+
}
|
|
625
|
+
if (unique.size === 0) {
|
|
626
|
+
unique.add("English");
|
|
627
|
+
}
|
|
628
|
+
return Array.from(unique).sort().map((langName) => ({
|
|
629
|
+
label: langName,
|
|
630
|
+
value: langName
|
|
631
|
+
}));
|
|
632
|
+
}, [voices, selectedLanguage]);
|
|
633
|
+
const filteredVoices = useMemo(() => {
|
|
634
|
+
const list = voices.filter(
|
|
635
|
+
(v) => !selectedLanguage || getLanguageName(v.lang) === selectedLanguage
|
|
636
|
+
).map((v) => ({
|
|
637
|
+
displayName: formatVoiceDisplayName(v.name || v.voiceURI),
|
|
638
|
+
voiceURI: v.voiceURI
|
|
639
|
+
})).sort((a, b) => a.displayName.localeCompare(b.displayName)).map((voice) => ({
|
|
640
|
+
label: voice.displayName,
|
|
641
|
+
value: voice.voiceURI
|
|
642
|
+
}));
|
|
643
|
+
if (list.length === 0) {
|
|
644
|
+
return [
|
|
645
|
+
{
|
|
646
|
+
label: "System Default Voice",
|
|
647
|
+
value: selectedVoiceUri || "default"
|
|
648
|
+
}
|
|
649
|
+
];
|
|
650
|
+
}
|
|
651
|
+
return list;
|
|
652
|
+
}, [voices, selectedLanguage, selectedVoiceUri]);
|
|
653
|
+
const activeVoiceValue = useMemo(() => {
|
|
654
|
+
if (!selectedVoiceUri) {
|
|
655
|
+
return filteredVoices[0]?.value ?? "";
|
|
656
|
+
}
|
|
657
|
+
const matched = findMatchingVoice(
|
|
658
|
+
filteredVoices.map((v) => ({ name: v.label, voiceURI: v.value })),
|
|
659
|
+
selectedVoiceUri
|
|
660
|
+
);
|
|
661
|
+
return matched ? matched.voiceURI : selectedVoiceUri;
|
|
662
|
+
}, [selectedVoiceUri, filteredVoices]);
|
|
663
|
+
return /* @__PURE__ */ jsxs7("div", { className: faceCn("pbf:flex pbf:flex-col pbf:gap-3", className), children: [
|
|
664
|
+
/* @__PURE__ */ jsx8(Field, { label: uiLabels.voiceSelectorLanguage, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ jsx8(
|
|
665
|
+
Select,
|
|
666
|
+
{
|
|
667
|
+
"aria-label": uiLabels.voiceSelectorLanguage,
|
|
668
|
+
className: "pbf:w-full",
|
|
669
|
+
value: selectedLanguage || languages[0]?.value || "English",
|
|
670
|
+
onChange: (val) => {
|
|
671
|
+
if (val && onLanguageChange) {
|
|
672
|
+
onLanguageChange(String(val));
|
|
673
|
+
}
|
|
674
|
+
},
|
|
675
|
+
options: languages
|
|
676
|
+
}
|
|
677
|
+
) }),
|
|
678
|
+
/* @__PURE__ */ jsx8(Field, { label: uiLabels.voiceSelectorVoice, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ jsx8(
|
|
679
|
+
Select,
|
|
680
|
+
{
|
|
681
|
+
"aria-label": uiLabels.voiceSelectorVoice,
|
|
682
|
+
className: "pbf:w-full",
|
|
683
|
+
value: activeVoiceValue,
|
|
684
|
+
onChange: (val) => {
|
|
685
|
+
if (val) {
|
|
686
|
+
onVoiceChange(String(val));
|
|
687
|
+
}
|
|
688
|
+
},
|
|
689
|
+
options: filteredVoices
|
|
690
|
+
}
|
|
691
|
+
) })
|
|
692
|
+
] });
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// src/components/CharacterSelectionControls.tsx
|
|
696
|
+
import {
|
|
697
|
+
Select as Select2,
|
|
698
|
+
Field as Field2,
|
|
699
|
+
SettingsPanel,
|
|
700
|
+
Button as Button2,
|
|
701
|
+
Input,
|
|
702
|
+
Separator,
|
|
703
|
+
SliderWithNumberField,
|
|
704
|
+
TabRadio
|
|
705
|
+
} from "@peerbots/core";
|
|
706
|
+
import { Fragment, jsx as jsx9, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
707
|
+
function CharacterSelectionControls({
|
|
708
|
+
enableVizij = true,
|
|
709
|
+
labels
|
|
710
|
+
} = {}) {
|
|
711
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
712
|
+
const faceSettings = useFaceStore((state) => state.faceSettings);
|
|
713
|
+
const availableFaces2 = useFaceStore((state) => state.availableFaces);
|
|
714
|
+
const availableVoices = useFaceStore((state) => state.availableVoices);
|
|
715
|
+
const refreshVoices = useFaceStore((state) => state.refreshVoices);
|
|
716
|
+
const selectedFace = useFaceStore((state) => state.selectedFace);
|
|
717
|
+
const getSelectedVoice = useFaceStore((state) => state.getSelectedVoice);
|
|
718
|
+
const selectedVoiceUri = useFaceStore((state) => state.selectedVoiceUri);
|
|
719
|
+
const setLanguage = useFaceStore((state) => state.setLanguage);
|
|
720
|
+
const setVoice = useFaceStore((state) => state.setVoice);
|
|
721
|
+
const setFace = useFaceStore((state) => state.setFace);
|
|
722
|
+
const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
|
|
723
|
+
const speechAllowed = useFaceStore((state) => state.speechAllowed);
|
|
724
|
+
const setSpeechAllowed = useFaceStore((state) => state.setSpeechAllowed);
|
|
725
|
+
const currentVoiceUri = selectedVoiceUri || getSelectedVoice()?.voiceURI || "";
|
|
726
|
+
const selectableFaces = enableVizij ? availableFaces2 : availableFaces2.filter((f) => f.kind !== "Vizij");
|
|
727
|
+
const caps = getFaceCapabilities(selectedFace);
|
|
728
|
+
return /* @__PURE__ */ jsx9(SettingsPanel, { title: uiLabels.characterSelection, headingLevel: 4, children: /* @__PURE__ */ jsxs8("div", { className: "pbf:space-y-4", children: [
|
|
729
|
+
!speechAllowed && /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
730
|
+
/* @__PURE__ */ jsx9("div", { className: "pbf:flex", children: /* @__PURE__ */ jsx9(
|
|
731
|
+
Button2,
|
|
732
|
+
{
|
|
733
|
+
variant: "solid",
|
|
734
|
+
color: "darkblue",
|
|
735
|
+
size: "sm",
|
|
736
|
+
onClick: () => {
|
|
737
|
+
try {
|
|
738
|
+
if (typeof window !== "undefined" && "speechSynthesis" in window && typeof SpeechSynthesisUtterance !== "undefined") {
|
|
739
|
+
const utterance = new SpeechSynthesisUtterance(" ");
|
|
740
|
+
window.speechSynthesis.speak(utterance);
|
|
741
|
+
}
|
|
742
|
+
} catch (err) {
|
|
743
|
+
console.warn("SpeechSynthesis prime warning:", err);
|
|
744
|
+
}
|
|
745
|
+
setSpeechAllowed(true);
|
|
746
|
+
void refreshVoices();
|
|
747
|
+
},
|
|
748
|
+
children: uiLabels.allowSpeech
|
|
749
|
+
}
|
|
750
|
+
) }),
|
|
751
|
+
/* @__PURE__ */ jsx9(Separator, {})
|
|
752
|
+
] }),
|
|
753
|
+
/* @__PURE__ */ jsx9(
|
|
754
|
+
VoiceSelector,
|
|
755
|
+
{
|
|
756
|
+
voices: availableVoices,
|
|
757
|
+
selectedVoiceUri: currentVoiceUri,
|
|
758
|
+
selectedLanguage: faceSettings.selectedLanguage,
|
|
759
|
+
labels: uiLabels,
|
|
760
|
+
onLanguageChange: (newLang) => {
|
|
761
|
+
setLanguage(newLang);
|
|
762
|
+
const firstVoice = availableVoices.find(
|
|
763
|
+
(v) => getLanguageName(v.lang) === newLang
|
|
764
|
+
);
|
|
765
|
+
if (firstVoice) {
|
|
766
|
+
setVoice(firstVoice.voiceURI);
|
|
767
|
+
}
|
|
768
|
+
},
|
|
769
|
+
onVoiceChange: (newVoiceUri) => {
|
|
770
|
+
setVoice(newVoiceUri);
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
),
|
|
774
|
+
/* @__PURE__ */ jsx9(Field2, { label: uiLabels.face, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ jsx9(
|
|
775
|
+
Select2,
|
|
776
|
+
{
|
|
777
|
+
"aria-label": uiLabels.face,
|
|
778
|
+
className: "pbf:w-full",
|
|
779
|
+
value: selectedFace ? selectedFace.name : "Hugo",
|
|
780
|
+
onChange: (selectedName) => {
|
|
781
|
+
const found = selectableFaces.find(
|
|
782
|
+
(f) => f.name === String(selectedName)
|
|
783
|
+
);
|
|
784
|
+
if (found) {
|
|
785
|
+
setFace(found);
|
|
786
|
+
}
|
|
787
|
+
},
|
|
788
|
+
options: selectableFaces.map((face) => ({
|
|
789
|
+
label: face.name,
|
|
790
|
+
value: face.name
|
|
791
|
+
}))
|
|
792
|
+
}
|
|
793
|
+
) }),
|
|
794
|
+
selectedFace?.name === "Custom Face" && /* @__PURE__ */ jsx9(Field2, { label: uiLabels.uploadGlb, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ jsx9(
|
|
795
|
+
Input,
|
|
796
|
+
{
|
|
797
|
+
"aria-label": uiLabels.uploadGlb,
|
|
798
|
+
type: "file",
|
|
799
|
+
accept: ".glb",
|
|
800
|
+
className: "pbf:w-full pbf:text-sm pbf:text-slate-900",
|
|
801
|
+
onChange: (e) => {
|
|
802
|
+
const file = e.target.files?.[0];
|
|
803
|
+
if (file && selectedFace?.kind === "Vizij") {
|
|
804
|
+
const url = URL.createObjectURL(file);
|
|
805
|
+
const updatedFace = {
|
|
806
|
+
...selectedFace,
|
|
807
|
+
assetBundle: {
|
|
808
|
+
...selectedFace.assetBundle,
|
|
809
|
+
glb: {
|
|
810
|
+
kind: "url",
|
|
811
|
+
src: url,
|
|
812
|
+
aggressiveImport: true
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
setFace(updatedFace);
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
) }),
|
|
821
|
+
selectedFace && /* @__PURE__ */ jsxs8("div", { className: "pbf:py-1.5 pbf:px-3 pbf:border-l-2 pbf:rtl:border-l-0 pbf:rtl:border-r-2 pbf:border-teal-700/30 pbf:bg-slate-50 pbf:rounded-r-md", children: [
|
|
822
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:text-[11px] pbf:font-bold pbf:text-slate-700 pbf:uppercase pbf:tracking-wider pbf:mb-1.5 pbf:block", children: uiLabels.faceCapabilities }),
|
|
823
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:flex-row pbf:flex-wrap pbf:gap-x-4 pbf:gap-y-2", children: [
|
|
824
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
|
|
825
|
+
/* @__PURE__ */ jsx9(
|
|
826
|
+
"span",
|
|
827
|
+
{
|
|
828
|
+
"aria-hidden": "true",
|
|
829
|
+
className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canExpressColor ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
|
|
830
|
+
}
|
|
831
|
+
),
|
|
832
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:flex-col", children: [
|
|
833
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.color }),
|
|
834
|
+
typeof caps.canExpressColor === "string" && /* @__PURE__ */ jsx9("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canExpressColor })
|
|
835
|
+
] })
|
|
836
|
+
] }),
|
|
837
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
|
|
838
|
+
/* @__PURE__ */ jsx9(
|
|
839
|
+
"span",
|
|
840
|
+
{
|
|
841
|
+
"aria-hidden": "true",
|
|
842
|
+
className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canExpressEmotion ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
|
|
843
|
+
}
|
|
844
|
+
),
|
|
845
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:flex-col", children: [
|
|
846
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.emotion }),
|
|
847
|
+
typeof caps.canExpressEmotion === "string" && /* @__PURE__ */ jsx9("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canExpressEmotion })
|
|
848
|
+
] })
|
|
849
|
+
] }),
|
|
850
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:items-start pbf:gap-1.5 pbf:min-w-fit", children: [
|
|
851
|
+
/* @__PURE__ */ jsx9(
|
|
852
|
+
"span",
|
|
853
|
+
{
|
|
854
|
+
"aria-hidden": "true",
|
|
855
|
+
className: `pbf:mt-1 pbf:w-2 pbf:h-2 pbf:rounded-full ${caps.canLipSync ? "pbf:bg-emerald-600" : "pbf:bg-slate-400"}`
|
|
856
|
+
}
|
|
857
|
+
),
|
|
858
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:flex-col", children: [
|
|
859
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:text-xs pbf:font-semibold pbf:text-slate-800", children: uiLabels.speech }),
|
|
860
|
+
typeof caps.canLipSync === "string" && /* @__PURE__ */ jsx9("span", { className: "pbf:text-[11px] pbf:text-slate-600", children: caps.canLipSync })
|
|
861
|
+
] })
|
|
862
|
+
] })
|
|
863
|
+
] })
|
|
864
|
+
] }),
|
|
865
|
+
enableVizij && selectedFace?.kind === "Vizij" && /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
866
|
+
/* @__PURE__ */ jsx9(Separator, {}),
|
|
867
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:space-y-3", children: [
|
|
868
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:items-center pbf:justify-between", children: [
|
|
869
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.faceSpecificSettings }),
|
|
870
|
+
/* @__PURE__ */ jsx9(PoweredByVizij, { poweredByLabel: uiLabels.poweredBy })
|
|
871
|
+
] }),
|
|
872
|
+
/* @__PURE__ */ jsx9(FieldGroup, { label: uiLabels.faceExpressivity, children: /* @__PURE__ */ jsx9(
|
|
873
|
+
SliderWithNumberField,
|
|
874
|
+
{
|
|
875
|
+
"aria-label": uiLabels.faceExpressivity,
|
|
876
|
+
min: 0,
|
|
877
|
+
max: 1,
|
|
878
|
+
step: 0.05,
|
|
879
|
+
value: faceSettings.vizijSettings?.faceExpressivity ?? 1,
|
|
880
|
+
onChange: (val) => {
|
|
881
|
+
const vizijSettings = faceSettings.vizijSettings ?? defaultFaceSettings.vizijSettings;
|
|
882
|
+
setFaceSettings({
|
|
883
|
+
vizijSettings: {
|
|
884
|
+
...vizijSettings,
|
|
885
|
+
faceExpressivity: val
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
}
|
|
890
|
+
) })
|
|
891
|
+
] })
|
|
892
|
+
] }),
|
|
893
|
+
selectedFace?.kind === "PixiFace" && /* @__PURE__ */ jsxs8(Fragment, { children: [
|
|
894
|
+
/* @__PURE__ */ jsx9(Separator, {}),
|
|
895
|
+
/* @__PURE__ */ jsxs8("div", { className: "pbf:space-y-3", children: [
|
|
896
|
+
/* @__PURE__ */ jsx9("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800 pbf:block", children: uiLabels.faceSpecificSettings }),
|
|
897
|
+
selectedFace.type === "avatar" && /* @__PURE__ */ jsxs8("div", { className: "pbf:flex pbf:flex-col pbf:gap-3", children: [
|
|
898
|
+
/* @__PURE__ */ jsx9(
|
|
899
|
+
Field2,
|
|
900
|
+
{
|
|
901
|
+
label: uiLabels.eyes,
|
|
902
|
+
labelPlacement: "left",
|
|
903
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
904
|
+
children: /* @__PURE__ */ jsx9(
|
|
905
|
+
TabRadio,
|
|
906
|
+
{
|
|
907
|
+
"aria-label": uiLabels.eyes,
|
|
908
|
+
options: [
|
|
909
|
+
{ value: "default", label: uiLabels.defaultOption },
|
|
910
|
+
{ value: "none", label: uiLabels.noneOption }
|
|
911
|
+
],
|
|
912
|
+
value: faceSettings.pixiSettings?.eyeDisplay ?? "default",
|
|
913
|
+
onChange: (val) => {
|
|
914
|
+
const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
|
|
915
|
+
setFaceSettings({
|
|
916
|
+
pixiSettings: {
|
|
917
|
+
...pixiSettings,
|
|
918
|
+
eyeDisplay: val || "default"
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
)
|
|
924
|
+
}
|
|
925
|
+
),
|
|
926
|
+
/* @__PURE__ */ jsx9(
|
|
927
|
+
Field2,
|
|
928
|
+
{
|
|
929
|
+
label: uiLabels.mouth,
|
|
930
|
+
labelPlacement: "left",
|
|
931
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
932
|
+
children: /* @__PURE__ */ jsx9(
|
|
933
|
+
TabRadio,
|
|
934
|
+
{
|
|
935
|
+
"aria-label": uiLabels.mouth,
|
|
936
|
+
options: [
|
|
937
|
+
{ value: "default", label: uiLabels.defaultOption },
|
|
938
|
+
{ value: "none", label: uiLabels.noneOption }
|
|
939
|
+
],
|
|
940
|
+
value: faceSettings.pixiSettings?.mouthDisplay ?? "default",
|
|
941
|
+
onChange: (val) => {
|
|
942
|
+
const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
|
|
943
|
+
setFaceSettings({
|
|
944
|
+
pixiSettings: {
|
|
945
|
+
...pixiSettings,
|
|
946
|
+
mouthDisplay: val || "default"
|
|
947
|
+
}
|
|
948
|
+
});
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
)
|
|
952
|
+
}
|
|
953
|
+
),
|
|
954
|
+
/* @__PURE__ */ jsx9(
|
|
955
|
+
Field2,
|
|
956
|
+
{
|
|
957
|
+
label: uiLabels.cheeks,
|
|
958
|
+
labelPlacement: "left",
|
|
959
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
960
|
+
children: /* @__PURE__ */ jsx9(
|
|
961
|
+
TabRadio,
|
|
962
|
+
{
|
|
963
|
+
"aria-label": uiLabels.cheeks,
|
|
964
|
+
options: [
|
|
965
|
+
{ value: "default", label: uiLabels.defaultOption },
|
|
966
|
+
{ value: "none", label: uiLabels.noneOption }
|
|
967
|
+
],
|
|
968
|
+
value: faceSettings.pixiSettings?.cheekDisplay ?? "default",
|
|
969
|
+
onChange: (val) => {
|
|
970
|
+
const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
|
|
971
|
+
setFaceSettings({
|
|
972
|
+
pixiSettings: {
|
|
973
|
+
...pixiSettings,
|
|
974
|
+
cheekDisplay: val || "default"
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
)
|
|
980
|
+
}
|
|
981
|
+
)
|
|
982
|
+
] }),
|
|
983
|
+
selectedFace.type === "text" && /* @__PURE__ */ jsx9(
|
|
984
|
+
Field2,
|
|
985
|
+
{
|
|
986
|
+
label: uiLabels.emotionDisplay,
|
|
987
|
+
labelPlacement: "left",
|
|
988
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
989
|
+
children: /* @__PURE__ */ jsx9(
|
|
990
|
+
TabRadio,
|
|
991
|
+
{
|
|
992
|
+
"aria-label": uiLabels.emotionDisplay,
|
|
993
|
+
options: [
|
|
994
|
+
{ value: "emoticon", label: uiLabels.emoticon },
|
|
995
|
+
{ value: "emoji", label: uiLabels.emoji },
|
|
996
|
+
{ value: "none", label: uiLabels.noneOption }
|
|
997
|
+
],
|
|
998
|
+
value: faceSettings.pixiSettings?.emotionDisplay ?? "emoticon",
|
|
999
|
+
onChange: (val) => {
|
|
1000
|
+
const pixiSettings = faceSettings.pixiSettings ?? defaultFaceSettings.pixiSettings;
|
|
1001
|
+
setFaceSettings({
|
|
1002
|
+
pixiSettings: {
|
|
1003
|
+
...pixiSettings,
|
|
1004
|
+
emotionDisplay: val || "emoticon"
|
|
1005
|
+
}
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
)
|
|
1010
|
+
}
|
|
1011
|
+
)
|
|
1012
|
+
] })
|
|
1013
|
+
] })
|
|
1014
|
+
] }) });
|
|
1015
|
+
}
|
|
1016
|
+
var CharacterSelectionSection = CharacterSelectionControls;
|
|
1017
|
+
|
|
1018
|
+
// src/components/FacePositioningControls.tsx
|
|
1019
|
+
import {
|
|
1020
|
+
Field as Field3,
|
|
1021
|
+
SliderWithNumberField as SliderWithNumberField2,
|
|
1022
|
+
Switch,
|
|
1023
|
+
SettingsPanel as SettingsPanel2,
|
|
1024
|
+
Button as Button3,
|
|
1025
|
+
Separator as Separator2,
|
|
1026
|
+
Icon as Icon2
|
|
1027
|
+
} from "@peerbots/core";
|
|
1028
|
+
import { jsx as jsx10, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
1029
|
+
function FacePositioningControls({
|
|
1030
|
+
labels
|
|
1031
|
+
} = {}) {
|
|
1032
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
1033
|
+
const faceSettings = useFaceStore((state) => state.faceSettings);
|
|
1034
|
+
const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
|
|
1035
|
+
const resetPositioning = useFaceStore((state) => state.resetPositioning);
|
|
1036
|
+
const isModified = faceSettings.zoom !== 1 || (faceSettings.offset?.x ?? 0) !== 0 || (faceSettings.offset?.y ?? 0) !== 0 || faceSettings.rotation !== 0;
|
|
1037
|
+
return /* @__PURE__ */ jsx10(SettingsPanel2, { title: uiLabels.positioning, headingLevel: 4, children: /* @__PURE__ */ jsxs9("div", { className: "pbf:space-y-4", children: [
|
|
1038
|
+
/* @__PURE__ */ jsxs9("div", { className: "pbf:flex pbf:w-full pbf:flex-wrap pbf:items-center pbf:justify-between pbf:gap-2", children: [
|
|
1039
|
+
/* @__PURE__ */ jsx10(
|
|
1040
|
+
Field3,
|
|
1041
|
+
{
|
|
1042
|
+
label: uiLabels.autoRotate,
|
|
1043
|
+
labelPlacement: "left",
|
|
1044
|
+
labelWeight: "normal",
|
|
1045
|
+
className: "pbf:flex-row pbf:items-center pbf:gap-2 pbf:mb-0 pbf:!w-auto",
|
|
1046
|
+
children: /* @__PURE__ */ jsx10(
|
|
1047
|
+
Switch,
|
|
1048
|
+
{
|
|
1049
|
+
"aria-label": uiLabels.autoRotate,
|
|
1050
|
+
checked: faceSettings.autoRotate,
|
|
1051
|
+
onChange: (checked) => {
|
|
1052
|
+
setFaceSettings({ autoRotate: checked });
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1055
|
+
)
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
/* @__PURE__ */ jsxs9("div", { className: "pbf:flex pbf:items-center pbf:gap-1.5 pbf:shrink-0", children: [
|
|
1059
|
+
/* @__PURE__ */ jsx10(
|
|
1060
|
+
Button3,
|
|
1061
|
+
{
|
|
1062
|
+
variant: "ghost",
|
|
1063
|
+
size: "sm",
|
|
1064
|
+
className: "pbf:p-1.5 pbf:text-xs pbf:whitespace-nowrap",
|
|
1065
|
+
onClick: () => {
|
|
1066
|
+
setFaceSettings({
|
|
1067
|
+
rotation: (faceSettings.rotation + 90) % 360
|
|
1068
|
+
});
|
|
1069
|
+
},
|
|
1070
|
+
leftIcon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowPath", className: "pbf:h-3.5 pbf:w-3.5" }),
|
|
1071
|
+
children: uiLabels.rotate
|
|
1072
|
+
}
|
|
1073
|
+
),
|
|
1074
|
+
isModified && /* @__PURE__ */ jsx10(
|
|
1075
|
+
Button3,
|
|
1076
|
+
{
|
|
1077
|
+
variant: "ghost",
|
|
1078
|
+
size: "sm",
|
|
1079
|
+
className: "pbf:p-1.5 pbf:text-xs pbf:whitespace-nowrap",
|
|
1080
|
+
onClick: resetPositioning,
|
|
1081
|
+
leftIcon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowUturnLeft", className: "pbf:h-3.5 pbf:w-3.5" }),
|
|
1082
|
+
children: uiLabels.reset
|
|
1083
|
+
}
|
|
1084
|
+
)
|
|
1085
|
+
] })
|
|
1086
|
+
] }),
|
|
1087
|
+
/* @__PURE__ */ jsx10(Separator2, {}),
|
|
1088
|
+
/* @__PURE__ */ jsxs9("div", { className: "pbf:flex pbf:flex-col pbf:gap-4", children: [
|
|
1089
|
+
/* @__PURE__ */ jsx10(
|
|
1090
|
+
FieldGroup,
|
|
1091
|
+
{
|
|
1092
|
+
label: uiLabels.zoom,
|
|
1093
|
+
icon: /* @__PURE__ */ jsx10(Icon2, { name: "magnifyingGlassPlus" }),
|
|
1094
|
+
children: /* @__PURE__ */ jsx10(
|
|
1095
|
+
SliderWithNumberField2,
|
|
1096
|
+
{
|
|
1097
|
+
"aria-label": uiLabels.zoom,
|
|
1098
|
+
min: 0.1,
|
|
1099
|
+
max: 3,
|
|
1100
|
+
step: 0.05,
|
|
1101
|
+
value: faceSettings.zoom,
|
|
1102
|
+
onChange: (val) => {
|
|
1103
|
+
setFaceSettings({ zoom: val });
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
)
|
|
1107
|
+
}
|
|
1108
|
+
),
|
|
1109
|
+
/* @__PURE__ */ jsx10(
|
|
1110
|
+
FieldGroup,
|
|
1111
|
+
{
|
|
1112
|
+
label: uiLabels.horizontalOffset,
|
|
1113
|
+
icon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowsRightLeft" }),
|
|
1114
|
+
children: /* @__PURE__ */ jsx10(
|
|
1115
|
+
SliderWithNumberField2,
|
|
1116
|
+
{
|
|
1117
|
+
"aria-label": uiLabels.horizontalOffset,
|
|
1118
|
+
min: -1e3,
|
|
1119
|
+
max: 1e3,
|
|
1120
|
+
value: faceSettings.offset?.x ?? 0,
|
|
1121
|
+
onChange: (val) => {
|
|
1122
|
+
setFaceSettings({
|
|
1123
|
+
offset: {
|
|
1124
|
+
x: val,
|
|
1125
|
+
y: faceSettings.offset?.y ?? 0
|
|
1126
|
+
}
|
|
1127
|
+
});
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
)
|
|
1131
|
+
}
|
|
1132
|
+
),
|
|
1133
|
+
/* @__PURE__ */ jsx10(
|
|
1134
|
+
FieldGroup,
|
|
1135
|
+
{
|
|
1136
|
+
label: uiLabels.verticalOffset,
|
|
1137
|
+
icon: /* @__PURE__ */ jsx10(Icon2, { name: "arrowsUpDown" }),
|
|
1138
|
+
children: /* @__PURE__ */ jsx10(
|
|
1139
|
+
SliderWithNumberField2,
|
|
1140
|
+
{
|
|
1141
|
+
"aria-label": uiLabels.verticalOffset,
|
|
1142
|
+
min: -1e3,
|
|
1143
|
+
max: 1e3,
|
|
1144
|
+
value: faceSettings.offset?.y ?? 0,
|
|
1145
|
+
onChange: (val) => {
|
|
1146
|
+
setFaceSettings({
|
|
1147
|
+
offset: {
|
|
1148
|
+
x: faceSettings.offset?.x ?? 0,
|
|
1149
|
+
y: val
|
|
1150
|
+
}
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
}
|
|
1154
|
+
)
|
|
1155
|
+
}
|
|
1156
|
+
)
|
|
1157
|
+
] })
|
|
1158
|
+
] }) });
|
|
1159
|
+
}
|
|
1160
|
+
var FacePositioningSection = FacePositioningControls;
|
|
1161
|
+
|
|
1162
|
+
// src/components/FaceBehaviorControls.tsx
|
|
1163
|
+
import {
|
|
1164
|
+
Field as Field4,
|
|
1165
|
+
Select as Select3,
|
|
1166
|
+
SliderWithNumberField as SliderWithNumberField3,
|
|
1167
|
+
SettingsPanel as SettingsPanel3,
|
|
1168
|
+
Separator as Separator3,
|
|
1169
|
+
Switch as Switch2
|
|
1170
|
+
} from "@peerbots/core";
|
|
1171
|
+
import { jsx as jsx11, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
1172
|
+
function FaceBehaviorControls({
|
|
1173
|
+
labels
|
|
1174
|
+
} = {}) {
|
|
1175
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
1176
|
+
const faceSettings = useFaceStore((state) => state.faceSettings);
|
|
1177
|
+
const setFaceSettings = useFaceStore((state) => state.setFaceSettings);
|
|
1178
|
+
return /* @__PURE__ */ jsx11(SettingsPanel3, { title: uiLabels.faceSettings, headingLevel: 4, children: /* @__PURE__ */ jsxs10("div", { className: "pbf:flex pbf:flex-col pbf:gap-4", children: [
|
|
1179
|
+
/* @__PURE__ */ jsxs10("div", { className: "pbf:flex pbf:flex-col pbf:gap-2", children: [
|
|
1180
|
+
/* @__PURE__ */ jsx11("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.onFaceButtons }),
|
|
1181
|
+
/* @__PURE__ */ jsx11(
|
|
1182
|
+
Field4,
|
|
1183
|
+
{
|
|
1184
|
+
label: uiLabels.showFullScreenButton,
|
|
1185
|
+
labelPlacement: "left",
|
|
1186
|
+
labelWeight: "normal",
|
|
1187
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
1188
|
+
children: /* @__PURE__ */ jsx11(
|
|
1189
|
+
Switch2,
|
|
1190
|
+
{
|
|
1191
|
+
"aria-label": uiLabels.showFullScreenButton,
|
|
1192
|
+
checked: faceSettings.showFullScreenButton,
|
|
1193
|
+
onChange: (checked) => {
|
|
1194
|
+
setFaceSettings({ showFullScreenButton: checked });
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
)
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
/* @__PURE__ */ jsx11(
|
|
1201
|
+
Field4,
|
|
1202
|
+
{
|
|
1203
|
+
label: uiLabels.showScrollButton,
|
|
1204
|
+
labelPlacement: "left",
|
|
1205
|
+
labelWeight: "normal",
|
|
1206
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
1207
|
+
children: /* @__PURE__ */ jsx11(
|
|
1208
|
+
Switch2,
|
|
1209
|
+
{
|
|
1210
|
+
"aria-label": uiLabels.showScrollButton,
|
|
1211
|
+
checked: faceSettings.showScrollButton,
|
|
1212
|
+
onChange: (checked) => {
|
|
1213
|
+
setFaceSettings({ showScrollButton: checked });
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
)
|
|
1217
|
+
}
|
|
1218
|
+
)
|
|
1219
|
+
] }),
|
|
1220
|
+
/* @__PURE__ */ jsx11(Separator3, {}),
|
|
1221
|
+
/* @__PURE__ */ jsxs10("div", { className: "pbf:flex pbf:flex-col pbf:gap-2", children: [
|
|
1222
|
+
/* @__PURE__ */ jsx11("span", { className: "pbf:font-bold pbf:text-sm pbf:text-slate-800", children: uiLabels.speechBehavior }),
|
|
1223
|
+
/* @__PURE__ */ jsx11(Field4, { label: uiLabels.newButtonSpeech, className: "pbf:flex-col pbf:gap-1", children: /* @__PURE__ */ jsx11(
|
|
1224
|
+
Select3,
|
|
1225
|
+
{
|
|
1226
|
+
"aria-label": uiLabels.newButtonSpeech,
|
|
1227
|
+
className: "pbf:w-full",
|
|
1228
|
+
value: faceSettings.speechQueueMode || "interrupt",
|
|
1229
|
+
onChange: (val) => {
|
|
1230
|
+
if (val) {
|
|
1231
|
+
setFaceSettings({
|
|
1232
|
+
speechQueueMode: val
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
},
|
|
1236
|
+
options: [
|
|
1237
|
+
{
|
|
1238
|
+
label: uiLabels.interruptSpeech,
|
|
1239
|
+
value: "interrupt"
|
|
1240
|
+
},
|
|
1241
|
+
{
|
|
1242
|
+
label: uiLabels.queueSpeech,
|
|
1243
|
+
value: "queue"
|
|
1244
|
+
}
|
|
1245
|
+
]
|
|
1246
|
+
}
|
|
1247
|
+
) })
|
|
1248
|
+
] }),
|
|
1249
|
+
/* @__PURE__ */ jsx11(Separator3, {}),
|
|
1250
|
+
/* @__PURE__ */ jsxs10("div", { className: "pbf:flex pbf:flex-col pbf:gap-3", children: [
|
|
1251
|
+
/* @__PURE__ */ jsx11(
|
|
1252
|
+
Field4,
|
|
1253
|
+
{
|
|
1254
|
+
label: uiLabels.captions,
|
|
1255
|
+
labelPlacement: "left",
|
|
1256
|
+
labelWeight: "bold",
|
|
1257
|
+
className: "pbf:flex-row pbf:items-center pbf:justify-between",
|
|
1258
|
+
children: /* @__PURE__ */ jsx11(
|
|
1259
|
+
Switch2,
|
|
1260
|
+
{
|
|
1261
|
+
"aria-label": uiLabels.captions,
|
|
1262
|
+
checked: faceSettings.captions?.enabled ?? false,
|
|
1263
|
+
onChange: (checked) => {
|
|
1264
|
+
setFaceSettings({
|
|
1265
|
+
captions: {
|
|
1266
|
+
...faceSettings.captions,
|
|
1267
|
+
enabled: checked
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
}
|
|
1271
|
+
}
|
|
1272
|
+
)
|
|
1273
|
+
}
|
|
1274
|
+
),
|
|
1275
|
+
faceSettings.captions?.enabled && /* @__PURE__ */ jsxs10("div", { className: "pbf:flex pbf:flex-col pbf:gap-4 pbf:mt-1", children: [
|
|
1276
|
+
/* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.fontSize, children: /* @__PURE__ */ jsx11(
|
|
1277
|
+
SliderWithNumberField3,
|
|
1278
|
+
{
|
|
1279
|
+
"aria-label": uiLabels.fontSize,
|
|
1280
|
+
min: 10,
|
|
1281
|
+
max: 100,
|
|
1282
|
+
step: 1,
|
|
1283
|
+
value: faceSettings.captions?.fontSize ?? 32,
|
|
1284
|
+
onChange: (val) => {
|
|
1285
|
+
setFaceSettings({
|
|
1286
|
+
captions: {
|
|
1287
|
+
...faceSettings.captions,
|
|
1288
|
+
fontSize: val
|
|
1289
|
+
}
|
|
1290
|
+
});
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
) }),
|
|
1294
|
+
/* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.horizontalOffset, children: /* @__PURE__ */ jsx11(
|
|
1295
|
+
SliderWithNumberField3,
|
|
1296
|
+
{
|
|
1297
|
+
"aria-label": uiLabels.horizontalOffset,
|
|
1298
|
+
min: -400,
|
|
1299
|
+
max: 400,
|
|
1300
|
+
step: 1,
|
|
1301
|
+
value: faceSettings.captions?.offset?.x ?? 0,
|
|
1302
|
+
onChange: (val) => {
|
|
1303
|
+
setFaceSettings({
|
|
1304
|
+
captions: {
|
|
1305
|
+
...faceSettings.captions,
|
|
1306
|
+
offset: {
|
|
1307
|
+
x: val,
|
|
1308
|
+
y: faceSettings.captions?.offset?.y ?? 0
|
|
1309
|
+
}
|
|
1310
|
+
}
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
) }),
|
|
1315
|
+
/* @__PURE__ */ jsx11(FieldGroup, { label: uiLabels.verticalPosition, children: /* @__PURE__ */ jsx11(
|
|
1316
|
+
SliderWithNumberField3,
|
|
1317
|
+
{
|
|
1318
|
+
"aria-label": uiLabels.verticalPosition,
|
|
1319
|
+
min: -50,
|
|
1320
|
+
max: 50,
|
|
1321
|
+
step: 1,
|
|
1322
|
+
value: faceSettings.captions?.offset?.y ?? 0,
|
|
1323
|
+
onChange: (val) => {
|
|
1324
|
+
setFaceSettings({
|
|
1325
|
+
captions: {
|
|
1326
|
+
...faceSettings.captions,
|
|
1327
|
+
offset: {
|
|
1328
|
+
x: faceSettings.captions?.offset?.x ?? 0,
|
|
1329
|
+
y: val
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
) })
|
|
1336
|
+
] })
|
|
1337
|
+
] })
|
|
1338
|
+
] }) });
|
|
1339
|
+
}
|
|
1340
|
+
var ControlSettingsSection = FaceBehaviorControls;
|
|
1341
|
+
|
|
1342
|
+
// src/components/FaceSettingsPanel.tsx
|
|
1343
|
+
import { SettingsPanel as SettingsPanel4 } from "@peerbots/core";
|
|
1344
|
+
import { jsx as jsx12, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
1345
|
+
function FaceSettingsPanel({
|
|
1346
|
+
inline = false,
|
|
1347
|
+
enableVizij = true,
|
|
1348
|
+
columns = 3,
|
|
1349
|
+
labels,
|
|
1350
|
+
className
|
|
1351
|
+
} = {}) {
|
|
1352
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
1353
|
+
const gridClass = columns === 1 ? "pbf:grid pbf:items-start pbf:gap-4 pbf:grid-cols-1" : "pbf:grid pbf:items-start pbf:gap-4 pbf:lg:gap-6 pbf:grid-cols-1 pbf:md:grid-cols-2 pbf:lg:grid-cols-3";
|
|
1354
|
+
const content = /* @__PURE__ */ jsxs11("div", { className: faceCn(gridClass, className), children: [
|
|
1355
|
+
/* @__PURE__ */ jsx12("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ jsx12(CharacterSelectionControls, { enableVizij, labels: uiLabels }) }),
|
|
1356
|
+
/* @__PURE__ */ jsx12("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ jsx12(FacePositioningControls, { labels: uiLabels }) }),
|
|
1357
|
+
/* @__PURE__ */ jsx12("div", { className: "pbf:min-w-0 pbf:h-full", children: /* @__PURE__ */ jsx12(FaceBehaviorControls, { labels: uiLabels }) })
|
|
1358
|
+
] });
|
|
1359
|
+
if (inline) {
|
|
1360
|
+
return content;
|
|
1361
|
+
}
|
|
1362
|
+
return /* @__PURE__ */ jsx12(SettingsPanel4, { title: uiLabels.faceSettings, children: content });
|
|
1363
|
+
}
|
|
1364
|
+
var FaceSettingsControl = FaceSettingsPanel;
|
|
1365
|
+
|
|
1366
|
+
// src/components/FaceTester.tsx
|
|
1367
|
+
import { useRef } from "react";
|
|
1368
|
+
import {
|
|
1369
|
+
Button as Button4,
|
|
1370
|
+
EmotionSelector,
|
|
1371
|
+
Input as Input2,
|
|
1372
|
+
PeerbotsColorSelector
|
|
1373
|
+
} from "@peerbots/core";
|
|
1374
|
+
import { jsx as jsx13, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
1375
|
+
function FaceTester({ labels, onSendMessage } = {}) {
|
|
1376
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
1377
|
+
const textToSpeak = useRef(null);
|
|
1378
|
+
const lastMessage = useFaceStore((state) => state.lastMessage);
|
|
1379
|
+
const updateLastMessage = useFaceStore((state) => state.updateLastMessage);
|
|
1380
|
+
const dispatchMessage = (next) => {
|
|
1381
|
+
if (onSendMessage) {
|
|
1382
|
+
onSendMessage(next, "system");
|
|
1383
|
+
return;
|
|
1384
|
+
}
|
|
1385
|
+
updateLastMessage(next, "system");
|
|
1386
|
+
};
|
|
1387
|
+
const triggerSpeak = () => {
|
|
1388
|
+
if (!textToSpeak.current) return;
|
|
1389
|
+
const text = textToSpeak.current.value;
|
|
1390
|
+
dispatchMessage({ ...lastMessage, speech: text });
|
|
1391
|
+
textToSpeak.current.value = "";
|
|
1392
|
+
};
|
|
1393
|
+
return /* @__PURE__ */ jsxs12("div", { children: [
|
|
1394
|
+
/* @__PURE__ */ jsxs12("div", { className: "pbf:flex pbf:my-2", children: [
|
|
1395
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
1396
|
+
/* @__PURE__ */ jsx13("div", { className: "pbf:text-xs", children: uiLabels.sendEmotion }),
|
|
1397
|
+
/* @__PURE__ */ jsx13(
|
|
1398
|
+
EmotionSelector,
|
|
1399
|
+
{
|
|
1400
|
+
selectedEmotion: "",
|
|
1401
|
+
onEmotionSelect: (emotion) => {
|
|
1402
|
+
dispatchMessage({ ...lastMessage, emotion, speech: "" });
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
)
|
|
1406
|
+
] }),
|
|
1407
|
+
/* @__PURE__ */ jsx13("div", { className: "pbf:flex-1" }),
|
|
1408
|
+
/* @__PURE__ */ jsxs12("div", { children: [
|
|
1409
|
+
/* @__PURE__ */ jsx13("div", { className: "pbf:text-xs", children: uiLabels.sendColor }),
|
|
1410
|
+
/* @__PURE__ */ jsx13(
|
|
1411
|
+
PeerbotsColorSelector,
|
|
1412
|
+
{
|
|
1413
|
+
selectedColor: "",
|
|
1414
|
+
onColorSelect: (color) => {
|
|
1415
|
+
dispatchMessage({ ...lastMessage, color, speech: "" });
|
|
1416
|
+
}
|
|
1417
|
+
}
|
|
1418
|
+
)
|
|
1419
|
+
] })
|
|
1420
|
+
] }),
|
|
1421
|
+
/* @__PURE__ */ jsxs12("div", { className: "pbf:flex pbf:mt-2 pbf:pt-2 pbf:gap-2", children: [
|
|
1422
|
+
/* @__PURE__ */ jsx13(
|
|
1423
|
+
Input2,
|
|
1424
|
+
{
|
|
1425
|
+
ref: textToSpeak,
|
|
1426
|
+
placeholder: uiLabels.textToSpeakPlaceholder,
|
|
1427
|
+
"aria-label": uiLabels.textToSpeakAria,
|
|
1428
|
+
onKeyDown: (e) => {
|
|
1429
|
+
if (e.key === "Enter") {
|
|
1430
|
+
triggerSpeak();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
),
|
|
1435
|
+
/* @__PURE__ */ jsx13(Button4, { onClick: triggerSpeak, children: uiLabels.speak })
|
|
1436
|
+
] })
|
|
1437
|
+
] });
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
// src/components/FaceTesterSection.tsx
|
|
1441
|
+
import { SettingsPanel as SettingsPanel5 } from "@peerbots/core";
|
|
1442
|
+
import { jsx as jsx14 } from "react/jsx-runtime";
|
|
1443
|
+
function FaceTesterSection({
|
|
1444
|
+
defaultOpen = false,
|
|
1445
|
+
collapsible = true,
|
|
1446
|
+
headingLevel = 4,
|
|
1447
|
+
labels,
|
|
1448
|
+
onSendMessage
|
|
1449
|
+
} = {}) {
|
|
1450
|
+
const uiLabels = resolveFaceUiLabels(labels);
|
|
1451
|
+
return /* @__PURE__ */ jsx14(
|
|
1452
|
+
SettingsPanel5,
|
|
1453
|
+
{
|
|
1454
|
+
title: uiLabels.testFace,
|
|
1455
|
+
collapsible,
|
|
1456
|
+
defaultOpen,
|
|
1457
|
+
headingLevel,
|
|
1458
|
+
children: /* @__PURE__ */ jsx14(FaceTester, { labels: uiLabels, onSendMessage })
|
|
1459
|
+
}
|
|
1460
|
+
);
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
// src/components/AmplitudeGraph.tsx
|
|
1464
|
+
import { Heading, LineGraph } from "@peerbots/core";
|
|
1465
|
+
import { jsx as jsx15, jsxs as jsxs13 } from "react/jsx-runtime";
|
|
1466
|
+
function AmplitudeGraph() {
|
|
1467
|
+
const amplitudeData = useFaceStore((state) => state.amplitudeData);
|
|
1468
|
+
const amplitudeExtrema = useFaceStore((state) => state.amplitudeExtrema);
|
|
1469
|
+
const isSpeaking = useFaceStore((state) => state.isSpeaking);
|
|
1470
|
+
const currentAmplitude = useFaceStore((state) => state.currentAmplitude);
|
|
1471
|
+
if (!isSpeaking && (!amplitudeData || amplitudeData.length === 0)) {
|
|
1472
|
+
return /* @__PURE__ */ jsx15("div", { className: "pbf:p-4 pbf:text-gray-500 pbf:italic", children: "No amplitude data available. Speak something to see data." });
|
|
1473
|
+
}
|
|
1474
|
+
const hasData = Boolean(amplitudeData && amplitudeData.length > 0);
|
|
1475
|
+
const maxTime = hasData && amplitudeData ? amplitudeData[amplitudeData.length - 1].time : 1e3;
|
|
1476
|
+
const height = 200;
|
|
1477
|
+
const padding = 20;
|
|
1478
|
+
return /* @__PURE__ */ jsxs13("div", { className: "pbf:m-4 pbf:p-4 pbf:bg-white pbf:shadow-xl pbf:rounded-lg pbf:border pbf:border-gray-100", children: [
|
|
1479
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:flex pbf:items-center pbf:justify-between pbf:mb-2", children: [
|
|
1480
|
+
/* @__PURE__ */ jsx15(Heading, { level: 3, children: "Audio Amplitude Visualization" }),
|
|
1481
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:flex pbf:gap-4 pbf:items-center", children: [
|
|
1482
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:text-sm pbf:font-medium", children: [
|
|
1483
|
+
"Live:",
|
|
1484
|
+
" ",
|
|
1485
|
+
/* @__PURE__ */ jsxs13("span", { className: "pbf:text-blue-600", children: [
|
|
1486
|
+
(currentAmplitude * 100).toFixed(1),
|
|
1487
|
+
"%"
|
|
1488
|
+
] })
|
|
1489
|
+
] }),
|
|
1490
|
+
/* @__PURE__ */ jsx15("div", { className: "pbf:flex-1 pbf:h-4 pbf:w-24 pbf:bg-gray-200 pbf:rounded-full pbf:overflow-hidden", children: /* @__PURE__ */ jsx15(
|
|
1491
|
+
"div",
|
|
1492
|
+
{
|
|
1493
|
+
className: "pbf:h-full pbf:bg-blue-500 pbf:transition-all pbf:duration-75",
|
|
1494
|
+
style: { width: `${currentAmplitude * 100}%` }
|
|
1495
|
+
}
|
|
1496
|
+
) }),
|
|
1497
|
+
isSpeaking && /* @__PURE__ */ jsxs13("span", { className: "pbf:flex pbf:h-3 pbf:w-3 pbf:relative", children: [
|
|
1498
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:animate-ping pbf:absolute pbf:inline-flex pbf:h-full pbf:w-full pbf:rounded-full pbf:bg-green-400 pbf:opacity-75" }),
|
|
1499
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:relative pbf:inline-flex pbf:rounded-full pbf:h-3 pbf:w-3 pbf:bg-green-500" })
|
|
1500
|
+
] })
|
|
1501
|
+
] })
|
|
1502
|
+
] }),
|
|
1503
|
+
/* @__PURE__ */ jsx15(
|
|
1504
|
+
LineGraph,
|
|
1505
|
+
{
|
|
1506
|
+
data: amplitudeData?.map((p) => ({ x: p.time, y: p.value })) ?? [],
|
|
1507
|
+
highlightPoints: amplitudeExtrema?.map((p) => ({
|
|
1508
|
+
x: p.time,
|
|
1509
|
+
y: p.value,
|
|
1510
|
+
color: p.value > 0.1 ? "#ef4444" : "#10b981",
|
|
1511
|
+
label: `Time: ${p.time} ms, Value: ${p.value}`
|
|
1512
|
+
})),
|
|
1513
|
+
minX: 0,
|
|
1514
|
+
maxX: maxTime,
|
|
1515
|
+
minY: 0,
|
|
1516
|
+
maxY: 1,
|
|
1517
|
+
height,
|
|
1518
|
+
strokeColor: "#3b82f6",
|
|
1519
|
+
xUnit: "ms",
|
|
1520
|
+
padding
|
|
1521
|
+
}
|
|
1522
|
+
),
|
|
1523
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:mt-4 pbf:grid pbf:grid-cols-2 pbf:gap-4 pbf:text-xs", children: [
|
|
1524
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1525
|
+
/* @__PURE__ */ jsxs13("span", { className: "pbf:font-bold pbf:block pbf:mb-1", children: [
|
|
1526
|
+
"Local Extrema (",
|
|
1527
|
+
amplitudeExtrema?.length || 0,
|
|
1528
|
+
")"
|
|
1529
|
+
] }),
|
|
1530
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:max-h-32 pbf:overflow-y-auto pbf:bg-gray-50 pbf:p-2 pbf:rounded pbf:border pbf:border-gray-200", children: [
|
|
1531
|
+
amplitudeExtrema?.map((p, i) => /* @__PURE__ */ jsxs13(
|
|
1532
|
+
"div",
|
|
1533
|
+
{
|
|
1534
|
+
className: "pbf:flex pbf:justify-between pbf:py-0.5 pbf:border-b pbf:border-gray-100 pbf:last:border-0",
|
|
1535
|
+
children: [
|
|
1536
|
+
/* @__PURE__ */ jsxs13("span", { children: [
|
|
1537
|
+
p.time,
|
|
1538
|
+
"ms"
|
|
1539
|
+
] }),
|
|
1540
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:font-mono", children: p.value.toFixed(4) })
|
|
1541
|
+
]
|
|
1542
|
+
},
|
|
1543
|
+
i
|
|
1544
|
+
)),
|
|
1545
|
+
!amplitudeExtrema?.length && /* @__PURE__ */ jsx15("div", { className: "pbf:text-slate-700 pbf:italic", children: "No extrema found" })
|
|
1546
|
+
] })
|
|
1547
|
+
] }),
|
|
1548
|
+
/* @__PURE__ */ jsxs13("div", { children: [
|
|
1549
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:font-bold pbf:block pbf:mb-1", children: "Stats" }),
|
|
1550
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:bg-gray-50 pbf:p-2 pbf:rounded pbf:border pbf:border-gray-200", children: [
|
|
1551
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:flex pbf:justify-between", children: [
|
|
1552
|
+
/* @__PURE__ */ jsx15("span", { children: "Duration:" }),
|
|
1553
|
+
/* @__PURE__ */ jsxs13("span", { className: "pbf:font-mono", children: [
|
|
1554
|
+
maxTime,
|
|
1555
|
+
"ms"
|
|
1556
|
+
] })
|
|
1557
|
+
] }),
|
|
1558
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:flex pbf:justify-between", children: [
|
|
1559
|
+
/* @__PURE__ */ jsx15("span", { children: "Data Points:" }),
|
|
1560
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:font-mono", children: amplitudeData?.length || 0 })
|
|
1561
|
+
] }),
|
|
1562
|
+
/* @__PURE__ */ jsxs13("div", { className: "pbf:flex pbf:justify-between pbf:mt-1 pbf:pt-1 pbf:border-t pbf:border-gray-200", children: [
|
|
1563
|
+
/* @__PURE__ */ jsx15("span", { children: "Method:" }),
|
|
1564
|
+
/* @__PURE__ */ jsx15("span", { className: "pbf:text-blue-600 pbf:font-medium", children: hasData ? "Pre-calculated" : currentAmplitude > 0 ? "Real-time/Simulated" : "Idle" })
|
|
1565
|
+
] })
|
|
1566
|
+
] })
|
|
1567
|
+
] })
|
|
1568
|
+
] })
|
|
1569
|
+
] });
|
|
1570
|
+
}
|
|
1571
|
+
export {
|
|
1572
|
+
AmplitudeGraph,
|
|
1573
|
+
AudioAnalyzer,
|
|
1574
|
+
CONNECTION_FACE_MESSAGE,
|
|
1575
|
+
CharacterSelectionControls,
|
|
1576
|
+
CharacterSelectionSection,
|
|
1577
|
+
ControlSettingsSection,
|
|
1578
|
+
DEFAULT_FACE_MESSAGE,
|
|
1579
|
+
DEFAULT_FACE_UI_LABELS,
|
|
1580
|
+
EMOTION_EMOJIS,
|
|
1581
|
+
EMOTION_EMOTICONS,
|
|
1582
|
+
EMOTION_ICON_FILES,
|
|
1583
|
+
FaceAudioPrompt,
|
|
1584
|
+
FaceBehaviorControls,
|
|
1585
|
+
FaceCaption,
|
|
1586
|
+
FacePositioningControls,
|
|
1587
|
+
FacePositioningSection,
|
|
1588
|
+
FaceRendererRegistry,
|
|
1589
|
+
FaceSettingsControl,
|
|
1590
|
+
FaceSettingsPanel,
|
|
1591
|
+
FaceStoreContext,
|
|
1592
|
+
FaceStoreProvider,
|
|
1593
|
+
FaceTester,
|
|
1594
|
+
FaceTesterSection,
|
|
1595
|
+
FaceView,
|
|
1596
|
+
FaceViewSkeleton,
|
|
1597
|
+
FieldGroup,
|
|
1598
|
+
PEERBOTS_COLORS,
|
|
1599
|
+
PEERBOTS_EMOTIONS,
|
|
1600
|
+
PoweredByVizij,
|
|
1601
|
+
StaticFaceFallback,
|
|
1602
|
+
TtsAudioCache,
|
|
1603
|
+
VoiceSelector,
|
|
1604
|
+
audioAnalyzer,
|
|
1605
|
+
availableFaces,
|
|
1606
|
+
blobToArrayBuffer,
|
|
1607
|
+
buildTtsCacheKey,
|
|
1608
|
+
builtInFaces,
|
|
1609
|
+
color_mapping,
|
|
1610
|
+
createBuiltInFaces,
|
|
1611
|
+
createBuiltInPixiFaces,
|
|
1612
|
+
createCustomVizijFace,
|
|
1613
|
+
createDefaultFaceRendererRegistry,
|
|
1614
|
+
createFaceRenderingSlice,
|
|
1615
|
+
createFaceSpeechSlice,
|
|
1616
|
+
createIncludedVizijFaces,
|
|
1617
|
+
createPeerbotsFaceStore,
|
|
1618
|
+
customFace,
|
|
1619
|
+
deconstructRgba,
|
|
1620
|
+
defaultFace,
|
|
1621
|
+
defaultFaceRendererRegistry,
|
|
1622
|
+
defaultFaceSettings,
|
|
1623
|
+
defaultTtsAudioCache,
|
|
1624
|
+
emotion_mapping,
|
|
1625
|
+
estimateVisemesFromText,
|
|
1626
|
+
findMatchingVoice,
|
|
1627
|
+
font_color_mapping,
|
|
1628
|
+
formatRbga,
|
|
1629
|
+
formatRgba,
|
|
1630
|
+
formatVoiceDisplayName,
|
|
1631
|
+
getEmotionEyeSpritePaths,
|
|
1632
|
+
getEmotionIconPath,
|
|
1633
|
+
getFaceCapabilities,
|
|
1634
|
+
getGlobalFaceStore,
|
|
1635
|
+
getLanguageName,
|
|
1636
|
+
globalFaceStore,
|
|
1637
|
+
hexToRgb,
|
|
1638
|
+
hexToRgba,
|
|
1639
|
+
includedVizijFaces,
|
|
1640
|
+
interpolateColor,
|
|
1641
|
+
isHeadlessOrTestEnvironment,
|
|
1642
|
+
isWebGLAvailable,
|
|
1643
|
+
mapVisemeToVizijTarget,
|
|
1644
|
+
mergeFaceSettings,
|
|
1645
|
+
normalizeAssetBaseUrl,
|
|
1646
|
+
pixiFaceRendererStrategy,
|
|
1647
|
+
pollyVisemeToVizijPath,
|
|
1648
|
+
possiblePollyVisemes,
|
|
1649
|
+
rbgToRgba,
|
|
1650
|
+
resolveFaceUiLabels,
|
|
1651
|
+
rgbToRgba,
|
|
1652
|
+
rgbaToHex,
|
|
1653
|
+
setGlobalFaceStore,
|
|
1654
|
+
stopNativeSpeechSynthesis,
|
|
1655
|
+
useFaceStore,
|
|
1656
|
+
useFaceStoreInstance,
|
|
1657
|
+
useMessageVisualState,
|
|
1658
|
+
vizijFaceRendererStrategy
|
|
1659
|
+
};
|
|
1660
|
+
//# sourceMappingURL=index.js.map
|