@atlaskit/collab-provider 8.9.1 → 9.0.1
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 +13 -0
- package/dist/cjs/channel.js +6 -8
- package/dist/cjs/document/catchup.js +8 -1
- package/dist/cjs/document/document-service.js +3 -2
- package/dist/cjs/helpers/const.js +2 -1
- package/dist/cjs/participants/participants-service.js +11 -5
- package/dist/cjs/provider/index.js +20 -7
- package/dist/cjs/types.js +2 -3
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/channel.js +6 -6
- package/dist/es2019/document/catchup.js +8 -0
- package/dist/es2019/document/document-service.js +3 -2
- package/dist/es2019/helpers/const.js +2 -1
- package/dist/es2019/participants/participants-service.js +10 -6
- package/dist/es2019/provider/index.js +13 -3
- package/dist/es2019/types.js +4 -4
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/channel.js +6 -8
- package/dist/esm/document/catchup.js +8 -1
- package/dist/esm/document/document-service.js +3 -2
- package/dist/esm/helpers/const.js +2 -1
- package/dist/esm/participants/participants-service.js +11 -5
- package/dist/esm/provider/index.js +20 -7
- package/dist/esm/types.js +4 -4
- 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/document/document-service.d.ts +2 -3
- package/dist/types/helpers/const.d.ts +11 -3
- package/dist/types/index.d.ts +1 -1
- package/dist/types/participants/participants-helper.d.ts +4 -3
- package/dist/types/participants/participants-service.d.ts +4 -3
- package/dist/types/participants/telepointers-helper.d.ts +2 -2
- package/dist/types/provider/index.d.ts +6 -5
- package/dist/types/types.d.ts +58 -8
- package/dist/types-ts4.5/channel.d.ts +1 -1
- package/dist/types-ts4.5/document/document-service.d.ts +2 -3
- package/dist/types-ts4.5/helpers/const.d.ts +11 -3
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/participants/participants-helper.d.ts +4 -3
- package/dist/types-ts4.5/participants/participants-service.d.ts +4 -3
- package/dist/types-ts4.5/participants/telepointers-helper.d.ts +2 -2
- package/dist/types-ts4.5/provider/index.d.ts +6 -5
- package/dist/types-ts4.5/types.d.ts +58 -8
- package/package.json +3 -4
- package/report.api.md +105 -13
|
@@ -107,6 +107,16 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
107
107
|
return _this.participantsService.onParticipantTelepointer(payload, _this.sessionId);
|
|
108
108
|
}).on('presence:joined', _this.participantsService.onPresenceJoined).on('presence', _this.participantsService.onPresence).on('participant:left', _this.participantsService.onParticipantLeft).on('participant:updated', _this.participantsService.onParticipantUpdated).on('disconnect', _this.onDisconnected.bind(_assertThisInitialized(_this))).on('error', _this.onErrorHandled).on('status', _this.namespaceService.onNamespaceStatusChanged).connect(shouldInitialize);
|
|
109
109
|
});
|
|
110
|
+
_defineProperty(_assertThisInitialized(_this), "setUserId", function (id) {
|
|
111
|
+
_this.userId = id;
|
|
112
|
+
});
|
|
113
|
+
_defineProperty(_assertThisInitialized(_this), "getPresenceData", function () {
|
|
114
|
+
return {
|
|
115
|
+
sessionId: _this.sessionId,
|
|
116
|
+
userId: _this.userId,
|
|
117
|
+
clientId: _this.clientId
|
|
118
|
+
};
|
|
119
|
+
});
|
|
110
120
|
/**
|
|
111
121
|
* @param {InternalError} error The error to handle
|
|
112
122
|
*/
|
|
@@ -175,17 +185,20 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
175
185
|
while (1) switch (_context2.prev = _context2.next) {
|
|
176
186
|
case 0:
|
|
177
187
|
_context2.prev = 0;
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
_context2.next = 3;
|
|
189
|
+
return _this.documentService.getFinalAcknowledgedState();
|
|
190
|
+
case 3:
|
|
191
|
+
return _context2.abrupt("return", _context2.sent);
|
|
192
|
+
case 6:
|
|
193
|
+
_context2.prev = 6;
|
|
181
194
|
_context2.t0 = _context2["catch"](0);
|
|
182
195
|
(_this$analyticsHelper4 = _this.analyticsHelper) === null || _this$analyticsHelper4 === void 0 ? void 0 : _this$analyticsHelper4.sendErrorEvent(_context2.t0, 'Error while returning ADF version of the final draft document');
|
|
183
196
|
throw new GetFinalAcknowledgedStateError('Error while returning the final acknowledged state of the draft document', _context2.t0);
|
|
184
|
-
case
|
|
197
|
+
case 10:
|
|
185
198
|
case "end":
|
|
186
199
|
return _context2.stop();
|
|
187
200
|
}
|
|
188
|
-
}, _callee2, null, [[0,
|
|
201
|
+
}, _callee2, null, [[0, 6]]);
|
|
189
202
|
})));
|
|
190
203
|
_defineProperty(_assertThisInitialized(_this), "getUnconfirmedSteps", function () {
|
|
191
204
|
return _this.documentService.getUnconfirmedSteps();
|
|
@@ -204,7 +217,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
204
217
|
_this.initialDraft = _this.config.initialDraft;
|
|
205
218
|
_this.isProviderInitialized = false;
|
|
206
219
|
_this.isPreinitializing = false;
|
|
207
|
-
_this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined);
|
|
220
|
+
_this.participantsService = new ParticipantsService(_this.analyticsHelper, undefined, _this.emitCallback, _this.config.getUser, _this.channel.broadcast, _this.channel.sendPresenceJoined, _this.getPresenceData, _this.setUserId);
|
|
208
221
|
_this.metadataService = new MetadataService(_this.emitCallback, _this.channel.sendMetadata);
|
|
209
222
|
_this.documentService = new DocumentService(_this.participantsService, _this.analyticsHelper, _this.channel.fetchCatchup, _this.emitCallback, _this.channel.broadcast, function () {
|
|
210
223
|
return _this.userId;
|
|
@@ -324,7 +337,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
324
337
|
/**
|
|
325
338
|
* Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
|
|
326
339
|
* Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
|
|
327
|
-
* @param {
|
|
340
|
+
* @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
|
|
328
341
|
* @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
|
|
329
342
|
* @param {CollabSendableSelection} data.selection Object representing the selected element
|
|
330
343
|
* @param {string} data.sessionId Identifier identifying the session
|
package/dist/esm/types.js
CHANGED
package/dist/esm/version.json
CHANGED
package/dist/types/channel.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
41
41
|
* @throws {NotConnectedError} Channel not connected
|
|
42
42
|
*/
|
|
43
43
|
sendMetadata: (metadata: Metadata) => void;
|
|
44
|
-
sendPresenceJoined()
|
|
44
|
+
sendPresenceJoined: () => void;
|
|
45
45
|
onOnlineHandler: () => void;
|
|
46
46
|
disconnect(): void;
|
|
47
47
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, StepsPayload } from '../types';
|
|
3
|
+
import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, ResolvedEditorState, StepsPayload } from '../types';
|
|
4
4
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
5
5
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
|
-
import { SyncUpErrorFunction } from '
|
|
6
|
+
import { SyncUpErrorFunction } from '../types';
|
|
7
7
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
8
|
-
import { ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
9
8
|
import { ParticipantsService } from '../participants/participants-service';
|
|
10
9
|
import type { InternalError } from '../errors/error-types';
|
|
11
10
|
export declare class DocumentService {
|
|
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
|
|
|
10
10
|
ERROR = "error",
|
|
11
11
|
PUBLISH_PAGE = "publishPage",
|
|
12
12
|
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
-
INVALIDATE_TOKEN = "invalidateToken"
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken",
|
|
14
|
+
DROPPED_STEPS = "droppedStepInCatchup"
|
|
14
15
|
}
|
|
15
16
|
export declare enum EVENT_STATUS {
|
|
16
17
|
SUCCESS = "SUCCESS",
|
|
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
|
|
|
110
111
|
latency?: number;
|
|
111
112
|
};
|
|
112
113
|
};
|
|
114
|
+
type CatchUpDroppedStepsEvent = {
|
|
115
|
+
eventAction: EVENT_ACTION.DROPPED_STEPS;
|
|
116
|
+
attributes: {
|
|
117
|
+
documentAri: string;
|
|
118
|
+
numOfDroppedSteps: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
113
121
|
type DocumentInitSuccessAnalyticsEvent = {
|
|
114
122
|
eventAction: EVENT_ACTION.DOCUMENT_INIT;
|
|
115
123
|
attributes: {
|
|
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
|
|
|
177
185
|
latency?: number;
|
|
178
186
|
};
|
|
179
187
|
};
|
|
180
|
-
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
181
|
-
export declare const ACK_MAX_TRY =
|
|
188
|
+
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
189
|
+
export declare const ACK_MAX_TRY = 60;
|
|
182
190
|
export declare const CONFLUENCE = "confluence";
|
|
183
191
|
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
|
-
export type { CollabConnectedPayload, CollabDisconnectedPayload,
|
|
2
|
+
export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
|
|
3
3
|
export type { ProviderError } from './errors/error-types';
|
|
4
4
|
export { PROVIDER_ERROR_CODE } from './errors/error-types';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CollabParticipant } from '
|
|
2
|
-
import type { PresencePayload } from '../types';
|
|
1
|
+
import type { CollabParticipant, PresencePayload } from '../types';
|
|
3
2
|
export declare const PARTICIPANT_UPDATE_INTERVAL: number;
|
|
4
3
|
export type ProviderParticipant = CollabParticipant & {
|
|
5
4
|
userId: string;
|
|
@@ -7,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
|
|
|
7
6
|
};
|
|
8
7
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
8
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
|
|
10
|
-
export declare const createParticipantFromPayload: (payload:
|
|
9
|
+
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
} & {
|
|
11
12
|
userId: string;
|
|
12
13
|
}, getUser: GetUserType) => Promise<ProviderParticipant>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { CollabEventPresenceData, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
|
|
2
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import type { ChannelEvent,
|
|
2
|
+
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
4
3
|
import { GetUserType } from './participants-helper';
|
|
5
4
|
import { ParticipantsState } from './participants-state';
|
|
6
5
|
/**
|
|
@@ -19,9 +18,11 @@ export declare class ParticipantsService {
|
|
|
19
18
|
private getUser;
|
|
20
19
|
private channelBroadcast;
|
|
21
20
|
private sendPresenceJoined;
|
|
21
|
+
private getPresenceData;
|
|
22
|
+
private setUserId;
|
|
22
23
|
private participantUpdateTimeout;
|
|
23
24
|
private presenceUpdateTimeout;
|
|
24
|
-
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData |
|
|
25
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
|
|
25
26
|
/**
|
|
26
27
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
27
28
|
* @param payload Payload from incoming socket event
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AcknowledgementPayload,
|
|
1
|
+
import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
|
|
2
2
|
import { ProviderParticipant } from './participants-helper';
|
|
3
|
-
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) =>
|
|
3
|
+
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabTelepointerPayload | undefined;
|
|
4
4
|
export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
3
3
|
import { Emitter } from '../emitter';
|
|
4
|
-
import type { ResolvedEditorState } from '
|
|
5
|
-
import type {
|
|
6
|
-
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, Config, Metadata, ResolvedEditorState } from '../types';
|
|
5
|
+
import type { SyncUpErrorFunction } from '../types';
|
|
7
6
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
7
|
type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
9
8
|
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
@@ -34,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
34
33
|
getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
|
|
35
34
|
constructor(config: Config);
|
|
36
35
|
private initializeChannel;
|
|
36
|
+
private setUserId;
|
|
37
|
+
private getPresenceData;
|
|
37
38
|
/**
|
|
38
39
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
39
40
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -73,12 +74,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
73
74
|
/**
|
|
74
75
|
* Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
|
|
75
76
|
* Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
|
|
76
|
-
* @param {
|
|
77
|
+
* @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
|
|
77
78
|
* @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
|
|
78
79
|
* @param {CollabSendableSelection} data.selection Object representing the selected element
|
|
79
80
|
* @param {string} data.sessionId Identifier identifying the session
|
|
80
81
|
*/
|
|
81
|
-
sendMessage(data:
|
|
82
|
+
sendMessage(data: CollabTelepointerPayload): void;
|
|
82
83
|
private onDisconnected;
|
|
83
84
|
/**
|
|
84
85
|
* "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
import type { Step } from 'prosemirror-transform';
|
|
2
2
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
-
import type { CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
3
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
4
|
import type { Manager } from 'socket.io-client';
|
|
6
5
|
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
7
6
|
import type { InternalError } from './errors/error-types';
|
|
8
7
|
import type { ProviderError } from './errors/error-types';
|
|
9
|
-
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
10
8
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
11
9
|
import { ProviderParticipant } from './participants/participants-helper';
|
|
10
|
+
import AnalyticsHelper from './analytics/analytics-helper';
|
|
11
|
+
export interface CollabParticipant {
|
|
12
|
+
lastActive: number;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
avatar: string;
|
|
15
|
+
name: string;
|
|
16
|
+
cursorPos?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface CollabEventInitData {
|
|
19
|
+
doc?: any;
|
|
20
|
+
json?: any;
|
|
21
|
+
version?: number;
|
|
22
|
+
sid?: string;
|
|
23
|
+
reserveCursor?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface CollabEventRemoteData {
|
|
26
|
+
json?: any;
|
|
27
|
+
newState?: EditorState;
|
|
28
|
+
userIds?: (number | string)[];
|
|
29
|
+
}
|
|
30
|
+
export interface CollabEventConnectionData {
|
|
31
|
+
sid: string;
|
|
32
|
+
initial: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface CollabEventConnectingData {
|
|
35
|
+
initial: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface CollabEventDisconnectedData {
|
|
38
|
+
sid: string;
|
|
39
|
+
reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
|
|
40
|
+
}
|
|
41
|
+
export interface CollabEventPresenceData {
|
|
42
|
+
joined?: CollabParticipant[];
|
|
43
|
+
left?: {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
export interface CollabEventLocalStepData {
|
|
48
|
+
steps: Array<Step>;
|
|
49
|
+
}
|
|
50
|
+
export type ResolvedEditorState<T = any> = {
|
|
51
|
+
content: JSONDocNode | T;
|
|
52
|
+
title: string | null;
|
|
53
|
+
stepVersion: number;
|
|
54
|
+
};
|
|
12
55
|
export interface Storage {
|
|
13
56
|
get(key: string): Promise<string>;
|
|
14
57
|
set(key: string, value: string): Promise<void>;
|
|
@@ -75,10 +118,6 @@ export interface CollabDisconnectedPayload {
|
|
|
75
118
|
reason: DisconnectReason;
|
|
76
119
|
sid: string;
|
|
77
120
|
}
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated Use ProviderError type instead
|
|
80
|
-
*/
|
|
81
|
-
export type CollabErrorPayload = ProviderError;
|
|
82
121
|
export interface CollabInitPayload extends CollabEventInitData {
|
|
83
122
|
doc: any;
|
|
84
123
|
version: number;
|
|
@@ -105,7 +144,7 @@ export interface CollabEvents {
|
|
|
105
144
|
telepointer: CollabTelepointerPayload;
|
|
106
145
|
presence: CollabPresencePayload;
|
|
107
146
|
'local-steps': CollabLocalStepsPayload;
|
|
108
|
-
error:
|
|
147
|
+
error: ProviderError;
|
|
109
148
|
entity: any;
|
|
110
149
|
connecting: CollabConnectingPayload;
|
|
111
150
|
}
|
|
@@ -129,10 +168,12 @@ export type BroadcastIncomingPayload = {
|
|
|
129
168
|
timestamp?: number;
|
|
130
169
|
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
131
170
|
};
|
|
132
|
-
export type
|
|
171
|
+
export type PresenceData = {
|
|
133
172
|
sessionId: string;
|
|
134
173
|
userId: string | undefined;
|
|
135
174
|
clientId: number | string;
|
|
175
|
+
};
|
|
176
|
+
export type PresencePayload = PresenceData & {
|
|
136
177
|
timestamp: number;
|
|
137
178
|
};
|
|
138
179
|
export type TelepointerPayload = PresencePayload & {
|
|
@@ -232,6 +273,7 @@ export interface CatchupOptions {
|
|
|
232
273
|
applyLocalSteps: (steps: Step[]) => void;
|
|
233
274
|
updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
234
275
|
updateMetadata: (metadata: Metadata | undefined) => void;
|
|
276
|
+
analyticsHelper: AnalyticsHelper | undefined;
|
|
235
277
|
}
|
|
236
278
|
export type ProductInformation = {
|
|
237
279
|
product: string;
|
|
@@ -262,4 +304,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
|
|
|
262
304
|
} & Events[K]): void;
|
|
263
305
|
getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
|
|
264
306
|
}
|
|
307
|
+
export type NewCollabSyncUpErrorAttributes = {
|
|
308
|
+
lengthOfUnconfirmedSteps?: number;
|
|
309
|
+
tries: number;
|
|
310
|
+
maxRetries: number;
|
|
311
|
+
clientId?: number | string;
|
|
312
|
+
version: number;
|
|
313
|
+
};
|
|
314
|
+
export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
|
|
265
315
|
export {};
|
|
@@ -41,7 +41,7 @@ export declare class Channel extends Emitter<ChannelEvent> {
|
|
|
41
41
|
* @throws {NotConnectedError} Channel not connected
|
|
42
42
|
*/
|
|
43
43
|
sendMetadata: (metadata: Metadata) => void;
|
|
44
|
-
sendPresenceJoined()
|
|
44
|
+
sendPresenceJoined: () => void;
|
|
45
45
|
onOnlineHandler: () => void;
|
|
46
46
|
disconnect(): void;
|
|
47
47
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
/// <reference types="lodash" />
|
|
2
2
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, StepsPayload } from '../types';
|
|
3
|
+
import { CatchupResponse, ChannelEvent, CollabEvents, CollabInitPayload, ResolvedEditorState, StepsPayload } from '../types';
|
|
4
4
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
5
5
|
import type { MetadataService } from '../metadata/metadata-service';
|
|
6
|
-
import { SyncUpErrorFunction } from '
|
|
6
|
+
import { SyncUpErrorFunction } from '../types';
|
|
7
7
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
8
|
-
import { ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
9
8
|
import { ParticipantsService } from '../participants/participants-service';
|
|
10
9
|
import type { InternalError } from '../errors/error-types';
|
|
11
10
|
export declare class DocumentService {
|
|
@@ -10,7 +10,8 @@ export declare enum EVENT_ACTION {
|
|
|
10
10
|
ERROR = "error",
|
|
11
11
|
PUBLISH_PAGE = "publishPage",
|
|
12
12
|
GET_CURRENT_STATE = "getCurrentState",
|
|
13
|
-
INVALIDATE_TOKEN = "invalidateToken"
|
|
13
|
+
INVALIDATE_TOKEN = "invalidateToken",
|
|
14
|
+
DROPPED_STEPS = "droppedStepInCatchup"
|
|
14
15
|
}
|
|
15
16
|
export declare enum EVENT_STATUS {
|
|
16
17
|
SUCCESS = "SUCCESS",
|
|
@@ -110,6 +111,13 @@ type CatchUpFailureAnalyticsEvent = {
|
|
|
110
111
|
latency?: number;
|
|
111
112
|
};
|
|
112
113
|
};
|
|
114
|
+
type CatchUpDroppedStepsEvent = {
|
|
115
|
+
eventAction: EVENT_ACTION.DROPPED_STEPS;
|
|
116
|
+
attributes: {
|
|
117
|
+
documentAri: string;
|
|
118
|
+
numOfDroppedSteps: number;
|
|
119
|
+
};
|
|
120
|
+
};
|
|
113
121
|
type DocumentInitSuccessAnalyticsEvent = {
|
|
114
122
|
eventAction: EVENT_ACTION.DOCUMENT_INIT;
|
|
115
123
|
attributes: {
|
|
@@ -177,7 +185,7 @@ type GetCurrentStateFailureAnalyticsEvent = {
|
|
|
177
185
|
latency?: number;
|
|
178
186
|
};
|
|
179
187
|
};
|
|
180
|
-
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent;
|
|
181
|
-
export declare const ACK_MAX_TRY =
|
|
188
|
+
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
189
|
+
export declare const ACK_MAX_TRY = 60;
|
|
182
190
|
export declare const CONFLUENCE = "confluence";
|
|
183
191
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { Provider } from './provider';
|
|
2
|
-
export type { CollabConnectedPayload, CollabDisconnectedPayload,
|
|
2
|
+
export type { CollabParticipant, CollabEventInitData, CollabEventRemoteData, CollabEventConnectionData, CollabEventConnectingData, CollabEventDisconnectedData, CollabEventPresenceData, CollabEventTelepointerData, CollabEventLocalStepData, ResolvedEditorState, CollabConnectedPayload, CollabDisconnectedPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, SyncUpErrorFunction, NewCollabSyncUpErrorAttributes, Socket, } from './types';
|
|
3
3
|
export type { ProviderError } from './errors/error-types';
|
|
4
4
|
export { PROVIDER_ERROR_CODE } from './errors/error-types';
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { CollabParticipant } from '
|
|
2
|
-
import type { PresencePayload } from '../types';
|
|
1
|
+
import type { CollabParticipant, PresencePayload } from '../types';
|
|
3
2
|
export declare const PARTICIPANT_UPDATE_INTERVAL: number;
|
|
4
3
|
export type ProviderParticipant = CollabParticipant & {
|
|
5
4
|
userId: string;
|
|
@@ -7,6 +6,8 @@ export type ProviderParticipant = CollabParticipant & {
|
|
|
7
6
|
};
|
|
8
7
|
export type ParticipantsMap = Map<string, ProviderParticipant>;
|
|
9
8
|
export type GetUserType = ((userId: string) => Promise<Pick<ProviderParticipant, 'name' | 'avatar' | 'userId'>>) | undefined;
|
|
10
|
-
export declare const createParticipantFromPayload: (payload:
|
|
9
|
+
export declare const createParticipantFromPayload: (payload: import("../types").PresenceData & {
|
|
10
|
+
timestamp: number;
|
|
11
|
+
} & {
|
|
11
12
|
userId: string;
|
|
12
13
|
}, getUser: GetUserType) => Promise<ProviderParticipant>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { CollabEventPresenceData, CollabEventDisconnectedData } from '@atlaskit/editor-common/collab';
|
|
2
1
|
import AnalyticsHelper from '../analytics/analytics-helper';
|
|
3
|
-
import type { ChannelEvent,
|
|
2
|
+
import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresenceData, PresencePayload, StepJson, TelepointerPayload } from '../types';
|
|
4
3
|
import { GetUserType } from './participants-helper';
|
|
5
4
|
import { ParticipantsState } from './participants-state';
|
|
6
5
|
/**
|
|
@@ -19,9 +18,11 @@ export declare class ParticipantsService {
|
|
|
19
18
|
private getUser;
|
|
20
19
|
private channelBroadcast;
|
|
21
20
|
private sendPresenceJoined;
|
|
21
|
+
private getPresenceData;
|
|
22
|
+
private setUserId;
|
|
22
23
|
private participantUpdateTimeout;
|
|
23
24
|
private presenceUpdateTimeout;
|
|
24
|
-
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData |
|
|
25
|
+
constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabTelepointerPayload | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void, getPresenceData: () => PresenceData, setUserId: (id: string) => void);
|
|
25
26
|
/**
|
|
26
27
|
* Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
|
|
27
28
|
* @param payload Payload from incoming socket event
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AcknowledgementPayload,
|
|
1
|
+
import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
|
|
2
2
|
import { ProviderParticipant } from './participants-helper';
|
|
3
|
-
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) =>
|
|
3
|
+
export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabTelepointerPayload | undefined;
|
|
4
4
|
export declare const telepointerCallback: (documentAri: string) => (response: AcknowledgementPayload) => void;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
2
2
|
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
3
3
|
import { Emitter } from '../emitter';
|
|
4
|
-
import type { ResolvedEditorState } from '
|
|
5
|
-
import type {
|
|
6
|
-
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
4
|
+
import type { CollabEditProvider, CollabEvents, CollabTelepointerPayload, Config, Metadata, ResolvedEditorState } from '../types';
|
|
5
|
+
import type { SyncUpErrorFunction } from '../types';
|
|
7
6
|
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
7
|
type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
9
8
|
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
@@ -34,6 +33,8 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
34
33
|
getStatePromiseResolve: (value: void | PromiseLike<void>) => void;
|
|
35
34
|
constructor(config: Config);
|
|
36
35
|
private initializeChannel;
|
|
36
|
+
private setUserId;
|
|
37
|
+
private getPresenceData;
|
|
37
38
|
/**
|
|
38
39
|
* Initialisation logic, called by Jira with a dummy getState function, deprecated in favour of the setup method which allows more configuration
|
|
39
40
|
* @param {Function} getState Function that returns the editor state, used to retrieve collab-edit properties and to interact with prosemirror-collab
|
|
@@ -73,12 +74,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
73
74
|
/**
|
|
74
75
|
* Send messages, such as telepointers, to NCS and other participants. Only used for telepointer data (text and node selections) in the editor and JWM. JWM does some weird serialisation stuff on the node selections.
|
|
75
76
|
* Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
|
|
76
|
-
* @param {
|
|
77
|
+
* @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
|
|
77
78
|
* @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
|
|
78
79
|
* @param {CollabSendableSelection} data.selection Object representing the selected element
|
|
79
80
|
* @param {string} data.sessionId Identifier identifying the session
|
|
80
81
|
*/
|
|
81
|
-
sendMessage(data:
|
|
82
|
+
sendMessage(data: CollabTelepointerPayload): void;
|
|
82
83
|
private onDisconnected;
|
|
83
84
|
/**
|
|
84
85
|
* "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
|
|
@@ -1,14 +1,57 @@
|
|
|
1
1
|
import type { Step } from 'prosemirror-transform';
|
|
2
2
|
import type { EditorState, Transaction } from 'prosemirror-state';
|
|
3
|
-
import type { CollabEventConnectionData, CollabEventInitData, CollabEventRemoteData, CollabEventPresenceData, CollabEventConnectingData, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
3
|
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
4
|
import type { Manager } from 'socket.io-client';
|
|
6
5
|
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
7
6
|
import type { InternalError } from './errors/error-types';
|
|
8
7
|
import type { ProviderError } from './errors/error-types';
|
|
9
|
-
import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
10
8
|
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
11
9
|
import { ProviderParticipant } from './participants/participants-helper';
|
|
10
|
+
import AnalyticsHelper from './analytics/analytics-helper';
|
|
11
|
+
export interface CollabParticipant {
|
|
12
|
+
lastActive: number;
|
|
13
|
+
sessionId: string;
|
|
14
|
+
avatar: string;
|
|
15
|
+
name: string;
|
|
16
|
+
cursorPos?: number;
|
|
17
|
+
}
|
|
18
|
+
export interface CollabEventInitData {
|
|
19
|
+
doc?: any;
|
|
20
|
+
json?: any;
|
|
21
|
+
version?: number;
|
|
22
|
+
sid?: string;
|
|
23
|
+
reserveCursor?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface CollabEventRemoteData {
|
|
26
|
+
json?: any;
|
|
27
|
+
newState?: EditorState;
|
|
28
|
+
userIds?: (number | string)[];
|
|
29
|
+
}
|
|
30
|
+
export interface CollabEventConnectionData {
|
|
31
|
+
sid: string;
|
|
32
|
+
initial: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface CollabEventConnectingData {
|
|
35
|
+
initial: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface CollabEventDisconnectedData {
|
|
38
|
+
sid: string;
|
|
39
|
+
reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
|
|
40
|
+
}
|
|
41
|
+
export interface CollabEventPresenceData {
|
|
42
|
+
joined?: CollabParticipant[];
|
|
43
|
+
left?: {
|
|
44
|
+
sessionId: string;
|
|
45
|
+
}[];
|
|
46
|
+
}
|
|
47
|
+
export interface CollabEventLocalStepData {
|
|
48
|
+
steps: Array<Step>;
|
|
49
|
+
}
|
|
50
|
+
export type ResolvedEditorState<T = any> = {
|
|
51
|
+
content: JSONDocNode | T;
|
|
52
|
+
title: string | null;
|
|
53
|
+
stepVersion: number;
|
|
54
|
+
};
|
|
12
55
|
export interface Storage {
|
|
13
56
|
get(key: string): Promise<string>;
|
|
14
57
|
set(key: string, value: string): Promise<void>;
|
|
@@ -75,10 +118,6 @@ export interface CollabDisconnectedPayload {
|
|
|
75
118
|
reason: DisconnectReason;
|
|
76
119
|
sid: string;
|
|
77
120
|
}
|
|
78
|
-
/**
|
|
79
|
-
* @deprecated Use ProviderError type instead
|
|
80
|
-
*/
|
|
81
|
-
export type CollabErrorPayload = ProviderError;
|
|
82
121
|
export interface CollabInitPayload extends CollabEventInitData {
|
|
83
122
|
doc: any;
|
|
84
123
|
version: number;
|
|
@@ -105,7 +144,7 @@ export interface CollabEvents {
|
|
|
105
144
|
telepointer: CollabTelepointerPayload;
|
|
106
145
|
presence: CollabPresencePayload;
|
|
107
146
|
'local-steps': CollabLocalStepsPayload;
|
|
108
|
-
error:
|
|
147
|
+
error: ProviderError;
|
|
109
148
|
entity: any;
|
|
110
149
|
connecting: CollabConnectingPayload;
|
|
111
150
|
}
|
|
@@ -129,10 +168,12 @@ export type BroadcastIncomingPayload = {
|
|
|
129
168
|
timestamp?: number;
|
|
130
169
|
data: PresencePayload | TelepointerPayload | StepsPayload | any;
|
|
131
170
|
};
|
|
132
|
-
export type
|
|
171
|
+
export type PresenceData = {
|
|
133
172
|
sessionId: string;
|
|
134
173
|
userId: string | undefined;
|
|
135
174
|
clientId: number | string;
|
|
175
|
+
};
|
|
176
|
+
export type PresencePayload = PresenceData & {
|
|
136
177
|
timestamp: number;
|
|
137
178
|
};
|
|
138
179
|
export type TelepointerPayload = PresencePayload & {
|
|
@@ -232,6 +273,7 @@ export interface CatchupOptions {
|
|
|
232
273
|
applyLocalSteps: (steps: Step[]) => void;
|
|
233
274
|
updateDocument: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
234
275
|
updateMetadata: (metadata: Metadata | undefined) => void;
|
|
276
|
+
analyticsHelper: AnalyticsHelper | undefined;
|
|
235
277
|
}
|
|
236
278
|
export type ProductInformation = {
|
|
237
279
|
product: string;
|
|
@@ -262,4 +304,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
|
|
|
262
304
|
} & Events[K]): void;
|
|
263
305
|
getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
|
|
264
306
|
}
|
|
307
|
+
export type NewCollabSyncUpErrorAttributes = {
|
|
308
|
+
lengthOfUnconfirmedSteps?: number;
|
|
309
|
+
tries: number;
|
|
310
|
+
maxRetries: number;
|
|
311
|
+
clientId?: number | string;
|
|
312
|
+
version: number;
|
|
313
|
+
};
|
|
314
|
+
export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
|
|
265
315
|
export {};
|