@powersync/common 1.43.1 → 1.45.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.
- package/dist/bundle.cjs +129 -81
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +129 -82
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +117 -69
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +117 -70
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +178 -150
- package/lib/client/AbstractPowerSyncDatabase.d.ts +1 -1
- package/lib/client/AbstractPowerSyncDatabase.js +5 -5
- package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
- package/lib/client/ConnectionManager.d.ts +1 -1
- package/lib/client/ConnectionManager.js.map +1 -1
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +4 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +8 -0
- package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
- package/lib/client/sync/stream/streaming-sync-types.d.ts +4 -0
- package/lib/client/sync/stream/streaming-sync-types.js.map +1 -1
- package/lib/db/ConnectionClosedError.d.ts +10 -0
- package/lib/db/ConnectionClosedError.js +21 -0
- package/lib/db/ConnectionClosedError.js.map +1 -0
- package/lib/db/crud/SyncStatus.d.ts +11 -2
- package/lib/db/crud/SyncStatus.js +19 -1
- package/lib/db/crud/SyncStatus.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/AbstractPowerSyncDatabase.ts +8 -8
- package/src/client/ConnectionManager.ts +1 -1
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +19 -2
- package/src/client/sync/stream/streaming-sync-types.ts +5 -0
- package/src/db/ConnectionClosedError.ts +23 -0
- package/src/db/crud/SyncStatus.ts +22 -3
- package/src/index.ts +1 -0
package/dist/bundle.cjs
CHANGED
|
@@ -722,12 +722,30 @@ class SyncStatus {
|
|
|
722
722
|
return {
|
|
723
723
|
connected: this.connected,
|
|
724
724
|
connecting: this.connecting,
|
|
725
|
-
dataFlow:
|
|
725
|
+
dataFlow: {
|
|
726
|
+
...this.dataFlowStatus,
|
|
727
|
+
uploadError: this.serializeError(this.dataFlowStatus.uploadError),
|
|
728
|
+
downloadError: this.serializeError(this.dataFlowStatus.downloadError)
|
|
729
|
+
},
|
|
726
730
|
lastSyncedAt: this.lastSyncedAt,
|
|
727
731
|
hasSynced: this.hasSynced,
|
|
728
732
|
priorityStatusEntries: this.priorityStatusEntries
|
|
729
733
|
};
|
|
730
734
|
}
|
|
735
|
+
/**
|
|
736
|
+
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
737
|
+
* This explicitly serializes errors in the SyncStatus.
|
|
738
|
+
*/
|
|
739
|
+
serializeError(error) {
|
|
740
|
+
if (typeof error == 'undefined') {
|
|
741
|
+
return undefined;
|
|
742
|
+
}
|
|
743
|
+
return {
|
|
744
|
+
name: error.name,
|
|
745
|
+
message: error.message,
|
|
746
|
+
stack: error.stack
|
|
747
|
+
};
|
|
748
|
+
}
|
|
731
749
|
static comparePriorities(a, b) {
|
|
732
750
|
return b.priority - a.priority; // Reverse because higher priorities have lower numbers
|
|
733
751
|
}
|
|
@@ -2340,7 +2358,7 @@ var hasRequiredBuffer$1;
|
|
|
2340
2358
|
function requireBuffer$1 () {
|
|
2341
2359
|
if (hasRequiredBuffer$1) return buffer$1;
|
|
2342
2360
|
hasRequiredBuffer$1 = 1;
|
|
2343
|
-
(function (exports) {
|
|
2361
|
+
(function (exports$1) {
|
|
2344
2362
|
|
|
2345
2363
|
const base64 = requireBase64Js();
|
|
2346
2364
|
const ieee754 = requireIeee754();
|
|
@@ -2349,12 +2367,12 @@ function requireBuffer$1 () {
|
|
|
2349
2367
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
2350
2368
|
: null;
|
|
2351
2369
|
|
|
2352
|
-
exports.Buffer = Buffer;
|
|
2353
|
-
exports.SlowBuffer = SlowBuffer;
|
|
2354
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
2370
|
+
exports$1.Buffer = Buffer;
|
|
2371
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
2372
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
2355
2373
|
|
|
2356
2374
|
const K_MAX_LENGTH = 0x7fffffff;
|
|
2357
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
2375
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
2358
2376
|
|
|
2359
2377
|
/**
|
|
2360
2378
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
@@ -2950,7 +2968,7 @@ function requireBuffer$1 () {
|
|
|
2950
2968
|
|
|
2951
2969
|
Buffer.prototype.inspect = function inspect () {
|
|
2952
2970
|
let str = '';
|
|
2953
|
-
const max = exports.INSPECT_MAX_BYTES;
|
|
2971
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
2954
2972
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
2955
2973
|
if (this.length > max) str += ' ... ';
|
|
2956
2974
|
return '<Buffer ' + str + '>'
|
|
@@ -4458,7 +4476,7 @@ var hasRequiredBuffer;
|
|
|
4458
4476
|
function requireBuffer () {
|
|
4459
4477
|
if (hasRequiredBuffer) return buffer;
|
|
4460
4478
|
hasRequiredBuffer = 1;
|
|
4461
|
-
(function (exports) {
|
|
4479
|
+
(function (exports$1) {
|
|
4462
4480
|
|
|
4463
4481
|
var base64 = requireBase64Js();
|
|
4464
4482
|
var ieee754 = requireIeee754();
|
|
@@ -4467,12 +4485,12 @@ function requireBuffer () {
|
|
|
4467
4485
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
4468
4486
|
: null;
|
|
4469
4487
|
|
|
4470
|
-
exports.Buffer = Buffer;
|
|
4471
|
-
exports.SlowBuffer = SlowBuffer;
|
|
4472
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
4488
|
+
exports$1.Buffer = Buffer;
|
|
4489
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
4490
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
4473
4491
|
|
|
4474
4492
|
var K_MAX_LENGTH = 0x7fffffff;
|
|
4475
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
4493
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
4476
4494
|
|
|
4477
4495
|
/**
|
|
4478
4496
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
@@ -5069,7 +5087,7 @@ function requireBuffer () {
|
|
|
5069
5087
|
|
|
5070
5088
|
Buffer.prototype.inspect = function inspect () {
|
|
5071
5089
|
var str = '';
|
|
5072
|
-
var max = exports.INSPECT_MAX_BYTES;
|
|
5090
|
+
var max = exports$1.INSPECT_MAX_BYTES;
|
|
5073
5091
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
5074
5092
|
if (this.length > max) str += ' ... ';
|
|
5075
5093
|
return '<Buffer ' + str + '>'
|
|
@@ -6282,7 +6300,7 @@ var hasRequiredFrames;
|
|
|
6282
6300
|
function requireFrames () {
|
|
6283
6301
|
if (hasRequiredFrames) return Frames;
|
|
6284
6302
|
hasRequiredFrames = 1;
|
|
6285
|
-
(function (exports) {
|
|
6303
|
+
(function (exports$1) {
|
|
6286
6304
|
/*
|
|
6287
6305
|
* Copyright 2021-2022 the original author or authors.
|
|
6288
6306
|
*
|
|
@@ -6298,8 +6316,8 @@ function requireFrames () {
|
|
|
6298
6316
|
* See the License for the specific language governing permissions and
|
|
6299
6317
|
* limitations under the License.
|
|
6300
6318
|
*/
|
|
6301
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6302
|
-
exports.Frame = exports.Lengths = exports.Flags = exports.FrameTypes = void 0;
|
|
6319
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
6320
|
+
exports$1.Frame = exports$1.Lengths = exports$1.Flags = exports$1.FrameTypes = void 0;
|
|
6303
6321
|
var FrameTypes;
|
|
6304
6322
|
(function (FrameTypes) {
|
|
6305
6323
|
FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
|
|
@@ -6318,7 +6336,7 @@ function requireFrames () {
|
|
|
6318
6336
|
FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
|
|
6319
6337
|
FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
|
|
6320
6338
|
FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
|
|
6321
|
-
})(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
|
|
6339
|
+
})(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
|
|
6322
6340
|
(function (Flags) {
|
|
6323
6341
|
Flags[Flags["NONE"] = 0] = "NONE";
|
|
6324
6342
|
Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
|
|
@@ -6329,7 +6347,7 @@ function requireFrames () {
|
|
|
6329
6347
|
Flags[Flags["NEXT"] = 32] = "NEXT";
|
|
6330
6348
|
Flags[Flags["RESPOND"] = 128] = "RESPOND";
|
|
6331
6349
|
Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
|
|
6332
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
6350
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
6333
6351
|
(function (Flags) {
|
|
6334
6352
|
function hasMetadata(flags) {
|
|
6335
6353
|
return (flags & Flags.METADATA) === Flags.METADATA;
|
|
@@ -6363,13 +6381,13 @@ function requireFrames () {
|
|
|
6363
6381
|
return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
|
|
6364
6382
|
}
|
|
6365
6383
|
Flags.hasResume = hasResume;
|
|
6366
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
6384
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
6367
6385
|
(function (Lengths) {
|
|
6368
6386
|
Lengths[Lengths["FRAME"] = 3] = "FRAME";
|
|
6369
6387
|
Lengths[Lengths["HEADER"] = 6] = "HEADER";
|
|
6370
6388
|
Lengths[Lengths["METADATA"] = 3] = "METADATA";
|
|
6371
6389
|
Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
|
|
6372
|
-
})(exports.Lengths || (exports.Lengths = {}));
|
|
6390
|
+
})(exports$1.Lengths || (exports$1.Lengths = {}));
|
|
6373
6391
|
(function (Frame) {
|
|
6374
6392
|
function isConnection(frame) {
|
|
6375
6393
|
return frame.streamId === 0;
|
|
@@ -6380,7 +6398,7 @@ function requireFrames () {
|
|
|
6380
6398
|
frame.type <= FrameTypes.REQUEST_CHANNEL);
|
|
6381
6399
|
}
|
|
6382
6400
|
Frame.isRequest = isRequest;
|
|
6383
|
-
})(exports.Frame || (exports.Frame = {}));
|
|
6401
|
+
})(exports$1.Frame || (exports$1.Frame = {}));
|
|
6384
6402
|
|
|
6385
6403
|
} (Frames));
|
|
6386
6404
|
return Frames;
|
|
@@ -6391,7 +6409,7 @@ var hasRequiredCodecs;
|
|
|
6391
6409
|
function requireCodecs () {
|
|
6392
6410
|
if (hasRequiredCodecs) return Codecs;
|
|
6393
6411
|
hasRequiredCodecs = 1;
|
|
6394
|
-
(function (exports) {
|
|
6412
|
+
(function (exports$1) {
|
|
6395
6413
|
var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
|
|
6396
6414
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
6397
6415
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
@@ -6419,22 +6437,22 @@ function requireCodecs () {
|
|
|
6419
6437
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
6420
6438
|
}
|
|
6421
6439
|
};
|
|
6422
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6423
|
-
exports.Deserializer = exports.sizeOfFrame = exports.serializeFrame = exports.deserializeFrame = exports.serializeFrameWithLength = exports.deserializeFrames = exports.deserializeFrameWithLength = exports.writeUInt64BE = exports.readUInt64BE = exports.writeUInt24BE = exports.readUInt24BE = exports.MAX_VERSION = exports.MAX_TTL = exports.MAX_STREAM_ID = exports.MAX_RESUME_LENGTH = exports.MAX_REQUEST_N = exports.MAX_REQUEST_COUNT = exports.MAX_MIME_LENGTH = exports.MAX_METADATA_LENGTH = exports.MAX_LIFETIME = exports.MAX_KEEPALIVE = exports.MAX_CODE = exports.FRAME_TYPE_OFFFSET = exports.FLAGS_MASK = void 0;
|
|
6440
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
6441
|
+
exports$1.Deserializer = exports$1.sizeOfFrame = exports$1.serializeFrame = exports$1.deserializeFrame = exports$1.serializeFrameWithLength = exports$1.deserializeFrames = exports$1.deserializeFrameWithLength = exports$1.writeUInt64BE = exports$1.readUInt64BE = exports$1.writeUInt24BE = exports$1.readUInt24BE = exports$1.MAX_VERSION = exports$1.MAX_TTL = exports$1.MAX_STREAM_ID = exports$1.MAX_RESUME_LENGTH = exports$1.MAX_REQUEST_N = exports$1.MAX_REQUEST_COUNT = exports$1.MAX_MIME_LENGTH = exports$1.MAX_METADATA_LENGTH = exports$1.MAX_LIFETIME = exports$1.MAX_KEEPALIVE = exports$1.MAX_CODE = exports$1.FRAME_TYPE_OFFFSET = exports$1.FLAGS_MASK = void 0;
|
|
6424
6442
|
var Frames_1 = requireFrames();
|
|
6425
|
-
exports.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
6426
|
-
exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
6427
|
-
exports.MAX_CODE = 0x7fffffff; // uint31
|
|
6428
|
-
exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
6429
|
-
exports.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
6430
|
-
exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
6431
|
-
exports.MAX_MIME_LENGTH = 0xff; // int8
|
|
6432
|
-
exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
6433
|
-
exports.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
6434
|
-
exports.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
6435
|
-
exports.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
6436
|
-
exports.MAX_TTL = 0x7fffffff; // uint31
|
|
6437
|
-
exports.MAX_VERSION = 0xffff; // uint16
|
|
6443
|
+
exports$1.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
6444
|
+
exports$1.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
6445
|
+
exports$1.MAX_CODE = 0x7fffffff; // uint31
|
|
6446
|
+
exports$1.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
6447
|
+
exports$1.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
6448
|
+
exports$1.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
6449
|
+
exports$1.MAX_MIME_LENGTH = 0xff; // int8
|
|
6450
|
+
exports$1.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
6451
|
+
exports$1.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
6452
|
+
exports$1.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
6453
|
+
exports$1.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
6454
|
+
exports$1.MAX_TTL = 0x7fffffff; // uint31
|
|
6455
|
+
exports$1.MAX_VERSION = 0xffff; // uint16
|
|
6438
6456
|
/**
|
|
6439
6457
|
* Mimimum value that would overflow bitwise operators (2^32).
|
|
6440
6458
|
*/
|
|
@@ -6448,7 +6466,7 @@ function requireCodecs () {
|
|
|
6448
6466
|
var val3 = buffer.readUInt8(offset + 2);
|
|
6449
6467
|
return val1 | val2 | val3;
|
|
6450
6468
|
}
|
|
6451
|
-
exports.readUInt24BE = readUInt24BE;
|
|
6469
|
+
exports$1.readUInt24BE = readUInt24BE;
|
|
6452
6470
|
/**
|
|
6453
6471
|
* Writes a uint24 to a buffer starting at the given offset, returning the
|
|
6454
6472
|
* offset of the next byte.
|
|
@@ -6458,7 +6476,7 @@ function requireCodecs () {
|
|
|
6458
6476
|
offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
|
|
6459
6477
|
return buffer.writeUInt8(value & 0xff, offset); // 1st byte
|
|
6460
6478
|
}
|
|
6461
|
-
exports.writeUInt24BE = writeUInt24BE;
|
|
6479
|
+
exports$1.writeUInt24BE = writeUInt24BE;
|
|
6462
6480
|
/**
|
|
6463
6481
|
* Read a uint64 (technically supports up to 53 bits per JS number
|
|
6464
6482
|
* representation).
|
|
@@ -6468,7 +6486,7 @@ function requireCodecs () {
|
|
|
6468
6486
|
var low = buffer.readUInt32BE(offset + 4);
|
|
6469
6487
|
return high * BITWISE_OVERFLOW + low;
|
|
6470
6488
|
}
|
|
6471
|
-
exports.readUInt64BE = readUInt64BE;
|
|
6489
|
+
exports$1.readUInt64BE = readUInt64BE;
|
|
6472
6490
|
/**
|
|
6473
6491
|
* Write a uint64 (technically supports up to 53 bits per JS number
|
|
6474
6492
|
* representation).
|
|
@@ -6479,7 +6497,7 @@ function requireCodecs () {
|
|
|
6479
6497
|
offset = buffer.writeUInt32BE(high, offset); // first half of uint64
|
|
6480
6498
|
return buffer.writeUInt32BE(low, offset); // second half of uint64
|
|
6481
6499
|
}
|
|
6482
|
-
exports.writeUInt64BE = writeUInt64BE;
|
|
6500
|
+
exports$1.writeUInt64BE = writeUInt64BE;
|
|
6483
6501
|
/**
|
|
6484
6502
|
* Frame header is:
|
|
6485
6503
|
* - stream id (uint32 = 4)
|
|
@@ -6497,7 +6515,7 @@ function requireCodecs () {
|
|
|
6497
6515
|
var frameLength = readUInt24BE(buffer, 0);
|
|
6498
6516
|
return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
|
|
6499
6517
|
}
|
|
6500
|
-
exports.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
6518
|
+
exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
6501
6519
|
/**
|
|
6502
6520
|
* Given a buffer that may contain zero or more length-prefixed frames followed
|
|
6503
6521
|
* by zero or more bytes of a (partial) subsequent frame, returns an array of
|
|
@@ -6530,7 +6548,7 @@ function requireCodecs () {
|
|
|
6530
6548
|
}
|
|
6531
6549
|
});
|
|
6532
6550
|
}
|
|
6533
|
-
exports.deserializeFrames = deserializeFrames;
|
|
6551
|
+
exports$1.deserializeFrames = deserializeFrames;
|
|
6534
6552
|
/**
|
|
6535
6553
|
* Writes a frame to a buffer with a length prefix.
|
|
6536
6554
|
*/
|
|
@@ -6541,7 +6559,7 @@ function requireCodecs () {
|
|
|
6541
6559
|
buffer.copy(lengthPrefixed, UINT24_SIZE);
|
|
6542
6560
|
return lengthPrefixed;
|
|
6543
6561
|
}
|
|
6544
|
-
exports.serializeFrameWithLength = serializeFrameWithLength;
|
|
6562
|
+
exports$1.serializeFrameWithLength = serializeFrameWithLength;
|
|
6545
6563
|
/**
|
|
6546
6564
|
* Read a frame from the buffer.
|
|
6547
6565
|
*/
|
|
@@ -6556,8 +6574,8 @@ function requireCodecs () {
|
|
|
6556
6574
|
// );
|
|
6557
6575
|
var typeAndFlags = buffer.readUInt16BE(offset);
|
|
6558
6576
|
offset += 2;
|
|
6559
|
-
var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
6560
|
-
var flags = typeAndFlags & exports.FLAGS_MASK; // keep lowest 10 bits
|
|
6577
|
+
var type = typeAndFlags >>> exports$1.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
6578
|
+
var flags = typeAndFlags & exports$1.FLAGS_MASK; // keep lowest 10 bits
|
|
6561
6579
|
switch (type) {
|
|
6562
6580
|
case Frames_1.FrameTypes.SETUP:
|
|
6563
6581
|
return deserializeSetupFrame(buffer, streamId, flags);
|
|
@@ -6594,7 +6612,7 @@ function requireCodecs () {
|
|
|
6594
6612
|
// );
|
|
6595
6613
|
}
|
|
6596
6614
|
}
|
|
6597
|
-
exports.deserializeFrame = deserializeFrame;
|
|
6615
|
+
exports$1.deserializeFrame = deserializeFrame;
|
|
6598
6616
|
/**
|
|
6599
6617
|
* Convert the frame to a (binary) buffer.
|
|
6600
6618
|
*/
|
|
@@ -6633,7 +6651,7 @@ function requireCodecs () {
|
|
|
6633
6651
|
// );
|
|
6634
6652
|
}
|
|
6635
6653
|
}
|
|
6636
|
-
exports.serializeFrame = serializeFrame;
|
|
6654
|
+
exports$1.serializeFrame = serializeFrame;
|
|
6637
6655
|
/**
|
|
6638
6656
|
* Byte size of frame without size prefix
|
|
6639
6657
|
*/
|
|
@@ -6672,7 +6690,7 @@ function requireCodecs () {
|
|
|
6672
6690
|
// );
|
|
6673
6691
|
}
|
|
6674
6692
|
}
|
|
6675
|
-
exports.sizeOfFrame = sizeOfFrame;
|
|
6693
|
+
exports$1.sizeOfFrame = sizeOfFrame;
|
|
6676
6694
|
/**
|
|
6677
6695
|
* Writes a SETUP frame into a new buffer and returns it.
|
|
6678
6696
|
*
|
|
@@ -7307,7 +7325,7 @@ function requireCodecs () {
|
|
|
7307
7325
|
function writeHeader(frame, buffer) {
|
|
7308
7326
|
var offset = buffer.writeInt32BE(frame.streamId, 0);
|
|
7309
7327
|
// shift frame to high 6 bits, extract lowest 10 bits from flags
|
|
7310
|
-
return buffer.writeUInt16BE((frame.type << exports.FRAME_TYPE_OFFFSET) | (frame.flags & exports.FLAGS_MASK), offset);
|
|
7328
|
+
return buffer.writeUInt16BE((frame.type << exports$1.FRAME_TYPE_OFFFSET) | (frame.flags & exports$1.FLAGS_MASK), offset);
|
|
7311
7329
|
}
|
|
7312
7330
|
/**
|
|
7313
7331
|
* Determine the length of the payload section of a frame. Only applies to
|
|
@@ -7388,7 +7406,7 @@ function requireCodecs () {
|
|
|
7388
7406
|
};
|
|
7389
7407
|
return Deserializer;
|
|
7390
7408
|
}());
|
|
7391
|
-
exports.Deserializer = Deserializer;
|
|
7409
|
+
exports$1.Deserializer = Deserializer;
|
|
7392
7410
|
|
|
7393
7411
|
} (Codecs));
|
|
7394
7412
|
return Codecs;
|
|
@@ -7534,7 +7552,7 @@ var hasRequiredErrors;
|
|
|
7534
7552
|
function requireErrors () {
|
|
7535
7553
|
if (hasRequiredErrors) return Errors;
|
|
7536
7554
|
hasRequiredErrors = 1;
|
|
7537
|
-
(function (exports) {
|
|
7555
|
+
(function (exports$1) {
|
|
7538
7556
|
/*
|
|
7539
7557
|
* Copyright 2021-2022 the original author or authors.
|
|
7540
7558
|
*
|
|
@@ -7565,8 +7583,8 @@ function requireErrors () {
|
|
|
7565
7583
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7566
7584
|
};
|
|
7567
7585
|
})();
|
|
7568
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7569
|
-
exports.ErrorCodes = exports.RSocketError = void 0;
|
|
7586
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
7587
|
+
exports$1.ErrorCodes = exports$1.RSocketError = void 0;
|
|
7570
7588
|
var RSocketError = /** @class */ (function (_super) {
|
|
7571
7589
|
__extends(RSocketError, _super);
|
|
7572
7590
|
function RSocketError(code, message) {
|
|
@@ -7576,7 +7594,7 @@ function requireErrors () {
|
|
|
7576
7594
|
}
|
|
7577
7595
|
return RSocketError;
|
|
7578
7596
|
}(Error));
|
|
7579
|
-
exports.RSocketError = RSocketError;
|
|
7597
|
+
exports$1.RSocketError = RSocketError;
|
|
7580
7598
|
(function (ErrorCodes) {
|
|
7581
7599
|
ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
|
|
7582
7600
|
ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
|
|
@@ -7590,7 +7608,7 @@ function requireErrors () {
|
|
|
7590
7608
|
ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
|
|
7591
7609
|
ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
|
|
7592
7610
|
ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
|
|
7593
|
-
})(exports.ErrorCodes || (exports.ErrorCodes = {}));
|
|
7611
|
+
})(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
|
|
7594
7612
|
|
|
7595
7613
|
} (Errors));
|
|
7596
7614
|
return Errors;
|
|
@@ -7632,7 +7650,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
|
|
|
7632
7650
|
function requireClientServerMultiplexerDemultiplexer () {
|
|
7633
7651
|
if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
|
|
7634
7652
|
hasRequiredClientServerMultiplexerDemultiplexer = 1;
|
|
7635
|
-
(function (exports) {
|
|
7653
|
+
(function (exports$1) {
|
|
7636
7654
|
/*
|
|
7637
7655
|
* Copyright 2021-2022 the original author or authors.
|
|
7638
7656
|
*
|
|
@@ -7699,8 +7717,8 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7699
7717
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7700
7718
|
}
|
|
7701
7719
|
};
|
|
7702
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7703
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports.ResumableClientServerInputMultiplexerDemultiplexer = exports.ClientServerInputMultiplexerDemultiplexer = exports.StreamIdGenerator = void 0;
|
|
7720
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
7721
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports$1.ResumableClientServerInputMultiplexerDemultiplexer = exports$1.ClientServerInputMultiplexerDemultiplexer = exports$1.StreamIdGenerator = void 0;
|
|
7704
7722
|
var _1 = requireDist();
|
|
7705
7723
|
var Deferred_1 = requireDeferred();
|
|
7706
7724
|
var Errors_1 = requireErrors();
|
|
@@ -7723,7 +7741,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7723
7741
|
};
|
|
7724
7742
|
return StreamIdGeneratorImpl;
|
|
7725
7743
|
}());
|
|
7726
|
-
})(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
|
|
7744
|
+
})(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
|
|
7727
7745
|
var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
7728
7746
|
__extends(ClientServerInputMultiplexerDemultiplexer, _super);
|
|
7729
7747
|
function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
|
|
@@ -7812,7 +7830,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7812
7830
|
};
|
|
7813
7831
|
return ClientServerInputMultiplexerDemultiplexer;
|
|
7814
7832
|
}(Deferred_1.Deferred));
|
|
7815
|
-
exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
7833
|
+
exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
7816
7834
|
var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
7817
7835
|
__extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
|
|
7818
7836
|
function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
|
|
@@ -7969,7 +7987,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7969
7987
|
};
|
|
7970
7988
|
return ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7971
7989
|
}(ClientServerInputMultiplexerDemultiplexer));
|
|
7972
|
-
exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7990
|
+
exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7973
7991
|
var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
|
|
7974
7992
|
function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
|
|
7975
7993
|
this.outbound = outbound;
|
|
@@ -8026,7 +8044,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
8026
8044
|
};
|
|
8027
8045
|
return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8028
8046
|
}());
|
|
8029
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8047
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8030
8048
|
|
|
8031
8049
|
} (ClientServerMultiplexerDemultiplexer));
|
|
8032
8050
|
return ClientServerMultiplexerDemultiplexer;
|
|
@@ -11012,7 +11030,7 @@ var hasRequiredDist;
|
|
|
11012
11030
|
function requireDist () {
|
|
11013
11031
|
if (hasRequiredDist) return dist;
|
|
11014
11032
|
hasRequiredDist = 1;
|
|
11015
|
-
(function (exports) {
|
|
11033
|
+
(function (exports$1) {
|
|
11016
11034
|
/*
|
|
11017
11035
|
* Copyright 2021-2022 the original author or authors.
|
|
11018
11036
|
*
|
|
@@ -11035,19 +11053,19 @@ function requireDist () {
|
|
|
11035
11053
|
if (k2 === undefined) k2 = k;
|
|
11036
11054
|
o[k2] = m[k];
|
|
11037
11055
|
}));
|
|
11038
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
11039
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11056
|
+
var __exportStar = (dist && dist.__exportStar) || function(m, exports$1) {
|
|
11057
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
11040
11058
|
};
|
|
11041
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11042
|
-
__exportStar(requireCodecs(), exports);
|
|
11043
|
-
__exportStar(requireCommon(), exports);
|
|
11044
|
-
__exportStar(requireDeferred(), exports);
|
|
11045
|
-
__exportStar(requireErrors(), exports);
|
|
11046
|
-
__exportStar(requireFrames(), exports);
|
|
11047
|
-
__exportStar(requireRSocket(), exports);
|
|
11048
|
-
__exportStar(requireRSocketConnector(), exports);
|
|
11049
|
-
__exportStar(requireRSocketServer(), exports);
|
|
11050
|
-
__exportStar(requireTransport(), exports);
|
|
11059
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
11060
|
+
__exportStar(requireCodecs(), exports$1);
|
|
11061
|
+
__exportStar(requireCommon(), exports$1);
|
|
11062
|
+
__exportStar(requireDeferred(), exports$1);
|
|
11063
|
+
__exportStar(requireErrors(), exports$1);
|
|
11064
|
+
__exportStar(requireFrames(), exports$1);
|
|
11065
|
+
__exportStar(requireRSocket(), exports$1);
|
|
11066
|
+
__exportStar(requireRSocketConnector(), exports$1);
|
|
11067
|
+
__exportStar(requireRSocketServer(), exports$1);
|
|
11068
|
+
__exportStar(requireTransport(), exports$1);
|
|
11051
11069
|
|
|
11052
11070
|
} (dist));
|
|
11053
11071
|
return dist;
|
|
@@ -11055,7 +11073,7 @@ function requireDist () {
|
|
|
11055
11073
|
|
|
11056
11074
|
var distExports = requireDist();
|
|
11057
11075
|
|
|
11058
|
-
var version = "1.
|
|
11076
|
+
var version = "1.45.0";
|
|
11059
11077
|
var PACKAGE = {
|
|
11060
11078
|
version: version};
|
|
11061
11079
|
|
|
@@ -11982,6 +12000,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
11982
12000
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
11983
12001
|
};
|
|
11984
12002
|
const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
12003
|
+
appMetadata: {},
|
|
11985
12004
|
connectionMethod: exports.SyncStreamConnectionMethod.WEB_SOCKET,
|
|
11986
12005
|
clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
|
|
11987
12006
|
fetchStrategy: exports.FetchStrategy.Buffered,
|
|
@@ -12360,6 +12379,11 @@ The next upload iteration will be delayed.`);
|
|
|
12360
12379
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
12361
12380
|
...(options ?? {})
|
|
12362
12381
|
};
|
|
12382
|
+
// Validate app metadata
|
|
12383
|
+
const invalidMetadata = Object.entries(resolvedOptions.appMetadata).filter(([_, value]) => typeof value != 'string');
|
|
12384
|
+
if (invalidMetadata.length > 0) {
|
|
12385
|
+
throw new Error(`Invalid appMetadata provided. Only string values are allowed. Invalid values: ${invalidMetadata.map(([key, value]) => `${key}: ${value}`).join(', ')}`);
|
|
12386
|
+
}
|
|
12363
12387
|
const clientImplementation = resolvedOptions.clientImplementation;
|
|
12364
12388
|
this.updateSyncStatus({ clientImplementation });
|
|
12365
12389
|
if (clientImplementation == exports.SyncClientImplementation.JAVASCRIPT) {
|
|
@@ -12395,6 +12419,7 @@ The next upload iteration will be delayed.`);
|
|
|
12395
12419
|
include_checksum: true,
|
|
12396
12420
|
raw_data: true,
|
|
12397
12421
|
parameters: resolvedOptions.params,
|
|
12422
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
12398
12423
|
client_id: clientId
|
|
12399
12424
|
}
|
|
12400
12425
|
};
|
|
@@ -12754,6 +12779,7 @@ The next upload iteration will be delayed.`);
|
|
|
12754
12779
|
try {
|
|
12755
12780
|
const options = {
|
|
12756
12781
|
parameters: resolvedOptions.params,
|
|
12782
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
12757
12783
|
active_streams: this.activeStreams,
|
|
12758
12784
|
include_defaults: resolvedOptions.includeDefaultStreams
|
|
12759
12785
|
};
|
|
@@ -13412,11 +13438,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
13412
13438
|
.map((n) => parseInt(n));
|
|
13413
13439
|
}
|
|
13414
13440
|
catch (e) {
|
|
13415
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
13441
|
+
throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
|
|
13416
13442
|
}
|
|
13417
|
-
// Validate >=0.4.
|
|
13418
|
-
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] <
|
|
13419
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
13443
|
+
// Validate >=0.4.10 <1.0.0
|
|
13444
|
+
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 10)) {
|
|
13445
|
+
throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}`);
|
|
13420
13446
|
}
|
|
13421
13447
|
}
|
|
13422
13448
|
async resolveOfflineSyncStatus() {
|
|
@@ -14536,6 +14562,27 @@ class SyncDataBatch {
|
|
|
14536
14562
|
}
|
|
14537
14563
|
}
|
|
14538
14564
|
|
|
14565
|
+
/**
|
|
14566
|
+
* Thrown when an underlying database connection is closed.
|
|
14567
|
+
* This is particularly relevant when worker connections are marked as closed while
|
|
14568
|
+
* operations are still in progress.
|
|
14569
|
+
*/
|
|
14570
|
+
class ConnectionClosedError extends Error {
|
|
14571
|
+
static NAME = 'ConnectionClosedError';
|
|
14572
|
+
static MATCHES(input) {
|
|
14573
|
+
/**
|
|
14574
|
+
* If there are weird package issues which cause multiple versions of classes to be present, the instanceof
|
|
14575
|
+
* check might fail. This also performs a failsafe check.
|
|
14576
|
+
* This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
|
|
14577
|
+
*/
|
|
14578
|
+
return (input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME));
|
|
14579
|
+
}
|
|
14580
|
+
constructor(message) {
|
|
14581
|
+
super(message);
|
|
14582
|
+
this.name = ConnectionClosedError.NAME;
|
|
14583
|
+
}
|
|
14584
|
+
}
|
|
14585
|
+
|
|
14539
14586
|
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
14540
14587
|
exports.ColumnType = void 0;
|
|
14541
14588
|
(function (ColumnType) {
|
|
@@ -15099,6 +15146,7 @@ exports.AbstractStreamingSyncImplementation = AbstractStreamingSyncImplementatio
|
|
|
15099
15146
|
exports.ArrayComparator = ArrayComparator;
|
|
15100
15147
|
exports.BaseObserver = BaseObserver;
|
|
15101
15148
|
exports.Column = Column;
|
|
15149
|
+
exports.ConnectionClosedError = ConnectionClosedError;
|
|
15102
15150
|
exports.ConnectionManager = ConnectionManager;
|
|
15103
15151
|
exports.ControlledExecutor = ControlledExecutor;
|
|
15104
15152
|
exports.CrudBatch = CrudBatch;
|