@textbus/collaborate 2.0.0-alpha.75 → 2.0.0-alpha.79

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  import { Injectable } from '@tanbo/di'
2
- import { filter, microTask, Observable, Subject, Subscription } from '@tanbo/stream'
2
+ import { merge, microTask, Observable, Subject, Subscription } from '@tanbo/stream'
3
3
  import {
4
4
  RootComponentRef,
5
5
  Starter,
@@ -7,13 +7,21 @@ import {
7
7
  Registry,
8
8
  Selection,
9
9
  SelectionPaths,
10
- History, Renderer
10
+ History, Renderer, Slot, ComponentInstance, makeError, Formats
11
11
  } from '@textbus/core'
12
- import { Doc as YDoc, UndoManager } from 'yjs'
13
- import { LocalToRemote } from './collab/local-to-remote'
14
- import { RemoteToLocal } from './collab/remote-to-local'
12
+ import {
13
+ Doc as YDoc,
14
+ Map as YMap,
15
+ Text as YText,
16
+ Array as YArray,
17
+ UndoManager,
18
+ Transaction
19
+ } from 'yjs'
20
+
15
21
  import { CollaborateCursor, RemoteSelection } from './collab/_api'
16
22
 
23
+ const collaborateErrorFn = makeError('Collaborate')
24
+
17
25
  @Injectable()
18
26
  export class Collaborate implements History {
19
27
  onSelectionChange: Observable<SelectionPaths>
@@ -31,9 +39,6 @@ export class Collaborate implements History {
31
39
  return this.manager?.canRedo()
32
40
  }
33
41
 
34
- private localToRemote = new LocalToRemote()
35
- private remoteToLocal = new RemoteToLocal(this.yDoc, this.translator, this.selection, this.registry)
36
-
37
42
  private backEvent = new Subject<void>()
38
43
  private forwardEvent = new Subject<void>()
39
44
  private changeEvent = new Subject<void>()
@@ -42,7 +47,12 @@ export class Collaborate implements History {
42
47
  private manager!: UndoManager
43
48
 
44
49
  private subscriptions: Subscription[] = []
45
- private updateFromSelf = true
50
+ private updateFromRemote = false
51
+
52
+ private contentSyncCaches = new WeakMap<Slot, () => void>()
53
+ private slotStateSyncCaches = new WeakMap<Slot, () => void>()
54
+ private slotsSyncCaches = new WeakMap<ComponentInstance, () => void>()
55
+ private componentStateSyncCaches = new WeakMap<ComponentInstance, () => void>()
46
56
 
47
57
  private selectionChangeEvent = new Subject<SelectionPaths>()
48
58
 
@@ -102,32 +112,357 @@ export class Collaborate implements History {
102
112
  this.manager = new UndoManager(root, {
103
113
  trackedOrigins: new Set<any>([this.yDoc])
104
114
  })
105
- root.observeDeep((events, transaction) => {
106
- if (transaction.origin === this.yDoc) {
107
- return
108
- }
109
- this.updateFromSelf = false
115
+ this.syncContent(root, rootComponent.slots.get(0)!)
110
116
 
111
- this.remoteToLocal.transform(events, rootComponent)
112
- this.renderer.render()
113
- this.selection.restore()
114
- this.updateFromSelf = true
115
- })
116
117
  this.subscriptions.push(
117
- this.rootComponentRef.component.changeMarker.onChange.pipe(
118
- filter(() => {
119
- return this.updateFromSelf
120
- }),
118
+ merge(
119
+ rootComponent.changeMarker.onForceChange,
120
+ rootComponent.changeMarker.onChange
121
+ ).pipe(
121
122
  microTask()
122
- ).subscribe((operations) => {
123
- this.yDoc.transact(() => {
124
- operations.forEach(operation => {
125
- this.localToRemote.transform(operation, root)
126
- })
127
- }, this.yDoc)
123
+ ).subscribe(() => {
128
124
  this.renderer.render()
129
125
  this.selection.restore()
130
126
  })
131
127
  )
132
128
  }
129
+
130
+ private syncContent(content: YText, slot: Slot) {
131
+ const fn = this.contentSyncCaches.get(slot)
132
+ if (fn) {
133
+ fn()
134
+ }
135
+ const syncRemote = (ev, tr) => {
136
+ this.runRemoteUpdate(tr, () => {
137
+ slot.retain(0)
138
+ ev.delta.forEach(action => {
139
+ if (Reflect.has(action, 'retain')) {
140
+ slot.retain(action.retain!, makeFormats(this.registry, action.attributes))
141
+ } else if (action.insert) {
142
+ const index = slot.index
143
+ let length = 1
144
+ if (typeof action.insert === 'string') {
145
+ length = action.insert.length
146
+ slot.insert(action.insert, makeFormats(this.registry, action.attributes))
147
+ } else {
148
+ const sharedComponent = action.insert as YMap<any>
149
+ const component = this.createComponentBySharedComponent(sharedComponent)
150
+ this.syncSlots(sharedComponent.get('slots'), component)
151
+ this.syncComponent(sharedComponent, component)
152
+ slot.insert(component)
153
+ }
154
+ if (this.selection.isSelected) {
155
+ if (slot === this.selection.startSlot && this.selection.startOffset! >= index) {
156
+ this.selection.setStart(slot, this.selection.startOffset! + length)
157
+ }
158
+ if (slot === this.selection.endSlot && this.selection.endOffset! >= index) {
159
+ this.selection.setEnd(slot, this.selection.endOffset! + length)
160
+ }
161
+ }
162
+ } else if (action.delete) {
163
+ const index = slot.index
164
+ slot.retain(slot.index)
165
+ slot.delete(action.delete)
166
+ if (this.selection.isSelected) {
167
+ if (slot === this.selection.startSlot && this.selection.startOffset! >= index) {
168
+ this.selection.setStart(slot, this.selection.startOffset! - action.delete)
169
+ }
170
+ if (slot === this.selection.endSlot && this.selection.endOffset! >= index) {
171
+ this.selection.setEnd(slot, this.selection.endOffset! - action.delete)
172
+ }
173
+ }
174
+ } else if (action.attributes) {
175
+ slot.updateState(draft => {
176
+ Object.assign(draft, action.attributes)
177
+ })
178
+ }
179
+ })
180
+ })
181
+ }
182
+ content.observe(syncRemote)
183
+
184
+ const sub = slot.onContentChange.subscribe(actions => {
185
+ this.runLocalUpdate(() => {
186
+ let offset = 0
187
+ let length = 0
188
+ for (const action of actions) {
189
+ if (action.type === 'retain') {
190
+ if (action.formats) {
191
+ content.format(offset, action.offset, action.formats)
192
+ } else {
193
+ offset = action.offset
194
+ }
195
+ } else if (action.type === 'insert') {
196
+ const delta = content.toDelta()
197
+ const isEmpty = delta.length === 1 && delta[0].insert === Slot.emptyPlaceholder
198
+ if (typeof action.content === 'string') {
199
+ length = action.content.length
200
+ content.insert(offset, action.content)
201
+ } else {
202
+ length = 1
203
+ const component = slot.getContentAtIndex(offset) as ComponentInstance
204
+ const sharedComponent = this.createSharedComponentByComponent(component)
205
+ content.insertEmbed(offset, sharedComponent)
206
+ }
207
+ if (action.formats) {
208
+ content.format(offset, length, action.formats)
209
+ }
210
+ if (isEmpty && offset === 0) {
211
+ content.delete(content.length - 1, 1)
212
+ }
213
+ offset += length
214
+ } else if (action.type === 'delete') {
215
+ const delta = content.toDelta()
216
+ content.delete(offset, action.count)
217
+ if (content.length === 0) {
218
+ content.insert(0, '\n', delta[0]?.attributes)
219
+ }
220
+ }
221
+ }
222
+ })
223
+ })
224
+ this.contentSyncCaches.set(slot, () => {
225
+ content.unobserve(syncRemote)
226
+ sub.unsubscribe()
227
+ })
228
+ }
229
+
230
+ private syncSlot(remoteSlot: YMap<any>, slot: Slot) {
231
+ const fn = this.slotStateSyncCaches.get(slot)
232
+ if (fn) {
233
+ fn()
234
+ }
235
+ const syncRemote = (ev, tr) => {
236
+ this.runRemoteUpdate(tr, () => {
237
+ ev.keysChanged.forEach(key => {
238
+ if (key === 'state') {
239
+ const state = (ev.target as YMap<any>).get('state')
240
+ slot.updateState(draft => {
241
+ Object.assign(draft, state)
242
+ })
243
+ }
244
+ })
245
+ })
246
+ }
247
+ remoteSlot.observe(syncRemote)
248
+
249
+ const sub = slot.onStateChange.subscribe(actions => {
250
+ this.runLocalUpdate(() => {
251
+ actions.forEach(action => {
252
+ remoteSlot.set('state', action.value)
253
+ })
254
+ })
255
+ })
256
+ this.slotStateSyncCaches.set(slot, () => {
257
+ remoteSlot.unobserve(syncRemote)
258
+ sub.unsubscribe()
259
+ })
260
+ }
261
+
262
+ private syncSlots(remoteSlots: YArray<any>, component: ComponentInstance) {
263
+ const slots = component.slots
264
+ const fn = this.slotsSyncCaches.get(component)
265
+ if (fn) {
266
+ fn()
267
+ }
268
+ const syncRemote = (ev, tr) => {
269
+ this.runRemoteUpdate(tr, () => {
270
+ ev.delta.forEach(action => {
271
+ if (Reflect.has(action, 'retain')) {
272
+ slots.retain(action.retain!)
273
+ } else if (action.insert) {
274
+ (action.insert as Array<YMap<any>>).forEach(item => {
275
+ const slot = this.createSlotBySharedSlot(item)
276
+ slots.insert(slot)
277
+ this.syncContent(item.get('content'), slot)
278
+ this.syncSlot(item, slot)
279
+ })
280
+ } else if (action.delete) {
281
+ slots.retain(slots.index)
282
+ slots.delete(action.delete)
283
+ }
284
+ })
285
+ })
286
+ }
287
+ remoteSlots.observe(syncRemote)
288
+
289
+ const sub = slots.onChange.subscribe(operations => {
290
+ this.runLocalUpdate(() => {
291
+ const applyActions = operations.apply
292
+ let index: number
293
+ applyActions.forEach(action => {
294
+ if (action.type === 'retain') {
295
+ index = action.offset
296
+ } else if (action.type === 'insertSlot') {
297
+ const slot = slots.get(index)!
298
+ const sharedSlot = this.createSharedSlotBySlot(slot)
299
+ remoteSlots.insert(index, [sharedSlot])
300
+ index++
301
+ } else if (action.type === 'delete') {
302
+ remoteSlots.delete(index, action.count)
303
+ }
304
+ })
305
+ })
306
+ })
307
+
308
+ this.slotsSyncCaches.set(component, () => {
309
+ remoteSlots.unobserve(syncRemote)
310
+ sub.unsubscribe()
311
+ })
312
+ }
313
+
314
+ private syncComponent(remoteComponent: YMap<any>, component: ComponentInstance) {
315
+ const fn = this.componentStateSyncCaches.get(component)
316
+ if (fn) {
317
+ fn()
318
+ }
319
+ const syncRemote = (ev, tr) => {
320
+ this.runRemoteUpdate(tr, () => {
321
+ ev.keysChanged.forEach(key => {
322
+ if (key === 'state') {
323
+ const state = (ev.target as YMap<any>).get('state')
324
+ component.updateState(draft => {
325
+ Object.assign(draft, state)
326
+ })
327
+ }
328
+ })
329
+ })
330
+ }
331
+ remoteComponent.observe(syncRemote)
332
+
333
+ const sub = component.onStateChange.subscribe(newState => {
334
+ this.runLocalUpdate(() => {
335
+ remoteComponent.set('state', newState)
336
+ })
337
+ })
338
+ this.componentStateSyncCaches.set(component, () => {
339
+ remoteComponent.unobserve(syncRemote)
340
+ sub.unsubscribe()
341
+ })
342
+ }
343
+
344
+ private runLocalUpdate(fn: () => void) {
345
+ if (this.updateFromRemote) {
346
+ return
347
+ }
348
+ fn()
349
+ }
350
+
351
+ private runRemoteUpdate(tr: Transaction, fn: () => void) {
352
+ if (!tr.origin) {
353
+ return
354
+ }
355
+ this.updateFromRemote = true
356
+ fn()
357
+ this.updateFromRemote = false
358
+ }
359
+
360
+ private createSharedComponentByComponent(component: ComponentInstance): YMap<any> {
361
+ const sharedComponent = new YMap()
362
+ sharedComponent.set('state', component.state)
363
+ sharedComponent.set('name', component.name)
364
+ const sharedSlots = new YArray()
365
+ sharedComponent.set('slots', sharedSlots)
366
+ component.slots.toArray().forEach(slot => {
367
+ const sharedSlot = this.createSharedSlotBySlot(slot)
368
+ sharedSlots.push([sharedSlot])
369
+ })
370
+ this.syncSlots(sharedSlots, component)
371
+ this.syncComponent(sharedComponent, component)
372
+ return sharedComponent
373
+ }
374
+
375
+ private createSharedSlotBySlot(slot: Slot): YMap<any> {
376
+ const sharedSlot = new YMap()
377
+ sharedSlot.set('schema', slot.schema)
378
+ sharedSlot.set('state', slot.state)
379
+ const sharedContent = new YText()
380
+ sharedSlot.set('content', sharedContent)
381
+ let offset = 0
382
+ slot.toDelta().forEach(i => {
383
+ let formats: any = {}
384
+ if (i.formats) {
385
+ i.formats.forEach(item => {
386
+ formats[item[0].name] = item[1]
387
+ })
388
+ } else {
389
+ formats = null
390
+ }
391
+ if (typeof i.insert === 'string') {
392
+ sharedContent.insert(offset, i.insert, formats)
393
+ } else {
394
+ const sharedComponent = this.createSharedComponentByComponent(i.insert)
395
+ sharedContent.insertEmbed(offset, sharedComponent, formats)
396
+ }
397
+ offset += i.insert.length
398
+ })
399
+ this.syncContent(sharedContent, slot)
400
+ this.syncSlot(sharedSlot, slot)
401
+ return sharedSlot
402
+ }
403
+
404
+ private createComponentBySharedComponent(yMap: YMap<any>): ComponentInstance {
405
+ const sharedSlots = yMap.get('slots') as YArray<YMap<any>>
406
+ const slots: Slot[] = []
407
+ sharedSlots.forEach(sharedSlot => {
408
+ const slot = this.createSlotBySharedSlot(sharedSlot)
409
+ slots.push(slot)
410
+ })
411
+ const name = yMap.get('name')
412
+ const instance = this.translator.createComponentByData(name, {
413
+ state: yMap.get('state'),
414
+ slots
415
+ })
416
+ if (instance) {
417
+ instance.slots.toArray().forEach((slot, index) => {
418
+ const sharedSlot = sharedSlots.get(index)
419
+ this.syncSlot(sharedSlot, slot)
420
+ this.syncContent(sharedSlot.get('content'), slot)
421
+ })
422
+ return instance
423
+ }
424
+ throw collaborateErrorFn(`cannot find component factory \`${name}\`.`)
425
+ }
426
+
427
+ private createSlotBySharedSlot(sharedSlot: YMap<any>): Slot {
428
+ const content = sharedSlot.get('content') as YText
429
+ const delta = content.toDelta()
430
+
431
+ const slot = this.translator.createSlot({
432
+ schema: sharedSlot.get('schema'),
433
+ state: sharedSlot.get('state'),
434
+ formats: {},
435
+ content: []
436
+ })
437
+
438
+ for (const action of delta) {
439
+ if (action.insert) {
440
+ if (typeof action.insert === 'string') {
441
+ slot.insert(action.insert, makeFormats(this.registry, action.attributes))
442
+ } else {
443
+ const sharedComponent = action.insert as YMap<any>
444
+ const component = this.createComponentBySharedComponent(sharedComponent)
445
+ slot.insert(component)
446
+ this.syncSlots(sharedComponent.get('slots'), component)
447
+ this.syncComponent(sharedComponent, component)
448
+ }
449
+ } else {
450
+ throw collaborateErrorFn('unexpected delta action.')
451
+ }
452
+ }
453
+ return slot
454
+ }
455
+ }
456
+
457
+ function makeFormats(registry: Registry, attrs?: any) {
458
+ const formats: Formats = []
459
+ if (attrs) {
460
+ Object.keys(attrs).map(key => {
461
+ const formatter = registry.getFormatter(key)
462
+ if (formatter) {
463
+ formats.push([formatter, attrs[key]])
464
+ }
465
+ })
466
+ }
467
+ return formats
133
468
  }
@@ -1,11 +0,0 @@
1
- import { Operation } from '@textbus/core';
2
- import { Text as YText } from 'yjs';
3
- export declare class LocalToRemote {
4
- transform(operation: Operation, root: YText): void;
5
- private applyComponentOperationToSharedComponent;
6
- private applySlotOperationToSharedSlot;
7
- private mergeActionsToSharedSlot;
8
- private makeSharedSlotBySlotLiteral;
9
- private makeSharedComponentByComponentLiteral;
10
- private getSharedComponentByIndex;
11
- }
@@ -1,158 +0,0 @@
1
- import { makeError } from '@textbus/core';
2
- import { Array as YArray, Map as YMap, Text as YText } from 'yjs';
3
- const collaborateErrorFn = makeError('Collaborate');
4
- export class LocalToRemote {
5
- transform(operation, root) {
6
- const path = [...operation.path];
7
- path.shift();
8
- if (path.length) {
9
- const componentIndex = path.shift();
10
- const sharedComponent = this.getSharedComponentByIndex(root, componentIndex);
11
- if (sharedComponent) {
12
- this.applyComponentOperationToSharedComponent(path, operation.apply, sharedComponent);
13
- }
14
- return;
15
- }
16
- this.mergeActionsToSharedSlot(root, operation.apply);
17
- }
18
- applyComponentOperationToSharedComponent(path, actions, componentYMap) {
19
- const sharedSlots = componentYMap.get('slots');
20
- if (path.length) {
21
- const slotIndex = path.shift();
22
- const sharedSlot = sharedSlots.get(slotIndex);
23
- this.applySlotOperationToSharedSlot(path, actions, sharedSlot);
24
- return;
25
- }
26
- let index;
27
- actions.forEach(action => {
28
- switch (action.type) {
29
- case 'retain':
30
- index = action.offset;
31
- break;
32
- case 'insertSlot':
33
- sharedSlots.insert(index, [this.makeSharedSlotBySlotLiteral(action.slot)]);
34
- index++;
35
- break;
36
- case 'apply':
37
- componentYMap.set('state', action.value);
38
- break;
39
- case 'delete':
40
- sharedSlots.delete(index, action.count);
41
- break;
42
- }
43
- });
44
- }
45
- applySlotOperationToSharedSlot(path, actions, slotYMap) {
46
- if (path.length) {
47
- const componentIndex = path.shift();
48
- const sharedContent = slotYMap.get('content');
49
- const sharedComponent = this.getSharedComponentByIndex(sharedContent, componentIndex);
50
- this.applyComponentOperationToSharedComponent(path, actions, sharedComponent);
51
- return;
52
- }
53
- const content = slotYMap.get('content');
54
- this.mergeActionsToSharedSlot(content, actions, slotYMap);
55
- }
56
- mergeActionsToSharedSlot(content, actions, slotYMap) {
57
- let index;
58
- let length;
59
- actions.forEach(action => {
60
- var _a;
61
- if (action.type === 'retain') {
62
- if (action.formats) {
63
- content.format(index, action.offset, action.formats);
64
- }
65
- else {
66
- index = action.offset;
67
- }
68
- }
69
- else if (action.type === 'insert') {
70
- const delta = content.toDelta();
71
- const isEmpty = delta.length === 1 && delta[0].insert === '\n';
72
- if (typeof action.content === 'string') {
73
- length = action.content.length;
74
- content.insert(index, action.content);
75
- }
76
- else {
77
- length = 1;
78
- content.insertEmbed(index, this.makeSharedComponentByComponentLiteral(action.content));
79
- }
80
- if (action.formats) {
81
- content.format(index, length, action.formats);
82
- }
83
- if (isEmpty && index === 0) {
84
- content.delete(content.length - 1, 1);
85
- }
86
- index += length;
87
- }
88
- else if (action.type === 'delete') {
89
- const delta = content.toDelta();
90
- content.delete(index, action.count);
91
- if (content.length === 0) {
92
- content.insert(0, '\n', (_a = delta[0]) === null || _a === void 0 ? void 0 : _a.attributes);
93
- }
94
- }
95
- else if (action.type === 'apply') {
96
- slotYMap === null || slotYMap === void 0 ? void 0 : slotYMap.set('state', action.value);
97
- }
98
- });
99
- }
100
- makeSharedSlotBySlotLiteral(slotLiteral) {
101
- const content = new YText();
102
- let index = 0;
103
- slotLiteral.content.forEach(i => {
104
- let size;
105
- if (typeof i === 'string') {
106
- size = i.length;
107
- content.insert(index, i);
108
- }
109
- else {
110
- size = 1;
111
- content.insertEmbed(index, this.makeSharedComponentByComponentLiteral(i));
112
- }
113
- index += size;
114
- });
115
- const formats = slotLiteral.formats;
116
- Object.keys(formats).forEach(key => {
117
- const formatRanges = formats[key];
118
- formatRanges.forEach(formatRange => {
119
- content.format(formatRange.startIndex, formatRange.endIndex - formatRange.startIndex, {
120
- [key]: formatRange.value
121
- });
122
- });
123
- });
124
- const sharedSlot = new YMap();
125
- sharedSlot.set('content', content);
126
- sharedSlot.set('schema', slotLiteral.schema);
127
- sharedSlot.set('state', slotLiteral.state);
128
- return sharedSlot;
129
- }
130
- makeSharedComponentByComponentLiteral(componentLiteral) {
131
- const slots = new YArray();
132
- componentLiteral.slots.forEach(item => {
133
- slots.push([this.makeSharedSlotBySlotLiteral(item)]);
134
- });
135
- const sharedComponent = new YMap();
136
- sharedComponent.set('name', componentLiteral.name);
137
- sharedComponent.set('slots', slots);
138
- sharedComponent.set('state', componentLiteral.state);
139
- return sharedComponent;
140
- }
141
- getSharedComponentByIndex(host, index) {
142
- const delta = host.toDelta();
143
- let i = 0;
144
- for (const action of delta) {
145
- if (action.insert) {
146
- if (i === index) {
147
- return action.insert instanceof YMap ? action.insert : null;
148
- }
149
- i += action.insert instanceof YMap ? 1 : action.insert.length;
150
- }
151
- else {
152
- throw collaborateErrorFn('Unexpected delta action.');
153
- }
154
- }
155
- return null;
156
- }
157
- }
158
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9jYWwtdG8tcmVtb3RlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NvbGxhYi9sb2NhbC10by1yZW1vdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxFQUFvRCxTQUFTLEVBQUUsTUFBTSxlQUFlLENBQUE7QUFDM0YsT0FBTyxFQUFFLEtBQUssSUFBSSxNQUFNLEVBQUUsR0FBRyxJQUFJLElBQUksRUFBRSxJQUFJLElBQUksS0FBSyxFQUFFLE1BQU0sS0FBSyxDQUFBO0FBRWpFLE1BQU0sa0JBQWtCLEdBQUcsU0FBUyxDQUFDLGFBQWEsQ0FBQyxDQUFBO0FBRW5ELE1BQU0sT0FBTyxhQUFhO0lBQ3hCLFNBQVMsQ0FBQyxTQUFvQixFQUFFLElBQVc7UUFDekMsTUFBTSxJQUFJLEdBQUcsQ0FBQyxHQUFHLFNBQVMsQ0FBQyxJQUFJLENBQUMsQ0FBQTtRQUNoQyxJQUFJLENBQUMsS0FBSyxFQUFFLENBQUE7UUFDWixJQUFJLElBQUksQ0FBQyxNQUFNLEVBQUU7WUFDZixNQUFNLGNBQWMsR0FBRyxJQUFJLENBQUMsS0FBSyxFQUFHLENBQUE7WUFDcEMsTUFBTSxlQUFlLEdBQUcsSUFBSSxDQUFDLHlCQUF5QixDQUFDLElBQUksRUFBRSxjQUFjLENBQUMsQ0FBQTtZQUM1RSxJQUFJLGVBQWUsRUFBRTtnQ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N0aW9uLmluc2VydC5sZW5ndGhcbiAgICAgIH0gZWxzZSB7XG4gICAgICAgIHRocm93IGNvbGxhYm9yYXRlRXJyb3JGbignVW5leHBlY3RlZCBkZWx0YSBhY3Rpb24uJylcbiAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIG51bGxcbiAgfVxufVxuIl19
@@ -1,14 +0,0 @@
1
- import { Doc as YDoc, YEvent } from 'yjs';
2
- import { ComponentInstance, Registry, Selection, Translator } from '@textbus/core';
3
- export declare class RemoteToLocal {
4
- private yDoc;
5
- private translator;
6
- private selection;
7
- private registry;
8
- constructor(yDoc: YDoc, translator: Translator, selection: Selection, registry: Registry);
9
- transform(events: YEvent[], rootComponent: ComponentInstance): void;
10
- private applySharedComponentToComponent;
11
- private applySharedSlotToSlot;
12
- private createComponentBySharedComponent;
13
- private createSlotBySharedSlot;
14
- }