@sendbird/uikit-react-native 3.10.3 → 3.11.0
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 +2 -2
- 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/createPlayerService.native.js +191 -114
- package/lib/commonjs/platform/createPlayerService.native.js.map +1 -1
- package/lib/commonjs/platform/createRecorderService.expo.js +3 -0
- 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/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/createPlayerService.native.js +191 -114
- package/lib/module/platform/createPlayerService.native.js.map +1 -1
- package/lib/module/platform/createRecorderService.expo.js +3 -0
- 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/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/createPlayerService.native.d.ts +5 -3
- 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/version.d.ts +1 -1
- package/package.json +18 -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/createPlayerService.native.tsx +237 -113
- package/src/platform/createRecorderService.expo.tsx +4 -0
- package/src/platform/createRecorderService.native.tsx +240 -118
- package/src/platform/types.ts +5 -0
- package/src/version.ts +1 -1
|
@@ -12,150 +12,233 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
|
|
|
12
12
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
13
13
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
14
14
|
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
15
|
-
|
|
16
|
-
audioRecorderModule
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
class AudioRecorderPlayerAdapter {
|
|
16
|
+
constructor(audioRecorderModule) {
|
|
17
|
+
_defineProperty(this, "module", void 0);
|
|
18
|
+
_defineProperty(this, "audioOptions", void 0);
|
|
19
|
+
this.module = new audioRecorderModule.default();
|
|
20
|
+
this.audioOptions = _reactNative.Platform.select({
|
|
21
|
+
android: {
|
|
22
|
+
AudioEncodingBitRateAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.BIT_RATE,
|
|
23
|
+
AudioChannelsAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.CHANNELS,
|
|
24
|
+
AudioSamplingRateAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
25
|
+
AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,
|
|
26
|
+
OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,
|
|
27
|
+
AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION
|
|
28
|
+
},
|
|
29
|
+
ios: {
|
|
30
|
+
AVEncoderBitRateKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.BIT_RATE,
|
|
31
|
+
AVNumberOfChannelsKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.CHANNELS,
|
|
32
|
+
AVSampleRateKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
33
|
+
AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4,
|
|
34
|
+
// same with aac
|
|
35
|
+
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
36
|
+
},
|
|
37
|
+
default: {}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
async setSubscriptionDuration(duration) {
|
|
41
|
+
await this.module.setSubscriptionDuration(duration);
|
|
42
|
+
}
|
|
43
|
+
addRecordBackListener(callback) {
|
|
44
|
+
this.module.addRecordBackListener(callback);
|
|
45
|
+
}
|
|
46
|
+
convertRecordPath(uri) {
|
|
47
|
+
return _reactNative.Platform.OS === 'ios' ? uri.split('/').pop() || uri : uri;
|
|
48
|
+
}
|
|
49
|
+
async startRecorder(uri) {
|
|
50
|
+
await this.module.startRecorder(uri, this.audioOptions);
|
|
51
|
+
}
|
|
52
|
+
async stopRecorder() {
|
|
53
|
+
await this.module.stopRecorder();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class NitroSoundOrLegacyV4Adapter {
|
|
57
|
+
constructor(audioRecorderModule) {
|
|
58
|
+
_defineProperty(this, "module", void 0);
|
|
59
|
+
_defineProperty(this, "audioOptions", void 0);
|
|
60
|
+
this.module = audioRecorderModule.default;
|
|
61
|
+
this.audioOptions = _reactNative.Platform.select({
|
|
62
|
+
android: {
|
|
63
|
+
AudioEncodingBitRateAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.BIT_RATE,
|
|
64
|
+
AudioChannelsAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.CHANNELS,
|
|
65
|
+
AudioSamplingRateAndroid: _VoiceMessageConfig.default.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
66
|
+
AudioEncoderAndroid: audioRecorderModule.AudioEncoderAndroidType.AAC,
|
|
67
|
+
OutputFormatAndroid: audioRecorderModule.OutputFormatAndroidType.MPEG_4,
|
|
68
|
+
AudioSourceAndroid: audioRecorderModule.AudioSourceAndroidType.VOICE_RECOGNITION
|
|
69
|
+
},
|
|
70
|
+
ios: {
|
|
71
|
+
AVEncoderBitRateKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.BIT_RATE,
|
|
72
|
+
AVNumberOfChannelsKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.CHANNELS,
|
|
73
|
+
AVSampleRateKeyIOS: _VoiceMessageConfig.default.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
74
|
+
AVFormatIDKeyIOS: 'mp4',
|
|
75
|
+
// same with aac
|
|
76
|
+
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
77
|
+
},
|
|
78
|
+
default: {}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
setSubscriptionDuration(duration) {
|
|
82
|
+
try {
|
|
83
|
+
this.module.setSubscriptionDuration(duration);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
_uikitUtils.Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
addRecordBackListener(callback) {
|
|
89
|
+
this.module.addRecordBackListener(callback);
|
|
90
|
+
}
|
|
91
|
+
convertRecordPath(uri) {
|
|
92
|
+
return uri;
|
|
93
|
+
}
|
|
94
|
+
async startRecorder(uri) {
|
|
95
|
+
await this.module.startRecorder(uri, this.audioOptions);
|
|
96
|
+
}
|
|
97
|
+
async stopRecorder() {
|
|
98
|
+
await this.module.stopRecorder();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
class VoiceRecorder {
|
|
102
|
+
constructor(adapter, permissionModule) {
|
|
103
|
+
this.adapter = adapter;
|
|
104
|
+
this.permissionModule = permissionModule;
|
|
105
|
+
_defineProperty(this, "uri", undefined);
|
|
106
|
+
_defineProperty(this, "state", 'idle');
|
|
107
|
+
_defineProperty(this, "options", {
|
|
108
|
+
minDuration: _VoiceMessageConfig.default.DEFAULT.RECORDER.MIN_DURATION,
|
|
109
|
+
maxDuration: _VoiceMessageConfig.default.DEFAULT.RECORDER.MAX_DURATION,
|
|
110
|
+
extension: _VoiceMessageConfig.default.DEFAULT.RECORDER.EXTENSION
|
|
111
|
+
});
|
|
112
|
+
_defineProperty(this, "_recordStartedAt", 0);
|
|
113
|
+
_defineProperty(this, "_stopping", false);
|
|
114
|
+
_defineProperty(this, "recordingSubscribers", new Set());
|
|
115
|
+
_defineProperty(this, "stateSubscribers", new Set());
|
|
116
|
+
_defineProperty(this, "setState", state => {
|
|
117
|
+
this.state = state;
|
|
118
|
+
this.stateSubscribers.forEach(callback => {
|
|
119
|
+
callback(state);
|
|
43
120
|
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
ios:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
AVSampleRateKeyIOS: this.audioSettings.sampleRate,
|
|
57
|
-
AVFormatIDKeyIOS: audioRecorderModule.AVEncodingOption.mp4,
|
|
58
|
-
// same with aac
|
|
59
|
-
AVEncoderAudioQualityKeyIOS: audioRecorderModule.AVEncoderAudioQualityIOSType.high
|
|
60
|
-
},
|
|
61
|
-
default: {}
|
|
62
|
-
}));
|
|
63
|
-
_defineProperty(this, "setState", state => {
|
|
64
|
-
this.state = state;
|
|
65
|
-
this.stateSubscribers.forEach(callback => {
|
|
66
|
-
callback(state);
|
|
67
|
-
});
|
|
121
|
+
});
|
|
122
|
+
_defineProperty(this, "getRecorderStopSafeBuffer", () => {
|
|
123
|
+
const minWaitingTime = 500;
|
|
124
|
+
const elapsedTime = Date.now() - this._recordStartedAt;
|
|
125
|
+
if (elapsedTime > minWaitingTime) return 0;else return minWaitingTime - elapsedTime;
|
|
126
|
+
});
|
|
127
|
+
_defineProperty(this, "requestPermission", async () => {
|
|
128
|
+
const permission = _reactNative.Platform.select({
|
|
129
|
+
android: [this.permissionModule.PERMISSIONS.ANDROID.RECORD_AUDIO],
|
|
130
|
+
ios: [this.permissionModule.PERMISSIONS.IOS.MICROPHONE],
|
|
131
|
+
windows: [this.permissionModule.PERMISSIONS.WINDOWS.MICROPHONE],
|
|
132
|
+
default: undefined
|
|
68
133
|
});
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
if (_reactNative.Platform.OS === 'android' && _reactNative.Platform.Version <= 28) {
|
|
77
|
-
permission === null || permission === void 0 || permission.push(permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
|
|
78
|
-
}
|
|
79
|
-
if (permission) {
|
|
80
|
-
const status = await permissionModule.checkMultiple(permission);
|
|
81
|
-
if ((0, _nativePermissionGranted.default)(status)) {
|
|
82
|
-
return true;
|
|
83
|
-
} else {
|
|
84
|
-
const status = await permissionModule.requestMultiple(permission);
|
|
85
|
-
return (0, _nativePermissionGranted.default)(status);
|
|
86
|
-
}
|
|
87
|
-
} else {
|
|
134
|
+
if (_reactNative.Platform.OS === 'android' && _reactNative.Platform.Version <= 28) {
|
|
135
|
+
permission === null || permission === void 0 || permission.push(this.permissionModule.PERMISSIONS.ANDROID.WRITE_EXTERNAL_STORAGE);
|
|
136
|
+
}
|
|
137
|
+
if (permission) {
|
|
138
|
+
const status = await this.permissionModule.checkMultiple(permission);
|
|
139
|
+
if ((0, _nativePermissionGranted.default)(status)) {
|
|
88
140
|
return true;
|
|
141
|
+
} else {
|
|
142
|
+
const status = await this.permissionModule.requestMultiple(permission);
|
|
143
|
+
return (0, _nativePermissionGranted.default)(status);
|
|
89
144
|
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
this.uri = uri;
|
|
114
|
-
this.setState('recording');
|
|
115
|
-
} catch (e) {
|
|
116
|
-
this.setState('idle');
|
|
117
|
-
throw e;
|
|
145
|
+
} else {
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
_defineProperty(this, "addRecordingListener", callback => {
|
|
150
|
+
this.recordingSubscribers.add(callback);
|
|
151
|
+
return () => {
|
|
152
|
+
this.recordingSubscribers.delete(callback);
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
_defineProperty(this, "addStateListener", callback => {
|
|
156
|
+
this.stateSubscribers.add(callback);
|
|
157
|
+
return () => {
|
|
158
|
+
this.stateSubscribers.delete(callback);
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
_defineProperty(this, "record", async uri => {
|
|
162
|
+
if ((0, _uikitUtils.matchesOneOf)(this.state, ['idle', 'completed'])) {
|
|
163
|
+
try {
|
|
164
|
+
this.setState('preparing');
|
|
165
|
+
await this.adapter.startRecorder(uri);
|
|
166
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
167
|
+
this._recordStartedAt = Date.now();
|
|
118
168
|
}
|
|
169
|
+
this.uri = uri;
|
|
170
|
+
this.setState('recording');
|
|
171
|
+
} catch (e) {
|
|
172
|
+
this.setState('idle');
|
|
173
|
+
throw e;
|
|
119
174
|
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
_defineProperty(this, "stop", async () => {
|
|
178
|
+
if ((0, _uikitUtils.matchesOneOf)(this.state, ['recording']) && !this._stopping) {
|
|
179
|
+
this._stopping = true;
|
|
180
|
+
try {
|
|
123
181
|
if (_reactNative.Platform.OS === 'android') {
|
|
124
|
-
const buffer = this.
|
|
182
|
+
const buffer = this.getRecorderStopSafeBuffer();
|
|
125
183
|
if (buffer > 0) await (0, _uikitUtils.sleep)(buffer);
|
|
126
184
|
}
|
|
127
|
-
await
|
|
185
|
+
await this.adapter.stopRecorder();
|
|
128
186
|
this.setState('completed');
|
|
187
|
+
} catch (error) {
|
|
188
|
+
_uikitUtils.Logger.error('[RecorderService.Native] Failed to stop recorder', error);
|
|
189
|
+
throw error;
|
|
190
|
+
} finally {
|
|
191
|
+
this._stopping = false;
|
|
129
192
|
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
_defineProperty(this, "reset", async () => {
|
|
196
|
+
await this.stop();
|
|
197
|
+
this.uri = undefined;
|
|
198
|
+
this.recordingSubscribers.clear();
|
|
199
|
+
this.setState('idle');
|
|
200
|
+
});
|
|
201
|
+
_defineProperty(this, "convertRecordPath", uri => {
|
|
202
|
+
return this.adapter.convertRecordPath(uri);
|
|
203
|
+
});
|
|
204
|
+
this.initialize();
|
|
205
|
+
}
|
|
206
|
+
initialize() {
|
|
207
|
+
const setDurationResult = this.adapter.setSubscriptionDuration(0.1);
|
|
208
|
+
if (setDurationResult instanceof Promise) {
|
|
209
|
+
setDurationResult.catch(error => {
|
|
138
210
|
_uikitUtils.Logger.warn('[RecorderService.Native] Failed to set subscription duration', error);
|
|
139
211
|
});
|
|
140
|
-
module.addRecordBackListener(data => {
|
|
141
|
-
const completed = data.currentPosition >= this.options.maxDuration;
|
|
142
|
-
if (completed) {
|
|
143
|
-
this.stop().catch(error => {
|
|
144
|
-
_uikitUtils.Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
if (this.state === 'recording') {
|
|
148
|
-
this.recordingSubscribers.forEach(callback => {
|
|
149
|
-
callback({
|
|
150
|
-
currentTime: data.currentPosition,
|
|
151
|
-
completed
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
212
|
}
|
|
213
|
+
this.adapter.addRecordBackListener(data => {
|
|
214
|
+
const completed = data.currentPosition >= this.options.maxDuration;
|
|
215
|
+
if (completed) {
|
|
216
|
+
this.stop().catch(error => {
|
|
217
|
+
_uikitUtils.Logger.warn('[RecorderService.Native] Failed to stop in RecordBackListener', error);
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
if (this.state === 'recording') {
|
|
221
|
+
this.recordingSubscribers.forEach(callback => {
|
|
222
|
+
callback({
|
|
223
|
+
currentTime: data.currentPosition,
|
|
224
|
+
completed
|
|
225
|
+
});
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
});
|
|
157
229
|
}
|
|
158
|
-
|
|
230
|
+
}
|
|
231
|
+
const createNativeRecorderService = modules => {
|
|
232
|
+
const adapter = isNitroSoundOrLegacyV4Module(modules.audioRecorderModule) ? new NitroSoundOrLegacyV4Adapter(modules.audioRecorderModule) : new AudioRecorderPlayerAdapter(modules.audioRecorderModule);
|
|
233
|
+
return new VoiceRecorder(adapter, modules.permissionModule);
|
|
159
234
|
};
|
|
235
|
+
function isNitroSoundOrLegacyV4Module(module) {
|
|
236
|
+
const isNitroSound = 'createSound' in module && typeof module.createSound === 'function';
|
|
237
|
+
const isLegacyV4 = 'default' in module && 'getHybridObject' in module.default && typeof module.default.getHybridObject === 'function';
|
|
238
|
+
if (isLegacyV4) {
|
|
239
|
+
_uikitUtils.Logger.warn('react-native-audio-recorder-player is deprecated. Please use react-native-nitro-sound instead.');
|
|
240
|
+
}
|
|
241
|
+
return isNitroSound || isLegacyV4;
|
|
242
|
+
}
|
|
160
243
|
var _default = exports.default = createNativeRecorderService;
|
|
161
244
|
//# sourceMappingURL=createRecorderService.native.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_uikitUtils","_VoiceMessageConfig","_interopRequireDefault","_nativePermissionGranted","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","createNativeRecorderService","audioRecorderModule","permissionModule","module","VoiceRecorder","constructor","undefined","minDuration","VoiceMessageConfig","DEFAULT","RECORDER","MIN_DURATION","maxDuration","MAX_DURATION","extension","EXTENSION","minWaitingTime","elapsedTime","Date","now","_recordStartedAt","Set","sampleRate","SAMPLE_RATE","bitRate","BIT_RATE","audioChannels","CHANNELS","Platform","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","nativePermissionGranted","requestMultiple","recordingSubscribers","add","delete","uri","matchesOneOf","setState","startRecorder","audioOptions","buffer","_getRecorderStopSafeBuffer","sleep","stopRecorder","stop","clear","setSubscriptionDuration","catch","error","Logger","warn","addRecordBackListener","data","completed","currentPosition","options","currentTime","_default","exports"],"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,IAAAA,YAAA,GAAAC,OAAA;AAKA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAAuE,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CA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AAK;QACrC,MAAMC,SAAS,GAAGD,IAAI,CAACE,eAAe,IAAI,IAAI,CAACC,OAAO,CAACrF,WAAW;QAElE,IAAImF,SAAS,EAAE;UACb,IAAI,CAACT,IAAI,CAAC,CAAC,CAACG,KAAK,CAAEC,KAAK,IAAK;YAC3BC,kBAAM,CAACC,IAAI,CAAC,+DAA+D,EAAEF,KAAK,CAAC;UACrF,CAAC,CAAC;QACJ;QACA,IAAI,IAAI,CAACpC,KAAK,KAAK,WAAW,EAAE;UAC9B,IAAI,CAACoB,oBAAoB,CAAClB,OAAO,CAAEC,QAAQ,IAAK;YAC9CA,QAAQ,CAAC;cAAEyC,WAAW,EAAEJ,IAAI,CAACE,eAAe;cAAED;YAAU,CAAC,CAAC;UAC5D,CAAC,CAAC;QACJ;MACF,CAAC,CAAC;IACJ;EAuFF;EAEA,OAAO,IAAI3F,aAAa,CAAC,CAAC;AAC5B,CAAC;AAAC,IAAA+F,QAAA,GAAAC,OAAA,CAAAvH,OAAA,GAEamB,2BAA2B","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_uikitUtils","_VoiceMessageConfig","_interopRequireDefault","_nativePermissionGranted","e","__esModule","default","_defineProperty","r","t","_toPropertyKey","Object","defineProperty","value","enumerable","configurable","writable","i","_toPrimitive","Symbol","toPrimitive","call","TypeError","String","Number","AudioRecorderPlayerAdapter","constructor","audioRecorderModule","module","audioOptions","Platform","select","android","AudioEncodingBitRateAndroid","VoiceMessageConfig","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","Logger","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","nativePermissionGranted","requestMultiple","recordingSubscribers","add","delete","matchesOneOf","setState","_stopping","buffer","getRecorderStopSafeBuffer","sleep","stop","clear","initialize","setDurationResult","Promise","catch","data","completed","currentPosition","options","currentTime","createNativeRecorderService","modules","isNitroSoundOrLegacyV4Module","isNitroSound","createSound","isLegacyV4","getHybridObject","_default","exports"],"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,IAAAA,YAAA,GAAAC,OAAA;AAMA,IAAAC,WAAA,GAAAD,OAAA;AAEA,IAAAE,mBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,wBAAA,GAAAD,sBAAA,CAAAH,OAAA;AAAuE,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,gBAAAH,CAAA,EAAAI,CAAA,EAAAC,CAAA,YAAAD,CAAA,GAAAE,cAAA,CAAAF,CAAA,MAAAJ,CAAA,GAAAO,MAAA,CAAAC,cAAA,CAAAR,CAAA,EAAAI,CAAA,IAAAK,KAAA,EAAAJ,CAAA,EAAAK,UAAA,MAAAC,YAAA,MAAAC,QAAA,UAAAZ,CAAA,CAAAI,CAAA,IAAAC,CAAA,EAAAL,CAAA;AAAA,SAAAM,eAAAD,CAAA,QAAAQ,CAAA,GAAAC,YAAA,CAAAT,CAAA,uCAAAQ,CAAA,GAAAA,CAAA,GAAAA,CAAA;AAAA,SAAAC,aAAAT,CAAA,EAAAD,CAAA,2BAAAC,CAAA,KAAAA,CAAA,SAAAA,CAAA,MAAAL,CAAA,GAAAK,CAAA,CAAAU,MAAA,CAAAC,WAAA,kBAAAhB,CAAA,QAAAa,CAAA,GAAAb,CAAA,CAAAiB,IAAA,CAAAZ,CAAA,EAAAD,CAAA,uCAAAS,CAAA,SAAAA,CAAA,YAAAK,SAAA,yEAAAd,CAAA,GAAAe,MAAA,GAAAC,MAAA,EAAAf,CAAA;AAyBvE,MAAMgB,0BAA0B,CAAkC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,4BAA4BA,CAACxG,MAA2B,EAA+C;EAC9G,MAAMyG,YAAY,GAAG,aAAa,IAAIzG,MAAM,IAAI,OAAOA,MAAM,CAAC0G,WAAW,KAAK,UAAU;EACxF,MAAMC,UAAU,GACd,SAAS,IAAI3G,MAAM,IAAI,iBAAiB,IAAIA,MAAM,CAACtB,OAAO,IAAI,OAAOsB,MAAM,CAACtB,OAAO,CAACkI,eAAe,KAAK,UAAU;EACpH,IAAID,UAAU,EAAE;IACd7D,kBAAM,CAACC,IAAI,CAAC,gGAAgG,CAAC;EAC/G;EACA,OAAO0D,YAAY,IAAIE,UAAU;AACnC;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAApI,OAAA,GAEc4H,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":[]}
|
package/lib/commonjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["VERSION","_default","exports","default"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.
|
|
1
|
+
{"version":3,"names":["VERSION","_default","exports","default"],"sources":["version.ts"],"sourcesContent":["const VERSION = '3.11.0';\nexport default VERSION;\n"],"mappings":";;;;;;AAAA,MAAMA,OAAO,GAAG,QAAQ;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACVH,OAAO","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","Animated","Box","Icon","PressBox","ProgressBar","Text","createStyleSheet","useUIKitTheme","Logger","conditionChaining","millsToMMSS","useLocalization","useVoiceMessageInput","VoiceMessageInput","onClose","onSend","STRINGS","colors","actions","state","file","duration","uiColors","ui","voiceMessageInput","default","status","onPressCancel","cancel","catch","error","warn","finally","onPressSend","send","onPressVoiceMessageAction","startRecording","lessThanMinimumDuration","stopRecording","playPlayer","pausePlayer","renderActionIcon","createElement","icon","size","color","recording","actionIcon","isRecorderState","recordingTime","currentTime","minDuration","remainingTime","playingTime","backgroundColor","background","paddingVertical","paddingHorizontal","style","styles","container","progressBar","current","total","maxDuration","trackColor","progressTrack","overlay","flex","flexDirection","alignItems","justifyContent","paddingEnd","RecordingLight","visible","caption1","lineHeight","undefined","marginStart","textTime","height","CancelButton","label","LABELS","VOICE_MESSAGE_INPUT_CANCEL","onPress","SendButton","disabled","position","activeOpacity","width","borderRadius","actionIconBackground","props","value","Value","animation","loop","sequence","timing","toValue","useNativeDriver","start","reset","View","opacity","active","button","textCancel","numberOfLines","sendIconBackground","padding","sendIcon","borderTopStartRadius","borderTopEndRadius","marginBottom"],"sources":["VoiceMessageInput.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Animated } from 'react-native';\n\nimport {\n Box,\n Icon,\n PressBox,\n ProgressBar,\n Text,\n createStyleSheet,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport { Logger, conditionChaining, millsToMMSS } from '@sendbird/uikit-utils';\n\nimport { useLocalization } from '../../hooks/useContext';\nimport useVoiceMessageInput from '../../hooks/useVoiceMessageInput';\nimport type { FileType } from '../../platform/types';\n\nexport type VoiceMessageInputProps = {\n onClose: () => Promise<void>;\n onSend: (params: { file: FileType; duration: number }) => void;\n};\n\nconst VoiceMessageInput = ({ onClose, onSend }: VoiceMessageInputProps) => {\n const { STRINGS } = useLocalization();\n const { colors } = useUIKitTheme();\n const { actions, state } = useVoiceMessageInput({\n onSend: (file, duration) => onSend({ file, duration }),\n onClose,\n });\n\n const uiColors = colors.ui.voiceMessageInput.default[state.status !== 'idle' ? 'active' : 'inactive'];\n\n const onPressCancel = async () => {\n await actions\n .cancel()\n .catch((error) => {\n Logger.warn('Failed to cancel voice message input', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n const onPressSend = async () => {\n await actions\n .send()\n .catch((error) => {\n Logger.warn('Failed to send voice message', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n const onPressVoiceMessageAction = async () => {\n try {\n switch (state.status) {\n case 'idle':\n await actions.startRecording();\n break;\n case 'recording':\n if (lessThanMinimumDuration) {\n await actions.cancel();\n } else {\n await actions.stopRecording();\n }\n break;\n case 'recording_completed':\n case 'playing_paused':\n await actions.playPlayer();\n break;\n case 'playing':\n await actions.pausePlayer();\n break;\n }\n } catch (error) {\n Logger.warn('Failed to run voice message action.', state);\n }\n };\n const renderActionIcon = () => {\n switch (state.status) {\n case 'idle':\n return <Icon icon={'recording'} size={20} color={uiColors.recording} />;\n case 'recording':\n return <Icon icon={'stop'} size={20} color={uiColors.actionIcon} />;\n case 'recording_completed':\n case 'playing_paused':\n return <Icon icon={'play'} size={20} color={uiColors.actionIcon} />;\n case 'playing':\n return <Icon icon={'pause'} size={20} color={uiColors.actionIcon} />;\n }\n };\n\n const isRecorderState = state.status === 'recording' || state.status === 'recording_completed';\n const lessThanMinimumDuration = state.recordingTime.currentTime < state.recordingTime.minDuration;\n const remainingTime = state.playingTime.duration - state.playingTime.currentTime;\n\n return (\n <Box backgroundColor={uiColors.background} paddingVertical={24} paddingHorizontal={16} style={styles.container}>\n {/** Progress bar **/}\n <ProgressBar\n style={styles.progressBar}\n current={conditionChaining(\n [state.status === 'recording', state.status === 'recording_completed'],\n [state.recordingTime.currentTime, 0, state.playingTime.currentTime],\n )}\n total={(isRecorderState ? state.recordingTime.maxDuration : state.playingTime.duration) || 1}\n trackColor={uiColors.progressTrack}\n overlay={\n <Box flex={1} flexDirection={'row'} alignItems={'center'} justifyContent={'flex-end'} paddingEnd={16}>\n <RecordingLight visible={state.status === 'recording'} />\n <Text caption1 style={{ lineHeight: undefined, marginStart: 6 }} color={uiColors.textTime}>\n {millsToMMSS(isRecorderState ? state.recordingTime.currentTime : remainingTime)}\n </Text>\n </Box>\n }\n />\n\n <Box height={34} alignItems={'center'} justifyContent={'center'}>\n {/** Cancel / Send **/}\n <Box flexDirection={'row'}>\n <CancelButton label={STRINGS.LABELS.VOICE_MESSAGE_INPUT_CANCEL} onPress={onPressCancel} />\n <Box flex={1} />\n <SendButton disabled={state.status === 'idle' || lessThanMinimumDuration} onPress={onPressSend} />\n </Box>\n\n {/** Record / Stop / Play / Pause **/}\n <Box style={{ position: 'absolute' }} alignItems={'center'} justifyContent={'center'}>\n <PressBox activeOpacity={0.5} onPress={onPressVoiceMessageAction}>\n <Box\n width={34}\n height={34}\n borderRadius={17}\n alignItems={'center'}\n justifyContent={'center'}\n backgroundColor={uiColors.actionIconBackground}\n >\n {renderActionIcon()}\n </Box>\n </PressBox>\n </Box>\n </Box>\n </Box>\n );\n};\n\nconst RecordingLight = (props: { visible: boolean }) => {\n const { colors } = useUIKitTheme();\n\n const value = useRef(new Animated.Value(0)).current;\n const animation = useRef(\n Animated.loop(\n Animated.sequence([\n Animated.timing(value, { toValue: 1, duration: 500, useNativeDriver: true }),\n Animated.timing(value, { toValue: 0, duration: 500, useNativeDriver: true }),\n ]),\n ),\n ).current;\n\n useEffect(() => {\n if (props.visible) animation.start();\n return () => {\n animation.reset();\n };\n }, [props.visible]);\n\n if (!props.visible) return null;\n return (\n <Animated.View\n style={{\n width: 12,\n height: 12,\n borderRadius: 6,\n opacity: value,\n backgroundColor: colors.ui.voiceMessageInput.default.active.recording,\n }}\n />\n );\n};\n\nconst CancelButton = (props: { onPress: () => void; label: string }) => {\n const { colors } = useUIKitTheme();\n\n return (\n <PressBox activeOpacity={0.8} onPress={props.onPress}>\n <Box paddingHorizontal={12} height={'100%'} alignItems={'center'} justifyContent={'center'}>\n <Text button color={colors.ui.voiceMessageInput.default.active.textCancel} numberOfLines={1}>\n {props.label}\n </Text>\n </Box>\n </PressBox>\n );\n};\n\nconst SendButton = (props: { onPress: () => void; disabled: boolean }) => {\n const { colors } = useUIKitTheme();\n\n const uiColors = colors.ui.voiceMessageInput.default[props.disabled ? 'inactive' : 'active'];\n\n return (\n <PressBox disabled={props.disabled} activeOpacity={0.8} onPress={props.onPress}>\n <Box backgroundColor={uiColors.sendIconBackground} padding={7} borderRadius={40}>\n <Icon icon={'send'} size={20} color={uiColors.sendIcon} />\n </Box>\n </PressBox>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n },\n progressBar: {\n height: 36,\n marginBottom: 16,\n borderRadius: 18,\n },\n});\n\nexport default VoiceMessageInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SACEC,GAAG,EACHC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,gBAAgB,EAChBC,aAAa,QACR,yCAAyC;AAChD,SAASC,MAAM,EAAEC,iBAAiB,EAAEC,WAAW,QAAQ,uBAAuB;AAE9E,SAASC,eAAe,QAAQ,wBAAwB;AACxD,OAAOC,oBAAoB,MAAM,kCAAkC;AAQnE,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAA+B,CAAC,KAAK;EACzE,MAAM;IAAEC;EAAQ,CAAC,GAAGL,eAAe,CAAC,CAAC;EACrC,MAAM;IAAEM;EAAO,CAAC,GAAGV,aAAa,CAAC,CAAC;EAClC,MAAM;IAAEW,OAAO;IAAEC;EAAM,CAAC,GAAGP,oBAAoB,CAAC;IAC9CG,MAAM,EAAEA,CAACK,IAAI,EAAEC,QAAQ,KAAKN,MAAM,CAAC;MAAEK,IAAI;MAAEC;IAAS,CAAC,CAAC;IACtDP;EACF,CAAC,CAAC;EAEF,MAAMQ,QAAQ,GAAGL,MAAM,CAACM,EAAE,CAACC,iBAAiB,CAACC,OAAO,CAACN,KAAK,CAACO,MAAM,KAAK,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;EAErG,MAAMC,aAAa,GAAG,MAAAA,CAAA,KAAY;IAChC,MAAMT,OAAO,CACVU,MAAM,CAAC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ACiF,MAAM,CAACE,UAAW;IAACC,aAAa,EAAE;EAAE,GACzFhB,KAAK,CAACX,KACH,CACH,CACG,CAAC;AAEf,CAAC;AAED,MAAMI,UAAU,GAAIO,KAAiD,IAAK;EACxE,MAAM;IAAE5E;EAAO,CAAC,GAAGV,aAAa,CAAC,CAAC;EAElC,MAAMe,QAAQ,GAAGL,MAAM,CAACM,EAAE,CAACC,iBAAiB,CAACC,OAAO,CAACoE,KAAK,CAACN,QAAQ,GAAG,UAAU,GAAG,QAAQ,CAAC;EAE5F,oBACE1F,KAAA,CAAA6C,aAAA,CAACvC,QAAQ;IAACoF,QAAQ,EAAEM,KAAK,CAACN,QAAS;IAACE,aAAa,EAAE,GAAI;IAACJ,OAAO,EAAEQ,KAAK,CAACR;EAAQ,gBAC7ExF,KAAA,CAAA6C,aAAA,CAACzC,GAAG;IAACqD,eAAe,EAAEhC,QAAQ,CAACwF,kBAAmB;IAACC,OAAO,EAAE,CAAE;IAACpB,YAAY,EAAE;EAAG,gBAC9E9F,KAAA,CAAA6C,aAAA,CAACxC,IAAI;IAACyC,IAAI,EAAE,MAAO;IAACC,IAAI,EAAE,EAAG;IAACC,KAAK,EAAEvB,QAAQ,CAAC0F;EAAS,CAAE,CACtD,CACG,CAAC;AAEf,CAAC;AAED,MAAMrD,MAAM,GAAGrD,gBAAgB,CAAC;EAC9BsD,SAAS,EAAE;IACTqD,oBAAoB,EAAE,CAAC;IACvBC,kBAAkB,EAAE;EACtB,CAAC;EACDrD,WAAW,EAAE;IACXmB,MAAM,EAAE,EAAE;IACVmC,YAAY,EAAE,EAAE;IAChBxB,YAAY,EAAE;EAChB;AACF,CAAC,CAAC;AAEF,eAAe9E,iBAAiB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","Animated","Box","Icon","PressBox","ProgressBar","Text","createStyleSheet","useUIKitTheme","Logger","conditionChaining","millsToMMSS","useLocalization","useVoiceMessageInput","VoiceMessageInput","onClose","onSend","STRINGS","colors","actions","state","file","duration","uiColors","ui","voiceMessageInput","default","status","onPressCancel","cancel","catch","error","warn","finally","onPressSend","send","onPressVoiceMessageAction","startRecording","lessThanMinimumDuration","stopRecording","playPlayer","pausePlayer","renderActionIcon","createElement","icon","size","color","recording","actionIcon","isRecorderState","recordingTime","currentTime","minDuration","remainingTime","playingTime","backgroundColor","background","paddingVertical","paddingHorizontal","style","styles","container","progressBar","current","total","maxDuration","trackColor","progressTrack","overlay","flex","flexDirection","alignItems","justifyContent","paddingEnd","RecordingLight","visible","caption1","lineHeight","undefined","marginStart","textTime","height","CancelButton","label","LABELS","VOICE_MESSAGE_INPUT_CANCEL","onPress","SendButton","disabled","position","activeOpacity","width","borderRadius","actionIconBackground","props","value","Value","animation","loop","sequence","timing","toValue","useNativeDriver","start","reset","View","opacity","active","button","textCancel","numberOfLines","sendIconBackground","padding","sendIcon","borderTopStartRadius","borderTopEndRadius","marginBottom"],"sources":["VoiceMessageInput.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport { Animated } from 'react-native';\n\nimport {\n Box,\n Icon,\n PressBox,\n ProgressBar,\n Text,\n createStyleSheet,\n useUIKitTheme,\n} from '@sendbird/uikit-react-native-foundation';\nimport { Logger, conditionChaining, millsToMMSS } from '@sendbird/uikit-utils';\n\nimport { useLocalization } from '../../hooks/useContext';\nimport useVoiceMessageInput from '../../hooks/useVoiceMessageInput';\nimport type { FileType } from '../../platform/types';\n\nexport type VoiceMessageInputProps = {\n onClose: () => Promise<void>;\n onSend: (params: { file: FileType; duration: number }) => void;\n};\n\nconst VoiceMessageInput = ({ onClose, onSend }: VoiceMessageInputProps) => {\n const { STRINGS } = useLocalization();\n const { colors } = useUIKitTheme();\n const { actions, state } = useVoiceMessageInput({\n onSend: (file, duration) => onSend({ file, duration }),\n onClose,\n });\n\n const uiColors = colors.ui.voiceMessageInput.default[state.status !== 'idle' ? 'active' : 'inactive'];\n\n const onPressCancel = async () => {\n await actions\n .cancel()\n .catch((error) => {\n Logger.warn('Failed to cancel voice message input', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n const onPressSend = async () => {\n await actions\n .send()\n .catch((error) => {\n Logger.warn('Failed to send voice message', error);\n })\n .finally(() => {\n onClose();\n });\n };\n\n const onPressVoiceMessageAction = async () => {\n try {\n switch (state.status) {\n case 'idle':\n await actions.startRecording();\n break;\n case 'recording':\n if (lessThanMinimumDuration) {\n await actions.cancel();\n } else {\n await actions.stopRecording();\n }\n break;\n case 'recording_completed':\n case 'playing_paused':\n await actions.playPlayer();\n break;\n case 'playing':\n await actions.pausePlayer();\n break;\n }\n } catch (error) {\n Logger.warn('Failed to run voice message action.', state, error);\n }\n };\n const renderActionIcon = () => {\n switch (state.status) {\n case 'idle':\n return <Icon icon={'recording'} size={20} color={uiColors.recording} />;\n case 'recording':\n return <Icon icon={'stop'} size={20} color={uiColors.actionIcon} />;\n case 'recording_completed':\n case 'playing_paused':\n return <Icon icon={'play'} size={20} color={uiColors.actionIcon} />;\n case 'playing':\n return <Icon icon={'pause'} size={20} color={uiColors.actionIcon} />;\n }\n };\n\n const isRecorderState = state.status === 'recording' || state.status === 'recording_completed';\n const lessThanMinimumDuration = state.recordingTime.currentTime < state.recordingTime.minDuration;\n const remainingTime = state.playingTime.duration - state.playingTime.currentTime;\n\n return (\n <Box backgroundColor={uiColors.background} paddingVertical={24} paddingHorizontal={16} style={styles.container}>\n {/** Progress bar **/}\n <ProgressBar\n style={styles.progressBar}\n current={conditionChaining(\n [state.status === 'recording', state.status === 'recording_completed'],\n [state.recordingTime.currentTime, 0, state.playingTime.currentTime],\n )}\n total={(isRecorderState ? state.recordingTime.maxDuration : state.playingTime.duration) || 1}\n trackColor={uiColors.progressTrack}\n overlay={\n <Box flex={1} flexDirection={'row'} alignItems={'center'} justifyContent={'flex-end'} paddingEnd={16}>\n <RecordingLight visible={state.status === 'recording'} />\n <Text caption1 style={{ lineHeight: undefined, marginStart: 6 }} color={uiColors.textTime}>\n {millsToMMSS(isRecorderState ? state.recordingTime.currentTime : remainingTime)}\n </Text>\n </Box>\n }\n />\n\n <Box height={34} alignItems={'center'} justifyContent={'center'}>\n {/** Cancel / Send **/}\n <Box flexDirection={'row'}>\n <CancelButton label={STRINGS.LABELS.VOICE_MESSAGE_INPUT_CANCEL} onPress={onPressCancel} />\n <Box flex={1} />\n <SendButton disabled={state.status === 'idle' || lessThanMinimumDuration} onPress={onPressSend} />\n </Box>\n\n {/** Record / Stop / Play / Pause **/}\n <Box style={{ position: 'absolute' }} alignItems={'center'} justifyContent={'center'}>\n <PressBox activeOpacity={0.5} onPress={onPressVoiceMessageAction}>\n <Box\n width={34}\n height={34}\n borderRadius={17}\n alignItems={'center'}\n justifyContent={'center'}\n backgroundColor={uiColors.actionIconBackground}\n >\n {renderActionIcon()}\n </Box>\n </PressBox>\n </Box>\n </Box>\n </Box>\n );\n};\n\nconst RecordingLight = (props: { visible: boolean }) => {\n const { colors } = useUIKitTheme();\n\n const value = useRef(new Animated.Value(0)).current;\n const animation = useRef(\n Animated.loop(\n Animated.sequence([\n Animated.timing(value, { toValue: 1, duration: 500, useNativeDriver: true }),\n Animated.timing(value, { toValue: 0, duration: 500, useNativeDriver: true }),\n ]),\n ),\n ).current;\n\n useEffect(() => {\n if (props.visible) animation.start();\n return () => {\n animation.reset();\n };\n }, [props.visible]);\n\n if (!props.visible) return null;\n return (\n <Animated.View\n style={{\n width: 12,\n height: 12,\n borderRadius: 6,\n opacity: value,\n backgroundColor: colors.ui.voiceMessageInput.default.active.recording,\n }}\n />\n );\n};\n\nconst CancelButton = (props: { onPress: () => void; label: string }) => {\n const { colors } = useUIKitTheme();\n\n return (\n <PressBox activeOpacity={0.8} onPress={props.onPress}>\n <Box paddingHorizontal={12} height={'100%'} alignItems={'center'} justifyContent={'center'}>\n <Text button color={colors.ui.voiceMessageInput.default.active.textCancel} numberOfLines={1}>\n {props.label}\n </Text>\n </Box>\n </PressBox>\n );\n};\n\nconst SendButton = (props: { onPress: () => void; disabled: boolean }) => {\n const { colors } = useUIKitTheme();\n\n const uiColors = colors.ui.voiceMessageInput.default[props.disabled ? 'inactive' : 'active'];\n\n return (\n <PressBox disabled={props.disabled} activeOpacity={0.8} onPress={props.onPress}>\n <Box backgroundColor={uiColors.sendIconBackground} padding={7} borderRadius={40}>\n <Icon icon={'send'} size={20} color={uiColors.sendIcon} />\n </Box>\n </PressBox>\n );\n};\n\nconst styles = createStyleSheet({\n container: {\n borderTopStartRadius: 8,\n borderTopEndRadius: 8,\n },\n progressBar: {\n height: 36,\n marginBottom: 16,\n borderRadius: 18,\n },\n});\n\nexport default VoiceMessageInput;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,SAASC,QAAQ,QAAQ,cAAc;AAEvC,SACEC,GAAG,EACHC,IAAI,EACJC,QAAQ,EACRC,WAAW,EACXC,IAAI,EACJC,gBAAgB,EAChBC,aAAa,QACR,yCAAyC;AAChD,SAASC,MAAM,EAAEC,iBAAiB,EAAEC,WAAW,QAAQ,uBAAuB;AAE9E,SAASC,eAAe,QAAQ,wBAAwB;AACxD,OAAOC,oBAAoB,MAAM,kCAAkC;AAQnE,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,OAAO;EAAEC;AAA+B,CAAC,KAAK;EACzE,MAAM;IAAEC;EAAQ,CAAC,GAAGL,eAAe,CAAC,CAAC;EACrC,MAAM;IAAEM;EAAO,CAAC,GAAGV,aAAa,CAAC,CAAC;EAClC,MAAM;IAAEW,OAAO;IAAEC;EAAM,CAAC,GAAGP,oBAAoB,CAAC;IAC9CG,MAAM,EAAEA,CAACK,IAAI,EAAEC,QAAQ,KAAKN,MAAM,CAAC;MAAEK,IAAI;MAAEC;IAAS,CAAC,CAAC;IACtDP;EACF,CAAC,CAAC;EAEF,MAAMQ,QAAQ,GAAGL,MAAM,CAACM,EAAE,CAACC,iBAAiB,CAACC,OAAO,CAACN,KAAK,CAACO,MAAM,KAAK,MAAM,GAAG,QAAQ,GAAG,UAAU,C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