capacitor-community-multilens-camerapreview 0.0.7 → 0.0.8

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.
Files changed (37) hide show
  1. package/CapacitorCommunityMultilensCamerapreview.podspec +17 -17
  2. package/README.md +16 -16
  3. package/android/build.gradle +55 -55
  4. package/android/src/main/AndroidManifest.xml +4 -4
  5. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +1008 -1008
  6. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +544 -544
  7. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +23 -23
  8. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +29 -29
  9. package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +386 -386
  10. package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +24 -24
  11. package/android/src/main/res/layout/bridge_layout_main.xml +15 -15
  12. package/android/src/main/res/layout/camera_activity.xml +68 -68
  13. package/android/src/main/res/values/camera_ids.xml +4 -4
  14. package/android/src/main/res/values/camera_theme.xml +9 -9
  15. package/android/src/main/res/values/colors.xml +3 -3
  16. package/android/src/main/res/values/strings.xml +3 -3
  17. package/android/src/main/res/values/styles.xml +3 -3
  18. package/dist/docs.json +1 -1
  19. package/dist/esm/definitions.d.ts +80 -80
  20. package/dist/esm/definitions.js +1 -1
  21. package/dist/esm/definitions.js.map +1 -1
  22. package/dist/esm/index.d.ts +4 -4
  23. package/dist/esm/index.js +6 -6
  24. package/dist/esm/index.js.map +1 -1
  25. package/dist/esm/web.d.ts +28 -28
  26. package/dist/esm/web.js +155 -155
  27. package/dist/esm/web.js.map +1 -1
  28. package/dist/plugin.cjs.js +149 -149
  29. package/dist/plugin.cjs.js.map +1 -1
  30. package/dist/plugin.js +149 -149
  31. package/dist/plugin.js.map +1 -1
  32. package/ios/Plugin/CameraController.swift +720 -716
  33. package/ios/Plugin/Info.plist +24 -24
  34. package/ios/Plugin/Plugin.h +10 -10
  35. package/ios/Plugin/Plugin.m +18 -18
  36. package/ios/Plugin/Plugin.swift +308 -300
  37. package/package.json +78 -78
package/dist/esm/web.js CHANGED
@@ -1,156 +1,156 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */
2
- /* eslint-disable @typescript-eslint/prefer-for-of */
3
- /* eslint-disable @typescript-eslint/ban-types */
4
- /* eslint-disable no-async-promise-executor */
5
- /* eslint-disable @typescript-eslint/consistent-type-assertions */
6
- /* eslint-disable @typescript-eslint/no-inferrable-types */
7
- import { WebPlugin, registerWebPlugin } from '@capacitor/core';
8
- export class CameraPreviewWeb extends WebPlugin {
9
- constructor() {
10
- super({
11
- name: 'CameraPreview',
12
- platforms: ['web'],
13
- });
14
- /**
15
- * track which camera is used based on start options
16
- * used in capture
17
- */
18
- this.isBackCamera = false;
19
- }
20
- async start(options) {
21
- return new Promise(async (resolve, reject) => {
22
- var _a;
23
- await navigator.mediaDevices
24
- .getUserMedia({
25
- audio: !options.disableAudio,
26
- video: true
27
- })
28
- .then((stream) => {
29
- // Stop any existing stream so we can request media with different constraints based on user input
30
- stream.getTracks().forEach((track) => track.stop());
31
- })
32
- .catch((error) => {
33
- reject(error);
34
- });
35
- const video = document.getElementById('video');
36
- const parent = document.getElementById(options.parent);
37
- if (!video) {
38
- const videoElement = document.createElement('video');
39
- videoElement.id = 'video';
40
- videoElement.setAttribute('class', options.className || '');
41
- // Don't flip video feed if camera is rear facing
42
- if (options.position !== 'rear') {
43
- videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
44
- }
45
- const userAgent = navigator.userAgent.toLowerCase();
46
- const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
47
- // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
48
- // Without these attributes videoElement.play() will throw a NotAllowedError
49
- // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
50
- if (isSafari) {
51
- videoElement.setAttribute('autoplay', 'true');
52
- videoElement.setAttribute('muted', 'true');
53
- videoElement.setAttribute('playsinline', 'true');
54
- }
55
- if (parent) {
56
- parent.appendChild(videoElement);
57
- }
58
- if ((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
59
- const constraints = {
60
- video: {
61
- width: { ideal: options.width },
62
- height: { ideal: options.height }
63
- }
64
- };
65
- if (options.position === 'rear') {
66
- constraints.video.facingMode = 'environment';
67
- this.isBackCamera = true;
68
- }
69
- else {
70
- this.isBackCamera = false;
71
- }
72
- navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
73
- //video.src = window.URL.createObjectURL(stream);
74
- videoElement.srcObject = stream;
75
- videoElement.play();
76
- resolve({});
77
- }, (err) => {
78
- reject(err);
79
- });
80
- }
81
- }
82
- else {
83
- reject({ message: 'camera already started' });
84
- }
85
- });
86
- }
87
- async stop() {
88
- const video = document.getElementById('video');
89
- if (video) {
90
- video.pause();
91
- const st = video.srcObject;
92
- const tracks = st.getTracks();
93
- for (let i = 0; i < tracks.length; i++) {
94
- const track = tracks[i];
95
- track.stop();
96
- }
97
- video.remove();
98
- }
99
- }
100
- async capture(options) {
101
- return new Promise((resolve, _) => {
102
- const video = document.getElementById('video');
103
- const canvas = document.createElement('canvas');
104
- // video.width = video.offsetWidth;
105
- const context = canvas.getContext('2d');
106
- canvas.width = video.videoWidth;
107
- canvas.height = video.videoHeight;
108
- // flip horizontally back camera isn't used
109
- if (context) {
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
- }
116
- let base64EncodedImage;
117
- if (options.quality != undefined) {
118
- base64EncodedImage = canvas.toDataURL('image/jpeg', options.quality / 100.0).replace('data:image/jpeg;base64,', '');
119
- }
120
- else {
121
- base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
122
- }
123
- resolve({
124
- value: base64EncodedImage,
125
- });
126
- });
127
- }
128
- async captureSample(_options) {
129
- return this.capture(_options);
130
- }
131
- async setZoom(_options) {
132
- throw new Error('set zoom not supported under the web platform');
133
- }
134
- async getSupportedFlashModes() {
135
- throw new Error('getSupportedFlashModes not supported under the web platform');
136
- }
137
- getSupportedZoomLevels() {
138
- throw new Error('getSupportedFlashModes not supported under the web platform.');
139
- }
140
- async setFlashMode(_options) {
141
- throw new Error('setFlashMode not supported under the web platform');
142
- }
143
- async flip() {
144
- throw new Error('flip not supported under the web platform');
145
- }
146
- async setOpacity(_options) {
147
- const video = document.getElementById('video');
148
- if (!!video && !!_options['opacity']) {
149
- video.style.setProperty('opacity', _options['opacity'].toString());
150
- }
151
- }
152
- }
153
- const CameraPreview = new CameraPreviewWeb();
154
- export { CameraPreview };
155
- registerWebPlugin(CameraPreview);
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /* eslint-disable @typescript-eslint/prefer-for-of */
3
+ /* eslint-disable @typescript-eslint/ban-types */
4
+ /* eslint-disable no-async-promise-executor */
5
+ /* eslint-disable @typescript-eslint/consistent-type-assertions */
6
+ /* eslint-disable @typescript-eslint/no-inferrable-types */
7
+ import { WebPlugin, registerWebPlugin } from '@capacitor/core';
8
+ export class CameraPreviewWeb extends WebPlugin {
9
+ constructor() {
10
+ super({
11
+ name: 'CameraPreview',
12
+ platforms: ['web'],
13
+ });
14
+ /**
15
+ * track which camera is used based on start options
16
+ * used in capture
17
+ */
18
+ this.isBackCamera = false;
19
+ }
20
+ async start(options) {
21
+ return new Promise(async (resolve, reject) => {
22
+ var _a;
23
+ await navigator.mediaDevices
24
+ .getUserMedia({
25
+ audio: !options.disableAudio,
26
+ video: true
27
+ })
28
+ .then((stream) => {
29
+ // Stop any existing stream so we can request media with different constraints based on user input
30
+ stream.getTracks().forEach((track) => track.stop());
31
+ })
32
+ .catch((error) => {
33
+ reject(error);
34
+ });
35
+ const video = document.getElementById('video');
36
+ const parent = document.getElementById(options.parent);
37
+ if (!video) {
38
+ const videoElement = document.createElement('video');
39
+ videoElement.id = 'video';
40
+ videoElement.setAttribute('class', options.className || '');
41
+ // Don't flip video feed if camera is rear facing
42
+ if (options.position !== 'rear') {
43
+ videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');
44
+ }
45
+ const userAgent = navigator.userAgent.toLowerCase();
46
+ const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');
47
+ // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful
48
+ // Without these attributes videoElement.play() will throw a NotAllowedError
49
+ // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari
50
+ if (isSafari) {
51
+ videoElement.setAttribute('autoplay', 'true');
52
+ videoElement.setAttribute('muted', 'true');
53
+ videoElement.setAttribute('playsinline', 'true');
54
+ }
55
+ if (parent) {
56
+ parent.appendChild(videoElement);
57
+ }
58
+ if ((_a = navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {
59
+ const constraints = {
60
+ video: {
61
+ width: { ideal: options.width },
62
+ height: { ideal: options.height }
63
+ }
64
+ };
65
+ if (options.position === 'rear') {
66
+ constraints.video.facingMode = 'environment';
67
+ this.isBackCamera = true;
68
+ }
69
+ else {
70
+ this.isBackCamera = false;
71
+ }
72
+ navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {
73
+ //video.src = window.URL.createObjectURL(stream);
74
+ videoElement.srcObject = stream;
75
+ videoElement.play();
76
+ resolve({});
77
+ }, (err) => {
78
+ reject(err);
79
+ });
80
+ }
81
+ }
82
+ else {
83
+ reject({ message: 'camera already started' });
84
+ }
85
+ });
86
+ }
87
+ async stop() {
88
+ const video = document.getElementById('video');
89
+ if (video) {
90
+ video.pause();
91
+ const st = video.srcObject;
92
+ const tracks = st.getTracks();
93
+ for (let i = 0; i < tracks.length; i++) {
94
+ const track = tracks[i];
95
+ track.stop();
96
+ }
97
+ video.remove();
98
+ }
99
+ }
100
+ async capture(options) {
101
+ return new Promise((resolve, _) => {
102
+ const video = document.getElementById('video');
103
+ const canvas = document.createElement('canvas');
104
+ // video.width = video.offsetWidth;
105
+ const context = canvas.getContext('2d');
106
+ canvas.width = video.videoWidth;
107
+ canvas.height = video.videoHeight;
108
+ // flip horizontally back camera isn't used
109
+ if (context) {
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
+ }
116
+ let base64EncodedImage;
117
+ if (options.quality != undefined) {
118
+ base64EncodedImage = canvas.toDataURL('image/jpeg', options.quality / 100.0).replace('data:image/jpeg;base64,', '');
119
+ }
120
+ else {
121
+ base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');
122
+ }
123
+ resolve({
124
+ value: base64EncodedImage,
125
+ });
126
+ });
127
+ }
128
+ async captureSample(_options) {
129
+ return this.capture(_options);
130
+ }
131
+ async setZoom(_options) {
132
+ throw new Error('set zoom not supported under the web platform');
133
+ }
134
+ async getSupportedFlashModes() {
135
+ throw new Error('getSupportedFlashModes not supported under the web platform');
136
+ }
137
+ getSupportedZoomLevels() {
138
+ throw new Error('getSupportedFlashModes not supported under the web platform.');
139
+ }
140
+ async setFlashMode(_options) {
141
+ throw new Error('setFlashMode not supported under the web platform');
142
+ }
143
+ async flip() {
144
+ throw new Error('flip not supported under the web platform');
145
+ }
146
+ async setOpacity(_options) {
147
+ const video = document.getElementById('video');
148
+ if (!!video && !!_options['opacity']) {
149
+ video.style.setProperty('opacity', _options['opacity'].toString());
150
+ }
151
+ }
152
+ }
153
+ const CameraPreview = new CameraPreviewWeb();
154
+ export { CameraPreview };
155
+ registerWebPlugin(CameraPreview);
156
156
  //# sourceMappingURL=web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,qDAAqD;AACrD,iDAAiD;AACjD,8CAA8C;AAC9C,kEAAkE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CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,MAAM,KAAK,GAAqB,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACpC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpE;IACH,CAAC;CACF;AAED,MAAM,aAAa,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,iBAAiB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\r\n/* eslint-disable @typescript-eslint/prefer-for-of */\r\n/* eslint-disable @typescript-eslint/ban-types */\r\n/* eslint-disable no-async-promise-executor */\r\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\r\n/* eslint-disable @typescript-eslint/no-inferrable-types */\r\nimport { WebPlugin, registerWebPlugin } from '@capacitor/core';\r\n\r\nimport type {\r\n CameraPreviewOptions,\r\n CameraPreviewPictureOptions,\r\n CameraPreviewPlugin,\r\n CameraPreviewFlashMode,\r\n CameraSampleOptions,\r\n CameraOpacityOptions,\r\n} from './definitions';\r\n\r\n\r\nexport class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {\r\n /**\r\n * track which camera is used based on start options\r\n * used in capture\r\n */\r\n private isBackCamera: boolean = false;\r\n\r\n constructor() {\r\n super({\r\n name: 'CameraPreview',\r\n platforms: ['web'],\r\n });\r\n }\r\n\r\n async start(options: CameraPreviewOptions): Promise<{}> {\r\n return new Promise(async (resolve, reject) => {\r\n await navigator.mediaDevices\r\n .getUserMedia({\r\n audio: !options.disableAudio,\r\n video: true\r\n })\r\n .then((stream: MediaStream) => {\r\n // Stop any existing stream so we can request media with different constraints based on user input\r\n stream.getTracks().forEach((track) => track.stop());\r\n })\r\n .catch((error) => {\r\n reject(error);\r\n });\r\n\r\n const video = document.getElementById('video');\r\n const parent = document.getElementById(options.parent as string);\r\n\r\n if (!video) {\r\n const videoElement = document.createElement('video');\r\n videoElement.id = 'video';\r\n videoElement.setAttribute('class', options.className || '');\r\n\r\n // Don't flip video feed if camera is rear facing\r\n if (options.position !== 'rear') {\r\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\r\n }\r\n\r\n const userAgent = navigator.userAgent.toLowerCase();\r\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\r\n\r\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\r\n // Without these attributes videoElement.play() will throw a NotAllowedError\r\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\r\n if (isSafari) {\r\n videoElement.setAttribute('autoplay', 'true');\r\n videoElement.setAttribute('muted', 'true');\r\n videoElement.setAttribute('playsinline', 'true');\r\n }\r\n if(parent){\r\n parent.appendChild(videoElement);\r\n }\r\n\r\n if (navigator.mediaDevices?.getUserMedia) {\r\n const constraints: MediaStreamConstraints = {\r\n video: {\r\n width: { ideal: options.width },\r\n height: { ideal: options.height }\r\n }\r\n };\r\n\r\n if (options.position === 'rear') {\r\n (constraints.video as MediaTrackConstraints).facingMode = 'environment';\r\n this.isBackCamera = true;\r\n } else {\r\n this.isBackCamera = false;\r\n }\r\n\r\n navigator.mediaDevices.getUserMedia(constraints).then(\r\n function (stream) {\r\n //video.src = window.URL.createObjectURL(stream);\r\n videoElement.srcObject = stream;\r\n videoElement.play();\r\n resolve({});\r\n },\r\n (err) => {\r\n reject(err);\r\n }\r\n );\r\n }\r\n } else {\r\n reject({ message: 'camera already started' });\r\n }\r\n });\r\n }\r\n\r\n async stop(): Promise<any> {\r\n const video = <HTMLVideoElement>document.getElementById('video');\r\n if (video) {\r\n video.pause();\r\n\r\n const st: any = video.srcObject;\r\n const tracks = st.getTracks();\r\n\r\n for (let i = 0; i < tracks.length; i++) {\r\n const track = tracks[i];\r\n track.stop();\r\n }\r\n video.remove();\r\n }\r\n }\r\n\r\n async capture(options: CameraPreviewPictureOptions): Promise<any> {\r\n return new Promise((resolve, _) => {\r\n const video = <HTMLVideoElement>document.getElementById('video');\r\n const canvas = document.createElement('canvas');\r\n\r\n // video.width = video.offsetWidth;\r\n\r\n const context = canvas.getContext('2d');\r\n canvas.width = video.videoWidth;\r\n canvas.height = video.videoHeight;\r\n\r\n // flip horizontally back camera isn't used\r\n if(context){\r\n if (!this.isBackCamera) {\r\n context.translate(video.videoWidth, 0);\r\n context.scale(-1, 1);\r\n }\r\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\r\n }\r\n\r\n let base64EncodedImage;\r\n\r\n if (options.quality != undefined) {\r\n base64EncodedImage = canvas.toDataURL('image/jpeg', options.quality / 100.0).replace('data:image/jpeg;base64,', '');\r\n } else {\r\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\r\n }\r\n\r\n resolve({\r\n value: base64EncodedImage,\r\n });\r\n });\r\n }\r\n\r\n async captureSample(_options: CameraSampleOptions): Promise<any> {\r\n return this.capture(_options);\r\n }\r\n\r\n async setZoom(_options: CameraPreviewOptions): Promise<void> {\r\n throw new Error('set zoom not supported under the web platform');\r\n }\r\n async getSupportedFlashModes(): Promise<{\r\n result: CameraPreviewFlashMode[];\r\n }> {\r\n throw new Error('getSupportedFlashModes not supported under the web platform');\r\n }\r\n getSupportedZoomLevels(): Promise<{ result: any[]; }> {\r\n throw new Error('getSupportedFlashModes not supported under the web platform.');\r\n }\r\n\r\n async setFlashMode(_options: { flashMode: CameraPreviewFlashMode | string }): Promise<void> {\r\n throw new Error('setFlashMode not supported under the web platform');\r\n }\r\n\r\n async flip(): Promise<void> {\r\n throw new Error('flip not supported under the web platform');\r\n }\r\n\r\n async setOpacity(_options: CameraOpacityOptions): Promise<any> {\r\n const video = <HTMLVideoElement>document.getElementById('video');\r\n if (!!video && !!_options['opacity']) {\r\n video.style.setProperty('opacity', _options['opacity'].toString());\r\n }\r\n }\r\n}\r\n\r\nconst CameraPreview = new CameraPreviewWeb();\r\n\r\nexport { CameraPreview };\r\n\r\nregisterWebPlugin(CameraPreview);"]}
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,qDAAqD;AACrD,iDAAiD;AACjD,8CAA8C;AAC9C,kEAAkE;AAClE,2DAA2D;AAC3D,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAY/D,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;QAVL;;;WAGG;QACK,iBAAY,GAAY,KAAK,CAAC;IAOtC,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA6B;QACvC,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;;YAC3C,MAAM,SAAS,CAAC,YAAY;iBACzB,YAAY,CAAC;gBACZ,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;gBAC5B,KAAK,EAAE,IAAI;aACZ,CAAC;iBACD,IAAI,CAAC,CAAC,MAAmB,EAAE,EAAE;gBAC5B,kGAAkG;gBAClG,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;YACtD,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;gBACf,MAAM,CAAC,KAAK,CAAC,CAAC;YAChB,CAAC,CAAC,CAAC;YAEL,MA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C,QAA6B;QAC/C,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAA8B;QAC1C,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,KAAK,CAAC,sBAAsB;QAG1B,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IACjF,CAAC;IACD,sBAAsB;QACpB,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IAClF,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAwD;QACzE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACvE,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC/D,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA8B;QAC7C,MAAM,KAAK,GAAqB,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC;QACjE,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YACpC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;SACpE;IACH,CAAC;CACF;AAED,MAAM,aAAa,GAAG,IAAI,gBAAgB,EAAE,CAAC;AAE7C,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,iBAAiB,CAAC,aAAa,CAAC,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-unused-vars */\n/* eslint-disable @typescript-eslint/prefer-for-of */\n/* eslint-disable @typescript-eslint/ban-types */\n/* eslint-disable no-async-promise-executor */\n/* eslint-disable @typescript-eslint/consistent-type-assertions */\n/* eslint-disable @typescript-eslint/no-inferrable-types */\nimport { WebPlugin, registerWebPlugin } from '@capacitor/core';\n\nimport type {\n CameraPreviewOptions,\n CameraPreviewPictureOptions,\n CameraPreviewPlugin,\n CameraPreviewFlashMode,\n CameraSampleOptions,\n CameraOpacityOptions,\n} from './definitions';\n\n\nexport class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {\n /**\n * track which camera is used based on start options\n * used in capture\n */\n private isBackCamera: boolean = false;\n\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n\n async start(options: CameraPreviewOptions): Promise<{}> {\n return new Promise(async (resolve, reject) => {\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true\n })\n .then((stream: MediaStream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n reject(error);\n });\n\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent as string);\n\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n if(parent){\n parent.appendChild(videoElement);\n }\n\n if (navigator.mediaDevices?.getUserMedia) {\n const constraints: MediaStreamConstraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height }\n }\n };\n\n if (options.position === 'rear') {\n (constraints.video as MediaTrackConstraints).facingMode = 'environment';\n this.isBackCamera = true;\n } else {\n this.isBackCamera = false;\n }\n\n navigator.mediaDevices.getUserMedia(constraints).then(\n function (stream) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n resolve({});\n },\n (err) => {\n reject(err);\n }\n );\n }\n } else {\n reject({ message: 'camera already started' });\n }\n });\n }\n\n async stop(): Promise<any> {\n const video = <HTMLVideoElement>document.getElementById('video');\n if (video) {\n video.pause();\n\n const st: any = video.srcObject;\n const tracks = st.getTracks();\n\n for (let i = 0; i < tracks.length; i++) {\n const track = tracks[i];\n track.stop();\n }\n video.remove();\n }\n }\n\n async capture(options: CameraPreviewPictureOptions): Promise<any> {\n return new Promise((resolve, _) => {\n const video = <HTMLVideoElement>document.getElementById('video');\n const canvas = document.createElement('canvas');\n\n // video.width = video.offsetWidth;\n\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n\n // flip horizontally back camera isn't used\n if(context){\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n }\n\n let base64EncodedImage;\n\n if (options.quality != undefined) {\n base64EncodedImage = canvas.toDataURL('image/jpeg', options.quality / 100.0).replace('data:image/jpeg;base64,', '');\n } else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n\n async captureSample(_options: CameraSampleOptions): Promise<any> {\n return this.capture(_options);\n }\n\n async setZoom(_options: CameraPreviewOptions): Promise<void> {\n throw new Error('set zoom not supported under the web platform');\n }\n async getSupportedFlashModes(): Promise<{\n result: CameraPreviewFlashMode[];\n }> {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n getSupportedZoomLevels(): Promise<{ result: any[]; }> {\n throw new Error('getSupportedFlashModes not supported under the web platform.');\n }\n\n async setFlashMode(_options: { flashMode: CameraPreviewFlashMode | string }): Promise<void> {\n throw new Error('setFlashMode not supported under the web platform');\n }\n\n async flip(): Promise<void> {\n throw new Error('flip not supported under the web platform');\n }\n\n async setOpacity(_options: CameraOpacityOptions): Promise<any> {\n const video = <HTMLVideoElement>document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n\nconst CameraPreview = new CameraPreviewWeb();\n\nexport { CameraPreview };\n\nregisterWebPlugin(CameraPreview);"]}