@filen/sdk-rs 0.3.22 → 0.3.25

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.
@@ -0,0 +1,80 @@
1
+ # Generated by uniffi-bindgen-react-native
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+ project(SdkRs)
4
+
5
+ set (CMAKE_VERBOSE_MAKEFILE ON)
6
+ set (CMAKE_CXX_STANDARD 17)
7
+
8
+ # Resolve the path to the uniffi-bindgen-react-native package
9
+ execute_process(
10
+ COMMAND node -p "require.resolve('uniffi-bindgen-react-native/package.json')"
11
+ OUTPUT_VARIABLE UNIFFI_BINDGEN_PATH
12
+ OUTPUT_STRIP_TRAILING_WHITESPACE
13
+ )
14
+ # Get the directory; get_filename_component and cmake_path will normalize
15
+ # paths with Windows path separators.
16
+ get_filename_component(UNIFFI_BINDGEN_PATH "${UNIFFI_BINDGEN_PATH}" DIRECTORY)
17
+
18
+ # Specifies a path to native header files.
19
+ include_directories(
20
+ ../cpp
21
+ ../cpp/generated
22
+
23
+ ${UNIFFI_BINDGEN_PATH}/cpp/includes
24
+ )
25
+
26
+ add_library(filen-sdk-rs SHARED
27
+ ../cpp/filen-sdk-rs.cpp
28
+ ../cpp/generated/filen_sdk_rs.cpp
29
+ ../cpp/generated/filen_types.cpp
30
+ cpp-adapter.cpp
31
+ )
32
+
33
+ # Set C++ compiler flags
34
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
35
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions")
36
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti")
37
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all")
38
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
39
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
40
+
41
+ # Set linker flags for 16KB page size alignment (required for Android 15+)
42
+ set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-z,max-page-size=16384")
43
+
44
+ cmake_path(
45
+ SET MY_RUST_LIB
46
+ ${CMAKE_SOURCE_DIR}/src/main/jniLibs/${ANDROID_ABI}/libfilen_sdk_rs.so
47
+ NORMALIZE
48
+ )
49
+ add_library(my_rust_lib SHARED IMPORTED)
50
+ set_target_properties(my_rust_lib PROPERTIES IMPORTED_LOCATION ${MY_RUST_LIB} IMPORTED_NO_SONAME ON)
51
+
52
+ # Add ReactAndroid libraries, being careful to account for different versions.
53
+ find_package(ReactAndroid REQUIRED CONFIG)
54
+ find_library(LOGCAT log)
55
+
56
+ # REACTNATIVE_MERGED_SO seems to be only be set in a build.gradle.kt file,
57
+ # which we don't use. Thus falling back to version number sniffing.
58
+ if (ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
59
+ set(REACTNATIVE_MERGED_SO true)
60
+ endif()
61
+
62
+ # https://github.com/react-native-community/discussions-and-proposals/discussions/816
63
+ # This if-then-else can be removed once this library does not support version below 0.76
64
+ if (REACTNATIVE_MERGED_SO)
65
+ target_link_libraries(filen-sdk-rs ReactAndroid::reactnative)
66
+ else()
67
+ target_link_libraries(filen-sdk-rs
68
+ ReactAndroid::turbomodulejsijni
69
+ ReactAndroid::react_nativemodule_core
70
+ )
71
+ endif()
72
+
73
+ find_package(fbjni REQUIRED CONFIG)
74
+ target_link_libraries(
75
+ filen-sdk-rs
76
+ fbjni::fbjni
77
+ ReactAndroid::jsi
78
+ ${LOGCAT}
79
+ my_rust_lib
80
+ )
@@ -0,0 +1,144 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+
3
+ buildscript {
4
+ // Buildscript is evaluated before everything else so we can't use getExtOrDefault
5
+ def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["DummyLibForAndroid_kotlinVersion"]
6
+
7
+ repositories {
8
+ google()
9
+ mavenCentral()
10
+ }
11
+
12
+ dependencies {
13
+ classpath "com.android.tools.build:gradle:7.2.1"
14
+ // noinspection DifferentKotlinGradleVersion
15
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
16
+ }
17
+ }
18
+
19
+ def reactNativeArchitectures() {
20
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
21
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
22
+ }
23
+
24
+ def isNewArchitectureEnabled() {
25
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
26
+ }
27
+
28
+ apply plugin: "com.android.library"
29
+ apply plugin: "kotlin-android"
30
+
31
+ if (isNewArchitectureEnabled()) {
32
+ apply plugin: "com.facebook.react"
33
+ }
34
+
35
+ def getExtOrDefault(name) {
36
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["SdkRs_" + name]
37
+ }
38
+
39
+ def getExtOrIntegerDefault(name) {
40
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["SdkRs_" + name]).toInteger()
41
+ }
42
+
43
+ def supportsNamespace() {
44
+ def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
45
+ def major = parsed[0].toInteger()
46
+ def minor = parsed[1].toInteger()
47
+
48
+ // Namespace support was added in 7.3.0
49
+ return (major == 7 && minor >= 3) || major >= 8
50
+ }
51
+
52
+ android {
53
+ if (supportsNamespace()) {
54
+ namespace "io.filen.sdkrsturbomodule"
55
+
56
+ sourceSets {
57
+ main {
58
+ manifest.srcFile "src/main/AndroidManifestNew.xml"
59
+ }
60
+ }
61
+ }
62
+
63
+ ndkVersion getExtOrDefault("ndkVersion")
64
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
65
+
66
+ defaultConfig {
67
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
68
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
69
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
70
+ consumerProguardFiles 'proguard-rules.pro'
71
+
72
+ buildFeatures {
73
+ prefab true
74
+ }
75
+ externalNativeBuild {
76
+ cmake {
77
+ arguments '-DANDROID_STL=c++_shared'
78
+ abiFilters (*reactNativeArchitectures())
79
+ }
80
+ }
81
+ ndk {
82
+ abiFilters "arm64-v8a", "x86_64"
83
+ }
84
+ }
85
+
86
+ externalNativeBuild {
87
+ cmake {
88
+ path "CMakeLists.txt"
89
+ }
90
+ }
91
+
92
+ buildFeatures {
93
+ buildConfig true
94
+ }
95
+
96
+ buildTypes {
97
+ release {
98
+ minifyEnabled false
99
+ }
100
+ }
101
+
102
+ lintOptions {
103
+ disable "GradleCompatible"
104
+ }
105
+
106
+ compileOptions {
107
+ sourceCompatibility JavaVersion.VERSION_1_8
108
+ targetCompatibility JavaVersion.VERSION_1_8
109
+ }
110
+
111
+ sourceSets {
112
+ main {
113
+ if (isNewArchitectureEnabled()) {
114
+ java.srcDirs += [
115
+ "generated/java",
116
+ "generated/jni"
117
+ ]
118
+ }
119
+ }
120
+ }
121
+ }
122
+
123
+ repositories {
124
+ mavenCentral()
125
+ google()
126
+ }
127
+
128
+ def kotlin_version = getExtOrDefault("kotlinVersion")
129
+
130
+ dependencies {
131
+ // For < 0.71, this will be from the local maven repo
132
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
133
+ //noinspection GradleDynamicVersion
134
+ implementation "com.facebook.react:react-native:+"
135
+ implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
136
+ }
137
+
138
+ if (isNewArchitectureEnabled()) {
139
+ react {
140
+ jsRootDir = file("../src/")
141
+ libraryName = "SdkRs"
142
+ codegenJavaPackageName = "io.filen.sdkrsturbomodule"
143
+ }
144
+ }
@@ -0,0 +1,43 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+ #include <jni.h>
3
+ #include <jsi/jsi.h>
4
+ #include <ReactCommon/CallInvokerHolder.h>
5
+ #include "filen-sdk-rs.h"
6
+
7
+ namespace jsi = facebook::jsi;
8
+ namespace react = facebook::react;
9
+
10
+ // Automated testing checks Java_io_filen_sdkrsturbomodule_SdkRsModule and filen_sdkrs
11
+ // by comparing the whole line here.
12
+ /*
13
+ Java_io_filen_sdkrsturbomodule_SdkRsModule_nativeMultiply(JNIEnv *env, jclass type, jdouble a, jdouble b) {
14
+ return filen_sdkrs::multiply(a, b);
15
+ }
16
+ */
17
+
18
+ // Installer coming from SdkRsModule
19
+ extern "C"
20
+ JNIEXPORT jboolean JNICALL
21
+ Java_io_filen_sdkrsturbomodule_SdkRsModule_nativeInstallRustCrate(
22
+ JNIEnv *env,
23
+ jclass type,
24
+ jlong rtPtr,
25
+ jobject callInvokerHolderJavaObj
26
+ ) {
27
+ using JCallInvokerHolder = facebook::react::CallInvokerHolder;
28
+
29
+ auto holderLocal = facebook::jni::make_local(callInvokerHolderJavaObj);
30
+ auto holderRef = facebook::jni::static_ref_cast<JCallInvokerHolder::javaobject>(holderLocal);
31
+ auto* holderCxx = holderRef->cthis();
32
+ auto jsCallInvoker = holderCxx->getCallInvoker();
33
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
34
+
35
+ return filen_sdkrs::installRustCrate(*runtime, jsCallInvoker);
36
+ }
37
+
38
+ extern "C"
39
+ JNIEXPORT jboolean JNICALL
40
+ Java_io_filen_sdkrsturbomodule_SdkRsModule_nativeCleanupRustCrate(JNIEnv *env, jclass type, jlong rtPtr) {
41
+ auto runtime = reinterpret_cast<jsi::Runtime *>(rtPtr);
42
+ return filen_sdkrs::cleanupRustCrate(*runtime);
43
+ }
@@ -0,0 +1,5 @@
1
+
2
+ <!-- Generated by uniffi-bindgen-react-native -->
3
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
4
+ package="io.filen.sdkrsturbomodule">
5
+ </manifest>
@@ -0,0 +1,43 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+ package io.filen.sdkrsturbomodule
3
+
4
+ import com.facebook.react.bridge.ReactApplicationContext
5
+ import com.facebook.react.module.annotations.ReactModule
6
+ import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
7
+
8
+ @ReactModule(name = SdkRsModule.NAME)
9
+ class SdkRsModule(reactContext: ReactApplicationContext) :
10
+ NativeSdkRsSpec(reactContext) {
11
+
12
+ override fun getName(): String {
13
+ return NAME
14
+ }
15
+
16
+ // Two native methods implemented in cpp-adapter.cpp, and ultimately
17
+ // filen-sdk-rs.cpp
18
+
19
+ external fun nativeInstallRustCrate(runtimePointer: Long, callInvoker: CallInvokerHolder): Boolean
20
+ external fun nativeCleanupRustCrate(runtimePointer: Long): Boolean
21
+
22
+ override fun installRustCrate(): Boolean {
23
+ val context = this.reactApplicationContext
24
+ return nativeInstallRustCrate(
25
+ context.javaScriptContextHolder!!.get(),
26
+ context.jsCallInvokerHolder!!
27
+ )
28
+ }
29
+
30
+ override fun cleanupRustCrate(): Boolean {
31
+ return nativeCleanupRustCrate(
32
+ this.reactApplicationContext.javaScriptContextHolder!!.get()
33
+ )
34
+ }
35
+
36
+ companion object {
37
+ const val NAME = "SdkRs"
38
+
39
+ init {
40
+ System.loadLibrary("filen-sdk-rs")
41
+ }
42
+ }
43
+ }
@@ -0,0 +1,34 @@
1
+ // Generated by uniffi-bindgen-react-native
2
+ package io.filen.sdkrsturbomodule
3
+
4
+ import com.facebook.react.TurboReactPackage
5
+ import com.facebook.react.bridge.NativeModule
6
+ import com.facebook.react.bridge.ReactApplicationContext
7
+ import com.facebook.react.module.model.ReactModuleInfo
8
+ import com.facebook.react.module.model.ReactModuleInfoProvider
9
+ import java.util.HashMap
10
+
11
+ class SdkRsPackage : TurboReactPackage() {
12
+ override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
13
+ return if (name == SdkRsModule.NAME) {
14
+ SdkRsModule(reactContext)
15
+ } else {
16
+ null
17
+ }
18
+ }
19
+
20
+ override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
21
+ return ReactModuleInfoProvider {
22
+ val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
23
+ moduleInfos[SdkRsModule.NAME] = ReactModuleInfo(
24
+ SdkRsModule.NAME,
25
+ SdkRsModule.NAME,
26
+ false, // canOverrideExistingModule
27
+ false, // needsEagerInit
28
+ false, // isCxxModule
29
+ true // isTurboModule
30
+ )
31
+ moduleInfos
32
+ }
33
+ }
34
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@filen/sdk-rs",
3
- "version": "0.3.22",
3
+ "version": "0.3.25",
4
4
  "description": "Filen JS SDK using filen-sdk-rs",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -8,7 +8,7 @@
8
8
  "ubrn:ios": "ubrn build ios --and-generate",
9
9
  "ubrn:android": "ubrn build android --and-generate",
10
10
  "ubrn:checkout": "ubrn checkout",
11
- "ubrn:release": "ubrn build ios --release --and-generate && ubrn build android --release"
11
+ "ubrn:release": "ubrn build ios --release --and-generate && ubrn build android --release --and-generate"
12
12
  },
13
13
  "homepage": "https://github.com/FilenCloudDienste/filen-rs",
14
14
  "author": "Filen",
@@ -16,9 +16,12 @@
16
16
  "Enduriel <endur1el@protonmail.com>"
17
17
  ],
18
18
  "files": [
19
- "browser",
20
- "filen-sdk-worker-thread.js",
19
+ "sdk-rs_bg.wasm",
20
+ "sdk-rs_bg.wasm.d.ts",
21
+ "sdk-rs.d.ts",
22
+ "sdk-rs.js",
21
23
  "snippets",
24
+ "filen-sdk-worker-thread.js",
22
25
  "android/src/main/",
23
26
  "android/build.gradle",
24
27
  "android/CMakeLists.txt",
@@ -29,7 +32,7 @@
29
32
  "src",
30
33
  "SdkRs.podspec"
31
34
  ],
32
- "main": "./browser/sdk-rs.js",
35
+ "main": "./sdk-rs.js",
33
36
  "react-native": "./src/index.tsx",
34
37
  "exports": {
35
38
  ".": {
@@ -38,13 +41,16 @@
38
41
  "types": "./src/index.tsx"
39
42
  },
40
43
  "browser": {
41
- "import": "./browser/sdk-rs.js",
42
- "types": "./browser/sdk-rs.d.ts"
43
- }
44
- }
44
+ "import": "./sdk-rs.js",
45
+ "types": "./sdk-rs.d.ts"
46
+ },
47
+ "types": "./sdk-rs.d.ts",
48
+ "default": "./sdk-rs.js"
49
+ },
50
+ "./sdk-rs_bg.wasm": "./sdk-rs_bg.wasm"
45
51
  },
46
52
  "sideEffects": [
47
- "/browser/sdk-rs.js"
53
+ "./sdk-rs.js"
48
54
  ],
49
55
  "license": "AGPL-3.0-only",
50
56
  "keywords": [