@atlaskit/collab-provider 10.2.0 → 10.2.2
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/CHANGELOG.md +16 -0
- package/dist/cjs/document/document-service.js +74 -47
- package/dist/cjs/provider/index.js +5 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/document-service.js +67 -46
- package/dist/es2019/provider/index.js +5 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/document/document-service.js +74 -47
- package/dist/esm/provider/index.js +5 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +1 -2
- package/dist/types-ts4.5/document/document-service.d.ts +1 -2
- package/package.json +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 10.2.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#177897](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/177897)
|
|
8
|
+
[`f2e0ea2ac3c20`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f2e0ea2ac3c20) -
|
|
9
|
+
FF restore_localstep_fallback_reconcile to handle offline user onRestoredocument with
|
|
10
|
+
applyLocalSteps and fallback using fetchReoncile
|
|
11
|
+
- Updated dependencies
|
|
12
|
+
|
|
13
|
+
## 10.2.1
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
|
|
3
19
|
## 10.2.0
|
|
4
20
|
|
|
5
21
|
### Minor Changes
|
|
@@ -10,6 +10,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
10
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
12
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
var _const = require("../helpers/const");
|
|
14
15
|
var _prosemirrorCollab = require("@atlaskit/prosemirror-collab");
|
|
15
16
|
var _editorJsonTransformer = require("@atlaskit/editor-json-transformer");
|
|
@@ -284,7 +285,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
284
285
|
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
285
286
|
(0, _defineProperty2.default)(this, "onRestore", /*#__PURE__*/function () {
|
|
286
287
|
var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref6) {
|
|
287
|
-
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper12, _this$analyticsHelper13, _this$
|
|
288
|
+
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper14, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper15, _this$analyticsHelper16;
|
|
288
289
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
289
290
|
while (1) switch (_context3.prev = _context3.next) {
|
|
290
291
|
case 0:
|
|
@@ -317,25 +318,51 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
317
318
|
reserveCursor: true
|
|
318
319
|
});
|
|
319
320
|
_this.metadataService.updateMetadata(metadata);
|
|
320
|
-
|
|
321
|
-
|
|
321
|
+
if (!(0, _platformFeatureFlags.fg)('restore_localstep_fallback_reconcile')) {
|
|
322
|
+
_context3.next = 25;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
_context3.prev = 12;
|
|
326
|
+
(_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.INFO, {
|
|
327
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
328
|
+
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
329
|
+
clientId: _this.clientId,
|
|
330
|
+
targetClientId: targetClientId,
|
|
331
|
+
triggeredByCatchup: targetClientId ? true : false
|
|
332
|
+
});
|
|
333
|
+
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
334
|
+
_this.applyLocalSteps(unconfirmedSteps);
|
|
335
|
+
}
|
|
336
|
+
_context3.next = 23;
|
|
337
|
+
break;
|
|
338
|
+
case 17:
|
|
339
|
+
_context3.prev = 17;
|
|
340
|
+
_context3.t0 = _context3["catch"](12);
|
|
341
|
+
(_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
|
|
342
|
+
useReconcile = true;
|
|
343
|
+
_context3.next = 23;
|
|
344
|
+
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
345
|
+
case 23:
|
|
346
|
+
_context3.next = 31;
|
|
347
|
+
break;
|
|
348
|
+
case 25:
|
|
322
349
|
if (!(useReconcile && currentState)) {
|
|
323
|
-
_context3.next =
|
|
350
|
+
_context3.next = 30;
|
|
324
351
|
break;
|
|
325
352
|
}
|
|
326
|
-
_context3.next =
|
|
353
|
+
_context3.next = 28;
|
|
327
354
|
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
328
|
-
case
|
|
329
|
-
_context3.next =
|
|
355
|
+
case 28:
|
|
356
|
+
_context3.next = 31;
|
|
330
357
|
break;
|
|
331
|
-
case
|
|
358
|
+
case 30:
|
|
332
359
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
333
360
|
// we don't want to use reconcile for restore triggered by catchup client out of sync (when targetClientId is provided)
|
|
334
361
|
// as this results in all changes made while the client was out of sync being lost
|
|
335
362
|
_this.applyLocalSteps(unconfirmedSteps);
|
|
336
363
|
}
|
|
337
|
-
case
|
|
338
|
-
(_this$
|
|
364
|
+
case 31:
|
|
365
|
+
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
|
|
339
366
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
340
367
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
341
368
|
useReconcile: useReconcile,
|
|
@@ -343,19 +370,19 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
343
370
|
targetClientId: targetClientId,
|
|
344
371
|
triggeredByCatchup: targetClientId ? true : false
|
|
345
372
|
});
|
|
346
|
-
_context3.next =
|
|
373
|
+
_context3.next = 39;
|
|
347
374
|
break;
|
|
348
|
-
case
|
|
349
|
-
_context3.prev =
|
|
350
|
-
_context3.
|
|
351
|
-
(_this$
|
|
375
|
+
case 34:
|
|
376
|
+
_context3.prev = 34;
|
|
377
|
+
_context3.t1 = _context3["catch"](8);
|
|
378
|
+
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
|
|
352
379
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
353
380
|
useReconcile: useReconcile,
|
|
354
381
|
clientId: _this.clientId,
|
|
355
382
|
targetClientId: targetClientId,
|
|
356
383
|
triggeredByCatchup: targetClientId ? true : false
|
|
357
384
|
});
|
|
358
|
-
(_this$
|
|
385
|
+
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(_context3.t1, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
|
|
359
386
|
_this.onErrorHandled({
|
|
360
387
|
message: 'Caught error while trying to recover the document',
|
|
361
388
|
data: {
|
|
@@ -364,18 +391,18 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
364
391
|
code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
|
|
365
392
|
}
|
|
366
393
|
});
|
|
367
|
-
case
|
|
394
|
+
case 39:
|
|
368
395
|
case "end":
|
|
369
396
|
return _context3.stop();
|
|
370
397
|
}
|
|
371
|
-
}, _callee3, null, [[8,
|
|
398
|
+
}, _callee3, null, [[8, 34], [12, 17]]);
|
|
372
399
|
}));
|
|
373
400
|
return function (_x2) {
|
|
374
401
|
return _ref7.apply(this, arguments);
|
|
375
402
|
};
|
|
376
403
|
}());
|
|
377
404
|
(0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
378
|
-
var _this$
|
|
405
|
+
var _this$analyticsHelper17, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper18, _this$analyticsHelper19, _measure2;
|
|
379
406
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
380
407
|
while (1) switch (_context4.prev = _context4.next) {
|
|
381
408
|
case 0:
|
|
@@ -410,7 +437,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
410
437
|
};
|
|
411
438
|
case 20:
|
|
412
439
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
413
|
-
(_this$
|
|
440
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
|
|
414
441
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
415
442
|
});
|
|
416
443
|
_this.aggressiveCatchup = false;
|
|
@@ -420,10 +447,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
420
447
|
_context4.t1 = _context4["catch"](1);
|
|
421
448
|
_this.aggressiveCatchup = false;
|
|
422
449
|
_measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
423
|
-
(_this$
|
|
450
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
|
|
424
451
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
425
452
|
});
|
|
426
|
-
(_this$
|
|
453
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
|
|
427
454
|
throw _context4.t1;
|
|
428
455
|
case 33:
|
|
429
456
|
case "end":
|
|
@@ -451,7 +478,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
451
478
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
452
479
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
453
480
|
if (updatedVersion < version) {
|
|
454
|
-
var _doc$content, _this$
|
|
481
|
+
var _doc$content, _this$analyticsHelper20;
|
|
455
482
|
var error = new _customErrors.UpdateDocumentError('Failed to update the document', {
|
|
456
483
|
newVersion: version,
|
|
457
484
|
editorVersion: updatedVersion,
|
|
@@ -459,7 +486,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
459
486
|
docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
|
|
460
487
|
isDocContentValid: isDocContentValid
|
|
461
488
|
});
|
|
462
|
-
(_this$
|
|
489
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
463
490
|
if (_this.enableErrorOnFailedDocumentApply) {
|
|
464
491
|
_this.onErrorHandled({
|
|
465
492
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -476,8 +503,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
476
503
|
}
|
|
477
504
|
// Otherwise just fail silently for now
|
|
478
505
|
} else {
|
|
479
|
-
var _this$
|
|
480
|
-
(_this$
|
|
506
|
+
var _this$analyticsHelper21, _doc$content2;
|
|
507
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
|
|
481
508
|
newVersion: version,
|
|
482
509
|
editorVersion: updatedVersion,
|
|
483
510
|
isDocTruthy: !!doc,
|
|
@@ -490,8 +517,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
490
517
|
try {
|
|
491
518
|
var _this$getState5;
|
|
492
519
|
if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
|
|
493
|
-
var _this$
|
|
494
|
-
(_this$
|
|
520
|
+
var _this$analyticsHelper22;
|
|
521
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
495
522
|
}
|
|
496
523
|
var state = _this.getState();
|
|
497
524
|
var content = (doc.content || []).map(function (child) {
|
|
@@ -514,7 +541,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
514
541
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
515
542
|
*/
|
|
516
543
|
(0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
|
|
517
|
-
var unconfirmedSteps, _this$getState6, _this$
|
|
544
|
+
var unconfirmedSteps, _this$getState6, _this$analyticsHelper24, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper23, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper25, _this$analyticsHelper26, _measure3;
|
|
518
545
|
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
519
546
|
while (1) switch (_context5.prev = _context5.next) {
|
|
520
547
|
case 0:
|
|
@@ -533,7 +560,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
533
560
|
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
534
561
|
isLastTrConfirmed = false;
|
|
535
562
|
if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
|
|
536
|
-
(_this$
|
|
563
|
+
(_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
537
564
|
}
|
|
538
565
|
case 9:
|
|
539
566
|
if (isLastTrConfirmed) {
|
|
@@ -580,7 +607,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
580
607
|
break;
|
|
581
608
|
case 22:
|
|
582
609
|
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
583
|
-
(_this$
|
|
610
|
+
(_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
|
|
584
611
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
585
612
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
586
613
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
@@ -592,11 +619,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
592
619
|
_context5.prev = 26;
|
|
593
620
|
_context5.t0 = _context5["catch"](1);
|
|
594
621
|
_measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
595
|
-
(_this$
|
|
622
|
+
(_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
|
|
596
623
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
597
624
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
598
625
|
});
|
|
599
|
-
(_this$
|
|
626
|
+
(_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
|
|
600
627
|
throw _context5.t0;
|
|
601
628
|
case 32:
|
|
602
629
|
case "end":
|
|
@@ -605,17 +632,17 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
605
632
|
}, _callee5, null, [[1, 26]]);
|
|
606
633
|
})));
|
|
607
634
|
(0, _defineProperty2.default)(this, "onStepRejectedError", function () {
|
|
608
|
-
var _this$
|
|
635
|
+
var _this$analyticsHelper27;
|
|
609
636
|
_this.stepRejectCounter++;
|
|
610
637
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
611
|
-
(_this$
|
|
638
|
+
(_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
|
|
612
639
|
count: _this.stepRejectCounter
|
|
613
640
|
});
|
|
614
641
|
var maxRetries = _this.aggressiveCatchup ? _provider.MAX_STEP_REJECTED_ERROR_AGGRESSIVE : _provider.MAX_STEP_REJECTED_ERROR;
|
|
615
642
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
616
|
-
var _this$
|
|
643
|
+
var _this$analyticsHelper28;
|
|
617
644
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
618
|
-
(_this$
|
|
645
|
+
(_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
|
|
619
646
|
_this.throttledCatchupv2(_const.CatchupEventReason.STEPS_REJECTED);
|
|
620
647
|
} else {
|
|
621
648
|
// If committing steps failed try again automatically in 1s
|
|
@@ -646,15 +673,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
646
673
|
value: function getVersionFromCollabState(state, resource) {
|
|
647
674
|
var collabState = (0, _prosemirrorCollab.getCollabState)(state);
|
|
648
675
|
if (!collabState) {
|
|
649
|
-
var _this$
|
|
650
|
-
(_this$
|
|
676
|
+
var _this$analyticsHelper29;
|
|
677
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
651
678
|
return 0;
|
|
652
679
|
}
|
|
653
680
|
|
|
654
681
|
// This should not happen in usual, just add error event in case it happens
|
|
655
682
|
if (collabState.version === undefined) {
|
|
656
|
-
var _this$
|
|
657
|
-
(_this$
|
|
683
|
+
var _this$analyticsHelper30;
|
|
684
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
658
685
|
return 0;
|
|
659
686
|
}
|
|
660
687
|
return collabState.version;
|
|
@@ -708,11 +735,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
708
735
|
}, 100);
|
|
709
736
|
}
|
|
710
737
|
} catch (error) {
|
|
711
|
-
var _this$
|
|
738
|
+
var _this$analyticsHelper31;
|
|
712
739
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
713
740
|
var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
714
741
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
715
|
-
(_this$
|
|
742
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
|
|
716
743
|
this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
|
|
717
744
|
}
|
|
718
745
|
}
|
|
@@ -747,8 +774,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
747
774
|
var _this$getState7;
|
|
748
775
|
var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
749
776
|
if (!state) {
|
|
750
|
-
var _this$
|
|
751
|
-
(_this$
|
|
777
|
+
var _this$analyticsHelper32;
|
|
778
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
752
779
|
return;
|
|
753
780
|
}
|
|
754
781
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -773,8 +800,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
|
|
|
773
800
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
774
801
|
// sent once on connection (as opposed to on every step)
|
|
775
802
|
if (sendAnalyticsEvent) {
|
|
776
|
-
var _this$
|
|
777
|
-
(_this$
|
|
803
|
+
var _this$analyticsHelper33;
|
|
804
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
|
|
778
805
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
779
806
|
});
|
|
780
807
|
}
|
|
@@ -328,6 +328,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
328
328
|
(0, _createClass2.default)(Provider, [{
|
|
329
329
|
key: "initialize",
|
|
330
330
|
value:
|
|
331
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
331
332
|
/**
|
|
332
333
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
333
334
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -531,6 +532,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
531
532
|
return this.unsubscribeAll();
|
|
532
533
|
}
|
|
533
534
|
|
|
535
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
534
536
|
/**
|
|
535
537
|
* Disconnect the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
536
538
|
* Used by Confluence to disable the provider when a user doesn't have access to a resource.
|
|
@@ -543,6 +545,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
543
545
|
return this.unsubscribeAll();
|
|
544
546
|
}
|
|
545
547
|
|
|
548
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
546
549
|
/**
|
|
547
550
|
* Disconnect the provider's connection to the back-end service and unsubscribe from all events emitted by this provider. Kept to keep roughly aligned to Synchrony API, which you need to call for each event.
|
|
548
551
|
* @deprecated use destroy instead, it does the same thing
|
|
@@ -567,6 +570,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
567
570
|
return this;
|
|
568
571
|
}
|
|
569
572
|
|
|
573
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
570
574
|
/**
|
|
571
575
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
572
576
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -589,6 +593,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
589
593
|
}
|
|
590
594
|
}
|
|
591
595
|
|
|
596
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
592
597
|
/**
|
|
593
598
|
* Set editor width, not used any more
|
|
594
599
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/collab-provider";
|
|
8
|
-
var version = exports.version = "10.2.
|
|
8
|
+
var version = exports.version = "10.2.2";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
3
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
3
4
|
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
4
5
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
@@ -264,9 +265,9 @@ export class DocumentService {
|
|
|
264
265
|
// We can then reconcile the document with the preserved state.
|
|
265
266
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
266
267
|
const currentState = await this.getCurrentState();
|
|
267
|
-
|
|
268
|
+
let useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
|
|
268
269
|
try {
|
|
269
|
-
var _this$
|
|
270
|
+
var _this$analyticsHelper14;
|
|
270
271
|
// Reset the editor,
|
|
271
272
|
// - Replace the document, keep in sync with the server
|
|
272
273
|
// - Replace the version number, so editor is in sync with NCS server and can commit new changes.
|
|
@@ -280,16 +281,36 @@ export class DocumentService {
|
|
|
280
281
|
reserveCursor: true
|
|
281
282
|
});
|
|
282
283
|
this.metadataService.updateMetadata(metadata);
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
284
|
+
if (fg('restore_localstep_fallback_reconcile')) {
|
|
285
|
+
try {
|
|
286
|
+
var _this$analyticsHelper12;
|
|
287
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
288
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
289
|
+
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
290
|
+
clientId: this.clientId,
|
|
291
|
+
targetClientId,
|
|
292
|
+
triggeredByCatchup: targetClientId ? true : false
|
|
293
|
+
});
|
|
294
|
+
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
295
|
+
this.applyLocalSteps(unconfirmedSteps);
|
|
296
|
+
}
|
|
297
|
+
} catch (applyLocalStepsError) {
|
|
298
|
+
var _this$analyticsHelper13;
|
|
299
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(applyLocalStepsError, `Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile`);
|
|
300
|
+
useReconcile = true;
|
|
301
|
+
await this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
302
|
+
}
|
|
303
|
+
} else {
|
|
304
|
+
// If there are unconfirmed steps, attempt to reconcile our current state with with recovered document
|
|
305
|
+
if (useReconcile && currentState) {
|
|
306
|
+
await this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
307
|
+
} else if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
308
|
+
// we don't want to use reconcile for restore triggered by catchup client out of sync (when targetClientId is provided)
|
|
309
|
+
// as this results in all changes made while the client was out of sync being lost
|
|
310
|
+
this.applyLocalSteps(unconfirmedSteps);
|
|
311
|
+
}
|
|
291
312
|
}
|
|
292
|
-
(_this$
|
|
313
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
293
314
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
294
315
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
295
316
|
useReconcile,
|
|
@@ -298,15 +319,15 @@ export class DocumentService {
|
|
|
298
319
|
triggeredByCatchup: targetClientId ? true : false
|
|
299
320
|
});
|
|
300
321
|
} catch (restoreError) {
|
|
301
|
-
var _this$
|
|
302
|
-
(_this$
|
|
322
|
+
var _this$analyticsHelper15, _this$analyticsHelper16;
|
|
323
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
303
324
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
304
325
|
useReconcile,
|
|
305
326
|
clientId: this.clientId,
|
|
306
327
|
targetClientId,
|
|
307
328
|
triggeredByCatchup: targetClientId ? true : false
|
|
308
329
|
});
|
|
309
|
-
(_this$
|
|
330
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
|
|
310
331
|
this.onErrorHandled({
|
|
311
332
|
message: 'Caught error while trying to recover the document',
|
|
312
333
|
data: {
|
|
@@ -320,7 +341,7 @@ export class DocumentService {
|
|
|
320
341
|
_defineProperty(this, "getFinalAcknowledgedState", async () => {
|
|
321
342
|
this.aggressiveCatchup = true;
|
|
322
343
|
try {
|
|
323
|
-
var _this$
|
|
344
|
+
var _this$analyticsHelper17;
|
|
324
345
|
startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
325
346
|
let finalAcknowledgedState;
|
|
326
347
|
try {
|
|
@@ -337,19 +358,19 @@ export class DocumentService {
|
|
|
337
358
|
};
|
|
338
359
|
}
|
|
339
360
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
340
|
-
(_this$
|
|
361
|
+
(_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
341
362
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
342
363
|
});
|
|
343
364
|
this.aggressiveCatchup = false;
|
|
344
365
|
return finalAcknowledgedState;
|
|
345
366
|
} catch (error) {
|
|
346
|
-
var _this$
|
|
367
|
+
var _this$analyticsHelper18, _this$analyticsHelper19;
|
|
347
368
|
this.aggressiveCatchup = false;
|
|
348
369
|
const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
|
|
349
|
-
(_this$
|
|
370
|
+
(_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
350
371
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
351
372
|
});
|
|
352
|
-
(_this$
|
|
373
|
+
(_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
|
|
353
374
|
throw error; // Reject the promise so the consumer can react to it failing
|
|
354
375
|
}
|
|
355
376
|
});
|
|
@@ -375,7 +396,7 @@ export class DocumentService {
|
|
|
375
396
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
376
397
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
377
398
|
if (updatedVersion < version) {
|
|
378
|
-
var _doc$content, _this$
|
|
399
|
+
var _doc$content, _this$analyticsHelper20;
|
|
379
400
|
const error = new UpdateDocumentError('Failed to update the document', {
|
|
380
401
|
newVersion: version,
|
|
381
402
|
editorVersion: updatedVersion,
|
|
@@ -383,7 +404,7 @@ export class DocumentService {
|
|
|
383
404
|
docHasContent: (doc === null || doc === void 0 ? void 0 : (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
|
|
384
405
|
isDocContentValid
|
|
385
406
|
});
|
|
386
|
-
(_this$
|
|
407
|
+
(_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
387
408
|
if (this.enableErrorOnFailedDocumentApply) {
|
|
388
409
|
this.onErrorHandled({
|
|
389
410
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -400,8 +421,8 @@ export class DocumentService {
|
|
|
400
421
|
}
|
|
401
422
|
// Otherwise just fail silently for now
|
|
402
423
|
} else {
|
|
403
|
-
var _this$
|
|
404
|
-
(_this$
|
|
424
|
+
var _this$analyticsHelper21, _doc$content2;
|
|
425
|
+
(_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
405
426
|
newVersion: version,
|
|
406
427
|
editorVersion: updatedVersion,
|
|
407
428
|
isDocTruthy: !!doc,
|
|
@@ -414,8 +435,8 @@ export class DocumentService {
|
|
|
414
435
|
try {
|
|
415
436
|
var _this$getState5;
|
|
416
437
|
if (!((_this$getState5 = this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(this))) {
|
|
417
|
-
var _this$
|
|
418
|
-
(_this$
|
|
438
|
+
var _this$analyticsHelper22;
|
|
439
|
+
(_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
419
440
|
}
|
|
420
441
|
const state = this.getState();
|
|
421
442
|
const content = (doc.content || []).map(child => state.schema.nodeFromJSON(child));
|
|
@@ -439,7 +460,7 @@ export class DocumentService {
|
|
|
439
460
|
const unconfirmedSteps = this.getUnconfirmedSteps();
|
|
440
461
|
try {
|
|
441
462
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
442
|
-
var _this$getState6, _this$
|
|
463
|
+
var _this$getState6, _this$analyticsHelper24;
|
|
443
464
|
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
444
465
|
let count = 0;
|
|
445
466
|
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
@@ -450,8 +471,8 @@ export class DocumentService {
|
|
|
450
471
|
const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
451
472
|
let isLastTrConfirmed = false;
|
|
452
473
|
if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(this))) {
|
|
453
|
-
var _this$
|
|
454
|
-
(_this$
|
|
474
|
+
var _this$analyticsHelper23;
|
|
475
|
+
(_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
455
476
|
}
|
|
456
477
|
while (!isLastTrConfirmed) {
|
|
457
478
|
this.sendStepsFromCurrentState();
|
|
@@ -484,35 +505,35 @@ export class DocumentService {
|
|
|
484
505
|
}
|
|
485
506
|
}
|
|
486
507
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
487
|
-
(_this$
|
|
508
|
+
(_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
488
509
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
489
510
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
490
511
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
491
512
|
});
|
|
492
513
|
}
|
|
493
514
|
} catch (error) {
|
|
494
|
-
var _this$
|
|
515
|
+
var _this$analyticsHelper25, _this$analyticsHelper26;
|
|
495
516
|
const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
|
|
496
|
-
(_this$
|
|
517
|
+
(_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
497
518
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
498
519
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
499
520
|
});
|
|
500
|
-
(_this$
|
|
521
|
+
(_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendErrorEvent(error, 'Error while committing unconfirmed steps');
|
|
501
522
|
throw error;
|
|
502
523
|
}
|
|
503
524
|
});
|
|
504
525
|
_defineProperty(this, "onStepRejectedError", () => {
|
|
505
|
-
var _this$
|
|
526
|
+
var _this$analyticsHelper27;
|
|
506
527
|
this.stepRejectCounter++;
|
|
507
528
|
logger(`Steps rejected (tries=${this.stepRejectCounter})`);
|
|
508
|
-
(_this$
|
|
529
|
+
(_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
509
530
|
count: this.stepRejectCounter
|
|
510
531
|
});
|
|
511
532
|
let maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
|
|
512
533
|
if (this.stepRejectCounter >= maxRetries) {
|
|
513
|
-
var _this$
|
|
534
|
+
var _this$analyticsHelper28;
|
|
514
535
|
logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
|
|
515
|
-
(_this$
|
|
536
|
+
(_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
516
537
|
this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
|
|
517
538
|
} else {
|
|
518
539
|
// If committing steps failed try again automatically in 1s
|
|
@@ -539,15 +560,15 @@ export class DocumentService {
|
|
|
539
560
|
getVersionFromCollabState(state, resource) {
|
|
540
561
|
const collabState = getCollabState(state);
|
|
541
562
|
if (!collabState) {
|
|
542
|
-
var _this$
|
|
543
|
-
(_this$
|
|
563
|
+
var _this$analyticsHelper29;
|
|
564
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
|
|
544
565
|
return 0;
|
|
545
566
|
}
|
|
546
567
|
|
|
547
568
|
// This should not happen in usual, just add error event in case it happens
|
|
548
569
|
if (collabState.version === undefined) {
|
|
549
|
-
var _this$
|
|
550
|
-
(_this$
|
|
570
|
+
var _this$analyticsHelper30;
|
|
571
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
|
|
551
572
|
return 0;
|
|
552
573
|
}
|
|
553
574
|
return collabState.version;
|
|
@@ -595,11 +616,11 @@ export class DocumentService {
|
|
|
595
616
|
setTimeout(() => this.sendStepsFromCurrentState(), 100);
|
|
596
617
|
}
|
|
597
618
|
} catch (error) {
|
|
598
|
-
var _this$
|
|
619
|
+
var _this$analyticsHelper31;
|
|
599
620
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
600
621
|
let userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
601
622
|
logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
|
|
602
|
-
(_this$
|
|
623
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(error, userIdMatch ? `Error while processing steps with new clientId` : `Error while processing steps`);
|
|
603
624
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
604
625
|
}
|
|
605
626
|
}
|
|
@@ -629,8 +650,8 @@ export class DocumentService {
|
|
|
629
650
|
var _this$getState7;
|
|
630
651
|
const state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
631
652
|
if (!state) {
|
|
632
|
-
var _this$
|
|
633
|
-
(_this$
|
|
653
|
+
var _this$analyticsHelper32;
|
|
654
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
634
655
|
return;
|
|
635
656
|
}
|
|
636
657
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -652,8 +673,8 @@ export class DocumentService {
|
|
|
652
673
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
653
674
|
// sent once on connection (as opposed to on every step)
|
|
654
675
|
if (sendAnalyticsEvent) {
|
|
655
|
-
var _this$
|
|
656
|
-
(_this$
|
|
676
|
+
var _this$analyticsHelper33;
|
|
677
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 ? void 0 : _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
657
678
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
658
679
|
});
|
|
659
680
|
}
|
|
@@ -275,6 +275,7 @@ export class Provider extends Emitter {
|
|
|
275
275
|
this.documentService.sendStepsFromCurrentState(true);
|
|
276
276
|
}, 5000);
|
|
277
277
|
}
|
|
278
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
278
279
|
/**
|
|
279
280
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
280
281
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -465,6 +466,7 @@ export class Provider extends Emitter {
|
|
|
465
466
|
return this.unsubscribeAll();
|
|
466
467
|
}
|
|
467
468
|
|
|
469
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
468
470
|
/**
|
|
469
471
|
* Disconnect the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
470
472
|
* Used by Confluence to disable the provider when a user doesn't have access to a resource.
|
|
@@ -475,6 +477,7 @@ export class Provider extends Emitter {
|
|
|
475
477
|
return this.unsubscribeAll();
|
|
476
478
|
}
|
|
477
479
|
|
|
480
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
478
481
|
/**
|
|
479
482
|
* Disconnect the provider's connection to the back-end service and unsubscribe from all events emitted by this provider. Kept to keep roughly aligned to Synchrony API, which you need to call for each event.
|
|
480
483
|
* @deprecated use destroy instead, it does the same thing
|
|
@@ -497,6 +500,7 @@ export class Provider extends Emitter {
|
|
|
497
500
|
return this;
|
|
498
501
|
}
|
|
499
502
|
|
|
503
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
500
504
|
/**
|
|
501
505
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
502
506
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -517,6 +521,7 @@ export class Provider extends Emitter {
|
|
|
517
521
|
}
|
|
518
522
|
}
|
|
519
523
|
|
|
524
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
520
525
|
/**
|
|
521
526
|
* Set editor width, not used any more
|
|
522
527
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -5,6 +5,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
5
5
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
6
6
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
7
7
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
8
9
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS, CatchupEventReason } from '../helpers/const';
|
|
9
10
|
import { getCollabState, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
10
11
|
import { JSONTransformer } from '@atlaskit/editor-json-transformer';
|
|
@@ -277,7 +278,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
277
278
|
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
278
279
|
_defineProperty(this, "onRestore", /*#__PURE__*/function () {
|
|
279
280
|
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref6) {
|
|
280
|
-
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper12, _this$analyticsHelper13, _this$
|
|
281
|
+
var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper14, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper15, _this$analyticsHelper16;
|
|
281
282
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
282
283
|
while (1) switch (_context3.prev = _context3.next) {
|
|
283
284
|
case 0:
|
|
@@ -310,25 +311,51 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
310
311
|
reserveCursor: true
|
|
311
312
|
});
|
|
312
313
|
_this.metadataService.updateMetadata(metadata);
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
if (!fg('restore_localstep_fallback_reconcile')) {
|
|
315
|
+
_context3.next = 25;
|
|
316
|
+
break;
|
|
317
|
+
}
|
|
318
|
+
_context3.prev = 12;
|
|
319
|
+
(_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.INFO, {
|
|
320
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
321
|
+
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
322
|
+
clientId: _this.clientId,
|
|
323
|
+
targetClientId: targetClientId,
|
|
324
|
+
triggeredByCatchup: targetClientId ? true : false
|
|
325
|
+
});
|
|
326
|
+
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
327
|
+
_this.applyLocalSteps(unconfirmedSteps);
|
|
328
|
+
}
|
|
329
|
+
_context3.next = 23;
|
|
330
|
+
break;
|
|
331
|
+
case 17:
|
|
332
|
+
_context3.prev = 17;
|
|
333
|
+
_context3.t0 = _context3["catch"](12);
|
|
334
|
+
(_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
|
|
335
|
+
useReconcile = true;
|
|
336
|
+
_context3.next = 23;
|
|
337
|
+
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
338
|
+
case 23:
|
|
339
|
+
_context3.next = 31;
|
|
340
|
+
break;
|
|
341
|
+
case 25:
|
|
315
342
|
if (!(useReconcile && currentState)) {
|
|
316
|
-
_context3.next =
|
|
343
|
+
_context3.next = 30;
|
|
317
344
|
break;
|
|
318
345
|
}
|
|
319
|
-
_context3.next =
|
|
346
|
+
_context3.next = 28;
|
|
320
347
|
return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
|
|
321
|
-
case
|
|
322
|
-
_context3.next =
|
|
348
|
+
case 28:
|
|
349
|
+
_context3.next = 31;
|
|
323
350
|
break;
|
|
324
|
-
case
|
|
351
|
+
case 30:
|
|
325
352
|
if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
|
|
326
353
|
// we don't want to use reconcile for restore triggered by catchup client out of sync (when targetClientId is provided)
|
|
327
354
|
// as this results in all changes made while the client was out of sync being lost
|
|
328
355
|
_this.applyLocalSteps(unconfirmedSteps);
|
|
329
356
|
}
|
|
330
|
-
case
|
|
331
|
-
(_this$
|
|
357
|
+
case 31:
|
|
358
|
+
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
332
359
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
333
360
|
hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
|
|
334
361
|
useReconcile: useReconcile,
|
|
@@ -336,19 +363,19 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
336
363
|
targetClientId: targetClientId,
|
|
337
364
|
triggeredByCatchup: targetClientId ? true : false
|
|
338
365
|
});
|
|
339
|
-
_context3.next =
|
|
366
|
+
_context3.next = 39;
|
|
340
367
|
break;
|
|
341
|
-
case
|
|
342
|
-
_context3.prev =
|
|
343
|
-
_context3.
|
|
344
|
-
(_this$
|
|
368
|
+
case 34:
|
|
369
|
+
_context3.prev = 34;
|
|
370
|
+
_context3.t1 = _context3["catch"](8);
|
|
371
|
+
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
|
|
345
372
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
|
|
346
373
|
useReconcile: useReconcile,
|
|
347
374
|
clientId: _this.clientId,
|
|
348
375
|
targetClientId: targetClientId,
|
|
349
376
|
triggeredByCatchup: targetClientId ? true : false
|
|
350
377
|
});
|
|
351
|
-
(_this$
|
|
378
|
+
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(_context3.t1, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
|
|
352
379
|
_this.onErrorHandled({
|
|
353
380
|
message: 'Caught error while trying to recover the document',
|
|
354
381
|
data: {
|
|
@@ -357,18 +384,18 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
357
384
|
code: INTERNAL_ERROR_CODE.DOCUMENT_RESTORE_ERROR
|
|
358
385
|
}
|
|
359
386
|
});
|
|
360
|
-
case
|
|
387
|
+
case 39:
|
|
361
388
|
case "end":
|
|
362
389
|
return _context3.stop();
|
|
363
390
|
}
|
|
364
|
-
}, _callee3, null, [[8,
|
|
391
|
+
}, _callee3, null, [[8, 34], [12, 17]]);
|
|
365
392
|
}));
|
|
366
393
|
return function (_x2) {
|
|
367
394
|
return _ref7.apply(this, arguments);
|
|
368
395
|
};
|
|
369
396
|
}());
|
|
370
397
|
_defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
371
|
-
var _this$
|
|
398
|
+
var _this$analyticsHelper17, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper18, _this$analyticsHelper19, _measure2;
|
|
372
399
|
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
373
400
|
while (1) switch (_context4.prev = _context4.next) {
|
|
374
401
|
case 0:
|
|
@@ -403,7 +430,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
403
430
|
};
|
|
404
431
|
case 20:
|
|
405
432
|
measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
406
|
-
(_this$
|
|
433
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
407
434
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
408
435
|
});
|
|
409
436
|
_this.aggressiveCatchup = false;
|
|
@@ -413,10 +440,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
413
440
|
_context4.t1 = _context4["catch"](1);
|
|
414
441
|
_this.aggressiveCatchup = false;
|
|
415
442
|
_measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
416
|
-
(_this$
|
|
443
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
417
444
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
418
445
|
});
|
|
419
|
-
(_this$
|
|
446
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
|
|
420
447
|
throw _context4.t1;
|
|
421
448
|
case 33:
|
|
422
449
|
case "end":
|
|
@@ -444,7 +471,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
444
471
|
// ESS-5023: only emit error event if updated client version is still behind server version
|
|
445
472
|
// client version could become higher than server version due to user editing or plugin adding steps
|
|
446
473
|
if (updatedVersion < version) {
|
|
447
|
-
var _doc$content, _this$
|
|
474
|
+
var _doc$content, _this$analyticsHelper20;
|
|
448
475
|
var error = new UpdateDocumentError('Failed to update the document', {
|
|
449
476
|
newVersion: version,
|
|
450
477
|
editorVersion: updatedVersion,
|
|
@@ -452,7 +479,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
452
479
|
docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
|
|
453
480
|
isDocContentValid: isDocContentValid
|
|
454
481
|
});
|
|
455
|
-
(_this$
|
|
482
|
+
(_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(error, 'Failed to update the document in document service');
|
|
456
483
|
if (_this.enableErrorOnFailedDocumentApply) {
|
|
457
484
|
_this.onErrorHandled({
|
|
458
485
|
message: 'The provider failed to apply changes to the editor',
|
|
@@ -469,8 +496,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
469
496
|
}
|
|
470
497
|
// Otherwise just fail silently for now
|
|
471
498
|
} else {
|
|
472
|
-
var _this$
|
|
473
|
-
(_this$
|
|
499
|
+
var _this$analyticsHelper21, _doc$content2;
|
|
500
|
+
(_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
|
|
474
501
|
newVersion: version,
|
|
475
502
|
editorVersion: updatedVersion,
|
|
476
503
|
isDocTruthy: !!doc,
|
|
@@ -483,8 +510,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
483
510
|
try {
|
|
484
511
|
var _this$getState5;
|
|
485
512
|
if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
|
|
486
|
-
var _this$
|
|
487
|
-
(_this$
|
|
513
|
+
var _this$analyticsHelper22;
|
|
514
|
+
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
488
515
|
}
|
|
489
516
|
var state = _this.getState();
|
|
490
517
|
var content = (doc.content || []).map(function (child) {
|
|
@@ -507,7 +534,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
507
534
|
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
508
535
|
*/
|
|
509
536
|
_defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
|
510
|
-
var unconfirmedSteps, _this$getState6, _this$
|
|
537
|
+
var unconfirmedSteps, _this$getState6, _this$analyticsHelper24, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper23, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper25, _this$analyticsHelper26, _measure3;
|
|
511
538
|
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
512
539
|
while (1) switch (_context5.prev = _context5.next) {
|
|
513
540
|
case 0:
|
|
@@ -526,7 +553,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
526
553
|
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
527
554
|
isLastTrConfirmed = false;
|
|
528
555
|
if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
|
|
529
|
-
(_this$
|
|
556
|
+
(_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
|
|
530
557
|
}
|
|
531
558
|
case 9:
|
|
532
559
|
if (isLastTrConfirmed) {
|
|
@@ -573,7 +600,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
573
600
|
break;
|
|
574
601
|
case 22:
|
|
575
602
|
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
576
|
-
(_this$
|
|
603
|
+
(_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
577
604
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
578
605
|
// upon success, emit the total number of unconfirmed steps we synced
|
|
579
606
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
@@ -585,11 +612,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
585
612
|
_context5.prev = 26;
|
|
586
613
|
_context5.t0 = _context5["catch"](1);
|
|
587
614
|
_measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
588
|
-
(_this$
|
|
615
|
+
(_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
589
616
|
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
590
617
|
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
591
618
|
});
|
|
592
|
-
(_this$
|
|
619
|
+
(_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
|
|
593
620
|
throw _context5.t0;
|
|
594
621
|
case 32:
|
|
595
622
|
case "end":
|
|
@@ -598,17 +625,17 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
598
625
|
}, _callee5, null, [[1, 26]]);
|
|
599
626
|
})));
|
|
600
627
|
_defineProperty(this, "onStepRejectedError", function () {
|
|
601
|
-
var _this$
|
|
628
|
+
var _this$analyticsHelper27;
|
|
602
629
|
_this.stepRejectCounter++;
|
|
603
630
|
logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
|
|
604
|
-
(_this$
|
|
631
|
+
(_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
|
|
605
632
|
count: _this.stepRejectCounter
|
|
606
633
|
});
|
|
607
634
|
var maxRetries = _this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
|
|
608
635
|
if (_this.stepRejectCounter >= maxRetries) {
|
|
609
|
-
var _this$
|
|
636
|
+
var _this$analyticsHelper28;
|
|
610
637
|
logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
|
|
611
|
-
(_this$
|
|
638
|
+
(_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
|
|
612
639
|
_this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
|
|
613
640
|
} else {
|
|
614
641
|
// If committing steps failed try again automatically in 1s
|
|
@@ -639,15 +666,15 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
639
666
|
value: function getVersionFromCollabState(state, resource) {
|
|
640
667
|
var collabState = getCollabState(state);
|
|
641
668
|
if (!collabState) {
|
|
642
|
-
var _this$
|
|
643
|
-
(_this$
|
|
669
|
+
var _this$analyticsHelper29;
|
|
670
|
+
(_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
|
|
644
671
|
return 0;
|
|
645
672
|
}
|
|
646
673
|
|
|
647
674
|
// This should not happen in usual, just add error event in case it happens
|
|
648
675
|
if (collabState.version === undefined) {
|
|
649
|
-
var _this$
|
|
650
|
-
(_this$
|
|
676
|
+
var _this$analyticsHelper30;
|
|
677
|
+
(_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
|
|
651
678
|
return 0;
|
|
652
679
|
}
|
|
653
680
|
return collabState.version;
|
|
@@ -701,11 +728,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
701
728
|
}, 100);
|
|
702
729
|
}
|
|
703
730
|
} catch (error) {
|
|
704
|
-
var _this$
|
|
731
|
+
var _this$analyticsHelper31;
|
|
705
732
|
// ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
|
|
706
733
|
var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
|
|
707
734
|
logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
|
|
708
|
-
(_this$
|
|
735
|
+
(_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
|
|
709
736
|
this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
|
|
710
737
|
}
|
|
711
738
|
}
|
|
@@ -740,8 +767,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
740
767
|
var _this$getState7;
|
|
741
768
|
var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
|
|
742
769
|
if (!state) {
|
|
743
|
-
var _this$
|
|
744
|
-
(_this$
|
|
770
|
+
var _this$analyticsHelper32;
|
|
771
|
+
(_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
|
|
745
772
|
return;
|
|
746
773
|
}
|
|
747
774
|
this.send(null, null, state, sendAnalyticsEvent);
|
|
@@ -766,8 +793,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
766
793
|
// to ensure that analytics events with the number of unconfirmed steps is only
|
|
767
794
|
// sent once on connection (as opposed to on every step)
|
|
768
795
|
if (sendAnalyticsEvent) {
|
|
769
|
-
var _this$
|
|
770
|
-
(_this$
|
|
796
|
+
var _this$analyticsHelper33;
|
|
797
|
+
(_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
|
|
771
798
|
numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
|
|
772
799
|
});
|
|
773
800
|
}
|
|
@@ -321,6 +321,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
321
321
|
_createClass(Provider, [{
|
|
322
322
|
key: "initialize",
|
|
323
323
|
value:
|
|
324
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
324
325
|
/**
|
|
325
326
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
326
327
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -524,6 +525,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
524
525
|
return this.unsubscribeAll();
|
|
525
526
|
}
|
|
526
527
|
|
|
528
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
527
529
|
/**
|
|
528
530
|
* Disconnect the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
529
531
|
* Used by Confluence to disable the provider when a user doesn't have access to a resource.
|
|
@@ -536,6 +538,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
536
538
|
return this.unsubscribeAll();
|
|
537
539
|
}
|
|
538
540
|
|
|
541
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
539
542
|
/**
|
|
540
543
|
* Disconnect the provider's connection to the back-end service and unsubscribe from all events emitted by this provider. Kept to keep roughly aligned to Synchrony API, which you need to call for each event.
|
|
541
544
|
* @deprecated use destroy instead, it does the same thing
|
|
@@ -560,6 +563,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
560
563
|
return this;
|
|
561
564
|
}
|
|
562
565
|
|
|
566
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
563
567
|
/**
|
|
564
568
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
565
569
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -582,6 +586,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
582
586
|
}
|
|
583
587
|
}
|
|
584
588
|
|
|
589
|
+
// eslint-disable-next-line @repo/internal/deprecations/deprecation-ticket-required -- Ignored via go/ED-25883
|
|
585
590
|
/**
|
|
586
591
|
* Set editor width, not used any more
|
|
587
592
|
* @deprecated use setMetadata instead, it does the same thing
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ResolvedEditorState, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
1
|
+
import type { ResolvedEditorState, SyncUpErrorFunction, CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
2
2
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import type AnalyticsHelper from '../analytics/analytics-helper';
|
|
4
4
|
import { CatchupEventReason } from '../helpers/const';
|
|
5
5
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
6
|
import type { Catchupv2Response, ChannelEvent, ReconcileResponse, StepsPayload } from '../types';
|
|
7
|
-
import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
8
7
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
9
8
|
import type { InternalError } from '../errors/internal-errors';
|
|
10
9
|
import type { ParticipantsService } from '../participants/participants-service';
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ResolvedEditorState, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
1
|
+
import type { ResolvedEditorState, SyncUpErrorFunction, CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
2
2
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import type AnalyticsHelper from '../analytics/analytics-helper';
|
|
4
4
|
import { CatchupEventReason } from '../helpers/const';
|
|
5
5
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
6
|
import type { Catchupv2Response, ChannelEvent, ReconcileResponse, StepsPayload } from '../types';
|
|
7
|
-
import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
8
7
|
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
9
8
|
import type { InternalError } from '../errors/internal-errors';
|
|
10
9
|
import type { ParticipantsService } from '../participants/participants-service';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.2",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
36
36
|
"@atlaskit/analytics-listeners": "^8.13.0",
|
|
37
|
-
"@atlaskit/editor-common": "^
|
|
37
|
+
"@atlaskit/editor-common": "^96.4.0",
|
|
38
38
|
"@atlaskit/editor-json-transformer": "^8.21.0",
|
|
39
|
-
"@atlaskit/editor-prosemirror": "6.
|
|
39
|
+
"@atlaskit/editor-prosemirror": "6.2.1",
|
|
40
40
|
"@atlaskit/feature-gate-js-client": "^4.22.0",
|
|
41
41
|
"@atlaskit/platform-feature-flags": "^0.3.0",
|
|
42
42
|
"@atlaskit/prosemirror-collab": "^0.10.0",
|
|
@@ -70,6 +70,9 @@
|
|
|
70
70
|
"platform-feature-flags": {
|
|
71
71
|
"platform.editor.live-pages-expand-divergence": {
|
|
72
72
|
"type": "boolean"
|
|
73
|
+
},
|
|
74
|
+
"restore_localstep_fallback_reconcile": {
|
|
75
|
+
"type": "boolean"
|
|
73
76
|
}
|
|
74
77
|
}
|
|
75
78
|
}
|