@atlaskit/collab-provider 9.6.4 → 9.7.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.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/disconnected-reason-mapper.js +8 -17
- package/dist/cjs/errors/error-code-mapper.js +13 -12
- package/dist/cjs/errors/error-types.js +2 -95
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/provider/index.js +88 -69
- package/dist/cjs/types.js +1 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/disconnected-reason-mapper.js +2 -9
- package/dist/es2019/errors/error-code-mapper.js +2 -1
- package/dist/es2019/errors/error-types.js +0 -94
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/provider/index.js +77 -57
- package/dist/es2019/types.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/disconnected-reason-mapper.js +2 -9
- package/dist/esm/errors/error-code-mapper.js +2 -1
- package/dist/esm/errors/error-types.js +0 -94
- package/dist/esm/index.js +1 -1
- package/dist/esm/provider/index.js +88 -69
- package/dist/esm/types.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/channel.d.ts +2 -1
- package/dist/types/disconnected-reason-mapper.d.ts +1 -8
- package/dist/types/document/document-service.d.ts +3 -2
- package/dist/types/errors/error-code-mapper.d.ts +2 -1
- package/dist/types/errors/error-types.d.ts +0 -190
- package/dist/types/helpers/const.d.ts +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/metadata/metadata-service.d.ts +1 -1
- package/dist/types/participants/participants-helper.d.ts +2 -6
- package/dist/types/participants/participants-service.d.ts +3 -2
- package/dist/types/participants/participants-state.d.ts +2 -1
- package/dist/types/participants/telepointers-helper.d.ts +2 -2
- package/dist/types/provider/commit-step.d.ts +2 -1
- package/dist/types/provider/index.d.ts +11 -5
- package/dist/types/socket-io-provider.d.ts +1 -1
- package/dist/types/types.d.ts +2 -149
- package/dist/types-ts4.5/channel.d.ts +2 -1
- package/dist/types-ts4.5/disconnected-reason-mapper.d.ts +1 -8
- package/dist/types-ts4.5/document/document-service.d.ts +3 -2
- package/dist/types-ts4.5/errors/error-code-mapper.d.ts +2 -1
- package/dist/types-ts4.5/errors/error-types.d.ts +0 -190
- package/dist/types-ts4.5/helpers/const.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +3 -3
- package/dist/types-ts4.5/metadata/metadata-service.d.ts +1 -1
- package/dist/types-ts4.5/participants/participants-helper.d.ts +2 -6
- package/dist/types-ts4.5/participants/participants-service.d.ts +3 -2
- package/dist/types-ts4.5/participants/participants-state.d.ts +2 -1
- package/dist/types-ts4.5/participants/telepointers-helper.d.ts +2 -2
- package/dist/types-ts4.5/provider/commit-step.d.ts +2 -1
- package/dist/types-ts4.5/provider/index.d.ts +11 -5
- package/dist/types-ts4.5/socket-io-provider.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +2 -149
- package/package.json +2 -1
- package/report.api.md +51 -392
- package/tmp/api-report-tmp.d.ts +51 -375
|
@@ -45,24 +45,48 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
45
45
|
* @param data - Event data to emit to subscribers
|
|
46
46
|
*/
|
|
47
47
|
_defineProperty(_assertThisInitialized(_this), "emitCallback", function (evt, data) {
|
|
48
|
-
// When the provider is initialized early, we want the editor state
|
|
48
|
+
// When the provider is initialized early, we want to ensure the editor state exists after setup is called before emitting events
|
|
49
49
|
// to ensure that it is ready to listen to the events fired by NCS
|
|
50
50
|
if (_this.isPreinitializing) {
|
|
51
|
-
_this.
|
|
51
|
+
_this.onSetupPromise.then(function () {
|
|
52
52
|
return _this.emit(evt, data);
|
|
53
53
|
});
|
|
54
54
|
} else {
|
|
55
55
|
_this.emit(evt, data);
|
|
56
56
|
}
|
|
57
57
|
});
|
|
58
|
+
/**
|
|
59
|
+
* Wrapper to update document and metadata.
|
|
60
|
+
* Catches and logs any errors thrown by document service's updateDocument and updateMetadata methods and destroys the provider in case of errors.
|
|
61
|
+
* Passing the document, metadata, version (either from the initial draft or from collab service)
|
|
62
|
+
*/
|
|
63
|
+
_defineProperty(_assertThisInitialized(_this), "updateDocumentAndMetadata", function (_ref) {
|
|
64
|
+
var doc = _ref.doc,
|
|
65
|
+
version = _ref.version,
|
|
66
|
+
metadata = _ref.metadata;
|
|
67
|
+
try {
|
|
68
|
+
_this.documentService.updateDocument({
|
|
69
|
+
doc: doc,
|
|
70
|
+
version: version,
|
|
71
|
+
metadata: metadata
|
|
72
|
+
});
|
|
73
|
+
_this.metadataService.updateMetadata(metadata);
|
|
74
|
+
_this.isProviderInitialized = true;
|
|
75
|
+
} catch (e) {
|
|
76
|
+
var _this$analyticsHelper;
|
|
77
|
+
(_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendErrorEvent(e, 'Failed to update with the init document, destroying provider');
|
|
78
|
+
// Stop events and connections to step us trying to talk to the backend with an invalid state.
|
|
79
|
+
_this.destroy();
|
|
80
|
+
}
|
|
81
|
+
});
|
|
58
82
|
_defineProperty(_assertThisInitialized(_this), "initializeChannel", function () {
|
|
59
83
|
_this.emit('connecting', {
|
|
60
84
|
initial: true
|
|
61
85
|
});
|
|
62
86
|
var shouldInitialize = Boolean(_this.initialDraft) && !_this.isProviderInitialized;
|
|
63
|
-
_this.channel.on('connected', function (
|
|
64
|
-
var sid =
|
|
65
|
-
initialized =
|
|
87
|
+
_this.channel.on('connected', function (_ref2) {
|
|
88
|
+
var sid = _ref2.sid,
|
|
89
|
+
initialized = _ref2.initialized;
|
|
66
90
|
_this.sessionId = sid;
|
|
67
91
|
_this.emitCallback('connected', {
|
|
68
92
|
sid: sid,
|
|
@@ -81,22 +105,24 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
81
105
|
document = _this$initialDraft.document,
|
|
82
106
|
version = _this$initialDraft.version,
|
|
83
107
|
metadata = _this$initialDraft.metadata;
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
108
|
+
if (_this.isPreinitializing) {
|
|
109
|
+
// When the provider is initialized early, we wait until setup is called with a defined getState before the document is updated to ensure that the editor state exists
|
|
110
|
+
// The `isPreinitializing` check is an extra precaution behind a FF - if the state is already resolved, onSetupPromise will resolve immediately
|
|
111
|
+
_this.onSetupPromise.then(function () {
|
|
112
|
+
_this.updateDocumentAndMetadata({
|
|
113
|
+
doc: document,
|
|
114
|
+
version: version,
|
|
115
|
+
metadata: metadata
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
_this.updateDocumentAndMetadata({
|
|
87
120
|
doc: document,
|
|
88
121
|
version: version,
|
|
89
122
|
metadata: metadata
|
|
90
123
|
});
|
|
91
|
-
} catch (e) {
|
|
92
|
-
var _this$analyticsHelper;
|
|
93
|
-
(_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendErrorEvent(e, 'Failed to update the document on reconnect, destroying provider');
|
|
94
|
-
// Stop events and connections to step us trying to talk to the backend with an invalid state.
|
|
95
|
-
_this.destroy();
|
|
96
124
|
}
|
|
97
|
-
_this.metadataService.updateMetadata(metadata);
|
|
98
125
|
}
|
|
99
|
-
_this.isProviderInitialized = true;
|
|
100
126
|
}
|
|
101
127
|
// If already initialized, `connected` means reconnected
|
|
102
128
|
if (initialized && _this.disconnectedAt &&
|
|
@@ -106,25 +132,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
106
132
|
}
|
|
107
133
|
_this.participantsService.startInactiveRemover(_this.sessionId);
|
|
108
134
|
_this.disconnectedAt = undefined;
|
|
109
|
-
}).on('init', function (
|
|
110
|
-
var doc =
|
|
111
|
-
version =
|
|
112
|
-
metadata =
|
|
135
|
+
}).on('init', function (_ref3) {
|
|
136
|
+
var doc = _ref3.doc,
|
|
137
|
+
version = _ref3.version,
|
|
138
|
+
metadata = _ref3.metadata;
|
|
113
139
|
// Initial document and version
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
});
|
|
120
|
-
_this.metadataService.updateMetadata(metadata);
|
|
121
|
-
_this.isProviderInitialized = true;
|
|
122
|
-
} catch (e) {
|
|
123
|
-
var _this$analyticsHelper2;
|
|
124
|
-
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(e, 'Failed to update with the init document, destroying provider');
|
|
125
|
-
// Stop events and connections to step us trying to talk to the backend with an invalid state.
|
|
126
|
-
_this.destroy();
|
|
127
|
-
}
|
|
140
|
+
_this.updateDocumentAndMetadata({
|
|
141
|
+
doc: doc,
|
|
142
|
+
version: version,
|
|
143
|
+
metadata: metadata
|
|
144
|
+
});
|
|
128
145
|
}).on('restore', _this.documentService.onRestore).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', function (payload) {
|
|
129
146
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
130
147
|
}).on('presence:joined', _this.participantsService.onPresenceJoined).on('presence', _this.participantsService.onPresence).on('participant:left', _this.participantsService.onParticipantLeft).on('participant:updated', _this.participantsService.onParticipantUpdated).on('disconnect', _this.onDisconnected.bind(_assertThisInitialized(_this))).on('error', _this.onErrorHandled).on('status', _this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
|
|
@@ -150,20 +167,20 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
150
167
|
if (((_error$data = error.data) === null || _error$data === void 0 ? void 0 : _error$data.code) === NCS_ERROR_CODE.HEAD_VERSION_UPDATE_FAILED || ((_error$data2 = error.data) === null || _error$data2 === void 0 ? void 0 : _error$data2.code) === NCS_ERROR_CODE.VERSION_NUMBER_ALREADY_EXISTS) {
|
|
151
168
|
_this.documentService.onStepRejectedError();
|
|
152
169
|
} else {
|
|
153
|
-
var _this$
|
|
154
|
-
(_this$
|
|
170
|
+
var _this$analyticsHelper2;
|
|
171
|
+
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendErrorEvent(error, 'Error handled');
|
|
155
172
|
var mappedError = errorCodeMapper(error);
|
|
156
173
|
// Temporarily only emit errors to Confluence very intentionally because they will disconnect the collab provider
|
|
157
174
|
if (mappedError) {
|
|
158
|
-
var _this$
|
|
159
|
-
(_this$
|
|
175
|
+
var _this$analyticsHelper3;
|
|
176
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(mappedError, 'Error emitted');
|
|
160
177
|
_this.emitCallback('error', mappedError);
|
|
161
178
|
}
|
|
162
179
|
}
|
|
163
180
|
});
|
|
164
181
|
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
165
|
-
_defineProperty(_assertThisInitialized(_this), "onDisconnected", function (
|
|
166
|
-
var reason =
|
|
182
|
+
_defineProperty(_assertThisInitialized(_this), "onDisconnected", function (_ref4) {
|
|
183
|
+
var reason = _ref4.reason;
|
|
167
184
|
_this.disconnectedAt = Date.now();
|
|
168
185
|
_this.participantsService.disconnect(reason, _this.sessionId);
|
|
169
186
|
});
|
|
@@ -179,7 +196,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
179
196
|
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
180
197
|
*/
|
|
181
198
|
_defineProperty(_assertThisInitialized(_this), "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
182
|
-
var _this$
|
|
199
|
+
var _this$analyticsHelper4;
|
|
183
200
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
184
201
|
while (1) switch (_context.prev = _context.next) {
|
|
185
202
|
case 0:
|
|
@@ -191,7 +208,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
191
208
|
case 6:
|
|
192
209
|
_context.prev = 6;
|
|
193
210
|
_context.t0 = _context["catch"](0);
|
|
194
|
-
(_this$
|
|
211
|
+
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context.t0, 'Error while returning ADF version of current draft document');
|
|
195
212
|
throw new GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
|
|
196
213
|
case 10:
|
|
197
214
|
case "end":
|
|
@@ -205,7 +222,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
205
222
|
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
206
223
|
*/
|
|
207
224
|
_defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
208
|
-
var _this$
|
|
225
|
+
var _this$analyticsHelper5;
|
|
209
226
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
210
227
|
while (1) switch (_context2.prev = _context2.next) {
|
|
211
228
|
case 0:
|
|
@@ -217,7 +234,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
217
234
|
case 6:
|
|
218
235
|
_context2.prev = 6;
|
|
219
236
|
_context2.t0 = _context2["catch"](0);
|
|
220
|
-
(_this$
|
|
237
|
+
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
221
238
|
throw new GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
222
239
|
case 10:
|
|
223
240
|
case "end":
|
|
@@ -253,8 +270,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
253
270
|
_this.documentService = new DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
|
|
254
271
|
return _this.userId;
|
|
255
272
|
}, _this.onErrorHandled, _this.metadataService, _this.config.failedStepLimitBeforeCatchupOnPublish, _this.config.enableErrorOnFailedDocumentApply);
|
|
256
|
-
_this.
|
|
257
|
-
_this.
|
|
273
|
+
_this.onSetupPromise = new Promise(function (resolve) {
|
|
274
|
+
_this.resolveOnSetupPromise = resolve;
|
|
258
275
|
});
|
|
259
276
|
_this.namespaceService = new NamespaceService();
|
|
260
277
|
return _this;
|
|
@@ -288,21 +305,17 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
288
305
|
*/
|
|
289
306
|
}, {
|
|
290
307
|
key: "setup",
|
|
291
|
-
value: function setup(
|
|
292
|
-
var getState =
|
|
293
|
-
onSyncUpError =
|
|
308
|
+
value: function setup(_ref7) {
|
|
309
|
+
var getState = _ref7.getState,
|
|
310
|
+
onSyncUpError = _ref7.onSyncUpError;
|
|
294
311
|
this.checkForCookies();
|
|
295
312
|
try {
|
|
296
|
-
// if setup is called with no
|
|
313
|
+
// if setup is called with no getState and the initial draft is already provided
|
|
297
314
|
// set a flag to mark early provider setup
|
|
298
315
|
if (!getState && this.initialDraft) {
|
|
299
316
|
this.isPreinitializing = true;
|
|
300
317
|
}
|
|
301
318
|
if (getState) {
|
|
302
|
-
// if provider has already been initialized earlier, resolve the state once it is available
|
|
303
|
-
if (this.isPreinitializing) {
|
|
304
|
-
this.getStatePromiseResolve();
|
|
305
|
-
}
|
|
306
319
|
var collabPlugin = getState().plugins.find(function (p) {
|
|
307
320
|
return p.key === 'collab$';
|
|
308
321
|
});
|
|
@@ -315,14 +328,20 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
315
328
|
onSyncUpError: onSyncUpError,
|
|
316
329
|
clientId: this.clientId
|
|
317
330
|
});
|
|
331
|
+
|
|
332
|
+
// if provider has already been initialized earlier, resolve the setup promise once setup has been called with
|
|
333
|
+
// a defined getState (ie editor state is ready) AND after documentService sets the editor state
|
|
334
|
+
if (this.isPreinitializing) {
|
|
335
|
+
this.resolveOnSetupPromise();
|
|
336
|
+
}
|
|
318
337
|
}
|
|
319
338
|
if (!this.isChannelInitialized) {
|
|
320
339
|
this.initializeChannel();
|
|
321
340
|
this.isChannelInitialized = true;
|
|
322
341
|
}
|
|
323
342
|
} catch (initError) {
|
|
324
|
-
var _this$
|
|
325
|
-
(_this$
|
|
343
|
+
var _this$analyticsHelper6;
|
|
344
|
+
(_this$analyticsHelper6 = this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(initError, 'Error while initialising the provider');
|
|
326
345
|
// Throw error so consumers are aware the initialisation failed when initialising themselves
|
|
327
346
|
throw new ProviderInitialisationError('Provider initialisation error', initError);
|
|
328
347
|
}
|
|
@@ -332,9 +351,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
332
351
|
key: "checkForCookies",
|
|
333
352
|
value: function checkForCookies() {
|
|
334
353
|
if (!global.navigator.cookieEnabled) {
|
|
335
|
-
var _this$
|
|
354
|
+
var _this$analyticsHelper7;
|
|
336
355
|
var initError = new ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
|
|
337
|
-
(_this$
|
|
356
|
+
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
|
|
338
357
|
throw new ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
|
|
339
358
|
}
|
|
340
359
|
}
|
|
@@ -372,8 +391,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
372
391
|
}
|
|
373
392
|
this.documentService.send(_tr, _oldState, newState);
|
|
374
393
|
} catch (error) {
|
|
375
|
-
var _this$
|
|
376
|
-
(_this$
|
|
394
|
+
var _this$analyticsHelper8;
|
|
395
|
+
(_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(error, 'Error while sending steps for a transaction');
|
|
377
396
|
throw new SendTransactionError('Error while sending steps for a transaction', error);
|
|
378
397
|
}
|
|
379
398
|
}
|
|
@@ -401,9 +420,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
401
420
|
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
402
421
|
}
|
|
403
422
|
} catch (error) {
|
|
404
|
-
var _this$
|
|
423
|
+
var _this$analyticsHelper9;
|
|
405
424
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
406
|
-
(_this$
|
|
425
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
407
426
|
}
|
|
408
427
|
}
|
|
409
428
|
}, {
|
|
@@ -442,8 +461,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
442
461
|
_get(_getPrototypeOf(Provider.prototype), "unsubscribeAll", this).call(this);
|
|
443
462
|
this.channel.disconnect();
|
|
444
463
|
} catch (error) {
|
|
445
|
-
var _this$
|
|
446
|
-
(_this$
|
|
464
|
+
var _this$analyticsHelper10;
|
|
465
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while shutting down the collab provider');
|
|
447
466
|
throw new DestroyError('Error while shutting down the collab provider', error);
|
|
448
467
|
}
|
|
449
468
|
this.clearTimers();
|
|
@@ -463,8 +482,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
463
482
|
try {
|
|
464
483
|
this.metadataService.setTitle(title, broadcast);
|
|
465
484
|
} catch (error) {
|
|
466
|
-
var _this$
|
|
467
|
-
(_this$
|
|
485
|
+
var _this$analyticsHelper11;
|
|
486
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while setting title');
|
|
468
487
|
throw new SetTitleError('Error while setting title', error);
|
|
469
488
|
}
|
|
470
489
|
}
|
|
@@ -482,8 +501,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
482
501
|
try {
|
|
483
502
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
484
503
|
} catch (error) {
|
|
485
|
-
var _this$
|
|
486
|
-
(_this$
|
|
504
|
+
var _this$analyticsHelper12;
|
|
505
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, 'Error while setting editor width');
|
|
487
506
|
throw new SetEditorWidthError('Error while setting editor width', error);
|
|
488
507
|
}
|
|
489
508
|
}
|
|
@@ -499,8 +518,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
499
518
|
try {
|
|
500
519
|
this.metadataService.setMetadata(metadata);
|
|
501
520
|
} catch (error) {
|
|
502
|
-
var _this$
|
|
503
|
-
(_this$
|
|
521
|
+
var _this$analyticsHelper13;
|
|
522
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting metadata');
|
|
504
523
|
throw new SetMetadataError('Error while setting metadata', error);
|
|
505
524
|
}
|
|
506
525
|
}
|
package/dist/esm/types.js
CHANGED
package/dist/esm/version.json
CHANGED
package/dist/types/channel.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Emitter } from './emitter';
|
|
2
|
-
import type { Config, ChannelEvent, CatchupResponse
|
|
2
|
+
import type { Config, ChannelEvent, CatchupResponse } from './types';
|
|
3
3
|
import type { Socket } from 'socket.io-client';
|
|
4
4
|
import AnalyticsHelper from './analytics/analytics-helper';
|
|
5
|
+
import type { Metadata } from '@atlaskit/editor-common/collab';
|
|
5
6
|
export declare class Channel extends Emitter<ChannelEvent> {
|
|
6
7
|
private connected;
|
|
7
8
|
private config;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DisconnectReason } from '@atlaskit/editor-common/collab';
|
|
1
2
|
export declare const socketIOReasons: {
|
|
2
3
|
IO_CLIENT_DISCONNECT: string;
|
|
3
4
|
IO_SERVER_DISCONNECT: string;
|
|
@@ -5,12 +6,4 @@ export declare const socketIOReasons: {
|
|
|
5
6
|
TRANSPORT_ERROR: string;
|
|
6
7
|
PING_TIMEOUT: string;
|
|
7
8
|
};
|
|
8
|
-
export declare enum DisconnectReason {
|
|
9
|
-
CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
|
|
10
|
-
SERVER_DISCONNECT = "SERVER_DISCONNECT",
|
|
11
|
-
SOCKET_CLOSED = "SOCKET_CLOSED",
|
|
12
|
-
SOCKET_ERROR = "SOCKET_ERROR",
|
|
13
|
-
SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
|
|
14
|
-
UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
|
|
15
|
-
}
|
|
16
9
|
export declare const disconnectedReasonMapper: (reason: string) => DisconnectReason;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import { CatchupResponse, ChannelEvent,
|
|
3
|
+
import { CatchupResponse, ChannelEvent, StepsPayload } from '../types';
|
|
4
|
+
import type { SyncUpErrorFunction, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
5
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
5
6
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
|
-
import {
|
|
7
|
+
import type { CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
7
8
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
8
9
|
import { ParticipantsService } from '../participants/participants-service';
|
|
9
10
|
import type { InternalError } from '../errors/error-types';
|
|
@@ -240,196 +240,6 @@ export type InternalDocumentUpdateFailure = {
|
|
|
240
240
|
* A union of all possible internal errors, that are mapped to another error if being emitted to the editor.
|
|
241
241
|
*/
|
|
242
242
|
export type InternalError = NCSErrors | DocumentRecoveryError | AddStepsError | CatchUpFailedError | TokenPermissionError | ReconnectionError | ConnectionError | ReconnectionNetworkError | DocumentNotFoundError | InternalDocumentUpdateFailure;
|
|
243
|
-
export declare enum PROVIDER_ERROR_CODE {
|
|
244
|
-
NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR",
|
|
245
|
-
INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
|
|
246
|
-
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
247
|
-
LOCKED = "LOCKED",
|
|
248
|
-
FAIL_TO_SAVE = "FAIL_TO_SAVE",
|
|
249
|
-
DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
|
|
250
|
-
INITIALISATION_ERROR = "INITIALISATION_ERROR",
|
|
251
|
-
NETWORK_ISSUE = "NETWORK_ISSUE",
|
|
252
|
-
INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
|
|
253
|
-
INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR",
|
|
254
|
-
DOCUMENT_UPDATE_ERROR = "DOCUMENT_UPDATE_ERROR"
|
|
255
|
-
}
|
|
256
|
-
/**
|
|
257
|
-
* This occurs when the provided user token is considered invalid for the given document ARI.
|
|
258
|
-
* It happens during initialisation of the provider.
|
|
259
|
-
* It could mean the document has been deleted (hence not found).
|
|
260
|
-
* @message Message returned to editor, i.e User does not have permissions to access this document or document is not found
|
|
261
|
-
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
262
|
-
*/
|
|
263
|
-
type InsufficientEditingPermission = {
|
|
264
|
-
code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
|
|
265
|
-
message: string;
|
|
266
|
-
recoverable: boolean;
|
|
267
|
-
reason?: string;
|
|
268
|
-
/**
|
|
269
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
270
|
-
*/
|
|
271
|
-
status?: number;
|
|
272
|
-
};
|
|
273
|
-
/**
|
|
274
|
-
* Similiar to InsufficientEditingPermission, but the user token is invalid because it has expired or been revoked.
|
|
275
|
-
* It may also be an invalid token format.
|
|
276
|
-
* This error is given to the provider by NCS.
|
|
277
|
-
* @message Message returned to editor, i.e. The user token was invalid
|
|
278
|
-
* @recoverable It is recoverable, as we will try to refresh the token.
|
|
279
|
-
*/
|
|
280
|
-
type InvalidUserToken = {
|
|
281
|
-
code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
|
|
282
|
-
message: string;
|
|
283
|
-
recoverable: boolean;
|
|
284
|
-
/**
|
|
285
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
286
|
-
*/
|
|
287
|
-
status?: number;
|
|
288
|
-
};
|
|
289
|
-
/**
|
|
290
|
-
* Document not found error, thrown when the provider is unable to find a document with the given ARI and user token.
|
|
291
|
-
* It occurs during fetchCatchup, a function that fetches the latest document state during catchup.
|
|
292
|
-
* We need to recieve a 404 from the document service to throw this error.
|
|
293
|
-
* @message Message returned to editor, i.e. The requested document is not found
|
|
294
|
-
* @recoverable It is recoverable, as the provider can try again later.
|
|
295
|
-
*/
|
|
296
|
-
type DocumentNotFound = {
|
|
297
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
298
|
-
message: string;
|
|
299
|
-
recoverable: boolean;
|
|
300
|
-
/**
|
|
301
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
302
|
-
*/
|
|
303
|
-
status?: number;
|
|
304
|
-
};
|
|
305
|
-
/**
|
|
306
|
-
* This error is thrown when the document is locked by another user.
|
|
307
|
-
* The error is passed to us by NCS.
|
|
308
|
-
* @message Message returned to editor, i.e. The document is currently not available, please try again later
|
|
309
|
-
* @recoverable It is recoverable, as the provider can try again later.
|
|
310
|
-
*/
|
|
311
|
-
type Locked = {
|
|
312
|
-
code: PROVIDER_ERROR_CODE.LOCKED;
|
|
313
|
-
message: string;
|
|
314
|
-
recoverable: boolean;
|
|
315
|
-
status?: number;
|
|
316
|
-
};
|
|
317
|
-
/**
|
|
318
|
-
* This error is thrown when the provider is unable to save the document.
|
|
319
|
-
* This can happen when the connection to dynamoDB is lost, or when we do not have sufficient permissions (DYNAMO ERROR).
|
|
320
|
-
* This error is given to us by NCS.
|
|
321
|
-
* @message Message returned to editor, i.e. Collab service is not able to save changes
|
|
322
|
-
* @recoverable It is not recoverable, as we don't want the user to continue editing a document that is not being saved.
|
|
323
|
-
*/
|
|
324
|
-
type FailToSave = {
|
|
325
|
-
code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
|
|
326
|
-
message: string;
|
|
327
|
-
recoverable: boolean;
|
|
328
|
-
/**
|
|
329
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
330
|
-
*/
|
|
331
|
-
status?: number;
|
|
332
|
-
};
|
|
333
|
-
/**
|
|
334
|
-
* This error is thrown when the provider is unable to restore the document.
|
|
335
|
-
* It occurs during onRestore, a function that restores the document to a previous version and reapplies unconfirmed steps.
|
|
336
|
-
* onRestore is called when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
337
|
-
* It could mean we failed to update the page metadata, or we failed to reapply unconfirmed steps.
|
|
338
|
-
* @message Message returned to editor, i.e. Collab service unable to restore document
|
|
339
|
-
* @recoverable It is not recoverable, as the provider has no further options after this.
|
|
340
|
-
* The user will need to refresh the page to try again.
|
|
341
|
-
*/
|
|
342
|
-
type DocumentNotRestore = {
|
|
343
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
|
|
344
|
-
message: string;
|
|
345
|
-
recoverable: boolean;
|
|
346
|
-
/**
|
|
347
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
348
|
-
*/
|
|
349
|
-
status?: number;
|
|
350
|
-
};
|
|
351
|
-
/**
|
|
352
|
-
* The initial document couldn't be loaded from the collab service.
|
|
353
|
-
* This error is given to us by NCS.
|
|
354
|
-
* It could indicate either a network issue, or an internal service error in NCS.
|
|
355
|
-
* @message Message returned to editor, i.e. The initial document couldn't be loaded from the collab service
|
|
356
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
357
|
-
* The user will need to refresh the page to try again.
|
|
358
|
-
*/
|
|
359
|
-
type InitialisationError = {
|
|
360
|
-
code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
|
|
361
|
-
message: string;
|
|
362
|
-
recoverable: boolean;
|
|
363
|
-
/**
|
|
364
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
365
|
-
*/
|
|
366
|
-
status?: number;
|
|
367
|
-
};
|
|
368
|
-
/**
|
|
369
|
-
* Couldn't reconnect to the collab service (NCS) due to network issues.
|
|
370
|
-
* NCS could be down, or the user could be offline. It's also possible the url is incorrect, or the user is behind a proxy blocking the connection.
|
|
371
|
-
* Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
372
|
-
* @message Message returned to editor, i.e. Couldn't reconnect to the collab service due to network issues
|
|
373
|
-
* @recoverable It is recoverable, as the provider will try to reconnect.
|
|
374
|
-
*/
|
|
375
|
-
type NetworkIssue = {
|
|
376
|
-
code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
|
|
377
|
-
message: string;
|
|
378
|
-
recoverable: boolean;
|
|
379
|
-
/**
|
|
380
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
381
|
-
*/
|
|
382
|
-
status?: number;
|
|
383
|
-
};
|
|
384
|
-
/**
|
|
385
|
-
* This error is thrown when the provider has an invalid configuration.
|
|
386
|
-
* It could happen due to these errors from NCS:
|
|
387
|
-
* NAMESPACE_INVALID
|
|
388
|
-
INVALID_ACTIVATION_ID
|
|
389
|
-
INVALID_DOCUMENT_ARI
|
|
390
|
-
INVALID_CLOUD_ID
|
|
391
|
-
* @message Message returned to editor, i.e. Invalid provider configuration
|
|
392
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
393
|
-
* The service using the provider will need to fix the configuration.
|
|
394
|
-
*/
|
|
395
|
-
type InvalidProviderConfiguration = {
|
|
396
|
-
code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
|
|
397
|
-
message: string;
|
|
398
|
-
recoverable: boolean;
|
|
399
|
-
reason: string;
|
|
400
|
-
/**
|
|
401
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
402
|
-
*/
|
|
403
|
-
status?: number;
|
|
404
|
-
};
|
|
405
|
-
/**
|
|
406
|
-
* This error is thrown when the provider encounters an internal service error, not otherwise accounted for.
|
|
407
|
-
* @message Message returned to editor, i.e. Collab Provider experienced an unrecoverable error
|
|
408
|
-
* @recoverable It is not recoverable, as the provider cannot do anything to fix it.
|
|
409
|
-
*/
|
|
410
|
-
type InternalServiceError = {
|
|
411
|
-
code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
|
|
412
|
-
message: string;
|
|
413
|
-
recoverable: boolean;
|
|
414
|
-
reason: string;
|
|
415
|
-
/**
|
|
416
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
417
|
-
*/
|
|
418
|
-
status?: number;
|
|
419
|
-
};
|
|
420
|
-
type ProviderDocumentUpdateError = {
|
|
421
|
-
code: PROVIDER_ERROR_CODE.DOCUMENT_UPDATE_ERROR;
|
|
422
|
-
message: 'The provider failed to apply changes to the editor';
|
|
423
|
-
recoverable: boolean;
|
|
424
|
-
/**
|
|
425
|
-
* @deprecated switch to using either the error code or the recoverable flag
|
|
426
|
-
*/
|
|
427
|
-
status?: number;
|
|
428
|
-
};
|
|
429
|
-
/**
|
|
430
|
-
* A union of all possible provider errors that can be emitted back to the editor.
|
|
431
|
-
*/
|
|
432
|
-
export type ProviderError = InsufficientEditingPermission | InvalidUserToken | DocumentNotFound | Locked | FailToSave | DocumentNotRestore | InitialisationError | NetworkIssue | InvalidProviderConfiguration | InternalServiceError | ProviderDocumentUpdateError;
|
|
433
243
|
type ValidEventAttributeType = boolean | string | number;
|
|
434
244
|
export declare class CustomError extends Error {
|
|
435
245
|
extraEventAttributes?: {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
|
-
export type {
|
|
3
|
-
export type { ProviderError } from '
|
|
4
|
-
export { PROVIDER_ERROR_CODE } from '
|
|
2
|
+
export type { CollabEventDisconnectedData, CollabEventLocalStepData, Socket, } from './types';
|
|
3
|
+
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, } from '@atlaskit/editor-common/collab';
|
|
4
|
+
export { PROVIDER_ERROR_CODE } from '@atlaskit/editor-common/collab';
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { PresencePayload } from '../types';
|
|
2
|
+
import type { ProviderParticipant } from '@atlaskit/editor-common/collab';
|
|
2
3
|
export declare const PARTICIPANT_UPDATE_INTERVAL: number;
|
|
3
|
-
export type ProviderParticipant = CollabParticipant & {
|
|
4
|
-
userId: string;
|
|
5
|
-
clientId: number | string;
|
|
6
|
-
email: string;
|
|
7
|
-
};
|
|
8
4
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
5
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId' | 'email'>>) | undefined;
|
|
10
6
|
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData,
|
|
2
|
+
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload } from '../types';
|
|
3
|
+
import { CollabEventPresenceData, CollabTelepointerPayload, StepJson } from '@atlaskit/editor-common/collab';
|
|
3
4
|
import { GetUserType } from './participants-helper';
|
|
4
5
|
import { ParticipantsState } from './participants-state';
|
|
5
6
|
/**
|
|
@@ -95,5 +96,5 @@ export declare class ParticipantsService {
|
|
|
95
96
|
/**
|
|
96
97
|
*
|
|
97
98
|
*/
|
|
98
|
-
getParticipants: () => import("
|
|
99
|
+
getParticipants: () => import("@atlaskit/editor-common/collab").ProviderParticipant[];
|
|
99
100
|
}
|