@textbus/collaborate 5.2.6 → 5.3.0
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/README.en.md +12 -0
- package/README.md +3 -1
- package/dist/base/collab-history.d.ts +1 -0
- package/dist/base/collaborate.d.ts +11 -0
- package/dist/connectors/_api.d.ts +1 -0
- package/dist/connectors/local-connector.d.ts +32 -0
- package/dist/index.esm.js +418 -180
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +416 -177
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.esm.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { Injectable, Inject, Optional } from '@viewfly/core';
|
|
2
|
-
import { makeError, Slot, ChangeOrigin, observe, AsyncSlot, AsyncComponent, Component, Scheduler, Registry, Selection, HISTORY_STACK_SIZE, RootComponentRef, History } from '@textbus/core';
|
|
2
|
+
import { makeError, Slot, ChangeOrigin, observe, toRaw, 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
|
-
import { Doc, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Array as Array$1, Text, UndoManager } from 'yjs';
|
|
4
|
+
import { Doc, createAbsolutePositionFromRelativePosition, createRelativePositionFromTypeIndex, Map, Array as Array$1, Text, XmlElement, UndoManager } from 'yjs';
|
|
5
5
|
import { HocuspocusProvider } from '@hocuspocus/provider';
|
|
6
6
|
import { WebsocketProvider } from 'y-websocket';
|
|
7
7
|
|
|
8
|
-
function _assert_this_initialized$
|
|
8
|
+
function _assert_this_initialized$3(self) {
|
|
9
9
|
if (self === void 0) {
|
|
10
10
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
11
11
|
}
|
|
12
12
|
return self;
|
|
13
13
|
}
|
|
14
|
-
function _call_super$
|
|
15
|
-
derived = _get_prototype_of$
|
|
16
|
-
return _possible_constructor_return$
|
|
14
|
+
function _call_super$3(_this, derived, args) {
|
|
15
|
+
derived = _get_prototype_of$3(derived);
|
|
16
|
+
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));
|
|
17
17
|
}
|
|
18
|
-
function _class_call_check$
|
|
18
|
+
function _class_call_check$a(instance, Constructor) {
|
|
19
19
|
if (!(instance instanceof Constructor)) {
|
|
20
20
|
throw new TypeError("Cannot call a class as a function");
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function _defineProperties$
|
|
23
|
+
function _defineProperties$9(target, props) {
|
|
24
24
|
for(var i = 0; i < props.length; i++){
|
|
25
25
|
var descriptor = props[i];
|
|
26
26
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -29,17 +29,17 @@ function _defineProperties$8(target, props) {
|
|
|
29
29
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
function _create_class$
|
|
33
|
-
if (protoProps) _defineProperties$
|
|
32
|
+
function _create_class$9(Constructor, protoProps, staticProps) {
|
|
33
|
+
if (protoProps) _defineProperties$9(Constructor.prototype, protoProps);
|
|
34
34
|
return Constructor;
|
|
35
35
|
}
|
|
36
|
-
function _get_prototype_of$
|
|
37
|
-
_get_prototype_of$
|
|
36
|
+
function _get_prototype_of$3(o) {
|
|
37
|
+
_get_prototype_of$3 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
38
38
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
39
39
|
};
|
|
40
|
-
return _get_prototype_of$
|
|
40
|
+
return _get_prototype_of$3(o);
|
|
41
41
|
}
|
|
42
|
-
function _inherits$
|
|
42
|
+
function _inherits$3(subClass, superClass) {
|
|
43
43
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
44
44
|
throw new TypeError("Super expression must either be null or a function");
|
|
45
45
|
}
|
|
@@ -50,30 +50,30 @@ function _inherits$2(subClass, superClass) {
|
|
|
50
50
|
configurable: true
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
|
-
if (superClass) _set_prototype_of$
|
|
53
|
+
if (superClass) _set_prototype_of$3(subClass, superClass);
|
|
54
54
|
}
|
|
55
|
-
function _possible_constructor_return$
|
|
56
|
-
if (call && (_type_of$
|
|
55
|
+
function _possible_constructor_return$3(self, call) {
|
|
56
|
+
if (call && (_type_of$4(call) === "object" || typeof call === "function")) {
|
|
57
57
|
return call;
|
|
58
58
|
}
|
|
59
|
-
return _assert_this_initialized$
|
|
59
|
+
return _assert_this_initialized$3(self);
|
|
60
60
|
}
|
|
61
|
-
function _set_prototype_of$
|
|
62
|
-
_set_prototype_of$
|
|
61
|
+
function _set_prototype_of$3(o, p) {
|
|
62
|
+
_set_prototype_of$3 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
63
63
|
o.__proto__ = p;
|
|
64
64
|
return o;
|
|
65
65
|
};
|
|
66
|
-
return _set_prototype_of$
|
|
66
|
+
return _set_prototype_of$3(o, p);
|
|
67
67
|
}
|
|
68
|
-
function _type_of$
|
|
68
|
+
function _type_of$4(obj) {
|
|
69
69
|
"@swc/helpers - typeof";
|
|
70
70
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
71
71
|
}
|
|
72
|
-
function _is_native_reflect_construct$
|
|
72
|
+
function _is_native_reflect_construct$3() {
|
|
73
73
|
try {
|
|
74
74
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
75
75
|
} catch (_) {}
|
|
76
|
-
return (_is_native_reflect_construct$
|
|
76
|
+
return (_is_native_reflect_construct$3 = function() {
|
|
77
77
|
return !!result;
|
|
78
78
|
})();
|
|
79
79
|
}
|
|
@@ -87,15 +87,15 @@ var subModelLoaderErrorFn = makeError('subModelLoaderError');
|
|
|
87
87
|
/**
|
|
88
88
|
* 子文档加载器
|
|
89
89
|
*/ var SubModelLoader = function SubModelLoader() {
|
|
90
|
-
_class_call_check$
|
|
90
|
+
_class_call_check$a(this, SubModelLoader);
|
|
91
91
|
};
|
|
92
92
|
var NonSubModelLoader = /*#__PURE__*/ function(SubModelLoader) {
|
|
93
|
-
_inherits$
|
|
93
|
+
_inherits$3(NonSubModelLoader, SubModelLoader);
|
|
94
94
|
function NonSubModelLoader() {
|
|
95
|
-
_class_call_check$
|
|
96
|
-
return _call_super$
|
|
95
|
+
_class_call_check$a(this, NonSubModelLoader);
|
|
96
|
+
return _call_super$3(this, NonSubModelLoader, arguments);
|
|
97
97
|
}
|
|
98
|
-
_create_class$
|
|
98
|
+
_create_class$9(NonSubModelLoader, [
|
|
99
99
|
{
|
|
100
100
|
key: "createSubModelBySlot",
|
|
101
101
|
value: function createSubModelBySlot() {
|
|
@@ -150,12 +150,12 @@ function _array_with_holes(arr) {
|
|
|
150
150
|
function _array_without_holes(arr) {
|
|
151
151
|
if (Array.isArray(arr)) return _array_like_to_array(arr);
|
|
152
152
|
}
|
|
153
|
-
function _class_call_check$
|
|
153
|
+
function _class_call_check$9(instance, Constructor) {
|
|
154
154
|
if (!(instance instanceof Constructor)) {
|
|
155
155
|
throw new TypeError("Cannot call a class as a function");
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
function _defineProperties$
|
|
158
|
+
function _defineProperties$8(target, props) {
|
|
159
159
|
for(var i = 0; i < props.length; i++){
|
|
160
160
|
var descriptor = props[i];
|
|
161
161
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -164,11 +164,11 @@ function _defineProperties$7(target, props) {
|
|
|
164
164
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
function _create_class$
|
|
168
|
-
if (protoProps) _defineProperties$
|
|
167
|
+
function _create_class$8(Constructor, protoProps, staticProps) {
|
|
168
|
+
if (protoProps) _defineProperties$8(Constructor.prototype, protoProps);
|
|
169
169
|
return Constructor;
|
|
170
170
|
}
|
|
171
|
-
function _define_property$
|
|
171
|
+
function _define_property$9(obj, key, value) {
|
|
172
172
|
if (key in obj) {
|
|
173
173
|
Object.defineProperty(obj, key, {
|
|
174
174
|
value: value,
|
|
@@ -228,7 +228,7 @@ function _sliced_to_array(arr, i) {
|
|
|
228
228
|
function _to_consumable_array(arr) {
|
|
229
229
|
return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
|
|
230
230
|
}
|
|
231
|
-
function _type_of$
|
|
231
|
+
function _type_of$3(obj) {
|
|
232
232
|
"@swc/helpers - typeof";
|
|
233
233
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
234
234
|
}
|
|
@@ -249,14 +249,15 @@ function _ts_decorate$2(decorators, target, key, desc) {
|
|
|
249
249
|
function _ts_metadata$2(k, v) {
|
|
250
250
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
251
251
|
}
|
|
252
|
+
/** 与本地稀疏数组「空洞」对应的 YXmlElement,仅放入 YArray,不作通用 XML 节点使用 */ var ARRAY_HOLE_ELEMENT_NODE = 'tb-array-hole';
|
|
252
253
|
var collaborateErrorFn = makeError('Collaborate');
|
|
253
254
|
var SlotMap = /*#__PURE__*/ function() {
|
|
254
255
|
function SlotMap() {
|
|
255
|
-
_class_call_check$
|
|
256
|
-
_define_property$
|
|
257
|
-
_define_property$
|
|
256
|
+
_class_call_check$9(this, SlotMap);
|
|
257
|
+
_define_property$9(this, "slotAndYTextMap", new WeakMap());
|
|
258
|
+
_define_property$9(this, "yTextAndSlotMap", new WeakMap());
|
|
258
259
|
}
|
|
259
|
-
_create_class$
|
|
260
|
+
_create_class$8(SlotMap, [
|
|
260
261
|
{
|
|
261
262
|
key: "set",
|
|
262
263
|
value: function set(key, value) {
|
|
@@ -301,19 +302,19 @@ var SlotMap = /*#__PURE__*/ function() {
|
|
|
301
302
|
}();
|
|
302
303
|
var Collaborate = /*#__PURE__*/ function() {
|
|
303
304
|
function Collaborate(scheduler, registry, selection, subModelLoader) {
|
|
304
|
-
_class_call_check$
|
|
305
|
-
_define_property$
|
|
306
|
-
_define_property$
|
|
307
|
-
_define_property$
|
|
308
|
-
_define_property$
|
|
309
|
-
_define_property$
|
|
310
|
-
_define_property$
|
|
311
|
-
_define_property$
|
|
312
|
-
_define_property$
|
|
313
|
-
_define_property$
|
|
314
|
-
_define_property$
|
|
315
|
-
_define_property$
|
|
316
|
-
_define_property$
|
|
305
|
+
_class_call_check$9(this, Collaborate);
|
|
306
|
+
_define_property$9(this, "scheduler", void 0);
|
|
307
|
+
_define_property$9(this, "registry", void 0);
|
|
308
|
+
_define_property$9(this, "selection", void 0);
|
|
309
|
+
_define_property$9(this, "subModelLoader", void 0);
|
|
310
|
+
_define_property$9(this, "yDoc", void 0);
|
|
311
|
+
_define_property$9(this, "slotMap", void 0);
|
|
312
|
+
_define_property$9(this, "onAddSubModel", void 0);
|
|
313
|
+
_define_property$9(this, "subscriptions", void 0);
|
|
314
|
+
_define_property$9(this, "updateFromRemote", void 0);
|
|
315
|
+
_define_property$9(this, "addSubModelEvent", void 0);
|
|
316
|
+
_define_property$9(this, "updateRemoteActions", void 0);
|
|
317
|
+
_define_property$9(this, "noRecord", void 0);
|
|
317
318
|
this.scheduler = scheduler;
|
|
318
319
|
this.registry = registry;
|
|
319
320
|
this.selection = selection;
|
|
@@ -327,7 +328,7 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
327
328
|
this.noRecord = {};
|
|
328
329
|
this.onAddSubModel = this.addSubModelEvent.asObservable();
|
|
329
330
|
}
|
|
330
|
-
_create_class$
|
|
331
|
+
_create_class$8(Collaborate, [
|
|
331
332
|
{
|
|
332
333
|
key: "syncRootComponent",
|
|
333
334
|
value: function syncRootComponent(yDoc, sharedComponent, localComponent) {
|
|
@@ -694,12 +695,15 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
694
695
|
{
|
|
695
696
|
key: "createLocalArrayBySharedArray",
|
|
696
697
|
value: function createLocalArrayBySharedArray(sharedArray) {
|
|
697
|
-
var
|
|
698
|
-
var
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
698
|
+
var raw = [];
|
|
699
|
+
for(var i = 0; i < sharedArray.length; i++){
|
|
700
|
+
var item = sharedArray.get(i);
|
|
701
|
+
if (!this.isArrayHoleElement(item)) {
|
|
702
|
+
raw[i] = this.createLocalModelBySharedByModel(item);
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
raw.length = sharedArray.length;
|
|
706
|
+
var localArray = observe(raw);
|
|
703
707
|
this.syncArray(sharedArray, localArray);
|
|
704
708
|
return localArray;
|
|
705
709
|
}
|
|
@@ -726,13 +730,19 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
726
730
|
{
|
|
727
731
|
key: "createSharedArrayByLocalArray",
|
|
728
732
|
value: function createSharedArrayByLocalArray(localArray) {
|
|
729
|
-
var _this = this;
|
|
730
733
|
var sharedArray = new Array$1();
|
|
731
|
-
localArray
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
734
|
+
var raw = toRaw(localArray);
|
|
735
|
+
for(var i = 0; i < raw.length; i++){
|
|
736
|
+
if (i in raw) {
|
|
737
|
+
sharedArray.push([
|
|
738
|
+
this.sharedModelForArraySlot(raw[i])
|
|
739
|
+
]);
|
|
740
|
+
} else {
|
|
741
|
+
sharedArray.push([
|
|
742
|
+
this.createArrayHoleXmlElement()
|
|
743
|
+
]);
|
|
744
|
+
}
|
|
745
|
+
}
|
|
736
746
|
this.syncArray(sharedArray, localArray);
|
|
737
747
|
return sharedArray;
|
|
738
748
|
}
|
|
@@ -920,7 +930,7 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
920
930
|
if (Array.isArray(localModel)) {
|
|
921
931
|
return this.createSharedArrayByLocalArray(localModel);
|
|
922
932
|
}
|
|
923
|
-
if ((typeof localModel === "undefined" ? "undefined" : _type_of$
|
|
933
|
+
if ((typeof localModel === "undefined" ? "undefined" : _type_of$3(localModel)) === 'object' && localModel !== null) {
|
|
924
934
|
return this.createSharedMapByLocalMap(localModel);
|
|
925
935
|
}
|
|
926
936
|
return localModel;
|
|
@@ -1033,6 +1043,51 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
1033
1043
|
throw collaborateErrorFn("cannot find component factory `".concat(componentName, "`."));
|
|
1034
1044
|
}
|
|
1035
1045
|
},
|
|
1046
|
+
{
|
|
1047
|
+
key: "createArrayHoleXmlElement",
|
|
1048
|
+
value: function createArrayHoleXmlElement() {
|
|
1049
|
+
return new XmlElement(ARRAY_HOLE_ELEMENT_NODE);
|
|
1050
|
+
}
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
key: "isArrayHoleElement",
|
|
1054
|
+
value: function isArrayHoleElement(sharedModel) {
|
|
1055
|
+
return _instanceof$1(sharedModel, XmlElement) && sharedModel.nodeName === ARRAY_HOLE_ELEMENT_NODE;
|
|
1056
|
+
}
|
|
1057
|
+
},
|
|
1058
|
+
{
|
|
1059
|
+
key: "sharedModelForArraySlot",
|
|
1060
|
+
value: /**
|
|
1061
|
+
* 仅用于 YArray ↔ 可观察数组:本地 `undefined` 槽位用 XmlElement 占位同步到 Yjs(不与对象字面量同步混用)。
|
|
1062
|
+
*/ function sharedModelForArraySlot(localItem) {
|
|
1063
|
+
if (localItem === undefined) {
|
|
1064
|
+
return this.createArrayHoleXmlElement();
|
|
1065
|
+
}
|
|
1066
|
+
return this.createSharedModelByLocalModel(localItem);
|
|
1067
|
+
}
|
|
1068
|
+
},
|
|
1069
|
+
{
|
|
1070
|
+
key: "insertSparseHole",
|
|
1071
|
+
value: /**
|
|
1072
|
+
* 在可观察数组中插入稀疏空洞(与 YArray 中 XmlElement 占位对齐)。
|
|
1073
|
+
* 仅在远端同步路径调用;直接操作 raw,避免走插入 undefined 的可观察路径。
|
|
1074
|
+
*/ function insertSparseHole(localArray, atIndex) {
|
|
1075
|
+
var raw = toRaw(localArray);
|
|
1076
|
+
var len = raw.length;
|
|
1077
|
+
if (atIndex >= len) {
|
|
1078
|
+
raw.length = atIndex + 1;
|
|
1079
|
+
return;
|
|
1080
|
+
}
|
|
1081
|
+
for(var i = len; i > atIndex; i--){
|
|
1082
|
+
if (i - 1 in raw) {
|
|
1083
|
+
raw[i] = raw[i - 1];
|
|
1084
|
+
} else {
|
|
1085
|
+
delete raw[i];
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
delete raw[atIndex];
|
|
1089
|
+
}
|
|
1090
|
+
},
|
|
1036
1091
|
{
|
|
1037
1092
|
key: "syncArray",
|
|
1038
1093
|
value: /**
|
|
@@ -1063,7 +1118,7 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
1063
1118
|
throw collaborateErrorFn('The insertion action must have a reference value.');
|
|
1064
1119
|
}
|
|
1065
1120
|
var data = ref.map(function(item) {
|
|
1066
|
-
return _this.
|
|
1121
|
+
return _this.sharedModelForArraySlot(item);
|
|
1067
1122
|
});
|
|
1068
1123
|
if (index <= sharedArray.length) {
|
|
1069
1124
|
sharedArray.insert(index, data);
|
|
@@ -1087,11 +1142,11 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
1087
1142
|
if (action.index < sharedArray.length) {
|
|
1088
1143
|
sharedArray.delete(action.index, 1);
|
|
1089
1144
|
sharedArray.insert(action.index, [
|
|
1090
|
-
_this.
|
|
1145
|
+
_this.sharedModelForArraySlot(action.ref)
|
|
1091
1146
|
]);
|
|
1092
1147
|
} else {
|
|
1093
1148
|
sharedArray.insert(sharedArray.length, [
|
|
1094
|
-
_this.
|
|
1149
|
+
_this.sharedModelForArraySlot(action.ref)
|
|
1095
1150
|
]);
|
|
1096
1151
|
logError('setIndex');
|
|
1097
1152
|
}
|
|
@@ -1121,15 +1176,33 @@ var Collaborate = /*#__PURE__*/ function() {
|
|
|
1121
1176
|
if (Reflect.has(action, 'retain')) {
|
|
1122
1177
|
index += action.retain;
|
|
1123
1178
|
} else if (action.insert) {
|
|
1124
|
-
var
|
|
1125
|
-
var
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1179
|
+
var at = index;
|
|
1180
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
1181
|
+
try {
|
|
1182
|
+
for(var _iterator = action.insert[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
1183
|
+
var item = _step.value;
|
|
1184
|
+
if (_this.isArrayHoleElement(item)) {
|
|
1185
|
+
_this.insertSparseHole(localArray, at);
|
|
1186
|
+
} else {
|
|
1187
|
+
localArray.splice(at, 0, _this.createLocalModelBySharedByModel(item));
|
|
1188
|
+
}
|
|
1189
|
+
at++;
|
|
1190
|
+
}
|
|
1191
|
+
} catch (err) {
|
|
1192
|
+
_didIteratorError = true;
|
|
1193
|
+
_iteratorError = err;
|
|
1194
|
+
} finally{
|
|
1195
|
+
try {
|
|
1196
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
1197
|
+
_iterator.return();
|
|
1198
|
+
}
|
|
1199
|
+
} finally{
|
|
1200
|
+
if (_didIteratorError) {
|
|
1201
|
+
throw _iteratorError;
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
index = at;
|
|
1133
1206
|
} else if (action.delete) {
|
|
1134
1207
|
localArray.splice(index, action.delete);
|
|
1135
1208
|
}
|
|
@@ -1270,12 +1343,12 @@ function remoteFormatsToLocal(registry, attrs) {
|
|
|
1270
1343
|
return formats;
|
|
1271
1344
|
}
|
|
1272
1345
|
|
|
1273
|
-
function _class_call_check$
|
|
1346
|
+
function _class_call_check$8(instance, Constructor) {
|
|
1274
1347
|
if (!(instance instanceof Constructor)) {
|
|
1275
1348
|
throw new TypeError("Cannot call a class as a function");
|
|
1276
1349
|
}
|
|
1277
1350
|
}
|
|
1278
|
-
function _defineProperties$
|
|
1351
|
+
function _defineProperties$7(target, props) {
|
|
1279
1352
|
for(var i = 0; i < props.length; i++){
|
|
1280
1353
|
var descriptor = props[i];
|
|
1281
1354
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -1284,11 +1357,11 @@ function _defineProperties$6(target, props) {
|
|
|
1284
1357
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1285
1358
|
}
|
|
1286
1359
|
}
|
|
1287
|
-
function _create_class$
|
|
1288
|
-
if (protoProps) _defineProperties$
|
|
1360
|
+
function _create_class$7(Constructor, protoProps, staticProps) {
|
|
1361
|
+
if (protoProps) _defineProperties$7(Constructor.prototype, protoProps);
|
|
1289
1362
|
return Constructor;
|
|
1290
1363
|
}
|
|
1291
|
-
function _define_property$
|
|
1364
|
+
function _define_property$8(obj, key, value) {
|
|
1292
1365
|
if (key in obj) {
|
|
1293
1366
|
Object.defineProperty(obj, key, {
|
|
1294
1367
|
value: value,
|
|
@@ -1316,29 +1389,29 @@ function _ts_param$1(paramIndex, decorator) {
|
|
|
1316
1389
|
};
|
|
1317
1390
|
}
|
|
1318
1391
|
var CustomUndoManagerConfig = function CustomUndoManagerConfig() {
|
|
1319
|
-
_class_call_check$
|
|
1392
|
+
_class_call_check$8(this, CustomUndoManagerConfig);
|
|
1320
1393
|
};
|
|
1321
1394
|
var collabHistoryErrorFn = makeError('CollabHistory');
|
|
1322
1395
|
var CollabHistory = /*#__PURE__*/ function() {
|
|
1323
1396
|
function CollabHistory(rootComponentRef, collaborate, scheduler, stackSize, undoManagerConfig) {
|
|
1324
|
-
_class_call_check$
|
|
1325
|
-
_define_property$
|
|
1326
|
-
_define_property$
|
|
1327
|
-
_define_property$
|
|
1328
|
-
_define_property$
|
|
1329
|
-
_define_property$
|
|
1330
|
-
_define_property$
|
|
1331
|
-
_define_property$
|
|
1332
|
-
_define_property$
|
|
1333
|
-
_define_property$
|
|
1334
|
-
_define_property$
|
|
1335
|
-
_define_property$
|
|
1336
|
-
_define_property$
|
|
1337
|
-
_define_property$
|
|
1338
|
-
_define_property$
|
|
1339
|
-
_define_property$
|
|
1340
|
-
_define_property$
|
|
1341
|
-
_define_property$
|
|
1397
|
+
_class_call_check$8(this, CollabHistory);
|
|
1398
|
+
_define_property$8(this, "rootComponentRef", void 0);
|
|
1399
|
+
_define_property$8(this, "collaborate", void 0);
|
|
1400
|
+
_define_property$8(this, "scheduler", void 0);
|
|
1401
|
+
_define_property$8(this, "stackSize", void 0);
|
|
1402
|
+
_define_property$8(this, "undoManagerConfig", void 0);
|
|
1403
|
+
_define_property$8(this, "onBack", void 0);
|
|
1404
|
+
_define_property$8(this, "onForward", void 0);
|
|
1405
|
+
_define_property$8(this, "onChange", void 0);
|
|
1406
|
+
_define_property$8(this, "onPush", void 0);
|
|
1407
|
+
_define_property$8(this, "manager", void 0);
|
|
1408
|
+
_define_property$8(this, "historyItems", void 0);
|
|
1409
|
+
_define_property$8(this, "index", void 0);
|
|
1410
|
+
_define_property$8(this, "subscriptions", void 0);
|
|
1411
|
+
_define_property$8(this, "backEvent", void 0);
|
|
1412
|
+
_define_property$8(this, "forwardEvent", void 0);
|
|
1413
|
+
_define_property$8(this, "changeEvent", void 0);
|
|
1414
|
+
_define_property$8(this, "pushEvent", void 0);
|
|
1342
1415
|
this.rootComponentRef = rootComponentRef;
|
|
1343
1416
|
this.collaborate = collaborate;
|
|
1344
1417
|
this.scheduler = scheduler;
|
|
@@ -1357,7 +1430,7 @@ var CollabHistory = /*#__PURE__*/ function() {
|
|
|
1357
1430
|
this.onChange = this.changeEvent.asObservable();
|
|
1358
1431
|
this.onPush = this.pushEvent.asObservable();
|
|
1359
1432
|
}
|
|
1360
|
-
_create_class$
|
|
1433
|
+
_create_class$7(CollabHistory, [
|
|
1361
1434
|
{
|
|
1362
1435
|
key: "canBack",
|
|
1363
1436
|
get: function get() {
|
|
@@ -1381,6 +1454,7 @@ var CollabHistory = /*#__PURE__*/ function() {
|
|
|
1381
1454
|
this.collaborate.syncRootComponent(this.collaborate.yDoc, root, rootComponent);
|
|
1382
1455
|
var undoManagerConfig = this.undoManagerConfig || {};
|
|
1383
1456
|
var manager = new UndoManager(root, {
|
|
1457
|
+
captureTimeout: typeof undoManagerConfig.captureTimeout === 'number' ? undoManagerConfig.captureTimeout : 500,
|
|
1384
1458
|
trackedOrigins: new Set([
|
|
1385
1459
|
this.collaborate.yDoc
|
|
1386
1460
|
]),
|
|
@@ -1509,12 +1583,12 @@ CollabHistory = _ts_decorate$1([
|
|
|
1509
1583
|
])
|
|
1510
1584
|
], CollabHistory);
|
|
1511
1585
|
|
|
1512
|
-
function _class_call_check$
|
|
1586
|
+
function _class_call_check$7(instance, Constructor) {
|
|
1513
1587
|
if (!(instance instanceof Constructor)) {
|
|
1514
1588
|
throw new TypeError("Cannot call a class as a function");
|
|
1515
1589
|
}
|
|
1516
1590
|
}
|
|
1517
|
-
function _defineProperties$
|
|
1591
|
+
function _defineProperties$6(target, props) {
|
|
1518
1592
|
for(var i = 0; i < props.length; i++){
|
|
1519
1593
|
var descriptor = props[i];
|
|
1520
1594
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -1523,11 +1597,11 @@ function _defineProperties$5(target, props) {
|
|
|
1523
1597
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1524
1598
|
}
|
|
1525
1599
|
}
|
|
1526
|
-
function _create_class$
|
|
1527
|
-
if (protoProps) _defineProperties$
|
|
1600
|
+
function _create_class$6(Constructor, protoProps, staticProps) {
|
|
1601
|
+
if (protoProps) _defineProperties$6(Constructor.prototype, protoProps);
|
|
1528
1602
|
return Constructor;
|
|
1529
1603
|
}
|
|
1530
|
-
function _define_property$
|
|
1604
|
+
function _define_property$7(obj, key, value) {
|
|
1531
1605
|
if (key in obj) {
|
|
1532
1606
|
Object.defineProperty(obj, key, {
|
|
1533
1607
|
value: value,
|
|
@@ -1544,12 +1618,12 @@ function _define_property$6(obj, key, value) {
|
|
|
1544
1618
|
* 协作消息总线,用于同步各终端消息
|
|
1545
1619
|
*/ var MessageBus = /*#__PURE__*/ function() {
|
|
1546
1620
|
function MessageBus() {
|
|
1547
|
-
_class_call_check$
|
|
1548
|
-
_define_property$
|
|
1549
|
-
_define_property$
|
|
1621
|
+
_class_call_check$7(this, MessageBus);
|
|
1622
|
+
_define_property$7(this, "onSync", void 0);
|
|
1623
|
+
_define_property$7(this, "syncEvent", new Subject());
|
|
1550
1624
|
this.onSync = this.syncEvent.asObservable();
|
|
1551
1625
|
}
|
|
1552
|
-
_create_class$
|
|
1626
|
+
_create_class$6(MessageBus, [
|
|
1553
1627
|
{
|
|
1554
1628
|
/**
|
|
1555
1629
|
* 立即同步消息
|
|
@@ -1562,12 +1636,12 @@ function _define_property$6(obj, key, value) {
|
|
|
1562
1636
|
return MessageBus;
|
|
1563
1637
|
}();
|
|
1564
1638
|
|
|
1565
|
-
function _class_call_check$
|
|
1639
|
+
function _class_call_check$6(instance, Constructor) {
|
|
1566
1640
|
if (!(instance instanceof Constructor)) {
|
|
1567
1641
|
throw new TypeError("Cannot call a class as a function");
|
|
1568
1642
|
}
|
|
1569
1643
|
}
|
|
1570
|
-
function _defineProperties$
|
|
1644
|
+
function _defineProperties$5(target, props) {
|
|
1571
1645
|
for(var i = 0; i < props.length; i++){
|
|
1572
1646
|
var descriptor = props[i];
|
|
1573
1647
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -1576,11 +1650,11 @@ function _defineProperties$4(target, props) {
|
|
|
1576
1650
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1577
1651
|
}
|
|
1578
1652
|
}
|
|
1579
|
-
function _create_class$
|
|
1580
|
-
if (protoProps) _defineProperties$
|
|
1653
|
+
function _create_class$5(Constructor, protoProps, staticProps) {
|
|
1654
|
+
if (protoProps) _defineProperties$5(Constructor.prototype, protoProps);
|
|
1581
1655
|
return Constructor;
|
|
1582
1656
|
}
|
|
1583
|
-
function _define_property$
|
|
1657
|
+
function _define_property$6(obj, key, value) {
|
|
1584
1658
|
if (key in obj) {
|
|
1585
1659
|
Object.defineProperty(obj, key, {
|
|
1586
1660
|
value: value,
|
|
@@ -1617,29 +1691,29 @@ function _ts_param(paramIndex, decorator) {
|
|
|
1617
1691
|
}
|
|
1618
1692
|
var MultipleDocCollabHistory = /*#__PURE__*/ function() {
|
|
1619
1693
|
function MultipleDocCollabHistory(collaborate, scheduler, rootComponentRef, stackSize, undoManagerConfig) {
|
|
1620
|
-
_class_call_check$
|
|
1621
|
-
_define_property$
|
|
1622
|
-
_define_property$
|
|
1623
|
-
_define_property$
|
|
1624
|
-
_define_property$
|
|
1625
|
-
_define_property$
|
|
1626
|
-
_define_property$
|
|
1627
|
-
_define_property$
|
|
1628
|
-
_define_property$
|
|
1629
|
-
_define_property$
|
|
1630
|
-
_define_property$
|
|
1631
|
-
_define_property$
|
|
1632
|
-
_define_property$
|
|
1633
|
-
_define_property$
|
|
1634
|
-
_define_property$
|
|
1635
|
-
_define_property$
|
|
1636
|
-
_define_property$
|
|
1637
|
-
_define_property$
|
|
1638
|
-
_define_property$
|
|
1639
|
-
_define_property$
|
|
1640
|
-
_define_property$
|
|
1641
|
-
_define_property$
|
|
1642
|
-
_define_property$
|
|
1694
|
+
_class_call_check$6(this, MultipleDocCollabHistory);
|
|
1695
|
+
_define_property$6(this, "collaborate", void 0);
|
|
1696
|
+
_define_property$6(this, "scheduler", void 0);
|
|
1697
|
+
_define_property$6(this, "rootComponentRef", void 0);
|
|
1698
|
+
_define_property$6(this, "stackSize", void 0);
|
|
1699
|
+
_define_property$6(this, "undoManagerConfig", void 0);
|
|
1700
|
+
_define_property$6(this, "onChange", void 0);
|
|
1701
|
+
_define_property$6(this, "onBack", void 0);
|
|
1702
|
+
_define_property$6(this, "onForward", void 0);
|
|
1703
|
+
_define_property$6(this, "onPush", void 0);
|
|
1704
|
+
_define_property$6(this, "isListen", void 0);
|
|
1705
|
+
_define_property$6(this, "changeEvent", void 0);
|
|
1706
|
+
_define_property$6(this, "backEvent", void 0);
|
|
1707
|
+
_define_property$6(this, "forwardEvent", void 0);
|
|
1708
|
+
_define_property$6(this, "pushEvent", void 0);
|
|
1709
|
+
_define_property$6(this, "actionStack", void 0);
|
|
1710
|
+
_define_property$6(this, "index", void 0);
|
|
1711
|
+
_define_property$6(this, "stackItem", void 0);
|
|
1712
|
+
_define_property$6(this, "timer", void 0);
|
|
1713
|
+
_define_property$6(this, "beforePosition", void 0);
|
|
1714
|
+
_define_property$6(this, "subscription", void 0);
|
|
1715
|
+
_define_property$6(this, "subDocs", void 0);
|
|
1716
|
+
_define_property$6(this, "listenerCaches", void 0);
|
|
1643
1717
|
this.collaborate = collaborate;
|
|
1644
1718
|
this.scheduler = scheduler;
|
|
1645
1719
|
this.rootComponentRef = rootComponentRef;
|
|
@@ -1663,7 +1737,7 @@ var MultipleDocCollabHistory = /*#__PURE__*/ function() {
|
|
|
1663
1737
|
this.onForward = this.forwardEvent.asObservable();
|
|
1664
1738
|
this.onPush = this.pushEvent.asObservable();
|
|
1665
1739
|
}
|
|
1666
|
-
_create_class$
|
|
1740
|
+
_create_class$5(MultipleDocCollabHistory, [
|
|
1667
1741
|
{
|
|
1668
1742
|
key: "canBack",
|
|
1669
1743
|
get: function get() {
|
|
@@ -1843,7 +1917,7 @@ var MultipleDocCollabHistory = /*#__PURE__*/ function() {
|
|
|
1843
1917
|
_this.stackItem = null;
|
|
1844
1918
|
_this.pushEvent.next();
|
|
1845
1919
|
_this.changeEvent.next();
|
|
1846
|
-
}, 500);
|
|
1920
|
+
}, typeof undoManagerConfig.captureTimeout === 'number' ? undoManagerConfig.captureTimeout : 500);
|
|
1847
1921
|
}
|
|
1848
1922
|
_this.stackItem.undoManagers.push(undoManager);
|
|
1849
1923
|
}
|
|
@@ -1868,12 +1942,12 @@ MultipleDocCollabHistory = _ts_decorate([
|
|
|
1868
1942
|
])
|
|
1869
1943
|
], MultipleDocCollabHistory);
|
|
1870
1944
|
|
|
1871
|
-
function _class_call_check$
|
|
1945
|
+
function _class_call_check$5(instance, Constructor) {
|
|
1872
1946
|
if (!(instance instanceof Constructor)) {
|
|
1873
1947
|
throw new TypeError("Cannot call a class as a function");
|
|
1874
1948
|
}
|
|
1875
1949
|
}
|
|
1876
|
-
function _define_property$
|
|
1950
|
+
function _define_property$5(obj, key, value) {
|
|
1877
1951
|
if (key in obj) {
|
|
1878
1952
|
Object.defineProperty(obj, key, {
|
|
1879
1953
|
value: value,
|
|
@@ -1889,35 +1963,35 @@ function _define_property$4(obj, key, value) {
|
|
|
1889
1963
|
/**
|
|
1890
1964
|
* 协作通信通用接口
|
|
1891
1965
|
*/ var SyncConnector = function SyncConnector() {
|
|
1892
|
-
_class_call_check$
|
|
1966
|
+
_class_call_check$5(this, SyncConnector);
|
|
1893
1967
|
/**
|
|
1894
1968
|
* 当文档加载完成时触发的观察者
|
|
1895
|
-
*/ _define_property$
|
|
1969
|
+
*/ _define_property$5(this, "onLoad", void 0);
|
|
1896
1970
|
/**
|
|
1897
1971
|
* 当文档 awareness 状态变更时触发的观察者
|
|
1898
|
-
*/ _define_property$
|
|
1899
|
-
_define_property$
|
|
1900
|
-
_define_property$
|
|
1972
|
+
*/ _define_property$5(this, "onStateChange", void 0);
|
|
1973
|
+
_define_property$5(this, "loadEvent", new Subject());
|
|
1974
|
+
_define_property$5(this, "stateChangeEvent", new Subject());
|
|
1901
1975
|
this.onLoad = this.loadEvent.asObservable();
|
|
1902
1976
|
this.onStateChange = this.stateChangeEvent.asObservable();
|
|
1903
1977
|
};
|
|
1904
1978
|
|
|
1905
|
-
function _assert_this_initialized$
|
|
1979
|
+
function _assert_this_initialized$2(self) {
|
|
1906
1980
|
if (self === void 0) {
|
|
1907
1981
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
1908
1982
|
}
|
|
1909
1983
|
return self;
|
|
1910
1984
|
}
|
|
1911
|
-
function _call_super$
|
|
1912
|
-
derived = _get_prototype_of$
|
|
1913
|
-
return _possible_constructor_return$
|
|
1985
|
+
function _call_super$2(_this, derived, args) {
|
|
1986
|
+
derived = _get_prototype_of$2(derived);
|
|
1987
|
+
return _possible_constructor_return$2(_this, _is_native_reflect_construct$2() ? Reflect.construct(derived, [], _get_prototype_of$2(_this).constructor) : derived.apply(_this, args));
|
|
1914
1988
|
}
|
|
1915
|
-
function _class_call_check$
|
|
1989
|
+
function _class_call_check$4(instance, Constructor) {
|
|
1916
1990
|
if (!(instance instanceof Constructor)) {
|
|
1917
1991
|
throw new TypeError("Cannot call a class as a function");
|
|
1918
1992
|
}
|
|
1919
1993
|
}
|
|
1920
|
-
function _defineProperties$
|
|
1994
|
+
function _defineProperties$4(target, props) {
|
|
1921
1995
|
for(var i = 0; i < props.length; i++){
|
|
1922
1996
|
var descriptor = props[i];
|
|
1923
1997
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
@@ -1926,11 +2000,11 @@ function _defineProperties$3(target, props) {
|
|
|
1926
2000
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
1927
2001
|
}
|
|
1928
2002
|
}
|
|
1929
|
-
function _create_class$
|
|
1930
|
-
if (protoProps) _defineProperties$
|
|
2003
|
+
function _create_class$4(Constructor, protoProps, staticProps) {
|
|
2004
|
+
if (protoProps) _defineProperties$4(Constructor.prototype, protoProps);
|
|
1931
2005
|
return Constructor;
|
|
1932
2006
|
}
|
|
1933
|
-
function _define_property$
|
|
2007
|
+
function _define_property$4(obj, key, value) {
|
|
1934
2008
|
if (key in obj) {
|
|
1935
2009
|
Object.defineProperty(obj, key, {
|
|
1936
2010
|
value: value,
|
|
@@ -1943,13 +2017,13 @@ function _define_property$3(obj, key, value) {
|
|
|
1943
2017
|
}
|
|
1944
2018
|
return obj;
|
|
1945
2019
|
}
|
|
1946
|
-
function _get_prototype_of$
|
|
1947
|
-
_get_prototype_of$
|
|
2020
|
+
function _get_prototype_of$2(o) {
|
|
2021
|
+
_get_prototype_of$2 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
1948
2022
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
1949
2023
|
};
|
|
1950
|
-
return _get_prototype_of$
|
|
2024
|
+
return _get_prototype_of$2(o);
|
|
1951
2025
|
}
|
|
1952
|
-
function _inherits$
|
|
2026
|
+
function _inherits$2(subClass, superClass) {
|
|
1953
2027
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
1954
2028
|
throw new TypeError("Super expression must either be null or a function");
|
|
1955
2029
|
}
|
|
@@ -1960,9 +2034,9 @@ function _inherits$1(subClass, superClass) {
|
|
|
1960
2034
|
configurable: true
|
|
1961
2035
|
}
|
|
1962
2036
|
});
|
|
1963
|
-
if (superClass) _set_prototype_of$
|
|
2037
|
+
if (superClass) _set_prototype_of$2(subClass, superClass);
|
|
1964
2038
|
}
|
|
1965
|
-
function _object_spread(target) {
|
|
2039
|
+
function _object_spread$1(target) {
|
|
1966
2040
|
for(var i = 1; i < arguments.length; i++){
|
|
1967
2041
|
var source = arguments[i] != null ? arguments[i] : {};
|
|
1968
2042
|
var ownKeys = Object.keys(source);
|
|
@@ -1972,7 +2046,7 @@ function _object_spread(target) {
|
|
|
1972
2046
|
}));
|
|
1973
2047
|
}
|
|
1974
2048
|
ownKeys.forEach(function(key) {
|
|
1975
|
-
_define_property$
|
|
2049
|
+
_define_property$4(target, key, source[key]);
|
|
1976
2050
|
});
|
|
1977
2051
|
}
|
|
1978
2052
|
return target;
|
|
@@ -1996,38 +2070,38 @@ function _object_spread_props(target, source) {
|
|
|
1996
2070
|
}
|
|
1997
2071
|
return target;
|
|
1998
2072
|
}
|
|
1999
|
-
function _possible_constructor_return$
|
|
2000
|
-
if (call && (_type_of$
|
|
2073
|
+
function _possible_constructor_return$2(self, call) {
|
|
2074
|
+
if (call && (_type_of$2(call) === "object" || typeof call === "function")) {
|
|
2001
2075
|
return call;
|
|
2002
2076
|
}
|
|
2003
|
-
return _assert_this_initialized$
|
|
2077
|
+
return _assert_this_initialized$2(self);
|
|
2004
2078
|
}
|
|
2005
|
-
function _set_prototype_of$
|
|
2006
|
-
_set_prototype_of$
|
|
2079
|
+
function _set_prototype_of$2(o, p) {
|
|
2080
|
+
_set_prototype_of$2 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
2007
2081
|
o.__proto__ = p;
|
|
2008
2082
|
return o;
|
|
2009
2083
|
};
|
|
2010
|
-
return _set_prototype_of$
|
|
2084
|
+
return _set_prototype_of$2(o, p);
|
|
2011
2085
|
}
|
|
2012
|
-
function _type_of$
|
|
2086
|
+
function _type_of$2(obj) {
|
|
2013
2087
|
"@swc/helpers - typeof";
|
|
2014
2088
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
2015
2089
|
}
|
|
2016
|
-
function _is_native_reflect_construct$
|
|
2090
|
+
function _is_native_reflect_construct$2() {
|
|
2017
2091
|
try {
|
|
2018
2092
|
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
2019
2093
|
} catch (_) {}
|
|
2020
|
-
return (_is_native_reflect_construct$
|
|
2094
|
+
return (_is_native_reflect_construct$2 = function() {
|
|
2021
2095
|
return !!result;
|
|
2022
2096
|
})();
|
|
2023
2097
|
}
|
|
2024
2098
|
var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
|
|
2025
|
-
_inherits$
|
|
2099
|
+
_inherits$2(HocuspocusConnector, SyncConnector);
|
|
2026
2100
|
function HocuspocusConnector(config) {
|
|
2027
|
-
_class_call_check$
|
|
2101
|
+
_class_call_check$4(this, HocuspocusConnector);
|
|
2028
2102
|
var _this;
|
|
2029
|
-
_this = _call_super$
|
|
2030
|
-
_this.provide = new HocuspocusProvider(_object_spread_props(_object_spread({}, config), {
|
|
2103
|
+
_this = _call_super$2(this, HocuspocusConnector), _define_property$4(_this, "provide", void 0);
|
|
2104
|
+
_this.provide = new HocuspocusProvider(_object_spread_props(_object_spread$1({}, config), {
|
|
2031
2105
|
onSynced: function onSynced(data) {
|
|
2032
2106
|
var _config_onSynced;
|
|
2033
2107
|
(_config_onSynced = config.onSynced) === null || _config_onSynced === void 0 ? void 0 : _config_onSynced.call(config, data);
|
|
@@ -2047,7 +2121,7 @@ var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
|
|
|
2047
2121
|
}));
|
|
2048
2122
|
return _this;
|
|
2049
2123
|
}
|
|
2050
|
-
_create_class$
|
|
2124
|
+
_create_class$4(HocuspocusConnector, [
|
|
2051
2125
|
{
|
|
2052
2126
|
key: "setLocalStateField",
|
|
2053
2127
|
value: function setLocalStateField(key, data) {
|
|
@@ -2065,6 +2139,170 @@ var HocuspocusConnector = /*#__PURE__*/ function(SyncConnector) {
|
|
|
2065
2139
|
return HocuspocusConnector;
|
|
2066
2140
|
}(SyncConnector);
|
|
2067
2141
|
|
|
2142
|
+
function _assert_this_initialized$1(self) {
|
|
2143
|
+
if (self === void 0) {
|
|
2144
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
2145
|
+
}
|
|
2146
|
+
return self;
|
|
2147
|
+
}
|
|
2148
|
+
function _call_super$1(_this, derived, args) {
|
|
2149
|
+
derived = _get_prototype_of$1(derived);
|
|
2150
|
+
return _possible_constructor_return$1(_this, _is_native_reflect_construct$1() ? Reflect.construct(derived, [], _get_prototype_of$1(_this).constructor) : derived.apply(_this, args));
|
|
2151
|
+
}
|
|
2152
|
+
function _class_call_check$3(instance, Constructor) {
|
|
2153
|
+
if (!(instance instanceof Constructor)) {
|
|
2154
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2155
|
+
}
|
|
2156
|
+
}
|
|
2157
|
+
function _defineProperties$3(target, props) {
|
|
2158
|
+
for(var i = 0; i < props.length; i++){
|
|
2159
|
+
var descriptor = props[i];
|
|
2160
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2161
|
+
descriptor.configurable = true;
|
|
2162
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
2163
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2164
|
+
}
|
|
2165
|
+
}
|
|
2166
|
+
function _create_class$3(Constructor, protoProps, staticProps) {
|
|
2167
|
+
if (protoProps) _defineProperties$3(Constructor.prototype, protoProps);
|
|
2168
|
+
return Constructor;
|
|
2169
|
+
}
|
|
2170
|
+
function _define_property$3(obj, key, value) {
|
|
2171
|
+
if (key in obj) {
|
|
2172
|
+
Object.defineProperty(obj, key, {
|
|
2173
|
+
value: value,
|
|
2174
|
+
enumerable: true,
|
|
2175
|
+
configurable: true,
|
|
2176
|
+
writable: true
|
|
2177
|
+
});
|
|
2178
|
+
} else {
|
|
2179
|
+
obj[key] = value;
|
|
2180
|
+
}
|
|
2181
|
+
return obj;
|
|
2182
|
+
}
|
|
2183
|
+
function _get_prototype_of$1(o) {
|
|
2184
|
+
_get_prototype_of$1 = Object.setPrototypeOf ? Object.getPrototypeOf : function getPrototypeOf(o) {
|
|
2185
|
+
return o.__proto__ || Object.getPrototypeOf(o);
|
|
2186
|
+
};
|
|
2187
|
+
return _get_prototype_of$1(o);
|
|
2188
|
+
}
|
|
2189
|
+
function _inherits$1(subClass, superClass) {
|
|
2190
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
2191
|
+
throw new TypeError("Super expression must either be null or a function");
|
|
2192
|
+
}
|
|
2193
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
2194
|
+
constructor: {
|
|
2195
|
+
value: subClass,
|
|
2196
|
+
writable: true,
|
|
2197
|
+
configurable: true
|
|
2198
|
+
}
|
|
2199
|
+
});
|
|
2200
|
+
if (superClass) _set_prototype_of$1(subClass, superClass);
|
|
2201
|
+
}
|
|
2202
|
+
function _object_spread(target) {
|
|
2203
|
+
for(var i = 1; i < arguments.length; i++){
|
|
2204
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2205
|
+
var ownKeys = Object.keys(source);
|
|
2206
|
+
if (typeof Object.getOwnPropertySymbols === "function") {
|
|
2207
|
+
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
|
|
2208
|
+
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
|
|
2209
|
+
}));
|
|
2210
|
+
}
|
|
2211
|
+
ownKeys.forEach(function(key) {
|
|
2212
|
+
_define_property$3(target, key, source[key]);
|
|
2213
|
+
});
|
|
2214
|
+
}
|
|
2215
|
+
return target;
|
|
2216
|
+
}
|
|
2217
|
+
function _possible_constructor_return$1(self, call) {
|
|
2218
|
+
if (call && (_type_of$1(call) === "object" || typeof call === "function")) {
|
|
2219
|
+
return call;
|
|
2220
|
+
}
|
|
2221
|
+
return _assert_this_initialized$1(self);
|
|
2222
|
+
}
|
|
2223
|
+
function _set_prototype_of$1(o, p) {
|
|
2224
|
+
_set_prototype_of$1 = Object.setPrototypeOf || function setPrototypeOf(o, p) {
|
|
2225
|
+
o.__proto__ = p;
|
|
2226
|
+
return o;
|
|
2227
|
+
};
|
|
2228
|
+
return _set_prototype_of$1(o, p);
|
|
2229
|
+
}
|
|
2230
|
+
function _type_of$1(obj) {
|
|
2231
|
+
"@swc/helpers - typeof";
|
|
2232
|
+
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
2233
|
+
}
|
|
2234
|
+
function _is_native_reflect_construct$1() {
|
|
2235
|
+
try {
|
|
2236
|
+
var result = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {}));
|
|
2237
|
+
} catch (_) {}
|
|
2238
|
+
return (_is_native_reflect_construct$1 = function() {
|
|
2239
|
+
return !!result;
|
|
2240
|
+
})();
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2243
|
+
* 不经网络的协作连接器,实现与 {@link SyncConnector} 相同的对外行为,
|
|
2244
|
+
* 便于在单元测试中配合 {@link CollaborateModule} 使用,无需 WebSocket / Provider。
|
|
2245
|
+
*
|
|
2246
|
+
* - `onLoad`:在微任务中触发一次,对应远端「已同步可编辑」的时机。
|
|
2247
|
+
* - `onStateChange`:在每次 {@link LocalConnector.setLocalStateField} 后发出当前客户端状态,
|
|
2248
|
+
* 载荷形状与 `YWebsocketConnector` 一致(`{ clientId, message }`,其中 `message` 为 awareness 上的 `message` 字段)。
|
|
2249
|
+
*
|
|
2250
|
+
* 第一个参数与 `createConnector(yDoc)` 对齐,便于直接传入 `Collaborate` 的文档;当前实现不读写该 `YDoc`。
|
|
2251
|
+
*/ var LocalConnector = /*#__PURE__*/ function(SyncConnector) {
|
|
2252
|
+
_inherits$1(LocalConnector, SyncConnector);
|
|
2253
|
+
function LocalConnector(_yDoc, options) {
|
|
2254
|
+
_class_call_check$3(this, LocalConnector);
|
|
2255
|
+
var _this;
|
|
2256
|
+
var _ref;
|
|
2257
|
+
_this = _call_super$1(this, LocalConnector), _define_property$3(_this, "clientId", void 0), _define_property$3(_this, "destroyed", false), _define_property$3(_this, "fields", {});
|
|
2258
|
+
_this.clientId = (_ref = options === null || options === void 0 ? void 0 : options.clientId) !== null && _ref !== void 0 ? _ref : 0;
|
|
2259
|
+
Promise.resolve().then(function() {
|
|
2260
|
+
if (!_this.destroyed) {
|
|
2261
|
+
_this.loadEvent.next();
|
|
2262
|
+
}
|
|
2263
|
+
});
|
|
2264
|
+
return _this;
|
|
2265
|
+
}
|
|
2266
|
+
_create_class$3(LocalConnector, [
|
|
2267
|
+
{
|
|
2268
|
+
key: "setLocalStateField",
|
|
2269
|
+
value: function setLocalStateField(key, data) {
|
|
2270
|
+
if (this.destroyed) {
|
|
2271
|
+
return;
|
|
2272
|
+
}
|
|
2273
|
+
this.fields[key] = data;
|
|
2274
|
+
this.emitAwarenessStates();
|
|
2275
|
+
}
|
|
2276
|
+
},
|
|
2277
|
+
{
|
|
2278
|
+
key: "onDestroy",
|
|
2279
|
+
value: function onDestroy() {
|
|
2280
|
+
this.destroyed = true;
|
|
2281
|
+
}
|
|
2282
|
+
},
|
|
2283
|
+
{
|
|
2284
|
+
/**
|
|
2285
|
+
* 读取当前本地 awareness 字段快照,仅用于测试断言。
|
|
2286
|
+
*/ key: "getLocalAwarenessSnapshot",
|
|
2287
|
+
value: function getLocalAwarenessSnapshot() {
|
|
2288
|
+
return _object_spread({}, this.fields);
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
{
|
|
2292
|
+
key: "emitAwarenessStates",
|
|
2293
|
+
value: function emitAwarenessStates() {
|
|
2294
|
+
var states = [];
|
|
2295
|
+
states.push({
|
|
2296
|
+
clientId: this.clientId,
|
|
2297
|
+
message: this.fields.message
|
|
2298
|
+
});
|
|
2299
|
+
this.stateChangeEvent.next(states);
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
]);
|
|
2303
|
+
return LocalConnector;
|
|
2304
|
+
}(SyncConnector);
|
|
2305
|
+
|
|
2068
2306
|
function _assert_this_initialized(self) {
|
|
2069
2307
|
if (self === void 0) {
|
|
2070
2308
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
@@ -2433,5 +2671,5 @@ var MultipleDocumentCollaborateModule = /*#__PURE__*/ function() {
|
|
|
2433
2671
|
return MultipleDocumentCollaborateModule;
|
|
2434
2672
|
}();
|
|
2435
2673
|
|
|
2436
|
-
export { CollabHistory, Collaborate, CollaborateModule, CustomUndoManagerConfig, HocuspocusConnector, MessageBus, MultipleDocCollabHistory, MultipleDocumentCollaborateModule, NonSubModelLoader, SubModelLoader, SyncConnector, YWebsocketConnector };
|
|
2674
|
+
export { CollabHistory, Collaborate, CollaborateModule, CustomUndoManagerConfig, HocuspocusConnector, LocalConnector, MessageBus, MultipleDocCollabHistory, MultipleDocumentCollaborateModule, NonSubModelLoader, SubModelLoader, SyncConnector, YWebsocketConnector };
|
|
2437
2675
|
//# sourceMappingURL=index.esm.js.map
|