@univerjs-pro/collaboration-client 0.4.0 → 0.4.1-experimental.20241023-bbb123f

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.
@@ -1,7 +1,6 @@
1
- import { IDisposable, IMutationInfo, ICommandService, ILogService, Injector, IPermissionService, LocaleService, RxDisposable } from '@univerjs/core';
1
+ import { IDisposable, IMutationInfo, Nullable, ICommandService, ILogService, Injector, IPermissionService, LocaleService, RxDisposable } from '@univerjs/core';
2
2
  import { UniverType } from '@univerjs/protocol';
3
3
  import { Observable, BehaviorSubject } from 'rxjs';
4
- import { Nullable } from 'vitest';
5
4
  import { CollaborationSession } from '../../services/collaboration-session/collaboration-session';
6
5
  import { CollaborationState, ICollaborationStateHandler, CollaborationStatus } from './collaboration-state';
7
6
  import { DocStateChangeManagerService } from '@univerjs/docs-ui';
@@ -60,6 +59,7 @@ export declare abstract class CollaborationEntity extends RxDisposable {
60
59
  private _applyRemoteChangeset;
61
60
  private _onRemoteACK;
62
61
  private _onRemoteRejected;
62
+ private _onRemoteRetry;
63
63
  private _onFetchMissResult;
64
64
  private _toggleOffline;
65
65
  private _toggleOnline;
@@ -1,5 +1,6 @@
1
1
  import { IMutationInfo, Nullable, ICommandService, IConfigService, ILogService, Injector, IPermissionService, IUniverInstanceService, LocaleService } from '@univerjs/core';
2
2
  import { IAcknowledgedChangeset, IChangeset, ITransformService, RevisionService } from '@univerjs-pro/collaboration';
3
+ import { Observable } from 'rxjs';
3
4
  import { ICollabEditingCursor } from '../../services/sync-editing-collab-cursor/doc-sync-editing-collab-cursor.service';
4
5
  import { ICollaborativeUndoRedoService } from '../../services/undoredo/collaborative-undoredo.service';
5
6
  import { UniverType } from '@univerjs/protocol';
@@ -80,6 +81,10 @@ export declare abstract class CollaborationState {
80
81
  abstract onRemoteRej(config?: {
81
82
  isPermissionRej: boolean;
82
83
  }): CollaborationState;
84
+ /**
85
+ * Received a retry message from the server, meaning that some unexpected error occurred in server.
86
+ */
87
+ abstract onRemoteRetry(changeset: IChangeset): CollaborationState;
83
88
  abstract toggleOffline(): CollaborationState;
84
89
  abstract toggleOnline(): CollaborationState;
85
90
  /**
@@ -117,6 +122,7 @@ export declare class SyncedState extends CollaborationState {
117
122
  private _onConflict;
118
123
  onRemoteAck(): never;
119
124
  onRemoteRej(): CollaborationState;
125
+ onRemoteRetry(): CollaborationState;
120
126
  toggleOffline(): CollaborationState;
121
127
  toggleOnline(): CollaborationState;
122
128
  resend(): void;
@@ -142,6 +148,7 @@ export declare class PendingState extends CollaborationState {
142
148
  onRemoteChangeset(changeset: IChangeset): CollaborationState;
143
149
  onRemoteAck(): CollaborationState;
144
150
  onRemoteRej(): CollaborationState;
151
+ onRemoteRetry(): CollaborationState;
145
152
  toggleOffline(): CollaborationState;
146
153
  toggleOnline(): CollaborationState;
147
154
  /**
@@ -163,6 +170,9 @@ export declare class AwaitingState extends CollaborationState {
163
170
  private readonly _logService;
164
171
  private readonly _transformService;
165
172
  readonly status = CollaborationStatus.AWAITING;
173
+ private _resendTimeout;
174
+ private _resendTimer;
175
+ private _sender;
166
176
  constructor(unitID: string, type: UniverType, awaitingChangeset: IChangeset, handler: ICollaborationStateHandler, _injector: Injector, revisionService: RevisionService, localCacheService: LocalCacheService, commandService: ICommandService, _logService: ILogService, _transformService: ITransformService, undoRedoService: ICollaborativeUndoRedoService);
167
177
  appendMutation(mutation: IMutationInfo): CollaborationState;
168
178
  onRemoteChangeset(changeset: IChangeset): CollaborationState;
@@ -170,10 +180,13 @@ export declare class AwaitingState extends CollaborationState {
170
180
  onRemoteRej(config?: {
171
181
  isPermissionRej: boolean;
172
182
  }): CollaborationState;
183
+ onRemoteRetry(changeset: IChangeset): CollaborationState;
173
184
  toggleOffline(): CollaborationState;
174
185
  toggleOnline(): CollaborationState;
175
186
  resend(): void;
176
187
  private _onConflict;
188
+ private _resendWithTimeout;
189
+ private _clearScheduledTask;
177
190
  }
178
191
  /**
179
192
  * Some local mutations are sent to the server and waiting for acknowledgement, yet still some local mutations
@@ -184,17 +197,26 @@ export declare class AwaitingWithPendingState extends CollaborationState {
184
197
  private readonly _logService;
185
198
  private readonly _transformService;
186
199
  readonly status = CollaborationStatus.AWAITING_WITH_PENDING;
187
- constructor(unitID: string, type: UniverType, awaitingChangeset: IChangeset, pendingMutations: IMutationInfo[], handler: ICollaborationStateHandler, _injector: Injector, revisionService: RevisionService, localCacheService: LocalCacheService, commandService: ICommandService, _logService: ILogService, _transformService: ITransformService, undoRedoService: ICollaborativeUndoRedoService);
200
+ private _resendTimeout;
201
+ private _resendTimer;
202
+ private _sender;
203
+ constructor(unitID: string, type: UniverType, awaitingChangeset: IChangeset, pendingMutations: IMutationInfo[], handler: ICollaborationStateHandler, timer: Observable<{
204
+ timeout: number;
205
+ reqId: number;
206
+ }> | undefined, _injector: Injector, revisionService: RevisionService, localCacheService: LocalCacheService, commandService: ICommandService, _logService: ILogService, _transformService: ITransformService, undoRedoService: ICollaborativeUndoRedoService);
188
207
  appendMutation(mutation: IMutationInfo): CollaborationState;
189
208
  onRemoteChangeset(changeset: IChangeset): CollaborationState;
190
209
  onRemoteAck(changeset: IAcknowledgedChangeset): CollaborationState;
191
210
  onRemoteRej(config?: {
192
211
  isPermissionRej: boolean;
193
212
  }): CollaborationState;
213
+ onRemoteRetry(changeset: IChangeset): CollaborationState;
194
214
  toggleOffline(): CollaborationState;
195
215
  toggleOnline(): CollaborationState;
196
216
  resend(): void;
197
217
  private _onConflict;
218
+ private _resendWithTimeout;
219
+ private _clearScheduledTask;
198
220
  }
199
221
  /**
200
222
  * This state is special for handling collaboration conflicts.
@@ -213,6 +235,7 @@ export declare class ConflictState extends CollaborationState {
213
235
  onRemoteChangeset(): CollaborationState;
214
236
  onRemoteAck(): CollaborationState;
215
237
  onRemoteRej(): CollaborationState;
238
+ onRemoteRetry(): CollaborationState;
216
239
  toggleOffline(): CollaborationState;
217
240
  toggleOnline(): CollaborationState;
218
241
  resend(): void;
@@ -228,6 +251,7 @@ export declare class OfflineState extends CollaborationState {
228
251
  onRemoteChangeset(_changeset: IChangeset): CollaborationState;
229
252
  onRemoteAck(): CollaborationState;
230
253
  onRemoteRej(): CollaborationState;
254
+ onRemoteRetry(): CollaborationState;
231
255
  toggleOffline(): CollaborationState;
232
256
  toggleOnline(): CollaborationState;
233
257
  resend(): void;
@@ -265,6 +289,7 @@ export declare class FetchingMissState extends CollaborationState {
265
289
  onRemoteRej(config?: {
266
290
  isPermissionRej: boolean;
267
291
  }): CollaborationState;
292
+ onRemoteRetry(): CollaborationState;
268
293
  toggleOffline(): CollaborationState;
269
294
  toggleOnline(): CollaborationState;
270
295
  private _onConflict;
@@ -1,5 +1,6 @@
1
1
  import { IMutationInfo, IUniverInstanceService } from '@univerjs/core';
2
2
  import { IChangeset, RevisionService } from '@univerjs-pro/collaboration';
3
+ import { Observable } from 'rxjs';
3
4
  import { MemberService } from '../../../services/member/member.service';
4
5
  export interface IAssembledChangeset {
5
6
  changeset: IChangeset;
@@ -14,3 +15,4 @@ export declare const SINGLE_CHANGESET_MUTATIONS: Set<string>;
14
15
  */
15
16
  export declare function assembleSheetChangeset(pendingMutations: IMutationInfo[], unitID: string, univerInstanceService: IUniverInstanceService, revisionService: RevisionService, memberService: MemberService): IAssembledChangeset;
16
17
  export declare function assembleDocChangeset(pendingMutations: IMutationInfo[], unitID: string, univerInstanceService: IUniverInstanceService, revisionService: RevisionService, memberService: MemberService): IAssembledChangeset;
18
+ export declare function createTimerObservable$<T>(ms: number, options: T): Observable<T>;
@@ -1,11 +1,11 @@
1
- import { IConfigService, ILogService, LocaleService, RxDisposable, IDisposable, Nullable } from '@univerjs/core';
2
- import { ITelemetryService } from '@univerjs/telemetry';
3
- import { IBeforeCloseService, IMessageService } from '@univerjs/ui';
1
+ import { IDisposable, Nullable, IConfigService, ILogService, LocaleService, RxDisposable } from '@univerjs/core';
4
2
  import { ICollaborationEvent } from '@univerjs-pro/collaboration';
5
3
  import { Observable } from 'rxjs';
4
+ import { ICollaborationSocket } from '../socket/collaboration-socket.service';
5
+ import { ITelemetryService } from '@univerjs/telemetry';
6
+ import { IBeforeCloseService, IMessageService } from '@univerjs/ui';
6
7
  import { CommentService } from '../comment/comment.service';
7
8
  import { MemberService } from '../member/member.service';
8
- import { ICollaborationSocket } from '../socket/collaboration-socket.service';
9
9
  export declare enum SessionStatus {
10
10
  IDLE = 0,
11
11
  JOINING = 1,