@roeehrl/tinode-sdk 0.25.1-sqlite.12 → 0.25.1-sqlite.14

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@roeehrl/tinode-sdk",
3
3
  "description": "Tinode SDK fork with Storage interface for SQLite persistence in React Native",
4
- "version": "0.25.1-sqlite.12",
4
+ "version": "0.25.1-sqlite.14",
5
5
  "types": "./types/index.d.ts",
6
6
  "scripts": {
7
7
  "format": "js-beautify -r src/*.js",
package/src/connection.js CHANGED
@@ -354,6 +354,9 @@ export default class Connection {
354
354
 
355
355
  this.reconnect = force => {
356
356
  this.#boffStop();
357
+ if (force) {
358
+ this.#boffReset();
359
+ }
357
360
  // Catch the promise to prevent unhandled rejection
358
361
  // Errors are handled via onDisconnect callback instead
359
362
  this.connect(null, force).catch(_ => {
@@ -467,6 +470,9 @@ export default class Connection {
467
470
 
468
471
  this.reconnect = force => {
469
472
  this.#boffStop();
473
+ if (force) {
474
+ this.#boffReset();
475
+ }
470
476
  // Catch the promise to prevent unhandled rejection
471
477
  // Errors are handled via onDisconnect callback instead
472
478
  this.connect(null, force).catch(_ => {
package/src/tinode.js CHANGED
@@ -384,7 +384,7 @@ export class Tinode {
384
384
  if (config.transport != 'lp' && config.transport != 'ws') {
385
385
  config.transport = detectTransport();
386
386
  }
387
- this._connection = new Connection(config, Const.PROTOCOL_VERSION, /* autoreconnect */ true);
387
+ this._connection = new Connection(config, Const.PROTOCOL_VERSION, config.autoreconnect !== false);
388
388
  this._connection.onMessage = (data) => {
389
389
  // Call the main message dispatcher.
390
390
  this.#dispatchMessage(data);
@@ -505,8 +505,14 @@ export class Tinode {
505
505
  callbacks.resolve(onOK);
506
506
  }
507
507
  } else if (callbacks.reject) {
508
- // Pass params from ctrl response to CommError for richer error handling
509
- callbacks.reject(new CommError(errorText, code, onOK?.params));
508
+ console.log("[Tinode/execPromise] Rejecting:", JSON.stringify({
509
+ code: code,
510
+ errorText: errorText,
511
+ hasOnOK: !!onOK,
512
+ params: onOK ? onOK.params : undefined,
513
+ onOKKeys: onOK ? Object.keys(onOK) : undefined,
514
+ }));
515
+ callbacks.reject(new CommError(errorText, code, onOK ? onOK.params : undefined));
510
516
  }
511
517
  }
512
518
  }
package/src/topic.js CHANGED
@@ -381,12 +381,19 @@ export default class Topic {
381
381
  this._routeData(pub);
382
382
  return ctrl;
383
383
  }).catch(err => {
384
+ console.log("[Tinode/publishMessage] Error caught:", JSON.stringify({
385
+ code: err.code,
386
+ message: err.message,
387
+ params: err.params,
388
+ name: err.name,
389
+ }));
384
390
  this._tinode.logger("WARNING: Message rejected by the server", err);
385
391
  pub._sending = false;
386
392
  pub._failed = true;
387
393
  if (this.onData) {
388
394
  this.onData();
389
395
  }
396
+ throw err;
390
397
  });
391
398
  }
392
399
 
package/types/index.d.ts CHANGED
@@ -31,6 +31,8 @@ declare module '@roeehrl/tinode-sdk' {
31
31
  platform?: 'ios' | 'web' | 'android';
32
32
  /** Enable IndexedDB caching for messages */
33
33
  persist?: boolean;
34
+ /** Enable SDK auto-reconnect on disconnect. Default: true. */
35
+ autoreconnect?: boolean;
34
36
  }
35
37
 
36
38
  // ==========================================================================
package/umd/tinode.dev.js CHANGED
@@ -670,6 +670,9 @@ class Connection {
670
670
  };
671
671
  this.reconnect = force => {
672
672
  this.#boffStop();
673
+ if (force) {
674
+ this.#boffReset();
675
+ }
673
676
  this.connect(null, force).catch(_ => {
674
677
  Connection.#log('LP reconnect promise rejected, error handled via onDisconnect callback');
675
678
  });
@@ -754,6 +757,9 @@ class Connection {
754
757
  };
755
758
  this.reconnect = force => {
756
759
  this.#boffStop();
760
+ if (force) {
761
+ this.#boffReset();
762
+ }
757
763
  this.connect(null, force).catch(_ => {
758
764
  Connection.#log('WS reconnect promise rejected, error handled via onDisconnect callback');
759
765
  });
@@ -4218,12 +4224,19 @@ class Topic {
4218
4224
  this._routeData(pub);
4219
4225
  return ctrl;
4220
4226
  }).catch(err => {
4227
+ console.log("[Tinode/publishMessage] Error caught:", JSON.stringify({
4228
+ code: err.code,
4229
+ message: err.message,
4230
+ params: err.params,
4231
+ name: err.name
4232
+ }));
4221
4233
  this._tinode.logger("WARNING: Message rejected by the server", err);
4222
4234
  pub._sending = false;
4223
4235
  pub._failed = true;
4224
4236
  if (this.onData) {
4225
4237
  this.onData();
4226
4238
  }
4239
+ throw err;
4227
4240
  });
4228
4241
  }
4229
4242
  publishDraft(pub, prom) {
@@ -5545,7 +5558,7 @@ __webpack_require__.r(__webpack_exports__);
5545
5558
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
5546
5559
  /* harmony export */ PACKAGE_VERSION: function() { return /* binding */ PACKAGE_VERSION; }
5547
5560
  /* harmony export */ });
5548
- const PACKAGE_VERSION = "0.25.1-sqlite.12";
5561
+ const PACKAGE_VERSION = "0.25.1-sqlite.14";
5549
5562
 
5550
5563
  /***/ })
5551
5564
 
@@ -5916,7 +5929,7 @@ class Tinode {
5916
5929
  if (config.transport != 'lp' && config.transport != 'ws') {
5917
5930
  config.transport = detectTransport();
5918
5931
  }
5919
- this._connection = new _connection_js__WEBPACK_IMPORTED_MODULE_3__["default"](config, _config_js__WEBPACK_IMPORTED_MODULE_1__.PROTOCOL_VERSION, true);
5932
+ this._connection = new _connection_js__WEBPACK_IMPORTED_MODULE_3__["default"](config, _config_js__WEBPACK_IMPORTED_MODULE_1__.PROTOCOL_VERSION, config.autoreconnect !== false);
5920
5933
  this._connection.onMessage = data => {
5921
5934
  this.#dispatchMessage(data);
5922
5935
  };
@@ -6007,7 +6020,14 @@ class Tinode {
6007
6020
  callbacks.resolve(onOK);
6008
6021
  }
6009
6022
  } else if (callbacks.reject) {
6010
- callbacks.reject(new _comm_error_js__WEBPACK_IMPORTED_MODULE_2__["default"](errorText, code, onOK?.params));
6023
+ console.log("[Tinode/execPromise] Rejecting:", JSON.stringify({
6024
+ code: code,
6025
+ errorText: errorText,
6026
+ hasOnOK: !!onOK,
6027
+ params: onOK ? onOK.params : undefined,
6028
+ onOKKeys: onOK ? Object.keys(onOK) : undefined
6029
+ }));
6030
+ callbacks.reject(new _comm_error_js__WEBPACK_IMPORTED_MODULE_2__["default"](errorText, code, onOK ? onOK.params : undefined));
6011
6031
  }
6012
6032
  }
6013
6033
  }