@quereus/plugin-react-native-leveldb 0.1.1

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/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # @quereus/plugin-react-native-leveldb
2
+
3
+ LevelDB storage plugin for Quereus on React Native. Provides fast, persistent storage for mobile iOS and Android applications using the [`@quereus/store`](../quereus-store/) module.
4
+
5
+ ## Features
6
+
7
+ - **Fast**: LevelDB offers excellent read/write performance, significantly faster than AsyncStorage
8
+ - **Synchronous API**: Uses rn-leveldb's synchronous, blocking APIs
9
+ - **Binary data**: Full support for binary keys and values via ArrayBuffers
10
+ - **Sorted keys**: Efficient range queries with ordered iteration
11
+ - **Persistent**: Data survives app restarts
12
+ - **Atomic batch writes**: Uses native LevelDB WriteBatch for atomic multi-key operations
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @quereus/plugin-react-native-leveldb @quereus/store rn-leveldb
18
+
19
+ # Don't forget to link native modules
20
+ cd ios && pod install
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ ### With registerPlugin (Recommended)
26
+
27
+ ```typescript
28
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
29
+ import { Database, registerPlugin } from '@quereus/quereus';
30
+ import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
31
+
32
+ const db = new Database();
33
+ await registerPlugin(db, leveldbPlugin, {
34
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
35
+ WriteBatch: LevelDBWriteBatch,
36
+ });
37
+
38
+ await db.exec(`
39
+ create table users (id integer primary key, name text)
40
+ using store
41
+ `);
42
+
43
+ await db.exec(`insert into users (id, name) values (1, 'Alice')`);
44
+
45
+ const users = await db.all('select * from users');
46
+ console.log(users);
47
+ ```
48
+
49
+ ### Direct Usage with Provider
50
+
51
+ ```typescript
52
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
53
+ import { Database } from '@quereus/quereus';
54
+ import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
55
+ import { StoreModule } from '@quereus/store';
56
+
57
+ const db = new Database();
58
+ const provider = createReactNativeLevelDBProvider({
59
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
60
+ WriteBatch: LevelDBWriteBatch,
61
+ });
62
+ const storeModule = new StoreModule(provider);
63
+ db.registerVtabModule('store', storeModule);
64
+
65
+ await db.exec(`
66
+ create table users (id integer primary key, name text)
67
+ using store
68
+ `);
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### ReactNativeLevelDBStore
74
+
75
+ Low-level KVStore implementation:
76
+
77
+ ```typescript
78
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
79
+ import { ReactNativeLevelDBStore } from '@quereus/plugin-react-native-leveldb';
80
+
81
+ // Open using the factory function
82
+ const openFn = (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists);
83
+ const store = ReactNativeLevelDBStore.open(openFn, LevelDBWriteBatch, 'mystore');
84
+
85
+ await store.put(key, value);
86
+ const data = await store.get(key);
87
+ await store.delete(key);
88
+
89
+ // Range iteration
90
+ for await (const { key, value } of store.iterate({ gte: startKey, lt: endKey })) {
91
+ console.log(key, value);
92
+ }
93
+
94
+ // Atomic batch writes (uses native LevelDB WriteBatch)
95
+ const batch = store.batch();
96
+ batch.put(key1, value1);
97
+ batch.put(key2, value2);
98
+ batch.delete(key3);
99
+ await batch.write();
100
+
101
+ await store.close();
102
+ ```
103
+
104
+ ### ReactNativeLevelDBProvider
105
+
106
+ Factory for managing multiple stores:
107
+
108
+ ```typescript
109
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
110
+ import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
111
+
112
+ const provider = createReactNativeLevelDBProvider({
113
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
114
+ WriteBatch: LevelDBWriteBatch,
115
+ databaseName: 'myapp',
116
+ });
117
+
118
+ const userStore = await provider.getStore('main', 'users');
119
+ const catalogStore = await provider.getCatalogStore();
120
+
121
+ await provider.closeStore('main', 'users');
122
+ await provider.closeAll();
123
+ ```
124
+
125
+ ## Configuration
126
+
127
+ ### Plugin Settings
128
+
129
+ | Setting | Type | Default | Description |
130
+ |---------|------|---------|-------------|
131
+ | `openFn` | function | **required** | Factory function: `(name, createIfMissing, errorIfExists) => LevelDB` |
132
+ | `WriteBatch` | constructor | **required** | LevelDBWriteBatch constructor from rn-leveldb |
133
+ | `databaseName` | string | `'quereus'` | Base name prefix for all LevelDB databases |
134
+ | `createIfMissing` | boolean | `true` | Create databases if they don't exist |
135
+ | `moduleName` | string | `'store'` | Name to register the virtual table module under |
136
+
137
+ ## Example with Transactions
138
+
139
+ ```typescript
140
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
141
+ import { Database, registerPlugin } from '@quereus/quereus';
142
+ import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
143
+
144
+ const db = new Database();
145
+ await registerPlugin(db, leveldbPlugin, {
146
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
147
+ WriteBatch: LevelDBWriteBatch,
148
+ });
149
+
150
+ await db.exec(`create table accounts (id integer primary key, balance real) using store`);
151
+
152
+ await db.exec('begin');
153
+ try {
154
+ await db.exec(`update accounts set balance = balance - 100 where id = 1`);
155
+ await db.exec(`update accounts set balance = balance + 100 where id = 2`);
156
+ await db.exec('commit');
157
+ } catch (e) {
158
+ await db.exec('rollback');
159
+ throw e;
160
+ }
161
+ ```
162
+
163
+ ## Why LevelDB?
164
+
165
+ rn-leveldb provides significant performance advantages over other React Native storage options:
166
+
167
+ | Storage Solution | Operations/sec | Notes |
168
+ |------------------|----------------|-------|
169
+ | rn-leveldb | ~50,000 | Synchronous, blocking API |
170
+ | AsyncStorage | ~2,000 | JSON serialization overhead |
171
+ | react-native-sqlite-storage | ~5,000 | Full SQL parsing overhead |
172
+
173
+ LevelDB is ideal for Quereus because:
174
+ - **Sorted keys**: Natural fit for the StoreModule's index-organized storage
175
+ - **Binary support**: No JSON serialization needed for keys/values
176
+ - **Range scans**: Efficient ordered iteration for query execution
177
+
178
+ ## Peer Dependencies
179
+
180
+ This plugin requires:
181
+ - `@quereus/quereus` ^0.24.0
182
+ - `@quereus/store` ^0.3.5
183
+ - `rn-leveldb` ^3.11.0
184
+
185
+ ## Related Packages
186
+
187
+ - [`@quereus/store`](../quereus-store/) - Core storage module (StoreModule, StoreTable)
188
+ - [`@quereus/plugin-leveldb`](../quereus-plugin-leveldb/) - LevelDB plugin for Node.js
189
+ - [`@quereus/plugin-indexeddb`](../quereus-plugin-indexeddb/) - IndexedDB plugin for browsers
190
+
191
+ ## License
192
+
193
+ MIT
194
+
@@ -0,0 +1,42 @@
1
+ /**
2
+ * React Native LevelDB storage plugin for Quereus.
3
+ *
4
+ * Provides LevelDB-based persistent storage for React Native mobile environments
5
+ * (iOS and Android). Uses rn-leveldb for native LevelDB bindings.
6
+ *
7
+ * @example Using as a plugin (recommended)
8
+ * ```typescript
9
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
10
+ * import { Database, registerPlugin } from '@quereus/quereus';
11
+ * import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
12
+ *
13
+ * const db = new Database();
14
+ * await registerPlugin(db, leveldbPlugin, {
15
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
16
+ * WriteBatch: LevelDBWriteBatch,
17
+ * });
18
+ *
19
+ * await db.exec(`
20
+ * create table users (id integer primary key, name text)
21
+ * using store
22
+ * `);
23
+ * ```
24
+ *
25
+ * @example Using the provider directly
26
+ * ```typescript
27
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
28
+ * import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
29
+ * import { StoreModule } from '@quereus/store';
30
+ *
31
+ * const provider = createReactNativeLevelDBProvider({
32
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
33
+ * WriteBatch: LevelDBWriteBatch,
34
+ * });
35
+ * const storeModule = new StoreModule(provider);
36
+ * db.registerVtabModule('store', storeModule);
37
+ * ```
38
+ */
39
+ export { ReactNativeLevelDBStore, type LevelDB, type LevelDBIterator, type LevelDBOpenFn, type LevelDBWriteBatch, type LevelDBWriteBatchConstructor } from './store.js';
40
+ export { ReactNativeLevelDBProvider, createReactNativeLevelDBProvider, type ReactNativeLevelDBProviderOptions } from './provider.js';
41
+ export { default as plugin, type ReactNativeLevelDBPluginConfig } from './plugin.js';
42
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,uBAAuB,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAAE,KAAK,aAAa,EAAE,KAAK,iBAAiB,EAAE,KAAK,4BAA4B,EAAE,MAAM,YAAY,CAAC;AACxK,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAAE,KAAK,iCAAiC,EAAE,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,KAAK,8BAA8B,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * React Native LevelDB storage plugin for Quereus.
3
+ *
4
+ * Provides LevelDB-based persistent storage for React Native mobile environments
5
+ * (iOS and Android). Uses rn-leveldb for native LevelDB bindings.
6
+ *
7
+ * @example Using as a plugin (recommended)
8
+ * ```typescript
9
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
10
+ * import { Database, registerPlugin } from '@quereus/quereus';
11
+ * import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
12
+ *
13
+ * const db = new Database();
14
+ * await registerPlugin(db, leveldbPlugin, {
15
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
16
+ * WriteBatch: LevelDBWriteBatch,
17
+ * });
18
+ *
19
+ * await db.exec(`
20
+ * create table users (id integer primary key, name text)
21
+ * using store
22
+ * `);
23
+ * ```
24
+ *
25
+ * @example Using the provider directly
26
+ * ```typescript
27
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
28
+ * import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
29
+ * import { StoreModule } from '@quereus/store';
30
+ *
31
+ * const provider = createReactNativeLevelDBProvider({
32
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
33
+ * WriteBatch: LevelDBWriteBatch,
34
+ * });
35
+ * const storeModule = new StoreModule(provider);
36
+ * db.registerVtabModule('store', storeModule);
37
+ * ```
38
+ */
39
+ export { ReactNativeLevelDBStore } from './store.js';
40
+ export { ReactNativeLevelDBProvider, createReactNativeLevelDBProvider } from './provider.js';
41
+ export { default as plugin } from './plugin.js';
42
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,EAAE,uBAAuB,EAAqH,MAAM,YAAY,CAAC;AACxK,OAAO,EAAE,0BAA0B,EAAE,gCAAgC,EAA0C,MAAM,eAAe,CAAC;AACrI,OAAO,EAAE,OAAO,IAAI,MAAM,EAAuC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * React Native LevelDB plugin for Quereus.
3
+ *
4
+ * Registers a StoreModule backed by LevelDB for React Native mobile environments.
5
+ * Uses rn-leveldb for native LevelDB bindings.
6
+ */
7
+ import type { Database, SqlValue } from '@quereus/quereus';
8
+ import { StoreModule } from '@quereus/store';
9
+ import type { LevelDBOpenFn, LevelDBWriteBatchConstructor } from './store.js';
10
+ /**
11
+ * Plugin configuration options.
12
+ */
13
+ export interface ReactNativeLevelDBPluginConfig {
14
+ /**
15
+ * The LevelDB open function from rn-leveldb.
16
+ * Obtain this from: import { LevelDB } from 'rn-leveldb';
17
+ * Then pass: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists)
18
+ */
19
+ openFn: LevelDBOpenFn;
20
+ /**
21
+ * The LevelDBWriteBatch constructor from rn-leveldb.
22
+ * Obtain this from: import { LevelDBWriteBatch } from 'rn-leveldb';
23
+ */
24
+ WriteBatch: LevelDBWriteBatchConstructor;
25
+ /**
26
+ * Base name prefix for all LevelDB databases.
27
+ * @default 'quereus'
28
+ */
29
+ databaseName?: string;
30
+ /**
31
+ * Create databases if they don't exist.
32
+ * @default true
33
+ */
34
+ createIfMissing?: boolean;
35
+ /**
36
+ * Module name to register. Tables are created with `USING <moduleName>`.
37
+ * @default 'store'
38
+ */
39
+ moduleName?: string;
40
+ }
41
+ /**
42
+ * Register the React Native LevelDB plugin with a database.
43
+ *
44
+ * @example
45
+ * ```typescript
46
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
47
+ * import { Database, registerPlugin } from '@quereus/quereus';
48
+ * import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
49
+ *
50
+ * const db = new Database();
51
+ * await registerPlugin(db, leveldbPlugin, {
52
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
53
+ * WriteBatch: LevelDBWriteBatch,
54
+ * });
55
+ *
56
+ * await db.exec(`
57
+ * create table users (id integer primary key, name text)
58
+ * using store
59
+ * `);
60
+ * ```
61
+ */
62
+ export default function register(_db: Database, config?: Record<string, SqlValue>): {
63
+ vtables: {
64
+ name: string;
65
+ module: StoreModule;
66
+ }[];
67
+ };
68
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,OAAO,KAAK,EAAE,aAAa,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE9E;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC9C;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,UAAU,EAAE,4BAA4B,CAAC;IAEzC;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EAyCrC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * React Native LevelDB plugin for Quereus.
3
+ *
4
+ * Registers a StoreModule backed by LevelDB for React Native mobile environments.
5
+ * Uses rn-leveldb for native LevelDB bindings.
6
+ */
7
+ import { StoreModule } from '@quereus/store';
8
+ import { ReactNativeLevelDBProvider } from './provider.js';
9
+ /**
10
+ * Register the React Native LevelDB plugin with a database.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
15
+ * import { Database, registerPlugin } from '@quereus/quereus';
16
+ * import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
17
+ *
18
+ * const db = new Database();
19
+ * await registerPlugin(db, leveldbPlugin, {
20
+ * openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
21
+ * WriteBatch: LevelDBWriteBatch,
22
+ * });
23
+ *
24
+ * await db.exec(`
25
+ * create table users (id integer primary key, name text)
26
+ * using store
27
+ * `);
28
+ * ```
29
+ */
30
+ export default function register(_db, config = {}) {
31
+ // The LevelDB open function must be provided
32
+ const openFn = config.openFn;
33
+ if (!openFn) {
34
+ throw new Error('@quereus/plugin-react-native-leveldb requires an "openFn" option. ' +
35
+ 'Import LevelDB from "rn-leveldb" and pass: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists)');
36
+ }
37
+ // The WriteBatch constructor must be provided
38
+ const WriteBatch = config.WriteBatch;
39
+ if (!WriteBatch) {
40
+ throw new Error('@quereus/plugin-react-native-leveldb requires a "WriteBatch" option. ' +
41
+ 'Import LevelDBWriteBatch from "rn-leveldb" and pass it as WriteBatch.');
42
+ }
43
+ const databaseName = config.databaseName ?? 'quereus';
44
+ const createIfMissing = config.createIfMissing !== false;
45
+ const moduleName = config.moduleName ?? 'store';
46
+ const provider = new ReactNativeLevelDBProvider({
47
+ openFn,
48
+ WriteBatch,
49
+ databaseName,
50
+ createIfMissing,
51
+ });
52
+ const storeModule = new StoreModule(provider);
53
+ return {
54
+ vtables: [
55
+ {
56
+ name: moduleName,
57
+ module: storeModule,
58
+ },
59
+ ],
60
+ };
61
+ }
62
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAC;AAuC3D;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAa,EACb,SAAmC,EAAE;IAErC,6CAA6C;IAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAkC,CAAC;IACzD,IAAI,CAAC,MAAM,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACd,oEAAoE;YACpE,wIAAwI,CACxI,CAAC;IACH,CAAC;IAED,8CAA8C;IAC9C,MAAM,UAAU,GAAG,MAAM,CAAC,UAAqD,CAAC;IAChF,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CACd,uEAAuE;YACvE,uEAAuE,CACvE,CAAC;IACH,CAAC;IAED,MAAM,YAAY,GAAI,MAAM,CAAC,YAAuB,IAAI,SAAS,CAAC;IAClE,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,KAAK,KAAK,CAAC;IACzD,MAAM,UAAU,GAAI,MAAM,CAAC,UAAqB,IAAI,OAAO,CAAC;IAE5D,MAAM,QAAQ,GAAG,IAAI,0BAA0B,CAAC;QAC/C,MAAM;QACN,UAAU;QACV,YAAY;QACZ,eAAe;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE9C,OAAO;QACN,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,WAAW;aACnB;SACD;KACD,CAAC;AACH,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * React Native LevelDB KVStore provider implementation.
3
+ *
4
+ * Manages LevelDB stores for the StoreModule in React Native environments.
5
+ */
6
+ import type { KVStore, KVStoreProvider } from '@quereus/store';
7
+ import { type LevelDBOpenFn, type LevelDBWriteBatchConstructor } from './store.js';
8
+ /**
9
+ * Options for creating a React Native LevelDB provider.
10
+ */
11
+ export interface ReactNativeLevelDBProviderOptions {
12
+ /**
13
+ * The LevelDB open function from rn-leveldb.
14
+ * Obtain this from: import { LevelDB } from 'rn-leveldb';
15
+ * Then pass: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists)
16
+ */
17
+ openFn: LevelDBOpenFn;
18
+ /**
19
+ * The LevelDBWriteBatch constructor from rn-leveldb.
20
+ * Obtain this from: import { LevelDBWriteBatch } from 'rn-leveldb';
21
+ */
22
+ WriteBatch: LevelDBWriteBatchConstructor;
23
+ /**
24
+ * Base name prefix for all LevelDB databases.
25
+ * Each table gets a separate database with this prefix.
26
+ * @default 'quereus'
27
+ */
28
+ databaseName?: string;
29
+ /**
30
+ * Create databases if they don't exist.
31
+ * @default true
32
+ */
33
+ createIfMissing?: boolean;
34
+ }
35
+ /**
36
+ * React Native LevelDB implementation of KVStoreProvider.
37
+ *
38
+ * Creates separate LevelDB databases for each table. On mobile platforms,
39
+ * this provides efficient, persistent key-value storage with sorted keys.
40
+ */
41
+ export declare class ReactNativeLevelDBProvider implements KVStoreProvider {
42
+ private openFn;
43
+ private WriteBatch;
44
+ private databaseName;
45
+ private createIfMissing;
46
+ private stores;
47
+ private catalogStore;
48
+ constructor(options: ReactNativeLevelDBProviderOptions);
49
+ /**
50
+ * Get the database name for a table.
51
+ * Uses dots as separators for a flat namespace.
52
+ */
53
+ private getDatabaseName;
54
+ /**
55
+ * Get the key for the store cache.
56
+ */
57
+ private getStoreKey;
58
+ getStore(schemaName: string, tableName: string, _options?: Record<string, unknown>): Promise<KVStore>;
59
+ getCatalogStore(): Promise<KVStore>;
60
+ closeStore(schemaName: string, tableName: string): Promise<void>;
61
+ closeAll(): Promise<void>;
62
+ }
63
+ /**
64
+ * Create a React Native LevelDB provider with the given options.
65
+ */
66
+ export declare function createReactNativeLevelDBProvider(options: ReactNativeLevelDBProviderOptions): ReactNativeLevelDBProvider;
67
+ //# sourceMappingURL=provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAA2B,KAAK,aAAa,EAAE,KAAK,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE5G;;GAEG;AACH,MAAM,WAAW,iCAAiC;IACjD;;;;OAIG;IACH,MAAM,EAAE,aAAa,CAAC;IAEtB;;;OAGG;IACH,UAAU,EAAE,4BAA4B,CAAC;IAEzC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED;;;;;GAKG;AACH,qBAAa,0BAA2B,YAAW,eAAe;IACjE,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,eAAe,CAAU;IACjC,OAAO,CAAC,MAAM,CAA8C;IAC5D,OAAO,CAAC,YAAY,CAAwC;gBAEhD,OAAO,EAAE,iCAAiC;IAOtD;;;OAGG;IACH,OAAO,CAAC,eAAe;IAIvB;;OAEG;IACH,OAAO,CAAC,WAAW;IAIb,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;IAerG,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC;IAUnC,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAShE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAW/B;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,iCAAiC,GAAG,0BAA0B,CAEvH"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * React Native LevelDB KVStore provider implementation.
3
+ *
4
+ * Manages LevelDB stores for the StoreModule in React Native environments.
5
+ */
6
+ import { ReactNativeLevelDBStore } from './store.js';
7
+ /**
8
+ * React Native LevelDB implementation of KVStoreProvider.
9
+ *
10
+ * Creates separate LevelDB databases for each table. On mobile platforms,
11
+ * this provides efficient, persistent key-value storage with sorted keys.
12
+ */
13
+ export class ReactNativeLevelDBProvider {
14
+ openFn;
15
+ WriteBatch;
16
+ databaseName;
17
+ createIfMissing;
18
+ stores = new Map();
19
+ catalogStore = null;
20
+ constructor(options) {
21
+ this.openFn = options.openFn;
22
+ this.WriteBatch = options.WriteBatch;
23
+ this.databaseName = options.databaseName ?? 'quereus';
24
+ this.createIfMissing = options.createIfMissing ?? true;
25
+ }
26
+ /**
27
+ * Get the database name for a table.
28
+ * Uses dots as separators for a flat namespace.
29
+ */
30
+ getDatabaseName(schemaName, tableName) {
31
+ return `${this.databaseName}.${schemaName}.${tableName}`.toLowerCase();
32
+ }
33
+ /**
34
+ * Get the key for the store cache.
35
+ */
36
+ getStoreKey(schemaName, tableName) {
37
+ return `${schemaName}.${tableName}`.toLowerCase();
38
+ }
39
+ async getStore(schemaName, tableName, _options) {
40
+ const key = this.getStoreKey(schemaName, tableName);
41
+ let store = this.stores.get(key);
42
+ if (!store) {
43
+ const dbName = this.getDatabaseName(schemaName, tableName);
44
+ store = ReactNativeLevelDBStore.open(this.openFn, this.WriteBatch, dbName, {
45
+ createIfMissing: this.createIfMissing,
46
+ });
47
+ this.stores.set(key, store);
48
+ }
49
+ return store;
50
+ }
51
+ async getCatalogStore() {
52
+ if (!this.catalogStore) {
53
+ const catalogDbName = `${this.databaseName}.__catalog__`;
54
+ this.catalogStore = ReactNativeLevelDBStore.open(this.openFn, this.WriteBatch, catalogDbName, {
55
+ createIfMissing: this.createIfMissing,
56
+ });
57
+ }
58
+ return this.catalogStore;
59
+ }
60
+ async closeStore(schemaName, tableName) {
61
+ const key = this.getStoreKey(schemaName, tableName);
62
+ const store = this.stores.get(key);
63
+ if (store) {
64
+ await store.close();
65
+ this.stores.delete(key);
66
+ }
67
+ }
68
+ async closeAll() {
69
+ for (const store of this.stores.values()) {
70
+ await store.close();
71
+ }
72
+ this.stores.clear();
73
+ if (this.catalogStore) {
74
+ await this.catalogStore.close();
75
+ this.catalogStore = null;
76
+ }
77
+ }
78
+ }
79
+ /**
80
+ * Create a React Native LevelDB provider with the given options.
81
+ */
82
+ export function createReactNativeLevelDBProvider(options) {
83
+ return new ReactNativeLevelDBProvider(options);
84
+ }
85
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,uBAAuB,EAAyD,MAAM,YAAY,CAAC;AAiC5G;;;;;GAKG;AACH,MAAM,OAAO,0BAA0B;IAC9B,MAAM,CAAgB;IACtB,UAAU,CAA+B;IACzC,YAAY,CAAS;IACrB,eAAe,CAAU;IACzB,MAAM,GAAG,IAAI,GAAG,EAAmC,CAAC;IACpD,YAAY,GAAmC,IAAI,CAAC;IAE5D,YAAY,OAA0C;QACrD,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;QACrC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,IAAI,SAAS,CAAC;QACtD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,IAAI,CAAC;IACxD,CAAC;IAED;;;OAGG;IACK,eAAe,CAAC,UAAkB,EAAE,SAAiB;QAC5D,OAAO,GAAG,IAAI,CAAC,YAAY,IAAI,UAAU,IAAI,SAAS,EAAE,CAAC,WAAW,EAAE,CAAC;IACxE,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,UAAkB,EAAE,SAAiB;QACxD,OAAO,GAAG,UAAU,IAAI,SAAS,EAAE,CAAC,WAAW,EAAE,CAAC;IACnD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,UAAkB,EAAE,SAAiB,EAAE,QAAkC;QACvF,MAAM,GAAG,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,KAAK,GA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AAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;YAC1C,MAAM,KAAK,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QAEpB,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YACvB,MAAM,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;YAChC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QAC1B,CAAC;IACF,CAAC;CACD;AAED;;GAEG;AACH,MAAM,UAAU,gCAAgC,CAAC,OAA0C;IAC1F,OAAO,IAAI,0BAA0B,CAAC,OAAO,CAAC,CAAC;AAChD,CAAC"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * LevelDB-based KVStore implementation for React Native.
3
+ *
4
+ * Uses rn-leveldb for LevelDB bindings on iOS/Android.
5
+ * Keys and values are stored as binary ArrayBuffers.
6
+ */
7
+ import type { KVStore, KVEntry, WriteBatch, IterateOptions } from '@quereus/store';
8
+ /**
9
+ * Type definition for rn-leveldb write batch.
10
+ * Used internally for atomic batch writes.
11
+ */
12
+ export interface LevelDBWriteBatch {
13
+ /**
14
+ * Add a put operation to the batch.
15
+ */
16
+ put(key: ArrayBuffer | string, value: ArrayBuffer | string): void;
17
+ /**
18
+ * Add a delete operation to the batch.
19
+ */
20
+ delete(key: ArrayBuffer | string): void;
21
+ /**
22
+ * Close the batch (releases native resources).
23
+ */
24
+ close(): void;
25
+ }
26
+ /**
27
+ * Constructor type for LevelDBWriteBatch.
28
+ * rn-leveldb exports this as a class that can be constructed without arguments.
29
+ */
30
+ export type LevelDBWriteBatchConstructor = new () => LevelDBWriteBatch;
31
+ /**
32
+ * Type definition for rn-leveldb database.
33
+ * We use a minimal interface to avoid hard dependency on the package types.
34
+ *
35
+ * rn-leveldb provides synchronous, blocking APIs which are
36
+ * significantly faster than alternatives like AsyncStorage.
37
+ */
38
+ export interface LevelDB {
39
+ /**
40
+ * Put a key-value pair.
41
+ */
42
+ put(key: ArrayBuffer | string, value: ArrayBuffer | string): void;
43
+ /**
44
+ * Get a value by key as ArrayBuffer.
45
+ * @returns The value as ArrayBuffer, or null if not found.
46
+ */
47
+ getBuf(key: ArrayBuffer | string): ArrayBuffer | null;
48
+ /**
49
+ * Delete a key.
50
+ */
51
+ delete(key: ArrayBuffer | string): void;
52
+ /**
53
+ * Close the database.
54
+ */
55
+ close(): void;
56
+ /**
57
+ * Create a new iterator for range scans.
58
+ */
59
+ newIterator(): LevelDBIterator;
60
+ /**
61
+ * Atomically write a batch of operations.
62
+ */
63
+ write(batch: LevelDBWriteBatch): void;
64
+ }
65
+ /**
66
+ * Type definition for rn-leveldb iterator.
67
+ */
68
+ export interface LevelDBIterator {
69
+ /**
70
+ * Check if the iterator points to a valid entry.
71
+ */
72
+ valid(): boolean;
73
+ /**
74
+ * Move to the first entry >= the given key.
75
+ */
76
+ seek(target: ArrayBuffer | string): LevelDBIterator;
77
+ /**
78
+ * Move to the first entry.
79
+ */
80
+ seekToFirst(): LevelDBIterator;
81
+ /**
82
+ * Move to the last entry.
83
+ */
84
+ seekLast(): LevelDBIterator;
85
+ /**
86
+ * Move to the next entry.
87
+ */
88
+ next(): void;
89
+ /**
90
+ * Move to the previous entry.
91
+ */
92
+ prev(): void;
93
+ /**
94
+ * Get the current key.
95
+ */
96
+ keyBuf(): ArrayBuffer;
97
+ /**
98
+ * Get the current value.
99
+ */
100
+ valueBuf(): ArrayBuffer;
101
+ /**
102
+ * Close the iterator.
103
+ */
104
+ close(): void;
105
+ }
106
+ /**
107
+ * Factory function type for opening a LevelDB database.
108
+ * Should be rn-leveldb's LevelDB constructor.
109
+ */
110
+ export type LevelDBOpenFn = (name: string, createIfMissing: boolean, errorIfExists: boolean) => LevelDB;
111
+ /**
112
+ * LevelDB implementation of KVStore for React Native.
113
+ *
114
+ * Keys and values are stored as ArrayBuffers. LevelDB provides correct
115
+ * lexicographic byte ordering for range scans.
116
+ */
117
+ export declare class ReactNativeLevelDBStore implements KVStore {
118
+ private db;
119
+ private WriteBatchCtor;
120
+ private closed;
121
+ private constructor();
122
+ /**
123
+ * Create a store with the given LevelDB instance and WriteBatch constructor.
124
+ */
125
+ static create(db: LevelDB, WriteBatch: LevelDBWriteBatchConstructor): ReactNativeLevelDBStore;
126
+ /**
127
+ * Open a store using the provided open function.
128
+ */
129
+ static open(openFn: LevelDBOpenFn, WriteBatch: LevelDBWriteBatchConstructor, name: string, options?: {
130
+ createIfMissing?: boolean;
131
+ errorIfExists?: boolean;
132
+ }): ReactNativeLevelDBStore;
133
+ get(key: Uint8Array): Promise<Uint8Array | undefined>;
134
+ put(key: Uint8Array, value: Uint8Array): Promise<void>;
135
+ delete(key: Uint8Array): Promise<void>;
136
+ has(key: Uint8Array): Promise<boolean>;
137
+ iterate(options?: IterateOptions): AsyncIterable<KVEntry>;
138
+ private collectEntries;
139
+ batch(): WriteBatch;
140
+ close(): Promise<void>;
141
+ approximateCount(options?: IterateOptions): Promise<number>;
142
+ private checkOpen;
143
+ }
144
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEnF;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IACjC;;OAEG;IACH,GAAG,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAElE;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI,CAAC;IAExC;;OAEG;IACH,KAAK,IAAI,IAAI,CAAC;CACd;AAED;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,UAAU,iBAAiB,CAAC;AAEvE;;;;;;GAMG;AACH,MAAM,W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AAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,UAAU,EAAE,4BAA4B,GAAG,uBAAuB;IAI7F;;OAEG;IACH,MAAM,CAAC,IAAI,CACV,MAAM,EAAE,aAAa,EACrB,UAAU,EAAE,4BAA4B,EACxC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QAAE,eAAe,CAAC,EAAE,OAAO,CAAC;QAAC,aAAa,CAAC,EAAE,OAAO,CAAA;KAAE,GAC9D,uBAAuB;IASpB,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAMrD,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtD,MAAM,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IAKtC,GAAG,CAAC,GAAG,EAAE,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC;IAMrC,OAAO,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,aAAa,CAAC,OAAO,CAAC;IAchE,OAAO,CAAC,cAAc;IA6EtB,KAAK,IAAI,UAAU;IAKb,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,gBAAgB,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,MAAM,CAAC;IAUjE,OAAO,CAAC,SAAS;CAKjB"}
@@ -0,0 +1,241 @@
1
+ /**
2
+ * LevelDB-based KVStore implementation for React Native.
3
+ *
4
+ * Uses rn-leveldb for LevelDB bindings on iOS/Android.
5
+ * Keys and values are stored as binary ArrayBuffers.
6
+ */
7
+ /**
8
+ * LevelDB implementation of KVStore for React Native.
9
+ *
10
+ * Keys and values are stored as ArrayBuffers. LevelDB provides correct
11
+ * lexicographic byte ordering for range scans.
12
+ */
13
+ export class ReactNativeLevelDBStore {
14
+ db;
15
+ WriteBatchCtor;
16
+ closed = false;
17
+ constructor(db, WriteBatch) {
18
+ this.db = db;
19
+ this.WriteBatchCtor = WriteBatch;
20
+ }
21
+ /**
22
+ * Create a store with the given LevelDB instance and WriteBatch constructor.
23
+ */
24
+ static create(db, WriteBatch) {
25
+ return new ReactNativeLevelDBStore(db, WriteBatch);
26
+ }
27
+ /**
28
+ * Open a store using the provided open function.
29
+ */
30
+ static open(openFn, WriteBatch, name, options) {
31
+ const db = openFn(name, options?.createIfMissing ?? true, options?.errorIfExists ?? false);
32
+ return new ReactNativeLevelDBStore(db, WriteBatch);
33
+ }
34
+ async get(key) {
35
+ this.checkOpen();
36
+ const result = this.db.getBuf(toArrayBuffer(key));
37
+ return result === null ? undefined : toUint8Array(result);
38
+ }
39
+ async put(key, value) {
40
+ this.checkOpen();
41
+ this.db.put(toArrayBuffer(key), toArrayBuffer(value));
42
+ }
43
+ async delete(key) {
44
+ this.checkOpen();
45
+ this.db.delete(toArrayBuffer(key));
46
+ }
47
+ async has(key) {
48
+ this.checkOpen();
49
+ const result = this.db.getBuf(toArrayBuffer(key));
50
+ return result !== null;
51
+ }
52
+ async *iterate(options) {
53
+ this.checkOpen();
54
+ const iterator = this.db.newIterator();
55
+ try {
56
+ const entries = this.collectEntries(iterator, options);
57
+ for (const entry of entries) {
58
+ yield entry;
59
+ }
60
+ }
61
+ finally {
62
+ iterator.close();
63
+ }
64
+ }
65
+ collectEntries(iterator, options) {
66
+ const entries = [];
67
+ const limit = options?.limit;
68
+ const reverse = options?.reverse ?? false;
69
+ // Position the iterator at the start
70
+ if (reverse) {
71
+ if (options?.lte) {
72
+ iterator.seek(toArrayBuffer(options.lte));
73
+ // If we seeked past, go back
74
+ if (!iterator.valid()) {
75
+ iterator.seekLast();
76
+ }
77
+ else {
78
+ // Check if current key is > lte (need to go back)
79
+ const currentKey = toUint8Array(iterator.keyBuf());
80
+ if (compareBytes(currentKey, options.lte) > 0) {
81
+ iterator.prev();
82
+ }
83
+ }
84
+ }
85
+ else if (options?.lt) {
86
+ iterator.seek(toArrayBuffer(options.lt));
87
+ // Go to previous since lt is exclusive
88
+ if (iterator.valid()) {
89
+ iterator.prev();
90
+ }
91
+ else {
92
+ iterator.seekLast();
93
+ }
94
+ }
95
+ else {
96
+ iterator.seekLast();
97
+ }
98
+ }
99
+ else {
100
+ if (options?.gte) {
101
+ iterator.seek(toArrayBuffer(options.gte));
102
+ }
103
+ else if (options?.gt) {
104
+ iterator.seek(toArrayBuffer(options.gt));
105
+ // Skip if current key equals gt (exclusive)
106
+ if (iterator.valid()) {
107
+ const currentKey = toUint8Array(iterator.keyBuf());
108
+ if (compareBytes(currentKey, options.gt) === 0) {
109
+ iterator.next();
110
+ }
111
+ }
112
+ }
113
+ else {
114
+ iterator.seekToFirst();
115
+ }
116
+ }
117
+ // Collect entries
118
+ while (iterator.valid()) {
119
+ if (limit !== undefined && entries.length >= limit) {
120
+ break;
121
+ }
122
+ const key = toUint8Array(iterator.keyBuf());
123
+ const value = toUint8Array(iterator.valueBuf());
124
+ // Check bounds
125
+ if (!reverse) {
126
+ if (options?.lt && compareBytes(key, options.lt) >= 0)
127
+ break;
128
+ if (options?.lte && compareBytes(key, options.lte) > 0)
129
+ break;
130
+ }
131
+ else {
132
+ if (options?.gt && compareBytes(key, options.gt) <= 0)
133
+ break;
134
+ if (options?.gte && compareBytes(key, options.gte) < 0)
135
+ break;
136
+ }
137
+ entries.push({ key, value });
138
+ if (reverse) {
139
+ iterator.prev();
140
+ }
141
+ else {
142
+ iterator.next();
143
+ }
144
+ }
145
+ return entries;
146
+ }
147
+ batch() {
148
+ this.checkOpen();
149
+ return new ReactNativeLevelDBWriteBatch(this.db, this.WriteBatchCtor);
150
+ }
151
+ async close() {
152
+ if (!this.closed) {
153
+ this.closed = true;
154
+ this.db.close();
155
+ }
156
+ }
157
+ async approximateCount(options) {
158
+ this.checkOpen();
159
+ // LevelDB doesn't have a native count, so we iterate and count
160
+ let count = 0;
161
+ for await (const _ of this.iterate(options)) {
162
+ count++;
163
+ }
164
+ return count;
165
+ }
166
+ checkOpen() {
167
+ if (this.closed) {
168
+ throw new Error('ReactNativeLevelDBStore is closed');
169
+ }
170
+ }
171
+ }
172
+ /**
173
+ * WriteBatch implementation for React Native LevelDB.
174
+ * Uses native LevelDB WriteBatch for atomic multi-key writes.
175
+ */
176
+ class ReactNativeLevelDBWriteBatch {
177
+ db;
178
+ WriteBatchCtor;
179
+ nativeBatch;
180
+ constructor(db, WriteBatch) {
181
+ this.db = db;
182
+ this.WriteBatchCtor = WriteBatch;
183
+ this.nativeBatch = new WriteBatch();
184
+ }
185
+ put(key, value) {
186
+ this.nativeBatch.put(toArrayBuffer(key), toArrayBuffer(value));
187
+ }
188
+ delete(key) {
189
+ this.nativeBatch.delete(toArrayBuffer(key));
190
+ }
191
+ async write() {
192
+ this.db.write(this.nativeBatch);
193
+ // Close the old batch and create a new one for potential reuse
194
+ this.nativeBatch.close();
195
+ this.nativeBatch = new this.WriteBatchCtor();
196
+ }
197
+ clear() {
198
+ // Close the old batch and create a new empty one
199
+ this.nativeBatch.close();
200
+ this.nativeBatch = new this.WriteBatchCtor();
201
+ }
202
+ }
203
+ // ============================================================================
204
+ // Binary conversion utilities
205
+ // ============================================================================
206
+ /**
207
+ * Convert Uint8Array to ArrayBuffer.
208
+ */
209
+ function toArrayBuffer(bytes) {
210
+ const buffer = bytes.buffer;
211
+ // Fast path: if the Uint8Array covers the full buffer and isn't shared, use directly
212
+ if (buffer instanceof ArrayBuffer &&
213
+ bytes.byteOffset === 0 &&
214
+ bytes.byteLength === buffer.byteLength) {
215
+ return buffer;
216
+ }
217
+ // Slow path: copy for views into larger buffers or SharedArrayBuffer
218
+ const copy = new ArrayBuffer(bytes.byteLength);
219
+ new Uint8Array(copy).set(bytes);
220
+ return copy;
221
+ }
222
+ /**
223
+ * Convert ArrayBuffer to Uint8Array.
224
+ */
225
+ function toUint8Array(data) {
226
+ return new Uint8Array(data);
227
+ }
228
+ /**
229
+ * Compare two Uint8Arrays lexicographically.
230
+ * @returns Negative if a < b, 0 if equal, positive if a > b.
231
+ */
232
+ function compareBytes(a, b) {
233
+ const minLength = Math.min(a.length, b.length);
234
+ for (let i = 0; i < minLength; i++) {
235
+ if (a[i] !== b[i]) {
236
+ return a[i] - b[i];
237
+ }
238
+ }
239
+ return a.length - b.length;
240
+ }
241
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AA+HH;;;;;GAKG;AACH,MAAM,OAAO,uBAAuB;IAC3B,EAAE,CAAU;IACZ,cAAc,CAA+B;IAC7C,MAAM,GAAG,KAAK,CAAC;IAEvB,YAAoB,EAAW,EAAE,UAAwC;QACxE,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,cAAc,GAAG,UAAU,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,EAAW,EAAE,UAAwC;QAClE,OAAO,IAAI,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAI,CACV,MAAqB,EACrB,UAAwC,EACxC,IAAY,EACZ,OAAgE;QAEhE,MAAM,EAAE,GAAG,MAAM,CAChB,IAAI,EACJ,OAAO,EAAE,eAAe,IAAI,IAAI,EAChC,OAAO,EAAE,aAAa,IAAI,KAAK,CAC/B,CAAC;QACF,OAAO,IAAI,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAe;QACxB,IAAI,CAAC,SAAS,EAAE,CAAC;QACjB,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC;QAClD,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC3D,CAAC;I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C;AAC7B,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CAAC,CAAa,EAAE,CAAa;IACjD,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC;IAC/C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACnB,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;IACD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,92 @@
1
+ {
2
+ "name": "@quereus/plugin-react-native-leveldb",
3
+ "version": "0.1.1",
4
+ "type": "module",
5
+ "description": "React Native LevelDB storage plugin for Quereus - mobile persistent storage",
6
+ "keywords": [
7
+ "quereus",
8
+ "quereus-plugin",
9
+ "sql",
10
+ "database",
11
+ "storage",
12
+ "leveldb",
13
+ "react-native",
14
+ "mobile",
15
+ "ios",
16
+ "android",
17
+ "kv-store",
18
+ "persistent"
19
+ ],
20
+ "publisher": "Got Choices Foundation",
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/gotchoices/quereus.git",
24
+ "directory": "packages/quereus-plugin-react-native-leveldb"
25
+ },
26
+ "license": "MIT",
27
+ "main": "dist/src/index.js",
28
+ "types": "./dist/src/index.d.ts",
29
+ "files": [
30
+ "dist",
31
+ "!**/*.tsbuildinfo"
32
+ ],
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/src/index.d.ts",
36
+ "import": "./dist/src/index.js"
37
+ },
38
+ "./plugin": {
39
+ "types": "./dist/src/plugin.d.ts",
40
+ "import": "./dist/src/plugin.js"
41
+ }
42
+ },
43
+ "peerDependencies": {
44
+ "@quereus/quereus": "^0.24.0",
45
+ "@quereus/store": "^0.3.5",
46
+ "rn-leveldb": "^3.11.0"
47
+ },
48
+ "engines": {
49
+ "quereus": "^0.24.0"
50
+ },
51
+ "quereus": {
52
+ "provides": {
53
+ "vtables": [
54
+ "store"
55
+ ]
56
+ },
57
+ "settings": [
58
+ {
59
+ "key": "databaseName",
60
+ "label": "Database Name",
61
+ "type": "string",
62
+ "default": "quereus",
63
+ "help": "Base name for LevelDB databases"
64
+ },
65
+ {
66
+ "key": "moduleName",
67
+ "label": "Module Name",
68
+ "type": "string",
69
+ "default": "store",
70
+ "help": "Name to register the virtual table module under"
71
+ }
72
+ ]
73
+ },
74
+ "scripts": {
75
+ "clean": "rimraf dist",
76
+ "build": "tsc",
77
+ "typecheck": "tsc --noEmit",
78
+ "test": "cd ../.. && node --import ./packages/quereus-plugin-react-native-leveldb/register.mjs node_modules/mocha/bin/mocha.js \"packages/quereus-plugin-react-native-leveldb/test/**/*.spec.ts\" --colors"
79
+ },
80
+ "devDependencies": {
81
+ "@quereus/quereus": "*",
82
+ "@quereus/store": "*",
83
+ "@types/chai": "^5.2.2",
84
+ "@types/mocha": "^10.0.10",
85
+ "@types/node": "^22.15.29",
86
+ "chai": "^5.2.0",
87
+ "mocha": "^11.5.0",
88
+ "rimraf": "^6.1.2",
89
+ "ts-node": "^10.9.2",
90
+ "typescript": "^5.8.3"
91
+ }
92
+ }