@cool-office/collaboration-client 0.0.0-stage → 1.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/LICENSE +176 -0
- package/README.md +2 -2
- package/lib/cjs/index.js +1501 -0
- package/lib/cjs/package.json +1 -0
- package/lib/es/index.js +1450 -0
- package/lib/types/src/changeset-submitter.d.ts +80 -0
- package/lib/types/src/document-object-resources.d.ts +4 -0
- package/lib/types/src/document-recovery.d.ts +82 -0
- package/lib/types/src/document-undo.d.ts +7 -0
- package/lib/types/src/index.d.ts +12 -0
- package/lib/types/src/revision-recovery.d.ts +85 -0
- package/lib/types/src/session.d.ts +80 -0
- package/lib/types/src/snapshot-server.d.ts +25 -0
- package/lib/types/src/socket.d.ts +46 -0
- package/package.json +28 -4
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { IMutationInfo, UniverInstanceType } from '@cool-office/core';
|
|
2
|
+
export interface ICollaborationChangeset {
|
|
3
|
+
unitID: string;
|
|
4
|
+
type: UniverInstanceType;
|
|
5
|
+
baseRev: number;
|
|
6
|
+
revision: number;
|
|
7
|
+
userID: string;
|
|
8
|
+
memberID: string;
|
|
9
|
+
mutations: IMutationInfo[];
|
|
10
|
+
sid?: string;
|
|
11
|
+
reqId?: number;
|
|
12
|
+
mutationSize?: number;
|
|
13
|
+
additionalFields?: string;
|
|
14
|
+
createTime?: number;
|
|
15
|
+
}
|
|
16
|
+
export type ChangesetResendReason = 'ack_timeout' | 'should_retry' | 'reconnect' | 'request_failed';
|
|
17
|
+
export interface IChangesetResendEvent {
|
|
18
|
+
unitID: string;
|
|
19
|
+
reqId: number;
|
|
20
|
+
reason: ChangesetResendReason;
|
|
21
|
+
attempt: number;
|
|
22
|
+
elapsedMs: number;
|
|
23
|
+
unsyncedMutationCount: number;
|
|
24
|
+
nextDelayMs: number;
|
|
25
|
+
}
|
|
26
|
+
export type ChangesetResendInfo = Omit<IChangesetResendEvent, 'unitID'>;
|
|
27
|
+
export declare const DEFAULT_ACK_TIMEOUT = 20000;
|
|
28
|
+
export declare const MAX_ACK_TIMEOUT = 120000;
|
|
29
|
+
export declare const MAX_RETRY_TIMEOUT = 20000;
|
|
30
|
+
export type SendChangeset = (changeset: ICollaborationChangeset, options: {
|
|
31
|
+
timeout?: number;
|
|
32
|
+
}) => void | Promise<void>;
|
|
33
|
+
export interface IChangesetSubmitterSource {
|
|
34
|
+
changeset: ICollaborationChangeset;
|
|
35
|
+
unsyncedMutationCount: number;
|
|
36
|
+
}
|
|
37
|
+
export interface IChangesetSubmitterOptions {
|
|
38
|
+
ackTimeout?: number;
|
|
39
|
+
maxAckTimeout?: number;
|
|
40
|
+
onResend?: (info: ChangesetResendInfo) => void;
|
|
41
|
+
now?: () => number;
|
|
42
|
+
}
|
|
43
|
+
/** Returns null for permanent failures and the transport's own acknowledgement timeout. */
|
|
44
|
+
export declare function getRetryDelay(error: unknown, backoff: number): number | null;
|
|
45
|
+
/** Owns delivery of one awaiting changeset; acknowledgement is handled by the caller. */
|
|
46
|
+
export declare class ChangesetSubmitter {
|
|
47
|
+
private readonly _send;
|
|
48
|
+
private readonly _options;
|
|
49
|
+
private _attempt;
|
|
50
|
+
private readonly _firstSentAt;
|
|
51
|
+
private _ackTimeout;
|
|
52
|
+
private readonly _maxAckTimeout;
|
|
53
|
+
private _retryBackoff;
|
|
54
|
+
private _nextDelay;
|
|
55
|
+
private _timer;
|
|
56
|
+
private _pendingReason;
|
|
57
|
+
private _source;
|
|
58
|
+
private _sendToken;
|
|
59
|
+
private _disposed;
|
|
60
|
+
private readonly _now;
|
|
61
|
+
private _reqId;
|
|
62
|
+
constructor(reqId: number, _send: SendChangeset, _options?: IChangesetSubmitterOptions);
|
|
63
|
+
get reqId(): number;
|
|
64
|
+
get attempt(): number;
|
|
65
|
+
get nextDelayMs(): number;
|
|
66
|
+
get elapsedMs(): number;
|
|
67
|
+
bind(source: () => IChangesetSubmitterSource): void;
|
|
68
|
+
unbind(): void;
|
|
69
|
+
submit(changeset: ICollaborationChangeset, unsyncedMutationCount: number, reason?: ChangesetResendReason): void;
|
|
70
|
+
armAckTimeout(): void;
|
|
71
|
+
requestRetry(): void;
|
|
72
|
+
dispose(): void;
|
|
73
|
+
private _deliver;
|
|
74
|
+
private _onRequestFailed;
|
|
75
|
+
private _schedule;
|
|
76
|
+
private _resend;
|
|
77
|
+
private _countResend;
|
|
78
|
+
private _notifyResend;
|
|
79
|
+
private _clearTimer;
|
|
80
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { IDocumentData, IResourceManagerService, JSONXActions } from '@cool-office/core';
|
|
2
|
+
export declare function isDocumentObjectMutation(id: string): boolean;
|
|
3
|
+
export declare function documentObjectEdit(before: IDocumentData, id: string, params: Record<string, unknown>, resources?: IResourceManagerService): JSONXActions | undefined;
|
|
4
|
+
export declare function refreshDocumentObjectResources(unitID: string, before: IDocumentData['resources'], after: IDocumentData['resources'], manager?: IResourceManagerService): void;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { DocumentDataModel, ICommandService, IDocumentData, IResourceManagerService, JSONXActions } from '@cool-office/core';
|
|
2
|
+
import { Disposable } from '@cool-office/core';
|
|
3
|
+
import type { IRevisionRecoveryOptions, RecoveryStatus } from './revision-recovery';
|
|
4
|
+
import type { CollaborationSessionService } from './session';
|
|
5
|
+
import type { SnapshotServerOverHTTPService } from './snapshot-server';
|
|
6
|
+
export type DocumentAccess = 'write' | 'read' | 'none';
|
|
7
|
+
export interface DocumentConnectionOptions {
|
|
8
|
+
initialAccess: DocumentAccess;
|
|
9
|
+
access(): Promise<DocumentAccess>;
|
|
10
|
+
setAccess(access: DocumentAccess): void;
|
|
11
|
+
recoveryKey?: string;
|
|
12
|
+
resources?: IResourceManagerService;
|
|
13
|
+
beforeRemote?(operation: JSONXActions, before: IDocumentData): void;
|
|
14
|
+
}
|
|
15
|
+
export declare class DocumentCollaborationRecovery extends Disposable {
|
|
16
|
+
readonly options: IRevisionRecoveryOptions;
|
|
17
|
+
private readonly _commands;
|
|
18
|
+
private readonly _snapshots;
|
|
19
|
+
private readonly _sessions;
|
|
20
|
+
private readonly _model;
|
|
21
|
+
private readonly _connection;
|
|
22
|
+
private readonly _remove;
|
|
23
|
+
private readonly _state;
|
|
24
|
+
readonly status$: import("rxjs").Observable<RecoveryStatus>;
|
|
25
|
+
private _confirmed;
|
|
26
|
+
private _queue;
|
|
27
|
+
private _sid;
|
|
28
|
+
private _next;
|
|
29
|
+
private _reason;
|
|
30
|
+
private _conflictBase?;
|
|
31
|
+
private _conflictRemote;
|
|
32
|
+
private _session?;
|
|
33
|
+
private _grant;
|
|
34
|
+
private _closed;
|
|
35
|
+
private _ready;
|
|
36
|
+
private _pulling;
|
|
37
|
+
private _accessPending;
|
|
38
|
+
private _generation;
|
|
39
|
+
private _sending;
|
|
40
|
+
private _ackTimer?;
|
|
41
|
+
private _buffer;
|
|
42
|
+
private _storageError;
|
|
43
|
+
private _batch?;
|
|
44
|
+
constructor(options: IRevisionRecoveryOptions, _commands: ICommandService, _snapshots: SnapshotServerOverHTTPService, _sessions: CollaborationSessionService, _model: DocumentDataModel, _connection: DocumentConnectionOptions, _remove: () => void);
|
|
45
|
+
get status(): RecoveryStatus;
|
|
46
|
+
get revision(): number;
|
|
47
|
+
get hasWritePending(): boolean;
|
|
48
|
+
get conflictReason(): string | null;
|
|
49
|
+
get canPublishConflict(): boolean;
|
|
50
|
+
getUnrecoverableDraft(): string | undefined;
|
|
51
|
+
getPendingEdits(): {
|
|
52
|
+
edits: {
|
|
53
|
+
id: string;
|
|
54
|
+
params: {
|
|
55
|
+
unitId: string;
|
|
56
|
+
actions: JSONXActions;
|
|
57
|
+
};
|
|
58
|
+
}[];
|
|
59
|
+
incomplete: boolean;
|
|
60
|
+
awaitingConfirmation: boolean;
|
|
61
|
+
};
|
|
62
|
+
getLocalDocument(): IDocumentData;
|
|
63
|
+
getConfirmedDocument(): IDocumentData;
|
|
64
|
+
getProposedDocument(): IDocumentData;
|
|
65
|
+
markUnitUnavailable(): void;
|
|
66
|
+
start(): Promise<void>;
|
|
67
|
+
/** The caller shows the two snapshots and supplies the revision the user actually reviewed. */
|
|
68
|
+
resolveDocumentConflict(choice: 'remote' | 'local', reviewedRevision: number): Promise<boolean>;
|
|
69
|
+
private _refreshAccess;
|
|
70
|
+
private _pull;
|
|
71
|
+
private _drain;
|
|
72
|
+
private _apply;
|
|
73
|
+
private _finishObjectCommand;
|
|
74
|
+
private _enqueue;
|
|
75
|
+
private _submit;
|
|
76
|
+
private _clearSend;
|
|
77
|
+
private _update;
|
|
78
|
+
private _conflict;
|
|
79
|
+
private _save;
|
|
80
|
+
private _restore;
|
|
81
|
+
dispose(): void;
|
|
82
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDocumentData, JSONXActions } from '@cool-office/core';
|
|
2
|
+
import { LocalUndoRedoService } from '@cool-office/core';
|
|
3
|
+
/** Keep each user's undo and redo operations in the coordinate system of the current document. */
|
|
4
|
+
export declare class DocumentCollaborationUndoService extends LocalUndoRedoService {
|
|
5
|
+
transformDocumentHistory(unitID: string, remote: JSONXActions, before: IDocumentData): void;
|
|
6
|
+
private _transformStack;
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { ChangesetSubmitter, DEFAULT_ACK_TIMEOUT, MAX_ACK_TIMEOUT } from './changeset-submitter';
|
|
2
|
+
export type { ChangesetResendReason, IChangesetResendEvent, IChangesetSubmitterOptions, IChangesetSubmitterSource, SendChangeset } from './changeset-submitter';
|
|
3
|
+
export { DocumentCollaborationRecovery } from './document-recovery';
|
|
4
|
+
export type { DocumentAccess, DocumentConnectionOptions } from './document-recovery';
|
|
5
|
+
export { DocumentCollaborationUndoService } from './document-undo';
|
|
6
|
+
export { CollaborationRevisionRecovery, CollaborationRevisionRecoveryService } from './revision-recovery';
|
|
7
|
+
export type { EditorRevisionRecovery, IRevisionRecoveryOptions, RecoveryStatus } from './revision-recovery';
|
|
8
|
+
export { CollaborationSession, CollaborationSessionService, SessionStatus } from './session';
|
|
9
|
+
export type { ICollaborationEvent } from './session';
|
|
10
|
+
export { COLLABORATION_CLIENT_PLUGIN_CONFIG_KEY, DEFAULT_SNAPSHOT_SERVER_URL, SNAPSHOT_URL_KEY, SnapshotServerOverHTTPService } from './snapshot-server';
|
|
11
|
+
export { CollaborationSocketService, deserializeToCombResponse, ICollaborationSocketService, serializeCombRequest } from './socket';
|
|
12
|
+
export type { ICollaborationSocket, ICombEvent } from './socket';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { UniverType } from '@cool-office/protocol';
|
|
2
|
+
import { Disposable, ICommandService, IUniverInstanceService } from '@cool-office/core';
|
|
3
|
+
import type { DocumentConnectionOptions } from './document-recovery';
|
|
4
|
+
import { DocumentCollaborationRecovery } from './document-recovery';
|
|
5
|
+
import { CollaborationSessionService } from './session';
|
|
6
|
+
import { SnapshotServerOverHTTPService } from './snapshot-server';
|
|
7
|
+
export type RecoveryStatus = 'connecting' | 'recovering' | 'synced' | 'pending' | 'offline' | 'conflict' | 'readonly' | 'denied';
|
|
8
|
+
export interface IRevisionRecoveryOptions {
|
|
9
|
+
unitID: string;
|
|
10
|
+
unitType: UniverType;
|
|
11
|
+
revision: number;
|
|
12
|
+
userID?: string;
|
|
13
|
+
document?: DocumentConnectionOptions;
|
|
14
|
+
sheetObjects?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface LocalEdit {
|
|
17
|
+
id: string;
|
|
18
|
+
params: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Synchronizes a restricted set of cell edits and contiguous remote revisions.
|
|
22
|
+
* It stops on concurrent changes, unsupported mutations or uncertain application.
|
|
23
|
+
*/
|
|
24
|
+
export declare class CollaborationRevisionRecovery extends Disposable {
|
|
25
|
+
readonly options: IRevisionRecoveryOptions;
|
|
26
|
+
private readonly _commands;
|
|
27
|
+
private readonly _snapshots;
|
|
28
|
+
private readonly _sessions;
|
|
29
|
+
private readonly _instances;
|
|
30
|
+
private readonly _onDispose?;
|
|
31
|
+
private readonly _status;
|
|
32
|
+
readonly status$: import("rxjs").Observable<RecoveryStatus>;
|
|
33
|
+
private readonly _subscriptions;
|
|
34
|
+
private readonly _pending;
|
|
35
|
+
private _session;
|
|
36
|
+
private _revision;
|
|
37
|
+
private _generation;
|
|
38
|
+
private _localDirty;
|
|
39
|
+
private _closed;
|
|
40
|
+
private _reason;
|
|
41
|
+
private readonly _localEdits;
|
|
42
|
+
private _inflight;
|
|
43
|
+
private _ackTimer;
|
|
44
|
+
private _nextRequest;
|
|
45
|
+
private readonly _sid;
|
|
46
|
+
private _untrackedLocalEdit;
|
|
47
|
+
constructor(options: IRevisionRecoveryOptions, _commands: ICommandService, _snapshots: SnapshotServerOverHTTPService, _sessions: CollaborationSessionService, _instances: IUniverInstanceService, _onDispose?: (() => void) | undefined);
|
|
48
|
+
get revision(): number;
|
|
49
|
+
get status(): RecoveryStatus;
|
|
50
|
+
get conflictReason(): string | null;
|
|
51
|
+
get hasWritePending(): boolean;
|
|
52
|
+
/** Retains in-memory pending edits when the editor closes the bound unit. */
|
|
53
|
+
markUnitUnavailable(): void;
|
|
54
|
+
/** Memory-only copy for the caller to preserve or inspect before disposing the unit. */
|
|
55
|
+
getPendingEdits(): {
|
|
56
|
+
edits: LocalEdit[];
|
|
57
|
+
incomplete: boolean;
|
|
58
|
+
awaitingConfirmation: boolean;
|
|
59
|
+
};
|
|
60
|
+
start(): Promise<void>;
|
|
61
|
+
dispose(): void;
|
|
62
|
+
private _localMutation;
|
|
63
|
+
private _withinSheet;
|
|
64
|
+
private _acceptsLocal;
|
|
65
|
+
private _submitNext;
|
|
66
|
+
private _ack;
|
|
67
|
+
private _clearAckTimer;
|
|
68
|
+
private _recover;
|
|
69
|
+
private _drain;
|
|
70
|
+
private _conflict;
|
|
71
|
+
private _isConflict;
|
|
72
|
+
}
|
|
73
|
+
export type EditorRevisionRecovery = CollaborationRevisionRecovery | DocumentCollaborationRecovery;
|
|
74
|
+
export declare class CollaborationRevisionRecoveryService {
|
|
75
|
+
private readonly _commands;
|
|
76
|
+
private readonly _snapshots;
|
|
77
|
+
private readonly _sessions;
|
|
78
|
+
private readonly _instances;
|
|
79
|
+
private readonly _active;
|
|
80
|
+
readonly active$: import("rxjs").Observable<ReadonlyMap<string, EditorRevisionRecovery>>;
|
|
81
|
+
get(unitID: string): EditorRevisionRecovery | undefined;
|
|
82
|
+
constructor(_commands: ICommandService, _snapshots: SnapshotServerOverHTTPService, _sessions: CollaborationSessionService, _instances: IUniverInstanceService);
|
|
83
|
+
attach(options: IRevisionRecoveryOptions): Promise<EditorRevisionRecovery>;
|
|
84
|
+
}
|
|
85
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Disposable, IConfigService } from '@cool-office/core';
|
|
2
|
+
import type { ICollaborationSocket, ICombEvent } from './socket';
|
|
3
|
+
import { ICollaborationSocketService } from './socket';
|
|
4
|
+
export declare enum SessionStatus {
|
|
5
|
+
IDLE = 0,
|
|
6
|
+
JOINING = 1,
|
|
7
|
+
OFFLINE = 2,
|
|
8
|
+
ONLINE = 3
|
|
9
|
+
}
|
|
10
|
+
export interface ICollaborationEvent {
|
|
11
|
+
eventID: string;
|
|
12
|
+
data?: unknown;
|
|
13
|
+
}
|
|
14
|
+
/** A single room on the shared connection. ONLINE describes room membership, not data synchronization. */
|
|
15
|
+
export declare class CollaborationSession {
|
|
16
|
+
readonly unitID: string;
|
|
17
|
+
private readonly _service;
|
|
18
|
+
private readonly _status;
|
|
19
|
+
private readonly _events;
|
|
20
|
+
readonly sessionStatus$: import("rxjs").Observable<SessionStatus>;
|
|
21
|
+
readonly event$: import("rxjs").Observable<ICollaborationEvent>;
|
|
22
|
+
private _closed;
|
|
23
|
+
private _joinedBefore;
|
|
24
|
+
private _requiresResync;
|
|
25
|
+
constructor(unitID: string, _service: CollaborationSessionService);
|
|
26
|
+
get sessionStatus(): SessionStatus;
|
|
27
|
+
get requiresResync(): boolean;
|
|
28
|
+
/** Call only after the consumer has reconciled the missed server revisions and pending edits. */
|
|
29
|
+
markResynced(): void;
|
|
30
|
+
getMemberID(): string | null;
|
|
31
|
+
send(event: ICollaborationEvent, _unitID: string, options?: {
|
|
32
|
+
timeout?: number;
|
|
33
|
+
}): Promise<void>;
|
|
34
|
+
close(): void;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
/** @internal */ setStatus(status: SessionStatus): void;
|
|
37
|
+
/** @internal */ emit(event: ICollaborationEvent): void;
|
|
38
|
+
/** @internal */ joined(): void;
|
|
39
|
+
/** @internal */ finish(): void;
|
|
40
|
+
}
|
|
41
|
+
/** Shared endpoint connection; does not apply mutations or reconcile revisions. */
|
|
42
|
+
export declare class CollaborationSessionService extends Disposable {
|
|
43
|
+
private readonly _configService;
|
|
44
|
+
private readonly _socketService;
|
|
45
|
+
private readonly _sessions;
|
|
46
|
+
private readonly _status;
|
|
47
|
+
private readonly _socketState;
|
|
48
|
+
readonly status$: import("rxjs").Observable<SessionStatus>;
|
|
49
|
+
readonly socket$: import("rxjs").Observable<ICollaborationSocket | null>;
|
|
50
|
+
private _socket;
|
|
51
|
+
private _subscriptions;
|
|
52
|
+
private _ready;
|
|
53
|
+
private _connecting;
|
|
54
|
+
private _online;
|
|
55
|
+
private _generation;
|
|
56
|
+
private _retryCount;
|
|
57
|
+
private _retryTimer;
|
|
58
|
+
private _handshakeTimer;
|
|
59
|
+
private _heartbeatTimer;
|
|
60
|
+
private _heartbeatTimeout;
|
|
61
|
+
constructor(_configService: IConfigService, _socketService: ICollaborationSocketService);
|
|
62
|
+
get memberID(): string | null;
|
|
63
|
+
requireSession(unitID: string): Promise<CollaborationSession>;
|
|
64
|
+
closeSession(unitID: string): void;
|
|
65
|
+
reconnect(): void;
|
|
66
|
+
/** Browser network signals are hints only; reconnection still requires a successful handshake. */
|
|
67
|
+
setOnline(online: boolean): void;
|
|
68
|
+
send(event: ICombEvent, options?: {
|
|
69
|
+
timeout?: number;
|
|
70
|
+
}): Promise<void>;
|
|
71
|
+
dispose(): void;
|
|
72
|
+
private _scheduleReconnect;
|
|
73
|
+
private _connect;
|
|
74
|
+
private _onMessage;
|
|
75
|
+
private _join;
|
|
76
|
+
private _scheduleHeartbeat;
|
|
77
|
+
private _failed;
|
|
78
|
+
private _disconnect;
|
|
79
|
+
private _clear;
|
|
80
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { IConfigService } from '@cool-office/core';
|
|
2
|
+
import { HTTPService } from '@cool-office/network';
|
|
3
|
+
import type { IFetchMissingChangesetsRequest, IFetchMissingChangesetsResponse, IGetDeserializedSheetBlockResponse, IGetResourcesRequest, IGetResourcesResponse, IGetSheetBlockRequest, IGetSheetBlockResponse, IGetUnitOnRevRequest, IGetUnitOnRevResponse } from '@cool-office/protocol';
|
|
4
|
+
export declare const DEFAULT_SNAPSHOT_SERVER_URL = "/universer-api/snapshot";
|
|
5
|
+
export declare const SNAPSHOT_URL_KEY = "SNAPSHOT_URL_KEY";
|
|
6
|
+
export declare const COLLABORATION_CLIENT_PLUGIN_CONFIG_KEY = "collaboration-client.config";
|
|
7
|
+
/** Independent client for the fixed-version collaboration snapshot HTTP routes. */
|
|
8
|
+
export declare class SnapshotServerOverHTTPService {
|
|
9
|
+
private readonly _configService;
|
|
10
|
+
private readonly _httpService;
|
|
11
|
+
constructor(_configService: IConfigService, _httpService: HTTPService);
|
|
12
|
+
private _prefix;
|
|
13
|
+
getSnapshotAPIPath(): string;
|
|
14
|
+
getUnitOnRev(_context: unknown, params: IGetUnitOnRevRequest): Promise<IGetUnitOnRevResponse>;
|
|
15
|
+
getSheetBlock(_context: unknown, params: IGetSheetBlockRequest): Promise<IGetSheetBlockResponse>;
|
|
16
|
+
getDeserializedSheetBlock(_context: unknown, params: IGetSheetBlockRequest): Promise<IGetDeserializedSheetBlockResponse>;
|
|
17
|
+
fetchMissingChangesets(_context: unknown, params: IFetchMissingChangesetsRequest): Promise<IFetchMissingChangesetsResponse>;
|
|
18
|
+
getResourcesRequest(_context: unknown, params: IGetResourcesRequest): Promise<IGetResourcesResponse>;
|
|
19
|
+
saveSnapshot(): never;
|
|
20
|
+
updateSnapshot(): never;
|
|
21
|
+
saveSheetBlock(): never;
|
|
22
|
+
saveChangeset(): never;
|
|
23
|
+
copyFileMeta(): never;
|
|
24
|
+
getLatestCsReqIdBySid(): never;
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Disposable, IConfigService, Injector, ILogService } from '@cool-office/core';
|
|
2
|
+
import { HTTPService } from '@cool-office/network';
|
|
3
|
+
import { CombCmd } from '@cool-office/protocol';
|
|
4
|
+
import type { Observable } from 'rxjs';
|
|
5
|
+
import type { ICollaborationChangeset } from './changeset-submitter';
|
|
6
|
+
import { SnapshotServerOverHTTPService } from './snapshot-server';
|
|
7
|
+
export interface ICombEvent {
|
|
8
|
+
cmd: CombCmd;
|
|
9
|
+
routeKey: string;
|
|
10
|
+
routeType?: string;
|
|
11
|
+
code?: number;
|
|
12
|
+
data?: any;
|
|
13
|
+
}
|
|
14
|
+
export interface ICollaborationSocket {
|
|
15
|
+
memberID: string;
|
|
16
|
+
open$: Observable<Event>;
|
|
17
|
+
error$: Observable<Event>;
|
|
18
|
+
close$: Observable<Event>;
|
|
19
|
+
message$: Observable<ICombEvent>;
|
|
20
|
+
send(event: ICombEvent, options?: {
|
|
21
|
+
timeout?: number;
|
|
22
|
+
}): void | Promise<void>;
|
|
23
|
+
close(): void;
|
|
24
|
+
}
|
|
25
|
+
export interface ICollaborationSocketService {
|
|
26
|
+
createSocket(url: string): Promise<ICollaborationSocket | null>;
|
|
27
|
+
}
|
|
28
|
+
export declare const ICollaborationSocketService: import("@wendellhu/redi").IdentifierDecorator<ICollaborationSocketService>;
|
|
29
|
+
export declare function serializeCombRequest(event: ICombEvent): string;
|
|
30
|
+
export declare function deserializeToCombResponse(event: MessageEvent): ICombEvent;
|
|
31
|
+
/** Shared HTTP and socket transport for environments that provide an ISocketService. */
|
|
32
|
+
export declare abstract class CollaborationSocketService extends Disposable implements ICollaborationSocketService {
|
|
33
|
+
protected readonly _injector: Injector;
|
|
34
|
+
protected readonly _httpService: HTTPService;
|
|
35
|
+
protected readonly _configService: IConfigService;
|
|
36
|
+
protected readonly _logService: ILogService;
|
|
37
|
+
protected readonly _snapshotServerService: SnapshotServerOverHTTPService;
|
|
38
|
+
constructor(_injector: Injector, _httpService: HTTPService, _configService: IConfigService, _logService: ILogService, _snapshotServerService: SnapshotServerOverHTTPService);
|
|
39
|
+
abstract createSocket(url: string): Promise<ICollaborationSocket | null>;
|
|
40
|
+
protected _doCreateSocket(url: string): ICollaborationSocket;
|
|
41
|
+
protected _submitChangeset(socket: ICollaborationSocket, request: {
|
|
42
|
+
unitType: number;
|
|
43
|
+
unitID: string;
|
|
44
|
+
changeset: ICollaborationChangeset;
|
|
45
|
+
}, timeoutMs: number): Promise<void>;
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cool-office/collaboration-client",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"license": "Apache-2.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./lib/cjs/index.js",
|
|
6
|
+
"module": "./lib/es/index.js",
|
|
7
|
+
"types": "./lib/types/src/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/types/src/index.d.ts",
|
|
11
|
+
"import": "./lib/es/index.js",
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"default": "./lib/es/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./lib/*": "./lib/*",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@cool-office/collaboration": "1.2.1",
|
|
20
|
+
"@cool-office/core": "1.2.0",
|
|
21
|
+
"@cool-office/network": "1.2.0",
|
|
22
|
+
"@cool-office/protocol": "1.2.0",
|
|
23
|
+
"rxjs": "7.8.2"
|
|
24
|
+
},
|
|
25
|
+
"version": "1.2.1",
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public",
|
|
28
|
+
"registry": "https://registry.npmjs.org/"
|
|
29
|
+
}
|
|
30
|
+
}
|