@lunarhue/react-native-web-wa-sqlite 1.0.9

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 (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +78 -0
  3. package/dist/wa-sqlite-async.mjs +16 -0
  4. package/dist/wa-sqlite-async.wasm +0 -0
  5. package/dist/wa-sqlite-jspi.mjs +16 -0
  6. package/dist/wa-sqlite-jspi.wasm +0 -0
  7. package/dist/wa-sqlite.mjs +16 -0
  8. package/dist/wa-sqlite.wasm +0 -0
  9. package/package.json +45 -0
  10. package/src/FacadeVFS.js +681 -0
  11. package/src/VFS.js +222 -0
  12. package/src/WebLocksMixin.js +411 -0
  13. package/src/examples/AccessHandlePoolVFS.js +458 -0
  14. package/src/examples/IDBBatchAtomicVFS.js +827 -0
  15. package/src/examples/IDBMirrorVFS.js +889 -0
  16. package/src/examples/MemoryAsyncVFS.js +100 -0
  17. package/src/examples/MemoryVFS.js +176 -0
  18. package/src/examples/OPFSAdaptiveVFS.js +437 -0
  19. package/src/examples/OPFSAnyContextVFS.js +300 -0
  20. package/src/examples/OPFSCoopSyncVFS.js +597 -0
  21. package/src/examples/OPFSPermutedVFS.js +1217 -0
  22. package/src/examples/README.md +89 -0
  23. package/src/examples/tag.js +82 -0
  24. package/src/sqlite-api.js +912 -0
  25. package/src/sqlite-constants.js +275 -0
  26. package/src/types/globals.d.ts +60 -0
  27. package/src/types/index.d.ts +1330 -0
  28. package/src/types/tsconfig.json +6 -0
  29. package/test/AccessHandlePoolVFS.test.js +27 -0
  30. package/test/IDBBatchAtomicVFS.test.js +97 -0
  31. package/test/IDBMirrorVFS.test.js +27 -0
  32. package/test/MemoryAsyncVFS.test.js +27 -0
  33. package/test/MemoryVFS.test.js +27 -0
  34. package/test/OPFSAdaptiveVFS.test.js +27 -0
  35. package/test/OPFSAnyContextVFS.test.js +27 -0
  36. package/test/OPFSCoopSyncVFS.test.js +27 -0
  37. package/test/OPFSPermutedVFS.test.js +27 -0
  38. package/test/TestContext.js +96 -0
  39. package/test/WebLocksMixin.test.js +521 -0
  40. package/test/api.test.js +49 -0
  41. package/test/api_exec.js +89 -0
  42. package/test/api_misc.js +63 -0
  43. package/test/api_statements.js +447 -0
  44. package/test/callbacks.test.js +581 -0
  45. package/test/sql.test.js +64 -0
  46. package/test/sql_0001.js +49 -0
  47. package/test/sql_0002.js +52 -0
  48. package/test/sql_0003.js +83 -0
  49. package/test/sql_0004.js +81 -0
  50. package/test/sql_0005.js +76 -0
  51. package/test/test-worker.js +204 -0
  52. package/test/vfs_xAccess.js +2 -0
  53. package/test/vfs_xClose.js +52 -0
  54. package/test/vfs_xOpen.js +91 -0
  55. package/test/vfs_xRead.js +38 -0
  56. package/test/vfs_xWrite.js +36 -0
@@ -0,0 +1,1330 @@
1
+ /**
2
+ * This is a WebAssembly build of SQLite with experimental support for
3
+ * writing SQLite virtual file systems and modules (for virtual tables)
4
+ * in Javascript. Also see the
5
+ * [GitHub repository](https://github.com/rhashimoto/wa-sqlite) and the
6
+ * [online demo](https://rhashimoto.github.io/wa-sqlite/demo/).
7
+ * @module
8
+ */
9
+
10
+ /**
11
+ * Javascript types that SQLite can use
12
+ *
13
+ * C integer and floating-point types both map to/from Javascript `number`.
14
+ * Blob data can be provided to SQLite as `Uint8Array` or `number[]` (with
15
+ * each element converted to a byte); SQLite always returns blob data as
16
+ * `Uint8Array`
17
+ */
18
+ type SQLiteCompatibleType = number|string|Uint8Array|Array<number>|bigint|null;
19
+
20
+ /**
21
+ * SQLite Virtual File System object
22
+ *
23
+ * Objects with this interface can be passed to {@link SQLiteAPI.vfs_register}
24
+ * to define a new filesystem.
25
+ *
26
+ * There are examples of a synchronous
27
+ * [MemoryVFS.js](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/MemoryVFS.js),
28
+ * and asynchronous
29
+ * [MemoryAsyncVFS.js](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/MemoryAsyncVFS.js)
30
+ * and
31
+ * [IndexedDbVFS.js](https://github.com/rhashimoto/wa-sqlite/blob/master/src/examples/IndexedDbVFS.js).
32
+ *
33
+ * @see https://sqlite.org/vfs.html
34
+ * @see https://sqlite.org/c3ref/io_methods.html
35
+ */
36
+ declare interface SQLiteVFS {
37
+ /** Maximum length of a file path in UTF-8 bytes (default 64) */
38
+ mxPathName?: number;
39
+
40
+ close(): void|Promise<void>;
41
+ isReady(): boolean|Promise<boolean>;
42
+
43
+ /** @see https://sqlite.org/c3ref/io_methods.html */
44
+ xClose(fileId: number): number|Promise<number>;
45
+
46
+ /** @see https://sqlite.org/c3ref/io_methods.html */
47
+ xRead(
48
+ fileId: number,
49
+ pData: number,
50
+ iAmt: number,
51
+ iOffsetLo: number,
52
+ iOffsetHi: number
53
+ ): number|Promise<number>;
54
+
55
+ /** @see https://sqlite.org/c3ref/io_methods.html */
56
+ xWrite(
57
+ fileId: number,
58
+ pData: number,
59
+ iAmt: number,
60
+ iOffsetLo: number,
61
+ iOffsetHi: number
62
+ ): number|Promise<number>;
63
+
64
+ /** @see https://sqlite.org/c3ref/io_methods.html */
65
+ xTruncate(fileId: number, iSizeLo: number, iSizeHi): number|Promise<number>;
66
+
67
+ /** @see https://sqlite.org/c3ref/io_methods.html */
68
+ xSync(fileId: number, flags: number): number|Promise<number>;
69
+
70
+ /** @see https://sqlite.org/c3ref/io_methods.html */
71
+ xFileSize(
72
+ fileId: number,
73
+ pSize64: number
74
+ ): number|Promise<number>;
75
+
76
+ /** @see https://sqlite.org/c3ref/io_methods.html */
77
+ xLock(fileId: number, flags: number): number|Promise<number>;
78
+
79
+ /** @see https://sqlite.org/c3ref/io_methods.html */
80
+ xUnlock(fileId: number, flags: number): number|Promise<number>;
81
+
82
+ /** @see https://sqlite.org/c3ref/io_methods.html */
83
+ xCheckReservedLock(
84
+ fileId: number,
85
+ pResOut: number
86
+ ): number|Promise<number>;
87
+
88
+ /** @see https://sqlite.org/c3ref/io_methods.html */
89
+ xFileControl(
90
+ fileId: number,
91
+ flags: number,
92
+ pOut: number
93
+ ): number|Promise<number>;
94
+
95
+ /** @see https://sqlite.org/c3ref/io_methods.html */
96
+ xDeviceCharacteristics(fileId: number): number|Promise<number>;
97
+
98
+ /** @see https://sqlite.org/c3ref/vfs.html */
99
+ xOpen(
100
+ pVfs: number,
101
+ zName: number,
102
+ pFile: number,
103
+ flags: number,
104
+ pOutFlags: number
105
+ ): number|Promise<number>;
106
+
107
+ /** @see https://sqlite.org/c3ref/vfs.html */
108
+ xDelete(pVfs: number, zName: number, syncDir: number): number|Promise<number>;
109
+
110
+ /** @see https://sqlite.org/c3ref/vfs.html */
111
+ xAccess(
112
+ pVfs: number,
113
+ zName: number,
114
+ flags: number,
115
+ pResOut: number
116
+ ): number|Promise<number>;
117
+ }
118
+
119
+ /**
120
+ * Options object argument for {@link SQLiteAPI.statements}
121
+ */
122
+ declare interface SQLitePrepareOptions {
123
+ /**
124
+ * Statement handles prepared and yielded by {@link SQLiteAPI.statements}
125
+ * are normally valid only within the scope of an iteration.
126
+ * Set `unscoped` to `true` to give iterated statements an arbitrary
127
+ * lifetime.
128
+ */
129
+ unscoped?: boolean;
130
+
131
+ /**
132
+ * SQLITE_PREPARE_* flags
133
+ * @see https://www.sqlite.org/c3ref/c_prepare_normalize.html#sqlitepreparepersistent
134
+ */
135
+ flags?: number;
136
+ }
137
+
138
+ /**
139
+ * Javascript wrappers for the SQLite C API (plus a few convenience functions)
140
+ *
141
+ * Function signatures have been slightly modified to be more
142
+ * Javascript-friendly. For the C functions that return an error code,
143
+ * the corresponding Javascript wrapper will throw an exception with a
144
+ * `code` property on an error.
145
+ *
146
+ * Note that a few functions return a Promise in order to accomodate
147
+ * either a synchronous or asynchronous SQLite build, generally those
148
+ * involved with opening/closing a database or executing a statement.
149
+ *
150
+ * To create an instance of the API, follow these steps:
151
+ *
152
+ * ```javascript
153
+ * // Import an ES6 module factory function from one of the
154
+ * // package builds, either 'wa-sqlite.mjs' (synchronous) or
155
+ * // 'wa-sqlite-async.mjs' (asynchronous). You should only
156
+ * // use the asynchronous build if you plan to use an
157
+ * // asynchronous VFS or module.
158
+ * import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
159
+ *
160
+ * // Import the Javascript API wrappers.
161
+ * import * as SQLite from 'wa-sqlite';
162
+ *
163
+ * // Use an async function to simplify Promise handling.
164
+ * (async function() {
165
+ * // Invoke the ES6 module factory to create the SQLite
166
+ * // Emscripten module. This will fetch and compile the
167
+ * // .wasm file.
168
+ * const module = await SQLiteESMFactory();
169
+ *
170
+ * // Use the module to build the API instance.
171
+ * const sqlite3 = SQLite.Factory(module);
172
+ *
173
+ * // Use the API to open and access a database.
174
+ * const db = await sqlite3.open_v2('myDB');
175
+ * ...
176
+ * })();
177
+ * ```
178
+ *
179
+ * @see https://sqlite.org/c3ref/funclist.html
180
+ */
181
+ declare interface SQLiteAPI {
182
+ /**
183
+ * Bind a collection of values to a statement
184
+ *
185
+ * This convenience function binds values from either an array or object
186
+ * to a prepared statement with placeholder parameters.
187
+ *
188
+ * Array example using numbered parameters (numbering is implicit in
189
+ * this example):
190
+ * ```
191
+ * const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
192
+ * for await (const stmt of sqlite3.statements(db, sql) {
193
+ * sqlite3.bind_collection(stmt, [42, 'hello', null]);
194
+ * ...
195
+ * }
196
+ * ```
197
+ *
198
+ * Object example using named parameters (':', '@', or '$' prefixes
199
+ * are allowed):
200
+ * ```
201
+ * const sql = 'INSERT INTO tbl VALUES (?, ?, ?)';
202
+ * for await (const stmt of sqlite3.statements(db, sql) {
203
+ * sqlite3.bind_collection(stmt, {
204
+ * '@foo': 42,
205
+ * '@bar': 'hello',
206
+ * '@baz': null,
207
+ * });
208
+ * ...
209
+ * }
210
+ * ```
211
+ *
212
+ * Note that SQLite bindings are indexed beginning with 1, but when
213
+ * binding values from an array `a` the values begin with `a[0]`.
214
+ * @param stmt prepared statement pointer
215
+ * @param bindings
216
+ * @returns `SQLITE_OK` (throws exception on error)
217
+ */
218
+ bind_collection(
219
+ stmt: number,
220
+ bindings: {[index: string]: SQLiteCompatibleType|null}|Array<SQLiteCompatibleType|null>
221
+ ): number;
222
+
223
+ /**
224
+ * Bind value to prepared statement
225
+ *
226
+ * This convenience function calls the appropriate `bind_*` function
227
+ * based on the type of `value`. Note that binding indices begin with 1.
228
+ * @param stmt prepared statement pointer
229
+ * @param i binding index
230
+ * @param value
231
+ * @returns `SQLITE_OK` (throws exception on error)
232
+ */
233
+ bind(stmt: number, i: number, value: SQLiteCompatibleType|null): number;
234
+
235
+ /**
236
+ * Bind blob to prepared statement parameter
237
+ *
238
+ * Note that binding indices begin with 1.
239
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
240
+ * @param stmt prepared statement pointer
241
+ * @param i binding index
242
+ * @param value
243
+ * @returns `SQLITE_OK` (throws exception on error)
244
+ */
245
+ bind_blob(stmt: number, i: number, value: Uint8Array|Array<number>): number;
246
+
247
+ /**
248
+ * Bind number to prepared statement parameter
249
+ *
250
+ * Note that binding indices begin with 1.
251
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
252
+ * @param stmt prepared statement pointer
253
+ * @param i binding index
254
+ * @param value
255
+ * @returns `SQLITE_OK` (throws exception on error)
256
+ */
257
+ bind_double(stmt: number, i: number, value: number): number;
258
+
259
+ /**
260
+ * Bind number to prepared statement parameter
261
+ *
262
+ * Note that binding indices begin with 1.
263
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
264
+ * @param stmt prepared statement pointer
265
+ * @param i binding index
266
+ * @param value
267
+ * @returns `SQLITE_OK` (throws exception on error)
268
+ */
269
+ bind_int(stmt: number, i: number, value: number): number;
270
+
271
+ /**
272
+ * Bind number to prepared statement parameter
273
+ *
274
+ * Note that binding indices begin with 1.
275
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
276
+ * @param stmt prepared statement pointer
277
+ * @param i binding index
278
+ * @param value
279
+ * @returns `SQLITE_OK` (throws exception on error)
280
+ */
281
+ bind_int64(stmt: number, i: number, value: bigint): number;
282
+
283
+ /**
284
+ * Bind null to prepared statement
285
+ *
286
+ * Note that binding indices begin with 1.
287
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
288
+ * @param stmt prepared statement pointer
289
+ * @param i binding index
290
+ * @returns `SQLITE_OK` (throws exception on error)
291
+ */
292
+ bind_null(stmt: number, i: number): number;
293
+
294
+ /**
295
+ * Get number of bound parameters
296
+ * @see https://www.sqlite.org/c3ref/bind_parameter_count.html
297
+ * @param stmt prepared statement pointer
298
+ * @returns number of statement binding locations
299
+ */
300
+ bind_parameter_count(stmt: number): number;
301
+
302
+ /**
303
+ * Get name of bound parameter
304
+ *
305
+ * Note that binding indices begin with 1.
306
+ * @see https://www.sqlite.org/c3ref/bind_parameter_name.html
307
+ * @param stmt prepared statement pointer
308
+ * @param i binding index
309
+ * @returns binding name
310
+ */
311
+ bind_parameter_name(stmt: number, i: number): string;
312
+
313
+ /**
314
+ * Bind string to prepared statement
315
+ *
316
+ * Note that binding indices begin with 1.
317
+ * @see https://www.sqlite.org/c3ref/bind_blob.html
318
+ * @param stmt prepared statement pointer
319
+ * @param i binding index
320
+ * @param value
321
+ * @returns `SQLITE_OK` (throws exception on error)
322
+ */
323
+ bind_text(stmt: number, i: number, value: string): number;
324
+
325
+ /**
326
+ * Get count of rows modified by last insert/update
327
+ * @see https://www.sqlite.org/c3ref/changes.html
328
+ * @param db database pointer
329
+ * @returns number of rows modified
330
+ */
331
+ changes(db): number;
332
+
333
+ /**
334
+ * Reset all bindings on a prepared statement.
335
+ * @see https://www.sqlite.org/c3ref/clear_bindings.html
336
+ * @param stmt prepared statement pointer
337
+ * @returns `SQLITE_OK` (throws exception on error)
338
+ */
339
+ clear_bindings(stmt: number): number;
340
+
341
+ /**
342
+ * Close database connection
343
+ * @see https://www.sqlite.org/c3ref/close.html
344
+ * @param db database pointer
345
+ * @returns `SQLITE_OK` (throws exception on error)
346
+ */
347
+ close(db): Promise<number>;
348
+
349
+ /**
350
+ * Call the appropriate `column_*` function based on the column type
351
+ *
352
+ * The type is determined by calling {@link column_type}, which may
353
+ * not match the type declared in `CREATE TABLE`. Note that if the column
354
+ * value is a blob then as with `column_blob` the result may be invalid
355
+ * after the next SQLite call; copy if it needs to be retained.
356
+ *
357
+ * Integer values are returned as Number if within the min/max safe
358
+ * integer bounds, otherwise they are returned as BigInt.
359
+ * @param stmt prepared statement pointer
360
+ * @param i column index
361
+ * @returns column value
362
+ */
363
+ column(stmt: number, i: number): SQLiteCompatibleType;
364
+
365
+ /**
366
+ * Extract a column value from a row after a prepared statment {@link step}
367
+ *
368
+ * The contents of the returned buffer may be invalid after the
369
+ * next SQLite call. Make a copy of the data (e.g. with `.slice()`)
370
+ * if longer retention is required.
371
+ * @see https://www.sqlite.org/c3ref/column_blob.html
372
+ * @param stmt prepared statement pointer
373
+ * @param i column index
374
+ * @returns column value
375
+ */
376
+ column_blob(stmt: number, i: number): Uint8Array;
377
+
378
+ /**
379
+ * Get storage size for column text or blob
380
+ * @see https://www.sqlite.org/c3ref/column_blob.html
381
+ * @param stmt prepared statement pointer
382
+ * @param i column index
383
+ * @returns number of bytes in column text or blob
384
+ */
385
+ column_bytes(stmt: number, i: number): number;
386
+
387
+ /**
388
+ * Get number of columns for a prepared statement
389
+ * @see https://www.sqlite.org/c3ref/column_blob.html
390
+ * @param stmt prepared statement pointer
391
+ * @returns number of columns
392
+ */
393
+ column_count(stmt: number): number;
394
+
395
+ /**
396
+ * Extract a column value from a row after a prepared statment {@link step}
397
+ * @see https://www.sqlite.org/c3ref/column_blob.html
398
+ * @param stmt prepared statement pointer
399
+ * @param i column index
400
+ * @returns column value
401
+ */
402
+ column_double(stmt: number, i: number): number;
403
+
404
+ /**
405
+ * Extract a column value from a row after a prepared statment {@link step}
406
+ * @see https://www.sqlite.org/c3ref/column_blob.html
407
+ * @param stmt prepared statement pointer
408
+ * @param i column index
409
+ * @returns column value
410
+ */
411
+ column_int(stmt: number, i: number): number;
412
+
413
+ /**
414
+ * Extract a column value from a row after a prepared statment {@link step}
415
+ * @see https://www.sqlite.org/c3ref/column_blob.html
416
+ * @param stmt prepared statement pointer
417
+ * @param i column index
418
+ * @returns column value
419
+ */
420
+ column_int64(stmt: number, i: number): bigint;
421
+
422
+ /**
423
+ * Get a column name for a prepared statement
424
+ * @see https://www.sqlite.org/c3ref/column_blob.html
425
+ * @param stmt prepared statement pointer
426
+ * @param i column index
427
+ * @returns column name
428
+ */
429
+ column_name(stmt: number, i: number): string;
430
+
431
+ /**
432
+ * Get names for all columns of a prepared statement
433
+ *
434
+ * This is a convenience function that calls {@link column_count} and
435
+ * {@link column_name}.
436
+ * @param stmt
437
+ * @returns array of column names
438
+ */
439
+ column_names(stmt: number): Array<string>;
440
+
441
+ /**
442
+ * Extract a column value from a row after a prepared statment {@link step}
443
+ * @see https://www.sqlite.org/c3ref/column_blob.html
444
+ * @param stmt prepared statement pointer
445
+ * @param i column index
446
+ * @returns column value
447
+ */
448
+ column_text(stmt: number, i: number): string;
449
+
450
+ /**
451
+ * Get column type for a prepared statement
452
+ *
453
+ * Note that this type may not match the type declared in `CREATE TABLE`.
454
+ * @see https://www.sqlite.org/c3ref/column_blob.html
455
+ * @param stmt prepared statement pointer
456
+ * @param i column index
457
+ * @returns enumeration value for type
458
+ */
459
+ column_type(stmt: number, i: number): number;
460
+
461
+ /**
462
+ * Register a commit hook
463
+ *
464
+ * @see https://www.sqlite.org/c3ref/commit_hook.html
465
+ *
466
+ * @param db database pointer
467
+ * @param callback If a non-zero value is returned, commit is converted into
468
+ * a rollback; disables callback when null
469
+ */
470
+ commit_hook(
471
+ db: number,
472
+ callback: (() => number) | null): void;
473
+
474
+ /**
475
+ * Create or redefine SQL functions
476
+ *
477
+ * The application data passed is ignored. Use closures instead.
478
+ *
479
+ * If any callback function returns a Promise, that function must
480
+ * be declared `async`, i.e. it must allow use of `await`.
481
+ * @see https://sqlite.org/c3ref/create_function.html
482
+ * @param db database pointer
483
+ * @param zFunctionName
484
+ * @param nArg number of function arguments
485
+ * @param eTextRep text encoding (and other flags)
486
+ * @param pApp application data (ignored)
487
+ * @param xFunc
488
+ * @param xStep
489
+ * @param xFinal
490
+ * @returns `SQLITE_OK` (throws exception on error)
491
+ */
492
+ create_function(
493
+ db: number,
494
+ zFunctionName: string,
495
+ nArg: number,
496
+ eTextRep: number,
497
+ pApp: number,
498
+ xFunc?: (context: number, values: Uint32Array) => void|Promise<void>,
499
+ xStep?: (context: number, values: Uint32Array) => void|Promise<void>,
500
+ xFinal?: (context: number) => void|Promise<void>): number;
501
+
502
+ /**
503
+ * Get number of columns in current row of a prepared statement
504
+ * @see https://www.sqlite.org/c3ref/data_count.html
505
+ * @param stmt prepared statement pointer
506
+ * @returns number of columns
507
+ */
508
+ data_count(stmt: number): number;
509
+
510
+ /**
511
+ * One-step query execution interface
512
+ *
513
+ * The implementation of this function uses {@link row}, which makes a
514
+ * copy of blobs and returns BigInt for integers outside the safe integer
515
+ * bounds for Number.
516
+ * @see https://www.sqlite.org/c3ref/exec.html
517
+ * @param db database pointer
518
+ * @param zSQL queries
519
+ * @param callback called for each output row
520
+ * @returns Promise resolving to `SQLITE_OK` (rejects on error)
521
+ */
522
+ exec(
523
+ db: number,
524
+ zSQL: string,
525
+ callback?: (row: Array<SQLiteCompatibleType|null>, columns: string[]) => void
526
+ ): Promise<number>;
527
+
528
+ /**
529
+ * Destroy a prepared statement object compiled by {@link statements}
530
+ * with the `unscoped` option set to `true`
531
+ *
532
+ * This function does *not* throw on error.
533
+ * @see https://www.sqlite.org/c3ref/finalize.html
534
+ * @param stmt prepared statement pointer
535
+ * @returns Promise resolving to `SQLITE_OK` or error status
536
+ */
537
+ finalize(stmt: number): Promise<number>;
538
+
539
+ /**
540
+ * Test for autocommit mode
541
+ * @see https://sqlite.org/c3ref/get_autocommit.html
542
+ * @param db database pointer
543
+ * @returns Non-zero if autocommit mode is on, zero otherwise
544
+ */
545
+ get_autocommit(db: number): number;
546
+
547
+ /**
548
+ * Get SQLite library version
549
+ * @see https://www.sqlite.org/c3ref/libversion.html
550
+ * @returns version string, e.g. '3.35.5'
551
+ */
552
+ libversion(): string;
553
+
554
+ /**
555
+ * Get SQLite library version
556
+ * @see https://www.sqlite.org/c3ref/libversion.html
557
+ * @returns version number, e.g. 3035005
558
+ */
559
+ libversion_number(): number
560
+
561
+ /**
562
+ * Set a usage limit on a connection.
563
+ * @see https://www.sqlite.org/c3ref/limit.html
564
+ * @param db database pointer
565
+ * @param id limit category
566
+ * @param newVal
567
+ * @returns previous setting
568
+ */
569
+ limit(
570
+ db: number,
571
+ id: number,
572
+ newVal: number): number;
573
+
574
+ /**
575
+ * Opening a new database connection.
576
+ *
577
+ * Note that this function differs from the C API in that it
578
+ * returns the Promise-wrapped database pointer (instead of a
579
+ * result code).
580
+ * @see https://sqlite.org/c3ref/open.html
581
+ * @param zFilename
582
+ * @param iFlags `SQLite.SQLITE_OPEN_CREATE | SQLite.SQLITE_OPEN_READWRITE` (0x6) if omitted
583
+ * @param zVfs VFS name
584
+ * @returns Promise-wrapped database pointer.
585
+ */
586
+ open_v2(
587
+ zFilename: string,
588
+ iFlags?: number,
589
+ zVfs?: string
590
+ ): Promise<number>;
591
+
592
+ /**
593
+ * Specify callback to be invoked between long-running queries
594
+ *
595
+ * The application data passed is ignored. Use closures instead.
596
+ *
597
+ * If any callback function returns a Promise, that function must
598
+ * be declared `async`, i.e. it must allow use of `await`.
599
+ * @param db database pointer
600
+ * @param nProgressOps target number of database operations between handler invocations
601
+ * @param handler
602
+ * @param userData
603
+ */
604
+ progress_handler(db: number, nProgressOps: number, handler: (userData: any) => number|Promise<number>, userData);
605
+
606
+ /**
607
+ * Reset a prepared statement object
608
+ * @see https://www.sqlite.org/c3ref/reset.html
609
+ * @param stmt prepared statement pointer
610
+ * @returns Promise-wrapped `SQLITE_OK` (rejects on error)
611
+ */
612
+ reset(stmt: number): Promise<number>;
613
+
614
+ /**
615
+ * Convenience function to call `result_*` based of the type of `value`
616
+ * @param context context pointer
617
+ * @param value
618
+ */
619
+ result(context: number, value: (SQLiteCompatibleType|number[])|null): void;
620
+
621
+ /**
622
+ * Set the result of a function or vtable column
623
+ * @see https://sqlite.org/c3ref/result_blob.html
624
+ * @param context context pointer
625
+ * @param value
626
+ */
627
+ result_blob(context: number, value: Uint8Array|number[]): void;
628
+
629
+ /**
630
+ * Set the result of a function or vtable column
631
+ * @see https://sqlite.org/c3ref/result_blob.html
632
+ * @param context context pointer
633
+ * @param value
634
+ */
635
+ result_double(context: number, value: number): void;
636
+
637
+ /**
638
+ * Set the result of a function or vtable column
639
+ * @see https://sqlite.org/c3ref/result_blob.html
640
+ * @param context context pointer
641
+ * @param value
642
+ */
643
+ result_int(context: number, value: number): void;
644
+
645
+ /**
646
+ * Set the result of a function or vtable column
647
+ * @see https://sqlite.org/c3ref/result_blob.html
648
+ * @param context context pointer
649
+ * @param value
650
+ */
651
+ result_int64(context: number, value: bigint): void;
652
+
653
+ /**
654
+ * Set the result of a function or vtable column
655
+ * @see https://sqlite.org/c3ref/result_blob.html
656
+ * @param context context pointer
657
+ */
658
+ result_null(context: number): void;
659
+
660
+ /**
661
+ * Set the result of a function or vtable column
662
+ * @see https://sqlite.org/c3ref/result_blob.html
663
+ * @param context context pointer
664
+ * @param value
665
+ */
666
+ result_text(context: number, value: string): void;
667
+
668
+ /**
669
+ * Get all column data for a row from a prepared statement step
670
+ *
671
+ * This convenience function will return a copy of any blob, unlike
672
+ * {@link column_blob} which returns a value referencing volatile WASM
673
+ * memory with short validity. Like {@link column}, it will return a
674
+ * BigInt for integers outside the safe integer bounds for Number.
675
+ * @param stmt prepared statement pointer
676
+ * @returns row data
677
+ */
678
+ row(stmt: number): Array<SQLiteCompatibleType|null>;
679
+
680
+ /**
681
+ * Register a callback function that is invoked to authorize certain SQL statement actions.
682
+ * @see https://www.sqlite.org/c3ref/set_authorizer.html
683
+ * @param db database pointer
684
+ * @param authFunction
685
+ * @param userData
686
+ */
687
+ set_authorizer(
688
+ db: number,
689
+ authFunction: (userData: any, iActionCode: number, param3: string|null, param4: string|null, param5: string|null, param6: string|null) => number|Promise<number>,
690
+ userData: any): number;
691
+
692
+ /**
693
+ * Get statement SQL
694
+ * @see https://www.sqlite.org/c3ref/expanded_sql.html
695
+ * @param stmt prepared statement pointer
696
+ * @returns SQL
697
+ */
698
+ sql(stmt: number): string;
699
+
700
+ /**
701
+ * SQL statement iterator
702
+ *
703
+ * This function manages statement compilation by creating an async
704
+ * iterator that yields a prepared statement handle on each iteration.
705
+ * It is typically used with a `for await` loop (in an async function),
706
+ * like this:
707
+ * ```javascript
708
+ * // Compile one statement on each iteration of this loop.
709
+ * for await (const stmt of sqlite3.statements(db, sql)) {
710
+ * // Bind parameters here if using SQLite placeholders.
711
+ *
712
+ * // Execute the statement with this loop.
713
+ * while (await sqlite3.step(stmt) === SQLite.SQLITE_ROW) {
714
+ * // Collect row data here.
715
+ * }
716
+ *
717
+ * // Change bindings, reset, and execute again if desired.
718
+ * }
719
+ * ```
720
+ *
721
+ * By default, the lifetime of a yielded prepared statement is managed
722
+ * automatically by the iterator, ending at the end of each iteration.
723
+ * {@link finalize} should *not* be called on a statement provided by
724
+ * the iterator unless the `unscoped` option is set to `true` (that
725
+ * option is provided for applications that wish to manage statement
726
+ * lifetimes manually).
727
+ *
728
+ * If using the iterator manually, i.e. by calling its `next`
729
+ * method, be sure to call the `return` method if iteration
730
+ * is abandoned before completion (`for await` and other implicit
731
+ * traversals provided by Javascript do this automatically)
732
+ * to ensure that all allocated resources are released.
733
+ * @see https://www.sqlite.org/c3ref/prepare.html
734
+ * @param db database pointer
735
+ * @param sql
736
+ * @param options
737
+ */
738
+ statements(db: number, sql: string, options?: SQLitePrepareOptions): AsyncIterable<number>;
739
+
740
+ /**
741
+ * Evaluate an SQL statement
742
+ * @see https://www.sqlite.org/c3ref/step.html
743
+ * @param stmt prepared statement pointer
744
+ * @returns Promise resolving to `SQLITE_ROW` or `SQLITE_DONE`
745
+ * (rejects on error)
746
+ */
747
+ step(stmt: number): Promise<number>;
748
+
749
+ /**
750
+ * Register an update hook
751
+ *
752
+ * The callback is invoked whenever a row is updated, inserted, or deleted
753
+ * in a rowid table on this connection.
754
+ * @see https://www.sqlite.org/c3ref/update_hook.html
755
+ *
756
+ * updateType is one of:
757
+ * - SQLITE_DELETE: 9
758
+ * - SQLITE_INSERT: 18
759
+ * - SQLITE_UPDATE: 23
760
+ * @see https://www.sqlite.org/c3ref/c_alter_table.html
761
+ *
762
+ * @param db database pointer
763
+ * @param callback
764
+ */
765
+ update_hook(
766
+ db: number,
767
+ callback: (updateType: number, dbName: string|null, tblName: string|null, rowid: bigint) => void): void;
768
+
769
+ /**
770
+ * Extract a value from `sqlite3_value`
771
+ *
772
+ * This is a convenience function that calls the appropriate `value_*`
773
+ * function based on its type. Note that if the value is a blob then as
774
+ * with `value_blob` the result may be invalid after the next SQLite call.
775
+ *
776
+ * Integer values are returned as Number if within the min/max safe
777
+ * integer bounds, otherwise they are returned as BigInt.
778
+ * @param pValue `sqlite3_value` pointer
779
+ * @returns value
780
+ */
781
+ value(pValue: number): SQLiteCompatibleType;
782
+
783
+ /**
784
+ * Extract a value from `sqlite3_value`
785
+ *
786
+ * The contents of the returned buffer may be invalid after the
787
+ * next SQLite call. Make a copy of the data (e.g. with `.slice()`)
788
+ * if longer retention is required.
789
+ * @see https://sqlite.org/c3ref/value_blob.html
790
+ * @param pValue `sqlite3_value` pointer
791
+ * @returns value
792
+ */
793
+ value_blob(pValue: number): Uint8Array;
794
+
795
+ /**
796
+ * Get blob or text size for value
797
+ * @see https://sqlite.org/c3ref/value_blob.html
798
+ * @param pValue `sqlite3_value` pointer
799
+ * @returns size
800
+ */
801
+ value_bytes(pValue: number): number;
802
+
803
+ /**
804
+ * Extract a value from `sqlite3_value`
805
+ * @see https://sqlite.org/c3ref/value_blob.html
806
+ * @param pValue `sqlite3_value` pointer
807
+ * @returns value
808
+ */
809
+ value_double(pValue: number): number;
810
+
811
+ /**
812
+ * Extract a value from `sqlite3_value`
813
+ * @see https://sqlite.org/c3ref/value_blob.html
814
+ * @param pValue `sqlite3_value` pointer
815
+ * @returns value
816
+ */
817
+ value_int(pValue: number): number;
818
+
819
+ /**
820
+ * Extract a value from `sqlite3_value`
821
+ * @see https://sqlite.org/c3ref/value_blob.html
822
+ * @param pValue `sqlite3_value` pointer
823
+ * @returns value
824
+ */
825
+ value_int64(pValue: number): bigint;
826
+
827
+ /**
828
+ * Extract a value from `sqlite3_value`
829
+ * @see https://sqlite.org/c3ref/value_blob.html
830
+ * @param pValue `sqlite3_value` pointer
831
+ * @returns value
832
+ */
833
+ value_text(pValue: number): string;
834
+
835
+ /**
836
+ * Get type of `sqlite3_value`
837
+ * @see https://sqlite.org/c3ref/value_blob.html
838
+ * @param pValue `sqlite3_value` pointer
839
+ * @returns enumeration value for type
840
+ */
841
+ value_type(pValue: number): number;
842
+
843
+ /**
844
+ * Register a new Virtual File System.
845
+ *
846
+ * @see https://www.sqlite.org/c3ref/vfs_find.html
847
+ * @param vfs VFS object
848
+ * @param makeDefault
849
+ * @returns `SQLITE_OK` (throws exception on error)
850
+ */
851
+ vfs_register(vfs: SQLiteVFS, makeDefault?: boolean): number;
852
+ }
853
+
854
+ /** @ignore */
855
+ declare module 'wa-sqlite/src/sqlite-constants.js' {
856
+ export const SQLITE_OK: 0;
857
+ export const SQLITE_ERROR: 1;
858
+ export const SQLITE_INTERNAL: 2;
859
+ export const SQLITE_PERM: 3;
860
+ export const SQLITE_ABORT: 4;
861
+ export const SQLITE_BUSY: 5;
862
+ export const SQLITE_LOCKED: 6;
863
+ export const SQLITE_NOMEM: 7;
864
+ export const SQLITE_READONLY: 8;
865
+ export const SQLITE_INTERRUPT: 9;
866
+ export const SQLITE_IOERR: 10;
867
+ export const SQLITE_CORRUPT: 11;
868
+ export const SQLITE_NOTFOUND: 12;
869
+ export const SQLITE_FULL: 13;
870
+ export const SQLITE_CANTOPEN: 14;
871
+ export const SQLITE_PROTOCOL: 15;
872
+ export const SQLITE_EMPTY: 16;
873
+ export const SQLITE_SCHEMA: 17;
874
+ export const SQLITE_TOOBIG: 18;
875
+ export const SQLITE_CONSTRAINT: 19;
876
+ export const SQLITE_MISMATCH: 20;
877
+ export const SQLITE_MISUSE: 21;
878
+ export const SQLITE_NOLFS: 22;
879
+ export const SQLITE_AUTH: 23;
880
+ export const SQLITE_FORMAT: 24;
881
+ export const SQLITE_RANGE: 25;
882
+ export const SQLITE_NOTADB: 26;
883
+ export const SQLITE_NOTICE: 27;
884
+ export const SQLITE_WARNING: 28;
885
+ export const SQLITE_ROW: 100;
886
+ export const SQLITE_DONE: 101;
887
+ export const SQLITE_IOERR_ACCESS: 3338;
888
+ export const SQLITE_IOERR_CHECKRESERVEDLOCK: 3594;
889
+ export const SQLITE_IOERR_CLOSE: 4106;
890
+ export const SQLITE_IOERR_DATA: 8202;
891
+ export const SQLITE_IOERR_DELETE: 2570;
892
+ export const SQLITE_IOERR_DELETE_NOENT: 5898;
893
+ export const SQLITE_IOERR_DIR_FSYNC: 1290;
894
+ export const SQLITE_IOERR_FSTAT: 1802;
895
+ export const SQLITE_IOERR_FSYNC: 1034;
896
+ export const SQLITE_IOERR_GETTEMPPATH: 6410;
897
+ export const SQLITE_IOERR_LOCK: 3850;
898
+ export const SQLITE_IOERR_NOMEM: 3082;
899
+ export const SQLITE_IOERR_READ: 266;
900
+ export const SQLITE_IOERR_RDLOCK: 2314;
901
+ export const SQLITE_IOERR_SEEK: 5642;
902
+ export const SQLITE_IOERR_SHORT_READ: 522;
903
+ export const SQLITE_IOERR_TRUNCATE: 1546;
904
+ export const SQLITE_IOERR_UNLOCK: 2058;
905
+ export const SQLITE_IOERR_VNODE: 6922;
906
+ export const SQLITE_IOERR_WRITE: 778;
907
+ export const SQLITE_IOERR_BEGIN_ATOMIC: 7434;
908
+ export const SQLITE_IOERR_COMMIT_ATOMIC: 7690;
909
+ export const SQLITE_IOERR_ROLLBACK_ATOMIC: 7946;
910
+ export const SQLITE_CONSTRAINT_CHECK: 275;
911
+ export const SQLITE_CONSTRAINT_COMMITHOOK: 531;
912
+ export const SQLITE_CONSTRAINT_FOREIGNKEY: 787;
913
+ export const SQLITE_CONSTRAINT_FUNCTION: 1043;
914
+ export const SQLITE_CONSTRAINT_NOTNULL: 1299;
915
+ export const SQLITE_CONSTRAINT_PINNED: 2835;
916
+ export const SQLITE_CONSTRAINT_PRIMARYKEY: 1555;
917
+ export const SQLITE_CONSTRAINT_ROWID: 2579;
918
+ export const SQLITE_CONSTRAINT_TRIGGER: 1811;
919
+ export const SQLITE_CONSTRAINT_UNIQUE: 2067;
920
+ export const SQLITE_CONSTRAINT_VTAB: 2323;
921
+ export const SQLITE_OPEN_READONLY: 1;
922
+ export const SQLITE_OPEN_READWRITE: 2;
923
+ export const SQLITE_OPEN_CREATE: 4;
924
+ export const SQLITE_OPEN_DELETEONCLOSE: 8;
925
+ export const SQLITE_OPEN_EXCLUSIVE: 16;
926
+ export const SQLITE_OPEN_AUTOPROXY: 32;
927
+ export const SQLITE_OPEN_URI: 64;
928
+ export const SQLITE_OPEN_MEMORY: 128;
929
+ export const SQLITE_OPEN_MAIN_DB: 256;
930
+ export const SQLITE_OPEN_TEMP_DB: 512;
931
+ export const SQLITE_OPEN_TRANSIENT_DB: 1024;
932
+ export const SQLITE_OPEN_MAIN_JOURNAL: 2048;
933
+ export const SQLITE_OPEN_TEMP_JOURNAL: 4096;
934
+ export const SQLITE_OPEN_SUBJOURNAL: 8192;
935
+ export const SQLITE_OPEN_SUPER_JOURNAL: 16384;
936
+ export const SQLITE_OPEN_NOMUTEX: 32768;
937
+ export const SQLITE_OPEN_FULLMUTEX: 65536;
938
+ export const SQLITE_OPEN_SHAREDCACHE: 131072;
939
+ export const SQLITE_OPEN_PRIVATECACHE: 262144;
940
+ export const SQLITE_OPEN_WAL: 524288;
941
+ export const SQLITE_OPEN_NOFOLLOW: 16777216;
942
+ export const SQLITE_LOCK_NONE: 0;
943
+ export const SQLITE_LOCK_SHARED: 1;
944
+ export const SQLITE_LOCK_RESERVED: 2;
945
+ export const SQLITE_LOCK_PENDING: 3;
946
+ export const SQLITE_LOCK_EXCLUSIVE: 4;
947
+ export const SQLITE_IOCAP_ATOMIC: 1;
948
+ export const SQLITE_IOCAP_ATOMIC512: 2;
949
+ export const SQLITE_IOCAP_ATOMIC1K: 4;
950
+ export const SQLITE_IOCAP_ATOMIC2K: 8;
951
+ export const SQLITE_IOCAP_ATOMIC4K: 16;
952
+ export const SQLITE_IOCAP_ATOMIC8K: 32;
953
+ export const SQLITE_IOCAP_ATOMIC16K: 64;
954
+ export const SQLITE_IOCAP_ATOMIC32K: 128;
955
+ export const SQLITE_IOCAP_ATOMIC64K: 256;
956
+ export const SQLITE_IOCAP_SAFE_APPEND: 512;
957
+ export const SQLITE_IOCAP_SEQUENTIAL: 1024;
958
+ export const SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN: 2048;
959
+ export const SQLITE_IOCAP_POWERSAFE_OVERWRITE: 4096;
960
+ export const SQLITE_IOCAP_IMMUTABLE: 8192;
961
+ export const SQLITE_IOCAP_BATCH_ATOMIC: 16384;
962
+ export const SQLITE_ACCESS_EXISTS: 0;
963
+ export const SQLITE_ACCESS_READWRITE: 1;
964
+ export const SQLITE_ACCESS_READ: 2;
965
+ export const SQLITE_FCNTL_LOCKSTATE: 1;
966
+ export const SQLITE_FCNTL_GET_LOCKPROXYFILE: 2;
967
+ export const SQLITE_FCNTL_SET_LOCKPROXYFILE: 3;
968
+ export const SQLITE_FCNTL_LAST_ERRNO: 4;
969
+ export const SQLITE_FCNTL_SIZE_HINT: 5;
970
+ export const SQLITE_FCNTL_CHUNK_SIZE: 6;
971
+ export const SQLITE_FCNTL_FILE_POINTER: 7;
972
+ export const SQLITE_FCNTL_SYNC_OMITTED: 8;
973
+ export const SQLITE_FCNTL_WIN32_AV_RETRY: 9;
974
+ export const SQLITE_FCNTL_PERSIST_WAL: 10;
975
+ export const SQLITE_FCNTL_OVERWRITE: 11;
976
+ export const SQLITE_FCNTL_VFSNAME: 12;
977
+ export const SQLITE_FCNTL_POWERSAFE_OVERWRITE: 13;
978
+ export const SQLITE_FCNTL_PRAGMA: 14;
979
+ export const SQLITE_FCNTL_BUSYHANDLER: 15;
980
+ export const SQLITE_FCNTL_TEMPFILENAME: 16;
981
+ export const SQLITE_FCNTL_MMAP_SIZE: 18;
982
+ export const SQLITE_FCNTL_TRACE: 19;
983
+ export const SQLITE_FCNTL_HAS_MOVED: 20;
984
+ export const SQLITE_FCNTL_SYNC: 21;
985
+ export const SQLITE_FCNTL_COMMIT_PHASETWO: 22;
986
+ export const SQLITE_FCNTL_WIN32_SET_HANDLE: 23;
987
+ export const SQLITE_FCNTL_WAL_BLOCK: 24;
988
+ export const SQLITE_FCNTL_ZIPVFS: 25;
989
+ export const SQLITE_FCNTL_RBU: 26;
990
+ export const SQLITE_FCNTL_VFS_POINTER: 27;
991
+ export const SQLITE_FCNTL_JOURNAL_POINTER: 28;
992
+ export const SQLITE_FCNTL_WIN32_GET_HANDLE: 29;
993
+ export const SQLITE_FCNTL_PDB: 30;
994
+ export const SQLITE_FCNTL_BEGIN_ATOMIC_WRITE: 31;
995
+ export const SQLITE_FCNTL_COMMIT_ATOMIC_WRITE: 32;
996
+ export const SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE: 33;
997
+ export const SQLITE_FCNTL_LOCK_TIMEOUT: 34;
998
+ export const SQLITE_FCNTL_DATA_VERSION: 35;
999
+ export const SQLITE_FCNTL_SIZE_LIMIT: 36;
1000
+ export const SQLITE_FCNTL_CKPT_DONE: 37;
1001
+ export const SQLITE_FCNTL_RESERVE_BYTES: 38;
1002
+ export const SQLITE_FCNTL_CKPT_START: 39;
1003
+ export const SQLITE_INTEGER: 1;
1004
+ export const SQLITE_FLOAT: 2;
1005
+ export const SQLITE_TEXT: 3;
1006
+ export const SQLITE_BLOB: 4;
1007
+ export const SQLITE_NULL: 5;
1008
+ export const SQLITE_STATIC: 0;
1009
+ export const SQLITE_TRANSIENT: -1;
1010
+ export const SQLITE_UTF8: 1;
1011
+ export const SQLITE_UTF16LE: 2;
1012
+ export const SQLITE_UTF16BE: 3;
1013
+ export const SQLITE_UTF16: 4;
1014
+ export const SQLITE_INDEX_CONSTRAINT_EQ: 2;
1015
+ export const SQLITE_INDEX_CONSTRAINT_GT: 4;
1016
+ export const SQLITE_INDEX_CONSTRAINT_LE: 8;
1017
+ export const SQLITE_INDEX_CONSTRAINT_LT: 16;
1018
+ export const SQLITE_INDEX_CONSTRAINT_GE: 32;
1019
+ export const SQLITE_INDEX_CONSTRAINT_MATCH: 64;
1020
+ export const SQLITE_INDEX_CONSTRAINT_LIKE: 65;
1021
+ export const SQLITE_INDEX_CONSTRAINT_GLOB: 66;
1022
+ export const SQLITE_INDEX_CONSTRAINT_REGEXP: 67;
1023
+ export const SQLITE_INDEX_CONSTRAINT_NE: 68;
1024
+ export const SQLITE_INDEX_CONSTRAINT_ISNOT: 69;
1025
+ export const SQLITE_INDEX_CONSTRAINT_ISNOTNULL: 70;
1026
+ export const SQLITE_INDEX_CONSTRAINT_ISNULL: 71;
1027
+ export const SQLITE_INDEX_CONSTRAINT_IS: 72;
1028
+ export const SQLITE_INDEX_CONSTRAINT_FUNCTION: 150;
1029
+ export const SQLITE_INDEX_SCAN_UNIQUE: 1;
1030
+ export const SQLITE_DETERMINISTIC: 0x000000800;
1031
+ export const SQLITE_DIRECTONLY: 0x000080000;
1032
+ export const SQLITE_SUBTYPE: 0x000100000;
1033
+ export const SQLITE_INNOCUOUS: 0x000200000;
1034
+ export const SQLITE_SYNC_NORMAL: 0x00002;
1035
+ export const SQLITE_SYNC_FULL: 0x00003;
1036
+ export const SQLITE_SYNC_DATAONLY: 0x00010;
1037
+ export const SQLITE_CREATE_INDEX: 1;
1038
+ export const SQLITE_CREATE_TABLE: 2;
1039
+ export const SQLITE_CREATE_TEMP_INDEX: 3;
1040
+ export const SQLITE_CREATE_TEMP_TABLE: 4;
1041
+ export const SQLITE_CREATE_TEMP_TRIGGER: 5;
1042
+ export const SQLITE_CREATE_TEMP_VIEW: 6;
1043
+ export const SQLITE_CREATE_TRIGGER: 7;
1044
+ export const SQLITE_CREATE_VIEW: 8;
1045
+ export const SQLITE_DELETE: 9;
1046
+ export const SQLITE_DROP_INDEX: 10;
1047
+ export const SQLITE_DROP_TABLE: 11;
1048
+ export const SQLITE_DROP_TEMP_INDEX: 12;
1049
+ export const SQLITE_DROP_TEMP_TABLE: 13;
1050
+ export const SQLITE_DROP_TEMP_TRIGGER: 14;
1051
+ export const SQLITE_DROP_TEMP_VIEW: 15;
1052
+ export const SQLITE_DROP_TRIGGER: 16;
1053
+ export const SQLITE_DROP_VIEW: 17;
1054
+ export const SQLITE_INSERT: 18;
1055
+ export const SQLITE_PRAGMA: 19;
1056
+ export const SQLITE_READ: 20;
1057
+ export const SQLITE_SELECT: 21;
1058
+ export const SQLITE_TRANSACTION: 22;
1059
+ export const SQLITE_UPDATE: 23;
1060
+ export const SQLITE_ATTACH: 24;
1061
+ export const SQLITE_DETACH: 25;
1062
+ export const SQLITE_ALTER_TABLE: 26;
1063
+ export const SQLITE_REINDEX: 27;
1064
+ export const SQLITE_ANALYZE: 28;
1065
+ export const SQLITE_CREATE_VTABLE: 29;
1066
+ export const SQLITE_DROP_VTABLE: 30;
1067
+ export const SQLITE_FUNCTION: 31;
1068
+ export const SQLITE_SAVEPOINT: 32;
1069
+ export const SQLITE_COPY: 0;
1070
+ export const SQLITE_RECURSIVE: 33;
1071
+ export const SQLITE_DENY: 1;
1072
+ export const SQLITE_IGNORE: 2;
1073
+ export const SQLITE_LIMIT_LENGTH: 0;
1074
+ export const SQLITE_LIMIT_SQL_LENGTH: 1;
1075
+ export const SQLITE_LIMIT_COLUMN: 2;
1076
+ export const SQLITE_LIMIT_EXPR_DEPTH: 3;
1077
+ export const SQLITE_LIMIT_COMPOUND_SELECT: 4;
1078
+ export const SQLITE_LIMIT_VDBE_OP: 5;
1079
+ export const SQLITE_LIMIT_FUNCTION_ARG: 6;
1080
+ export const SQLITE_LIMIT_ATTACHED: 7;
1081
+ export const SQLITE_LIMIT_LIKE_PATTERN_LENGTH: 8;
1082
+ export const SQLITE_LIMIT_VARIABLE_NUMBER: 9;
1083
+ export const SQLITE_LIMIT_TRIGGER_DEPTH: 10;
1084
+ export const SQLITE_LIMIT_WORKER_THREADS: 11;
1085
+ export const SQLITE_PREPARE_PERSISTENT: 0x01;
1086
+ export const SQLITE_PREPARE_NORMALIZED: 0x02;
1087
+ export const SQLITE_PREPARE_NO_VTAB: 0x04;
1088
+ }
1089
+
1090
+ declare module 'wa-sqlite' {
1091
+ export * from 'wa-sqlite/src/sqlite-constants.js';
1092
+
1093
+ /**
1094
+ * @ignore
1095
+ * Builds a Javascript API from the Emscripten module. This API is still
1096
+ * low-level and closely corresponds to the C API exported by the module,
1097
+ * but differs in some specifics like throwing exceptions on errors.
1098
+ * @param {*} Module SQLite module
1099
+ * @returns {SQLiteAPI}
1100
+ */
1101
+ export function Factory(Module: any): SQLiteAPI;
1102
+
1103
+ export class SQLiteError extends Error {
1104
+ constructor(message: any, code: any);
1105
+ code: any;
1106
+ }
1107
+ }
1108
+
1109
+ /** @ignore */
1110
+ declare module 'wa-sqlite/dist/wa-sqlite.mjs' {
1111
+ function ModuleFactory(config?: object): Promise<any>;
1112
+ export = ModuleFactory;
1113
+ }
1114
+
1115
+ /** @ignore */
1116
+ declare module 'wa-sqlite/dist/wa-sqlite-async.mjs' {
1117
+ function ModuleFactory(config?: object): Promise<any>;
1118
+ export = ModuleFactory;
1119
+ }
1120
+
1121
+ /** @ignore */
1122
+ declare module 'wa-sqlite/src/VFS.js' {
1123
+ export * from 'wa-sqlite/src/sqlite-constants.js';
1124
+
1125
+ export class Base {
1126
+ mxPathName: number;
1127
+ /**
1128
+ * @param {number} fileId
1129
+ * @returns {number|Promise<number>}
1130
+ */
1131
+ xClose(fileId: number): number;
1132
+ /**
1133
+ * @param {number} fileId
1134
+ * @param {Uint8Array} pData
1135
+ * @param {number} iOffset
1136
+ * @returns {number}
1137
+ */
1138
+ xRead(fileId: number, pData: {
1139
+ size: number;
1140
+ value: Uint8Array;
1141
+ }, iOffset: number): number;
1142
+ /**
1143
+ * @param {number} fileId
1144
+ * @param {Uint8Array} pData
1145
+ * @param {number} iOffset
1146
+ * @returns {number}
1147
+ */
1148
+ xWrite(fileId: number, pData: {
1149
+ size: number;
1150
+ value: Uint8Array;
1151
+ }, iOffset: number): number;
1152
+ /**
1153
+ * @param {number} fileId
1154
+ * @param {number} iSize
1155
+ * @returns {number}
1156
+ */
1157
+ xTruncate(fileId: number, iSize: number): number;
1158
+ /**
1159
+ * @param {number} fileId
1160
+ * @param {*} flags
1161
+ * @returns {number}
1162
+ */
1163
+ xSync(fileId: number, flags: any): number;
1164
+ /**
1165
+ * @param {number} fileId
1166
+ * @param {DataView} pSize64
1167
+ * @returns {number|Promise<number>}
1168
+ */
1169
+ xFileSize(fileId: number, pSize64: DataView): number;
1170
+ /**
1171
+ * @param {number} fileId
1172
+ * @param {number} flags
1173
+ * @returns {number}
1174
+ */
1175
+ xLock(fileId: number, flags: number): number;
1176
+ /**
1177
+ * @param {number} fileId
1178
+ * @param {number} flags
1179
+ * @returns {number}
1180
+ */
1181
+ xUnlock(fileId: number, flags: number): number;
1182
+ /**
1183
+ * @param {number} fileId
1184
+ * @param {DataView} pResOut
1185
+ * @returns {number}
1186
+ */
1187
+ xCheckReservedLock(fileId: number, pResOut: DataView): number;
1188
+ /**
1189
+ * @param {number} fileId
1190
+ * @param {number} flags
1191
+ * @param {DataView} pArg
1192
+ * @returns {number}
1193
+ */
1194
+ xFileControl(fileId: number, flags: number, pArg: DataView): number;
1195
+ /**
1196
+ * @param {number} fileId
1197
+ * @returns {number}
1198
+ */
1199
+ xSectorSize(fileId: number): number;
1200
+ /**
1201
+ * @param {number} fileId
1202
+ * @returns {number}
1203
+ */
1204
+ xDeviceCharacteristics(fileId: number): number;
1205
+ /**
1206
+ * @param {string?} name
1207
+ * @param {number} fileId
1208
+ * @param {number} flags
1209
+ * @param {DataView} pOutFlags
1210
+ * @returns {number}
1211
+ */
1212
+ xOpen(name: string | null, fileId: number, flags: number, pOutFlags: DataView): number;
1213
+ /**
1214
+ *
1215
+ * @param {string} name
1216
+ * @param {number} syncDir
1217
+ * @returns {number}
1218
+ */
1219
+ xDelete(name: string, syncDir: number): number;
1220
+ /**
1221
+ * @param {string} name
1222
+ * @param {number} flags
1223
+ * @param {DataView} pResOut
1224
+ * @returns {number}
1225
+ */
1226
+ xAccess(name: string, flags: number, pResOut: DataView): number;
1227
+ /**
1228
+ * Handle asynchronous operation. This implementation will be overriden on
1229
+ * registration by an Asyncify build.
1230
+ * @param {function(): Promise<number>} f
1231
+ * @returns {number}
1232
+ */
1233
+ handleAsync(f: () => Promise<number>): number;
1234
+ }
1235
+ }
1236
+
1237
+ /** @ignore */
1238
+ declare module 'wa-sqlite/src/examples/IndexedDbVFS.js' {
1239
+ import * as VFS from "wa-sqlite/src/VFS.js";
1240
+ export class IndexedDbVFS extends VFS.Base {
1241
+ /**
1242
+ * @param {string} idbName Name of IndexedDB database.
1243
+ */
1244
+ constructor(idbName?: string);
1245
+ name: string;
1246
+ mapIdToFile: Map<any, any>;
1247
+ cacheSize: number;
1248
+ db: any;
1249
+ close(): Promise<void>;
1250
+ /**
1251
+ * Delete a file from IndexedDB.
1252
+ * @param {string} name
1253
+ */
1254
+ deleteFile(name: string): Promise<void>;
1255
+ /**
1256
+ * Forcibly clear an orphaned file lock.
1257
+ * @param {string} name
1258
+ */
1259
+ forceClearLock(name: string): Promise<void>;
1260
+ _getStore(mode?: string): any;
1261
+ /**
1262
+ * Returns the key for file metadata.
1263
+ * @param {string} name
1264
+ * @returns
1265
+ */
1266
+ _metaKey(name: string): string;
1267
+ /**
1268
+ * Returns the key for file block data.
1269
+ * @param {string} name
1270
+ * @param {number} index
1271
+ * @returns
1272
+ */
1273
+ _blockKey(name: string, index: number): string;
1274
+ _getBlock(store: any, file: any, index: any): Promise<any>;
1275
+ _putBlock(store: any, file: any, index: any, blockData: any): void;
1276
+ _purgeCache(store: any, file: any, size?: number): void;
1277
+ _flushCache(store: any, file: any): Promise<void>;
1278
+ _sync(file: any): Promise<void>;
1279
+ /**
1280
+ * Helper function that deletes all keys greater or equal to `key`
1281
+ * provided they start with `prefix`.
1282
+ * @param {string} key
1283
+ * @param {string} [prefix]
1284
+ * @returns
1285
+ */
1286
+ _delete(key: string, prefix?: string): Promise<any>;
1287
+ }
1288
+ }
1289
+
1290
+ /** @ignore */
1291
+ declare module 'wa-sqlite/src/examples/MemoryVFS.js' {
1292
+ import * as VFS from "wa-sqlite/src/VFS.js";
1293
+ /** @ignore */
1294
+ export class MemoryVFS extends VFS.Base {
1295
+ name: string;
1296
+ mapNameToFile: Map<any, any>;
1297
+ mapIdToFile: Map<any, any>;
1298
+ }
1299
+ }
1300
+
1301
+ /** @ignore */
1302
+ declare module 'wa-sqlite/src/examples/MemoryAsyncVFS.js' {
1303
+ import { MemoryVFS } from "wa-sqlite/src/examples/MemoryVFS.js";
1304
+ export class MemoryAsyncVFS extends MemoryVFS {
1305
+ }
1306
+ }
1307
+
1308
+ /** @ignore */
1309
+ declare module 'wa-sqlite/src/examples/tag.js' {
1310
+ /**
1311
+ * @ignore
1312
+ * Template tag builder. This function creates a tag with an API and
1313
+ * database from the same module, then the tag can be used like this:
1314
+ * ```
1315
+ * const sql = tag(sqlite3, db);
1316
+ * const results = await sql`
1317
+ * SELECT 1 + 1;
1318
+ * SELECT 6 * 7;
1319
+ * `;
1320
+ * ```
1321
+ * The returned Promise value contains an array of results for each
1322
+ * SQL statement that produces output. Each result is an object with
1323
+ * properties `columns` (array of names) and `rows` (array of array
1324
+ * of values).
1325
+ * @param {SQLiteAPI} sqlite3
1326
+ * @param {number} db
1327
+ * @returns {function(TemplateStringsArray, ...any): Promise<object[]>}
1328
+ */
1329
+ export function tag(sqlite3: any, db: number): (arg0: TemplateStringsArray, ...args: any[]) => Promise<object[]>;
1330
+ }