@docyrus/rn-assistant 0.0.1
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 +477 -0
- package/dist/commonjs/components/agent-selector/agent-selector.js +300 -0
- package/dist/commonjs/components/agent-selector/agent-selector.js.map +1 -0
- package/dist/commonjs/components/agent-selector/index.js +17 -0
- package/dist/commonjs/components/agent-selector/index.js.map +1 -0
- package/dist/commonjs/components/assistant-animations/assistant-animations.js +169 -0
- package/dist/commonjs/components/assistant-animations/assistant-animations.js.map +1 -0
- package/dist/commonjs/components/assistant-animations/index.js +17 -0
- package/dist/commonjs/components/assistant-animations/index.js.map +1 -0
- package/dist/commonjs/components/assistant-screen/assistant-screen.js +809 -0
- package/dist/commonjs/components/assistant-screen/assistant-screen.js.map +1 -0
- package/dist/commonjs/components/assistant-screen/index.js +17 -0
- package/dist/commonjs/components/assistant-screen/index.js.map +1 -0
- package/dist/commonjs/components/index.js +116 -0
- package/dist/commonjs/components/index.js.map +1 -0
- package/dist/commonjs/components/message-parts/index.js +13 -0
- package/dist/commonjs/components/message-parts/index.js.map +1 -0
- package/dist/commonjs/components/message-parts/message-parts.js +209 -0
- package/dist/commonjs/components/message-parts/message-parts.js.map +1 -0
- package/dist/commonjs/components/new-chat/index.js +17 -0
- package/dist/commonjs/components/new-chat/index.js.map +1 -0
- package/dist/commonjs/components/new-chat/new-chat.js +100 -0
- package/dist/commonjs/components/new-chat/new-chat.js.map +1 -0
- package/dist/commonjs/components/prompt-input/attachment-picker.js +341 -0
- package/dist/commonjs/components/prompt-input/attachment-picker.js.map +1 -0
- package/dist/commonjs/components/prompt-input/attachment-preview.js +229 -0
- package/dist/commonjs/components/prompt-input/attachment-preview.js.map +1 -0
- package/dist/commonjs/components/prompt-input/index.js +41 -0
- package/dist/commonjs/components/prompt-input/index.js.map +1 -0
- package/dist/commonjs/components/prompt-input/prompt-input.js +288 -0
- package/dist/commonjs/components/prompt-input/prompt-input.js.map +1 -0
- package/dist/commonjs/components/prompt-input/provider-selector.js +542 -0
- package/dist/commonjs/components/prompt-input/provider-selector.js.map +1 -0
- package/dist/commonjs/components/prompt-input/reasoning-level-selector.js +350 -0
- package/dist/commonjs/components/prompt-input/reasoning-level-selector.js.map +1 -0
- package/dist/commonjs/components/prompt-input/voice-recorder.js +260 -0
- package/dist/commonjs/components/prompt-input/voice-recorder.js.map +1 -0
- package/dist/commonjs/components/sessions-list/index.js +17 -0
- package/dist/commonjs/components/sessions-list/index.js.map +1 -0
- package/dist/commonjs/components/sessions-list/sessions-list.js +820 -0
- package/dist/commonjs/components/sessions-list/sessions-list.js.map +1 -0
- package/dist/commonjs/hooks/index.js +34 -0
- package/dist/commonjs/hooks/index.js.map +1 -0
- package/dist/commonjs/hooks/use-agent-models.js +104 -0
- package/dist/commonjs/hooks/use-agent-models.js.map +1 -0
- package/dist/commonjs/hooks/use-assistant.js +402 -0
- package/dist/commonjs/hooks/use-assistant.js.map +1 -0
- package/dist/commonjs/hooks/use-attachment-picker.js +308 -0
- package/dist/commonjs/hooks/use-attachment-picker.js.map +1 -0
- package/dist/commonjs/hooks/use-voice-recorder.js +217 -0
- package/dist/commonjs/hooks/use-voice-recorder.js.map +1 -0
- package/dist/commonjs/index.js +112 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/package.json +1 -0
- package/dist/commonjs/theme/assistant-theme.js +105 -0
- package/dist/commonjs/theme/assistant-theme.js.map +1 -0
- package/dist/commonjs/theme/index.js +19 -0
- package/dist/commonjs/theme/index.js.map +1 -0
- package/dist/commonjs/types/index.js +2 -0
- package/dist/commonjs/types/index.js.map +1 -0
- package/dist/commonjs/ui/action-sheet.js +348 -0
- package/dist/commonjs/ui/action-sheet.js.map +1 -0
- package/dist/commonjs/ui/alert-dialog.js +134 -0
- package/dist/commonjs/ui/alert-dialog.js.map +1 -0
- package/dist/commonjs/ui/docyrus-brand-mark.js +52 -0
- package/dist/commonjs/ui/docyrus-brand-mark.js.map +1 -0
- package/dist/commonjs/ui/docyrus-icon.js +298 -0
- package/dist/commonjs/ui/docyrus-icon.js.map +1 -0
- package/dist/commonjs/ui/index.js +34 -0
- package/dist/commonjs/ui/index.js.map +1 -0
- package/dist/commonjs/utils/api-client.js +99 -0
- package/dist/commonjs/utils/api-client.js.map +1 -0
- package/dist/commonjs/utils/default-api-config.js +195 -0
- package/dist/commonjs/utils/default-api-config.js.map +1 -0
- package/dist/commonjs/utils/index.js +39 -0
- package/dist/commonjs/utils/index.js.map +1 -0
- package/dist/commonjs/utils/resolve-api-headers.js +16 -0
- package/dist/commonjs/utils/resolve-api-headers.js.map +1 -0
- package/dist/module/components/agent-selector/agent-selector.js +296 -0
- package/dist/module/components/agent-selector/agent-selector.js.map +1 -0
- package/dist/module/components/agent-selector/index.js +4 -0
- package/dist/module/components/agent-selector/index.js.map +1 -0
- package/dist/module/components/assistant-animations/assistant-animations.js +164 -0
- package/dist/module/components/assistant-animations/assistant-animations.js.map +1 -0
- package/dist/module/components/assistant-animations/index.js +4 -0
- package/dist/module/components/assistant-animations/index.js.map +1 -0
- package/dist/module/components/assistant-screen/assistant-screen.js +801 -0
- package/dist/module/components/assistant-screen/assistant-screen.js.map +1 -0
- package/dist/module/components/assistant-screen/index.js +4 -0
- package/dist/module/components/assistant-screen/index.js.map +1 -0
- package/dist/module/components/index.js +23 -0
- package/dist/module/components/index.js.map +1 -0
- package/dist/module/components/message-parts/index.js +4 -0
- package/dist/module/components/message-parts/index.js.map +1 -0
- package/dist/module/components/message-parts/message-parts.js +205 -0
- package/dist/module/components/message-parts/message-parts.js.map +1 -0
- package/dist/module/components/new-chat/index.js +4 -0
- package/dist/module/components/new-chat/index.js.map +1 -0
- package/dist/module/components/new-chat/new-chat.js +96 -0
- package/dist/module/components/new-chat/new-chat.js.map +1 -0
- package/dist/module/components/prompt-input/attachment-picker.js +337 -0
- package/dist/module/components/prompt-input/attachment-picker.js.map +1 -0
- package/dist/module/components/prompt-input/attachment-preview.js +225 -0
- package/dist/module/components/prompt-input/attachment-preview.js.map +1 -0
- package/dist/module/components/prompt-input/index.js +15 -0
- package/dist/module/components/prompt-input/index.js.map +1 -0
- package/dist/module/components/prompt-input/prompt-input.js +284 -0
- package/dist/module/components/prompt-input/prompt-input.js.map +1 -0
- package/dist/module/components/prompt-input/provider-selector.js +538 -0
- package/dist/module/components/prompt-input/provider-selector.js.map +1 -0
- package/dist/module/components/prompt-input/reasoning-level-selector.js +346 -0
- package/dist/module/components/prompt-input/reasoning-level-selector.js.map +1 -0
- package/dist/module/components/prompt-input/voice-recorder.js +256 -0
- package/dist/module/components/prompt-input/voice-recorder.js.map +1 -0
- package/dist/module/components/sessions-list/index.js +4 -0
- package/dist/module/components/sessions-list/index.js.map +1 -0
- package/dist/module/components/sessions-list/sessions-list.js +816 -0
- package/dist/module/components/sessions-list/sessions-list.js.map +1 -0
- package/dist/module/hooks/index.js +18 -0
- package/dist/module/hooks/index.js.map +1 -0
- package/dist/module/hooks/use-agent-models.js +100 -0
- package/dist/module/hooks/use-agent-models.js.map +1 -0
- package/dist/module/hooks/use-assistant.js +398 -0
- package/dist/module/hooks/use-assistant.js.map +1 -0
- package/dist/module/hooks/use-attachment-picker.js +303 -0
- package/dist/module/hooks/use-attachment-picker.js.map +1 -0
- package/dist/module/hooks/use-voice-recorder.js +214 -0
- package/dist/module/hooks/use-voice-recorder.js.map +1 -0
- package/dist/module/index.js +59 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/package.json +1 -0
- package/dist/module/theme/assistant-theme.js +100 -0
- package/dist/module/theme/assistant-theme.js.map +1 -0
- package/dist/module/theme/index.js +4 -0
- package/dist/module/theme/index.js.map +1 -0
- package/dist/module/types/index.js +2 -0
- package/dist/module/types/index.js.map +1 -0
- package/dist/module/ui/action-sheet.js +344 -0
- package/dist/module/ui/action-sheet.js.map +1 -0
- package/dist/module/ui/alert-dialog.js +130 -0
- package/dist/module/ui/alert-dialog.js.map +1 -0
- package/dist/module/ui/docyrus-brand-mark.js +48 -0
- package/dist/module/ui/docyrus-brand-mark.js.map +1 -0
- package/dist/module/ui/docyrus-icon.js +294 -0
- package/dist/module/ui/docyrus-icon.js.map +1 -0
- package/dist/module/ui/index.js +7 -0
- package/dist/module/ui/index.js.map +1 -0
- package/dist/module/utils/api-client.js +95 -0
- package/dist/module/utils/api-client.js.map +1 -0
- package/dist/module/utils/default-api-config.js +190 -0
- package/dist/module/utils/default-api-config.js.map +1 -0
- package/dist/module/utils/index.js +12 -0
- package/dist/module/utils/index.js.map +1 -0
- package/dist/module/utils/resolve-api-headers.js +12 -0
- package/dist/module/utils/resolve-api-headers.js.map +1 -0
- package/dist/typescript/commonjs/eslint.config.d.mts +4 -0
- package/dist/typescript/commonjs/eslint.config.d.mts.map +1 -0
- package/dist/typescript/commonjs/package.json +1 -0
- package/dist/typescript/commonjs/src/components/agent-selector/agent-selector.d.ts +49 -0
- package/dist/typescript/commonjs/src/components/agent-selector/agent-selector.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/agent-selector/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/agent-selector/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/assistant-animations/assistant-animations.d.ts +8 -0
- package/dist/typescript/commonjs/src/components/assistant-animations/assistant-animations.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/assistant-animations/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/assistant-animations/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/assistant-screen/assistant-screen.d.ts +122 -0
- package/dist/typescript/commonjs/src/components/assistant-screen/assistant-screen.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/assistant-screen/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/assistant-screen/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/index.d.ts +11 -0
- package/dist/typescript/commonjs/src/components/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/message-parts/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/message-parts/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/message-parts/message-parts.d.ts +22 -0
- package/dist/typescript/commonjs/src/components/message-parts/message-parts.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/new-chat/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/new-chat/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/new-chat/new-chat.d.ts +34 -0
- package/dist/typescript/commonjs/src/components/new-chat/new-chat.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/attachment-picker.d.ts +53 -0
- package/dist/typescript/commonjs/src/components/prompt-input/attachment-picker.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/attachment-preview.d.ts +42 -0
- package/dist/typescript/commonjs/src/components/prompt-input/attachment-preview.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/index.d.ts +9 -0
- package/dist/typescript/commonjs/src/components/prompt-input/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/prompt-input.d.ts +139 -0
- package/dist/typescript/commonjs/src/components/prompt-input/prompt-input.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/provider-selector.d.ts +11 -0
- package/dist/typescript/commonjs/src/components/prompt-input/provider-selector.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/reasoning-level-selector.d.ts +35 -0
- package/dist/typescript/commonjs/src/components/prompt-input/reasoning-level-selector.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/prompt-input/voice-recorder.d.ts +48 -0
- package/dist/typescript/commonjs/src/components/prompt-input/voice-recorder.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/sessions-list/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/components/sessions-list/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/components/sessions-list/sessions-list.d.ts +59 -0
- package/dist/typescript/commonjs/src/components/sessions-list/sessions-list.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/hooks/index.d.ts +8 -0
- package/dist/typescript/commonjs/src/hooks/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/hooks/use-agent-models.d.ts +68 -0
- package/dist/typescript/commonjs/src/hooks/use-agent-models.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/hooks/use-assistant.d.ts +55 -0
- package/dist/typescript/commonjs/src/hooks/use-assistant.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/hooks/use-attachment-picker.d.ts +99 -0
- package/dist/typescript/commonjs/src/hooks/use-attachment-picker.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/hooks/use-voice-recorder.d.ts +101 -0
- package/dist/typescript/commonjs/src/hooks/use-voice-recorder.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/index.d.ts +47 -0
- package/dist/typescript/commonjs/src/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/theme/assistant-theme.d.ts +51 -0
- package/dist/typescript/commonjs/src/theme/assistant-theme.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/theme/index.d.ts +2 -0
- package/dist/typescript/commonjs/src/theme/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/types/index.d.ts +167 -0
- package/dist/typescript/commonjs/src/types/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/ui/action-sheet.d.ts +29 -0
- package/dist/typescript/commonjs/src/ui/action-sheet.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/ui/alert-dialog.d.ts +12 -0
- package/dist/typescript/commonjs/src/ui/alert-dialog.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/ui/docyrus-brand-mark.d.ts +5 -0
- package/dist/typescript/commonjs/src/ui/docyrus-brand-mark.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/ui/docyrus-icon.d.ts +11 -0
- package/dist/typescript/commonjs/src/ui/docyrus-icon.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/ui/index.d.ts +5 -0
- package/dist/typescript/commonjs/src/ui/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/utils/api-client.d.ts +35 -0
- package/dist/typescript/commonjs/src/utils/api-client.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/utils/default-api-config.d.ts +38 -0
- package/dist/typescript/commonjs/src/utils/default-api-config.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/utils/index.d.ts +9 -0
- package/dist/typescript/commonjs/src/utils/index.d.ts.map +1 -0
- package/dist/typescript/commonjs/src/utils/resolve-api-headers.d.ts +3 -0
- package/dist/typescript/commonjs/src/utils/resolve-api-headers.d.ts.map +1 -0
- package/dist/typescript/module/eslint.config.d.mts +4 -0
- package/dist/typescript/module/eslint.config.d.mts.map +1 -0
- package/dist/typescript/module/package.json +1 -0
- package/dist/typescript/module/src/components/agent-selector/agent-selector.d.ts +49 -0
- package/dist/typescript/module/src/components/agent-selector/agent-selector.d.ts.map +1 -0
- package/dist/typescript/module/src/components/agent-selector/index.d.ts +2 -0
- package/dist/typescript/module/src/components/agent-selector/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/assistant-animations/assistant-animations.d.ts +8 -0
- package/dist/typescript/module/src/components/assistant-animations/assistant-animations.d.ts.map +1 -0
- package/dist/typescript/module/src/components/assistant-animations/index.d.ts +2 -0
- package/dist/typescript/module/src/components/assistant-animations/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/assistant-screen/assistant-screen.d.ts +122 -0
- package/dist/typescript/module/src/components/assistant-screen/assistant-screen.d.ts.map +1 -0
- package/dist/typescript/module/src/components/assistant-screen/index.d.ts +2 -0
- package/dist/typescript/module/src/components/assistant-screen/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/index.d.ts +11 -0
- package/dist/typescript/module/src/components/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/message-parts/index.d.ts +2 -0
- package/dist/typescript/module/src/components/message-parts/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/message-parts/message-parts.d.ts +22 -0
- package/dist/typescript/module/src/components/message-parts/message-parts.d.ts.map +1 -0
- package/dist/typescript/module/src/components/new-chat/index.d.ts +2 -0
- package/dist/typescript/module/src/components/new-chat/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/new-chat/new-chat.d.ts +34 -0
- package/dist/typescript/module/src/components/new-chat/new-chat.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/attachment-picker.d.ts +53 -0
- package/dist/typescript/module/src/components/prompt-input/attachment-picker.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/attachment-preview.d.ts +42 -0
- package/dist/typescript/module/src/components/prompt-input/attachment-preview.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/index.d.ts +9 -0
- package/dist/typescript/module/src/components/prompt-input/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/prompt-input.d.ts +139 -0
- package/dist/typescript/module/src/components/prompt-input/prompt-input.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/provider-selector.d.ts +11 -0
- package/dist/typescript/module/src/components/prompt-input/provider-selector.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/reasoning-level-selector.d.ts +35 -0
- package/dist/typescript/module/src/components/prompt-input/reasoning-level-selector.d.ts.map +1 -0
- package/dist/typescript/module/src/components/prompt-input/voice-recorder.d.ts +48 -0
- package/dist/typescript/module/src/components/prompt-input/voice-recorder.d.ts.map +1 -0
- package/dist/typescript/module/src/components/sessions-list/index.d.ts +2 -0
- package/dist/typescript/module/src/components/sessions-list/index.d.ts.map +1 -0
- package/dist/typescript/module/src/components/sessions-list/sessions-list.d.ts +59 -0
- package/dist/typescript/module/src/components/sessions-list/sessions-list.d.ts.map +1 -0
- package/dist/typescript/module/src/hooks/index.d.ts +8 -0
- package/dist/typescript/module/src/hooks/index.d.ts.map +1 -0
- package/dist/typescript/module/src/hooks/use-agent-models.d.ts +68 -0
- package/dist/typescript/module/src/hooks/use-agent-models.d.ts.map +1 -0
- package/dist/typescript/module/src/hooks/use-assistant.d.ts +55 -0
- package/dist/typescript/module/src/hooks/use-assistant.d.ts.map +1 -0
- package/dist/typescript/module/src/hooks/use-attachment-picker.d.ts +99 -0
- package/dist/typescript/module/src/hooks/use-attachment-picker.d.ts.map +1 -0
- package/dist/typescript/module/src/hooks/use-voice-recorder.d.ts +101 -0
- package/dist/typescript/module/src/hooks/use-voice-recorder.d.ts.map +1 -0
- package/dist/typescript/module/src/index.d.ts +47 -0
- package/dist/typescript/module/src/index.d.ts.map +1 -0
- package/dist/typescript/module/src/theme/assistant-theme.d.ts +51 -0
- package/dist/typescript/module/src/theme/assistant-theme.d.ts.map +1 -0
- package/dist/typescript/module/src/theme/index.d.ts +2 -0
- package/dist/typescript/module/src/theme/index.d.ts.map +1 -0
- package/dist/typescript/module/src/types/index.d.ts +167 -0
- package/dist/typescript/module/src/types/index.d.ts.map +1 -0
- package/dist/typescript/module/src/ui/action-sheet.d.ts +29 -0
- package/dist/typescript/module/src/ui/action-sheet.d.ts.map +1 -0
- package/dist/typescript/module/src/ui/alert-dialog.d.ts +12 -0
- package/dist/typescript/module/src/ui/alert-dialog.d.ts.map +1 -0
- package/dist/typescript/module/src/ui/docyrus-brand-mark.d.ts +5 -0
- package/dist/typescript/module/src/ui/docyrus-brand-mark.d.ts.map +1 -0
- package/dist/typescript/module/src/ui/docyrus-icon.d.ts +11 -0
- package/dist/typescript/module/src/ui/docyrus-icon.d.ts.map +1 -0
- package/dist/typescript/module/src/ui/index.d.ts +5 -0
- package/dist/typescript/module/src/ui/index.d.ts.map +1 -0
- package/dist/typescript/module/src/utils/api-client.d.ts +35 -0
- package/dist/typescript/module/src/utils/api-client.d.ts.map +1 -0
- package/dist/typescript/module/src/utils/default-api-config.d.ts +38 -0
- package/dist/typescript/module/src/utils/default-api-config.d.ts.map +1 -0
- package/dist/typescript/module/src/utils/index.d.ts +9 -0
- package/dist/typescript/module/src/utils/index.d.ts.map +1 -0
- package/dist/typescript/module/src/utils/resolve-api-headers.d.ts +3 -0
- package/dist/typescript/module/src/utils/resolve-api-headers.d.ts.map +1 -0
- package/package.json +176 -0
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback } from 'react';
|
|
4
|
+
import * as DocumentPicker from 'expo-document-picker';
|
|
5
|
+
import * as ImagePicker from 'expo-image-picker';
|
|
6
|
+
/**
|
|
7
|
+
* Generate unique ID for attachments
|
|
8
|
+
*/
|
|
9
|
+
const generateId = () => `attachment_${Date.now()}_${Math.random().toString(36).substring(2, 9)}`;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Get file extension from name or URI
|
|
13
|
+
*/
|
|
14
|
+
const getFileExtension = name => {
|
|
15
|
+
const match = name.match(/\.([^.]+)$/);
|
|
16
|
+
return match?.[1]?.toLowerCase() ?? '';
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Determine MIME type from extension
|
|
21
|
+
*/
|
|
22
|
+
const getMimeType = (name, providedMime) => {
|
|
23
|
+
if (providedMime && providedMime !== 'application/octet-stream') {
|
|
24
|
+
return providedMime;
|
|
25
|
+
}
|
|
26
|
+
const ext = getFileExtension(name);
|
|
27
|
+
const mimeMap = {
|
|
28
|
+
pdf: 'application/pdf',
|
|
29
|
+
doc: 'application/msword',
|
|
30
|
+
docx: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
|
31
|
+
xls: 'application/vnd.ms-excel',
|
|
32
|
+
xlsx: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
33
|
+
ppt: 'application/vnd.ms-powerpoint',
|
|
34
|
+
pptx: 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
|
35
|
+
txt: 'text/plain',
|
|
36
|
+
csv: 'text/csv',
|
|
37
|
+
json: 'application/json',
|
|
38
|
+
jpg: 'image/jpeg',
|
|
39
|
+
jpeg: 'image/jpeg',
|
|
40
|
+
png: 'image/png',
|
|
41
|
+
gif: 'image/gif',
|
|
42
|
+
webp: 'image/webp',
|
|
43
|
+
heic: 'image/heic',
|
|
44
|
+
mp3: 'audio/mpeg',
|
|
45
|
+
wav: 'audio/wav',
|
|
46
|
+
m4a: 'audio/m4a',
|
|
47
|
+
mp4: 'video/mp4',
|
|
48
|
+
mov: 'video/quicktime'
|
|
49
|
+
};
|
|
50
|
+
return mimeMap[ext] || 'application/octet-stream';
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Hook for picking and managing attachments
|
|
55
|
+
*
|
|
56
|
+
* Supports documents via expo-document-picker and images via expo-image-picker.
|
|
57
|
+
* Converts picked files to AIMessageFile format.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```tsx
|
|
61
|
+
* const {
|
|
62
|
+
* attachments,
|
|
63
|
+
* pickDocuments,
|
|
64
|
+
* pickImages,
|
|
65
|
+
* takePhoto,
|
|
66
|
+
* removeAttachment,
|
|
67
|
+
* clearAttachments
|
|
68
|
+
* } = useAttachmentPicker({
|
|
69
|
+
* maxAttachments: 5,
|
|
70
|
+
* onAttachmentsChange: (files) => console.log('Attachments:', files)
|
|
71
|
+
* });
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export function useAttachmentPicker(options = {}) {
|
|
75
|
+
const {
|
|
76
|
+
allowedDocumentTypes = ['*/*'],
|
|
77
|
+
allowedImageTypes = ['images'],
|
|
78
|
+
maxAttachments = 10,
|
|
79
|
+
maxFileSize = 10 * 1024 * 1024,
|
|
80
|
+
// 10MB
|
|
81
|
+
allowMultiple = true,
|
|
82
|
+
onAttachmentsChange,
|
|
83
|
+
onError
|
|
84
|
+
} = options;
|
|
85
|
+
const [attachments, setAttachments] = useState([]);
|
|
86
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
87
|
+
const [isPicking, setIsPicking] = useState(false);
|
|
88
|
+
const [error, setError] = useState(null);
|
|
89
|
+
const updateAttachments = useCallback(newAttachments => {
|
|
90
|
+
setAttachments(newAttachments);
|
|
91
|
+
onAttachmentsChange?.(newAttachments);
|
|
92
|
+
}, [onAttachmentsChange]);
|
|
93
|
+
const validateFile = useCallback(file => {
|
|
94
|
+
if (file.size && file.size > maxFileSize) {
|
|
95
|
+
const err = new Error(`File "${file.name}" exceeds maximum size of ${Math.round(maxFileSize / 1024 / 1024)}MB`);
|
|
96
|
+
setError(err);
|
|
97
|
+
onError?.(err);
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
return true;
|
|
101
|
+
}, [maxFileSize, onError]);
|
|
102
|
+
const checkAttachmentLimit = useCallback(countToAdd => {
|
|
103
|
+
if (attachments.length + countToAdd > maxAttachments) {
|
|
104
|
+
const err = new Error(`Maximum ${maxAttachments} attachments allowed`);
|
|
105
|
+
setError(err);
|
|
106
|
+
onError?.(err);
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
return true;
|
|
110
|
+
}, [attachments.length, maxAttachments, onError]);
|
|
111
|
+
const pickDocuments = useCallback(async () => {
|
|
112
|
+
// Prevent multiple concurrent picks
|
|
113
|
+
if (isPicking) {
|
|
114
|
+
return [];
|
|
115
|
+
}
|
|
116
|
+
setError(null);
|
|
117
|
+
setIsLoading(true);
|
|
118
|
+
setIsPicking(true);
|
|
119
|
+
try {
|
|
120
|
+
const result = await DocumentPicker.getDocumentAsync({
|
|
121
|
+
type: allowedDocumentTypes,
|
|
122
|
+
multiple: allowMultiple,
|
|
123
|
+
copyToCacheDirectory: true
|
|
124
|
+
});
|
|
125
|
+
if (result.canceled || !result.assets) {
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const availableSlots = maxAttachments - attachments.length;
|
|
129
|
+
const assetsToAdd = result.assets.slice(0, availableSlots);
|
|
130
|
+
if (result.assets.length > availableSlots) {
|
|
131
|
+
const err = new Error(`Only ${availableSlots} more attachment(s) allowed. Some files were not added.`);
|
|
132
|
+
setError(err);
|
|
133
|
+
onError?.(err);
|
|
134
|
+
}
|
|
135
|
+
const newAttachments = [];
|
|
136
|
+
for (const asset of assetsToAdd) {
|
|
137
|
+
if (!validateFile({
|
|
138
|
+
size: asset.size,
|
|
139
|
+
name: asset.name
|
|
140
|
+
})) {
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
newAttachments.push({
|
|
144
|
+
id: generateId(),
|
|
145
|
+
name: asset.name,
|
|
146
|
+
type: getMimeType(asset.name, asset.mimeType),
|
|
147
|
+
uri: asset.uri,
|
|
148
|
+
size: asset.size
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
const updatedAttachments = [...attachments, ...newAttachments];
|
|
152
|
+
updateAttachments(updatedAttachments);
|
|
153
|
+
return newAttachments;
|
|
154
|
+
} catch (err) {
|
|
155
|
+
const pickerError = err instanceof Error ? err : new Error('Failed to pick documents');
|
|
156
|
+
setError(pickerError);
|
|
157
|
+
onError?.(pickerError);
|
|
158
|
+
return [];
|
|
159
|
+
} finally {
|
|
160
|
+
setIsLoading(false);
|
|
161
|
+
setIsPicking(false);
|
|
162
|
+
}
|
|
163
|
+
}, [isPicking, allowedDocumentTypes, allowMultiple, attachments, maxAttachments, validateFile, updateAttachments, onError]);
|
|
164
|
+
const pickImages = useCallback(async () => {
|
|
165
|
+
// Prevent multiple concurrent picks
|
|
166
|
+
if (isPicking) {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
setError(null);
|
|
170
|
+
setIsLoading(true);
|
|
171
|
+
setIsPicking(true);
|
|
172
|
+
try {
|
|
173
|
+
// Request permissions
|
|
174
|
+
const permissionResult = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
|
175
|
+
if (!permissionResult.granted) {
|
|
176
|
+
throw new Error('Permission to access media library was denied');
|
|
177
|
+
}
|
|
178
|
+
const result = await ImagePicker.launchImageLibraryAsync({
|
|
179
|
+
mediaTypes: allowedImageTypes,
|
|
180
|
+
allowsMultipleSelection: allowMultiple,
|
|
181
|
+
quality: 0.8
|
|
182
|
+
});
|
|
183
|
+
if (result.canceled || !result.assets) {
|
|
184
|
+
return [];
|
|
185
|
+
}
|
|
186
|
+
const availableSlots = maxAttachments - attachments.length;
|
|
187
|
+
const assetsToAdd = result.assets.slice(0, availableSlots);
|
|
188
|
+
if (result.assets.length > availableSlots) {
|
|
189
|
+
const err = new Error(`Only ${availableSlots} more attachment(s) allowed. Some images were not added.`);
|
|
190
|
+
setError(err);
|
|
191
|
+
onError?.(err);
|
|
192
|
+
}
|
|
193
|
+
const newAttachments = [];
|
|
194
|
+
for (const asset of assetsToAdd) {
|
|
195
|
+
const fileName = asset.fileName || `image_${Date.now()}.${asset.type === 'video' ? 'mp4' : 'jpg'}`;
|
|
196
|
+
if (!validateFile({
|
|
197
|
+
size: asset.fileSize,
|
|
198
|
+
name: fileName
|
|
199
|
+
})) {
|
|
200
|
+
continue;
|
|
201
|
+
}
|
|
202
|
+
newAttachments.push({
|
|
203
|
+
id: generateId(),
|
|
204
|
+
name: fileName,
|
|
205
|
+
type: asset.mimeType || getMimeType(fileName),
|
|
206
|
+
uri: asset.uri,
|
|
207
|
+
size: asset.fileSize
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
const updatedAttachments = [...attachments, ...newAttachments];
|
|
211
|
+
updateAttachments(updatedAttachments);
|
|
212
|
+
return newAttachments;
|
|
213
|
+
} catch (err) {
|
|
214
|
+
const pickerError = err instanceof Error ? err : new Error('Failed to pick images');
|
|
215
|
+
setError(pickerError);
|
|
216
|
+
onError?.(pickerError);
|
|
217
|
+
return [];
|
|
218
|
+
} finally {
|
|
219
|
+
setIsLoading(false);
|
|
220
|
+
setIsPicking(false);
|
|
221
|
+
}
|
|
222
|
+
}, [isPicking, allowedImageTypes, allowMultiple, attachments, maxAttachments, validateFile, updateAttachments, onError]);
|
|
223
|
+
const takePhoto = useCallback(async () => {
|
|
224
|
+
// Prevent multiple concurrent picks
|
|
225
|
+
if (isPicking) {
|
|
226
|
+
return null;
|
|
227
|
+
}
|
|
228
|
+
setError(null);
|
|
229
|
+
if (!checkAttachmentLimit(1)) {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
setIsLoading(true);
|
|
233
|
+
setIsPicking(true);
|
|
234
|
+
try {
|
|
235
|
+
// Request camera permissions
|
|
236
|
+
const permissionResult = await ImagePicker.requestCameraPermissionsAsync();
|
|
237
|
+
if (!permissionResult.granted) {
|
|
238
|
+
throw new Error('Permission to access camera was denied');
|
|
239
|
+
}
|
|
240
|
+
const result = await ImagePicker.launchCameraAsync({
|
|
241
|
+
mediaTypes: ['images'],
|
|
242
|
+
quality: 0.8
|
|
243
|
+
});
|
|
244
|
+
const asset = result.assets?.[0];
|
|
245
|
+
if (result.canceled || !asset) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const fileName = asset.fileName || `photo_${Date.now()}.jpg`;
|
|
249
|
+
if (!validateFile({
|
|
250
|
+
size: asset.fileSize,
|
|
251
|
+
name: fileName
|
|
252
|
+
})) {
|
|
253
|
+
return null;
|
|
254
|
+
}
|
|
255
|
+
const newAttachment = {
|
|
256
|
+
id: generateId(),
|
|
257
|
+
name: fileName,
|
|
258
|
+
type: asset.mimeType || 'image/jpeg',
|
|
259
|
+
uri: asset.uri,
|
|
260
|
+
size: asset.fileSize
|
|
261
|
+
};
|
|
262
|
+
const updatedAttachments = [...attachments, newAttachment];
|
|
263
|
+
updateAttachments(updatedAttachments);
|
|
264
|
+
return newAttachment;
|
|
265
|
+
} catch (err) {
|
|
266
|
+
const cameraError = err instanceof Error ? err : new Error('Failed to take photo');
|
|
267
|
+
setError(cameraError);
|
|
268
|
+
onError?.(cameraError);
|
|
269
|
+
return null;
|
|
270
|
+
} finally {
|
|
271
|
+
setIsLoading(false);
|
|
272
|
+
setIsPicking(false);
|
|
273
|
+
}
|
|
274
|
+
}, [isPicking, attachments, checkAttachmentLimit, validateFile, updateAttachments, onError]);
|
|
275
|
+
const addAttachment = useCallback(attachment => {
|
|
276
|
+
if (!checkAttachmentLimit(1)) {
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
const updatedAttachments = [...attachments, attachment];
|
|
280
|
+
updateAttachments(updatedAttachments);
|
|
281
|
+
}, [attachments, checkAttachmentLimit, updateAttachments]);
|
|
282
|
+
const removeAttachment = useCallback(id => {
|
|
283
|
+
const updatedAttachments = attachments.filter(a => a.id !== id);
|
|
284
|
+
updateAttachments(updatedAttachments);
|
|
285
|
+
setError(null);
|
|
286
|
+
}, [attachments, updateAttachments]);
|
|
287
|
+
const clearAttachments = useCallback(() => {
|
|
288
|
+
updateAttachments([]);
|
|
289
|
+
setError(null);
|
|
290
|
+
}, [updateAttachments]);
|
|
291
|
+
return {
|
|
292
|
+
attachments,
|
|
293
|
+
isLoading,
|
|
294
|
+
pickDocuments,
|
|
295
|
+
pickImages,
|
|
296
|
+
takePhoto,
|
|
297
|
+
addAttachment,
|
|
298
|
+
removeAttachment,
|
|
299
|
+
clearAttachments,
|
|
300
|
+
error
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
//# sourceMappingURL=use-attachment-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useCallback","DocumentPicker","ImagePicker","generateId","Date","now","Math","random","toString","substring","getFileExtension","name","match","toLowerCase","getMimeType","providedMime","ext","mimeMap","pdf","doc","docx","xls","xlsx","ppt","pptx","txt","csv","json","jpg","jpeg","png","gif","webp","heic","mp3","wav","m4a","mp4","mov","useAttachmentPicker","options","allowedDocumentTypes","allowedImageTypes","maxAttachments","maxFileSize","allowMultiple","onAttachmentsChange","onError","attachments","setAttachments","isLoading","setIsLoading","isPicking","setIsPicking","error","setError","updateAttachments","newAttachments","validateFile","file","size","err","Error","round","checkAttachmentLimit","countToAdd","length","pickDocuments","result","getDocumentAsync","type","multiple","copyToCacheDirectory","canceled","assets","availableSlots","assetsToAdd","slice","asset","push","id","mimeType","uri","updatedAttachments","pickerError","pickImages","permissionResult","requestMediaLibraryPermissionsAsync","granted","launchImageLibraryAsync","mediaTypes","allowsMultipleSelection","quality","fileName","fileSize","takePhoto","requestCameraPermissionsAsync","launchCameraAsync","newAttachment","cameraError","addAttachment","attachment","removeAttachment","filter","a","clearAttachments"],"sourceRoot":"../../../src","sources":["hooks/use-attachment-picker.ts"],"mappings":";;AAAA,SAASA,QAAQ,EAAEC,WAAW,QAAQ,OAAO;AAE7C,OAAO,KAAKC,cAAc,MAAM,sBAAsB;AACtD,OAAO,KAAKC,WAAW,MAAM,mBAAmB;AA+FhD;AACA;AACA;AACA,MAAMC,UAAU,GAAGA,CAAA,KAAM,cAAcC,IAAI,CAACC,GAAG,CAAC,CAAC,IAAIC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE;;AAEjG;AACA;AACA;AACA,MAAMC,gBAAgB,GAAIC,IAAY,IAAa;EACjD,MAAMC,KAAK,GAAGD,IAAI,CAACC,KAAK,CAAC,YAAY,CAAC;EAEtC,OAAOA,KAAK,GAAG,CAAC,CAAC,EAAEC,WAAW,CAAC,CAAC,IAAI,EAAE;AACxC,CAAC;;AAED;AACA;AACA;AACA,MAAMC,WAAW,GAAGA,CAACH,IAAY,EAAEI,YAAqB,KAAa;EACnE,IAAIA,YAAY,IAAIA,YAAY,KAAK,0BAA0B,EAAE;IAC/D,OAAOA,YAAY;EACrB;EAEA,MAAMC,GAAG,GAAGN,gBAAgB,CAACC,IAAI,CAAC;EAClC,MAAMM,OAA+B,GAAG;IACtCC,GAAG,EAAE,iBAAiB;IACtBC,GAAG,EAAE,oBAAoB;IACzBC,IAAI,EAAE,yEAAyE;IAC/EC,GAAG,EAAE,0BAA0B;IAC/BC,IAAI,EAAE,mEAAmE;IACzEC,GAAG,EAAE,+BAA+B;IACpCC,IAAI,EAAE,2EAA2E;IACjFC,GAAG,EAAE,YAAY;IACjBC,GAAG,EAAE,UAAU;IACfC,IAAI,EAAE,kBAAkB;IACxBC,GAAG,EAAE,YAAY;IACjBC,IAAI,EAAE,YAAY;IAClBC,GAAG,EAAE,WAAW;IAChBC,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AQ,CAAC,IAAI,CAAC;EAChB,CAAC,EAAE,CAACC,iBAAiB,CAAC,CAAC;EAEvB,OAAO;IACLR,WAAW;IACXE,SAAS;IACTiB,aAAa;IACbkB,UAAU;IACVU,SAAS;IACTK,aAAa;IACbE,gBAAgB;IAChBG,gBAAgB;IAChBnD;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useState, useCallback, useRef } from 'react';
|
|
4
|
+
import { useAudioRecorder, AudioModule, setAudioModeAsync, useAudioRecorderState, IOSOutputFormat, AudioQuality } from 'expo-audio';
|
|
5
|
+
import { apiClient } from "../utils/api-client.js";
|
|
6
|
+
import { resolveAPIHeaders } from "../utils/resolve-api-headers.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Custom recording preset optimized for speech transcription
|
|
10
|
+
* Uses WAV format for universal compatibility with transcription APIs
|
|
11
|
+
*/
|
|
12
|
+
const TRANSCRIPTION_PRESET = {
|
|
13
|
+
extension: '.wav',
|
|
14
|
+
sampleRate: 16000,
|
|
15
|
+
numberOfChannels: 1,
|
|
16
|
+
bitRate: 128000,
|
|
17
|
+
android: {
|
|
18
|
+
outputFormat: 'default',
|
|
19
|
+
audioEncoder: 'default',
|
|
20
|
+
extension: '.wav'
|
|
21
|
+
},
|
|
22
|
+
ios: {
|
|
23
|
+
outputFormat: IOSOutputFormat.LINEARPCM,
|
|
24
|
+
audioQuality: AudioQuality.HIGH,
|
|
25
|
+
linearPCMBitDepth: 16,
|
|
26
|
+
linearPCMIsBigEndian: false,
|
|
27
|
+
linearPCMIsFloat: false
|
|
28
|
+
},
|
|
29
|
+
web: {
|
|
30
|
+
mimeType: 'audio/wav',
|
|
31
|
+
bitsPerSecond: 128000
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Hook for voice recording with optional transcription
|
|
36
|
+
*
|
|
37
|
+
* Uses expo-audio (new API) for recording.
|
|
38
|
+
* Supports optional transcription via external endpoint.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```tsx
|
|
42
|
+
* const {
|
|
43
|
+
* isRecording,
|
|
44
|
+
* duration,
|
|
45
|
+
* startRecording,
|
|
46
|
+
* stopAndTranscribe,
|
|
47
|
+
* transcribedText
|
|
48
|
+
* } = useVoiceRecorder({
|
|
49
|
+
* transcribeEndpoint: 'https://api.example.com/transcribe',
|
|
50
|
+
* onTranscription: (text) => console.log('Transcribed:', text)
|
|
51
|
+
* });
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export function useVoiceRecorder(options = {}) {
|
|
55
|
+
const {
|
|
56
|
+
transcribeEndpoint,
|
|
57
|
+
transcribeHeaders,
|
|
58
|
+
onRecordingStart,
|
|
59
|
+
onRecordingStop,
|
|
60
|
+
onTranscription,
|
|
61
|
+
onError
|
|
62
|
+
} = options;
|
|
63
|
+
const [status, setStatus] = useState('idle');
|
|
64
|
+
const [recordingUri, setRecordingUri] = useState(null);
|
|
65
|
+
const [transcribedText, setTranscribedText] = useState(null);
|
|
66
|
+
const [isTranscribing, setIsTranscribing] = useState(false);
|
|
67
|
+
const [error, setError] = useState(null);
|
|
68
|
+
const [permissionGranted, setPermissionGranted] = useState(false);
|
|
69
|
+
const audioRecorder = useAudioRecorder(TRANSCRIPTION_PRESET);
|
|
70
|
+
const recorderState = useAudioRecorderState(audioRecorder);
|
|
71
|
+
const startTimeRef = useRef(null);
|
|
72
|
+
const ensureRecordingPermission = useCallback(async () => {
|
|
73
|
+
if (permissionGranted) {
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
try {
|
|
77
|
+
const result = await AudioModule.requestRecordingPermissionsAsync();
|
|
78
|
+
if (!result.granted) {
|
|
79
|
+
const permissionError = new Error('Recording permission denied');
|
|
80
|
+
setError(permissionError);
|
|
81
|
+
setStatus('error');
|
|
82
|
+
onError?.(permissionError);
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
setPermissionGranted(true);
|
|
86
|
+
await setAudioModeAsync({
|
|
87
|
+
playsInSilentMode: true,
|
|
88
|
+
allowsRecording: true
|
|
89
|
+
});
|
|
90
|
+
return true;
|
|
91
|
+
} catch (err) {
|
|
92
|
+
const recordError = err instanceof Error ? err : new Error('Failed to request permissions');
|
|
93
|
+
setError(recordError);
|
|
94
|
+
setStatus('error');
|
|
95
|
+
onError?.(recordError);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
}, [onError, permissionGranted]);
|
|
99
|
+
const startRecording = useCallback(async () => {
|
|
100
|
+
const hasPermission = await ensureRecordingPermission();
|
|
101
|
+
if (!hasPermission) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
try {
|
|
105
|
+
setError(null);
|
|
106
|
+
setTranscribedText(null);
|
|
107
|
+
setRecordingUri(null);
|
|
108
|
+
await audioRecorder.prepareToRecordAsync();
|
|
109
|
+
audioRecorder.record();
|
|
110
|
+
startTimeRef.current = Date.now();
|
|
111
|
+
setStatus('recording');
|
|
112
|
+
onRecordingStart?.();
|
|
113
|
+
} catch (err) {
|
|
114
|
+
const recordError = err instanceof Error ? err : new Error('Failed to start recording');
|
|
115
|
+
setError(recordError);
|
|
116
|
+
setStatus('error');
|
|
117
|
+
onError?.(recordError);
|
|
118
|
+
}
|
|
119
|
+
}, [ensureRecordingPermission, audioRecorder, onRecordingStart, onError]);
|
|
120
|
+
const stopRecording = useCallback(async () => {
|
|
121
|
+
try {
|
|
122
|
+
await audioRecorder.stop();
|
|
123
|
+
const {
|
|
124
|
+
uri
|
|
125
|
+
} = audioRecorder;
|
|
126
|
+
if (uri) {
|
|
127
|
+
setRecordingUri(uri);
|
|
128
|
+
setStatus('stopped');
|
|
129
|
+
onRecordingStop?.(uri);
|
|
130
|
+
return uri;
|
|
131
|
+
}
|
|
132
|
+
return null;
|
|
133
|
+
} catch (err) {
|
|
134
|
+
const recordError = err instanceof Error ? err : new Error('Failed to stop recording');
|
|
135
|
+
setError(recordError);
|
|
136
|
+
setStatus('error');
|
|
137
|
+
onError?.(recordError);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
}, [audioRecorder, onRecordingStop, onError]);
|
|
141
|
+
const transcribe = useCallback(async uri => {
|
|
142
|
+
if (!transcribeEndpoint) {
|
|
143
|
+
const err = new Error('Transcription endpoint not configured');
|
|
144
|
+
setError(err);
|
|
145
|
+
onError?.(err);
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
setIsTranscribing(true);
|
|
149
|
+
try {
|
|
150
|
+
/*
|
|
151
|
+
* Recording is already in WAV format (LINEARPCM)
|
|
152
|
+
* WAV has universal MIME type recognition: audio/wav
|
|
153
|
+
*/
|
|
154
|
+
const formData = new FormData();
|
|
155
|
+
formData.append('file', {
|
|
156
|
+
uri,
|
|
157
|
+
type: 'audio/wav',
|
|
158
|
+
name: 'recording.wav'
|
|
159
|
+
});
|
|
160
|
+
const result = await apiClient(transcribeEndpoint, {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: await resolveAPIHeaders(transcribeHeaders),
|
|
163
|
+
body: formData,
|
|
164
|
+
isFormData: true
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
// API returns: { success: true, data: { transcription: { text: "..." } } }
|
|
168
|
+
const text = result.data?.transcription?.text || result.data?.text || result.text || result.transcription?.text || result.transcription || '';
|
|
169
|
+
setTranscribedText(text);
|
|
170
|
+
onTranscription?.(text);
|
|
171
|
+
return text;
|
|
172
|
+
} catch (err) {
|
|
173
|
+
const transcribeError = err instanceof Error ? err : new Error('Transcription failed');
|
|
174
|
+
setError(transcribeError);
|
|
175
|
+
onError?.(transcribeError);
|
|
176
|
+
return null;
|
|
177
|
+
} finally {
|
|
178
|
+
setIsTranscribing(false);
|
|
179
|
+
}
|
|
180
|
+
}, [transcribeEndpoint, transcribeHeaders, onTranscription, onError]);
|
|
181
|
+
const stopAndTranscribe = useCallback(async () => {
|
|
182
|
+
const uri = await stopRecording();
|
|
183
|
+
if (uri && transcribeEndpoint) {
|
|
184
|
+
return transcribe(uri);
|
|
185
|
+
}
|
|
186
|
+
return null;
|
|
187
|
+
}, [stopRecording, transcribe, transcribeEndpoint]);
|
|
188
|
+
const reset = useCallback(() => {
|
|
189
|
+
setStatus('idle');
|
|
190
|
+
setRecordingUri(null);
|
|
191
|
+
setTranscribedText(null);
|
|
192
|
+
setIsTranscribing(false);
|
|
193
|
+
setError(null);
|
|
194
|
+
startTimeRef.current = null;
|
|
195
|
+
}, []);
|
|
196
|
+
|
|
197
|
+
// Calculate duration from recorder state
|
|
198
|
+
const duration = recorderState.isRecording ? Math.floor((Date.now() - (startTimeRef.current || Date.now())) / 1000) : 0;
|
|
199
|
+
return {
|
|
200
|
+
status,
|
|
201
|
+
isRecording: recorderState.isRecording,
|
|
202
|
+
duration,
|
|
203
|
+
recordingUri,
|
|
204
|
+
transcribedText,
|
|
205
|
+
isTranscribing,
|
|
206
|
+
startRecording,
|
|
207
|
+
stopRecording,
|
|
208
|
+
stopAndTranscribe,
|
|
209
|
+
transcribe,
|
|
210
|
+
reset,
|
|
211
|
+
error
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=use-voice-recorder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useState","useCallback","useRef","useAudioRecorder","AudioModule","setAudioModeAsync","useAudioRecorderState","IOSOutputFormat","AudioQuality","apiClient","resolveAPIHeaders","TRANSCRIPTION_PRESET","extension","sampleRate","numberOfChannels","bitRate","android","outputFormat","audioEncoder","ios","LINEARPCM","audioQuality","HIGH","linearPCMBitDepth","linearPCMIsBigEndian","linearPCMIsFloat","web","mimeType","bitsPerSecond","useVoiceRecorder","options","transcribeEndpoint","transcribeHeaders","onRecordingStart","onRecordingStop","onTranscription","onError","status","setStatus","recordingUri","setRecordingUri","transcribedText","setTranscribedText","isTranscribing","setIsTranscribing","error","setError","permissionGranted","setPermissionGranted","audioRecorder","recorderState","startTimeRef","ensureRecordingPermission","result","requestRecordingPermissionsAsync","granted","permissionError","Error","playsInSilentMode","allowsRecording","err","recordError","startRecording","hasPermission","prepareToRecordAsync","record","current","Date","now","stopRecording","stop","uri","transcribe","formData","FormData","append","type","name","method","headers","body","isFormData","text","data","transcription","transcribeError","stopAndTranscribe","reset","duration","isRecording","Math","floor"],"sourceRoot":"../../../src","sources":["hooks/use-voice-recorder.ts"],"mappings":";;AAAA,SACEA,QAAQ,EAAEC,WAAW,EAAEC,MAAM,QACxB,OAAO;AAEd,SACEC,gBAAgB,EAChBC,WAAW,EACXC,iBAAiB,EACjBC,qBAAqB,EACrBC,eAAe,EACfC,YAAY,QAEP,YAAY;AAGnB,SAASC,SAAS,QAAQ,wBAAqB;AAC/C,SAASC,iBAAiB,QAAQ,iCAA8B;;AAEhE;AACA;AACA;AACA;AACA,MAAMC,oBAAsC,GAAG;EAC7CC,SAAS,EAAE,MAAM;EACjBC,UAAU,EAAE,KAAK;EACjBC,gBAAgB,EAAE,CAAC;EACnBC,OAAO,EAAE,MAAM;EACfC,OAAO,EAAE;IACPC,YAAY,EAAE,SAAS;IACvBC,YAAY,EAAE,SAAS;IACvBN,SAAS,EAAE;EACb,CAAC;EACDO,GAAG,EAAE;IACHF,YAAY,EAAEV,eAAe,CAACa,SAAS;IACvCC,YAAY,EAAEb,YAAY,CAACc,IAAI;IAC/BC,iBAAiB,EAAE,EAAE;IACrBC,oBAAoB,EAAE,KAAK;IAC3BC,gBAAgB,EAAE;EACpB,CAAC;EACDC,GAAG,EAAE;IACHC,QAAQ,EAAE,WAAW;IACrBC,aAAa,EAAE;EACjB;AACF,CAAC;AAmGD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAACC,OAAgC,GAAG,CAAC,CAAC,EAA0B;EAC9F,MAAM;IACJC,kBAAkB;IAClBC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AAC,IAAI,CAAC;IACdK,YAAY,CAACe,OAAO,GAAG,IAAI;EAC7B,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA,MAAMsB,QAAQ,GAAGtC,aAAa,CAACuC,WAAW,GAAGC,IAAI,CAACC,KAAK,CAAC,CAACxB,IAAI,CAACC,GAAG,CAAC,CAAC,IAAIjB,YAAY,CAACe,OAAO,IAAIC,IAAI,CAACC,GAAG,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC;EAEvH,OAAO;IACL/B,MAAM;IACNoD,WAAW,EAAEvC,aAAa,CAACuC,WAAW;IACtCD,QAAQ;IACRjD,YAAY;IACZE,eAAe;IACfE,cAAc;IACdmB,cAAc;IACdO,aAAa;IACbiB,iBAAiB;IACjBd,UAAU;IACVe,KAAK;IACL1C;EACF,CAAC;AACH","ignoreList":[]}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @docyrus/rn-assistant - AI Assistant System for React Native
|
|
5
|
+
*
|
|
6
|
+
* Complete AI assistant system with Vercel AI SDK integration:
|
|
7
|
+
* - Chat interface with streaming responses
|
|
8
|
+
* - Agent/Model selection
|
|
9
|
+
* - Session management
|
|
10
|
+
* - Voice recording & transcription
|
|
11
|
+
* - File attachments (documents, images)
|
|
12
|
+
* - Quick actions and prompts
|
|
13
|
+
*
|
|
14
|
+
* **Requirements:**
|
|
15
|
+
* - `expo-constants` >= 18.0.0 (for AI SDK integration)
|
|
16
|
+
* - `@ai-sdk/react` and `ai` (bundled)
|
|
17
|
+
* - `expo/fetch` (for network requests)
|
|
18
|
+
* - internal theme and UI primitives are bundled locally
|
|
19
|
+
*
|
|
20
|
+
* @module @docyrus/rn-assistant
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* import { DocyrusRNAssistant, createDocyrusRNAssistantConfig } from '@docyrus/rn-assistant';
|
|
25
|
+
*
|
|
26
|
+
* function App() {
|
|
27
|
+
* const apiConfig = createDocyrusRNAssistantConfig({
|
|
28
|
+
* baseUrl: 'https://api.docyrus.com',
|
|
29
|
+
* token: userToken
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* return (
|
|
33
|
+
* <DocyrusRNAssistant
|
|
34
|
+
* apiConfig={apiConfig}
|
|
35
|
+
* agentId="agent-123"
|
|
36
|
+
* credentials={{ token: userToken }}
|
|
37
|
+
* />
|
|
38
|
+
* );
|
|
39
|
+
* }
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
// Components
|
|
44
|
+
export * from "./components/index.js";
|
|
45
|
+
export { DocyrusRNAssistant, DocyrusRNAssistantEmbedded, DocyrusRNAssistantModal, DocyrusRNAssistantSheet } from "./components/assistant-screen/index.js";
|
|
46
|
+
|
|
47
|
+
// Hooks
|
|
48
|
+
export * from "./hooks/index.js";
|
|
49
|
+
|
|
50
|
+
// Theme
|
|
51
|
+
export * from "./theme/index.js";
|
|
52
|
+
|
|
53
|
+
// Utils
|
|
54
|
+
export * from "./utils/index.js";
|
|
55
|
+
export { createDocyrusAPIConfig, createDocyrusRNAssistantConfig } from "./utils/default-api-config.js";
|
|
56
|
+
|
|
57
|
+
// Types
|
|
58
|
+
export * from "./types/index.js";
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["DocyrusRNAssistant","DocyrusRNAssistantEmbedded","DocyrusRNAssistantModal","DocyrusRNAssistantSheet","createDocyrusAPIConfig","createDocyrusRNAssistantConfig"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,cAAc,uBAAc;AAC5B,SACEA,kBAAkB,EAClBC,0BAA0B,EAC1BC,uBAAuB,EACvBC,uBAAuB,QAElB,wCAA+B;;AAEtC;AACA,cAAc,kBAAS;;AAEvB;AACA,cAAc,kBAAS;;AAEvB;AACA,cAAc,kBAAS;AACvB,SACEC,sBAAsB,EACtBC,8BAA8B,QACzB,+BAA4B;;AAEnC;AACA,cAAc,kBAAS","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"type":"module"}
|