mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-02-21 00:23:00 +08:00
chore(camera): update camera
This commit is contained in:
parent
072173308d
commit
5bed810624
94
dist/plugins/camera.d.ts
vendored
94
dist/plugins/camera.d.ts
vendored
@ -1,3 +1,85 @@
|
||||
export interface CameraOptions {
|
||||
/** Picture quality in range 0-100. Default is 50 */
|
||||
quality?: number;
|
||||
/**
|
||||
* Choose the format of the return value.
|
||||
* Defined in navigator.camera.DestinationType. Default is FILE_URI.
|
||||
* DATA_URL : 0, Return image as base64-encoded string
|
||||
* FILE_URI : 1, Return image file URI
|
||||
* NATIVE_URI : 2 Return image native URI
|
||||
* (e.g., assets-library:// on iOS or content:// on Android)
|
||||
*/
|
||||
destinationType?: number;
|
||||
/**
|
||||
* Set the source of the picture.
|
||||
* Defined in navigator.camera.PictureSourceType. Default is CAMERA.
|
||||
* PHOTOLIBRARY : 0,
|
||||
* CAMERA : 1,
|
||||
* SAVEDPHOTOALBUM : 2
|
||||
*/
|
||||
sourceType?: number;
|
||||
/** Allow simple editing of image before selection. */
|
||||
allowEdit?: boolean;
|
||||
/**
|
||||
* Choose the returned image file's encoding.
|
||||
* Defined in navigator.camera.EncodingType. Default is JPEG
|
||||
* JPEG : 0 Return JPEG encoded image
|
||||
* PNG : 1 Return PNG encoded image
|
||||
*/
|
||||
encodingType?: number;
|
||||
/**
|
||||
* Width in pixels to scale image. Must be used with targetHeight.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetWidth?: number;
|
||||
/**
|
||||
* Height in pixels to scale image. Must be used with targetWidth.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetHeight?: number;
|
||||
/**
|
||||
* Set the type of media to select from. Only works when PictureSourceType
|
||||
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType
|
||||
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
|
||||
* Will return format specified via DestinationType
|
||||
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
|
||||
* ALLMEDIA : 2 allow selection from all media types
|
||||
*/
|
||||
mediaType?: number;
|
||||
/** Rotate the image to correct for the orientation of the device during capture. */
|
||||
correctOrientation?: boolean;
|
||||
/** Save the image to the photo album on the device after capture. */
|
||||
saveToPhotoAlbum?: boolean;
|
||||
/**
|
||||
* Choose the camera to use (front- or back-facing).
|
||||
* Defined in navigator.camera.Direction. Default is BACK.
|
||||
* FRONT: 0
|
||||
* BACK: 1
|
||||
*/
|
||||
cameraDirection?: number;
|
||||
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
|
||||
popoverOptions?: CameraPopoverOptions;
|
||||
}
|
||||
/**
|
||||
* iOS-only parameters that specify the anchor element location and arrow direction
|
||||
* of the popover when selecting images from an iPad's library or album.
|
||||
*/
|
||||
export interface CameraPopoverOptions {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
/**
|
||||
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
|
||||
* Matches iOS UIPopoverArrowDirection constants.
|
||||
* ARROW_UP : 1,
|
||||
* ARROW_DOWN : 2,
|
||||
* ARROW_LEFT : 4,
|
||||
* ARROW_RIGHT : 8,
|
||||
* ARROW_ANY : 15
|
||||
*/
|
||||
arrowDir: number;
|
||||
}
|
||||
/**
|
||||
* Take a photo or capture video.
|
||||
*
|
||||
@ -14,6 +96,16 @@
|
||||
* ```
|
||||
*/
|
||||
export declare class Camera {
|
||||
static getPicture(options: any): void;
|
||||
/**
|
||||
* Take a picture or video, or load one from the library.
|
||||
* @param {CameraOptions} options
|
||||
* @return Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
|
||||
*/
|
||||
static getPicture(options: CameraOptions): Promise<any>;
|
||||
/**
|
||||
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
|
||||
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
|
||||
* @return Returns a Promise
|
||||
*/
|
||||
static cleanup(): void;
|
||||
}
|
||||
|
20
dist/plugins/camera.js
vendored
20
dist/plugins/camera.js
vendored
@ -23,13 +23,29 @@ var plugin_1 = require('./plugin');
|
||||
var Camera = (function () {
|
||||
function Camera() {
|
||||
}
|
||||
Camera.getPicture = function (options) { };
|
||||
/**
|
||||
* Take a picture or video, or load one from the library.
|
||||
* @param {CameraOptions} options
|
||||
* @return Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
|
||||
*/
|
||||
Camera.getPicture = function (options) {
|
||||
// This Promise is replaced by one from the @Cordova decorator that wraps
|
||||
// the plugin's callbacks. We provide a dummy one here so TypeScript
|
||||
// knows that the correct return type is Promise, because there's no way
|
||||
// for it to know the return type from a decorator.
|
||||
// See https://github.com/Microsoft/TypeScript/issues/4881
|
||||
return new Promise(function (res, rej) { });
|
||||
};
|
||||
;
|
||||
/**
|
||||
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
|
||||
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
|
||||
* @return Returns a Promise
|
||||
*/
|
||||
Camera.cleanup = function () { };
|
||||
;
|
||||
__decorate([
|
||||
plugin_1.Cordova({
|
||||
// Not sure why this plugin has the success/err come first...
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
], Camera, "getPicture", null);
|
||||
|
2
dist/plugins/camera.js.map
vendored
2
dist/plugins/camera.js.map
vendored
@ -1 +1 @@
|
||||
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/plugins/camera.ts"],"names":["Camera","Camera.constructor","Camera.getPicture","Camera.cleanup"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAEzC;;;;;;;;;;;;;;GAcG;AACH;IAAAA;IAcAC,CAACA;IAJQD,iBAAUA,GAJjBA,UAIkBA,OAAWA,IAAEE,CAACA;;IAGzBF,cAAOA,GADdA,cACiBG,CAACA;;IAPlBH;QAACA,gBAAOA,CAACA;YACPA,6DAA6DA;YAC7DA,aAAaA,EAAEA,SAASA;SACzBA,CAACA;OACKA,oBAAUA,QAAeA;IAEhCA;QAACA,gBAAOA,EAAEA;OACHA,iBAAOA,QAAIA;IAbpBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,kBAAkBA;SAC9BA,CAACA;eAUDA;IAADA,aAACA;AAADA,CAACA,AAdD,IAcC;AATY,cAAM,SASlB,CAAA"}
|
||||
{"version":3,"file":"camera.js","sourceRoot":"","sources":["../../src/plugins/camera.ts"],"names":["Camera","Camera.constructor","Camera.getPicture","Camera.cleanup"],"mappings":";;;;;;AAAA,uBAA8B,UAAU,CAAC,CAAA;AAsFzC;;;;;;;;;;;;;;GAcG;AACH;IAAAA;IA8BAC,CAACA;IAxBCD;;;;OAIGA;IAIIA,iBAAUA,GAHjBA,UAGkBA,OAAsBA;QACtCE,yEAAyEA;QACzEA,oEAAoEA;QACpEA,wEAAwEA;QACxEA,mDAAmDA;QACnDA,0DAA0DA;QAC1DA,MAAMA,CAACA,IAAIA,OAAOA,CAAMA,UAACA,GAAGA,EAAEA,GAAGA,IAAMA,CAACA,CAACA,CAACA;IAC5CA,CAACA;;IAEDF;;;;OAIGA;IAEIA,cAAOA,GADdA,cACiBG,CAACA;;IAlBlBH;QAACA,gBAAOA,CAACA;YACPA,aAAaA,EAAEA,SAASA;SACzBA,CAACA;OACKA,oBAAUA,QAOhBA;IAODA;QAACA,gBAAOA,EAAEA;OACHA,iBAAOA,QAAIA;IA7BpBA;QAACA,eAAMA,CAACA;YACNA,IAAIA,EAAEA,QAAQA;YACdA,MAAMA,EAAEA,uBAAuBA;YAC/BA,SAASA,EAAEA,kBAAkBA;SAC9BA,CAACA;eA0BDA;IAADA,aAACA;AAADA,CAACA,AA9BD,IA8BC;AAzBY,cAAM,SAyBlB,CAAA"}
|
@ -1,5 +1,89 @@
|
||||
import {Plugin, Cordova} from './plugin';
|
||||
|
||||
export interface CameraOptions {
|
||||
/** Picture quality in range 0-100. Default is 50 */
|
||||
quality?: number;
|
||||
/**
|
||||
* Choose the format of the return value.
|
||||
* Defined in navigator.camera.DestinationType. Default is FILE_URI.
|
||||
* DATA_URL : 0, Return image as base64-encoded string
|
||||
* FILE_URI : 1, Return image file URI
|
||||
* NATIVE_URI : 2 Return image native URI
|
||||
* (e.g., assets-library:// on iOS or content:// on Android)
|
||||
*/
|
||||
destinationType?: number;
|
||||
/**
|
||||
* Set the source of the picture.
|
||||
* Defined in navigator.camera.PictureSourceType. Default is CAMERA.
|
||||
* PHOTOLIBRARY : 0,
|
||||
* CAMERA : 1,
|
||||
* SAVEDPHOTOALBUM : 2
|
||||
*/
|
||||
sourceType?: number;
|
||||
/** Allow simple editing of image before selection. */
|
||||
allowEdit?: boolean;
|
||||
/**
|
||||
* Choose the returned image file's encoding.
|
||||
* Defined in navigator.camera.EncodingType. Default is JPEG
|
||||
* JPEG : 0 Return JPEG encoded image
|
||||
* PNG : 1 Return PNG encoded image
|
||||
*/
|
||||
encodingType?: number;
|
||||
/**
|
||||
* Width in pixels to scale image. Must be used with targetHeight.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetWidth?: number;
|
||||
/**
|
||||
* Height in pixels to scale image. Must be used with targetWidth.
|
||||
* Aspect ratio remains constant.
|
||||
*/
|
||||
targetHeight?: number;
|
||||
/**
|
||||
* Set the type of media to select from. Only works when PictureSourceType
|
||||
* is PHOTOLIBRARY or SAVEDPHOTOALBUM. Defined in nagivator.camera.MediaType
|
||||
* PICTURE: 0 allow selection of still pictures only. DEFAULT.
|
||||
* Will return format specified via DestinationType
|
||||
* VIDEO: 1 allow selection of video only, WILL ALWAYS RETURN FILE_URI
|
||||
* ALLMEDIA : 2 allow selection from all media types
|
||||
*/
|
||||
mediaType?: number;
|
||||
/** Rotate the image to correct for the orientation of the device during capture. */
|
||||
correctOrientation?: boolean;
|
||||
/** Save the image to the photo album on the device after capture. */
|
||||
saveToPhotoAlbum?: boolean;
|
||||
/**
|
||||
* Choose the camera to use (front- or back-facing).
|
||||
* Defined in navigator.camera.Direction. Default is BACK.
|
||||
* FRONT: 0
|
||||
* BACK: 1
|
||||
*/
|
||||
cameraDirection?: number;
|
||||
/** iOS-only options that specify popover location in iPad. Defined in CameraPopoverOptions. */
|
||||
popoverOptions?: CameraPopoverOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* iOS-only parameters that specify the anchor element location and arrow direction
|
||||
* of the popover when selecting images from an iPad's library or album.
|
||||
*/
|
||||
export interface CameraPopoverOptions {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
/**
|
||||
* Direction the arrow on the popover should point. Defined in Camera.PopoverArrowDirection
|
||||
* Matches iOS UIPopoverArrowDirection constants.
|
||||
* ARROW_UP : 1,
|
||||
* ARROW_DOWN : 2,
|
||||
* ARROW_LEFT : 4,
|
||||
* ARROW_RIGHT : 8,
|
||||
* ARROW_ANY : 15
|
||||
*/
|
||||
arrowDir : number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a photo or capture video.
|
||||
*
|
||||
@ -21,12 +105,30 @@ import {Plugin, Cordova} from './plugin';
|
||||
pluginRef: 'navigator.camera'
|
||||
})
|
||||
export class Camera {
|
||||
/**
|
||||
* Take a picture or video, or load one from the library.
|
||||
* @param {CameraOptions} options
|
||||
* @return Returns a Promise that resolves with Base64 encoding of the image data, or the image file URI, depending on cameraOptions, otherwise rejects with an error.
|
||||
*/
|
||||
@Cordova({
|
||||
// Not sure why this plugin has the success/err come first...
|
||||
callbackOrder: 'reverse'
|
||||
})
|
||||
static getPicture(options:any){};
|
||||
static getPicture(options: CameraOptions){
|
||||
// This Promise is replaced by one from the @Cordova decorator that wraps
|
||||
// the plugin's callbacks. We provide a dummy one here so TypeScript
|
||||
// knows that the correct return type is Promise, because there's no way
|
||||
// for it to know the return type from a decorator.
|
||||
// See https://github.com/Microsoft/TypeScript/issues/4881
|
||||
return new Promise<any>((res, rej) => {});
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove intermediate image files that are kept in temporary storage after calling camera.getPicture.
|
||||
* Applies only when the value of Camera.sourceType equals Camera.PictureSourceType.CAMERA and the Camera.destinationType equals Camera.DestinationType.FILE_URI.
|
||||
* @return Returns a Promise
|
||||
*/
|
||||
@Cordova()
|
||||
static cleanup(){};
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user