@atlaskit/collab-provider 9.38.0 → 9.39.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/cjs/api/null-api.js +38 -0
  3. package/dist/cjs/channel.js +8 -7
  4. package/dist/cjs/document/catchupv2.js +1 -1
  5. package/dist/cjs/document/document-service.js +74 -66
  6. package/dist/cjs/document/interface-document-service.js +5 -0
  7. package/dist/cjs/document/null-document-service.js +64 -0
  8. package/dist/cjs/helpers/const.js +11 -2
  9. package/dist/cjs/provider/index.js +52 -23
  10. package/dist/cjs/version-wrapper.js +1 -1
  11. package/dist/es2019/api/null-api.js +6 -0
  12. package/dist/es2019/channel.js +3 -2
  13. package/dist/es2019/document/catchupv2.js +1 -1
  14. package/dist/es2019/document/document-service.js +11 -8
  15. package/dist/es2019/document/interface-document-service.js +1 -0
  16. package/dist/es2019/document/null-document-service.js +29 -0
  17. package/dist/es2019/helpers/const.js +10 -1
  18. package/dist/es2019/provider/index.js +49 -22
  19. package/dist/es2019/version-wrapper.js +1 -1
  20. package/dist/esm/api/null-api.js +31 -0
  21. package/dist/esm/channel.js +8 -7
  22. package/dist/esm/document/catchupv2.js +1 -1
  23. package/dist/esm/document/document-service.js +75 -67
  24. package/dist/esm/document/interface-document-service.js +1 -0
  25. package/dist/esm/document/null-document-service.js +57 -0
  26. package/dist/esm/helpers/const.js +10 -1
  27. package/dist/esm/provider/index.js +53 -24
  28. package/dist/esm/version-wrapper.js +1 -1
  29. package/dist/types/api/null-api.d.ts +5 -0
  30. package/dist/types/channel.d.ts +2 -1
  31. package/dist/types/document/document-service.d.ts +7 -3
  32. package/dist/types/document/interface-document-service.d.ts +35 -0
  33. package/dist/types/document/null-document-service.d.ts +17 -0
  34. package/dist/types/helpers/const.d.ts +7 -0
  35. package/dist/types/provider/index.d.ts +3 -1
  36. package/dist/types/types.d.ts +4 -1
  37. package/dist/types-ts4.5/api/null-api.d.ts +5 -0
  38. package/dist/types-ts4.5/channel.d.ts +2 -1
  39. package/dist/types-ts4.5/document/document-service.d.ts +7 -3
  40. package/dist/types-ts4.5/document/interface-document-service.d.ts +35 -0
  41. package/dist/types-ts4.5/document/null-document-service.d.ts +17 -0
  42. package/dist/types-ts4.5/helpers/const.d.ts +7 -0
  43. package/dist/types-ts4.5/provider/index.d.ts +3 -1
  44. package/dist/types-ts4.5/types.d.ts +4 -1
  45. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#138046](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/138046)
8
+ [`0291f7bee806e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/0291f7bee806e) -
9
+ HOT-111468: specifically for experiment teammate presence - add a new method
10
+ `setupPresenceOnly_do_not_use`, and opt out the document service and api by implementing the
11
+ `NullDocumentService` and `NullApi` objects when passed in by calling the new setup method, make
12
+ sure to pass in `clientId`
13
+
14
+ ## 9.38.1
15
+
16
+ ### Patch Changes
17
+
18
+ - [#136958](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/136958)
19
+ [`e1fd99410b2a7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/e1fd99410b2a7) -
20
+ Adding reasons for BE catchup calls
21
+ - Updated dependencies
22
+
3
23
  ## 9.38.0
4
24
 
5
25
  ### Minor Changes
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.NullApi = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
12
+ // A mock for the actual Api class designed for the experiment teammate presence (ATLAS-53155)
13
+ var NullApi = exports.NullApi = /*#__PURE__*/function () {
14
+ function NullApi() {
15
+ (0, _classCallCheck2.default)(this, NullApi);
16
+ }
17
+ (0, _createClass2.default)(NullApi, [{
18
+ key: "addComment",
19
+ value: function () {
20
+ var _addComment = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
21
+ return _regenerator.default.wrap(function _callee$(_context) {
22
+ while (1) switch (_context.prev = _context.next) {
23
+ case 0:
24
+ return _context.abrupt("return");
25
+ case 1:
26
+ case "end":
27
+ return _context.stop();
28
+ }
29
+ }, _callee);
30
+ }));
31
+ function addComment() {
32
+ return _addComment.apply(this, arguments);
33
+ }
34
+ return addComment;
35
+ }()
36
+ }]);
37
+ return NullApi;
38
+ }();
@@ -305,7 +305,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
305
305
  };
306
306
  }());
307
307
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchCatchupv2", /*#__PURE__*/function () {
308
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(fromVersion, clientId, catchUpOutofSync) {
308
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(fromVersion, clientId, catchUpOutofSync, reason) {
309
309
  var _yield$utils$requestS2, steps, metadata, errorNotFound, errorCatchupv2;
310
310
  return _regenerator.default.wrap(function _callee3$(_context3) {
311
311
  while (1) switch (_context3.prev = _context3.next) {
@@ -317,7 +317,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
317
317
  _context3.t3 = {
318
318
  version: fromVersion,
319
319
  clientId: clientId,
320
- catchUpOutofSync: catchUpOutofSync
320
+ catchUpOutofSync: catchUpOutofSync,
321
+ reason: reason
321
322
  };
322
323
  _context3.next = 7;
323
324
  return _this.commonHeaders();
@@ -374,7 +375,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
374
375
  }
375
376
  }, _callee3, null, [[0, 18]]);
376
377
  }));
377
- return function (_x3, _x4, _x5) {
378
+ return function (_x3, _x4, _x5, _x6) {
378
379
  return _ref3.apply(this, arguments);
379
380
  };
380
381
  }());
@@ -432,7 +433,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
432
433
  }
433
434
  }, _callee4, null, [[0, 24]]);
434
435
  }));
435
- return function (_x6, _x7) {
436
+ return function (_x7, _x8) {
436
437
  return _ref4.apply(this, arguments);
437
438
  };
438
439
  }());
@@ -567,7 +568,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
567
568
  }
568
569
  }, _callee5, null, [[1, 9]]);
569
570
  }));
570
- return function auth(_x8) {
571
+ return function auth(_x9) {
571
572
  return _ref5.apply(this, arguments);
572
573
  };
573
574
  }();
@@ -592,7 +593,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
592
593
  }
593
594
  }, _callee6);
594
595
  }));
595
- return function auth(_x9) {
596
+ return function auth(_x10) {
596
597
  return _ref6.apply(this, arguments);
597
598
  };
598
599
  }();
@@ -687,7 +688,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
687
688
  }
688
689
  }, _callee7);
689
690
  }));
690
- return function (_x10) {
691
+ return function (_x11) {
691
692
  return _ref11.apply(this, arguments);
692
693
  };
693
694
  }());
@@ -18,7 +18,7 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
18
18
  fromVersion = opt.getCurrentPmVersion();
19
19
  _context.prev = 1;
20
20
  _context.next = 4;
21
- return opt.fetchCatchupv2(fromVersion, opt.clientId, opt.catchUpOutofSync);
21
+ return opt.fetchCatchupv2(fromVersion, opt.clientId, opt.catchUpOutofSync, opt.reason);
22
22
  case 4:
23
23
  _yield$opt$fetchCatch = _context.sent;
24
24
  steps = _yield$opt$fetchCatch.steps;
@@ -129,9 +129,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
129
129
  })));
130
130
  /**
131
131
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
132
+ * @param reason - optional reason to attach.
132
133
  */
133
- (0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function () {
134
- return _this.catchupv2();
134
+ (0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function (reason) {
135
+ return _this.catchupv2(reason);
135
136
  }, CATCHUP_THROTTLE, {
136
137
  leading: false,
137
138
  // TODO: why shouldn't this be leading?
@@ -141,67 +142,74 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
141
142
  * Called when:
142
143
  * * session established(offline -> online)
143
144
  * * try to accept steps but version is behind.
145
+ * @param reason - optional reason to attach.
144
146
  */
145
- (0, _defineProperty2.default)(this, "catchupv2", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
146
- var start, _this$analyticsHelper3, latency, _this$analyticsHelper4, _latency2;
147
- return _regenerator.default.wrap(function _callee2$(_context2) {
148
- while (1) switch (_context2.prev = _context2.next) {
149
- case 0:
150
- start = new Date().getTime(); // if the queue is already paused, we are busy with something else, so don't proceed.
151
- if (!_this.stepQueue.isPaused()) {
152
- _context2.next = 4;
153
- break;
154
- }
155
- logger("Queue is paused. Aborting.");
156
- return _context2.abrupt("return");
157
- case 4:
158
- if (!_this.isNameSpaceLocked()) {
159
- _context2.next = 7;
147
+ (0, _defineProperty2.default)(this, "catchupv2", /*#__PURE__*/function () {
148
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(reason) {
149
+ var start, _this$analyticsHelper3, latency, _this$analyticsHelper4, _latency2;
150
+ return _regenerator.default.wrap(function _callee2$(_context2) {
151
+ while (1) switch (_context2.prev = _context2.next) {
152
+ case 0:
153
+ start = new Date().getTime(); // if the queue is already paused, we are busy with something else, so don't proceed.
154
+ if (!_this.stepQueue.isPaused()) {
155
+ _context2.next = 4;
156
+ break;
157
+ }
158
+ logger("Queue is paused. Aborting.");
159
+ return _context2.abrupt("return");
160
+ case 4:
161
+ if (!_this.isNameSpaceLocked()) {
162
+ _context2.next = 7;
163
+ break;
164
+ }
165
+ logger("catchupv2: Document is locked. Aborting.");
166
+ return _context2.abrupt("return");
167
+ case 7:
168
+ _this.stepQueue.pauseQueue();
169
+ _context2.prev = 8;
170
+ _context2.next = 11;
171
+ return (0, _catchupv.catchupv2)({
172
+ getCurrentPmVersion: _this.getCurrentPmVersion,
173
+ fetchCatchupv2: _this.fetchCatchupv2,
174
+ updateMetadata: _this.metadataService.updateMetadata,
175
+ analyticsHelper: _this.analyticsHelper,
176
+ clientId: _this.clientId,
177
+ onStepsAdded: _this.onStepsAdded,
178
+ catchUpOutofSync: _this.catchUpOutofSync,
179
+ reason: reason
180
+ });
181
+ case 11:
182
+ _this.catchUpOutofSync = _context2.sent;
183
+ latency = new Date().getTime() - start;
184
+ (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.SUCCESS, {
185
+ latency: latency
186
+ });
187
+ _context2.next = 20;
160
188
  break;
161
- }
162
- logger("catchupv2: Document is locked. Aborting.");
163
- return _context2.abrupt("return");
164
- case 7:
165
- _this.stepQueue.pauseQueue();
166
- _context2.prev = 8;
167
- _context2.next = 11;
168
- return (0, _catchupv.catchupv2)({
169
- getCurrentPmVersion: _this.getCurrentPmVersion,
170
- fetchCatchupv2: _this.fetchCatchupv2,
171
- updateMetadata: _this.metadataService.updateMetadata,
172
- analyticsHelper: _this.analyticsHelper,
173
- clientId: _this.clientId,
174
- onStepsAdded: _this.onStepsAdded,
175
- catchUpOutofSync: _this.catchUpOutofSync
176
- });
177
- case 11:
178
- _this.catchUpOutofSync = _context2.sent;
179
- latency = new Date().getTime() - start;
180
- (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.SUCCESS, {
181
- latency: latency
182
- });
183
- _context2.next = 20;
184
- break;
185
- case 16:
186
- _context2.prev = 16;
187
- _context2.t0 = _context2["catch"](8);
188
- _latency2 = new Date().getTime() - start;
189
- (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.FAILURE, {
190
- latency: _latency2
191
- });
192
- case 20:
193
- _context2.prev = 20;
194
- _this.stepQueue.resumeQueue();
195
- _this.processQueue();
196
- _this.sendStepsFromCurrentState(); // this will eventually retry catchup as it calls throttledCommitStep which will either catchup on onStepsAdded or onErrorHandled
197
- _this.stepRejectCounter = 0;
198
- return _context2.finish(20);
199
- case 26:
200
- case "end":
201
- return _context2.stop();
202
- }
203
- }, _callee2, null, [[8, 16, 20, 26]]);
204
- })));
189
+ case 16:
190
+ _context2.prev = 16;
191
+ _context2.t0 = _context2["catch"](8);
192
+ _latency2 = new Date().getTime() - start;
193
+ (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.FAILURE, {
194
+ latency: _latency2
195
+ });
196
+ case 20:
197
+ _context2.prev = 20;
198
+ _this.stepQueue.resumeQueue();
199
+ _this.processQueue();
200
+ _this.sendStepsFromCurrentState(); // this will eventually retry catchup as it calls throttledCommitStep which will either catchup on onStepsAdded or onErrorHandled
201
+ _this.stepRejectCounter = 0;
202
+ return _context2.finish(20);
203
+ case 26:
204
+ case "end":
205
+ return _context2.stop();
206
+ }
207
+ }, _callee2, null, [[8, 16, 20, 26]]);
208
+ }));
209
+ return function (_x) {
210
+ return _ref2.apply(this, arguments);
211
+ };
212
+ }());
205
213
  (0, _defineProperty2.default)(this, "getCurrentPmVersion", function () {
206
214
  var _this$getState;
207
215
  var state = (_this$getState = _this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(_this);
@@ -299,7 +307,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
299
307
  } else if (data.version > expectedVersion) {
300
308
  logger("Version too high. Expected \"".concat(expectedVersion, "\" but got \"").concat(data.version, ". Current local version is ").concat(currentVersion, "."));
301
309
  _this.stepQueue.queueSteps(data);
302
- _this.throttledCatchupv2();
310
+ _this.throttledCatchupv2(_const.CatchupEventReason.STEPS_ADDED);
303
311
  }
304
312
  _this.participantsService.updateLastActive(data.steps.map(function (_ref4) {
305
313
  var userId = _ref4.userId;
@@ -399,7 +407,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
399
407
  }
400
408
  }, _callee4, null, [[8, 20]]);
401
409
  }));
402
- return function (_x) {
410
+ return function (_x2) {
403
411
  return _ref6.apply(this, arguments);
404
412
  };
405
413
  }());
@@ -644,7 +652,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
644
652
  var _this$analyticsHelper27;
645
653
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
646
654
  (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
647
- _this.throttledCatchupv2();
655
+ _this.throttledCatchupv2(_const.CatchupEventReason.STEPS_REJECTED);
648
656
  } else {
649
657
  // If committing steps failed try again automatically in 1s
650
658
  // This makes it more likely that unconfirmed steps trigger a catch-up
@@ -663,12 +671,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
663
671
  this.providerEmitCallback = providerEmitCallback;
664
672
  this.broadcast = broadcast;
665
673
  this.getUserId = getUserId;
666
- this.onErrorHandled = onErrorHandled;
667
674
  this.metadataService = metadataService;
668
675
  this.isNameSpaceLocked = isNameSpaceLocked;
669
676
  this.enableErrorOnFailedDocumentApply = enableErrorOnFailedDocumentApply;
670
677
  this.options = options;
671
678
  this.stepQueue = new _stepQueueState.StepQueueState();
679
+ this.onErrorHandled = onErrorHandled;
672
680
  }
673
681
  (0, _createClass2.default)(DocumentService, [{
674
682
  key: "processQueue",
@@ -722,7 +730,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
722
730
  var _this$analyticsHelper28;
723
731
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
724
732
  (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendErrorEvent(error, 'Error while processing steps');
725
- this.throttledCatchupv2();
733
+ this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
726
734
  }
727
735
  }
728
736
  }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.NullDocumentService = void 0;
8
+ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
+ // A Null object for the actual DocumentService class only for the experiment teammate presence (ATLAS-53155)
12
+ var NullDocumentService = exports.NullDocumentService = /*#__PURE__*/function () {
13
+ function NullDocumentService() {
14
+ var _this = this;
15
+ (0, _classCallCheck2.default)(this, NullDocumentService);
16
+ (0, _defineProperty2.default)(this, "setup", function () {
17
+ return _this;
18
+ });
19
+ (0, _defineProperty2.default)(this, "onErrorHandled", function () {});
20
+ }
21
+ (0, _createClass2.default)(NullDocumentService, [{
22
+ key: "updateDocument",
23
+ value: function updateDocument() {}
24
+ }, {
25
+ key: "onRestore",
26
+ value: function onRestore() {}
27
+ }, {
28
+ key: "onStepsAdded",
29
+ value: function onStepsAdded() {}
30
+ }, {
31
+ key: "onStepRejectedError",
32
+ value: function onStepRejectedError() {}
33
+ }, {
34
+ key: "send",
35
+ value: function send() {}
36
+ }, {
37
+ key: "sendStepsFromCurrentState",
38
+ value: function sendStepsFromCurrentState() {}
39
+ }, {
40
+ key: "throttledCatchupv2",
41
+ value: function throttledCatchupv2() {}
42
+ }, {
43
+ key: "getCurrentState",
44
+ value: function getCurrentState() {
45
+ return Promise.resolve({});
46
+ }
47
+ }, {
48
+ key: "getFinalAcknowledgedState",
49
+ value: function getFinalAcknowledgedState() {
50
+ return Promise.resolve({});
51
+ }
52
+ }, {
53
+ key: "getUnconfirmedSteps",
54
+ value: function getUnconfirmedSteps() {
55
+ return undefined;
56
+ }
57
+ }, {
58
+ key: "getCurrentPmVersion",
59
+ value: function getCurrentPmVersion() {
60
+ return -1;
61
+ }
62
+ }]);
63
+ return NullDocumentService;
64
+ }();
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.EVENT_STATUS = exports.EVENT_ACTION = exports.CONFLUENCE = exports.ADD_STEPS_TYPE = exports.ACK_MAX_TRY = void 0;
6
+ exports.EVENT_STATUS = exports.EVENT_ACTION = exports.CatchupEventReason = exports.CONFLUENCE = exports.ADD_STEPS_TYPE = exports.ACK_MAX_TRY = void 0;
7
7
  var EVENT_ACTION = exports.EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
8
8
  EVENT_ACTION["CONNECTION"] = "connection";
9
9
  EVENT_ACTION["CATCHUP"] = "catchup";
@@ -40,4 +40,13 @@ var ADD_STEPS_TYPE = exports.ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_T
40
40
  return ADD_STEPS_TYPE;
41
41
  }({});
42
42
  var ACK_MAX_TRY = exports.ACK_MAX_TRY = 60;
43
- var CONFLUENCE = exports.CONFLUENCE = 'confluence';
43
+ var CONFLUENCE = exports.CONFLUENCE = 'confluence';
44
+
45
+ /** Enumerable for attaching a reason to catchup (v2) call(s) */
46
+ var CatchupEventReason = exports.CatchupEventReason = /*#__PURE__*/function (CatchupEventReason) {
47
+ CatchupEventReason["STEPS_ADDED"] = "onStepsAdded";
48
+ CatchupEventReason["STEPS_REJECTED"] = "onStepsRejected";
49
+ CatchupEventReason["PROCESS_STEPS"] = "processSteps";
50
+ CatchupEventReason["RECONNECTED"] = "reconnected";
51
+ return CatchupEventReason;
52
+ }({});
@@ -25,6 +25,7 @@ var _customErrors = require("../errors/custom-errors");
25
25
  var _ncsErrors = require("../errors/ncs-errors");
26
26
  var _metadataService = require("../metadata/metadata-service");
27
27
  var _documentService = require("../document/document-service");
28
+ var _nullDocumentService = require("../document/null-document-service");
28
29
  var _namespaceService = require("../namespace/namespace-service");
29
30
  var _participantsService = require("../participants/participants-service");
30
31
  var _errorCodeMapper = require("../errors/error-code-mapper");
@@ -33,6 +34,7 @@ var _const = require("../helpers/const");
33
34
  var _featureFlags = require("../feature-flags");
34
35
  var _api = require("../api/api");
35
36
  var _performance = require("../analytics/performance");
37
+ var _nullApi = require("../api/null-api");
36
38
  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; }
37
39
  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) { (0, _defineProperty2.default)(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; }
38
40
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -135,7 +137,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
135
137
  if (initialized && _this.disconnectedAt &&
136
138
  // Offline longer than `OUT_OF_SYNC_PERIOD`
137
139
  Date.now() - _this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
138
- _this.documentService.throttledCatchupv2();
140
+ _this.documentService.throttledCatchupv2(_const.CatchupEventReason.RECONNECTED);
139
141
  }
140
142
  _this.participantsService.startInactiveRemover(_this.sessionId);
141
143
  _this.disconnectedAt = undefined;
@@ -282,12 +284,19 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
282
284
  _this.participantsService = new _participantsService.ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined, _this.getPresenceData, _this.setUserId);
283
285
  _this.metadataService = new _metadataService.MetadataService(_this.emitCallback, _this.channel.sendMetadata);
284
286
  _this.namespaceService = new _namespaceService.NamespaceService();
285
- _this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.channel.fetchCatchupv2, _this.channel.fetchReconcile, _this.emitCallback, _this.channel.broadcast, function () {
286
- return _this.userId;
287
- }, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
288
- __livePage: _this.config.__livePage || false
289
- });
290
- _this.api = new _api.Api(config, _this.documentService, _this.channel);
287
+ if (config.isPresenceOnly_do_not_use) {
288
+ // this check is specifically for the experiment teammate presence
289
+ // This presence feature is only for the view pages which do not need the document service or api
290
+ _this.documentService = new _nullDocumentService.NullDocumentService();
291
+ _this.api = new _nullApi.NullApi();
292
+ } else {
293
+ _this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.channel.fetchCatchupv2, _this.channel.fetchReconcile, _this.emitCallback, _this.channel.broadcast, function () {
294
+ return _this.userId;
295
+ }, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
296
+ __livePage: _this.config.__livePage || false
297
+ });
298
+ _this.api = new _api.Api(config, _this.documentService, _this.channel);
299
+ }
291
300
  _this.sendStepsTimer = setInterval(function () {
292
301
  logger('Intervally sendStepsFromCurrentState');
293
302
  _this.documentService.sendStepsFromCurrentState(true);
@@ -369,13 +378,33 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
369
378
  }
370
379
  return this;
371
380
  }
381
+
382
+ // Only used for the experiment teammate presence (ATLAS-53155) - opts out of the document service and api service
383
+ }, {
384
+ key: "setupPresenceOnly_do_not_use",
385
+ value: function setupPresenceOnly_do_not_use(clientId) {
386
+ this.clientId = clientId;
387
+ this.checkForCookies();
388
+ try {
389
+ if (!this.isChannelInitialized) {
390
+ this.initializeChannel();
391
+ this.isChannelInitialized = true;
392
+ }
393
+ } catch (initError) {
394
+ var _this$analyticsHelper8;
395
+ (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(initError, 'Error while initialising the provider');
396
+ // Throw error so consumers are aware the initialisation failed when initialising themselves
397
+ throw new _customErrors.ProviderInitialisationError('Provider initialisation error', initError);
398
+ }
399
+ return this;
400
+ }
372
401
  }, {
373
402
  key: "checkForCookies",
374
403
  value: function checkForCookies() {
375
404
  if (!global.navigator.cookieEnabled) {
376
- var _this$analyticsHelper8;
405
+ var _this$analyticsHelper9;
377
406
  var initError = new _customErrors.ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
378
- (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
407
+ (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
379
408
  throw new _customErrors.ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
380
409
  }
381
410
  }
@@ -392,14 +421,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
392
421
  value: function send(_tr, _oldState, newState) {
393
422
  try {
394
423
  if (this.isViewOnly()) {
395
- var _this$analyticsHelper9;
424
+ var _this$analyticsHelper10;
396
425
  var error = {
397
426
  message: 'Attempted to send steps in view only mode',
398
427
  data: {
399
428
  code: _internalErrors.INTERNAL_ERROR_CODE.VIEW_ONLY_STEPS_ERROR
400
429
  }
401
430
  };
402
- (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(error, error.message);
431
+ (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, error.message);
403
432
  return;
404
433
  }
405
434
  // Don't send steps while the document is locked (eg. when restoring the document)
@@ -409,8 +438,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
409
438
  }
410
439
  this.documentService.send(_tr, _oldState, newState);
411
440
  } catch (error) {
412
- var _this$analyticsHelper10;
413
- (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, 'Error while sending steps for a transaction');
441
+ var _this$analyticsHelper11;
442
+ (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(error, 'Error while sending steps for a transaction');
414
443
  throw new _customErrors.SendTransactionError('Error while sending steps for a transaction', error);
415
444
  }
416
445
  }
@@ -450,9 +479,9 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
450
479
  }), activityCallback());
451
480
  }
452
481
  } catch (error) {
453
- var _this$analyticsHelper11;
482
+ var _this$analyticsHelper12;
454
483
  // We don't want to throw errors for Presence features as they tend to self-restore
455
- (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(error, 'Error while sending message - telepointer');
484
+ (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(error, 'Error while sending message - telepointer');
456
485
  }
457
486
  }
458
487
  }, {
@@ -495,8 +524,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
495
524
  this.sendStepsTimer = undefined;
496
525
  }
497
526
  } catch (error) {
498
- var _this$analyticsHelper12;
499
- (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(error, 'Error while shutting down the collab provider');
527
+ var _this$analyticsHelper13;
528
+ (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(error, 'Error while shutting down the collab provider');
500
529
  throw new _customErrors.DestroyError('Error while shutting down the collab provider', error);
501
530
  }
502
531
  this.clearTimers();
@@ -519,8 +548,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
519
548
  }
520
549
  this.metadataService.setTitle(title, broadcast);
521
550
  } catch (error) {
522
- var _this$analyticsHelper13;
523
- (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting title');
551
+ var _this$analyticsHelper14;
552
+ (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting title');
524
553
  throw new _customErrors.SetTitleError('Error while setting title', error);
525
554
  }
526
555
  }
@@ -538,8 +567,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
538
567
  try {
539
568
  this.metadataService.setEditorWidth(editorWidth, broadcast);
540
569
  } catch (error) {
541
- var _this$analyticsHelper14;
542
- (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting editor width');
570
+ var _this$analyticsHelper15;
571
+ (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting editor width');
543
572
  throw new _customErrors.SetEditorWidthError('Error while setting editor width', error);
544
573
  }
545
574
  }
@@ -558,8 +587,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
558
587
  }
559
588
  this.metadataService.setMetadata(metadata);
560
589
  } catch (error) {
561
- var _this$analyticsHelper15;
562
- (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting metadata');
590
+ var _this$analyticsHelper16;
591
+ (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(error, 'Error while setting metadata');
563
592
  throw new _customErrors.SetMetadataError('Error while setting metadata', error);
564
593
  }
565
594
  }
@@ -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 = "9.38.0";
8
+ var version = exports.version = "9.39.0";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -0,0 +1,6 @@
1
+ // A mock for the actual Api class designed for the experiment teammate presence (ATLAS-53155)
2
+ export class NullApi {
3
+ async addComment() {
4
+ return;
5
+ }
6
+ }
@@ -209,7 +209,7 @@ export class Channel extends Emitter {
209
209
  throw error;
210
210
  }
211
211
  });
212
- _defineProperty(this, "fetchCatchupv2", async (fromVersion, clientId, catchUpOutofSync) => {
212
+ _defineProperty(this, "fetchCatchupv2", async (fromVersion, clientId, catchUpOutofSync, reason) => {
213
213
  try {
214
214
  const {
215
215
  steps,
@@ -219,7 +219,8 @@ export class Channel extends Emitter {
219
219
  queryParams: {
220
220
  version: fromVersion,
221
221
  clientId: clientId,
222
- catchUpOutofSync
222
+ catchUpOutofSync,
223
+ reason
223
224
  },
224
225
  requestInit: {
225
226
  headers: await this.commonHeaders()
@@ -8,7 +8,7 @@ export const catchupv2 = async opt => {
8
8
  ({
9
9
  steps,
10
10
  metadata
11
- } = await opt.fetchCatchupv2(fromVersion, opt.clientId, opt.catchUpOutofSync));
11
+ } = await opt.fetchCatchupv2(fromVersion, opt.clientId, opt.catchUpOutofSync, opt.reason));
12
12
  } catch (error) {
13
13
  var _opt$analyticsHelper;
14
14
  (_opt$analyticsHelper = opt.analyticsHelper) === null || _opt$analyticsHelper === void 0 ? void 0 : _opt$analyticsHelper.sendErrorEvent(error, 'Error while fetching catchupv2 from server');