@atlaskit/collab-provider 9.30.0 → 9.31.0
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 +19 -0
- package/afm-jira/tsconfig.json +45 -0
- package/dist/cjs/channel.js +15 -7
- package/dist/cjs/participants/participants-service.js +38 -4
- package/dist/cjs/provider/index.js +33 -11
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/channel.js +10 -0
- package/dist/es2019/participants/participants-service.js +38 -4
- package/dist/es2019/provider/index.js +33 -10
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/channel.js +15 -7
- package/dist/esm/participants/participants-service.js +38 -4
- package/dist/esm/provider/index.js +34 -11
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/participants/participants-service.d.ts +11 -3
- package/dist/types/provider/index.d.ts +2 -2
- package/dist/types/types.d.ts +8 -2
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/participants/participants-service.d.ts +11 -3
- package/dist/types-ts4.5/provider/index.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +8 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.31.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#114811](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114811)
|
|
8
|
+
[`ad0d2f10ef71b`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ad0d2f10ef71b) -
|
|
9
|
+
CONFONBO-3268: Changes for the experiment Teammate Presence: expose 2 new collab events to add
|
|
10
|
+
statuses (viewing/editing) to Confluence
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 9.30.1
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
|
|
3
22
|
## 9.30.0
|
|
4
23
|
|
|
5
24
|
### Minor Changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../../tsconfig.entry-points.jira.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"declaration": true,
|
|
5
|
+
"target": "es5",
|
|
6
|
+
"outDir": "../../../../../tsDist/@atlaskit__collab-provider/app",
|
|
7
|
+
"composite": true,
|
|
8
|
+
"rootDir": "../"
|
|
9
|
+
},
|
|
10
|
+
"include": [
|
|
11
|
+
"../src/**/*.ts",
|
|
12
|
+
"../src/**/*.tsx"
|
|
13
|
+
],
|
|
14
|
+
"exclude": [
|
|
15
|
+
"../src/**/__tests__/*",
|
|
16
|
+
"../src/**/*.test.*",
|
|
17
|
+
"../src/**/test.*"
|
|
18
|
+
],
|
|
19
|
+
"references": [
|
|
20
|
+
{
|
|
21
|
+
"path": "../../../analytics/analytics-gas-types/afm-jira/tsconfig.json"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"path": "../../../analytics/analytics-listeners/afm-jira/tsconfig.json"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"path": "../../editor-common/afm-jira/tsconfig.json"
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"path": "../../editor-json-transformer/afm-jira/tsconfig.json"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"path": "../../../platform/feature-flags/afm-jira/tsconfig.json"
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
"path": "../../prosemirror-collab/afm-jira/tsconfig.json"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"path": "../../../data/ufo-external/afm-jira/tsconfig.json"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"path": "../../../elements/util-service-support/afm-jira/tsconfig.json"
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|
package/dist/cjs/channel.js
CHANGED
|
@@ -618,6 +618,14 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
618
618
|
timestamp: timestamp
|
|
619
619
|
}, data));
|
|
620
620
|
});
|
|
621
|
+
this.socket.on('participant:activity-ack', function (_ref8) {
|
|
622
|
+
var data = _ref8.data;
|
|
623
|
+
_this2.emit('participant:activity-ack', data);
|
|
624
|
+
});
|
|
625
|
+
this.socket.on('participant:activity-join', function (_ref9) {
|
|
626
|
+
var data = _ref9.data;
|
|
627
|
+
_this2.emit('participant:activity-join', data);
|
|
628
|
+
});
|
|
621
629
|
this.socket.on('presence:joined', function (data) {
|
|
622
630
|
_this2.emit('presence:joined', data);
|
|
623
631
|
});
|
|
@@ -627,11 +635,11 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
627
635
|
this.socket.on('participant:left', function (data) {
|
|
628
636
|
_this2.emit('participant:left', data);
|
|
629
637
|
});
|
|
630
|
-
this.socket.on('participant:updated', function (
|
|
631
|
-
var sessionId =
|
|
632
|
-
timestamp =
|
|
633
|
-
data =
|
|
634
|
-
clientId =
|
|
638
|
+
this.socket.on('participant:updated', function (_ref10) {
|
|
639
|
+
var sessionId = _ref10.sessionId,
|
|
640
|
+
timestamp = _ref10.timestamp,
|
|
641
|
+
data = _ref10.data,
|
|
642
|
+
clientId = _ref10.clientId;
|
|
635
643
|
_this2.emit('participant:updated', _objectSpread({
|
|
636
644
|
sessionId: sessionId,
|
|
637
645
|
timestamp: timestamp,
|
|
@@ -647,7 +655,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
647
655
|
_this2.emit('status', data);
|
|
648
656
|
});
|
|
649
657
|
this.socket.on('disconnect', /*#__PURE__*/function () {
|
|
650
|
-
var
|
|
658
|
+
var _ref11 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee7(reason) {
|
|
651
659
|
var _this2$analyticsHelpe, reconnectionError;
|
|
652
660
|
return _regenerator.default.wrap(function _callee7$(_context7) {
|
|
653
661
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -680,7 +688,7 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
680
688
|
}, _callee7);
|
|
681
689
|
}));
|
|
682
690
|
return function (_x10) {
|
|
683
|
-
return
|
|
691
|
+
return _ref11.apply(this, arguments);
|
|
684
692
|
};
|
|
685
693
|
}());
|
|
686
694
|
|
|
@@ -250,6 +250,40 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
|
|
|
250
250
|
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(error, 'Error while sending presence');
|
|
251
251
|
}
|
|
252
252
|
});
|
|
253
|
+
/**
|
|
254
|
+
* sending new joiner's activity to existing participants
|
|
255
|
+
*/
|
|
256
|
+
(0, _defineProperty2.default)(this, "onParticipantActivityJoin", function (payload) {
|
|
257
|
+
try {
|
|
258
|
+
logger('New participant joined: ', payload.activity);
|
|
259
|
+
var _data2 = {
|
|
260
|
+
userId: payload.userId,
|
|
261
|
+
activity: payload.activity
|
|
262
|
+
};
|
|
263
|
+
_this.emit('activity:join', _data2);
|
|
264
|
+
} catch (error) {
|
|
265
|
+
var _this$analyticsHelper8;
|
|
266
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
267
|
+
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(error, "Error while sending 'activity:join'");
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
/**
|
|
271
|
+
* respond to new joiner with existing participant's activity
|
|
272
|
+
*/
|
|
273
|
+
(0, _defineProperty2.default)(this, "onParticipantActivityAck", function (payload) {
|
|
274
|
+
try {
|
|
275
|
+
logger('Existing participants ack: ', payload.activity);
|
|
276
|
+
var _data3 = {
|
|
277
|
+
activity: payload.activity,
|
|
278
|
+
userId: _this.getPresenceData().userId
|
|
279
|
+
};
|
|
280
|
+
_this.emit('activity:ack', _data3);
|
|
281
|
+
} catch (error) {
|
|
282
|
+
var _this$analyticsHelper9;
|
|
283
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
284
|
+
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(error, "Error while sending 'activity:ack'");
|
|
285
|
+
}
|
|
286
|
+
});
|
|
253
287
|
/**
|
|
254
288
|
* Called when a participant joins the session.
|
|
255
289
|
*
|
|
@@ -263,9 +297,9 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
|
|
|
263
297
|
// This expose existing users to the newly joined user
|
|
264
298
|
_this.sendPresence();
|
|
265
299
|
} catch (error) {
|
|
266
|
-
var _this$
|
|
300
|
+
var _this$analyticsHelper10;
|
|
267
301
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
268
|
-
(_this$
|
|
302
|
+
(_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, 'Error while joining presence');
|
|
269
303
|
}
|
|
270
304
|
});
|
|
271
305
|
/**
|
|
@@ -281,9 +315,9 @@ var ParticipantsService = exports.ParticipantsService = /*#__PURE__*/function ()
|
|
|
281
315
|
_this.sendPresence();
|
|
282
316
|
_this.sendPresenceJoined();
|
|
283
317
|
} catch (error) {
|
|
284
|
-
var _this$
|
|
318
|
+
var _this$analyticsHelper11;
|
|
285
319
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
286
|
-
(_this$
|
|
320
|
+
(_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(error, 'Error while receiving presence');
|
|
287
321
|
}
|
|
288
322
|
});
|
|
289
323
|
/**
|
|
@@ -31,6 +31,8 @@ var _internalErrors = require("../errors/internal-errors");
|
|
|
31
31
|
var _const = require("../helpers/const");
|
|
32
32
|
var _featureFlags = require("../feature-flags");
|
|
33
33
|
var _api = require("../api/api");
|
|
34
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
35
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
34
36
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
35
37
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
36
38
|
var logger = (0, _utils.createLogger)('Provider', 'black');
|
|
@@ -149,7 +151,7 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
149
151
|
_this.emit('permission', permit);
|
|
150
152
|
}).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', function (payload) {
|
|
151
153
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
152
|
-
}).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(shouldSkipDocumentInit);
|
|
154
|
+
}).on('participant:activity-join', _this.participantsService.onParticipantActivityJoin).on('participant:activity-ack', _this.participantsService.onParticipantActivityAck).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(shouldSkipDocumentInit);
|
|
153
155
|
});
|
|
154
156
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setUserId", function (id) {
|
|
155
157
|
_this.userId = id;
|
|
@@ -419,17 +421,21 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
419
421
|
}, {
|
|
420
422
|
key: "sendMessage",
|
|
421
423
|
value: function sendMessage(data) {
|
|
424
|
+
var basePayload = {
|
|
425
|
+
userId: this.userId,
|
|
426
|
+
sessionId: this.sessionId,
|
|
427
|
+
clientId: this.clientId,
|
|
428
|
+
permit: this.permit
|
|
429
|
+
};
|
|
422
430
|
try {
|
|
423
431
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'telepointer') {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
};
|
|
431
|
-
var callback = (0, _telepointersHelper.telepointerCallback)(this.config.documentAri);
|
|
432
|
-
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
432
|
+
this.channel.broadcast('participant:telepointer', _objectSpread(_objectSpread({}, basePayload), {}, {
|
|
433
|
+
selection: data.selection
|
|
434
|
+
}), (0, _telepointersHelper.telepointerCallback)(this.config.documentAri));
|
|
435
|
+
} else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
|
|
436
|
+
this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', _objectSpread(_objectSpread({}, basePayload), {}, {
|
|
437
|
+
activity: data.activity
|
|
438
|
+
}), activityCallback());
|
|
433
439
|
}
|
|
434
440
|
} catch (error) {
|
|
435
441
|
var _this$analyticsHelper11;
|
|
@@ -547,4 +553,20 @@ var Provider = exports.Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
547
553
|
}
|
|
548
554
|
}]);
|
|
549
555
|
return Provider;
|
|
550
|
-
}(_emitter.Emitter);
|
|
556
|
+
}(_emitter.Emitter);
|
|
557
|
+
/**
|
|
558
|
+
* Callback for handling the broadcast response of participant activity.
|
|
559
|
+
* This example assumes a simple logging mechanism. It could be expanded to handle errors or other responses.
|
|
560
|
+
*
|
|
561
|
+
* @param activity The activity that was broadcast.
|
|
562
|
+
* @returns A function that handles the response from the broadcast operation.
|
|
563
|
+
*/
|
|
564
|
+
function activityCallback() {
|
|
565
|
+
return function (error) {
|
|
566
|
+
if (error) {
|
|
567
|
+
// Log or handle the error. This could involve retrying the broadcast or notifying the user.
|
|
568
|
+
logger('Error broadcasting participant activity:', error);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
};
|
|
572
|
+
}
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/collab-provider";
|
|
8
|
-
var version = exports.version = "9.
|
|
8
|
+
var version = exports.version = "9.31.0";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
package/dist/es2019/channel.js
CHANGED
|
@@ -426,6 +426,16 @@ export class Channel extends Emitter {
|
|
|
426
426
|
...data
|
|
427
427
|
});
|
|
428
428
|
});
|
|
429
|
+
this.socket.on('participant:activity-ack', ({
|
|
430
|
+
data
|
|
431
|
+
}) => {
|
|
432
|
+
this.emit('participant:activity-ack', data);
|
|
433
|
+
});
|
|
434
|
+
this.socket.on('participant:activity-join', ({
|
|
435
|
+
data
|
|
436
|
+
}) => {
|
|
437
|
+
this.emit('participant:activity-join', data);
|
|
438
|
+
});
|
|
429
439
|
this.socket.on('presence:joined', data => {
|
|
430
440
|
this.emit('presence:joined', data);
|
|
431
441
|
});
|
|
@@ -199,6 +199,40 @@ export class ParticipantsService {
|
|
|
199
199
|
(_this$analyticsHelper7 = this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(error, 'Error while sending presence');
|
|
200
200
|
}
|
|
201
201
|
});
|
|
202
|
+
/**
|
|
203
|
+
* sending new joiner's activity to existing participants
|
|
204
|
+
*/
|
|
205
|
+
_defineProperty(this, "onParticipantActivityJoin", payload => {
|
|
206
|
+
try {
|
|
207
|
+
logger('New participant joined: ', payload.activity);
|
|
208
|
+
const data = {
|
|
209
|
+
userId: payload.userId,
|
|
210
|
+
activity: payload.activity
|
|
211
|
+
};
|
|
212
|
+
this.emit('activity:join', data);
|
|
213
|
+
} catch (error) {
|
|
214
|
+
var _this$analyticsHelper8;
|
|
215
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
216
|
+
(_this$analyticsHelper8 = this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 ? void 0 : _this$analyticsHelper8.sendErrorEvent(error, `Error while sending 'activity:join'`);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
/**
|
|
220
|
+
* respond to new joiner with existing participant's activity
|
|
221
|
+
*/
|
|
222
|
+
_defineProperty(this, "onParticipantActivityAck", payload => {
|
|
223
|
+
try {
|
|
224
|
+
logger('Existing participants ack: ', payload.activity);
|
|
225
|
+
const data = {
|
|
226
|
+
activity: payload.activity,
|
|
227
|
+
userId: this.getPresenceData().userId
|
|
228
|
+
};
|
|
229
|
+
this.emit('activity:ack', data);
|
|
230
|
+
} catch (error) {
|
|
231
|
+
var _this$analyticsHelper9;
|
|
232
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
233
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(error, `Error while sending 'activity:ack'`);
|
|
234
|
+
}
|
|
235
|
+
});
|
|
202
236
|
/**
|
|
203
237
|
* Called when a participant joins the session.
|
|
204
238
|
*
|
|
@@ -212,9 +246,9 @@ export class ParticipantsService {
|
|
|
212
246
|
// This expose existing users to the newly joined user
|
|
213
247
|
this.sendPresence();
|
|
214
248
|
} catch (error) {
|
|
215
|
-
var _this$
|
|
249
|
+
var _this$analyticsHelper10;
|
|
216
250
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
217
|
-
(_this$
|
|
251
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while joining presence');
|
|
218
252
|
}
|
|
219
253
|
});
|
|
220
254
|
/**
|
|
@@ -230,9 +264,9 @@ export class ParticipantsService {
|
|
|
230
264
|
this.sendPresence();
|
|
231
265
|
this.sendPresenceJoined();
|
|
232
266
|
} catch (error) {
|
|
233
|
-
var _this$
|
|
267
|
+
var _this$analyticsHelper11;
|
|
234
268
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
235
|
-
(_this$
|
|
269
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while receiving presence');
|
|
236
270
|
}
|
|
237
271
|
});
|
|
238
272
|
/**
|
|
@@ -127,7 +127,7 @@ export class Provider extends Emitter {
|
|
|
127
127
|
}).on('restore', this.documentService.onRestore).on('permission', permit => {
|
|
128
128
|
this.permit = Object.assign(this.permit, permit);
|
|
129
129
|
this.emit('permission', permit);
|
|
130
|
-
}).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(shouldSkipDocumentInit);
|
|
130
|
+
}).on('steps:added', this.documentService.onStepsAdded).on('metadata:changed', this.metadataService.onMetadataChanged).on('participant:telepointer', payload => this.participantsService.onParticipantTelepointer(payload, this.sessionId)).on('participant:activity-join', this.participantsService.onParticipantActivityJoin).on('participant:activity-ack', this.participantsService.onParticipantActivityAck).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(shouldSkipDocumentInit);
|
|
131
131
|
});
|
|
132
132
|
_defineProperty(this, "setUserId", id => {
|
|
133
133
|
this.userId = id;
|
|
@@ -358,17 +358,23 @@ export class Provider extends Emitter {
|
|
|
358
358
|
* @param {string} data.sessionId Identifier identifying the session
|
|
359
359
|
*/
|
|
360
360
|
sendMessage(data) {
|
|
361
|
+
const basePayload = {
|
|
362
|
+
userId: this.userId,
|
|
363
|
+
sessionId: this.sessionId,
|
|
364
|
+
clientId: this.clientId,
|
|
365
|
+
permit: this.permit
|
|
366
|
+
};
|
|
361
367
|
try {
|
|
362
368
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'telepointer') {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
369
|
+
this.channel.broadcast('participant:telepointer', {
|
|
370
|
+
...basePayload,
|
|
371
|
+
selection: data.selection
|
|
372
|
+
}, telepointerCallback(this.config.documentAri));
|
|
373
|
+
} else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
|
|
374
|
+
this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', {
|
|
375
|
+
...basePayload,
|
|
376
|
+
activity: data.activity
|
|
377
|
+
}, activityCallback());
|
|
372
378
|
}
|
|
373
379
|
} catch (error) {
|
|
374
380
|
var _this$analyticsHelper11;
|
|
@@ -471,4 +477,21 @@ export class Provider extends Emitter {
|
|
|
471
477
|
throw new SetMetadataError('Error while setting metadata', error);
|
|
472
478
|
}
|
|
473
479
|
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* Callback for handling the broadcast response of participant activity.
|
|
484
|
+
* This example assumes a simple logging mechanism. It could be expanded to handle errors or other responses.
|
|
485
|
+
*
|
|
486
|
+
* @param activity The activity that was broadcast.
|
|
487
|
+
* @returns A function that handles the response from the broadcast operation.
|
|
488
|
+
*/
|
|
489
|
+
function activityCallback() {
|
|
490
|
+
return error => {
|
|
491
|
+
if (error) {
|
|
492
|
+
// Log or handle the error. This could involve retrying the broadcast or notifying the user.
|
|
493
|
+
logger('Error broadcasting participant activity:', error);
|
|
494
|
+
return;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
474
497
|
}
|
package/dist/esm/channel.js
CHANGED
|
@@ -611,6 +611,14 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
611
611
|
timestamp: timestamp
|
|
612
612
|
}, data));
|
|
613
613
|
});
|
|
614
|
+
this.socket.on('participant:activity-ack', function (_ref8) {
|
|
615
|
+
var data = _ref8.data;
|
|
616
|
+
_this2.emit('participant:activity-ack', data);
|
|
617
|
+
});
|
|
618
|
+
this.socket.on('participant:activity-join', function (_ref9) {
|
|
619
|
+
var data = _ref9.data;
|
|
620
|
+
_this2.emit('participant:activity-join', data);
|
|
621
|
+
});
|
|
614
622
|
this.socket.on('presence:joined', function (data) {
|
|
615
623
|
_this2.emit('presence:joined', data);
|
|
616
624
|
});
|
|
@@ -620,11 +628,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
620
628
|
this.socket.on('participant:left', function (data) {
|
|
621
629
|
_this2.emit('participant:left', data);
|
|
622
630
|
});
|
|
623
|
-
this.socket.on('participant:updated', function (
|
|
624
|
-
var sessionId =
|
|
625
|
-
timestamp =
|
|
626
|
-
data =
|
|
627
|
-
clientId =
|
|
631
|
+
this.socket.on('participant:updated', function (_ref10) {
|
|
632
|
+
var sessionId = _ref10.sessionId,
|
|
633
|
+
timestamp = _ref10.timestamp,
|
|
634
|
+
data = _ref10.data,
|
|
635
|
+
clientId = _ref10.clientId;
|
|
628
636
|
_this2.emit('participant:updated', _objectSpread({
|
|
629
637
|
sessionId: sessionId,
|
|
630
638
|
timestamp: timestamp,
|
|
@@ -640,7 +648,7 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
640
648
|
_this2.emit('status', data);
|
|
641
649
|
});
|
|
642
650
|
this.socket.on('disconnect', /*#__PURE__*/function () {
|
|
643
|
-
var
|
|
651
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(reason) {
|
|
644
652
|
var _this2$analyticsHelpe, reconnectionError;
|
|
645
653
|
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
646
654
|
while (1) switch (_context7.prev = _context7.next) {
|
|
@@ -673,7 +681,7 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
673
681
|
}, _callee7);
|
|
674
682
|
}));
|
|
675
683
|
return function (_x10) {
|
|
676
|
-
return
|
|
684
|
+
return _ref11.apply(this, arguments);
|
|
677
685
|
};
|
|
678
686
|
}());
|
|
679
687
|
|
|
@@ -243,6 +243,40 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
243
243
|
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(error, 'Error while sending presence');
|
|
244
244
|
}
|
|
245
245
|
});
|
|
246
|
+
/**
|
|
247
|
+
* sending new joiner's activity to existing participants
|
|
248
|
+
*/
|
|
249
|
+
_defineProperty(this, "onParticipantActivityJoin", function (payload) {
|
|
250
|
+
try {
|
|
251
|
+
logger('New participant joined: ', payload.activity);
|
|
252
|
+
var _data2 = {
|
|
253
|
+
userId: payload.userId,
|
|
254
|
+
activity: payload.activity
|
|
255
|
+
};
|
|
256
|
+
_this.emit('activity:join', _data2);
|
|
257
|
+
} catch (error) {
|
|
258
|
+
var _this$analyticsHelper8;
|
|
259
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
260
|
+
(_this$analyticsHelper8 = _this.analyticsHelper) === null || _this$analyticsHelper8 === void 0 || _this$analyticsHelper8.sendErrorEvent(error, "Error while sending 'activity:join'");
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
/**
|
|
264
|
+
* respond to new joiner with existing participant's activity
|
|
265
|
+
*/
|
|
266
|
+
_defineProperty(this, "onParticipantActivityAck", function (payload) {
|
|
267
|
+
try {
|
|
268
|
+
logger('Existing participants ack: ', payload.activity);
|
|
269
|
+
var _data3 = {
|
|
270
|
+
activity: payload.activity,
|
|
271
|
+
userId: _this.getPresenceData().userId
|
|
272
|
+
};
|
|
273
|
+
_this.emit('activity:ack', _data3);
|
|
274
|
+
} catch (error) {
|
|
275
|
+
var _this$analyticsHelper9;
|
|
276
|
+
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
277
|
+
(_this$analyticsHelper9 = _this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 || _this$analyticsHelper9.sendErrorEvent(error, "Error while sending 'activity:ack'");
|
|
278
|
+
}
|
|
279
|
+
});
|
|
246
280
|
/**
|
|
247
281
|
* Called when a participant joins the session.
|
|
248
282
|
*
|
|
@@ -256,9 +290,9 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
256
290
|
// This expose existing users to the newly joined user
|
|
257
291
|
_this.sendPresence();
|
|
258
292
|
} catch (error) {
|
|
259
|
-
var _this$
|
|
293
|
+
var _this$analyticsHelper10;
|
|
260
294
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
261
|
-
(_this$
|
|
295
|
+
(_this$analyticsHelper10 = _this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 || _this$analyticsHelper10.sendErrorEvent(error, 'Error while joining presence');
|
|
262
296
|
}
|
|
263
297
|
});
|
|
264
298
|
/**
|
|
@@ -274,9 +308,9 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
274
308
|
_this.sendPresence();
|
|
275
309
|
_this.sendPresenceJoined();
|
|
276
310
|
} catch (error) {
|
|
277
|
-
var _this$
|
|
311
|
+
var _this$analyticsHelper11;
|
|
278
312
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
279
|
-
(_this$
|
|
313
|
+
(_this$analyticsHelper11 = _this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 || _this$analyticsHelper11.sendErrorEvent(error, 'Error while receiving presence');
|
|
280
314
|
}
|
|
281
315
|
});
|
|
282
316
|
/**
|
|
@@ -7,6 +7,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
12
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
14
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
@@ -142,7 +144,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
142
144
|
_this.emit('permission', permit);
|
|
143
145
|
}).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', function (payload) {
|
|
144
146
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
145
|
-
}).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(shouldSkipDocumentInit);
|
|
147
|
+
}).on('participant:activity-join', _this.participantsService.onParticipantActivityJoin).on('participant:activity-ack', _this.participantsService.onParticipantActivityAck).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(shouldSkipDocumentInit);
|
|
146
148
|
});
|
|
147
149
|
_defineProperty(_assertThisInitialized(_this), "setUserId", function (id) {
|
|
148
150
|
_this.userId = id;
|
|
@@ -412,17 +414,21 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
412
414
|
}, {
|
|
413
415
|
key: "sendMessage",
|
|
414
416
|
value: function sendMessage(data) {
|
|
417
|
+
var basePayload = {
|
|
418
|
+
userId: this.userId,
|
|
419
|
+
sessionId: this.sessionId,
|
|
420
|
+
clientId: this.clientId,
|
|
421
|
+
permit: this.permit
|
|
422
|
+
};
|
|
415
423
|
try {
|
|
416
424
|
if ((data === null || data === void 0 ? void 0 : data.type) === 'telepointer') {
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
};
|
|
424
|
-
var callback = telepointerCallback(this.config.documentAri);
|
|
425
|
-
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
425
|
+
this.channel.broadcast('participant:telepointer', _objectSpread(_objectSpread({}, basePayload), {}, {
|
|
426
|
+
selection: data.selection
|
|
427
|
+
}), telepointerCallback(this.config.documentAri));
|
|
428
|
+
} else if ((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' || (data === null || data === void 0 ? void 0 : data.type) === 'activity:ack') {
|
|
429
|
+
this.channel.broadcast((data === null || data === void 0 ? void 0 : data.type) === 'activity:join' ? 'participant:activity-join' : 'participant:activity-ack', _objectSpread(_objectSpread({}, basePayload), {}, {
|
|
430
|
+
activity: data.activity
|
|
431
|
+
}), activityCallback());
|
|
426
432
|
}
|
|
427
433
|
} catch (error) {
|
|
428
434
|
var _this$analyticsHelper11;
|
|
@@ -540,4 +546,21 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
540
546
|
}
|
|
541
547
|
}]);
|
|
542
548
|
return Provider;
|
|
543
|
-
}(Emitter);
|
|
549
|
+
}(Emitter);
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Callback for handling the broadcast response of participant activity.
|
|
553
|
+
* This example assumes a simple logging mechanism. It could be expanded to handle errors or other responses.
|
|
554
|
+
*
|
|
555
|
+
* @param activity The activity that was broadcast.
|
|
556
|
+
* @returns A function that handles the response from the broadcast operation.
|
|
557
|
+
*/
|
|
558
|
+
function activityCallback() {
|
|
559
|
+
return function (error) {
|
|
560
|
+
if (error) {
|
|
561
|
+
// Log or handle the error. This could involve retrying the broadcast or notifying the user.
|
|
562
|
+
logger('Error broadcasting participant activity:', error);
|
|
563
|
+
return;
|
|
564
|
+
}
|
|
565
|
+
};
|
|
566
|
+
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
2
|
export type { CollabEventDisconnectedData, Socket } from './types';
|
|
3
|
-
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, } from '@atlaskit/editor-common/collab';
|
|
3
|
+
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabActivityJoinPayload, CollabActivityAckPayload, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, } from '@atlaskit/editor-common/collab';
|
|
4
4
|
export { PROVIDER_ERROR_CODE } from '@atlaskit/editor-common/collab';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload } from '../types';
|
|
3
|
-
import type { CollabEventPresenceData, CollabTelepointerPayload, ProviderParticipant, StepJson } from '@atlaskit/editor-common/collab';
|
|
2
|
+
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload, ActivityPayload } from '../types';
|
|
3
|
+
import type { CollabActivityData, CollabEventPresenceData, CollabTelepointerPayload, ProviderParticipant, StepJson } from '@atlaskit/editor-common/collab';
|
|
4
4
|
import type { GetUserType } from './participants-helper';
|
|
5
5
|
import { ParticipantsState } from './participants-state';
|
|
6
6
|
/**
|
|
@@ -23,7 +23,7 @@ export declare class ParticipantsService {
|
|
|
23
23
|
private setUserId;
|
|
24
24
|
private participantUpdateTimeout;
|
|
25
25
|
private presenceUpdateTimeout;
|
|
26
|
-
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);
|
|
26
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected' | 'activity:join' | 'activity:ack', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData | CollabActivityData) => 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);
|
|
27
27
|
/**
|
|
28
28
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
29
29
|
* @param payload Payload from incoming socket event
|
|
@@ -78,6 +78,14 @@ export declare class ParticipantsService {
|
|
|
78
78
|
*/
|
|
79
79
|
clearTimers: () => void;
|
|
80
80
|
private sendPresence;
|
|
81
|
+
/**
|
|
82
|
+
* sending new joiner's activity to existing participants
|
|
83
|
+
*/
|
|
84
|
+
onParticipantActivityJoin: (payload: ActivityPayload) => void;
|
|
85
|
+
/**
|
|
86
|
+
* respond to new joiner with existing participant's activity
|
|
87
|
+
*/
|
|
88
|
+
onParticipantActivityAck: (payload: ActivityPayload) => void;
|
|
81
89
|
/**
|
|
82
90
|
* Called when a participant joins the session.
|
|
83
91
|
*
|
|
@@ -2,7 +2,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
|
|
|
2
2
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { Emitter } from '../emitter';
|
|
4
4
|
import type { Config } from '../types';
|
|
5
|
-
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, ResolvedEditorState, Metadata, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
5
|
+
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, ResolvedEditorState, Metadata, SyncUpErrorFunction, CollabActivityJoinPayload, CollabActivityAckPayload } from '@atlaskit/editor-common/collab';
|
|
6
6
|
import { Api } from '../api/api';
|
|
7
7
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
8
|
export declare const MAX_STEP_REJECTED_ERROR_AGGRESSIVE = 2;
|
|
@@ -86,7 +86,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
86
86
|
* @param {CollabSendableSelection} data.selection Object representing the selected element
|
|
87
87
|
* @param {string} data.sessionId Identifier identifying the session
|
|
88
88
|
*/
|
|
89
|
-
sendMessage(data: CollabTelepointerPayload): void;
|
|
89
|
+
sendMessage(data: CollabTelepointerPayload | CollabActivityJoinPayload | CollabActivityAckPayload): void;
|
|
90
90
|
private onDisconnected;
|
|
91
91
|
/**
|
|
92
92
|
* "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
package/dist/types/types.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type { InternalError } from './errors/internal-errors';
|
|
|
5
5
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
6
6
|
import type { GetUserType } from './participants/participants-helper';
|
|
7
7
|
import type AnalyticsHelper from './analytics/analytics-helper';
|
|
8
|
-
import type { CollabInitPayload, StepJson, CollabSendableSelection, Metadata, UserPermitType } from '@atlaskit/editor-common/collab';
|
|
8
|
+
import type { CollabInitPayload, StepJson, CollabSendableSelection, Metadata, UserPermitType, Activity } from '@atlaskit/editor-common/collab';
|
|
9
9
|
export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventPresenceData, ResolvedEditorState, CollabConnectedPayload, CollabConnectingPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabCommitStatusEventPayload, CollabPermissionEventPayload, UserPermitType, CollabEvents, Metadata, StepJson, CollabEventTelepointerData, CollabSendableSelection, CollabEditProvider, NewCollabSyncUpErrorAttributes, SyncUpErrorFunction, CollabEventLocalStepData, } from '@atlaskit/editor-common/collab';
|
|
10
10
|
export interface CollabEventDisconnectedData {
|
|
11
11
|
sid: string;
|
|
@@ -115,7 +115,7 @@ export type InitPayload = {
|
|
|
115
115
|
export type BroadcastIncomingPayload = {
|
|
116
116
|
sessionId?: string;
|
|
117
117
|
timestamp?: number;
|
|
118
|
-
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
118
|
+
data: PresencePayload | TelepointerPayload | StepsPayload | ActivityPayload | any;
|
|
119
119
|
};
|
|
120
120
|
export type PresenceData = {
|
|
121
121
|
sessionId: string;
|
|
@@ -126,6 +126,10 @@ export type PresenceData = {
|
|
|
126
126
|
export type PresencePayload = PresenceData & {
|
|
127
127
|
timestamp: number;
|
|
128
128
|
};
|
|
129
|
+
export type ActivityPayload = {
|
|
130
|
+
userId: string | undefined;
|
|
131
|
+
activity: Activity;
|
|
132
|
+
};
|
|
129
133
|
export type TelepointerPayload = PresencePayload & {
|
|
130
134
|
selection: CollabSendableSelection;
|
|
131
135
|
};
|
|
@@ -166,6 +170,8 @@ export type ChannelEvent = {
|
|
|
166
170
|
'presence:joined': PresencePayload;
|
|
167
171
|
presence: PresencePayload;
|
|
168
172
|
'participant:left': PresencePayload;
|
|
173
|
+
'participant:activity-join': ActivityPayload;
|
|
174
|
+
'participant:activity-ack': ActivityPayload;
|
|
169
175
|
'participant:telepointer': TelepointerPayload;
|
|
170
176
|
'participant:updated': PresencePayload;
|
|
171
177
|
'steps:commit': StepsPayload & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
2
|
export type { CollabEventDisconnectedData, Socket } from './types';
|
|
3
|
-
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, } from '@atlaskit/editor-common/collab';
|
|
3
|
+
export type { NewCollabSyncUpErrorAttributes, ResolvedEditorState, CollabMetadataPayload, CollabEventInitData, CollabInitPayload, CollabEventConnectionData, CollabConnectedPayload, CollabDisconnectedPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabLocalStepsPayload, CollabPermissionEventPayload, CollabEventRemoteData, CollabEventPresenceData, CollabActivityJoinPayload, CollabActivityAckPayload, CollabEventConnectingData, CollabEventTelepointerData, CollabSendableSelection, CollabParticipant, CollabEvents, SyncUpErrorFunction, CollabEditProvider, ProviderError, ProviderParticipant, CollabEventLocalStepData, UserPermitType, } from '@atlaskit/editor-common/collab';
|
|
4
4
|
export { PROVIDER_ERROR_CODE } from '@atlaskit/editor-common/collab';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type AnalyticsHelper from '../analytics/analytics-helper';
|
|
2
|
-
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload } from '../types';
|
|
3
|
-
import type { CollabEventPresenceData, CollabTelepointerPayload, ProviderParticipant, StepJson } from '@atlaskit/editor-common/collab';
|
|
2
|
+
import type { CollabEventDisconnectedData, ChannelEvent, PresenceData, PresencePayload, TelepointerPayload, ActivityPayload } from '../types';
|
|
3
|
+
import type { CollabActivityData, CollabEventPresenceData, CollabTelepointerPayload, ProviderParticipant, StepJson } from '@atlaskit/editor-common/collab';
|
|
4
4
|
import type { GetUserType } from './participants-helper';
|
|
5
5
|
import { ParticipantsState } from './participants-state';
|
|
6
6
|
/**
|
|
@@ -23,7 +23,7 @@ export declare class ParticipantsService {
|
|
|
23
23
|
private setUserId;
|
|
24
24
|
private participantUpdateTimeout;
|
|
25
25
|
private presenceUpdateTimeout;
|
|
26
|
-
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);
|
|
26
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected' | 'activity:join' | 'activity:ack', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData | CollabActivityData) => 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);
|
|
27
27
|
/**
|
|
28
28
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
29
29
|
* @param payload Payload from incoming socket event
|
|
@@ -78,6 +78,14 @@ export declare class ParticipantsService {
|
|
|
78
78
|
*/
|
|
79
79
|
clearTimers: () => void;
|
|
80
80
|
private sendPresence;
|
|
81
|
+
/**
|
|
82
|
+
* sending new joiner's activity to existing participants
|
|
83
|
+
*/
|
|
84
|
+
onParticipantActivityJoin: (payload: ActivityPayload) => void;
|
|
85
|
+
/**
|
|
86
|
+
* respond to new joiner with existing participant's activity
|
|
87
|
+
*/
|
|
88
|
+
onParticipantActivityAck: (payload: ActivityPayload) => void;
|
|
81
89
|
/**
|
|
82
90
|
* Called when a participant joins the session.
|
|
83
91
|
*
|
|
@@ -2,7 +2,7 @@ import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/stat
|
|
|
2
2
|
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
3
|
import { Emitter } from '../emitter';
|
|
4
4
|
import type { Config } from '../types';
|
|
5
|
-
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, ResolvedEditorState, Metadata, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
5
|
+
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, ResolvedEditorState, Metadata, SyncUpErrorFunction, CollabActivityJoinPayload, CollabActivityAckPayload } from '@atlaskit/editor-common/collab';
|
|
6
6
|
import { Api } from '../api/api';
|
|
7
7
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
8
|
export declare const MAX_STEP_REJECTED_ERROR_AGGRESSIVE = 2;
|
|
@@ -86,7 +86,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
86
86
|
* @param {CollabSendableSelection} data.selection Object representing the selected element
|
|
87
87
|
* @param {string} data.sessionId Identifier identifying the session
|
|
88
88
|
*/
|
|
89
|
-
sendMessage(data: CollabTelepointerPayload): void;
|
|
89
|
+
sendMessage(data: CollabTelepointerPayload | CollabActivityJoinPayload | CollabActivityAckPayload): void;
|
|
90
90
|
private onDisconnected;
|
|
91
91
|
/**
|
|
92
92
|
* "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
@@ -5,7 +5,7 @@ import type { InternalError } from './errors/internal-errors';
|
|
|
5
5
|
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
6
6
|
import type { GetUserType } from './participants/participants-helper';
|
|
7
7
|
import type AnalyticsHelper from './analytics/analytics-helper';
|
|
8
|
-
import type { CollabInitPayload, StepJson, CollabSendableSelection, Metadata, UserPermitType } from '@atlaskit/editor-common/collab';
|
|
8
|
+
import type { CollabInitPayload, StepJson, CollabSendableSelection, Metadata, UserPermitType, Activity } from '@atlaskit/editor-common/collab';
|
|
9
9
|
export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventPresenceData, ResolvedEditorState, CollabConnectedPayload, CollabConnectingPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabCommitStatusEventPayload, CollabPermissionEventPayload, UserPermitType, CollabEvents, Metadata, StepJson, CollabEventTelepointerData, CollabSendableSelection, CollabEditProvider, NewCollabSyncUpErrorAttributes, SyncUpErrorFunction, CollabEventLocalStepData, } from '@atlaskit/editor-common/collab';
|
|
10
10
|
export interface CollabEventDisconnectedData {
|
|
11
11
|
sid: string;
|
|
@@ -115,7 +115,7 @@ export type InitPayload = {
|
|
|
115
115
|
export type BroadcastIncomingPayload = {
|
|
116
116
|
sessionId?: string;
|
|
117
117
|
timestamp?: number;
|
|
118
|
-
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
118
|
+
data: PresencePayload | TelepointerPayload | StepsPayload | ActivityPayload | any;
|
|
119
119
|
};
|
|
120
120
|
export type PresenceData = {
|
|
121
121
|
sessionId: string;
|
|
@@ -126,6 +126,10 @@ export type PresenceData = {
|
|
|
126
126
|
export type PresencePayload = PresenceData & {
|
|
127
127
|
timestamp: number;
|
|
128
128
|
};
|
|
129
|
+
export type ActivityPayload = {
|
|
130
|
+
userId: string | undefined;
|
|
131
|
+
activity: Activity;
|
|
132
|
+
};
|
|
129
133
|
export type TelepointerPayload = PresencePayload & {
|
|
130
134
|
selection: CollabSendableSelection;
|
|
131
135
|
};
|
|
@@ -166,6 +170,8 @@ export type ChannelEvent = {
|
|
|
166
170
|
'presence:joined': PresencePayload;
|
|
167
171
|
presence: PresencePayload;
|
|
168
172
|
'participant:left': PresencePayload;
|
|
173
|
+
'participant:activity-join': ActivityPayload;
|
|
174
|
+
'participant:activity-ack': ActivityPayload;
|
|
169
175
|
'participant:telepointer': TelepointerPayload;
|
|
170
176
|
'participant:updated': PresencePayload;
|
|
171
177
|
'steps:commit': StepsPayload & {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.31.0",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
41
41
|
"@atlaskit/analytics-listeners": "^8.10.0",
|
|
42
|
-
"@atlaskit/editor-common": "^
|
|
42
|
+
"@atlaskit/editor-common": "^83.1.0",
|
|
43
43
|
"@atlaskit/editor-json-transformer": "^8.14.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "4.0.1",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|