@capgo/camera-preview 3.6.23 → 5.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.
- package/README.md +67 -405
- package/android/build.gradle +8 -7
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/gradle.properties +1 -1
- package/android/gradlew +2 -2
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +6 -6
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +1105 -854
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +543 -428
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +15 -10
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +31 -21
- package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +386 -332
- package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +13 -13
- package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +4 -4
- package/dist/docs.json +208 -37
- package/dist/esm/definitions.d.ts +76 -3
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/index.js +4 -4
- package/dist/esm/web.d.ts +2 -2
- package/dist/esm/web.js +39 -36
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +39 -36
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +39 -36
- package/dist/plugin.js.map +1 -1
- package/ios/Plugin/CameraController.swift +1 -1
- package/ios/Plugin/Plugin.swift +1 -1
- package/ios/Podfile.lock +3 -3
- package/package.json +22 -22
- package/android/.gradle/7.6/checksums/checksums.lock +0 -0
- package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
- package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/7.6/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/dist/plugin.js.map
CHANGED
|
@@ -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 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 Promise.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 === null || navigator === void 0 ? void 0 : 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 const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById('video')) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: 'camera already stopped' });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: 'camera already started' });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject({ message: 'camera is not running' });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\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 if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error('stopRecordVideo not supported under the web platform');\n }\n async startRecordVideo(_options) {\n throw new Error('startRecordVideo not supported under the web platform');\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform' + _options);\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,IAAI,EAAE,CAAC;IACf,QAAQ,MAAM,SAAS,CAAC,YAAY;IACpC,aAAa,YAAY,CAAC;IAC1B,YAAY,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;IACxC,YAAY,KAAK,EAAE,IAAI;IACvB,SAAS,CAAC;IACV,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK;IAC9B;IACA,YAAY,MAAM,CAAC,SAAS,EA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AC,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 constructor() {\n super({\n name: \"CameraPreview\",\n platforms: [\"web\"],\n });\n }\n async start(options) {\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 Promise.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 === null || navigator === void 0 ? void 0 : 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 =\n \"environment\";\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById(\"video\")) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: \"camera already stopped\" });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: \"camera already started\" });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById(\"video\");\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById(\"video\");\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject({ message: \"camera is not running\" });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement(\"canvas\");\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 if ((options.format || \"jpeg\") === \"jpeg\") {\n base64EncodedImage = canvas\n .toDataURL(\"image/jpeg\", (options.quality || 85) / 100.0)\n .replace(\"data:image/jpeg;base64,\", \"\");\n }\n else {\n base64EncodedImage = canvas\n .toDataURL(\"image/png\")\n .replace(\"data:image/png;base64,\", \"\");\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error(\"stopRecordVideo not supported under the web platform\");\n }\n async startRecordVideo(_options) {\n throw new Error(\"startRecordVideo not supported under the web platform\");\n }\n async getSupportedFlashModes() {\n throw new Error(\"getSupportedFlashModes not supported under the web platform\");\n }\n async getHorizontalFov() {\n throw new Error(\"getHorizontalFov not supported under the web platform\");\n }\n async setFlashMode(_options) {\n throw new Error(\"setFlashMode not supported under the web platform\" + _options);\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,IAAI,EAAE,CAAC;IACf,QAAQ,MAAM,SAAS,CAAC,YAAY;IACpC,aAAa,YAAY,CAAC;IAC1B,YAAY,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;IACxC,YAAY,KAAK,EAAE,IAAI;IACvB,SAAS,CAAC;IACV,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK;IAC9B;IACA,YAAY,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,SA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AS;IACT,KAAK;IACL;;;;;;;;;;;;;;;"}
|
package/ios/Plugin/Plugin.swift
CHANGED
package/ios/Podfile.lock
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
PODS:
|
|
2
|
-
- Capacitor (
|
|
2
|
+
- Capacitor (5.0.3):
|
|
3
3
|
- CapacitorCordova
|
|
4
4
|
- CapacitorCordova (2.0.1)
|
|
5
5
|
|
|
@@ -15,9 +15,9 @@ EXTERNAL SOURCES:
|
|
|
15
15
|
:path: "../node_modules/@capacitor/ios"
|
|
16
16
|
|
|
17
17
|
SPEC CHECKSUMS:
|
|
18
|
-
Capacitor:
|
|
18
|
+
Capacitor: 304a960e431f9e6f78556554ca71c41c1b2b9680
|
|
19
19
|
CapacitorCordova: 9fee2eb6780331b6ff09710d6a7d1f2e4707f1b9
|
|
20
20
|
|
|
21
21
|
PODFILE CHECKSUM: e80ffb7ef3a0ac7d0d6143f3e64f287d4d027c84
|
|
22
22
|
|
|
23
|
-
COCOAPODS: 1.
|
|
23
|
+
COCOAPODS: 1.12.1
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capgo/camera-preview",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Camera preview",
|
|
5
5
|
"main": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -12,40 +12,40 @@
|
|
|
12
12
|
"lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
|
|
13
13
|
"fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --autocorrect --format",
|
|
14
14
|
"eslint": "eslint . --ext ts",
|
|
15
|
-
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
|
|
15
|
+
"prettier": "prettier --config .prettierrc.js \"**/*.{css,html,ts,js,java}\"",
|
|
16
16
|
"swiftlint": "node-swiftlint",
|
|
17
|
-
"docgen": "docgen --api CameraPreviewPlugin --output-readme README.md --output-json dist/docs.json",
|
|
18
17
|
"build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
|
|
19
|
-
"clean": "rimraf ./dist
|
|
18
|
+
"clean": "rimraf ./dist",
|
|
20
19
|
"watch": "tsc --watch",
|
|
20
|
+
"docgen": "docgen --api CameraPreviewPlugin --output-readme README.md --output-json dist/docs.json",
|
|
21
21
|
"prepublishOnly": "npm run build",
|
|
22
22
|
"prepare": "husky install"
|
|
23
23
|
},
|
|
24
24
|
"author": "Martin Donadieu <martindonadieu@gmail.com>",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@capacitor/android": "^
|
|
28
|
-
"@capacitor/cli": "^
|
|
29
|
-
"@capacitor/core": "^
|
|
30
|
-
"@capacitor/docgen": "^0.2.
|
|
31
|
-
"@capacitor/ios": "^
|
|
27
|
+
"@capacitor/android": "^5.0.3",
|
|
28
|
+
"@capacitor/cli": "^5.0.3",
|
|
29
|
+
"@capacitor/core": "^5.0.3",
|
|
30
|
+
"@capacitor/docgen": "^0.2.1",
|
|
31
|
+
"@capacitor/ios": "^5.0.3",
|
|
32
32
|
"@ionic/eslint-config": "^0.3.0",
|
|
33
|
-
"@ionic/prettier-config": "^
|
|
33
|
+
"@ionic/prettier-config": "^3.0.0",
|
|
34
34
|
"@ionic/swiftlint-config": "^1.1.2",
|
|
35
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
36
|
-
"@typescript-eslint/parser": "^5.
|
|
37
|
-
"eslint": "^8.
|
|
38
|
-
"eslint-plugin-import": "^2.
|
|
39
|
-
"husky": "^8.0.
|
|
40
|
-
"prettier": "^2.
|
|
41
|
-
"prettier-plugin-java": "^1.
|
|
42
|
-
"rimraf": "^
|
|
43
|
-
"rollup": "^3.
|
|
44
|
-
"swiftlint": "^1.0.
|
|
45
|
-
"typescript": "^
|
|
35
|
+
"@typescript-eslint/eslint-plugin": "^5.59.7",
|
|
36
|
+
"@typescript-eslint/parser": "^5.59.7",
|
|
37
|
+
"eslint": "^8.41.0",
|
|
38
|
+
"eslint-plugin-import": "^2.27.5",
|
|
39
|
+
"husky": "^8.0.3",
|
|
40
|
+
"prettier": "^2.8.8",
|
|
41
|
+
"prettier-plugin-java": "^2.1.0",
|
|
42
|
+
"rimraf": "^5.0.1",
|
|
43
|
+
"rollup": "^3.23.0",
|
|
44
|
+
"swiftlint": "^1.0.2",
|
|
45
|
+
"typescript": "^5.0.4"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
|
-
"@capacitor/core": "^
|
|
48
|
+
"@capacitor/core": "^5.0.0"
|
|
49
49
|
},
|
|
50
50
|
"capacitor": {
|
|
51
51
|
"ios": {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|