@powersync/web 1.25.0 → 1.26.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.
Files changed (34) hide show
  1. package/dist/1e160d3e77d39f686b3c.wasm +0 -0
  2. package/dist/354f119c1a8982b0100f.wasm +0 -0
  3. package/dist/3a9592de41d4b5afa787.wasm +0 -0
  4. package/dist/d56cac2067625f83be92.wasm +0 -0
  5. package/dist/index.umd.js +117 -165
  6. package/dist/index.umd.js.map +1 -1
  7. package/dist/worker/SharedSyncImplementation.umd.js +84 -81
  8. package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
  9. package/dist/worker/WASQLiteDB.umd.js +2445 -2442
  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 +11 -23
  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 +11 -23
  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 +11 -23
  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 +11 -23
  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 +234 -62
  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 +240 -68
  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 +234 -62
  24. package/dist/worker/node_modules_journeyapps_wa-sqlite_src_examples_OPFSCoopSyncVFS_js.umd.js.map +1 -1
  25. package/lib/package.json +5 -5
  26. package/lib/src/db/PowerSyncDatabase.d.ts +1 -1
  27. package/lib/src/db/sync/WebStreamingSyncImplementation.js +1 -1
  28. package/lib/src/worker/db/WASQLiteDB.worker.js +3 -3
  29. package/lib/tsconfig.tsbuildinfo +1 -1
  30. package/package.json +6 -6
  31. package/dist/2dcb8a60ed4b341d3046.wasm +0 -0
  32. package/dist/50eaffc7435d7a77ffb5.wasm +0 -0
  33. package/dist/88ca2d3820062df8ea26.wasm +0 -0
  34. package/dist/efe40e50208db1807722.wasm +0 -0
@@ -1,17 +1,17 @@
1
1
  "use strict";
2
2
  (self["webpackChunksdk_web"] = self["webpackChunksdk_web"] || []).push([["node_modules_journeyapps_wa-sqlite_src_examples_IDBBatchAtomicVFS_js"],{
3
3
 
4
- /***/ "./node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js":
5
- /*!**************************************************************!*\
6
- !*** ./node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js ***!
7
- \**************************************************************/
4
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js":
5
+ /*!******************************************************************!*\
6
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js ***!
7
+ \******************************************************************/
8
8
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
9
9
 
10
10
  __webpack_require__.r(__webpack_exports__);
11
11
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
12
12
  /* harmony export */ FacadeVFS: () => (/* binding */ FacadeVFS)
13
13
  /* harmony export */ });
14
- /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "./node_modules/@journeyapps/wa-sqlite/src/VFS.js");
14
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js");
15
15
  // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
16
16
 
17
17
 
@@ -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,13 +526,219 @@ 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
 
566
- /***/ "./node_modules/@journeyapps/wa-sqlite/src/VFS.js":
567
- /*!********************************************************!*\
568
- !*** ./node_modules/@journeyapps/wa-sqlite/src/VFS.js ***!
569
- \********************************************************/
738
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js":
739
+ /*!************************************************************!*\
740
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/VFS.js ***!
741
+ \************************************************************/
570
742
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
571
743
 
572
744
  __webpack_require__.r(__webpack_exports__);
@@ -806,7 +978,7 @@ __webpack_require__.r(__webpack_exports__);
806
978
  /* harmony export */ SQLITE_UTF8: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_UTF8),
807
979
  /* harmony export */ SQLITE_WARNING: () => (/* reexport safe */ _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__.SQLITE_WARNING)
808
980
  /* harmony export */ });
809
- /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "./node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
981
+ /* harmony import */ var _sqlite_constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sqlite-constants.js */ "../../node_modules/@journeyapps/wa-sqlite/src/sqlite-constants.js");
810
982
  // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
811
983
 
812
984
 
@@ -1032,17 +1204,17 @@ const FILE_TYPE_MASK = [
1032
1204
 
1033
1205
  /***/ }),
1034
1206
 
1035
- /***/ "./node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js":
1036
- /*!******************************************************************!*\
1037
- !*** ./node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js ***!
1038
- \******************************************************************/
1207
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js":
1208
+ /*!**********************************************************************!*\
1209
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js ***!
1210
+ \**********************************************************************/
1039
1211
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1040
1212
 
1041
1213
  __webpack_require__.r(__webpack_exports__);
1042
1214
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
1043
1215
  /* harmony export */ WebLocksMixin: () => (/* binding */ WebLocksMixin)
1044
1216
  /* harmony export */ });
1045
- /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "./node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1217
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./VFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1046
1218
 
1047
1219
 
1048
1220
  // Options for navigator.locks.request().
@@ -1460,10 +1632,10 @@ WebLocksMixin.WRITE_HINT_OP_CODE = -9999;
1460
1632
 
1461
1633
  /***/ }),
1462
1634
 
1463
- /***/ "./node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js":
1464
- /*!*******************************************************************************!*\
1465
- !*** ./node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js ***!
1466
- \*******************************************************************************/
1635
+ /***/ "../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js":
1636
+ /*!***********************************************************************************!*\
1637
+ !*** ../../node_modules/@journeyapps/wa-sqlite/src/examples/IDBBatchAtomicVFS.js ***!
1638
+ \***********************************************************************************/
1467
1639
  /***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => {
1468
1640
 
1469
1641
  __webpack_require__.r(__webpack_exports__);
@@ -1471,9 +1643,9 @@ __webpack_require__.r(__webpack_exports__);
1471
1643
  /* harmony export */ IDBBatchAtomicVFS: () => (/* binding */ IDBBatchAtomicVFS),
1472
1644
  /* harmony export */ IDBContext: () => (/* binding */ IDBContext)
1473
1645
  /* harmony export */ });
1474
- /* harmony import */ var _FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../FacadeVFS.js */ "./node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js");
1475
- /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../VFS.js */ "./node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1476
- /* harmony import */ var _WebLocksMixin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WebLocksMixin.js */ "./node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js");
1646
+ /* harmony import */ var _FacadeVFS_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../FacadeVFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/FacadeVFS.js");
1647
+ /* harmony import */ var _VFS_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../VFS.js */ "../../node_modules/@journeyapps/wa-sqlite/src/VFS.js");
1648
+ /* harmony import */ var _WebLocksMixin_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../WebLocksMixin.js */ "../../node_modules/@journeyapps/wa-sqlite/src/WebLocksMixin.js");
1477
1649
  // Copyright 2024 Roy T. Hashimoto. All Rights Reserved.
1478
1650
 
1479
1651