@textbus/collaborate 4.3.11 → 4.3.13

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.
@@ -759,6 +759,9 @@ let Collaborate = class Collaborate {
759
759
  * @private
760
760
  */
761
761
  syncArray(sharedArray, localArray) {
762
+ function logError(type) {
763
+ console.error(collaborateErrorFn(`${type} error, length exceeded, path in ${localArray.__changeMarker__.getPaths().join('/')}`));
764
+ }
762
765
  const sub = localArray.__changeMarker__.onSelfChange.subscribe((actions) => {
763
766
  this.runLocalUpdate(sharedArray.doc, !localArray.__changeMarker__.irrevocableUpdate, () => {
764
767
  let index = 0;
@@ -776,18 +779,35 @@ let Collaborate = class Collaborate {
776
779
  const data = ref.map(item => {
777
780
  return this.createSharedModelByLocalModel(item);
778
781
  });
779
- sharedArray.insert(index, data);
782
+ if (index <= sharedArray.length) {
783
+ sharedArray.insert(index, data);
784
+ }
785
+ else {
786
+ sharedArray.insert(sharedArray.length, data);
787
+ logError('insert');
788
+ }
780
789
  }
781
790
  break;
782
791
  case 'delete':
783
792
  if (action.count <= 0) {
784
793
  break;
785
794
  }
786
- sharedArray.delete(index, action.count);
795
+ if (index < sharedArray.length) {
796
+ sharedArray.delete(index, action.count);
797
+ }
798
+ else {
799
+ logError('delete');
800
+ }
787
801
  break;
788
802
  case 'setIndex':
789
- sharedArray.delete(action.index, 1);
790
- sharedArray.insert(action.index, [this.createSharedModelByLocalModel(action.ref)]);
803
+ if (action.index < sharedArray.length) {
804
+ sharedArray.delete(action.index, 1);
805
+ sharedArray.insert(action.index, [this.createSharedModelByLocalModel(action.ref)]);
806
+ }
807
+ else {
808
+ sharedArray.insert(sharedArray.length, [this.createSharedModelByLocalModel(action.ref)]);
809
+ logError('setIndex');
810
+ }
791
811
  break;
792
812
  }
793
813
  }
package/bundles/index.js CHANGED
@@ -761,6 +761,9 @@ exports.Collaborate = class Collaborate {
761
761
  * @private
762
762
  */
763
763
  syncArray(sharedArray, localArray) {
764
+ function logError(type) {
765
+ console.error(collaborateErrorFn(`${type} error, length exceeded, path in ${localArray.__changeMarker__.getPaths().join('/')}`));
766
+ }
764
767
  const sub = localArray.__changeMarker__.onSelfChange.subscribe((actions) => {
765
768
  this.runLocalUpdate(sharedArray.doc, !localArray.__changeMarker__.irrevocableUpdate, () => {
766
769
  let index = 0;
@@ -778,18 +781,35 @@ exports.Collaborate = class Collaborate {
778
781
  const data = ref.map(item => {
779
782
  return this.createSharedModelByLocalModel(item);
780
783
  });
781
- sharedArray.insert(index, data);
784
+ if (index <= sharedArray.length) {
785
+ sharedArray.insert(index, data);
786
+ }
787
+ else {
788
+ sharedArray.insert(sharedArray.length, data);
789
+ logError('insert');
790
+ }
782
791
  }
783
792
  break;
784
793
  case 'delete':
785
794
  if (action.count <= 0) {
786
795
  break;
787
796
  }
788
- sharedArray.delete(index, action.count);
797
+ if (index < sharedArray.length) {
798
+ sharedArray.delete(index, action.count);
799
+ }
800
+ else {
801
+ logError('delete');
802
+ }
789
803
  break;
790
804
  case 'setIndex':
791
- sharedArray.delete(action.index, 1);
792
- sharedArray.insert(action.index, [this.createSharedModelByLocalModel(action.ref)]);
805
+ if (action.index < sharedArray.length) {
806
+ sharedArray.delete(action.index, 1);
807
+ sharedArray.insert(action.index, [this.createSharedModelByLocalModel(action.ref)]);
808
+ }
809
+ else {
810
+ sharedArray.insert(sharedArray.length, [this.createSharedModelByLocalModel(action.ref)]);
811
+ logError('setIndex');
812
+ }
793
813
  break;
794
814
  }
795
815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@textbus/collaborate",
3
- "version": "4.3.11",
3
+ "version": "4.3.13",
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",
@@ -29,7 +29,7 @@
29
29
  "@tanbo/stream": "^1.2.7",
30
30
  "@textbus/core": "^4.3.4",
31
31
  "@viewfly/core": "^1.1.10",
32
- "y-websocket": "^1.5.4",
32
+ "y-websocket": "^2.1.0",
33
33
  "yjs": "^13.6.23"
34
34
  },
35
35
  "devDependencies": {
@@ -50,5 +50,5 @@
50
50
  "bugs": {
51
51
  "url": "https://github.com/textbus/textbus.git/issues"
52
52
  },
53
- "gitHead": "ae81815d6997cae3c2a8e3a8cc83d539301a3192"
53
+ "gitHead": "cff6a20d9308efb3faba585af4c05846cf4124ab"
54
54
  }