Skip to content

Commit

Permalink
Merge pull request #36 from functionland/troubleshoot
Browse files Browse the repository at this point in the history
Troubleshoot
  • Loading branch information
ehsan6sha authored Dec 12, 2022
2 parents 037de20 + ea5664c commit 37b1fb3
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 36 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ yarn-debug.log
yarn-error.log
yarn.lock
package-lock.json
.yarn/
example/.yarn/

# BUCK
buck-out/
Expand Down
8 changes: 5 additions & 3 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def safeExtGet(prop, fallback) {
}

android {
compileSdkVersion safeExtGet('Fula_compileSdkVersion', 31)
defaultConfig {
compileSdk 33
defaultConfig {
minSdkVersion safeExtGet('Fula_minSdkVersion', 26)
targetSdkVersion safeExtGet('Fula_targetSdkVersion', 31)
versionCode 1
Expand All @@ -40,6 +40,8 @@ android {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildToolsVersion '33.0.0'
ndkVersion '25.1.8937393'
}

repositories {
Expand All @@ -62,6 +64,6 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.github.functionland:fula-build-aar:v0.7.3' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.2.4' // From jitpack.io
implementation 'com.github.functionland:wnfs-build-aar:v1.2.7' // From jitpack.io
// implementation files('mobile.aar')
}
34 changes: 16 additions & 18 deletions android/src/main/java/land/fx/fula/FulaModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import fulamobile.Config;
import fulamobile.Fulamobile;

import land.fx.wnfslib.LibKt;
import land.fx.wnfslib.Fs;

@ReactModule(name = FulaModule.NAME)
public class FulaModule extends ReactContextBaseJavaModule {
Expand All @@ -35,9 +35,9 @@ public class FulaModule extends ReactContextBaseJavaModule {
SharedPreferenceHelper sharedPref;
static String PRIVATE_KEY_STORE_ID = "PRIVATE_KEY";

public class Client implements land.fx.wnfslib.Client {
public class Client implements land.fx.wnfslib.Datastore {

private fulamobile.Client internalClient;
private final fulamobile.Client internalClient;

Client(fulamobile.Client clientInput) {
internalClient = clientInput;
Expand All @@ -51,7 +51,7 @@ public byte[] get(@NonNull byte[] cid) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
return cid;
}

@NonNull
Expand All @@ -62,7 +62,7 @@ public byte[] put(@NonNull byte[] data, long codec) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
return data;
}
}

Expand All @@ -85,7 +85,7 @@ public FulaModule(ReactApplicationContext reactContext) {

@Override
@NonNull
public String getName() {
public java.lang.String getName() {
return NAME;
}

Expand Down Expand Up @@ -192,9 +192,10 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr
Log.d("ReactNative", "fula initialized: " + this.fula.id());
if (this.rootConfig == null) {
Log.d("ReactNative", "creating rootConfig");
this.privateForest = LibKt.createPrivateForest(this.client);

this.privateForest = Fs.createPrivateForest(this.client);
Log.d("ReactNative", "privateForest is created: " + this.privateForest);
this.rootConfig = LibKt.createRootDir(this.client, this.privateForest);
this.rootConfig = Fs.createRootDir(this.client, this.privateForest);
Log.d("ReactNative", "rootConfig is created: " + this.rootConfig.getCid());
} else {
Log.d("ReactNative", "rootConfig existed: " + this.rootConfig.getCid());
Expand All @@ -217,7 +218,7 @@ public void mkdir(String path, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "mkdir: path = " + path);
try {
land.fx.wnfslib.Config config = LibKt.mkdir(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
land.fx.wnfslib.Config config = Fs.mkdir(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
this.rootConfig = config;
promise.resolve(config.getCid());
} catch (Exception e) {
Expand All @@ -239,7 +240,7 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "writeFile to : path = " + fulaTargetFilename + ", from: " + localFilename);
try {
land.fx.wnfslib.Config config = LibKt.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
land.fx.wnfslib.Config config = Fs.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
this.rootConfig = config;
promise.resolve(config.getCid());
} catch (Exception e) {
Expand All @@ -256,7 +257,7 @@ public void writeFileContent(String path, String contentString, Promise promise)
Log.d("ReactNative", "writeFile: path = " + path);
try {
byte[] content = convertStringToByte(contentString);
land.fx.wnfslib.Config config = LibKt.writeFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path, content);
land.fx.wnfslib.Config config = Fs.writeFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path, content);
this.rootConfig = config;
promise.resolve(config.getCid());
} catch (Exception e) {
Expand All @@ -271,7 +272,7 @@ public void ls(String path, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "ls: path = " + path);
try {
String res = LibKt.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
String res = Fs.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
promise.resolve(res);
} catch (Exception e) {
Log.d("get", e.getMessage());
Expand All @@ -285,7 +286,7 @@ public void rm(String path, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "rm: path = " + path);
try {
land.fx.wnfslib.Config config = LibKt.rm(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
land.fx.wnfslib.Config config = Fs.rm(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
this.rootConfig = config;
promise.resolve(config.getCid());
} catch (Exception e) {
Expand All @@ -307,7 +308,7 @@ public void readFile(String fulaTargetFilename, String localFilename, Promise pr
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "readFile: fulaTargetFilename = " + fulaTargetFilename);
try {
String path = LibKt.readFileToPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
String path = Fs.readFileToPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
promise.resolve(path);
} catch (Exception e) {
Log.d("get", e.getMessage());
Expand All @@ -321,7 +322,7 @@ public void readFileContent(String path, Promise promise) {
ThreadUtils.runOnExecutor(() -> {
Log.d("ReactNative", "readFileContent: path = " + path);
try {
byte[] res = LibKt.readFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
byte[] res = Fs.readFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
String resString = toString(res);
promise.resolve(resString);
} catch (Exception e) {
Expand Down Expand Up @@ -377,7 +378,6 @@ public void has(String keyString, Promise promise) {
});
}

@NonNull
private boolean hasInternal(byte[] key) throws Exception {
try {
boolean res = this.fula.has(key);
Expand All @@ -388,7 +388,6 @@ private boolean hasInternal(byte[] key) throws Exception {
}
}

@NonNull
private void pullInternal(byte[] key) throws Exception {
try {
this.fula.pull(key);
Expand All @@ -412,7 +411,6 @@ public void push(Promise promise) {
});
}

@NonNull
private void pushInternal(byte[] key) throws Exception {
try {
if (this.fula.has(key)) {
Expand Down
8 changes: 4 additions & 4 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", false);
def enableHermes = project.ext.react.get("enableHermes", false)

android {
compileSdkVersion rootProject.ext.compileSdkVersion
Expand All @@ -128,7 +128,7 @@ android {
}

defaultConfig {
applicationId "com.example.reactnativefula"
applicationId "land.fx.reactnativefula"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down Expand Up @@ -184,7 +184,7 @@ dependencies {
implementation "com.facebook.react:react-native:+" // From node_modules


implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
Expand All @@ -197,7 +197,7 @@ dependencies {
}

if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
def hermesPath = "../../node_modules/hermes-engine/android/"
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
Expand Down
40 changes: 35 additions & 5 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ buildscript {
minSdkVersion = 26
compileSdkVersion = 31
targetSdkVersion = 31
ndkVersion = '25.1.8937393'
kotlin_version = '1.7.10'
}
repositories {
google()
mavenCentral()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
}
dependencies {
classpath("com.android.tools.build:gradle:7.0.4")
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.mozilla.rust-android-gradle:plugin:0.9.3"
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
classpath "com.palantir.gradle.gitversion:gradle-git-version:0.15.0"
classpath 'pl.allegro.tech.build:axion-release-plugin:1.13.14'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.8.0-Beta'
}

allprojects {
repositories {
mavenLocal()
Expand All @@ -31,9 +43,27 @@ allprojects {
url("$rootDir/../node_modules/jsc-android/dist")
}

google()
mavenCentral()
jcenter()
maven { url 'https://www.jitpack.io' }
google()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
gradlePluginPortal()
maven { url "https://jitpack.io" }
}
}

repositories {
mavenCentral()
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}
compileKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
compileTestKotlin {
kotlinOptions {
jvmTarget = "1.8"
}
}
2 changes: 1 addition & 1 deletion example/android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion example/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';

import { fula } from 'react-native-fula';
import { fula } from '@functionland/react-native-fula';

const App = () => {
const [key, setKey] = React.useState<string>('');
Expand Down
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@
"homepage": "https://github.com/functionland/react-native-fula#readme",
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"dependencies": {

},
"devDependencies": {
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
Expand Down Expand Up @@ -148,5 +145,6 @@
}
]
]
}
},
"packageManager": "[email protected]"
}

0 comments on commit 37b1fb3

Please sign in to comment.