@textbus/collaborate 4.3.9 → 4.3.11

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, Inject, Optional } from '@viewfly/core';
2
- import { makeError, ChangeOrigin, Slot, createObjectProxy, createArrayProxy, AsyncSlot, AsyncComponent, Component, Scheduler, Registry, Selection, HISTORY_STACK_SIZE, RootComponentRef, History } from '@textbus/core';
2
+ import { makeError, ChangeOrigin, Slot, observe, AsyncSlot, AsyncComponent, Component, Scheduler, Registry, Selection, HISTORY_STACK_SIZE, RootComponentRef, History } from '@textbus/core';
3
3
  import { Subject, map, filter, Subscription } from '@tanbo/stream';
4
4
  import { Doc, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Array as Array$1, Text, UndoManager } from 'yjs';
5
5
  import { HocuspocusProvider } from '@hocuspocus/provider';
@@ -461,7 +461,7 @@ let Collaborate = class Collaborate {
461
461
  });
462
462
  });
463
463
  this.slotMap.set(localSlot, sharedSlot);
464
- localSlot.__changeMarker__.destroyCallbacks.push(() => {
464
+ localSlot.__changeMarker__.addDetachCallback(() => {
465
465
  this.slotMap.delete(localSlot);
466
466
  sharedSlot.unobserve(syncRemote);
467
467
  sub.unsubscribe();
@@ -469,6 +469,7 @@ let Collaborate = class Collaborate {
469
469
  }
470
470
  destroy() {
471
471
  this.subscriptions.forEach(i => i.unsubscribe());
472
+ this.subscriptions = [];
472
473
  }
473
474
  syncSharedMapToLocalMap(sharedMap, localMap) {
474
475
  sharedMap.forEach((value, key) => {
@@ -477,12 +478,12 @@ let Collaborate = class Collaborate {
477
478
  this.syncObject(sharedMap, localMap);
478
479
  }
479
480
  createLocalMapBySharedMap(sharedMap) {
480
- const localMap = createObjectProxy({});
481
+ const localMap = observe({});
481
482
  this.syncSharedMapToLocalMap(sharedMap, localMap);
482
483
  return localMap;
483
484
  }
484
485
  createLocalArrayBySharedArray(sharedArray) {
485
- const localArray = createArrayProxy([]);
486
+ const localArray = observe([]);
486
487
  localArray.push(...sharedArray.map(item => this.createLocalModelBySharedByModel(item)));
487
488
  this.syncArray(sharedArray, localArray);
488
489
  return localArray;
@@ -529,7 +530,7 @@ let Collaborate = class Collaborate {
529
530
  this.initSyncEvent(subDocument);
530
531
  localSlot.loader.markAsLoaded();
531
532
  });
532
- localSlot.__changeMarker__.destroyCallbacks.push(() => {
533
+ localSlot.__changeMarker__.addDetachCallback(() => {
533
534
  isDestroyed = true;
534
535
  });
535
536
  return sharedSlot;
@@ -599,7 +600,7 @@ let Collaborate = class Collaborate {
599
600
  yType: subContent
600
601
  });
601
602
  });
602
- slot.__changeMarker__.destroyCallbacks.push(() => {
603
+ slot.__changeMarker__.addDetachCallback(() => {
603
604
  isDestroyed = true;
604
605
  });
605
606
  return slot;
@@ -673,7 +674,7 @@ let Collaborate = class Collaborate {
673
674
  sharedComponent.set('metadata', sharedMetadata);
674
675
  const state = component.state;
675
676
  let isDestroyed = false;
676
- state.__changeMarker__.destroyCallbacks.push(() => {
677
+ state.__changeMarker__.addDetachCallback(() => {
677
678
  isDestroyed = true;
678
679
  });
679
680
  this.subModelLoader.createSubModelByComponent(component).then(subDocument => {
@@ -733,7 +734,7 @@ let Collaborate = class Collaborate {
733
734
  yDoc: subDocument
734
735
  });
735
736
  });
736
- state.__changeMarker__.destroyCallbacks.push(() => {
737
+ state.__changeMarker__.addDetachCallback(() => {
737
738
  isDestroyed = true;
738
739
  });
739
740
  }
@@ -813,7 +814,7 @@ let Collaborate = class Collaborate {
813
814
  });
814
815
  };
815
816
  sharedArray.observe(syncRemote);
816
- localArray.__changeMarker__.destroyCallbacks.push(() => {
817
+ localArray.__changeMarker__.addDetachCallback(() => {
817
818
  sub.unsubscribe();
818
819
  sharedArray.unobserve(syncRemote);
819
820
  });
@@ -853,7 +854,7 @@ let Collaborate = class Collaborate {
853
854
  }
854
855
  });
855
856
  });
856
- localObject.__changeMarker__.destroyCallbacks.push(function () {
857
+ localObject.__changeMarker__.addDetachCallback(function () {
857
858
  sharedObject.unobserve(syncRemote);
858
859
  sub.unsubscribe();
859
860
  });
package/bundles/index.js CHANGED
@@ -463,7 +463,7 @@ exports.Collaborate = class Collaborate {
463
463
  });
464
464
  });
465
465
  this.slotMap.set(localSlot, sharedSlot);
466
- localSlot.__changeMarker__.destroyCallbacks.push(() => {
466
+ localSlot.__changeMarker__.addDetachCallback(() => {
467
467
  this.slotMap.delete(localSlot);
468
468
  sharedSlot.unobserve(syncRemote);
469
469
  sub.unsubscribe();
@@ -471,6 +471,7 @@ exports.Collaborate = class Collaborate {
471
471
  }
472
472
  destroy() {
473
473
  this.subscriptions.forEach(i => i.unsubscribe());
474
+ this.subscriptions = [];
474
475
  }
475
476
  syncSharedMapToLocalMap(sharedMap, localMap) {
476
477
  sharedMap.forEach((value, key) => {
@@ -479,12 +480,12 @@ exports.Collaborate = class Collaborate {
479
480
  this.syncObject(sharedMap, localMap);
480
481
  }
481
482
  createLocalMapBySharedMap(sharedMap) {
482
- const localMap = core.createObjectProxy({});
483
+ const localMap = core.observe({});
483
484
  this.syncSharedMapToLocalMap(sharedMap, localMap);
484
485
  return localMap;
485
486
  }
486
487
  createLocalArrayBySharedArray(sharedArray) {
487
- const localArray = core.createArrayProxy([]);
488
+ const localArray = core.observe([]);
488
489
  localArray.push(...sharedArray.map(item => this.createLocalModelBySharedByModel(item)));
489
490
  this.syncArray(sharedArray, localArray);
490
491
  return localArray;
@@ -531,7 +532,7 @@ exports.Collaborate = class Collaborate {
531
532
  this.initSyncEvent(subDocument);
532
533
  localSlot.loader.markAsLoaded();
533
534
  });
534
- localSlot.__changeMarker__.destroyCallbacks.push(() => {
535
+ localSlot.__changeMarker__.addDetachCallback(() => {
535
536
  isDestroyed = true;
536
537
  });
537
538
  return sharedSlot;
@@ -601,7 +602,7 @@ exports.Collaborate = class Collaborate {
601
602
  yType: subContent
602
603
  });
603
604
  });
604
- slot.__changeMarker__.destroyCallbacks.push(() => {
605
+ slot.__changeMarker__.addDetachCallback(() => {
605
606
  isDestroyed = true;
606
607
  });
607
608
  return slot;
@@ -675,7 +676,7 @@ exports.Collaborate = class Collaborate {
675
676
  sharedComponent.set('metadata', sharedMetadata);
676
677
  const state = component.state;
677
678
  let isDestroyed = false;
678
- state.__changeMarker__.destroyCallbacks.push(() => {
679
+ state.__changeMarker__.addDetachCallback(() => {
679
680
  isDestroyed = true;
680
681
  });
681
682
  this.subModelLoader.createSubModelByComponent(component).then(subDocument => {
@@ -735,7 +736,7 @@ exports.Collaborate = class Collaborate {
735
736
  yDoc: subDocument
736
737
  });
737
738
  });
738
- state.__changeMarker__.destroyCallbacks.push(() => {
739
+ state.__changeMarker__.addDetachCallback(() => {
739
740
  isDestroyed = true;
740
741
  });
741
742
  }
@@ -815,7 +816,7 @@ exports.Collaborate = class Collaborate {
815
816
  });
816
817
  };
817
818
  sharedArray.observe(syncRemote);
818
- localArray.__changeMarker__.destroyCallbacks.push(() => {
819
+ localArray.__changeMarker__.addDetachCallback(() => {
819
820
  sub.unsubscribe();
820
821
  sharedArray.unobserve(syncRemote);
821
822
  });
@@ -855,7 +856,7 @@ exports.Collaborate = class Collaborate {
855
856
  }
856
857
  });
857
858
  });
858
- localObject.__changeMarker__.destroyCallbacks.push(function () {
859
+ localObject.__changeMarker__.addDetachCallback(function () {
859
860
  sharedObject.unobserve(syncRemote);
860
861
  sub.unsubscribe();
861
862
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "4.3.9",
3
+ "version": "4.3.11",
4
4
  "description": "Textbus is a rich text editor and framework that is highly customizable and extensible to achieve rich wysiwyg effects.",
5
5
  "main": "./bundles/index.js",
6
6
  "module": "./bundles/index.esm.js",
@@ -25,12 +25,12 @@
25
25
  "typescript editor"
26
26
  ],
27
27
  "dependencies": {
28
- "@hocuspocus/provider": "^2.13.6",
29
- "@tanbo/stream": "^1.2.6",
30
- "@textbus/core": "^4.3.9",
28
+ "@hocuspocus/provider": "^2.15.2",
29
+ "@tanbo/stream": "^1.2.7",
30
+ "@textbus/core": "^4.3.4",
31
31
  "@viewfly/core": "^1.1.10",
32
- "y-websocket": "^1.4.3",
33
- "yjs": "^13.6.14"
32
+ "y-websocket": "^1.5.4",
33
+ "yjs": "^13.6.23"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@rollup/plugin-commonjs": "^23.0.2",
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "731963a2130e44597df1c9179a972d4387a40451"
53
+ "gitHead": "ae81815d6997cae3c2a8e3a8cc83d539301a3192"
54
54
  }