@mirai/core 0.4.449 → 0.4.450
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.
|
@@ -34,17 +34,20 @@ const Aura = () => {
|
|
|
34
34
|
return (0, _auraHelpers.subscribeToMessageSent)(handler);
|
|
35
35
|
}, [busyConversation, conversation]);
|
|
36
36
|
(0, _react2.useEffect)(() => {
|
|
37
|
-
if (type === _Core.TYPE.CHAIN && !hotel.id
|
|
37
|
+
if (type === _Core.TYPE.CHAIN && !hotel.id) return;
|
|
38
38
|
setContext({
|
|
39
39
|
hotelId: hotel.id
|
|
40
40
|
});
|
|
41
41
|
}, [hotel.id, type, id]);
|
|
42
42
|
const handlePressConversation = () => {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
_dataSources.Event.publish(_helpers.EVENT.METRICS, {
|
|
44
|
+
id: 'AURA:START'
|
|
45
|
+
});
|
|
46
|
+
const isChain = type === _Core.TYPE.CHAIN && !hotel.id;
|
|
47
|
+
const chainId = isChain ? id : null;
|
|
45
48
|
(0, _auraHelpers.handleConversation)(busyConversation, isConnecting, context, conversation, assistant, locale, setIsConnecting, setBusyConversation, isChain, chainId);
|
|
46
49
|
};
|
|
47
|
-
if (!context && !(type === _Core.TYPE.CHAIN && !hotel.id
|
|
50
|
+
if (!context && !(type === _Core.TYPE.CHAIN && !hotel.id)) return null;
|
|
48
51
|
const getIcon = () => {
|
|
49
52
|
if (busyConversation && isHovering) return _helpers.ICON.HANG_UP;
|
|
50
53
|
if (busyConversation) return _helpers.ICON.RECORD;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Aura.js","names":["_react","require","_dataSources","_ui","_react2","_interopRequireWildcard","style","_Core","_helpers","_auraHelpers","_AiHalo","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Aura","busyConversation","setBusyConversation","useState","isConnecting","setIsConnecting","context","setContext","isHovering","setIsHovering","conversation","useConversation","value","assistant","hotel","locale","type","id","useStore","useEffect","handler","createMessageSentHandler","subscribeToMessageSent","TYPE","CHAIN","
|
|
1
|
+
{"version":3,"file":"Aura.js","names":["_react","require","_dataSources","_ui","_react2","_interopRequireWildcard","style","_Core","_helpers","_auraHelpers","_AiHalo","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Aura","busyConversation","setBusyConversation","useState","isConnecting","setIsConnecting","context","setContext","isHovering","setIsHovering","conversation","useConversation","value","assistant","hotel","locale","type","id","useStore","useEffect","handler","createMessageSentHandler","subscribeToMessageSent","TYPE","CHAIN","hotelId","handlePressConversation","Event","publish","EVENT","METRICS","isChain","chainId","handleConversation","getIcon","ICON","HANG_UP","RECORD","AGENT","createElement","AiHalo","active","sensitivity","onMouseEnter","onMouseLeave","Button","busy","squared","top","onPress","className","styles","button","hangup","Icon","exports"],"sources":["../../../../../src/components/Chat/components/Aura/Aura.jsx"],"sourcesContent":["import { useConversation } from '@elevenlabs/react';\nimport { Event, useStore } from '@mirai/data-sources';\nimport { Button, Icon, styles } from '@mirai/ui';\nimport React, { useEffect, useState } from 'react';\n\nimport * as style from './Aura.module.css';\nimport { TYPE } from '../../../../Core.constants';\nimport { EVENT, ICON } from '../../../helpers';\nimport { createMessageSentHandler, subscribeToMessageSent, handleConversation } from '../../helpers/auraHelpers';\nimport { AiHalo } from '../AiHalo';\n\nconst Aura = () => {\n const [busyConversation, setBusyConversation] = useState(false);\n const [isConnecting, setIsConnecting] = useState(false);\n const [context, setContext] = useState(null);\n const [isHovering, setIsHovering] = useState(false);\n const conversation = useConversation();\n const {\n value: { assistant = {}, hotel = {}, locale, type, id },\n } = useStore();\n\n useEffect(() => {\n const handler = createMessageSentHandler(busyConversation, conversation, setBusyConversation);\n return subscribeToMessageSent(handler);\n }, [busyConversation, conversation]);\n\n useEffect(() => {\n if (type === TYPE.CHAIN && !hotel.id) return;\n\n setContext({ hotelId: hotel.id });\n }, [hotel.id, type, id]);\n\n const handlePressConversation = () => {\n Event.publish(EVENT.METRICS, { id: 'AURA:START' });\n const isChain = type === TYPE.CHAIN && !hotel.id;\n const chainId = isChain ? id : null;\n\n handleConversation(\n busyConversation,\n isConnecting,\n context,\n conversation,\n assistant,\n locale,\n setIsConnecting,\n setBusyConversation,\n isChain,\n chainId,\n );\n };\n\n if (!context && !(type === TYPE.CHAIN && !hotel.id)) return null;\n\n const getIcon = () => {\n if (busyConversation && isHovering) return ICON.HANG_UP;\n if (busyConversation) return ICON.RECORD;\n return ICON.AGENT;\n };\n\n return (\n <AiHalo\n active={busyConversation}\n conversation={conversation}\n sensitivity={1.2}\n onMouseEnter={() => setIsHovering(true)}\n onMouseLeave={() => setIsHovering(false)}\n >\n <Button\n busy={isConnecting}\n squared\n top\n onPress={handlePressConversation}\n className={styles(style.button, busyConversation && isHovering && style.hangup)}\n >\n <Icon value={getIcon()} />\n </Button>\n </AiHalo>\n );\n};\n\nexport { Aura };\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAC,uBAAA,CAAAJ,OAAA;AAEA,IAAAK,KAAA,GAAAD,uBAAA,CAAAJ,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,YAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAmC,SAAAI,wBAAAM,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAR,uBAAA,YAAAA,CAAAM,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC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