init
This commit is contained in:
337
node_modules/@capacitor/camera/dist/esm/definitions.d.ts
generated
vendored
Normal file
337
node_modules/@capacitor/camera/dist/esm/definitions.d.ts
generated
vendored
Normal file
@@ -0,0 +1,337 @@
|
||||
import type { PermissionState } from '@capacitor/core';
|
||||
export declare type CameraPermissionState = PermissionState | 'limited';
|
||||
export declare type CameraPermissionType = 'camera' | 'photos';
|
||||
export interface PermissionStatus {
|
||||
camera: CameraPermissionState;
|
||||
photos: CameraPermissionState;
|
||||
}
|
||||
export interface CameraPluginPermissions {
|
||||
permissions: CameraPermissionType[];
|
||||
}
|
||||
export interface CameraPlugin {
|
||||
/**
|
||||
* Prompt the user to pick a photo from an album, or take a new photo
|
||||
* with the camera.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
getPhoto(options: ImageOptions): Promise<Photo>;
|
||||
/**
|
||||
* Allows the user to pick multiple pictures from the photo gallery.
|
||||
* On iOS 13 and older it only allows to pick one picture.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
pickImages(options: GalleryImageOptions): Promise<GalleryPhotos>;
|
||||
/**
|
||||
* iOS 14+ Only: Allows the user to update their limited photo library selection.
|
||||
* On iOS 15+ returns all the limited photos after the picker dismissal.
|
||||
* On iOS 14 or if the user gave full access to the photos it returns an empty array.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;
|
||||
/**
|
||||
* iOS 14+ Only: Return an array of photos selected from the limited photo library.
|
||||
*
|
||||
* @since 4.1.0
|
||||
*/
|
||||
getLimitedLibraryPhotos(): Promise<GalleryPhotos>;
|
||||
/**
|
||||
* Check camera and photo album permissions
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
checkPermissions(): Promise<PermissionStatus>;
|
||||
/**
|
||||
* Request camera and photo album permissions
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
requestPermissions(permissions?: CameraPluginPermissions): Promise<PermissionStatus>;
|
||||
}
|
||||
export interface ImageOptions {
|
||||
/**
|
||||
* The quality of image to return as JPEG, from 0-100
|
||||
* Note: This option is only supported on Android and iOS
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
quality?: number;
|
||||
/**
|
||||
* Whether to allow the user to crop or make small edits (platform specific).
|
||||
* On iOS 14+ it's only supported for CameraSource.Camera, but not for CameraSource.Photos.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
allowEditing?: boolean;
|
||||
/**
|
||||
* How the data should be returned. Currently, only 'Base64', 'DataUrl' or 'Uri' is supported
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
resultType: CameraResultType;
|
||||
/**
|
||||
* Whether to save the photo to the gallery.
|
||||
* If the photo was picked from the gallery, it will only be saved if edited.
|
||||
* @default: false
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
saveToGallery?: boolean;
|
||||
/**
|
||||
* The desired maximum width of the saved image. The aspect ratio is respected.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* The desired maximum height of the saved image. The aspect ratio is respected.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* Whether to automatically rotate the image "up" to correct for orientation
|
||||
* in portrait mode
|
||||
* @default: true
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
correctOrientation?: boolean;
|
||||
/**
|
||||
* The source to get the photo from. By default this prompts the user to select
|
||||
* either the photo album or take a photo.
|
||||
* @default: CameraSource.Prompt
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
source?: CameraSource;
|
||||
/**
|
||||
* iOS and Web only: The camera direction.
|
||||
* @default: CameraDirection.Rear
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
direction?: CameraDirection;
|
||||
/**
|
||||
* iOS only: The presentation style of the Camera.
|
||||
* @default: 'fullscreen'
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
presentationStyle?: 'fullscreen' | 'popover';
|
||||
/**
|
||||
* Web only: Whether to use the PWA Element experience or file input. The
|
||||
* default is to use PWA Elements if installed and fall back to file input.
|
||||
* To always use file input, set this to `true`.
|
||||
*
|
||||
* Learn more about PWA Elements: https://capacitorjs.com/docs/web/pwa-elements
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
webUseInput?: boolean;
|
||||
/**
|
||||
* Text value to use when displaying the prompt.
|
||||
* @default: 'Photo'
|
||||
*
|
||||
* @since 1.0.0
|
||||
*
|
||||
*/
|
||||
promptLabelHeader?: string;
|
||||
/**
|
||||
* Text value to use when displaying the prompt.
|
||||
* iOS only: The label of the 'cancel' button.
|
||||
* @default: 'Cancel'
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
promptLabelCancel?: string;
|
||||
/**
|
||||
* Text value to use when displaying the prompt.
|
||||
* The label of the button to select a saved image.
|
||||
* @default: 'From Photos'
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
promptLabelPhoto?: string;
|
||||
/**
|
||||
* Text value to use when displaying the prompt.
|
||||
* The label of the button to open the camera.
|
||||
* @default: 'Take Picture'
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
promptLabelPicture?: string;
|
||||
}
|
||||
export interface Photo {
|
||||
/**
|
||||
* The base64 encoded string representation of the image, if using CameraResultType.Base64.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
base64String?: string;
|
||||
/**
|
||||
* The url starting with 'data:image/jpeg;base64,' and the base64 encoded string representation of the image, if using CameraResultType.DataUrl.
|
||||
*
|
||||
* Note: On web, the file format could change depending on the browser.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
dataUrl?: string;
|
||||
/**
|
||||
* If using CameraResultType.Uri, the path will contain a full,
|
||||
* platform-specific file URL that can be read later using the Filesystem API.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* webPath returns a path that can be used to set the src attribute of an image for efficient
|
||||
* loading and rendering.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
webPath?: string;
|
||||
/**
|
||||
* Exif data, if any, retrieved from the image
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
exif?: any;
|
||||
/**
|
||||
* The format of the image, ex: jpeg, png, gif.
|
||||
*
|
||||
* iOS and Android only support jpeg.
|
||||
* Web supports jpeg, png and gif, but the exact availability may vary depending on the browser.
|
||||
* gif is only supported if `webUseInput` is set to `true` or if `source` is set to `Photos`.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
format: string;
|
||||
/**
|
||||
* Whether if the image was saved to the gallery or not.
|
||||
*
|
||||
* On Android and iOS, saving to the gallery can fail if the user didn't
|
||||
* grant the required permissions.
|
||||
* On Web there is no gallery, so always returns false.
|
||||
*
|
||||
* @since 1.1.0
|
||||
*/
|
||||
saved: boolean;
|
||||
}
|
||||
export interface GalleryPhotos {
|
||||
/**
|
||||
* Array of all the picked photos.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
photos: GalleryPhoto[];
|
||||
}
|
||||
export interface GalleryPhoto {
|
||||
/**
|
||||
* Full, platform-specific file URL that can be read later using the Filesystem API.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* webPath returns a path that can be used to set the src attribute of an image for efficient
|
||||
* loading and rendering.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
webPath: string;
|
||||
/**
|
||||
* Exif data, if any, retrieved from the image
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
exif?: any;
|
||||
/**
|
||||
* The format of the image, ex: jpeg, png, gif.
|
||||
*
|
||||
* iOS and Android only support jpeg.
|
||||
* Web supports jpeg, png and gif.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
format: string;
|
||||
}
|
||||
export interface GalleryImageOptions {
|
||||
/**
|
||||
* The quality of image to return as JPEG, from 0-100
|
||||
* Note: This option is only supported on Android and iOS.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
quality?: number;
|
||||
/**
|
||||
* The desired maximum width of the saved image. The aspect ratio is respected.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* The desired maximum height of the saved image. The aspect ratio is respected.
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
height?: number;
|
||||
/**
|
||||
* Whether to automatically rotate the image "up" to correct for orientation
|
||||
* in portrait mode
|
||||
* @default: true
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
correctOrientation?: boolean;
|
||||
/**
|
||||
* iOS only: The presentation style of the Camera.
|
||||
* @default: 'fullscreen'
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
presentationStyle?: 'fullscreen' | 'popover';
|
||||
/**
|
||||
* Maximum number of pictures the user will be able to choose.
|
||||
* Note: This option is only supported on Android 13+ and iOS.
|
||||
*
|
||||
* @default 0 (unlimited)
|
||||
*
|
||||
* @since 1.2.0
|
||||
*/
|
||||
limit?: number;
|
||||
}
|
||||
export declare enum CameraSource {
|
||||
/**
|
||||
* Prompts the user to select either the photo album or take a photo.
|
||||
*/
|
||||
Prompt = "PROMPT",
|
||||
/**
|
||||
* Take a new photo using the camera.
|
||||
*/
|
||||
Camera = "CAMERA",
|
||||
/**
|
||||
* Pick an existing photo from the gallery or photo album.
|
||||
*/
|
||||
Photos = "PHOTOS"
|
||||
}
|
||||
export declare enum CameraDirection {
|
||||
Rear = "REAR",
|
||||
Front = "FRONT"
|
||||
}
|
||||
export declare enum CameraResultType {
|
||||
Uri = "uri",
|
||||
Base64 = "base64",
|
||||
DataUrl = "dataUrl"
|
||||
}
|
||||
/**
|
||||
* @deprecated Use `Photo`.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
export declare type CameraPhoto = Photo;
|
||||
/**
|
||||
* @deprecated Use `ImageOptions`.
|
||||
* @since 1.0.0
|
||||
*/
|
||||
export declare type CameraOptions = ImageOptions;
|
||||
27
node_modules/@capacitor/camera/dist/esm/definitions.js
generated
vendored
Normal file
27
node_modules/@capacitor/camera/dist/esm/definitions.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
export var CameraSource;
|
||||
(function (CameraSource) {
|
||||
/**
|
||||
* Prompts the user to select either the photo album or take a photo.
|
||||
*/
|
||||
CameraSource["Prompt"] = "PROMPT";
|
||||
/**
|
||||
* Take a new photo using the camera.
|
||||
*/
|
||||
CameraSource["Camera"] = "CAMERA";
|
||||
/**
|
||||
* Pick an existing photo from the gallery or photo album.
|
||||
*/
|
||||
CameraSource["Photos"] = "PHOTOS";
|
||||
})(CameraSource || (CameraSource = {}));
|
||||
export var CameraDirection;
|
||||
(function (CameraDirection) {
|
||||
CameraDirection["Rear"] = "REAR";
|
||||
CameraDirection["Front"] = "FRONT";
|
||||
})(CameraDirection || (CameraDirection = {}));
|
||||
export var CameraResultType;
|
||||
(function (CameraResultType) {
|
||||
CameraResultType["Uri"] = "uri";
|
||||
CameraResultType["Base64"] = "base64";
|
||||
CameraResultType["DataUrl"] = "dataUrl";
|
||||
})(CameraResultType || (CameraResultType = {}));
|
||||
//# sourceMappingURL=definitions.js.map
|
||||
1
node_modules/@capacitor/camera/dist/esm/definitions.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/camera/dist/esm/definitions.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
4
node_modules/@capacitor/camera/dist/esm/index.d.ts
generated
vendored
Normal file
4
node_modules/@capacitor/camera/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import type { CameraPlugin } from './definitions';
|
||||
declare const Camera: CameraPlugin;
|
||||
export * from './definitions';
|
||||
export { Camera };
|
||||
8
node_modules/@capacitor/camera/dist/esm/index.js
generated
vendored
Normal file
8
node_modules/@capacitor/camera/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { registerPlugin } from '@capacitor/core';
|
||||
import { CameraWeb } from './web';
|
||||
const Camera = registerPlugin('Camera', {
|
||||
web: () => new CameraWeb(),
|
||||
});
|
||||
export * from './definitions';
|
||||
export { Camera };
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@capacitor/camera/dist/esm/index.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/camera/dist/esm/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,GAAG,EAAE,GAAG,EAAE,CAAC,IAAI,SAAS,EAAE;CAC3B,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CameraPlugin } from './definitions';\nimport { CameraWeb } from './web';\n\nconst Camera = registerPlugin<CameraPlugin>('Camera', {\n web: () => new CameraWeb(),\n});\n\nexport * from './definitions';\nexport { Camera };\n"]}
|
||||
16
node_modules/@capacitor/camera/dist/esm/web.d.ts
generated
vendored
Normal file
16
node_modules/@capacitor/camera/dist/esm/web.d.ts
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
import { WebPlugin } from '@capacitor/core';
|
||||
import type { CameraPlugin, GalleryImageOptions, GalleryPhotos, ImageOptions, PermissionStatus, Photo } from './definitions';
|
||||
export declare class CameraWeb extends WebPlugin implements CameraPlugin {
|
||||
getPhoto(options: ImageOptions): Promise<Photo>;
|
||||
pickImages(_options: GalleryImageOptions): Promise<GalleryPhotos>;
|
||||
private cameraExperience;
|
||||
private fileInputExperience;
|
||||
private multipleFileInputExperience;
|
||||
private _getCameraPhoto;
|
||||
checkPermissions(): Promise<PermissionStatus>;
|
||||
requestPermissions(): Promise<PermissionStatus>;
|
||||
pickLimitedLibraryPhotos(): Promise<GalleryPhotos>;
|
||||
getLimitedLibraryPhotos(): Promise<GalleryPhotos>;
|
||||
}
|
||||
declare const Camera: CameraWeb;
|
||||
export { Camera };
|
||||
254
node_modules/@capacitor/camera/dist/esm/web.js
generated
vendored
Normal file
254
node_modules/@capacitor/camera/dist/esm/web.js
generated
vendored
Normal file
@@ -0,0 +1,254 @@
|
||||
import { WebPlugin, CapacitorException } from '@capacitor/core';
|
||||
import { CameraSource, CameraDirection } from './definitions';
|
||||
export class CameraWeb extends WebPlugin {
|
||||
async getPhoto(options) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve, reject) => {
|
||||
if (options.webUseInput || options.source === CameraSource.Photos) {
|
||||
this.fileInputExperience(options, resolve, reject);
|
||||
}
|
||||
else if (options.source === CameraSource.Prompt) {
|
||||
let actionSheet = document.querySelector('pwa-action-sheet');
|
||||
if (!actionSheet) {
|
||||
actionSheet = document.createElement('pwa-action-sheet');
|
||||
document.body.appendChild(actionSheet);
|
||||
}
|
||||
actionSheet.header = options.promptLabelHeader || 'Photo';
|
||||
actionSheet.cancelable = false;
|
||||
actionSheet.options = [
|
||||
{ title: options.promptLabelPhoto || 'From Photos' },
|
||||
{ title: options.promptLabelPicture || 'Take Picture' },
|
||||
];
|
||||
actionSheet.addEventListener('onSelection', async (e) => {
|
||||
const selection = e.detail;
|
||||
if (selection === 0) {
|
||||
this.fileInputExperience(options, resolve, reject);
|
||||
}
|
||||
else {
|
||||
this.cameraExperience(options, resolve, reject);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
this.cameraExperience(options, resolve, reject);
|
||||
}
|
||||
});
|
||||
}
|
||||
async pickImages(_options) {
|
||||
// eslint-disable-next-line no-async-promise-executor
|
||||
return new Promise(async (resolve, reject) => {
|
||||
this.multipleFileInputExperience(resolve, reject);
|
||||
});
|
||||
}
|
||||
async cameraExperience(options, resolve, reject) {
|
||||
if (customElements.get('pwa-camera-modal')) {
|
||||
const cameraModal = document.createElement('pwa-camera-modal');
|
||||
cameraModal.facingMode =
|
||||
options.direction === CameraDirection.Front ? 'user' : 'environment';
|
||||
document.body.appendChild(cameraModal);
|
||||
try {
|
||||
await cameraModal.componentOnReady();
|
||||
cameraModal.addEventListener('onPhoto', async (e) => {
|
||||
const photo = e.detail;
|
||||
if (photo === null) {
|
||||
reject(new CapacitorException('User cancelled photos app'));
|
||||
}
|
||||
else if (photo instanceof Error) {
|
||||
reject(photo);
|
||||
}
|
||||
else {
|
||||
resolve(await this._getCameraPhoto(photo, options));
|
||||
}
|
||||
cameraModal.dismiss();
|
||||
document.body.removeChild(cameraModal);
|
||||
});
|
||||
cameraModal.present();
|
||||
}
|
||||
catch (e) {
|
||||
this.fileInputExperience(options, resolve, reject);
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error(`Unable to load PWA Element 'pwa-camera-modal'. See the docs: https://capacitorjs.com/docs/web/pwa-elements.`);
|
||||
this.fileInputExperience(options, resolve, reject);
|
||||
}
|
||||
}
|
||||
fileInputExperience(options, resolve, reject) {
|
||||
let input = document.querySelector('#_capacitor-camera-input');
|
||||
const cleanup = () => {
|
||||
var _a;
|
||||
(_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);
|
||||
};
|
||||
if (!input) {
|
||||
input = document.createElement('input');
|
||||
input.id = '_capacitor-camera-input';
|
||||
input.type = 'file';
|
||||
input.hidden = true;
|
||||
document.body.appendChild(input);
|
||||
input.addEventListener('change', (_e) => {
|
||||
const file = input.files[0];
|
||||
let format = 'jpeg';
|
||||
if (file.type === 'image/png') {
|
||||
format = 'png';
|
||||
}
|
||||
else if (file.type === 'image/gif') {
|
||||
format = 'gif';
|
||||
}
|
||||
if (options.resultType === 'dataUrl' ||
|
||||
options.resultType === 'base64') {
|
||||
const reader = new FileReader();
|
||||
reader.addEventListener('load', () => {
|
||||
if (options.resultType === 'dataUrl') {
|
||||
resolve({
|
||||
dataUrl: reader.result,
|
||||
format,
|
||||
});
|
||||
}
|
||||
else if (options.resultType === 'base64') {
|
||||
const b64 = reader.result.split(',')[1];
|
||||
resolve({
|
||||
base64String: b64,
|
||||
format,
|
||||
});
|
||||
}
|
||||
cleanup();
|
||||
});
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
webPath: URL.createObjectURL(file),
|
||||
format: format,
|
||||
});
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
input.addEventListener('cancel', (_e) => {
|
||||
reject(new CapacitorException('User cancelled photos app'));
|
||||
cleanup();
|
||||
});
|
||||
}
|
||||
input.accept = 'image/*';
|
||||
input.capture = true;
|
||||
if (options.source === CameraSource.Photos ||
|
||||
options.source === CameraSource.Prompt) {
|
||||
input.removeAttribute('capture');
|
||||
}
|
||||
else if (options.direction === CameraDirection.Front) {
|
||||
input.capture = 'user';
|
||||
}
|
||||
else if (options.direction === CameraDirection.Rear) {
|
||||
input.capture = 'environment';
|
||||
}
|
||||
input.click();
|
||||
}
|
||||
multipleFileInputExperience(resolve, reject) {
|
||||
let input = document.querySelector('#_capacitor-camera-input-multiple');
|
||||
const cleanup = () => {
|
||||
var _a;
|
||||
(_a = input.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(input);
|
||||
};
|
||||
if (!input) {
|
||||
input = document.createElement('input');
|
||||
input.id = '_capacitor-camera-input-multiple';
|
||||
input.type = 'file';
|
||||
input.hidden = true;
|
||||
input.multiple = true;
|
||||
document.body.appendChild(input);
|
||||
input.addEventListener('change', (_e) => {
|
||||
const photos = [];
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-for-of
|
||||
for (let i = 0; i < input.files.length; i++) {
|
||||
const file = input.files[i];
|
||||
let format = 'jpeg';
|
||||
if (file.type === 'image/png') {
|
||||
format = 'png';
|
||||
}
|
||||
else if (file.type === 'image/gif') {
|
||||
format = 'gif';
|
||||
}
|
||||
photos.push({
|
||||
webPath: URL.createObjectURL(file),
|
||||
format: format,
|
||||
});
|
||||
}
|
||||
resolve({ photos });
|
||||
cleanup();
|
||||
});
|
||||
input.addEventListener('cancel', (_e) => {
|
||||
reject(new CapacitorException('User cancelled photos app'));
|
||||
cleanup();
|
||||
});
|
||||
}
|
||||
input.accept = 'image/*';
|
||||
input.click();
|
||||
}
|
||||
_getCameraPhoto(photo, options) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
const format = photo.type.split('/')[1];
|
||||
if (options.resultType === 'uri') {
|
||||
resolve({
|
||||
webPath: URL.createObjectURL(photo),
|
||||
format: format,
|
||||
saved: false,
|
||||
});
|
||||
}
|
||||
else {
|
||||
reader.readAsDataURL(photo);
|
||||
reader.onloadend = () => {
|
||||
const r = reader.result;
|
||||
if (options.resultType === 'dataUrl') {
|
||||
resolve({
|
||||
dataUrl: r,
|
||||
format: format,
|
||||
saved: false,
|
||||
});
|
||||
}
|
||||
else {
|
||||
resolve({
|
||||
base64String: r.split(',')[1],
|
||||
format: format,
|
||||
saved: false,
|
||||
});
|
||||
}
|
||||
};
|
||||
reader.onerror = e => {
|
||||
reject(e);
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
async checkPermissions() {
|
||||
if (typeof navigator === 'undefined' || !navigator.permissions) {
|
||||
throw this.unavailable('Permissions API not available in this browser');
|
||||
}
|
||||
try {
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/Permissions/query
|
||||
// the specific permissions that are supported varies among browsers that implement the
|
||||
// permissions API, so we need a try/catch in case 'camera' is invalid
|
||||
const permission = await window.navigator.permissions.query({
|
||||
name: 'camera',
|
||||
});
|
||||
return {
|
||||
camera: permission.state,
|
||||
photos: 'granted',
|
||||
};
|
||||
}
|
||||
catch (_a) {
|
||||
throw this.unavailable('Camera permissions are not available in this browser');
|
||||
}
|
||||
}
|
||||
async requestPermissions() {
|
||||
throw this.unimplemented('Not implemented on web.');
|
||||
}
|
||||
async pickLimitedLibraryPhotos() {
|
||||
throw this.unavailable('Not implemented on web.');
|
||||
}
|
||||
async getLimitedLibraryPhotos() {
|
||||
throw this.unavailable('Not implemented on web.');
|
||||
}
|
||||
}
|
||||
const Camera = new CameraWeb();
|
||||
export { Camera };
|
||||
//# sourceMappingURL=web.js.map
|
||||
1
node_modules/@capacitor/camera/dist/esm/web.js.map
generated
vendored
Normal file
1
node_modules/@capacitor/camera/dist/esm/web.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user