@atlaskit/collab-provider 10.3.0 → 10.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/analytics/analytics-helper.js +10 -0
- package/dist/cjs/analytics/performance.js +4 -1
- package/dist/cjs/api/null-api.js +3 -1
- package/dist/cjs/channel.js +22 -1
- package/dist/cjs/connectivity/network.js +8 -0
- package/dist/cjs/connectivity/reconnect-helper.js +4 -0
- package/dist/cjs/document/catchupv2.js +8 -1
- package/dist/cjs/document/document-service.js +65 -4
- package/dist/cjs/emitter.js +10 -0
- package/dist/cjs/helpers/utils.js +16 -7
- package/dist/cjs/metadata/metadata-service.js +4 -1
- package/dist/cjs/namespace/namespace-service.js +2 -0
- package/dist/cjs/participants/participants-service.js +6 -0
- package/dist/cjs/provider/commit-step.js +7 -2
- package/dist/cjs/provider/index.js +19 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/analytics/analytics-helper.js +10 -0
- package/dist/es2019/analytics/performance.js +4 -1
- package/dist/es2019/api/null-api.js +2 -0
- package/dist/es2019/channel.js +26 -0
- package/dist/es2019/connectivity/network.js +8 -0
- package/dist/es2019/connectivity/reconnect-helper.js +4 -0
- package/dist/es2019/document/catchupv2.js +8 -1
- package/dist/es2019/document/document-service.js +67 -4
- package/dist/es2019/emitter.js +11 -0
- package/dist/es2019/helpers/utils.js +10 -2
- package/dist/es2019/metadata/metadata-service.js +4 -1
- package/dist/es2019/namespace/namespace-service.js +2 -0
- package/dist/es2019/participants/participants-service.js +6 -0
- package/dist/es2019/provider/commit-step.js +8 -3
- package/dist/es2019/provider/index.js +19 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/analytics/analytics-helper.js +10 -0
- package/dist/esm/analytics/performance.js +4 -1
- package/dist/esm/api/null-api.js +3 -1
- package/dist/esm/channel.js +22 -1
- package/dist/esm/connectivity/network.js +8 -0
- package/dist/esm/connectivity/reconnect-helper.js +4 -0
- package/dist/esm/document/catchupv2.js +8 -1
- package/dist/esm/document/document-service.js +68 -4
- package/dist/esm/emitter.js +11 -0
- package/dist/esm/helpers/utils.js +16 -7
- package/dist/esm/metadata/metadata-service.js +4 -1
- package/dist/esm/namespace/namespace-service.js +2 -0
- package/dist/esm/participants/participants-service.js +6 -0
- package/dist/esm/provider/commit-step.js +8 -3
- package/dist/esm/provider/index.js +19 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/document/document-service.d.ts +4 -2
- package/dist/types-ts4.5/document/document-service.d.ts +4 -2
- package/package.json +6 -3
- package/tsconfig.json +0 -1
|
@@ -37,6 +37,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
|
|
|
37
37
|
if (analyticsEvent.eventAction === EVENT_ACTION.ERROR) {
|
|
38
38
|
payload.nonPrivacySafeAttributes = analyticsEvent.nonPrivacySafeAttributes;
|
|
39
39
|
try {
|
|
40
|
+
// Ignored via go/ees005
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
40
42
|
var requestIdleCallbackFunction = window.requestIdleCallback;
|
|
41
43
|
var runItLater = typeof requestIdleCallbackFunction === 'function' ? requestIdleCallbackFunction : window.requestAnimationFrame;
|
|
42
44
|
runItLater(function () {
|
|
@@ -49,6 +51,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
|
|
|
49
51
|
// Let the browser figure out
|
|
50
52
|
// when it should send those events
|
|
51
53
|
try {
|
|
54
|
+
// Ignored via go/ees005
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
56
|
var _requestIdleCallbackFunction = window.requestIdleCallback;
|
|
53
57
|
var _runItLater = typeof _requestIdleCallbackFunction === 'function' ? _requestIdleCallbackFunction : window.requestAnimationFrame;
|
|
54
58
|
_runItLater(function () {
|
|
@@ -60,6 +64,8 @@ var triggerAnalyticsEvent = function triggerAnalyticsEvent(analyticsEvent, analy
|
|
|
60
64
|
}
|
|
61
65
|
};
|
|
62
66
|
var AnalyticsHelper = /*#__PURE__*/function () {
|
|
67
|
+
// Ignored via go/ees005
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
63
69
|
function AnalyticsHelper(documentAri, subProduct, analyticsClient, getAnalyticsClient) {
|
|
64
70
|
_classCallCheck(this, AnalyticsHelper);
|
|
65
71
|
this.documentAri = documentAri;
|
|
@@ -82,7 +88,11 @@ var AnalyticsHelper = /*#__PURE__*/function () {
|
|
|
82
88
|
subProduct: this.subProduct,
|
|
83
89
|
errorMessage: errorMessage,
|
|
84
90
|
errorName: error instanceof Error ? error.name : undefined,
|
|
91
|
+
// Ignored via go/ees005
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
85
93
|
errorCode: (_data$code = (_data = error.data) === null || _data === void 0 ? void 0 : _data.code) !== null && _data$code !== void 0 ? _data$code : undefined,
|
|
94
|
+
// Ignored via go/ees005
|
|
95
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
86
96
|
errorStatus: (_data$status = (_data2 = error.data) === null || _data2 === void 0 ? void 0 : _data2.status) !== null && _data$status !== void 0 ? _data$status : undefined,
|
|
87
97
|
errorStack: error instanceof Error && loggableErrorName.includes(error.name) ? error.stack : undefined,
|
|
88
98
|
originalErrorMessage: this.getUGCFreeErrorMessage(error)
|
|
@@ -9,7 +9,10 @@ export var MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
|
|
|
9
9
|
return MEASURE_NAME;
|
|
10
10
|
}({});
|
|
11
11
|
export var isPerformanceAPIAvailable = function isPerformanceAPIAvailable() {
|
|
12
|
-
return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(
|
|
12
|
+
return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
function (api) {
|
|
13
16
|
return !!performance[api];
|
|
14
17
|
});
|
|
15
18
|
};
|
package/dist/esm/api/null-api.js
CHANGED
|
@@ -9,7 +9,9 @@ export var NullApi = /*#__PURE__*/function () {
|
|
|
9
9
|
}
|
|
10
10
|
return _createClass(NullApi, [{
|
|
11
11
|
key: "addComment",
|
|
12
|
-
value:
|
|
12
|
+
value: // Ignored via go/ees005
|
|
13
|
+
// eslint-disable-next-line require-await
|
|
14
|
+
function () {
|
|
13
15
|
var _addComment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
14
16
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
15
17
|
while (1) switch (_context.prev = _context.next) {
|
package/dist/esm/channel.js
CHANGED
|
@@ -161,6 +161,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
161
161
|
_defineProperty(_this, "onConnect", function () {
|
|
162
162
|
var _this$analyticsHelper5;
|
|
163
163
|
_this.connected = true;
|
|
164
|
+
// Ignored via go/ees005
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
164
166
|
logger('Connected.', _this.socket.id);
|
|
165
167
|
var measure = stopMeasure(MEASURE_NAME.SOCKET_CONNECT, _this.analyticsHelper);
|
|
166
168
|
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 || _this$analyticsHelper5.sendActionEvent(EVENT_ACTION.CONNECTION, EVENT_STATUS.SUCCESS, {
|
|
@@ -170,12 +172,19 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
170
172
|
usedCachedToken: !!_this.token
|
|
171
173
|
});
|
|
172
174
|
_this.emit('connected', {
|
|
175
|
+
// Ignored via go/ees005
|
|
176
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
173
177
|
sid: _this.socket.id,
|
|
174
178
|
initialized: _this.initialized
|
|
175
179
|
});
|
|
176
180
|
});
|
|
181
|
+
// Ignored via go/ees005
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
177
183
|
_defineProperty(_this, "onReceiveData", function (data) {
|
|
178
184
|
logger('Received data', data);
|
|
185
|
+
|
|
186
|
+
// Ignored via go/ees005
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
179
188
|
logger('Session ID is', _this.socket.id);
|
|
180
189
|
if (data.type === 'initial') {
|
|
181
190
|
if (!_this.initialized) {
|
|
@@ -219,6 +228,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
219
228
|
_this.emit('steps:added', data);
|
|
220
229
|
}
|
|
221
230
|
});
|
|
231
|
+
// Ignored via go/ees005
|
|
232
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
222
233
|
_defineProperty(_this, "fetchCatchupv2", /*#__PURE__*/function () {
|
|
223
234
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(fromVersion, clientId, catchUpOutofSync, reason) {
|
|
224
235
|
var _yield$utils$requestS, steps, metadata, errorNotFound, errorCatchupv2;
|
|
@@ -305,7 +316,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
305
316
|
doc: currentStateDoc,
|
|
306
317
|
productId: 'ccollab',
|
|
307
318
|
reason: reason
|
|
308
|
-
});
|
|
319
|
+
}); // Ignored via go/ees005
|
|
320
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
309
321
|
_context3.t0 = utils;
|
|
310
322
|
_context3.t1 = _this.config;
|
|
311
323
|
_context3.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/reconcile");
|
|
@@ -472,6 +484,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
472
484
|
code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
|
|
473
485
|
meta: {
|
|
474
486
|
originalError: _context4.t0,
|
|
487
|
+
// Ignored via go/ees005
|
|
488
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
475
489
|
reason: _context4.t0 === null || _context4.t0 === void 0 || (_data = _context4.t0.data) === null || _data === void 0 || (_data = _data.meta) === null || _data === void 0 ? void 0 : _data.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
|
|
476
490
|
// https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
|
|
477
491
|
}
|
|
@@ -489,6 +503,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
489
503
|
};
|
|
490
504
|
}();
|
|
491
505
|
} else {
|
|
506
|
+
// Ignored via go/ees005
|
|
507
|
+
// eslint-disable-next-line require-await
|
|
492
508
|
auth = /*#__PURE__*/function () {
|
|
493
509
|
var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(cb) {
|
|
494
510
|
var authData;
|
|
@@ -571,6 +587,8 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
571
587
|
this.socket.on('status', function (data) {
|
|
572
588
|
_this2.emit('status', data);
|
|
573
589
|
});
|
|
590
|
+
// Ignored via go/ees005
|
|
591
|
+
// eslint-disable-next-line require-await
|
|
574
592
|
this.socket.on('disconnect', /*#__PURE__*/function () {
|
|
575
593
|
var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(reason) {
|
|
576
594
|
var _this2$analyticsHelpe, reconnectionError;
|
|
@@ -637,6 +655,9 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
637
655
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
638
656
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
639
657
|
}
|
|
658
|
+
|
|
659
|
+
// Ignored via go/ees005
|
|
660
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
640
661
|
}, {
|
|
641
662
|
key: "onAnyOutgoingHandler",
|
|
642
663
|
value: function onAnyOutgoingHandler(currentTimeMs, args) {
|
|
@@ -26,7 +26,11 @@ var Network = /*#__PURE__*/function () {
|
|
|
26
26
|
this.onlineCallback = props.onlineCallback;
|
|
27
27
|
}
|
|
28
28
|
if (typeof window !== 'undefined') {
|
|
29
|
+
// Ignored via go/ees005
|
|
30
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
29
31
|
window.addEventListener('offline', this.offlineHandler);
|
|
32
|
+
// Ignored via go/ees005
|
|
33
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
30
34
|
window.addEventListener('online', this.onlineHandler);
|
|
31
35
|
}
|
|
32
36
|
}
|
|
@@ -38,7 +42,11 @@ var Network = /*#__PURE__*/function () {
|
|
|
38
42
|
}, {
|
|
39
43
|
key: "destroy",
|
|
40
44
|
value: function destroy() {
|
|
45
|
+
// Ignored via go/ees005
|
|
46
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
41
47
|
window.removeEventListener('offline', this.offlineHandler);
|
|
48
|
+
// Ignored via go/ees005
|
|
49
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
42
50
|
window.removeEventListener('online', this.onlineHandler);
|
|
43
51
|
}
|
|
44
52
|
}]);
|
|
@@ -15,6 +15,8 @@ var ReconnectHelper = /*#__PURE__*/function () {
|
|
|
15
15
|
_defineProperty(this, "onlineHandler", function () {
|
|
16
16
|
_this.failedReconnectCount = 0;
|
|
17
17
|
});
|
|
18
|
+
// Ignored via go/ees005
|
|
19
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
18
20
|
window.addEventListener('online', this.onlineHandler);
|
|
19
21
|
}
|
|
20
22
|
return _createClass(ReconnectHelper, [{
|
|
@@ -34,6 +36,8 @@ var ReconnectHelper = /*#__PURE__*/function () {
|
|
|
34
36
|
}, {
|
|
35
37
|
key: "destroy",
|
|
36
38
|
value: function destroy() {
|
|
39
|
+
// Ignored via go/ees005
|
|
40
|
+
// eslint-disable-next-line @repo/internal/dom-events/no-unsafe-event-listeners
|
|
37
41
|
window.removeEventListener('online', this.onlineHandler);
|
|
38
42
|
}
|
|
39
43
|
}]);
|
|
@@ -8,6 +8,10 @@ export var catchupv2 = /*#__PURE__*/function () {
|
|
|
8
8
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
9
9
|
while (1) switch (_context.prev = _context.next) {
|
|
10
10
|
case 0:
|
|
11
|
+
// Ignored via go/ees005
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
// Ignored via go/ees005
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
15
|
fromVersion = opt.getCurrentPmVersion();
|
|
12
16
|
_context.prev = 1;
|
|
13
17
|
_context.next = 4;
|
|
@@ -66,7 +70,10 @@ export var catchupv2 = /*#__PURE__*/function () {
|
|
|
66
70
|
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
67
71
|
* @returns True if we're out of sync, false if not.
|
|
68
72
|
*/
|
|
69
|
-
export var isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId
|
|
73
|
+
export var isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId
|
|
74
|
+
// Ignored via go/ees005
|
|
75
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
76
|
+
) {
|
|
70
77
|
return (
|
|
71
78
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
72
79
|
Boolean(fromVersion >= currentVersion && steps.some(function (step) {
|
|
@@ -38,13 +38,20 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
38
38
|
* @param onErrorHandled - Callback to handle
|
|
39
39
|
* @param metadataService
|
|
40
40
|
* @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
|
|
41
|
+
* @param getConnected - if the channel is currently connected
|
|
41
42
|
*/
|
|
42
|
-
|
|
43
|
+
// Ignored via go/ees005
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
45
|
+
function DocumentService(participantsService, analyticsHelper, fetchCatchupv2, fetchReconcile,
|
|
46
|
+
// Ignored via go/ees005
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService, isNameSpaceLocked) {
|
|
43
49
|
var _this = this;
|
|
44
50
|
var enableErrorOnFailedDocumentApply = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : false;
|
|
45
51
|
var options = arguments.length > 11 && arguments[11] !== undefined ? arguments[11] : {
|
|
46
52
|
__livePage: false
|
|
47
53
|
};
|
|
54
|
+
var getConnected = arguments.length > 12 ? arguments[12] : undefined;
|
|
48
55
|
_classCallCheck(this, DocumentService);
|
|
49
56
|
// Fires analytics to editor when collab editor cannot sync up
|
|
50
57
|
_defineProperty(this, "stepRejectCounter", 0);
|
|
@@ -143,6 +150,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
143
150
|
}
|
|
144
151
|
return _this.getVersionFromCollabState(state, 'collab-provider: getCurrentPmVersion');
|
|
145
152
|
});
|
|
153
|
+
// Ignored via go/ees005
|
|
154
|
+
// eslint-disable-next-line require-await
|
|
146
155
|
_defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
147
156
|
var _this$getState2, _this$analyticsHelper5, _this$analyticsHelper4, state, adfDocument, version, currentState, measure, _this$analyticsHelper6, _this$analyticsHelper7, _measure;
|
|
148
157
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
@@ -155,6 +164,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
155
164
|
if (!((_this$getState2 = _this.getState) !== null && _this$getState2 !== void 0 && _this$getState2.call(_this))) {
|
|
156
165
|
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 || _this$analyticsHelper4.sendErrorEvent(new Error('Editor state is undefined'), 'getCurrentState called without state');
|
|
157
166
|
}
|
|
167
|
+
// Ignored via go/ees005
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
158
169
|
state = _this.getState();
|
|
159
170
|
adfDocument = new JSONTransformer().encode(state.doc);
|
|
160
171
|
version = _this.getVersionFromCollabState(state, 'collab-provider: getCurrentState');
|
|
@@ -192,11 +203,15 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
192
203
|
var clientId = _ref3.clientId;
|
|
193
204
|
return clientId;
|
|
194
205
|
}));
|
|
206
|
+
// Ignored via go/ees005
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
195
208
|
if (!clientIds.has(_this.clientId)) {
|
|
196
209
|
var userIds = new Set(steps.map(function (_ref4) {
|
|
197
210
|
var userId = _ref4.userId;
|
|
198
211
|
return userId;
|
|
199
212
|
}));
|
|
213
|
+
// Ignored via go/ees005
|
|
214
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
200
215
|
if (userIds.has(_this.getUserId())) {
|
|
201
216
|
return true;
|
|
202
217
|
}
|
|
@@ -465,6 +480,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
465
480
|
} : {}));
|
|
466
481
|
_this.updateDocumentAnalytics(doc, version);
|
|
467
482
|
});
|
|
483
|
+
// Ignored via go/ees005
|
|
484
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
468
485
|
_defineProperty(this, "updateDocumentAnalytics", function (doc, version) {
|
|
469
486
|
var updatedVersion = _this.getCurrentPmVersion();
|
|
470
487
|
var isDocContentValid = _this.validatePMJSONDocument(doc);
|
|
@@ -506,6 +523,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
506
523
|
});
|
|
507
524
|
}
|
|
508
525
|
});
|
|
526
|
+
// Ignored via go/ees005
|
|
527
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
509
528
|
_defineProperty(this, "validatePMJSONDocument", function (doc) {
|
|
510
529
|
try {
|
|
511
530
|
var _this$getState5;
|
|
@@ -513,7 +532,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
513
532
|
var _this$analyticsHelper22;
|
|
514
533
|
(_this$analyticsHelper22 = _this.analyticsHelper) === null || _this$analyticsHelper22 === void 0 || _this$analyticsHelper22.sendErrorEvent(new Error('Editor state is undefined'), 'validatePMJSONDocument called without state');
|
|
515
534
|
}
|
|
535
|
+
// Ignored via go/ees005
|
|
536
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
516
537
|
var state = _this.getState();
|
|
538
|
+
// Ignored via go/ees005
|
|
539
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
517
540
|
var content = (doc.content || []).map(function (child) {
|
|
518
541
|
return state.schema.nodeFromJSON(child);
|
|
519
542
|
});
|
|
@@ -578,6 +601,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
578
601
|
break;
|
|
579
602
|
}
|
|
580
603
|
if (_this.onSyncUpError) {
|
|
604
|
+
// Ignored via go/ees005
|
|
605
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
581
606
|
state = _this.getState();
|
|
582
607
|
version = _this.getVersionFromCollabState(state, 'collab-provider: commitUnconfirmedSteps');
|
|
583
608
|
_this.onSyncUpError({
|
|
@@ -658,6 +683,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
658
683
|
this.isNameSpaceLocked = isNameSpaceLocked;
|
|
659
684
|
this.enableErrorOnFailedDocumentApply = enableErrorOnFailedDocumentApply;
|
|
660
685
|
this.options = options;
|
|
686
|
+
this.getConnected = getConnected;
|
|
661
687
|
this.stepQueue = new StepQueueState();
|
|
662
688
|
this.onErrorHandled = onErrorHandled;
|
|
663
689
|
}
|
|
@@ -690,9 +716,15 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
690
716
|
if (this.stepQueue.getQueue().length > 0) {
|
|
691
717
|
var firstItem = this.stepQueue.shift();
|
|
692
718
|
var currentVersion = this.getCurrentPmVersion();
|
|
719
|
+
// Ignored via go/ees005
|
|
720
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
693
721
|
var expectedVersion = currentVersion + firstItem.steps.length;
|
|
722
|
+
// Ignored via go/ees005
|
|
723
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
694
724
|
if (firstItem.version === expectedVersion) {
|
|
695
725
|
logger("Applying data from queue!");
|
|
726
|
+
// Ignored via go/ees005
|
|
727
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
696
728
|
this.processSteps(firstItem);
|
|
697
729
|
// recur
|
|
698
730
|
this.processQueue();
|
|
@@ -722,6 +754,8 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
722
754
|
this.participantsService.emitTelepointersFromSteps(steps);
|
|
723
755
|
|
|
724
756
|
// Resend local steps if none of the received steps originated with us!
|
|
757
|
+
// Ignored via go/ees005
|
|
758
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
725
759
|
if (clientIds.indexOf(this.clientId) === -1) {
|
|
726
760
|
setTimeout(function () {
|
|
727
761
|
return _this2.sendStepsFromCurrentState();
|
|
@@ -780,13 +814,21 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
780
814
|
* Send steps from transaction to other participants
|
|
781
815
|
* It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
|
|
782
816
|
*/
|
|
817
|
+
// Ignored via go/ees005
|
|
818
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
783
819
|
function send(_tr, _oldState, newState, sendAnalyticsEvent) {
|
|
784
820
|
var unconfirmedStepsData = sendableSteps(newState);
|
|
785
821
|
var version = this.getVersionFromCollabState(newState, 'collab-provider: send');
|
|
786
822
|
|
|
787
823
|
// Don't send any steps before we're ready.
|
|
788
|
-
if (
|
|
789
|
-
|
|
824
|
+
if (fg('platform_editor_merge_unconfirmed_steps')) {
|
|
825
|
+
if (!unconfirmedStepsData || !this.getConnected()) {
|
|
826
|
+
return;
|
|
827
|
+
}
|
|
828
|
+
} else {
|
|
829
|
+
if (!unconfirmedStepsData) {
|
|
830
|
+
return;
|
|
831
|
+
}
|
|
790
832
|
}
|
|
791
833
|
var unconfirmedSteps = unconfirmedStepsData.steps;
|
|
792
834
|
// sendAnalyticsEvent is only true when buffering is enabled,
|
|
@@ -802,12 +844,28 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
802
844
|
return;
|
|
803
845
|
}
|
|
804
846
|
|
|
847
|
+
// If we are going to commit unconfirmed steps
|
|
848
|
+
// we need to lock them to ensure they don't get
|
|
849
|
+
// mutated in: `packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts`
|
|
850
|
+
if (fg('platform_editor_merge_unconfirmed_steps')) {
|
|
851
|
+
unconfirmedStepsData.steps.forEach(function (s) {
|
|
852
|
+
if (isLockable(s)) {
|
|
853
|
+
var _s$lockStep;
|
|
854
|
+
(_s$lockStep = s.lockStep) === null || _s$lockStep === void 0 || _s$lockStep.call(s);
|
|
855
|
+
}
|
|
856
|
+
});
|
|
857
|
+
}
|
|
858
|
+
|
|
805
859
|
// Avoid reference issues using a
|
|
806
860
|
// method outside of the provider
|
|
807
861
|
// scope
|
|
808
862
|
commitStepQueue({
|
|
809
863
|
broadcast: this.broadcast,
|
|
864
|
+
// Ignored via go/ees005
|
|
865
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
810
866
|
userId: this.getUserId(),
|
|
867
|
+
// Ignored via go/ees005
|
|
868
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
811
869
|
clientId: this.clientId,
|
|
812
870
|
steps: unconfirmedSteps,
|
|
813
871
|
version: version,
|
|
@@ -819,4 +877,10 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
819
877
|
});
|
|
820
878
|
}
|
|
821
879
|
}]);
|
|
822
|
-
}();
|
|
880
|
+
}();
|
|
881
|
+
|
|
882
|
+
// Based on: packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts
|
|
883
|
+
|
|
884
|
+
function isLockable(step) {
|
|
885
|
+
return (step === null || step === void 0 ? void 0 : step.lockStep) !== undefined;
|
|
886
|
+
}
|
package/dist/esm/emitter.js
CHANGED
|
@@ -2,6 +2,9 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
|
2
2
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import { EventEmitter2 } from 'eventemitter2';
|
|
5
|
+
|
|
6
|
+
// Ignored via go/ees005
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
8
|
export var Emitter = /*#__PURE__*/function () {
|
|
6
9
|
function Emitter() {
|
|
7
10
|
_classCallCheck(this, Emitter);
|
|
@@ -14,6 +17,8 @@ export var Emitter = /*#__PURE__*/function () {
|
|
|
14
17
|
* Emit events to subscribers
|
|
15
18
|
*/
|
|
16
19
|
function emit(evt, data) {
|
|
20
|
+
// Ignored via go/ees005
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
22
|
this.eventEmitter.emit(evt, data);
|
|
18
23
|
return this;
|
|
19
24
|
}
|
|
@@ -24,6 +29,8 @@ export var Emitter = /*#__PURE__*/function () {
|
|
|
24
29
|
}, {
|
|
25
30
|
key: "on",
|
|
26
31
|
value: function on(evt, handler) {
|
|
32
|
+
// Ignored via go/ees005
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
27
34
|
this.eventEmitter.on(evt, handler);
|
|
28
35
|
return this;
|
|
29
36
|
}
|
|
@@ -34,6 +41,8 @@ export var Emitter = /*#__PURE__*/function () {
|
|
|
34
41
|
}, {
|
|
35
42
|
key: "off",
|
|
36
43
|
value: function off(evt, handler) {
|
|
44
|
+
// Ignored via go/ees005
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
46
|
this.eventEmitter.off(evt, handler);
|
|
38
47
|
return this;
|
|
39
48
|
}
|
|
@@ -44,6 +53,8 @@ export var Emitter = /*#__PURE__*/function () {
|
|
|
44
53
|
}, {
|
|
45
54
|
key: "unsubscribeAll",
|
|
46
55
|
value: function unsubscribeAll(evt) {
|
|
56
|
+
// Ignored via go/ees005
|
|
57
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
47
58
|
this.eventEmitter.removeAllListeners(evt);
|
|
48
59
|
return this;
|
|
49
60
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
export var createLogger = function createLogger(prefix) {
|
|
2
2
|
var color = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'blue';
|
|
3
|
-
return
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
return (
|
|
4
|
+
// Ignored via go/ees005
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
+
function (msg) {
|
|
7
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
8
|
+
// Ignored via go/ees005
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
if (window.COLLAB_PROVIDER_LOGGER) {
|
|
11
|
+
// eslint-disable-next-line no-console
|
|
12
|
+
console.log("%cCollab-".concat(prefix, ": ").concat(msg), "color: ".concat(color, "; font-weight: bold"), data);
|
|
13
|
+
}
|
|
8
14
|
}
|
|
9
|
-
|
|
15
|
+
);
|
|
10
16
|
};
|
|
11
17
|
export function sleep(ms) {
|
|
12
18
|
return new Promise(function (resolve) {
|
|
@@ -39,7 +45,10 @@ export var getStepUGCFreeDetails = function getStepUGCFreeDetails(step) {
|
|
|
39
45
|
}
|
|
40
46
|
var contentTypes = '';
|
|
41
47
|
if ((_stepJson$slice = stepJson.slice) !== null && _stepJson$slice !== void 0 && _stepJson$slice.content && Array.isArray((_stepJson$slice2 = stepJson.slice) === null || _stepJson$slice2 === void 0 ? void 0 : _stepJson$slice2.content)) {
|
|
42
|
-
contentTypes = stepJson.slice.content
|
|
48
|
+
contentTypes = stepJson.slice.content
|
|
49
|
+
// Ignored via go/ees005
|
|
50
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
+
.map(function (c) {
|
|
43
52
|
return (c === null || c === void 0 ? void 0 : c.type) || 'unknown';
|
|
44
53
|
}).join(', ');
|
|
45
54
|
}
|
|
@@ -3,7 +3,10 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
3
3
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
4
|
import isEqual from 'lodash/isEqual';
|
|
5
5
|
export var MetadataService = /*#__PURE__*/function () {
|
|
6
|
-
function MetadataService(
|
|
6
|
+
function MetadataService(
|
|
7
|
+
// Ignored via go/ees005
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
providerEmitCallback, broadcastMetadata) {
|
|
7
10
|
var _this = this;
|
|
8
11
|
_classCallCheck(this, MetadataService);
|
|
9
12
|
_defineProperty(this, "metadata", {});
|
|
@@ -21,6 +21,8 @@ export var NamespaceService = /*#__PURE__*/_createClass(function NamespaceServic
|
|
|
21
21
|
/**
|
|
22
22
|
* ESS-2916 namespace status event- lock/unlock
|
|
23
23
|
*/
|
|
24
|
+
// Ignored via go/ees005
|
|
25
|
+
// eslint-disable-next-line require-await
|
|
24
26
|
_defineProperty(this, "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
25
27
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
26
28
|
var isLocked, waitTimeInMs, timestamp, start;
|
|
@@ -24,6 +24,8 @@ var SEND_PRESENCE_INTERVAL = 150 * 1000; // 150 seconds
|
|
|
24
24
|
* @param sendPresenceJoined Callback to Channel class
|
|
25
25
|
*/
|
|
26
26
|
export var ParticipantsService = /*#__PURE__*/function () {
|
|
27
|
+
// Ignored via go/ees005
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/max-params
|
|
27
29
|
function ParticipantsService(analyticsHelper) {
|
|
28
30
|
var _this = this;
|
|
29
31
|
var participantsState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new ParticipantsState();
|
|
@@ -181,6 +183,8 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
181
183
|
try {
|
|
182
184
|
_this.emit('disconnected', {
|
|
183
185
|
reason: disconnectedReasonMapper(reason),
|
|
186
|
+
// Ignored via go/ees005
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
184
188
|
sid: sessionId
|
|
185
189
|
});
|
|
186
190
|
} catch (error) {
|
|
@@ -366,6 +370,8 @@ export var ParticipantsService = /*#__PURE__*/function () {
|
|
|
366
370
|
_defineProperty(this, "onPresence", function (payload) {
|
|
367
371
|
try {
|
|
368
372
|
logger('onPresence userId: ', payload.userId);
|
|
373
|
+
// Ignored via go/ees005
|
|
374
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
369
375
|
_this.setUserId(payload.userId);
|
|
370
376
|
_this.sendPresence();
|
|
371
377
|
_this.sendPresenceJoined();
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
4
|
import countBy from 'lodash/countBy';
|
|
5
|
-
import {
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
6
|
import { ADD_STEPS_TYPE, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
7
7
|
import { AcknowledgementResponseTypes } from '../types';
|
|
8
8
|
import { NCS_ERROR_CODE } from '../errors/ncs-errors';
|
|
@@ -47,7 +47,7 @@ export var commitStepQueue = function commitStepQueue(_ref) {
|
|
|
47
47
|
// - doesn't impact any indexes,
|
|
48
48
|
// - is setup for last write wins,
|
|
49
49
|
// - and is just a boolean -- so no real risk of data loss.
|
|
50
|
-
if (
|
|
50
|
+
if (__livePage && fg('platform.editor.live-pages-expand-divergence')) {
|
|
51
51
|
// @atlaskit/platform-feature-flags
|
|
52
52
|
stepsWithClientAndUserId = stepsWithClientAndUserId.map(function (step) {
|
|
53
53
|
if (isExpandChangeStep(step)) {
|
|
@@ -96,7 +96,10 @@ export var commitStepQueue = function commitStepQueue(_ref) {
|
|
|
96
96
|
analyticsHelper === null || analyticsHelper === void 0 || analyticsHelper.sendActionEvent(EVENT_ACTION.ADD_STEPS, EVENT_STATUS.SUCCESS_10x_SAMPLED, {
|
|
97
97
|
type: ADD_STEPS_TYPE.ACCEPTED,
|
|
98
98
|
latency: latency,
|
|
99
|
-
stepType: countBy(stepsWithClientAndUserId,
|
|
99
|
+
stepType: countBy(stepsWithClientAndUserId,
|
|
100
|
+
// Ignored via go/ees005
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
102
|
+
function (stepWithClientAndUserId) {
|
|
100
103
|
return stepWithClientAndUserId.stepType;
|
|
101
104
|
})
|
|
102
105
|
});
|
|
@@ -138,6 +141,8 @@ export var commitStepQueue = function commitStepQueue(_ref) {
|
|
|
138
141
|
}
|
|
139
142
|
};
|
|
140
143
|
function isExpandChangeStep(step) {
|
|
144
|
+
// Ignored via go/ees005
|
|
145
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
141
146
|
if (step.stepType === 'setAttrs' && '__expanded' in step.attrs) {
|
|
142
147
|
return true;
|
|
143
148
|
}
|
|
@@ -64,6 +64,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
64
64
|
* @param evt - Event name to emit to subscribers
|
|
65
65
|
* @param data - Event data to emit to subscribers
|
|
66
66
|
*/
|
|
67
|
+
// Ignored via go/ees005
|
|
68
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
69
|
_defineProperty(_this, "emitCallback", function (evt, data) {
|
|
68
70
|
return _this.emit(evt, data);
|
|
69
71
|
});
|
|
@@ -159,8 +161,14 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
159
161
|
});
|
|
160
162
|
_defineProperty(_this, "getPresenceData", function () {
|
|
161
163
|
return {
|
|
164
|
+
// Ignored via go/ees005
|
|
165
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
162
166
|
sessionId: _this.sessionId,
|
|
167
|
+
// Ignored via go/ees005
|
|
168
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
163
169
|
userId: _this.userId,
|
|
170
|
+
// Ignored via go/ees005
|
|
171
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
164
172
|
clientId: _this.clientId,
|
|
165
173
|
permit: _this.permit,
|
|
166
174
|
presenceId: _this.presenceId,
|
|
@@ -307,7 +315,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
307
315
|
return _this.userId;
|
|
308
316
|
}, _this.onErrorHandled, _this.metadataService, _this.namespaceService.getIsNamespaceLocked.bind(_this.namespaceService), _this.config.enableErrorOnFailedDocumentApply, {
|
|
309
317
|
__livePage: _this.config.__livePage || false
|
|
310
|
-
});
|
|
318
|
+
}, _this.channel.getConnected);
|
|
311
319
|
_this.api = new Api(config, _this.documentService, _this.channel);
|
|
312
320
|
}
|
|
313
321
|
_this.sendStepsTimer = setInterval(function () {
|
|
@@ -349,12 +357,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
349
357
|
onSyncUpError = _ref7.onSyncUpError;
|
|
350
358
|
this.checkForCookies();
|
|
351
359
|
try {
|
|
360
|
+
// Ignored via go/ees005
|
|
361
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
352
362
|
var collabPlugin = getState().plugins.find(function (p) {
|
|
353
363
|
return p.key === 'collab$';
|
|
354
364
|
});
|
|
355
365
|
if (collabPlugin === undefined) {
|
|
356
366
|
throw new ProviderInitialisationError('Collab provider attempted to initialise, but Editor state is missing collab plugin');
|
|
357
367
|
}
|
|
368
|
+
// Ignored via go/ees005
|
|
369
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
358
370
|
this.clientId = collabPlugin.spec.config.clientID;
|
|
359
371
|
|
|
360
372
|
// generate a temporary id as clientId when it is undefined
|
|
@@ -483,8 +495,14 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
483
495
|
key: "sendMessage",
|
|
484
496
|
value: function sendMessage(data) {
|
|
485
497
|
var basePayload = {
|
|
498
|
+
// Ignored via go/ees005
|
|
499
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
486
500
|
userId: this.userId,
|
|
501
|
+
// Ignored via go/ees005
|
|
502
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
487
503
|
sessionId: this.sessionId,
|
|
504
|
+
// Ignored via go/ees005
|
|
505
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
488
506
|
clientId: this.clientId,
|
|
489
507
|
permit: this.permit
|
|
490
508
|
};
|