@amazon-devices/expo-file-system 2.0.1758683737
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +2 -0
- package/CHANGELOG.md +317 -0
- package/CMakeLists.txt +52 -0
- package/LICENSE +7 -0
- package/README.kepler.md +260 -0
- package/README.md +46 -0
- package/THIRD_PARTY_NOTICES.txt +24 -0
- package/android/build.gradle +118 -0
- package/android/src/main/AndroidManifest.xml +17 -0
- package/android/src/main/java/expo/modules/filesystem/AppDirectoriesModule.kt +26 -0
- package/android/src/main/java/expo/modules/filesystem/CountingRequestBody.kt +52 -0
- package/android/src/main/java/expo/modules/filesystem/FilePermissionModule.kt +48 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemExceptions.kt +48 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemFileProvider.kt +5 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemModule.kt +1110 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemPackage.kt +10 -0
- package/android/src/main/java/expo/modules/filesystem/FileSystemRecords.kt +92 -0
- package/android/src/main/res/xml/file_system_provider_paths.xml +5 -0
- package/app.plugin.js +1 -0
- package/build/ExponentFileSystem.d.ts +4 -0
- package/build/ExponentFileSystem.d.ts.map +1 -0
- package/build/ExponentFileSystem.js +5 -0
- package/build/ExponentFileSystem.js.map +1 -0
- package/build/ExponentFileSystem.kepler.d.ts +4 -0
- package/build/ExponentFileSystem.kepler.d.ts.map +1 -0
- package/build/ExponentFileSystem.kepler.js +112 -0
- package/build/ExponentFileSystem.kepler.js.map +1 -0
- package/build/ExponentFileSystem.web.d.ts +3 -0
- package/build/ExponentFileSystem.web.d.ts.map +1 -0
- package/build/ExponentFileSystem.web.js +3 -0
- package/build/ExponentFileSystem.web.js.map +1 -0
- package/build/ExponentFileSystemShim.d.ts +4 -0
- package/build/ExponentFileSystemShim.d.ts.map +1 -0
- package/build/ExponentFileSystemShim.js +21 -0
- package/build/ExponentFileSystemShim.js.map +1 -0
- package/build/FileSystem.d.ts +361 -0
- package/build/FileSystem.d.ts.map +1 -0
- package/build/FileSystem.js +616 -0
- package/build/FileSystem.js.map +1 -0
- package/build/FileSystem.types.d.ts +304 -0
- package/build/FileSystem.types.d.ts.map +1 -0
- package/build/FileSystem.types.js +47 -0
- package/build/FileSystem.types.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +3 -0
- package/build/index.js.map +1 -0
- package/build/types.d.ts +35 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/expo-module.config.json +11 -0
- package/ios/EXFilePermissionModule.h +16 -0
- package/ios/EXFilePermissionModule.m +68 -0
- package/ios/EXFileSystem.h +25 -0
- package/ios/EXFileSystem.m +1084 -0
- package/ios/EXFileSystemAssetLibraryHandler.h +6 -0
- package/ios/EXFileSystemAssetLibraryHandler.m +142 -0
- package/ios/EXFileSystemHandler.h +17 -0
- package/ios/EXFileSystemLocalFileHandler.h +7 -0
- package/ios/EXFileSystemLocalFileHandler.m +79 -0
- package/ios/EXSessionTasks/EXSessionCancelableUploadTaskDelegate.h +16 -0
- package/ios/EXSessionTasks/EXSessionCancelableUploadTaskDelegate.m +55 -0
- package/ios/EXSessionTasks/EXSessionDownloadTaskDelegate.h +13 -0
- package/ios/EXSessionTasks/EXSessionDownloadTaskDelegate.m +64 -0
- package/ios/EXSessionTasks/EXSessionHandler.h +19 -0
- package/ios/EXSessionTasks/EXSessionHandler.m +49 -0
- package/ios/EXSessionTasks/EXSessionResumableDownloadTaskDelegate.h +18 -0
- package/ios/EXSessionTasks/EXSessionResumableDownloadTaskDelegate.m +66 -0
- package/ios/EXSessionTasks/EXSessionTaskDelegate.h +32 -0
- package/ios/EXSessionTasks/EXSessionTaskDelegate.m +58 -0
- package/ios/EXSessionTasks/EXSessionTaskDispatcher.h +19 -0
- package/ios/EXSessionTasks/EXSessionTaskDispatcher.m +96 -0
- package/ios/EXSessionTasks/EXSessionUploadTaskDelegate.h +8 -0
- package/ios/EXSessionTasks/EXSessionUploadTaskDelegate.m +52 -0
- package/ios/EXSessionTasks/EXTaskHandlersManager.h +21 -0
- package/ios/EXSessionTasks/EXTaskHandlersManager.m +56 -0
- package/ios/Encoding.swift +88 -0
- package/ios/ExpoFileSystem.h +1 -0
- package/ios/ExpoFileSystem.podspec +32 -0
- package/ios/FileSystemBackgroundSessionHandler.swift +25 -0
- package/ios/FileSystemExceptions.swift +69 -0
- package/ios/FileSystemHelpers.swift +66 -0
- package/ios/FileSystemModule.swift +263 -0
- package/ios/FileSystemRecords.swift +74 -0
- package/ios/NSData+EXFileSystem.h +9 -0
- package/ios/NSData+EXFileSystem.m +19 -0
- package/ios/NetworkingHelpers.swift +84 -0
- package/ios/Tests/EXFileSystemSpec.swift +55 -0
- package/jest.config.js +3 -0
- package/kepler/ExponentFileSystem.cpp +498 -0
- package/kepler/ExponentFileSystem.h +60 -0
- package/kepler/KeplerInit.cpp +28 -0
- package/kepler/NetworkingRequestHandler.cpp +47 -0
- package/kepler/test/FileSystem.cpp +425 -0
- package/package.json +1 -0
- package/plugin/build/withFileSystem.d.ts +3 -0
- package/plugin/build/withFileSystem.js +12 -0
- package/plugin/src/withFileSystem.ts +13 -0
- package/plugin/tsconfig.json +9 -0
- package/plugin/tsconfig.tsbuildinfo +1 -0
- package/react-native.config.js +21 -0
- package/src/ExponentFileSystem.kepler.ts +167 -0
- package/src/ExponentFileSystem.ts +7 -0
- package/src/ExponentFileSystem.web.ts +2 -0
- package/src/ExponentFileSystemShim.ts +23 -0
- package/src/FileSystem.ts +756 -0
- package/src/FileSystem.types.ts +339 -0
- package/src/index.ts +2 -0
- package/src/types.ts +34 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
package expo.modules.filesystem
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import expo.modules.core.BasePackage
|
|
5
|
+
import expo.modules.core.interfaces.InternalModule
|
|
6
|
+
|
|
7
|
+
class FileSystemPackage : BasePackage() {
|
|
8
|
+
override fun createInternalModules(context: Context): List<InternalModule> =
|
|
9
|
+
listOf(FilePermissionModule(), AppDirectoriesModule(context))
|
|
10
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
package expo.modules.filesystem
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.records.Field
|
|
4
|
+
import expo.modules.kotlin.records.Record
|
|
5
|
+
import expo.modules.kotlin.types.Enumerable
|
|
6
|
+
|
|
7
|
+
data class InfoOptions(
|
|
8
|
+
@Field
|
|
9
|
+
val md5: Boolean?,
|
|
10
|
+
@Field
|
|
11
|
+
val size: Boolean?
|
|
12
|
+
) : Record
|
|
13
|
+
|
|
14
|
+
data class DeletingOptions(
|
|
15
|
+
@Field
|
|
16
|
+
val idempotent: Boolean = false
|
|
17
|
+
) : Record
|
|
18
|
+
|
|
19
|
+
data class ReadingOptions(
|
|
20
|
+
@Field
|
|
21
|
+
val encoding: EncodingType = EncodingType.UTF8,
|
|
22
|
+
@Field
|
|
23
|
+
val position: Int?,
|
|
24
|
+
@Field
|
|
25
|
+
val length: Int?
|
|
26
|
+
) : Record
|
|
27
|
+
|
|
28
|
+
enum class EncodingType(val value: String) : Enumerable {
|
|
29
|
+
UTF8("utf8"),
|
|
30
|
+
BASE64("base64")
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
enum class SessionType(val value: Int) : Enumerable {
|
|
34
|
+
BACKGROUND(0),
|
|
35
|
+
FOREGROUND(1)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
enum class FileSystemUploadType(val value: Int) : Enumerable {
|
|
39
|
+
BINARY_CONTENT(0),
|
|
40
|
+
MULTIPART(1)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
data class MakeDirectoryOptions(
|
|
44
|
+
@Field
|
|
45
|
+
val intermediates: Boolean = false
|
|
46
|
+
) : Record
|
|
47
|
+
|
|
48
|
+
data class RelocatingOptions(
|
|
49
|
+
@Field
|
|
50
|
+
val from: String,
|
|
51
|
+
@Field
|
|
52
|
+
val to: String
|
|
53
|
+
) : Record
|
|
54
|
+
|
|
55
|
+
data class DownloadOptions(
|
|
56
|
+
@Field
|
|
57
|
+
val md5: Boolean = false,
|
|
58
|
+
@Field
|
|
59
|
+
val cache: Boolean?,
|
|
60
|
+
@Field
|
|
61
|
+
val headers: Map<String, String>?,
|
|
62
|
+
@Field
|
|
63
|
+
val sessionType: SessionType = SessionType.BACKGROUND
|
|
64
|
+
) : Record
|
|
65
|
+
|
|
66
|
+
data class WritingOptions(
|
|
67
|
+
@Field
|
|
68
|
+
val encoding: EncodingType = EncodingType.UTF8
|
|
69
|
+
) : Record
|
|
70
|
+
|
|
71
|
+
data class FileSystemUploadOptions(
|
|
72
|
+
@Field
|
|
73
|
+
val headers: Map<String, String>?,
|
|
74
|
+
@Field
|
|
75
|
+
val httpMethod: HttpMethod = HttpMethod.POST,
|
|
76
|
+
@Field
|
|
77
|
+
val sessionType: SessionType = SessionType.BACKGROUND,
|
|
78
|
+
@Field
|
|
79
|
+
val uploadType: FileSystemUploadType,
|
|
80
|
+
@Field
|
|
81
|
+
val fieldName: String?,
|
|
82
|
+
@Field
|
|
83
|
+
val mimeType: String?,
|
|
84
|
+
@Field
|
|
85
|
+
val parameters: Map<String, String>?
|
|
86
|
+
) : Record
|
|
87
|
+
|
|
88
|
+
enum class HttpMethod(val value: String) : Enumerable {
|
|
89
|
+
POST("POST"),
|
|
90
|
+
PUT("PUT"),
|
|
91
|
+
PATCH("PATCH")
|
|
92
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./plugin/build/withFileSystem');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.d.ts","sourceRoot":"","sources":["../src/ExponentFileSystem.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;;AAEnD,wBACyB"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { requireOptionalNativeModule } from 'expo-modules-core';
|
|
2
|
+
import ExponentFileSystemShim from './ExponentFileSystemShim';
|
|
3
|
+
export default requireOptionalNativeModule('ExponentFileSystem') ??
|
|
4
|
+
ExponentFileSystemShim;
|
|
5
|
+
//# sourceMappingURL=ExponentFileSystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.js","sourceRoot":"","sources":["../src/ExponentFileSystem.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAG9D,eAAe,2BAA2B,CAA2B,oBAAoB,CAAC;IACxF,sBAAsB,CAAC","sourcesContent":["import { requireOptionalNativeModule } from 'expo-modules-core';\n\nimport ExponentFileSystemShim from './ExponentFileSystemShim';\nimport { ExponentFileSystemModule } from './types';\n\nexport default requireOptionalNativeModule<ExponentFileSystemModule>('ExponentFileSystem') ??\n ExponentFileSystemShim;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.kepler.d.ts","sourceRoot":"","sources":["../src/ExponentFileSystem.kepler.ts"],"names":[],"mappings":"AAgBA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAwCnD,QAAA,MAAM,MAAM,EAAE,wBA4Gb,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { TurboModuleRegistry } from '@amazon-devices/keplerscript-turbomodule-api';
|
|
2
|
+
const nativeModule = TurboModuleRegistry.getEnforcing('ExponentFileSystem');
|
|
3
|
+
const expoCryptoNativeModule = TurboModuleRegistry.getEnforcing('ExpoCrypto');
|
|
4
|
+
function getHeadersFromResponse(response) {
|
|
5
|
+
const responseHeaders = {};
|
|
6
|
+
response.headers.forEach((value, key) => {
|
|
7
|
+
responseHeaders[key] = value;
|
|
8
|
+
});
|
|
9
|
+
return responseHeaders;
|
|
10
|
+
}
|
|
11
|
+
function getMimeTypeFromHeaders(responseHeaders) {
|
|
12
|
+
const contentTypeKey = Object.keys(responseHeaders).find((key) => key.toLowerCase() === "content-type");
|
|
13
|
+
return contentTypeKey ? responseHeaders[contentTypeKey].split(';')[0] : null;
|
|
14
|
+
}
|
|
15
|
+
const module = {
|
|
16
|
+
get name() {
|
|
17
|
+
return 'ExponentFileSystem';
|
|
18
|
+
},
|
|
19
|
+
get documentDirectory() {
|
|
20
|
+
return nativeModule.documentDirectory();
|
|
21
|
+
},
|
|
22
|
+
get cacheDirectory() {
|
|
23
|
+
return nativeModule.cacheDirectory();
|
|
24
|
+
},
|
|
25
|
+
/**
|
|
26
|
+
* @deprecated this property was removed from expo
|
|
27
|
+
*/
|
|
28
|
+
get bundledAssets() {
|
|
29
|
+
return null;
|
|
30
|
+
},
|
|
31
|
+
get bundleDirectory() {
|
|
32
|
+
return nativeModule.bundleDirectory();
|
|
33
|
+
},
|
|
34
|
+
async getInfoAsync(fileUri, options) {
|
|
35
|
+
return nativeModule.getInfoAsync(fileUri, options);
|
|
36
|
+
},
|
|
37
|
+
async readAsStringAsync(fileUri, options) {
|
|
38
|
+
return nativeModule.readAsStringAsync(fileUri, options);
|
|
39
|
+
},
|
|
40
|
+
async getContentUriAsync(fileUri) {
|
|
41
|
+
return nativeModule.getContentUriAsync(fileUri);
|
|
42
|
+
},
|
|
43
|
+
async writeAsStringAsync(fileUri, contents, options) {
|
|
44
|
+
return nativeModule.writeAsStringAsync(fileUri, contents, options);
|
|
45
|
+
},
|
|
46
|
+
async deleteAsync(fileUri, options) {
|
|
47
|
+
return nativeModule.deleteAsync(fileUri, options);
|
|
48
|
+
},
|
|
49
|
+
async moveAsync(options) {
|
|
50
|
+
return nativeModule.moveAsync(options);
|
|
51
|
+
},
|
|
52
|
+
async copyAsync(options) {
|
|
53
|
+
return nativeModule.copyAsync(options);
|
|
54
|
+
},
|
|
55
|
+
async makeDirectoryAsync(fileUri, options) {
|
|
56
|
+
return nativeModule.makeDirectoryAsync(fileUri, options);
|
|
57
|
+
},
|
|
58
|
+
async readDirectoryAsync(fileUri) {
|
|
59
|
+
return nativeModule.readDirectoryAsync(fileUri);
|
|
60
|
+
},
|
|
61
|
+
async getFreeDiskStorageAsync() {
|
|
62
|
+
return nativeModule.getFreeDiskStorageAsync().then(parseInt);
|
|
63
|
+
},
|
|
64
|
+
async getTotalDiskCapacityAsync() {
|
|
65
|
+
const result = await nativeModule.getTotalDiskCapacityAsync();
|
|
66
|
+
return result ? parseInt(result) : 0;
|
|
67
|
+
},
|
|
68
|
+
async downloadAsync(url, fileUri, options) {
|
|
69
|
+
const { headers, md5 } = options;
|
|
70
|
+
const response = await fetch(url, { headers });
|
|
71
|
+
if (!response.ok) {
|
|
72
|
+
throw new Error('Failed to download the file!');
|
|
73
|
+
}
|
|
74
|
+
const data = await response.arrayBuffer();
|
|
75
|
+
await nativeModule.writeArrayBufferAsync(fileUri, data);
|
|
76
|
+
const responseHeaders = getHeadersFromResponse(response);
|
|
77
|
+
let downloadResult = {
|
|
78
|
+
uri: fileUri,
|
|
79
|
+
headers: responseHeaders,
|
|
80
|
+
status: response.status,
|
|
81
|
+
mimeType: getMimeTypeFromHeaders(responseHeaders)
|
|
82
|
+
};
|
|
83
|
+
if (md5) {
|
|
84
|
+
const md5ArrayBuffer = await expoCryptoNativeModule.digestAsync("MD5", data);
|
|
85
|
+
downloadResult.md5 = [...new Uint8Array(md5ArrayBuffer)]
|
|
86
|
+
.map(x => x.toString(16).padStart(2, '0'))
|
|
87
|
+
.join('');
|
|
88
|
+
}
|
|
89
|
+
return downloadResult;
|
|
90
|
+
},
|
|
91
|
+
async uploadAsync(url, fileUri, options) {
|
|
92
|
+
const { headers, httpMethod } = options;
|
|
93
|
+
const method = httpMethod ?? "POST";
|
|
94
|
+
const data = await nativeModule.readAsStringAsync(fileUri, {});
|
|
95
|
+
const response = await fetch(url, { method, headers, body: data });
|
|
96
|
+
if (!response.ok) {
|
|
97
|
+
throw new Error('Failed to upload the file!');
|
|
98
|
+
}
|
|
99
|
+
const uploadResult = await response.text();
|
|
100
|
+
const responseHeaders = getHeadersFromResponse(response);
|
|
101
|
+
return {
|
|
102
|
+
body: uploadResult,
|
|
103
|
+
headers: responseHeaders,
|
|
104
|
+
status: response.status,
|
|
105
|
+
mimeType: getMimeTypeFromHeaders(responseHeaders)
|
|
106
|
+
};
|
|
107
|
+
},
|
|
108
|
+
addListener(eventName) { },
|
|
109
|
+
removeListeners(count) { },
|
|
110
|
+
};
|
|
111
|
+
export default module;
|
|
112
|
+
//# sourceMappingURL=ExponentFileSystem.kepler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.kepler.js","sourceRoot":"","sources":["../src/ExponentFileSystem.kepler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAwC5F,MAAM,YAAY,GAAG,mBAAmB,CAAC,YAAY,CAAO,oBAAoB,CAAS,CAAC;AAC1F,MAAM,sBAAsB,GAAG,mBAAmB,CAAC,YAAY,CAAM,YAAY,CAAC,CAAC;AAEnF,SAAS,sBAAsB,CAAC,QAAkB;IAChD,MAAM,eAAe,GAAwC,EAAE,CAAC;IAChE,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAa,EAAE,GAAW,EAAE,EAAE;QACtD,eAAe,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC/B,CAAC,CAAC,CAAA;IACF,OAAO,eAAe,CAAC;AACzB,CAAC;AAED,SAAS,sBAAsB,CAAC,eAAgD;IAC9E,MAAM,cAAc,GAAG,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,cAAc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AM,EAAE,QAAQ,CAAC,MAAM;YACvB,QAAQ,EAAE,sBAAsB,CAAC,eAAe,CAAC;SAClD,CAAC;IACJ,CAAC;IACD,WAAW,CAAC,SAAiB,IAAQ,CAAC;IACtC,eAAe,CAAC,KAAa,IAAQ,CAAC;CACzC,CAAC;AAEF,eAAe,MAAM,CAAC","sourcesContent":["import { KeplerTurboModule, TurboModuleRegistry } from '@amazon-devices/keplerscript-turbomodule-api';\n\nimport {\n DeletingOptions,\n DownloadOptions,\n FileInfo,\n FileSystemDownloadResult,\n FileSystemUploadOptions,\n FileSystemUploadResult,\n InfoOptions,\n MakeDirectoryOptions,\n ReadingOptions,\n RelocatingOptions,\n WritingOptions,\n FileSystemHttpResult,\n} from './FileSystem.types';\nimport { ExponentFileSystemModule } from './types';\n\ninterface Spec extends KeplerTurboModule {\n readonly documentDirectory: () => string;\n readonly cacheDirectory: () => string;\n /**\n * @deprecated this property was removed from expo\n */\n readonly bundledAssets: () => string;\n readonly bundleDirectory: () => string;\n readonly getInfoAsync: (fileUri: string, options: InfoOptions) => Promise<FileInfo>;\n readonly readAsStringAsync: (fileUri: string, options: ReadingOptions) => Promise<string>;\n readonly getContentUriAsync: (fileUri: string) => Promise<string>;\n readonly writeAsStringAsync: (fileUri: string, contents: string, options: WritingOptions) => Promise<void>;\n readonly writeArrayBufferAsync: (fileUri: string, contents: ArrayBuffer) => Promise<void>;\n readonly deleteAsync: (fileUri: string, options: DeletingOptions) => Promise<void>;\n readonly moveAsync: (options: RelocatingOptions) => Promise<void>;\n readonly copyAsync: (options: RelocatingOptions) => Promise<void>;\n readonly makeDirectoryAsync: (fileUri: string, options: MakeDirectoryOptions) => Promise<void>;\n readonly readDirectoryAsync: (fileUri: string) => Promise<string[]>;\n readonly getFreeDiskStorageAsync: () => Promise<string>;\n readonly getTotalDiskCapacityAsync: () => Promise<string | undefined>;\n}\n\nconst nativeModule = TurboModuleRegistry.getEnforcing<Spec>('ExponentFileSystem') as Spec;\nconst expoCryptoNativeModule = TurboModuleRegistry.getEnforcing<any>('ExpoCrypto');\n\nfunction getHeadersFromResponse(response: Response): FileSystemHttpResult['headers'] {\n const responseHeaders: FileSystemDownloadResult['headers'] = {};\n response.headers.forEach((value: string, key: string) => {\n responseHeaders[key] = value;\n })\n return responseHeaders;\n}\n\nfunction getMimeTypeFromHeaders(responseHeaders: FileSystemHttpResult['headers']): FileSystemHttpResult['mimeType'] {\n const contentTypeKey = Object.keys(responseHeaders).find((key) => key.toLowerCase() === \"content-type\");\n return contentTypeKey ? responseHeaders[contentTypeKey].split(';')[0] : null;\n}\n\nconst module: ExponentFileSystemModule = {\n get name(): 'ExponentFileSystem' {\n return 'ExponentFileSystem';\n },\n get documentDirectory() {\n return nativeModule.documentDirectory();\n },\n get cacheDirectory() {\n return nativeModule.cacheDirectory();\n },\n /**\n * @deprecated this property was removed from expo\n */\n get bundledAssets() {\n return null;\n },\n get bundleDirectory() {\n return nativeModule.bundleDirectory();\n },\n async getInfoAsync(fileUri: string, options: InfoOptions) {\n return nativeModule.getInfoAsync(fileUri, options);\n },\n async readAsStringAsync(fileUri: string, options: ReadingOptions) {\n return nativeModule.readAsStringAsync(fileUri, options);\n },\n async getContentUriAsync(fileUri: string) {\n return nativeModule.getContentUriAsync(fileUri);\n },\n async writeAsStringAsync(fileUri: string, contents: string, options: WritingOptions) {\n return nativeModule.writeAsStringAsync(fileUri, contents, options);\n },\n async deleteAsync(fileUri: string, options: DeletingOptions) {\n return nativeModule.deleteAsync(fileUri, options);\n },\n async moveAsync(options: RelocatingOptions) {\n return nativeModule.moveAsync(options);\n },\n async copyAsync(options: RelocatingOptions) {\n return nativeModule.copyAsync(options);\n },\n async makeDirectoryAsync(fileUri: string, options: MakeDirectoryOptions) {\n return nativeModule.makeDirectoryAsync(fileUri, options);\n },\n async readDirectoryAsync(fileUri: string) {\n return nativeModule.readDirectoryAsync(fileUri);\n },\n async getFreeDiskStorageAsync() {\n return nativeModule.getFreeDiskStorageAsync().then(parseInt);\n },\n async getTotalDiskCapacityAsync() {\n const result = await nativeModule.getTotalDiskCapacityAsync();\n return result ? parseInt(result) : 0;\n },\n async downloadAsync(url: string, fileUri: string, options: DownloadOptions): Promise<FileSystemDownloadResult> {\n const { headers, md5 } = options;\n const response = await fetch(url, { headers });\n\n if (!response.ok) {\n throw new Error('Failed to download the file!');\n }\n\n const data = await response.arrayBuffer();\n\n await nativeModule.writeArrayBufferAsync(fileUri, data);\n\n const responseHeaders = getHeadersFromResponse(response);\n\n let downloadResult: FileSystemDownloadResult = {\n uri: fileUri,\n headers: responseHeaders,\n status: response.status,\n mimeType: getMimeTypeFromHeaders(responseHeaders)\n };\n\n if (md5) {\n const md5ArrayBuffer = await expoCryptoNativeModule.digestAsync(\"MD5\", data);\n downloadResult.md5 = [...new Uint8Array(md5ArrayBuffer)]\n .map(x => x.toString(16).padStart(2, '0'))\n .join('');\n }\n\n return downloadResult;\n },\n async uploadAsync(url: string, fileUri: string, options: FileSystemUploadOptions): Promise<FileSystemUploadResult> {\n const { headers, httpMethod } = options;\n const method = httpMethod ?? \"POST\";\n\n const data = await nativeModule.readAsStringAsync(fileUri, {});\n\n const response = await fetch(url, { method, headers, body: data });\n\n if (!response.ok) {\n throw new Error('Failed to upload the file!');\n }\n\n const uploadResult = await response.text();\n\n const responseHeaders = getHeadersFromResponse(response);\n\n return {\n body: uploadResult,\n headers: responseHeaders,\n status: response.status,\n mimeType: getMimeTypeFromHeaders(responseHeaders)\n };\n },\n addListener(eventName: string): void{},\n removeListeners(count: number): void{},\n};\n\nexport default module;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.web.d.ts","sourceRoot":"","sources":["../src/ExponentFileSystem.web.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,eAAe,sBAAsB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystem.web.js","sourceRoot":"","sources":["../src/ExponentFileSystem.web.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,MAAM,0BAA0B,CAAC;AAC9D,eAAe,sBAAsB,CAAC","sourcesContent":["import ExponentFileSystemShim from './ExponentFileSystemShim';\nexport default ExponentFileSystemShim;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystemShim.d.ts","sourceRoot":"","sources":["../src/ExponentFileSystemShim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD,QAAA,MAAM,cAAc,EAAE,wBAkBrB,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const platformModule = {
|
|
2
|
+
get name() {
|
|
3
|
+
return 'ExponentFileSystem';
|
|
4
|
+
},
|
|
5
|
+
get documentDirectory() {
|
|
6
|
+
return null;
|
|
7
|
+
},
|
|
8
|
+
get cacheDirectory() {
|
|
9
|
+
return null;
|
|
10
|
+
},
|
|
11
|
+
get bundledAssets() {
|
|
12
|
+
return null;
|
|
13
|
+
},
|
|
14
|
+
get bundleDirectory() {
|
|
15
|
+
return null;
|
|
16
|
+
},
|
|
17
|
+
addListener(eventName) { },
|
|
18
|
+
removeListeners(count) { },
|
|
19
|
+
};
|
|
20
|
+
export default platformModule;
|
|
21
|
+
//# sourceMappingURL=ExponentFileSystemShim.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentFileSystemShim.js","sourceRoot":"","sources":["../src/ExponentFileSystemShim.ts"],"names":[],"mappings":"AAEA,MAAM,cAAc,GAA6B;IAC/C,IAAI,IAAI;QACN,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IACD,IAAI,iBAAiB;QACnB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,aAAa;QACf,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;IACD,WAAW,CAAC,SAAiB,IAAS,CAAC;IACvC,eAAe,CAAC,KAAa,IAAS,CAAC;CACxC,CAAC;AAEF,eAAe,cAAc,CAAC","sourcesContent":["import { ExponentFileSystemModule } from './types';\n\nconst platformModule: ExponentFileSystemModule = {\n get name(): 'ExponentFileSystem' {\n return 'ExponentFileSystem';\n },\n get documentDirectory(): string | null {\n return null;\n },\n get cacheDirectory(): string | null {\n return null;\n },\n get bundledAssets(): string | null {\n return null;\n },\n get bundleDirectory(): string | null {\n return null;\n },\n addListener(eventName: string): void {},\n removeListeners(count: number): void {},\n};\n\nexport default platformModule;\n"]}
|