react-native-fs-turbo 0.1.4 → 0.2.0
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/README.md +20 -14
- package/RNFSTurbo.podspec +1 -0
- package/cpp/NativeRNFSTurboModule.cpp +2 -2
- package/cpp/NativeRNFSTurboModule.h +2 -18
- package/cpp/RNFSTurboHostObject.cpp +192 -164
- package/cpp/RNFSTurboHostObject.h +1 -1
- package/cpp/RNFSTurboLogger.h +10 -0
- package/cpp/filesystem/helpers.cpp +69 -11
- package/cpp/filesystem/helpers.h +7 -0
- package/ios/PrivacyInfo.xcprivacy +30 -0
- package/lib/commonjs/RNFSTurbo.js +1 -1
- package/lib/commonjs/RNFSTurbo.js.map +1 -1
- package/lib/commonjs/createRNFSTurbo.js +1 -1
- package/lib/commonjs/createRNFSTurbo.js.map +1 -1
- package/lib/module/RNFSTurbo.js +1 -1
- package/lib/module/RNFSTurbo.js.map +1 -1
- package/lib/module/createRNFSTurbo.js +1 -1
- package/lib/module/createRNFSTurbo.js.map +1 -1
- package/lib/typescript/NativeRNFSTurboModule.d.ts +1 -1
- package/lib/typescript/NativeRNFSTurboModule.d.ts.map +1 -1
- package/lib/typescript/Types.d.ts +1 -1
- package/lib/typescript/Types.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/NativeRNFSTurboModule.ts +1 -1
- package/src/RNFSTurbo.ts +1 -1
- package/src/Types.ts +7 -1
- package/src/createRNFSTurbo.ts +1 -1
package/README.md
CHANGED
|
@@ -102,12 +102,15 @@ import RNFSTurbo from 'react-native-fs-turbo';
|
|
|
102
102
|
const pathUtf8 = `${RNFSTurbo.DocumentDirectoryPath}/test_utf8.txt`;
|
|
103
103
|
const pathBase64 = `${RNFSTurbo.DocumentDirectoryPath}/test_base64.txt`;
|
|
104
104
|
const pathUint8 = `${RNFSTurbo.DocumentDirectoryPath}/test_uint8.txt`;
|
|
105
|
+
const pathFloat32 = `${RNFSTurbo.DocumentDirectoryPath}/test_float32.txt`;
|
|
105
106
|
|
|
106
107
|
try {
|
|
107
108
|
RNFSTurbo.writeFile(path, 'Lorem ipsum dolor sit amet', 'utf8');
|
|
108
109
|
RNFSTurbo.writeFile(path, 'TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQ=', 'base64');
|
|
109
110
|
// An array with uint8 can be passed as input data
|
|
110
111
|
RNFSTurbo.writeFile(path, [76, 111, 114, 101, 109, 32, 105, 112, 115, 117, 109, 32, 100, 111, 108, 111, 114, 32, 115, 105, 116, 32, 97, 109, 101, 116], 'uint8');
|
|
112
|
+
// An array with float32 can be passed as input data
|
|
113
|
+
RNFSTurbo.writeFile(path, [0.4233244061470032, 0.5435456037521362, 2.5345540046691895, 7.2343244552612305, 3.867867946624756, 0.7876875996589661], 'float32');
|
|
111
114
|
} catch (err: Error) {
|
|
112
115
|
console.log(err.message);
|
|
113
116
|
}
|
|
@@ -275,39 +278,42 @@ type ReadDirItem = {
|
|
|
275
278
|
|
|
276
279
|
Node.js style version of `readDir` that returns only the names. Note the lowercase `d`.
|
|
277
280
|
|
|
278
|
-
### `readFile(filepath: string, encoding?: 'utf8' | 'ascii' | 'base64' | 'uint8'): string | number[]`
|
|
281
|
+
### `readFile(filepath: string, encoding?: 'utf8' | 'ascii' | 'base64' | 'uint8' | 'float32'): string | number[]`
|
|
279
282
|
|
|
280
|
-
Reads the file at `path` and return contents. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`. Use `base64` or `uint8` for reading binary files.
|
|
283
|
+
Reads the file at `path` and return contents. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`. Use `base64` or `uint8` or `float32` for reading binary files.
|
|
281
284
|
|
|
282
285
|
Note: you will take quite a performance hit if you are reading big files
|
|
283
286
|
|
|
284
|
-
### `read(filepath: string, length: number, position: number, encoding?: 'utf8' | 'ascii' | 'base64' | 'uint8'): string | number[]`
|
|
287
|
+
### `read(filepath: string, length: number, position: number, encoding?: 'utf8' | 'ascii' | 'base64' | 'uint8' | 'float32'): string | number[]`
|
|
285
288
|
|
|
286
|
-
Reads `length` bytes from the given `position` of the file at `path` and returns contents. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`. Use `base64` or `uint8` for reading binary files.
|
|
289
|
+
Reads `length` bytes from the given `position` of the file at `path` and returns contents. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`, `float32`. Use `base64` or `uint8` or `float32` for reading binary files.
|
|
287
290
|
|
|
288
291
|
Note: reading big files piece by piece using this method may be useful in terms of performance.
|
|
292
|
+
Note: `float32` size is 4 bytes, so `position` and `length` should be specified in bytes (multiplied by 4)
|
|
289
293
|
|
|
290
|
-
### (Android only) `readFileAssets(filepath: string, encoding?: "utf8" | 'ascii' | "base64"
|
|
294
|
+
### (Android only) `readFileAssets(filepath: string, encoding?: "utf8" | 'ascii' | "base64") => string[]`
|
|
291
295
|
|
|
292
|
-
Reads the file at `path` in the Android app's assets folder and return contents. `encoding` can be one of `utf8` (default), `ascii`, `base64
|
|
296
|
+
Reads the file at `path` in the Android app's assets folder and return contents. `encoding` can be one of `utf8` (default), `ascii`, `base64`. Use `base64` or `uint8` for reading binary files.
|
|
293
297
|
|
|
294
298
|
`filepath` is the relative path to the file from the root of the `assets` folder.
|
|
295
299
|
|
|
296
|
-
### (Android only) `readFileRes: (filepath: string, encoding?: "utf8" | 'ascii' | "base64"
|
|
300
|
+
### (Android only) `readFileRes: (filepath: string, encoding?: "utf8" | 'ascii' | "base64") => string[]`
|
|
297
301
|
|
|
298
|
-
Reads the file named `filename` in the Android app's `res` folder and return contents. Only the file name (not folder) needs to be specified. The file type will be detected from the extension and automatically located within `res/drawable` (for image files) or `res/raw` (for everything else). `encoding` can be one of `utf8` (default), `ascii`, `base64
|
|
302
|
+
Reads the file named `filename` in the Android app's `res` folder and return contents. Only the file name (not folder) needs to be specified. The file type will be detected from the extension and automatically located within `res/drawable` (for image files) or `res/raw` (for everything else). `encoding` can be one of `utf8` (default), `ascii`, `base64`. Use `base64` for reading binary files.
|
|
299
303
|
|
|
300
|
-
### `writeFile(filepath: string, contents: string | number[], encoding?: "utf8" | 'ascii' | "base64" | "uint8"): void`
|
|
304
|
+
### `writeFile(filepath: string, contents: string | number[], encoding?: "utf8" | 'ascii' | "base64" | "uint8" | "float32"): void`
|
|
301
305
|
|
|
302
|
-
Write the `contents` to `filepath`. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`. `options` optionally takes an object specifying the file's properties, like mode etc.
|
|
306
|
+
Write the `contents` to `filepath`. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`, `float32`. `options` optionally takes an object specifying the file's properties, like mode etc.
|
|
303
307
|
|
|
304
|
-
### `appendFile(filepath: string, contents: string | number[], encoding?: "utf8" | 'ascii' | "base64" | "uint8"): void`
|
|
308
|
+
### `appendFile(filepath: string, contents: string | number[], encoding?: "utf8" | 'ascii' | "base64" | "uint8" | "float32"): void`
|
|
305
309
|
|
|
306
|
-
Append the `contents` to `filepath`. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`.
|
|
310
|
+
Append the `contents` to `filepath`. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`, `float32`.
|
|
307
311
|
|
|
308
|
-
### `write(filepath: string, contents: string | number[], position?: number, encoding?: "utf8" | "base64" | "uint8"): void`
|
|
312
|
+
### `write(filepath: string, contents: string | number[], position?: number, encoding?: "utf8" | "base64" | "uint8" | "float32"): void`
|
|
309
313
|
|
|
310
|
-
Write the `contents` to `filepath` at the given random access position. When `position` is `undefined` or `-1` the contents is appended to the end of the file. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`.
|
|
314
|
+
Write the `contents` to `filepath` at the given random access position. When `position` is `undefined` or `-1` the contents is appended to the end of the file. `encoding` can be one of `utf8` (default), `ascii`, `base64`, `uint8`, `float32`.
|
|
315
|
+
|
|
316
|
+
Note: `float32` size is 4 bytes, so `position` should be specified in bytes (multiplied by 4)
|
|
311
317
|
|
|
312
318
|
### `moveFile(filepath: string, destPath: string): void`
|
|
313
319
|
|
package/RNFSTurbo.podspec
CHANGED
|
@@ -15,8 +15,8 @@ NativeRNFSTurboModule::NativeRNFSTurboModule(std::shared_ptr<CallInvoker> jsInvo
|
|
|
15
15
|
|
|
16
16
|
NativeRNFSTurboModule::~NativeRNFSTurboModule() {}
|
|
17
17
|
|
|
18
|
-
jsi::Object NativeRNFSTurboModule::createRNFSTurbo(jsi::Runtime& runtime
|
|
19
|
-
auto instance = std::make_shared<RNFSTurboHostObject>(
|
|
18
|
+
jsi::Object NativeRNFSTurboModule::createRNFSTurbo(jsi::Runtime& runtime) {
|
|
19
|
+
auto instance = std::make_shared<RNFSTurboHostObject>();
|
|
20
20
|
return jsi::Object::createFromHostObject(runtime, instance);
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -19,29 +19,13 @@
|
|
|
19
19
|
|
|
20
20
|
namespace facebook::react {
|
|
21
21
|
|
|
22
|
-
// The RNFSTurboConfiguration type from JS
|
|
23
|
-
using RNFSTurboConfig = RNFSTurboModuleConfiguration<
|
|
24
|
-
std::string,
|
|
25
|
-
std::string,
|
|
26
|
-
std::string,
|
|
27
|
-
std::string,
|
|
28
|
-
std::string,
|
|
29
|
-
std::string,
|
|
30
|
-
std::string,
|
|
31
|
-
std::string,
|
|
32
|
-
std::string,
|
|
33
|
-
std::string,
|
|
34
|
-
std::string
|
|
35
|
-
>;
|
|
36
|
-
template <> struct Bridging<RNFSTurboConfig> : RNFSTurboModuleConfigurationBridging<RNFSTurboConfig> {};
|
|
37
|
-
|
|
38
22
|
// The TurboModule itself
|
|
39
23
|
class NativeRNFSTurboModule : public NativeRNFSTurboModuleCxxSpec<NativeRNFSTurboModule> {
|
|
40
24
|
public:
|
|
41
25
|
NativeRNFSTurboModule(std::shared_ptr<CallInvoker> jsInvoker);
|
|
42
26
|
~NativeRNFSTurboModule();
|
|
43
27
|
|
|
44
|
-
jsi::Object createRNFSTurbo(jsi::Runtime& runtime
|
|
28
|
+
jsi::Object createRNFSTurbo(jsi::Runtime& runtime);
|
|
45
29
|
};
|
|
46
30
|
|
|
47
|
-
} // namespace facebook::react
|
|
31
|
+
} // namespace facebook::react
|