@textbus/collaborate 5.2.7 → 5.3.1

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.
package/dist/index.js CHANGED
@@ -9,22 +9,22 @@ const yjs = require('yjs');
9
9
  const provider = require('@hocuspocus/provider');
10
10
  const yWebsocket = require('y-websocket');
11
11
 
12
- function _assert_this_initialized$2(self) {
12
+ function _assert_this_initialized$3(self) {
13
13
  if (self === void 0) {
14
14
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
15
15
  }
16
16
  return self;
17
17
  }
18
- function _call_super$2(_this, derived, args) {
19
- derived = _get_prototype_of$2(derived);
20
- return _possible_constructor_return$2(_this, _is_native_reflect_construct$2() ? Reflect.construct(derived, args || [], _get_prototype_of$2(_this).constructor) : derived.apply(_this, args));
18
+ function _call_super$3(_this, derived, args) {
19
+ derived = _get_prototype_of$3(derived);
20
+ return _possible_constructor_return$3(_this, _is_native_reflect_construct$3() ? Reflect.construct(derived, args || [], _get_prototype_of$3(_this).constructor) : derived.apply(_this, args));
21
21
  }
22
- function _class_call_check$9(instance, Constructor) {
22
+ function _class_call_check$a(instance, Constructor) {
23
23
  if (!(instance instanceof Constructor)) {
24
24
  throw new TypeError("Cannot call a class as a function");
25
25
  }
26
26
  }
27
- function _defineProperties$8(target, props) {
27
+ function _defineProperties$9(target, props) {
28
28
  for(var i = 0; i < props.length; i++){
29
29
  var descriptor = props[i];
30
30
  descriptor.enumerable = descriptor.enumerable || false;
@@ -33,17 +33,17 @@ function _defineProperties$8(target, props) {
33
33
  Object.defineProperty(target, descriptor.key, descriptor);
34
34
  }
35
35
  }
36
- function _create_class$8(Constructor, protoProps, staticProps) {
37
- if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
36
+ function _create_class$9(Constructor, protoProps, staticProps) {
37
+ if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);
38
38
  return Constructor;
39
39
  }
40
- function _get_prototype_of$2(o) {
41
- _get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
40
+ function _get_prototype_of$3(o) {
41
+ _get_prototype_of$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
42
42
  return o.__proto__ || Object.getPrototypeOf(o);
43
43
  };
44
- return _get_prototype_of$2(o);
44
+ return _get_prototype_of$3(o);
45
45
  }
46
- function _inherits$2(subClass, superClass) {
46
+ function _inherits$3(subClass, superClass) {
47
47
  if (typeof superClass !== "function" && superClass !== null) {
48
48
  throw new TypeError("Super expression must either be null or a function");
49
49
  }
@@ -54,30 +54,30 @@ function _inherits$2(subClass, superClass) {
54
54
  configurable: true
55
55
  }
56
56
  });
57
- if (superClass) _set_prototype_of$2(subClass, superClass);
57
+ if (superClass) _set_prototype_of$3(subClass, superClass);
58
58
  }
59
- function _possible_constructor_return$2(self, call) {
60
- if (call && (_type_of$3(call) === "object" || typeof call === "function")) {
59
+ function _possible_constructor_return$3(self, call) {
60
+ if (call && (_type_of$4(call) === "object" || typeof call === "function")) {
61
61
  return call;
62
62
  }
63
- return _assert_this_initialized$2(self);
63
+ return _assert_this_initialized$3(self);
64
64
  }
65
- function _set_prototype_of$2(o, p) {
66
- _set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
65
+ function _set_prototype_of$3(o, p) {
66
+ _set_prototype_of$3 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
67
67
  o.__proto__ = p;
68
68
  return o;
69
69
  };
70
- return _set_prototype_of$2(o, p);
70
+ return _set_prototype_of$3(o, p);
71
71
  }
72
- function _type_of$3(obj) {
72
+ function _type_of$4(obj) {
73
73
  "@swc/helpers - typeof";
74
74
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
75
75
  }
76
- function _is_native_reflect_construct$2() {
76
+ function _is_native_reflect_construct$3() {
77
77
  try {
78
78
  var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
79
79
  } catch (_) {}
80
- return (_is_native_reflect_construct$2 = function() {
80
+ return (_is_native_reflect_construct$3 = function() {
81
81
  return !!result;
82
82
  })();
83
83
  }
@@ -91,15 +91,15 @@ var subModelLoaderErrorFn = core.makeError('subModelLoaderError');
91
91
  /**
92
92
  * 子文档加载器
93
93
  */ var SubModelLoader = function SubModelLoader() {
94
- _class_call_check$9(this, SubModelLoader);
94
+ _class_call_check$a(this, SubModelLoader);
95
95
  };
96
96
  exports.NonSubModelLoader = /*#__PURE__*/ function(SubModelLoader) {
97
- _inherits$2(NonSubModelLoader, SubModelLoader);
97
+ _inherits$3(NonSubModelLoader, SubModelLoader);
98
98
  function NonSubModelLoader() {
99
- _class_call_check$9(this, NonSubModelLoader);
100
- return _call_super$2(this, NonSubModelLoader, arguments);
99
+ _class_call_check$a(this, NonSubModelLoader);
100
+ return _call_super$3(this, NonSubModelLoader, arguments);
101
101
  }
102
- _create_class$8(NonSubModelLoader, [
102
+ _create_class$9(NonSubModelLoader, [
103
103
  {
104
104
  key: "createSubModelBySlot",
105
105
  value: function createSubModelBySlot() {
@@ -154,12 +154,12 @@ function _array_with_holes(arr) {
154
154
  function _array_without_holes(arr) {
155
155
  if (Array.isArray(arr)) return _array_like_to_array(arr);
156
156
  }
157
- function _class_call_check$8(instance, Constructor) {
157
+ function _class_call_check$9(instance, Constructor) {
158
158
  if (!(instance instanceof Constructor)) {
159
159
  throw new TypeError("Cannot call a class as a function");
160
160
  }
161
161
  }
162
- function _defineProperties$7(target, props) {
162
+ function _defineProperties$8(target, props) {
163
163
  for(var i = 0; i < props.length; i++){
164
164
  var descriptor = props[i];
165
165
  descriptor.enumerable = descriptor.enumerable || false;
@@ -168,11 +168,11 @@ function _defineProperties$7(target, props) {
168
168
  Object.defineProperty(target, descriptor.key, descriptor);
169
169
  }
170
170
  }
171
- function _create_class$7(Constructor, protoProps, staticProps) {
172
- if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
171
+ function _create_class$8(Constructor, protoProps, staticProps) {
172
+ if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
173
173
  return Constructor;
174
174
  }
175
- function _define_property$8(obj, key, value) {
175
+ function _define_property$9(obj, key, value) {
176
176
  if (key in obj) {
177
177
  Object.defineProperty(obj, key, {
178
178
  value: value,
@@ -232,7 +232,7 @@ function _sliced_to_array(arr, i) {
232
232
  function _to_consumable_array(arr) {
233
233
  return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
234
234
  }
235
- function _type_of$2(obj) {
235
+ function _type_of$3(obj) {
236
236
  "@swc/helpers - typeof";
237
237
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
238
238
  }
@@ -253,14 +253,15 @@ function _ts_decorate$2(decorators, target, key, desc) {
253
253
  function _ts_metadata$2(k, v) {
254
254
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
255
255
  }
256
+ /** 与本地稀疏数组「空洞」对应的 YXmlElement,仅放入 YArray,不作通用 XML 节点使用 */ var ARRAY_HOLE_ELEMENT_NODE = 'tb-array-hole';
256
257
  var collaborateErrorFn = core.makeError('Collaborate');
257
258
  var SlotMap = /*#__PURE__*/ function() {
258
259
  function SlotMap() {
259
- _class_call_check$8(this, SlotMap);
260
- _define_property$8(this, "slotAndYTextMap", new WeakMap());
261
- _define_property$8(this, "yTextAndSlotMap", new WeakMap());
260
+ _class_call_check$9(this, SlotMap);
261
+ _define_property$9(this, "slotAndYTextMap", new WeakMap());
262
+ _define_property$9(this, "yTextAndSlotMap", new WeakMap());
262
263
  }
263
- _create_class$7(SlotMap, [
264
+ _create_class$8(SlotMap, [
264
265
  {
265
266
  key: "set",
266
267
  value: function set(key, value) {
@@ -305,19 +306,19 @@ var SlotMap = /*#__PURE__*/ function() {
305
306
  }();
306
307
  exports.Collaborate = /*#__PURE__*/ function() {
307
308
  function Collaborate(scheduler, registry, selection, subModelLoader) {
308
- _class_call_check$8(this, Collaborate);
309
- _define_property$8(this, "scheduler", void 0);
310
- _define_property$8(this, "registry", void 0);
311
- _define_property$8(this, "selection", void 0);
312
- _define_property$8(this, "subModelLoader", void 0);
313
- _define_property$8(this, "yDoc", void 0);
314
- _define_property$8(this, "slotMap", void 0);
315
- _define_property$8(this, "onAddSubModel", void 0);
316
- _define_property$8(this, "subscriptions", void 0);
317
- _define_property$8(this, "updateFromRemote", void 0);
318
- _define_property$8(this, "addSubModelEvent", void 0);
319
- _define_property$8(this, "updateRemoteActions", void 0);
320
- _define_property$8(this, "noRecord", void 0);
309
+ _class_call_check$9(this, Collaborate);
310
+ _define_property$9(this, "scheduler", void 0);
311
+ _define_property$9(this, "registry", void 0);
312
+ _define_property$9(this, "selection", void 0);
313
+ _define_property$9(this, "subModelLoader", void 0);
314
+ _define_property$9(this, "yDoc", void 0);
315
+ _define_property$9(this, "slotMap", void 0);
316
+ _define_property$9(this, "onAddSubModel", void 0);
317
+ _define_property$9(this, "subscriptions", void 0);
318
+ _define_property$9(this, "updateFromRemote", void 0);
319
+ _define_property$9(this, "addSubModelEvent", void 0);
320
+ _define_property$9(this, "updateRemoteActions", void 0);
321
+ _define_property$9(this, "noRecord", void 0);
321
322
  this.scheduler = scheduler;
322
323
  this.registry = registry;
323
324
  this.selection = selection;
@@ -331,7 +332,7 @@ exports.Collaborate = /*#__PURE__*/ function() {
331
332
  this.noRecord = {};
332
333
  this.onAddSubModel = this.addSubModelEvent.asObservable();
333
334
  }
334
- _create_class$7(Collaborate, [
335
+ _create_class$8(Collaborate, [
335
336
  {
336
337
  key: "syncRootComponent",
337
338
  value: function syncRootComponent(yDoc, sharedComponent, localComponent) {
@@ -698,12 +699,15 @@ exports.Collaborate = /*#__PURE__*/ function() {
698
699
  {
699
700
  key: "createLocalArrayBySharedArray",
700
701
  value: function createLocalArrayBySharedArray(sharedArray) {
701
- var _this = this;
702
- var _localArray;
703
- var localArray = core.observe([]);
704
- (_localArray = localArray).push.apply(_localArray, _to_consumable_array(sharedArray.map(function(item) {
705
- return _this.createLocalModelBySharedByModel(item);
706
- })));
702
+ var raw = [];
703
+ for(var i = 0; i < sharedArray.length; i++){
704
+ var item = sharedArray.get(i);
705
+ if (!this.isArrayHoleElement(item)) {
706
+ raw[i] = this.createLocalModelBySharedByModel(item);
707
+ }
708
+ }
709
+ raw.length = sharedArray.length;
710
+ var localArray = core.observe(raw);
707
711
  this.syncArray(sharedArray, localArray);
708
712
  return localArray;
709
713
  }
@@ -730,13 +734,19 @@ exports.Collaborate = /*#__PURE__*/ function() {
730
734
  {
731
735
  key: "createSharedArrayByLocalArray",
732
736
  value: function createSharedArrayByLocalArray(localArray) {
733
- var _this = this;
734
737
  var sharedArray = new yjs.Array();
735
- localArray.forEach(function(value) {
736
- sharedArray.push([
737
- _this.createSharedModelByLocalModel(value)
738
- ]);
739
- });
738
+ var raw = core.toRaw(localArray);
739
+ for(var i = 0; i < raw.length; i++){
740
+ if (i in raw) {
741
+ sharedArray.push([
742
+ this.sharedModelForArraySlot(raw[i])
743
+ ]);
744
+ } else {
745
+ sharedArray.push([
746
+ this.createArrayHoleXmlElement()
747
+ ]);
748
+ }
749
+ }
740
750
  this.syncArray(sharedArray, localArray);
741
751
  return sharedArray;
742
752
  }
@@ -924,7 +934,7 @@ exports.Collaborate = /*#__PURE__*/ function() {
924
934
  if (Array.isArray(localModel)) {
925
935
  return this.createSharedArrayByLocalArray(localModel);
926
936
  }
927
- if ((typeof localModel === "undefined" ? "undefined" : _type_of$2(localModel)) === 'object' && localModel !== null) {
937
+ if ((typeof localModel === "undefined" ? "undefined" : _type_of$3(localModel)) === 'object' && localModel !== null) {
928
938
  return this.createSharedMapByLocalMap(localModel);
929
939
  }
930
940
  return localModel;
@@ -1037,6 +1047,51 @@ exports.Collaborate = /*#__PURE__*/ function() {
1037
1047
  throw collaborateErrorFn("cannot find component factory `".concat(componentName, "`."));
1038
1048
  }
1039
1049
  },
1050
+ {
1051
+ key: "createArrayHoleXmlElement",
1052
+ value: function createArrayHoleXmlElement() {
1053
+ return new yjs.XmlElement(ARRAY_HOLE_ELEMENT_NODE);
1054
+ }
1055
+ },
1056
+ {
1057
+ key: "isArrayHoleElement",
1058
+ value: function isArrayHoleElement(sharedModel) {
1059
+ return _instanceof$1(sharedModel, yjs.XmlElement) && sharedModel.nodeName === ARRAY_HOLE_ELEMENT_NODE;
1060
+ }
1061
+ },
1062
+ {
1063
+ key: "sharedModelForArraySlot",
1064
+ value: /**
1065
+ * 仅用于 YArray ↔ 可观察数组:本地 `undefined` 槽位用 XmlElement 占位同步到 Yjs(不与对象字面量同步混用)。
1066
+ */ function sharedModelForArraySlot(localItem) {
1067
+ if (localItem === undefined) {
1068
+ return this.createArrayHoleXmlElement();
1069
+ }
1070
+ return this.createSharedModelByLocalModel(localItem);
1071
+ }
1072
+ },
1073
+ {
1074
+ key: "insertSparseHole",
1075
+ value: /**
1076
+ * 在可观察数组中插入稀疏空洞(与 YArray 中 XmlElement 占位对齐)。
1077
+ * 仅在远端同步路径调用;直接操作 raw,避免走插入 undefined 的可观察路径。
1078
+ */ function insertSparseHole(localArray, atIndex) {
1079
+ var raw = core.toRaw(localArray);
1080
+ var len = raw.length;
1081
+ if (atIndex >= len) {
1082
+ raw.length = atIndex + 1;
1083
+ return;
1084
+ }
1085
+ for(var i = len; i > atIndex; i--){
1086
+ if (i - 1 in raw) {
1087
+ raw[i] = raw[i - 1];
1088
+ } else {
1089
+ delete raw[i];
1090
+ }
1091
+ }
1092
+ delete raw[atIndex];
1093
+ }
1094
+ },
1040
1095
  {
1041
1096
  key: "syncArray",
1042
1097
  value: /**
@@ -1067,7 +1122,7 @@ exports.Collaborate = /*#__PURE__*/ function() {
1067
1122
  throw collaborateErrorFn('The insertion action must have a reference value.');
1068
1123
  }
1069
1124
  var data = ref.map(function(item) {
1070
- return _this.createSharedModelByLocalModel(item);
1125
+ return _this.sharedModelForArraySlot(item);
1071
1126
  });
1072
1127
  if (index <= sharedArray.length) {
1073
1128
  sharedArray.insert(index, data);
@@ -1091,11 +1146,11 @@ exports.Collaborate = /*#__PURE__*/ function() {
1091
1146
  if (action.index < sharedArray.length) {
1092
1147
  sharedArray.delete(action.index, 1);
1093
1148
  sharedArray.insert(action.index, [
1094
- _this.createSharedModelByLocalModel(action.ref)
1149
+ _this.sharedModelForArraySlot(action.ref)
1095
1150
  ]);
1096
1151
  } else {
1097
1152
  sharedArray.insert(sharedArray.length, [
1098
- _this.createSharedModelByLocalModel(action.ref)
1153
+ _this.sharedModelForArraySlot(action.ref)
1099
1154
  ]);
1100
1155
  logError('setIndex');
1101
1156
  }
@@ -1125,15 +1180,33 @@ exports.Collaborate = /*#__PURE__*/ function() {
1125
1180
  if (Reflect.has(action, 'retain')) {
1126
1181
  index += action.retain;
1127
1182
  } else if (action.insert) {
1128
- var _localArray;
1129
- var data = action.insert.map(function(item) {
1130
- return _this.createLocalModelBySharedByModel(item);
1131
- });
1132
- (_localArray = localArray).splice.apply(_localArray, [
1133
- index,
1134
- 0
1135
- ].concat(_to_consumable_array(data)));
1136
- index += data.length;
1183
+ var at = index;
1184
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1185
+ try {
1186
+ for(var _iterator = action.insert[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1187
+ var item = _step.value;
1188
+ if (_this.isArrayHoleElement(item)) {
1189
+ _this.insertSparseHole(localArray, at);
1190
+ } else {
1191
+ localArray.splice(at, 0, _this.createLocalModelBySharedByModel(item));
1192
+ }
1193
+ at++;
1194
+ }
1195
+ } catch (err) {
1196
+ _didIteratorError = true;
1197
+ _iteratorError = err;
1198
+ } finally{
1199
+ try {
1200
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1201
+ _iterator.return();
1202
+ }
1203
+ } finally{
1204
+ if (_didIteratorError) {
1205
+ throw _iteratorError;
1206
+ }
1207
+ }
1208
+ }
1209
+ index = at;
1137
1210
  } else if (action.delete) {
1138
1211
  localArray.splice(index, action.delete);
1139
1212
  }
@@ -1274,12 +1347,12 @@ function remoteFormatsToLocal(registry, attrs) {
1274
1347
  return formats;
1275
1348
  }
1276
1349
 
1277
- function _class_call_check$7(instance, Constructor) {
1350
+ function _class_call_check$8(instance, Constructor) {
1278
1351
  if (!(instance instanceof Constructor)) {
1279
1352
  throw new TypeError("Cannot call a class as a function");
1280
1353
  }
1281
1354
  }
1282
- function _defineProperties$6(target, props) {
1355
+ function _defineProperties$7(target, props) {
1283
1356
  for(var i = 0; i < props.length; i++){
1284
1357
  var descriptor = props[i];
1285
1358
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1288,11 +1361,11 @@ function _defineProperties$6(target, props) {
1288
1361
  Object.defineProperty(target, descriptor.key, descriptor);
1289
1362
  }
1290
1363
  }
1291
- function _create_class$6(Constructor, protoProps, staticProps) {
1292
- if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
1364
+ function _create_class$7(Constructor, protoProps, staticProps) {
1365
+ if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
1293
1366
  return Constructor;
1294
1367
  }
1295
- function _define_property$7(obj, key, value) {
1368
+ function _define_property$8(obj, key, value) {
1296
1369
  if (key in obj) {
1297
1370
  Object.defineProperty(obj, key, {
1298
1371
  value: value,
@@ -1320,29 +1393,29 @@ function _ts_param$1(paramIndex, decorator) {
1320
1393
  };
1321
1394
  }
1322
1395
  var CustomUndoManagerConfig = function CustomUndoManagerConfig() {
1323
- _class_call_check$7(this, CustomUndoManagerConfig);
1396
+ _class_call_check$8(this, CustomUndoManagerConfig);
1324
1397
  };
1325
1398
  var collabHistoryErrorFn = core.makeError('CollabHistory');
1326
1399
  exports.CollabHistory = /*#__PURE__*/ function() {
1327
1400
  function CollabHistory(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
1328
- _class_call_check$7(this, CollabHistory);
1329
- _define_property$7(this, "rootComponentRef", void 0);
1330
- _define_property$7(this, "collaborate", void 0);
1331
- _define_property$7(this, "scheduler", void 0);
1332
- _define_property$7(this, "stackSize", void 0);
1333
- _define_property$7(this, "undoManagerConfig", void 0);
1334
- _define_property$7(this, "onBack", void 0);
1335
- _define_property$7(this, "onForward", void 0);
1336
- _define_property$7(this, "onChange", void 0);
1337
- _define_property$7(this, "onPush", void 0);
1338
- _define_property$7(this, "manager", void 0);
1339
- _define_property$7(this, "historyItems", void 0);
1340
- _define_property$7(this, "index", void 0);
1341
- _define_property$7(this, "subscriptions", void 0);
1342
- _define_property$7(this, "backEvent", void 0);
1343
- _define_property$7(this, "forwardEvent", void 0);
1344
- _define_property$7(this, "changeEvent", void 0);
1345
- _define_property$7(this, "pushEvent", void 0);
1401
+ _class_call_check$8(this, CollabHistory);
1402
+ _define_property$8(this, "rootComponentRef", void 0);
1403
+ _define_property$8(this, "collaborate", void 0);
1404
+ _define_property$8(this, "scheduler", void 0);
1405
+ _define_property$8(this, "stackSize", void 0);
1406
+ _define_property$8(this, "undoManagerConfig", void 0);
1407
+ _define_property$8(this, "onBack", void 0);
1408
+ _define_property$8(this, "onForward", void 0);
1409
+ _define_property$8(this, "onChange", void 0);
1410
+ _define_property$8(this, "onPush", void 0);
1411
+ _define_property$8(this, "manager", void 0);
1412
+ _define_property$8(this, "historyItems", void 0);
1413
+ _define_property$8(this, "index", void 0);
1414
+ _define_property$8(this, "subscriptions", void 0);
1415
+ _define_property$8(this, "backEvent", void 0);
1416
+ _define_property$8(this, "forwardEvent", void 0);
1417
+ _define_property$8(this, "changeEvent", void 0);
1418
+ _define_property$8(this, "pushEvent", void 0);
1346
1419
  this.rootComponentRef = rootComponentRef;
1347
1420
  this.collaborate = collaborate;
1348
1421
  this.scheduler = scheduler;
@@ -1361,7 +1434,7 @@ exports.CollabHistory = /*#__PURE__*/ function() {
1361
1434
  this.onChange = this.changeEvent.asObservable();
1362
1435
  this.onPush = this.pushEvent.asObservable();
1363
1436
  }
1364
- _create_class$6(CollabHistory, [
1437
+ _create_class$7(CollabHistory, [
1365
1438
  {
1366
1439
  key: "canBack",
1367
1440
  get: function get() {
@@ -1385,6 +1458,7 @@ exports.CollabHistory = /*#__PURE__*/ function() {
1385
1458
  this.collaborate.syncRootComponent(this.collaborate.yDoc, root, rootComponent);
1386
1459
  var undoManagerConfig = this.undoManagerConfig || {};
1387
1460
  var manager = new yjs.UndoManager(root, {
1461
+ captureTimeout: typeof undoManagerConfig.captureTimeout === 'number' ? undoManagerConfig.captureTimeout : 500,
1388
1462
  trackedOrigins: new Set([
1389
1463
  this.collaborate.yDoc
1390
1464
  ]),
@@ -1513,12 +1587,12 @@ exports.CollabHistory = _ts_decorate$1([
1513
1587
  ])
1514
1588
  ], exports.CollabHistory);
1515
1589
 
1516
- function _class_call_check$6(instance, Constructor) {
1590
+ function _class_call_check$7(instance, Constructor) {
1517
1591
  if (!(instance instanceof Constructor)) {
1518
1592
  throw new TypeError("Cannot call a class as a function");
1519
1593
  }
1520
1594
  }
1521
- function _defineProperties$5(target, props) {
1595
+ function _defineProperties$6(target, props) {
1522
1596
  for(var i = 0; i < props.length; i++){
1523
1597
  var descriptor = props[i];
1524
1598
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1527,11 +1601,11 @@ function _defineProperties$5(target, props) {
1527
1601
  Object.defineProperty(target, descriptor.key, descriptor);
1528
1602
  }
1529
1603
  }
1530
- function _create_class$5(Constructor, protoProps, staticProps) {
1531
- if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
1604
+ function _create_class$6(Constructor, protoProps, staticProps) {
1605
+ if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
1532
1606
  return Constructor;
1533
1607
  }
1534
- function _define_property$6(obj, key, value) {
1608
+ function _define_property$7(obj, key, value) {
1535
1609
  if (key in obj) {
1536
1610
  Object.defineProperty(obj, key, {
1537
1611
  value: value,
@@ -1548,12 +1622,12 @@ function _define_property$6(obj, key, value) {
1548
1622
  * 协作消息总线,用于同步各终端消息
1549
1623
  */ var MessageBus = /*#__PURE__*/ function() {
1550
1624
  function MessageBus() {
1551
- _class_call_check$6(this, MessageBus);
1552
- _define_property$6(this, "onSync", void 0);
1553
- _define_property$6(this, "syncEvent", new stream.Subject());
1625
+ _class_call_check$7(this, MessageBus);
1626
+ _define_property$7(this, "onSync", void 0);
1627
+ _define_property$7(this, "syncEvent", new stream.Subject());
1554
1628
  this.onSync = this.syncEvent.asObservable();
1555
1629
  }
1556
- _create_class$5(MessageBus, [
1630
+ _create_class$6(MessageBus, [
1557
1631
  {
1558
1632
  /**
1559
1633
  * 立即同步消息
@@ -1566,12 +1640,12 @@ function _define_property$6(obj, key, value) {
1566
1640
  return MessageBus;
1567
1641
  }();
1568
1642
 
1569
- function _class_call_check$5(instance, Constructor) {
1643
+ function _class_call_check$6(instance, Constructor) {
1570
1644
  if (!(instance instanceof Constructor)) {
1571
1645
  throw new TypeError("Cannot call a class as a function");
1572
1646
  }
1573
1647
  }
1574
- function _defineProperties$4(target, props) {
1648
+ function _defineProperties$5(target, props) {
1575
1649
  for(var i = 0; i < props.length; i++){
1576
1650
  var descriptor = props[i];
1577
1651
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1580,11 +1654,11 @@ function _defineProperties$4(target, props) {
1580
1654
  Object.defineProperty(target, descriptor.key, descriptor);
1581
1655
  }
1582
1656
  }
1583
- function _create_class$4(Constructor, protoProps, staticProps) {
1584
- if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
1657
+ function _create_class$5(Constructor, protoProps, staticProps) {
1658
+ if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
1585
1659
  return Constructor;
1586
1660
  }
1587
- function _define_property$5(obj, key, value) {
1661
+ function _define_property$6(obj, key, value) {
1588
1662
  if (key in obj) {
1589
1663
  Object.defineProperty(obj, key, {
1590
1664
  value: value,
@@ -1621,29 +1695,29 @@ function _ts_param(paramIndex, decorator) {
1621
1695
  }
1622
1696
  exports.MultipleDocCollabHistory = /*#__PURE__*/ function() {
1623
1697
  function MultipleDocCollabHistory(collaborate, scheduler, rootComponentRef, stackSize, undoManagerConfig) {
1624
- _class_call_check$5(this, MultipleDocCollabHistory);
1625
- _define_property$5(this, "collaborate", void 0);
1626
- _define_property$5(this, "scheduler", void 0);
1627
- _define_property$5(this, "rootComponentRef", void 0);
1628
- _define_property$5(this, "stackSize", void 0);
1629
- _define_property$5(this, "undoManagerConfig", void 0);
1630
- _define_property$5(this, "onChange", void 0);
1631
- _define_property$5(this, "onBack", void 0);
1632
- _define_property$5(this, "onForward", void 0);
1633
- _define_property$5(this, "onPush", void 0);
1634
- _define_property$5(this, "isListen", void 0);
1635
- _define_property$5(this, "changeEvent", void 0);
1636
- _define_property$5(this, "backEvent", void 0);
1637
- _define_property$5(this, "forwardEvent", void 0);
1638
- _define_property$5(this, "pushEvent", void 0);
1639
- _define_property$5(this, "actionStack", void 0);
1640
- _define_property$5(this, "index", void 0);
1641
- _define_property$5(this, "stackItem", void 0);
1642
- _define_property$5(this, "timer", void 0);
1643
- _define_property$5(this, "beforePosition", void 0);
1644
- _define_property$5(this, "subscription", void 0);
1645
- _define_property$5(this, "subDocs", void 0);
1646
- _define_property$5(this, "listenerCaches", void 0);
1698
+ _class_call_check$6(this, MultipleDocCollabHistory);
1699
+ _define_property$6(this, "collaborate", void 0);
1700
+ _define_property$6(this, "scheduler", void 0);
1701
+ _define_property$6(this, "rootComponentRef", void 0);
1702
+ _define_property$6(this, "stackSize", void 0);
1703
+ _define_property$6(this, "undoManagerConfig", void 0);
1704
+ _define_property$6(this, "onChange", void 0);
1705
+ _define_property$6(this, "onBack", void 0);
1706
+ _define_property$6(this, "onForward", void 0);
1707
+ _define_property$6(this, "onPush", void 0);
1708
+ _define_property$6(this, "isListen", void 0);
1709
+ _define_property$6(this, "changeEvent", void 0);
1710
+ _define_property$6(this, "backEvent", void 0);
1711
+ _define_property$6(this, "forwardEvent", void 0);
1712
+ _define_property$6(this, "pushEvent", void 0);
1713
+ _define_property$6(this, "actionStack", void 0);
1714
+ _define_property$6(this, "index", void 0);
1715
+ _define_property$6(this, "stackItem", void 0);
1716
+ _define_property$6(this, "timer", void 0);
1717
+ _define_property$6(this, "beforePosition", void 0);
1718
+ _define_property$6(this, "subscription", void 0);
1719
+ _define_property$6(this, "subDocs", void 0);
1720
+ _define_property$6(this, "listenerCaches", void 0);
1647
1721
  this.collaborate = collaborate;
1648
1722
  this.scheduler = scheduler;
1649
1723
  this.rootComponentRef = rootComponentRef;
@@ -1667,7 +1741,7 @@ exports.MultipleDocCollabHistory = /*#__PURE__*/ function() {
1667
1741
  this.onForward = this.forwardEvent.asObservable();
1668
1742
  this.onPush = this.pushEvent.asObservable();
1669
1743
  }
1670
- _create_class$4(MultipleDocCollabHistory, [
1744
+ _create_class$5(MultipleDocCollabHistory, [
1671
1745
  {
1672
1746
  key: "canBack",
1673
1747
  get: function get() {
@@ -1847,7 +1921,7 @@ exports.MultipleDocCollabHistory = /*#__PURE__*/ function() {
1847
1921
  _this.stackItem = null;
1848
1922
  _this.pushEvent.next();
1849
1923
  _this.changeEvent.next();
1850
- }, 500);
1924
+ }, typeof undoManagerConfig.captureTimeout === 'number' ? undoManagerConfig.captureTimeout : 500);
1851
1925
  }
1852
1926
  _this.stackItem.undoManagers.push(undoManager);
1853
1927
  }
@@ -1872,12 +1946,12 @@ exports.MultipleDocCollabHistory = _ts_decorate([
1872
1946
  ])
1873
1947
  ], exports.MultipleDocCollabHistory);
1874
1948
 
1875
- function _class_call_check$4(instance, Constructor) {
1949
+ function _class_call_check$5(instance, Constructor) {
1876
1950
  if (!(instance instanceof Constructor)) {
1877
1951
  throw new TypeError("Cannot call a class as a function");
1878
1952
  }
1879
1953
  }
1880
- function _define_property$4(obj, key, value) {
1954
+ function _define_property$5(obj, key, value) {
1881
1955
  if (key in obj) {
1882
1956
  Object.defineProperty(obj, key, {
1883
1957
  value: value,
@@ -1893,35 +1967,35 @@ function _define_property$4(obj, key, value) {
1893
1967
  /**
1894
1968
  * 协作通信通用接口
1895
1969
  */ var SyncConnector = function SyncConnector() {
1896
- _class_call_check$4(this, SyncConnector);
1970
+ _class_call_check$5(this, SyncConnector);
1897
1971
  /**
1898
1972
  * 当文档加载完成时触发的观察者
1899
- */ _define_property$4(this, "onLoad", void 0);
1973
+ */ _define_property$5(this, "onLoad", void 0);
1900
1974
  /**
1901
1975
  * 当文档 awareness 状态变更时触发的观察者
1902
- */ _define_property$4(this, "onStateChange", void 0);
1903
- _define_property$4(this, "loadEvent", new stream.Subject());
1904
- _define_property$4(this, "stateChangeEvent", new stream.Subject());
1976
+ */ _define_property$5(this, "onStateChange", void 0);
1977
+ _define_property$5(this, "loadEvent", new stream.Subject());
1978
+ _define_property$5(this, "stateChangeEvent", new stream.Subject());
1905
1979
  this.onLoad = this.loadEvent.asObservable();
1906
1980
  this.onStateChange = this.stateChangeEvent.asObservable();
1907
1981
  };
1908
1982
 
1909
- function _assert_this_initialized$1(self) {
1983
+ function _assert_this_initialized$2(self) {
1910
1984
  if (self === void 0) {
1911
1985
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
1912
1986
  }
1913
1987
  return self;
1914
1988
  }
1915
- function _call_super$1(_this, derived, args) {
1916
- derived = _get_prototype_of$1(derived);
1917
- return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
1989
+ function _call_super$2(_this, derived, args) {
1990
+ derived = _get_prototype_of$2(derived);
1991
+ return _possible_constructor_return$2(_this, _is_native_reflect_construct$2() ? Reflect.construct(derived, [], _get_prototype_of$2(_this).constructor) : derived.apply(_this, args));
1918
1992
  }
1919
- function _class_call_check$3(instance, Constructor) {
1993
+ function _class_call_check$4(instance, Constructor) {
1920
1994
  if (!(instance instanceof Constructor)) {
1921
1995
  throw new TypeError("Cannot call a class as a function");
1922
1996
  }
1923
1997
  }
1924
- function _defineProperties$3(target, props) {
1998
+ function _defineProperties$4(target, props) {
1925
1999
  for(var i = 0; i < props.length; i++){
1926
2000
  var descriptor = props[i];
1927
2001
  descriptor.enumerable = descriptor.enumerable || false;
@@ -1930,11 +2004,11 @@ function _defineProperties$3(target, props) {
1930
2004
  Object.defineProperty(target, descriptor.key, descriptor);
1931
2005
  }
1932
2006
  }
1933
- function _create_class$3(Constructor, protoProps, staticProps) {
1934
- if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
2007
+ function _create_class$4(Constructor, protoProps, staticProps) {
2008
+ if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
1935
2009
  return Constructor;
1936
2010
  }
1937
- function _define_property$3(obj, key, value) {
2011
+ function _define_property$4(obj, key, value) {
1938
2012
  if (key in obj) {
1939
2013
  Object.defineProperty(obj, key, {
1940
2014
  value: value,
@@ -1947,13 +2021,13 @@ function _define_property$3(obj, key, value) {
1947
2021
  }
1948
2022
  return obj;
1949
2023
  }
1950
- function _get_prototype_of$1(o) {
1951
- _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
2024
+ function _get_prototype_of$2(o) {
2025
+ _get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
1952
2026
  return o.__proto__ || Object.getPrototypeOf(o);
1953
2027
  };
1954
- return _get_prototype_of$1(o);
2028
+ return _get_prototype_of$2(o);
1955
2029
  }
1956
- function _inherits$1(subClass, superClass) {
2030
+ function _inherits$2(subClass, superClass) {
1957
2031
  if (typeof superClass !== "function" && superClass !== null) {
1958
2032
  throw new TypeError("Super expression must either be null or a function");
1959
2033
  }
@@ -1964,9 +2038,9 @@ function _inherits$1(subClass, superClass) {
1964
2038
  configurable: true
1965
2039
  }
1966
2040
  });
1967
- if (superClass) _set_prototype_of$1(subClass, superClass);
2041
+ if (superClass) _set_prototype_of$2(subClass, superClass);
1968
2042
  }
1969
- function _object_spread(target) {
2043
+ function _object_spread$1(target) {
1970
2044
  for(var i = 1; i < arguments.length; i++){
1971
2045
  var source = arguments[i] != null ? arguments[i] : {};
1972
2046
  var ownKeys = Object.keys(source);
@@ -1976,7 +2050,7 @@ function _object_spread(target) {
1976
2050
  }));
1977
2051
  }
1978
2052
  ownKeys.forEach(function(key) {
1979
- _define_property$3(target, key, source[key]);
2053
+ _define_property$4(target, key, source[key]);
1980
2054
  });
1981
2055
  }
1982
2056
  return target;
@@ -2000,38 +2074,38 @@ function _object_spread_props(target, source) {
2000
2074
  }
2001
2075
  return target;
2002
2076
  }
2003
- function _possible_constructor_return$1(self, call) {
2004
- if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
2077
+ function _possible_constructor_return$2(self, call) {
2078
+ if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
2005
2079
  return call;
2006
2080
  }
2007
- return _assert_this_initialized$1(self);
2081
+ return _assert_this_initialized$2(self);
2008
2082
  }
2009
- function _set_prototype_of$1(o, p) {
2010
- _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
2083
+ function _set_prototype_of$2(o, p) {
2084
+ _set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
2011
2085
  o.__proto__ = p;
2012
2086
  return o;
2013
2087
  };
2014
- return _set_prototype_of$1(o, p);
2088
+ return _set_prototype_of$2(o, p);
2015
2089
  }
2016
- function _type_of$1(obj) {
2090
+ function _type_of$2(obj) {
2017
2091
  "@swc/helpers - typeof";
2018
2092
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2019
2093
  }
2020
- function _is_native_reflect_construct$1() {
2094
+ function _is_native_reflect_construct$2() {
2021
2095
  try {
2022
2096
  var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
2023
2097
  } catch (_) {}
2024
- return (_is_native_reflect_construct$1 = function() {
2098
+ return (_is_native_reflect_construct$2 = function() {
2025
2099
  return !!result;
2026
2100
  })();
2027
2101
  }
2028
2102
  var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
2029
- _inherits$1(HocuspocusConnector, SyncConnector);
2103
+ _inherits$2(HocuspocusConnector, SyncConnector);
2030
2104
  function HocuspocusConnector(config) {
2031
- _class_call_check$3(this, HocuspocusConnector);
2105
+ _class_call_check$4(this, HocuspocusConnector);
2032
2106
  var _this;
2033
- _this = _call_super$1(this, HocuspocusConnector), _define_property$3(_this, "provide", void 0);
2034
- _this.provide = new provider.HocuspocusProvider(_object_spread_props(_object_spread({}, config), {
2107
+ _this = _call_super$2(this, HocuspocusConnector), _define_property$4(_this, "provide", void 0);
2108
+ _this.provide = new provider.HocuspocusProvider(_object_spread_props(_object_spread$1({}, config), {
2035
2109
  onSynced: function onSynced(data) {
2036
2110
  var _config_onSynced;
2037
2111
  (_config_onSynced = config.onSynced) === null || _config_onSynced === void 0 ? void 0 : _config_onSynced.call(config, data);
@@ -2051,7 +2125,7 @@ var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
2051
2125
  }));
2052
2126
  return _this;
2053
2127
  }
2054
- _create_class$3(HocuspocusConnector, [
2128
+ _create_class$4(HocuspocusConnector, [
2055
2129
  {
2056
2130
  key: "setLocalStateField",
2057
2131
  value: function setLocalStateField(key, data) {
@@ -2069,6 +2143,170 @@ var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
2069
2143
  return HocuspocusConnector;
2070
2144
  }(SyncConnector);
2071
2145
 
2146
+ function _assert_this_initialized$1(self) {
2147
+ if (self === void 0) {
2148
+ throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
2149
+ }
2150
+ return self;
2151
+ }
2152
+ function _call_super$1(_this, derived, args) {
2153
+ derived = _get_prototype_of$1(derived);
2154
+ return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
2155
+ }
2156
+ function _class_call_check$3(instance, Constructor) {
2157
+ if (!(instance instanceof Constructor)) {
2158
+ throw new TypeError("Cannot call a class as a function");
2159
+ }
2160
+ }
2161
+ function _defineProperties$3(target, props) {
2162
+ for(var i = 0; i < props.length; i++){
2163
+ var descriptor = props[i];
2164
+ descriptor.enumerable = descriptor.enumerable || false;
2165
+ descriptor.configurable = true;
2166
+ if ("value" in descriptor) descriptor.writable = true;
2167
+ Object.defineProperty(target, descriptor.key, descriptor);
2168
+ }
2169
+ }
2170
+ function _create_class$3(Constructor, protoProps, staticProps) {
2171
+ if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
2172
+ return Constructor;
2173
+ }
2174
+ function _define_property$3(obj, key, value) {
2175
+ if (key in obj) {
2176
+ Object.defineProperty(obj, key, {
2177
+ value: value,
2178
+ enumerable: true,
2179
+ configurable: true,
2180
+ writable: true
2181
+ });
2182
+ } else {
2183
+ obj[key] = value;
2184
+ }
2185
+ return obj;
2186
+ }
2187
+ function _get_prototype_of$1(o) {
2188
+ _get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
2189
+ return o.__proto__ || Object.getPrototypeOf(o);
2190
+ };
2191
+ return _get_prototype_of$1(o);
2192
+ }
2193
+ function _inherits$1(subClass, superClass) {
2194
+ if (typeof superClass !== "function" && superClass !== null) {
2195
+ throw new TypeError("Super expression must either be null or a function");
2196
+ }
2197
+ subClass.prototype = Object.create(superClass && superClass.prototype, {
2198
+ constructor: {
2199
+ value: subClass,
2200
+ writable: true,
2201
+ configurable: true
2202
+ }
2203
+ });
2204
+ if (superClass) _set_prototype_of$1(subClass, superClass);
2205
+ }
2206
+ function _object_spread(target) {
2207
+ for(var i = 1; i < arguments.length; i++){
2208
+ var source = arguments[i] != null ? arguments[i] : {};
2209
+ var ownKeys = Object.keys(source);
2210
+ if (typeof Object.getOwnPropertySymbols === "function") {
2211
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
2212
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
2213
+ }));
2214
+ }
2215
+ ownKeys.forEach(function(key) {
2216
+ _define_property$3(target, key, source[key]);
2217
+ });
2218
+ }
2219
+ return target;
2220
+ }
2221
+ function _possible_constructor_return$1(self, call) {
2222
+ if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
2223
+ return call;
2224
+ }
2225
+ return _assert_this_initialized$1(self);
2226
+ }
2227
+ function _set_prototype_of$1(o, p) {
2228
+ _set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
2229
+ o.__proto__ = p;
2230
+ return o;
2231
+ };
2232
+ return _set_prototype_of$1(o, p);
2233
+ }
2234
+ function _type_of$1(obj) {
2235
+ "@swc/helpers - typeof";
2236
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
2237
+ }
2238
+ function _is_native_reflect_construct$1() {
2239
+ try {
2240
+ var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
2241
+ } catch (_) {}
2242
+ return (_is_native_reflect_construct$1 = function() {
2243
+ return !!result;
2244
+ })();
2245
+ }
2246
+ /**
2247
+ * 不经网络的协作连接器,实现与 {@link SyncConnector} 相同的对外行为,
2248
+ * 便于在单元测试中配合 {@link CollaborateModule} 使用,无需 WebSocket / Provider。
2249
+ *
2250
+ * - `onLoad`:在微任务中触发一次,对应远端「已同步可编辑」的时机。
2251
+ * - `onStateChange`:在每次 {@link LocalConnector.setLocalStateField} 后发出当前客户端状态,
2252
+ * 载荷形状与 `YWebsocketConnector` 一致(`{ clientId, message }`,其中 `message` 为 awareness 上的 `message` 字段)。
2253
+ *
2254
+ * 第一个参数与 `createConnector(yDoc)` 对齐,便于直接传入 `Collaborate` 的文档;当前实现不读写该 `YDoc`。
2255
+ */ var LocalConnector = /*#__PURE__*/ function(SyncConnector) {
2256
+ _inherits$1(LocalConnector, SyncConnector);
2257
+ function LocalConnector(_yDoc, options) {
2258
+ _class_call_check$3(this, LocalConnector);
2259
+ var _this;
2260
+ var _ref;
2261
+ _this = _call_super$1(this, LocalConnector), _define_property$3(_this, "clientId", void 0), _define_property$3(_this, "destroyed", false), _define_property$3(_this, "fields", {});
2262
+ _this.clientId = (_ref = options === null || options === void 0 ? void 0 : options.clientId) !== null && _ref !== void 0 ? _ref : 0;
2263
+ Promise.resolve().then(function() {
2264
+ if (!_this.destroyed) {
2265
+ _this.loadEvent.next();
2266
+ }
2267
+ });
2268
+ return _this;
2269
+ }
2270
+ _create_class$3(LocalConnector, [
2271
+ {
2272
+ key: "setLocalStateField",
2273
+ value: function setLocalStateField(key, data) {
2274
+ if (this.destroyed) {
2275
+ return;
2276
+ }
2277
+ this.fields[key] = data;
2278
+ this.emitAwarenessStates();
2279
+ }
2280
+ },
2281
+ {
2282
+ key: "onDestroy",
2283
+ value: function onDestroy() {
2284
+ this.destroyed = true;
2285
+ }
2286
+ },
2287
+ {
2288
+ /**
2289
+ * 读取当前本地 awareness 字段快照,仅用于测试断言。
2290
+ */ key: "getLocalAwarenessSnapshot",
2291
+ value: function getLocalAwarenessSnapshot() {
2292
+ return _object_spread({}, this.fields);
2293
+ }
2294
+ },
2295
+ {
2296
+ key: "emitAwarenessStates",
2297
+ value: function emitAwarenessStates() {
2298
+ var states = [];
2299
+ states.push({
2300
+ clientId: this.clientId,
2301
+ message: this.fields.message
2302
+ });
2303
+ this.stateChangeEvent.next(states);
2304
+ }
2305
+ }
2306
+ ]);
2307
+ return LocalConnector;
2308
+ }(SyncConnector);
2309
+
2072
2310
  function _assert_this_initialized(self) {
2073
2311
  if (self === void 0) {
2074
2312
  throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -2440,6 +2678,7 @@ var MultipleDocumentCollaborateModule = /*#__PURE__*/ function() {
2440
2678
  exports.CollaborateModule = CollaborateModule;
2441
2679
  exports.CustomUndoManagerConfig = CustomUndoManagerConfig;
2442
2680
  exports.HocuspocusConnector = HocuspocusConnector;
2681
+ exports.LocalConnector = LocalConnector;
2443
2682
  exports.MessageBus = MessageBus;
2444
2683
  exports.MultipleDocumentCollaborateModule = MultipleDocumentCollaborateModule;
2445
2684
  exports.SubModelLoader = SubModelLoader;