@peerbit/indexer-sqlite3 1.2.21 → 1.2.22-7ce8142
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/dist/peerbit/sqlite3-bundler-friendly.mjs +82 -22
- package/dist/peerbit/sqlite3-node.mjs +14 -8
- package/dist/peerbit/sqlite3.js +82 -22
- package/dist/peerbit/sqlite3.min.js +71 -18
- package/dist/peerbit/sqlite3.mjs +82 -22
- package/dist/peerbit/sqlite3.wasm +0 -0
- package/dist/peerbit/sqlite3.worker.min.js +71 -18
- package/package.json +78 -78
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
/*
|
|
27
27
|
** This code was built from sqlite3 version...
|
|
28
28
|
**
|
|
29
|
-
** SQLITE_VERSION "3.
|
|
30
|
-
** SQLITE_VERSION_NUMBER
|
|
31
|
-
** SQLITE_SOURCE_ID "2025-
|
|
29
|
+
** SQLITE_VERSION "3.50.1"
|
|
30
|
+
** SQLITE_VERSION_NUMBER 3050001
|
|
31
|
+
** SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
|
|
32
32
|
**
|
|
33
33
|
** Using the Emscripten SDK version 3.1.70.
|
|
34
34
|
*/
|
|
@@ -10051,7 +10051,7 @@ var sqlite3InitModule = (() => {
|
|
|
10051
10051
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
10052
10052
|
toss('Usage error: target object is-not-a StructType.');
|
|
10053
10053
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
10054
|
-
toss('Usage
|
|
10054
|
+
toss('Usage error: expecting a Function or WASM pointer to one.');
|
|
10055
10055
|
}
|
|
10056
10056
|
if (1 === arguments.length) {
|
|
10057
10057
|
return (n, f) => callee(tgt, n, f, applyArgcCheck);
|
|
@@ -10165,11 +10165,11 @@ var sqlite3InitModule = (() => {
|
|
|
10165
10165
|
|
|
10166
10166
|
globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
|
|
10167
10167
|
sqlite3.version = {
|
|
10168
|
-
libVersion: '3.
|
|
10169
|
-
libVersionNumber:
|
|
10168
|
+
libVersion: '3.50.1',
|
|
10169
|
+
libVersionNumber: 3050001,
|
|
10170
10170
|
sourceId:
|
|
10171
|
-
'2025-
|
|
10172
|
-
downloadVersion:
|
|
10171
|
+
'2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95',
|
|
10172
|
+
downloadVersion: 3500100,
|
|
10173
10173
|
};
|
|
10174
10174
|
});
|
|
10175
10175
|
|
|
@@ -11536,6 +11536,12 @@ var sqlite3InitModule = (() => {
|
|
|
11536
11536
|
rc.changeCount =
|
|
11537
11537
|
db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
11538
11538
|
}
|
|
11539
|
+
const lastInsertRowId = !!rc.lastInsertRowId
|
|
11540
|
+
? sqlite3.capi.sqlite3_last_insert_rowid(db)
|
|
11541
|
+
: undefined;
|
|
11542
|
+
if (undefined !== lastInsertRowId) {
|
|
11543
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
11544
|
+
}
|
|
11539
11545
|
if (rc.callback instanceof Function) {
|
|
11540
11546
|
rc.callback = theCallback;
|
|
11541
11547
|
|
|
@@ -13007,7 +13013,7 @@ var sqlite3InitModule = (() => {
|
|
|
13007
13013
|
capi.SQLITE_OPEN_MAIN_JOURNAL |
|
|
13008
13014
|
capi.SQLITE_OPEN_SUPER_JOURNAL |
|
|
13009
13015
|
capi.SQLITE_OPEN_WAL;
|
|
13010
|
-
|
|
13016
|
+
const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
|
|
13011
13017
|
const OPAQUE_DIR_NAME = '.opaque';
|
|
13012
13018
|
|
|
13013
13019
|
const getRandomName = () => Math.random().toString(36).slice(2);
|
|
@@ -13237,6 +13243,7 @@ var sqlite3InitModule = (() => {
|
|
|
13237
13243
|
xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
|
|
13238
13244
|
const pool = getPoolForVfs(pVfs);
|
|
13239
13245
|
try {
|
|
13246
|
+
flags &= ~FLAG_COMPUTE_DIGEST_V2;
|
|
13240
13247
|
pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
|
|
13241
13248
|
|
|
13242
13249
|
const path =
|
|
@@ -13385,8 +13392,7 @@ var sqlite3InitModule = (() => {
|
|
|
13385
13392
|
|
|
13386
13393
|
getFileNames() {
|
|
13387
13394
|
const rc = [];
|
|
13388
|
-
const
|
|
13389
|
-
for (const n of iter) rc.push(n);
|
|
13395
|
+
for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
|
|
13390
13396
|
return rc;
|
|
13391
13397
|
}
|
|
13392
13398
|
|
|
@@ -13427,7 +13433,7 @@ var sqlite3InitModule = (() => {
|
|
|
13427
13433
|
this.#availableSAH.clear();
|
|
13428
13434
|
}
|
|
13429
13435
|
|
|
13430
|
-
async acquireAccessHandles(clearFiles) {
|
|
13436
|
+
async acquireAccessHandles(clearFiles = false) {
|
|
13431
13437
|
const files = [];
|
|
13432
13438
|
for await (const [name, h] of this.#dhOpaque) {
|
|
13433
13439
|
if ('file' === h.kind) {
|
|
@@ -13478,12 +13484,14 @@ var sqlite3InitModule = (() => {
|
|
|
13478
13484
|
|
|
13479
13485
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
|
13480
13486
|
sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
|
|
13481
|
-
const compDigest = this.computeDigest(this.#apBody);
|
|
13487
|
+
const compDigest = this.computeDigest(this.#apBody, flags);
|
|
13488
|
+
|
|
13482
13489
|
if (fileDigest.every((v, i) => v === compDigest[i])) {
|
|
13483
13490
|
const pathBytes = this.#apBody.findIndex((v) => 0 === v);
|
|
13484
13491
|
if (0 === pathBytes) {
|
|
13485
13492
|
sah.truncate(HEADER_OFFSET_DATA);
|
|
13486
13493
|
}
|
|
13494
|
+
|
|
13487
13495
|
return pathBytes
|
|
13488
13496
|
? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
|
|
13489
13497
|
: '';
|
|
@@ -13499,10 +13507,13 @@ var sqlite3InitModule = (() => {
|
|
|
13499
13507
|
if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
|
|
13500
13508
|
toss('Path too long:', path);
|
|
13501
13509
|
}
|
|
13510
|
+
if (path && flags) {
|
|
13511
|
+
flags |= FLAG_COMPUTE_DIGEST_V2;
|
|
13512
|
+
}
|
|
13502
13513
|
this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
|
|
13503
13514
|
this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
13515
|
+
const digest = this.computeDigest(this.#apBody, flags);
|
|
13504
13516
|
|
|
13505
|
-
const digest = this.computeDigest(this.#apBody);
|
|
13506
13517
|
sah.write(this.#apBody, { at: 0 });
|
|
13507
13518
|
sah.write(digest, { at: HEADER_OFFSET_DIGEST });
|
|
13508
13519
|
sah.flush();
|
|
@@ -13516,14 +13527,18 @@ var sqlite3InitModule = (() => {
|
|
|
13516
13527
|
}
|
|
13517
13528
|
}
|
|
13518
13529
|
|
|
13519
|
-
computeDigest(byteArray) {
|
|
13520
|
-
|
|
13521
|
-
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13530
|
+
computeDigest(byteArray, fileFlags) {
|
|
13531
|
+
if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
|
|
13532
|
+
let h1 = 0xdeadbeef;
|
|
13533
|
+
let h2 = 0x41c6ce57;
|
|
13534
|
+
for (const v of byteArray) {
|
|
13535
|
+
h1 = Math.imul(h1 ^ v, 2654435761);
|
|
13536
|
+
h2 = Math.imul(h2 ^ v, 104729);
|
|
13537
|
+
}
|
|
13538
|
+
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13539
|
+
} else {
|
|
13540
|
+
return new Uint32Array([0, 0]);
|
|
13525
13541
|
}
|
|
13526
|
-
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13527
13542
|
}
|
|
13528
13543
|
|
|
13529
13544
|
async reset(clearFiles) {
|
|
@@ -13620,11 +13635,45 @@ var sqlite3InitModule = (() => {
|
|
|
13620
13635
|
});
|
|
13621
13636
|
this.#dhVfsRoot = this.#dhVfsParent = undefined;
|
|
13622
13637
|
} catch (e) {
|
|
13623
|
-
sqlite3.config.error(
|
|
13638
|
+
sqlite3.config.error(
|
|
13639
|
+
this.vfsName,
|
|
13640
|
+
'removeVfs() failed with no recovery strategy:',
|
|
13641
|
+
e,
|
|
13642
|
+
);
|
|
13624
13643
|
}
|
|
13625
13644
|
return true;
|
|
13626
13645
|
}
|
|
13627
13646
|
|
|
13647
|
+
pauseVfs() {
|
|
13648
|
+
if (this.#mapS3FileToOFile_.size > 0) {
|
|
13649
|
+
sqlite3.SQLite3Error.toss(
|
|
13650
|
+
capi.SQLITE_MISUSE,
|
|
13651
|
+
'Cannot pause VFS',
|
|
13652
|
+
this.vfsName,
|
|
13653
|
+
'because it has opened files.',
|
|
13654
|
+
);
|
|
13655
|
+
}
|
|
13656
|
+
if (this.#mapSAHToName.size > 0) {
|
|
13657
|
+
capi.sqlite3_vfs_unregister(this.vfsName);
|
|
13658
|
+
this.releaseAccessHandles();
|
|
13659
|
+
}
|
|
13660
|
+
return this;
|
|
13661
|
+
}
|
|
13662
|
+
|
|
13663
|
+
isPaused() {
|
|
13664
|
+
return 0 === this.#mapSAHToName.size;
|
|
13665
|
+
}
|
|
13666
|
+
|
|
13667
|
+
async unpauseVfs() {
|
|
13668
|
+
if (0 === this.#mapSAHToName.size) {
|
|
13669
|
+
return this.acquireAccessHandles(false).then(
|
|
13670
|
+
() => capi.sqlite3_vfs_register(this.#cVfs, 0),
|
|
13671
|
+
this,
|
|
13672
|
+
);
|
|
13673
|
+
}
|
|
13674
|
+
return this;
|
|
13675
|
+
}
|
|
13676
|
+
|
|
13628
13677
|
exportFile(name) {
|
|
13629
13678
|
const sah =
|
|
13630
13679
|
this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
|
|
@@ -13769,6 +13818,17 @@ var sqlite3InitModule = (() => {
|
|
|
13769
13818
|
async removeVfs() {
|
|
13770
13819
|
return this.#p.removeVfs();
|
|
13771
13820
|
}
|
|
13821
|
+
|
|
13822
|
+
pauseVfs() {
|
|
13823
|
+
this.#p.pauseVfs();
|
|
13824
|
+
return this;
|
|
13825
|
+
}
|
|
13826
|
+
async unpauseVfs() {
|
|
13827
|
+
return this.#p.unpauseVfs().then(() => this);
|
|
13828
|
+
}
|
|
13829
|
+
isPaused() {
|
|
13830
|
+
return this.#p.isPaused();
|
|
13831
|
+
}
|
|
13772
13832
|
}
|
|
13773
13833
|
|
|
13774
13834
|
const apiVersionCheck = async () => {
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
/*
|
|
27
27
|
** This code was built from sqlite3 version...
|
|
28
28
|
**
|
|
29
|
-
** SQLITE_VERSION "3.
|
|
30
|
-
** SQLITE_VERSION_NUMBER
|
|
31
|
-
** SQLITE_SOURCE_ID "2025-
|
|
29
|
+
** SQLITE_VERSION "3.50.1"
|
|
30
|
+
** SQLITE_VERSION_NUMBER 3050001
|
|
31
|
+
** SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
|
|
32
32
|
**
|
|
33
33
|
** Using the Emscripten SDK version 3.1.70.
|
|
34
34
|
*/
|
|
@@ -10071,7 +10071,7 @@ var sqlite3InitModule = (() => {
|
|
|
10071
10071
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
10072
10072
|
toss('Usage error: target object is-not-a StructType.');
|
|
10073
10073
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
10074
|
-
toss('Usage
|
|
10074
|
+
toss('Usage error: expecting a Function or WASM pointer to one.');
|
|
10075
10075
|
}
|
|
10076
10076
|
if (1 === arguments.length) {
|
|
10077
10077
|
return (n, f) => callee(tgt, n, f, applyArgcCheck);
|
|
@@ -10185,11 +10185,11 @@ var sqlite3InitModule = (() => {
|
|
|
10185
10185
|
|
|
10186
10186
|
globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
|
|
10187
10187
|
sqlite3.version = {
|
|
10188
|
-
libVersion: '3.
|
|
10189
|
-
libVersionNumber:
|
|
10188
|
+
libVersion: '3.50.1',
|
|
10189
|
+
libVersionNumber: 3050001,
|
|
10190
10190
|
sourceId:
|
|
10191
|
-
'2025-
|
|
10192
|
-
downloadVersion:
|
|
10191
|
+
'2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95',
|
|
10192
|
+
downloadVersion: 3500100,
|
|
10193
10193
|
};
|
|
10194
10194
|
});
|
|
10195
10195
|
|
|
@@ -11556,6 +11556,12 @@ var sqlite3InitModule = (() => {
|
|
|
11556
11556
|
rc.changeCount =
|
|
11557
11557
|
db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
11558
11558
|
}
|
|
11559
|
+
const lastInsertRowId = !!rc.lastInsertRowId
|
|
11560
|
+
? sqlite3.capi.sqlite3_last_insert_rowid(db)
|
|
11561
|
+
: undefined;
|
|
11562
|
+
if (undefined !== lastInsertRowId) {
|
|
11563
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
11564
|
+
}
|
|
11559
11565
|
if (rc.callback instanceof Function) {
|
|
11560
11566
|
rc.callback = theCallback;
|
|
11561
11567
|
|
package/dist/peerbit/sqlite3.js
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
/*
|
|
27
27
|
** This code was built from sqlite3 version...
|
|
28
28
|
**
|
|
29
|
-
** SQLITE_VERSION "3.
|
|
30
|
-
** SQLITE_VERSION_NUMBER
|
|
31
|
-
** SQLITE_SOURCE_ID "2025-
|
|
29
|
+
** SQLITE_VERSION "3.50.1"
|
|
30
|
+
** SQLITE_VERSION_NUMBER 3050001
|
|
31
|
+
** SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
|
|
32
32
|
**
|
|
33
33
|
** Using the Emscripten SDK version 3.1.70.
|
|
34
34
|
*/
|
|
@@ -10077,7 +10077,7 @@ var sqlite3InitModule = (() => {
|
|
|
10077
10077
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
10078
10078
|
toss('Usage error: target object is-not-a StructType.');
|
|
10079
10079
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
10080
|
-
toss('Usage
|
|
10080
|
+
toss('Usage error: expecting a Function or WASM pointer to one.');
|
|
10081
10081
|
}
|
|
10082
10082
|
if (1 === arguments.length) {
|
|
10083
10083
|
return (n, f) => callee(tgt, n, f, applyArgcCheck);
|
|
@@ -10191,11 +10191,11 @@ var sqlite3InitModule = (() => {
|
|
|
10191
10191
|
|
|
10192
10192
|
globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
|
|
10193
10193
|
sqlite3.version = {
|
|
10194
|
-
libVersion: '3.
|
|
10195
|
-
libVersionNumber:
|
|
10194
|
+
libVersion: '3.50.1',
|
|
10195
|
+
libVersionNumber: 3050001,
|
|
10196
10196
|
sourceId:
|
|
10197
|
-
'2025-
|
|
10198
|
-
downloadVersion:
|
|
10197
|
+
'2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95',
|
|
10198
|
+
downloadVersion: 3500100,
|
|
10199
10199
|
};
|
|
10200
10200
|
});
|
|
10201
10201
|
|
|
@@ -11562,6 +11562,12 @@ var sqlite3InitModule = (() => {
|
|
|
11562
11562
|
rc.changeCount =
|
|
11563
11563
|
db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
11564
11564
|
}
|
|
11565
|
+
const lastInsertRowId = !!rc.lastInsertRowId
|
|
11566
|
+
? sqlite3.capi.sqlite3_last_insert_rowid(db)
|
|
11567
|
+
: undefined;
|
|
11568
|
+
if (undefined !== lastInsertRowId) {
|
|
11569
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
11570
|
+
}
|
|
11565
11571
|
if (rc.callback instanceof Function) {
|
|
11566
11572
|
rc.callback = theCallback;
|
|
11567
11573
|
|
|
@@ -13031,7 +13037,7 @@ var sqlite3InitModule = (() => {
|
|
|
13031
13037
|
capi.SQLITE_OPEN_MAIN_JOURNAL |
|
|
13032
13038
|
capi.SQLITE_OPEN_SUPER_JOURNAL |
|
|
13033
13039
|
capi.SQLITE_OPEN_WAL;
|
|
13034
|
-
|
|
13040
|
+
const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
|
|
13035
13041
|
const OPAQUE_DIR_NAME = '.opaque';
|
|
13036
13042
|
|
|
13037
13043
|
const getRandomName = () => Math.random().toString(36).slice(2);
|
|
@@ -13261,6 +13267,7 @@ var sqlite3InitModule = (() => {
|
|
|
13261
13267
|
xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
|
|
13262
13268
|
const pool = getPoolForVfs(pVfs);
|
|
13263
13269
|
try {
|
|
13270
|
+
flags &= ~FLAG_COMPUTE_DIGEST_V2;
|
|
13264
13271
|
pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
|
|
13265
13272
|
|
|
13266
13273
|
const path =
|
|
@@ -13409,8 +13416,7 @@ var sqlite3InitModule = (() => {
|
|
|
13409
13416
|
|
|
13410
13417
|
getFileNames() {
|
|
13411
13418
|
const rc = [];
|
|
13412
|
-
const
|
|
13413
|
-
for (const n of iter) rc.push(n);
|
|
13419
|
+
for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
|
|
13414
13420
|
return rc;
|
|
13415
13421
|
}
|
|
13416
13422
|
|
|
@@ -13451,7 +13457,7 @@ var sqlite3InitModule = (() => {
|
|
|
13451
13457
|
this.#availableSAH.clear();
|
|
13452
13458
|
}
|
|
13453
13459
|
|
|
13454
|
-
async acquireAccessHandles(clearFiles) {
|
|
13460
|
+
async acquireAccessHandles(clearFiles = false) {
|
|
13455
13461
|
const files = [];
|
|
13456
13462
|
for await (const [name, h] of this.#dhOpaque) {
|
|
13457
13463
|
if ('file' === h.kind) {
|
|
@@ -13502,12 +13508,14 @@ var sqlite3InitModule = (() => {
|
|
|
13502
13508
|
|
|
13503
13509
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
|
13504
13510
|
sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
|
|
13505
|
-
const compDigest = this.computeDigest(this.#apBody);
|
|
13511
|
+
const compDigest = this.computeDigest(this.#apBody, flags);
|
|
13512
|
+
|
|
13506
13513
|
if (fileDigest.every((v, i) => v === compDigest[i])) {
|
|
13507
13514
|
const pathBytes = this.#apBody.findIndex((v) => 0 === v);
|
|
13508
13515
|
if (0 === pathBytes) {
|
|
13509
13516
|
sah.truncate(HEADER_OFFSET_DATA);
|
|
13510
13517
|
}
|
|
13518
|
+
|
|
13511
13519
|
return pathBytes
|
|
13512
13520
|
? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
|
|
13513
13521
|
: '';
|
|
@@ -13523,10 +13531,13 @@ var sqlite3InitModule = (() => {
|
|
|
13523
13531
|
if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
|
|
13524
13532
|
toss('Path too long:', path);
|
|
13525
13533
|
}
|
|
13534
|
+
if (path && flags) {
|
|
13535
|
+
flags |= FLAG_COMPUTE_DIGEST_V2;
|
|
13536
|
+
}
|
|
13526
13537
|
this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
|
|
13527
13538
|
this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
13539
|
+
const digest = this.computeDigest(this.#apBody, flags);
|
|
13528
13540
|
|
|
13529
|
-
const digest = this.computeDigest(this.#apBody);
|
|
13530
13541
|
sah.write(this.#apBody, { at: 0 });
|
|
13531
13542
|
sah.write(digest, { at: HEADER_OFFSET_DIGEST });
|
|
13532
13543
|
sah.flush();
|
|
@@ -13540,14 +13551,18 @@ var sqlite3InitModule = (() => {
|
|
|
13540
13551
|
}
|
|
13541
13552
|
}
|
|
13542
13553
|
|
|
13543
|
-
computeDigest(byteArray) {
|
|
13544
|
-
|
|
13545
|
-
|
|
13546
|
-
|
|
13547
|
-
|
|
13548
|
-
|
|
13554
|
+
computeDigest(byteArray, fileFlags) {
|
|
13555
|
+
if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
|
|
13556
|
+
let h1 = 0xdeadbeef;
|
|
13557
|
+
let h2 = 0x41c6ce57;
|
|
13558
|
+
for (const v of byteArray) {
|
|
13559
|
+
h1 = Math.imul(h1 ^ v, 2654435761);
|
|
13560
|
+
h2 = Math.imul(h2 ^ v, 104729);
|
|
13561
|
+
}
|
|
13562
|
+
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13563
|
+
} else {
|
|
13564
|
+
return new Uint32Array([0, 0]);
|
|
13549
13565
|
}
|
|
13550
|
-
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13551
13566
|
}
|
|
13552
13567
|
|
|
13553
13568
|
async reset(clearFiles) {
|
|
@@ -13644,11 +13659,45 @@ var sqlite3InitModule = (() => {
|
|
|
13644
13659
|
});
|
|
13645
13660
|
this.#dhVfsRoot = this.#dhVfsParent = undefined;
|
|
13646
13661
|
} catch (e) {
|
|
13647
|
-
sqlite3.config.error(
|
|
13662
|
+
sqlite3.config.error(
|
|
13663
|
+
this.vfsName,
|
|
13664
|
+
'removeVfs() failed with no recovery strategy:',
|
|
13665
|
+
e,
|
|
13666
|
+
);
|
|
13648
13667
|
}
|
|
13649
13668
|
return true;
|
|
13650
13669
|
}
|
|
13651
13670
|
|
|
13671
|
+
pauseVfs() {
|
|
13672
|
+
if (this.#mapS3FileToOFile_.size > 0) {
|
|
13673
|
+
sqlite3.SQLite3Error.toss(
|
|
13674
|
+
capi.SQLITE_MISUSE,
|
|
13675
|
+
'Cannot pause VFS',
|
|
13676
|
+
this.vfsName,
|
|
13677
|
+
'because it has opened files.',
|
|
13678
|
+
);
|
|
13679
|
+
}
|
|
13680
|
+
if (this.#mapSAHToName.size > 0) {
|
|
13681
|
+
capi.sqlite3_vfs_unregister(this.vfsName);
|
|
13682
|
+
this.releaseAccessHandles();
|
|
13683
|
+
}
|
|
13684
|
+
return this;
|
|
13685
|
+
}
|
|
13686
|
+
|
|
13687
|
+
isPaused() {
|
|
13688
|
+
return 0 === this.#mapSAHToName.size;
|
|
13689
|
+
}
|
|
13690
|
+
|
|
13691
|
+
async unpauseVfs() {
|
|
13692
|
+
if (0 === this.#mapSAHToName.size) {
|
|
13693
|
+
return this.acquireAccessHandles(false).then(
|
|
13694
|
+
() => capi.sqlite3_vfs_register(this.#cVfs, 0),
|
|
13695
|
+
this,
|
|
13696
|
+
);
|
|
13697
|
+
}
|
|
13698
|
+
return this;
|
|
13699
|
+
}
|
|
13700
|
+
|
|
13652
13701
|
exportFile(name) {
|
|
13653
13702
|
const sah =
|
|
13654
13703
|
this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
|
|
@@ -13793,6 +13842,17 @@ var sqlite3InitModule = (() => {
|
|
|
13793
13842
|
async removeVfs() {
|
|
13794
13843
|
return this.#p.removeVfs();
|
|
13795
13844
|
}
|
|
13845
|
+
|
|
13846
|
+
pauseVfs() {
|
|
13847
|
+
this.#p.pauseVfs();
|
|
13848
|
+
return this;
|
|
13849
|
+
}
|
|
13850
|
+
async unpauseVfs() {
|
|
13851
|
+
return this.#p.unpauseVfs().then(() => this);
|
|
13852
|
+
}
|
|
13853
|
+
isPaused() {
|
|
13854
|
+
return this.#p.isPaused();
|
|
13855
|
+
}
|
|
13796
13856
|
}
|
|
13797
13857
|
|
|
13798
13858
|
const apiVersionCheck = async () => {
|
|
@@ -17840,7 +17840,7 @@ var sqlite3InitModule = (() => {
|
|
|
17840
17840
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
17841
17841
|
toss("Usage error: target object is-not-a StructType.");
|
|
17842
17842
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
17843
|
-
toss("Usage
|
|
17843
|
+
toss("Usage error: expecting a Function or WASM pointer to one.");
|
|
17844
17844
|
}
|
|
17845
17845
|
if (1 === arguments.length) {
|
|
17846
17846
|
return (n, f) => callee2(tgt, n, f, applyArgcCheck);
|
|
@@ -17930,10 +17930,10 @@ var sqlite3InitModule = (() => {
|
|
|
17930
17930
|
});
|
|
17931
17931
|
globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite32) {
|
|
17932
17932
|
sqlite32.version = {
|
|
17933
|
-
libVersion: "3.
|
|
17934
|
-
libVersionNumber:
|
|
17935
|
-
sourceId: "2025-
|
|
17936
|
-
downloadVersion:
|
|
17933
|
+
libVersion: "3.50.1",
|
|
17934
|
+
libVersionNumber: 3050001,
|
|
17935
|
+
sourceId: "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95",
|
|
17936
|
+
downloadVersion: 3500100
|
|
17937
17937
|
};
|
|
17938
17938
|
});
|
|
17939
17939
|
globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite32) {
|
|
@@ -19099,6 +19099,10 @@ var sqlite3InitModule = (() => {
|
|
|
19099
19099
|
if (void 0 !== changeCount) {
|
|
19100
19100
|
rc.changeCount = db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
19101
19101
|
}
|
|
19102
|
+
const lastInsertRowId = !!rc.lastInsertRowId ? sqlite33.capi.sqlite3_last_insert_rowid(db) : void 0;
|
|
19103
|
+
if (void 0 !== lastInsertRowId) {
|
|
19104
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
19105
|
+
}
|
|
19102
19106
|
if (rc.callback instanceof Function) {
|
|
19103
19107
|
rc.callback = theCallback;
|
|
19104
19108
|
wState.post({
|
|
@@ -20391,6 +20395,7 @@ var sqlite3InitModule = (() => {
|
|
|
20391
20395
|
const HEADER_OFFSET_DIGEST = HEADER_CORPUS_SIZE;
|
|
20392
20396
|
const HEADER_OFFSET_DATA = SECTOR_SIZE;
|
|
20393
20397
|
const PERSISTENT_FILE_TYPES = capi.SQLITE_OPEN_MAIN_DB | capi.SQLITE_OPEN_MAIN_JOURNAL | capi.SQLITE_OPEN_SUPER_JOURNAL | capi.SQLITE_OPEN_WAL;
|
|
20398
|
+
const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
|
|
20394
20399
|
const OPAQUE_DIR_NAME = ".opaque";
|
|
20395
20400
|
const getRandomName = () => Math.random().toString(36).slice(2);
|
|
20396
20401
|
const textDecoder = new TextDecoder();
|
|
@@ -20606,6 +20611,7 @@ var sqlite3InitModule = (() => {
|
|
|
20606
20611
|
xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
|
|
20607
20612
|
const pool = getPoolForVfs(pVfs);
|
|
20608
20613
|
try {
|
|
20614
|
+
flags &= ~FLAG_COMPUTE_DIGEST_V2;
|
|
20609
20615
|
pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
|
|
20610
20616
|
const path = zName && wasm.peek8(zName) ? pool.getPath(zName) : getRandomName();
|
|
20611
20617
|
let sah = pool.getSAHForPath(path);
|
|
@@ -20726,8 +20732,7 @@ var sqlite3InitModule = (() => {
|
|
|
20726
20732
|
}
|
|
20727
20733
|
getFileNames() {
|
|
20728
20734
|
const rc = [];
|
|
20729
|
-
const
|
|
20730
|
-
for (const n of iter) rc.push(n);
|
|
20735
|
+
for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
|
|
20731
20736
|
return rc;
|
|
20732
20737
|
}
|
|
20733
20738
|
async addCapacity(n) {
|
|
@@ -20763,7 +20768,7 @@ var sqlite3InitModule = (() => {
|
|
|
20763
20768
|
this.#mapFilenameToSAH.clear();
|
|
20764
20769
|
this.#availableSAH.clear();
|
|
20765
20770
|
}
|
|
20766
|
-
async acquireAccessHandles(clearFiles) {
|
|
20771
|
+
async acquireAccessHandles(clearFiles = false) {
|
|
20767
20772
|
const files = [];
|
|
20768
20773
|
for await (const [name, h] of this.#dhOpaque) {
|
|
20769
20774
|
if ("file" === h.kind) {
|
|
@@ -20807,7 +20812,7 @@ var sqlite3InitModule = (() => {
|
|
|
20807
20812
|
}
|
|
20808
20813
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
|
20809
20814
|
sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
|
|
20810
|
-
const compDigest = this.computeDigest(this.#apBody);
|
|
20815
|
+
const compDigest = this.computeDigest(this.#apBody, flags);
|
|
20811
20816
|
if (fileDigest.every((v2, i) => v2 === compDigest[i])) {
|
|
20812
20817
|
const pathBytes = this.#apBody.findIndex((v2) => 0 === v2);
|
|
20813
20818
|
if (0 === pathBytes) {
|
|
@@ -20825,9 +20830,12 @@ var sqlite3InitModule = (() => {
|
|
|
20825
20830
|
if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
|
|
20826
20831
|
toss("Path too long:", path);
|
|
20827
20832
|
}
|
|
20833
|
+
if (path && flags) {
|
|
20834
|
+
flags |= FLAG_COMPUTE_DIGEST_V2;
|
|
20835
|
+
}
|
|
20828
20836
|
this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
|
|
20829
20837
|
this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
20830
|
-
const digest = this.computeDigest(this.#apBody);
|
|
20838
|
+
const digest = this.computeDigest(this.#apBody, flags);
|
|
20831
20839
|
sah.write(this.#apBody, { at: 0 });
|
|
20832
20840
|
sah.write(digest, { at: HEADER_OFFSET_DIGEST });
|
|
20833
20841
|
sah.flush();
|
|
@@ -20839,14 +20847,18 @@ var sqlite3InitModule = (() => {
|
|
|
20839
20847
|
this.#availableSAH.add(sah);
|
|
20840
20848
|
}
|
|
20841
20849
|
}
|
|
20842
|
-
computeDigest(byteArray) {
|
|
20843
|
-
|
|
20844
|
-
|
|
20845
|
-
|
|
20846
|
-
|
|
20847
|
-
|
|
20850
|
+
computeDigest(byteArray, fileFlags) {
|
|
20851
|
+
if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
|
|
20852
|
+
let h1 = 3735928559;
|
|
20853
|
+
let h2 = 1103547991;
|
|
20854
|
+
for (const v2 of byteArray) {
|
|
20855
|
+
h1 = Math.imul(h1 ^ v2, 2654435761);
|
|
20856
|
+
h2 = Math.imul(h2 ^ v2, 104729);
|
|
20857
|
+
}
|
|
20858
|
+
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
20859
|
+
} else {
|
|
20860
|
+
return new Uint32Array([0, 0]);
|
|
20848
20861
|
}
|
|
20849
|
-
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
20850
20862
|
}
|
|
20851
20863
|
async reset(clearFiles) {
|
|
20852
20864
|
await this.isReady;
|
|
@@ -20930,10 +20942,41 @@ var sqlite3InitModule = (() => {
|
|
|
20930
20942
|
});
|
|
20931
20943
|
this.#dhVfsRoot = this.#dhVfsParent = void 0;
|
|
20932
20944
|
} catch (e) {
|
|
20933
|
-
sqlite32.config.error(
|
|
20945
|
+
sqlite32.config.error(
|
|
20946
|
+
this.vfsName,
|
|
20947
|
+
"removeVfs() failed with no recovery strategy:",
|
|
20948
|
+
e
|
|
20949
|
+
);
|
|
20934
20950
|
}
|
|
20935
20951
|
return true;
|
|
20936
20952
|
}
|
|
20953
|
+
pauseVfs() {
|
|
20954
|
+
if (this.#mapS3FileToOFile_.size > 0) {
|
|
20955
|
+
sqlite32.SQLite3Error.toss(
|
|
20956
|
+
capi.SQLITE_MISUSE,
|
|
20957
|
+
"Cannot pause VFS",
|
|
20958
|
+
this.vfsName,
|
|
20959
|
+
"because it has opened files."
|
|
20960
|
+
);
|
|
20961
|
+
}
|
|
20962
|
+
if (this.#mapSAHToName.size > 0) {
|
|
20963
|
+
capi.sqlite3_vfs_unregister(this.vfsName);
|
|
20964
|
+
this.releaseAccessHandles();
|
|
20965
|
+
}
|
|
20966
|
+
return this;
|
|
20967
|
+
}
|
|
20968
|
+
isPaused() {
|
|
20969
|
+
return 0 === this.#mapSAHToName.size;
|
|
20970
|
+
}
|
|
20971
|
+
async unpauseVfs() {
|
|
20972
|
+
if (0 === this.#mapSAHToName.size) {
|
|
20973
|
+
return this.acquireAccessHandles(false).then(
|
|
20974
|
+
() => capi.sqlite3_vfs_register(this.#cVfs, 0),
|
|
20975
|
+
this
|
|
20976
|
+
);
|
|
20977
|
+
}
|
|
20978
|
+
return this;
|
|
20979
|
+
}
|
|
20937
20980
|
exportFile(name) {
|
|
20938
20981
|
const sah = this.#mapFilenameToSAH.get(name) || toss("File not found:", name);
|
|
20939
20982
|
const n = sah.getSize() - HEADER_OFFSET_DATA;
|
|
@@ -21054,6 +21097,16 @@ var sqlite3InitModule = (() => {
|
|
|
21054
21097
|
async removeVfs() {
|
|
21055
21098
|
return this.#p.removeVfs();
|
|
21056
21099
|
}
|
|
21100
|
+
pauseVfs() {
|
|
21101
|
+
this.#p.pauseVfs();
|
|
21102
|
+
return this;
|
|
21103
|
+
}
|
|
21104
|
+
async unpauseVfs() {
|
|
21105
|
+
return this.#p.unpauseVfs().then(() => this);
|
|
21106
|
+
}
|
|
21107
|
+
isPaused() {
|
|
21108
|
+
return this.#p.isPaused();
|
|
21109
|
+
}
|
|
21057
21110
|
}
|
|
21058
21111
|
const apiVersionCheck = async () => {
|
|
21059
21112
|
const dh = await navigator.storage.getDirectory();
|
package/dist/peerbit/sqlite3.mjs
CHANGED
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
/*
|
|
27
27
|
** This code was built from sqlite3 version...
|
|
28
28
|
**
|
|
29
|
-
** SQLITE_VERSION "3.
|
|
30
|
-
** SQLITE_VERSION_NUMBER
|
|
31
|
-
** SQLITE_SOURCE_ID "2025-
|
|
29
|
+
** SQLITE_VERSION "3.50.1"
|
|
30
|
+
** SQLITE_VERSION_NUMBER 3050001
|
|
31
|
+
** SQLITE_SOURCE_ID "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95"
|
|
32
32
|
**
|
|
33
33
|
** Using the Emscripten SDK version 3.1.70.
|
|
34
34
|
*/
|
|
@@ -10055,7 +10055,7 @@ var sqlite3InitModule = (() => {
|
|
|
10055
10055
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
10056
10056
|
toss('Usage error: target object is-not-a StructType.');
|
|
10057
10057
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
10058
|
-
toss('Usage
|
|
10058
|
+
toss('Usage error: expecting a Function or WASM pointer to one.');
|
|
10059
10059
|
}
|
|
10060
10060
|
if (1 === arguments.length) {
|
|
10061
10061
|
return (n, f) => callee(tgt, n, f, applyArgcCheck);
|
|
@@ -10169,11 +10169,11 @@ var sqlite3InitModule = (() => {
|
|
|
10169
10169
|
|
|
10170
10170
|
globalThis.sqlite3ApiBootstrap.initializers.push(function (sqlite3) {
|
|
10171
10171
|
sqlite3.version = {
|
|
10172
|
-
libVersion: '3.
|
|
10173
|
-
libVersionNumber:
|
|
10172
|
+
libVersion: '3.50.1',
|
|
10173
|
+
libVersionNumber: 3050001,
|
|
10174
10174
|
sourceId:
|
|
10175
|
-
'2025-
|
|
10176
|
-
downloadVersion:
|
|
10175
|
+
'2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95',
|
|
10176
|
+
downloadVersion: 3500100,
|
|
10177
10177
|
};
|
|
10178
10178
|
});
|
|
10179
10179
|
|
|
@@ -11540,6 +11540,12 @@ var sqlite3InitModule = (() => {
|
|
|
11540
11540
|
rc.changeCount =
|
|
11541
11541
|
db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
11542
11542
|
}
|
|
11543
|
+
const lastInsertRowId = !!rc.lastInsertRowId
|
|
11544
|
+
? sqlite3.capi.sqlite3_last_insert_rowid(db)
|
|
11545
|
+
: undefined;
|
|
11546
|
+
if (undefined !== lastInsertRowId) {
|
|
11547
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
11548
|
+
}
|
|
11543
11549
|
if (rc.callback instanceof Function) {
|
|
11544
11550
|
rc.callback = theCallback;
|
|
11545
11551
|
|
|
@@ -13009,7 +13015,7 @@ var sqlite3InitModule = (() => {
|
|
|
13009
13015
|
capi.SQLITE_OPEN_MAIN_JOURNAL |
|
|
13010
13016
|
capi.SQLITE_OPEN_SUPER_JOURNAL |
|
|
13011
13017
|
capi.SQLITE_OPEN_WAL;
|
|
13012
|
-
|
|
13018
|
+
const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
|
|
13013
13019
|
const OPAQUE_DIR_NAME = '.opaque';
|
|
13014
13020
|
|
|
13015
13021
|
const getRandomName = () => Math.random().toString(36).slice(2);
|
|
@@ -13239,6 +13245,7 @@ var sqlite3InitModule = (() => {
|
|
|
13239
13245
|
xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
|
|
13240
13246
|
const pool = getPoolForVfs(pVfs);
|
|
13241
13247
|
try {
|
|
13248
|
+
flags &= ~FLAG_COMPUTE_DIGEST_V2;
|
|
13242
13249
|
pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
|
|
13243
13250
|
|
|
13244
13251
|
const path =
|
|
@@ -13387,8 +13394,7 @@ var sqlite3InitModule = (() => {
|
|
|
13387
13394
|
|
|
13388
13395
|
getFileNames() {
|
|
13389
13396
|
const rc = [];
|
|
13390
|
-
const
|
|
13391
|
-
for (const n of iter) rc.push(n);
|
|
13397
|
+
for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
|
|
13392
13398
|
return rc;
|
|
13393
13399
|
}
|
|
13394
13400
|
|
|
@@ -13429,7 +13435,7 @@ var sqlite3InitModule = (() => {
|
|
|
13429
13435
|
this.#availableSAH.clear();
|
|
13430
13436
|
}
|
|
13431
13437
|
|
|
13432
|
-
async acquireAccessHandles(clearFiles) {
|
|
13438
|
+
async acquireAccessHandles(clearFiles = false) {
|
|
13433
13439
|
const files = [];
|
|
13434
13440
|
for await (const [name, h] of this.#dhOpaque) {
|
|
13435
13441
|
if ('file' === h.kind) {
|
|
@@ -13480,12 +13486,14 @@ var sqlite3InitModule = (() => {
|
|
|
13480
13486
|
|
|
13481
13487
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
|
13482
13488
|
sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
|
|
13483
|
-
const compDigest = this.computeDigest(this.#apBody);
|
|
13489
|
+
const compDigest = this.computeDigest(this.#apBody, flags);
|
|
13490
|
+
|
|
13484
13491
|
if (fileDigest.every((v, i) => v === compDigest[i])) {
|
|
13485
13492
|
const pathBytes = this.#apBody.findIndex((v) => 0 === v);
|
|
13486
13493
|
if (0 === pathBytes) {
|
|
13487
13494
|
sah.truncate(HEADER_OFFSET_DATA);
|
|
13488
13495
|
}
|
|
13496
|
+
|
|
13489
13497
|
return pathBytes
|
|
13490
13498
|
? textDecoder.decode(this.#apBody.subarray(0, pathBytes))
|
|
13491
13499
|
: '';
|
|
@@ -13501,10 +13509,13 @@ var sqlite3InitModule = (() => {
|
|
|
13501
13509
|
if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
|
|
13502
13510
|
toss('Path too long:', path);
|
|
13503
13511
|
}
|
|
13512
|
+
if (path && flags) {
|
|
13513
|
+
flags |= FLAG_COMPUTE_DIGEST_V2;
|
|
13514
|
+
}
|
|
13504
13515
|
this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
|
|
13505
13516
|
this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
13517
|
+
const digest = this.computeDigest(this.#apBody, flags);
|
|
13506
13518
|
|
|
13507
|
-
const digest = this.computeDigest(this.#apBody);
|
|
13508
13519
|
sah.write(this.#apBody, { at: 0 });
|
|
13509
13520
|
sah.write(digest, { at: HEADER_OFFSET_DIGEST });
|
|
13510
13521
|
sah.flush();
|
|
@@ -13518,14 +13529,18 @@ var sqlite3InitModule = (() => {
|
|
|
13518
13529
|
}
|
|
13519
13530
|
}
|
|
13520
13531
|
|
|
13521
|
-
computeDigest(byteArray) {
|
|
13522
|
-
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13532
|
+
computeDigest(byteArray, fileFlags) {
|
|
13533
|
+
if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
|
|
13534
|
+
let h1 = 0xdeadbeef;
|
|
13535
|
+
let h2 = 0x41c6ce57;
|
|
13536
|
+
for (const v of byteArray) {
|
|
13537
|
+
h1 = Math.imul(h1 ^ v, 2654435761);
|
|
13538
|
+
h2 = Math.imul(h2 ^ v, 104729);
|
|
13539
|
+
}
|
|
13540
|
+
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13541
|
+
} else {
|
|
13542
|
+
return new Uint32Array([0, 0]);
|
|
13527
13543
|
}
|
|
13528
|
-
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
13529
13544
|
}
|
|
13530
13545
|
|
|
13531
13546
|
async reset(clearFiles) {
|
|
@@ -13622,11 +13637,45 @@ var sqlite3InitModule = (() => {
|
|
|
13622
13637
|
});
|
|
13623
13638
|
this.#dhVfsRoot = this.#dhVfsParent = undefined;
|
|
13624
13639
|
} catch (e) {
|
|
13625
|
-
sqlite3.config.error(
|
|
13640
|
+
sqlite3.config.error(
|
|
13641
|
+
this.vfsName,
|
|
13642
|
+
'removeVfs() failed with no recovery strategy:',
|
|
13643
|
+
e,
|
|
13644
|
+
);
|
|
13626
13645
|
}
|
|
13627
13646
|
return true;
|
|
13628
13647
|
}
|
|
13629
13648
|
|
|
13649
|
+
pauseVfs() {
|
|
13650
|
+
if (this.#mapS3FileToOFile_.size > 0) {
|
|
13651
|
+
sqlite3.SQLite3Error.toss(
|
|
13652
|
+
capi.SQLITE_MISUSE,
|
|
13653
|
+
'Cannot pause VFS',
|
|
13654
|
+
this.vfsName,
|
|
13655
|
+
'because it has opened files.',
|
|
13656
|
+
);
|
|
13657
|
+
}
|
|
13658
|
+
if (this.#mapSAHToName.size > 0) {
|
|
13659
|
+
capi.sqlite3_vfs_unregister(this.vfsName);
|
|
13660
|
+
this.releaseAccessHandles();
|
|
13661
|
+
}
|
|
13662
|
+
return this;
|
|
13663
|
+
}
|
|
13664
|
+
|
|
13665
|
+
isPaused() {
|
|
13666
|
+
return 0 === this.#mapSAHToName.size;
|
|
13667
|
+
}
|
|
13668
|
+
|
|
13669
|
+
async unpauseVfs() {
|
|
13670
|
+
if (0 === this.#mapSAHToName.size) {
|
|
13671
|
+
return this.acquireAccessHandles(false).then(
|
|
13672
|
+
() => capi.sqlite3_vfs_register(this.#cVfs, 0),
|
|
13673
|
+
this,
|
|
13674
|
+
);
|
|
13675
|
+
}
|
|
13676
|
+
return this;
|
|
13677
|
+
}
|
|
13678
|
+
|
|
13630
13679
|
exportFile(name) {
|
|
13631
13680
|
const sah =
|
|
13632
13681
|
this.#mapFilenameToSAH.get(name) || toss('File not found:', name);
|
|
@@ -13771,6 +13820,17 @@ var sqlite3InitModule = (() => {
|
|
|
13771
13820
|
async removeVfs() {
|
|
13772
13821
|
return this.#p.removeVfs();
|
|
13773
13822
|
}
|
|
13823
|
+
|
|
13824
|
+
pauseVfs() {
|
|
13825
|
+
this.#p.pauseVfs();
|
|
13826
|
+
return this;
|
|
13827
|
+
}
|
|
13828
|
+
async unpauseVfs() {
|
|
13829
|
+
return this.#p.unpauseVfs().then(() => this);
|
|
13830
|
+
}
|
|
13831
|
+
isPaused() {
|
|
13832
|
+
return this.#p.isPaused();
|
|
13833
|
+
}
|
|
13774
13834
|
}
|
|
13775
13835
|
|
|
13776
13836
|
const apiVersionCheck = async () => {
|
|
Binary file
|
|
@@ -13684,7 +13684,7 @@ var sqlite3InitModule = (() => {
|
|
|
13684
13684
|
if (!(tgt instanceof StructBinder.StructType)) {
|
|
13685
13685
|
toss("Usage error: target object is-not-a StructType.");
|
|
13686
13686
|
} else if (!(func instanceof Function) && !wasm.isPtr(func)) {
|
|
13687
|
-
toss("Usage
|
|
13687
|
+
toss("Usage error: expecting a Function or WASM pointer to one.");
|
|
13688
13688
|
}
|
|
13689
13689
|
if (1 === arguments.length) {
|
|
13690
13690
|
return (n, f) => callee2(tgt, n, f, applyArgcCheck);
|
|
@@ -13774,10 +13774,10 @@ var sqlite3InitModule = (() => {
|
|
|
13774
13774
|
});
|
|
13775
13775
|
globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite32) {
|
|
13776
13776
|
sqlite32.version = {
|
|
13777
|
-
libVersion: "3.
|
|
13778
|
-
libVersionNumber:
|
|
13779
|
-
sourceId: "2025-
|
|
13780
|
-
downloadVersion:
|
|
13777
|
+
libVersion: "3.50.1",
|
|
13778
|
+
libVersionNumber: 3050001,
|
|
13779
|
+
sourceId: "2025-06-06 14:52:32 b77dc5e0f596d2140d9ac682b2893ff65d3a4140aa86067a3efebe29dc914c95",
|
|
13780
|
+
downloadVersion: 3500100
|
|
13781
13781
|
};
|
|
13782
13782
|
});
|
|
13783
13783
|
globalThis.sqlite3ApiBootstrap.initializers.push(function(sqlite32) {
|
|
@@ -14943,6 +14943,10 @@ var sqlite3InitModule = (() => {
|
|
|
14943
14943
|
if (void 0 !== changeCount) {
|
|
14944
14944
|
rc.changeCount = db.changes(true, 64 === rc.countChanges) - changeCount;
|
|
14945
14945
|
}
|
|
14946
|
+
const lastInsertRowId = !!rc.lastInsertRowId ? sqlite33.capi.sqlite3_last_insert_rowid(db) : void 0;
|
|
14947
|
+
if (void 0 !== lastInsertRowId) {
|
|
14948
|
+
rc.lastInsertRowId = lastInsertRowId;
|
|
14949
|
+
}
|
|
14946
14950
|
if (rc.callback instanceof Function) {
|
|
14947
14951
|
rc.callback = theCallback;
|
|
14948
14952
|
wState.post({
|
|
@@ -16235,6 +16239,7 @@ var sqlite3InitModule = (() => {
|
|
|
16235
16239
|
const HEADER_OFFSET_DIGEST = HEADER_CORPUS_SIZE;
|
|
16236
16240
|
const HEADER_OFFSET_DATA = SECTOR_SIZE;
|
|
16237
16241
|
const PERSISTENT_FILE_TYPES = capi.SQLITE_OPEN_MAIN_DB | capi.SQLITE_OPEN_MAIN_JOURNAL | capi.SQLITE_OPEN_SUPER_JOURNAL | capi.SQLITE_OPEN_WAL;
|
|
16242
|
+
const FLAG_COMPUTE_DIGEST_V2 = capi.SQLITE_OPEN_MEMORY;
|
|
16238
16243
|
const OPAQUE_DIR_NAME = ".opaque";
|
|
16239
16244
|
const getRandomName = () => Math.random().toString(36).slice(2);
|
|
16240
16245
|
const textDecoder = new TextDecoder();
|
|
@@ -16450,6 +16455,7 @@ var sqlite3InitModule = (() => {
|
|
|
16450
16455
|
xOpen: function f(pVfs, zName, pFile, flags, pOutFlags) {
|
|
16451
16456
|
const pool = getPoolForVfs(pVfs);
|
|
16452
16457
|
try {
|
|
16458
|
+
flags &= ~FLAG_COMPUTE_DIGEST_V2;
|
|
16453
16459
|
pool.log(`xOpen ${wasm.cstrToJs(zName)} ${flags}`);
|
|
16454
16460
|
const path = zName && wasm.peek8(zName) ? pool.getPath(zName) : getRandomName();
|
|
16455
16461
|
let sah = pool.getSAHForPath(path);
|
|
@@ -16570,8 +16576,7 @@ var sqlite3InitModule = (() => {
|
|
|
16570
16576
|
}
|
|
16571
16577
|
getFileNames() {
|
|
16572
16578
|
const rc = [];
|
|
16573
|
-
const
|
|
16574
|
-
for (const n of iter) rc.push(n);
|
|
16579
|
+
for (const n of this.#mapFilenameToSAH.keys()) rc.push(n);
|
|
16575
16580
|
return rc;
|
|
16576
16581
|
}
|
|
16577
16582
|
async addCapacity(n) {
|
|
@@ -16607,7 +16612,7 @@ var sqlite3InitModule = (() => {
|
|
|
16607
16612
|
this.#mapFilenameToSAH.clear();
|
|
16608
16613
|
this.#availableSAH.clear();
|
|
16609
16614
|
}
|
|
16610
|
-
async acquireAccessHandles(clearFiles) {
|
|
16615
|
+
async acquireAccessHandles(clearFiles = false) {
|
|
16611
16616
|
const files = [];
|
|
16612
16617
|
for await (const [name, h] of this.#dhOpaque) {
|
|
16613
16618
|
if ("file" === h.kind) {
|
|
@@ -16651,7 +16656,7 @@ var sqlite3InitModule = (() => {
|
|
|
16651
16656
|
}
|
|
16652
16657
|
const fileDigest = new Uint32Array(HEADER_DIGEST_SIZE / 4);
|
|
16653
16658
|
sah.read(fileDigest, { at: HEADER_OFFSET_DIGEST });
|
|
16654
|
-
const compDigest = this.computeDigest(this.#apBody);
|
|
16659
|
+
const compDigest = this.computeDigest(this.#apBody, flags);
|
|
16655
16660
|
if (fileDigest.every((v2, i) => v2 === compDigest[i])) {
|
|
16656
16661
|
const pathBytes = this.#apBody.findIndex((v2) => 0 === v2);
|
|
16657
16662
|
if (0 === pathBytes) {
|
|
@@ -16669,9 +16674,12 @@ var sqlite3InitModule = (() => {
|
|
|
16669
16674
|
if (HEADER_MAX_PATH_SIZE <= enc.written + 1) {
|
|
16670
16675
|
toss("Path too long:", path);
|
|
16671
16676
|
}
|
|
16677
|
+
if (path && flags) {
|
|
16678
|
+
flags |= FLAG_COMPUTE_DIGEST_V2;
|
|
16679
|
+
}
|
|
16672
16680
|
this.#apBody.fill(0, enc.written, HEADER_MAX_PATH_SIZE);
|
|
16673
16681
|
this.#dvBody.setUint32(HEADER_OFFSET_FLAGS, flags);
|
|
16674
|
-
const digest = this.computeDigest(this.#apBody);
|
|
16682
|
+
const digest = this.computeDigest(this.#apBody, flags);
|
|
16675
16683
|
sah.write(this.#apBody, { at: 0 });
|
|
16676
16684
|
sah.write(digest, { at: HEADER_OFFSET_DIGEST });
|
|
16677
16685
|
sah.flush();
|
|
@@ -16683,14 +16691,18 @@ var sqlite3InitModule = (() => {
|
|
|
16683
16691
|
this.#availableSAH.add(sah);
|
|
16684
16692
|
}
|
|
16685
16693
|
}
|
|
16686
|
-
computeDigest(byteArray) {
|
|
16687
|
-
|
|
16688
|
-
|
|
16689
|
-
|
|
16690
|
-
|
|
16691
|
-
|
|
16694
|
+
computeDigest(byteArray, fileFlags) {
|
|
16695
|
+
if (fileFlags & FLAG_COMPUTE_DIGEST_V2) {
|
|
16696
|
+
let h1 = 3735928559;
|
|
16697
|
+
let h2 = 1103547991;
|
|
16698
|
+
for (const v2 of byteArray) {
|
|
16699
|
+
h1 = Math.imul(h1 ^ v2, 2654435761);
|
|
16700
|
+
h2 = Math.imul(h2 ^ v2, 104729);
|
|
16701
|
+
}
|
|
16702
|
+
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
16703
|
+
} else {
|
|
16704
|
+
return new Uint32Array([0, 0]);
|
|
16692
16705
|
}
|
|
16693
|
-
return new Uint32Array([h1 >>> 0, h2 >>> 0]);
|
|
16694
16706
|
}
|
|
16695
16707
|
async reset(clearFiles) {
|
|
16696
16708
|
await this.isReady;
|
|
@@ -16774,10 +16786,41 @@ var sqlite3InitModule = (() => {
|
|
|
16774
16786
|
});
|
|
16775
16787
|
this.#dhVfsRoot = this.#dhVfsParent = void 0;
|
|
16776
16788
|
} catch (e) {
|
|
16777
|
-
sqlite32.config.error(
|
|
16789
|
+
sqlite32.config.error(
|
|
16790
|
+
this.vfsName,
|
|
16791
|
+
"removeVfs() failed with no recovery strategy:",
|
|
16792
|
+
e
|
|
16793
|
+
);
|
|
16778
16794
|
}
|
|
16779
16795
|
return true;
|
|
16780
16796
|
}
|
|
16797
|
+
pauseVfs() {
|
|
16798
|
+
if (this.#mapS3FileToOFile_.size > 0) {
|
|
16799
|
+
sqlite32.SQLite3Error.toss(
|
|
16800
|
+
capi.SQLITE_MISUSE,
|
|
16801
|
+
"Cannot pause VFS",
|
|
16802
|
+
this.vfsName,
|
|
16803
|
+
"because it has opened files."
|
|
16804
|
+
);
|
|
16805
|
+
}
|
|
16806
|
+
if (this.#mapSAHToName.size > 0) {
|
|
16807
|
+
capi.sqlite3_vfs_unregister(this.vfsName);
|
|
16808
|
+
this.releaseAccessHandles();
|
|
16809
|
+
}
|
|
16810
|
+
return this;
|
|
16811
|
+
}
|
|
16812
|
+
isPaused() {
|
|
16813
|
+
return 0 === this.#mapSAHToName.size;
|
|
16814
|
+
}
|
|
16815
|
+
async unpauseVfs() {
|
|
16816
|
+
if (0 === this.#mapSAHToName.size) {
|
|
16817
|
+
return this.acquireAccessHandles(false).then(
|
|
16818
|
+
() => capi.sqlite3_vfs_register(this.#cVfs, 0),
|
|
16819
|
+
this
|
|
16820
|
+
);
|
|
16821
|
+
}
|
|
16822
|
+
return this;
|
|
16823
|
+
}
|
|
16781
16824
|
exportFile(name) {
|
|
16782
16825
|
const sah = this.#mapFilenameToSAH.get(name) || toss("File not found:", name);
|
|
16783
16826
|
const n = sah.getSize() - HEADER_OFFSET_DATA;
|
|
@@ -16898,6 +16941,16 @@ var sqlite3InitModule = (() => {
|
|
|
16898
16941
|
async removeVfs() {
|
|
16899
16942
|
return this.#p.removeVfs();
|
|
16900
16943
|
}
|
|
16944
|
+
pauseVfs() {
|
|
16945
|
+
this.#p.pauseVfs();
|
|
16946
|
+
return this;
|
|
16947
|
+
}
|
|
16948
|
+
async unpauseVfs() {
|
|
16949
|
+
return this.#p.unpauseVfs().then(() => this);
|
|
16950
|
+
}
|
|
16951
|
+
isPaused() {
|
|
16952
|
+
return this.#p.isPaused();
|
|
16953
|
+
}
|
|
16901
16954
|
}
|
|
16902
16955
|
const apiVersionCheck = async () => {
|
|
16903
16956
|
const dh = await navigator.storage.getDirectory();
|
package/package.json
CHANGED
|
@@ -1,80 +1,80 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
2
|
+
"name": "@peerbit/indexer-sqlite3",
|
|
3
|
+
"version": "1.2.22-7ce8142",
|
|
4
|
+
"description": "SQLite index for document store",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"types": "./dist/src/index.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
"*": {
|
|
10
|
+
"*": [
|
|
11
|
+
"*",
|
|
12
|
+
"dist/*",
|
|
13
|
+
"dist/src/*",
|
|
14
|
+
"dist/src/*/index"
|
|
15
|
+
],
|
|
16
|
+
"src/*": [
|
|
17
|
+
"*",
|
|
18
|
+
"dist/*",
|
|
19
|
+
"dist/src/*",
|
|
20
|
+
"dist/src/*/index"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/e2e",
|
|
28
|
+
"!dist/test",
|
|
29
|
+
"!**/*.tsbuildinfo"
|
|
30
|
+
],
|
|
31
|
+
"exports": {
|
|
32
|
+
".": {
|
|
33
|
+
"types": "./dist/src/index.d.ts",
|
|
34
|
+
"import": "./dist/src/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./sqlite.org": {
|
|
37
|
+
"types": "./dist/peerbit/sqlite.org/sqlite3.d.ts",
|
|
38
|
+
"import": "./dist/peerbit/sqlite.org/sqlite3.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"browser": {
|
|
42
|
+
"./dist/src/sqlite3.js": "./dist/src/sqlite3.browser.js"
|
|
43
|
+
},
|
|
44
|
+
"eslintConfig": {
|
|
45
|
+
"extends": "peerbit",
|
|
46
|
+
"parserOptions": {
|
|
47
|
+
"project": true,
|
|
48
|
+
"sourceType": "module"
|
|
49
|
+
},
|
|
50
|
+
"ignorePatterns": [
|
|
51
|
+
"!.aegir.js",
|
|
52
|
+
"test/ts-use",
|
|
53
|
+
"*.d.ts"
|
|
54
|
+
]
|
|
55
|
+
},
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"clean": "aegir clean",
|
|
61
|
+
"copy-sqlite-wasm": "mkdir -p ./dist/peerbit/ && cp -r ../../../../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/. ./dist/peerbit/",
|
|
62
|
+
"build-worker": "node ../../../../node_modules/esbuild/bin/esbuild --bundle ./src/sqlite3.worker.ts --format=esm --outfile=./dist/peerbit/sqlite3.worker.min.js",
|
|
63
|
+
"build": "aegir build && npm run build-worker && npm run copy-sqlite-wasm",
|
|
64
|
+
"test": "aegir test",
|
|
65
|
+
"test:browser": "aegir clean && aegir test -t browser",
|
|
66
|
+
"test:node": "aegir clean && aegir test -t node",
|
|
67
|
+
"lint": "aegir lint"
|
|
68
|
+
},
|
|
69
|
+
"author": "dao.xyz",
|
|
70
|
+
"license": "MIT",
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"better-sqlite3": "^11.10.0",
|
|
73
|
+
"@peerbit/indexer-interface": "2.0.10-7ce8142",
|
|
74
|
+
"@sqlite.org/sqlite-wasm": "^3.50.1-build1"
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
78
|
+
"@peerbit/indexer-tests": "1.1.14-7ce8142"
|
|
79
|
+
}
|
|
80
80
|
}
|