Skip to content

Commit

Permalink
android build
Browse files Browse the repository at this point in the history
  • Loading branch information
boorad committed Aug 14, 2024
1 parent af97646 commit cf4f6e3
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 20 deletions.
5 changes: 0 additions & 5 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,5 @@
},
"engines": {
"node": ">=18"
},
"codegenConfig": {
"name": "QuickCryptoExampleSpec",
"type": "modules",
"jsSrcsDir": "src"
}
}
2 changes: 2 additions & 0 deletions packages/react-native-quick-crypto/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rootProject.name = 'QuickCrypto'
project(':react-native-nitro-modules').projectDir = new File(rootProject.projectDir, '../../node_modules/react-native-nitro-modules/android')
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
#include <NitroModules/HybridObjectRegistry.hpp>

using namespace margelo::nitro::crypto;
using namespace margelo::crypto;

JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
HybridObjectRegistry::registerHybridObjectConstructor("Random",
[]() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>(); });
HybridObjectRegistry::registerHybridObjectConstructor(
"Random", []() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>();
});

return JNI_VERSION_1_2;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.util.Log;

// import androidx.annotation.Nullable;
import androidx.annotation.Nullable;

import com.facebook.react.bridge.NativeModule;
import com.facebook.react.bridge.ReactApplicationContext;
Expand All @@ -12,7 +12,7 @@
import com.margelo.nitro.HybridObjectRegistry;

import java.util.HashMap;
// import java.util.function.Supplier;
import java.util.function.Supplier;

public class QuickCryptoPackage extends TurboReactPackage {
@Nullable
Expand All @@ -21,12 +21,13 @@ public NativeModule getModule(String name, ReactApplicationContext reactContext)
return null;
}

public QuickCryptoPackagePackage() {
HybridObjectRegistry.registerHybridObjectConstructor("HybridRandom", () -> {
public QuickCryptoPackage() {
HybridObjectRegistry.registerHybridObjectConstructor("HybridRandom", () -> {
Log.i("YEET", "initializing Random...");
HybridObject obj = new HybridObject(new Random());
Log.i("YEET", "done Random!");
return f;
});
}

@Override
Expand Down
5 changes: 3 additions & 2 deletions packages/react-native-quick-crypto/ios/QuickCryptoOnLoad.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ @implementation QuickCryptoOnLoad
using namespace margelo::crypto;

+ (void)load {
HybridObjectRegistry::registerHybridObjectConstructor("Random",
[]() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>(); });
HybridObjectRegistry::registerHybridObjectConstructor(
"Random", []() -> std::shared_ptr<HybridObject> { return std::make_shared<HybridRandom>();
});
}

@end
9 changes: 2 additions & 7 deletions packages/react-native-quick-crypto/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
"dependencies": {
"@craftzdog/react-native-buffer": "6.0.5",
"events": "3.3.0",
"react-native-nitro-modules": "0.4.0",
"react-native-quick-base64": "2.1.2",
"readable-stream": "4.5.2",
"string_decoder": "1.3.0",
Expand All @@ -90,7 +91,6 @@
"react": "18.3.1",
"react-native": "0.74.5",
"react-native-builder-bob": "0.29.1",
"react-native-nitro-modules": "0.4.0",
"release-it": "17.6.0",
"typescript": "5.1.6",
"typescript-eslint": "^8.0.1"
Expand Down Expand Up @@ -154,10 +154,5 @@
}
]
]
},
"codegenConfig": {
"name": "QuickCryptoSpec",
"type": "modules",
"jsSrcsDir": "src/specs"
}
}
}

0 comments on commit cf4f6e3

Please sign in to comment.