@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
package/dist/esm/channel.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
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";
|
|
@@ -7,7 +6,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
6
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
7
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
8
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
-
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; }
|
|
9
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
10
|
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; }
|
|
12
11
|
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; }
|
|
13
12
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
@@ -35,6 +34,7 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
35
34
|
_defineProperty(_assertThisInitialized(_this), "reconnectHelper", null);
|
|
36
35
|
_defineProperty(_assertThisInitialized(_this), "initialized", false);
|
|
37
36
|
_defineProperty(_assertThisInitialized(_this), "network", null);
|
|
37
|
+
// read-only getters used for tests
|
|
38
38
|
_defineProperty(_assertThisInitialized(_this), "getInitialized", function () {
|
|
39
39
|
return _this.initialized;
|
|
40
40
|
});
|
|
@@ -52,6 +52,7 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
52
52
|
_this.token = value;
|
|
53
53
|
}
|
|
54
54
|
});
|
|
55
|
+
// sets the token as undefined
|
|
55
56
|
_defineProperty(_assertThisInitialized(_this), "unsetToken", function () {
|
|
56
57
|
return _this.setToken();
|
|
57
58
|
});
|
|
@@ -175,134 +176,132 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
175
176
|
}
|
|
176
177
|
});
|
|
177
178
|
_defineProperty(_assertThisInitialized(_this), "fetchCatchup", /*#__PURE__*/function () {
|
|
178
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
179
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(fromVersion) {
|
|
179
180
|
var _ref2, _this$token, _yield$utils$requestS, doc, version, stepMaps, metadata, errorNotFound, errorCatchup;
|
|
180
|
-
return _regeneratorRuntime
|
|
181
|
-
while (1) {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
_context.next = 29;
|
|
196
|
-
break;
|
|
197
|
-
}
|
|
198
|
-
if (!((_this$token = _this.token) !== null && _this$token !== void 0)) {
|
|
199
|
-
_context.next = 13;
|
|
200
|
-
break;
|
|
201
|
-
}
|
|
202
|
-
_context.t9 = _this$token;
|
|
203
|
-
_context.next = 16;
|
|
181
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
182
|
+
while (1) switch (_context.prev = _context.next) {
|
|
183
|
+
case 0:
|
|
184
|
+
_context.prev = 0;
|
|
185
|
+
_context.t0 = utils;
|
|
186
|
+
_context.t1 = _this.config;
|
|
187
|
+
_context.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchup");
|
|
188
|
+
_context.t3 = {
|
|
189
|
+
version: fromVersion
|
|
190
|
+
};
|
|
191
|
+
_context.t4 = _objectSpread;
|
|
192
|
+
_context.t5 = _objectSpread;
|
|
193
|
+
_context.t6 = {};
|
|
194
|
+
if (!_this.config.permissionTokenRefresh) {
|
|
195
|
+
_context.next = 29;
|
|
204
196
|
break;
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
if (!_context.t8) {
|
|
219
|
-
_context.next = 20;
|
|
220
|
-
break;
|
|
221
|
-
}
|
|
222
|
-
_context.t8 = _ref2 !== void 0;
|
|
223
|
-
case 20:
|
|
224
|
-
if (!_context.t8) {
|
|
225
|
-
_context.next = 24;
|
|
226
|
-
break;
|
|
197
|
+
}
|
|
198
|
+
if (!((_this$token = _this.token) !== null && _this$token !== void 0)) {
|
|
199
|
+
_context.next = 13;
|
|
200
|
+
break;
|
|
201
|
+
}
|
|
202
|
+
_context.t9 = _this$token;
|
|
203
|
+
_context.next = 16;
|
|
204
|
+
break;
|
|
205
|
+
case 13:
|
|
206
|
+
_context.next = 15;
|
|
207
|
+
return _this.config.permissionTokenRefresh().then(function (token) {
|
|
208
|
+
if (token) {
|
|
209
|
+
_this.setToken(token);
|
|
227
210
|
}
|
|
228
|
-
|
|
229
|
-
|
|
211
|
+
return token;
|
|
212
|
+
});
|
|
213
|
+
case 15:
|
|
214
|
+
_context.t9 = _context.sent;
|
|
215
|
+
case 16:
|
|
216
|
+
_context.t10 = _ref2 = _context.t9;
|
|
217
|
+
_context.t8 = _context.t10 !== null;
|
|
218
|
+
if (!_context.t8) {
|
|
219
|
+
_context.next = 20;
|
|
230
220
|
break;
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
_context.
|
|
236
|
-
'x-token': _context.t12
|
|
237
|
-
};
|
|
238
|
-
_context.next = 30;
|
|
221
|
+
}
|
|
222
|
+
_context.t8 = _ref2 !== void 0;
|
|
223
|
+
case 20:
|
|
224
|
+
if (!_context.t8) {
|
|
225
|
+
_context.next = 24;
|
|
239
226
|
break;
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
227
|
+
}
|
|
228
|
+
_context.t11 = _ref2;
|
|
229
|
+
_context.next = 25;
|
|
230
|
+
break;
|
|
231
|
+
case 24:
|
|
232
|
+
_context.t11 = undefined;
|
|
233
|
+
case 25:
|
|
234
|
+
_context.t12 = _context.t11;
|
|
235
|
+
_context.t7 = {
|
|
236
|
+
'x-token': _context.t12
|
|
237
|
+
};
|
|
238
|
+
_context.next = 30;
|
|
239
|
+
break;
|
|
240
|
+
case 29:
|
|
241
|
+
_context.t7 = {};
|
|
242
|
+
case 30:
|
|
243
|
+
_context.t13 = _context.t7;
|
|
244
|
+
_context.t14 = (0, _context.t5)(_context.t6, _context.t13);
|
|
245
|
+
_context.t15 = {};
|
|
246
|
+
_context.t16 = {
|
|
247
|
+
'x-product': getProduct(_this.config.productInfo),
|
|
248
|
+
'x-subproduct': getSubProduct(_this.config.productInfo)
|
|
249
|
+
};
|
|
250
|
+
_context.t17 = (0, _context.t4)(_context.t14, _context.t15, _context.t16);
|
|
251
|
+
_context.t18 = {
|
|
252
|
+
headers: _context.t17
|
|
253
|
+
};
|
|
254
|
+
_context.t19 = {
|
|
255
|
+
path: _context.t2,
|
|
256
|
+
queryParams: _context.t3,
|
|
257
|
+
requestInit: _context.t18
|
|
258
|
+
};
|
|
259
|
+
_context.next = 39;
|
|
260
|
+
return _context.t0.requestService.call(_context.t0, _context.t1, _context.t19);
|
|
261
|
+
case 39:
|
|
262
|
+
_yield$utils$requestS = _context.sent;
|
|
263
|
+
doc = _yield$utils$requestS.doc;
|
|
264
|
+
version = _yield$utils$requestS.version;
|
|
265
|
+
stepMaps = _yield$utils$requestS.stepMaps;
|
|
266
|
+
metadata = _yield$utils$requestS.metadata;
|
|
267
|
+
return _context.abrupt("return", {
|
|
268
|
+
doc: doc,
|
|
269
|
+
version: version,
|
|
270
|
+
stepMaps: stepMaps,
|
|
271
|
+
metadata: metadata
|
|
272
|
+
});
|
|
273
|
+
case 47:
|
|
274
|
+
_context.prev = 47;
|
|
275
|
+
_context.t20 = _context["catch"](0);
|
|
276
|
+
if (!(_context.t20.code === 404)) {
|
|
277
|
+
_context.next = 53;
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
errorNotFound = {
|
|
281
|
+
message: 'The requested document is not found',
|
|
282
|
+
data: {
|
|
283
|
+
status: _context.t20.code,
|
|
284
|
+
code: INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
|
|
279
285
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
};
|
|
300
|
-
_this.emit('error', errorCatchup);
|
|
301
|
-
throw _context.t20;
|
|
302
|
-
case 58:
|
|
303
|
-
case "end":
|
|
304
|
-
return _context.stop();
|
|
305
|
-
}
|
|
286
|
+
};
|
|
287
|
+
_this.emit('error', errorNotFound);
|
|
288
|
+
return _context.abrupt("return", {});
|
|
289
|
+
case 53:
|
|
290
|
+
//nullify token so it is forced to generate new token on reconnect
|
|
291
|
+
_this.unsetToken();
|
|
292
|
+
logger("Can't fetch the catchup", _context.t20.message);
|
|
293
|
+
errorCatchup = {
|
|
294
|
+
message: 'Cannot fetch catchup from collab service',
|
|
295
|
+
data: {
|
|
296
|
+
status: _context.t20.status,
|
|
297
|
+
code: INTERNAL_ERROR_CODE.CATCHUP_FAILED
|
|
298
|
+
}
|
|
299
|
+
};
|
|
300
|
+
_this.emit('error', errorCatchup);
|
|
301
|
+
throw _context.t20;
|
|
302
|
+
case 58:
|
|
303
|
+
case "end":
|
|
304
|
+
return _context.stop();
|
|
306
305
|
}
|
|
307
306
|
}, _callee, null, [[0, 47]]);
|
|
308
307
|
}));
|
|
@@ -310,6 +309,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
310
309
|
return _ref.apply(this, arguments);
|
|
311
310
|
};
|
|
312
311
|
}());
|
|
312
|
+
/**
|
|
313
|
+
* Send message to the back-end service over the channel. Timestamp will be added server side.
|
|
314
|
+
* @throws {NotInitializedError} Channel not initialized
|
|
315
|
+
* @throws {NotConnectedError} Channel not connected
|
|
316
|
+
*/
|
|
313
317
|
_defineProperty(_assertThisInitialized(_this), "broadcast", function (type, data, callback) {
|
|
314
318
|
if (!_this.socket) {
|
|
315
319
|
throw new NotInitializedError('Cannot broadcast, not initialized yet');
|
|
@@ -324,6 +328,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
324
328
|
type: type
|
|
325
329
|
}, data), callback);
|
|
326
330
|
});
|
|
331
|
+
/**
|
|
332
|
+
* Send metadata to the back-end service over the channel
|
|
333
|
+
* @throws {NotInitializedError} Channel not initialized
|
|
334
|
+
* @throws {NotConnectedError} Channel not connected
|
|
335
|
+
*/
|
|
327
336
|
_defineProperty(_assertThisInitialized(_this), "sendMetadata", function (metadata) {
|
|
328
337
|
if (!_this.socket) {
|
|
329
338
|
throw new NotInitializedError('Cannot send metadata, not initialized yet');
|
|
@@ -348,10 +357,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
348
357
|
_this.initExperience = createDocInitExp(_this.analyticsHelper);
|
|
349
358
|
return _this;
|
|
350
359
|
}
|
|
351
|
-
|
|
352
|
-
// read-only getters used for tests
|
|
353
|
-
|
|
354
|
-
// sets the token as undefined
|
|
355
360
|
_createClass(Channel, [{
|
|
356
361
|
key: "connect",
|
|
357
362
|
value:
|
|
@@ -388,57 +393,55 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
388
393
|
};
|
|
389
394
|
if (permissionTokenRefresh) {
|
|
390
395
|
auth = /*#__PURE__*/function () {
|
|
391
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
396
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(cb) {
|
|
392
397
|
var token, _err, _err$data, _err$data$meta, authenticationError;
|
|
393
|
-
return _regeneratorRuntime
|
|
394
|
-
while (1) {
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
_context2.next = 5;
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
authData.token = _this2.token;
|
|
402
|
-
cb(authData);
|
|
403
|
-
_context2.next = 17;
|
|
404
|
-
break;
|
|
405
|
-
case 5:
|
|
406
|
-
_context2.prev = 5;
|
|
407
|
-
_context2.next = 8;
|
|
408
|
-
return permissionTokenRefresh();
|
|
409
|
-
case 8:
|
|
410
|
-
token = _context2.sent;
|
|
411
|
-
if (token) {
|
|
412
|
-
// save token locally
|
|
413
|
-
_this2.setToken(token);
|
|
414
|
-
authData.token = token;
|
|
415
|
-
}
|
|
416
|
-
cb(authData);
|
|
417
|
-
_context2.next = 17;
|
|
398
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
399
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
400
|
+
case 0:
|
|
401
|
+
if (!(cacheToken && _this2.token)) {
|
|
402
|
+
_context2.next = 5;
|
|
418
403
|
break;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
404
|
+
}
|
|
405
|
+
authData.token = _this2.token;
|
|
406
|
+
cb(authData);
|
|
407
|
+
_context2.next = 17;
|
|
408
|
+
break;
|
|
409
|
+
case 5:
|
|
410
|
+
_context2.prev = 5;
|
|
411
|
+
_context2.next = 8;
|
|
412
|
+
return permissionTokenRefresh();
|
|
413
|
+
case 8:
|
|
414
|
+
token = _context2.sent;
|
|
415
|
+
if (token) {
|
|
416
|
+
// save token locally
|
|
417
|
+
_this2.setToken(token);
|
|
418
|
+
authData.token = token;
|
|
419
|
+
}
|
|
420
|
+
cb(authData);
|
|
421
|
+
_context2.next = 17;
|
|
422
|
+
break;
|
|
423
|
+
case 13:
|
|
424
|
+
_context2.prev = 13;
|
|
425
|
+
_context2.t0 = _context2["catch"](5);
|
|
426
|
+
// Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
|
|
427
|
+
authenticationError = {
|
|
428
|
+
message: 'Insufficient editing permissions',
|
|
429
|
+
data: {
|
|
430
|
+
status: 403,
|
|
431
|
+
code: INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
|
|
432
|
+
meta: {
|
|
433
|
+
originalError: _context2.t0,
|
|
434
|
+
// @ts-expect-error we know the error structure passed in this hack
|
|
435
|
+
reason: (_err = err) === null || _err === void 0 ? void 0 : (_err$data = _err.data) === null || _err$data === void 0 ? void 0 : (_err$data$meta = _err$data.meta) === null || _err$data$meta === void 0 ? void 0 : _err$data$meta.reason // Should always be 'RESOURCE_DELETED' Temporary, until Confluence Cloud removes their hack
|
|
436
|
+
// https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
|
|
434
437
|
}
|
|
435
|
-
}
|
|
438
|
+
}
|
|
439
|
+
};
|
|
436
440
|
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
}
|
|
441
|
+
_this2.emit('error', authenticationError);
|
|
442
|
+
case 17:
|
|
443
|
+
case "end":
|
|
444
|
+
return _context2.stop();
|
|
442
445
|
}
|
|
443
446
|
}, _callee2, null, [[5, 13]]);
|
|
444
447
|
}));
|
|
@@ -459,8 +462,13 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
459
462
|
this.socket.on('steps:added', function (data) {
|
|
460
463
|
_this2.emit('steps:added', data);
|
|
461
464
|
});
|
|
462
|
-
this.socket.on('participant:telepointer', function (
|
|
463
|
-
|
|
465
|
+
this.socket.on('participant:telepointer', function (_ref4) {
|
|
466
|
+
var timestamp = _ref4.timestamp,
|
|
467
|
+
data = _ref4.data;
|
|
468
|
+
// data is TelepointerPayload without timestamp
|
|
469
|
+
_this2.emit('participant:telepointer', _objectSpread({
|
|
470
|
+
timestamp: timestamp
|
|
471
|
+
}, data));
|
|
464
472
|
});
|
|
465
473
|
this.socket.on('presence:joined', function (data) {
|
|
466
474
|
_this2.emit('presence:joined', data);
|
|
@@ -471,11 +479,11 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
471
479
|
this.socket.on('participant:left', function (data) {
|
|
472
480
|
_this2.emit('participant:left', data);
|
|
473
481
|
});
|
|
474
|
-
this.socket.on('participant:updated', function (
|
|
475
|
-
var sessionId =
|
|
476
|
-
timestamp =
|
|
477
|
-
data =
|
|
478
|
-
clientId =
|
|
482
|
+
this.socket.on('participant:updated', function (_ref5) {
|
|
483
|
+
var sessionId = _ref5.sessionId,
|
|
484
|
+
timestamp = _ref5.timestamp,
|
|
485
|
+
data = _ref5.data,
|
|
486
|
+
clientId = _ref5.clientId;
|
|
479
487
|
_this2.emit('participant:updated', _objectSpread({
|
|
480
488
|
sessionId: sessionId,
|
|
481
489
|
timestamp: timestamp,
|
|
@@ -491,42 +499,40 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
491
499
|
_this2.emit('status', data);
|
|
492
500
|
});
|
|
493
501
|
this.socket.on('disconnect', /*#__PURE__*/function () {
|
|
494
|
-
var
|
|
502
|
+
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(reason) {
|
|
495
503
|
var _this2$analyticsHelpe, reconnectionError;
|
|
496
|
-
return _regeneratorRuntime
|
|
497
|
-
while (1) {
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
_this2.emit('error', reconnectionError);
|
|
519
|
-
}
|
|
504
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
505
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
506
|
+
case 0:
|
|
507
|
+
_this2.connected = false;
|
|
508
|
+
logger("disconnect reason: ".concat(reason));
|
|
509
|
+
_this2.emit('disconnect', {
|
|
510
|
+
reason: reason
|
|
511
|
+
});
|
|
512
|
+
if (reason === socketIOReasons.IO_SERVER_DISCONNECT && _this2.socket) {
|
|
513
|
+
// The disconnection was initiated by the server, we need to reconnect manually.
|
|
514
|
+
try {
|
|
515
|
+
_this2.socket.connect();
|
|
516
|
+
} catch (error) {
|
|
517
|
+
(_this2$analyticsHelpe = _this2.analyticsHelper) === null || _this2$analyticsHelpe === void 0 ? void 0 : _this2$analyticsHelpe.sendErrorEvent(error, 'Error while reconnecting the channel');
|
|
518
|
+
reconnectionError = {
|
|
519
|
+
message: 'Caught error during reconnection',
|
|
520
|
+
data: {
|
|
521
|
+
status: 500,
|
|
522
|
+
code: INTERNAL_ERROR_CODE.RECONNECTION_ERROR
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
_this2.emit('error', reconnectionError);
|
|
520
526
|
}
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
527
|
+
}
|
|
528
|
+
case 4:
|
|
529
|
+
case "end":
|
|
530
|
+
return _context3.stop();
|
|
525
531
|
}
|
|
526
532
|
}, _callee3);
|
|
527
533
|
}));
|
|
528
534
|
return function (_x3) {
|
|
529
|
-
return
|
|
535
|
+
return _ref6.apply(this, arguments);
|
|
530
536
|
};
|
|
531
537
|
}());
|
|
532
538
|
|
|
@@ -552,18 +558,6 @@ export var Channel = /*#__PURE__*/function (_Emitter) {
|
|
|
552
558
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
553
559
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
554
560
|
}
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* Send message to the back-end service over the channel. Timestamp will be added server side.
|
|
558
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
559
|
-
* @throws {NotConnectedError} Channel not connected
|
|
560
|
-
*/
|
|
561
|
-
|
|
562
|
-
/**
|
|
563
|
-
* Send metadata to to the back-end service over the channel
|
|
564
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
565
|
-
* @throws {NotConnectedError} Channel not connected
|
|
566
|
-
*/
|
|
567
561
|
}, {
|
|
568
562
|
key: "sendPresenceJoined",
|
|
569
563
|
value: function sendPresenceJoined() {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
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
|
-
export var NetworkStatus
|
|
5
|
-
(function (NetworkStatus) {
|
|
4
|
+
export var NetworkStatus = /*#__PURE__*/function (NetworkStatus) {
|
|
6
5
|
NetworkStatus["ONLINE"] = "ONLINE";
|
|
7
6
|
NetworkStatus["OFFLINE"] = "OFFLINE";
|
|
8
|
-
|
|
7
|
+
return NetworkStatus;
|
|
8
|
+
}({});
|
|
9
9
|
var Network = /*#__PURE__*/function () {
|
|
10
10
|
function Network(props) {
|
|
11
11
|
var _this = this;
|
|
@@ -11,15 +11,15 @@ export var socketIOReasons = {
|
|
|
11
11
|
PING_TIMEOUT: 'ping timeout' // The connection has encountered an error (example: the server was killed during a HTTP long-polling cycle)
|
|
12
12
|
};
|
|
13
13
|
|
|
14
|
-
export var DisconnectReason
|
|
15
|
-
(function (DisconnectReason) {
|
|
14
|
+
export var DisconnectReason = /*#__PURE__*/function (DisconnectReason) {
|
|
16
15
|
DisconnectReason["CLIENT_DISCONNECT"] = "CLIENT_DISCONNECT";
|
|
17
16
|
DisconnectReason["SERVER_DISCONNECT"] = "SERVER_DISCONNECT";
|
|
18
17
|
DisconnectReason["SOCKET_CLOSED"] = "SOCKET_CLOSED";
|
|
19
18
|
DisconnectReason["SOCKET_ERROR"] = "SOCKET_ERROR";
|
|
20
19
|
DisconnectReason["SOCKET_TIMEOUT"] = "SOCKET_TIMEOUT";
|
|
21
20
|
DisconnectReason["UNKNOWN_DISCONNECT"] = "UNKNOWN_DISCONNECT";
|
|
22
|
-
|
|
21
|
+
return DisconnectReason;
|
|
22
|
+
}({});
|
|
23
23
|
export var disconnectedReasonMapper = function disconnectedReasonMapper(reason) {
|
|
24
24
|
switch (reason) {
|
|
25
25
|
case socketIOReasons.IO_CLIENT_DISCONNECT:
|