@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.
Files changed (36) hide show
  1. package/dist/bundle.cjs +129 -81
  2. package/dist/bundle.cjs.map +1 -1
  3. package/dist/bundle.mjs +129 -82
  4. package/dist/bundle.mjs.map +1 -1
  5. package/dist/bundle.node.cjs +117 -69
  6. package/dist/bundle.node.cjs.map +1 -1
  7. package/dist/bundle.node.mjs +117 -70
  8. package/dist/bundle.node.mjs.map +1 -1
  9. package/dist/index.d.cts +178 -150
  10. package/lib/client/AbstractPowerSyncDatabase.d.ts +1 -1
  11. package/lib/client/AbstractPowerSyncDatabase.js +5 -5
  12. package/lib/client/AbstractPowerSyncDatabase.js.map +1 -1
  13. package/lib/client/ConnectionManager.d.ts +1 -1
  14. package/lib/client/ConnectionManager.js.map +1 -1
  15. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.d.ts +4 -0
  16. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js +8 -0
  17. package/lib/client/sync/stream/AbstractStreamingSyncImplementation.js.map +1 -1
  18. package/lib/client/sync/stream/streaming-sync-types.d.ts +4 -0
  19. package/lib/client/sync/stream/streaming-sync-types.js.map +1 -1
  20. package/lib/db/ConnectionClosedError.d.ts +10 -0
  21. package/lib/db/ConnectionClosedError.js +21 -0
  22. package/lib/db/ConnectionClosedError.js.map +1 -0
  23. package/lib/db/crud/SyncStatus.d.ts +11 -2
  24. package/lib/db/crud/SyncStatus.js +19 -1
  25. package/lib/db/crud/SyncStatus.js.map +1 -1
  26. package/lib/index.d.ts +1 -0
  27. package/lib/index.js +1 -0
  28. package/lib/index.js.map +1 -1
  29. package/package.json +1 -1
  30. package/src/client/AbstractPowerSyncDatabase.ts +8 -8
  31. package/src/client/ConnectionManager.ts +1 -1
  32. package/src/client/sync/stream/AbstractStreamingSyncImplementation.ts +19 -2
  33. package/src/client/sync/stream/streaming-sync-types.ts +5 -0
  34. package/src/db/ConnectionClosedError.ts +23 -0
  35. package/src/db/crud/SyncStatus.ts +22 -3
  36. package/src/index.ts +1 -0
@@ -571,12 +571,30 @@ class SyncStatus {
571
571
  return {
572
572
  connected: this.connected,
573
573
  connecting: this.connecting,
574
- dataFlow: this.dataFlowStatus,
574
+ dataFlow: {
575
+ ...this.dataFlowStatus,
576
+ uploadError: this.serializeError(this.dataFlowStatus.uploadError),
577
+ downloadError: this.serializeError(this.dataFlowStatus.downloadError)
578
+ },
575
579
  lastSyncedAt: this.lastSyncedAt,
576
580
  hasSynced: this.hasSynced,
577
581
  priorityStatusEntries: this.priorityStatusEntries
578
582
  };
579
583
  }
584
+ /**
585
+ * Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
586
+ * This explicitly serializes errors in the SyncStatus.
587
+ */
588
+ serializeError(error) {
589
+ if (typeof error == 'undefined') {
590
+ return undefined;
591
+ }
592
+ return {
593
+ name: error.name,
594
+ message: error.message,
595
+ stack: error.stack
596
+ };
597
+ }
580
598
  static comparePriorities(a, b) {
581
599
  return b.priority - a.priority; // Reverse because higher priorities have lower numbers
582
600
  }
@@ -1931,7 +1949,7 @@ var hasRequiredFrames;
1931
1949
  function requireFrames () {
1932
1950
  if (hasRequiredFrames) return Frames;
1933
1951
  hasRequiredFrames = 1;
1934
- (function (exports) {
1952
+ (function (exports$1) {
1935
1953
  /*
1936
1954
  * Copyright 2021-2022 the original author or authors.
1937
1955
  *
@@ -1947,8 +1965,8 @@ function requireFrames () {
1947
1965
  * See the License for the specific language governing permissions and
1948
1966
  * limitations under the License.
1949
1967
  */
1950
- Object.defineProperty(exports, "__esModule", { value: true });
1951
- exports.Frame = exports.Lengths = exports.Flags = exports.FrameTypes = void 0;
1968
+ Object.defineProperty(exports$1, "__esModule", { value: true });
1969
+ exports$1.Frame = exports$1.Lengths = exports$1.Flags = exports$1.FrameTypes = void 0;
1952
1970
  var FrameTypes;
1953
1971
  (function (FrameTypes) {
1954
1972
  FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
@@ -1967,7 +1985,7 @@ function requireFrames () {
1967
1985
  FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
1968
1986
  FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
1969
1987
  FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
1970
- })(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
1988
+ })(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
1971
1989
  (function (Flags) {
1972
1990
  Flags[Flags["NONE"] = 0] = "NONE";
1973
1991
  Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
@@ -1978,7 +1996,7 @@ function requireFrames () {
1978
1996
  Flags[Flags["NEXT"] = 32] = "NEXT";
1979
1997
  Flags[Flags["RESPOND"] = 128] = "RESPOND";
1980
1998
  Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
1981
- })(exports.Flags || (exports.Flags = {}));
1999
+ })(exports$1.Flags || (exports$1.Flags = {}));
1982
2000
  (function (Flags) {
1983
2001
  function hasMetadata(flags) {
1984
2002
  return (flags & Flags.METADATA) === Flags.METADATA;
@@ -2012,13 +2030,13 @@ function requireFrames () {
2012
2030
  return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
2013
2031
  }
2014
2032
  Flags.hasResume = hasResume;
2015
- })(exports.Flags || (exports.Flags = {}));
2033
+ })(exports$1.Flags || (exports$1.Flags = {}));
2016
2034
  (function (Lengths) {
2017
2035
  Lengths[Lengths["FRAME"] = 3] = "FRAME";
2018
2036
  Lengths[Lengths["HEADER"] = 6] = "HEADER";
2019
2037
  Lengths[Lengths["METADATA"] = 3] = "METADATA";
2020
2038
  Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
2021
- })(exports.Lengths || (exports.Lengths = {}));
2039
+ })(exports$1.Lengths || (exports$1.Lengths = {}));
2022
2040
  (function (Frame) {
2023
2041
  function isConnection(frame) {
2024
2042
  return frame.streamId === 0;
@@ -2029,7 +2047,7 @@ function requireFrames () {
2029
2047
  frame.type <= FrameTypes.REQUEST_CHANNEL);
2030
2048
  }
2031
2049
  Frame.isRequest = isRequest;
2032
- })(exports.Frame || (exports.Frame = {}));
2050
+ })(exports$1.Frame || (exports$1.Frame = {}));
2033
2051
 
2034
2052
  } (Frames));
2035
2053
  return Frames;
@@ -2040,7 +2058,7 @@ var hasRequiredCodecs;
2040
2058
  function requireCodecs () {
2041
2059
  if (hasRequiredCodecs) return Codecs;
2042
2060
  hasRequiredCodecs = 1;
2043
- (function (exports) {
2061
+ (function (exports$1) {
2044
2062
  var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
2045
2063
  var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
2046
2064
  return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
@@ -2068,22 +2086,22 @@ function requireCodecs () {
2068
2086
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
2069
2087
  }
2070
2088
  };
2071
- Object.defineProperty(exports, "__esModule", { value: true });
2072
- 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;
2089
+ Object.defineProperty(exports$1, "__esModule", { value: true });
2090
+ 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;
2073
2091
  var Frames_1 = requireFrames();
2074
- exports.FLAGS_MASK = 0x3ff; // low 10 bits
2075
- exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
2076
- exports.MAX_CODE = 0x7fffffff; // uint31
2077
- exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
2078
- exports.MAX_LIFETIME = 0x7fffffff; // uint31
2079
- exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
2080
- exports.MAX_MIME_LENGTH = 0xff; // int8
2081
- exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
2082
- exports.MAX_REQUEST_N = 0x7fffffff; // uint31
2083
- exports.MAX_RESUME_LENGTH = 0xffff; // uint16
2084
- exports.MAX_STREAM_ID = 0x7fffffff; // uint31
2085
- exports.MAX_TTL = 0x7fffffff; // uint31
2086
- exports.MAX_VERSION = 0xffff; // uint16
2092
+ exports$1.FLAGS_MASK = 0x3ff; // low 10 bits
2093
+ exports$1.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
2094
+ exports$1.MAX_CODE = 0x7fffffff; // uint31
2095
+ exports$1.MAX_KEEPALIVE = 0x7fffffff; // uint31
2096
+ exports$1.MAX_LIFETIME = 0x7fffffff; // uint31
2097
+ exports$1.MAX_METADATA_LENGTH = 0xffffff; // uint24
2098
+ exports$1.MAX_MIME_LENGTH = 0xff; // int8
2099
+ exports$1.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
2100
+ exports$1.MAX_REQUEST_N = 0x7fffffff; // uint31
2101
+ exports$1.MAX_RESUME_LENGTH = 0xffff; // uint16
2102
+ exports$1.MAX_STREAM_ID = 0x7fffffff; // uint31
2103
+ exports$1.MAX_TTL = 0x7fffffff; // uint31
2104
+ exports$1.MAX_VERSION = 0xffff; // uint16
2087
2105
  /**
2088
2106
  * Mimimum value that would overflow bitwise operators (2^32).
2089
2107
  */
@@ -2097,7 +2115,7 @@ function requireCodecs () {
2097
2115
  var val3 = buffer.readUInt8(offset + 2);
2098
2116
  return val1 | val2 | val3;
2099
2117
  }
2100
- exports.readUInt24BE = readUInt24BE;
2118
+ exports$1.readUInt24BE = readUInt24BE;
2101
2119
  /**
2102
2120
  * Writes a uint24 to a buffer starting at the given offset, returning the
2103
2121
  * offset of the next byte.
@@ -2107,7 +2125,7 @@ function requireCodecs () {
2107
2125
  offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
2108
2126
  return buffer.writeUInt8(value & 0xff, offset); // 1st byte
2109
2127
  }
2110
- exports.writeUInt24BE = writeUInt24BE;
2128
+ exports$1.writeUInt24BE = writeUInt24BE;
2111
2129
  /**
2112
2130
  * Read a uint64 (technically supports up to 53 bits per JS number
2113
2131
  * representation).
@@ -2117,7 +2135,7 @@ function requireCodecs () {
2117
2135
  var low = buffer.readUInt32BE(offset + 4);
2118
2136
  return high * BITWISE_OVERFLOW + low;
2119
2137
  }
2120
- exports.readUInt64BE = readUInt64BE;
2138
+ exports$1.readUInt64BE = readUInt64BE;
2121
2139
  /**
2122
2140
  * Write a uint64 (technically supports up to 53 bits per JS number
2123
2141
  * representation).
@@ -2128,7 +2146,7 @@ function requireCodecs () {
2128
2146
  offset = buffer.writeUInt32BE(high, offset); // first half of uint64
2129
2147
  return buffer.writeUInt32BE(low, offset); // second half of uint64
2130
2148
  }
2131
- exports.writeUInt64BE = writeUInt64BE;
2149
+ exports$1.writeUInt64BE = writeUInt64BE;
2132
2150
  /**
2133
2151
  * Frame header is:
2134
2152
  * - stream id (uint32 = 4)
@@ -2146,7 +2164,7 @@ function requireCodecs () {
2146
2164
  var frameLength = readUInt24BE(buffer, 0);
2147
2165
  return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
2148
2166
  }
2149
- exports.deserializeFrameWithLength = deserializeFrameWithLength;
2167
+ exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
2150
2168
  /**
2151
2169
  * Given a buffer that may contain zero or more length-prefixed frames followed
2152
2170
  * by zero or more bytes of a (partial) subsequent frame, returns an array of
@@ -2179,7 +2197,7 @@ function requireCodecs () {
2179
2197
  }
2180
2198
  });
2181
2199
  }
2182
- exports.deserializeFrames = deserializeFrames;
2200
+ exports$1.deserializeFrames = deserializeFrames;
2183
2201
  /**
2184
2202
  * Writes a frame to a buffer with a length prefix.
2185
2203
  */
@@ -2190,7 +2208,7 @@ function requireCodecs () {
2190
2208
  buffer.copy(lengthPrefixed, UINT24_SIZE);
2191
2209
  return lengthPrefixed;
2192
2210
  }
2193
- exports.serializeFrameWithLength = serializeFrameWithLength;
2211
+ exports$1.serializeFrameWithLength = serializeFrameWithLength;
2194
2212
  /**
2195
2213
  * Read a frame from the buffer.
2196
2214
  */
@@ -2205,8 +2223,8 @@ function requireCodecs () {
2205
2223
  // );
2206
2224
  var typeAndFlags = buffer.readUInt16BE(offset);
2207
2225
  offset += 2;
2208
- var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
2209
- var flags = typeAndFlags & exports.FLAGS_MASK; // keep lowest 10 bits
2226
+ var type = typeAndFlags >>> exports$1.FRAME_TYPE_OFFFSET; // keep highest 6 bits
2227
+ var flags = typeAndFlags & exports$1.FLAGS_MASK; // keep lowest 10 bits
2210
2228
  switch (type) {
2211
2229
  case Frames_1.FrameTypes.SETUP:
2212
2230
  return deserializeSetupFrame(buffer, streamId, flags);
@@ -2243,7 +2261,7 @@ function requireCodecs () {
2243
2261
  // );
2244
2262
  }
2245
2263
  }
2246
- exports.deserializeFrame = deserializeFrame;
2264
+ exports$1.deserializeFrame = deserializeFrame;
2247
2265
  /**
2248
2266
  * Convert the frame to a (binary) buffer.
2249
2267
  */
@@ -2282,7 +2300,7 @@ function requireCodecs () {
2282
2300
  // );
2283
2301
  }
2284
2302
  }
2285
- exports.serializeFrame = serializeFrame;
2303
+ exports$1.serializeFrame = serializeFrame;
2286
2304
  /**
2287
2305
  * Byte size of frame without size prefix
2288
2306
  */
@@ -2321,7 +2339,7 @@ function requireCodecs () {
2321
2339
  // );
2322
2340
  }
2323
2341
  }
2324
- exports.sizeOfFrame = sizeOfFrame;
2342
+ exports$1.sizeOfFrame = sizeOfFrame;
2325
2343
  /**
2326
2344
  * Writes a SETUP frame into a new buffer and returns it.
2327
2345
  *
@@ -2956,7 +2974,7 @@ function requireCodecs () {
2956
2974
  function writeHeader(frame, buffer) {
2957
2975
  var offset = buffer.writeInt32BE(frame.streamId, 0);
2958
2976
  // shift frame to high 6 bits, extract lowest 10 bits from flags
2959
- return buffer.writeUInt16BE((frame.type << exports.FRAME_TYPE_OFFFSET) | (frame.flags & exports.FLAGS_MASK), offset);
2977
+ return buffer.writeUInt16BE((frame.type << exports$1.FRAME_TYPE_OFFFSET) | (frame.flags & exports$1.FLAGS_MASK), offset);
2960
2978
  }
2961
2979
  /**
2962
2980
  * Determine the length of the payload section of a frame. Only applies to
@@ -3037,7 +3055,7 @@ function requireCodecs () {
3037
3055
  };
3038
3056
  return Deserializer;
3039
3057
  }());
3040
- exports.Deserializer = Deserializer;
3058
+ exports$1.Deserializer = Deserializer;
3041
3059
 
3042
3060
  } (Codecs));
3043
3061
  return Codecs;
@@ -3183,7 +3201,7 @@ var hasRequiredErrors;
3183
3201
  function requireErrors () {
3184
3202
  if (hasRequiredErrors) return Errors;
3185
3203
  hasRequiredErrors = 1;
3186
- (function (exports) {
3204
+ (function (exports$1) {
3187
3205
  /*
3188
3206
  * Copyright 2021-2022 the original author or authors.
3189
3207
  *
@@ -3214,8 +3232,8 @@ function requireErrors () {
3214
3232
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
3215
3233
  };
3216
3234
  })();
3217
- Object.defineProperty(exports, "__esModule", { value: true });
3218
- exports.ErrorCodes = exports.RSocketError = void 0;
3235
+ Object.defineProperty(exports$1, "__esModule", { value: true });
3236
+ exports$1.ErrorCodes = exports$1.RSocketError = void 0;
3219
3237
  var RSocketError = /** @class */ (function (_super) {
3220
3238
  __extends(RSocketError, _super);
3221
3239
  function RSocketError(code, message) {
@@ -3225,7 +3243,7 @@ function requireErrors () {
3225
3243
  }
3226
3244
  return RSocketError;
3227
3245
  }(Error));
3228
- exports.RSocketError = RSocketError;
3246
+ exports$1.RSocketError = RSocketError;
3229
3247
  (function (ErrorCodes) {
3230
3248
  ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
3231
3249
  ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
@@ -3239,7 +3257,7 @@ function requireErrors () {
3239
3257
  ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
3240
3258
  ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
3241
3259
  ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
3242
- })(exports.ErrorCodes || (exports.ErrorCodes = {}));
3260
+ })(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
3243
3261
 
3244
3262
  } (Errors));
3245
3263
  return Errors;
@@ -3281,7 +3299,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
3281
3299
  function requireClientServerMultiplexerDemultiplexer () {
3282
3300
  if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
3283
3301
  hasRequiredClientServerMultiplexerDemultiplexer = 1;
3284
- (function (exports) {
3302
+ (function (exports$1) {
3285
3303
  /*
3286
3304
  * Copyright 2021-2022 the original author or authors.
3287
3305
  *
@@ -3348,8 +3366,8 @@ function requireClientServerMultiplexerDemultiplexer () {
3348
3366
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
3349
3367
  }
3350
3368
  };
3351
- Object.defineProperty(exports, "__esModule", { value: true });
3352
- exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports.ResumableClientServerInputMultiplexerDemultiplexer = exports.ClientServerInputMultiplexerDemultiplexer = exports.StreamIdGenerator = void 0;
3369
+ Object.defineProperty(exports$1, "__esModule", { value: true });
3370
+ exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports$1.ResumableClientServerInputMultiplexerDemultiplexer = exports$1.ClientServerInputMultiplexerDemultiplexer = exports$1.StreamIdGenerator = void 0;
3353
3371
  var _1 = requireDist();
3354
3372
  var Deferred_1 = requireDeferred();
3355
3373
  var Errors_1 = requireErrors();
@@ -3372,7 +3390,7 @@ function requireClientServerMultiplexerDemultiplexer () {
3372
3390
  };
3373
3391
  return StreamIdGeneratorImpl;
3374
3392
  }());
3375
- })(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
3393
+ })(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
3376
3394
  var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
3377
3395
  __extends(ClientServerInputMultiplexerDemultiplexer, _super);
3378
3396
  function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
@@ -3461,7 +3479,7 @@ function requireClientServerMultiplexerDemultiplexer () {
3461
3479
  };
3462
3480
  return ClientServerInputMultiplexerDemultiplexer;
3463
3481
  }(Deferred_1.Deferred));
3464
- exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
3482
+ exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
3465
3483
  var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
3466
3484
  __extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
3467
3485
  function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
@@ -3618,7 +3636,7 @@ function requireClientServerMultiplexerDemultiplexer () {
3618
3636
  };
3619
3637
  return ResumableClientServerInputMultiplexerDemultiplexer;
3620
3638
  }(ClientServerInputMultiplexerDemultiplexer));
3621
- exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
3639
+ exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
3622
3640
  var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
3623
3641
  function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
3624
3642
  this.outbound = outbound;
@@ -3675,7 +3693,7 @@ function requireClientServerMultiplexerDemultiplexer () {
3675
3693
  };
3676
3694
  return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
3677
3695
  }());
3678
- exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
3696
+ exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
3679
3697
 
3680
3698
  } (ClientServerMultiplexerDemultiplexer));
3681
3699
  return ClientServerMultiplexerDemultiplexer;
@@ -6661,7 +6679,7 @@ var hasRequiredDist;
6661
6679
  function requireDist () {
6662
6680
  if (hasRequiredDist) return dist;
6663
6681
  hasRequiredDist = 1;
6664
- (function (exports) {
6682
+ (function (exports$1) {
6665
6683
  /*
6666
6684
  * Copyright 2021-2022 the original author or authors.
6667
6685
  *
@@ -6684,19 +6702,19 @@ function requireDist () {
6684
6702
  if (k2 === undefined) k2 = k;
6685
6703
  o[k2] = m[k];
6686
6704
  }));
6687
- var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
6688
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
6705
+ var __exportStar = (dist && dist.__exportStar) || function(m, exports$1) {
6706
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
6689
6707
  };
6690
- Object.defineProperty(exports, "__esModule", { value: true });
6691
- __exportStar(requireCodecs(), exports);
6692
- __exportStar(requireCommon(), exports);
6693
- __exportStar(requireDeferred(), exports);
6694
- __exportStar(requireErrors(), exports);
6695
- __exportStar(requireFrames(), exports);
6696
- __exportStar(requireRSocket(), exports);
6697
- __exportStar(requireRSocketConnector(), exports);
6698
- __exportStar(requireRSocketServer(), exports);
6699
- __exportStar(requireTransport(), exports);
6708
+ Object.defineProperty(exports$1, "__esModule", { value: true });
6709
+ __exportStar(requireCodecs(), exports$1);
6710
+ __exportStar(requireCommon(), exports$1);
6711
+ __exportStar(requireDeferred(), exports$1);
6712
+ __exportStar(requireErrors(), exports$1);
6713
+ __exportStar(requireFrames(), exports$1);
6714
+ __exportStar(requireRSocket(), exports$1);
6715
+ __exportStar(requireRSocketConnector(), exports$1);
6716
+ __exportStar(requireRSocketServer(), exports$1);
6717
+ __exportStar(requireTransport(), exports$1);
6700
6718
 
6701
6719
  } (dist));
6702
6720
  return dist;
@@ -6704,7 +6722,7 @@ function requireDist () {
6704
6722
 
6705
6723
  var distExports = requireDist();
6706
6724
 
6707
- var version = "1.43.1";
6725
+ var version = "1.45.0";
6708
6726
  var PACKAGE = {
6709
6727
  version: version};
6710
6728
 
@@ -7631,6 +7649,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
7631
7649
  crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
7632
7650
  };
7633
7651
  const DEFAULT_STREAM_CONNECTION_OPTIONS = {
7652
+ appMetadata: {},
7634
7653
  connectionMethod: exports.SyncStreamConnectionMethod.WEB_SOCKET,
7635
7654
  clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
7636
7655
  fetchStrategy: exports.FetchStrategy.Buffered,
@@ -8009,6 +8028,11 @@ The next upload iteration will be delayed.`);
8009
8028
  ...DEFAULT_STREAM_CONNECTION_OPTIONS,
8010
8029
  ...(options ?? {})
8011
8030
  };
8031
+ // Validate app metadata
8032
+ const invalidMetadata = Object.entries(resolvedOptions.appMetadata).filter(([_, value]) => typeof value != 'string');
8033
+ if (invalidMetadata.length > 0) {
8034
+ throw new Error(`Invalid appMetadata provided. Only string values are allowed. Invalid values: ${invalidMetadata.map(([key, value]) => `${key}: ${value}`).join(', ')}`);
8035
+ }
8012
8036
  const clientImplementation = resolvedOptions.clientImplementation;
8013
8037
  this.updateSyncStatus({ clientImplementation });
8014
8038
  if (clientImplementation == exports.SyncClientImplementation.JAVASCRIPT) {
@@ -8044,6 +8068,7 @@ The next upload iteration will be delayed.`);
8044
8068
  include_checksum: true,
8045
8069
  raw_data: true,
8046
8070
  parameters: resolvedOptions.params,
8071
+ app_metadata: resolvedOptions.appMetadata,
8047
8072
  client_id: clientId
8048
8073
  }
8049
8074
  };
@@ -8403,6 +8428,7 @@ The next upload iteration will be delayed.`);
8403
8428
  try {
8404
8429
  const options = {
8405
8430
  parameters: resolvedOptions.params,
8431
+ app_metadata: resolvedOptions.appMetadata,
8406
8432
  active_streams: this.activeStreams,
8407
8433
  include_defaults: resolvedOptions.includeDefaultStreams
8408
8434
  };
@@ -9061,11 +9087,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
9061
9087
  .map((n) => parseInt(n));
9062
9088
  }
9063
9089
  catch (e) {
9064
- throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
9090
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
9065
9091
  }
9066
- // Validate >=0.4.5 <1.0.0
9067
- if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 5)) {
9068
- throw new Error(`Unsupported powersync extension version. Need >=0.4.5 <1.0.0, got: ${this.sdkVersion}`);
9092
+ // Validate >=0.4.10 <1.0.0
9093
+ if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 10)) {
9094
+ throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}`);
9069
9095
  }
9070
9096
  }
9071
9097
  async resolveOfflineSyncStatus() {
@@ -10185,6 +10211,27 @@ class SyncDataBatch {
10185
10211
  }
10186
10212
  }
10187
10213
 
10214
+ /**
10215
+ * Thrown when an underlying database connection is closed.
10216
+ * This is particularly relevant when worker connections are marked as closed while
10217
+ * operations are still in progress.
10218
+ */
10219
+ class ConnectionClosedError extends Error {
10220
+ static NAME = 'ConnectionClosedError';
10221
+ static MATCHES(input) {
10222
+ /**
10223
+ * If there are weird package issues which cause multiple versions of classes to be present, the instanceof
10224
+ * check might fail. This also performs a failsafe check.
10225
+ * This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
10226
+ */
10227
+ return (input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME));
10228
+ }
10229
+ constructor(message) {
10230
+ super(message);
10231
+ this.name = ConnectionClosedError.NAME;
10232
+ }
10233
+ }
10234
+
10188
10235
  // https://www.sqlite.org/lang_expr.html#castexpr
10189
10236
  exports.ColumnType = void 0;
10190
10237
  (function (ColumnType) {
@@ -10748,6 +10795,7 @@ exports.AbstractStreamingSyncImplementation = AbstractStreamingSyncImplementatio
10748
10795
  exports.ArrayComparator = ArrayComparator;
10749
10796
  exports.BaseObserver = BaseObserver;
10750
10797
  exports.Column = Column;
10798
+ exports.ConnectionClosedError = ConnectionClosedError;
10751
10799
  exports.ConnectionManager = ConnectionManager;
10752
10800
  exports.ControlledExecutor = ControlledExecutor;
10753
10801
  exports.CrudBatch = CrudBatch;