@atlaskit/collab-provider 19.0.4 → 19.0.5

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.
@@ -94,28 +94,28 @@ export var DocumentService = /*#__PURE__*/function () {
94
94
  */
95
95
  _defineProperty(this, "catchupv2", /*#__PURE__*/function () {
96
96
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(reason, reconnectionMetadata, sessionId) {
97
- var start, _this$analyticsHelper2, latency, _latency, errorMessage, _this$analyticsHelper3;
98
- return _regeneratorRuntime.wrap(function _callee$(_context) {
97
+ var start, _this$analyticsHelper2, latency, _latency, errorMessage, _this$analyticsHelper3, _t;
98
+ return _regeneratorRuntime.wrap(function (_context) {
99
99
  while (1) switch (_context.prev = _context.next) {
100
100
  case 0:
101
101
  start = new Date().getTime(); // if the queue is already paused, we are busy with something else, so don't proceed.
102
102
  if (!_this.stepQueue.isPaused()) {
103
- _context.next = 4;
103
+ _context.next = 1;
104
104
  break;
105
105
  }
106
106
  logger("Queue is paused. Aborting.");
107
107
  return _context.abrupt("return");
108
- case 4:
108
+ case 1:
109
109
  if (!_this.isNameSpaceLocked()) {
110
- _context.next = 7;
110
+ _context.next = 2;
111
111
  break;
112
112
  }
113
113
  logger("catchupv2: Document is locked. Aborting.");
114
114
  return _context.abrupt("return");
115
- case 7:
115
+ case 2:
116
116
  _this.stepQueue.pauseQueue();
117
- _context.prev = 8;
118
- _context.next = 11;
117
+ _context.prev = 3;
118
+ _context.next = 4;
119
119
  return catchupv2({
120
120
  getCurrentPmVersion: _this.getCurrentPmVersion,
121
121
  fetchCatchupv2: _this.fetchCatchupv2,
@@ -138,21 +138,21 @@ export var DocumentService = /*#__PURE__*/function () {
138
138
  },
139
139
  getState: _this.getState
140
140
  });
141
- case 11:
141
+ case 4:
142
142
  _this.catchUpOutofSync = _context.sent;
143
143
  latency = new Date().getTime() - start;
144
144
  (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
145
145
  latency: latency,
146
146
  version: _this.getCurrentPmVersion()
147
147
  });
148
- _context.next = 21;
148
+ _context.next = 6;
149
149
  break;
150
- case 16:
151
- _context.prev = 16;
152
- _context.t0 = _context["catch"](8);
150
+ case 5:
151
+ _context.prev = 5;
152
+ _t = _context["catch"](3);
153
153
  _latency = new Date().getTime() - start; // Skip client side errors; TypeErrors are client side errors https://developer.mozilla.org/en-US/docs/Web/API/Window/fetch
154
- errorMessage = _context.t0 instanceof Error ? _context.t0.message : String(_context.t0);
155
- if (!errorMessage.includes('TypeError') && !(_context.t0 instanceof TypeError)) {
154
+ errorMessage = _t instanceof Error ? _t.message : String(_t);
155
+ if (!errorMessage.includes('TypeError') && !(_t instanceof TypeError)) {
156
156
  (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
157
157
  latency: _latency,
158
158
  reason: reason,
@@ -160,18 +160,18 @@ export var DocumentService = /*#__PURE__*/function () {
160
160
  disconnectionPeriodSeconds: reconnectionMetadata === null || reconnectionMetadata === void 0 ? void 0 : reconnectionMetadata.disconnectionPeriodSeconds
161
161
  });
162
162
  }
163
- case 21:
164
- _context.prev = 21;
163
+ case 6:
164
+ _context.prev = 6;
165
165
  _this.stepQueue.resumeQueue();
166
166
  _this.processQueue();
167
167
  _this.sendStepsFromCurrentState(); // this will eventually retry catchup as it calls throttledCommitStep which will either catchup on onStepsAdded or onErrorHandled
168
168
  _this.stepRejectCounter = 0;
169
- return _context.finish(21);
170
- case 27:
169
+ return _context.finish(6);
170
+ case 7:
171
171
  case "end":
172
172
  return _context.stop();
173
173
  }
174
- }, _callee, null, [[8, 16, 21, 27]]);
174
+ }, _callee, null, [[3, 5, 6, 7]]);
175
175
  }));
176
176
  return function (_x, _x2, _x3) {
177
177
  return _ref.apply(this, arguments);
@@ -190,8 +190,8 @@ export var DocumentService = /*#__PURE__*/function () {
190
190
  // Ignored via go/ees005
191
191
  // eslint-disable-next-line require-await
192
192
  _defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
193
- var _this$getState2, _this$analyticsHelper6, _this$analyticsHelper5, state, adfDocument, version, currentState, measure, _this$analyticsHelper7, _this$analyticsHelper8, _measure;
194
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
193
+ var _this$getState2, _this$analyticsHelper6, _this$analyticsHelper5, state, adfDocument, version, currentState, measure, _this$analyticsHelper7, _this$analyticsHelper8, _measure, _t2;
194
+ return _regeneratorRuntime.wrap(function (_context2) {
195
195
  while (1) switch (_context2.prev = _context2.next) {
196
196
  case 0:
197
197
  _context2.prev = 0;
@@ -216,20 +216,20 @@ export var DocumentService = /*#__PURE__*/function () {
216
216
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
217
217
  });
218
218
  return _context2.abrupt("return", currentState);
219
- case 12:
220
- _context2.prev = 12;
221
- _context2.t0 = _context2["catch"](0);
219
+ case 1:
220
+ _context2.prev = 1;
221
+ _t2 = _context2["catch"](0);
222
222
  _measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
223
223
  (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
224
224
  latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
225
225
  });
226
- (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
227
- throw _context2.t0;
228
- case 18:
226
+ (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(_t2, 'Error while returning ADF version of current draft document');
227
+ throw _t2;
228
+ case 2:
229
229
  case "end":
230
230
  return _context2.stop();
231
231
  }
232
- }, _callee2, null, [[0, 12]]);
232
+ }, _callee2, null, [[0, 1]]);
233
233
  })));
234
234
  _defineProperty(this, "isStepsFromNewClientIdForSameUserId", function (steps) {
235
235
  try {
@@ -359,8 +359,8 @@ export var DocumentService = /*#__PURE__*/function () {
359
359
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
360
360
  _defineProperty(this, "onRestore", /*#__PURE__*/function () {
361
361
  var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
362
- var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$obfuscateStepsA, obfuscatedSteps, obfuscatedDoc, _this$analyticsHelper15, _this$analyticsHelper11, _this$getState5, generatedDiffStepsResponse, generatedSteps, state, stepsToBeApplied, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper14, _this$analyticsHelper16, _this$analyticsHelper17;
363
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
362
+ var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$obfuscateStepsA, obfuscatedSteps, obfuscatedDoc, _this$analyticsHelper15, _this$analyticsHelper11, _this$getState5, generatedDiffStepsResponse, generatedSteps, state, stepsToBeApplied, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper14, _this$analyticsHelper16, _this$analyticsHelper17, _t3, _t4, _t5;
363
+ return _regeneratorRuntime.wrap(function (_context3) {
364
364
  while (1) switch (_context3.prev = _context3.next) {
365
365
  case 0:
366
366
  doc = _ref6.doc, version = _ref6.version, metadata = _ref6.metadata, targetClientId = _ref6.targetClientId;
@@ -368,21 +368,21 @@ export var DocumentService = /*#__PURE__*/function () {
368
368
  _this.hasRecovered = true;
369
369
  }
370
370
  if (!(targetClientId && _this.clientId !== targetClientId)) {
371
- _context3.next = 4;
371
+ _context3.next = 1;
372
372
  break;
373
373
  }
374
374
  return _context3.abrupt("return");
375
- case 4:
375
+ case 1:
376
376
  // We preserve these as they will be lost apon this.updateDocument. This is because we are using document recovery.
377
377
  // We can then reconcile the document with the preserved state.
378
378
  unconfirmedSteps = _this.getUnconfirmedSteps();
379
- _context3.next = 7;
379
+ _context3.next = 2;
380
380
  return _this.getCurrentState();
381
- case 7:
381
+ case 2:
382
382
  currentState = _context3.sent;
383
383
  useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
384
384
  _this$obfuscateStepsA = _this.obfuscateStepsAndState(unconfirmedSteps, currentState), obfuscatedSteps = _this$obfuscateStepsA.obfuscatedSteps, obfuscatedDoc = _this$obfuscateStepsA.obfuscatedDoc;
385
- _context3.prev = 10;
385
+ _context3.prev = 3;
386
386
  // Reset the editor,
387
387
  // - Replace the document, keep in sync with the server
388
388
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -397,7 +397,7 @@ export var DocumentService = /*#__PURE__*/function () {
397
397
  caller: 'onRestore'
398
398
  });
399
399
  _this.metadataService.updateMetadata(metadata);
400
- _context3.prev = 13;
400
+ _context3.prev = 4;
401
401
  (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
402
402
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
403
403
  obfuscatedSteps: obfuscatedSteps,
@@ -410,11 +410,11 @@ export var DocumentService = /*#__PURE__*/function () {
410
410
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
411
411
  _this.applyLocalSteps(unconfirmedSteps);
412
412
  }
413
- _context3.next = 34;
413
+ _context3.next = 9;
414
414
  break;
415
- case 18:
416
- _context3.prev = 18;
417
- _context3.t0 = _context3["catch"](13);
415
+ case 5:
416
+ _context3.prev = 5;
417
+ _t3 = _context3["catch"](4);
418
418
  // Extract generatedSteps from fetchReconcile response
419
419
  // and apply them to the editor state.
420
420
  _this.onErrorHandled({
@@ -427,10 +427,10 @@ export var DocumentService = /*#__PURE__*/function () {
427
427
  }
428
428
  });
429
429
  useReconcile = false;
430
- _context3.prev = 22;
431
- _context3.next = 25;
430
+ _context3.prev = 6;
431
+ _context3.next = 7;
432
432
  return _this.fetchGeneratedDiffSteps(JSON.stringify(currentState.content), 'fe-restore-fetch-generated-steps');
433
- case 25:
433
+ case 7:
434
434
  generatedDiffStepsResponse = _context3.sent;
435
435
  generatedSteps = generatedDiffStepsResponse.generatedSteps;
436
436
  state = (_this$getState5 = _this.getState) === null || _this$getState5 === void 0 ? void 0 : _this$getState5.call(_this);
@@ -449,13 +449,13 @@ export var DocumentService = /*#__PURE__*/function () {
449
449
  });
450
450
  }
451
451
  }
452
- _context3.next = 34;
452
+ _context3.next = 9;
453
453
  break;
454
- case 31:
455
- _context3.prev = 31;
456
- _context3.t1 = _context3["catch"](22);
457
- (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t1, "Error fetchGeneratedDiffSteps with steps-only mode");
458
- case 34:
454
+ case 8:
455
+ _context3.prev = 8;
456
+ _t4 = _context3["catch"](6);
457
+ (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_t4, "Error fetchGeneratedDiffSteps with steps-only mode");
458
+ case 9:
459
459
  (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
460
460
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
461
461
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
@@ -464,11 +464,11 @@ export var DocumentService = /*#__PURE__*/function () {
464
464
  targetClientId: targetClientId,
465
465
  triggeredByCatchup: !!targetClientId
466
466
  });
467
- _context3.next = 42;
467
+ _context3.next = 11;
468
468
  break;
469
- case 37:
470
- _context3.prev = 37;
471
- _context3.t2 = _context3["catch"](10);
469
+ case 10:
470
+ _context3.prev = 10;
471
+ _t5 = _context3["catch"](3);
472
472
  (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
473
473
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
474
474
  useReconcile: useReconcile,
@@ -476,7 +476,7 @@ export var DocumentService = /*#__PURE__*/function () {
476
476
  targetClientId: targetClientId,
477
477
  triggeredByCatchup: !!targetClientId
478
478
  });
479
- (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_context3.t2, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
479
+ (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_t5, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
480
480
  _this.onErrorHandled({
481
481
  message: 'Caught error while trying to recover the document',
482
482
  data: {
@@ -485,11 +485,11 @@ export var DocumentService = /*#__PURE__*/function () {
485
485
  code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
486
486
  }
487
487
  });
488
- case 42:
488
+ case 11:
489
489
  case "end":
490
490
  return _context3.stop();
491
491
  }
492
- }, _callee3, null, [[10, 37], [13, 18], [22, 31]]);
492
+ }, _callee3, null, [[3, 10], [4, 5], [6, 8]]);
493
493
  }));
494
494
  return function (_x4) {
495
495
  return _ref7.apply(this, arguments);
@@ -497,61 +497,61 @@ export var DocumentService = /*#__PURE__*/function () {
497
497
  }());
498
498
  _defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/function () {
499
499
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(reason) {
500
- var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2;
501
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
500
+ var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2, _t6, _t7;
501
+ return _regeneratorRuntime.wrap(function (_context4) {
502
502
  while (1) switch (_context4.prev = _context4.next) {
503
503
  case 0:
504
504
  _this.aggressiveCatchup = true;
505
505
  _context4.prev = 1;
506
506
  startMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
507
- _context4.prev = 3;
508
- _context4.next = 6;
507
+ _context4.prev = 2;
508
+ _context4.next = 3;
509
509
  return _this.commitUnconfirmedSteps(reason);
510
- case 6:
511
- _context4.next = 8;
510
+ case 3:
511
+ _context4.next = 4;
512
512
  return _this.getCurrentState();
513
- case 8:
513
+ case 4:
514
514
  finalAcknowledgedState = _context4.sent;
515
- _context4.next = 20;
515
+ _context4.next = 8;
516
516
  break;
517
- case 11:
518
- _context4.prev = 11;
519
- _context4.t0 = _context4["catch"](3);
520
- _context4.next = 15;
517
+ case 5:
518
+ _context4.prev = 5;
519
+ _t6 = _context4["catch"](2);
520
+ _context4.next = 6;
521
521
  return _this.getCurrentState();
522
- case 15:
522
+ case 6:
523
523
  currentState = _context4.sent;
524
- _context4.next = 18;
524
+ _context4.next = 7;
525
525
  return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-final-ack');
526
- case 18:
526
+ case 7:
527
527
  reconcileResponse = _context4.sent;
528
528
  finalAcknowledgedState = {
529
529
  content: JSON.parse(reconcileResponse.document),
530
530
  title: currentState.title,
531
531
  stepVersion: reconcileResponse.version
532
532
  };
533
- case 20:
533
+ case 8:
534
534
  measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
535
535
  (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
536
536
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
537
537
  });
538
538
  _this.aggressiveCatchup = false;
539
539
  return _context4.abrupt("return", finalAcknowledgedState);
540
- case 26:
541
- _context4.prev = 26;
542
- _context4.t1 = _context4["catch"](1);
540
+ case 9:
541
+ _context4.prev = 9;
542
+ _t7 = _context4["catch"](1);
543
543
  _this.aggressiveCatchup = false;
544
544
  _measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
545
545
  (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
546
546
  latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
547
547
  });
548
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
549
- throw _context4.t1;
550
- case 33:
548
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_t7, 'Error while returning ADF version of the final draft document');
549
+ throw _t7;
550
+ case 10:
551
551
  case "end":
552
552
  return _context4.stop();
553
553
  }
554
- }, _callee4, null, [[1, 26], [3, 11]]);
554
+ }, _callee4, null, [[1, 9], [2, 5]]);
555
555
  }));
556
556
  return function (_x5) {
557
557
  return _ref8.apply(this, arguments);
@@ -653,14 +653,14 @@ export var DocumentService = /*#__PURE__*/function () {
653
653
  */
654
654
  _defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/function () {
655
655
  var _ref0 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(reason) {
656
- var unconfirmedSteps, _this$getState7, _this$analyticsHelper25, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper24, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper26, _this$analyticsHelper27, _measure3;
657
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
656
+ var unconfirmedSteps, _this$getState7, _this$analyticsHelper25, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper24, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper26, _this$analyticsHelper27, _measure3, _t8;
657
+ return _regeneratorRuntime.wrap(function (_context5) {
658
658
  while (1) switch (_context5.prev = _context5.next) {
659
659
  case 0:
660
660
  unconfirmedSteps = _this.getUnconfirmedSteps();
661
661
  _context5.prev = 1;
662
662
  if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
663
- _context5.next = 24;
663
+ _context5.next = 6;
664
664
  break;
665
665
  }
666
666
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
@@ -674,16 +674,16 @@ export var DocumentService = /*#__PURE__*/function () {
674
674
  if (!((_this$getState7 = _this.getState) !== null && _this$getState7 !== void 0 && _this$getState7.call(_this))) {
675
675
  (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
676
676
  }
677
- case 9:
677
+ case 2:
678
678
  if (isLastTrConfirmed) {
679
- _context5.next = 22;
679
+ _context5.next = 5;
680
680
  break;
681
681
  }
682
682
  // this makes all commitUnconfirmedSteps skip the waiting time, which means draft-sync is sped up too.
683
683
  _this.sendStepsFromCurrentState(undefined, 'publish');
684
- _context5.next = 13;
684
+ _context5.next = 3;
685
685
  return sleep(500);
686
- case 13:
686
+ case 3:
687
687
  nextUnconfirmedSteps = _this.getUnconfirmedSteps();
688
688
  if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
689
689
  nextUnconfirmedTrs = _this.getUnconfirmedStepsOrigins();
@@ -694,7 +694,7 @@ export var DocumentService = /*#__PURE__*/function () {
694
694
  isLastTrConfirmed = true;
695
695
  }
696
696
  if (!(!isLastTrConfirmed && count++ >= ACK_MAX_TRY)) {
697
- _context5.next = 20;
697
+ _context5.next = 4;
698
698
  break;
699
699
  }
700
700
  if (_this.onSyncUpError) {
@@ -717,34 +717,34 @@ export var DocumentService = /*#__PURE__*/function () {
717
717
  unconfirmedStepsInfo: unconfirmedStepsInfoUGCRemoved ? JSON.stringify(unconfirmedStepsInfoUGCRemoved) : 'Unable to generate UGC removed step info'
718
718
  });
719
719
  throw error;
720
- case 20:
721
- _context5.next = 9;
720
+ case 4:
721
+ _context5.next = 2;
722
722
  break;
723
- case 22:
723
+ case 5:
724
724
  measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
725
725
  (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
726
726
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
727
727
  // upon success, emit the total number of unconfirmed steps we synced
728
728
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
729
729
  });
730
- case 24:
731
- _context5.next = 32;
730
+ case 6:
731
+ _context5.next = 8;
732
732
  break;
733
- case 26:
734
- _context5.prev = 26;
735
- _context5.t0 = _context5["catch"](1);
733
+ case 7:
734
+ _context5.prev = 7;
735
+ _t8 = _context5["catch"](1);
736
736
  _measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
737
737
  (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
738
738
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
739
739
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
740
740
  });
741
- (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
742
- throw _context5.t0;
743
- case 32:
741
+ (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_t8, 'Error while committing unconfirmed steps');
742
+ throw _t8;
743
+ case 8:
744
744
  case "end":
745
745
  return _context5.stop();
746
746
  }
747
- }, _callee5, null, [[1, 26]]);
747
+ }, _callee5, null, [[1, 7]]);
748
748
  }));
749
749
  return function (_x6) {
750
750
  return _ref0.apply(this, arguments);
@@ -210,8 +210,8 @@ export function logObfuscatedSteps(_x, _x2) {
210
210
  }
211
211
  function _logObfuscatedSteps() {
212
212
  _logObfuscatedSteps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(oldState, newState) {
213
- var _states$new, _states$old, stepsFromOldState, stepsFromNewState, states;
214
- return _regeneratorRuntime.wrap(function _callee$(_context) {
213
+ var _states$new, _states$old, stepsFromOldState, stepsFromNewState, states, _t;
214
+ return _regeneratorRuntime.wrap(function (_context) {
215
215
  while (1) switch (_context.prev = _context.next) {
216
216
  case 0:
217
217
  _context.prev = 0;
@@ -221,36 +221,36 @@ function _logObfuscatedSteps() {
221
221
  new: sendableSteps(newState)
222
222
  };
223
223
  if (!((_states$new = states.new) !== null && _states$new !== void 0 && _states$new.steps)) {
224
- _context.next = 7;
224
+ _context.next = 2;
225
225
  break;
226
226
  }
227
- _context.next = 6;
227
+ _context.next = 1;
228
228
  return toObfuscatedSteps(states.new.steps);
229
- case 6:
229
+ case 1:
230
230
  stepsFromNewState = _context.sent;
231
- case 7:
231
+ case 2:
232
232
  if (!((_states$old = states.old) !== null && _states$old !== void 0 && _states$old.steps)) {
233
- _context.next = 11;
233
+ _context.next = 4;
234
234
  break;
235
235
  }
236
- _context.next = 10;
236
+ _context.next = 3;
237
237
  return toObfuscatedSteps(states.old.steps);
238
- case 10:
238
+ case 3:
239
239
  stepsFromOldState = _context.sent;
240
- case 11:
240
+ case 4:
241
241
  return _context.abrupt("return", {
242
242
  stepsFromOldState: stepsFromOldState,
243
243
  stepsFromNewState: stepsFromNewState
244
244
  });
245
- case 14:
246
- _context.prev = 14;
247
- _context.t0 = _context["catch"](0);
248
- return _context.abrupt("return", new CustomError('Failed to obfuscate steps', _context.t0));
249
- case 17:
245
+ case 5:
246
+ _context.prev = 5;
247
+ _t = _context["catch"](0);
248
+ return _context.abrupt("return", new CustomError('Failed to obfuscate steps', _t));
249
+ case 6:
250
250
  case "end":
251
251
  return _context.stop();
252
252
  }
253
- }, _callee, null, [[0, 14]]);
253
+ }, _callee, null, [[0, 5]]);
254
254
  }));
255
255
  return _logObfuscatedSteps.apply(this, arguments);
256
256
  }
@@ -267,17 +267,17 @@ export function toObfuscatedSteps(_x3) {
267
267
  function _toObfuscatedSteps() {
268
268
  _toObfuscatedSteps = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(steps) {
269
269
  var _steps;
270
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
270
+ return _regeneratorRuntime.wrap(function (_context2) {
271
271
  while (1) switch (_context2.prev = _context2.next) {
272
272
  case 0:
273
- _context2.next = 2;
273
+ _context2.next = 1;
274
274
  return Promise.resolve(steps.slice().map(function (s) {
275
275
  return s.toJSON();
276
276
  }));
277
- case 2:
277
+ case 1:
278
278
  _steps = _context2.sent;
279
279
  return _context2.abrupt("return", JSON.stringify(getObfuscatedSteps(_steps)));
280
- case 4:
280
+ case 2:
281
281
  case "end":
282
282
  return _context2.stop();
283
283
  }
@@ -26,7 +26,7 @@ export var NamespaceService = /*#__PURE__*/_createClass(function NamespaceServic
26
26
  _defineProperty(this, "onNamespaceStatusChanged", /*#__PURE__*/function () {
27
27
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
28
28
  var isLocked, waitTimeInMs, timestamp, start;
29
- return _regeneratorRuntime.wrap(function _callee$(_context) {
29
+ return _regeneratorRuntime.wrap(function (_context) {
30
30
  while (1) switch (_context.prev = _context.next) {
31
31
  case 0:
32
32
  isLocked = _ref.isLocked, waitTimeInMs = _ref.waitTimeInMs, timestamp = _ref.timestamp;
@@ -37,7 +37,7 @@ export var NamespaceService = /*#__PURE__*/_createClass(function NamespaceServic
37
37
  timestamp: timestamp
38
38
  });
39
39
  if (!(isLocked && waitTimeInMs)) {
40
- _context.next = 8;
40
+ _context.next = 1;
41
41
  break;
42
42
  }
43
43
  _this.isNamespaceLocked = true;
@@ -54,10 +54,10 @@ export var NamespaceService = /*#__PURE__*/_createClass(function NamespaceServic
54
54
  _this.isNamespaceLocked = false;
55
55
  }, waitTimeInMs);
56
56
  return _context.abrupt("return");
57
- case 8:
57
+ case 1:
58
58
  _this.isNamespaceLocked = false;
59
59
  logger("The page lock has expired");
60
- case 10:
60
+ case 2:
61
61
  case "end":
62
62
  return _context.stop();
63
63
  }
@@ -9,13 +9,13 @@ var DEFAULT_BATCH_FETCH_SIZE = 25;
9
9
  export var createParticipantFromPayload = /*#__PURE__*/function () {
10
10
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(payload, getUser) {
11
11
  var sessionId, timestamp, clientId, userId, permit, presenceId, presenceActivity, user, participant;
12
- return _regeneratorRuntime.wrap(function _callee$(_context) {
12
+ return _regeneratorRuntime.wrap(function (_context) {
13
13
  while (1) switch (_context.prev = _context.next) {
14
14
  case 0:
15
15
  sessionId = payload.sessionId, timestamp = payload.timestamp, clientId = payload.clientId, userId = payload.userId, permit = payload.permit, presenceId = payload.presenceId, presenceActivity = payload.presenceActivity;
16
- _context.next = 3;
16
+ _context.next = 1;
17
17
  return getUser === null || getUser === void 0 ? void 0 : getUser(userId);
18
- case 3:
18
+ case 1:
19
19
  user = _context.sent;
20
20
  participant = {
21
21
  name: (user === null || user === void 0 ? void 0 : user.name) || '',
@@ -32,7 +32,7 @@ export var createParticipantFromPayload = /*#__PURE__*/function () {
32
32
  isHydrated: !!user
33
33
  };
34
34
  return _context.abrupt("return", participant);
35
- case 6:
35
+ case 2:
36
36
  case "end":
37
37
  return _context.stop();
38
38
  }
@@ -58,7 +58,7 @@ export var createParticipantFromPayload = /*#__PURE__*/function () {
58
58
  export var fetchParticipants = /*#__PURE__*/function () {
59
59
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(participantsState, batchProps) {
60
60
  var _batchProps$batchSize, batchSize, getUsers, participantsToHydrate, participants, aaids, users, hydratedParticipants;
61
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
61
+ return _regeneratorRuntime.wrap(function (_context2) {
62
62
  while (1) switch (_context2.prev = _context2.next) {
63
63
  case 0:
64
64
  _batchProps$batchSize = batchProps.batchSize, batchSize = _batchProps$batchSize === void 0 ? DEFAULT_BATCH_FETCH_SIZE : _batchProps$batchSize, getUsers = batchProps.getUsers;
@@ -67,18 +67,18 @@ export var fetchParticipants = /*#__PURE__*/function () {
67
67
  });
68
68
  participants = participantsToHydrate.splice(0, batchSize);
69
69
  if (participants.length) {
70
- _context2.next = 5;
70
+ _context2.next = 1;
71
71
  break;
72
72
  }
73
73
  return _context2.abrupt("return", []);
74
- case 5:
74
+ case 1:
75
75
  aaids = new Set();
76
76
  participants.forEach(function (p) {
77
77
  aaids.add(p.userId);
78
78
  });
79
- _context2.next = 9;
79
+ _context2.next = 2;
80
80
  return getUsers === null || getUsers === void 0 ? void 0 : getUsers(_toConsumableArray(aaids.values()));
81
- case 9:
81
+ case 2:
82
82
  users = _context2.sent;
83
83
  hydratedParticipants = [];
84
84
  users === null || users === void 0 || users.forEach(function (user) {
@@ -106,7 +106,7 @@ export var fetchParticipants = /*#__PURE__*/function () {
106
106
  });
107
107
  });
108
108
  return _context2.abrupt("return", hydratedParticipants);
109
- case 13:
109
+ case 3:
110
110
  case "end":
111
111
  return _context2.stop();
112
112
  }