@atlaskit/collab-provider 7.1.4 → 7.1.7

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,30 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 7.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 7.1.6
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5d5d6468ba9`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5d5d6468ba9) - Remove url-parse from collab-provider
14
+
15
+ Url-parse can be replaced with the built-in URL constructor
16
+
17
+ ## 7.1.5
18
+
19
+ ### Patch Changes
20
+
21
+ - [`f82fb6c48f7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f82fb6c48f7) - [ED-13911] Fix cycle dependencies
22
+ - [`97412280671`](https://bitbucket.org/atlassian/atlassian-frontend/commits/97412280671) - [ED-13939] Add analytics event to track "can't syncup with collab service" error
23
+ - [`88ada10af2c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/88ada10af2c) - [ED-14097] Moved getFinalAcknowledgedState control to editor and made the API public
24
+ - [`85648c038a4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/85648c038a4) - ED-13939 Rename newCollabSyncUpError analytics event to newCollabSyncUpErrorNoSteps
25
+ - [`e292f108d4b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e292f108d4b) - Ensure metadata is persisted when it is updated by another participant during an editing session
26
+ - Updated dependencies
27
+
3
28
  ## 7.1.4
4
29
 
5
30
  ### Patch Changes
@@ -77,6 +77,8 @@ var CATCHUP_THROTTLE = 1 * 1000; // 1 second
77
77
  exports.CATCHUP_THROTTLE = CATCHUP_THROTTLE;
78
78
  var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
79
79
 
80
+ var noop = function noop() {};
81
+
80
82
  var MAX_STEP_REJECTED_ERROR = 15;
81
83
  exports.MAX_STEP_REJECTED_ERROR = MAX_STEP_REJECTED_ERROR;
82
84
 
@@ -146,7 +148,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
146
148
  version: version,
147
149
  metadata: metadata
148
150
  });
149
- }).on('steps:added', _this.onStepsAdded).on('participant:telepointer', _this.onParticipantTelepointer).on('presence:joined', _this.onPresenceJoined).on('presence', _this.onPresence).on('participant:left', _this.onParticipantLeft).on('participant:updated', _this.onParticipantUpdated).on('metadata:changed', _this.onMetadataChanged).on('disconnect', _this.onDisconnected).on('error', _this.onErrorHandled).connect();
151
+ }).on('steps:added', _this.onStepsAdded.bind((0, _assertThisInitialized2.default)(_this))).on('participant:telepointer', _this.onParticipantTelepointer.bind((0, _assertThisInitialized2.default)(_this))).on('presence:joined', _this.onPresenceJoined.bind((0, _assertThisInitialized2.default)(_this))).on('presence', _this.onPresence.bind((0, _assertThisInitialized2.default)(_this))).on('participant:left', _this.onParticipantLeft.bind((0, _assertThisInitialized2.default)(_this))).on('participant:updated', _this.onParticipantUpdated.bind((0, _assertThisInitialized2.default)(_this))).on('metadata:changed', _this.onMetadataChanged.bind((0, _assertThisInitialized2.default)(_this))).on('disconnect', _this.onDisconnected.bind((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled.bind((0, _assertThisInitialized2.default)(_this))).connect();
150
152
  });
151
153
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onStepsAdded", function (data) {
152
154
  logger("Received steps", {
@@ -332,6 +334,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
332
334
  });
333
335
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMetadataChanged", function (metadata) {
334
336
  if (metadata !== undefined && !(0, _isEqual.default)(_this.metadata, metadata)) {
337
+ _this.metadata = metadata;
338
+
335
339
  _this.emit('metadata:changed', metadata);
336
340
  }
337
341
  });
@@ -531,6 +535,71 @@ var Provider = /*#__PURE__*/function (_Emitter) {
531
535
  });
532
536
  }
533
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;
540
+
541
+ var maxAttemptsToSync, count, unconfirmedSteps, _this$getUnconfirmedS2, _unconfirmedSteps, _state, state;
542
+
543
+ return _regenerator.default.wrap(function _callee3$(_context3) {
544
+ while (1) {
545
+ switch (_context3.prev = _context3.next) {
546
+ case 0:
547
+ maxAttemptsToSync = _const.ACK_MAX_TRY;
548
+ 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;
564
+
565
+ if (!(count++ >= maxAttemptsToSync)) {
566
+ _context3.next = 11;
567
+ break;
568
+ }
569
+
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:
589
+ state = _this.getState();
590
+ return _context3.abrupt("return", {
591
+ content: state.doc.toJSON(),
592
+ title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
593
+ stepVersion: (0, _prosemirrorCollab.getVersion)(state)
594
+ });
595
+
596
+ case 15:
597
+ case "end":
598
+ return _context3.stop();
599
+ }
600
+ }
601
+ }, _callee3);
602
+ })));
534
603
  _this.config = config;
535
604
  _this.channel = new _channel.Channel(config);
536
605
  _this.isChannelInitialized = false;
@@ -544,13 +613,26 @@ var Provider = /*#__PURE__*/function (_Emitter) {
544
613
 
545
614
  (0, _createClass2.default)(Provider, [{
546
615
  key: "initialize",
547
- value: function initialize(optionsOrGetState) {
548
- // move this
549
- this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
550
- this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
551
- this.getState().plugins.find(function (p) {
616
+ value:
617
+ /**
618
+ * Called by collab plugin in editor when it's ready to
619
+ * initialize a collab session.
620
+ */
621
+ function initialize(getState) {
622
+ return this.setup({
623
+ getState: getState
624
+ });
625
+ }
626
+ }, {
627
+ key: "setup",
628
+ value: function setup(_ref16) {
629
+ var getState = _ref16.getState,
630
+ onSyncUpError = _ref16.onSyncUpError;
631
+ this.getState = getState;
632
+ this.onSyncUpError = onSyncUpError || noop;
633
+ this.clientId = getState().plugins.find(function (p) {
552
634
  return p.key === 'collab$';
553
- }).spec.config.clientID : optionsOrGetState.clientId;
635
+ }).spec.config.clientID;
554
636
 
555
637
  if (!this.isChannelInitialized) {
556
638
  this.initializeChannel();
@@ -655,8 +737,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
655
737
  logger("Processing data. Version \"".concat(version, "\"."));
656
738
 
657
739
  if (steps && steps.length) {
658
- var clientIds = steps.map(function (_ref15) {
659
- var clientId = _ref15.clientId;
740
+ var clientIds = steps.map(function (_ref17) {
741
+ var clientId = _ref17.clientId;
660
742
  return clientId;
661
743
  });
662
744
  this.emit('data', {
@@ -718,14 +800,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
718
800
  participant = _Array$from$filter2[0];
719
801
 
720
802
  if (participant) {
721
- var _ref16 = step,
722
- stepType = _ref16.stepType,
723
- to = _ref16.to,
724
- from = _ref16.from,
725
- _ref16$slice = _ref16.slice,
726
- slice = _ref16$slice === void 0 ? {
803
+ var _ref18 = step,
804
+ stepType = _ref18.stepType,
805
+ to = _ref18.to,
806
+ from = _ref18.from,
807
+ _ref18$slice = _ref18.slice,
808
+ slice = _ref18$slice === void 0 ? {
727
809
  content: []
728
- } : _ref16$slice;
810
+ } : _ref18$slice;
729
811
 
730
812
  var _slice$content = (0, _slicedToArray2.default)(slice.content, 1),
731
813
  node = _slice$content[0];
@@ -786,80 +868,13 @@ var Provider = /*#__PURE__*/function (_Emitter) {
786
868
  this.channel.sendMetadata(metadata);
787
869
  Object.assign(this.metadata, metadata);
788
870
  }
789
- /**
790
- * Get latest state.
791
- *
792
- * NOTE: Should this actually convert to ADF instead?
793
- */
794
-
795
871
  }, {
796
- key: "getFinalAcknowledgedState",
797
- value: function () {
798
- var _getFinalAcknowledgedState = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
799
- var _this$getUnconfirmedS;
800
-
801
- var state, count, unconfirmedSteps, _this$getUnconfirmedS2;
802
-
803
- return _regenerator.default.wrap(function _callee3$(_context3) {
804
- while (1) {
805
- switch (_context3.prev = _context3.next) {
806
- case 0:
807
- state = this.getState();
808
- count = 0;
809
- unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps);
810
-
811
- case 3:
812
- if (!(unconfirmedSteps && unconfirmedSteps.length)) {
813
- _context3.next = 12;
814
- break;
815
- }
816
-
817
- this.sendStepsFromCurrentState();
818
- _context3.next = 7;
819
- return (0, _utils.sleep)(500);
820
-
821
- case 7:
822
- unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS2 = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps);
823
-
824
- if (!(count++ >= _const.ACK_MAX_TRY)) {
825
- _context3.next = 10;
826
- break;
827
- }
828
-
829
- throw new Error("Can't syncup with Collab Service");
830
-
831
- case 10:
832
- _context3.next = 3;
833
- break;
834
-
835
- case 12:
836
- return _context3.abrupt("return", {
837
- content: state.doc.toJSON(),
838
- title: this.metadata.title,
839
- stepVersion: (0, _prosemirrorCollab.getVersion)(state)
840
- });
841
-
842
- case 13:
843
- case "end":
844
- return _context3.stop();
845
- }
846
- }
847
- }, _callee3, this);
848
- }));
849
-
850
- function getFinalAcknowledgedState() {
851
- return _getFinalAcknowledgedState.apply(this, arguments);
852
- }
853
-
854
- return getFinalAcknowledgedState;
855
- }()
872
+ key: "unsubscribeAll",
873
+ value:
856
874
  /**
857
875
  * Unsubscribe from all events emitted by this provider.
858
876
  */
859
-
860
- }, {
861
- key: "unsubscribeAll",
862
- value: function unsubscribeAll() {
877
+ function unsubscribeAll() {
863
878
  (0, _get2.default)((0, _getPrototypeOf2.default)(Provider.prototype), "unsubscribeAll", this).call(this);
864
879
  this.channel.disconnect();
865
880
  return this;
@@ -14,15 +14,13 @@ var _provider = require("./provider");
14
14
 
15
15
  var _socket = require("socket.io-client");
16
16
 
17
- var _urlParse2 = _interopRequireDefault(require("url-parse"));
18
-
19
17
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
20
18
 
21
19
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
22
20
 
23
21
  function createSocketIOSocket(url, auth) {
24
- var _urlParse = (0, _urlParse2.default)(url),
25
- pathname = _urlParse.pathname;
22
+ var _URL = new URL(url),
23
+ pathname = _URL.pathname;
26
24
 
27
25
  return (0, _socket.io)(url, {
28
26
  withCredentials: true,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.1.4",
3
+ "version": "7.1.7",
4
4
  "sideEffects": false
5
5
  }
@@ -21,6 +21,8 @@ export const CATCHUP_THROTTLE = 1 * 1000; // 1 second
21
21
 
22
22
  const OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
23
23
 
24
+ const noop = () => {};
25
+
24
26
  export const MAX_STEP_REJECTED_ERROR = 15;
25
27
 
26
28
  const commitStep = ({
@@ -84,7 +86,7 @@ export class Provider extends Emitter {
84
86
  version,
85
87
  metadata
86
88
  });
87
- }).on('steps:added', this.onStepsAdded).on('participant:telepointer', this.onParticipantTelepointer).on('presence:joined', this.onPresenceJoined).on('presence', this.onPresence).on('participant:left', this.onParticipantLeft).on('participant:updated', this.onParticipantUpdated).on('metadata:changed', this.onMetadataChanged).on('disconnect', this.onDisconnected).on('error', this.onErrorHandled).connect();
89
+ }).on('steps:added', this.onStepsAdded.bind(this)).on('participant:telepointer', this.onParticipantTelepointer.bind(this)).on('presence:joined', this.onPresenceJoined.bind(this)).on('presence', this.onPresence.bind(this)).on('participant:left', this.onParticipantLeft.bind(this)).on('participant:updated', this.onParticipantUpdated.bind(this)).on('metadata:changed', this.onMetadataChanged.bind(this)).on('disconnect', this.onDisconnected.bind(this)).on('error', this.onErrorHandled.bind(this)).connect();
88
90
  });
89
91
 
90
92
  _defineProperty(this, "onStepsAdded", data => {
@@ -248,6 +250,7 @@ export class Provider extends Emitter {
248
250
 
249
251
  _defineProperty(this, "onMetadataChanged", metadata => {
250
252
  if (metadata !== undefined && !isequal(this.metadata, metadata)) {
253
+ this.metadata = metadata;
251
254
  this.emit('metadata:changed', metadata);
252
255
  }
253
256
  });
@@ -420,6 +423,46 @@ export class Provider extends Emitter {
420
423
  }
421
424
  });
422
425
 
426
+ _defineProperty(this, "getFinalAcknowledgedState", async () => {
427
+ var _this$getUnconfirmedS, _this$metadata$title;
428
+
429
+ const maxAttemptsToSync = ACK_MAX_TRY;
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
+ });
452
+ }
453
+
454
+ throw new Error("Can't syncup with Collab Service");
455
+ }
456
+ }
457
+
458
+ const state = this.getState();
459
+ return {
460
+ content: state.doc.toJSON(),
461
+ title: (_this$metadata$title = this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
462
+ stepVersion: getVersion(state)
463
+ };
464
+ });
465
+
423
466
  this.config = config;
424
467
  this.channel = new Channel(config);
425
468
  this.isChannelInitialized = false;
@@ -429,11 +472,23 @@ export class Provider extends Emitter {
429
472
  }
430
473
  }
431
474
 
432
- initialize(optionsOrGetState) {
433
- // move this
434
- this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
435
- this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
436
- this.getState().plugins.find(p => p.key === 'collab$').spec.config.clientID : optionsOrGetState.clientId;
475
+ /**
476
+ * Called by collab plugin in editor when it's ready to
477
+ * initialize a collab session.
478
+ */
479
+ initialize(getState) {
480
+ return this.setup({
481
+ getState
482
+ });
483
+ }
484
+
485
+ setup({
486
+ getState,
487
+ onSyncUpError
488
+ }) {
489
+ this.getState = getState;
490
+ this.onSyncUpError = onSyncUpError || noop;
491
+ this.clientId = getState().plugins.find(p => p.key === 'collab$').spec.config.clientID;
437
492
 
438
493
  if (!this.isChannelInitialized) {
439
494
  this.initializeChannel();
@@ -652,43 +707,10 @@ export class Provider extends Emitter {
652
707
  this.channel.sendMetadata(metadata);
653
708
  Object.assign(this.metadata, metadata);
654
709
  }
655
- /**
656
- * Get latest state.
657
- *
658
- * NOTE: Should this actually convert to ADF instead?
659
- */
660
-
661
-
662
- async getFinalAcknowledgedState() {
663
- var _this$getUnconfirmedS;
664
-
665
- const state = this.getState();
666
- let count = 0;
667
- let unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps);
668
710
 
669
- while (unconfirmedSteps && unconfirmedSteps.length) {
670
- var _this$getUnconfirmedS2;
671
-
672
- this.sendStepsFromCurrentState();
673
- await sleep(500);
674
- unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS2 = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps);
675
-
676
- if (count++ >= ACK_MAX_TRY) {
677
- throw new Error("Can't syncup with Collab Service");
678
- }
679
- }
680
-
681
- return {
682
- content: state.doc.toJSON(),
683
- title: this.metadata.title,
684
- stepVersion: getVersion(state)
685
- };
686
- }
687
711
  /**
688
712
  * Unsubscribe from all events emitted by this provider.
689
713
  */
690
-
691
-
692
714
  unsubscribeAll() {
693
715
  super.unsubscribeAll();
694
716
  this.channel.disconnect();
@@ -1,10 +1,9 @@
1
1
  import { Provider } from './provider';
2
2
  import { io } from 'socket.io-client';
3
- import urlParse from 'url-parse';
4
3
  export function createSocketIOSocket(url, auth) {
5
4
  const {
6
5
  pathname
7
- } = urlParse(url);
6
+ } = new URL(url);
8
7
  return io(url, {
9
8
  withCredentials: true,
10
9
  transports: ['polling', 'websocket'],
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.1.4",
3
+ "version": "7.1.7",
4
4
  "sideEffects": false
5
5
  }
@@ -43,6 +43,8 @@ export var CATCHUP_THROTTLE = 1 * 1000; // 1 second
43
43
 
44
44
  var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
45
45
 
46
+ var noop = function noop() {};
47
+
46
48
  export var MAX_STEP_REJECTED_ERROR = 15;
47
49
 
48
50
  var commitStep = function commitStep(_ref) {
@@ -116,7 +118,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
116
118
  version: version,
117
119
  metadata: metadata
118
120
  });
119
- }).on('steps:added', _this.onStepsAdded).on('participant:telepointer', _this.onParticipantTelepointer).on('presence:joined', _this.onPresenceJoined).on('presence', _this.onPresence).on('participant:left', _this.onParticipantLeft).on('participant:updated', _this.onParticipantUpdated).on('metadata:changed', _this.onMetadataChanged).on('disconnect', _this.onDisconnected).on('error', _this.onErrorHandled).connect();
121
+ }).on('steps:added', _this.onStepsAdded.bind(_assertThisInitialized(_this))).on('participant:telepointer', _this.onParticipantTelepointer.bind(_assertThisInitialized(_this))).on('presence:joined', _this.onPresenceJoined.bind(_assertThisInitialized(_this))).on('presence', _this.onPresence.bind(_assertThisInitialized(_this))).on('participant:left', _this.onParticipantLeft.bind(_assertThisInitialized(_this))).on('participant:updated', _this.onParticipantUpdated.bind(_assertThisInitialized(_this))).on('metadata:changed', _this.onMetadataChanged.bind(_assertThisInitialized(_this))).on('disconnect', _this.onDisconnected.bind(_assertThisInitialized(_this))).on('error', _this.onErrorHandled.bind(_assertThisInitialized(_this))).connect();
120
122
  });
121
123
 
122
124
  _defineProperty(_assertThisInitialized(_this), "onStepsAdded", function (data) {
@@ -316,6 +318,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
316
318
 
317
319
  _defineProperty(_assertThisInitialized(_this), "onMetadataChanged", function (metadata) {
318
320
  if (metadata !== undefined && !isequal(_this.metadata, metadata)) {
321
+ _this.metadata = metadata;
322
+
319
323
  _this.emit('metadata:changed', metadata);
320
324
  }
321
325
  });
@@ -523,6 +527,72 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
523
527
  }
524
528
  });
525
529
 
530
+ _defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
531
+ var _this$getUnconfirmedS, _this$metadata$title;
532
+
533
+ var maxAttemptsToSync, count, unconfirmedSteps, _this$getUnconfirmedS2, _unconfirmedSteps, _state, state;
534
+
535
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
536
+ while (1) {
537
+ switch (_context3.prev = _context3.next) {
538
+ case 0:
539
+ maxAttemptsToSync = ACK_MAX_TRY;
540
+ 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;
556
+
557
+ if (!(count++ >= maxAttemptsToSync)) {
558
+ _context3.next = 11;
559
+ break;
560
+ }
561
+
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:
581
+ state = _this.getState();
582
+ return _context3.abrupt("return", {
583
+ content: state.doc.toJSON(),
584
+ title: (_this$metadata$title = _this.metadata.title) === null || _this$metadata$title === void 0 ? void 0 : _this$metadata$title.toString(),
585
+ stepVersion: getVersion(state)
586
+ });
587
+
588
+ case 15:
589
+ case "end":
590
+ return _context3.stop();
591
+ }
592
+ }
593
+ }, _callee3);
594
+ })));
595
+
526
596
  _this.config = config;
527
597
  _this.channel = new Channel(config);
528
598
  _this.isChannelInitialized = false;
@@ -536,13 +606,26 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
536
606
 
537
607
  _createClass(Provider, [{
538
608
  key: "initialize",
539
- value: function initialize(optionsOrGetState) {
540
- // move this
541
- this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
542
- this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
543
- this.getState().plugins.find(function (p) {
609
+ value:
610
+ /**
611
+ * Called by collab plugin in editor when it's ready to
612
+ * initialize a collab session.
613
+ */
614
+ function initialize(getState) {
615
+ return this.setup({
616
+ getState: getState
617
+ });
618
+ }
619
+ }, {
620
+ key: "setup",
621
+ value: function setup(_ref16) {
622
+ var getState = _ref16.getState,
623
+ onSyncUpError = _ref16.onSyncUpError;
624
+ this.getState = getState;
625
+ this.onSyncUpError = onSyncUpError || noop;
626
+ this.clientId = getState().plugins.find(function (p) {
544
627
  return p.key === 'collab$';
545
- }).spec.config.clientID : optionsOrGetState.clientId;
628
+ }).spec.config.clientID;
546
629
 
547
630
  if (!this.isChannelInitialized) {
548
631
  this.initializeChannel();
@@ -647,8 +730,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
647
730
  logger("Processing data. Version \"".concat(version, "\"."));
648
731
 
649
732
  if (steps && steps.length) {
650
- var clientIds = steps.map(function (_ref15) {
651
- var clientId = _ref15.clientId;
733
+ var clientIds = steps.map(function (_ref17) {
734
+ var clientId = _ref17.clientId;
652
735
  return clientId;
653
736
  });
654
737
  this.emit('data', {
@@ -711,14 +794,14 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
711
794
  participant = _Array$from$filter2[0];
712
795
 
713
796
  if (participant) {
714
- var _ref16 = step,
715
- stepType = _ref16.stepType,
716
- to = _ref16.to,
717
- from = _ref16.from,
718
- _ref16$slice = _ref16.slice,
719
- slice = _ref16$slice === void 0 ? {
797
+ var _ref18 = step,
798
+ stepType = _ref18.stepType,
799
+ to = _ref18.to,
800
+ from = _ref18.from,
801
+ _ref18$slice = _ref18.slice,
802
+ slice = _ref18$slice === void 0 ? {
720
803
  content: []
721
- } : _ref16$slice;
804
+ } : _ref18$slice;
722
805
 
723
806
  var _slice$content = _slicedToArray(slice.content, 1),
724
807
  node = _slice$content[0];
@@ -779,80 +862,13 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
779
862
  this.channel.sendMetadata(metadata);
780
863
  Object.assign(this.metadata, metadata);
781
864
  }
782
- /**
783
- * Get latest state.
784
- *
785
- * NOTE: Should this actually convert to ADF instead?
786
- */
787
-
788
865
  }, {
789
- key: "getFinalAcknowledgedState",
790
- value: function () {
791
- var _getFinalAcknowledgedState = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
792
- var _this$getUnconfirmedS;
793
-
794
- var state, count, unconfirmedSteps, _this$getUnconfirmedS2;
795
-
796
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
797
- while (1) {
798
- switch (_context3.prev = _context3.next) {
799
- case 0:
800
- state = this.getState();
801
- count = 0;
802
- unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS === void 0 ? void 0 : _this$getUnconfirmedS.steps);
803
-
804
- case 3:
805
- if (!(unconfirmedSteps && unconfirmedSteps.length)) {
806
- _context3.next = 12;
807
- break;
808
- }
809
-
810
- this.sendStepsFromCurrentState();
811
- _context3.next = 7;
812
- return sleep(500);
813
-
814
- case 7:
815
- unconfirmedSteps = this.getUnconfirmedSteps() && ((_this$getUnconfirmedS2 = this.getUnconfirmedSteps()) === null || _this$getUnconfirmedS2 === void 0 ? void 0 : _this$getUnconfirmedS2.steps);
816
-
817
- if (!(count++ >= ACK_MAX_TRY)) {
818
- _context3.next = 10;
819
- break;
820
- }
821
-
822
- throw new Error("Can't syncup with Collab Service");
823
-
824
- case 10:
825
- _context3.next = 3;
826
- break;
827
-
828
- case 12:
829
- return _context3.abrupt("return", {
830
- content: state.doc.toJSON(),
831
- title: this.metadata.title,
832
- stepVersion: getVersion(state)
833
- });
834
-
835
- case 13:
836
- case "end":
837
- return _context3.stop();
838
- }
839
- }
840
- }, _callee3, this);
841
- }));
842
-
843
- function getFinalAcknowledgedState() {
844
- return _getFinalAcknowledgedState.apply(this, arguments);
845
- }
846
-
847
- return getFinalAcknowledgedState;
848
- }()
866
+ key: "unsubscribeAll",
867
+ value:
849
868
  /**
850
869
  * Unsubscribe from all events emitted by this provider.
851
870
  */
852
-
853
- }, {
854
- key: "unsubscribeAll",
855
- value: function unsubscribeAll() {
871
+ function unsubscribeAll() {
856
872
  _get(_getPrototypeOf(Provider.prototype), "unsubscribeAll", this).call(this);
857
873
 
858
874
  this.channel.disconnect();
@@ -6,10 +6,9 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
6
6
 
7
7
  import { Provider } from './provider';
8
8
  import { io } from 'socket.io-client';
9
- import urlParse from 'url-parse';
10
9
  export function createSocketIOSocket(url, auth) {
11
- var _urlParse = urlParse(url),
12
- pathname = _urlParse.pathname;
10
+ var _URL = new URL(url),
11
+ pathname = _URL.pathname;
13
12
 
14
13
  return io(url, {
15
14
  withCredentials: true,
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.1.4",
3
+ "version": "7.1.7",
4
4
  "sideEffects": false
5
5
  }
@@ -1,6 +1,6 @@
1
1
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
2
2
  import { GasPurePayload } from '@atlaskit/analytics-gas-types';
3
- import { ErrorPayload } from '../channel';
3
+ import { ErrorPayload } from '../types';
4
4
  export declare const buildAnalyticsPayload: (subject: string, payload?: any) => GasPurePayload;
5
5
  export declare const fireAnalyticsEvent: (analyticsClient?: AnalyticsWebClient | undefined, analyticsEvent?: GasPurePayload | undefined) => void;
6
6
  export declare const triggerAnalyticsForStepsAddedSuccessfully: (analyticsClient?: AnalyticsWebClient | undefined) => void;
@@ -1,74 +1,5 @@
1
1
  import { Emitter } from './emitter';
2
- import { Config, Socket } from './types';
3
- export interface Metadata {
4
- [key: string]: string | number | boolean;
5
- }
6
- export declare type InitPayload = {
7
- doc: any;
8
- version: number;
9
- userId?: string;
10
- metadata?: Metadata;
11
- };
12
- export declare type PresencePayload = {
13
- sessionId: string;
14
- userId: string;
15
- clientId: string;
16
- timestamp: number;
17
- };
18
- export declare type TelepointerPayload = PresencePayload & {
19
- selection: {
20
- type: 'textSelection' | 'nodeSelection';
21
- anchor: number;
22
- head: number;
23
- };
24
- };
25
- export declare type StepJson = {
26
- from?: number;
27
- to?: number;
28
- stepType?: string;
29
- clientId: string;
30
- userId: string;
31
- };
32
- export declare type StepsPayload = {
33
- version: number;
34
- steps: StepJson[];
35
- };
36
- export declare type ErrorPayload = {
37
- message: string;
38
- data?: {
39
- status: number;
40
- code?: string;
41
- meta?: string;
42
- };
43
- };
44
- export declare type ChannelEvent = {
45
- connected: {
46
- sid: string;
47
- initialized: boolean;
48
- };
49
- init: InitPayload;
50
- reconnected: null;
51
- 'presence:joined': PresencePayload;
52
- presence: PresencePayload;
53
- 'participant:left': PresencePayload;
54
- 'participant:telepointer': TelepointerPayload;
55
- 'participant:updated': PresencePayload;
56
- 'steps:commit': StepsPayload & {
57
- userId: string;
58
- };
59
- 'steps:added': StepsPayload;
60
- 'metadata:changed': Metadata;
61
- error: ErrorPayload;
62
- disconnect: {
63
- reason: string;
64
- };
65
- };
66
- export interface CatchupResponse {
67
- doc?: string;
68
- version?: number;
69
- stepMaps?: any[];
70
- metadata?: Metadata;
71
- }
2
+ import type { Config, Socket, ChannelEvent, CatchupResponse, Metadata } from './types';
72
3
  export declare class Channel extends Emitter<ChannelEvent> {
73
4
  private connected;
74
5
  private config;
@@ -1,5 +1,4 @@
1
- import { ErrorPayload } from './channel';
2
- import { CollabErrorPayload } from './provider';
1
+ import type { CollabErrorPayload, ErrorPayload } from './types';
3
2
  export declare const ErrorCodeMapper: {
4
3
  noPermissionError: {
5
4
  code: string;
@@ -1,3 +1,2 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, } from './provider';
3
- export type { Socket } from './types';
2
+ export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, Socket, } from './types';
@@ -1,20 +1,5 @@
1
- import { StepsPayload, CatchupResponse } from '../channel';
2
- import { CollabInitPayload } from '.';
1
+ import type { CatchupOptions } from '../types';
3
2
  import { Mapping, Step } from 'prosemirror-transform';
4
- import { Transaction } from 'prosemirror-state';
5
- export interface CatchupOptions {
6
- getCurrentPmVersion: () => number;
7
- fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>;
8
- fitlerQueue: (condition: (stepsPayload: StepsPayload) => boolean) => void;
9
- getUnconfirmedSteps: () => {
10
- version: number;
11
- steps: Step<any>[];
12
- clientID: string | number;
13
- origins: Transaction<any>[];
14
- } | null | undefined;
15
- updateDocumentWithMetadata: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
16
- applyLocalsteps: (steps: Step[]) => void;
17
- }
18
3
  /**
19
4
  * Rebase the steps based on the mapping pipeline.
20
5
  * Some steps could be lost, if they are no longer
@@ -1,57 +1,11 @@
1
1
  import { EditorState, Transaction } from 'prosemirror-state';
2
- import { Step } from 'prosemirror-transform';
3
2
  import { Emitter } from '../emitter';
4
- import { Metadata, StepJson } from '../channel';
5
- import { CollabEditProvider, CollabEventTelepointerData as EditorCollabTelepointerData, CollabEventConnectionData as EditorCollabConnetedData, CollabEventInitData as EditorCollabInitData, CollabEventRemoteData as EditorCollabData, CollabEventPresenceData as EditorCollabPresenceData } from '@atlaskit/editor-common/collab';
6
- import { Config } from '../types';
7
- import { DisconnectReason } from '../disconnected-reason-mapper';
3
+ import { CollabEditProvider, ResolvedEditorState } from '@atlaskit/editor-common/collab';
4
+ import type { Config, Metadata, CollabEvents } from '../types';
5
+ import { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
8
6
  export declare const CATCHUP_THROTTLE: number;
9
7
  export declare const MAX_STEP_REJECTED_ERROR = 15;
10
- export declare type CollabConnectedPayload = EditorCollabConnetedData;
11
- export interface CollabDisconnectedPayload {
12
- reason: DisconnectReason;
13
- sid: string;
14
- }
15
- export interface CollabErrorPayload {
16
- status: number;
17
- code: string;
18
- message: string;
19
- }
20
- export interface CollabInitPayload extends EditorCollabInitData {
21
- doc: any;
22
- version: number;
23
- userId?: string;
24
- metadata?: Metadata;
25
- }
26
- export interface CollabDataPayload extends EditorCollabData {
27
- version: number;
28
- json: StepJson[];
29
- userIds: string[];
30
- }
31
- export declare type CollabTelepointerPayload = EditorCollabTelepointerData;
32
- export declare type CollabPresencePayload = EditorCollabPresenceData;
33
- export declare type CollabMetadataPayload = Metadata;
34
- export declare type CollabLocalStepsPayload = {
35
- steps: Step[];
36
- };
37
- export interface CollabEvents {
38
- 'metadata:changed': CollabMetadataPayload;
39
- init: CollabInitPayload;
40
- connected: CollabConnectedPayload;
41
- disconnected: CollabDisconnectedPayload;
42
- data: CollabDataPayload;
43
- telepointer: CollabTelepointerPayload;
44
- presence: CollabPresencePayload;
45
- 'local-steps': CollabLocalStepsPayload;
46
- error: CollabErrorPayload;
47
- entity: any;
48
- }
49
- declare type EditorStateGetter = () => EditorState;
50
- declare type InitializeOptions = {
51
- getState: EditorStateGetter;
52
- clientId: string;
53
- };
54
- declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'initialize' | 'send' | 'sendMessage'>;
8
+ declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
55
9
  export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
56
10
  private participants;
57
11
  private channel;
@@ -61,6 +15,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
61
15
  private stepRejectCounter;
62
16
  private analyticsClient?;
63
17
  private isChannelInitialized;
18
+ private onSyncUpError?;
64
19
  private sessionId?;
65
20
  private clientId?;
66
21
  private userId?;
@@ -73,8 +28,11 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
73
28
  * Called by collab plugin in editor when it's ready to
74
29
  * initialize a collab session.
75
30
  */
76
- initialize(getState: EditorStateGetter): this;
77
- initialize(options: InitializeOptions): this;
31
+ initialize(getState: () => EditorState): this;
32
+ setup({ getState, onSyncUpError, }: {
33
+ getState: () => EditorState;
34
+ onSyncUpError?: SyncUpErrorFunction;
35
+ }): this;
78
36
  /**
79
37
  * We can use this function to throttle/delay
80
38
  * Any send steps operation
@@ -157,18 +115,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
157
115
  setTitle(title: string, broadcast?: boolean): void;
158
116
  setEditorWidth(editorWidth: string, broadcast?: boolean): void;
159
117
  setMetadata(metadata: Metadata): void;
160
- /**
161
- * Get latest state.
162
- *
163
- * NOTE: Should this actually convert to ADF instead?
164
- */
165
- getFinalAcknowledgedState(): Promise<{
166
- content: {
167
- [key: string]: any;
168
- };
169
- title: string | number | boolean;
170
- stepVersion: number;
171
- }>;
118
+ getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
172
119
  /**
173
120
  * Unsubscribe from all events emitted by this provider.
174
121
  */
@@ -1,6 +1,9 @@
1
- import { CollabParticipant } from '@atlaskit/editor-common/collab';
2
- import { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
3
- import { Manager } from 'socket.io-client';
1
+ import type { Transaction } from 'prosemirror-state';
2
+ import type { Step } from 'prosemirror-transform';
3
+ import type { CollabParticipant, CollabEventTelepointerData as EditorCollabTelepointerData, CollabEventConnectionData as EditorCollabConnetedData, CollabEventInitData as EditorCollabInitData, CollabEventRemoteData as EditorCollabData, CollabEventPresenceData as EditorCollabPresenceData } from '@atlaskit/editor-common/collab';
4
+ import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
5
+ import type { Manager } from 'socket.io-client';
6
+ import type { DisconnectReason } from './disconnected-reason-mapper';
4
7
  export interface Storage {
5
8
  get(key: string): Promise<string>;
6
9
  set(key: string, value: string): Promise<void>;
@@ -33,4 +36,125 @@ export declare type EventHandler = () => void;
33
36
  export interface Lifecycle {
34
37
  on(event: LifecycleEvents, handler: EventHandler): void;
35
38
  }
39
+ export declare type CollabConnectedPayload = EditorCollabConnetedData;
40
+ export interface CollabDisconnectedPayload {
41
+ reason: DisconnectReason;
42
+ sid: string;
43
+ }
44
+ export interface CollabErrorPayload {
45
+ status: number;
46
+ code: string;
47
+ message: string;
48
+ }
49
+ export interface CollabInitPayload extends EditorCollabInitData {
50
+ doc: any;
51
+ version: number;
52
+ userId?: string;
53
+ metadata?: Metadata;
54
+ }
55
+ export interface CollabDataPayload extends EditorCollabData {
56
+ version: number;
57
+ json: StepJson[];
58
+ userIds: string[];
59
+ }
60
+ export declare type CollabTelepointerPayload = EditorCollabTelepointerData;
61
+ export declare type CollabPresencePayload = EditorCollabPresenceData;
62
+ export declare type CollabMetadataPayload = Metadata;
63
+ export declare type CollabLocalStepsPayload = {
64
+ steps: Step[];
65
+ };
66
+ export interface CollabEvents {
67
+ 'metadata:changed': CollabMetadataPayload;
68
+ init: CollabInitPayload;
69
+ connected: CollabConnectedPayload;
70
+ disconnected: CollabDisconnectedPayload;
71
+ data: CollabDataPayload;
72
+ telepointer: CollabTelepointerPayload;
73
+ presence: CollabPresencePayload;
74
+ 'local-steps': CollabLocalStepsPayload;
75
+ error: CollabErrorPayload;
76
+ entity: any;
77
+ }
78
+ export interface Metadata {
79
+ [key: string]: string | number | boolean;
80
+ }
81
+ export declare type InitPayload = {
82
+ doc: any;
83
+ version: number;
84
+ userId?: string;
85
+ metadata?: Metadata;
86
+ };
87
+ export declare type PresencePayload = {
88
+ sessionId: string;
89
+ userId: string;
90
+ clientId: string;
91
+ timestamp: number;
92
+ };
93
+ export declare type TelepointerPayload = PresencePayload & {
94
+ selection: {
95
+ type: 'textSelection' | 'nodeSelection';
96
+ anchor: number;
97
+ head: number;
98
+ };
99
+ };
100
+ export declare type StepJson = {
101
+ from?: number;
102
+ to?: number;
103
+ stepType?: string;
104
+ clientId: string;
105
+ userId: string;
106
+ };
107
+ export declare type StepsPayload = {
108
+ version: number;
109
+ steps: StepJson[];
110
+ };
111
+ export declare type ErrorPayload = {
112
+ message: string;
113
+ data?: {
114
+ status: number;
115
+ code?: string;
116
+ meta?: string;
117
+ };
118
+ };
119
+ export declare type ChannelEvent = {
120
+ connected: {
121
+ sid: string;
122
+ initialized: boolean;
123
+ };
124
+ init: InitPayload;
125
+ reconnected: null;
126
+ 'presence:joined': PresencePayload;
127
+ presence: PresencePayload;
128
+ 'participant:left': PresencePayload;
129
+ 'participant:telepointer': TelepointerPayload;
130
+ 'participant:updated': PresencePayload;
131
+ 'steps:commit': StepsPayload & {
132
+ userId: string;
133
+ };
134
+ 'steps:added': StepsPayload;
135
+ 'metadata:changed': Metadata;
136
+ error: ErrorPayload;
137
+ disconnect: {
138
+ reason: string;
139
+ };
140
+ };
141
+ export interface CatchupResponse {
142
+ doc?: string;
143
+ version?: number;
144
+ stepMaps?: any[];
145
+ metadata?: Metadata;
146
+ }
147
+ export interface CatchupOptions {
148
+ getCurrentPmVersion: () => number;
149
+ fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>;
150
+ fitlerQueue: (condition: (stepsPayload: StepsPayload) => boolean) => void;
151
+ getUnconfirmedSteps: () => {
152
+ version: number;
153
+ steps: Step<any>[];
154
+ clientID: string | number;
155
+ origins: Transaction<any>[];
156
+ } | null | undefined;
157
+ updateDocumentWithMetadata: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
158
+ applyLocalsteps: (steps: Step[]) => void;
159
+ }
36
160
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "7.1.4",
3
+ "version": "7.1.7",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -22,8 +22,9 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@atlaskit/analytics-gas-types": "5.0.5",
25
- "@atlaskit/analytics-listeners": "^8.0.0",
26
- "@atlaskit/editor-common": "^63.0.0",
25
+ "@atlaskit/analytics-listeners": "^8.2.0",
26
+ "@atlaskit/editor-common": "^65.0.0",
27
+ "@atlaskit/editor-json-transformer": "^8.7.0",
27
28
  "@atlaskit/util-service-support": "^6.1.0",
28
29
  "@babel/runtime": "^7.0.0",
29
30
  "eventemitter2": "^4.1.0",
@@ -31,8 +32,7 @@
31
32
  "prosemirror-collab": "^1.2.2",
32
33
  "prosemirror-state": "1.3.4",
33
34
  "prosemirror-transform": "1.3.2",
34
- "socket.io-client": "^4.0.0",
35
- "url-parse": "^1.4.5"
35
+ "socket.io-client": "^4.0.0"
36
36
  },
37
37
  "techstack": {
38
38
  "@atlassian/frontend": {
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "devDependencies": {
46
- "@atlaskit/editor-test-helpers": "^16.0.0",
46
+ "@atlaskit/editor-test-helpers": "^16.1.0",
47
47
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
48
48
  "@types/prosemirror-collab": "^1.1.1",
49
49
  "@types/prosemirror-model": "^1.11.0",