@atlaskit/collab-provider 9.1.0 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/cjs/document/document-service.js +27 -21
- package/dist/cjs/helpers/utils.js +28 -2
- 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/document/document-service.js +17 -12
- package/dist/es2019/helpers/utils.js +25 -0
- 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/document/document-service.js +28 -22
- package/dist/esm/helpers/utils.js +25 -0
- 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/helpers/const.d.ts +2 -2
- package/dist/types/helpers/utils.d.ts +7 -0
- package/dist/types/provider/index.d.ts +6 -0
- package/dist/types/types.d.ts +1 -0
- package/dist/types-ts4.5/helpers/const.d.ts +2 -2
- package/dist/types-ts4.5/helpers/utils.d.ts +7 -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 +3 -3
- package/report.api.md +2 -0
- package/tmp/api-report-tmp.d.ts +564 -0
|
@@ -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
|
@@ -192,7 +192,7 @@ type SendStepsRetryAnalyticsEvent = {
|
|
|
192
192
|
eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
|
|
193
193
|
attributes: {
|
|
194
194
|
documentAri: string;
|
|
195
|
-
eventStatus: EVENT_STATUS.
|
|
195
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
196
196
|
count: number;
|
|
197
197
|
};
|
|
198
198
|
};
|
|
@@ -200,7 +200,7 @@ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
|
|
|
200
200
|
eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
|
|
201
201
|
attributes: {
|
|
202
202
|
documentAri: string;
|
|
203
|
-
eventStatus: EVENT_STATUS.
|
|
203
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ProductInformation } from '../types';
|
|
2
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
3
|
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
4
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
4
5
|
export declare const getProduct: (productInfo?: ProductInformation) => string;
|
|
5
6
|
export declare const getSubProduct: (productInfo?: ProductInformation) => string;
|
|
7
|
+
export type UGCFreeStepDetails = {
|
|
8
|
+
type: string;
|
|
9
|
+
contentTypes: string;
|
|
10
|
+
stepSizeInBytes?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
|
|
@@ -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
|
@@ -192,7 +192,7 @@ type SendStepsRetryAnalyticsEvent = {
|
|
|
192
192
|
eventAction: EVENT_ACTION.SEND_STEPS_RETRY;
|
|
193
193
|
attributes: {
|
|
194
194
|
documentAri: string;
|
|
195
|
-
eventStatus: EVENT_STATUS.
|
|
195
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
196
196
|
count: number;
|
|
197
197
|
};
|
|
198
198
|
};
|
|
@@ -200,7 +200,7 @@ type CatchupAfterMaxSendStepsRetryAnalyticsEvent = {
|
|
|
200
200
|
eventAction: EVENT_ACTION.CATCHUP_AFTER_MAX_SEND_STEPS_RETRY;
|
|
201
201
|
attributes: {
|
|
202
202
|
documentAri: string;
|
|
203
|
-
eventStatus: EVENT_STATUS.
|
|
203
|
+
eventStatus: EVENT_STATUS.INFO;
|
|
204
204
|
};
|
|
205
205
|
};
|
|
206
206
|
export type ActionAnalyticsEvent = AddStepsSuccessAnalyticsEvent | AddStepsFailureAnalyticsEvent | ReInitDocFailAnalyticsEvent | ReInitDocSuccessAnalyticsEvent | ConnectionSuccessAnalyticsEvent | ConnectionFailureAnalyticsEvent | CatchUpSuccessAnalyticsEvent | CatchUpFailureAnalyticsEvent | DocumentInitSuccessAnalyticsEvent | UpdateParticipantsSuccessAnalyticsEvent | CommitUnconfirmedStepsSuccessAnalyticsEvent | CommitUnconfirmedStepsFailureAnalyticsEvent | PublishPageSuccessAnalyticsEvent | PublishPageFailureAnalyticsEvent | GetCurrentStateSuccessAnalyticsEvent | GetCurrentStateFailureAnalyticsEvent | InvalidateTokenAnalyticsEvent | SendStepsRetryAnalyticsEvent | CatchupAfterMaxSendStepsRetryAnalyticsEvent | CatchUpDroppedStepsEvent;
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import type { ProductInformation } from '../types';
|
|
2
|
+
import type { Step as ProseMirrorStep } from 'prosemirror-transform';
|
|
2
3
|
export declare const createLogger: (prefix: string, color?: string) => (msg: string, data?: any) => void;
|
|
3
4
|
export declare function sleep(ms: number): Promise<unknown>;
|
|
4
5
|
export declare const getProduct: (productInfo?: ProductInformation) => string;
|
|
5
6
|
export declare const getSubProduct: (productInfo?: ProductInformation) => string;
|
|
7
|
+
export type UGCFreeStepDetails = {
|
|
8
|
+
type: string;
|
|
9
|
+
contentTypes: string;
|
|
10
|
+
stepSizeInBytes?: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const getStepUGCFreeDetails: (step: ProseMirrorStep) => UGCFreeStepDetails;
|
|
@@ -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.1
|
|
3
|
+
"version": "9.2.1",
|
|
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",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@atlaskit/adf-schema": "^25.8.0",
|
|
65
65
|
"@atlaskit/analytics-listeners": "^8.7.0",
|
|
66
|
-
"@atlaskit/editor-test-helpers": "^18.
|
|
66
|
+
"@atlaskit/editor-test-helpers": "^18.6.0",
|
|
67
67
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
68
68
|
"@types/prosemirror-model": "^1.11.0",
|
|
69
69
|
"@types/prosemirror-state": "^1.2.0",
|