@agentscope-ai/chat 1.1.4
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 +88 -0
- package/dist/_util/hooks/use-proxy-imperative-handle.d.ts +4 -0
- package/dist/_util/hooks/use-proxy-imperative-handle.js +18 -0
- package/dist/_util/type.d.ts +1 -0
- package/dist/_util/type.js +1 -0
- package/dist/_util/warning.d.ts +30 -0
- package/dist/_util/warning.js +63 -0
- package/dist/accordion/Accordion.d.ts +22 -0
- package/dist/accordion/Accordion.js +93 -0
- package/dist/accordion/BodyContent.d.ts +8 -0
- package/dist/accordion/BodyContent.js +18 -0
- package/dist/accordion/DeepThink.d.ts +7 -0
- package/dist/accordion/DeepThink.js +35 -0
- package/dist/accordion/index.d.ts +2 -0
- package/dist/accordion/index.js +1 -0
- package/dist/accordion/index.less +170 -0
- package/dist/attachments/DropArea.d.ts +8 -0
- package/dist/attachments/DropArea.js +87 -0
- package/dist/attachments/FileList/AudioIcon.d.ts +2 -0
- package/dist/attachments/FileList/AudioIcon.js +19 -0
- package/dist/attachments/FileList/FileListCard.d.ts +12 -0
- package/dist/attachments/FileList/FileListCard.js +229 -0
- package/dist/attachments/FileList/Progress.d.ts +6 -0
- package/dist/attachments/FileList/Progress.js +21 -0
- package/dist/attachments/FileList/VideoIcon.d.ts +2 -0
- package/dist/attachments/FileList/VideoIcon.js +19 -0
- package/dist/attachments/FileList/index.d.ts +16 -0
- package/dist/attachments/FileList/index.js +132 -0
- package/dist/attachments/PlaceholderUploader.d.ts +17 -0
- package/dist/attachments/PlaceholderUploader.js +79 -0
- package/dist/attachments/SilentUploader.d.ts +9 -0
- package/dist/attachments/SilentUploader.js +23 -0
- package/dist/attachments/context.d.ts +5 -0
- package/dist/attachments/context.js +2 -0
- package/dist/attachments/index.d.ts +33 -0
- package/dist/attachments/index.js +166 -0
- package/dist/attachments/style/fileCard.d.ts +4 -0
- package/dist/attachments/style/fileCard.js +124 -0
- package/dist/attachments/style/index.d.ts +10 -0
- package/dist/attachments/style/index.js +211 -0
- package/dist/attachments/util.d.ts +2 -0
- package/dist/attachments/util.js +53 -0
- package/dist/bubble/Avatar.d.ts +10 -0
- package/dist/bubble/Avatar.js +22 -0
- package/dist/bubble/Bubble.d.ts +11 -0
- package/dist/bubble/Bubble.js +102 -0
- package/dist/bubble/BubbleList.d.ts +15 -0
- package/dist/bubble/BubbleList.js +44 -0
- package/dist/bubble/Cards.d.ts +21 -0
- package/dist/bubble/Cards.js +47 -0
- package/dist/bubble/ScrollToBottom.d.ts +7 -0
- package/dist/bubble/ScrollToBottom.js +45 -0
- package/dist/bubble/Spin.d.ts +2 -0
- package/dist/bubble/Spin.js +18 -0
- package/dist/bubble/hooks/useDisplayData.d.ts +0 -0
- package/dist/bubble/hooks/useDisplayData.js +0 -0
- package/dist/bubble/hooks/useListData.d.ts +0 -0
- package/dist/bubble/hooks/useListData.js +0 -0
- package/dist/bubble/index.d.ts +8 -0
- package/dist/bubble/index.js +4 -0
- package/dist/bubble/interface.d.ts +26 -0
- package/dist/bubble/interface.js +1 -0
- package/dist/bubble/loading.d.ts +6 -0
- package/dist/bubble/loading.js +17 -0
- package/dist/bubble/style/avatar.less +40 -0
- package/dist/bubble/style/content.d.ts +4 -0
- package/dist/bubble/style/content.js +43 -0
- package/dist/bubble/style/index.d.ts +9 -0
- package/dist/bubble/style/index.js +53 -0
- package/dist/bubble/style/list.less +15 -0
- package/dist/bubble/style/scrollToBottom.less +174 -0
- package/dist/chat-anywhere/Chat/Ref.d.ts +3 -0
- package/dist/chat-anywhere/Chat/Ref.js +19 -0
- package/dist/chat-anywhere/Chat/index.d.ts +4 -0
- package/dist/chat-anywhere/Chat/index.js +65 -0
- package/dist/chat-anywhere/Chat/index.less +54 -0
- package/dist/chat-anywhere/Header/index.d.ts +3 -0
- package/dist/chat-anywhere/Header/index.js +32 -0
- package/dist/chat-anywhere/Header/index.less +24 -0
- package/dist/chat-anywhere/Input/index.d.ts +3 -0
- package/dist/chat-anywhere/Input/index.js +170 -0
- package/dist/chat-anywhere/Input/index.less +12 -0
- package/dist/chat-anywhere/Layout/index.d.ts +10 -0
- package/dist/chat-anywhere/Layout/index.js +73 -0
- package/dist/chat-anywhere/Layout/index.less +61 -0
- package/dist/chat-anywhere/SessionList/index.d.ts +5 -0
- package/dist/chat-anywhere/SessionList/index.js +115 -0
- package/dist/chat-anywhere/SessionList/index.less +52 -0
- package/dist/chat-anywhere/hooks/ChatAnywhereProvider.d.ts +43 -0
- package/dist/chat-anywhere/hooks/ChatAnywhereProvider.js +90 -0
- package/dist/chat-anywhere/hooks/types.d.ts +57 -0
- package/dist/chat-anywhere/hooks/types.js +1 -0
- package/dist/chat-anywhere/hooks/useInput.d.ts +7 -0
- package/dist/chat-anywhere/hooks/useInput.js +21 -0
- package/dist/chat-anywhere/hooks/useMessages.d.ts +11 -0
- package/dist/chat-anywhere/hooks/useMessages.js +56 -0
- package/dist/chat-anywhere/hooks/useSessionList.d.ts +24 -0
- package/dist/chat-anywhere/hooks/useSessionList.js +120 -0
- package/dist/chat-anywhere/index.d.ts +9 -0
- package/dist/chat-anywhere/index.js +58 -0
- package/dist/conversations/GroupTitle.d.ts +10 -0
- package/dist/conversations/GroupTitle.js +15 -0
- package/dist/conversations/Item.d.ts +14 -0
- package/dist/conversations/Item.js +96 -0
- package/dist/conversations/hooks/useGroupable.d.ts +9 -0
- package/dist/conversations/hooks/useGroupable.js +72 -0
- package/dist/conversations/index.d.ts +62 -0
- package/dist/conversations/index.js +124 -0
- package/dist/conversations/interface.d.ts +60 -0
- package/dist/conversations/interface.js +1 -0
- package/dist/conversations/style/index.d.ts +9 -0
- package/dist/conversations/style/index.js +80 -0
- package/dist/default-cards/Count/index.d.ts +3 -0
- package/dist/default-cards/Count/index.js +16 -0
- package/dist/default-cards/Count/index.less +19 -0
- package/dist/default-cards/DeepThink/index.d.ts +11 -0
- package/dist/default-cards/DeepThink/index.js +11 -0
- package/dist/default-cards/DeepThink/index.less +0 -0
- package/dist/default-cards/Files/index.d.ts +2 -0
- package/dist/default-cards/Files/index.js +18 -0
- package/dist/default-cards/Footer/index.d.ts +19 -0
- package/dist/default-cards/Footer/index.js +50 -0
- package/dist/default-cards/Footer/index.less +41 -0
- package/dist/default-cards/Images/index.d.ts +3 -0
- package/dist/default-cards/Images/index.js +33 -0
- package/dist/default-cards/Images/index.less +17 -0
- package/dist/default-cards/Interrupted/index.d.ts +11 -0
- package/dist/default-cards/Interrupted/index.js +40 -0
- package/dist/default-cards/Interrupted/index.less +57 -0
- package/dist/default-cards/Text/index.d.ts +2 -0
- package/dist/default-cards/Text/index.js +12 -0
- package/dist/default-cards/index.d.ts +6 -0
- package/dist/default-cards/index.js +6 -0
- package/dist/disclaimer/index.d.ts +11 -0
- package/dist/disclaimer/index.js +26 -0
- package/dist/docs/1896.async.js +457 -0
- package/dist/docs/2710.async.js +62 -0
- package/dist/docs/2863.async.js +400 -0
- package/dist/docs/3057.async.js +46 -0
- package/dist/docs/3364.async.js +25 -0
- package/dist/docs/404.html +15 -0
- package/dist/docs/4820.async.js +1381 -0
- package/dist/docs/5623.async.js +60 -0
- package/dist/docs/5757.async.js +1 -0
- package/dist/docs/5804.async.js +271 -0
- package/dist/docs/6198.async.js +18 -0
- package/dist/docs/6671.async.js +137 -0
- package/dist/docs/7195.async.js +1 -0
- package/dist/docs/7485.async.js +29 -0
- package/dist/docs/7931.async.js +19 -0
- package/dist/docs/7997.async.js +5 -0
- package/dist/docs/8156.async.js +110 -0
- package/dist/docs/8368.async.js +2 -0
- package/dist/docs/8480.async.js +1449 -0
- package/dist/docs/8618.async.js +246 -0
- package/dist/docs/9016.async.js +32 -0
- package/dist/docs/9016.chunk.css +1 -0
- package/dist/docs/9335.async.js +11 -0
- package/dist/docs/accordion__demos.async.js +9 -0
- package/dist/docs/attachments__demos.async.js +1 -0
- package/dist/docs/bubble__demos.async.js +50 -0
- package/dist/docs/components/accordion/index.html +15 -0
- package/dist/docs/components/accordion-cn/index.html +15 -0
- package/dist/docs/components/attachments/index.html +15 -0
- package/dist/docs/components/attachments-cn/index.html +15 -0
- package/dist/docs/components/bubble/index.html +15 -0
- package/dist/docs/components/bubble-cn/index.html +15 -0
- package/dist/docs/components/bubble-list/index.html +15 -0
- package/dist/docs/components/bubble-list-cn/index.html +15 -0
- package/dist/docs/components/conversations/index.html +15 -0
- package/dist/docs/components/conversations-cn/index.html +15 -0
- package/dist/docs/components/disclaimer/index.html +15 -0
- package/dist/docs/components/disclaimer-cn/index.html +15 -0
- package/dist/docs/components/footer/index.html +15 -0
- package/dist/docs/components/footer-cn/index.html +15 -0
- package/dist/docs/components/markdown/index.html +15 -0
- package/dist/docs/components/markdown-cn/index.html +15 -0
- package/dist/docs/components/sender/index.html +15 -0
- package/dist/docs/components/sender-cn/index.html +15 -0
- package/dist/docs/components/status/index.html +15 -0
- package/dist/docs/components/status-cn/index.html +15 -0
- package/dist/docs/components/welcome/index.html +15 -0
- package/dist/docs/components/welcome-cn/index.html +15 -0
- package/dist/docs/components__accordion__index.en-US.md.async.js +6 -0
- package/dist/docs/components__accordion__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__accordion__index.zh-CN.md.async.js +6 -0
- package/dist/docs/components__accordion__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__attachments__index.en-US.md.async.js +1 -0
- package/dist/docs/components__attachments__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__attachments__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__attachments__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__bubble-list__index.en-US.md.async.js +2 -0
- package/dist/docs/components__bubble-list__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__bubble-list__index.zh-CN.md.async.js +2 -0
- package/dist/docs/components__bubble-list__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__bubble__index.en-US.md.async.js +1 -0
- package/dist/docs/components__bubble__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__bubble__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__bubble__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__conversations__index.en-US.md.async.js +2 -0
- package/dist/docs/components__conversations__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__conversations__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__conversations__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__disclaimer__index.en-US.md.async.js +1 -0
- package/dist/docs/components__disclaimer__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__disclaimer__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__disclaimer__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__footer__index.en-US.md.async.js +1 -0
- package/dist/docs/components__footer__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__footer__index.zh-CN.md.async.js +2 -0
- package/dist/docs/components__footer__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__markdown__index.en-US.md.async.js +1 -0
- package/dist/docs/components__markdown__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__markdown__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__markdown__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__sender__index.en-US.md.async.js +1 -0
- package/dist/docs/components__sender__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__sender__index.zh-CN.md.async.js +1 -0
- package/dist/docs/components__sender__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__status__index.en-US.md.async.js +1 -0
- package/dist/docs/components__status__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__status__index.zh-CN.md.async.js +2 -0
- package/dist/docs/components__status__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/components__welcome__index.en-US.md.async.js +2 -0
- package/dist/docs/components__welcome__index.en-US.md.chunk.css +1 -0
- package/dist/docs/components__welcome__index.zh-CN.md.async.js +2 -0
- package/dist/docs/components__welcome__index.zh-CN.md.chunk.css +1 -0
- package/dist/docs/conversations__demos.async.js +1 -0
- package/dist/docs/demos.async.js +47 -0
- package/dist/docs/demos.chunk.css +1 -0
- package/dist/docs/disclaimer__demos.async.js +1 -0
- package/dist/docs/docs/development/ag-ui/index.html +15 -0
- package/dist/docs/docs/development/ag-ui-cn/index.html +15 -0
- package/dist/docs/docs/development/backend/index.html +15 -0
- package/dist/docs/docs/development/backend-cn/index.html +15 -0
- package/dist/docs/docs/development/cards/index.html +15 -0
- package/dist/docs/docs/development/cards-cn/index.html +15 -0
- package/dist/docs/docs/development/chatanywhere/index.html +15 -0
- package/dist/docs/docs/development/chatanywhere-api/index.html +15 -0
- package/dist/docs/docs/development/chatanywhere-api-cn/index.html +15 -0
- package/dist/docs/docs/development/chatanywhere-cn/index.html +15 -0
- package/dist/docs/docs/development/custom/index.html +15 -0
- package/dist/docs/docs/development/custom-cn/index.html +15 -0
- package/dist/docs/docs/development/overview/index.html +15 -0
- package/dist/docs/docs/development/overview-cn/index.html +15 -0
- package/dist/docs/docs/development/qwen/index.html +15 -0
- package/dist/docs/docs/development/qwen-cn/index.html +15 -0
- package/dist/docs/docs/templates/copilot/index.html +15 -0
- package/dist/docs/docs/templates/copilot-cn/index.html +15 -0
- package/dist/docs/docs/templates/native/index.html +15 -0
- package/dist/docs/docs/templates/native-cn/index.html +15 -0
- package/dist/docs/docs/templates/voice/index.html +15 -0
- package/dist/docs/docs/templates/voice-cn/index.html +15 -0
- package/dist/docs/docs__development__ag-ui.en-US.md.async.js +210 -0
- package/dist/docs/docs__development__ag-ui.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__ag-ui.zh-CN.md.async.js +210 -0
- package/dist/docs/docs__development__ag-ui.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__backend.en-US.md.async.js +12 -0
- package/dist/docs/docs__development__backend.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__backend.zh-CN.md.async.js +12 -0
- package/dist/docs/docs__development__backend.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__cards.en-US.md.async.js +27 -0
- package/dist/docs/docs__development__cards.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__cards.zh-CN.md.async.js +27 -0
- package/dist/docs/docs__development__cards.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__chatanywhere-api.en-US.md.async.js +69 -0
- package/dist/docs/docs__development__chatanywhere-api.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__chatanywhere-api.zh-CN.md.async.js +69 -0
- package/dist/docs/docs__development__chatanywhere-api.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__chatanywhere.en-US.md.async.js +77 -0
- package/dist/docs/docs__development__chatanywhere.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__chatanywhere.zh-CN.md.async.js +77 -0
- package/dist/docs/docs__development__chatanywhere.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__custom.en-US.md.async.js +22 -0
- package/dist/docs/docs__development__custom.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__custom.zh-CN.md.async.js +22 -0
- package/dist/docs/docs__development__custom.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__overview.en-US.md.async.js +21 -0
- package/dist/docs/docs__development__overview.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__overview.zh-CN.md.async.js +21 -0
- package/dist/docs/docs__development__overview.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__development__qwen.en-US.md.async.js +25 -0
- package/dist/docs/docs__development__qwen.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__development__qwen.zh-CN.md.async.js +25 -0
- package/dist/docs/docs__development__qwen.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__templates__copilot.en-US.md.async.js +1 -0
- package/dist/docs/docs__templates__copilot.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__templates__copilot.zh-CN.md.async.js +1 -0
- package/dist/docs/docs__templates__copilot.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__templates__native.en-US.md.async.js +1 -0
- package/dist/docs/docs__templates__native.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__templates__native.zh-CN.md.async.js +1 -0
- package/dist/docs/docs__templates__native.zh-CN.md.chunk.css +1 -0
- package/dist/docs/docs__templates__voice.en-US.md.async.js +20 -0
- package/dist/docs/docs__templates__voice.en-US.md.chunk.css +1 -0
- package/dist/docs/docs__templates__voice.zh-CN.md.async.js +1 -0
- package/dist/docs/docs__templates__voice.zh-CN.md.chunk.css +1 -0
- package/dist/docs/dumi__pages__index__index.en-US.async.js +1 -0
- package/dist/docs/dumi__pages__index__index.en-US.chunk.css +1 -0
- package/dist/docs/dumi__pages__index__index.zh-CN.async.js +1 -0
- package/dist/docs/dumi__pages__index__index.zh-CN.chunk.css +1 -0
- package/dist/docs/dumi__theme__layouts__DocLayout__index.async.js +1 -0
- package/dist/docs/dumi__theme__layouts__DocLayout__index.chunk.css +1 -0
- package/dist/docs/dumi__theme__layouts__GlobalLayout__index.async.js +18 -0
- package/dist/docs/dumi__theme__layouts__GlobalLayout__index.chunk.css +1 -0
- package/dist/docs/dumi__tmp-production__dumi__theme__ContextWrapper.async.js +1 -0
- package/dist/docs/index/index.html +15 -0
- package/dist/docs/index-cn/index.html +15 -0
- package/dist/docs/markdown__demos.async.js +164 -0
- package/dist/docs/meta__components__en-US.async.js +9 -0
- package/dist/docs/meta__components__zh-CN.async.js +10 -0
- package/dist/docs/meta__docs__en-US.async.js +475 -0
- package/dist/docs/meta__docs__en-US.chunk.css +1 -0
- package/dist/docs/meta__docs__zh-CN.async.js +456 -0
- package/dist/docs/meta__docs__zh-CN.chunk.css +1 -0
- package/dist/docs/nm__dumi__dist__client__pages__404.async.js +1 -0
- package/dist/docs/nm__dumi__dist__client__pages__Demo__index.async.js +1 -0
- package/dist/docs/nm__dumi__dist__client__pages__Demo__index.chunk.css +1 -0
- package/dist/docs/preload_helper.js +1 -0
- package/dist/docs/sender__demos.async.js +1 -0
- package/dist/docs/umi.css +1 -0
- package/dist/docs/umi.js +107 -0
- package/dist/docs/welcome__demos.async.js +1 -0
- package/dist/docs/~demos/:id/index.html +15 -0
- package/dist/docs/~demos/accordion-demo-inline/index.html +15 -0
- package/dist/docs/~demos/accordion-demo-mutisteps/index.html +15 -0
- package/dist/docs/~demos/accordion-demo-thinking/index.html +15 -0
- package/dist/docs/~demos/attachments-demo-files/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-basic/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-havestopped/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-userwithfile/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-userwithimage/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-userwithnormal/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-withavatar/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-withcode/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-witherror/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-witherrordetail/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-withimage/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-withusage/index.html +15 -0
- package/dist/docs/~demos/bubble-demo-withwaitingmessage/index.html +15 -0
- package/dist/docs/~demos/components-bubble-list-demo-basic/index.html +15 -0
- package/dist/docs/~demos/components-footer-demo-basic/index.html +15 -0
- package/dist/docs/~demos/components-footer-demo-withusage/index.html +15 -0
- package/dist/docs/~demos/components-status-demo-basic/index.html +15 -0
- package/dist/docs/~demos/conversations-demo-basic/index.html +15 -0
- package/dist/docs/~demos/disclaimer-demo-demo/index.html +15 -0
- package/dist/docs/~demos/disclaimer-demo-withlink/index.html +15 -0
- package/dist/docs/~demos/docs-development-ag-ui-demo-with-copilotkit/index.html +15 -0
- package/dist/docs/~demos/docs-development-cards-demo-file/index.html +15 -0
- package/dist/docs/~demos/docs-development-cards-demo-footer/index.html +15 -0
- package/dist/docs/~demos/docs-development-cards-demo-image/index.html +15 -0
- package/dist/docs/~demos/docs-development-cards-demo-text/index.html +15 -0
- package/dist/docs/~demos/docs-development-custom-demo-custom/index.html +15 -0
- package/dist/docs/~demos/docs-templates-copilot-demo-copilot/index.html +15 -0
- package/dist/docs/~demos/docs-templates-native-demo-basic/index.html +15 -0
- package/dist/docs/~demos/docs-templates-voice-demo-demo/index.html +15 -0
- package/dist/docs/~demos/markdown-demo-citations/index.html +15 -0
- package/dist/docs/~demos/markdown-demo-cursor/index.html +15 -0
- package/dist/docs/~demos/markdown-demo-mathjax/index.html +15 -0
- package/dist/docs/~demos/markdown-demo-md/index.html +15 -0
- package/dist/docs/~demos/sender-demo-basic/index.html +15 -0
- package/dist/docs/~demos/sender-demo-disabled/index.html +15 -0
- package/dist/docs/~demos/sender-demo-loading/index.html +15 -0
- package/dist/docs/~demos/sender-demo-moreprefixaction/index.html +15 -0
- package/dist/docs/~demos/sender-demo-withfile/index.html +15 -0
- package/dist/docs/~demos/welcome-demo-demo0/index.html +15 -0
- package/dist/docs/~demos/welcome-demo-demo1/index.html +15 -0
- package/dist/docs/~demos/welcome-demo-demo2/index.html +15 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +20 -0
- package/dist/index.less +1 -0
- package/dist/markdown/Citation.d.ts +16 -0
- package/dist/markdown/Citation.js +55 -0
- package/dist/markdown/CodeBlock.d.ts +6 -0
- package/dist/markdown/CodeBlock.js +88 -0
- package/dist/markdown/ImageOrVideo.d.ts +2 -0
- package/dist/markdown/ImageOrVideo.js +81 -0
- package/dist/markdown/Link.d.ts +3 -0
- package/dist/markdown/Link.js +28 -0
- package/dist/markdown/Markdown.d.ts +4 -0
- package/dist/markdown/Markdown.js +121 -0
- package/dist/markdown/cursor/Blur.d.ts +3 -0
- package/dist/markdown/cursor/Blur.js +7 -0
- package/dist/markdown/cursor/Dot.d.ts +3 -0
- package/dist/markdown/cursor/Dot.js +16 -0
- package/dist/markdown/cursor/Underline.d.ts +3 -0
- package/dist/markdown/cursor/Underline.js +7 -0
- package/dist/markdown/cursor/index.less +124 -0
- package/dist/markdown/hooks/index.d.ts +1 -0
- package/dist/markdown/hooks/index.js +49 -0
- package/dist/markdown/hooks/useTypedEffect.d.ts +6 -0
- package/dist/markdown/hooks/useTypedEffect.js +56 -0
- package/dist/markdown/index.d.ts +16 -0
- package/dist/markdown/index.js +37 -0
- package/dist/markdown/index.less +204 -0
- package/dist/markdown/plugins/footnote.d.ts +2 -0
- package/dist/markdown/plugins/footnote.js +89 -0
- package/dist/markdown/plugins/katexDir.d.ts +1 -0
- package/dist/markdown/plugins/katexDir.js +15 -0
- package/dist/markdown/rehype/fadeIn.d.ts +2 -0
- package/dist/markdown/rehype/fadeIn.js +43 -0
- package/dist/markdown/type.d.ts +46 -0
- package/dist/markdown/type.js +1 -0
- package/dist/markdown/utils.d.ts +22 -0
- package/dist/markdown/utils.js +125 -0
- package/dist/provider/CustomCardsProvider.d.ts +15 -0
- package/dist/provider/CustomCardsProvider.js +18 -0
- package/dist/provider/GlobalProvider.d.ts +5 -0
- package/dist/provider/GlobalProvider.js +11 -0
- package/dist/provider/index.d.ts +8 -0
- package/dist/provider/index.js +20 -0
- package/dist/provider/types.d.ts +8 -0
- package/dist/provider/types.js +1 -0
- package/dist/sender/SenderHeader.d.ts +19 -0
- package/dist/sender/SenderHeader.js +79 -0
- package/dist/sender/StopLoading.d.ts +5 -0
- package/dist/sender/StopLoading.js +20 -0
- package/dist/sender/components/ActionButton.d.ts +22 -0
- package/dist/sender/components/ActionButton.js +39 -0
- package/dist/sender/components/ClearButton.d.ts +4 -0
- package/dist/sender/components/ClearButton.js +13 -0
- package/dist/sender/components/LoadingButton.d.ts +4 -0
- package/dist/sender/components/LoadingButton.js +22 -0
- package/dist/sender/components/SendButton.d.ts +4 -0
- package/dist/sender/components/SendButton.js +14 -0
- package/dist/sender/components/SpeechButton/RecordingIcon.d.ts +5 -0
- package/dist/sender/components/SpeechButton/RecordingIcon.js +49 -0
- package/dist/sender/components/SpeechButton/index.d.ts +4 -0
- package/dist/sender/components/SpeechButton/index.js +30 -0
- package/dist/sender/index.d.ts +61 -0
- package/dist/sender/index.js +307 -0
- package/dist/sender/style/header.d.ts +4 -0
- package/dist/sender/style/header.js +46 -0
- package/dist/sender/style/index.d.ts +10 -0
- package/dist/sender/style/index.js +123 -0
- package/dist/sender/useSpeech.d.ts +6 -0
- package/dist/sender/useSpeech.js +114 -0
- package/dist/stream/index.d.ts +34 -0
- package/dist/stream/index.en-US.md.bk +50 -0
- package/dist/stream/index.js +197 -0
- package/dist/stream/index.zh-CN.md.bk +51 -0
- package/dist/theme/components.d.ts +10 -0
- package/dist/theme/components.js +1 -0
- package/dist/theme/cssinjs-utils.d.ts +14 -0
- package/dist/theme/cssinjs-utils.js +1 -0
- package/dist/theme/genStyleUtils.d.ts +28 -0
- package/dist/theme/genStyleUtils.js +49 -0
- package/dist/theme/useToken.d.ts +18 -0
- package/dist/theme/useToken.js +110 -0
- package/dist/version/index.d.ts +2 -0
- package/dist/version/index.js +2 -0
- package/dist/voice-chat/Recorder/index.d.ts +26 -0
- package/dist/voice-chat/Recorder/index.js +168 -0
- package/dist/voice-chat/VoiceChatProvider/context.d.ts +22 -0
- package/dist/voice-chat/VoiceChatProvider/context.js +3 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useChatState.d.ts +1 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useChatState.js +5 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useMessages.d.ts +8 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useMessages.js +31 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useRecorder.d.ts +5 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useRecorder.js +48 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useVoiceChat.d.ts +4 -0
- package/dist/voice-chat/VoiceChatProvider/hooks/useVoiceChat.js +10 -0
- package/dist/voice-chat/VoiceChatProvider/index.d.ts +9 -0
- package/dist/voice-chat/VoiceChatProvider/index.js +55 -0
- package/dist/voice-chat/VoiceChatService/index.d.ts +34 -0
- package/dist/voice-chat/VoiceChatService/index.js +209 -0
- package/dist/voice-chat/index.d.ts +2 -0
- package/dist/voice-chat/index.js +2 -0
- package/dist/voice-chat/types/index.d.ts +12 -0
- package/dist/voice-chat/types/index.js +4 -0
- package/dist/welcome/icon.d.ts +2 -0
- package/dist/welcome/icon.js +38 -0
- package/dist/welcome/index.d.ts +9 -0
- package/dist/welcome/index.js +57 -0
- package/package.json +117 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
var _excluded = ["override"],
|
|
3
|
+
_excluded2 = ["theme"];
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
13
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
14
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
16
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
17
|
+
import { createTheme, useCacheToken } from '@ant-design/cssinjs';
|
|
18
|
+
import { theme as antdTheme } from 'antd';
|
|
19
|
+
import { ignore, unitless } from 'antd/es/theme/useToken';
|
|
20
|
+
import formatToken from 'antd/es/theme/util/alias';
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import version from "../version";
|
|
23
|
+
var defaultTheme = createTheme(antdTheme.defaultAlgorithm);
|
|
24
|
+
var preserve = {
|
|
25
|
+
screenXS: true,
|
|
26
|
+
screenXSMin: true,
|
|
27
|
+
screenXSMax: true,
|
|
28
|
+
screenSM: true,
|
|
29
|
+
screenSMMin: true,
|
|
30
|
+
screenSMMax: true,
|
|
31
|
+
screenMD: true,
|
|
32
|
+
screenMDMin: true,
|
|
33
|
+
screenMDMax: true,
|
|
34
|
+
screenLG: true,
|
|
35
|
+
screenLGMin: true,
|
|
36
|
+
screenLGMax: true,
|
|
37
|
+
screenXL: true,
|
|
38
|
+
screenXLMin: true,
|
|
39
|
+
screenXLMax: true,
|
|
40
|
+
screenXXL: true,
|
|
41
|
+
screenXXLMin: true
|
|
42
|
+
};
|
|
43
|
+
export var getComputedToken = function getComputedToken(originToken, overrideToken, theme) {
|
|
44
|
+
var derivativeToken = theme.getDerivativeToken(originToken);
|
|
45
|
+
var override = overrideToken.override,
|
|
46
|
+
components = _objectWithoutProperties(overrideToken, _excluded);
|
|
47
|
+
|
|
48
|
+
// Merge with override
|
|
49
|
+
var mergedDerivativeToken = _objectSpread(_objectSpread({}, derivativeToken), {}, {
|
|
50
|
+
override: override
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Format if needed
|
|
54
|
+
mergedDerivativeToken = formatToken(mergedDerivativeToken);
|
|
55
|
+
if (components) {
|
|
56
|
+
Object.entries(components).forEach(function (_ref) {
|
|
57
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
58
|
+
key = _ref2[0],
|
|
59
|
+
value = _ref2[1];
|
|
60
|
+
var componentTheme = value.theme,
|
|
61
|
+
componentTokens = _objectWithoutProperties(value, _excluded2);
|
|
62
|
+
var mergedComponentToken = componentTokens;
|
|
63
|
+
if (componentTheme) {
|
|
64
|
+
mergedComponentToken = getComputedToken(_objectSpread(_objectSpread({}, mergedDerivativeToken), componentTokens), {
|
|
65
|
+
override: componentTokens
|
|
66
|
+
}, componentTheme);
|
|
67
|
+
}
|
|
68
|
+
mergedDerivativeToken[key] = mergedComponentToken;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return mergedDerivativeToken;
|
|
72
|
+
};
|
|
73
|
+
export function useInternalToken() {
|
|
74
|
+
var _React$useContext = React.useContext(antdTheme._internalContext),
|
|
75
|
+
rootDesignToken = _React$useContext.token,
|
|
76
|
+
hashed = _React$useContext.hashed,
|
|
77
|
+
_React$useContext$the = _React$useContext.theme,
|
|
78
|
+
theme = _React$useContext$the === void 0 ? defaultTheme : _React$useContext$the,
|
|
79
|
+
override = _React$useContext.override,
|
|
80
|
+
cssVar = _React$useContext.cssVar;
|
|
81
|
+
var _useCacheToken = useCacheToken(theme, [antdTheme.defaultSeed, rootDesignToken], {
|
|
82
|
+
salt: "".concat(version, "-").concat(hashed || ''),
|
|
83
|
+
override: override,
|
|
84
|
+
getComputedToken: getComputedToken,
|
|
85
|
+
cssVar: cssVar && {
|
|
86
|
+
prefix: cssVar.prefix,
|
|
87
|
+
key: cssVar.key,
|
|
88
|
+
unitless: unitless,
|
|
89
|
+
ignore: ignore,
|
|
90
|
+
preserve: preserve
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
_useCacheToken2 = _slicedToArray(_useCacheToken, 3),
|
|
94
|
+
token = _useCacheToken2[0],
|
|
95
|
+
hashId = _useCacheToken2[1],
|
|
96
|
+
realToken = _useCacheToken2[2];
|
|
97
|
+
return [theme, realToken, hashed ? hashId : '', token, cssVar];
|
|
98
|
+
}
|
|
99
|
+
export default function useToken() {
|
|
100
|
+
var _useInternalToken = useInternalToken(),
|
|
101
|
+
_useInternalToken2 = _slicedToArray(_useInternalToken, 3),
|
|
102
|
+
theme = _useInternalToken2[0],
|
|
103
|
+
token = _useInternalToken2[1],
|
|
104
|
+
hashId = _useInternalToken2[2];
|
|
105
|
+
return {
|
|
106
|
+
theme: theme,
|
|
107
|
+
token: token,
|
|
108
|
+
hashId: hashId
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import 'recorder-core/src/extensions/waveview';
|
|
2
|
+
import { IVoiceChatContext } from '../VoiceChatProvider/context';
|
|
3
|
+
import { IVoiceChatService } from '../VoiceChatService';
|
|
4
|
+
export interface IRecorder extends IVoiceChatService {
|
|
5
|
+
onStart?: () => void;
|
|
6
|
+
onStop?: () => void;
|
|
7
|
+
chatState: IVoiceChatContext;
|
|
8
|
+
}
|
|
9
|
+
declare class Recorder {
|
|
10
|
+
private _recorderInstance;
|
|
11
|
+
private _voiceChatService;
|
|
12
|
+
private _recorderWave;
|
|
13
|
+
private _sendPcmBufferRef;
|
|
14
|
+
private _sendChunkRef;
|
|
15
|
+
private _sendLastFrameRef;
|
|
16
|
+
onStart: () => void;
|
|
17
|
+
onStop: () => void;
|
|
18
|
+
chatState: IVoiceChatContext;
|
|
19
|
+
constructor(props: IRecorder);
|
|
20
|
+
start(): Promise<void>;
|
|
21
|
+
stop(): void;
|
|
22
|
+
reset(): void;
|
|
23
|
+
send(pcmFrame: Int16Array, isClose: boolean): void;
|
|
24
|
+
process(buffers: (Int16Array | null)[], bufferSampleRate: number, isClose: boolean): void;
|
|
25
|
+
}
|
|
26
|
+
export default Recorder;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
6
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
7
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
11
|
+
import RecorderCore from 'recorder-core';
|
|
12
|
+
import 'recorder-core/src/extensions/waveview';
|
|
13
|
+
import { BIT_RATE, FRAME_SIZE, SAMPLE_RATE } from "../types";
|
|
14
|
+
import VoiceChatService from "../VoiceChatService";
|
|
15
|
+
var noop = function noop() {};
|
|
16
|
+
var Recorder = /*#__PURE__*/function () {
|
|
17
|
+
function Recorder(props) {
|
|
18
|
+
_classCallCheck(this, Recorder);
|
|
19
|
+
_defineProperty(this, "_recorderInstance", void 0);
|
|
20
|
+
_defineProperty(this, "_voiceChatService", void 0);
|
|
21
|
+
_defineProperty(this, "_recorderWave", void 0);
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
_defineProperty(this, "_sendPcmBufferRef", void 0);
|
|
24
|
+
_defineProperty(this, "_sendChunkRef", void 0);
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
_defineProperty(this, "_sendLastFrameRef", void 0);
|
|
27
|
+
_defineProperty(this, "onStart", void 0);
|
|
28
|
+
_defineProperty(this, "onStop", void 0);
|
|
29
|
+
_defineProperty(this, "chatState", void 0);
|
|
30
|
+
var wsURL = props.wsURL,
|
|
31
|
+
onProcessResponseText = props.onProcessResponseText,
|
|
32
|
+
onProcessASR = props.onProcessASR,
|
|
33
|
+
onProcessTTS = props.onProcessTTS;
|
|
34
|
+
var _props$onStart = props.onStart,
|
|
35
|
+
onStart = _props$onStart === void 0 ? noop : _props$onStart,
|
|
36
|
+
_props$onStop = props.onStop,
|
|
37
|
+
onStop = _props$onStop === void 0 ? noop : _props$onStop;
|
|
38
|
+
var chatState = props.chatState;
|
|
39
|
+
this.onStart = onStart;
|
|
40
|
+
this.onStop = onStop;
|
|
41
|
+
this.chatState = chatState;
|
|
42
|
+
this._voiceChatService = new VoiceChatService({
|
|
43
|
+
chatState: chatState,
|
|
44
|
+
wsURL: wsURL,
|
|
45
|
+
onProcessResponseText: onProcessResponseText,
|
|
46
|
+
onProcessASR: onProcessASR,
|
|
47
|
+
onProcessTTS: onProcessTTS
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
_createClass(Recorder, [{
|
|
51
|
+
key: "start",
|
|
52
|
+
value: function () {
|
|
53
|
+
var _start = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
54
|
+
var _this = this;
|
|
55
|
+
var clearBufferIdx, recorder;
|
|
56
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
+
while (1) switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
this.reset();
|
|
60
|
+
_context.next = 3;
|
|
61
|
+
return this._voiceChatService.connect();
|
|
62
|
+
case 3:
|
|
63
|
+
clearBufferIdx = 0;
|
|
64
|
+
recorder = RecorderCore({
|
|
65
|
+
type: 'unknown',
|
|
66
|
+
onProcess: function onProcess(buffers, powerLevel, bufferDuration, bufferSampleRate, newBufferIdx) {
|
|
67
|
+
var buffer = buffers[buffers.length - 1];
|
|
68
|
+
_this._recorderWave && _this._recorderWave.input(buffer, powerLevel, bufferSampleRate);
|
|
69
|
+
for (var i = clearBufferIdx; i < newBufferIdx; i++) {
|
|
70
|
+
buffers[i] = null;
|
|
71
|
+
}
|
|
72
|
+
clearBufferIdx = newBufferIdx;
|
|
73
|
+
_this.process(buffers, bufferSampleRate, false);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
this._recorderInstance = recorder;
|
|
77
|
+
this._recorderInstance.open(function () {
|
|
78
|
+
// this._recorderWave = RecorderCore.WaveView({
|
|
79
|
+
// elem: '.asr',
|
|
80
|
+
// width: 165,
|
|
81
|
+
// height: 45,
|
|
82
|
+
// });
|
|
83
|
+
_this._recorderInstance.start();
|
|
84
|
+
_this.onStart();
|
|
85
|
+
}, function () {
|
|
86
|
+
return console.log('error');
|
|
87
|
+
});
|
|
88
|
+
case 7:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee, this);
|
|
93
|
+
}));
|
|
94
|
+
function start() {
|
|
95
|
+
return _start.apply(this, arguments);
|
|
96
|
+
}
|
|
97
|
+
return start;
|
|
98
|
+
}()
|
|
99
|
+
}, {
|
|
100
|
+
key: "stop",
|
|
101
|
+
value: function stop() {
|
|
102
|
+
try {
|
|
103
|
+
var _this$_recorderInstan, _this$_voiceChatServi;
|
|
104
|
+
(_this$_recorderInstan = this._recorderInstance) === null || _this$_recorderInstan === void 0 || _this$_recorderInstan.stop(undefined, undefined, true);
|
|
105
|
+
(_this$_voiceChatServi = this._voiceChatService) === null || _this$_voiceChatServi === void 0 || _this$_voiceChatServi.close();
|
|
106
|
+
this.onStop();
|
|
107
|
+
this.process([], 0, true);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error(error);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}, {
|
|
113
|
+
key: "reset",
|
|
114
|
+
value: function reset() {
|
|
115
|
+
this._sendPcmBufferRef = new Int16Array(0);
|
|
116
|
+
this._sendChunkRef = null;
|
|
117
|
+
this._sendLastFrameRef = null;
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "send",
|
|
121
|
+
value: function send(pcmFrame, isClose) {
|
|
122
|
+
if (isClose && pcmFrame.length === 0) {
|
|
123
|
+
var _this$_sendLastFrameR;
|
|
124
|
+
var len = this._sendLastFrameRef ? (_this$_sendLastFrameR = this._sendLastFrameRef) === null || _this$_sendLastFrameR === void 0 ? void 0 : _this$_sendLastFrameR.length : Math.round(SAMPLE_RATE / 1000 * 50);
|
|
125
|
+
pcmFrame = new Int16Array(len);
|
|
126
|
+
}
|
|
127
|
+
this._sendLastFrameRef = pcmFrame;
|
|
128
|
+
this._voiceChatService.send(pcmFrame.buffer);
|
|
129
|
+
}
|
|
130
|
+
}, {
|
|
131
|
+
key: "process",
|
|
132
|
+
value: function process(buffers, bufferSampleRate, isClose) {
|
|
133
|
+
var pcm = new Int16Array(0);
|
|
134
|
+
if (buffers.length > 0) {
|
|
135
|
+
var chunk = RecorderCore.SampleData(buffers, bufferSampleRate, SAMPLE_RATE, this._sendChunkRef);
|
|
136
|
+
this._sendChunkRef = chunk;
|
|
137
|
+
pcm = chunk.data;
|
|
138
|
+
}
|
|
139
|
+
var pcmBuffer = this._sendPcmBufferRef;
|
|
140
|
+
var tmp = new Int16Array(pcmBuffer.length + pcm.length);
|
|
141
|
+
tmp.set(pcmBuffer, 0);
|
|
142
|
+
tmp.set(pcm, pcmBuffer.length);
|
|
143
|
+
pcmBuffer = tmp;
|
|
144
|
+
var chunkSize = FRAME_SIZE / (BIT_RATE / 8);
|
|
145
|
+
while (true) {
|
|
146
|
+
if (pcmBuffer.length >= chunkSize) {
|
|
147
|
+
var frame = new Int16Array(pcmBuffer.subarray(0, chunkSize));
|
|
148
|
+
pcmBuffer = new Int16Array(pcmBuffer.subarray(chunkSize));
|
|
149
|
+
var closeVal = false;
|
|
150
|
+
if (isClose && pcmBuffer.length === 0) {
|
|
151
|
+
closeVal = true;
|
|
152
|
+
}
|
|
153
|
+
this.send(frame, closeVal);
|
|
154
|
+
if (!closeVal) continue;
|
|
155
|
+
} else if (isClose) {
|
|
156
|
+
var _frame = new Int16Array(chunkSize);
|
|
157
|
+
_frame.set(pcmBuffer);
|
|
158
|
+
pcmBuffer = new Int16Array(0);
|
|
159
|
+
this.send(_frame, true);
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
this._sendPcmBufferRef = pcmBuffer;
|
|
164
|
+
}
|
|
165
|
+
}]);
|
|
166
|
+
return Recorder;
|
|
167
|
+
}();
|
|
168
|
+
export default Recorder;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { TMessage } from "../..";
|
|
2
|
+
import { Dispatch, SetStateAction } from 'react';
|
|
3
|
+
import Recorder from '../Recorder';
|
|
4
|
+
export interface IVoiceChatContext {
|
|
5
|
+
botSpeaking: boolean;
|
|
6
|
+
setBotSpeaking: Dispatch<SetStateAction<boolean>>;
|
|
7
|
+
getBotSpeaking: () => boolean;
|
|
8
|
+
userSpeaking: boolean;
|
|
9
|
+
setUserSpeaking: Dispatch<SetStateAction<boolean>>;
|
|
10
|
+
getUserSpeaking: () => boolean;
|
|
11
|
+
wsConnected: boolean;
|
|
12
|
+
setWsConnected: Dispatch<SetStateAction<boolean>>;
|
|
13
|
+
getWsConnected: () => boolean;
|
|
14
|
+
messages: TMessage[];
|
|
15
|
+
setMessages: Dispatch<SetStateAction<TMessage[]>>;
|
|
16
|
+
getMessages: () => TMessage[];
|
|
17
|
+
}
|
|
18
|
+
export declare const VoiceChatContext: import("react").Context<IVoiceChatContext>;
|
|
19
|
+
export interface IRecorderContext {
|
|
20
|
+
recorderRef: React.MutableRefObject<Recorder>;
|
|
21
|
+
}
|
|
22
|
+
export declare const RecorderContext: import("react").Context<IRecorderContext>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function (): import("../context").IVoiceChatContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { TMessage } from "../../..";
|
|
3
|
+
export default function (): {
|
|
4
|
+
messages: TMessage[];
|
|
5
|
+
setMessages: import("react").Dispatch<import("react").SetStateAction<TMessage[]>>;
|
|
6
|
+
getMessages: () => TMessage[];
|
|
7
|
+
updateMessage: (message: TMessage) => void;
|
|
8
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
import { useContext } from 'react';
|
|
8
|
+
import { VoiceChatContext } from "../context";
|
|
9
|
+
export default function () {
|
|
10
|
+
var _useContext = useContext(VoiceChatContext),
|
|
11
|
+
messages = _useContext.messages,
|
|
12
|
+
setMessages = _useContext.setMessages,
|
|
13
|
+
getMessages = _useContext.getMessages;
|
|
14
|
+
return {
|
|
15
|
+
messages: messages,
|
|
16
|
+
setMessages: setMessages,
|
|
17
|
+
getMessages: getMessages,
|
|
18
|
+
updateMessage: function updateMessage(message) {
|
|
19
|
+
setMessages(function (prev) {
|
|
20
|
+
var index = prev.findIndex(function (item) {
|
|
21
|
+
return item.id === message.id;
|
|
22
|
+
});
|
|
23
|
+
if (index > -1) {
|
|
24
|
+
return [].concat(_toConsumableArray(prev.slice(0, index)), [message], _toConsumableArray(prev.slice(index + 1)));
|
|
25
|
+
} else {
|
|
26
|
+
return [].concat(_toConsumableArray(prev), [message]);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import Recorder from "../../Recorder";
|
|
3
|
+
import useChatState from "./useChatState";
|
|
4
|
+
import useMessages from "./useMessages";
|
|
5
|
+
export default function () {
|
|
6
|
+
var chatState = useChatState();
|
|
7
|
+
var messageContext = useMessages();
|
|
8
|
+
var recorderRef = useRef(new Recorder({
|
|
9
|
+
chatState: chatState,
|
|
10
|
+
wsURL: 'ws://localhost:8000/api',
|
|
11
|
+
onProcessASR: function onProcessASR(data) {
|
|
12
|
+
messageContext.updateMessage({
|
|
13
|
+
id: data.payload._id,
|
|
14
|
+
content: data.payload.text,
|
|
15
|
+
role: 'user'
|
|
16
|
+
});
|
|
17
|
+
chatState.setBotSpeaking(false);
|
|
18
|
+
chatState.setUserSpeaking(true);
|
|
19
|
+
},
|
|
20
|
+
onProcessResponseText: function onProcessResponseText(data) {
|
|
21
|
+
messageContext.updateMessage({
|
|
22
|
+
id: data.payload._id,
|
|
23
|
+
content: data.payload.text,
|
|
24
|
+
role: 'assistant'
|
|
25
|
+
});
|
|
26
|
+
chatState.setBotSpeaking(true);
|
|
27
|
+
chatState.setUserSpeaking(false);
|
|
28
|
+
},
|
|
29
|
+
onStart: function onStart() {
|
|
30
|
+
chatState.setUserSpeaking(true);
|
|
31
|
+
chatState.setWsConnected(true);
|
|
32
|
+
},
|
|
33
|
+
onStop: function onStop() {
|
|
34
|
+
messageContext.setMessages([]);
|
|
35
|
+
chatState.setBotSpeaking(false);
|
|
36
|
+
chatState.setUserSpeaking(false);
|
|
37
|
+
chatState.setWsConnected(false);
|
|
38
|
+
}
|
|
39
|
+
}));
|
|
40
|
+
useEffect(function () {
|
|
41
|
+
return function () {
|
|
42
|
+
recorderRef.current.stop();
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
return {
|
|
46
|
+
recorderRef: recorderRef
|
|
47
|
+
};
|
|
48
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContext } from 'react';
|
|
2
|
+
import { RecorderContext, VoiceChatContext } from "../context";
|
|
3
|
+
export default function useVoiceChat() {
|
|
4
|
+
var voiceChatContext = useContext(VoiceChatContext);
|
|
5
|
+
var recorderContext = useContext(RecorderContext);
|
|
6
|
+
return {
|
|
7
|
+
voiceChatContext: voiceChatContext,
|
|
8
|
+
recorderContext: recorderContext
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
declare function VoiceChatProvider(props: {
|
|
4
|
+
children: ReactElement;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
|
+
declare function RecorderProvider(props: {
|
|
7
|
+
children: ReactElement | ReactElement[];
|
|
8
|
+
}): React.JSX.Element;
|
|
9
|
+
export { VoiceChatProvider, RecorderProvider, };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React from "react";
|
|
8
|
+
import { VoiceChatContext, RecorderContext } from "./context";
|
|
9
|
+
import useRecorder from "./hooks/useRecorder";
|
|
10
|
+
import { useGetState } from "ahooks";
|
|
11
|
+
function VoiceChatProvider(props) {
|
|
12
|
+
var _useGetState = useGetState(false),
|
|
13
|
+
_useGetState2 = _slicedToArray(_useGetState, 3),
|
|
14
|
+
botSpeaking = _useGetState2[0],
|
|
15
|
+
setBotSpeaking = _useGetState2[1],
|
|
16
|
+
getBotSpeaking = _useGetState2[2];
|
|
17
|
+
var _useGetState3 = useGetState(false),
|
|
18
|
+
_useGetState4 = _slicedToArray(_useGetState3, 3),
|
|
19
|
+
userSpeaking = _useGetState4[0],
|
|
20
|
+
setUserSpeaking = _useGetState4[1],
|
|
21
|
+
getUserSpeaking = _useGetState4[2];
|
|
22
|
+
var _useGetState5 = useGetState(false),
|
|
23
|
+
_useGetState6 = _slicedToArray(_useGetState5, 3),
|
|
24
|
+
wsConnected = _useGetState6[0],
|
|
25
|
+
setWsConnected = _useGetState6[1],
|
|
26
|
+
getWsConnected = _useGetState6[2];
|
|
27
|
+
var _useGetState7 = useGetState([]),
|
|
28
|
+
_useGetState8 = _slicedToArray(_useGetState7, 3),
|
|
29
|
+
messages = _useGetState8[0],
|
|
30
|
+
setMessages = _useGetState8[1],
|
|
31
|
+
getMessages = _useGetState8[2];
|
|
32
|
+
return /*#__PURE__*/React.createElement(VoiceChatContext.Provider, {
|
|
33
|
+
value: {
|
|
34
|
+
botSpeaking: botSpeaking,
|
|
35
|
+
setBotSpeaking: setBotSpeaking,
|
|
36
|
+
getBotSpeaking: getBotSpeaking,
|
|
37
|
+
userSpeaking: userSpeaking,
|
|
38
|
+
setUserSpeaking: setUserSpeaking,
|
|
39
|
+
getUserSpeaking: getUserSpeaking,
|
|
40
|
+
wsConnected: wsConnected,
|
|
41
|
+
setWsConnected: setWsConnected,
|
|
42
|
+
getWsConnected: getWsConnected,
|
|
43
|
+
messages: messages,
|
|
44
|
+
setMessages: setMessages,
|
|
45
|
+
getMessages: getMessages
|
|
46
|
+
}
|
|
47
|
+
}, /*#__PURE__*/React.createElement(RecorderProvider, null, props.children));
|
|
48
|
+
}
|
|
49
|
+
function RecorderProvider(props) {
|
|
50
|
+
var recorder = useRecorder();
|
|
51
|
+
return /*#__PURE__*/React.createElement(RecorderContext.Provider, {
|
|
52
|
+
value: recorder
|
|
53
|
+
}, props.children);
|
|
54
|
+
}
|
|
55
|
+
export { VoiceChatProvider, RecorderProvider };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import 'recorder-core/src/extensions/buffer_stream.player.js';
|
|
2
|
+
import { WebRequest, WebResponse } from '../types';
|
|
3
|
+
import { IVoiceChatContext } from '../VoiceChatProvider/context';
|
|
4
|
+
export interface IVoiceChatService {
|
|
5
|
+
wsURL: string;
|
|
6
|
+
onProcessTTS?: () => void;
|
|
7
|
+
onProcessResponseText?: (data: WebResponse) => void;
|
|
8
|
+
onProcessASR?: (data: WebResponse) => void;
|
|
9
|
+
chatState: IVoiceChatContext;
|
|
10
|
+
}
|
|
11
|
+
export default class VoiceChatService {
|
|
12
|
+
private _wsURL;
|
|
13
|
+
private _ws?;
|
|
14
|
+
private _stream?;
|
|
15
|
+
private _rec?;
|
|
16
|
+
onProcessResponseText: (data: WebResponse) => void;
|
|
17
|
+
onProcessASR: (data: WebResponse) => void;
|
|
18
|
+
onProcessTTS: (data: WebResponse) => void;
|
|
19
|
+
chatState: IVoiceChatContext;
|
|
20
|
+
constructor(props: IVoiceChatService);
|
|
21
|
+
initPlayer: () => void;
|
|
22
|
+
closePlayer(): void;
|
|
23
|
+
connect(): Promise<WebSocket>;
|
|
24
|
+
close(): void;
|
|
25
|
+
start(): void;
|
|
26
|
+
send(data: WebRequest | ArrayBuffer): void;
|
|
27
|
+
_asrCache: WebResponse;
|
|
28
|
+
processASR(jsonData: WebResponse): void;
|
|
29
|
+
_responseTextCache: WebResponse;
|
|
30
|
+
processResponseText(jsonData: WebResponse): void;
|
|
31
|
+
processByCache: (key: any) => (jsonData: WebResponse) => any;
|
|
32
|
+
processTTS(event: any): void;
|
|
33
|
+
onMessage(event: any): void;
|
|
34
|
+
}
|