@powersync/web 1.28.0 → 1.28.2
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/dist/index.umd.js +64 -26
- package/dist/index.umd.js.map +1 -1
- package/dist/worker/SharedSyncImplementation.umd.js +13651 -440
- package/dist/worker/SharedSyncImplementation.umd.js.map +1 -1
- package/dist/worker/WASQLiteDB.umd.js +13478 -161
- package/dist/worker/WASQLiteDB.umd.js.map +1 -1
- package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js +66 -38
- package/dist/worker/node_modules_bson_lib_bson_mjs.umd.js.map +1 -1
- package/lib/package.json +6 -5
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -6
- package/src/db/PowerSyncDatabase.ts +224 -0
- package/src/db/adapters/AbstractWebPowerSyncDatabaseOpenFactory.ts +47 -0
- package/src/db/adapters/AbstractWebSQLOpenFactory.ts +48 -0
- package/src/db/adapters/AsyncDatabaseConnection.ts +40 -0
- package/src/db/adapters/LockedAsyncDatabaseAdapter.ts +358 -0
- package/src/db/adapters/SSRDBAdapter.ts +94 -0
- package/src/db/adapters/WebDBAdapter.ts +20 -0
- package/src/db/adapters/WorkerWrappedAsyncDatabaseConnection.ts +175 -0
- package/src/db/adapters/wa-sqlite/WASQLiteConnection.ts +444 -0
- package/src/db/adapters/wa-sqlite/WASQLiteDBAdapter.ts +86 -0
- package/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts +134 -0
- package/src/db/adapters/wa-sqlite/WASQLitePowerSyncDatabaseOpenFactory.ts +24 -0
- package/src/db/adapters/web-sql-flags.ts +135 -0
- package/src/db/sync/SSRWebStreamingSyncImplementation.ts +89 -0
- package/src/db/sync/SharedWebStreamingSyncImplementation.ts +274 -0
- package/src/db/sync/WebRemote.ts +59 -0
- package/src/db/sync/WebStreamingSyncImplementation.ts +34 -0
- package/src/db/sync/userAgent.ts +78 -0
- package/src/index.ts +13 -0
- package/src/shared/navigator.ts +9 -0
- package/src/worker/db/WASQLiteDB.worker.ts +112 -0
- package/src/worker/db/open-worker-database.ts +62 -0
- package/src/worker/sync/AbstractSharedSyncClientProvider.ts +21 -0
- package/src/worker/sync/BroadcastLogger.ts +142 -0
- package/src/worker/sync/SharedSyncImplementation.ts +520 -0
- package/src/worker/sync/SharedSyncImplementation.worker.ts +14 -0
- package/src/worker/sync/WorkerClient.ts +106 -0
- package/dist/worker/node_modules_crypto-browserify_index_js.umd.js +0 -33734
- package/dist/worker/node_modules_crypto-browserify_index_js.umd.js.map +0 -1
package/dist/index.umd.js
CHANGED
|
@@ -18063,6 +18063,7 @@ class Binary extends BSONValue {
|
|
|
18063
18063
|
if (this.buffer[0] !== Binary.VECTOR_TYPE.Int8) {
|
|
18064
18064
|
throw new BSONError('Binary datatype field is not Int8');
|
|
18065
18065
|
}
|
|
18066
|
+
validateBinaryVector(this);
|
|
18066
18067
|
return new Int8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
18067
18068
|
}
|
|
18068
18069
|
toFloat32Array() {
|
|
@@ -18072,6 +18073,7 @@ class Binary extends BSONValue {
|
|
|
18072
18073
|
if (this.buffer[0] !== Binary.VECTOR_TYPE.Float32) {
|
|
18073
18074
|
throw new BSONError('Binary datatype field is not Float32');
|
|
18074
18075
|
}
|
|
18076
|
+
validateBinaryVector(this);
|
|
18075
18077
|
const floatBytes = new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
18076
18078
|
if (NumberUtils.isBigEndian)
|
|
18077
18079
|
ByteUtils.swap32(floatBytes);
|
|
@@ -18084,6 +18086,7 @@ class Binary extends BSONValue {
|
|
|
18084
18086
|
if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
|
|
18085
18087
|
throw new BSONError('Binary datatype field is not packed bit');
|
|
18086
18088
|
}
|
|
18089
|
+
validateBinaryVector(this);
|
|
18087
18090
|
return new Uint8Array(this.buffer.buffer.slice(this.buffer.byteOffset + 2, this.buffer.byteOffset + this.position));
|
|
18088
18091
|
}
|
|
18089
18092
|
toBits() {
|
|
@@ -18093,6 +18096,7 @@ class Binary extends BSONValue {
|
|
|
18093
18096
|
if (this.buffer[0] !== Binary.VECTOR_TYPE.PackedBit) {
|
|
18094
18097
|
throw new BSONError('Binary datatype field is not packed bit');
|
|
18095
18098
|
}
|
|
18099
|
+
validateBinaryVector(this);
|
|
18096
18100
|
const byteCount = this.length() - 2;
|
|
18097
18101
|
const bitCount = byteCount * 8 - this.buffer[1];
|
|
18098
18102
|
const bits = new Int8Array(bitCount);
|
|
@@ -18111,7 +18115,9 @@ class Binary extends BSONValue {
|
|
|
18111
18115
|
buffer[1] = 0;
|
|
18112
18116
|
const intBytes = new Uint8Array(array.buffer, array.byteOffset, array.byteLength);
|
|
18113
18117
|
buffer.set(intBytes, 2);
|
|
18114
|
-
|
|
18118
|
+
const bin = new this(buffer, this.SUBTYPE_VECTOR);
|
|
18119
|
+
validateBinaryVector(bin);
|
|
18120
|
+
return bin;
|
|
18115
18121
|
}
|
|
18116
18122
|
static fromFloat32Array(array) {
|
|
18117
18123
|
const binaryBytes = ByteUtils.allocate(array.byteLength + 2);
|
|
@@ -18121,14 +18127,18 @@ class Binary extends BSONValue {
|
|
|
18121
18127
|
binaryBytes.set(floatBytes, 2);
|
|
18122
18128
|
if (NumberUtils.isBigEndian)
|
|
18123
18129
|
ByteUtils.swap32(new Uint8Array(binaryBytes.buffer, 2));
|
|
18124
|
-
|
|
18130
|
+
const bin = new this(binaryBytes, this.SUBTYPE_VECTOR);
|
|
18131
|
+
validateBinaryVector(bin);
|
|
18132
|
+
return bin;
|
|
18125
18133
|
}
|
|
18126
18134
|
static fromPackedBits(array, padding = 0) {
|
|
18127
18135
|
const buffer = ByteUtils.allocate(array.byteLength + 2);
|
|
18128
18136
|
buffer[0] = Binary.VECTOR_TYPE.PackedBit;
|
|
18129
18137
|
buffer[1] = padding;
|
|
18130
18138
|
buffer.set(array, 2);
|
|
18131
|
-
|
|
18139
|
+
const bin = new this(buffer, this.SUBTYPE_VECTOR);
|
|
18140
|
+
validateBinaryVector(bin);
|
|
18141
|
+
return bin;
|
|
18132
18142
|
}
|
|
18133
18143
|
static fromBits(bits) {
|
|
18134
18144
|
const byteLength = (bits.length + 7) >>> 3;
|
|
@@ -18178,6 +18188,11 @@ function validateBinaryVector(vector) {
|
|
|
18178
18188
|
padding !== 0) {
|
|
18179
18189
|
throw new BSONError('Invalid Vector: padding must be zero for int8 and float32 vectors');
|
|
18180
18190
|
}
|
|
18191
|
+
if (datatype === Binary.VECTOR_TYPE.Float32) {
|
|
18192
|
+
if (size !== 0 && size - 2 !== 0 && (size - 2) % 4 !== 0) {
|
|
18193
|
+
throw new BSONError('Invalid Vector: Float32 vector must contain a multiple of 4 bytes');
|
|
18194
|
+
}
|
|
18195
|
+
}
|
|
18181
18196
|
if (datatype === Binary.VECTOR_TYPE.PackedBit && padding !== 0 && size === 2) {
|
|
18182
18197
|
throw new BSONError('Invalid Vector: padding must be zero for packed bit vectors that are empty');
|
|
18183
18198
|
}
|
|
@@ -21689,6 +21704,29 @@ EJSON.serialize = EJSONserialize;
|
|
|
21689
21704
|
EJSON.deserialize = EJSONdeserialize;
|
|
21690
21705
|
Object.freeze(EJSON);
|
|
21691
21706
|
|
|
21707
|
+
const BSONElementType = {
|
|
21708
|
+
double: 1,
|
|
21709
|
+
string: 2,
|
|
21710
|
+
object: 3,
|
|
21711
|
+
array: 4,
|
|
21712
|
+
binData: 5,
|
|
21713
|
+
undefined: 6,
|
|
21714
|
+
objectId: 7,
|
|
21715
|
+
bool: 8,
|
|
21716
|
+
date: 9,
|
|
21717
|
+
null: 10,
|
|
21718
|
+
regex: 11,
|
|
21719
|
+
dbPointer: 12,
|
|
21720
|
+
javascript: 13,
|
|
21721
|
+
symbol: 14,
|
|
21722
|
+
javascriptWithScope: 15,
|
|
21723
|
+
int: 16,
|
|
21724
|
+
timestamp: 17,
|
|
21725
|
+
long: 18,
|
|
21726
|
+
decimal: 19,
|
|
21727
|
+
minKey: 255,
|
|
21728
|
+
maxKey: 127
|
|
21729
|
+
};
|
|
21692
21730
|
function getSize(source, offset) {
|
|
21693
21731
|
try {
|
|
21694
21732
|
return NumberUtils.getNonnegativeInt32LE(source, offset);
|
|
@@ -21733,48 +21771,48 @@ function parseToElements(bytes, startOffset = 0) {
|
|
|
21733
21771
|
const nameLength = findNull(bytes, offset) - nameOffset;
|
|
21734
21772
|
offset += nameLength + 1;
|
|
21735
21773
|
let length;
|
|
21736
|
-
if (type ===
|
|
21737
|
-
type ===
|
|
21738
|
-
type ===
|
|
21739
|
-
type ===
|
|
21774
|
+
if (type === BSONElementType.double ||
|
|
21775
|
+
type === BSONElementType.long ||
|
|
21776
|
+
type === BSONElementType.date ||
|
|
21777
|
+
type === BSONElementType.timestamp) {
|
|
21740
21778
|
length = 8;
|
|
21741
21779
|
}
|
|
21742
|
-
else if (type ===
|
|
21780
|
+
else if (type === BSONElementType.int) {
|
|
21743
21781
|
length = 4;
|
|
21744
21782
|
}
|
|
21745
|
-
else if (type ===
|
|
21783
|
+
else if (type === BSONElementType.objectId) {
|
|
21746
21784
|
length = 12;
|
|
21747
21785
|
}
|
|
21748
|
-
else if (type ===
|
|
21786
|
+
else if (type === BSONElementType.decimal) {
|
|
21749
21787
|
length = 16;
|
|
21750
21788
|
}
|
|
21751
|
-
else if (type ===
|
|
21789
|
+
else if (type === BSONElementType.bool) {
|
|
21752
21790
|
length = 1;
|
|
21753
21791
|
}
|
|
21754
|
-
else if (type ===
|
|
21755
|
-
type ===
|
|
21756
|
-
type ===
|
|
21757
|
-
type ===
|
|
21792
|
+
else if (type === BSONElementType.null ||
|
|
21793
|
+
type === BSONElementType.undefined ||
|
|
21794
|
+
type === BSONElementType.maxKey ||
|
|
21795
|
+
type === BSONElementType.minKey) {
|
|
21758
21796
|
length = 0;
|
|
21759
21797
|
}
|
|
21760
|
-
else if (type ===
|
|
21798
|
+
else if (type === BSONElementType.regex) {
|
|
21761
21799
|
length = findNull(bytes, findNull(bytes, offset) + 1) + 1 - offset;
|
|
21762
21800
|
}
|
|
21763
|
-
else if (type ===
|
|
21764
|
-
type ===
|
|
21765
|
-
type ===
|
|
21801
|
+
else if (type === BSONElementType.object ||
|
|
21802
|
+
type === BSONElementType.array ||
|
|
21803
|
+
type === BSONElementType.javascriptWithScope) {
|
|
21766
21804
|
length = getSize(bytes, offset);
|
|
21767
21805
|
}
|
|
21768
|
-
else if (type ===
|
|
21769
|
-
type ===
|
|
21770
|
-
type ===
|
|
21771
|
-
type ===
|
|
21772
|
-
type ===
|
|
21806
|
+
else if (type === BSONElementType.string ||
|
|
21807
|
+
type === BSONElementType.binData ||
|
|
21808
|
+
type === BSONElementType.dbPointer ||
|
|
21809
|
+
type === BSONElementType.javascript ||
|
|
21810
|
+
type === BSONElementType.symbol) {
|
|
21773
21811
|
length = getSize(bytes, offset) + 4;
|
|
21774
|
-
if (type ===
|
|
21812
|
+
if (type === BSONElementType.binData) {
|
|
21775
21813
|
length += 1;
|
|
21776
21814
|
}
|
|
21777
|
-
if (type ===
|
|
21815
|
+
if (type === BSONElementType.dbPointer) {
|
|
21778
21816
|
length += 12;
|
|
21779
21817
|
}
|
|
21780
21818
|
}
|