@moyodb/sdk 1.4.0 → 1.5.1

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 (36) hide show
  1. package/README.md +2 -2
  2. package/dist/assets/browser-worker-p7uX85l-.js +4 -0
  3. package/dist/assets/browser-worker-p7uX85l-.js.map +1 -0
  4. package/dist/assets/shared-worker-BALTqEUe.js +2 -0
  5. package/dist/assets/shared-worker-BALTqEUe.js.map +1 -0
  6. package/dist/chunks/{indexing-B0duqlUs.js → indexing-DdpU69Fd.js} +302 -69
  7. package/dist/chunks/{indexing-B0duqlUs.js.map → indexing-DdpU69Fd.js.map} +1 -1
  8. package/dist/codec.d.ts.map +1 -1
  9. package/dist/compression.d.ts.map +1 -1
  10. package/dist/engine/README.md +2 -2
  11. package/dist/engine/moyodb_engine.d.ts +3 -3
  12. package/dist/engine/moyodb_engine.js +34 -34
  13. package/dist/engine/moyodb_engine_bg.wasm +0 -0
  14. package/dist/engine/moyodb_engine_bg.wasm.d.ts +2 -2
  15. package/dist/engine/package.json +1 -1
  16. package/dist/engine/snippets/{moyodb-engine-1d53039816cbc2f7 → moyodb-engine-e9fc900519b160aa}/js/opfs_shim.js +8 -2
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/indexing.d.ts +7 -0
  19. package/dist/indexing.d.ts.map +1 -1
  20. package/dist/moyodb-sdk.js +1329 -931
  21. package/dist/moyodb-sdk.js.map +1 -1
  22. package/dist/node-engine.js +382 -47
  23. package/dist/node-engine.js.map +1 -1
  24. package/dist/node.js +332 -44
  25. package/dist/node.js.map +1 -1
  26. package/dist/registry.d.ts.map +1 -1
  27. package/dist/subscriptions.d.ts.map +1 -1
  28. package/dist/worker-client.d.ts.map +1 -1
  29. package/dist/worker-server.d.ts.map +1 -1
  30. package/dist/worker.d.ts +10 -3
  31. package/dist/worker.d.ts.map +1 -1
  32. package/package.json +2 -1
  33. package/dist/assets/browser-worker-Bj2ErRvC.js +0 -4
  34. package/dist/assets/browser-worker-Bj2ErRvC.js.map +0 -1
  35. package/dist/assets/shared-worker-CMeTcusa.js +0 -2
  36. package/dist/assets/shared-worker-CMeTcusa.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"codec.d.ts","sourceRoot":"","sources":["../src/codec.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAcrC,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,CAAC;AAC5E,MAAM,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAChD,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEpD;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEpD;AACD,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAMrD;AACD,wBAAgB,UAAU,CAAC,CAAC,EAAE,KAAK,EAAE,UAAU,GAAG,CAAC,CAElD;AACD,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,CAezD;AAMD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,CAAC,eAAe,CAAC,GAAG,UAAU,CAK5F;AACD,wBAAgB,WAAW,CAAC,GAAG,KAAK,EAAE,eAAe,EAAE,GAAG,UAAU,CAEnE;AACD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,GAAG,UAAU,CAEtE;AACD,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,UAAU,CAEnF;AACD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,EAAE,CA2B9D;AACD,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,GAAG,IAAI,CASrE;AACD,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU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JD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAc1E;AACD,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CA6BnH;AACD,wBAAsB,sBAAsB,CACxC,KAAK,EAAE,UAAU,EACjB,OAAO,EAAE;IACL,MAAM,EAAE,OAAO,CAAC;CACnB,GACF,OAAO,CAAC,UAAU,CAAC,CAqDrB;AACD,wBAAsB,2BAA2B,CAC7C,QAAQ,EAAE,UAAU,EACpB,WAAW,EAAE,uBAAuB,GAAG,KAAK,GAC7C,OAAO,CAAC,UAAU,CAAC,CAyBrB;AACD,wBAAsB,yBAAyB,CAAC,QAAQ,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAsCzF"}
@@ -19,7 +19,7 @@ Rust/WASM transactional database for browsers, Node.js, and native Rust applicat
19
19
 
20
20
  It provides ordered keys, typed records, SQL queries, indexes, snapshots, TTL, and recovery checks. Browser storage uses OPFS; Node.js and native Rust storage use local files. The SDK runs storage operations in a worker.
21
21
 
22
- Version 1.4.0 creates fresh databases with storage format 2. Format 1 databases are rejected before their files are changed; no in-place migration is provided. Self-contained snapshot versions 1–3 can be imported into a fresh format 2 database. The Release 1.0.1 public API, key and index encodings remain covered by historical fixtures. Unknown storage formats fail before modifying durable data.
22
+ Version 1.5.1 creates fresh databases with storage format 2. Format 1 databases are rejected before their files are changed; no in-place migration is provided. Self-contained snapshot versions 1–3 can be imported into a fresh format 2 database. The Release 1.0.1 public API, key and index encodings remain covered by historical fixtures. Unknown storage formats fail before modifying durable data.
23
23
 
24
24
  Large values use immutable contiguous `PAY2` extents in the main file. Leaf cells with value kind `External` (3) store a descriptor and an optional prefix. Payload bodies are flushed before their references enter the WAL. B-tree page and WAL record layouts retain `PAG1` and `WAL1`; the manifest's format version distinguishes the new storage contract.
25
25
 
@@ -30,7 +30,7 @@ New SDK stores use Snappy compression by default for values of at least 1,024 by
30
30
  ## Quick start
31
31
 
32
32
  ```bash
33
- npm install @moyodb/sdk@1.4.0
33
+ npm install @moyodb/sdk@1.5.1
34
34
  ```
35
35
 
36
36
  ```ts
@@ -93,8 +93,8 @@ export class WasmEngine {
93
93
  recover(): any;
94
94
  reset(): bigint;
95
95
  rollback_tx(tx_id: bigint): void;
96
- scan(tx_id: bigint, store: string, range: any): any;
97
96
  scan_cursor_next(cursor_id: number, max_rows: number, max_bytes: number): any;
97
+ scan(tx_id: bigint, store: string, range: any): any;
98
98
  set_change_feed_policy(tx_id: bigint, policy: any): void;
99
99
  set_failpoint(failpoint: any): void;
100
100
  set_schema_version(tx_id: bigint, version: bigint): void;
@@ -191,8 +191,8 @@ export interface InitOutput {
191
191
  readonly wasmengine_set_failpoint: (a: number, b: number, c: number) => void;
192
192
  readonly wasmengine_set_schema_version: (a: number, b: number, c: bigint, d: bigint) => void;
193
193
  readonly wasmengine_stats: (a: number, b: number) => void;
194
- readonly __wasm_bindgen_func_elem_915: (a: number, b: number, c: number, d: number) => void;
195
- readonly __wasm_bindgen_func_elem_930: (a: number, b: number, c: number, d: number) => void;
194
+ readonly __wasm_bindgen_func_elem_967: (a: number, b: number, c: number, d: number) => void;
195
+ readonly __wasm_bindgen_func_elem_982: (a: number, b: number, c: number, d: number) => void;
196
196
  readonly __wbindgen_export: (a: number, b: number) => number;
197
197
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
198
198
  readonly __wbindgen_export3: (a: number) => void;
@@ -1,5 +1,5 @@
1
1
  /* @ts-self-types="./moyodb_engine.d.ts" */
2
- import { opfsAppendOffset, opfsCleanupInactiveEntries, opfsCloseSession, opfsDbDirectorySize, opfsFlush, opfsLen, opfsOpenActiveDb, opfsOpenGenerationDb, opfsPrepareRebuildTarget, opfsReadActiveGeneration, opfsReadAtInto, opfsRemoveDb, opfsSwapActiveGeneration, opfsTruncate, opfsWriteAt } from './snippets/moyodb-engine-1d53039816cbc2f7/js/opfs_shim.js';
2
+ import { opfsAppendOffset, opfsCleanupInactiveEntries, opfsCloseSession, opfsDbDirectorySize, opfsFlush, opfsLen, opfsOpenActiveDb, opfsOpenGenerationDb, opfsPrepareRebuildTarget, opfsReadActiveGeneration, opfsReadAtInto, opfsRemoveDb, opfsSwapActiveGeneration, opfsTruncate, opfsWriteAt } from './snippets/moyodb-engine-e9fc900519b160aa/js/opfs_shim.js';
3
3
 
4
4
 
5
5
  export class WasmEngine {
@@ -977,17 +977,15 @@ export class WasmEngine {
977
977
  }
978
978
  }
979
979
  /**
980
- * @param {bigint} tx_id
981
- * @param {string} store
982
- * @param {any} range
980
+ * @param {number} cursor_id
981
+ * @param {number} max_rows
982
+ * @param {number} max_bytes
983
983
  * @returns {any}
984
984
  */
985
- scan(tx_id, store, range) {
985
+ scan_cursor_next(cursor_id, max_rows, max_bytes) {
986
986
  try {
987
987
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
988
- const ptr0 = passStringToWasm0(store, wasm.__wbindgen_export, wasm.__wbindgen_export2);
989
- const len0 = WASM_VECTOR_LEN;
990
- wasm.wasmengine_scan(retptr, this.__wbg_ptr, tx_id, ptr0, len0, addHeapObject(range));
988
+ wasm.wasmengine_scan_cursor_next(retptr, this.__wbg_ptr, cursor_id, max_rows, max_bytes);
991
989
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
992
990
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
993
991
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1000,15 +998,17 @@ export class WasmEngine {
1000
998
  }
1001
999
  }
1002
1000
  /**
1003
- * @param {number} cursor_id
1004
- * @param {number} max_rows
1005
- * @param {number} max_bytes
1001
+ * @param {bigint} tx_id
1002
+ * @param {string} store
1003
+ * @param {any} range
1006
1004
  * @returns {any}
1007
1005
  */
1008
- scan_cursor_next(cursor_id, max_rows, max_bytes) {
1006
+ scan(tx_id, store, range) {
1009
1007
  try {
1010
1008
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1011
- wasm.wasmengine_scan_cursor_next(retptr, this.__wbg_ptr, cursor_id, max_rows, max_bytes);
1009
+ const ptr0 = passStringToWasm0(store, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1010
+ const len0 = WASM_VECTOR_LEN;
1011
+ wasm.wasmengine_scan(retptr, this.__wbg_ptr, tx_id, ptr0, len0, addHeapObject(range));
1012
1012
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1013
1013
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1014
1014
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -1387,7 +1387,7 @@ function __wbg_get_imports() {
1387
1387
  const a = state0.a;
1388
1388
  state0.a = 0;
1389
1389
  try {
1390
- return __wasm_bindgen_func_elem_930(a, state0.b, arg0, arg1);
1390
+ return __wasm_bindgen_func_elem_982(a, state0.b, arg0, arg1);
1391
1391
  } finally {
1392
1392
  state0.a = a;
1393
1393
  }
@@ -1414,53 +1414,53 @@ function __wbg_get_imports() {
1414
1414
  const ret = Date.now();
1415
1415
  return ret;
1416
1416
  },
1417
- __wbg_opfsAppendOffset_68bb03935297d9db: function() { return handleError(function (arg0, arg1) {
1417
+ __wbg_opfsAppendOffset_59f1428d084f2fc2: function() { return handleError(function (arg0, arg1) {
1418
1418
  const ret = opfsAppendOffset(arg0 >>> 0, arg1 >>> 0);
1419
1419
  return ret;
1420
1420
  }, arguments) ?? 0n; },
1421
- __wbg_opfsCleanupInactiveEntries_ea82f341effa497d: function() { return handleError(function (arg0, arg1) {
1421
+ __wbg_opfsCleanupInactiveEntries_ce05ab3e3b1a9d52: function() { return handleError(function (arg0, arg1) {
1422
1422
  const ret = opfsCleanupInactiveEntries(getStringFromWasm0(arg0, arg1));
1423
1423
  return addHeapObject(ret);
1424
1424
  }, arguments); },
1425
- __wbg_opfsCloseSession_e8fb6e251703d6ee: function() { return handleError(function (arg0) {
1425
+ __wbg_opfsCloseSession_97c99e64af5ce259: function() { return handleError(function (arg0) {
1426
1426
  opfsCloseSession(arg0 >>> 0);
1427
1427
  }, arguments); },
1428
- __wbg_opfsDbDirectorySize_e355d3aa6e4ea90f: function() { return handleError(function (arg0, arg1) {
1428
+ __wbg_opfsDbDirectorySize_600a835c949ab66c: function() { return handleError(function (arg0, arg1) {
1429
1429
  const ret = opfsDbDirectorySize(getStringFromWasm0(arg0, arg1));
1430
1430
  return addHeapObject(ret);
1431
1431
  }, arguments); },
1432
- __wbg_opfsFlush_541e3d32f6cf55ac: function() { return handleError(function (arg0, arg1) {
1432
+ __wbg_opfsFlush_d963b4e76c5b8fa3: function() { return handleError(function (arg0, arg1) {
1433
1433
  opfsFlush(arg0 >>> 0, arg1 >>> 0);
1434
1434
  }, arguments); },
1435
- __wbg_opfsLen_054ec74e900922d9: function() { return handleError(function (arg0, arg1) {
1435
+ __wbg_opfsLen_0c5e7c77e5624afb: function() { return handleError(function (arg0, arg1) {
1436
1436
  const ret = opfsLen(arg0 >>> 0, arg1 >>> 0);
1437
1437
  return ret;
1438
1438
  }, arguments) ?? 0n; },
1439
- __wbg_opfsOpenActiveDb_7f5fecc61f745b3d: function() { return handleError(function (arg0, arg1, arg2) {
1439
+ __wbg_opfsOpenActiveDb_3905986c098f00da: function() { return handleError(function (arg0, arg1, arg2) {
1440
1440
  const ret = opfsOpenActiveDb(getStringFromWasm0(arg0, arg1), arg2 !== 0);
1441
1441
  return addHeapObject(ret);
1442
1442
  }, arguments); },
1443
- __wbg_opfsOpenGenerationDb_876413305f4f1fe7: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1443
+ __wbg_opfsOpenGenerationDb_3343567a07e924ed: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1444
1444
  const ret = opfsOpenGenerationDb(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), arg4 !== 0);
1445
1445
  return addHeapObject(ret);
1446
1446
  }, arguments); },
1447
- __wbg_opfsPrepareRebuildTarget_ee80037de2c17503: function() { return handleError(function (arg0, arg1) {
1447
+ __wbg_opfsPrepareRebuildTarget_63ba233664d3d747: function() { return handleError(function (arg0, arg1) {
1448
1448
  const ret = opfsPrepareRebuildTarget(getStringFromWasm0(arg0, arg1));
1449
1449
  return addHeapObject(ret);
1450
1450
  }, arguments); },
1451
- __wbg_opfsReadActiveGeneration_b27b6bb9024cb2fb: function() { return handleError(function (arg0, arg1) {
1451
+ __wbg_opfsReadActiveGeneration_118ed01560c820ee: function() { return handleError(function (arg0, arg1) {
1452
1452
  const ret = opfsReadActiveGeneration(getStringFromWasm0(arg0, arg1));
1453
1453
  return addHeapObject(ret);
1454
1454
  }, arguments); },
1455
- __wbg_opfsReadAtInto_846a150e2cdf5e92: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1455
+ __wbg_opfsReadAtInto_1e7f1ddf0e566bc3: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1456
1456
  const ret = opfsReadAtInto(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2), getArrayU8FromWasm0(arg3, arg4));
1457
1457
  return ret;
1458
1458
  }, arguments); },
1459
- __wbg_opfsRemoveDb_41e6a0ff05ecec6d: function() { return handleError(function (arg0, arg1) {
1459
+ __wbg_opfsRemoveDb_38b7c57135a41df4: function() { return handleError(function (arg0, arg1) {
1460
1460
  const ret = opfsRemoveDb(getStringFromWasm0(arg0, arg1));
1461
1461
  return addHeapObject(ret);
1462
1462
  }, arguments); },
1463
- __wbg_opfsSwapActiveGeneration_88a88a11e82b002c: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
1463
+ __wbg_opfsSwapActiveGeneration_f92ff0f5be554381: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4, arg5) {
1464
1464
  let v0;
1465
1465
  if (arg4 !== 0) {
1466
1466
  v0 = getStringFromWasm0(arg4, arg5);
@@ -1469,10 +1469,10 @@ function __wbg_get_imports() {
1469
1469
  const ret = opfsSwapActiveGeneration(getStringFromWasm0(arg0, arg1), getStringFromWasm0(arg2, arg3), v0);
1470
1470
  return addHeapObject(ret);
1471
1471
  }, arguments); },
1472
- __wbg_opfsTruncate_089325c9096b2f99: function() { return handleError(function (arg0, arg1, arg2) {
1472
+ __wbg_opfsTruncate_2e99fcc5c22b4fa9: function() { return handleError(function (arg0, arg1, arg2) {
1473
1473
  opfsTruncate(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2));
1474
1474
  }, arguments); },
1475
- __wbg_opfsWriteAt_4c805bf06b2cae54: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1475
+ __wbg_opfsWriteAt_fe70b772024843f0: function() { return handleError(function (arg0, arg1, arg2, arg3, arg4) {
1476
1476
  const ret = opfsWriteAt(arg0 >>> 0, arg1 >>> 0, BigInt.asUintN(64, arg2), getArrayU8FromWasm0(arg3, arg4));
1477
1477
  return ret;
1478
1478
  }, arguments); },
@@ -1530,7 +1530,7 @@ function __wbg_get_imports() {
1530
1530
  },
1531
1531
  __wbindgen_generic_0000000000000001: function(arg0, arg1) {
1532
1532
  // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 113, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1533
- const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_915);
1533
+ const ret = makeMutClosure(arg0, arg1, __wasm_bindgen_func_elem_967);
1534
1534
  return addHeapObject(ret);
1535
1535
  },
1536
1536
  __wbindgen_generic_0000000000000002: function(arg0) {
@@ -1572,14 +1572,14 @@ function __wbg_get_imports() {
1572
1572
  };
1573
1573
  }
1574
1574
 
1575
- function __wasm_bindgen_func_elem_930(arg0, arg1, arg2, arg3) {
1576
- wasm.__wasm_bindgen_func_elem_930(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1575
+ function __wasm_bindgen_func_elem_982(arg0, arg1, arg2, arg3) {
1576
+ wasm.__wasm_bindgen_func_elem_982(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
1577
1577
  }
1578
1578
 
1579
- function __wasm_bindgen_func_elem_915(arg0, arg1, arg2) {
1579
+ function __wasm_bindgen_func_elem_967(arg0, arg1, arg2) {
1580
1580
  try {
1581
1581
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1582
- wasm.__wasm_bindgen_func_elem_915(retptr, arg0, arg1, addHeapObject(arg2));
1582
+ wasm.__wasm_bindgen_func_elem_967(retptr, arg0, arg1, addHeapObject(arg2));
1583
1583
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1584
1584
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1585
1585
  if (r1) {
Binary file
@@ -60,8 +60,8 @@ export const wasmengine_set_change_feed_policy: (a: number, b: number, c: bigint
60
60
  export const wasmengine_set_failpoint: (a: number, b: number, c: number) => void;
61
61
  export const wasmengine_set_schema_version: (a: number, b: number, c: bigint, d: bigint) => void;
62
62
  export const wasmengine_stats: (a: number, b: number) => void;
63
- export const __wasm_bindgen_func_elem_915: (a: number, b: number, c: number, d: number) => void;
64
- export const __wasm_bindgen_func_elem_930: (a: number, b: number, c: number, d: number) => void;
63
+ export const __wasm_bindgen_func_elem_967: (a: number, b: number, c: number, d: number) => void;
64
+ export const __wasm_bindgen_func_elem_982: (a: number, b: number, c: number, d: number) => void;
65
65
  export const __wbindgen_export: (a: number, b: number) => number;
66
66
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
67
67
  export const __wbindgen_export3: (a: number) => void;
@@ -2,7 +2,7 @@
2
2
  "name": "moyodb-engine",
3
3
  "type": "module",
4
4
  "description": "Rust/WASM transactional storage engine for browser and native file runtimes.",
5
- "version": "1.4.0",
5
+ "version": "1.5.1",
6
6
  "license": "SEE LICENSE IN ../../LICENSE",
7
7
  "repository": {
8
8
  "type": "git",
@@ -107,10 +107,13 @@ export function writeAll(handle, bytes, at) {
107
107
  return writtenTotal;
108
108
  }
109
109
  // Reads until the buffer is full or a read returns zero. The unread suffix is unchanged.
110
+ // The first attempt borrows the caller view. A short read retries through a suffix
111
+ // view so bytes already stored stay put without copying them.
110
112
  export function readAll(handle, buffer, at) {
111
113
  let readTotal = 0;
112
114
  while (readTotal < buffer.length) {
113
- const rawRead = handle.read(buffer.subarray(readTotal), { at: at + readTotal });
115
+ const chunk = readTotal === 0 ? buffer : buffer.subarray(readTotal);
116
+ const rawRead = handle.read(chunk, { at: at + readTotal });
114
117
  const read = Number(rawRead);
115
118
  if (!Number.isSafeInteger(read) || read < 0 || read > buffer.length - readTotal) {
116
119
  throw namedError('StorageError', `opfs read failed: invalid byte count ${String(rawRead)}`);
@@ -192,7 +195,10 @@ export function readControlStateFromAccessHandle(accessHandle) {
192
195
  return { status: 'absent', control: null };
193
196
  }
194
197
  const buffer = new Uint8Array(CONTROL_SLOT_SIZE * 2);
195
- readAll(accessHandle, buffer.subarray(0, Math.min(buffer.length, size)), 0);
198
+ // A short file must not be presented as a full two-slot buffer. A file that
199
+ // already covers both slots can be read through the allocated buffer itself.
200
+ const readable = size < buffer.length ? buffer.subarray(0, size) : buffer;
201
+ readAll(accessHandle, readable, 0);
196
202
  const slot0 = decodeControlSlot(0, buffer.subarray(0, CONTROL_SLOT_SIZE));
197
203
  const slot1 = decodeControlSlot(1, buffer.subarray(CONTROL_SLOT_SIZE, CONTROL_SLOT_SIZE * 2));
198
204
  if (slot0 && slot1) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAMR,EAAE,EAOF,WAAW,EAYd,MAAM,SAAS,CAAC;AACjB,OAAO,EASH,KAAK,aAAa,EACrB,MAAM,YAAY,CAAC;AA0+BpB,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,WAAgB,GAAG,OAAO,CAAC,EAAE,CAAC,CAMjF;AACD,wBAAsB,gBAAgB,CAClC,IAAI,EAAE,MAAM,EACZ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AY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,OAAO,CAAC;AACtB,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,mBAAmB,aAAa,CAAC;AACjC,mBAAmB,SAAS,CAAC"}
@@ -25,6 +25,13 @@ export declare function decodeIndexMetadataValue(bytes: Uint8Array): NormalizedI
25
25
  export declare function encodeIndexEntryKey(logicalIndexKey: Uint8Array, primaryKey: Uint8Array): Uint8Array;
26
26
  export declare function decodeIndexEntryKey(bytes: Uint8Array): DecodedIndexEntryKey;
27
27
  export declare function indexKeyExactRange(logicalIndexKey: Uint8Array): Range;
28
+ /** WASM `usize` is 32-bit, so this is the largest limit the engine can accept. */
29
+ export declare const MAX_ENGINE_SCAN_LIMIT = 4294967295;
30
+ /**
31
+ * Bounds and limits follow the engine `RangeSpec` contract.
32
+ * Conflicting bounds and a limit the engine cannot store are `InvalidRangeError`.
33
+ */
34
+ export declare function assertValidScanRange(range?: Range): void;
28
35
  export declare function indexRangeToPhysicalRange(range?: Range): Range;
29
36
  export declare function extractLogicalIndexKey(def: NormalizedIndexDef, valueBytes: Uint8Array): Uint8Array | null;
30
37
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"indexing.d.ts","sourceRoot":"","sources":["../src/indexing.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAS/C,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AAC1D,MAAM,WAAW,kBAAkB;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;CACzB;AACD,MAAM,WAAW,oBAAoB;IACjC,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;CAC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