@atlaskit/collab-provider 7.6.3 → 8.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 +32 -0
- package/dist/cjs/analytics/index.js +17 -27
- package/dist/cjs/analytics/performance.js +0 -2
- package/dist/cjs/channel.js +91 -35
- package/dist/cjs/helpers/const.js +11 -1
- package/dist/cjs/provider/catchup.js +2 -2
- package/dist/cjs/provider/index.js +310 -106
- package/dist/cjs/types.js +10 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics/index.js +15 -22
- package/dist/es2019/analytics/performance.js +0 -2
- package/dist/es2019/channel.js +46 -10
- package/dist/es2019/helpers/const.js +9 -0
- package/dist/es2019/provider/catchup.js +2 -2
- package/dist/es2019/provider/index.js +244 -65
- package/dist/es2019/types.js +7 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics/index.js +15 -22
- package/dist/esm/analytics/performance.js +0 -2
- package/dist/esm/channel.js +92 -36
- package/dist/esm/helpers/const.js +9 -0
- package/dist/esm/provider/catchup.js +2 -2
- package/dist/esm/provider/index.js +314 -110
- package/dist/esm/types.js +7 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics/index.d.ts +1 -3
- package/dist/types/analytics/performance.d.ts +0 -2
- package/dist/types/channel.d.ts +2 -1
- package/dist/types/helpers/const.d.ts +33 -3
- package/dist/types/provider/index.d.ts +16 -6
- package/dist/types/types.d.ts +39 -12
- package/package.json +9 -14
- package/report.api.md +28 -19
- package/dist/types-ts4.0/analytics/index.d.ts +0 -5
- package/dist/types-ts4.0/analytics/performance.d.ts +0 -14
- package/dist/types-ts4.0/channel.d.ts +0 -27
- package/dist/types-ts4.0/config.d.ts +0 -5
- package/dist/types-ts4.0/disconnected-reason-mapper.d.ts +0 -15
- package/dist/types-ts4.0/emitter.d.ts +0 -19
- package/dist/types-ts4.0/error-code-mapper.d.ts +0 -32
- package/dist/types-ts4.0/helpers/const.d.ts +0 -31
- package/dist/types-ts4.0/helpers/utils.d.ts +0 -11
- package/dist/types-ts4.0/index.d.ts +0 -2
- package/dist/types-ts4.0/provider/catchup.d.ts +0 -9
- package/dist/types-ts4.0/provider/index.d.ts +0 -124
- package/dist/types-ts4.0/socket-io-provider.d.ts +0 -4
- package/dist/types-ts4.0/types.d.ts +0 -170
- package/dist/types-ts4.0/version-wrapper.d.ts +0 -3
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export { Provider } from './provider';
|
|
2
|
-
export type { CollabConnectedPayload, CollabDisconnectedPayload, CollabErrorPayload, CollabInitPayload, CollabDataPayload, CollabTelepointerPayload, CollabPresencePayload, CollabMetadataPayload, CollabLocalStepsPayload, CollabEvents, Socket, } from './types';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CatchupOptions } from '../types';
|
|
2
|
-
import { Mapping, Step } from 'prosemirror-transform';
|
|
3
|
-
/**
|
|
4
|
-
* Rebase the steps based on the mapping pipeline.
|
|
5
|
-
* Some steps could be lost, if they are no longer
|
|
6
|
-
* invalid after rebased.
|
|
7
|
-
*/
|
|
8
|
-
export declare function rebaseSteps(steps: Step[], mapping: Mapping): Step[];
|
|
9
|
-
export declare const catchup: (opt: CatchupOptions) => Promise<void>;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { EditorState, Transaction } from 'prosemirror-state';
|
|
2
|
-
import { Emitter } from '../emitter';
|
|
3
|
-
import { CollabEditProvider, ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
4
|
-
import type { Config, Metadata, CollabEvents } from '../types';
|
|
5
|
-
import { SyncUpErrorFunction } from '@atlaskit/editor-common/types';
|
|
6
|
-
export declare const CATCHUP_THROTTLE: number;
|
|
7
|
-
export declare const MAX_STEP_REJECTED_ERROR = 15;
|
|
8
|
-
declare type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'setup' | 'send' | 'sendMessage'>;
|
|
9
|
-
export declare class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
10
|
-
private participants;
|
|
11
|
-
private channel;
|
|
12
|
-
private config;
|
|
13
|
-
private getState;
|
|
14
|
-
private metadata;
|
|
15
|
-
private stepRejectCounter;
|
|
16
|
-
private analyticsClient?;
|
|
17
|
-
private isChannelInitialized;
|
|
18
|
-
private onSyncUpError?;
|
|
19
|
-
private sessionId?;
|
|
20
|
-
private clientId?;
|
|
21
|
-
private userId?;
|
|
22
|
-
private participantUpdateTimeout?;
|
|
23
|
-
private presenceUpdateTimeout?;
|
|
24
|
-
private disconnectedAt?;
|
|
25
|
-
constructor(config: Config);
|
|
26
|
-
private initializeChannel;
|
|
27
|
-
/**
|
|
28
|
-
* Called by collab plugin in editor when it's ready to
|
|
29
|
-
* initialize a collab session.
|
|
30
|
-
*/
|
|
31
|
-
initialize(getState: () => EditorState): this;
|
|
32
|
-
setup({ getState, onSyncUpError, }: {
|
|
33
|
-
getState: () => EditorState;
|
|
34
|
-
onSyncUpError?: SyncUpErrorFunction;
|
|
35
|
-
}): this;
|
|
36
|
-
/**
|
|
37
|
-
* We can use this function to throttle/delay
|
|
38
|
-
* Any send steps operation
|
|
39
|
-
*
|
|
40
|
-
* The getState function will return the current EditorState
|
|
41
|
-
* from the EditorView.
|
|
42
|
-
*/
|
|
43
|
-
private sendStepsFromCurrentState;
|
|
44
|
-
/**
|
|
45
|
-
* Send steps from transaction to other participants
|
|
46
|
-
*/
|
|
47
|
-
send(_tr: Transaction | null, _oldState: EditorState | null, newState: EditorState): void;
|
|
48
|
-
/**
|
|
49
|
-
* Called when we receive steps from the service
|
|
50
|
-
*/
|
|
51
|
-
private onStepsAdded;
|
|
52
|
-
private throttledCatchup;
|
|
53
|
-
private fitlerQueue;
|
|
54
|
-
private updateDocumentWithMetadata;
|
|
55
|
-
private applyLocalsteps;
|
|
56
|
-
private getCurrentPmVersion;
|
|
57
|
-
private getUnconfirmedSteps;
|
|
58
|
-
/**
|
|
59
|
-
* Called when:
|
|
60
|
-
* * session established(offline -> online)
|
|
61
|
-
* * try to accept steps but version is behind.
|
|
62
|
-
*/
|
|
63
|
-
private catchup;
|
|
64
|
-
private onErrorHandled;
|
|
65
|
-
private pauseQueue?;
|
|
66
|
-
private queue;
|
|
67
|
-
private queueSteps;
|
|
68
|
-
private processQueue;
|
|
69
|
-
private processSteps;
|
|
70
|
-
/**
|
|
71
|
-
* Send messages, such as telepointers, to other participants.
|
|
72
|
-
*/
|
|
73
|
-
sendMessage(data: any): void;
|
|
74
|
-
private sendPresence;
|
|
75
|
-
/**
|
|
76
|
-
* Called when a participant joins the session.
|
|
77
|
-
*
|
|
78
|
-
* We keep track of participants internally in this class, and emit the `presence` event to update
|
|
79
|
-
* the active avatars in the editor.
|
|
80
|
-
* This method will be triggered from backend to notify all participants to exchange presence
|
|
81
|
-
*
|
|
82
|
-
*/
|
|
83
|
-
private onPresenceJoined;
|
|
84
|
-
private onPresence;
|
|
85
|
-
/**
|
|
86
|
-
* Called when a metadata is changed.
|
|
87
|
-
*
|
|
88
|
-
*/
|
|
89
|
-
private onMetadataChanged;
|
|
90
|
-
/**
|
|
91
|
-
* Called when a participant leaves the session.
|
|
92
|
-
*
|
|
93
|
-
* We emit the `presence` event to update the active avatars in the editor.
|
|
94
|
-
*/
|
|
95
|
-
private onParticipantLeft;
|
|
96
|
-
/**
|
|
97
|
-
* Called when we receive an update event from another participant.
|
|
98
|
-
*/
|
|
99
|
-
private onParticipantUpdated;
|
|
100
|
-
/**
|
|
101
|
-
* Called when we receive a telepointer update from another
|
|
102
|
-
* participant.
|
|
103
|
-
*/
|
|
104
|
-
private onParticipantTelepointer;
|
|
105
|
-
private updateParticipant;
|
|
106
|
-
/**
|
|
107
|
-
* Keep list of participants up to date. Filter out inactive users etc.
|
|
108
|
-
*/
|
|
109
|
-
private updateParticipants;
|
|
110
|
-
private emitTelepointersFromSteps;
|
|
111
|
-
private disconnectedReasonMapper;
|
|
112
|
-
private onDisconnected;
|
|
113
|
-
destroy(): this;
|
|
114
|
-
disconnect(): this;
|
|
115
|
-
setTitle(title: string, broadcast?: boolean): void;
|
|
116
|
-
setEditorWidth(editorWidth: string, broadcast?: boolean): void;
|
|
117
|
-
setMetadata(metadata: Metadata): void;
|
|
118
|
-
getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
|
|
119
|
-
/**
|
|
120
|
-
* Unsubscribe from all events emitted by this provider.
|
|
121
|
-
*/
|
|
122
|
-
unsubscribeAll(): this;
|
|
123
|
-
}
|
|
124
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Provider } from './provider';
|
|
2
|
-
import { Socket, Config, ProductInformation } from './types';
|
|
3
|
-
export declare function createSocketIOSocket(url: string, auth?: (cb: (data: object) => void) => void, productInfo?: ProductInformation): Socket;
|
|
4
|
-
export declare function createSocketIOCollabProvider(config: Omit<Config, 'createSocket'>): Provider;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import type { Transaction } from 'prosemirror-state';
|
|
2
|
-
import type { Step } from 'prosemirror-transform';
|
|
3
|
-
import type { CollabParticipant, CollabEventTelepointerData as EditorCollabTelepointerData, CollabEventConnectionData as EditorCollabConnetedData, CollabEventInitData as EditorCollabInitData, CollabEventRemoteData as EditorCollabData, CollabEventPresenceData as EditorCollabPresenceData } from '@atlaskit/editor-common/collab';
|
|
4
|
-
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
5
|
-
import type { Manager } from 'socket.io-client';
|
|
6
|
-
import type { DisconnectReason } from './disconnected-reason-mapper';
|
|
7
|
-
export interface Storage {
|
|
8
|
-
get(key: string): Promise<string>;
|
|
9
|
-
set(key: string, value: string): Promise<void>;
|
|
10
|
-
delete(key: string): Promise<void>;
|
|
11
|
-
}
|
|
12
|
-
export interface Config {
|
|
13
|
-
url: string;
|
|
14
|
-
documentAri: string;
|
|
15
|
-
lifecycle?: Lifecycle;
|
|
16
|
-
storage?: Storage;
|
|
17
|
-
need404?: boolean;
|
|
18
|
-
createSocket: (path: string, auth?: (cb: (data: object) => void) => void, productInfo?: ProductInformation) => Socket;
|
|
19
|
-
analyticsClient?: AnalyticsWebClient;
|
|
20
|
-
getUser?(userId: string): Promise<Pick<CollabParticipant, 'avatar' | 'email' | 'name'> & {
|
|
21
|
-
userId: string;
|
|
22
|
-
}>;
|
|
23
|
-
permissionTokenRefresh?: () => Promise<string>;
|
|
24
|
-
productInfo?: ProductInformation;
|
|
25
|
-
}
|
|
26
|
-
interface SimpleEventEmitter {
|
|
27
|
-
on(event: string, fn: Function): SimpleEventEmitter;
|
|
28
|
-
}
|
|
29
|
-
export interface Socket extends SimpleEventEmitter {
|
|
30
|
-
id: string;
|
|
31
|
-
connect(): Socket;
|
|
32
|
-
emit(event: string, ...args: any[]): Socket;
|
|
33
|
-
close(): Socket;
|
|
34
|
-
io?: Manager;
|
|
35
|
-
}
|
|
36
|
-
export declare type LifecycleEvents = 'save' | 'restore';
|
|
37
|
-
export declare type EventHandler = () => void;
|
|
38
|
-
export interface Lifecycle {
|
|
39
|
-
on(event: LifecycleEvents, handler: EventHandler): void;
|
|
40
|
-
}
|
|
41
|
-
export declare type CollabConnectedPayload = EditorCollabConnetedData;
|
|
42
|
-
export interface CollabDisconnectedPayload {
|
|
43
|
-
reason: DisconnectReason;
|
|
44
|
-
sid: string;
|
|
45
|
-
}
|
|
46
|
-
export interface CollabErrorPayload {
|
|
47
|
-
status: number;
|
|
48
|
-
code: string;
|
|
49
|
-
message: string;
|
|
50
|
-
reason?: string;
|
|
51
|
-
}
|
|
52
|
-
export interface CollabInitPayload extends EditorCollabInitData {
|
|
53
|
-
doc: any;
|
|
54
|
-
version: number;
|
|
55
|
-
userId?: string;
|
|
56
|
-
metadata?: Metadata;
|
|
57
|
-
}
|
|
58
|
-
export interface CollabDataPayload extends EditorCollabData {
|
|
59
|
-
version: number;
|
|
60
|
-
json: StepJson[];
|
|
61
|
-
userIds: string[];
|
|
62
|
-
}
|
|
63
|
-
export declare type CollabTelepointerPayload = EditorCollabTelepointerData;
|
|
64
|
-
export declare type CollabPresencePayload = EditorCollabPresenceData;
|
|
65
|
-
export declare type CollabMetadataPayload = Metadata;
|
|
66
|
-
export declare type CollabLocalStepsPayload = {
|
|
67
|
-
steps: Step[];
|
|
68
|
-
};
|
|
69
|
-
export interface CollabEvents {
|
|
70
|
-
'metadata:changed': CollabMetadataPayload;
|
|
71
|
-
init: CollabInitPayload;
|
|
72
|
-
connected: CollabConnectedPayload;
|
|
73
|
-
disconnected: CollabDisconnectedPayload;
|
|
74
|
-
data: CollabDataPayload;
|
|
75
|
-
telepointer: CollabTelepointerPayload;
|
|
76
|
-
presence: CollabPresencePayload;
|
|
77
|
-
'local-steps': CollabLocalStepsPayload;
|
|
78
|
-
error: CollabErrorPayload;
|
|
79
|
-
entity: any;
|
|
80
|
-
}
|
|
81
|
-
export interface Metadata {
|
|
82
|
-
[key: string]: string | number | boolean;
|
|
83
|
-
}
|
|
84
|
-
export declare type InitPayload = {
|
|
85
|
-
doc: any;
|
|
86
|
-
version: number;
|
|
87
|
-
userId?: string;
|
|
88
|
-
metadata?: Metadata;
|
|
89
|
-
};
|
|
90
|
-
export declare type PresencePayload = {
|
|
91
|
-
sessionId: string;
|
|
92
|
-
userId: string;
|
|
93
|
-
clientId: string;
|
|
94
|
-
timestamp: number;
|
|
95
|
-
};
|
|
96
|
-
export declare type TelepointerPayload = PresencePayload & {
|
|
97
|
-
selection: {
|
|
98
|
-
type: 'textSelection' | 'nodeSelection';
|
|
99
|
-
anchor: number;
|
|
100
|
-
head: number;
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
export declare type StepJson = {
|
|
104
|
-
from?: number;
|
|
105
|
-
to?: number;
|
|
106
|
-
stepType?: string;
|
|
107
|
-
clientId: string;
|
|
108
|
-
userId: string;
|
|
109
|
-
};
|
|
110
|
-
export declare type StepsPayload = {
|
|
111
|
-
version: number;
|
|
112
|
-
steps: StepJson[];
|
|
113
|
-
};
|
|
114
|
-
export declare type ErrorPayload = {
|
|
115
|
-
message: string;
|
|
116
|
-
data?: {
|
|
117
|
-
status: number;
|
|
118
|
-
code?: string;
|
|
119
|
-
meta?: string | {
|
|
120
|
-
description: string;
|
|
121
|
-
reason?: string;
|
|
122
|
-
};
|
|
123
|
-
};
|
|
124
|
-
};
|
|
125
|
-
export declare type ChannelEvent = {
|
|
126
|
-
connected: {
|
|
127
|
-
sid: string;
|
|
128
|
-
initialized: boolean;
|
|
129
|
-
};
|
|
130
|
-
init: InitPayload;
|
|
131
|
-
reconnected: null;
|
|
132
|
-
'presence:joined': PresencePayload;
|
|
133
|
-
presence: PresencePayload;
|
|
134
|
-
'participant:left': PresencePayload;
|
|
135
|
-
'participant:telepointer': TelepointerPayload;
|
|
136
|
-
'participant:updated': PresencePayload;
|
|
137
|
-
'steps:commit': StepsPayload & {
|
|
138
|
-
userId: string;
|
|
139
|
-
};
|
|
140
|
-
'steps:added': StepsPayload;
|
|
141
|
-
'metadata:changed': Metadata;
|
|
142
|
-
error: ErrorPayload;
|
|
143
|
-
disconnect: {
|
|
144
|
-
reason: string;
|
|
145
|
-
};
|
|
146
|
-
};
|
|
147
|
-
export interface CatchupResponse {
|
|
148
|
-
doc?: string;
|
|
149
|
-
version?: number;
|
|
150
|
-
stepMaps?: any[];
|
|
151
|
-
metadata?: Metadata;
|
|
152
|
-
}
|
|
153
|
-
export interface CatchupOptions {
|
|
154
|
-
getCurrentPmVersion: () => number;
|
|
155
|
-
fetchCatchup: (fromVersion: number) => Promise<CatchupResponse>;
|
|
156
|
-
fitlerQueue: (condition: (stepsPayload: StepsPayload) => boolean) => void;
|
|
157
|
-
getUnconfirmedSteps: () => {
|
|
158
|
-
version: number;
|
|
159
|
-
steps: Step<any>[];
|
|
160
|
-
clientID: string | number;
|
|
161
|
-
origins: Transaction<any>[];
|
|
162
|
-
} | null | undefined;
|
|
163
|
-
updateDocumentWithMetadata: ({ doc, version, metadata, reserveCursor, }: CollabInitPayload) => void;
|
|
164
|
-
applyLocalsteps: (steps: Step[]) => void;
|
|
165
|
-
}
|
|
166
|
-
export declare type ProductInformation = {
|
|
167
|
-
product: string;
|
|
168
|
-
subProduct?: string;
|
|
169
|
-
};
|
|
170
|
-
export {};
|