@atlaskit/collab-provider 9.1.0 → 9.2.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 +6 -0
- package/dist/cjs/provider/index.js +36 -13
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/provider/index.js +35 -14
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/provider/index.js +36 -13
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/provider/index.d.ts +6 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types-ts4.5/provider/index.d.ts +6 -0
- package/dist/types-ts4.5/types.d.ts +1 -0
- package/package.json +2 -2
- package/report.api.md +2 -0
- package/tmp/api-report-tmp.d.ts +564 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/collab-provider
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`ef726a72028`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ef726a72028) - adding provider catchup when initial draft timestamp exceeds stale timeout
|
|
8
|
+
|
|
3
9
|
## 9.1.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -30,6 +30,7 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
|
|
|
30
30
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
31
31
|
var logger = (0, _utils.createLogger)('Provider', 'black');
|
|
32
32
|
var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
|
|
33
|
+
var PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
|
|
33
34
|
|
|
34
35
|
var MAX_STEP_REJECTED_ERROR = 15;
|
|
35
36
|
exports.MAX_STEP_REJECTED_ERROR = MAX_STEP_REJECTED_ERROR;
|
|
@@ -75,20 +76,27 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
75
76
|
sid: sid,
|
|
76
77
|
initial: !initialized
|
|
77
78
|
});
|
|
78
|
-
|
|
79
|
-
//
|
|
79
|
+
|
|
80
|
+
// Early initialization with initial draft passed via provider
|
|
80
81
|
if (_this.initialDraft && initialized && !_this.isProviderInitialized) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
//
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
82
|
+
// Call catchup if the draft has become stale since being passed to provider
|
|
83
|
+
if (_this.isDraftTimestampStale()) {
|
|
84
|
+
_this.documentService.throttledCatchup();
|
|
85
|
+
}
|
|
86
|
+
// If the initial draft is already up to date, update the document with that of the initial draft
|
|
87
|
+
else {
|
|
88
|
+
var _this$initialDraft = _this.initialDraft,
|
|
89
|
+
document = _this$initialDraft.document,
|
|
90
|
+
version = _this$initialDraft.version,
|
|
91
|
+
metadata = _this$initialDraft.metadata;
|
|
92
|
+
// Initial document, version, metadata from initial draft
|
|
93
|
+
_this.documentService.updateDocument({
|
|
94
|
+
doc: document,
|
|
95
|
+
version: version,
|
|
96
|
+
metadata: metadata
|
|
97
|
+
});
|
|
98
|
+
_this.metadataService.updateMetadata(metadata);
|
|
99
|
+
}
|
|
92
100
|
_this.isProviderInitialized = true;
|
|
93
101
|
}
|
|
94
102
|
// If already initialized, `connected` means reconnected
|
|
@@ -316,6 +324,21 @@ var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
316
324
|
}
|
|
317
325
|
}
|
|
318
326
|
|
|
327
|
+
/**
|
|
328
|
+
* Checks the provider's initial draft timestamp to determine if it is stale.
|
|
329
|
+
* Returns true only if the time elapsed since the draft timestamp is greater than or
|
|
330
|
+
* equal to a predetermined timeout. Returns false in all other cases.
|
|
331
|
+
*/
|
|
332
|
+
}, {
|
|
333
|
+
key: "isDraftTimestampStale",
|
|
334
|
+
value: function isDraftTimestampStale() {
|
|
335
|
+
var _this$initialDraft2;
|
|
336
|
+
if (!((_this$initialDraft2 = this.initialDraft) !== null && _this$initialDraft2 !== void 0 && _this$initialDraft2.timestamp)) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
|
|
340
|
+
}
|
|
341
|
+
|
|
319
342
|
/**
|
|
320
343
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
321
344
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
|
@@ -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 = "9.
|
|
9
|
+
var version = "9.2.0";
|
|
10
10
|
exports.version = version;
|
|
11
11
|
var nextMajorVersion = function nextMajorVersion() {
|
|
12
12
|
return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
|
package/dist/cjs/version.json
CHANGED
|
@@ -12,6 +12,7 @@ import { ParticipantsService } from '../participants/participants-service';
|
|
|
12
12
|
import { errorCodeMapper } from '../errors/error-code-mapper';
|
|
13
13
|
const logger = createLogger('Provider', 'black');
|
|
14
14
|
const OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
|
|
15
|
+
const PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
|
|
15
16
|
|
|
16
17
|
export const MAX_STEP_REJECTED_ERROR = 15;
|
|
17
18
|
export class Provider extends Emitter {
|
|
@@ -51,21 +52,28 @@ export class Provider extends Emitter {
|
|
|
51
52
|
sid,
|
|
52
53
|
initial: !initialized
|
|
53
54
|
});
|
|
54
|
-
|
|
55
|
-
//
|
|
55
|
+
|
|
56
|
+
// Early initialization with initial draft passed via provider
|
|
56
57
|
if (this.initialDraft && initialized && !this.isProviderInitialized) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
58
|
+
// Call catchup if the draft has become stale since being passed to provider
|
|
59
|
+
if (this.isDraftTimestampStale()) {
|
|
60
|
+
this.documentService.throttledCatchup();
|
|
61
|
+
}
|
|
62
|
+
// If the initial draft is already up to date, update the document with that of the initial draft
|
|
63
|
+
else {
|
|
64
|
+
const {
|
|
65
|
+
document,
|
|
66
|
+
version,
|
|
67
|
+
metadata
|
|
68
|
+
} = this.initialDraft;
|
|
69
|
+
// Initial document, version, metadata from initial draft
|
|
70
|
+
this.documentService.updateDocument({
|
|
71
|
+
doc: document,
|
|
72
|
+
version,
|
|
73
|
+
metadata
|
|
74
|
+
});
|
|
75
|
+
this.metadataService.updateMetadata(metadata);
|
|
76
|
+
}
|
|
69
77
|
this.isProviderInitialized = true;
|
|
70
78
|
}
|
|
71
79
|
// If already initialized, `connected` means reconnected
|
|
@@ -261,6 +269,19 @@ export class Provider extends Emitter {
|
|
|
261
269
|
}
|
|
262
270
|
}
|
|
263
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Checks the provider's initial draft timestamp to determine if it is stale.
|
|
274
|
+
* Returns true only if the time elapsed since the draft timestamp is greater than or
|
|
275
|
+
* equal to a predetermined timeout. Returns false in all other cases.
|
|
276
|
+
*/
|
|
277
|
+
isDraftTimestampStale() {
|
|
278
|
+
var _this$initialDraft;
|
|
279
|
+
if (!((_this$initialDraft = this.initialDraft) !== null && _this$initialDraft !== void 0 && _this$initialDraft.timestamp)) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
|
|
283
|
+
}
|
|
284
|
+
|
|
264
285
|
/**
|
|
265
286
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
266
287
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
package/dist/es2019/version.json
CHANGED
|
@@ -23,6 +23,7 @@ import { ParticipantsService } from '../participants/participants-service';
|
|
|
23
23
|
import { errorCodeMapper } from '../errors/error-code-mapper';
|
|
24
24
|
var logger = createLogger('Provider', 'black');
|
|
25
25
|
var OUT_OF_SYNC_PERIOD = 3 * 1000; // 3 seconds
|
|
26
|
+
var PRELOAD_DRAFT_SYNC_PERIOD = 15 * 1000; // 15 seconds
|
|
26
27
|
|
|
27
28
|
export var MAX_STEP_REJECTED_ERROR = 15;
|
|
28
29
|
export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
@@ -67,20 +68,27 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
67
68
|
sid: sid,
|
|
68
69
|
initial: !initialized
|
|
69
70
|
});
|
|
70
|
-
|
|
71
|
-
//
|
|
71
|
+
|
|
72
|
+
// Early initialization with initial draft passed via provider
|
|
72
73
|
if (_this.initialDraft && initialized && !_this.isProviderInitialized) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
//
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
74
|
+
// Call catchup if the draft has become stale since being passed to provider
|
|
75
|
+
if (_this.isDraftTimestampStale()) {
|
|
76
|
+
_this.documentService.throttledCatchup();
|
|
77
|
+
}
|
|
78
|
+
// If the initial draft is already up to date, update the document with that of the initial draft
|
|
79
|
+
else {
|
|
80
|
+
var _this$initialDraft = _this.initialDraft,
|
|
81
|
+
document = _this$initialDraft.document,
|
|
82
|
+
version = _this$initialDraft.version,
|
|
83
|
+
metadata = _this$initialDraft.metadata;
|
|
84
|
+
// Initial document, version, metadata from initial draft
|
|
85
|
+
_this.documentService.updateDocument({
|
|
86
|
+
doc: document,
|
|
87
|
+
version: version,
|
|
88
|
+
metadata: metadata
|
|
89
|
+
});
|
|
90
|
+
_this.metadataService.updateMetadata(metadata);
|
|
91
|
+
}
|
|
84
92
|
_this.isProviderInitialized = true;
|
|
85
93
|
}
|
|
86
94
|
// If already initialized, `connected` means reconnected
|
|
@@ -308,6 +316,21 @@ export var Provider = /*#__PURE__*/function (_Emitter) {
|
|
|
308
316
|
}
|
|
309
317
|
}
|
|
310
318
|
|
|
319
|
+
/**
|
|
320
|
+
* Checks the provider's initial draft timestamp to determine if it is stale.
|
|
321
|
+
* Returns true only if the time elapsed since the draft timestamp is greater than or
|
|
322
|
+
* equal to a predetermined timeout. Returns false in all other cases.
|
|
323
|
+
*/
|
|
324
|
+
}, {
|
|
325
|
+
key: "isDraftTimestampStale",
|
|
326
|
+
value: function isDraftTimestampStale() {
|
|
327
|
+
var _this$initialDraft2;
|
|
328
|
+
if (!((_this$initialDraft2 = this.initialDraft) !== null && _this$initialDraft2 !== void 0 && _this$initialDraft2.timestamp)) {
|
|
329
|
+
return false;
|
|
330
|
+
}
|
|
331
|
+
return Date.now() - this.initialDraft.timestamp >= PRELOAD_DRAFT_SYNC_PERIOD;
|
|
332
|
+
}
|
|
333
|
+
|
|
311
334
|
/**
|
|
312
335
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
313
336
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
package/dist/esm/version.json
CHANGED
|
@@ -59,6 +59,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
59
59
|
onSyncUpError?: SyncUpErrorFunction;
|
|
60
60
|
}): this;
|
|
61
61
|
private checkForCookies;
|
|
62
|
+
/**
|
|
63
|
+
* Checks the provider's initial draft timestamp to determine if it is stale.
|
|
64
|
+
* Returns true only if the time elapsed since the draft timestamp is greater than or
|
|
65
|
+
* equal to a predetermined timeout. Returns false in all other cases.
|
|
66
|
+
*/
|
|
67
|
+
private isDraftTimestampStale;
|
|
62
68
|
/**
|
|
63
69
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
64
70
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
package/dist/types/types.d.ts
CHANGED
|
@@ -59,6 +59,12 @@ export declare class Provider extends Emitter<CollabEvents> implements BaseEvent
|
|
|
59
59
|
onSyncUpError?: SyncUpErrorFunction;
|
|
60
60
|
}): this;
|
|
61
61
|
private checkForCookies;
|
|
62
|
+
/**
|
|
63
|
+
* Checks the provider's initial draft timestamp to determine if it is stale.
|
|
64
|
+
* Returns true only if the time elapsed since the draft timestamp is greater than or
|
|
65
|
+
* equal to a predetermined timeout. Returns false in all other cases.
|
|
66
|
+
*/
|
|
67
|
+
private isDraftTimestampStale;
|
|
62
68
|
/**
|
|
63
69
|
* Send steps from transaction to NCS (and as a consequence to other participants), called from the collab-edit plugin in the editor
|
|
64
70
|
* @param {Transaction} _tr Deprecated, included to keep API consistent with Synchrony provider
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/collab-provider",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "A provider for collaborative editing.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"atlassian": {
|
|
26
26
|
"team": "Editor Services",
|
|
27
27
|
"inPublicMirror": true,
|
|
28
|
-
"releaseModel": "
|
|
28
|
+
"releaseModel": "continuous"
|
|
29
29
|
},
|
|
30
30
|
"af:exports": {
|
|
31
31
|
".": "./src/index.ts",
|
package/report.api.md
CHANGED
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
## API Report File for "@atlaskit/collab-provider"
|
|
2
|
+
|
|
3
|
+
> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/).
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
|
|
7
|
+
import type { AnalyticsWebClient } from '@atlaskit/analytics-listeners';
|
|
8
|
+
import type { EditorState } from 'prosemirror-state';
|
|
9
|
+
import { JSONDocNode } from '@atlaskit/editor-json-transformer';
|
|
10
|
+
import type { Manager } from 'socket.io-client';
|
|
11
|
+
import type { Step } from 'prosemirror-transform';
|
|
12
|
+
import type { Transaction } from 'prosemirror-state';
|
|
13
|
+
|
|
14
|
+
// @public (undocumented)
|
|
15
|
+
type AuthCallback = (cb: (data: InitAndAuthData) => void) => void;
|
|
16
|
+
|
|
17
|
+
// @public (undocumented)
|
|
18
|
+
type BaseEvents = Pick<CollabEditProvider<CollabEvents>, 'send' | 'sendMessage' | 'setup'>;
|
|
19
|
+
|
|
20
|
+
// @public (undocumented)
|
|
21
|
+
type CollabCommitStatusEventPayload = {
|
|
22
|
+
status: 'attempt' | 'failure' | 'success';
|
|
23
|
+
version: number;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// @public (undocumented)
|
|
27
|
+
export type CollabConnectedPayload = CollabEventConnectionData;
|
|
28
|
+
|
|
29
|
+
// @public (undocumented)
|
|
30
|
+
type CollabConnectingPayload = CollabEventConnectingData;
|
|
31
|
+
|
|
32
|
+
// @public (undocumented)
|
|
33
|
+
export interface CollabDataPayload extends CollabEventRemoteData {
|
|
34
|
+
// (undocumented)
|
|
35
|
+
json: StepJson[];
|
|
36
|
+
// (undocumented)
|
|
37
|
+
userIds: (number | string)[];
|
|
38
|
+
// (undocumented)
|
|
39
|
+
version: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// @public (undocumented)
|
|
43
|
+
export interface CollabDisconnectedPayload {
|
|
44
|
+
// (undocumented)
|
|
45
|
+
reason: DisconnectReason;
|
|
46
|
+
// (undocumented)
|
|
47
|
+
sid: string;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// @public (undocumented)
|
|
51
|
+
export interface CollabEditProvider<Events extends CollabEvents = CollabEvents> {
|
|
52
|
+
// (undocumented)
|
|
53
|
+
getFinalAcknowledgedState(): Promise<ResolvedEditorState>;
|
|
54
|
+
// (undocumented)
|
|
55
|
+
initialize(getState: () => any, createStep: (json: object) => Step): this;
|
|
56
|
+
// (undocumented)
|
|
57
|
+
off(evt: keyof Events, handler: (...args: any) => void): this;
|
|
58
|
+
// (undocumented)
|
|
59
|
+
on(evt: keyof Events, handler: (...args: any) => void): this;
|
|
60
|
+
// (undocumented)
|
|
61
|
+
send(tr: Transaction, oldState: EditorState, newState: EditorState): void;
|
|
62
|
+
// (undocumented)
|
|
63
|
+
sendMessage<K extends keyof Events>(data: {
|
|
64
|
+
type: K;
|
|
65
|
+
} & Events[K]): void;
|
|
66
|
+
// (undocumented)
|
|
67
|
+
setup(props: {
|
|
68
|
+
getState?: () => EditorState;
|
|
69
|
+
onSyncUpError?: SyncUpErrorFunction;
|
|
70
|
+
}): this;
|
|
71
|
+
// (undocumented)
|
|
72
|
+
unsubscribeAll(evt: keyof Events): this;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// @public (undocumented)
|
|
76
|
+
export interface CollabEventConnectingData {
|
|
77
|
+
// (undocumented)
|
|
78
|
+
initial: boolean;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// @public (undocumented)
|
|
82
|
+
export interface CollabEventConnectionData {
|
|
83
|
+
// (undocumented)
|
|
84
|
+
initial: boolean;
|
|
85
|
+
// (undocumented)
|
|
86
|
+
sid: string;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// @public (undocumented)
|
|
90
|
+
export interface CollabEventDisconnectedData {
|
|
91
|
+
// (undocumented)
|
|
92
|
+
reason: 'CLIENT_DISCONNECT' | 'SERVER_DISCONNECT' | 'SOCKET_CLOSED' | 'SOCKET_ERROR' | 'SOCKET_TIMEOUT' | 'UNKNOWN_DISCONNECT';
|
|
93
|
+
// (undocumented)
|
|
94
|
+
sid: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// @public (undocumented)
|
|
98
|
+
export interface CollabEventInitData {
|
|
99
|
+
// (undocumented)
|
|
100
|
+
doc?: any;
|
|
101
|
+
// (undocumented)
|
|
102
|
+
json?: any;
|
|
103
|
+
// (undocumented)
|
|
104
|
+
reserveCursor?: boolean;
|
|
105
|
+
// (undocumented)
|
|
106
|
+
sid?: string;
|
|
107
|
+
// (undocumented)
|
|
108
|
+
version?: number;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// @public (undocumented)
|
|
112
|
+
export interface CollabEventLocalStepData {
|
|
113
|
+
// (undocumented)
|
|
114
|
+
steps: Array<Step>;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// @public (undocumented)
|
|
118
|
+
export interface CollabEventPresenceData {
|
|
119
|
+
// (undocumented)
|
|
120
|
+
joined?: CollabParticipant[];
|
|
121
|
+
// (undocumented)
|
|
122
|
+
left?: {
|
|
123
|
+
sessionId: string;
|
|
124
|
+
}[];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// @public (undocumented)
|
|
128
|
+
export interface CollabEventRemoteData {
|
|
129
|
+
// (undocumented)
|
|
130
|
+
json?: any;
|
|
131
|
+
// (undocumented)
|
|
132
|
+
newState?: EditorState;
|
|
133
|
+
// (undocumented)
|
|
134
|
+
userIds?: (number | string)[];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// @public (undocumented)
|
|
138
|
+
export interface CollabEvents {
|
|
139
|
+
// (undocumented)
|
|
140
|
+
'commit-status': CollabCommitStatusEventPayload;
|
|
141
|
+
// (undocumented)
|
|
142
|
+
'local-steps': CollabLocalStepsPayload;
|
|
143
|
+
// (undocumented)
|
|
144
|
+
'metadata:changed': CollabMetadataPayload;
|
|
145
|
+
// (undocumented)
|
|
146
|
+
connected: CollabConnectedPayload;
|
|
147
|
+
// (undocumented)
|
|
148
|
+
connecting: CollabConnectingPayload;
|
|
149
|
+
// (undocumented)
|
|
150
|
+
data: CollabDataPayload;
|
|
151
|
+
// (undocumented)
|
|
152
|
+
disconnected: CollabDisconnectedPayload;
|
|
153
|
+
// (undocumented)
|
|
154
|
+
entity: any;
|
|
155
|
+
// (undocumented)
|
|
156
|
+
error: ProviderError;
|
|
157
|
+
// (undocumented)
|
|
158
|
+
init: CollabInitPayload;
|
|
159
|
+
// (undocumented)
|
|
160
|
+
presence: CollabPresencePayload;
|
|
161
|
+
// (undocumented)
|
|
162
|
+
telepointer: CollabTelepointerPayload;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// @public (undocumented)
|
|
166
|
+
export interface CollabEventTelepointerData {
|
|
167
|
+
// (undocumented)
|
|
168
|
+
selection: CollabSendableSelection;
|
|
169
|
+
// (undocumented)
|
|
170
|
+
sessionId: string;
|
|
171
|
+
// (undocumented)
|
|
172
|
+
type: 'telepointer';
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// @public (undocumented)
|
|
176
|
+
export interface CollabInitPayload extends CollabEventInitData {
|
|
177
|
+
// (undocumented)
|
|
178
|
+
doc: any;
|
|
179
|
+
// (undocumented)
|
|
180
|
+
metadata?: Metadata_2;
|
|
181
|
+
// (undocumented)
|
|
182
|
+
reserveCursor?: boolean;
|
|
183
|
+
// (undocumented)
|
|
184
|
+
version: number;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
// @public (undocumented)
|
|
188
|
+
export type CollabLocalStepsPayload = {
|
|
189
|
+
steps: readonly Step[];
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// @public (undocumented)
|
|
193
|
+
export type CollabMetadataPayload = Metadata_2;
|
|
194
|
+
|
|
195
|
+
// @public (undocumented)
|
|
196
|
+
export interface CollabParticipant {
|
|
197
|
+
// (undocumented)
|
|
198
|
+
avatar: string;
|
|
199
|
+
// (undocumented)
|
|
200
|
+
cursorPos?: number;
|
|
201
|
+
// (undocumented)
|
|
202
|
+
lastActive: number;
|
|
203
|
+
// (undocumented)
|
|
204
|
+
name: string;
|
|
205
|
+
// (undocumented)
|
|
206
|
+
sessionId: string;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// @public (undocumented)
|
|
210
|
+
export type CollabPresencePayload = CollabEventPresenceData;
|
|
211
|
+
|
|
212
|
+
// @public (undocumented)
|
|
213
|
+
export interface CollabSendableSelection {
|
|
214
|
+
// (undocumented)
|
|
215
|
+
anchor?: number | string;
|
|
216
|
+
// (undocumented)
|
|
217
|
+
head?: number | string;
|
|
218
|
+
// (undocumented)
|
|
219
|
+
type: 'nodeSelection' | 'textSelection';
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// @public (undocumented)
|
|
223
|
+
export type CollabTelepointerPayload = CollabEventTelepointerData;
|
|
224
|
+
|
|
225
|
+
// @public (undocumented)
|
|
226
|
+
interface Config {
|
|
227
|
+
analyticsClient?: AnalyticsWebClient;
|
|
228
|
+
// (undocumented)
|
|
229
|
+
cacheToken?: boolean;
|
|
230
|
+
// (undocumented)
|
|
231
|
+
createSocket: (path: string, auth?: AuthCallback | InitAndAuthData, productInfo?: ProductInformation) => Socket;
|
|
232
|
+
// (undocumented)
|
|
233
|
+
documentAri: string;
|
|
234
|
+
failedStepLimitBeforeCatchupOnPublish?: number;
|
|
235
|
+
// (undocumented)
|
|
236
|
+
featureFlags?: {
|
|
237
|
+
[key: string]: boolean;
|
|
238
|
+
};
|
|
239
|
+
// (undocumented)
|
|
240
|
+
getAnalyticsWebClient?: Promise<AnalyticsWebClient>;
|
|
241
|
+
// (undocumented)
|
|
242
|
+
getUser?(userId: string): Promise<Pick<ProviderParticipant, 'avatar' | 'name' | 'userId'>>;
|
|
243
|
+
// (undocumented)
|
|
244
|
+
initialDraft?: InitialDraft;
|
|
245
|
+
// (undocumented)
|
|
246
|
+
lifecycle?: Lifecycle;
|
|
247
|
+
// (undocumented)
|
|
248
|
+
need404?: boolean;
|
|
249
|
+
permissionTokenRefresh?: () => Promise<null | string>;
|
|
250
|
+
// (undocumented)
|
|
251
|
+
productInfo?: ProductInformation;
|
|
252
|
+
// (undocumented)
|
|
253
|
+
storage?: Storage_2;
|
|
254
|
+
throwOnNotConnected?: boolean;
|
|
255
|
+
// (undocumented)
|
|
256
|
+
url: string;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// @public (undocumented)
|
|
260
|
+
enum DisconnectReason {
|
|
261
|
+
// (undocumented)
|
|
262
|
+
CLIENT_DISCONNECT = "CLIENT_DISCONNECT",
|
|
263
|
+
// (undocumented)
|
|
264
|
+
SERVER_DISCONNECT = "SERVER_DISCONNECT",
|
|
265
|
+
// (undocumented)
|
|
266
|
+
SOCKET_CLOSED = "SOCKET_CLOSED",
|
|
267
|
+
// (undocumented)
|
|
268
|
+
SOCKET_ERROR = "SOCKET_ERROR",
|
|
269
|
+
// (undocumented)
|
|
270
|
+
SOCKET_TIMEOUT = "SOCKET_TIMEOUT",
|
|
271
|
+
// (undocumented)
|
|
272
|
+
UNKNOWN_DISCONNECT = "UNKNOWN_DISCONNECT"
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// @public
|
|
276
|
+
type DocumentNotFound = {
|
|
277
|
+
code: PROVIDER_ERROR_CODE.DOCUMENT_NOT_FOUND;
|
|
278
|
+
message: string;
|
|
279
|
+
recoverable: boolean;
|
|
280
|
+
status?: number;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// @public
|
|
284
|
+
type DocumentNotRestore = {
|
|
285
|
+
code: PROVIDER_ERROR_CODE.DOCUMENT_RESTORE_ERROR;
|
|
286
|
+
message: string;
|
|
287
|
+
recoverable: boolean;
|
|
288
|
+
status?: number;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
// @public (undocumented)
|
|
292
|
+
class Emitter<T = any> {
|
|
293
|
+
protected emit<K extends keyof T>(evt: K, data: T[K]): this;
|
|
294
|
+
off<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
|
|
295
|
+
on<K extends keyof T>(evt: K, handler: (args: T[K]) => void): this;
|
|
296
|
+
unsubscribeAll<K extends keyof T>(evt?: K): this;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// @public (undocumented)
|
|
300
|
+
type EventHandler = () => void;
|
|
301
|
+
|
|
302
|
+
// @public
|
|
303
|
+
type FailToSave = {
|
|
304
|
+
code: PROVIDER_ERROR_CODE.FAIL_TO_SAVE;
|
|
305
|
+
message: string;
|
|
306
|
+
recoverable: boolean;
|
|
307
|
+
status?: number;
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
// @public (undocumented)
|
|
311
|
+
interface InitAndAuthData {
|
|
312
|
+
// (undocumented)
|
|
313
|
+
initialized: boolean;
|
|
314
|
+
// (undocumented)
|
|
315
|
+
need404?: boolean;
|
|
316
|
+
// (undocumented)
|
|
317
|
+
token?: string;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// @public (undocumented)
|
|
321
|
+
interface InitialDraft {
|
|
322
|
+
// (undocumented)
|
|
323
|
+
document: JSONDocNode;
|
|
324
|
+
// (undocumented)
|
|
325
|
+
metadata?: Metadata_2;
|
|
326
|
+
// (undocumented)
|
|
327
|
+
timestamp?: number;
|
|
328
|
+
// (undocumented)
|
|
329
|
+
version: number;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
// @public
|
|
333
|
+
type InitialisationError = {
|
|
334
|
+
code: PROVIDER_ERROR_CODE.INITIALISATION_ERROR;
|
|
335
|
+
message: string;
|
|
336
|
+
recoverable: boolean;
|
|
337
|
+
status?: number;
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// @public
|
|
341
|
+
type InsufficientEditingPermission = {
|
|
342
|
+
code: PROVIDER_ERROR_CODE.NO_PERMISSION_ERROR;
|
|
343
|
+
message: string;
|
|
344
|
+
recoverable: boolean;
|
|
345
|
+
reason?: string;
|
|
346
|
+
status?: number;
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// @public
|
|
350
|
+
type InternalServiceError = {
|
|
351
|
+
code: PROVIDER_ERROR_CODE.INTERNAL_SERVICE_ERROR;
|
|
352
|
+
message: string;
|
|
353
|
+
recoverable: boolean;
|
|
354
|
+
reason: string;
|
|
355
|
+
status?: number;
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
// @public
|
|
359
|
+
type InvalidProviderConfiguration = {
|
|
360
|
+
code: PROVIDER_ERROR_CODE.INVALID_PROVIDER_CONFIGURATION;
|
|
361
|
+
message: string;
|
|
362
|
+
recoverable: boolean;
|
|
363
|
+
reason: string;
|
|
364
|
+
status?: number;
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
// @public
|
|
368
|
+
type InvalidUserToken = {
|
|
369
|
+
code: PROVIDER_ERROR_CODE.INVALID_USER_TOKEN;
|
|
370
|
+
message: string;
|
|
371
|
+
recoverable: boolean;
|
|
372
|
+
status?: number;
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// @public (undocumented)
|
|
376
|
+
interface Lifecycle {
|
|
377
|
+
// (undocumented)
|
|
378
|
+
on(event: LifecycleEvents, handler: EventHandler): void;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
// @public (undocumented)
|
|
382
|
+
type LifecycleEvents = 'restore' | 'save';
|
|
383
|
+
|
|
384
|
+
// @public
|
|
385
|
+
type Locked = {
|
|
386
|
+
code: PROVIDER_ERROR_CODE.LOCKED;
|
|
387
|
+
message: string;
|
|
388
|
+
recoverable: boolean;
|
|
389
|
+
status?: number;
|
|
390
|
+
};
|
|
391
|
+
|
|
392
|
+
// @public (undocumented)
|
|
393
|
+
type MarkJson = {
|
|
394
|
+
type: string;
|
|
395
|
+
attrs: {
|
|
396
|
+
[key: string]: any;
|
|
397
|
+
};
|
|
398
|
+
};
|
|
399
|
+
|
|
400
|
+
// @public (undocumented)
|
|
401
|
+
interface Metadata_2 {
|
|
402
|
+
// (undocumented)
|
|
403
|
+
[key: string]: boolean | number | string;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
// @public
|
|
407
|
+
type NetworkIssue = {
|
|
408
|
+
code: PROVIDER_ERROR_CODE.NETWORK_ISSUE;
|
|
409
|
+
message: string;
|
|
410
|
+
recoverable: boolean;
|
|
411
|
+
status?: number;
|
|
412
|
+
};
|
|
413
|
+
|
|
414
|
+
// @public (undocumented)
|
|
415
|
+
export type NewCollabSyncUpErrorAttributes = {
|
|
416
|
+
lengthOfUnconfirmedSteps?: number;
|
|
417
|
+
tries: number;
|
|
418
|
+
maxRetries: number;
|
|
419
|
+
clientId?: number | string;
|
|
420
|
+
version: number;
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
// @public (undocumented)
|
|
424
|
+
type NodeJson = {
|
|
425
|
+
type: string;
|
|
426
|
+
attrs: {
|
|
427
|
+
[key: string]: any;
|
|
428
|
+
};
|
|
429
|
+
content: NodeJson[];
|
|
430
|
+
marks: MarkJson[];
|
|
431
|
+
text?: string;
|
|
432
|
+
};
|
|
433
|
+
|
|
434
|
+
// @public (undocumented)
|
|
435
|
+
type ProductInformation = {
|
|
436
|
+
product: string;
|
|
437
|
+
subProduct?: string;
|
|
438
|
+
};
|
|
439
|
+
|
|
440
|
+
// @public (undocumented)
|
|
441
|
+
export class Provider extends Emitter<CollabEvents> implements BaseEvents {
|
|
442
|
+
constructor(config: Config);
|
|
443
|
+
destroy(): this;
|
|
444
|
+
// @deprecated
|
|
445
|
+
disconnect(): this;
|
|
446
|
+
getCurrentState: () => Promise<ResolvedEditorState>;
|
|
447
|
+
getFinalAcknowledgedState: () => Promise<ResolvedEditorState>;
|
|
448
|
+
getMetadata: () => Metadata_2;
|
|
449
|
+
// (undocumented)
|
|
450
|
+
getStatePromiseResolve: (value: PromiseLike<void> | void) => void;
|
|
451
|
+
// (undocumented)
|
|
452
|
+
getUnconfirmedSteps: () => readonly Step[] | undefined;
|
|
453
|
+
// @deprecated
|
|
454
|
+
initialize(getState: () => EditorState): this;
|
|
455
|
+
send(_tr: Transaction | null, _oldState: EditorState | null, newState: EditorState): void;
|
|
456
|
+
sendMessage(data: CollabTelepointerPayload): void;
|
|
457
|
+
// @deprecated
|
|
458
|
+
setEditorWidth(editorWidth: string, broadcast?: boolean): void;
|
|
459
|
+
setMetadata(metadata: Metadata_2): void;
|
|
460
|
+
// @deprecated
|
|
461
|
+
setTitle(title: string, broadcast?: boolean): void;
|
|
462
|
+
setup({ getState, onSyncUpError, }: {
|
|
463
|
+
getState?: () => EditorState;
|
|
464
|
+
onSyncUpError?: SyncUpErrorFunction;
|
|
465
|
+
}): this;
|
|
466
|
+
// @deprecated
|
|
467
|
+
unsubscribeAll(): this;
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
// @public (undocumented)
|
|
471
|
+
export enum PROVIDER_ERROR_CODE {
|
|
472
|
+
// (undocumented)
|
|
473
|
+
DOCUMENT_NOT_FOUND = "DOCUMENT_NOT_FOUND",
|
|
474
|
+
// (undocumented)
|
|
475
|
+
DOCUMENT_RESTORE_ERROR = "DOCUMENT_RESTORE_ERROR",
|
|
476
|
+
// (undocumented)
|
|
477
|
+
FAIL_TO_SAVE = "FAIL_TO_SAVE",
|
|
478
|
+
// (undocumented)
|
|
479
|
+
INITIALISATION_ERROR = "INITIALISATION_ERROR",
|
|
480
|
+
// (undocumented)
|
|
481
|
+
INTERNAL_SERVICE_ERROR = "INTERNAL_SERVICE_ERROR",
|
|
482
|
+
// (undocumented)
|
|
483
|
+
INVALID_PROVIDER_CONFIGURATION = "INVALID_PROVIDER_CONFIGURATION",
|
|
484
|
+
// (undocumented)
|
|
485
|
+
INVALID_USER_TOKEN = "INVALID_USER_TOKEN",
|
|
486
|
+
// (undocumented)
|
|
487
|
+
LOCKED = "LOCKED",
|
|
488
|
+
// (undocumented)
|
|
489
|
+
NETWORK_ISSUE = "NETWORK_ISSUE",
|
|
490
|
+
// (undocumented)
|
|
491
|
+
NO_PERMISSION_ERROR = "NO_PERMISSION_ERROR"
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// @public
|
|
495
|
+
export type ProviderError = DocumentNotFound | DocumentNotRestore | FailToSave | InitialisationError | InsufficientEditingPermission | InternalServiceError | InvalidProviderConfiguration | InvalidUserToken | Locked | NetworkIssue;
|
|
496
|
+
|
|
497
|
+
// @public (undocumented)
|
|
498
|
+
type ProviderParticipant = CollabParticipant & {
|
|
499
|
+
userId: string;
|
|
500
|
+
clientId: number | string;
|
|
501
|
+
};
|
|
502
|
+
|
|
503
|
+
// @public (undocumented)
|
|
504
|
+
export type ResolvedEditorState<T = any> = {
|
|
505
|
+
content: JSONDocNode | T;
|
|
506
|
+
title: null | string;
|
|
507
|
+
stepVersion: number;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// @public (undocumented)
|
|
511
|
+
interface SimpleEventEmitter {
|
|
512
|
+
// (undocumented)
|
|
513
|
+
on(event: string, fn: Function): SimpleEventEmitter;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// @public (undocumented)
|
|
517
|
+
type SliceJson = {
|
|
518
|
+
content: NodeJson[];
|
|
519
|
+
openStart: number;
|
|
520
|
+
openEnd: number;
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
// @public (undocumented)
|
|
524
|
+
export interface Socket extends SimpleEventEmitter {
|
|
525
|
+
// (undocumented)
|
|
526
|
+
close(): Socket;
|
|
527
|
+
// (undocumented)
|
|
528
|
+
connect(): Socket;
|
|
529
|
+
// (undocumented)
|
|
530
|
+
emit(event: string, ...args: any[]): Socket;
|
|
531
|
+
// (undocumented)
|
|
532
|
+
id: string;
|
|
533
|
+
// (undocumented)
|
|
534
|
+
io?: Manager;
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
// @public (undocumented)
|
|
538
|
+
type StepJson = {
|
|
539
|
+
stepType?: string;
|
|
540
|
+
from?: number;
|
|
541
|
+
to?: number;
|
|
542
|
+
slice?: SliceJson;
|
|
543
|
+
clientId: number | string;
|
|
544
|
+
userId: string;
|
|
545
|
+
createdAt?: number;
|
|
546
|
+
structure?: boolean;
|
|
547
|
+
};
|
|
548
|
+
|
|
549
|
+
// @public (undocumented)
|
|
550
|
+
interface Storage_2 {
|
|
551
|
+
// (undocumented)
|
|
552
|
+
delete(key: string): Promise<void>;
|
|
553
|
+
// (undocumented)
|
|
554
|
+
get(key: string): Promise<string>;
|
|
555
|
+
// (undocumented)
|
|
556
|
+
set(key: string, value: string): Promise<void>;
|
|
557
|
+
}
|
|
558
|
+
|
|
559
|
+
// @public (undocumented)
|
|
560
|
+
export type SyncUpErrorFunction = (attributes: NewCollabSyncUpErrorAttributes) => void;
|
|
561
|
+
|
|
562
|
+
// (No @packageDocumentation comment for this package)
|
|
563
|
+
|
|
564
|
+
```
|