@powersync/common 0.0.0-dev-20251203144301 → 0.0.0-dev-20260112083235
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 +116 -82
- package/dist/bundle.cjs.map +1 -1
- package/dist/bundle.mjs +116 -83
- package/dist/bundle.mjs.map +1 -1
- package/dist/bundle.node.cjs +104 -70
- package/dist/bundle.node.cjs.map +1 -1
- package/dist/bundle.node.mjs +104 -71
- package/dist/bundle.node.mjs.map +1 -1
- package/dist/index.d.cts +25 -2
- package/lib/client/AbstractPowerSyncDatabase.d.ts +2 -2
- package/lib/client/AbstractPowerSyncDatabase.js +7 -7
- package/lib/client/AbstractPowerSyncDatabase.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 +4 -0
- package/lib/db/crud/SyncStatus.js +4 -0
- 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 +10 -10
- package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +18 -0
- package/src/client/sync/stream/streaming-sync-types.ts +5 -0
- package/src/db/ConnectionClosedError.ts +23 -0
- package/src/db/crud/SyncStatus.ts +4 -0
- package/src/index.ts +1 -0
package/dist/bundle.cjs
CHANGED
|
@@ -732,6 +732,10 @@ class SyncStatus {
|
|
|
732
732
|
priorityStatusEntries: this.priorityStatusEntries
|
|
733
733
|
};
|
|
734
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
|
+
*/
|
|
735
739
|
serializeError(error) {
|
|
736
740
|
if (typeof error == 'undefined') {
|
|
737
741
|
return undefined;
|
|
@@ -2354,7 +2358,7 @@ var hasRequiredBuffer$1;
|
|
|
2354
2358
|
function requireBuffer$1 () {
|
|
2355
2359
|
if (hasRequiredBuffer$1) return buffer$1;
|
|
2356
2360
|
hasRequiredBuffer$1 = 1;
|
|
2357
|
-
(function (exports) {
|
|
2361
|
+
(function (exports$1) {
|
|
2358
2362
|
|
|
2359
2363
|
const base64 = requireBase64Js();
|
|
2360
2364
|
const ieee754 = requireIeee754();
|
|
@@ -2363,12 +2367,12 @@ function requireBuffer$1 () {
|
|
|
2363
2367
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
2364
2368
|
: null;
|
|
2365
2369
|
|
|
2366
|
-
exports.Buffer = Buffer;
|
|
2367
|
-
exports.SlowBuffer = SlowBuffer;
|
|
2368
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
2370
|
+
exports$1.Buffer = Buffer;
|
|
2371
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
2372
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
2369
2373
|
|
|
2370
2374
|
const K_MAX_LENGTH = 0x7fffffff;
|
|
2371
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
2375
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
2372
2376
|
|
|
2373
2377
|
/**
|
|
2374
2378
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
@@ -2964,7 +2968,7 @@ function requireBuffer$1 () {
|
|
|
2964
2968
|
|
|
2965
2969
|
Buffer.prototype.inspect = function inspect () {
|
|
2966
2970
|
let str = '';
|
|
2967
|
-
const max = exports.INSPECT_MAX_BYTES;
|
|
2971
|
+
const max = exports$1.INSPECT_MAX_BYTES;
|
|
2968
2972
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
2969
2973
|
if (this.length > max) str += ' ... ';
|
|
2970
2974
|
return '<Buffer ' + str + '>'
|
|
@@ -4472,7 +4476,7 @@ var hasRequiredBuffer;
|
|
|
4472
4476
|
function requireBuffer () {
|
|
4473
4477
|
if (hasRequiredBuffer) return buffer;
|
|
4474
4478
|
hasRequiredBuffer = 1;
|
|
4475
|
-
(function (exports) {
|
|
4479
|
+
(function (exports$1) {
|
|
4476
4480
|
|
|
4477
4481
|
var base64 = requireBase64Js();
|
|
4478
4482
|
var ieee754 = requireIeee754();
|
|
@@ -4481,12 +4485,12 @@ function requireBuffer () {
|
|
|
4481
4485
|
? Symbol['for']('nodejs.util.inspect.custom') // eslint-disable-line dot-notation
|
|
4482
4486
|
: null;
|
|
4483
4487
|
|
|
4484
|
-
exports.Buffer = Buffer;
|
|
4485
|
-
exports.SlowBuffer = SlowBuffer;
|
|
4486
|
-
exports.INSPECT_MAX_BYTES = 50;
|
|
4488
|
+
exports$1.Buffer = Buffer;
|
|
4489
|
+
exports$1.SlowBuffer = SlowBuffer;
|
|
4490
|
+
exports$1.INSPECT_MAX_BYTES = 50;
|
|
4487
4491
|
|
|
4488
4492
|
var K_MAX_LENGTH = 0x7fffffff;
|
|
4489
|
-
exports.kMaxLength = K_MAX_LENGTH;
|
|
4493
|
+
exports$1.kMaxLength = K_MAX_LENGTH;
|
|
4490
4494
|
|
|
4491
4495
|
/**
|
|
4492
4496
|
* If `Buffer.TYPED_ARRAY_SUPPORT`:
|
|
@@ -5083,7 +5087,7 @@ function requireBuffer () {
|
|
|
5083
5087
|
|
|
5084
5088
|
Buffer.prototype.inspect = function inspect () {
|
|
5085
5089
|
var str = '';
|
|
5086
|
-
var max = exports.INSPECT_MAX_BYTES;
|
|
5090
|
+
var max = exports$1.INSPECT_MAX_BYTES;
|
|
5087
5091
|
str = this.toString('hex', 0, max).replace(/(.{2})/g, '$1 ').trim();
|
|
5088
5092
|
if (this.length > max) str += ' ... ';
|
|
5089
5093
|
return '<Buffer ' + str + '>'
|
|
@@ -6296,7 +6300,7 @@ var hasRequiredFrames;
|
|
|
6296
6300
|
function requireFrames () {
|
|
6297
6301
|
if (hasRequiredFrames) return Frames;
|
|
6298
6302
|
hasRequiredFrames = 1;
|
|
6299
|
-
(function (exports) {
|
|
6303
|
+
(function (exports$1) {
|
|
6300
6304
|
/*
|
|
6301
6305
|
* Copyright 2021-2022 the original author or authors.
|
|
6302
6306
|
*
|
|
@@ -6312,8 +6316,8 @@ function requireFrames () {
|
|
|
6312
6316
|
* See the License for the specific language governing permissions and
|
|
6313
6317
|
* limitations under the License.
|
|
6314
6318
|
*/
|
|
6315
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6316
|
-
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;
|
|
6317
6321
|
var FrameTypes;
|
|
6318
6322
|
(function (FrameTypes) {
|
|
6319
6323
|
FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
|
|
@@ -6332,7 +6336,7 @@ function requireFrames () {
|
|
|
6332
6336
|
FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
|
|
6333
6337
|
FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
|
|
6334
6338
|
FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
|
|
6335
|
-
})(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
|
|
6339
|
+
})(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
|
|
6336
6340
|
(function (Flags) {
|
|
6337
6341
|
Flags[Flags["NONE"] = 0] = "NONE";
|
|
6338
6342
|
Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
|
|
@@ -6343,7 +6347,7 @@ function requireFrames () {
|
|
|
6343
6347
|
Flags[Flags["NEXT"] = 32] = "NEXT";
|
|
6344
6348
|
Flags[Flags["RESPOND"] = 128] = "RESPOND";
|
|
6345
6349
|
Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
|
|
6346
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
6350
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
6347
6351
|
(function (Flags) {
|
|
6348
6352
|
function hasMetadata(flags) {
|
|
6349
6353
|
return (flags & Flags.METADATA) === Flags.METADATA;
|
|
@@ -6377,13 +6381,13 @@ function requireFrames () {
|
|
|
6377
6381
|
return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
|
|
6378
6382
|
}
|
|
6379
6383
|
Flags.hasResume = hasResume;
|
|
6380
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
6384
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
6381
6385
|
(function (Lengths) {
|
|
6382
6386
|
Lengths[Lengths["FRAME"] = 3] = "FRAME";
|
|
6383
6387
|
Lengths[Lengths["HEADER"] = 6] = "HEADER";
|
|
6384
6388
|
Lengths[Lengths["METADATA"] = 3] = "METADATA";
|
|
6385
6389
|
Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
|
|
6386
|
-
})(exports.Lengths || (exports.Lengths = {}));
|
|
6390
|
+
})(exports$1.Lengths || (exports$1.Lengths = {}));
|
|
6387
6391
|
(function (Frame) {
|
|
6388
6392
|
function isConnection(frame) {
|
|
6389
6393
|
return frame.streamId === 0;
|
|
@@ -6394,7 +6398,7 @@ function requireFrames () {
|
|
|
6394
6398
|
frame.type <= FrameTypes.REQUEST_CHANNEL);
|
|
6395
6399
|
}
|
|
6396
6400
|
Frame.isRequest = isRequest;
|
|
6397
|
-
})(exports.Frame || (exports.Frame = {}));
|
|
6401
|
+
})(exports$1.Frame || (exports$1.Frame = {}));
|
|
6398
6402
|
|
|
6399
6403
|
} (Frames));
|
|
6400
6404
|
return Frames;
|
|
@@ -6405,7 +6409,7 @@ var hasRequiredCodecs;
|
|
|
6405
6409
|
function requireCodecs () {
|
|
6406
6410
|
if (hasRequiredCodecs) return Codecs;
|
|
6407
6411
|
hasRequiredCodecs = 1;
|
|
6408
|
-
(function (exports) {
|
|
6412
|
+
(function (exports$1) {
|
|
6409
6413
|
var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
|
|
6410
6414
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
6411
6415
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
@@ -6433,22 +6437,22 @@ function requireCodecs () {
|
|
|
6433
6437
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
6434
6438
|
}
|
|
6435
6439
|
};
|
|
6436
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6437
|
-
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;
|
|
6438
6442
|
var Frames_1 = requireFrames();
|
|
6439
|
-
exports.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
6440
|
-
exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
6441
|
-
exports.MAX_CODE = 0x7fffffff; // uint31
|
|
6442
|
-
exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
6443
|
-
exports.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
6444
|
-
exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
6445
|
-
exports.MAX_MIME_LENGTH = 0xff; // int8
|
|
6446
|
-
exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
6447
|
-
exports.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
6448
|
-
exports.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
6449
|
-
exports.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
6450
|
-
exports.MAX_TTL = 0x7fffffff; // uint31
|
|
6451
|
-
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
|
|
6452
6456
|
/**
|
|
6453
6457
|
* Mimimum value that would overflow bitwise operators (2^32).
|
|
6454
6458
|
*/
|
|
@@ -6462,7 +6466,7 @@ function requireCodecs () {
|
|
|
6462
6466
|
var val3 = buffer.readUInt8(offset + 2);
|
|
6463
6467
|
return val1 | val2 | val3;
|
|
6464
6468
|
}
|
|
6465
|
-
exports.readUInt24BE = readUInt24BE;
|
|
6469
|
+
exports$1.readUInt24BE = readUInt24BE;
|
|
6466
6470
|
/**
|
|
6467
6471
|
* Writes a uint24 to a buffer starting at the given offset, returning the
|
|
6468
6472
|
* offset of the next byte.
|
|
@@ -6472,7 +6476,7 @@ function requireCodecs () {
|
|
|
6472
6476
|
offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
|
|
6473
6477
|
return buffer.writeUInt8(value & 0xff, offset); // 1st byte
|
|
6474
6478
|
}
|
|
6475
|
-
exports.writeUInt24BE = writeUInt24BE;
|
|
6479
|
+
exports$1.writeUInt24BE = writeUInt24BE;
|
|
6476
6480
|
/**
|
|
6477
6481
|
* Read a uint64 (technically supports up to 53 bits per JS number
|
|
6478
6482
|
* representation).
|
|
@@ -6482,7 +6486,7 @@ function requireCodecs () {
|
|
|
6482
6486
|
var low = buffer.readUInt32BE(offset + 4);
|
|
6483
6487
|
return high * BITWISE_OVERFLOW + low;
|
|
6484
6488
|
}
|
|
6485
|
-
exports.readUInt64BE = readUInt64BE;
|
|
6489
|
+
exports$1.readUInt64BE = readUInt64BE;
|
|
6486
6490
|
/**
|
|
6487
6491
|
* Write a uint64 (technically supports up to 53 bits per JS number
|
|
6488
6492
|
* representation).
|
|
@@ -6493,7 +6497,7 @@ function requireCodecs () {
|
|
|
6493
6497
|
offset = buffer.writeUInt32BE(high, offset); // first half of uint64
|
|
6494
6498
|
return buffer.writeUInt32BE(low, offset); // second half of uint64
|
|
6495
6499
|
}
|
|
6496
|
-
exports.writeUInt64BE = writeUInt64BE;
|
|
6500
|
+
exports$1.writeUInt64BE = writeUInt64BE;
|
|
6497
6501
|
/**
|
|
6498
6502
|
* Frame header is:
|
|
6499
6503
|
* - stream id (uint32 = 4)
|
|
@@ -6511,7 +6515,7 @@ function requireCodecs () {
|
|
|
6511
6515
|
var frameLength = readUInt24BE(buffer, 0);
|
|
6512
6516
|
return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
|
|
6513
6517
|
}
|
|
6514
|
-
exports.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
6518
|
+
exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
6515
6519
|
/**
|
|
6516
6520
|
* Given a buffer that may contain zero or more length-prefixed frames followed
|
|
6517
6521
|
* by zero or more bytes of a (partial) subsequent frame, returns an array of
|
|
@@ -6544,7 +6548,7 @@ function requireCodecs () {
|
|
|
6544
6548
|
}
|
|
6545
6549
|
});
|
|
6546
6550
|
}
|
|
6547
|
-
exports.deserializeFrames = deserializeFrames;
|
|
6551
|
+
exports$1.deserializeFrames = deserializeFrames;
|
|
6548
6552
|
/**
|
|
6549
6553
|
* Writes a frame to a buffer with a length prefix.
|
|
6550
6554
|
*/
|
|
@@ -6555,7 +6559,7 @@ function requireCodecs () {
|
|
|
6555
6559
|
buffer.copy(lengthPrefixed, UINT24_SIZE);
|
|
6556
6560
|
return lengthPrefixed;
|
|
6557
6561
|
}
|
|
6558
|
-
exports.serializeFrameWithLength = serializeFrameWithLength;
|
|
6562
|
+
exports$1.serializeFrameWithLength = serializeFrameWithLength;
|
|
6559
6563
|
/**
|
|
6560
6564
|
* Read a frame from the buffer.
|
|
6561
6565
|
*/
|
|
@@ -6570,8 +6574,8 @@ function requireCodecs () {
|
|
|
6570
6574
|
// );
|
|
6571
6575
|
var typeAndFlags = buffer.readUInt16BE(offset);
|
|
6572
6576
|
offset += 2;
|
|
6573
|
-
var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
6574
|
-
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
|
|
6575
6579
|
switch (type) {
|
|
6576
6580
|
case Frames_1.FrameTypes.SETUP:
|
|
6577
6581
|
return deserializeSetupFrame(buffer, streamId, flags);
|
|
@@ -6608,7 +6612,7 @@ function requireCodecs () {
|
|
|
6608
6612
|
// );
|
|
6609
6613
|
}
|
|
6610
6614
|
}
|
|
6611
|
-
exports.deserializeFrame = deserializeFrame;
|
|
6615
|
+
exports$1.deserializeFrame = deserializeFrame;
|
|
6612
6616
|
/**
|
|
6613
6617
|
* Convert the frame to a (binary) buffer.
|
|
6614
6618
|
*/
|
|
@@ -6647,7 +6651,7 @@ function requireCodecs () {
|
|
|
6647
6651
|
// );
|
|
6648
6652
|
}
|
|
6649
6653
|
}
|
|
6650
|
-
exports.serializeFrame = serializeFrame;
|
|
6654
|
+
exports$1.serializeFrame = serializeFrame;
|
|
6651
6655
|
/**
|
|
6652
6656
|
* Byte size of frame without size prefix
|
|
6653
6657
|
*/
|
|
@@ -6686,7 +6690,7 @@ function requireCodecs () {
|
|
|
6686
6690
|
// );
|
|
6687
6691
|
}
|
|
6688
6692
|
}
|
|
6689
|
-
exports.sizeOfFrame = sizeOfFrame;
|
|
6693
|
+
exports$1.sizeOfFrame = sizeOfFrame;
|
|
6690
6694
|
/**
|
|
6691
6695
|
* Writes a SETUP frame into a new buffer and returns it.
|
|
6692
6696
|
*
|
|
@@ -7321,7 +7325,7 @@ function requireCodecs () {
|
|
|
7321
7325
|
function writeHeader(frame, buffer) {
|
|
7322
7326
|
var offset = buffer.writeInt32BE(frame.streamId, 0);
|
|
7323
7327
|
// shift frame to high 6 bits, extract lowest 10 bits from flags
|
|
7324
|
-
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);
|
|
7325
7329
|
}
|
|
7326
7330
|
/**
|
|
7327
7331
|
* Determine the length of the payload section of a frame. Only applies to
|
|
@@ -7402,7 +7406,7 @@ function requireCodecs () {
|
|
|
7402
7406
|
};
|
|
7403
7407
|
return Deserializer;
|
|
7404
7408
|
}());
|
|
7405
|
-
exports.Deserializer = Deserializer;
|
|
7409
|
+
exports$1.Deserializer = Deserializer;
|
|
7406
7410
|
|
|
7407
7411
|
} (Codecs));
|
|
7408
7412
|
return Codecs;
|
|
@@ -7548,7 +7552,7 @@ var hasRequiredErrors;
|
|
|
7548
7552
|
function requireErrors () {
|
|
7549
7553
|
if (hasRequiredErrors) return Errors;
|
|
7550
7554
|
hasRequiredErrors = 1;
|
|
7551
|
-
(function (exports) {
|
|
7555
|
+
(function (exports$1) {
|
|
7552
7556
|
/*
|
|
7553
7557
|
* Copyright 2021-2022 the original author or authors.
|
|
7554
7558
|
*
|
|
@@ -7579,8 +7583,8 @@ function requireErrors () {
|
|
|
7579
7583
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
7580
7584
|
};
|
|
7581
7585
|
})();
|
|
7582
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7583
|
-
exports.ErrorCodes = exports.RSocketError = void 0;
|
|
7586
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
7587
|
+
exports$1.ErrorCodes = exports$1.RSocketError = void 0;
|
|
7584
7588
|
var RSocketError = /** @class */ (function (_super) {
|
|
7585
7589
|
__extends(RSocketError, _super);
|
|
7586
7590
|
function RSocketError(code, message) {
|
|
@@ -7590,7 +7594,7 @@ function requireErrors () {
|
|
|
7590
7594
|
}
|
|
7591
7595
|
return RSocketError;
|
|
7592
7596
|
}(Error));
|
|
7593
|
-
exports.RSocketError = RSocketError;
|
|
7597
|
+
exports$1.RSocketError = RSocketError;
|
|
7594
7598
|
(function (ErrorCodes) {
|
|
7595
7599
|
ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
|
|
7596
7600
|
ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
|
|
@@ -7604,7 +7608,7 @@ function requireErrors () {
|
|
|
7604
7608
|
ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
|
|
7605
7609
|
ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
|
|
7606
7610
|
ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
|
|
7607
|
-
})(exports.ErrorCodes || (exports.ErrorCodes = {}));
|
|
7611
|
+
})(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
|
|
7608
7612
|
|
|
7609
7613
|
} (Errors));
|
|
7610
7614
|
return Errors;
|
|
@@ -7646,7 +7650,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
|
|
|
7646
7650
|
function requireClientServerMultiplexerDemultiplexer () {
|
|
7647
7651
|
if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
|
|
7648
7652
|
hasRequiredClientServerMultiplexerDemultiplexer = 1;
|
|
7649
|
-
(function (exports) {
|
|
7653
|
+
(function (exports$1) {
|
|
7650
7654
|
/*
|
|
7651
7655
|
* Copyright 2021-2022 the original author or authors.
|
|
7652
7656
|
*
|
|
@@ -7713,8 +7717,8 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7713
7717
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
7714
7718
|
}
|
|
7715
7719
|
};
|
|
7716
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7717
|
-
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;
|
|
7718
7722
|
var _1 = requireDist();
|
|
7719
7723
|
var Deferred_1 = requireDeferred();
|
|
7720
7724
|
var Errors_1 = requireErrors();
|
|
@@ -7737,7 +7741,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7737
7741
|
};
|
|
7738
7742
|
return StreamIdGeneratorImpl;
|
|
7739
7743
|
}());
|
|
7740
|
-
})(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
|
|
7744
|
+
})(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
|
|
7741
7745
|
var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
7742
7746
|
__extends(ClientServerInputMultiplexerDemultiplexer, _super);
|
|
7743
7747
|
function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
|
|
@@ -7826,7 +7830,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7826
7830
|
};
|
|
7827
7831
|
return ClientServerInputMultiplexerDemultiplexer;
|
|
7828
7832
|
}(Deferred_1.Deferred));
|
|
7829
|
-
exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
7833
|
+
exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
7830
7834
|
var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
7831
7835
|
__extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
|
|
7832
7836
|
function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
|
|
@@ -7983,7 +7987,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
7983
7987
|
};
|
|
7984
7988
|
return ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7985
7989
|
}(ClientServerInputMultiplexerDemultiplexer));
|
|
7986
|
-
exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7990
|
+
exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
7987
7991
|
var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
|
|
7988
7992
|
function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
|
|
7989
7993
|
this.outbound = outbound;
|
|
@@ -8040,7 +8044,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
8040
8044
|
};
|
|
8041
8045
|
return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8042
8046
|
}());
|
|
8043
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8047
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
8044
8048
|
|
|
8045
8049
|
} (ClientServerMultiplexerDemultiplexer));
|
|
8046
8050
|
return ClientServerMultiplexerDemultiplexer;
|
|
@@ -11026,7 +11030,7 @@ var hasRequiredDist;
|
|
|
11026
11030
|
function requireDist () {
|
|
11027
11031
|
if (hasRequiredDist) return dist;
|
|
11028
11032
|
hasRequiredDist = 1;
|
|
11029
|
-
(function (exports) {
|
|
11033
|
+
(function (exports$1) {
|
|
11030
11034
|
/*
|
|
11031
11035
|
* Copyright 2021-2022 the original author or authors.
|
|
11032
11036
|
*
|
|
@@ -11049,19 +11053,19 @@ function requireDist () {
|
|
|
11049
11053
|
if (k2 === undefined) k2 = k;
|
|
11050
11054
|
o[k2] = m[k];
|
|
11051
11055
|
}));
|
|
11052
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
11053
|
-
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);
|
|
11054
11058
|
};
|
|
11055
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11056
|
-
__exportStar(requireCodecs(), exports);
|
|
11057
|
-
__exportStar(requireCommon(), exports);
|
|
11058
|
-
__exportStar(requireDeferred(), exports);
|
|
11059
|
-
__exportStar(requireErrors(), exports);
|
|
11060
|
-
__exportStar(requireFrames(), exports);
|
|
11061
|
-
__exportStar(requireRSocket(), exports);
|
|
11062
|
-
__exportStar(requireRSocketConnector(), exports);
|
|
11063
|
-
__exportStar(requireRSocketServer(), exports);
|
|
11064
|
-
__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);
|
|
11065
11069
|
|
|
11066
11070
|
} (dist));
|
|
11067
11071
|
return dist;
|
|
@@ -11069,7 +11073,7 @@ function requireDist () {
|
|
|
11069
11073
|
|
|
11070
11074
|
var distExports = requireDist();
|
|
11071
11075
|
|
|
11072
|
-
var version = "1.
|
|
11076
|
+
var version = "1.45.0";
|
|
11073
11077
|
var PACKAGE = {
|
|
11074
11078
|
version: version};
|
|
11075
11079
|
|
|
@@ -11996,6 +12000,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
11996
12000
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
11997
12001
|
};
|
|
11998
12002
|
const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
12003
|
+
appMetadata: {},
|
|
11999
12004
|
connectionMethod: exports.SyncStreamConnectionMethod.WEB_SOCKET,
|
|
12000
12005
|
clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
|
|
12001
12006
|
fetchStrategy: exports.FetchStrategy.Buffered,
|
|
@@ -12374,6 +12379,11 @@ The next upload iteration will be delayed.`);
|
|
|
12374
12379
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
12375
12380
|
...(options ?? {})
|
|
12376
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
|
+
}
|
|
12377
12387
|
const clientImplementation = resolvedOptions.clientImplementation;
|
|
12378
12388
|
this.updateSyncStatus({ clientImplementation });
|
|
12379
12389
|
if (clientImplementation == exports.SyncClientImplementation.JAVASCRIPT) {
|
|
@@ -12409,6 +12419,7 @@ The next upload iteration will be delayed.`);
|
|
|
12409
12419
|
include_checksum: true,
|
|
12410
12420
|
raw_data: true,
|
|
12411
12421
|
parameters: resolvedOptions.params,
|
|
12422
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
12412
12423
|
client_id: clientId
|
|
12413
12424
|
}
|
|
12414
12425
|
};
|
|
@@ -12768,6 +12779,7 @@ The next upload iteration will be delayed.`);
|
|
|
12768
12779
|
try {
|
|
12769
12780
|
const options = {
|
|
12770
12781
|
parameters: resolvedOptions.params,
|
|
12782
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
12771
12783
|
active_streams: this.activeStreams,
|
|
12772
12784
|
include_defaults: resolvedOptions.includeDefaultStreams
|
|
12773
12785
|
};
|
|
@@ -13404,14 +13416,14 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
13404
13416
|
async initialize() {
|
|
13405
13417
|
await this._initialize();
|
|
13406
13418
|
await this.bucketStorageAdapter.init();
|
|
13407
|
-
await this.
|
|
13419
|
+
await this.loadVersion();
|
|
13408
13420
|
await this.updateSchema(this.options.schema);
|
|
13409
13421
|
await this.resolveOfflineSyncStatus();
|
|
13410
13422
|
await this.database.execute('PRAGMA RECURSIVE_TRIGGERS=TRUE');
|
|
13411
13423
|
this.ready = true;
|
|
13412
13424
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
13413
13425
|
}
|
|
13414
|
-
async
|
|
13426
|
+
async loadVersion() {
|
|
13415
13427
|
try {
|
|
13416
13428
|
const { version } = await this.database.get('SELECT powersync_rs_version() as version');
|
|
13417
13429
|
this.sdkVersion = version;
|
|
@@ -13426,11 +13438,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
13426
13438
|
.map((n) => parseInt(n));
|
|
13427
13439
|
}
|
|
13428
13440
|
catch (e) {
|
|
13429
|
-
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}`);
|
|
13430
13442
|
}
|
|
13431
|
-
// Validate >=0.4.
|
|
13432
|
-
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] <
|
|
13433
|
-
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}`);
|
|
13434
13446
|
}
|
|
13435
13447
|
}
|
|
13436
13448
|
async resolveOfflineSyncStatus() {
|
|
@@ -14550,6 +14562,27 @@ class SyncDataBatch {
|
|
|
14550
14562
|
}
|
|
14551
14563
|
}
|
|
14552
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
|
+
|
|
14553
14586
|
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
14554
14587
|
exports.ColumnType = void 0;
|
|
14555
14588
|
(function (ColumnType) {
|
|
@@ -15113,6 +15146,7 @@ exports.AbstractStreamingSyncImplementation = AbstractStreamingSyncImplementatio
|
|
|
15113
15146
|
exports.ArrayComparator = ArrayComparator;
|
|
15114
15147
|
exports.BaseObserver = BaseObserver;
|
|
15115
15148
|
exports.Column = Column;
|
|
15149
|
+
exports.ConnectionClosedError = ConnectionClosedError;
|
|
15116
15150
|
exports.ConnectionManager = ConnectionManager;
|
|
15117
15151
|
exports.ControlledExecutor = ControlledExecutor;
|
|
15118
15152
|
exports.CrudBatch = CrudBatch;
|