@univerjs-pro/collaboration 1.0.0-alpha.3 → 1.0.0-alpha.4
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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1 -1
- package/lib/index.js +1 -1
- package/lib/types/index.d.ts +2 -0
- package/lib/types/services/snapshot/snapshot-loading.service.d.ts +37 -0
- package/lib/types/services/snapshot/snapshot-transform.d.ts +4 -0
- package/lib/types/services/snapshot/snapshot.service.d.ts +6 -2
- package/lib/umd/index.js +1 -1
- package/package.json +29 -25
package/lib/types/index.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export type { ICombRequestEvent, ICombResponseEvent, IHeartbeatRequestEvent, IHe
|
|
|
16
16
|
export { UniverCollaborationPlugin } from './plugin';
|
|
17
17
|
export { CompressMutationService } from './services/compress-mutation/compress-mutation.service';
|
|
18
18
|
export { RevisionService, SINGLE_HISTORY_MUTATIONS, SINGLE_SNAPSHOT_MUTATIONS, } from './services/rev/rev.service';
|
|
19
|
+
export { SNAPSHOT_LOADING_PREVIEW_BLOCK_LIMIT, SnapshotLoadingService, SnapshotLoadStage, } from './services/snapshot/snapshot-loading.service';
|
|
20
|
+
export type { ISnapshotLoadState } from './services/snapshot/snapshot-loading.service';
|
|
19
21
|
export { SnapshotSaveService } from './services/snapshot/snapshot-save.service';
|
|
20
22
|
export { getSheetBlocksFromSnapshot, transformDocumentDataToSnapshot, transformSlideDataToSnapshot, transformSnapshotToDocumentData, transformSnapshotToSlideData, transformSnapshotToWorkbookData, transformWorkbookDataToSnapshot, } from './services/snapshot/snapshot-transform';
|
|
21
23
|
export { textDecoder, textEncoder, } from './services/snapshot/snapshot-utils';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ICellData, IObjectMatrixPrimitiveType, IWorkbookData, UniverInstanceType } from '@univerjs/core';
|
|
2
|
+
import { Disposable } from '@univerjs/core';
|
|
3
|
+
export declare const SNAPSHOT_LOADING_PREVIEW_BLOCK_LIMIT = 3;
|
|
4
|
+
export declare enum SnapshotLoadStage {
|
|
5
|
+
LOADING_SNAPSHOT = "loading-snapshot",
|
|
6
|
+
LOADING_BLOCKS = "loading-blocks",
|
|
7
|
+
COMPLETE = "complete",
|
|
8
|
+
ERROR = "error"
|
|
9
|
+
}
|
|
10
|
+
export interface ISnapshotLoadState {
|
|
11
|
+
unitId: string;
|
|
12
|
+
type: UniverInstanceType;
|
|
13
|
+
stage: SnapshotLoadStage;
|
|
14
|
+
totalBlocks: number;
|
|
15
|
+
loadedBlocks: number;
|
|
16
|
+
totalPreviewBlocks: number;
|
|
17
|
+
loadedPreviewBlocks: number;
|
|
18
|
+
previewReady: boolean;
|
|
19
|
+
activeSheetId?: string;
|
|
20
|
+
workbookShell?: IWorkbookData;
|
|
21
|
+
previewCellData?: IObjectMatrixPrimitiveType<ICellData>;
|
|
22
|
+
error?: Error;
|
|
23
|
+
}
|
|
24
|
+
/** Sheet snapshot loading state consumed by loading UI and preview renderers. */
|
|
25
|
+
export declare class SnapshotLoadingService extends Disposable {
|
|
26
|
+
private readonly _stateByUnit;
|
|
27
|
+
private readonly _state$;
|
|
28
|
+
readonly state$: import("rxjs").Observable<ReadonlyMap<string, ISnapshotLoadState>>;
|
|
29
|
+
begin(unitId: string, type: UniverInstanceType): void;
|
|
30
|
+
setSnapshot(unitId: string, workbookShell: IWorkbookData, activeSheetId: string, totalBlocks: number, totalPreviewBlocks: number): void;
|
|
31
|
+
addBlock(unitId: string, subUnitId: string, cellData: IObjectMatrixPrimitiveType<ICellData>, isPreviewBlock?: boolean): void;
|
|
32
|
+
complete(unitId: string): void;
|
|
33
|
+
fail(unitId: string, error: Error): void;
|
|
34
|
+
getState(unitId: string): ISnapshotLoadState | undefined;
|
|
35
|
+
dispose(): void;
|
|
36
|
+
private _setState;
|
|
37
|
+
}
|
|
@@ -28,6 +28,10 @@ export declare function transformBaseDataToSnapshot(context: ILogContext, base:
|
|
|
28
28
|
* @param sheetBlocks
|
|
29
29
|
*/
|
|
30
30
|
export declare function transformSnapshotToWorkbookData(snapshot: ISnapshot, sheetBlocks: (IDeserializedSheetBlock | ISheetBlock)[], _context?: ILogContext, logService?: ILogService): Promise<IWorkbookData>;
|
|
31
|
+
/**
|
|
32
|
+
* Builds the workbook shell from snapshot metadata without loading cell blocks.
|
|
33
|
+
*/
|
|
34
|
+
export declare function transformSnapshotToWorkbookDataWithoutBlocks(snapshot: ISnapshot): IWorkbookData;
|
|
31
35
|
export declare function transformSnapshotToBaseData(snapshot: ISnapshot, baseBlocks?: (IDeserializedSheetBlock | ISheetBlock)[], _context?: ILogContext, logService?: ILogService): Promise<IBaseSnapshot>;
|
|
32
36
|
export declare function transformSnapshotToDocumentData(snapshot: ISnapshot): IDocumentData;
|
|
33
37
|
export declare function transformDocumentDataToSnapshot(context: ILogContext, document: IDocumentData, unitID: string, rev: number, snapshotService: ISnapshotServerService): Promise<{
|
|
@@ -6,6 +6,7 @@ import type { ILogContext } from '../../utils';
|
|
|
6
6
|
import { ICommandService, ILogService, IResourceManagerService, IUniverInstanceService } from '@univerjs/core';
|
|
7
7
|
import { CompressMutationService } from '../compress-mutation/compress-mutation.service';
|
|
8
8
|
import { RevisionService } from '../rev/rev.service';
|
|
9
|
+
import { SnapshotLoadingService } from './snapshot-loading.service';
|
|
9
10
|
export declare function hasSlideSnapshotMeta(snapshot: ISnapshot | null | undefined): boolean;
|
|
10
11
|
export declare function hasBoardSnapshotMeta(snapshot: ISnapshot | null | undefined): boolean;
|
|
11
12
|
/**
|
|
@@ -38,6 +39,7 @@ export interface ISnapshotServerService {
|
|
|
38
39
|
}
|
|
39
40
|
export interface ISnapshotLoadOptions {
|
|
40
41
|
createOptions?: ICreateUnitOptions;
|
|
42
|
+
initialSubUnitId?: string;
|
|
41
43
|
}
|
|
42
44
|
/**
|
|
43
45
|
* The service provides methods to load snapshots from the snapshot server.
|
|
@@ -50,12 +52,14 @@ export declare class SnapshotService {
|
|
|
50
52
|
private readonly _logService;
|
|
51
53
|
private _compressMutationService;
|
|
52
54
|
private _resourceManagerService;
|
|
53
|
-
|
|
55
|
+
private readonly _snapshotLoadingService;
|
|
56
|
+
constructor(_revisionService: RevisionService, _univerInstanceService: IUniverInstanceService, _snapshotServerService: ISnapshotServerService, _commandService: ICommandService, _logService: ILogService, _compressMutationService: CompressMutationService, _resourceManagerService: IResourceManagerService, _snapshotLoadingService: SnapshotLoadingService);
|
|
54
57
|
loadSheet(unitId: string, rev: number, context?: ILogContext, options?: ISnapshotLoadOptions): Promise<Workbook>;
|
|
58
|
+
private _getPrioritizedSheetBlocks;
|
|
55
59
|
loadBase(unitId: string, rev: number, context?: ILogContext, options?: ISnapshotLoadOptions): Promise<BaseDataModel>;
|
|
56
60
|
loadDoc(unitID: string, rev: number, context?: ILogContext, options?: ISnapshotLoadOptions): Promise<DocumentDataModel>;
|
|
57
61
|
loadSlide(unitID: string, rev?: number, context?: ILogContext, options?: ISnapshotLoadOptions): Promise<SlideModel>;
|
|
58
|
-
loadBoard(unitID: string, rev?: number, context?: ILogContext): Promise<BoardModel>;
|
|
62
|
+
loadBoard(unitID: string, rev?: number, context?: ILogContext, options?: ISnapshotLoadOptions): Promise<BoardModel>;
|
|
59
63
|
saveSheet(_context: ILogContext, workbook: Workbook): IWorkbookData;
|
|
60
64
|
saveBase(_context: ILogContext, base: BaseDataModel): IBaseSnapshot;
|
|
61
65
|
saveDoc(_context: ILogContext, document: DocumentDataModel): IDocumentData;
|