@textbus/collaborate 4.0.0-alpha.6 → 4.0.0-alpha.60

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,14 @@
1
- import { Module } from '@textbus/core';
1
+ import { Module, Textbus } from '@textbus/core';
2
2
  import { Provider } from '@viewfly/core';
3
+ import { UserInfo } from './user-activity';
4
+ export interface CollaborateConfig {
5
+ url: string;
6
+ roomName: string;
7
+ userinfo: UserInfo;
8
+ }
3
9
  export declare class CollaborateModule implements Module {
10
+ config: CollaborateConfig;
4
11
  providers: Provider[];
12
+ constructor(config: CollaborateConfig);
13
+ setup(textbus: Textbus): Promise<(() => void) | void> | (() => void) | void;
5
14
  }
@@ -1,38 +1,17 @@
1
- import { Observable, Subject, Subscription } from '@tanbo/stream';
2
- import { AbstractSelection, ComponentInstance, Registry, History, RootComponentRef, Scheduler, Selection, SelectionPaths, Slot } from '@textbus/core';
3
- import { Array as YArray, Doc as YDoc, Map as YMap, RelativePosition, Text as YText, Transaction, UndoManager, Item } from 'yjs';
4
- interface CursorPosition {
5
- anchor: RelativePosition;
6
- focus: RelativePosition;
7
- }
8
- declare class ContentMap {
9
- private slotAndYTextMap;
10
- private yTextAndSLotMap;
11
- set(key: Slot, value: YText): void;
12
- set(key: YText, value: Slot): void;
13
- get(key: Slot): YText | null;
14
- get(key: YText): Slot | null;
15
- delete(key: Slot | YText): void;
16
- }
17
- interface UpdateItem {
18
- record: boolean;
19
- action(): void;
20
- }
1
+ import { Observable } from '@tanbo/stream';
2
+ import { Registry, History, RootComponentRef, Scheduler, Selection } from '@textbus/core';
3
+ import { Doc as YDoc, Transaction, Item } from 'yjs';
21
4
  export declare abstract class CustomUndoManagerConfig {
22
5
  abstract captureTransaction?(arg0: Transaction): boolean;
23
6
  abstract deleteFilter?(arg0: Item): boolean;
24
7
  }
25
- interface CollaborateHistorySelectionPosition {
26
- before: CursorPosition | null;
27
- after: CursorPosition | null;
28
- }
29
8
  export declare class Collaborate implements History {
30
- protected stackSize: number;
31
- protected rootComponentRef: RootComponentRef;
32
- protected scheduler: Scheduler;
33
- protected registry: Registry;
34
- protected selection: Selection;
35
- protected undoManagerConfig: CustomUndoManagerConfig;
9
+ private stackSize;
10
+ private rootComponentRef;
11
+ private scheduler;
12
+ private registry;
13
+ private selection;
14
+ private undoManagerConfig;
36
15
  onLocalChangesApplied: Observable<void>;
37
16
  yDoc: YDoc;
38
17
  onBack: Observable<void>;
@@ -41,44 +20,56 @@ export declare class Collaborate implements History {
41
20
  onPush: Observable<void>;
42
21
  get canBack(): boolean;
43
22
  get canForward(): boolean;
44
- protected backEvent: Subject<void>;
45
- protected forwardEvent: Subject<void>;
46
- protected changeEvent: Subject<void>;
47
- protected pushEvent: Subject<void>;
48
- protected manager: UndoManager | null;
49
- protected subscriptions: Subscription[];
50
- protected updateFromRemote: boolean;
51
- protected contentSyncCaches: WeakMap<Slot<any>, () => void>;
52
- protected slotStateSyncCaches: WeakMap<Slot<any>, () => void>;
53
- protected slotsSyncCaches: WeakMap<ComponentInstance<unknown, unknown, unknown>, () => void>;
54
- protected componentStateSyncCaches: WeakMap<ComponentInstance<unknown, unknown, unknown>, () => void>;
55
- protected localChangesAppliedEvent: Subject<void>;
56
- protected selectionChangeEvent: Subject<SelectionPaths>;
57
- protected contentMap: ContentMap;
58
- protected updateRemoteActions: Array<UpdateItem>;
59
- protected noRecord: {};
60
- protected historyItems: Array<CollaborateHistorySelectionPosition>;
61
- protected index: number;
23
+ private backEvent;
24
+ private forwardEvent;
25
+ private changeEvent;
26
+ private pushEvent;
27
+ private manager;
28
+ private subscriptions;
29
+ private updateFromRemote;
30
+ private localChangesAppliedEvent;
31
+ private selectionChangeEvent;
32
+ private slotMap;
33
+ private updateRemoteActions;
34
+ private noRecord;
35
+ private historyItems;
36
+ private index;
62
37
  constructor(stackSize: number, rootComponentRef: RootComponentRef, scheduler: Scheduler, registry: Registry, selection: Selection, undoManagerConfig: CustomUndoManagerConfig);
63
38
  listen(): void;
64
39
  back(): void;
65
40
  forward(): void;
66
41
  clear(): void;
67
42
  destroy(): void;
68
- protected syncRootComponent(root: YMap<any>, rootComponent: ComponentInstance): void;
69
- protected getAbstractSelection(position: CursorPosition): AbstractSelection | null;
70
- protected getRelativeCursorLocation(): CursorPosition | null;
71
- protected syncSlotContent(content: YText, slot: Slot): void;
72
- protected syncSlotState(remoteSlot: YMap<any>, slot: Slot): void;
73
- protected syncComponentSlots(remoteSlots: YArray<any>, component: ComponentInstance): void;
74
- protected syncComponentState(remoteComponent: YMap<any>, component: ComponentInstance): void;
75
- protected runLocalUpdate(fn: () => void, record?: boolean): void;
76
- protected runRemoteUpdate(tr: Transaction, fn: () => void): void;
77
- protected createSharedComponentByComponent(component: ComponentInstance): YMap<any>;
78
- protected createSharedSlotBySlot(slot: Slot): YMap<any>;
79
- protected createComponentBySharedComponent(yMap: YMap<any>): ComponentInstance;
80
- protected createSlotBySharedSlot(sharedSlot: YMap<any>): Slot;
81
- protected cleanSubscriptionsBySlot(slot: Slot): void;
82
- protected cleanSubscriptionsByComponent(component: ComponentInstance): void;
43
+ private syncRootComponent;
44
+ private syncSharedMapToLocalMap;
45
+ private createLocalMapBySharedMap;
46
+ private createLocalArrayBySharedArray;
47
+ private syncLocalMapToSharedMap;
48
+ private createSharedMapByLocalMap;
49
+ private createSharedArrayByLocalArray;
50
+ private createSharedSlotByLocalSlot;
51
+ private createLocalSlotBySharedSlot;
52
+ private createSharedModelByLocalModel;
53
+ private createLocalModelBySharedByModel;
54
+ private getAbstractSelection;
55
+ private getRelativeCursorLocation;
56
+ private syncSlot;
57
+ private createSharedComponentByLocalComponent;
58
+ private createLocalComponentBySharedComponent;
59
+ /**
60
+ * 双向同步数组
61
+ * @param sharedArray
62
+ * @param localArray
63
+ * @private
64
+ */
65
+ private syncArray;
66
+ /**
67
+ * 双向同步对象
68
+ * @param sharedObject
69
+ * @param localObject
70
+ * @private
71
+ */
72
+ private syncObject;
73
+ private runLocalUpdate;
74
+ private runRemoteUpdate;
83
75
  }
84
- export {};