From 90469eed6dc7b2ad801dfbf6dfa3470c92353541 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Mon, 18 Dec 2023 17:53:28 +0530 Subject: [PATCH 1/4] Fix audio recorder functionality on Apple devices --- package.json | 2 +- src/components/chatbar.tsx | 10 +- src/components/recorder.tsx | 52 ++++++++ yarn.lock | 234 ++++-------------------------------- 4 files changed, 81 insertions(+), 217 deletions(-) create mode 100644 src/components/recorder.tsx diff --git a/package.json b/package.json index dd5358c5..b4bf836d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@types/node": "18.16.0", "@types/react": "18.0.38", "@types/react-dom": "18.0.11", + "audio-recorder-polyfill": "^0.4.1", "autoprefixer": "10.4.14", "eslint": "8.39.0", "eslint-config-next": "13.3.1", @@ -36,7 +37,6 @@ "react-hot-toast": "^2.4.1", "react-infinite-scroller": "^1.2.6", "react-markdown": "^8.0.7", - "react-media-recorder-2": "^1.6.23", "rehype-raw": "^6.1.1", "remark-gfm": "^3.0.1", "tailwind-merge": "^1.12.0", diff --git a/src/components/chatbar.tsx b/src/components/chatbar.tsx index 2ca3ddf3..5d85e30e 100644 --- a/src/components/chatbar.tsx +++ b/src/components/chatbar.tsx @@ -1,12 +1,12 @@ import { useState } from "react"; import { Input } from "./ui/interactive"; import Loading from "./ui/loading"; -import { useReactMediaRecorder } from "react-media-recorder-2"; import LangDialog from "./ui/langdialog"; import { supportedLanguages } from "@/utils/constants"; import { storageAtom } from "@/store"; import { useAtom } from "jotai"; import Modal from "./modal"; +import { useAudioRecorder } from "./recorder"; export default function ChatBar(props: { chat: string, @@ -20,11 +20,7 @@ export default function ChatBar(props: { const { chat, onChange, onSubmit, errors, loading, onAudio } = props; const [storage, setStorage] = useAtom(storageAtom); - - const { status, startRecording, stopRecording, mediaBlobUrl } = useReactMediaRecorder({ - audio: true, - onStop: onAudio - }); + const { status, startRecording, stopRecording, mediaBlobUrl } = useAudioRecorder(onAudio); const [langDialogOpen, setLangDialogOpen] = useState(false); @@ -90,7 +86,7 @@ export default function ChatBar(props: { - diff --git a/src/components/recorder.tsx b/src/components/recorder.tsx new file mode 100644 index 00000000..0f019d79 --- /dev/null +++ b/src/components/recorder.tsx @@ -0,0 +1,52 @@ +import { useState, useCallback } from 'react'; +import AudioRecorder from 'audio-recorder-polyfill'; + +type UseAudioRecorderReturn = { + status: string, + startRecording: () => void, + stopRecording: () => void, + mediaBlobUrl: string | null, +}; + +export const useAudioRecorder = (onStop?: (url: string) => void): UseAudioRecorderReturn => { + const [status, setStatus] = useState('idle'); + const [mediaBlobUrl, setMediaBlobUrl] = useState(null); + const [mediaRecorder, setMediaRecorder] = useState(null); + const [mediaStream, setMediaStream] = useState(null); + + const startRecording = useCallback(() => { + if (status !== 'idle') return; + + navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => { + setMediaStream(stream); + + const recorder = new AudioRecorder(stream); + setMediaRecorder(recorder); + + const audioChunks: BlobPart[] = []; + recorder.addEventListener('dataavailable', (event: any) => audioChunks.push(event.data)); + recorder.addEventListener('stop', () => { + const audioBlob = new Blob(audioChunks, { type: 'audio/wav' }); + const audioUrl = URL.createObjectURL(audioBlob); + setMediaBlobUrl(audioUrl); + onStop?.(audioUrl); + setStatus('stopped'); + }); + + recorder.start(); + setStatus('recording'); + }).catch(error => { + console.error('Error accessing media devices:', error); + }); + }, [status, onStop]); + + const stopRecording = useCallback(() => { + if (mediaRecorder && mediaRecorder.state === 'recording') { + mediaRecorder.stop(); + mediaStream?.getTracks().forEach(track => track.stop()); + setMediaStream(null); + } + }, [mediaRecorder, mediaStream]); + + return { status, startRecording, stopRecording, mediaBlobUrl }; +}; diff --git a/yarn.lock b/yarn.lock index f9c5c2f8..05104f39 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,7 +2,7 @@ # yarn lockfile v1 -"@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.20.7", "@babel/runtime@^7.21.5": +"@babel/runtime@^7.12.5", "@babel/runtime@^7.14.0", "@babel/runtime@^7.20.7": version "7.21.5" resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.5.tgz" integrity sha512-8jI69toZqqcsnqGGqwGS4Qb1VwLOEp4hz+CXPywcvjs60u3B4Pom/U/7rm4W8tMOYEB+E9wgD0mW1l3r8qlI9Q== @@ -89,11 +89,6 @@ resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz" integrity sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg== -"@jridgewell/sourcemap-codec@1.4.14": - version "1.4.14" - resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - "@jridgewell/trace-mapping@^0.3.9": version "0.3.18" resolved "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.18.tgz" @@ -149,6 +144,21 @@ resolved "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-13.3.1.tgz" integrity sha512-uqm5sielhQmKJM+qayIhgZv1KlS5pqTdQ99b+Z7hMWryXS96qE0DftTmMZowBcUL6x7s2vSXyH5wPtO1ON7LBg== +"@next/swc-win32-arm64-msvc@13.3.1": + version "13.3.1" + resolved "https://registry.yarnpkg.com/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-13.3.1.tgz#f8ed1badab57ed4503969758754e6fb0cf326753" + integrity sha512-WomIiTj/v3LevltlibNQKmvrOymNRYL+a0dp5R73IwPWN5FvXWwSELN/kiNALig/+T3luc4qHNTyvMCp9L6U5Q== + +"@next/swc-win32-ia32-msvc@13.3.1": + version "13.3.1" + resolved "https://registry.yarnpkg.com/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-13.3.1.tgz#7f599c8975b09ee5527cc49b9e5a4d13be50635a" + integrity sha512-M+PoH+0+q658wRUbs285RIaSTYnGBSTdweH/0CdzDgA6Q4rBM0sQs4DHmO3BPP0ltCO/vViIoyG7ks66XmCA5g== + +"@next/swc-win32-x64-msvc@13.3.1": + version "13.3.1" + resolved "https://registry.yarnpkg.com/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.3.1.tgz#192d43ab44ebb98bd4f5865d0e1d7ce62703182f" + integrity sha512-Sl1F4Vp5Z1rNXWZYqJwMuWRRol4bqOB6+/d7KqkgQ4AcafKPN1PZmpkCoxv4UFHtFNIB7EotnuIhtXu3zScicQ== + "@nodelib/fs.scandir@2.1.5": version "2.1.5" resolved "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz" @@ -157,7 +167,7 @@ "@nodelib/fs.stat" "2.0.5" run-parallel "^1.1.9" -"@nodelib/fs.stat@^2.0.2", "@nodelib/fs.stat@2.0.5": +"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": version "2.0.5" resolved "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz" integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== @@ -504,13 +514,10 @@ atob@^2.1.2: resolved "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== -automation-events@^6.0.1: - version "6.0.1" - resolved "https://registry.npmjs.org/automation-events/-/automation-events-6.0.1.tgz" - integrity sha512-AHpETuZtlDy9/lupkn7GZIpUxgAlx7AjVGU6uh04wrrMawNf9Zjr6Erl/QoHRhQvIGMdFrs+6B2ngkh50lNJ9w== - dependencies: - "@babel/runtime" "^7.21.5" - tslib "^2.5.0" +audio-recorder-polyfill@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/audio-recorder-polyfill/-/audio-recorder-polyfill-0.4.1.tgz#4290eca3d8edf49eb6daba59592aacf357b6e5b7" + integrity sha512-SS4qVOzuVwlS/tjQdd0uR+9cCKBTkx4jsAdjM+rMNqoTEWf6bMnBSTfv+FO4Zn9ngxviJOxhkgRWWXsAMqM96Q== autoprefixer@10.4.14: version "10.4.14" @@ -576,16 +583,6 @@ braces@^3.0.2, braces@~3.0.2: dependencies: fill-range "^7.0.1" -broker-factory@^3.0.77: - version "3.0.77" - resolved "https://registry.npmjs.org/broker-factory/-/broker-factory-3.0.77.tgz" - integrity sha512-umNbrB0Y2qUiaNBMfyLIkKIQffUrBS72H7hMrxdEqHAZDcaUNtuhzV+7cNlU+omVScpwFXzmByw4OM87X4Afow== - dependencies: - "@babel/runtime" "^7.21.5" - fast-unique-numbers "^8.0.1" - tslib "^2.5.0" - worker-factory "^7.0.1" - browserslist@^4.21.5: version "4.21.5" resolved "https://registry.npmjs.org/browserslist/-/browserslist-4.21.5.tgz" @@ -731,16 +728,6 @@ commander@^6.2.0: resolved "https://registry.npmjs.org/commander/-/commander-6.2.1.tgz" integrity sha512-U7VdrJFnJgo4xjrHpTzu0yrHPGImdsmD95ZlgYSEajAn2JKzDhDTPG9kBTefmObL2w/ngeZnilk+OV9CG3d7UA== -compilerr@^11.0.1: - version "11.0.1" - resolved "https://registry.npmjs.org/compilerr/-/compilerr-11.0.1.tgz" - integrity sha512-SAsrObH0Y5d8DjjWfgugmlc1Pl2d0/rD+Sinlj8+FaH1EWXnwwkjp9Pg8f84EEsGfd6J1cytilITgl1uyRI3nw== - dependencies: - "@babel/runtime" "^7.21.5" - dashify "^2.0.0" - indefinite-article "0.0.2" - tslib "^2.5.0" - concat-map@0.0.1: version "0.0.1" resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz" @@ -798,7 +785,7 @@ cssesc@^3.0.0: resolved "https://registry.npmjs.org/cssesc/-/cssesc-3.0.0.tgz" integrity sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg== -csstype@^3.0.10, csstype@^3.0.2: +csstype@^3.0.2: version "3.1.2" resolved "https://registry.npmjs.org/csstype/-/csstype-3.1.2.tgz" integrity sha512-I7K1Uu0MBPzaFKg4nI5Q7Vs2t+3gWWW648spaF+Rg7pI9ds18Ugn+lvg4SHczUdKlHI5LWBXyqfS8+DufyBsgQ== @@ -808,11 +795,6 @@ damerau-levenshtein@^1.0.8: resolved "https://registry.npmjs.org/damerau-levenshtein/-/damerau-levenshtein-1.0.8.tgz" integrity sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA== -dashify@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/dashify/-/dashify-2.0.0.tgz" - integrity sha512-hpA5C/YrPjucXypHPPc0oJ1l9Hf6wWbiOL7Ik42cxnsUOhWiCB/fylKbKqqJalW9FgkNQCw16YO8uW9Hs0Iy1A== - debug@^3.2.7: version "3.2.7" resolved "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz" @@ -1174,7 +1156,7 @@ eslint-visitor-keys@^3.3.0, eslint-visitor-keys@^3.4.0: resolved "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.0.tgz" integrity sha512-HPpKPUBQcAsZOsHAFwTtIKcYlCje62XB7SEAcxjtmW6TD1WVpkS6i6/hOVtTZIl4zGj/mBqpFVGvaDneik+VoQ== -eslint@*, "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8", "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8", "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0", "eslint@^6.0.0 || ^7.0.0 || ^8.0.0", "eslint@^6.0.0 || ^7.0.0 || >=8.0.0", "eslint@^7.23.0 || ^8.0.0", eslint@8.39.0: +eslint@8.39.0: version "8.39.0" resolved "https://registry.npmjs.org/eslint/-/eslint-8.39.0.tgz" integrity sha512-mwiok6cy7KTW7rBpo05k6+p4YVZByLNjAZ/ACB9DRCu4YDRwjXI01tWHp6KAUWelsBetTxKK/2sHB0vdS8Z2Og== @@ -1258,48 +1240,6 @@ extend@^3.0.0: resolved "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz" integrity sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g== -extendable-media-recorder-wav-encoder-broker@^7.0.79: - version "7.0.79" - resolved "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-broker/-/extendable-media-recorder-wav-encoder-broker-7.0.79.tgz" - integrity sha512-mzl++2+ahw+sy7w1hV67OSEkxYa8ERBDm+TWb5P/wn8KLhg3cCGa4DaicJYYhSCF4EH1N2PauicmIUGS5MSBxA== - dependencies: - "@babel/runtime" "^7.21.5" - broker-factory "^3.0.77" - extendable-media-recorder-wav-encoder-worker "^8.0.78" - tslib "^2.5.0" - -extendable-media-recorder-wav-encoder-worker@^8.0.78: - version "8.0.78" - resolved "https://registry.npmjs.org/extendable-media-recorder-wav-encoder-worker/-/extendable-media-recorder-wav-encoder-worker-8.0.78.tgz" - integrity sha512-Zi05HnU7nWcTmAb6XGxKZg+nSQ7HogKHeEMTf1KLZZ8afZKy9ekkfE3N95oIEyXH5zvWE8QckCI/8JStYdTStg== - dependencies: - "@babel/runtime" "^7.21.5" - tslib "^2.5.0" - worker-factory "^7.0.1" - -extendable-media-recorder-wav-encoder@^7.0.85: - version "7.0.87" - resolved "https://registry.npmjs.org/extendable-media-recorder-wav-encoder/-/extendable-media-recorder-wav-encoder-7.0.87.tgz" - integrity sha512-NL3tdhArn+qJa7tP2u2rPEqSYvDixsa9cP9ZplepNznYQvF/AGANyl3kROJfNpjx0vCbskiCs/GyGQXzSNpirg== - dependencies: - "@babel/runtime" "^7.21.5" - extendable-media-recorder-wav-encoder-broker "^7.0.79" - extendable-media-recorder-wav-encoder-worker "^8.0.78" - tslib "^2.5.0" - -extendable-media-recorder@^7.1.9: - version "7.1.14" - resolved "https://registry.npmjs.org/extendable-media-recorder/-/extendable-media-recorder-7.1.14.tgz" - integrity sha512-MkYf2S8OKFeMMEgybPM9M1i/G4+pa7JkapEEkzKmndpmuWPTu1f9fdEAzFoyOt+d7MQpQGpC/Y9hSyZMqMcIOQ== - dependencies: - "@babel/runtime" "^7.21.5" - media-encoder-host "^8.0.90" - multi-buffer-data-view "^5.0.1" - recorder-audio-worklet "^6.0.4" - standardized-audio-context "^25.3.46" - subscribable-things "^2.1.15" - tslib "^2.5.0" - fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: version "3.1.3" resolved "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz" @@ -1326,14 +1266,6 @@ fast-levenshtein@^2.0.6: resolved "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz" integrity sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw== -fast-unique-numbers@^8.0.1: - version "8.0.1" - resolved "https://registry.npmjs.org/fast-unique-numbers/-/fast-unique-numbers-8.0.1.tgz" - integrity sha512-du9ACbyy9v5aP3VJehpGVMOXm2gVDy/3isaJHrmKaofMCN1ViSq0OTppIZJ11Ve/ATgt/qWbfCstXnU/xPd4bg== - dependencies: - "@babel/runtime" "^7.21.5" - tslib "^2.5.0" - fastparse@^1.1.2: version "1.1.2" resolved "https://registry.npmjs.org/fastparse/-/fastparse-1.1.2.tgz" @@ -1451,7 +1383,7 @@ get-tsconfig@^4.5.0: resolved "https://registry.npmjs.org/get-tsconfig/-/get-tsconfig-4.5.0.tgz" integrity sha512-MjhiaIWCJ1sAU4pIQ5i5OfOuHHxVo1oYeNsWTON7jxYkod8pHocXeh+SSbmu5OZZZK73B6cbJ2XADzXehLyovQ== -glob-parent@^5.1.2: +glob-parent@^5.1.2, glob-parent@~5.1.2: version "5.1.2" resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz" integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== @@ -1717,11 +1649,6 @@ imurmurhash@^0.1.4: resolved "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz" integrity sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA== -indefinite-article@0.0.2: - version "0.0.2" - resolved "https://registry.npmjs.org/indefinite-article/-/indefinite-article-0.0.2.tgz" - integrity sha512-Au/2XzRkvxq2J6w5uvSSbBKPZ5kzINx5F2wb0SF8xpRL8BP9Lav81TnRbfPp6p+SYjYxwaaLn4EUwI3/MmYKSw== - inflight@^1.0.4: version "1.0.6" resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz" @@ -2258,37 +2185,6 @@ mdast-util-to-string@^3.0.0, mdast-util-to-string@^3.1.0: dependencies: "@types/mdast" "^3.0.0" -media-encoder-host-broker@^7.0.80: - version "7.0.80" - resolved "https://registry.npmjs.org/media-encoder-host-broker/-/media-encoder-host-broker-7.0.80.tgz" - integrity sha512-TQ8j+eVatsPghhX2avAJwWejsWDbJbfLUi6p3rqpYwSBMcaGE3iwNmBJPPKbd6zs/nPNqenS54uEeXuA0qYd1Q== - dependencies: - "@babel/runtime" "^7.21.5" - broker-factory "^3.0.77" - fast-unique-numbers "^8.0.1" - media-encoder-host-worker "^9.1.2" - tslib "^2.5.0" - -media-encoder-host-worker@^9.1.2: - version "9.1.2" - resolved "https://registry.npmjs.org/media-encoder-host-worker/-/media-encoder-host-worker-9.1.2.tgz" - integrity sha512-0sTwT12Y5q+oIe8BBqlkBwhRuPT+kqu81jfCGXJ7iPVG4UYk/66Z6FY+Wh9XM7cb+70B6S/i8mEzXl/oZpVDSw== - dependencies: - "@babel/runtime" "^7.21.5" - extendable-media-recorder-wav-encoder-broker "^7.0.79" - tslib "^2.5.0" - worker-factory "^7.0.1" - -media-encoder-host@^8.0.90: - version "8.0.90" - resolved "https://registry.npmjs.org/media-encoder-host/-/media-encoder-host-8.0.90.tgz" - integrity sha512-d15kcrkpoFhhejIwcRur4kbf2T/0617a8yAznzBWfgAOFWZ56KEz9khzvkInXwn9/14bH600vsu0LASaBxTpCw== - dependencies: - "@babel/runtime" "^7.21.5" - media-encoder-host-broker "^7.0.80" - media-encoder-host-worker "^9.1.2" - tslib "^2.5.0" - memorystream@^0.3.1: version "0.3.1" resolved "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz" @@ -2603,14 +2499,6 @@ ms@2.1.2, ms@^2.1.1: resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -multi-buffer-data-view@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/multi-buffer-data-view/-/multi-buffer-data-view-5.0.1.tgz" - integrity sha512-GHyvJrZgILWm1nQlizjipJjbbhyfaupM8gIJtT2B45c6msKpjOVPOoEzWMcm1LCr10cr+yERE/0N+JzZLN4BjA== - dependencies: - "@babel/runtime" "^7.21.5" - tslib "^2.5.0" - mz@^2.7.0: version "2.7.0" resolved "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz" @@ -2955,15 +2843,6 @@ postcss-value-parser@^4.0.0, postcss-value-parser@^4.2.0: resolved "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz" integrity sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ== -postcss@^8.0.0, postcss@^8.0.9, postcss@^8.1.0, postcss@^8.2.14, postcss@^8.4.21, postcss@>=8.0.9, postcss@8.4.23: - version "8.4.23" - resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.23.tgz" - integrity sha512-bQ3qMcpF6A/YjR55xtoTr0jGOlnPOKAIMdOWiv0EIT6HVPEaJiJB4NLljSbiHoC2RX7DN5Uvjtpbg1NPdwv1oA== - dependencies: - nanoid "^3.3.6" - picocolors "^1.0.0" - source-map-js "^1.0.2" - postcss@8.4.14: version "8.4.14" resolved "https://registry.npmjs.org/postcss/-/postcss-8.4.14.tgz" @@ -3092,14 +2971,6 @@ react-markdown@^8.0.7: unist-util-visit "^4.0.0" vfile "^5.0.0" -react-media-recorder-2@^1.6.23: - version "1.6.23" - resolved "https://registry.npmjs.org/react-media-recorder-2/-/react-media-recorder-2-1.6.23.tgz" - integrity sha512-hwCteUOn/3/77qOiRtFRmAtLM97aez+I/KApP7e5BLXbIlN5tGnEy3ZmZHe+ag0iZas9wKMBxCA0qoh5jGGP6g== - dependencies: - extendable-media-recorder "^7.1.9" - extendable-media-recorder-wav-encoder "^7.0.85" - react@18.2.0: version "18.2.0" resolved "https://registry.npmjs.org/react/-/react-18.2.0.tgz" @@ -3130,28 +3001,6 @@ readdirp@~3.6.0: dependencies: picomatch "^2.2.1" -recorder-audio-worklet-processor@^5.0.1: - version "5.0.1" - resolved "https://registry.npmjs.org/recorder-audio-worklet-processor/-/recorder-audio-worklet-processor-5.0.1.tgz" - integrity sha512-7T/SoBTxjDSwSXTcj/4UsG0Yj7XI8/bnCHsp2RyxOftdIbqX56uVu2U+RJ54Fm2i5yZtDs/L7of4mB2Uw6DXyQ== - dependencies: - "@babel/runtime" "^7.21.5" - tslib "^2.5.0" - -recorder-audio-worklet@^6.0.4: - version "6.0.4" - resolved "https://registry.npmjs.org/recorder-audio-worklet/-/recorder-audio-worklet-6.0.4.tgz" - integrity sha512-0VdJy87BY67vcD/maECPIy2D+6cm0UEen0nhsZL5EB4Hsr5LSRnDsbZ1vi/hMTXdOGoiDsxOtLXtavZx9on2FA== - dependencies: - "@babel/runtime" "^7.21.5" - broker-factory "^3.0.77" - fast-unique-numbers "^8.0.1" - recorder-audio-worklet-processor "^5.0.1" - standardized-audio-context "^25.3.46" - subscribable-things "^2.1.15" - tslib "^2.5.0" - worker-factory "^7.0.1" - regenerator-runtime@^0.13.11, regenerator-runtime@^0.13.7: version "0.13.11" resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz" @@ -3256,11 +3105,6 @@ run-parallel@^1.1.9: dependencies: queue-microtask "^1.2.2" -rxjs-interop@^2.0.0: - version "2.0.0" - resolved "https://registry.npmjs.org/rxjs-interop/-/rxjs-interop-2.0.0.tgz" - integrity sha512-ASEq9atUw7lualXB+knvgtvwkCEvGWV2gDD/8qnASzBkzEARZck9JAyxmY8OS6Nc1pCPEgDTKNcx+YqqYfzArw== - sade@^1.7.3: version "1.8.1" resolved "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz" @@ -3390,15 +3234,6 @@ stackblur-canvas@^2.0.0: resolved "https://registry.npmjs.org/stackblur-canvas/-/stackblur-canvas-2.6.0.tgz" integrity sha512-8S1aIA+UoF6erJYnglGPug6MaHYGo1Ot7h5fuXx4fUPvcvQfcdw2o/ppCse63+eZf8PPidSu4v1JnmEVtEDnpg== -standardized-audio-context@^25.3.46: - version "25.3.46" - resolved "https://registry.npmjs.org/standardized-audio-context/-/standardized-audio-context-25.3.46.tgz" - integrity sha512-kI7oM1IrGUawaBgCizRnVuS/+xSwRzwEDSqDkvJASAh+0IwuxUBYJFG4JSuaD6OkLQVg5i8oCf5aLOBX4dfVPw== - dependencies: - "@babel/runtime" "^7.21.5" - automation-events "^6.0.1" - tslib "^2.5.0" - stop-iteration-iterator@^1.0.0: version "1.0.0" resolved "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.0.0.tgz" @@ -3492,15 +3327,6 @@ styled-jsx@5.1.1: dependencies: client-only "0.0.1" -subscribable-things@^2.1.15: - version "2.1.15" - resolved "https://registry.npmjs.org/subscribable-things/-/subscribable-things-2.1.15.tgz" - integrity sha512-JWnQT53i8ODVHbzufipqfVenNRdfTQwGLbEOgc/nxLHgHHTWuQqnGwYoLrFsUM8JKiSI61Qx0OPpMXOqtF86IQ== - dependencies: - "@babel/runtime" "^7.21.5" - rxjs-interop "^2.0.0" - tslib "^2.5.0" - sucrase@^3.29.0: version "3.32.0" resolved "https://registry.npmjs.org/sucrase/-/sucrase-3.32.0.tgz" @@ -3697,7 +3523,7 @@ typed-array-length@^1.0.4: for-each "^0.3.3" is-typed-array "^1.1.9" -"typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta", typescript@>=3.3.1, typescript@5.0.4: +typescript@5.0.4: version "5.0.4" resolved "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz" integrity sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw== @@ -3901,16 +3727,6 @@ word-wrap@^1.2.3: resolved "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.3.tgz" integrity sha512-Hz/mrNwitNRh/HUAtM/VT/5VH+ygD6DV7mYKZAtHOrbs8U7lvPS6xf7EJKMF0uW1KJCl0H701g3ZGus+muE5vQ== -worker-factory@^7.0.1: - version "7.0.1" - resolved "https://registry.npmjs.org/worker-factory/-/worker-factory-7.0.1.tgz" - integrity sha512-niubsebqYimbqaORJxwTvlPn9v3UOqRFTe0pTggGh36fR2GG6J1nchIifLwV7KKExM7HPiamSZZmfjVzpIXMkw== - dependencies: - "@babel/runtime" "^7.21.5" - compilerr "^11.0.1" - fast-unique-numbers "^8.0.1" - tslib "^2.5.0" - wrappy@1: version "1.0.2" resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz" From 706f69e34d557a30d012ddaa619cffb92b3e0981 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:02:07 +0530 Subject: [PATCH 2/4] Fixes --- src/components/chatbar.tsx | 2 +- src/components/{recorder.tsx => recorder.ts} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename src/components/{recorder.tsx => recorder.ts} (100%) diff --git a/src/components/chatbar.tsx b/src/components/chatbar.tsx index 5d85e30e..f65206c3 100644 --- a/src/components/chatbar.tsx +++ b/src/components/chatbar.tsx @@ -20,7 +20,7 @@ export default function ChatBar(props: { const { chat, onChange, onSubmit, errors, loading, onAudio } = props; const [storage, setStorage] = useAtom(storageAtom); - const { status, startRecording, stopRecording, mediaBlobUrl } = useAudioRecorder(onAudio); + const { status, startRecording, stopRecording } = useAudioRecorder(onAudio); const [langDialogOpen, setLangDialogOpen] = useState(false); diff --git a/src/components/recorder.tsx b/src/components/recorder.ts similarity index 100% rename from src/components/recorder.tsx rename to src/components/recorder.ts From 6ff29e61e04df27a1f4f70572d5e274327a58fc8 Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:19:03 +0530 Subject: [PATCH 3/4] Update React and React DOM types to version 18.2.25 to fix chatbot build --- chatbot/package.json | 4 ++-- chatbot/yarn.lock | 27 ++++++++++++++++++--------- package.json | 2 +- yarn.lock | 8 ++++---- 4 files changed, 25 insertions(+), 16 deletions(-) diff --git a/chatbot/package.json b/chatbot/package.json index d31f6780..4919fc76 100644 --- a/chatbot/package.json +++ b/chatbot/package.json @@ -13,8 +13,8 @@ "@rollup/plugin-commonjs": "^25.0.3", "@rollup/plugin-node-resolve": "^15.1.0", "@rollup/plugin-replace": "^5.0.2", - "@types/react": "^16.9.9", - "@types/react-dom": "^16.9.2", + "@types/react": "18.2.25", + "@types/react-dom": "18.0.11", "autoprefixer": "^10.4.14", "babel-plugin-external-helpers": "^6.22.0", "babel-preset-es2015": "^6.24.1", diff --git a/chatbot/yarn.lock b/chatbot/yarn.lock index de8ee4ee..547fc063 100644 --- a/chatbot/yarn.lock +++ b/chatbot/yarn.lock @@ -530,17 +530,26 @@ resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz" integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w== -"@types/react-dom@^16.9.2": - version "16.9.19" - resolved "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.19.tgz" - integrity sha512-xC8D280Bf6p0zguJ8g62jcEOKZiUbx9sIe6O3tT/lKfR87A7A6g65q13z6D5QUMIa/6yFPkNhqjF5z/VVZEYqQ== +"@types/react-dom@18.0.11": + version "18.0.11" + resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.0.11.tgz#321351c1459bc9ca3d216aefc8a167beec334e33" + integrity sha512-O38bPbI2CWtgw/OoQoY+BRelw7uysmXbWvw3nLWO21H1HSh+GOlqPuXshJfjmpNlKiiSDG9cc1JZAaMmVdcTlw== dependencies: - "@types/react" "^16" + "@types/react" "*" -"@types/react@^16", "@types/react@^16.9.9": - version "16.14.43" - resolved "https://registry.npmjs.org/@types/react/-/react-16.14.43.tgz" - integrity sha512-7zdjv7jvoLLQg1tTvpQsm+hyNUMT2mPlNV1+d0I8fbGhkJl82spopMyBlu4wb1dviZAxpGdk5eHu/muacknnfw== +"@types/react@*": + version "18.2.45" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.45.tgz#253f4fac288e7e751ab3dc542000fb687422c15c" + integrity sha512-TtAxCNrlrBp8GoeEp1npd5g+d/OejJHFxS3OWmrPBMFaVQMSN0OFySozJio5BHxTuTeug00AVXVAjfDSfk+lUg== + dependencies: + "@types/prop-types" "*" + "@types/scheduler" "*" + csstype "^3.0.2" + +"@types/react@18.2.25": + version "18.2.25" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.25.tgz#99fa44154132979e870ff409dc5b6e67f06f0199" + integrity sha512-24xqse6+VByVLIr+xWaQ9muX1B4bXJKXBbjszbld/UEDslGLY53+ZucF44HCmLbMPejTzGG9XgR+3m2/Wqu1kw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" diff --git a/package.json b/package.json index 08224a97..dc14aa8f 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "@tanstack/react-query": "^4.29.3", "@tanstack/react-query-devtools": "^4.29.3", "@types/node": "18.16.0", - "@types/react": "18.0.38", + "@types/react": "18.2.25", "@types/react-dom": "18.0.11", "audio-recorder-polyfill": "^0.4.1", "autoprefixer": "10.4.14", diff --git a/yarn.lock b/yarn.lock index 8d980662..929539f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -487,10 +487,10 @@ "@types/scheduler" "*" csstype "^3.0.2" -"@types/react@18.0.38": - version "18.0.38" - resolved "https://registry.yarnpkg.com/@types/react/-/react-18.0.38.tgz#02a23bef8848b360a0d1dceef4432c15c21c600c" - integrity sha512-ExsidLLSzYj4cvaQjGnQCk4HFfVT9+EZ9XZsQ8Hsrcn8QNgXtpZ3m9vSIC2MWtx7jHictK6wYhQgGh6ic58oOw== +"@types/react@18.2.25": + version "18.2.25" + resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.25.tgz#99fa44154132979e870ff409dc5b6e67f06f0199" + integrity sha512-24xqse6+VByVLIr+xWaQ9muX1B4bXJKXBbjszbld/UEDslGLY53+ZucF44HCmLbMPejTzGG9XgR+3m2/Wqu1kw== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" From 01bc2173d4dce2df91551fa0607016af0d42505a Mon Sep 17 00:00:00 2001 From: Ashesh3 <3626859+Ashesh3@users.noreply.github.com> Date: Mon, 18 Dec 2023 18:22:50 +0530 Subject: [PATCH 4/4] Update silent option in next.config.js --- next.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/next.config.js b/next.config.js index 2f86c12f..0332313b 100644 --- a/next.config.js +++ b/next.config.js @@ -21,7 +21,7 @@ module.exports = withSentryConfig( // https://github.com/getsentry/sentry-webpack-plugin#options // Suppresses source map uploading logs during build - silent: false, + silent: true, org: "coronasafe-network", project: "ayushma-nextjs", },