@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.
- package/CHANGELOG.md +15 -0
- package/dist/cjs/analytics/analytics-helper.js +10 -0
- package/dist/cjs/analytics/performance.js +4 -1
- package/dist/cjs/api/null-api.js +3 -1
- package/dist/cjs/channel.js +22 -1
- package/dist/cjs/connectivity/network.js +8 -0
- package/dist/cjs/connectivity/reconnect-helper.js +4 -0
- package/dist/cjs/document/catchupv2.js +17 -8
- package/dist/cjs/document/document-service.js +133 -63
- package/dist/cjs/emitter.js +10 -0
- package/dist/cjs/helpers/utils.js +16 -7
- package/dist/cjs/metadata/metadata-service.js +4 -1
- package/dist/cjs/namespace/namespace-service.js +2 -0
- package/dist/cjs/participants/participants-service.js +6 -0
- package/dist/cjs/provider/commit-step.js +7 -2
- package/dist/cjs/provider/index.js +54 -35
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/analytics/analytics-helper.js +10 -0
- package/dist/es2019/analytics/performance.js +4 -1
- package/dist/es2019/api/null-api.js +2 -0
- package/dist/es2019/channel.js +26 -0
- package/dist/es2019/connectivity/network.js +8 -0
- package/dist/es2019/connectivity/reconnect-helper.js +4 -0
- package/dist/es2019/document/catchupv2.js +10 -1
- package/dist/es2019/document/document-service.js +144 -71
- package/dist/es2019/emitter.js +11 -0
- package/dist/es2019/helpers/utils.js +10 -2
- package/dist/es2019/metadata/metadata-service.js +4 -1
- package/dist/es2019/namespace/namespace-service.js +2 -0
- package/dist/es2019/participants/participants-service.js +6 -0
- package/dist/es2019/provider/commit-step.js +8 -3
- package/dist/es2019/provider/index.js +54 -35
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/analytics/analytics-helper.js +10 -0
- package/dist/esm/analytics/performance.js +4 -1
- package/dist/esm/api/null-api.js +3 -1
- package/dist/esm/channel.js +22 -1
- package/dist/esm/connectivity/network.js +8 -0
- package/dist/esm/connectivity/reconnect-helper.js +4 -0
- package/dist/esm/document/catchupv2.js +17 -8
- package/dist/esm/document/document-service.js +137 -64
- package/dist/esm/emitter.js +11 -0
- package/dist/esm/helpers/utils.js +16 -7
- package/dist/esm/metadata/metadata-service.js +4 -1
- package/dist/esm/namespace/namespace-service.js +2 -0
- package/dist/esm/participants/participants-service.js +6 -0
- package/dist/esm/provider/commit-step.js +8 -3
- package/dist/esm/provider/index.js +54 -35
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +6 -4
- package/dist/types/types.d.ts +5 -0
- package/dist/types-ts4.5/document/document-service.d.ts +6 -4
- package/dist/types-ts4.5/types.d.ts +5 -0
- package/package.json +6 -3
- package/tsconfig.json +0 -1
|
@@ -7,13 +7,19 @@ exports.isAIProviderID = exports.getSubProduct = exports.getStepUGCFreeDetails =
|
|
|
7
7
|
exports.sleep = sleep;
|
|
8
8
|
var createLogger = exports.createLogger = function createLogger(prefix) {
|
|
9
9
|
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
|
|
10
|
-
return
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
return (
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
function (msg) {
|
|
14
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
15
|
+
// Ignored via go/ees005
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
if (window.COLLAB_PROVIDER_LOGGER) {
|
|
18
|
+
// eslint-disable-next-line no-console
|
|
19
|
+
console.log("%cCollab-".concat(prefix, ": ").concat(msg), "color: ".concat(color, "; font-weight: bold"), data);
|
|
20
|
+
}
|
|
15
21
|
}
|
|
16
|
-
|
|
22
|
+
);
|
|
17
23
|
};
|
|
18
24
|
function sleep(ms) {
|
|
19
25
|
return new Promise(function (resolve) {
|
|
@@ -46,7 +52,10 @@ var getStepUGCFreeDetails = exports.getStepUGCFreeDetails = function getStepUGCF
|
|
|
46
52
|
}
|
|
47
53
|
var contentTypes = '';
|
|
48
54
|
if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
|
|
49
|
-
contentTypes = stepJson.slice.content
|
|
55
|
+
contentTypes = stepJson.slice.content
|
|
56
|
+
// Ignored via go/ees005
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
58
|
+
.map(function (c) {
|
|
50
59
|
return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
|
|
51
60
|
}).join(', ');
|
|
52
61
|
}
|
|
@@ -10,7 +10,10 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
|
|
|
10
10
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
11
|
var _isEqual = _interopRequireDefault(require("lodash/isEqual"));
|
|
12
12
|
var MetadataService = exports.MetadataService = /*#__PURE__*/function () {
|
|
13
|
-
function MetadataService(
|
|
13
|
+
function MetadataService(
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
providerEmitCallback, broadcastMetadata) {
|
|
14
17
|
var _this = this;
|
|
15
18
|
(0, _classCallCheck2.default)(this, MetadataService);
|
|
16
19
|
(0, _defineProperty2.default)(this, "metadata", {});
|
|
@@ -28,6 +28,8 @@ var NamespaceService = exports.NamespaceService = /*#__PURE__*/(0, _createClass2
|
|
|
28
28
|
/**
|
|
29
29
|
* ESS-2916 namespace status event- lock/unlock
|
|
30
30
|
*/
|
|
31
|
+
// Ignored via go/ees005
|
|
32
|
+
// eslint-disable-next-line require-await
|
|
31
33
|
(0, _defineProperty2.default)(this, "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
32
34
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(_ref) {
|
|
33
35
|
var isLocked, waitTimeInMs, timestamp, start;
|
|
@@ -31,6 +31,8 @@ var SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
|
|
|
31
31
|
* @param sendPresenceJoined Callback to Channel class
|
|
32
32
|
*/
|
|
33
33
|
var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function () {
|
|
34
|
+
// Ignored via go/ees005
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
34
36
|
function ParticipantsService(analyticsHelper) {
|
|
35
37
|
var _this = this;
|
|
36
38
|
var participantsState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new _participantsState.ParticipantsState();
|
|
@@ -188,6 +190,8 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
|
|
|
188
190
|
try {
|
|
189
191
|
_this.emit('disconnected', {
|
|
190
192
|
reason: (0, _disconnectedReasonMapper.disconnectedReasonMapper)(reason),
|
|
193
|
+
// Ignored via go/ees005
|
|
194
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
191
195
|
sid: sessionId
|
|
192
196
|
});
|
|
193
197
|
} catch (error) {
|
|
@@ -373,6 +377,8 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
|
|
|
373
377
|
(0, _defineProperty2.default)(this, "onPresence", function (payload) {
|
|
374
378
|
try {
|
|
375
379
|
logger('onPresence userId: ', payload.userId);
|
|
380
|
+
// Ignored via go/ees005
|
|
381
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
376
382
|
_this.setUserId(payload.userId);
|
|
377
383
|
_this.sendPresence();
|
|
378
384
|
_this.sendPresenceJoined();
|
|
@@ -54,7 +54,7 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
|
|
|
54
54
|
// - doesn't impact any indexes,
|
|
55
55
|
// - is setup for last write wins,
|
|
56
56
|
// - and is just a boolean -- so no real risk of data loss.
|
|
57
|
-
if ((0, _platformFeatureFlags.
|
|
57
|
+
if (__livePage && (0, _platformFeatureFlags.fg)('platform.editor.live-pages-expand-divergence')) {
|
|
58
58
|
// @atlaskit/platform-feature-flags
|
|
59
59
|
stepsWithClientAndUserId = stepsWithClientAndUserId.map(function (step) {
|
|
60
60
|
if (isExpandChangeStep(step)) {
|
|
@@ -103,7 +103,10 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
|
|
|
103
103
|
analyticsHelper === null || analyticsHelper === void 0 || analyticsHelper.sendActionEvent(_const.EVENT_ACTION.ADD_STEPS, _const.EVENT_STATUS.SUCCESS_10x_SAMPLED, {
|
|
104
104
|
type: _const.ADD_STEPS_TYPE.ACCEPTED,
|
|
105
105
|
latency: latency,
|
|
106
|
-
stepType: (0, _countBy.default)(stepsWithClientAndUserId,
|
|
106
|
+
stepType: (0, _countBy.default)(stepsWithClientAndUserId,
|
|
107
|
+
// Ignored via go/ees005
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
109
|
+
function (stepWithClientAndUserId) {
|
|
107
110
|
return stepWithClientAndUserId.stepType;
|
|
108
111
|
})
|
|
109
112
|
});
|
|
@@ -145,6 +148,8 @@ var commitStepQueue = exports.commitStepQueue = function commitStepQueue(_ref) {
|
|
|
145
148
|
}
|
|
146
149
|
};
|
|
147
150
|
function isExpandChangeStep(step) {
|
|
151
|
+
// Ignored via go/ees005
|
|
152
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
148
153
|
if (step.stepType === 'setAttrs' && '__expanded' in step.attrs) {
|
|
149
154
|
return true;
|
|
150
155
|
}
|
|
@@ -71,6 +71,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
71
71
|
* @param evt - Event name to emit to subscribers
|
|
72
72
|
* @param data - Event data to emit to subscribers
|
|
73
73
|
*/
|
|
74
|
+
// Ignored via go/ees005
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
74
76
|
(0, _defineProperty2.default)(_this, "emitCallback", function (evt, data) {
|
|
75
77
|
return _this.emit(evt, data);
|
|
76
78
|
});
|
|
@@ -105,6 +107,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
105
107
|
// shouldSkipDocumentInit will bypass the NCS draft fetch if the initial draft is passed to the provider
|
|
106
108
|
var shouldSkipDocumentInit = Boolean(_this.initialDraft);
|
|
107
109
|
_this.channel.on('connected', function (_ref2) {
|
|
110
|
+
var _this$documentService;
|
|
108
111
|
var sid = _ref2.sid,
|
|
109
112
|
initialized = _ref2.initialized;
|
|
110
113
|
_this.sessionId = sid;
|
|
@@ -112,6 +115,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
112
115
|
sid: sid,
|
|
113
116
|
initial: !initialized
|
|
114
117
|
});
|
|
118
|
+
var unconfirmedStepsLength = (_this$documentService = _this.documentService.getUnconfirmedSteps()) === null || _this$documentService === void 0 ? void 0 : _this$documentService.length;
|
|
115
119
|
|
|
116
120
|
// if buffering is enabled and the provider is initialized before connection,
|
|
117
121
|
// send any unconfirmed steps
|
|
@@ -136,11 +140,10 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
136
140
|
if (initialized && _this.disconnectedAt &&
|
|
137
141
|
// Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
138
142
|
Date.now() - _this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
143
|
+
_this.documentService.throttledCatchupv2(_const.CatchupEventReason.RECONNECTED, {
|
|
144
|
+
disconnectionPeriodSeconds: Math.floor((Date.now() - _this.disconnectedAt) / 1000),
|
|
145
|
+
unconfirmedStepsLength: unconfirmedStepsLength
|
|
142
146
|
});
|
|
143
|
-
_this.documentService.throttledCatchupv2(_const.CatchupEventReason.RECONNECTED);
|
|
144
147
|
}
|
|
145
148
|
_this.participantsService.startInactiveRemover(_this.sessionId);
|
|
146
149
|
_this.disconnectedAt = undefined;
|
|
@@ -166,8 +169,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
166
169
|
});
|
|
167
170
|
(0, _defineProperty2.default)(_this, "getPresenceData", function () {
|
|
168
171
|
return {
|
|
172
|
+
// Ignored via go/ees005
|
|
173
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
169
174
|
sessionId: _this.sessionId,
|
|
175
|
+
// Ignored via go/ees005
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
170
177
|
userId: _this.userId,
|
|
178
|
+
// Ignored via go/ees005
|
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
171
180
|
clientId: _this.clientId,
|
|
172
181
|
permit: _this.permit,
|
|
173
182
|
presenceId: _this.presenceId,
|
|
@@ -185,13 +194,13 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
185
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) {
|
|
186
195
|
_this.documentService.onStepRejectedError();
|
|
187
196
|
} else {
|
|
188
|
-
var _this$
|
|
189
|
-
(_this$
|
|
197
|
+
var _this$analyticsHelper2;
|
|
198
|
+
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 || _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
|
|
190
199
|
var mappedError = (0, _errorCodeMapper.errorCodeMapper)(error);
|
|
191
200
|
// Only emit errors to Confluence very intentionally because they will disconnect the collab provider
|
|
192
201
|
if (mappedError) {
|
|
193
|
-
var _this$
|
|
194
|
-
(_this$
|
|
202
|
+
var _this$analyticsHelper3;
|
|
203
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 || _this$analyticsHelper3.sendProviderErrorEvent(mappedError);
|
|
195
204
|
_this.emit('error', mappedError);
|
|
196
205
|
}
|
|
197
206
|
}
|
|
@@ -217,7 +226,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
217
226
|
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
218
227
|
*/
|
|
219
228
|
(0, _defineProperty2.default)(_this, "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
220
|
-
var _this$
|
|
229
|
+
var _this$analyticsHelper4;
|
|
221
230
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
222
231
|
while (1) switch (_context.prev = _context.next) {
|
|
223
232
|
case 0:
|
|
@@ -229,7 +238,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
229
238
|
case 6:
|
|
230
239
|
_context.prev = 6;
|
|
231
240
|
_context.t0 = _context["catch"](0);
|
|
232
|
-
(_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');
|
|
233
242
|
throw new _customErrors.GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
|
|
234
243
|
case 10:
|
|
235
244
|
case "end":
|
|
@@ -243,7 +252,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
243
252
|
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
244
253
|
*/
|
|
245
254
|
(0, _defineProperty2.default)(_this, "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
246
|
-
var _this$
|
|
255
|
+
var _this$analyticsHelper5;
|
|
247
256
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
248
257
|
while (1) switch (_context2.prev = _context2.next) {
|
|
249
258
|
case 0:
|
|
@@ -255,7 +264,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
255
264
|
case 6:
|
|
256
265
|
_context2.prev = 6;
|
|
257
266
|
_context2.t0 = _context2["catch"](0);
|
|
258
|
-
(_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');
|
|
259
268
|
throw new _customErrors.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
260
269
|
case 10:
|
|
261
270
|
case "end":
|
|
@@ -314,7 +323,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
314
323
|
return _this.userId;
|
|
315
324
|
}, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
|
|
316
325
|
__livePage: _this.config.__livePage || false
|
|
317
|
-
});
|
|
326
|
+
}, _this.channel.getConnected);
|
|
318
327
|
_this.api = new _api.Api(config, _this.documentService, _this.channel);
|
|
319
328
|
}
|
|
320
329
|
_this.sendStepsTimer = setInterval(function () {
|
|
@@ -356,12 +365,16 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
356
365
|
onSyncUpError = _ref7.onSyncUpError;
|
|
357
366
|
this.checkForCookies();
|
|
358
367
|
try {
|
|
368
|
+
// Ignored via go/ees005
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
359
370
|
var collabPlugin = getState().plugins.find(function (p) {
|
|
360
371
|
return p.key === 'collab$';
|
|
361
372
|
});
|
|
362
373
|
if (collabPlugin === undefined) {
|
|
363
374
|
throw new _customErrors.ProviderInitialisationError('Collab provider attempted to initialise, but Editor state is missing collab plugin');
|
|
364
375
|
}
|
|
376
|
+
// Ignored via go/ees005
|
|
377
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
365
378
|
this.clientId = collabPlugin.spec.config.clientID;
|
|
366
379
|
|
|
367
380
|
// generate a temporary id as clientId when it is undefined
|
|
@@ -375,7 +388,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
375
388
|
clientId: this.clientId
|
|
376
389
|
});
|
|
377
390
|
if (this.isBufferingEnabled && this.initialDraft && !this.isProviderInitialized) {
|
|
378
|
-
var _this$
|
|
391
|
+
var _this$analyticsHelper6;
|
|
379
392
|
var _this$initialDraft2 = this.initialDraft,
|
|
380
393
|
document = _this$initialDraft2.document,
|
|
381
394
|
version = _this$initialDraft2.version,
|
|
@@ -385,7 +398,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
385
398
|
version: version,
|
|
386
399
|
metadata: metadata
|
|
387
400
|
});
|
|
388
|
-
(_this$
|
|
401
|
+
(_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 || _this$analyticsHelper6.sendActionEvent(_const.EVENT_ACTION.PROVIDER_INITIALIZED, _const.EVENT_STATUS.INFO, {
|
|
389
402
|
isBuffered: true
|
|
390
403
|
});
|
|
391
404
|
}
|
|
@@ -394,8 +407,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
394
407
|
this.isChannelInitialized = true;
|
|
395
408
|
}
|
|
396
409
|
} catch (initError) {
|
|
397
|
-
var _this$
|
|
398
|
-
(_this$
|
|
410
|
+
var _this$analyticsHelper7;
|
|
411
|
+
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
399
412
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
400
413
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error', initError);
|
|
401
414
|
}
|
|
@@ -415,8 +428,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
415
428
|
this.isChannelInitialized = true;
|
|
416
429
|
}
|
|
417
430
|
} catch (initError) {
|
|
418
|
-
var _this$
|
|
419
|
-
(_this$
|
|
431
|
+
var _this$analyticsHelper8;
|
|
432
|
+
(_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
420
433
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
421
434
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error', initError);
|
|
422
435
|
}
|
|
@@ -426,9 +439,9 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
426
439
|
key: "checkForCookies",
|
|
427
440
|
value: function checkForCookies() {
|
|
428
441
|
if (!global.navigator.cookieEnabled) {
|
|
429
|
-
var _this$
|
|
442
|
+
var _this$analyticsHelper9;
|
|
430
443
|
var initError = new _customErrors.ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
|
|
431
|
-
(_this$
|
|
444
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
|
|
432
445
|
throw new _customErrors.ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
|
|
433
446
|
}
|
|
434
447
|
}
|
|
@@ -445,14 +458,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
445
458
|
value: function send(_tr, _oldState, newState) {
|
|
446
459
|
try {
|
|
447
460
|
if (this.isViewOnly()) {
|
|
448
|
-
var _this$
|
|
461
|
+
var _this$analyticsHelper10;
|
|
449
462
|
var error = {
|
|
450
463
|
message: 'Attempted to send steps in view only mode',
|
|
451
464
|
data: {
|
|
452
465
|
code: _internalErrors.INTERNAL_ERROR_CODE.VIEW_ONLY_STEPS_ERROR
|
|
453
466
|
}
|
|
454
467
|
};
|
|
455
|
-
(_this$
|
|
468
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, error.message);
|
|
456
469
|
return;
|
|
457
470
|
}
|
|
458
471
|
// Don't send steps while the document is locked (eg. when restoring the document)
|
|
@@ -462,8 +475,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
462
475
|
}
|
|
463
476
|
this.documentService.send(_tr, _oldState, newState);
|
|
464
477
|
} catch (error) {
|
|
465
|
-
var _this$
|
|
466
|
-
(_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');
|
|
467
480
|
throw new _customErrors.SendTransactionError('Error while sending steps for a transaction', error);
|
|
468
481
|
}
|
|
469
482
|
}
|
|
@@ -490,8 +503,14 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
490
503
|
key: "sendMessage",
|
|
491
504
|
value: function sendMessage(data) {
|
|
492
505
|
var basePayload = {
|
|
506
|
+
// Ignored via go/ees005
|
|
507
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
493
508
|
userId: this.userId,
|
|
509
|
+
// Ignored via go/ees005
|
|
510
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
494
511
|
sessionId: this.sessionId,
|
|
512
|
+
// Ignored via go/ees005
|
|
513
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
495
514
|
clientId: this.clientId,
|
|
496
515
|
permit: this.permit
|
|
497
516
|
};
|
|
@@ -508,9 +527,9 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
508
527
|
this.participantsService.sendAIProviderChanged(_objectSpread(_objectSpread({}, basePayload), data));
|
|
509
528
|
}
|
|
510
529
|
} catch (error) {
|
|
511
|
-
var _this$
|
|
530
|
+
var _this$analyticsHelper12;
|
|
512
531
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
513
|
-
(_this$
|
|
532
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 || _this$analyticsHelper12.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
514
533
|
}
|
|
515
534
|
}
|
|
516
535
|
}, {
|
|
@@ -561,8 +580,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
561
580
|
this.sendStepsTimer = undefined;
|
|
562
581
|
}
|
|
563
582
|
} catch (error) {
|
|
564
|
-
var _this$
|
|
565
|
-
(_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');
|
|
566
585
|
throw new _customErrors.DestroyError('Error while shutting down the collab provider', error);
|
|
567
586
|
}
|
|
568
587
|
this.clearTimers();
|
|
@@ -586,8 +605,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
586
605
|
}
|
|
587
606
|
this.metadataService.setTitle(title, broadcast);
|
|
588
607
|
} catch (error) {
|
|
589
|
-
var _this$
|
|
590
|
-
(_this$
|
|
608
|
+
var _this$analyticsHelper14;
|
|
609
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 || _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting title');
|
|
591
610
|
throw new _customErrors.SetTitleError('Error while setting title', error);
|
|
592
611
|
}
|
|
593
612
|
}
|
|
@@ -606,8 +625,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
606
625
|
try {
|
|
607
626
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
608
627
|
} catch (error) {
|
|
609
|
-
var _this$
|
|
610
|
-
(_this$
|
|
628
|
+
var _this$analyticsHelper15;
|
|
629
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 || _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting editor width');
|
|
611
630
|
throw new _customErrors.SetEditorWidthError('Error while setting editor width', error);
|
|
612
631
|
}
|
|
613
632
|
}
|
|
@@ -626,8 +645,8 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
626
645
|
}
|
|
627
646
|
this.metadataService.setMetadata(metadata);
|
|
628
647
|
} catch (error) {
|
|
629
|
-
var _this$
|
|
630
|
-
(_this$
|
|
648
|
+
var _this$analyticsHelper16;
|
|
649
|
+
(_this$analyticsHelper16 = this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 || _this$analyticsHelper16.sendErrorEvent(error, 'Error while setting metadata');
|
|
631
650
|
throw new _customErrors.SetMetadataError('Error while setting metadata', error);
|
|
632
651
|
}
|
|
633
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.3";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
|
@@ -31,6 +31,8 @@ const triggerAnalyticsEvent = (analyticsEvent, analyticsClient) => {
|
|
|
31
31
|
if (analyticsEvent.eventAction === EVENT_ACTION.ERROR) {
|
|
32
32
|
payload.nonPrivacySafeAttributes = analyticsEvent.nonPrivacySafeAttributes;
|
|
33
33
|
try {
|
|
34
|
+
// Ignored via go/ees005
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
36
|
const requestIdleCallbackFunction = window.requestIdleCallback;
|
|
35
37
|
const runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
|
|
36
38
|
runItLater(() => {
|
|
@@ -43,6 +45,8 @@ const triggerAnalyticsEvent = (analyticsEvent, analyticsClient) => {
|
|
|
43
45
|
// Let the browser figure out
|
|
44
46
|
// when it should send those events
|
|
45
47
|
try {
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
50
|
const requestIdleCallbackFunction = window.requestIdleCallback;
|
|
47
51
|
const runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
|
|
48
52
|
runItLater(() => {
|
|
@@ -54,6 +58,8 @@ const triggerAnalyticsEvent = (analyticsEvent, analyticsClient) => {
|
|
|
54
58
|
}
|
|
55
59
|
};
|
|
56
60
|
export default class AnalyticsHelper {
|
|
61
|
+
// Ignored via go/ees005
|
|
62
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
57
63
|
constructor(documentAri, subProduct, analyticsClient, getAnalyticsClient) {
|
|
58
64
|
this.documentAri = documentAri;
|
|
59
65
|
this.subProduct = subProduct;
|
|
@@ -73,7 +79,11 @@ export default class AnalyticsHelper {
|
|
|
73
79
|
subProduct: this.subProduct,
|
|
74
80
|
errorMessage,
|
|
75
81
|
errorName: error instanceof Error ? error.name : undefined,
|
|
82
|
+
// Ignored via go/ees005
|
|
83
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
76
84
|
errorCode: (_data$code = (_data = error.data) === null || _data === void 0 ? void 0 : _data.code) !== null && _data$code !== void 0 ? _data$code : undefined,
|
|
85
|
+
// Ignored via go/ees005
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
87
|
errorStatus: (_data$status = (_data2 = error.data) === null || _data2 === void 0 ? void 0 : _data2.status) !== null && _data$status !== void 0 ? _data$status : undefined,
|
|
78
88
|
errorStack: error instanceof Error && loggableErrorName.includes(error.name) ? error.stack : undefined,
|
|
79
89
|
originalErrorMessage: this.getUGCFreeErrorMessage(error),
|
|
@@ -9,7 +9,10 @@ export let MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
|
|
|
9
9
|
return MEASURE_NAME;
|
|
10
10
|
}({});
|
|
11
11
|
export const isPerformanceAPIAvailable = () => {
|
|
12
|
-
return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(
|
|
12
|
+
return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
api => !!performance[api]);
|
|
13
16
|
};
|
|
14
17
|
export const measureMap = new Map();
|
|
15
18
|
export function startMeasure(measureName, analyticsHelper) {
|
package/dist/es2019/channel.js
CHANGED
|
@@ -102,6 +102,8 @@ export class Channel extends Emitter {
|
|
|
102
102
|
_defineProperty(this, "onConnect", () => {
|
|
103
103
|
var _this$analyticsHelper5;
|
|
104
104
|
this.connected = true;
|
|
105
|
+
// Ignored via go/ees005
|
|
106
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
105
107
|
logger('Connected.', this.socket.id);
|
|
106
108
|
const measure = stopMeasure(MEASURE_NAME.SOCKET_CONNECT, this.analyticsHelper);
|
|
107
109
|
(_this$analyticsHelper5 = this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendActionEvent(EVENT_ACTION.CONNECTION, EVENT_STATUS.SUCCESS, {
|
|
@@ -111,12 +113,19 @@ export class Channel extends Emitter {
|
|
|
111
113
|
usedCachedToken: !!this.token
|
|
112
114
|
});
|
|
113
115
|
this.emit('connected', {
|
|
116
|
+
// Ignored via go/ees005
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
114
118
|
sid: this.socket.id,
|
|
115
119
|
initialized: this.initialized
|
|
116
120
|
});
|
|
117
121
|
});
|
|
122
|
+
// Ignored via go/ees005
|
|
123
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
118
124
|
_defineProperty(this, "onReceiveData", data => {
|
|
119
125
|
logger('Received data', data);
|
|
126
|
+
|
|
127
|
+
// Ignored via go/ees005
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
120
129
|
logger('Session ID is', this.socket.id);
|
|
121
130
|
if (data.type === 'initial') {
|
|
122
131
|
if (!this.initialized) {
|
|
@@ -164,6 +173,8 @@ export class Channel extends Emitter {
|
|
|
164
173
|
this.emit('steps:added', data);
|
|
165
174
|
}
|
|
166
175
|
});
|
|
176
|
+
// Ignored via go/ees005
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
167
178
|
_defineProperty(this, "fetchCatchupv2", async (fromVersion, clientId, catchUpOutofSync, reason) => {
|
|
168
179
|
try {
|
|
169
180
|
const {
|
|
@@ -185,6 +196,8 @@ export class Channel extends Emitter {
|
|
|
185
196
|
steps,
|
|
186
197
|
metadata
|
|
187
198
|
};
|
|
199
|
+
// Ignored via go/ees005
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
188
201
|
} catch (error) {
|
|
189
202
|
if (error.code === 404) {
|
|
190
203
|
const errorNotFound = {
|
|
@@ -216,6 +229,8 @@ export class Channel extends Emitter {
|
|
|
216
229
|
productId: 'ccollab',
|
|
217
230
|
reason
|
|
218
231
|
});
|
|
232
|
+
// Ignored via go/ees005
|
|
233
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
219
234
|
const reconcileResponse = await utils.requestService(this.config, {
|
|
220
235
|
path: `document/${encodeURIComponent(this.config.documentAri)}/reconcile`,
|
|
221
236
|
requestInit: {
|
|
@@ -228,6 +243,8 @@ export class Channel extends Emitter {
|
|
|
228
243
|
}
|
|
229
244
|
});
|
|
230
245
|
return reconcileResponse;
|
|
246
|
+
// Ignored via go/ees005
|
|
247
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
248
|
} catch (error) {
|
|
232
249
|
var _this$analyticsHelper7;
|
|
233
250
|
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(error, 'Error while fetching reconciled document');
|
|
@@ -339,6 +356,8 @@ export class Channel extends Emitter {
|
|
|
339
356
|
code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
|
|
340
357
|
meta: {
|
|
341
358
|
originalError: error,
|
|
359
|
+
// Ignored via go/ees005
|
|
360
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
342
361
|
reason: error === null || error === void 0 ? void 0 : (_data = error.data) === null || _data === void 0 ? void 0 : (_data$meta = _data.meta) === null || _data$meta === void 0 ? void 0 : _data$meta.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
|
|
343
362
|
// https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
|
|
344
363
|
}
|
|
@@ -348,6 +367,8 @@ export class Channel extends Emitter {
|
|
|
348
367
|
}
|
|
349
368
|
};
|
|
350
369
|
} else {
|
|
370
|
+
// Ignored via go/ees005
|
|
371
|
+
// eslint-disable-next-line require-await
|
|
351
372
|
auth = async cb => {
|
|
352
373
|
// Rebuild authData to ensure values are current
|
|
353
374
|
const authData = {
|
|
@@ -422,6 +443,8 @@ export class Channel extends Emitter {
|
|
|
422
443
|
this.socket.on('status', data => {
|
|
423
444
|
this.emit('status', data);
|
|
424
445
|
});
|
|
446
|
+
// Ignored via go/ees005
|
|
447
|
+
// eslint-disable-next-line require-await
|
|
425
448
|
this.socket.on('disconnect', async reason => {
|
|
426
449
|
this.connected = false;
|
|
427
450
|
logger(`disconnect reason: ${reason}`);
|
|
@@ -470,6 +493,9 @@ export class Channel extends Emitter {
|
|
|
470
493
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
471
494
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
472
495
|
}
|
|
496
|
+
|
|
497
|
+
// Ignored via go/ees005
|
|
498
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
473
499
|
onAnyOutgoingHandler(currentTimeMs, args) {
|
|
474
500
|
const rateLimitType = this.config.rateLimitType || this.RATE_LIMIT_TYPE_NONE;
|
|
475
501
|
if (rateLimitType === this.RATE_LIMIT_TYPE_NONE) {
|
|
@@ -22,7 +22,11 @@ export default class Network {
|
|
|
22
22
|
this.onlineCallback = props.onlineCallback;
|
|
23
23
|
}
|
|
24
24
|
if (typeof window !== 'undefined') {
|
|
25
|
+
// Ignored via go/ees005
|
|
26
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
25
27
|
window.addEventListener('offline', this.offlineHandler);
|
|
28
|
+
// Ignored via go/ees005
|
|
29
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
26
30
|
window.addEventListener('online', this.onlineHandler);
|
|
27
31
|
}
|
|
28
32
|
}
|
|
@@ -30,7 +34,11 @@ export default class Network {
|
|
|
30
34
|
return this.status || null;
|
|
31
35
|
}
|
|
32
36
|
destroy() {
|
|
37
|
+
// Ignored via go/ees005
|
|
38
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
33
39
|
window.removeEventListener('offline', this.offlineHandler);
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
34
42
|
window.removeEventListener('online', this.onlineHandler);
|
|
35
43
|
}
|
|
36
44
|
}
|
|
@@ -11,6 +11,8 @@ export default class ReconnectHelper {
|
|
|
11
11
|
_defineProperty(this, "onlineHandler", () => {
|
|
12
12
|
this.failedReconnectCount = 0;
|
|
13
13
|
});
|
|
14
|
+
// Ignored via go/ees005
|
|
15
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
14
16
|
window.addEventListener('online', this.onlineHandler);
|
|
15
17
|
}
|
|
16
18
|
countReconnectError() {
|
|
@@ -24,6 +26,8 @@ export default class ReconnectHelper {
|
|
|
24
26
|
return isLikelyNetworkIssue;
|
|
25
27
|
}
|
|
26
28
|
destroy() {
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
27
31
|
window.removeEventListener('online', this.onlineHandler);
|
|
28
32
|
}
|
|
29
33
|
}
|