cry-synced-db-client 0.1.207 → 0.1.208

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 (2) hide show
  1. package/dist/index.js +66 -28
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -5391,7 +5391,7 @@ var _SyncedDb = class _SyncedDb {
5391
5391
  }
5392
5392
  // ==================== Lifecycle ====================
5393
5393
  async init() {
5394
- var _a, _b, _c, _d;
5394
+ var _a, _b, _c;
5395
5395
  if (this.initialized) return;
5396
5396
  if (typeof localStorage === "undefined") {
5397
5397
  this.connectionManager.reportInfrastructureError(
@@ -5448,10 +5448,8 @@ var _SyncedDb = class _SyncedDb {
5448
5448
  );
5449
5449
  try {
5450
5450
  await this.serverUpdateNotifier.connect();
5451
- const ep = (_c = this.serverUpdateNotifier.endpoint) != null ? _c : "unknown";
5452
- console.log(`[SyncedDb] SyncedDb: ebus-proxy connected to ${ep}`);
5453
5451
  } catch (err) {
5454
- const ep = (_d = this.serverUpdateNotifier.endpoint) != null ? _d : "unknown";
5452
+ const ep = (_c = this.serverUpdateNotifier.endpoint) != null ? _c : "unknown";
5455
5453
  console.warn(
5456
5454
  `[SyncedDb] SyncedDb: ebus-proxy connection to ${ep} failed`
5457
5455
  );
@@ -6714,9 +6712,7 @@ var _SyncedDb = class _SyncedDb {
6714
6712
  const allDirty = await this.dexieDb.getDirty(collectionName);
6715
6713
  const content = stuck.map((m) => {
6716
6714
  const dirtyId = String(m.id);
6717
- const found = allDirty.find(
6718
- (d) => String(d._id) === dirtyId
6719
- );
6715
+ const found = allDirty.find((d) => String(d._id) === dirtyId);
6720
6716
  if (found) {
6721
6717
  const _a = found, { _id, _ts, _rev } = _a, changedFields = __objRest(_a, ["_id", "_ts", "_rev"]);
6722
6718
  return {
@@ -10866,7 +10862,8 @@ function preprocessForPack2(data) {
10866
10862
  if (isTimestamp2(data)) return { t: data.high, i: data.low };
10867
10863
  if (typeof data !== "object") return data;
10868
10864
  if (data instanceof Date) return data;
10869
- if (data instanceof Map || data instanceof Set || data instanceof RegExp) return data;
10865
+ if (data instanceof Map || data instanceof Set || data instanceof RegExp)
10866
+ return data;
10870
10867
  if (Array.isArray(data)) return data.map(preprocessForPack2);
10871
10868
  const result = {};
10872
10869
  for (const key of Object.keys(data)) {
@@ -10916,8 +10913,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
10916
10913
  this.pongTimeoutMs = (_d = config.pongTimeoutMs) != null ? _d : DEFAULT_PONG_TIMEOUT_MS;
10917
10914
  this.currentReconnectDelay = this.reconnectDelayMs;
10918
10915
  if (config.onWsConnect) this.onWsConnectCallbacks.push(config.onWsConnect);
10919
- if (config.onWsDisconnect) this.onWsDisconnectCallbacks.push(config.onWsDisconnect);
10920
- if (config.onWsReconnect) this.onWsReconnectCallbacks.push(config.onWsReconnect);
10916
+ if (config.onWsDisconnect)
10917
+ this.onWsDisconnectCallbacks.push(config.onWsDisconnect);
10918
+ if (config.onWsReconnect)
10919
+ this.onWsReconnectCallbacks.push(config.onWsReconnect);
10921
10920
  this.onWsNotification = config.onWsNotification;
10922
10921
  this.subscribeServices = (_e = config.subscribeServices) != null ? _e : false;
10923
10922
  this.onServicesChange = config.onServicesChange;
@@ -10999,7 +10998,11 @@ var Ebus2ProxyServerUpdateNotifier = class {
10999
10998
  return new Promise((resolve, reject) => {
11000
10999
  const timer = setTimeout(() => {
11001
11000
  this._pendingRttPings.delete(id);
11002
- reject(new Error(`[Ebus2ProxyNotifier] measureWsRtt: timeout after ${timeoutMs}ms`));
11001
+ reject(
11002
+ new Error(
11003
+ `[Ebus2ProxyNotifier] measureWsRtt: timeout after ${timeoutMs}ms`
11004
+ )
11005
+ );
11003
11006
  }, timeoutMs);
11004
11007
  this._pendingRttPings.set(id, () => {
11005
11008
  clearTimeout(timer);
@@ -11080,7 +11083,9 @@ var Ebus2ProxyServerUpdateNotifier = class {
11080
11083
  return new Promise((resolve, reject) => {
11081
11084
  var _a2;
11082
11085
  if ((_a2 = options == null ? void 0 : options.signal) == null ? void 0 : _a2.aborted) {
11083
- reject(new Error(`[Ebus2ProxyNotifier] callWorker(${service}): aborted`));
11086
+ reject(
11087
+ new Error(`[Ebus2ProxyNotifier] callWorker(${service}): aborted`)
11088
+ );
11084
11089
  return;
11085
11090
  }
11086
11091
  const timer = setTimeout(() => {
@@ -11106,7 +11111,9 @@ var Ebus2ProxyServerUpdateNotifier = class {
11106
11111
  );
11107
11112
  } : void 0;
11108
11113
  if (abortListener && options.signal) {
11109
- options.signal.addEventListener("abort", abortListener, { once: true });
11114
+ options.signal.addEventListener("abort", abortListener, {
11115
+ once: true
11116
+ });
11110
11117
  }
11111
11118
  this._pendingRequests.set(id, {
11112
11119
  resolve,
@@ -11164,11 +11171,15 @@ var Ebus2ProxyServerUpdateNotifier = class {
11164
11171
  if (idx !== -1) this.onWsConnectCallbacks.splice(idx, 1);
11165
11172
  }
11166
11173
  if (addedCallbacks.onDisconnect) {
11167
- const idx = this.onWsDisconnectCallbacks.indexOf(addedCallbacks.onDisconnect);
11174
+ const idx = this.onWsDisconnectCallbacks.indexOf(
11175
+ addedCallbacks.onDisconnect
11176
+ );
11168
11177
  if (idx !== -1) this.onWsDisconnectCallbacks.splice(idx, 1);
11169
11178
  }
11170
11179
  if (addedCallbacks.onReconnect) {
11171
- const idx = this.onWsReconnectCallbacks.indexOf(addedCallbacks.onReconnect);
11180
+ const idx = this.onWsReconnectCallbacks.indexOf(
11181
+ addedCallbacks.onReconnect
11182
+ );
11172
11183
  if (idx !== -1) this.onWsReconnectCallbacks.splice(idx, 1);
11173
11184
  }
11174
11185
  };
@@ -11229,9 +11240,6 @@ var Ebus2ProxyServerUpdateNotifier = class {
11229
11240
  this.connected = true;
11230
11241
  this.reconnectAttempt = 0;
11231
11242
  this.currentReconnectDelay = this.reconnectDelayMs;
11232
- console.log(
11233
- `[Ebus2ProxyNotifier] Ebus2Proxy connected to ${this.wsUrl} (db: ${this.dbName})`
11234
- );
11235
11243
  this.sendSubscribe(`db/${this.dbName}`);
11236
11244
  if (this.subscribeServices) {
11237
11245
  this.sendSubscribe("ebus/services");
@@ -11241,7 +11249,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11241
11249
  try {
11242
11250
  callback();
11243
11251
  } catch (err) {
11244
- console.error(`[Ebus2ProxyNotifier] onWsConnect callback failed: ${err}`, err);
11252
+ console.error(
11253
+ `[Ebus2ProxyNotifier] onWsConnect callback failed: ${err}`,
11254
+ err
11255
+ );
11245
11256
  }
11246
11257
  }
11247
11258
  }
@@ -11270,7 +11281,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11270
11281
  try {
11271
11282
  callback(reason);
11272
11283
  } catch (err) {
11273
- console.error(`[Ebus2ProxyNotifier] onWsDisconnect callback failed: ${err}`, err);
11284
+ console.error(
11285
+ `[Ebus2ProxyNotifier] onWsDisconnect callback failed: ${err}`,
11286
+ err
11287
+ );
11274
11288
  }
11275
11289
  }
11276
11290
  }
@@ -11314,7 +11328,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11314
11328
  clearTimeout(pending.timer);
11315
11329
  this._pendingRequests.delete(message.id);
11316
11330
  if (pending.abortListener && pending.signal) {
11317
- pending.signal.removeEventListener("abort", pending.abortListener);
11331
+ pending.signal.removeEventListener(
11332
+ "abort",
11333
+ pending.abortListener
11334
+ );
11318
11335
  }
11319
11336
  pending.resolve(message.data);
11320
11337
  }
@@ -11328,7 +11345,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11328
11345
  clearTimeout(pending.timer);
11329
11346
  this._pendingRequests.delete(message.id);
11330
11347
  if (pending.abortListener && pending.signal) {
11331
- pending.signal.removeEventListener("abort", pending.abortListener);
11348
+ pending.signal.removeEventListener(
11349
+ "abort",
11350
+ pending.abortListener
11351
+ );
11332
11352
  }
11333
11353
  pending.reject(
11334
11354
  new Error(
@@ -11338,11 +11358,17 @@ var Ebus2ProxyServerUpdateNotifier = class {
11338
11358
  break;
11339
11359
  }
11340
11360
  }
11341
- console.error(`[Ebus2ProxyNotifier] WebSocket server error: ${message.error}`, message.error);
11361
+ console.error(
11362
+ `[Ebus2ProxyNotifier] WebSocket server error: ${message.error}`,
11363
+ message.error
11364
+ );
11342
11365
  break;
11343
11366
  }
11344
11367
  } catch (err) {
11345
- console.error(`[Ebus2ProxyNotifier] Failed to parse WebSocket message: ${err}`, err);
11368
+ console.error(
11369
+ `[Ebus2ProxyNotifier] Failed to parse WebSocket message: ${err}`,
11370
+ err
11371
+ );
11346
11372
  }
11347
11373
  }
11348
11374
  handleChannelMessage(message) {
@@ -11350,7 +11376,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11350
11376
  try {
11351
11377
  this.onServicesChange(message.data);
11352
11378
  } catch (err) {
11353
- console.error(`[Ebus2ProxyNotifier] onServicesChange callback failed: ${err}`, err);
11379
+ console.error(
11380
+ `[Ebus2ProxyNotifier] onServicesChange callback failed: ${err}`,
11381
+ err
11382
+ );
11354
11383
  }
11355
11384
  return;
11356
11385
  }
@@ -11367,14 +11396,20 @@ var Ebus2ProxyServerUpdateNotifier = class {
11367
11396
  try {
11368
11397
  this.onWsNotification(payload);
11369
11398
  } catch (err) {
11370
- console.error(`[Ebus2ProxyNotifier] onWsNotification callback failed: ${err}`, err);
11399
+ console.error(
11400
+ `[Ebus2ProxyNotifier] onWsNotification callback failed: ${err}`,
11401
+ err
11402
+ );
11371
11403
  }
11372
11404
  }
11373
11405
  for (const callback of this.callbacks) {
11374
11406
  try {
11375
11407
  callback(payload);
11376
11408
  } catch (err) {
11377
- console.error(`[Ebus2ProxyNotifier] ServerUpdateCallback failed: ${err}`, err);
11409
+ console.error(
11410
+ `[Ebus2ProxyNotifier] ServerUpdateCallback failed: ${err}`,
11411
+ err
11412
+ );
11378
11413
  }
11379
11414
  }
11380
11415
  }
@@ -11393,7 +11428,10 @@ var Ebus2ProxyServerUpdateNotifier = class {
11393
11428
  try {
11394
11429
  callback(this.reconnectAttempt);
11395
11430
  } catch (err) {
11396
- console.error(`[Ebus2ProxyNotifier] onWsReconnect callback failed: ${err}`, err);
11431
+ console.error(
11432
+ `[Ebus2ProxyNotifier] onWsReconnect callback failed: ${err}`,
11433
+ err
11434
+ );
11397
11435
  }
11398
11436
  }
11399
11437
  this.reconnectTimer = setTimeout(() => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cry-synced-db-client",
3
- "version": "0.1.207",
3
+ "version": "0.1.208",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",