@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.
Files changed (67) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/analytics/analytics-helper.js +25 -28
  3. package/dist/cjs/analytics/performance.js +4 -4
  4. package/dist/cjs/channel.js +218 -224
  5. package/dist/cjs/connectivity/network.js +4 -4
  6. package/dist/cjs/disconnected-reason-mapper.js +4 -4
  7. package/dist/cjs/document/catchup.js +84 -87
  8. package/dist/cjs/document/document-service.js +205 -234
  9. package/dist/cjs/document/step-queue-state.js +4 -5
  10. package/dist/cjs/errors/error-types.js +25 -24
  11. package/dist/cjs/helpers/const.js +12 -12
  12. package/dist/cjs/metadata/metadata-service.js +15 -20
  13. package/dist/cjs/participants/participants-helper.js +22 -32
  14. package/dist/cjs/participants/participants-service.js +89 -101
  15. package/dist/cjs/participants/participants-state.js +2 -4
  16. package/dist/cjs/provider/index.js +130 -136
  17. package/dist/cjs/types.js +11 -5
  18. package/dist/cjs/version-wrapper.js +1 -1
  19. package/dist/cjs/version.json +1 -1
  20. package/dist/es2019/analytics/analytics-helper.js +3 -3
  21. package/dist/es2019/analytics/performance.js +3 -3
  22. package/dist/es2019/channel.js +21 -20
  23. package/dist/es2019/connectivity/network.js +3 -3
  24. package/dist/es2019/disconnected-reason-mapper.js +3 -3
  25. package/dist/es2019/document/document-service.js +17 -25
  26. package/dist/es2019/document/step-queue-state.js +4 -5
  27. package/dist/es2019/errors/error-types.js +26 -25
  28. package/dist/es2019/helpers/const.js +9 -9
  29. package/dist/es2019/metadata/metadata-service.js +15 -19
  30. package/dist/es2019/participants/participants-helper.js +3 -8
  31. package/dist/es2019/participants/participants-service.js +42 -52
  32. package/dist/es2019/participants/participants-state.js +1 -2
  33. package/dist/es2019/provider/index.js +68 -71
  34. package/dist/es2019/types.js +13 -3
  35. package/dist/es2019/version-wrapper.js +1 -1
  36. package/dist/es2019/version.json +1 -1
  37. package/dist/esm/analytics/analytics-helper.js +25 -28
  38. package/dist/esm/analytics/performance.js +3 -3
  39. package/dist/esm/channel.js +218 -224
  40. package/dist/esm/connectivity/network.js +3 -3
  41. package/dist/esm/disconnected-reason-mapper.js +3 -3
  42. package/dist/esm/document/catchup.js +84 -87
  43. package/dist/esm/document/document-service.js +205 -234
  44. package/dist/esm/document/step-queue-state.js +4 -5
  45. package/dist/esm/errors/error-types.js +26 -25
  46. package/dist/esm/helpers/const.js +9 -9
  47. package/dist/esm/metadata/metadata-service.js +15 -20
  48. package/dist/esm/participants/participants-helper.js +22 -32
  49. package/dist/esm/participants/participants-service.js +89 -101
  50. package/dist/esm/participants/participants-state.js +2 -4
  51. package/dist/esm/provider/index.js +130 -136
  52. package/dist/esm/types.js +13 -3
  53. package/dist/esm/version-wrapper.js +1 -1
  54. package/dist/esm/version.json +1 -1
  55. package/dist/types/channel.d.ts +1 -1
  56. package/dist/types/feature-flags/types.d.ts +1 -1
  57. package/dist/types/metadata/metadata-service.d.ts +1 -1
  58. package/dist/types/participants/participants-helper.d.ts +2 -3
  59. package/dist/types/participants/participants-service.d.ts +4 -8
  60. package/dist/types/provider/index.d.ts +6 -0
  61. package/dist/types/types.d.ts +15 -9
  62. package/package.json +16 -11
  63. package/report.api.md +11 -5
  64. package/channel/package.json +0 -15
  65. package/config/package.json +0 -15
  66. package/disconnected-reason-mapper/package.json +0 -15
  67. package/emitter/package.json +0 -15
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- var _typeof = require("@babel/runtime/helpers/typeof");
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.Channel = void 0;
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
10
10
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
11
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
@@ -24,7 +24,6 @@ var _ufo = require("./analytics/ufo");
24
24
  var _disconnectedReasonMapper = require("./disconnected-reason-mapper");
25
25
  var _network = _interopRequireDefault(require("./connectivity/network"));
26
26
  var _errorTypes = require("./errors/error-types");
27
- 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; }
28
27
  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; }
29
28
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
30
29
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
@@ -42,6 +41,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
42
41
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "reconnectHelper", null);
43
42
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initialized", false);
44
43
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "network", null);
44
+ // read-only getters used for tests
45
45
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getInitialized", function () {
46
46
  return _this.initialized;
47
47
  });
@@ -59,6 +59,7 @@ var Channel = /*#__PURE__*/function (_Emitter) {
59
59
  _this.token = value;
60
60
  }
61
61
  });
62
+ // sets the token as undefined
62
63
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "unsetToken", function () {
63
64
  return _this.setToken();
64
65
  });
@@ -182,134 +183,132 @@ var Channel = /*#__PURE__*/function (_Emitter) {
182
183
  }
183
184
  });
184
185
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fetchCatchup", /*#__PURE__*/function () {
185
- var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(fromVersion) {
186
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(fromVersion) {
186
187
  var _ref2, _this$token, _yield$utils$requestS, doc, version, stepMaps, metadata, errorNotFound, errorCatchup;
187
- return _regeneratorRuntime().wrap(function _callee$(_context) {
188
- while (1) {
189
- switch (_context.prev = _context.next) {
190
- case 0:
191
- _context.prev = 0;
192
- _context.t0 = _utilServiceSupport.utils;
193
- _context.t1 = _this.config;
194
- _context.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchup");
195
- _context.t3 = {
196
- version: fromVersion
197
- };
198
- _context.t4 = _objectSpread;
199
- _context.t5 = _objectSpread;
200
- _context.t6 = {};
201
- if (!_this.config.permissionTokenRefresh) {
202
- _context.next = 29;
203
- break;
204
- }
205
- if (!((_this$token = _this.token) !== null && _this$token !== void 0)) {
206
- _context.next = 13;
207
- break;
208
- }
209
- _context.t9 = _this$token;
210
- _context.next = 16;
188
+ return _regenerator.default.wrap(function _callee$(_context) {
189
+ while (1) switch (_context.prev = _context.next) {
190
+ case 0:
191
+ _context.prev = 0;
192
+ _context.t0 = _utilServiceSupport.utils;
193
+ _context.t1 = _this.config;
194
+ _context.t2 = "document/".concat(encodeURIComponent(_this.config.documentAri), "/catchup");
195
+ _context.t3 = {
196
+ version: fromVersion
197
+ };
198
+ _context.t4 = _objectSpread;
199
+ _context.t5 = _objectSpread;
200
+ _context.t6 = {};
201
+ if (!_this.config.permissionTokenRefresh) {
202
+ _context.next = 29;
211
203
  break;
212
- case 13:
213
- _context.next = 15;
214
- return _this.config.permissionTokenRefresh().then(function (token) {
215
- if (token) {
216
- _this.setToken(token);
217
- }
218
- return token;
219
- });
220
- case 15:
221
- _context.t9 = _context.sent;
222
- case 16:
223
- _context.t10 = _ref2 = _context.t9;
224
- _context.t8 = _context.t10 !== null;
225
- if (!_context.t8) {
226
- _context.next = 20;
227
- break;
228
- }
229
- _context.t8 = _ref2 !== void 0;
230
- case 20:
231
- if (!_context.t8) {
232
- _context.next = 24;
233
- break;
204
+ }
205
+ if (!((_this$token = _this.token) !== null && _this$token !== void 0)) {
206
+ _context.next = 13;
207
+ break;
208
+ }
209
+ _context.t9 = _this$token;
210
+ _context.next = 16;
211
+ break;
212
+ case 13:
213
+ _context.next = 15;
214
+ return _this.config.permissionTokenRefresh().then(function (token) {
215
+ if (token) {
216
+ _this.setToken(token);
234
217
  }
235
- _context.t11 = _ref2;
236
- _context.next = 25;
218
+ return token;
219
+ });
220
+ case 15:
221
+ _context.t9 = _context.sent;
222
+ case 16:
223
+ _context.t10 = _ref2 = _context.t9;
224
+ _context.t8 = _context.t10 !== null;
225
+ if (!_context.t8) {
226
+ _context.next = 20;
237
227
  break;
238
- case 24:
239
- _context.t11 = undefined;
240
- case 25:
241
- _context.t12 = _context.t11;
242
- _context.t7 = {
243
- 'x-token': _context.t12
244
- };
245
- _context.next = 30;
228
+ }
229
+ _context.t8 = _ref2 !== void 0;
230
+ case 20:
231
+ if (!_context.t8) {
232
+ _context.next = 24;
246
233
  break;
247
- case 29:
248
- _context.t7 = {};
249
- case 30:
250
- _context.t13 = _context.t7;
251
- _context.t14 = (0, _context.t5)(_context.t6, _context.t13);
252
- _context.t15 = {};
253
- _context.t16 = {
254
- 'x-product': (0, _utils.getProduct)(_this.config.productInfo),
255
- 'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo)
256
- };
257
- _context.t17 = (0, _context.t4)(_context.t14, _context.t15, _context.t16);
258
- _context.t18 = {
259
- headers: _context.t17
260
- };
261
- _context.t19 = {
262
- path: _context.t2,
263
- queryParams: _context.t3,
264
- requestInit: _context.t18
265
- };
266
- _context.next = 39;
267
- return _context.t0.requestService.call(_context.t0, _context.t1, _context.t19);
268
- case 39:
269
- _yield$utils$requestS = _context.sent;
270
- doc = _yield$utils$requestS.doc;
271
- version = _yield$utils$requestS.version;
272
- stepMaps = _yield$utils$requestS.stepMaps;
273
- metadata = _yield$utils$requestS.metadata;
274
- return _context.abrupt("return", {
275
- doc: doc,
276
- version: version,
277
- stepMaps: stepMaps,
278
- metadata: metadata
279
- });
280
- case 47:
281
- _context.prev = 47;
282
- _context.t20 = _context["catch"](0);
283
- if (!(_context.t20.code === 404)) {
284
- _context.next = 53;
285
- break;
234
+ }
235
+ _context.t11 = _ref2;
236
+ _context.next = 25;
237
+ break;
238
+ case 24:
239
+ _context.t11 = undefined;
240
+ case 25:
241
+ _context.t12 = _context.t11;
242
+ _context.t7 = {
243
+ 'x-token': _context.t12
244
+ };
245
+ _context.next = 30;
246
+ break;
247
+ case 29:
248
+ _context.t7 = {};
249
+ case 30:
250
+ _context.t13 = _context.t7;
251
+ _context.t14 = (0, _context.t5)(_context.t6, _context.t13);
252
+ _context.t15 = {};
253
+ _context.t16 = {
254
+ 'x-product': (0, _utils.getProduct)(_this.config.productInfo),
255
+ 'x-subproduct': (0, _utils.getSubProduct)(_this.config.productInfo)
256
+ };
257
+ _context.t17 = (0, _context.t4)(_context.t14, _context.t15, _context.t16);
258
+ _context.t18 = {
259
+ headers: _context.t17
260
+ };
261
+ _context.t19 = {
262
+ path: _context.t2,
263
+ queryParams: _context.t3,
264
+ requestInit: _context.t18
265
+ };
266
+ _context.next = 39;
267
+ return _context.t0.requestService.call(_context.t0, _context.t1, _context.t19);
268
+ case 39:
269
+ _yield$utils$requestS = _context.sent;
270
+ doc = _yield$utils$requestS.doc;
271
+ version = _yield$utils$requestS.version;
272
+ stepMaps = _yield$utils$requestS.stepMaps;
273
+ metadata = _yield$utils$requestS.metadata;
274
+ return _context.abrupt("return", {
275
+ doc: doc,
276
+ version: version,
277
+ stepMaps: stepMaps,
278
+ metadata: metadata
279
+ });
280
+ case 47:
281
+ _context.prev = 47;
282
+ _context.t20 = _context["catch"](0);
283
+ if (!(_context.t20.code === 404)) {
284
+ _context.next = 53;
285
+ break;
286
+ }
287
+ errorNotFound = {
288
+ message: 'The requested document is not found',
289
+ data: {
290
+ status: _context.t20.code,
291
+ code: _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
286
292
  }
287
- errorNotFound = {
288
- message: 'The requested document is not found',
289
- data: {
290
- status: _context.t20.code,
291
- code: _errorTypes.INTERNAL_ERROR_CODE.DOCUMENT_NOT_FOUND
292
- }
293
- };
294
- _this.emit('error', errorNotFound);
295
- return _context.abrupt("return", {});
296
- case 53:
297
- //nullify token so it is forced to generate new token on reconnect
298
- _this.unsetToken();
299
- logger("Can't fetch the catchup", _context.t20.message);
300
- errorCatchup = {
301
- message: 'Cannot fetch catchup from collab service',
302
- data: {
303
- status: _context.t20.status,
304
- code: _errorTypes.INTERNAL_ERROR_CODE.CATCHUP_FAILED
305
- }
306
- };
307
- _this.emit('error', errorCatchup);
308
- throw _context.t20;
309
- case 58:
310
- case "end":
311
- return _context.stop();
312
- }
293
+ };
294
+ _this.emit('error', errorNotFound);
295
+ return _context.abrupt("return", {});
296
+ case 53:
297
+ //nullify token so it is forced to generate new token on reconnect
298
+ _this.unsetToken();
299
+ logger("Can't fetch the catchup", _context.t20.message);
300
+ errorCatchup = {
301
+ message: 'Cannot fetch catchup from collab service',
302
+ data: {
303
+ status: _context.t20.status,
304
+ code: _errorTypes.INTERNAL_ERROR_CODE.CATCHUP_FAILED
305
+ }
306
+ };
307
+ _this.emit('error', errorCatchup);
308
+ throw _context.t20;
309
+ case 58:
310
+ case "end":
311
+ return _context.stop();
313
312
  }
314
313
  }, _callee, null, [[0, 47]]);
315
314
  }));
@@ -317,6 +316,11 @@ var Channel = /*#__PURE__*/function (_Emitter) {
317
316
  return _ref.apply(this, arguments);
318
317
  };
319
318
  }());
319
+ /**
320
+ * Send message to the back-end service over the channel. Timestamp will be added server side.
321
+ * @throws {NotInitializedError} Channel not initialized
322
+ * @throws {NotConnectedError} Channel not connected
323
+ */
320
324
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "broadcast", function (type, data, callback) {
321
325
  if (!_this.socket) {
322
326
  throw new _errorTypes.NotInitializedError('Cannot broadcast, not initialized yet');
@@ -331,6 +335,11 @@ var Channel = /*#__PURE__*/function (_Emitter) {
331
335
  type: type
332
336
  }, data), callback);
333
337
  });
338
+ /**
339
+ * Send metadata to the back-end service over the channel
340
+ * @throws {NotInitializedError} Channel not initialized
341
+ * @throws {NotConnectedError} Channel not connected
342
+ */
334
343
  (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sendMetadata", function (metadata) {
335
344
  if (!_this.socket) {
336
345
  throw new _errorTypes.NotInitializedError('Cannot send metadata, not initialized yet');
@@ -355,10 +364,6 @@ var Channel = /*#__PURE__*/function (_Emitter) {
355
364
  _this.initExperience = (0, _ufo.createDocInitExp)(_this.analyticsHelper);
356
365
  return _this;
357
366
  }
358
-
359
- // read-only getters used for tests
360
-
361
- // sets the token as undefined
362
367
  (0, _createClass2.default)(Channel, [{
363
368
  key: "connect",
364
369
  value:
@@ -395,57 +400,55 @@ var Channel = /*#__PURE__*/function (_Emitter) {
395
400
  };
396
401
  if (permissionTokenRefresh) {
397
402
  auth = /*#__PURE__*/function () {
398
- var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(cb) {
403
+ var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(cb) {
399
404
  var token, _err, _err$data, _err$data$meta, authenticationError;
400
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
401
- while (1) {
402
- switch (_context2.prev = _context2.next) {
403
- case 0:
404
- if (!(cacheToken && _this2.token)) {
405
- _context2.next = 5;
406
- break;
407
- }
408
- authData.token = _this2.token;
409
- cb(authData);
410
- _context2.next = 17;
411
- break;
412
- case 5:
413
- _context2.prev = 5;
414
- _context2.next = 8;
415
- return permissionTokenRefresh();
416
- case 8:
417
- token = _context2.sent;
418
- if (token) {
419
- // save token locally
420
- _this2.setToken(token);
421
- authData.token = token;
422
- }
423
- cb(authData);
424
- _context2.next = 17;
405
+ return _regenerator.default.wrap(function _callee2$(_context2) {
406
+ while (1) switch (_context2.prev = _context2.next) {
407
+ case 0:
408
+ if (!(cacheToken && _this2.token)) {
409
+ _context2.next = 5;
425
410
  break;
426
- case 13:
427
- _context2.prev = 13;
428
- _context2.t0 = _context2["catch"](5);
429
- // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
430
- authenticationError = {
431
- message: 'Insufficient editing permissions',
432
- data: {
433
- status: 403,
434
- code: _errorTypes.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
435
- meta: {
436
- originalError: _context2.t0,
437
- // @ts-expect-error we know the error structure passed in this hack
438
- 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
439
- // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
440
- }
411
+ }
412
+ authData.token = _this2.token;
413
+ cb(authData);
414
+ _context2.next = 17;
415
+ break;
416
+ case 5:
417
+ _context2.prev = 5;
418
+ _context2.next = 8;
419
+ return permissionTokenRefresh();
420
+ case 8:
421
+ token = _context2.sent;
422
+ if (token) {
423
+ // save token locally
424
+ _this2.setToken(token);
425
+ authData.token = token;
426
+ }
427
+ cb(authData);
428
+ _context2.next = 17;
429
+ break;
430
+ case 13:
431
+ _context2.prev = 13;
432
+ _context2.t0 = _context2["catch"](5);
433
+ // Pass the error back to the consumers so they can deal with exceptional cases themselves (eg. no permissions because the page was deleted)
434
+ authenticationError = {
435
+ message: 'Insufficient editing permissions',
436
+ data: {
437
+ status: 403,
438
+ code: _errorTypes.INTERNAL_ERROR_CODE.TOKEN_PERMISSION_ERROR,
439
+ meta: {
440
+ originalError: _context2.t0,
441
+ // @ts-expect-error we know the error structure passed in this hack
442
+ 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
443
+ // https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/browse/next/packages/native-collab/src/fetchCollabPermissionToken.ts#37
441
444
  }
442
- };
445
+ }
446
+ };
443
447
 
444
- _this2.emit('error', authenticationError);
445
- case 17:
446
- case "end":
447
- return _context2.stop();
448
- }
448
+ _this2.emit('error', authenticationError);
449
+ case 17:
450
+ case "end":
451
+ return _context2.stop();
449
452
  }
450
453
  }, _callee2, null, [[5, 13]]);
451
454
  }));
@@ -466,8 +469,13 @@ var Channel = /*#__PURE__*/function (_Emitter) {
466
469
  this.socket.on('steps:added', function (data) {
467
470
  _this2.emit('steps:added', data);
468
471
  });
469
- this.socket.on('participant:telepointer', function (payload) {
470
- _this2.emit('participant:telepointer', payload.data);
472
+ this.socket.on('participant:telepointer', function (_ref4) {
473
+ var timestamp = _ref4.timestamp,
474
+ data = _ref4.data;
475
+ // data is TelepointerPayload without timestamp
476
+ _this2.emit('participant:telepointer', _objectSpread({
477
+ timestamp: timestamp
478
+ }, data));
471
479
  });
472
480
  this.socket.on('presence:joined', function (data) {
473
481
  _this2.emit('presence:joined', data);
@@ -478,11 +486,11 @@ var Channel = /*#__PURE__*/function (_Emitter) {
478
486
  this.socket.on('participant:left', function (data) {
479
487
  _this2.emit('participant:left', data);
480
488
  });
481
- this.socket.on('participant:updated', function (_ref4) {
482
- var sessionId = _ref4.sessionId,
483
- timestamp = _ref4.timestamp,
484
- data = _ref4.data,
485
- clientId = _ref4.clientId;
489
+ this.socket.on('participant:updated', function (_ref5) {
490
+ var sessionId = _ref5.sessionId,
491
+ timestamp = _ref5.timestamp,
492
+ data = _ref5.data,
493
+ clientId = _ref5.clientId;
486
494
  _this2.emit('participant:updated', _objectSpread({
487
495
  sessionId: sessionId,
488
496
  timestamp: timestamp,
@@ -498,42 +506,40 @@ var Channel = /*#__PURE__*/function (_Emitter) {
498
506
  _this2.emit('status', data);
499
507
  });
500
508
  this.socket.on('disconnect', /*#__PURE__*/function () {
501
- var _ref5 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(reason) {
509
+ var _ref6 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(reason) {
502
510
  var _this2$analyticsHelpe, reconnectionError;
503
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
504
- while (1) {
505
- 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 === _disconnectedReasonMapper.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: _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_ERROR
523
- }
524
- };
525
- _this2.emit('error', reconnectionError);
526
- }
511
+ return _regenerator.default.wrap(function _callee3$(_context3) {
512
+ while (1) switch (_context3.prev = _context3.next) {
513
+ case 0:
514
+ _this2.connected = false;
515
+ logger("disconnect reason: ".concat(reason));
516
+ _this2.emit('disconnect', {
517
+ reason: reason
518
+ });
519
+ if (reason === _disconnectedReasonMapper.socketIOReasons.IO_SERVER_DISCONNECT && _this2.socket) {
520
+ // The disconnection was initiated by the server, we need to reconnect manually.
521
+ try {
522
+ _this2.socket.connect();
523
+ } catch (error) {
524
+ (_this2$analyticsHelpe = _this2.analyticsHelper) === null || _this2$analyticsHelpe === void 0 ? void 0 : _this2$analyticsHelpe.sendErrorEvent(error, 'Error while reconnecting the channel');
525
+ reconnectionError = {
526
+ message: 'Caught error during reconnection',
527
+ data: {
528
+ status: 500,
529
+ code: _errorTypes.INTERNAL_ERROR_CODE.RECONNECTION_ERROR
530
+ }
531
+ };
532
+ _this2.emit('error', reconnectionError);
527
533
  }
528
- case 4:
529
- case "end":
530
- return _context3.stop();
531
- }
534
+ }
535
+ case 4:
536
+ case "end":
537
+ return _context3.stop();
532
538
  }
533
539
  }, _callee3);
534
540
  }));
535
541
  return function (_x3) {
536
- return _ref5.apply(this, arguments);
542
+ return _ref6.apply(this, arguments);
537
543
  };
538
544
  }());
539
545
 
@@ -559,18 +565,6 @@ var Channel = /*#__PURE__*/function (_Emitter) {
559
565
  // Fired upon a reconnection attempt error (from Socket.IO Manager)
560
566
  this.socket.io.on('reconnect_error', this.onReconnectError);
561
567
  }
562
-
563
- /**
564
- * Send message to the back-end service over the channel. Timestamp will be added server side.
565
- * @throws {NotInitializedError} Channel not initialized
566
- * @throws {NotConnectedError} Channel not connected
567
- */
568
-
569
- /**
570
- * Send metadata to to the back-end service over the channel
571
- * @throws {NotInitializedError} Channel not initialized
572
- * @throws {NotConnectedError} Channel not connected
573
- */
574
568
  }, {
575
569
  key: "sendPresenceJoined",
576
570
  value: function sendPresenceJoined() {
@@ -8,12 +8,12 @@ exports.default = exports.NetworkStatus = void 0;
8
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
- var NetworkStatus;
12
- exports.NetworkStatus = NetworkStatus;
13
- (function (NetworkStatus) {
11
+ var NetworkStatus = /*#__PURE__*/function (NetworkStatus) {
14
12
  NetworkStatus["ONLINE"] = "ONLINE";
15
13
  NetworkStatus["OFFLINE"] = "OFFLINE";
16
- })(NetworkStatus || (exports.NetworkStatus = NetworkStatus = {}));
14
+ return NetworkStatus;
15
+ }({});
16
+ exports.NetworkStatus = NetworkStatus;
17
17
  var Network = /*#__PURE__*/function () {
18
18
  function Network(props) {
19
19
  var _this = this;
@@ -17,16 +17,16 @@ var socketIOReasons = {
17
17
  PING_TIMEOUT: 'ping timeout' // The connection has encountered an error (example: the server was killed during a HTTP long-polling cycle)
18
18
  };
19
19
  exports.socketIOReasons = socketIOReasons;
20
- var DisconnectReason;
21
- exports.DisconnectReason = DisconnectReason;
22
- (function (DisconnectReason) {
20
+ var DisconnectReason = /*#__PURE__*/function (DisconnectReason) {
23
21
  DisconnectReason["CLIENT_DISCONNECT"] = "CLIENT_DISCONNECT";
24
22
  DisconnectReason["SERVER_DISCONNECT"] = "SERVER_DISCONNECT";
25
23
  DisconnectReason["SOCKET_CLOSED"] = "SOCKET_CLOSED";
26
24
  DisconnectReason["SOCKET_ERROR"] = "SOCKET_ERROR";
27
25
  DisconnectReason["SOCKET_TIMEOUT"] = "SOCKET_TIMEOUT";
28
26
  DisconnectReason["UNKNOWN_DISCONNECT"] = "UNKNOWN_DISCONNECT";
29
- })(DisconnectReason || (exports.DisconnectReason = DisconnectReason = {}));
27
+ return DisconnectReason;
28
+ }({});
29
+ exports.DisconnectReason = DisconnectReason;
30
30
  var disconnectedReasonMapper = function disconnectedReasonMapper(reason) {
31
31
  switch (reason) {
32
32
  case socketIOReasons.IO_CLIENT_DISCONNECT: