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.
Files changed (63) hide show
  1. package/CHANGELOG.md +15 -13
  2. package/android/build.gradle +3 -6
  3. package/android/src/main/java/expo/modules/camera/CameraModule.java +5 -5
  4. package/android/src/main/java/expo/modules/camera/CameraPackage.java +3 -3
  5. package/android/src/main/java/expo/modules/camera/CameraViewHelper.java +1 -1
  6. package/android/src/main/java/expo/modules/camera/CameraViewManager.java +4 -4
  7. package/android/src/main/java/expo/modules/camera/ExpoCameraView.java +5 -5
  8. package/android/src/main/java/expo/modules/camera/events/BarCodeScannedEvent.java +1 -1
  9. package/android/src/main/java/expo/modules/camera/events/CameraMountErrorEvent.java +1 -1
  10. package/android/src/main/java/expo/modules/camera/events/CameraReadyEvent.java +1 -1
  11. package/android/src/main/java/expo/modules/camera/events/FaceDetectionErrorEvent.java +1 -1
  12. package/android/src/main/java/expo/modules/camera/events/FacesDetectedEvent.java +1 -1
  13. package/android/src/main/java/expo/modules/camera/events/PictureSavedEvent.java +1 -1
  14. package/android/src/main/java/expo/modules/camera/tasks/ResolveTakenPictureAsyncTask.java +1 -1
  15. package/build/Camera.d.ts +26 -0
  16. package/build/Camera.js +103 -68
  17. package/build/Camera.js.map +1 -1
  18. package/build/Camera.types.d.ts +2 -2
  19. package/build/Camera.types.js +1 -1
  20. package/build/Camera.types.js.map +1 -1
  21. package/build/ExponentCamera.js +1 -1
  22. package/build/ExponentCamera.js.map +1 -1
  23. package/build/ExponentCamera.web.js +2 -1
  24. package/build/ExponentCamera.web.js.map +1 -1
  25. package/build/ExponentCameraManager.js +1 -1
  26. package/build/ExponentCameraManager.js.map +1 -1
  27. package/build/ExponentCameraManager.web.js +1 -1
  28. package/build/ExponentCameraManager.web.js.map +1 -1
  29. package/build/WebCameraUtils.js +4 -4
  30. package/build/WebCameraUtils.js.map +1 -1
  31. package/build/WebConstants.d.ts +1 -1
  32. package/build/WebUserMediaManager.js +9 -9
  33. package/build/WebUserMediaManager.js.map +1 -1
  34. package/build/useWebCameraStream.js +2 -2
  35. package/build/useWebCameraStream.js.map +1 -1
  36. package/build/utils/props.js +1 -1
  37. package/build/utils/props.js.map +1 -1
  38. package/ios/EXCamera/EXCamera.h +6 -6
  39. package/ios/EXCamera/EXCamera.m +76 -76
  40. package/ios/EXCamera/EXCameraCameraPermissionRequester.m +5 -5
  41. package/ios/EXCamera/EXCameraManager.h +4 -4
  42. package/ios/EXCamera/EXCameraManager.m +59 -59
  43. package/ios/EXCamera/EXCameraMicrophonePermissionRequester.m +5 -5
  44. package/ios/EXCamera/EXCameraPermissionRequester.m +5 -5
  45. package/ios/EXCamera.podspec +2 -2
  46. package/ios/EXCamera.xcframework/Info.plist +5 -5
  47. package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/EXCamera +0 -0
  48. package/ios/EXCamera.xcframework/ios-arm64/EXCamera.framework/Info.plist +0 -0
  49. package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/EXCamera +0 -0
  50. package/ios/EXCamera.xcframework/ios-arm64_x86_64-simulator/EXCamera.framework/Info.plist +0 -0
  51. package/package.json +6 -6
  52. package/plugin/build/withCamera.js +2 -2
  53. package/plugin/src/withCamera.ts +2 -2
  54. package/src/Camera.tsx +61 -17
  55. package/src/Camera.types.ts +7 -2
  56. package/src/ExponentCamera.ts +3 -4
  57. package/src/ExponentCamera.web.tsx +1 -1
  58. package/src/ExponentCameraManager.ts +1 -1
  59. package/src/ExponentCameraManager.web.ts +2 -2
  60. package/src/WebCameraUtils.ts +5 -11
  61. package/src/WebUserMediaManager.ts +10 -10
  62. package/src/useWebCameraStream.ts +2 -2
  63. package/src/utils/props.ts +1 -1
@@ -1,4 +1,4 @@
1
- import { UnavailabilityError } from '@unimodules/core';
1
+ import { UnavailabilityError } from 'expo-modules-core';
2
2
 
3
3
  import {
4
4
  CameraCapturedPicture,
@@ -28,7 +28,7 @@ function getUserMedia(constraints: MediaStreamConstraints): Promise<MediaStream>
28
28
  navigator.getUserMedia ||
29
29
  (navigator as any).webkitGetUserMedia ||
30
30
  (navigator as any).mozGetUserMedia ||
31
- function() {
31
+ function () {
32
32
  const error: any = new Error('Permission unimplemented');
33
33
  error.code = 0;
34
34
  error.name = 'NotAllowedError';
@@ -278,7 +278,7 @@ export async function syncTrackCapabilities(
278
278
  ): Promise<void> {
279
279
  if (stream?.getVideoTracks) {
280
280
  await Promise.all(
281
- stream.getVideoTracks().map(track => onCapabilitiesReady(cameraType, track, settings))
281
+ stream.getVideoTracks().map((track) => onCapabilitiesReady(cameraType, track, settings))
282
282
  );
283
283
  }
284
284
  }
@@ -363,10 +363,10 @@ export function stopMediaStream(stream: MediaStream | null) {
363
363
  return;
364
364
  }
365
365
  if (stream.getAudioTracks) {
366
- stream.getAudioTracks().forEach(track => track.stop());
366
+ stream.getAudioTracks().forEach((track) => track.stop());
367
367
  }
368
368
  if (stream.getVideoTracks) {
369
- stream.getVideoTracks().forEach(track => track.stop());
369
+ stream.getVideoTracks().forEach((track) => track.stop());
370
370
  }
371
371
  if (isMediaStreamTrack(stream)) {
372
372
  stream.stop();
@@ -433,14 +433,8 @@ function validatedConstrainedValue<T>(props: {
433
433
  settings: WebCameraSettings;
434
434
  cameraType: string;
435
435
  }): T | undefined {
436
- const {
437
- constraintKey,
438
- settingsKey,
439
- convertedSetting,
440
- capabilities,
441
- settings,
442
- cameraType,
443
- } = props;
436
+ const { constraintKey, settingsKey, convertedSetting, capabilities, settings, cameraType } =
437
+ props;
444
438
  const setting = settings[settingsKey];
445
439
  if (
446
440
  Array.isArray(capabilities[constraintKey]) &&
@@ -2,16 +2,16 @@
2
2
  /**
3
3
  * A web-only module for ponyfilling the UserMedia API.
4
4
  */
5
- import { Platform } from '@unimodules/core';
5
+ import { Platform } from 'expo-modules-core';
6
6
 
7
7
  export const userMediaRequested: boolean = false;
8
8
 
9
9
  export const mountedInstances: any[] = [];
10
10
 
11
11
  async function requestLegacyUserMediaAsync(props): Promise<any[]> {
12
- const optionalSource = id => ({ optional: [{ sourceId: id }] });
12
+ const optionalSource = (id) => ({ optional: [{ sourceId: id }] });
13
13
 
14
- const constraintToSourceId = constraint => {
14
+ const constraintToSourceId = (constraint) => {
15
15
  const { deviceId } = constraint;
16
16
 
17
17
  if (typeof deviceId === 'string') {
@@ -29,15 +29,15 @@ async function requestLegacyUserMediaAsync(props): Promise<any[]> {
29
29
  return null;
30
30
  };
31
31
 
32
- const sources: any[] = await new Promise(resolve =>
32
+ const sources: any[] = await new Promise((resolve) =>
33
33
  // @ts-ignore: https://caniuse.com/#search=getSources Chrome for Android (78) & Samsung Internet (10.1) use this
34
- MediaStreamTrack.getSources(sources => resolve(sources))
34
+ MediaStreamTrack.getSources((sources) => resolve(sources))
35
35
  );
36
36
 
37
37
  let audioSource = null;
38
38
  let videoSource = null;
39
39
 
40
- sources.forEach(source => {
40
+ sources.forEach((source) => {
41
41
  if (source.kind === 'audio') {
42
42
  audioSource = source.id;
43
43
  } else if (source.kind === 'video') {
@@ -151,11 +151,11 @@ async function supportsCameraType(
151
151
  }
152
152
  devices = await navigator.mediaDevices.enumerateDevices();
153
153
  }
154
- const cameras = devices.filter(t => t.kind === 'videoinput');
155
- const [hasCamera] = cameras.filter(camera =>
156
- labels.some(label => camera.label.toLowerCase().includes(label))
154
+ const cameras = devices.filter((t) => t.kind === 'videoinput');
155
+ const [hasCamera] = cameras.filter((camera) =>
156
+ labels.some((label) => camera.label.toLowerCase().includes(label))
157
157
  );
158
- const [isCapable] = cameras.filter(camera => {
158
+ const [isCapable] = cameras.filter((camera) => {
159
159
  if (!('getCapabilities' in camera)) {
160
160
  return null;
161
161
  }
@@ -101,7 +101,7 @@ export function useWebCameraStream(
101
101
 
102
102
  // Save a history of all active streams (usually 2+) so we can close them later.
103
103
  // Keeping them open makes swapping camera types much faster.
104
- if (!activeStreams.current.some(value => value.id === nextStream?.id)) {
104
+ if (!activeStreams.current.some((value) => value.id === nextStream?.id)) {
105
105
  activeStreams.current.push(nextStream!);
106
106
  }
107
107
 
@@ -121,7 +121,7 @@ export function useWebCameraStream(
121
121
  isStartingCamera.current = true;
122
122
 
123
123
  resumeAsync()
124
- .then(isStarting => {
124
+ .then((isStarting) => {
125
125
  isStartingCamera.current = isStarting;
126
126
  })
127
127
  .catch(() => {
@@ -1,4 +1,4 @@
1
- import { Platform } from '@unimodules/core';
1
+ import { Platform } from 'expo-modules-core';
2
2
 
3
3
  import {
4
4
  CameraNativeProps,