@capgo/camera-preview 7.1.0 → 7.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/android/build.gradle +1 -1
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradlew +2 -3
- package/dist/docs.json +7 -0
- package/dist/esm/definitions.d.ts +2 -0
- package/dist/esm/definitions.js.map +1 -1
- package/ios/Plugin/Plugin.swift +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
<br>
|
|
14
14
|
|
|
15
|
-
This plugin is compatible Capacitor
|
|
15
|
+
This plugin is compatible Capacitor 7 and above.
|
|
16
16
|
|
|
17
|
-
Use
|
|
17
|
+
Use v6 for Capacitor 6 and below.
|
|
18
18
|
|
|
19
19
|
**PR's are greatly appreciated.**
|
|
20
20
|
|
|
@@ -69,6 +69,13 @@ If it don't work in dark mode here is issue who explain how to fix it: https://g
|
|
|
69
69
|
<li>Tap to focus</li>
|
|
70
70
|
</ul> -->
|
|
71
71
|
|
|
72
|
+
## Good to know
|
|
73
|
+
|
|
74
|
+
Video and photo taken with the plugin are never removed, so do not forget to remove them after used to not bloat the user phone.
|
|
75
|
+
|
|
76
|
+
use https://capacitorjs.com/docs/apis/filesystem#deletefile for that
|
|
77
|
+
|
|
78
|
+
|
|
72
79
|
# Installation
|
|
73
80
|
|
|
74
81
|
```
|
|
@@ -385,6 +392,7 @@ Start recording video.
|
|
|
385
392
|
| **`height`** | <code>number</code> | The preview height in pixels, default window.screen.height |
|
|
386
393
|
| **`x`** | <code>number</code> | The x origin, default 0 (applicable to the android and ios platforms only) |
|
|
387
394
|
| **`y`** | <code>number</code> | The y origin, default 0 (applicable to the android and ios platforms only) |
|
|
395
|
+
| **`includeSafeAreaInsets`** | <code>boolean</code> | Whether to include safe area insets in y-position calculation, default false (applicable to the ios platform only) |
|
|
388
396
|
| **`toBack`** | <code>boolean</code> | Brings your html in front of your preview, default false (applicable to the android only) |
|
|
389
397
|
| **`paddingBottom`** | <code>number</code> | The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) |
|
|
390
398
|
| **`rotateWhenOrientationChanged`** | <code>boolean</code> | Rotate preview when orientation changes (applicable to the ios platforms only; default value is true) |
|
package/android/build.gradle
CHANGED
|
@@ -48,7 +48,7 @@ dependencies {
|
|
|
48
48
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
49
49
|
implementation project(':capacitor-android')
|
|
50
50
|
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
51
|
-
implementation 'androidx.exifinterface:exifinterface:1.
|
|
51
|
+
implementation 'androidx.exifinterface:exifinterface:1.4.0'
|
|
52
52
|
testImplementation "junit:junit:$junitVersion"
|
|
53
53
|
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
54
54
|
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
distributionBase=GRADLE_USER_HOME
|
|
2
2
|
distributionPath=wrapper/dists
|
|
3
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.
|
|
3
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-all.zip
|
|
4
4
|
networkTimeout=10000
|
|
5
5
|
validateDistributionUrl=true
|
|
6
6
|
zipStoreBase=GRADLE_USER_HOME
|
package/android/gradlew
CHANGED
|
@@ -86,8 +86,7 @@ done
|
|
|
86
86
|
# shellcheck disable=SC2034
|
|
87
87
|
APP_BASE_NAME=${0##*/}
|
|
88
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
|
|
89
|
+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
|
91
90
|
|
|
92
91
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
93
92
|
MAX_FD=maximum
|
|
@@ -206,7 +205,7 @@ fi
|
|
|
206
205
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
207
206
|
|
|
208
207
|
# Collect all arguments for the java command:
|
|
209
|
-
# * DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
208
|
+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
210
209
|
# and any embedded shellness will be escaped.
|
|
211
210
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
212
211
|
# treated as '${Hostname}' itself on the command line.
|
package/dist/docs.json
CHANGED
|
@@ -408,6 +408,13 @@
|
|
|
408
408
|
"complexTypes": [],
|
|
409
409
|
"type": "number | undefined"
|
|
410
410
|
},
|
|
411
|
+
{
|
|
412
|
+
"name": "includeSafeAreaInsets",
|
|
413
|
+
"tags": [],
|
|
414
|
+
"docs": "Whether to include safe area insets in y-position calculation, default false (applicable to the ios platform only)",
|
|
415
|
+
"complexTypes": [],
|
|
416
|
+
"type": "boolean | undefined"
|
|
417
|
+
},
|
|
411
418
|
{
|
|
412
419
|
"name": "toBack",
|
|
413
420
|
"tags": [],
|
|
@@ -12,6 +12,8 @@ export interface CameraPreviewOptions {
|
|
|
12
12
|
x?: number;
|
|
13
13
|
/** The y origin, default 0 (applicable to the android and ios platforms only) */
|
|
14
14
|
y?: number;
|
|
15
|
+
/** Whether to include safe area insets in y-position calculation, default false (applicable to the ios platform only) */
|
|
16
|
+
includeSafeAreaInsets?: boolean;
|
|
15
17
|
/** Brings your html in front of your preview, default false (applicable to the android only) */
|
|
16
18
|
toBack?: boolean;
|
|
17
19
|
/** The preview bottom padding in pixes. Useful to keep the appropriate preview sizes when orientation changes (applicable to the android and ios platforms only) */
|
|
@@ -1 +1 @@
|
|
|
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 - 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 /** default to false - IOS only. Set the CameraPreview to use the video mode preset */\n cameraMode?: boolean;\n}\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 */\n quality?: number;\n /** The picture format, jpeg or png, default jpeg on `Web`.\n *\n * quality has no effect on png */\n format?: PictureFormat;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\nexport interface CameraSampleOptions {\n /** The picture quality, 0 - 100, default 85 */\n quality?: number;\n}\n\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"red-eye\"\n | \"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 /**\n * Start the camera preview instance.\n * @param {CameraPreviewOptions} options the options to start the camera preview with\n * @returns {Promise<void>} an Promise that resolves when the instance is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<void>;\n /**\n * Stop the camera preview instance.\n * @returns {Promise<void>} an Promise that resolves when the instance is stopped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stop(): Promise<void>;\n /**\n * Switch camera.\n * @param {CameraPreviewOptions} options the options to switch the camera with\n * @returns {Promise<void>} an Promise that resolves when the camera is switched\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string }>;\n /**\n * Capture a sample image.\n * @param {CameraSampleOptions} options the options to capture the sample image with\n * @returns {Promise<string>} an Promise that resolves with the sample image as a base64 encoded string\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n /**\n * Get supported flash modes.\n * @returns {Promise<CameraPreviewFlashMode[]>} an Promise that resolves with the supported flash modes\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n /**\n * Get horizontal field of view.\n * @returns {Promise<any>} an Promise that resolves with the horizontal field of view\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: any;\n }>;\n /**\n * Gets the supported picture sizes for a given device.\n * @returns {Promise<any>} an Promise that resolves with the supported picture sizes for a given device\n * @throws An error if the something goes wrong\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: {\n facing: string;\n supportedPictureSizes: { width: number; height: number }[];\n }[];\n }>;\n /**\n * Set flash mode.\n * @param options the options to set the flash mode with\n * @returns {Promise<void>} an Promise that resolves when the flash mode is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n /**\n * Flip camera.\n * @returns {Promise<void>} an Promise that resolves when the camera is flipped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n flip(): Promise<void>;\n /**\n * Set opacity.\n * @param {CameraOpacityOptions} options the options to set the camera opacity with\n * @returns {Promise<void>} an Promise that resolves when the camera color effect is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n /**\n * Stop recording video.\n * @param {CameraPreviewOptions} options the options to stop recording video with\n * @returns {Promise<{videoFilePath: string}>} an Promise that resolves when the camera zoom is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n /**\n * Start recording video.\n * @param {CameraPreviewOptions} options the options to start recording video with\n * @returns {Promise<void>} an Promise that resolves when the video recording is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n}\n"]}
|
|
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 /** Whether to include safe area insets in y-position calculation, default false (applicable to the ios platform only) */\n includeSafeAreaInsets?: boolean;\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 - 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 /** default to false - IOS only. Set the CameraPreview to use the video mode preset */\n cameraMode?: boolean;\n}\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 */\n quality?: number;\n /** The picture format, jpeg or png, default jpeg on `Web`.\n *\n * quality has no effect on png */\n format?: PictureFormat;\n}\n\nexport type PictureFormat = \"jpeg\" | \"png\";\n\nexport interface CameraSampleOptions {\n /** The picture quality, 0 - 100, default 85 */\n quality?: number;\n}\n\nexport type CameraPreviewFlashMode =\n | \"off\"\n | \"on\"\n | \"auto\"\n | \"red-eye\"\n | \"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 /**\n * Start the camera preview instance.\n * @param {CameraPreviewOptions} options the options to start the camera preview with\n * @returns {Promise<void>} an Promise that resolves when the instance is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n start(options: CameraPreviewOptions): Promise<void>;\n /**\n * Stop the camera preview instance.\n * @returns {Promise<void>} an Promise that resolves when the instance is stopped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stop(): Promise<void>;\n /**\n * Switch camera.\n * @param {CameraPreviewOptions} options the options to switch the camera with\n * @returns {Promise<void>} an Promise that resolves when the camera is switched\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n capture(options: CameraPreviewPictureOptions): Promise<{ value: string }>;\n /**\n * Capture a sample image.\n * @param {CameraSampleOptions} options the options to capture the sample image with\n * @returns {Promise<string>} an Promise that resolves with the sample image as a base64 encoded string\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n captureSample(options: CameraSampleOptions): Promise<{ value: string }>;\n /**\n * Get supported flash modes.\n * @returns {Promise<CameraPreviewFlashMode[]>} an Promise that resolves with the supported flash modes\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }>;\n /**\n * Get horizontal field of view.\n * @returns {Promise<any>} an Promise that resolves with the horizontal field of view\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n getHorizontalFov(): Promise<{\n result: any;\n }>;\n /**\n * Gets the supported picture sizes for a given device.\n * @returns {Promise<any>} an Promise that resolves with the supported picture sizes for a given device\n * @throws An error if the something goes wrong\n */\n getSupportedPictureSizes(): Promise<{\n supportedPictureSizes: {\n facing: string;\n supportedPictureSizes: { width: number; height: number }[];\n }[];\n }>;\n /**\n * Set flash mode.\n * @param options the options to set the flash mode with\n * @returns {Promise<void>} an Promise that resolves when the flash mode is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setFlashMode(options: {\n flashMode: CameraPreviewFlashMode | string;\n }): Promise<void>;\n /**\n * Flip camera.\n * @returns {Promise<void>} an Promise that resolves when the camera is flipped\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n flip(): Promise<void>;\n /**\n * Set opacity.\n * @param {CameraOpacityOptions} options the options to set the camera opacity with\n * @returns {Promise<void>} an Promise that resolves when the camera color effect is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n setOpacity(options: CameraOpacityOptions): Promise<void>;\n /**\n * Stop recording video.\n * @param {CameraPreviewOptions} options the options to stop recording video with\n * @returns {Promise<{videoFilePath: string}>} an Promise that resolves when the camera zoom is set\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n stopRecordVideo(): Promise<{ videoFilePath: string }>;\n /**\n * Start recording video.\n * @param {CameraPreviewOptions} options the options to start recording video with\n * @returns {Promise<void>} an Promise that resolves when the video recording is started\n * @throws An error if the something went wrong\n * @since 0.0.1\n */\n startRecordVideo(options: CameraPreviewOptions): Promise<void>;\n}\n"]}
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -206,7 +206,7 @@ public class CameraPreview: CAPPlugin, CAPBridgedPlugin {
|
|
|
206
206
|
self.height = UIScreen.main.bounds.size.height
|
|
207
207
|
}
|
|
208
208
|
self.posX = call.getInt("x") != nil ? CGFloat(call.getInt("x")!)/UIScreen.main.scale: 0
|
|
209
|
-
self.posY = call.getInt("y") != nil ? CGFloat(call.getInt("y")!)/UIScreen.main.scale: 0
|
|
209
|
+
self.posY = call.getInt("y") != nil ? CGFloat(call.getInt("y")!) / (call.getBool("includeSafeAreaInsets") ?? false ? 1.0 : UIScreen.main.scale) + (call.getBool("includeSafeAreaInsets") ?? false ? UIApplication.shared.windows.first?.safeAreaInsets.top ?? 0 : 0) : 0
|
|
210
210
|
if call.getInt("paddingBottom") != nil {
|
|
211
211
|
self.paddingBottom = CGFloat(call.getInt("paddingBottom")!)
|
|
212
212
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/camera-preview",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.2.2",
|
|
4
4
|
"description": "Camera preview",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/Cap-go/camera-preview
|
|
8
|
+
"url": "https://github.com/Cap-go/capacitor-camera-preview"
|
|
9
9
|
},
|
|
10
10
|
"bugs": {
|
|
11
11
|
"url": "https://github.com/Cap-go/camera-preview/issues"
|