Skip to content

SQL执行调整&代码格式修改 #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 38 additions & 16 deletions NativeSQLitePlugin.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,42 @@
import type {TurboModule } from 'react-native/Libraries/TurboModule/RCTExport';
import {TurboModuleRegistry} from 'react-native';
import type { TurboModule } from "react-native/Libraries/TurboModule/RCTExport";
import { TurboModuleRegistry } from "react-native";

export interface Spec extends TurboModule {

open(openargs:Object,opensuccesscb:() => void,openerrorcb:(e:Object) => void):void;

close(closeargs:Object,mysuccess:(t:Object,r:Object) => void,myerror:(e:Object) => void):void;

attach(attachargs:Object,mysuccess:(t:Object,r:Object) => void,myerror:(e:Object) => void):void;

backgroundExecuteSqlBatch(args:Object,mysuccess:(result:Object) => void,myerror:(e:Object) => void):void;

echoStringValue(openargs:Object,mysuccess:(testValue:Object) => void,myerror:(e:Object) => void):void;

delete(args:Object,mysuccess:(r:Object) => void,myerror:(e:Object) => void):void;

open(
openargs: Object,
opensuccesscb: () => void,
openerrorcb: (e: Object) => void
): void;

close(
closeargs: Object,
mysuccess: (t: Object, r: Object) => void,
myerror: (e: Object) => void
): void;

attach(
attachargs: Object,
mysuccess: (t: Object, r: Object) => void,
myerror: (e: Object) => void
): void;

backgroundExecuteSqlBatch(
args: Object,
mysuccess: (result: Object) => void,
myerror: (e: Object) => void
): void;

echoStringValue(
openargs: Object,
mysuccess: (testValue: Object) => void,
myerror: (e: Object) => void
): void;

delete(
args: Object,
mysuccess: (r: Object) => void,
myerror: (e: Object) => void
): void;
}

export default TurboModuleRegistry.getEnforcing<Spec>('SQLitePlugin');
export default TurboModuleRegistry.getEnforcing<Spec>("SQLitePlugin");
6 changes: 0 additions & 6 deletions Podfile

This file was deleted.

28 changes: 13 additions & 15 deletions lib/sqlite.core.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* See http://opensource.org/licenses/alphabetical for full text.
*/

// var NativeModules = require("react-native").NativeModules;
import NativeModules from '../NativeSQLitePlugin'
var DB_STATE_INIT, DB_STATE_OPEN, READ_ONLY_REGEX, SQLiteFactory, SQLitePlugin, SQLitePluginTransaction, argsArray, dblocations, newSQLError, txLocks;

Expand Down Expand Up @@ -86,20 +85,19 @@ argsArray = function(fun) {
plugin.exec = function(method, options, success, error) {
if (plugin.sqlitePlugin.DEBUG){
plugin.log("SQLite." + method + "(" + JSON.stringify(options) + ")");
}
// NativeModules["SQLite"][method](options,success,error);
if(method=='open'){
NativeModules.open(options,success,error);
}else if(method=='close'){
NativeModules.close(options,success,error);
}else if(method=='attach'){
NativeModules.attach(options,success,error);
}else if(method=='backgroundExecuteSqlBatch'){
NativeModules.backgroundExecuteSqlBatch(options,success,error);
}else if(method=='echoStringValue'){
NativeModules.echoStringValue(options,success,error);
}else if(method=='delete'){
NativeModules.delete(options,success,error);
}
if (method == 'open') {
NativeModules.open(options, success, error);
} else if (method == 'close') {
NativeModules.close(options, success, error);
} else if (method == 'attach') {
NativeModules.attach(options, success, error);
} else if (method == 'backgroundExecuteSqlBatch') {
NativeModules.backgroundExecuteSqlBatch(options, success, error);
} else if (method == 'echoStringValue') {
NativeModules.echoStringValue(options, success, error);
} else if (method == 'delete') {
NativeModules.delete(options, success, error);
}
};

Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@react-native-oh-tpl/react-native-sqlite-storage",
"version": "6.0.1-0.0.16",
"version": "6.0.1-0.0.5",
"description": "SQLite3 bindings for React Native (Android & iOS)",
"overrides":{
"@react-native/codegen": "0.74.0"
Expand Down Expand Up @@ -48,7 +48,6 @@
"devDependencies": {
"react": "18.2.0",
"react-native": "0.74.1",
"react-native-windows": "^0.74.3",
"react-native-sqlite-storage": "^6.0.1"
"react-native-windows": "^0.74.3"
}
}
Binary file modified platforms/harmony/sqlite_storage.har
Binary file not shown.
2 changes: 1 addition & 1 deletion platforms/harmony/sqlite_storage/BuildProfile.ets
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export default class BuildProfile {
static readonly HAR_VERSION = '6.0.1-0.0.1';
static readonly HAR_VERSION = '6.0.1-0.0.5';
static readonly BUILD_MODE_NAME = 'debug';
static readonly DEBUG = true;
}
2 changes: 1 addition & 1 deletion platforms/harmony/sqlite_storage/oh-package.json5
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"description": "",
"main": "ts.ts",
"type": "module",
"version": "6.0.1-0.0.1",
"version": "6.0.1-0.0.5",
"dependencies": {
"@rnoh/react-native-openharmony": "file:../react_native_openharmony",
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ import CommonConstants from './CommonConstants';

class SQLitePluginTurboModulesFactory extends TurboModulesFactory {
createTurboModule(name: string): TurboModule | null {
Logger.debug(CommonConstants.TAG, "test--SQLitePlugin=createTurboModule>>>>>" + name);
if (name == TM.SQLitePlugin.NAME) {
return new SQLitePluginTurboModule(this.ctx);
}
return null;
}

hasTurboModule(name: string): boolean {
Logger.debug(CommonConstants.TAG, "test--SQLitePlugin=hasTurboModule>>>>>" + name);
return name == TM.SQLitePlugin.NAME;
}
}

export class SQLitePluginPackage extends RNPackage {
createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
Logger.debug(CommonConstants.TAG, "test--SQLitePlugin=createTurboModulesFactory>>>>>");
return new SQLitePluginTurboModulesFactory(ctx);
}
}
Loading