@exode-team/react-recorder 1.1.3 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -12,9 +12,8 @@ export { useVoiceRecorder } from './hooks/useVoiceRecorder';
12
12
  export { useVoiceMessagePlayer } from './hooks/useVoiceMessagePlayer';
13
13
  export { useRecorderVisualization } from './hooks/useRecorderVisualization';
14
14
  export { useRecordingTiming } from './hooks/useRecordingTiming';
15
- export type { StorageSpace, StorageFileEntity, UploadStrategy } from './types/upload';
15
+ export type { StorageFileEntity, UploadStrategy } from './types/upload';
16
16
  export type { UseVoiceRecorderOptions, UseVoiceRecorderResult, UseVoiceMessagePlayerOptions, UseVoiceMessagePlayerResult, } from './types/recorder';
17
- export { StorageSpaceEnum } from './types/upload';
18
17
  export { AUDIO_LEVEL_BARS } from './constants';
19
18
  export { clampValue } from './utils/math';
20
19
  export { formatTime } from './utils/format';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oDAAoD,CAAC;AACxF,YAAY,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAChG,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAGtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,YAAY,EAAE,YAAY,EAAE,iBAAiB,EAAE,cAAc,EAA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EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -178,7 +178,11 @@ const decodeAudioLevels = async (blob, barCount = AUDIO_LEVEL_BARS) => {
178
178
  * @author: exode <hello@exode.ru>
179
179
  */
180
180
  const fetchAudioBlob = async (url, signal) => {
181
- const response = await fetch(url, { signal });
181
+ const response = await fetch(url, {
182
+ signal,
183
+ mode: 'cors',
184
+ credentials: 'omit',
185
+ });
182
186
  return response.blob();
183
187
  };
184
188
 
@@ -585,7 +589,7 @@ const useRecorderVisualization = () => {
585
589
  * @author: exode <hello@exode.ru>
586
590
  */
587
591
  const useRecordingSender = (options) => {
588
- const { space, uploader, fileName, mimeType, uploadId, audioBlob, onUploaded, onRecordingError, deleteRecording, autoResetAfterUpload, } = options;
592
+ const { uploader, fileName, mimeType, uploadId, audioBlob, onUploaded, onRecordingError, deleteRecording, autoResetAfterUpload, } = options;
589
593
  const sendRecording = useCallback(async () => {
590
594
  if (!audioBlob) {
591
595
  const error = new Error('Voice recording is not available');
@@ -601,7 +605,7 @@ const useRecordingSender = (options) => {
601
605
  const file = new File([audioBlob], fileName, {
602
606
  type: audioBlob.type || mimeType,
603
607
  });
604
- const uploaded = await uploader(file, { space, uploadId });
608
+ const uploaded = await uploader(file, { uploadId });
605
609
  await onUploaded(uploaded);
606
610
  if (autoResetAfterUpload) {
607
611
  deleteRecording();
@@ -612,7 +616,6 @@ const useRecordingSender = (options) => {
612
616
  throw error;
613
617
  }
614
618
  }, [
615
- space,
616
619
  uploadId,
617
620
  uploader,
618
621
  fileName,
@@ -632,7 +635,7 @@ const useRecordingSender = (options) => {
632
635
  * @author: exode <hello@exode.ru>
633
636
  */
634
637
  function useVoiceRecorder(props) {
635
- const { space, uploadId, uploader, onUploaded, onRecordingStop, onRecordingStart, onRecordingError, onRecordingDelete, onPermissionDenied, fileName = 'record.webm', mimeType = 'audio/webm', autoResetAfterUpload = true, } = props;
638
+ const { uploadId, uploader, onUploaded, onRecordingStop, onRecordingStart, onRecordingError, onRecordingDelete, onPermissionDenied, fileName = 'record.webm', mimeType = 'audio/webm', autoResetAfterUpload = true, } = props;
636
639
  const [audioBlob, setAudioBlob] = useState(null);
637
640
  const { audioURL, isPlaying, mountBlob, playbackTime, stopPlayback, resetPlayback, togglePlayback: _togglePlayback, playbackDuration, } = useAudioPlayback();
638
641
  const { audioLevels, previewLevels, resetAudioLevels, stopVisualization, resetPreviewLevels, resumeVisualization, cleanupVisualization, generatePreviewLevels, initializeVisualization, } = useRecorderVisualization();
@@ -662,7 +665,6 @@ function useVoiceRecorder(props) {
662
665
  audioBlob,
663
666
  fileName,
664
667
  mimeType,
665
- space,
666
668
  uploadId,
667
669
  uploader,
668
670
  autoResetAfterUpload,
@@ -1319,7 +1321,7 @@ const CircleButton = styled.button `
1319
1321
  cursor: pointer;
1320
1322
  transition: transform 160ms ease, color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
1321
1323
  flex-shrink: 0;
1322
- background: ${({ $variant }) => ($variant === 'play' ? 'var(--background_content, #ffffff)' : 'var(--background_content, #ffffff)')};
1324
+ background: var(--background_content, #ffffff);
1323
1325
 
1324
1326
  color: ${({ $variant }) => {
1325
1327
  if ($variant === 'record') {
@@ -1536,24 +1538,12 @@ const mergeMessages = (custom) => {
1536
1538
  };
1537
1539
  };
1538
1540
 
1539
- /**
1540
- * Upload types
1541
- *
1542
- * @author: exode <hello@exode.ru>
1543
- */
1544
- const StorageSpaceEnum = {
1545
- User: 'user',
1546
- Shared: 'shared',
1547
- System: 'system',
1548
- };
1549
-
1550
1541
  const AudioRecorder = (props) => {
1551
- const { space, fileName, uploadId, mimeType, className, uploader, onUploaded, onUploadError, onRecordingStop, onRecordingError, onRecordingStart, onRecordingDelete, onPermissionDenied, autoResetAfterUpload, messages: customMessages, } = props;
1542
+ const { fileName, uploadId, mimeType, className, uploader, onUploaded, onUploadError, onRecordingStop, onRecordingError, onRecordingStart, onRecordingDelete, onPermissionDenied, autoResetAfterUpload, messages: customMessages, } = props;
1552
1543
  const messages = useMemo(() => mergeMessages(customMessages), [customMessages]);
1553
1544
  const [resolvedUploadId] = useState(() => uploadId !== null && uploadId !== void 0 ? uploadId : (typeof crypto !== 'undefined' && 'randomUUID' in crypto
1554
1545
  ? crypto.randomUUID()
1555
1546
  : `upload-${Date.now()}`));
1556
- const resolvedSpace = space !== null && space !== void 0 ? space : StorageSpaceEnum.User;
1557
1547
  const handleRecorderError = useCallback((error) => {
1558
1548
  onRecordingError === null || onRecordingError === void 0 ? void 0 : onRecordingError(error);
1559
1549
  onUploadError === null || onUploadError === void 0 ? void 0 : onUploadError(error);
@@ -1571,7 +1561,6 @@ const AudioRecorder = (props) => {
1571
1561
  onRecordingDelete,
1572
1562
  onPermissionDenied,
1573
1563
  autoResetAfterUpload,
1574
- space: resolvedSpace,
1575
1564
  uploader,
1576
1565
  uploadId: resolvedUploadId,
1577
1566
  onRecordingError: handleRecorderError,
@@ -1594,7 +1583,7 @@ const AudioRecorder = (props) => {
1594
1583
  * @author: exode <hello@exode.ru>
1595
1584
  */
1596
1585
  const useVoiceRecorderInput = (options) => {
1597
- const { onSend, onError, onCancel, uploader, onUploaded, onPermissionDenied, autoStart = true, space = StorageSpaceEnum.User, mimeType = 'audio/webm', fileName = 'voice-message.webm', } = options;
1586
+ const { onSend, onError, onCancel, uploader, onUploaded, onPermissionDenied, autoStart = true, mimeType = 'audio/webm', fileName = 'voice-message.webm', } = options;
1598
1587
  const [isSending, setIsSending] = useState(false);
1599
1588
  const [timelineLevels, setTimelineLevels] = useState([]);
1600
1589
  const audioBlobRef = useRef(null);
@@ -1615,7 +1604,6 @@ const useVoiceRecorderInput = (options) => {
1615
1604
  }
1616
1605
  }, []);
1617
1606
  const recorder = useVoiceRecorder({
1618
- space,
1619
1607
  fileName,
1620
1608
  mimeType,
1621
1609
  uploadId,
@@ -1942,14 +1930,10 @@ const MicIndicator = styled.button `
1942
1930
  border: 0;
1943
1931
  flex-shrink: 0;
1944
1932
  cursor: pointer;
1945
- background: color-mix(in srgb, var(--exode_red, #ed1c24) 14%, transparent);
1946
- color: var(--exode_red, #ed1c24);
1933
+ background: var(--background_content, #ffffff);
1934
+ color: color-mix(in srgb, var(--accent, #3f8ae0) 86%, white 14%);
1947
1935
  transition: background-color 140ms ease, transform 120ms ease;
1948
1936
 
1949
- &:hover {
1950
- background: color-mix(in srgb, var(--exode_red, #ed1c24) 22%, transparent);
1951
- }
1952
-
1953
1937
  &:active {
1954
1938
  transform: scale(0.94);
1955
1939
  }
@@ -2312,5 +2296,5 @@ class VoiceBlobCacheClass {
2312
2296
  }
2313
2297
  const VoiceBlobCache = new VoiceBlobCacheClass();
2314
2298
 
2315
- export { AUDIO_LEVEL_BARS, AudioRecorder, StorageSpaceEnum, VoiceBlobCache, VoiceMessagePlayer, VoicePlaybackChain, VoiceRecorderInput, WaveformBars, clampValue, formatTime, useRecorderVisualization, useRecordingTiming, useVoiceMessagePlayer, useVoiceRecorder };
2299
+ export { AUDIO_LEVEL_BARS, AudioRecorder, VoiceBlobCache, VoiceMessagePlayer, VoicePlaybackChain, VoiceRecorderInput, WaveformBars, clampValue, formatTime, useRecorderVisualization, useRecordingTiming, useVoiceMessagePlayer, useVoiceRecorder };
2316
2300
  //# sourceMappingURL=index.js.map