@livestore/wa-sqlite 1.0.1-dev.0 → 1.0.1-dev.2
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/package.json +1 -1
- package/src/sqlite-api.js +12 -0
- package/src/types/globals.d.ts +3 -3
- package/src/types/index.d.ts +39 -18
package/package.json
CHANGED
package/src/sqlite-api.js
CHANGED
|
@@ -237,6 +237,18 @@ export function Factory(Module) {
|
|
|
237
237
|
};
|
|
238
238
|
})();
|
|
239
239
|
|
|
240
|
+
sqlite3.deserialize = (function() {
|
|
241
|
+
const fname = 'sqlite3_deserialize';
|
|
242
|
+
const f = Module.cwrap(fname, ...decl('nnnnnn:n'));
|
|
243
|
+
return function(db, schema, data, szDb, szBuf, flags) {
|
|
244
|
+
verifyDatabase(db);
|
|
245
|
+
const ptr = Module._sqlite3_malloc(szDb);
|
|
246
|
+
Module.HEAPU8.subarray(ptr).set(data);
|
|
247
|
+
const result = f(db, schema, ptr, szDb, szBuf, flags);
|
|
248
|
+
return result;
|
|
249
|
+
};
|
|
250
|
+
})();
|
|
251
|
+
|
|
240
252
|
sqlite3.clear_bindings = (function() {
|
|
241
253
|
const fname = 'sqlite3_clear_bindings';
|
|
242
254
|
const f = Module.cwrap(fname, ...decl('n:n'));
|
package/src/types/globals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
declare namespace Asyncify {
|
|
2
|
-
|
|
3
|
-
}
|
|
1
|
+
// declare namespace Asyncify {
|
|
2
|
+
// function handleAsync(f: () => Promise<any>);
|
|
3
|
+
// }
|
|
4
4
|
|
|
5
5
|
declare function UTF8ToString(ptr: number): string;
|
|
6
6
|
declare function lengthBytesUTF8(s: string): number;
|
package/src/types/index.d.ts
CHANGED
|
@@ -151,14 +151,14 @@ declare interface SQLitePrepareOptions {
|
|
|
151
151
|
*
|
|
152
152
|
* ```javascript
|
|
153
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
|
|
154
|
+
* // package builds, either '@livestore/wa-sqlite.mjs' (synchronous) or
|
|
155
|
+
* // '@livestore/wa-sqlite-async.mjs' (asynchronous). You should only
|
|
156
156
|
* // use the asynchronous build if you plan to use an
|
|
157
157
|
* // asynchronous VFS or module.
|
|
158
|
-
* import SQLiteESMFactory from 'wa-sqlite/dist/wa-sqlite.mjs';
|
|
158
|
+
* import SQLiteESMFactory from '@livestore/wa-sqlite/dist/wa-sqlite.mjs';
|
|
159
159
|
*
|
|
160
160
|
* // Import the Javascript API wrappers.
|
|
161
|
-
* import * as SQLite from 'wa-sqlite';
|
|
161
|
+
* import * as SQLite from '@livestore/wa-sqlite';
|
|
162
162
|
*
|
|
163
163
|
* // Use an async function to simplify Promise handling.
|
|
164
164
|
* (async function() {
|
|
@@ -330,6 +330,27 @@ declare interface SQLiteAPI {
|
|
|
330
330
|
*/
|
|
331
331
|
changes(db): number;
|
|
332
332
|
|
|
333
|
+
/**
|
|
334
|
+
* https://www.sqlite.org/c3ref/deserialize.html
|
|
335
|
+
* int sqlite3_deserialize(
|
|
336
|
+
* sqlite3 *db, The database connection
|
|
337
|
+
* const char *zSchema, Which DB to reopen with the deserialization
|
|
338
|
+
* unsigned char *pData, The serialized database content
|
|
339
|
+
* sqlite3_int64 szDb, Number bytes in the deserialization
|
|
340
|
+
* sqlite3_int64 szBuf, Total size of buffer pData[]
|
|
341
|
+
* unsigned mFlags Zero or more SQLITE_DESERIALIZE_* flags
|
|
342
|
+
* );
|
|
343
|
+
*/
|
|
344
|
+
|
|
345
|
+
deserialize(
|
|
346
|
+
db: number,
|
|
347
|
+
zSchema: string,
|
|
348
|
+
pData: Uint8Array,
|
|
349
|
+
szDb: number,
|
|
350
|
+
szBuf: number,
|
|
351
|
+
mFlags: number
|
|
352
|
+
): number;
|
|
353
|
+
|
|
333
354
|
/**
|
|
334
355
|
* Reset all bindings on a prepared statement.
|
|
335
356
|
* @see https://www.sqlite.org/c3ref/clear_bindings.html
|
|
@@ -823,7 +844,7 @@ declare interface SQLiteAPI {
|
|
|
823
844
|
}
|
|
824
845
|
|
|
825
846
|
/** @ignore */
|
|
826
|
-
declare module 'wa-sqlite/src/sqlite-constants.js' {
|
|
847
|
+
declare module '@livestore/wa-sqlite/src/sqlite-constants.js' {
|
|
827
848
|
export const SQLITE_OK: 0;
|
|
828
849
|
export const SQLITE_ERROR: 1;
|
|
829
850
|
export const SQLITE_INTERNAL: 2;
|
|
@@ -1058,8 +1079,8 @@ declare module 'wa-sqlite/src/sqlite-constants.js' {
|
|
|
1058
1079
|
export const SQLITE_PREPARE_NO_VTAB: 0x04;
|
|
1059
1080
|
}
|
|
1060
1081
|
|
|
1061
|
-
declare module 'wa-sqlite' {
|
|
1062
|
-
export * from 'wa-sqlite/src/sqlite-constants.js';
|
|
1082
|
+
declare module '@livestore/wa-sqlite' {
|
|
1083
|
+
export * from '@livestore/wa-sqlite/src/sqlite-constants.js';
|
|
1063
1084
|
|
|
1064
1085
|
/**
|
|
1065
1086
|
* @ignore
|
|
@@ -1078,20 +1099,20 @@ declare module 'wa-sqlite' {
|
|
|
1078
1099
|
}
|
|
1079
1100
|
|
|
1080
1101
|
/** @ignore */
|
|
1081
|
-
declare module 'wa-sqlite/dist/wa-sqlite.mjs' {
|
|
1102
|
+
declare module '@livestore/wa-sqlite/dist/wa-sqlite.mjs' {
|
|
1082
1103
|
function ModuleFactory(config?: object): Promise<any>;
|
|
1083
1104
|
export = ModuleFactory;
|
|
1084
1105
|
}
|
|
1085
1106
|
|
|
1086
1107
|
/** @ignore */
|
|
1087
|
-
declare module 'wa-sqlite/dist/wa-sqlite-async.mjs' {
|
|
1108
|
+
declare module '@livestore/wa-sqlite/dist/wa-sqlite-async.mjs' {
|
|
1088
1109
|
function ModuleFactory(config?: object): Promise<any>;
|
|
1089
1110
|
export = ModuleFactory;
|
|
1090
1111
|
}
|
|
1091
1112
|
|
|
1092
1113
|
/** @ignore */
|
|
1093
|
-
declare module 'wa-sqlite/src/VFS.js' {
|
|
1094
|
-
export * from 'wa-sqlite/src/sqlite-constants.js';
|
|
1114
|
+
declare module '@livestore/wa-sqlite/src/VFS.js' {
|
|
1115
|
+
export * from '@livestore/wa-sqlite/src/sqlite-constants.js';
|
|
1095
1116
|
|
|
1096
1117
|
export class Base {
|
|
1097
1118
|
mxPathName: number;
|
|
@@ -1206,8 +1227,8 @@ declare module 'wa-sqlite/src/VFS.js' {
|
|
|
1206
1227
|
}
|
|
1207
1228
|
|
|
1208
1229
|
/** @ignore */
|
|
1209
|
-
declare module 'wa-sqlite/src/examples/IndexedDbVFS.js' {
|
|
1210
|
-
import * as VFS from "wa-sqlite/src/VFS.js";
|
|
1230
|
+
declare module '@livestore/wa-sqlite/src/examples/IndexedDbVFS.js' {
|
|
1231
|
+
import * as VFS from "@livestore/wa-sqlite/src/VFS.js";
|
|
1211
1232
|
export class IndexedDbVFS extends VFS.Base {
|
|
1212
1233
|
/**
|
|
1213
1234
|
* @param {string} idbName Name of IndexedDB database.
|
|
@@ -1260,8 +1281,8 @@ declare module 'wa-sqlite/src/examples/IndexedDbVFS.js' {
|
|
|
1260
1281
|
}
|
|
1261
1282
|
|
|
1262
1283
|
/** @ignore */
|
|
1263
|
-
declare module 'wa-sqlite/src/examples/MemoryVFS.js' {
|
|
1264
|
-
import * as VFS from "wa-sqlite/src/VFS.js";
|
|
1284
|
+
declare module '@livestore/wa-sqlite/src/examples/MemoryVFS.js' {
|
|
1285
|
+
import * as VFS from "@livestore/wa-sqlite/src/VFS.js";
|
|
1265
1286
|
/** @ignore */
|
|
1266
1287
|
export class MemoryVFS extends VFS.Base {
|
|
1267
1288
|
name: string;
|
|
@@ -1271,14 +1292,14 @@ declare module 'wa-sqlite/src/examples/MemoryVFS.js' {
|
|
|
1271
1292
|
}
|
|
1272
1293
|
|
|
1273
1294
|
/** @ignore */
|
|
1274
|
-
declare module 'wa-sqlite/src/examples/MemoryAsyncVFS.js' {
|
|
1275
|
-
import { MemoryVFS } from "wa-sqlite/src/examples/MemoryVFS.js";
|
|
1295
|
+
declare module '@livestore/wa-sqlite/src/examples/MemoryAsyncVFS.js' {
|
|
1296
|
+
import { MemoryVFS } from "@livestore/wa-sqlite/src/examples/MemoryVFS.js";
|
|
1276
1297
|
export class MemoryAsyncVFS extends MemoryVFS {
|
|
1277
1298
|
}
|
|
1278
1299
|
}
|
|
1279
1300
|
|
|
1280
1301
|
/** @ignore */
|
|
1281
|
-
declare module 'wa-sqlite/src/examples/tag.js' {
|
|
1302
|
+
declare module '@livestore/wa-sqlite/src/examples/tag.js' {
|
|
1282
1303
|
/**
|
|
1283
1304
|
* @ignore
|
|
1284
1305
|
* Template tag builder. This function creates a tag with an API and
|