@capacitor-community/camera-preview 5.0.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/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/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/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/outputFiles.bin +0 -0
- package/android/.gradle/file-system.probe +0 -0
- package/android/build.gradle +3 -2
- package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +3 -3
- package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +5 -7
- package/dist/esm/definitions.d.ts +2 -0
- 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 +17 -7
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,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AC;IACzG,aAAa;IACb,YAAY,OAAO,CAAC;IACpB,gBAAgB,KAAK,EAAE,kBAAkB;IACzC,aAAa,CAAC,CAAC;IACf,SAAS,CAAC,CAAC;IACX,KAAK;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
|
+
|
|
@@ -0,0 +1,109 @@
|
|
|
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
|
+
#define __CORDOVA_IOS__
|
|
21
|
+
|
|
22
|
+
#define __CORDOVA_0_9_6 906
|
|
23
|
+
#define __CORDOVA_1_0_0 10000
|
|
24
|
+
#define __CORDOVA_1_1_0 10100
|
|
25
|
+
#define __CORDOVA_1_2_0 10200
|
|
26
|
+
#define __CORDOVA_1_3_0 10300
|
|
27
|
+
#define __CORDOVA_1_4_0 10400
|
|
28
|
+
#define __CORDOVA_1_4_1 10401
|
|
29
|
+
#define __CORDOVA_1_5_0 10500
|
|
30
|
+
#define __CORDOVA_1_6_0 10600
|
|
31
|
+
#define __CORDOVA_1_6_1 10601
|
|
32
|
+
#define __CORDOVA_1_7_0 10700
|
|
33
|
+
#define __CORDOVA_1_8_0 10800
|
|
34
|
+
#define __CORDOVA_1_8_1 10801
|
|
35
|
+
#define __CORDOVA_1_9_0 10900
|
|
36
|
+
#define __CORDOVA_2_0_0 20000
|
|
37
|
+
#define __CORDOVA_2_1_0 20100
|
|
38
|
+
#define __CORDOVA_2_2_0 20200
|
|
39
|
+
#define __CORDOVA_2_3_0 20300
|
|
40
|
+
#define __CORDOVA_2_4_0 20400
|
|
41
|
+
#define __CORDOVA_2_5_0 20500
|
|
42
|
+
#define __CORDOVA_2_6_0 20600
|
|
43
|
+
#define __CORDOVA_2_7_0 20700
|
|
44
|
+
#define __CORDOVA_2_8_0 20800
|
|
45
|
+
#define __CORDOVA_2_9_0 20900
|
|
46
|
+
#define __CORDOVA_3_0_0 30000
|
|
47
|
+
#define __CORDOVA_3_1_0 30100
|
|
48
|
+
#define __CORDOVA_3_2_0 30200
|
|
49
|
+
#define __CORDOVA_3_3_0 30300
|
|
50
|
+
#define __CORDOVA_3_4_0 30400
|
|
51
|
+
#define __CORDOVA_3_4_1 30401
|
|
52
|
+
#define __CORDOVA_3_5_0 30500
|
|
53
|
+
#define __CORDOVA_3_6_0 30600
|
|
54
|
+
#define __CORDOVA_3_7_0 30700
|
|
55
|
+
#define __CORDOVA_3_8_0 30800
|
|
56
|
+
#define __CORDOVA_3_9_0 30900
|
|
57
|
+
#define __CORDOVA_3_9_1 30901
|
|
58
|
+
#define __CORDOVA_3_9_2 30902
|
|
59
|
+
#define __CORDOVA_4_0_0 40000
|
|
60
|
+
#define __CORDOVA_4_0_1 40001
|
|
61
|
+
#define __CORDOVA_4_1_0 40100
|
|
62
|
+
#define __CORDOVA_4_1_1 40101
|
|
63
|
+
#define __CORDOVA_4_2_0 40200
|
|
64
|
+
#define __CORDOVA_4_2_1 40201
|
|
65
|
+
#define __CORDOVA_4_3_0 40300
|
|
66
|
+
#define __CORDOVA_4_3_1 40301
|
|
67
|
+
#define __CORDOVA_4_4_0 40400
|
|
68
|
+
#define __CORDOVA_4_5_0 40500
|
|
69
|
+
#define __CORDOVA_4_5_1 40501
|
|
70
|
+
#define __CORDOVA_4_5_2 40502
|
|
71
|
+
#define __CORDOVA_4_5_4 40504
|
|
72
|
+
/* coho:next-version,insert-before */
|
|
73
|
+
#define __CORDOVA_NA 99999 /* not available */
|
|
74
|
+
|
|
75
|
+
/*
|
|
76
|
+
#if CORDOVA_VERSION_MIN_REQUIRED >= __CORDOVA_4_0_0
|
|
77
|
+
// do something when its at least 4.0.0
|
|
78
|
+
#else
|
|
79
|
+
// do something else (non 4.0.0)
|
|
80
|
+
#endif
|
|
81
|
+
*/
|
|
82
|
+
#ifndef CORDOVA_VERSION_MIN_REQUIRED
|
|
83
|
+
/* coho:next-version-min-required,replace-after */
|
|
84
|
+
#define CORDOVA_VERSION_MIN_REQUIRED __CORDOVA_4_5_4
|
|
85
|
+
#endif
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
Returns YES if it is at least version specified as NSString(X)
|
|
89
|
+
Usage:
|
|
90
|
+
if (IsAtLeastiOSVersion(@"5.1")) {
|
|
91
|
+
// do something for iOS 5.1 or greater
|
|
92
|
+
}
|
|
93
|
+
*/
|
|
94
|
+
#define IsAtLeastiOSVersion(X) ([[[UIDevice currentDevice] systemVersion] compare:X options:NSNumericSearch] != NSOrderedAscending)
|
|
95
|
+
|
|
96
|
+
/* Return the string version of the decimal version */
|
|
97
|
+
#define CDV_VERSION [NSString stringWithFormat:@"%d.%d.%d", \
|
|
98
|
+
(CORDOVA_VERSION_MIN_REQUIRED / 10000), \
|
|
99
|
+
(CORDOVA_VERSION_MIN_REQUIRED % 10000) / 100, \
|
|
100
|
+
(CORDOVA_VERSION_MIN_REQUIRED % 10000) % 100]
|
|
101
|
+
|
|
102
|
+
// Enable this to log all exec() calls.
|
|
103
|
+
#define CDV_ENABLE_EXEC_LOGGING 0
|
|
104
|
+
#if CDV_ENABLE_EXEC_LOGGING
|
|
105
|
+
#define CDV_EXEC_LOG NSLog
|
|
106
|
+
#else
|
|
107
|
+
#define CDV_EXEC_LOG(...) do { \
|
|
108
|
+
} while (NO)
|
|
109
|
+
#endif
|
|
@@ -0,0 +1,51 @@
|
|
|
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 "CDVInvokedUrlCommand.h"
|
|
21
|
+
|
|
22
|
+
@class CDVPlugin;
|
|
23
|
+
@class CDVPluginResult;
|
|
24
|
+
|
|
25
|
+
typedef NSURL* (^ UrlTransformerBlock)(NSURL*);
|
|
26
|
+
|
|
27
|
+
@protocol CDVCommandDelegate <NSObject>
|
|
28
|
+
|
|
29
|
+
@property (nonatomic, readonly) NSDictionary* settings;
|
|
30
|
+
@property (nonatomic, copy) UrlTransformerBlock urlTransformer;
|
|
31
|
+
|
|
32
|
+
- (NSString*)pathForResource:(NSString*)resourcepath;
|
|
33
|
+
- (id)getCommandInstance:(NSString*)pluginName;
|
|
34
|
+
|
|
35
|
+
// Sends a plugin result to the JS. This is thread-safe.
|
|
36
|
+
- (void)sendPluginResult:(CDVPluginResult*)result callbackId:(NSString*)callbackId;
|
|
37
|
+
// Evaluates the given JS. This is thread-safe.
|
|
38
|
+
- (void)evalJs:(NSString*)js;
|
|
39
|
+
// Can be used to evaluate JS right away instead of scheduling it on the run-loop.
|
|
40
|
+
// This is required for dispatch resign and pause events, but should not be used
|
|
41
|
+
// without reason. Without the run-loop delay, alerts used in JS callbacks may result
|
|
42
|
+
// in dead-lock. This method must be called from the UI thread.
|
|
43
|
+
- (void)evalJs:(NSString*)js scheduledOnRunLoop:(BOOL)scheduledOnRunLoop;
|
|
44
|
+
// Run the javascript
|
|
45
|
+
- (void)evalJsHelper2:(NSString*)js;
|
|
46
|
+
// Runs the given block on a background thread using a shared thread-pool.
|
|
47
|
+
- (void)runInBackground:(void (^)())block;
|
|
48
|
+
// Returns the User-Agent of the associated UIWebView.
|
|
49
|
+
- (NSString*)userAgent;
|
|
50
|
+
|
|
51
|
+
@end
|
|
@@ -0,0 +1,39 @@
|
|
|
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 <UIKit/UIKit.h>
|
|
21
|
+
#import "CDVCommandDelegate.h"
|
|
22
|
+
#import <WebKit/WebKit.h>
|
|
23
|
+
#import "CDVPluginManager.h"
|
|
24
|
+
|
|
25
|
+
@class CDVViewController;
|
|
26
|
+
@class CDVCommandQueue;
|
|
27
|
+
|
|
28
|
+
@interface CDVCommandDelegateImpl : NSObject <CDVCommandDelegate>{
|
|
29
|
+
@private
|
|
30
|
+
__weak WKWebView* _webView;
|
|
31
|
+
__weak CDVPluginManager* _manager;
|
|
32
|
+
NSRegularExpression* _callbackIdPattern;
|
|
33
|
+
@protected
|
|
34
|
+
__weak CDVCommandQueue* _commandQueue;
|
|
35
|
+
BOOL _delayResponses;
|
|
36
|
+
}
|
|
37
|
+
- (id)initWithWebView:(WKWebView*)webView pluginManager:(CDVPluginManager *)manager;
|
|
38
|
+
- (void)flushCommandQueueWithDelayedJs;
|
|
39
|
+
@end
|