@capacitor/camera 1.1.2 → 1.2.3

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/CHANGELOG.md CHANGED
@@ -3,6 +3,51 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.2.3](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.2.2...@capacitor/camera@1.2.3) (2022-01-10)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **camera:** set camera direction for web ([#665](https://github.com/ionic-team/capacitor-plugins/issues/665)) ([4afedb9](https://github.com/ionic-team/capacitor-plugins/commit/4afedb96f3b745a86d9cacd33ca71c42ae3fb8d4))
12
+
13
+
14
+
15
+
16
+
17
+ ## [1.2.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.2.1...@capacitor/camera@1.2.2) (2021-12-08)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **camera:** Return proper exif when picking multiple images ([#712](https://github.com/ionic-team/capacitor-plugins/issues/712)) ([8451237](https://github.com/ionic-team/capacitor-plugins/commit/8451237e46f24c59e74e350eaa9b31e6d99a68a0))
23
+
24
+
25
+
26
+
27
+
28
+ ## [1.2.1](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.2.0...@capacitor/camera@1.2.1) (2021-11-17)
29
+
30
+
31
+ ### Bug Fixes
32
+
33
+ * **camera:** Don't save gallery images on iOS 14+ ([#696](https://github.com/ionic-team/capacitor-plugins/issues/696)) ([7b2cc88](https://github.com/ionic-team/capacitor-plugins/commit/7b2cc88f6e83265c991ae9f81cfc3f6bed346250))
34
+ * **camera:** Remove capture attribute from multiple photo picker ([#687](https://github.com/ionic-team/capacitor-plugins/issues/687)) ([e551ef7](https://github.com/ionic-team/capacitor-plugins/commit/e551ef77eebe331cc7bf13c9c0eab5a0bd2da0d1))
35
+
36
+
37
+
38
+
39
+
40
+ # [1.2.0](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.1.2...@capacitor/camera@1.2.0) (2021-11-03)
41
+
42
+
43
+ ### Features
44
+
45
+ * **camera:** Add new method for multiple image picking from gallery ([#671](https://github.com/ionic-team/capacitor-plugins/issues/671)) ([a49c590](https://github.com/ionic-team/capacitor-plugins/commit/a49c5901683da12438fbafbd1bf6ae91133d18ed))
46
+
47
+
48
+
49
+
50
+
6
51
  ## [1.1.2](https://github.com/ionic-team/capacitor-plugins/compare/@capacitor/camera@1.1.1...@capacitor/camera@1.1.2) (2021-10-14)
7
52
 
8
53
 
package/README.md CHANGED
@@ -73,6 +73,7 @@ const takePicture = async () => {
73
73
  <docgen-index>
74
74
 
75
75
  * [`getPhoto(...)`](#getphoto)
76
+ * [`pickImages(...)`](#pickimages)
76
77
  * [`checkPermissions()`](#checkpermissions)
77
78
  * [`requestPermissions(...)`](#requestpermissions)
78
79
  * [Interfaces](#interfaces)
@@ -104,6 +105,26 @@ with the camera.
104
105
  --------------------
105
106
 
106
107
 
108
+ ### pickImages(...)
109
+
110
+ ```typescript
111
+ pickImages(options: GalleryImageOptions) => Promise<GalleryPhotos>
112
+ ```
113
+
114
+ Allows the user to pick multiple pictures from the photo gallery.
115
+ On iOS 13 and older it only allows to pick one picture.
116
+
117
+ | Param | Type |
118
+ | ------------- | ------------------------------------------------------------------- |
119
+ | **`options`** | <code><a href="#galleryimageoptions">GalleryImageOptions</a></code> |
120
+
121
+ **Returns:** <code>Promise&lt;<a href="#galleryphotos">GalleryPhotos</a>&gt;</code>
122
+
123
+ **Since:** 1.2.0
124
+
125
+ --------------------
126
+
127
+
107
128
  ### checkPermissions()
108
129
 
109
130
  ```typescript
@@ -159,7 +180,7 @@ Request camera and photo album permissions
159
180
  | Prop | Type | Description | Default | Since |
160
181
  | ------------------------- | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------- | ----- |
161
182
  | **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.0.0 |
162
- | **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific) | | 1.0.0 |
183
+ | **`allowEditing`** | <code>boolean</code> | Whether to allow the user to crop or make small edits (platform specific). On iOS 14+ it's only supported for <a href="#camerasource">CameraSource.Camera</a>, but not for <a href="#camerasource">CameraSource.Photos</a>. | | 1.0.0 |
163
184
  | **`resultType`** | <code><a href="#cameraresulttype">CameraResultType</a></code> | How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported | | 1.0.0 |
164
185
  | **`saveToGallery`** | <code>boolean</code> | Whether to save the photo to the gallery. If the photo was picked from the gallery, it will only be saved if edited. | <code>: false</code> | 1.0.0 |
165
186
  | **`width`** | <code>number</code> | The width of the saved image | | 1.0.0 |
@@ -176,6 +197,35 @@ Request camera and photo album permissions
176
197
  | **`promptLabelPicture`** | <code>string</code> | Text value to use when displaying the prompt. The label of the button to open the camera. | <code>: 'Take Picture'</code> | 1.0.0 |
177
198
 
178
199
 
200
+ #### GalleryPhotos
201
+
202
+ | Prop | Type | Description | Since |
203
+ | ------------ | --------------------------- | ------------------------------- | ----- |
204
+ | **`photos`** | <code>GalleryPhoto[]</code> | Array of all the picked photos. | 1.2.0 |
205
+
206
+
207
+ #### GalleryPhoto
208
+
209
+ | Prop | Type | Description | Since |
210
+ | ------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------- | ----- |
211
+ | **`path`** | <code>string</code> | Full, platform-specific file URL that can be read later using the Filsystem API. | 1.2.0 |
212
+ | **`webPath`** | <code>string</code> | webPath returns a path that can be used to set the src attribute of an image for efficient loading and rendering. | 1.2.0 |
213
+ | **`exif`** | <code>any</code> | Exif data, if any, retrieved from the image | 1.2.0 |
214
+ | **`format`** | <code>string</code> | The format of the image, ex: jpeg, png, gif. iOS and Android only support jpeg. Web supports jpeg, png and gif. | 1.2.0 |
215
+
216
+
217
+ #### GalleryImageOptions
218
+
219
+ | Prop | Type | Description | Default | Since |
220
+ | ------------------------ | -------------------------------------- | ------------------------------------------------------------------------------------------ | --------------------------- | ----- |
221
+ | **`quality`** | <code>number</code> | The quality of image to return as JPEG, from 0-100 | | 1.2.0 |
222
+ | **`width`** | <code>number</code> | The width of the saved image | | 1.2.0 |
223
+ | **`height`** | <code>number</code> | The height of the saved image | | 1.2.0 |
224
+ | **`correctOrientation`** | <code>boolean</code> | Whether to automatically rotate the image "up" to correct for orientation in portrait mode | <code>: true</code> | 1.2.0 |
225
+ | **`presentationStyle`** | <code>'fullscreen' \| 'popover'</code> | iOS only: The presentation style of the Camera. | <code>: 'fullscreen'</code> | 1.2.0 |
226
+ | **`limit`** | <code>number</code> | iOS only: Maximum number of pictures the user will be able to choose. | <code>0 (unlimited)</code> | 1.2.0 |
227
+
228
+
179
229
  #### PermissionStatus
180
230
 
181
231
  | Prop | Type |
@@ -2,6 +2,7 @@ package com.capacitorjs.plugins.camera;
2
2
 
3
3
  import android.Manifest;
4
4
  import android.app.Activity;
5
+ import android.content.ActivityNotFoundException;
5
6
  import android.content.Intent;
6
7
  import android.content.pm.PackageManager;
7
8
  import android.content.pm.ResolveInfo;
@@ -35,6 +36,8 @@ import java.io.InputStream;
35
36
  import java.util.ArrayList;
36
37
  import java.util.List;
37
38
  import java.util.Map;
39
+ import java.util.concurrent.Executor;
40
+ import java.util.concurrent.Executors;
38
41
  import org.json.JSONException;
39
42
 
40
43
  /**
@@ -67,6 +70,7 @@ public class CameraPlugin extends Plugin {
67
70
  private static final String PERMISSION_DENIED_ERROR_PHOTOS = "User denied access to photos";
68
71
  private static final String NO_CAMERA_ERROR = "Device doesn't have a camera available";
69
72
  private static final String NO_CAMERA_ACTIVITY_ERROR = "Unable to resolve camera activity";
73
+ private static final String NO_PHOTO_ACTIVITY_ERROR = "Unable to resolve photo activity";
70
74
  private static final String IMAGE_FILE_SAVE_ERROR = "Unable to create photo on disk";
71
75
  private static final String IMAGE_PROCESS_NO_FILE_ERROR = "Unable to process image, file not found on disk";
72
76
  private static final String UNABLE_TO_PROCESS_IMAGE = "Unable to process image";
@@ -90,6 +94,12 @@ public class CameraPlugin extends Plugin {
90
94
  doShow(call);
91
95
  }
92
96
 
97
+ @PluginMethod
98
+ public void pickImages(PluginCall call) {
99
+ settings = getSettings(call);
100
+ openPhotos(call, true);
101
+ }
102
+
93
103
  private void doShow(PluginCall call) {
94
104
  switch (settings.getSource()) {
95
105
  case CAMERA:
@@ -250,10 +260,23 @@ public class CameraPlugin extends Plugin {
250
260
  }
251
261
 
252
262
  public void openPhotos(final PluginCall call) {
253
- if (checkPhotosPermissions(call)) {
263
+ openPhotos(call, false);
264
+ }
265
+
266
+ private void openPhotos(final PluginCall call, boolean multiple) {
267
+ if (multiple || checkPhotosPermissions(call)) {
254
268
  Intent intent = new Intent(Intent.ACTION_PICK);
269
+ intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, multiple);
255
270
  intent.setType("image/*");
256
- startActivityForResult(call, intent, "processPickedImage");
271
+ try {
272
+ if (multiple) {
273
+ startActivityForResult(call, intent, "processPickedImages");
274
+ } else {
275
+ startActivityForResult(call, intent, "processPickedImage");
276
+ }
277
+ } catch (ActivityNotFoundException ex) {
278
+ call.reject(NO_PHOTO_ACTIVITY_ERROR);
279
+ }
257
280
  }
258
281
  }
259
282
 
@@ -294,6 +317,35 @@ public class CameraPlugin extends Plugin {
294
317
  processPickedImage(u, call);
295
318
  }
296
319
 
320
+ @ActivityCallback
321
+ public void processPickedImages(PluginCall call, ActivityResult result) {
322
+ Intent data = result.getData();
323
+ if (data != null && data.getClipData() != null) {
324
+ Executor executor = Executors.newSingleThreadExecutor();
325
+ executor.execute(
326
+ () -> {
327
+ JSObject ret = new JSObject();
328
+ JSArray photos = new JSArray();
329
+ int count = data.getClipData().getItemCount();
330
+ for (int i = 0; i < count; i++) {
331
+ Uri imageUri = data.getClipData().getItemAt(i).getUri();
332
+ JSObject processResult = processPickedImages(imageUri);
333
+ if (processResult.getString("error") != null && !processResult.getString("error").isEmpty()) {
334
+ call.reject(processResult.getString("error"));
335
+ return;
336
+ } else {
337
+ photos.put(processPickedImages(imageUri));
338
+ }
339
+ }
340
+ ret.put("photos", photos);
341
+ call.resolve(ret);
342
+ }
343
+ );
344
+ } else {
345
+ call.reject("No images picked");
346
+ }
347
+ }
348
+
297
349
  private void processPickedImage(Uri imageUri, PluginCall call) {
298
350
  InputStream imageStream = null;
299
351
 
@@ -322,6 +374,57 @@ public class CameraPlugin extends Plugin {
322
374
  }
323
375
  }
324
376
 
377
+ private JSObject processPickedImages(Uri imageUri) {
378
+ InputStream imageStream = null;
379
+ JSObject ret = new JSObject();
380
+ try {
381
+ imageStream = getContext().getContentResolver().openInputStream(imageUri);
382
+ Bitmap bitmap = BitmapFactory.decodeStream(imageStream);
383
+
384
+ if (bitmap == null) {
385
+ ret.put("error", "Unable to process bitmap");
386
+ return ret;
387
+ }
388
+
389
+ ExifWrapper exif = ImageUtils.getExifData(getContext(), bitmap, imageUri);
390
+ try {
391
+ bitmap = prepareBitmap(bitmap, imageUri, exif);
392
+ } catch (IOException e) {
393
+ ret.put("error", UNABLE_TO_PROCESS_IMAGE);
394
+ return ret;
395
+ }
396
+ // Compress the final image and prepare for output to client
397
+ ByteArrayOutputStream bitmapOutputStream = new ByteArrayOutputStream();
398
+ bitmap.compress(Bitmap.CompressFormat.JPEG, settings.getQuality(), bitmapOutputStream);
399
+
400
+ Uri newUri = getTempImage(imageUri, bitmapOutputStream);
401
+ exif.copyExif(newUri.getPath());
402
+ if (newUri != null) {
403
+ ret.put("format", "jpeg");
404
+ ret.put("exif", exif.toJson());
405
+ ret.put("path", newUri.toString());
406
+ ret.put("webPath", FileUtils.getPortablePath(getContext(), bridge.getLocalUrl(), newUri));
407
+ } else {
408
+ ret.put("error", UNABLE_TO_PROCESS_IMAGE);
409
+ }
410
+ return ret;
411
+ } catch (OutOfMemoryError err) {
412
+ ret.put("error", "Out of memory");
413
+ } catch (FileNotFoundException ex) {
414
+ ret.put("error", "No such image found");
415
+ Logger.error(getLogTag(), "No such image found", ex);
416
+ } finally {
417
+ if (imageStream != null) {
418
+ try {
419
+ imageStream.close();
420
+ } catch (IOException e) {
421
+ Logger.error(getLogTag(), UNABLE_TO_PROCESS_IMAGE, e);
422
+ }
423
+ }
424
+ }
425
+ return ret;
426
+ }
427
+
325
428
  @ActivityCallback
326
429
  private void processEditedImage(PluginCall call, ActivityResult result) {
327
430
  isEdited = true;
package/dist/docs.json CHANGED
@@ -29,6 +29,30 @@
29
29
  ],
30
30
  "slug": "getphoto"
31
31
  },
32
+ {
33
+ "name": "pickImages",
34
+ "signature": "(options: GalleryImageOptions) => Promise<GalleryPhotos>",
35
+ "parameters": [
36
+ {
37
+ "name": "options",
38
+ "docs": "",
39
+ "type": "GalleryImageOptions"
40
+ }
41
+ ],
42
+ "returns": "Promise<GalleryPhotos>",
43
+ "tags": [
44
+ {
45
+ "name": "since",
46
+ "text": "1.2.0"
47
+ }
48
+ ],
49
+ "docs": "Allows the user to pick multiple pictures from the photo gallery.\nOn iOS 13 and older it only allows to pick one picture.",
50
+ "complexTypes": [
51
+ "GalleryPhotos",
52
+ "GalleryImageOptions"
53
+ ],
54
+ "slug": "pickimages"
55
+ },
32
56
  {
33
57
  "name": "checkPermissions",
34
58
  "signature": "() => Promise<PermissionStatus>",
@@ -194,7 +218,7 @@
194
218
  "name": "since"
195
219
  }
196
220
  ],
197
- "docs": "Whether to allow the user to crop or make small edits (platform specific)",
221
+ "docs": "Whether to allow the user to crop or make small edits (platform specific).\nOn iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos.",
198
222
  "complexTypes": [],
199
223
  "type": "boolean | undefined"
200
224
  },
@@ -414,6 +438,179 @@
414
438
  }
415
439
  ]
416
440
  },
441
+ {
442
+ "name": "GalleryPhotos",
443
+ "slug": "galleryphotos",
444
+ "docs": "",
445
+ "tags": [],
446
+ "methods": [],
447
+ "properties": [
448
+ {
449
+ "name": "photos",
450
+ "tags": [
451
+ {
452
+ "text": "1.2.0",
453
+ "name": "since"
454
+ }
455
+ ],
456
+ "docs": "Array of all the picked photos.",
457
+ "complexTypes": [
458
+ "GalleryPhoto"
459
+ ],
460
+ "type": "GalleryPhoto[]"
461
+ }
462
+ ]
463
+ },
464
+ {
465
+ "name": "GalleryPhoto",
466
+ "slug": "galleryphoto",
467
+ "docs": "",
468
+ "tags": [],
469
+ "methods": [],
470
+ "properties": [
471
+ {
472
+ "name": "path",
473
+ "tags": [
474
+ {
475
+ "text": "1.2.0",
476
+ "name": "since"
477
+ }
478
+ ],
479
+ "docs": "Full, platform-specific file URL that can be read later using the Filsystem API.",
480
+ "complexTypes": [],
481
+ "type": "string | undefined"
482
+ },
483
+ {
484
+ "name": "webPath",
485
+ "tags": [
486
+ {
487
+ "text": "1.2.0",
488
+ "name": "since"
489
+ }
490
+ ],
491
+ "docs": "webPath returns a path that can be used to set the src attribute of an image for efficient\nloading and rendering.",
492
+ "complexTypes": [],
493
+ "type": "string"
494
+ },
495
+ {
496
+ "name": "exif",
497
+ "tags": [
498
+ {
499
+ "text": "1.2.0",
500
+ "name": "since"
501
+ }
502
+ ],
503
+ "docs": "Exif data, if any, retrieved from the image",
504
+ "complexTypes": [],
505
+ "type": "any"
506
+ },
507
+ {
508
+ "name": "format",
509
+ "tags": [
510
+ {
511
+ "text": "1.2.0",
512
+ "name": "since"
513
+ }
514
+ ],
515
+ "docs": "The format of the image, ex: jpeg, png, gif.\n\niOS and Android only support jpeg.\nWeb supports jpeg, png and gif.",
516
+ "complexTypes": [],
517
+ "type": "string"
518
+ }
519
+ ]
520
+ },
521
+ {
522
+ "name": "GalleryImageOptions",
523
+ "slug": "galleryimageoptions",
524
+ "docs": "",
525
+ "tags": [],
526
+ "methods": [],
527
+ "properties": [
528
+ {
529
+ "name": "quality",
530
+ "tags": [
531
+ {
532
+ "text": "1.2.0",
533
+ "name": "since"
534
+ }
535
+ ],
536
+ "docs": "The quality of image to return as JPEG, from 0-100",
537
+ "complexTypes": [],
538
+ "type": "number | undefined"
539
+ },
540
+ {
541
+ "name": "width",
542
+ "tags": [
543
+ {
544
+ "text": "1.2.0",
545
+ "name": "since"
546
+ }
547
+ ],
548
+ "docs": "The width of the saved image",
549
+ "complexTypes": [],
550
+ "type": "number | undefined"
551
+ },
552
+ {
553
+ "name": "height",
554
+ "tags": [
555
+ {
556
+ "text": "1.2.0",
557
+ "name": "since"
558
+ }
559
+ ],
560
+ "docs": "The height of the saved image",
561
+ "complexTypes": [],
562
+ "type": "number | undefined"
563
+ },
564
+ {
565
+ "name": "correctOrientation",
566
+ "tags": [
567
+ {
568
+ "text": ": true",
569
+ "name": "default"
570
+ },
571
+ {
572
+ "text": "1.2.0",
573
+ "name": "since"
574
+ }
575
+ ],
576
+ "docs": "Whether to automatically rotate the image \"up\" to correct for orientation\nin portrait mode",
577
+ "complexTypes": [],
578
+ "type": "boolean | undefined"
579
+ },
580
+ {
581
+ "name": "presentationStyle",
582
+ "tags": [
583
+ {
584
+ "text": ": 'fullscreen'",
585
+ "name": "default"
586
+ },
587
+ {
588
+ "text": "1.2.0",
589
+ "name": "since"
590
+ }
591
+ ],
592
+ "docs": "iOS only: The presentation style of the Camera.",
593
+ "complexTypes": [],
594
+ "type": "'fullscreen' | 'popover' | undefined"
595
+ },
596
+ {
597
+ "name": "limit",
598
+ "tags": [
599
+ {
600
+ "text": "0 (unlimited)",
601
+ "name": "default"
602
+ },
603
+ {
604
+ "text": "1.2.0",
605
+ "name": "since"
606
+ }
607
+ ],
608
+ "docs": "iOS only: Maximum number of pictures the user will be able to choose.",
609
+ "complexTypes": [],
610
+ "type": "number | undefined"
611
+ }
612
+ ]
613
+ },
417
614
  {
418
615
  "name": "PermissionStatus",
419
616
  "slug": "permissionstatus",
@@ -16,6 +16,13 @@ export interface CameraPlugin {
16
16
  * @since 1.0.0
17
17
  */
18
18
  getPhoto(options: ImageOptions): Promise<Photo>;
19
+ /**
20
+ * Allows the user to pick multiple pictures from the photo gallery.
21
+ * On iOS 13 and older it only allows to pick one picture.
22
+ *
23
+ * @since 1.2.0
24
+ */
25
+ pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;
19
26
  /**
20
27
  * Check camera and photo album permissions
21
28
  *
@@ -37,7 +44,8 @@ export interface ImageOptions {
37
44
  */
38
45
  quality?: number;
39
46
  /**
40
- * Whether to allow the user to crop or make small edits (platform specific)
47
+ * Whether to allow the user to crop or make small edits (platform specific).
48
+ * On iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos.
41
49
  *
42
50
  * @since 1.0.0
43
51
  */
@@ -202,6 +210,86 @@ export interface Photo {
202
210
  */
203
211
  saved: boolean;
204
212
  }
213
+ export interface GalleryPhotos {
214
+ /**
215
+ * Array of all the picked photos.
216
+ *
217
+ * @since 1.2.0
218
+ */
219
+ photos: GalleryPhoto[];
220
+ }
221
+ export interface GalleryPhoto {
222
+ /**
223
+ * Full, platform-specific file URL that can be read later using the Filsystem API.
224
+ *
225
+ * @since 1.2.0
226
+ */
227
+ path?: string;
228
+ /**
229
+ * webPath returns a path that can be used to set the src attribute of an image for efficient
230
+ * loading and rendering.
231
+ *
232
+ * @since 1.2.0
233
+ */
234
+ webPath: string;
235
+ /**
236
+ * Exif data, if any, retrieved from the image
237
+ *
238
+ * @since 1.2.0
239
+ */
240
+ exif?: any;
241
+ /**
242
+ * The format of the image, ex: jpeg, png, gif.
243
+ *
244
+ * iOS and Android only support jpeg.
245
+ * Web supports jpeg, png and gif.
246
+ *
247
+ * @since 1.2.0
248
+ */
249
+ format: string;
250
+ }
251
+ export interface GalleryImageOptions {
252
+ /**
253
+ * The quality of image to return as JPEG, from 0-100
254
+ *
255
+ * @since 1.2.0
256
+ */
257
+ quality?: number;
258
+ /**
259
+ * The width of the saved image
260
+ *
261
+ * @since 1.2.0
262
+ */
263
+ width?: number;
264
+ /**
265
+ * The height of the saved image
266
+ *
267
+ * @since 1.2.0
268
+ */
269
+ height?: number;
270
+ /**
271
+ * Whether to automatically rotate the image "up" to correct for orientation
272
+ * in portrait mode
273
+ * @default: true
274
+ *
275
+ * @since 1.2.0
276
+ */
277
+ correctOrientation?: boolean;
278
+ /**
279
+ * iOS only: The presentation style of the Camera.
280
+ * @default: 'fullscreen'
281
+ *
282
+ * @since 1.2.0
283
+ */
284
+ presentationStyle?: 'fullscreen' | 'popover';
285
+ /**
286
+ * iOS only: Maximum number of pictures the user will be able to choose.
287
+ * @default 0 (unlimited)
288
+ *
289
+ * @since 1.2.0
290
+ */
291
+ limit?: number;
292
+ }
205
293
  export declare enum CameraSource {
206
294
  /**
207
295
  * Prompts the user to select either the photo album or take a photo.
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA8NA,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B"}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AA2TA,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;IACjB;;OAEG;IACH,iCAAiB,CAAA;AACnB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,MAAM,CAAN,IAAY,eAGX;AAHD,WAAY,eAAe;IACzB,gCAAa,CAAA;IACb,kCAAe,CAAA;AACjB,CAAC,EAHW,eAAe,KAAf,eAAe,QAG1B;AAED,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B"}
package/dist/esm/web.d.ts CHANGED
@@ -1,9 +1,11 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
- import type { CameraPlugin, ImageOptions, PermissionStatus, Photo } from './definitions';
2
+ import type { CameraPlugin, GalleryImageOptions, GalleryPhotos, ImageOptions, PermissionStatus, Photo } from './definitions';
3
3
  export declare class CameraWeb extends WebPlugin implements CameraPlugin {
4
4
  getPhoto(options: ImageOptions): Promise<Photo>;
5
+ pickImages(_options: GalleryImageOptions): Promise<GalleryPhotos>;
5
6
  private cameraExperience;
6
7
  private fileInputExperience;
8
+ private multipleFileInputExperience;
7
9
  private _getCameraPhoto;
8
10
  checkPermissions(): Promise<PermissionStatus>;
9
11
  requestPermissions(): Promise<PermissionStatus>;
package/dist/esm/web.js CHANGED
@@ -34,9 +34,17 @@ export class CameraWeb extends WebPlugin {
34
34
  }
35
35
  });
36
36
  }
37
+ async pickImages(_options) {
38
+ // eslint-disable-next-line no-async-promise-executor
39
+ return new Promise(async (resolve) => {
40
+ this.multipleFileInputExperience(resolve);
41
+ });
42
+ }
37
43
  async cameraExperience(options, resolve, reject) {
38
44
  if (customElements.get('pwa-camera-modal')) {
39
45
  const cameraModal = document.createElement('pwa-camera-modal');
46
+ cameraModal.facingMode =
47
+ options.direction === CameraDirection.Front ? 'user' : 'environment';
40
48
  document.body.appendChild(cameraModal);
41
49
  try {
42
50
  await cameraModal.componentOnReady();
@@ -130,6 +138,43 @@ export class CameraWeb extends WebPlugin {
130
138
  }
131
139
  input.click();
132
140
  }
141
+ multipleFileInputExperience(resolve) {
142
+ let input = document.querySelector('#_capacitor-camera-input-multiple');
143
+ const cleanup = () => {
144
+ var _a;
145
+ (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);
146
+ };
147
+ if (!input) {
148
+ input = document.createElement('input');
149
+ input.id = '_capacitor-camera-input-multiple';
150
+ input.type = 'file';
151
+ input.hidden = true;
152
+ input.multiple = true;
153
+ document.body.appendChild(input);
154
+ input.addEventListener('change', (_e) => {
155
+ const photos = [];
156
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
157
+ for (let i = 0; i < input.files.length; i++) {
158
+ const file = input.files[i];
159
+ let format = 'jpeg';
160
+ if (file.type === 'image/png') {
161
+ format = 'png';
162
+ }
163
+ else if (file.type === 'image/gif') {
164
+ format = 'gif';
165
+ }
166
+ photos.push({
167
+ webPath: URL.createObjectURL(file),
168
+ format: format,
169
+ });
170
+ }
171
+ resolve({ photos });
172
+ cleanup();
173
+ });
174
+ }
175
+ input.accept = 'image/*';
176
+ input.click();
177
+ }
133
178
  _getCameraPhoto(photo, options) {
134
179
  return new Promise((resolve, reject) => {
135
180
  const reader = new FileReader();
@@ -1 +1 @@
1
- {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAQ9D,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,QAAQ,CAAC,OAAqB;QAClC,qDAAqD;QACrD,OAAO,IAAI,OAAO,CAAQ,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;YAClD,IAAI,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC,MAAM,KAAK,YAAY,CAAC,MAAM,EAAE;gBACjE,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;aAC5C;iBAAM,IAAI,OAAO,CAAC,MAAM,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AAE,KAAK;yBACb,CAAC,CAAC;qBACJ;yBAAM;wBACL,OAAO,CAAC;4BACN,YAAY,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;4BAC7B,MAAM,EAAE,MAAM;4BACd,KAAK,EAAE,KAAK;yBACb,CAAC,CAAC;qBACJ;gBACH,CAAC,CAAC;gBACF,MAAM,CAAC,OAAO,GAAG,CAAC,CAAC,EAAE;oBACnB,MAAM,CAAC,CAAC,CAAC,CAAC;gBACZ,CAAC,CAAC;aACH;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;YAC9D,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;SACzE;QAED,IAAI;YACF,qEAAqE;YACrE,uFAAuF;YACvF,sEAAsE;YACtE,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;gBAC1D,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;YACH,OAAO;gBACL,MAAM,EAAE,UAAU,CAAC,KAAK;gBACxB,MAAM,EAAE,SAAS;aAClB,CAAC;SACH;QAAC,WAAM;YACN,MAAM,IAAI,CAAC,WAAW,CACpB,sDAAsD,CACvD,CAAC;SACH;IACH,CAAC;IAED,KAAK,CAAC,kBAAkB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IACtD,CAAC;CACF;AAED,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,CAAC"}
@@ -69,9 +69,17 @@ class CameraWeb extends core.WebPlugin {
69
69
  }
70
70
  });
71
71
  }
72
+ async pickImages(_options) {
73
+ // eslint-disable-next-line no-async-promise-executor
74
+ return new Promise(async (resolve) => {
75
+ this.multipleFileInputExperience(resolve);
76
+ });
77
+ }
72
78
  async cameraExperience(options, resolve, reject) {
73
79
  if (customElements.get('pwa-camera-modal')) {
74
80
  const cameraModal = document.createElement('pwa-camera-modal');
81
+ cameraModal.facingMode =
82
+ options.direction === exports.CameraDirection.Front ? 'user' : 'environment';
75
83
  document.body.appendChild(cameraModal);
76
84
  try {
77
85
  await cameraModal.componentOnReady();
@@ -165,6 +173,43 @@ class CameraWeb extends core.WebPlugin {
165
173
  }
166
174
  input.click();
167
175
  }
176
+ multipleFileInputExperience(resolve) {
177
+ let input = document.querySelector('#_capacitor-camera-input-multiple');
178
+ const cleanup = () => {
179
+ var _a;
180
+ (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);
181
+ };
182
+ if (!input) {
183
+ input = document.createElement('input');
184
+ input.id = '_capacitor-camera-input-multiple';
185
+ input.type = 'file';
186
+ input.hidden = true;
187
+ input.multiple = true;
188
+ document.body.appendChild(input);
189
+ input.addEventListener('change', (_e) => {
190
+ const photos = [];
191
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
192
+ for (let i = 0; i < input.files.length; i++) {
193
+ const file = input.files[i];
194
+ let format = 'jpeg';
195
+ if (file.type === 'image/png') {
196
+ format = 'png';
197
+ }
198
+ else if (file.type === 'image/gif') {
199
+ format = 'gif';
200
+ }
201
+ photos.push({
202
+ webPath: URL.createObjectURL(file),
203
+ format: format,
204
+ });
205
+ }
206
+ resolve({ photos });
207
+ cleanup();
208
+ });
209
+ }
210
+ input.accept = 'image/*';
211
+ input.click();
212
+ }
168
213
  _getCameraPhoto(photo, options) {
169
214
  return new Promise((resolve, reject) => {
170
215
  const reader = new FileReader();
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CameraSource;\n(function (CameraSource) {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n CameraSource[\"Prompt\"] = \"PROMPT\";\n /**\n * Take a new photo using the camera.\n */\n CameraSource[\"Camera\"] = \"CAMERA\";\n /**\n * Pick an existing photo fron the gallery or photo album.\n */\n CameraSource[\"Photos\"] = \"PHOTOS\";\n})(CameraSource || (CameraSource = {}));\nexport var CameraDirection;\n(function (CameraDirection) {\n CameraDirection[\"Rear\"] = \"REAR\";\n CameraDirection[\"Front\"] = \"FRONT\";\n})(CameraDirection || (CameraDirection = {}));\nexport var CameraResultType;\n(function (CameraResultType) {\n CameraResultType[\"Uri\"] = \"uri\";\n CameraResultType[\"Base64\"] = \"base64\";\n CameraResultType[\"DataUrl\"] = \"dataUrl\";\n})(CameraResultType || (CameraResultType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Camera = registerPlugin('Camera', {\n web: () => import('./web').then(m => new m.CameraWeb()),\n});\nexport * from './definitions';\nexport { Camera };\n//# sourceMappingURL=index.js.map","import { WebPlugin, CapacitorException } from '@capacitor/core';\nimport { CameraSource, CameraDirection } from './definitions';\nexport class CameraWeb extends WebPlugin {\n async getPhoto(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n if (options.webUseInput || options.source === CameraSource.Photos) {\n this.fileInputExperience(options, resolve);\n }\n else if (options.source === CameraSource.Prompt) {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.promptLabelHeader || 'Photo';\n actionSheet.cancelable = false;\n actionSheet.options = [\n { title: options.promptLabelPhoto || 'From Photos' },\n { title: options.promptLabelPicture || 'Take Picture' },\n ];\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n if (selection === 0) {\n this.fileInputExperience(options, resolve);\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n async cameraExperience(options, resolve, reject) {\n if (customElements.get('pwa-camera-modal')) {\n const cameraModal = document.createElement('pwa-camera-modal');\n document.body.appendChild(cameraModal);\n try {\n await cameraModal.componentOnReady();\n cameraModal.addEventListener('onPhoto', async (e) => {\n const photo = e.detail;\n if (photo === null) {\n reject(new CapacitorException('User cancelled photos app'));\n }\n else if (photo instanceof Error) {\n reject(photo);\n }\n else {\n resolve(await this._getCameraPhoto(photo, options));\n }\n cameraModal.dismiss();\n document.body.removeChild(cameraModal);\n });\n cameraModal.present();\n }\n catch (e) {\n this.fileInputExperience(options, resolve);\n }\n }\n else {\n console.error(`Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/pwa-elements.`);\n this.fileInputExperience(options, resolve);\n }\n }\n fileInputExperience(options, resolve) {\n let input = document.querySelector('#_capacitor-camera-input');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input';\n input.type = 'file';\n input.hidden = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const file = input.files[0];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n if (options.resultType === 'dataUrl' ||\n options.resultType === 'base64') {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: reader.result,\n format,\n });\n }\n else if (options.resultType === 'base64') {\n const b64 = reader.result.split(',')[1];\n resolve({\n base64String: b64,\n format,\n });\n }\n cleanup();\n });\n reader.readAsDataURL(file);\n }\n else {\n resolve({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n cleanup();\n }\n });\n }\n input.accept = 'image/*';\n input.capture = true;\n if (options.source === CameraSource.Photos ||\n options.source === CameraSource.Prompt) {\n input.removeAttribute('capture');\n }\n else if (options.direction === CameraDirection.Front) {\n input.capture = 'user';\n }\n else if (options.direction === CameraDirection.Rear) {\n input.capture = 'environment';\n }\n input.click();\n }\n _getCameraPhoto(photo, options) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n const format = photo.type.split('/')[1];\n if (options.resultType === 'uri') {\n resolve({\n webPath: URL.createObjectURL(photo),\n format: format,\n saved: false,\n });\n }\n else {\n reader.readAsDataURL(photo);\n reader.onloadend = () => {\n const r = reader.result;\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: r,\n format: format,\n saved: false,\n });\n }\n else {\n resolve({\n base64String: r.split(',')[1],\n format: format,\n saved: false,\n });\n }\n };\n reader.onerror = e => {\n reject(e);\n };\n }\n });\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n try {\n // https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query\n // the specific permissions that are supported varies among browsers that implement the\n // permissions API, so we need a try/catch in case 'camera' is invalid\n const permission = await window.navigator.permissions.query({\n name: 'camera',\n });\n return {\n camera: permission.state,\n photos: 'granted',\n };\n }\n catch (_a) {\n throw this.unavailable('Camera permissions are not available in this browser');\n }\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Camera = new CameraWeb();\nexport { Camera };\n//# sourceMappingURL=web.js.map"],"names":["CameraSource","CameraDirection","CameraResultType","Camera","registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;;;;AAAWA,8BAAa;AACxB,CAAC,UAAU,YAAY,EAAE;AACzB;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC,CAAC;AAC7BC,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,MAAM,CAAC,GA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yB,CAAC,CAAC;AAC3B,qBAAqB;AACrB,iBAAiB,CAAC;AAClB,gBAAgB,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI;AACtC,oBAAoB,MAAM,CAAC,CAAC,CAAC,CAAC;AAC9B,iBAAiB,CAAC;AAClB,aAAa;AACb,SAAS,CAAC,CAAC;AACX,KAAK;AACL,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;AACxE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;AACpF,SAAS;AACT,QAAQ,IAAI;AACZ;AACA;AACA;AACA,YAAY,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;AACxE,gBAAgB,IAAI,EAAE,QAAQ;AAC9B,aAAa,CAAC,CAAC;AACf,YAAY,OAAO;AACnB,gBAAgB,MAAM,EAAE,UAAU,CAAC,KAAK;AACxC,gBAAgB,MAAM,EAAE,SAAS;AACjC,aAAa,CAAC;AACd,SAAS;AACT,QAAQ,OAAO,EAAE,EAAE;AACnB,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,sDAAsD,CAAC,CAAC;AAC3F,SAAS;AACT,KAAK;AACL,IAAI,MAAM,kBAAkB,GAAG;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;AAC5D,KAAK;AACL,CAAC;AACD,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CameraSource;\n(function (CameraSource) {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n CameraSource[\"Prompt\"] = \"PROMPT\";\n /**\n * Take a new photo using the camera.\n */\n CameraSource[\"Camera\"] = \"CAMERA\";\n /**\n * Pick an existing photo fron the gallery or photo album.\n */\n CameraSource[\"Photos\"] = \"PHOTOS\";\n})(CameraSource || (CameraSource = {}));\nexport var CameraDirection;\n(function (CameraDirection) {\n CameraDirection[\"Rear\"] = \"REAR\";\n CameraDirection[\"Front\"] = \"FRONT\";\n})(CameraDirection || (CameraDirection = {}));\nexport var CameraResultType;\n(function (CameraResultType) {\n CameraResultType[\"Uri\"] = \"uri\";\n CameraResultType[\"Base64\"] = \"base64\";\n CameraResultType[\"DataUrl\"] = \"dataUrl\";\n})(CameraResultType || (CameraResultType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Camera = registerPlugin('Camera', {\n web: () => import('./web').then(m => new m.CameraWeb()),\n});\nexport * from './definitions';\nexport { Camera };\n//# sourceMappingURL=index.js.map","import { WebPlugin, CapacitorException } from '@capacitor/core';\nimport { CameraSource, CameraDirection } from './definitions';\nexport class CameraWeb extends WebPlugin {\n async getPhoto(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n if (options.webUseInput || options.source === CameraSource.Photos) {\n this.fileInputExperience(options, resolve);\n }\n else if (options.source === CameraSource.Prompt) {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.promptLabelHeader || 'Photo';\n actionSheet.cancelable = false;\n actionSheet.options = [\n { title: options.promptLabelPhoto || 'From Photos' },\n { title: options.promptLabelPicture || 'Take Picture' },\n ];\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n if (selection === 0) {\n this.fileInputExperience(options, resolve);\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n async pickImages(_options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n this.multipleFileInputExperience(resolve);\n });\n }\n async cameraExperience(options, resolve, reject) {\n if (customElements.get('pwa-camera-modal')) {\n const cameraModal = document.createElement('pwa-camera-modal');\n cameraModal.facingMode =\n options.direction === CameraDirection.Front ? 'user' : 'environment';\n document.body.appendChild(cameraModal);\n try {\n await cameraModal.componentOnReady();\n cameraModal.addEventListener('onPhoto', async (e) => {\n const photo = e.detail;\n if (photo === null) {\n reject(new CapacitorException('User cancelled photos app'));\n }\n else if (photo instanceof Error) {\n reject(photo);\n }\n else {\n resolve(await this._getCameraPhoto(photo, options));\n }\n cameraModal.dismiss();\n document.body.removeChild(cameraModal);\n });\n cameraModal.present();\n }\n catch (e) {\n this.fileInputExperience(options, resolve);\n }\n }\n else {\n console.error(`Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/pwa-elements.`);\n this.fileInputExperience(options, resolve);\n }\n }\n fileInputExperience(options, resolve) {\n let input = document.querySelector('#_capacitor-camera-input');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input';\n input.type = 'file';\n input.hidden = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const file = input.files[0];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n if (options.resultType === 'dataUrl' ||\n options.resultType === 'base64') {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: reader.result,\n format,\n });\n }\n else if (options.resultType === 'base64') {\n const b64 = reader.result.split(',')[1];\n resolve({\n base64String: b64,\n format,\n });\n }\n cleanup();\n });\n reader.readAsDataURL(file);\n }\n else {\n resolve({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n cleanup();\n }\n });\n }\n input.accept = 'image/*';\n input.capture = true;\n if (options.source === CameraSource.Photos ||\n options.source === CameraSource.Prompt) {\n input.removeAttribute('capture');\n }\n else if (options.direction === CameraDirection.Front) {\n input.capture = 'user';\n }\n else if (options.direction === CameraDirection.Rear) {\n input.capture = 'environment';\n }\n input.click();\n }\n multipleFileInputExperience(resolve) {\n let input = document.querySelector('#_capacitor-camera-input-multiple');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input-multiple';\n input.type = 'file';\n input.hidden = true;\n input.multiple = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const photos = [];\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < input.files.length; i++) {\n const file = input.files[i];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n photos.push({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n }\n resolve({ photos });\n cleanup();\n });\n }\n input.accept = 'image/*';\n input.click();\n }\n _getCameraPhoto(photo, options) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n const format = photo.type.split('/')[1];\n if (options.resultType === 'uri') {\n resolve({\n webPath: URL.createObjectURL(photo),\n format: format,\n saved: false,\n });\n }\n else {\n reader.readAsDataURL(photo);\n reader.onloadend = () => {\n const r = reader.result;\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: r,\n format: format,\n saved: false,\n });\n }\n else {\n resolve({\n base64String: r.split(',')[1],\n format: format,\n saved: false,\n });\n }\n };\n reader.onerror = e => {\n reject(e);\n };\n }\n });\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n try {\n // https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query\n // the specific permissions that are supported varies among browsers that implement the\n // permissions API, so we need a try/catch in case 'camera' is invalid\n const permission = await window.navigator.permissions.query({\n name: 'camera',\n });\n return {\n camera: permission.state,\n photos: 'granted',\n };\n }\n catch (_a) {\n throw this.unavailable('Camera permissions are not available in this browser');\n }\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Camera = new CameraWeb();\nexport { Camera };\n//# sourceMappingURL=web.js.map"],"names":["CameraSource","CameraDirection","CameraResultType","Camera","registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;;;;AAAWA,8BAAa;AACxB,CAAC,UAAU,YAAY,EAAE;AACzB;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC;AACA;AACA;AACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AACtC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC,CAAC;AAC7BC,iCAAgB;AAC3B,CAAC,UAAU,eAAe,EAAE;AAC5B,IAAI,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;AACrC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,kCAAiB;AAC5B,CAAC,UAAU,gBAAgB,EAAE;AAC7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;AACpC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;AAC1C,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;AAC5C,CAAC,EAAEA,wBAAgB,KAAKA,wBAAgB,GAAG,EAAE,CAAC,CAAC;;ACxB1C,MAACC,QAAM,GAAGC,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC3D,CAAC;;ACDM,MAA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  }
67
67
  });
68
68
  }
69
+ async pickImages(_options) {
70
+ // eslint-disable-next-line no-async-promise-executor
71
+ return new Promise(async (resolve) => {
72
+ this.multipleFileInputExperience(resolve);
73
+ });
74
+ }
69
75
  async cameraExperience(options, resolve, reject) {
70
76
  if (customElements.get('pwa-camera-modal')) {
71
77
  const cameraModal = document.createElement('pwa-camera-modal');
78
+ cameraModal.facingMode =
79
+ options.direction === exports.CameraDirection.Front ? 'user' : 'environment';
72
80
  document.body.appendChild(cameraModal);
73
81
  try {
74
82
  await cameraModal.componentOnReady();
@@ -162,6 +170,43 @@ var capacitorCamera = (function (exports, core) {
162
170
  }
163
171
  input.click();
164
172
  }
173
+ multipleFileInputExperience(resolve) {
174
+ let input = document.querySelector('#_capacitor-camera-input-multiple');
175
+ const cleanup = () => {
176
+ var _a;
177
+ (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);
178
+ };
179
+ if (!input) {
180
+ input = document.createElement('input');
181
+ input.id = '_capacitor-camera-input-multiple';
182
+ input.type = 'file';
183
+ input.hidden = true;
184
+ input.multiple = true;
185
+ document.body.appendChild(input);
186
+ input.addEventListener('change', (_e) => {
187
+ const photos = [];
188
+ // eslint-disable-next-line @typescript-eslint/prefer-for-of
189
+ for (let i = 0; i < input.files.length; i++) {
190
+ const file = input.files[i];
191
+ let format = 'jpeg';
192
+ if (file.type === 'image/png') {
193
+ format = 'png';
194
+ }
195
+ else if (file.type === 'image/gif') {
196
+ format = 'gif';
197
+ }
198
+ photos.push({
199
+ webPath: URL.createObjectURL(file),
200
+ format: format,
201
+ });
202
+ }
203
+ resolve({ photos });
204
+ cleanup();
205
+ });
206
+ }
207
+ input.accept = 'image/*';
208
+ input.click();
209
+ }
165
210
  _getCameraPhoto(photo, options) {
166
211
  return new Promise((resolve, reject) => {
167
212
  const reader = new FileReader();
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CameraSource;\n(function (CameraSource) {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n CameraSource[\"Prompt\"] = \"PROMPT\";\n /**\n * Take a new photo using the camera.\n */\n CameraSource[\"Camera\"] = \"CAMERA\";\n /**\n * Pick an existing photo fron the gallery or photo album.\n */\n CameraSource[\"Photos\"] = \"PHOTOS\";\n})(CameraSource || (CameraSource = {}));\nexport var CameraDirection;\n(function (CameraDirection) {\n CameraDirection[\"Rear\"] = \"REAR\";\n CameraDirection[\"Front\"] = \"FRONT\";\n})(CameraDirection || (CameraDirection = {}));\nexport var CameraResultType;\n(function (CameraResultType) {\n CameraResultType[\"Uri\"] = \"uri\";\n CameraResultType[\"Base64\"] = \"base64\";\n CameraResultType[\"DataUrl\"] = \"dataUrl\";\n})(CameraResultType || (CameraResultType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Camera = registerPlugin('Camera', {\n web: () => import('./web').then(m => new m.CameraWeb()),\n});\nexport * from './definitions';\nexport { Camera };\n//# sourceMappingURL=index.js.map","import { WebPlugin, CapacitorException } from '@capacitor/core';\nimport { CameraSource, CameraDirection } from './definitions';\nexport class CameraWeb extends WebPlugin {\n async getPhoto(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n if (options.webUseInput || options.source === CameraSource.Photos) {\n this.fileInputExperience(options, resolve);\n }\n else if (options.source === CameraSource.Prompt) {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.promptLabelHeader || 'Photo';\n actionSheet.cancelable = false;\n actionSheet.options = [\n { title: options.promptLabelPhoto || 'From Photos' },\n { title: options.promptLabelPicture || 'Take Picture' },\n ];\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n if (selection === 0) {\n this.fileInputExperience(options, resolve);\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n async cameraExperience(options, resolve, reject) {\n if (customElements.get('pwa-camera-modal')) {\n const cameraModal = document.createElement('pwa-camera-modal');\n document.body.appendChild(cameraModal);\n try {\n await cameraModal.componentOnReady();\n cameraModal.addEventListener('onPhoto', async (e) => {\n const photo = e.detail;\n if (photo === null) {\n reject(new CapacitorException('User cancelled photos app'));\n }\n else if (photo instanceof Error) {\n reject(photo);\n }\n else {\n resolve(await this._getCameraPhoto(photo, options));\n }\n cameraModal.dismiss();\n document.body.removeChild(cameraModal);\n });\n cameraModal.present();\n }\n catch (e) {\n this.fileInputExperience(options, resolve);\n }\n }\n else {\n console.error(`Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/pwa-elements.`);\n this.fileInputExperience(options, resolve);\n }\n }\n fileInputExperience(options, resolve) {\n let input = document.querySelector('#_capacitor-camera-input');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input';\n input.type = 'file';\n input.hidden = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const file = input.files[0];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n if (options.resultType === 'dataUrl' ||\n options.resultType === 'base64') {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: reader.result,\n format,\n });\n }\n else if (options.resultType === 'base64') {\n const b64 = reader.result.split(',')[1];\n resolve({\n base64String: b64,\n format,\n });\n }\n cleanup();\n });\n reader.readAsDataURL(file);\n }\n else {\n resolve({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n cleanup();\n }\n });\n }\n input.accept = 'image/*';\n input.capture = true;\n if (options.source === CameraSource.Photos ||\n options.source === CameraSource.Prompt) {\n input.removeAttribute('capture');\n }\n else if (options.direction === CameraDirection.Front) {\n input.capture = 'user';\n }\n else if (options.direction === CameraDirection.Rear) {\n input.capture = 'environment';\n }\n input.click();\n }\n _getCameraPhoto(photo, options) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n const format = photo.type.split('/')[1];\n if (options.resultType === 'uri') {\n resolve({\n webPath: URL.createObjectURL(photo),\n format: format,\n saved: false,\n });\n }\n else {\n reader.readAsDataURL(photo);\n reader.onloadend = () => {\n const r = reader.result;\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: r,\n format: format,\n saved: false,\n });\n }\n else {\n resolve({\n base64String: r.split(',')[1],\n format: format,\n saved: false,\n });\n }\n };\n reader.onerror = e => {\n reject(e);\n };\n }\n });\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n try {\n // https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query\n // the specific permissions that are supported varies among browsers that implement the\n // permissions API, so we need a try/catch in case 'camera' is invalid\n const permission = await window.navigator.permissions.query({\n name: 'camera',\n });\n return {\n camera: permission.state,\n photos: 'granted',\n };\n }\n catch (_a) {\n throw this.unavailable('Camera permissions are not available in this browser');\n }\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Camera = new CameraWeb();\nexport { Camera };\n//# sourceMappingURL=web.js.map"],"names":["CameraSource","CameraDirection","CameraResultType","Camera","registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;AAAWA,kCAAa;IACxB,CAAC,UAAU,YAAY,EAAE;IACzB;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,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AAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACzD,4BAA4B,MAAM,EAAE,MAAM;IAC1C,4BAA4B,KAAK,EAAE,KAAK;IACxC,yBAAyB,CAAC,CAAC;IAC3B,qBAAqB;IACrB,iBAAiB,CAAC;IAClB,gBAAgB,MAAM,CAAC,OAAO,GAAG,CAAC,IAAI;IACtC,oBAAoB,MAAM,CAAC,CAAC,CAAC,CAAC;IAC9B,iBAAiB,CAAC;IAClB,aAAa;IACb,SAAS,CAAC,CAAC;IACX,KAAK;IACL,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE;IACxE,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,+CAA+C,CAAC,CAAC;IACpF,SAAS;IACT,QAAQ,IAAI;IACZ;IACA;IACA;IACA,YAAY,MAAM,UAAU,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC;IACxE,gBAAgB,IAAI,EAAE,QAAQ;IAC9B,aAAa,CAAC,CAAC;IACf,YAAY,OAAO;IACnB,gBAAgB,MAAM,EAAE,UAAU,CAAC,KAAK;IACxC,gBAAgB,MAAM,EAAE,SAAS;IACjC,aAAa,CAAC;IACd,SAAS;IACT,QAAQ,OAAO,EAAE,EAAE;IACnB,YAAY,MAAM,IAAI,CAAC,WAAW,CAAC,sDAAsD,CAAC,CAAC;IAC3F,SAAS;IACT,KAAK;IACL,IAAI,MAAM,kBAAkB,GAAG;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,yBAAyB,CAAC,CAAC;IAC5D,KAAK;IACL,CAAC;IACD,MAAM,MAAM,GAAG,IAAI,SAAS,EAAE;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["export var CameraSource;\n(function (CameraSource) {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n CameraSource[\"Prompt\"] = \"PROMPT\";\n /**\n * Take a new photo using the camera.\n */\n CameraSource[\"Camera\"] = \"CAMERA\";\n /**\n * Pick an existing photo fron the gallery or photo album.\n */\n CameraSource[\"Photos\"] = \"PHOTOS\";\n})(CameraSource || (CameraSource = {}));\nexport var CameraDirection;\n(function (CameraDirection) {\n CameraDirection[\"Rear\"] = \"REAR\";\n CameraDirection[\"Front\"] = \"FRONT\";\n})(CameraDirection || (CameraDirection = {}));\nexport var CameraResultType;\n(function (CameraResultType) {\n CameraResultType[\"Uri\"] = \"uri\";\n CameraResultType[\"Base64\"] = \"base64\";\n CameraResultType[\"DataUrl\"] = \"dataUrl\";\n})(CameraResultType || (CameraResultType = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst Camera = registerPlugin('Camera', {\n web: () => import('./web').then(m => new m.CameraWeb()),\n});\nexport * from './definitions';\nexport { Camera };\n//# sourceMappingURL=index.js.map","import { WebPlugin, CapacitorException } from '@capacitor/core';\nimport { CameraSource, CameraDirection } from './definitions';\nexport class CameraWeb extends WebPlugin {\n async getPhoto(options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n if (options.webUseInput || options.source === CameraSource.Photos) {\n this.fileInputExperience(options, resolve);\n }\n else if (options.source === CameraSource.Prompt) {\n let actionSheet = document.querySelector('pwa-action-sheet');\n if (!actionSheet) {\n actionSheet = document.createElement('pwa-action-sheet');\n document.body.appendChild(actionSheet);\n }\n actionSheet.header = options.promptLabelHeader || 'Photo';\n actionSheet.cancelable = false;\n actionSheet.options = [\n { title: options.promptLabelPhoto || 'From Photos' },\n { title: options.promptLabelPicture || 'Take Picture' },\n ];\n actionSheet.addEventListener('onSelection', async (e) => {\n const selection = e.detail;\n if (selection === 0) {\n this.fileInputExperience(options, resolve);\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n else {\n this.cameraExperience(options, resolve, reject);\n }\n });\n }\n async pickImages(_options) {\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve) => {\n this.multipleFileInputExperience(resolve);\n });\n }\n async cameraExperience(options, resolve, reject) {\n if (customElements.get('pwa-camera-modal')) {\n const cameraModal = document.createElement('pwa-camera-modal');\n cameraModal.facingMode =\n options.direction === CameraDirection.Front ? 'user' : 'environment';\n document.body.appendChild(cameraModal);\n try {\n await cameraModal.componentOnReady();\n cameraModal.addEventListener('onPhoto', async (e) => {\n const photo = e.detail;\n if (photo === null) {\n reject(new CapacitorException('User cancelled photos app'));\n }\n else if (photo instanceof Error) {\n reject(photo);\n }\n else {\n resolve(await this._getCameraPhoto(photo, options));\n }\n cameraModal.dismiss();\n document.body.removeChild(cameraModal);\n });\n cameraModal.present();\n }\n catch (e) {\n this.fileInputExperience(options, resolve);\n }\n }\n else {\n console.error(`Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/pwa-elements.`);\n this.fileInputExperience(options, resolve);\n }\n }\n fileInputExperience(options, resolve) {\n let input = document.querySelector('#_capacitor-camera-input');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input';\n input.type = 'file';\n input.hidden = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const file = input.files[0];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n if (options.resultType === 'dataUrl' ||\n options.resultType === 'base64') {\n const reader = new FileReader();\n reader.addEventListener('load', () => {\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: reader.result,\n format,\n });\n }\n else if (options.resultType === 'base64') {\n const b64 = reader.result.split(',')[1];\n resolve({\n base64String: b64,\n format,\n });\n }\n cleanup();\n });\n reader.readAsDataURL(file);\n }\n else {\n resolve({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n cleanup();\n }\n });\n }\n input.accept = 'image/*';\n input.capture = true;\n if (options.source === CameraSource.Photos ||\n options.source === CameraSource.Prompt) {\n input.removeAttribute('capture');\n }\n else if (options.direction === CameraDirection.Front) {\n input.capture = 'user';\n }\n else if (options.direction === CameraDirection.Rear) {\n input.capture = 'environment';\n }\n input.click();\n }\n multipleFileInputExperience(resolve) {\n let input = document.querySelector('#_capacitor-camera-input-multiple');\n const cleanup = () => {\n var _a;\n (_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);\n };\n if (!input) {\n input = document.createElement('input');\n input.id = '_capacitor-camera-input-multiple';\n input.type = 'file';\n input.hidden = true;\n input.multiple = true;\n document.body.appendChild(input);\n input.addEventListener('change', (_e) => {\n const photos = [];\n // eslint-disable-next-line @typescript-eslint/prefer-for-of\n for (let i = 0; i < input.files.length; i++) {\n const file = input.files[i];\n let format = 'jpeg';\n if (file.type === 'image/png') {\n format = 'png';\n }\n else if (file.type === 'image/gif') {\n format = 'gif';\n }\n photos.push({\n webPath: URL.createObjectURL(file),\n format: format,\n });\n }\n resolve({ photos });\n cleanup();\n });\n }\n input.accept = 'image/*';\n input.click();\n }\n _getCameraPhoto(photo, options) {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n const format = photo.type.split('/')[1];\n if (options.resultType === 'uri') {\n resolve({\n webPath: URL.createObjectURL(photo),\n format: format,\n saved: false,\n });\n }\n else {\n reader.readAsDataURL(photo);\n reader.onloadend = () => {\n const r = reader.result;\n if (options.resultType === 'dataUrl') {\n resolve({\n dataUrl: r,\n format: format,\n saved: false,\n });\n }\n else {\n resolve({\n base64String: r.split(',')[1],\n format: format,\n saved: false,\n });\n }\n };\n reader.onerror = e => {\n reject(e);\n };\n }\n });\n }\n async checkPermissions() {\n if (typeof navigator === 'undefined' || !navigator.permissions) {\n throw this.unavailable('Permissions API not available in this browser');\n }\n try {\n // https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query\n // the specific permissions that are supported varies among browsers that implement the\n // permissions API, so we need a try/catch in case 'camera' is invalid\n const permission = await window.navigator.permissions.query({\n name: 'camera',\n });\n return {\n camera: permission.state,\n photos: 'granted',\n };\n }\n catch (_a) {\n throw this.unavailable('Camera permissions are not available in this browser');\n }\n }\n async requestPermissions() {\n throw this.unimplemented('Not implemented on web.');\n }\n}\nconst Camera = new CameraWeb();\nexport { Camera };\n//# sourceMappingURL=web.js.map"],"names":["CameraSource","CameraDirection","CameraResultType","Camera","registerPlugin","WebPlugin","CapacitorException"],"mappings":";;;AAAWA,kCAAa;IACxB,CAAC,UAAU,YAAY,EAAE;IACzB;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC;IACA;IACA;IACA,IAAI,YAAY,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IACtC,CAAC,EAAEA,oBAAY,KAAKA,oBAAY,GAAG,EAAE,CAAC,CAAC,CAAC;AAC7BC,qCAAgB;IAC3B,CAAC,UAAU,eAAe,EAAE;IAC5B,IAAI,eAAe,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACrC,IAAI,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACvC,CAAC,EAAEA,uBAAe,KAAKA,uBAAe,GAAG,EAAE,CAAC,CAAC,CAAC;AACnCC,sCAAiB;IAC5B,CAAC,UAAU,gBAAgB,EAAE;IAC7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;IACpC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC;IAC1C,IAAI,gBAAgB,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IAC5C,CAAC,EAAEA,wBAAgB,KAAKA,wBAAgB,GAAG,EAAE,CAAC,CAAC;;ACxB1C,UAACC,QAAM,GAAGC,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GA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M,MAAM,GAAG,IAAI,SAAS,EAAE;;;;;;;;;;;;;;;;;;"}
@@ -3,6 +3,7 @@
3
3
 
4
4
  CAP_PLUGIN(CAPCameraPlugin, "Camera",
5
5
  CAP_PLUGIN_METHOD(getPhoto, CAPPluginReturnPromise);
6
+ CAP_PLUGIN_METHOD(pickImages, CAPPluginReturnPromise);
6
7
  CAP_PLUGIN_METHOD(checkPermissions, CAPPluginReturnPromise);
7
8
  CAP_PLUGIN_METHOD(requestPermissions, CAPPluginReturnPromise);
8
9
  )
@@ -9,6 +9,7 @@ public class CameraPlugin: CAPPlugin {
9
9
  private var settings = CameraSettings()
10
10
  private let defaultSource = CameraSource.prompt
11
11
  private let defaultDirection = CameraDirection.rear
12
+ private var multiple = false
12
13
 
13
14
  private var imageCounter = 0
14
15
 
@@ -66,6 +67,7 @@ public class CameraPlugin: CAPPlugin {
66
67
  }
67
68
 
68
69
  @objc func getPhoto(_ call: CAPPluginCall) {
70
+ self.multiple = false
69
71
  self.call = call
70
72
  self.settings = cameraSettings(from: call)
71
73
 
@@ -89,6 +91,15 @@ public class CameraPlugin: CAPPlugin {
89
91
  }
90
92
  }
91
93
 
94
+ @objc func pickImages(_ call: CAPPluginCall) {
95
+ self.multiple = true
96
+ self.call = call
97
+ self.settings = cameraSettings(from: call)
98
+ DispatchQueue.main.async {
99
+ self.showPhotos()
100
+ }
101
+ }
102
+
92
103
  private func checkUsageDescriptions() -> String? {
93
104
  if let dict = Bundle.main.infoDictionary {
94
105
  for key in CameraPropertyListKeys.allCases where dict[key.rawValue] == nil {
@@ -164,24 +175,56 @@ extension CameraPlugin: PHPickerViewControllerDelegate {
164
175
  self.call?.reject("User cancelled photos app")
165
176
  return
166
177
  }
167
- guard result.itemProvider.canLoadObject(ofClass: UIImage.self) else {
168
- self.call?.reject("Error loading image")
169
- return
170
- }
171
- // extract the image
172
- result.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] (reading, _) in
173
- if let image = reading as? UIImage {
174
- var asset: PHAsset?
175
- if let assetId = result.assetIdentifier {
176
- asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
177
- }
178
- if let processedImage = self?.processedImage(from: image, with: asset?.imageData) {
179
- self?.returnProcessedImage(processedImage)
178
+ if multiple {
179
+ var images: [ProcessedImage] = []
180
+ var processedCount = 0
181
+ for img in results {
182
+ guard img.itemProvider.canLoadObject(ofClass: UIImage.self) else {
183
+ self.call?.reject("Error loading image")
180
184
  return
181
185
  }
186
+ // extract the image
187
+ img.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] (reading, _) in
188
+ if let image = reading as? UIImage {
189
+ var asset: PHAsset?
190
+ if let assetId = img.assetIdentifier {
191
+ asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
192
+ }
193
+ if let processedImage = self?.processedImage(from: image, with: asset?.imageData) {
194
+ images.append(processedImage)
195
+ }
196
+ processedCount += 1
197
+ if processedCount == results.count {
198
+ self?.returnImages(images)
199
+ }
200
+ } else {
201
+ self?.call?.reject("Error loading image")
202
+ }
203
+ }
204
+ }
205
+
206
+ } else {
207
+ guard result.itemProvider.canLoadObject(ofClass: UIImage.self) else {
208
+ self.call?.reject("Error loading image")
209
+ return
210
+ }
211
+ // extract the image
212
+ result.itemProvider.loadObject(ofClass: UIImage.self) { [weak self] (reading, _) in
213
+ if let image = reading as? UIImage {
214
+ var asset: PHAsset?
215
+ if let assetId = result.assetIdentifier {
216
+ asset = PHAsset.fetchAssets(withLocalIdentifiers: [assetId], options: nil).firstObject
217
+ }
218
+ if var processedImage = self?.processedImage(from: image, with: asset?.imageData) {
219
+ processedImage.flags = .gallery
220
+ self?.returnProcessedImage(processedImage)
221
+ return
222
+ }
223
+ }
224
+ self?.call?.reject("Error loading image")
182
225
  }
183
- self?.call?.reject("Error loading image")
184
226
  }
227
+
185
228
  }
186
229
  }
187
230
 
@@ -192,7 +235,31 @@ private extension CameraPlugin {
192
235
  return
193
236
  }
194
237
 
195
- if settings.resultType == CameraResultType.base64 {
238
+ if settings.resultType == CameraResultType.uri || multiple {
239
+ guard let fileURL = try? saveTemporaryImage(jpeg),
240
+ let webURL = bridge?.portablePath(fromLocalURL: fileURL) else {
241
+ call?.reject("Unable to get portable path to file")
242
+ return
243
+ }
244
+ if self.multiple {
245
+ call?.resolve([
246
+ "photos": [[
247
+ "path": fileURL.absoluteString,
248
+ "exif": processedImage.exifData,
249
+ "webPath": webURL.absoluteString,
250
+ "format": "jpeg"
251
+ ]]
252
+ ])
253
+ return
254
+ }
255
+ call?.resolve([
256
+ "path": fileURL.absoluteString,
257
+ "exif": processedImage.exifData,
258
+ "webPath": webURL.absoluteString,
259
+ "format": "jpeg",
260
+ "saved": isSaved
261
+ ])
262
+ } else if settings.resultType == CameraResultType.base64 {
196
263
  self.call?.resolve([
197
264
  "base64String": jpeg.base64EncodedString(),
198
265
  "exif": processedImage.exifData,
@@ -206,20 +273,33 @@ private extension CameraPlugin {
206
273
  "format": "jpeg",
207
274
  "saved": isSaved
208
275
  ])
209
- } else if settings.resultType == CameraResultType.uri {
276
+ }
277
+ }
278
+
279
+ func returnImages(_ processedImages: [ProcessedImage]) {
280
+ var photos: [PluginCallResultData] = []
281
+ for processedImage in processedImages {
282
+ guard let jpeg = processedImage.generateJPEG(with: settings.jpegQuality) else {
283
+ self.call?.reject("Unable to convert image to jpeg")
284
+ return
285
+ }
286
+
210
287
  guard let fileURL = try? saveTemporaryImage(jpeg),
211
288
  let webURL = bridge?.portablePath(fromLocalURL: fileURL) else {
212
289
  call?.reject("Unable to get portable path to file")
213
290
  return
214
291
  }
215
- call?.resolve([
292
+
293
+ photos.append([
216
294
  "path": fileURL.absoluteString,
217
295
  "exif": processedImage.exifData,
218
296
  "webPath": webURL.absoluteString,
219
- "format": "jpeg",
220
- "saved": isSaved
297
+ "format": "jpeg"
221
298
  ])
222
299
  }
300
+ call?.resolve([
301
+ "photos": photos
302
+ ])
223
303
  }
224
304
 
225
305
  func returnProcessedImage(_ processedImage: ProcessedImage) {
@@ -350,7 +430,7 @@ private extension CameraPlugin {
350
430
  @available(iOS 14, *)
351
431
  func presentPhotoPicker() {
352
432
  var configuration = PHPickerConfiguration(photoLibrary: PHPhotoLibrary.shared())
353
- configuration.selectionLimit = 1
433
+ configuration.selectionLimit = self.multiple ? (self.call?.getInt("limit") ?? 0) : 1
354
434
  configuration.filter = .images
355
435
  let picker = PHPickerViewController(configuration: configuration)
356
436
  picker.delegate = self
@@ -2,9 +2,9 @@ import UIKit
2
2
 
3
3
  class ImageSaver: NSObject {
4
4
 
5
- var onResult: ((Error?)->Void) = {_ in }
5
+ var onResult: ((Error?) -> Void) = {_ in }
6
6
 
7
- init(image: UIImage, onResult:@escaping ((Error?)->Void)) {
7
+ init(image: UIImage, onResult:@escaping ((Error?) -> Void)) {
8
8
  self.onResult = onResult
9
9
  super.init()
10
10
  UIImageWriteToSavedPhotosAlbum(image, self, #selector(saveResult), nil)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capacitor/camera",
3
- "version": "1.1.2",
3
+ "version": "1.2.3",
4
4
  "description": "The Camera API provides the ability to take a photo with the camera or choose an existing one from the photo album.",
5
5
  "main": "dist/plugin.cjs.js",
6
6
  "module": "dist/esm/index.js",
@@ -33,7 +33,7 @@
33
33
  "verify:android": "cd android && ./gradlew clean build test && cd ..",
34
34
  "verify:web": "npm run build",
35
35
  "lint": "npm run eslint && npm run prettier -- --check && npm run swiftlint -- lint",
36
- "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- autocorrect --format",
36
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
37
37
  "eslint": "eslint . --ext ts",
38
38
  "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
39
39
  "swiftlint": "node-swiftlint",
@@ -79,5 +79,5 @@
79
79
  "publishConfig": {
80
80
  "access": "public"
81
81
  },
82
- "gitHead": "eadbffd4bf9f0859bd301a639ab4e0c3337ea8db"
82
+ "gitHead": "e5b333320426ee120d4504c68c02bd5538b21c51"
83
83
  }