@capacitor-community/camera-preview 4.0.0 → 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 +19 -13
- package/android/.gradle/8.0.2/checksums/checksums.lock +0 -0
- package/android/.gradle/{4.10.1/fileHashes/fileHashes.bin → 8.0.2/checksums/md5-checksums.bin} +0 -0
- package/android/.gradle/8.0.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/8.0.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.bin +0 -0
- package/android/.gradle/8.0.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/8.0.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.0.2/fileHashes/resourceHashesCache.bin +0 -0
- package/android/.gradle/8.0.2/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +10 -8
- package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/android/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/android/gradle.properties +1 -1
- package/android/gradlew +14 -4
- package/android/gradlew.bat +34 -32
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +3 -3
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +5 -7
- package/dist/esm/definitions.d.ts +4 -2
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/web.d.ts +3 -3
- package/dist/esm/web.js +14 -10
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +155 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +158 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/CameraController.swift +1 -1
- package/ios/Plugin/Plugin.swift +5 -5
- package/ios/Podfile +7 -4
- package/ios/Podfile.lock +9 -10
- package/ios/Pods/CapacitorCordova/LICENSE +23 -0
- package/ios/Pods/CapacitorCordova/README.md +39 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/CapacitorCordova.h +21 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.h +8 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/AppDelegate.m +5 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDV.h +28 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVAvailability.h +109 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegate.h +51 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.h +39 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVCommandDelegateImpl.m +154 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.h +31 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVConfigParser.m +81 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.h +52 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVInvokedUrlCommand.m +116 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.h +81 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPlugin.m +154 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.h +25 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginManager.m +77 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.h +82 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVPluginResult.m +216 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVScreenOrientationDelegate.h +33 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.h +41 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUIWebViewDelegate.m +399 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.h +27 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVURLProtocol.m +74 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.h +27 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVUserAgentUtil.m +156 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.h +30 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/CDVViewController.m +34 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.h +35 -0
- package/ios/Pods/CapacitorCordova/ios/CapacitorCordova/CapacitorCordova/Classes/Public/NSDictionary+CordovaPreferences.m +63 -0
- package/ios/Pods/Local Podspecs/Capacitor.podspec.json +34 -0
- package/ios/Pods/Local Podspecs/CapacitorCordova.podspec.json +26 -0
- package/ios/Pods/Manifest.lock +22 -0
- package/ios/Pods/Pods.xcodeproj/project.pbxproj +1374 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Capacitor.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/CapacitorCordova.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-Plugin.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/Pods-PluginTests.xcscheme +58 -0
- package/ios/Pods/Pods.xcodeproj/xcuserdata/julionic.xcuserdatad/xcschemes/xcschememanagement.plist +31 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor-prefix.pch +12 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.debug.xcconfig +15 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.modulemap +8 -0
- package/ios/Pods/Target Support Files/Capacitor/Capacitor.release.xcconfig +15 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-Info.plist +26 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-dummy.m +5 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-prefix.pch +12 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova-umbrella.h +32 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.debug.xcconfig +12 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.modulemap +6 -0
- package/ios/Pods/Target Support Files/CapacitorCordova/CapacitorCordova.release.xcconfig +12 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.markdown +53 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-acknowledgements.plist +91 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.debug.xcconfig +14 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-Plugin/Pods-Plugin.release.xcconfig +14 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-Info.plist +26 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.markdown +53 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-acknowledgements.plist +91 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-dummy.m +5 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-frameworks.sh +188 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests-umbrella.h +16 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.debug.xcconfig +15 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.modulemap +6 -0
- package/ios/Pods/Target Support Files/Pods-PluginTests/Pods-PluginTests.release.xcconfig +15 -0
- package/package.json +19 -9
- package/android/.gradle/4.10.1/fileHashes/fileHashes.lock +0 -0
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -20
- package/android/.idea/jarRepositories.xml +0 -45
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_2_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_activity_activity_1_2_3_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_1_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_1_2_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_annotation_annotation_experimental_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_2_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_1_3_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_2_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_appcompat_appcompat_resources_1_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_common_2_1_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_arch_core_core_runtime_2_1_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_collection_collection_1_1_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_coordinatorlayout_coordinatorlayout_1_1_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_core_core_1_3_2_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_core_core_1_5_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_cursoradapter_cursoradapter_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_customview_customview_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_drawerlayout_drawerlayout_1_0_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_exifinterface_exifinterface_1_3_2_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_0_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_fragment_fragment_1_3_4_aar.xml +0 -14
- package/android/.idea/libraries/Gradle__androidx_interpolator_interpolator_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_0.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_common_2_3_1.xml +0 -9
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_2_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_livedata_core_2_3_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_runtime_2_3_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_2_3_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_lifecycle_lifecycle_viewmodel_savedstate_2_3_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_loader_loader_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_savedstate_savedstate_1_1_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_core_1_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_1_0_alpha3_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_core_3_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_1_0_alpha3_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_espresso_espresso_idling_resource_3_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_ext_junit_1_1_2_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_monitor_1_1_0_alpha3_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_monitor_1_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_runner_1_1_0_alpha3_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_test_runner_1_3_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_tracing_tracing_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_1_1_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_vectordrawable_vectordrawable_animated_1_1_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_versionedparcelable_versionedparcelable_1_1_1_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__androidx_viewpager_viewpager_1_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__com_google_code_findbugs_jsr305_2_0_1.xml +0 -9
- package/android/.idea/libraries/Gradle__com_squareup_javawriter_2_1_1.xml +0 -9
- package/android/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +0 -9
- package/android/.idea/libraries/Gradle__junit_junit_4_12.xml +0 -9
- package/android/.idea/libraries/Gradle__junit_junit_4_13_1.xml +0 -9
- package/android/.idea/libraries/Gradle__net_bytebuddy_byte_buddy_1_10_18.xml +0 -9
- package/android/.idea/libraries/Gradle__net_bytebuddy_byte_buddy_agent_1_10_18.xml +0 -9
- package/android/.idea/libraries/Gradle__net_sf_kxml_kxml2_2_3_0.xml +0 -9
- package/android/.idea/libraries/Gradle__org_apache_cordova_framework_7_0_0_aar.xml +0 -11
- package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_core_1_3.xml +0 -9
- package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_integration_1_3.xml +0 -9
- package/android/.idea/libraries/Gradle__org_hamcrest_hamcrest_library_1_3.xml +0 -9
- package/android/.idea/libraries/Gradle__org_json_json_20140107.xml +0 -9
- package/android/.idea/libraries/Gradle__org_mockito_mockito_core_3_6_28.xml +0 -9
- package/android/.idea/libraries/Gradle__org_mockito_mockito_inline_3_6_28.xml +0 -9
- package/android/.idea/libraries/Gradle__org_objenesis_objenesis_3_1.xml +0 -9
- package/android/.idea/misc.xml +0 -9
- package/android/.idea/modules/1419750366/android.capacitor-android.iml +0 -92
- package/android/.idea/modules/android.iml +0 -87
- package/android/.idea/modules.xml +0 -9
- package/android/.idea/vcs.xml +0 -6
- /package/android/.gradle/{4.10.1 → 8.0.2/dependencies-accessors}/gc.properties +0 -0
- /package/android/.gradle/{4.10.1 → 8.0.2}/fileChanges/last-build.bin +0 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@capacitor/core');
|
|
6
|
+
|
|
7
|
+
const CameraPreview = core.registerPlugin('CameraPreview', {
|
|
8
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CameraPreviewWeb()),
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
class CameraPreviewWeb extends core.WebPlugin {
|
|
12
|
+
constructor() {
|
|
13
|
+
super({
|
|
14
|
+
name: 'CameraPreview',
|
|
15
|
+
platforms: ['web'],
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async start(options) {
|
|
19
|
+
return new Promise(async (resolve, reject) => {
|
|
20
|
+
await navigator.mediaDevices
|
|
21
|
+
.getUserMedia({
|
|
22
|
+
audio: !options.disableAudio,
|
|
23
|
+
video: true,
|
|
24
|
+
})
|
|
25
|
+
.then((stream) => {
|
|
26
|
+
// Stop any existing stream so we can request media with different constraints based on user input
|
|
27
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
28
|
+
})
|
|
29
|
+
.catch((error) => {
|
|
30
|
+
reject(error);
|
|
31
|
+
});
|
|
32
|
+
const video = document.getElementById('video');
|
|
33
|
+
const parent = document.getElementById(options.parent);
|
|
34
|
+
if (!video) {
|
|
35
|
+
const videoElement = document.createElement('video');
|
|
36
|
+
videoElement.id = 'video';
|
|
37
|
+
videoElement.setAttribute('class', options.className || '');
|
|
38
|
+
// Don't flip video feed if camera is rear facing
|
|
39
|
+
if (options.position !== 'rear') {
|
|
40
|
+
videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
|
|
41
|
+
}
|
|
42
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
43
|
+
const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
|
|
44
|
+
// Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
|
|
45
|
+
// Without these attributes videoElement.play() will throw a NotAllowedError
|
|
46
|
+
// https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
|
|
47
|
+
if (isSafari) {
|
|
48
|
+
videoElement.setAttribute('autoplay', 'true');
|
|
49
|
+
videoElement.setAttribute('muted', 'true');
|
|
50
|
+
videoElement.setAttribute('playsinline', 'true');
|
|
51
|
+
}
|
|
52
|
+
parent.appendChild(videoElement);
|
|
53
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
54
|
+
const constraints = {
|
|
55
|
+
video: {
|
|
56
|
+
width: { ideal: options.width },
|
|
57
|
+
height: { ideal: options.height },
|
|
58
|
+
},
|
|
59
|
+
};
|
|
60
|
+
if (options.position === 'rear') {
|
|
61
|
+
constraints.video.facingMode = 'environment';
|
|
62
|
+
this.isBackCamera = true;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.isBackCamera = false;
|
|
66
|
+
}
|
|
67
|
+
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
|
|
68
|
+
//video.src = window.URL.createObjectURL(stream);
|
|
69
|
+
videoElement.srcObject = stream;
|
|
70
|
+
videoElement.play();
|
|
71
|
+
resolve({});
|
|
72
|
+
}, (err) => {
|
|
73
|
+
reject(err);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
reject({ message: 'camera already started' });
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async startRecordVideo() {
|
|
83
|
+
throw this.unimplemented('Not implemented on web.');
|
|
84
|
+
}
|
|
85
|
+
async stopRecordVideo() {
|
|
86
|
+
throw this.unimplemented('Not implemented on web.');
|
|
87
|
+
}
|
|
88
|
+
async stop() {
|
|
89
|
+
const video = document.getElementById('video');
|
|
90
|
+
if (video) {
|
|
91
|
+
video.pause();
|
|
92
|
+
const st = video.srcObject;
|
|
93
|
+
const tracks = st.getTracks();
|
|
94
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
95
|
+
const track = tracks[i];
|
|
96
|
+
track.stop();
|
|
97
|
+
}
|
|
98
|
+
video.remove();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
async capture(options) {
|
|
102
|
+
return new Promise((resolve, _) => {
|
|
103
|
+
const video = document.getElementById('video');
|
|
104
|
+
const canvas = document.createElement('canvas');
|
|
105
|
+
// video.width = video.offsetWidth;
|
|
106
|
+
const context = canvas.getContext('2d');
|
|
107
|
+
canvas.width = video.videoWidth;
|
|
108
|
+
canvas.height = video.videoHeight;
|
|
109
|
+
// flip horizontally back camera isn't used
|
|
110
|
+
if (!this.isBackCamera) {
|
|
111
|
+
context.translate(video.videoWidth, 0);
|
|
112
|
+
context.scale(-1, 1);
|
|
113
|
+
}
|
|
114
|
+
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
115
|
+
let base64EncodedImage;
|
|
116
|
+
if (options.quality != undefined) {
|
|
117
|
+
base64EncodedImage = canvas
|
|
118
|
+
.toDataURL('image/jpeg', options.quality / 100.0)
|
|
119
|
+
.replace('data:image/jpeg;base64,', '');
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
|
|
123
|
+
}
|
|
124
|
+
resolve({
|
|
125
|
+
value: base64EncodedImage,
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async captureSample(_options) {
|
|
130
|
+
return this.capture(_options);
|
|
131
|
+
}
|
|
132
|
+
async getSupportedFlashModes() {
|
|
133
|
+
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
134
|
+
}
|
|
135
|
+
async setFlashMode(_options) {
|
|
136
|
+
throw new Error('setFlashMode not supported under the web platform');
|
|
137
|
+
}
|
|
138
|
+
async flip() {
|
|
139
|
+
throw new Error('flip not supported under the web platform');
|
|
140
|
+
}
|
|
141
|
+
async setOpacity(_options) {
|
|
142
|
+
const video = document.getElementById('video');
|
|
143
|
+
if (!!video && !!_options['opacity']) {
|
|
144
|
+
video.style.setProperty('opacity', _options['opacity'].toString());
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
150
|
+
__proto__: null,
|
|
151
|
+
CameraPreviewWeb: CameraPreviewWeb
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
exports.CameraPreview = CameraPreview;
|
|
155
|
+
//# sourceMappingURL=plugin.cjs.js.map
|
|
@@ -0,0 +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,K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AM,YAAY,CAAC,QAAQ,EAAE;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;;;;;;;;;"}
|
package/dist/plugin.js
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
var capacitorSplashScreen = (function (exports, core) {
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const CameraPreview = core.registerPlugin('CameraPreview', {
|
|
5
|
+
web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.CameraPreviewWeb()),
|
|
6
|
+
});
|
|
7
|
+
|
|
8
|
+
class CameraPreviewWeb extends core.WebPlugin {
|
|
9
|
+
constructor() {
|
|
10
|
+
super({
|
|
11
|
+
name: 'CameraPreview',
|
|
12
|
+
platforms: ['web'],
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
async start(options) {
|
|
16
|
+
return new Promise(async (resolve, reject) => {
|
|
17
|
+
await navigator.mediaDevices
|
|
18
|
+
.getUserMedia({
|
|
19
|
+
audio: !options.disableAudio,
|
|
20
|
+
video: true,
|
|
21
|
+
})
|
|
22
|
+
.then((stream) => {
|
|
23
|
+
// Stop any existing stream so we can request media with different constraints based on user input
|
|
24
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
25
|
+
})
|
|
26
|
+
.catch((error) => {
|
|
27
|
+
reject(error);
|
|
28
|
+
});
|
|
29
|
+
const video = document.getElementById('video');
|
|
30
|
+
const parent = document.getElementById(options.parent);
|
|
31
|
+
if (!video) {
|
|
32
|
+
const videoElement = document.createElement('video');
|
|
33
|
+
videoElement.id = 'video';
|
|
34
|
+
videoElement.setAttribute('class', options.className || '');
|
|
35
|
+
// Don't flip video feed if camera is rear facing
|
|
36
|
+
if (options.position !== 'rear') {
|
|
37
|
+
videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
|
|
38
|
+
}
|
|
39
|
+
const userAgent = navigator.userAgent.toLowerCase();
|
|
40
|
+
const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
|
|
41
|
+
// Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
|
|
42
|
+
// Without these attributes videoElement.play() will throw a NotAllowedError
|
|
43
|
+
// https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
|
|
44
|
+
if (isSafari) {
|
|
45
|
+
videoElement.setAttribute('autoplay', 'true');
|
|
46
|
+
videoElement.setAttribute('muted', 'true');
|
|
47
|
+
videoElement.setAttribute('playsinline', 'true');
|
|
48
|
+
}
|
|
49
|
+
parent.appendChild(videoElement);
|
|
50
|
+
if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
|
|
51
|
+
const constraints = {
|
|
52
|
+
video: {
|
|
53
|
+
width: { ideal: options.width },
|
|
54
|
+
height: { ideal: options.height },
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
if (options.position === 'rear') {
|
|
58
|
+
constraints.video.facingMode = 'environment';
|
|
59
|
+
this.isBackCamera = true;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.isBackCamera = false;
|
|
63
|
+
}
|
|
64
|
+
navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
|
|
65
|
+
//video.src = window.URL.createObjectURL(stream);
|
|
66
|
+
videoElement.srcObject = stream;
|
|
67
|
+
videoElement.play();
|
|
68
|
+
resolve({});
|
|
69
|
+
}, (err) => {
|
|
70
|
+
reject(err);
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
reject({ message: 'camera already started' });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async startRecordVideo() {
|
|
80
|
+
throw this.unimplemented('Not implemented on web.');
|
|
81
|
+
}
|
|
82
|
+
async stopRecordVideo() {
|
|
83
|
+
throw this.unimplemented('Not implemented on web.');
|
|
84
|
+
}
|
|
85
|
+
async stop() {
|
|
86
|
+
const video = document.getElementById('video');
|
|
87
|
+
if (video) {
|
|
88
|
+
video.pause();
|
|
89
|
+
const st = video.srcObject;
|
|
90
|
+
const tracks = st.getTracks();
|
|
91
|
+
for (let i = 0; i < tracks.length; i++) {
|
|
92
|
+
const track = tracks[i];
|
|
93
|
+
track.stop();
|
|
94
|
+
}
|
|
95
|
+
video.remove();
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
async capture(options) {
|
|
99
|
+
return new Promise((resolve, _) => {
|
|
100
|
+
const video = document.getElementById('video');
|
|
101
|
+
const canvas = document.createElement('canvas');
|
|
102
|
+
// video.width = video.offsetWidth;
|
|
103
|
+
const context = canvas.getContext('2d');
|
|
104
|
+
canvas.width = video.videoWidth;
|
|
105
|
+
canvas.height = video.videoHeight;
|
|
106
|
+
// flip horizontally back camera isn't used
|
|
107
|
+
if (!this.isBackCamera) {
|
|
108
|
+
context.translate(video.videoWidth, 0);
|
|
109
|
+
context.scale(-1, 1);
|
|
110
|
+
}
|
|
111
|
+
context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
|
|
112
|
+
let base64EncodedImage;
|
|
113
|
+
if (options.quality != undefined) {
|
|
114
|
+
base64EncodedImage = canvas
|
|
115
|
+
.toDataURL('image/jpeg', options.quality / 100.0)
|
|
116
|
+
.replace('data:image/jpeg;base64,', '');
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
|
|
120
|
+
}
|
|
121
|
+
resolve({
|
|
122
|
+
value: base64EncodedImage,
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
async captureSample(_options) {
|
|
127
|
+
return this.capture(_options);
|
|
128
|
+
}
|
|
129
|
+
async getSupportedFlashModes() {
|
|
130
|
+
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
131
|
+
}
|
|
132
|
+
async setFlashMode(_options) {
|
|
133
|
+
throw new Error('setFlashMode not supported under the web platform');
|
|
134
|
+
}
|
|
135
|
+
async flip() {
|
|
136
|
+
throw new Error('flip not supported under the web platform');
|
|
137
|
+
}
|
|
138
|
+
async setOpacity(_options) {
|
|
139
|
+
const video = document.getElementById('video');
|
|
140
|
+
if (!!video && !!_options['opacity']) {
|
|
141
|
+
video.style.setProperty('opacity', _options['opacity'].toString());
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var web = /*#__PURE__*/Object.freeze({
|
|
147
|
+
__proto__: null,
|
|
148
|
+
CameraPreviewWeb: CameraPreviewWeb
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
exports.CameraPreview = CameraPreview;
|
|
152
|
+
|
|
153
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
154
|
+
|
|
155
|
+
return exports;
|
|
156
|
+
|
|
157
|
+
})({}, capacitorExports);
|
|
158
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +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,K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AK;IACL,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;IAClC,QAAQ,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,KAAK;IACL,IAAI,MAAM,sBAAsB,GAAG;IACnC,QAAQ,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACvF,KAAK;IACL,IAAI,MAAM,YAAY,CAAC,QAAQ,EAAE;IACjC,QAAQ,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IAC7E,KAAK;IACL,IAAI,MAAM,IAAI,GAAG;IACjB,QAAQ,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IACrE,KAAK;IACL,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,KAAK,GAAG,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;IACvD,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,CAAC;IAC/E,SAAS;IACT,KAAK;IACL;;;;;;;;;;;;;;;;;"}
|
|
@@ -487,7 +487,7 @@ extension CameraController: AVCapturePhotoCaptureDelegate {
|
|
|
487
487
|
public func photoOutput(_ captureOutput: AVCapturePhotoOutput, didFinishProcessingPhoto photoSampleBuffer: CMSampleBuffer?, previewPhoto previewPhotoSampleBuffer: CMSampleBuffer?,
|
|
488
488
|
resolvedSettings: AVCaptureResolvedPhotoSettings, bracketSettings: AVCaptureBracketedStillImageSettings?, error: Swift.Error?) {
|
|
489
489
|
if let error = error { self.photoCaptureCompletionBlock?(nil, error) } else if let buffer = photoSampleBuffer, let data = AVCapturePhotoOutput.jpegPhotoDataRepresentation(forJPEGSampleBuffer: buffer, previewPhotoSampleBuffer: nil),
|
|
490
|
-
|
|
490
|
+
let image = UIImage(data: data) {
|
|
491
491
|
self.photoCaptureCompletionBlock?(image.fixedOrientation(), nil)
|
|
492
492
|
} else {
|
|
493
493
|
self.photoCaptureCompletionBlock?(nil, CameraControllerError.unknown)
|
package/ios/Plugin/Plugin.swift
CHANGED
|
@@ -24,7 +24,7 @@ public class CameraPreview: CAPPlugin {
|
|
|
24
24
|
var disableAudio: Bool = false
|
|
25
25
|
|
|
26
26
|
@objc func rotated() {
|
|
27
|
-
let height = self.paddingBottom != nil ? self.height! - self.paddingBottom!: self.height
|
|
27
|
+
let height = self.paddingBottom != nil ? self.height! - self.paddingBottom!: self.height!
|
|
28
28
|
|
|
29
29
|
if UIApplication.shared.statusBarOrientation.isLandscape {
|
|
30
30
|
self.previewView.frame = CGRect(x: self.y!, y: self.x!, width: max(height, self.width!), height: min(height, self.width!))
|
|
@@ -32,7 +32,7 @@ public class CameraPreview: CAPPlugin {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
if UIApplication.shared.statusBarOrientation.isPortrait {
|
|
35
|
-
if
|
|
35
|
+
if self.previewView != nil && self.x != nil && self.y != nil && self.width != nil && self.height != nil {
|
|
36
36
|
self.previewView.frame = CGRect(x: self.x!, y: self.y!, width: min(height, self.width!), height: max(height, self.width!))
|
|
37
37
|
}
|
|
38
38
|
self.cameraController.previewLayer?.frame = self.previewView.frame
|
|
@@ -67,7 +67,7 @@ public class CameraPreview: CAPPlugin {
|
|
|
67
67
|
self.storeToFile = call.getBool("storeToFile") ?? false
|
|
68
68
|
self.enableZoom = call.getBool("enableZoom") ?? false
|
|
69
69
|
self.disableAudio = call.getBool("disableAudio") ?? false
|
|
70
|
-
|
|
70
|
+
|
|
71
71
|
AVCaptureDevice.requestAccess(for: .video, completionHandler: { (granted: Bool) in
|
|
72
72
|
guard granted else {
|
|
73
73
|
call.reject("permission failed")
|
|
@@ -78,7 +78,7 @@ public class CameraPreview: CAPPlugin {
|
|
|
78
78
|
if self.cameraController.captureSession?.isRunning ?? false {
|
|
79
79
|
call.reject("camera already started")
|
|
80
80
|
} else {
|
|
81
|
-
self.cameraController.prepare(cameraPosition: self.cameraPosition, disableAudio: self.disableAudio){error in
|
|
81
|
+
self.cameraController.prepare(cameraPosition: self.cameraPosition, disableAudio: self.disableAudio) {error in
|
|
82
82
|
if let error = error {
|
|
83
83
|
print(error)
|
|
84
84
|
call.reject(error.localizedDescription)
|
|
@@ -235,7 +235,7 @@ public class CameraPreview: CAPPlugin {
|
|
|
235
235
|
do {
|
|
236
236
|
var flashModeAsEnum: AVCaptureDevice.FlashMode?
|
|
237
237
|
switch flashMode {
|
|
238
|
-
case "off"
|
|
238
|
+
case "off":
|
|
239
239
|
flashModeAsEnum = AVCaptureDevice.FlashMode.off
|
|
240
240
|
case "on":
|
|
241
241
|
flashModeAsEnum = AVCaptureDevice.FlashMode.on
|
package/ios/Podfile
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
platform :ios, '13.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
|
|
5
5
|
use_frameworks!
|
|
6
6
|
pod 'Capacitor', :path => '../node_modules/@capacitor/ios'
|
|
7
|
+
pod 'CapacitorCordova', :path => '../node_modules/@capacitor/ios'
|
|
7
8
|
end
|
|
8
9
|
|
|
9
|
-
target '
|
|
10
|
-
|
|
10
|
+
target 'Plugin' do
|
|
11
|
+
capacitor_pods
|
|
12
|
+
end
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
target 'PluginTests' do
|
|
15
|
+
capacitor_pods
|
|
13
16
|
end
|
package/ios/Podfile.lock
CHANGED
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
PODS:
|
|
2
|
-
- Capacitor (
|
|
2
|
+
- Capacitor (5.0.3):
|
|
3
3
|
- CapacitorCordova
|
|
4
|
-
- CapacitorCordova (
|
|
4
|
+
- CapacitorCordova (5.0.3)
|
|
5
5
|
|
|
6
6
|
DEPENDENCIES:
|
|
7
7
|
- "Capacitor (from `../node_modules/@capacitor/ios`)"
|
|
8
|
-
|
|
9
|
-
SPEC REPOS:
|
|
10
|
-
trunk:
|
|
11
|
-
- CapacitorCordova
|
|
8
|
+
- "CapacitorCordova (from `../node_modules/@capacitor/ios`)"
|
|
12
9
|
|
|
13
10
|
EXTERNAL SOURCES:
|
|
14
11
|
Capacitor:
|
|
15
12
|
:path: "../node_modules/@capacitor/ios"
|
|
13
|
+
CapacitorCordova:
|
|
14
|
+
:path: "../node_modules/@capacitor/ios"
|
|
16
15
|
|
|
17
16
|
SPEC CHECKSUMS:
|
|
18
|
-
Capacitor:
|
|
19
|
-
CapacitorCordova:
|
|
17
|
+
Capacitor: 304a960e431f9e6f78556554ca71c41c1b2b9680
|
|
18
|
+
CapacitorCordova: def732a63679698df6fb392bbe6d269a0b61e937
|
|
20
19
|
|
|
21
|
-
PODFILE CHECKSUM:
|
|
20
|
+
PODFILE CHECKSUM: 14e8b2400457751b865e1c327e7cfa1c6fa67da6
|
|
22
21
|
|
|
23
|
-
COCOAPODS: 1.
|
|
22
|
+
COCOAPODS: 1.11.3
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Copyright 2015-present Drifty Co.
|
|
2
|
+
http://drifty.com/
|
|
3
|
+
|
|
4
|
+
MIT License
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
7
|
+
a copy of this software and associated documentation files (the
|
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
12
|
+
the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be
|
|
15
|
+
included in all copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
[![Build Status][circle-badge]][circle-badge-url]
|
|
2
|
+
|
|
3
|
+
# ⚡️ Cross-platform apps with JavaScript and the Web ⚡️
|
|
4
|
+
|
|
5
|
+
Capacitor is a cross-platform API and code execution layer that makes it easy to call Native SDKs from web code and to write custom Native plugins that your app might need. Additionally, Capacitor provides first-class Progressive Web App support so you can write one app and deploy it to the app stores, _and_ the mobile web.
|
|
6
|
+
|
|
7
|
+
Capacitor was created by the Ionic Framework team as a spiritual successor to Cordova, though it does have backward compatibility with the majority of Cordova plugins. Capacitor can be used without [Ionic Framework](https://ionicframework.com/docs/components), but since it's a core part of the Ionic Platform, it's recommended for the best app development experience.
|
|
8
|
+
|
|
9
|
+
Capacitor also comes with a Plugin API for building native plugins. On iOS, first-class Swift support is available, and much of the iOS Capacitor runtime is written in Swift. Plugins may also be written in Objective-C. On Android, writing plugins in Java and Kotlin is supported.
|
|
10
|
+
|
|
11
|
+
## Roadmap
|
|
12
|
+
|
|
13
|
+
_Disclaimer: Our roadmap is subject to change at any time and has no specific date guarantees_
|
|
14
|
+
|
|
15
|
+
2020 and beyond: The core Capacitor project is now stable. Maintenance is ongoing (including support for new mobile operating system versions, bugs, etc.). Going forward, most new functionality will be implemented as plugins. For the latest updates, track new releases [here](https://github.com/ionic-team/capacitor/releases) or milestones [here](https://github.com/ionic-team/capacitor/milestones).
|
|
16
|
+
|
|
17
|
+
[2019](https://blog.ionicframework.com/capacitor-in-2019-native-progressive-web-apps-for-all/)
|
|
18
|
+
|
|
19
|
+
2018
|
|
20
|
+
|
|
21
|
+
- __Cordova Plugin Integration__
|
|
22
|
+
- Preliminary support for using plugins from the existing Cordova community
|
|
23
|
+
- __Electron support__
|
|
24
|
+
- Support for building Electron apps and interacting with Node.js libraries
|
|
25
|
+
- __Enterprise Premium Plugins__
|
|
26
|
+
- Paid add-on plugins with support for common Enterprise use cases, such as storage, authentication, security, and more
|
|
27
|
+
- Developer Support options with SLAs and priority patches
|
|
28
|
+
- We are working with a few large teams/businesses as early development partners. Interested? Email [max@ionicframework.com](mailto:max@ionicframework.com)
|
|
29
|
+
|
|
30
|
+
## Contributing
|
|
31
|
+
|
|
32
|
+
Contributing to Capacitor may involve writing TypeScript, Swift/Objective-C, Java, or Markdown depending on the component you are working on. We are looking for help in any of these areas!
|
|
33
|
+
|
|
34
|
+
Please read the [Contributing](.github/CONTRIBUTING.md) guide for more information.
|
|
35
|
+
|
|
36
|
+
For details on updating the Capacitor website or documentation, [see here](site/CONTRIBUTING.md).
|
|
37
|
+
|
|
38
|
+
[circle-badge]: https://circleci.com/gh/ionic-team/capacitor.svg?style=shield
|
|
39
|
+
[circle-badge-url]: https://circleci.com/gh/ionic-team/capacitor
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#import <UIKit/UIKit.h>
|
|
2
|
+
|
|
3
|
+
//! Project version number for CapacitorCordova.
|
|
4
|
+
FOUNDATION_EXPORT double CapacitorCordovaVersionNumber;
|
|
5
|
+
|
|
6
|
+
//! Project version string for CapacitorCordova.
|
|
7
|
+
FOUNDATION_EXPORT const unsigned char CapacitorCordovaVersionString[];
|
|
8
|
+
|
|
9
|
+
// In this header, you should import all the public headers of your framework using statements like #import <CapacitorCordova/PublicHeader.h>
|
|
10
|
+
|
|
11
|
+
#import <Cordova/CDV.h>
|
|
12
|
+
#import <Cordova/CDVCommandDelegateImpl.h>
|
|
13
|
+
#import <Cordova/CDVAvailability.h>
|
|
14
|
+
#import <Cordova/CDVPlugin.h>
|
|
15
|
+
#import <Cordova/CDVPluginResult.h>
|
|
16
|
+
#import <Cordova/CDVCommandDelegate.h>
|
|
17
|
+
#import <Cordova/CDVInvokedUrlCommand.h>
|
|
18
|
+
#import <Cordova/CDVConfigParser.h>
|
|
19
|
+
#import <Cordova/CDVViewController.h>
|
|
20
|
+
#import <Cordova/NSDictionary+CordovaPreferences.h>
|
|
21
|
+
#import <Cordova/CDVURLProtocol.h>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Licensed to the Apache Software Foundation (ASF) under one
|
|
3
|
+
or more contributor license agreements. See the NOTICE file
|
|
4
|
+
distributed with this work for additional information
|
|
5
|
+
regarding copyright ownership. The ASF licenses this file
|
|
6
|
+
to you under the Apache License, Version 2.0 (the
|
|
7
|
+
"License"); you may not use this file except in compliance
|
|
8
|
+
with the License. You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
Unless required by applicable law or agreed to in writing,
|
|
13
|
+
software distributed under the License is distributed on an
|
|
14
|
+
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
15
|
+
KIND, either express or implied. See the License for the
|
|
16
|
+
specific language governing permissions and limitations
|
|
17
|
+
under the License.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
#import "CDVAvailability.h"
|
|
21
|
+
#import "CDVPlugin.h"
|
|
22
|
+
#import "CDVPluginResult.h"
|
|
23
|
+
#import "CDVCommandDelegate.h"
|
|
24
|
+
#import "CDVInvokedUrlCommand.h"
|
|
25
|
+
#import "CDVViewController.h"
|
|
26
|
+
#import "CDVURLProtocol.h"
|
|
27
|
+
#import "CDVScreenOrientationDelegate.h"
|
|
28
|
+
|