@atlaskit/collab-provider 10.3.1 → 10.3.3

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 (55) hide show
  1. package/CHANGELOG.md +15 -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 +17 -8
  9. package/dist/cjs/document/document-service.js +133 -63
  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 +54 -35
  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 +10 -1
  25. package/dist/es2019/document/document-service.js +144 -71
  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 +54 -35
  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 +17 -8
  41. package/dist/esm/document/document-service.js +137 -64
  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 +54 -35
  49. package/dist/esm/version-wrapper.js +1 -1
  50. package/dist/types/document/document-service.d.ts +6 -4
  51. package/dist/types/types.d.ts +5 -0
  52. package/dist/types-ts4.5/document/document-service.d.ts +6 -4
  53. package/dist/types-ts4.5/types.d.ts +5 -0
  54. package/package.json +6 -3
  55. package/tsconfig.json +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 10.3.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#99251](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/99251)
8
+ [`df1d982fa96ba`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/df1d982fa96ba) -
9
+ Add additional metadata for reconnection analytics to include step length.
10
+ - Updated dependencies
11
+
12
+ ## 10.3.2
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies
17
+
3
18
  ## 10.3.1
4
19
 
5
20
  ### Patch 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
  }]);
@@ -11,10 +11,14 @@ var _utils = require("../helpers/utils");
11
11
  var logger = (0, _utils.createLogger)('Catchupv2', 'red');
12
12
  var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
13
13
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opt) {
14
- var steps, metadata, fromVersion, _yield$opt$fetchCatch, _opt$analyticsHelper, version, stepsPayload, _opt$analyticsHelper2;
14
+ var steps, metadata, fromVersion, _yield$opt$fetchCatch, _opt$analyticsHelper, _opt$onCatchupComplet, version, stepsPayload, _opt$analyticsHelper2;
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;
@@ -33,13 +37,15 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
33
37
  throw _context.t0;
34
38
  case 14:
35
39
  _context.prev = 14;
40
+ (_opt$onCatchupComplet = opt.onCatchupComplete) === null || _opt$onCatchupComplet === void 0 || _opt$onCatchupComplet.call(opt, steps);
41
+ // skip onStepsAdded if steps are undefined or empty
36
42
  if (!(!steps || steps.length === 0)) {
37
- _context.next = 18;
43
+ _context.next = 19;
38
44
  break;
39
45
  }
40
46
  opt.updateMetadata(metadata);
41
47
  return _context.abrupt("return", false);
42
- case 18:
48
+ case 19:
43
49
  version = fromVersion + steps.length;
44
50
  stepsPayload = {
45
51
  version: version,
@@ -48,17 +54,17 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
48
54
  opt.onStepsAdded(stepsPayload);
49
55
  opt.updateMetadata(metadata);
50
56
  return _context.abrupt("return", Boolean(opt.clientId && isOutOfSync(fromVersion, opt.getCurrentPmVersion(), steps, opt.clientId)));
51
- case 25:
52
- _context.prev = 25;
57
+ case 26:
58
+ _context.prev = 26;
53
59
  _context.t1 = _context["catch"](14);
54
60
  (_opt$analyticsHelper2 = opt.analyticsHelper) === null || _opt$analyticsHelper2 === void 0 || _opt$analyticsHelper2.sendErrorEvent(_context.t1, 'Failed to apply catchupv2 result in the editor');
55
61
  logger("Apply catchupv2 steps failed:", _context.t1.message);
56
62
  throw _context.t1;
57
- case 30:
63
+ case 31:
58
64
  case "end":
59
65
  return _context.stop();
60
66
  }
61
- }, _callee, null, [[1, 9], [14, 25]]);
67
+ }, _callee, null, [[1, 9], [14, 26]]);
62
68
  }));
63
69
  return function catchupv2(_x) {
64
70
  return _ref.apply(this, arguments);
@@ -73,7 +79,10 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
73
79
  * @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
74
80
  * @returns True if we're out of sync, false if not.
75
81
  */
76
- var isOutOfSync = exports.isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId) {
82
+ var isOutOfSync = exports.isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId
83
+ // Ignored via go/ees005
84
+ // eslint-disable-next-line @typescript-eslint/max-params
85
+ ) {
77
86
  return (
78
87
  // If version number hasn't increased, and steps are not from our client, we're out of sync
79
88
  Boolean(fromVersion >= currentVersion && steps.some(function (step) {