@textbus/collaborate 3.0.0-alpha.8 → 3.0.0-y.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,717 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- var __param = (this && this.__param) || function (paramIndex, decorator) {
11
- return function (target, key) { decorator(target, key, paramIndex); }
12
- };
13
- import { Inject, Injectable } from '@tanbo/di';
14
- import { delay, filter, map, Subject } from '@tanbo/stream';
15
- import { ChangeOrigin, ContentType, Controller, Factory, HISTORY_STACK_SIZE, makeError, RootComponentRef, Scheduler, Selection, Slot, Starter } from '@textbus/core';
16
- import { Array as YArray, Doc as YDoc, Map as YMap, Text as YText, UndoManager, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex } from 'yjs';
17
- import { CollaborateCursor } from './collaborate-cursor';
18
- import { createUnknownComponent } from './unknown.component';
19
- const collaborateErrorFn = makeError('Collaborate');
20
- class ContentMap {
21
- constructor() {
22
- this.slotAndYTextMap = new WeakMap();
23
- this.yTextAndSLotMap = new WeakMap();
24
- }
25
- set(key, value) {
26
- if (key instanceof Slot) {
27
- this.slotAndYTextMap.set(key, value);
28
- this.yTextAndSLotMap.set(value, key);
29
- }
30
- else {
31
- this.slotAndYTextMap.set(value, key);
32
- this.yTextAndSLotMap.set(key, value);
33
- }
34
- }
35
- get(key) {
36
- if (key instanceof Slot) {
37
- return this.slotAndYTextMap.get(key) || null;
38
- }
39
- return this.yTextAndSLotMap.get(key) || null;
40
- }
41
- delete(key) {
42
- if (key instanceof Slot) {
43
- const v = this.slotAndYTextMap.get(key);
44
- this.slotAndYTextMap.delete(key);
45
- if (v) {
46
- this.yTextAndSLotMap.delete(v);
47
- }
48
- }
49
- else {
50
- const v = this.yTextAndSLotMap.get(key);
51
- this.yTextAndSLotMap.delete(key);
52
- if (v) {
53
- this.slotAndYTextMap.delete(v);
54
- }
55
- }
56
- }
57
- }
58
- let Collaborate = class Collaborate {
59
- constructor(stackSize, rootComponentRef, collaborateCursor, controller, scheduler, factory, selection, starter) {
60
- this.stackSize = stackSize;
61
- this.rootComponentRef = rootComponentRef;
62
- this.collaborateCursor = collaborateCursor;
63
- this.controller = controller;
64
- this.scheduler = scheduler;
65
- this.factory = factory;
66
- this.selection = selection;
67
- this.starter = starter;
68
- this.yDoc = new YDoc();
69
- this.backEvent = new Subject();
70
- this.forwardEvent = new Subject();
71
- this.changeEvent = new Subject();
72
- this.pushEvent = new Subject();
73
- this.manager = null;
74
- this.subscriptions = [];
75
- this.updateFromRemote = false;
76
- this.contentSyncCaches = new WeakMap();
77
- this.slotStateSyncCaches = new WeakMap();
78
- this.slotsSyncCaches = new WeakMap();
79
- this.componentStateSyncCaches = new WeakMap();
80
- this.selectionChangeEvent = new Subject();
81
- this.contentMap = new ContentMap();
82
- this.updateRemoteActions = [];
83
- this.noRecord = {};
84
- this.onSelectionChange = this.selectionChangeEvent.asObservable().pipe(delay());
85
- this.onBack = this.backEvent.asObservable();
86
- this.onForward = this.forwardEvent.asObservable();
87
- this.onChange = this.changeEvent.asObservable();
88
- this.onPush = this.pushEvent.asObservable();
89
- }
90
- get canBack() {
91
- var _a;
92
- return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canUndo()) || false;
93
- }
94
- get canForward() {
95
- var _a;
96
- return ((_a = this.manager) === null || _a === void 0 ? void 0 : _a.canRedo()) || false;
97
- }
98
- listen() {
99
- const root = this.yDoc.getMap('RootComponent');
100
- const rootComponent = this.rootComponentRef.component;
101
- this.manager = new UndoManager(root, {
102
- trackedOrigins: new Set([this.yDoc])
103
- });
104
- const cursorKey = 'cursor-position';
105
- this.manager.on('stack-item-added', event => {
106
- event.stackItem.meta.set(cursorKey, this.getRelativeCursorLocation());
107
- if (this.manager.undoStack.length > this.stackSize) {
108
- this.manager.undoStack.shift();
109
- }
110
- if (event.origin === this.yDoc) {
111
- this.pushEvent.next();
112
- }
113
- this.changeEvent.next();
114
- });
115
- this.manager.on('stack-item-popped', event => {
116
- const position = event.stackItem.meta.get(cursorKey);
117
- if (position) {
118
- this.restoreCursorLocation(position);
119
- }
120
- });
121
- this.subscriptions.push(this.selection.onChange.subscribe(() => {
122
- const paths = this.selection.getPaths();
123
- this.selectionChangeEvent.next(paths);
124
- }), this.scheduler.onDocChanged.pipe(map(item => {
125
- return item.filter(i => {
126
- return i.from !== ChangeOrigin.Remote;
127
- });
128
- }), filter(item => {
129
- return item.length;
130
- })).subscribe(() => {
131
- const updates = [];
132
- let update = null;
133
- for (const item of this.updateRemoteActions) {
134
- if (!update) {
135
- update = {
136
- record: item.record,
137
- actions: []
138
- };
139
- updates.push(update);
140
- }
141
- if (update.record === item.record) {
142
- update.actions.push(item.action);
143
- }
144
- else {
145
- update = {
146
- record: item.record,
147
- actions: [item.action]
148
- };
149
- updates.push(update);
150
- }
151
- }
152
- this.updateRemoteActions = [];
153
- for (const item of updates) {
154
- this.yDoc.transact(() => {
155
- item.actions.forEach(fn => {
156
- fn();
157
- });
158
- }, item.record ? this.yDoc : this.noRecord);
159
- }
160
- }));
161
- this.syncRootComponent(root, rootComponent);
162
- }
163
- updateRemoteSelection(paths) {
164
- this.collaborateCursor.draw(paths);
165
- }
166
- back() {
167
- var _a;
168
- if (this.canBack) {
169
- (_a = this.manager) === null || _a === void 0 ? void 0 : _a.undo();
170
- this.backEvent.next();
171
- }
172
- }
173
- forward() {
174
- var _a;
175
- if (this.canForward) {
176
- (_a = this.manager) === null || _a === void 0 ? void 0 : _a.redo();
177
- this.forwardEvent.next();
178
- }
179
- }
180
- clear() {
181
- var _a;
182
- (_a = this.manager) === null || _a === void 0 ? void 0 : _a.clear();
183
- this.changeEvent.next();
184
- }
185
- destroy() {
186
- var _a;
187
- this.subscriptions.forEach(i => i.unsubscribe());
188
- this.collaborateCursor.destroy();
189
- (_a = this.manager) === null || _a === void 0 ? void 0 : _a.destroy();
190
- }
191
- syncRootComponent(root, rootComponent) {
192
- let slots = root.get('slots');
193
- if (!slots) {
194
- slots = new YArray();
195
- rootComponent.slots.toArray().forEach(i => {
196
- const sharedSlot = this.createSharedSlotBySlot(i);
197
- slots.push([sharedSlot]);
198
- });
199
- this.yDoc.transact(() => {
200
- root.set('state', rootComponent.state);
201
- root.set('slots', slots);
202
- });
203
- }
204
- else if (slots.length === 0) {
205
- rootComponent.updateState(() => {
206
- return root.get('state');
207
- });
208
- this.yDoc.transact(() => {
209
- rootComponent.slots.toArray().forEach(i => {
210
- const sharedSlot = this.createSharedSlotBySlot(i);
211
- slots.push([sharedSlot]);
212
- });
213
- });
214
- }
215
- else {
216
- rootComponent.updateState(() => {
217
- return root.get('state');
218
- });
219
- rootComponent.slots.clean();
220
- slots.forEach(sharedSlot => {
221
- const slot = this.createSlotBySharedSlot(sharedSlot);
222
- this.syncSlotContent(sharedSlot.get('content'), slot);
223
- this.syncSlotState(sharedSlot, slot);
224
- rootComponent.slots.insert(slot);
225
- });
226
- }
227
- this.syncComponentState(root, rootComponent);
228
- this.syncComponentSlots(slots, rootComponent);
229
- }
230
- restoreCursorLocation(position) {
231
- const anchorPosition = createAbsolutePositionFromRelativePosition(position.anchor, this.yDoc);
232
- const focusPosition = createAbsolutePositionFromRelativePosition(position.focus, this.yDoc);
233
- if (anchorPosition && focusPosition) {
234
- const focusSlot = this.contentMap.get(focusPosition.type);
235
- const anchorSlot = this.contentMap.get(anchorPosition.type);
236
- if (focusSlot && anchorSlot) {
237
- this.selection.setBaseAndExtent(anchorSlot, anchorPosition.index, focusSlot, focusPosition.index);
238
- return;
239
- }
240
- }
241
- this.selection.unSelect();
242
- }
243
- getRelativeCursorLocation() {
244
- const { anchorSlot, anchorOffset, focusSlot, focusOffset } = this.selection;
245
- if (anchorSlot) {
246
- const anchorYText = this.contentMap.get(anchorSlot);
247
- if (anchorYText) {
248
- const anchorPosition = createRelativePositionFromTypeIndex(anchorYText, anchorOffset);
249
- if (focusSlot) {
250
- const focusYText = this.contentMap.get(focusSlot);
251
- if (focusYText) {
252
- const focusPosition = createRelativePositionFromTypeIndex(focusYText, focusOffset);
253
- return {
254
- focus: focusPosition,
255
- anchor: anchorPosition
256
- };
257
- }
258
- }
259
- }
260
- }
261
- return null;
262
- }
263
- syncSlotContent(content, slot) {
264
- this.contentMap.set(slot, content);
265
- const syncRemote = (ev, tr) => {
266
- this.runRemoteUpdate(tr, () => {
267
- slot.retain(0);
268
- ev.keysChanged.forEach(key => {
269
- const change = ev.keys.get(key);
270
- if (!change) {
271
- return;
272
- }
273
- const updateType = change.action;
274
- if (updateType === 'update' || updateType === 'add') {
275
- const attribute = this.factory.getAttribute(key);
276
- if (attribute) {
277
- slot.setAttribute(attribute, content.getAttribute(key));
278
- }
279
- }
280
- else if (updateType === 'delete') {
281
- const attribute = this.factory.getAttribute(key);
282
- if (attribute) {
283
- slot.removeAttribute(attribute);
284
- }
285
- }
286
- });
287
- ev.delta.forEach(action => {
288
- if (Reflect.has(action, 'retain')) {
289
- if (action.attributes) {
290
- const formats = remoteFormatsToLocal(this.factory, action.attributes);
291
- if (formats.length) {
292
- slot.retain(action.retain, formats);
293
- }
294
- slot.retain(slot.index + action.retain);
295
- }
296
- else {
297
- slot.retain(action.retain);
298
- }
299
- }
300
- else if (action.insert) {
301
- const index = slot.index;
302
- let length = 1;
303
- if (typeof action.insert === 'string') {
304
- length = action.insert.length;
305
- slot.insert(action.insert, remoteFormatsToLocal(this.factory, action.attributes));
306
- }
307
- else {
308
- const sharedComponent = action.insert;
309
- const canInsertInlineComponent = slot.schema.includes(ContentType.InlineComponent);
310
- const component = this.createComponentBySharedComponent(sharedComponent, canInsertInlineComponent);
311
- this.syncComponentSlots(sharedComponent.get('slots'), component);
312
- this.syncComponentState(sharedComponent, component);
313
- slot.insert(component);
314
- }
315
- if (this.selection.isSelected) {
316
- if (slot === this.selection.anchorSlot && this.selection.anchorOffset > index) {
317
- this.selection.setAnchor(slot, this.selection.anchorOffset + length);
318
- }
319
- if (slot === this.selection.focusSlot && this.selection.focusOffset > index) {
320
- this.selection.setFocus(slot, this.selection.focusOffset + length);
321
- }
322
- }
323
- }
324
- else if (action.delete) {
325
- const index = slot.index;
326
- slot.retain(slot.index);
327
- slot.delete(action.delete);
328
- if (this.selection.isSelected) {
329
- if (slot === this.selection.anchorSlot && this.selection.anchorOffset >= index) {
330
- this.selection.setAnchor(slot, this.selection.startOffset - action.delete);
331
- }
332
- if (slot === this.selection.focusSlot && this.selection.focusOffset >= index) {
333
- this.selection.setFocus(slot, this.selection.focusOffset - action.delete);
334
- }
335
- }
336
- }
337
- });
338
- });
339
- };
340
- content.observe(syncRemote);
341
- const sub = slot.onContentChange.pipe(filter(() => {
342
- return !this.scheduler.ignoreChanges;
343
- })).subscribe(actions => {
344
- this.runLocalUpdate(() => {
345
- var _a;
346
- let offset = 0;
347
- let length = 0;
348
- for (const action of actions) {
349
- if (action.type === 'retain') {
350
- const formats = action.formats;
351
- if (formats) {
352
- const keys = Object.keys(formats);
353
- let length = keys.length;
354
- keys.forEach(key => {
355
- const formatter = this.factory.getFormatter(key);
356
- if (!formatter) {
357
- length--;
358
- Reflect.deleteProperty(formats, key);
359
- }
360
- });
361
- if (length) {
362
- content.format(offset, action.offset, formats);
363
- }
364
- }
365
- else {
366
- offset = action.offset;
367
- }
368
- }
369
- else if (action.type === 'insert') {
370
- const delta = content.toDelta();
371
- const isEmpty = delta.length === 1 && delta[0].insert === Slot.emptyPlaceholder;
372
- if (typeof action.content === 'string') {
373
- length = action.content.length;
374
- content.insert(offset, action.content, action.formats || {});
375
- }
376
- else {
377
- length = 1;
378
- const sharedComponent = this.createSharedComponentByComponent(action.ref);
379
- content.insertEmbed(offset, sharedComponent, action.formats || {});
380
- }
381
- if (isEmpty && offset === 0) {
382
- content.delete(content.length - 1, 1);
383
- }
384
- offset += length;
385
- }
386
- else if (action.type === 'delete') {
387
- const delta = content.toDelta();
388
- if (content.length) {
389
- content.delete(offset, action.count);
390
- }
391
- if (content.length === 0) {
392
- content.insert(0, '\n', (_a = delta[0]) === null || _a === void 0 ? void 0 : _a.attributes);
393
- }
394
- }
395
- else if (action.type === 'attrSet') {
396
- content.setAttribute(action.name, action.value);
397
- }
398
- else if (action.type === 'attrRemove') {
399
- content.removeAttribute(action.name);
400
- }
401
- }
402
- });
403
- });
404
- sub.add(slot.onChildComponentRemove.subscribe(components => {
405
- components.forEach(c => {
406
- this.cleanSubscriptionsByComponent(c);
407
- });
408
- }));
409
- this.contentSyncCaches.set(slot, () => {
410
- content.unobserve(syncRemote);
411
- sub.unsubscribe();
412
- });
413
- }
414
- syncSlotState(remoteSlot, slot) {
415
- const syncRemote = (ev, tr) => {
416
- this.runRemoteUpdate(tr, () => {
417
- ev.keysChanged.forEach(key => {
418
- if (key === 'state') {
419
- const state = ev.target.get('state');
420
- slot.updateState(draft => {
421
- if (typeof draft === 'object' && draft !== null) {
422
- Object.assign(draft, state);
423
- }
424
- else {
425
- return state;
426
- }
427
- });
428
- }
429
- });
430
- });
431
- };
432
- remoteSlot.observe(syncRemote);
433
- const sub = slot.onStateChange.pipe(filter(() => {
434
- return !this.scheduler.ignoreChanges;
435
- })).subscribe(change => {
436
- this.runLocalUpdate(() => {
437
- remoteSlot.set('state', change.newState);
438
- }, change.record);
439
- });
440
- this.slotStateSyncCaches.set(slot, () => {
441
- remoteSlot.unobserve(syncRemote);
442
- sub.unsubscribe();
443
- });
444
- }
445
- syncComponentSlots(remoteSlots, component) {
446
- const slots = component.slots;
447
- const syncRemote = (ev, tr) => {
448
- this.runRemoteUpdate(tr, () => {
449
- let index = 0;
450
- slots.retain(index);
451
- ev.delta.forEach(action => {
452
- if (Reflect.has(action, 'retain')) {
453
- index += action.retain;
454
- slots.retain(index);
455
- }
456
- else if (action.insert) {
457
- action.insert.forEach(item => {
458
- const slot = this.createSlotBySharedSlot(item);
459
- slots.insert(slot);
460
- this.syncSlotContent(item.get('content'), slot);
461
- this.syncSlotState(item, slot);
462
- index++;
463
- });
464
- }
465
- else if (action.delete) {
466
- slots.retain(index);
467
- slots.delete(action.delete);
468
- }
469
- });
470
- });
471
- };
472
- remoteSlots.observe(syncRemote);
473
- const sub = slots.onChange.pipe(filter(() => {
474
- return !this.scheduler.ignoreChanges;
475
- })).subscribe(operations => {
476
- this.runLocalUpdate(() => {
477
- const applyActions = operations.apply;
478
- let index;
479
- applyActions.forEach(action => {
480
- if (action.type === 'retain') {
481
- index = action.offset;
482
- }
483
- else if (action.type === 'insertSlot') {
484
- const sharedSlot = this.createSharedSlotBySlot(action.ref);
485
- remoteSlots.insert(index, [sharedSlot]);
486
- index++;
487
- }
488
- else if (action.type === 'delete') {
489
- remoteSlots.delete(index, action.count);
490
- }
491
- });
492
- });
493
- });
494
- sub.add(slots.onChildSlotRemove.subscribe(slots => {
495
- slots.forEach(slot => {
496
- this.cleanSubscriptionsBySlot(slot);
497
- });
498
- }));
499
- this.slotsSyncCaches.set(component, () => {
500
- remoteSlots.unobserve(syncRemote);
501
- sub.unsubscribe();
502
- });
503
- }
504
- syncComponentState(remoteComponent, component) {
505
- const syncRemote = (ev, tr) => {
506
- this.runRemoteUpdate(tr, () => {
507
- ev.keysChanged.forEach(key => {
508
- if (key === 'state') {
509
- const state = ev.target.get('state');
510
- component.updateState(draft => {
511
- if (typeof draft === 'object' && draft !== null) {
512
- Object.assign(draft, state);
513
- }
514
- else {
515
- return state;
516
- }
517
- });
518
- }
519
- });
520
- });
521
- };
522
- remoteComponent.observe(syncRemote);
523
- const sub = component.onStateChange.pipe(filter(() => {
524
- return !this.scheduler.ignoreChanges;
525
- })).subscribe(change => {
526
- this.runLocalUpdate(() => {
527
- remoteComponent.set('state', change.newState);
528
- }, change.record);
529
- });
530
- this.componentStateSyncCaches.set(component, () => {
531
- remoteComponent.unobserve(syncRemote);
532
- sub.unsubscribe();
533
- });
534
- }
535
- runLocalUpdate(fn, record = true) {
536
- if (this.updateFromRemote || this.controller.readonly) {
537
- return;
538
- }
539
- this.updateRemoteActions.push({
540
- record,
541
- action: fn
542
- });
543
- }
544
- runRemoteUpdate(tr, fn) {
545
- if (tr.origin === this.yDoc) {
546
- return;
547
- }
548
- this.updateFromRemote = true;
549
- if (tr.origin === this.manager) {
550
- this.scheduler.historyApplyTransact(fn);
551
- }
552
- else {
553
- this.scheduler.remoteUpdateTransact(fn);
554
- }
555
- this.updateFromRemote = false;
556
- }
557
- createSharedComponentByComponent(component) {
558
- const sharedComponent = new YMap();
559
- sharedComponent.set('state', component.state);
560
- sharedComponent.set('name', component.name);
561
- const sharedSlots = new YArray();
562
- sharedComponent.set('slots', sharedSlots);
563
- component.slots.toArray().forEach(slot => {
564
- const sharedSlot = this.createSharedSlotBySlot(slot);
565
- sharedSlots.push([sharedSlot]);
566
- });
567
- this.syncComponentSlots(sharedSlots, component);
568
- this.syncComponentState(sharedComponent, component);
569
- return sharedComponent;
570
- }
571
- createSharedSlotBySlot(slot) {
572
- const sharedSlot = new YMap();
573
- sharedSlot.set('schema', slot.schema);
574
- sharedSlot.set('state', slot.state);
575
- const sharedContent = new YText();
576
- sharedSlot.set('content', sharedContent);
577
- let offset = 0;
578
- slot.toDelta().forEach(i => {
579
- let formats = {};
580
- if (i.formats) {
581
- i.formats.forEach(item => {
582
- formats[item[0].name] = item[1];
583
- });
584
- }
585
- else {
586
- formats = null;
587
- }
588
- if (typeof i.insert === 'string') {
589
- sharedContent.insert(offset, i.insert, formats);
590
- }
591
- else {
592
- const sharedComponent = this.createSharedComponentByComponent(i.insert);
593
- sharedContent.insertEmbed(offset, sharedComponent, formats);
594
- }
595
- offset += i.insert.length;
596
- });
597
- slot.getAttributes().forEach(item => {
598
- sharedContent.setAttribute(item[0].name, item[1]);
599
- });
600
- this.syncSlotContent(sharedContent, slot);
601
- this.syncSlotState(sharedSlot, slot);
602
- return sharedSlot;
603
- }
604
- createComponentBySharedComponent(yMap, canInsertInlineComponent) {
605
- const sharedSlots = yMap.get('slots');
606
- const slots = [];
607
- sharedSlots.forEach(sharedSlot => {
608
- const slot = this.createSlotBySharedSlot(sharedSlot);
609
- slots.push(slot);
610
- });
611
- const name = yMap.get('name');
612
- const state = yMap.get('state');
613
- const instance = this.factory.createComponentByData(name, {
614
- state,
615
- slots
616
- });
617
- if (instance) {
618
- instance.slots.toArray().forEach((slot, index) => {
619
- let sharedSlot = sharedSlots.get(index);
620
- if (!sharedSlot) {
621
- sharedSlot = this.createSharedSlotBySlot(slot);
622
- sharedSlots.push([sharedSlot]);
623
- }
624
- this.syncSlotState(sharedSlot, slot);
625
- this.syncSlotContent(sharedSlot.get('content'), slot);
626
- });
627
- return instance;
628
- }
629
- return createUnknownComponent(name, canInsertInlineComponent).createInstance(this.starter);
630
- }
631
- createSlotBySharedSlot(sharedSlot) {
632
- const content = sharedSlot.get('content');
633
- const delta = content.toDelta();
634
- const slot = this.factory.createSlot({
635
- schema: sharedSlot.get('schema'),
636
- state: sharedSlot.get('state'),
637
- attributes: {},
638
- formats: {},
639
- content: []
640
- });
641
- const attrs = content.getAttributes();
642
- Object.keys(attrs).forEach(key => {
643
- const attribute = this.factory.getAttribute(key);
644
- if (attribute) {
645
- slot.setAttribute(attribute, attrs[key]);
646
- }
647
- });
648
- for (const action of delta) {
649
- if (action.insert) {
650
- if (typeof action.insert === 'string') {
651
- const formats = remoteFormatsToLocal(this.factory, action.attributes);
652
- slot.insert(action.insert, formats);
653
- }
654
- else {
655
- const sharedComponent = action.insert;
656
- const canInsertInlineComponent = slot.schema.includes(ContentType.InlineComponent);
657
- const component = this.createComponentBySharedComponent(sharedComponent, canInsertInlineComponent);
658
- slot.insert(component, remoteFormatsToLocal(this.factory, action.attributes));
659
- this.syncComponentSlots(sharedComponent.get('slots'), component);
660
- this.syncComponentState(sharedComponent, component);
661
- }
662
- }
663
- else {
664
- throw collaborateErrorFn('unexpected delta action.');
665
- }
666
- }
667
- return slot;
668
- }
669
- cleanSubscriptionsBySlot(slot) {
670
- this.contentMap.delete(slot);
671
- [this.contentSyncCaches.get(slot), this.slotStateSyncCaches.get(slot)].forEach(fn => {
672
- if (fn) {
673
- fn();
674
- }
675
- });
676
- slot.sliceContent().forEach(i => {
677
- if (typeof i !== 'string') {
678
- this.cleanSubscriptionsByComponent(i);
679
- }
680
- });
681
- }
682
- cleanSubscriptionsByComponent(component) {
683
- [this.slotsSyncCaches.get(component), this.componentStateSyncCaches.get(component)].forEach(fn => {
684
- if (fn) {
685
- fn();
686
- }
687
- });
688
- component.slots.toArray().forEach(slot => {
689
- this.cleanSubscriptionsBySlot(slot);
690
- });
691
- }
692
- };
693
- Collaborate = __decorate([
694
- Injectable(),
695
- __param(0, Inject(HISTORY_STACK_SIZE)),
696
- __metadata("design:paramtypes", [Number, RootComponentRef,
697
- CollaborateCursor,
698
- Controller,
699
- Scheduler,
700
- Factory,
701
- Selection,
702
- Starter])
703
- ], Collaborate);
704
- export { Collaborate };
705
- function remoteFormatsToLocal(factory, attrs) {
706
- const formats = [];
707
- if (attrs) {
708
- Object.keys(attrs).forEach(key => {
709
- const formatter = factory.getFormatter(key);
710
- if (formatter) {
711
- formats.push([formatter, attrs[key]]);
712
- }
713
- });
714
- }
715
- return formats;
716
- }
717
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29sbGFib3JhdGUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvY29sbGFib3JhdGUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7O0FBQUEsT0FBTyxFQUFFLE1BQU0sRUFBRSxVQUFVLEVBQUUsTUFBTSxXQU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SksXG4gICAgICAgIGZpbHRlcihpdGVtID0+IHtcbiAgICAgICAgICByZXR1cm4gaXRlbS5sZW5ndGhcbiAgICAgICAgfSlcbiAgICAgICkuc3Vic2NyaWJlKCgpID0+IHtcbiAgICAgICAgY29uc3QgdXBkYXRlczogVXBkYXRlW10gPSBbXVxuXG4gICAgICAgIGxldCB1cGRhdGU6IFVwZGF0ZSB8IG51bGwgPSBudWxsXG5cbiAgICAgICAgZm9yIChjb25zdCBpdGVtIG9mIHRoaXMudXBkYXRlUmVtb3RlQWN0aW9ucykge1xuICAgICAgICAgIGlmICghdXBkYXRlKSB7XG4gICAgICAgICAgICB1cGRhdGUgPSB7XG4gICAgICAgICAgICAgIHJlY29yZDogaXRlbS5yZWNvcmQsXG4gICAgICAgICAgICAgIGFjdGlvbnM6IFtdXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB1cGRhdGVzLnB1c2godXBkYXRlKVxuICAgICAgICAgIH1cbiAgICAgICAgICBpZiAodXBkYXRlLnJlY29yZCA9PT0gaXRlbS5yZWNvcmQpIHtcbiAgICAgICAgICAgIHVwZGF0ZS5hY3Rpb25zLnB1c2goaXRlbS5hY3Rpb24pXG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHVwZGF0ZSA9IHtcbiAgICAgICAgICAgICAgcmVjb3JkOiBpdGVtLnJlY29yZCxcbiAgICAgICAgICAgICAgYWN0aW9uczogW2l0ZW0uYWN0aW9uXVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdXBkYXRlcy5wdXNoKHVwZGF0ZSlcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICB0aGlzLnVwZGF0ZVJlbW90ZUFjdGlvbnMgPSBbXVxuXG4gICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiB1cGRhdGVzKSB7XG4gICAgICAgICAgdGhpcy55RG9jLnRyYW5zYWN0KCgpID0+IHtcbiAgICAgICAgICAgIGl0ZW0uYWN0aW9ucy5mb3JFYWNoK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c2l0aW9uLFxuICAgICAgICAgICAgICBhbmNob3I6IGFuY2hvclBvc2l0aW9uXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuICAgIHJldHVybiBudWxsXG4gIH1cblxuICBwcm90ZWN0ZWQgc3luY1Nsb3RDb250ZW50KGNvbnRlbnQ6IFlUZXh0LCBzbG90OiBTbG90KSB7XG4gICAgdGhpcy5jb250ZW50TWFwLnNldChzbG90LCBjb250ZW50KVxuICAgIGNvbnN0IHN5bmNSZW1vdGUgPSAoZXYsIHRyKSA9PiB7XG4gICAgICB0aGlzLnJ1blJlbW90ZVVwZGF0ZSh0ciwgKCkgPT4ge1xuICAgICAgICBzbG90LnJldGFpbigwKVxuICAgICAgICBldi5rZXlzQ2hhbmdlZC5mb3JFYWNoKGtleSA9PiB7XG4gICAgICAgICAgY29uc3QgY2hhbmdlID0gZXYua2V5cy5nZXQoa2V5KVxuICAgICAgICAgIGlmICghY2hhbmdlKSB7XG4gICAgICAgICAgICByZXR1cm5cbiAgICAgICAgICB9XG4gICAgICAgICAgY29uc3QgdXBkYXRlVHlwZSA9IGNoYW5nZS5hY3Rpb25cbiAgICAgICAgICBpZiAodXBkYXRlVHlwZSA9PT0gJ3VwZGF0ZScgfHwgdXBkYXRlVHlwZSA9PT0gJ2FkZCcpIHtcbiAgICAgICAgICAgIGNvbnN0IGF0dHJpYnV0ZSA9IHRoaXMuZmFjdG9yeS5nZXRBdHRyaWJ1dGUoa2V5KVxuICAgICAgICAgICAgaWYgKGF0dHJpYnV0ZSkge1xuICAgICAgICAgICAgICBzbG90LnNldEF0dHJpYnV0ZShhdHRyaWJ1dGUsIGNvbnRlbnQuZ2V0QXR0cmlidXRlKGtleSkpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmICh1cGRhdGVUeXBlID09PSAnZGVsZXRlJykge1xuICAgICAgICAgICAgY29uc3QgYXR0cmlidXRlID0gdGhpcy5mYWN0b3J5LmdldEF0dHJpYnV0ZShrZXkpXG4gICAgICAgICAgICBpZiAoYXR0cmlidXRlKSB7XG4gICAgICAgICAgICAgIHNsb3QucmVtb3ZlQXR0cmlidXRlKGF0dHJpYnV0ZSlcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0pXG4gICAgICAgIGV2LmRlbHRhLmZvckVhY2goYWN0aW9uID0+IHtcbiAgICAgICAgICBpZiAoUmVmbGVjdC5oYXMoYWN0aW9uLCAncmV0YWluJykpIHtcbiAgICAgICAgICAgIGlmIChhY3Rpb24uYXR0cmlidXRlcykge1xuICAgICAgICAgICAgICBjb25zdCBmb3JtYXRzID0gcmVtb3RlRm9ybWF0c1RvTG9jYWwodGhpcy5mYWN0b3J5LCBhY3Rpb24uYXR0cmlidXRlcylcbiAgICAgICAgICAgICAgaWYgKGZvcm1hdHMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgc2xvdC5yZXRhaW4oYWN0aW9uLnJldGFpbiEsIGZvcm1hdHMpXG4gICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgc2xvdC5yZXRhaW4oc2xvdC5pbmRleCArIGFjdGlvbi5yZXRhaW4pXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBzbG90LnJldGFpbihhY3Rpb24ucmV0YWluKVxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLmluc2VydCkge1xuICAgICAgICAgICAgY29uc3QgaW5kZXggPSBzbG90LmluZGV4XG4gICAgICAgICAgICBsZXQgbGVuZ3RoID0gMVxuICAgICAgICAgICAgaWYgKHR5cGVvZiBhY3Rpb24uaW5zZXJ0ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICBsZW5ndGggPSBhY3Rpb24uaW5zZXJ0Lmxlbmd0aFxuICAgICAgICAgICAgICBzbG90Lmluc2VydChhY3Rpb24uaW5zZXJ0LCByZW1vdGVGb3JtYXRzVG9Mb2NhbC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c3luY1JlbW90ZSlcblxuICAgIGNvbnN0IHN1YiA9IHNsb3Qub25Db250ZW50Q2hhbmdlLnBpcGUoZmlsdGVyKCgpID0+IHtcbiAgICAgIHJldHVybiAhdGhpcy5zY2hlZHVsZXIuaWdub3JlQ2hhbmdlc1xuICAgIH0pKS5zdWJzY3JpYmUoYWN0aW9ucyA9PiB7XG4gICAgICB0aGlzLnJ1bkxvY2FsVXBkYXRlKCgpID0+IHtcbiAgICAgICAgbGV0IG9mZnNldCA9IDBcbiAgICAgICAgbGV0IGxlbmd0aCA9IDBcbiAgICAgICAgZm9yIChjb25zdCBhY3Rpb24gb2YgYWN0aW9ucykge1xuICAgICAgICAgIGlmIChhY3Rpb24udHlwZSA9PT0gJ3JldGFpbicpIHtcbiAgICAgICAgICAgIGNvbnN0IGZvcm1hdHMgPSBhY3Rpb24uZm9ybWF0c1xuICAgICAgICAgICAgaWYgKGZvcm1hdHMpIHtcbiAgICAgICAgICAgICAgY29uc3Qga2V5cyA9IE9iamVjdC5rZXlzKGZvcm1hdHMpXG4gICAgICAgICAgICAgIGxldCBsZW5ndGggPSBrZXlzLmxlbmd0aFxuICAgICAgICAgICAgICBrZXlzLmZvckVhY2goa2V5ID0+IHtcbiAgICAgICAgICAgICAgICBjb25zdCBmb3JtYXR0ZXIgPSB0aGlzLmZhY3RvcnkuZ2V0Rm9ybWF0dGVyKGtleSlcbiAgICAgICAgICAgICAgICBpZiAoIWZvcm1hdHRlcikge1xuICAgICAgICAgICAgICAgICAgbGVuZ3RoLS1cbiAgICAgICAgICAgICAgICAgIFJlZmxlY3QuZGVsZXRlUHJvcGVydHkoZm9ybWF0cywga2V5KVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgfSlcbiAgICAgICAgICAgICAgaWYgKGxlbmd0aCkge1xuICAgICAgICAgICAgICAgIGNvbnRlbnQuZm9ybWF0KG9mZnNldCwgYWN0aW9uLm9mZnNldCwgZm9ybWF0cylcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgb2Zmc2V0ID0gYWN0aW9uLm9mZnNldFxuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLnR5cGUgPT09ICdpbnNlcnQnKSB7XG4gICAgICAgICAgICBjb25zdCBkZWx0YSA9IGNvbnRlbnQudG9EZWx0YSgpXG4gICAgICAgICAgICBjb25zdCBpc0VtcHR5ID0gZGVsdGEubGVuZ3RoID09PSAxICYmIGRlbHRhWzBdLmluc2VydCA9PT0gU2xvdC5lbXB0eVBsYWNlaG9sZGVyXG4gICAgICAgICAgICBpZiAodHlwZW9mIGFjdGlvbi5jb250ZW50ID09PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICBsZW5ndGggPSBhY3Rpb24uY29udGVudC5sZW5ndGhcbiAgICAgICAgICAgICAgY29udGVudC5pbnNlcnQob2Zmc2V0LCBhY3Rpb24uY29udGVudCwgYWN0aW9uLmZvcm1hdHMgfHwge30pXG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBsZW5ndGggPSAxXG4gICAgICAgICAgICAgIGNvbnN0IHNoYXJlZENvbXBvbmVudCA9IHRoaXMuY3JlYXRlU2hhcmVkQ29tcG9uZW50QnlDb21wb25lbnQoYWN0aW9uLnJlZiBhcyBDb21wb25lbnRJbnN0YW5jZSlcbiAgICAgICAgICAgICAgY29udGVudC5pbnNlcnRFbWJlZChvZmZzZXQsIHNoYXJlZENvbXBvbmVudCwgYWN0aW9uLmZvcm1hdHMgfHwge30pXG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIGlmIChpc0VtcHR5ICYmIG9mZnNldCA9PT0gMCkge1xuICAgICAgICAgICAgICBjb250ZW50LmRlbGV0ZShjb250ZW50Lmxlbmd0aCAtIDEsIDEpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBvZmZzZXQgKz0gbGVuZ3RoXG4gICAgICAgICAgfSBlbHNlIGlmIChhY3Rpb24udHlwZSA9PT0gJ2RlbGV0ZScpIHtcbiAgICAgICAgICAgIGNvbnN0IGRlbHRhID0gY29udGVudC50b0RlbHRhKClcbiAgICAgICAgICAgIGlmIChjb250ZW50Lmxlbmd0aCkge1xuICAgICAgICAgICAgICBjb250ZW50LmRlbGV0ZShvZmZzZXQsIGFjdGlvbi5jb3VudClcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChjb250ZW50Lmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgICBjb250ZW50Lmluc2VydCgwLCAnXFxuJywgZGVsdGFbMF0/LmF0dHJpYnV0ZXMpXG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChhY3Rpb24udHlwZSA9PT0gJ2F0dHJTZXQnKSB7XG4gICAgICAgICAgICBjb250ZW50LnNldEF0dHJpYnV0ZShhY3Rpb24ubmFtZSwgYWN0aW9uLnZhbHVlKVxuICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLnR5cGUgPT09ICdhdHRyUmVtb3ZlJykge1xuICAgICAgICAgICAgY29udGVudC5yZW1vdmVBdHRyaWJ1dGUoYWN0aW9uLm5hbWUpXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9KVxuICAgIH0pXG5cbiAgICBzdWIuYWRkKHNsb3Qub25DaGlsZENvbXBvbmVudFJlbW92ZS5zdWJzY3JpYmUoY29tcG9uZW50cyA9PiB7XG4gICAgICBjb21wb25lbnRzLmZvckVhY2goYyA9PiB7XG4gICAgICAgIHRoaXMuY2xlYW5TdWJzY3JpcHRpb25zQnlDb21wb25lbnQoYylcbiAgICAgIH0pXG4gICAgfSkpXG4gICAgdGhpcy5jb250ZW50U3luY0NhY2hlcy5zZXQoc2xvdCwgKCkgPT4ge1xuICAgICAgY29udGVudC51bm9ic2VydmUoc3luY1JlbW90ZSlcbiAgICAgIHN1Yi51bnN1YnNjcmliZSgpXG4gICAgfSlcbiAgfVxuXG4gIHByb3RlY3RlZC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uc3luY1Nsb3RTdGF0ZShpdGVtLCBzbG90KVxuICAgICAgICAgICAgICBpbmRleCsrXG4gICAgICAgICAgICB9KVxuICAgICAgICAgIH0gZWxzZSBpZiAoYWN0aW9uLmRlbGV0ZSkge1xuICAgICAgICAgICAgc2xvdHMucmV0YWluKGluZGV4KVxuICAgICAgICAgICAgc2xvdHMuZGVsZXRlKGFjdGlvbi5kZWxldGUpXG4gICAgICAgICAgfVxuICAgICAgICB9KVxuICAgICAgfSlcbiAgICB9XG4gICAgcmVtb3RlU2xvdHMub2JzZXJ2ZShzeW5jUmVtb3RlKVxuXG4gICAgY29uc3Qgc3ViID0gc2xvdHMub25DaGFuZ2UucGlwZShmaWx0ZXIoKCkgPT4ge1xuICAgICAgcmV0dXJuICF0aGlzLnNjaGVkdWxlci5pZ25vcmVDaGFuZ2VzXG4gICAgfSkpLnN1YnNjcmliZShvcGVyYXRpb25zID0+IHtcbiAgICAgIHRoaXMucnVuTG9jYWxVcGRhdGUoKCkgPT4ge1xuICAgICAgICBjb25zdCBhcHBseUFjdGlvbnMgPSBvcGVyYXRpb25zLmFwcGx5XG4gICAgICAgIGxldCBpbmRleDogbnVtYmVyXG4gICAgICAgIGFwcGx5QWN0aW9ucy5mb3JFYWNoKGFjdGlvbiA9PiB7XG4gICAgICAgICAgaWYgKGFjdGlvbi50eXBlID09PSAncmV0YWluJykge1xuICAgICAgICAgICAgaW5kZXggPSBhY3Rpb24ub2Zmc2V0XG4gICAgICAgICAgfSBlbHNlIGlmIChhY3Rpb24udHlwZSA9PT0gJ2luc2VydFNsb3QnKSB7XG4gICAgICAgICAgICBjb25zdCBzaGFyZWRTbG90ID0gdGhpcy5jcmVhdGVTaGFyZWRTbG90QnlTbG90KGFjdGlvbi5yZWYpXG4gICAgICAgICAgICByZW1vdGVTbG90cy5pbnNlcnQoaW5kZXgsIFtzaGFyZWRTbG90XSlcbiAgICAgICAgICAgIGluZGV4KytcbiAgICAgICAgICB9IGVsc2UgaWYgKGFjdGlvb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