@atlaskit/collab-provider 8.6.0 → 8.7.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 +16 -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/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 +9 -4
- 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,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";
|
|
@@ -8,7 +7,7 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
8
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
9
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
10
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
11
|
-
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; }
|
|
10
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
12
11
|
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); }; }
|
|
13
12
|
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; } }
|
|
14
13
|
import { Emitter } from '../emitter';
|
|
@@ -30,20 +29,13 @@ export var MAX_STEP_REJECTED_ERROR = 15;
|
|
|
30
29
|
export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
31
30
|
_inherits(Provider, _Emitter);
|
|
32
31
|
var _super = _createSuper(Provider);
|
|
33
|
-
// To keep track of the namespace event changes from the server.
|
|
34
|
-
|
|
35
|
-
// SessionID is the unique socket-session.
|
|
36
|
-
|
|
37
|
-
// ClientID is the unique ID for a prosemirror client. Used for step-rebasing.
|
|
38
|
-
|
|
39
|
-
// UserID is the users actual account id.
|
|
40
|
-
|
|
41
32
|
function Provider(config) {
|
|
42
33
|
var _this;
|
|
43
34
|
_classCallCheck(this, Provider);
|
|
44
35
|
_this = _super.call(this);
|
|
45
36
|
_defineProperty(_assertThisInitialized(_this), "isChannelInitialized", false);
|
|
46
37
|
_defineProperty(_assertThisInitialized(_this), "isProviderInitialized", false);
|
|
38
|
+
// To keep track of the namespace event changes from the server.
|
|
47
39
|
_defineProperty(_assertThisInitialized(_this), "isNamespaceLocked", false);
|
|
48
40
|
_defineProperty(_assertThisInitialized(_this), "emitCallback", function (evt, data) {
|
|
49
41
|
return _this.emit(evt, data);
|
|
@@ -98,6 +90,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
98
90
|
_this.metadataService.updateMetadata(metadata);
|
|
99
91
|
}).on('restore', _this.documentService.onRestore).on('steps:added', _this.documentService.onStepsAdded).on('metadata:changed', _this.metadataService.onMetadataChanged).on('participant:telepointer', _this.onParticipantTelepointer.bind(_assertThisInitialized(_this))).on('presence:joined', _this.onPresenceJoined.bind(_assertThisInitialized(_this))).on('presence', _this.onPresence.bind(_assertThisInitialized(_this))).on('participant:left', _this.onParticipantLeft.bind(_assertThisInitialized(_this))).on('participant:updated', _this.onParticipantUpdated.bind(_assertThisInitialized(_this))).on('disconnect', _this.onDisconnected.bind(_assertThisInitialized(_this))).on('error', _this.onErrorHandled).on('status', _this.onNamespaceStatusChanged.bind(_assertThisInitialized(_this))).connect(shouldInitialize);
|
|
100
92
|
});
|
|
93
|
+
/**
|
|
94
|
+
* @param {InternalError} error The error to handle
|
|
95
|
+
*/
|
|
101
96
|
_defineProperty(_assertThisInitialized(_this), "onErrorHandled", function (error) {
|
|
102
97
|
var _error$data, _error$data2;
|
|
103
98
|
// User tried committing steps but they were rejected because:
|
|
@@ -136,6 +131,13 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
136
131
|
(_this$analyticsHelper3 = _this.analyticsHelper) === null || _this$analyticsHelper3 === void 0 ? void 0 : _this$analyticsHelper3.sendErrorEvent(error, 'Error while sending presence');
|
|
137
132
|
}
|
|
138
133
|
});
|
|
134
|
+
/**
|
|
135
|
+
* Called when a participant joins the session.
|
|
136
|
+
*
|
|
137
|
+
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
138
|
+
* the active avatars in the editor.
|
|
139
|
+
* This method will be triggered from backend to notify all participants to exchange presence
|
|
140
|
+
*/
|
|
139
141
|
_defineProperty(_assertThisInitialized(_this), "onPresenceJoined", function (_ref3) {
|
|
140
142
|
var sessionId = _ref3.sessionId;
|
|
141
143
|
try {
|
|
@@ -161,103 +163,129 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
161
163
|
(_this$analyticsHelper5 = _this.analyticsHelper) === null || _this$analyticsHelper5 === void 0 ? void 0 : _this$analyticsHelper5.sendErrorEvent(error, 'Error while receiving presence');
|
|
162
164
|
}
|
|
163
165
|
});
|
|
166
|
+
/**
|
|
167
|
+
* Called when a participant leaves the session.
|
|
168
|
+
*
|
|
169
|
+
* We emit the `presence` event to update the active avatars in the editor.
|
|
170
|
+
*/
|
|
164
171
|
_defineProperty(_assertThisInitialized(_this), "onParticipantLeft", function (data) {
|
|
165
172
|
return _this.participantsService.participantLeft(data, _this.emitCallback);
|
|
166
173
|
});
|
|
167
174
|
_defineProperty(_assertThisInitialized(_this), "startInactiveRemover", function () {
|
|
168
175
|
return _this.participantsService.removeInactiveParticipants(_this.sessionId, _this.emitCallback);
|
|
169
176
|
});
|
|
177
|
+
/**
|
|
178
|
+
* Called when we receive an update event from another participant.
|
|
179
|
+
*/
|
|
170
180
|
_defineProperty(_assertThisInitialized(_this), "onParticipantUpdated", function (data) {
|
|
171
181
|
return _this.participantsService.updateParticipant(data, _this.config.getUser, _this.emitCallback);
|
|
172
182
|
});
|
|
183
|
+
/**
|
|
184
|
+
* Called when we receive a telepointer update from another
|
|
185
|
+
* participant.
|
|
186
|
+
*/
|
|
173
187
|
_defineProperty(_assertThisInitialized(_this), "onParticipantTelepointer", function (data) {
|
|
174
188
|
return _this.participantsService.participantTelepointer(data, _this.sessionId, _this.config.getUser, _this.emitCallback);
|
|
175
189
|
});
|
|
190
|
+
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
176
191
|
_defineProperty(_assertThisInitialized(_this), "onDisconnected", function (_ref5) {
|
|
177
192
|
var reason = _ref5.reason;
|
|
178
193
|
_this.disconnectedAt = Date.now();
|
|
179
194
|
_this.participantsService.disconnect(reason, _this.sessionId, _this.emitCallback);
|
|
180
195
|
});
|
|
181
|
-
|
|
196
|
+
/**
|
|
197
|
+
* Returns the documents metadata
|
|
198
|
+
*/
|
|
199
|
+
_defineProperty(_assertThisInitialized(_this), "getMetadata", function () {
|
|
200
|
+
return _this.metadataService.getMetaData();
|
|
201
|
+
});
|
|
202
|
+
/**
|
|
203
|
+
* Return the ADF version of the current draft document, together with it's title and the current step version.
|
|
204
|
+
* 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.
|
|
205
|
+
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
206
|
+
*/
|
|
207
|
+
_defineProperty(_assertThisInitialized(_this), "getCurrentState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
182
208
|
var _this$analyticsHelper6;
|
|
183
|
-
return _regeneratorRuntime
|
|
184
|
-
while (1) {
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
return _context.stop();
|
|
197
|
-
}
|
|
209
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
210
|
+
while (1) switch (_context.prev = _context.next) {
|
|
211
|
+
case 0:
|
|
212
|
+
_context.prev = 0;
|
|
213
|
+
return _context.abrupt("return", _this.documentService.getCurrentState());
|
|
214
|
+
case 4:
|
|
215
|
+
_context.prev = 4;
|
|
216
|
+
_context.t0 = _context["catch"](0);
|
|
217
|
+
(_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');
|
|
218
|
+
throw new GetCurrentStateError('Error while returning the current state of the draft document', _context.t0);
|
|
219
|
+
case 8:
|
|
220
|
+
case "end":
|
|
221
|
+
return _context.stop();
|
|
198
222
|
}
|
|
199
223
|
}, _callee, null, [[0, 4]]);
|
|
200
224
|
})));
|
|
201
|
-
|
|
225
|
+
/**
|
|
226
|
+
* Return the final acknowledged (by NCS) ADF version of the current draft document, together with it's title and the current step version.
|
|
227
|
+
* Used when returning the document to Confluence on publish.
|
|
228
|
+
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
229
|
+
*/
|
|
230
|
+
_defineProperty(_assertThisInitialized(_this), "getFinalAcknowledgedState", /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
202
231
|
var _this$analyticsHelper7;
|
|
203
|
-
return _regeneratorRuntime
|
|
204
|
-
while (1) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
return _context2.stop();
|
|
217
|
-
}
|
|
232
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
233
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
234
|
+
case 0:
|
|
235
|
+
_context2.prev = 0;
|
|
236
|
+
return _context2.abrupt("return", _this.documentService.getFinalAcknowledgedState());
|
|
237
|
+
case 4:
|
|
238
|
+
_context2.prev = 4;
|
|
239
|
+
_context2.t0 = _context2["catch"](0);
|
|
240
|
+
(_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');
|
|
241
|
+
throw new GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
242
|
+
case 8:
|
|
243
|
+
case "end":
|
|
244
|
+
return _context2.stop();
|
|
218
245
|
}
|
|
219
246
|
}, _callee2, null, [[0, 4]]);
|
|
220
247
|
})));
|
|
221
248
|
_defineProperty(_assertThisInitialized(_this), "getUnconfirmedSteps", function () {
|
|
222
249
|
return _this.documentService.getUnconfirmedSteps();
|
|
223
250
|
});
|
|
251
|
+
/**
|
|
252
|
+
* ESS-2916 namespace status event- lock/unlock
|
|
253
|
+
*/
|
|
224
254
|
_defineProperty(_assertThisInitialized(_this), "onNamespaceStatusChanged", /*#__PURE__*/function () {
|
|
225
|
-
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime
|
|
255
|
+
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(data) {
|
|
226
256
|
var isLocked, waitTimeInMs, timestamp, start;
|
|
227
|
-
return _regeneratorRuntime
|
|
228
|
-
while (1) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
});
|
|
257
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
258
|
+
while (1) switch (_context3.prev = _context3.next) {
|
|
259
|
+
case 0:
|
|
260
|
+
isLocked = data.isLocked, waitTimeInMs = data.waitTimeInMs, timestamp = data.timestamp;
|
|
261
|
+
start = Date.now();
|
|
262
|
+
logger("Received a namespace status changed event ", {
|
|
263
|
+
data: data
|
|
264
|
+
});
|
|
265
|
+
if (!(isLocked && waitTimeInMs)) {
|
|
266
|
+
_context3.next = 8;
|
|
267
|
+
break;
|
|
268
|
+
}
|
|
269
|
+
_this.isNamespaceLocked = true;
|
|
270
|
+
logger("Received a namespace status change event ", {
|
|
271
|
+
isLocked: isLocked
|
|
272
|
+
});
|
|
244
273
|
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
_this.isNamespaceLocked = false;
|
|
252
|
-
}, waitTimeInMs);
|
|
253
|
-
return _context3.abrupt("return");
|
|
254
|
-
case 8:
|
|
274
|
+
// To protect the collab editing process from locked out due to BE
|
|
275
|
+
setTimeout(function () {
|
|
276
|
+
logger("The namespace lock has expired", {
|
|
277
|
+
waitTime: Date.now() - start,
|
|
278
|
+
timestamp: timestamp
|
|
279
|
+
});
|
|
255
280
|
_this.isNamespaceLocked = false;
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
281
|
+
}, waitTimeInMs);
|
|
282
|
+
return _context3.abrupt("return");
|
|
283
|
+
case 8:
|
|
284
|
+
_this.isNamespaceLocked = false;
|
|
285
|
+
logger("The page lock has expired");
|
|
286
|
+
case 10:
|
|
287
|
+
case "end":
|
|
288
|
+
return _context3.stop();
|
|
261
289
|
}
|
|
262
290
|
}, _callee3);
|
|
263
291
|
}));
|
|
@@ -265,6 +293,9 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
265
293
|
return _ref8.apply(this, arguments);
|
|
266
294
|
};
|
|
267
295
|
}());
|
|
296
|
+
/**
|
|
297
|
+
* Used when the provider is disconnected or destroyed to prevent perpetual timers from continuously running
|
|
298
|
+
*/
|
|
268
299
|
_defineProperty(_assertThisInitialized(_this), "clearTimers", function () {
|
|
269
300
|
clearTimeout(_this.presenceUpdateTimeout);
|
|
270
301
|
_this.participantsService.clearTimers();
|
|
@@ -309,6 +340,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
309
340
|
value: function setup(_ref9) {
|
|
310
341
|
var getState = _ref9.getState,
|
|
311
342
|
onSyncUpError = _ref9.onSyncUpError;
|
|
343
|
+
this.checkForCookies();
|
|
312
344
|
try {
|
|
313
345
|
var collabPlugin = getState().plugins.find(function (p) {
|
|
314
346
|
return p.key === 'collab$';
|
|
@@ -334,6 +366,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
334
366
|
}
|
|
335
367
|
return this;
|
|
336
368
|
}
|
|
369
|
+
}, {
|
|
370
|
+
key: "checkForCookies",
|
|
371
|
+
value: function checkForCookies() {
|
|
372
|
+
if (!global.navigator.cookieEnabled) {
|
|
373
|
+
var _this$analyticsHelper9;
|
|
374
|
+
var initError = new ProviderInitialisationError('Cookies are not enabled. Please enable cookies to use collaborative editing.');
|
|
375
|
+
(_this$analyticsHelper9 = this.analyticsHelper) === null || _this$analyticsHelper9 === void 0 ? void 0 : _this$analyticsHelper9.sendErrorEvent(initError, 'Error while initialising the provider - cookies disabled');
|
|
376
|
+
throw new ProviderInitialisationError('Provider initialisation error - cookies disabled', initError);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
337
379
|
|
|
338
380
|
/**
|
|
339
381
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
@@ -353,15 +395,11 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
353
395
|
}
|
|
354
396
|
this.documentService.send(_tr, _oldState, newState);
|
|
355
397
|
} catch (error) {
|
|
356
|
-
var _this$
|
|
357
|
-
(_this$
|
|
398
|
+
var _this$analyticsHelper10;
|
|
399
|
+
(_this$analyticsHelper10 = this.analyticsHelper) === null || _this$analyticsHelper10 === void 0 ? void 0 : _this$analyticsHelper10.sendErrorEvent(error, 'Error while sending steps for a transaction');
|
|
358
400
|
throw new SendTransactionError('Error while sending steps for a transaction', error);
|
|
359
401
|
}
|
|
360
402
|
}
|
|
361
|
-
|
|
362
|
-
/**
|
|
363
|
-
* @param {InternalError} error The error to handle
|
|
364
|
-
*/
|
|
365
403
|
}, {
|
|
366
404
|
key: "sendMessage",
|
|
367
405
|
value:
|
|
@@ -386,36 +424,11 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
386
424
|
this.channel.broadcast('participant:telepointer', payload, callback);
|
|
387
425
|
}
|
|
388
426
|
} catch (error) {
|
|
389
|
-
var _this$
|
|
427
|
+
var _this$analyticsHelper11;
|
|
390
428
|
// We don't want to throw errors for Presence features as they tend to self-restore
|
|
391
|
-
(_this$
|
|
429
|
+
(_this$analyticsHelper11 = this.analyticsHelper) === null || _this$analyticsHelper11 === void 0 ? void 0 : _this$analyticsHelper11.sendErrorEvent(error, 'Error while sending message - telepointer');
|
|
392
430
|
}
|
|
393
431
|
}
|
|
394
|
-
|
|
395
|
-
/**
|
|
396
|
-
* Called when a participant joins the session.
|
|
397
|
-
*
|
|
398
|
-
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
399
|
-
* the active avatars in the editor.
|
|
400
|
-
* This method will be triggered from backend to notify all participants to exchange presence
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Called when a participant leaves the session.
|
|
405
|
-
*
|
|
406
|
-
* We emit the `presence` event to update the active avatars in the editor.
|
|
407
|
-
*/
|
|
408
|
-
|
|
409
|
-
/**
|
|
410
|
-
* Called when we receive an update event from another participant.
|
|
411
|
-
*/
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Called when we receive a telepointer update from another
|
|
415
|
-
* participant.
|
|
416
|
-
*/
|
|
417
|
-
|
|
418
|
-
// Note: this gets triggered on page reload for Firefox (not other browsers) because of closeOnBeforeunload: false
|
|
419
432
|
}, {
|
|
420
433
|
key: "destroy",
|
|
421
434
|
value:
|
|
@@ -452,8 +465,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
452
465
|
_get(_getPrototypeOf(Provider.prototype), "unsubscribeAll", this).call(this);
|
|
453
466
|
this.channel.disconnect();
|
|
454
467
|
} catch (error) {
|
|
455
|
-
var _this$
|
|
456
|
-
(_this$
|
|
468
|
+
var _this$analyticsHelper12;
|
|
469
|
+
(_this$analyticsHelper12 = this.analyticsHelper) === null || _this$analyticsHelper12 === void 0 ? void 0 : _this$analyticsHelper12.sendErrorEvent(error, 'Error while shutting down the collab provider');
|
|
457
470
|
throw new DestroyError('Error while shutting down the collab provider', error);
|
|
458
471
|
}
|
|
459
472
|
this.clearTimers();
|
|
@@ -462,6 +475,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
462
475
|
|
|
463
476
|
/**
|
|
464
477
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
478
|
+
* @deprecated use setMetadata instead, it does the same thing
|
|
465
479
|
* @param {string} title Title you want to set on the document
|
|
466
480
|
* @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)
|
|
467
481
|
* @throws {SetTitleError} Something went wrong while setting the title
|
|
@@ -472,8 +486,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
472
486
|
try {
|
|
473
487
|
this.metadataService.setTitle(title, broadcast);
|
|
474
488
|
} catch (error) {
|
|
475
|
-
var _this$
|
|
476
|
-
(_this$
|
|
489
|
+
var _this$analyticsHelper13;
|
|
490
|
+
(_this$analyticsHelper13 = this.analyticsHelper) === null || _this$analyticsHelper13 === void 0 ? void 0 : _this$analyticsHelper13.sendErrorEvent(error, 'Error while setting title');
|
|
477
491
|
throw new SetTitleError('Error while setting title', error);
|
|
478
492
|
}
|
|
479
493
|
}
|
|
@@ -491,8 +505,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
491
505
|
try {
|
|
492
506
|
this.metadataService.setEditorWidth(editorWidth, broadcast);
|
|
493
507
|
} catch (error) {
|
|
494
|
-
var _this$
|
|
495
|
-
(_this$
|
|
508
|
+
var _this$analyticsHelper14;
|
|
509
|
+
(_this$analyticsHelper14 = this.analyticsHelper) === null || _this$analyticsHelper14 === void 0 ? void 0 : _this$analyticsHelper14.sendErrorEvent(error, 'Error while setting editor width');
|
|
496
510
|
throw new SetEditorWidthError('Error while setting editor width', error);
|
|
497
511
|
}
|
|
498
512
|
}
|
|
@@ -508,31 +522,11 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
508
522
|
try {
|
|
509
523
|
this.metadataService.setMetadata(metadata);
|
|
510
524
|
} catch (error) {
|
|
511
|
-
var _this$
|
|
512
|
-
(_this$
|
|
525
|
+
var _this$analyticsHelper15;
|
|
526
|
+
(_this$analyticsHelper15 = this.analyticsHelper) === null || _this$analyticsHelper15 === void 0 ? void 0 : _this$analyticsHelper15.sendErrorEvent(error, 'Error while setting metadata');
|
|
513
527
|
throw new SetMetadataError('Error while setting metadata', error);
|
|
514
528
|
}
|
|
515
529
|
}
|
|
516
|
-
|
|
517
|
-
/**
|
|
518
|
-
* Return the ADF version of the current draft document, together with it's title and the current step version.
|
|
519
|
-
* 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.
|
|
520
|
-
* @throws {GetCurrentStateError} Something went wrong while returning the current state
|
|
521
|
-
*/
|
|
522
|
-
|
|
523
|
-
/**
|
|
524
|
-
* Return the final acknowledged (by NCS) ADF version of the current draft document, together with it's title and the current step version.
|
|
525
|
-
* Used when returning the document to Confluence on publish.
|
|
526
|
-
* @throws {GetFinalAcknowledgedStateError} Something went wrong while returning the acknowledged state
|
|
527
|
-
*/
|
|
528
|
-
|
|
529
|
-
/**
|
|
530
|
-
* ESS-2916 namespace status event- lock/unlock
|
|
531
|
-
*/
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Used when the provider is disconnected or destroyed to prevent perpetual timers from continuously running
|
|
535
|
-
*/
|
|
536
530
|
}]);
|
|
537
531
|
return Provider;
|
|
538
532
|
}(Emitter);
|
package/dist/esm/types.js
CHANGED
|
@@ -6,9 +6,19 @@
|
|
|
6
6
|
|
|
7
7
|
// Channel
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @description Incoming payload type from the `broadcast` route in NCS
|
|
11
|
+
* @param {number} timestamp added in NCS
|
|
12
|
+
* @param {string} sessionId socket.id from NCS
|
|
13
|
+
* @param data event specific data from NCS
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
export var AcknowledgementResponseTypes = /*#__PURE__*/function (AcknowledgementResponseTypes) {
|
|
11
17
|
AcknowledgementResponseTypes["SUCCESS"] = "SUCCESS";
|
|
12
18
|
AcknowledgementResponseTypes["ERROR"] = "ERROR";
|
|
13
|
-
|
|
19
|
+
return AcknowledgementResponseTypes;
|
|
20
|
+
}({});
|
|
21
|
+
|
|
22
|
+
// ESS-2916 Type def for namespace status - lock/unlock
|
|
23
|
+
|
|
14
24
|
// Catchup
|
package/dist/esm/version.json
CHANGED
package/dist/types/channel.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
36
36
|
*/
|
|
37
37
|
broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function | undefined) => void;
|
|
38
38
|
/**
|
|
39
|
-
* Send metadata to
|
|
39
|
+
* Send metadata to the back-end service over the channel
|
|
40
40
|
* @throws {NotInitializedError} Channel not initialized
|
|
41
41
|
* @throws {NotConnectedError} Channel not connected
|
|
42
42
|
*/
|
|
@@ -16,7 +16,7 @@ export declare class MetadataService {
|
|
|
16
16
|
* Updates the local metadata and broadcasts the metadata to other clients/backend.
|
|
17
17
|
* @param metadata
|
|
18
18
|
*/
|
|
19
|
-
setMetadata(metadata: Metadata)
|
|
19
|
+
setMetadata: (metadata: Metadata) => void;
|
|
20
20
|
/**
|
|
21
21
|
* Emits a change in document's metadata
|
|
22
22
|
* @param metadata
|
|
@@ -8,8 +8,7 @@ export declare type ProviderParticipant = CollabParticipant & {
|
|
|
8
8
|
export declare type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
9
|
export declare type PresenceEmit = (evt: 'presence', data: CollabEventPresenceData) => void;
|
|
10
10
|
export declare type TelepointerEmit = (evt: 'telepointer', data: CollabEventTelepointerData) => void;
|
|
11
|
+
export declare type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
|
|
11
12
|
export declare const createParticipantFromPayload: (payload: PresencePayload & {
|
|
12
13
|
userId: string;
|
|
13
|
-
}, getUser:
|
|
14
|
-
userId: string;
|
|
15
|
-
}>) | undefined) => Promise<ProviderParticipant>;
|
|
14
|
+
}, getUser: GetUserType) => Promise<ProviderParticipant>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { CollabEventPresenceData,
|
|
1
|
+
import type { CollabEventPresenceData, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
3
|
import type { CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
4
|
-
import { TelepointerEmit } from './participants-helper';
|
|
4
|
+
import { GetUserType, TelepointerEmit } from './participants-helper';
|
|
5
5
|
import type { PresenceEmit } from './participants-helper';
|
|
6
6
|
import { ParticipantsState } from './participants-state';
|
|
7
7
|
export declare class ParticipantsService {
|
|
@@ -16,9 +16,7 @@ export declare class ParticipantsService {
|
|
|
16
16
|
* @param emit Function to execute emit from provider socket
|
|
17
17
|
* @returns Awaitable Promise, due to getUser
|
|
18
18
|
*/
|
|
19
|
-
updateParticipant: (payload: PresencePayload, getUser:
|
|
20
|
-
userId: string;
|
|
21
|
-
}>) | undefined, emit: PresenceEmit) => Promise<void>;
|
|
19
|
+
updateParticipant: (payload: PresencePayload, getUser: GetUserType, emit: PresenceEmit) => Promise<void>;
|
|
22
20
|
/**
|
|
23
21
|
* Called when a participant leaves the session.
|
|
24
22
|
*
|
|
@@ -41,9 +39,7 @@ export declare class ParticipantsService {
|
|
|
41
39
|
* Called when we receive a telepointer update from another
|
|
42
40
|
* participant.
|
|
43
41
|
*/
|
|
44
|
-
participantTelepointer: (payload: TelepointerPayload, thisSessionId: string | undefined, getUser: (
|
|
45
|
-
userId: string;
|
|
46
|
-
}>) | undefined, emit: (evt: 'telepointer' | 'presence', data: CollabEventTelepointerData | CollabEventPresenceData) => void) => void;
|
|
42
|
+
participantTelepointer: (payload: TelepointerPayload, thisSessionId: string | undefined, getUser: GetUserType, emit: (evt: 'telepointer' | 'presence', data: CollabEventTelepointerData | CollabEventPresenceData) => void) => void;
|
|
47
43
|
/**
|
|
48
44
|
* Every 5 minutes (PARTICIPANT_UPDATE_INTERVAL), removes inactive participants and emits the update to other participants.
|
|
49
45
|
* Needs to be kicked off in the Provider.
|
|
@@ -43,6 +43,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
43
43
|
getState: () => EditorState;
|
|
44
44
|
onSyncUpError?: SyncUpErrorFunction;
|
|
45
45
|
}): this;
|
|
46
|
+
private checkForCookies;
|
|
46
47
|
/**
|
|
47
48
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
48
49
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
|
@@ -112,6 +113,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
112
113
|
unsubscribeAll(): this;
|
|
113
114
|
/**
|
|
114
115
|
* Update the title of the document in the collab provider and optionally broadcast it to other participants and NCS
|
|
116
|
+
* @deprecated use setMetadata instead, it does the same thing
|
|
115
117
|
* @param {string} title Title you want to set on the document
|
|
116
118
|
* @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)
|
|
117
119
|
* @throws {SetTitleError} Something went wrong while setting the title
|
|
@@ -131,6 +133,10 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
131
133
|
* @throws {ExampleError} Something went wrong while setting the metadata
|
|
132
134
|
*/
|
|
133
135
|
setMetadata(metadata: Metadata): void;
|
|
136
|
+
/**
|
|
137
|
+
* Returns the documents metadata
|
|
138
|
+
*/
|
|
139
|
+
getMetadata: () => Metadata;
|
|
134
140
|
/**
|
|
135
141
|
* Return the ADF version of the current draft document, together with it's title and the current step version.
|
|
136
142
|
* 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.
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Step } from 'prosemirror-transform';
|
|
2
2
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
-
import type {
|
|
3
|
+
import type { CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
4
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
5
|
import type { Manager } from 'socket.io-client';
|
|
6
6
|
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
@@ -8,6 +8,7 @@ import type { InternalError } from './errors/error-types';
|
|
|
8
8
|
import type { ProviderError } from './errors/error-types';
|
|
9
9
|
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
10
10
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
11
|
+
import { ProviderParticipant } from './participants/participants-helper';
|
|
11
12
|
export interface Storage {
|
|
12
13
|
get(key: string): Promise<string>;
|
|
13
14
|
set(key: string, value: string): Promise<void>;
|
|
@@ -33,9 +34,7 @@ export interface Config {
|
|
|
33
34
|
featureFlags?: {
|
|
34
35
|
[key: string]: boolean;
|
|
35
36
|
};
|
|
36
|
-
getUser?(userId: string): Promise<Pick<
|
|
37
|
-
userId: string;
|
|
38
|
-
}>;
|
|
37
|
+
getUser?(userId: string): Promise<Pick<ProviderParticipant, 'avatar' | 'name' | 'userId'>>;
|
|
39
38
|
/**
|
|
40
39
|
* If provided, permissionTokenRefresh is called whenever a new JWT token is required.
|
|
41
40
|
*/
|
|
@@ -119,6 +118,17 @@ export declare type InitPayload = {
|
|
|
119
118
|
userId?: string;
|
|
120
119
|
metadata?: Metadata;
|
|
121
120
|
};
|
|
121
|
+
/**
|
|
122
|
+
* @description Incoming payload type from the `broadcast` route in NCS
|
|
123
|
+
* @param {number} timestamp added in NCS
|
|
124
|
+
* @param {string} sessionId socket.id from NCS
|
|
125
|
+
* @param data event specific data from NCS
|
|
126
|
+
*/
|
|
127
|
+
export declare type BroadcastIncomingPayload = {
|
|
128
|
+
sessionId?: string;
|
|
129
|
+
timestamp?: number;
|
|
130
|
+
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
131
|
+
};
|
|
122
132
|
export declare type PresencePayload = {
|
|
123
133
|
sessionId: string;
|
|
124
134
|
userId: string | undefined;
|
|
@@ -126,11 +136,7 @@ export declare type PresencePayload = {
|
|
|
126
136
|
timestamp: number;
|
|
127
137
|
};
|
|
128
138
|
export declare type TelepointerPayload = PresencePayload & {
|
|
129
|
-
selection:
|
|
130
|
-
type: 'textSelection' | 'nodeSelection';
|
|
131
|
-
anchor?: number | string;
|
|
132
|
-
head?: number | string;
|
|
133
|
-
};
|
|
139
|
+
selection: CollabSendableSelection;
|
|
134
140
|
};
|
|
135
141
|
declare type MarkJson = {
|
|
136
142
|
type: string;
|