@univerjs-pro/collaboration-client 0.1.9
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/README.md +18 -0
- package/lib/cjs/index.js +4 -0
- package/lib/es/index.js +3626 -0
- package/lib/index.css +1 -0
- package/lib/types/controllers/collab-cursor/__tests__/doc-collab-cursor.controller.spec.d.ts +1 -0
- package/lib/types/controllers/collab-cursor/__tests__/serialize-text-ranges.spec.d.ts +1 -0
- package/lib/types/controllers/collab-cursor/__tests__/sheet-collab-cursor.controller.spec.d.ts +1 -0
- package/lib/types/controllers/collab-cursor/collab-cursor.controller.d.ts +24 -0
- package/lib/types/controllers/collab-cursor/doc-collab-cursor-entity.d.ts +40 -0
- package/lib/types/controllers/collab-cursor/doc-collab-cursor-render.controller.d.ts +22 -0
- package/lib/types/controllers/collab-cursor/serialize-text-ranges.d.ts +4 -0
- package/lib/types/controllers/collab-cursor/sheet-collab-cursor-entity.d.ts +41 -0
- package/lib/types/controllers/collab-cursor/sheet-collab-cursor-render.controller.d.ts +23 -0
- package/lib/types/controllers/collab-status/collab-status.controller.d.ts +18 -0
- package/lib/types/controllers/collaboration/__tests__/collaboration.controller.spec.d.ts +5 -0
- package/lib/types/controllers/collaboration/__tests__/mock-text-selection-render-manager.service.d.ts +10 -0
- package/lib/types/controllers/collaboration/__tests__/mocks.d.ts +55 -0
- package/lib/types/controllers/collaboration/collaboration-state.d.ts +266 -0
- package/lib/types/controllers/collaboration/collaboration.controller.d.ts +110 -0
- package/lib/types/controllers/collaboration/utils/changeset-utils.d.ts +17 -0
- package/lib/types/controllers/data-loader/__tests__/data-loader.controller.spec.d.ts +1 -0
- package/lib/types/controllers/data-loader/data-loader.controller.d.ts +23 -0
- package/lib/types/controllers/file-name/file-name.controller.d.ts +13 -0
- package/lib/types/index.d.ts +11 -0
- package/lib/types/locale/en-US.d.ts +4 -0
- package/lib/types/locale/index.d.ts +2 -0
- package/lib/types/locale/zh-CN.d.ts +29 -0
- package/lib/types/models/cursor.d.ts +29 -0
- package/lib/types/plugin.d.ts +20 -0
- package/lib/types/services/auth-server/auth-server.service.d.ts +15 -0
- package/lib/types/services/collaboration-session/collaboration-session.service.d.ts +107 -0
- package/lib/types/services/color-assign/color-assign.service.d.ts +11 -0
- package/lib/types/services/ime-cache-transform/doc-transform-ime-cache.service.d.ts +12 -0
- package/lib/types/services/local-cache/local-cache.service.d.ts +43 -0
- package/lib/types/services/member/member.service.d.ts +33 -0
- package/lib/types/services/range-selection/sheet-transform-selections.service.d.ts +9 -0
- package/lib/types/services/single-active-unit/single-active-unit.service.d.ts +40 -0
- package/lib/types/services/snapshot-server/snapshot-server.service.d.ts +22 -0
- package/lib/types/services/socket/collaboration-socket.service.d.ts +36 -0
- package/lib/types/services/socket/serialize.d.ts +4 -0
- package/lib/types/services/sync-editing-collab-cursor/doc-sync-editing-collab-cursor.service.d.ts +14 -0
- package/lib/types/services/text-selection/doc-transform-selections.service.d.ts +9 -0
- package/lib/types/services/undoredo/collaborative-undoredo.service.d.ts +20 -0
- package/lib/types/services/url/url.service.d.ts +13 -0
- package/lib/types/services/url/web-url.service.d.ts +11 -0
- package/lib/types/views/components/CollabStatus.d.ts +14 -0
- package/lib/types/views/components/CollabStatus.stories.d.ts +9 -0
- package/lib/types/views/shapes/doc-collab-cursor.d.ts +27 -0
- package/lib/types/views/shapes/sheet-collab-cursor.shape.d.ts +27 -0
- package/lib/types/views/shapes/text-bubble.shape.d.ts +20 -0
- package/lib/umd/index.js +4 -0
- package/package.json +102 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
import { MemberService } from '../../../services/member/member.service';
|
2
|
+
import { IChangeset, RevisionService } from '@univerjs-pro/collaboration';
|
3
|
+
import { IMutationInfo, IUniverInstanceService } from '@univerjs/core';
|
4
|
+
|
5
|
+
export interface IAssembledChangeset {
|
6
|
+
changeset: IChangeset;
|
7
|
+
pendingMutations: IMutationInfo[];
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Mutations those should be assembled into a single changeset.
|
11
|
+
*/
|
12
|
+
export declare const SINGLE_CHANGESET_MUTATIONS: Set<string>;
|
13
|
+
/**
|
14
|
+
* Assemble a changeset from a list of mutations.
|
15
|
+
*/
|
16
|
+
export declare function assembleSheetChangeset(pendingMutations: IMutationInfo[], unitID: string, univerInstanceService: IUniverInstanceService, revisionService: RevisionService, memberService: MemberService): IAssembledChangeset;
|
17
|
+
export declare function assembleDocChangeset(pendingMutations: IMutationInfo[], unitID: string, univerInstanceService: IUniverInstanceService, revisionService: RevisionService, memberService: MemberService): IAssembledChangeset;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { IURLService } from '../../services/url/url.service';
|
2
|
+
import { LocalCacheService } from '../../services/local-cache/local-cache.service';
|
3
|
+
import { SnapshotService } from '@univerjs-pro/collaboration';
|
4
|
+
import { IRemoteInstanceService } from '@univerjs/rpc';
|
5
|
+
import { ICommandService, ILogService, RxDisposable } from '@univerjs/core';
|
6
|
+
|
7
|
+
/**
|
8
|
+
* This controller loads data from the server.
|
9
|
+
*/
|
10
|
+
export declare class DataLoaderController extends RxDisposable {
|
11
|
+
private _urlService;
|
12
|
+
private readonly _logService;
|
13
|
+
private readonly _commandService;
|
14
|
+
private readonly _localCacheService;
|
15
|
+
private readonly _snapshotService;
|
16
|
+
constructor(_urlService: IURLService, _logService: ILogService, _commandService: ICommandService, _localCacheService: LocalCacheService, _snapshotService: SnapshotService, remoteInstanceService?: IRemoteInstanceService);
|
17
|
+
private _init;
|
18
|
+
private _setupSubUnitSync;
|
19
|
+
private _updateURLWithCurrentState;
|
20
|
+
private _updateSubUnitFromURLParams;
|
21
|
+
private _loadSheet;
|
22
|
+
private _loadDoc;
|
23
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Disposable, IConfigService, IUniverInstanceService } from '@univerjs/core';
|
2
|
+
|
3
|
+
export declare const DEFAULT_FILE_NAME_KEY = "DEFAULT_FILE_NAME";
|
4
|
+
/**
|
5
|
+
* This controller would change the current tab's title to the
|
6
|
+
* currently focused unit's name.
|
7
|
+
*/
|
8
|
+
export declare class FileNameController extends Disposable {
|
9
|
+
private readonly _univerInstanceService;
|
10
|
+
private readonly _configService;
|
11
|
+
constructor(_univerInstanceService: IUniverInstanceService, _configService: IConfigService);
|
12
|
+
private _init;
|
13
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
export { CollaborationController } from './controllers/collaboration/collaboration.controller';
|
2
|
+
export { SEND_CHANGESET_TIMEOUT_KEY } from './controllers/collaboration/collaboration-state';
|
3
|
+
export { CollaborationClientPlugin, type ICollaborationClientPluginConfig } from './plugin';
|
4
|
+
export { COLLAB_WEB_SOCKET_URL_KEY, CollaborationSession, CollaborationSessionService, HEARTBEAT_INTERVAL_KEY, HEARTBEAT_TIMEOUT_KEY, SessionStatus, } from './services/collaboration-session/collaboration-session.service';
|
5
|
+
export { LOCAL_CACHE_INTERVAL_KEY } from './services/local-cache/local-cache.service';
|
6
|
+
export { SNAPSHOT_SERVER_URL_KEY } from './services/snapshot-server/snapshot-server.service';
|
7
|
+
export type { ICollaborationSocket } from './services/socket/collaboration-socket.service';
|
8
|
+
export { COLLAB_SUBMIT_CHANGESET_URL_KEY, CollaborationSocketService, ICollaborationSocketService, } from './services/socket/collaboration-socket.service';
|
9
|
+
export { LOGIN_URL_KEY } from './services/auth-server/auth-server.service';
|
10
|
+
export { deserializeToCombResponse, serializeCombRequest } from './services/socket/serialize';
|
11
|
+
export { enUS, zhCN } from './locale';
|
@@ -0,0 +1,29 @@
|
|
1
|
+
declare const locales: {
|
2
|
+
collabStatus: {
|
3
|
+
fetchMiss: string;
|
4
|
+
conflict: string;
|
5
|
+
notCollab: string;
|
6
|
+
synced: string;
|
7
|
+
syncing: string;
|
8
|
+
offline: string;
|
9
|
+
};
|
10
|
+
session: {
|
11
|
+
'connection-failed': string;
|
12
|
+
'will-retry': string;
|
13
|
+
'room-full': string;
|
14
|
+
'collaboration-timeout': string;
|
15
|
+
};
|
16
|
+
conflict: {
|
17
|
+
title: string;
|
18
|
+
content: string;
|
19
|
+
};
|
20
|
+
collaboration: {
|
21
|
+
'single-unit': {
|
22
|
+
warning: string;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
auth: {
|
26
|
+
needGotoLoginAlert: string;
|
27
|
+
};
|
28
|
+
};
|
29
|
+
export default locales;
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { ITextRangeWithStyle } from '@univerjs/engine-render';
|
2
|
+
import { IRange } from '@univerjs/core';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* The data structure to store collab cursor info of sheet.
|
6
|
+
*/
|
7
|
+
export interface ISheetCollabCursor {
|
8
|
+
/** Background color of this collab cursor */
|
9
|
+
color: string;
|
10
|
+
/** Position of this cursor */
|
11
|
+
range: IRange;
|
12
|
+
/** Displayed user name of this cursor */
|
13
|
+
name: string;
|
14
|
+
/** The serialized range to check if two cursor are on the same position. */
|
15
|
+
selection: string;
|
16
|
+
/** Worksheet ID */
|
17
|
+
sheetID: string;
|
18
|
+
}
|
19
|
+
/**
|
20
|
+
* The data structure to store collab cursor info of doc.
|
21
|
+
*/
|
22
|
+
export interface IDocCollabCursor {
|
23
|
+
/** Background color of this collab cursor */
|
24
|
+
color: string;
|
25
|
+
/** Displayed user name of this cursor */
|
26
|
+
name: string;
|
27
|
+
/** The deserialized ranges of collab cursor. */
|
28
|
+
ranges: ITextRangeWithStyle[];
|
29
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { ICollaborationSocketService } from './services/socket/collaboration-socket.service';
|
2
|
+
import { Ctor, Injector } from '@wendellhu/redi';
|
3
|
+
import { LocaleService, Plugin, UniverInstanceType } from '@univerjs/core';
|
4
|
+
|
5
|
+
export interface ICollaborationClientPluginConfig {
|
6
|
+
socketService?: Ctor<ICollaborationSocketService>;
|
7
|
+
enableOfflineEditing?: boolean;
|
8
|
+
enableSingleActiveInstanceLock?: boolean;
|
9
|
+
collaborationUniverTypes?: UniverInstanceType[];
|
10
|
+
enableAuthServer?: boolean;
|
11
|
+
}
|
12
|
+
export declare class CollaborationClientPlugin extends Plugin {
|
13
|
+
private readonly _config;
|
14
|
+
protected _injector: Injector;
|
15
|
+
private readonly _localeService;
|
16
|
+
static pluginName: string;
|
17
|
+
constructor(_config: ICollaborationClientPluginConfig | undefined, _injector: Injector, _localeService: LocaleService);
|
18
|
+
onStarting(injector: Injector): void;
|
19
|
+
private _initModules;
|
20
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { HTTPService } from '@univerjs/network';
|
2
|
+
import { IConfigService, LocaleService } from '@univerjs/core';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* The config key to determined the URL provided by the auth server
|
6
|
+
*/
|
7
|
+
export declare const LOGIN_URL_KEY = "LOGIN_URL_KEY";
|
8
|
+
export declare class AuthServerService {
|
9
|
+
private readonly _configService;
|
10
|
+
private readonly _httpService;
|
11
|
+
private readonly localeService;
|
12
|
+
constructor(_configService: IConfigService, _httpService: HTTPService, localeService: LocaleService);
|
13
|
+
init(): void;
|
14
|
+
private _getLoginPath;
|
15
|
+
}
|
@@ -0,0 +1,107 @@
|
|
1
|
+
import { ICollaborationSocket, ICollaborationSocketService } from '../socket/collaboration-socket.service';
|
2
|
+
import { MemberService } from '../member/member.service';
|
3
|
+
import { Observable } from 'rxjs';
|
4
|
+
import { IDisposable, Injector } from '@wendellhu/redi';
|
5
|
+
import { ICollaborationEvent } from '@univerjs-pro/collaboration';
|
6
|
+
import { IBeforeCloseService, IMessageService } from '@univerjs/ui';
|
7
|
+
import { Nullable, Disposable, IConfigService, ILogService, LocaleService, RxDisposable } from '@univerjs/core';
|
8
|
+
|
9
|
+
export declare enum SessionStatus {
|
10
|
+
IDLE = 0,
|
11
|
+
JOINING = 1,
|
12
|
+
OFFLINE = 2,
|
13
|
+
ONLINE = 3
|
14
|
+
}
|
15
|
+
export declare const COLLAB_WEB_SOCKET_URL_KEY = "COLLAB_WEB_SOCKET_URL";
|
16
|
+
export declare const DEFAULT_COLLAB_WEB_SOCKET_URL = "ws://127.0.0.1:8000/universer-api/comb/connect";
|
17
|
+
/** The heartbeat interval in milliseconds. */
|
18
|
+
export declare const HEARTBEAT_INTERVAL_KEY = "HEARTBEAT_INTERVAL";
|
19
|
+
export declare const HEARTBEAT_TIMEOUT_KEY = "HEARTBEAT_TIMEOUT";
|
20
|
+
export declare const RETRY_CONNECTING_INTERVAL_KEY = "RETRY_CONNECTING_INTERVAL";
|
21
|
+
export declare const RETRY_CONNECTING_MAX_COUNT_KEY = "RETRY_CONNECTING_MAX_COUNT";
|
22
|
+
/**
|
23
|
+
* The data structure to represent a collaboration session. It also manages the collaborator's identity.
|
24
|
+
*
|
25
|
+
* An collaboration session maps to a unit.
|
26
|
+
*/
|
27
|
+
export declare class CollaborationSession extends RxDisposable implements IDisposable {
|
28
|
+
private readonly _unitID;
|
29
|
+
private readonly _logService;
|
30
|
+
private readonly _beforeCloseService;
|
31
|
+
private readonly _messageService;
|
32
|
+
private readonly _configService;
|
33
|
+
private readonly _localeService;
|
34
|
+
private readonly _memberService;
|
35
|
+
private readonly _sessionStatus$;
|
36
|
+
readonly sessionStatus$: Observable<SessionStatus>;
|
37
|
+
get sessionStatus(): SessionStatus;
|
38
|
+
private readonly _event$;
|
39
|
+
readonly event$: Observable<ICollaborationEvent>;
|
40
|
+
private _socket;
|
41
|
+
private _socketMessageSubscription;
|
42
|
+
constructor(_unitID: string, socket$: Observable<Nullable<ICollaborationSocket>>, _logService: ILogService, _beforeCloseService: IBeforeCloseService, _messageService: IMessageService, _configService: IConfigService, _localeService: LocaleService, _memberService: MemberService);
|
43
|
+
getMemberID(): string | null;
|
44
|
+
dispose(): void;
|
45
|
+
private _onCombEvent;
|
46
|
+
private _joinRoom;
|
47
|
+
private _onJoinRoomEvent;
|
48
|
+
private _onRecvEvent;
|
49
|
+
private _onUserJoin;
|
50
|
+
private _onUserLeave;
|
51
|
+
/**
|
52
|
+
* Send event to the collaboration server.
|
53
|
+
*/
|
54
|
+
send(event: ICollaborationEvent, unitID: string): Promise<void>;
|
55
|
+
private _collaborationTimeoutTimer;
|
56
|
+
private _scheduleCollaborationTimeoutTimer;
|
57
|
+
private _clearCollaborationTimeoutTimer;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* This service provide collaboration sessions to univer instances. A collaboration session
|
61
|
+
* may be used by different controllers of different features.
|
62
|
+
*/
|
63
|
+
export declare class CollaborationSessionService extends Disposable {
|
64
|
+
private readonly _injector;
|
65
|
+
private readonly _localeService;
|
66
|
+
private readonly _messageService;
|
67
|
+
private readonly _logService;
|
68
|
+
private readonly _configService;
|
69
|
+
private readonly _socketService;
|
70
|
+
/**
|
71
|
+
* Socket for collaboration sessions. Session are by unitID but the socket is share by collaboration sessions.
|
72
|
+
*/
|
73
|
+
private _socket$;
|
74
|
+
private get _socket();
|
75
|
+
private _sessions;
|
76
|
+
private _status$;
|
77
|
+
status$: Observable<SessionStatus>;
|
78
|
+
private _socketReady;
|
79
|
+
private _sendHeartbeatTimer;
|
80
|
+
private _timeoutTimer;
|
81
|
+
private _retryConnectingTimer;
|
82
|
+
private _retryCount;
|
83
|
+
constructor(_injector: Injector, _localeService: LocaleService, _messageService: IMessageService, _logService: ILogService, _configService: IConfigService, _socketService: ICollaborationSocketService);
|
84
|
+
dispose(): void;
|
85
|
+
/**
|
86
|
+
* Require a collaboration session.
|
87
|
+
* @param unitID
|
88
|
+
* @returns a collaboration session.
|
89
|
+
*/
|
90
|
+
requireSession(unitID: string): Promise<CollaborationSession>;
|
91
|
+
private _createSocket;
|
92
|
+
/**
|
93
|
+
* Try to establish connection to the collaboration server.
|
94
|
+
*
|
95
|
+
* Will send heartbeat channel to the server to keep the connection alive.
|
96
|
+
*/
|
97
|
+
private _tryEnsureSocket;
|
98
|
+
private _onConnectionOpen;
|
99
|
+
private _onConnectionFailed;
|
100
|
+
private _scheduleReconnection;
|
101
|
+
private _rescheduleHeartbeatEvent;
|
102
|
+
private _sendHeartbeat;
|
103
|
+
private _waitForHeartbeatResponse;
|
104
|
+
private _onMessage;
|
105
|
+
private _clearHeartbeatTimer;
|
106
|
+
private _clearTimeoutTimer;
|
107
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { Disposable } from '@univerjs/core';
|
2
|
+
|
3
|
+
export declare const BACKGROUND_TOKENS: string[];
|
4
|
+
/**
|
5
|
+
* This service assign a color to each collaboration member.
|
6
|
+
*/
|
7
|
+
export declare class ColorAssignService extends Disposable {
|
8
|
+
private _assignedColors;
|
9
|
+
private _colorIndex;
|
10
|
+
assignAColorForMemberID(memberID: string): string;
|
11
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { Injector } from '@wendellhu/redi';
|
2
|
+
import { ITransformService, IChangeset } from '@univerjs-pro/collaboration';
|
3
|
+
|
4
|
+
export declare class DocTransformIMECacheService {
|
5
|
+
private readonly _injector;
|
6
|
+
private readonly _transformService;
|
7
|
+
constructor(_injector: Injector, _transformService: ITransformService);
|
8
|
+
transformIMECache(changeset: IChangeset): void;
|
9
|
+
transformRemoteChangeset(changeset: IChangeset): IChangeset;
|
10
|
+
private _transformUndoRedoStack;
|
11
|
+
private _transformPreviousActiveRange;
|
12
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { UniverType } from '@univerjs/protocol';
|
2
|
+
import { IChangeset, RevisionService } from '@univerjs-pro/collaboration';
|
3
|
+
import { IBeforeCloseService } from '@univerjs/ui';
|
4
|
+
import { IMutationInfo, Nullable, Disposable, IConfigService, ILocalStorageService, LocaleService } from '@univerjs/core';
|
5
|
+
|
6
|
+
export interface IUnitCacheData {
|
7
|
+
unitID: string;
|
8
|
+
type: UniverType;
|
9
|
+
rev: number;
|
10
|
+
awaitingChangeset: Nullable<IChangeset>;
|
11
|
+
mutations: IMutationInfo[];
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* A config key to determine how often should Univer save local edits.
|
15
|
+
*/
|
16
|
+
export declare const LOCAL_CACHE_INTERVAL_KEY = "LOCAL_CACHE_INTERVAL";
|
17
|
+
export declare const LOCAL_CACHE_INTERVAL = 1000;
|
18
|
+
/**
|
19
|
+
* This service provide caching to the collaboration controller.
|
20
|
+
*/
|
21
|
+
export declare class LocalCacheService extends Disposable {
|
22
|
+
private readonly _configService;
|
23
|
+
private readonly _localStorageService;
|
24
|
+
private readonly _beforeCloseService;
|
25
|
+
private readonly _localeService;
|
26
|
+
private readonly _revisionService;
|
27
|
+
private _cachedData;
|
28
|
+
private _saveTaskMap;
|
29
|
+
private _disabled;
|
30
|
+
constructor(_configService: IConfigService, _localStorageService: ILocalStorageService, _beforeCloseService: IBeforeCloseService, _localeService: LocaleService, _revisionService: RevisionService);
|
31
|
+
disableLocalCache(): void;
|
32
|
+
enableLocalCache(): void;
|
33
|
+
dispose(): void;
|
34
|
+
loadOfflineData(unitID: string): Promise<Nullable<IUnitCacheData>>;
|
35
|
+
saveOfflineData(unitID: string, data: IUnitCacheData): Promise<boolean>;
|
36
|
+
updateOfflineData(unitID: string, type: UniverType, awaitingChangeset: Nullable<IChangeset>, pendingMutations: IMutationInfo[]): void;
|
37
|
+
private _scheduleSaving;
|
38
|
+
private _getSaveTimeout;
|
39
|
+
private _saveCache;
|
40
|
+
private _exhaustSavingTask;
|
41
|
+
private _setupBeforeClosingHandler;
|
42
|
+
}
|
43
|
+
export declare function getLocalCacheKey(unitID: string): string;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { IMember } from '@univerjs/protocol';
|
2
|
+
import { Nullable, Disposable, IUniverInstanceService } from '@univerjs/core';
|
3
|
+
|
4
|
+
export interface IUser extends IMember {
|
5
|
+
userID: string;
|
6
|
+
}
|
7
|
+
/**
|
8
|
+
* This services manages members is each rooms.
|
9
|
+
*/
|
10
|
+
export declare class MemberService extends Disposable {
|
11
|
+
private readonly _univerInstanceService;
|
12
|
+
private _roomMembers;
|
13
|
+
private _currentUser;
|
14
|
+
constructor(_univerInstanceService: IUniverInstanceService);
|
15
|
+
setCurrentUser(user: IUser): void;
|
16
|
+
getCurrentUser(): Nullable<IUser>;
|
17
|
+
updateMember(roomID: string, member: IMember): void;
|
18
|
+
removeMember(roomID: string, memberID: string): void;
|
19
|
+
getRoom(roomID: string): RoomMember | undefined;
|
20
|
+
getMember(roomID: string, memberID: string): IMember | undefined;
|
21
|
+
private _removeRoom;
|
22
|
+
dispose(): void;
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* This class manages members is a single room.
|
26
|
+
*/
|
27
|
+
export declare class RoomMember extends Disposable {
|
28
|
+
private readonly _members;
|
29
|
+
dispose(): void;
|
30
|
+
updateMember(member: IMember): void;
|
31
|
+
removeMember(memberID: string): void;
|
32
|
+
getMember(memberID: string): IMember | undefined;
|
33
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Injector } from '@wendellhu/redi';
|
2
|
+
import { IChangeset, ITransformService } from '@univerjs-pro/collaboration';
|
3
|
+
|
4
|
+
export declare class SheetTransformSelectionsService {
|
5
|
+
private readonly _injector;
|
6
|
+
private readonly _transformService;
|
7
|
+
constructor(_injector: Injector, _transformService: ITransformService);
|
8
|
+
transformSelections(changeset: IChangeset): void;
|
9
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { Observable } from 'rxjs';
|
2
|
+
import { Disposable } from '@univerjs/core';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* It is not recommended to open multiple units in different browser tabs at the same time,
|
6
|
+
* especially when the there is not access to the internet. There is a great chance of loosing
|
7
|
+
* offline data! So we should make there is only one active unit at a time.
|
8
|
+
*/
|
9
|
+
export declare const ISingleActiveUnitService: import('@wendellhu/redi').IdentifierDecorator<ISingleActiveUnitService>;
|
10
|
+
export interface ISingleActiveUnitService {
|
11
|
+
editingUnit: (unitID: string) => void;
|
12
|
+
getUnitStatus$: (unitID: string) => Observable<UnitStatus>;
|
13
|
+
}
|
14
|
+
export declare enum UnitStatus {
|
15
|
+
NO_OTHER_CLIENTS_EDITING = 0,
|
16
|
+
OTHER_CLIENTS_EDITING = 1
|
17
|
+
}
|
18
|
+
export declare class WebBrowserSingleActiveUnitService extends Disposable implements ISingleActiveUnitService {
|
19
|
+
private _id;
|
20
|
+
private _selfUnitIDs;
|
21
|
+
private _unitOnClients;
|
22
|
+
private _heartbeatTimer;
|
23
|
+
private _clearOtherTimers;
|
24
|
+
private _unitStatus;
|
25
|
+
constructor();
|
26
|
+
dispose(): void;
|
27
|
+
getUnitStatus$(unitID: string): Observable<UnitStatus>;
|
28
|
+
editingUnit(unitID: string): void;
|
29
|
+
disposeUnit(unitID: string): void;
|
30
|
+
private _init;
|
31
|
+
private _handleEvent;
|
32
|
+
private _handleJoinEvent;
|
33
|
+
private _scheduleClearOtherTimer;
|
34
|
+
private _removeClearOtherTimer;
|
35
|
+
private _handleLeaveEvent;
|
36
|
+
private _handleHeartbeatEvent;
|
37
|
+
private _send;
|
38
|
+
private _scheduleHeartbeat;
|
39
|
+
private _ensureSubject;
|
40
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
import { IFetchMissingChangesetsRequest, IFetchMissingChangesetsResponse, IGetResourcesRequest, IGetResourcesResponse, IGetSheetBlockRequest, IGetSheetBlockResponse, IGetUnitOnRevRequest, IGetUnitOnRevResponse, ISaveChangesetResponse, ISaveSheetBlockResponse, ISaveSnapshotResponse } from '@univerjs/protocol';
|
2
|
+
import { HTTPService } from '@univerjs/network';
|
3
|
+
import { ILogContext, ISnapshotServerService, IConfigService } from '@univerjs/core';
|
4
|
+
|
5
|
+
/**
|
6
|
+
* The config key to determined the URL provided by the snapshot server
|
7
|
+
* to load snapshot. The URL should not ends with a slash.
|
8
|
+
*/
|
9
|
+
export declare const SNAPSHOT_SERVER_URL_KEY = "SNAPSHOT_SERVER_URL_KEY";
|
10
|
+
export declare class SnapshotServerOverHTTPService implements ISnapshotServerService {
|
11
|
+
private readonly _configService;
|
12
|
+
private readonly _httpService;
|
13
|
+
constructor(_configService: IConfigService, _httpService: HTTPService);
|
14
|
+
getUnitOnRev(_context: ILogContext, params: IGetUnitOnRevRequest): Promise<IGetUnitOnRevResponse>;
|
15
|
+
getSheetBlock(_context: ILogContext, params: IGetSheetBlockRequest): Promise<IGetSheetBlockResponse>;
|
16
|
+
fetchMissingChangesets(_context: ILogContext, params: IFetchMissingChangesetsRequest): Promise<IFetchMissingChangesetsResponse>;
|
17
|
+
private _getAPIPrefixPath;
|
18
|
+
getResourcesRequest(_context: ILogContext, params: IGetResourcesRequest): Promise<IGetResourcesResponse>;
|
19
|
+
saveSnapshot(): Promise<ISaveSnapshotResponse>;
|
20
|
+
saveSheetBlock(): Promise<ISaveSheetBlockResponse>;
|
21
|
+
saveChangeset(): Promise<ISaveChangesetResponse>;
|
22
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { Observable } from 'rxjs';
|
2
|
+
import { IChangeset } from '@univerjs/protocol';
|
3
|
+
import { ICombRequestEvent, ICombResponseEvent, IFetchingMissEvent, ISubmitChangesetEvent } from '@univerjs-pro/collaboration';
|
4
|
+
import { ISocket, HTTPService, WebSocketService } from '@univerjs/network';
|
5
|
+
import { Nullable, IConfigService, ILogService, ISnapshotServerService } from '@univerjs/core';
|
6
|
+
|
7
|
+
export interface ICollaborationSocket extends Pick<ISocket, 'open$' | 'error$' | 'close$'> {
|
8
|
+
memberID: string;
|
9
|
+
message$: Observable<ICombResponseEvent>;
|
10
|
+
send: (event: ICombRequestEvent) => void;
|
11
|
+
close: () => void;
|
12
|
+
}
|
13
|
+
/**
|
14
|
+
* This service provides a socket that can be used to communicate with the remote collaboration server.
|
15
|
+
*/
|
16
|
+
export interface ICollaborationSocketService {
|
17
|
+
createSocket: (url: string) => Nullable<ICollaborationSocket>;
|
18
|
+
}
|
19
|
+
export declare const ICollaborationSocketService: import('@wendellhu/redi').IdentifierDecorator<ICollaborationSocketService>;
|
20
|
+
export declare const COLLAB_SUBMIT_CHANGESET_URL_KEY = "COLLAB_SUBMIT_CHANGESET_URL";
|
21
|
+
export declare class CollaborationSocketService implements ICollaborationSocketService {
|
22
|
+
protected readonly _http: HTTPService;
|
23
|
+
protected readonly _ws: WebSocketService;
|
24
|
+
protected readonly _configService: IConfigService;
|
25
|
+
protected readonly _logService: ILogService;
|
26
|
+
protected readonly _snapshotServerService: ISnapshotServerService;
|
27
|
+
constructor(_http: HTTPService, _ws: WebSocketService, _configService: IConfigService, _logService: ILogService, _snapshotServerService: ISnapshotServerService);
|
28
|
+
/**
|
29
|
+
* Create a socket that would connect to the remote collaboration server. It would throw an error when the socket cannot be created.
|
30
|
+
*
|
31
|
+
* @param URL The URL of the remote server.
|
32
|
+
*/
|
33
|
+
createSocket(URL: string): Nullable<ICollaborationSocket>;
|
34
|
+
protected _submitChangeset(socket: ICollaborationSocket, event: ISubmitChangesetEvent): Promise<void>;
|
35
|
+
protected _fetchMissChangesets(event: IFetchingMissEvent): Promise<IChangeset[]>;
|
36
|
+
}
|
package/lib/types/services/sync-editing-collab-cursor/doc-sync-editing-collab-cursor.service.d.ts
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ITextRangeWithStyle } from '@univerjs/engine-render';
|
2
|
+
import { Nullable, RxDisposable } from '@univerjs/core';
|
3
|
+
import { IUpdateCursor } from '@univerjs/protocol';
|
4
|
+
|
5
|
+
export interface ICollabEditingCursor {
|
6
|
+
unitID: string;
|
7
|
+
memberID: string;
|
8
|
+
textRanges: ITextRangeWithStyle[];
|
9
|
+
}
|
10
|
+
export declare class DocSyncEditingCollabCursorService extends RxDisposable {
|
11
|
+
private readonly _collabCursorState$;
|
12
|
+
readonly collabCursorState$: import('rxjs').Observable<Nullable<IUpdateCursor>>;
|
13
|
+
syncEditingCollabCursor(collabCursor: ICollabEditingCursor): void;
|
14
|
+
}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { Injector } from '@wendellhu/redi';
|
2
|
+
import { IChangeset, ITransformService } from '@univerjs-pro/collaboration';
|
3
|
+
|
4
|
+
export declare class DocTransformSelectionsService {
|
5
|
+
private readonly _injector;
|
6
|
+
private readonly _transformService;
|
7
|
+
constructor(_injector: Injector, _transformService: ITransformService);
|
8
|
+
transformSelections(changeset: IChangeset): void;
|
9
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { IChangeset, ITransformService } from '@univerjs-pro/collaboration';
|
2
|
+
import { IUndoRedoService, ICommandService, IContextService, ILogService, IUniverInstanceService, LocalUndoRedoService } from '@univerjs/core';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* `LocalUndoRedoService` cannot transform mutations in the undo redo stack under collaboration conditions.
|
6
|
+
*/
|
7
|
+
export interface ICollaborativeUndoRedoService extends IUndoRedoService {
|
8
|
+
transformUndoRedo: (unitID: string, changeset: IChangeset) => void;
|
9
|
+
}
|
10
|
+
export declare class CollaborativeUndoRedoService extends LocalUndoRedoService implements ICollaborativeUndoRedoService {
|
11
|
+
private readonly _transformService;
|
12
|
+
private readonly _logService;
|
13
|
+
constructor(_currentUniverSheet: IUniverInstanceService, _commandService: ICommandService, _contextService: IContextService, _transformService: ITransformService, _logService: ILogService);
|
14
|
+
transformUndoRedo(unitID: string, changesets: IChangeset): void;
|
15
|
+
private _clearUndo;
|
16
|
+
private _clearRedo;
|
17
|
+
private _substituteUndoStack;
|
18
|
+
private _substituteRedoStack;
|
19
|
+
private _transformStack;
|
20
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { Observable } from 'rxjs';
|
2
|
+
|
3
|
+
/**
|
4
|
+
* This service reads the url from the host platform and return url parts,
|
5
|
+
* such as queries, hashes and path.
|
6
|
+
*/
|
7
|
+
export interface IURLService {
|
8
|
+
getParam: (key: string) => string | undefined;
|
9
|
+
setParam: (key: string, value: string, useReplace?: boolean) => void;
|
10
|
+
removeParam: (key: string, useReplace?: boolean) => void;
|
11
|
+
urlChange$: Observable<void>;
|
12
|
+
}
|
13
|
+
export declare const IURLService: import('@wendellhu/redi').IdentifierDecorator<IURLService>;
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { IURLService } from './url.service';
|
2
|
+
import { Observable } from 'rxjs';
|
3
|
+
import { RxDisposable } from '@univerjs/core';
|
4
|
+
|
5
|
+
export declare class WebURLService extends RxDisposable implements IURLService {
|
6
|
+
readonly urlChange$: Observable<void>;
|
7
|
+
constructor();
|
8
|
+
setParam(key: string, value: string, useReplace?: boolean): void;
|
9
|
+
removeParam(key: string, useReplace?: boolean): void;
|
10
|
+
getParam(key: string): string | undefined;
|
11
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { CollaborationStatus } from '../../controllers/collaboration/collaboration-state';
|
2
|
+
import { Observable } from 'rxjs';
|
3
|
+
|
4
|
+
export interface IOnlineStatusProps {
|
5
|
+
/** The collaboration state of the currently focused unit. */
|
6
|
+
status$: Observable<CollaborationStatus>;
|
7
|
+
}
|
8
|
+
/**
|
9
|
+
* A component to display collaboration status to users.
|
10
|
+
*
|
11
|
+
* @param props
|
12
|
+
* @returns
|
13
|
+
*/
|
14
|
+
export declare function CollaborationStatusDisplay(props: Readonly<IOnlineStatusProps>): JSX.Element;
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import { CollaborationStatusDisplay } from './CollabStatus';
|
2
|
+
import { default as React } from 'react';
|
3
|
+
import { Meta } from '@storybook/react';
|
4
|
+
|
5
|
+
declare const meta: Meta<typeof CollaborationStatusDisplay>;
|
6
|
+
export default meta;
|
7
|
+
export declare const Playground: {
|
8
|
+
render: () => React.JSX.Element;
|
9
|
+
};
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import { IDocCollabCursor } from '../../models/cursor';
|
2
|
+
import { Documents, DocumentSkeleton, Scene } from '@univerjs/engine-render';
|
3
|
+
|
4
|
+
/**
|
5
|
+
* Render a single collaborated cursor on the canvas.
|
6
|
+
*/
|
7
|
+
export declare class DocCollabCursor {
|
8
|
+
private _cursor;
|
9
|
+
private _scene;
|
10
|
+
private _docSkeleton;
|
11
|
+
private _document;
|
12
|
+
private _shapes;
|
13
|
+
private _anchor;
|
14
|
+
private _textBubble;
|
15
|
+
private _anchorDot;
|
16
|
+
private _hideTimer;
|
17
|
+
private _eventUnsubscribe;
|
18
|
+
constructor(_cursor: IDocCollabCursor, _scene: Scene, _docSkeleton: DocumentSkeleton, _document: Documents);
|
19
|
+
private set _hover(value);
|
20
|
+
dispose(): void;
|
21
|
+
private _render;
|
22
|
+
private _drawAnchor;
|
23
|
+
private _handleHover;
|
24
|
+
private _drawRange;
|
25
|
+
private _getAnchorBounding;
|
26
|
+
private _getScale;
|
27
|
+
}
|