expo-file-system 18.0.3 → 18.0.4
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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/android/src/main/java/expo/modules/filesystem/next/FileSystemFile.kt +7 -1
- package/android/src/main/java/expo/modules/filesystem/next/FileSystemNextModule.kt +4 -0
- package/build/next/ExpoFileSystem.types.d.ts +6 -1
- package/build/next/ExpoFileSystem.types.d.ts.map +1 -1
- package/ios/Next/FileSystemFile.swift +10 -1
- package/ios/Next/FileSystemNextModule.swift +4 -0
- package/package.json +2 -2
- package/src/next/ExpoFileSystem.types.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 18.0.4 — 2024-11-19
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- [next] Added `.bytes()` and writing a `Uint8Array`. ([#33020](https://github.com/expo/expo/pull/33020) by [@aleqsio](https://github.com/aleqsio))
|
|
18
|
+
|
|
13
19
|
## 18.0.3 — 2024-11-13
|
|
14
20
|
|
|
15
21
|
### 🎉 New features
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '18.0.
|
|
4
|
+
version = '18.0.4'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -14,7 +14,7 @@ android {
|
|
|
14
14
|
namespace "expo.modules.filesystem"
|
|
15
15
|
defaultConfig {
|
|
16
16
|
versionCode 30
|
|
17
|
-
versionName "18.0.
|
|
17
|
+
versionName "18.0.4"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -53,7 +53,7 @@ class FileSystemFile(file: File) : FileSystemPath(file) {
|
|
|
53
53
|
create()
|
|
54
54
|
}
|
|
55
55
|
FileOutputStream(file).use {
|
|
56
|
-
it.write(content.toDirectBuffer()
|
|
56
|
+
it.channel.write(content.toDirectBuffer())
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -74,6 +74,12 @@ class FileSystemFile(file: File) : FileSystemPath(file) {
|
|
|
74
74
|
return Base64.encodeToString(file.readBytes(), Base64.NO_WRAP)
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
fun bytes(): ByteArray {
|
|
78
|
+
validateType()
|
|
79
|
+
validatePermission(Permission.READ)
|
|
80
|
+
return file.readBytes()
|
|
81
|
+
}
|
|
82
|
+
|
|
77
83
|
@OptIn(ExperimentalStdlibApi::class)
|
|
78
84
|
val md5: String get() {
|
|
79
85
|
validatePermission(Permission.READ)
|
|
@@ -85,11 +85,16 @@ export declare class File {
|
|
|
85
85
|
* @returns The contents of the file as a base64 string.
|
|
86
86
|
*/
|
|
87
87
|
base64(): string;
|
|
88
|
+
/**
|
|
89
|
+
* Retrieves byte content of the entire file.
|
|
90
|
+
* @returns The contents of the file as a Uint8Array.
|
|
91
|
+
*/
|
|
92
|
+
bytes(): Uint8Array;
|
|
88
93
|
/**
|
|
89
94
|
* Writes content to the file.
|
|
90
95
|
* @param content - The content to write into the file.
|
|
91
96
|
*/
|
|
92
|
-
write(content: string): void;
|
|
97
|
+
write(content: string | Uint8Array): void;
|
|
93
98
|
/**
|
|
94
99
|
* Deletes a file.
|
|
95
100
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpoFileSystem.types.d.ts","sourceRoot":"","sources":["../../src/next/ExpoFileSystem.types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,SAAS;IAC5B;;;;;;;OAOG;gBACS,GAAG,IAAI,EAAE,CAAC,MA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,GAAG,OAAO,CAAC,IAAI,CAAC;IAEnF;;OAEG;IACH,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAEpB;;OAEG;IACH,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,OAAO,UAAU;IAI7B,KAAK,IAAI,IAAI;IAKb,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAKrC,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAMnC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAItB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB"}
|
|
@@ -73,8 +73,11 @@ internal final class FileSystemFile: FileSystemPath {
|
|
|
73
73
|
try content.write(to: url, atomically: false, encoding: .utf8) // TODO: better error handling
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
// TODO:
|
|
76
|
+
// TODO: blob support
|
|
77
77
|
func write(_ content: TypedArray) throws {
|
|
78
|
+
try validateType()
|
|
79
|
+
try validatePermission(.write)
|
|
80
|
+
try Data(bytes: content.rawPointer, count: content.byteLength).write(to: url)
|
|
78
81
|
}
|
|
79
82
|
|
|
80
83
|
func text() throws -> String {
|
|
@@ -83,6 +86,12 @@ internal final class FileSystemFile: FileSystemPath {
|
|
|
83
86
|
return try String(contentsOf: url)
|
|
84
87
|
}
|
|
85
88
|
|
|
89
|
+
func bytes() throws -> Data {
|
|
90
|
+
try validateType()
|
|
91
|
+
try validatePermission(.read)
|
|
92
|
+
return try Data(contentsOf: url)
|
|
93
|
+
}
|
|
94
|
+
|
|
86
95
|
func base64() throws -> String {
|
|
87
96
|
try validatePermission(.read)
|
|
88
97
|
return try Data(contentsOf: url).base64EncodedString()
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-file-system",
|
|
3
|
-
"version": "18.0.
|
|
3
|
+
"version": "18.0.4",
|
|
4
4
|
"description": "Provides access to the local file system on the device.",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"web-streams-polyfill": "^3.3.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "128718d43bac2eaed764b3551469b95400f2363e"
|
|
49
49
|
}
|
|
@@ -97,11 +97,17 @@ export declare class File {
|
|
|
97
97
|
*/
|
|
98
98
|
base64(): string;
|
|
99
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves byte content of the entire file.
|
|
102
|
+
* @returns The contents of the file as a Uint8Array.
|
|
103
|
+
*/
|
|
104
|
+
bytes(): Uint8Array;
|
|
105
|
+
|
|
100
106
|
/**
|
|
101
107
|
* Writes content to the file.
|
|
102
108
|
* @param content - The content to write into the file.
|
|
103
109
|
*/
|
|
104
|
-
write(content: string): void;
|
|
110
|
+
write(content: string | Uint8Array): void;
|
|
105
111
|
|
|
106
112
|
/**
|
|
107
113
|
* Deletes a file.
|