@atlaskit/collab-provider 7.5.1 → 7.6.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 +17 -0
- package/channel/package.json +8 -1
- package/config/package.json +8 -1
- package/disconnected-reason-mapper/package.json +8 -1
- package/dist/cjs/analytics/index.js +2 -1
- package/dist/cjs/channel.js +6 -3
- package/dist/cjs/helpers/const.js +10 -1
- package/dist/cjs/provider/index.js +22 -6
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +2 -1
- package/dist/es2019/channel.js +6 -3
- package/dist/es2019/helpers/const.js +8 -0
- package/dist/es2019/provider/index.js +21 -6
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +3 -2
- package/dist/esm/channel.js +6 -3
- package/dist/esm/helpers/const.js +8 -0
- package/dist/esm/provider/index.js +22 -6
- package/dist/esm/version.json +1 -1
- package/dist/types/helpers/const.d.ts +9 -2
- package/dist/types-ts4.0/analytics/index.d.ts +5 -0
- package/dist/types-ts4.0/analytics/performance.d.ts +12 -0
- package/dist/types-ts4.0/channel.d.ts +27 -0
- package/dist/types-ts4.0/config.d.ts +5 -0
- package/dist/types-ts4.0/disconnected-reason-mapper.d.ts +15 -0
- package/dist/types-ts4.0/emitter.d.ts +19 -0
- package/dist/types-ts4.0/error-code-mapper.d.ts +32 -0
- package/dist/types-ts4.0/helpers/const.d.ts +31 -0
- package/dist/types-ts4.0/helpers/utils.d.ts +11 -0
- package/dist/types-ts4.0/index.d.ts +2 -0
- package/dist/types-ts4.0/provider/catchup.d.ts +9 -0
- package/dist/types-ts4.0/provider/index.d.ts +124 -0
- package/dist/types-ts4.0/socket-io-provider.d.ts +4 -0
- package/dist/types-ts4.0/types.d.ts +170 -0
- package/emitter/package.json +8 -1
- package/error-code-mapper/package.json +8 -1
- package/package.json +14 -7
- package/socket-io-provider/package.json +8 -1
- package/types/package.json +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 7.6.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`8cc2f888c83`](https://bitbucket.org/atlassian/atlassian-frontend/commits/8cc2f888c83) - Upgrade Typescript from `4.3.5` to `4.5.5`
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 7.6.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- [`5bd58e91664`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5bd58e91664) - [ESS-2513] Add tracking for number of participants in analytics
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 7.5.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/channel/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/channel.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/channel.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/channel.d.ts"
|
|
7
|
+
"types": "../dist/types/channel.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/channel.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
package/config/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/config.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/config.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/config.d.ts"
|
|
7
|
+
"types": "../dist/types/config.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/config.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/disconnected-reason-mapper.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/disconnected-reason-mapper.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/disconnected-reason-mapper.d.ts"
|
|
7
|
+
"types": "../dist/types/disconnected-reason-mapper.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/disconnected-reason-mapper.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
|
@@ -43,7 +43,8 @@ var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(analytics
|
|
|
43
43
|
actionSubject: _const.EVENT_SUBJECT,
|
|
44
44
|
source: 'unknown',
|
|
45
45
|
attributes: _objectSpread({
|
|
46
|
-
packageName: _const.ATTRIBUTES_PACKAGE
|
|
46
|
+
packageName: _const.ATTRIBUTES_PACKAGE,
|
|
47
|
+
collabService: _const.COLLAB_SERVICE.NCS
|
|
47
48
|
}, analyticsEvent.attributes)
|
|
48
49
|
};
|
|
49
50
|
fireAnalyticsEvent(analyticsClient, payload);
|
package/dist/cjs/channel.js
CHANGED
|
@@ -79,7 +79,8 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
79
79
|
eventAction: _const.EVENT_ACTION.CONNECTION,
|
|
80
80
|
attributes: {
|
|
81
81
|
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
82
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
82
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
83
|
+
documentAri: _this.config.documentAri
|
|
83
84
|
}
|
|
84
85
|
}, _this.analyticsClient);
|
|
85
86
|
|
|
@@ -100,7 +101,8 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
100
101
|
attributes: {
|
|
101
102
|
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
102
103
|
// TODO: detect when document init fails and fire corresponding event for it
|
|
103
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
104
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
105
|
+
documentAri: _this.config.documentAri
|
|
104
106
|
}
|
|
105
107
|
}, _this.analyticsClient);
|
|
106
108
|
var doc = data.doc,
|
|
@@ -257,7 +259,8 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
257
259
|
attributes: {
|
|
258
260
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
259
261
|
error: error,
|
|
260
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
262
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
263
|
+
documentAri: _this2.config.documentAri
|
|
261
264
|
}
|
|
262
265
|
}, _this2.analyticsClient); // If error received with `data`, it means the connection is rejected
|
|
263
266
|
// by the server on purpose for example no permission, so no need to
|
|
@@ -3,11 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
|
|
6
|
+
exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.ATTRIBUTES_PACKAGE = exports.ACK_MAX_TRY = void 0;
|
|
7
7
|
var ATTRIBUTES_PACKAGE = 'collabProvider';
|
|
8
8
|
exports.ATTRIBUTES_PACKAGE = ATTRIBUTES_PACKAGE;
|
|
9
9
|
var EVENT_SUBJECT = 'collab';
|
|
10
10
|
exports.EVENT_SUBJECT = EVENT_SUBJECT;
|
|
11
|
+
var COLLAB_SERVICE;
|
|
12
|
+
exports.COLLAB_SERVICE = COLLAB_SERVICE;
|
|
13
|
+
|
|
14
|
+
(function (COLLAB_SERVICE) {
|
|
15
|
+
COLLAB_SERVICE["NCS"] = "ncs";
|
|
16
|
+
COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
|
|
17
|
+
})(COLLAB_SERVICE || (exports.COLLAB_SERVICE = COLLAB_SERVICE = {}));
|
|
18
|
+
|
|
11
19
|
var EVENT_ACTION;
|
|
12
20
|
exports.EVENT_ACTION = EVENT_ACTION;
|
|
13
21
|
|
|
@@ -17,6 +25,7 @@ exports.EVENT_ACTION = EVENT_ACTION;
|
|
|
17
25
|
EVENT_ACTION["DOCUMENT_INIT"] = "documentInit";
|
|
18
26
|
EVENT_ACTION["ADD_STEPS"] = "addSteps";
|
|
19
27
|
EVENT_ACTION["CONVERT_PM_TO_ADF"] = "convertPMToADF";
|
|
28
|
+
EVENT_ACTION["UPDATE_PARTICIPANTS"] = "updateParticipants";
|
|
20
29
|
})(EVENT_ACTION || (exports.EVENT_ACTION = EVENT_ACTION = {}));
|
|
21
30
|
|
|
22
31
|
var EVENT_STATUS;
|
|
@@ -263,7 +263,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
263
263
|
eventAction: _const.EVENT_ACTION.CATCHUP,
|
|
264
264
|
attributes: {
|
|
265
265
|
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
266
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
266
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
267
|
+
documentAri: _this.config.documentAri
|
|
267
268
|
}
|
|
268
269
|
}, _this.analyticsClient);
|
|
269
270
|
_context.next = 17;
|
|
@@ -278,7 +279,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
278
279
|
attributes: {
|
|
279
280
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
280
281
|
error: _context.t0,
|
|
281
|
-
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
282
|
+
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration,
|
|
283
|
+
documentAri: _this.config.documentAri
|
|
282
284
|
}
|
|
283
285
|
}, _this.analyticsClient);
|
|
284
286
|
logger("Catch-Up Failed:", _context.t0.message);
|
|
@@ -308,7 +310,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
308
310
|
eventAction: _const.EVENT_ACTION.ADD_STEPS,
|
|
309
311
|
attributes: {
|
|
310
312
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
311
|
-
error: error
|
|
313
|
+
error: error,
|
|
314
|
+
documentAri: _this.config.documentAri
|
|
312
315
|
}
|
|
313
316
|
}, _this.analyticsClient);
|
|
314
317
|
_this.stepRejectCounter++;
|
|
@@ -515,6 +518,16 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
515
518
|
});
|
|
516
519
|
|
|
517
520
|
if (joined.length || left.length) {
|
|
521
|
+
var _this$participants$si;
|
|
522
|
+
|
|
523
|
+
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
524
|
+
eventAction: _const.EVENT_ACTION.UPDATE_PARTICIPANTS,
|
|
525
|
+
attributes: {
|
|
526
|
+
participants: (_this$participants$si = _this.participants.size) !== null && _this$participants$si !== void 0 ? _this$participants$si : 1,
|
|
527
|
+
documentAri: _this.config.documentAri
|
|
528
|
+
}
|
|
529
|
+
}, _this.analyticsClient);
|
|
530
|
+
|
|
518
531
|
_this.emit('presence', _objectSpread(_objectSpread({}, joined.length ? {
|
|
519
532
|
joined: joined
|
|
520
533
|
} : {}), left.length ? {
|
|
@@ -663,7 +676,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
663
676
|
eventAction: _const.EVENT_ACTION.CONVERT_PM_TO_ADF,
|
|
664
677
|
attributes: {
|
|
665
678
|
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
666
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
679
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
680
|
+
documentAri: _this.config.documentAri
|
|
667
681
|
}
|
|
668
682
|
}, _this.analyticsClient);
|
|
669
683
|
} catch (error) {
|
|
@@ -673,7 +687,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
673
687
|
attributes: {
|
|
674
688
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
675
689
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration,
|
|
676
|
-
error: error
|
|
690
|
+
error: error,
|
|
691
|
+
documentAri: _this.config.documentAri
|
|
677
692
|
}
|
|
678
693
|
}, _this.analyticsClient);
|
|
679
694
|
logger("Error when converting PM document to ADF: ", error);
|
|
@@ -843,7 +858,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
843
858
|
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
844
859
|
eventAction: _const.EVENT_ACTION.ADD_STEPS,
|
|
845
860
|
attributes: {
|
|
846
|
-
eventStatus: _const.EVENT_STATUS.SUCCESS
|
|
861
|
+
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
862
|
+
documentAri: this.config.documentAri
|
|
847
863
|
}
|
|
848
864
|
}, this.analyticsClient);
|
|
849
865
|
this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT } from '../helpers/const';
|
|
1
|
+
import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT, COLLAB_SERVICE } from '../helpers/const';
|
|
2
2
|
export const fireAnalyticsEvent = (analyticsClient, payload) => {
|
|
3
3
|
if (!analyticsClient || !payload) {
|
|
4
4
|
return;
|
|
@@ -25,6 +25,7 @@ export const triggerCollabAnalyticsEvent = (analyticsEvent, analyticsClient) =>
|
|
|
25
25
|
source: 'unknown',
|
|
26
26
|
attributes: {
|
|
27
27
|
packageName: ATTRIBUTES_PACKAGE,
|
|
28
|
+
collabService: COLLAB_SERVICE.NCS,
|
|
28
29
|
...analyticsEvent.attributes
|
|
29
30
|
}
|
|
30
31
|
};
|
package/dist/es2019/channel.js
CHANGED
|
@@ -32,7 +32,8 @@ export class Channel extends Emitter {
|
|
|
32
32
|
eventAction: EVENT_ACTION.CONNECTION,
|
|
33
33
|
attributes: {
|
|
34
34
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
35
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
35
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
36
|
+
documentAri: this.config.documentAri
|
|
36
37
|
}
|
|
37
38
|
}, this.analyticsClient);
|
|
38
39
|
this.emit('connected', {
|
|
@@ -53,7 +54,8 @@ export class Channel extends Emitter {
|
|
|
53
54
|
attributes: {
|
|
54
55
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
55
56
|
// TODO: detect when document init fails and fire corresponding event for it
|
|
56
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
57
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
58
|
+
documentAri: this.config.documentAri
|
|
57
59
|
}
|
|
58
60
|
}, this.analyticsClient);
|
|
59
61
|
const {
|
|
@@ -193,7 +195,8 @@ export class Channel extends Emitter {
|
|
|
193
195
|
attributes: {
|
|
194
196
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
195
197
|
error: error,
|
|
196
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
198
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
199
|
+
documentAri: this.config.documentAri
|
|
197
200
|
}
|
|
198
201
|
}, this.analyticsClient); // If error received with `data`, it means the connection is rejected
|
|
199
202
|
// by the server on purpose for example no permission, so no need to
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export const ATTRIBUTES_PACKAGE = 'collabProvider';
|
|
2
2
|
export const EVENT_SUBJECT = 'collab';
|
|
3
|
+
export let COLLAB_SERVICE;
|
|
4
|
+
|
|
5
|
+
(function (COLLAB_SERVICE) {
|
|
6
|
+
COLLAB_SERVICE["NCS"] = "ncs";
|
|
7
|
+
COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
|
|
8
|
+
})(COLLAB_SERVICE || (COLLAB_SERVICE = {}));
|
|
9
|
+
|
|
3
10
|
export let EVENT_ACTION;
|
|
4
11
|
|
|
5
12
|
(function (EVENT_ACTION) {
|
|
@@ -8,6 +15,7 @@ export let EVENT_ACTION;
|
|
|
8
15
|
EVENT_ACTION["DOCUMENT_INIT"] = "documentInit";
|
|
9
16
|
EVENT_ACTION["ADD_STEPS"] = "addSteps";
|
|
10
17
|
EVENT_ACTION["CONVERT_PM_TO_ADF"] = "convertPMToADF";
|
|
18
|
+
EVENT_ACTION["UPDATE_PARTICIPANTS"] = "updateParticipants";
|
|
11
19
|
})(EVENT_ACTION || (EVENT_ACTION = {}));
|
|
12
20
|
|
|
13
21
|
export let EVENT_STATUS;
|
|
@@ -189,7 +189,8 @@ export class Provider extends Emitter {
|
|
|
189
189
|
eventAction: EVENT_ACTION.CATCHUP,
|
|
190
190
|
attributes: {
|
|
191
191
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
192
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
192
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
193
|
+
documentAri: this.config.documentAri
|
|
193
194
|
}
|
|
194
195
|
}, this.analyticsClient);
|
|
195
196
|
} catch (error) {
|
|
@@ -199,7 +200,8 @@ export class Provider extends Emitter {
|
|
|
199
200
|
attributes: {
|
|
200
201
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
201
202
|
error: error,
|
|
202
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
203
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
204
|
+
documentAri: this.config.documentAri
|
|
203
205
|
}
|
|
204
206
|
}, this.analyticsClient);
|
|
205
207
|
logger(`Catch-Up Failed:`, error.message);
|
|
@@ -218,7 +220,8 @@ export class Provider extends Emitter {
|
|
|
218
220
|
eventAction: EVENT_ACTION.ADD_STEPS,
|
|
219
221
|
attributes: {
|
|
220
222
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
221
|
-
error
|
|
223
|
+
error,
|
|
224
|
+
documentAri: this.config.documentAri
|
|
222
225
|
}
|
|
223
226
|
}, this.analyticsClient);
|
|
224
227
|
this.stepRejectCounter++;
|
|
@@ -396,6 +399,15 @@ export class Provider extends Emitter {
|
|
|
396
399
|
left.forEach(p => this.participants.delete(p.sessionId));
|
|
397
400
|
|
|
398
401
|
if (joined.length || left.length) {
|
|
402
|
+
var _this$participants$si;
|
|
403
|
+
|
|
404
|
+
triggerCollabAnalyticsEvent({
|
|
405
|
+
eventAction: EVENT_ACTION.UPDATE_PARTICIPANTS,
|
|
406
|
+
attributes: {
|
|
407
|
+
participants: (_this$participants$si = this.participants.size) !== null && _this$participants$si !== void 0 ? _this$participants$si : 1,
|
|
408
|
+
documentAri: this.config.documentAri
|
|
409
|
+
}
|
|
410
|
+
}, this.analyticsClient);
|
|
399
411
|
this.emit('presence', { ...(joined.length ? {
|
|
400
412
|
joined
|
|
401
413
|
} : {}),
|
|
@@ -505,7 +517,8 @@ export class Provider extends Emitter {
|
|
|
505
517
|
eventAction: EVENT_ACTION.CONVERT_PM_TO_ADF,
|
|
506
518
|
attributes: {
|
|
507
519
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
508
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
520
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
521
|
+
documentAri: this.config.documentAri
|
|
509
522
|
}
|
|
510
523
|
}, this.analyticsClient);
|
|
511
524
|
} catch (error) {
|
|
@@ -515,7 +528,8 @@ export class Provider extends Emitter {
|
|
|
515
528
|
attributes: {
|
|
516
529
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
517
530
|
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
518
|
-
error: error
|
|
531
|
+
error: error,
|
|
532
|
+
documentAri: this.config.documentAri
|
|
519
533
|
}
|
|
520
534
|
}, this.analyticsClient);
|
|
521
535
|
logger(`Error when converting PM document to ADF: `, error);
|
|
@@ -666,7 +680,8 @@ export class Provider extends Emitter {
|
|
|
666
680
|
triggerCollabAnalyticsEvent({
|
|
667
681
|
eventAction: EVENT_ACTION.ADD_STEPS,
|
|
668
682
|
attributes: {
|
|
669
|
-
eventStatus: EVENT_STATUS.SUCCESS
|
|
683
|
+
eventStatus: EVENT_STATUS.SUCCESS,
|
|
684
|
+
documentAri: this.config.documentAri
|
|
670
685
|
}
|
|
671
686
|
}, this.analyticsClient);
|
|
672
687
|
this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
|
package/dist/es2019/version.json
CHANGED
|
@@ -4,7 +4,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
4
4
|
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
|
-
import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT } from '../helpers/const';
|
|
7
|
+
import { ATTRIBUTES_PACKAGE, EVENT_SUBJECT, COLLAB_SERVICE } from '../helpers/const';
|
|
8
8
|
export var fireAnalyticsEvent = function fireAnalyticsEvent(analyticsClient, payload) {
|
|
9
9
|
if (!analyticsClient || !payload) {
|
|
10
10
|
return;
|
|
@@ -30,7 +30,8 @@ export var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(an
|
|
|
30
30
|
actionSubject: EVENT_SUBJECT,
|
|
31
31
|
source: 'unknown',
|
|
32
32
|
attributes: _objectSpread({
|
|
33
|
-
packageName: ATTRIBUTES_PACKAGE
|
|
33
|
+
packageName: ATTRIBUTES_PACKAGE,
|
|
34
|
+
collabService: COLLAB_SERVICE.NCS
|
|
34
35
|
}, analyticsEvent.attributes)
|
|
35
36
|
};
|
|
36
37
|
fireAnalyticsEvent(analyticsClient, payload);
|
package/dist/esm/channel.js
CHANGED
|
@@ -63,7 +63,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
63
63
|
eventAction: EVENT_ACTION.CONNECTION,
|
|
64
64
|
attributes: {
|
|
65
65
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
66
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
66
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
67
|
+
documentAri: _this.config.documentAri
|
|
67
68
|
}
|
|
68
69
|
}, _this.analyticsClient);
|
|
69
70
|
|
|
@@ -85,7 +86,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
85
86
|
attributes: {
|
|
86
87
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
87
88
|
// TODO: detect when document init fails and fire corresponding event for it
|
|
88
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
89
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
90
|
+
documentAri: _this.config.documentAri
|
|
89
91
|
}
|
|
90
92
|
}, _this.analyticsClient);
|
|
91
93
|
var doc = data.doc,
|
|
@@ -243,7 +245,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
243
245
|
attributes: {
|
|
244
246
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
245
247
|
error: error,
|
|
246
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
248
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
249
|
+
documentAri: _this2.config.documentAri
|
|
247
250
|
}
|
|
248
251
|
}, _this2.analyticsClient); // If error received with `data`, it means the connection is rejected
|
|
249
252
|
// by the server on purpose for example no permission, so no need to
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export var ATTRIBUTES_PACKAGE = 'collabProvider';
|
|
2
2
|
export var EVENT_SUBJECT = 'collab';
|
|
3
|
+
export var COLLAB_SERVICE;
|
|
4
|
+
|
|
5
|
+
(function (COLLAB_SERVICE) {
|
|
6
|
+
COLLAB_SERVICE["NCS"] = "ncs";
|
|
7
|
+
COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
|
|
8
|
+
})(COLLAB_SERVICE || (COLLAB_SERVICE = {}));
|
|
9
|
+
|
|
3
10
|
export var EVENT_ACTION;
|
|
4
11
|
|
|
5
12
|
(function (EVENT_ACTION) {
|
|
@@ -8,6 +15,7 @@ export var EVENT_ACTION;
|
|
|
8
15
|
EVENT_ACTION["DOCUMENT_INIT"] = "documentInit";
|
|
9
16
|
EVENT_ACTION["ADD_STEPS"] = "addSteps";
|
|
10
17
|
EVENT_ACTION["CONVERT_PM_TO_ADF"] = "convertPMToADF";
|
|
18
|
+
EVENT_ACTION["UPDATE_PARTICIPANTS"] = "updateParticipants";
|
|
11
19
|
})(EVENT_ACTION || (EVENT_ACTION = {}));
|
|
12
20
|
|
|
13
21
|
export var EVENT_STATUS;
|
|
@@ -239,7 +239,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
239
239
|
eventAction: EVENT_ACTION.CATCHUP,
|
|
240
240
|
attributes: {
|
|
241
241
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
242
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
242
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
243
|
+
documentAri: _this.config.documentAri
|
|
243
244
|
}
|
|
244
245
|
}, _this.analyticsClient);
|
|
245
246
|
_context.next = 17;
|
|
@@ -254,7 +255,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
254
255
|
attributes: {
|
|
255
256
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
256
257
|
error: _context.t0,
|
|
257
|
-
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
258
|
+
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration,
|
|
259
|
+
documentAri: _this.config.documentAri
|
|
258
260
|
}
|
|
259
261
|
}, _this.analyticsClient);
|
|
260
262
|
logger("Catch-Up Failed:", _context.t0.message);
|
|
@@ -285,7 +287,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
285
287
|
eventAction: EVENT_ACTION.ADD_STEPS,
|
|
286
288
|
attributes: {
|
|
287
289
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
288
|
-
error: error
|
|
290
|
+
error: error,
|
|
291
|
+
documentAri: _this.config.documentAri
|
|
289
292
|
}
|
|
290
293
|
}, _this.analyticsClient);
|
|
291
294
|
_this.stepRejectCounter++;
|
|
@@ -502,6 +505,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
502
505
|
});
|
|
503
506
|
|
|
504
507
|
if (joined.length || left.length) {
|
|
508
|
+
var _this$participants$si;
|
|
509
|
+
|
|
510
|
+
triggerCollabAnalyticsEvent({
|
|
511
|
+
eventAction: EVENT_ACTION.UPDATE_PARTICIPANTS,
|
|
512
|
+
attributes: {
|
|
513
|
+
participants: (_this$participants$si = _this.participants.size) !== null && _this$participants$si !== void 0 ? _this$participants$si : 1,
|
|
514
|
+
documentAri: _this.config.documentAri
|
|
515
|
+
}
|
|
516
|
+
}, _this.analyticsClient);
|
|
517
|
+
|
|
505
518
|
_this.emit('presence', _objectSpread(_objectSpread({}, joined.length ? {
|
|
506
519
|
joined: joined
|
|
507
520
|
} : {}), left.length ? {
|
|
@@ -653,7 +666,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
653
666
|
eventAction: EVENT_ACTION.CONVERT_PM_TO_ADF,
|
|
654
667
|
attributes: {
|
|
655
668
|
eventStatus: EVENT_STATUS.SUCCESS,
|
|
656
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
669
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
670
|
+
documentAri: _this.config.documentAri
|
|
657
671
|
}
|
|
658
672
|
}, _this.analyticsClient);
|
|
659
673
|
} catch (error) {
|
|
@@ -663,7 +677,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
663
677
|
attributes: {
|
|
664
678
|
eventStatus: EVENT_STATUS.FAILURE,
|
|
665
679
|
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration,
|
|
666
|
-
error: error
|
|
680
|
+
error: error,
|
|
681
|
+
documentAri: _this.config.documentAri
|
|
667
682
|
}
|
|
668
683
|
}, _this.analyticsClient);
|
|
669
684
|
logger("Error when converting PM document to ADF: ", error);
|
|
@@ -834,7 +849,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
834
849
|
triggerCollabAnalyticsEvent({
|
|
835
850
|
eventAction: EVENT_ACTION.ADD_STEPS,
|
|
836
851
|
attributes: {
|
|
837
|
-
eventStatus: EVENT_STATUS.SUCCESS
|
|
852
|
+
eventStatus: EVENT_STATUS.SUCCESS,
|
|
853
|
+
documentAri: this.config.documentAri
|
|
838
854
|
}
|
|
839
855
|
}, this.analyticsClient);
|
|
840
856
|
this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
|
package/dist/esm/version.json
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { ErrorPayload } from '../types';
|
|
2
2
|
export declare const ATTRIBUTES_PACKAGE = "collabProvider";
|
|
3
3
|
export declare const EVENT_SUBJECT = "collab";
|
|
4
|
+
export declare enum COLLAB_SERVICE {
|
|
5
|
+
NCS = "ncs",
|
|
6
|
+
SYNCHRONY = "synchrony"
|
|
7
|
+
}
|
|
4
8
|
export declare enum EVENT_ACTION {
|
|
5
9
|
CONNECTION = "connection",
|
|
6
10
|
CATCHUP = "catchup",
|
|
7
11
|
DOCUMENT_INIT = "documentInit",
|
|
8
12
|
ADD_STEPS = "addSteps",
|
|
9
|
-
CONVERT_PM_TO_ADF = "convertPMToADF"
|
|
13
|
+
CONVERT_PM_TO_ADF = "convertPMToADF",
|
|
14
|
+
UPDATE_PARTICIPANTS = "updateParticipants"
|
|
10
15
|
}
|
|
11
16
|
export declare enum EVENT_STATUS {
|
|
12
17
|
SUCCESS = "SUCCESS",
|
|
@@ -15,10 +20,12 @@ export declare enum EVENT_STATUS {
|
|
|
15
20
|
export declare type AnalyticsEvent = {
|
|
16
21
|
eventAction: EVENT_ACTION;
|
|
17
22
|
attributes: {
|
|
18
|
-
|
|
23
|
+
documentAri?: string;
|
|
24
|
+
eventStatus?: EVENT_STATUS;
|
|
19
25
|
meetsSLO?: boolean;
|
|
20
26
|
latency?: number;
|
|
21
27
|
error?: ErrorPayload;
|
|
28
|
+
participants?: number;
|
|
22
29
|
};
|
|
23
30
|
};
|
|
24
31
|
export declare const ACK_MAX_TRY = 10;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
2
|
+
import { GasPurePayload } from '@atlaskit/analytics-gas-types';
|
|
3
|
+
import { AnalyticsEvent } from '../helpers/const';
|
|
4
|
+
export declare const fireAnalyticsEvent: (analyticsClient?: AnalyticsWebClient | undefined, payload?: GasPurePayload | undefined) => void;
|
|
5
|
+
export declare const triggerCollabAnalyticsEvent: (analyticsEvent: AnalyticsEvent, analyticsClient?: AnalyticsWebClient | undefined) => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare enum MEASURE_NAME {
|
|
2
|
+
CALLING_CATCHUP_API = "callingCatchupApi",
|
|
3
|
+
SOCKET_CONNECT = "socketConnect",
|
|
4
|
+
DOCUMENT_INIT = "documentInit",
|
|
5
|
+
CONVERT_PM_TO_ADF = "convertPMToADF"
|
|
6
|
+
}
|
|
7
|
+
export declare function startMeasure(measureName: MEASURE_NAME): void;
|
|
8
|
+
export declare function stopMeasure(measureName: MEASURE_NAME, onMeasureComplete?: (duration: number, startTime: number) => void): {
|
|
9
|
+
duration: number;
|
|
10
|
+
startTime: number;
|
|
11
|
+
} | undefined;
|
|
12
|
+
export declare function clearMeasure(measureName: string): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Emitter } from './emitter';
|
|
2
|
+
import type { Config, Socket, ChannelEvent, CatchupResponse, Metadata } from './types';
|
|
3
|
+
export declare class Channel extends Emitter<ChannelEvent> {
|
|
4
|
+
private connected;
|
|
5
|
+
private config;
|
|
6
|
+
private socket;
|
|
7
|
+
private initialized;
|
|
8
|
+
private analyticsClient?;
|
|
9
|
+
constructor(config: Config);
|
|
10
|
+
getInitialized: () => boolean;
|
|
11
|
+
getConnected: () => boolean;
|
|
12
|
+
getSocket: () => Socket | null;
|
|
13
|
+
/**
|
|
14
|
+
* Connect to collab service using websockets
|
|
15
|
+
*/
|
|
16
|
+
connect(): void;
|
|
17
|
+
private onConnect;
|
|
18
|
+
private onReceiveData;
|
|
19
|
+
fetchCatchup(fromVersion: number): Promise<CatchupResponse>;
|
|
20
|
+
/**
|
|
21
|
+
* Send message to service. Timestamp will be added server side.
|
|
22
|
+
*/
|
|
23
|
+
broadcast<K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>): void;
|
|
24
|
+
sendMetadata(metadata: Metadata): void;
|
|
25
|
+
sendPresenceJoined(): void;
|
|
26
|
+
disconnect(): void;
|
|
27
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const socketIOReasons: {
|
|
2
|
+
IO_CLIENT_DISCONNECT: string;
|
|
3
|
+
IO_SERVER_DISCONNECT: string;
|
|
4
|
+
TRANSPORT_CLOSED: string;
|
|
5
|
+
TRANSPORT_ERROR: string;
|
|
6
|
+
PING_TIMEOUT: string;
|
|
7
|
+
};
|
|
8
|
+
export declare enum DisconnectReason {
|
|
9
|
+
CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
|
|
10
|
+
SERVER_DISCONNECT = "SERVER_DISCONNECT",
|
|
11
|
+
SOCKET_CLOSED = "SOCKET_CLOSED",
|
|
12
|
+
SOCKET_ERROR = "SOCKET_ERROR",
|
|
13
|
+
SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
|
|
14
|
+
UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
|
|
15
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare class Emitter<T = any> {
|
|
2
|
+
private eventEmitter;
|
|
3
|
+
/**
|
|
4
|
+
* Emit events to subscribers
|
|
5
|
+
*/
|
|
6
|
+
protected emit<K extends keyof T>(evt: K, data: T[K]): this;
|
|
7
|
+
/**
|
|
8
|
+
* Subscribe to events emitted by this provider
|
|
9
|
+
*/
|
|
10
|
+
on<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
|
|
11
|
+
/**
|
|
12
|
+
* Unsubscribe from events emitted by this provider
|
|
13
|
+
*/
|
|
14
|
+
off<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
|
|
15
|
+
/**
|
|
16
|
+
* Unsubscribe from all events emitted by this provider.
|
|
17
|
+
*/
|
|
18
|
+
unsubscribeAll<K extends keyof T>(evt?: K): this;
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { CollabErrorPayload, ErrorPayload } from './types';
|
|
2
|
+
export declare const ErrorCodeMapper: {
|
|
3
|
+
noPermissionError: {
|
|
4
|
+
code: string;
|
|
5
|
+
message: string;
|
|
6
|
+
};
|
|
7
|
+
documentNotFound: {
|
|
8
|
+
code: string;
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
hasToLogin: {
|
|
12
|
+
code: string;
|
|
13
|
+
message: string;
|
|
14
|
+
};
|
|
15
|
+
catchupFail: {
|
|
16
|
+
code: string;
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
serviceUnvailable: {
|
|
20
|
+
code: string;
|
|
21
|
+
message: string;
|
|
22
|
+
};
|
|
23
|
+
failToSave: {
|
|
24
|
+
code: string;
|
|
25
|
+
message: string;
|
|
26
|
+
};
|
|
27
|
+
internalError: {
|
|
28
|
+
code: string;
|
|
29
|
+
message: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare const errorCodeMapper: (error: ErrorPayload) => CollabErrorPayload | undefined;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ErrorPayload } from '../types';
|
|
2
|
+
export declare const ATTRIBUTES_PACKAGE = "collabProvider";
|
|
3
|
+
export declare const EVENT_SUBJECT = "collab";
|
|
4
|
+
export declare enum COLLAB_SERVICE {
|
|
5
|
+
NCS = "ncs",
|
|
6
|
+
SYNCHRONY = "synchrony"
|
|
7
|
+
}
|
|
8
|
+
export declare enum EVENT_ACTION {
|
|
9
|
+
CONNECTION = "connection",
|
|
10
|
+
CATCHUP = "catchup",
|
|
11
|
+
DOCUMENT_INIT = "documentInit",
|
|
12
|
+
ADD_STEPS = "addSteps",
|
|
13
|
+
CONVERT_PM_TO_ADF = "convertPMToADF",
|
|
14
|
+
UPDATE_PARTICIPANTS = "updateParticipants"
|
|
15
|
+
}
|
|
16
|
+
export declare enum EVENT_STATUS {
|
|
17
|
+
SUCCESS = "SUCCESS",
|
|
18
|
+
FAILURE = "FAILURE"
|
|
19
|
+
}
|
|
20
|
+
export declare type AnalyticsEvent = {
|
|
21
|
+
eventAction: EVENT_ACTION;
|
|
22
|
+
attributes: {
|
|
23
|
+
documentAri?: string;
|
|
24
|
+
eventStatus?: EVENT_STATUS;
|
|
25
|
+
meetsSLO?: boolean;
|
|
26
|
+
latency?: number;
|
|
27
|
+
error?: ErrorPayload;
|
|
28
|
+
participants?: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
export declare const ACK_MAX_TRY = 10;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ProductInformation } from '../types';
|
|
2
|
+
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
|
+
export declare const getParticipant: (userId: string) => {
|
|
4
|
+
userId: string;
|
|
5
|
+
name: string;
|
|
6
|
+
avatar: string;
|
|
7
|
+
email: string;
|
|
8
|
+
};
|
|
9
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
10
|
+
export declare const getProduct: (productInfo?: ProductInformation | undefined) => string;
|
|
11
|
+
export declare const getSubProduct: (productInfo?: ProductInformation | undefined) => string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export { Provider } from './provider';
|
|
2
|
+
export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, Socket, } from './types';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CatchupOptions } from '../types';
|
|
2
|
+
import { Mapping, Step } from 'prosemirror-transform';
|
|
3
|
+
/**
|
|
4
|
+
* Rebase the steps based on the mapping pipeline.
|
|
5
|
+
* Some steps could be lost, if they are no longer
|
|
6
|
+
* invalid after rebased.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rebaseSteps(steps: Step[], mapping: Mapping): Step[];
|
|
9
|
+
export declare const catchup: (opt: CatchupOptions) => Promise<void>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
+
import { Emitter } from '../emitter';
|
|
3
|
+
import { CollabEditProvider, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
|
+
import type { Config, Metadata, CollabEvents } from '../types';
|
|
5
|
+
import { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
6
|
+
export declare const CATCHUP_THROTTLE: number;
|
|
7
|
+
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
|
+
declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
9
|
+
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
10
|
+
private participants;
|
|
11
|
+
private channel;
|
|
12
|
+
private config;
|
|
13
|
+
private getState;
|
|
14
|
+
private metadata;
|
|
15
|
+
private stepRejectCounter;
|
|
16
|
+
private analyticsClient?;
|
|
17
|
+
private isChannelInitialized;
|
|
18
|
+
private onSyncUpError?;
|
|
19
|
+
private sessionId?;
|
|
20
|
+
private clientId?;
|
|
21
|
+
private userId?;
|
|
22
|
+
private participantUpdateTimeout?;
|
|
23
|
+
private presenceUpdateTimeout?;
|
|
24
|
+
private disconnectedAt?;
|
|
25
|
+
constructor(config: Config);
|
|
26
|
+
private initializeChannel;
|
|
27
|
+
/**
|
|
28
|
+
* Called by collab plugin in editor when it's ready to
|
|
29
|
+
* initialize a collab session.
|
|
30
|
+
*/
|
|
31
|
+
initialize(getState: () => EditorState): this;
|
|
32
|
+
setup({ getState, onSyncUpError, }: {
|
|
33
|
+
getState: () => EditorState;
|
|
34
|
+
onSyncUpError?: SyncUpErrorFunction;
|
|
35
|
+
}): this;
|
|
36
|
+
/**
|
|
37
|
+
* We can use this function to throttle/delay
|
|
38
|
+
* Any send steps operation
|
|
39
|
+
*
|
|
40
|
+
* The getState function will return the current EditorState
|
|
41
|
+
* from the EditorView.
|
|
42
|
+
*/
|
|
43
|
+
private sendStepsFromCurrentState;
|
|
44
|
+
/**
|
|
45
|
+
* Send steps from transaction to other participants
|
|
46
|
+
*/
|
|
47
|
+
send(_tr: Transaction | null, _oldState: EditorState | null, newState: EditorState): void;
|
|
48
|
+
/**
|
|
49
|
+
* Called when we receive steps from the service
|
|
50
|
+
*/
|
|
51
|
+
private onStepsAdded;
|
|
52
|
+
private throttledCatchup;
|
|
53
|
+
private fitlerQueue;
|
|
54
|
+
private updateDocumentWithMetadata;
|
|
55
|
+
private applyLocalsteps;
|
|
56
|
+
private getCurrentPmVersion;
|
|
57
|
+
private getUnconfirmedSteps;
|
|
58
|
+
/**
|
|
59
|
+
* Called when:
|
|
60
|
+
* * session established(offline -> online)
|
|
61
|
+
* * try to accept steps but version is behind.
|
|
62
|
+
*/
|
|
63
|
+
private catchup;
|
|
64
|
+
private onErrorHandled;
|
|
65
|
+
private pauseQueue?;
|
|
66
|
+
private queue;
|
|
67
|
+
private queueSteps;
|
|
68
|
+
private processQueue;
|
|
69
|
+
private processSteps;
|
|
70
|
+
/**
|
|
71
|
+
* Send messages, such as telepointers, to other participants.
|
|
72
|
+
*/
|
|
73
|
+
sendMessage(data: any): void;
|
|
74
|
+
private sendPresence;
|
|
75
|
+
/**
|
|
76
|
+
* Called when a participant joins the session.
|
|
77
|
+
*
|
|
78
|
+
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
79
|
+
* the active avatars in the editor.
|
|
80
|
+
* This method will be triggered from backend to notify all participants to exchange presence
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
private onPresenceJoined;
|
|
84
|
+
private onPresence;
|
|
85
|
+
/**
|
|
86
|
+
* Called when a metadata is changed.
|
|
87
|
+
*
|
|
88
|
+
*/
|
|
89
|
+
private onMetadataChanged;
|
|
90
|
+
/**
|
|
91
|
+
* Called when a participant leaves the session.
|
|
92
|
+
*
|
|
93
|
+
* We emit the `presence` event to update the active avatars in the editor.
|
|
94
|
+
*/
|
|
95
|
+
private onParticipantLeft;
|
|
96
|
+
/**
|
|
97
|
+
* Called when we receive an update event from another participant.
|
|
98
|
+
*/
|
|
99
|
+
private onParticipantUpdated;
|
|
100
|
+
/**
|
|
101
|
+
* Called when we receive a telepointer update from another
|
|
102
|
+
* participant.
|
|
103
|
+
*/
|
|
104
|
+
private onParticipantTelepointer;
|
|
105
|
+
private updateParticipant;
|
|
106
|
+
/**
|
|
107
|
+
* Keep list of participants up to date. Filter out inactive users etc.
|
|
108
|
+
*/
|
|
109
|
+
private updateParticipants;
|
|
110
|
+
private emitTelepointersFromSteps;
|
|
111
|
+
private disconnectedReasonMapper;
|
|
112
|
+
private onDisconnected;
|
|
113
|
+
destroy(): this;
|
|
114
|
+
disconnect(): this;
|
|
115
|
+
setTitle(title: string, broadcast?: boolean): void;
|
|
116
|
+
setEditorWidth(editorWidth: string, broadcast?: boolean): void;
|
|
117
|
+
setMetadata(metadata: Metadata): void;
|
|
118
|
+
getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
|
|
119
|
+
/**
|
|
120
|
+
* Unsubscribe from all events emitted by this provider.
|
|
121
|
+
*/
|
|
122
|
+
unsubscribeAll(): this;
|
|
123
|
+
}
|
|
124
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Provider } from './provider';
|
|
2
|
+
import { Socket, Config, ProductInformation } from './types';
|
|
3
|
+
export declare function createSocketIOSocket(url: string, auth?: (cb: (data: object) => void) => void, productInfo?: ProductInformation): Socket;
|
|
4
|
+
export declare function createSocketIOCollabProvider(config: Omit<Config, 'createSocket'>): Provider;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import type { Transaction } from 'prosemirror-state';
|
|
2
|
+
import type { Step } from 'prosemirror-transform';
|
|
3
|
+
import type { CollabParticipant, CollabEventTelepointerData as EditorCollabTelepointerData, CollabEventConnectionData as EditorCollabConnetedData, CollabEventInitData as EditorCollabInitData, CollabEventRemoteData as EditorCollabData, CollabEventPresenceData as EditorCollabPresenceData } from '@atlaskit/editor-common/collab';
|
|
4
|
+
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
|
+
import type { Manager } from 'socket.io-client';
|
|
6
|
+
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
7
|
+
export interface Storage {
|
|
8
|
+
get(key: string): Promise<string>;
|
|
9
|
+
set(key: string, value: string): Promise<void>;
|
|
10
|
+
delete(key: string): Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
export interface Config {
|
|
13
|
+
url: string;
|
|
14
|
+
documentAri: string;
|
|
15
|
+
lifecycle?: Lifecycle;
|
|
16
|
+
storage?: Storage;
|
|
17
|
+
need404?: boolean;
|
|
18
|
+
createSocket: (path: string, auth?: (cb: (data: object) => void) => void, productInfo?: ProductInformation) => Socket;
|
|
19
|
+
analyticsClient?: AnalyticsWebClient;
|
|
20
|
+
getUser?(userId: string): Promise<Pick<CollabParticipant, 'avatar' | 'email' | 'name'> & {
|
|
21
|
+
userId: string;
|
|
22
|
+
}>;
|
|
23
|
+
permissionTokenRefresh?: () => Promise<string>;
|
|
24
|
+
productInfo?: ProductInformation;
|
|
25
|
+
}
|
|
26
|
+
interface SimpleEventEmitter {
|
|
27
|
+
on(event: string, fn: Function): SimpleEventEmitter;
|
|
28
|
+
}
|
|
29
|
+
export interface Socket extends SimpleEventEmitter {
|
|
30
|
+
id: string;
|
|
31
|
+
connect(): Socket;
|
|
32
|
+
emit(event: string, ...args: any[]): Socket;
|
|
33
|
+
close(): Socket;
|
|
34
|
+
io?: Manager;
|
|
35
|
+
}
|
|
36
|
+
export declare type LifecycleEvents = 'save' | 'restore';
|
|
37
|
+
export declare type EventHandler = () => void;
|
|
38
|
+
export interface Lifecycle {
|
|
39
|
+
on(event: LifecycleEvents, handler: EventHandler): void;
|
|
40
|
+
}
|
|
41
|
+
export declare type CollabConnectedPayload = EditorCollabConnetedData;
|
|
42
|
+
export interface CollabDisconnectedPayload {
|
|
43
|
+
reason: DisconnectReason;
|
|
44
|
+
sid: string;
|
|
45
|
+
}
|
|
46
|
+
export interface CollabErrorPayload {
|
|
47
|
+
status: number;
|
|
48
|
+
code: string;
|
|
49
|
+
message: string;
|
|
50
|
+
reason?: string;
|
|
51
|
+
}
|
|
52
|
+
export interface CollabInitPayload extends EditorCollabInitData {
|
|
53
|
+
doc: any;
|
|
54
|
+
version: number;
|
|
55
|
+
userId?: string;
|
|
56
|
+
metadata?: Metadata;
|
|
57
|
+
}
|
|
58
|
+
export interface CollabDataPayload extends EditorCollabData {
|
|
59
|
+
version: number;
|
|
60
|
+
json: StepJson[];
|
|
61
|
+
userIds: string[];
|
|
62
|
+
}
|
|
63
|
+
export declare type CollabTelepointerPayload = EditorCollabTelepointerData;
|
|
64
|
+
export declare type CollabPresencePayload = EditorCollabPresenceData;
|
|
65
|
+
export declare type CollabMetadataPayload = Metadata;
|
|
66
|
+
export declare type CollabLocalStepsPayload = {
|
|
67
|
+
steps: Step[];
|
|
68
|
+
};
|
|
69
|
+
export interface CollabEvents {
|
|
70
|
+
'metadata:changed': CollabMetadataPayload;
|
|
71
|
+
init: CollabInitPayload;
|
|
72
|
+
connected: CollabConnectedPayload;
|
|
73
|
+
disconnected: CollabDisconnectedPayload;
|
|
74
|
+
data: CollabDataPayload;
|
|
75
|
+
telepointer: CollabTelepointerPayload;
|
|
76
|
+
presence: CollabPresencePayload;
|
|
77
|
+
'local-steps': CollabLocalStepsPayload;
|
|
78
|
+
error: CollabErrorPayload;
|
|
79
|
+
entity: any;
|
|
80
|
+
}
|
|
81
|
+
export interface Metadata {
|
|
82
|
+
[key: string]: string | number | boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare type InitPayload = {
|
|
85
|
+
doc: any;
|
|
86
|
+
version: number;
|
|
87
|
+
userId?: string;
|
|
88
|
+
metadata?: Metadata;
|
|
89
|
+
};
|
|
90
|
+
export declare type PresencePayload = {
|
|
91
|
+
sessionId: string;
|
|
92
|
+
userId: string;
|
|
93
|
+
clientId: string;
|
|
94
|
+
timestamp: number;
|
|
95
|
+
};
|
|
96
|
+
export declare type TelepointerPayload = PresencePayload & {
|
|
97
|
+
selection: {
|
|
98
|
+
type: 'textSelection' | 'nodeSelection';
|
|
99
|
+
anchor: number;
|
|
100
|
+
head: number;
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
export declare type StepJson = {
|
|
104
|
+
from?: number;
|
|
105
|
+
to?: number;
|
|
106
|
+
stepType?: string;
|
|
107
|
+
clientId: string;
|
|
108
|
+
userId: string;
|
|
109
|
+
};
|
|
110
|
+
export declare type StepsPayload = {
|
|
111
|
+
version: number;
|
|
112
|
+
steps: StepJson[];
|
|
113
|
+
};
|
|
114
|
+
export declare type ErrorPayload = {
|
|
115
|
+
message: string;
|
|
116
|
+
data?: {
|
|
117
|
+
status: number;
|
|
118
|
+
code?: string;
|
|
119
|
+
meta?: string | {
|
|
120
|
+
description: string;
|
|
121
|
+
reason?: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
export declare type ChannelEvent = {
|
|
126
|
+
connected: {
|
|
127
|
+
sid: string;
|
|
128
|
+
initialized: boolean;
|
|
129
|
+
};
|
|
130
|
+
init: InitPayload;
|
|
131
|
+
reconnected: null;
|
|
132
|
+
'presence:joined': PresencePayload;
|
|
133
|
+
presence: PresencePayload;
|
|
134
|
+
'participant:left': PresencePayload;
|
|
135
|
+
'participant:telepointer': TelepointerPayload;
|
|
136
|
+
'participant:updated': PresencePayload;
|
|
137
|
+
'steps:commit': StepsPayload & {
|
|
138
|
+
userId: string;
|
|
139
|
+
};
|
|
140
|
+
'steps:added': StepsPayload;
|
|
141
|
+
'metadata:changed': Metadata;
|
|
142
|
+
error: ErrorPayload;
|
|
143
|
+
disconnect: {
|
|
144
|
+
reason: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
export interface CatchupResponse {
|
|
148
|
+
doc?: string;
|
|
149
|
+
version?: number;
|
|
150
|
+
stepMaps?: any[];
|
|
151
|
+
metadata?: Metadata;
|
|
152
|
+
}
|
|
153
|
+
export interface CatchupOptions {
|
|
154
|
+
getCurrentPmVersion: () => number;
|
|
155
|
+
fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>;
|
|
156
|
+
fitlerQueue: (condition: (stepsPayload: StepsPayload) => boolean) => void;
|
|
157
|
+
getUnconfirmedSteps: () => {
|
|
158
|
+
version: number;
|
|
159
|
+
steps: Step<any>[];
|
|
160
|
+
clientID: string | number;
|
|
161
|
+
origins: Transaction<any>[];
|
|
162
|
+
} | null | undefined;
|
|
163
|
+
updateDocumentWithMetadata: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
164
|
+
applyLocalsteps: (steps: Step[]) => void;
|
|
165
|
+
}
|
|
166
|
+
export declare type ProductInformation = {
|
|
167
|
+
product: string;
|
|
168
|
+
subProduct?: string;
|
|
169
|
+
};
|
|
170
|
+
export {};
|
package/emitter/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/emitter.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/emitter.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/emitter.d.ts"
|
|
7
|
+
"types": "../dist/types/emitter.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/emitter.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/error-code-mapper.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/error-code-mapper.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/error-code-mapper.d.ts"
|
|
7
|
+
"types": "../dist/types/error-code-mapper.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/error-code-mapper.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.6.1",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -12,6 +12,13 @@
|
|
|
12
12
|
"module": "dist/esm/index.js",
|
|
13
13
|
"module:es2019": "dist/es2019/index.js",
|
|
14
14
|
"types": "dist/types/index.d.ts",
|
|
15
|
+
"typesVersions": {
|
|
16
|
+
">=4.0 <4.5": {
|
|
17
|
+
"*": [
|
|
18
|
+
"dist/types-ts4.0/*"
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
},
|
|
15
22
|
"sideEffects": false,
|
|
16
23
|
"atlaskit:src": "src/index.ts",
|
|
17
24
|
"atlassian": {
|
|
@@ -21,10 +28,10 @@
|
|
|
21
28
|
"releaseModel": "scheduled"
|
|
22
29
|
},
|
|
23
30
|
"dependencies": {
|
|
24
|
-
"@atlaskit/analytics-gas-types": "5.0.
|
|
31
|
+
"@atlaskit/analytics-gas-types": "5.0.9",
|
|
25
32
|
"@atlaskit/analytics-listeners": "^8.3.0",
|
|
26
|
-
"@atlaskit/editor-common": "^69.
|
|
27
|
-
"@atlaskit/editor-json-transformer": "^8.
|
|
33
|
+
"@atlaskit/editor-common": "^69.3.0",
|
|
34
|
+
"@atlaskit/editor-json-transformer": "^8.8.0",
|
|
28
35
|
"@atlaskit/util-service-support": "^6.1.0",
|
|
29
36
|
"@babel/runtime": "^7.0.0",
|
|
30
37
|
"eventemitter2": "^4.1.0",
|
|
@@ -44,14 +51,14 @@
|
|
|
44
51
|
}
|
|
45
52
|
},
|
|
46
53
|
"devDependencies": {
|
|
47
|
-
"@atlaskit/adf-schema": "^
|
|
48
|
-
"@atlaskit/editor-test-helpers": "^17.
|
|
54
|
+
"@atlaskit/adf-schema": "^24.0.0",
|
|
55
|
+
"@atlaskit/editor-test-helpers": "^17.2.0",
|
|
49
56
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
50
57
|
"@types/prosemirror-collab": "^1.1.1",
|
|
51
58
|
"@types/prosemirror-model": "^1.11.0",
|
|
52
59
|
"@types/prosemirror-state": "^1.2.0",
|
|
53
60
|
"prosemirror-model": "1.14.3",
|
|
54
|
-
"typescript": "4.
|
|
61
|
+
"typescript": "4.5.5"
|
|
55
62
|
},
|
|
56
63
|
"prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
|
|
57
64
|
}
|
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/socket-io-provider.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/socket-io-provider.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/socket-io-provider.d.ts"
|
|
7
|
+
"types": "../dist/types/socket-io-provider.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/socket-io-provider.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|
package/types/package.json
CHANGED
|
@@ -4,5 +4,12 @@
|
|
|
4
4
|
"module": "../dist/esm/types.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/types.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/types.d.ts"
|
|
7
|
+
"types": "../dist/types/types.d.ts",
|
|
8
|
+
"typesVersions": {
|
|
9
|
+
">=4.0 <4.5": {
|
|
10
|
+
"*": [
|
|
11
|
+
"../dist/types-ts4.0/types.d.ts"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
}
|
|
8
15
|
}
|