@atlaskit/collab-provider 9.0.0 → 9.0.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 +7 -0
- package/dist/cjs/channel.js +6 -8
- package/dist/cjs/document/catchup.js +8 -1
- package/dist/cjs/document/document-service.js +3 -2
- package/dist/cjs/helpers/const.js +2 -1
- package/dist/cjs/participants/participants-service.js +11 -5
- package/dist/cjs/provider/index.js +19 -6
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/channel.js +6 -6
- package/dist/es2019/document/catchup.js +8 -0
- package/dist/es2019/document/document-service.js +3 -2
- package/dist/es2019/helpers/const.js +2 -1
- package/dist/es2019/participants/participants-service.js +10 -6
- package/dist/es2019/provider/index.js +12 -2
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/channel.js +6 -8
- package/dist/esm/document/catchup.js +8 -1
- package/dist/esm/document/document-service.js +3 -2
- package/dist/esm/helpers/const.js +2 -1
- package/dist/esm/participants/participants-service.js +11 -5
- package/dist/esm/provider/index.js +19 -6
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/channel.d.ts +1 -1
- package/dist/types/helpers/const.d.ts +11 -3
- package/dist/types/participants/participants-helper.d.ts +3 -1
- package/dist/types/participants/participants-service.d.ts +4 -2
- package/dist/types/provider/index.d.ts +2 -0
- package/dist/types/types.d.ts +5 -1
- package/dist/types-ts4.5/channel.d.ts +1 -1
- package/dist/types-ts4.5/helpers/const.d.ts +11 -3
- package/dist/types-ts4.5/participants/participants-helper.d.ts +3 -1
- package/dist/types-ts4.5/participants/participants-service.d.ts +4 -2
- package/dist/types-ts4.5/provider/index.d.ts +2 -0
- package/dist/types-ts4.5/types.d.ts +5 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`6fe0ddc993e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6fe0ddc993e) - ESS-3624 bug fix for missing avatar in editing sessions
|
|
8
|
+
- [`579326b4915`](https://bitbucket.org/atlassian/atlassian-frontend/commits/579326b4915) - ESS-2763 update get final editor state
|
|
9
|
+
|
|
3
10
|
## 9.0.0
|
|
4
11
|
|
|
5
12
|
### Major Changes
|
package/dist/cjs/channel.js
CHANGED
|
@@ -350,6 +350,12 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
350
350
|
}
|
|
351
351
|
_this.socket.emit('metadata', metadata);
|
|
352
352
|
});
|
|
353
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sendPresenceJoined", function () {
|
|
354
|
+
if (!_this.connected || !_this.socket) {
|
|
355
|
+
return;
|
|
356
|
+
}
|
|
357
|
+
_this.socket.emit('presence:joined');
|
|
358
|
+
});
|
|
353
359
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onOnlineHandler", function () {
|
|
354
360
|
// Force an immediate reconnect, the socket must first be closed to reset reconnection delay logic
|
|
355
361
|
if (!_this.connected) {
|
|
@@ -566,14 +572,6 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
566
572
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
567
573
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
568
574
|
}
|
|
569
|
-
}, {
|
|
570
|
-
key: "sendPresenceJoined",
|
|
571
|
-
value: function sendPresenceJoined() {
|
|
572
|
-
if (!this.connected || !this.socket) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
this.socket.emit('presence:joined');
|
|
576
|
-
}
|
|
577
575
|
}, {
|
|
578
576
|
key: "disconnect",
|
|
579
577
|
value: function disconnect() {
|
|
@@ -8,6 +8,7 @@ exports.catchup = void 0;
|
|
|
8
8
|
exports.rebaseSteps = rebaseSteps;
|
|
9
9
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
10
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
11
|
+
var _const = require("../helpers/const");
|
|
11
12
|
var _utils = require("../helpers/utils");
|
|
12
13
|
var _prosemirrorTransform = require("prosemirror-transform");
|
|
13
14
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
@@ -42,7 +43,7 @@ function rebaseSteps(steps, mapping) {
|
|
|
42
43
|
}
|
|
43
44
|
var catchup = /*#__PURE__*/function () {
|
|
44
45
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opt) {
|
|
45
|
-
var _yield$opt$fetchCatch, doc, serverStepMaps, serverVersion, metadata, currentPmVersion, unconfirmedSteps, _unconfirmedSteps, stepMaps, mapping, newUnconfirmedSteps;
|
|
46
|
+
var _yield$opt$fetchCatch, doc, serverStepMaps, serverVersion, metadata, currentPmVersion, unconfirmedSteps, _unconfirmedSteps, stepMaps, mapping, newUnconfirmedSteps, _opt$analyticsHelper;
|
|
46
47
|
return _regenerator.default.wrap(function _callee$(_context) {
|
|
47
48
|
while (1) switch (_context.prev = _context.next) {
|
|
48
49
|
case 0:
|
|
@@ -120,6 +121,12 @@ var catchup = /*#__PURE__*/function () {
|
|
|
120
121
|
mapping = new _prosemirrorTransform.Mapping(stepMaps);
|
|
121
122
|
logger("".concat(_unconfirmedSteps.length, " unconfirmed steps before rebased: ").concat(JSON.stringify(_unconfirmedSteps)));
|
|
122
123
|
newUnconfirmedSteps = rebaseSteps(_unconfirmedSteps, mapping);
|
|
124
|
+
if ((newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length) < _unconfirmedSteps.length) {
|
|
125
|
+
// Log the dropped steps after rebase
|
|
126
|
+
(_opt$analyticsHelper = opt.analyticsHelper) === null || _opt$analyticsHelper === void 0 ? void 0 : _opt$analyticsHelper.sendActionEvent(_const.EVENT_ACTION.DROPPED_STEPS, _const.EVENT_STATUS.SUCCESS, {
|
|
127
|
+
numOfDroppedSteps: _unconfirmedSteps.length - (newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length)
|
|
128
|
+
});
|
|
129
|
+
}
|
|
123
130
|
logger("Re-aply ".concat(newUnconfirmedSteps.length, " mapped unconfirmed steps: ").concat(JSON.stringify(newUnconfirmedSteps)));
|
|
124
131
|
// Re-apply local steps
|
|
125
132
|
opt.applyLocalSteps(newUnconfirmedSteps);
|
|
@@ -85,7 +85,8 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
85
85
|
filterQueue: _this.stepQueue.filterQueue,
|
|
86
86
|
applyLocalSteps: _this.applyLocalSteps,
|
|
87
87
|
updateDocument: _this.updateDocument,
|
|
88
|
-
updateMetadata: _this.metadataService.updateMetadata
|
|
88
|
+
updateMetadata: _this.metadataService.updateMetadata,
|
|
89
|
+
analyticsHelper: _this.analyticsHelper
|
|
89
90
|
});
|
|
90
91
|
case 8:
|
|
91
92
|
latency = new Date().getTime() - start;
|
|
@@ -352,7 +353,7 @@ var DocumentService = /*#__PURE__*/function () {
|
|
|
352
353
|
}
|
|
353
354
|
_this.sendStepsFromCurrentState();
|
|
354
355
|
_context4.next = 12;
|
|
355
|
-
return (0, _utils.sleep)(
|
|
356
|
+
return (0, _utils.sleep)(500);
|
|
356
357
|
case 12:
|
|
357
358
|
nextUnconfirmedSteps = _this.getUnconfirmedSteps();
|
|
358
359
|
if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
|
|
@@ -16,6 +16,7 @@ var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
|
|
|
16
16
|
EVENT_ACTION["PUBLISH_PAGE"] = "publishPage";
|
|
17
17
|
EVENT_ACTION["GET_CURRENT_STATE"] = "getCurrentState";
|
|
18
18
|
EVENT_ACTION["INVALIDATE_TOKEN"] = "invalidateToken";
|
|
19
|
+
EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
|
|
19
20
|
return EVENT_ACTION;
|
|
20
21
|
}({});
|
|
21
22
|
exports.EVENT_ACTION = EVENT_ACTION;
|
|
@@ -32,7 +33,7 @@ var ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_TYPE) {
|
|
|
32
33
|
return ADD_STEPS_TYPE;
|
|
33
34
|
}({});
|
|
34
35
|
exports.ADD_STEPS_TYPE = ADD_STEPS_TYPE;
|
|
35
|
-
var ACK_MAX_TRY =
|
|
36
|
+
var ACK_MAX_TRY = 60;
|
|
36
37
|
exports.ACK_MAX_TRY = ACK_MAX_TRY;
|
|
37
38
|
var CONFLUENCE = 'confluence';
|
|
38
39
|
exports.CONFLUENCE = CONFLUENCE;
|
|
@@ -38,6 +38,8 @@ var ParticipantsService = /*#__PURE__*/function () {
|
|
|
38
38
|
var getUser = arguments.length > 3 ? arguments[3] : undefined;
|
|
39
39
|
var channelBroadcast = arguments.length > 4 ? arguments[4] : undefined;
|
|
40
40
|
var sendPresenceJoined = arguments.length > 5 ? arguments[5] : undefined;
|
|
41
|
+
var getPresenceData = arguments.length > 6 ? arguments[6] : undefined;
|
|
42
|
+
var setUserId = arguments.length > 7 ? arguments[7] : undefined;
|
|
41
43
|
(0, _classCallCheck2.default)(this, ParticipantsService);
|
|
42
44
|
/**
|
|
43
45
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
@@ -234,12 +236,13 @@ var ParticipantsService = /*#__PURE__*/function () {
|
|
|
234
236
|
(0, _defineProperty2.default)(this, "clearTimers", function () {
|
|
235
237
|
clearTimeout(_this.participantUpdateTimeout);
|
|
236
238
|
});
|
|
237
|
-
(0, _defineProperty2.default)(this, "sendPresence", function (
|
|
239
|
+
(0, _defineProperty2.default)(this, "sendPresence", function () {
|
|
238
240
|
try {
|
|
239
241
|
clearTimeout(_this.presenceUpdateTimeout);
|
|
240
|
-
_this.
|
|
242
|
+
var _data = _this.getPresenceData();
|
|
243
|
+
_this.channelBroadcast('participant:updated', _data);
|
|
241
244
|
_this.presenceUpdateTimeout = window.setTimeout(function () {
|
|
242
|
-
return _this.sendPresence(
|
|
245
|
+
return _this.sendPresence();
|
|
243
246
|
}, SEND_PRESENCE_INTERVAL);
|
|
244
247
|
} catch (error) {
|
|
245
248
|
var _this$analyticsHelper7;
|
|
@@ -258,7 +261,7 @@ var ParticipantsService = /*#__PURE__*/function () {
|
|
|
258
261
|
try {
|
|
259
262
|
logger('Participant joined with session: ', payload.sessionId);
|
|
260
263
|
// This expose existing users to the newly joined user
|
|
261
|
-
_this.sendPresence(
|
|
264
|
+
_this.sendPresence();
|
|
262
265
|
} catch (error) {
|
|
263
266
|
var _this$analyticsHelper8;
|
|
264
267
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
@@ -274,7 +277,8 @@ var ParticipantsService = /*#__PURE__*/function () {
|
|
|
274
277
|
(0, _defineProperty2.default)(this, "onPresence", function (payload) {
|
|
275
278
|
try {
|
|
276
279
|
logger('onPresence userId: ', payload.userId);
|
|
277
|
-
_this.
|
|
280
|
+
_this.setUserId(payload.userId);
|
|
281
|
+
_this.sendPresence();
|
|
278
282
|
_this.sendPresenceJoined();
|
|
279
283
|
} catch (error) {
|
|
280
284
|
var _this$analyticsHelper9;
|
|
@@ -288,6 +292,8 @@ var ParticipantsService = /*#__PURE__*/function () {
|
|
|
288
292
|
this.getUser = getUser;
|
|
289
293
|
this.channelBroadcast = channelBroadcast;
|
|
290
294
|
this.sendPresenceJoined = sendPresenceJoined;
|
|
295
|
+
this.getPresenceData = getPresenceData;
|
|
296
|
+
this.setUserId = setUserId;
|
|
291
297
|
}
|
|
292
298
|
(0, _createClass2.default)(ParticipantsService, [{
|
|
293
299
|
key: "emitTelepointersFromSteps",
|
|
@@ -115,6 +115,16 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
115
115
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
116
116
|
}).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((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled).on('status', _this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
|
|
117
117
|
});
|
|
118
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setUserId", function (id) {
|
|
119
|
+
_this.userId = id;
|
|
120
|
+
});
|
|
121
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getPresenceData", function () {
|
|
122
|
+
return {
|
|
123
|
+
sessionId: _this.sessionId,
|
|
124
|
+
userId: _this.userId,
|
|
125
|
+
clientId: _this.clientId
|
|
126
|
+
};
|
|
127
|
+
});
|
|
118
128
|
/**
|
|
119
129
|
* @param {InternalError} error The error to handle
|
|
120
130
|
*/
|
|
@@ -183,17 +193,20 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
183
193
|
while (1) switch (_context2.prev = _context2.next) {
|
|
184
194
|
case 0:
|
|
185
195
|
_context2.prev = 0;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
196
|
+
_context2.next = 3;
|
|
197
|
+
return _this.documentService.getFinalAcknowledgedState();
|
|
198
|
+
case 3:
|
|
199
|
+
return _context2.abrupt("return", _context2.sent);
|
|
200
|
+
case 6:
|
|
201
|
+
_context2.prev = 6;
|
|
189
202
|
_context2.t0 = _context2["catch"](0);
|
|
190
203
|
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
191
204
|
throw new _errorTypes.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
192
|
-
case
|
|
205
|
+
case 10:
|
|
193
206
|
case "end":
|
|
194
207
|
return _context2.stop();
|
|
195
208
|
}
|
|
196
|
-
}, _callee2, null, [[0,
|
|
209
|
+
}, _callee2, null, [[0, 6]]);
|
|
197
210
|
})));
|
|
198
211
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getUnconfirmedSteps", function () {
|
|
199
212
|
return _this.documentService.getUnconfirmedSteps();
|
|
@@ -212,7 +225,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
212
225
|
_this.initialDraft = _this.config.initialDraft;
|
|
213
226
|
_this.isProviderInitialized = false;
|
|
214
227
|
_this.isPreinitializing = false;
|
|
215
|
-
_this.participantsService = new _participantsService.ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined);
|
|
228
|
+
_this.participantsService = new _participantsService.ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined, _this.getPresenceData, _this.setUserId);
|
|
216
229
|
_this.metadataService = new _metadataService.MetadataService(_this.emitCallback, _this.channel.sendMetadata);
|
|
217
230
|
_this.documentService = new _documentService.DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
|
|
218
231
|
return _this.userId;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/collab-provider";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "9.0.
|
|
9
|
+
var version = "9.0.1";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
package/dist/es2019/channel.js
CHANGED
|
@@ -250,6 +250,12 @@ export class Channel extends Emitter {
|
|
|
250
250
|
}
|
|
251
251
|
this.socket.emit('metadata', metadata);
|
|
252
252
|
});
|
|
253
|
+
_defineProperty(this, "sendPresenceJoined", () => {
|
|
254
|
+
if (!this.connected || !this.socket) {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
this.socket.emit('presence:joined');
|
|
258
|
+
});
|
|
253
259
|
_defineProperty(this, "onOnlineHandler", () => {
|
|
254
260
|
// Force an immediate reconnect, the socket must first be closed to reset reconnection delay logic
|
|
255
261
|
if (!this.connected) {
|
|
@@ -433,12 +439,6 @@ export class Channel extends Emitter {
|
|
|
433
439
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
434
440
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
435
441
|
}
|
|
436
|
-
sendPresenceJoined() {
|
|
437
|
-
if (!this.connected || !this.socket) {
|
|
438
|
-
return;
|
|
439
|
-
}
|
|
440
|
-
this.socket.emit('presence:joined');
|
|
441
|
-
}
|
|
442
442
|
disconnect() {
|
|
443
443
|
var _this$network;
|
|
444
444
|
this.unsubscribeAll();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
1
2
|
import { createLogger } from '../helpers/utils';
|
|
2
3
|
import { StepMap, Mapping } from 'prosemirror-transform';
|
|
3
4
|
const logger = createLogger('Catchup', 'red');
|
|
@@ -93,6 +94,13 @@ export const catchup = async opt => {
|
|
|
93
94
|
const mapping = new Mapping(stepMaps);
|
|
94
95
|
logger(`${unconfirmedSteps.length} unconfirmed steps before rebased: ${JSON.stringify(unconfirmedSteps)}`);
|
|
95
96
|
const newUnconfirmedSteps = rebaseSteps(unconfirmedSteps, mapping);
|
|
97
|
+
if ((newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length) < unconfirmedSteps.length) {
|
|
98
|
+
var _opt$analyticsHelper;
|
|
99
|
+
// Log the dropped steps after rebase
|
|
100
|
+
(_opt$analyticsHelper = opt.analyticsHelper) === null || _opt$analyticsHelper === void 0 ? void 0 : _opt$analyticsHelper.sendActionEvent(EVENT_ACTION.DROPPED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
101
|
+
numOfDroppedSteps: unconfirmedSteps.length - (newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length)
|
|
102
|
+
});
|
|
103
|
+
}
|
|
96
104
|
logger(`Re-aply ${newUnconfirmedSteps.length} mapped unconfirmed steps: ${JSON.stringify(newUnconfirmedSteps)}`);
|
|
97
105
|
// Re-apply local steps
|
|
98
106
|
opt.applyLocalSteps(newUnconfirmedSteps);
|
|
@@ -62,7 +62,8 @@ export class DocumentService {
|
|
|
62
62
|
filterQueue: this.stepQueue.filterQueue,
|
|
63
63
|
applyLocalSteps: this.applyLocalSteps,
|
|
64
64
|
updateDocument: this.updateDocument,
|
|
65
|
-
updateMetadata: this.metadataService.updateMetadata
|
|
65
|
+
updateMetadata: this.metadataService.updateMetadata,
|
|
66
|
+
analyticsHelper: this.analyticsHelper
|
|
66
67
|
});
|
|
67
68
|
const latency = new Date().getTime() - start;
|
|
68
69
|
(_this$analyticsHelper = this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
|
|
@@ -290,7 +291,7 @@ export class DocumentService {
|
|
|
290
291
|
let isLastTrConfirmed = false;
|
|
291
292
|
while (!isLastTrConfirmed) {
|
|
292
293
|
this.sendStepsFromCurrentState();
|
|
293
|
-
await sleep(
|
|
294
|
+
await sleep(500);
|
|
294
295
|
const nextUnconfirmedSteps = this.getUnconfirmedSteps();
|
|
295
296
|
if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
|
|
296
297
|
const nextUnconfirmedTrs = this.getUnconfirmedStepsOrigins();
|
|
@@ -10,6 +10,7 @@ export let EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
|
|
|
10
10
|
EVENT_ACTION["PUBLISH_PAGE"] = "publishPage";
|
|
11
11
|
EVENT_ACTION["GET_CURRENT_STATE"] = "getCurrentState";
|
|
12
12
|
EVENT_ACTION["INVALIDATE_TOKEN"] = "invalidateToken";
|
|
13
|
+
EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
|
|
13
14
|
return EVENT_ACTION;
|
|
14
15
|
}({});
|
|
15
16
|
export let EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
|
|
@@ -23,5 +24,5 @@ export let ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_TYPE) {
|
|
|
23
24
|
ADD_STEPS_TYPE["ERROR"] = "ERROR";
|
|
24
25
|
return ADD_STEPS_TYPE;
|
|
25
26
|
}({});
|
|
26
|
-
export const ACK_MAX_TRY =
|
|
27
|
+
export const ACK_MAX_TRY = 60;
|
|
27
28
|
export const CONFLUENCE = 'confluence';
|
|
@@ -18,7 +18,7 @@ const SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
|
|
|
18
18
|
* @param sendPresenceJoined Callback to Channel class
|
|
19
19
|
*/
|
|
20
20
|
export class ParticipantsService {
|
|
21
|
-
constructor(analyticsHelper, participantsState = new ParticipantsState(), emit, getUser, channelBroadcast, sendPresenceJoined) {
|
|
21
|
+
constructor(analyticsHelper, participantsState = new ParticipantsState(), emit, getUser, channelBroadcast, sendPresenceJoined, getPresenceData, setUserId) {
|
|
22
22
|
/**
|
|
23
23
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
24
24
|
* @param payload Payload from incoming socket event
|
|
@@ -187,11 +187,12 @@ export class ParticipantsService {
|
|
|
187
187
|
_defineProperty(this, "clearTimers", () => {
|
|
188
188
|
clearTimeout(this.participantUpdateTimeout);
|
|
189
189
|
});
|
|
190
|
-
_defineProperty(this, "sendPresence",
|
|
190
|
+
_defineProperty(this, "sendPresence", () => {
|
|
191
191
|
try {
|
|
192
192
|
clearTimeout(this.presenceUpdateTimeout);
|
|
193
|
-
this.
|
|
194
|
-
this.
|
|
193
|
+
const data = this.getPresenceData();
|
|
194
|
+
this.channelBroadcast('participant:updated', data);
|
|
195
|
+
this.presenceUpdateTimeout = window.setTimeout(() => this.sendPresence(), SEND_PRESENCE_INTERVAL);
|
|
195
196
|
} catch (error) {
|
|
196
197
|
var _this$analyticsHelper7;
|
|
197
198
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
@@ -209,7 +210,7 @@ export class ParticipantsService {
|
|
|
209
210
|
try {
|
|
210
211
|
logger('Participant joined with session: ', payload.sessionId);
|
|
211
212
|
// This expose existing users to the newly joined user
|
|
212
|
-
this.sendPresence(
|
|
213
|
+
this.sendPresence();
|
|
213
214
|
} catch (error) {
|
|
214
215
|
var _this$analyticsHelper8;
|
|
215
216
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
@@ -225,7 +226,8 @@ export class ParticipantsService {
|
|
|
225
226
|
_defineProperty(this, "onPresence", payload => {
|
|
226
227
|
try {
|
|
227
228
|
logger('onPresence userId: ', payload.userId);
|
|
228
|
-
this.
|
|
229
|
+
this.setUserId(payload.userId);
|
|
230
|
+
this.sendPresence();
|
|
229
231
|
this.sendPresenceJoined();
|
|
230
232
|
} catch (error) {
|
|
231
233
|
var _this$analyticsHelper9;
|
|
@@ -239,6 +241,8 @@ export class ParticipantsService {
|
|
|
239
241
|
this.getUser = getUser;
|
|
240
242
|
this.channelBroadcast = channelBroadcast;
|
|
241
243
|
this.sendPresenceJoined = sendPresenceJoined;
|
|
244
|
+
this.getPresenceData = getPresenceData;
|
|
245
|
+
this.setUserId = setUserId;
|
|
242
246
|
}
|
|
243
247
|
/**
|
|
244
248
|
* Called on receiving steps, emits each step's telepointer
|
|
@@ -91,6 +91,16 @@ export class Provider extends Emitter {
|
|
|
91
91
|
this.isProviderInitialized = true;
|
|
92
92
|
}).on('restore', this.documentService.onRestore).on('steps:added', this.documentService.onStepsAdded).on('metadata:changed', this.metadataService.onMetadataChanged).on('participant:telepointer', payload => this.participantsService.onParticipantTelepointer(payload, this.sessionId)).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(this)).on('error', this.onErrorHandled).on('status', this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
|
|
93
93
|
});
|
|
94
|
+
_defineProperty(this, "setUserId", id => {
|
|
95
|
+
this.userId = id;
|
|
96
|
+
});
|
|
97
|
+
_defineProperty(this, "getPresenceData", () => {
|
|
98
|
+
return {
|
|
99
|
+
sessionId: this.sessionId,
|
|
100
|
+
userId: this.userId,
|
|
101
|
+
clientId: this.clientId
|
|
102
|
+
};
|
|
103
|
+
});
|
|
94
104
|
/**
|
|
95
105
|
* @param {InternalError} error The error to handle
|
|
96
106
|
*/
|
|
@@ -147,7 +157,7 @@ export class Provider extends Emitter {
|
|
|
147
157
|
*/
|
|
148
158
|
_defineProperty(this, "getFinalAcknowledgedState", async () => {
|
|
149
159
|
try {
|
|
150
|
-
return this.documentService.getFinalAcknowledgedState();
|
|
160
|
+
return await this.documentService.getFinalAcknowledgedState();
|
|
151
161
|
} catch (error) {
|
|
152
162
|
var _this$analyticsHelper4;
|
|
153
163
|
(_this$analyticsHelper4 = this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(error, 'Error while returning ADF version of the final draft document');
|
|
@@ -171,7 +181,7 @@ export class Provider extends Emitter {
|
|
|
171
181
|
this.initialDraft = this.config.initialDraft;
|
|
172
182
|
this.isProviderInitialized = false;
|
|
173
183
|
this.isPreinitializing = false;
|
|
174
|
-
this.participantsService = new ParticipantsService(this.analyticsHelper, undefined, this.emitCallback, this.config.getUser, this.channel.broadcast, this.channel.sendPresenceJoined);
|
|
184
|
+
this.participantsService = new ParticipantsService(this.analyticsHelper, undefined, this.emitCallback, this.config.getUser, this.channel.broadcast, this.channel.sendPresenceJoined, this.getPresenceData, this.setUserId);
|
|
175
185
|
this.metadataService = new MetadataService(this.emitCallback, this.channel.sendMetadata);
|
|
176
186
|
this.documentService = new DocumentService(this.participantsService, this.analyticsHelper, this.channel.fetchCatchup, this.emitCallback, this.channel.broadcast, () => this.userId, this.onErrorHandled, this.metadataService);
|
|
177
187
|
this.getStatePromise = new Promise(resolve => {
|
package/dist/es2019/version.json
CHANGED
package/dist/esm/channel.js
CHANGED
|
@@ -343,6 +343,12 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
343
343
|
}
|
|
344
344
|
_this.socket.emit('metadata', metadata);
|
|
345
345
|
});
|
|
346
|
+
_defineProperty(_assertThisInitialized(_this), "sendPresenceJoined", function () {
|
|
347
|
+
if (!_this.connected || !_this.socket) {
|
|
348
|
+
return;
|
|
349
|
+
}
|
|
350
|
+
_this.socket.emit('presence:joined');
|
|
351
|
+
});
|
|
346
352
|
_defineProperty(_assertThisInitialized(_this), "onOnlineHandler", function () {
|
|
347
353
|
// Force an immediate reconnect, the socket must first be closed to reset reconnection delay logic
|
|
348
354
|
if (!_this.connected) {
|
|
@@ -559,14 +565,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
559
565
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
560
566
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
561
567
|
}
|
|
562
|
-
}, {
|
|
563
|
-
key: "sendPresenceJoined",
|
|
564
|
-
value: function sendPresenceJoined() {
|
|
565
|
-
if (!this.connected || !this.socket) {
|
|
566
|
-
return;
|
|
567
|
-
}
|
|
568
|
-
this.socket.emit('presence:joined');
|
|
569
|
-
}
|
|
570
568
|
}, {
|
|
571
569
|
key: "disconnect",
|
|
572
570
|
value: function disconnect() {
|
|
@@ -3,6 +3,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
|
3
3
|
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
4
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
5
5
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
6
|
+
import { EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
6
7
|
import { createLogger } from '../helpers/utils';
|
|
7
8
|
import { StepMap, Mapping } from 'prosemirror-transform';
|
|
8
9
|
var logger = createLogger('Catchup', 'red');
|
|
@@ -34,7 +35,7 @@ export function rebaseSteps(steps, mapping) {
|
|
|
34
35
|
}
|
|
35
36
|
export var catchup = /*#__PURE__*/function () {
|
|
36
37
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(opt) {
|
|
37
|
-
var _yield$opt$fetchCatch, doc, serverStepMaps, serverVersion, metadata, currentPmVersion, unconfirmedSteps, _unconfirmedSteps, stepMaps, mapping, newUnconfirmedSteps;
|
|
38
|
+
var _yield$opt$fetchCatch, doc, serverStepMaps, serverVersion, metadata, currentPmVersion, unconfirmedSteps, _unconfirmedSteps, stepMaps, mapping, newUnconfirmedSteps, _opt$analyticsHelper;
|
|
38
39
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
40
|
while (1) switch (_context.prev = _context.next) {
|
|
40
41
|
case 0:
|
|
@@ -112,6 +113,12 @@ export var catchup = /*#__PURE__*/function () {
|
|
|
112
113
|
mapping = new Mapping(stepMaps);
|
|
113
114
|
logger("".concat(_unconfirmedSteps.length, " unconfirmed steps before rebased: ").concat(JSON.stringify(_unconfirmedSteps)));
|
|
114
115
|
newUnconfirmedSteps = rebaseSteps(_unconfirmedSteps, mapping);
|
|
116
|
+
if ((newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length) < _unconfirmedSteps.length) {
|
|
117
|
+
// Log the dropped steps after rebase
|
|
118
|
+
(_opt$analyticsHelper = opt.analyticsHelper) === null || _opt$analyticsHelper === void 0 ? void 0 : _opt$analyticsHelper.sendActionEvent(EVENT_ACTION.DROPPED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
119
|
+
numOfDroppedSteps: _unconfirmedSteps.length - (newUnconfirmedSteps === null || newUnconfirmedSteps === void 0 ? void 0 : newUnconfirmedSteps.length)
|
|
120
|
+
});
|
|
121
|
+
}
|
|
115
122
|
logger("Re-aply ".concat(newUnconfirmedSteps.length, " mapped unconfirmed steps: ").concat(JSON.stringify(newUnconfirmedSteps)));
|
|
116
123
|
// Re-apply local steps
|
|
117
124
|
opt.applyLocalSteps(newUnconfirmedSteps);
|
|
@@ -78,7 +78,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
78
78
|
filterQueue: _this.stepQueue.filterQueue,
|
|
79
79
|
applyLocalSteps: _this.applyLocalSteps,
|
|
80
80
|
updateDocument: _this.updateDocument,
|
|
81
|
-
updateMetadata: _this.metadataService.updateMetadata
|
|
81
|
+
updateMetadata: _this.metadataService.updateMetadata,
|
|
82
|
+
analyticsHelper: _this.analyticsHelper
|
|
82
83
|
});
|
|
83
84
|
case 8:
|
|
84
85
|
latency = new Date().getTime() - start;
|
|
@@ -345,7 +346,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
345
346
|
}
|
|
346
347
|
_this.sendStepsFromCurrentState();
|
|
347
348
|
_context4.next = 12;
|
|
348
|
-
return sleep(
|
|
349
|
+
return sleep(500);
|
|
349
350
|
case 12:
|
|
350
351
|
nextUnconfirmedSteps = _this.getUnconfirmedSteps();
|
|
351
352
|
if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
|
|
@@ -10,6 +10,7 @@ export var EVENT_ACTION = /*#__PURE__*/function (EVENT_ACTION) {
|
|
|
10
10
|
EVENT_ACTION["PUBLISH_PAGE"] = "publishPage";
|
|
11
11
|
EVENT_ACTION["GET_CURRENT_STATE"] = "getCurrentState";
|
|
12
12
|
EVENT_ACTION["INVALIDATE_TOKEN"] = "invalidateToken";
|
|
13
|
+
EVENT_ACTION["DROPPED_STEPS"] = "droppedStepInCatchup";
|
|
13
14
|
return EVENT_ACTION;
|
|
14
15
|
}({});
|
|
15
16
|
export var EVENT_STATUS = /*#__PURE__*/function (EVENT_STATUS) {
|
|
@@ -23,5 +24,5 @@ export var ADD_STEPS_TYPE = /*#__PURE__*/function (ADD_STEPS_TYPE) {
|
|
|
23
24
|
ADD_STEPS_TYPE["ERROR"] = "ERROR";
|
|
24
25
|
return ADD_STEPS_TYPE;
|
|
25
26
|
}({});
|
|
26
|
-
export var ACK_MAX_TRY =
|
|
27
|
+
export var ACK_MAX_TRY = 60;
|
|
27
28
|
export var CONFLUENCE = 'confluence';
|
|
@@ -31,6 +31,8 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
31
31
|
var getUser = arguments.length > 3 ? arguments[3] : undefined;
|
|
32
32
|
var channelBroadcast = arguments.length > 4 ? arguments[4] : undefined;
|
|
33
33
|
var sendPresenceJoined = arguments.length > 5 ? arguments[5] : undefined;
|
|
34
|
+
var getPresenceData = arguments.length > 6 ? arguments[6] : undefined;
|
|
35
|
+
var setUserId = arguments.length > 7 ? arguments[7] : undefined;
|
|
34
36
|
_classCallCheck(this, ParticipantsService);
|
|
35
37
|
/**
|
|
36
38
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
@@ -227,12 +229,13 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
227
229
|
_defineProperty(this, "clearTimers", function () {
|
|
228
230
|
clearTimeout(_this.participantUpdateTimeout);
|
|
229
231
|
});
|
|
230
|
-
_defineProperty(this, "sendPresence", function (
|
|
232
|
+
_defineProperty(this, "sendPresence", function () {
|
|
231
233
|
try {
|
|
232
234
|
clearTimeout(_this.presenceUpdateTimeout);
|
|
233
|
-
_this.
|
|
235
|
+
var _data = _this.getPresenceData();
|
|
236
|
+
_this.channelBroadcast('participant:updated', _data);
|
|
234
237
|
_this.presenceUpdateTimeout = window.setTimeout(function () {
|
|
235
|
-
return _this.sendPresence(
|
|
238
|
+
return _this.sendPresence();
|
|
236
239
|
}, SEND_PRESENCE_INTERVAL);
|
|
237
240
|
} catch (error) {
|
|
238
241
|
var _this$analyticsHelper7;
|
|
@@ -251,7 +254,7 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
251
254
|
try {
|
|
252
255
|
logger('Participant joined with session: ', payload.sessionId);
|
|
253
256
|
// This expose existing users to the newly joined user
|
|
254
|
-
_this.sendPresence(
|
|
257
|
+
_this.sendPresence();
|
|
255
258
|
} catch (error) {
|
|
256
259
|
var _this$analyticsHelper8;
|
|
257
260
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
@@ -267,7 +270,8 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
267
270
|
_defineProperty(this, "onPresence", function (payload) {
|
|
268
271
|
try {
|
|
269
272
|
logger('onPresence userId: ', payload.userId);
|
|
270
|
-
_this.
|
|
273
|
+
_this.setUserId(payload.userId);
|
|
274
|
+
_this.sendPresence();
|
|
271
275
|
_this.sendPresenceJoined();
|
|
272
276
|
} catch (error) {
|
|
273
277
|
var _this$analyticsHelper9;
|
|
@@ -281,6 +285,8 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
281
285
|
this.getUser = getUser;
|
|
282
286
|
this.channelBroadcast = channelBroadcast;
|
|
283
287
|
this.sendPresenceJoined = sendPresenceJoined;
|
|
288
|
+
this.getPresenceData = getPresenceData;
|
|
289
|
+
this.setUserId = setUserId;
|
|
284
290
|
}
|
|
285
291
|
_createClass(ParticipantsService, [{
|
|
286
292
|
key: "emitTelepointersFromSteps",
|
|
@@ -107,6 +107,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
107
107
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
108
108
|
}).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);
|
|
109
109
|
});
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "setUserId", function (id) {
|
|
111
|
+
_this.userId = id;
|
|
112
|
+
});
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "getPresenceData", function () {
|
|
114
|
+
return {
|
|
115
|
+
sessionId: _this.sessionId,
|
|
116
|
+
userId: _this.userId,
|
|
117
|
+
clientId: _this.clientId
|
|
118
|
+
};
|
|
119
|
+
});
|
|
110
120
|
/**
|
|
111
121
|
* @param {InternalError} error The error to handle
|
|
112
122
|
*/
|
|
@@ -175,17 +185,20 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
175
185
|
while (1) switch (_context2.prev = _context2.next) {
|
|
176
186
|
case 0:
|
|
177
187
|
_context2.prev = 0;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
_context2.next = 3;
|
|
189
|
+
return _this.documentService.getFinalAcknowledgedState();
|
|
190
|
+
case 3:
|
|
191
|
+
return _context2.abrupt("return", _context2.sent);
|
|
192
|
+
case 6:
|
|
193
|
+
_context2.prev = 6;
|
|
181
194
|
_context2.t0 = _context2["catch"](0);
|
|
182
195
|
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
183
196
|
throw new GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
184
|
-
case
|
|
197
|
+
case 10:
|
|
185
198
|
case "end":
|
|
186
199
|
return _context2.stop();
|
|
187
200
|
}
|
|
188
|
-
}, _callee2, null, [[0,
|
|
201
|
+
}, _callee2, null, [[0, 6]]);
|
|
189
202
|
})));
|
|
190
203
|
_defineProperty(_assertThisInitialized(_this), "getUnconfirmedSteps", function () {
|
|
191
204
|
return _this.documentService.getUnconfirmedSteps();
|
|
@@ -204,7 +217,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
204
217
|
_this.initialDraft = _this.config.initialDraft;
|
|
205
218
|
_this.isProviderInitialized = false;
|
|
206
219
|
_this.isPreinitializing = false;
|
|
207
|
-
_this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined);
|
|
220
|
+
_this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined, _this.getPresenceData, _this.setUserId);
|
|
208
221
|
_this.metadataService = new MetadataService(_this.emitCallback, _this.channel.sendMetadata);
|
|
209
222
|
_this.documentService = new DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
|
|
210
223
|
return _this.userId;
|
package/dist/esm/version.json
CHANGED
package/dist/types/channel.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
41
41
|
* @throws {NotConnectedError} Channel not connected
|
|
42
42
|
*/
|
|
43
43
|
sendMetadata: (metadata: Metadata) => void;
|
|
44
|
-
sendPresenceJoined()
|
|
44
|
+
sendPresenceJoined: () => void;
|
|
45
45
|
onOnlineHandler: () => void;
|
|
46
46
|
disconnect(): void;
|
|
47
47
|
}
|
|
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
|
|
|
10
10
|
ERROR = "error",
|
|
11
11
|
PUBLISH_PAGE = "publishPage",
|
|
12
12
|
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
-
INVALIDATE_TOKEN = "invalidateToken"
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken",
|
|
14
|
+
DROPPED_STEPS = "droppedStepInCatchup"
|
|
14
15
|
}
|
|
15
16
|
export declare enum EVENT_STATUS {
|
|
16
17
|
SUCCESS = "SUCCESS",
|
|
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
|
|
|
110
111
|
latency?: number;
|
|
111
112
|
};
|
|
112
113
|
};
|
|
114
|
+
type CatchUpDroppedStepsEvent = {
|
|
115
|
+
eventAction: EVENT_ACTION.DROPPED_STEPS;
|
|
116
|
+
attributes: {
|
|
117
|
+
documentAri: string;
|
|
118
|
+
numOfDroppedSteps: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
113
121
|
type DocumentInitSuccessAnalyticsEvent = {
|
|
114
122
|
eventAction: EVENT_ACTION.DOCUMENT_INIT;
|
|
115
123
|
attributes: {
|
|
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
|
|
|
177
185
|
latency?: number;
|
|
178
186
|
};
|
|
179
187
|
};
|
|
180
|
-
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
181
|
-
export declare const ACK_MAX_TRY =
|
|
188
|
+
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
189
|
+
export declare const ACK_MAX_TRY = 60;
|
|
182
190
|
export declare const CONFLUENCE = "confluence";
|
|
183
191
|
export {};
|
|
@@ -6,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
|
|
|
6
6
|
};
|
|
7
7
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
8
8
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
|
|
9
|
-
export declare const createParticipantFromPayload: (payload:
|
|
9
|
+
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
} & {
|
|
10
12
|
userId: string;
|
|
11
13
|
}, getUser: GetUserType) => Promise<ProviderParticipant>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
2
|
+
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
3
3
|
import { GetUserType } from './participants-helper';
|
|
4
4
|
import { ParticipantsState } from './participants-state';
|
|
5
5
|
/**
|
|
@@ -18,9 +18,11 @@ export declare class ParticipantsService {
|
|
|
18
18
|
private getUser;
|
|
19
19
|
private channelBroadcast;
|
|
20
20
|
private sendPresenceJoined;
|
|
21
|
+
private getPresenceData;
|
|
22
|
+
private setUserId;
|
|
21
23
|
private participantUpdateTimeout;
|
|
22
24
|
private presenceUpdateTimeout;
|
|
23
|
-
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
|
|
25
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
|
|
24
26
|
/**
|
|
25
27
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
26
28
|
* @param payload Payload from incoming socket event
|
|
@@ -33,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
33
33
|
getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
|
|
34
34
|
constructor(config: Config);
|
|
35
35
|
private initializeChannel;
|
|
36
|
+
private setUserId;
|
|
37
|
+
private getPresenceData;
|
|
36
38
|
/**
|
|
37
39
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
38
40
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
package/dist/types/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { InternalError } from './errors/error-types';
|
|
|
7
7
|
import type { ProviderError } from './errors/error-types';
|
|
8
8
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
9
9
|
import { ProviderParticipant } from './participants/participants-helper';
|
|
10
|
+
import AnalyticsHelper from './analytics/analytics-helper';
|
|
10
11
|
export interface CollabParticipant {
|
|
11
12
|
lastActive: number;
|
|
12
13
|
sessionId: string;
|
|
@@ -167,10 +168,12 @@ export type BroadcastIncomingPayload = {
|
|
|
167
168
|
timestamp?: number;
|
|
168
169
|
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
169
170
|
};
|
|
170
|
-
export type
|
|
171
|
+
export type PresenceData = {
|
|
171
172
|
sessionId: string;
|
|
172
173
|
userId: string | undefined;
|
|
173
174
|
clientId: number | string;
|
|
175
|
+
};
|
|
176
|
+
export type PresencePayload = PresenceData & {
|
|
174
177
|
timestamp: number;
|
|
175
178
|
};
|
|
176
179
|
export type TelepointerPayload = PresencePayload & {
|
|
@@ -270,6 +273,7 @@ export interface CatchupOptions {
|
|
|
270
273
|
applyLocalSteps: (steps: Step[]) => void;
|
|
271
274
|
updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
272
275
|
updateMetadata: (metadata: Metadata | undefined) => void;
|
|
276
|
+
analyticsHelper: AnalyticsHelper | undefined;
|
|
273
277
|
}
|
|
274
278
|
export type ProductInformation = {
|
|
275
279
|
product: string;
|
|
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
41
41
|
* @throws {NotConnectedError} Channel not connected
|
|
42
42
|
*/
|
|
43
43
|
sendMetadata: (metadata: Metadata) => void;
|
|
44
|
-
sendPresenceJoined()
|
|
44
|
+
sendPresenceJoined: () => void;
|
|
45
45
|
onOnlineHandler: () => void;
|
|
46
46
|
disconnect(): void;
|
|
47
47
|
}
|
|
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
|
|
|
10
10
|
ERROR = "error",
|
|
11
11
|
PUBLISH_PAGE = "publishPage",
|
|
12
12
|
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
-
INVALIDATE_TOKEN = "invalidateToken"
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken",
|
|
14
|
+
DROPPED_STEPS = "droppedStepInCatchup"
|
|
14
15
|
}
|
|
15
16
|
export declare enum EVENT_STATUS {
|
|
16
17
|
SUCCESS = "SUCCESS",
|
|
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
|
|
|
110
111
|
latency?: number;
|
|
111
112
|
};
|
|
112
113
|
};
|
|
114
|
+
type CatchUpDroppedStepsEvent = {
|
|
115
|
+
eventAction: EVENT_ACTION.DROPPED_STEPS;
|
|
116
|
+
attributes: {
|
|
117
|
+
documentAri: string;
|
|
118
|
+
numOfDroppedSteps: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
113
121
|
type DocumentInitSuccessAnalyticsEvent = {
|
|
114
122
|
eventAction: EVENT_ACTION.DOCUMENT_INIT;
|
|
115
123
|
attributes: {
|
|
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
|
|
|
177
185
|
latency?: number;
|
|
178
186
|
};
|
|
179
187
|
};
|
|
180
|
-
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
181
|
-
export declare const ACK_MAX_TRY =
|
|
188
|
+
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
189
|
+
export declare const ACK_MAX_TRY = 60;
|
|
182
190
|
export declare const CONFLUENCE = "confluence";
|
|
183
191
|
export {};
|
|
@@ -6,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
|
|
|
6
6
|
};
|
|
7
7
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
8
8
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
|
|
9
|
-
export declare const createParticipantFromPayload: (payload:
|
|
9
|
+
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
} & {
|
|
10
12
|
userId: string;
|
|
11
13
|
}, getUser: GetUserType) => Promise<ProviderParticipant>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
2
|
+
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
3
3
|
import { GetUserType } from './participants-helper';
|
|
4
4
|
import { ParticipantsState } from './participants-state';
|
|
5
5
|
/**
|
|
@@ -18,9 +18,11 @@ export declare class ParticipantsService {
|
|
|
18
18
|
private getUser;
|
|
19
19
|
private channelBroadcast;
|
|
20
20
|
private sendPresenceJoined;
|
|
21
|
+
private getPresenceData;
|
|
22
|
+
private setUserId;
|
|
21
23
|
private participantUpdateTimeout;
|
|
22
24
|
private presenceUpdateTimeout;
|
|
23
|
-
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
|
|
25
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
|
|
24
26
|
/**
|
|
25
27
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
26
28
|
* @param payload Payload from incoming socket event
|
|
@@ -33,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
33
33
|
getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
|
|
34
34
|
constructor(config: Config);
|
|
35
35
|
private initializeChannel;
|
|
36
|
+
private setUserId;
|
|
37
|
+
private getPresenceData;
|
|
36
38
|
/**
|
|
37
39
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
38
40
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -7,6 +7,7 @@ import type { InternalError } from './errors/error-types';
|
|
|
7
7
|
import type { ProviderError } from './errors/error-types';
|
|
8
8
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
9
9
|
import { ProviderParticipant } from './participants/participants-helper';
|
|
10
|
+
import AnalyticsHelper from './analytics/analytics-helper';
|
|
10
11
|
export interface CollabParticipant {
|
|
11
12
|
lastActive: number;
|
|
12
13
|
sessionId: string;
|
|
@@ -167,10 +168,12 @@ export type BroadcastIncomingPayload = {
|
|
|
167
168
|
timestamp?: number;
|
|
168
169
|
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
169
170
|
};
|
|
170
|
-
export type
|
|
171
|
+
export type PresenceData = {
|
|
171
172
|
sessionId: string;
|
|
172
173
|
userId: string | undefined;
|
|
173
174
|
clientId: number | string;
|
|
175
|
+
};
|
|
176
|
+
export type PresencePayload = PresenceData & {
|
|
174
177
|
timestamp: number;
|
|
175
178
|
};
|
|
176
179
|
export type TelepointerPayload = PresencePayload & {
|
|
@@ -270,6 +273,7 @@ export interface CatchupOptions {
|
|
|
270
273
|
applyLocalSteps: (steps: Step[]) => void;
|
|
271
274
|
updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
272
275
|
updateMetadata: (metadata: Metadata | undefined) => void;
|
|
276
|
+
analyticsHelper: AnalyticsHelper | undefined;
|
|
273
277
|
}
|
|
274
278
|
export type ProductInformation = {
|
|
275
279
|
product: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.0.
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@atlaskit/adf-schema": "^25.7.0",
|
|
65
65
|
"@atlaskit/analytics-listeners": "^8.7.0",
|
|
66
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
66
|
+
"@atlaskit/editor-test-helpers": "^18.5.0",
|
|
67
67
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
68
68
|
"@types/prosemirror-model": "^1.11.0",
|
|
69
69
|
"@types/prosemirror-state": "^1.2.0",
|