@capgo/camera-preview 3.6.23 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +67 -405
  2. package/android/build.gradle +8 -7
  3. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  4. package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  5. package/android/gradle.properties +1 -1
  6. package/android/gradlew +2 -2
  7. package/android/src/androidTest/java/com/getcapacitor/android/ExampleInstrumentedTest.java +6 -6
  8. package/android/src/main/AndroidManifest.xml +1 -1
  9. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraActivity.java +1105 -854
  10. package/android/src/main/java/com/ahm/capacitor/camera/preview/CameraPreview.java +543 -428
  11. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomSurfaceView.java +15 -10
  12. package/android/src/main/java/com/ahm/capacitor/camera/preview/CustomTextureView.java +31 -21
  13. package/android/src/main/java/com/ahm/capacitor/camera/preview/Preview.java +386 -332
  14. package/android/src/main/java/com/ahm/capacitor/camera/preview/TapGestureDetector.java +13 -13
  15. package/android/src/test/java/com/getcapacitor/ExampleUnitTest.java +4 -4
  16. package/dist/docs.json +208 -37
  17. package/dist/esm/definitions.d.ts +76 -3
  18. package/dist/esm/index.d.ts +2 -2
  19. package/dist/esm/index.js +4 -4
  20. package/dist/esm/web.d.ts +2 -2
  21. package/dist/esm/web.js +39 -36
  22. package/dist/esm/web.js.map +1 -1
  23. package/dist/plugin.cjs.js +39 -36
  24. package/dist/plugin.cjs.js.map +1 -1
  25. package/dist/plugin.js +39 -36
  26. package/dist/plugin.js.map +1 -1
  27. package/ios/Plugin/CameraController.swift +1 -1
  28. package/ios/Plugin/Plugin.swift +1 -1
  29. package/ios/Podfile.lock +3 -3
  30. package/package.json +22 -22
  31. package/android/.gradle/7.6/checksums/checksums.lock +0 -0
  32. package/android/.gradle/7.6/checksums/md5-checksums.bin +0 -0
  33. package/android/.gradle/7.6/checksums/sha1-checksums.bin +0 -0
  34. package/android/.gradle/7.6/dependencies-accessors/dependencies-accessors.lock +0 -0
  35. package/android/.gradle/7.6/dependencies-accessors/gc.properties +0 -0
  36. package/android/.gradle/7.6/executionHistory/executionHistory.lock +0 -0
  37. package/android/.gradle/7.6/fileChanges/last-build.bin +0 -0
  38. package/android/.gradle/7.6/fileHashes/fileHashes.lock +0 -0
  39. package/android/.gradle/7.6/gc.properties +0 -0
  40. package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  41. package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
  42. package/android/.gradle/vcs-1/gc.properties +0 -0
@@ -5,20 +5,20 @@ import android.view.MotionEvent;
5
5
 
6
6
  class TapGestureDetector extends GestureDetector.SimpleOnGestureListener {
7
7
 
8
- private final String TAG = "TapGestureDetector";
8
+ private final String TAG = "TapGestureDetector";
9
9
 
10
- @Override
11
- public boolean onDown(MotionEvent e) {
12
- return false;
13
- }
10
+ @Override
11
+ public boolean onDown(MotionEvent e) {
12
+ return false;
13
+ }
14
14
 
15
- @Override
16
- public boolean onSingleTapUp(MotionEvent e) {
17
- return true;
18
- }
15
+ @Override
16
+ public boolean onSingleTapUp(MotionEvent e) {
17
+ return true;
18
+ }
19
19
 
20
- @Override
21
- public boolean onSingleTapConfirmed(MotionEvent e) {
22
- return true;
23
- }
20
+ @Override
21
+ public boolean onSingleTapConfirmed(MotionEvent e) {
22
+ return true;
23
+ }
24
24
  }
@@ -11,8 +11,8 @@ import org.junit.Test;
11
11
  */
12
12
  public class ExampleUnitTest {
13
13
 
14
- @Test
15
- public void addition_isCorrect() throws Exception {
16
- assertEquals(4, 2 + 2);
17
- }
14
+ @Test
15
+ public void addition_isCorrect() throws Exception {
16
+ assertEquals(4, 2 + 2);
17
+ }
18
18
  }
package/dist/docs.json CHANGED
@@ -11,13 +11,30 @@
11
11
  "parameters": [
12
12
  {
13
13
  "name": "options",
14
- "docs": "",
14
+ "docs": "the options to start the camera preview with",
15
15
  "type": "CameraPreviewOptions"
16
16
  }
17
17
  ],
18
18
  "returns": "any",
19
- "tags": [],
20
- "docs": "",
19
+ "tags": [
20
+ {
21
+ "name": "param",
22
+ "text": "options the options to start the camera preview with"
23
+ },
24
+ {
25
+ "name": "returns",
26
+ "text": "an Promise that resolves when the instance is started"
27
+ },
28
+ {
29
+ "name": "throws",
30
+ "text": "An error if the something went wrong"
31
+ },
32
+ {
33
+ "name": "since",
34
+ "text": "0.0.1"
35
+ }
36
+ ],
37
+ "docs": "Start the camera preview instance.",
21
38
  "complexTypes": [
22
39
  "CameraPreviewOptions"
23
40
  ],
@@ -28,8 +45,21 @@
28
45
  "signature": "() => any",
29
46
  "parameters": [],
30
47
  "returns": "any",
31
- "tags": [],
32
- "docs": "",
48
+ "tags": [
49
+ {
50
+ "name": "returns",
51
+ "text": "an Promise that resolves when the instance is stopped"
52
+ },
53
+ {
54
+ "name": "throws",
55
+ "text": "An error if the something went wrong"
56
+ },
57
+ {
58
+ "name": "since",
59
+ "text": "0.0.1"
60
+ }
61
+ ],
62
+ "docs": "Stop the camera preview instance.",
33
63
  "complexTypes": [],
34
64
  "slug": "stop"
35
65
  },
@@ -39,13 +69,30 @@
39
69
  "parameters": [
40
70
  {
41
71
  "name": "options",
42
- "docs": "",
72
+ "docs": "the options to switch the camera with",
43
73
  "type": "CameraPreviewPictureOptions"
44
74
  }
45
75
  ],
46
76
  "returns": "any",
47
- "tags": [],
48
- "docs": "",
77
+ "tags": [
78
+ {
79
+ "name": "param",
80
+ "text": "options the options to switch the camera with"
81
+ },
82
+ {
83
+ "name": "returns",
84
+ "text": "an Promise that resolves when the camera is switched"
85
+ },
86
+ {
87
+ "name": "throws",
88
+ "text": "An error if the something went wrong"
89
+ },
90
+ {
91
+ "name": "since",
92
+ "text": "0.0.1"
93
+ }
94
+ ],
95
+ "docs": "Switch camera.",
49
96
  "complexTypes": [
50
97
  "CameraPreviewPictureOptions"
51
98
  ],
@@ -57,13 +104,30 @@
57
104
  "parameters": [
58
105
  {
59
106
  "name": "options",
60
- "docs": "",
107
+ "docs": "the options to capture the sample image with",
61
108
  "type": "CameraSampleOptions"
62
109
  }
63
110
  ],
64
111
  "returns": "any",
65
- "tags": [],
66
- "docs": "",
112
+ "tags": [
113
+ {
114
+ "name": "param",
115
+ "text": "options the options to capture the sample image with"
116
+ },
117
+ {
118
+ "name": "returns",
119
+ "text": "an Promise that resolves with the sample image as a base64 encoded string"
120
+ },
121
+ {
122
+ "name": "throws",
123
+ "text": "An error if the something went wrong"
124
+ },
125
+ {
126
+ "name": "since",
127
+ "text": "0.0.1"
128
+ }
129
+ ],
130
+ "docs": "Capture a sample image.",
67
131
  "complexTypes": [
68
132
  "CameraSampleOptions"
69
133
  ],
@@ -74,8 +138,21 @@
74
138
  "signature": "() => any",
75
139
  "parameters": [],
76
140
  "returns": "any",
77
- "tags": [],
78
- "docs": "",
141
+ "tags": [
142
+ {
143
+ "name": "returns",
144
+ "text": "an Promise that resolves with the supported flash modes"
145
+ },
146
+ {
147
+ "name": "throws",
148
+ "text": "An error if the something went wrong"
149
+ },
150
+ {
151
+ "name": "since",
152
+ "text": "0.0.1"
153
+ }
154
+ ],
155
+ "docs": "Get supported flash modes.",
79
156
  "complexTypes": [
80
157
  "CameraPreviewFlashMode"
81
158
  ],
@@ -86,8 +163,21 @@
86
163
  "signature": "() => any",
87
164
  "parameters": [],
88
165
  "returns": "any",
89
- "tags": [],
90
- "docs": "",
166
+ "tags": [
167
+ {
168
+ "name": "returns",
169
+ "text": "an Promise that resolves with the horizontal field of view"
170
+ },
171
+ {
172
+ "name": "throws",
173
+ "text": "An error if the something went wrong"
174
+ },
175
+ {
176
+ "name": "since",
177
+ "text": "0.0.1"
178
+ }
179
+ ],
180
+ "docs": "Get horizontal field of view.",
91
181
  "complexTypes": [],
92
182
  "slug": "gethorizontalfov"
93
183
  },
@@ -97,13 +187,30 @@
97
187
  "parameters": [
98
188
  {
99
189
  "name": "options",
100
- "docs": "",
190
+ "docs": "the options to set the flash mode with",
101
191
  "type": "{ flashMode: string; }"
102
192
  }
103
193
  ],
104
194
  "returns": "any",
105
- "tags": [],
106
- "docs": "",
195
+ "tags": [
196
+ {
197
+ "name": "param",
198
+ "text": "options the options to set the flash mode with"
199
+ },
200
+ {
201
+ "name": "returns",
202
+ "text": "an Promise that resolves when the flash mode is set"
203
+ },
204
+ {
205
+ "name": "throws",
206
+ "text": "An error if the something went wrong"
207
+ },
208
+ {
209
+ "name": "since",
210
+ "text": "0.0.1"
211
+ }
212
+ ],
213
+ "docs": "Set flash mode.",
107
214
  "complexTypes": [
108
215
  "CameraPreviewFlashMode"
109
216
  ],
@@ -114,8 +221,21 @@
114
221
  "signature": "() => any",
115
222
  "parameters": [],
116
223
  "returns": "any",
117
- "tags": [],
118
- "docs": "",
224
+ "tags": [
225
+ {
226
+ "name": "returns",
227
+ "text": "an Promise that resolves when the camera is flipped"
228
+ },
229
+ {
230
+ "name": "throws",
231
+ "text": "An error if the something went wrong"
232
+ },
233
+ {
234
+ "name": "since",
235
+ "text": "0.0.1"
236
+ }
237
+ ],
238
+ "docs": "Flip camera.",
119
239
  "complexTypes": [],
120
240
  "slug": "flip"
121
241
  },
@@ -125,13 +245,30 @@
125
245
  "parameters": [
126
246
  {
127
247
  "name": "options",
128
- "docs": "",
248
+ "docs": "the options to set the camera opacity with",
129
249
  "type": "CameraOpacityOptions"
130
250
  }
131
251
  ],
132
252
  "returns": "any",
133
- "tags": [],
134
- "docs": "",
253
+ "tags": [
254
+ {
255
+ "name": "param",
256
+ "text": "options the options to set the camera opacity with"
257
+ },
258
+ {
259
+ "name": "returns",
260
+ "text": "an Promise that resolves when the camera color effect is set"
261
+ },
262
+ {
263
+ "name": "throws",
264
+ "text": "An error if the something went wrong"
265
+ },
266
+ {
267
+ "name": "since",
268
+ "text": "0.0.1"
269
+ }
270
+ ],
271
+ "docs": "Set opacity.",
135
272
  "complexTypes": [
136
273
  "CameraOpacityOptions"
137
274
  ],
@@ -142,8 +279,25 @@
142
279
  "signature": "() => any",
143
280
  "parameters": [],
144
281
  "returns": "any",
145
- "tags": [],
146
- "docs": "",
282
+ "tags": [
283
+ {
284
+ "name": "param",
285
+ "text": "options the options to stop recording video with"
286
+ },
287
+ {
288
+ "name": "returns",
289
+ "text": "an Promise that resolves when the camera zoom is set"
290
+ },
291
+ {
292
+ "name": "throws",
293
+ "text": "An error if the something went wrong"
294
+ },
295
+ {
296
+ "name": "since",
297
+ "text": "0.0.1"
298
+ }
299
+ ],
300
+ "docs": "Stop recording video.",
147
301
  "complexTypes": [],
148
302
  "slug": "stoprecordvideo"
149
303
  },
@@ -153,13 +307,30 @@
153
307
  "parameters": [
154
308
  {
155
309
  "name": "options",
156
- "docs": "",
310
+ "docs": "the options to start recording video with",
157
311
  "type": "CameraPreviewOptions"
158
312
  }
159
313
  ],
160
314
  "returns": "any",
161
- "tags": [],
162
- "docs": "",
315
+ "tags": [
316
+ {
317
+ "name": "param",
318
+ "text": "options the options to start recording video with"
319
+ },
320
+ {
321
+ "name": "returns",
322
+ "text": "an Promise that resolves when the video recording is started"
323
+ },
324
+ {
325
+ "name": "throws",
326
+ "text": "An error if the something went wrong"
327
+ },
328
+ {
329
+ "name": "since",
330
+ "text": "0.0.1"
331
+ }
332
+ ],
333
+ "docs": "Start recording video.",
163
334
  "complexTypes": [
164
335
  "CameraPreviewOptions"
165
336
  ],
@@ -379,11 +550,11 @@
379
550
  "docs": "",
380
551
  "types": [
381
552
  {
382
- "text": "'rear'",
553
+ "text": "\"rear\"",
383
554
  "complexTypes": []
384
555
  },
385
556
  {
386
- "text": "'front'",
557
+ "text": "\"front\"",
387
558
  "complexTypes": []
388
559
  }
389
560
  ]
@@ -394,11 +565,11 @@
394
565
  "docs": "",
395
566
  "types": [
396
567
  {
397
- "text": "'jpeg'",
568
+ "text": "\"jpeg\"",
398
569
  "complexTypes": []
399
570
  },
400
571
  {
401
- "text": "'png'",
572
+ "text": "\"png\"",
402
573
  "complexTypes": []
403
574
  }
404
575
  ]
@@ -409,23 +580,23 @@
409
580
  "docs": "",
410
581
  "types": [
411
582
  {
412
- "text": "'off'",
583
+ "text": "\"off\"",
413
584
  "complexTypes": []
414
585
  },
415
586
  {
416
- "text": "'on'",
587
+ "text": "\"on\"",
417
588
  "complexTypes": []
418
589
  },
419
590
  {
420
- "text": "'auto'",
591
+ "text": "\"auto\"",
421
592
  "complexTypes": []
422
593
  },
423
594
  {
424
- "text": "'red-eye'",
595
+ "text": "\"red-eye\"",
425
596
  "complexTypes": []
426
597
  },
427
598
  {
428
- "text": "'torch'",
599
+ "text": "\"torch\"",
429
600
  "complexTypes": []
430
601
  }
431
602
  ]
@@ -1,4 +1,4 @@
1
- export type CameraPosition = 'rear' | 'front';
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,36 +47,109 @@ export interface CameraPreviewPictureOptions {
47
47
  * quality has no effect on png */
48
48
  format?: PictureFormat;
49
49
  }
50
- export type PictureFormat = 'jpeg' | 'png';
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 type CameraPreviewFlashMode = 'off' | 'on' | 'auto' | 'red-eye' | 'torch';
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;
59
59
  }
60
60
  export interface CameraPreviewPlugin {
61
+ /**
62
+ * Start the camera preview instance.
63
+ * @param {CameraPreviewOptions} options the options to start the camera preview with
64
+ * @returns {Promise<void>} an Promise that resolves when the instance is started
65
+ * @throws An error if the something went wrong
66
+ * @since 0.0.1
67
+ */
61
68
  start(options: CameraPreviewOptions): Promise<void>;
69
+ /**
70
+ * Stop the camera preview instance.
71
+ * @returns {Promise<void>} an Promise that resolves when the instance is stopped
72
+ * @throws An error if the something went wrong
73
+ * @since 0.0.1
74
+ */
62
75
  stop(): Promise<void>;
76
+ /**
77
+ * Switch camera.
78
+ * @param {CameraPreviewOptions} options the options to switch the camera with
79
+ * @returns {Promise<void>} an Promise that resolves when the camera is switched
80
+ * @throws An error if the something went wrong
81
+ * @since 0.0.1
82
+ */
63
83
  capture(options: CameraPreviewPictureOptions): Promise<{
64
84
  value: string;
65
85
  }>;
86
+ /**
87
+ * Capture a sample image.
88
+ * @param {CameraSampleOptions} options the options to capture the sample image with
89
+ * @returns {Promise<string>} an Promise that resolves with the sample image as a base64 encoded string
90
+ * @throws An error if the something went wrong
91
+ * @since 0.0.1
92
+ */
66
93
  captureSample(options: CameraSampleOptions): Promise<{
67
94
  value: string;
68
95
  }>;
96
+ /**
97
+ * Get supported flash modes.
98
+ * @returns {Promise<CameraPreviewFlashMode[]>} an Promise that resolves with the supported flash modes
99
+ * @throws An error if the something went wrong
100
+ * @since 0.0.1
101
+ */
69
102
  getSupportedFlashModes(): Promise<{
70
103
  result: CameraPreviewFlashMode[];
71
104
  }>;
105
+ /**
106
+ * Get horizontal field of view.
107
+ * @returns {Promise<any>} an Promise that resolves with the horizontal field of view
108
+ * @throws An error if the something went wrong
109
+ * @since 0.0.1
110
+ */
72
111
  getHorizontalFov(): Promise<{
73
112
  result: any;
74
113
  }>;
114
+ /**
115
+ * Set flash mode.
116
+ * @param options the options to set the flash mode with
117
+ * @returns {Promise<void>} an Promise that resolves when the flash mode is set
118
+ * @throws An error if the something went wrong
119
+ * @since 0.0.1
120
+ */
75
121
  setFlashMode(options: {
76
122
  flashMode: CameraPreviewFlashMode | string;
77
123
  }): Promise<void>;
124
+ /**
125
+ * Flip camera.
126
+ * @returns {Promise<void>} an Promise that resolves when the camera is flipped
127
+ * @throws An error if the something went wrong
128
+ * @since 0.0.1
129
+ */
78
130
  flip(): Promise<void>;
131
+ /**
132
+ * Set opacity.
133
+ * @param {CameraOpacityOptions} options the options to set the camera opacity with
134
+ * @returns {Promise<void>} an Promise that resolves when the camera color effect is set
135
+ * @throws An error if the something went wrong
136
+ * @since 0.0.1
137
+ */
79
138
  setOpacity(options: CameraOpacityOptions): Promise<void>;
139
+ /**
140
+ * Stop recording video.
141
+ * @param {CameraPreviewOptions} options the options to stop recording video with
142
+ * @returns {Promise<void>} an Promise that resolves when the camera zoom is set
143
+ * @throws An error if the something went wrong
144
+ * @since 0.0.1
145
+ */
80
146
  stopRecordVideo(): Promise<void>;
147
+ /**
148
+ * Start recording video.
149
+ * @param {CameraPreviewOptions} options the options to start recording video with
150
+ * @returns {Promise<void>} an Promise that resolves when the video recording is started
151
+ * @throws An error if the something went wrong
152
+ * @since 0.0.1
153
+ */
81
154
  startRecordVideo(options: CameraPreviewOptions): Promise<void>;
82
155
  }
@@ -1,4 +1,4 @@
1
- import type { CameraPreviewPlugin } from './definitions';
1
+ import type { CameraPreviewPlugin } from "./definitions";
2
2
  declare const CameraPreview: CameraPreviewPlugin;
3
- export * from './definitions';
3
+ export * from "./definitions";
4
4
  export { CameraPreview };
package/dist/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { registerPlugin } from '@capacitor/core';
2
- const CameraPreview = registerPlugin('CameraPreview', {
3
- web: () => import('./web').then((m) => new m.CameraPreviewWeb()),
1
+ import { registerPlugin } from "@capacitor/core";
2
+ const CameraPreview = registerPlugin("CameraPreview", {
3
+ web: () => import("./web").then((m) => new m.CameraPreviewWeb()),
4
4
  });
5
- export * from './definitions';
5
+ export * from "./definitions";
6
6
  export { CameraPreview };
7
7
  //# sourceMappingURL=index.js.map
package/dist/esm/web.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { WebPlugin } from '@capacitor/core';
2
- import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions, CameraPreviewPlugin } from './definitions';
1
+ import { WebPlugin } from "@capacitor/core";
2
+ import type { CameraPreviewOptions, CameraPreviewPictureOptions, CameraPreviewFlashMode, CameraSampleOptions, CameraOpacityOptions, CameraPreviewPlugin } from "./definitions";
3
3
  export declare class CameraPreviewWeb extends WebPlugin implements CameraPreviewPlugin {
4
4
  /**
5
5
  * track which camera is used based on start options