@taladb/web 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pkg/package.json +1 -1
- package/pkg/taladb_web.d.ts +32 -7
- package/pkg/taladb_web.js +182 -17
- package/pkg/taladb_web_bg.wasm +0 -0
- package/pkg/taladb_web_bg.wasm.d.ts +11 -7
- package/worker/taladb.worker.js +28 -8
package/package.json
CHANGED
package/pkg/package.json
CHANGED
package/pkg/taladb_web.d.ts
CHANGED
|
@@ -184,6 +184,27 @@ export class WorkerDB {
|
|
|
184
184
|
* Open an in-memory database (for tests and OPFS-unavailable fallback).
|
|
185
185
|
*/
|
|
186
186
|
static openInMemory(): WorkerDB;
|
|
187
|
+
/**
|
|
188
|
+
* Open a database backed by OPFS with HTTP push sync config.
|
|
189
|
+
*
|
|
190
|
+
* `config_json` — JSON-serialised `TalaDbConfig`, or `null` to open without sync.
|
|
191
|
+
*
|
|
192
|
+
* ```js
|
|
193
|
+
* const handle = await file_handle.createSyncAccessHandle();
|
|
194
|
+
* const db = WorkerDB.openWithConfigAndOpfs(handle, JSON.stringify(config));
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
static openWithConfigAndOpfs(sync_handle: FileSystemSyncAccessHandle, config_json?: string | null): WorkerDB;
|
|
198
|
+
/**
|
|
199
|
+
* Open a database from an optional snapshot with HTTP push sync config.
|
|
200
|
+
*
|
|
201
|
+
* `config_json` — JSON-serialised `TalaDbConfig`, or `null` to open without sync.
|
|
202
|
+
*
|
|
203
|
+
* ```js
|
|
204
|
+
* const db = WorkerDB.openWithConfigAndSnapshot(snapshot, JSON.stringify(config));
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
static openWithConfigAndSnapshot(data?: Uint8Array | null, config_json?: string | null): WorkerDB;
|
|
187
208
|
/**
|
|
188
209
|
* Open a database backed by an OPFS `FileSystemSyncAccessHandle`.
|
|
189
210
|
*
|
|
@@ -294,6 +315,8 @@ export interface InitOutput {
|
|
|
294
315
|
readonly workerdb_insertMany: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
295
316
|
readonly workerdb_listIndexes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
296
317
|
readonly workerdb_openInMemory: () => [number, number, number];
|
|
318
|
+
readonly workerdb_openWithConfigAndOpfs: (a: any, b: number, c: number) => [number, number, number];
|
|
319
|
+
readonly workerdb_openWithConfigAndSnapshot: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
297
320
|
readonly workerdb_openWithOpfs: (a: any) => [number, number, number];
|
|
298
321
|
readonly workerdb_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
299
322
|
readonly workerdb_updateMany: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
@@ -321,18 +344,20 @@ export interface InitOutput {
|
|
|
321
344
|
readonly taladbwasm_openInMemory: () => [number, number, number];
|
|
322
345
|
readonly taladbwasm_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
323
346
|
readonly init: () => void;
|
|
347
|
+
readonly idb_load_snapshot: (a: number, b: number) => any;
|
|
348
|
+
readonly idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
324
349
|
readonly is_opfs_available: () => any;
|
|
325
350
|
readonly opfs_delete_snapshot: (a: number, b: number) => any;
|
|
326
351
|
readonly opfs_flush_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
327
352
|
readonly opfs_load_snapshot: (a: number, b: number) => any;
|
|
328
353
|
readonly opfs_open_backend: (a: number, b: number) => any;
|
|
329
|
-
readonly
|
|
330
|
-
readonly
|
|
331
|
-
readonly
|
|
332
|
-
readonly
|
|
333
|
-
readonly
|
|
334
|
-
readonly
|
|
335
|
-
readonly
|
|
354
|
+
readonly wasm_bindgen__closure__destroy__hf3c3b5f99d903397: (a: number, b: number) => void;
|
|
355
|
+
readonly wasm_bindgen__closure__destroy__h478053cb26acc43f: (a: number, b: number) => void;
|
|
356
|
+
readonly wasm_bindgen__closure__destroy__h1febc128ce23ccd1: (a: number, b: number) => void;
|
|
357
|
+
readonly wasm_bindgen__convert__closures_____invoke__h3022e61d849d0b12: (a: number, b: number, c: any) => [number, number];
|
|
358
|
+
readonly wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015: (a: number, b: number, c: any, d: any) => void;
|
|
359
|
+
readonly wasm_bindgen__convert__closures_____invoke__h524ec4525bd0d07f: (a: number, b: number, c: any) => void;
|
|
360
|
+
readonly wasm_bindgen__convert__closures_____invoke__h325a87e086f6f78c: (a: number, b: number) => void;
|
|
336
361
|
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
337
362
|
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
338
363
|
readonly __wbindgen_exn_store: (a: number) => void;
|
package/pkg/taladb_web.js
CHANGED
|
@@ -695,6 +695,51 @@ export class WorkerDB {
|
|
|
695
695
|
}
|
|
696
696
|
return WorkerDB.__wrap(ret[0]);
|
|
697
697
|
}
|
|
698
|
+
/**
|
|
699
|
+
* Open a database backed by OPFS with HTTP push sync config.
|
|
700
|
+
*
|
|
701
|
+
* `config_json` — JSON-serialised `TalaDbConfig`, or `null` to open without sync.
|
|
702
|
+
*
|
|
703
|
+
* ```js
|
|
704
|
+
* const handle = await file_handle.createSyncAccessHandle();
|
|
705
|
+
* const db = WorkerDB.openWithConfigAndOpfs(handle, JSON.stringify(config));
|
|
706
|
+
* ```
|
|
707
|
+
* @param {FileSystemSyncAccessHandle} sync_handle
|
|
708
|
+
* @param {string | null} [config_json]
|
|
709
|
+
* @returns {WorkerDB}
|
|
710
|
+
*/
|
|
711
|
+
static openWithConfigAndOpfs(sync_handle, config_json) {
|
|
712
|
+
var ptr0 = isLikeNone(config_json) ? 0 : passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
713
|
+
var len0 = WASM_VECTOR_LEN;
|
|
714
|
+
const ret = wasm.workerdb_openWithConfigAndOpfs(sync_handle, ptr0, len0);
|
|
715
|
+
if (ret[2]) {
|
|
716
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
717
|
+
}
|
|
718
|
+
return WorkerDB.__wrap(ret[0]);
|
|
719
|
+
}
|
|
720
|
+
/**
|
|
721
|
+
* Open a database from an optional snapshot with HTTP push sync config.
|
|
722
|
+
*
|
|
723
|
+
* `config_json` — JSON-serialised `TalaDbConfig`, or `null` to open without sync.
|
|
724
|
+
*
|
|
725
|
+
* ```js
|
|
726
|
+
* const db = WorkerDB.openWithConfigAndSnapshot(snapshot, JSON.stringify(config));
|
|
727
|
+
* ```
|
|
728
|
+
* @param {Uint8Array | null} [data]
|
|
729
|
+
* @param {string | null} [config_json]
|
|
730
|
+
* @returns {WorkerDB}
|
|
731
|
+
*/
|
|
732
|
+
static openWithConfigAndSnapshot(data, config_json) {
|
|
733
|
+
var ptr0 = isLikeNone(data) ? 0 : passArray8ToWasm0(data, wasm.__wbindgen_malloc);
|
|
734
|
+
var len0 = WASM_VECTOR_LEN;
|
|
735
|
+
var ptr1 = isLikeNone(config_json) ? 0 : passStringToWasm0(config_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
736
|
+
var len1 = WASM_VECTOR_LEN;
|
|
737
|
+
const ret = wasm.workerdb_openWithConfigAndSnapshot(ptr0, len0, ptr1, len1);
|
|
738
|
+
if (ret[2]) {
|
|
739
|
+
throw takeFromExternrefTable0(ret[1]);
|
|
740
|
+
}
|
|
741
|
+
return WorkerDB.__wrap(ret[0]);
|
|
742
|
+
}
|
|
698
743
|
/**
|
|
699
744
|
* Open a database backed by an OPFS `FileSystemSyncAccessHandle`.
|
|
700
745
|
*
|
|
@@ -988,10 +1033,23 @@ function __wbg_get_imports() {
|
|
|
988
1033
|
__wbg__wbg_cb_unref_6b5b6b8576d35cb1: function(arg0) {
|
|
989
1034
|
arg0._wbg_cb_unref();
|
|
990
1035
|
},
|
|
1036
|
+
__wbg_abort_5ef96933660780b7: function(arg0) {
|
|
1037
|
+
arg0.abort();
|
|
1038
|
+
},
|
|
1039
|
+
__wbg_abort_6479c2d794ebf2ee: function(arg0, arg1) {
|
|
1040
|
+
arg0.abort(arg1);
|
|
1041
|
+
},
|
|
1042
|
+
__wbg_append_608dfb635ee8998f: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
|
|
1043
|
+
arg0.append(getStringFromWasm0(arg1, arg2), getStringFromWasm0(arg3, arg4));
|
|
1044
|
+
}, arguments); },
|
|
991
1045
|
__wbg_apply_ac9afb97ca32f169: function() { return handleError(function (arg0, arg1, arg2) {
|
|
992
1046
|
const ret = arg0.apply(arg1, arg2);
|
|
993
1047
|
return ret;
|
|
994
1048
|
}, arguments); },
|
|
1049
|
+
__wbg_apply_d7728efbea08f95e: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1050
|
+
const ret = Reflect.apply(arg0, arg1, arg2);
|
|
1051
|
+
return ret;
|
|
1052
|
+
}, arguments); },
|
|
995
1053
|
__wbg_arrayBuffer_7ff5e58aa85a64f7: function(arg0) {
|
|
996
1054
|
const ret = arg0.arrayBuffer();
|
|
997
1055
|
return ret;
|
|
@@ -1008,6 +1066,10 @@ function __wbg_get_imports() {
|
|
|
1008
1066
|
const ret = arg0.call(arg1);
|
|
1009
1067
|
return ret;
|
|
1010
1068
|
}, arguments); },
|
|
1069
|
+
__wbg_clearTimeout_6b8d9a38b9263d65: function(arg0) {
|
|
1070
|
+
const ret = clearTimeout(arg0);
|
|
1071
|
+
return ret;
|
|
1072
|
+
},
|
|
1011
1073
|
__wbg_close_8b24f0978d9a4917: function(arg0) {
|
|
1012
1074
|
const ret = arg0.close();
|
|
1013
1075
|
return ret;
|
|
@@ -1035,6 +1097,14 @@ function __wbg_get_imports() {
|
|
|
1035
1097
|
wasm.__wbindgen_free(deferred0_0, deferred0_1, 1);
|
|
1036
1098
|
}
|
|
1037
1099
|
},
|
|
1100
|
+
__wbg_fetch_5550a88cf343aaa9: function(arg0, arg1) {
|
|
1101
|
+
const ret = arg0.fetch(arg1);
|
|
1102
|
+
return ret;
|
|
1103
|
+
},
|
|
1104
|
+
__wbg_fetch_9dad4fe911207b37: function(arg0) {
|
|
1105
|
+
const ret = fetch(arg0);
|
|
1106
|
+
return ret;
|
|
1107
|
+
},
|
|
1038
1108
|
__wbg_flush_1eca046e0ff7c399: function() { return handleError(function (arg0) {
|
|
1039
1109
|
arg0.flush();
|
|
1040
1110
|
}, arguments); },
|
|
@@ -1077,6 +1147,14 @@ function __wbg_get_imports() {
|
|
|
1077
1147
|
const ret = arg0[arg1 >>> 0];
|
|
1078
1148
|
return ret;
|
|
1079
1149
|
},
|
|
1150
|
+
__wbg_has_926ef2ff40b308cf: function() { return handleError(function (arg0, arg1) {
|
|
1151
|
+
const ret = Reflect.has(arg0, arg1);
|
|
1152
|
+
return ret;
|
|
1153
|
+
}, arguments); },
|
|
1154
|
+
__wbg_headers_eb2234545f9ff993: function(arg0) {
|
|
1155
|
+
const ret = arg0.headers;
|
|
1156
|
+
return ret;
|
|
1157
|
+
},
|
|
1080
1158
|
__wbg_instanceof_ArrayBuffer_101e2bf31071a9f6: function(arg0) {
|
|
1081
1159
|
let result;
|
|
1082
1160
|
try {
|
|
@@ -1157,6 +1235,16 @@ function __wbg_get_imports() {
|
|
|
1157
1235
|
const ret = result;
|
|
1158
1236
|
return ret;
|
|
1159
1237
|
},
|
|
1238
|
+
__wbg_instanceof_Response_9b4d9fd451e051b1: function(arg0) {
|
|
1239
|
+
let result;
|
|
1240
|
+
try {
|
|
1241
|
+
result = arg0 instanceof Response;
|
|
1242
|
+
} catch (_) {
|
|
1243
|
+
result = false;
|
|
1244
|
+
}
|
|
1245
|
+
const ret = result;
|
|
1246
|
+
return ret;
|
|
1247
|
+
},
|
|
1160
1248
|
__wbg_instanceof_Uint8Array_740438561a5b956d: function(arg0) {
|
|
1161
1249
|
let result;
|
|
1162
1250
|
try {
|
|
@@ -1201,6 +1289,10 @@ function __wbg_get_imports() {
|
|
|
1201
1289
|
const ret = arg0.navigator;
|
|
1202
1290
|
return ret;
|
|
1203
1291
|
},
|
|
1292
|
+
__wbg_new_0837727332ac86ba: function() { return handleError(function () {
|
|
1293
|
+
const ret = new Headers();
|
|
1294
|
+
return ret;
|
|
1295
|
+
}, arguments); },
|
|
1204
1296
|
__wbg_new_227d7c05414eb861: function() {
|
|
1205
1297
|
const ret = new Error();
|
|
1206
1298
|
return ret;
|
|
@@ -1221,6 +1313,10 @@ function __wbg_get_imports() {
|
|
|
1221
1313
|
const ret = new Object();
|
|
1222
1314
|
return ret;
|
|
1223
1315
|
},
|
|
1316
|
+
__wbg_new_c518c60af666645b: function() { return handleError(function () {
|
|
1317
|
+
const ret = new AbortController();
|
|
1318
|
+
return ret;
|
|
1319
|
+
}, arguments); },
|
|
1224
1320
|
__wbg_new_d098e265629cd10f: function(arg0, arg1) {
|
|
1225
1321
|
try {
|
|
1226
1322
|
var state0 = {a: arg0, b: arg1};
|
|
@@ -1228,7 +1324,7 @@ function __wbg_get_imports() {
|
|
|
1228
1324
|
const a = state0.a;
|
|
1229
1325
|
state0.a = 0;
|
|
1230
1326
|
try {
|
|
1231
|
-
return
|
|
1327
|
+
return wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015(a, state0.b, arg0, arg1);
|
|
1232
1328
|
} finally {
|
|
1233
1329
|
state0.a = a;
|
|
1234
1330
|
}
|
|
@@ -1250,7 +1346,7 @@ function __wbg_get_imports() {
|
|
|
1250
1346
|
const a = state0.a;
|
|
1251
1347
|
state0.a = 0;
|
|
1252
1348
|
try {
|
|
1253
|
-
return
|
|
1349
|
+
return wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015(a, state0.b, arg0, arg1);
|
|
1254
1350
|
} finally {
|
|
1255
1351
|
state0.a = a;
|
|
1256
1352
|
}
|
|
@@ -1265,6 +1361,10 @@ function __wbg_get_imports() {
|
|
|
1265
1361
|
const ret = new Uint8Array(arg0 >>> 0);
|
|
1266
1362
|
return ret;
|
|
1267
1363
|
},
|
|
1364
|
+
__wbg_new_with_str_and_init_b4b54d1a819bc724: function() { return handleError(function (arg0, arg1, arg2) {
|
|
1365
|
+
const ret = new Request(getStringFromWasm0(arg0, arg1), arg2);
|
|
1366
|
+
return ret;
|
|
1367
|
+
}, arguments); },
|
|
1268
1368
|
__wbg_next_11b99ee6237339e3: function() { return handleError(function (arg0) {
|
|
1269
1369
|
const ret = arg0.next();
|
|
1270
1370
|
return ret;
|
|
@@ -1277,6 +1377,10 @@ function __wbg_get_imports() {
|
|
|
1277
1377
|
const ret = Date.now();
|
|
1278
1378
|
return ret;
|
|
1279
1379
|
},
|
|
1380
|
+
__wbg_of_d6376e3774c51f89: function(arg0, arg1) {
|
|
1381
|
+
const ret = Array.of(arg0, arg1);
|
|
1382
|
+
return ret;
|
|
1383
|
+
},
|
|
1280
1384
|
__wbg_prototypesetcall_d62e5099504357e6: function(arg0, arg1, arg2) {
|
|
1281
1385
|
Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
|
|
1282
1386
|
},
|
|
@@ -1299,6 +1403,10 @@ function __wbg_get_imports() {
|
|
|
1299
1403
|
const ret = Promise.resolve(arg0);
|
|
1300
1404
|
return ret;
|
|
1301
1405
|
},
|
|
1406
|
+
__wbg_setTimeout_f757f00851f76c42: function(arg0, arg1) {
|
|
1407
|
+
const ret = setTimeout(arg0, arg1);
|
|
1408
|
+
return ret;
|
|
1409
|
+
},
|
|
1302
1410
|
__wbg_set_282384002438957f: function(arg0, arg1, arg2) {
|
|
1303
1411
|
arg0[arg1 >>> 0] = arg2;
|
|
1304
1412
|
},
|
|
@@ -1313,9 +1421,34 @@ function __wbg_get_imports() {
|
|
|
1313
1421
|
const ret = arg0.set(arg1, arg2);
|
|
1314
1422
|
return ret;
|
|
1315
1423
|
},
|
|
1424
|
+
__wbg_set_body_a3d856b097dfda04: function(arg0, arg1) {
|
|
1425
|
+
arg0.body = arg1;
|
|
1426
|
+
},
|
|
1427
|
+
__wbg_set_cache_ec7e430c6056ebda: function(arg0, arg1) {
|
|
1428
|
+
arg0.cache = __wbindgen_enum_RequestCache[arg1];
|
|
1429
|
+
},
|
|
1316
1430
|
__wbg_set_create_ef897736206a6f05: function(arg0, arg1) {
|
|
1317
1431
|
arg0.create = arg1 !== 0;
|
|
1318
1432
|
},
|
|
1433
|
+
__wbg_set_credentials_ed63183445882c65: function(arg0, arg1) {
|
|
1434
|
+
arg0.credentials = __wbindgen_enum_RequestCredentials[arg1];
|
|
1435
|
+
},
|
|
1436
|
+
__wbg_set_headers_3c8fecc693b75327: function(arg0, arg1) {
|
|
1437
|
+
arg0.headers = arg1;
|
|
1438
|
+
},
|
|
1439
|
+
__wbg_set_method_8c015e8bcafd7be1: function(arg0, arg1, arg2) {
|
|
1440
|
+
arg0.method = getStringFromWasm0(arg1, arg2);
|
|
1441
|
+
},
|
|
1442
|
+
__wbg_set_mode_5a87f2c809cf37c2: function(arg0, arg1) {
|
|
1443
|
+
arg0.mode = __wbindgen_enum_RequestMode[arg1];
|
|
1444
|
+
},
|
|
1445
|
+
__wbg_set_signal_0cebecb698f25d21: function(arg0, arg1) {
|
|
1446
|
+
arg0.signal = arg1;
|
|
1447
|
+
},
|
|
1448
|
+
__wbg_signal_166e1da31adcac18: function(arg0) {
|
|
1449
|
+
const ret = arg0.signal;
|
|
1450
|
+
return ret;
|
|
1451
|
+
},
|
|
1319
1452
|
__wbg_stack_3b0d974bbf31e44f: function(arg0, arg1) {
|
|
1320
1453
|
const ret = arg1.stack;
|
|
1321
1454
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -1339,10 +1472,18 @@ function __wbg_get_imports() {
|
|
|
1339
1472
|
const ret = typeof window === 'undefined' ? null : window;
|
|
1340
1473
|
return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
|
|
1341
1474
|
},
|
|
1475
|
+
__wbg_status_318629ab93a22955: function(arg0) {
|
|
1476
|
+
const ret = arg0.status;
|
|
1477
|
+
return ret;
|
|
1478
|
+
},
|
|
1342
1479
|
__wbg_storage_63fa6fa9455d2153: function(arg0) {
|
|
1343
1480
|
const ret = arg0.storage;
|
|
1344
1481
|
return ret;
|
|
1345
1482
|
},
|
|
1483
|
+
__wbg_stringify_5ae93966a84901ac: function() { return handleError(function (arg0) {
|
|
1484
|
+
const ret = JSON.stringify(arg0);
|
|
1485
|
+
return ret;
|
|
1486
|
+
}, arguments); },
|
|
1346
1487
|
__wbg_then_098abe61755d12f6: function(arg0, arg1) {
|
|
1347
1488
|
const ret = arg0.then(arg1);
|
|
1348
1489
|
return ret;
|
|
@@ -1354,41 +1495,53 @@ function __wbg_get_imports() {
|
|
|
1354
1495
|
__wbg_truncate_af8ac1613ab66393: function() { return handleError(function (arg0, arg1) {
|
|
1355
1496
|
arg0.truncate(arg1);
|
|
1356
1497
|
}, arguments); },
|
|
1498
|
+
__wbg_url_7fefc1820fba4e0c: function(arg0, arg1) {
|
|
1499
|
+
const ret = arg1.url;
|
|
1500
|
+
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
1501
|
+
const len1 = WASM_VECTOR_LEN;
|
|
1502
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
|
|
1503
|
+
getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
|
|
1504
|
+
},
|
|
1357
1505
|
__wbg_value_21fc78aab0322612: function(arg0) {
|
|
1358
1506
|
const ret = arg0.value;
|
|
1359
1507
|
return ret;
|
|
1360
1508
|
},
|
|
1361
1509
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1362
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1363
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1510
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 156, function: Function { arguments: [Externref], shim_idx: 157, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1511
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf3c3b5f99d903397, wasm_bindgen__convert__closures_____invoke__h524ec4525bd0d07f);
|
|
1364
1512
|
return ret;
|
|
1365
1513
|
},
|
|
1366
1514
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1367
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1368
|
-
const ret = makeMutClosure(arg0, arg1, wasm.
|
|
1515
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 170, function: Function { arguments: [], shim_idx: 171, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1516
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h478053cb26acc43f, wasm_bindgen__convert__closures_____invoke__h325a87e086f6f78c);
|
|
1369
1517
|
return ret;
|
|
1370
1518
|
},
|
|
1371
|
-
__wbindgen_cast_0000000000000003: function(arg0) {
|
|
1519
|
+
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1520
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 575, function: Function { arguments: [Externref], shim_idx: 576, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1521
|
+
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h1febc128ce23ccd1, wasm_bindgen__convert__closures_____invoke__h3022e61d849d0b12);
|
|
1522
|
+
return ret;
|
|
1523
|
+
},
|
|
1524
|
+
__wbindgen_cast_0000000000000004: function(arg0) {
|
|
1372
1525
|
// Cast intrinsic for `F64 -> Externref`.
|
|
1373
1526
|
const ret = arg0;
|
|
1374
1527
|
return ret;
|
|
1375
1528
|
},
|
|
1376
|
-
|
|
1529
|
+
__wbindgen_cast_0000000000000005: function(arg0) {
|
|
1377
1530
|
// Cast intrinsic for `I64 -> Externref`.
|
|
1378
1531
|
const ret = arg0;
|
|
1379
1532
|
return ret;
|
|
1380
1533
|
},
|
|
1381
|
-
|
|
1534
|
+
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
|
|
1382
1535
|
// Cast intrinsic for `Ref(String) -> Externref`.
|
|
1383
1536
|
const ret = getStringFromWasm0(arg0, arg1);
|
|
1384
1537
|
return ret;
|
|
1385
1538
|
},
|
|
1386
|
-
|
|
1539
|
+
__wbindgen_cast_0000000000000007: function(arg0) {
|
|
1387
1540
|
// Cast intrinsic for `U64 -> Externref`.
|
|
1388
1541
|
const ret = BigInt.asUintN(64, arg0);
|
|
1389
1542
|
return ret;
|
|
1390
1543
|
},
|
|
1391
|
-
|
|
1544
|
+
__wbindgen_cast_0000000000000008: function(arg0, arg1) {
|
|
1392
1545
|
var v0 = getArrayU8FromWasm0(arg0, arg1).slice();
|
|
1393
1546
|
wasm.__wbindgen_free(arg0, arg1 * 1, 1);
|
|
1394
1547
|
// Cast intrinsic for `Vector(U8) -> Externref`.
|
|
@@ -1411,21 +1564,33 @@ function __wbg_get_imports() {
|
|
|
1411
1564
|
};
|
|
1412
1565
|
}
|
|
1413
1566
|
|
|
1414
|
-
function
|
|
1415
|
-
wasm.
|
|
1567
|
+
function wasm_bindgen__convert__closures_____invoke__h325a87e086f6f78c(arg0, arg1) {
|
|
1568
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h325a87e086f6f78c(arg0, arg1);
|
|
1569
|
+
}
|
|
1570
|
+
|
|
1571
|
+
function wasm_bindgen__convert__closures_____invoke__h524ec4525bd0d07f(arg0, arg1, arg2) {
|
|
1572
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h524ec4525bd0d07f(arg0, arg1, arg2);
|
|
1416
1573
|
}
|
|
1417
1574
|
|
|
1418
|
-
function
|
|
1419
|
-
const ret = wasm.
|
|
1575
|
+
function wasm_bindgen__convert__closures_____invoke__h3022e61d849d0b12(arg0, arg1, arg2) {
|
|
1576
|
+
const ret = wasm.wasm_bindgen__convert__closures_____invoke__h3022e61d849d0b12(arg0, arg1, arg2);
|
|
1420
1577
|
if (ret[1]) {
|
|
1421
1578
|
throw takeFromExternrefTable0(ret[0]);
|
|
1422
1579
|
}
|
|
1423
1580
|
}
|
|
1424
1581
|
|
|
1425
|
-
function
|
|
1426
|
-
wasm.
|
|
1582
|
+
function wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015(arg0, arg1, arg2, arg3) {
|
|
1583
|
+
wasm.wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015(arg0, arg1, arg2, arg3);
|
|
1427
1584
|
}
|
|
1428
1585
|
|
|
1586
|
+
|
|
1587
|
+
const __wbindgen_enum_RequestCache = ["default", "no-store", "reload", "no-cache", "force-cache", "only-if-cached"];
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
const __wbindgen_enum_RequestCredentials = ["omit", "same-origin", "include"];
|
|
1591
|
+
|
|
1592
|
+
|
|
1593
|
+
const __wbindgen_enum_RequestMode = ["same-origin", "no-cors", "cors", "navigate"];
|
|
1429
1594
|
const CollectionWasmFinalization = (typeof FinalizationRegistry === 'undefined')
|
|
1430
1595
|
? { register: () => {}, unregister: () => {} }
|
|
1431
1596
|
: new FinalizationRegistry(ptr => wasm.__wbg_collectionwasm_free(ptr >>> 0, 1));
|
package/pkg/taladb_web_bg.wasm
CHANGED
|
Binary file
|
|
@@ -19,6 +19,8 @@ export const workerdb_insert: (a: number, b: number, c: number, d: number, e: nu
|
|
|
19
19
|
export const workerdb_insertMany: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
|
20
20
|
export const workerdb_listIndexes: (a: number, b: number, c: number) => [number, number, number, number];
|
|
21
21
|
export const workerdb_openInMemory: () => [number, number, number];
|
|
22
|
+
export const workerdb_openWithConfigAndOpfs: (a: any, b: number, c: number) => [number, number, number];
|
|
23
|
+
export const workerdb_openWithConfigAndSnapshot: (a: number, b: number, c: number, d: number) => [number, number, number];
|
|
22
24
|
export const workerdb_openWithOpfs: (a: any) => [number, number, number];
|
|
23
25
|
export const workerdb_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
24
26
|
export const workerdb_updateMany: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number, number];
|
|
@@ -46,18 +48,20 @@ export const taladbwasm_exportSnapshot: (a: number) => [number, number, number,
|
|
|
46
48
|
export const taladbwasm_openInMemory: () => [number, number, number];
|
|
47
49
|
export const taladbwasm_openWithSnapshot: (a: number, b: number) => [number, number, number];
|
|
48
50
|
export const init: () => void;
|
|
51
|
+
export const idb_load_snapshot: (a: number, b: number) => any;
|
|
52
|
+
export const idb_save_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
49
53
|
export const is_opfs_available: () => any;
|
|
50
54
|
export const opfs_delete_snapshot: (a: number, b: number) => any;
|
|
51
55
|
export const opfs_flush_snapshot: (a: number, b: number, c: number, d: number) => any;
|
|
52
56
|
export const opfs_load_snapshot: (a: number, b: number) => any;
|
|
53
57
|
export const opfs_open_backend: (a: number, b: number) => any;
|
|
54
|
-
export const
|
|
55
|
-
export const
|
|
56
|
-
export const
|
|
57
|
-
export const
|
|
58
|
-
export const
|
|
59
|
-
export const
|
|
60
|
-
export const
|
|
58
|
+
export const wasm_bindgen__closure__destroy__hf3c3b5f99d903397: (a: number, b: number) => void;
|
|
59
|
+
export const wasm_bindgen__closure__destroy__h478053cb26acc43f: (a: number, b: number) => void;
|
|
60
|
+
export const wasm_bindgen__closure__destroy__h1febc128ce23ccd1: (a: number, b: number) => void;
|
|
61
|
+
export const wasm_bindgen__convert__closures_____invoke__h3022e61d849d0b12: (a: number, b: number, c: any) => [number, number];
|
|
62
|
+
export const wasm_bindgen__convert__closures_____invoke__h470c93d8a24e0015: (a: number, b: number, c: any, d: any) => void;
|
|
63
|
+
export const wasm_bindgen__convert__closures_____invoke__h524ec4525bd0d07f: (a: number, b: number, c: any) => void;
|
|
64
|
+
export const wasm_bindgen__convert__closures_____invoke__h325a87e086f6f78c: (a: number, b: number) => void;
|
|
61
65
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
62
66
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
63
67
|
export const __wbindgen_exn_store: (a: number) => void;
|
package/worker/taladb.worker.js
CHANGED
|
@@ -102,6 +102,9 @@ const initPromises = new Map();
|
|
|
102
102
|
/** The dbName that was successfully initialised (or is being initialised). */
|
|
103
103
|
let activeDbName = null;
|
|
104
104
|
|
|
105
|
+
/** The configJson passed during init (stored so snapshot reloads can use it). */
|
|
106
|
+
let activeConfigJson = null;
|
|
107
|
+
|
|
105
108
|
const isDev = typeof location !== 'undefined' && (location.hostname === 'localhost' || location.hostname === '127.0.0.1');
|
|
106
109
|
const log = isDev ? console.log.bind(console, '[TalaDB Worker]') : () => {};
|
|
107
110
|
const warn = isDev ? console.warn.bind(console, '[TalaDB Worker]') : () => {};
|
|
@@ -231,12 +234,16 @@ async function dispatch(op, args) {
|
|
|
231
234
|
snapshotDirty = false;
|
|
232
235
|
try {
|
|
233
236
|
const fresh = await idbLoadSnapshot(activeDbName);
|
|
234
|
-
if (fresh)
|
|
237
|
+
if (fresh) {
|
|
238
|
+
db = activeConfigJson
|
|
239
|
+
? WorkerDB.openWithConfigAndSnapshot(fresh, activeConfigJson)
|
|
240
|
+
: WorkerDB.openWithSnapshot(fresh);
|
|
241
|
+
}
|
|
235
242
|
} catch { /* ignore reload errors — stale read is acceptable */ }
|
|
236
243
|
}
|
|
237
244
|
|
|
238
245
|
if (op === 'init') {
|
|
239
|
-
const { dbName } = args;
|
|
246
|
+
const { dbName, configJson } = args;
|
|
240
247
|
|
|
241
248
|
if (activeDbName !== null && activeDbName !== dbName) {
|
|
242
249
|
throw new Error(
|
|
@@ -247,7 +254,8 @@ async function dispatch(op, args) {
|
|
|
247
254
|
|
|
248
255
|
if (!initPromises.has(dbName)) {
|
|
249
256
|
activeDbName = dbName;
|
|
250
|
-
|
|
257
|
+
activeConfigJson = configJson ?? null;
|
|
258
|
+
initPromises.set(dbName, doInit(dbName, configJson ?? null));
|
|
251
259
|
}
|
|
252
260
|
await initPromises.get(dbName);
|
|
253
261
|
return null;
|
|
@@ -367,7 +375,7 @@ async function dispatch(op, args) {
|
|
|
367
375
|
// Initialisation — load WASM, acquire lock, open OPFS file
|
|
368
376
|
// ---------------------------------------------------------------------------
|
|
369
377
|
|
|
370
|
-
async function doInit(dbName) {
|
|
378
|
+
async function doInit(dbName, configJson) {
|
|
371
379
|
const wasm = await import('../pkg/taladb_web.js');
|
|
372
380
|
await wasm.default();
|
|
373
381
|
|
|
@@ -399,11 +407,23 @@ async function doInit(dbName) {
|
|
|
399
407
|
log('BroadcastChannel opened:', `taladb:${dbName}`);
|
|
400
408
|
}
|
|
401
409
|
|
|
410
|
+
// Helpers to open DB with or without sync config.
|
|
411
|
+
// Uses the config-aware constructors when configJson is provided so that
|
|
412
|
+
// HTTP push sync is wired up from the first write.
|
|
413
|
+
function openWithSnapshot(snapshot) {
|
|
414
|
+
if (configJson) return WorkerDB.openWithConfigAndSnapshot(snapshot, configJson);
|
|
415
|
+
return WorkerDB.openWithSnapshot(snapshot);
|
|
416
|
+
}
|
|
417
|
+
function openWithOpfs(syncHandle) {
|
|
418
|
+
if (configJson) return WorkerDB.openWithConfigAndOpfs(syncHandle, configJson);
|
|
419
|
+
return WorkerDB.openWithOpfs(syncHandle);
|
|
420
|
+
}
|
|
421
|
+
|
|
402
422
|
const opfsAvailable = await checkOpfs();
|
|
403
423
|
if (!opfsAvailable) {
|
|
404
424
|
warn('OPFS unavailable — falling back to IndexedDB-backed in-memory');
|
|
405
425
|
const snapshot = await idbLoadSnapshot(dbName);
|
|
406
|
-
db =
|
|
426
|
+
db = openWithSnapshot(snapshot);
|
|
407
427
|
idbFallback = true;
|
|
408
428
|
if (snapshot) {
|
|
409
429
|
log(`Restored from IndexedDB snapshot (${snapshot.byteLength} bytes)`);
|
|
@@ -421,7 +441,7 @@ async function doInit(dbName) {
|
|
|
421
441
|
// Web Locks not available — open directly (single-tab safe only).
|
|
422
442
|
warn('Web Locks unavailable — multi-tab write safety disabled');
|
|
423
443
|
const syncHandle = await fileHandle.createSyncAccessHandle();
|
|
424
|
-
db =
|
|
444
|
+
db = openWithOpfs(syncHandle);
|
|
425
445
|
log(`Opened "${fileName}" via OPFS`);
|
|
426
446
|
return;
|
|
427
447
|
}
|
|
@@ -451,7 +471,7 @@ async function doInit(dbName) {
|
|
|
451
471
|
if (gotIt !== false) snapshot = await idbLoadSnapshot(dbName);
|
|
452
472
|
}
|
|
453
473
|
|
|
454
|
-
db =
|
|
474
|
+
db = openWithSnapshot(snapshot ?? null);
|
|
455
475
|
idbFallback = true;
|
|
456
476
|
if (snapshot) {
|
|
457
477
|
log(`Restored from IDB snapshot (${snapshot.byteLength} bytes)`);
|
|
@@ -465,7 +485,7 @@ async function doInit(dbName) {
|
|
|
465
485
|
// Acquired the lock — use OPFS.
|
|
466
486
|
try {
|
|
467
487
|
const syncHandle = await fileHandle.createSyncAccessHandle();
|
|
468
|
-
db =
|
|
488
|
+
db = openWithOpfs(syncHandle);
|
|
469
489
|
log(`Opened "${fileName}" via OPFS (Web Locks)`);
|
|
470
490
|
resolve(); // signal doInit complete — caller can proceed
|
|
471
491
|
|