@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.node.cjs
CHANGED
|
@@ -581,6 +581,10 @@ class SyncStatus {
|
|
|
581
581
|
priorityStatusEntries: this.priorityStatusEntries
|
|
582
582
|
};
|
|
583
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
|
+
*/
|
|
584
588
|
serializeError(error) {
|
|
585
589
|
if (typeof error == 'undefined') {
|
|
586
590
|
return undefined;
|
|
@@ -1945,7 +1949,7 @@ var hasRequiredFrames;
|
|
|
1945
1949
|
function requireFrames () {
|
|
1946
1950
|
if (hasRequiredFrames) return Frames;
|
|
1947
1951
|
hasRequiredFrames = 1;
|
|
1948
|
-
(function (exports) {
|
|
1952
|
+
(function (exports$1) {
|
|
1949
1953
|
/*
|
|
1950
1954
|
* Copyright 2021-2022 the original author or authors.
|
|
1951
1955
|
*
|
|
@@ -1961,8 +1965,8 @@ function requireFrames () {
|
|
|
1961
1965
|
* See the License for the specific language governing permissions and
|
|
1962
1966
|
* limitations under the License.
|
|
1963
1967
|
*/
|
|
1964
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1965
|
-
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;
|
|
1966
1970
|
var FrameTypes;
|
|
1967
1971
|
(function (FrameTypes) {
|
|
1968
1972
|
FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
|
|
@@ -1981,7 +1985,7 @@ function requireFrames () {
|
|
|
1981
1985
|
FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
|
|
1982
1986
|
FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
|
|
1983
1987
|
FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
|
|
1984
|
-
})(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
|
|
1988
|
+
})(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
|
|
1985
1989
|
(function (Flags) {
|
|
1986
1990
|
Flags[Flags["NONE"] = 0] = "NONE";
|
|
1987
1991
|
Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
|
|
@@ -1992,7 +1996,7 @@ function requireFrames () {
|
|
|
1992
1996
|
Flags[Flags["NEXT"] = 32] = "NEXT";
|
|
1993
1997
|
Flags[Flags["RESPOND"] = 128] = "RESPOND";
|
|
1994
1998
|
Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
|
|
1995
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
1999
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
1996
2000
|
(function (Flags) {
|
|
1997
2001
|
function hasMetadata(flags) {
|
|
1998
2002
|
return (flags & Flags.METADATA) === Flags.METADATA;
|
|
@@ -2026,13 +2030,13 @@ function requireFrames () {
|
|
|
2026
2030
|
return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
|
|
2027
2031
|
}
|
|
2028
2032
|
Flags.hasResume = hasResume;
|
|
2029
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
2033
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
2030
2034
|
(function (Lengths) {
|
|
2031
2035
|
Lengths[Lengths["FRAME"] = 3] = "FRAME";
|
|
2032
2036
|
Lengths[Lengths["HEADER"] = 6] = "HEADER";
|
|
2033
2037
|
Lengths[Lengths["METADATA"] = 3] = "METADATA";
|
|
2034
2038
|
Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
|
|
2035
|
-
})(exports.Lengths || (exports.Lengths = {}));
|
|
2039
|
+
})(exports$1.Lengths || (exports$1.Lengths = {}));
|
|
2036
2040
|
(function (Frame) {
|
|
2037
2041
|
function isConnection(frame) {
|
|
2038
2042
|
return frame.streamId === 0;
|
|
@@ -2043,7 +2047,7 @@ function requireFrames () {
|
|
|
2043
2047
|
frame.type <= FrameTypes.REQUEST_CHANNEL);
|
|
2044
2048
|
}
|
|
2045
2049
|
Frame.isRequest = isRequest;
|
|
2046
|
-
})(exports.Frame || (exports.Frame = {}));
|
|
2050
|
+
})(exports$1.Frame || (exports$1.Frame = {}));
|
|
2047
2051
|
|
|
2048
2052
|
} (Frames));
|
|
2049
2053
|
return Frames;
|
|
@@ -2054,7 +2058,7 @@ var hasRequiredCodecs;
|
|
|
2054
2058
|
function requireCodecs () {
|
|
2055
2059
|
if (hasRequiredCodecs) return Codecs;
|
|
2056
2060
|
hasRequiredCodecs = 1;
|
|
2057
|
-
(function (exports) {
|
|
2061
|
+
(function (exports$1) {
|
|
2058
2062
|
var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
|
|
2059
2063
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2060
2064
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
@@ -2082,22 +2086,22 @@ function requireCodecs () {
|
|
|
2082
2086
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2083
2087
|
}
|
|
2084
2088
|
};
|
|
2085
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2086
|
-
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;
|
|
2087
2091
|
var Frames_1 = requireFrames();
|
|
2088
|
-
exports.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
2089
|
-
exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
2090
|
-
exports.MAX_CODE = 0x7fffffff; // uint31
|
|
2091
|
-
exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
2092
|
-
exports.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
2093
|
-
exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
2094
|
-
exports.MAX_MIME_LENGTH = 0xff; // int8
|
|
2095
|
-
exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
2096
|
-
exports.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
2097
|
-
exports.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
2098
|
-
exports.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
2099
|
-
exports.MAX_TTL = 0x7fffffff; // uint31
|
|
2100
|
-
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
|
|
2101
2105
|
/**
|
|
2102
2106
|
* Mimimum value that would overflow bitwise operators (2^32).
|
|
2103
2107
|
*/
|
|
@@ -2111,7 +2115,7 @@ function requireCodecs () {
|
|
|
2111
2115
|
var val3 = buffer.readUInt8(offset + 2);
|
|
2112
2116
|
return val1 | val2 | val3;
|
|
2113
2117
|
}
|
|
2114
|
-
exports.readUInt24BE = readUInt24BE;
|
|
2118
|
+
exports$1.readUInt24BE = readUInt24BE;
|
|
2115
2119
|
/**
|
|
2116
2120
|
* Writes a uint24 to a buffer starting at the given offset, returning the
|
|
2117
2121
|
* offset of the next byte.
|
|
@@ -2121,7 +2125,7 @@ function requireCodecs () {
|
|
|
2121
2125
|
offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
|
|
2122
2126
|
return buffer.writeUInt8(value & 0xff, offset); // 1st byte
|
|
2123
2127
|
}
|
|
2124
|
-
exports.writeUInt24BE = writeUInt24BE;
|
|
2128
|
+
exports$1.writeUInt24BE = writeUInt24BE;
|
|
2125
2129
|
/**
|
|
2126
2130
|
* Read a uint64 (technically supports up to 53 bits per JS number
|
|
2127
2131
|
* representation).
|
|
@@ -2131,7 +2135,7 @@ function requireCodecs () {
|
|
|
2131
2135
|
var low = buffer.readUInt32BE(offset + 4);
|
|
2132
2136
|
return high * BITWISE_OVERFLOW + low;
|
|
2133
2137
|
}
|
|
2134
|
-
exports.readUInt64BE = readUInt64BE;
|
|
2138
|
+
exports$1.readUInt64BE = readUInt64BE;
|
|
2135
2139
|
/**
|
|
2136
2140
|
* Write a uint64 (technically supports up to 53 bits per JS number
|
|
2137
2141
|
* representation).
|
|
@@ -2142,7 +2146,7 @@ function requireCodecs () {
|
|
|
2142
2146
|
offset = buffer.writeUInt32BE(high, offset); // first half of uint64
|
|
2143
2147
|
return buffer.writeUInt32BE(low, offset); // second half of uint64
|
|
2144
2148
|
}
|
|
2145
|
-
exports.writeUInt64BE = writeUInt64BE;
|
|
2149
|
+
exports$1.writeUInt64BE = writeUInt64BE;
|
|
2146
2150
|
/**
|
|
2147
2151
|
* Frame header is:
|
|
2148
2152
|
* - stream id (uint32 = 4)
|
|
@@ -2160,7 +2164,7 @@ function requireCodecs () {
|
|
|
2160
2164
|
var frameLength = readUInt24BE(buffer, 0);
|
|
2161
2165
|
return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
|
|
2162
2166
|
}
|
|
2163
|
-
exports.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
2167
|
+
exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
2164
2168
|
/**
|
|
2165
2169
|
* Given a buffer that may contain zero or more length-prefixed frames followed
|
|
2166
2170
|
* by zero or more bytes of a (partial) subsequent frame, returns an array of
|
|
@@ -2193,7 +2197,7 @@ function requireCodecs () {
|
|
|
2193
2197
|
}
|
|
2194
2198
|
});
|
|
2195
2199
|
}
|
|
2196
|
-
exports.deserializeFrames = deserializeFrames;
|
|
2200
|
+
exports$1.deserializeFrames = deserializeFrames;
|
|
2197
2201
|
/**
|
|
2198
2202
|
* Writes a frame to a buffer with a length prefix.
|
|
2199
2203
|
*/
|
|
@@ -2204,7 +2208,7 @@ function requireCodecs () {
|
|
|
2204
2208
|
buffer.copy(lengthPrefixed, UINT24_SIZE);
|
|
2205
2209
|
return lengthPrefixed;
|
|
2206
2210
|
}
|
|
2207
|
-
exports.serializeFrameWithLength = serializeFrameWithLength;
|
|
2211
|
+
exports$1.serializeFrameWithLength = serializeFrameWithLength;
|
|
2208
2212
|
/**
|
|
2209
2213
|
* Read a frame from the buffer.
|
|
2210
2214
|
*/
|
|
@@ -2219,8 +2223,8 @@ function requireCodecs () {
|
|
|
2219
2223
|
// );
|
|
2220
2224
|
var typeAndFlags = buffer.readUInt16BE(offset);
|
|
2221
2225
|
offset += 2;
|
|
2222
|
-
var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
2223
|
-
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
|
|
2224
2228
|
switch (type) {
|
|
2225
2229
|
case Frames_1.FrameTypes.SETUP:
|
|
2226
2230
|
return deserializeSetupFrame(buffer, streamId, flags);
|
|
@@ -2257,7 +2261,7 @@ function requireCodecs () {
|
|
|
2257
2261
|
// );
|
|
2258
2262
|
}
|
|
2259
2263
|
}
|
|
2260
|
-
exports.deserializeFrame = deserializeFrame;
|
|
2264
|
+
exports$1.deserializeFrame = deserializeFrame;
|
|
2261
2265
|
/**
|
|
2262
2266
|
* Convert the frame to a (binary) buffer.
|
|
2263
2267
|
*/
|
|
@@ -2296,7 +2300,7 @@ function requireCodecs () {
|
|
|
2296
2300
|
// );
|
|
2297
2301
|
}
|
|
2298
2302
|
}
|
|
2299
|
-
exports.serializeFrame = serializeFrame;
|
|
2303
|
+
exports$1.serializeFrame = serializeFrame;
|
|
2300
2304
|
/**
|
|
2301
2305
|
* Byte size of frame without size prefix
|
|
2302
2306
|
*/
|
|
@@ -2335,7 +2339,7 @@ function requireCodecs () {
|
|
|
2335
2339
|
// );
|
|
2336
2340
|
}
|
|
2337
2341
|
}
|
|
2338
|
-
exports.sizeOfFrame = sizeOfFrame;
|
|
2342
|
+
exports$1.sizeOfFrame = sizeOfFrame;
|
|
2339
2343
|
/**
|
|
2340
2344
|
* Writes a SETUP frame into a new buffer and returns it.
|
|
2341
2345
|
*
|
|
@@ -2970,7 +2974,7 @@ function requireCodecs () {
|
|
|
2970
2974
|
function writeHeader(frame, buffer) {
|
|
2971
2975
|
var offset = buffer.writeInt32BE(frame.streamId, 0);
|
|
2972
2976
|
// shift frame to high 6 bits, extract lowest 10 bits from flags
|
|
2973
|
-
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);
|
|
2974
2978
|
}
|
|
2975
2979
|
/**
|
|
2976
2980
|
* Determine the length of the payload section of a frame. Only applies to
|
|
@@ -3051,7 +3055,7 @@ function requireCodecs () {
|
|
|
3051
3055
|
};
|
|
3052
3056
|
return Deserializer;
|
|
3053
3057
|
}());
|
|
3054
|
-
exports.Deserializer = Deserializer;
|
|
3058
|
+
exports$1.Deserializer = Deserializer;
|
|
3055
3059
|
|
|
3056
3060
|
} (Codecs));
|
|
3057
3061
|
return Codecs;
|
|
@@ -3197,7 +3201,7 @@ var hasRequiredErrors;
|
|
|
3197
3201
|
function requireErrors () {
|
|
3198
3202
|
if (hasRequiredErrors) return Errors;
|
|
3199
3203
|
hasRequiredErrors = 1;
|
|
3200
|
-
(function (exports) {
|
|
3204
|
+
(function (exports$1) {
|
|
3201
3205
|
/*
|
|
3202
3206
|
* Copyright 2021-2022 the original author or authors.
|
|
3203
3207
|
*
|
|
@@ -3228,8 +3232,8 @@ function requireErrors () {
|
|
|
3228
3232
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3229
3233
|
};
|
|
3230
3234
|
})();
|
|
3231
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3232
|
-
exports.ErrorCodes = exports.RSocketError = void 0;
|
|
3235
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
3236
|
+
exports$1.ErrorCodes = exports$1.RSocketError = void 0;
|
|
3233
3237
|
var RSocketError = /** @class */ (function (_super) {
|
|
3234
3238
|
__extends(RSocketError, _super);
|
|
3235
3239
|
function RSocketError(code, message) {
|
|
@@ -3239,7 +3243,7 @@ function requireErrors () {
|
|
|
3239
3243
|
}
|
|
3240
3244
|
return RSocketError;
|
|
3241
3245
|
}(Error));
|
|
3242
|
-
exports.RSocketError = RSocketError;
|
|
3246
|
+
exports$1.RSocketError = RSocketError;
|
|
3243
3247
|
(function (ErrorCodes) {
|
|
3244
3248
|
ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
|
|
3245
3249
|
ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
|
|
@@ -3253,7 +3257,7 @@ function requireErrors () {
|
|
|
3253
3257
|
ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
|
|
3254
3258
|
ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
|
|
3255
3259
|
ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
|
|
3256
|
-
})(exports.ErrorCodes || (exports.ErrorCodes = {}));
|
|
3260
|
+
})(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
|
|
3257
3261
|
|
|
3258
3262
|
} (Errors));
|
|
3259
3263
|
return Errors;
|
|
@@ -3295,7 +3299,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
|
|
|
3295
3299
|
function requireClientServerMultiplexerDemultiplexer () {
|
|
3296
3300
|
if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
|
|
3297
3301
|
hasRequiredClientServerMultiplexerDemultiplexer = 1;
|
|
3298
|
-
(function (exports) {
|
|
3302
|
+
(function (exports$1) {
|
|
3299
3303
|
/*
|
|
3300
3304
|
* Copyright 2021-2022 the original author or authors.
|
|
3301
3305
|
*
|
|
@@ -3362,8 +3366,8 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3362
3366
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
3363
3367
|
}
|
|
3364
3368
|
};
|
|
3365
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3366
|
-
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;
|
|
3367
3371
|
var _1 = requireDist();
|
|
3368
3372
|
var Deferred_1 = requireDeferred();
|
|
3369
3373
|
var Errors_1 = requireErrors();
|
|
@@ -3386,7 +3390,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3386
3390
|
};
|
|
3387
3391
|
return StreamIdGeneratorImpl;
|
|
3388
3392
|
}());
|
|
3389
|
-
})(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
|
|
3393
|
+
})(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
|
|
3390
3394
|
var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
3391
3395
|
__extends(ClientServerInputMultiplexerDemultiplexer, _super);
|
|
3392
3396
|
function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
|
|
@@ -3475,7 +3479,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3475
3479
|
};
|
|
3476
3480
|
return ClientServerInputMultiplexerDemultiplexer;
|
|
3477
3481
|
}(Deferred_1.Deferred));
|
|
3478
|
-
exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
3482
|
+
exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
3479
3483
|
var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
3480
3484
|
__extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
|
|
3481
3485
|
function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
|
|
@@ -3632,7 +3636,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3632
3636
|
};
|
|
3633
3637
|
return ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3634
3638
|
}(ClientServerInputMultiplexerDemultiplexer));
|
|
3635
|
-
exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3639
|
+
exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3636
3640
|
var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
|
|
3637
3641
|
function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
|
|
3638
3642
|
this.outbound = outbound;
|
|
@@ -3689,7 +3693,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3689
3693
|
};
|
|
3690
3694
|
return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3691
3695
|
}());
|
|
3692
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3696
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3693
3697
|
|
|
3694
3698
|
} (ClientServerMultiplexerDemultiplexer));
|
|
3695
3699
|
return ClientServerMultiplexerDemultiplexer;
|
|
@@ -6675,7 +6679,7 @@ var hasRequiredDist;
|
|
|
6675
6679
|
function requireDist () {
|
|
6676
6680
|
if (hasRequiredDist) return dist;
|
|
6677
6681
|
hasRequiredDist = 1;
|
|
6678
|
-
(function (exports) {
|
|
6682
|
+
(function (exports$1) {
|
|
6679
6683
|
/*
|
|
6680
6684
|
* Copyright 2021-2022 the original author or authors.
|
|
6681
6685
|
*
|
|
@@ -6698,19 +6702,19 @@ function requireDist () {
|
|
|
6698
6702
|
if (k2 === undefined) k2 = k;
|
|
6699
6703
|
o[k2] = m[k];
|
|
6700
6704
|
}));
|
|
6701
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
6702
|
-
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);
|
|
6703
6707
|
};
|
|
6704
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6705
|
-
__exportStar(requireCodecs(), exports);
|
|
6706
|
-
__exportStar(requireCommon(), exports);
|
|
6707
|
-
__exportStar(requireDeferred(), exports);
|
|
6708
|
-
__exportStar(requireErrors(), exports);
|
|
6709
|
-
__exportStar(requireFrames(), exports);
|
|
6710
|
-
__exportStar(requireRSocket(), exports);
|
|
6711
|
-
__exportStar(requireRSocketConnector(), exports);
|
|
6712
|
-
__exportStar(requireRSocketServer(), exports);
|
|
6713
|
-
__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);
|
|
6714
6718
|
|
|
6715
6719
|
} (dist));
|
|
6716
6720
|
return dist;
|
|
@@ -6718,7 +6722,7 @@ function requireDist () {
|
|
|
6718
6722
|
|
|
6719
6723
|
var distExports = requireDist();
|
|
6720
6724
|
|
|
6721
|
-
var version = "1.
|
|
6725
|
+
var version = "1.45.0";
|
|
6722
6726
|
var PACKAGE = {
|
|
6723
6727
|
version: version};
|
|
6724
6728
|
|
|
@@ -7645,6 +7649,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
7645
7649
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
7646
7650
|
};
|
|
7647
7651
|
const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
7652
|
+
appMetadata: {},
|
|
7648
7653
|
connectionMethod: exports.SyncStreamConnectionMethod.WEB_SOCKET,
|
|
7649
7654
|
clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
|
|
7650
7655
|
fetchStrategy: exports.FetchStrategy.Buffered,
|
|
@@ -8023,6 +8028,11 @@ The next upload iteration will be delayed.`);
|
|
|
8023
8028
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
8024
8029
|
...(options ?? {})
|
|
8025
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
|
+
}
|
|
8026
8036
|
const clientImplementation = resolvedOptions.clientImplementation;
|
|
8027
8037
|
this.updateSyncStatus({ clientImplementation });
|
|
8028
8038
|
if (clientImplementation == exports.SyncClientImplementation.JAVASCRIPT) {
|
|
@@ -8058,6 +8068,7 @@ The next upload iteration will be delayed.`);
|
|
|
8058
8068
|
include_checksum: true,
|
|
8059
8069
|
raw_data: true,
|
|
8060
8070
|
parameters: resolvedOptions.params,
|
|
8071
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
8061
8072
|
client_id: clientId
|
|
8062
8073
|
}
|
|
8063
8074
|
};
|
|
@@ -8417,6 +8428,7 @@ The next upload iteration will be delayed.`);
|
|
|
8417
8428
|
try {
|
|
8418
8429
|
const options = {
|
|
8419
8430
|
parameters: resolvedOptions.params,
|
|
8431
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
8420
8432
|
active_streams: this.activeStreams,
|
|
8421
8433
|
include_defaults: resolvedOptions.includeDefaultStreams
|
|
8422
8434
|
};
|
|
@@ -9053,14 +9065,14 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
9053
9065
|
async initialize() {
|
|
9054
9066
|
await this._initialize();
|
|
9055
9067
|
await this.bucketStorageAdapter.init();
|
|
9056
|
-
await this.
|
|
9068
|
+
await this.loadVersion();
|
|
9057
9069
|
await this.updateSchema(this.options.schema);
|
|
9058
9070
|
await this.resolveOfflineSyncStatus();
|
|
9059
9071
|
await this.database.execute('PRAGMA RECURSIVE_TRIGGERS=TRUE');
|
|
9060
9072
|
this.ready = true;
|
|
9061
9073
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
9062
9074
|
}
|
|
9063
|
-
async
|
|
9075
|
+
async loadVersion() {
|
|
9064
9076
|
try {
|
|
9065
9077
|
const { version } = await this.database.get('SELECT powersync_rs_version() as version');
|
|
9066
9078
|
this.sdkVersion = version;
|
|
@@ -9075,11 +9087,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
9075
9087
|
.map((n) => parseInt(n));
|
|
9076
9088
|
}
|
|
9077
9089
|
catch (e) {
|
|
9078
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
9090
|
+
throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
|
|
9079
9091
|
}
|
|
9080
|
-
// Validate >=0.4.
|
|
9081
|
-
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] <
|
|
9082
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
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}`);
|
|
9083
9095
|
}
|
|
9084
9096
|
}
|
|
9085
9097
|
async resolveOfflineSyncStatus() {
|
|
@@ -10199,6 +10211,27 @@ class SyncDataBatch {
|
|
|
10199
10211
|
}
|
|
10200
10212
|
}
|
|
10201
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
|
+
|
|
10202
10235
|
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
10203
10236
|
exports.ColumnType = void 0;
|
|
10204
10237
|
(function (ColumnType) {
|
|
@@ -10762,6 +10795,7 @@ exports.AbstractStreamingSyncImplementation = AbstractStreamingSyncImplementatio
|
|
|
10762
10795
|
exports.ArrayComparator = ArrayComparator;
|
|
10763
10796
|
exports.BaseObserver = BaseObserver;
|
|
10764
10797
|
exports.Column = Column;
|
|
10798
|
+
exports.ConnectionClosedError = ConnectionClosedError;
|
|
10765
10799
|
exports.ConnectionManager = ConnectionManager;
|
|
10766
10800
|
exports.ControlledExecutor = ControlledExecutor;
|
|
10767
10801
|
exports.CrudBatch = CrudBatch;
|