react-native-fs-turbo 0.3.7 → 0.4.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.
Files changed (66) hide show
  1. package/README.md +119 -27
  2. package/RNFSTurbo.podspec +2 -2
  3. package/android/CMakeLists.txt +62 -9
  4. package/android/build.gradle +80 -3
  5. package/android/gradle.properties +5 -5
  6. package/android/src/main/codegen/RNFSTurboSpec.java +17 -0
  7. package/android/src/main/cpp/JNIOnLoad.cpp +18 -0
  8. package/android/src/main/cpp/RNFSTurboLogger.cpp +4 -0
  9. package/android/src/main/cpp/RNFSTurboModule.cpp +44 -0
  10. package/android/src/main/cpp/RNFSTurboModule.h +40 -0
  11. package/android/src/main/cpp/RNFSTurboPlatformHelper.cpp +5 -1
  12. package/android/src/main/java/com/cmpayc/rnfsturbo/JNIOnLoad.java +27 -0
  13. package/android/src/main/java/com/cmpayc/rnfsturbo/{RNFSTurboPlatformContextModule.java → RNFSTurboModule.java} +62 -11
  14. package/android/src/main/java/com/cmpayc/rnfsturbo/RNFSTurboPackage.java +11 -9
  15. package/cpp/RNFSTurboHostObject.cpp +138 -15
  16. package/cpp/RNFSTurboHostObject.h +12 -4
  17. package/cpp/RNFSTurboInstall.cpp +27 -0
  18. package/cpp/RNFSTurboInstall.h +20 -0
  19. package/cpp/RNFSTurboLogger.h +4 -0
  20. package/cpp/RNFSTurboPlatformHelper.h +4 -0
  21. package/cpp/algorithms/Krypt/AES.cpp +502 -0
  22. package/cpp/algorithms/Krypt/bytearray.cpp +158 -0
  23. package/cpp/algorithms/Krypt/functions.cpp +137 -0
  24. package/cpp/algorithms/Krypt/mode.cpp +203 -0
  25. package/cpp/algorithms/Krypt/padding.cpp +219 -0
  26. package/cpp/encryption/encryption-utils.cpp +162 -0
  27. package/cpp/encryption/encryption-utils.h +43 -0
  28. package/cpp/filesystem/{helpers.cpp → filesystem-utils.cpp} +5 -1
  29. package/cpp/filesystem/{helpers.h → filesystem-utils.h} +4 -0
  30. package/ios/RNFSTurboLogger.mm +4 -0
  31. package/ios/{RNFSTurboPlatformContextModule.h → RNFSTurboModule.h} +3 -3
  32. package/ios/{RNFSTurboPlatformContextModule.mm → RNFSTurboModule.mm} +22 -5
  33. package/ios/RNFSTurboPlatformHelper.mm +4 -0
  34. package/lib/commonjs/NativeRNFSTurboModule.js +14 -16
  35. package/lib/commonjs/NativeRNFSTurboModule.js.map +1 -1
  36. package/lib/commonjs/createRNFSTurbo.js +3 -2
  37. package/lib/commonjs/createRNFSTurbo.js.map +1 -1
  38. package/lib/commonjs/globals.d.js +6 -0
  39. package/lib/commonjs/globals.d.js.map +1 -0
  40. package/lib/module/NativeRNFSTurboModule.js +14 -16
  41. package/lib/module/NativeRNFSTurboModule.js.map +1 -1
  42. package/lib/module/createRNFSTurbo.js +3 -2
  43. package/lib/module/createRNFSTurbo.js.map +1 -1
  44. package/lib/module/globals.d.js +4 -0
  45. package/lib/module/globals.d.js.map +1 -0
  46. package/lib/typescript/NativeRNFSTurboModule.d.ts +12 -3
  47. package/lib/typescript/NativeRNFSTurboModule.d.ts.map +1 -1
  48. package/lib/typescript/Types.d.ts +11 -0
  49. package/lib/typescript/Types.d.ts.map +1 -1
  50. package/lib/typescript/createRNFSTurbo.d.ts.map +1 -1
  51. package/package.json +6 -3
  52. package/react-native.config.js +1 -5
  53. package/src/NativeRNFSTurboModule.ts +25 -21
  54. package/src/Types.ts +11 -0
  55. package/src/createRNFSTurbo.ts +4 -2
  56. package/src/globals.d.ts +9 -0
  57. package/cpp/NativeRNFSTurboModule.cpp +0 -24
  58. package/cpp/NativeRNFSTurboModule.h +0 -31
  59. package/ios/RNFSTurboOnLoad.mm +0 -25
  60. package/lib/commonjs/NativeRNFSTurboPlatformContextModule.js +0 -22
  61. package/lib/commonjs/NativeRNFSTurboPlatformContextModule.js.map +0 -1
  62. package/lib/module/NativeRNFSTurboPlatformContextModule.js +0 -18
  63. package/lib/module/NativeRNFSTurboPlatformContextModule.js.map +0 -1
  64. package/lib/typescript/NativeRNFSTurboPlatformContextModule.d.ts +0 -16
  65. package/lib/typescript/NativeRNFSTurboPlatformContextModule.d.ts.map +0 -1
  66. package/src/NativeRNFSTurboPlatformContextModule.ts +0 -34
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-fs-turbo",
3
- "version": "0.3.7",
3
+ "version": "0.4.0",
4
4
  "description": "React-Native library for working with Android/iOS file system, written using JSI and C++ TurboModules",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -65,7 +65,10 @@
65
65
  "codegenConfig": {
66
66
  "name": "RNFSTurboSpec",
67
67
  "type": "modules",
68
- "jsSrcsDir": "src"
68
+ "jsSrcsDir": "src",
69
+ "android": {
70
+ "javaPackageName": "com.cmpayc.rnfsturbo"
71
+ }
69
72
  },
70
73
  "devDependencies": {
71
74
  "@typescript-eslint/eslint-plugin": "^7.0.0",
@@ -77,7 +80,7 @@
77
80
  "eslint-plugin-prettier": "^5.2.1",
78
81
  "prettier": "^3.3.3",
79
82
  "react": "^18.3.1",
80
- "react-native": "^0.74.2",
83
+ "react-native": "0.75.1",
81
84
  "react-native-builder-bob": "^0.30.2",
82
85
  "release-it": "^17.10.0",
83
86
  "typescript": "^5.1.6"
@@ -10,11 +10,7 @@ module.exports = {
10
10
  /**
11
11
  * @type {import('@react-native-community/cli-types').AndroidDependencyParams}
12
12
  */
13
- android: {
14
- cxxModuleCMakeListsModuleName: 'react-native-fs-turbo',
15
- cxxModuleCMakeListsPath: 'CMakeLists.txt',
16
- cxxModuleHeaderName: 'NativeRNFSTurboModule',
17
- },
13
+ android: {},
18
14
  },
19
15
  },
20
16
  };
@@ -1,8 +1,7 @@
1
+ /* eslint-disable import/no-import-module-exports */
1
2
  import type { TurboModule } from "react-native";
2
3
  import { TurboModuleRegistry } from "react-native";
3
- import { UnsafeObject } from "react-native/Libraries/Types/CodegenTypes";
4
4
  import { ModuleNotFoundError } from "./ModuleNotFoundError";
5
- import { getRNFSTurboPlatformContextTurboModule } from "./NativeRNFSTurboPlatformContextModule";
6
5
 
7
6
  /**
8
7
  * Used for configuration of a single RNFSTurbo instance.
@@ -28,9 +27,19 @@ export interface Configuration {
28
27
  export interface Spec extends TurboModule {
29
28
  /**
30
29
  * Create a new instance of RNFSTurbo.
31
- * The returned {@linkcode UnsafeObject} is a `jsi::HostObject`.
32
30
  */
33
- readonly createRNFSTurbo: () => UnsafeObject;
31
+ readonly createRNFSTurbo: () => boolean;
32
+ getMainBundlePath(): string;
33
+ getCachesDirectoryPath(): string;
34
+ getDocumentDirectoryPath(): string;
35
+ getTemporaryDirectoryPath(): string;
36
+ getLibraryDirectoryPath(): string;
37
+ getExternalDirectoryPath(): string;
38
+ getExternalStorageDirectoryPath(): string;
39
+ getExternalCachesDirectoryPath(): string;
40
+ getDownloadDirectoryPath(): string;
41
+ getPicturesDirectoryPath(): string;
42
+ getRoamingDirectoryPath(): string;
34
43
  }
35
44
 
36
45
  let module: Spec | null;
@@ -45,24 +54,19 @@ export function getRNFSTurboModule(): {
45
54
  // 1. Load RNFS TurboModule
46
55
  module = TurboModuleRegistry.getEnforcing<Spec>("RNFSTurboModule");
47
56
 
48
- // 2. Get the PlatformContext TurboModule as well
49
- const platformContext = getRNFSTurboPlatformContextTurboModule();
50
-
51
- // 3. Initialize it with the storage directores from platform-specific context
57
+ // 2. Create platform-specific configuration
52
58
  configuration = {
53
- mainBundlePath: platformContext.getMainBundlePath(),
54
- cachesDirectoryPath: platformContext.getCachesDirectoryPath(),
55
- documentDirectoryPath: platformContext.getDocumentDirectoryPath(),
56
- temporaryDirectoryPath: platformContext.getTemporaryDirectoryPath(),
57
- libraryDirectoryPath: platformContext.getLibraryDirectoryPath(),
58
- externalDirectoryPath: platformContext.getExternalDirectoryPath(),
59
- externalStorageDirectoryPath:
60
- platformContext.getExternalStorageDirectoryPath(),
61
- externalCachesDirectoryPath:
62
- platformContext.getExternalCachesDirectoryPath(),
63
- downloadDirectoryPath: platformContext.getDownloadDirectoryPath(),
64
- picturesDirectoryPath: platformContext.getPicturesDirectoryPath(),
65
- roamingDirectoryPath: platformContext.getRoamingDirectoryPath(),
59
+ mainBundlePath: module.getMainBundlePath(),
60
+ cachesDirectoryPath: module.getCachesDirectoryPath(),
61
+ documentDirectoryPath: module.getDocumentDirectoryPath(),
62
+ temporaryDirectoryPath: module.getTemporaryDirectoryPath(),
63
+ libraryDirectoryPath: module.getLibraryDirectoryPath(),
64
+ externalDirectoryPath: module.getExternalDirectoryPath(),
65
+ externalStorageDirectoryPath: module.getExternalStorageDirectoryPath(),
66
+ externalCachesDirectoryPath: module.getExternalCachesDirectoryPath(),
67
+ downloadDirectoryPath: module.getDownloadDirectoryPath(),
68
+ picturesDirectoryPath: module.getPicturesDirectoryPath(),
69
+ roamingDirectoryPath: module.getRoamingDirectoryPath(),
66
70
  };
67
71
  }
68
72
 
package/src/Types.ts CHANGED
@@ -105,6 +105,7 @@ export type FSInfoResult = {
105
105
  freeSpace: number; // The amount of available storage space on the device (in bytes).
106
106
  totalSpaceEx?: number; // The amount of available external storage space on the device (in bytes) (android only)
107
107
  freeSpaceEx?: number; // The amount of available external storage space on the device (in bytes) (android only)
108
+ encryptionEnabled: boolean; // Check if encryption is enabled in the RNFSTurbo library
108
109
  };
109
110
 
110
111
  export type ScanResult = {
@@ -181,6 +182,11 @@ export type ReadOptions =
181
182
  | EncodingType
182
183
  | {
183
184
  encoding?: EncodingType;
185
+ encrypted?: boolean;
186
+ passphrase?: string | number[];
187
+ iv?: string | number[];
188
+ mode?: "ecb" | "cbc" | "cfb";
189
+ padding?: "ansi_x9.23" | "iso/iec_7816-4" | "pkcs5/pkcs7" | "zero" | "no";
184
190
  }
185
191
  | undefined;
186
192
 
@@ -189,6 +195,11 @@ export type WriteOptions =
189
195
  | {
190
196
  encoding?: EncodingType;
191
197
  NSFileProtectionKey?: IOSProtectionTypes;
198
+ encrypted?: boolean;
199
+ passphrase?: string | number[];
200
+ iv?: string | number[];
201
+ mode?: "ecb" | "cbc" | "cfb";
202
+ padding?: "ansi_x9.23" | "iso/iec_7816-4" | "pkcs5/pkcs7" | "zero" | "no";
192
203
  }
193
204
  | undefined;
194
205
 
@@ -10,9 +10,11 @@ export const createRNFSTurbo = (): {
10
10
  } => {
11
11
  const { configuration, module } = getRNFSTurboModule();
12
12
 
13
- const instance = module.createRNFSTurbo() as RNFSTurboInterface;
13
+ const isCreated = module.createRNFSTurbo();
14
+
15
+ const instance = global.RNFSTurboProxy as RNFSTurboInterface;
14
16
  if (__DEV__) {
15
- if (typeof instance !== "object" || instance == null) {
17
+ if (!isCreated || typeof instance !== "object" || instance == null) {
16
18
  throw new Error(
17
19
  "Failed to create RNFSTurbo instance - an unknown object was returned by createRNFSTurbo(..)!",
18
20
  );
@@ -0,0 +1,9 @@
1
+ declare global {
2
+ /**
3
+ * The global RNFSTurbo proxy.
4
+ */
5
+ // eslint-disable-next-line vars-on-top, no-var
6
+ var RNFSTurboProxy: {} | undefined;
7
+ }
8
+
9
+ export {};
@@ -1,24 +0,0 @@
1
- //
2
- // NativeRNFSTurboModule.cpp
3
- // react-native-fs-turbo
4
- //
5
- // Created by Sergei Kazakov on 03.08.24.
6
- //
7
-
8
- #include "NativeRNFSTurboModule.h"
9
- #include "RNFSTurboHostObject.h"
10
-
11
- namespace facebook::react {
12
-
13
- NativeRNFSTurboModule::NativeRNFSTurboModule(std::shared_ptr<CallInvoker> jsInvoker)
14
- : NativeRNFSTurboModuleCxxSpec(std::move(jsInvoker)) {}
15
-
16
- NativeRNFSTurboModule::~NativeRNFSTurboModule() {}
17
-
18
- jsi::Object NativeRNFSTurboModule::createRNFSTurbo(jsi::Runtime& runtime) {
19
- auto instance = std::make_shared<RNFSTurboHostObject>();
20
- instance->jsInvoker = jsInvoker_;
21
- return jsi::Object::createFromHostObject(runtime, instance);
22
- }
23
-
24
- } // namespace facebook::react
@@ -1,31 +0,0 @@
1
- //
2
- // NativeRNFSTurboModule.h
3
- // react-native-fs-turbo
4
- //
5
- // Created by Sergei Kazakov on 03.08.24.
6
- //
7
-
8
- #pragma once
9
-
10
- #if __has_include(<React-Codegen/RNFSTurboSpecJSI.h>)
11
- // CocoaPods include (iOS)
12
- #include <React-Codegen/RNFSTurboSpecJSI.h>
13
- #elif __has_include(<RNFSTurboSpecJSI.h>)
14
- // CMake include on Android
15
- #include <RNFSTurboSpecJSI.h>
16
- #else
17
- #error Cannot find react-native-fs-turbo spec! Try cleaning your cache and re-running CodeGen!
18
- #endif
19
-
20
- namespace facebook::react {
21
-
22
- // The TurboModule itself
23
- class NativeRNFSTurboModule : public NativeRNFSTurboModuleCxxSpec<NativeRNFSTurboModule> {
24
- public:
25
- NativeRNFSTurboModule(std::shared_ptr<CallInvoker> jsInvoker);
26
- ~NativeRNFSTurboModule();
27
-
28
- jsi::Object createRNFSTurbo(jsi::Runtime& runtime);
29
- };
30
-
31
- } // namespace facebook::react
@@ -1,25 +0,0 @@
1
- //
2
- // RNFSTurboOnLoad.mm
3
- // react-native-fa-turbo
4
- //
5
- // Created by Sergei Kazakov on 03.08.24.
6
- //
7
-
8
- #import "NativeRNFSTurboModule.h"
9
- #import <Foundation/Foundation.h>
10
- #import <ReactCommon/CxxTurboModuleUtils.h>
11
-
12
- @interface RNFSTurboOnLoad : NSObject
13
- @end
14
-
15
- @implementation RNFSTurboOnLoad
16
-
17
- + (void)load {
18
- facebook::react::registerCxxModuleToGlobalModuleMap(
19
- std::string(facebook::react::NativeRNFSTurboModule::kModuleName),
20
- [&](std::shared_ptr<facebook::react::CallInvoker> jsInvoker) {
21
- return std::make_shared<facebook::react::NativeRNFSTurboModule>(jsInvoker);
22
- });
23
- }
24
-
25
- @end
@@ -1,22 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.getRNFSTurboPlatformContextTurboModule = getRNFSTurboPlatformContextTurboModule;
7
- var _reactNative = require("react-native");
8
- var _ModuleNotFoundError = require("./ModuleNotFoundError");
9
- let _module;
10
- function getRNFSTurboPlatformContextTurboModule() {
11
- try {
12
- if (_module == null) {
13
- // 1. Get the TurboModule
14
- _module = _reactNative.TurboModuleRegistry.getEnforcing("RNFSTurboPlatformContextModule");
15
- }
16
- return _module;
17
- } catch {
18
- // TurboModule could not be found!
19
- throw new _ModuleNotFoundError.ModuleNotFoundError();
20
- }
21
- }
22
- //# sourceMappingURL=NativeRNFSTurboPlatformContextModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","_ModuleNotFoundError","module","getRNFSTurboPlatformContextTurboModule","TurboModuleRegistry","getEnforcing","ModuleNotFoundError"],"sourceRoot":"../../src","sources":["NativeRNFSTurboPlatformContextModule.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD,OAAA;AAgBA,IAAIE,OAAmB;AAEhB,SAASC,sCAAsCA,CAAA,EAAS;EAC7D,IAAI;IACF,IAAID,OAAM,IAAI,IAAI,EAAE;MAClB;MACAA,OAAM,GAAGE,gCAAmB,CAACC,YAAY,CACvC,gCACF,CAAC;IACH;IACA,OAAOH,OAAM;EACf,CAAC,CAAC,MAAM;IACN;IACA,MAAM,IAAII,wCAAmB,CAAC,CAAC;EACjC;AACF","ignoreList":[]}
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- import { TurboModuleRegistry } from "react-native";
4
- import { ModuleNotFoundError } from "./ModuleNotFoundError";
5
- let module;
6
- export function getRNFSTurboPlatformContextTurboModule() {
7
- try {
8
- if (module == null) {
9
- // 1. Get the TurboModule
10
- module = TurboModuleRegistry.getEnforcing("RNFSTurboPlatformContextModule");
11
- }
12
- return module;
13
- } catch {
14
- // TurboModule could not be found!
15
- throw new ModuleNotFoundError();
16
- }
17
- }
18
- //# sourceMappingURL=NativeRNFSTurboPlatformContextModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["TurboModuleRegistry","ModuleNotFoundError","module","getRNFSTurboPlatformContextTurboModule","getEnforcing"],"sourceRoot":"../../src","sources":["NativeRNFSTurboPlatformContextModule.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;AAClD,SAASC,mBAAmB,QAAQ,uBAAuB;AAgB3D,IAAIC,MAAmB;AAEvB,OAAO,SAASC,sCAAsCA,CAAA,EAAS;EAC7D,IAAI;IACF,IAAID,MAAM,IAAI,IAAI,EAAE;MAClB;MACAA,MAAM,GAAGF,mBAAmB,CAACI,YAAY,CACvC,gCACF,CAAC;IACH;IACA,OAAOF,MAAM;EACf,CAAC,CAAC,MAAM;IACN;IACA,MAAM,IAAID,mBAAmB,CAAC,CAAC;EACjC;AACF","ignoreList":[]}
@@ -1,16 +0,0 @@
1
- import type { TurboModule } from "react-native";
2
- export interface Spec extends TurboModule {
3
- getMainBundlePath(): string;
4
- getCachesDirectoryPath(): string;
5
- getDocumentDirectoryPath(): string;
6
- getTemporaryDirectoryPath(): string;
7
- getLibraryDirectoryPath(): string;
8
- getExternalDirectoryPath(): string;
9
- getExternalStorageDirectoryPath(): string;
10
- getExternalCachesDirectoryPath(): string;
11
- getDownloadDirectoryPath(): string;
12
- getPicturesDirectoryPath(): string;
13
- getRoamingDirectoryPath(): string;
14
- }
15
- export declare function getRNFSTurboPlatformContextTurboModule(): Spec;
16
- //# sourceMappingURL=NativeRNFSTurboPlatformContextModule.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"NativeRNFSTurboPlatformContextModule.d.ts","sourceRoot":"","sources":["../../src/NativeRNFSTurboPlatformContextModule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,iBAAiB,IAAI,MAAM,CAAC;IAC5B,sBAAsB,IAAI,MAAM,CAAC;IACjC,wBAAwB,IAAI,MAAM,CAAC;IACnC,yBAAyB,IAAI,MAAM,CAAC;IACpC,uBAAuB,IAAI,MAAM,CAAC;IAClC,wBAAwB,IAAI,MAAM,CAAC;IACnC,+BAA+B,IAAI,MAAM,CAAC;IAC1C,8BAA8B,IAAI,MAAM,CAAC;IACzC,wBAAwB,IAAI,MAAM,CAAC;IACnC,wBAAwB,IAAI,MAAM,CAAC;IACnC,uBAAuB,IAAI,MAAM,CAAC;CACnC;AAID,wBAAgB,sCAAsC,IAAI,IAAI,CAa7D"}
@@ -1,34 +0,0 @@
1
- import type { TurboModule } from "react-native";
2
- import { TurboModuleRegistry } from "react-native";
3
- import { ModuleNotFoundError } from "./ModuleNotFoundError";
4
-
5
- export interface Spec extends TurboModule {
6
- getMainBundlePath(): string;
7
- getCachesDirectoryPath(): string;
8
- getDocumentDirectoryPath(): string;
9
- getTemporaryDirectoryPath(): string;
10
- getLibraryDirectoryPath(): string;
11
- getExternalDirectoryPath(): string;
12
- getExternalStorageDirectoryPath(): string;
13
- getExternalCachesDirectoryPath(): string;
14
- getDownloadDirectoryPath(): string;
15
- getPicturesDirectoryPath(): string;
16
- getRoamingDirectoryPath(): string;
17
- }
18
-
19
- let module: Spec | null;
20
-
21
- export function getRNFSTurboPlatformContextTurboModule(): Spec {
22
- try {
23
- if (module == null) {
24
- // 1. Get the TurboModule
25
- module = TurboModuleRegistry.getEnforcing<Spec>(
26
- "RNFSTurboPlatformContextModule",
27
- );
28
- }
29
- return module;
30
- } catch {
31
- // TurboModule could not be found!
32
- throw new ModuleNotFoundError();
33
- }
34
- }