@op-engineering/op-sqlite 0.0.0-resolution-test
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +7 -0
- package/README.md +31 -0
- package/android/.project +17 -0
- package/android/.settings/org.eclipse.buildship.core.prefs +13 -0
- package/android/CMakeLists.txt +141 -0
- package/android/build.gradle +266 -0
- package/android/c_sources/tokenizers.cpp +88 -0
- package/android/c_sources/tokenizers.h +15 -0
- package/android/cpp-adapter.cpp +46 -0
- package/android/gradle.properties +1 -0
- package/android/jniLibs/arm64-v8a/libsql_experimental.a +0 -0
- package/android/jniLibs/armeabi-v7a/libsql_experimental.a +0 -0
- package/android/jniLibs/x86/libsql_experimental.a +0 -0
- package/android/jniLibs/x86_64/libsql_experimental.a +0 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/op/sqlite/OPSQLiteBridge.kt +37 -0
- package/android/src/main/java/com/op/sqlite/OPSQLiteModule.kt +119 -0
- package/android/src/main/java/com/op/sqlite/OPSQLitePackage.kt +18 -0
- package/android/src/main/jniLibs/arm64-v8a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/arm64-v8a/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/x86/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86/libsqlite_vec.so +0 -0
- package/android/src/main/jniLibs/x86_64/libcrsqlite.so +0 -0
- package/android/src/main/jniLibs/x86_64/libsqlite_vec.so +0 -0
- package/android/src/paper/java/com/op/sqlite/NativeOPSQLiteSpec.java +77 -0
- package/cpp/DBHostObject.cpp +852 -0
- package/cpp/DBHostObject.h +99 -0
- package/cpp/DumbHostObject.cpp +72 -0
- package/cpp/DumbHostObject.h +36 -0
- package/cpp/OPThreadPool.cpp +120 -0
- package/cpp/OPThreadPool.h +44 -0
- package/cpp/PreparedStatementHostObject.cpp +151 -0
- package/cpp/PreparedStatementHostObject.h +59 -0
- package/cpp/SmartHostObject.cpp +34 -0
- package/cpp/SmartHostObject.h +24 -0
- package/cpp/bindings.cpp +182 -0
- package/cpp/bindings.h +19 -0
- package/cpp/bridge.cpp +873 -0
- package/cpp/bridge.h +80 -0
- package/cpp/libsql/bridge.cpp +738 -0
- package/cpp/libsql/bridge.h +85 -0
- package/cpp/libsql/libsql.h +172 -0
- package/cpp/logs.h +40 -0
- package/cpp/macros.h +15 -0
- package/cpp/sqlcipher/sqlite3.c +262970 -0
- package/cpp/sqlcipher/sqlite3.h +13485 -0
- package/cpp/sqlite3.c +261454 -0
- package/cpp/sqlite3.h +13715 -0
- package/cpp/types.h +33 -0
- package/cpp/utils.cpp +327 -0
- package/cpp/utils.h +47 -0
- package/generate_tokenizers_header_file.rb +29 -0
- package/ios/OPSQLite.h +7 -0
- package/ios/OPSQLite.mm +157 -0
- package/ios/OPSQLite.xcodeproj/project.pbxproj +275 -0
- package/ios/crsqlite.xcframework/Info.plist +46 -0
- package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/Info.plist +24 -0
- package/ios/crsqlite.xcframework/ios-arm64/crsqlite.framework/crsqlite +0 -0
- package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/Info.plist +24 -0
- package/ios/crsqlite.xcframework/ios-arm64_x86_64-simulator/crsqlite.framework/crsqlite +0 -0
- package/ios/libsql.xcframework/Info.plist +48 -0
- package/ios/libsql.xcframework/ios-arm64/Headers/libsql.h +172 -0
- package/ios/libsql.xcframework/ios-arm64/libsql_experimental.a +0 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/Headers/libsql.h +172 -0
- package/ios/libsql.xcframework/ios-arm64_x86_64-simulator/libsql_experimental.a +0 -0
- package/ios/sqlitevec.xcframework/Info.plist +71 -0
- package/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/ios-arm64/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/ios-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/tvos-arm64/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/tvos-arm64/sqlitevec.framework/sqlitevec +0 -0
- package/ios/sqlitevec.xcframework/tvos-arm64_x86_64-simulator/sqlitevec.framework/Info.plist +24 -0
- package/ios/sqlitevec.xcframework/tvos-arm64_x86_64-simulator/sqlitevec.framework/sqlitevec +0 -0
- package/lib/commonjs/NativeOPSQLite.js +9 -0
- package/lib/commonjs/NativeOPSQLite.js.map +1 -0
- package/lib/commonjs/Storage.js +60 -0
- package/lib/commonjs/Storage.js.map +1 -0
- package/lib/commonjs/index.js +365 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/module/NativeOPSQLite.js +3 -0
- package/lib/module/NativeOPSQLite.js.map +1 -0
- package/lib/module/Storage.js +53 -0
- package/lib/module/Storage.js.map +1 -0
- package/lib/module/index.js +340 -0
- package/lib/module/index.js.map +1 -0
- package/lib/typescript/src/NativeOPSQLite.d.ts +15 -0
- package/lib/typescript/src/NativeOPSQLite.d.ts.map +1 -0
- package/lib/typescript/src/Storage.d.ts +23 -0
- package/lib/typescript/src/Storage.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +319 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/op-sqlite.podspec +212 -0
- package/package.json +85 -0
- package/src/NativeOPSQLite.ts +17 -0
- package/src/Storage.ts +85 -0
- package/src/index.ts +722 -0
package/src/Storage.ts
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { open, type DB } from './index';
|
|
2
|
+
|
|
3
|
+
type StorageOptions = {
|
|
4
|
+
location?: string;
|
|
5
|
+
encryptionKey?: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new async-storage api compatible instance.
|
|
10
|
+
* The encryption key is only used when compiled against the SQLCipher version of op-sqlite.
|
|
11
|
+
*/
|
|
12
|
+
export class Storage {
|
|
13
|
+
private db: DB;
|
|
14
|
+
|
|
15
|
+
constructor(options: StorageOptions) {
|
|
16
|
+
this.db = open({ ...options, name: '__opsqlite_storage' });
|
|
17
|
+
this.db.executeSync('PRAGMA mmap_size=268435456');
|
|
18
|
+
this.db.executeSync(
|
|
19
|
+
'CREATE TABLE IF NOT EXISTS storage (key TEXT PRIMARY KEY, value TEXT) WITHOUT ROWID'
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async getItem(key: string): Promise<string | undefined> {
|
|
24
|
+
const result = await this.db.execute(
|
|
25
|
+
'SELECT value FROM storage WHERE key = ?',
|
|
26
|
+
[key]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
let value = result.rows[0]?.value;
|
|
30
|
+
if (typeof value !== 'undefined' && typeof value !== 'string') {
|
|
31
|
+
throw new Error('Value must be a string or undefined');
|
|
32
|
+
}
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
getItemSync(key: string): string | undefined {
|
|
37
|
+
const result = this.db.executeSync(
|
|
38
|
+
'SELECT value FROM storage WHERE key = ?',
|
|
39
|
+
[key]
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
let value = result.rows[0]?.value;
|
|
43
|
+
if (typeof value !== 'undefined' && typeof value !== 'string') {
|
|
44
|
+
throw new Error('Value must be a string or undefined');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async setItem(key: string, value: string) {
|
|
51
|
+
await this.db.execute(
|
|
52
|
+
'INSERT OR REPLACE INTO storage (key, value) VALUES (?, ?)',
|
|
53
|
+
[key, value.toString()]
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
setItemSync(key: string, value: string) {
|
|
58
|
+
this.db.executeSync(
|
|
59
|
+
'INSERT OR REPLACE INTO storage (key, value) VALUES (?, ?)',
|
|
60
|
+
[key, value.toString()]
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async removeItem(key: string) {
|
|
65
|
+
await this.db.execute('DELETE FROM storage WHERE key = ?', [key]);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
removeItemSync(key: string) {
|
|
69
|
+
this.db.executeSync('DELETE FROM storage WHERE key = ?', [key]);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
async clear() {
|
|
73
|
+
await this.db.execute('DELETE FROM storage');
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
clearSync() {
|
|
77
|
+
this.db.executeSync('DELETE FROM storage');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
getAllKeys() {
|
|
81
|
+
return this.db
|
|
82
|
+
.executeSync('SELECT key FROM storage')
|
|
83
|
+
.rows.map((row: any) => row.key);
|
|
84
|
+
}
|
|
85
|
+
}
|