@powersync/web 1.25.1 → 1.26.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 (31) hide show
  1. package/dist/31ba59416bad61e8fb1f.wasm +0 -0
  2. package/dist/d0a1e43030b814ed322f.wasm +0 -0
  3. package/dist/f4ad8bfeb6e6e5326142.wasm +0 -0
  4. package/dist/fbde47713220d7baec73.wasm +0 -0
  5. package/dist/index.umd.js +12 -60
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/worker/SharedSyncImplementation.umd.js +83 -80
  8. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  9. package/dist/worker/WASQLiteDB.umd.js +83 -80
  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 +3 -15
  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 +3 -15
  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 +3 -15
  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 +3 -15
  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 +218 -46
  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 +218 -46
  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 +218 -46
  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/tsconfig.tsbuildinfo +1 -1
  27. package/package.json +5 -5
  28. package/dist/2dcb8a60ed4b341d3046.wasm +0 -0
  29. package/dist/50eaffc7435d7a77ffb5.wasm +0 -0
  30. package/dist/88ca2d3820062df8ea26.wasm +0 -0
  31. package/dist/efe40e50208db1807722.wasm +0 -0
@@ -458,64 +458,30 @@ 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 DataView. A Proxy
462
- * wrapper prevents use of incorrect type or endianness.
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.
463
464
  * @param {'Int32'|'BigInt64'} type
464
465
  * @param {number} byteOffset
465
466
  * @returns {DataView}
466
467
  */
467
468
  #makeTypedDataView(type, byteOffset) {
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
- });
469
+ // @ts-ignore
470
+ return new DataViewProxy(this._module, byteOffset, type);
501
471
  }
502
472
 
503
473
  /**
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.
504
478
  * @param {number} byteOffset
505
479
  * @param {number} byteLength
480
+ * @returns {Uint8Array}
506
481
  */
507
482
  #makeDataArray(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
- });
483
+ // @ts-ignore
484
+ return new Uint8ArrayProxy(this._module, byteOffset, byteLength);
519
485
  }
520
486
 
521
487
  #decodeFilename(zName, flags) {
@@ -560,6 +526,212 @@ function delegalize(lo32, hi32) {
560
526
  return (hi32 * 0x100000000) + lo32 + (lo32 < 0 ? 2**32 : 0);
561
527
  }
562
528
 
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
+ }
563
735
 
564
736
  /***/ }),
565
737