/
FileSystem.types.ts
99 lines (87 loc) · 2.41 KB
/
FileSystem.types.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
export type DownloadOptions = {
md5?: boolean;
cache?: boolean;
headers?: { [name: string]: string };
};
export type DownloadResult = {
uri: string;
status: number;
headers: { [name: string]: string };
md5?: string;
};
export type DownloadProgressCallback = (data: DownloadProgressData) => void;
export type DownloadProgressData = {
totalBytesWritten: number;
totalBytesExpectedToWrite: number;
};
export type DownloadPauseState = {
url: string;
fileUri: string;
options: DownloadOptions;
resumeData?: string;
};
export type FileInfo =
| {
exists: true;
uri: string;
size: number;
isDirectory: boolean;
modificationTime: number;
md5?: string;
}
| {
exists: false;
uri: string;
size: undefined;
isDirectory: false;
modificationTime: undefined;
md5: undefined;
};
export enum EncodingType {
UTF8 = 'utf8',
Base64 = 'base64',
}
export type ReadingOptions = {
encoding?: EncodingType | 'utf8' | 'base64';
position?: number;
length?: number;
};
export type WritingOptions = {
encoding?: EncodingType | 'utf8' | 'base64';
};
export type ProgressEvent = {
uuid: string;
data: {
totalBytesWritten: number;
totalBytesExpectedToWrite: number;
};
};
export type FileSystemContentUri = {
uri: string;
};
type PlatformMethod = (...args: any[]) => Promise<any>;
export interface ExponentFileSystemModule {
readonly name: 'ExponentFileSystem';
readonly documentDirectory: string | null;
readonly cacheDirectory: string | null;
readonly bundledAssets: string | null;
readonly bundleDirectory: string | null;
readonly getInfoAsync?: PlatformMethod;
readonly readAsStringAsync?: PlatformMethod;
readonly writeAsStringAsync?: PlatformMethod;
readonly deleteAsync?: PlatformMethod;
readonly moveAsync?: PlatformMethod;
readonly copyAsync?: PlatformMethod;
readonly makeDirectoryAsync?: PlatformMethod;
readonly readDirectoryAsync?: PlatformMethod;
readonly downloadAsync?: PlatformMethod;
readonly downloadResumableStartAsync?: PlatformMethod;
readonly downloadResumablePauseAsync?: PlatformMethod;
readonly getContentUriAsync?: PlatformMethod;
readonly getFreeDiskStorageAsync?: PlatformMethod;
readonly getTotalDiskCapacityAsync?: PlatformMethod;
startObserving?: () => void;
stopObserving?: () => void;
addListener: (eventName: string) => void;
removeListeners: (count: number) => void;
}