@capgo/camera-preview 3.5.0 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -22
- package/android/.gradle/7.4.2/checksums/checksums.lock +0 -0
- package/android/.gradle/7.4.2/checksums/md5-checksums.bin +0 -0
- package/android/.gradle/7.4.2/checksums/sha1-checksums.bin +0 -0
- package/android/.gradle/7.4.2/dependencies-accessors/dependencies-accessors.lock +0 -0
- package/android/.gradle/7.4.2/executionHistory/executionHistory.lock +0 -0
- package/android/.gradle/7.4.2/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +1 -1
- package/dist/docs.json +46 -18
- package/dist/esm/definitions.d.ts +5 -3
- package/dist/esm/web.d.ts +2 -0
- package/dist/esm/web.js +7 -1
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +7 -1
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +7 -1
- package/dist/plugin.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
<
|
|
4
|
-
<br>
|
|
5
|
-
<p align="center"><strong>CAPACITOR 4</strong></p><br>
|
|
1
|
+
# Capacitor Camera Preview Plugin
|
|
2
|
+
|
|
3
|
+
<a href="https://capgo.app/"><img src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/></a>
|
|
6
4
|
|
|
7
|
-
<
|
|
5
|
+
<div align="center">
|
|
6
|
+
<h2><a href="https://capgo.app/">Check out: Capgo — Live updates for capacitor</a></h2>
|
|
7
|
+
</div>
|
|
8
|
+
|
|
9
|
+
<p>
|
|
8
10
|
Capacitor plugin that allows camera interaction from Javascript and HTML<br>(based on cordova-plugin-camera-preview).
|
|
9
11
|
</p>
|
|
10
12
|
<br>
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
This plugin is compatible Capacitor 4 only.
|
|
13
15
|
|
|
14
16
|
**PR's are greatly appreciated.**
|
|
15
17
|
|
|
@@ -265,7 +267,7 @@ const CameraPreviewFlashMode: CameraPreviewFlashMode = 'torch';
|
|
|
265
267
|
CameraPreview.setFlashMode(cameraPreviewFlashMode);
|
|
266
268
|
```
|
|
267
269
|
|
|
268
|
-
### startRecordVideo(options)
|
|
270
|
+
### startRecordVideo(options)
|
|
269
271
|
|
|
270
272
|
<info>Start capturing video</info><br/>
|
|
271
273
|
|
|
@@ -279,7 +281,7 @@ const cameraPreviewOptions: CameraPreviewOptions = {
|
|
|
279
281
|
CameraPreview.startRecordVideo(cameraPreviewOptions);
|
|
280
282
|
```
|
|
281
283
|
|
|
282
|
-
### stopRecordVideo()
|
|
284
|
+
### stopRecordVideo()
|
|
283
285
|
|
|
284
286
|
<info>Finish capturing a video. The captured video will be returned as a file path and the video format is .mp4</info><br/>
|
|
285
287
|
|
|
@@ -460,6 +462,8 @@ To run the demo on your local network and access media devices, a secure context
|
|
|
460
462
|
* [`setFlashMode(...)`](#setflashmode)
|
|
461
463
|
* [`flip()`](#flip)
|
|
462
464
|
* [`setOpacity(...)`](#setopacity)
|
|
465
|
+
* [`stopRecordVideo()`](#stoprecordvideo)
|
|
466
|
+
* [`startRecordVideo(...)`](#startrecordvideo)
|
|
463
467
|
* [Interfaces](#interfaces)
|
|
464
468
|
* [Type Aliases](#type-aliases)
|
|
465
469
|
|
|
@@ -471,36 +475,40 @@ To run the demo on your local network and access media devices, a secure context
|
|
|
471
475
|
### start(...)
|
|
472
476
|
|
|
473
477
|
```typescript
|
|
474
|
-
start(options: CameraPreviewOptions) =>
|
|
478
|
+
start(options: CameraPreviewOptions) => any
|
|
475
479
|
```
|
|
476
480
|
|
|
477
481
|
| Param | Type |
|
|
478
482
|
| ------------- | --------------------------------------------------------------------- |
|
|
479
483
|
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> |
|
|
480
484
|
|
|
485
|
+
**Returns:** <code>any</code>
|
|
486
|
+
|
|
481
487
|
--------------------
|
|
482
488
|
|
|
483
489
|
|
|
484
490
|
### stop()
|
|
485
491
|
|
|
486
492
|
```typescript
|
|
487
|
-
stop() =>
|
|
493
|
+
stop() => any
|
|
488
494
|
```
|
|
489
495
|
|
|
496
|
+
**Returns:** <code>any</code>
|
|
497
|
+
|
|
490
498
|
--------------------
|
|
491
499
|
|
|
492
500
|
|
|
493
501
|
### capture(...)
|
|
494
502
|
|
|
495
503
|
```typescript
|
|
496
|
-
capture(options: CameraPreviewPictureOptions) =>
|
|
504
|
+
capture(options: CameraPreviewPictureOptions) => any
|
|
497
505
|
```
|
|
498
506
|
|
|
499
507
|
| Param | Type |
|
|
500
508
|
| ------------- | ----------------------------------------------------------------------------------- |
|
|
501
509
|
| **`options`** | <code><a href="#camerapreviewpictureoptions">CameraPreviewPictureOptions</a></code> |
|
|
502
510
|
|
|
503
|
-
**Returns:** <code>
|
|
511
|
+
**Returns:** <code>any</code>
|
|
504
512
|
|
|
505
513
|
--------------------
|
|
506
514
|
|
|
@@ -508,14 +516,14 @@ capture(options: CameraPreviewPictureOptions) => Promise<{ value: string; }>
|
|
|
508
516
|
### captureSample(...)
|
|
509
517
|
|
|
510
518
|
```typescript
|
|
511
|
-
captureSample(options: CameraSampleOptions) =>
|
|
519
|
+
captureSample(options: CameraSampleOptions) => any
|
|
512
520
|
```
|
|
513
521
|
|
|
514
522
|
| Param | Type |
|
|
515
523
|
| ------------- | ------------------------------------------------------------------- |
|
|
516
524
|
| **`options`** | <code><a href="#camerasampleoptions">CameraSampleOptions</a></code> |
|
|
517
525
|
|
|
518
|
-
**Returns:** <code>
|
|
526
|
+
**Returns:** <code>any</code>
|
|
519
527
|
|
|
520
528
|
--------------------
|
|
521
529
|
|
|
@@ -523,10 +531,10 @@ captureSample(options: CameraSampleOptions) => Promise<{ value: string; }>
|
|
|
523
531
|
### getSupportedFlashModes()
|
|
524
532
|
|
|
525
533
|
```typescript
|
|
526
|
-
getSupportedFlashModes() =>
|
|
534
|
+
getSupportedFlashModes() => any
|
|
527
535
|
```
|
|
528
536
|
|
|
529
|
-
**Returns:** <code>
|
|
537
|
+
**Returns:** <code>any</code>
|
|
530
538
|
|
|
531
539
|
--------------------
|
|
532
540
|
|
|
@@ -534,10 +542,10 @@ getSupportedFlashModes() => Promise<{ result: CameraPreviewFlashMode[]; }>
|
|
|
534
542
|
### getHorizontalFov()
|
|
535
543
|
|
|
536
544
|
```typescript
|
|
537
|
-
getHorizontalFov() =>
|
|
545
|
+
getHorizontalFov() => any
|
|
538
546
|
```
|
|
539
547
|
|
|
540
|
-
**Returns:** <code>
|
|
548
|
+
**Returns:** <code>any</code>
|
|
541
549
|
|
|
542
550
|
--------------------
|
|
543
551
|
|
|
@@ -545,35 +553,67 @@ getHorizontalFov() => Promise<{ result: any; }>
|
|
|
545
553
|
### setFlashMode(...)
|
|
546
554
|
|
|
547
555
|
```typescript
|
|
548
|
-
setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) =>
|
|
556
|
+
setFlashMode(options: { flashMode: CameraPreviewFlashMode | string; }) => any
|
|
549
557
|
```
|
|
550
558
|
|
|
551
559
|
| Param | Type |
|
|
552
560
|
| ------------- | ----------------------------------- |
|
|
553
561
|
| **`options`** | <code>{ flashMode: string; }</code> |
|
|
554
562
|
|
|
563
|
+
**Returns:** <code>any</code>
|
|
564
|
+
|
|
555
565
|
--------------------
|
|
556
566
|
|
|
557
567
|
|
|
558
568
|
### flip()
|
|
559
569
|
|
|
560
570
|
```typescript
|
|
561
|
-
flip() =>
|
|
571
|
+
flip() => any
|
|
562
572
|
```
|
|
563
573
|
|
|
574
|
+
**Returns:** <code>any</code>
|
|
575
|
+
|
|
564
576
|
--------------------
|
|
565
577
|
|
|
566
578
|
|
|
567
579
|
### setOpacity(...)
|
|
568
580
|
|
|
569
581
|
```typescript
|
|
570
|
-
setOpacity(options: CameraOpacityOptions) =>
|
|
582
|
+
setOpacity(options: CameraOpacityOptions) => any
|
|
571
583
|
```
|
|
572
584
|
|
|
573
585
|
| Param | Type |
|
|
574
586
|
| ------------- | --------------------------------------------------------------------- |
|
|
575
587
|
| **`options`** | <code><a href="#cameraopacityoptions">CameraOpacityOptions</a></code> |
|
|
576
588
|
|
|
589
|
+
**Returns:** <code>any</code>
|
|
590
|
+
|
|
591
|
+
--------------------
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
### stopRecordVideo()
|
|
595
|
+
|
|
596
|
+
```typescript
|
|
597
|
+
stopRecordVideo() => any
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
**Returns:** <code>any</code>
|
|
601
|
+
|
|
602
|
+
--------------------
|
|
603
|
+
|
|
604
|
+
|
|
605
|
+
### startRecordVideo(...)
|
|
606
|
+
|
|
607
|
+
```typescript
|
|
608
|
+
startRecordVideo(options: CameraPreviewOptions) => any
|
|
609
|
+
```
|
|
610
|
+
|
|
611
|
+
| Param | Type |
|
|
612
|
+
| ------------- | --------------------------------------------------------------------- |
|
|
613
|
+
| **`options`** | <code><a href="#camerapreviewoptions">CameraPreviewOptions</a></code> |
|
|
614
|
+
|
|
615
|
+
**Returns:** <code>any</code>
|
|
616
|
+
|
|
577
617
|
--------------------
|
|
578
618
|
|
|
579
619
|
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#
|
|
1
|
+
#Wed Jan 04 12:49:07 UTC 2023
|
|
2
2
|
gradle.version=7.4.2
|
package/dist/docs.json
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
"methods": [
|
|
8
8
|
{
|
|
9
9
|
"name": "start",
|
|
10
|
-
"signature": "(options: CameraPreviewOptions) =>
|
|
10
|
+
"signature": "(options: CameraPreviewOptions) => any",
|
|
11
11
|
"parameters": [
|
|
12
12
|
{
|
|
13
13
|
"name": "options",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"type": "CameraPreviewOptions"
|
|
16
16
|
}
|
|
17
17
|
],
|
|
18
|
-
"returns": "
|
|
18
|
+
"returns": "any",
|
|
19
19
|
"tags": [],
|
|
20
20
|
"docs": "",
|
|
21
21
|
"complexTypes": [
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
27
|
"name": "stop",
|
|
28
|
-
"signature": "() =>
|
|
28
|
+
"signature": "() => any",
|
|
29
29
|
"parameters": [],
|
|
30
|
-
"returns": "
|
|
30
|
+
"returns": "any",
|
|
31
31
|
"tags": [],
|
|
32
32
|
"docs": "",
|
|
33
33
|
"complexTypes": [],
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
{
|
|
37
37
|
"name": "capture",
|
|
38
|
-
"signature": "(options: CameraPreviewPictureOptions) =>
|
|
38
|
+
"signature": "(options: CameraPreviewPictureOptions) => any",
|
|
39
39
|
"parameters": [
|
|
40
40
|
{
|
|
41
41
|
"name": "options",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"type": "CameraPreviewPictureOptions"
|
|
44
44
|
}
|
|
45
45
|
],
|
|
46
|
-
"returns": "
|
|
46
|
+
"returns": "any",
|
|
47
47
|
"tags": [],
|
|
48
48
|
"docs": "",
|
|
49
49
|
"complexTypes": [
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
55
|
"name": "captureSample",
|
|
56
|
-
"signature": "(options: CameraSampleOptions) =>
|
|
56
|
+
"signature": "(options: CameraSampleOptions) => any",
|
|
57
57
|
"parameters": [
|
|
58
58
|
{
|
|
59
59
|
"name": "options",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"type": "CameraSampleOptions"
|
|
62
62
|
}
|
|
63
63
|
],
|
|
64
|
-
"returns": "
|
|
64
|
+
"returns": "any",
|
|
65
65
|
"tags": [],
|
|
66
66
|
"docs": "",
|
|
67
67
|
"complexTypes": [
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
},
|
|
72
72
|
{
|
|
73
73
|
"name": "getSupportedFlashModes",
|
|
74
|
-
"signature": "() =>
|
|
74
|
+
"signature": "() => any",
|
|
75
75
|
"parameters": [],
|
|
76
|
-
"returns": "
|
|
76
|
+
"returns": "any",
|
|
77
77
|
"tags": [],
|
|
78
78
|
"docs": "",
|
|
79
79
|
"complexTypes": [
|
|
@@ -83,9 +83,9 @@
|
|
|
83
83
|
},
|
|
84
84
|
{
|
|
85
85
|
"name": "getHorizontalFov",
|
|
86
|
-
"signature": "() =>
|
|
86
|
+
"signature": "() => any",
|
|
87
87
|
"parameters": [],
|
|
88
|
-
"returns": "
|
|
88
|
+
"returns": "any",
|
|
89
89
|
"tags": [],
|
|
90
90
|
"docs": "",
|
|
91
91
|
"complexTypes": [],
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
"name": "setFlashMode",
|
|
96
|
-
"signature": "(options: { flashMode: CameraPreviewFlashMode | string; }) =>
|
|
96
|
+
"signature": "(options: { flashMode: CameraPreviewFlashMode | string; }) => any",
|
|
97
97
|
"parameters": [
|
|
98
98
|
{
|
|
99
99
|
"name": "options",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"type": "{ flashMode: string; }"
|
|
102
102
|
}
|
|
103
103
|
],
|
|
104
|
-
"returns": "
|
|
104
|
+
"returns": "any",
|
|
105
105
|
"tags": [],
|
|
106
106
|
"docs": "",
|
|
107
107
|
"complexTypes": [
|
|
@@ -111,9 +111,9 @@
|
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
"name": "flip",
|
|
114
|
-
"signature": "() =>
|
|
114
|
+
"signature": "() => any",
|
|
115
115
|
"parameters": [],
|
|
116
|
-
"returns": "
|
|
116
|
+
"returns": "any",
|
|
117
117
|
"tags": [],
|
|
118
118
|
"docs": "",
|
|
119
119
|
"complexTypes": [],
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
"name": "setOpacity",
|
|
124
|
-
"signature": "(options: CameraOpacityOptions) =>
|
|
124
|
+
"signature": "(options: CameraOpacityOptions) => any",
|
|
125
125
|
"parameters": [
|
|
126
126
|
{
|
|
127
127
|
"name": "options",
|
|
@@ -129,13 +129,41 @@
|
|
|
129
129
|
"type": "CameraOpacityOptions"
|
|
130
130
|
}
|
|
131
131
|
],
|
|
132
|
-
"returns": "
|
|
132
|
+
"returns": "any",
|
|
133
133
|
"tags": [],
|
|
134
134
|
"docs": "",
|
|
135
135
|
"complexTypes": [
|
|
136
136
|
"CameraOpacityOptions"
|
|
137
137
|
],
|
|
138
138
|
"slug": "setopacity"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
"name": "stopRecordVideo",
|
|
142
|
+
"signature": "() => any",
|
|
143
|
+
"parameters": [],
|
|
144
|
+
"returns": "any",
|
|
145
|
+
"tags": [],
|
|
146
|
+
"docs": "",
|
|
147
|
+
"complexTypes": [],
|
|
148
|
+
"slug": "stoprecordvideo"
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
"name": "startRecordVideo",
|
|
152
|
+
"signature": "(options: CameraPreviewOptions) => any",
|
|
153
|
+
"parameters": [
|
|
154
|
+
{
|
|
155
|
+
"name": "options",
|
|
156
|
+
"docs": "",
|
|
157
|
+
"type": "CameraPreviewOptions"
|
|
158
|
+
}
|
|
159
|
+
],
|
|
160
|
+
"returns": "any",
|
|
161
|
+
"tags": [],
|
|
162
|
+
"docs": "",
|
|
163
|
+
"complexTypes": [
|
|
164
|
+
"CameraPreviewOptions"
|
|
165
|
+
],
|
|
166
|
+
"slug": "startrecordvideo"
|
|
139
167
|
}
|
|
140
168
|
],
|
|
141
169
|
"properties": []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type CameraPosition = 'rear' | 'front';
|
|
2
2
|
export interface CameraPreviewOptions {
|
|
3
3
|
/** Parent element to attach the video preview element to (applicable to the web platform only) */
|
|
4
4
|
parent?: string;
|
|
@@ -47,12 +47,12 @@ export interface CameraPreviewPictureOptions {
|
|
|
47
47
|
* quality has no effect on png */
|
|
48
48
|
format?: PictureFormat;
|
|
49
49
|
}
|
|
50
|
-
export
|
|
50
|
+
export type PictureFormat = 'jpeg' | 'png';
|
|
51
51
|
export interface CameraSampleOptions {
|
|
52
52
|
/** The picture quality, 0 - 100, default 85 */
|
|
53
53
|
quality?: number;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
55
|
+
export type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'red-eye' | 'torch';
|
|
56
56
|
export interface CameraOpacityOptions {
|
|
57
57
|
/** The percent opacity to set for camera view, default 1 */
|
|
58
58
|
opacity?: number;
|
|
@@ -77,4 +77,6 @@ export interface CameraPreviewPlugin {
|
|
|
77
77
|
}): Promise<void>;
|
|
78
78
|
flip(): Promise<void>;
|
|
79
79
|
setOpacity(options: CameraOpacityOptions): Promise<void>;
|
|
80
|
+
stopRecordVideo(): Promise<void>;
|
|
81
|
+
startRecordVideo(options: CameraPreviewOptions): Promise<void>;
|
|
80
82
|
}
|
package/dist/esm/web.d.ts
CHANGED
|
@@ -12,6 +12,8 @@ export declare class CameraPreviewWeb extends WebPlugin implements CameraPreview
|
|
|
12
12
|
stop(): Promise<any>;
|
|
13
13
|
capture(options: CameraPreviewPictureOptions): Promise<any>;
|
|
14
14
|
captureSample(_options: CameraSampleOptions): Promise<any>;
|
|
15
|
+
stopRecordVideo(): Promise<any>;
|
|
16
|
+
startRecordVideo(_options: CameraPreviewOptions): Promise<any>;
|
|
15
17
|
getSupportedFlashModes(): Promise<{
|
|
16
18
|
result: CameraPreviewFlashMode[];
|
|
17
19
|
}>;
|
package/dist/esm/web.js
CHANGED
|
@@ -95,7 +95,7 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
95
95
|
async capture(options) {
|
|
96
96
|
return new Promise((resolve, reject) => {
|
|
97
97
|
const video = document.getElementById('video');
|
|
98
|
-
if (!video ||
|
|
98
|
+
if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {
|
|
99
99
|
reject({ message: 'camera is not running' });
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
@@ -129,6 +129,12 @@ export class CameraPreviewWeb extends WebPlugin {
|
|
|
129
129
|
async captureSample(_options) {
|
|
130
130
|
return this.capture(_options);
|
|
131
131
|
}
|
|
132
|
+
async stopRecordVideo() {
|
|
133
|
+
throw new Error('stopRecordVideo not supported under the web platform');
|
|
134
|
+
}
|
|
135
|
+
async startRecordVideo(_options) {
|
|
136
|
+
throw new Error('startRecordVideo not supported under the web platform');
|
|
137
|
+
}
|
|
132
138
|
async getSupportedFlashModes() {
|
|
133
139
|
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
134
140
|
}
|
package/dist/esm/web.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAW5C,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAO7C;QACE,KAAK,CAAC;YACJ,IAAI,EAAE,eAAe;YACrB,SAAS,EAAE,CAAC,KAAK,CAAC;SACnB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAA6B;;QACvC,MAAM,SAAS,CAAC,YAAY;aACzB,YAAY,CAAC;YACZ,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;YAC5B,KAAK,EAAE,IAAI;SACZ,CAAC;aACD,IAAI,CAAC,CAAC,MAAmB,EAAE,EAAE;YAC5B,kGAAkG;YAClG,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;QACtD,CAAC,CAAC;aACD,KAAK,C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AAC,OAAO,CAAqB,CAAC;QACnE,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"}
|
package/dist/plugin.cjs.js
CHANGED
|
@@ -102,7 +102,7 @@ class CameraPreviewWeb extends core.WebPlugin {
|
|
|
102
102
|
async capture(options) {
|
|
103
103
|
return new Promise((resolve, reject) => {
|
|
104
104
|
const video = document.getElementById('video');
|
|
105
|
-
if (!video ||
|
|
105
|
+
if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {
|
|
106
106
|
reject({ message: 'camera is not running' });
|
|
107
107
|
return;
|
|
108
108
|
}
|
|
@@ -136,6 +136,12 @@ class CameraPreviewWeb extends core.WebPlugin {
|
|
|
136
136
|
async captureSample(_options) {
|
|
137
137
|
return this.capture(_options);
|
|
138
138
|
}
|
|
139
|
+
async stopRecordVideo() {
|
|
140
|
+
throw new Error('stopRecordVideo not supported under the web platform');
|
|
141
|
+
}
|
|
142
|
+
async startRecordVideo(_options) {
|
|
143
|
+
throw new Error('startRecordVideo not supported under the web platform');
|
|
144
|
+
}
|
|
139
145
|
async getSupportedFlashModes() {
|
|
140
146
|
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
141
147
|
}
|
package/dist/plugin.cjs.js.map
CHANGED
|
@@ -1 +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 var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById('video')) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: 'camera already stopped' });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: 'camera already started' });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!video || !video.srcObject) {\n reject({ message: 'camera is not running' });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform' + _options);\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,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;;ACF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,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;;;;;;;;;"}
|
|
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 var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById('video')) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: 'camera already stopped' });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: 'camera already started' });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject({ message: 'camera is not running' });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error('stopRecordVideo not supported under the web platform');\n }\n async startRecordVideo(_options) {\n throw new Error('startRecordVideo not supported under the web platform');\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform' + _options);\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,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,IAAI,EAAE,CAAC;AACf,QAAQ,MAAM,SAAS,CAAC,YAAY;AACpC,aAAa,YAAY,CAAC;AAC1B,YAAY,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;AACxC,YAAY,KAAK,EAAE,IAAI;AACvB,SAAS,CAAC;AACV,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK;AAC9B;AACA,YAAY,MAAM,CAAC,SAAS,EAAE,CAAC,OA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AC,CAAC,QAAQ,EAAE,CAAC,CAAC;AAC/E,SAAS;AACT,KAAK;AACL;;;;;;;;;"}
|
package/dist/plugin.js
CHANGED
|
@@ -101,7 +101,7 @@ var capacitorApp = (function (exports, core) {
|
|
|
101
101
|
async capture(options) {
|
|
102
102
|
return new Promise((resolve, reject) => {
|
|
103
103
|
const video = document.getElementById('video');
|
|
104
|
-
if (!video ||
|
|
104
|
+
if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {
|
|
105
105
|
reject({ message: 'camera is not running' });
|
|
106
106
|
return;
|
|
107
107
|
}
|
|
@@ -135,6 +135,12 @@ var capacitorApp = (function (exports, core) {
|
|
|
135
135
|
async captureSample(_options) {
|
|
136
136
|
return this.capture(_options);
|
|
137
137
|
}
|
|
138
|
+
async stopRecordVideo() {
|
|
139
|
+
throw new Error('stopRecordVideo not supported under the web platform');
|
|
140
|
+
}
|
|
141
|
+
async startRecordVideo(_options) {
|
|
142
|
+
throw new Error('startRecordVideo not supported under the web platform');
|
|
143
|
+
}
|
|
138
144
|
async getSupportedFlashModes() {
|
|
139
145
|
throw new Error('getSupportedFlashModes not supported under the web platform');
|
|
140
146
|
}
|
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById('video')) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: 'camera already stopped' });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: 'camera already started' });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!video || !video.srcObject) {\n reject({ message: 'camera is not running' });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform' + _options);\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC;IACd,YAAY,IAAI,EAAE,eAAe;IACjC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAA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AAC,WAAW,CAAC,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC/E,SAAS;IACT,KAAK;IACL;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst CameraPreview = registerPlugin('CameraPreview', {\n web: () => import('./web').then((m) => new m.CameraPreviewWeb()),\n});\nexport * from './definitions';\nexport { CameraPreview };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CameraPreviewWeb extends WebPlugin {\n constructor() {\n super({\n name: 'CameraPreview',\n platforms: ['web'],\n });\n }\n async start(options) {\n var _a;\n await navigator.mediaDevices\n .getUserMedia({\n audio: !options.disableAudio,\n video: true,\n })\n .then((stream) => {\n // Stop any existing stream so we can request media with different constraints based on user input\n stream.getTracks().forEach((track) => track.stop());\n })\n .catch((error) => {\n Promise.reject(error);\n });\n const video = document.getElementById('video');\n const parent = document.getElementById(options.parent);\n if (!video) {\n const videoElement = document.createElement('video');\n videoElement.id = 'video';\n videoElement.setAttribute('class', options.className || '');\n // Don't flip video feed if camera is rear facing\n if (options.position !== 'rear') {\n videoElement.setAttribute('style', '-webkit-transform: scaleX(-1); transform: scaleX(-1);');\n }\n const userAgent = navigator.userAgent.toLowerCase();\n const isSafari = userAgent.includes('safari') && !userAgent.includes('chrome');\n // Safari on iOS needs to have the autoplay, muted and playsinline attributes set for video.play() to be successful\n // Without these attributes videoElement.play() will throw a NotAllowedError\n // https://developer.apple.com/documentation/webkit/delivering_video_content_for_safari\n if (isSafari) {\n videoElement.setAttribute('autoplay', 'true');\n videoElement.setAttribute('muted', 'true');\n videoElement.setAttribute('playsinline', 'true');\n }\n parent.appendChild(videoElement);\n if ((_a = navigator === null || navigator === void 0 ? void 0 : navigator.mediaDevices) === null || _a === void 0 ? void 0 : _a.getUserMedia) {\n const constraints = {\n video: {\n width: { ideal: options.width },\n height: { ideal: options.height },\n },\n };\n if (options.position === 'rear') {\n constraints.video.facingMode = 'environment';\n this.isBackCamera = true;\n }\n else {\n this.isBackCamera = false;\n }\n const self = this;\n await navigator.mediaDevices.getUserMedia(constraints).then(function (stream) {\n if (document.getElementById('video')) {\n //video.src = window.URL.createObjectURL(stream);\n videoElement.srcObject = stream;\n videoElement.play();\n Promise.resolve({});\n }\n else {\n self.stopStream(stream);\n Promise.reject({ message: 'camera already stopped' });\n }\n }, (err) => {\n Promise.reject(err);\n });\n }\n }\n else {\n Promise.reject({ message: 'camera already started' });\n }\n }\n stopStream(stream) {\n if (stream) {\n const tracks = stream.getTracks();\n for (const track of tracks) {\n track.stop();\n }\n }\n }\n async stop() {\n const video = document.getElementById('video');\n if (video) {\n video.pause();\n this.stopStream(video.srcObject);\n video.remove();\n }\n }\n async capture(options) {\n return new Promise((resolve, reject) => {\n const video = document.getElementById('video');\n if (!(video === null || video === void 0 ? void 0 : video.srcObject)) {\n reject({ message: 'camera is not running' });\n return;\n }\n // video.width = video.offsetWidth;\n let base64EncodedImage;\n if (video && video.videoWidth > 0 && video.videoHeight > 0) {\n const canvas = document.createElement('canvas');\n const context = canvas.getContext('2d');\n canvas.width = video.videoWidth;\n canvas.height = video.videoHeight;\n // flip horizontally back camera isn't used\n if (!this.isBackCamera) {\n context.translate(video.videoWidth, 0);\n context.scale(-1, 1);\n }\n context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight);\n if ((options.format || 'jpeg') === 'jpeg') {\n base64EncodedImage = canvas\n .toDataURL('image/jpeg', (options.quality || 85) / 100.0)\n .replace('data:image/jpeg;base64,', '');\n }\n else {\n base64EncodedImage = canvas.toDataURL('image/png').replace('data:image/png;base64,', '');\n }\n }\n resolve({\n value: base64EncodedImage,\n });\n });\n }\n async captureSample(_options) {\n return this.capture(_options);\n }\n async stopRecordVideo() {\n throw new Error('stopRecordVideo not supported under the web platform');\n }\n async startRecordVideo(_options) {\n throw new Error('startRecordVideo not supported under the web platform');\n }\n async getSupportedFlashModes() {\n throw new Error('getSupportedFlashModes not supported under the web platform');\n }\n async getHorizontalFov() {\n throw new Error('getHorizontalFov not supported under the web platform');\n }\n async setFlashMode(_options) {\n throw new Error('setFlashMode not supported under the web platform' + _options);\n }\n async flip() {\n throw new Error('flip not supported under the web platform');\n }\n async setOpacity(_options) {\n const video = document.getElementById('video');\n if (!!video && !!_options['opacity']) {\n video.style.setProperty('opacity', _options['opacity'].toString());\n }\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,aAAa,GAAGA,mBAAc,CAAC,eAAe,EAAE;IACtD,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,gBAAgB,EAAE,CAAC;IACpE,CAAC;;ICFM,MAAM,gBAAgB,SAASC,cAAS,CAAC;IAChD,IAAI,WAAW,GAAG;IAClB,QAAQ,KAAK,CAAC;IACd,YAAY,IAAI,EAAE,eAAe;IACjC,YAAY,SAAS,EAAE,CAAC,KAAK,CAAC;IAC9B,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,KAAK,CAAC,OAAO,EAAE;IACzB,QAAQ,IAAI,EAAE,CAAC;IACf,QAAQ,MAAM,SAAS,CAAC,YAAY;IACpC,aAAa,YAAY,CAAC;IAC1B,YAAY,KAAK,EAAE,CAAC,OAAO,CAAC,YAAY;IACxC,YAAY,KAAK,EAAE,IAAI;IACvB,SAAS,CAAC;IACV,aAAa,IAAI,CAAC,CAAC,MAAM,KAAK;IAC9B;IACA,YAAY,MAAM,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,SAAS,CAAC;IACV,aAAa,KAAK,CAAC,CAAC,KAAK,KAAK;IAC9B,YAAY,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAClC,SAA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