@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
@@ -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);
@@ -61,8 +68,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
61
68
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
62
69
  * @param reason - optional reason to attach.
63
70
  */
64
- (0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function (reason) {
65
- return _this.catchupv2(reason);
71
+ (0, _defineProperty2.default)(this, "throttledCatchupv2", (0, _throttle.default)(function (reason, reconnectionMetadata) {
72
+ return _this.catchupv2(reason, reconnectionMetadata);
66
73
  }, CATCHUP_THROTTLE, {
67
74
  leading: false,
68
75
  // TODO: why shouldn't this be leading?
@@ -75,8 +82,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
75
82
  * @param reason - optional reason to attach.
76
83
  */
77
84
  (0, _defineProperty2.default)(this, "catchupv2", /*#__PURE__*/function () {
78
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reason) {
79
- var start, _this$analyticsHelper, latency, _this$analyticsHelper2, _latency;
85
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reason, reconnectionMetadata) {
86
+ var start, _this$analyticsHelper2, latency, _this$analyticsHelper3, _latency;
80
87
  return _regenerator.default.wrap(function _callee$(_context) {
81
88
  while (1) switch (_context.prev = _context.next) {
82
89
  case 0:
@@ -106,12 +113,21 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
106
113
  clientId: _this.clientId,
107
114
  onStepsAdded: _this.onStepsAdded,
108
115
  catchUpOutofSync: _this.catchUpOutofSync,
109
- reason: reason
116
+ reason: reason,
117
+ onCatchupComplete: function onCatchupComplete(steps) {
118
+ // We want to capture the number of steps made while offline vs. online
119
+ if (reason === _const.CatchupEventReason.RECONNECTED) {
120
+ var _this$analyticsHelper, _steps$length;
121
+ (_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 || _this$analyticsHelper.sendActionEvent(_const.EVENT_ACTION.RECONNECTION, _const.EVENT_STATUS.INFO, _objectSpread(_objectSpread({}, reconnectionMetadata), {}, {
122
+ remoteStepsLength: (_steps$length = steps === null || steps === void 0 ? void 0 : steps.length) !== null && _steps$length !== void 0 ? _steps$length : 0
123
+ }));
124
+ }
125
+ }
110
126
  });
111
127
  case 11:
112
128
  _this.catchUpOutofSync = _context.sent;
113
129
  latency = new Date().getTime() - start;
114
- (_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 || _this$analyticsHelper.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.SUCCESS, {
130
+ (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.SUCCESS, {
115
131
  latency: latency
116
132
  });
117
133
  _context.next = 20;
@@ -120,7 +136,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
120
136
  _context.prev = 16;
121
137
  _context.t0 = _context["catch"](8);
122
138
  _latency = new Date().getTime() - start;
123
- (_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.FAILURE, {
139
+ (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendActionEvent(_const.EVENT_ACTION.CATCHUP, _const.EVENT_STATUS.FAILURE, {
124
140
  latency: _latency
125
141
  });
126
142
  case 20:
@@ -136,7 +152,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
136
152
  }
137
153
  }, _callee, null, [[8, 16, 20, 26]]);
138
154
  }));
139
- return function (_x) {
155
+ return function (_x, _x2) {
140
156
  return _ref.apply(this, arguments);
141
157
  };
142
158
  }());
@@ -144,14 +160,16 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
144
160
  var _this$getState;
145
161
  var state = (_this$getState = _this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(_this);
146
162
  if (!state) {
147
- var _this$analyticsHelper3;
148
- (_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
163
+ var _this$analyticsHelper4;
164
+ (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
149
165
  return 0;
150
166
  }
151
167
  return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
152
168
  });
169
+ // Ignored via go/ees005
170
+ // eslint-disable-next-line require-await
153
171
  (0, _defineProperty2.default)(this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
154
- var _this$getState2, _this$analyticsHelper5, _this$analyticsHelper4, state, adfDocument, version, currentState, measure, _this$analyticsHelper6, _this$analyticsHelper7, _measure;
172
+ var _this$getState2, _this$analyticsHelper6, _this$analyticsHelper5, state, adfDocument, version, currentState, measure, _this$analyticsHelper7, _this$analyticsHelper8, _measure;
155
173
  return _regenerator.default.wrap(function _callee2$(_context2) {
156
174
  while (1) switch (_context2.prev = _context2.next) {
157
175
  case 0:
@@ -160,8 +178,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
160
178
 
161
179
  // Convert ProseMirror document in Editor state to ADF document
162
180
  if (!((_this$getState2 = _this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(_this))) {
163
- (_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
181
+ (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
164
182
  }
183
+ // Ignored via go/ees005
184
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
165
185
  state = _this.getState();
166
186
  adfDocument = new _editorJsonTransformer.JSONTransformer().encode(state.doc);
167
187
  version = _this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
@@ -171,7 +191,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
171
191
  stepVersion: version
172
192
  };
173
193
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
174
- (_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.SUCCESS, {
194
+ (_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.SUCCESS, {
175
195
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
176
196
  });
177
197
  return _context2.abrupt("return", currentState);
@@ -179,10 +199,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
179
199
  _context2.prev = 12;
180
200
  _context2.t0 = _context2["catch"](0);
181
201
  _measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
182
- (_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.FAILURE, {
202
+ (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendActionEvent(_const.EVENT_ACTION.GET_CURRENT_STATE, _const.EVENT_STATUS.FAILURE, {
183
203
  latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
184
204
  });
185
- (_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
205
+ (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
186
206
  throw _context2.t0;
187
207
  case 18:
188
208
  case "end":
@@ -199,19 +219,23 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
199
219
  var clientId = _ref3.clientId;
200
220
  return clientId;
201
221
  }));
222
+ // Ignored via go/ees005
223
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
202
224
  if (!clientIds.has(_this.clientId)) {
203
225
  var userIds = new Set(steps.map(function (_ref4) {
204
226
  var userId = _ref4.userId;
205
227
  return userId;
206
228
  }));
229
+ // Ignored via go/ees005
230
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
207
231
  if (userIds.has(_this.getUserId())) {
208
232
  return true;
209
233
  }
210
234
  }
211
235
  return false;
212
236
  } catch (err) {
213
- var _this$analyticsHelper8;
214
- (_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
237
+ var _this$analyticsHelper9;
238
+ (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(err, 'Error while checking for new clientId for same userId in steps');
215
239
  return false;
216
240
  }
217
241
  });
@@ -219,8 +243,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
219
243
  var _this$getState3, _sendableSteps;
220
244
  var state = (_this$getState3 = _this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(_this);
221
245
  if (!state) {
222
- var _this$analyticsHelper9;
223
- (_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
246
+ var _this$analyticsHelper10;
247
+ (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
224
248
  return;
225
249
  }
226
250
  return (_sendableSteps = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -229,8 +253,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
229
253
  var _this$getState4, _sendableSteps2;
230
254
  var state = (_this$getState4 = _this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(_this);
231
255
  if (!state) {
232
- var _this$analyticsHelper10;
233
- (_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
256
+ var _this$analyticsHelper11;
257
+ (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
234
258
  return;
235
259
  }
236
260
  return (_sendableSteps2 = (0, _prosemirrorCollab.sendableSteps)(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -270,8 +294,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
270
294
  return userId;
271
295
  }));
272
296
  } catch (stepsAddedError) {
273
- var _this$analyticsHelper11;
274
- (_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
297
+ var _this$analyticsHelper12;
298
+ (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
275
299
  _this.onErrorHandled({
276
300
  message: 'Error while adding steps in the provider',
277
301
  data: {
@@ -285,7 +309,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
285
309
  // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
286
310
  (0, _defineProperty2.default)(this, "onRestore", /*#__PURE__*/function () {
287
311
  var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(_ref6) {
288
- var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper14, _this$analyticsHelper12, _this$analyticsHelper13, _this$analyticsHelper15, _this$analyticsHelper16;
312
+ var doc, version, metadata, targetClientId, unconfirmedSteps, currentState, useReconcile, _this$analyticsHelper15, _this$analyticsHelper13, _this$analyticsHelper14, _this$analyticsHelper16, _this$analyticsHelper17;
289
313
  return _regenerator.default.wrap(function _callee3$(_context3) {
290
314
  while (1) switch (_context3.prev = _context3.next) {
291
315
  case 0:
@@ -323,7 +347,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
323
347
  break;
324
348
  }
325
349
  _context3.prev = 12;
326
- (_this$analyticsHelper12 = _this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.INFO, {
350
+ (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.INFO, {
327
351
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
328
352
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
329
353
  clientId: _this.clientId,
@@ -338,7 +362,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
338
362
  case 17:
339
363
  _context3.prev = 17;
340
364
  _context3.t0 = _context3["catch"](12);
341
- (_this$analyticsHelper13 = _this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
365
+ (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(_context3.t0, "Error while onRestore with applyLocalSteps. Will fallback to fetchReconcile");
342
366
  useReconcile = true;
343
367
  _context3.next = 23;
344
368
  return _this.fetchReconcile(JSON.stringify(currentState.content), 'fe-restore');
@@ -362,7 +386,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
362
386
  _this.applyLocalSteps(unconfirmedSteps);
363
387
  }
364
388
  case 31:
365
- (_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
389
+ (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
366
390
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
367
391
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
368
392
  useReconcile: useReconcile,
@@ -375,14 +399,14 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
375
399
  case 34:
376
400
  _context3.prev = 34;
377
401
  _context3.t1 = _context3["catch"](8);
378
- (_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
402
+ (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendActionEvent(_const.EVENT_ACTION.REINITIALISE_DOCUMENT, _const.EVENT_STATUS.FAILURE, {
379
403
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
380
404
  useReconcile: useReconcile,
381
405
  clientId: _this.clientId,
382
406
  targetClientId: targetClientId,
383
407
  triggeredByCatchup: targetClientId ? true : false
384
408
  });
385
- (_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(_context3.t1, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
409
+ (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendErrorEvent(_context3.t1, "Error while reinitialising document. Use Reconcile: ".concat(useReconcile));
386
410
  _this.onErrorHandled({
387
411
  message: 'Caught error while trying to recover the document',
388
412
  data: {
@@ -397,12 +421,12 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
397
421
  }
398
422
  }, _callee3, null, [[8, 34], [12, 17]]);
399
423
  }));
400
- return function (_x2) {
424
+ return function (_x3) {
401
425
  return _ref7.apply(this, arguments);
402
426
  };
403
427
  }());
404
428
  (0, _defineProperty2.default)(this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
405
- var _this$analyticsHelper17, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper18, _this$analyticsHelper19, _measure2;
429
+ var _this$analyticsHelper18, finalAcknowledgedState, currentState, reconcileResponse, measure, _this$analyticsHelper19, _this$analyticsHelper20, _measure2;
406
430
  return _regenerator.default.wrap(function _callee4$(_context4) {
407
431
  while (1) switch (_context4.prev = _context4.next) {
408
432
  case 0:
@@ -437,7 +461,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
437
461
  };
438
462
  case 20:
439
463
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
440
- (_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 || _this$analyticsHelper17.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
464
+ (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.SUCCESS, {
441
465
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
442
466
  });
443
467
  _this.aggressiveCatchup = false;
@@ -447,10 +471,10 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
447
471
  _context4.t1 = _context4["catch"](1);
448
472
  _this.aggressiveCatchup = false;
449
473
  _measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
450
- (_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 || _this$analyticsHelper18.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
474
+ (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendActionEvent(_const.EVENT_ACTION.PUBLISH_PAGE, _const.EVENT_STATUS.FAILURE, {
451
475
  latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
452
476
  });
453
- (_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 || _this$analyticsHelper19.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
477
+ (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(_context4.t1, 'Error while returning ADF version of the final draft document');
454
478
  throw _context4.t1;
455
479
  case 33:
456
480
  case "end":
@@ -472,13 +496,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
472
496
  } : {}));
473
497
  _this.updateDocumentAnalytics(doc, version);
474
498
  });
499
+ // Ignored via go/ees005
500
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
475
501
  (0, _defineProperty2.default)(this, "updateDocumentAnalytics", function (doc, version) {
476
502
  var updatedVersion = _this.getCurrentPmVersion();
477
503
  var isDocContentValid = _this.validatePMJSONDocument(doc);
478
504
  // ESS-5023: only emit error event if updated client version is still behind server version
479
505
  // client version could become higher than server version due to user editing or plugin adding steps
480
506
  if (updatedVersion < version) {
481
- var _doc$content, _this$analyticsHelper20;
507
+ var _doc$content, _this$analyticsHelper21;
482
508
  var error = new _customErrors.UpdateDocumentError('Failed to update the document', {
483
509
  newVersion: version,
484
510
  editorVersion: updatedVersion,
@@ -486,7 +512,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
486
512
  docHasContent: (doc === null || doc === void 0 || (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
487
513
  isDocContentValid: isDocContentValid
488
514
  });
489
- (_this$analyticsHelper20 = _this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 || _this$analyticsHelper20.sendErrorEvent(error, 'Failed to update the document in document service');
515
+ (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendErrorEvent(error, 'Failed to update the document in document service');
490
516
  if (_this.enableErrorOnFailedDocumentApply) {
491
517
  _this.onErrorHandled({
492
518
  message: 'The provider failed to apply changes to the editor',
@@ -503,8 +529,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
503
529
  }
504
530
  // Otherwise just fail silently for now
505
531
  } else {
506
- var _this$analyticsHelper21, _doc$content2;
507
- (_this$analyticsHelper21 = _this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 || _this$analyticsHelper21.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
532
+ var _this$analyticsHelper22, _doc$content2;
533
+ (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendActionEvent(_const.EVENT_ACTION.UPDATE_DOCUMENT, _const.EVENT_STATUS.SUCCESS, {
508
534
  newVersion: version,
509
535
  editorVersion: updatedVersion,
510
536
  isDocTruthy: !!doc,
@@ -513,14 +539,20 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
513
539
  });
514
540
  }
515
541
  });
542
+ // Ignored via go/ees005
543
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
516
544
  (0, _defineProperty2.default)(this, "validatePMJSONDocument", function (doc) {
517
545
  try {
518
546
  var _this$getState5;
519
547
  if (!((_this$getState5 = _this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(_this))) {
520
- var _this$analyticsHelper22;
521
- (_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
548
+ var _this$analyticsHelper23;
549
+ (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
522
550
  }
551
+ // Ignored via go/ees005
552
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
523
553
  var state = _this.getState();
554
+ // Ignored via go/ees005
555
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
524
556
  var content = (doc.content || []).map(function (child) {
525
557
  return state.schema.nodeFromJSON(child);
526
558
  });
@@ -541,7 +573,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
541
573
  * @throws {Error} Couldn't sync the steps after retrying 30 times
542
574
  */
543
575
  (0, _defineProperty2.default)(this, "commitUnconfirmedSteps", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
544
- var unconfirmedSteps, _this$getState6, _this$analyticsHelper24, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper23, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper25, _this$analyticsHelper26, _measure3;
576
+ var unconfirmedSteps, _this$getState6, _this$analyticsHelper25, count, unconfirmedTrs, lastTr, isLastTrConfirmed, _this$analyticsHelper24, nextUnconfirmedSteps, nextUnconfirmedTrs, _this$getUnconfirmedS, state, version, unconfirmedStepsInfoUGCRemoved, error, measure, _this$analyticsHelper26, _this$analyticsHelper27, _measure3;
545
577
  return _regenerator.default.wrap(function _callee5$(_context5) {
546
578
  while (1) switch (_context5.prev = _context5.next) {
547
579
  case 0:
@@ -560,7 +592,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
560
592
  lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
561
593
  isLastTrConfirmed = false;
562
594
  if (!((_this$getState6 = _this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(_this))) {
563
- (_this$analyticsHelper23 = _this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 || _this$analyticsHelper23.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
595
+ (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
564
596
  }
565
597
  case 9:
566
598
  if (isLastTrConfirmed) {
@@ -585,6 +617,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
585
617
  break;
586
618
  }
587
619
  if (_this.onSyncUpError) {
620
+ // Ignored via go/ees005
621
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
588
622
  state = _this.getState();
589
623
  version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
590
624
  _this.onSyncUpError({
@@ -607,7 +641,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
607
641
  break;
608
642
  case 22:
609
643
  measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
610
- (_this$analyticsHelper24 = _this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 || _this$analyticsHelper24.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
644
+ (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.SUCCESS, {
611
645
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
612
646
  // upon success, emit the total number of unconfirmed steps we synced
613
647
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
@@ -619,11 +653,11 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
619
653
  _context5.prev = 26;
620
654
  _context5.t0 = _context5["catch"](1);
621
655
  _measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
622
- (_this$analyticsHelper25 = _this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 || _this$analyticsHelper25.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
656
+ (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendActionEvent(_const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, _const.EVENT_STATUS.FAILURE, {
623
657
  latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
624
658
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
625
659
  });
626
- (_this$analyticsHelper26 = _this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 || _this$analyticsHelper26.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
660
+ (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendErrorEvent(_context5.t0, 'Error while committing unconfirmed steps');
627
661
  throw _context5.t0;
628
662
  case 32:
629
663
  case "end":
@@ -632,17 +666,17 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
632
666
  }, _callee5, null, [[1, 26]]);
633
667
  })));
634
668
  (0, _defineProperty2.default)(this, "onStepRejectedError", function () {
635
- var _this$analyticsHelper27;
669
+ var _this$analyticsHelper28;
636
670
  _this.stepRejectCounter++;
637
671
  logger("Steps rejected (tries=".concat(_this.stepRejectCounter, ")"));
638
- (_this$analyticsHelper27 = _this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 || _this$analyticsHelper27.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
672
+ (_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendActionEvent(_const.EVENT_ACTION.SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO, {
639
673
  count: _this.stepRejectCounter
640
674
  });
641
675
  var maxRetries = _this.aggressiveCatchup ? _provider.MAX_STEP_REJECTED_ERROR_AGGRESSIVE : _provider.MAX_STEP_REJECTED_ERROR;
642
676
  if (_this.stepRejectCounter >= maxRetries) {
643
- var _this$analyticsHelper28;
677
+ var _this$analyticsHelper29;
644
678
  logger("The steps were rejected too many times (tries=".concat(_this.stepRejectCounter, ", limit=").concat(_provider.MAX_STEP_REJECTED_ERROR, "). Trying to catch-up."));
645
- (_this$analyticsHelper28 = _this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 || _this$analyticsHelper28.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
679
+ (_this$analyticsHelper29 = _this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendActionEvent(_const.EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, _const.EVENT_STATUS.INFO);
646
680
  _this.throttledCatchupv2(_const.CatchupEventReason.STEPS_REJECTED);
647
681
  } else {
648
682
  // If committing steps failed try again automatically in 1s
@@ -665,6 +699,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
665
699
  this.isNameSpaceLocked = isNameSpaceLocked;
666
700
  this.enableErrorOnFailedDocumentApply = enableErrorOnFailedDocumentApply;
667
701
  this.options = options;
702
+ this.getConnected = getConnected;
668
703
  this.stepQueue = new _stepQueueState.StepQueueState();
669
704
  this.onErrorHandled = onErrorHandled;
670
705
  }
@@ -673,15 +708,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
673
708
  value: function getVersionFromCollabState(state, resource) {
674
709
  var collabState = (0, _prosemirrorCollab.getCollabState)(state);
675
710
  if (!collabState) {
676
- var _this$analyticsHelper29;
677
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 || _this$analyticsHelper29.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
711
+ var _this$analyticsHelper30;
712
+ (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), "".concat(resource, " called without collab state"));
678
713
  return 0;
679
714
  }
680
715
 
681
716
  // This should not happen in usual, just add error event in case it happens
682
717
  if (collabState.version === undefined) {
683
- var _this$analyticsHelper30;
684
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 || _this$analyticsHelper30.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
718
+ var _this$analyticsHelper31;
719
+ (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), "".concat(resource, " called with collab state missing version info"));
685
720
  return 0;
686
721
  }
687
722
  return collabState.version;
@@ -697,9 +732,15 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
697
732
  if (this.stepQueue.getQueue().length > 0) {
698
733
  var firstItem = this.stepQueue.shift();
699
734
  var currentVersion = this.getCurrentPmVersion();
735
+ // Ignored via go/ees005
736
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
700
737
  var expectedVersion = currentVersion + firstItem.steps.length;
738
+ // Ignored via go/ees005
739
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
701
740
  if (firstItem.version === expectedVersion) {
702
741
  logger("Applying data from queue!");
742
+ // Ignored via go/ees005
743
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
703
744
  this.processSteps(firstItem);
704
745
  // recur
705
746
  this.processQueue();
@@ -729,17 +770,19 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
729
770
  this.participantsService.emitTelepointersFromSteps(steps);
730
771
 
731
772
  // Resend local steps if none of the received steps originated with us!
773
+ // Ignored via go/ees005
774
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
732
775
  if (clientIds.indexOf(this.clientId) === -1) {
733
776
  setTimeout(function () {
734
777
  return _this2.sendStepsFromCurrentState();
735
778
  }, 100);
736
779
  }
737
780
  } catch (error) {
738
- var _this$analyticsHelper31;
781
+ var _this$analyticsHelper32;
739
782
  // ESS-6421: log if error processing steps when there are steps from the same userId but not the same clientId
740
783
  var userIdMatch = this.isStepsFromNewClientIdForSameUserId(steps);
741
784
  logger("Processing steps failed with error: ".concat(error, ". Triggering catch up call."));
742
- (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 || _this$analyticsHelper31.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
785
+ (_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(error, userIdMatch ? "Error while processing steps with new clientId" : "Error while processing steps");
743
786
  this.throttledCatchupv2(_const.CatchupEventReason.PROCESS_STEPS);
744
787
  }
745
788
  }
@@ -774,8 +817,8 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
774
817
  var _this$getState7;
775
818
  var state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
776
819
  if (!state) {
777
- var _this$analyticsHelper32;
778
- (_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 || _this$analyticsHelper32.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
820
+ var _this$analyticsHelper33;
821
+ (_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
779
822
  return;
780
823
  }
781
824
  this.send(null, null, state, sendAnalyticsEvent);
@@ -787,21 +830,29 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
787
830
  * Send steps from transaction to other participants
788
831
  * It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
789
832
  */
833
+ // Ignored via go/ees005
834
+ // eslint-disable-next-line @typescript-eslint/max-params
790
835
  function send(_tr, _oldState, newState, sendAnalyticsEvent) {
791
836
  var unconfirmedStepsData = (0, _prosemirrorCollab.sendableSteps)(newState);
792
837
  var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
793
838
 
794
839
  // Don't send any steps before we're ready.
795
- if (!unconfirmedStepsData) {
796
- return;
840
+ if ((0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps')) {
841
+ if (!unconfirmedStepsData || !this.getConnected()) {
842
+ return;
843
+ }
844
+ } else {
845
+ if (!unconfirmedStepsData) {
846
+ return;
847
+ }
797
848
  }
798
849
  var unconfirmedSteps = unconfirmedStepsData.steps;
799
850
  // sendAnalyticsEvent is only true when buffering is enabled,
800
851
  // to ensure that analytics events with the number of unconfirmed steps is only
801
852
  // sent once on connection (as opposed to on every step)
802
853
  if (sendAnalyticsEvent) {
803
- var _this$analyticsHelper33;
804
- (_this$analyticsHelper33 = this.analyticsHelper) === null || _this$analyticsHelper33 === void 0 || _this$analyticsHelper33.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
854
+ var _this$analyticsHelper34;
855
+ (_this$analyticsHelper34 = this.analyticsHelper) === null || _this$analyticsHelper34 === void 0 || _this$analyticsHelper34.sendActionEvent(_const.EVENT_ACTION.HAS_UNCONFIRMED_STEPS, _const.EVENT_STATUS.INFO, {
805
856
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
806
857
  });
807
858
  }
@@ -809,12 +860,28 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
809
860
  return;
810
861
  }
811
862
 
863
+ // If we are going to commit unconfirmed steps
864
+ // we need to lock them to ensure they don't get
865
+ // mutated in: `packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts`
866
+ if ((0, _platformFeatureFlags.fg)('platform_editor_merge_unconfirmed_steps')) {
867
+ unconfirmedStepsData.steps.forEach(function (s) {
868
+ if (isLockable(s)) {
869
+ var _s$lockStep;
870
+ (_s$lockStep = s.lockStep) === null || _s$lockStep === void 0 || _s$lockStep.call(s);
871
+ }
872
+ });
873
+ }
874
+
812
875
  // Avoid reference issues using a
813
876
  // method outside of the provider
814
877
  // scope
815
878
  (0, _commitStep.commitStepQueue)({
816
879
  broadcast: this.broadcast,
880
+ // Ignored via go/ees005
881
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
817
882
  userId: this.getUserId(),
883
+ // Ignored via go/ees005
884
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
818
885
  clientId: this.clientId,
819
886
  steps: unconfirmedSteps,
820
887
  version: version,
@@ -826,4 +893,7 @@ var DocumentService = exports.DocumentService = /*#__PURE__*/function () {
826
893
  });
827
894
  }
828
895
  }]);
829
- }();
896
+ }(); // Based on: packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts
897
+ function isLockable(step) {
898
+ return (step === null || step === void 0 ? void 0 : step.lockStep) !== undefined;
899
+ }
@@ -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
  }