@atlaskit/collab-provider 10.3.0 → 10.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics/analytics-helper.js +10 -0
  3. package/dist/cjs/analytics/performance.js +4 -1
  4. package/dist/cjs/api/null-api.js +3 -1
  5. package/dist/cjs/channel.js +22 -1
  6. package/dist/cjs/connectivity/network.js +8 -0
  7. package/dist/cjs/connectivity/reconnect-helper.js +4 -0
  8. package/dist/cjs/document/catchupv2.js +8 -1
  9. package/dist/cjs/document/document-service.js +65 -4
  10. package/dist/cjs/emitter.js +10 -0
  11. package/dist/cjs/helpers/utils.js +16 -7
  12. package/dist/cjs/metadata/metadata-service.js +4 -1
  13. package/dist/cjs/namespace/namespace-service.js +2 -0
  14. package/dist/cjs/participants/participants-service.js +6 -0
  15. package/dist/cjs/provider/commit-step.js +7 -2
  16. package/dist/cjs/provider/index.js +19 -1
  17. package/dist/cjs/version-wrapper.js +1 -1
  18. package/dist/es2019/analytics/analytics-helper.js +10 -0
  19. package/dist/es2019/analytics/performance.js +4 -1
  20. package/dist/es2019/api/null-api.js +2 -0
  21. package/dist/es2019/channel.js +26 -0
  22. package/dist/es2019/connectivity/network.js +8 -0
  23. package/dist/es2019/connectivity/reconnect-helper.js +4 -0
  24. package/dist/es2019/document/catchupv2.js +8 -1
  25. package/dist/es2019/document/document-service.js +67 -4
  26. package/dist/es2019/emitter.js +11 -0
  27. package/dist/es2019/helpers/utils.js +10 -2
  28. package/dist/es2019/metadata/metadata-service.js +4 -1
  29. package/dist/es2019/namespace/namespace-service.js +2 -0
  30. package/dist/es2019/participants/participants-service.js +6 -0
  31. package/dist/es2019/provider/commit-step.js +8 -3
  32. package/dist/es2019/provider/index.js +19 -1
  33. package/dist/es2019/version-wrapper.js +1 -1
  34. package/dist/esm/analytics/analytics-helper.js +10 -0
  35. package/dist/esm/analytics/performance.js +4 -1
  36. package/dist/esm/api/null-api.js +3 -1
  37. package/dist/esm/channel.js +22 -1
  38. package/dist/esm/connectivity/network.js +8 -0
  39. package/dist/esm/connectivity/reconnect-helper.js +4 -0
  40. package/dist/esm/document/catchupv2.js +8 -1
  41. package/dist/esm/document/document-service.js +68 -4
  42. package/dist/esm/emitter.js +11 -0
  43. package/dist/esm/helpers/utils.js +16 -7
  44. package/dist/esm/metadata/metadata-service.js +4 -1
  45. package/dist/esm/namespace/namespace-service.js +2 -0
  46. package/dist/esm/participants/participants-service.js +6 -0
  47. package/dist/esm/provider/commit-step.js +8 -3
  48. package/dist/esm/provider/index.js +19 -1
  49. package/dist/esm/version-wrapper.js +1 -1
  50. package/dist/types/document/document-service.d.ts +4 -2
  51. package/dist/types-ts4.5/document/document-service.d.ts +4 -2
  52. package/package.json +6 -3
  53. package/tsconfig.json +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 10.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 10.3.1
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies
14
+
3
15
  ## 10.3.0
4
16
 
5
17
  ### Minor Changes
@@ -44,6 +44,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
44
44
  if (analyticsEvent.eventAction === _const.EVENT_ACTION.ERROR) {
45
45
  payload.nonPrivacySafeAttributes = analyticsEvent.nonPrivacySafeAttributes;
46
46
  try {
47
+ // Ignored via go/ees005
48
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
47
49
  var requestIdleCallbackFunction = window.requestIdleCallback;
48
50
  var runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
49
51
  runItLater(function () {
@@ -56,6 +58,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
56
58
  // Let the browser figure out
57
59
  // when it should send those events
58
60
  try {
61
+ // Ignored via go/ees005
62
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
59
63
  var _requestIdleCallbackFunction = window.requestIdleCallback;
60
64
  var _runItLater = typeof _requestIdleCallbackFunction === 'function' ? _requestIdleCallbackFunction : window.requestAnimationFrame;
61
65
  _runItLater(function () {
@@ -67,6 +71,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
67
71
  }
68
72
  };
69
73
  var AnalyticsHelper = exports.default = /*#__PURE__*/function () {
74
+ // Ignored via go/ees005
75
+ // eslint-disable-next-line @typescript-eslint/max-params
70
76
  function AnalyticsHelper(documentAri, subProduct, analyticsClient, getAnalyticsClient) {
71
77
  (0, _classCallCheck2.default)(this, AnalyticsHelper);
72
78
  this.documentAri = documentAri;
@@ -89,7 +95,11 @@ var AnalyticsHelper = exports.default = /*#__PURE__*/function () {
89
95
  subProduct: this.subProduct,
90
96
  errorMessage: errorMessage,
91
97
  errorName: error instanceof Error ? error.name : undefined,
98
+ // Ignored via go/ees005
99
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
100
  errorCode: (_data$code = (_data = error.data) === null || _data === void 0 ? void 0 : _data.code) !== null && _data$code !== void 0 ? _data$code : undefined,
101
+ // Ignored via go/ees005
102
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
93
103
  errorStatus: (_data$status = (_data2 = error.data) === null || _data2 === void 0 ? void 0 : _data2.status) !== null && _data$status !== void 0 ? _data$status : undefined,
94
104
  errorStack: error instanceof Error && loggableErrorName.includes(error.name) ? error.stack : undefined,
95
105
  originalErrorMessage: this.getUGCFreeErrorMessage(error)
@@ -17,7 +17,10 @@ var MEASURE_NAME = exports.MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
17
17
  return MEASURE_NAME;
18
18
  }({});
19
19
  var isPerformanceAPIAvailable = exports.isPerformanceAPIAvailable = function isPerformanceAPIAvailable() {
20
- return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(function (api) {
20
+ return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(
21
+ // Ignored via go/ees005
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ function (api) {
21
24
  return !!performance[api];
22
25
  });
23
26
  };
@@ -16,7 +16,9 @@ var NullApi = exports.NullApi = /*#__PURE__*/function () {
16
16
  }
17
17
  return (0, _createClass2.default)(NullApi, [{
18
18
  key: "addComment",
19
- value: function () {
19
+ value: // Ignored via go/ees005
20
+ // eslint-disable-next-line require-await
21
+ function () {
20
22
  var _addComment = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
21
23
  return _regenerator.default.wrap(function _callee$(_context) {
22
24
  while (1) switch (_context.prev = _context.next) {
@@ -168,6 +168,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
168
168
  (0, _defineProperty2.default)(_this, "onConnect", function () {
169
169
  var _this$analyticsHelper5;
170
170
  _this.connected = true;
171
+ // Ignored via go/ees005
172
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
171
173
  logger('Connected.', _this.socket.id);
172
174
  var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.SOCKET_CONNECT, _this.analyticsHelper);
173
175
  (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendActionEvent(_const.EVENT_ACTION.CONNECTION, _const.EVENT_STATUS.SUCCESS, {
@@ -177,12 +179,19 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
177
179
  usedCachedToken: !!_this.token
178
180
  });
179
181
  _this.emit('connected', {
182
+ // Ignored via go/ees005
183
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
180
184
  sid: _this.socket.id,
181
185
  initialized: _this.initialized
182
186
  });
183
187
  });
188
+ // Ignored via go/ees005
189
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
184
190
  (0, _defineProperty2.default)(_this, "onReceiveData", function (data) {
185
191
  logger('Received data', data);
192
+
193
+ // Ignored via go/ees005
194
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
186
195
  logger('Session ID is', _this.socket.id);
187
196
  if (data.type === 'initial') {
188
197
  if (!_this.initialized) {
@@ -226,6 +235,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
226
235
  _this.emit('steps:added', data);
227
236
  }
228
237
  });
238
+ // Ignored via go/ees005
239
+ // eslint-disable-next-line @typescript-eslint/max-params
229
240
  (0, _defineProperty2.default)(_this, "fetchCatchupv2", /*#__PURE__*/function () {
230
241
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(fromVersion, clientId, catchUpOutofSync, reason) {
231
242
  var _yield$utils$requestS, steps, metadata, errorNotFound, errorCatchupv2;
@@ -312,7 +323,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
312
323
  doc: currentStateDoc,
313
324
  productId: 'ccollab',
314
325
  reason: reason
315
- });
326
+ }); // Ignored via go/ees005
327
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
316
328
  _context3.t0 = _utilServiceSupport.utils;
317
329
  _context3.t1 = _this.config;
318
330
  _context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
@@ -479,6 +491,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
479
491
  code: _internalErrors.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
480
492
  meta: {
481
493
  originalError: _context4.t0,
494
+ // Ignored via go/ees005
495
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
482
496
  reason: _context4.t0 === null || _context4.t0 === void 0 || (_data = _context4.t0.data) === null || _data === void 0 || (_data = _data.meta) === null || _data === void 0 ? void 0 : _data.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
483
497
  // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
484
498
  }
@@ -496,6 +510,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
496
510
  };
497
511
  }();
498
512
  } else {
513
+ // Ignored via go/ees005
514
+ // eslint-disable-next-line require-await
499
515
  auth = /*#__PURE__*/function () {
500
516
  var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(cb) {
501
517
  var authData;
@@ -578,6 +594,8 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
578
594
  this.socket.on('status', function (data) {
579
595
  _this2.emit('status', data);
580
596
  });
597
+ // Ignored via go/ees005
598
+ // eslint-disable-next-line require-await
581
599
  this.socket.on('disconnect', /*#__PURE__*/function () {
582
600
  var _ref10 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(reason) {
583
601
  var _this2$analyticsHelpe, reconnectionError;
@@ -644,6 +662,9 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
644
662
  // Fired upon a reconnection attempt error (from Socket.IO Manager)
645
663
  this.socket.io.on('reconnect_error', this.onReconnectError);
646
664
  }
665
+
666
+ // Ignored via go/ees005
667
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
647
668
  }, {
648
669
  key: "onAnyOutgoingHandler",
649
670
  value: function onAnyOutgoingHandler(currentTimeMs, args) {
@@ -33,7 +33,11 @@ var Network = exports.default = /*#__PURE__*/function () {
33
33
  this.onlineCallback = props.onlineCallback;
34
34
  }
35
35
  if (typeof window !== 'undefined') {
36
+ // Ignored via go/ees005
37
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
36
38
  window.addEventListener('offline', this.offlineHandler);
39
+ // Ignored via go/ees005
40
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
37
41
  window.addEventListener('online', this.onlineHandler);
38
42
  }
39
43
  }
@@ -45,7 +49,11 @@ var Network = exports.default = /*#__PURE__*/function () {
45
49
  }, {
46
50
  key: "destroy",
47
51
  value: function destroy() {
52
+ // Ignored via go/ees005
53
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
48
54
  window.removeEventListener('offline', this.offlineHandler);
55
+ // Ignored via go/ees005
56
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
49
57
  window.removeEventListener('online', this.onlineHandler);
50
58
  }
51
59
  }]);
@@ -21,6 +21,8 @@ var ReconnectHelper = exports.default = /*#__PURE__*/function () {
21
21
  (0, _defineProperty2.default)(this, "onlineHandler", function () {
22
22
  _this.failedReconnectCount = 0;
23
23
  });
24
+ // Ignored via go/ees005
25
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
24
26
  window.addEventListener('online', this.onlineHandler);
25
27
  }
26
28
  return (0, _createClass2.default)(ReconnectHelper, [{
@@ -40,6 +42,8 @@ var ReconnectHelper = exports.default = /*#__PURE__*/function () {
40
42
  }, {
41
43
  key: "destroy",
42
44
  value: function destroy() {
45
+ // Ignored via go/ees005
46
+ // eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
43
47
  window.removeEventListener('online', this.onlineHandler);
44
48
  }
45
49
  }]);
@@ -15,6 +15,10 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
15
15
  return _regenerator.default.wrap(function _callee$(_context) {
16
16
  while (1) switch (_context.prev = _context.next) {
17
17
  case 0:
18
+ // Ignored via go/ees005
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ // Ignored via go/ees005
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
22
  fromVersion = opt.getCurrentPmVersion();
19
23
  _context.prev = 1;
20
24
  _context.next = 4;
@@ -73,7 +77,10 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
73
77
  * @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
74
78
  * @returns True if we're out of sync, false if not.
75
79
  */
76
- var isOutOfSync = exports.isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId) {
80
+ var isOutOfSync = exports.isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId
81
+ // Ignored via go/ees005
82
+ // eslint-disable-next-line @typescript-eslint/max-params
83
+ ) {
77
84
  return (
78
85
  // If version number hasn't increased, and steps are not from our client, we're out of sync
79
86
  Boolean(fromVersion >= currentVersion && steps.some(function (step) {
@@ -45,13 +45,20 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
45
45
  * @param onErrorHandled - Callback to handle
46
46
  * @param metadataService
47
47
  * @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
48
+ * @param getConnected - if the channel is currently connected
48
49
  */
49
- function DocumentService(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile, providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService, isNameSpaceLocked) {
50
+ // Ignored via go/ees005
51
+ // eslint-disable-next-line @typescript-eslint/max-params
52
+ function DocumentService(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile,
53
+ // Ignored via go/ees005
54
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55
+ providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService, isNameSpaceLocked) {
50
56
  var _this = this;
51
57
  var enableErrorOnFailedDocumentApply = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
52
58
  var options = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : {
53
59
  __livePage: false
54
60
  };
61
+ var getConnected = arguments.length > 12 ? arguments[12] : undefined;
55
62
  (0, _classCallCheck2.default)(this, DocumentService);
56
63
  // Fires analytics to editor when collab editor cannot sync up
57
64
  (0, _defineProperty2.default)(this, "stepRejectCounter", 0);
@@ -150,6 +157,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
150
157
  }
151
158
  return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
152
159
  });
160
+ // Ignored via go/ees005
161
+ // eslint-disable-next-line require-await
153
162
  (0, _defineProperty2.default)(this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
154
163
  var _this$getState2, _this$analyticsHelper5, _this$analyticsHelper4, state, adfDocument, version, currentState, measure, _this$analyticsHelper6, _this$analyticsHelper7, _measure;
155
164
  return _regenerator.default.wrap(function _callee2$(_context2) {
@@ -162,6 +171,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
162
171
  if (!((_this$getState2 = _this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(_this))) {
163
172
  (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
164
173
  }
174
+ // Ignored via go/ees005
175
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
165
176
  state = _this.getState();
166
177
  adfDocument = new _editorJsonTransformer.JSONTransformer().encode(state.doc);
167
178
  version = _this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
@@ -199,11 +210,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
199
210
  var clientId = _ref3.clientId;
200
211
  return clientId;
201
212
  }));
213
+ // Ignored via go/ees005
214
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
202
215
  if (!clientIds.has(_this.clientId)) {
203
216
  var userIds = new Set(steps.map(function (_ref4) {
204
217
  var userId = _ref4.userId;
205
218
  return userId;
206
219
  }));
220
+ // Ignored via go/ees005
221
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
207
222
  if (userIds.has(_this.getUserId())) {
208
223
  return true;
209
224
  }
@@ -472,6 +487,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
472
487
  } : {}));
473
488
  _this.updateDocumentAnalytics(doc, version);
474
489
  });
490
+ // Ignored via go/ees005
491
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
475
492
  (0, _defineProperty2.default)(this, "updateDocumentAnalytics", function (doc, version) {
476
493
  var updatedVersion = _this.getCurrentPmVersion();
477
494
  var isDocContentValid = _this.validatePMJSONDocument(doc);
@@ -513,6 +530,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
513
530
  });
514
531
  }
515
532
  });
533
+ // Ignored via go/ees005
534
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
516
535
  (0, _defineProperty2.default)(this, "validatePMJSONDocument", function (doc) {
517
536
  try {
518
537
  var _this$getState5;
@@ -520,7 +539,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
520
539
  var _this$analyticsHelper22;
521
540
  (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
522
541
  }
542
+ // Ignored via go/ees005
543
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
523
544
  var state = _this.getState();
545
+ // Ignored via go/ees005
546
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
524
547
  var content = (doc.content || []).map(function (child) {
525
548
  return state.schema.nodeFromJSON(child);
526
549
  });
@@ -585,6 +608,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
585
608
  break;
586
609
  }
587
610
  if (_this.onSyncUpError) {
611
+ // Ignored via go/ees005
612
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
588
613
  state = _this.getState();
589
614
  version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
590
615
  _this.onSyncUpError({
@@ -665,6 +690,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
665
690
  this.isNameSpaceLocked = isNameSpaceLocked;
666
691
  this.enableErrorOnFailedDocumentApply = enableErrorOnFailedDocumentApply;
667
692
  this.options = options;
693
+ this.getConnected = getConnected;
668
694
  this.stepQueue = new _stepQueueState.StepQueueState();
669
695
  this.onErrorHandled = onErrorHandled;
670
696
  }
@@ -697,9 +723,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
697
723
  if (this.stepQueue.getQueue().length > 0) {
698
724
  var firstItem = this.stepQueue.shift();
699
725
  var currentVersion = this.getCurrentPmVersion();
726
+ // Ignored via go/ees005
727
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
700
728
  var expectedVersion = currentVersion + firstItem.steps.length;
729
+ // Ignored via go/ees005
730
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
701
731
  if (firstItem.version === expectedVersion) {
702
732
  logger("Applying data from queue!");
733
+ // Ignored via go/ees005
734
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
703
735
  this.processSteps(firstItem);
704
736
  // recur
705
737
  this.processQueue();
@@ -729,6 +761,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
729
761
  this.participantsService.emitTelepointersFromSteps(steps);
730
762
 
731
763
  // Resend local steps if none of the received steps originated with us!
764
+ // Ignored via go/ees005
765
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
732
766
  if (clientIds.indexOf(this.clientId) === -1) {
733
767
  setTimeout(function () {
734
768
  return _this2.sendStepsFromCurrentState();
@@ -787,13 +821,21 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
787
821
  * Send steps from transaction to other participants
788
822
  * It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
789
823
  */
824
+ // Ignored via go/ees005
825
+ // eslint-disable-next-line @typescript-eslint/max-params
790
826
  function send(_tr, _oldState, newState, sendAnalyticsEvent) {
791
827
  var unconfirmedStepsData = (0, _prosemirrorCollab.sendableSteps)(newState);
792
828
  var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
793
829
 
794
830
  // Don't send any steps before we're ready.
795
- if (!unconfirmedStepsData) {
796
- return;
831
+ if ((0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps')) {
832
+ if (!unconfirmedStepsData || !this.getConnected()) {
833
+ return;
834
+ }
835
+ } else {
836
+ if (!unconfirmedStepsData) {
837
+ return;
838
+ }
797
839
  }
798
840
  var unconfirmedSteps = unconfirmedStepsData.steps;
799
841
  // sendAnalyticsEvent is only true when buffering is enabled,
@@ -809,12 +851,28 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
809
851
  return;
810
852
  }
811
853
 
854
+ // If we are going to commit unconfirmed steps
855
+ // we need to lock them to ensure they don't get
856
+ // mutated in: `packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts`
857
+ if ((0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps')) {
858
+ unconfirmedStepsData.steps.forEach(function (s) {
859
+ if (isLockable(s)) {
860
+ var _s$lockStep;
861
+ (_s$lockStep = s.lockStep) === null || _s$lockStep === void 0 || _s$lockStep.call(s);
862
+ }
863
+ });
864
+ }
865
+
812
866
  // Avoid reference issues using a
813
867
  // method outside of the provider
814
868
  // scope
815
869
  (0, _commitStep.commitStepQueue)({
816
870
  broadcast: this.broadcast,
871
+ // Ignored via go/ees005
872
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
817
873
  userId: this.getUserId(),
874
+ // Ignored via go/ees005
875
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
818
876
  clientId: this.clientId,
819
877
  steps: unconfirmedSteps,
820
878
  version: version,
@@ -826,4 +884,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
826
884
  });
827
885
  }
828
886
  }]);
829
- }();
887
+ }(); // Based on: packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts
888
+ function isLockable(step) {
889
+ return (step === null || step === void 0 ? void 0 : step.lockStep) !== undefined;
890
+ }
@@ -9,6 +9,8 @@ var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/cl
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _eventemitter = require("eventemitter2");
12
+ // Ignored via go/ees005
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
14
  var Emitter = exports.Emitter = /*#__PURE__*/function () {
13
15
  function Emitter() {
14
16
  (0, _classCallCheck2.default)(this, Emitter);
@@ -21,6 +23,8 @@ var Emitter = exports.Emitter = /*#__PURE__*/function () {
21
23
  * Emit events to subscribers
22
24
  */
23
25
  function emit(evt, data) {
26
+ // Ignored via go/ees005
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
24
28
  this.eventEmitter.emit(evt, data);
25
29
  return this;
26
30
  }
@@ -31,6 +35,8 @@ var Emitter = exports.Emitter = /*#__PURE__*/function () {
31
35
  }, {
32
36
  key: "on",
33
37
  value: function on(evt, handler) {
38
+ // Ignored via go/ees005
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
34
40
  this.eventEmitter.on(evt, handler);
35
41
  return this;
36
42
  }
@@ -41,6 +47,8 @@ var Emitter = exports.Emitter = /*#__PURE__*/function () {
41
47
  }, {
42
48
  key: "off",
43
49
  value: function off(evt, handler) {
50
+ // Ignored via go/ees005
51
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
52
  this.eventEmitter.off(evt, handler);
45
53
  return this;
46
54
  }
@@ -51,6 +59,8 @@ var Emitter = exports.Emitter = /*#__PURE__*/function () {
51
59
  }, {
52
60
  key: "unsubscribeAll",
53
61
  value: function unsubscribeAll(evt) {
62
+ // Ignored via go/ees005
63
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
54
64
  this.eventEmitter.removeAllListeners(evt);
55
65
  return this;
56
66
  }
@@ -7,13 +7,19 @@ exports.isAIProviderID = exports.getSubProduct = exports.getStepUGCFreeDetails =
7
7
  exports.sleep = sleep;
8
8
  var createLogger = exports.createLogger = function createLogger(prefix) {
9
9
  var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
10
- return function (msg) {
11
- var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
12
- if (window.COLLAB_PROVIDER_LOGGER) {
13
- // eslint-disable-next-line no-console
14
- console.log("%cCollab-".concat(prefix, ": ").concat(msg), "color: ".concat(color, "; font-weight: bold"), data);
10
+ return (
11
+ // Ignored via go/ees005
12
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
13
+ function (msg) {
14
+ var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
15
+ // Ignored via go/ees005
16
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
+ if (window.COLLAB_PROVIDER_LOGGER) {
18
+ // eslint-disable-next-line no-console
19
+ console.log("%cCollab-".concat(prefix, ": ").concat(msg), "color: ".concat(color, "; font-weight: bold"), data);
20
+ }
15
21
  }
16
- };
22
+ );
17
23
  };
18
24
  function sleep(ms) {
19
25
  return new Promise(function (resolve) {
@@ -46,7 +52,10 @@ var getStepUGCFreeDetails = exports.getStepUGCFreeDetails = function getStepUGCF
46
52
  }
47
53
  var contentTypes = '';
48
54
  if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
49
- contentTypes = stepJson.slice.content.map(function (c) {
55
+ contentTypes = stepJson.slice.content
56
+ // Ignored via go/ees005
57
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
58
+ .map(function (c) {
50
59
  return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
51
60
  }).join(', ');
52
61
  }
@@ -10,7 +10,10 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
11
  var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
12
12
  var MetadataService = exports.MetadataService = /*#__PURE__*/function () {
13
- function MetadataService(providerEmitCallback, broadcastMetadata) {
13
+ function MetadataService(
14
+ // Ignored via go/ees005
15
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
16
+ providerEmitCallback, broadcastMetadata) {
14
17
  var _this = this;
15
18
  (0, _classCallCheck2.default)(this, MetadataService);
16
19
  (0, _defineProperty2.default)(this, "metadata", {});
@@ -28,6 +28,8 @@ var NamespaceService = exports.NamespaceService = /*#__PURE__*/(0, _createClass2
28
28
  /**
29
29
  * ESS-2916 namespace status event- lock/unlock
30
30
  */
31
+ // Ignored via go/ees005
32
+ // eslint-disable-next-line require-await
31
33
  (0, _defineProperty2.default)(this, "onNamespaceStatusChanged", /*#__PURE__*/function () {
32
34
  var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
33
35
  var isLocked, waitTimeInMs, timestamp, start;
@@ -31,6 +31,8 @@ var SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
31
31
  * @param sendPresenceJoined Callback to Channel class
32
32
  */
33
33
  var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function () {
34
+ // Ignored via go/ees005
35
+ // eslint-disable-next-line @typescript-eslint/max-params
34
36
  function ParticipantsService(analyticsHelper) {
35
37
  var _this = this;
36
38
  var participantsState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _participantsState.ParticipantsState();
@@ -188,6 +190,8 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
188
190
  try {
189
191
  _this.emit('disconnected', {
190
192
  reason: (0, _disconnectedReasonMapper.disconnectedReasonMapper)(reason),
193
+ // Ignored via go/ees005
194
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
191
195
  sid: sessionId
192
196
  });
193
197
  } catch (error) {
@@ -373,6 +377,8 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
373
377
  (0, _defineProperty2.default)(this, "onPresence", function (payload) {
374
378
  try {
375
379
  logger('onPresence userId: ', payload.userId);
380
+ // Ignored via go/ees005
381
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
376
382
  _this.setUserId(payload.userId);
377
383
  _this.sendPresence();
378
384
  _this.sendPresenceJoined();
@@ -54,7 +54,7 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
54
54
  // - doesn't impact any indexes,
55
55
  // - is setup for last write wins,
56
56
  // - and is just a boolean -- so no real risk of data loss.
57
- if ((0, _platformFeatureFlags.getBooleanFF)('platform.editor.live-pages-expand-divergence') && __livePage) {
57
+ if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence')) {
58
58
  // @atlaskit/platform-feature-flags
59
59
  stepsWithClientAndUserId = stepsWithClientAndUserId.map(function (step) {
60
60
  if (isExpandChangeStep(step)) {
@@ -103,7 +103,10 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
103
103
  analyticsHelper === null || analyticsHelper === void 0 || analyticsHelper.sendActionEvent(_const.EVENT_ACTION.ADD_STEPS, _const.EVENT_STATUS.SUCCESS_10x_SAMPLED, {
104
104
  type: _const.ADD_STEPS_TYPE.ACCEPTED,
105
105
  latency: latency,
106
- stepType: (0, _countBy.default)(stepsWithClientAndUserId, function (stepWithClientAndUserId) {
106
+ stepType: (0, _countBy.default)(stepsWithClientAndUserId,
107
+ // Ignored via go/ees005
108
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
109
+ function (stepWithClientAndUserId) {
107
110
  return stepWithClientAndUserId.stepType;
108
111
  })
109
112
  });
@@ -145,6 +148,8 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
145
148
  }
146
149
  };
147
150
  function isExpandChangeStep(step) {
151
+ // Ignored via go/ees005
152
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
153
  if (step.stepType === 'setAttrs' && '__expanded' in step.attrs) {
149
154
  return true;
150
155
  }
@@ -71,6 +71,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
71
71
  * @param evt - Event name to emit to subscribers
72
72
  * @param data - Event data to emit to subscribers
73
73
  */
74
+ // Ignored via go/ees005
75
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
74
76
  (0, _defineProperty2.default)(_this, "emitCallback", function (evt, data) {
75
77
  return _this.emit(evt, data);
76
78
  });
@@ -166,8 +168,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
166
168
  });
167
169
  (0, _defineProperty2.default)(_this, "getPresenceData", function () {
168
170
  return {
171
+ // Ignored via go/ees005
172
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
169
173
  sessionId: _this.sessionId,
174
+ // Ignored via go/ees005
175
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
170
176
  userId: _this.userId,
177
+ // Ignored via go/ees005
178
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
171
179
  clientId: _this.clientId,
172
180
  permit: _this.permit,
173
181
  presenceId: _this.presenceId,
@@ -314,7 +322,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
314
322
  return _this.userId;
315
323
  }, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
316
324
  __livePage: _this.config.__livePage || false
317
- });
325
+ }, _this.channel.getConnected);
318
326
  _this.api = new _api.Api(config, _this.documentService, _this.channel);
319
327
  }
320
328
  _this.sendStepsTimer = setInterval(function () {
@@ -356,12 +364,16 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
356
364
  onSyncUpError = _ref7.onSyncUpError;
357
365
  this.checkForCookies();
358
366
  try {
367
+ // Ignored via go/ees005
368
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
359
369
  var collabPlugin = getState().plugins.find(function (p) {
360
370
  return p.key === 'collab$';
361
371
  });
362
372
  if (collabPlugin === undefined) {
363
373
  throw new _customErrors.ProviderInitialisationError('Collab provider attempted to initialise, but Editor state is missing collab plugin');
364
374
  }
375
+ // Ignored via go/ees005
376
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
365
377
  this.clientId = collabPlugin.spec.config.clientID;
366
378
 
367
379
  // generate a temporary id as clientId when it is undefined
@@ -490,8 +502,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
490
502
  key: "sendMessage",
491
503
  value: function sendMessage(data) {
492
504
  var basePayload = {
505
+ // Ignored via go/ees005
506
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
493
507
  userId: this.userId,
508
+ // Ignored via go/ees005
509
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
494
510
  sessionId: this.sessionId,
511
+ // Ignored via go/ees005
512
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
495
513
  clientId: this.clientId,
496
514
  permit: this.permit
497
515
  };