Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • polycentric/leveldb-capacitor-plugin
1 result
Show changes
......@@ -101,14 +101,14 @@ public class LevelDBWrapperTest {
String batchValue2_b64 = Base64.getEncoder().encodeToString(batchValue2.getBytes());
// Perform batch put operations
Map<String, String>[] operations = new Map[2];
Map<String, String> operation1 = new HashMap<>();
HashMap<String, String>[] operations = new HashMap[2];
HashMap<String, String> operation1 = new HashMap<>();
operation1.put("type", "put");
operation1.put("key", batchKey1_b64);
operation1.put("value", batchValue1_b64);
operations[0] = operation1;
Map<String, String> operation2 = new HashMap<>();
HashMap<String, String> operation2 = new HashMap<>();
operation2.put("type", "put");
operation2.put("key", batchKey2_b64);
operation2.put("value", batchValue2_b64);
......
......@@ -241,7 +241,7 @@ JNIEXPORT void JNICALL Java_org_futo_polycentric_leveldbcapacitor_MobileLevelImp
batch.Put(decoded_key, decoded_value);
env->ReleaseStringUTFChars(value, value_cstr);
} else if (strcmp(type_cstr, "delete") == 0) {
} else if (strcmp(type_cstr, "del") == 0) {
batch.Delete(decoded_key);
} else {
throwJavaException(env, "Invalid operation type");
......
......@@ -17,7 +17,7 @@ public class MobileLevelImpl {
public native void db_delete(String dbName, String key);
public native void db_clear(String dbName) throws Exception;
public native void db_close(String dbName);
public native void db_batch(String dbName, Map<String, String>[] operations);
public native void db_batch(String dbName, HashMap<String, String>[] operations);
public native ArrayList<ArrayList<String>> db_iterator(String dbName, HashMap<String, Object> options);
static {
......
......@@ -140,17 +140,19 @@ public class MobileLevelPlugin extends Plugin {
}
try {
Map<String, String>[] java_operations = new Map[operations.length()];
HashMap<String, String>[] javaOperations = new HashMap[operations.length()];
for (int i = 0; i < operations.length(); i++) {
JSONObject operation = operations.getJSONObject(0);
Map<String, String> java_operation = new HashMap<>();
java_operation.put("type", operation.getString("type"));
java_operation.put("key", operation.getString("key"));
java_operation.put("value", operation.getString("value"));
java_operations[i] = java_operation;
JSONObject operation = operations.getJSONObject(i); // corrected to getJSONObject(i)
HashMap<String, String> javaOperation = new HashMap<>();
javaOperation.put("type", operation.getString("type"));
javaOperation.put("key", operation.getString("key"));
if (operation.has("value")) {
javaOperation.put("value", operation.getString("value"));
}
javaOperations[i] = javaOperation;
}
mobileLevel.db_batch(dbName, java_operations);
mobileLevel.db_batch(dbName, javaOperations);
call.resolve();
} catch (Exception e) {
call.reject(e.getMessage());
......
esbuild src/index.ts \
--bundle \
--outfile=dist/plugin.js \
--format=iife \
--global-name=capacitorMobileLevel \
--external:@capacitor/core
# build cjs
esbuild src/index.ts \
--bundle \
--outfile=dist/plugin.cjs.js \
--format=cjs \
--external:@capacitor/core
esbuild src/index.ts \
--bundle \
--outfile=dist/esm/plugin.js \
--format=esm \
--external:@capacitor/core
cp dist/esm/plugin.js dist/esm/index.js
\ No newline at end of file
......@@ -197,7 +197,7 @@ NSDictionary * EMPTY_SUCCESS = nil;
if ([type isEqualToString:@"put"]) {
batch.Put(decoded_key, decoded_value);
} else if ([type isEqualToString:@"delete"]) {
} else if ([type isEqualToString:@"del"]) {
batch.Delete(decoded_key);
}
}
......
This diff is collapsed.
......@@ -38,7 +38,7 @@
"prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
"swiftlint": "node-swiftlint",
"docgen": "docgen --api MobileLevelPlugin --output-readme README.md --output-json dist/docs.json",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"build": "npm run clean && tsc --noEmit && ./build.sh",
"clean": "rimraf ./dist",
"watch": "tsc --watch",
"prepublishOnly": "npm run build"
......@@ -51,11 +51,11 @@
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"esbuild": "^0.21.4",
"eslint": "^9.1.1",
"prettier": "~2.3.0",
"prettier-plugin-java": "~1.0.2",
"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"swiftlint": "^1.0.1",
"typescript": "^5.4.5"
},
......
export default {
input: 'dist/esm/index.js',
output: [
{
file: 'dist/plugin.js',
format: 'iife',
name: 'capacitorMobileLevel',
globals: {
'@capacitor/core': 'capacitorExports',
},
sourcemap: true,
inlineDynamicImports: true,
},
{
file: 'dist/plugin.cjs.js',
format: 'cjs',
sourcemap: true,
inlineDynamicImports: true,
},
],
external: ['@capacitor/core'],
};