@atlaskit/collab-provider 9.41.0 → 9.41.1

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.
@@ -298,7 +298,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
298
298
  _this.documentService = new _nullDocumentService.NullDocumentService();
299
299
  _this.api = new _nullApi.NullApi();
300
300
  } else {
301
- _this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.channel.fetchCatchupv2, _this.channel.fetchReconcile, _this.emitCallback, _this.channel.broadcast, function () {
301
+ _this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchupv2, _this.channel.fetchReconcile, _this.emitCallback, _this.channel.broadcast, function () {
302
302
  return _this.userId;
303
303
  }, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
304
304
  __livePage: _this.config.__livePage || false
package/dist/cjs/types.js CHANGED
@@ -19,5 +19,4 @@ var AcknowledgementResponseTypes = exports.AcknowledgementResponseTypes = /*#__P
19
19
  AcknowledgementResponseTypes["ERROR"] = "ERROR";
20
20
  return AcknowledgementResponseTypes;
21
21
  }({}); // ESS-2916 Type def for namespace status - lock/unlock
22
- // Catchup
23
22
  // CatchupV2
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/collab-provider";
8
- var version = exports.version = "9.41.0";
8
+ var version = exports.version = "9.41.1";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -164,53 +164,6 @@ export class Channel extends Emitter {
164
164
  this.emit('steps:added', data);
165
165
  }
166
166
  });
167
- _defineProperty(this, "fetchCatchup", async (fromVersion, clientId) => {
168
- try {
169
- const {
170
- doc,
171
- version,
172
- stepMaps,
173
- metadata
174
- } = await utils.requestService(this.config, {
175
- path: `document/${encodeURIComponent(this.config.documentAri)}/catchup`,
176
- queryParams: {
177
- version: fromVersion,
178
- clientId: clientId
179
- },
180
- requestInit: {
181
- headers: await this.commonHeaders()
182
- }
183
- });
184
- return {
185
- doc,
186
- version,
187
- stepMaps,
188
- metadata
189
- };
190
- } catch (error) {
191
- if (error.code === 404) {
192
- const errorNotFound = {
193
- message: 'The requested document is not found',
194
- data: {
195
- status: error.code,
196
- code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
197
- }
198
- };
199
- this.emit('error', errorNotFound);
200
- return {};
201
- }
202
- logger("Can't fetch the catchup", error.message);
203
- const errorCatchup = {
204
- message: 'Cannot fetch catchup from collab service',
205
- data: {
206
- status: error.status,
207
- code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
208
- }
209
- };
210
- this.emit('error', errorCatchup);
211
- throw error;
212
- }
213
- });
214
167
  _defineProperty(this, "fetchCatchupv2", async (fromVersion, clientId, catchUpOutofSync, reason) => {
215
168
  try {
216
169
  const {
@@ -8,7 +8,6 @@ import { INTERNAL_ERROR_CODE } from '../errors/internal-errors';
8
8
  import { createLogger, getStepUGCFreeDetails, sleep } from '../helpers/utils';
9
9
  import { MAX_STEP_REJECTED_ERROR, MAX_STEP_REJECTED_ERROR_AGGRESSIVE } from '../provider';
10
10
  import { commitStepQueue } from '../provider/commit-step';
11
- import { catchup } from './catchup';
12
11
  import { catchupv2 } from './catchupv2';
13
12
  import { StepQueueState } from './step-queue-state';
14
13
  import { CantSyncUpError, UpdateDocumentError } from '../errors/custom-errors';
@@ -24,7 +23,6 @@ export class DocumentService {
24
23
  * @param participantsService - The participants service, used when users are detected active when making changes to the document
25
24
  * and to emit their telepointers from steps they add
26
25
  * @param analyticsHelper - Helper for analytics events
27
- * @param fetchCatchup - StepMap based - Function to fetch "catchup" data, data required to rebase current steps to the latest version.
28
26
  * @param fetchCatchupv2 - Step based - Function to fetch "catchupv2" data, data required to rebase current steps to the latest version.
29
27
  * @param fetchReconcile - Function to call "reconcile" from NCS backend
30
28
  * @param providerEmitCallback - Callback for emitting events to listeners on the provider
@@ -34,64 +32,13 @@ export class DocumentService {
34
32
  * @param metadataService
35
33
  * @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
36
34
  */
37
- constructor(participantsService, analyticsHelper, fetchCatchup, fetchCatchupv2, fetchReconcile, providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService, isNameSpaceLocked, enableErrorOnFailedDocumentApply = false, options = {
35
+ constructor(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile, providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService, isNameSpaceLocked, enableErrorOnFailedDocumentApply = false, options = {
38
36
  __livePage: false
39
37
  }) {
40
38
  // Fires analytics to editor when collab editor cannot sync up
41
39
  _defineProperty(this, "stepRejectCounter", 0);
42
40
  _defineProperty(this, "aggressiveCatchup", false);
43
41
  _defineProperty(this, "catchUpOutofSync", false);
44
- /**
45
- * To prevent calling catchup to often, use lodash throttle to reduce the frequency
46
- */
47
- _defineProperty(this, "throttledCatchup", throttle(() => this.catchup(), CATCHUP_THROTTLE, {
48
- leading: false,
49
- // TODO: why shouldn't this be leading?
50
- trailing: true
51
- }));
52
- /**
53
- * Called when:
54
- * * session established(offline -> online)
55
- * * try to accept steps but version is behind.
56
- */
57
- _defineProperty(this, "catchup", async () => {
58
- const start = new Date().getTime();
59
- // if the queue is already paused, we are busy with something else, so don't proceed.
60
- if (this.stepQueue.isPaused()) {
61
- logger(`Queue is paused. Aborting.`);
62
- return;
63
- }
64
- this.stepQueue.pauseQueue();
65
- try {
66
- var _this$analyticsHelper;
67
- await catchup({
68
- getCurrentPmVersion: this.getCurrentPmVersion,
69
- fetchCatchup: this.fetchCatchup,
70
- getUnconfirmedSteps: this.getUnconfirmedSteps,
71
- filterQueue: this.stepQueue.filterQueue,
72
- applyLocalSteps: this.applyLocalSteps,
73
- updateDocument: this.updateDocument,
74
- updateMetadata: this.metadataService.updateMetadata,
75
- analyticsHelper: this.analyticsHelper,
76
- clientId: this.clientId
77
- });
78
- const latency = new Date().getTime() - start;
79
- (_this$analyticsHelper = this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
80
- latency
81
- });
82
- } catch (error) {
83
- var _this$analyticsHelper2;
84
- const latency = new Date().getTime() - start;
85
- (_this$analyticsHelper2 = this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
86
- latency
87
- });
88
- } finally {
89
- this.stepQueue.resumeQueue();
90
- this.processQueue();
91
- this.sendStepsFromCurrentState(); // this will eventually retry catchup as it calls commitStepQueue which will either catchup on onStepsAdded or onErrorHandled
92
- this.stepRejectCounter = 0;
93
- }
94
- });
95
42
  /**
96
43
  * To prevent calling catchup to often, use lodash throttle to reduce the frequency
97
44
  * @param reason - optional reason to attach.
@@ -131,7 +78,7 @@ export class DocumentService {
131
78
  }
132
79
  this.stepQueue.pauseQueue();
133
80
  try {
134
- var _this$analyticsHelper3;
81
+ var _this$analyticsHelper;
135
82
  /**
136
83
  * We have two options when out of sync:
137
84
  * - Check a boolean that ensures we reset the document next time we catchup
@@ -155,13 +102,13 @@ export class DocumentService {
155
102
  reason
156
103
  });
157
104
  const latency = new Date().getTime() - start;
158
- (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
105
+ (_this$analyticsHelper = this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
159
106
  latency
160
107
  });
161
108
  } catch (error) {
162
- var _this$analyticsHelper4;
109
+ var _this$analyticsHelper2;
163
110
  const latency = new Date().getTime() - start;
164
- (_this$analyticsHelper4 = this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
111
+ (_this$analyticsHelper2 = this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
165
112
  latency
166
113
  });
167
114
  } finally {
@@ -175,21 +122,21 @@ export class DocumentService {
175
122
  var _this$getState;
176
123
  const state = (_this$getState = this.getState) === null || _this$getState === void 0 ? void 0 : _this$getState.call(this);
177
124
  if (!state) {
178
- var _this$analyticsHelper5;
179
- (_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
125
+ var _this$analyticsHelper3;
126
+ (_this$analyticsHelper3 = this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getCurrentPmVersion called without state');
180
127
  return 0;
181
128
  }
182
129
  return this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
183
130
  });
184
131
  _defineProperty(this, "getCurrentState", async () => {
185
132
  try {
186
- var _this$getState2, _this$analyticsHelper7;
133
+ var _this$getState2, _this$analyticsHelper5;
187
134
  startMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
188
135
 
189
136
  // Convert ProseMirror document in Editor state to ADF document
190
137
  if (!((_this$getState2 = this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(this))) {
191
- var _this$analyticsHelper6;
192
- (_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
138
+ var _this$analyticsHelper4;
139
+ (_this$analyticsHelper4 = this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
193
140
  }
194
141
  const state = this.getState();
195
142
  const adfDocument = new JSONTransformer().encode(state.doc);
@@ -200,17 +147,17 @@ export class DocumentService {
200
147
  stepVersion: version
201
148
  };
202
149
  const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
203
- (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
150
+ (_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
204
151
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
205
152
  });
206
153
  return currentState;
207
154
  } catch (error) {
208
- var _this$analyticsHelper8, _this$analyticsHelper9;
155
+ var _this$analyticsHelper6, _this$analyticsHelper7;
209
156
  const measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, this.analyticsHelper);
210
- (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
157
+ (_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
211
158
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
212
159
  });
213
- (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, 'Error while returning ADF version of current draft document');
160
+ (_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(error, 'Error while returning ADF version of current draft document');
214
161
  throw error; // Reject the promise so the consumer can react to it failing
215
162
  }
216
163
  });
@@ -218,8 +165,8 @@ export class DocumentService {
218
165
  var _this$getState3, _sendableSteps;
219
166
  const state = (_this$getState3 = this.getState) === null || _this$getState3 === void 0 ? void 0 : _this$getState3.call(this);
220
167
  if (!state) {
221
- var _this$analyticsHelper10;
222
- (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
168
+ var _this$analyticsHelper8;
169
+ (_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedStepsOrigins called without state');
223
170
  return;
224
171
  }
225
172
  return (_sendableSteps = sendableSteps(state)) === null || _sendableSteps === void 0 ? void 0 : _sendableSteps.origins;
@@ -228,8 +175,8 @@ export class DocumentService {
228
175
  var _this$getState4, _sendableSteps2;
229
176
  const state = (_this$getState4 = this.getState) === null || _this$getState4 === void 0 ? void 0 : _this$getState4.call(this);
230
177
  if (!state) {
231
- var _this$analyticsHelper11;
232
- (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
178
+ var _this$analyticsHelper9;
179
+ (_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(new Error('No editor state when calling ProseMirror function'), 'getUnconfirmedSteps called without state');
233
180
  return;
234
181
  }
235
182
  return (_sendableSteps2 = sendableSteps(state)) === null || _sendableSteps2 === void 0 ? void 0 : _sendableSteps2.steps;
@@ -268,8 +215,8 @@ export class DocumentService {
268
215
  userId
269
216
  }) => userId));
270
217
  } catch (stepsAddedError) {
271
- var _this$analyticsHelper12;
272
- (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
218
+ var _this$analyticsHelper10;
219
+ (_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(stepsAddedError, 'Error while adding steps in the provider');
273
220
  this.onErrorHandled({
274
221
  message: 'Error while adding steps in the provider',
275
222
  data: {
@@ -296,7 +243,7 @@ export class DocumentService {
296
243
  const currentState = await this.getCurrentState();
297
244
  const useReconcile = Boolean((unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) && currentState && !targetClientId);
298
245
  try {
299
- var _this$analyticsHelper13;
246
+ var _this$analyticsHelper11;
300
247
  // Reset the editor,
301
248
  // - Replace the document, keep in sync with the server
302
249
  // - Replace the version number, so editor is in sync with NCS server and can commit new changes.
@@ -319,7 +266,7 @@ export class DocumentService {
319
266
  // as this results in all changes made while the client was out of sync being lost
320
267
  this.applyLocalSteps(unconfirmedSteps);
321
268
  }
322
- (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
269
+ (_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.SUCCESS, {
323
270
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
324
271
  hasTitle: !!(metadata !== null && metadata !== void 0 && metadata.title),
325
272
  useReconcile,
@@ -327,14 +274,14 @@ export class DocumentService {
327
274
  targetClientId
328
275
  });
329
276
  } catch (restoreError) {
330
- var _this$analyticsHelper14, _this$analyticsHelper15;
331
- (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
277
+ var _this$analyticsHelper12, _this$analyticsHelper13;
278
+ (_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendActionEvent(EVENT_ACTION.REINITIALISE_DOCUMENT, EVENT_STATUS.FAILURE, {
332
279
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length,
333
280
  useReconcile,
334
281
  clientId: this.clientId,
335
282
  targetClientId
336
283
  });
337
- (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
284
+ (_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(restoreError, `Error while reinitialising document. Use Reconcile: ${useReconcile}`);
338
285
  this.onErrorHandled({
339
286
  message: 'Caught error while trying to recover the document',
340
287
  data: {
@@ -348,7 +295,7 @@ export class DocumentService {
348
295
  _defineProperty(this, "getFinalAcknowledgedState", async () => {
349
296
  this.aggressiveCatchup = true;
350
297
  try {
351
- var _this$analyticsHelper16;
298
+ var _this$analyticsHelper14;
352
299
  startMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
353
300
  let finalAcknowledgedState;
354
301
  try {
@@ -365,19 +312,19 @@ export class DocumentService {
365
312
  };
366
313
  }
367
314
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
368
- (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
315
+ (_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
369
316
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
370
317
  });
371
318
  this.aggressiveCatchup = false;
372
319
  return finalAcknowledgedState;
373
320
  } catch (error) {
374
- var _this$analyticsHelper17, _this$analyticsHelper18;
321
+ var _this$analyticsHelper15, _this$analyticsHelper16;
375
322
  this.aggressiveCatchup = false;
376
323
  const measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, this.analyticsHelper);
377
- (_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
324
+ (_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
378
325
  latency: measure === null || measure === void 0 ? void 0 : measure.duration
379
326
  });
380
- (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
327
+ (_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
381
328
  throw error; // Reject the promise so the consumer can react to it failing
382
329
  }
383
330
  });
@@ -403,7 +350,7 @@ export class DocumentService {
403
350
  // ESS-5023: only emit error event if updated client version is still behind server version
404
351
  // client version could become higher than server version due to user editing or plugin adding steps
405
352
  if (updatedVersion < version) {
406
- var _doc$content, _this$analyticsHelper19;
353
+ var _doc$content, _this$analyticsHelper17;
407
354
  const error = new UpdateDocumentError('Failed to update the document', {
408
355
  newVersion: version,
409
356
  editorVersion: updatedVersion,
@@ -411,7 +358,7 @@ export class DocumentService {
411
358
  docHasContent: (doc === null || doc === void 0 ? void 0 : (_doc$content = doc.content) === null || _doc$content === void 0 ? void 0 : _doc$content.length) >= 1,
412
359
  isDocContentValid
413
360
  });
414
- (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(error, 'Failed to update the document in document service');
361
+ (_this$analyticsHelper17 = this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendErrorEvent(error, 'Failed to update the document in document service');
415
362
  if (this.enableErrorOnFailedDocumentApply) {
416
363
  this.onErrorHandled({
417
364
  message: 'The provider failed to apply changes to the editor',
@@ -428,8 +375,8 @@ export class DocumentService {
428
375
  }
429
376
  // Otherwise just fail silently for now
430
377
  } else {
431
- var _this$analyticsHelper20, _doc$content2;
432
- (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
378
+ var _this$analyticsHelper18, _doc$content2;
379
+ (_this$analyticsHelper18 = this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.UPDATE_DOCUMENT, EVENT_STATUS.SUCCESS, {
433
380
  newVersion: version,
434
381
  editorVersion: updatedVersion,
435
382
  isDocTruthy: !!doc,
@@ -442,8 +389,8 @@ export class DocumentService {
442
389
  try {
443
390
  var _this$getState5;
444
391
  if (!((_this$getState5 = this.getState) !== null && _this$getState5 !== void 0 && _this$getState5.call(this))) {
445
- var _this$analyticsHelper21;
446
- (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
392
+ var _this$analyticsHelper19;
393
+ (_this$analyticsHelper19 = this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
447
394
  }
448
395
  const state = this.getState();
449
396
  const content = (doc.content || []).map(child => state.schema.nodeFromJSON(child));
@@ -467,7 +414,7 @@ export class DocumentService {
467
414
  const unconfirmedSteps = this.getUnconfirmedSteps();
468
415
  try {
469
416
  if (unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length) {
470
- var _this$getState6, _this$analyticsHelper23;
417
+ var _this$getState6, _this$analyticsHelper21;
471
418
  startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
472
419
  let count = 0;
473
420
  // We use origins here as steps can be rebased. When steps are rebased a new step is created.
@@ -478,8 +425,8 @@ export class DocumentService {
478
425
  const lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
479
426
  let isLastTrConfirmed = false;
480
427
  if (!((_this$getState6 = this.getState) !== null && _this$getState6 !== void 0 && _this$getState6.call(this))) {
481
- var _this$analyticsHelper22;
482
- (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
428
+ var _this$analyticsHelper20;
429
+ (_this$analyticsHelper20 = this.analyticsHelper) === null || _this$analyticsHelper20 === void 0 ? void 0 : _this$analyticsHelper20.sendErrorEvent(new Error('Editor state is undefined'), 'commitUnconfirmedSteps called without state');
483
430
  }
484
431
  while (!isLastTrConfirmed) {
485
432
  this.sendStepsFromCurrentState();
@@ -512,35 +459,35 @@ export class DocumentService {
512
459
  }
513
460
  }
514
461
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
515
- (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
462
+ (_this$analyticsHelper21 = this.analyticsHelper) === null || _this$analyticsHelper21 === void 0 ? void 0 : _this$analyticsHelper21.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
516
463
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
517
464
  // upon success, emit the total number of unconfirmed steps we synced
518
465
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
519
466
  });
520
467
  }
521
468
  } catch (error) {
522
- var _this$analyticsHelper24, _this$analyticsHelper25;
469
+ var _this$analyticsHelper22, _this$analyticsHelper23;
523
470
  const measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, this.analyticsHelper);
524
- (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
471
+ (_this$analyticsHelper22 = this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 ? void 0 : _this$analyticsHelper22.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
525
472
  latency: measure === null || measure === void 0 ? void 0 : measure.duration,
526
473
  numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
527
474
  });
528
- (_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendErrorEvent(error, 'Error while committing unconfirmed steps');
475
+ (_this$analyticsHelper23 = this.analyticsHelper) === null || _this$analyticsHelper23 === void 0 ? void 0 : _this$analyticsHelper23.sendErrorEvent(error, 'Error while committing unconfirmed steps');
529
476
  throw error;
530
477
  }
531
478
  });
532
479
  _defineProperty(this, "onStepRejectedError", () => {
533
- var _this$analyticsHelper26;
480
+ var _this$analyticsHelper24;
534
481
  this.stepRejectCounter++;
535
482
  logger(`Steps rejected (tries=${this.stepRejectCounter})`);
536
- (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
483
+ (_this$analyticsHelper24 = this.analyticsHelper) === null || _this$analyticsHelper24 === void 0 ? void 0 : _this$analyticsHelper24.sendActionEvent(EVENT_ACTION.SEND_STEPS_RETRY, EVENT_STATUS.INFO, {
537
484
  count: this.stepRejectCounter
538
485
  });
539
486
  let maxRetries = this.aggressiveCatchup ? MAX_STEP_REJECTED_ERROR_AGGRESSIVE : MAX_STEP_REJECTED_ERROR;
540
487
  if (this.stepRejectCounter >= maxRetries) {
541
- var _this$analyticsHelper27;
488
+ var _this$analyticsHelper25;
542
489
  logger(`The steps were rejected too many times (tries=${this.stepRejectCounter}, limit=${MAX_STEP_REJECTED_ERROR}). Trying to catch-up.`);
543
- (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
490
+ (_this$analyticsHelper25 = this.analyticsHelper) === null || _this$analyticsHelper25 === void 0 ? void 0 : _this$analyticsHelper25.sendActionEvent(EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY, EVENT_STATUS.INFO);
544
491
  this.throttledCatchupv2(CatchupEventReason.STEPS_REJECTED);
545
492
  } else {
546
493
  // If committing steps failed try again automatically in 1s
@@ -552,7 +499,6 @@ export class DocumentService {
552
499
  });
553
500
  this.participantsService = participantsService;
554
501
  this.analyticsHelper = analyticsHelper;
555
- this.fetchCatchup = fetchCatchup;
556
502
  this.fetchCatchupv2 = fetchCatchupv2;
557
503
  this.fetchReconcile = fetchReconcile;
558
504
  this.providerEmitCallback = providerEmitCallback;
@@ -568,15 +514,15 @@ export class DocumentService {
568
514
  getVersionFromCollabState(state, resource) {
569
515
  const collabState = getCollabState(state);
570
516
  if (!collabState) {
571
- var _this$analyticsHelper28;
572
- (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
517
+ var _this$analyticsHelper26;
518
+ (_this$analyticsHelper26 = this.analyticsHelper) === null || _this$analyticsHelper26 === void 0 ? void 0 : _this$analyticsHelper26.sendErrorEvent(new Error('No collab state when calling ProseMirror function'), `${resource} called without collab state`);
573
519
  return 0;
574
520
  }
575
521
 
576
522
  // This should not happen in usual, just add error event in case it happens
577
523
  if (collabState.version === undefined) {
578
- var _this$analyticsHelper29;
579
- (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
524
+ var _this$analyticsHelper27;
525
+ (_this$analyticsHelper27 = this.analyticsHelper) === null || _this$analyticsHelper27 === void 0 ? void 0 : _this$analyticsHelper27.sendErrorEvent(new Error('Collab state missing version info when calling ProseMirror function'), `${resource} called with collab state missing version info`);
580
526
  return 0;
581
527
  }
582
528
  return collabState.version;
@@ -624,9 +570,9 @@ export class DocumentService {
624
570
  setTimeout(() => this.sendStepsFromCurrentState(), 100);
625
571
  }
626
572
  } catch (error) {
627
- var _this$analyticsHelper30;
573
+ var _this$analyticsHelper28;
628
574
  logger(`Processing steps failed with error: ${error}. Triggering catch up call.`);
629
- (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendErrorEvent(error, 'Error while processing steps');
575
+ (_this$analyticsHelper28 = this.analyticsHelper) === null || _this$analyticsHelper28 === void 0 ? void 0 : _this$analyticsHelper28.sendErrorEvent(error, 'Error while processing steps');
630
576
  this.throttledCatchupv2(CatchupEventReason.PROCESS_STEPS);
631
577
  }
632
578
  }
@@ -653,8 +599,8 @@ export class DocumentService {
653
599
  var _this$getState7;
654
600
  const state = (_this$getState7 = this.getState) === null || _this$getState7 === void 0 ? void 0 : _this$getState7.call(this);
655
601
  if (!state) {
656
- var _this$analyticsHelper31;
657
- (_this$analyticsHelper31 = this.analyticsHelper) === null || _this$analyticsHelper31 === void 0 ? void 0 : _this$analyticsHelper31.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
602
+ var _this$analyticsHelper29;
603
+ (_this$analyticsHelper29 = this.analyticsHelper) === null || _this$analyticsHelper29 === void 0 ? void 0 : _this$analyticsHelper29.sendErrorEvent(new Error('Editor state is undefined'), 'sendStepsFromCurrentState called without state');
658
604
  return;
659
605
  }
660
606
  this.send(null, null, state, sendAnalyticsEvent);
@@ -676,8 +622,8 @@ export class DocumentService {
676
622
  // to ensure that analytics events with the number of unconfirmed steps is only
677
623
  // sent once on connection (as opposed to on every step)
678
624
  if (sendAnalyticsEvent) {
679
- var _this$analyticsHelper32;
680
- (_this$analyticsHelper32 = this.analyticsHelper) === null || _this$analyticsHelper32 === void 0 ? void 0 : _this$analyticsHelper32.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
625
+ var _this$analyticsHelper30;
626
+ (_this$analyticsHelper30 = this.analyticsHelper) === null || _this$analyticsHelper30 === void 0 ? void 0 : _this$analyticsHelper30.sendActionEvent(EVENT_ACTION.HAS_UNCONFIRMED_STEPS, EVENT_STATUS.INFO, {
681
627
  numUnconfirmedSteps: (unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length) || 0
682
628
  });
683
629
  }
@@ -251,7 +251,7 @@ export class Provider extends Emitter {
251
251
  this.documentService = new NullDocumentService();
252
252
  this.api = new NullApi();
253
253
  } else {
254
- this.documentService = new DocumentService(this.participantsService, this.analyticsHelper, this.channel.fetchCatchup, this.channel.fetchCatchupv2, this.channel.fetchReconcile, this.emitCallback, this.channel.broadcast, () => this.userId, this.onErrorHandled, this.metadataService, this.namespaceService.getIsNamespaceLocked.bind(this.namespaceService), this.config.enableErrorOnFailedDocumentApply, {
254
+ this.documentService = new DocumentService(this.participantsService, this.analyticsHelper, this.channel.fetchCatchupv2, this.channel.fetchReconcile, this.emitCallback, this.channel.broadcast, () => this.userId, this.onErrorHandled, this.metadataService, this.namespaceService.getIsNamespaceLocked.bind(this.namespaceService), this.config.enableErrorOnFailedDocumentApply, {
255
255
  __livePage: this.config.__livePage || false
256
256
  });
257
257
  this.api = new Api(config, this.documentService, this.channel);
@@ -21,6 +21,4 @@ export let AcknowledgementResponseTypes = /*#__PURE__*/function (Acknowledgement
21
21
 
22
22
  // ESS-2916 Type def for namespace status - lock/unlock
23
23
 
24
- // Catchup
25
-
26
24
  // CatchupV2
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "9.41.0";
2
+ export const version = "9.41.1";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };