@powersync/web 0.0.0-dev-20250916075127 → 0.0.0-dev-20250922105207

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 (40) hide show
  1. package/dist/2dcb8a60ed4b341d3046.wasm +0 -0
  2. package/dist/50eaffc7435d7a77ffb5.wasm +0 -0
  3. package/dist/88ca2d3820062df8ea26.wasm +0 -0
  4. package/dist/efe40e50208db1807722.wasm +0 -0
  5. package/dist/index.umd.js +95 -16
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/worker/SharedSyncImplementation.umd.js +10 -10
  8. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  9. package/dist/worker/WASQLiteDB.umd.js +152 -41
  10. package/dist/worker/WASQLiteDB.umd.js.map +1 -1
  11. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js +15 -3
  12. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite-async_mjs.umd.js.map +1 -1
  13. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js +15 -3
  14. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_mc-wa-sqlite_mjs.umd.js.map +1 -1
  15. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js +15 -3
  16. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite-async_mjs.umd.js.map +1 -1
  17. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js +15 -3
  18. package/dist/worker/node_modules_journeyapps_wa-sqlite_dist_wa-sqlite_mjs.umd.js.map +1 -1
  19. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js +46 -218
  20. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_AccessHandlePoolVFS_js.umd.js.map +1 -1
  21. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js +46 -218
  22. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js.umd.js.map +1 -1
  23. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js +46 -218
  24. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js.map +1 -1
  25. package/lib/package.json +4 -4
  26. package/lib/src/db/PowerSyncDatabase.js +1 -0
  27. package/lib/src/db/adapters/AsyncDatabaseConnection.d.ts +13 -1
  28. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.d.ts +3 -1
  29. package/lib/src/db/adapters/wa-sqlite/WASQLiteConnection.js +28 -2
  30. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.d.ts +1 -1
  31. package/lib/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.js +6 -2
  32. package/lib/src/worker/db/LogHandler.d.ts +12 -0
  33. package/lib/src/worker/db/LogHandler.js +6 -0
  34. package/lib/src/worker/db/WASQLiteDB.worker.js +80 -17
  35. package/lib/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +5 -5
  37. package/dist/31ba59416bad61e8fb1f.wasm +0 -0
  38. package/dist/d0a1e43030b814ed322f.wasm +0 -0
  39. package/dist/f4ad8bfeb6e6e5326142.wasm +0 -0
  40. package/dist/fbde47713220d7baec73.wasm +0 -0
@@ -458,30 +458,64 @@ class FacadeVFS extends _VFS_js__WEBPACK_IMPORTED_MODULE_0__.Base {
458
458
 
459
459
  /**
460
460
  * Wrapped DataView for pointer arguments.
461
- * Pointers to a single value are passed using a DataView-like class.
462
- * This wrapper class prevents use of incorrect type or endianness, and
463
- * reacquires the underlying buffer when the WebAssembly memory is resized.
461
+ * Pointers to a single value are passed using DataView. A Proxy
462
+ * wrapper prevents use of incorrect type or endianness.
464
463
  * @param {'Int32'|'BigInt64'} type
465
464
  * @param {number} byteOffset
466
465
  * @returns {DataView}
467
466
  */
468
467
  #makeTypedDataView(type, byteOffset) {
469
- // @ts-ignore
470
- return new DataViewProxy(this._module, byteOffset, type);
468
+ const byteLength = type === 'Int32' ? 4 : 8;
469
+ const getter = `get${type}`;
470
+ const setter = `set${type}`;
471
+ const makeDataView = () => new DataView(
472
+ this._module.HEAPU8.buffer,
473
+ this._module.HEAPU8.byteOffset + byteOffset,
474
+ byteLength);
475
+ let dataView = makeDataView();
476
+ return new Proxy(dataView, {
477
+ get(_, prop) {
478
+ if (dataView.buffer.byteLength === 0) {
479
+ // WebAssembly memory resize detached the buffer.
480
+ dataView = makeDataView();
481
+ }
482
+ if (prop === getter) {
483
+ return function(byteOffset, littleEndian) {
484
+ if (!littleEndian) throw new Error('must be little endian');
485
+ return dataView[prop](byteOffset, littleEndian);
486
+ }
487
+ }
488
+ if (prop === setter) {
489
+ return function(byteOffset, value, littleEndian) {
490
+ if (!littleEndian) throw new Error('must be little endian');
491
+ return dataView[prop](byteOffset, value, littleEndian);
492
+ }
493
+ }
494
+ if (typeof prop === 'string' && (prop.match(/^(get)|(set)/))) {
495
+ throw new Error('invalid type');
496
+ }
497
+ const result = dataView[prop];
498
+ return typeof result === 'function' ? result.bind(dataView) : result;
499
+ }
500
+ });
471
501
  }
472
502
 
473
503
  /**
474
- * Wrapped Uint8Array for buffer arguments.
475
- * Memory blocks are passed as a Uint8Array-like class. This wrapper
476
- * class reacquires the underlying buffer when the WebAssembly memory
477
- * is resized.
478
504
  * @param {number} byteOffset
479
505
  * @param {number} byteLength
480
- * @returns {Uint8Array}
481
506
  */
482
507
  #makeDataArray(byteOffset, byteLength) {
483
- // @ts-ignore
484
- return new Uint8ArrayProxy(this._module, byteOffset, byteLength);
508
+ let target = this._module.HEAPU8.subarray(byteOffset, byteOffset + byteLength);
509
+ return new Proxy(target, {
510
+ get: (_, prop, receiver) => {
511
+ if (target.buffer.byteLength === 0) {
512
+ // WebAssembly memory resize detached the buffer.
513
+ target = this._module.HEAPU8.subarray(byteOffset, byteOffset + byteLength);
514
+ }
515
+ const result = target[prop];
516
+ return typeof result === 'function' ? result.bind(target) : result;
517
+ }
518
+ });
485
519
  }
486
520
 
487
521
  #decodeFilename(zName, flags) {
@@ -526,212 +560,6 @@ function delegalize(lo32, hi32) {
526
560
  return (hi32 * 0x100000000) + lo32 + (lo32 < 0 ? 2**32 : 0);
527
561
  }
528
562
 
529
- // This class provides a Uint8Array-like interface for a WebAssembly memory
530
- // buffer. It is used to access memory blocks passed as arguments to
531
- // xRead, xWrite, etc. The class reacquires the underlying buffer when the
532
- // WebAssembly memory is resized, which can happen when the memory is
533
- // detached and resized by the WebAssembly module.
534
- //
535
- // Note that although this class implements the same methods as Uint8Array,
536
- // it is not a real Uint8Array and passing it to functions that expect
537
- // a Uint8Array may not work. Use subarray() to get a real Uint8Array
538
- // if needed.
539
- class Uint8ArrayProxy {
540
- #module;
541
-
542
- #_array = new Uint8Array()
543
- get #array() {
544
- if (this.#_array.buffer.byteLength === 0) {
545
- // WebAssembly memory resize detached the buffer so re-create the
546
- // array with the new buffer.
547
- this.#_array = this.#module.HEAPU8.subarray(
548
- this.byteOffset,
549
- this.byteOffset + this.byteLength);
550
- }
551
- return this.#_array;
552
- }
553
-
554
- /**
555
- * @param {*} module
556
- * @param {number} byteOffset
557
- * @param {number} byteLength
558
- */
559
- constructor(module, byteOffset, byteLength) {
560
- this.#module = module;
561
- this.byteOffset = byteOffset;
562
- this.length = this.byteLength = byteLength;
563
- }
564
-
565
- get buffer() {
566
- return this.#array.buffer;
567
- }
568
-
569
- at(index) {
570
- return this.#array.at(index);
571
- }
572
- copyWithin(target, start, end) {
573
- this.#array.copyWithin(target, start, end);
574
- }
575
- entries() {
576
- return this.#array.entries();
577
- }
578
- every(predicate) {
579
- return this.#array.every(predicate);
580
- }
581
- fill(value, start, end) {
582
- this.#array.fill(value, start, end);
583
- }
584
- filter(predicate) {
585
- return this.#array.filter(predicate);
586
- }
587
- find(predicate) {
588
- return this.#array.find(predicate);
589
- }
590
- findIndex(predicate) {
591
- return this.#array.findIndex(predicate);
592
- }
593
- findLast(predicate) {
594
- return this.#array.findLast(predicate);
595
- }
596
- findLastIndex(predicate) {
597
- return this.#array.findLastIndex(predicate);
598
- }
599
- forEach(callback) {
600
- this.#array.forEach(callback);
601
- }
602
- includes(value, start) {
603
- return this.#array.includes(value, start);
604
- }
605
- indexOf(value, start) {
606
- return this.#array.indexOf(value, start);
607
- }
608
- join(separator) {
609
- return this.#array.join(separator);
610
- }
611
- keys() {
612
- return this.#array.keys();
613
- }
614
- lastIndexOf(value, start) {
615
- return this.#array.lastIndexOf(value, start);
616
- }
617
- map(callback) {
618
- return this.#array.map(callback);
619
- }
620
- reduce(callback, initialValue) {
621
- return this.#array.reduce(callback, initialValue);
622
- }
623
- reduceRight(callback, initialValue) {
624
- return this.#array.reduceRight(callback, initialValue);
625
- }
626
- reverse() {
627
- this.#array.reverse();
628
- }
629
- set(array, offset) {
630
- this.#array.set(array, offset);
631
- }
632
- slice(start, end) {
633
- return this.#array.slice(start, end);
634
- }
635
- some(predicate) {
636
- return this.#array.some(predicate);
637
- }
638
- sort(compareFn) {
639
- this.#array.sort(compareFn);
640
- }
641
- subarray(begin, end) {
642
- return this.#array.subarray(begin, end);
643
- }
644
- toLocaleString(locales, options) {
645
- // @ts-ignore
646
- return this.#array.toLocaleString(locales, options);
647
- }
648
- toReversed() {
649
- return this.#array.toReversed();
650
- }
651
- toSorted(compareFn) {
652
- return this.#array.toSorted(compareFn);
653
- }
654
- toString() {
655
- return this.#array.toString();
656
- }
657
- values() {
658
- return this.#array.values();
659
- }
660
- with(index, value) {
661
- return this.#array.with(index, value);
662
- }
663
- [Symbol.iterator]() {
664
- return this.#array[Symbol.iterator]();
665
- }
666
- }
667
-
668
- // This class provides a DataView-like interface for a WebAssembly memory
669
- // buffer, restricted to either Int32 or BigInt64 types. It also reacquires
670
- // the underlying buffer when the WebAssembly memory is resized, which can
671
- // happen when the memory is detached and resized by the WebAssembly module.
672
- class DataViewProxy {
673
- #module;
674
- #type;
675
-
676
- #_view = new DataView(new ArrayBuffer(0));
677
- get #view() {
678
- if (this.#_view.buffer.byteLength === 0) {
679
- // WebAssembly memory resize detached the buffer so re-create the
680
- // view with the new buffer.
681
- this.#_view = new DataView(
682
- this.#module.HEAPU8.buffer,
683
- this.#module.HEAPU8.byteOffset + this.byteOffset);
684
- }
685
- return this.#_view;
686
- }
687
-
688
- /**
689
- * @param {*} module
690
- * @param {number} byteOffset
691
- * @param {'Int32'|'BigInt64'} type
692
- */
693
- constructor(module, byteOffset, type) {
694
- this.#module = module;
695
- this.byteOffset = byteOffset;
696
- this.#type = type;
697
- }
698
-
699
- get buffer() {
700
- return this.#view.buffer;
701
- }
702
- get byteLength() {
703
- return this.#type === 'Int32' ? 4 : 8;
704
- }
705
-
706
- getInt32(byteOffset, littleEndian) {
707
- if (this.#type !== 'Int32') {
708
- throw new Error('invalid type');
709
- }
710
- if (!littleEndian) throw new Error('must be little endian');
711
- return this.#view.getInt32(byteOffset, littleEndian);
712
- }
713
- setInt32(byteOffset, value, littleEndian) {
714
- if (this.#type !== 'Int32') {
715
- throw new Error('invalid type');
716
- }
717
- if (!littleEndian) throw new Error('must be little endian');
718
- this.#view.setInt32(byteOffset, value, littleEndian);
719
- }
720
- getBigInt64(byteOffset, littleEndian) {
721
- if (this.#type !== 'BigInt64') {
722
- throw new Error('invalid type');
723
- }
724
- if (!littleEndian) throw new Error('must be little endian');
725
- return this.#view.getBigInt64(byteOffset, littleEndian);
726
- }
727
- setBigInt64(byteOffset, value, littleEndian) {
728
- if (this.#type !== 'BigInt64') {
729
- throw new Error('invalid type');
730
- }
731
- if (!littleEndian) throw new Error('must be little endian');
732
- this.#view.setBigInt64(byteOffset, value, littleEndian);
733
- }
734
- }
735
563
 
736
564
  /***/ }),
737
565