@atlaskit/collab-provider 8.6.0 → 8.8.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 +26 -0
- package/dist/cjs/analytics/analytics-helper.js +25 -28
- package/dist/cjs/analytics/performance.js +4 -4
- package/dist/cjs/channel.js +218 -224
- package/dist/cjs/connectivity/network.js +4 -4
- package/dist/cjs/disconnected-reason-mapper.js +4 -4
- package/dist/cjs/document/catchup.js +84 -87
- package/dist/cjs/document/document-service.js +205 -234
- package/dist/cjs/document/step-queue-state.js +4 -5
- package/dist/cjs/errors/error-types.js +25 -24
- package/dist/cjs/helpers/const.js +12 -12
- package/dist/cjs/metadata/metadata-service.js +15 -20
- package/dist/cjs/participants/participants-helper.js +22 -32
- package/dist/cjs/participants/participants-service.js +89 -101
- package/dist/cjs/participants/participants-state.js +2 -4
- package/dist/cjs/provider/index.js +130 -136
- package/dist/cjs/types.js +11 -5
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/analytics-helper.js +3 -3
- package/dist/es2019/analytics/performance.js +3 -3
- package/dist/es2019/channel.js +21 -20
- package/dist/es2019/connectivity/network.js +3 -3
- package/dist/es2019/disconnected-reason-mapper.js +3 -3
- package/dist/es2019/document/document-service.js +17 -25
- package/dist/es2019/document/step-queue-state.js +4 -5
- package/dist/es2019/errors/error-types.js +26 -25
- package/dist/es2019/helpers/const.js +9 -9
- package/dist/es2019/metadata/metadata-service.js +15 -19
- package/dist/es2019/participants/participants-helper.js +3 -8
- package/dist/es2019/participants/participants-service.js +42 -52
- package/dist/es2019/participants/participants-state.js +1 -2
- package/dist/es2019/provider/index.js +68 -71
- package/dist/es2019/types.js +13 -3
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/analytics-helper.js +25 -28
- package/dist/esm/analytics/performance.js +3 -3
- package/dist/esm/channel.js +218 -224
- package/dist/esm/connectivity/network.js +3 -3
- package/dist/esm/disconnected-reason-mapper.js +3 -3
- package/dist/esm/document/catchup.js +84 -87
- package/dist/esm/document/document-service.js +205 -234
- package/dist/esm/document/step-queue-state.js +4 -5
- package/dist/esm/errors/error-types.js +26 -25
- package/dist/esm/helpers/const.js +9 -9
- package/dist/esm/metadata/metadata-service.js +15 -20
- package/dist/esm/participants/participants-helper.js +22 -32
- package/dist/esm/participants/participants-service.js +89 -101
- package/dist/esm/participants/participants-state.js +2 -4
- package/dist/esm/provider/index.js +130 -136
- package/dist/esm/types.js +13 -3
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/channel.d.ts +1 -1
- package/dist/types/feature-flags/types.d.ts +1 -1
- package/dist/types/metadata/metadata-service.d.ts +1 -1
- package/dist/types/participants/participants-helper.d.ts +2 -3
- package/dist/types/participants/participants-service.d.ts +4 -8
- package/dist/types/provider/index.d.ts +6 -0
- package/dist/types/types.d.ts +15 -9
- package/package.json +16 -11
- package/report.api.md +11 -5
- package/channel/package.json +0 -15
- package/config/package.json +0 -15
- package/disconnected-reason-mapper/package.json +0 -15
- package/emitter/package.json +0 -15
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
2
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
3
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
4
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
5
|
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; }
|
|
7
6
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
8
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
9
8
|
import { ACK_MAX_TRY, EVENT_ACTION, EVENT_STATUS } from '../helpers/const';
|
|
10
9
|
import { getVersion, sendableSteps } from '@atlaskit/prosemirror-collab';
|
|
11
10
|
import { createLogger, sleep } from '../helpers/utils';
|
|
@@ -22,8 +21,6 @@ var CATCHUP_THROTTLE = 1 * 1000; // 1 second
|
|
|
22
21
|
var noop = function noop() {};
|
|
23
22
|
var logger = createLogger('documentService', 'black');
|
|
24
23
|
export var DocumentService = /*#__PURE__*/function () {
|
|
25
|
-
// Fires analytics to editor when collab editor cannot sync up
|
|
26
|
-
|
|
27
24
|
// ClientID is the unique ID for a prosemirror client. Used for step-rebasing.
|
|
28
25
|
|
|
29
26
|
/**
|
|
@@ -41,7 +38,11 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
41
38
|
function DocumentService(participantsService, analyticsHelper, fetchCatchup, providerEmitCallback, broadcast, getUserId, onErrorHandled, metadataService) {
|
|
42
39
|
var _this = this;
|
|
43
40
|
_classCallCheck(this, DocumentService);
|
|
41
|
+
// Fires analytics to editor when collab editor cannot sync up
|
|
44
42
|
_defineProperty(this, "stepRejectCounter", 0);
|
|
43
|
+
/**
|
|
44
|
+
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
45
|
+
*/
|
|
45
46
|
_defineProperty(this, "throttledCatchup", throttle(function () {
|
|
46
47
|
return _this.catchup();
|
|
47
48
|
}, CATCHUP_THROTTLE, {
|
|
@@ -49,59 +50,62 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
49
50
|
// TODO: why shouldn't this be leading?
|
|
50
51
|
trailing: true
|
|
51
52
|
}));
|
|
52
|
-
|
|
53
|
+
/**
|
|
54
|
+
* Called when:
|
|
55
|
+
* * session established(offline -> online)
|
|
56
|
+
* * try to accept steps but version is behind.
|
|
57
|
+
*/
|
|
58
|
+
_defineProperty(this, "catchup", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
53
59
|
var start, _this$analyticsHelper, latency, _this$analyticsHelper2, _this$analyticsHelper3, _latency;
|
|
54
|
-
return _regeneratorRuntime
|
|
55
|
-
while (1) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
_context.next = 4;
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
logger("Queue is paused. Aborting.");
|
|
64
|
-
return _context.abrupt("return");
|
|
65
|
-
case 4:
|
|
66
|
-
_this.stepQueue.pauseQueue();
|
|
67
|
-
_context.prev = 5;
|
|
68
|
-
_context.next = 8;
|
|
69
|
-
return catchup({
|
|
70
|
-
getCurrentPmVersion: _this.getCurrentPmVersion,
|
|
71
|
-
fetchCatchup: _this.fetchCatchup,
|
|
72
|
-
getUnconfirmedSteps: _this.getUnconfirmedSteps,
|
|
73
|
-
filterQueue: _this.stepQueue.filterQueue,
|
|
74
|
-
applyLocalSteps: _this.applyLocalSteps,
|
|
75
|
-
updateDocument: _this.updateDocument,
|
|
76
|
-
updateMetadata: _this.metadataService.updateMetadata
|
|
77
|
-
});
|
|
78
|
-
case 8:
|
|
79
|
-
latency = new Date().getTime() - start;
|
|
80
|
-
(_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
|
|
81
|
-
latency: latency
|
|
82
|
-
});
|
|
83
|
-
_context.next = 18;
|
|
60
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
61
|
+
while (1) switch (_context.prev = _context.next) {
|
|
62
|
+
case 0:
|
|
63
|
+
start = new Date().getTime(); // if the queue is already paused, we are busy with something else, so don't proceed.
|
|
64
|
+
if (!_this.stepQueue.isPaused()) {
|
|
65
|
+
_context.next = 4;
|
|
84
66
|
break;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
_this.stepQueue.
|
|
97
|
-
_this.
|
|
98
|
-
_this.
|
|
99
|
-
_this.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
67
|
+
}
|
|
68
|
+
logger("Queue is paused. Aborting.");
|
|
69
|
+
return _context.abrupt("return");
|
|
70
|
+
case 4:
|
|
71
|
+
_this.stepQueue.pauseQueue();
|
|
72
|
+
_context.prev = 5;
|
|
73
|
+
_context.next = 8;
|
|
74
|
+
return catchup({
|
|
75
|
+
getCurrentPmVersion: _this.getCurrentPmVersion,
|
|
76
|
+
fetchCatchup: _this.fetchCatchup,
|
|
77
|
+
getUnconfirmedSteps: _this.getUnconfirmedSteps,
|
|
78
|
+
filterQueue: _this.stepQueue.filterQueue,
|
|
79
|
+
applyLocalSteps: _this.applyLocalSteps,
|
|
80
|
+
updateDocument: _this.updateDocument,
|
|
81
|
+
updateMetadata: _this.metadataService.updateMetadata
|
|
82
|
+
});
|
|
83
|
+
case 8:
|
|
84
|
+
latency = new Date().getTime() - start;
|
|
85
|
+
(_this$analyticsHelper = _this.analyticsHelper) === null || _this$analyticsHelper === void 0 ? void 0 : _this$analyticsHelper.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.SUCCESS, {
|
|
86
|
+
latency: latency
|
|
87
|
+
});
|
|
88
|
+
_context.next = 18;
|
|
89
|
+
break;
|
|
90
|
+
case 12:
|
|
91
|
+
_context.prev = 12;
|
|
92
|
+
_context.t0 = _context["catch"](5);
|
|
93
|
+
_latency = new Date().getTime() - start;
|
|
94
|
+
(_this$analyticsHelper2 = _this.analyticsHelper) === null || _this$analyticsHelper2 === void 0 ? void 0 : _this$analyticsHelper2.sendActionEvent(EVENT_ACTION.CATCHUP, EVENT_STATUS.FAILURE, {
|
|
95
|
+
latency: _latency
|
|
96
|
+
});
|
|
97
|
+
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(_context.t0, 'Error while catching up');
|
|
98
|
+
logger("Catch-Up Failed:", _context.t0.message);
|
|
99
|
+
case 18:
|
|
100
|
+
_context.prev = 18;
|
|
101
|
+
_this.stepQueue.resumeQueue();
|
|
102
|
+
_this.processQueue();
|
|
103
|
+
_this.sendStepsFromCurrentState(); // this will eventually retry catchup as it calls commitStep which will either catchup on onStepsAdded or onErrorHandled
|
|
104
|
+
_this.stepRejectCounter = 0;
|
|
105
|
+
return _context.finish(18);
|
|
106
|
+
case 24:
|
|
107
|
+
case "end":
|
|
108
|
+
return _context.stop();
|
|
105
109
|
}
|
|
106
110
|
}, _callee, null, [[5, 12, 18, 24]]);
|
|
107
111
|
})));
|
|
@@ -115,41 +119,39 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
115
119
|
}
|
|
116
120
|
return getVersion(state);
|
|
117
121
|
});
|
|
118
|
-
_defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
122
|
+
_defineProperty(this, "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
119
123
|
var _this$analyticsHelper5, state, adfDocument, currentState, measure, _this$analyticsHelper6, _this$analyticsHelper7, _measure;
|
|
120
|
-
return _regeneratorRuntime
|
|
121
|
-
while (1) {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
startMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
124
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
125
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
126
|
+
case 0:
|
|
127
|
+
_context2.prev = 0;
|
|
128
|
+
startMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
126
129
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
130
|
+
// Convert ProseMirror document in Editor state to ADF document
|
|
131
|
+
state = _this.getState();
|
|
132
|
+
adfDocument = new JSONTransformer().encode(state.doc);
|
|
133
|
+
currentState = {
|
|
134
|
+
content: adfDocument,
|
|
135
|
+
title: _this.metadataService.getTitle(),
|
|
136
|
+
stepVersion: getVersion(state)
|
|
137
|
+
};
|
|
138
|
+
measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
139
|
+
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.SUCCESS, {
|
|
140
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
141
|
+
});
|
|
142
|
+
return _context2.abrupt("return", currentState);
|
|
143
|
+
case 10:
|
|
144
|
+
_context2.prev = 10;
|
|
145
|
+
_context2.t0 = _context2["catch"](0);
|
|
146
|
+
_measure = stopMeasure(MEASURE_NAME.GET_CURRENT_STATE, _this.analyticsHelper);
|
|
147
|
+
(_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendActionEvent(EVENT_ACTION.GET_CURRENT_STATE, EVENT_STATUS.FAILURE, {
|
|
148
|
+
latency: _measure === null || _measure === void 0 ? void 0 : _measure.duration
|
|
149
|
+
});
|
|
150
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(_context2.t0, 'Error while returning ADF version of current draft document');
|
|
151
|
+
throw _context2.t0;
|
|
152
|
+
case 16:
|
|
153
|
+
case "end":
|
|
154
|
+
return _context2.stop();
|
|
153
155
|
}
|
|
154
156
|
}, _callee2, null, [[0, 10]]);
|
|
155
157
|
})));
|
|
@@ -179,6 +181,9 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
179
181
|
steps: steps
|
|
180
182
|
});
|
|
181
183
|
});
|
|
184
|
+
/**
|
|
185
|
+
* Called when we receive steps from the service
|
|
186
|
+
*/
|
|
182
187
|
_defineProperty(this, "onStepsAdded", function (data) {
|
|
183
188
|
logger("Received steps", {
|
|
184
189
|
steps: data.steps,
|
|
@@ -217,6 +222,7 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
217
222
|
});
|
|
218
223
|
}
|
|
219
224
|
});
|
|
225
|
+
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
220
226
|
_defineProperty(this, "onRestore", function (_ref4) {
|
|
221
227
|
var doc = _ref4.doc,
|
|
222
228
|
version = _ref4.version,
|
|
@@ -262,39 +268,37 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
262
268
|
});
|
|
263
269
|
}
|
|
264
270
|
});
|
|
265
|
-
_defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
271
|
+
_defineProperty(this, "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
|
|
266
272
|
var _this$analyticsHelper14, currentState, measure, _this$analyticsHelper15, _this$analyticsHelper16, _measure2;
|
|
267
|
-
return _regeneratorRuntime
|
|
268
|
-
while (1) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
return _context3.stop();
|
|
297
|
-
}
|
|
273
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
274
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
275
|
+
case 0:
|
|
276
|
+
_context3.prev = 0;
|
|
277
|
+
startMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
278
|
+
_context3.next = 4;
|
|
279
|
+
return _this.commitUnconfirmedSteps();
|
|
280
|
+
case 4:
|
|
281
|
+
_context3.next = 6;
|
|
282
|
+
return _this.getCurrentState();
|
|
283
|
+
case 6:
|
|
284
|
+
currentState = _context3.sent;
|
|
285
|
+
measure = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
286
|
+
(_this$analyticsHelper14 = _this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.SUCCESS, {
|
|
287
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration
|
|
288
|
+
});
|
|
289
|
+
return _context3.abrupt("return", currentState);
|
|
290
|
+
case 12:
|
|
291
|
+
_context3.prev = 12;
|
|
292
|
+
_context3.t0 = _context3["catch"](0);
|
|
293
|
+
_measure2 = stopMeasure(MEASURE_NAME.PUBLISH_PAGE, _this.analyticsHelper);
|
|
294
|
+
(_this$analyticsHelper15 = _this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendActionEvent(EVENT_ACTION.PUBLISH_PAGE, EVENT_STATUS.FAILURE, {
|
|
295
|
+
latency: _measure2 === null || _measure2 === void 0 ? void 0 : _measure2.duration
|
|
296
|
+
});
|
|
297
|
+
(_this$analyticsHelper16 = _this.analyticsHelper) === null || _this$analyticsHelper16 === void 0 ? void 0 : _this$analyticsHelper16.sendErrorEvent(_context3.t0, 'Error while returning ADF version of the final draft document');
|
|
298
|
+
throw _context3.t0;
|
|
299
|
+
case 18:
|
|
300
|
+
case "end":
|
|
301
|
+
return _context3.stop();
|
|
298
302
|
}
|
|
299
303
|
}, _callee3, null, [[0, 12]]);
|
|
300
304
|
})));
|
|
@@ -311,102 +315,90 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
311
315
|
reserveCursor: reserveCursor
|
|
312
316
|
} : {}));
|
|
313
317
|
});
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
isLastTrConfirmed = true;
|
|
358
|
-
}
|
|
359
|
-
if (!(!isLastTrConfirmed && count++ >= ACK_MAX_TRY)) {
|
|
360
|
-
_context4.next = 14;
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
if (_this.onSyncUpError) {
|
|
364
|
-
state = _this.getState();
|
|
365
|
-
_this.onSyncUpError({
|
|
366
|
-
lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
|
|
367
|
-
tries: count,
|
|
368
|
-
maxRetries: ACK_MAX_TRY,
|
|
369
|
-
clientId: _this.clientId,
|
|
370
|
-
version: getVersion(state)
|
|
371
|
-
});
|
|
372
|
-
}
|
|
373
|
-
throw new Error("Can't sync up with Collab Service");
|
|
374
|
-
case 14:
|
|
375
|
-
_context4.next = 5;
|
|
376
|
-
break;
|
|
377
|
-
case 16:
|
|
378
|
-
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
379
|
-
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
380
|
-
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
381
|
-
// upon success, emit the total number of unconfirmed steps we synced
|
|
382
|
-
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
383
|
-
});
|
|
384
|
-
case 18:
|
|
385
|
-
case "end":
|
|
386
|
-
return _context4.stop();
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}, _callee4);
|
|
390
|
-
})(), "t0", 4);
|
|
391
|
-
case 4:
|
|
392
|
-
_context5.next = 12;
|
|
318
|
+
/**
|
|
319
|
+
* Commit the unconfirmed local steps to the back-end service
|
|
320
|
+
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
321
|
+
*/
|
|
322
|
+
_defineProperty(this, "commitUnconfirmedSteps", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
|
323
|
+
var unconfirmedSteps, _this$analyticsHelper17, count, unconfirmedTrs, lastTr, isLastTrConfirmed, nextUnconfirmedSteps, nextUnconfirmedTrs, state, measure, _this$analyticsHelper18, _this$analyticsHelper19, _measure3;
|
|
324
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
325
|
+
while (1) switch (_context4.prev = _context4.next) {
|
|
326
|
+
case 0:
|
|
327
|
+
unconfirmedSteps = _this.getUnconfirmedSteps();
|
|
328
|
+
_context4.prev = 1;
|
|
329
|
+
if (!(unconfirmedSteps !== null && unconfirmedSteps !== void 0 && unconfirmedSteps.length)) {
|
|
330
|
+
_context4.next = 21;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
startMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
334
|
+
count = 0; // We use origins here as steps can be rebased. When steps are rebased a new step is created.
|
|
335
|
+
// This means that we can not track if it has been removed from the unconfirmed array or not.
|
|
336
|
+
// Origins points to the original transaction that the step was created in. This is never changed
|
|
337
|
+
// and gets passed down when a step is rebased.
|
|
338
|
+
unconfirmedTrs = _this.getUnconfirmedStepsOrigins();
|
|
339
|
+
lastTr = unconfirmedTrs === null || unconfirmedTrs === void 0 ? void 0 : unconfirmedTrs[unconfirmedTrs.length - 1];
|
|
340
|
+
isLastTrConfirmed = false;
|
|
341
|
+
case 8:
|
|
342
|
+
if (isLastTrConfirmed) {
|
|
343
|
+
_context4.next = 19;
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
_this.sendStepsFromCurrentState();
|
|
347
|
+
_context4.next = 12;
|
|
348
|
+
return sleep(1000);
|
|
349
|
+
case 12:
|
|
350
|
+
nextUnconfirmedSteps = _this.getUnconfirmedSteps();
|
|
351
|
+
if (nextUnconfirmedSteps !== null && nextUnconfirmedSteps !== void 0 && nextUnconfirmedSteps.length) {
|
|
352
|
+
nextUnconfirmedTrs = _this.getUnconfirmedStepsOrigins();
|
|
353
|
+
isLastTrConfirmed = !(nextUnconfirmedTrs !== null && nextUnconfirmedTrs !== void 0 && nextUnconfirmedTrs.some(function (tr) {
|
|
354
|
+
return tr === lastTr;
|
|
355
|
+
}));
|
|
356
|
+
} else {
|
|
357
|
+
isLastTrConfirmed = true;
|
|
358
|
+
}
|
|
359
|
+
if (!(!isLastTrConfirmed && count++ >= ACK_MAX_TRY)) {
|
|
360
|
+
_context4.next = 17;
|
|
393
361
|
break;
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
362
|
+
}
|
|
363
|
+
if (_this.onSyncUpError) {
|
|
364
|
+
state = _this.getState();
|
|
365
|
+
_this.onSyncUpError({
|
|
366
|
+
lengthOfUnconfirmedSteps: nextUnconfirmedSteps === null || nextUnconfirmedSteps === void 0 ? void 0 : nextUnconfirmedSteps.length,
|
|
367
|
+
tries: count,
|
|
368
|
+
maxRetries: ACK_MAX_TRY,
|
|
369
|
+
clientId: _this.clientId,
|
|
370
|
+
version: getVersion(state)
|
|
401
371
|
});
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
372
|
+
}
|
|
373
|
+
throw new Error("Can't sync up with Collab Service");
|
|
374
|
+
case 17:
|
|
375
|
+
_context4.next = 8;
|
|
376
|
+
break;
|
|
377
|
+
case 19:
|
|
378
|
+
measure = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
379
|
+
(_this$analyticsHelper17 = _this.analyticsHelper) === null || _this$analyticsHelper17 === void 0 ? void 0 : _this$analyticsHelper17.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.SUCCESS, {
|
|
380
|
+
latency: measure === null || measure === void 0 ? void 0 : measure.duration,
|
|
381
|
+
// upon success, emit the total number of unconfirmed steps we synced
|
|
382
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
383
|
+
});
|
|
384
|
+
case 21:
|
|
385
|
+
_context4.next = 29;
|
|
386
|
+
break;
|
|
387
|
+
case 23:
|
|
388
|
+
_context4.prev = 23;
|
|
389
|
+
_context4.t0 = _context4["catch"](1);
|
|
390
|
+
_measure3 = stopMeasure(MEASURE_NAME.COMMIT_UNCONFIRMED_STEPS, _this.analyticsHelper);
|
|
391
|
+
(_this$analyticsHelper18 = _this.analyticsHelper) === null || _this$analyticsHelper18 === void 0 ? void 0 : _this$analyticsHelper18.sendActionEvent(EVENT_ACTION.COMMIT_UNCONFIRMED_STEPS, EVENT_STATUS.FAILURE, {
|
|
392
|
+
latency: _measure3 === null || _measure3 === void 0 ? void 0 : _measure3.duration,
|
|
393
|
+
numUnconfirmedSteps: unconfirmedSteps === null || unconfirmedSteps === void 0 ? void 0 : unconfirmedSteps.length
|
|
394
|
+
});
|
|
395
|
+
(_this$analyticsHelper19 = _this.analyticsHelper) === null || _this$analyticsHelper19 === void 0 ? void 0 : _this$analyticsHelper19.sendErrorEvent(_context4.t0, 'Error while committing unconfirmed steps');
|
|
396
|
+
throw _context4.t0;
|
|
397
|
+
case 29:
|
|
398
|
+
case "end":
|
|
399
|
+
return _context4.stop();
|
|
408
400
|
}
|
|
409
|
-
},
|
|
401
|
+
}, _callee4, null, [[1, 23]]);
|
|
410
402
|
})));
|
|
411
403
|
_defineProperty(this, "onStepRejectedError", function () {
|
|
412
404
|
_this.stepRejectCounter++;
|
|
@@ -434,16 +426,6 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
434
426
|
this.metadataService = metadataService;
|
|
435
427
|
this.stepQueue = new StepQueueState();
|
|
436
428
|
}
|
|
437
|
-
|
|
438
|
-
/**
|
|
439
|
-
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
440
|
-
*/
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* Called when:
|
|
444
|
-
* * session established(offline -> online)
|
|
445
|
-
* * try to accept steps but version is behind.
|
|
446
|
-
*/
|
|
447
429
|
_createClass(DocumentService, [{
|
|
448
430
|
key: "processQueue",
|
|
449
431
|
value: function processQueue() {
|
|
@@ -500,17 +482,6 @@ export var DocumentService = /*#__PURE__*/function () {
|
|
|
500
482
|
}
|
|
501
483
|
}
|
|
502
484
|
}
|
|
503
|
-
|
|
504
|
-
/**
|
|
505
|
-
* Called when we receive steps from the service
|
|
506
|
-
*/
|
|
507
|
-
|
|
508
|
-
// Triggered when page recovery has emitted an 'init' event on a page client is currently connected to.
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Commit the unconfirmed local steps to the back-end service
|
|
512
|
-
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
513
|
-
*/
|
|
514
485
|
}, {
|
|
515
486
|
key: "setup",
|
|
516
487
|
value: function setup(_ref9) {
|
|
@@ -16,6 +16,10 @@ export var StepQueueState = /*#__PURE__*/function () {
|
|
|
16
16
|
_defineProperty(this, "filterQueue", function (condition) {
|
|
17
17
|
_this.queue = _this.queue.filter(condition);
|
|
18
18
|
});
|
|
19
|
+
/**
|
|
20
|
+
* Get whether the document service has stopped processing new steps whilst it carries out processes such as catchup.
|
|
21
|
+
* Exposed for testing
|
|
22
|
+
*/
|
|
19
23
|
_defineProperty(this, "isPaused", function () {
|
|
20
24
|
return _this.queuePaused;
|
|
21
25
|
});
|
|
@@ -38,11 +42,6 @@ export var StepQueueState = /*#__PURE__*/function () {
|
|
|
38
42
|
});
|
|
39
43
|
this.queue = orderedQueue;
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get whether the document service has stopped processing new steps whilst it carries out processes such as catchup.
|
|
44
|
-
* Exposed for testing
|
|
45
|
-
*/
|
|
46
45
|
}]);
|
|
47
46
|
return StepQueueState;
|
|
48
47
|
}();
|