@quereus/plugin-indexeddb 0.4.2 → 0.5.0

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
@@ -5,13 +5,14 @@ IndexedDB storage plugin for Quereus. Provides persistent storage for browser en
5
5
  ## Features
6
6
 
7
7
  - **Browser-native**: Uses IndexedDB for reliable persistent storage
8
+ - **Transaction isolation**: Read-your-own-writes and snapshot isolation by default
8
9
  - **Cross-tab sync**: BroadcastChannel-based synchronization across browser tabs
9
10
  - **Async iteration**: Efficient range queries with cursor-based iteration
10
11
 
11
12
  ## Installation
12
13
 
13
14
  ```bash
14
- npm install @quereus/plugin-indexeddb @quereus/store
15
+ npm install @quereus/plugin-indexeddb @quereus/store @quereus/isolation
15
16
  ```
16
17
 
17
18
  ## Quick Start
@@ -26,6 +27,23 @@ const db = new Database();
26
27
  await registerPlugin(db, indexeddbPlugin, { prefix: 'myapp' });
27
28
 
28
29
  await db.exec(`create table users (id integer primary key, name text) using store`);
30
+
31
+ // Full transaction isolation enabled by default
32
+ await db.exec('BEGIN');
33
+ await db.exec(`INSERT INTO users VALUES (1, 'Alice')`);
34
+ const user = await db.get('SELECT * FROM users WHERE id = 1'); // Sees uncommitted insert
35
+ await db.exec('COMMIT');
36
+ ```
37
+
38
+ ### Disabling Isolation
39
+
40
+ If you need maximum performance and don't require read-your-own-writes within transactions:
41
+
42
+ ```typescript
43
+ await registerPlugin(db, indexeddbPlugin, {
44
+ prefix: 'myapp',
45
+ isolation: false // Disable isolation layer
46
+ });
29
47
  ```
30
48
 
31
49
  ### Direct Usage with Provider
@@ -33,11 +51,13 @@ await db.exec(`create table users (id integer primary key, name text) using stor
33
51
  ```typescript
34
52
  import { Database } from '@quereus/quereus';
35
53
  import { createIndexedDBProvider } from '@quereus/plugin-indexeddb';
36
- import { StoreModule } from '@quereus/store';
54
+ import { createIsolatedStoreModule } from '@quereus/store';
37
55
 
38
56
  const db = new Database();
39
57
  const provider = createIndexedDBProvider({ prefix: 'myapp' });
40
- const storeModule = new StoreModule(provider);
58
+
59
+ // With isolation (recommended)
60
+ const storeModule = createIsolatedStoreModule({ provider });
41
61
  db.registerModule('store', storeModule);
42
62
 
43
63
  await db.exec(`create table users (id integer primary key, name text) using store`);
@@ -20,6 +20,12 @@ export interface IndexedDBPluginConfig {
20
20
  * @default 'store'
21
21
  */
22
22
  moduleName?: string;
23
+ /**
24
+ * Enable transaction isolation (read-your-own-writes, snapshot isolation).
25
+ * When true, wraps the store module with an isolation layer.
26
+ * @default true
27
+ */
28
+ isolation?: boolean;
23
29
  }
24
30
  /**
25
31
  * Register the IndexedDB plugin with a database.
@@ -27,7 +33,7 @@ export interface IndexedDBPluginConfig {
27
33
  export default function register(_db: Database, config?: Record<string, SqlValue>): {
28
34
  vtables: {
29
35
  name: string;
30
- module: StoreModule;
36
+ module: import("@quereus/isolation").IsolationModule | StoreModule;
31
37
  }[];
32
38
  };
33
39
  //# sourceMappingURL=plugin.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC9B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EAmBtC"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAA6B,MAAM,gBAAgB,CAAC;AAGxE;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACrC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,GAAG,EAAE,QAAQ,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAM;;;;;EAsBrC"}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Registers a StoreModule backed by IndexedDB for browser environments.
5
5
  */
6
- import { StoreModule } from '@quereus/store';
6
+ import { StoreModule, createIsolatedStoreModule } from '@quereus/store';
7
7
  import { IndexedDBProvider } from './provider.js';
8
8
  /**
9
9
  * Register the IndexedDB plugin with a database.
@@ -11,10 +11,13 @@ import { IndexedDBProvider } from './provider.js';
11
11
  export default function register(_db, config = {}) {
12
12
  const databaseName = config.databaseName ?? 'quereus';
13
13
  const moduleName = config.moduleName ?? 'store';
14
+ const isolation = config.isolation ?? true;
14
15
  const provider = new IndexedDBProvider({
15
16
  databaseName,
16
17
  });
17
- const storeModule = new StoreModule(provider);
18
+ const storeModule = isolation
19
+ ? createIsolatedStoreModule({ provider })
20
+ : new StoreModule(provider);
18
21
  return {
19
22
  vtables: [
20
23
  {
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAoBlD;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,QAAQ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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quereus/plugin-indexeddb",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "IndexedDB storage plugin for Quereus - browser persistent storage",
6
6
  "keywords": [
@@ -38,8 +38,9 @@
38
38
  }
39
39
  },
40
40
  "peerDependencies": {
41
- "@quereus/quereus": "^0.12.1",
42
- "@quereus/store": "^0.5.1"
41
+ "@quereus/isolation": "^0.2.0",
42
+ "@quereus/quereus": "^0.13.0",
43
+ "@quereus/store": "^0.6.0"
43
44
  },
44
45
  "engines": {
45
46
  "quereus": "^0.24.0"
@@ -64,6 +65,13 @@
64
65
  "type": "string",
65
66
  "default": "store",
66
67
  "help": "Name to register the virtual table module under"
68
+ },
69
+ {
70
+ "key": "isolation",
71
+ "label": "Transaction Isolation",
72
+ "type": "boolean",
73
+ "default": true,
74
+ "help": "Enable transaction isolation (read-your-own-writes, snapshot isolation)"
67
75
  }
68
76
  ]
69
77
  },
@@ -74,6 +82,7 @@
74
82
  "test": "cd ../.. && node --import ./packages/quereus-plugin-indexeddb/register.mjs node_modules/mocha/bin/mocha.js \"packages/quereus-plugin-indexeddb/test/**/*.spec.ts\" --colors"
75
83
  },
76
84
  "devDependencies": {
85
+ "@quereus/isolation": "*",
77
86
  "@quereus/quereus": "*",
78
87
  "@quereus/store": "*",
79
88
  "@types/chai": "^5.2.2",