UNPKG

3.68 kBTypeScriptView Raw
1import { Subscription } from '@unimodules/core';
2import { PermissionResponse, PermissionStatus } from 'unimodules-permissions-interface';
3export declare type MediaTypeValue = 'audio' | 'photo' | 'video' | 'unknown';
4export declare type SortByKey = 'default' | 'mediaType' | 'width' | 'height' | 'creationTime' | 'modificationTime' | 'duration';
5export declare type SortByValue = [SortByKey, boolean] | SortByKey;
6export declare type MediaTypeObject = {
7 audio: 'audio';
8 photo: 'photo';
9 video: 'video';
10 unknown: 'unknown';
11};
12export declare type SortByObject = {
13 default: 'default';
14 mediaType: 'mediaType';
15 width: 'width';
16 height: 'height';
17 creationTime: 'creationTime';
18 modificationTime: 'modificationTime';
19 duration: 'duration';
20};
21export declare type Asset = {
22 id: string;
23 filename: string;
24 uri: string;
25 mediaType: MediaTypeValue;
26 mediaSubtypes?: string[];
27 width: number;
28 height: number;
29 creationTime: number;
30 modificationTime: number;
31 duration: number;
32 albumId?: string;
33};
34export declare type AssetInfo = Asset & {
35 localUri?: string;
36 location?: Location;
37 exif?: object;
38 isFavorite?: boolean;
39};
40export declare type Location = {
41 latitude: number;
42 longitude: number;
43};
44export declare type Album = {
45 id: string;
46 title: string;
47 assetCount: number;
48 type?: string;
49 startTime: number;
50 endTime: number;
51 approximateLocation?: Location;
52 locationNames?: string[];
53};
54export declare type AlbumsOptions = {
55 includeSmartAlbums?: boolean;
56};
57export declare type AssetsOptions = {
58 first?: number;
59 after?: AssetRef;
60 album?: AlbumRef;
61 sortBy?: SortByValue[] | SortByValue;
62 mediaType?: MediaTypeValue[] | MediaTypeValue;
63 createdAfter?: Date | number;
64 createdBefore?: Date | number;
65};
66export declare type PagedInfo<T> = {
67 assets: T[];
68 endCursor: string;
69 hasNextPage: boolean;
70 totalCount: number;
71};
72export { PermissionStatus, PermissionResponse };
73export declare type AssetRef = Asset | string;
74export declare type AlbumRef = Album | string;
75export declare const MediaType: MediaTypeObject;
76export declare const SortBy: SortByObject;
77export declare function requestPermissionsAsync(): Promise<PermissionResponse>;
78export declare function getPermissionsAsync(): Promise<PermissionResponse>;
79export declare function createAssetAsync(localUri: string): Promise<Asset>;
80export declare function saveToLibraryAsync(localUri: string): Promise<void>;
81export declare function addAssetsToAlbumAsync(assets: AssetRef[] | AssetRef, album: AlbumRef, copy?: boolean): Promise<any>;
82export declare function removeAssetsFromAlbumAsync(assets: AssetRef[] | AssetRef, album: AlbumRef): Promise<any>;
83export declare function deleteAssetsAsync(assets: AssetRef[] | AssetRef): Promise<any>;
84export declare function getAssetInfoAsync(asset: AssetRef): Promise<AssetInfo>;
85export declare function getAlbumsAsync({ includeSmartAlbums }?: AlbumsOptions): Promise<Album[]>;
86export declare function getAlbumAsync(title: string): Promise<Album>;
87export declare function createAlbumAsync(albumName: string, asset?: AssetRef, copyAsset?: boolean): Promise<Album>;
88export declare function deleteAlbumsAsync(albums: AlbumRef[] | AlbumRef, assetRemove?: boolean): Promise<any>;
89export declare function getAssetsAsync(assetsOptions?: AssetsOptions): Promise<PagedInfo<Asset>>;
90export declare function addListener(listener: () => void): Subscription;
91export declare function removeSubscription(subscription: Subscription): void;
92export declare function removeAllListeners(): void;
93export declare function getMomentsAsync(): Promise<any>;