@atlaskit/collab-provider 8.9.0 → 9.0.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/collab-provider
2
2
 
3
+ ## 9.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`b7086232a7c`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b7086232a7c) - ESS-3135: move collab provider types into @atlaskit/collab-provider
8
+
9
+ ## 8.9.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`9d00501a414`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9d00501a414) - Ensure legacy types are published for TS 4.5-4.8
14
+
3
15
  ## 8.9.0
4
16
 
5
17
  ### Minor Changes
@@ -332,7 +332,7 @@ var Provider = /*#__PURE__*/function (_Emitter) {
332
332
  /**
333
333
  * 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.
334
334
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
335
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
335
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
336
336
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
337
337
  * @param {CollabSendableSelection} data.selection Object representing the selected element
338
338
  * @param {string} data.sessionId Identifier identifying the session
package/dist/cjs/types.js CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.AcknowledgementResponseTypes = void 0;
7
+ // types from editor common
8
+ // types from editor common end
7
9
  // Initial draft
8
- /**
9
- * @deprecated Use ProviderError type instead
10
- */
11
10
  // Channel
12
11
  /**
13
12
  * @description Incoming payload type from the `broadcast` route in NCS
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/collab-provider";
8
8
  exports.name = name;
9
- var version = "8.9.0";
9
+ var version = "9.0.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "8.9.0",
3
+ "version": "9.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -275,7 +275,7 @@ export class Provider extends Emitter {
275
275
  /**
276
276
  * 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.
277
277
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
278
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
278
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
279
279
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
280
280
  * @param {CollabSendableSelection} data.selection Object representing the selected element
281
281
  * @param {string} data.sessionId Identifier identifying the session
@@ -1,8 +1,8 @@
1
- // Initial draft
1
+ // types from editor common
2
2
 
3
- /**
4
- * @deprecated Use ProviderError type instead
5
- */
3
+ // types from editor common end
4
+
5
+ // Initial draft
6
6
 
7
7
  // Channel
8
8
 
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/collab-provider";
2
- export const version = "8.9.0";
2
+ export const version = "9.0.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "8.9.0",
3
+ "version": "9.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -324,7 +324,7 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
324
324
  /**
325
325
  * 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
326
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
327
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
327
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
328
328
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
329
329
  * @param {CollabSendableSelection} data.selection Object representing the selected element
330
330
  * @param {string} data.sessionId Identifier identifying the session
package/dist/esm/types.js CHANGED
@@ -1,8 +1,8 @@
1
- // Initial draft
1
+ // types from editor common
2
2
 
3
- /**
4
- * @deprecated Use ProviderError type instead
5
- */
3
+ // types from editor common end
4
+
5
+ // Initial draft
6
6
 
7
7
  // Channel
8
8
 
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/collab-provider";
2
- export var version = "8.9.0";
2
+ export var version = "9.0.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "8.9.0",
3
+ "version": "9.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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 '@atlaskit/editor-common/types';
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 {
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, Socket, } from './types';
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 '@atlaskit/editor-common/collab';
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;
@@ -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, CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
4
3
  import { GetUserType } from './participants-helper';
5
4
  import { ParticipantsState } from './participants-state';
6
5
  /**
@@ -21,7 +20,7 @@ export declare class ParticipantsService {
21
20
  private sendPresenceJoined;
22
21
  private participantUpdateTimeout;
23
22
  private presenceUpdateTimeout;
24
- constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabEventTelepointerData | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
23
+ 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);
25
24
  /**
26
25
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
27
26
  * @param payload Payload from incoming socket event
@@ -1,4 +1,4 @@
1
- import type { AcknowledgementPayload, CollabEventTelepointerData, StepJson } from '../types';
1
+ import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
2
2
  import { ProviderParticipant } from './participants-helper';
3
- export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabEventTelepointerData | undefined;
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 '@atlaskit/editor-common/collab';
5
- import type { CollabEditProvider, CollabEvents, CollabEventTelepointerData, Config, Metadata } from '../types';
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 {
@@ -73,12 +72,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
73
72
  /**
74
73
  * 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
74
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
76
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
75
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
77
76
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
78
77
  * @param {CollabSendableSelection} data.selection Object representing the selected element
79
78
  * @param {string} data.sessionId Identifier identifying the session
80
79
  */
81
- sendMessage(data: CollabEventTelepointerData): void;
80
+ sendMessage(data: CollabTelepointerPayload): void;
82
81
  private onDisconnected;
83
82
  /**
84
83
  * "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
@@ -1,14 +1,56 @@
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
+ export interface CollabParticipant {
11
+ lastActive: number;
12
+ sessionId: string;
13
+ avatar: string;
14
+ name: string;
15
+ cursorPos?: number;
16
+ }
17
+ export interface CollabEventInitData {
18
+ doc?: any;
19
+ json?: any;
20
+ version?: number;
21
+ sid?: string;
22
+ reserveCursor?: boolean;
23
+ }
24
+ export interface CollabEventRemoteData {
25
+ json?: any;
26
+ newState?: EditorState;
27
+ userIds?: (number | string)[];
28
+ }
29
+ export interface CollabEventConnectionData {
30
+ sid: string;
31
+ initial: boolean;
32
+ }
33
+ export interface CollabEventConnectingData {
34
+ initial: boolean;
35
+ }
36
+ export interface CollabEventDisconnectedData {
37
+ sid: string;
38
+ reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
39
+ }
40
+ export interface CollabEventPresenceData {
41
+ joined?: CollabParticipant[];
42
+ left?: {
43
+ sessionId: string;
44
+ }[];
45
+ }
46
+ export interface CollabEventLocalStepData {
47
+ steps: Array<Step>;
48
+ }
49
+ export type ResolvedEditorState<T = any> = {
50
+ content: JSONDocNode | T;
51
+ title: string | null;
52
+ stepVersion: number;
53
+ };
12
54
  export interface Storage {
13
55
  get(key: string): Promise<string>;
14
56
  set(key: string, value: string): Promise<void>;
@@ -75,10 +117,6 @@ export interface CollabDisconnectedPayload {
75
117
  reason: DisconnectReason;
76
118
  sid: string;
77
119
  }
78
- /**
79
- * @deprecated Use ProviderError type instead
80
- */
81
- export type CollabErrorPayload = ProviderError;
82
120
  export interface CollabInitPayload extends CollabEventInitData {
83
121
  doc: any;
84
122
  version: number;
@@ -105,7 +143,7 @@ export interface CollabEvents {
105
143
  telepointer: CollabTelepointerPayload;
106
144
  presence: CollabPresencePayload;
107
145
  'local-steps': CollabLocalStepsPayload;
108
- error: CollabErrorPayload;
146
+ error: ProviderError;
109
147
  entity: any;
110
148
  connecting: CollabConnectingPayload;
111
149
  }
@@ -262,4 +300,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
262
300
  } & Events[K]): void;
263
301
  getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
264
302
  }
303
+ export type NewCollabSyncUpErrorAttributes = {
304
+ lengthOfUnconfirmedSteps?: number;
305
+ tries: number;
306
+ maxRetries: number;
307
+ clientId?: number | string;
308
+ version: number;
309
+ };
310
+ export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
265
311
  export {};
@@ -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 '@atlaskit/editor-common/types';
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 {
@@ -1,4 +1,4 @@
1
1
  export { Provider } from './provider';
2
- export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, CollabSendableSelection, CollabEditProvider, Socket, } from './types';
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 '@atlaskit/editor-common/collab';
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;
@@ -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, CollabEventTelepointerData, PresencePayload, StepJson, TelepointerPayload } from '../types';
2
+ import type { CollabEventDisconnectedData, CollabEventPresenceData, CollabTelepointerPayload, ChannelEvent, PresencePayload, StepJson, TelepointerPayload } from '../types';
4
3
  import { GetUserType } from './participants-helper';
5
4
  import { ParticipantsState } from './participants-state';
6
5
  /**
@@ -21,7 +20,7 @@ export declare class ParticipantsService {
21
20
  private sendPresenceJoined;
22
21
  private participantUpdateTimeout;
23
22
  private presenceUpdateTimeout;
24
- constructor(analyticsHelper: AnalyticsHelper | undefined, participantsState: ParticipantsState, emit: (evt: 'presence' | 'telepointer' | 'disconnected', data: CollabEventPresenceData | CollabEventTelepointerData | CollabEventDisconnectedData) => void, getUser: GetUserType, channelBroadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, sendPresenceJoined: () => void);
23
+ 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);
25
24
  /**
26
25
  * Carries out 3 things: 1) enriches the participant with user data, 2) updates the participantsState, 3) emits the presence event
27
26
  * @param payload Payload from incoming socket event
@@ -1,4 +1,4 @@
1
- import type { AcknowledgementPayload, CollabEventTelepointerData, StepJson } from '../types';
1
+ import type { AcknowledgementPayload, CollabTelepointerPayload, StepJson } from '../types';
2
2
  import { ProviderParticipant } from './participants-helper';
3
- export declare const telepointerFromStep: (participants: ProviderParticipant[], step: StepJson) => CollabEventTelepointerData | undefined;
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 '@atlaskit/editor-common/collab';
5
- import type { CollabEditProvider, CollabEvents, CollabEventTelepointerData, Config, Metadata } from '../types';
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 {
@@ -73,12 +72,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
73
72
  /**
74
73
  * 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
74
  * Silently fails if an error occurs, since Presence isn't a critical functionality and self-restores over time.
76
- * @param {CollabEventTelepointerData} data Data you want to send to NCS / the other participants
75
+ * @param {CollabTelepointerPayload} data Data you want to send to NCS / the other participants
77
76
  * @param {string} data.type Can only be 'telepointer' for now, we don't support anything else yet
78
77
  * @param {CollabSendableSelection} data.selection Object representing the selected element
79
78
  * @param {string} data.sessionId Identifier identifying the session
80
79
  */
81
- sendMessage(data: CollabEventTelepointerData): void;
80
+ sendMessage(data: CollabTelepointerPayload): void;
82
81
  private onDisconnected;
83
82
  /**
84
83
  * "Destroy" the provider, disconnect it's connection to the back-end service and unsubscribe all event listeners on the provider.
@@ -1,14 +1,56 @@
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
+ export interface CollabParticipant {
11
+ lastActive: number;
12
+ sessionId: string;
13
+ avatar: string;
14
+ name: string;
15
+ cursorPos?: number;
16
+ }
17
+ export interface CollabEventInitData {
18
+ doc?: any;
19
+ json?: any;
20
+ version?: number;
21
+ sid?: string;
22
+ reserveCursor?: boolean;
23
+ }
24
+ export interface CollabEventRemoteData {
25
+ json?: any;
26
+ newState?: EditorState;
27
+ userIds?: (number | string)[];
28
+ }
29
+ export interface CollabEventConnectionData {
30
+ sid: string;
31
+ initial: boolean;
32
+ }
33
+ export interface CollabEventConnectingData {
34
+ initial: boolean;
35
+ }
36
+ export interface CollabEventDisconnectedData {
37
+ sid: string;
38
+ reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
39
+ }
40
+ export interface CollabEventPresenceData {
41
+ joined?: CollabParticipant[];
42
+ left?: {
43
+ sessionId: string;
44
+ }[];
45
+ }
46
+ export interface CollabEventLocalStepData {
47
+ steps: Array<Step>;
48
+ }
49
+ export type ResolvedEditorState<T = any> = {
50
+ content: JSONDocNode | T;
51
+ title: string | null;
52
+ stepVersion: number;
53
+ };
12
54
  export interface Storage {
13
55
  get(key: string): Promise<string>;
14
56
  set(key: string, value: string): Promise<void>;
@@ -75,10 +117,6 @@ export interface CollabDisconnectedPayload {
75
117
  reason: DisconnectReason;
76
118
  sid: string;
77
119
  }
78
- /**
79
- * @deprecated Use ProviderError type instead
80
- */
81
- export type CollabErrorPayload = ProviderError;
82
120
  export interface CollabInitPayload extends CollabEventInitData {
83
121
  doc: any;
84
122
  version: number;
@@ -105,7 +143,7 @@ export interface CollabEvents {
105
143
  telepointer: CollabTelepointerPayload;
106
144
  presence: CollabPresencePayload;
107
145
  'local-steps': CollabLocalStepsPayload;
108
- error: CollabErrorPayload;
146
+ error: ProviderError;
109
147
  entity: any;
110
148
  connecting: CollabConnectingPayload;
111
149
  }
@@ -262,4 +300,12 @@ export interface CollabEditProvider<Events extends CollabEvents = CollabEvents>
262
300
  } & Events[K]): void;
263
301
  getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
264
302
  }
303
+ export type NewCollabSyncUpErrorAttributes = {
304
+ lengthOfUnconfirmedSteps?: number;
305
+ tries: number;
306
+ maxRetries: number;
307
+ clientId?: number | string;
308
+ version: number;
309
+ };
310
+ export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
265
311
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/collab-provider",
3
- "version": "8.9.0",
3
+ "version": "9.0.0",
4
4
  "description": "A provider for collaborative editing.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +36,6 @@
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-gas-types": "^5.1.0",
38
38
  "@atlaskit/analytics-listeners": "^8.7.0",
39
- "@atlaskit/editor-common": "^74.1.0",
40
39
  "@atlaskit/editor-json-transformer": "^8.9.0",
41
40
  "@atlaskit/prosemirror-collab": "^0.2.0",
42
41
  "@atlaskit/ufo": "^0.2.0",
@@ -62,9 +61,9 @@
62
61
  }
63
62
  },
64
63
  "devDependencies": {
65
- "@atlaskit/adf-schema": "^25.6.0",
64
+ "@atlaskit/adf-schema": "^25.7.0",
66
65
  "@atlaskit/analytics-listeners": "^8.7.0",
67
- "@atlaskit/editor-test-helpers": "^18.3.0",
66
+ "@atlaskit/editor-test-helpers": "^18.4.0",
68
67
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
69
68
  "@types/prosemirror-model": "^1.11.0",
70
69
  "@types/prosemirror-state": "^1.2.0",
package/report.api.md CHANGED
@@ -16,18 +16,10 @@
16
16
 
17
17
  ```ts
18
18
  import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
19
- import type { CollabEventConnectingData } from '@atlaskit/editor-common/collab';
20
- import type { CollabEventConnectionData } from '@atlaskit/editor-common/collab';
21
- import type { CollabEventInitData } from '@atlaskit/editor-common/collab';
22
- import type { CollabEventPresenceData } from '@atlaskit/editor-common/collab';
23
- import type { CollabEventRemoteData } from '@atlaskit/editor-common/collab';
24
- import type { CollabParticipant } from '@atlaskit/editor-common/collab';
25
19
  import type { EditorState } from 'prosemirror-state';
26
20
  import { JSONDocNode } from '@atlaskit/editor-json-transformer';
27
21
  import type { Manager } from 'socket.io-client';
28
- import type { ResolvedEditorState } from '@atlaskit/editor-common/collab';
29
22
  import type { Step } from 'prosemirror-transform';
30
- import type { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
31
23
  import type { Transaction } from 'prosemirror-state';
32
24
 
33
25
  // @public (undocumented)
@@ -92,8 +84,73 @@ export interface CollabEditProvider<
92
84
  unsubscribeAll(evt: keyof Events): this;
93
85
  }
94
86
 
95
- // @public @deprecated (undocumented)
96
- export type CollabErrorPayload = ProviderError;
87
+ // @public (undocumented)
88
+ export interface CollabEventConnectingData {
89
+ // (undocumented)
90
+ initial: boolean;
91
+ }
92
+
93
+ // @public (undocumented)
94
+ export interface CollabEventConnectionData {
95
+ // (undocumented)
96
+ initial: boolean;
97
+ // (undocumented)
98
+ sid: string;
99
+ }
100
+
101
+ // @public (undocumented)
102
+ export interface CollabEventDisconnectedData {
103
+ // (undocumented)
104
+ reason:
105
+ | 'CLIENT_DISCONNECT'
106
+ | 'SERVER_DISCONNECT'
107
+ | 'SOCKET_CLOSED'
108
+ | 'SOCKET_ERROR'
109
+ | 'SOCKET_TIMEOUT'
110
+ | 'UNKNOWN_DISCONNECT';
111
+ // (undocumented)
112
+ sid: string;
113
+ }
114
+
115
+ // @public (undocumented)
116
+ export interface CollabEventInitData {
117
+ // (undocumented)
118
+ doc?: any;
119
+ // (undocumented)
120
+ json?: any;
121
+ // (undocumented)
122
+ reserveCursor?: boolean;
123
+ // (undocumented)
124
+ sid?: string;
125
+ // (undocumented)
126
+ version?: number;
127
+ }
128
+
129
+ // @public (undocumented)
130
+ export interface CollabEventLocalStepData {
131
+ // (undocumented)
132
+ steps: Array<Step>;
133
+ }
134
+
135
+ // @public (undocumented)
136
+ export interface CollabEventPresenceData {
137
+ // (undocumented)
138
+ joined?: CollabParticipant[];
139
+ // (undocumented)
140
+ left?: {
141
+ sessionId: string;
142
+ }[];
143
+ }
144
+
145
+ // @public (undocumented)
146
+ export interface CollabEventRemoteData {
147
+ // (undocumented)
148
+ json?: any;
149
+ // (undocumented)
150
+ newState?: EditorState;
151
+ // (undocumented)
152
+ userIds?: (number | string)[];
153
+ }
97
154
 
98
155
  // @public (undocumented)
99
156
  export interface CollabEvents {
@@ -112,7 +169,7 @@ export interface CollabEvents {
112
169
  // (undocumented)
113
170
  entity: any;
114
171
  // (undocumented)
115
- error: CollabErrorPayload;
172
+ error: ProviderError;
116
173
  // (undocumented)
117
174
  init: CollabInitPayload;
118
175
  // (undocumented)
@@ -122,7 +179,7 @@ export interface CollabEvents {
122
179
  }
123
180
 
124
181
  // @public (undocumented)
125
- interface CollabEventTelepointerData {
182
+ export interface CollabEventTelepointerData {
126
183
  // (undocumented)
127
184
  selection: CollabSendableSelection;
128
185
  // (undocumented)
@@ -151,6 +208,20 @@ export type CollabLocalStepsPayload = {
151
208
  // @public (undocumented)
152
209
  export type CollabMetadataPayload = Metadata_2;
153
210
 
211
+ // @public (undocumented)
212
+ export interface CollabParticipant {
213
+ // (undocumented)
214
+ avatar: string;
215
+ // (undocumented)
216
+ cursorPos?: number;
217
+ // (undocumented)
218
+ lastActive: number;
219
+ // (undocumented)
220
+ name: string;
221
+ // (undocumented)
222
+ sessionId: string;
223
+ }
224
+
154
225
  // @public (undocumented)
155
226
  export type CollabPresencePayload = CollabEventPresenceData;
156
227
 
@@ -359,6 +430,15 @@ type NetworkIssue = {
359
430
  status?: number;
360
431
  };
361
432
 
433
+ // @public (undocumented)
434
+ export type NewCollabSyncUpErrorAttributes = {
435
+ lengthOfUnconfirmedSteps?: number;
436
+ tries: number;
437
+ maxRetries: number;
438
+ clientId?: number | string;
439
+ version: number;
440
+ };
441
+
362
442
  // @public (undocumented)
363
443
  type NodeJson = {
364
444
  type: string;
@@ -396,7 +476,7 @@ export class Provider extends Emitter<CollabEvents> implements BaseEvents {
396
476
  _oldState: EditorState | null,
397
477
  newState: EditorState,
398
478
  ): void;
399
- sendMessage(data: CollabEventTelepointerData): void;
479
+ sendMessage(data: CollabTelepointerPayload): void;
400
480
  // @deprecated
401
481
  setEditorWidth(editorWidth: string, broadcast?: boolean): void;
402
482
  setMetadata(metadata: Metadata_2): void;
@@ -456,6 +536,13 @@ type ProviderParticipant = CollabParticipant & {
456
536
  clientId: number | string;
457
537
  };
458
538
 
539
+ // @public (undocumented)
540
+ export type ResolvedEditorState<T = any> = {
541
+ content: JSONDocNode | T;
542
+ title: null | string;
543
+ stepVersion: number;
544
+ };
545
+
459
546
  // @public (undocumented)
460
547
  interface SimpleEventEmitter {
461
548
  // (undocumented)
@@ -505,6 +592,11 @@ interface Storage_2 {
505
592
  set(key: string, value: string): Promise<void>;
506
593
  }
507
594
 
595
+ // @public (undocumented)
596
+ export type SyncUpErrorFunction = (
597
+ attributes: NewCollabSyncUpErrorAttributes,
598
+ ) => void;
599
+
508
600
  // (No @packageDocumentation comment for this package)
509
601
  ```
510
602