@capacitor/camera 8.1.0-test.250320251731 → 8.2.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.
@@ -150,23 +150,16 @@ export interface TakePhotoOptions {
150
150
  */
151
151
  cameraDirection?: CameraDirection;
152
152
  /**
153
- * Whether to allow the user to crop or make small edits.
154
- * Note: This option is only supported on Android and iOS.
155
- * @default false
156
- *
157
- * @since 8.1.0
158
- */
159
- allowEdit?: boolean;
160
- /**
161
- * If `true`, will use an in-app editor for photo edition.
162
- * If `false`, will open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available.
163
- * Only applicable with `allowEdit` set to true.
164
- * Note: This option is only supported on Android and iOS.
153
+ * Determines if and how the user can edit the photo.
154
+ * - 'in-app': Use an in-app editor for photo edition.
155
+ * - 'external': Open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available. Note: iOS does not support external editing and will use 'in-app' instead.
156
+ * - 'no': No editing allowed.
157
+ * Not available on Web.
158
+ * @default 'no'
165
159
  *
166
- * @default true
167
160
  * @since 8.1.0
168
161
  */
169
- editInApp?: boolean;
162
+ editable?: 'in-app' | 'external' | 'no';
170
163
  /**
171
164
  * iOS only: The presentation style of the Camera.
172
165
  * @default 'fullscreen'
@@ -187,7 +180,6 @@ export interface TakePhotoOptions {
187
180
  /**
188
181
  * Whether or not MediaResult should include its metadata.
189
182
  * If an error occurs when obtaining the metadata, it will return empty.
190
- * Note: This option is only supported on Android and iOS.
191
183
  * @default false
192
184
  *
193
185
  * @since 8.1.0
@@ -257,31 +249,23 @@ export interface ChooseFromGalleryOptions {
257
249
  /**
258
250
  * Whether or not MediaResult should include its metadata.
259
251
  * If an error occurs when obtaining the metadata, it will return empty.
260
- * Note: This option is only supported on Android and iOS.
261
252
  * @default false
262
253
  *
263
254
  * @since 8.1.0
264
255
  */
265
256
  includeMetadata?: boolean;
266
257
  /**
267
- * Whether to allow the user to crop or make small edits.
258
+ * Determines if and how the user can edit the photo.
259
+ * - 'in-app': Use an in-app editor for photo edition.
260
+ * - 'external': Open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available. Note: iOS does not support external editing and will use 'in-app' instead.
261
+ * - 'no': No editing allowed.
268
262
  * Only applicable for `MediaTypeSelection.Photo` and `allowMultipleSelection` set to `false`.
269
- * Note: This option is only supported on Android and iOS.
270
- * @default false
263
+ * Not available on Web.
264
+ * @default 'no'
271
265
  *
272
266
  * @since 8.1.0
273
267
  */
274
- allowEdit?: boolean;
275
- /**
276
- * If `true`, will use an in-app editor for photo edition.
277
- * If `false`, will open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available.
278
- * Only applicable with `allowEdit` set to true.
279
- * Note: This option is only supported on Android and iOS.
280
- *
281
- * @default true
282
- * @since 8.1.0
283
- */
284
- editInApp?: boolean;
268
+ editable?: 'in-app' | 'external' | 'no';
285
269
  /**
286
270
  * iOS only: The presentation style of media picker.
287
271
  * @default 'fullscreen'
@@ -354,7 +338,6 @@ export interface EditURIPhotoOptions {
354
338
  /**
355
339
  * Whether or not MediaResult should include its metadata.
356
340
  * If an error occurs when obtaining the metadata, it will return empty.
357
- * Note: This option is only supported on Android and iOS.
358
341
  * @default false
359
342
  *
360
343
  * @since 8.1.0
@@ -394,6 +377,7 @@ export interface MediaResult {
394
377
  /**
395
378
  * Returns the thumbnail of the media, base64 encoded.
396
379
  * On Web, for `MediaType.Photo`, the full image is returned here, also base64 encoded.
380
+ * On Web, for `MediaType.Video`, a full-resolution JPEG frame captured from the video is returned, base64 encoded at 80% quality.
397
381
  *
398
382
  * @since 8.1.0
399
383
  */
@@ -424,15 +408,13 @@ export interface MediaResult {
424
408
  }
425
409
  export interface MediaMetadata {
426
410
  /**
427
- * File size of the media, in bytes
428
- * Not available on Web.
411
+ * File size of the media, in bytes.
429
412
  *
430
413
  * @since 8.1.0
431
414
  */
432
415
  size?: number;
433
416
  /**
434
417
  * Only applicable for `MediaType.Video` - the duration of the media, in seconds.
435
- * Not available on Web.
436
418
  *
437
419
  * @since 8.1.0
438
420
  */
@@ -440,8 +422,10 @@ export interface MediaMetadata {
440
422
  /**
441
423
  * The format of the image, ex: jpeg, png, mp4.
442
424
  *
425
+ * Android and iOS may return 'jpg' instead of 'jpeg'. The format is the same, just with a different name.
426
+ * Please compare against both 'jpeg' and 'jpg' when checking if the format of the returned media is JPEG.
443
427
  * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.
444
- * gif is only supported for `chooseFromGallery`, and only if `webUseInput` option is set to `true`.
428
+ * gif is only supported for `chooseFromGallery` on Web.
445
429
  *
446
430
  * @since 8.1.0
447
431
  */
@@ -451,17 +435,18 @@ export interface MediaMetadata {
451
435
  *
452
436
  * @since 8.1.0
453
437
  */
454
- resolution: string;
438
+ resolution?: string;
455
439
  /**
456
440
  * The date and time the media was created, in ISO 8601 format.
457
441
  * If creation date is not available (e.g. Android 7 and below), the last modified date is returned.
458
- * Not available on web.
442
+ * For Web, the last modified date is always returned.
459
443
  *
460
444
  * @since 8.1.0
461
445
  */
462
446
  creationDate?: string;
463
447
  /**
464
- * Exif data, if any, retreived from the media item.
448
+ * Exif data, if any, retrieved from the media item.
449
+ * Only available for `MediaType.Photo`.
465
450
  * Not available on Web.
466
451
  *
467
452
  * @since 8.1.0
@@ -799,3 +784,115 @@ export type CameraPhoto = Photo;
799
784
  * @since 1.0.0
800
785
  */
801
786
  export type CameraOptions = ImageOptions;
787
+ /**
788
+ * Error codes returned by the Camera plugin.
789
+ * These values match the `code` field on rejected promises.
790
+ *
791
+ * @since 8.2.0
792
+ */
793
+ export declare enum CameraErrorCode {
794
+ /**
795
+ * Camera access was denied by the user.
796
+ */
797
+ CameraPermissionDenied = "OS-PLUG-CAMR-0003",
798
+ /**
799
+ * Photo library / gallery access was denied by the user.
800
+ */
801
+ GalleryPermissionDenied = "OS-PLUG-CAMR-0005",
802
+ /**
803
+ * No camera hardware is available on the device.
804
+ */
805
+ NoCameraAvailable = "OS-PLUG-CAMR-0007",
806
+ /**
807
+ * The user cancelled the take photo action.
808
+ */
809
+ TakePhotoCancelled = "OS-PLUG-CAMR-0006",
810
+ /**
811
+ * Failed to take photo.
812
+ */
813
+ TakePhotoFailed = "OS-PLUG-CAMR-0010",
814
+ /**
815
+ * The take photo action received invalid arguments.
816
+ * @platform ios
817
+ */
818
+ TakePhotoInvalidArguments = "OS-PLUG-CAMR-0014",
819
+ /**
820
+ * The selected file contains invalid image data.
821
+ * @platform ios
822
+ */
823
+ InvalidImageData = "OS-PLUG-CAMR-0008",
824
+ /**
825
+ * Failed to edit image.
826
+ */
827
+ EditPhotoFailed = "OS-PLUG-CAMR-0009",
828
+ /**
829
+ * The user cancelled the edit photo action.
830
+ */
831
+ EditPhotoCancelled = "OS-PLUG-CAMR-0013",
832
+ /**
833
+ * The URI parameter for editing is empty.
834
+ * @platform android
835
+ */
836
+ EditPhotoEmptyUri = "OS-PLUG-CAMR-0024",
837
+ /**
838
+ * Failed to retrieve an image from the gallery.
839
+ */
840
+ ImageNotFound = "OS-PLUG-CAMR-0011",
841
+ /**
842
+ * Failed to process the selected image.
843
+ */
844
+ ProcessImageFailed = "OS-PLUG-CAMR-0012",
845
+ /**
846
+ * Failed to choose media from the gallery.
847
+ */
848
+ ChooseMediaFailed = "OS-PLUG-CAMR-0018",
849
+ /**
850
+ * The user cancelled choosing media from the gallery.
851
+ */
852
+ ChooseMediaCancelled = "OS-PLUG-CAMR-0020",
853
+ /**
854
+ * Failed to retrieve the media file path.
855
+ * @platform android
856
+ */
857
+ MediaPathError = "OS-PLUG-CAMR-0021",
858
+ /**
859
+ * Failed to retrieve an image from the provided URI.
860
+ */
861
+ FetchImageFromUriFailed = "OS-PLUG-CAMR-0028",
862
+ /**
863
+ * Failed to record video.
864
+ */
865
+ RecordVideoFailed = "OS-PLUG-CAMR-0016",
866
+ /**
867
+ * The user cancelled the video recording.
868
+ */
869
+ RecordVideoCancelled = "OS-PLUG-CAMR-0017",
870
+ /**
871
+ * Failed to retrieve a video from the gallery.
872
+ * @platform ios
873
+ */
874
+ VideoNotFound = "OS-PLUG-CAMR-0025",
875
+ /**
876
+ * Failed to play video.
877
+ */
878
+ PlayVideoFailed = "OS-PLUG-CAMR-0023",
879
+ /**
880
+ * Failed to encode the media result.
881
+ * @platform ios
882
+ */
883
+ EncodeResultFailed = "OS-PLUG-CAMR-0019",
884
+ /**
885
+ * The selected file does not exist.
886
+ */
887
+ FileNotFound = "OS-PLUG-CAMR-0027",
888
+ /**
889
+ * Invalid argument provided to a plugin method.
890
+ * @platform android
891
+ */
892
+ InvalidArgument = "OS-PLUG-CAMR-0031",
893
+ /**
894
+ * A general plugin error occurred.
895
+ * @platform ios
896
+ */
897
+ GeneralError = "OS-PLUG-CAMR-0026"
898
+ }
@@ -48,4 +48,124 @@ export var EncodingType;
48
48
  EncodingType[EncodingType["JPEG"] = 0] = "JPEG";
49
49
  EncodingType[EncodingType["PNG"] = 1] = "PNG";
50
50
  })(EncodingType || (EncodingType = {}));
51
+ /**
52
+ * Error codes returned by the Camera plugin.
53
+ * These values match the `code` field on rejected promises.
54
+ *
55
+ * @since 8.2.0
56
+ */
57
+ export var CameraErrorCode;
58
+ (function (CameraErrorCode) {
59
+ // Permissions
60
+ /**
61
+ * Camera access was denied by the user.
62
+ */
63
+ CameraErrorCode["CameraPermissionDenied"] = "OS-PLUG-CAMR-0003";
64
+ /**
65
+ * Photo library / gallery access was denied by the user.
66
+ */
67
+ CameraErrorCode["GalleryPermissionDenied"] = "OS-PLUG-CAMR-0005";
68
+ /**
69
+ * No camera hardware is available on the device.
70
+ */
71
+ CameraErrorCode["NoCameraAvailable"] = "OS-PLUG-CAMR-0007";
72
+ // Take Photo
73
+ /**
74
+ * The user cancelled the take photo action.
75
+ */
76
+ CameraErrorCode["TakePhotoCancelled"] = "OS-PLUG-CAMR-0006";
77
+ /**
78
+ * Failed to take photo.
79
+ */
80
+ CameraErrorCode["TakePhotoFailed"] = "OS-PLUG-CAMR-0010";
81
+ /**
82
+ * The take photo action received invalid arguments.
83
+ * @platform ios
84
+ */
85
+ CameraErrorCode["TakePhotoInvalidArguments"] = "OS-PLUG-CAMR-0014";
86
+ // Edit Photo
87
+ /**
88
+ * The selected file contains invalid image data.
89
+ * @platform ios
90
+ */
91
+ CameraErrorCode["InvalidImageData"] = "OS-PLUG-CAMR-0008";
92
+ /**
93
+ * Failed to edit image.
94
+ */
95
+ CameraErrorCode["EditPhotoFailed"] = "OS-PLUG-CAMR-0009";
96
+ /**
97
+ * The user cancelled the edit photo action.
98
+ */
99
+ CameraErrorCode["EditPhotoCancelled"] = "OS-PLUG-CAMR-0013";
100
+ /**
101
+ * The URI parameter for editing is empty.
102
+ * @platform android
103
+ */
104
+ CameraErrorCode["EditPhotoEmptyUri"] = "OS-PLUG-CAMR-0024";
105
+ // Choose from Gallery
106
+ /**
107
+ * Failed to retrieve an image from the gallery.
108
+ */
109
+ CameraErrorCode["ImageNotFound"] = "OS-PLUG-CAMR-0011";
110
+ /**
111
+ * Failed to process the selected image.
112
+ */
113
+ CameraErrorCode["ProcessImageFailed"] = "OS-PLUG-CAMR-0012";
114
+ /**
115
+ * Failed to choose media from the gallery.
116
+ */
117
+ CameraErrorCode["ChooseMediaFailed"] = "OS-PLUG-CAMR-0018";
118
+ /**
119
+ * The user cancelled choosing media from the gallery.
120
+ */
121
+ CameraErrorCode["ChooseMediaCancelled"] = "OS-PLUG-CAMR-0020";
122
+ /**
123
+ * Failed to retrieve the media file path.
124
+ * @platform android
125
+ */
126
+ CameraErrorCode["MediaPathError"] = "OS-PLUG-CAMR-0021";
127
+ /**
128
+ * Failed to retrieve an image from the provided URI.
129
+ */
130
+ CameraErrorCode["FetchImageFromUriFailed"] = "OS-PLUG-CAMR-0028";
131
+ // Record Video
132
+ /**
133
+ * Failed to record video.
134
+ */
135
+ CameraErrorCode["RecordVideoFailed"] = "OS-PLUG-CAMR-0016";
136
+ /**
137
+ * The user cancelled the video recording.
138
+ */
139
+ CameraErrorCode["RecordVideoCancelled"] = "OS-PLUG-CAMR-0017";
140
+ /**
141
+ * Failed to retrieve a video from the gallery.
142
+ * @platform ios
143
+ */
144
+ CameraErrorCode["VideoNotFound"] = "OS-PLUG-CAMR-0025";
145
+ // Play Video
146
+ /**
147
+ * Failed to play video.
148
+ */
149
+ CameraErrorCode["PlayVideoFailed"] = "OS-PLUG-CAMR-0023";
150
+ // General
151
+ /**
152
+ * Failed to encode the media result.
153
+ * @platform ios
154
+ */
155
+ CameraErrorCode["EncodeResultFailed"] = "OS-PLUG-CAMR-0019";
156
+ /**
157
+ * The selected file does not exist.
158
+ */
159
+ CameraErrorCode["FileNotFound"] = "OS-PLUG-CAMR-0027";
160
+ /**
161
+ * Invalid argument provided to a plugin method.
162
+ * @platform android
163
+ */
164
+ CameraErrorCode["InvalidArgument"] = "OS-PLUG-CAMR-0031";
165
+ /**
166
+ * A general plugin error occurred.
167
+ * @platform ios
168
+ */
169
+ CameraErrorCode["GeneralError"] = "OS-PLUG-CAMR-0026";
170
+ })(CameraErrorCode || (CameraErrorCode = {}));
51
171
  //# sourceMappingURL=definitions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAuzBA;;;GAGG;AACH,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;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,2CAAS,CAAA;IACT,2CAAS,CAAA;AACX,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,6DAAS,CAAA;IACT,yDAAO,CAAA;AACT,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAED,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IACR,6CAAO,CAAA;AACT,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport type CameraPermissionState = PermissionState | 'limited';\n\nexport type CameraPermissionType = 'camera' | 'photos';\n\nexport interface PermissionStatus {\n camera: CameraPermissionState;\n photos: CameraPermissionState;\n}\n\nexport interface CameraPluginPermissions {\n permissions: CameraPermissionType[];\n}\n\nexport interface CameraPlugin {\n /**\n * Open the device's camera and allow the user to take a photo.\n *\n * @since 8.1.0\n */\n takePhoto(options: TakePhotoOptions): Promise<MediaResult>;\n\n /**\n * Open the device's camera and allow the user to record a video.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n recordVideo(options: RecordVideoOptions): Promise<MediaResult>;\n\n /**\n * Open a native video player.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n playVideo(options: PlayVideoOptions): Promise<void>;\n\n /**\n * Allow users to choose pictures, videos, or both, directly from their gallery.\n *\n * @since 8.1.0\n */\n chooseFromGallery(options: ChooseFromGalleryOptions): Promise<MediaResults>;\n\n /**\n * Open an in-app screen to edit a given photo using the provided base64 string.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n editPhoto(options: EditPhotoOptions): Promise<EditPhotoResult>;\n\n /**\n * Open an in-app screen to edit a photo using the provided URI.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n editURIPhoto(options: EditURIPhotoOptions): Promise<MediaResult>;\n\n /**\n * Allows the user to update their limited photo library selection.\n * Returns all the limited photos after the picker dismissal.\n * If instead the user gave full access to the photos it returns an empty array.\n *\n * @since 4.1.0\n */\n pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;\n /**\n * Return an array of photos selected from the limited photo library.\n *\n * @since 4.1.0\n */\n getLimitedLibraryPhotos(): Promise<GalleryPhotos>;\n\n /**\n * Check camera and photo album permissions\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and photo album permissions\n *\n * @since 1.0.0\n */\n requestPermissions(permissions?: CameraPluginPermissions): Promise<PermissionStatus>;\n\n /**\n * Prompt the user to pick a photo from an album, or take a new photo\n * with the camera.\n *\n * @since 1.0.0\n * @deprecated Use `takePhoto` for a camera photo, or `chooseFromGallery` to select from the gallery. For creating a prompt for the user to select which source, use `@capacitor/action-sheet` or any UI component of your choosing. Refer to the Camera API documentation for more information on migrating.\n */\n getPhoto(options: ImageOptions): Promise<Photo>;\n\n /**\n * Allows the user to pick multiple pictures from the photo gallery.\n *\n * @since 1.2.0\n * @deprecated Use `chooseFromGallery` instead. Refer to the Camera API documentation for more information on migrating.\n */\n pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;\n}\n\nexport interface TakePhotoOptions {\n /**\n * The quality of image to return, from 0-100.\n * Only applicable for `EncodingType.JPEG`.\n * Note: This option is only supported on Android and iOS.\n *\n * @default 100\n * @since 8.1.0\n */\n quality?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetHeight`.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetWidth?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetWidth`.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetHeight?: number;\n\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Note: This option is only supported on Android and iOS\n * @default true\n *\n * @since 8.1.0\n */\n correctOrientation?: boolean;\n\n /**\n * The encoding type for the captured photo - JPEG or PNG.\n * Note: This option is only supported on Android and iOS.\n * @default EncodingType.JPEG\n *\n * @since 8.1.0\n */\n encodingType?: EncodingType;\n\n /**\n * Whether to save the photo to the gallery.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n saveToGallery?: boolean;\n\n /**\n * iOS and Web only: The camera direction.\n * @default CameraDirection.Rear\n *\n * @since 8.1.0\n */\n cameraDirection?: CameraDirection;\n\n /**\n * Whether to allow the user to crop or make small edits.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n allowEdit?: boolean;\n\n /**\n * If `true`, will use an in-app editor for photo edition.\n * If `false`, will open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available.\n * Only applicable with `allowEdit` set to true.\n * Note: This option is only supported on Android and iOS.\n *\n * @default true\n * @since 8.1.0\n */\n editInApp?: boolean;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 8.1.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 8.1.0\n */\n webUseInput?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n}\n\nexport interface RecordVideoOptions {\n /**\n * Whether to save the video to the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n saveToGallery?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n\n /**\n * Whether the to store the video in persistent app storage or in temporary cache.\n * If you plan to use the returned `MediaResult#URI` across app launches, you may want to set to true.\n * Otherwise, you can set to false.\n * @default true\n *\n * @since 8.1.0\n */\n isPersistent?: boolean;\n}\n\nexport interface PlayVideoOptions {\n /**\n * The URI of the video to play.\n * You may use the `MediaResult#URI` returned from `recordVideo` or `chooseFromGallery` directly.\n *\n * @since 8.1.0\n */\n uri: string;\n}\n\nexport interface ChooseFromGalleryOptions {\n /**\n * The type of media to select. Can be pictures, videos, or both.\n * @default MediaTypeSelection.Photo\n *\n * @since 8.1.0\n */\n mediaType?: MediaTypeSelection;\n\n /**\n * Whether or not to allow selecting multiple media files from the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n allowMultipleSelection?: boolean;\n\n /**\n * The maximum number of media files that the user can choose.\n * Only applicable if `allowMultipleSelection` is `true`.\n * Any non-positive number will be treated as unlimited.\n * Note: This option is only supported on Android 13+ and iOS.\n * @default 0\n *\n * @since 8.1.0\n */\n limit?: number;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n\n /**\n * Whether to allow the user to crop or make small edits.\n * Only applicable for `MediaTypeSelection.Photo` and `allowMultipleSelection` set to `false`.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n allowEdit?: boolean;\n\n /**\n * If `true`, will use an in-app editor for photo edition.\n * If `false`, will open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available.\n * Only applicable with `allowEdit` set to true.\n * Note: This option is only supported on Android and iOS.\n *\n * @default true\n * @since 8.1.0\n */\n editInApp?: boolean;\n\n /**\n * iOS only: The presentation style of media picker.\n * @default 'fullscreen'\n *\n * @since 8.1.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * The quality of images to return, from 0-100.\n * Only applicable for `MediaType.Photo` and JPEG format.\n * Note: This option is only supported on Android and iOS.\n *\n * @default 100\n * @since 8.1.0\n */\n quality?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetHeight`.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n targetWidth?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetWidth`.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetHeight?: number;\n\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS\n * @default true\n *\n * @since 8.1.0\n */\n correctOrientation?: boolean;\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 8.1.0\n */\n webUseInput?: boolean;\n}\n\nexport interface EditURIPhotoOptions {\n /**\n * The URI that contains the photo to edit.\n *\n * @since 8.1.0\n */\n uri: string;\n\n /**\n * Whether to save the edited photo to the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n\n saveToGallery?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n}\n\nexport interface EditPhotoOptions {\n /**\n * The base64 encoded image to edit.\n *\n * @since 8.1.0\n */\n inputImage: string;\n}\n\nexport interface EditPhotoResult {\n /**\n * The edited image, base64 encoded.\n *\n * @since 8.1.0\n */\n outputImage: string;\n}\n\nexport interface MediaResult {\n /**\n * The type of media result. Either `Photo` or `Video`.\n *\n * @since 8.1.0\n */\n type: MediaType;\n\n /**\n * The URI pointing to the media file.\n * Not available on Web. Use `webPath` instead for Web.\n *\n * @since 8.1.0\n */\n uri?: string;\n\n /**\n * Returns the thumbnail of the media, base64 encoded.\n * On Web, for `MediaType.Photo`, the full image is returned here, also base64 encoded.\n *\n * @since 8.1.0\n */\n thumbnail?: string;\n\n /**\n * Whether if the media was saved to the gallery successfully or not.\n * Only applicable if `saveToGallery` was set to `true` in input options.\n * Otherwise, `false` is always returned for `save`.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n saved: boolean;\n\n /**\n * webPath returns a path that can be used to set the src attribute of a media item for efficient\n * loading and rendering.\n *\n * @since 8.1.0\n */\n webPath?: string;\n\n /**\n * Metadata associated to the media result.\n * Only included if `includeMetadata` was set to `true` in input options.\n *\n * @since 8.1.0\n */\n metadata?: MediaMetadata;\n}\n\nexport interface MediaMetadata {\n /**\n * File size of the media, in bytes\n * Not available on Web.\n *\n * @since 8.1.0\n */\n size?: number;\n\n /**\n * Only applicable for `MediaType.Video` - the duration of the media, in seconds.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n duration?: number;\n\n /**\n * The format of the image, ex: jpeg, png, mp4.\n *\n * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.\n * gif is only supported for `chooseFromGallery`, and only if `webUseInput` option is set to `true`.\n *\n * @since 8.1.0\n */\n format: string;\n\n /**\n * The resolution of the media, in `<width>x<height>` format. Example: '1920x1080'.\n *\n * @since 8.1.0\n */\n resolution: string;\n\n /**\n * The date and time the media was created, in ISO 8601 format.\n * If creation date is not available (e.g. Android 7 and below), the last modified date is returned.\n * Not available on web.\n *\n * @since 8.1.0\n */\n creationDate?: string;\n\n /**\n * Exif data, if any, retreived from the media item.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n exif?: string;\n}\n\nexport interface MediaResults {\n /**\n * The list of media results.\n *\n * @since 8.1.0\n */\n results: MediaResult[];\n}\n\n/**\n * @deprecated This interface is only meant to be used for deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport interface ImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n quality?: number;\n /**\n * Whether to allow the user to crop or make small edits (platform specific).\n * Note: This option is only supported on Android and iOS.\n * On iOS it's only supported for CameraSource.Camera, but not for CameraSource.Photos.\n *\n * @since 1.0.0\n */\n allowEditing?: boolean;\n /**\n * How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported\n *\n * @since 1.0.0\n */\n resultType: CameraResultType;\n /**\n * Whether to save the photo to the gallery.\n * If the photo was picked from the gallery, it will only be saved if edited.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 1.0.0\n */\n saveToGallery?: boolean;\n /**\n * The desired maximum width of the saved image. The aspect ratio is respected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n width?: number;\n /**\n * The desired maximum height of the saved image. The aspect ratio is respected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Note: This option is only supported on Android and iOS.\n * @default true\n *\n * @since 1.0.0\n */\n correctOrientation?: boolean;\n /**\n * The source to get the photo from. By default this prompts the user to select\n * either the photo album or take a photo.\n * @default CameraSource.Prompt\n *\n * @since 1.0.0\n */\n source?: CameraSource;\n /**\n * iOS and Web only: The camera direction.\n * @default CameraDirection.Rear\n *\n * @since 1.0.0\n */\n direction?: CameraDirection;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 1.0.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 1.0.0\n */\n webUseInput?: boolean;\n\n /**\n * Text value to use when displaying the prompt.\n * @default 'Photo'\n *\n * @since 1.0.0\n *\n */\n promptLabelHeader?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * iOS only: The label of the 'cancel' button.\n * @default 'Cancel'\n *\n * @since 1.0.0\n */\n promptLabelCancel?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to select a saved image.\n * @default 'From Photos'\n *\n * @since 1.0.0\n */\n promptLabelPhoto?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to open the camera.\n * @default 'Take Picture'\n *\n * @since 1.0.0\n */\n promptLabelPicture?: string;\n}\n\n/**\n * @deprecated This interface is only meant to be used for received the result of deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport interface Photo {\n /**\n * The base64 encoded string representation of the image, if using CameraResultType.Base64.\n *\n * @since 1.0.0\n */\n base64String?: string;\n /**\n * The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl.\n *\n * Note: On web, the file format could change depending on the browser.\n * @since 1.0.0\n */\n dataUrl?: string;\n /**\n * If using CameraResultType.Uri, the path will contain a full,\n * platform-specific file URL that can be read later using the Filesystem API.\n *\n * @since 1.0.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.0.0\n */\n webPath?: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.0.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.\n * gif is only supported if `webUseInput` is set to `true` or if `source` is set to `Photos`.\n *\n * @since 1.0.0\n */\n format: string;\n /**\n * Whether if the image was saved to the gallery or not.\n *\n * On Android and iOS, saving to the gallery can fail if the user didn't\n * grant the required permissions.\n * On Web there is no gallery, so always returns false.\n *\n * @since 1.1.0\n */\n saved: boolean;\n}\n\nexport interface GalleryPhotos {\n /**\n * Array of all the picked photos.\n *\n * @since 1.2.0\n */\n photos: GalleryPhoto[];\n}\n\nexport interface GalleryPhoto {\n /**\n * Full, platform-specific file URL that can be read later using the Filesystem API.\n *\n * @since 1.2.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.2.0\n */\n webPath: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.2.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg, png and gif.\n *\n * @since 1.2.0\n */\n format: string;\n}\n\n/**\n * @deprecated This interface is only meant to be used for deprecated `pickImages` method.\n * It will be removed in a future major version of the plugin, along with `pickImages`.\n */\nexport interface GalleryImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.2.0\n */\n quality?: number;\n /**\n * The desired maximum width of the saved image. The aspect ratio is respected.\n *\n * @since 1.2.0\n */\n width?: number;\n /**\n * The desired maximum height of the saved image. The aspect ratio is respected.\n *\n * @since 1.2.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode\n * @default true\n *\n * @since 1.2.0\n */\n correctOrientation?: boolean;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 1.2.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Maximum number of pictures the user will be able to choose.\n * Note: This option is only supported on Android 13+ and iOS.\n *\n * @default 0 (unlimited)\n *\n * @since 1.2.0\n */\n limit?: number;\n}\n\n/**\n * @deprecated This enum is only meant to be used for deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport enum CameraSource {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n Prompt = 'PROMPT',\n /**\n * Take a new photo using the camera.\n */\n Camera = 'CAMERA',\n /**\n * Pick an existing photo from the gallery or photo album.\n */\n Photos = 'PHOTOS',\n}\n\nexport enum CameraDirection {\n Rear = 'REAR',\n Front = 'FRONT',\n}\n\n/**\n * @deprecated This enum is only meant to be used for `ImageOptions` in deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport enum CameraResultType {\n Uri = 'uri',\n Base64 = 'base64',\n DataUrl = 'dataUrl',\n}\n\nexport enum MediaType {\n Photo = 0,\n Video = 1,\n}\n\nexport enum MediaTypeSelection {\n Photo = 0,\n Video = 1,\n All = 2,\n}\n\nexport enum EncodingType {\n JPEG = 0,\n PNG = 1,\n}\n\n/**\n * @deprecated Use `Photo`.\n * @since 1.0.0\n */\nexport type CameraPhoto = Photo;\n\n/**\n * @deprecated Use `ImageOptions`.\n * @since 1.0.0\n */\nexport type CameraOptions = ImageOptions;\n"]}
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAsyBA;;;GAGG;AACH,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;;;GAGG;AACH,MAAM,CAAN,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,+BAAW,CAAA;IACX,qCAAiB,CAAA;IACjB,uCAAmB,CAAA;AACrB,CAAC,EAJW,gBAAgB,KAAhB,gBAAgB,QAI3B;AAED,MAAM,CAAN,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,2CAAS,CAAA;IACT,2CAAS,CAAA;AACX,CAAC,EAHW,SAAS,KAAT,SAAS,QAGpB;AAED,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,6DAAS,CAAA;IACT,6DAAS,CAAA;IACT,yDAAO,CAAA;AACT,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAED,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IACR,6CAAO,CAAA;AACT,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAcD;;;;;GAKG;AACH,MAAM,CAAN,IAAY,eAuIX;AAvID,WAAY,eAAe;IACzB,cAAc;IACd;;OAEG;IACH,+DAA4C,CAAA;IAE5C;;OAEG;IACH,gEAA6C,CAAA;IAE7C;;OAEG;IACH,0DAAuC,CAAA;IAEvC,aAAa;IACb;;OAEG;IACH,2DAAwC,CAAA;IAExC;;OAEG;IACH,wDAAqC,CAAA;IAErC;;;OAGG;IACH,kEAA+C,CAAA;IAE/C,aAAa;IACb;;;OAGG;IACH,yDAAsC,CAAA;IAEtC;;OAEG;IACH,wDAAqC,CAAA;IAErC;;OAEG;IACH,2DAAwC,CAAA;IAExC;;;OAGG;IACH,0DAAuC,CAAA;IAEvC,sBAAsB;IACtB;;OAEG;IACH,sDAAmC,CAAA;IAEnC;;OAEG;IACH,2DAAwC,CAAA;IAExC;;OAEG;IACH,0DAAuC,CAAA;IAEvC;;OAEG;IACH,6DAA0C,CAAA;IAE1C;;;OAGG;IACH,uDAAoC,CAAA;IAEpC;;OAEG;IACH,gEAA6C,CAAA;IAE7C,eAAe;IACf;;OAEG;IACH,0DAAuC,CAAA;IAEvC;;OAEG;IACH,6DAA0C,CAAA;IAE1C;;;OAGG;IACH,sDAAmC,CAAA;IAEnC,aAAa;IACb;;OAEG;IACH,wDAAqC,CAAA;IAErC,UAAU;IACV;;;OAGG;IACH,2DAAwC,CAAA;IAExC;;OAEG;IACH,qDAAkC,CAAA;IAElC;;;OAGG;IACH,wDAAqC,CAAA;IAErC;;;OAGG;IACH,qDAAkC,CAAA;AACpC,CAAC,EAvIW,eAAe,KAAf,eAAe,QAuI1B","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\nexport type CameraPermissionState = PermissionState | 'limited';\n\nexport type CameraPermissionType = 'camera' | 'photos';\n\nexport interface PermissionStatus {\n camera: CameraPermissionState;\n photos: CameraPermissionState;\n}\n\nexport interface CameraPluginPermissions {\n permissions: CameraPermissionType[];\n}\n\nexport interface CameraPlugin {\n /**\n * Open the device's camera and allow the user to take a photo.\n *\n * @since 8.1.0\n */\n takePhoto(options: TakePhotoOptions): Promise<MediaResult>;\n\n /**\n * Open the device's camera and allow the user to record a video.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n recordVideo(options: RecordVideoOptions): Promise<MediaResult>;\n\n /**\n * Open a native video player.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n playVideo(options: PlayVideoOptions): Promise<void>;\n\n /**\n * Allow users to choose pictures, videos, or both, directly from their gallery.\n *\n * @since 8.1.0\n */\n chooseFromGallery(options: ChooseFromGalleryOptions): Promise<MediaResults>;\n\n /**\n * Open an in-app screen to edit a given photo using the provided base64 string.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n editPhoto(options: EditPhotoOptions): Promise<EditPhotoResult>;\n\n /**\n * Open an in-app screen to edit a photo using the provided URI.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n editURIPhoto(options: EditURIPhotoOptions): Promise<MediaResult>;\n\n /**\n * Allows the user to update their limited photo library selection.\n * Returns all the limited photos after the picker dismissal.\n * If instead the user gave full access to the photos it returns an empty array.\n *\n * @since 4.1.0\n */\n pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;\n /**\n * Return an array of photos selected from the limited photo library.\n *\n * @since 4.1.0\n */\n getLimitedLibraryPhotos(): Promise<GalleryPhotos>;\n\n /**\n * Check camera and photo album permissions\n *\n * @since 1.0.0\n */\n checkPermissions(): Promise<PermissionStatus>;\n\n /**\n * Request camera and photo album permissions\n *\n * @since 1.0.0\n */\n requestPermissions(permissions?: CameraPluginPermissions): Promise<PermissionStatus>;\n\n /**\n * Prompt the user to pick a photo from an album, or take a new photo\n * with the camera.\n *\n * @since 1.0.0\n * @deprecated Use `takePhoto` for a camera photo, or `chooseFromGallery` to select from the gallery. For creating a prompt for the user to select which source, use `@capacitor/action-sheet` or any UI component of your choosing. Refer to the Camera API documentation for more information on migrating.\n */\n getPhoto(options: ImageOptions): Promise<Photo>;\n\n /**\n * Allows the user to pick multiple pictures from the photo gallery.\n *\n * @since 1.2.0\n * @deprecated Use `chooseFromGallery` instead. Refer to the Camera API documentation for more information on migrating.\n */\n pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;\n}\n\nexport interface TakePhotoOptions {\n /**\n * The quality of image to return, from 0-100.\n * Only applicable for `EncodingType.JPEG`.\n * Note: This option is only supported on Android and iOS.\n *\n * @default 100\n * @since 8.1.0\n */\n quality?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetHeight`.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetWidth?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetWidth`.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetHeight?: number;\n\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Note: This option is only supported on Android and iOS\n * @default true\n *\n * @since 8.1.0\n */\n correctOrientation?: boolean;\n\n /**\n * The encoding type for the captured photo - JPEG or PNG.\n * Note: This option is only supported on Android and iOS.\n * @default EncodingType.JPEG\n *\n * @since 8.1.0\n */\n encodingType?: EncodingType;\n\n /**\n * Whether to save the photo to the gallery.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 8.1.0\n */\n saveToGallery?: boolean;\n\n /**\n * iOS and Web only: The camera direction.\n * @default CameraDirection.Rear\n *\n * @since 8.1.0\n */\n cameraDirection?: CameraDirection;\n\n /**\n * Determines if and how the user can edit the photo.\n * - 'in-app': Use an in-app editor for photo edition.\n * - 'external': Open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available. Note: iOS does not support external editing and will use 'in-app' instead.\n * - 'no': No editing allowed.\n * Not available on Web.\n * @default 'no'\n *\n * @since 8.1.0\n */\n editable?: 'in-app' | 'external' | 'no';\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 8.1.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 8.1.0\n */\n webUseInput?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n}\n\nexport interface RecordVideoOptions {\n /**\n * Whether to save the video to the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n saveToGallery?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n\n /**\n * Whether the to store the video in persistent app storage or in temporary cache.\n * If you plan to use the returned `MediaResult#URI` across app launches, you may want to set to true.\n * Otherwise, you can set to false.\n * @default true\n *\n * @since 8.1.0\n */\n isPersistent?: boolean;\n}\n\nexport interface PlayVideoOptions {\n /**\n * The URI of the video to play.\n * You may use the `MediaResult#URI` returned from `recordVideo` or `chooseFromGallery` directly.\n *\n * @since 8.1.0\n */\n uri: string;\n}\n\nexport interface ChooseFromGalleryOptions {\n /**\n * The type of media to select. Can be pictures, videos, or both.\n * @default MediaTypeSelection.Photo\n *\n * @since 8.1.0\n */\n mediaType?: MediaTypeSelection;\n\n /**\n * Whether or not to allow selecting multiple media files from the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n allowMultipleSelection?: boolean;\n\n /**\n * The maximum number of media files that the user can choose.\n * Only applicable if `allowMultipleSelection` is `true`.\n * Any non-positive number will be treated as unlimited.\n * Note: This option is only supported on Android 13+ and iOS.\n * @default 0\n *\n * @since 8.1.0\n */\n limit?: number;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n\n /**\n * Determines if and how the user can edit the photo.\n * - 'in-app': Use an in-app editor for photo edition.\n * - 'external': Open a separate (platform-specific) native app to handle photo edition, falling back to the in-app editor if none is available. Note: iOS does not support external editing and will use 'in-app' instead.\n * - 'no': No editing allowed.\n * Only applicable for `MediaTypeSelection.Photo` and `allowMultipleSelection` set to `false`.\n * Not available on Web.\n * @default 'no'\n *\n * @since 8.1.0\n */\n editable?: 'in-app' | 'external' | 'no';\n\n /**\n * iOS only: The presentation style of media picker.\n * @default 'fullscreen'\n *\n * @since 8.1.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * The quality of images to return, from 0-100.\n * Only applicable for `MediaType.Photo` and JPEG format.\n * Note: This option is only supported on Android and iOS.\n *\n * @default 100\n * @since 8.1.0\n */\n quality?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetHeight`.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n targetWidth?: number;\n\n /**\n * The target width of photos to apply.\n * Must be a positive number, and used along `targetWidth`.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 8.1.0\n */\n targetHeight?: number;\n\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Not applicable when videos are selected.\n * Note: This option is only supported on Android and iOS\n * @default true\n *\n * @since 8.1.0\n */\n correctOrientation?: boolean;\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 8.1.0\n */\n webUseInput?: boolean;\n}\n\nexport interface EditURIPhotoOptions {\n /**\n * The URI that contains the photo to edit.\n *\n * @since 8.1.0\n */\n uri: string;\n\n /**\n * Whether to save the edited photo to the gallery.\n * @default false\n *\n * @since 8.1.0\n */\n\n saveToGallery?: boolean;\n\n /**\n * Whether or not MediaResult should include its metadata.\n * If an error occurs when obtaining the metadata, it will return empty.\n * @default false\n *\n * @since 8.1.0\n */\n includeMetadata?: boolean;\n}\n\nexport interface EditPhotoOptions {\n /**\n * The base64 encoded image to edit.\n *\n * @since 8.1.0\n */\n inputImage: string;\n}\n\nexport interface EditPhotoResult {\n /**\n * The edited image, base64 encoded.\n *\n * @since 8.1.0\n */\n outputImage: string;\n}\n\nexport interface MediaResult {\n /**\n * The type of media result. Either `Photo` or `Video`.\n *\n * @since 8.1.0\n */\n type: MediaType;\n\n /**\n * The URI pointing to the media file.\n * Not available on Web. Use `webPath` instead for Web.\n *\n * @since 8.1.0\n */\n uri?: string;\n\n /**\n * Returns the thumbnail of the media, base64 encoded.\n * On Web, for `MediaType.Photo`, the full image is returned here, also base64 encoded.\n * On Web, for `MediaType.Video`, a full-resolution JPEG frame captured from the video is returned, base64 encoded at 80% quality.\n *\n * @since 8.1.0\n */\n thumbnail?: string;\n\n /**\n * Whether if the media was saved to the gallery successfully or not.\n * Only applicable if `saveToGallery` was set to `true` in input options.\n * Otherwise, `false` is always returned for `save`.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n saved: boolean;\n\n /**\n * webPath returns a path that can be used to set the src attribute of a media item for efficient\n * loading and rendering.\n *\n * @since 8.1.0\n */\n webPath?: string;\n\n /**\n * Metadata associated to the media result.\n * Only included if `includeMetadata` was set to `true` in input options.\n *\n * @since 8.1.0\n */\n metadata?: MediaMetadata;\n}\n\nexport interface MediaMetadata {\n /**\n * File size of the media, in bytes.\n *\n * @since 8.1.0\n */\n size?: number;\n\n /**\n * Only applicable for `MediaType.Video` - the duration of the media, in seconds.\n *\n * @since 8.1.0\n */\n duration?: number;\n\n /**\n * The format of the image, ex: jpeg, png, mp4.\n *\n * Android and iOS may return 'jpg' instead of 'jpeg'. The format is the same, just with a different name.\n * Please compare against both 'jpeg' and 'jpg' when checking if the format of the returned media is JPEG.\n * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.\n * gif is only supported for `chooseFromGallery` on Web.\n *\n * @since 8.1.0\n */\n format: string;\n\n /**\n * The resolution of the media, in `<width>x<height>` format. Example: '1920x1080'.\n *\n * @since 8.1.0\n */\n resolution?: string;\n\n /**\n * The date and time the media was created, in ISO 8601 format.\n * If creation date is not available (e.g. Android 7 and below), the last modified date is returned.\n * For Web, the last modified date is always returned.\n *\n * @since 8.1.0\n */\n creationDate?: string;\n\n /**\n * Exif data, if any, retrieved from the media item.\n * Only available for `MediaType.Photo`.\n * Not available on Web.\n *\n * @since 8.1.0\n */\n exif?: string;\n}\n\nexport interface MediaResults {\n /**\n * The list of media results.\n *\n * @since 8.1.0\n */\n results: MediaResult[];\n}\n\n/**\n * @deprecated This interface is only meant to be used for deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport interface ImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n quality?: number;\n /**\n * Whether to allow the user to crop or make small edits (platform specific).\n * Note: This option is only supported on Android and iOS.\n * On iOS it's only supported for CameraSource.Camera, but not for CameraSource.Photos.\n *\n * @since 1.0.0\n */\n allowEditing?: boolean;\n /**\n * How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported\n *\n * @since 1.0.0\n */\n resultType: CameraResultType;\n /**\n * Whether to save the photo to the gallery.\n * If the photo was picked from the gallery, it will only be saved if edited.\n * Note: This option is only supported on Android and iOS.\n * @default false\n *\n * @since 1.0.0\n */\n saveToGallery?: boolean;\n /**\n * The desired maximum width of the saved image. The aspect ratio is respected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n width?: number;\n /**\n * The desired maximum height of the saved image. The aspect ratio is respected.\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.0.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode.\n * Note: This option is only supported on Android and iOS.\n * @default true\n *\n * @since 1.0.0\n */\n correctOrientation?: boolean;\n /**\n * The source to get the photo from. By default this prompts the user to select\n * either the photo album or take a photo.\n * @default CameraSource.Prompt\n *\n * @since 1.0.0\n */\n source?: CameraSource;\n /**\n * iOS and Web only: The camera direction.\n * @default CameraDirection.Rear\n *\n * @since 1.0.0\n */\n direction?: CameraDirection;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 1.0.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Web only: Whether to use the PWA Element experience or file input. The\n * default is to use PWA Elements if installed and fall back to file input.\n * To always use file input, set this to `true`.\n *\n * Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements\n *\n * @since 1.0.0\n */\n webUseInput?: boolean;\n\n /**\n * Text value to use when displaying the prompt.\n * @default 'Photo'\n *\n * @since 1.0.0\n *\n */\n promptLabelHeader?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * iOS only: The label of the 'cancel' button.\n * @default 'Cancel'\n *\n * @since 1.0.0\n */\n promptLabelCancel?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to select a saved image.\n * @default 'From Photos'\n *\n * @since 1.0.0\n */\n promptLabelPhoto?: string;\n\n /**\n * Text value to use when displaying the prompt.\n * The label of the button to open the camera.\n * @default 'Take Picture'\n *\n * @since 1.0.0\n */\n promptLabelPicture?: string;\n}\n\n/**\n * @deprecated This interface is only meant to be used for received the result of deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport interface Photo {\n /**\n * The base64 encoded string representation of the image, if using CameraResultType.Base64.\n *\n * @since 1.0.0\n */\n base64String?: string;\n /**\n * The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl.\n *\n * Note: On web, the file format could change depending on the browser.\n * @since 1.0.0\n */\n dataUrl?: string;\n /**\n * If using CameraResultType.Uri, the path will contain a full,\n * platform-specific file URL that can be read later using the Filesystem API.\n *\n * @since 1.0.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.0.0\n */\n webPath?: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.0.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.\n * gif is only supported if `webUseInput` is set to `true` or if `source` is set to `Photos`.\n *\n * @since 1.0.0\n */\n format: string;\n /**\n * Whether if the image was saved to the gallery or not.\n *\n * On Android and iOS, saving to the gallery can fail if the user didn't\n * grant the required permissions.\n * On Web there is no gallery, so always returns false.\n *\n * @since 1.1.0\n */\n saved: boolean;\n}\n\nexport interface GalleryPhotos {\n /**\n * Array of all the picked photos.\n *\n * @since 1.2.0\n */\n photos: GalleryPhoto[];\n}\n\nexport interface GalleryPhoto {\n /**\n * Full, platform-specific file URL that can be read later using the Filesystem API.\n *\n * @since 1.2.0\n */\n path?: string;\n /**\n * webPath returns a path that can be used to set the src attribute of an image for efficient\n * loading and rendering.\n *\n * @since 1.2.0\n */\n webPath: string;\n /**\n * Exif data, if any, retrieved from the image\n *\n * @since 1.2.0\n */\n exif?: any;\n /**\n * The format of the image, ex: jpeg, png, gif.\n *\n * iOS and Android only support jpeg.\n * Web supports jpeg, png and gif.\n *\n * @since 1.2.0\n */\n format: string;\n}\n\n/**\n * @deprecated This interface is only meant to be used for deprecated `pickImages` method.\n * It will be removed in a future major version of the plugin, along with `pickImages`.\n */\nexport interface GalleryImageOptions {\n /**\n * The quality of image to return as JPEG, from 0-100\n * Note: This option is only supported on Android and iOS.\n *\n * @since 1.2.0\n */\n quality?: number;\n /**\n * The desired maximum width of the saved image. The aspect ratio is respected.\n *\n * @since 1.2.0\n */\n width?: number;\n /**\n * The desired maximum height of the saved image. The aspect ratio is respected.\n *\n * @since 1.2.0\n */\n height?: number;\n /**\n * Whether to automatically rotate the image \"up\" to correct for orientation\n * in portrait mode\n * @default true\n *\n * @since 1.2.0\n */\n correctOrientation?: boolean;\n\n /**\n * iOS only: The presentation style of the Camera.\n * @default 'fullscreen'\n *\n * @since 1.2.0\n */\n presentationStyle?: 'fullscreen' | 'popover';\n\n /**\n * Maximum number of pictures the user will be able to choose.\n * Note: This option is only supported on Android 13+ and iOS.\n *\n * @default 0 (unlimited)\n *\n * @since 1.2.0\n */\n limit?: number;\n}\n\n/**\n * @deprecated This enum is only meant to be used for deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport enum CameraSource {\n /**\n * Prompts the user to select either the photo album or take a photo.\n */\n Prompt = 'PROMPT',\n /**\n * Take a new photo using the camera.\n */\n Camera = 'CAMERA',\n /**\n * Pick an existing photo from the gallery or photo album.\n */\n Photos = 'PHOTOS',\n}\n\nexport enum CameraDirection {\n Rear = 'REAR',\n Front = 'FRONT',\n}\n\n/**\n * @deprecated This enum is only meant to be used for `ImageOptions` in deprecated `getPhoto` method.\n * It will be removed in a future major version of the plugin, along with `getPhoto`.\n */\nexport enum CameraResultType {\n Uri = 'uri',\n Base64 = 'base64',\n DataUrl = 'dataUrl',\n}\n\nexport enum MediaType {\n Photo = 0,\n Video = 1,\n}\n\nexport enum MediaTypeSelection {\n Photo = 0,\n Video = 1,\n All = 2,\n}\n\nexport enum EncodingType {\n JPEG = 0,\n PNG = 1,\n}\n\n/**\n * @deprecated Use `Photo`.\n * @since 1.0.0\n */\nexport type CameraPhoto = Photo;\n\n/**\n * @deprecated Use `ImageOptions`.\n * @since 1.0.0\n */\nexport type CameraOptions = ImageOptions;\n\n/**\n * Error codes returned by the Camera plugin.\n * These values match the `code` field on rejected promises.\n *\n * @since 8.2.0\n */\nexport enum CameraErrorCode {\n // Permissions\n /**\n * Camera access was denied by the user.\n */\n CameraPermissionDenied = 'OS-PLUG-CAMR-0003',\n\n /**\n * Photo library / gallery access was denied by the user.\n */\n GalleryPermissionDenied = 'OS-PLUG-CAMR-0005',\n\n /**\n * No camera hardware is available on the device.\n */\n NoCameraAvailable = 'OS-PLUG-CAMR-0007',\n\n // Take Photo\n /**\n * The user cancelled the take photo action.\n */\n TakePhotoCancelled = 'OS-PLUG-CAMR-0006',\n\n /**\n * Failed to take photo.\n */\n TakePhotoFailed = 'OS-PLUG-CAMR-0010',\n\n /**\n * The take photo action received invalid arguments.\n * @platform ios\n */\n TakePhotoInvalidArguments = 'OS-PLUG-CAMR-0014',\n\n // Edit Photo\n /**\n * The selected file contains invalid image data.\n * @platform ios\n */\n InvalidImageData = 'OS-PLUG-CAMR-0008',\n\n /**\n * Failed to edit image.\n */\n EditPhotoFailed = 'OS-PLUG-CAMR-0009',\n\n /**\n * The user cancelled the edit photo action.\n */\n EditPhotoCancelled = 'OS-PLUG-CAMR-0013',\n\n /**\n * The URI parameter for editing is empty.\n * @platform android\n */\n EditPhotoEmptyUri = 'OS-PLUG-CAMR-0024',\n\n // Choose from Gallery\n /**\n * Failed to retrieve an image from the gallery.\n */\n ImageNotFound = 'OS-PLUG-CAMR-0011',\n\n /**\n * Failed to process the selected image.\n */\n ProcessImageFailed = 'OS-PLUG-CAMR-0012',\n\n /**\n * Failed to choose media from the gallery.\n */\n ChooseMediaFailed = 'OS-PLUG-CAMR-0018',\n\n /**\n * The user cancelled choosing media from the gallery.\n */\n ChooseMediaCancelled = 'OS-PLUG-CAMR-0020',\n\n /**\n * Failed to retrieve the media file path.\n * @platform android\n */\n MediaPathError = 'OS-PLUG-CAMR-0021',\n\n /**\n * Failed to retrieve an image from the provided URI.\n */\n FetchImageFromUriFailed = 'OS-PLUG-CAMR-0028',\n\n // Record Video\n /**\n * Failed to record video.\n */\n RecordVideoFailed = 'OS-PLUG-CAMR-0016',\n\n /**\n * The user cancelled the video recording.\n */\n RecordVideoCancelled = 'OS-PLUG-CAMR-0017',\n\n /**\n * Failed to retrieve a video from the gallery.\n * @platform ios\n */\n VideoNotFound = 'OS-PLUG-CAMR-0025',\n\n // Play Video\n /**\n * Failed to play video.\n */\n PlayVideoFailed = 'OS-PLUG-CAMR-0023',\n\n // General\n /**\n * Failed to encode the media result.\n * @platform ios\n */\n EncodeResultFailed = 'OS-PLUG-CAMR-0019',\n\n /**\n * The selected file does not exist.\n */\n FileNotFound = 'OS-PLUG-CAMR-0027',\n\n /**\n * Invalid argument provided to a plugin method.\n * @platform android\n */\n InvalidArgument = 'OS-PLUG-CAMR-0031',\n\n /**\n * A general plugin error occurred.\n * @platform ios\n */\n GeneralError = 'OS-PLUG-CAMR-0026',\n}\n"]}
package/dist/esm/web.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { WebPlugin } from '@capacitor/core';
2
2
  import type { CameraPlugin, GalleryImageOptions, GalleryPhotos, ImageOptions, PermissionStatus, Photo, RecordVideoOptions, EditPhotoOptions, PlayVideoOptions, EditURIPhotoOptions, EditPhotoResult, MediaResult, MediaResults, ChooseFromGalleryOptions, TakePhotoOptions } from './definitions';
3
3
  export declare class CameraWeb extends WebPlugin implements CameraPlugin {
4
- takePhoto(_options: TakePhotoOptions): Promise<MediaResult>;
4
+ takePhoto(options: TakePhotoOptions): Promise<MediaResult>;
5
5
  recordVideo(_options: RecordVideoOptions): Promise<MediaResult>;
6
6
  playVideo(_options: PlayVideoOptions): Promise<void>;
7
- chooseFromGallery(_options: ChooseFromGalleryOptions): Promise<MediaResults>;
7
+ chooseFromGallery(options: ChooseFromGalleryOptions): Promise<MediaResults>;
8
8
  editPhoto(_options: EditPhotoOptions): Promise<EditPhotoResult>;
9
9
  editURIPhoto(_options: EditURIPhotoOptions): Promise<MediaResult>;
10
10
  getPhoto(options: ImageOptions): Promise<Photo>;
@@ -13,6 +13,17 @@ export declare class CameraWeb extends WebPlugin implements CameraPlugin {
13
13
  private fileInputExperience;
14
14
  private multipleFileInputExperience;
15
15
  private _getCameraPhoto;
16
+ private takePhotoCameraExperience;
17
+ private takePhotoCameraInputExperience;
18
+ private galleryInputExperience;
19
+ private _getFileFormat;
20
+ private _buildPhotoMediaResult;
21
+ private _validateFileInput;
22
+ private _setupPWACameraModal;
23
+ private _createFileInput;
24
+ private _getImageResolution;
25
+ private _getBase64FromFile;
26
+ private _getVideoMetadata;
16
27
  checkPermissions(): Promise<PermissionStatus>;
17
28
  requestPermissions(): Promise<PermissionStatus>;
18
29
  pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;