@atlaskit/collab-provider 10.3.2 → 10.3.4
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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/document/catchupv2.js +9 -7
- package/dist/cjs/document/document-service.js +68 -59
- package/dist/cjs/provider/index.js +35 -34
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/document/catchupv2.js +2 -0
- package/dist/es2019/document/document-service.js +77 -67
- package/dist/es2019/provider/index.js +35 -34
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/document/catchupv2.js +9 -7
- package/dist/esm/document/document-service.js +69 -60
- package/dist/esm/provider/index.js +35 -34
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +2 -2
- package/dist/types/types.d.ts +5 -0
- package/dist/types-ts4.5/document/document-service.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +5 -0
- package/package.json +2 -2
|
@@ -107,6 +107,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
107
107
|
// shouldSkipDocumentInit will bypass the NCS draft fetch if the initial draft is passed to the provider
|
|
108
108
|
var shouldSkipDocumentInit = Boolean(_this.initialDraft);
|
|
109
109
|
_this.channel.on('connected', function (_ref2) {
|
|
110
|
+
var _this$documentService;
|
|
110
111
|
var sid = _ref2.sid,
|
|
111
112
|
initialized = _ref2.initialized;
|
|
112
113
|
_this.sessionId = sid;
|
|
@@ -114,6 +115,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
114
115
|
sid: sid,
|
|
115
116
|
initial: !initialized
|
|
116
117
|
});
|
|
118
|
+
var unconfirmedStepsLength = (_this$documentService = _this.documentService.getUnconfirmedSteps()) === null || _this$documentService === void 0 ? void 0 : _this$documentService.length;
|
|
117
119
|
|
|
118
120
|
// if buffering is enabled and the provider is initialized before connection,
|
|
119
121
|
// send any unconfirmed steps
|
|
@@ -138,11 +140,10 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
138
140
|
if (initialized && _this.disconnectedAt &&
|
|
139
141
|
// Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
140
142
|
Date.now() - _this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
_this.documentService.throttledCatchupv2(_const.CatchupEventReason.RECONNECTED, {
|
|
144
|
+
disconnectionPeriodSeconds: Math.floor((Date.now() - _this.disconnectedAt) / 1000),
|
|
145
|
+
unconfirmedStepsLength: unconfirmedStepsLength
|
|
144
146
|
});
|
|
145
|
-
_this.documentService.throttledCatchupv2(_const.CatchupEventReason.RECONNECTED);
|
|
146
147
|
}
|
|
147
148
|
_this.participantsService.startInactiveRemover(_this.sessionId);
|
|
148
149
|
_this.disconnectedAt = undefined;
|
|
@@ -193,13 +194,13 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
193
194
|
if (((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) === _ncsErrors.NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code) === _ncsErrors.NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS) {
|
|
194
195
|
_this.documentService.onStepRejectedError();
|
|
195
196
|
} else {
|
|
196
|
-
var _this$
|
|
197
|
-
(_this$
|
|
197
|
+
var _this$analyticsHelper2;
|
|
198
|
+
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
|
|
198
199
|
var mappedError = (0, _errorCodeMapper.errorCodeMapper)(error);
|
|
199
200
|
// Only emit errors to Confluence very intentionally because they will disconnect the collab provider
|
|
200
201
|
if (mappedError) {
|
|
201
|
-
var _this$
|
|
202
|
-
(_this$
|
|
202
|
+
var _this$analyticsHelper3;
|
|
203
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendProviderErrorEvent(mappedError);
|
|
203
204
|
_this.emit('error', mappedError);
|
|
204
205
|
}
|
|
205
206
|
}
|
|
@@ -225,7 +226,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
225
226
|
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
226
227
|
*/
|
|
227
228
|
(0, _defineProperty2.default)(_this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
228
|
-
var _this$
|
|
229
|
+
var _this$analyticsHelper4;
|
|
229
230
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
230
231
|
while (1) switch (_context.prev = _context.next) {
|
|
231
232
|
case 0:
|
|
@@ -237,7 +238,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
237
238
|
case 6:
|
|
238
239
|
_context.prev = 6;
|
|
239
240
|
_context.t0 = _context["catch"](0);
|
|
240
|
-
(_this$
|
|
241
|
+
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(_context.t0, 'Error while returning ADF version of current draft document');
|
|
241
242
|
throw new _customErrors.GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
|
|
242
243
|
case 10:
|
|
243
244
|
case "end":
|
|
@@ -251,7 +252,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
251
252
|
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
252
253
|
*/
|
|
253
254
|
(0, _defineProperty2.default)(_this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
254
|
-
var _this$
|
|
255
|
+
var _this$analyticsHelper5;
|
|
255
256
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
256
257
|
while (1) switch (_context2.prev = _context2.next) {
|
|
257
258
|
case 0:
|
|
@@ -263,7 +264,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
263
264
|
case 6:
|
|
264
265
|
_context2.prev = 6;
|
|
265
266
|
_context2.t0 = _context2["catch"](0);
|
|
266
|
-
(_this$
|
|
267
|
+
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
267
268
|
throw new _customErrors.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
268
269
|
case 10:
|
|
269
270
|
case "end":
|
|
@@ -387,7 +388,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
387
388
|
clientId: this.clientId
|
|
388
389
|
});
|
|
389
390
|
if (this.isBufferingEnabled && this.initialDraft && !this.isProviderInitialized) {
|
|
390
|
-
var _this$
|
|
391
|
+
var _this$analyticsHelper6;
|
|
391
392
|
var _this$initialDraft2 = this.initialDraft,
|
|
392
393
|
document = _this$initialDraft2.document,
|
|
393
394
|
version = _this$initialDraft2.version,
|
|
@@ -397,7 +398,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
397
398
|
version: version,
|
|
398
399
|
metadata: metadata
|
|
399
400
|
});
|
|
400
|
-
(_this$
|
|
401
|
+
(_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.PROVIDER_INITIALIZED, _const.EVENT_STATUS.INFO, {
|
|
401
402
|
isBuffered: true
|
|
402
403
|
});
|
|
403
404
|
}
|
|
@@ -406,8 +407,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
406
407
|
this.isChannelInitialized = true;
|
|
407
408
|
}
|
|
408
409
|
} catch (initError) {
|
|
409
|
-
var _this$
|
|
410
|
-
(_this$
|
|
410
|
+
var _this$analyticsHelper7;
|
|
411
|
+
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
411
412
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
412
413
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error', initError);
|
|
413
414
|
}
|
|
@@ -427,8 +428,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
427
428
|
this.isChannelInitialized = true;
|
|
428
429
|
}
|
|
429
430
|
} catch (initError) {
|
|
430
|
-
var _this$
|
|
431
|
-
(_this$
|
|
431
|
+
var _this$analyticsHelper8;
|
|
432
|
+
(_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
432
433
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
433
434
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error', initError);
|
|
434
435
|
}
|
|
@@ -438,9 +439,9 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
438
439
|
key: "checkForCookies",
|
|
439
440
|
value: function checkForCookies() {
|
|
440
441
|
if (!global.navigator.cookieEnabled) {
|
|
441
|
-
var _this$
|
|
442
|
+
var _this$analyticsHelper9;
|
|
442
443
|
var initError = new _customErrors.ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
|
|
443
|
-
(_this$
|
|
444
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
|
|
444
445
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
|
|
445
446
|
}
|
|
446
447
|
}
|
|
@@ -457,14 +458,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
457
458
|
value: function send(_tr, _oldState, newState) {
|
|
458
459
|
try {
|
|
459
460
|
if (this.isViewOnly()) {
|
|
460
|
-
var _this$
|
|
461
|
+
var _this$analyticsHelper10;
|
|
461
462
|
var error = {
|
|
462
463
|
message: 'Attempted to send steps in view only mode',
|
|
463
464
|
data: {
|
|
464
465
|
code: _internalErrors.INTERNAL_ERROR_CODE.VIEW_ONLY_STEPS_ERROR
|
|
465
466
|
}
|
|
466
467
|
};
|
|
467
|
-
(_this$
|
|
468
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, error.message);
|
|
468
469
|
return;
|
|
469
470
|
}
|
|
470
471
|
// Don't send steps while the document is locked (eg. when restoring the document)
|
|
@@ -474,8 +475,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
474
475
|
}
|
|
475
476
|
this.documentService.send(_tr, _oldState, newState);
|
|
476
477
|
} catch (error) {
|
|
477
|
-
var _this$
|
|
478
|
-
(_this$
|
|
478
|
+
var _this$analyticsHelper11;
|
|
479
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(error, 'Error while sending steps for a transaction');
|
|
479
480
|
throw new _customErrors.SendTransactionError('Error while sending steps for a transaction', error);
|
|
480
481
|
}
|
|
481
482
|
}
|
|
@@ -526,9 +527,9 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
526
527
|
this.participantsService.sendAIProviderChanged(_objectSpread(_objectSpread({}, basePayload), data));
|
|
527
528
|
}
|
|
528
529
|
} catch (error) {
|
|
529
|
-
var _this$
|
|
530
|
+
var _this$analyticsHelper12;
|
|
530
531
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
531
|
-
(_this$
|
|
532
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
532
533
|
}
|
|
533
534
|
}
|
|
534
535
|
}, {
|
|
@@ -579,8 +580,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
579
580
|
this.sendStepsTimer = undefined;
|
|
580
581
|
}
|
|
581
582
|
} catch (error) {
|
|
582
|
-
var _this$
|
|
583
|
-
(_this$
|
|
583
|
+
var _this$analyticsHelper13;
|
|
584
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 || _this$analyticsHelper13.sendErrorEvent(error, 'Error while shutting down the collab provider');
|
|
584
585
|
throw new _customErrors.DestroyError('Error while shutting down the collab provider', error);
|
|
585
586
|
}
|
|
586
587
|
this.clearTimers();
|
|
@@ -604,8 +605,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
604
605
|
}
|
|
605
606
|
this.metadataService.setTitle(title, broadcast);
|
|
606
607
|
} catch (error) {
|
|
607
|
-
var _this$
|
|
608
|
-
(_this$
|
|
608
|
+
var _this$analyticsHelper14;
|
|
609
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting title');
|
|
609
610
|
throw new _customErrors.SetTitleError('Error while setting title', error);
|
|
610
611
|
}
|
|
611
612
|
}
|
|
@@ -624,8 +625,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
624
625
|
try {
|
|
625
626
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
626
627
|
} catch (error) {
|
|
627
|
-
var _this$
|
|
628
|
-
(_this$
|
|
628
|
+
var _this$analyticsHelper15;
|
|
629
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting editor width');
|
|
629
630
|
throw new _customErrors.SetEditorWidthError('Error while setting editor width', error);
|
|
630
631
|
}
|
|
631
632
|
}
|
|
@@ -644,8 +645,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
644
645
|
}
|
|
645
646
|
this.metadataService.setMetadata(metadata);
|
|
646
647
|
} catch (error) {
|
|
647
|
-
var _this$
|
|
648
|
-
(_this$
|
|
648
|
+
var _this$analyticsHelper16;
|
|
649
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(error, 'Error while setting metadata');
|
|
649
650
|
throw new _customErrors.SetMetadataError('Error while setting metadata', error);
|
|
650
651
|
}
|
|
651
652
|
}
|
|
@@ -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 = "10.3.
|
|
8
|
+
var version = exports.version = "10.3.4";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -20,6 +20,8 @@ export const catchupv2 = async opt => {
|
|
|
20
20
|
throw error;
|
|
21
21
|
}
|
|
22
22
|
try {
|
|
23
|
+
var _opt$onCatchupComplet;
|
|
24
|
+
(_opt$onCatchupComplet = opt.onCatchupComplete) === null || _opt$onCatchupComplet === void 0 ? void 0 : _opt$onCatchupComplet.call(opt, steps);
|
|
23
25
|
// skip onStepsAdded if steps are undefined or empty
|
|
24
26
|
if (!steps || steps.length === 0) {
|
|
25
27
|
opt.updateMetadata(metadata);
|