@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.mjs
CHANGED
|
@@ -579,6 +579,10 @@ class SyncStatus {
|
|
|
579
579
|
priorityStatusEntries: this.priorityStatusEntries
|
|
580
580
|
};
|
|
581
581
|
}
|
|
582
|
+
/**
|
|
583
|
+
* Not all errors are serializable over a MessagePort. E.g. some `DomExceptions` fail to be passed across workers.
|
|
584
|
+
* This explicitly serializes errors in the SyncStatus.
|
|
585
|
+
*/
|
|
582
586
|
serializeError(error) {
|
|
583
587
|
if (typeof error == 'undefined') {
|
|
584
588
|
return undefined;
|
|
@@ -1943,7 +1947,7 @@ var hasRequiredFrames;
|
|
|
1943
1947
|
function requireFrames () {
|
|
1944
1948
|
if (hasRequiredFrames) return Frames;
|
|
1945
1949
|
hasRequiredFrames = 1;
|
|
1946
|
-
(function (exports) {
|
|
1950
|
+
(function (exports$1) {
|
|
1947
1951
|
/*
|
|
1948
1952
|
* Copyright 2021-2022 the original author or authors.
|
|
1949
1953
|
*
|
|
@@ -1959,8 +1963,8 @@ function requireFrames () {
|
|
|
1959
1963
|
* See the License for the specific language governing permissions and
|
|
1960
1964
|
* limitations under the License.
|
|
1961
1965
|
*/
|
|
1962
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1963
|
-
exports.Frame = exports.Lengths = exports.Flags = exports.FrameTypes = void 0;
|
|
1966
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
1967
|
+
exports$1.Frame = exports$1.Lengths = exports$1.Flags = exports$1.FrameTypes = void 0;
|
|
1964
1968
|
var FrameTypes;
|
|
1965
1969
|
(function (FrameTypes) {
|
|
1966
1970
|
FrameTypes[FrameTypes["RESERVED"] = 0] = "RESERVED";
|
|
@@ -1979,7 +1983,7 @@ function requireFrames () {
|
|
|
1979
1983
|
FrameTypes[FrameTypes["RESUME"] = 13] = "RESUME";
|
|
1980
1984
|
FrameTypes[FrameTypes["RESUME_OK"] = 14] = "RESUME_OK";
|
|
1981
1985
|
FrameTypes[FrameTypes["EXT"] = 63] = "EXT";
|
|
1982
|
-
})(FrameTypes = exports.FrameTypes || (exports.FrameTypes = {}));
|
|
1986
|
+
})(FrameTypes = exports$1.FrameTypes || (exports$1.FrameTypes = {}));
|
|
1983
1987
|
(function (Flags) {
|
|
1984
1988
|
Flags[Flags["NONE"] = 0] = "NONE";
|
|
1985
1989
|
Flags[Flags["COMPLETE"] = 64] = "COMPLETE";
|
|
@@ -1990,7 +1994,7 @@ function requireFrames () {
|
|
|
1990
1994
|
Flags[Flags["NEXT"] = 32] = "NEXT";
|
|
1991
1995
|
Flags[Flags["RESPOND"] = 128] = "RESPOND";
|
|
1992
1996
|
Flags[Flags["RESUME_ENABLE"] = 128] = "RESUME_ENABLE";
|
|
1993
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
1997
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
1994
1998
|
(function (Flags) {
|
|
1995
1999
|
function hasMetadata(flags) {
|
|
1996
2000
|
return (flags & Flags.METADATA) === Flags.METADATA;
|
|
@@ -2024,13 +2028,13 @@ function requireFrames () {
|
|
|
2024
2028
|
return (flags & Flags.RESUME_ENABLE) === Flags.RESUME_ENABLE;
|
|
2025
2029
|
}
|
|
2026
2030
|
Flags.hasResume = hasResume;
|
|
2027
|
-
})(exports.Flags || (exports.Flags = {}));
|
|
2031
|
+
})(exports$1.Flags || (exports$1.Flags = {}));
|
|
2028
2032
|
(function (Lengths) {
|
|
2029
2033
|
Lengths[Lengths["FRAME"] = 3] = "FRAME";
|
|
2030
2034
|
Lengths[Lengths["HEADER"] = 6] = "HEADER";
|
|
2031
2035
|
Lengths[Lengths["METADATA"] = 3] = "METADATA";
|
|
2032
2036
|
Lengths[Lengths["REQUEST"] = 3] = "REQUEST";
|
|
2033
|
-
})(exports.Lengths || (exports.Lengths = {}));
|
|
2037
|
+
})(exports$1.Lengths || (exports$1.Lengths = {}));
|
|
2034
2038
|
(function (Frame) {
|
|
2035
2039
|
function isConnection(frame) {
|
|
2036
2040
|
return frame.streamId === 0;
|
|
@@ -2041,7 +2045,7 @@ function requireFrames () {
|
|
|
2041
2045
|
frame.type <= FrameTypes.REQUEST_CHANNEL);
|
|
2042
2046
|
}
|
|
2043
2047
|
Frame.isRequest = isRequest;
|
|
2044
|
-
})(exports.Frame || (exports.Frame = {}));
|
|
2048
|
+
})(exports$1.Frame || (exports$1.Frame = {}));
|
|
2045
2049
|
|
|
2046
2050
|
} (Frames));
|
|
2047
2051
|
return Frames;
|
|
@@ -2052,7 +2056,7 @@ var hasRequiredCodecs;
|
|
|
2052
2056
|
function requireCodecs () {
|
|
2053
2057
|
if (hasRequiredCodecs) return Codecs;
|
|
2054
2058
|
hasRequiredCodecs = 1;
|
|
2055
|
-
(function (exports) {
|
|
2059
|
+
(function (exports$1) {
|
|
2056
2060
|
var __generator = (Codecs && Codecs.__generator) || function (thisArg, body) {
|
|
2057
2061
|
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
2058
2062
|
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
@@ -2080,22 +2084,22 @@ function requireCodecs () {
|
|
|
2080
2084
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
2081
2085
|
}
|
|
2082
2086
|
};
|
|
2083
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2084
|
-
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;
|
|
2087
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
2088
|
+
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;
|
|
2085
2089
|
var Frames_1 = requireFrames();
|
|
2086
|
-
exports.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
2087
|
-
exports.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
2088
|
-
exports.MAX_CODE = 0x7fffffff; // uint31
|
|
2089
|
-
exports.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
2090
|
-
exports.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
2091
|
-
exports.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
2092
|
-
exports.MAX_MIME_LENGTH = 0xff; // int8
|
|
2093
|
-
exports.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
2094
|
-
exports.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
2095
|
-
exports.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
2096
|
-
exports.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
2097
|
-
exports.MAX_TTL = 0x7fffffff; // uint31
|
|
2098
|
-
exports.MAX_VERSION = 0xffff; // uint16
|
|
2090
|
+
exports$1.FLAGS_MASK = 0x3ff; // low 10 bits
|
|
2091
|
+
exports$1.FRAME_TYPE_OFFFSET = 10; // frame type is offset 10 bytes within the uint16 containing type + flags
|
|
2092
|
+
exports$1.MAX_CODE = 0x7fffffff; // uint31
|
|
2093
|
+
exports$1.MAX_KEEPALIVE = 0x7fffffff; // uint31
|
|
2094
|
+
exports$1.MAX_LIFETIME = 0x7fffffff; // uint31
|
|
2095
|
+
exports$1.MAX_METADATA_LENGTH = 0xffffff; // uint24
|
|
2096
|
+
exports$1.MAX_MIME_LENGTH = 0xff; // int8
|
|
2097
|
+
exports$1.MAX_REQUEST_COUNT = 0x7fffffff; // uint31
|
|
2098
|
+
exports$1.MAX_REQUEST_N = 0x7fffffff; // uint31
|
|
2099
|
+
exports$1.MAX_RESUME_LENGTH = 0xffff; // uint16
|
|
2100
|
+
exports$1.MAX_STREAM_ID = 0x7fffffff; // uint31
|
|
2101
|
+
exports$1.MAX_TTL = 0x7fffffff; // uint31
|
|
2102
|
+
exports$1.MAX_VERSION = 0xffff; // uint16
|
|
2099
2103
|
/**
|
|
2100
2104
|
* Mimimum value that would overflow bitwise operators (2^32).
|
|
2101
2105
|
*/
|
|
@@ -2109,7 +2113,7 @@ function requireCodecs () {
|
|
|
2109
2113
|
var val3 = buffer.readUInt8(offset + 2);
|
|
2110
2114
|
return val1 | val2 | val3;
|
|
2111
2115
|
}
|
|
2112
|
-
exports.readUInt24BE = readUInt24BE;
|
|
2116
|
+
exports$1.readUInt24BE = readUInt24BE;
|
|
2113
2117
|
/**
|
|
2114
2118
|
* Writes a uint24 to a buffer starting at the given offset, returning the
|
|
2115
2119
|
* offset of the next byte.
|
|
@@ -2119,7 +2123,7 @@ function requireCodecs () {
|
|
|
2119
2123
|
offset = buffer.writeUInt8((value >>> 8) & 0xff, offset); // 2nd byte
|
|
2120
2124
|
return buffer.writeUInt8(value & 0xff, offset); // 1st byte
|
|
2121
2125
|
}
|
|
2122
|
-
exports.writeUInt24BE = writeUInt24BE;
|
|
2126
|
+
exports$1.writeUInt24BE = writeUInt24BE;
|
|
2123
2127
|
/**
|
|
2124
2128
|
* Read a uint64 (technically supports up to 53 bits per JS number
|
|
2125
2129
|
* representation).
|
|
@@ -2129,7 +2133,7 @@ function requireCodecs () {
|
|
|
2129
2133
|
var low = buffer.readUInt32BE(offset + 4);
|
|
2130
2134
|
return high * BITWISE_OVERFLOW + low;
|
|
2131
2135
|
}
|
|
2132
|
-
exports.readUInt64BE = readUInt64BE;
|
|
2136
|
+
exports$1.readUInt64BE = readUInt64BE;
|
|
2133
2137
|
/**
|
|
2134
2138
|
* Write a uint64 (technically supports up to 53 bits per JS number
|
|
2135
2139
|
* representation).
|
|
@@ -2140,7 +2144,7 @@ function requireCodecs () {
|
|
|
2140
2144
|
offset = buffer.writeUInt32BE(high, offset); // first half of uint64
|
|
2141
2145
|
return buffer.writeUInt32BE(low, offset); // second half of uint64
|
|
2142
2146
|
}
|
|
2143
|
-
exports.writeUInt64BE = writeUInt64BE;
|
|
2147
|
+
exports$1.writeUInt64BE = writeUInt64BE;
|
|
2144
2148
|
/**
|
|
2145
2149
|
* Frame header is:
|
|
2146
2150
|
* - stream id (uint32 = 4)
|
|
@@ -2158,7 +2162,7 @@ function requireCodecs () {
|
|
|
2158
2162
|
var frameLength = readUInt24BE(buffer, 0);
|
|
2159
2163
|
return deserializeFrame(buffer.slice(UINT24_SIZE, UINT24_SIZE + frameLength));
|
|
2160
2164
|
}
|
|
2161
|
-
exports.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
2165
|
+
exports$1.deserializeFrameWithLength = deserializeFrameWithLength;
|
|
2162
2166
|
/**
|
|
2163
2167
|
* Given a buffer that may contain zero or more length-prefixed frames followed
|
|
2164
2168
|
* by zero or more bytes of a (partial) subsequent frame, returns an array of
|
|
@@ -2191,7 +2195,7 @@ function requireCodecs () {
|
|
|
2191
2195
|
}
|
|
2192
2196
|
});
|
|
2193
2197
|
}
|
|
2194
|
-
exports.deserializeFrames = deserializeFrames;
|
|
2198
|
+
exports$1.deserializeFrames = deserializeFrames;
|
|
2195
2199
|
/**
|
|
2196
2200
|
* Writes a frame to a buffer with a length prefix.
|
|
2197
2201
|
*/
|
|
@@ -2202,7 +2206,7 @@ function requireCodecs () {
|
|
|
2202
2206
|
buffer.copy(lengthPrefixed, UINT24_SIZE);
|
|
2203
2207
|
return lengthPrefixed;
|
|
2204
2208
|
}
|
|
2205
|
-
exports.serializeFrameWithLength = serializeFrameWithLength;
|
|
2209
|
+
exports$1.serializeFrameWithLength = serializeFrameWithLength;
|
|
2206
2210
|
/**
|
|
2207
2211
|
* Read a frame from the buffer.
|
|
2208
2212
|
*/
|
|
@@ -2217,8 +2221,8 @@ function requireCodecs () {
|
|
|
2217
2221
|
// );
|
|
2218
2222
|
var typeAndFlags = buffer.readUInt16BE(offset);
|
|
2219
2223
|
offset += 2;
|
|
2220
|
-
var type = typeAndFlags >>> exports.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
2221
|
-
var flags = typeAndFlags & exports.FLAGS_MASK; // keep lowest 10 bits
|
|
2224
|
+
var type = typeAndFlags >>> exports$1.FRAME_TYPE_OFFFSET; // keep highest 6 bits
|
|
2225
|
+
var flags = typeAndFlags & exports$1.FLAGS_MASK; // keep lowest 10 bits
|
|
2222
2226
|
switch (type) {
|
|
2223
2227
|
case Frames_1.FrameTypes.SETUP:
|
|
2224
2228
|
return deserializeSetupFrame(buffer, streamId, flags);
|
|
@@ -2255,7 +2259,7 @@ function requireCodecs () {
|
|
|
2255
2259
|
// );
|
|
2256
2260
|
}
|
|
2257
2261
|
}
|
|
2258
|
-
exports.deserializeFrame = deserializeFrame;
|
|
2262
|
+
exports$1.deserializeFrame = deserializeFrame;
|
|
2259
2263
|
/**
|
|
2260
2264
|
* Convert the frame to a (binary) buffer.
|
|
2261
2265
|
*/
|
|
@@ -2294,7 +2298,7 @@ function requireCodecs () {
|
|
|
2294
2298
|
// );
|
|
2295
2299
|
}
|
|
2296
2300
|
}
|
|
2297
|
-
exports.serializeFrame = serializeFrame;
|
|
2301
|
+
exports$1.serializeFrame = serializeFrame;
|
|
2298
2302
|
/**
|
|
2299
2303
|
* Byte size of frame without size prefix
|
|
2300
2304
|
*/
|
|
@@ -2333,7 +2337,7 @@ function requireCodecs () {
|
|
|
2333
2337
|
// );
|
|
2334
2338
|
}
|
|
2335
2339
|
}
|
|
2336
|
-
exports.sizeOfFrame = sizeOfFrame;
|
|
2340
|
+
exports$1.sizeOfFrame = sizeOfFrame;
|
|
2337
2341
|
/**
|
|
2338
2342
|
* Writes a SETUP frame into a new buffer and returns it.
|
|
2339
2343
|
*
|
|
@@ -2968,7 +2972,7 @@ function requireCodecs () {
|
|
|
2968
2972
|
function writeHeader(frame, buffer) {
|
|
2969
2973
|
var offset = buffer.writeInt32BE(frame.streamId, 0);
|
|
2970
2974
|
// shift frame to high 6 bits, extract lowest 10 bits from flags
|
|
2971
|
-
return buffer.writeUInt16BE((frame.type << exports.FRAME_TYPE_OFFFSET) | (frame.flags & exports.FLAGS_MASK), offset);
|
|
2975
|
+
return buffer.writeUInt16BE((frame.type << exports$1.FRAME_TYPE_OFFFSET) | (frame.flags & exports$1.FLAGS_MASK), offset);
|
|
2972
2976
|
}
|
|
2973
2977
|
/**
|
|
2974
2978
|
* Determine the length of the payload section of a frame. Only applies to
|
|
@@ -3049,7 +3053,7 @@ function requireCodecs () {
|
|
|
3049
3053
|
};
|
|
3050
3054
|
return Deserializer;
|
|
3051
3055
|
}());
|
|
3052
|
-
exports.Deserializer = Deserializer;
|
|
3056
|
+
exports$1.Deserializer = Deserializer;
|
|
3053
3057
|
|
|
3054
3058
|
} (Codecs));
|
|
3055
3059
|
return Codecs;
|
|
@@ -3195,7 +3199,7 @@ var hasRequiredErrors;
|
|
|
3195
3199
|
function requireErrors () {
|
|
3196
3200
|
if (hasRequiredErrors) return Errors;
|
|
3197
3201
|
hasRequiredErrors = 1;
|
|
3198
|
-
(function (exports) {
|
|
3202
|
+
(function (exports$1) {
|
|
3199
3203
|
/*
|
|
3200
3204
|
* Copyright 2021-2022 the original author or authors.
|
|
3201
3205
|
*
|
|
@@ -3226,8 +3230,8 @@ function requireErrors () {
|
|
|
3226
3230
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
3227
3231
|
};
|
|
3228
3232
|
})();
|
|
3229
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3230
|
-
exports.ErrorCodes = exports.RSocketError = void 0;
|
|
3233
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
3234
|
+
exports$1.ErrorCodes = exports$1.RSocketError = void 0;
|
|
3231
3235
|
var RSocketError = /** @class */ (function (_super) {
|
|
3232
3236
|
__extends(RSocketError, _super);
|
|
3233
3237
|
function RSocketError(code, message) {
|
|
@@ -3237,7 +3241,7 @@ function requireErrors () {
|
|
|
3237
3241
|
}
|
|
3238
3242
|
return RSocketError;
|
|
3239
3243
|
}(Error));
|
|
3240
|
-
exports.RSocketError = RSocketError;
|
|
3244
|
+
exports$1.RSocketError = RSocketError;
|
|
3241
3245
|
(function (ErrorCodes) {
|
|
3242
3246
|
ErrorCodes[ErrorCodes["RESERVED"] = 0] = "RESERVED";
|
|
3243
3247
|
ErrorCodes[ErrorCodes["INVALID_SETUP"] = 1] = "INVALID_SETUP";
|
|
@@ -3251,7 +3255,7 @@ function requireErrors () {
|
|
|
3251
3255
|
ErrorCodes[ErrorCodes["CANCELED"] = 515] = "CANCELED";
|
|
3252
3256
|
ErrorCodes[ErrorCodes["INVALID"] = 516] = "INVALID";
|
|
3253
3257
|
ErrorCodes[ErrorCodes["RESERVED_EXTENSION"] = 4294967295] = "RESERVED_EXTENSION";
|
|
3254
|
-
})(exports.ErrorCodes || (exports.ErrorCodes = {}));
|
|
3258
|
+
})(exports$1.ErrorCodes || (exports$1.ErrorCodes = {}));
|
|
3255
3259
|
|
|
3256
3260
|
} (Errors));
|
|
3257
3261
|
return Errors;
|
|
@@ -3293,7 +3297,7 @@ var hasRequiredClientServerMultiplexerDemultiplexer;
|
|
|
3293
3297
|
function requireClientServerMultiplexerDemultiplexer () {
|
|
3294
3298
|
if (hasRequiredClientServerMultiplexerDemultiplexer) return ClientServerMultiplexerDemultiplexer;
|
|
3295
3299
|
hasRequiredClientServerMultiplexerDemultiplexer = 1;
|
|
3296
|
-
(function (exports) {
|
|
3300
|
+
(function (exports$1) {
|
|
3297
3301
|
/*
|
|
3298
3302
|
* Copyright 2021-2022 the original author or authors.
|
|
3299
3303
|
*
|
|
@@ -3360,8 +3364,8 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3360
3364
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
3361
3365
|
}
|
|
3362
3366
|
};
|
|
3363
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3364
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports.ResumableClientServerInputMultiplexerDemultiplexer = exports.ClientServerInputMultiplexerDemultiplexer = exports.StreamIdGenerator = void 0;
|
|
3367
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
3368
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = exports$1.ResumableClientServerInputMultiplexerDemultiplexer = exports$1.ClientServerInputMultiplexerDemultiplexer = exports$1.StreamIdGenerator = void 0;
|
|
3365
3369
|
var _1 = requireDist();
|
|
3366
3370
|
var Deferred_1 = requireDeferred();
|
|
3367
3371
|
var Errors_1 = requireErrors();
|
|
@@ -3384,7 +3388,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3384
3388
|
};
|
|
3385
3389
|
return StreamIdGeneratorImpl;
|
|
3386
3390
|
}());
|
|
3387
|
-
})(exports.StreamIdGenerator || (exports.StreamIdGenerator = {}));
|
|
3391
|
+
})(exports$1.StreamIdGenerator || (exports$1.StreamIdGenerator = {}));
|
|
3388
3392
|
var ClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
3389
3393
|
__extends(ClientServerInputMultiplexerDemultiplexer, _super);
|
|
3390
3394
|
function ClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable) {
|
|
@@ -3473,7 +3477,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3473
3477
|
};
|
|
3474
3478
|
return ClientServerInputMultiplexerDemultiplexer;
|
|
3475
3479
|
}(Deferred_1.Deferred));
|
|
3476
|
-
exports.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
3480
|
+
exports$1.ClientServerInputMultiplexerDemultiplexer = ClientServerInputMultiplexerDemultiplexer;
|
|
3477
3481
|
var ResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function (_super) {
|
|
3478
3482
|
__extends(ResumableClientServerInputMultiplexerDemultiplexer, _super);
|
|
3479
3483
|
function ResumableClientServerInputMultiplexerDemultiplexer(streamIdSupplier, outbound, closeable, frameStore, token, sessionStoreOrReconnector, sessionTimeout) {
|
|
@@ -3630,7 +3634,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3630
3634
|
};
|
|
3631
3635
|
return ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3632
3636
|
}(ClientServerInputMultiplexerDemultiplexer));
|
|
3633
|
-
exports.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3637
|
+
exports$1.ResumableClientServerInputMultiplexerDemultiplexer = ResumableClientServerInputMultiplexerDemultiplexer;
|
|
3634
3638
|
var ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = /** @class */ (function () {
|
|
3635
3639
|
function ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer(outbound, closeable, delegate) {
|
|
3636
3640
|
this.outbound = outbound;
|
|
@@ -3687,7 +3691,7 @@ function requireClientServerMultiplexerDemultiplexer () {
|
|
|
3687
3691
|
};
|
|
3688
3692
|
return ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3689
3693
|
}());
|
|
3690
|
-
exports.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3694
|
+
exports$1.ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer = ResumeOkAwaitingResumableClientServerInputMultiplexerDemultiplexer;
|
|
3691
3695
|
|
|
3692
3696
|
} (ClientServerMultiplexerDemultiplexer));
|
|
3693
3697
|
return ClientServerMultiplexerDemultiplexer;
|
|
@@ -6673,7 +6677,7 @@ var hasRequiredDist;
|
|
|
6673
6677
|
function requireDist () {
|
|
6674
6678
|
if (hasRequiredDist) return dist;
|
|
6675
6679
|
hasRequiredDist = 1;
|
|
6676
|
-
(function (exports) {
|
|
6680
|
+
(function (exports$1) {
|
|
6677
6681
|
/*
|
|
6678
6682
|
* Copyright 2021-2022 the original author or authors.
|
|
6679
6683
|
*
|
|
@@ -6696,19 +6700,19 @@ function requireDist () {
|
|
|
6696
6700
|
if (k2 === undefined) k2 = k;
|
|
6697
6701
|
o[k2] = m[k];
|
|
6698
6702
|
}));
|
|
6699
|
-
var __exportStar = (dist && dist.__exportStar) || function(m, exports) {
|
|
6700
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
6703
|
+
var __exportStar = (dist && dist.__exportStar) || function(m, exports$1) {
|
|
6704
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$1, p)) __createBinding(exports$1, m, p);
|
|
6701
6705
|
};
|
|
6702
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6703
|
-
__exportStar(requireCodecs(), exports);
|
|
6704
|
-
__exportStar(requireCommon(), exports);
|
|
6705
|
-
__exportStar(requireDeferred(), exports);
|
|
6706
|
-
__exportStar(requireErrors(), exports);
|
|
6707
|
-
__exportStar(requireFrames(), exports);
|
|
6708
|
-
__exportStar(requireRSocket(), exports);
|
|
6709
|
-
__exportStar(requireRSocketConnector(), exports);
|
|
6710
|
-
__exportStar(requireRSocketServer(), exports);
|
|
6711
|
-
__exportStar(requireTransport(), exports);
|
|
6706
|
+
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
6707
|
+
__exportStar(requireCodecs(), exports$1);
|
|
6708
|
+
__exportStar(requireCommon(), exports$1);
|
|
6709
|
+
__exportStar(requireDeferred(), exports$1);
|
|
6710
|
+
__exportStar(requireErrors(), exports$1);
|
|
6711
|
+
__exportStar(requireFrames(), exports$1);
|
|
6712
|
+
__exportStar(requireRSocket(), exports$1);
|
|
6713
|
+
__exportStar(requireRSocketConnector(), exports$1);
|
|
6714
|
+
__exportStar(requireRSocketServer(), exports$1);
|
|
6715
|
+
__exportStar(requireTransport(), exports$1);
|
|
6712
6716
|
|
|
6713
6717
|
} (dist));
|
|
6714
6718
|
return dist;
|
|
@@ -6716,7 +6720,7 @@ function requireDist () {
|
|
|
6716
6720
|
|
|
6717
6721
|
var distExports = requireDist();
|
|
6718
6722
|
|
|
6719
|
-
var version = "1.
|
|
6723
|
+
var version = "1.45.0";
|
|
6720
6724
|
var PACKAGE = {
|
|
6721
6725
|
version: version};
|
|
6722
6726
|
|
|
@@ -7643,6 +7647,7 @@ const DEFAULT_STREAMING_SYNC_OPTIONS = {
|
|
|
7643
7647
|
crudUploadThrottleMs: DEFAULT_CRUD_UPLOAD_THROTTLE_MS
|
|
7644
7648
|
};
|
|
7645
7649
|
const DEFAULT_STREAM_CONNECTION_OPTIONS = {
|
|
7650
|
+
appMetadata: {},
|
|
7646
7651
|
connectionMethod: SyncStreamConnectionMethod.WEB_SOCKET,
|
|
7647
7652
|
clientImplementation: DEFAULT_SYNC_CLIENT_IMPLEMENTATION,
|
|
7648
7653
|
fetchStrategy: FetchStrategy.Buffered,
|
|
@@ -8021,6 +8026,11 @@ The next upload iteration will be delayed.`);
|
|
|
8021
8026
|
...DEFAULT_STREAM_CONNECTION_OPTIONS,
|
|
8022
8027
|
...(options ?? {})
|
|
8023
8028
|
};
|
|
8029
|
+
// Validate app metadata
|
|
8030
|
+
const invalidMetadata = Object.entries(resolvedOptions.appMetadata).filter(([_, value]) => typeof value != 'string');
|
|
8031
|
+
if (invalidMetadata.length > 0) {
|
|
8032
|
+
throw new Error(`Invalid appMetadata provided. Only string values are allowed. Invalid values: ${invalidMetadata.map(([key, value]) => `${key}: ${value}`).join(', ')}`);
|
|
8033
|
+
}
|
|
8024
8034
|
const clientImplementation = resolvedOptions.clientImplementation;
|
|
8025
8035
|
this.updateSyncStatus({ clientImplementation });
|
|
8026
8036
|
if (clientImplementation == SyncClientImplementation.JAVASCRIPT) {
|
|
@@ -8056,6 +8066,7 @@ The next upload iteration will be delayed.`);
|
|
|
8056
8066
|
include_checksum: true,
|
|
8057
8067
|
raw_data: true,
|
|
8058
8068
|
parameters: resolvedOptions.params,
|
|
8069
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
8059
8070
|
client_id: clientId
|
|
8060
8071
|
}
|
|
8061
8072
|
};
|
|
@@ -8415,6 +8426,7 @@ The next upload iteration will be delayed.`);
|
|
|
8415
8426
|
try {
|
|
8416
8427
|
const options = {
|
|
8417
8428
|
parameters: resolvedOptions.params,
|
|
8429
|
+
app_metadata: resolvedOptions.appMetadata,
|
|
8418
8430
|
active_streams: this.activeStreams,
|
|
8419
8431
|
include_defaults: resolvedOptions.includeDefaultStreams
|
|
8420
8432
|
};
|
|
@@ -9051,14 +9063,14 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
9051
9063
|
async initialize() {
|
|
9052
9064
|
await this._initialize();
|
|
9053
9065
|
await this.bucketStorageAdapter.init();
|
|
9054
|
-
await this.
|
|
9066
|
+
await this.loadVersion();
|
|
9055
9067
|
await this.updateSchema(this.options.schema);
|
|
9056
9068
|
await this.resolveOfflineSyncStatus();
|
|
9057
9069
|
await this.database.execute('PRAGMA RECURSIVE_TRIGGERS=TRUE');
|
|
9058
9070
|
this.ready = true;
|
|
9059
9071
|
this.iterateListeners((cb) => cb.initialized?.());
|
|
9060
9072
|
}
|
|
9061
|
-
async
|
|
9073
|
+
async loadVersion() {
|
|
9062
9074
|
try {
|
|
9063
9075
|
const { version } = await this.database.get('SELECT powersync_rs_version() as version');
|
|
9064
9076
|
this.sdkVersion = version;
|
|
@@ -9073,11 +9085,11 @@ class AbstractPowerSyncDatabase extends BaseObserver {
|
|
|
9073
9085
|
.map((n) => parseInt(n));
|
|
9074
9086
|
}
|
|
9075
9087
|
catch (e) {
|
|
9076
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
9088
|
+
throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}. Details: ${e.message}`);
|
|
9077
9089
|
}
|
|
9078
|
-
// Validate >=0.4.
|
|
9079
|
-
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] <
|
|
9080
|
-
throw new Error(`Unsupported powersync extension version. Need >=0.4.
|
|
9090
|
+
// Validate >=0.4.10 <1.0.0
|
|
9091
|
+
if (versionInts[0] != 0 || versionInts[1] < 4 || (versionInts[1] == 4 && versionInts[2] < 10)) {
|
|
9092
|
+
throw new Error(`Unsupported powersync extension version. Need >=0.4.10 <1.0.0, got: ${this.sdkVersion}`);
|
|
9081
9093
|
}
|
|
9082
9094
|
}
|
|
9083
9095
|
async resolveOfflineSyncStatus() {
|
|
@@ -10197,6 +10209,27 @@ class SyncDataBatch {
|
|
|
10197
10209
|
}
|
|
10198
10210
|
}
|
|
10199
10211
|
|
|
10212
|
+
/**
|
|
10213
|
+
* Thrown when an underlying database connection is closed.
|
|
10214
|
+
* This is particularly relevant when worker connections are marked as closed while
|
|
10215
|
+
* operations are still in progress.
|
|
10216
|
+
*/
|
|
10217
|
+
class ConnectionClosedError extends Error {
|
|
10218
|
+
static NAME = 'ConnectionClosedError';
|
|
10219
|
+
static MATCHES(input) {
|
|
10220
|
+
/**
|
|
10221
|
+
* If there are weird package issues which cause multiple versions of classes to be present, the instanceof
|
|
10222
|
+
* check might fail. This also performs a failsafe check.
|
|
10223
|
+
* This might also happen if the Error is serialized and parsed over a bridging channel like a MessagePort.
|
|
10224
|
+
*/
|
|
10225
|
+
return (input instanceof ConnectionClosedError || (input instanceof Error && input.name == ConnectionClosedError.NAME));
|
|
10226
|
+
}
|
|
10227
|
+
constructor(message) {
|
|
10228
|
+
super(message);
|
|
10229
|
+
this.name = ConnectionClosedError.NAME;
|
|
10230
|
+
}
|
|
10231
|
+
}
|
|
10232
|
+
|
|
10200
10233
|
// https://www.sqlite.org/lang_expr.html#castexpr
|
|
10201
10234
|
var ColumnType;
|
|
10202
10235
|
(function (ColumnType) {
|
|
@@ -10751,5 +10784,5 @@ const parseQuery = (query, parameters) => {
|
|
|
10751
10784
|
return { sqlStatement, parameters: parameters };
|
|
10752
10785
|
};
|
|
10753
10786
|
|
|
10754
|
-
export { AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, BaseObserver, Column, ColumnType, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, Table, TableV2, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
10787
|
+
export { AbortOperation, AbstractPowerSyncDatabase, AbstractPowerSyncDatabaseOpenFactory, AbstractQueryProcessor, AbstractRemote, AbstractStreamingSyncImplementation, ArrayComparator, BaseObserver, Column, ColumnType, ConnectionClosedError, ConnectionManager, ControlledExecutor, CrudBatch, CrudEntry, CrudTransaction, DEFAULT_CRUD_BATCH_LIMIT, DEFAULT_CRUD_UPLOAD_THROTTLE_MS, DEFAULT_INDEX_COLUMN_OPTIONS, DEFAULT_INDEX_OPTIONS, DEFAULT_LOCK_TIMEOUT_MS, DEFAULT_POWERSYNC_CLOSE_OPTIONS, DEFAULT_POWERSYNC_DB_OPTIONS, DEFAULT_PRESSURE_LIMITS, DEFAULT_REMOTE_LOGGER, DEFAULT_REMOTE_OPTIONS, DEFAULT_RETRY_DELAY_MS, DEFAULT_ROW_COMPARATOR, DEFAULT_STREAMING_SYNC_OPTIONS, DEFAULT_STREAM_CONNECTION_OPTIONS, DEFAULT_SYNC_CLIENT_IMPLEMENTATION, DEFAULT_TABLE_OPTIONS, DEFAULT_WATCH_QUERY_OPTIONS, DEFAULT_WATCH_THROTTLE_MS, DataStream, DiffTriggerOperation, DifferentialQueryProcessor, EMPTY_DIFFERENTIAL, FalsyComparator, FetchImplementationProvider, FetchStrategy, GetAllQuery, Index, IndexedColumn, InvalidSQLCharacters, LockType, LogLevel, MAX_AMOUNT_OF_COLUMNS, MAX_OP_ID, OnChangeQueryProcessor, OpType, OpTypeEnum, OplogEntry, PSInternalTable, PowerSyncControlCommand, RowUpdateType, Schema, SqliteBucketStorage, SyncClientImplementation, SyncDataBatch, SyncDataBucket, SyncProgress, SyncStatus, SyncStreamConnectionMethod, Table, TableV2, UpdateType, UploadQueueStats, WatchedQueryListenerEvent, column, compilableQueryWatch, createBaseLogger, createLogger, extractTableUpdates, isBatchedUpdateNotification, isContinueCheckpointRequest, isDBAdapter, isPowerSyncDatabaseOptionsWithSettings, isSQLOpenFactory, isSQLOpenOptions, isStreamingKeepalive, isStreamingSyncCheckpoint, isStreamingSyncCheckpointComplete, isStreamingSyncCheckpointDiff, isStreamingSyncCheckpointPartiallyComplete, isStreamingSyncData, isSyncNewCheckpointRequest, parseQuery, runOnSchemaChange, sanitizeSQL, sanitizeUUID };
|
|
10755
10788
|
//# sourceMappingURL=bundle.node.mjs.map
|