@sendbird/uikit-react-native 3.11.0 → 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 +7 -5
- 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/createRecorderService.expo.js +248 -130
- package/lib/commonjs/platform/createRecorderService.expo.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/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/createRecorderService.expo.js +249 -131
- package/lib/module/platform/createRecorderService.expo.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/createRecorderService.expo.d.ts +2 -2
- 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 +16 -5
- package/src/platform/createMediaService.expo.tsx +87 -9
- package/src/platform/createPlayerService.expo.tsx +242 -109
- package/src/platform/createRecorderService.expo.tsx +267 -110
- package/src/utils/expoBackwardUtils.ts +29 -0
- package/src/utils/expoPermissionGranted.ts +3 -1
- package/src/version.ts +1 -1
|
@@ -2,151 +2,269 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
2
2
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
3
3
|
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); }
|
|
4
4
|
import { Platform } from 'react-native';
|
|
5
|
-
import { matchesOneOf, sleep } from '@sendbird/uikit-utils';
|
|
5
|
+
import { Logger, matchesOneOf, sleep } from '@sendbird/uikit-utils';
|
|
6
6
|
import VoiceMessageConfig from '../libs/VoiceMessageConfig';
|
|
7
|
+
import expoBackwardUtils from '../utils/expoBackwardUtils';
|
|
7
8
|
import expoPermissionGranted from '../utils/expoPermissionGranted';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
class BaseAudioRecorderAdapter {
|
|
10
|
+
constructor() {
|
|
11
|
+
_defineProperty(this, "uri", undefined);
|
|
12
|
+
_defineProperty(this, "state", 'idle');
|
|
13
|
+
_defineProperty(this, "options", {
|
|
14
|
+
minDuration: VoiceMessageConfig.DEFAULT.RECORDER.MIN_DURATION,
|
|
15
|
+
maxDuration: VoiceMessageConfig.DEFAULT.RECORDER.MAX_DURATION,
|
|
16
|
+
extension: VoiceMessageConfig.DEFAULT.RECORDER.EXTENSION
|
|
17
|
+
});
|
|
18
|
+
_defineProperty(this, "_audioSettings", {
|
|
19
|
+
sampleRate: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,
|
|
20
|
+
bitRate: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,
|
|
21
|
+
numberOfChannels: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS
|
|
22
|
+
// encoding: mpeg4_aac
|
|
23
|
+
});
|
|
24
|
+
_defineProperty(this, "_recordingSubscribers", new Set());
|
|
25
|
+
_defineProperty(this, "_stateSubscribers", new Set());
|
|
26
|
+
// NOTE: In Android, even when startRecorder() is awaited, if stop() is executed immediately afterward, an error occurs
|
|
27
|
+
_defineProperty(this, "_recordStartedAt", 0);
|
|
28
|
+
_defineProperty(this, "_getRecorderStopSafeBuffer", () => {
|
|
29
|
+
const minWaitingTime = 500;
|
|
30
|
+
const elapsedTime = Date.now() - this._recordStartedAt;
|
|
31
|
+
if (elapsedTime > minWaitingTime) return 0;else return minWaitingTime - elapsedTime;
|
|
32
|
+
});
|
|
33
|
+
_defineProperty(this, "setState", state => {
|
|
34
|
+
this.state = state;
|
|
35
|
+
this._stateSubscribers.forEach(callback => {
|
|
36
|
+
callback(state);
|
|
19
37
|
});
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
38
|
+
});
|
|
39
|
+
_defineProperty(this, "addRecordingListener", callback => {
|
|
40
|
+
this._recordingSubscribers.add(callback);
|
|
41
|
+
return () => {
|
|
42
|
+
this._recordingSubscribers.delete(callback);
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
_defineProperty(this, "addStateListener", callback => {
|
|
46
|
+
this._stateSubscribers.add(callback);
|
|
47
|
+
return () => {
|
|
48
|
+
this._stateSubscribers.delete(callback);
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
_defineProperty(this, "convertRecordPath", uri => {
|
|
52
|
+
return uri;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class LegacyExpoAVRecorderAdapter extends BaseAudioRecorderAdapter {
|
|
57
|
+
constructor(avModule) {
|
|
58
|
+
super();
|
|
59
|
+
_defineProperty(this, "avModule", void 0);
|
|
60
|
+
_defineProperty(this, "_recorder", void 0);
|
|
61
|
+
_defineProperty(this, "_audioOptions", void 0);
|
|
62
|
+
_defineProperty(this, "prepare", async () => {
|
|
63
|
+
this.setState('preparing');
|
|
64
|
+
if (Platform.OS === 'ios') {
|
|
65
|
+
await this.avModule.Audio.setAudioModeAsync({
|
|
66
|
+
allowsRecordingIOS: true,
|
|
67
|
+
playsInSilentModeIOS: true
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (this._recorder._isDoneRecording) {
|
|
71
|
+
this._recorder = new this.avModule.Audio.Recording();
|
|
72
|
+
}
|
|
73
|
+
this._recorder.setProgressUpdateInterval(100);
|
|
74
|
+
this._recorder.setOnRecordingStatusUpdate(status => {
|
|
75
|
+
const completed = status.durationMillis >= this.options.maxDuration;
|
|
76
|
+
if (completed) this.stop();
|
|
77
|
+
if (status.isRecording) {
|
|
78
|
+
this._recordingSubscribers.forEach(callback => {
|
|
79
|
+
callback({
|
|
80
|
+
currentTime: status.durationMillis,
|
|
81
|
+
completed: completed
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
}
|
|
50
85
|
});
|
|
51
|
-
|
|
52
|
-
|
|
86
|
+
await this._recorder.prepareToRecordAsync(this._audioOptions);
|
|
87
|
+
});
|
|
88
|
+
_defineProperty(this, "requestPermission", async () => {
|
|
89
|
+
const status = await this.avModule.Audio.getPermissionsAsync();
|
|
90
|
+
if (expoPermissionGranted([status])) {
|
|
91
|
+
return true;
|
|
92
|
+
} else {
|
|
93
|
+
const status = await this.avModule.Audio.requestPermissionsAsync();
|
|
94
|
+
return expoPermissionGranted([status]);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
_defineProperty(this, "record", async () => {
|
|
98
|
+
if (matchesOneOf(this.state, ['idle', 'completed'])) {
|
|
99
|
+
try {
|
|
100
|
+
await this.prepare();
|
|
101
|
+
await this._recorder.startAsync();
|
|
102
|
+
if (Platform.OS === 'android') {
|
|
103
|
+
this._recordStartedAt = Date.now();
|
|
104
|
+
}
|
|
105
|
+
const uri = this._recorder.getURI();
|
|
106
|
+
if (uri) this.uri = uri;
|
|
107
|
+
this.setState('recording');
|
|
108
|
+
} catch (e) {
|
|
109
|
+
this.setState('idle');
|
|
110
|
+
throw e;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
_defineProperty(this, "stop", async () => {
|
|
115
|
+
if (matchesOneOf(this.state, ['recording'])) {
|
|
116
|
+
if (Platform.OS === 'android') {
|
|
117
|
+
const buffer = this._getRecorderStopSafeBuffer();
|
|
118
|
+
if (buffer > 0) await sleep(buffer);
|
|
119
|
+
}
|
|
120
|
+
await this._recorder.stopAndUnloadAsync();
|
|
53
121
|
if (Platform.OS === 'ios') {
|
|
54
|
-
await avModule.Audio.setAudioModeAsync({
|
|
55
|
-
allowsRecordingIOS:
|
|
56
|
-
playsInSilentModeIOS:
|
|
122
|
+
await this.avModule.Audio.setAudioModeAsync({
|
|
123
|
+
allowsRecordingIOS: false,
|
|
124
|
+
playsInSilentModeIOS: false
|
|
57
125
|
});
|
|
58
126
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
127
|
+
this.setState('completed');
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
_defineProperty(this, "reset", async () => {
|
|
131
|
+
await this.stop();
|
|
132
|
+
this.uri = undefined;
|
|
133
|
+
this._recordingSubscribers.clear();
|
|
134
|
+
this._recorder = new this.avModule.Audio.Recording();
|
|
135
|
+
this.setState('idle');
|
|
136
|
+
});
|
|
137
|
+
this.avModule = avModule;
|
|
138
|
+
this._recorder = new avModule.Audio.Recording();
|
|
139
|
+
this._audioOptions = {
|
|
140
|
+
android: {
|
|
141
|
+
...this._audioSettings,
|
|
142
|
+
extension: `.${this.options.extension}`,
|
|
143
|
+
audioEncoder: avModule.Audio.AndroidAudioEncoder.AAC,
|
|
144
|
+
outputFormat: avModule.Audio.AndroidOutputFormat.MPEG_4
|
|
145
|
+
},
|
|
146
|
+
ios: {
|
|
147
|
+
...this._audioSettings,
|
|
148
|
+
extension: `.${this.options.extension}`,
|
|
149
|
+
outputFormat: avModule.Audio.IOSOutputFormat.MPEG4AAC,
|
|
150
|
+
audioQuality: avModule.Audio.IOSAudioQuality.HIGH
|
|
151
|
+
},
|
|
152
|
+
web: {}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
class ExpoAudioRecorderAdapter extends BaseAudioRecorderAdapter {
|
|
157
|
+
constructor(audioModule) {
|
|
158
|
+
super();
|
|
159
|
+
_defineProperty(this, "audioModule", void 0);
|
|
160
|
+
_defineProperty(this, "recorder", null);
|
|
161
|
+
_defineProperty(this, "recordingUpdateInterval", null);
|
|
162
|
+
_defineProperty(this, "setListener", () => {
|
|
163
|
+
if (!this.recorder) return;
|
|
164
|
+
this.recordingUpdateInterval = setInterval(() => {
|
|
165
|
+
if (this.recorder && this.recorder.isRecording) {
|
|
166
|
+
const currentTime = this.recorder.currentTime * 1000;
|
|
167
|
+
const completed = currentTime >= this.options.maxDuration;
|
|
168
|
+
if (completed) {
|
|
169
|
+
this.stop().catch(error => {
|
|
170
|
+
Logger.warn('[RecorderService.Expo] Failed to stop in update interval', error);
|
|
72
171
|
});
|
|
73
172
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
callback(state);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
_defineProperty(this, "requestPermission", async () => {
|
|
84
|
-
const status = await avModule.Audio.getPermissionsAsync();
|
|
85
|
-
if (expoPermissionGranted([status])) {
|
|
86
|
-
return true;
|
|
87
|
-
} else {
|
|
88
|
-
const status = await avModule.Audio.requestPermissionsAsync();
|
|
89
|
-
return expoPermissionGranted([status]);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
_defineProperty(this, "addRecordingListener", callback => {
|
|
93
|
-
this._recordingSubscribers.add(callback);
|
|
94
|
-
return () => {
|
|
95
|
-
this._recordingSubscribers.delete(callback);
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
_defineProperty(this, "addStateListener", callback => {
|
|
99
|
-
this._stateSubscribers.add(callback);
|
|
100
|
-
return () => {
|
|
101
|
-
this._stateSubscribers.delete(callback);
|
|
102
|
-
};
|
|
103
|
-
});
|
|
104
|
-
_defineProperty(this, "record", async () => {
|
|
105
|
-
if (matchesOneOf(this.state, ['idle', 'completed'])) {
|
|
106
|
-
try {
|
|
107
|
-
await this.prepare();
|
|
108
|
-
await this._recorder.startAsync();
|
|
109
|
-
if (Platform.OS === 'android') {
|
|
110
|
-
this._recordStartedAt = Date.now();
|
|
111
|
-
}
|
|
112
|
-
const uri = this._recorder.getURI();
|
|
113
|
-
if (uri) this.uri = uri;
|
|
114
|
-
this.setState('recording');
|
|
115
|
-
} catch (e) {
|
|
116
|
-
this.setState('idle');
|
|
117
|
-
throw e;
|
|
118
|
-
}
|
|
173
|
+
this._recordingSubscribers.forEach(callback => {
|
|
174
|
+
callback({
|
|
175
|
+
currentTime,
|
|
176
|
+
completed
|
|
177
|
+
});
|
|
178
|
+
});
|
|
119
179
|
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
|
|
180
|
+
}, 100);
|
|
181
|
+
});
|
|
182
|
+
_defineProperty(this, "removeListener", () => {
|
|
183
|
+
if (this.recordingUpdateInterval) {
|
|
184
|
+
clearInterval(this.recordingUpdateInterval);
|
|
185
|
+
this.recordingUpdateInterval = null;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
_defineProperty(this, "prepare", async () => {
|
|
189
|
+
this.setState('preparing');
|
|
190
|
+
if (Platform.OS === 'ios') {
|
|
191
|
+
await this.audioModule.setAudioModeAsync({
|
|
192
|
+
allowsRecording: true,
|
|
193
|
+
playsInSilentMode: true
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
const recordingOptions = {
|
|
197
|
+
...this._audioSettings,
|
|
198
|
+
extension: `.${this.options.extension}`
|
|
199
|
+
};
|
|
200
|
+
this.recorder = new this.audioModule.AudioModule.AudioRecorder(recordingOptions);
|
|
201
|
+
await this.recorder.prepareToRecordAsync();
|
|
202
|
+
});
|
|
203
|
+
_defineProperty(this, "requestPermission", async () => {
|
|
204
|
+
const status = await this.audioModule.getRecordingPermissionsAsync();
|
|
205
|
+
if (expoPermissionGranted([status])) {
|
|
206
|
+
return true;
|
|
207
|
+
} else {
|
|
208
|
+
const status = await this.audioModule.requestRecordingPermissionsAsync();
|
|
209
|
+
return expoPermissionGranted([status]);
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
_defineProperty(this, "record", async () => {
|
|
213
|
+
if (matchesOneOf(this.state, ['idle', 'completed'])) {
|
|
214
|
+
try {
|
|
215
|
+
var _this$recorder, _this$recorder2;
|
|
216
|
+
await this.prepare();
|
|
217
|
+
this.setListener();
|
|
218
|
+
(_this$recorder = this.recorder) === null || _this$recorder === void 0 || _this$recorder.record();
|
|
123
219
|
if (Platform.OS === 'android') {
|
|
124
|
-
|
|
125
|
-
if (buffer > 0) await sleep(buffer);
|
|
220
|
+
this._recordStartedAt = Date.now();
|
|
126
221
|
}
|
|
127
|
-
|
|
128
|
-
if (
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
this.setState('completed');
|
|
222
|
+
const uri = (_this$recorder2 = this.recorder) === null || _this$recorder2 === void 0 ? void 0 : _this$recorder2.uri;
|
|
223
|
+
if (uri) this.uri = uri;
|
|
224
|
+
this.setState('recording');
|
|
225
|
+
} catch (e) {
|
|
226
|
+
this.setState('idle');
|
|
227
|
+
this.removeListener();
|
|
228
|
+
throw e;
|
|
135
229
|
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
_defineProperty(this, "stop", async () => {
|
|
233
|
+
if (matchesOneOf(this.state, ['recording'])) {
|
|
234
|
+
var _this$recorder3;
|
|
235
|
+
if (Platform.OS === 'android') {
|
|
236
|
+
const buffer = this._getRecorderStopSafeBuffer();
|
|
237
|
+
if (buffer > 0) await sleep(buffer);
|
|
238
|
+
}
|
|
239
|
+
await ((_this$recorder3 = this.recorder) === null || _this$recorder3 === void 0 ? void 0 : _this$recorder3.stop());
|
|
240
|
+
this.removeListener();
|
|
241
|
+
if (Platform.OS === 'ios') {
|
|
242
|
+
await this.audioModule.setAudioModeAsync({
|
|
243
|
+
allowsRecording: false,
|
|
244
|
+
playsInSilentMode: false
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
this.setState('completed');
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
_defineProperty(this, "reset", async () => {
|
|
251
|
+
await this.stop();
|
|
252
|
+
this.recorder = null;
|
|
253
|
+
this.uri = undefined;
|
|
254
|
+
this._recordingSubscribers.clear();
|
|
255
|
+
this._stateSubscribers.clear();
|
|
256
|
+
this.setState('idle');
|
|
257
|
+
});
|
|
258
|
+
this.audioModule = audioModule;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
const createExpoRecorderService = ({
|
|
262
|
+
avModule
|
|
263
|
+
}) => {
|
|
264
|
+
if (expoBackwardUtils.expoAV.isLegacyAVModule(avModule)) {
|
|
265
|
+
Logger.warn('[RecorderService.Expo] expo-av is deprecated and will be removed in Expo 54. Please migrate to expo-audio.');
|
|
148
266
|
}
|
|
149
|
-
return new
|
|
267
|
+
return expoBackwardUtils.expoAV.isAudioModule(avModule) ? new ExpoAudioRecorderAdapter(avModule) : new LegacyExpoAVRecorderAdapter(avModule);
|
|
150
268
|
};
|
|
151
269
|
export default createExpoRecorderService;
|
|
152
270
|
//# sourceMappingURL=createRecorderService.expo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","matchesOneOf","sleep","VoiceMessageConfig","expoPermissionGranted","createExpoRecorderService","avModule","VoiceRecorder","constructor","_defineProperty","undefined","minDuration","DEFAULT","RECORDER","MIN_DURATION","maxDuration","MAX_DURATION","extension","EXTENSION","minWaitingTime","elapsedTime","Date","now","_recordStartedAt","Audio","Recording","Set","sampleRate","SAMPLE_RATE","bitRate","BIT_RATE","numberOfChannels","CHANNELS","android","_audioSettings","options","audioEncoder","AndroidAudioEncoder","AAC","outputFormat","AndroidOutputFormat","MPEG_4","ios","IOSOutputFormat","MPEG4AAC","audioQuality","IOSAudioQuality","HIGH","web","setState","OS","setAudioModeAsync","allowsRecordingIOS","playsInSilentModeIOS","_recorder","_isDoneRecording","setProgressUpdateInterval","setOnRecordingStatusUpdate","status","completed","durationMillis","stop","isRecording","_recordingSubscribers","forEach","callback","currentTime","prepareToRecordAsync","_audioOptions","state","_stateSubscribers","getPermissionsAsync","requestPermissionsAsync","add","delete","prepare","startAsync","uri","getURI","e","buffer","_getRecorderStopSafeBuffer","stopAndUnloadAsync","clear"],"sources":["createRecorderService.expo.tsx"],"sourcesContent":["import * as ExpoAV from 'expo-av';\nimport type { RecordingOptions } from 'expo-av/build/Audio/Recording.types';\nimport { Platform } from 'react-native';\n\nimport { matchesOneOf, sleep } from '@sendbird/uikit-utils';\n\nimport VoiceMessageConfig from '../libs/VoiceMessageConfig';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type { RecorderServiceInterface, Unsubscribe } from './types';\n\ntype RecordingListener = Parameters<RecorderServiceInterface['addRecordingListener']>[number];\ntype StateListener = Parameters<RecorderServiceInterface['addStateListener']>[number];\ntype Modules = {\n avModule: typeof ExpoAV;\n};\nconst createExpoRecorderService = ({ avModule }: Modules): RecorderServiceInterface => {\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 _recorder = new avModule.Audio.Recording();\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 numberOfChannels: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n // encoding: mpeg4_aac\n };\n private readonly _audioOptions: RecordingOptions = {\n android: {\n ...this._audioSettings,\n extension: `.${this.options.extension}`,\n audioEncoder: avModule.Audio.AndroidAudioEncoder.AAC,\n outputFormat: avModule.Audio.AndroidOutputFormat.MPEG_4,\n },\n ios: {\n ...this._audioSettings,\n extension: `.${this.options.extension}`,\n outputFormat: avModule.Audio.IOSOutputFormat.MPEG4AAC,\n audioQuality: avModule.Audio.IOSAudioQuality.HIGH,\n },\n web: {},\n };\n\n private prepare = async () => {\n this.setState('preparing');\n if (Platform.OS === 'ios') {\n await avModule.Audio.setAudioModeAsync({ allowsRecordingIOS: true, playsInSilentModeIOS: true });\n }\n\n if (this._recorder._isDoneRecording) {\n this._recorder = new avModule.Audio.Recording();\n }\n this._recorder.setProgressUpdateInterval(100);\n this._recorder.setOnRecordingStatusUpdate((status) => {\n const completed = status.durationMillis >= this.options.maxDuration;\n if (completed) this.stop();\n if (status.isRecording) {\n this._recordingSubscribers.forEach((callback) => {\n callback({ currentTime: status.durationMillis, completed: completed });\n });\n }\n });\n await this._recorder.prepareToRecordAsync(this._audioOptions);\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 status = await avModule.Audio.getPermissionsAsync();\n if (expoPermissionGranted([status])) {\n return true;\n } else {\n const status = await avModule.Audio.requestPermissionsAsync();\n return expoPermissionGranted([status]);\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 (): Promise<void> => {\n if (matchesOneOf(this.state, ['idle', 'completed'])) {\n try {\n await this.prepare();\n await this._recorder.startAsync();\n\n if (Platform.OS === 'android') {\n this._recordStartedAt = Date.now();\n }\n\n const uri = this._recorder.getURI();\n if (uri) 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 this._recorder.stopAndUnloadAsync();\n if (Platform.OS === 'ios') {\n await avModule.Audio.setAudioModeAsync({ allowsRecordingIOS: false, playsInSilentModeIOS: false });\n }\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._recorder = new avModule.Audio.Recording();\n this.setState('idle');\n };\n\n public convertRecordPath = (uri: string): string => {\n return uri;\n };\n }\n\n return new VoiceRecorder();\n};\n\nexport default createExpoRecorderService;\n"],"mappings":";;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAE3D,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,qBAAqB,MAAM,gCAAgC;AAQlE,MAAMC,yBAAyB,GAAGA,CAAC;EAAEC;AAAkB,CAAC,KAA+B;EACrF,MAAMC,aAAa,CAAqC;IAAAC,YAAA;MAAAC,eAAA,cACRC,SAAS;MAAAD,eAAA,gBACL,MAAM;MAAAA,eAAA,kBACF;QACpDE,WAAW,EAAER,kBAAkB,CAACS,OAAO,CAACC,QAAQ,CAACC,YAAY;QAC7DC,WAAW,EAAEZ,kBAAkB,CAACS,OAAO,CAACC,QAAQ,CAACG,YAAY;QAC7DC,SAAS,EAAEd,kBAAkB,CAACS,OAAO,CAACC,QAAQ,CAACK;MACjD,CAAC;MAED;MAAAT,eAAA,2BAC2B,CAAC;MAAAA,eAAA,qCACS,MAAM;QACzC,MAAMU,cAAc,GAAG,GAAG;QAC1B,MAAMC,WAAW,GAAGC,IAAI,CAACC,GAAG,CAAC,CAAC,GAAG,IAAI,CAACC,gBAAgB;QACtD,IAAIH,WAAW,GAAGD,cAAc,EAAE,OAAO,CAAC,CAAC,KACtC,OAAOA,cAAc,GAAGC,WAAW;MAC1C,CA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AIrE,QAAQ,CAACkD,EAAE,KAAK,SAAS,EAAE;YAC7B,MAAM8B,MAAM,GAAG,IAAI,CAACC,0BAA0B,CAAC,CAAC;YAChD,IAAID,MAAM,GAAG,CAAC,EAAE,MAAM9E,KAAK,CAAC8E,MAAM,CAAC;UACrC;UAEA,MAAM,IAAI,CAAC1B,SAAS,CAAC4B,kBAAkB,CAAC,CAAC;UACzC,IAAIlF,QAAQ,CAACkD,EAAE,KAAK,KAAK,EAAE;YACzB,MAAM5C,QAAQ,CAACkB,KAAK,CAAC2B,iBAAiB,CAAC;cAAEC,kBAAkB,EAAE,KAAK;cAAEC,oBAAoB,EAAE;YAAM,CAAC,CAAC;UACpG;UACA,IAAI,CAACJ,QAAQ,CAAC,WAAW,CAAC;QAC5B;MACF,CAAC;MAAAxC,eAAA,gBAEc,YAA2B;QACxC,MAAM,IAAI,CAACoD,IAAI,CAAC,CAAC;QACjB,IAAI,CAACgB,GAAG,GAAGnE,SAAS;QACpB,IAAI,CAACqD,qBAAqB,CAACoB,KAAK,CAAC,CAAC;QAClC,IAAI,CAAC7B,SAAS,GAAG,IAAIhD,QAAQ,CAACkB,KAAK,CAACC,SAAS,CAAC,CAAC;QAC/C,IAAI,CAACwB,QAAQ,CAAC,MAAM,CAAC;MACvB,CAAC;MAAAxC,eAAA,4BAE2BoE,GAAW,IAAa;QAClD,OAAOA,GAAG;MACZ,CAAC;IAAA;EACH;EAEA,OAAO,IAAItE,aAAa,CAAC,CAAC;AAC5B,CAAC;AAED,eAAeF,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["Platform","Logger","matchesOneOf","sleep","VoiceMessageConfig","expoBackwardUtils","expoPermissionGranted","BaseAudioRecorderAdapter","constructor","_defineProperty","undefined","minDuration","DEFAULT","RECORDER","MIN_DURATION","maxDuration","MAX_DURATION","extension","EXTENSION","sampleRate","SAMPLE_RATE","bitRate","BIT_RATE","numberOfChannels","CHANNELS","Set","minWaitingTime","elapsedTime","Date","now","_recordStartedAt","state","_stateSubscribers","forEach","callback","_recordingSubscribers","add","delete","uri","LegacyExpoAVRecorderAdapter","avModule","setState","OS","Audio","setAudioModeAsync","allowsRecordingIOS","playsInSilentModeIOS","_recorder","_isDoneRecording","Recording","setProgressUpdateInterval","setOnRecordingStatusUpdate","status","completed","durationMillis","options","stop","isRecording","currentTime","prepareToRecordAsync","_audioOptions","getPermissionsAsync","requestPermissionsAsync","prepare","startAsync","getURI","e","buffer","_getRecorderStopSafeBuffer","stopAndUnloadAsync","clear","android","_audioSettings","audioEncoder","AndroidAudioEncoder","AAC","outputFormat","AndroidOutputFormat","MPEG_4","ios","IOSOutputFormat","MPEG4AAC","audioQuality","IOSAudioQuality","HIGH","web","ExpoAudioRecorderAdapter","audioModule","recorder","recordingUpdateInterval","setInterval","catch","error","warn","clearInterval","allowsRecording","playsInSilentMode","recordingOptions","AudioModule","AudioRecorder","getRecordingPermissionsAsync","requestRecordingPermissionsAsync","_this$recorder","_this$recorder2","setListener","record","removeListener","_this$recorder3","createExpoRecorderService","expoAV","isLegacyAVModule","isAudioModule"],"sources":["createRecorderService.expo.tsx"],"sourcesContent":["import type * as ExpoAudio from 'expo-audio';\nimport type * as ExpoAV from 'expo-av';\nimport { Platform } from 'react-native';\n\nimport { Logger, matchesOneOf, sleep } from '@sendbird/uikit-utils';\n\nimport VoiceMessageConfig from '../libs/VoiceMessageConfig';\nimport expoBackwardUtils from '../utils/expoBackwardUtils';\nimport type { ExpoAudioModule } from '../utils/expoBackwardUtils';\nimport expoPermissionGranted from '../utils/expoPermissionGranted';\nimport type { RecorderServiceInterface, Unsubscribe } from './types';\n\ntype RecordingListener = Parameters<RecorderServiceInterface['addRecordingListener']>[number];\ntype StateListener = Parameters<RecorderServiceInterface['addStateListener']>[number];\ntype Modules = {\n avModule: ExpoAudioModule;\n};\n\ninterface AudioRecorderAdapter {\n requestPermission(): Promise<boolean>;\n record(): Promise<void>;\n stop(): Promise<void>;\n reset(): Promise<void>;\n addRecordingListener(callback: RecordingListener): Unsubscribe;\n addStateListener(callback: StateListener): Unsubscribe;\n convertRecordPath(uri: string): string;\n readonly state: RecorderServiceInterface['state'];\n readonly options: RecorderServiceInterface['options'];\n uri?: string;\n}\n\nabstract class BaseAudioRecorderAdapter implements AudioRecorderAdapter {\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 protected readonly _audioSettings = {\n sampleRate: VoiceMessageConfig.DEFAULT.RECORDER.SAMPLE_RATE,\n bitRate: VoiceMessageConfig.DEFAULT.RECORDER.BIT_RATE,\n numberOfChannels: VoiceMessageConfig.DEFAULT.RECORDER.CHANNELS,\n // encoding: mpeg4_aac\n };\n protected readonly _recordingSubscribers = new Set<RecordingListener>();\n protected readonly _stateSubscribers = new Set<StateListener>();\n\n // NOTE: In Android, even when startRecorder() is awaited, if stop() is executed immediately afterward, an error occurs\n protected _recordStartedAt = 0;\n protected _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 protected setState = (state: RecorderServiceInterface['state']) => {\n this.state = state;\n this._stateSubscribers.forEach((callback) => {\n callback(state);\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 convertRecordPath = (uri: string): string => {\n return uri;\n };\n\n abstract requestPermission(): Promise<boolean>;\n abstract record(): Promise<void>;\n abstract stop(): Promise<void>;\n abstract reset(): Promise<void>;\n}\n\nclass LegacyExpoAVRecorderAdapter extends BaseAudioRecorderAdapter {\n private readonly avModule: typeof ExpoAV;\n\n private _recorder: ExpoAV.Audio.Recording;\n private readonly _audioOptions: ExpoAV.Audio.RecordingOptions;\n\n constructor(avModule: typeof ExpoAV) {\n super();\n this.avModule = avModule;\n this._recorder = new avModule.Audio.Recording();\n this._audioOptions = {\n android: {\n ...this._audioSettings,\n extension: `.${this.options.extension}`,\n audioEncoder: avModule.Audio.AndroidAudioEncoder.AAC,\n outputFormat: avModule.Audio.AndroidOutputFormat.MPEG_4,\n },\n ios: {\n ...this._audioSettings,\n extension: `.${this.options.extension}`,\n outputFormat: avModule.Audio.IOSOutputFormat.MPEG4AAC,\n audioQuality: avModule.Audio.IOSAudioQuality.HIGH,\n },\n web: {},\n };\n }\n\n private prepare = async () => {\n this.setState('preparing');\n if (Platform.OS === 'ios') {\n await this.avModule.Audio.setAudioModeAsync({ allowsRecordingIOS: true, playsInSilentModeIOS: true });\n }\n\n if (this._recorder._isDoneRecording) {\n this._recorder = new this.avModule.Audio.Recording();\n }\n this._recorder.setProgressUpdateInterval(100);\n this._recorder.setOnRecordingStatusUpdate((status) => {\n const completed = status.durationMillis >= this.options.maxDuration;\n if (completed) this.stop();\n if (status.isRecording) {\n this._recordingSubscribers.forEach((callback) => {\n callback({ currentTime: status.durationMillis, completed: completed });\n });\n }\n });\n await this._recorder.prepareToRecordAsync(this._audioOptions);\n };\n\n public requestPermission = async (): Promise<boolean> => {\n const status = await this.avModule.Audio.getPermissionsAsync();\n if (expoPermissionGranted([status])) {\n return true;\n } else {\n const status = await this.avModule.Audio.requestPermissionsAsync();\n return expoPermissionGranted([status]);\n }\n };\n\n public record = async (): Promise<void> => {\n if (matchesOneOf(this.state, ['idle', 'completed'])) {\n try {\n await this.prepare();\n await this._recorder.startAsync();\n\n if (Platform.OS === 'android') {\n this._recordStartedAt = Date.now();\n }\n\n const uri = this._recorder.getURI();\n if (uri) 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 this._recorder.stopAndUnloadAsync();\n if (Platform.OS === 'ios') {\n await this.avModule.Audio.setAudioModeAsync({ allowsRecordingIOS: false, playsInSilentModeIOS: false });\n }\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._recorder = new this.avModule.Audio.Recording();\n this.setState('idle');\n };\n}\n\nclass ExpoAudioRecorderAdapter extends BaseAudioRecorderAdapter {\n private readonly audioModule: typeof ExpoAudio;\n private recorder: ExpoAudio.AudioRecorder | null = null;\n private recordingUpdateInterval: NodeJS.Timeout | null = null;\n\n constructor(audioModule: typeof ExpoAudio) {\n super();\n this.audioModule = audioModule;\n }\n\n private setListener = () => {\n if (!this.recorder) return;\n\n this.recordingUpdateInterval = setInterval(() => {\n if (this.recorder && this.recorder.isRecording) {\n const currentTime = this.recorder.currentTime * 1000;\n const completed = currentTime >= this.options.maxDuration;\n\n if (completed) {\n this.stop().catch((error) => {\n Logger.warn('[RecorderService.Expo] Failed to stop in update interval', error);\n });\n }\n\n this._recordingSubscribers.forEach((callback) => {\n callback({ currentTime, completed });\n });\n }\n }, 100);\n };\n\n private removeListener = () => {\n if (this.recordingUpdateInterval) {\n clearInterval(this.recordingUpdateInterval);\n this.recordingUpdateInterval = null;\n }\n };\n\n private prepare = async () => {\n this.setState('preparing');\n if (Platform.OS === 'ios') {\n await this.audioModule.setAudioModeAsync({\n allowsRecording: true,\n playsInSilentMode: true,\n });\n }\n\n const recordingOptions = {\n ...this._audioSettings,\n extension: `.${this.options.extension}`,\n };\n\n this.recorder = new this.audioModule.AudioModule.AudioRecorder(recordingOptions);\n await this.recorder.prepareToRecordAsync();\n };\n\n public requestPermission = async (): Promise<boolean> => {\n const status = await this.audioModule.getRecordingPermissionsAsync();\n if (expoPermissionGranted([status])) {\n return true;\n } else {\n const status = await this.audioModule.requestRecordingPermissionsAsync();\n return expoPermissionGranted([status]);\n }\n };\n\n public record = async (): Promise<void> => {\n if (matchesOneOf(this.state, ['idle', 'completed'])) {\n try {\n await this.prepare();\n this.setListener();\n this.recorder?.record();\n\n if (Platform.OS === 'android') {\n this._recordStartedAt = Date.now();\n }\n\n const uri = this.recorder?.uri;\n if (uri) this.uri = uri;\n this.setState('recording');\n } catch (e) {\n this.setState('idle');\n this.removeListener();\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 this.recorder?.stop();\n this.removeListener();\n if (Platform.OS === 'ios') {\n await this.audioModule.setAudioModeAsync({\n allowsRecording: false,\n playsInSilentMode: false,\n });\n }\n this.setState('completed');\n }\n };\n\n public reset = async (): Promise<void> => {\n await this.stop();\n this.recorder = null;\n this.uri = undefined;\n this._recordingSubscribers.clear();\n this._stateSubscribers.clear();\n this.setState('idle');\n };\n}\n\nconst createExpoRecorderService = ({ avModule }: Modules): RecorderServiceInterface => {\n if (expoBackwardUtils.expoAV.isLegacyAVModule(avModule)) {\n Logger.warn(\n '[RecorderService.Expo] expo-av is deprecated and will be removed in Expo 54. Please migrate to expo-audio.',\n );\n }\n\n return expoBackwardUtils.expoAV.isAudioModule(avModule)\n ? new ExpoAudioRecorderAdapter(avModule)\n : new LegacyExpoAVRecorderAdapter(avModule);\n};\n\nexport default createExpoRecorderService;\n"],"mappings":";;;AAEA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,SAASC,MAAM,EAAEC,YAAY,EAAEC,KAAK,QAAQ,uBAAuB;AAEnE,OAAOC,kBAAkB,MAAM,4BAA4B;AAC3D,OAAOC,iBAAiB,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|
|
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;UAAEF,IAAI,EAAEd,iBAAiB,CAACsB,UAAU,CAACH,QAAQ;QAAE,CAAC,CAAC;QACvG,OAAO,CAACE,QAAQ,CAAC;MACnB,CAAC,MAAM;QACL,OAAO,EAAE;MACX;IACF;EACF,CAAC;EACDE,cAAc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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.11.
|
|
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.11.
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ExpoAudioModule } from '../utils/expoBackwardUtils';
|
|
2
2
|
import type { RecorderServiceInterface } from './types';
|
|
3
3
|
type Modules = {
|
|
4
|
-
avModule:
|
|
4
|
+
avModule: ExpoAudioModule;
|
|
5
5
|
};
|
|
6
6
|
declare const createExpoRecorderService: ({ avModule }: Modules) => RecorderServiceInterface;
|
|
7
7
|
export default createExpoRecorderService;
|