@atlaskit/collab-provider 7.6.2 → 7.7.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 +22 -0
- package/dist/cjs/analytics/index.js +4 -1
- package/dist/cjs/analytics/performance.js +2 -0
- package/dist/cjs/channel.js +17 -0
- package/dist/cjs/config.js +2 -2
- package/dist/cjs/helpers/const.js +4 -4
- package/dist/cjs/provider/index.js +188 -67
- package/dist/cjs/socket-io-provider.js +1 -0
- package/dist/cjs/version-wrapper.js +16 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +4 -2
- package/dist/es2019/analytics/performance.js +2 -0
- package/dist/es2019/channel.js +18 -0
- package/dist/es2019/config.js +2 -2
- package/dist/es2019/helpers/const.js +3 -2
- package/dist/es2019/provider/index.js +117 -13
- package/dist/es2019/socket-io-provider.js +1 -0
- package/dist/es2019/version-wrapper.js +5 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +4 -2
- package/dist/esm/analytics/performance.js +2 -0
- package/dist/esm/channel.js +17 -0
- package/dist/esm/config.js +2 -2
- package/dist/esm/helpers/const.js +3 -2
- package/dist/esm/provider/index.js +191 -67
- package/dist/esm/socket-io-provider.js +1 -0
- package/dist/esm/version-wrapper.js +5 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/performance.d.ts +3 -1
- package/dist/types/helpers/const.d.ts +5 -3
- package/dist/types/provider/index.d.ts +6 -0
- package/dist/types/types.d.ts +7 -0
- package/dist/types/version-wrapper.d.ts +3 -0
- package/package.json +7 -11
- package/report.api.md +154 -177
- package/version-wrapper/package.json +15 -0
- package/dist/types-ts4.0/analytics/index.d.ts +0 -5
- package/dist/types-ts4.0/analytics/performance.d.ts +0 -12
- package/dist/types-ts4.0/channel.d.ts +0 -27
- package/dist/types-ts4.0/config.d.ts +0 -5
- package/dist/types-ts4.0/disconnected-reason-mapper.d.ts +0 -15
- package/dist/types-ts4.0/emitter.d.ts +0 -19
- package/dist/types-ts4.0/error-code-mapper.d.ts +0 -32
- package/dist/types-ts4.0/helpers/const.d.ts +0 -31
- package/dist/types-ts4.0/helpers/utils.d.ts +0 -11
- package/dist/types-ts4.0/index.d.ts +0 -2
- package/dist/types-ts4.0/provider/catchup.d.ts +0 -9
- package/dist/types-ts4.0/provider/index.d.ts +0 -124
- package/dist/types-ts4.0/socket-io-provider.d.ts +0 -4
- package/dist/types-ts4.0/types.d.ts +0 -170
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 7.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`fa0da169cce`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fa0da169cce) - Introducing namespace status update: lock & unlock events
|
|
8
|
+
- [`eaada7441d0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/eaada7441d0) - ESS-2853 Add metrics for page recovery events
|
|
9
|
+
- [`6319cd08784`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6319cd08784) - add page restoration event handler
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
|
|
15
|
+
## 7.6.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- [`1a64a3e3e53`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1a64a3e3e53) - ESS-2591 Reduce initial re-connection delay and increase randomization factor for socket io connections.
|
|
20
|
+
- [`ee8ac15d730`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ee8ac15d730) - ESS-1363 add packageVersion to analytic events
|
|
21
|
+
- [`29292da81d7`](https://bitbucket.org/atlassian/atlassian-frontend/commits/29292da81d7) - Increased the limits for the collab sync on returning the document to the consumer
|
|
22
|
+
- [`e06f8ba062f`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e06f8ba062f) - Disable collab provider transport closing on the beforeunload event.
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
|
|
3
25
|
## 7.6.2
|
|
4
26
|
|
|
5
27
|
### Patch Changes
|
|
@@ -11,6 +11,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _const = require("../helpers/const");
|
|
13
13
|
|
|
14
|
+
var _versionWrapper = require("../version-wrapper");
|
|
15
|
+
|
|
14
16
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
17
|
|
|
16
18
|
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) { (0, _defineProperty2.default)(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; }
|
|
@@ -43,7 +45,8 @@ var triggerCollabAnalyticsEvent = function triggerCollabAnalyticsEvent(analytics
|
|
|
43
45
|
actionSubject: _const.EVENT_SUBJECT,
|
|
44
46
|
source: 'unknown',
|
|
45
47
|
attributes: _objectSpread({
|
|
46
|
-
packageName:
|
|
48
|
+
packageName: _versionWrapper.name,
|
|
49
|
+
packageVersion: _versionWrapper.version,
|
|
47
50
|
collabService: _const.COLLAB_SERVICE.NCS
|
|
48
51
|
}, analyticsEvent.attributes)
|
|
49
52
|
};
|
|
@@ -15,6 +15,8 @@ exports.MEASURE_NAME = MEASURE_NAME;
|
|
|
15
15
|
MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
|
|
16
16
|
MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
|
|
17
17
|
MEASURE_NAME["CONVERT_PM_TO_ADF"] = "convertPMToADF";
|
|
18
|
+
MEASURE_NAME["ADD_STEPS"] = "addSteps";
|
|
19
|
+
MEASURE_NAME["COMMIT_UNCONFIRMED_STEPS"] = "commitUnconfirmedSteps";
|
|
18
20
|
})(MEASURE_NAME || (exports.MEASURE_NAME = MEASURE_NAME = {}));
|
|
19
21
|
|
|
20
22
|
var isPerformanceAPIAvailable = function isPerformanceAPIAvailable() {
|
package/dist/cjs/channel.js
CHANGED
|
@@ -117,6 +117,19 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
117
117
|
userId: userId,
|
|
118
118
|
metadata: metadata
|
|
119
119
|
});
|
|
120
|
+
} else {
|
|
121
|
+
// Page is been just restored, need to fix all the participants as well.
|
|
122
|
+
var _doc = data.doc,
|
|
123
|
+
_version = data.version,
|
|
124
|
+
_userId = data.userId,
|
|
125
|
+
_metadata = data.metadata;
|
|
126
|
+
|
|
127
|
+
_this.emit('restore', {
|
|
128
|
+
doc: _doc,
|
|
129
|
+
version: _version,
|
|
130
|
+
userId: _userId,
|
|
131
|
+
metadata: _metadata
|
|
132
|
+
});
|
|
120
133
|
}
|
|
121
134
|
} else {
|
|
122
135
|
_this.emit('steps:added', data);
|
|
@@ -215,6 +228,10 @@ var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
215
228
|
});
|
|
216
229
|
this.socket.on('metadata:changed', function (payload) {
|
|
217
230
|
_this2.emit('metadata:changed', payload);
|
|
231
|
+
}); // ESS-2916 namespace status event - lock/unlock
|
|
232
|
+
|
|
233
|
+
this.socket.on('status', function (data) {
|
|
234
|
+
_this2.emit('status', data);
|
|
218
235
|
});
|
|
219
236
|
this.socket.on('disconnect', /*#__PURE__*/function () {
|
|
220
237
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(reason) {
|
package/dist/cjs/config.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.SOCKET_IO_OPTIONS = void 0;
|
|
7
7
|
var SOCKET_IO_OPTIONS = {
|
|
8
8
|
RECONNECTION_DELAY_MAX: 128 * 1000,
|
|
9
|
-
RECONNECTION_DELAY:
|
|
10
|
-
RANDOMIZATION_FACTOR: 0.
|
|
9
|
+
RECONNECTION_DELAY: 200,
|
|
10
|
+
RANDOMIZATION_FACTOR: 0.5
|
|
11
11
|
};
|
|
12
12
|
exports.SOCKET_IO_OPTIONS = SOCKET_IO_OPTIONS;
|
|
@@ -3,9 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.
|
|
7
|
-
var ATTRIBUTES_PACKAGE = 'collabProvider';
|
|
8
|
-
exports.ATTRIBUTES_PACKAGE = ATTRIBUTES_PACKAGE;
|
|
6
|
+
exports.EVENT_SUBJECT = exports.EVENT_STATUS = exports.EVENT_ACTION = exports.COLLAB_SERVICE = exports.ACK_MAX_TRY = void 0;
|
|
9
7
|
var EVENT_SUBJECT = 'collab';
|
|
10
8
|
exports.EVENT_SUBJECT = EVENT_SUBJECT;
|
|
11
9
|
var COLLAB_SERVICE;
|
|
@@ -26,6 +24,8 @@ exports.EVENT_ACTION = EVENT_ACTION;
|
|
|
26
24
|
EVENT_ACTION["ADD_STEPS"] = "addSteps";
|
|
27
25
|
EVENT_ACTION["CONVERT_PM_TO_ADF"] = "convertPMToADF";
|
|
28
26
|
EVENT_ACTION["UPDATE_PARTICIPANTS"] = "updateParticipants";
|
|
27
|
+
EVENT_ACTION["COMMIT_UNCONFIRMED_STEPS"] = "commitUnconfirmedSteps";
|
|
28
|
+
EVENT_ACTION["REINITIALISE_DOCUMENT"] = "reinitialiseDocument";
|
|
29
29
|
})(EVENT_ACTION || (exports.EVENT_ACTION = EVENT_ACTION = {}));
|
|
30
30
|
|
|
31
31
|
var EVENT_STATUS;
|
|
@@ -36,5 +36,5 @@ exports.EVENT_STATUS = EVENT_STATUS;
|
|
|
36
36
|
EVENT_STATUS["FAILURE"] = "FAILURE";
|
|
37
37
|
})(EVENT_STATUS || (exports.EVENT_STATUS = EVENT_STATUS = {}));
|
|
38
38
|
|
|
39
|
-
var ACK_MAX_TRY =
|
|
39
|
+
var ACK_MAX_TRY = 30;
|
|
40
40
|
exports.ACK_MAX_TRY = ACK_MAX_TRY;
|
|
@@ -115,6 +115,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
115
115
|
|
|
116
116
|
var _super = _createSuper(Provider);
|
|
117
117
|
|
|
118
|
+
// To keep track of the namespace event changes from the server.
|
|
118
119
|
function Provider(config) {
|
|
119
120
|
var _this;
|
|
120
121
|
|
|
@@ -124,6 +125,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
124
125
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "metadata", {});
|
|
125
126
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "stepRejectCounter", 0);
|
|
126
127
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isChannelInitialized", false);
|
|
128
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isNamespaceLocked", false);
|
|
127
129
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initializeChannel", function () {
|
|
128
130
|
_this.channel.on('connected', function (_ref2) {
|
|
129
131
|
var sid = _ref2.sid,
|
|
@@ -152,7 +154,42 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
152
154
|
version: version,
|
|
153
155
|
metadata: metadata
|
|
154
156
|
});
|
|
155
|
-
}).on('steps:added', _this.onStepsAdded.bind((0, _assertThisInitialized2.default)(_this))).on('participant:telepointer', _this.onParticipantTelepointer.bind((0, _assertThisInitialized2.default)(_this))).on('presence:joined', _this.onPresenceJoined.bind((0, _assertThisInitialized2.default)(_this))).on('presence', _this.onPresence.bind((0, _assertThisInitialized2.default)(_this))).on('participant:left', _this.onParticipantLeft.bind((0, _assertThisInitialized2.default)(_this))).on('participant:updated', _this.onParticipantUpdated.bind((0, _assertThisInitialized2.default)(_this))).on('metadata:changed', _this.onMetadataChanged.bind((0, _assertThisInitialized2.default)(_this))).on('disconnect', _this.onDisconnected.bind((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled.bind((0, _assertThisInitialized2.default)(_this))).connect();
|
|
157
|
+
}).on('restore', _this.onRestore.bind((0, _assertThisInitialized2.default)(_this))).on('steps:added', _this.onStepsAdded.bind((0, _assertThisInitialized2.default)(_this))).on('participant:telepointer', _this.onParticipantTelepointer.bind((0, _assertThisInitialized2.default)(_this))).on('presence:joined', _this.onPresenceJoined.bind((0, _assertThisInitialized2.default)(_this))).on('presence', _this.onPresence.bind((0, _assertThisInitialized2.default)(_this))).on('participant:left', _this.onParticipantLeft.bind((0, _assertThisInitialized2.default)(_this))).on('participant:updated', _this.onParticipantUpdated.bind((0, _assertThisInitialized2.default)(_this))).on('metadata:changed', _this.onMetadataChanged.bind((0, _assertThisInitialized2.default)(_this))).on('disconnect', _this.onDisconnected.bind((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled.bind((0, _assertThisInitialized2.default)(_this))).on('status', _this.onNamespaceStatusChanged.bind((0, _assertThisInitialized2.default)(_this))).connect();
|
|
158
|
+
});
|
|
159
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onRestore", function (_ref4) {
|
|
160
|
+
var doc = _ref4.doc,
|
|
161
|
+
version = _ref4.version,
|
|
162
|
+
metadata = _ref4.metadata;
|
|
163
|
+
|
|
164
|
+
// Preseve the unconfirmed steps to prevent data loss.
|
|
165
|
+
var _ref5 = _this.getUnconfirmedSteps() || {
|
|
166
|
+
steps: []
|
|
167
|
+
},
|
|
168
|
+
unconfirmedSteps = _ref5.steps; // Reset the editor,
|
|
169
|
+
// - Repalce the document, keep in sync with the server
|
|
170
|
+
// - Repalce the version number, so editor is in sync with NCS server and can commit new changes.
|
|
171
|
+
// - Repalce the metadata
|
|
172
|
+
// - Reserve the cursore position, in case a cursor jump.
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
_this.updateDocumentWithMetadata({
|
|
176
|
+
doc: doc,
|
|
177
|
+
version: version,
|
|
178
|
+
metadata: metadata,
|
|
179
|
+
reserveCursor: true
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
183
|
+
eventAction: _const.EVENT_ACTION.REINITIALISE_DOCUMENT,
|
|
184
|
+
attributes: {
|
|
185
|
+
numUnconfirmedSteps: unconfirmedSteps.length,
|
|
186
|
+
documentAri: _this.config.documentAri
|
|
187
|
+
}
|
|
188
|
+
}, _this.analyticsClient); // Re-apply the unconfirmed steps, not 100% of them can be applied, if document is changed significantly.
|
|
189
|
+
|
|
190
|
+
if (unconfirmedSteps.length > 0) {
|
|
191
|
+
_this.applyLocalsteps(unconfirmedSteps);
|
|
192
|
+
}
|
|
156
193
|
});
|
|
157
194
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onStepsAdded", function (data) {
|
|
158
195
|
logger("Received steps", {
|
|
@@ -181,8 +218,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
181
218
|
_this.throttledCatchup();
|
|
182
219
|
}
|
|
183
220
|
|
|
184
|
-
_this.updateParticipants([], data.steps.map(function (
|
|
185
|
-
var userId =
|
|
221
|
+
_this.updateParticipants([], data.steps.map(function (_ref6) {
|
|
222
|
+
var userId = _ref6.userId;
|
|
186
223
|
return userId;
|
|
187
224
|
}));
|
|
188
225
|
});
|
|
@@ -195,11 +232,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
195
232
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fitlerQueue", function (condition) {
|
|
196
233
|
_this.queue = _this.queue.filter(condition);
|
|
197
234
|
});
|
|
198
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDocumentWithMetadata", function (
|
|
199
|
-
var doc =
|
|
200
|
-
version =
|
|
201
|
-
metadata =
|
|
202
|
-
reserveCursor =
|
|
235
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDocumentWithMetadata", function (_ref7) {
|
|
236
|
+
var doc = _ref7.doc,
|
|
237
|
+
version = _ref7.version,
|
|
238
|
+
metadata = _ref7.metadata,
|
|
239
|
+
reserveCursor = _ref7.reserveCursor;
|
|
203
240
|
|
|
204
241
|
_this.emit('init', _objectSpread({
|
|
205
242
|
doc: doc,
|
|
@@ -306,12 +343,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
306
343
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onErrorHandled", function (error) {
|
|
307
344
|
if (error && error.data) {
|
|
308
345
|
if (error.data.code === 'HEAD_VERSION_UPDATE_FAILED' || error.data.code === 'VERSION_NUMBER_ALREADY_EXISTS') {
|
|
346
|
+
var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.ADD_STEPS);
|
|
309
347
|
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
310
348
|
eventAction: _const.EVENT_ACTION.ADD_STEPS,
|
|
311
349
|
attributes: {
|
|
312
350
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
313
351
|
error: error,
|
|
314
|
-
documentAri: _this.config.documentAri
|
|
352
|
+
documentAri: _this.config.documentAri,
|
|
353
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
315
354
|
}
|
|
316
355
|
}, _this.analyticsClient);
|
|
317
356
|
_this.stepRejectCounter++;
|
|
@@ -350,14 +389,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
350
389
|
return _this.sendPresence();
|
|
351
390
|
}, SEND_PRESENCE_INTERVAL);
|
|
352
391
|
});
|
|
353
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresenceJoined", function (
|
|
354
|
-
var sessionId =
|
|
392
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresenceJoined", function (_ref9) {
|
|
393
|
+
var sessionId = _ref9.sessionId;
|
|
355
394
|
logger('Participant joined with session: ', sessionId); // This expose existing users to the newly joined user
|
|
356
395
|
|
|
357
396
|
_this.sendPresence();
|
|
358
397
|
});
|
|
359
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresence", function (
|
|
360
|
-
var userId =
|
|
398
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresence", function (_ref10) {
|
|
399
|
+
var userId = _ref10.userId;
|
|
361
400
|
logger('onPresence userId: ', userId);
|
|
362
401
|
_this.userId = userId;
|
|
363
402
|
|
|
@@ -372,8 +411,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
372
411
|
_this.emit('metadata:changed', metadata);
|
|
373
412
|
}
|
|
374
413
|
});
|
|
375
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantLeft", function (
|
|
376
|
-
var sessionId =
|
|
414
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantLeft", function (_ref11) {
|
|
415
|
+
var sessionId = _ref11.sessionId;
|
|
377
416
|
logger("Participant left");
|
|
378
417
|
|
|
379
418
|
_this.participants.delete(sessionId);
|
|
@@ -384,11 +423,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
384
423
|
}]
|
|
385
424
|
});
|
|
386
425
|
});
|
|
387
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantUpdated", function (
|
|
388
|
-
var sessionId =
|
|
389
|
-
timestamp =
|
|
390
|
-
userId =
|
|
391
|
-
clientId =
|
|
426
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantUpdated", function (_ref12) {
|
|
427
|
+
var sessionId = _ref12.sessionId,
|
|
428
|
+
timestamp = _ref12.timestamp,
|
|
429
|
+
userId = _ref12.userId,
|
|
430
|
+
clientId = _ref12.clientId;
|
|
392
431
|
|
|
393
432
|
_this.updateParticipant({
|
|
394
433
|
sessionId: sessionId,
|
|
@@ -397,12 +436,12 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
397
436
|
clientId: clientId
|
|
398
437
|
});
|
|
399
438
|
});
|
|
400
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantTelepointer", function (
|
|
401
|
-
var sessionId =
|
|
402
|
-
timestamp =
|
|
403
|
-
selection =
|
|
404
|
-
userId =
|
|
405
|
-
clientId =
|
|
439
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantTelepointer", function (_ref13) {
|
|
440
|
+
var sessionId = _ref13.sessionId,
|
|
441
|
+
timestamp = _ref13.timestamp,
|
|
442
|
+
selection = _ref13.selection,
|
|
443
|
+
userId = _ref13.userId,
|
|
444
|
+
clientId = _ref13.clientId;
|
|
406
445
|
|
|
407
446
|
if (sessionId === _this.sessionId) {
|
|
408
447
|
return;
|
|
@@ -430,14 +469,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
430
469
|
});
|
|
431
470
|
});
|
|
432
471
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateParticipant", /*#__PURE__*/function () {
|
|
433
|
-
var
|
|
472
|
+
var _ref15 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref14) {
|
|
434
473
|
var sessionId, timestamp, userId, clientId, getUser, _yield, _yield$name, name, _yield$email, email, _yield$avatar, avatar, isNewParticipant;
|
|
435
474
|
|
|
436
475
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
437
476
|
while (1) {
|
|
438
477
|
switch (_context2.prev = _context2.next) {
|
|
439
478
|
case 0:
|
|
440
|
-
sessionId =
|
|
479
|
+
sessionId = _ref14.sessionId, timestamp = _ref14.timestamp, userId = _ref14.userId, clientId = _ref14.clientId;
|
|
441
480
|
|
|
442
481
|
if (userId) {
|
|
443
482
|
_context2.next = 3;
|
|
@@ -490,7 +529,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
490
529
|
}));
|
|
491
530
|
|
|
492
531
|
return function (_x) {
|
|
493
|
-
return
|
|
532
|
+
return _ref15.apply(this, arguments);
|
|
494
533
|
};
|
|
495
534
|
}());
|
|
496
535
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateParticipants", function () {
|
|
@@ -560,8 +599,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
560
599
|
return _disconnectedReasonMapper.DisconnectReason.UNKNOWN_DISCONNECT;
|
|
561
600
|
}
|
|
562
601
|
});
|
|
563
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (
|
|
564
|
-
var reason =
|
|
602
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (_ref16) {
|
|
603
|
+
var reason = _ref16.reason;
|
|
565
604
|
_this.disconnectedAt = Date.now();
|
|
566
605
|
var left = Array.from(_this.participants.values());
|
|
567
606
|
|
|
@@ -581,7 +620,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
581
620
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
|
|
582
621
|
var _this$metadata$title;
|
|
583
622
|
|
|
584
|
-
var maxAttemptsToSync, count, unconfirmedState, state, adfDocument, measure,
|
|
623
|
+
var maxAttemptsToSync, count, unconfirmedState, state, adfDocument, measure, _measure3;
|
|
585
624
|
|
|
586
625
|
return _regenerator.default.wrap(function _callee4$(_context4) {
|
|
587
626
|
while (1) {
|
|
@@ -597,32 +636,33 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
597
636
|
}
|
|
598
637
|
|
|
599
638
|
return _context4.delegateYield( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
|
|
600
|
-
var unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedState, nextUnconfirmedTrs, _state;
|
|
639
|
+
var unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedState, nextUnconfirmedTrs, _state, _measure2, measure;
|
|
601
640
|
|
|
602
641
|
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
603
642
|
while (1) {
|
|
604
643
|
switch (_context3.prev = _context3.next) {
|
|
605
644
|
case 0:
|
|
606
|
-
// We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
645
|
+
(0, _performance.startMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS); // We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
607
646
|
// This means that we can not track if it has been removed from the unconfirmed array or not.
|
|
608
647
|
// Origins points to the original transaction that the step was created in. This is never changed
|
|
609
648
|
// and gets passed down when a step is rebased.
|
|
649
|
+
|
|
610
650
|
unconfirmedTrs = unconfirmedState.origins;
|
|
611
651
|
lastTr = unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
612
652
|
isLastTrConfirmed = false;
|
|
613
653
|
|
|
614
|
-
case
|
|
654
|
+
case 4:
|
|
615
655
|
if (isLastTrConfirmed) {
|
|
616
|
-
_context3.next =
|
|
656
|
+
_context3.next = 17;
|
|
617
657
|
break;
|
|
618
658
|
}
|
|
619
659
|
|
|
620
660
|
_this.sendStepsFromCurrentState();
|
|
621
661
|
|
|
622
|
-
_context3.next =
|
|
623
|
-
return (0, _utils.sleep)(
|
|
662
|
+
_context3.next = 8;
|
|
663
|
+
return (0, _utils.sleep)(1000);
|
|
624
664
|
|
|
625
|
-
case
|
|
665
|
+
case 8:
|
|
626
666
|
nextUnconfirmedState = _this.getUnconfirmedSteps();
|
|
627
667
|
|
|
628
668
|
if (nextUnconfirmedState && nextUnconfirmedState.steps.length) {
|
|
@@ -635,7 +675,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
635
675
|
}
|
|
636
676
|
|
|
637
677
|
if (!(!isLastTrConfirmed && count++ >= maxAttemptsToSync)) {
|
|
638
|
-
_context3.next =
|
|
678
|
+
_context3.next = 15;
|
|
639
679
|
break;
|
|
640
680
|
}
|
|
641
681
|
|
|
@@ -651,13 +691,37 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
651
691
|
});
|
|
652
692
|
}
|
|
653
693
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
694
|
+
_measure2 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS);
|
|
695
|
+
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
696
|
+
eventAction: _const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS,
|
|
697
|
+
attributes: {
|
|
698
|
+
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
699
|
+
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration,
|
|
700
|
+
documentAri: _this.config.documentAri,
|
|
701
|
+
// upon failure, emit the number of unconfirmed steps we attempted to sync
|
|
702
|
+
numUnconfirmedSteps: nextUnconfirmedState === null || nextUnconfirmedState === void 0 ? void 0 : nextUnconfirmedState.steps.length
|
|
703
|
+
}
|
|
704
|
+
}, _this.analyticsClient);
|
|
705
|
+
throw new Error("Can't sync up with Collab Service");
|
|
706
|
+
|
|
707
|
+
case 15:
|
|
708
|
+
_context3.next = 4;
|
|
658
709
|
break;
|
|
659
710
|
|
|
660
|
-
case
|
|
711
|
+
case 17:
|
|
712
|
+
measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS);
|
|
713
|
+
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
714
|
+
eventAction: _const.EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS,
|
|
715
|
+
attributes: {
|
|
716
|
+
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
717
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
718
|
+
documentAri: _this.config.documentAri,
|
|
719
|
+
// upon success, emit the total number of unconfirmed steps we synced
|
|
720
|
+
numUnconfirmedSteps: unconfirmedState.steps.length
|
|
721
|
+
}
|
|
722
|
+
}, _this.analyticsClient);
|
|
723
|
+
|
|
724
|
+
case 19:
|
|
661
725
|
case "end":
|
|
662
726
|
return _context3.stop();
|
|
663
727
|
}
|
|
@@ -681,12 +745,12 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
681
745
|
}
|
|
682
746
|
}, _this.analyticsClient);
|
|
683
747
|
} catch (error) {
|
|
684
|
-
|
|
748
|
+
_measure3 = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.CONVERT_PM_TO_ADF);
|
|
685
749
|
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
686
750
|
eventAction: _const.EVENT_ACTION.CONVERT_PM_TO_ADF,
|
|
687
751
|
attributes: {
|
|
688
752
|
eventStatus: _const.EVENT_STATUS.FAILURE,
|
|
689
|
-
latency:
|
|
753
|
+
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
690
754
|
error: error,
|
|
691
755
|
documentAri: _this.config.documentAri
|
|
692
756
|
}
|
|
@@ -707,6 +771,54 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
707
771
|
}
|
|
708
772
|
}, _callee4);
|
|
709
773
|
})));
|
|
774
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
775
|
+
var _ref18 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(data) {
|
|
776
|
+
var isLocked, waitTimeInMs, timestamp, start;
|
|
777
|
+
return _regenerator.default.wrap(function _callee5$(_context5) {
|
|
778
|
+
while (1) {
|
|
779
|
+
switch (_context5.prev = _context5.next) {
|
|
780
|
+
case 0:
|
|
781
|
+
isLocked = data.isLocked, waitTimeInMs = data.waitTimeInMs, timestamp = data.timestamp;
|
|
782
|
+
start = Date.now();
|
|
783
|
+
logger("Received a namespace status changed event ", {
|
|
784
|
+
data: data
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
if (!(isLocked && waitTimeInMs)) {
|
|
788
|
+
_context5.next = 8;
|
|
789
|
+
break;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
_this.isNamespaceLocked = true;
|
|
793
|
+
logger("Received a namespace status change event ", {
|
|
794
|
+
isLocked: isLocked
|
|
795
|
+
}); // To protect the collab editing process from locked out due to BE
|
|
796
|
+
|
|
797
|
+
setTimeout(function () {
|
|
798
|
+
logger("The namespace lock has expired", {
|
|
799
|
+
waitTime: Date.now() - start,
|
|
800
|
+
timestamp: timestamp
|
|
801
|
+
});
|
|
802
|
+
_this.isNamespaceLocked = false;
|
|
803
|
+
}, waitTimeInMs);
|
|
804
|
+
return _context5.abrupt("return");
|
|
805
|
+
|
|
806
|
+
case 8:
|
|
807
|
+
_this.isNamespaceLocked = false;
|
|
808
|
+
logger("The page lock has expired");
|
|
809
|
+
|
|
810
|
+
case 10:
|
|
811
|
+
case "end":
|
|
812
|
+
return _context5.stop();
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}, _callee5);
|
|
816
|
+
}));
|
|
817
|
+
|
|
818
|
+
return function (_x2) {
|
|
819
|
+
return _ref18.apply(this, arguments);
|
|
820
|
+
};
|
|
821
|
+
}());
|
|
710
822
|
_this.config = config;
|
|
711
823
|
_this.channel = new _channel.Channel(config);
|
|
712
824
|
_this.isChannelInitialized = false;
|
|
@@ -732,9 +844,9 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
732
844
|
}
|
|
733
845
|
}, {
|
|
734
846
|
key: "setup",
|
|
735
|
-
value: function setup(
|
|
736
|
-
var getState =
|
|
737
|
-
onSyncUpError =
|
|
847
|
+
value: function setup(_ref19) {
|
|
848
|
+
var getState = _ref19.getState,
|
|
849
|
+
onSyncUpError = _ref19.onSyncUpError;
|
|
738
850
|
this.getState = getState;
|
|
739
851
|
this.onSyncUpError = onSyncUpError || noop;
|
|
740
852
|
this.clientId = getState().plugins.find(function (p) {
|
|
@@ -781,15 +893,21 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
781
893
|
return;
|
|
782
894
|
}
|
|
783
895
|
|
|
896
|
+
if (this.isNamespaceLocked) {
|
|
897
|
+
logger('The document is temporary locked');
|
|
898
|
+
return;
|
|
899
|
+
}
|
|
900
|
+
|
|
784
901
|
var steps = sendable.steps;
|
|
785
902
|
|
|
786
903
|
if (!steps || !steps.length) {
|
|
787
904
|
return;
|
|
788
|
-
}
|
|
905
|
+
}
|
|
906
|
+
|
|
907
|
+
(0, _performance.startMeasure)(_performance.MEASURE_NAME.ADD_STEPS); // Avoid reference issues using a
|
|
789
908
|
// method outside of the provider
|
|
790
909
|
// scope
|
|
791
910
|
|
|
792
|
-
|
|
793
911
|
throttledCommitStep({
|
|
794
912
|
channel: this.channel,
|
|
795
913
|
userId: this.userId,
|
|
@@ -797,10 +915,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
797
915
|
steps: steps,
|
|
798
916
|
version: version
|
|
799
917
|
});
|
|
800
|
-
}
|
|
801
|
-
/**
|
|
802
|
-
* Called when we receive steps from the service
|
|
803
|
-
*/
|
|
918
|
+
} // Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
804
919
|
|
|
805
920
|
}, {
|
|
806
921
|
key: "queueSteps",
|
|
@@ -844,22 +959,24 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
844
959
|
logger("Processing data. Version \"".concat(version, "\"."));
|
|
845
960
|
|
|
846
961
|
if (steps && steps.length) {
|
|
847
|
-
var clientIds = steps.map(function (
|
|
848
|
-
var clientId =
|
|
962
|
+
var clientIds = steps.map(function (_ref20) {
|
|
963
|
+
var clientId = _ref20.clientId;
|
|
849
964
|
return clientId;
|
|
850
965
|
});
|
|
851
966
|
this.emit('data', {
|
|
852
967
|
json: steps,
|
|
853
968
|
version: version,
|
|
854
969
|
userIds: clientIds
|
|
855
|
-
}); // If steps can apply to local editor
|
|
970
|
+
}); // If steps can apply to local editor successfully, no need to accumulate the error counter.
|
|
856
971
|
|
|
857
972
|
this.stepRejectCounter = 0;
|
|
973
|
+
var measure = (0, _performance.stopMeasure)(_performance.MEASURE_NAME.ADD_STEPS);
|
|
858
974
|
(0, _analytics.triggerCollabAnalyticsEvent)({
|
|
859
975
|
eventAction: _const.EVENT_ACTION.ADD_STEPS,
|
|
860
976
|
attributes: {
|
|
861
977
|
eventStatus: _const.EVENT_STATUS.SUCCESS,
|
|
862
|
-
documentAri: this.config.documentAri
|
|
978
|
+
documentAri: this.config.documentAri,
|
|
979
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
863
980
|
}
|
|
864
981
|
}, this.analyticsClient);
|
|
865
982
|
this.emitTelepointersFromSteps(steps); // Resend local steps if none of the received steps originated with us!
|
|
@@ -913,14 +1030,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
913
1030
|
participant = _Array$from$filter2[0];
|
|
914
1031
|
|
|
915
1032
|
if (participant) {
|
|
916
|
-
var
|
|
917
|
-
stepType =
|
|
918
|
-
to =
|
|
919
|
-
from =
|
|
920
|
-
|
|
921
|
-
slice =
|
|
1033
|
+
var _ref21 = step,
|
|
1034
|
+
stepType = _ref21.stepType,
|
|
1035
|
+
to = _ref21.to,
|
|
1036
|
+
from = _ref21.from,
|
|
1037
|
+
_ref21$slice = _ref21.slice,
|
|
1038
|
+
slice = _ref21$slice === void 0 ? {
|
|
922
1039
|
content: []
|
|
923
|
-
} :
|
|
1040
|
+
} : _ref21$slice;
|
|
924
1041
|
|
|
925
1042
|
var _slice$content = (0, _slicedToArray2.default)(slice.content, 1),
|
|
926
1043
|
node = _slice$content[0];
|
|
@@ -992,6 +1109,10 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
992
1109
|
this.channel.disconnect();
|
|
993
1110
|
return this;
|
|
994
1111
|
}
|
|
1112
|
+
/**
|
|
1113
|
+
* ESS-2916 namespace status event- lock/unlock
|
|
1114
|
+
*/
|
|
1115
|
+
|
|
995
1116
|
}]);
|
|
996
1117
|
return Provider;
|
|
997
1118
|
}(_emitter.Emitter);
|
|
@@ -31,6 +31,7 @@ function createSocketIOSocket(url, auth, productInfo) {
|
|
|
31
31
|
reconnectionDelayMax: _config.SOCKET_IO_OPTIONS.RECONNECTION_DELAY_MAX,
|
|
32
32
|
reconnectionDelay: _config.SOCKET_IO_OPTIONS.RECONNECTION_DELAY,
|
|
33
33
|
randomizationFactor: _config.SOCKET_IO_OPTIONS.RANDOMIZATION_FACTOR,
|
|
34
|
+
closeOnBeforeunload: false,
|
|
34
35
|
withCredentials: true,
|
|
35
36
|
transports: ['polling', 'websocket'],
|
|
36
37
|
path: "/".concat(pathname.split('/')[1], "/socket.io"),
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
|
+
var name = "@atlaskit/collab-provider";
|
|
8
|
+
exports.name = name;
|
|
9
|
+
var version = "7.7.0";
|
|
10
|
+
exports.version = version;
|
|
11
|
+
|
|
12
|
+
var nextMajorVersion = function nextMajorVersion() {
|
|
13
|
+
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.nextMajorVersion = nextMajorVersion;
|
package/dist/cjs/version.json
CHANGED