rn-file-toolkit 1.0.1
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/FileToolkit.podspec +22 -0
- package/LICENSE +20 -0
- package/README.md +522 -0
- package/android/build.gradle +61 -0
- package/android/src/main/AndroidManifest.xml +13 -0
- package/android/src/main/java/com/filetoolkit/FileToolkitModule.kt +1204 -0
- package/android/src/main/java/com/filetoolkit/FileToolkitPackage.kt +31 -0
- package/android/src/main/res/xml/file_provider_paths.xml +14 -0
- package/app.plugin.js +49 -0
- package/ios/FileToolkit.h +6 -0
- package/ios/FileToolkit.mm +1468 -0
- package/lib/commonjs/NativeFileToolkit.js +9 -0
- package/lib/commonjs/NativeFileToolkit.js.map +1 -0
- package/lib/commonjs/index.js +941 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/NativeFileToolkit.js +5 -0
- package/lib/module/NativeFileToolkit.js.map +1 -0
- package/lib/module/index.js +905 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/NativeFileToolkit.d.ts +29 -0
- package/lib/typescript/commonjs/src/NativeFileToolkit.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +635 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/src/NativeFileToolkit.d.ts +29 -0
- package/lib/typescript/module/src/NativeFileToolkit.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +635 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +232 -0
- package/src/NativeFileToolkit.ts +29 -0
- package/src/index.tsx +1293 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package com.filetoolkit
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class FileToolkitPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == FileToolkitModule.NAME) {
|
|
13
|
+
FileToolkitModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider() = ReactModuleInfoProvider {
|
|
20
|
+
mapOf(
|
|
21
|
+
FileToolkitModule.NAME to ReactModuleInfo(
|
|
22
|
+
name = FileToolkitModule.NAME,
|
|
23
|
+
className = FileToolkitModule.NAME,
|
|
24
|
+
canOverrideExistingModule = false,
|
|
25
|
+
needsEagerInit = false,
|
|
26
|
+
isCxxModule = false,
|
|
27
|
+
isTurboModule = true
|
|
28
|
+
)
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
|
3
|
+
<!-- External storage (public downloads) -->
|
|
4
|
+
<external-path name="external_files" path="." />
|
|
5
|
+
|
|
6
|
+
<!-- App-specific external storage (documents) -->
|
|
7
|
+
<external-files-path name="external_app_files" path="." />
|
|
8
|
+
|
|
9
|
+
<!-- App-specific cache directory -->
|
|
10
|
+
<cache-path name="cache_files" path="." />
|
|
11
|
+
|
|
12
|
+
<!-- App-specific files directory -->
|
|
13
|
+
<files-path name="internal_files" path="." />
|
|
14
|
+
</paths>
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
const {
|
|
2
|
+
withInfoPlist,
|
|
3
|
+
withAndroidManifest,
|
|
4
|
+
AndroidConfig,
|
|
5
|
+
createRunOncePlugin,
|
|
6
|
+
} = require('@expo/config-plugins');
|
|
7
|
+
|
|
8
|
+
const pkg = require('./package.json');
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Config plugin to add necessary permissions and background modes for rn-file-toolkit.
|
|
12
|
+
*/
|
|
13
|
+
const withFileToolkitPermissions = (config) => {
|
|
14
|
+
// 1. Android: Add internet and storage permissions
|
|
15
|
+
config = withAndroidManifest(config, (modConfig) => {
|
|
16
|
+
AndroidConfig.Permissions.addPermission(
|
|
17
|
+
modConfig.modResults,
|
|
18
|
+
'android.permission.INTERNET'
|
|
19
|
+
);
|
|
20
|
+
AndroidConfig.Permissions.addPermission(
|
|
21
|
+
modConfig.modResults,
|
|
22
|
+
'android.permission.WRITE_EXTERNAL_STORAGE'
|
|
23
|
+
);
|
|
24
|
+
AndroidConfig.Permissions.addPermission(
|
|
25
|
+
modConfig.modResults,
|
|
26
|
+
'android.permission.READ_EXTERNAL_STORAGE'
|
|
27
|
+
);
|
|
28
|
+
return modConfig;
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// 2. iOS: Add 'fetch' background mode
|
|
32
|
+
config = withInfoPlist(config, (modConfig) => {
|
|
33
|
+
if (!Array.isArray(modConfig.modResults.UIBackgroundModes)) {
|
|
34
|
+
modConfig.modResults.UIBackgroundModes = [];
|
|
35
|
+
}
|
|
36
|
+
if (!modConfig.modResults.UIBackgroundModes.includes('fetch')) {
|
|
37
|
+
modConfig.modResults.UIBackgroundModes.push('fetch');
|
|
38
|
+
}
|
|
39
|
+
return modConfig;
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return config;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = createRunOncePlugin(
|
|
46
|
+
withFileToolkitPermissions,
|
|
47
|
+
pkg.name,
|
|
48
|
+
pkg.version
|
|
49
|
+
);
|