podchat-browser 12.9.20 → 12.9.21-snapshot.1

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.
@@ -1 +1 @@
1
- {"version":"12.9.20","date":"۱۴۰۵/۴/۷","VersionInfo":"Release: true, Snapshot: false, Is For Test: false"}
1
+ {"version":"12.9.21-snapshot.1","date":"۱۴۰۵/۴/۱۷","VersionInfo":"Release: false, Snapshot: true, Is For Test: true"}
@@ -2274,7 +2274,7 @@ function MultiTrackCallManager(_ref) {
2274
2274
 
2275
2275
  function _parsePc() {
2276
2276
  _parsePc = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(pc, type, parseData) {
2277
- var stats, now, out;
2277
+ var stats, now, out, bytesByKind, lossByKind, jitterByKind, totalRecv, totalSend, totalJitter;
2278
2278
  return _regenerator["default"].wrap(function _callee9$(_context10) {
2279
2279
  while (1) {
2280
2280
  switch (_context10.prev = _context10.next) {
@@ -2298,6 +2298,62 @@ function MultiTrackCallManager(_ref) {
2298
2298
  connection: {},
2299
2299
  tracks: {}
2300
2300
  };
2301
+ bytesByKind = {
2302
+ audio: {
2303
+ bytesSent: 0,
2304
+ bytesReceived: 0
2305
+ },
2306
+ video: {
2307
+ bytesSent: 0,
2308
+ bytesReceived: 0
2309
+ }
2310
+ };
2311
+ lossByKind = {
2312
+ audio: {
2313
+ recv: {
2314
+ packetsLost: 0,
2315
+ packetsReceived: 0
2316
+ },
2317
+ send: {
2318
+ packetsLost: 0
2319
+ }
2320
+ },
2321
+ video: {
2322
+ recv: {
2323
+ packetsLost: 0,
2324
+ packetsReceived: 0
2325
+ },
2326
+ send: {
2327
+ packetsLost: 0
2328
+ }
2329
+ }
2330
+ };
2331
+ jitterByKind = {
2332
+ audio: {
2333
+ recv: {
2334
+ sum: 0,
2335
+ max: 0,
2336
+ count: 0
2337
+ },
2338
+ send: {
2339
+ sum: 0,
2340
+ max: 0,
2341
+ count: 0
2342
+ }
2343
+ },
2344
+ video: {
2345
+ recv: {
2346
+ sum: 0,
2347
+ max: 0,
2348
+ count: 0
2349
+ },
2350
+ send: {
2351
+ sum: 0,
2352
+ max: 0,
2353
+ count: 0
2354
+ }
2355
+ }
2356
+ };
2301
2357
  stats.forEach(function (report) {
2302
2358
  // ---------- CONNECTION ----------
2303
2359
  if (report.type === "candidate-pair" && report.state === "succeeded") {
@@ -2311,11 +2367,26 @@ function MultiTrackCallManager(_ref) {
2311
2367
  kind: report.kind
2312
2368
  };
2313
2369
  var t = out.tracks[id];
2314
- t.direction = "recv"; // jitter
2370
+ t.direction = "recv";
2371
+
2372
+ if (report.bytesReceived != null) {
2373
+ bytesByKind[report.kind].bytesReceived += report.bytesReceived;
2374
+ } // jitter
2375
+
2376
+
2377
+ t.jitter = report.jitter;
2378
+
2379
+ if (report.jitter != null) {
2380
+ var jitterMs = report.jitter * 1000;
2381
+ jitterByKind[report.kind].recv.sum += jitterMs;
2382
+ jitterByKind[report.kind].recv.max = Math.max(jitterByKind[report.kind].recv.max, jitterMs);
2383
+ jitterByKind[report.kind].recv.count++;
2384
+ } // loss
2315
2385
 
2316
- t.jitter = report.jitter; // loss
2317
2386
 
2318
2387
  if (report.packetsLost != null && report.packetsReceived != null) {
2388
+ lossByKind[report.kind].recv.packetsLost += report.packetsLost;
2389
+ lossByKind[report.kind].recv.packetsReceived += report.packetsReceived;
2319
2390
  t.loss = calcLoss(report.packetsLost, report.packetsReceived);
2320
2391
  } // bitrate
2321
2392
 
@@ -2341,6 +2412,7 @@ function MultiTrackCallManager(_ref) {
2341
2412
  _t.direction = "send";
2342
2413
 
2343
2414
  if (report.bytesSent != null) {
2415
+ bytesByKind[report.kind].bytesSent += report.bytesSent;
2344
2416
  _t.bitrate = calcBitrate(report.id, report.bytesSent, now);
2345
2417
  }
2346
2418
 
@@ -2364,6 +2436,18 @@ function MultiTrackCallManager(_ref) {
2364
2436
 
2365
2437
  _t2.jitter = report.jitter;
2366
2438
 
2439
+ if (report.jitter != null) {
2440
+ var _jitterMs = report.jitter * 1000;
2441
+
2442
+ jitterByKind[report.kind].send.sum += _jitterMs;
2443
+ jitterByKind[report.kind].send.max = Math.max(jitterByKind[report.kind].send.max, _jitterMs);
2444
+ jitterByKind[report.kind].send.count++;
2445
+ }
2446
+
2447
+ if (report.packetsLost != null) {
2448
+ lossByKind[report.kind].send.packetsLost += report.packetsLost;
2449
+ }
2450
+
2367
2451
  if (report.fractionLost != null) {
2368
2452
  _t2.loss = report.fractionLost / 256 * 100;
2369
2453
  } else if (report.packetsLost != null) {
@@ -2375,9 +2459,70 @@ function MultiTrackCallManager(_ref) {
2375
2459
  }
2376
2460
  }
2377
2461
  });
2462
+ out.totalBytes = bytesByKind;
2463
+ ['audio', 'video'].forEach(function (kind) {
2464
+ var r = lossByKind[kind].recv;
2465
+ r.percent = r.packetsLost + r.packetsReceived > 0 ? r.packetsLost / (r.packetsLost + r.packetsReceived) * 100 : 0;
2466
+ });
2467
+ totalRecv = {
2468
+ packetsLost: 0,
2469
+ packetsReceived: 0,
2470
+ percent: 0
2471
+ };
2472
+ totalSend = {
2473
+ packetsLost: 0
2474
+ };
2475
+ ['audio', 'video'].forEach(function (kind) {
2476
+ totalRecv.packetsLost += lossByKind[kind].recv.packetsLost;
2477
+ totalRecv.packetsReceived += lossByKind[kind].recv.packetsReceived;
2478
+ totalSend.packetsLost += lossByKind[kind].send.packetsLost;
2479
+ });
2480
+ totalRecv.percent = totalRecv.packetsLost + totalRecv.packetsReceived > 0 ? totalRecv.packetsLost / (totalRecv.packetsLost + totalRecv.packetsReceived) * 100 : 0;
2481
+ lossByKind.total = {
2482
+ recv: totalRecv,
2483
+ send: totalSend
2484
+ };
2485
+ out.totalLoss = lossByKind;
2486
+ totalJitter = {
2487
+ recv: {
2488
+ sum: 0,
2489
+ max: 0,
2490
+ count: 0
2491
+ },
2492
+ send: {
2493
+ sum: 0,
2494
+ max: 0,
2495
+ count: 0
2496
+ }
2497
+ };
2498
+ ['audio', 'video'].forEach(function (kind) {
2499
+ ['recv', 'send'].forEach(function (dir) {
2500
+ var j = jitterByKind[kind][dir];
2501
+ totalJitter[dir].sum += j.sum || 0;
2502
+ totalJitter[dir].max = Math.max(totalJitter[dir].max, j.max);
2503
+ totalJitter[dir].count += j.count || 0;
2504
+ });
2505
+ });
2506
+ totalJitter.recv.avg = totalJitter.recv.count > 0 ? totalJitter.recv.sum / totalJitter.recv.count : 0;
2507
+ totalJitter.send.avg = totalJitter.send.count > 0 ? totalJitter.send.sum / totalJitter.send.count : 0;
2508
+ delete totalJitter.recv.sum;
2509
+ delete totalJitter.recv.count;
2510
+ delete totalJitter.send.sum;
2511
+ delete totalJitter.send.count;
2512
+ ['audio', 'video'].forEach(function (kind) {
2513
+ ['recv', 'send'].forEach(function (dir) {
2514
+ var j = jitterByKind[kind][dir];
2515
+ j.avg = j.count > 0 ? j.sum / j.count : 0;
2516
+ delete j.sum;
2517
+ delete j.count;
2518
+ });
2519
+ });
2520
+ jitterByKind.total = totalJitter;
2521
+ jitterByKind.unit = "ms";
2522
+ out.jitterSummary = jitterByKind;
2378
2523
  return _context10.abrupt("return", out);
2379
2524
 
2380
- case 11:
2525
+ case 34:
2381
2526
  case "end":
2382
2527
  return _context10.stop();
2383
2528
  }
@@ -795,6 +795,7 @@ function CallUser(app, user) {
795
795
  topic: conf.topic,
796
796
  mediaType: 3,
797
797
  clientId: config.user.clientId,
798
+ mline: conf && conf.mline,
798
799
  onTrackCallback: function onTrackCallback() {},
799
800
  onUpdateSuccess: function onUpdateSuccess() {}
800
801
  });
@@ -37,20 +37,20 @@ var FileManager = /*#__PURE__*/function () {
37
37
  (0, _createClass2["default"])(FileManager, [{
38
38
  key: "getPodspaceFile",
39
39
  value:
40
- /**
41
- * @param {string} fileHash - The hash of the file to retrieve.
42
- * @param {string} threadId - The ID of the thread associated with the file.
43
- * @param {object} options - Optional settings for the file retrieval.
44
- * @param {object} [options.headers={}] - Custom headers to send with the request.
45
- * @param {string} [options.method='GET'] - The HTTP method to use for the request.
46
- * @param {function|null} [options.onProgress=null] - Callback for download progress.
47
- * @param {function|null} [options.onComplete=null] - Callback when download is complete.
48
- * @param {function|null} [options.onError=null] - Callback for errors.
49
- * @param {function|null} [options.onPause=null] - Callback when download is paused.
50
- * @param {function|null} [options.onCancel=null] - Callback when download is cancelled.
51
- * @param {number} [options.maxRetries=3] - Maximum number of retries for the request.
52
- * @param {number} [options.initialDelay=1000] - Initial delay in milliseconds before retrying.
53
- * @param {number} [options.timeoutDuration=30000] - Timeout duration in milliseconds for the request.
40
+ /**
41
+ * @param {string} fileHash - The hash of the file to retrieve.
42
+ * @param {string} threadId - The ID of the thread associated with the file.
43
+ * @param {object} options - Optional settings for the file retrieval.
44
+ * @param {object} [options.headers={}] - Custom headers to send with the request.
45
+ * @param {string} [options.method='GET'] - The HTTP method to use for the request.
46
+ * @param {function|null} [options.onProgress=null] - Callback for download progress.
47
+ * @param {function|null} [options.onComplete=null] - Callback when download is complete.
48
+ * @param {function|null} [options.onError=null] - Callback for errors.
49
+ * @param {function|null} [options.onPause=null] - Callback when download is paused.
50
+ * @param {function|null} [options.onCancel=null] - Callback when download is cancelled.
51
+ * @param {number} [options.maxRetries=3] - Maximum number of retries for the request.
52
+ * @param {number} [options.initialDelay=1000] - Initial delay in milliseconds before retrying.
53
+ * @param {number} [options.timeoutDuration=30000] - Timeout duration in milliseconds for the request.
54
54
  */
55
55
  function getPodspaceFile(_ref) {
56
56
  var _this = this;
@@ -83,19 +83,19 @@ var FileManager = /*#__PURE__*/function () {
83
83
  delete _this._downloadList[fileHash];
84
84
  _this._downloadList[fileHash] = null;
85
85
  },
86
- pause: this._downloadList[fileHash].cancel.bind(this._downloadList[fileHash]),
86
+ pause: this._downloadList[fileHash].pause.bind(this._downloadList[fileHash]),
87
87
  resume: this._downloadList[fileHash].resume.bind(this._downloadList[fileHash])
88
88
  };
89
89
  }
90
- /**
91
- *
92
- * @param {string} fileHash - The hash of the file to retrieve.
93
- * @param {string} threadId - (optional) The ID of the thread associated with the file.
94
- * @param {string} size - (optional) The ID of the thread associated with the file.
95
- * @param {number} quality - (optional) The ID of the thread associated with the file.
96
- * @param {boolean} crop - (optional) The ID of the thread associated with the file.
97
- * @param {object} options
98
- * @returns {{cancel: cancel, resume: *, getStatus: any, pause: *}}
90
+ /**
91
+ *
92
+ * @param {string} fileHash - The hash of the file to retrieve.
93
+ * @param {string} threadId - (optional) The ID of the thread associated with the file.
94
+ * @param {string} size - (optional) The ID of the thread associated with the file.
95
+ * @param {number} quality - (optional) The ID of the thread associated with the file.
96
+ * @param {boolean} crop - (optional) The ID of the thread associated with the file.
97
+ * @param {object} options
98
+ * @returns {{cancel: cancel, resume: *, getStatus: any, pause: *}}
99
99
  */
100
100
 
101
101
  }, {
@@ -144,7 +144,7 @@ var FileManager = /*#__PURE__*/function () {
144
144
  delete _this2._downloadList[fileHash];
145
145
  _this2._downloadList[fileHash] = null;
146
146
  },
147
- pause: this._downloadList[fileHash].cancel.bind(this._downloadList[fileHash]),
147
+ pause: this._downloadList[fileHash].pause.bind(this._downloadList[fileHash]),
148
148
  resume: this._downloadList[fileHash].resume.bind(this._downloadList[fileHash])
149
149
  };
150
150
  }
@@ -204,8 +204,7 @@ var FileDownloadObject = /*#__PURE__*/function () {
204
204
  this._paused = false;
205
205
  this._canceled = false;
206
206
  this.dataChunks = [];
207
- this._addToGroupRetryCount = 0; // reqObject.headers.method = 'GET';
208
- // reqObject.headers.headers.Range = `bytes=${reqObject.start}-${Math.min(reqObject.start + reqObject.chunkSize - 1, reqObject.fileSize - 1)}`;
207
+ this._addToGroupRetryCount = 0;
209
208
  }
210
209
 
211
210
  (0, _createClass2["default"])(FileDownloadObject, [{
@@ -221,16 +220,24 @@ var FileDownloadObject = /*#__PURE__*/function () {
221
220
  }, {
222
221
  key: "cancel",
223
222
  value: function cancel() {
224
- this.abortController.abort();
223
+ this._canceled = true;
224
+ if (this.abortController) this.abortController.abort();
225
225
  }
226
226
  }, {
227
227
  key: "pause",
228
228
  value: function pause() {
229
229
  this._paused = true;
230
+
231
+ if (this.abortController) {
232
+ this.abortController.abort();
233
+ }
230
234
  }
231
235
  }, {
232
236
  key: "resume",
233
237
  value: function resume() {
238
+ this._paused = false;
239
+ this._canceled = false;
240
+
234
241
  this._downloadWithResume();
235
242
  }
236
243
  }, {
@@ -239,7 +246,7 @@ var FileDownloadObject = /*#__PURE__*/function () {
239
246
  var _downloadWithResume2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
240
247
  var _this4 = this;
241
248
 
242
- var _this$options, _this$options$method, method, _this$options$maxRetr, maxRetries, _this$options$initial, initialDelay, _this$options$timeout, timeoutDuration, retries, currentDelay, totalSize, headResponse, signal, timeoutId, rangeHeader, response, receivedRange, currentFileTotalSize, reader, chunkDownloadedSize, progressPercentOld, _yield$reader$read, done, value, currentChunkSize, blob, jitter, delayWithJitter;
249
+ var _this$options, _this$options$method, method, _this$options$maxRetr, maxRetries, _this$options$initial, initialDelay, _this$options$timeout, timeoutDuration, retries, currentDelay, totalSize, headResponse, signal, timeoutId, rangeHeader, response, receivedRange, currentFileTotalSize, reader, chunkDownloadedSize, progressPercentOld, _yield$reader$read, done, value, currentChunkSize, blob, _blob, jitter, delayWithJitter;
243
250
 
244
251
  return _regenerator["default"].wrap(function _callee$(_context) {
245
252
  while (1) {
@@ -248,8 +255,9 @@ var FileDownloadObject = /*#__PURE__*/function () {
248
255
  _this$options = this.options, _this$options$method = _this$options.method, method = _this$options$method === void 0 ? 'GET' : _this$options$method, _this$options$maxRetr = _this$options.maxRetries, maxRetries = _this$options$maxRetr === void 0 ? 5 : _this$options$maxRetr, _this$options$initial = _this$options.initialDelay, initialDelay = _this$options$initial === void 0 ? 1000 : _this$options$initial, _this$options$timeout = _this$options.timeoutDuration, timeoutDuration = _this$options$timeout === void 0 ? 30000 : _this$options$timeout;
249
256
  retries = 0;
250
257
  currentDelay = initialDelay;
251
- totalSize = 0;
252
- if (!this.abortController) this.abortController = new AbortController();
258
+ totalSize = 0; // Resume: create new abort controller each time
259
+
260
+ if (!this.abortController || !this.abortController.signal) this.abortController = new AbortController();
253
261
  _context.prev = 5;
254
262
  _context.next = 8;
255
263
  return fetch(this.url, {
@@ -272,7 +280,7 @@ var FileDownloadObject = /*#__PURE__*/function () {
272
280
  threadId: this.threadId
273
281
  }, function (result2) {
274
282
  if (!result2.hasError) {
275
- //Retry the request
283
+ // Retry the request
276
284
  _this4._addToGroupRetryCount++;
277
285
 
278
286
  _this4._downloadWithResume();
@@ -294,7 +302,7 @@ var FileDownloadObject = /*#__PURE__*/function () {
294
302
  return _context.abrupt("return");
295
303
 
296
304
  case 12:
297
- this.status.totalSize = parseInt(headResponse.headers.get('content-length') || '0', 10);
305
+ this.status.totalSize = parseInt(headResponse.headers.get('content-length') || '0', 10); // If already fully downloaded
298
306
 
299
307
  if (!(this.status.downloadedSize >= this.status.totalSize && this.status.totalSize > 0)) {
300
308
  _context.next = 17;
@@ -321,12 +329,11 @@ var FileDownloadObject = /*#__PURE__*/function () {
321
329
  this.status.errorObject.response = null;
322
330
  this.status.errorObject.error = _context.t0;
323
331
  this.options.onError && this.options.onError(this.status);
324
- this.status.downloadedSize = 0; //TODO: maybe reset file state
325
- // storage.clearProgress(this.url);
332
+ this.status.downloadedSize = 0;
326
333
 
327
334
  case 27:
328
335
  if (!(retries <= maxRetries)) {
329
- _context.next = 99;
336
+ _context.next = 92;
330
337
  break;
331
338
  }
332
339
 
@@ -354,7 +361,6 @@ var FileDownloadObject = /*#__PURE__*/function () {
354
361
  break;
355
362
  }
356
363
 
357
- // Partial Content
358
364
  receivedRange = response.headers.get('content-range');
359
365
  currentFileTotalSize = parseInt((receivedRange === null || receivedRange === void 0 ? void 0 : receivedRange.split('/')[1]) || this.status.totalSize, 10);
360
366
  if (!isNaN(currentFileTotalSize)) this.status.totalSize = currentFileTotalSize;
@@ -367,10 +373,8 @@ var FileDownloadObject = /*#__PURE__*/function () {
367
373
  break;
368
374
  }
369
375
 
370
- // کل فایل مجددا ارسال شد
371
376
  console.warn("Server did not support Range Requests, restarting download from beginning.");
372
- this.status.downloadedSize = 0; // ریست کردن اندازه دانلود شده
373
-
377
+ this.status.downloadedSize = 0;
374
378
  _context.next = 49;
375
379
  break;
376
380
 
@@ -396,7 +400,7 @@ var FileDownloadObject = /*#__PURE__*/function () {
396
400
  done = _yield$reader$read.done;
397
401
  value = _yield$reader$read.value;
398
402
 
399
- if (!(done || this._canceled)) {
403
+ if (!(done || this._canceled || this._paused)) {
400
404
  _context.next = 60;
401
405
  break;
402
406
  }
@@ -411,6 +415,8 @@ var FileDownloadObject = /*#__PURE__*/function () {
411
415
  this.status.downloadProgress = this.status.totalSize > 0 ? Math.round(this.status.downloadedSize / this.status.totalSize * 100) : 0;
412
416
 
413
417
  if (this.status.downloadProgress > progressPercentOld) {
418
+ blob = new Blob(this.dataChunks);
419
+ this.status.fileObject = blob;
414
420
  progressPercentOld = this.status.downloadProgress;
415
421
  this.options.onProgress && this.options.onProgress(this.status);
416
422
  }
@@ -419,47 +425,49 @@ var FileDownloadObject = /*#__PURE__*/function () {
419
425
  break;
420
426
 
421
427
  case 68:
422
- if (!(this.status.downloadedSize >= this.status.totalSize && this.status.totalSize > 0)) {
423
- _context.next = 74;
424
- break;
425
- }
428
+ if (this.status.downloadedSize >= this.status.totalSize && this.status.totalSize > 0) {
429
+ _blob = new Blob(this.dataChunks);
430
+ this.status.fileObject = _blob;
426
431
 
427
- blob = new Blob(this.dataChunks);
428
- this.status.fileObject = blob;
432
+ if (this.options.onComplete) {
433
+ this.status.fileObject = _blob;
434
+ this.options.onComplete(this.status);
435
+ }
429
436
 
430
- if (this.options.onComplete) {
431
- this.status.fileObject = blob;
432
- this.options.onComplete(this.status);
437
+ this.abortController = null;
433
438
  }
434
439
 
435
- this.abortController = null;
436
- return _context.abrupt("return");
437
-
438
- case 74:
439
- _context.next = 97;
440
+ _context.next = 90;
440
441
  break;
441
442
 
442
- case 76:
443
- _context.prev = 76;
443
+ case 71:
444
+ _context.prev = 71;
444
445
  _context.t1 = _context["catch"](30);
445
446
  clearTimeout(timeoutId);
446
447
 
447
448
  if (!(_context.t1.name === 'AbortError')) {
448
- _context.next = 84;
449
+ _context.next = 77;
449
450
  break;
450
451
  }
451
452
 
452
- console.log('Download aborted.');
453
- this.options.onCancel && this.options.onCancel();
454
- this.abortController = null;
453
+ if (this._canceled) {
454
+ console.log('Download aborted.');
455
+ this.options.onCancel && this.options.onCancel();
456
+ this.abortController = null;
457
+ } else if (this._paused) {
458
+ console.log('Download paused.');
459
+ this.options.onPause && this.options.onPause(this.status);
460
+ this.abortController = null;
461
+ }
462
+
455
463
  return _context.abrupt("return");
456
464
 
457
- case 84:
465
+ case 77:
458
466
  console.error("Attempt ".concat(retries + 1, " failed:"), _context.t1.message);
459
467
  retries++;
460
468
 
461
469
  if (!(retries > maxRetries)) {
462
- _context.next = 91;
470
+ _context.next = 84;
463
471
  break;
464
472
  }
465
473
 
@@ -468,27 +476,26 @@ var FileDownloadObject = /*#__PURE__*/function () {
468
476
  this.abortController = null;
469
477
  return _context.abrupt("return");
470
478
 
471
- case 91:
472
- // Exponential Backoff + Jitter
479
+ case 84:
473
480
  jitter = Math.random() * currentDelay * 0.5;
474
481
  delayWithJitter = currentDelay + jitter;
475
- console.log("Retrying in ".concat(Math.round(delayWithJitter / 1000), " seconds..."));
476
- _context.next = 96;
482
+ console.log("Retry in ".concat(Math.round(delayWithJitter / 1000), " sec"));
483
+ _context.next = 89;
477
484
  return this.delay(delayWithJitter);
478
485
 
479
- case 96:
486
+ case 89:
480
487
  currentDelay *= 2;
481
488
 
482
- case 97:
489
+ case 90:
483
490
  _context.next = 27;
484
491
  break;
485
492
 
486
- case 99:
493
+ case 92:
487
494
  case "end":
488
495
  return _context.stop();
489
496
  }
490
497
  }
491
- }, _callee, this, [[5, 19], [30, 76]]);
498
+ }, _callee, this, [[5, 19], [30, 71]]);
492
499
  }));
493
500
 
494
501
  function _downloadWithResume() {