2019-03-03 06:39:57 +00:00
|
|
|
/**
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
*/
|
|
|
|
|
2019-08-14 17:14:14 +00:00
|
|
|
declare namespace CameraRoll {
|
|
|
|
type GroupType =
|
|
|
|
| 'Album'
|
|
|
|
| 'All'
|
|
|
|
| 'Event'
|
|
|
|
| 'Faces'
|
|
|
|
| 'Library'
|
|
|
|
| 'PhotoStream'
|
|
|
|
| 'SavedPhotos';
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2019-08-14 17:14:14 +00:00
|
|
|
type AssetType = 'All' | 'Videos' | 'Photos';
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
type Include =
|
|
|
|
/** Ensures the filename is included. Has a large performance hit on iOS */
|
|
|
|
| 'filename'
|
|
|
|
/** Ensures the fileSize is included. Has a large performance hit on iOS */
|
|
|
|
| 'fileSize'
|
|
|
|
/** Ensures the location is included. Has a medium performance hit on Android */
|
2020-06-23 05:45:20 +00:00
|
|
|
| 'location'
|
|
|
|
/** Ensures the image width and height are included. Has a small performance hit on Android */
|
|
|
|
| 'imageSize'
|
|
|
|
/** Ensures the image playableDuration is included. Has a medium performance hit on Android */
|
|
|
|
| 'playableDuration';
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Shape of the param arg for the `getPhotosFast` function.
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
interface GetPhotosParams {
|
2020-06-16 10:20:51 +00:00
|
|
|
/**
|
|
|
|
* The number of photos wanted in reverse order of the photo application
|
|
|
|
* (i.e. most recent first).
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
first: number;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A cursor that matches `page_info { end_cursor }` returned from a previous
|
|
|
|
* call to `getPhotos`. Note that using this will reduce performance
|
|
|
|
* slightly on iOS. An alternative is just using the `fromTime` and `toTime`
|
|
|
|
* filters, which have no such impact.
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
after?: string;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies which group types to filter the results to.
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
groupTypes?: GroupType;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies filter on group names, like 'Recent Photos' or custom album
|
|
|
|
* titles.
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
groupName?: string;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Specifies filter on asset type
|
|
|
|
*/
|
2019-08-14 17:14:14 +00:00
|
|
|
assetType?: AssetType;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter by creation time with a timestamp in milliseconds. This time is
|
|
|
|
* exclusive, so we'll select all photos with `timestamp > fromTime`.
|
|
|
|
*/
|
2020-02-05 09:20:54 +00:00
|
|
|
fromTime?: number;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter by creation time with a timestamp in milliseconds. This time is
|
|
|
|
* inclusive, so we'll select all photos with `timestamp <= toTime`.
|
|
|
|
*/
|
2020-02-05 09:20:54 +00:00
|
|
|
toTime?: number;
|
2020-06-16 10:20:51 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter by mimetype (e.g. image/jpeg). Note that using this will reduce
|
|
|
|
* performance slightly on iOS.
|
|
|
|
*/
|
|
|
|
mimeTypes?: Array<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Specific fields in the output that we want to include, even though they
|
|
|
|
* might have some performance impact.
|
|
|
|
*/
|
|
|
|
include?: Include[];
|
2019-08-14 17:14:14 +00:00
|
|
|
}
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2019-08-14 17:14:14 +00:00
|
|
|
interface PhotoIdentifier {
|
|
|
|
node: {
|
2020-06-16 10:20:51 +00:00
|
|
|
type: string;
|
|
|
|
group_name: string;
|
2019-08-14 17:14:14 +00:00
|
|
|
image: {
|
2020-06-16 10:20:51 +00:00
|
|
|
/** Only set if the `include` parameter contains `filename`. */
|
|
|
|
filename: string | null;
|
|
|
|
uri: string;
|
2020-06-23 05:45:20 +00:00
|
|
|
/** Only set if the `include` parameter contains `imageSize`. */
|
2020-06-16 10:20:51 +00:00
|
|
|
height: number;
|
2020-06-23 05:45:20 +00:00
|
|
|
/** Only set if the `include` parameter contains `imageSize`. */
|
2020-06-16 10:20:51 +00:00
|
|
|
width: number;
|
|
|
|
/** Only set if the `include` parameter contains `fileSize`. */
|
|
|
|
fileSize: number | null;
|
2020-06-23 05:45:20 +00:00
|
|
|
/**
|
|
|
|
* Only set if the `include` parameter contains `playableDuration`.
|
|
|
|
* Will be null for images.
|
|
|
|
*/
|
|
|
|
playableDuration: number | null;
|
2020-06-16 10:20:51 +00:00
|
|
|
};
|
|
|
|
/** Timestamp in seconds. */
|
|
|
|
timestamp: number;
|
|
|
|
/** Only set if the `include` parameter contains `location`. */
|
|
|
|
location: {
|
|
|
|
latitude?: number;
|
|
|
|
longitude?: number;
|
|
|
|
altitude?: number;
|
|
|
|
heading?: number;
|
|
|
|
speed?: number;
|
|
|
|
} | null;
|
2019-08-14 17:14:14 +00:00
|
|
|
};
|
|
|
|
}
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2019-08-14 17:14:14 +00:00
|
|
|
interface PhotoIdentifiersPage {
|
|
|
|
edges: Array<PhotoIdentifier>;
|
|
|
|
page_info: {
|
2020-06-16 10:20:51 +00:00
|
|
|
has_next_page: boolean;
|
|
|
|
start_cursor?: string;
|
|
|
|
end_cursor?: string;
|
2019-08-14 17:14:14 +00:00
|
|
|
};
|
|
|
|
}
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2020-02-08 03:17:56 +00:00
|
|
|
interface GetAlbumsParams {
|
|
|
|
assetType?: AssetType;
|
|
|
|
}
|
|
|
|
|
|
|
|
interface Album {
|
|
|
|
title: string;
|
|
|
|
count: number;
|
|
|
|
}
|
|
|
|
|
2019-08-14 19:00:20 +00:00
|
|
|
type SaveToCameraRollOptions = {
|
2020-06-16 10:20:51 +00:00
|
|
|
type?: 'photo' | 'video' | 'auto';
|
|
|
|
album?: string;
|
2019-08-14 19:00:20 +00:00
|
|
|
};
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
/**
|
|
|
|
* `CameraRoll.saveImageWithTag()` is deprecated. Use `CameraRoll.saveToCameraRoll()` instead.
|
|
|
|
*/
|
|
|
|
function saveImageWithTag(tag: string): Promise<string>;
|
2019-03-03 06:39:57 +00:00
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
/**
|
|
|
|
* Delete a photo from the camera roll or media library. photoUris is an array of photo uri's.
|
|
|
|
*/
|
|
|
|
function deletePhotos(photoUris: Array<string>): Promise<boolean>;
|
2019-08-14 19:00:20 +00:00
|
|
|
|
2023-10-14 14:59:36 +00:00
|
|
|
/**
|
|
|
|
* Returns the Camera Roll images count on iOS.
|
|
|
|
*/
|
|
|
|
function getPhotosCountiOS(): Promise<number>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the Camera Roll favorite images count on iOS.
|
|
|
|
*/
|
|
|
|
function getFavoritesiOS(): Promise<Album>;
|
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
/**
|
|
|
|
* Saves the photo or video to the camera roll or photo library.
|
|
|
|
*/
|
|
|
|
function saveToCameraRoll(
|
|
|
|
tag: string,
|
|
|
|
type?: 'photo' | 'video',
|
|
|
|
): Promise<string>;
|
2020-06-16 09:07:25 +00:00
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
/**
|
|
|
|
* Saves the photo or video to the camera roll or photo library.
|
|
|
|
*/
|
|
|
|
function save(
|
|
|
|
tag: string,
|
|
|
|
options?: SaveToCameraRollOptions,
|
|
|
|
): Promise<string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a Promise with photo identifier objects from the local camera
|
|
|
|
* roll of the device matching shape defined by `getPhotosReturnChecker`.
|
|
|
|
*/
|
|
|
|
function getPhotos(params: GetPhotosParams): Promise<PhotoIdentifiersPage>;
|
2020-02-08 03:17:56 +00:00
|
|
|
|
2020-06-16 10:20:51 +00:00
|
|
|
function getAlbums(params: GetAlbumsParams): Promise<Album[]>;
|
2019-03-03 06:39:57 +00:00
|
|
|
}
|
2019-04-03 11:20:54 +00:00
|
|
|
|
2019-08-14 17:14:14 +00:00
|
|
|
export = CameraRoll;
|