@atlaskit/collab-provider 7.3.1 → 7.4.0

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 7.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`de9e3c28026`](https://bitbucket.org/atlassian/atlassian-frontend/commits/de9e3c28026) - [ED-14689] Refactor getFinalAcknowledgedState to only wait for the unconfirmed steps at the time of calling it to be confirmed. It will no longer wait for there to be no unconfirmed steps at all.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 7.3.1
4
14
 
5
15
  ### Patch Changes
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/channel.js",
4
4
  "module": "../dist/esm/channel.js",
5
5
  "module:es2019": "../dist/es2019/channel.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/channel.d.ts"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/disconnected-reason-mapper.js",
4
4
  "module": "../dist/esm/disconnected-reason-mapper.js",
5
5
  "module:es2019": "../dist/es2019/disconnected-reason-mapper.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/disconnected-reason-mapper.d.ts"
7
8
  }
@@ -535,70 +535,106 @@ var Provider = /*#__PURE__*/function (_Emitter) {
535
535
  });
536
536
  }
537
537
  });
538
- (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
539
- var _this$getUnconfirmedS, _this$metadata$title;
538
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
539
+ var _this$metadata$title;
540
540
 
541
- var maxAttemptsToSync, count, unconfirmedSteps, _this$getUnconfirmedS2, _unconfirmedSteps, _state, state;
542
-
543
- return _regenerator.default.wrap(function _callee3$(_context3) {
541
+ var maxAttemptsToSync, count, unconfirmedState, state;
542
+ return _regenerator.default.wrap(function _callee4$(_context4) {
544
543
  while (1) {
545
- switch (_context3.prev = _context3.next) {
544
+ switch (_context4.prev = _context4.next) {
546
545
  case 0:
547
546
  maxAttemptsToSync = _const.ACK_MAX_TRY;
548
547
  count = 0;
549
- unconfirmedSteps = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps;
550
-
551
- case 3:
552
- if (!(unconfirmedSteps && unconfirmedSteps.length)) {
553
- _context3.next = 13;
554
- break;
555
- }
556
-
557
- _this.sendStepsFromCurrentState();
558
-
559
- _context3.next = 7;
560
- return (0, _utils.sleep)(500);
561
-
562
- case 7:
563
- unconfirmedSteps = (_this$getUnconfirmedS2 = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps;
548
+ unconfirmedState = _this.getUnconfirmedSteps();
564
549
 
565
- if (!(count++ >= maxAttemptsToSync)) {
566
- _context3.next = 11;
550
+ if (!(unconfirmedState && unconfirmedState.steps.length)) {
551
+ _context4.next = 5;
567
552
  break;
568
553
  }
569
554
 
570
- if (_this.onSyncUpError) {
571
- _state = _this.getState();
572
-
573
- _this.onSyncUpError({
574
- lengthOfUnconfirmedSteps: (_unconfirmedSteps = unconfirmedSteps) === null || _unconfirmedSteps === void 0 ? void 0 : _unconfirmedSteps.length,
575
- tries: count,
576
- maxRetries: maxAttemptsToSync,
577
- clientId: _this.clientId,
578
- version: (0, _prosemirrorCollab.getVersion)(_state)
579
- });
580
- }
581
-
582
- throw new Error("Can't syncup with Collab Service");
583
-
584
- case 11:
585
- _context3.next = 3;
586
- break;
587
-
588
- case 13:
555
+ return _context4.delegateYield( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
556
+ var unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedState, nextUnconfirmedTrs, _state;
557
+
558
+ return _regenerator.default.wrap(function _callee3$(_context3) {
559
+ while (1) {
560
+ switch (_context3.prev = _context3.next) {
561
+ case 0:
562
+ // We use origins here as steps can be rebased. When steps are rebased a new step is created.
563
+ // This means that we can not track if it has been removed from the unconfirmed array or not.
564
+ // Origins points to the original transaction that the step was created in. This is never changed
565
+ // and gets passed down when a step is rebased.
566
+ unconfirmedTrs = unconfirmedState.origins;
567
+ lastTr = unconfirmedTrs[unconfirmedTrs.length - 1];
568
+ isLastTrConfirmed = false;
569
+
570
+ case 3:
571
+ if (isLastTrConfirmed) {
572
+ _context3.next = 14;
573
+ break;
574
+ }
575
+
576
+ _this.sendStepsFromCurrentState();
577
+
578
+ _context3.next = 7;
579
+ return (0, _utils.sleep)(500);
580
+
581
+ case 7:
582
+ nextUnconfirmedState = _this.getUnconfirmedSteps();
583
+
584
+ if (nextUnconfirmedState && nextUnconfirmedState.steps.length) {
585
+ nextUnconfirmedTrs = nextUnconfirmedState.origins;
586
+ isLastTrConfirmed = !nextUnconfirmedTrs.some(function (tr) {
587
+ return tr === lastTr;
588
+ });
589
+ } else {
590
+ isLastTrConfirmed = true;
591
+ }
592
+
593
+ if (!(!isLastTrConfirmed && count++ >= maxAttemptsToSync)) {
594
+ _context3.next = 12;
595
+ break;
596
+ }
597
+
598
+ if (_this.onSyncUpError) {
599
+ _state = _this.getState();
600
+
601
+ _this.onSyncUpError({
602
+ lengthOfUnconfirmedSteps: nextUnconfirmedState === null || nextUnconfirmedState === void 0 ? void 0 : nextUnconfirmedState.steps.length,
603
+ tries: count,
604
+ maxRetries: maxAttemptsToSync,
605
+ clientId: _this.clientId,
606
+ version: (0, _prosemirrorCollab.getVersion)(_state)
607
+ });
608
+ }
609
+
610
+ throw new Error("Can't syncup with Collab Service");
611
+
612
+ case 12:
613
+ _context3.next = 3;
614
+ break;
615
+
616
+ case 14:
617
+ case "end":
618
+ return _context3.stop();
619
+ }
620
+ }
621
+ }, _callee3);
622
+ })(), "t0", 5);
623
+
624
+ case 5:
589
625
  state = _this.getState();
590
- return _context3.abrupt("return", {
626
+ return _context4.abrupt("return", {
591
627
  content: state.doc.toJSON(),
592
628
  title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
593
629
  stepVersion: (0, _prosemirrorCollab.getVersion)(state)
594
630
  });
595
631
 
596
- case 15:
632
+ case 7:
597
633
  case "end":
598
- return _context3.stop();
634
+ return _context4.stop();
599
635
  }
600
636
  }
601
- }, _callee3);
637
+ }, _callee4);
602
638
  })));
603
639
  _this.config = config;
604
640
  _this.channel = new _channel.Channel(config);
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -424,34 +424,47 @@ export class Provider extends Emitter {
424
424
  });
425
425
 
426
426
  _defineProperty(this, "getFinalAcknowledgedState", async () => {
427
- var _this$getUnconfirmedS, _this$metadata$title;
427
+ var _this$metadata$title;
428
428
 
429
429
  const maxAttemptsToSync = ACK_MAX_TRY;
430
430
  let count = 0;
431
- let unconfirmedSteps = (_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps;
432
-
433
- while (unconfirmedSteps && unconfirmedSteps.length) {
434
- var _this$getUnconfirmedS2;
435
-
436
- this.sendStepsFromCurrentState();
437
- await sleep(500);
438
- unconfirmedSteps = (_this$getUnconfirmedS2 = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps;
439
-
440
- if (count++ >= maxAttemptsToSync) {
441
- if (this.onSyncUpError) {
442
- var _unconfirmedSteps;
443
-
444
- const state = this.getState();
445
- this.onSyncUpError({
446
- lengthOfUnconfirmedSteps: (_unconfirmedSteps = unconfirmedSteps) === null || _unconfirmedSteps === void 0 ? void 0 : _unconfirmedSteps.length,
447
- tries: count,
448
- maxRetries: maxAttemptsToSync,
449
- clientId: this.clientId,
450
- version: getVersion(state)
451
- });
431
+ let unconfirmedState = this.getUnconfirmedSteps();
432
+
433
+ if (unconfirmedState && unconfirmedState.steps.length) {
434
+ // We use origins here as steps can be rebased. When steps are rebased a new step is created.
435
+ // This means that we can not track if it has been removed from the unconfirmed array or not.
436
+ // Origins points to the original transaction that the step was created in. This is never changed
437
+ // and gets passed down when a step is rebased.
438
+ const unconfirmedTrs = unconfirmedState.origins;
439
+ const lastTr = unconfirmedTrs[unconfirmedTrs.length - 1];
440
+ let isLastTrConfirmed = false;
441
+
442
+ while (!isLastTrConfirmed) {
443
+ this.sendStepsFromCurrentState();
444
+ await sleep(500);
445
+ const nextUnconfirmedState = this.getUnconfirmedSteps();
446
+
447
+ if (nextUnconfirmedState && nextUnconfirmedState.steps.length) {
448
+ const nextUnconfirmedTrs = nextUnconfirmedState.origins;
449
+ isLastTrConfirmed = !nextUnconfirmedTrs.some(tr => tr === lastTr);
450
+ } else {
451
+ isLastTrConfirmed = true;
452
452
  }
453
453
 
454
- throw new Error("Can't syncup with Collab Service");
454
+ if (!isLastTrConfirmed && count++ >= maxAttemptsToSync) {
455
+ if (this.onSyncUpError) {
456
+ const state = this.getState();
457
+ this.onSyncUpError({
458
+ lengthOfUnconfirmedSteps: nextUnconfirmedState === null || nextUnconfirmedState === void 0 ? void 0 : nextUnconfirmedState.steps.length,
459
+ tries: count,
460
+ maxRetries: maxAttemptsToSync,
461
+ clientId: this.clientId,
462
+ version: getVersion(state)
463
+ });
464
+ }
465
+
466
+ throw new Error("Can't syncup with Collab Service");
467
+ }
455
468
  }
456
469
  }
457
470
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -527,70 +527,106 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
527
527
  }
528
528
  });
529
529
 
530
- _defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
531
- var _this$getUnconfirmedS, _this$metadata$title;
530
+ _defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
531
+ var _this$metadata$title;
532
532
 
533
- var maxAttemptsToSync, count, unconfirmedSteps, _this$getUnconfirmedS2, _unconfirmedSteps, _state, state;
534
-
535
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
533
+ var maxAttemptsToSync, count, unconfirmedState, state;
534
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
536
535
  while (1) {
537
- switch (_context3.prev = _context3.next) {
536
+ switch (_context4.prev = _context4.next) {
538
537
  case 0:
539
538
  maxAttemptsToSync = ACK_MAX_TRY;
540
539
  count = 0;
541
- unconfirmedSteps = (_this$getUnconfirmedS = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps;
542
-
543
- case 3:
544
- if (!(unconfirmedSteps && unconfirmedSteps.length)) {
545
- _context3.next = 13;
546
- break;
547
- }
548
-
549
- _this.sendStepsFromCurrentState();
550
-
551
- _context3.next = 7;
552
- return sleep(500);
553
-
554
- case 7:
555
- unconfirmedSteps = (_this$getUnconfirmedS2 = _this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps;
540
+ unconfirmedState = _this.getUnconfirmedSteps();
556
541
 
557
- if (!(count++ >= maxAttemptsToSync)) {
558
- _context3.next = 11;
542
+ if (!(unconfirmedState && unconfirmedState.steps.length)) {
543
+ _context4.next = 5;
559
544
  break;
560
545
  }
561
546
 
562
- if (_this.onSyncUpError) {
563
- _state = _this.getState();
564
-
565
- _this.onSyncUpError({
566
- lengthOfUnconfirmedSteps: (_unconfirmedSteps = unconfirmedSteps) === null || _unconfirmedSteps === void 0 ? void 0 : _unconfirmedSteps.length,
567
- tries: count,
568
- maxRetries: maxAttemptsToSync,
569
- clientId: _this.clientId,
570
- version: getVersion(_state)
571
- });
572
- }
573
-
574
- throw new Error("Can't syncup with Collab Service");
575
-
576
- case 11:
577
- _context3.next = 3;
578
- break;
579
-
580
- case 13:
547
+ return _context4.delegateYield( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
548
+ var unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedState, nextUnconfirmedTrs, _state;
549
+
550
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
551
+ while (1) {
552
+ switch (_context3.prev = _context3.next) {
553
+ case 0:
554
+ // We use origins here as steps can be rebased. When steps are rebased a new step is created.
555
+ // This means that we can not track if it has been removed from the unconfirmed array or not.
556
+ // Origins points to the original transaction that the step was created in. This is never changed
557
+ // and gets passed down when a step is rebased.
558
+ unconfirmedTrs = unconfirmedState.origins;
559
+ lastTr = unconfirmedTrs[unconfirmedTrs.length - 1];
560
+ isLastTrConfirmed = false;
561
+
562
+ case 3:
563
+ if (isLastTrConfirmed) {
564
+ _context3.next = 14;
565
+ break;
566
+ }
567
+
568
+ _this.sendStepsFromCurrentState();
569
+
570
+ _context3.next = 7;
571
+ return sleep(500);
572
+
573
+ case 7:
574
+ nextUnconfirmedState = _this.getUnconfirmedSteps();
575
+
576
+ if (nextUnconfirmedState && nextUnconfirmedState.steps.length) {
577
+ nextUnconfirmedTrs = nextUnconfirmedState.origins;
578
+ isLastTrConfirmed = !nextUnconfirmedTrs.some(function (tr) {
579
+ return tr === lastTr;
580
+ });
581
+ } else {
582
+ isLastTrConfirmed = true;
583
+ }
584
+
585
+ if (!(!isLastTrConfirmed && count++ >= maxAttemptsToSync)) {
586
+ _context3.next = 12;
587
+ break;
588
+ }
589
+
590
+ if (_this.onSyncUpError) {
591
+ _state = _this.getState();
592
+
593
+ _this.onSyncUpError({
594
+ lengthOfUnconfirmedSteps: nextUnconfirmedState === null || nextUnconfirmedState === void 0 ? void 0 : nextUnconfirmedState.steps.length,
595
+ tries: count,
596
+ maxRetries: maxAttemptsToSync,
597
+ clientId: _this.clientId,
598
+ version: getVersion(_state)
599
+ });
600
+ }
601
+
602
+ throw new Error("Can't syncup with Collab Service");
603
+
604
+ case 12:
605
+ _context3.next = 3;
606
+ break;
607
+
608
+ case 14:
609
+ case "end":
610
+ return _context3.stop();
611
+ }
612
+ }
613
+ }, _callee3);
614
+ })(), "t0", 5);
615
+
616
+ case 5:
581
617
  state = _this.getState();
582
- return _context3.abrupt("return", {
618
+ return _context4.abrupt("return", {
583
619
  content: state.doc.toJSON(),
584
620
  title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
585
621
  stepVersion: getVersion(state)
586
622
  });
587
623
 
588
- case 15:
624
+ case 7:
589
625
  case "end":
590
- return _context3.stop();
626
+ return _context4.stop();
591
627
  }
592
628
  }
593
- }, _callee3);
629
+ }, _callee4);
594
630
  })));
595
631
 
596
632
  _this.config = config;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "sideEffects": false
5
5
  }
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/emitter.js",
4
4
  "module": "../dist/esm/emitter.js",
5
5
  "module:es2019": "../dist/es2019/emitter.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/emitter.d.ts"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/error-code-mapper.js",
4
4
  "module": "../dist/esm/error-code-mapper.js",
5
5
  "module:es2019": "../dist/es2019/error-code-mapper.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/error-code-mapper.d.ts"
7
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.3.1",
3
+ "version": "7.4.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "@atlaskit/analytics-gas-types": "5.0.6",
25
25
  "@atlaskit/analytics-listeners": "^8.2.0",
26
- "@atlaskit/editor-common": "^66.0.0",
26
+ "@atlaskit/editor-common": "^67.0.0",
27
27
  "@atlaskit/editor-json-transformer": "^8.7.0",
28
28
  "@atlaskit/util-service-support": "^6.1.0",
29
29
  "@babel/runtime": "^7.0.0",
@@ -39,7 +39,8 @@
39
39
  "tree-shaking": []
40
40
  },
41
41
  "@repo/internal": {
42
- "deprecation": "no-deprecated-imports"
42
+ "deprecation": "no-deprecated-imports",
43
+ "theming": "tokens"
43
44
  }
44
45
  },
45
46
  "devDependencies": {
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/socket-io-provider.js",
4
4
  "module": "../dist/esm/socket-io-provider.js",
5
5
  "module:es2019": "../dist/es2019/socket-io-provider.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/socket-io-provider.d.ts"
7
8
  }
@@ -3,5 +3,6 @@
3
3
  "main": "../dist/cjs/types.js",
4
4
  "module": "../dist/esm/types.js",
5
5
  "module:es2019": "../dist/es2019/types.js",
6
+ "sideEffects": false,
6
7
  "types": "../dist/types/types.d.ts"
7
8
  }