expo-camera 11.2.2 → 12.0.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/CHANGELOG.md +15 -13
- package/android/build.gradle +3 -6
- package/android/src/main/java/expo/modules/camera/CameraModule.java +5 -5
- package/android/src/main/java/expo/modules/camera/CameraPackage.java +3 -3
- package/android/src/main/java/expo/modules/camera/CameraViewHelper.java +1 -1
- package/android/src/main/java/expo/modules/camera/CameraViewManager.java +4 -4
- package/android/src/main/java/expo/modules/camera/ExpoCameraView.java +5 -5
- package/android/src/main/java/expo/modules/camera/events/BarCodeScannedEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/events/CameraMountErrorEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/events/CameraReadyEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/events/FaceDetectionErrorEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/events/FacesDetectedEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/events/PictureSavedEvent.java +1 -1
- package/android/src/main/java/expo/modules/camera/tasks/ResolveTakenPictureAsyncTask.java +1 -1
- package/build/Camera.d.ts +26 -0
- package/build/Camera.js +103 -68
- package/build/Camera.js.map +1 -1
- package/build/Camera.types.d.ts +2 -2
- package/build/Camera.types.js +1 -1
- package/build/Camera.types.js.map +1 -1
- package/build/ExponentCamera.js +1 -1
- package/build/ExponentCamera.js.map +1 -1
- package/build/ExponentCamera.web.js +2 -1
- package/build/ExponentCamera.web.js.map +1 -1
- package/build/ExponentCameraManager.js +1 -1
- package/build/ExponentCameraManager.js.map +1 -1
- package/build/ExponentCameraManager.web.js +1 -1
- package/build/ExponentCameraManager.web.js.map +1 -1
- package/build/WebCameraUtils.js +4 -4
- package/build/WebCameraUtils.js.map +1 -1
- package/build/WebConstants.d.ts +1 -1
- package/build/WebUserMediaManager.js +9 -9
- package/build/WebUserMediaManager.js.map +1 -1
- package/build/useWebCameraStream.js +2 -2
- package/build/useWebCameraStream.js.map +1 -1
- package/build/utils/props.js +1 -1
- package/build/utils/props.js.map +1 -1
- package/ios/EXCamera/EXCamera.h +6 -6
- package/ios/EXCamera/EXCamera.m +76 -76
- package/ios/EXCamera/EXCameraCameraPermissionRequester.m +5 -5
- package/ios/EXCamera/EXCameraManager.h +4 -4
- package/ios/EXCamera/EXCameraManager.m +59 -59
- package/ios/EXCamera/EXCameraMicrophonePermissionRequester.m +5 -5
- package/ios/EXCamera/EXCameraPermissionRequester.m +5 -5
- package/ios/EXCamera.podspec +2 -2
- package/ios/EXCamera.xcframework/Info.plist +5 -5
- package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/EXCamera +0 -0
- package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/Info.plist +0 -0
- package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/EXCamera +0 -0
- package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/Info.plist +0 -0
- package/package.json +6 -6
- package/plugin/build/withCamera.js +2 -2
- package/plugin/src/withCamera.ts +2 -2
- package/src/Camera.tsx +61 -17
- package/src/Camera.types.ts +7 -2
- package/src/ExponentCamera.ts +3 -4
- package/src/ExponentCamera.web.tsx +1 -1
- package/src/ExponentCameraManager.ts +1 -1
- package/src/ExponentCameraManager.web.ts +2 -2
- package/src/WebCameraUtils.ts +5 -11
- package/src/WebUserMediaManager.ts +10 -10
- package/src/useWebCameraStream.ts +2 -2
- package/src/utils/props.ts +1 -1
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
#import <EXCamera/EXCameraCameraPermissionRequester.h>
|
|
6
6
|
#import <EXCamera/EXCameraMicrophonePermissionRequester.h>
|
|
7
7
|
|
|
8
|
-
#import <
|
|
8
|
+
#import <ExpoModulesCore/EXUIManager.h>
|
|
9
9
|
#import <ExpoModulesCore/EXFileSystemInterface.h>
|
|
10
10
|
#import <ExpoModulesCore/EXPermissionsInterface.h>
|
|
11
11
|
#import <ExpoModulesCore/EXPermissionsMethodsDelegate.h>
|
|
@@ -13,25 +13,25 @@
|
|
|
13
13
|
@interface EXCameraManager ()
|
|
14
14
|
|
|
15
15
|
@property (nonatomic, weak) id<EXFileSystemInterface> fileSystem;
|
|
16
|
-
@property (nonatomic, weak) id<
|
|
17
|
-
@property (nonatomic, weak)
|
|
16
|
+
@property (nonatomic, weak) id<EXUIManager> uiManager;
|
|
17
|
+
@property (nonatomic, weak) EXModuleRegistry *moduleRegistry;
|
|
18
18
|
@property (nonatomic, weak) id<EXPermissionsInterface> permissionsManager;
|
|
19
19
|
@end
|
|
20
20
|
|
|
21
21
|
@implementation EXCameraManager
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
EX_EXPORT_MODULE(ExponentCameraManager);
|
|
24
24
|
|
|
25
25
|
- (NSString *)viewName
|
|
26
26
|
{
|
|
27
27
|
return @"ExponentCamera";
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
- (void)setModuleRegistry:(
|
|
30
|
+
- (void)setModuleRegistry:(EXModuleRegistry *)moduleRegistry
|
|
31
31
|
{
|
|
32
32
|
_moduleRegistry = moduleRegistry;
|
|
33
33
|
_fileSystem = [moduleRegistry getModuleImplementingProtocol:@protocol(EXFileSystemInterface)];
|
|
34
|
-
_uiManager = [moduleRegistry getModuleImplementingProtocol:@protocol(
|
|
34
|
+
_uiManager = [moduleRegistry getModuleImplementingProtocol:@protocol(EXUIManager)];
|
|
35
35
|
_permissionsManager = [moduleRegistry getModuleImplementingProtocol:@protocol(EXPermissionsInterface)];
|
|
36
36
|
[EXPermissionsMethodsDelegate registerRequesters:@[[EXCameraPermissionRequester new]] withPermissionsManager:_permissionsManager];
|
|
37
37
|
[EXPermissionsMethodsDelegate registerRequesters:@[[EXCameraCameraPermissionRequester new]] withPermissionsManager:_permissionsManager];
|
|
@@ -114,7 +114,7 @@ UM_EXPORT_MODULE(ExponentCameraManager);
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
|
|
117
|
+
EX_VIEW_PROPERTY(type, NSNumber *, EXCamera)
|
|
118
118
|
{
|
|
119
119
|
long longValue = [value longValue];
|
|
120
120
|
if (view.presetCamera != longValue) {
|
|
@@ -123,7 +123,7 @@ UM_VIEW_PROPERTY(type, NSNumber *, EXCamera)
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
126
|
+
EX_VIEW_PROPERTY(flashMode, NSNumber *, EXCamera)
|
|
127
127
|
{
|
|
128
128
|
long longValue = [value longValue];
|
|
129
129
|
if (longValue != view.flashMode) {
|
|
@@ -132,17 +132,17 @@ UM_VIEW_PROPERTY(flashMode, NSNumber *, EXCamera)
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
|
|
135
|
+
EX_VIEW_PROPERTY(faceDetectorSettings, NSDictionary *, EXCamera)
|
|
136
136
|
{
|
|
137
137
|
[view updateFaceDetectorSettings:value];
|
|
138
138
|
}
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
EX_VIEW_PROPERTY(barCodeScannerSettings, NSDictionary *, EXCamera)
|
|
141
141
|
{
|
|
142
142
|
[view setBarCodeScannerSettings:value];
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
-
|
|
145
|
+
EX_VIEW_PROPERTY(autoFocus, NSNumber *, EXCamera)
|
|
146
146
|
{
|
|
147
147
|
long longValue = [value longValue];
|
|
148
148
|
if (longValue != view.autoFocus) {
|
|
@@ -151,7 +151,7 @@ UM_VIEW_PROPERTY(autoFocus, NSNumber *, EXCamera)
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
|
|
154
|
-
|
|
154
|
+
EX_VIEW_PROPERTY(focusDepth, NSNumber *, EXCamera)
|
|
155
155
|
{
|
|
156
156
|
float floatValue = [value floatValue];
|
|
157
157
|
if (fabsf(view.focusDepth - floatValue) > FLT_EPSILON) {
|
|
@@ -160,7 +160,7 @@ UM_VIEW_PROPERTY(focusDepth, NSNumber *, EXCamera)
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
EX_VIEW_PROPERTY(zoom, NSNumber *, EXCamera)
|
|
164
164
|
{
|
|
165
165
|
double doubleValue = [value doubleValue];
|
|
166
166
|
if (fabs(view.zoom - doubleValue) > DBL_EPSILON) {
|
|
@@ -169,7 +169,7 @@ UM_VIEW_PROPERTY(zoom, NSNumber *, EXCamera)
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
EX_VIEW_PROPERTY(whiteBalance, NSNumber *, EXCamera)
|
|
173
173
|
{
|
|
174
174
|
long longValue = [value longValue];
|
|
175
175
|
if (longValue != view.whiteBalance) {
|
|
@@ -178,12 +178,12 @@ UM_VIEW_PROPERTY(whiteBalance, NSNumber *, EXCamera)
|
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
|
|
181
|
-
|
|
181
|
+
EX_VIEW_PROPERTY(pictureSize, NSString *, EXCamera) {
|
|
182
182
|
[view setPictureSize:[[self class] pictureSizes][value]];
|
|
183
183
|
[view updatePictureSize];
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
|
|
186
|
+
EX_VIEW_PROPERTY(faceDetectorEnabled, NSNumber *, EXCamera)
|
|
187
187
|
{
|
|
188
188
|
bool boolValue = [value boolValue];
|
|
189
189
|
if ([view isDetectingFaces] != boolValue) {
|
|
@@ -191,7 +191,7 @@ UM_VIEW_PROPERTY(faceDetectorEnabled, NSNumber *, EXCamera)
|
|
|
191
191
|
}
|
|
192
192
|
}
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
EX_VIEW_PROPERTY(barCodeScannerEnabled, NSNumber *, EXCamera)
|
|
195
195
|
{
|
|
196
196
|
bool boolValue = [value boolValue];
|
|
197
197
|
if ([view isScanningBarCodes] != boolValue) {
|
|
@@ -199,11 +199,11 @@ UM_VIEW_PROPERTY(barCodeScannerEnabled, NSNumber *, EXCamera)
|
|
|
199
199
|
}
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
|
|
202
|
+
EX_EXPORT_METHOD_AS(takePicture,
|
|
203
203
|
takePictureWithOptions:(NSDictionary *)options
|
|
204
204
|
reactTag:(nonnull NSNumber *)reactTag
|
|
205
|
-
resolver:(
|
|
206
|
-
rejecter:(
|
|
205
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
206
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
207
207
|
{
|
|
208
208
|
#if TARGET_IPHONE_SIMULATOR
|
|
209
209
|
__weak EXCameraManager *weakSelf = self;
|
|
@@ -251,11 +251,11 @@ UM_EXPORT_METHOD_AS(takePicture,
|
|
|
251
251
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
EX_EXPORT_METHOD_AS(record,
|
|
255
255
|
recordWithOptions:(NSDictionary *)options
|
|
256
256
|
reactTag:(nonnull NSNumber *)reactTag
|
|
257
|
-
resolver:(
|
|
258
|
-
rejecter:(
|
|
257
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
258
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
259
259
|
{
|
|
260
260
|
#pragma clang diagnostic push
|
|
261
261
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
|
@@ -274,25 +274,25 @@ UM_EXPORT_METHOD_AS(record,
|
|
|
274
274
|
#pragma clang diagnostic pop
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
EX_EXPORT_METHOD_AS(stopRecording,
|
|
278
278
|
stopRecordingOfReactTag:(nonnull NSNumber *)reactTag
|
|
279
|
-
resolver:(
|
|
280
|
-
rejecter:(
|
|
279
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
280
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
281
281
|
{
|
|
282
282
|
[_uiManager executeUIBlock:^(id view) {
|
|
283
283
|
if (view != nil) {
|
|
284
284
|
[view stopRecording];
|
|
285
285
|
resolve(nil);
|
|
286
286
|
} else {
|
|
287
|
-
|
|
287
|
+
EXLogError(@"Invalid view returned from registry, expected EXCamera, got: %@", view);
|
|
288
288
|
}
|
|
289
289
|
} forView:reactTag ofClass:[EXCamera class]];
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
EX_EXPORT_METHOD_AS(resumePreview,
|
|
293
293
|
resumePreview:(nonnull NSNumber *)tag
|
|
294
|
-
resolver:(
|
|
295
|
-
rejecter:(
|
|
294
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
295
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
296
296
|
{
|
|
297
297
|
#pragma clang diagnostic push
|
|
298
298
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
|
@@ -305,16 +305,16 @@ UM_EXPORT_METHOD_AS(resumePreview,
|
|
|
305
305
|
[view resumePreview];
|
|
306
306
|
resolve(nil);
|
|
307
307
|
} else {
|
|
308
|
-
|
|
308
|
+
EXLogError(@"Invalid view returned from registry, expected EXCamera, got: %@", view);
|
|
309
309
|
}
|
|
310
310
|
} forView:tag ofClass:[EXCamera class]];
|
|
311
311
|
#pragma clang diagnostic pop
|
|
312
312
|
}
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
EX_EXPORT_METHOD_AS(pausePreview,
|
|
315
315
|
pausePreview:(nonnull NSNumber *)tag
|
|
316
|
-
resolver:(
|
|
317
|
-
rejecter:(
|
|
316
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
317
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
318
318
|
{
|
|
319
319
|
#pragma clang diagnostic push
|
|
320
320
|
#pragma clang diagnostic ignored "-Wunreachable-code"
|
|
@@ -327,24 +327,24 @@ UM_EXPORT_METHOD_AS(pausePreview,
|
|
|
327
327
|
[view pausePreview];
|
|
328
328
|
resolve(nil);
|
|
329
329
|
} else {
|
|
330
|
-
|
|
330
|
+
EXLogError(@"Invalid view returned from registry, expected EXCamera, got: %@", view);
|
|
331
331
|
}
|
|
332
332
|
} forView:tag ofClass:[EXCamera class]];
|
|
333
333
|
#pragma clang diagnostic pop
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
|
|
336
|
+
EX_EXPORT_METHOD_AS(getAvailablePictureSizes,
|
|
337
337
|
getAvailablePictureSizesWithRatio:(NSString *)ratio
|
|
338
338
|
tag:(nonnull NSNumber *)tag
|
|
339
|
-
resolver:(
|
|
340
|
-
rejecter:(
|
|
339
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
340
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
341
341
|
{
|
|
342
342
|
resolve([[[self class] pictureSizes] allKeys]);
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
-
|
|
346
|
-
resolver:(
|
|
347
|
-
rejecter:(
|
|
345
|
+
EX_EXPORT_METHOD_AS(getAvailableVideoCodecsAsync,
|
|
346
|
+
resolver:(EXPromiseResolveBlock)resolve
|
|
347
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
348
348
|
{
|
|
349
349
|
AVCaptureSession *session = [AVCaptureSession new];
|
|
350
350
|
[session beginConfiguration];
|
|
@@ -367,9 +367,9 @@ UM_EXPORT_METHOD_AS(getAvailableVideoCodecsAsync,
|
|
|
367
367
|
resolve([movieFileOutput availableVideoCodecTypes]);
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
-
|
|
371
|
-
getPermissionsAsync:(
|
|
372
|
-
rejecter:(
|
|
370
|
+
EX_EXPORT_METHOD_AS(getPermissionsAsync,
|
|
371
|
+
getPermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
372
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
373
373
|
{
|
|
374
374
|
[EXPermissionsMethodsDelegate getPermissionWithPermissionsManager:_permissionsManager
|
|
375
375
|
withRequester:[EXCameraPermissionRequester class]
|
|
@@ -377,9 +377,9 @@ UM_EXPORT_METHOD_AS(getPermissionsAsync,
|
|
|
377
377
|
reject:reject];
|
|
378
378
|
}
|
|
379
379
|
|
|
380
|
-
|
|
381
|
-
requestPermissionsAsync:(
|
|
382
|
-
rejecter:(
|
|
380
|
+
EX_EXPORT_METHOD_AS(requestPermissionsAsync,
|
|
381
|
+
requestPermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
382
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
383
383
|
{
|
|
384
384
|
[EXPermissionsMethodsDelegate askForPermissionWithPermissionsManager:_permissionsManager
|
|
385
385
|
withRequester:[EXCameraPermissionRequester class]
|
|
@@ -388,9 +388,9 @@ UM_EXPORT_METHOD_AS(requestPermissionsAsync,
|
|
|
388
388
|
}
|
|
389
389
|
|
|
390
390
|
|
|
391
|
-
|
|
392
|
-
getCameraPermissionsAsync:(
|
|
393
|
-
rejecter:(
|
|
391
|
+
EX_EXPORT_METHOD_AS(getCameraPermissionsAsync,
|
|
392
|
+
getCameraPermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
393
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
394
394
|
{
|
|
395
395
|
[EXPermissionsMethodsDelegate getPermissionWithPermissionsManager:_permissionsManager
|
|
396
396
|
withRequester:[EXCameraCameraPermissionRequester class]
|
|
@@ -399,9 +399,9 @@ UM_EXPORT_METHOD_AS(getCameraPermissionsAsync,
|
|
|
399
399
|
}
|
|
400
400
|
|
|
401
401
|
|
|
402
|
-
|
|
403
|
-
requestCameraPermissionsAsync:(
|
|
404
|
-
rejecter:(
|
|
402
|
+
EX_EXPORT_METHOD_AS(requestCameraPermissionsAsync,
|
|
403
|
+
requestCameraPermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
404
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
405
405
|
{
|
|
406
406
|
[EXPermissionsMethodsDelegate askForPermissionWithPermissionsManager:_permissionsManager
|
|
407
407
|
withRequester:[EXCameraCameraPermissionRequester class]
|
|
@@ -411,9 +411,9 @@ UM_EXPORT_METHOD_AS(requestCameraPermissionsAsync,
|
|
|
411
411
|
|
|
412
412
|
|
|
413
413
|
|
|
414
|
-
|
|
415
|
-
getMicrophonePermissionsAsync:(
|
|
416
|
-
rejecter:(
|
|
414
|
+
EX_EXPORT_METHOD_AS(getMicrophonePermissionsAsync,
|
|
415
|
+
getMicrophonePermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
416
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
417
417
|
{
|
|
418
418
|
[EXPermissionsMethodsDelegate getPermissionWithPermissionsManager:_permissionsManager
|
|
419
419
|
withRequester:[EXCameraMicrophonePermissionRequester class]
|
|
@@ -422,9 +422,9 @@ UM_EXPORT_METHOD_AS(getMicrophonePermissionsAsync,
|
|
|
422
422
|
}
|
|
423
423
|
|
|
424
424
|
|
|
425
|
-
|
|
426
|
-
requestMicrophonePermissionsAsync:(
|
|
427
|
-
rejecter:(
|
|
425
|
+
EX_EXPORT_METHOD_AS(requestMicrophonePermissionsAsync,
|
|
426
|
+
requestMicrophonePermissionsAsync:(EXPromiseResolveBlock)resolve
|
|
427
|
+
rejecter:(EXPromiseRejectBlock)reject)
|
|
428
428
|
{
|
|
429
429
|
[EXPermissionsMethodsDelegate askForPermissionWithPermissionsManager:_permissionsManager
|
|
430
430
|
withRequester:[EXCameraMicrophonePermissionRequester class]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2016-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <EXCamera/EXCameraMicrophonePermissionRequester.h>
|
|
4
|
-
#import <
|
|
4
|
+
#import <ExpoModulesCore/EXDefines.h>
|
|
5
5
|
#import <ExpoModulesCore/EXPermissionsInterface.h>
|
|
6
6
|
|
|
7
7
|
#import <AVFoundation/AVFoundation.h>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
NSString *microphoneUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];
|
|
21
21
|
|
|
22
22
|
if (!microphoneUsageDescription) {
|
|
23
|
-
|
|
23
|
+
EXFatal(EXErrorWithMessage(@"This app is missing NSMicrophoneUsageDescription, so audio services will fail. Add this entry to your bundle's Info.plist."));
|
|
24
24
|
systemStatus = AVAuthorizationStatusDenied;
|
|
25
25
|
} else {
|
|
26
26
|
systemStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeAudio];
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
- (void)requestPermissionsWithResolver:(
|
|
45
|
+
- (void)requestPermissionsWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
EX_WEAKIFY(self)
|
|
48
48
|
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted) {
|
|
49
|
-
|
|
49
|
+
EX_STRONGIFY(self)
|
|
50
50
|
resolve([self getPermissions]);
|
|
51
51
|
}];
|
|
52
52
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Copyright 2016-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <EXCamera/EXCameraPermissionRequester.h>
|
|
4
|
-
#import <
|
|
4
|
+
#import <ExpoModulesCore/EXDefines.h>
|
|
5
5
|
#import <ExpoModulesCore/EXPermissionsInterface.h>
|
|
6
6
|
|
|
7
7
|
#import <AVFoundation/AVFoundation.h>
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
NSString *cameraUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSCameraUsageDescription"];
|
|
21
21
|
NSString *microphoneUsageDescription = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSMicrophoneUsageDescription"];
|
|
22
22
|
if (!(cameraUsageDescription && microphoneUsageDescription)) {
|
|
23
|
-
|
|
23
|
+
EXFatal(EXErrorWithMessage(@"This app is missing either NSCameraUsageDescription or NSMicrophoneUsageDescription, so audio/video services will fail. Add one of these entries to your bundle's Info.plist."));
|
|
24
24
|
systemStatus = AVAuthorizationStatusDenied;
|
|
25
25
|
} else {
|
|
26
26
|
systemStatus = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
};
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
- (void)requestPermissionsWithResolver:(
|
|
45
|
+
- (void)requestPermissionsWithResolver:(EXPromiseResolveBlock)resolve rejecter:(EXPromiseRejectBlock)reject
|
|
46
46
|
{
|
|
47
|
-
|
|
47
|
+
EX_WEAKIFY(self)
|
|
48
48
|
[AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
|
|
49
|
-
|
|
49
|
+
EX_STRONGIFY(self)
|
|
50
50
|
resolve([self getPermissions]);
|
|
51
51
|
}];
|
|
52
52
|
}
|
package/ios/EXCamera.podspec
CHANGED
|
@@ -10,10 +10,10 @@ Pod::Spec.new do |s|
|
|
|
10
10
|
s.license = package['license']
|
|
11
11
|
s.author = package['author']
|
|
12
12
|
s.homepage = package['homepage']
|
|
13
|
-
s.platform = :ios, '
|
|
13
|
+
s.platform = :ios, '12.0'
|
|
14
14
|
s.source = { :git => "https://github.com/expo/expo.git" }
|
|
15
|
+
s.static_framework = true
|
|
15
16
|
|
|
16
|
-
s.dependency 'UMCore'
|
|
17
17
|
s.dependency 'ExpoModulesCore'
|
|
18
18
|
|
|
19
19
|
if !$ExpoUseSources&.include?(package['name']) && ENV['EXPO_USE_SOURCE'].to_i == 0 && File.exist?("#{s.name}.xcframework") && Gem::Version.new(Pod::VERSION) >= Gem::Version.new('1.10.0')
|
|
@@ -6,30 +6,30 @@
|
|
|
6
6
|
<array>
|
|
7
7
|
<dict>
|
|
8
8
|
<key>LibraryIdentifier</key>
|
|
9
|
-
<string>ios-
|
|
9
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
10
10
|
<key>LibraryPath</key>
|
|
11
11
|
<string>EXCamera.framework</string>
|
|
12
12
|
<key>SupportedArchitectures</key>
|
|
13
13
|
<array>
|
|
14
14
|
<string>arm64</string>
|
|
15
|
+
<string>x86_64</string>
|
|
15
16
|
</array>
|
|
16
17
|
<key>SupportedPlatform</key>
|
|
17
18
|
<string>ios</string>
|
|
19
|
+
<key>SupportedPlatformVariant</key>
|
|
20
|
+
<string>simulator</string>
|
|
18
21
|
</dict>
|
|
19
22
|
<dict>
|
|
20
23
|
<key>LibraryIdentifier</key>
|
|
21
|
-
<string>ios-
|
|
24
|
+
<string>ios-arm64</string>
|
|
22
25
|
<key>LibraryPath</key>
|
|
23
26
|
<string>EXCamera.framework</string>
|
|
24
27
|
<key>SupportedArchitectures</key>
|
|
25
28
|
<array>
|
|
26
29
|
<string>arm64</string>
|
|
27
|
-
<string>x86_64</string>
|
|
28
30
|
</array>
|
|
29
31
|
<key>SupportedPlatform</key>
|
|
30
32
|
<string>ios</string>
|
|
31
|
-
<key>SupportedPlatformVariant</key>
|
|
32
|
-
<string>simulator</string>
|
|
33
33
|
</dict>
|
|
34
34
|
</array>
|
|
35
35
|
<key>CFBundlePackageType</key>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-camera",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "12.0.1",
|
|
4
4
|
"description": "A React component that renders a preview for the device's either front or back camera. Camera's parameters like zoom, auto focus, white balance and flash mode are adjustable. With expo-camera, one can also take photos and record videos that are saved to the app's cache. Morever, the component is also capable of detecting faces and bar codes appearing on the preview.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -29,18 +29,18 @@
|
|
|
29
29
|
},
|
|
30
30
|
"author": "650 Industries, Inc.",
|
|
31
31
|
"license": "MIT",
|
|
32
|
-
"homepage": "https://docs.expo.
|
|
32
|
+
"homepage": "https://docs.expo.dev/versions/latest/sdk/camera/",
|
|
33
33
|
"jest": {
|
|
34
34
|
"preset": "expo-module-scripts"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@expo/config-plugins": "^3.
|
|
38
|
-
"@koale/useworker": "^
|
|
39
|
-
"expo-modules-core": "~0.2
|
|
37
|
+
"@expo/config-plugins": "^3.1.0",
|
|
38
|
+
"@koale/useworker": "^4.0.2",
|
|
39
|
+
"expo-modules-core": "~0.4.2",
|
|
40
40
|
"invariant": "2.2.4"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"expo-module-scripts": "^2.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "2718b696f4a6919905b0f47ebb24ff65b42d8ff9"
|
|
46
46
|
}
|
|
@@ -9,8 +9,8 @@ const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
|
|
|
9
9
|
// It's ok to have multiple allprojects.repositories, so we create a new one since it's cheaper than tokenizing
|
|
10
10
|
// the existing block to find the correct place to insert our camera maven.
|
|
11
11
|
const gradleMaven = 'allprojects { repositories { maven { url "$rootDir/../node_modules/expo-camera/android/maven" } } }';
|
|
12
|
-
const withAndroidCameraGradle = config => {
|
|
13
|
-
return config_plugins_1.withProjectBuildGradle(config, config => {
|
|
12
|
+
const withAndroidCameraGradle = (config) => {
|
|
13
|
+
return config_plugins_1.withProjectBuildGradle(config, (config) => {
|
|
14
14
|
if (config.modResults.language === 'groovy') {
|
|
15
15
|
config.modResults.contents = setGradleMaven(config.modResults.contents);
|
|
16
16
|
}
|
package/plugin/src/withCamera.ts
CHANGED
|
@@ -17,8 +17,8 @@ const MICROPHONE_USAGE = 'Allow $(PRODUCT_NAME) to access your microphone';
|
|
|
17
17
|
const gradleMaven =
|
|
18
18
|
'allprojects { repositories { maven { url "$rootDir/../node_modules/expo-camera/android/maven" } } }';
|
|
19
19
|
|
|
20
|
-
const withAndroidCameraGradle: ConfigPlugin = config => {
|
|
21
|
-
return withProjectBuildGradle(config, config => {
|
|
20
|
+
const withAndroidCameraGradle: ConfigPlugin = (config) => {
|
|
21
|
+
return withProjectBuildGradle(config, (config) => {
|
|
22
22
|
if (config.modResults.language === 'groovy') {
|
|
23
23
|
config.modResults.contents = setGradleMaven(config.modResults.contents);
|
|
24
24
|
} else {
|
package/src/Camera.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Platform, UnavailabilityError } from '
|
|
1
|
+
import { createPermissionHook, Platform, UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { findNodeHandle } from 'react-native';
|
|
4
4
|
|
|
@@ -117,11 +117,23 @@ export default class Camera extends React.Component<CameraProps> {
|
|
|
117
117
|
whiteBalance: CameraManager.WhiteBalance.auto,
|
|
118
118
|
};
|
|
119
119
|
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated Use `getCameraPermissionsAync` or `getMicrophonePermissionsAsync` instead.
|
|
122
|
+
*/
|
|
120
123
|
static async getPermissionsAsync(): Promise<PermissionResponse> {
|
|
124
|
+
console.warn(
|
|
125
|
+
`"getPermissionsAsync()" is now deprecated. Please use "getCameraPermissionsAsync()" or "getMicrophonePermissionsAsync()" instead.`
|
|
126
|
+
);
|
|
121
127
|
return CameraManager.getPermissionsAsync();
|
|
122
128
|
}
|
|
123
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated Use `requestCameraPermissionsAsync` or `requestMicrophonePermissionsAsync` instead.
|
|
132
|
+
*/
|
|
124
133
|
static async requestPermissionsAsync(): Promise<PermissionResponse> {
|
|
134
|
+
console.warn(
|
|
135
|
+
`"requestPermissionsAsync()" is now deprecated. Please use "requestCameraPermissionsAsync()" or "requestMicrophonePermissionsAsync()" instead.`
|
|
136
|
+
);
|
|
125
137
|
return CameraManager.requestPermissionsAsync();
|
|
126
138
|
}
|
|
127
139
|
|
|
@@ -133,6 +145,21 @@ export default class Camera extends React.Component<CameraProps> {
|
|
|
133
145
|
return CameraManager.requestCameraPermissionsAsync();
|
|
134
146
|
}
|
|
135
147
|
|
|
148
|
+
// @needsAudit
|
|
149
|
+
/**
|
|
150
|
+
* Check or request permissions to access the camera.
|
|
151
|
+
* This uses both `requestCameraPermissionsAsync` and `getCameraPermissionsAsync` to interact with the permissions.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const [status, requestPermission] = Camera.useCameraPermissions();
|
|
156
|
+
* ```
|
|
157
|
+
*/
|
|
158
|
+
static useCameraPermissions = createPermissionHook({
|
|
159
|
+
getMethod: Camera.getCameraPermissionsAsync,
|
|
160
|
+
requestMethod: Camera.requestCameraPermissionsAsync,
|
|
161
|
+
});
|
|
162
|
+
|
|
136
163
|
static async getMicrophonePermissionsAsync(): Promise<PermissionResponse> {
|
|
137
164
|
return CameraManager.getMicrophonePermissionsAsync();
|
|
138
165
|
}
|
|
@@ -141,6 +168,21 @@ export default class Camera extends React.Component<CameraProps> {
|
|
|
141
168
|
return CameraManager.requestMicrophonePermissionsAsync();
|
|
142
169
|
}
|
|
143
170
|
|
|
171
|
+
// @needsAudit
|
|
172
|
+
/**
|
|
173
|
+
* Check or request permissions to access the microphone.
|
|
174
|
+
* This uses both `requestMicrophonePermissionsAsync` and `getMicrophonePermissionsAsync` to interact with the permissions.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* const [status, requestPermission] = Camera.useMicrophonePermissions();
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
static useMicrophonePermissions = createPermissionHook({
|
|
182
|
+
getMethod: Camera.getMicrophonePermissionsAsync,
|
|
183
|
+
requestMethod: Camera.requestMicrophonePermissionsAsync,
|
|
184
|
+
});
|
|
185
|
+
|
|
144
186
|
_cameraHandle?: number | null;
|
|
145
187
|
_cameraRef?: React.Component | null;
|
|
146
188
|
_lastEvents: { [eventName: string]: string } = {};
|
|
@@ -214,23 +256,25 @@ export default class Camera extends React.Component<CameraProps> {
|
|
|
214
256
|
}
|
|
215
257
|
};
|
|
216
258
|
|
|
217
|
-
_onObjectDetected =
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
259
|
+
_onObjectDetected =
|
|
260
|
+
(callback?: Function) =>
|
|
261
|
+
({ nativeEvent }: { nativeEvent: any }) => {
|
|
262
|
+
const { type } = nativeEvent;
|
|
263
|
+
if (
|
|
264
|
+
this._lastEvents[type] &&
|
|
265
|
+
this._lastEventsTimes[type] &&
|
|
266
|
+
JSON.stringify(nativeEvent) === this._lastEvents[type] &&
|
|
267
|
+
new Date().getTime() - this._lastEventsTimes[type].getTime() < EventThrottleMs
|
|
268
|
+
) {
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
227
271
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
272
|
+
if (callback) {
|
|
273
|
+
callback(nativeEvent);
|
|
274
|
+
this._lastEventsTimes[type] = new Date();
|
|
275
|
+
this._lastEvents[type] = JSON.stringify(nativeEvent);
|
|
276
|
+
}
|
|
277
|
+
};
|
|
234
278
|
|
|
235
279
|
_setReference = (ref?: React.Component) => {
|
|
236
280
|
if (ref) {
|
package/src/Camera.types.ts
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
PermissionResponse,
|
|
3
|
+
PermissionStatus,
|
|
4
|
+
PermissionExpiration,
|
|
5
|
+
PermissionHookOptions,
|
|
6
|
+
} from 'expo-modules-core';
|
|
2
7
|
import { ViewProps } from 'react-native';
|
|
3
8
|
|
|
4
9
|
export enum CameraType {
|
|
@@ -301,4 +306,4 @@ export type BarCodeSettings = {
|
|
|
301
306
|
interval?: number;
|
|
302
307
|
};
|
|
303
308
|
|
|
304
|
-
export { PermissionResponse, PermissionStatus, PermissionExpiration };
|
|
309
|
+
export { PermissionResponse, PermissionStatus, PermissionExpiration, PermissionHookOptions };
|
package/src/ExponentCamera.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { requireNativeViewManager } from '
|
|
1
|
+
import { requireNativeViewManager } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
|
|
4
4
|
import { CameraNativeProps } from './Camera.types';
|
|
5
5
|
|
|
6
|
-
const ExponentCamera: React.ComponentType<CameraNativeProps> =
|
|
7
|
-
'ExponentCamera'
|
|
8
|
-
);
|
|
6
|
+
const ExponentCamera: React.ComponentType<CameraNativeProps> =
|
|
7
|
+
requireNativeViewManager('ExponentCamera');
|
|
9
8
|
|
|
10
9
|
export default ExponentCamera;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodedError } from '
|
|
1
|
+
import { CodedError } from 'expo-modules-core';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
|
|
4
4
|
import createElement from 'react-native-web/dist/exports/createElement';
|