@xnetjs/sqlite 0.0.2 → 0.1.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.
Files changed (37) hide show
  1. package/dist/{adapter-I7yAV6iu.d.ts → adapter-imtxkmXZ.d.ts} +48 -1
  2. package/dist/adapters/electron.d.ts +70 -6
  3. package/dist/adapters/electron.js +662 -36
  4. package/dist/adapters/expo.d.ts +6 -2
  5. package/dist/adapters/expo.js +34 -6
  6. package/dist/adapters/memory.d.ts +6 -2
  7. package/dist/adapters/memory.js +8 -1
  8. package/dist/adapters/reader-thread.d.ts +78 -0
  9. package/dist/adapters/reader-thread.js +57 -0
  10. package/dist/adapters/web-proxy.d.ts +71 -3
  11. package/dist/adapters/web-proxy.js +554 -39
  12. package/dist/adapters/web-router-worker.d.ts +76 -0
  13. package/dist/adapters/web-router-worker.js +91 -0
  14. package/dist/adapters/web-worker.d.ts +56 -1
  15. package/dist/adapters/web-worker.js +253 -14
  16. package/dist/adapters/web.d.ts +90 -3
  17. package/dist/adapters/web.js +10 -4
  18. package/dist/browser-support.d.ts +65 -1
  19. package/dist/browser-support.js +15 -3
  20. package/dist/chunk-5HC5V73T.js +191 -0
  21. package/dist/chunk-BBZDKLA3.js +727 -0
  22. package/dist/chunk-CBU263LI.js +30 -0
  23. package/dist/chunk-CGI2YBZY.js +16 -0
  24. package/dist/chunk-S6MT6KCI.js +279 -0
  25. package/dist/chunk-SV475UL5.js +44 -0
  26. package/dist/chunk-W3L4FXU5.js +415 -0
  27. package/dist/index.d.ts +111 -8
  28. package/dist/index.js +219 -130
  29. package/dist/schema-C4gufY3B.d.ts +35 -0
  30. package/dist/types-BTabr_VP.d.ts +225 -0
  31. package/dist/worker-scheduler-D04DqMmR.d.ts +56 -0
  32. package/package.json +5 -1
  33. package/dist/chunk-BXYZU3OL.js +0 -245
  34. package/dist/chunk-HIREU5S5.js +0 -193
  35. package/dist/chunk-ZRR5D2OD.js +0 -140
  36. package/dist/schema-CjkXTqxn.d.ts +0 -35
  37. package/dist/types-C_aHfRDF.d.ts +0 -42
@@ -0,0 +1,415 @@
1
+ // src/schema.ts
2
+ var SCHEMA_VERSION = 7;
3
+ var SCHEMA_DDL_CORE = `
4
+ -- ============================================
5
+ -- Schema Version Tracking
6
+ -- ============================================
7
+
8
+ CREATE TABLE IF NOT EXISTS _schema_version (
9
+ version INTEGER PRIMARY KEY,
10
+ applied_at INTEGER NOT NULL
11
+ );
12
+
13
+ -- ============================================
14
+ -- Core Tables
15
+ -- ============================================
16
+
17
+ -- All nodes (Pages, Databases, Rows, Comments, etc.)
18
+ CREATE TABLE IF NOT EXISTS nodes (
19
+ id TEXT PRIMARY KEY,
20
+ schema_id TEXT NOT NULL,
21
+ created_at INTEGER NOT NULL,
22
+ updated_at INTEGER NOT NULL,
23
+ created_by TEXT NOT NULL,
24
+ deleted_at INTEGER
25
+ );
26
+
27
+ -- Node properties (LWW per-property)
28
+ CREATE TABLE IF NOT EXISTS node_properties (
29
+ node_id TEXT NOT NULL,
30
+ property_key TEXT NOT NULL,
31
+ value BLOB,
32
+ lamport_time INTEGER NOT NULL,
33
+ updated_by TEXT NOT NULL,
34
+ updated_at INTEGER NOT NULL,
35
+
36
+ PRIMARY KEY (node_id, property_key),
37
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
38
+ );
39
+
40
+ -- Rebuildable scalar property index for query planning.
41
+ CREATE TABLE IF NOT EXISTS node_property_scalars (
42
+ node_id TEXT NOT NULL,
43
+ schema_id TEXT NOT NULL,
44
+ property_key TEXT NOT NULL,
45
+ value_type TEXT NOT NULL,
46
+ value_text TEXT,
47
+ value_number REAL,
48
+ value_boolean INTEGER,
49
+ value_hash TEXT,
50
+ updated_at INTEGER NOT NULL,
51
+ lamport_time INTEGER NOT NULL,
52
+
53
+ PRIMARY KEY (schema_id, property_key, node_id),
54
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
55
+ );
56
+
57
+ -- Query planner telemetry for adaptive read indexes.
58
+ CREATE TABLE IF NOT EXISTS query_descriptor_stats (
59
+ descriptor_hash TEXT PRIMARY KEY,
60
+ schema_id TEXT NOT NULL,
61
+ descriptor_json TEXT NOT NULL,
62
+ hits INTEGER NOT NULL,
63
+ total_duration_ms REAL NOT NULL,
64
+ avg_duration_ms REAL NOT NULL,
65
+ avg_candidates REAL NOT NULL,
66
+ last_seen_at INTEGER NOT NULL
67
+ );
68
+
69
+ CREATE TABLE IF NOT EXISTS query_index_candidates (
70
+ index_name TEXT PRIMARY KEY,
71
+ descriptor_hash TEXT NOT NULL,
72
+ schema_id TEXT NOT NULL,
73
+ property_key TEXT NOT NULL,
74
+ value_type TEXT NOT NULL,
75
+ ddl TEXT NOT NULL,
76
+ created_at INTEGER NOT NULL,
77
+ last_used_at INTEGER NOT NULL,
78
+ estimated_bytes INTEGER NOT NULL DEFAULT 0,
79
+ estimated_rows INTEGER NOT NULL DEFAULT 0,
80
+
81
+ FOREIGN KEY (descriptor_hash) REFERENCES query_descriptor_stats(descriptor_hash)
82
+ ON DELETE CASCADE
83
+ );
84
+
85
+ CREATE TABLE IF NOT EXISTS node_query_materializations (
86
+ view_id TEXT PRIMARY KEY,
87
+ descriptor_hash TEXT NOT NULL,
88
+ schema_id TEXT NOT NULL,
89
+ descriptor_json TEXT NOT NULL,
90
+ generated_at INTEGER NOT NULL,
91
+ invalidated_at INTEGER,
92
+ row_count INTEGER NOT NULL,
93
+ -- Authorization fingerprint the view was materialized under (exploration
94
+ -- 0226). NULL when authz is off; a mismatch forces an 'authz-changed'
95
+ -- refresh so a cached id list can never serve rows the viewer can no
96
+ -- longer read.
97
+ auth_fingerprint TEXT
98
+ );
99
+
100
+ CREATE TABLE IF NOT EXISTS node_query_materialized_ids (
101
+ view_id TEXT NOT NULL,
102
+ ordinal INTEGER NOT NULL,
103
+ node_id TEXT NOT NULL,
104
+
105
+ PRIMARY KEY (view_id, ordinal),
106
+ UNIQUE (view_id, node_id),
107
+ FOREIGN KEY (view_id) REFERENCES node_query_materializations(view_id)
108
+ ON DELETE CASCADE,
109
+ FOREIGN KEY (node_id) REFERENCES nodes(id)
110
+ ON DELETE CASCADE
111
+ );
112
+
113
+ -- Change log (event sourcing)
114
+ CREATE TABLE IF NOT EXISTS changes (
115
+ hash TEXT PRIMARY KEY,
116
+ node_id TEXT NOT NULL,
117
+ payload BLOB NOT NULL,
118
+ lamport_time INTEGER NOT NULL,
119
+ lamport_peer TEXT NOT NULL,
120
+ wall_time INTEGER NOT NULL,
121
+ author TEXT NOT NULL,
122
+ parent_hash TEXT,
123
+ batch_id TEXT,
124
+ signature BLOB NOT NULL,
125
+
126
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
127
+ );
128
+
129
+ -- Y.Doc binary state (for nodes with collaborative content)
130
+ CREATE TABLE IF NOT EXISTS yjs_state (
131
+ node_id TEXT PRIMARY KEY,
132
+ state BLOB NOT NULL,
133
+ updated_at INTEGER NOT NULL,
134
+
135
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
136
+ );
137
+
138
+ -- Y.Doc incremental updates (for sync)
139
+ CREATE TABLE IF NOT EXISTS yjs_updates (
140
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
141
+ node_id TEXT NOT NULL,
142
+ update_data BLOB NOT NULL,
143
+ timestamp INTEGER NOT NULL,
144
+ origin TEXT,
145
+
146
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
147
+ );
148
+
149
+ -- Yjs snapshots (for document time travel)
150
+ CREATE TABLE IF NOT EXISTS yjs_snapshots (
151
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
152
+ node_id TEXT NOT NULL,
153
+ timestamp INTEGER NOT NULL,
154
+ snapshot BLOB NOT NULL,
155
+ doc_state BLOB NOT NULL,
156
+ byte_size INTEGER NOT NULL,
157
+
158
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
159
+ );
160
+
161
+ -- Blobs (content-addressed)
162
+ CREATE TABLE IF NOT EXISTS blobs (
163
+ cid TEXT PRIMARY KEY,
164
+ data BLOB NOT NULL,
165
+ mime_type TEXT,
166
+ size INTEGER NOT NULL,
167
+ created_at INTEGER NOT NULL,
168
+ reference_count INTEGER DEFAULT 1
169
+ );
170
+
171
+ -- Documents (for @xnetjs/storage compatibility)
172
+ CREATE TABLE IF NOT EXISTS documents (
173
+ id TEXT PRIMARY KEY,
174
+ content BLOB NOT NULL,
175
+ metadata TEXT NOT NULL,
176
+ version INTEGER NOT NULL DEFAULT 1
177
+ );
178
+
179
+ -- Signed updates (for @xnetjs/storage compatibility)
180
+ CREATE TABLE IF NOT EXISTS updates (
181
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
182
+ doc_id TEXT NOT NULL,
183
+ update_hash TEXT NOT NULL,
184
+ update_data TEXT NOT NULL,
185
+ created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000),
186
+ UNIQUE(doc_id, update_hash)
187
+ );
188
+
189
+ -- Snapshots (for @xnetjs/storage compatibility)
190
+ CREATE TABLE IF NOT EXISTS snapshots (
191
+ doc_id TEXT PRIMARY KEY,
192
+ snapshot_data TEXT NOT NULL,
193
+ created_at INTEGER DEFAULT (strftime('%s', 'now') * 1000)
194
+ );
195
+
196
+ -- Sync metadata
197
+ CREATE TABLE IF NOT EXISTS sync_state (
198
+ key TEXT PRIMARY KEY,
199
+ value TEXT NOT NULL
200
+ );
201
+
202
+ -- ============================================
203
+ -- Indexes
204
+ -- ============================================
205
+
206
+ CREATE INDEX IF NOT EXISTS idx_nodes_schema ON nodes(schema_id);
207
+ CREATE INDEX IF NOT EXISTS idx_nodes_updated ON nodes(updated_at);
208
+ CREATE INDEX IF NOT EXISTS idx_nodes_created_by ON nodes(created_by);
209
+ CREATE INDEX IF NOT EXISTS idx_nodes_deleted ON nodes(deleted_at);
210
+ CREATE INDEX IF NOT EXISTS idx_nodes_live_schema_updated
211
+ ON nodes(schema_id, updated_at DESC, id)
212
+ WHERE deleted_at IS NULL;
213
+ CREATE INDEX IF NOT EXISTS idx_nodes_all_schema_updated
214
+ ON nodes(schema_id, updated_at DESC, id);
215
+ CREATE INDEX IF NOT EXISTS idx_nodes_live_schema_created
216
+ ON nodes(schema_id, created_at DESC, id)
217
+ WHERE deleted_at IS NULL;
218
+
219
+ CREATE INDEX IF NOT EXISTS idx_properties_node ON node_properties(node_id);
220
+ CREATE INDEX IF NOT EXISTS idx_properties_lamport ON node_properties(lamport_time);
221
+
222
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_text
223
+ ON node_property_scalars(schema_id, property_key, value_text, node_id)
224
+ WHERE value_type = 'text';
225
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_number
226
+ ON node_property_scalars(schema_id, property_key, value_number, node_id)
227
+ WHERE value_type = 'number';
228
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_boolean
229
+ ON node_property_scalars(schema_id, property_key, value_boolean, node_id)
230
+ WHERE value_type = 'boolean';
231
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_null
232
+ ON node_property_scalars(schema_id, property_key, node_id)
233
+ WHERE value_type = 'null';
234
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_node
235
+ ON node_property_scalars(node_id);
236
+
237
+ CREATE INDEX IF NOT EXISTS idx_query_stats_schema_seen
238
+ ON query_descriptor_stats(schema_id, last_seen_at DESC);
239
+ CREATE INDEX IF NOT EXISTS idx_query_indexes_schema_property
240
+ ON query_index_candidates(schema_id, property_key, value_type);
241
+ CREATE INDEX IF NOT EXISTS idx_query_materializations_schema
242
+ ON node_query_materializations(schema_id, invalidated_at);
243
+ CREATE INDEX IF NOT EXISTS idx_query_materialized_ids_node
244
+ ON node_query_materialized_ids(node_id);
245
+
246
+ CREATE INDEX IF NOT EXISTS idx_changes_node ON changes(node_id);
247
+ CREATE INDEX IF NOT EXISTS idx_changes_lamport ON changes(lamport_time);
248
+ CREATE INDEX IF NOT EXISTS idx_changes_wall_time ON changes(wall_time);
249
+ CREATE INDEX IF NOT EXISTS idx_changes_batch ON changes(batch_id);
250
+ CREATE INDEX IF NOT EXISTS idx_changes_node_lamport
251
+ ON changes(node_id, lamport_time DESC, hash);
252
+
253
+ CREATE INDEX IF NOT EXISTS idx_yjs_state_updated ON yjs_state(updated_at);
254
+ CREATE INDEX IF NOT EXISTS idx_yjs_updates_node ON yjs_updates(node_id);
255
+ CREATE INDEX IF NOT EXISTS idx_yjs_snapshots_node ON yjs_snapshots(node_id);
256
+ CREATE INDEX IF NOT EXISTS idx_yjs_snapshots_timestamp ON yjs_snapshots(node_id, timestamp);
257
+
258
+ CREATE INDEX IF NOT EXISTS idx_updates_doc ON updates(doc_id);
259
+ CREATE INDEX IF NOT EXISTS idx_updates_created ON updates(created_at);
260
+ `;
261
+ var SCHEMA_DDL_FTS = `
262
+ -- ============================================
263
+ -- Full-Text Search (FTS5)
264
+ -- ============================================
265
+
266
+ -- FTS index for searchable node content
267
+ CREATE VIRTUAL TABLE IF NOT EXISTS nodes_fts USING fts5(
268
+ node_id,
269
+ title,
270
+ content,
271
+ tokenize='porter unicode61'
272
+ );
273
+
274
+ -- Triggers to keep FTS in sync will be managed by application layer
275
+ -- since the searchable content is derived from node properties
276
+ `;
277
+ var SCHEMA_DDL = SCHEMA_DDL_CORE + SCHEMA_DDL_FTS;
278
+ var SCHEMA_MIGRATIONS = {
279
+ 2: `
280
+ CREATE TABLE IF NOT EXISTS node_property_scalars (
281
+ node_id TEXT NOT NULL,
282
+ schema_id TEXT NOT NULL,
283
+ property_key TEXT NOT NULL,
284
+ value_type TEXT NOT NULL,
285
+ value_text TEXT,
286
+ value_number REAL,
287
+ value_boolean INTEGER,
288
+ value_hash TEXT,
289
+ updated_at INTEGER NOT NULL,
290
+ lamport_time INTEGER NOT NULL,
291
+
292
+ PRIMARY KEY (schema_id, property_key, node_id),
293
+ FOREIGN KEY (node_id) REFERENCES nodes(id) ON DELETE CASCADE
294
+ );
295
+
296
+ CREATE INDEX IF NOT EXISTS idx_nodes_live_schema_updated
297
+ ON nodes(schema_id, updated_at DESC, id)
298
+ WHERE deleted_at IS NULL;
299
+ CREATE INDEX IF NOT EXISTS idx_nodes_all_schema_updated
300
+ ON nodes(schema_id, updated_at DESC, id);
301
+ CREATE INDEX IF NOT EXISTS idx_nodes_live_schema_created
302
+ ON nodes(schema_id, created_at DESC, id)
303
+ WHERE deleted_at IS NULL;
304
+
305
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_text
306
+ ON node_property_scalars(schema_id, property_key, value_text, node_id)
307
+ WHERE value_type = 'text';
308
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_number
309
+ ON node_property_scalars(schema_id, property_key, value_number, node_id)
310
+ WHERE value_type = 'number';
311
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_boolean
312
+ ON node_property_scalars(schema_id, property_key, value_boolean, node_id)
313
+ WHERE value_type = 'boolean';
314
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_null
315
+ ON node_property_scalars(schema_id, property_key, node_id)
316
+ WHERE value_type = 'null';
317
+ `,
318
+ 3: `
319
+ CREATE TABLE IF NOT EXISTS query_descriptor_stats (
320
+ descriptor_hash TEXT PRIMARY KEY,
321
+ schema_id TEXT NOT NULL,
322
+ descriptor_json TEXT NOT NULL,
323
+ hits INTEGER NOT NULL,
324
+ total_duration_ms REAL NOT NULL,
325
+ avg_duration_ms REAL NOT NULL,
326
+ avg_candidates REAL NOT NULL,
327
+ last_seen_at INTEGER NOT NULL
328
+ );
329
+
330
+ CREATE TABLE IF NOT EXISTS query_index_candidates (
331
+ index_name TEXT PRIMARY KEY,
332
+ descriptor_hash TEXT NOT NULL,
333
+ schema_id TEXT NOT NULL,
334
+ property_key TEXT NOT NULL,
335
+ value_type TEXT NOT NULL,
336
+ ddl TEXT NOT NULL,
337
+ created_at INTEGER NOT NULL,
338
+ last_used_at INTEGER NOT NULL,
339
+ estimated_bytes INTEGER NOT NULL DEFAULT 0,
340
+ estimated_rows INTEGER NOT NULL DEFAULT 0,
341
+
342
+ FOREIGN KEY (descriptor_hash) REFERENCES query_descriptor_stats(descriptor_hash)
343
+ ON DELETE CASCADE
344
+ );
345
+
346
+ CREATE INDEX IF NOT EXISTS idx_query_stats_schema_seen
347
+ ON query_descriptor_stats(schema_id, last_seen_at DESC);
348
+ CREATE INDEX IF NOT EXISTS idx_query_indexes_schema_property
349
+ ON query_index_candidates(schema_id, property_key, value_type);
350
+ `,
351
+ 4: `
352
+ ALTER TABLE query_index_candidates
353
+ ADD COLUMN estimated_bytes INTEGER NOT NULL DEFAULT 0;
354
+ ALTER TABLE query_index_candidates
355
+ ADD COLUMN estimated_rows INTEGER NOT NULL DEFAULT 0;
356
+ `,
357
+ 5: `
358
+ CREATE TABLE IF NOT EXISTS node_query_materializations (
359
+ view_id TEXT PRIMARY KEY,
360
+ descriptor_hash TEXT NOT NULL,
361
+ schema_id TEXT NOT NULL,
362
+ descriptor_json TEXT NOT NULL,
363
+ generated_at INTEGER NOT NULL,
364
+ invalidated_at INTEGER,
365
+ row_count INTEGER NOT NULL
366
+ );
367
+
368
+ CREATE TABLE IF NOT EXISTS node_query_materialized_ids (
369
+ view_id TEXT NOT NULL,
370
+ ordinal INTEGER NOT NULL,
371
+ node_id TEXT NOT NULL,
372
+
373
+ PRIMARY KEY (view_id, ordinal),
374
+ UNIQUE (view_id, node_id),
375
+ FOREIGN KEY (view_id) REFERENCES node_query_materializations(view_id)
376
+ ON DELETE CASCADE,
377
+ FOREIGN KEY (node_id) REFERENCES nodes(id)
378
+ ON DELETE CASCADE
379
+ );
380
+
381
+ CREATE INDEX IF NOT EXISTS idx_query_materializations_schema
382
+ ON node_query_materializations(schema_id, invalidated_at);
383
+ CREATE INDEX IF NOT EXISTS idx_query_materialized_ids_node
384
+ ON node_query_materialized_ids(node_id);
385
+ `,
386
+ 6: `
387
+ CREATE INDEX IF NOT EXISTS idx_prop_scalars_node
388
+ ON node_property_scalars(node_id);
389
+ CREATE INDEX IF NOT EXISTS idx_changes_node_lamport
390
+ ON changes(node_id, lamport_time DESC, hash);
391
+ `,
392
+ 7: `
393
+ ALTER TABLE node_query_materializations
394
+ ADD COLUMN auth_fingerprint TEXT;
395
+ `
396
+ };
397
+ function getMigrationSQL(fromVersion, toVersion) {
398
+ const statements = [];
399
+ for (let v = fromVersion + 1; v <= toVersion; v++) {
400
+ const migration = SCHEMA_MIGRATIONS[v];
401
+ if (migration) {
402
+ statements.push(migration);
403
+ }
404
+ }
405
+ return statements.join("\n");
406
+ }
407
+
408
+ export {
409
+ SCHEMA_VERSION,
410
+ SCHEMA_DDL_CORE,
411
+ SCHEMA_DDL_FTS,
412
+ SCHEMA_DDL,
413
+ SCHEMA_MIGRATIONS,
414
+ getMigrationSQL
415
+ };
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { S as SQLValue } from './types-C_aHfRDF.js';
2
- export { R as RunResult, a as SQLRow, b as SQLiteConfig, c as SchemaVersion } from './types-C_aHfRDF.js';
3
- import { S as SQLiteAdapter } from './adapter-I7yAV6iu.js';
4
- export { P as PreparedStatement } from './adapter-I7yAV6iu.js';
5
- export { a as SCHEMA_DDL, b as SCHEMA_DDL_CORE, c as SCHEMA_DDL_FTS, d as SCHEMA_MIGRATIONS, S as SCHEMA_VERSION, g as getMigrationSQL } from './schema-CjkXTqxn.js';
6
- export { BrowserSupport, checkBrowserSupport, showUnsupportedBrowserMessage } from './browser-support.js';
1
+ import { S as SQLValue } from './types-BTabr_VP.js';
2
+ export { E as ElectronSQLiteDiagnostics, R as RunResult, c as SQLBatchRead, a as SQLRow, b as SQLiteConfig, l as SQLiteNodeBatchApplyInput, m as SQLiteNodeBatchApplyResult, i as SQLiteNodeBatchChangeRow, k as SQLiteNodeBatchFtsRow, f as SQLiteNodeBatchIndexMode, g as SQLiteNodeBatchNodeRow, h as SQLiteNodeBatchPropertyRow, j as SQLiteNodeBatchScalarIndexRow, e as SQLiteOperationStats, d as SchemaVersion } from './types-BTabr_VP.js';
3
+ import { S as SQLiteAdapter } from './adapter-imtxkmXZ.js';
4
+ export { P as PreparedStatement } from './adapter-imtxkmXZ.js';
5
+ export { a as SCHEMA_DDL, b as SCHEMA_DDL_CORE, c as SCHEMA_DDL_FTS, d as SCHEMA_MIGRATIONS, S as SCHEMA_VERSION, g as getMigrationSQL } from './schema-C4gufY3B.js';
6
+ export { BrowserSupport, PersistentStorageRequestOptions, PersistentStorageStatus, checkBrowserSupport, checkPersistentStorage, getMemoryFallbackSessionCount, isSilentPersistRequestSafe, recordMemoryFallbackSession, requestPersistentStorage, showUnsupportedBrowserMessage, watchPersistentStoragePermission } from './browser-support.js';
7
7
 
8
8
  /**
9
9
  * @xnetjs/sqlite - SQL query building helpers
@@ -156,8 +156,15 @@ interface DatabaseStats {
156
156
  walMode: boolean;
157
157
  foreignKeys: boolean;
158
158
  }
159
+ interface SQLiteRuntimeCapabilities {
160
+ fts5: boolean;
161
+ rtree: boolean;
162
+ }
159
163
  /**
160
- * Get information about all indexes in the database.
164
+ * Get information about all indexes in the database. Cached per adapter and keyed
165
+ * on `PRAGMA schema_version`, so repeated calls between DDL changes pay one cheap
166
+ * version probe instead of `sqlite_master` + N `PRAGMA index_info` round-trips
167
+ * (exploration 0253).
161
168
  */
162
169
  declare function getIndexInfo(db: SQLiteAdapter): Promise<IndexInfo[]>;
163
170
  /**
@@ -180,6 +187,13 @@ declare function getAllTableStats(db: SQLiteAdapter): Promise<TableStats[]>;
180
187
  * Get overall database statistics.
181
188
  */
182
189
  declare function getDatabaseStats(db: SQLiteAdapter): Promise<DatabaseStats>;
190
+ /**
191
+ * Detect optional SQLite virtual table modules for the active runtime.
192
+ *
193
+ * xNet runs against multiple SQLite implementations, so feature availability
194
+ * must be probed at runtime rather than inferred from platform.
195
+ */
196
+ declare function detectSQLiteCapabilities(db: SQLiteAdapter): Promise<SQLiteRuntimeCapabilities>;
183
197
  /**
184
198
  * Run ANALYZE to update query planner statistics.
185
199
  */
@@ -204,4 +218,93 @@ declare function timeQuery<T>(db: SQLiteAdapter, sql: string, params?: SQLValue[
204
218
  rowCount: number;
205
219
  }>;
206
220
 
207
- export { type DatabaseStats, type FTSSearchOptions, type FTSSearchResult, type IndexInfo, type QueryPlanStep, SQLValue, SQLiteAdapter, type TableStats, analyzeQuery, analyzeTable, buildBatchInsert, buildInsert, buildSelect, buildUpdate, checkIntegrity, deleteNodeFTS, escapeLike, explainQuery, extractSearchableContent, extractTextFromTipTap, getAllTableStats, getDatabaseStats, getIndexInfo, optimizeFTS, rebuildFTS, runAnalyze, searchNodes, timeQuery, updateNodeFTS };
221
+ /**
222
+ * SQLite error classification helpers.
223
+ */
224
+ /**
225
+ * Return true when an error represents a malformed or unreadable SQLite file.
226
+ */
227
+ declare function isSQLiteCorruptionError(error: unknown): boolean;
228
+
229
+ /**
230
+ * @xnetjs/sqlite — OPFS capability detection (exploration 0238)
231
+ *
232
+ * The web adapter persists through the Origin Private File System. Which OPFS
233
+ * backend is reachable depends on the runtime, and the difference matters most
234
+ * inside a **mobile webview**:
235
+ *
236
+ * - `opfs-sahpool` (the fast path) needs synchronous access handles —
237
+ * `FileSystemSyncAccessHandle` — which land in **iOS 16.4+** and Chromium 108+
238
+ * (Android System WebView). This is what {@link WebSQLiteAdapter} installs.
239
+ * - Below that (iOS 15.2–16.3, older WebViews) only the **async** OPFS VFS
240
+ * (`sqlite3.oo1.OpfsDb`) works — still durable, just slower I/O.
241
+ * - With no OPFS at all (private mode, ancient engines) the adapter falls back
242
+ * to a non-durable in-memory database.
243
+ *
244
+ * The web adapter already walks that fallback chain at `open()`; this module
245
+ * makes the decision *legible* — a pure, injectable predicate the adapter uses
246
+ * to emit an accurate "why are we on the slow/no-persistence path" diagnostic,
247
+ * and that the host app / tests can call directly to branch on capability.
248
+ */
249
+ /** The durable OPFS backend a context can support, best first. */
250
+ type OpfsPersistenceMode = 'sync-access-handle' | 'async-opfs' | 'memory';
251
+ /** Structured capability report for the current (or an injected) scope. */
252
+ interface OpfsCapability {
253
+ /** OPFS root is reachable (`navigator.storage.getDirectory`). */
254
+ opfs: boolean;
255
+ /**
256
+ * Synchronous access handles exist → the `opfs-sahpool` fast path is usable
257
+ * (iOS 16.4+, Chromium 108+). When false on an OPFS-capable engine we are on
258
+ * an older iOS/WebView and must use the async OPFS VFS.
259
+ */
260
+ syncAccessHandle: boolean;
261
+ /**
262
+ * `SharedArrayBuffer` is present *and* the context is cross-origin isolated.
263
+ * Required by the highest-performance sqlite-wasm mode; in a webview this is
264
+ * what `capacitor://localhost` + COOP/COEP unlocks (exploration 0238).
265
+ */
266
+ crossOriginIsolated: boolean;
267
+ /** Best durable backend this context supports. */
268
+ mode: OpfsPersistenceMode;
269
+ /** Human-readable explanation, useful for the iOS <16.4 async-fallback case. */
270
+ reason: string;
271
+ }
272
+ /**
273
+ * The slice of global APIs capability detection reads. Injectable so the
274
+ * shared (non-isolated) `unit` test pool can probe synthetic environments
275
+ * without mutating real globals.
276
+ */
277
+ interface OpfsCapabilityScope {
278
+ navigator?: {
279
+ storage?: {
280
+ getDirectory?: unknown;
281
+ };
282
+ } | undefined;
283
+ FileSystemSyncAccessHandle?: unknown;
284
+ FileSystemFileHandle?: {
285
+ prototype?: Record<string, unknown>;
286
+ } | undefined;
287
+ SharedArrayBuffer?: unknown;
288
+ crossOriginIsolated?: unknown;
289
+ }
290
+ /** True when the context exposes OPFS via `navigator.storage.getDirectory`. */
291
+ declare function supportsOpfs(scope?: OpfsCapabilityScope): boolean;
292
+ /**
293
+ * True when synchronous access handles are available — the gate for the
294
+ * `opfs-sahpool` fast path (iOS 16.4+, Chromium 108+). Checks both the global
295
+ * constructor and the `createSyncAccessHandle` method on the file-handle
296
+ * prototype, since engines have shipped one or the other.
297
+ */
298
+ declare function supportsSyncAccessHandle(scope?: OpfsCapabilityScope): boolean;
299
+ /**
300
+ * True when a `SharedArrayBuffer` can actually be used — present *and* the
301
+ * context is cross-origin isolated (the browser ungated SAB behind COI).
302
+ */
303
+ declare function isCrossOriginIsolated(scope?: OpfsCapabilityScope): boolean;
304
+ /**
305
+ * Report the best durable OPFS backend the given scope supports, with a reason.
306
+ * Pure and synchronous — safe to call before any sqlite-wasm import.
307
+ */
308
+ declare function detectOpfsCapability(scope?: OpfsCapabilityScope): OpfsCapability;
309
+
310
+ export { type DatabaseStats, type FTSSearchOptions, type FTSSearchResult, type IndexInfo, type OpfsCapability, type OpfsCapabilityScope, type OpfsPersistenceMode, type QueryPlanStep, SQLValue, SQLiteAdapter, type SQLiteRuntimeCapabilities, type TableStats, analyzeQuery, analyzeTable, buildBatchInsert, buildInsert, buildSelect, buildUpdate, checkIntegrity, deleteNodeFTS, detectOpfsCapability, detectSQLiteCapabilities, escapeLike, explainQuery, extractSearchableContent, extractTextFromTipTap, getAllTableStats, getDatabaseStats, getIndexInfo, isCrossOriginIsolated, isSQLiteCorruptionError, optimizeFTS, rebuildFTS, runAnalyze, searchNodes, supportsOpfs, supportsSyncAccessHandle, timeQuery, updateNodeFTS };