@atlaskit/collab-provider 9.26.4 → 9.26.6
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 +13 -0
- package/dist/cjs/channel.js +115 -131
- package/dist/cjs/document/catchupv2.js +25 -27
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/channel.js +12 -19
- package/dist/es2019/document/catchupv2.js +16 -10
- package/dist/es2019/document/document-service.js +12 -0
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/channel.js +115 -131
- package/dist/esm/document/catchupv2.js +24 -26
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/channel.d.ts +1 -0
- package/dist/types/document/catchupv2.d.ts +10 -0
- package/dist/types-ts4.5/channel.d.ts +1 -0
- package/dist/types-ts4.5/document/catchupv2.d.ts +10 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.26.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#92490](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/92490) [`97780ddb724d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/97780ddb724d) - refactor channel to reduce code duplication
|
|
8
|
+
|
|
9
|
+
## 9.26.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#91579](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/91579) [`99a74057c77a`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/99a74057c77a) - Handle undefined steps in catchup v2
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
3
16
|
## 9.26.4
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/dist/cjs/channel.js
CHANGED
|
@@ -241,44 +241,21 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
241
241
|
version: fromVersion,
|
|
242
242
|
clientId: clientId
|
|
243
243
|
};
|
|
244
|
-
_context2.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
}
|
|
251
|
-
_context2.next = 11;
|
|
252
|
-
return _this.getChannelToken();
|
|
253
|
-
case 11:
|
|
254
|
-
_context2.t8 = _context2.sent;
|
|
255
|
-
_context2.t7 = {
|
|
256
|
-
'x-token': _context2.t8
|
|
257
|
-
};
|
|
258
|
-
_context2.next = 16;
|
|
259
|
-
break;
|
|
260
|
-
case 15:
|
|
261
|
-
_context2.t7 = {};
|
|
262
|
-
case 16:
|
|
263
|
-
_context2.t9 = _context2.t7;
|
|
264
|
-
_context2.t10 = (0, _context2.t5)(_context2.t6, _context2.t9);
|
|
265
|
-
_context2.t11 = {};
|
|
266
|
-
_context2.t12 = {
|
|
267
|
-
'x-product': (0, _utils.getProduct)(_this.config.productInfo),
|
|
268
|
-
'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo)
|
|
269
|
-
};
|
|
270
|
-
_context2.t13 = (0, _context2.t4)(_context2.t10, _context2.t11, _context2.t12);
|
|
271
|
-
_context2.t14 = {
|
|
272
|
-
headers: _context2.t13
|
|
244
|
+
_context2.next = 7;
|
|
245
|
+
return _this.commonHeaders();
|
|
246
|
+
case 7:
|
|
247
|
+
_context2.t4 = _context2.sent;
|
|
248
|
+
_context2.t5 = {
|
|
249
|
+
headers: _context2.t4
|
|
273
250
|
};
|
|
274
|
-
_context2.
|
|
251
|
+
_context2.t6 = {
|
|
275
252
|
path: _context2.t2,
|
|
276
253
|
queryParams: _context2.t3,
|
|
277
|
-
requestInit: _context2.
|
|
254
|
+
requestInit: _context2.t5
|
|
278
255
|
};
|
|
279
|
-
_context2.next =
|
|
280
|
-
return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.
|
|
281
|
-
case
|
|
256
|
+
_context2.next = 12;
|
|
257
|
+
return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t6);
|
|
258
|
+
case 12:
|
|
282
259
|
_yield$utils$requestS = _context2.sent;
|
|
283
260
|
doc = _yield$utils$requestS.doc;
|
|
284
261
|
version = _yield$utils$requestS.version;
|
|
@@ -290,38 +267,38 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
290
267
|
stepMaps: stepMaps,
|
|
291
268
|
metadata: metadata
|
|
292
269
|
});
|
|
293
|
-
case
|
|
294
|
-
_context2.prev =
|
|
295
|
-
_context2.
|
|
296
|
-
if (!(_context2.
|
|
297
|
-
_context2.next =
|
|
270
|
+
case 20:
|
|
271
|
+
_context2.prev = 20;
|
|
272
|
+
_context2.t7 = _context2["catch"](0);
|
|
273
|
+
if (!(_context2.t7.code === 404)) {
|
|
274
|
+
_context2.next = 26;
|
|
298
275
|
break;
|
|
299
276
|
}
|
|
300
277
|
errorNotFound = {
|
|
301
278
|
message: 'The requested document is not found',
|
|
302
279
|
data: {
|
|
303
|
-
status: _context2.
|
|
280
|
+
status: _context2.t7.code,
|
|
304
281
|
code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
305
282
|
}
|
|
306
283
|
};
|
|
307
284
|
_this.emit('error', errorNotFound);
|
|
308
285
|
return _context2.abrupt("return", {});
|
|
309
|
-
case
|
|
310
|
-
logger("Can't fetch the catchup", _context2.
|
|
286
|
+
case 26:
|
|
287
|
+
logger("Can't fetch the catchup", _context2.t7.message);
|
|
311
288
|
errorCatchup = {
|
|
312
289
|
message: 'Cannot fetch catchup from collab service',
|
|
313
290
|
data: {
|
|
314
|
-
status: _context2.
|
|
291
|
+
status: _context2.t7.status,
|
|
315
292
|
code: _internalErrors.INTERNAL_ERROR_CODE.CATCHUP_FAILED
|
|
316
293
|
}
|
|
317
294
|
};
|
|
318
295
|
_this.emit('error', errorCatchup);
|
|
319
|
-
throw _context2.
|
|
320
|
-
case
|
|
296
|
+
throw _context2.t7;
|
|
297
|
+
case 30:
|
|
321
298
|
case "end":
|
|
322
299
|
return _context2.stop();
|
|
323
300
|
}
|
|
324
|
-
}, _callee2, null, [[0,
|
|
301
|
+
}, _callee2, null, [[0, 20]]);
|
|
325
302
|
}));
|
|
326
303
|
return function (_x, _x2) {
|
|
327
304
|
return _ref2.apply(this, arguments);
|
|
@@ -342,44 +319,21 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
342
319
|
clientId: clientId,
|
|
343
320
|
catchUpOutofSync: catchUpOutofSync
|
|
344
321
|
};
|
|
345
|
-
_context3.
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
}
|
|
352
|
-
_context3.next = 11;
|
|
353
|
-
return _this.getChannelToken();
|
|
354
|
-
case 11:
|
|
355
|
-
_context3.t8 = _context3.sent;
|
|
356
|
-
_context3.t7 = {
|
|
357
|
-
'x-token': _context3.t8
|
|
358
|
-
};
|
|
359
|
-
_context3.next = 16;
|
|
360
|
-
break;
|
|
361
|
-
case 15:
|
|
362
|
-
_context3.t7 = {};
|
|
363
|
-
case 16:
|
|
364
|
-
_context3.t9 = _context3.t7;
|
|
365
|
-
_context3.t10 = (0, _context3.t5)(_context3.t6, _context3.t9);
|
|
366
|
-
_context3.t11 = {};
|
|
367
|
-
_context3.t12 = {
|
|
368
|
-
'x-product': (0, _utils.getProduct)(_this.config.productInfo),
|
|
369
|
-
'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo)
|
|
322
|
+
_context3.next = 7;
|
|
323
|
+
return _this.commonHeaders();
|
|
324
|
+
case 7:
|
|
325
|
+
_context3.t4 = _context3.sent;
|
|
326
|
+
_context3.t5 = {
|
|
327
|
+
headers: _context3.t4
|
|
370
328
|
};
|
|
371
|
-
_context3.
|
|
372
|
-
_context3.t14 = {
|
|
373
|
-
headers: _context3.t13
|
|
374
|
-
};
|
|
375
|
-
_context3.t15 = {
|
|
329
|
+
_context3.t6 = {
|
|
376
330
|
path: _context3.t2,
|
|
377
331
|
queryParams: _context3.t3,
|
|
378
|
-
requestInit: _context3.
|
|
332
|
+
requestInit: _context3.t5
|
|
379
333
|
};
|
|
380
|
-
_context3.next =
|
|
381
|
-
return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.
|
|
382
|
-
case
|
|
334
|
+
_context3.next = 12;
|
|
335
|
+
return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.t6);
|
|
336
|
+
case 12:
|
|
383
337
|
_yield$utils$requestS2 = _context3.sent;
|
|
384
338
|
steps = _yield$utils$requestS2.steps;
|
|
385
339
|
metadata = _yield$utils$requestS2.metadata;
|
|
@@ -387,38 +341,38 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
387
341
|
steps: steps,
|
|
388
342
|
metadata: metadata
|
|
389
343
|
});
|
|
390
|
-
case
|
|
391
|
-
_context3.prev =
|
|
392
|
-
_context3.
|
|
393
|
-
if (!(_context3.
|
|
394
|
-
_context3.next =
|
|
344
|
+
case 18:
|
|
345
|
+
_context3.prev = 18;
|
|
346
|
+
_context3.t7 = _context3["catch"](0);
|
|
347
|
+
if (!(_context3.t7.code === 404)) {
|
|
348
|
+
_context3.next = 24;
|
|
395
349
|
break;
|
|
396
350
|
}
|
|
397
351
|
errorNotFound = {
|
|
398
352
|
message: 'The requested document is not found',
|
|
399
353
|
data: {
|
|
400
|
-
status: _context3.
|
|
354
|
+
status: _context3.t7.code,
|
|
401
355
|
code: _internalErrors.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
402
356
|
}
|
|
403
357
|
};
|
|
404
358
|
_this.emit('error', errorNotFound);
|
|
405
359
|
return _context3.abrupt("return", {});
|
|
406
|
-
case
|
|
407
|
-
logger("Can't fetch the catchupv2", _context3.
|
|
360
|
+
case 24:
|
|
361
|
+
logger("Can't fetch the catchupv2", _context3.t7.message);
|
|
408
362
|
errorCatchupv2 = {
|
|
409
363
|
message: 'Cannot fetch catchupv2 from collab service',
|
|
410
364
|
data: {
|
|
411
|
-
status: _context3.
|
|
365
|
+
status: _context3.t7.status,
|
|
412
366
|
code: _internalErrors.INTERNAL_ERROR_CODE.CATCHUP_FAILED
|
|
413
367
|
}
|
|
414
368
|
};
|
|
415
369
|
_this.emit('error', errorCatchupv2);
|
|
416
|
-
throw _context3.
|
|
417
|
-
case
|
|
370
|
+
throw _context3.t7;
|
|
371
|
+
case 28:
|
|
418
372
|
case "end":
|
|
419
373
|
return _context3.stop();
|
|
420
374
|
}
|
|
421
|
-
}, _callee3, null, [[0,
|
|
375
|
+
}, _callee3, null, [[0, 18]]);
|
|
422
376
|
}));
|
|
423
377
|
return function (_x3, _x4, _x5) {
|
|
424
378
|
return _ref3.apply(this, arguments);
|
|
@@ -442,56 +396,41 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
442
396
|
_context4.t3 = _objectSpread;
|
|
443
397
|
_context4.t4 = _objectSpread;
|
|
444
398
|
_context4.t5 = {};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
_context4.
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
_context4.t7 = _context4.sent;
|
|
453
|
-
_context4.t6 = {
|
|
454
|
-
'x-token': _context4.t7
|
|
455
|
-
};
|
|
456
|
-
_context4.next = 16;
|
|
457
|
-
break;
|
|
458
|
-
case 15:
|
|
459
|
-
_context4.t6 = {};
|
|
460
|
-
case 16:
|
|
461
|
-
_context4.t8 = _context4.t6;
|
|
462
|
-
_context4.t9 = (0, _context4.t4)(_context4.t5, _context4.t8);
|
|
463
|
-
_context4.t10 = {};
|
|
464
|
-
_context4.t11 = {
|
|
465
|
-
'x-product': (0, _utils.getProduct)(_this.config.productInfo),
|
|
466
|
-
'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo),
|
|
399
|
+
_context4.next = 10;
|
|
400
|
+
return _this.commonHeaders();
|
|
401
|
+
case 10:
|
|
402
|
+
_context4.t6 = _context4.sent;
|
|
403
|
+
_context4.t7 = (0, _context4.t4)(_context4.t5, _context4.t6);
|
|
404
|
+
_context4.t8 = {};
|
|
405
|
+
_context4.t9 = {
|
|
467
406
|
'Content-Type': 'application/json'
|
|
468
407
|
};
|
|
469
|
-
_context4.
|
|
470
|
-
_context4.
|
|
471
|
-
_context4.
|
|
472
|
-
headers: _context4.
|
|
408
|
+
_context4.t10 = (0, _context4.t3)(_context4.t7, _context4.t8, _context4.t9);
|
|
409
|
+
_context4.t11 = reqBody;
|
|
410
|
+
_context4.t12 = {
|
|
411
|
+
headers: _context4.t10,
|
|
473
412
|
method: 'POST',
|
|
474
|
-
body: _context4.
|
|
413
|
+
body: _context4.t11
|
|
475
414
|
};
|
|
476
|
-
_context4.
|
|
415
|
+
_context4.t13 = {
|
|
477
416
|
path: _context4.t2,
|
|
478
|
-
requestInit: _context4.
|
|
417
|
+
requestInit: _context4.t12
|
|
479
418
|
};
|
|
480
|
-
_context4.next =
|
|
481
|
-
return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.
|
|
482
|
-
case
|
|
419
|
+
_context4.next = 20;
|
|
420
|
+
return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.t13);
|
|
421
|
+
case 20:
|
|
483
422
|
reconcileResponse = _context4.sent;
|
|
484
423
|
return _context4.abrupt("return", reconcileResponse);
|
|
485
|
-
case
|
|
486
|
-
_context4.prev =
|
|
487
|
-
_context4.
|
|
488
|
-
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.
|
|
489
|
-
throw _context4.
|
|
490
|
-
case
|
|
424
|
+
case 24:
|
|
425
|
+
_context4.prev = 24;
|
|
426
|
+
_context4.t14 = _context4["catch"](0);
|
|
427
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.t14, 'Error while fetching reconciled document');
|
|
428
|
+
throw _context4.t14;
|
|
429
|
+
case 28:
|
|
491
430
|
case "end":
|
|
492
431
|
return _context4.stop();
|
|
493
432
|
}
|
|
494
|
-
}, _callee4, null, [[0,
|
|
433
|
+
}, _callee4, null, [[0, 24]]);
|
|
495
434
|
}));
|
|
496
435
|
return function (_x6, _x7) {
|
|
497
436
|
return _ref4.apply(this, arguments);
|
|
@@ -843,6 +782,51 @@ var Channel = exports.Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
843
782
|
_iterator.f();
|
|
844
783
|
}
|
|
845
784
|
}
|
|
785
|
+
}, {
|
|
786
|
+
key: "commonHeaders",
|
|
787
|
+
value: function () {
|
|
788
|
+
var _commonHeaders = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee8() {
|
|
789
|
+
return _regenerator.default.wrap(function _callee8$(_context8) {
|
|
790
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
791
|
+
case 0:
|
|
792
|
+
_context8.t0 = _objectSpread;
|
|
793
|
+
_context8.t1 = _objectSpread;
|
|
794
|
+
_context8.t2 = {};
|
|
795
|
+
if (!this.config.permissionTokenRefresh) {
|
|
796
|
+
_context8.next = 10;
|
|
797
|
+
break;
|
|
798
|
+
}
|
|
799
|
+
_context8.next = 6;
|
|
800
|
+
return this.getChannelToken();
|
|
801
|
+
case 6:
|
|
802
|
+
_context8.t4 = _context8.sent;
|
|
803
|
+
_context8.t3 = {
|
|
804
|
+
'x-token': _context8.t4
|
|
805
|
+
};
|
|
806
|
+
_context8.next = 11;
|
|
807
|
+
break;
|
|
808
|
+
case 10:
|
|
809
|
+
_context8.t3 = {};
|
|
810
|
+
case 11:
|
|
811
|
+
_context8.t5 = _context8.t3;
|
|
812
|
+
_context8.t6 = (0, _context8.t1)(_context8.t2, _context8.t5);
|
|
813
|
+
_context8.t7 = {};
|
|
814
|
+
_context8.t8 = {
|
|
815
|
+
'x-product': (0, _utils.getProduct)(this.config.productInfo),
|
|
816
|
+
'x-subproduct': (0, _utils.getSubProduct)(this.config.productInfo)
|
|
817
|
+
};
|
|
818
|
+
return _context8.abrupt("return", (0, _context8.t0)(_context8.t6, _context8.t7, _context8.t8));
|
|
819
|
+
case 16:
|
|
820
|
+
case "end":
|
|
821
|
+
return _context8.stop();
|
|
822
|
+
}
|
|
823
|
+
}, _callee8, this);
|
|
824
|
+
}));
|
|
825
|
+
function commonHeaders() {
|
|
826
|
+
return _commonHeaders.apply(this, arguments);
|
|
827
|
+
}
|
|
828
|
+
return commonHeaders;
|
|
829
|
+
}()
|
|
846
830
|
}, {
|
|
847
831
|
key: "isLimitExceeded",
|
|
848
832
|
value: function isLimitExceeded(stepLimit, stepSizeLimit, maxStepSizeLimit) {
|
|
@@ -4,13 +4,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.catchupv2 = void 0;
|
|
7
|
+
exports.isOutOfSync = exports.catchupv2 = void 0;
|
|
8
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
9
9
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
10
10
|
var _utils = require("../helpers/utils");
|
|
11
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
11
|
var logger = (0, _utils.createLogger)('Catchupv2', 'red');
|
|
15
12
|
var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
16
13
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(opt) {
|
|
@@ -36,6 +33,13 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
|
36
33
|
throw _context.t0;
|
|
37
34
|
case 14:
|
|
38
35
|
_context.prev = 14;
|
|
36
|
+
if (!(!steps || steps.length === 0)) {
|
|
37
|
+
_context.next = 18;
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
opt.updateMetadata(metadata);
|
|
41
|
+
return _context.abrupt("return", false);
|
|
42
|
+
case 18:
|
|
39
43
|
version = fromVersion + steps.length;
|
|
40
44
|
stepsPayload = {
|
|
41
45
|
version: version,
|
|
@@ -44,42 +48,36 @@ var catchupv2 = exports.catchupv2 = /*#__PURE__*/function () {
|
|
|
44
48
|
opt.onStepsAdded(stepsPayload);
|
|
45
49
|
opt.updateMetadata(metadata);
|
|
46
50
|
return _context.abrupt("return", Boolean(opt.clientId && isOutOfSync(fromVersion, opt.getCurrentPmVersion(), steps, opt.clientId)));
|
|
47
|
-
case
|
|
48
|
-
_context.prev =
|
|
51
|
+
case 25:
|
|
52
|
+
_context.prev = 25;
|
|
49
53
|
_context.t1 = _context["catch"](14);
|
|
50
54
|
(_opt$analyticsHelper2 = opt.analyticsHelper) === null || _opt$analyticsHelper2 === void 0 || _opt$analyticsHelper2.sendErrorEvent(_context.t1, 'Failed to apply catchupv2 result in the editor');
|
|
51
55
|
logger("Apply catchupv2 steps failed:", _context.t1.message);
|
|
52
56
|
throw _context.t1;
|
|
53
|
-
case
|
|
57
|
+
case 30:
|
|
54
58
|
case "end":
|
|
55
59
|
return _context.stop();
|
|
56
60
|
}
|
|
57
|
-
}, _callee, null, [[1, 9], [14,
|
|
61
|
+
}, _callee, null, [[1, 9], [14, 25]]);
|
|
58
62
|
}));
|
|
59
63
|
return function catchupv2(_x) {
|
|
60
64
|
return _ref.apply(this, arguments);
|
|
61
65
|
};
|
|
62
66
|
}();
|
|
63
|
-
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
70
|
+
* @param fromVersion The document's PM version from before we applied catchup
|
|
71
|
+
* @param currentVersion The document's PM version after we applied catchup
|
|
72
|
+
* @param steps Steps returned to us by catchup
|
|
73
|
+
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
74
|
+
* @returns True if we're out of sync, false if not.
|
|
75
|
+
*/
|
|
76
|
+
var isOutOfSync = exports.isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId) {
|
|
64
77
|
return (
|
|
65
78
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
66
|
-
Boolean(fromVersion >= currentVersion &&
|
|
79
|
+
Boolean(fromVersion >= currentVersion && steps.some(function (step) {
|
|
80
|
+
return step.clientId !== clientId;
|
|
81
|
+
}))
|
|
67
82
|
);
|
|
68
|
-
};
|
|
69
|
-
var checkForeignSteps = function checkForeignSteps(steps, clientId) {
|
|
70
|
-
var _iterator = _createForOfIteratorHelper(steps),
|
|
71
|
-
_step;
|
|
72
|
-
try {
|
|
73
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
74
|
-
var step = _step.value;
|
|
75
|
-
if (step.clientId !== clientId) {
|
|
76
|
-
return true;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
_iterator.e(err);
|
|
81
|
-
} finally {
|
|
82
|
-
_iterator.f();
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
83
|
};
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/collab-provider";
|
|
8
|
-
var version = exports.version = "9.26.
|
|
8
|
+
var version = exports.version = "9.26.6";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
package/dist/es2019/channel.js
CHANGED
|
@@ -176,13 +176,7 @@ export class Channel extends Emitter {
|
|
|
176
176
|
clientId: clientId
|
|
177
177
|
},
|
|
178
178
|
requestInit: {
|
|
179
|
-
headers:
|
|
180
|
-
...(this.config.permissionTokenRefresh ? {
|
|
181
|
-
'x-token': await this.getChannelToken()
|
|
182
|
-
} : {}),
|
|
183
|
-
'x-product': getProduct(this.config.productInfo),
|
|
184
|
-
'x-subproduct': getSubProduct(this.config.productInfo)
|
|
185
|
-
}
|
|
179
|
+
headers: await this.commonHeaders()
|
|
186
180
|
}
|
|
187
181
|
});
|
|
188
182
|
return {
|
|
@@ -228,13 +222,7 @@ export class Channel extends Emitter {
|
|
|
228
222
|
catchUpOutofSync
|
|
229
223
|
},
|
|
230
224
|
requestInit: {
|
|
231
|
-
headers:
|
|
232
|
-
...(this.config.permissionTokenRefresh ? {
|
|
233
|
-
'x-token': await this.getChannelToken()
|
|
234
|
-
} : {}),
|
|
235
|
-
'x-product': getProduct(this.config.productInfo),
|
|
236
|
-
'x-subproduct': getSubProduct(this.config.productInfo)
|
|
237
|
-
}
|
|
225
|
+
headers: await this.commonHeaders()
|
|
238
226
|
}
|
|
239
227
|
});
|
|
240
228
|
return {
|
|
@@ -276,11 +264,7 @@ export class Channel extends Emitter {
|
|
|
276
264
|
path: `document/${encodeURIComponent(this.config.documentAri)}/reconcile`,
|
|
277
265
|
requestInit: {
|
|
278
266
|
headers: {
|
|
279
|
-
...(this.
|
|
280
|
-
'x-token': await this.getChannelToken()
|
|
281
|
-
} : {}),
|
|
282
|
-
'x-product': getProduct(this.config.productInfo),
|
|
283
|
-
'x-subproduct': getSubProduct(this.config.productInfo),
|
|
267
|
+
...(await this.commonHeaders()),
|
|
284
268
|
'Content-Type': 'application/json'
|
|
285
269
|
},
|
|
286
270
|
method: 'POST',
|
|
@@ -570,6 +554,15 @@ export class Channel extends Emitter {
|
|
|
570
554
|
}
|
|
571
555
|
}
|
|
572
556
|
}
|
|
557
|
+
async commonHeaders() {
|
|
558
|
+
return {
|
|
559
|
+
...(this.config.permissionTokenRefresh ? {
|
|
560
|
+
'x-token': await this.getChannelToken()
|
|
561
|
+
} : {}),
|
|
562
|
+
'x-product': getProduct(this.config.productInfo),
|
|
563
|
+
'x-subproduct': getSubProduct(this.config.productInfo)
|
|
564
|
+
};
|
|
565
|
+
}
|
|
573
566
|
isLimitExceeded(stepLimit, stepSizeLimit, maxStepSizeLimit) {
|
|
574
567
|
return stepLimit > 0 && this.stepCounter > stepLimit || stepSizeLimit > 0 && this.stepSizeCounter > stepSizeLimit || maxStepSizeLimit > 0 && this.maxStepSize > maxStepSizeLimit;
|
|
575
568
|
}
|
|
@@ -16,6 +16,11 @@ export const catchupv2 = async opt => {
|
|
|
16
16
|
throw error;
|
|
17
17
|
}
|
|
18
18
|
try {
|
|
19
|
+
// skip onStepsAdded if steps are undefined or empty
|
|
20
|
+
if (!steps || steps.length === 0) {
|
|
21
|
+
opt.updateMetadata(metadata);
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
19
24
|
const version = fromVersion + steps.length;
|
|
20
25
|
const stepsPayload = {
|
|
21
26
|
version,
|
|
@@ -31,14 +36,15 @@ export const catchupv2 = async opt => {
|
|
|
31
36
|
throw error;
|
|
32
37
|
}
|
|
33
38
|
};
|
|
34
|
-
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
42
|
+
* @param fromVersion The document's PM version from before we applied catchup
|
|
43
|
+
* @param currentVersion The document's PM version after we applied catchup
|
|
44
|
+
* @param steps Steps returned to us by catchup
|
|
45
|
+
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
46
|
+
* @returns True if we're out of sync, false if not.
|
|
47
|
+
*/
|
|
48
|
+
export const isOutOfSync = (fromVersion, currentVersion, steps, clientId) =>
|
|
35
49
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
36
|
-
Boolean(fromVersion >= currentVersion &&
|
|
37
|
-
const checkForeignSteps = (steps, clientId) => {
|
|
38
|
-
for (const step of steps) {
|
|
39
|
-
if (step.clientId !== clientId) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
50
|
+
Boolean(fromVersion >= currentVersion && steps.some(step => step.clientId !== clientId));
|
|
@@ -130,6 +130,18 @@ export class DocumentService {
|
|
|
130
130
|
this.stepQueue.pauseQueue();
|
|
131
131
|
try {
|
|
132
132
|
var _this$analyticsHelper3;
|
|
133
|
+
/**
|
|
134
|
+
* We have two options when out of sync:
|
|
135
|
+
* - Check a boolean that ensures we reset the document next time we catchup
|
|
136
|
+
* - Immediately catchup
|
|
137
|
+
*
|
|
138
|
+
* Immediately catching up has some complexity invovled with it - do we call catchupv2 again, fetchCatchupv2 again, or documentService.catchupV2 again?
|
|
139
|
+
* If we call either catchupv2 or documentService.catchupv2, we run the risk of creating an infinite loop of reset catchup requests.
|
|
140
|
+
* We can slow down the loop by calling throttledCatchupv2, and can add booleans that check if we're already doing a reset catchup request.
|
|
141
|
+
*
|
|
142
|
+
* But this all adds complexity that can be avoided by choosing the first option.
|
|
143
|
+
* Collab provider will already call catchup again, so this time we can ensure we call it with reset.
|
|
144
|
+
*/
|
|
133
145
|
this.catchUpOutofSync = await catchupv2({
|
|
134
146
|
getCurrentPmVersion: this.getCurrentPmVersion,
|
|
135
147
|
fetchCatchupv2: this.fetchCatchupv2,
|
package/dist/esm/channel.js
CHANGED
|
@@ -234,44 +234,21 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
234
234
|
version: fromVersion,
|
|
235
235
|
clientId: clientId
|
|
236
236
|
};
|
|
237
|
-
_context2.
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
}
|
|
244
|
-
_context2.next = 11;
|
|
245
|
-
return _this.getChannelToken();
|
|
246
|
-
case 11:
|
|
247
|
-
_context2.t8 = _context2.sent;
|
|
248
|
-
_context2.t7 = {
|
|
249
|
-
'x-token': _context2.t8
|
|
250
|
-
};
|
|
251
|
-
_context2.next = 16;
|
|
252
|
-
break;
|
|
253
|
-
case 15:
|
|
254
|
-
_context2.t7 = {};
|
|
255
|
-
case 16:
|
|
256
|
-
_context2.t9 = _context2.t7;
|
|
257
|
-
_context2.t10 = (0, _context2.t5)(_context2.t6, _context2.t9);
|
|
258
|
-
_context2.t11 = {};
|
|
259
|
-
_context2.t12 = {
|
|
260
|
-
'x-product': getProduct(_this.config.productInfo),
|
|
261
|
-
'x-subproduct': getSubProduct(_this.config.productInfo)
|
|
262
|
-
};
|
|
263
|
-
_context2.t13 = (0, _context2.t4)(_context2.t10, _context2.t11, _context2.t12);
|
|
264
|
-
_context2.t14 = {
|
|
265
|
-
headers: _context2.t13
|
|
237
|
+
_context2.next = 7;
|
|
238
|
+
return _this.commonHeaders();
|
|
239
|
+
case 7:
|
|
240
|
+
_context2.t4 = _context2.sent;
|
|
241
|
+
_context2.t5 = {
|
|
242
|
+
headers: _context2.t4
|
|
266
243
|
};
|
|
267
|
-
_context2.
|
|
244
|
+
_context2.t6 = {
|
|
268
245
|
path: _context2.t2,
|
|
269
246
|
queryParams: _context2.t3,
|
|
270
|
-
requestInit: _context2.
|
|
247
|
+
requestInit: _context2.t5
|
|
271
248
|
};
|
|
272
|
-
_context2.next =
|
|
273
|
-
return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.
|
|
274
|
-
case
|
|
249
|
+
_context2.next = 12;
|
|
250
|
+
return _context2.t0.requestService.call(_context2.t0, _context2.t1, _context2.t6);
|
|
251
|
+
case 12:
|
|
275
252
|
_yield$utils$requestS = _context2.sent;
|
|
276
253
|
doc = _yield$utils$requestS.doc;
|
|
277
254
|
version = _yield$utils$requestS.version;
|
|
@@ -283,38 +260,38 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
283
260
|
stepMaps: stepMaps,
|
|
284
261
|
metadata: metadata
|
|
285
262
|
});
|
|
286
|
-
case
|
|
287
|
-
_context2.prev =
|
|
288
|
-
_context2.
|
|
289
|
-
if (!(_context2.
|
|
290
|
-
_context2.next =
|
|
263
|
+
case 20:
|
|
264
|
+
_context2.prev = 20;
|
|
265
|
+
_context2.t7 = _context2["catch"](0);
|
|
266
|
+
if (!(_context2.t7.code === 404)) {
|
|
267
|
+
_context2.next = 26;
|
|
291
268
|
break;
|
|
292
269
|
}
|
|
293
270
|
errorNotFound = {
|
|
294
271
|
message: 'The requested document is not found',
|
|
295
272
|
data: {
|
|
296
|
-
status: _context2.
|
|
273
|
+
status: _context2.t7.code,
|
|
297
274
|
code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
298
275
|
}
|
|
299
276
|
};
|
|
300
277
|
_this.emit('error', errorNotFound);
|
|
301
278
|
return _context2.abrupt("return", {});
|
|
302
|
-
case
|
|
303
|
-
logger("Can't fetch the catchup", _context2.
|
|
279
|
+
case 26:
|
|
280
|
+
logger("Can't fetch the catchup", _context2.t7.message);
|
|
304
281
|
errorCatchup = {
|
|
305
282
|
message: 'Cannot fetch catchup from collab service',
|
|
306
283
|
data: {
|
|
307
|
-
status: _context2.
|
|
284
|
+
status: _context2.t7.status,
|
|
308
285
|
code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
|
|
309
286
|
}
|
|
310
287
|
};
|
|
311
288
|
_this.emit('error', errorCatchup);
|
|
312
|
-
throw _context2.
|
|
313
|
-
case
|
|
289
|
+
throw _context2.t7;
|
|
290
|
+
case 30:
|
|
314
291
|
case "end":
|
|
315
292
|
return _context2.stop();
|
|
316
293
|
}
|
|
317
|
-
}, _callee2, null, [[0,
|
|
294
|
+
}, _callee2, null, [[0, 20]]);
|
|
318
295
|
}));
|
|
319
296
|
return function (_x, _x2) {
|
|
320
297
|
return _ref2.apply(this, arguments);
|
|
@@ -335,44 +312,21 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
335
312
|
clientId: clientId,
|
|
336
313
|
catchUpOutofSync: catchUpOutofSync
|
|
337
314
|
};
|
|
338
|
-
_context3.
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
_context3.next = 11;
|
|
346
|
-
return _this.getChannelToken();
|
|
347
|
-
case 11:
|
|
348
|
-
_context3.t8 = _context3.sent;
|
|
349
|
-
_context3.t7 = {
|
|
350
|
-
'x-token': _context3.t8
|
|
351
|
-
};
|
|
352
|
-
_context3.next = 16;
|
|
353
|
-
break;
|
|
354
|
-
case 15:
|
|
355
|
-
_context3.t7 = {};
|
|
356
|
-
case 16:
|
|
357
|
-
_context3.t9 = _context3.t7;
|
|
358
|
-
_context3.t10 = (0, _context3.t5)(_context3.t6, _context3.t9);
|
|
359
|
-
_context3.t11 = {};
|
|
360
|
-
_context3.t12 = {
|
|
361
|
-
'x-product': getProduct(_this.config.productInfo),
|
|
362
|
-
'x-subproduct': getSubProduct(_this.config.productInfo)
|
|
315
|
+
_context3.next = 7;
|
|
316
|
+
return _this.commonHeaders();
|
|
317
|
+
case 7:
|
|
318
|
+
_context3.t4 = _context3.sent;
|
|
319
|
+
_context3.t5 = {
|
|
320
|
+
headers: _context3.t4
|
|
363
321
|
};
|
|
364
|
-
_context3.
|
|
365
|
-
_context3.t14 = {
|
|
366
|
-
headers: _context3.t13
|
|
367
|
-
};
|
|
368
|
-
_context3.t15 = {
|
|
322
|
+
_context3.t6 = {
|
|
369
323
|
path: _context3.t2,
|
|
370
324
|
queryParams: _context3.t3,
|
|
371
|
-
requestInit: _context3.
|
|
325
|
+
requestInit: _context3.t5
|
|
372
326
|
};
|
|
373
|
-
_context3.next =
|
|
374
|
-
return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.
|
|
375
|
-
case
|
|
327
|
+
_context3.next = 12;
|
|
328
|
+
return _context3.t0.requestService.call(_context3.t0, _context3.t1, _context3.t6);
|
|
329
|
+
case 12:
|
|
376
330
|
_yield$utils$requestS2 = _context3.sent;
|
|
377
331
|
steps = _yield$utils$requestS2.steps;
|
|
378
332
|
metadata = _yield$utils$requestS2.metadata;
|
|
@@ -380,38 +334,38 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
380
334
|
steps: steps,
|
|
381
335
|
metadata: metadata
|
|
382
336
|
});
|
|
383
|
-
case
|
|
384
|
-
_context3.prev =
|
|
385
|
-
_context3.
|
|
386
|
-
if (!(_context3.
|
|
387
|
-
_context3.next =
|
|
337
|
+
case 18:
|
|
338
|
+
_context3.prev = 18;
|
|
339
|
+
_context3.t7 = _context3["catch"](0);
|
|
340
|
+
if (!(_context3.t7.code === 404)) {
|
|
341
|
+
_context3.next = 24;
|
|
388
342
|
break;
|
|
389
343
|
}
|
|
390
344
|
errorNotFound = {
|
|
391
345
|
message: 'The requested document is not found',
|
|
392
346
|
data: {
|
|
393
|
-
status: _context3.
|
|
347
|
+
status: _context3.t7.code,
|
|
394
348
|
code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
395
349
|
}
|
|
396
350
|
};
|
|
397
351
|
_this.emit('error', errorNotFound);
|
|
398
352
|
return _context3.abrupt("return", {});
|
|
399
|
-
case
|
|
400
|
-
logger("Can't fetch the catchupv2", _context3.
|
|
353
|
+
case 24:
|
|
354
|
+
logger("Can't fetch the catchupv2", _context3.t7.message);
|
|
401
355
|
errorCatchupv2 = {
|
|
402
356
|
message: 'Cannot fetch catchupv2 from collab service',
|
|
403
357
|
data: {
|
|
404
|
-
status: _context3.
|
|
358
|
+
status: _context3.t7.status,
|
|
405
359
|
code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
|
|
406
360
|
}
|
|
407
361
|
};
|
|
408
362
|
_this.emit('error', errorCatchupv2);
|
|
409
|
-
throw _context3.
|
|
410
|
-
case
|
|
363
|
+
throw _context3.t7;
|
|
364
|
+
case 28:
|
|
411
365
|
case "end":
|
|
412
366
|
return _context3.stop();
|
|
413
367
|
}
|
|
414
|
-
}, _callee3, null, [[0,
|
|
368
|
+
}, _callee3, null, [[0, 18]]);
|
|
415
369
|
}));
|
|
416
370
|
return function (_x3, _x4, _x5) {
|
|
417
371
|
return _ref3.apply(this, arguments);
|
|
@@ -435,56 +389,41 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
435
389
|
_context4.t3 = _objectSpread;
|
|
436
390
|
_context4.t4 = _objectSpread;
|
|
437
391
|
_context4.t5 = {};
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
_context4.
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
_context4.t7 = _context4.sent;
|
|
446
|
-
_context4.t6 = {
|
|
447
|
-
'x-token': _context4.t7
|
|
448
|
-
};
|
|
449
|
-
_context4.next = 16;
|
|
450
|
-
break;
|
|
451
|
-
case 15:
|
|
452
|
-
_context4.t6 = {};
|
|
453
|
-
case 16:
|
|
454
|
-
_context4.t8 = _context4.t6;
|
|
455
|
-
_context4.t9 = (0, _context4.t4)(_context4.t5, _context4.t8);
|
|
456
|
-
_context4.t10 = {};
|
|
457
|
-
_context4.t11 = {
|
|
458
|
-
'x-product': getProduct(_this.config.productInfo),
|
|
459
|
-
'x-subproduct': getSubProduct(_this.config.productInfo),
|
|
392
|
+
_context4.next = 10;
|
|
393
|
+
return _this.commonHeaders();
|
|
394
|
+
case 10:
|
|
395
|
+
_context4.t6 = _context4.sent;
|
|
396
|
+
_context4.t7 = (0, _context4.t4)(_context4.t5, _context4.t6);
|
|
397
|
+
_context4.t8 = {};
|
|
398
|
+
_context4.t9 = {
|
|
460
399
|
'Content-Type': 'application/json'
|
|
461
400
|
};
|
|
462
|
-
_context4.
|
|
463
|
-
_context4.
|
|
464
|
-
_context4.
|
|
465
|
-
headers: _context4.
|
|
401
|
+
_context4.t10 = (0, _context4.t3)(_context4.t7, _context4.t8, _context4.t9);
|
|
402
|
+
_context4.t11 = reqBody;
|
|
403
|
+
_context4.t12 = {
|
|
404
|
+
headers: _context4.t10,
|
|
466
405
|
method: 'POST',
|
|
467
|
-
body: _context4.
|
|
406
|
+
body: _context4.t11
|
|
468
407
|
};
|
|
469
|
-
_context4.
|
|
408
|
+
_context4.t13 = {
|
|
470
409
|
path: _context4.t2,
|
|
471
|
-
requestInit: _context4.
|
|
410
|
+
requestInit: _context4.t12
|
|
472
411
|
};
|
|
473
|
-
_context4.next =
|
|
474
|
-
return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.
|
|
475
|
-
case
|
|
412
|
+
_context4.next = 20;
|
|
413
|
+
return _context4.t0.requestService.call(_context4.t0, _context4.t1, _context4.t13);
|
|
414
|
+
case 20:
|
|
476
415
|
reconcileResponse = _context4.sent;
|
|
477
416
|
return _context4.abrupt("return", reconcileResponse);
|
|
478
|
-
case
|
|
479
|
-
_context4.prev =
|
|
480
|
-
_context4.
|
|
481
|
-
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.
|
|
482
|
-
throw _context4.
|
|
483
|
-
case
|
|
417
|
+
case 24:
|
|
418
|
+
_context4.prev = 24;
|
|
419
|
+
_context4.t14 = _context4["catch"](0);
|
|
420
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 || _this$analyticsHelper7.sendErrorEvent(_context4.t14, 'Error while fetching reconciled document');
|
|
421
|
+
throw _context4.t14;
|
|
422
|
+
case 28:
|
|
484
423
|
case "end":
|
|
485
424
|
return _context4.stop();
|
|
486
425
|
}
|
|
487
|
-
}, _callee4, null, [[0,
|
|
426
|
+
}, _callee4, null, [[0, 24]]);
|
|
488
427
|
}));
|
|
489
428
|
return function (_x6, _x7) {
|
|
490
429
|
return _ref4.apply(this, arguments);
|
|
@@ -836,6 +775,51 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
836
775
|
_iterator.f();
|
|
837
776
|
}
|
|
838
777
|
}
|
|
778
|
+
}, {
|
|
779
|
+
key: "commonHeaders",
|
|
780
|
+
value: function () {
|
|
781
|
+
var _commonHeaders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
782
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
783
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
784
|
+
case 0:
|
|
785
|
+
_context8.t0 = _objectSpread;
|
|
786
|
+
_context8.t1 = _objectSpread;
|
|
787
|
+
_context8.t2 = {};
|
|
788
|
+
if (!this.config.permissionTokenRefresh) {
|
|
789
|
+
_context8.next = 10;
|
|
790
|
+
break;
|
|
791
|
+
}
|
|
792
|
+
_context8.next = 6;
|
|
793
|
+
return this.getChannelToken();
|
|
794
|
+
case 6:
|
|
795
|
+
_context8.t4 = _context8.sent;
|
|
796
|
+
_context8.t3 = {
|
|
797
|
+
'x-token': _context8.t4
|
|
798
|
+
};
|
|
799
|
+
_context8.next = 11;
|
|
800
|
+
break;
|
|
801
|
+
case 10:
|
|
802
|
+
_context8.t3 = {};
|
|
803
|
+
case 11:
|
|
804
|
+
_context8.t5 = _context8.t3;
|
|
805
|
+
_context8.t6 = (0, _context8.t1)(_context8.t2, _context8.t5);
|
|
806
|
+
_context8.t7 = {};
|
|
807
|
+
_context8.t8 = {
|
|
808
|
+
'x-product': getProduct(this.config.productInfo),
|
|
809
|
+
'x-subproduct': getSubProduct(this.config.productInfo)
|
|
810
|
+
};
|
|
811
|
+
return _context8.abrupt("return", (0, _context8.t0)(_context8.t6, _context8.t7, _context8.t8));
|
|
812
|
+
case 16:
|
|
813
|
+
case "end":
|
|
814
|
+
return _context8.stop();
|
|
815
|
+
}
|
|
816
|
+
}, _callee8, this);
|
|
817
|
+
}));
|
|
818
|
+
function commonHeaders() {
|
|
819
|
+
return _commonHeaders.apply(this, arguments);
|
|
820
|
+
}
|
|
821
|
+
return commonHeaders;
|
|
822
|
+
}()
|
|
839
823
|
}, {
|
|
840
824
|
key: "isLimitExceeded",
|
|
841
825
|
value: function isLimitExceeded(stepLimit, stepSizeLimit, maxStepSizeLimit) {
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
3
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
2
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
6
3
|
import { createLogger } from '../helpers/utils';
|
|
7
4
|
var logger = createLogger('Catchupv2', 'red');
|
|
@@ -29,6 +26,13 @@ export var catchupv2 = /*#__PURE__*/function () {
|
|
|
29
26
|
throw _context.t0;
|
|
30
27
|
case 14:
|
|
31
28
|
_context.prev = 14;
|
|
29
|
+
if (!(!steps || steps.length === 0)) {
|
|
30
|
+
_context.next = 18;
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
opt.updateMetadata(metadata);
|
|
34
|
+
return _context.abrupt("return", false);
|
|
35
|
+
case 18:
|
|
32
36
|
version = fromVersion + steps.length;
|
|
33
37
|
stepsPayload = {
|
|
34
38
|
version: version,
|
|
@@ -37,42 +41,36 @@ export var catchupv2 = /*#__PURE__*/function () {
|
|
|
37
41
|
opt.onStepsAdded(stepsPayload);
|
|
38
42
|
opt.updateMetadata(metadata);
|
|
39
43
|
return _context.abrupt("return", Boolean(opt.clientId && isOutOfSync(fromVersion, opt.getCurrentPmVersion(), steps, opt.clientId)));
|
|
40
|
-
case
|
|
41
|
-
_context.prev =
|
|
44
|
+
case 25:
|
|
45
|
+
_context.prev = 25;
|
|
42
46
|
_context.t1 = _context["catch"](14);
|
|
43
47
|
(_opt$analyticsHelper2 = opt.analyticsHelper) === null || _opt$analyticsHelper2 === void 0 || _opt$analyticsHelper2.sendErrorEvent(_context.t1, 'Failed to apply catchupv2 result in the editor');
|
|
44
48
|
logger("Apply catchupv2 steps failed:", _context.t1.message);
|
|
45
49
|
throw _context.t1;
|
|
46
|
-
case
|
|
50
|
+
case 30:
|
|
47
51
|
case "end":
|
|
48
52
|
return _context.stop();
|
|
49
53
|
}
|
|
50
|
-
}, _callee, null, [[1, 9], [14,
|
|
54
|
+
}, _callee, null, [[1, 9], [14, 25]]);
|
|
51
55
|
}));
|
|
52
56
|
return function catchupv2(_x) {
|
|
53
57
|
return _ref.apply(this, arguments);
|
|
54
58
|
};
|
|
55
59
|
}();
|
|
56
|
-
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
63
|
+
* @param fromVersion The document's PM version from before we applied catchup
|
|
64
|
+
* @param currentVersion The document's PM version after we applied catchup
|
|
65
|
+
* @param steps Steps returned to us by catchup
|
|
66
|
+
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
67
|
+
* @returns True if we're out of sync, false if not.
|
|
68
|
+
*/
|
|
69
|
+
export var isOutOfSync = function isOutOfSync(fromVersion, currentVersion, steps, clientId) {
|
|
57
70
|
return (
|
|
58
71
|
// If version number hasn't increased, and steps are not from our client, we're out of sync
|
|
59
|
-
Boolean(fromVersion >= currentVersion &&
|
|
72
|
+
Boolean(fromVersion >= currentVersion && steps.some(function (step) {
|
|
73
|
+
return step.clientId !== clientId;
|
|
74
|
+
}))
|
|
60
75
|
);
|
|
61
|
-
};
|
|
62
|
-
var checkForeignSteps = function checkForeignSteps(steps, clientId) {
|
|
63
|
-
var _iterator = _createForOfIteratorHelper(steps),
|
|
64
|
-
_step;
|
|
65
|
-
try {
|
|
66
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
67
|
-
var step = _step.value;
|
|
68
|
-
if (step.clientId !== clientId) {
|
|
69
|
-
return true;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
} catch (err) {
|
|
73
|
-
_iterator.e(err);
|
|
74
|
-
} finally {
|
|
75
|
-
_iterator.f();
|
|
76
|
-
}
|
|
77
|
-
return false;
|
|
78
76
|
};
|
package/dist/types/channel.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
32
32
|
*/
|
|
33
33
|
connect(shouldInitialize?: boolean): void;
|
|
34
34
|
onAnyOutgoingHandler(currentTimeMs: number, args: any[]): void;
|
|
35
|
+
private commonHeaders;
|
|
35
36
|
private isLimitExceeded;
|
|
36
37
|
private handlePermissionInvalidateToken;
|
|
37
38
|
private onConnectError;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { Catchupv2Options } from '../types';
|
|
2
|
+
import type { StepJson } from '@atlaskit/editor-common/collab';
|
|
2
3
|
export declare const catchupv2: (opt: Catchupv2Options) => Promise<boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
6
|
+
* @param fromVersion The document's PM version from before we applied catchup
|
|
7
|
+
* @param currentVersion The document's PM version after we applied catchup
|
|
8
|
+
* @param steps Steps returned to us by catchup
|
|
9
|
+
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
10
|
+
* @returns True if we're out of sync, false if not.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isOutOfSync: (fromVersion: number, currentVersion: number, steps: StepJson[], clientId: string | number) => boolean;
|
|
@@ -32,6 +32,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
32
32
|
*/
|
|
33
33
|
connect(shouldInitialize?: boolean): void;
|
|
34
34
|
onAnyOutgoingHandler(currentTimeMs: number, args: any[]): void;
|
|
35
|
+
private commonHeaders;
|
|
35
36
|
private isLimitExceeded;
|
|
36
37
|
private handlePermissionInvalidateToken;
|
|
37
38
|
private onConnectError;
|
|
@@ -1,2 +1,12 @@
|
|
|
1
1
|
import type { Catchupv2Options } from '../types';
|
|
2
|
+
import type { StepJson } from '@atlaskit/editor-common/collab';
|
|
2
3
|
export declare const catchupv2: (opt: Catchupv2Options) => Promise<boolean>;
|
|
4
|
+
/**
|
|
5
|
+
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
6
|
+
* @param fromVersion The document's PM version from before we applied catchup
|
|
7
|
+
* @param currentVersion The document's PM version after we applied catchup
|
|
8
|
+
* @param steps Steps returned to us by catchup
|
|
9
|
+
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
10
|
+
* @returns True if we're out of sync, false if not.
|
|
11
|
+
*/
|
|
12
|
+
export declare const isOutOfSync: (fromVersion: number, currentVersion: number, steps: StepJson[], clientId: string | number) => boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.26.
|
|
3
|
+
"version": "9.26.6",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@atlaskit/analytics-gas-types": "^5.1.0",
|
|
41
41
|
"@atlaskit/analytics-listeners": "^8.9.0",
|
|
42
|
-
"@atlaskit/editor-common": "^78.
|
|
42
|
+
"@atlaskit/editor-common": "^78.30.0",
|
|
43
43
|
"@atlaskit/editor-json-transformer": "^8.10.0",
|
|
44
44
|
"@atlaskit/editor-prosemirror": "3.0.0",
|
|
45
45
|
"@atlaskit/platform-feature-flags": "^0.2.0",
|