expo-camera 13.7.0 → 13.9.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.
Files changed (112) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/android/build.gradle +62 -32
  3. package/android/src/main/AndroidManifest.xml +1 -0
  4. package/android/src/main/java/expo/modules/camera/CameraViewModule.kt +2 -2
  5. package/android/src/main/java/expo/modules/camera/Options.kt +2 -2
  6. package/android/src/main/java/expo/modules/camera/next/CameraExceptions.kt +9 -0
  7. package/android/src/main/java/expo/modules/camera/next/CameraViewHelper.kt +40 -0
  8. package/android/src/main/java/expo/modules/camera/next/CameraViewNextModule.kt +158 -0
  9. package/android/src/main/java/expo/modules/camera/next/ExpoCameraView.kt +479 -0
  10. package/android/src/main/java/expo/modules/camera/next/Options.kt +22 -0
  11. package/android/src/main/java/expo/modules/camera/next/analyzers/BarcodeAnalyzer.kt +77 -0
  12. package/android/src/main/java/expo/modules/camera/next/records/CameraRecords.kt +71 -0
  13. package/android/src/main/java/expo/modules/camera/next/tasks/PictureSavedDelegate.kt +7 -0
  14. package/android/src/main/java/expo/modules/camera/next/tasks/ResolveTakenPicture.kt +248 -0
  15. package/android/src/main/java/expo/modules/camera/next/utils/FileSystemUtils.kt +22 -0
  16. package/android/src/main/java/expo/modules/camera/next/utils/ImageDimensions.kt +16 -0
  17. package/android/src/main/java/expo/modules/camera/utils/FileSystemUtils.kt +8 -0
  18. package/build/Camera.d.ts +1 -1
  19. package/build/Camera.d.ts.map +1 -1
  20. package/build/Camera.js +2 -2
  21. package/build/Camera.js.map +1 -1
  22. package/build/{ExponentCamera.d.ts → ExpoCamera.d.ts} +1 -1
  23. package/build/ExpoCamera.d.ts.map +1 -0
  24. package/build/ExpoCamera.js +4 -0
  25. package/build/ExpoCamera.js.map +1 -0
  26. package/build/ExponentCamera.web.js +9 -6
  27. package/build/ExponentCamera.web.js.map +1 -1
  28. package/build/ExponentCameraManager.d.ts.map +1 -1
  29. package/build/ExponentCameraManager.js +1 -1
  30. package/build/ExponentCameraManager.js.map +1 -1
  31. package/build/next/Camera.d.ts +139 -0
  32. package/build/next/Camera.d.ts.map +1 -0
  33. package/build/next/Camera.js +256 -0
  34. package/build/next/Camera.js.map +1 -0
  35. package/build/next/Camera.types.d.ts +396 -0
  36. package/build/next/Camera.types.d.ts.map +1 -0
  37. package/build/next/Camera.types.js +15 -0
  38. package/build/next/Camera.types.js.map +1 -0
  39. package/build/next/ExpoCamera.d.ts +5 -0
  40. package/build/next/ExpoCamera.d.ts.map +1 -0
  41. package/build/next/ExpoCamera.js +4 -0
  42. package/build/next/ExpoCamera.js.map +1 -0
  43. package/build/next/ExpoCamera.web.d.ts +13 -0
  44. package/build/next/ExpoCamera.web.d.ts.map +1 -0
  45. package/build/next/ExpoCamera.web.js +106 -0
  46. package/build/next/ExpoCamera.web.js.map +1 -0
  47. package/build/next/ExpoCameraManager.d.ts +3 -0
  48. package/build/next/ExpoCameraManager.d.ts.map +1 -0
  49. package/build/next/ExpoCameraManager.js +3 -0
  50. package/build/next/ExpoCameraManager.js.map +1 -0
  51. package/build/next/ExpoCameraManager.web.d.ts +42 -0
  52. package/build/next/ExpoCameraManager.web.d.ts.map +1 -0
  53. package/build/next/ExpoCameraManager.web.js +216 -0
  54. package/build/next/ExpoCameraManager.web.js.map +1 -0
  55. package/build/next/index.d.ts +4 -0
  56. package/build/next/index.d.ts.map +1 -0
  57. package/build/next/index.js +4 -0
  58. package/build/next/index.js.map +1 -0
  59. package/build/next/utils/props.d.ts +8 -0
  60. package/build/next/utils/props.d.ts.map +1 -0
  61. package/build/next/utils/props.js +33 -0
  62. package/build/next/utils/props.js.map +1 -0
  63. package/expo-module.config.json +5 -2
  64. package/ios/CameraEnums.swift +98 -0
  65. package/ios/CameraExceptions.swift +55 -0
  66. package/ios/CameraPermissionsRequester.swift +125 -0
  67. package/ios/CameraRecordingOptions.swift +57 -0
  68. package/ios/CameraView.swift +982 -0
  69. package/ios/{EXCamera/CameraViewModule.swift → CameraViewModule.swift} +98 -90
  70. package/ios/CameraViewNextModule.swift +231 -0
  71. package/ios/{EXCamera.podspec → ExpoCamera.podspec} +7 -4
  72. package/ios/ExpoCameraUtils.swift +175 -0
  73. package/ios/Next/BarcodeRecord.swift +75 -0
  74. package/ios/Next/BarcodeScanner.swift +182 -0
  75. package/ios/Next/BarcodeScannerUtils.swift +117 -0
  76. package/ios/Next/CameraEnumsNext.swift +29 -0
  77. package/ios/Next/CameraRecordingOptionsNext.swift +54 -0
  78. package/ios/Next/CameraViewNext.swift +777 -0
  79. package/ios/Next/ExpoCameraUtilsNext.swift +175 -0
  80. package/ios/Next/PreviewView.swift +24 -0
  81. package/ios/Next/Scanner+Delegates.swift +52 -0
  82. package/ios/Next/TakePictureOptionsNext.swift +23 -0
  83. package/ios/Next/VisionScannerDelegate.swift +25 -0
  84. package/next.d.ts +1 -0
  85. package/next.js +1 -0
  86. package/package.json +2 -2
  87. package/src/Camera.tsx +3 -3
  88. package/src/{ExponentCamera.ts → ExpoCamera.ts} +1 -1
  89. package/src/ExponentCamera.web.tsx +4 -3
  90. package/src/ExponentCameraManager.ts +1 -1
  91. package/src/next/Camera.tsx +349 -0
  92. package/src/next/Camera.types.ts +447 -0
  93. package/src/next/ExpoCamera.ts +9 -0
  94. package/src/next/ExpoCamera.web.tsx +164 -0
  95. package/src/next/ExpoCameraManager.ts +3 -0
  96. package/src/next/ExpoCameraManager.web.ts +239 -0
  97. package/src/next/index.ts +9 -0
  98. package/src/next/utils/props.ts +45 -0
  99. package/build/ExponentCamera.d.ts.map +0 -1
  100. package/build/ExponentCamera.js +0 -4
  101. package/build/ExponentCamera.js.map +0 -1
  102. package/ios/EXCamera/EXCamera.h +0 -112
  103. package/ios/EXCamera/EXCamera.m +0 -1046
  104. package/ios/EXCamera/EXCameraCameraPermissionRequester.h +0 -7
  105. package/ios/EXCamera/EXCameraCameraPermissionRequester.m +0 -54
  106. package/ios/EXCamera/EXCameraMicrophonePermissionRequester.h +0 -7
  107. package/ios/EXCamera/EXCameraMicrophonePermissionRequester.m +0 -54
  108. package/ios/EXCamera/EXCameraPermissionRequester.h +0 -7
  109. package/ios/EXCamera/EXCameraPermissionRequester.m +0 -54
  110. package/ios/EXCamera/Utilities/EXCameraUtils.h +0 -35
  111. package/ios/EXCamera/Utilities/EXCameraUtils.m +0 -228
  112. /package/ios/{EXCamera/TakePictureOptions.swift → TakePictureOptions.swift} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,36 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 13.9.0 — 2023-11-14
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Bumped iOS deployment target to 13.4. ([#25063](https://github.com/expo/expo/pull/25063) by [@gabrieldonadel](https://github.com/gabrieldonadel))
18
+ - On `Android` bump `compileSdkVersion` and `targetSdkVersion` to `34`. ([#24708](https://github.com/expo/expo/pull/24708) by [@alanjhughes](https://github.com/alanjhughes))
19
+
20
+ ### 🎉 New features
21
+
22
+ - [iOS] Rewrote Objective-C classes to Swift. ([#22604](https://github.com/expo/expo/pull/22604) by [@alanjhughes](https://github.com/alanjhughes))
23
+
24
+ ### 🐛 Bug fixes
25
+
26
+ - [iOS] Fix a regression from ([#22604](https://github.com/expo/expo/pull/22604) that prevented the barcode scanner from starting.([#25053](https://github.com/expo/expo/pull/25053) by [@alanjhughes](https://github.com/alanjhughes))
27
+
28
+ ### 💡 Others
29
+
30
+ - Use `pointerEvent` style instead of prop. ([#24931](https://github.com/expo/expo/pull/24931) by [@EvanBacon](https://github.com/EvanBacon))
31
+
32
+ ## 13.8.0 — 2023-10-17
33
+
34
+ ### 🛠 Breaking changes
35
+
36
+ - Dropped support for Android SDK 21 and 22. ([#24201](https://github.com/expo/expo/pull/24201) by [@behenate](https://github.com/behenate))
37
+ - Mark the `ratio` param of `getAvailablePictureSizes` as required because omitting it causes a crash on Android. On iOS, the param has no effect. ([#24234](https://github.com/expo/expo/pull/24234) by [@vonovak](https://github.com/vonovak))
38
+
39
+ ### 💡 Others
40
+
41
+ - Ship untranspiled JSX to support custom handling of `jsx` and `createElement`. ([#24889](https://github.com/expo/expo/pull/24889) by [@EvanBacon](https://github.com/EvanBacon))
42
+
13
43
  ## 13.7.0 — 2023-09-15
14
44
 
15
45
  _This version does not introduce any user-facing changes._
@@ -3,15 +3,20 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '13.7.0'
7
-
8
- buildscript {
9
- def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
10
- if (expoModulesCorePlugin.exists()) {
11
- apply from: expoModulesCorePlugin
12
- applyKotlinExpoModulesCorePlugin()
6
+ version = '13.9.0'
7
+
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ // Remove this check, but keep the contents after SDK49 support is dropped
13
+ if (safeExtGet("expoProvidesDefaultConfig", false)) {
14
+ useExpoPublishing()
15
+ useCoreDependencies()
13
16
  }
17
+ }
14
18
 
19
+ buildscript {
15
20
  // Simple helper that allows the root project to override versions declared by this library.
16
21
  ext.safeExtGet = { prop, fallback ->
17
22
  rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
@@ -35,23 +40,44 @@ buildscript {
35
40
  }
36
41
  }
37
42
 
38
- afterEvaluate {
39
- publishing {
40
- publications {
41
- release(MavenPublication) {
42
- from components.release
43
+ // Remove this if and it's contents, when support for SDK49 is dropped
44
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
45
+ afterEvaluate {
46
+ publishing {
47
+ publications {
48
+ release(MavenPublication) {
49
+ from components.release
50
+ }
43
51
  }
44
- }
45
- repositories {
46
- maven {
47
- url = mavenLocal().url
52
+ repositories {
53
+ maven {
54
+ url = mavenLocal().url
55
+ }
48
56
  }
49
57
  }
50
58
  }
51
59
  }
52
60
 
53
61
  android {
54
- compileSdkVersion safeExtGet("compileSdkVersion", 33)
62
+ // Remove this if and it's contents, when support for SDK49 is dropped
63
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
64
+ compileSdkVersion safeExtGet("compileSdkVersion", 34)
65
+
66
+ defaultConfig {
67
+ minSdkVersion safeExtGet("minSdkVersion", 23)
68
+ targetSdkVersion safeExtGet("targetSdkVersion", 34)
69
+ }
70
+
71
+ publishing {
72
+ singleVariant("release") {
73
+ withSourcesJar()
74
+ }
75
+ }
76
+
77
+ lintOptions {
78
+ abortOnError false
79
+ }
80
+ }
55
81
 
56
82
  def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
57
83
  if (agpVersion.tokenize('.')[0].toInteger() < 8) {
@@ -67,19 +93,8 @@ android {
67
93
 
68
94
  namespace "expo.modules.camera"
69
95
  defaultConfig {
70
- minSdkVersion safeExtGet("minSdkVersion", 21)
71
- targetSdkVersion safeExtGet("targetSdkVersion", 33)
72
96
  versionCode 32
73
- versionName "13.7.0"
74
- }
75
-
76
- lintOptions {
77
- abortOnError false
78
- }
79
- publishing {
80
- singleVariant("release") {
81
- withSourcesJar()
82
- }
97
+ versionName "13.9.0"
83
98
  }
84
99
  }
85
100
 
@@ -91,10 +106,25 @@ repositories {
91
106
  }
92
107
 
93
108
  dependencies {
94
- implementation project(':expo-modules-core')
109
+ // Remove this if and it's contents, when support for SDK49 is dropped
110
+ if (!safeExtGet("expoProvidesDefaultConfig", false)) {
111
+ implementation project(':expo-modules-core')
112
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
113
+ }
114
+ def camerax_version = "1.3.0"
95
115
 
96
- api "androidx.exifinterface:exifinterface:1.0.0"
116
+ api "androidx.exifinterface:exifinterface:1.3.6"
97
117
  api 'com.google.android:cameraview:1.0.0'
98
118
 
99
- implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
119
+ implementation "androidx.camera:camera-core:${camerax_version}"
120
+ implementation "androidx.camera:camera-camera2:${camerax_version}"
121
+ implementation "androidx.camera:camera-lifecycle:${camerax_version}"
122
+ implementation "androidx.camera:camera-video:${camerax_version}"
123
+
124
+ implementation "androidx.camera:camera-view:${camerax_version}"
125
+ implementation "androidx.camera:camera-extensions:${camerax_version}"
126
+ implementation "com.google.mlkit:barcode-scanning:17.2.0"
127
+ implementation 'androidx.camera:camera-mlkit-vision:1.4.0-alpha02'
128
+
129
+ api 'com.google.android:cameraview:1.0.0'
100
130
  }
@@ -1,3 +1,4 @@
1
1
  <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
2
  <uses-permission android:name="android.permission.CAMERA" />
3
+ <uses-permission android:name="android.permission.RECORD_AUDIO" />
3
4
  </manifest>
@@ -17,7 +17,7 @@ import java.io.File
17
17
 
18
18
  class CameraViewModule : Module() {
19
19
  override fun definition() = ModuleDefinition {
20
- Name("ExponentCamera")
20
+ Name("ExpoCamera")
21
21
 
22
22
  Constants(
23
23
  "Type" to mapOf(
@@ -114,7 +114,7 @@ class CameraViewModule : Module() {
114
114
  return@AsyncFunction view.cameraView.supportedAspectRatios.map { it.toString() }
115
115
  }.runOnQueue(Queues.MAIN)
116
116
 
117
- AsyncFunction("getAvailablePictureSizes") { ratio: String?, viewTag: Int ->
117
+ AsyncFunction("getAvailablePictureSizes") { ratio: String, viewTag: Int ->
118
118
  val view = findView(viewTag)
119
119
 
120
120
  if (!view.cameraView.isCameraOpened) {
@@ -16,8 +16,8 @@ class PictureOptions : Record {
16
16
  }
17
17
 
18
18
  class RecordingOptions : Record {
19
- @Field val maxDuration: Int = -1
20
- @Field val maxFileSize: Int = -1
19
+ @Field val maxDuration: Int = 0
20
+ @Field val maxFileSize: Int = 0
21
21
  @Field val quality: Int = CamcorderProfile.QUALITY_HIGH
22
22
  @Field val mute: Boolean = false
23
23
  @Field val videoBitrate: Int? = null
@@ -0,0 +1,9 @@
1
+ package expo.modules.camera.next
2
+
3
+ import expo.modules.kotlin.exception.CodedException
4
+
5
+ class CameraExceptions {
6
+ class ImageCaptureFailed : CodedException(message = "Failed to capture image")
7
+
8
+ class VideoRecordingFailed(cause: String?) : CodedException("Video recording failed: $cause")
9
+ }
@@ -0,0 +1,40 @@
1
+ package expo.modules.camera.next
2
+
3
+ import android.graphics.Bitmap
4
+ import android.graphics.Canvas
5
+ import android.graphics.Color
6
+ import android.graphics.Paint
7
+ import expo.modules.camera.next.records.CameraType
8
+ import java.io.ByteArrayOutputStream
9
+ import java.text.SimpleDateFormat
10
+ import java.util.Calendar
11
+ import java.util.Locale
12
+
13
+ object CameraViewHelper {
14
+ // Utilities
15
+ @JvmStatic
16
+ fun getCorrectCameraRotation(rotation: Int, facing: CameraType) =
17
+ if (facing == CameraType.FRONT) (rotation - 90 + 360) % 360
18
+ else (-rotation + 90 + 360) % 360
19
+
20
+ fun generateSimulatorPhoto(width: Int, height: Int): ByteArray {
21
+ val fakePhotoBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
22
+ val canvas = Canvas(fakePhotoBitmap)
23
+ val background = Paint().apply {
24
+ color = Color.BLACK
25
+ }
26
+ canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), background)
27
+ val textPaint = Paint().apply {
28
+ color = Color.YELLOW
29
+ textSize = 35f
30
+ }
31
+ val calendar = Calendar.getInstance()
32
+ val simpleDateFormat = SimpleDateFormat("dd.MM.yy HH:mm:ss", Locale.US)
33
+ canvas.drawText(simpleDateFormat.format(calendar.time), width * 0.1f, height * 0.9f, textPaint)
34
+
35
+ val stream = ByteArrayOutputStream()
36
+ fakePhotoBitmap.compress(Bitmap.CompressFormat.PNG, 90, stream)
37
+ val fakePhotoByteArray = stream.toByteArray()
38
+ return fakePhotoByteArray
39
+ }
40
+ }
@@ -0,0 +1,158 @@
1
+ package expo.modules.camera.next
2
+
3
+ import android.Manifest
4
+ import android.util.Log
5
+ import expo.modules.camera.next.records.BarCodeSettings
6
+ import expo.modules.camera.next.records.CameraMode
7
+ import expo.modules.camera.next.records.CameraType
8
+ import expo.modules.camera.next.records.FlashMode
9
+ import expo.modules.camera.next.tasks.ResolveTakenPicture
10
+ import expo.modules.core.errors.ModuleDestroyedException
11
+ import expo.modules.core.utilities.EmulatorUtilities
12
+ import expo.modules.interfaces.permissions.Permissions
13
+ import expo.modules.kotlin.Promise
14
+ import expo.modules.kotlin.exception.Exceptions
15
+ import expo.modules.kotlin.functions.Queues
16
+ import expo.modules.kotlin.modules.Module
17
+ import expo.modules.kotlin.modules.ModuleDefinition
18
+ import kotlinx.coroutines.CoroutineScope
19
+ import kotlinx.coroutines.Dispatchers
20
+ import kotlinx.coroutines.cancel
21
+ import kotlinx.coroutines.launch
22
+ import java.io.File
23
+
24
+ val cameraEvents = arrayOf(
25
+ "onCameraReady",
26
+ "onMountError",
27
+ "onBarCodeScanned",
28
+ "onFacesDetected",
29
+ "onFaceDetectionError",
30
+ "onPictureSaved"
31
+ )
32
+
33
+ class CameraViewNextModule : Module() {
34
+ private val moduleScope = CoroutineScope(Dispatchers.Main)
35
+ override fun definition() = ModuleDefinition {
36
+ Name("ExpoCameraNext")
37
+
38
+ Events("onModernBarcodeScanned")
39
+
40
+ AsyncFunction("requestCameraPermissionsAsync") { promise: Promise ->
41
+ Permissions.askForPermissionsWithPermissionsManager(
42
+ permissionsManager,
43
+ promise,
44
+ Manifest.permission.CAMERA
45
+ )
46
+ }
47
+
48
+ AsyncFunction("requestMicrophonePermissionsAsync") { promise: Promise ->
49
+ Permissions.askForPermissionsWithPermissionsManager(
50
+ permissionsManager,
51
+ promise,
52
+ Manifest.permission.RECORD_AUDIO
53
+ )
54
+ }
55
+
56
+ AsyncFunction("getCameraPermissionsAsync") { promise: Promise ->
57
+ Permissions.getPermissionsWithPermissionsManager(
58
+ permissionsManager,
59
+ promise,
60
+ Manifest.permission.CAMERA
61
+ )
62
+ }
63
+
64
+ AsyncFunction("getMicrophonePermissionsAsync") { promise: Promise ->
65
+ Permissions.getPermissionsWithPermissionsManager(
66
+ permissionsManager,
67
+ promise,
68
+ Manifest.permission.RECORD_AUDIO
69
+ )
70
+ }
71
+
72
+ OnDestroy {
73
+ try {
74
+ moduleScope.cancel(ModuleDestroyedException())
75
+ } catch (e: IllegalStateException) {
76
+ Log.e(TAG, "The scope does not have a job in it")
77
+ }
78
+ }
79
+
80
+ View(ExpoCameraView::class) {
81
+ Events(cameraEvents)
82
+
83
+ Prop("type") { view, type: CameraType ->
84
+ view.lenFacing = type
85
+ }
86
+
87
+ Prop("flashMode") { view, flashMode: FlashMode ->
88
+ view.setCameraFlashMode(flashMode)
89
+ }
90
+
91
+ Prop("enableTorch") { view, enabled: Boolean ->
92
+ view.setTorchEnabled(enabled)
93
+ }
94
+
95
+ Prop("zoom") { view, zoom: Float ->
96
+ view.camera?.cameraControl?.setLinearZoom(zoom)
97
+ }
98
+
99
+ Prop("mode") { view, mode: CameraMode ->
100
+ view.cameraMode = mode
101
+ }
102
+
103
+ Prop("mute") { view, muted: Boolean? ->
104
+ view.mute = muted ?: false
105
+ }
106
+
107
+ Prop("barCodeScannerSettings") { view, settings: BarCodeSettings? ->
108
+ if (settings == null) {
109
+ return@Prop
110
+ }
111
+ view.setBarCodeScannerSettings(settings)
112
+ }
113
+
114
+ Prop("barCodeScannerEnabled") { view, barCodeScannerEnabled: Boolean? ->
115
+ view.setShouldScanBarCodes(barCodeScannerEnabled ?: false)
116
+ }
117
+
118
+ AsyncFunction("takePicture") { view: ExpoCameraView, options: PictureOptions, promise: Promise ->
119
+ if (!EmulatorUtilities.isRunningOnEmulator()) {
120
+ view.takePicture(options, promise, cacheDirectory)
121
+ } else {
122
+ val image = CameraViewHelper.generateSimulatorPhoto(view.width, view.height)
123
+ moduleScope.launch {
124
+ ResolveTakenPicture(image, promise, options, cacheDirectory) { response ->
125
+ view.onPictureSaved(response)
126
+ }.resolve()
127
+ }
128
+ }
129
+ }.runOnQueue(Queues.MAIN)
130
+
131
+ AsyncFunction("record") { view: ExpoCameraView, options: RecordingOptions, promise: Promise ->
132
+ if (!view.mute && !permissionsManager.hasGrantedPermissions(Manifest.permission.RECORD_AUDIO)) {
133
+ throw Exceptions.MissingPermissions(Manifest.permission.RECORD_AUDIO)
134
+ }
135
+
136
+ view.record(options, promise, cacheDirectory)
137
+ }.runOnQueue(Queues.MAIN)
138
+
139
+ AsyncFunction("stopRecording") { view: ExpoCameraView ->
140
+ view.activeRecording?.close()
141
+ }.runOnQueue(Queues.MAIN)
142
+
143
+ OnViewDestroys { view ->
144
+ view.cancelCoroutineScope()
145
+ }
146
+ }
147
+ }
148
+
149
+ private val cacheDirectory: File
150
+ get() = appContext.cacheDirectory
151
+
152
+ private val permissionsManager: Permissions
153
+ get() = appContext.permissions ?: throw Exceptions.PermissionsModuleNotFound()
154
+
155
+ companion object {
156
+ internal val TAG = CameraViewNextModule::class.java.simpleName
157
+ }
158
+ }