@atlaskit/collab-provider 20.0.16 → 20.0.17
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 +6 -0
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/version-wrapper.js +1 -1
- package/package.json +2 -2
- package/provider/package.json +1 -8
- package/socket-io-provider/package.json +1 -8
- package/types/package.json +1 -8
- package/version-wrapper/package.json +1 -8
- package/dist/types-ts4.5/analytics/analytics-helper.d.ts +0 -15
- package/dist/types-ts4.5/analytics/performance.d.ts +0 -16
- package/dist/types-ts4.5/analytics/ufo.d.ts +0 -3
- package/dist/types-ts4.5/api/api.d.ts +0 -24
- package/dist/types-ts4.5/api/null-api.d.ts +0 -5
- package/dist/types-ts4.5/channel.d.ts +0 -83
- package/dist/types-ts4.5/config.d.ts +0 -35
- package/dist/types-ts4.5/connectivity/network.d.ts +0 -17
- package/dist/types-ts4.5/connectivity/reconnect-helper.d.ts +0 -8
- package/dist/types-ts4.5/connectivity/singleton.d.ts +0 -3
- package/dist/types-ts4.5/disconnected-reason-mapper.d.ts +0 -9
- package/dist/types-ts4.5/document/catchupv2.d.ts +0 -12
- package/dist/types-ts4.5/document/document-service.d.ts +0 -195
- package/dist/types-ts4.5/document/getConflictChanges.d.ts +0 -24
- package/dist/types-ts4.5/document/interface-document-service.d.ts +0 -37
- package/dist/types-ts4.5/document/null-document-service.d.ts +0 -20
- package/dist/types-ts4.5/document/step-queue-state.d.ts +0 -16
- package/dist/types-ts4.5/emitter.d.ts +0 -19
- package/dist/types-ts4.5/entry-points/provider.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/socket-io-provider.d.ts +0 -1
- package/dist/types-ts4.5/entry-points/types.d.ts +0 -2
- package/dist/types-ts4.5/entry-points/version-wrapper.d.ts +0 -1
- package/dist/types-ts4.5/errors/custom-errors.d.ts +0 -56
- package/dist/types-ts4.5/errors/error-code-mapper.d.ts +0 -3
- package/dist/types-ts4.5/errors/internal-errors.d.ts +0 -110
- package/dist/types-ts4.5/errors/ncs-errors.d.ts +0 -184
- package/dist/types-ts4.5/feature-flags/index.d.ts +0 -9
- package/dist/types-ts4.5/feature-flags/types.d.ts +0 -13
- package/dist/types-ts4.5/helpers/const.d.ts +0 -324
- package/dist/types-ts4.5/helpers/utils.d.ts +0 -72
- package/dist/types-ts4.5/index.d.ts +0 -1
- package/dist/types-ts4.5/metadata/metadata-service.d.ts +0 -25
- package/dist/types-ts4.5/namespace/namespace-service.d.ts +0 -14
- package/dist/types-ts4.5/participants/participants-helper.d.ts +0 -35
- package/dist/types-ts4.5/participants/participants-service.d.ts +0 -200
- package/dist/types-ts4.5/participants/participants-state.d.ts +0 -27
- package/dist/types-ts4.5/participants/telepointers-helper.d.ts +0 -4
- package/dist/types-ts4.5/provider/commit-step.d.ts +0 -41
- package/dist/types-ts4.5/provider/get-offline-steps-length.d.ts +0 -4
- package/dist/types-ts4.5/provider/index.d.ts +0 -206
- package/dist/types-ts4.5/socket-io-provider.d.ts +0 -6
- package/dist/types-ts4.5/types.d.ts +0 -256
- package/dist/types-ts4.5/version-wrapper.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.version = exports.nextMajorVersion = exports.name = void 0;
|
|
7
7
|
var name = exports.name = "@atlaskit/collab-provider";
|
|
8
|
-
var version = exports.version = "20.0.
|
|
8
|
+
var version = exports.version = "20.0.16";
|
|
9
9
|
var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
|
|
10
10
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
|
11
11
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "20.0.
|
|
3
|
+
"version": "20.0.17",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
38
38
|
"@atlaskit/prosemirror-collab": "^0.22.0",
|
|
39
39
|
"@atlaskit/react-ufo": "^6.7.0",
|
|
40
|
-
"@atlaskit/tmp-editor-statsig": "^
|
|
40
|
+
"@atlaskit/tmp-editor-statsig": "^103.0.0",
|
|
41
41
|
"@atlaskit/ufo": "^0.5.0",
|
|
42
42
|
"@atlaskit/util-service-support": "^6.4.0",
|
|
43
43
|
"@babel/runtime": "^7.0.0",
|
package/provider/package.json
CHANGED
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/entry-points/provider.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/entry-points/provider.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/entry-points/provider.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/entry-points/provider.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/entry-points/provider.d.ts"
|
|
15
8
|
}
|
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/entry-points/socket-io-provider.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/entry-points/socket-io-provider.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/entry-points/socket-io-provider.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/entry-points/socket-io-provider.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/entry-points/socket-io-provider.d.ts"
|
|
15
8
|
}
|
package/types/package.json
CHANGED
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/entry-points/types.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/entry-points/types.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/entry-points/types.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/entry-points/types.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/entry-points/types.d.ts"
|
|
15
8
|
}
|
|
@@ -4,12 +4,5 @@
|
|
|
4
4
|
"module": "../dist/esm/entry-points/version-wrapper.js",
|
|
5
5
|
"module:es2019": "../dist/es2019/entry-points/version-wrapper.js",
|
|
6
6
|
"sideEffects": false,
|
|
7
|
-
"types": "../dist/types/entry-points/version-wrapper.d.ts"
|
|
8
|
-
"typesVersions": {
|
|
9
|
-
">=4.5 <5.9": {
|
|
10
|
-
"*": [
|
|
11
|
-
"../dist/types-ts4.5/entry-points/version-wrapper.d.ts"
|
|
12
|
-
]
|
|
13
|
-
}
|
|
14
|
-
}
|
|
7
|
+
"types": "../dist/types/entry-points/version-wrapper.d.ts"
|
|
15
8
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
2
|
-
import type { ProviderError } from '@atlaskit/editor-common/collab';
|
|
3
|
-
import type { ActionAnalyticsEvent, EVENT_STATUS } from '../helpers/const';
|
|
4
|
-
export default class AnalyticsHelper {
|
|
5
|
-
analyticsClient: AnalyticsWebClient | undefined;
|
|
6
|
-
getAnalyticsClient: Promise<AnalyticsWebClient> | undefined;
|
|
7
|
-
documentAri: string;
|
|
8
|
-
subProduct: string | undefined;
|
|
9
|
-
constructor(documentAri: string, subProduct?: string, analyticsClient?: AnalyticsWebClient, getAnalyticsClient?: Promise<AnalyticsWebClient>);
|
|
10
|
-
sendErrorEvent(error: unknown, errorMessage: string): void;
|
|
11
|
-
sendProviderErrorEvent(error: ProviderError): void;
|
|
12
|
-
sendActionEvent(action: ActionAnalyticsEvent['eventAction'], status: EVENT_STATUS, attributes?: Omit<ActionAnalyticsEvent['attributes'], 'documentAri' | 'subProduct' | 'eventStatus'>): void;
|
|
13
|
-
private sendEvent;
|
|
14
|
-
private getUGCFreeErrorMessage;
|
|
15
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type AnalyticsHelper from './analytics-helper';
|
|
2
|
-
export declare enum MEASURE_NAME {
|
|
3
|
-
SOCKET_CONNECT = "socketConnect",
|
|
4
|
-
DOCUMENT_INIT = "documentInit",
|
|
5
|
-
COMMIT_UNCONFIRMED_STEPS = "commitUnconfirmedSteps",
|
|
6
|
-
PUBLISH_PAGE = "publishPage",
|
|
7
|
-
GET_CURRENT_STATE = "getCurrentState"
|
|
8
|
-
}
|
|
9
|
-
export declare const isPerformanceAPIAvailable: () => boolean;
|
|
10
|
-
export declare const measureMap: Map<string, number>;
|
|
11
|
-
export declare function startMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined): void;
|
|
12
|
-
export declare function stopMeasure(measureName: MEASURE_NAME, analyticsHelper: AnalyticsHelper | undefined, onMeasureComplete?: (duration: number, startTime: number) => void): {
|
|
13
|
-
duration: number;
|
|
14
|
-
startTime: number;
|
|
15
|
-
} | undefined;
|
|
16
|
-
export declare const shouldTelepointerBeSampled: () => boolean;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Config } from '../types';
|
|
2
|
-
import type { Channel } from '../channel';
|
|
3
|
-
import type { DocumentService } from '../document/document-service';
|
|
4
|
-
interface Step {
|
|
5
|
-
stepType: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* We create this API component, and export it under collab provider (e.g. provider.api.sendComment())
|
|
9
|
-
* From a design perspective, this makes it more disitinctive, and less confusing.
|
|
10
|
-
* Collab provider follows a state machine philosophy, whereas this new component does CRUD function calls
|
|
11
|
-
* In future we can add to this api class without adding complexity to provider
|
|
12
|
-
*
|
|
13
|
-
*/
|
|
14
|
-
export declare class Api {
|
|
15
|
-
private readonly config;
|
|
16
|
-
private documentService;
|
|
17
|
-
private readonly channel;
|
|
18
|
-
constructor(config: Config, documentService: DocumentService, channel: Channel);
|
|
19
|
-
addComment(steps: Step[]): Promise<{
|
|
20
|
-
message: any;
|
|
21
|
-
}>;
|
|
22
|
-
private submitComment;
|
|
23
|
-
}
|
|
24
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { Emitter } from './emitter';
|
|
2
|
-
import type { Config, ChannelEvent, Catchupv2Response, ReconcileResponse, GenerateDiffStepsResponseBody } from './types';
|
|
3
|
-
import type { CatchupEventReason } from './helpers/const';
|
|
4
|
-
import type { Socket } from 'socket.io-client';
|
|
5
|
-
import type AnalyticsHelper from './analytics/analytics-helper';
|
|
6
|
-
import type { Metadata } from '@atlaskit/editor-common/collab';
|
|
7
|
-
export declare class Channel extends Emitter<ChannelEvent> {
|
|
8
|
-
private readonly RATE_LIMIT_TYPE_NONE;
|
|
9
|
-
private readonly RATE_LIMIT_TYPE_SOFT;
|
|
10
|
-
private readonly RATE_LIMIT_TYPE_HARD;
|
|
11
|
-
private connected;
|
|
12
|
-
private readonly config;
|
|
13
|
-
private socket;
|
|
14
|
-
private reconnectHelper?;
|
|
15
|
-
private initialized;
|
|
16
|
-
private readonly analyticsHelper?;
|
|
17
|
-
private initExperience?;
|
|
18
|
-
private token?;
|
|
19
|
-
private network;
|
|
20
|
-
private disconnectTimer?;
|
|
21
|
-
private readonly rateLimitWindowDurationMs;
|
|
22
|
-
private rateLimitWindowStartMs;
|
|
23
|
-
private stepCounter;
|
|
24
|
-
private stepSizeCounter;
|
|
25
|
-
private maxStepSize;
|
|
26
|
-
constructor(config: Config, analyticsHelper: AnalyticsHelper);
|
|
27
|
-
getInitialized: () => boolean;
|
|
28
|
-
getConnected: () => boolean;
|
|
29
|
-
getSocket: () => Socket | null;
|
|
30
|
-
getToken: () => string | undefined;
|
|
31
|
-
getChannelToken: () => Promise<string | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Connect to collab service using websockets
|
|
34
|
-
*/
|
|
35
|
-
connect(shouldInitialize?: boolean): void;
|
|
36
|
-
onAnyOutgoingHandler(currentTimeMs: number, args: any[]): void;
|
|
37
|
-
private commonHeaders;
|
|
38
|
-
private isLimitExceeded;
|
|
39
|
-
private handlePermissionInvalidateToken;
|
|
40
|
-
private onConnectError;
|
|
41
|
-
private onReconnectError;
|
|
42
|
-
private onConnect;
|
|
43
|
-
private onReceiveData;
|
|
44
|
-
fetchCatchupv2: (fromVersion: number, clientId: number | string | undefined, catchUpOutofSync: boolean | undefined, reason?: CatchupEventReason, sessionId?: string) => Promise<Catchupv2Response>;
|
|
45
|
-
fetchReconcile: (currentStateDoc: string, reason: string) => Promise<ReconcileResponse>;
|
|
46
|
-
/**
|
|
47
|
-
* Fetch generated diff steps from the back-end service
|
|
48
|
-
* @param currentStateDoc - The current state document
|
|
49
|
-
* @param reason - The reason for generating diff steps
|
|
50
|
-
* @returns {Promise<GenerateDiffStepsResponseBody>} - The generated diff steps response body
|
|
51
|
-
*/
|
|
52
|
-
fetchGeneratedDiffSteps: (currentStateDoc: string, reason: string) => Promise<GenerateDiffStepsResponseBody>;
|
|
53
|
-
/**
|
|
54
|
-
* Send message to the back-end service over the channel. Timestamp will be added server side.
|
|
55
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
56
|
-
* @throws {NotConnectedError} Channel not connected
|
|
57
|
-
*/
|
|
58
|
-
broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], "timestamp">, callback?: Function) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Send metadata to the back-end service over the channel
|
|
61
|
-
* @throws {NotInitializedError} Channel not initialized
|
|
62
|
-
* @throws {NotConnectedError} Channel not connected
|
|
63
|
-
*/
|
|
64
|
-
sendMetadata: (metadata: Metadata) => void;
|
|
65
|
-
sendPresenceJoined: () => void;
|
|
66
|
-
onOnlineHandler: () => void;
|
|
67
|
-
/**
|
|
68
|
-
* Unbinds event listeners and timers used when handling connection auto-close when tab is hidden
|
|
69
|
-
*/
|
|
70
|
-
private cleanupAutoDisconnect;
|
|
71
|
-
/**
|
|
72
|
-
* Cleanup the visiblitychange listener upon Collab Provider destroy
|
|
73
|
-
* Value set when the listener is binded in addVisiblityListener
|
|
74
|
-
*/
|
|
75
|
-
private unbindVisibilityListener;
|
|
76
|
-
/**
|
|
77
|
-
* Adds an event listener for visibilitychange events to automatically close the socket
|
|
78
|
-
* connection if tab is in background for longer than disconnectDelay
|
|
79
|
-
*/
|
|
80
|
-
private addVisiblityListener;
|
|
81
|
-
autoDisconnect: (disconnectTimer: ReturnType<typeof setTimeout> | undefined, disconnectDelay: number) => NodeJS.Timeout | undefined;
|
|
82
|
-
disconnect(): void;
|
|
83
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* https://socket.io/docs/v4/client-options/#randomizationfactor
|
|
3
|
-
* 1st reconnection attempt happens between 100 - 300 ms
|
|
4
|
-
* 2nd reconnection attempt happens between 200 - 600 ms
|
|
5
|
-
* 3rd reconnection attempt happens between 400 - 1200 ms
|
|
6
|
-
* 4th 800 - 2400 ms
|
|
7
|
-
* 5th 1600 - 4800 ms
|
|
8
|
-
* 6th 3200 - 9600 ms
|
|
9
|
-
* 7th 6400 - 19200 ms
|
|
10
|
-
* 8th 12800 - 38400 ms
|
|
11
|
-
* 9th 25600 - 76800 ms
|
|
12
|
-
* 10th 51200 - 128000 ms (capped at max delay)
|
|
13
|
-
* nth 128000 ms
|
|
14
|
-
*/
|
|
15
|
-
export declare const SOCKET_IO_OPTIONS: {
|
|
16
|
-
RECONNECTION_DELAY_MAX: number;
|
|
17
|
-
RECONNECTION_DELAY: number;
|
|
18
|
-
RANDOMIZATION_FACTOR: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* 1st reconnection attempt happens between 250 - 1750 ms
|
|
22
|
-
* 2nd reconnection attempt happens between 500 - 3500 ms
|
|
23
|
-
* 3rd reconnection attempt happens between 1000 - 7000 ms
|
|
24
|
-
* 4th 2000 - 14000 ms
|
|
25
|
-
* 5th 4000 - 28000 ms
|
|
26
|
-
* 6th 8000 - 56000 ms
|
|
27
|
-
* 7th 16000 - 112000 ms
|
|
28
|
-
* 8th 32000 - 128000 ms (capped at max delay)
|
|
29
|
-
* nth 128000 ms
|
|
30
|
-
*/
|
|
31
|
-
export declare const SOCKET_IO_OPTIONS_WITH_HIGH_JITTER: {
|
|
32
|
-
RECONNECTION_DELAY_MAX: number;
|
|
33
|
-
RECONNECTION_DELAY: number;
|
|
34
|
-
RANDOMIZATION_FACTOR: number;
|
|
35
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare enum NetworkStatus {
|
|
2
|
-
ONLINE = "ONLINE",
|
|
3
|
-
OFFLINE = "OFFLINE"
|
|
4
|
-
}
|
|
5
|
-
export interface NetworkProps {
|
|
6
|
-
initialStatus?: NetworkStatus;
|
|
7
|
-
onlineCallback?: () => void;
|
|
8
|
-
}
|
|
9
|
-
export default class Network {
|
|
10
|
-
status?: NetworkStatus;
|
|
11
|
-
onlineCallback?: () => void;
|
|
12
|
-
constructor(props?: NetworkProps);
|
|
13
|
-
private offlineHandler;
|
|
14
|
-
private onlineHandler;
|
|
15
|
-
getStatus(): NetworkStatus | null;
|
|
16
|
-
destroy(): void;
|
|
17
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { DisconnectReason } from '@atlaskit/editor-common/collab';
|
|
2
|
-
export declare const socketIOReasons: {
|
|
3
|
-
IO_CLIENT_DISCONNECT: string;
|
|
4
|
-
IO_SERVER_DISCONNECT: string;
|
|
5
|
-
TRANSPORT_CLOSED: string;
|
|
6
|
-
TRANSPORT_ERROR: string;
|
|
7
|
-
PING_TIMEOUT: string;
|
|
8
|
-
};
|
|
9
|
-
export declare const disconnectedReasonMapper: (reason: string) => DisconnectReason;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Catchupv2Options } from '../types';
|
|
2
|
-
import type { StepJson } from '@atlaskit/editor-common/collab';
|
|
3
|
-
export declare const catchupv2: (opt: Catchupv2Options) => Promise<boolean>;
|
|
4
|
-
/**
|
|
5
|
-
* Checks if we're out of sync with the backend because catchup failed to apply, and thus the doc should be reset.
|
|
6
|
-
* @param fromVersion The document's PM version from before we applied catchup
|
|
7
|
-
* @param currentVersion The document's PM version after we applied catchup
|
|
8
|
-
* @param steps Steps returned to us by catchup
|
|
9
|
-
* @param clientId The ID of the currently connected session (one user can have multiple if theu have multiple tabs open)
|
|
10
|
-
* @returns True if we're out of sync, false if not.
|
|
11
|
-
*/
|
|
12
|
-
export declare const isOutOfSync: (fromVersion: number, currentVersion: number, steps: StepJson[], clientId: string | number) => boolean;
|
|
@@ -1,195 +0,0 @@
|
|
|
1
|
-
import type { ResolvedEditorState, SyncUpErrorFunction, CollabEvents, CollabInitPayload } from '@atlaskit/editor-common/collab';
|
|
2
|
-
import { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
import type { EditorState } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
5
|
-
import type { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
6
|
-
import type { Catchupv2Response, ChannelEvent, GenerateDiffStepsResponseBody, ReconcileResponse, ReconnectionMetadata, StepsPayload } from '../types';
|
|
7
|
-
import type { MetadataService } from '../metadata/metadata-service';
|
|
8
|
-
import { CatchupEventReason } from '../helpers/const';
|
|
9
|
-
import type AnalyticsHelper from '../analytics/analytics-helper';
|
|
10
|
-
import type { InternalError } from '../errors/internal-errors';
|
|
11
|
-
import type { ParticipantsService } from '../participants/participants-service';
|
|
12
|
-
import type { DocumentServiceInterface } from './interface-document-service';
|
|
13
|
-
import type { GetResolvedEditorStateReason } from '@atlaskit/editor-common/types';
|
|
14
|
-
import type { ADFEntity } from '@atlaskit/adf-utils/types';
|
|
15
|
-
import type { DebouncedFunc } from 'lodash';
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
export declare class DocumentService implements DocumentServiceInterface {
|
|
20
|
-
private participantsService;
|
|
21
|
-
private analyticsHelper;
|
|
22
|
-
private fetchCatchupv2;
|
|
23
|
-
private fetchReconcile;
|
|
24
|
-
private fetchGeneratedDiffSteps;
|
|
25
|
-
private providerEmitCallback;
|
|
26
|
-
private broadcast;
|
|
27
|
-
private getUserId;
|
|
28
|
-
private metadataService;
|
|
29
|
-
private isNameSpaceLocked;
|
|
30
|
-
private enableErrorOnFailedDocumentApply;
|
|
31
|
-
private options;
|
|
32
|
-
private getConnected;
|
|
33
|
-
private getState;
|
|
34
|
-
private onSyncUpError?;
|
|
35
|
-
private stepQueue;
|
|
36
|
-
private stepRejectCounter;
|
|
37
|
-
private aggressiveCatchup;
|
|
38
|
-
private catchUpOutofSync;
|
|
39
|
-
private hasRecovered;
|
|
40
|
-
private commitStepService;
|
|
41
|
-
private timeout;
|
|
42
|
-
private timeoutExceeded;
|
|
43
|
-
private clientId?;
|
|
44
|
-
onErrorHandled: (error: InternalError) => void;
|
|
45
|
-
/**
|
|
46
|
-
*
|
|
47
|
-
* @param participantsService - The participants service, used when users are detected active when making changes to the document
|
|
48
|
-
* and to emit their telepointers from steps they add
|
|
49
|
-
* @param analyticsHelper - Helper for analytics events
|
|
50
|
-
* @param fetchCatchupv2 - Step based - Function to fetch "catchupv2" data, data required to rebase current steps to the latest version.
|
|
51
|
-
* @param fetchReconcile - Function to call "reconcile" from NCS backend
|
|
52
|
-
* @param fetchGeneratedDiffSteps - Function to call "generateDiffSteps" from NCS backend
|
|
53
|
-
* @param providerEmitCallback - Callback for emitting events to listeners on the provider
|
|
54
|
-
* @param broadcast - Callback for broadcasting events to other clients
|
|
55
|
-
* @param getUserId - Callback to fetch the current user's ID
|
|
56
|
-
* @param onErrorHandled - Callback to handle
|
|
57
|
-
* @param metadataService
|
|
58
|
-
* @param isNameSpaceLocked
|
|
59
|
-
* @param enableErrorOnFailedDocumentApply - Enable failed document update exceptions.
|
|
60
|
-
* @param options.__livePage
|
|
61
|
-
* @param options
|
|
62
|
-
* @param getConnected - if the channel is currently connected
|
|
63
|
-
* @example
|
|
64
|
-
*/
|
|
65
|
-
constructor(participantsService: ParticipantsService, analyticsHelper: AnalyticsHelper | undefined, fetchCatchupv2: (fromVersion: number, clientId: number | string | undefined, catchUpOutofSync: boolean) => Promise<Catchupv2Response>, fetchReconcile: (currentStateDoc: string, reason: string) => Promise<ReconcileResponse>, fetchGeneratedDiffSteps: (currentStateDoc: string, reason: string) => Promise<GenerateDiffStepsResponseBody>, providerEmitCallback: (evt: keyof CollabEvents, data: any) => void, broadcast: <K extends keyof ChannelEvent>(type: K, data: Omit<ChannelEvent[K], 'timestamp'>, callback?: Function) => void, getUserId: () => string | undefined, onErrorHandled: (error: InternalError) => void, metadataService: MetadataService, isNameSpaceLocked: () => boolean, enableErrorOnFailedDocumentApply: boolean | undefined, options: {
|
|
66
|
-
__livePage: boolean;
|
|
67
|
-
} | undefined, getConnected: () => boolean);
|
|
68
|
-
/**
|
|
69
|
-
* To prevent calling catchup to often, use lodash throttle to reduce the frequency
|
|
70
|
-
* @param reason - optional reason to attach.
|
|
71
|
-
*/
|
|
72
|
-
throttledCatchupv2: DebouncedFunc<(reason?: CatchupEventReason, reconnectionMetadata?: ReconnectionMetadata, sessionId?: string) => Promise<void>>;
|
|
73
|
-
/**
|
|
74
|
-
* Called when:
|
|
75
|
-
* * session established(offline -> online)
|
|
76
|
-
* * try to accept steps but version is behind.
|
|
77
|
-
* @param reason - optional reason to attach.
|
|
78
|
-
* @param reconnectionMetadata
|
|
79
|
-
* @example
|
|
80
|
-
*/
|
|
81
|
-
private catchupv2;
|
|
82
|
-
private getVersionFromCollabState;
|
|
83
|
-
getCurrentPmVersion: () => number;
|
|
84
|
-
/**
|
|
85
|
-
* In the event we reconnect check if we have existing unconfirmed steps and if so
|
|
86
|
-
* notify the editor that we have a potential conflict to resolve on the frontend.
|
|
87
|
-
*
|
|
88
|
-
* @param data remote steps payload
|
|
89
|
-
* @param steps
|
|
90
|
-
* @example
|
|
91
|
-
*/
|
|
92
|
-
private notifyReconnectionConflict;
|
|
93
|
-
private processQueue;
|
|
94
|
-
getCurrentState: () => Promise<ResolvedEditorState>;
|
|
95
|
-
private isStepsFromNewClientIdForSameUserId;
|
|
96
|
-
private processSteps;
|
|
97
|
-
getUnconfirmedStepsOrigins: () => readonly Transaction[] | undefined;
|
|
98
|
-
getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
|
|
99
|
-
private applyLocalSteps;
|
|
100
|
-
/**
|
|
101
|
-
* Called when we receive steps from the service
|
|
102
|
-
* @param data
|
|
103
|
-
* @example
|
|
104
|
-
*/
|
|
105
|
-
onStepsAdded: (data: StepsPayload) => void;
|
|
106
|
-
obfuscateStepsAndState: (unconfirmedSteps: readonly ProseMirrorStep[] | undefined, currentState?: ResolvedEditorState<JSONDocNode>) => {
|
|
107
|
-
obfuscatedSteps: string | {
|
|
108
|
-
stepType: {
|
|
109
|
-
type: string;
|
|
110
|
-
contentTypes: string | null;
|
|
111
|
-
};
|
|
112
|
-
stepContent: ADFEntity[] | null;
|
|
113
|
-
stepPositions: {
|
|
114
|
-
pos?: number | undefined;
|
|
115
|
-
insert?: number | undefined;
|
|
116
|
-
gapFrom?: number | undefined;
|
|
117
|
-
gapTo?: number | undefined;
|
|
118
|
-
from?: number | undefined;
|
|
119
|
-
to?: number | undefined;
|
|
120
|
-
};
|
|
121
|
-
stepMetadata: {
|
|
122
|
-
createdOffline?: boolean;
|
|
123
|
-
prevStepId?: string;
|
|
124
|
-
rebased?: boolean;
|
|
125
|
-
reqId?: string;
|
|
126
|
-
schemaVersion?: string;
|
|
127
|
-
source?: string;
|
|
128
|
-
stepId?: string;
|
|
129
|
-
traceId?: string;
|
|
130
|
-
unconfirmedStepAfterRecovery?: boolean;
|
|
131
|
-
} | undefined;
|
|
132
|
-
}[];
|
|
133
|
-
obfuscatedDoc: string | ADFEntity | null | undefined;
|
|
134
|
-
};
|
|
135
|
-
onRestore: ({ doc, version, metadata, targetClientId, }: CollabInitPayload) => Promise<void>;
|
|
136
|
-
getFinalAcknowledgedState: (reason: GetResolvedEditorStateReason) => Promise<ResolvedEditorState>;
|
|
137
|
-
/**
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
*/
|
|
141
|
-
getIsNamespaceLocked(): boolean;
|
|
142
|
-
updateDocument: ({ doc, version, metadata, reserveCursor, caller }: CollabInitPayload) => void;
|
|
143
|
-
private updateDocumentAnalytics;
|
|
144
|
-
private validatePMJSONDocument;
|
|
145
|
-
/**
|
|
146
|
-
* Commit the unconfirmed local steps to the back-end service
|
|
147
|
-
* @param reason
|
|
148
|
-
* @throws {Error} Couldn't sync the steps after retrying 30 times
|
|
149
|
-
* @example
|
|
150
|
-
*/
|
|
151
|
-
commitUnconfirmedSteps: (reason: GetResolvedEditorStateReason) => Promise<void>;
|
|
152
|
-
/**
|
|
153
|
-
*
|
|
154
|
-
* @param root0
|
|
155
|
-
* @param root0.getState
|
|
156
|
-
* @param root0.onSyncUpError
|
|
157
|
-
* @param root0.clientId
|
|
158
|
-
* @example
|
|
159
|
-
*/
|
|
160
|
-
setup({ getState, onSyncUpError, clientId, }: {
|
|
161
|
-
clientId: number | string | undefined;
|
|
162
|
-
getState: () => EditorState;
|
|
163
|
-
onSyncUpError?: SyncUpErrorFunction;
|
|
164
|
-
}): this;
|
|
165
|
-
/**
|
|
166
|
-
* We can use this function to throttle/delay
|
|
167
|
-
* Any send steps operation
|
|
168
|
-
*
|
|
169
|
-
* The getState function will return the current EditorState
|
|
170
|
-
* from the EditorView.
|
|
171
|
-
* @param sendAnalyticsEvent
|
|
172
|
-
* @param reason
|
|
173
|
-
* @example
|
|
174
|
-
*/
|
|
175
|
-
sendStepsFromCurrentState(sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason): void;
|
|
176
|
-
onStepRejectedError: () => void;
|
|
177
|
-
/**
|
|
178
|
-
* If we are going to commit unconfirmed steps
|
|
179
|
-
* we need to lock them to ensure they don't get
|
|
180
|
-
* mutated in: `packages/editor/editor-plugin-collab-edit/src/pm-plugins/mergeUnconfirmed.ts`
|
|
181
|
-
*/
|
|
182
|
-
lockSteps: () => void;
|
|
183
|
-
lockStepOrigins: (origins: readonly Transaction[] | undefined) => void;
|
|
184
|
-
/**
|
|
185
|
-
* Send steps from transaction to other participants
|
|
186
|
-
* It needs the superfluous arguments because we keep the interface of the send API the same as the Synchrony plugin
|
|
187
|
-
* @param tr
|
|
188
|
-
* @param _oldState
|
|
189
|
-
* @param newState
|
|
190
|
-
* @param sendAnalyticsEvent
|
|
191
|
-
* @param reason
|
|
192
|
-
* @example
|
|
193
|
-
*/
|
|
194
|
-
send(tr: Transaction | null, _oldState: EditorState | null, _newState: EditorState, sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason): void;
|
|
195
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
2
|
-
import type { Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
3
|
-
import type { ConflictChanges } from '@atlaskit/editor-common/collab';
|
|
4
|
-
import type { Rebaseable } from '@atlaskit/prosemirror-collab';
|
|
5
|
-
interface Options {
|
|
6
|
-
localSteps: readonly Rebaseable[];
|
|
7
|
-
remoteSteps: ProseMirrorStep[];
|
|
8
|
-
tr: Transaction;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Gets the conflicts between the local document and the remote document based on steps.
|
|
12
|
-
* It assumes the steps will be rebased using the `prosemirror-collab` algorithm synchronously after this
|
|
13
|
-
* Therefore the `tr` property is based on the document before rebasing.
|
|
14
|
-
*
|
|
15
|
-
* In the future we could possibly use `prosemirror-recreate-steps` (or similar approach)
|
|
16
|
-
* and tweak this to work for arbitrary diffs between offline and remote documents.
|
|
17
|
-
*
|
|
18
|
-
* @param localSteps Local steps applied between now and the server steps
|
|
19
|
-
* @param remoteSteps Steps retrieved from the server
|
|
20
|
-
* @param tr Transaction of the current document (expected to happen with local steps applied, before remote are applied)
|
|
21
|
-
* @returns All the conflicts (inserted + deleted) which can be applied to the current document
|
|
22
|
-
*/
|
|
23
|
-
export declare function getConflictChanges({ localSteps, remoteSteps, tr }: Options): ConflictChanges;
|
|
24
|
-
export {};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { ResolvedEditorState, SyncUpErrorFunction } from '@atlaskit/editor-common/collab';
|
|
2
|
-
import type { Step as ProseMirrorStep } from '@atlaskit/editor-prosemirror/transform';
|
|
3
|
-
import type { EditorState, Transaction } from '@atlaskit/editor-prosemirror/state';
|
|
4
|
-
import type { InternalError } from '../errors/internal-errors';
|
|
5
|
-
import type { GetResolvedEditorStateReason } from '@atlaskit/editor-common/types';
|
|
6
|
-
export interface DocumentServiceInterface {
|
|
7
|
-
getCurrentPmVersion: () => number;
|
|
8
|
-
getCurrentState: () => Promise<ResolvedEditorState>;
|
|
9
|
-
getFinalAcknowledgedState: (reason: GetResolvedEditorStateReason) => Promise<ResolvedEditorState>;
|
|
10
|
-
getIsNamespaceLocked: () => boolean;
|
|
11
|
-
getUnconfirmedSteps: () => readonly ProseMirrorStep[] | undefined;
|
|
12
|
-
onErrorHandled: (error: InternalError) => void;
|
|
13
|
-
onRestore: (params: {
|
|
14
|
-
doc: any;
|
|
15
|
-
metadata: any;
|
|
16
|
-
version: number;
|
|
17
|
-
}) => void;
|
|
18
|
-
onStepRejectedError: () => void;
|
|
19
|
-
onStepsAdded: (data: {
|
|
20
|
-
steps: any[];
|
|
21
|
-
version: number;
|
|
22
|
-
}) => void;
|
|
23
|
-
send: (tr: Transaction | null, oldState: EditorState | null, newState: EditorState, sendAnalyticsEvent?: boolean) => void;
|
|
24
|
-
sendStepsFromCurrentState: (sendAnalyticsEvent?: boolean, reason?: GetResolvedEditorStateReason) => void;
|
|
25
|
-
setup: (params: {
|
|
26
|
-
clientId: number | string | undefined;
|
|
27
|
-
getState: () => EditorState;
|
|
28
|
-
onSyncUpError?: SyncUpErrorFunction;
|
|
29
|
-
}) => this;
|
|
30
|
-
throttledCatchupv2: () => void;
|
|
31
|
-
updateDocument: (params: {
|
|
32
|
-
doc: any;
|
|
33
|
-
metadata: any;
|
|
34
|
-
reserveCursor?: boolean;
|
|
35
|
-
version: number;
|
|
36
|
-
}) => void;
|
|
37
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ResolvedEditorState } from '@atlaskit/editor-common/collab';
|
|
2
|
-
import type { DocumentServiceInterface } from './interface-document-service';
|
|
3
|
-
import type { GetResolvedEditorStateReason } from '@atlaskit/editor-common/types';
|
|
4
|
-
export declare class NullDocumentService implements DocumentServiceInterface {
|
|
5
|
-
setup: () => this;
|
|
6
|
-
updateDocument(): void;
|
|
7
|
-
onRestore(): void;
|
|
8
|
-
onStepsAdded(): void;
|
|
9
|
-
onStepRejectedError(): void;
|
|
10
|
-
send(): void;
|
|
11
|
-
sendStepsFromCurrentState(): void;
|
|
12
|
-
throttledCatchupv2(): void;
|
|
13
|
-
getCurrentState(): Promise<ResolvedEditorState>;
|
|
14
|
-
getFinalAcknowledgedState(reason: GetResolvedEditorStateReason): Promise<ResolvedEditorState>;
|
|
15
|
-
getIsNamespaceLocked(): boolean;
|
|
16
|
-
getUnconfirmedSteps(): undefined;
|
|
17
|
-
getUnconfirmedStepsOrigins(): undefined;
|
|
18
|
-
getCurrentPmVersion(): number;
|
|
19
|
-
onErrorHandled: () => void;
|
|
20
|
-
}
|