@quereus/plugin-react-native-leveldb 0.3.1 → 0.4.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 CHANGED
@@ -1,194 +1,239 @@
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.registerModule('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
-
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
+ - **Transaction isolation**: Read-your-own-writes and snapshot isolation by default
9
+ - **Synchronous API**: Uses rn-leveldb's synchronous, blocking APIs
10
+ - **Binary data**: Full support for binary keys and values via ArrayBuffers
11
+ - **Sorted keys**: Efficient range queries with ordered iteration
12
+ - **Persistent**: Data survives app restarts
13
+ - **Atomic batch writes**: Uses native LevelDB WriteBatch for atomic multi-key operations
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @quereus/plugin-react-native-leveldb @quereus/store @quereus/isolation rn-leveldb
19
+
20
+ # Don't forget to link native modules
21
+ cd ios && pod install
22
+ ```
23
+
24
+ ## Required Polyfills
25
+
26
+ React Native apps typically need a few runtime polyfills for Quereus and its plugins:
27
+
28
+ - **`structuredClone`** - Quereus uses it internally for deep cloning operations
29
+ - **`TextEncoder` / `TextDecoder`** - Used by store plugins for binary data encoding
30
+ - **`Symbol.asyncIterator`** - Required for async-iterable support (for-await-of loops, async generators)
31
+ - Quereus uses async iterables extensively for query results and data streaming
32
+ - While Hermes has a workaround for AsyncGenerator objects, the `Symbol.asyncIterator` symbol itself must exist
33
+ - Without it, you'll get `ReferenceError: Can't find variable: Symbol` when checking for async iterables
34
+
35
+ **The plugin automatically checks for these polyfills** and throws a clear error message with installation instructions if any are missing.
36
+
37
+ You can use packages like `core-js` or provide your own implementations:
38
+
39
+ ```bash
40
+ npm install core-js text-encoding
41
+ ```
42
+
43
+ Then in your app's entry point:
44
+
45
+ ```typescript
46
+ import 'core-js/features/structured-clone';
47
+ import 'text-encoding';
48
+
49
+ // Ensure Symbol.asyncIterator exists
50
+ if (typeof Symbol.asyncIterator === 'undefined') {
51
+ (Symbol as any).asyncIterator = Symbol.for('Symbol.asyncIterator');
52
+ }
53
+ ```
54
+
55
+ ## Quick Start
56
+
57
+ ### With registerPlugin (Recommended)
58
+
59
+ ```typescript
60
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
61
+ import { Database, registerPlugin } from '@quereus/quereus';
62
+ import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
63
+
64
+ const db = new Database();
65
+ await registerPlugin(db, leveldbPlugin, {
66
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
67
+ WriteBatch: LevelDBWriteBatch,
68
+ });
69
+
70
+ await db.exec(`
71
+ create table users (id integer primary key, name text)
72
+ using store
73
+ `);
74
+
75
+ // Full transaction isolation enabled by default
76
+ await db.exec('BEGIN');
77
+ await db.exec(`insert into users (id, name) values (1, 'Alice')`);
78
+ const user = await db.get('select * from users where id = 1'); // Sees uncommitted insert
79
+ await db.exec('COMMIT');
80
+ ```
81
+
82
+ ### Disabling Isolation
83
+
84
+ If you need maximum performance and don't require read-your-own-writes within transactions:
85
+
86
+ ```typescript
87
+ await registerPlugin(db, leveldbPlugin, {
88
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
89
+ WriteBatch: LevelDBWriteBatch,
90
+ isolation: false // Disable isolation layer
91
+ });
92
+ ```
93
+
94
+ ### Direct Usage with Provider
95
+
96
+ ```typescript
97
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
98
+ import { Database } from '@quereus/quereus';
99
+ import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
100
+ import { createIsolatedStoreModule } from '@quereus/store';
101
+
102
+ const db = new Database();
103
+ const provider = createReactNativeLevelDBProvider({
104
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
105
+ WriteBatch: LevelDBWriteBatch,
106
+ });
107
+ const storeModule = new StoreModule(provider);
108
+ db.registerModule('store', storeModule);
109
+
110
+ await db.exec(`
111
+ create table users (id integer primary key, name text)
112
+ using store
113
+ `);
114
+ ```
115
+
116
+ ## API
117
+
118
+ ### ReactNativeLevelDBStore
119
+
120
+ Low-level KVStore implementation:
121
+
122
+ ```typescript
123
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
124
+ import { ReactNativeLevelDBStore } from '@quereus/plugin-react-native-leveldb';
125
+
126
+ // Open using the factory function
127
+ const openFn = (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists);
128
+ const store = ReactNativeLevelDBStore.open(openFn, LevelDBWriteBatch, 'mystore');
129
+
130
+ await store.put(key, value);
131
+ const data = await store.get(key);
132
+ await store.delete(key);
133
+
134
+ // Range iteration
135
+ for await (const { key, value } of store.iterate({ gte: startKey, lt: endKey })) {
136
+ console.log(key, value);
137
+ }
138
+
139
+ // Atomic batch writes (uses native LevelDB WriteBatch)
140
+ const batch = store.batch();
141
+ batch.put(key1, value1);
142
+ batch.put(key2, value2);
143
+ batch.delete(key3);
144
+ await batch.write();
145
+
146
+ await store.close();
147
+ ```
148
+
149
+ ### ReactNativeLevelDBProvider
150
+
151
+ Factory for managing multiple stores:
152
+
153
+ ```typescript
154
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
155
+ import { createReactNativeLevelDBProvider } from '@quereus/plugin-react-native-leveldb';
156
+
157
+ const provider = createReactNativeLevelDBProvider({
158
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
159
+ WriteBatch: LevelDBWriteBatch,
160
+ databaseName: 'myapp',
161
+ });
162
+
163
+ const userStore = await provider.getStore('main', 'users');
164
+ const catalogStore = await provider.getCatalogStore();
165
+
166
+ await provider.closeStore('main', 'users');
167
+ await provider.closeAll();
168
+ ```
169
+
170
+ ## Configuration
171
+
172
+ ### Plugin Settings
173
+
174
+ | Setting | Type | Default | Description |
175
+ |---------|------|---------|-------------|
176
+ | `openFn` | function | **required** | Factory function: `(name, createIfMissing, errorIfExists) => LevelDB` |
177
+ | `WriteBatch` | constructor | **required** | LevelDBWriteBatch constructor from rn-leveldb |
178
+ | `databaseName` | string | `'quereus'` | Base name prefix for all LevelDB databases |
179
+ | `createIfMissing` | boolean | `true` | Create databases if they don't exist |
180
+ | `moduleName` | string | `'store'` | Name to register the virtual table module under |
181
+
182
+ ## Example with Transactions
183
+
184
+ ```typescript
185
+ import { LevelDB, LevelDBWriteBatch } from 'rn-leveldb';
186
+ import { Database, registerPlugin } from '@quereus/quereus';
187
+ import leveldbPlugin from '@quereus/plugin-react-native-leveldb/plugin';
188
+
189
+ const db = new Database();
190
+ await registerPlugin(db, leveldbPlugin, {
191
+ openFn: (name, createIfMissing, errorIfExists) => new LevelDB(name, createIfMissing, errorIfExists),
192
+ WriteBatch: LevelDBWriteBatch,
193
+ });
194
+
195
+ await db.exec(`create table accounts (id integer primary key, balance real) using store`);
196
+
197
+ await db.exec('begin');
198
+ try {
199
+ await db.exec(`update accounts set balance = balance - 100 where id = 1`);
200
+ await db.exec(`update accounts set balance = balance + 100 where id = 2`);
201
+ await db.exec('commit');
202
+ } catch (e) {
203
+ await db.exec('rollback');
204
+ throw e;
205
+ }
206
+ ```
207
+
208
+ ## Why LevelDB?
209
+
210
+ rn-leveldb provides significant performance advantages over other React Native storage options:
211
+
212
+ | Storage Solution | Operations/sec | Notes |
213
+ |------------------|----------------|-------|
214
+ | rn-leveldb | ~50,000 | Synchronous, blocking API |
215
+ | AsyncStorage | ~2,000 | JSON serialization overhead |
216
+ | react-native-sqlite-storage | ~5,000 | Full SQL parsing overhead |
217
+
218
+ LevelDB is ideal for Quereus because:
219
+ - **Sorted keys**: Natural fit for the StoreModule's index-organized storage
220
+ - **Binary support**: No JSON serialization needed for keys/values
221
+ - **Range scans**: Efficient ordered iteration for query execution
222
+
223
+ ## Peer Dependencies
224
+
225
+ This plugin requires:
226
+ - `@quereus/quereus` ^0.24.0
227
+ - `@quereus/store` ^0.3.5
228
+ - `rn-leveldb` ^3.11.0
229
+
230
+ ## Related Packages
231
+
232
+ - [`@quereus/store`](../quereus-store/) - Core storage module (StoreModule, StoreTable)
233
+ - [`@quereus/plugin-leveldb`](../quereus-plugin-leveldb/) - LevelDB plugin for Node.js
234
+ - [`@quereus/plugin-indexeddb`](../quereus-plugin-indexeddb/) - IndexedDB plugin for browsers
235
+
236
+ ## License
237
+
238
+ MIT
239
+
@@ -37,6 +37,12 @@ export interface ReactNativeLevelDBPluginConfig {
37
37
  * @default 'store'
38
38
  */
39
39
  moduleName?: string;
40
+ /**
41
+ * Enable transaction isolation (read-your-own-writes, snapshot isolation).
42
+ * When true, wraps the store module with an isolation layer.
43
+ * @default true
44
+ */
45
+ isolation?: boolean;
40
46
  }
41
47
  /**
42
48
  * Register the React Native LevelDB plugin with a database.
@@ -62,7 +68,7 @@ export interface ReactNativeLevelDBPluginConfig {
62
68
  export default function register(_db: Database, config?: Record<string, SqlValue>): {
63
69
  vtables: {
64
70
  name: string;
65
- module: StoreModule;
71
+ module: import("@quereus/isolation").IsolationModule | StoreModule;
66
72
  }[];
67
73
  };
68
74
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +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,W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,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EA+CrC"}
@@ -4,8 +4,41 @@
4
4
  * Registers a StoreModule backed by LevelDB for React Native mobile environments.
5
5
  * Uses rn-leveldb for native LevelDB bindings.
6
6
  */
7
- import { StoreModule } from '@quereus/store';
7
+ import { StoreModule, createIsolatedStoreModule } from '@quereus/store';
8
8
  import { ReactNativeLevelDBProvider } from './provider.js';
9
+ /**
10
+ * Check for required React Native polyfills and throw a helpful error if any are missing.
11
+ */
12
+ function checkRequiredPolyfills() {
13
+ const missing = [];
14
+ // Check for structuredClone
15
+ if (typeof structuredClone === 'undefined') {
16
+ missing.push('structuredClone (used internally by Quereus)\n' +
17
+ ' Install: npm install core-js\n' +
18
+ ' Import: import \'core-js/features/structured-clone\';');
19
+ }
20
+ // Check for TextEncoder/TextDecoder
21
+ if (typeof TextEncoder === 'undefined' || typeof TextDecoder === 'undefined') {
22
+ missing.push('TextEncoder/TextDecoder (used by store plugins for binary data)\n' +
23
+ ' Install: npm install text-encoding\n' +
24
+ ' Import: import \'text-encoding\';');
25
+ }
26
+ // Check for Symbol.asyncIterator
27
+ if (typeof Symbol.asyncIterator === 'undefined') {
28
+ missing.push('Symbol.asyncIterator (required for async-iterable support)\n' +
29
+ ' Quereus uses async generators and for-await-of loops extensively.\n' +
30
+ ' While Hermes has special handling for AsyncGenerator objects, the symbol must exist.\n' +
31
+ ' Add to your app entry point:\n' +
32
+ ' if (typeof Symbol.asyncIterator === \'undefined\') {\n' +
33
+ ' (Symbol as any).asyncIterator = Symbol.for(\'Symbol.asyncIterator\');\n' +
34
+ ' }');
35
+ }
36
+ if (missing.length > 0) {
37
+ throw new Error('@quereus/plugin-react-native-leveldb requires the following polyfills:\n\n' +
38
+ missing.map((msg, i) => `${i + 1}. ${msg}`).join('\n\n') +
39
+ '\n\nFor more details, see: https://github.com/yourorg/quereus/tree/main/packages/quereus-plugin-react-native-leveldb#required-polyfills');
40
+ }
41
+ }
9
42
  /**
10
43
  * Register the React Native LevelDB plugin with a database.
11
44
  *
@@ -28,6 +61,8 @@ import { ReactNativeLevelDBProvider } from './provider.js';
28
61
  * ```
29
62
  */
30
63
  export default function register(_db, config = {}) {
64
+ // Check for required polyfills first
65
+ checkRequiredPolyfills();
31
66
  // The LevelDB open function must be provided
32
67
  const openFn = config.openFn;
33
68
  if (!openFn) {
@@ -43,13 +78,16 @@ export default function register(_db, config = {}) {
43
78
  const databaseName = config.databaseName ?? 'quereus';
44
79
  const createIfMissing = config.createIfMissing !== false;
45
80
  const moduleName = config.moduleName ?? 'store';
81
+ const isolation = config.isolation ?? true;
46
82
  const provider = new ReactNativeLevelDBProvider({
47
83
  openFn,
48
84
  WriteBatch,
49
85
  databaseName,
50
86
  createIfMissing,
51
87
  });
52
- const storeModule = new StoreModule(provider);
88
+ const storeModule = isolation
89
+ ? createIsolatedStoreModule({ provider })
90
+ : new StoreModule(provider);
53
91
  return {
54
92
  vtables: [
55
93
  {
@@ -1 +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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M;QACN,UAAU;QACV,YAAY;QACZ,eAAe;KACf,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,SAAS;QAC5B,CAAC,CAAC,yBAAyB,CAAC,EAAE,QAAQ,EAAE,CAAC;QACzC,CAAC,CAAC,IAAI,WAAW,CAAC,QAAQ,CAAC,CAAC;IAE7B,OAAO;QACN,OAAO,EAAE;YACR;gBACC,IAAI,EAAE,UAAU;gBAChB,MAAM,EAAE,WAAW;aACnB;SACD;KACD,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quereus/plugin-react-native-leveldb",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "type": "module",
5
5
  "description": "React Native LevelDB storage plugin for Quereus - mobile persistent storage",
6
6
  "keywords": [
@@ -41,8 +41,9 @@
41
41
  }
42
42
  },
43
43
  "peerDependencies": {
44
- "@quereus/quereus": "^0.12.1",
45
- "@quereus/store": "^0.5.1",
44
+ "@quereus/isolation": "^0.2.0",
45
+ "@quereus/quereus": "^0.13.0",
46
+ "@quereus/store": "^0.6.0",
46
47
  "rn-leveldb": "^3.11.0"
47
48
  },
48
49
  "engines": {
@@ -68,6 +69,13 @@
68
69
  "type": "string",
69
70
  "default": "store",
70
71
  "help": "Name to register the virtual table module under"
72
+ },
73
+ {
74
+ "key": "isolation",
75
+ "label": "Transaction Isolation",
76
+ "type": "boolean",
77
+ "default": true,
78
+ "help": "Enable transaction isolation (read-your-own-writes, snapshot isolation)"
71
79
  }
72
80
  ]
73
81
  },
@@ -78,6 +86,7 @@
78
86
  "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
87
  },
80
88
  "devDependencies": {
89
+ "@quereus/isolation": "*",
81
90
  "@quereus/quereus": "*",
82
91
  "@quereus/store": "*",
83
92
  "@types/chai": "^5.2.2",