@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,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.Provider = exports.MAX_STEP_REJECTED_ERROR = 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"));
|
|
@@ -25,7 +25,6 @@ var _errorTypes = require("../errors/error-types");
|
|
|
25
25
|
var _metadataService = require("../metadata/metadata-service");
|
|
26
26
|
var _documentService = require("../document/document-service");
|
|
27
27
|
var _errorCodeMapper = require("../errors/error-code-mapper");
|
|
28
|
-
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; }
|
|
29
28
|
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); }; }
|
|
30
29
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
30
|
var logger = (0, _utils.createLogger)('Provider', 'black');
|
|
@@ -38,20 +37,13 @@ exports.MAX_STEP_REJECTED_ERROR = MAX_STEP_REJECTED_ERROR;
|
|
|
38
37
|
var Provider = /*#__PURE__*/function (_Emitter) {
|
|
39
38
|
(0, _inherits2.default)(Provider, _Emitter);
|
|
40
39
|
var _super = _createSuper(Provider);
|
|
41
|
-
// To keep track of the namespace event changes from the server.
|
|
42
|
-
|
|
43
|
-
// SessionID is the unique socket-session.
|
|
44
|
-
|
|
45
|
-
// ClientID is the unique ID for a prosemirror client. Used for step-rebasing.
|
|
46
|
-
|
|
47
|
-
// UserID is the users actual account id.
|
|
48
|
-
|
|
49
40
|
function Provider(config) {
|
|
50
41
|
var _this;
|
|
51
42
|
(0, _classCallCheck2.default)(this, Provider);
|
|
52
43
|
_this = _super.call(this);
|
|
53
44
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isChannelInitialized", false);
|
|
54
45
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isProviderInitialized", false);
|
|
46
|
+
// To keep track of the namespace event changes from the server.
|
|
55
47
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isNamespaceLocked", false);
|
|
56
48
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "emitCallback", function (evt, data) {
|
|
57
49
|
return _this.emit(evt, data);
|
|
@@ -106,6 +98,9 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
106
98
|
_this.metadataService.updateMetadata(metadata);
|
|
107
99
|
}).on('restore', _this.documentService.onRestore).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', _this.onParticipantTelepointer.bind((0, _assertThisInitialized2.default)(_this))).on('presence:joined', _this.onPresenceJoined.bind((0, _assertThisInitialized2.default)(_this))).on('presence', _this.onPresence.bind((0, _assertThisInitialized2.default)(_this))).on('participant:left', _this.onParticipantLeft.bind((0, _assertThisInitialized2.default)(_this))).on('participant:updated', _this.onParticipantUpdated.bind((0, _assertThisInitialized2.default)(_this))).on('disconnect', _this.onDisconnected.bind((0, _assertThisInitialized2.default)(_this))).on('error', _this.onErrorHandled).on('status', _this.onNamespaceStatusChanged.bind((0, _assertThisInitialized2.default)(_this))).connect(shouldInitialize);
|
|
108
100
|
});
|
|
101
|
+
/**
|
|
102
|
+
* @param {InternalError} error The error to handle
|
|
103
|
+
*/
|
|
109
104
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onErrorHandled", function (error) {
|
|
110
105
|
var _error$data, _error$data2;
|
|
111
106
|
// User tried committing steps but they were rejected because:
|
|
@@ -144,6 +139,13 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
144
139
|
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(error, 'Error while sending presence');
|
|
145
140
|
}
|
|
146
141
|
});
|
|
142
|
+
/**
|
|
143
|
+
* Called when a participant joins the session.
|
|
144
|
+
*
|
|
145
|
+
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
146
|
+
* the active avatars in the editor.
|
|
147
|
+
* This method will be triggered from backend to notify all participants to exchange presence
|
|
148
|
+
*/
|
|
147
149
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresenceJoined", function (_ref3) {
|
|
148
150
|
var sessionId = _ref3.sessionId;
|
|
149
151
|
try {
|
|
@@ -169,103 +171,129 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
169
171
|
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(error, 'Error while receiving presence');
|
|
170
172
|
}
|
|
171
173
|
});
|
|
174
|
+
/**
|
|
175
|
+
* Called when a participant leaves the session.
|
|
176
|
+
*
|
|
177
|
+
* We emit the `presence` event to update the active avatars in the editor.
|
|
178
|
+
*/
|
|
172
179
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantLeft", function (data) {
|
|
173
180
|
return _this.participantsService.participantLeft(data, _this.emitCallback);
|
|
174
181
|
});
|
|
175
182
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "startInactiveRemover", function () {
|
|
176
183
|
return _this.participantsService.removeInactiveParticipants(_this.sessionId, _this.emitCallback);
|
|
177
184
|
});
|
|
185
|
+
/**
|
|
186
|
+
* Called when we receive an update event from another participant.
|
|
187
|
+
*/
|
|
178
188
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantUpdated", function (data) {
|
|
179
189
|
return _this.participantsService.updateParticipant(data, _this.config.getUser, _this.emitCallback);
|
|
180
190
|
});
|
|
191
|
+
/**
|
|
192
|
+
* Called when we receive a telepointer update from another
|
|
193
|
+
* participant.
|
|
194
|
+
*/
|
|
181
195
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantTelepointer", function (data) {
|
|
182
196
|
return _this.participantsService.participantTelepointer(data, _this.sessionId, _this.config.getUser, _this.emitCallback);
|
|
183
197
|
});
|
|
198
|
+
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
184
199
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (_ref5) {
|
|
185
200
|
var reason = _ref5.reason;
|
|
186
201
|
_this.disconnectedAt = Date.now();
|
|
187
202
|
_this.participantsService.disconnect(reason, _this.sessionId, _this.emitCallback);
|
|
188
203
|
});
|
|
189
|
-
|
|
204
|
+
/**
|
|
205
|
+
* Returns the documents metadata
|
|
206
|
+
*/
|
|
207
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getMetadata", function () {
|
|
208
|
+
return _this.metadataService.getMetaData();
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* Return the ADF version of the current draft document, together with it's title and the current step version.
|
|
212
|
+
* Used for draft sync, a process running every 5s for the first editor of a document to sync the document to the Confluence back-end.
|
|
213
|
+
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
214
|
+
*/
|
|
215
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getCurrentState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
|
|
190
216
|
var _this$analyticsHelper6;
|
|
191
|
-
return
|
|
192
|
-
while (1) {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
return _context.stop();
|
|
205
|
-
}
|
|
217
|
+
return _regenerator.default.wrap(function _callee$(_context) {
|
|
218
|
+
while (1) switch (_context.prev = _context.next) {
|
|
219
|
+
case 0:
|
|
220
|
+
_context.prev = 0;
|
|
221
|
+
return _context.abrupt("return", _this.documentService.getCurrentState());
|
|
222
|
+
case 4:
|
|
223
|
+
_context.prev = 4;
|
|
224
|
+
_context.t0 = _context["catch"](0);
|
|
225
|
+
(_this$analyticsHelper6 = _this.analyticsHelper) === null || _this$analyticsHelper6 === void 0 ? void 0 : _this$analyticsHelper6.sendErrorEvent(_context.t0, 'Error while returning ADF version of current draft document');
|
|
226
|
+
throw new _errorTypes.GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
|
|
227
|
+
case 8:
|
|
228
|
+
case "end":
|
|
229
|
+
return _context.stop();
|
|
206
230
|
}
|
|
207
231
|
}, _callee, null, [[0, 4]]);
|
|
208
232
|
})));
|
|
209
|
-
|
|
233
|
+
/**
|
|
234
|
+
* Return the final acknowledged (by NCS) ADF version of the current draft document, together with it's title and the current step version.
|
|
235
|
+
* Used when returning the document to Confluence on publish.
|
|
236
|
+
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
237
|
+
*/
|
|
238
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getFinalAcknowledgedState", /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
210
239
|
var _this$analyticsHelper7;
|
|
211
|
-
return
|
|
212
|
-
while (1) {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
return _context2.stop();
|
|
225
|
-
}
|
|
240
|
+
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
241
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
242
|
+
case 0:
|
|
243
|
+
_context2.prev = 0;
|
|
244
|
+
return _context2.abrupt("return", _this.documentService.getFinalAcknowledgedState());
|
|
245
|
+
case 4:
|
|
246
|
+
_context2.prev = 4;
|
|
247
|
+
_context2.t0 = _context2["catch"](0);
|
|
248
|
+
(_this$analyticsHelper7 = _this.analyticsHelper) === null || _this$analyticsHelper7 === void 0 ? void 0 : _this$analyticsHelper7.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
249
|
+
throw new _errorTypes.GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
250
|
+
case 8:
|
|
251
|
+
case "end":
|
|
252
|
+
return _context2.stop();
|
|
226
253
|
}
|
|
227
254
|
}, _callee2, null, [[0, 4]]);
|
|
228
255
|
})));
|
|
229
256
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "getUnconfirmedSteps", function () {
|
|
230
257
|
return _this.documentService.getUnconfirmedSteps();
|
|
231
258
|
});
|
|
259
|
+
/**
|
|
260
|
+
* ESS-2916 namespace status event- lock/unlock
|
|
261
|
+
*/
|
|
232
262
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
233
|
-
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/
|
|
263
|
+
var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(data) {
|
|
234
264
|
var isLocked, waitTimeInMs, timestamp, start;
|
|
235
|
-
return
|
|
236
|
-
while (1) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
});
|
|
265
|
+
return _regenerator.default.wrap(function _callee3$(_context3) {
|
|
266
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
267
|
+
case 0:
|
|
268
|
+
isLocked = data.isLocked, waitTimeInMs = data.waitTimeInMs, timestamp = data.timestamp;
|
|
269
|
+
start = Date.now();
|
|
270
|
+
logger("Received a namespace status changed event ", {
|
|
271
|
+
data: data
|
|
272
|
+
});
|
|
273
|
+
if (!(isLocked && waitTimeInMs)) {
|
|
274
|
+
_context3.next = 8;
|
|
275
|
+
break;
|
|
276
|
+
}
|
|
277
|
+
_this.isNamespaceLocked = true;
|
|
278
|
+
logger("Received a namespace status change event ", {
|
|
279
|
+
isLocked: isLocked
|
|
280
|
+
});
|
|
252
281
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
_this.isNamespaceLocked = false;
|
|
260
|
-
}, waitTimeInMs);
|
|
261
|
-
return _context3.abrupt("return");
|
|
262
|
-
case 8:
|
|
282
|
+
// To protect the collab editing process from locked out due to BE
|
|
283
|
+
setTimeout(function () {
|
|
284
|
+
logger("The namespace lock has expired", {
|
|
285
|
+
waitTime: Date.now() - start,
|
|
286
|
+
timestamp: timestamp
|
|
287
|
+
});
|
|
263
288
|
_this.isNamespaceLocked = false;
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
289
|
+
}, waitTimeInMs);
|
|
290
|
+
return _context3.abrupt("return");
|
|
291
|
+
case 8:
|
|
292
|
+
_this.isNamespaceLocked = false;
|
|
293
|
+
logger("The page lock has expired");
|
|
294
|
+
case 10:
|
|
295
|
+
case "end":
|
|
296
|
+
return _context3.stop();
|
|
269
297
|
}
|
|
270
298
|
}, _callee3);
|
|
271
299
|
}));
|
|
@@ -273,6 +301,9 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
273
301
|
return _ref8.apply(this, arguments);
|
|
274
302
|
};
|
|
275
303
|
}());
|
|
304
|
+
/**
|
|
305
|
+
* Used when the provider is disconnected or destroyed to prevent perpetual timers from continuously running
|
|
306
|
+
*/
|
|
276
307
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "clearTimers", function () {
|
|
277
308
|
clearTimeout(_this.presenceUpdateTimeout);
|
|
278
309
|
_this.participantsService.clearTimers();
|
|
@@ -317,6 +348,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
317
348
|
value: function setup(_ref9) {
|
|
318
349
|
var getState = _ref9.getState,
|
|
319
350
|
onSyncUpError = _ref9.onSyncUpError;
|
|
351
|
+
this.checkForCookies();
|
|
320
352
|
try {
|
|
321
353
|
var collabPlugin = getState().plugins.find(function (p) {
|
|
322
354
|
return p.key === 'collab$';
|
|
@@ -342,6 +374,16 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
342
374
|
}
|
|
343
375
|
return this;
|
|
344
376
|
}
|
|
377
|
+
}, {
|
|
378
|
+
key: "checkForCookies",
|
|
379
|
+
value: function checkForCookies() {
|
|
380
|
+
if (!global.navigator.cookieEnabled) {
|
|
381
|
+
var _this$analyticsHelper9;
|
|
382
|
+
var initError = new _errorTypes.ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
|
|
383
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
|
|
384
|
+
throw new _errorTypes.ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
345
387
|
|
|
346
388
|
/**
|
|
347
389
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
@@ -361,15 +403,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
361
403
|
}
|
|
362
404
|
this.documentService.send(_tr, _oldState, newState);
|
|
363
405
|
} catch (error) {
|
|
364
|
-
var _this$
|
|
365
|
-
(_this$
|
|
406
|
+
var _this$analyticsHelper10;
|
|
407
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while sending steps for a transaction');
|
|
366
408
|
throw new _errorTypes.SendTransactionError('Error while sending steps for a transaction', error);
|
|
367
409
|
}
|
|
368
410
|
}
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* @param {InternalError} error The error to handle
|
|
372
|
-
*/
|
|
373
411
|
}, {
|
|
374
412
|
key: "sendMessage",
|
|
375
413
|
value:
|
|
@@ -394,36 +432,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
394
432
|
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
395
433
|
}
|
|
396
434
|
} catch (error) {
|
|
397
|
-
var _this$
|
|
435
|
+
var _this$analyticsHelper11;
|
|
398
436
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
399
|
-
(_this$
|
|
437
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
400
438
|
}
|
|
401
439
|
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Called when a participant joins the session.
|
|
405
|
-
*
|
|
406
|
-
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
407
|
-
* the active avatars in the editor.
|
|
408
|
-
* This method will be triggered from backend to notify all participants to exchange presence
|
|
409
|
-
*/
|
|
410
|
-
|
|
411
|
-
/**
|
|
412
|
-
* Called when a participant leaves the session.
|
|
413
|
-
*
|
|
414
|
-
* We emit the `presence` event to update the active avatars in the editor.
|
|
415
|
-
*/
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* Called when we receive an update event from another participant.
|
|
419
|
-
*/
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* Called when we receive a telepointer update from another
|
|
423
|
-
* participant.
|
|
424
|
-
*/
|
|
425
|
-
|
|
426
|
-
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
427
440
|
}, {
|
|
428
441
|
key: "destroy",
|
|
429
442
|
value:
|
|
@@ -460,8 +473,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
460
473
|
(0, _get2.default)((0, _getPrototypeOf2.default)(Provider.prototype), "unsubscribeAll", this).call(this);
|
|
461
474
|
this.channel.disconnect();
|
|
462
475
|
} catch (error) {
|
|
463
|
-
var _this$
|
|
464
|
-
(_this$
|
|
476
|
+
var _this$analyticsHelper12;
|
|
477
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, 'Error while shutting down the collab provider');
|
|
465
478
|
throw new _errorTypes.DestroyError('Error while shutting down the collab provider', error);
|
|
466
479
|
}
|
|
467
480
|
this.clearTimers();
|
|
@@ -470,6 +483,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
470
483
|
|
|
471
484
|
/**
|
|
472
485
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
486
|
+
* @deprecated use setMetadata instead, it does the same thing
|
|
473
487
|
* @param {string} title Title you want to set on the document
|
|
474
488
|
* @param {boolean} broadcast (Optional) Flag indicating whether you want to broadcast the title change to the other participants, always true for now (otherwise we would lose title changes)
|
|
475
489
|
* @throws {SetTitleError} Something went wrong while setting the title
|
|
@@ -480,8 +494,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
480
494
|
try {
|
|
481
495
|
this.metadataService.setTitle(title, broadcast);
|
|
482
496
|
} catch (error) {
|
|
483
|
-
var _this$
|
|
484
|
-
(_this$
|
|
497
|
+
var _this$analyticsHelper13;
|
|
498
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting title');
|
|
485
499
|
throw new _errorTypes.SetTitleError('Error while setting title', error);
|
|
486
500
|
}
|
|
487
501
|
}
|
|
@@ -499,8 +513,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
499
513
|
try {
|
|
500
514
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
501
515
|
} catch (error) {
|
|
502
|
-
var _this$
|
|
503
|
-
(_this$
|
|
516
|
+
var _this$analyticsHelper14;
|
|
517
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting editor width');
|
|
504
518
|
throw new _errorTypes.SetEditorWidthError('Error while setting editor width', error);
|
|
505
519
|
}
|
|
506
520
|
}
|
|
@@ -516,31 +530,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
516
530
|
try {
|
|
517
531
|
this.metadataService.setMetadata(metadata);
|
|
518
532
|
} catch (error) {
|
|
519
|
-
var _this$
|
|
520
|
-
(_this$
|
|
533
|
+
var _this$analyticsHelper15;
|
|
534
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting metadata');
|
|
521
535
|
throw new _errorTypes.SetMetadataError('Error while setting metadata', error);
|
|
522
536
|
}
|
|
523
537
|
}
|
|
524
|
-
|
|
525
|
-
/**
|
|
526
|
-
* Return the ADF version of the current draft document, together with it's title and the current step version.
|
|
527
|
-
* Used for draft sync, a process running every 5s for the first editor of a document to sync the document to the Confluence back-end.
|
|
528
|
-
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
529
|
-
*/
|
|
530
|
-
|
|
531
|
-
/**
|
|
532
|
-
* Return the final acknowledged (by NCS) ADF version of the current draft document, together with it's title and the current step version.
|
|
533
|
-
* Used when returning the document to Confluence on publish.
|
|
534
|
-
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
535
|
-
*/
|
|
536
|
-
|
|
537
|
-
/**
|
|
538
|
-
* ESS-2916 namespace status event- lock/unlock
|
|
539
|
-
*/
|
|
540
|
-
|
|
541
|
-
/**
|
|
542
|
-
* Used when the provider is disconnected or destroyed to prevent perpetual timers from continuously running
|
|
543
|
-
*/
|
|
544
538
|
}]);
|
|
545
539
|
return Provider;
|
|
546
540
|
}(_emitter.Emitter);
|
package/dist/cjs/types.js
CHANGED
|
@@ -9,10 +9,16 @@ exports.AcknowledgementResponseTypes = void 0;
|
|
|
9
9
|
* @deprecated Use ProviderError type instead
|
|
10
10
|
*/
|
|
11
11
|
// Channel
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* @description Incoming payload type from the `broadcast` route in NCS
|
|
14
|
+
* @param {number} timestamp added in NCS
|
|
15
|
+
* @param {string} sessionId socket.id from NCS
|
|
16
|
+
* @param data event specific data from NCS
|
|
17
|
+
*/
|
|
18
|
+
var AcknowledgementResponseTypes = /*#__PURE__*/function (AcknowledgementResponseTypes) {
|
|
15
19
|
AcknowledgementResponseTypes["SUCCESS"] = "SUCCESS";
|
|
16
20
|
AcknowledgementResponseTypes["ERROR"] = "ERROR";
|
|
17
|
-
|
|
18
|
-
//
|
|
21
|
+
return AcknowledgementResponseTypes;
|
|
22
|
+
}({}); // ESS-2916 Type def for namespace status - lock/unlock
|
|
23
|
+
// Catchup
|
|
24
|
+
exports.AcknowledgementResponseTypes = AcknowledgementResponseTypes;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = "@atlaskit/collab-provider";
|
|
8
8
|
exports.name = name;
|
|
9
|
-
var version = "8.
|
|
9
|
+
var version = "8.8.0";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -2,11 +2,11 @@ import { EVENT_ACTION } from '../helpers/const';
|
|
|
2
2
|
import { name as packageName, version as packageVersion } from '../version-wrapper';
|
|
3
3
|
import { network } from '../connectivity/singleton';
|
|
4
4
|
const EVENT_SUBJECT = 'collab';
|
|
5
|
-
var COLLAB_SERVICE
|
|
6
|
-
(function (COLLAB_SERVICE) {
|
|
5
|
+
var COLLAB_SERVICE = /*#__PURE__*/function (COLLAB_SERVICE) {
|
|
7
6
|
COLLAB_SERVICE["NCS"] = "ncs";
|
|
8
7
|
COLLAB_SERVICE["SYNCHRONY"] = "synchrony";
|
|
9
|
-
|
|
8
|
+
return COLLAB_SERVICE;
|
|
9
|
+
}(COLLAB_SERVICE || {});
|
|
10
10
|
const triggerAnalyticsEvent = (analyticsEvent, analyticsClient) => {
|
|
11
11
|
if (!analyticsClient) {
|
|
12
12
|
return;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export let MEASURE_NAME
|
|
2
|
-
(function (MEASURE_NAME) {
|
|
1
|
+
export let MEASURE_NAME = /*#__PURE__*/function (MEASURE_NAME) {
|
|
3
2
|
MEASURE_NAME["SOCKET_CONNECT"] = "socketConnect";
|
|
4
3
|
MEASURE_NAME["DOCUMENT_INIT"] = "documentInit";
|
|
5
4
|
MEASURE_NAME["COMMIT_UNCONFIRMED_STEPS"] = "commitUnconfirmedSteps";
|
|
6
5
|
MEASURE_NAME["PUBLISH_PAGE"] = "publishPage";
|
|
7
6
|
MEASURE_NAME["GET_CURRENT_STATE"] = "getCurrentState";
|
|
8
|
-
|
|
7
|
+
return MEASURE_NAME;
|
|
8
|
+
}({});
|
|
9
9
|
export const isPerformanceAPIAvailable = () => {
|
|
10
10
|
return typeof window !== 'undefined' && 'performance' in window && ['measure', 'clearMeasures', 'clearMarks', 'getEntriesByName', 'getEntriesByType'].every(api => !!performance[api]);
|
|
11
11
|
};
|
package/dist/es2019/channel.js
CHANGED
|
@@ -18,6 +18,7 @@ export class Channel extends Emitter {
|
|
|
18
18
|
_defineProperty(this, "reconnectHelper", null);
|
|
19
19
|
_defineProperty(this, "initialized", false);
|
|
20
20
|
_defineProperty(this, "network", null);
|
|
21
|
+
// read-only getters used for tests
|
|
21
22
|
_defineProperty(this, "getInitialized", () => this.initialized);
|
|
22
23
|
_defineProperty(this, "getConnected", () => this.connected);
|
|
23
24
|
_defineProperty(this, "getSocket", () => this.socket);
|
|
@@ -27,6 +28,7 @@ export class Channel extends Emitter {
|
|
|
27
28
|
this.token = value;
|
|
28
29
|
}
|
|
29
30
|
});
|
|
31
|
+
// sets the token as undefined
|
|
30
32
|
_defineProperty(this, "unsetToken", () => this.setToken());
|
|
31
33
|
_defineProperty(this, "handlePermissionInvalidateToken", data => {
|
|
32
34
|
var _this$analyticsHelper;
|
|
@@ -213,6 +215,11 @@ export class Channel extends Emitter {
|
|
|
213
215
|
throw error;
|
|
214
216
|
}
|
|
215
217
|
});
|
|
218
|
+
/**
|
|
219
|
+
* Send message to the back-end service over the channel. Timestamp will be added server side.
|
|
220
|
+
* @throws {NotInitializedError} Channel not initialized
|
|
221
|
+
* @throws {NotConnectedError} Channel not connected
|
|
222
|
+
*/
|
|
216
223
|
_defineProperty(this, "broadcast", (type, data, callback) => {
|
|
217
224
|
if (!this.socket) {
|
|
218
225
|
throw new NotInitializedError('Cannot broadcast, not initialized yet');
|
|
@@ -228,6 +235,11 @@ export class Channel extends Emitter {
|
|
|
228
235
|
...data
|
|
229
236
|
}, callback);
|
|
230
237
|
});
|
|
238
|
+
/**
|
|
239
|
+
* Send metadata to the back-end service over the channel
|
|
240
|
+
* @throws {NotInitializedError} Channel not initialized
|
|
241
|
+
* @throws {NotConnectedError} Channel not connected
|
|
242
|
+
*/
|
|
231
243
|
_defineProperty(this, "sendMetadata", metadata => {
|
|
232
244
|
if (!this.socket) {
|
|
233
245
|
throw new NotInitializedError('Cannot send metadata, not initialized yet');
|
|
@@ -251,11 +263,6 @@ export class Channel extends Emitter {
|
|
|
251
263
|
this.analyticsHelper = analyticsHelper;
|
|
252
264
|
this.initExperience = createDocInitExp(this.analyticsHelper);
|
|
253
265
|
}
|
|
254
|
-
|
|
255
|
-
// read-only getters used for tests
|
|
256
|
-
|
|
257
|
-
// sets the token as undefined
|
|
258
|
-
|
|
259
266
|
/**
|
|
260
267
|
* Connect to collab service using websockets
|
|
261
268
|
*/
|
|
@@ -338,8 +345,15 @@ export class Channel extends Emitter {
|
|
|
338
345
|
this.socket.on('steps:added', data => {
|
|
339
346
|
this.emit('steps:added', data);
|
|
340
347
|
});
|
|
341
|
-
this.socket.on('participant:telepointer',
|
|
342
|
-
|
|
348
|
+
this.socket.on('participant:telepointer', ({
|
|
349
|
+
timestamp,
|
|
350
|
+
data
|
|
351
|
+
}) => {
|
|
352
|
+
// data is TelepointerPayload without timestamp
|
|
353
|
+
this.emit('participant:telepointer', {
|
|
354
|
+
timestamp,
|
|
355
|
+
...data
|
|
356
|
+
});
|
|
343
357
|
});
|
|
344
358
|
this.socket.on('presence:joined', data => {
|
|
345
359
|
this.emit('presence:joined', data);
|
|
@@ -418,19 +432,6 @@ export class Channel extends Emitter {
|
|
|
418
432
|
// Fired upon a reconnection attempt error (from Socket.IO Manager)
|
|
419
433
|
this.socket.io.on('reconnect_error', this.onReconnectError);
|
|
420
434
|
}
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Send message to the back-end service over the channel. Timestamp will be added server side.
|
|
424
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
425
|
-
* @throws {NotConnectedError} Channel not connected
|
|
426
|
-
*/
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* Send metadata to to the back-end service over the channel
|
|
430
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
431
|
-
* @throws {NotConnectedError} Channel not connected
|
|
432
|
-
*/
|
|
433
|
-
|
|
434
435
|
sendPresenceJoined() {
|
|
435
436
|
if (!this.connected || !this.socket) {
|
|
436
437
|
return;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
export let NetworkStatus
|
|
3
|
-
(function (NetworkStatus) {
|
|
2
|
+
export let NetworkStatus = /*#__PURE__*/function (NetworkStatus) {
|
|
4
3
|
NetworkStatus["ONLINE"] = "ONLINE";
|
|
5
4
|
NetworkStatus["OFFLINE"] = "OFFLINE";
|
|
6
|
-
|
|
5
|
+
return NetworkStatus;
|
|
6
|
+
}({});
|
|
7
7
|
export default class Network {
|
|
8
8
|
constructor(props) {
|
|
9
9
|
_defineProperty(this, "offlineHandler", () => {
|