Skip to content

Commit 37b1fb3

Browse files
authored
Merge pull request #36 from functionland/troubleshoot
Troubleshoot
2 parents 037de20 + ea5664c commit 37b1fb3

File tree

8 files changed

+66
-36
lines changed

8 files changed

+66
-36
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ yarn-debug.log
5353
yarn-error.log
5454
yarn.lock
5555
package-lock.json
56+
.yarn/
57+
example/.yarn/
5658

5759
# BUCK
5860
buck-out/

android/build.gradle

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def safeExtGet(prop, fallback) {
1919
}
2020

2121
android {
22-
compileSdkVersion safeExtGet('Fula_compileSdkVersion', 31)
23-
defaultConfig {
22+
compileSdk 33
23+
defaultConfig {
2424
minSdkVersion safeExtGet('Fula_minSdkVersion', 26)
2525
targetSdkVersion safeExtGet('Fula_targetSdkVersion', 31)
2626
versionCode 1
@@ -40,6 +40,8 @@ android {
4040
sourceCompatibility JavaVersion.VERSION_1_8
4141
targetCompatibility JavaVersion.VERSION_1_8
4242
}
43+
buildToolsVersion '33.0.0'
44+
ndkVersion '25.1.8937393'
4345
}
4446

4547
repositories {
@@ -62,6 +64,6 @@ dependencies {
6264
//noinspection GradleDynamicVersion
6365
implementation "com.facebook.react:react-native:+" // From node_modules
6466
implementation 'com.github.functionland:fula-build-aar:v0.7.3' // From jitpack.io
65-
implementation 'com.github.functionland:wnfs-build-aar:v1.2.4' // From jitpack.io
67+
implementation 'com.github.functionland:wnfs-build-aar:v1.2.7' // From jitpack.io
6668
// implementation files('mobile.aar')
6769
}

android/src/main/java/land/fx/fula/FulaModule.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import fulamobile.Config;
2222
import fulamobile.Fulamobile;
2323

24-
import land.fx.wnfslib.LibKt;
24+
import land.fx.wnfslib.Fs;
2525

2626
@ReactModule(name = FulaModule.NAME)
2727
public class FulaModule extends ReactContextBaseJavaModule {
@@ -35,9 +35,9 @@ public class FulaModule extends ReactContextBaseJavaModule {
3535
SharedPreferenceHelper sharedPref;
3636
static String PRIVATE_KEY_STORE_ID = "PRIVATE_KEY";
3737

38-
public class Client implements land.fx.wnfslib.Client {
38+
public class Client implements land.fx.wnfslib.Datastore {
3939

40-
private fulamobile.Client internalClient;
40+
private final fulamobile.Client internalClient;
4141

4242
Client(fulamobile.Client clientInput) {
4343
internalClient = clientInput;
@@ -51,7 +51,7 @@ public byte[] get(@NonNull byte[] cid) {
5151
} catch (Exception e) {
5252
e.printStackTrace();
5353
}
54-
return null;
54+
return cid;
5555
}
5656

5757
@NonNull
@@ -62,7 +62,7 @@ public byte[] put(@NonNull byte[] data, long codec) {
6262
} catch (Exception e) {
6363
e.printStackTrace();
6464
}
65-
return null;
65+
return data;
6666
}
6767
}
6868

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

8686
@Override
8787
@NonNull
88-
public String getName() {
88+
public java.lang.String getName() {
8989
return NAME;
9090
}
9191

@@ -192,9 +192,10 @@ private String[] initInternal(byte[] identity, String storePath, String bloxAddr
192192
Log.d("ReactNative", "fula initialized: " + this.fula.id());
193193
if (this.rootConfig == null) {
194194
Log.d("ReactNative", "creating rootConfig");
195-
this.privateForest = LibKt.createPrivateForest(this.client);
195+
196+
this.privateForest = Fs.createPrivateForest(this.client);
196197
Log.d("ReactNative", "privateForest is created: " + this.privateForest);
197-
this.rootConfig = LibKt.createRootDir(this.client, this.privateForest);
198+
this.rootConfig = Fs.createRootDir(this.client, this.privateForest);
198199
Log.d("ReactNative", "rootConfig is created: " + this.rootConfig.getCid());
199200
} else {
200201
Log.d("ReactNative", "rootConfig existed: " + this.rootConfig.getCid());
@@ -217,7 +218,7 @@ public void mkdir(String path, Promise promise) {
217218
ThreadUtils.runOnExecutor(() -> {
218219
Log.d("ReactNative", "mkdir: path = " + path);
219220
try {
220-
land.fx.wnfslib.Config config = LibKt.mkdir(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
221+
land.fx.wnfslib.Config config = Fs.mkdir(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
221222
this.rootConfig = config;
222223
promise.resolve(config.getCid());
223224
} catch (Exception e) {
@@ -239,7 +240,7 @@ public void writeFile(String fulaTargetFilename, String localFilename, Promise p
239240
ThreadUtils.runOnExecutor(() -> {
240241
Log.d("ReactNative", "writeFile to : path = " + fulaTargetFilename + ", from: " + localFilename);
241242
try {
242-
land.fx.wnfslib.Config config = LibKt.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
243+
land.fx.wnfslib.Config config = Fs.writeFileFromPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
243244
this.rootConfig = config;
244245
promise.resolve(config.getCid());
245246
} catch (Exception e) {
@@ -256,7 +257,7 @@ public void writeFileContent(String path, String contentString, Promise promise)
256257
Log.d("ReactNative", "writeFile: path = " + path);
257258
try {
258259
byte[] content = convertStringToByte(contentString);
259-
land.fx.wnfslib.Config config = LibKt.writeFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path, content);
260+
land.fx.wnfslib.Config config = Fs.writeFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path, content);
260261
this.rootConfig = config;
261262
promise.resolve(config.getCid());
262263
} catch (Exception e) {
@@ -271,7 +272,7 @@ public void ls(String path, Promise promise) {
271272
ThreadUtils.runOnExecutor(() -> {
272273
Log.d("ReactNative", "ls: path = " + path);
273274
try {
274-
String res = LibKt.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
275+
String res = Fs.ls(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
275276
promise.resolve(res);
276277
} catch (Exception e) {
277278
Log.d("get", e.getMessage());
@@ -285,7 +286,7 @@ public void rm(String path, Promise promise) {
285286
ThreadUtils.runOnExecutor(() -> {
286287
Log.d("ReactNative", "rm: path = " + path);
287288
try {
288-
land.fx.wnfslib.Config config = LibKt.rm(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
289+
land.fx.wnfslib.Config config = Fs.rm(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
289290
this.rootConfig = config;
290291
promise.resolve(config.getCid());
291292
} catch (Exception e) {
@@ -307,7 +308,7 @@ public void readFile(String fulaTargetFilename, String localFilename, Promise pr
307308
ThreadUtils.runOnExecutor(() -> {
308309
Log.d("ReactNative", "readFile: fulaTargetFilename = " + fulaTargetFilename);
309310
try {
310-
String path = LibKt.readFileToPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
311+
String path = Fs.readFileToPath(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), fulaTargetFilename, localFilename);
311312
promise.resolve(path);
312313
} catch (Exception e) {
313314
Log.d("get", e.getMessage());
@@ -321,7 +322,7 @@ public void readFileContent(String path, Promise promise) {
321322
ThreadUtils.runOnExecutor(() -> {
322323
Log.d("ReactNative", "readFileContent: path = " + path);
323324
try {
324-
byte[] res = LibKt.readFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
325+
byte[] res = Fs.readFile(this.client, this.rootConfig.getCid(), this.rootConfig.getPrivate_ref(), path);
325326
String resString = toString(res);
326327
promise.resolve(resString);
327328
} catch (Exception e) {
@@ -377,7 +378,6 @@ public void has(String keyString, Promise promise) {
377378
});
378379
}
379380

380-
@NonNull
381381
private boolean hasInternal(byte[] key) throws Exception {
382382
try {
383383
boolean res = this.fula.has(key);
@@ -388,7 +388,6 @@ private boolean hasInternal(byte[] key) throws Exception {
388388
}
389389
}
390390

391-
@NonNull
392391
private void pullInternal(byte[] key) throws Exception {
393392
try {
394393
this.fula.pull(key);
@@ -412,7 +411,6 @@ public void push(Promise promise) {
412411
});
413412
}
414413

415-
@NonNull
416414
private void pushInternal(byte[] key) throws Exception {
417415
try {
418416
if (this.fula.has(key)) {

example/android/app/build.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def jscFlavor = 'org.webkit:android-jsc:+'
117117
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118118
* and the benefits of using Hermes will therefore be sharply reduced.
119119
*/
120-
def enableHermes = project.ext.react.get("enableHermes", false);
120+
def enableHermes = project.ext.react.get("enableHermes", false)
121121

122122
android {
123123
compileSdkVersion rootProject.ext.compileSdkVersion
@@ -128,7 +128,7 @@ android {
128128
}
129129

130130
defaultConfig {
131-
applicationId "com.example.reactnativefula"
131+
applicationId "land.fx.reactnativefula"
132132
minSdkVersion rootProject.ext.minSdkVersion
133133
targetSdkVersion rootProject.ext.targetSdkVersion
134134
versionCode 1
@@ -184,7 +184,7 @@ dependencies {
184184
implementation "com.facebook.react:react-native:+" // From node_modules
185185

186186

187-
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
187+
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
188188
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
189189
exclude group:'com.facebook.fbjni'
190190
}
@@ -197,7 +197,7 @@ dependencies {
197197
}
198198

199199
if (enableHermes) {
200-
def hermesPath = "../../node_modules/hermes-engine/android/";
200+
def hermesPath = "../../node_modules/hermes-engine/android/"
201201
debugImplementation files(hermesPath + "hermes-debug.aar")
202202
releaseImplementation files(hermesPath + "hermes-release.aar")
203203
} else {

example/android/build.gradle

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,32 @@ buildscript {
55
minSdkVersion = 26
66
compileSdkVersion = 31
77
targetSdkVersion = 31
8+
ndkVersion = '25.1.8937393'
9+
kotlin_version = '1.7.10'
810
}
911
repositories {
1012
google()
1113
mavenCentral()
1214
jcenter()
15+
maven { url "https://plugins.gradle.org/m2/" }
16+
gradlePluginPortal()
1317
}
1418
dependencies {
15-
classpath("com.android.tools.build:gradle:7.0.4")
19+
classpath 'com.android.tools.build:gradle:7.3.1'
20+
classpath "org.mozilla.rust-android-gradle:plugin:0.9.3"
21+
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
22+
classpath "com.palantir.gradle.gitversion:gradle-git-version:0.15.0"
23+
classpath 'pl.allegro.tech.build:axion-release-plugin:1.13.14'
1624

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

30+
plugins {
31+
id 'org.jetbrains.kotlin.jvm' version '1.8.0-Beta'
32+
}
33+
2234
allprojects {
2335
repositories {
2436
mavenLocal()
@@ -31,9 +43,27 @@ allprojects {
3143
url("$rootDir/../node_modules/jsc-android/dist")
3244
}
3345

34-
google()
35-
mavenCentral()
36-
jcenter()
37-
maven { url 'https://www.jitpack.io' }
46+
google()
47+
jcenter()
48+
maven { url "https://plugins.gradle.org/m2/" }
49+
gradlePluginPortal()
50+
maven { url "https://jitpack.io" }
3851
}
3952
}
53+
54+
repositories {
55+
mavenCentral()
56+
}
57+
dependencies {
58+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
59+
}
60+
compileKotlin {
61+
kotlinOptions {
62+
jvmTarget = "1.8"
63+
}
64+
}
65+
compileTestKotlin {
66+
kotlinOptions {
67+
jvmTarget = "1.8"
68+
}
69+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-all.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-all.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

example/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { StyleSheet, Text, View, Button, TextInput } from 'react-native';
33

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

66
const App = () => {
77
const [key, setKey] = React.useState<string>('');

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@
4646
"homepage": "https://github.com/functionland/react-native-fula#readme",
4747
"publishConfig": {
4848
"registry": "https://registry.npmjs.org"
49-
},
50-
"dependencies": {
51-
5249
},
5350
"devDependencies": {
5451
"@babel/plugin-proposal-export-namespace-from": "^7.16.7",
@@ -148,5 +145,6 @@
148145
}
149146
]
150147
]
151-
}
148+
},
149+
"packageManager": "[email protected]"
152150
}

0 commit comments

Comments
 (0)