@burdenoff/microfe-healthybowl 2026.829.3 → 2026.829.5
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/dist/components/assistant/AssistantHeader.js +40 -38
- package/dist/components/assistant/AssistantHeader.js.map +1 -1
- package/dist/components/assistant/AssistantSpeechProvider.js +165 -139
- package/dist/components/assistant/AssistantSpeechProvider.js.map +1 -1
- package/dist/components/assistant/composer/AssistantLanguageSelector.js +1 -1
- package/dist/components/assistant/composer/AssistantLanguageSelector.js.map +1 -1
- package/dist/components/assistant/composer/AssistantVoiceSelector.js +39 -0
- package/dist/components/assistant/composer/AssistantVoiceSelector.js.map +1 -0
- package/dist/config/assistantLanguages.js +29 -18
- package/dist/config/assistantLanguages.js.map +1 -1
- package/dist/services/speech/createSpeechEngine.js +32 -0
- package/dist/services/speech/createSpeechEngine.js.map +1 -0
- package/dist/services/speech/hostedTtsProtocol.js +41 -0
- package/dist/services/speech/hostedTtsProtocol.js.map +1 -0
- package/dist/services/speech/hostedTtsSpeechEngine.js +119 -0
- package/dist/services/speech/hostedTtsSpeechEngine.js.map +1 -0
- package/dist/services/speech/hostedVoiceCatalogue.js +52 -0
- package/dist/services/speech/hostedVoiceCatalogue.js.map +1 -0
- package/dist/services/speech/index.js +5 -0
- package/dist/services/speech/routingSpeechEngine.js +28 -0
- package/dist/services/speech/routingSpeechEngine.js.map +1 -0
- package/dist/store/assistantStore.js +10 -3
- package/dist/store/assistantStore.js.map +1 -1
- package/dist/utils/speakableText.js +7 -5
- package/dist/utils/speakableText.js.map +1 -1
- package/dist/utils/speechVoices.js +25 -12
- package/dist/utils/speechVoices.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,79 +1,81 @@
|
|
|
1
1
|
import { useTr as e } from "../../shared/hooks/useTr.js";
|
|
2
2
|
import { AssistantExportMenu as t } from "./AssistantExportMenu.js";
|
|
3
3
|
import { AssistantAutoSpeakToggle as n } from "./AssistantAutoSpeakToggle.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { AssistantVoiceSelector as r } from "./composer/AssistantVoiceSelector.js";
|
|
5
|
+
import { History as i, PanelBottom as a, PanelRight as o, Plus as s, Sparkles as c, X as l } from "lucide-react";
|
|
6
|
+
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
6
7
|
//#region src/components/assistant/AssistantHeader.tsx
|
|
7
|
-
var
|
|
8
|
-
let
|
|
9
|
-
return /* @__PURE__ */
|
|
8
|
+
var f = ({ contextLabel: f, onNewConversation: p, onOpenHistory: m, historyOpen: h, onClose: g, docked: _, onToggleDock: v }) => {
|
|
9
|
+
let y = e();
|
|
10
|
+
return /* @__PURE__ */ d("div", {
|
|
10
11
|
className: "flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5",
|
|
11
|
-
children: [/* @__PURE__ */
|
|
12
|
+
children: [/* @__PURE__ */ d("div", {
|
|
12
13
|
className: "flex min-w-0 flex-1 items-center gap-2",
|
|
13
|
-
children: [/* @__PURE__ */
|
|
14
|
+
children: [/* @__PURE__ */ u("span", {
|
|
14
15
|
className: "flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg",
|
|
15
|
-
children: /* @__PURE__ */
|
|
16
|
-
}), /* @__PURE__ */
|
|
16
|
+
children: /* @__PURE__ */ u(c, { className: "size-4" })
|
|
17
|
+
}), /* @__PURE__ */ d("span", {
|
|
17
18
|
className: "min-w-0 flex-1",
|
|
18
|
-
children: [/* @__PURE__ */
|
|
19
|
+
children: [/* @__PURE__ */ u("span", {
|
|
19
20
|
className: "block truncate text-[14px] font-semibold leading-tight text-text-primary",
|
|
20
|
-
children:
|
|
21
|
-
}), /* @__PURE__ */
|
|
21
|
+
children: y("healthybowl.assistant.header.title", "HealthyBowl AI")
|
|
22
|
+
}), /* @__PURE__ */ d("span", {
|
|
22
23
|
className: "block truncate text-[11px] leading-tight text-text-muted",
|
|
23
24
|
children: [
|
|
24
|
-
|
|
25
|
-
/* @__PURE__ */
|
|
25
|
+
y("healthybowl.assistant.header.ready", "Ready"),
|
|
26
|
+
/* @__PURE__ */ u("span", {
|
|
26
27
|
"aria-hidden": "true",
|
|
27
28
|
children: " · "
|
|
28
29
|
}),
|
|
29
|
-
|
|
30
|
+
y("healthybowl.assistant.header.context", "Context: {{page}}", { page: f })
|
|
30
31
|
]
|
|
31
32
|
})]
|
|
32
33
|
})]
|
|
33
|
-
}), /* @__PURE__ */
|
|
34
|
+
}), /* @__PURE__ */ d("div", {
|
|
34
35
|
className: "flex flex-shrink-0 items-center gap-0.5",
|
|
35
36
|
children: [
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
+
/* @__PURE__ */ u("button", {
|
|
37
38
|
type: "button",
|
|
38
|
-
onClick:
|
|
39
|
+
onClick: p,
|
|
39
40
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
40
|
-
"aria-label":
|
|
41
|
+
"aria-label": y("healthybowl.assistant.header.newConversation", "New conversation"),
|
|
41
42
|
"data-testid": "assistant-new-conversation",
|
|
42
|
-
children: /* @__PURE__ */
|
|
43
|
+
children: /* @__PURE__ */ u(s, { className: "size-4" })
|
|
43
44
|
}),
|
|
44
|
-
/* @__PURE__ */
|
|
45
|
+
/* @__PURE__ */ u("button", {
|
|
45
46
|
type: "button",
|
|
46
|
-
onClick:
|
|
47
|
-
className: `rounded-lg p-1.5 transition-colors ${
|
|
48
|
-
"aria-label":
|
|
49
|
-
"aria-pressed":
|
|
47
|
+
onClick: m,
|
|
48
|
+
className: `rounded-lg p-1.5 transition-colors ${h ? "bg-action-primary-bg/15 text-action-primary-bg" : "text-text-secondary hover:bg-bg-sunken hover:text-text-primary"}`,
|
|
49
|
+
"aria-label": y("healthybowl.assistant.header.history", "Conversation history"),
|
|
50
|
+
"aria-pressed": h,
|
|
50
51
|
"data-testid": "assistant-open-history",
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
+
children: /* @__PURE__ */ u(i, { className: "size-4" })
|
|
52
53
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
|
|
54
|
+
/* @__PURE__ */ u(n, {}),
|
|
55
|
+
/* @__PURE__ */ u(r, {}),
|
|
56
|
+
/* @__PURE__ */ u(t, {}),
|
|
57
|
+
v && /* @__PURE__ */ u("button", {
|
|
56
58
|
type: "button",
|
|
57
|
-
onClick:
|
|
59
|
+
onClick: v,
|
|
58
60
|
className: "hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex",
|
|
59
|
-
"aria-label":
|
|
60
|
-
"aria-pressed":
|
|
61
|
+
"aria-label": _ ? y("healthybowl.assistant.header.float", "Float chat window") : y("healthybowl.assistant.header.dock", "Dock to side panel"),
|
|
62
|
+
"aria-pressed": _,
|
|
61
63
|
"data-testid": "assistant-toggle-dock",
|
|
62
|
-
children:
|
|
64
|
+
children: u(_ ? a : o, { className: "size-4" })
|
|
63
65
|
}),
|
|
64
|
-
/* @__PURE__ */
|
|
66
|
+
/* @__PURE__ */ u("button", {
|
|
65
67
|
type: "button",
|
|
66
|
-
onClick:
|
|
68
|
+
onClick: g,
|
|
67
69
|
className: "rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary",
|
|
68
|
-
"aria-label":
|
|
70
|
+
"aria-label": y("healthybowl.assistant.header.close", "Close assistant"),
|
|
69
71
|
"data-testid": "assistant-close",
|
|
70
|
-
children: /* @__PURE__ */ l
|
|
72
|
+
children: /* @__PURE__ */ u(l, { className: "size-4" })
|
|
71
73
|
})
|
|
72
74
|
]
|
|
73
75
|
})]
|
|
74
76
|
});
|
|
75
77
|
};
|
|
76
78
|
//#endregion
|
|
77
|
-
export {
|
|
79
|
+
export { f as AssistantHeader };
|
|
78
80
|
|
|
79
81
|
//# sourceMappingURL=AssistantHeader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantExportMenu } from './AssistantExportMenu';\nimport { AssistantAutoSpeakToggle } from './AssistantAutoSpeakToggle';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantAutoSpeakToggle />\n <AssistantExportMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"AssistantHeader.js","names":[],"sources":["../../../src/components/assistant/AssistantHeader.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { Sparkles, Plus, History, PanelRight, PanelBottom, X } from 'lucide-react';\nimport { AssistantExportMenu } from './AssistantExportMenu';\nimport { AssistantAutoSpeakToggle } from './AssistantAutoSpeakToggle';\nimport { AssistantVoiceSelector } from './composer/AssistantVoiceSelector';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface Props {\n /** Friendly label for the page the user is on (e.g. \"Inventory\"). */\n contextLabel: string;\n onNewConversation: () => void;\n onOpenHistory: () => void;\n /** True when the history drawer is currently open (drives the toggle state). */\n historyOpen: boolean;\n onClose: () => void;\n docked?: boolean;\n onToggleDock?: () => void;\n}\n\n/**\n * AssistantHeader — the v2 identity bar (per the ai-assistant-v2 mockups):\n * a ✦ brand mark + \"HealthyBowl AI\", a small availability/context subtitle\n * (\"Ready · Context: <page>\"), and a row of icon actions: New conversation,\n * History (opens the conversation list as an overlay drawer — NOT an accordion),\n * Export, Dock toggle, Close.\n *\n * Replaces the old \"Conversation History\" accordion header. HB semantic tokens\n * only; copy via useTr.\n */\nexport const AssistantHeader: FC<Props> = ({\n contextLabel,\n onNewConversation,\n onOpenHistory,\n historyOpen,\n onClose,\n docked,\n onToggleDock,\n}) => {\n const tr = useTr();\n\n return (\n <div className=\"flex items-center gap-2 border-b border-border-default bg-bg-elevated px-3 py-2.5\">\n {/* Brand + context subtitle */}\n <div className=\"flex min-w-0 flex-1 items-center gap-2\">\n <span className=\"flex size-7 flex-shrink-0 items-center justify-center rounded-lg bg-gradient-to-br from-action-primary-bg/25 to-action-primary-bg/5 text-action-primary-bg\">\n <Sparkles className=\"size-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-[14px] font-semibold leading-tight text-text-primary\">\n {tr('healthybowl.assistant.header.title', 'HealthyBowl AI')}\n </span>\n <span className=\"block truncate text-[11px] leading-tight text-text-muted\">\n {tr('healthybowl.assistant.header.ready', 'Ready')}\n <span aria-hidden=\"true\"> · </span>\n {tr('healthybowl.assistant.header.context', 'Context: {{page}}', { page: contextLabel })}\n </span>\n </span>\n </div>\n\n {/* Actions */}\n <div className=\"flex flex-shrink-0 items-center gap-0.5\">\n <button\n type=\"button\"\n onClick={onNewConversation}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.newConversation', 'New conversation')}\n data-testid=\"assistant-new-conversation\"\n >\n <Plus className=\"size-4\" />\n </button>\n <button\n type=\"button\"\n onClick={onOpenHistory}\n className={`rounded-lg p-1.5 transition-colors ${\n historyOpen\n ? 'bg-action-primary-bg/15 text-action-primary-bg'\n : 'text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n }`}\n aria-label={tr('healthybowl.assistant.header.history', 'Conversation history')}\n aria-pressed={historyOpen}\n data-testid=\"assistant-open-history\"\n >\n <History className=\"size-4\" />\n </button>\n {/* Renders nothing where the browser has no speech output. */}\n <AssistantAutoSpeakToggle />\n {/* Beside the auto-speak toggle rather than in the composer: it is a\n playback setting, and the composer row is already exactly full at\n 390px — a fourth chip there would push send off the edge. Renders\n nothing when the device offers fewer than two voices. */}\n <AssistantVoiceSelector />\n <AssistantExportMenu />\n {onToggleDock && (\n <button\n type=\"button\"\n onClick={onToggleDock}\n className=\"hidden rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary md:inline-flex\"\n aria-label={\n docked\n ? tr('healthybowl.assistant.header.float', 'Float chat window')\n : tr('healthybowl.assistant.header.dock', 'Dock to side panel')\n }\n aria-pressed={docked}\n data-testid=\"assistant-toggle-dock\"\n >\n {docked ? <PanelBottom className=\"size-4\" /> : <PanelRight className=\"size-4\" />}\n </button>\n )}\n <button\n type=\"button\"\n onClick={onClose}\n className=\"rounded-lg p-1.5 text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n aria-label={tr('healthybowl.assistant.header.close', 'Close assistant')}\n data-testid=\"assistant-close\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;AA6BA,IAAa,KAA8B,EACzC,iBACA,sBACA,kBACA,gBACA,YACA,WACA,sBACI;CACJ,IAAM,IAAK,EAAM;CAEjB,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CAEE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACE,kBAAC,QAAD;IAAM,WAAU;cACd,kBAAC,GAAD,EAAU,WAAU,SAAU,CAAA;GAC1B,CAAA,GACN,kBAAC,QAAD;IAAM,WAAU;cAAhB,CACE,kBAAC,QAAD;KAAM,WAAU;eACb,EAAG,sCAAsC,gBAAgB;IACtD,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;eAAhB;MACG,EAAG,sCAAsC,OAAO;MACjD,kBAAC,QAAD;OAAM,eAAY;iBAAO;MAAS,CAAA;MACjC,EAAG,wCAAwC,qBAAqB,EAAE,MAAM,EAAa,CAAC;KACnF;MACF;KACH;MAGL,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,gDAAgD,kBAAkB;KACjF,eAAY;eAEZ,kBAAC,GAAD,EAAM,WAAU,SAAU,CAAA;IACpB,CAAA;IACR,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAW,sCACT,IACI,mDACA;KAEN,cAAY,EAAG,wCAAwC,sBAAsB;KAC7E,gBAAc;KACd,eAAY;eAEZ,kBAAC,GAAD,EAAS,WAAU,SAAU,CAAA;IACvB,CAAA;IAER,kBAAC,GAAD,CAA2B,CAAA;IAK3B,kBAAC,GAAD,CAAyB,CAAA;IACzB,kBAAC,GAAD,CAAsB,CAAA;IACrB,KACC,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cACE,IACI,EAAG,sCAAsC,mBAAmB,IAC5D,EAAG,qCAAqC,oBAAoB;KAElE,gBAAc;KACd,eAAY;eAEF,EAAT,IAAU,IAAqC,GAAtC,EAAa,WAAU,SAAU,CAAoC;IACzE,CAAA;IAEV,kBAAC,UAAD;KACE,MAAK;KACL,SAAS;KACT,WAAU;KACV,cAAY,EAAG,sCAAsC,iBAAiB;KACtE,eAAY;eAEZ,kBAAC,GAAD,EAAG,WAAU,SAAU,CAAA;IACjB,CAAA;GACL;IACF;;AAET"}
|
|
@@ -1,30 +1,37 @@
|
|
|
1
1
|
import { useAssistantStore as e } from "../../store/assistantStore.js";
|
|
2
2
|
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getSpeechEngine as n } from "../../services/speech/createSpeechEngine.js";
|
|
4
|
+
import "../../services/speech/index.js";
|
|
4
5
|
import { chunkForSpeech as r, toSpeakableText as i } from "../../utils/speakableText.js";
|
|
5
|
-
import { VOICE_LIST_TIMEOUT_MS as a, languageDisplayName as o, selectVoiceForLocale as s, speechGate as
|
|
6
|
+
import { VOICE_LIST_TIMEOUT_MS as a, languageDisplayName as o, selectVoiceForLocale as s, speechGate as ee, speechLangForLocale as c, voiceAvailability as l, voicesForLocale as u } from "../../utils/speechVoices.js";
|
|
6
7
|
import { resolveSpeechLocale as d } from "../../utils/replyLanguage.js";
|
|
7
|
-
import { findAssistantLanguage as f, resolveAssistantLanguage as
|
|
8
|
-
import { IDLE_PLAYBACK as
|
|
9
|
-
import { isTurnInFlight as
|
|
10
|
-
import { parseToolActivity as
|
|
11
|
-
import { createContext as
|
|
12
|
-
import { useI18n as
|
|
13
|
-
import { jsx as
|
|
8
|
+
import { findAssistantLanguage as f, resolveAssistantLanguage as te } from "../../config/assistantLanguages.js";
|
|
9
|
+
import { IDLE_PLAYBACK as ne, isSpeakingMessage as p, speechPlaybackReducer as re } from "../../utils/speechPlayback.js";
|
|
10
|
+
import { isTurnInFlight as ie } from "../../utils/assistantTurnState.js";
|
|
11
|
+
import { parseToolActivity as ae } from "./AssistantToolActivity.js";
|
|
12
|
+
import { createContext as m, useCallback as h, useContext as g, useEffect as _, useMemo as v, useReducer as oe, useRef as y, useState as b } from "react";
|
|
13
|
+
import { useI18n as se } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
14
|
+
import { jsx as ce } from "react/jsx-runtime";
|
|
14
15
|
//#region src/components/assistant/AssistantSpeechProvider.tsx
|
|
15
|
-
var
|
|
16
|
+
var le = {
|
|
16
17
|
codeBlock: "",
|
|
17
18
|
image: "",
|
|
18
19
|
link: "",
|
|
19
20
|
largeTable: "",
|
|
20
21
|
truncated: "",
|
|
22
|
+
emailAt: "at",
|
|
23
|
+
emailDot: "dot",
|
|
21
24
|
nestedItem: ""
|
|
22
|
-
},
|
|
25
|
+
}, x = m({
|
|
23
26
|
isSupported: !1,
|
|
24
27
|
availability: "unsupported",
|
|
25
28
|
isBlocked: !0,
|
|
26
29
|
disabledReason: null,
|
|
27
30
|
blockedFor: () => null,
|
|
31
|
+
voiceChoices: [],
|
|
32
|
+
activeVoiceName: null,
|
|
33
|
+
preferredVoiceName: null,
|
|
34
|
+
setVoice: () => {},
|
|
28
35
|
speakingMessageId: null,
|
|
29
36
|
isSpeaking: () => !1,
|
|
30
37
|
toggle: () => {},
|
|
@@ -32,196 +39,215 @@ var se = {
|
|
|
32
39
|
autoSpeakEnabled: !1,
|
|
33
40
|
setAutoSpeak: () => {}
|
|
34
41
|
});
|
|
35
|
-
function
|
|
36
|
-
return
|
|
42
|
+
function S() {
|
|
43
|
+
return g(x);
|
|
37
44
|
}
|
|
38
|
-
var
|
|
39
|
-
let
|
|
40
|
-
|
|
41
|
-
}, []),
|
|
42
|
-
|
|
43
|
-
if (!
|
|
45
|
+
var C = ({ children: m, visible: g = !0, engine: S = n() }) => {
|
|
46
|
+
let C = t(), { locale: w } = se(), [T, E] = oe(re, ne), [D, O] = b(() => S.listVoices()), [k, A] = b(!1), [j, M] = b(() => /* @__PURE__ */ new Map()), N = y(0), P = y(null), F = y(() => {}), I = h(() => {
|
|
47
|
+
P.current?.(), P.current = null;
|
|
48
|
+
}, []), L = e((e) => e.autoSpeakEnabled), R = e((e) => e.setAutoSpeak), ue = e((e) => e.activeConversationId), z = v(() => S.isSupported(), [S]);
|
|
49
|
+
_(() => {
|
|
50
|
+
if (!z) return;
|
|
44
51
|
let e = () => {
|
|
45
|
-
|
|
52
|
+
O(S.listVoices()), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
46
53
|
};
|
|
47
|
-
return e(),
|
|
48
|
-
}, [
|
|
49
|
-
let
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
]),
|
|
55
|
-
codeBlock:
|
|
56
|
-
image:
|
|
57
|
-
link:
|
|
58
|
-
largeTable:
|
|
59
|
-
truncated:
|
|
60
|
-
nestedItem:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, [
|
|
64
|
-
|
|
54
|
+
return e(), S.subscribeVoices(e);
|
|
55
|
+
}, [S, z]);
|
|
56
|
+
let B = e((e) => e.assistantLanguage), V = e((e) => e.preferredVoices), H = e((e) => e.setPreferredVoice), U = v(() => te(B, w), [B, w]), W = U.code, G = h((e) => f(e)?.tag ?? c(e), []), K = h((e) => f(e)?.rate ?? .9, []), q = v(() => l(z, D, U.tag, k), [
|
|
57
|
+
z,
|
|
58
|
+
D,
|
|
59
|
+
U,
|
|
60
|
+
k
|
|
61
|
+
]), J = v(() => ({
|
|
62
|
+
codeBlock: C("healthybowl.assistant.speech.codeBlock", "Code block"),
|
|
63
|
+
image: C("healthybowl.assistant.speech.image", "image"),
|
|
64
|
+
link: C("healthybowl.assistant.speech.link", "link"),
|
|
65
|
+
largeTable: C("healthybowl.assistant.speech.largeTable", "Table with {{rows}} rows and {{columns}} columns"),
|
|
66
|
+
truncated: C("healthybowl.assistant.speech.truncated", "The rest of this message is not read aloud"),
|
|
67
|
+
nestedItem: C("healthybowl.assistant.speech.nestedItem", "Sub-item {{ordinal}}"),
|
|
68
|
+
emailAt: C("healthybowl.assistant.speech.emailAt", "at"),
|
|
69
|
+
emailDot: C("healthybowl.assistant.speech.emailDot", "dot")
|
|
70
|
+
}), [C]), Y = h(() => {
|
|
71
|
+
I(), S.cancel(), E({ type: "stop" });
|
|
72
|
+
}, [I, S]), X = h((e) => j.get(e) ?? null, [j]), Z = h((e, t, n) => {
|
|
73
|
+
I();
|
|
65
74
|
let r = !1, i = () => {}, o = (a) => {
|
|
66
75
|
if (!r) {
|
|
67
|
-
if (r = !0,
|
|
68
|
-
|
|
76
|
+
if (r = !0, P.current = null, clearTimeout(s), i(), a.length === 0) {
|
|
77
|
+
A(!0);
|
|
69
78
|
return;
|
|
70
79
|
}
|
|
71
|
-
|
|
80
|
+
O(a), F.current(e, t, a, n);
|
|
72
81
|
}
|
|
73
|
-
}, s = setTimeout(() => o(
|
|
74
|
-
i =
|
|
75
|
-
r || (r = !0, clearTimeout(s), i(),
|
|
82
|
+
}, s = setTimeout(() => o(S.listVoices()), a);
|
|
83
|
+
i = S.subscribeVoices(() => o(S.listVoices())), P.current = () => {
|
|
84
|
+
r || (r = !0, clearTimeout(s), i(), P.current = null);
|
|
76
85
|
};
|
|
77
|
-
}, [
|
|
86
|
+
}, [I, S]), Q = h((e, t, n, i) => {
|
|
78
87
|
let a = n;
|
|
79
88
|
if (a.length === 0) {
|
|
80
|
-
let e =
|
|
81
|
-
e.length > 0 && (a = e,
|
|
89
|
+
let e = S.listVoices();
|
|
90
|
+
e.length > 0 && (a = e, O(e));
|
|
82
91
|
}
|
|
83
|
-
let
|
|
84
|
-
if (
|
|
85
|
-
let t =
|
|
86
|
-
|
|
92
|
+
let c = G(i), u = ee(l(!0, a, i, k));
|
|
93
|
+
if (u === "block") {
|
|
94
|
+
let t = C("healthybowl.assistant.speech.noVoiceForReply", "This reply is in {{language}}, and no {{language}} voice is installed on this device.", { language: o(c, w) });
|
|
95
|
+
M((n) => new Map(n).set(e, t));
|
|
87
96
|
return;
|
|
88
97
|
}
|
|
89
|
-
if (
|
|
90
|
-
|
|
98
|
+
if (u === "wait-for-voices") {
|
|
99
|
+
Z(e, t, i);
|
|
91
100
|
return;
|
|
92
101
|
}
|
|
93
|
-
|
|
102
|
+
M((t) => {
|
|
94
103
|
if (!t.has(e)) return t;
|
|
95
104
|
let n = new Map(t);
|
|
96
105
|
return n.delete(e), n;
|
|
97
106
|
});
|
|
98
|
-
let
|
|
99
|
-
|
|
107
|
+
let d = N.current + 1;
|
|
108
|
+
N.current = d, E({
|
|
100
109
|
type: "start",
|
|
101
110
|
messageId: e,
|
|
102
|
-
requestId:
|
|
103
|
-
}),
|
|
104
|
-
voice: s(a,
|
|
105
|
-
lang:
|
|
111
|
+
requestId: d
|
|
112
|
+
}), S.speak(r(t), {
|
|
113
|
+
voice: s(a, c, V[i]),
|
|
114
|
+
lang: c,
|
|
115
|
+
rate: K(i)
|
|
106
116
|
}, {
|
|
107
|
-
onEnd: () =>
|
|
117
|
+
onEnd: () => E({
|
|
108
118
|
type: "finished",
|
|
109
|
-
requestId:
|
|
119
|
+
requestId: d
|
|
110
120
|
}),
|
|
111
|
-
onError: () =>
|
|
121
|
+
onError: () => E({
|
|
112
122
|
type: "failed",
|
|
113
|
-
requestId:
|
|
123
|
+
requestId: d
|
|
114
124
|
})
|
|
115
125
|
});
|
|
116
126
|
}, [
|
|
117
|
-
|
|
118
|
-
T,
|
|
119
|
-
W,
|
|
127
|
+
S,
|
|
120
128
|
w,
|
|
121
|
-
|
|
122
|
-
|
|
129
|
+
V,
|
|
130
|
+
K,
|
|
131
|
+
G,
|
|
132
|
+
C,
|
|
133
|
+
k,
|
|
134
|
+
Z
|
|
123
135
|
]);
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}, [
|
|
127
|
-
let
|
|
128
|
-
if (!
|
|
129
|
-
let r = i(t, { labels:
|
|
130
|
-
r &&
|
|
136
|
+
_(() => {
|
|
137
|
+
F.current = Q;
|
|
138
|
+
}, [Q]);
|
|
139
|
+
let $ = h((e, t, n) => {
|
|
140
|
+
if (!z) return;
|
|
141
|
+
let r = i(t, { labels: J });
|
|
142
|
+
r && Q(e, r, D, d(i(t, { labels: le }), n ?? W));
|
|
131
143
|
}, [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
]),
|
|
138
|
-
if (
|
|
139
|
-
|
|
144
|
+
z,
|
|
145
|
+
J,
|
|
146
|
+
W,
|
|
147
|
+
Q,
|
|
148
|
+
D
|
|
149
|
+
]), de = h((e, t, n) => {
|
|
150
|
+
if (p(T, e)) {
|
|
151
|
+
Y();
|
|
140
152
|
return;
|
|
141
153
|
}
|
|
142
|
-
|
|
154
|
+
$(e, t, n);
|
|
143
155
|
}, [
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
156
|
+
T,
|
|
157
|
+
$,
|
|
158
|
+
Y
|
|
147
159
|
]);
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}, [
|
|
151
|
-
|
|
152
|
-
}, [
|
|
153
|
-
|
|
154
|
-
}, [
|
|
155
|
-
|
|
156
|
-
}, [
|
|
160
|
+
_(() => {
|
|
161
|
+
g || Y();
|
|
162
|
+
}, [g, Y]), _(() => {
|
|
163
|
+
Y(), M(/* @__PURE__ */ new Map());
|
|
164
|
+
}, [ue, Y]), _(() => {
|
|
165
|
+
M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map()), Y();
|
|
166
|
+
}, [W, Y]), _(() => () => {
|
|
167
|
+
P.current?.(), P.current = null, S.cancel();
|
|
168
|
+
}, [S]), _(() => {
|
|
157
169
|
if (typeof window > "u") return;
|
|
158
|
-
let e = () =>
|
|
170
|
+
let e = () => S.cancel();
|
|
159
171
|
return window.addEventListener("pagehide", e), () => window.removeEventListener("pagehide", e);
|
|
160
|
-
}, [
|
|
161
|
-
if (typeof document > "u" || !
|
|
172
|
+
}, [S]), _(() => {
|
|
173
|
+
if (typeof document > "u" || !z) return;
|
|
162
174
|
let e = () => {
|
|
163
175
|
if (document.visibilityState !== "visible") return;
|
|
164
|
-
let e =
|
|
165
|
-
e.length > 0 &&
|
|
176
|
+
let e = S.listVoices();
|
|
177
|
+
e.length > 0 && I(), O(e), A(!1), M((e) => e.size === 0 ? e : /* @__PURE__ */ new Map());
|
|
166
178
|
};
|
|
167
179
|
return document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), () => {
|
|
168
180
|
document.removeEventListener("visibilitychange", e), window.removeEventListener("focus", e);
|
|
169
181
|
};
|
|
170
182
|
}, [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
I,
|
|
184
|
+
S,
|
|
185
|
+
z
|
|
174
186
|
]);
|
|
175
|
-
let
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}, [
|
|
179
|
-
if (!(!
|
|
187
|
+
let fe = y($);
|
|
188
|
+
_(() => {
|
|
189
|
+
fe.current = $;
|
|
190
|
+
}, [$]), _(() => {
|
|
191
|
+
if (!(!L || !g || !z)) return e.subscribe((e, t) => {
|
|
180
192
|
let n = e.activeConversationId;
|
|
181
193
|
if (!n || n !== t.activeConversationId) return;
|
|
182
194
|
let r = e.processingByConversationId[n], i = t.processingByConversationId[n];
|
|
183
|
-
if (r?.status !== "complete" || !
|
|
195
|
+
if (r?.status !== "complete" || !ie(i?.status)) return;
|
|
184
196
|
let a = r.messageId ?? i?.messageId ?? null;
|
|
185
197
|
if (!a) return;
|
|
186
198
|
let o = e.conversations.find((e) => e.id === n)?.messages.find((e) => e.id === a);
|
|
187
199
|
if (!o || o.role !== "assistant") return;
|
|
188
|
-
let { text: s } =
|
|
189
|
-
s.trim() &&
|
|
200
|
+
let { text: s } = ae(o.content);
|
|
201
|
+
s.trim() && fe.current(a, s, o.metadata?.lang);
|
|
190
202
|
});
|
|
191
203
|
}, [
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
204
|
+
L,
|
|
205
|
+
z,
|
|
206
|
+
g
|
|
195
207
|
]);
|
|
196
|
-
let
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
+
let pe = v(() => u(D, U.tag), [D, U]), me = v(() => s(D, U.tag, V[W]), [
|
|
209
|
+
D,
|
|
210
|
+
U,
|
|
211
|
+
V,
|
|
212
|
+
W
|
|
213
|
+
]), he = v(() => ({
|
|
214
|
+
isSupported: z,
|
|
215
|
+
availability: q,
|
|
216
|
+
isBlocked: q === "no-voices",
|
|
217
|
+
disabledReason: q === "no-voices" ? C("healthybowl.assistant.speech.noVoicesOnDevice", "This device has no speech voices installed. Add one in your device speech or accessibility settings.") : null,
|
|
218
|
+
blockedFor: X,
|
|
219
|
+
voiceChoices: pe,
|
|
220
|
+
activeVoiceName: me?.name ?? null,
|
|
221
|
+
preferredVoiceName: V[W] ?? null,
|
|
222
|
+
setVoice: (e) => H(W, e),
|
|
223
|
+
speakingMessageId: T.status === "speaking" ? T.messageId : null,
|
|
224
|
+
isSpeaking: (e) => p(T, e),
|
|
225
|
+
toggle: de,
|
|
226
|
+
stop: Y,
|
|
227
|
+
autoSpeakEnabled: L,
|
|
228
|
+
setAutoSpeak: R
|
|
208
229
|
}), [
|
|
209
|
-
|
|
210
|
-
G,
|
|
211
|
-
J,
|
|
212
|
-
E,
|
|
213
|
-
Q,
|
|
230
|
+
z,
|
|
214
231
|
q,
|
|
232
|
+
X,
|
|
233
|
+
pe,
|
|
234
|
+
me,
|
|
235
|
+
V,
|
|
236
|
+
H,
|
|
237
|
+
W,
|
|
238
|
+
T,
|
|
239
|
+
de,
|
|
240
|
+
Y,
|
|
241
|
+
L,
|
|
215
242
|
R,
|
|
216
|
-
|
|
217
|
-
w
|
|
243
|
+
C
|
|
218
244
|
]);
|
|
219
|
-
return /* @__PURE__ */
|
|
220
|
-
value:
|
|
221
|
-
children:
|
|
245
|
+
return /* @__PURE__ */ ce(x.Provider, {
|
|
246
|
+
value: he,
|
|
247
|
+
children: m
|
|
222
248
|
});
|
|
223
249
|
};
|
|
224
250
|
//#endregion
|
|
225
|
-
export {
|
|
251
|
+
export { C as AssistantSpeechProvider, S as useAssistantSpeech };
|
|
226
252
|
|
|
227
253
|
//# sourceMappingURL=AssistantSpeechProvider.js.map
|