stream-chat-expo 6.0.1 → 6.0.2

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "stream-chat-expo",
3
3
  "description": "The official Expo SDK for Stream Chat, a service for building chat applications",
4
- "version": "6.0.1",
4
+ "version": "6.0.2",
5
5
  "author": {
6
6
  "company": "Stream.io Inc",
7
7
  "name": "Stream.io Inc"
@@ -10,7 +10,7 @@
10
10
  "main": "src/index.js",
11
11
  "types": "types/index.d.ts",
12
12
  "dependencies": {
13
- "stream-chat-react-native-core": "6.0.1"
13
+ "stream-chat-react-native-core": "6.0.2"
14
14
  },
15
15
  "peerDependencies": {
16
16
  "expo": ">=51.0.0",
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ import {
11
11
  getPhotos,
12
12
  iOS14RefreshGallerySelection,
13
13
  oniOS14GalleryLibrarySelectionChange,
14
+ overrideAudioRecordingConfiguration,
14
15
  pickDocument,
15
16
  pickImage,
16
17
  saveFile,
@@ -31,6 +32,7 @@ registerNativeHandlers({
31
32
  getPhotos,
32
33
  iOS14RefreshGallerySelection,
33
34
  oniOS14GalleryLibrarySelectionChange,
35
+ overrideAudioRecordingConfiguration,
34
36
  pickDocument,
35
37
  pickImage,
36
38
  saveFile,
@@ -1,216 +1,13 @@
1
- import { AudioComponent, RecordingObject } from './AudioVideo';
2
-
3
- export enum AndroidOutputFormat {
4
- DEFAULT = 0,
5
- THREE_GPP = 1,
6
- MPEG_4 = 2,
7
- AMR_NB = 3,
8
- AMR_WB = 4,
9
- AAC_ADIF = 5,
10
- AAC_ADTS = 6,
11
- RTP_AVP = 7,
12
- MPEG2TS = 8,
13
- WEBM = 9,
14
- }
15
-
16
- // @docsMissing
17
- export enum AndroidAudioEncoder {
18
- DEFAULT = 0,
19
- AMR_NB = 1,
20
- AMR_WB = 2,
21
- AAC = 3,
22
- HE_AAC = 4,
23
- AAC_ELD = 5,
24
- }
25
-
26
- export enum IOSOutputFormat {
27
- LINEARPCM = 'lpcm',
28
- AC3 = 'ac-3',
29
- '60958AC3' = 'cac3',
30
- APPLEIMA4 = 'ima4',
31
- MPEG4AAC = 'aac ',
32
- MPEG4CELP = 'celp',
33
- MPEG4HVXC = 'hvxc',
34
- MPEG4TWINVQ = 'twvq',
35
- MACE3 = 'MAC3',
36
- MACE6 = 'MAC6',
37
- ULAW = 'ulaw',
38
- ALAW = 'alaw',
39
- QDESIGN = 'QDMC',
40
- QDESIGN2 = 'QDM2',
41
- QUALCOMM = 'Qclp',
42
- MPEGLAYER1 = '.mp1',
43
- MPEGLAYER2 = '.mp2',
44
- MPEGLAYER3 = '.mp3',
45
- APPLELOSSLESS = 'alac',
46
- MPEG4AAC_HE = 'aach',
47
- MPEG4AAC_LD = 'aacl',
48
- MPEG4AAC_ELD = 'aace',
49
- MPEG4AAC_ELD_SBR = 'aacf',
50
- MPEG4AAC_ELD_V2 = 'aacg',
51
- MPEG4AAC_HE_V2 = 'aacp',
52
- MPEG4AAC_SPATIAL = 'aacs',
53
- AMR = 'samr',
54
- AMR_WB = 'sawb',
55
- AUDIBLE = 'AUDB',
56
- ILBC = 'ilbc',
57
- DVIINTELIMA = 0x6d730011,
58
- MICROSOFTGSM = 0x6d730031,
59
- AES3 = 'aes3',
60
- ENHANCEDAC3 = 'ec-3',
61
- }
62
-
63
- export enum IOSAudioQuality {
64
- MIN = 0,
65
- LOW = 0x20,
66
- MEDIUM = 0x40,
67
- HIGH = 0x60,
68
- MAX = 0x7f,
69
- }
1
+ import {
2
+ AndroidAudioEncoder,
3
+ AndroidOutputFormat,
4
+ ExpoAudioRecordingConfiguration as AudioRecordingConfiguration,
5
+ IOSAudioQuality,
6
+ IOSOutputFormat,
7
+ ExpoRecordingOptions as RecordingOptions,
8
+ } from 'stream-chat-react-native-core';
70
9
 
71
- export type RecordingOptionsAndroid = {
72
- /**
73
- * The desired audio encoder. See the [`AndroidAudioEncoder`](#androidaudioencoder) enum for all valid values.
74
- */
75
- audioEncoder: AndroidAudioEncoder | number;
76
- /**
77
- * The desired file extension. Example valid values are `.3gp` and `.m4a`.
78
- * For more information, see the [Android docs](https://developer.android.com/guide/topics/media/media-formats)
79
- * for supported output formats.
80
- */
81
- extension: string;
82
- /**
83
- * The desired file format. See the [`AndroidOutputFormat`](#androidoutputformat) enum for all valid values.
84
- */
85
- outputFormat: AndroidOutputFormat | number;
86
- /**
87
- * The desired bit rate.
88
- *
89
- * Note that `prepareToRecordAsync()` may perform additional checks on the parameter to make sure whether the specified
90
- * bit rate is applicable, and sometimes the passed bitRate will be clipped internally to ensure the audio recording
91
- * can proceed smoothly based on the capabilities of the platform.
92
- *
93
- * @example `128000`
94
- */
95
- bitRate?: number;
96
- /**
97
- * The desired maximum file size in bytes, after which the recording will stop (but `stopAndUnloadAsync()` must still
98
- * be called after this point).
99
- *
100
- * @example `65536`
101
- */
102
- maxFileSize?: number;
103
- /**
104
- * The desired number of channels.
105
- *
106
- * Note that `prepareToRecordAsync()` may perform additional checks on the parameter to make sure whether the specified
107
- * number of audio channels are applicable.
108
- *
109
- * @example `1`, `2`
110
- */
111
- numberOfChannels?: number;
112
- /**
113
- * The desired sample rate.
114
- *
115
- * Note that the sampling rate depends on the format for the audio recording, as well as the capabilities of the platform.
116
- * For instance, the sampling rate supported by AAC audio coding standard ranges from 8 to 96 kHz,
117
- * the sampling rate supported by AMRNB is 8kHz, and the sampling rate supported by AMRWB is 16kHz.
118
- * Please consult with the related audio coding standard for the supported audio sampling rate.
119
- *
120
- * @example 44100
121
- */
122
- sampleRate?: number;
123
- };
124
-
125
- export type RecordingOptionsIOS = {
126
- /**
127
- * The desired audio quality. See the [`IOSAudioQuality`](#iosaudioquality) enum for all valid values.
128
- */
129
- audioQuality: IOSAudioQuality | number;
130
- /**
131
- * The desired bit rate.
132
- *
133
- * @example `128000`
134
- */
135
- bitRate: number;
136
- /**
137
- * The desired file extension.
138
- *
139
- * @example `'.caf'`
140
- */
141
- extension: string;
142
- /**
143
- * The desired number of channels.
144
- *
145
- * @example `1`, `2`
146
- */
147
- numberOfChannels: number;
148
- /**
149
- * The desired sample rate.
150
- *
151
- * @example `44100`
152
- */
153
- sampleRate: number;
154
- /**
155
- * The desired bit depth hint.
156
- *
157
- * @example `16`
158
- */
159
- bitDepthHint?: number;
160
- /**
161
- * The desired bit rate strategy. See the next section for an enumeration of all valid values of `bitRateStrategy`.
162
- */
163
- bitRateStrategy?: number;
164
- /**
165
- * The desired PCM bit depth.
166
- *
167
- * @example `16`
168
- */
169
- linearPCMBitDepth?: number;
170
- /**
171
- * A boolean describing if the PCM data should be formatted in big endian.
172
- */
173
- linearPCMIsBigEndian?: boolean;
174
- /**
175
- * A boolean describing if the PCM data should be encoded in floating point or integral values.
176
- */
177
- linearPCMIsFloat?: boolean;
178
- /**
179
- * The desired file format. See the [`IOSOutputFormat`](#iosoutputformat) enum for all valid values.
180
- */
181
- outputFormat?: string | IOSOutputFormat | number;
182
- };
183
-
184
- // @docsMissing
185
- export type RecordingOptionsWeb = {
186
- bitsPerSecond?: number;
187
- mimeType?: string;
188
- };
189
-
190
- export type RecordingOptions = {
191
- /**
192
- * Recording options for the Android platform.
193
- */
194
- android: RecordingOptionsAndroid;
195
- /**
196
- * Recording options for the iOS platform.
197
- */
198
- ios: RecordingOptionsIOS;
199
- /**
200
- * Recording options for the Web platform.
201
- */
202
- web: RecordingOptionsWeb;
203
- /**
204
- * A boolean that determines whether audio level information will be part of the status object under the "metering" key.
205
- */
206
- isMeteringEnabled?: boolean;
207
- /**
208
- * A boolean that hints to keep the audio active after `prepareToRecordAsync` completes.
209
- * Setting this value can improve the speed at which the recording starts. Only set this value to `true` when you call `startAsync`
210
- * immediately after `prepareToRecordAsync`. This value is automatically set when using `Audio.recording.createAsync()`.
211
- */
212
- keepAudioActiveHint?: boolean;
213
- };
10
+ import { AudioComponent, RecordingObject } from './AudioVideo';
214
11
 
215
12
  const sleep = (ms: number) =>
216
13
  new Promise<void>((resolve) => {
@@ -221,6 +18,29 @@ const sleep = (ms: number) =>
221
18
 
222
19
  class _Audio {
223
20
  recording: typeof RecordingObject | null = null;
21
+ audioRecordingConfiguration: AudioRecordingConfiguration = {
22
+ mode: {
23
+ allowsRecordingIOS: true,
24
+ playsInSilentModeIOS: true,
25
+ },
26
+ options: {
27
+ android: {
28
+ audioEncoder: AndroidAudioEncoder.AAC,
29
+ extension: '.aac',
30
+ outputFormat: AndroidOutputFormat.AAC_ADTS,
31
+ },
32
+ ios: {
33
+ audioQuality: IOSAudioQuality.HIGH,
34
+ bitRate: 128000,
35
+ extension: '.aac',
36
+ numberOfChannels: 2,
37
+ outputFormat: IOSOutputFormat.MPEG4AAC,
38
+ sampleRate: 44100,
39
+ },
40
+ isMeteringEnabled: true,
41
+ web: {},
42
+ },
43
+ };
224
44
 
225
45
  startRecording = async (recordingOptions: RecordingOptions, onRecordingStatusUpdate) => {
226
46
  try {
@@ -242,28 +62,10 @@ class _Audio {
242
62
  if (!permissionsGranted) {
243
63
  throw new Error('Missing audio recording permission.');
244
64
  }
245
- await AudioComponent.setAudioModeAsync({
246
- allowsRecordingIOS: true,
247
- playsInSilentModeIOS: true,
248
- });
249
- const androidOptions = {
250
- audioEncoder: AndroidAudioEncoder.AAC,
251
- extension: '.aac',
252
- outputFormat: AndroidOutputFormat.AAC_ADTS,
253
- };
254
- const iosOptions = {
255
- audioQuality: IOSAudioQuality.HIGH,
256
- bitRate: 128000,
257
- extension: '.aac',
258
- numberOfChannels: 2,
259
- outputFormat: IOSOutputFormat.MPEG4AAC,
260
- sampleRate: 44100,
261
- };
65
+ await AudioComponent.setAudioModeAsync(this.audioRecordingConfiguration.mode);
262
66
  const options = {
263
67
  ...recordingOptions,
264
- android: androidOptions,
265
- ios: iosOptions,
266
- web: {},
68
+ ...this.audioRecordingConfiguration.options,
267
69
  };
268
70
 
269
71
  // This is a band-aid fix for this (still unresolved) issue on Expo's side:
@@ -303,4 +105,8 @@ class _Audio {
303
105
  };
304
106
  }
305
107
 
108
+ export const overrideAudioRecordingConfiguration = (
109
+ audioRecordingConfiguration: AudioRecordingConfiguration,
110
+ ) => audioRecordingConfiguration;
111
+
306
112
  export const Audio = AudioComponent ? new _Audio() : null;