@capacitor-community/camera-preview 6.0.0 → 7.0.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.
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.author = package['author']
12
12
  s.source = { :git => 'https://github.com/capacitor-community/camera-preview.git', :tag => s.version.to_s }
13
13
  s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
14
- s.ios.deployment_target = '13.0'
14
+ s.ios.deployment_target = '14.0'
15
15
  s.dependency 'Capacitor'
16
16
  s.swift_version = '5.1'
17
17
  end
package/README.md CHANGED
@@ -2,13 +2,15 @@
2
2
  <h3 align="center">Capacitor Camera Preview</h3>
3
3
  <p align="center"><strong><code>@capacitor-community/camera-preview</code></strong></p>
4
4
  <br>
5
- <p align="center"><strong>CAPACITOR 5</strong></p><br>
5
+ <p align="center"><strong>CAPACITOR 7</strong></p><br>
6
6
 
7
7
  <p align="center">
8
8
  Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
9
9
  </p>
10
10
  <br>
11
- Version 6 of this plugin requires Capacitor 6.
11
+ Version 7 of this plugin requires Capacitor 7.
12
+
13
+ If you are using Capacitor 6, use [version 6.1](https://github.com/capacitor-community/camera-preview/releases/tag/v6.0.1)
12
14
 
13
15
  If you are using Capacitor 5, use [version 5](https://github.com/capacitor-community/camera-preview/releases/tag/v5.0.0)
14
16
 
@@ -46,18 +48,23 @@ or
46
48
 
47
49
  npm install @capacitor-community/camera-preview
48
50
  ```
51
+
49
52
  Then run
53
+
50
54
  ```
51
55
  npx cap sync
52
56
  ```
53
57
 
54
58
  ## Extra Android installation steps
59
+
55
60
  **Important** `camera-preview` 3+ requires Gradle 7. If you are using Gradle 4, please use [version 2](https://github.com/capacitor-community/camera-preview/tree/v2.1.0) of this plugin.
56
61
 
57
62
  Open `android/app/src/main/AndroidManifest.xml` and above the closing `</manifest>` tag add this line to request the CAMERA permission:
63
+
58
64
  ```xml
59
65
  <uses-permission android:name="android.permission.CAMERA" />
60
66
  ```
67
+
61
68
  For more help consult the [Capacitor docs](https://capacitorjs.com/docs/android/configuration#configuring-androidmanifestxml).
62
69
 
63
70
  ### Variables
@@ -67,6 +74,7 @@ This plugin will use the following project variables (defined in your app's `var
67
74
  - `androidxExifInterfaceVersion`: version of `androidx.exifinterface:exifinterface` (default: `1.3.6`)
68
75
 
69
76
  ## Extra iOS installation steps
77
+
70
78
  You will need to add two permissions to `Info.plist`. Follow the [Capacitor docs](https://capacitorjs.com/docs/ios/configuration#configuring-infoplist) and add permissions with the raw keys `NSCameraUsageDescription` and `NSMicrophoneUsageDescription`. `NSMicrophoneUsageDescription` is only required, if audio will be used. Otherwise set the `disableAudio` option to `true`, which also disables the microphone permission request.
71
79
 
72
80
  ## Extra Web installation steps
@@ -77,31 +85,31 @@ then in html add `<div id="cameraPreview"></div>`
77
85
 
78
86
  and `CameraPreview.start({ parent: "cameraPreview"});` will work.
79
87
 
80
-
81
88
  # Methods
82
89
 
83
90
  ### start(options)
84
91
 
85
92
  Starts the camera preview instance.
93
+
86
94
  <br>
87
95
 
88
- | Option | values | descriptions |
89
- |----------|---------------|------------------------------------------------------------------------|
90
- | position | front \| rear | Show front or rear camera when start the preview. Defaults to front |
91
- | width | number | (optional) The preview width in pixels, default window.screen.width (applicable to the android and ios platforms only) |
92
- | height | number | (optional) The preview height in pixels, default window.screen.height (applicable to the android and ios platforms only) |
93
- | x | number | (optional) The x origin, default 0 (applicable to the android and ios platforms only) |
94
- | y | number | (optional) The y origin, default 0 (applicable to the android and ios platforms only) |
95
- | toBack | boolean | (optional) Brings your html in front of your preview, default false (applicable to the android and ios platforms only) |
96
- | paddingBottom | number | (optional) The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) |
97
- | rotateWhenOrientationChanged | boolean | (optional) Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
98
- | storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
99
- | disableExifHeaderStripping | boolean | (optional) Disable automatic rotation of the image, and let the browser deal with it, default true (applicable to the android and ios platforms only) |
100
- | enableHighResolution | boolean | (optional) Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device |
101
- | disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web and iOS only) |
102
- | lockAndroidOrientation | boolean | (optional) Locks device orientation when camera is showing, default false. (applicable to Android only) |
103
- | enableOpacity | boolean | (optional) Make the camera preview see-through. Ideal for augmented reality uses. Default false (applicable to Android and web only)
104
- | enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to the android and ios platforms only)
96
+ | Option | values | descriptions |
97
+ | ---------------------------- | ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
98
+ | position | front \| rear | Show front or rear camera when start the preview. Defaults to front |
99
+ | width | number | (optional) The preview width in pixels, default window.screen.width (applicable to the android and ios platforms only) |
100
+ | height | number | (optional) The preview height in pixels, default window.screen.height (applicable to the android and ios platforms only) |
101
+ | x | number | (optional) The x origin, default 0 (applicable to the android and ios platforms only) |
102
+ | y | number | (optional) The y origin, default 0 (applicable to the android and ios platforms only) |
103
+ | toBack | boolean | (optional) Brings your html in front of your preview, default false (applicable to the android and ios platforms only) |
104
+ | paddingBottom | number | (optional) The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) |
105
+ | rotateWhenOrientationChanged | boolean | (optional) Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
106
+ | storeToFile | boolean | (optional) Capture images to a file and return back the file path instead of returning base64 encoded data, default false. |
107
+ | disableExifHeaderStripping | boolean | (optional) Disable automatic rotation of the image, and let the browser deal with it, default true (applicable to the android and ios platforms only) |
108
+ | enableHighResolution | boolean | (optional) Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device |
109
+ | disableAudio | boolean | (optional) Disables audio stream to prevent permission requests, default false. (applicable to web and iOS only) |
110
+ | lockAndroidOrientation | boolean | (optional) Locks device orientation when camera is showing, default false. (applicable to Android only) |
111
+ | enableOpacity | boolean | (optional) Make the camera preview see-through. Ideal for augmented reality uses. Default false (applicable to Android and web only) |
112
+ | enableZoom | boolean | (optional) Set if you can pinch to zoom. Default false (applicable to the android and ios platforms only) |
105
113
 
106
114
  <!-- <strong>Options:</strong>
107
115
  All options stated are optional and will default to values here
@@ -146,7 +154,8 @@ Take into account that this will make transparent all ion-content on application
146
154
  ```
147
155
 
148
156
  If the camera preview is not displaying after applying the above styles, apply transparent background color to the root div element of the parent component
149
- Ex: VueJS >> App.vue component
157
+ Ex: VueJS >> App.vue component
158
+
150
159
  ```html
151
160
  <template>
152
161
  <ion-app id="app">
@@ -161,20 +170,19 @@ Ex: VueJS >> App.vue component
161
170
  <style>
162
171
  ```
163
172
 
164
-
165
173
  ### stop()
166
174
 
167
- <info>Stops the camera preview instance.</info><br/>
175
+ <info>Stops the camera preview instance.</info>
176
+ <br />
168
177
 
169
178
  ```javascript
170
179
  CameraPreview.stop();
171
180
  ```
172
181
 
173
182
  ### flip()
183
+
174
184
  <info>Switch between rear and front camera only for android and ios, web is not supported</info>
175
- ```javascript
176
- CameraPreview.flip()
177
- ```
185
+ ```javascript CameraPreview.flip() ```
178
186
 
179
187
  <!-- ### switchCamera([successCallback, errorCallback])
180
188
 
@@ -202,11 +210,11 @@ CameraPreview.hide();
202
210
 
203
211
  ### capture(options)
204
212
 
205
- | Option | values | descriptions |
206
- |----------|---------------|----------------------------------------------------------------------|
207
- | quality | number | (optional) The picture quality, 0 - 100, default 85 |
208
- | width | number | (optional) The picture width, default 0 (Device default) |
209
- | height | number | (optional) The picture height, default 0 (Device default) |
213
+ | Option | values | descriptions |
214
+ | ------- | ------ | --------------------------------------------------------- |
215
+ | quality | number | (optional) The picture quality, 0 - 100, default 85 |
216
+ | width | number | (optional) The picture width, default 0 (Device default) |
217
+ | height | number | (optional) The picture height, default 0 (Device default) |
210
218
 
211
219
  <!-- <info>Take the picture. If width and height are not specified or are 0 it will use the defaults. If width and height are specified, it will choose a supported photo size that is closest to width and height specified and has closest aspect ratio to the preview. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/> -->
212
220
 
@@ -226,11 +234,16 @@ const base64PictureData = result.value;
226
234
 
227
235
  ### captureSample(options)
228
236
 
229
- | Option | values | descriptions |
230
- |----------|---------------|----------------------------------------------------------------------|
231
- | quality | number | (optional) The picture quality, 0 - 100, default 85 |
237
+ | Option | values | descriptions |
238
+ | ------- | ------ | --------------------------------------------------- |
239
+ | quality | number | (optional) The picture quality, 0 - 100, default 85 |
232
240
 
233
- <info>Captures a sample image from the video stream. Only for Android and iOS, web implementation falls back to `capture` method. This can be used to perform real-time analysis on the current frame in the video. The argument `quality` defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.</info><br/>
241
+ <info>
242
+ Captures a sample image from the video stream. Only for Android and iOS, web implementation falls back to `capture`
243
+ method. This can be used to perform real-time analysis on the current frame in the video. The argument `quality`
244
+ defaults to `85` and specifies the quality/compression value: `0=max compression`, `100=max quality`.
245
+ </info>
246
+ <br />
234
247
 
235
248
  ```javascript
236
249
  import { CameraSampleOptions } from '@capacitor-community/camera-preview';
@@ -248,7 +261,11 @@ const base64PictureData = result.value;
248
261
 
249
262
  ### getSupportedFlashModes()
250
263
 
251
- <info>Get the flash modes supported by the camera device currently started. Returns an array containing supported flash modes. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for possible values that can be returned</info><br/>
264
+ <info>
265
+ Get the flash modes supported by the camera device currently started. Returns an array containing supported flash
266
+ modes. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for possible values that can be returned
267
+ </info>
268
+ <br />
252
269
 
253
270
  ```javascript
254
271
  import { CameraPreviewFlashMode } from '@capacitor-community/camera-preview';
@@ -256,9 +273,14 @@ import { CameraPreviewFlashMode } from '@capacitor-community/camera-preview';
256
273
  const flashModes = await CameraPreview.getSupportedFlashModes();
257
274
  const supportedFlashModes: CameraPreviewFlashMode[] = flashModes.result;
258
275
  ```
276
+
259
277
  ### setFlashMode(options)
260
278
 
261
- <info>Set the flash mode. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for details about the possible values for flashMode.</info><br/>
279
+ <info>
280
+ Set the flash mode. See <code>[FLASH_MODE](#camera_Settings.FlashMode)</code> for details about the possible values
281
+ for flashMode.
282
+ </info>
283
+ <br />
262
284
 
263
285
  ```javascript
264
286
  const CameraPreviewFlashMode: CameraPreviewFlashMode = 'torch';
@@ -266,9 +288,10 @@ const CameraPreviewFlashMode: CameraPreviewFlashMode = 'torch';
266
288
  CameraPreview.setFlashMode(cameraPreviewFlashMode);
267
289
  ```
268
290
 
269
- ### startRecordVideo(options) ---- ANDROID and iOS only
291
+ ### startRecordVideo(options) ---- ANDROID and iOS only
270
292
 
271
- <info>Start capturing video</info><br/>
293
+ <info>Start capturing video</info>
294
+ <br />
272
295
 
273
296
  ```javascript
274
297
  const cameraPreviewOptions: CameraPreviewOptions = {
@@ -280,21 +303,32 @@ const cameraPreviewOptions: CameraPreviewOptions = {
280
303
  CameraPreview.startRecordVideo(cameraPreviewOptions);
281
304
  ```
282
305
 
283
- ### stopRecordVideo() ---- ANDROID and iOS only
306
+ ### stopRecordVideo() ---- ANDROID and iOS only
284
307
 
285
- <info>Finish capturing a video. The captured video will be returned as a file path and the video format is .mp4</info><br/>
308
+ <info>Finish capturing a video. The captured video will be returned as a file path and the video format is .mp4</info>
309
+ <br />
286
310
 
287
311
  ```javascript
288
312
  const resultRecordVideo = await CameraPreview.stopRecordVideo();
289
313
  ```
290
314
 
291
- ### setOpacity(options: CameraOpacityOptions): Promise<{}>; ---- ANDROID only
315
+ ### setOpacity(options: CameraOpacityOptions): Promise<{}>; ---- ANDROID only
292
316
 
293
- <info>Set the opacity for the camera preview</info><br/>
317
+ <info>Set the opacity for the camera preview</info>
318
+ <br />
294
319
 
295
320
  ```javascript
296
- const myCamera = CameraPreview.start({enableOpacity: true});
297
- myCamera.setOpacity({opacity: 0.4});
321
+ const myCamera = CameraPreview.start({ enableOpacity: true });
322
+ myCamera.setOpacity({ opacity: 0.4 });
323
+ ```
324
+
325
+ ### isCameraStarted() ---- ANDROID and iOS only
326
+
327
+ <info>Check or detect if the camera has been started</info>
328
+ <br />
329
+
330
+ ```javascript
331
+ const { value } = await CameraPreview.isCameraStarted();
298
332
  ```
299
333
 
300
334
  # Settings
@@ -303,15 +337,16 @@ myCamera.setOpacity({opacity: 0.4});
303
337
 
304
338
  ### FLASH_MODE
305
339
 
306
- <info>Flash mode settings:</info><br/>
340
+ <info>Flash mode settings:</info>
341
+ <br />
307
342
 
308
- | Name | Type | Default | Note |
309
- | ------- | ------- | ------- | ------------- |
310
- | OFF | string | off | |
311
- | ON | string | on | |
312
- | AUTO | string | auto | |
313
- | RED_EYE | string | red-eye | Android Only |
314
- | TORCH | string | torch | |
343
+ | Name | Type | Default | Note |
344
+ | ------- | ------ | ------- | ------------ |
345
+ | OFF | string | off | |
346
+ | ON | string | on | |
347
+ | AUTO | string | auto | |
348
+ | RED_EYE | string | red-eye | Android Only |
349
+ | TORCH | string | torch | |
315
350
 
316
351
  <!--
317
352
 
@@ -441,8 +476,6 @@ Maintained by [Weston Ganger](https://westonganger.com) - [@westonganger](https:
441
476
  Created by Marcel Barbosa Pinto [@mbppower](https://github.com/mbppower)
442
477
  Â -->
443
478
 
444
- # Demo
445
-
446
- A working example can be found at [Demo](https://github.com/capacitor-community/camera-preview/tree/master/demo)
479
+ # Demo/Example App
447
480
 
448
- To run the demo on your local network and access media devices, a secure context is needed. Add an `.env` file at the root of the demo folder with `HTTPS=true` to start react with HTTPS.
481
+ A working example can be found at [Example App](https://github.com/capacitor-community/camera-preview/tree/master/example-app)
@@ -1,9 +1,9 @@
1
1
  ext {
2
2
  junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
3
- androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
4
- androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.6'
5
- androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
6
- androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
3
+ androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.7.0'
4
+ androidxExifInterfaceVersion = project.hasProperty('androidxExifInterfaceVersion') ? rootProject.ext.androidxExifInterfaceVersion : '1.3.7'
5
+ androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.2.1'
6
+ androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.6.1'
7
7
  }
8
8
 
9
9
  buildscript {
@@ -12,7 +12,7 @@ buildscript {
12
12
  google()
13
13
  }
14
14
  dependencies {
15
- classpath 'com.android.tools.build:gradle:8.2.1'
15
+ classpath 'com.android.tools.build:gradle:8.7.2'
16
16
  }
17
17
  }
18
18
 
@@ -20,10 +20,10 @@ apply plugin: 'com.android.library'
20
20
 
21
21
  android {
22
22
  namespace "com.ahm.capacitor.camera.preview.capacitorcamerapreview"
23
- compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
23
+ compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 35
24
24
  defaultConfig {
25
- minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
26
- targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
25
+ minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 23
26
+ targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 35
27
27
  versionCode 1
28
28
  versionName "1.0"
29
29
  testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
@@ -1,6 +1,6 @@
1
1
  distributionBase=GRADLE_USER_HOME
2
2
  distributionPath=wrapper/dists
3
- distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-all.zip
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-all.zip
4
4
  networkTimeout=10000
5
5
  validateDistributionUrl=true
6
6
  zipStoreBase=GRADLE_USER_HOME
package/android/gradlew CHANGED
@@ -15,6 +15,8 @@
15
15
  # See the License for the specific language governing permissions and
16
16
  # limitations under the License.
17
17
  #
18
+ # SPDX-License-Identifier: Apache-2.0
19
+ #
18
20
 
19
21
  ##############################################################################
20
22
  #
@@ -55,7 +57,7 @@
55
57
  # Darwin, MinGW, and NonStop.
56
58
  #
57
59
  # (3) This script is generated from the Groovy template
58
- # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60
+ # https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59
61
  # within the Gradle project.
60
62
  #
61
63
  # You can find Gradle at https://github.com/gradle/gradle/.
@@ -83,7 +85,9 @@ done
83
85
  # This is normally unused
84
86
  # shellcheck disable=SC2034
85
87
  APP_BASE_NAME=${0##*/}
86
- APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
88
+ # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
89
+ APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
90
+ ' "$PWD" ) || exit
87
91
 
88
92
  # Use the maximum available, or set MAX_FD != -1 to use that value.
89
93
  MAX_FD=maximum
@@ -144,7 +148,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144
148
  case $MAX_FD in #(
145
149
  max*)
146
150
  # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
147
- # shellcheck disable=SC3045
151
+ # shellcheck disable=SC2039,SC3045
148
152
  MAX_FD=$( ulimit -H -n ) ||
149
153
  warn "Could not query maximum file descriptor limit"
150
154
  esac
@@ -152,7 +156,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
152
156
  '' | soft) :;; #(
153
157
  *)
154
158
  # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
155
- # shellcheck disable=SC3045
159
+ # shellcheck disable=SC2039,SC3045
156
160
  ulimit -n "$MAX_FD" ||
157
161
  warn "Could not set maximum file descriptor limit to $MAX_FD"
158
162
  esac
@@ -201,11 +205,11 @@ fi
201
205
  # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
202
206
  DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
203
207
 
204
- # Collect all arguments for the java command;
205
- # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
206
- # shell script including quotes and variable substitutions, so put them in
207
- # double quotes to make sure that they get re-expanded; and
208
- # * put everything else in single quotes, so that it's not re-expanded.
208
+ # Collect all arguments for the java command:
209
+ # * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
210
+ # and any embedded shellness will be escaped.
211
+ # * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
212
+ # treated as '${Hostname}' itself on the command line.
209
213
 
210
214
  set -- \
211
215
  "-Dorg.gradle.appname=$APP_BASE_NAME" \
@@ -13,6 +13,8 @@
13
13
  @rem See the License for the specific language governing permissions and
14
14
  @rem limitations under the License.
15
15
  @rem
16
+ @rem SPDX-License-Identifier: Apache-2.0
17
+ @rem
16
18
 
17
19
  @if "%DEBUG%"=="" @echo off
18
20
  @rem ##########################################################################
@@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
43
45
  %JAVA_EXE% -version >NUL 2>&1
44
46
  if %ERRORLEVEL% equ 0 goto execute
45
47
 
46
- echo.
47
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
48
- echo.
49
- echo Please set the JAVA_HOME variable in your environment to match the
50
- echo location of your Java installation.
48
+ echo. 1>&2
49
+ echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
50
+ echo. 1>&2
51
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
52
+ echo location of your Java installation. 1>&2
51
53
 
52
54
  goto fail
53
55
 
@@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
57
59
 
58
60
  if exist "%JAVA_EXE%" goto execute
59
61
 
60
- echo.
61
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
62
- echo.
63
- echo Please set the JAVA_HOME variable in your environment to match the
64
- echo location of your Java installation.
62
+ echo. 1>&2
63
+ echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
64
+ echo. 1>&2
65
+ echo Please set the JAVA_HOME variable in your environment to match the 1>&2
66
+ echo location of your Java installation. 1>&2
65
67
 
66
68
  goto fail
67
69
 
@@ -427,6 +427,42 @@ public class CameraActivity extends Fragment {
427
427
  return mCamera;
428
428
  }
429
429
 
430
+ /**
431
+ * Method to get the front camera id if the current camera is back and visa versa
432
+ *
433
+ * @return front or back camera id depending on the currently active camera
434
+ */
435
+ private int getNextCameraId() {
436
+ int nextCameraId = 0;
437
+
438
+ // Find the total number of cameras available
439
+ // NOTE: The getNumberOfCameras() method in Android's android.hardware.camera API returns the total
440
+ // number of cameras available on the device. The number might not be limited to just the front
441
+ // and back cameras because modern smartphones often come with more than two cameras.
442
+ // For example, devices might have:
443
+ // - a main (back) camera.
444
+ // - a wide-angle camera.
445
+ // - a telephoto camera.
446
+ // - a depth-sensing camera.
447
+ // - an ultrawide camera.
448
+ // - a macro camera.
449
+ // etc.
450
+ numberOfCameras = Camera.getNumberOfCameras();
451
+
452
+ int nextFacing = cameraCurrentlyLocked == Camera.CameraInfo.CAMERA_FACING_BACK ? Camera.CameraInfo.CAMERA_FACING_FRONT : Camera.CameraInfo.CAMERA_FACING_BACK;
453
+
454
+ // Find the next ID of the camera to switch to (front if the current is back and visa versa)
455
+ Camera.CameraInfo cameraInfo = new Camera.CameraInfo();
456
+ for (int i = 0; i < numberOfCameras; i++) {
457
+ Camera.getCameraInfo(i, cameraInfo);
458
+ if (cameraInfo.facing == nextFacing) {
459
+ nextCameraId = i;
460
+ break;
461
+ }
462
+ }
463
+ return nextCameraId;
464
+ }
465
+
430
466
  public void switchCamera() {
431
467
  // check for availability of multiple cameras
432
468
  if (numberOfCameras == 1) {
@@ -444,7 +480,7 @@ public class CameraActivity extends Fragment {
444
480
 
445
481
  Log.d(TAG, "cameraCurrentlyLocked := " + Integer.toString(cameraCurrentlyLocked));
446
482
  try {
447
- cameraCurrentlyLocked = (cameraCurrentlyLocked + 1) % numberOfCameras;
483
+ cameraCurrentlyLocked = getNextCameraId();
448
484
  Log.d(TAG, "cameraCurrentlyLocked new: " + cameraCurrentlyLocked);
449
485
  } catch (Exception exception) {
450
486
  Log.d(TAG, exception.getMessage());
@@ -70,7 +70,7 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
70
70
  @PluginMethod
71
71
  public void setOpacity(PluginCall call) {
72
72
  if (this.hasCamera(call) == false) {
73
- call.error("Camera is not running");
73
+ call.reject("Camera is not running");
74
74
  return;
75
75
  }
76
76
 
@@ -249,6 +249,14 @@ public class CameraPreview extends Plugin implements CameraActivity.CameraPrevie
249
249
  // call.resolve();
250
250
  }
251
251
 
252
+ @PluginMethod
253
+ public void isCameraStarted(PluginCall call) {
254
+ boolean isCameraStarted = hasCamera(call);
255
+ JSObject ret = new JSObject();
256
+ ret.put("value", isCameraStarted);
257
+ call.resolve(ret);
258
+ }
259
+
252
260
  @PermissionCallback
253
261
  private void handleCameraPermissionResult(PluginCall call) {
254
262
  if (PermissionState.GRANTED.equals(getPermissionState(CAMERA_PERMISSION_ALIAS))) {
@@ -55,10 +55,10 @@ export interface CameraOpacityOptions {
55
55
  opacity?: number;
56
56
  }
57
57
  export interface CameraPreviewPlugin {
58
- start(options: CameraPreviewOptions): Promise<{}>;
59
- startRecordVideo(options: CameraPreviewOptions): Promise<{}>;
60
- stop(): Promise<{}>;
61
- stopRecordVideo(): Promise<{}>;
58
+ start(options: CameraPreviewOptions): Promise<void>;
59
+ startRecordVideo(options: CameraPreviewOptions): Promise<void>;
60
+ stop(): Promise<void>;
61
+ stopRecordVideo(): Promise<void>;
62
62
  capture(options: CameraPreviewPictureOptions): Promise<{
63
63
  value: string;
64
64
  }>;
@@ -72,5 +72,8 @@ export interface CameraPreviewPlugin {
72
72
  flashMode: CameraPreviewFlashMode | string;
73
73
  }): Promise<void>;
74
74
  flip(): Promise<void>;
75
- setOpacity(options: CameraOpacityOptions): Promise<{}>;
75
+ setOpacity(options: CameraOpacityOptions): Promise<void>;
76
+ isCameraStarted(): Promise<{
77
+ value: boolean;
78
+ }>;
76
79
  }
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type CameraPosition = 'rear' | 'front';\nexport interface CameraPreviewOptions {\n /** Parent element to attach the video preview element to (applicable to the web platform only) */\n parent?: string;\n /** Class name to add to the video preview element (applicable to the web platform only) */\n className?: string;\n /** The preview width in pixels, default window.screen.width */\n width?: number;\n /** The preview height in pixels, default window.screen.height */\n height?: number;\n /** The x origin, default 0 (applicable to the android and ios platforms only) */\n x?: number;\n /** The y origin, default 0 (applicable to the android and ios platforms only) */\n y?: number;\n /** Brings your html in front of your preview, default false (applicable to the android only) */\n toBack?: boolean;\n /** The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) */\n paddingBottom?: number;\n /** Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) */\n rotateWhenOrientationChanged?: boolean;\n /** Choose the camera to use 'front' or 'rear', default 'front' */\n position?: CameraPosition | string;\n /** Defaults to false - Capture images to a file and return the file path instead of returning base64 encoded data */\n storeToFile?: boolean;\n /** Defaults to false - Android Only - Disable automatic rotation of the image, and let the browser deal with it (keep reading on how to achieve it) */\n disableExifHeaderStripping?: boolean;\n /** Defaults to false - iOS only - Activate high resolution image capture so that output images are from the highest resolution possible on the device **/\n enableHighResolution?: boolean;\n /** Defaults to false - Web only - Disables audio stream to prevent permission requests and output switching */\n disableAudio?: boolean;\n /** Android Only - Locks device orientation when camera is showing. */\n lockAndroidOrientation?: boolean;\n /** Defaults to false - Android and Web only. Set if camera preview can change opacity. */\n enableOpacity?: boolean;\n /** Defaults to false - Android only. Set if camera preview will support pinch to zoom. */\n enableZoom?: boolean;\n}\nexport interface CameraPreviewPictureOptions {\n /** The picture height, optional, default 0 (Device default) */\n height?: number;\n /** The picture width, optional, default 0 (Device default) */\n width?: number;\n /** The picture quality, 0 - 100, default 85 on `iOS/Android`.\n *\n * If left undefined, the `web` implementation will export a PNG, otherwise a JPEG will be generated */\n quality?: number;\n}\n\nexport interface CameraSampleOptions {\n /** The picture quality, 0 - 100, default 85 */\n quality?: number;\n}\n\nexport type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'red-eye' | 'torch';\n\nexport interface CameraOpacityOptions {\n /** The percent opacity to set for camera view, default 1 */\n opacity?: number;\n}\n\nexport interface CameraPreviewPlugin {\n start(options: CameraPreviewOptions): Promise<void>;\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n stop(): Promise<void>;\n stopRecordVideo(): Promise<void>;\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string }>;\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n setFlashMode(options: { flashMode: CameraPreviewFlashMode | string }): Promise<void>;\n flip(): Promise<void>;\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n isCameraStarted(): Promise<{ value: boolean }>;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,aAAa,GAAG,cAAc,CAAsB,eAAe,EAAE;IACzE,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;CACjE,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CameraPreviewPlugin } from './definitions';\n\nconst CameraPreview = registerPlugin<CameraPreviewPlugin>('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\n\nexport * from './definitions';\nexport { CameraPreview };\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -6,10 +6,9 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
6
6
  * used in capture
7
7
  */
8
8
  private isBackCamera;
9
- constructor();
10
- start(options: CameraPreviewOptions): Promise<{}>;
11
- startRecordVideo(): Promise<{}>;
12
- stopRecordVideo(): Promise<{}>;
9
+ start(options: CameraPreviewOptions): Promise<void>;
10
+ startRecordVideo(): Promise<void>;
11
+ stopRecordVideo(): Promise<void>;
13
12
  stop(): Promise<any>;
14
13
  capture(options: CameraPreviewPictureOptions): Promise<any>;
15
14
  captureSample(_options: CameraSampleOptions): Promise<any>;
@@ -21,4 +20,7 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
21
20
  }): Promise<void>;
22
21
  flip(): Promise<void>;
23
22
  setOpacity(_options: CameraOpacityOptions): Promise<any>;
23
+ isCameraStarted(): Promise<{
24
+ value: boolean;
25
+ }>;
24
26
  }
package/dist/esm/web.js CHANGED
@@ -1,13 +1,9 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  export class CameraPreviewWeb extends WebPlugin {
3
- constructor() {
4
- super({
5
- name: 'CameraPreview',
6
- platforms: ['web'],
7
- });
8
- }
9
3
  async start(options) {
4
+ // eslint-disable-next-line no-async-promise-executor
10
5
  return new Promise(async (resolve, reject) => {
6
+ var _a;
11
7
  await navigator.mediaDevices
12
8
  .getUserMedia({
13
9
  audio: !options.disableAudio,
@@ -41,7 +37,7 @@ export class CameraPreviewWeb extends WebPlugin {
41
37
  videoElement.setAttribute('playsinline', 'true');
42
38
  }
43
39
  parent.appendChild(videoElement);
44
- if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
40
+ if ((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
45
41
  const constraints = {
46
42
  video: {
47
43
  width: { ideal: options.width },
@@ -59,7 +55,7 @@ export class CameraPreviewWeb extends WebPlugin {
59
55
  //video.src = window.URL.createObjectURL(stream);
60
56
  videoElement.srcObject = stream;
61
57
  videoElement.play();
62
- resolve({});
58
+ resolve();
63
59
  }, (err) => {
64
60
  reject(err);
65
61
  });
@@ -82,15 +78,14 @@ export class CameraPreviewWeb extends WebPlugin {
82
78
  video.pause();
83
79
  const st = video.srcObject;
84
80
  const tracks = st.getTracks();
85
- for (let i = 0; i < tracks.length; i++) {
86
- const track = tracks[i];
81
+ for (const track of tracks) {
87
82
  track.stop();
88
83
  }
89
84
  video.remove();
90
85
  }
91
86
  }
92
87
  async capture(options) {
93
- return new Promise((resolve, _) => {
88
+ return new Promise((resolve) => {
94
89
  const video = document.getElementById('video');
95
90
  const canvas = document.createElement('canvas');
96
91
  // video.width = video.offsetWidth;
@@ -123,6 +118,7 @@ export class CameraPreviewWeb extends WebPlugin {
123
118
  async getSupportedFlashModes() {
124
119
  throw new Error('getSupportedFlashModes not supported under the web platform');
125
120
  }
121
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
126
122
  async setFlashMode(_options) {
127
123
  throw new Error('setFlashMode not supported under the web platform');
128
124
  }
@@ -135,5 +131,8 @@ export class CameraPreviewWeb extends WebPlugin {
135
131
  video.style.setProperty('opacity', _options['opacity'].toString());
136
132
  }
137
133
  }
134
+ async isCameraStarted() {
135
+ throw this.unimplemented('Not implemented on web.');
136
+ }
138
137
  }
139
138
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA6B;QACvC,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAC3C,MAAM,SAAS,CAAC,YAAY;iBACzB,YAAY,CAAC;gBACZ,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;gBAC5B,KAAK,EAAE,IAAI;aACZ,CAAC;iBACD,IAAI,CAAC,CAAC,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AAQ,EAAE,CAAC,CAAC;SACpE;IACH,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n CameraPreviewOptions,\n CameraPreviewPictureOptions,\n CameraPreviewPlugin,\n CameraPreviewFlashMode,\n CameraSampleOptions,\n CameraOpacityOptions,\n} from './definitions';\n\nexport class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {\n /**\n * track which camera is used based on start options\n * used in capture\n */\n private isBackCamera: boolean;\n\n async start(options: CameraPreviewOptions): Promise<void> {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream: MediaStream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n\n parent.appendChild(videoElement);\n\n if (navigator.mediaDevices?.getUserMedia) {\n const constraints: MediaStreamConstraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n\n if (options.position === 'rear') {\n (constraints.video as MediaTrackConstraints).facingMode = 'environment';\n this.isBackCamera = true;\n } else {\n this.isBackCamera = false;\n }\n\n navigator.mediaDevices.getUserMedia(constraints).then(\n function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve();\n },\n (err) => {\n reject(err);\n }\n );\n }\n } else {\n reject({ message: 'camera already started' });\n }\n });\n }\n\n async startRecordVideo(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async stopRecordVideo(): Promise<void> {\n throw this.unimplemented('Not implemented on web.');\n }\n\n async stop(): Promise<any> {\n const video = document.getElementById('video') as HTMLVideoElement;\n if (video) {\n video.pause();\n\n const st: any = video.srcObject;\n const tracks = st.getTracks();\n\n for (const track of tracks) {\n track.stop();\n }\n video.remove();\n }\n }\n\n async capture(options: CameraPreviewPictureOptions): Promise<any> {\n return new Promise((resolve) => {\n const video = document.getElementById('video') as HTMLVideoElement;\n const canvas = document.createElement('canvas');\n\n // video.width = video.offsetWidth;\n\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n\n let base64EncodedImage;\n\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n } else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n\n async captureSample(_options: CameraSampleOptions): Promise<any> {\n return this.capture(_options);\n }\n\n async getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }> {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async setFlashMode(_options: { flashMode: CameraPreviewFlashMode | string }): Promise<void> {\n throw new Error('setFlashMode not supported under the web platform');\n }\n\n async flip(): Promise<void> {\n throw new Error('flip not supported under the web platform');\n }\n\n async setOpacity(_options: CameraOpacityOptions): Promise<any> {\n const video = document.getElementById('video') as HTMLVideoElement;\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n\n async isCameraStarted(): Promise<{ value: boolean }> {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n"]}
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var core = require('@capacitor/core');
6
4
 
7
5
  const CameraPreview = core.registerPlugin('CameraPreview', {
@@ -9,14 +7,10 @@ const CameraPreview = core.registerPlugin('CameraPreview', {
9
7
  });
10
8
 
11
9
  class CameraPreviewWeb extends core.WebPlugin {
12
- constructor() {
13
- super({
14
- name: 'CameraPreview',
15
- platforms: ['web'],
16
- });
17
- }
18
10
  async start(options) {
11
+ // eslint-disable-next-line no-async-promise-executor
19
12
  return new Promise(async (resolve, reject) => {
13
+ var _a;
20
14
  await navigator.mediaDevices
21
15
  .getUserMedia({
22
16
  audio: !options.disableAudio,
@@ -50,7 +44,7 @@ class CameraPreviewWeb extends core.WebPlugin {
50
44
  videoElement.setAttribute('playsinline', 'true');
51
45
  }
52
46
  parent.appendChild(videoElement);
53
- if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
47
+ if ((_a = navigator.mediaDevices) === null || _a === undefined ? undefined : _a.getUserMedia) {
54
48
  const constraints = {
55
49
  video: {
56
50
  width: { ideal: options.width },
@@ -68,7 +62,7 @@ class CameraPreviewWeb extends core.WebPlugin {
68
62
  //video.src = window.URL.createObjectURL(stream);
69
63
  videoElement.srcObject = stream;
70
64
  videoElement.play();
71
- resolve({});
65
+ resolve();
72
66
  }, (err) => {
73
67
  reject(err);
74
68
  });
@@ -91,15 +85,14 @@ class CameraPreviewWeb extends core.WebPlugin {
91
85
  video.pause();
92
86
  const st = video.srcObject;
93
87
  const tracks = st.getTracks();
94
- for (let i = 0; i < tracks.length; i++) {
95
- const track = tracks[i];
88
+ for (const track of tracks) {
96
89
  track.stop();
97
90
  }
98
91
  video.remove();
99
92
  }
100
93
  }
101
94
  async capture(options) {
102
- return new Promise((resolve, _) => {
95
+ return new Promise((resolve) => {
103
96
  const video = document.getElementById('video');
104
97
  const canvas = document.createElement('canvas');
105
98
  // video.width = video.offsetWidth;
@@ -132,6 +125,7 @@ class CameraPreviewWeb extends core.WebPlugin {
132
125
  async getSupportedFlashModes() {
133
126
  throw new Error('getSupportedFlashModes not supported under the web platform');
134
127
  }
128
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
135
129
  async setFlashMode(_options) {
136
130
  throw new Error('setFlashMode not supported under the web platform');
137
131
  }
@@ -144,6 +138,9 @@ class CameraPreviewWeb extends core.WebPlugin {
144
138
  video.style.setProperty('opacity', _options['opacity'].toString());
145
139
  }
146
140
  }
141
+ async isCameraStarted() {
142
+ throw this.unimplemented('Not implemented on web.');
143
+ }
147
144
  }
148
145
 
149
146
  var web = /*#__PURE__*/Object.freeze({
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n return new Promise(async (resolve, reject) => {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve({});\n }, (err) => {\n reject(err);\n });\n }\n }\n else {\n reject({ message: 'camera already started' });\n }\n });\n }\n async startRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stopRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,WAAW,GAAG;AAClB,QAAQ,KAAK,CAAC;AACd,YAAY,IAAI,EAAE,eAAe;AACjC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;AAC9B,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,OAAO,EAAE,MAAM,KAAK;AACtD,YAAY,MAAM,SAAS,CAAC,YAAY;AACxC,iBAAiB,YAAY,CAAC;AAC9B,gBAAgB,KAAK,EAAE,CAAC,OAAO,CAAC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;AACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;AAC7E,KAAK;AACL,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;AACrE,KAAK;AACL,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;AACvD,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9C,YAAY,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/E,SAAS;AACT,KAAK;AACL;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n async start(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve();\n }, (err) => {\n reject(err);\n });\n }\n }\n else {\n reject({ message: 'camera already started' });\n }\n });\n }\n async startRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stopRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async isCameraStarted() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;AACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;AACpE,CAAC;;ACFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;AAChD,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;AACzB;AACA,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,OAAO,EAAE,MAAM,KAAK;AACtD,YAAY,IAAI,EAAE;AAClB,YAAY,MAAM,SAAS,CAAC;AAC5B,iBAAiB,YAAY,CAAC;AAC9B,gBAAgB,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;AAC5C,gBAAgB,KAAK,EAAE,IAAI;AAC3B,aAAa;AACb,iBAAiB,IAAI,CAAC,CAAC,MAAM,KAAK;AAClC;AACA,gBAAgB,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC;AACnE,aAAa;AACb,iBAAiB,KAAK,CAAC,CAAC,KAAK,KAAK;AAClC,gBAAgB,MAAM,CAAC,KAAK,CAAC;A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CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC;AACxG;AACA,YAAY,OAAO,CAAC;AACpB,gBAAgB,KAAK,EAAE,kBAAkB;AACzC,aAAa,CAAC;AACd,SAAS,CAAC;AACV;AACA,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;AAClC,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC;AACrC;AACA,IAAI,MAAM,sBAAsB,GAAG;AACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC;AACtF;AACA;AACA,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;AACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC;AAC5E;AACA,IAAI,MAAM,IAAI,GAAG;AACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;AACpE;AACA,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;AACtD,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;AAC9C,YAAY,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;AAC9E;AACA;AACA,IAAI,MAAM,eAAe,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;AAC3D;AACA;;;;;;;;;"}
package/dist/plugin.js CHANGED
@@ -1,4 +1,4 @@
1
- var capacitorSplashScreen = (function (exports, core) {
1
+ var capacitorCameraPreview = (function (exports, core) {
2
2
  'use strict';
3
3
 
4
4
  const CameraPreview = core.registerPlugin('CameraPreview', {
@@ -6,14 +6,10 @@ var capacitorSplashScreen = (function (exports, core) {
6
6
  });
7
7
 
8
8
  class CameraPreviewWeb extends core.WebPlugin {
9
- constructor() {
10
- super({
11
- name: 'CameraPreview',
12
- platforms: ['web'],
13
- });
14
- }
15
9
  async start(options) {
10
+ // eslint-disable-next-line no-async-promise-executor
16
11
  return new Promise(async (resolve, reject) => {
12
+ var _a;
17
13
  await navigator.mediaDevices
18
14
  .getUserMedia({
19
15
  audio: !options.disableAudio,
@@ -47,7 +43,7 @@ var capacitorSplashScreen = (function (exports, core) {
47
43
  videoElement.setAttribute('playsinline', 'true');
48
44
  }
49
45
  parent.appendChild(videoElement);
50
- if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
46
+ if ((_a = navigator.mediaDevices) === null || _a === undefined ? undefined : _a.getUserMedia) {
51
47
  const constraints = {
52
48
  video: {
53
49
  width: { ideal: options.width },
@@ -65,7 +61,7 @@ var capacitorSplashScreen = (function (exports, core) {
65
61
  //video.src = window.URL.createObjectURL(stream);
66
62
  videoElement.srcObject = stream;
67
63
  videoElement.play();
68
- resolve({});
64
+ resolve();
69
65
  }, (err) => {
70
66
  reject(err);
71
67
  });
@@ -88,15 +84,14 @@ var capacitorSplashScreen = (function (exports, core) {
88
84
  video.pause();
89
85
  const st = video.srcObject;
90
86
  const tracks = st.getTracks();
91
- for (let i = 0; i < tracks.length; i++) {
92
- const track = tracks[i];
87
+ for (const track of tracks) {
93
88
  track.stop();
94
89
  }
95
90
  video.remove();
96
91
  }
97
92
  }
98
93
  async capture(options) {
99
- return new Promise((resolve, _) => {
94
+ return new Promise((resolve) => {
100
95
  const video = document.getElementById('video');
101
96
  const canvas = document.createElement('canvas');
102
97
  // video.width = video.offsetWidth;
@@ -129,6 +124,7 @@ var capacitorSplashScreen = (function (exports, core) {
129
124
  async getSupportedFlashModes() {
130
125
  throw new Error('getSupportedFlashModes not supported under the web platform');
131
126
  }
127
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
132
128
  async setFlashMode(_options) {
133
129
  throw new Error('setFlashMode not supported under the web platform');
134
130
  }
@@ -141,6 +137,9 @@ var capacitorSplashScreen = (function (exports, core) {
141
137
  video.style.setProperty('opacity', _options['opacity'].toString());
142
138
  }
143
139
  }
140
+ async isCameraStarted() {
141
+ throw this.unimplemented('Not implemented on web.');
142
+ }
144
143
  }
145
144
 
146
145
  var web = /*#__PURE__*/Object.freeze({
@@ -150,8 +149,6 @@ var capacitorSplashScreen = (function (exports, core) {
150
149
 
151
150
  exports.CameraPreview = CameraPreview;
152
151
 
153
- Object.defineProperty(exports, '__esModule', { value: true });
154
-
155
152
  return exports;
156
153
 
157
154
  })({}, capacitorExports);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n return new Promise(async (resolve, reject) => {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve({});\n }, (err) => {\n reject(err);\n });\n }\n }\n else {\n reject({ message: 'camera already started' });\n }\n });\n }\n async startRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stopRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, _) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC;IACd,YAAY,IAAI,EAAE,eAAe;IACjC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,OAAO,IAAI,OAAO,CAAC,OAAO,OAAO,EAAE,MAAM,KAAK;IACtD,YAAY,MAAM,SAAS,CAAC,YAAY;IACxC,iBAAiB,YAAY,CAAC;IAC9B,gBAAgB,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;IAC5C,gBAAgB,KAAK,EAAE,IAAI;IAC3B,aAAa,CAAC;IACd,iBAAiB,IAAI,CAAC,CAAC,MAAM,KAAK;IAClC;IACA,gBAAgB,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IACpE,aAAa,CAAC;IACd,iBAAiB,KAAK,CAAC,CAAC,KAAK,KAAK;IAClC,gBAAgB,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,aAAa,CAAC,CAAC;IACf,YAAY,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IAC3D,YA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AAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,SAAS;IACT,KAAK;IACL;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n async start(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve();\n }, (err) => {\n reject(err);\n });\n }\n }\n else {\n reject({ message: 'camera already started' });\n }\n });\n }\n async startRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stopRecordVideo() {\n throw this.unimplemented('Not implemented on web.');\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n const st = video.srcObject;\n const tracks = st.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve) => {\n const video = document.getElementById('video');\n const canvas = document.createElement('canvas');\n // video.width = video.offsetWidth;\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n let base64EncodedImage;\n if (options.quality != undefined) {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', options.quality / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform');\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n async isCameraStarted() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\n//# source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AAmD,CAAC;IAC5E;IACA,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC;IACpE;IACA,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC;IACtD,QAAQ,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;IAC9C,YAAY,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9E;IACA;IACA,IAAI,MAAM,eAAe,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC;IAC3D;IACA;;;;;;;;;;;;;;;"}
@@ -13,4 +13,5 @@ CAP_PLUGIN(CameraPreview, "CameraPreview",
13
13
  CAP_PLUGIN_METHOD(setFlashMode, CAPPluginReturnPromise);
14
14
  CAP_PLUGIN_METHOD(startRecordVideo, CAPPluginReturnPromise);
15
15
  CAP_PLUGIN_METHOD(stopRecordVideo, CAPPluginReturnPromise);
16
+ CAP_PLUGIN_METHOD(isCameraStarted, CAPPluginReturnPromise);
16
17
  )
@@ -287,5 +287,15 @@ public class CameraPreview: CAPPlugin {
287
287
 
288
288
  }
289
289
  }
290
+
291
+ @objc func isCameraStarted(_ call: CAPPluginCall) {
292
+ DispatchQueue.main.async {
293
+ if self.cameraController.captureSession?.isRunning ?? false {
294
+ call.resolve(["value": true])
295
+ } else {
296
+ call.resolve(["value": false])
297
+ }
298
+ }
299
+ }
290
300
 
291
301
  }
@@ -414,7 +414,7 @@
414
414
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
415
415
  GCC_WARN_UNUSED_FUNCTION = YES;
416
416
  GCC_WARN_UNUSED_VARIABLE = YES;
417
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
417
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
418
418
  MTL_ENABLE_DEBUG_INFO = YES;
419
419
  ONLY_ACTIVE_ARCH = YES;
420
420
  SDKROOT = iphoneos;
@@ -469,7 +469,7 @@
469
469
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
470
470
  GCC_WARN_UNUSED_FUNCTION = YES;
471
471
  GCC_WARN_UNUSED_VARIABLE = YES;
472
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
472
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
473
473
  MTL_ENABLE_DEBUG_INFO = NO;
474
474
  SDKROOT = iphoneos;
475
475
  SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
@@ -493,7 +493,7 @@
493
493
  DYLIB_INSTALL_NAME_BASE = "@rpath";
494
494
  INFOPLIST_FILE = Plugin/Info.plist;
495
495
  INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
496
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
496
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
497
497
  LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)\n$(FRAMEWORK_SEARCH_PATHS)";
498
498
  ONLY_ACTIVE_ARCH = YES;
499
499
  PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
@@ -519,7 +519,7 @@
519
519
  DYLIB_INSTALL_NAME_BASE = "@rpath";
520
520
  INFOPLIST_FILE = Plugin/Info.plist;
521
521
  INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
522
- IPHONEOS_DEPLOYMENT_TARGET = 13.0;
522
+ IPHONEOS_DEPLOYMENT_TARGET = 14.0;
523
523
  LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks $(FRAMEWORK_SEARCH_PATHS)";
524
524
  ONLY_ACTIVE_ARCH = NO;
525
525
  PRODUCT_BUNDLE_IDENTIFIER = com.getcapacitor.Plugin;
package/ios/Podfile CHANGED
@@ -1,4 +1,4 @@
1
- platform :ios, '13.0'
1
+ platform :ios, '14.0'
2
2
 
3
3
  def capacitor_pods
4
4
  # Comment the next line if you're not using Swift and don't want to use dynamic frameworks
package/ios/Podfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PODS:
2
- - Capacitor (5.0.3):
2
+ - Capacitor (6.2.0):
3
3
  - CapacitorCordova
4
- - CapacitorCordova (5.0.3)
4
+ - CapacitorCordova (6.2.0)
5
5
 
6
6
  DEPENDENCIES:
7
7
  - "Capacitor (from `../node_modules/@capacitor/ios`)"
@@ -14,9 +14,9 @@ EXTERNAL SOURCES:
14
14
  :path: "../node_modules/@capacitor/ios"
15
15
 
16
16
  SPEC CHECKSUMS:
17
- Capacitor: 304a960e431f9e6f78556554ca71c41c1b2b9680
18
- CapacitorCordova: def732a63679698df6fb392bbe6d269a0b61e937
17
+ Capacitor: 1f3c7b9802d958cd8c4eb63895fff85dff2e1eea
18
+ CapacitorCordova: b33e7f4aa4ed105dd43283acdd940964374a87d9
19
19
 
20
20
  PODFILE CHECKSUM: 14e8b2400457751b865e1c327e7cfa1c6fa67da6
21
21
 
22
- COCOAPODS: 1.11.3
22
+ COCOAPODS: 1.15.2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor-community/camera-preview",
3
- "version": "6.0.0",
3
+ "version": "7.0.0",
4
4
  "description": "Camera preview",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -11,13 +11,13 @@
11
11
  "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
12
12
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
13
13
  "verify:web": "npm run build",
14
- "build": "npm run clean && tsc && rollup -c rollup.config.js",
14
+ "build": "npm run clean && tsc && rollup -c rollup.config.mjs",
15
15
  "clean": "rimraf './dist'",
16
16
  "watch": "tsc --watch",
17
- "lint": "concurrently -g \"npm:eslint\" \"npm:prettier -- --check\" \"npm run swiftlint -- lint ios\"",
17
+ "lint": "concurrently -g \"npm:eslint\" \"npm:prettier -- --check --plugin=prettier-plugin-java\" \"npm run swiftlint -- lint ios\"",
18
18
  "fmt": "concurrently -g \"npm:eslint -- --fix\" \"npm:prettier -- --write\" \"npm:swiftlint -- lint --fix --format ios\"",
19
19
  "eslint": "eslint . --ext ts",
20
- "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
20
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
21
21
  "swiftlint": "node-swiftlint",
22
22
  "prepublishOnly": "npm run build",
23
23
  "prepare": "husky install && npm run build"
@@ -25,25 +25,25 @@
25
25
  "author": "Ariel Hernandez Musa",
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
- "@capacitor/android": "^6.0.0",
29
- "@capacitor/core": "^6.0.0",
30
- "@capacitor/ios": "^6.0.0",
31
- "@ionic/eslint-config": "^0.3.0",
32
- "@ionic/prettier-config": "^2.0.0",
33
- "@ionic/swiftlint-config": "^1.1.2",
34
- "concurrently": "^7.0.0",
35
- "eslint": "^7.32.0",
36
- "husky": "^7.0.4",
37
- "prettier": "^2.5.1",
38
- "prettier-plugin-java": "^1.6.1",
39
- "pretty-quick": "^3.1.3",
40
- "rimraf": "^3.0.2",
41
- "rollup": "^2.79.1",
42
- "swiftlint": "^1.0.1",
28
+ "@capacitor/android": "^7.0.0",
29
+ "@capacitor/core": "^7.0.0",
30
+ "@capacitor/ios": "^7.0.0",
31
+ "@ionic/eslint-config": "^0.4.0",
32
+ "@ionic/prettier-config": "^4.0.0",
33
+ "@ionic/swiftlint-config": "^2.0.0",
34
+ "concurrently": "^9.1.0",
35
+ "eslint": "^8.57.0",
36
+ "husky": "^9.1.7",
37
+ "prettier": "^3.4.2",
38
+ "prettier-plugin-java": "^2.6.6",
39
+ "pretty-quick": "^4.0.0",
40
+ "rimraf": "^6.0.1",
41
+ "rollup": "^4.30.1",
42
+ "swiftlint": "^2.0.0",
43
43
  "typescript": "^4.3.2"
44
44
  },
45
45
  "peerDependencies": {
46
- "@capacitor/core": "^6.0.0"
46
+ "@capacitor/core": ">=7.0.0"
47
47
  },
48
48
  "husky": {
49
49
  "hooks": {
@@ -80,5 +80,9 @@
80
80
  },
81
81
  "bugs": {
82
82
  "url": "https://github.com/capacitor-community/camera-preview/issues"
83
+ },
84
+ "engines": {
85
+ "node": ">=18.0.0",
86
+ "npm": ">=9.0.0"
83
87
  }
84
88
  }