UNPKG

3.97 kBTypeScriptView Raw
1export declare enum FileSystemSessionType {
2 BACKGROUND = 0,
3 FOREGROUND = 1
4}
5export declare enum FileSystemUploadType {
6 BINARY_CONTENT = 0,
7 MULTIPART = 1
8}
9export declare type DownloadOptions = {
10 md5?: boolean;
11 cache?: boolean;
12 headers?: Record<string, string>;
13 sessionType?: FileSystemSessionType;
14};
15export declare type FileSystemHttpResult = {
16 headers: Record<string, string>;
17 status: number;
18 mimeType: string | null;
19};
20export declare type FileSystemDownloadResult = FileSystemHttpResult & {
21 uri: string;
22 md5?: string;
23};
24/**
25 * @deprecated Use `FileSystemDownloadResult` instead.
26 */
27export declare type DownloadResult = FileSystemDownloadResult;
28export declare type FileSystemUploadOptions = ({
29 uploadType?: FileSystemUploadType.BINARY_CONTENT;
30} | {
31 uploadType: FileSystemUploadType.MULTIPART;
32 fieldName?: string;
33 mimeType?: string;
34 parameters?: Record<string, string>;
35}) & {
36 headers?: Record<string, string>;
37 httpMethod?: FileSystemAcceptedUploadHttpMethod;
38 sessionType?: FileSystemSessionType;
39};
40export declare type FileSystemUploadResult = FileSystemHttpResult & {
41 body: string;
42};
43export declare type DownloadProgressCallback = (data: DownloadProgressData) => void;
44export declare type DownloadProgressData = {
45 totalBytesWritten: number;
46 totalBytesExpectedToWrite: number;
47};
48export declare type DownloadPauseState = {
49 url: string;
50 fileUri: string;
51 options: DownloadOptions;
52 resumeData?: string;
53};
54export declare type FileInfo = {
55 exists: true;
56 uri: string;
57 size: number;
58 isDirectory: boolean;
59 modificationTime: number;
60 md5?: string;
61} | {
62 exists: false;
63 uri: string;
64 size: undefined;
65 isDirectory: false;
66 modificationTime: undefined;
67 md5: undefined;
68};
69export declare enum EncodingType {
70 UTF8 = "utf8",
71 Base64 = "base64"
72}
73export declare type FileSystemAcceptedUploadHttpMethod = 'POST' | 'PUT' | 'PATCH';
74export declare type ReadingOptions = {
75 encoding?: EncodingType | 'utf8' | 'base64';
76 position?: number;
77 length?: number;
78};
79export declare type WritingOptions = {
80 encoding?: EncodingType | 'utf8' | 'base64';
81};
82export declare type ProgressEvent = {
83 uuid: string;
84 data: {
85 totalBytesWritten: number;
86 totalBytesExpectedToWrite: number;
87 };
88};
89export declare type FileSystemRequestDirectoryPermissionsResult = {
90 granted: true;
91 directoryUri: string;
92} | {
93 granted: false;
94};
95declare type PlatformMethod = (...args: any[]) => Promise<any>;
96export interface ExponentFileSystemModule {
97 readonly name: 'ExponentFileSystem';
98 readonly documentDirectory: string | null;
99 readonly cacheDirectory: string | null;
100 readonly bundledAssets: string | null;
101 readonly bundleDirectory: string | null;
102 readonly getInfoAsync?: PlatformMethod;
103 readonly readAsStringAsync?: PlatformMethod;
104 readonly writeAsStringAsync?: PlatformMethod;
105 readonly deleteAsync?: PlatformMethod;
106 readonly moveAsync?: PlatformMethod;
107 readonly copyAsync?: PlatformMethod;
108 readonly makeDirectoryAsync?: PlatformMethod;
109 readonly readDirectoryAsync?: PlatformMethod;
110 readonly downloadAsync?: PlatformMethod;
111 readonly uploadAsync?: PlatformMethod;
112 readonly downloadResumableStartAsync?: PlatformMethod;
113 readonly downloadResumablePauseAsync?: PlatformMethod;
114 readonly getContentUriAsync?: PlatformMethod;
115 readonly getFreeDiskStorageAsync?: PlatformMethod;
116 readonly getTotalDiskCapacityAsync?: PlatformMethod;
117 readonly requestDirectoryPermissionsAsync?: PlatformMethod;
118 readonly readSAFDirectoryAsync?: PlatformMethod;
119 readonly makeSAFDirectoryAsync?: PlatformMethod;
120 readonly createSAFFileAsync?: PlatformMethod;
121 startObserving?: () => void;
122 stopObserving?: () => void;
123 addListener: (eventName: string) => void;
124 removeListeners: (count: number) => void;
125}
126export {};