@atlaskit/collab-provider 7.1.3 → 7.1.4
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 +7 -0
- package/dist/cjs/analytics/index.js +2 -2
- package/dist/cjs/channel.js +2 -2
- package/dist/cjs/provider/index.js +76 -70
- package/dist/cjs/socket-io-provider.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/provider/index.js +38 -30
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +2 -2
- package/dist/esm/channel.js +2 -2
- package/dist/esm/provider/index.js +77 -70
- package/dist/esm/socket-io-provider.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/provider/index.d.ts +2 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 7.1.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - ED-13912 refactor editor collab-provider and make sure that initializeChannel is only called once
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
3
10
|
## 7.1.3
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
|
@@ -11,9 +11,9 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _const = require("../helpers/const");
|
|
13
13
|
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
15
|
|
|
16
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
16
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
17
|
|
|
18
18
|
var buildAnalyticsPayload = function buildAnalyticsPayload(subject, payload) {
|
|
19
19
|
return {
|
package/dist/cjs/channel.js
CHANGED
|
@@ -37,9 +37,9 @@ var _performance = require("./analytics/performance");
|
|
|
37
37
|
|
|
38
38
|
var _analytics = require("./analytics");
|
|
39
39
|
|
|
40
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
40
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
41
41
|
|
|
42
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
42
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
43
43
|
|
|
44
44
|
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); }; }
|
|
45
45
|
|
|
@@ -55,13 +55,15 @@ var _errorCodeMapper = require("../error-code-mapper");
|
|
|
55
55
|
|
|
56
56
|
var _disconnectedReasonMapper = require("../disconnected-reason-mapper");
|
|
57
57
|
|
|
58
|
+
var _excluded = ["type"];
|
|
59
|
+
|
|
58
60
|
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); }; }
|
|
59
61
|
|
|
60
62
|
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; } }
|
|
61
63
|
|
|
62
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
64
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
63
65
|
|
|
64
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
66
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
65
67
|
|
|
66
68
|
var logger = (0, _utils.createLogger)('Provider', 'black');
|
|
67
69
|
var PARTICIPANT_UPDATE_INTERVAL = 300 * 1000; // 300 seconds
|
|
@@ -115,6 +117,37 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
115
117
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "participants", new Map());
|
|
116
118
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "metadata", {});
|
|
117
119
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "stepRejectCounter", 0);
|
|
120
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isChannelInitialized", false);
|
|
121
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "initializeChannel", function () {
|
|
122
|
+
_this.channel.on('connected', function (_ref2) {
|
|
123
|
+
var sid = _ref2.sid,
|
|
124
|
+
initialized = _ref2.initialized;
|
|
125
|
+
_this.sessionId = sid;
|
|
126
|
+
|
|
127
|
+
_this.emit('connected', {
|
|
128
|
+
sid: sid
|
|
129
|
+
}); // If already initialized, `connected` means reconnected
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
if (initialized && _this.disconnectedAt && // Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
133
|
+
Date.now() - _this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
134
|
+
_this.throttledCatchup();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
_this.disconnectedAt = undefined;
|
|
138
|
+
}).on('init', function (_ref3) {
|
|
139
|
+
var doc = _ref3.doc,
|
|
140
|
+
version = _ref3.version,
|
|
141
|
+
metadata = _ref3.metadata;
|
|
142
|
+
|
|
143
|
+
// Initial document and version
|
|
144
|
+
_this.updateDocumentWithMetadata({
|
|
145
|
+
doc: doc,
|
|
146
|
+
version: version,
|
|
147
|
+
metadata: metadata
|
|
148
|
+
});
|
|
149
|
+
}).on('steps:added', _this.onStepsAdded).on('participant:telepointer', _this.onParticipantTelepointer).on('presence:joined', _this.onPresenceJoined).on('presence', _this.onPresence).on('participant:left', _this.onParticipantLeft).on('participant:updated', _this.onParticipantUpdated).on('metadata:changed', _this.onMetadataChanged).on('disconnect', _this.onDisconnected).on('error', _this.onErrorHandled).connect();
|
|
150
|
+
});
|
|
118
151
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onStepsAdded", function (data) {
|
|
119
152
|
logger("Received steps", {
|
|
120
153
|
steps: data.steps,
|
|
@@ -142,8 +175,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
142
175
|
_this.throttledCatchup();
|
|
143
176
|
}
|
|
144
177
|
|
|
145
|
-
_this.updateParticipants([], data.steps.map(function (
|
|
146
|
-
var userId =
|
|
178
|
+
_this.updateParticipants([], data.steps.map(function (_ref4) {
|
|
179
|
+
var userId = _ref4.userId;
|
|
147
180
|
return userId;
|
|
148
181
|
}));
|
|
149
182
|
});
|
|
@@ -156,11 +189,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
156
189
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "fitlerQueue", function (condition) {
|
|
157
190
|
_this.queue = _this.queue.filter(condition);
|
|
158
191
|
});
|
|
159
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDocumentWithMetadata", function (
|
|
160
|
-
var doc =
|
|
161
|
-
version =
|
|
162
|
-
metadata =
|
|
163
|
-
reserveCursor =
|
|
192
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateDocumentWithMetadata", function (_ref5) {
|
|
193
|
+
var doc = _ref5.doc,
|
|
194
|
+
version = _ref5.version,
|
|
195
|
+
metadata = _ref5.metadata,
|
|
196
|
+
reserveCursor = _ref5.reserveCursor;
|
|
164
197
|
|
|
165
198
|
_this.emit('init', _objectSpread({
|
|
166
199
|
doc: doc,
|
|
@@ -282,14 +315,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
282
315
|
return _this.sendPresence();
|
|
283
316
|
}, SEND_PRESENCE_INTERVAL);
|
|
284
317
|
});
|
|
285
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresenceJoined", function (
|
|
286
|
-
var sessionId =
|
|
318
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresenceJoined", function (_ref7) {
|
|
319
|
+
var sessionId = _ref7.sessionId;
|
|
287
320
|
logger('Participant joined with session: ', sessionId); // This expose existing users to the newly joined user
|
|
288
321
|
|
|
289
322
|
_this.sendPresence();
|
|
290
323
|
});
|
|
291
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresence", function (
|
|
292
|
-
var userId =
|
|
324
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onPresence", function (_ref8) {
|
|
325
|
+
var userId = _ref8.userId;
|
|
293
326
|
logger('onPresence userId: ', userId);
|
|
294
327
|
_this.userId = userId;
|
|
295
328
|
|
|
@@ -302,8 +335,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
302
335
|
_this.emit('metadata:changed', metadata);
|
|
303
336
|
}
|
|
304
337
|
});
|
|
305
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantLeft", function (
|
|
306
|
-
var sessionId =
|
|
338
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantLeft", function (_ref9) {
|
|
339
|
+
var sessionId = _ref9.sessionId;
|
|
307
340
|
logger("Participant left");
|
|
308
341
|
|
|
309
342
|
_this.participants.delete(sessionId);
|
|
@@ -314,11 +347,11 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
314
347
|
}]
|
|
315
348
|
});
|
|
316
349
|
});
|
|
317
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantUpdated", function (
|
|
318
|
-
var sessionId =
|
|
319
|
-
timestamp =
|
|
320
|
-
userId =
|
|
321
|
-
clientId =
|
|
350
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantUpdated", function (_ref10) {
|
|
351
|
+
var sessionId = _ref10.sessionId,
|
|
352
|
+
timestamp = _ref10.timestamp,
|
|
353
|
+
userId = _ref10.userId,
|
|
354
|
+
clientId = _ref10.clientId;
|
|
322
355
|
|
|
323
356
|
_this.updateParticipant({
|
|
324
357
|
sessionId: sessionId,
|
|
@@ -327,12 +360,12 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
327
360
|
clientId: clientId
|
|
328
361
|
});
|
|
329
362
|
});
|
|
330
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantTelepointer", function (
|
|
331
|
-
var sessionId =
|
|
332
|
-
timestamp =
|
|
333
|
-
selection =
|
|
334
|
-
userId =
|
|
335
|
-
clientId =
|
|
363
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onParticipantTelepointer", function (_ref11) {
|
|
364
|
+
var sessionId = _ref11.sessionId,
|
|
365
|
+
timestamp = _ref11.timestamp,
|
|
366
|
+
selection = _ref11.selection,
|
|
367
|
+
userId = _ref11.userId,
|
|
368
|
+
clientId = _ref11.clientId;
|
|
336
369
|
|
|
337
370
|
if (sessionId === _this.sessionId) {
|
|
338
371
|
return;
|
|
@@ -360,14 +393,14 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
360
393
|
});
|
|
361
394
|
});
|
|
362
395
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateParticipant", /*#__PURE__*/function () {
|
|
363
|
-
var
|
|
396
|
+
var _ref13 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(_ref12) {
|
|
364
397
|
var sessionId, timestamp, userId, clientId, getUser, _yield, _yield$name, name, _yield$email, email, _yield$avatar, avatar, isNewParticipant;
|
|
365
398
|
|
|
366
399
|
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
367
400
|
while (1) {
|
|
368
401
|
switch (_context2.prev = _context2.next) {
|
|
369
402
|
case 0:
|
|
370
|
-
sessionId =
|
|
403
|
+
sessionId = _ref12.sessionId, timestamp = _ref12.timestamp, userId = _ref12.userId, clientId = _ref12.clientId;
|
|
371
404
|
|
|
372
405
|
if (userId) {
|
|
373
406
|
_context2.next = 3;
|
|
@@ -420,7 +453,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
420
453
|
}));
|
|
421
454
|
|
|
422
455
|
return function (_x) {
|
|
423
|
-
return
|
|
456
|
+
return _ref13.apply(this, arguments);
|
|
424
457
|
};
|
|
425
458
|
}());
|
|
426
459
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateParticipants", function () {
|
|
@@ -480,8 +513,8 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
480
513
|
return _disconnectedReasonMapper.DisconnectReason.UNKNOWN_DISCONNECT;
|
|
481
514
|
}
|
|
482
515
|
});
|
|
483
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (
|
|
484
|
-
var reason =
|
|
516
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onDisconnected", function (_ref14) {
|
|
517
|
+
var reason = _ref14.reason;
|
|
485
518
|
_this.disconnectedAt = Date.now();
|
|
486
519
|
var left = Array.from(_this.participants.values());
|
|
487
520
|
|
|
@@ -500,6 +533,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
500
533
|
});
|
|
501
534
|
_this.config = config;
|
|
502
535
|
_this.channel = new _channel.Channel(config);
|
|
536
|
+
_this.isChannelInitialized = false;
|
|
503
537
|
|
|
504
538
|
if (config.analyticsClient) {
|
|
505
539
|
_this.analyticsClient = config.analyticsClient;
|
|
@@ -507,50 +541,22 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
507
541
|
|
|
508
542
|
return _this;
|
|
509
543
|
}
|
|
510
|
-
/**
|
|
511
|
-
* Called by collab plugin in editor when it's ready to
|
|
512
|
-
* initialize a collab session.
|
|
513
|
-
*/
|
|
514
|
-
|
|
515
544
|
|
|
516
545
|
(0, _createClass2.default)(Provider, [{
|
|
517
546
|
key: "initialize",
|
|
518
547
|
value: function initialize(optionsOrGetState) {
|
|
519
|
-
|
|
520
|
-
|
|
548
|
+
// move this
|
|
521
549
|
this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
|
|
522
550
|
this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
|
|
523
551
|
this.getState().plugins.find(function (p) {
|
|
524
552
|
return p.key === 'collab$';
|
|
525
553
|
}).spec.config.clientID : optionsOrGetState.clientId;
|
|
526
|
-
this.channel.on('connected', function (_ref13) {
|
|
527
|
-
var sid = _ref13.sid,
|
|
528
|
-
initialized = _ref13.initialized;
|
|
529
|
-
_this2.sessionId = sid;
|
|
530
|
-
|
|
531
|
-
_this2.emit('connected', {
|
|
532
|
-
sid: sid
|
|
533
|
-
}); // If already initialized, `connected` means reconnected
|
|
534
554
|
|
|
555
|
+
if (!this.isChannelInitialized) {
|
|
556
|
+
this.initializeChannel();
|
|
557
|
+
this.isChannelInitialized = true;
|
|
558
|
+
}
|
|
535
559
|
|
|
536
|
-
if (initialized && _this2.disconnectedAt && // Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
537
|
-
Date.now() - _this2.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
538
|
-
_this2.throttledCatchup();
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
_this2.disconnectedAt = undefined;
|
|
542
|
-
}).on('init', function (_ref14) {
|
|
543
|
-
var doc = _ref14.doc,
|
|
544
|
-
version = _ref14.version,
|
|
545
|
-
metadata = _ref14.metadata;
|
|
546
|
-
|
|
547
|
-
// Initial document and version
|
|
548
|
-
_this2.updateDocumentWithMetadata({
|
|
549
|
-
doc: doc,
|
|
550
|
-
version: version,
|
|
551
|
-
metadata: metadata
|
|
552
|
-
});
|
|
553
|
-
}).on('steps:added', this.onStepsAdded).on('participant:telepointer', this.onParticipantTelepointer).on('presence:joined', this.onPresenceJoined).on('presence', this.onPresence).on('participant:left', this.onParticipantLeft).on('participant:updated', this.onParticipantUpdated).on('metadata:changed', this.onMetadataChanged).on('disconnect', this.onDisconnected).on('error', this.onErrorHandled).connect();
|
|
554
560
|
return this;
|
|
555
561
|
}
|
|
556
562
|
/**
|
|
@@ -642,7 +648,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
642
648
|
}, {
|
|
643
649
|
key: "processSteps",
|
|
644
650
|
value: function processSteps(data) {
|
|
645
|
-
var
|
|
651
|
+
var _this2 = this;
|
|
646
652
|
|
|
647
653
|
var version = data.version,
|
|
648
654
|
steps = data.steps;
|
|
@@ -665,7 +671,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
665
671
|
|
|
666
672
|
if (clientIds.indexOf(this.clientId) === -1) {
|
|
667
673
|
setTimeout(function () {
|
|
668
|
-
return
|
|
674
|
+
return _this2.sendStepsFromCurrentState();
|
|
669
675
|
}, 100);
|
|
670
676
|
}
|
|
671
677
|
}
|
|
@@ -682,7 +688,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
682
688
|
}
|
|
683
689
|
|
|
684
690
|
var type = data.type,
|
|
685
|
-
rest = (0, _objectWithoutProperties2.default)(data,
|
|
691
|
+
rest = (0, _objectWithoutProperties2.default)(data, _excluded);
|
|
686
692
|
var userId = this.userId,
|
|
687
693
|
sessionId = this.sessionId,
|
|
688
694
|
clientId = this.clientId;
|
|
@@ -702,10 +708,10 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
702
708
|
}, {
|
|
703
709
|
key: "emitTelepointersFromSteps",
|
|
704
710
|
value: function emitTelepointersFromSteps(steps) {
|
|
705
|
-
var
|
|
711
|
+
var _this3 = this;
|
|
706
712
|
|
|
707
713
|
steps.forEach(function (step) {
|
|
708
|
-
var _Array$from$filter = Array.from(
|
|
714
|
+
var _Array$from$filter = Array.from(_this3.participants.values()).filter(function (p) {
|
|
709
715
|
return p.clientId === step.clientId;
|
|
710
716
|
}),
|
|
711
717
|
_Array$from$filter2 = (0, _slicedToArray2.default)(_Array$from$filter, 1),
|
|
@@ -725,7 +731,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
725
731
|
node = _slice$content[0];
|
|
726
732
|
|
|
727
733
|
if (stepType === 'replace' && to === from && slice.content.length === 1 && node.type === 'text' && node.text.length === 1) {
|
|
728
|
-
|
|
734
|
+
_this3.emit('telepointer', {
|
|
729
735
|
sessionId: participant.sessionId,
|
|
730
736
|
selection: {
|
|
731
737
|
type: 'textSelection',
|
|
@@ -16,9 +16,9 @@ var _socket = require("socket.io-client");
|
|
|
16
16
|
|
|
17
17
|
var _urlParse2 = _interopRequireDefault(require("url-parse"));
|
|
18
18
|
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
20
|
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
22
|
|
|
23
23
|
function createSocketIOSocket(url, auth) {
|
|
24
24
|
var _urlParse = (0, _urlParse2.default)(url),
|
package/dist/cjs/version.json
CHANGED
|
@@ -55,6 +55,38 @@ export class Provider extends Emitter {
|
|
|
55
55
|
|
|
56
56
|
_defineProperty(this, "stepRejectCounter", 0);
|
|
57
57
|
|
|
58
|
+
_defineProperty(this, "isChannelInitialized", false);
|
|
59
|
+
|
|
60
|
+
_defineProperty(this, "initializeChannel", () => {
|
|
61
|
+
this.channel.on('connected', ({
|
|
62
|
+
sid,
|
|
63
|
+
initialized
|
|
64
|
+
}) => {
|
|
65
|
+
this.sessionId = sid;
|
|
66
|
+
this.emit('connected', {
|
|
67
|
+
sid
|
|
68
|
+
}); // If already initialized, `connected` means reconnected
|
|
69
|
+
|
|
70
|
+
if (initialized && this.disconnectedAt && // Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
71
|
+
Date.now() - this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
72
|
+
this.throttledCatchup();
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
this.disconnectedAt = undefined;
|
|
76
|
+
}).on('init', ({
|
|
77
|
+
doc,
|
|
78
|
+
version,
|
|
79
|
+
metadata
|
|
80
|
+
}) => {
|
|
81
|
+
// Initial document and version
|
|
82
|
+
this.updateDocumentWithMetadata({
|
|
83
|
+
doc,
|
|
84
|
+
version,
|
|
85
|
+
metadata
|
|
86
|
+
});
|
|
87
|
+
}).on('steps:added', this.onStepsAdded).on('participant:telepointer', this.onParticipantTelepointer).on('presence:joined', this.onPresenceJoined).on('presence', this.onPresence).on('participant:left', this.onParticipantLeft).on('participant:updated', this.onParticipantUpdated).on('metadata:changed', this.onMetadataChanged).on('disconnect', this.onDisconnected).on('error', this.onErrorHandled).connect();
|
|
88
|
+
});
|
|
89
|
+
|
|
58
90
|
_defineProperty(this, "onStepsAdded", data => {
|
|
59
91
|
logger(`Received steps`, {
|
|
60
92
|
steps: data.steps,
|
|
@@ -390,48 +422,24 @@ export class Provider extends Emitter {
|
|
|
390
422
|
|
|
391
423
|
this.config = config;
|
|
392
424
|
this.channel = new Channel(config);
|
|
425
|
+
this.isChannelInitialized = false;
|
|
393
426
|
|
|
394
427
|
if (config.analyticsClient) {
|
|
395
428
|
this.analyticsClient = config.analyticsClient;
|
|
396
429
|
}
|
|
397
430
|
}
|
|
398
|
-
/**
|
|
399
|
-
* Called by collab plugin in editor when it's ready to
|
|
400
|
-
* initialize a collab session.
|
|
401
|
-
*/
|
|
402
|
-
|
|
403
431
|
|
|
404
432
|
initialize(optionsOrGetState) {
|
|
433
|
+
// move this
|
|
405
434
|
this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
|
|
406
435
|
this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
|
|
407
436
|
this.getState().plugins.find(p => p.key === 'collab$').spec.config.clientID : optionsOrGetState.clientId;
|
|
408
|
-
this.channel.on('connected', ({
|
|
409
|
-
sid,
|
|
410
|
-
initialized
|
|
411
|
-
}) => {
|
|
412
|
-
this.sessionId = sid;
|
|
413
|
-
this.emit('connected', {
|
|
414
|
-
sid
|
|
415
|
-
}); // If already initialized, `connected` means reconnected
|
|
416
437
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
438
|
+
if (!this.isChannelInitialized) {
|
|
439
|
+
this.initializeChannel();
|
|
440
|
+
this.isChannelInitialized = true;
|
|
441
|
+
}
|
|
421
442
|
|
|
422
|
-
this.disconnectedAt = undefined;
|
|
423
|
-
}).on('init', ({
|
|
424
|
-
doc,
|
|
425
|
-
version,
|
|
426
|
-
metadata
|
|
427
|
-
}) => {
|
|
428
|
-
// Initial document and version
|
|
429
|
-
this.updateDocumentWithMetadata({
|
|
430
|
-
doc,
|
|
431
|
-
version,
|
|
432
|
-
metadata
|
|
433
|
-
});
|
|
434
|
-
}).on('steps:added', this.onStepsAdded).on('participant:telepointer', this.onParticipantTelepointer).on('presence:joined', this.onPresenceJoined).on('presence', this.onPresence).on('participant:left', this.onParticipantLeft).on('participant:updated', this.onParticipantUpdated).on('metadata:changed', this.onMetadataChanged).on('disconnect', this.onDisconnected).on('error', this.onErrorHandled).connect();
|
|
435
443
|
return this;
|
|
436
444
|
}
|
|
437
445
|
/**
|
package/dist/es2019/version.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { ATTRIBUTES_PACKAGE, CATCHUP_FAILURE, CATCHUP_SUCCESS, STEPS_ADDED, STEPS_REJECTED } from '../helpers/const';
|
|
8
8
|
export var buildAnalyticsPayload = function buildAnalyticsPayload(subject, payload) {
|
package/dist/esm/channel.js
CHANGED
|
@@ -8,9 +8,9 @@ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstruct
|
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
10
|
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
12
|
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
14
|
|
|
15
15
|
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); }; }
|
|
16
16
|
|
|
@@ -11,14 +11,15 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
11
11
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
12
12
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
13
13
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
14
|
+
var _excluded = ["type"];
|
|
14
15
|
|
|
15
16
|
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); }; }
|
|
16
17
|
|
|
17
18
|
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; } }
|
|
18
19
|
|
|
19
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
20
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
21
|
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
22
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
23
|
|
|
23
24
|
import { getVersion, sendableSteps } from 'prosemirror-collab';
|
|
24
25
|
import throttle from 'lodash/throttle';
|
|
@@ -85,6 +86,39 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
85
86
|
|
|
86
87
|
_defineProperty(_assertThisInitialized(_this), "stepRejectCounter", 0);
|
|
87
88
|
|
|
89
|
+
_defineProperty(_assertThisInitialized(_this), "isChannelInitialized", false);
|
|
90
|
+
|
|
91
|
+
_defineProperty(_assertThisInitialized(_this), "initializeChannel", function () {
|
|
92
|
+
_this.channel.on('connected', function (_ref2) {
|
|
93
|
+
var sid = _ref2.sid,
|
|
94
|
+
initialized = _ref2.initialized;
|
|
95
|
+
_this.sessionId = sid;
|
|
96
|
+
|
|
97
|
+
_this.emit('connected', {
|
|
98
|
+
sid: sid
|
|
99
|
+
}); // If already initialized, `connected` means reconnected
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
if (initialized && _this.disconnectedAt && // Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
103
|
+
Date.now() - _this.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
104
|
+
_this.throttledCatchup();
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_this.disconnectedAt = undefined;
|
|
108
|
+
}).on('init', function (_ref3) {
|
|
109
|
+
var doc = _ref3.doc,
|
|
110
|
+
version = _ref3.version,
|
|
111
|
+
metadata = _ref3.metadata;
|
|
112
|
+
|
|
113
|
+
// Initial document and version
|
|
114
|
+
_this.updateDocumentWithMetadata({
|
|
115
|
+
doc: doc,
|
|
116
|
+
version: version,
|
|
117
|
+
metadata: metadata
|
|
118
|
+
});
|
|
119
|
+
}).on('steps:added', _this.onStepsAdded).on('participant:telepointer', _this.onParticipantTelepointer).on('presence:joined', _this.onPresenceJoined).on('presence', _this.onPresence).on('participant:left', _this.onParticipantLeft).on('participant:updated', _this.onParticipantUpdated).on('metadata:changed', _this.onMetadataChanged).on('disconnect', _this.onDisconnected).on('error', _this.onErrorHandled).connect();
|
|
120
|
+
});
|
|
121
|
+
|
|
88
122
|
_defineProperty(_assertThisInitialized(_this), "onStepsAdded", function (data) {
|
|
89
123
|
logger("Received steps", {
|
|
90
124
|
steps: data.steps,
|
|
@@ -112,8 +146,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
112
146
|
_this.throttledCatchup();
|
|
113
147
|
}
|
|
114
148
|
|
|
115
|
-
_this.updateParticipants([], data.steps.map(function (
|
|
116
|
-
var userId =
|
|
149
|
+
_this.updateParticipants([], data.steps.map(function (_ref4) {
|
|
150
|
+
var userId = _ref4.userId;
|
|
117
151
|
return userId;
|
|
118
152
|
}));
|
|
119
153
|
});
|
|
@@ -129,11 +163,11 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
129
163
|
_this.queue = _this.queue.filter(condition);
|
|
130
164
|
});
|
|
131
165
|
|
|
132
|
-
_defineProperty(_assertThisInitialized(_this), "updateDocumentWithMetadata", function (
|
|
133
|
-
var doc =
|
|
134
|
-
version =
|
|
135
|
-
metadata =
|
|
136
|
-
reserveCursor =
|
|
166
|
+
_defineProperty(_assertThisInitialized(_this), "updateDocumentWithMetadata", function (_ref5) {
|
|
167
|
+
var doc = _ref5.doc,
|
|
168
|
+
version = _ref5.version,
|
|
169
|
+
metadata = _ref5.metadata,
|
|
170
|
+
reserveCursor = _ref5.reserveCursor;
|
|
137
171
|
|
|
138
172
|
_this.emit('init', _objectSpread({
|
|
139
173
|
doc: doc,
|
|
@@ -263,15 +297,15 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
263
297
|
}, SEND_PRESENCE_INTERVAL);
|
|
264
298
|
});
|
|
265
299
|
|
|
266
|
-
_defineProperty(_assertThisInitialized(_this), "onPresenceJoined", function (
|
|
267
|
-
var sessionId =
|
|
300
|
+
_defineProperty(_assertThisInitialized(_this), "onPresenceJoined", function (_ref7) {
|
|
301
|
+
var sessionId = _ref7.sessionId;
|
|
268
302
|
logger('Participant joined with session: ', sessionId); // This expose existing users to the newly joined user
|
|
269
303
|
|
|
270
304
|
_this.sendPresence();
|
|
271
305
|
});
|
|
272
306
|
|
|
273
|
-
_defineProperty(_assertThisInitialized(_this), "onPresence", function (
|
|
274
|
-
var userId =
|
|
307
|
+
_defineProperty(_assertThisInitialized(_this), "onPresence", function (_ref8) {
|
|
308
|
+
var userId = _ref8.userId;
|
|
275
309
|
logger('onPresence userId: ', userId);
|
|
276
310
|
_this.userId = userId;
|
|
277
311
|
|
|
@@ -286,8 +320,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
286
320
|
}
|
|
287
321
|
});
|
|
288
322
|
|
|
289
|
-
_defineProperty(_assertThisInitialized(_this), "onParticipantLeft", function (
|
|
290
|
-
var sessionId =
|
|
323
|
+
_defineProperty(_assertThisInitialized(_this), "onParticipantLeft", function (_ref9) {
|
|
324
|
+
var sessionId = _ref9.sessionId;
|
|
291
325
|
logger("Participant left");
|
|
292
326
|
|
|
293
327
|
_this.participants.delete(sessionId);
|
|
@@ -299,11 +333,11 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
299
333
|
});
|
|
300
334
|
});
|
|
301
335
|
|
|
302
|
-
_defineProperty(_assertThisInitialized(_this), "onParticipantUpdated", function (
|
|
303
|
-
var sessionId =
|
|
304
|
-
timestamp =
|
|
305
|
-
userId =
|
|
306
|
-
clientId =
|
|
336
|
+
_defineProperty(_assertThisInitialized(_this), "onParticipantUpdated", function (_ref10) {
|
|
337
|
+
var sessionId = _ref10.sessionId,
|
|
338
|
+
timestamp = _ref10.timestamp,
|
|
339
|
+
userId = _ref10.userId,
|
|
340
|
+
clientId = _ref10.clientId;
|
|
307
341
|
|
|
308
342
|
_this.updateParticipant({
|
|
309
343
|
sessionId: sessionId,
|
|
@@ -313,12 +347,12 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
313
347
|
});
|
|
314
348
|
});
|
|
315
349
|
|
|
316
|
-
_defineProperty(_assertThisInitialized(_this), "onParticipantTelepointer", function (
|
|
317
|
-
var sessionId =
|
|
318
|
-
timestamp =
|
|
319
|
-
selection =
|
|
320
|
-
userId =
|
|
321
|
-
clientId =
|
|
350
|
+
_defineProperty(_assertThisInitialized(_this), "onParticipantTelepointer", function (_ref11) {
|
|
351
|
+
var sessionId = _ref11.sessionId,
|
|
352
|
+
timestamp = _ref11.timestamp,
|
|
353
|
+
selection = _ref11.selection,
|
|
354
|
+
userId = _ref11.userId,
|
|
355
|
+
clientId = _ref11.clientId;
|
|
322
356
|
|
|
323
357
|
if (sessionId === _this.sessionId) {
|
|
324
358
|
return;
|
|
@@ -347,14 +381,14 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
347
381
|
});
|
|
348
382
|
|
|
349
383
|
_defineProperty(_assertThisInitialized(_this), "updateParticipant", /*#__PURE__*/function () {
|
|
350
|
-
var
|
|
384
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref12) {
|
|
351
385
|
var sessionId, timestamp, userId, clientId, getUser, _yield, _yield$name, name, _yield$email, email, _yield$avatar, avatar, isNewParticipant;
|
|
352
386
|
|
|
353
387
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
354
388
|
while (1) {
|
|
355
389
|
switch (_context2.prev = _context2.next) {
|
|
356
390
|
case 0:
|
|
357
|
-
sessionId =
|
|
391
|
+
sessionId = _ref12.sessionId, timestamp = _ref12.timestamp, userId = _ref12.userId, clientId = _ref12.clientId;
|
|
358
392
|
|
|
359
393
|
if (userId) {
|
|
360
394
|
_context2.next = 3;
|
|
@@ -407,7 +441,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
407
441
|
}));
|
|
408
442
|
|
|
409
443
|
return function (_x) {
|
|
410
|
-
return
|
|
444
|
+
return _ref13.apply(this, arguments);
|
|
411
445
|
};
|
|
412
446
|
}());
|
|
413
447
|
|
|
@@ -470,8 +504,8 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
470
504
|
}
|
|
471
505
|
});
|
|
472
506
|
|
|
473
|
-
_defineProperty(_assertThisInitialized(_this), "onDisconnected", function (
|
|
474
|
-
var reason =
|
|
507
|
+
_defineProperty(_assertThisInitialized(_this), "onDisconnected", function (_ref14) {
|
|
508
|
+
var reason = _ref14.reason;
|
|
475
509
|
_this.disconnectedAt = Date.now();
|
|
476
510
|
var left = Array.from(_this.participants.values());
|
|
477
511
|
|
|
@@ -491,6 +525,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
491
525
|
|
|
492
526
|
_this.config = config;
|
|
493
527
|
_this.channel = new Channel(config);
|
|
528
|
+
_this.isChannelInitialized = false;
|
|
494
529
|
|
|
495
530
|
if (config.analyticsClient) {
|
|
496
531
|
_this.analyticsClient = config.analyticsClient;
|
|
@@ -498,50 +533,22 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
498
533
|
|
|
499
534
|
return _this;
|
|
500
535
|
}
|
|
501
|
-
/**
|
|
502
|
-
* Called by collab plugin in editor when it's ready to
|
|
503
|
-
* initialize a collab session.
|
|
504
|
-
*/
|
|
505
|
-
|
|
506
536
|
|
|
507
537
|
_createClass(Provider, [{
|
|
508
538
|
key: "initialize",
|
|
509
539
|
value: function initialize(optionsOrGetState) {
|
|
510
|
-
|
|
511
|
-
|
|
540
|
+
// move this
|
|
512
541
|
this.getState = typeof optionsOrGetState === 'function' ? optionsOrGetState : optionsOrGetState.getState;
|
|
513
542
|
this.clientId = typeof optionsOrGetState === 'function' ? // Quick-hack to get clientID from native collab-plugin.
|
|
514
543
|
this.getState().plugins.find(function (p) {
|
|
515
544
|
return p.key === 'collab$';
|
|
516
545
|
}).spec.config.clientID : optionsOrGetState.clientId;
|
|
517
|
-
this.channel.on('connected', function (_ref13) {
|
|
518
|
-
var sid = _ref13.sid,
|
|
519
|
-
initialized = _ref13.initialized;
|
|
520
|
-
_this2.sessionId = sid;
|
|
521
|
-
|
|
522
|
-
_this2.emit('connected', {
|
|
523
|
-
sid: sid
|
|
524
|
-
}); // If already initialized, `connected` means reconnected
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
if (initialized && _this2.disconnectedAt && // Offline longer than `OUT_OF_SYNC_PERIOD`
|
|
528
|
-
Date.now() - _this2.disconnectedAt >= OUT_OF_SYNC_PERIOD) {
|
|
529
|
-
_this2.throttledCatchup();
|
|
530
|
-
}
|
|
531
546
|
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
metadata = _ref14.metadata;
|
|
547
|
+
if (!this.isChannelInitialized) {
|
|
548
|
+
this.initializeChannel();
|
|
549
|
+
this.isChannelInitialized = true;
|
|
550
|
+
}
|
|
537
551
|
|
|
538
|
-
// Initial document and version
|
|
539
|
-
_this2.updateDocumentWithMetadata({
|
|
540
|
-
doc: doc,
|
|
541
|
-
version: version,
|
|
542
|
-
metadata: metadata
|
|
543
|
-
});
|
|
544
|
-
}).on('steps:added', this.onStepsAdded).on('participant:telepointer', this.onParticipantTelepointer).on('presence:joined', this.onPresenceJoined).on('presence', this.onPresence).on('participant:left', this.onParticipantLeft).on('participant:updated', this.onParticipantUpdated).on('metadata:changed', this.onMetadataChanged).on('disconnect', this.onDisconnected).on('error', this.onErrorHandled).connect();
|
|
545
552
|
return this;
|
|
546
553
|
}
|
|
547
554
|
/**
|
|
@@ -633,7 +640,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
633
640
|
}, {
|
|
634
641
|
key: "processSteps",
|
|
635
642
|
value: function processSteps(data) {
|
|
636
|
-
var
|
|
643
|
+
var _this2 = this;
|
|
637
644
|
|
|
638
645
|
var version = data.version,
|
|
639
646
|
steps = data.steps;
|
|
@@ -656,7 +663,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
656
663
|
|
|
657
664
|
if (clientIds.indexOf(this.clientId) === -1) {
|
|
658
665
|
setTimeout(function () {
|
|
659
|
-
return
|
|
666
|
+
return _this2.sendStepsFromCurrentState();
|
|
660
667
|
}, 100);
|
|
661
668
|
}
|
|
662
669
|
}
|
|
@@ -673,7 +680,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
673
680
|
}
|
|
674
681
|
|
|
675
682
|
var type = data.type,
|
|
676
|
-
rest = _objectWithoutProperties(data,
|
|
683
|
+
rest = _objectWithoutProperties(data, _excluded);
|
|
677
684
|
|
|
678
685
|
var userId = this.userId,
|
|
679
686
|
sessionId = this.sessionId,
|
|
@@ -694,10 +701,10 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
694
701
|
}, {
|
|
695
702
|
key: "emitTelepointersFromSteps",
|
|
696
703
|
value: function emitTelepointersFromSteps(steps) {
|
|
697
|
-
var
|
|
704
|
+
var _this3 = this;
|
|
698
705
|
|
|
699
706
|
steps.forEach(function (step) {
|
|
700
|
-
var _Array$from$filter = Array.from(
|
|
707
|
+
var _Array$from$filter = Array.from(_this3.participants.values()).filter(function (p) {
|
|
701
708
|
return p.clientId === step.clientId;
|
|
702
709
|
}),
|
|
703
710
|
_Array$from$filter2 = _slicedToArray(_Array$from$filter, 1),
|
|
@@ -717,7 +724,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
717
724
|
node = _slice$content[0];
|
|
718
725
|
|
|
719
726
|
if (stepType === 'replace' && to === from && slice.content.length === 1 && node.type === 'text' && node.text.length === 1) {
|
|
720
|
-
|
|
727
|
+
_this3.emit('telepointer', {
|
|
721
728
|
sessionId: participant.sessionId,
|
|
722
729
|
selection: {
|
|
723
730
|
type: 'textSelection',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
|
|
3
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object);
|
|
3
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
4
4
|
|
|
5
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]
|
|
5
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { Provider } from './provider';
|
|
8
8
|
import { io } from 'socket.io-client';
|
package/dist/esm/version.json
CHANGED
|
@@ -60,6 +60,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
60
60
|
private metadata;
|
|
61
61
|
private stepRejectCounter;
|
|
62
62
|
private analyticsClient?;
|
|
63
|
+
private isChannelInitialized;
|
|
63
64
|
private sessionId?;
|
|
64
65
|
private clientId?;
|
|
65
66
|
private userId?;
|
|
@@ -67,6 +68,7 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
67
68
|
private presenceUpdateTimeout?;
|
|
68
69
|
private disconnectedAt?;
|
|
69
70
|
constructor(config: Config);
|
|
71
|
+
private initializeChannel;
|
|
70
72
|
/**
|
|
71
73
|
* Called by collab plugin in editor when it's ready to
|
|
72
74
|
* initialize a collab session.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "7.1.
|
|
3
|
+
"version": "7.1.4",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@atlaskit/analytics-gas-types": "5.0.5",
|
|
25
25
|
"@atlaskit/analytics-listeners": "^8.0.0",
|
|
26
|
-
"@atlaskit/editor-common": "^
|
|
27
|
-
"@atlaskit/util-service-support": "^6.
|
|
26
|
+
"@atlaskit/editor-common": "^63.0.0",
|
|
27
|
+
"@atlaskit/util-service-support": "^6.1.0",
|
|
28
28
|
"@babel/runtime": "^7.0.0",
|
|
29
29
|
"eventemitter2": "^4.1.0",
|
|
30
30
|
"lodash": "^4.17.21",
|