@sendbird/uikit-react-native 3.10.3 → 3.11.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 +9 -7
- package/lib/commonjs/components/ChannelInput/VoiceMessageInput.js +1 -1
- package/lib/commonjs/components/ChannelInput/VoiceMessageInput.js.map +1 -1
- package/lib/commonjs/components/ChannelInput/index.js +2 -25
- package/lib/commonjs/components/ChannelInput/index.js.map +1 -1
- package/lib/commonjs/hooks/useVoiceMessageInput.js +10 -2
- package/lib/commonjs/hooks/useVoiceMessageInput.js.map +1 -1
- package/lib/commonjs/platform/createFileService.native.js +1 -1
- package/lib/commonjs/platform/createFileService.native.js.map +1 -1
- package/lib/commonjs/platform/createMediaService.expo.js +83 -12
- package/lib/commonjs/platform/createMediaService.expo.js.map +1 -1
- package/lib/commonjs/platform/createPlayerService.expo.js +214 -113
- package/lib/commonjs/platform/createPlayerService.expo.js.map +1 -1
- package/lib/commonjs/platform/createPlayerService.native.js +191 -114
- package/lib/commonjs/platform/createPlayerService.native.js.map +1 -1
- package/lib/commonjs/platform/createRecorderService.expo.js +248 -127
- package/lib/commonjs/platform/createRecorderService.expo.js.map +1 -1
- package/lib/commonjs/platform/createRecorderService.native.js +212 -129
- package/lib/commonjs/platform/createRecorderService.native.js.map +1 -1
- package/lib/commonjs/platform/types.js.map +1 -1
- package/lib/commonjs/utils/expoBackwardUtils.js +23 -0
- package/lib/commonjs/utils/expoBackwardUtils.js.map +1 -1
- package/lib/commonjs/utils/expoPermissionGranted.js.map +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/commonjs/version.js.map +1 -1
- package/lib/module/components/ChannelInput/VoiceMessageInput.js +1 -1
- package/lib/module/components/ChannelInput/VoiceMessageInput.js.map +1 -1
- package/lib/module/components/ChannelInput/index.js +3 -26
- package/lib/module/components/ChannelInput/index.js.map +1 -1
- package/lib/module/hooks/useVoiceMessageInput.js +10 -2
- package/lib/module/hooks/useVoiceMessageInput.js.map +1 -1
- package/lib/module/platform/createFileService.native.js +1 -1
- package/lib/module/platform/createFileService.native.js.map +1 -1
- package/lib/module/platform/createMediaService.expo.js +82 -13
- package/lib/module/platform/createMediaService.expo.js.map +1 -1
- package/lib/module/platform/createPlayerService.expo.js +214 -113
- package/lib/module/platform/createPlayerService.expo.js.map +1 -1
- package/lib/module/platform/createPlayerService.native.js +191 -114
- package/lib/module/platform/createPlayerService.native.js.map +1 -1
- package/lib/module/platform/createRecorderService.expo.js +249 -128
- package/lib/module/platform/createRecorderService.expo.js.map +1 -1
- package/lib/module/platform/createRecorderService.native.js +212 -129
- package/lib/module/platform/createRecorderService.native.js.map +1 -1
- package/lib/module/platform/types.js.map +1 -1
- package/lib/module/utils/expoBackwardUtils.js +23 -0
- package/lib/module/utils/expoBackwardUtils.js.map +1 -1
- package/lib/module/utils/expoPermissionGranted.js.map +1 -1
- package/lib/module/version.js +1 -1
- package/lib/module/version.js.map +1 -1
- package/lib/typescript/src/containers/SendbirdUIKitContainer.d.ts +1 -1
- package/lib/typescript/src/platform/createMediaService.expo.d.ts +2 -2
- package/lib/typescript/src/platform/createPlayerService.expo.d.ts +2 -2
- package/lib/typescript/src/platform/createPlayerService.native.d.ts +5 -3
- package/lib/typescript/src/platform/createRecorderService.expo.d.ts +2 -2
- package/lib/typescript/src/platform/createRecorderService.native.d.ts +5 -3
- package/lib/typescript/src/platform/types.d.ts +4 -0
- package/lib/typescript/src/utils/expoBackwardUtils.d.ts +10 -0
- package/lib/typescript/src/utils/expoPermissionGranted.d.ts +1 -1
- package/lib/typescript/src/version.d.ts +1 -1
- package/package.json +29 -5
- package/src/components/ChannelInput/VoiceMessageInput.tsx +1 -1
- package/src/components/ChannelInput/index.tsx +6 -36
- package/src/hooks/useVoiceMessageInput.ts +7 -2
- package/src/platform/createFileService.native.ts +1 -1
- package/src/platform/createMediaService.expo.tsx +87 -9
- package/src/platform/createPlayerService.expo.tsx +242 -109
- package/src/platform/createPlayerService.native.tsx +237 -113
- package/src/platform/createRecorderService.expo.tsx +268 -107
- package/src/platform/createRecorderService.native.tsx +240 -118
- package/src/platform/types.ts +5 -0
- package/src/utils/expoBackwardUtils.ts +29 -0
- package/src/utils/expoPermissionGranted.ts +3 -1
- package/src/version.ts +1 -1
|
@@ -5,150 +5,233 @@ import { Platform } from 'react-native';
|
|
|
5
5
|
import { Logger, matchesOneOf, sleep } from '@sendbird/uikit-utils';
|
|
6
6
|
import VoiceMessageConfig from '../libs/VoiceMessageConfig';
|
|
7
7
|
import nativePermissionGranted from '../utils/nativePermissionGranted';
|
|
8
|
-
|
|
9
|
-
audioRecorderModule
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
8
|
+
class AudioRecorderPlayerAdapter {
|
|
9
|
+
constructor(audioRecorderModule) {
|
|
10
|
+
_defineProperty(this, "module", void 0);
|
|
11
|
+
_defineProperty(this, "audioOptions", void 0);
|
|
12
|
+
this.module = new audioRecorderModule.default();
|
|
13
|
+
this.audioOptions = Platform.select({
|
|
14
|
+
android: {
|
|
15
|
+
AudioEncodingBitRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,
|
|
16
|
+
AudioChannelsAndroid: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,
|
|
17
|
+
AudioSamplingRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
18
|
+
AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,
|
|
19
|
+
OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,
|
|
20
|
+
AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION
|
|
21
|
+
},
|
|
22
|
+
ios: {
|
|
23
|
+
AVEncoderBitRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,
|
|
24
|
+
AVNumberOfChannelsKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,
|
|
25
|
+
AVSampleRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
26
|
+
AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4,
|
|
27
|
+
// same with aac
|
|
28
|
+
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
29
|
+
},
|
|
30
|
+
default: {}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
async setSubscriptionDuration(duration) {
|
|
34
|
+
await this.module.setSubscriptionDuration(duration);
|
|
35
|
+
}
|
|
36
|
+
addRecordBackListener(callback) {
|
|
37
|
+
this.module.addRecordBackListener(callback);
|
|
38
|
+
}
|
|
39
|
+
convertRecordPath(uri) {
|
|
40
|
+
return Platform.OS === 'ios' ? uri.split('/').pop() || uri : uri;
|
|
41
|
+
}
|
|
42
|
+
async startRecorder(uri) {
|
|
43
|
+
await this.module.startRecorder(uri, this.audioOptions);
|
|
44
|
+
}
|
|
45
|
+
async stopRecorder() {
|
|
46
|
+
await this.module.stopRecorder();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
class NitroSoundOrLegacyV4Adapter {
|
|
50
|
+
constructor(audioRecorderModule) {
|
|
51
|
+
_defineProperty(this, "module", void 0);
|
|
52
|
+
_defineProperty(this, "audioOptions", void 0);
|
|
53
|
+
this.module = audioRecorderModule.default;
|
|
54
|
+
this.audioOptions = Platform.select({
|
|
55
|
+
android: {
|
|
56
|
+
AudioEncodingBitRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,
|
|
57
|
+
AudioChannelsAndroid: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,
|
|
58
|
+
AudioSamplingRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
59
|
+
AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,
|
|
60
|
+
OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,
|
|
61
|
+
AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION
|
|
62
|
+
},
|
|
63
|
+
ios: {
|
|
64
|
+
AVEncoderBitRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,
|
|
65
|
+
AVNumberOfChannelsKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,
|
|
66
|
+
AVSampleRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
67
|
+
AVFormatIDKeyIOS: 'mp4',
|
|
68
|
+
// same with aac
|
|
69
|
+
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
70
|
+
},
|
|
71
|
+
default: {}
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
setSubscriptionDuration(duration) {
|
|
75
|
+
try {
|
|
76
|
+
this.module.setSubscriptionDuration(duration);
|
|
77
|
+
} catch (error) {
|
|
78
|
+
Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
addRecordBackListener(callback) {
|
|
82
|
+
this.module.addRecordBackListener(callback);
|
|
83
|
+
}
|
|
84
|
+
convertRecordPath(uri) {
|
|
85
|
+
return uri;
|
|
86
|
+
}
|
|
87
|
+
async startRecorder(uri) {
|
|
88
|
+
await this.module.startRecorder(uri, this.audioOptions);
|
|
89
|
+
}
|
|
90
|
+
async stopRecorder() {
|
|
91
|
+
await this.module.stopRecorder();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class VoiceRecorder {
|
|
95
|
+
constructor(adapter, permissionModule) {
|
|
96
|
+
this.adapter = adapter;
|
|
97
|
+
this.permissionModule = permissionModule;
|
|
98
|
+
_defineProperty(this, "uri", undefined);
|
|
99
|
+
_defineProperty(this, "state", 'idle');
|
|
100
|
+
_defineProperty(this, "options", {
|
|
101
|
+
minDuration: VoiceMessageConfig.DEFAULT.RECORDER.MIN_DURATION,
|
|
102
|
+
maxDuration: VoiceMessageConfig.DEFAULT.RECORDER.MAX_DURATION,
|
|
103
|
+
extension: VoiceMessageConfig.DEFAULT.RECORDER.EXTENSION
|
|
104
|
+
});
|
|
105
|
+
_defineProperty(this, "_recordStartedAt", 0);
|
|
106
|
+
_defineProperty(this, "_stopping", false);
|
|
107
|
+
_defineProperty(this, "recordingSubscribers", new Set());
|
|
108
|
+
_defineProperty(this, "stateSubscribers", new Set());
|
|
109
|
+
_defineProperty(this, "setState", state => {
|
|
110
|
+
this.state = state;
|
|
111
|
+
this.stateSubscribers.forEach(callback => {
|
|
112
|
+
callback(state);
|
|
36
113
|
});
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
ios:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
AVSampleRateKeyIOS: this.audioSettings.sampleRate,
|
|
50
|
-
AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4,
|
|
51
|
-
// same with aac
|
|
52
|
-
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
53
|
-
},
|
|
54
|
-
default: {}
|
|
55
|
-
}));
|
|
56
|
-
_defineProperty(this, "setState", state => {
|
|
57
|
-
this.state = state;
|
|
58
|
-
this.stateSubscribers.forEach(callback => {
|
|
59
|
-
callback(state);
|
|
60
|
-
});
|
|
114
|
+
});
|
|
115
|
+
_defineProperty(this, "getRecorderStopSafeBuffer", () => {
|
|
116
|
+
const minWaitingTime = 500;
|
|
117
|
+
const elapsedTime = Date.now() - this._recordStartedAt;
|
|
118
|
+
if (elapsedTime > minWaitingTime) return 0;else return minWaitingTime - elapsedTime;
|
|
119
|
+
});
|
|
120
|
+
_defineProperty(this, "requestPermission", async () => {
|
|
121
|
+
const permission = Platform.select({
|
|
122
|
+
android: [this.permissionModule.PERMISSIONS.ANDROID.RECORD_AUDIO],
|
|
123
|
+
ios: [this.permissionModule.PERMISSIONS.IOS.MICROPHONE],
|
|
124
|
+
windows: [this.permissionModule.PERMISSIONS.WINDOWS.MICROPHONE],
|
|
125
|
+
default: undefined
|
|
61
126
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
if (Platform.OS === 'android' && Platform.Version <= 28) {
|
|
70
|
-
permission === null || permission === void 0 || permission.push(permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
|
|
71
|
-
}
|
|
72
|
-
if (permission) {
|
|
73
|
-
const status = await permissionModule.checkMultiple(permission);
|
|
74
|
-
if (nativePermissionGranted(status)) {
|
|
75
|
-
return true;
|
|
76
|
-
} else {
|
|
77
|
-
const status = await permissionModule.requestMultiple(permission);
|
|
78
|
-
return nativePermissionGranted(status);
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
127
|
+
if (Platform.OS === 'android' && Platform.Version <= 28) {
|
|
128
|
+
permission === null || permission === void 0 || permission.push(this.permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
|
|
129
|
+
}
|
|
130
|
+
if (permission) {
|
|
131
|
+
const status = await this.permissionModule.checkMultiple(permission);
|
|
132
|
+
if (nativePermissionGranted(status)) {
|
|
81
133
|
return true;
|
|
134
|
+
} else {
|
|
135
|
+
const status = await this.permissionModule.requestMultiple(permission);
|
|
136
|
+
return nativePermissionGranted(status);
|
|
82
137
|
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
this.uri = uri;
|
|
107
|
-
this.setState('recording');
|
|
108
|
-
} catch (e) {
|
|
109
|
-
this.setState('idle');
|
|
110
|
-
throw e;
|
|
138
|
+
} else {
|
|
139
|
+
return true;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
_defineProperty(this, "addRecordingListener", callback => {
|
|
143
|
+
this.recordingSubscribers.add(callback);
|
|
144
|
+
return () => {
|
|
145
|
+
this.recordingSubscribers.delete(callback);
|
|
146
|
+
};
|
|
147
|
+
});
|
|
148
|
+
_defineProperty(this, "addStateListener", callback => {
|
|
149
|
+
this.stateSubscribers.add(callback);
|
|
150
|
+
return () => {
|
|
151
|
+
this.stateSubscribers.delete(callback);
|
|
152
|
+
};
|
|
153
|
+
});
|
|
154
|
+
_defineProperty(this, "record", async uri => {
|
|
155
|
+
if (matchesOneOf(this.state, ['idle', 'completed'])) {
|
|
156
|
+
try {
|
|
157
|
+
this.setState('preparing');
|
|
158
|
+
await this.adapter.startRecorder(uri);
|
|
159
|
+
if (Platform.OS === 'android') {
|
|
160
|
+
this._recordStartedAt = Date.now();
|
|
111
161
|
}
|
|
162
|
+
this.uri = uri;
|
|
163
|
+
this.setState('recording');
|
|
164
|
+
} catch (e) {
|
|
165
|
+
this.setState('idle');
|
|
166
|
+
throw e;
|
|
112
167
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
_defineProperty(this, "stop", async () => {
|
|
171
|
+
if (matchesOneOf(this.state, ['recording']) && !this._stopping) {
|
|
172
|
+
this._stopping = true;
|
|
173
|
+
try {
|
|
116
174
|
if (Platform.OS === 'android') {
|
|
117
|
-
const buffer = this.
|
|
175
|
+
const buffer = this.getRecorderStopSafeBuffer();
|
|
118
176
|
if (buffer > 0) await sleep(buffer);
|
|
119
177
|
}
|
|
120
|
-
await
|
|
178
|
+
await this.adapter.stopRecorder();
|
|
121
179
|
this.setState('completed');
|
|
180
|
+
} catch (error) {
|
|
181
|
+
Logger.error('[RecorderService.Native] Failed to stop recorder', error);
|
|
182
|
+
throw error;
|
|
183
|
+
} finally {
|
|
184
|
+
this._stopping = false;
|
|
122
185
|
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
_defineProperty(this, "reset", async () => {
|
|
189
|
+
await this.stop();
|
|
190
|
+
this.uri = undefined;
|
|
191
|
+
this.recordingSubscribers.clear();
|
|
192
|
+
this.setState('idle');
|
|
193
|
+
});
|
|
194
|
+
_defineProperty(this, "convertRecordPath", uri => {
|
|
195
|
+
return this.adapter.convertRecordPath(uri);
|
|
196
|
+
});
|
|
197
|
+
this.initialize();
|
|
198
|
+
}
|
|
199
|
+
initialize() {
|
|
200
|
+
const setDurationResult = this.adapter.setSubscriptionDuration(0.1);
|
|
201
|
+
if (setDurationResult instanceof Promise) {
|
|
202
|
+
setDurationResult.catch(error => {
|
|
131
203
|
Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);
|
|
132
204
|
});
|
|
133
|
-
module.addRecordBackListener(data => {
|
|
134
|
-
const completed = data.currentPosition >= this.options.maxDuration;
|
|
135
|
-
if (completed) {
|
|
136
|
-
this.stop().catch(error => {
|
|
137
|
-
Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
if (this.state === 'recording') {
|
|
141
|
-
this.recordingSubscribers.forEach(callback => {
|
|
142
|
-
callback({
|
|
143
|
-
currentTime: data.currentPosition,
|
|
144
|
-
completed
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
205
|
}
|
|
206
|
+
this.adapter.addRecordBackListener(data => {
|
|
207
|
+
const completed = data.currentPosition >= this.options.maxDuration;
|
|
208
|
+
if (completed) {
|
|
209
|
+
this.stop().catch(error => {
|
|
210
|
+
Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
if (this.state === 'recording') {
|
|
214
|
+
this.recordingSubscribers.forEach(callback => {
|
|
215
|
+
callback({
|
|
216
|
+
currentTime: data.currentPosition,
|
|
217
|
+
completed
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
});
|
|
150
222
|
}
|
|
151
|
-
|
|
223
|
+
}
|
|
224
|
+
const createNativeRecorderService = modules => {
|
|
225
|
+
const adapter = isNitroSoundOrLegacyV4Module(modules.audioRecorderModule) ? new NitroSoundOrLegacyV4Adapter(modules.audioRecorderModule) : new AudioRecorderPlayerAdapter(modules.audioRecorderModule);
|
|
226
|
+
return new VoiceRecorder(adapter, modules.permissionModule);
|
|
152
227
|
};
|
|
228
|
+
function isNitroSoundOrLegacyV4Module(module) {
|
|
229
|
+
const isNitroSound = 'createSound' in module && typeof module.createSound === 'function';
|
|
230
|
+
const isLegacyV4 = 'default' in module && 'getHybridObject' in module.default && typeof module.default.getHybridObject === 'function';
|
|
231
|
+
if (isLegacyV4) {
|
|
232
|
+
Logger.warn('react-native-audio-recorder-player is deprecated. Please use react-native-nitro-sound instead.');
|
|
233
|
+
}
|
|
234
|
+
return isNitroSound || isLegacyV4;
|
|
235
|
+
}
|
|
153
236
|
export default createNativeRecorderService;
|
|
154
237
|
//# sourceMappingURL=createRecorderService.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","Logger","matchesOneOf","sleep","VoiceMessageConfig","nativePermissionGranted","createNativeRecorderService","audioRecorderModule","permissionModule","module","default","VoiceRecorder","constructor","_defineProperty","undefined","minDuration","DEFAULT","RECORDER","MIN_DURATION","maxDuration","MAX_DURATION","extension","EXTENSION","minWaitingTime","elapsedTime","Date","now","_recordStartedAt","Set","sampleRate","SAMPLE_RATE","bitRate","BIT_RATE","audioChannels","CHANNELS","select","android","AudioEncodingBitRateAndroid","audioSettings","AudioChannelsAndroid","AudioSamplingRateAndroid","AudioEncoderAndroid","AudioEncoderAndroidType","AAC","OutputFormatAndroid","OutputFormatAndroidType","MPEG_4","AudioSourceAndroid","AudioSourceAndroidType","VOICE_RECOGNITION","ios","AVEncoderBitRateKeyIOS","AVNumberOfChannelsKeyIOS","AVSampleRateKeyIOS","AVFormatIDKeyIOS","AVEncodingOption","mp4","AVEncoderAudioQualityKeyIOS","AVEncoderAudioQualityIOSType","high","state","stateSubscribers","forEach","callback","permission","PERMISSIONS","ANDROID","RECORD_AUDIO","IOS","MICROPHONE","windows","WINDOWS","OS","Version","push","WRITE_EXTERNAL_STORAGE","status","checkMultiple","requestMultiple","recordingSubscribers","add","delete","uri","setState","startRecorder","audioOptions","e","buffer","_getRecorderStopSafeBuffer","stopRecorder","stop","clear","setSubscriptionDuration","catch","error","warn","addRecordBackListener","data","completed","currentPosition","options","currentTime"],"sources":["createRecorderService.native.tsx"],"sourcesContent":["import { Platform } from 'react-native';\nimport * as RNAudioRecorder from 'react-native-audio-recorder-player';\nimport * as Permissions from 'react-native-permissions';\nimport { Permission } from 'react-native-permissions/src/types';\n\nimport { Logger, matchesOneOf, sleep } from '@sendbird/uikit-utils';\n\nimport VoiceMessageConfig from '../libs/VoiceMessageConfig';\nimport nativePermissionGranted from '../utils/nativePermissionGranted';\nimport type { RecorderServiceInterface, Unsubscribe } from './types';\n\ntype RecordingListener = Parameters<RecorderServiceInterface['addRecordingListener']>[number];\ntype StateListener = Parameters<RecorderServiceInterface['addStateListener']>[number];\ntype Modules = {\n audioRecorderModule: typeof RNAudioRecorder;\n permissionModule: typeof Permissions;\n};\nconst createNativeRecorderService = ({ audioRecorderModule, permissionModule }: Modules): RecorderServiceInterface => {\n const module = new audioRecorderModule.default();\n\n class VoiceRecorder implements RecorderServiceInterface {\n public uri: RecorderServiceInterface['uri'] = undefined;\n public state: RecorderServiceInterface['state'] = 'idle';\n public options: RecorderServiceInterface['options'] = {\n minDuration: VoiceMessageConfig.DEFAULT.RECORDER.MIN_DURATION,\n maxDuration: VoiceMessageConfig.DEFAULT.RECORDER.MAX_DURATION,\n extension: VoiceMessageConfig.DEFAULT.RECORDER.EXTENSION,\n };\n\n // NOTE: In Android, even when startRecorder() is awaited, if stop() is executed immediately afterward, an error occurs\n private _recordStartedAt = 0;\n private _getRecorderStopSafeBuffer = () => {\n const minWaitingTime = 500;\n const elapsedTime = Date.now() - this._recordStartedAt;\n if (elapsedTime > minWaitingTime) return 0;\n else return minWaitingTime - elapsedTime;\n };\n\n private readonly recordingSubscribers = new Set<RecordingListener>();\n private readonly stateSubscribers = new Set<StateListener>();\n private readonly audioSettings = {\n sampleRate: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n bitRate: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n audioChannels: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n // encoding: mpeg4_aac\n };\n private readonly audioOptions = Platform.select({\n android: {\n AudioEncodingBitRateAndroid: this.audioSettings.bitRate,\n AudioChannelsAndroid: this.audioSettings.audioChannels,\n AudioSamplingRateAndroid: this.audioSettings.sampleRate,\n AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,\n OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,\n AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION,\n },\n ios: {\n AVEncoderBitRateKeyIOS: this.audioSettings.bitRate,\n AVNumberOfChannelsKeyIOS: this.audioSettings.audioChannels,\n AVSampleRateKeyIOS: this.audioSettings.sampleRate,\n AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4, // same with aac\n AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high,\n },\n default: {},\n });\n\n constructor() {\n module.setSubscriptionDuration(0.1).catch((error) => {\n Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);\n });\n module.addRecordBackListener((data) => {\n const completed = data.currentPosition >= this.options.maxDuration;\n\n if (completed) {\n this.stop().catch((error) => {\n Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);\n });\n }\n if (this.state === 'recording') {\n this.recordingSubscribers.forEach((callback) => {\n callback({ currentTime: data.currentPosition, completed });\n });\n }\n });\n }\n\n private setState = (state: RecorderServiceInterface['state']) => {\n this.state = state;\n this.stateSubscribers.forEach((callback) => {\n callback(state);\n });\n };\n\n public requestPermission = async (): Promise<boolean> => {\n const permission: Permission[] | undefined = Platform.select({\n android: [permissionModule.PERMISSIONS.ANDROID.RECORD_AUDIO],\n ios: [permissionModule.PERMISSIONS.IOS.MICROPHONE],\n windows: [permissionModule.PERMISSIONS.WINDOWS.MICROPHONE],\n default: undefined,\n });\n\n if (Platform.OS === 'android' && Platform.Version <= 28) {\n permission?.push(permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);\n }\n\n if (permission) {\n const status = await permissionModule.checkMultiple(permission);\n if (nativePermissionGranted(status)) {\n return true;\n } else {\n const status = await permissionModule.requestMultiple(permission);\n return nativePermissionGranted(status);\n }\n } else {\n return true;\n }\n };\n\n public addRecordingListener = (callback: RecordingListener): Unsubscribe => {\n this.recordingSubscribers.add(callback);\n return () => {\n this.recordingSubscribers.delete(callback);\n };\n };\n\n public addStateListener = (callback: StateListener): Unsubscribe => {\n this.stateSubscribers.add(callback);\n return () => {\n this.stateSubscribers.delete(callback);\n };\n };\n\n public record = async (uri: string): Promise<void> => {\n if (matchesOneOf(this.state, ['idle', 'completed'])) {\n try {\n this.setState('preparing');\n await module.startRecorder(uri, {\n ...this.audioOptions,\n });\n\n if (Platform.OS === 'android') {\n this._recordStartedAt = Date.now();\n }\n\n this.uri = uri;\n this.setState('recording');\n } catch (e) {\n this.setState('idle');\n throw e;\n }\n }\n };\n\n public stop = async (): Promise<void> => {\n if (matchesOneOf(this.state, ['recording'])) {\n if (Platform.OS === 'android') {\n const buffer = this._getRecorderStopSafeBuffer();\n if (buffer > 0) await sleep(buffer);\n }\n\n await module.stopRecorder();\n this.setState('completed');\n }\n };\n\n public reset = async (): Promise<void> => {\n await this.stop();\n this.uri = undefined;\n this.recordingSubscribers.clear();\n this.setState('idle');\n };\n }\n\n return new VoiceRecorder();\n};\n\nexport default createNativeRecorderService;\n"],"mappings":";;;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAKvC,SAASC,MAAM,EAAEC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAEnE,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,uBAAuB,MAAM,kCAAkC;AAStE,MAAMC,2BAA2B,GAAGA,CAAC;EAAEC,mBAAmB;EAAEC;AAA0B,CAAC,KAA+B;EACpH,MAAMC,MAAM,GAAG,IAAIF,mBAAmB,CAACG,OAAO,CAAC,CAAC;EAEhD,MAAMC,aAAa,CAAqC;IA6CtDC,WAAWA,CAAA,EAAG;MAAAC,eAAA,cA5CgCC,SAAS;MAAAD,eAAA,gBACL,MAAM;MAAAA,eAAA,kBACF;QACpDE,WAAW,EAAEX,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACC,YAAY;QAC7DC,WAAW,EAAEf,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACG,YAAY;QAC7DC,SAAS,EAAEjB,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACK;MACjD,CAAC;MAED;MAAAT,eAAA,2BAC2B,CAAC;MAAAA,eAAA,qCACS,MAAM;QACzC,MAAMU,cAAc,GAAG,GAAG;QAC1B,MAAMC,WA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F,MAAM,CAAC;UACrC;UAEA,MAAM9E,MAAM,CAACgF,YAAY,CAAC,CAAC;UAC3B,IAAI,CAACN,QAAQ,CAAC,WAAW,CAAC;QAC5B;MACF,CAAC;MAAAtE,eAAA,gBAEc,YAA2B;QACxC,MAAM,IAAI,CAAC6E,IAAI,CAAC,CAAC;QACjB,IAAI,CAACR,GAAG,GAAGpE,SAAS;QACpB,IAAI,CAACiE,oBAAoB,CAACY,KAAK,CAAC,CAAC;QACjC,IAAI,CAACR,QAAQ,CAAC,MAAM,CAAC;MACvB,CAAC;MAvGC1E,MAAM,CAACmF,uBAAuB,CAAC,GAAG,CAAC,CAACC,KAAK,CAAEC,KAAK,IAAK;QACnD7F,MAAM,CAAC8F,IAAI,CAAC,8DAA8D,EAAED,KAAK,CAAC;MACpF,CAAC,CAAC;MACFrF,MAAM,CAACuF,qBAAqB,CAAEC,IAAI,IAAK;QACrC,MAAMC,SAAS,GAAGD,IAAI,CAACE,eAAe,IAAI,IAAI,CAACC,OAAO,CAACjF,WAAW;QAElE,IAAI+E,SAAS,EAAE;UACb,IAAI,CAACR,IAAI,CAAC,CAAC,CAACG,KAAK,CAAEC,KAAK,IAAK;YAC3B7F,MAAM,CAAC8F,IAAI,CAAC,+DAA+D,EAAED,KAAK,CAAC;UACrF,CAAC,CAAC;QACJ;QACA,IAAI,IAAI,CAAClC,KAAK,KAAK,WAAW,EAAE;UAC9B,IAAI,CAACmB,oBAAoB,CAACjB,OAAO,CAAEC,QAAQ,IAAK;YAC9CA,QAAQ,CAAC;cAAEsC,WAAW,EAAEJ,IAAI,CAACE,eAAe;cAAED;YAAU,CAAC,CAAC;UAC5D,CAAC,CAAC;QACJ;MACF,CAAC,CAAC;IACJ;EAuFF;EAEA,OAAO,IAAIvF,aAAa,CAAC,CAAC;AAC5B,CAAC;AAED,eAAeL,2BAA2B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Platform","Logger","matchesOneOf","sleep","VoiceMessageConfig","nativePermissionGranted","AudioRecorderPlayerAdapter","constructor","audioRecorderModule","_defineProperty","module","default","audioOptions","select","android","AudioEncodingBitRateAndroid","DEFAULT","RECORDER","BIT_RATE","AudioChannelsAndroid","CHANNELS","AudioSamplingRateAndroid","SAMPLE_RATE","AudioEncoderAndroid","AudioEncoderAndroidType","AAC","OutputFormatAndroid","OutputFormatAndroidType","MPEG_4","AudioSourceAndroid","AudioSourceAndroidType","VOICE_RECOGNITION","ios","AVEncoderBitRateKeyIOS","AVNumberOfChannelsKeyIOS","AVSampleRateKeyIOS","AVFormatIDKeyIOS","AVEncodingOption","mp4","AVEncoderAudioQualityKeyIOS","AVEncoderAudioQualityIOSType","high","setSubscriptionDuration","duration","addRecordBackListener","callback","convertRecordPath","uri","OS","split","pop","startRecorder","stopRecorder","NitroSoundOrLegacyV4Adapter","error","warn","VoiceRecorder","adapter","permissionModule","undefined","minDuration","MIN_DURATION","maxDuration","MAX_DURATION","extension","EXTENSION","Set","state","stateSubscribers","forEach","minWaitingTime","elapsedTime","Date","now","_recordStartedAt","permission","PERMISSIONS","ANDROID","RECORD_AUDIO","IOS","MICROPHONE","windows","WINDOWS","Version","push","WRITE_EXTERNAL_STORAGE","status","checkMultiple","requestMultiple","recordingSubscribers","add","delete","setState","e","_stopping","buffer","getRecorderStopSafeBuffer","stop","clear","initialize","setDurationResult","Promise","catch","data","completed","currentPosition","options","currentTime","createNativeRecorderService","modules","isNitroSoundOrLegacyV4Module","isNitroSound","createSound","isLegacyV4","getHybridObject"],"sources":["createRecorderService.native.tsx"],"sourcesContent":["import { Platform } from 'react-native';\nimport type * as LegacyModule from 'react-native-audio-recorder-player';\nimport type * as NitroSoundOrLegacyV4Module from 'react-native-nitro-sound';\nimport * as Permissions from 'react-native-permissions';\nimport { Permission } from 'react-native-permissions/src/types';\n\nimport { Logger, matchesOneOf, sleep } from '@sendbird/uikit-utils';\n\nimport VoiceMessageConfig from '../libs/VoiceMessageConfig';\nimport nativePermissionGranted from '../utils/nativePermissionGranted';\nimport type { RecorderServiceInterface, Unsubscribe } from './types';\n\nexport type AudioRecorderModule = typeof LegacyModule | typeof NitroSoundOrLegacyV4Module;\n\ntype RecordingListener = Parameters<RecorderServiceInterface['addRecordingListener']>[number];\ntype StateListener = Parameters<RecorderServiceInterface['addStateListener']>[number];\ntype Modules = {\n audioRecorderModule: AudioRecorderModule;\n permissionModule: typeof Permissions;\n};\n\ninterface RecordBackData {\n currentPosition: number;\n duration?: number;\n}\n\ninterface RecorderModuleAdapter {\n setSubscriptionDuration(duration: number): Promise<void> | void;\n addRecordBackListener(callback: (data: RecordBackData) => void): void;\n convertRecordPath(uri: string): string;\n startRecorder(uri: string): Promise<void>;\n stopRecorder(): Promise<void>;\n}\n\nclass AudioRecorderPlayerAdapter implements RecorderModuleAdapter {\n private module: InstanceType<typeof LegacyModule.default>;\n private readonly audioOptions;\n\n constructor(audioRecorderModule: typeof LegacyModule) {\n this.module = new audioRecorderModule.default();\n\n this.audioOptions = Platform.select({\n android: {\n AudioEncodingBitRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n AudioChannelsAndroid: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n AudioSamplingRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,\n OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,\n AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION,\n },\n ios: {\n AVEncoderBitRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n AVNumberOfChannelsKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n AVSampleRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4, // same with aac\n AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high,\n },\n default: {},\n });\n }\n\n async setSubscriptionDuration(duration: number): Promise<void> {\n await this.module.setSubscriptionDuration(duration);\n }\n\n addRecordBackListener(callback: (data: RecordBackData) => void): void {\n this.module.addRecordBackListener(callback);\n }\n\n convertRecordPath(uri: string): string {\n return Platform.OS === 'ios' ? uri.split('/').pop() || uri : uri;\n }\n\n async startRecorder(uri: string): Promise<void> {\n await this.module.startRecorder(uri, this.audioOptions as Parameters<typeof this.module.startRecorder>[1]);\n }\n\n async stopRecorder(): Promise<void> {\n await this.module.stopRecorder();\n }\n}\n\nclass NitroSoundOrLegacyV4Adapter implements RecorderModuleAdapter {\n private module;\n private readonly audioOptions;\n\n constructor(audioRecorderModule: typeof NitroSoundOrLegacyV4Module) {\n this.module = audioRecorderModule.default;\n this.audioOptions = Platform.select({\n android: {\n AudioEncodingBitRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n AudioChannelsAndroid: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n AudioSamplingRateAndroid: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,\n OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,\n AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION,\n },\n ios: {\n AVEncoderBitRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n AVNumberOfChannelsKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n AVSampleRateKeyIOS: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n AVFormatIDKeyIOS: 'mp4', // same with aac\n AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high,\n },\n default: {},\n });\n }\n\n setSubscriptionDuration(duration: number): void {\n try {\n this.module.setSubscriptionDuration(duration);\n } catch (error) {\n Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);\n }\n }\n\n addRecordBackListener(callback: (data: RecordBackData) => void): void {\n this.module.addRecordBackListener(callback);\n }\n\n convertRecordPath(uri: string): string {\n return uri;\n }\n\n async startRecorder(uri: string): Promise<void> {\n await this.module.startRecorder(uri, this.audioOptions as Parameters<typeof this.module.startRecorder>[1]);\n }\n\n async stopRecorder(): Promise<void> {\n await this.module.stopRecorder();\n }\n}\n\nclass VoiceRecorder implements RecorderServiceInterface {\n public uri: RecorderServiceInterface['uri'] = undefined;\n public state: RecorderServiceInterface['state'] = 'idle';\n public options: RecorderServiceInterface['options'] = {\n minDuration: VoiceMessageConfig.DEFAULT.RECORDER.MIN_DURATION,\n maxDuration: VoiceMessageConfig.DEFAULT.RECORDER.MAX_DURATION,\n extension: VoiceMessageConfig.DEFAULT.RECORDER.EXTENSION,\n };\n\n private _recordStartedAt = 0;\n private _stopping = false;\n private readonly recordingSubscribers = new Set<RecordingListener>();\n private readonly stateSubscribers = new Set<StateListener>();\n\n constructor(private readonly adapter: RecorderModuleAdapter, private readonly permissionModule: typeof Permissions) {\n this.initialize();\n }\n\n private initialize(): void {\n const setDurationResult = this.adapter.setSubscriptionDuration(0.1);\n if (setDurationResult instanceof Promise) {\n setDurationResult.catch((error) => {\n Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);\n });\n }\n\n this.adapter.addRecordBackListener((data) => {\n const completed = data.currentPosition >= this.options.maxDuration;\n\n if (completed) {\n this.stop().catch((error) => {\n Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);\n });\n }\n if (this.state === 'recording') {\n this.recordingSubscribers.forEach((callback) => {\n callback({ currentTime: data.currentPosition, completed });\n });\n }\n });\n }\n\n private setState = (state: RecorderServiceInterface['state']): void => {\n this.state = state;\n this.stateSubscribers.forEach((callback) => {\n callback(state);\n });\n };\n\n private getRecorderStopSafeBuffer = (): number => {\n const minWaitingTime = 500;\n const elapsedTime = Date.now() - this._recordStartedAt;\n if (elapsedTime > minWaitingTime) return 0;\n else return minWaitingTime - elapsedTime;\n };\n\n public requestPermission = async (): Promise<boolean> => {\n const permission: Permission[] | undefined = Platform.select({\n android: [this.permissionModule.PERMISSIONS.ANDROID.RECORD_AUDIO],\n ios: [this.permissionModule.PERMISSIONS.IOS.MICROPHONE],\n windows: [this.permissionModule.PERMISSIONS.WINDOWS.MICROPHONE],\n default: undefined,\n });\n\n if (Platform.OS === 'android' && Platform.Version <= 28) {\n permission?.push(this.permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);\n }\n\n if (permission) {\n const status = await this.permissionModule.checkMultiple(permission);\n if (nativePermissionGranted(status)) {\n return true;\n } else {\n const status = await this.permissionModule.requestMultiple(permission);\n return nativePermissionGranted(status);\n }\n } else {\n return true;\n }\n };\n\n public addRecordingListener = (callback: RecordingListener): Unsubscribe => {\n this.recordingSubscribers.add(callback);\n return () => {\n this.recordingSubscribers.delete(callback);\n };\n };\n\n public addStateListener = (callback: StateListener): Unsubscribe => {\n this.stateSubscribers.add(callback);\n return () => {\n this.stateSubscribers.delete(callback);\n };\n };\n\n public record = async (uri: string): Promise<void> => {\n if (matchesOneOf(this.state, ['idle', 'completed'])) {\n try {\n this.setState('preparing');\n await this.adapter.startRecorder(uri);\n\n if (Platform.OS === 'android') {\n this._recordStartedAt = Date.now();\n }\n\n this.uri = uri;\n this.setState('recording');\n } catch (e) {\n this.setState('idle');\n throw e;\n }\n }\n };\n\n public stop = async (): Promise<void> => {\n if (matchesOneOf(this.state, ['recording']) && !this._stopping) {\n this._stopping = true;\n try {\n if (Platform.OS === 'android') {\n const buffer = this.getRecorderStopSafeBuffer();\n if (buffer > 0) await sleep(buffer);\n }\n\n await this.adapter.stopRecorder();\n this.setState('completed');\n } catch (error) {\n Logger.error('[RecorderService.Native] Failed to stop recorder', error);\n throw error;\n } finally {\n this._stopping = false;\n }\n }\n };\n\n public reset = async (): Promise<void> => {\n await this.stop();\n this.uri = undefined;\n this.recordingSubscribers.clear();\n this.setState('idle');\n };\n\n public convertRecordPath = (uri: string): string => {\n return this.adapter.convertRecordPath(uri);\n };\n}\n\nconst createNativeRecorderService = (modules: Modules): RecorderServiceInterface => {\n const adapter = isNitroSoundOrLegacyV4Module(modules.audioRecorderModule)\n ? new NitroSoundOrLegacyV4Adapter(modules.audioRecorderModule)\n : new AudioRecorderPlayerAdapter(modules.audioRecorderModule as typeof LegacyModule);\n\n return new VoiceRecorder(adapter, modules.permissionModule);\n};\n\nfunction isNitroSoundOrLegacyV4Module(module: AudioRecorderModule): module is typeof NitroSoundOrLegacyV4Module {\n const isNitroSound = 'createSound' in module && typeof module.createSound === 'function';\n const isLegacyV4 =\n 'default' in module && 'getHybridObject' in module.default && typeof module.default.getHybridObject === 'function';\n if (isLegacyV4) {\n Logger.warn('react-native-audio-recorder-player is deprecated. Please use react-native-nitro-sound instead.');\n }\n return isNitroSound || isLegacyV4;\n}\n\nexport default createNativeRecorderService;\n"],"mappings":";;;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAMvC,SAASC,MAAM,EAAEC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAEnE,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,uBAAuB,MAAM,kCAAkC;AAyBtE,MAAMC,0BAA0B,CAAkC;EAIhEC,WAAWA,CAACC,mBAAwC,EAAE;IAAAC,eAAA;IAAAA,eAAA;IACpD,IAAI,CAACC,MAAM,GAAG,IAAIF,mBAAmB,CAACG,OAAO,CAAC,CAAC;IAE/C,IAAI,CAACC,YAAY,GAAGZ,QAAQ,CAACa,MAAM,CAAC;MAClCC,OAAO,EAAE;QACPC,2BAA2B,EAAEX,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACC,QAAQ;QACzEC,oBAAoB,EAAEf,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACG,QAAQ;QAClEC,wBAAwB,EAAEjB,kBAAkB,CAACY,OAAO,CAACC,QAAQ,CAACK,WAAW;QACzEC,mBAAmB,EAAEf,mBAAmB,CAACg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P,IAAI,CAAC,CAAC,CAACK,KAAK,CAAEhD,KAAK,IAAK;UAC3BrD,MAAM,CAACsD,IAAI,CAAC,+DAA+D,EAAED,KAAK,CAAC;QACrF,CAAC,CAAC;MACJ;MACA,IAAI,IAAI,CAACa,KAAK,KAAK,WAAW,EAAE;QAC9B,IAAI,CAACsB,oBAAoB,CAACpB,OAAO,CAAExB,QAAQ,IAAK;UAC9CA,QAAQ,CAAC;YAAE8D,WAAW,EAAEJ,IAAI,CAACE,eAAe;YAAED;UAAU,CAAC,CAAC;QAC5D,CAAC,CAAC;MACJ;IACF,CAAC,CAAC;EACJ;AAwGF;AAEA,MAAMI,2BAA2B,GAAIC,OAAgB,IAA+B;EAClF,MAAMpD,OAAO,GAAGqD,4BAA4B,CAACD,OAAO,CAACrG,mBAAmB,CAAC,GACrE,IAAI6C,2BAA2B,CAACwD,OAAO,CAACrG,mBAAmB,CAAC,GAC5D,IAAIF,0BAA0B,CAACuG,OAAO,CAACrG,mBAA0C,CAAC;EAEtF,OAAO,IAAIgD,aAAa,CAACC,OAAO,EAAEoD,OAAO,CAACnD,gBAAgB,CAAC;AAC7D,CAAC;AAED,SAASoD,4BAA4BA,CAACpG,MAA2B,EAA+C;EAC9G,MAAMqG,YAAY,GAAG,aAAa,IAAIrG,MAAM,IAAI,OAAOA,MAAM,CAACsG,WAAW,KAAK,UAAU;EACxF,MAAMC,UAAU,GACd,SAAS,IAAIvG,MAAM,IAAI,iBAAiB,IAAIA,MAAM,CAACC,OAAO,IAAI,OAAOD,MAAM,CAACC,OAAO,CAACuG,eAAe,KAAK,UAAU;EACpH,IAAID,UAAU,EAAE;IACdhH,MAAM,CAACsD,IAAI,CAAC,gGAAgG,CAAC;EAC/G;EACA,OAAOwD,YAAY,IAAIE,UAAU;AACnC;AAEA,eAAeL,2BAA2B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type SBUError from '../libs/SBUError';\n\nexport type Unsubscribe = () => void | undefined;\nexport type DownloadedPath = string;\nexport type FilePickerResponse = FileType | null;\n\n/**\n * We are following the file format of react-native FormData\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Network/FormData.js#L37-L41\n * */\nexport type FileType = { name: string; uri: string; size: number; type: string };\n\n// ---------- NotificationService ---------- //\nexport interface NotificationServiceInterface {\n hasPushPermission(): Promise<boolean>;\n requestPushPermission(): Promise<boolean>;\n\n getAPNSToken(): Promise<string | null>;\n getFCMToken(): Promise<string | null>;\n onTokenRefresh(handler: (token: string) => void): Unsubscribe;\n}\n\n// ---------- ClipboardService ---------- //\nexport interface ClipboardServiceInterface {\n setString(text: string): void;\n getString(): Promise<string>;\n}\n\n// ---------- FileService ---------- //\nexport interface FileServiceInterface extends FilePickerServiceInterface, FileSystemServiceInterface {}\n\nexport interface OpenResultListener {\n onOpenFailure?: (error: SBUError, originError?: unknown) => void;\n}\nexport interface OpenMediaLibraryOptions extends OpenResultListener {\n selectionLimit?: number;\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport interface OpenCameraOptions extends OpenResultListener {\n cameraType?: 'front' | 'back';\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport type OpenDocumentOptions = OpenResultListener;\nexport interface SaveOptions {\n fileUrl: string;\n fileName: string;\n fileType?: string | null;\n}\n\nexport interface FilePickerServiceInterface {\n openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<null | FilePickerResponse[]>;\n openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse>;\n openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse>;\n}\n\nexport interface FileSystemServiceInterface {\n // NOTE: On iOS, You can access the downloaded files by providing options below to info.plist\n // - Supports opening documents in place\n // - Application supports iTunes file sharing\n save(options?: SaveOptions): Promise<DownloadedPath | null>;\n createRecordFilePath(customExtension?: string): { recordFilePath: string; uri: string };\n}\n\n// ---------- MediaService ---------- //\nexport type VideoProps = {\n source: { uri: string } | number;\n resizeMode?: 'cover' | 'contain' | 'stretch';\n onLoad?: () => void;\n};\n\nexport type GetVideoThumbnailOptions = {\n url: string;\n timeMills?: number;\n quality?: number;\n};\nexport type GetVideoThumbnailResult = Promise<{ path: string } | null>;\n\nexport type CompressImageOptions = {\n /**\n * A uri of image file to compress\n * */\n uri: string;\n\n /**\n * A resize width, apply only to downscale\n * */\n maxWidth?: number;\n\n /**\n * A resize height, apply only to downscale\n * */\n maxHeight?: number;\n\n /**\n * A value in range 0.0 - 1.0 specifying compression level of the result image.\n * 1 means highest quality and 0 the lowest quality.\n * */\n compressionRate?: number;\n};\nexport type CompressImageResult = Promise<{ uri: string; size: number } | null>;\n\nexport interface MediaServiceInterface {\n VideoComponent<Props = {}>(props: VideoProps & Props): ReactNode;\n getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult;\n compressImage(options: CompressImageOptions): CompressImageResult;\n}\n\n// ---------- PlayerService ---------- //\nexport interface PlayerServiceInterface {\n uri?: string;\n state: 'idle' | 'preparing' | 'playing' | 'paused' | 'stopped';\n\n /**\n * Check and request permission for the player.\n * */\n requestPermission(): Promise<boolean>;\n\n /**\n * Add a playback listener.\n * */\n addPlaybackListener(\n callback: (params: { currentTime: number; duration: number; stopped: boolean }) => void,\n ): Unsubscribe;\n\n /**\n * Add a state listener.\n * */\n addStateListener(callback: (state: PlayerServiceInterface['state']) => void): Unsubscribe;\n\n /**\n * State transition:\n * [idle, stopped] to [playing] - start from the beginning\n * [paused] to [playing] - resume\n * */\n play(uri: string): Promise<void>;\n\n /**\n * State transition:\n * [playing] to [paused]\n * */\n pause(): Promise<void>;\n\n /**\n * State transition:\n * [preparing, playing, paused] to [stop]\n * */\n stop(): Promise<void>;\n\n /**\n * State transition:\n * [*] to [idle]\n * */\n reset(): Promise<void>;\n\n /**\n * Seek time, only available when the state is [playing, paused].\n * */\n seek(time: number): Promise<void>;\n}\n\n// ---------- RecorderService ---------- //\nexport interface RecorderOptions {\n /**\n * Minimum recording duration (milliseconds).\n * */\n minDuration: number;\n\n /**\n * Maximum recording duration (milliseconds).\n * */\n maxDuration: number;\n\n /**\n * File extension for recorded audio file\n * */\n extension: string;\n}\n\nexport interface RecorderServiceInterface {\n uri?: string;\n options: RecorderOptions;\n state: 'idle' | 'preparing' | 'recording' | 'completed';\n\n /**\n * Check and request permission for the recorder.\n * */\n requestPermission(): Promise<boolean>;\n\n /**\n * Add recording listener.\n * */\n addRecordingListener(callback: (params: { currentTime: number; completed: boolean }) => void): Unsubscribe;\n\n /**\n * Add state listener.\n * */\n addStateListener(callback: (state: RecorderServiceInterface['state']) => void): Unsubscribe;\n\n /**\n * State transition:\n * [idle, completed] to [recording]\n * */\n record(uri?: string): Promise<void>;\n\n /**\n * State transition:\n * [recording] to [completed]\n * */\n stop(): Promise<void>;\n\n /**\n * State transition:\n * [*] to [idle]\n * */\n reset(): Promise<void>;\n}\n"],"mappings":"","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["types.ts"],"sourcesContent":["import type { ReactNode } from 'react';\n\nimport type SBUError from '../libs/SBUError';\n\nexport type Unsubscribe = () => void | undefined;\nexport type DownloadedPath = string;\nexport type FilePickerResponse = FileType | null;\n\n/**\n * We are following the file format of react-native FormData\n * @see https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Network/FormData.js#L37-L41\n * */\nexport type FileType = { name: string; uri: string; size: number; type: string };\n\n// ---------- NotificationService ---------- //\nexport interface NotificationServiceInterface {\n hasPushPermission(): Promise<boolean>;\n requestPushPermission(): Promise<boolean>;\n\n getAPNSToken(): Promise<string | null>;\n getFCMToken(): Promise<string | null>;\n onTokenRefresh(handler: (token: string) => void): Unsubscribe;\n}\n\n// ---------- ClipboardService ---------- //\nexport interface ClipboardServiceInterface {\n setString(text: string): void;\n getString(): Promise<string>;\n}\n\n// ---------- FileService ---------- //\nexport interface FileServiceInterface extends FilePickerServiceInterface, FileSystemServiceInterface {}\n\nexport interface OpenResultListener {\n onOpenFailure?: (error: SBUError, originError?: unknown) => void;\n}\nexport interface OpenMediaLibraryOptions extends OpenResultListener {\n selectionLimit?: number;\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport interface OpenCameraOptions extends OpenResultListener {\n cameraType?: 'front' | 'back';\n mediaType?: 'photo' | 'video' | 'all';\n}\nexport type OpenDocumentOptions = OpenResultListener;\nexport interface SaveOptions {\n fileUrl: string;\n fileName: string;\n fileType?: string | null;\n}\n\nexport interface FilePickerServiceInterface {\n openMediaLibrary(options?: OpenMediaLibraryOptions): Promise<null | FilePickerResponse[]>;\n openCamera(options?: OpenCameraOptions): Promise<FilePickerResponse>;\n openDocument(options?: OpenDocumentOptions): Promise<FilePickerResponse>;\n}\n\nexport interface FileSystemServiceInterface {\n // NOTE: On iOS, You can access the downloaded files by providing options below to info.plist\n // - Supports opening documents in place\n // - Application supports iTunes file sharing\n save(options?: SaveOptions): Promise<DownloadedPath | null>;\n createRecordFilePath(customExtension?: string): { recordFilePath: string; uri: string };\n}\n\n// ---------- MediaService ---------- //\nexport type VideoProps = {\n source: { uri: string } | number;\n resizeMode?: 'cover' | 'contain' | 'stretch';\n onLoad?: () => void;\n};\n\nexport type GetVideoThumbnailOptions = {\n url: string;\n timeMills?: number;\n quality?: number;\n};\nexport type GetVideoThumbnailResult = Promise<{ path: string } | null>;\n\nexport type CompressImageOptions = {\n /**\n * A uri of image file to compress\n * */\n uri: string;\n\n /**\n * A resize width, apply only to downscale\n * */\n maxWidth?: number;\n\n /**\n * A resize height, apply only to downscale\n * */\n maxHeight?: number;\n\n /**\n * A value in range 0.0 - 1.0 specifying compression level of the result image.\n * 1 means highest quality and 0 the lowest quality.\n * */\n compressionRate?: number;\n};\nexport type CompressImageResult = Promise<{ uri: string; size: number } | null>;\n\nexport interface MediaServiceInterface {\n VideoComponent<Props = {}>(props: VideoProps & Props): ReactNode;\n getVideoThumbnail(options: GetVideoThumbnailOptions): GetVideoThumbnailResult;\n compressImage(options: CompressImageOptions): CompressImageResult;\n}\n\n// ---------- PlayerService ---------- //\nexport interface PlayerServiceInterface {\n uri?: string;\n state: 'idle' | 'preparing' | 'playing' | 'paused' | 'stopped';\n\n /**\n * Check and request permission for the player.\n * */\n requestPermission(): Promise<boolean>;\n\n /**\n * Add a playback listener.\n * */\n addPlaybackListener(\n callback: (params: { currentTime: number; duration: number; stopped: boolean }) => void,\n ): Unsubscribe;\n\n /**\n * Add a state listener.\n * */\n addStateListener(callback: (state: PlayerServiceInterface['state']) => void): Unsubscribe;\n\n /**\n * State transition:\n * [idle, stopped] to [playing] - start from the beginning\n * [paused] to [playing] - resume\n * */\n play(uri: string): Promise<void>;\n\n /**\n * State transition:\n * [playing] to [paused]\n * */\n pause(): Promise<void>;\n\n /**\n * State transition:\n * [preparing, playing, paused] to [stop]\n * */\n stop(): Promise<void>;\n\n /**\n * State transition:\n * [*] to [idle]\n * */\n reset(): Promise<void>;\n\n /**\n * Seek time, only available when the state is [playing, paused].\n * */\n seek(time: number): Promise<void>;\n}\n\n// ---------- RecorderService ---------- //\nexport interface RecorderOptions {\n /**\n * Minimum recording duration (milliseconds).\n * */\n minDuration: number;\n\n /**\n * Maximum recording duration (milliseconds).\n * */\n maxDuration: number;\n\n /**\n * File extension for recorded audio file\n * */\n extension: string;\n}\n\nexport interface RecorderServiceInterface {\n uri?: string;\n options: RecorderOptions;\n state: 'idle' | 'preparing' | 'recording' | 'completed';\n\n /**\n * Check and request permission for the recorder.\n * */\n requestPermission(): Promise<boolean>;\n\n /**\n * Add recording listener.\n * */\n addRecordingListener(callback: (params: { currentTime: number; completed: boolean }) => void): Unsubscribe;\n\n /**\n * Add state listener.\n * */\n addStateListener(callback: (state: RecorderServiceInterface['state']) => void): Unsubscribe;\n\n /**\n * State transition:\n * [idle, completed] to [recording]\n * */\n record(uri?: string): Promise<void>;\n\n /**\n * State transition:\n * [recording] to [completed]\n * */\n stop(): Promise<void>;\n\n /**\n * State transition:\n * [*] to [idle]\n * */\n reset(): Promise<void>;\n\n /**\n * Get the record path processed for the specific platform and adapter.\n * */\n convertRecordPath(uri: string): string;\n}\n"],"mappings":"","ignoreList":[]}
|
|
@@ -72,6 +72,29 @@ const expoBackwardUtils = {
|
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
74
|
},
|
|
75
|
+
expoAV: {
|
|
76
|
+
isLegacyAVModule(module) {
|
|
77
|
+
try {
|
|
78
|
+
return 'Video' in module && 'Audio' in module && typeof module.Video === 'function';
|
|
79
|
+
} catch {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
isAudioModule(module) {
|
|
84
|
+
try {
|
|
85
|
+
return 'useAudioRecorder' in module && typeof module.useAudioRecorder === 'function';
|
|
86
|
+
} catch {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
isVideoModule(module) {
|
|
91
|
+
try {
|
|
92
|
+
return 'VideoView' in module && 'useVideoPlayer' in module && typeof module.useVideoPlayer === 'function';
|
|
93
|
+
} catch {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
75
98
|
toFileSize(info) {
|
|
76
99
|
if ('size' in info) {
|
|
77
100
|
return info.size;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["normalizeFile","expoBackwardUtils","imagePicker","isCanceled","result","canceled","cancelled","toFilePickerResponses","fsModule","assets","promises","map","fileName","name","fileSize","size","type","uri","Promise","all","fileInfo","getInfoAsync","response","toFileSize","documentPicker","mimeType","info"],"sources":["expoBackwardUtils.ts"],"sourcesContent":["import type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\n\nimport type { FilePickerResponse } from '../platform/types';\nimport normalizeFile from './normalizeFile';\n\nconst expoBackwardUtils = {\n imagePicker: {\n isCanceled(result: ExpoImagePicker.ImagePickerResult) {\n // @ts-expect-error backward compatibility\n return result.canceled ?? result.cancelled;\n },\n async toFilePickerResponses(\n result: ExpoImagePicker.ImagePickerResult,\n fsModule: typeof ExpoFs,\n ): Promise<FilePickerResponse[]> {\n if (result.assets) {\n const assets = result.assets || [];\n const promises = assets.map(({ fileName: name, fileSize: size, type, uri }) =>\n normalizeFile({ uri, size, name, type }),\n );\n\n return Promise.all(promises);\n } else if ('uri' in result && typeof result.uri === 'string') {\n const fileInfo = await fsModule.getInfoAsync(result.uri);\n const response = await normalizeFile({ uri: result.uri, size: expoBackwardUtils.toFileSize(fileInfo) });\n return [response];\n } else {\n return [];\n }\n },\n },\n documentPicker: {\n isCanceled(result: ExpoDocumentPicker.DocumentPickerResult) {\n // @ts-expect-error backward compatibility\n return result.canceled ?? result.type === 'cancel';\n },\n async toFilePickerResponses(result: ExpoDocumentPicker.DocumentPickerResult): Promise<FilePickerResponse[]> {\n if (result.assets) {\n const assets = result.assets || [];\n const promises = assets.map(({ name, size, mimeType, uri }) =>\n normalizeFile({ uri, size, name, type: mimeType }),\n );\n\n return Promise.all(promises);\n } else if ('uri' in result && typeof result.uri === 'string') {\n // @ts-expect-error backward compatibility\n const { mimeType, uri, size, name } = result;\n const response = await normalizeFile({ uri, size, name, type: mimeType });\n\n return [response];\n } else {\n return [];\n }\n },\n },\n toFileSize(info: ExpoFs.FileInfo) {\n if ('size' in info) {\n return info.size;\n } else {\n return 0;\n }\n },\n};\n\nexport default expoBackwardUtils;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["normalizeFile","expoBackwardUtils","imagePicker","isCanceled","result","canceled","cancelled","toFilePickerResponses","fsModule","assets","promises","map","fileName","name","fileSize","size","type","uri","Promise","all","fileInfo","getInfoAsync","response","toFileSize","documentPicker","mimeType","expoAV","isLegacyAVModule","module","Video","isAudioModule","useAudioRecorder","isVideoModule","useVideoPlayer","info"],"sources":["expoBackwardUtils.ts"],"sourcesContent":["import type * as ExpoAudio from 'expo-audio';\nimport type * as ExpoAV from 'expo-av';\nimport type * as ExpoDocumentPicker from 'expo-document-picker';\nimport type * as ExpoFs from 'expo-file-system';\nimport type * as ExpoImagePicker from 'expo-image-picker';\nimport type * as ExpoVideo from 'expo-video';\n\nimport type { FilePickerResponse } from '../platform/types';\nimport normalizeFile from './normalizeFile';\n\nconst expoBackwardUtils = {\n imagePicker: {\n isCanceled(result: ExpoImagePicker.ImagePickerResult) {\n // @ts-expect-error backward compatibility\n return result.canceled ?? result.cancelled;\n },\n async toFilePickerResponses(\n result: ExpoImagePicker.ImagePickerResult,\n fsModule: typeof ExpoFs,\n ): Promise<FilePickerResponse[]> {\n if (result.assets) {\n const assets = result.assets || [];\n const promises = assets.map(({ fileName: name, fileSize: size, type, uri }) =>\n normalizeFile({ uri, size, name, type }),\n );\n\n return Promise.all(promises);\n } else if ('uri' in result && typeof result.uri === 'string') {\n const fileInfo = await fsModule.getInfoAsync(result.uri);\n const response = await normalizeFile({ uri: result.uri, size: expoBackwardUtils.toFileSize(fileInfo) });\n return [response];\n } else {\n return [];\n }\n },\n },\n documentPicker: {\n isCanceled(result: ExpoDocumentPicker.DocumentPickerResult) {\n // @ts-expect-error backward compatibility\n return result.canceled ?? result.type === 'cancel';\n },\n async toFilePickerResponses(result: ExpoDocumentPicker.DocumentPickerResult): Promise<FilePickerResponse[]> {\n if (result.assets) {\n const assets = result.assets || [];\n const promises = assets.map(({ name, size, mimeType, uri }) =>\n normalizeFile({ uri, size, name, type: mimeType }),\n );\n\n return Promise.all(promises);\n } else if ('uri' in result && typeof result.uri === 'string') {\n // @ts-expect-error backward compatibility\n const { mimeType, uri, size, name } = result;\n const response = await normalizeFile({ uri, size, name, type: mimeType });\n\n return [response];\n } else {\n return [];\n }\n },\n },\n expoAV: {\n isLegacyAVModule(module: ExpoAudioModule | ExpoVideoModule): module is typeof ExpoAV {\n try {\n return 'Video' in module && 'Audio' in module && typeof module.Video === 'function';\n } catch {\n return false;\n }\n },\n isAudioModule(module: ExpoAudioModule): module is typeof ExpoAudio {\n try {\n return 'useAudioRecorder' in module && typeof module.useAudioRecorder === 'function';\n } catch {\n return false;\n }\n },\n isVideoModule(module: ExpoVideoModule): module is typeof ExpoVideo {\n try {\n return 'VideoView' in module && 'useVideoPlayer' in module && typeof module.useVideoPlayer === 'function';\n } catch {\n return false;\n }\n },\n },\n toFileSize(info: ExpoFs.FileInfo) {\n if ('size' in info) {\n return info.size;\n } else {\n return 0;\n }\n },\n};\n\nexport type ExpoAudioModule = typeof ExpoAV | typeof ExpoAudio;\nexport type ExpoVideoModule = typeof ExpoAV | typeof ExpoVideo;\n\nexport default expoBackwardUtils;\n"],"mappings":"AAQA,OAAOA,aAAa,MAAM,iBAAiB;AAE3C,MAAMC,iBAAiB,GAAG;EACxBC,WAAW,EAAE;IACXC,UAAUA,CAACC,MAAyC,EAAE;MACpD;MACA,OAAOA,MAAM,CAACC,QAAQ,IAAID,MAAM,CAACE,SAAS;IAC5C,CAAC;IACD,MAAMC,qBAAqBA,CACzBH,MAAyC,EACzCI,QAAuB,EACQ;MAC/B,IAAIJ,MAAM,CAACK,MAAM,EAAE;QACjB,MAAMA,MAAM,GAAGL,MAAM,CAACK,MAAM,IAAI,EAAE;QAClC,MAAMC,QAAQ,GAAGD,MAAM,CAACE,GAAG,CAAC,CAAC;UAAEC,QAAQ,EAAEC,IAAI;UAAEC,QAAQ,EAAEC,IAAI;UAAEC,IAAI;UAAEC;QAAI,CAAC,KACxEjB,aAAa,CAAC;UAAEiB,GAAG;UAAEF,IAAI;UAAEF,IAAI;UAAEG;QAAK,CAAC,CACzC,CAAC;QAED,OAAOE,OAAO,CAACC,GAAG,CAACT,QAAQ,CAAC;MAC9B,CAAC,MAAM,IAAI,KAAK,IAAIN,MAAM,IAAI,OAAOA,MAAM,CAACa,GAAG,KAAK,QAAQ,EAAE;QAC5D,MAAMG,QAAQ,GAAG,MAAMZ,QAAQ,CAACa,YAAY,CAACjB,MAAM,CAACa,GAAG,CAAC;QACxD,MAAMK,QAAQ,GAAG,MAAMtB,aAAa,CAAC;UAAEiB,GAAG,EAAEb,MAAM,CAACa,GAAG;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AAI,OAAOA,MAAM,CAACC,KAAK,KAAK,UAAU;MACrF,CAAC,CAAC,MAAM;QACN,OAAO,KAAK;MACd;IACF,CAAC;IACDC,aAAaA,CAACF,MAAuB,EAA8B;MACjE,IAAI;QACF,OAAO,kBAAkB,IAAIA,MAAM,IAAI,OAAOA,MAAM,CAACG,gBAAgB,KAAK,UAAU;MACtF,CAAC,CAAC,MAAM;QACN,OAAO,KAAK;MACd;IACF,CAAC;IACDC,aAAaA,CAACJ,MAAuB,EAA8B;MACjE,IAAI;QACF,OAAO,WAAW,IAAIA,MAAM,IAAI,gBAAgB,IAAIA,MAAM,IAAI,OAAOA,MAAM,CAACK,cAAc,KAAK,UAAU;MAC3G,CAAC,CAAC,MAAM;QACN,OAAO,KAAK;MACd;IACF;EACF,CAAC;EACDV,UAAUA,CAACW,IAAqB,EAAE;IAChC,IAAI,MAAM,IAAIA,IAAI,EAAE;MAClB,OAAOA,IAAI,CAACnB,IAAI;IAClB,CAAC,MAAM;MACL,OAAO,CAAC;IACV;EACF;AACF,CAAC;AAKD,eAAed,iBAAiB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["expoPermissionGranted","stats","limitedCallback","every","res","accessPrivileges","granted","status","_res$ios","ios"],"sources":["expoPermissionGranted.ts"],"sourcesContent":["import type { NotificationPermissionsStatus } from 'expo-notifications';\n\nexport interface ExpoPermissionResponse {\n canAskAgain: boolean;\n granted: boolean;\n status: 'denied' | 'granted' | 'undetermined';\n}\n\nexport interface ExpoMediaLibraryPermissionResponse extends ExpoPermissionResponse {\n accessPrivileges?: 'all' | 'limited' | 'none';\n}\nexport interface ExpoPushPermissionResponse
|
|
1
|
+
{"version":3,"names":["expoPermissionGranted","stats","limitedCallback","every","res","accessPrivileges","granted","status","_res$ios","ios"],"sources":["expoPermissionGranted.ts"],"sourcesContent":["import type { NotificationPermissionsStatus } from 'expo-notifications';\n\nexport interface ExpoPermissionResponse {\n canAskAgain: boolean;\n granted: boolean;\n status: 'denied' | 'granted' | 'undetermined';\n}\n\nexport interface ExpoMediaLibraryPermissionResponse extends ExpoPermissionResponse {\n accessPrivileges?: 'all' | 'limited' | 'none';\n}\nexport interface ExpoPushPermissionResponse\n extends Omit<ExpoPermissionResponse, 'status'>,\n NotificationPermissionsStatus {}\n\nconst expoPermissionGranted = (\n stats: Array<ExpoMediaLibraryPermissionResponse | ExpoPushPermissionResponse | ExpoPermissionResponse>,\n limitedCallback?: () => void,\n) => {\n return stats.every((res) => {\n if ('accessPrivileges' in res) {\n if (res.accessPrivileges === 'limited') limitedCallback?.();\n return (\n res.granted || res.status === 'granted' || res.accessPrivileges === 'all' || res.accessPrivileges === 'limited'\n );\n }\n if ('ios' in res) {\n // NOT_DETERMINED = 0,\n // DENIED = 1,\n // AUTHORIZED = 2,\n // PROVISIONAL = 3,\n // EPHEMERAL = 4,\n return (\n res.granted || res.status === 'granted' || (res.ios?.status && (res.ios.status === 2 || res.ios.status === 3))\n );\n }\n return res.granted || res.status === 'granted';\n });\n};\n\nexport default expoPermissionGranted;\n"],"mappings":"AAeA,MAAMA,qBAAqB,GAAGA,CAC5BC,KAAsG,EACtGC,eAA4B,KACzB;EACH,OAAOD,KAAK,CAACE,KAAK,CAAEC,GAAG,IAAK;IAC1B,IAAI,kBAAkB,IAAIA,GAAG,EAAE;MAC7B,IAAIA,GAAG,CAACC,gBAAgB,KAAK,SAAS,EAAEH,eAAe,aAAfA,eAAe,eAAfA,eAAe,CAAG,CAAC;MAC3D,OACEE,GAAG,CAACE,OAAO,IAAIF,GAAG,CAACG,MAAM,KAAK,SAAS,IAAIH,GAAG,CAACC,gBAAgB,KAAK,KAAK,IAAID,GAAG,CAACC,gBAAgB,KAAK,SAAS;IAEnH;IACA,IAAI,KAAK,IAAID,GAAG,EAAE;MAAA,IAAAI,QAAA;MAChB;MACA;MACA;MACA;MACA;MACA,OACEJ,GAAG,CAACE,OAAO,IAAIF,GAAG,CAACG,MAAM,KAAK,SAAS,IAAK,EAAAC,QAAA,GAAAJ,GAAG,CAACK,GAAG,cAAAD,QAAA,uBAAPA,QAAA,CAASD,MAAM,MAAKH,GAAG,CAACK,GAAG,CAACF,MAAM,KAAK,CAAC,IAAIH,GAAG,CAACK,GAAG,CAACF,MAAM,KAAK,CAAC,CAAE;IAElH;IACA,OAAOH,GAAG,CAACE,OAAO,IAAIF,GAAG,CAACG,MAAM,KAAK,SAAS;EAChD,CAAC,CAAC;AACJ,CAAC;AAED,eAAeP,qBAAqB","ignoreList":[]}
|
package/lib/module/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.
|
|
1
|
+
{"version":3,"names":["VERSION"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.11.1';\nexport default VERSION;\n"],"mappings":"AAAA,MAAMA,OAAO,GAAG,QAAQ;AACxB,eAAeA,OAAO","ignoreList":[]}
|
|
@@ -14,7 +14,7 @@ import type { StringSet } from '../localization/StringSet.type';
|
|
|
14
14
|
import type { ClipboardServiceInterface, FileServiceInterface, MediaServiceInterface, NotificationServiceInterface, PlayerServiceInterface, RecorderServiceInterface } from '../platform/types';
|
|
15
15
|
import { ErrorBoundaryProps, LocalCacheStorage } from '../types';
|
|
16
16
|
export declare const SendbirdUIKit: Readonly<{
|
|
17
|
-
VERSION: "3.
|
|
17
|
+
VERSION: "3.11.1";
|
|
18
18
|
PLATFORM: string;
|
|
19
19
|
DEFAULT: {
|
|
20
20
|
AUTO_PUSH_TOKEN_REGISTRATION: boolean;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type * as ExpoAV from 'expo-av';
|
|
2
1
|
import type * as ExpoFS from 'expo-file-system';
|
|
3
2
|
import type * as ExpoImageManipulator from 'expo-image-manipulator';
|
|
4
3
|
import type * as ExpoVideoThumbnail from 'expo-video-thumbnails';
|
|
4
|
+
import type { ExpoVideoModule } from '../utils/expoBackwardUtils';
|
|
5
5
|
import type { MediaServiceInterface } from './types';
|
|
6
6
|
type Modules = {
|
|
7
|
-
avModule:
|
|
7
|
+
avModule: ExpoVideoModule;
|
|
8
8
|
thumbnailModule: typeof ExpoVideoThumbnail;
|
|
9
9
|
imageManipulator: typeof ExpoImageManipulator;
|
|
10
10
|
fsModule: typeof ExpoFS;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { ExpoAudioModule } from '../utils/expoBackwardUtils';
|
|
2
2
|
import type { PlayerServiceInterface } from './types';
|
|
3
3
|
type Modules = {
|
|
4
|
-
avModule:
|
|
4
|
+
avModule: ExpoAudioModule;
|
|
5
5
|
};
|
|
6
6
|
declare const createExpoPlayerService: ({ avModule }: Modules) => PlayerServiceInterface;
|
|
7
7
|
export default createExpoPlayerService;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type * as
|
|
1
|
+
import type * as LegacyModule from 'react-native-audio-recorder-player';
|
|
2
|
+
import type * as NitroSoundOrLegacyV4Module from 'react-native-nitro-sound';
|
|
2
3
|
import * as Permissions from 'react-native-permissions';
|
|
3
4
|
import type { PlayerServiceInterface } from './types';
|
|
5
|
+
export type AudioPlayerModule = typeof LegacyModule | typeof NitroSoundOrLegacyV4Module;
|
|
4
6
|
type Modules = {
|
|
5
|
-
audioRecorderModule:
|
|
7
|
+
audioRecorderModule: AudioPlayerModule;
|
|
6
8
|
permissionModule: typeof Permissions;
|
|
7
9
|
};
|
|
8
|
-
declare const createNativePlayerService: (
|
|
10
|
+
declare const createNativePlayerService: (modules: Modules) => PlayerServiceInterface;
|
|
9
11
|
export default createNativePlayerService;
|