@univerjs/drawing 0.5.0 → 0.5.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/lib/cjs/index.js +1 -1
- package/lib/es/index.js +1522 -1510
- package/lib/types/controllers/config.schema.d.ts +1 -1
- package/lib/types/index.d.ts +1 -2
- package/lib/types/models/image-model-interface.d.ts +1 -2
- package/lib/types/plugin.d.ts +1 -1
- package/lib/types/services/drawing-manager-impl.service.d.ts +2 -2
- package/lib/types/services/drawing-manager.service.d.ts +1 -36
- package/lib/types/services/image-io.service.d.ts +16 -30
- package/lib/umd/index.js +1 -1
- package/package.json +6 -6
- package/lib/types/services/interface.d.ts +0 -10
package/lib/es/index.js
CHANGED
|
@@ -1,318 +1,329 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { sortRules as Nt, sortRulesByDesc as Rt, createIdentifier as
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function
|
|
10
|
-
if (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (
|
|
1
|
+
var jt = Object.defineProperty;
|
|
2
|
+
var $t = (a, e, n) => e in a ? jt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3
|
+
var F = (a, e, n) => $t(a, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { sortRules as Nt, sortRulesByDesc as Rt, createIdentifier as xt, ImageSourceType as at, ImageUploadStatusType as et, Tools as Bt, Inject as Wt, Injector as Gt, Plugin as Lt, mergeOverrideWithDependencies as qt, IConfigService as Kt, IImageIoService as Ft } from "@univerjs/core";
|
|
5
|
+
import { IImageIoService as wn, ImageSourceType as bn, ImageUploadStatusType as Cn } from "@univerjs/core";
|
|
6
|
+
import { Subject as be } from "rxjs";
|
|
7
|
+
const pn = 500, gn = 500, yn = 10, Vt = 5 * 1024 * 1024, Ht = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
|
|
8
|
+
var Ve = {}, Ze = {}, tt = {}, _t;
|
|
9
|
+
function zt() {
|
|
10
|
+
if (_t) return tt;
|
|
11
|
+
_t = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
|
|
12
|
+
function a(t, r) {
|
|
13
|
+
if (Array.isArray(r))
|
|
14
14
|
return !1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (!
|
|
15
|
+
for (let u in t)
|
|
16
|
+
if (!n(t[u], r[u]))
|
|
17
|
+
return !1;
|
|
18
|
+
for (let u in r)
|
|
19
|
+
if (t[u] === void 0)
|
|
20
|
+
return !1;
|
|
21
|
+
return !0;
|
|
22
|
+
}
|
|
23
|
+
function e(t, r) {
|
|
24
|
+
if (!Array.isArray(r) || t.length !== r.length)
|
|
25
25
|
return !1;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
ct.default = ut;
|
|
32
|
-
var dt = {};
|
|
33
|
-
Object.defineProperty(dt, "__esModule", { value: !0 });
|
|
34
|
-
function lt(n) {
|
|
35
|
-
if (n === null)
|
|
36
|
-
return null;
|
|
37
|
-
if (Array.isArray(n))
|
|
38
|
-
return n.map(lt);
|
|
39
|
-
if (typeof n == "object") {
|
|
40
|
-
const e = {};
|
|
41
|
-
for (let t in n)
|
|
42
|
-
e[t] = lt(n[t]);
|
|
43
|
-
return e;
|
|
44
|
-
} else
|
|
45
|
-
return n;
|
|
46
|
-
}
|
|
47
|
-
dt.default = lt;
|
|
48
|
-
var ft = {};
|
|
49
|
-
(function(n) {
|
|
50
|
-
Object.defineProperty(n, "__esModule", { value: !0 }), n.eachChildOf = n.advancer = n.readCursor = n.writeCursor = n.WriteCursor = n.ReadCursor = n.isValidPathItem = void 0;
|
|
51
|
-
function e(O, o) {
|
|
52
|
-
if (!O)
|
|
53
|
-
throw new Error(o);
|
|
54
|
-
}
|
|
55
|
-
const t = (O) => O != null && typeof O == "object" && !Array.isArray(O), i = (O, o) => (
|
|
56
|
-
// All the numbers, then all the letters. Just as the gods of ascii intended.
|
|
57
|
-
typeof O == typeof o ? O > o : typeof O == "string" && typeof o == "number"
|
|
58
|
-
);
|
|
59
|
-
function s(O, o) {
|
|
60
|
-
for (let c in O) {
|
|
61
|
-
const h = c;
|
|
62
|
-
o.write(h, O[h]);
|
|
63
|
-
}
|
|
26
|
+
for (let u = 0; u < t.length; u++)
|
|
27
|
+
if (!n(t[u], r[u]))
|
|
28
|
+
return !1;
|
|
29
|
+
return !0;
|
|
64
30
|
}
|
|
65
|
-
n
|
|
66
|
-
|
|
67
|
-
constructor(o = null) {
|
|
68
|
-
this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = o;
|
|
69
|
-
}
|
|
70
|
-
ascend() {
|
|
71
|
-
e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, t(this.container[this.idx]) && this.idx--);
|
|
72
|
-
}
|
|
73
|
-
getPath() {
|
|
74
|
-
const o = [];
|
|
75
|
-
let c = this.container, h = this.parents.length - 1, k = this.idx;
|
|
76
|
-
for (; k >= 0; )
|
|
77
|
-
o.unshift(c[k]), k === 0 ? (k = this.indexes[h * 2], c = this.parents[h--]) : k -= t(c[k - 1]) ? 2 : 1;
|
|
78
|
-
return o;
|
|
79
|
-
}
|
|
31
|
+
function n(t, r) {
|
|
32
|
+
return t === r ? !0 : t === null || r === null || typeof t != "object" || typeof r != "object" ? !1 : Array.isArray(t) ? e(t, r) : a(t, r);
|
|
80
33
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
let
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
}
|
|
110
|
-
clone() {
|
|
111
|
-
const o = new l();
|
|
112
|
-
return o._init(this.container, this.idx, this.parents, this.indexes), o;
|
|
34
|
+
return tt.default = n, tt;
|
|
35
|
+
}
|
|
36
|
+
var nt = {}, vt;
|
|
37
|
+
function Xt() {
|
|
38
|
+
if (vt) return nt;
|
|
39
|
+
vt = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
|
|
40
|
+
function a(e) {
|
|
41
|
+
if (e === null)
|
|
42
|
+
return null;
|
|
43
|
+
if (Array.isArray(e))
|
|
44
|
+
return e.map(a);
|
|
45
|
+
if (typeof e == "object") {
|
|
46
|
+
const n = {};
|
|
47
|
+
for (let t in e)
|
|
48
|
+
n[t] = a(e[t]);
|
|
49
|
+
return n;
|
|
50
|
+
} else
|
|
51
|
+
return e;
|
|
52
|
+
}
|
|
53
|
+
return nt.default = a, nt;
|
|
54
|
+
}
|
|
55
|
+
var lt = {}, mt;
|
|
56
|
+
function At() {
|
|
57
|
+
return mt || (mt = 1, function(a) {
|
|
58
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0;
|
|
59
|
+
function e(_, s) {
|
|
60
|
+
if (!_)
|
|
61
|
+
throw new Error(s);
|
|
113
62
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
63
|
+
const n = (_) => _ != null && typeof _ == "object" && !Array.isArray(_), t = (_, s) => (
|
|
64
|
+
// All the numbers, then all the letters. Just as the gods of ascii intended.
|
|
65
|
+
typeof _ == typeof s ? _ > s : typeof _ == "string" && typeof s == "number"
|
|
66
|
+
);
|
|
67
|
+
function r(_, s) {
|
|
68
|
+
for (let c in _) {
|
|
69
|
+
const h = c;
|
|
70
|
+
s.write(h, _[h]);
|
|
120
71
|
}
|
|
121
72
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
this.traverse(o, (h, k) => {
|
|
138
|
-
h.d != null && c(h.d, k);
|
|
139
|
-
});
|
|
73
|
+
a.isValidPathItem = (_) => typeof _ == "number" || typeof _ == "string" && _ !== "__proto__";
|
|
74
|
+
class u {
|
|
75
|
+
constructor(s = null) {
|
|
76
|
+
this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = s;
|
|
77
|
+
}
|
|
78
|
+
ascend() {
|
|
79
|
+
e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, n(this.container[this.idx]) && this.idx--);
|
|
80
|
+
}
|
|
81
|
+
getPath() {
|
|
82
|
+
const s = [];
|
|
83
|
+
let c = this.container, h = this.parents.length - 1, S = this.idx;
|
|
84
|
+
for (; S >= 0; )
|
|
85
|
+
s.unshift(c[S]), S === 0 ? (S = this.indexes[h * 2], c = this.parents[h--]) : S -= n(c[S - 1]) ? 2 : 1;
|
|
86
|
+
return s;
|
|
87
|
+
}
|
|
140
88
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
89
|
+
class o extends u {
|
|
90
|
+
get() {
|
|
91
|
+
return this.container ? this.container.slice(this.idx + 1) : null;
|
|
92
|
+
}
|
|
93
|
+
// Its only valid to call this after descending into a child.
|
|
94
|
+
getKey() {
|
|
95
|
+
return e(this.container != null, "Invalid call to getKey before cursor descended"), this.container[this.idx];
|
|
96
|
+
}
|
|
97
|
+
getComponent() {
|
|
98
|
+
let s;
|
|
99
|
+
return this.container && this.container.length > this.idx + 1 && n(s = this.container[this.idx + 1]) ? s : null;
|
|
100
|
+
}
|
|
101
|
+
descendFirst() {
|
|
102
|
+
let s = this.idx + 1;
|
|
103
|
+
if (!this.container || s >= this.container.length || n(this.container[s]) && s + 1 >= this.container.length)
|
|
104
|
+
return !1;
|
|
105
|
+
n(this.container[s]) && s++;
|
|
106
|
+
const c = this.container[s];
|
|
107
|
+
return Array.isArray(c) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(s), this.idx = 0, this.container = c) : this.idx = s, !0;
|
|
108
|
+
}
|
|
109
|
+
nextSibling() {
|
|
110
|
+
if (e(this.parents.length === this.indexes.length / 2), this.idx > 0 || this.parents.length === 0)
|
|
111
|
+
return !1;
|
|
112
|
+
const s = this.indexes[this.indexes.length - 1] + 1, c = this.parents[this.parents.length - 1];
|
|
113
|
+
return s >= c.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = c[s], !0);
|
|
114
|
+
}
|
|
115
|
+
_init(s, c, h, S) {
|
|
116
|
+
this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = S.slice();
|
|
117
|
+
}
|
|
118
|
+
clone() {
|
|
119
|
+
const s = new o();
|
|
120
|
+
return s._init(this.container, this.idx, this.parents, this.indexes), s;
|
|
121
|
+
}
|
|
122
|
+
*[Symbol.iterator]() {
|
|
123
|
+
if (this.descendFirst()) {
|
|
124
|
+
do
|
|
125
|
+
yield this.getKey();
|
|
126
|
+
while (this.nextSibling());
|
|
127
|
+
this.ascend();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
// TODO(cleanup): Consider moving these functions out of cursor, since
|
|
131
|
+
// they're really just helper methods.
|
|
132
|
+
// It'd be really nice to do this using generators.
|
|
133
|
+
traverse(s, c) {
|
|
134
|
+
const h = this.getComponent();
|
|
135
|
+
h && c(h, s);
|
|
136
|
+
for (const S of this)
|
|
137
|
+
s && s.descend(S), this.traverse(s, c), s && s.ascend();
|
|
138
|
+
}
|
|
139
|
+
eachPick(s, c) {
|
|
140
|
+
this.traverse(s, (h, S) => {
|
|
141
|
+
h.p != null && c(h.p, S);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
eachDrop(s, c) {
|
|
145
|
+
this.traverse(s, (h, S) => {
|
|
146
|
+
h.d != null && c(h.d, S);
|
|
147
|
+
});
|
|
148
|
+
}
|
|
146
149
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(i(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && i(c, this.container[h][0]); )
|
|
162
|
-
h++;
|
|
163
|
-
if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
|
|
164
|
-
this.container = this.container[h];
|
|
150
|
+
a.ReadCursor = o;
|
|
151
|
+
class l extends u {
|
|
152
|
+
constructor(s = null) {
|
|
153
|
+
super(s), this.pendingDescent = [], this._op = s;
|
|
154
|
+
}
|
|
155
|
+
flushDescent() {
|
|
156
|
+
e(this.parents.length === this.indexes.length / 2), this.container === null && (this._op = this.container = []);
|
|
157
|
+
for (let s = 0; s < this.pendingDescent.length; s++) {
|
|
158
|
+
const c = this.pendingDescent[s];
|
|
159
|
+
let h = this.idx + 1;
|
|
160
|
+
if (h < this.container.length && n(this.container[h]) && h++, e(h === this.container.length || !n(this.container[h])), h === this.container.length)
|
|
161
|
+
this.container.push(c), this.idx = h;
|
|
162
|
+
else if (this.container[h] === c)
|
|
163
|
+
this.idx = h;
|
|
165
164
|
else {
|
|
166
|
-
|
|
167
|
-
|
|
165
|
+
if (!Array.isArray(this.container[h])) {
|
|
166
|
+
const S = this.container.splice(h, this.container.length - h);
|
|
167
|
+
this.container.push(S), this.lcIdx > -1 && (this.lcIdx = h);
|
|
168
|
+
}
|
|
169
|
+
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(t(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && t(c, this.container[h][0]); )
|
|
170
|
+
h++;
|
|
171
|
+
if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
|
|
172
|
+
this.container = this.container[h];
|
|
173
|
+
else {
|
|
174
|
+
const S = [c];
|
|
175
|
+
this.container.splice(h, 0, S), this.container = S;
|
|
176
|
+
}
|
|
168
177
|
}
|
|
169
178
|
}
|
|
179
|
+
this.pendingDescent.length = 0;
|
|
170
180
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
reset() {
|
|
174
|
-
this.lcIdx = -1;
|
|
175
|
-
}
|
|
176
|
-
// Creates and returns a component, creating one if need be. You should
|
|
177
|
-
// probably write to it immediately - ops are not valid with empty
|
|
178
|
-
// components.
|
|
179
|
-
getComponent() {
|
|
180
|
-
this.flushDescent();
|
|
181
|
-
const o = this.idx + 1;
|
|
182
|
-
if (o < this.container.length && t(this.container[o]))
|
|
183
|
-
return this.container[o];
|
|
184
|
-
{
|
|
185
|
-
const c = {};
|
|
186
|
-
return this.container.splice(o, 0, c), c;
|
|
181
|
+
reset() {
|
|
182
|
+
this.lcIdx = -1;
|
|
187
183
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
184
|
+
// Creates and returns a component, creating one if need be. You should
|
|
185
|
+
// probably write to it immediately - ops are not valid with empty
|
|
186
|
+
// components.
|
|
187
|
+
getComponent() {
|
|
188
|
+
this.flushDescent();
|
|
189
|
+
const s = this.idx + 1;
|
|
190
|
+
if (s < this.container.length && n(this.container[s]))
|
|
191
|
+
return this.container[s];
|
|
192
|
+
{
|
|
193
|
+
const c = {};
|
|
194
|
+
return this.container.splice(s, 0, c), c;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
write(s, c) {
|
|
198
|
+
const h = this.getComponent();
|
|
199
|
+
e(h[s] == null || h[s] === c, "Internal consistency error: Overwritten component. File a bug"), h[s] = c;
|
|
200
|
+
}
|
|
201
|
+
get() {
|
|
202
|
+
return this._op;
|
|
203
|
+
}
|
|
204
|
+
descend(s) {
|
|
205
|
+
if (!a.isValidPathItem(s))
|
|
206
|
+
throw Error("Invalid JSON key");
|
|
207
|
+
this.pendingDescent.push(s);
|
|
208
|
+
}
|
|
209
|
+
descendPath(s) {
|
|
210
|
+
return this.pendingDescent.push(...s), this;
|
|
211
|
+
}
|
|
212
|
+
ascend() {
|
|
213
|
+
this.pendingDescent.length ? this.pendingDescent.pop() : super.ascend();
|
|
214
|
+
}
|
|
215
|
+
mergeTree(s, c = r) {
|
|
216
|
+
if (s === null)
|
|
217
|
+
return;
|
|
218
|
+
if (e(Array.isArray(s)), s === this._op)
|
|
219
|
+
throw Error("Cannot merge into my own tree");
|
|
220
|
+
const h = this.lcIdx, S = this.parents.length;
|
|
221
|
+
let Y = 0;
|
|
222
|
+
for (let pe = 0; pe < s.length; pe++) {
|
|
223
|
+
const Z = s[pe];
|
|
224
|
+
typeof Z == "string" || typeof Z == "number" ? (Y++, this.descend(Z)) : Array.isArray(Z) ? this.mergeTree(Z, c) : typeof Z == "object" && c(Z, this);
|
|
225
|
+
}
|
|
226
|
+
for (; Y--; )
|
|
227
|
+
this.ascend();
|
|
228
|
+
this.lcIdx = this.parents.length === S ? h : -1;
|
|
229
|
+
}
|
|
230
|
+
at(s, c) {
|
|
231
|
+
this.descendPath(s), c(this);
|
|
232
|
+
for (let h = 0; h < s.length; h++)
|
|
233
|
+
this.ascend();
|
|
234
|
+
return this;
|
|
235
|
+
}
|
|
236
|
+
// This is used by helpers, so the strict ordering guarantees are
|
|
237
|
+
// relaxed.
|
|
238
|
+
writeAtPath(s, c, h) {
|
|
239
|
+
return this.at(s, () => this.write(c, h)), this.reset(), this;
|
|
240
|
+
}
|
|
241
|
+
writeMove(s, c, h = 0) {
|
|
242
|
+
return this.writeAtPath(s, "p", h).writeAtPath(c, "d", h);
|
|
243
|
+
}
|
|
244
|
+
getPath() {
|
|
245
|
+
const s = super.getPath();
|
|
246
|
+
return s.push(...this.pendingDescent), s;
|
|
217
247
|
}
|
|
218
|
-
for (; Z--; )
|
|
219
|
-
this.ascend();
|
|
220
|
-
this.lcIdx = this.parents.length === k ? h : -1;
|
|
221
|
-
}
|
|
222
|
-
at(o, c) {
|
|
223
|
-
this.descendPath(o), c(this);
|
|
224
|
-
for (let h = 0; h < o.length; h++)
|
|
225
|
-
this.ascend();
|
|
226
|
-
return this;
|
|
227
|
-
}
|
|
228
|
-
// This is used by helpers, so the strict ordering guarantees are
|
|
229
|
-
// relaxed.
|
|
230
|
-
writeAtPath(o, c, h) {
|
|
231
|
-
return this.at(o, () => this.write(c, h)), this.reset(), this;
|
|
232
|
-
}
|
|
233
|
-
writeMove(o, c, h = 0) {
|
|
234
|
-
return this.writeAtPath(o, "p", h).writeAtPath(c, "d", h);
|
|
235
|
-
}
|
|
236
|
-
getPath() {
|
|
237
|
-
const o = super.getPath();
|
|
238
|
-
return o.push(...this.pendingDescent), o;
|
|
239
248
|
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
249
|
+
a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_);
|
|
250
|
+
function E(_, s, c) {
|
|
251
|
+
let h, S;
|
|
252
|
+
S = h = _ ? _.descendFirst() : !1;
|
|
253
|
+
function Y(pe) {
|
|
254
|
+
let Z;
|
|
255
|
+
for (; S; ) {
|
|
256
|
+
const Ce = Z = _.getKey();
|
|
257
|
+
if (pe != null) {
|
|
258
|
+
let Ge = !1;
|
|
259
|
+
if (s && typeof Ce == "number" && (Z = s(Ce, _.getComponent()), Z < 0 && (Z = ~Z, Ge = !0)), t(Z, pe))
|
|
260
|
+
return null;
|
|
261
|
+
if (Z === pe && !Ge)
|
|
262
|
+
return _;
|
|
263
|
+
}
|
|
264
|
+
c && typeof Z == "number" && c(Z, _.getComponent()), S = _.nextSibling();
|
|
255
265
|
}
|
|
256
|
-
|
|
266
|
+
return null;
|
|
257
267
|
}
|
|
258
|
-
return
|
|
268
|
+
return Y.end = () => {
|
|
269
|
+
h && _.ascend();
|
|
270
|
+
}, Y;
|
|
259
271
|
}
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
let J = h ? O.getKey() : null, Ie = Z ? o.getKey() : null;
|
|
269
|
-
J !== null && Ie !== null && (i(Ie, J) ? Ie = null : J !== Ie && (J = null)), c(J == null ? Ie : J, J != null ? O : null, Ie != null ? o : null), J != null && h && (h = O.nextSibling()), Ie != null && Z && (Z = o.nextSibling());
|
|
272
|
+
a.advancer = E;
|
|
273
|
+
function x(_, s, c) {
|
|
274
|
+
let h, S, Y, pe;
|
|
275
|
+
for (h = S = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
|
|
276
|
+
let Z = h ? _.getKey() : null, Ce = Y ? s.getKey() : null;
|
|
277
|
+
Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), c(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null && Y && (Y = s.nextSibling());
|
|
278
|
+
}
|
|
279
|
+
S && _.ascend(), pe && s.ascend();
|
|
270
280
|
}
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
(function(
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
281
|
+
a.eachChildOf = x;
|
|
282
|
+
}(lt)), lt;
|
|
283
|
+
}
|
|
284
|
+
var ut = {}, Ot;
|
|
285
|
+
function Mt() {
|
|
286
|
+
return Ot || (Ot = 1, function(a) {
|
|
287
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, function(e) {
|
|
288
|
+
e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
|
|
289
|
+
}(a.ConflictType || (a.ConflictType = {}));
|
|
290
|
+
}(ut)), ut;
|
|
291
|
+
}
|
|
292
|
+
var Se = {}, He = {}, wt;
|
|
293
|
+
function ht() {
|
|
294
|
+
return wt || (wt = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.uniToStrPos = He.strPosToUni = void 0, He.strPosToUni = (a, e = a.length) => {
|
|
295
|
+
let n = 0, t = 0;
|
|
296
|
+
for (; t < e; t++) {
|
|
297
|
+
const r = a.charCodeAt(t);
|
|
298
|
+
r >= 55296 && r <= 57343 && (n++, t++);
|
|
288
299
|
}
|
|
289
|
-
if (
|
|
300
|
+
if (t !== e)
|
|
290
301
|
throw Error("Invalid offset - splits unicode bytes");
|
|
291
|
-
return
|
|
292
|
-
},
|
|
293
|
-
let
|
|
302
|
+
return t - n;
|
|
303
|
+
}, He.uniToStrPos = (a, e) => {
|
|
304
|
+
let n = 0;
|
|
294
305
|
for (; e > 0; e--) {
|
|
295
|
-
const
|
|
296
|
-
|
|
306
|
+
const t = a.charCodeAt(n);
|
|
307
|
+
n += t >= 55296 && t <= 57343 ? 2 : 1;
|
|
297
308
|
}
|
|
298
|
-
return
|
|
299
|
-
}),
|
|
309
|
+
return n;
|
|
310
|
+
}), He;
|
|
300
311
|
}
|
|
301
|
-
var
|
|
302
|
-
function
|
|
303
|
-
return
|
|
304
|
-
Object.defineProperty(
|
|
305
|
-
const e =
|
|
312
|
+
var ct = {}, bt;
|
|
313
|
+
function ft() {
|
|
314
|
+
return bt || (bt = 1, function(a) {
|
|
315
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), a.uniSlice = a.dlen = a.eachOp = void 0;
|
|
316
|
+
const e = ht(), n = (f) => {
|
|
306
317
|
if (!Array.isArray(f))
|
|
307
318
|
throw Error("Op must be an array of components");
|
|
308
|
-
let
|
|
309
|
-
for (let
|
|
310
|
-
const L = f[
|
|
319
|
+
let y = null;
|
|
320
|
+
for (let b = 0; b < f.length; b++) {
|
|
321
|
+
const L = f[b];
|
|
311
322
|
switch (typeof L) {
|
|
312
323
|
case "object":
|
|
313
324
|
if (typeof L.d != "number" && typeof L.d != "string")
|
|
314
325
|
throw Error("Delete must be number or string");
|
|
315
|
-
if (
|
|
326
|
+
if (a.dlen(L.d) <= 0)
|
|
316
327
|
throw Error("Deletes must not be empty");
|
|
317
328
|
break;
|
|
318
329
|
case "string":
|
|
@@ -322,234 +333,236 @@ function at() {
|
|
|
322
333
|
case "number":
|
|
323
334
|
if (!(L > 0))
|
|
324
335
|
throw Error("Skip components must be >0");
|
|
325
|
-
if (typeof
|
|
336
|
+
if (typeof y == "number")
|
|
326
337
|
throw Error("Adjacent skip components should be combined");
|
|
327
338
|
break;
|
|
328
339
|
}
|
|
329
|
-
|
|
340
|
+
y = L;
|
|
330
341
|
}
|
|
331
|
-
if (typeof
|
|
342
|
+
if (typeof y == "number")
|
|
332
343
|
throw Error("Op has a trailing skip");
|
|
333
344
|
};
|
|
334
|
-
function
|
|
335
|
-
let
|
|
345
|
+
function t(f, y) {
|
|
346
|
+
let b = 0, L = 0;
|
|
336
347
|
for (let z = 0; z < f.length; z++) {
|
|
337
|
-
const
|
|
338
|
-
switch (
|
|
348
|
+
const q = f[z];
|
|
349
|
+
switch (y(q, b, L), typeof q) {
|
|
339
350
|
case "object":
|
|
340
|
-
|
|
351
|
+
b += a.dlen(q.d);
|
|
341
352
|
break;
|
|
342
353
|
case "string":
|
|
343
|
-
L += e.strPosToUni(
|
|
354
|
+
L += e.strPosToUni(q);
|
|
344
355
|
break;
|
|
345
356
|
case "number":
|
|
346
|
-
|
|
357
|
+
b += q, L += q;
|
|
347
358
|
break;
|
|
348
359
|
}
|
|
349
360
|
}
|
|
350
361
|
}
|
|
351
|
-
|
|
352
|
-
function
|
|
353
|
-
const
|
|
354
|
-
return
|
|
355
|
-
L(
|
|
356
|
-
}),
|
|
362
|
+
a.eachOp = t;
|
|
363
|
+
function r(f, y) {
|
|
364
|
+
const b = [], L = l(b);
|
|
365
|
+
return t(f, (z, q, Ee) => {
|
|
366
|
+
L(y(z, q, Ee));
|
|
367
|
+
}), s(b);
|
|
357
368
|
}
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
if (!(!
|
|
362
|
-
f.push(
|
|
363
|
-
else if (typeof
|
|
364
|
-
if (typeof
|
|
365
|
-
const
|
|
366
|
-
|
|
369
|
+
const u = (f) => f, o = (f) => r(f, u);
|
|
370
|
+
a.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f);
|
|
371
|
+
const l = (f) => (y) => {
|
|
372
|
+
if (!(!y || y.d === 0 || y.d === "")) if (f.length === 0)
|
|
373
|
+
f.push(y);
|
|
374
|
+
else if (typeof y == typeof f[f.length - 1])
|
|
375
|
+
if (typeof y == "object") {
|
|
376
|
+
const b = f[f.length - 1];
|
|
377
|
+
b.d = typeof b.d == "string" && typeof y.d == "string" ? b.d + y.d : a.dlen(b.d) + a.dlen(y.d);
|
|
367
378
|
} else
|
|
368
|
-
f[f.length - 1] +=
|
|
379
|
+
f[f.length - 1] += y;
|
|
369
380
|
else
|
|
370
|
-
f.push(
|
|
381
|
+
f.push(y);
|
|
371
382
|
}, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
|
|
372
|
-
|
|
373
|
-
const L = e.uniToStrPos(f,
|
|
383
|
+
a.uniSlice = (f, y, b) => {
|
|
384
|
+
const L = e.uniToStrPos(f, y), z = b == null ? 1 / 0 : e.uniToStrPos(f, b);
|
|
374
385
|
return f.slice(L, z);
|
|
375
386
|
};
|
|
376
|
-
const
|
|
377
|
-
let
|
|
378
|
-
return { take: (
|
|
379
|
-
if (
|
|
380
|
-
return
|
|
381
|
-
const
|
|
387
|
+
const x = (f, y, b) => typeof f == "number" ? b == null ? f - y : Math.min(f, b) - y : a.uniSlice(f, y, b), _ = (f) => {
|
|
388
|
+
let y = 0, b = 0;
|
|
389
|
+
return { take: (q, Ee) => {
|
|
390
|
+
if (y === f.length)
|
|
391
|
+
return q === -1 ? null : q;
|
|
392
|
+
const ce = f[y];
|
|
382
393
|
let ne;
|
|
383
|
-
if (typeof
|
|
384
|
-
return
|
|
385
|
-
if (typeof
|
|
386
|
-
if (
|
|
387
|
-
return ne =
|
|
394
|
+
if (typeof ce == "number")
|
|
395
|
+
return q === -1 || ce - b <= q ? (ne = ce - b, ++y, b = 0, ne) : (b += q, q);
|
|
396
|
+
if (typeof ce == "string") {
|
|
397
|
+
if (q === -1 || Ee === "i" || e.strPosToUni(ce.slice(b)) <= q)
|
|
398
|
+
return ne = ce.slice(b), ++y, b = 0, ne;
|
|
388
399
|
{
|
|
389
|
-
const
|
|
390
|
-
return ne =
|
|
400
|
+
const le = b + e.uniToStrPos(ce.slice(b), q);
|
|
401
|
+
return ne = ce.slice(b, le), b = le, ne;
|
|
391
402
|
}
|
|
392
403
|
} else {
|
|
393
|
-
if (
|
|
394
|
-
return ne = { d:
|
|
404
|
+
if (q === -1 || Ee === "d" || a.dlen(ce.d) - b <= q)
|
|
405
|
+
return ne = { d: x(ce.d, b) }, ++y, b = 0, ne;
|
|
395
406
|
{
|
|
396
|
-
let
|
|
397
|
-
return
|
|
407
|
+
let le = x(ce.d, b, b + q);
|
|
408
|
+
return b += q, { d: le };
|
|
398
409
|
}
|
|
399
410
|
}
|
|
400
|
-
}, peek: () => f[
|
|
401
|
-
},
|
|
402
|
-
function c(f,
|
|
403
|
-
if (
|
|
404
|
-
throw Error("side (" +
|
|
405
|
-
|
|
406
|
-
const L = [], z =
|
|
407
|
-
for (let ne = 0; ne <
|
|
408
|
-
const
|
|
409
|
-
let ge,
|
|
410
|
-
switch (typeof
|
|
411
|
+
}, peek: () => f[y] };
|
|
412
|
+
}, s = (f) => (f.length > 0 && typeof f[f.length - 1] == "number" && f.pop(), f);
|
|
413
|
+
function c(f, y, b) {
|
|
414
|
+
if (b !== "left" && b !== "right")
|
|
415
|
+
throw Error("side (" + b + ") must be 'left' or 'right'");
|
|
416
|
+
n(f), n(y);
|
|
417
|
+
const L = [], z = l(L), { take: q, peek: Ee } = _(f);
|
|
418
|
+
for (let ne = 0; ne < y.length; ne++) {
|
|
419
|
+
const le = y[ne];
|
|
420
|
+
let ge, De;
|
|
421
|
+
switch (typeof le) {
|
|
411
422
|
case "number":
|
|
412
|
-
for (ge =
|
|
413
|
-
|
|
423
|
+
for (ge = le; ge > 0; )
|
|
424
|
+
De = q(ge, "i"), z(De), typeof De != "string" && (ge -= E(De));
|
|
414
425
|
break;
|
|
415
426
|
case "string":
|
|
416
|
-
|
|
427
|
+
b === "left" && typeof Ee() == "string" && z(q(-1)), z(e.strPosToUni(le));
|
|
417
428
|
break;
|
|
418
429
|
case "object":
|
|
419
|
-
for (ge =
|
|
420
|
-
switch (
|
|
430
|
+
for (ge = a.dlen(le.d); ge > 0; )
|
|
431
|
+
switch (De = q(ge, "i"), typeof De) {
|
|
421
432
|
case "number":
|
|
422
|
-
ge -=
|
|
433
|
+
ge -= De;
|
|
423
434
|
break;
|
|
424
435
|
case "string":
|
|
425
|
-
z(
|
|
436
|
+
z(De);
|
|
426
437
|
break;
|
|
427
438
|
case "object":
|
|
428
|
-
ge -=
|
|
439
|
+
ge -= a.dlen(De.d);
|
|
429
440
|
}
|
|
430
441
|
break;
|
|
431
442
|
}
|
|
432
443
|
}
|
|
433
|
-
let
|
|
434
|
-
for (;
|
|
435
|
-
z(
|
|
436
|
-
return
|
|
444
|
+
let ce;
|
|
445
|
+
for (; ce = q(-1); )
|
|
446
|
+
z(ce);
|
|
447
|
+
return s(L);
|
|
437
448
|
}
|
|
438
|
-
function h(f,
|
|
439
|
-
|
|
440
|
-
const
|
|
441
|
-
for (let
|
|
442
|
-
const
|
|
443
|
-
let ne,
|
|
444
|
-
switch (typeof
|
|
449
|
+
function h(f, y) {
|
|
450
|
+
n(f), n(y);
|
|
451
|
+
const b = [], L = l(b), { take: z } = _(f);
|
|
452
|
+
for (let Ee = 0; Ee < y.length; Ee++) {
|
|
453
|
+
const ce = y[Ee];
|
|
454
|
+
let ne, le;
|
|
455
|
+
switch (typeof ce) {
|
|
445
456
|
case "number":
|
|
446
|
-
for (ne =
|
|
447
|
-
|
|
457
|
+
for (ne = ce; ne > 0; )
|
|
458
|
+
le = z(ne, "d"), L(le), typeof le != "object" && (ne -= E(le));
|
|
448
459
|
break;
|
|
449
460
|
case "string":
|
|
450
|
-
L(
|
|
461
|
+
L(ce);
|
|
451
462
|
break;
|
|
452
463
|
case "object":
|
|
453
|
-
ne =
|
|
464
|
+
ne = a.dlen(ce.d);
|
|
454
465
|
let ge = 0;
|
|
455
466
|
for (; ge < ne; )
|
|
456
|
-
switch (
|
|
467
|
+
switch (le = z(ne - ge, "d"), typeof le) {
|
|
457
468
|
case "number":
|
|
458
|
-
L({ d:
|
|
469
|
+
L({ d: x(ce.d, ge, ge + le) }), ge += le;
|
|
459
470
|
break;
|
|
460
471
|
case "string":
|
|
461
|
-
ge += e.strPosToUni(
|
|
472
|
+
ge += e.strPosToUni(le);
|
|
462
473
|
break;
|
|
463
474
|
case "object":
|
|
464
|
-
L(
|
|
475
|
+
L(le);
|
|
465
476
|
}
|
|
466
477
|
break;
|
|
467
478
|
}
|
|
468
479
|
}
|
|
469
|
-
let
|
|
470
|
-
for (;
|
|
471
|
-
L(
|
|
472
|
-
return
|
|
480
|
+
let q;
|
|
481
|
+
for (; q = z(-1); )
|
|
482
|
+
L(q);
|
|
483
|
+
return s(b);
|
|
473
484
|
}
|
|
474
|
-
const
|
|
475
|
-
let
|
|
476
|
-
for (let L = 0; L <
|
|
477
|
-
const z =
|
|
485
|
+
const S = (f, y) => {
|
|
486
|
+
let b = 0;
|
|
487
|
+
for (let L = 0; L < y.length && f > b; L++) {
|
|
488
|
+
const z = y[L];
|
|
478
489
|
switch (typeof z) {
|
|
479
490
|
case "number": {
|
|
480
|
-
|
|
491
|
+
b += z;
|
|
481
492
|
break;
|
|
482
493
|
}
|
|
483
494
|
case "string":
|
|
484
|
-
const
|
|
485
|
-
|
|
495
|
+
const q = e.strPosToUni(z);
|
|
496
|
+
b += q, f += q;
|
|
486
497
|
break;
|
|
487
498
|
case "object":
|
|
488
|
-
f -= Math.min(
|
|
499
|
+
f -= Math.min(a.dlen(z.d), f - b);
|
|
489
500
|
break;
|
|
490
501
|
}
|
|
491
502
|
}
|
|
492
503
|
return f;
|
|
493
|
-
},
|
|
494
|
-
function pe(f,
|
|
495
|
-
return
|
|
504
|
+
}, Y = (f, y) => typeof f == "number" ? S(f, y) : f.map((b) => S(b, y));
|
|
505
|
+
function pe(f, y, b) {
|
|
506
|
+
return r(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: b.slice(y, z, z + L.d) } : L);
|
|
496
507
|
}
|
|
497
|
-
function
|
|
498
|
-
return
|
|
499
|
-
switch (typeof
|
|
508
|
+
function Z(f) {
|
|
509
|
+
return r(f, (y) => {
|
|
510
|
+
switch (typeof y) {
|
|
500
511
|
case "object":
|
|
501
|
-
if (typeof
|
|
512
|
+
if (typeof y.d == "number")
|
|
502
513
|
throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");
|
|
503
|
-
return
|
|
514
|
+
return y.d;
|
|
515
|
+
// delete -> insert
|
|
504
516
|
case "string":
|
|
505
|
-
return { d:
|
|
517
|
+
return { d: y };
|
|
518
|
+
// Insert -> delete
|
|
506
519
|
case "number":
|
|
507
|
-
return
|
|
520
|
+
return y;
|
|
508
521
|
}
|
|
509
522
|
});
|
|
510
523
|
}
|
|
511
|
-
function
|
|
512
|
-
return
|
|
524
|
+
function Ce(f) {
|
|
525
|
+
return r(f, (y) => typeof y == "object" && typeof y.d == "string" ? { d: e.strPosToUni(y.d) } : y);
|
|
513
526
|
}
|
|
514
|
-
function
|
|
515
|
-
let
|
|
516
|
-
return
|
|
517
|
-
typeof
|
|
518
|
-
}),
|
|
527
|
+
function Ge(f) {
|
|
528
|
+
let y = !0;
|
|
529
|
+
return t(f, (b) => {
|
|
530
|
+
typeof b == "object" && typeof b.d == "number" && (y = !1);
|
|
531
|
+
}), y;
|
|
519
532
|
}
|
|
520
533
|
function ve(f) {
|
|
521
534
|
return {
|
|
522
535
|
name: "text-unicode",
|
|
523
536
|
uri: "http://sharejs.org/types/text-unicode",
|
|
524
|
-
trim:
|
|
525
|
-
normalize:
|
|
526
|
-
checkOp:
|
|
537
|
+
trim: s,
|
|
538
|
+
normalize: o,
|
|
539
|
+
checkOp: n,
|
|
527
540
|
/** Create a new text snapshot.
|
|
528
541
|
*
|
|
529
542
|
* @param {string} initial - initial snapshot data. Optional. Defaults to ''.
|
|
530
543
|
* @returns {Snap} Initial document snapshot object
|
|
531
544
|
*/
|
|
532
|
-
create(
|
|
533
|
-
if (typeof
|
|
545
|
+
create(y = "") {
|
|
546
|
+
if (typeof y != "string")
|
|
534
547
|
throw Error("Initial data must be a string");
|
|
535
|
-
return f.create(
|
|
548
|
+
return f.create(y);
|
|
536
549
|
},
|
|
537
550
|
/** Apply an operation to a document snapshot
|
|
538
551
|
*/
|
|
539
|
-
apply(
|
|
540
|
-
|
|
541
|
-
const L = f.builder(
|
|
542
|
-
for (let z = 0; z <
|
|
543
|
-
const
|
|
544
|
-
switch (typeof
|
|
552
|
+
apply(y, b) {
|
|
553
|
+
n(b);
|
|
554
|
+
const L = f.builder(y);
|
|
555
|
+
for (let z = 0; z < b.length; z++) {
|
|
556
|
+
const q = b[z];
|
|
557
|
+
switch (typeof q) {
|
|
545
558
|
case "number":
|
|
546
|
-
L.skip(
|
|
559
|
+
L.skip(q);
|
|
547
560
|
break;
|
|
548
561
|
case "string":
|
|
549
|
-
L.append(
|
|
562
|
+
L.append(q);
|
|
550
563
|
break;
|
|
551
564
|
case "object":
|
|
552
|
-
L.del(
|
|
565
|
+
L.del(a.dlen(q.d));
|
|
553
566
|
break;
|
|
554
567
|
}
|
|
555
568
|
}
|
|
@@ -557,58 +570,58 @@ function at() {
|
|
|
557
570
|
},
|
|
558
571
|
transform: c,
|
|
559
572
|
compose: h,
|
|
560
|
-
transformPosition:
|
|
561
|
-
transformSelection:
|
|
562
|
-
isInvertible:
|
|
563
|
-
makeInvertible(
|
|
564
|
-
return pe(
|
|
573
|
+
transformPosition: S,
|
|
574
|
+
transformSelection: Y,
|
|
575
|
+
isInvertible: Ge,
|
|
576
|
+
makeInvertible(y, b) {
|
|
577
|
+
return pe(y, b, f);
|
|
565
578
|
},
|
|
566
|
-
stripInvertible:
|
|
567
|
-
invert:
|
|
568
|
-
invertWithDoc(
|
|
569
|
-
return
|
|
579
|
+
stripInvertible: Ce,
|
|
580
|
+
invert: Z,
|
|
581
|
+
invertWithDoc(y, b) {
|
|
582
|
+
return Z(pe(y, b, f));
|
|
570
583
|
},
|
|
571
|
-
isNoop: (
|
|
584
|
+
isNoop: (y) => y.length === 0
|
|
572
585
|
};
|
|
573
586
|
}
|
|
574
|
-
|
|
575
|
-
}(
|
|
587
|
+
a.default = ve;
|
|
588
|
+
}(ct)), ct;
|
|
576
589
|
}
|
|
577
|
-
var
|
|
578
|
-
function
|
|
579
|
-
if (
|
|
580
|
-
|
|
581
|
-
const
|
|
582
|
-
function t
|
|
590
|
+
var rt = {}, Ct;
|
|
591
|
+
function Jt() {
|
|
592
|
+
if (Ct) return rt;
|
|
593
|
+
Ct = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
|
|
594
|
+
const a = ft(), e = ht();
|
|
595
|
+
function n(t, r) {
|
|
583
596
|
return {
|
|
584
597
|
// Returns the text content of the document
|
|
585
|
-
get:
|
|
598
|
+
get: t,
|
|
586
599
|
// Returns the number of characters in the string
|
|
587
600
|
getLength() {
|
|
588
|
-
return
|
|
601
|
+
return t().length;
|
|
589
602
|
},
|
|
590
603
|
// Insert the specified text at the given position in the document
|
|
591
|
-
insert(
|
|
592
|
-
const E = e.strPosToUni(
|
|
593
|
-
return
|
|
604
|
+
insert(u, o, l) {
|
|
605
|
+
const E = e.strPosToUni(t(), u);
|
|
606
|
+
return r([E, o], l);
|
|
594
607
|
},
|
|
595
|
-
remove(
|
|
596
|
-
const E = e.strPosToUni(
|
|
597
|
-
return
|
|
608
|
+
remove(u, o, l) {
|
|
609
|
+
const E = e.strPosToUni(t(), u);
|
|
610
|
+
return r([E, { d: o }], l);
|
|
598
611
|
},
|
|
599
612
|
// When you use this API, you should implement these two methods
|
|
600
613
|
// in your editing context.
|
|
601
614
|
//onInsert: function(pos, text) {},
|
|
602
615
|
//onRemove: function(pos, removedLength) {},
|
|
603
|
-
_onOp(
|
|
604
|
-
|
|
605
|
-
switch (typeof
|
|
616
|
+
_onOp(u) {
|
|
617
|
+
a.eachOp(u, (o, l, E) => {
|
|
618
|
+
switch (typeof o) {
|
|
606
619
|
case "string":
|
|
607
|
-
this.onInsert && this.onInsert(E,
|
|
620
|
+
this.onInsert && this.onInsert(E, o);
|
|
608
621
|
break;
|
|
609
622
|
case "object":
|
|
610
|
-
const
|
|
611
|
-
this.onRemove && this.onRemove(E,
|
|
623
|
+
const x = a.dlen(o.d);
|
|
624
|
+
this.onRemove && this.onRemove(E, x);
|
|
612
625
|
}
|
|
613
626
|
});
|
|
614
627
|
},
|
|
@@ -616,31 +629,31 @@ function Ht() {
|
|
|
616
629
|
onRemove: null
|
|
617
630
|
};
|
|
618
631
|
}
|
|
619
|
-
return
|
|
632
|
+
return rt.default = n, n.provides = { text: !0 }, rt;
|
|
620
633
|
}
|
|
621
|
-
var
|
|
622
|
-
function
|
|
623
|
-
return
|
|
624
|
-
var e =
|
|
625
|
-
|
|
626
|
-
return h[
|
|
634
|
+
var It;
|
|
635
|
+
function Yt() {
|
|
636
|
+
return It || (It = 1, function(a) {
|
|
637
|
+
var e = Se && Se.__createBinding || (Object.create ? function(c, h, S, Y) {
|
|
638
|
+
Y === void 0 && (Y = S), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
|
|
639
|
+
return h[S];
|
|
627
640
|
} });
|
|
628
|
-
} : function(c, h,
|
|
629
|
-
|
|
630
|
-
}),
|
|
641
|
+
} : function(c, h, S, Y) {
|
|
642
|
+
Y === void 0 && (Y = S), c[Y] = h[S];
|
|
643
|
+
}), n = Se && Se.__setModuleDefault || (Object.create ? function(c, h) {
|
|
631
644
|
Object.defineProperty(c, "default", { enumerable: !0, value: h });
|
|
632
645
|
} : function(c, h) {
|
|
633
646
|
c.default = h;
|
|
634
|
-
}),
|
|
647
|
+
}), t = Se && Se.__importStar || function(c) {
|
|
635
648
|
if (c && c.__esModule) return c;
|
|
636
649
|
var h = {};
|
|
637
|
-
if (c != null) for (var
|
|
638
|
-
return
|
|
639
|
-
},
|
|
650
|
+
if (c != null) for (var S in c) Object.hasOwnProperty.call(c, S) && e(h, c, S);
|
|
651
|
+
return n(h, c), h;
|
|
652
|
+
}, r = Se && Se.__importDefault || function(c) {
|
|
640
653
|
return c && c.__esModule ? c : { default: c };
|
|
641
654
|
};
|
|
642
|
-
Object.defineProperty(
|
|
643
|
-
const
|
|
655
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0;
|
|
656
|
+
const u = ht(), o = t(ft()), l = r(Jt()), E = {
|
|
644
657
|
create(c) {
|
|
645
658
|
return c;
|
|
646
659
|
},
|
|
@@ -652,854 +665,861 @@ function Kt() {
|
|
|
652
665
|
throw Error("Invalid document snapshot: " + c);
|
|
653
666
|
const h = [];
|
|
654
667
|
return {
|
|
655
|
-
skip(
|
|
656
|
-
let
|
|
657
|
-
if (
|
|
668
|
+
skip(S) {
|
|
669
|
+
let Y = u.uniToStrPos(c, S);
|
|
670
|
+
if (Y > c.length)
|
|
658
671
|
throw Error("The op is too long for this document");
|
|
659
|
-
h.push(c.slice(0,
|
|
672
|
+
h.push(c.slice(0, Y)), c = c.slice(Y);
|
|
660
673
|
},
|
|
661
|
-
append(
|
|
662
|
-
h.push(
|
|
674
|
+
append(S) {
|
|
675
|
+
h.push(S);
|
|
663
676
|
},
|
|
664
|
-
del(
|
|
665
|
-
c = c.slice(
|
|
677
|
+
del(S) {
|
|
678
|
+
c = c.slice(u.uniToStrPos(c, S));
|
|
666
679
|
},
|
|
667
680
|
build() {
|
|
668
681
|
return h.join("") + c;
|
|
669
682
|
}
|
|
670
683
|
};
|
|
671
684
|
},
|
|
672
|
-
slice:
|
|
673
|
-
},
|
|
674
|
-
|
|
675
|
-
var
|
|
676
|
-
Object.defineProperty(
|
|
677
|
-
return
|
|
685
|
+
slice: o.uniSlice
|
|
686
|
+
}, x = o.default(E), _ = Object.assign(Object.assign({}, x), { api: l.default });
|
|
687
|
+
a.type = _, a.insert = (c, h) => h.length === 0 ? [] : c === 0 ? [h] : [c, h], a.remove = (c, h) => o.dlen(h) === 0 ? [] : c === 0 ? [{ d: h }] : [c, { d: h }];
|
|
688
|
+
var s = ft();
|
|
689
|
+
Object.defineProperty(a, "makeType", { enumerable: !0, get: function() {
|
|
690
|
+
return s.default;
|
|
678
691
|
} });
|
|
679
|
-
}(
|
|
692
|
+
}(Se)), Se;
|
|
680
693
|
}
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
694
|
+
var Et;
|
|
695
|
+
function Zt() {
|
|
696
|
+
return Et || (Et = 1, function(a) {
|
|
697
|
+
var e = Ze && Ze.__importDefault || function(i) {
|
|
698
|
+
return i && i.__esModule ? i : {
|
|
699
|
+
default: i
|
|
700
|
+
};
|
|
685
701
|
};
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
702
|
+
Object.defineProperty(a, "__esModule", {
|
|
703
|
+
value: !0
|
|
704
|
+
}), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0;
|
|
705
|
+
const n = e(zt()), t = e(Xt()), r = At(), u = Mt();
|
|
706
|
+
function o(i, d) {
|
|
707
|
+
if (!i) throw new Error(d);
|
|
708
|
+
}
|
|
709
|
+
a.type = {
|
|
710
|
+
name: "json1",
|
|
711
|
+
uri: "http://sharejs.org/types/JSONv1",
|
|
712
|
+
readCursor: r.readCursor,
|
|
713
|
+
writeCursor: r.writeCursor,
|
|
714
|
+
create: (i) => i,
|
|
715
|
+
isNoop: (i) => i == null,
|
|
716
|
+
setDebug(i) {
|
|
717
|
+
},
|
|
718
|
+
registerSubtype: Z,
|
|
719
|
+
checkValidOp: z,
|
|
720
|
+
normalize: q,
|
|
721
|
+
apply: Ee,
|
|
722
|
+
transformPosition: ce,
|
|
723
|
+
compose: ne,
|
|
724
|
+
tryTransform: st,
|
|
725
|
+
transform: kt,
|
|
726
|
+
makeInvertible: De,
|
|
727
|
+
invert: le,
|
|
728
|
+
invertWithDoc: Ut,
|
|
729
|
+
RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
730
|
+
DROP_COLLISION: u.ConflictType.DROP_COLLISION,
|
|
731
|
+
BLACKHOLE: u.ConflictType.BLACKHOLE,
|
|
732
|
+
transformNoConflict: (i, d, m) => gt(() => !0, i, d, m),
|
|
733
|
+
typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), {
|
|
734
|
+
transform: (d, m, D) => gt(i, d, m, D)
|
|
735
|
+
})
|
|
736
|
+
};
|
|
737
|
+
const l = (i) => i ? i.getComponent() : null;
|
|
738
|
+
function E(i) {
|
|
739
|
+
return i && typeof i == "object" && !Array.isArray(i);
|
|
740
|
+
}
|
|
741
|
+
const x = (i) => Array.isArray(i) ? i.slice() : i !== null && typeof i == "object" ? Object.assign({}, i) : i, _ = (i) => i && (i.p != null || i.r !== void 0), s = (i) => i && (i.d != null || i.i !== void 0);
|
|
742
|
+
function c(i, d) {
|
|
743
|
+
return o(i != null), typeof d == "number" ? (o(Array.isArray(i), "Invalid key - child is not an array"), (i = i.slice()).splice(d, 1)) : (o(E(i), "Invalid key - child is not an object"), delete (i = Object.assign({}, i))[d]), i;
|
|
744
|
+
}
|
|
745
|
+
function h(i, d, m) {
|
|
746
|
+
return typeof d == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= d, "Cannot insert into out of bounds index"), i.splice(d, 0, m)) : (o(E(i), "Cannot insert into missing item"), o(i[d] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[d] = m), m;
|
|
747
|
+
}
|
|
748
|
+
a.removeOp = (i, d = !0) => r.writeCursor().writeAtPath(i, "r", d).get(), a.moveOp = (i, d) => r.writeCursor().writeMove(i, d).get(), a.insertOp = (i, d) => r.writeCursor().writeAtPath(i, "i", d).get(), a.replaceOp = (i, d, m) => r.writeCursor().at(i, (D) => {
|
|
749
|
+
D.write("r", d), D.write("i", m);
|
|
750
|
+
}).get(), a.editOp = (i, d, m, D = !1) => r.writeCursor().at(i, (O) => y(O, d, m, D)).get();
|
|
751
|
+
const S = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => S(i, d) ? i[d] : void 0, pe = {};
|
|
752
|
+
function Z(i) {
|
|
753
|
+
let d = i.type ? i.type : i;
|
|
754
|
+
d.name && (pe[d.name] = d), d.uri && (pe[d.uri] = d);
|
|
755
|
+
}
|
|
756
|
+
const Ce = (i) => {
|
|
757
|
+
const d = pe[i];
|
|
758
|
+
if (d) return d;
|
|
759
|
+
throw Error("Missing type: " + i);
|
|
760
|
+
};
|
|
761
|
+
Z(Yt());
|
|
762
|
+
const Ge = (i, d) => i + d;
|
|
763
|
+
Z({
|
|
764
|
+
name: "number",
|
|
765
|
+
apply: Ge,
|
|
766
|
+
compose: Ge,
|
|
767
|
+
invert: (i) => -i,
|
|
768
|
+
transform: (i) => i
|
|
769
|
+
});
|
|
770
|
+
const ve = (i) => i == null ? null : i.et ? Ce(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, d, m, D = !1) => {
|
|
771
|
+
const [O, I] = typeof d == "string" ? [Ce(d), d] : [d, d.name];
|
|
772
|
+
!D && O.isNoop && O.isNoop(m) || (I === "number" ? i.write("ena", m) : I === "text-unicode" ? i.write("es", m) : (i.write("et", I), i.write("e", m)));
|
|
773
|
+
};
|
|
774
|
+
function b(i) {
|
|
775
|
+
o(typeof i == "number"), o(i >= 0), o(i === (0 | i));
|
|
776
|
+
}
|
|
777
|
+
function L(i) {
|
|
778
|
+
typeof i == "number" ? b(i) : o(typeof i == "string");
|
|
779
|
+
}
|
|
780
|
+
function z(i) {
|
|
781
|
+
if (i === null) return;
|
|
782
|
+
const d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), D = (I) => {
|
|
783
|
+
let R = !0, $ = !1;
|
|
784
|
+
for (let p in I) {
|
|
785
|
+
const v = I[p];
|
|
786
|
+
if (R = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") b(v), o(!d.has(v)), d.add(v), o(I.r === void 0);
|
|
787
|
+
else if (p === "d") b(v), o(!m.has(v)), m.add(v), o(I.i === void 0);
|
|
788
|
+
else if (p === "e" || p === "es" || p === "ena") {
|
|
789
|
+
o(!$), $ = !0;
|
|
790
|
+
const w = ve(I);
|
|
791
|
+
o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(I));
|
|
792
|
+
}
|
|
777
793
|
}
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
794
|
+
o(!R);
|
|
795
|
+
}, O = (I, R, $) => {
|
|
796
|
+
if (!Array.isArray(I)) throw Error("Op must be null or a list");
|
|
797
|
+
if (I.length === 0) throw Error("Empty descent");
|
|
798
|
+
R || L(I[0]);
|
|
799
|
+
let p = 1, v = 0, w = 0;
|
|
800
|
+
for (let C = 0; C < I.length; C++) {
|
|
801
|
+
const N = I[C];
|
|
802
|
+
if (o(N != null), Array.isArray(N)) {
|
|
803
|
+
const B = O(N, !1);
|
|
804
|
+
if (v) {
|
|
805
|
+
const g = typeof w, U = typeof B;
|
|
806
|
+
g === U ? o(w < B, "descent keys are not in order") : o(g === "number" && U === "string");
|
|
807
|
+
}
|
|
808
|
+
w = B, v++, p = 3;
|
|
809
|
+
} else typeof N == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(N), p = 2) : (o(p !== 3), L(N), o(r.isValidPathItem(N), "Invalid path key"), p = 1);
|
|
810
|
+
}
|
|
811
|
+
return o(v !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0];
|
|
812
|
+
};
|
|
813
|
+
O(i, !0), o(d.size === m.size, "Mismatched picks and drops in op");
|
|
814
|
+
for (let I = 0; I < d.size; I++) o(d.has(I)), o(m.has(I));
|
|
815
|
+
}
|
|
816
|
+
function q(i) {
|
|
817
|
+
let d = 0, m = [];
|
|
818
|
+
const D = r.writeCursor();
|
|
819
|
+
return D.mergeTree(i, (O, I) => {
|
|
820
|
+
const R = ve(O);
|
|
821
|
+
if (R) {
|
|
822
|
+
const p = f(O);
|
|
823
|
+
y(I, R, R.normalize ? R.normalize(p) : p);
|
|
824
|
+
}
|
|
825
|
+
for (const p of ["r", "p", "i", "d"]) if (O[p] !== void 0) {
|
|
826
|
+
const v = p === "p" || p === "d" ? ($ = O[p], m[$] == null && (m[$] = d++), m[$]) : O[p];
|
|
827
|
+
I.write(p, v);
|
|
828
|
+
}
|
|
829
|
+
var $;
|
|
830
|
+
}), D.get();
|
|
831
|
+
}
|
|
832
|
+
function Ee(i, d) {
|
|
833
|
+
if (z(d), d === null) return i;
|
|
834
|
+
const m = [];
|
|
835
|
+
return function D(O, I) {
|
|
836
|
+
let R = O, $ = 0, p = {
|
|
837
|
+
root: O
|
|
838
|
+
}, v = 0, w = p, C = "root";
|
|
839
|
+
function N() {
|
|
840
|
+
for (; v < $; v++) {
|
|
841
|
+
let B = I[v];
|
|
842
|
+
typeof B != "object" && (o(S(w, C)), w = w[C] = x(w[C]), C = B);
|
|
792
843
|
}
|
|
793
|
-
b = G, v++, p = 3;
|
|
794
|
-
} else typeof T == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`), D(T), p = 2) : (l(p !== 3), L(T), l(s.isValidPathItem(T), "Invalid path key"), p = 1);
|
|
795
|
-
}
|
|
796
|
-
return l(v !== 1, "Operation makes multiple descents. Remove some []"), l(p === 2 || p === 3), C[0];
|
|
797
|
-
};
|
|
798
|
-
m(r, !0), l(u.size === y.size, "Mismatched picks and drops in op");
|
|
799
|
-
for (let C = 0; C < u.size; C++) l(u.has(C)), l(y.has(C));
|
|
800
|
-
}
|
|
801
|
-
function H(r) {
|
|
802
|
-
let u = 0, y = [];
|
|
803
|
-
const D = s.writeCursor();
|
|
804
|
-
return D.mergeTree(r, (m, C) => {
|
|
805
|
-
const $ = ve(m);
|
|
806
|
-
if ($) {
|
|
807
|
-
const p = f(m);
|
|
808
|
-
_(C, $, $.normalize ? $.normalize(p) : p);
|
|
809
|
-
}
|
|
810
|
-
for (const p of ["r", "p", "i", "d"]) if (m[p] !== void 0) {
|
|
811
|
-
const v = p === "p" || p === "d" ? (j = m[p], y[j] == null && (y[j] = u++), y[j]) : m[p];
|
|
812
|
-
C.write(p, v);
|
|
813
|
-
}
|
|
814
|
-
var j;
|
|
815
|
-
}), D.get();
|
|
816
|
-
}
|
|
817
|
-
function De(r, u) {
|
|
818
|
-
if (z(u), u === null) return r;
|
|
819
|
-
const y = [];
|
|
820
|
-
return function D(m, C) {
|
|
821
|
-
let $ = m, j = 0, p = {
|
|
822
|
-
root: m
|
|
823
|
-
}, v = 0, b = p, I = "root";
|
|
824
|
-
function T() {
|
|
825
|
-
for (; v < j; v++) {
|
|
826
|
-
let G = C[v];
|
|
827
|
-
typeof G != "object" && (l(k(b, I)), b = b[I] = W(b[I]), I = G);
|
|
828
844
|
}
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
else
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
}
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
}(r, u), u);
|
|
862
|
-
}
|
|
863
|
-
function ue(r, u) {
|
|
864
|
-
r = r.slice(), z(u);
|
|
865
|
-
const y = s.readCursor(u);
|
|
866
|
-
let D, m, C = !1;
|
|
867
|
-
const $ = [];
|
|
868
|
-
for (let p = 0; ; p++) {
|
|
869
|
-
const v = r[p], b = y.getComponent();
|
|
870
|
-
if (b && (b.r !== void 0 ? C = !0 : b.p != null && (C = !1, D = b.p, m = p)), p >= r.length) break;
|
|
871
|
-
let I = 0;
|
|
872
|
-
const T = s.advancer(y, void 0, (g, N) => {
|
|
873
|
-
O(N) && I++;
|
|
874
|
-
});
|
|
875
|
-
$.unshift(T);
|
|
876
|
-
const G = T(v);
|
|
877
|
-
if (typeof v == "number" && (r[p] -= I), !G) break;
|
|
845
|
+
for (; $ < I.length; $++) {
|
|
846
|
+
const B = I[$];
|
|
847
|
+
if (Array.isArray(B)) {
|
|
848
|
+
const g = D(R, B);
|
|
849
|
+
g !== R && g !== void 0 && (N(), R = w[C] = g);
|
|
850
|
+
} else if (typeof B == "object") {
|
|
851
|
+
B.d != null ? (N(), R = h(w, C, m[B.d])) : B.i !== void 0 && (N(), R = h(w, C, B.i));
|
|
852
|
+
const g = ve(B);
|
|
853
|
+
if (g) N(), R = w[C] = g.apply(R, f(B));
|
|
854
|
+
else if (B.e !== void 0) throw Error("Subtype " + B.et + " undefined");
|
|
855
|
+
} else R = Y(R, B);
|
|
856
|
+
}
|
|
857
|
+
return p.root;
|
|
858
|
+
}(i = function D(O, I) {
|
|
859
|
+
const R = [];
|
|
860
|
+
let $ = 0;
|
|
861
|
+
for (; $ < I.length; $++) {
|
|
862
|
+
const C = I[$];
|
|
863
|
+
if (Array.isArray(C)) break;
|
|
864
|
+
typeof C != "object" && (R.push(O), O = Y(O, C));
|
|
865
|
+
}
|
|
866
|
+
for (let C = I.length - 1; C >= $; C--) O = D(O, I[C]);
|
|
867
|
+
for (--$; $ >= 0; $--) {
|
|
868
|
+
const C = I[$];
|
|
869
|
+
if (typeof C != "object") {
|
|
870
|
+
const N = R.pop();
|
|
871
|
+
O = O === Y(N, C) ? N : O === void 0 ? c(N, C) : (v = C, w = O, (p = x(p = N))[v] = w, p);
|
|
872
|
+
} else _(C) && (o(O !== void 0, "Cannot pick up or remove undefined"), C.p != null && (m[C.p] = O), O = void 0);
|
|
873
|
+
}
|
|
874
|
+
var p, v, w;
|
|
875
|
+
return O;
|
|
876
|
+
}(i, d), d);
|
|
878
877
|
}
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
878
|
+
function ce(i, d) {
|
|
879
|
+
i = i.slice(), z(d);
|
|
880
|
+
const m = r.readCursor(d);
|
|
881
|
+
let D, O, I = !1;
|
|
882
|
+
const R = [];
|
|
883
|
+
for (let p = 0; ; p++) {
|
|
884
|
+
const v = i[p], w = m.getComponent();
|
|
885
|
+
if (w && (w.r !== void 0 ? I = !0 : w.p != null && (I = !1, D = w.p, O = p)), p >= i.length) break;
|
|
886
|
+
let C = 0;
|
|
887
|
+
const N = r.advancer(m, void 0, (g, U) => {
|
|
888
|
+
_(U) && C++;
|
|
889
|
+
});
|
|
890
|
+
R.unshift(N);
|
|
891
|
+
const B = N(v);
|
|
892
|
+
if (typeof v == "number" && (i[p] -= C), !B) break;
|
|
885
893
|
}
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
894
|
+
if (R.forEach((p) => p.end()), I) return null;
|
|
895
|
+
const $ = () => {
|
|
896
|
+
let p = 0;
|
|
897
|
+
if (D != null) {
|
|
898
|
+
const v = m.getPath();
|
|
899
|
+
p = v.length, i = v.concat(i.slice(O));
|
|
892
900
|
}
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (z(r), z(u), r == null) return u;
|
|
906
|
-
if (u == null) return r;
|
|
907
|
-
let y = 0;
|
|
908
|
-
const D = s.readCursor(r), m = s.readCursor(u), C = s.writeCursor(), $ = [], j = [], p = [], v = [], b = [], I = [], T = /* @__PURE__ */ new Set();
|
|
909
|
-
D.traverse(null, (g) => {
|
|
910
|
-
g.p != null && (p[g.p] = D.clone());
|
|
911
|
-
}), m.traverse(null, (g) => {
|
|
912
|
-
g.d != null && (v[g.d] = m.clone());
|
|
913
|
-
});
|
|
914
|
-
const G = s.writeCursor();
|
|
915
|
-
return function g(N, re, te, K, se, Te, me, _e) {
|
|
916
|
-
l(re || te);
|
|
917
|
-
const oe = a(re), Pe = a(te), Me = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Ue = oe ? oe.d : null, Ee = Pe ? Pe.p : null, $e = (Te || Me) && Ee == null;
|
|
918
|
-
if (Ee != null) K = v[Ee], me = j[Ee] = new s.WriteCursor();
|
|
919
|
-
else if (Pe && Pe.r !== void 0) K = null;
|
|
920
|
-
else {
|
|
921
|
-
const P = a(K);
|
|
922
|
-
P && P.d != null && (K = null);
|
|
923
|
-
}
|
|
924
|
-
const Q = a(K);
|
|
925
|
-
if (Ue != null) if (N = p[Ue], _e = $[Ue] = new s.WriteCursor(), $e) Te && !Me && _e.write("r", !0);
|
|
926
|
-
else {
|
|
927
|
-
const P = b[Ue] = y++;
|
|
928
|
-
me.write("d", P);
|
|
929
|
-
}
|
|
930
|
-
else if (oe && oe.i !== void 0) N = null;
|
|
931
|
-
else {
|
|
932
|
-
const P = a(N);
|
|
933
|
-
P && P.p != null && (N = null);
|
|
934
|
-
}
|
|
935
|
-
let U;
|
|
936
|
-
Le ? (l(se === void 0), U = oe.i) : U = se;
|
|
937
|
-
const B = (Ee == null ? !Le || Te || Me : U === void 0) ? null : me.getComponent();
|
|
938
|
-
if (Ee != null) {
|
|
939
|
-
if (!(se !== void 0 || Le)) {
|
|
940
|
-
const P = Ue != null ? b[Ue] : y++;
|
|
941
|
-
I[Ee] = P, _e.write("p", P);
|
|
901
|
+
for (; p < i.length; p++) {
|
|
902
|
+
const v = i[p], w = l(m), C = ve(w);
|
|
903
|
+
if (C) {
|
|
904
|
+
const g = f(w);
|
|
905
|
+
C.transformPosition && (i[p] = C.transformPosition(i[p], g));
|
|
906
|
+
break;
|
|
907
|
+
}
|
|
908
|
+
let N = 0;
|
|
909
|
+
const B = r.advancer(m, (g, U) => s(U) ? ~(g - N) : g - N, (g, U) => {
|
|
910
|
+
s(U) && N++;
|
|
911
|
+
})(v);
|
|
912
|
+
if (typeof v == "number" && (i[p] += N), !B) break;
|
|
942
913
|
}
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
let
|
|
952
|
-
const
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
914
|
+
};
|
|
915
|
+
return D != null ? m.eachDrop(null, (p) => {
|
|
916
|
+
p === D && $();
|
|
917
|
+
}) : $(), i;
|
|
918
|
+
}
|
|
919
|
+
function ne(i, d) {
|
|
920
|
+
if (z(i), z(d), i == null) return d;
|
|
921
|
+
if (d == null) return i;
|
|
922
|
+
let m = 0;
|
|
923
|
+
const D = r.readCursor(i), O = r.readCursor(d), I = r.writeCursor(), R = [], $ = [], p = [], v = [], w = [], C = [], N = /* @__PURE__ */ new Set();
|
|
924
|
+
D.traverse(null, (g) => {
|
|
925
|
+
g.p != null && (p[g.p] = D.clone());
|
|
926
|
+
}), O.traverse(null, (g) => {
|
|
927
|
+
g.d != null && (v[g.d] = O.clone());
|
|
956
928
|
});
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
} else be = q(P), We = ye(P);
|
|
967
|
-
_e.descend(He), me.descend(Ne);
|
|
968
|
-
const ze = R && !o(a(x)) ? U[Ye] : void 0, Se = g(be, x, he, We, ze, $e, me, _e);
|
|
969
|
-
var je, S, ie;
|
|
970
|
-
R && !$e ? ze !== Se && (X || (U = Array.isArray(U) ? U.slice() : Object.assign({}, U), X = !0), je = U, ie = Se, typeof (S = Ye) == "number" ? (l(Array.isArray(je)), l(S < je.length)) : (l(!Array.isArray(je)), l(je[S] !== void 0)), ie === void 0 ? typeof S == "number" ? je.splice(S, 1) : delete je[S] : je[S] = ie) : l(Se === void 0), me.ascend(), _e.ascend();
|
|
971
|
-
}), q.end(), ye.end(), B != null) B.i = U;
|
|
972
|
-
else if (!Te && !Me && Ee == null) return U;
|
|
973
|
-
}(D, D.clone(), m, m.clone(), void 0, !1, C, G), C.reset(), C.mergeTree(G.get()), C.reset(), C.get(), $.map((g) => g.get()), j.map((g) => g.get()), D.traverse(C, (g, N) => {
|
|
974
|
-
const re = g.p;
|
|
975
|
-
if (re != null) {
|
|
976
|
-
const te = b[re];
|
|
977
|
-
te != null && N.write("p", te);
|
|
978
|
-
const K = $[re];
|
|
979
|
-
K && K.get(), K && N.mergeTree(K.get());
|
|
980
|
-
} else g.r !== void 0 && N.write("r", g.r);
|
|
981
|
-
}), C.reset(), C.get(), m.traverse(C, (g, N) => {
|
|
982
|
-
const re = g.d;
|
|
983
|
-
if (re != null) {
|
|
984
|
-
const K = I[re];
|
|
985
|
-
K != null && N.write("d", K);
|
|
986
|
-
const se = j[re];
|
|
987
|
-
se && N.mergeTree(se.get());
|
|
988
|
-
} else g.i !== void 0 && N.write("i", g.i);
|
|
989
|
-
const te = ve(g);
|
|
990
|
-
te && !T.has(g) && _(N, te, f(g));
|
|
991
|
-
}), C.get();
|
|
992
|
-
}
|
|
993
|
-
function ae(r) {
|
|
994
|
-
if (r == null) return null;
|
|
995
|
-
const u = new s.ReadCursor(r), y = new s.WriteCursor();
|
|
996
|
-
let D;
|
|
997
|
-
const m = [], C = [];
|
|
998
|
-
return function $(j, p, v) {
|
|
999
|
-
const b = j.getComponent();
|
|
1000
|
-
let I, T = !1;
|
|
1001
|
-
if (b) {
|
|
1002
|
-
b.p != null && (p.write("d", b.p), m[b.p] = j.clone()), b.r !== void 0 && p.write("i", b.r), b.d != null && (p.write("p", b.d), v = void 0), b.i !== void 0 && (v = I = b.i);
|
|
1003
|
-
const g = ve(b);
|
|
1004
|
-
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(b)) : (f(b), v = g.apply(v, f(b)), T = !0));
|
|
1005
|
-
}
|
|
1006
|
-
let G = 0;
|
|
1007
|
-
for (const g of j) {
|
|
1008
|
-
p.descend(g);
|
|
1009
|
-
const N = typeof g == "number" ? g - G : g, re = Z(v, N);
|
|
1010
|
-
o(j.getComponent()) && G++;
|
|
1011
|
-
const te = $(j, p, re);
|
|
1012
|
-
if (v !== void 0 && te !== void 0) {
|
|
1013
|
-
if (T || (T = !0, v = W(v)), !k(v, N)) throw Error("Cannot modify child - invalid operation");
|
|
1014
|
-
v[N] = te;
|
|
929
|
+
const B = r.writeCursor();
|
|
930
|
+
return function g(U, re, te, K, se, Ne, Oe, ye) {
|
|
931
|
+
o(re || te);
|
|
932
|
+
const oe = l(re), Pe = l(te), Ae = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ie = Pe ? Pe.p : null, Re = (Ne || Ae) && Ie == null;
|
|
933
|
+
if (Ie != null) K = v[Ie], Oe = $[Ie] = new r.WriteCursor();
|
|
934
|
+
else if (Pe && Pe.r !== void 0) K = null;
|
|
935
|
+
else {
|
|
936
|
+
const T = l(K);
|
|
937
|
+
T && T.d != null && (K = null);
|
|
1015
938
|
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
const b = p.getComponent();
|
|
1022
|
-
if (b) {
|
|
1023
|
-
const g = b.d;
|
|
1024
|
-
if (g != null && (j = m[g], v = C[g] = s.writeCursor()), D.has(b)) {
|
|
1025
|
-
const N = ve(b);
|
|
1026
|
-
if (!N.invert) throw Error(`Cannot invert subtype ${N.name}`);
|
|
1027
|
-
_(v, N, N.invert(f(b)));
|
|
939
|
+
const Q = l(K);
|
|
940
|
+
if (Te != null) if (U = p[Te], ye = R[Te] = new r.WriteCursor(), Re) Ne && !Ae && ye.write("r", !0);
|
|
941
|
+
else {
|
|
942
|
+
const T = w[Te] = m++;
|
|
943
|
+
Oe.write("d", T);
|
|
1028
944
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
});
|
|
1034
|
-
for (const g of p) if (typeof g == "number") {
|
|
1035
|
-
const N = g - T, re = G(N), te = N + I;
|
|
1036
|
-
v.descend(te), $(re, p, v), o(p.getComponent()) && T++, v.ascend();
|
|
1037
|
-
} else v.descend(g), $(G(g), p, v), v.ascend();
|
|
1038
|
-
G.end();
|
|
1039
|
-
}(u.clone(), u, y), C.length && (y.reset(), u.traverse(y, ($, j) => {
|
|
1040
|
-
const p = $.p;
|
|
1041
|
-
if (p != null) {
|
|
1042
|
-
const v = C[p];
|
|
1043
|
-
v && v.get(), v && j.mergeTree(v.get());
|
|
1044
|
-
}
|
|
1045
|
-
}))), y.get();
|
|
1046
|
-
}
|
|
1047
|
-
const ge = (r, u) => r.some((y) => typeof y == "object" && (Array.isArray(y) ? ge(y, u) : u(y)));
|
|
1048
|
-
function Ae(r, u) {
|
|
1049
|
-
if (r == null || !ge(r, (p) => {
|
|
1050
|
-
var v;
|
|
1051
|
-
return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
|
|
1052
|
-
})) return r;
|
|
1053
|
-
const y = new s.ReadCursor(r), D = new s.WriteCursor();
|
|
1054
|
-
let m = !1;
|
|
1055
|
-
const C = [], $ = [], j = (p, v, b) => {
|
|
1056
|
-
const I = p.getComponent();
|
|
1057
|
-
let T = !1;
|
|
1058
|
-
if (I) {
|
|
1059
|
-
I.d != null && v.write("d", I.d), I.i !== void 0 && v.write("i", I.i);
|
|
1060
|
-
const g = I.p;
|
|
1061
|
-
if (g != null && (C[g] = p.clone(), l(b !== void 0, "Operation picks up at an invalid key"), $[g] = b, v.write("p", I.p)), I.r !== void 0 && b === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
|
|
1062
|
-
const N = ve(I);
|
|
1063
|
-
N && (N.makeInvertible ? m = !0 : _(v, N, f(I), !0));
|
|
1064
|
-
}
|
|
1065
|
-
let G = 0;
|
|
1066
|
-
for (const g of p) {
|
|
1067
|
-
v.descend(g);
|
|
1068
|
-
const N = typeof g == "number" ? g - G : g, re = Z(b, N), te = j(p, v, re);
|
|
1069
|
-
re !== te && (T || (T = !0, b = W(b)), te === void 0 ? (b = c(b, N), typeof g == "number" && G++) : b[N] = te), v.ascend();
|
|
1070
|
-
}
|
|
1071
|
-
return I && (I.r !== void 0 ? (v.write("r", i.default(b)), b = void 0) : I.p != null && (b = void 0)), b;
|
|
1072
|
-
};
|
|
1073
|
-
return j(y, D, u), D.get(), m && (D.reset(), function p(v, b, I, T, G) {
|
|
1074
|
-
const g = b.getComponent();
|
|
1075
|
-
if (g) {
|
|
1076
|
-
g.i !== void 0 ? (T = g.i, G = !0) : g.d != null && (T = $[g.d], v = C[g.d], G = !1, g.d);
|
|
1077
|
-
let K = ve(g);
|
|
1078
|
-
if (K && K.makeInvertible) {
|
|
1079
|
-
const se = f(g);
|
|
1080
|
-
_(I, K, K.makeInvertible(se, T), !0);
|
|
945
|
+
else if (oe && oe.i !== void 0) U = null;
|
|
946
|
+
else {
|
|
947
|
+
const T = l(U);
|
|
948
|
+
T && T.p != null && (U = null);
|
|
1081
949
|
}
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
950
|
+
let A;
|
|
951
|
+
Le ? (o(se === void 0), A = oe.i) : A = se;
|
|
952
|
+
const W = (Ie == null ? !Le || Ne || Ae : A === void 0) ? null : Oe.getComponent();
|
|
953
|
+
if (Ie != null) {
|
|
954
|
+
if (!(se !== void 0 || Le)) {
|
|
955
|
+
const T = Te != null ? w[Te] : m++;
|
|
956
|
+
C[Ie] = T, ye.write("p", T);
|
|
957
|
+
}
|
|
958
|
+
} else Ae && (Le || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
|
|
959
|
+
const M = Re ? null : ve(oe), P = ve(Q);
|
|
960
|
+
if ((M || P) && (M && M.name, P && P.name), M && P) {
|
|
961
|
+
o(M === P);
|
|
962
|
+
const T = f(oe), G = f(Q), he = M.compose(T, G);
|
|
963
|
+
y(Oe, M, he), N.add(Q);
|
|
964
|
+
} else M ? y(Oe, M, f(oe)) : P && (y(Oe, P, f(Q)), N.add(Q));
|
|
965
|
+
const k = typeof A == "object" && A != null;
|
|
966
|
+
let X = !1, J = 0, ee = 0, fe = 0, de = 0, ae = 0;
|
|
967
|
+
const me = r.advancer(K, (T, G) => s(G) ? de - T - 1 : T - de, (T, G) => {
|
|
968
|
+
s(G) && de++;
|
|
969
|
+
}), H = r.advancer(U, (T, G) => _(G) ? J - T - 1 : T - J, (T, G) => {
|
|
970
|
+
_(G) && J++;
|
|
971
|
+
});
|
|
972
|
+
if (r.eachChildOf(re, te, (T, G, he) => {
|
|
973
|
+
let we, xe, qe = T, Me = T, Ye = T;
|
|
974
|
+
if (typeof T == "number") {
|
|
975
|
+
let _e = T + fe;
|
|
976
|
+
xe = me(_e), Me = _e + de;
|
|
977
|
+
let ue = T + ee;
|
|
978
|
+
we = H(ue), s(l(xe)) && (we = null), qe = ue + J, Ye = T + ae, o(qe >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative");
|
|
979
|
+
const Ue = s(l(G)), Be = _(l(he));
|
|
980
|
+
(Ue || Be && !Re) && ae--, Ue && ee--, Be && fe--;
|
|
981
|
+
} else we = H(T), xe = me(T);
|
|
982
|
+
ye.descend(qe), Oe.descend(Me);
|
|
983
|
+
const Xe = k && !s(l(G)) ? A[Ye] : void 0, je = g(we, G, he, xe, Xe, Re, Oe, ye);
|
|
984
|
+
var $e, j, ie;
|
|
985
|
+
k && !Re ? Xe !== je && (X || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), X = !0), $e = A, ie = je, typeof (j = Ye) == "number" ? (o(Array.isArray($e)), o(j < $e.length)) : (o(!Array.isArray($e)), o($e[j] !== void 0)), ie === void 0 ? typeof j == "number" ? $e.splice(j, 1) : delete $e[j] : $e[j] = ie) : o(je === void 0), Oe.ascend(), ye.ascend();
|
|
986
|
+
}), H.end(), me.end(), W != null) W.i = A;
|
|
987
|
+
else if (!Ne && !Ae && Ie == null) return A;
|
|
988
|
+
}(D, D.clone(), O, O.clone(), void 0, !1, I, B), I.reset(), I.mergeTree(B.get()), I.reset(), I.get(), R.map((g) => g.get()), $.map((g) => g.get()), D.traverse(I, (g, U) => {
|
|
989
|
+
const re = g.p;
|
|
990
|
+
if (re != null) {
|
|
991
|
+
const te = w[re];
|
|
992
|
+
te != null && U.write("p", te);
|
|
993
|
+
const K = R[re];
|
|
994
|
+
K && K.get(), K && U.mergeTree(K.get());
|
|
995
|
+
} else g.r !== void 0 && U.write("r", g.r);
|
|
996
|
+
}), I.reset(), I.get(), O.traverse(I, (g, U) => {
|
|
997
|
+
const re = g.d;
|
|
998
|
+
if (re != null) {
|
|
999
|
+
const K = C[re];
|
|
1000
|
+
K != null && U.write("d", K);
|
|
1001
|
+
const se = $[re];
|
|
1002
|
+
se && U.mergeTree(se.get());
|
|
1003
|
+
} else g.i !== void 0 && U.write("i", g.i);
|
|
1004
|
+
const te = ve(g);
|
|
1005
|
+
te && !N.has(g) && y(U, te, f(g));
|
|
1006
|
+
}), I.get();
|
|
1106
1007
|
}
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
}),
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1008
|
+
function le(i) {
|
|
1009
|
+
if (i == null) return null;
|
|
1010
|
+
const d = new r.ReadCursor(i), m = new r.WriteCursor();
|
|
1011
|
+
let D;
|
|
1012
|
+
const O = [], I = [];
|
|
1013
|
+
return function R($, p, v) {
|
|
1014
|
+
const w = $.getComponent();
|
|
1015
|
+
let C, N = !1;
|
|
1016
|
+
if (w) {
|
|
1017
|
+
w.p != null && (p.write("d", w.p), O[w.p] = $.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d), v = void 0), w.i !== void 0 && (v = C = w.i);
|
|
1018
|
+
const g = ve(w);
|
|
1019
|
+
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), v = g.apply(v, f(w)), N = !0));
|
|
1020
|
+
}
|
|
1021
|
+
let B = 0;
|
|
1022
|
+
for (const g of $) {
|
|
1023
|
+
p.descend(g);
|
|
1024
|
+
const U = typeof g == "number" ? g - B : g, re = Y(v, U);
|
|
1025
|
+
s($.getComponent()) && B++;
|
|
1026
|
+
const te = R($, p, re);
|
|
1027
|
+
if (v !== void 0 && te !== void 0) {
|
|
1028
|
+
if (N || (N = !0, v = x(v)), !S(v, U)) throw Error("Cannot modify child - invalid operation");
|
|
1029
|
+
v[U] = te;
|
|
1030
|
+
}
|
|
1031
|
+
p.ascend();
|
|
1032
|
+
}
|
|
1033
|
+
if (C === void 0) return N ? v : void 0;
|
|
1034
|
+
p.write("r", v);
|
|
1035
|
+
}(d, m, void 0), D && (m.reset(), function R($, p, v) {
|
|
1036
|
+
const w = p.getComponent();
|
|
1037
|
+
if (w) {
|
|
1038
|
+
const g = w.d;
|
|
1039
|
+
if (g != null && ($ = O[g], v = I[g] = r.writeCursor()), D.has(w)) {
|
|
1040
|
+
const U = ve(w);
|
|
1041
|
+
if (!U.invert) throw Error(`Cannot invert subtype ${U.name}`);
|
|
1042
|
+
y(v, U, U.invert(f(w)));
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
let C = 0, N = 0;
|
|
1046
|
+
const B = r.advancer($, (g, U) => _(U) ? C - g - 1 : g - C, (g, U) => {
|
|
1047
|
+
_(U) && C++;
|
|
1048
|
+
});
|
|
1049
|
+
for (const g of p) if (typeof g == "number") {
|
|
1050
|
+
const U = g - N, re = B(U), te = U + C;
|
|
1051
|
+
v.descend(te), R(re, p, v), s(p.getComponent()) && N++, v.ascend();
|
|
1052
|
+
} else v.descend(g), R(B(g), p, v), v.ascend();
|
|
1053
|
+
B.end();
|
|
1054
|
+
}(d.clone(), d, m), I.length && (m.reset(), d.traverse(m, (R, $) => {
|
|
1055
|
+
const p = R.p;
|
|
1056
|
+
if (p != null) {
|
|
1057
|
+
const v = I[p];
|
|
1058
|
+
v && v.get(), v && $.mergeTree(v.get());
|
|
1059
|
+
}
|
|
1060
|
+
}))), m.get();
|
|
1061
|
+
}
|
|
1062
|
+
const ge = (i, d) => i.some((m) => typeof m == "object" && (Array.isArray(m) ? ge(m, d) : d(m)));
|
|
1063
|
+
function De(i, d) {
|
|
1064
|
+
if (i == null || !ge(i, (p) => {
|
|
1065
|
+
var v;
|
|
1066
|
+
return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
|
|
1067
|
+
})) return i;
|
|
1068
|
+
const m = new r.ReadCursor(i), D = new r.WriteCursor();
|
|
1069
|
+
let O = !1;
|
|
1070
|
+
const I = [], R = [], $ = (p, v, w) => {
|
|
1071
|
+
const C = p.getComponent();
|
|
1072
|
+
let N = !1;
|
|
1073
|
+
if (C) {
|
|
1074
|
+
C.d != null && v.write("d", C.d), C.i !== void 0 && v.write("i", C.i);
|
|
1075
|
+
const g = C.p;
|
|
1076
|
+
if (g != null && (I[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), R[g] = w, v.write("p", C.p)), C.r !== void 0 && w === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
|
|
1077
|
+
const U = ve(C);
|
|
1078
|
+
U && (U.makeInvertible ? O = !0 : y(v, U, f(C), !0));
|
|
1079
|
+
}
|
|
1080
|
+
let B = 0;
|
|
1081
|
+
for (const g of p) {
|
|
1082
|
+
v.descend(g);
|
|
1083
|
+
const U = typeof g == "number" ? g - B : g, re = Y(w, U), te = $(p, v, re);
|
|
1084
|
+
re !== te && (N || (N = !0, w = x(w)), te === void 0 ? (w = c(w, U), typeof g == "number" && B++) : w[U] = te), v.ascend();
|
|
1085
|
+
}
|
|
1086
|
+
return C && (C.r !== void 0 ? (v.write("r", t.default(w)), w = void 0) : C.p != null && (w = void 0)), w;
|
|
1087
|
+
};
|
|
1088
|
+
return $(m, D, d), D.get(), O && (D.reset(), function p(v, w, C, N, B) {
|
|
1089
|
+
const g = w.getComponent();
|
|
1090
|
+
if (g) {
|
|
1091
|
+
g.i !== void 0 ? (N = g.i, B = !0) : g.d != null && (N = R[g.d], v = I[g.d], B = !1, g.d);
|
|
1092
|
+
let K = ve(g);
|
|
1093
|
+
if (K && K.makeInvertible) {
|
|
1094
|
+
const se = f(g);
|
|
1095
|
+
y(C, K, K.makeInvertible(se, N), !0);
|
|
1096
|
+
}
|
|
1097
|
+
}
|
|
1098
|
+
let U = 0, re = 0;
|
|
1099
|
+
const te = r.advancer(v, (K, se) => _(se) ? U - K - 1 : K - U, (K, se) => {
|
|
1100
|
+
_(se) && U++;
|
|
1101
|
+
});
|
|
1102
|
+
for (const K of w) if (typeof K == "number") {
|
|
1103
|
+
const se = K - re, Ne = te(se), Oe = se + U, ye = Y(N, B ? se : Oe);
|
|
1104
|
+
C.descend(K), p(Ne, w, C, ye, B), s(w.getComponent()) && re++, C.ascend();
|
|
1105
|
+
} else {
|
|
1106
|
+
const se = Y(N, K);
|
|
1107
|
+
C.descend(K), p(te(K), w, C, se, B), C.ascend();
|
|
1108
|
+
}
|
|
1109
|
+
te.end();
|
|
1110
|
+
}(m.clone(), m, D, d, !1)), D.get();
|
|
1111
|
+
}
|
|
1112
|
+
function Ut(i, d) {
|
|
1113
|
+
return le(De(i, d));
|
|
1114
|
+
}
|
|
1115
|
+
const it = (i) => {
|
|
1116
|
+
if (i == null) return null;
|
|
1117
|
+
const d = i.slice();
|
|
1118
|
+
for (let m = 0; m < i.length; m++) {
|
|
1119
|
+
const D = d[m];
|
|
1120
|
+
Array.isArray(D) && (d[m] = it(D));
|
|
1160
1121
|
}
|
|
1161
|
-
return
|
|
1162
|
-
}(me, _e, _e.clone(), null, null), p.map((Q) => Q && Q.get()), m) return {
|
|
1163
|
-
ok: !1,
|
|
1164
|
-
conflict: m
|
|
1122
|
+
return d;
|
|
1165
1123
|
};
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
const
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1124
|
+
function st(i, d, m) {
|
|
1125
|
+
o(m === "left" || m === "right", "Direction must be left or right");
|
|
1126
|
+
const D = m === "left" ? 0 : 1;
|
|
1127
|
+
if (d == null) return {
|
|
1128
|
+
ok: !0,
|
|
1129
|
+
result: i
|
|
1130
|
+
};
|
|
1131
|
+
z(i), z(d);
|
|
1132
|
+
let O = null;
|
|
1133
|
+
const I = [], R = [], $ = [], p = [], v = [], w = [], C = [], N = [], B = [], g = [], U = [], re = [], te = [], K = [], se = [];
|
|
1134
|
+
let Ne = 0;
|
|
1135
|
+
const Oe = r.readCursor(i), ye = r.readCursor(d), oe = r.writeCursor();
|
|
1136
|
+
if (function Q(A, W = null, M) {
|
|
1137
|
+
const P = l(W);
|
|
1138
|
+
P && (P.r !== void 0 ? M = W.clone() : P.p != null && (M = null, w[P.p] = A.clone()));
|
|
1139
|
+
const k = A.getComponent();
|
|
1140
|
+
let X;
|
|
1141
|
+
k && (X = k.p) != null && (v[X] = W ? W.clone() : null, $[X] = A.clone(), M && (g[X] = !0, B[X] = M), P && P.p != null && (K[X] = P.p));
|
|
1142
|
+
const J = r.advancer(W);
|
|
1143
|
+
for (const ee of A) Q(A, J(ee), M);
|
|
1144
|
+
J.end();
|
|
1145
|
+
}(ye, Oe, null), function Q(A, W, M, P, k) {
|
|
1146
|
+
const X = M.getComponent();
|
|
1147
|
+
let J, ee = !1;
|
|
1148
|
+
X && ((J = X.d) != null ? (p[J] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(J)), A = v[J] || null, W = $[J] || null, g[J] ? (k && (U[J] = !0), k = B[J] || null) : !k || D !== 1 && K[J] != null || O == null && (O = {
|
|
1149
|
+
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1150
|
+
op1: a.removeOp(k.getPath()),
|
|
1151
|
+
op2: a.moveOp(W.getPath(), M.getPath())
|
|
1152
|
+
}), ee = !0) : X.i !== void 0 && (A = W = null, ee = !0, k && O == null && (O = {
|
|
1153
|
+
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1154
|
+
op1: a.removeOp(k.getPath()),
|
|
1155
|
+
op2: a.insertOp(M.getPath(), X.i)
|
|
1156
|
+
})));
|
|
1157
|
+
const fe = l(A);
|
|
1158
|
+
fe && (fe.r !== void 0 ? k = A.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
|
|
1159
|
+
const de = ve(X);
|
|
1160
|
+
de && k && O == null && (O = {
|
|
1161
|
+
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1162
|
+
op1: a.removeOp(k.getPath()),
|
|
1163
|
+
op2: a.editOp(M.getPath(), de, f(X), !0)
|
|
1164
|
+
});
|
|
1165
|
+
let ae = 0, me = 0;
|
|
1166
|
+
const H = r.advancer(W, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => {
|
|
1167
|
+
_(he) && ae++;
|
|
1168
|
+
}), T = r.advancer(A);
|
|
1169
|
+
for (const G of M) if (typeof G == "number") {
|
|
1170
|
+
const he = G - me, we = H(he);
|
|
1171
|
+
me += +Q(T(he + ae), we, M, P, k);
|
|
1172
|
+
} else {
|
|
1173
|
+
const he = H(G);
|
|
1174
|
+
Q(T(G), he, M, P, k);
|
|
1175
|
+
}
|
|
1176
|
+
return H.end(), T.end(), ee;
|
|
1177
|
+
}(Oe, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), O) return {
|
|
1178
|
+
ok: !1,
|
|
1179
|
+
conflict: O
|
|
1180
|
+
};
|
|
1181
|
+
U.map((Q) => !!Q);
|
|
1182
|
+
const Pe = [];
|
|
1183
|
+
let Ae = null;
|
|
1184
|
+
(function Q(A, W, M, P, k) {
|
|
1185
|
+
let X = !1;
|
|
1186
|
+
const J = l(W);
|
|
1187
|
+
if (_(J)) {
|
|
1188
|
+
const H = J.p;
|
|
1189
|
+
H != null ? (M = p[H], P = re[H] = r.writeCursor(), X = !0, k = null) : (M = null, k = W.clone());
|
|
1190
|
+
} else s(l(M)) && (M = null);
|
|
1191
|
+
const ee = A.getComponent();
|
|
1192
|
+
if (ee) {
|
|
1193
|
+
const H = ee.p;
|
|
1194
|
+
H != null ? (k && (N[H] = k), Pe[H] = k || D === 1 && X ? null : P.getComponent(), I[H] = A.clone(), M && (C[H] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || X) && (Ae == null && (Ae = /* @__PURE__ */ new Set()), Ae.add(ee)));
|
|
1221
1195
|
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (A = null, X = M.clone()) : S != null && (A = p[S], D !== 1 && K[S] != null || ((R = te[S]) || (R = te[S] = s.writeCursor()), R.reset(), X = null));
|
|
1228
|
-
} else !o(Y) && o(ee) && (A = null);
|
|
1229
|
-
ee = A != null ? A.getComponent() : null;
|
|
1230
|
-
const q = ve(Y);
|
|
1231
|
-
if (q) {
|
|
1232
|
-
const S = f(Y);
|
|
1233
|
-
if (X) m == null && (m = {
|
|
1234
|
-
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1235
|
-
op1: n.editOp(B.getPath(), q, S, !0),
|
|
1236
|
-
op2: n.removeOp(X.getPath())
|
|
1196
|
+
let fe = 0, de = 0;
|
|
1197
|
+
const ae = r.advancer(W, void 0, (H, T) => {
|
|
1198
|
+
_(T) && fe++;
|
|
1199
|
+
}), me = r.advancer(M, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
|
|
1200
|
+
s(T) && de++;
|
|
1237
1201
|
});
|
|
1238
|
-
|
|
1239
|
-
const
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
Oe = q.transform(S, ce, y);
|
|
1245
|
-
} else Oe = i.default(S);
|
|
1246
|
-
_(R, q, Oe);
|
|
1202
|
+
if (A) for (const H of A) if (typeof H == "string") {
|
|
1203
|
+
const T = ae(H), G = me(H);
|
|
1204
|
+
P.descend(H), Q(A, T, G, P, k), P.ascend();
|
|
1205
|
+
} else {
|
|
1206
|
+
const T = ae(H), G = H - fe, he = _(l(T)) ? null : me(G), we = G + de;
|
|
1207
|
+
o(we >= 0), P.descend(we), Q(A, T, he, P, k), P.ascend();
|
|
1247
1208
|
}
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
}
|
|
1268
|
-
|
|
1209
|
+
ae.end(), me.end();
|
|
1210
|
+
})(Oe, ye, ye.clone(), oe, null), oe.reset();
|
|
1211
|
+
let Le = [];
|
|
1212
|
+
if (function Q(A, W, M, P, k, X) {
|
|
1213
|
+
o(W);
|
|
1214
|
+
const J = W.getComponent();
|
|
1215
|
+
let ee = l(P), fe = !1;
|
|
1216
|
+
const de = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
|
|
1217
|
+
if (s(J)) {
|
|
1218
|
+
const j = J.d;
|
|
1219
|
+
j != null && (R[j] = W.clone());
|
|
1220
|
+
const ie = j != null ? Pe[j] : null;
|
|
1221
|
+
let _e = !1;
|
|
1222
|
+
if (J.i !== void 0 || j != null && ie) {
|
|
1223
|
+
let ue;
|
|
1224
|
+
ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : n.default(ee.i, J.i), _e || ue != null && D !== 1 && K[ue] != null || O == null && (O = {
|
|
1225
|
+
type: u.ConflictType.DROP_COLLISION,
|
|
1226
|
+
op1: de(j != null ? I[j] : null, W, J),
|
|
1227
|
+
op2: de(ue != null ? $[ue] : null, P, ee)
|
|
1228
|
+
})), _e || (X ? O == null && (O = {
|
|
1229
|
+
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1230
|
+
op1: de(j != null ? I[j] : null, W, J),
|
|
1231
|
+
op2: a.removeOp(X.getPath())
|
|
1232
|
+
}) : (j != null ? (Le[Ne] = j, k.write("d", ie.p = Ne++)) : k.write("i", t.default(J.i)), fe = !0));
|
|
1233
|
+
} else if (j != null && !ie) {
|
|
1234
|
+
const ue = N[j];
|
|
1235
|
+
ue && (X = ue.clone());
|
|
1236
|
+
}
|
|
1237
|
+
j != null ? (A = I[j], M = w[j], P = C[j]) : J.i !== void 0 && (A = M = null, _e || (P = null));
|
|
1238
|
+
} else _(l(A)) && (A = M = P = null);
|
|
1239
|
+
const ae = l(A), me = l(M);
|
|
1240
|
+
if (_(me)) {
|
|
1241
|
+
const j = me.p;
|
|
1242
|
+
me.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, X = M.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((k = te[j]) || (k = te[j] = r.writeCursor()), k.reset(), X = null));
|
|
1243
|
+
} else !s(J) && s(ee) && (P = null);
|
|
1244
|
+
ee = P != null ? P.getComponent() : null;
|
|
1245
|
+
const H = ve(J);
|
|
1246
|
+
if (H) {
|
|
1247
|
+
const j = f(J);
|
|
1248
|
+
if (X) O == null && (O = {
|
|
1249
|
+
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1250
|
+
op1: a.editOp(W.getPath(), H, j, !0),
|
|
1251
|
+
op2: a.removeOp(X.getPath())
|
|
1252
|
+
});
|
|
1253
|
+
else {
|
|
1254
|
+
const ie = ve(ee);
|
|
1255
|
+
let _e;
|
|
1256
|
+
if (ie) {
|
|
1257
|
+
if (H !== ie) throw Error("Transforming incompatible types");
|
|
1258
|
+
const ue = f(ee);
|
|
1259
|
+
_e = H.transform(j, ue, m);
|
|
1260
|
+
} else _e = t.default(j);
|
|
1261
|
+
y(k, H, _e);
|
|
1269
1262
|
}
|
|
1270
|
-
ie = Ne && Be === ce ? U : null;
|
|
1271
1263
|
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1264
|
+
let T = 0, G = 0, he = 0, we = 0, xe = 0, qe = 0, Me = A != null && A.descendFirst(), Ye = Me;
|
|
1265
|
+
const Xe = r.advancer(M, void 0, (j, ie) => {
|
|
1266
|
+
_(ie) && he++;
|
|
1267
|
+
});
|
|
1268
|
+
let je = P != null && P.descendFirst(), $e = je;
|
|
1269
|
+
for (const j of W) if (typeof j == "number") {
|
|
1270
|
+
let ie;
|
|
1271
|
+
const _e = s(W.getComponent()), ue = j - G;
|
|
1272
|
+
{
|
|
1273
|
+
let We;
|
|
1274
|
+
for (; Me && typeof (We = A.getKey()) == "number"; ) {
|
|
1275
|
+
We += T;
|
|
1276
|
+
const ke = A.getComponent(), Je = _(ke);
|
|
1277
|
+
if (We > ue || We === ue && (!Je || D === 0 && _e)) break;
|
|
1278
|
+
if (Je) {
|
|
1279
|
+
T--;
|
|
1280
|
+
const Ke = ke.p;
|
|
1281
|
+
K.includes(Ke), ke.d, l(te[ke.d]), _(l(te[ke.d])), (ke.r === void 0 || Ae && Ae.has(ke)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || xe--;
|
|
1286
1282
|
}
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1283
|
+
Me = A.nextSibling();
|
|
1284
|
+
}
|
|
1285
|
+
ie = Me && We === ue ? A : null;
|
|
1286
|
+
}
|
|
1287
|
+
const Ue = ue - T;
|
|
1288
|
+
let Be = Xe(Ue);
|
|
1289
|
+
const ot = Ue - he;
|
|
1290
|
+
let Qe = null;
|
|
1291
|
+
{
|
|
1292
|
+
let We, ke;
|
|
1293
|
+
for (; je && typeof (We = P.getKey()) == "number"; ) {
|
|
1294
|
+
ke = We - we;
|
|
1295
|
+
const Je = P.getComponent(), Ke = s(Je);
|
|
1296
|
+
if (ke > ot) break;
|
|
1297
|
+
if (ke === ot) {
|
|
1298
|
+
if (!Ke) {
|
|
1299
|
+
Qe = P;
|
|
1290
1300
|
break;
|
|
1291
1301
|
}
|
|
1292
|
-
|
|
1293
|
-
|
|
1302
|
+
{
|
|
1303
|
+
if (D === 0 && _e) {
|
|
1304
|
+
Qe = P;
|
|
1305
|
+
break;
|
|
1306
|
+
}
|
|
1307
|
+
const Fe = Be && _(Be.getComponent());
|
|
1308
|
+
if (D === 0 && Fe) break;
|
|
1309
|
+
}
|
|
1294
1310
|
}
|
|
1311
|
+
if (Ke) {
|
|
1312
|
+
const Fe = Je.d;
|
|
1313
|
+
K[Fe], Je.i === void 0 && (g[Fe] || K[Fe] != null && D !== 1) ? (g[Fe] || K[Fe] != null && D === 0) && (we++, qe--) : we++;
|
|
1314
|
+
}
|
|
1315
|
+
je = P.nextSibling();
|
|
1295
1316
|
}
|
|
1296
|
-
if (Ke) {
|
|
1297
|
-
const Ve = Xe.d;
|
|
1298
|
-
K[Ve], Xe.i === void 0 && (g[Ve] || K[Ve] != null && D !== 1) ? (g[Ve] || K[Ve] != null && D === 0) && (be++, He--) : be++;
|
|
1299
|
-
}
|
|
1300
|
-
Se = A.nextSibling();
|
|
1301
|
-
}
|
|
1302
|
-
}
|
|
1303
|
-
const Ot = rt + be + We + He;
|
|
1304
|
-
l(Ot >= 0, "trying to descend to a negative index"), R.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, R, X) && He++, R.ascend();
|
|
1305
|
-
} else {
|
|
1306
|
-
let ie;
|
|
1307
|
-
for (; Ne && (ie = U.getKey(), typeof ie != "string" || !(ie > S || ie === S)); ) Ne = U.nextSibling();
|
|
1308
|
-
const Oe = Ne && ie === S ? U : null, ce = ze(S);
|
|
1309
|
-
let Re;
|
|
1310
|
-
for (; Se && (Re = A.getKey(), typeof Re != "string" || !(Re > S || Re === S)); ) Se = A.nextSibling();
|
|
1311
|
-
const Ge = Se && Re === S ? A : null;
|
|
1312
|
-
R.descend(S), Q(Oe, B, ce, Ge, R, X), R.ascend();
|
|
1313
|
-
}
|
|
1314
|
-
return ze.end(), Ye && U.ascend(), je && A.ascend(), fe;
|
|
1315
|
-
}(me, me.clone(), _e, _e.clone(), oe, null), m) return {
|
|
1316
|
-
ok: !1,
|
|
1317
|
-
conflict: m
|
|
1318
|
-
};
|
|
1319
|
-
oe.reset();
|
|
1320
|
-
const Ue = (Q, U, B) => Q.traverse(U, (M, A) => {
|
|
1321
|
-
M.d != null && B(M.d, Q, A);
|
|
1322
|
-
});
|
|
1323
|
-
(g.length || re.length) && (Ue(_e, oe, (Q, U, B) => {
|
|
1324
|
-
g[Q] && !N[Q] && B.write("r", !0), re[Q] && B.mergeTree(re[Q].get());
|
|
1325
|
-
}), oe.reset());
|
|
1326
|
-
const Ee = [], $e = [];
|
|
1327
|
-
if ((te.length || g.length) && !m) {
|
|
1328
|
-
const Q = s.readCursor(tt(oe.get()));
|
|
1329
|
-
if (Ue(Q, null, (U, B) => {
|
|
1330
|
-
Ee[U] = B.clone();
|
|
1331
|
-
}), te.forEach((U) => {
|
|
1332
|
-
U && Ue(s.readCursor(U.get()), null, (B, M) => {
|
|
1333
|
-
Ee[B] = M.clone();
|
|
1334
|
-
});
|
|
1335
|
-
}), function U(B, M, A, R, X, Y) {
|
|
1336
|
-
const ee = a(M);
|
|
1337
|
-
if (ee && O(ee)) if (ee.p != null) {
|
|
1338
|
-
const P = ee.p;
|
|
1339
|
-
Ee[P].getPath(), A = Ee[P], R = $e[P] = s.writeCursor();
|
|
1340
|
-
} else ee.r !== void 0 && (A = null);
|
|
1341
|
-
else o(a(A)) && (A = null);
|
|
1342
|
-
const fe = B.getComponent();
|
|
1343
|
-
if (fe) {
|
|
1344
|
-
let P;
|
|
1345
|
-
if ((P = fe.d) != null) {
|
|
1346
|
-
const x = te[P];
|
|
1347
|
-
x && (x.get(), R.mergeTree(x.get()), A = s.readCursor(x.get()));
|
|
1348
1317
|
}
|
|
1318
|
+
const yt = ot + we + xe + qe;
|
|
1319
|
+
o(yt >= 0, "trying to descend to a negative index"), k.descend(yt), _e && (ie = Be = Qe = null, G++), Q(ie, W, Be, Qe, k, X) && qe++, k.ascend();
|
|
1320
|
+
} else {
|
|
1321
|
+
let ie;
|
|
1322
|
+
for (; Me && (ie = A.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) Me = A.nextSibling();
|
|
1323
|
+
const _e = Me && ie === j ? A : null, ue = Xe(j);
|
|
1324
|
+
let Ue;
|
|
1325
|
+
for (; je && (Ue = P.getKey(), typeof Ue != "string" || !(Ue > j || Ue === j)); ) je = P.nextSibling();
|
|
1326
|
+
const Be = je && Ue === j ? P : null;
|
|
1327
|
+
k.descend(j), Q(_e, W, ue, Be, k, X), k.ascend();
|
|
1349
1328
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
O(x) && de--;
|
|
1353
|
-
}), q = s.advancer(A, (P, x) => o(x) ? -(P - le) - 1 : P - le, (P, x) => {
|
|
1354
|
-
o(x) && le++;
|
|
1355
|
-
});
|
|
1356
|
-
for (const P of B) if (typeof P == "number") {
|
|
1357
|
-
const x = ye(P), he = P + de, be = q(he), We = he + le;
|
|
1358
|
-
R.descend(We), U(B, x, be, R), R.ascend();
|
|
1359
|
-
} else R.descend(P), U(B, ye(P), q(P), R), R.ascend();
|
|
1360
|
-
ye.end(), q.end();
|
|
1361
|
-
}(_e, Q, Q.clone(), oe), oe.reset(), m) return {
|
|
1329
|
+
return Xe.end(), Ye && A.ascend(), $e && P.ascend(), fe;
|
|
1330
|
+
}(Oe, Oe.clone(), ye, ye.clone(), oe, null), O) return {
|
|
1362
1331
|
ok: !1,
|
|
1363
|
-
conflict:
|
|
1332
|
+
conflict: O
|
|
1364
1333
|
};
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1334
|
+
oe.reset();
|
|
1335
|
+
const Te = (Q, A, W) => Q.traverse(A, (M, P) => {
|
|
1336
|
+
M.d != null && W(M.d, Q, P);
|
|
1337
|
+
});
|
|
1338
|
+
(g.length || re.length) && (Te(ye, oe, (Q, A, W) => {
|
|
1339
|
+
g[Q] && !U[Q] && W.write("r", !0), re[Q] && W.mergeTree(re[Q].get());
|
|
1340
|
+
}), oe.reset());
|
|
1341
|
+
const Ie = [], Re = [];
|
|
1342
|
+
if ((te.length || g.length) && !O) {
|
|
1343
|
+
const Q = r.readCursor(it(oe.get()));
|
|
1344
|
+
if (Te(Q, null, (A, W) => {
|
|
1345
|
+
Ie[A] = W.clone();
|
|
1346
|
+
}), te.forEach((A) => {
|
|
1347
|
+
A && Te(r.readCursor(A.get()), null, (W, M) => {
|
|
1348
|
+
Ie[W] = M.clone();
|
|
1349
|
+
});
|
|
1350
|
+
}), function A(W, M, P, k, X, J) {
|
|
1351
|
+
const ee = l(M);
|
|
1352
|
+
if (ee && _(ee)) if (ee.p != null) {
|
|
1353
|
+
const T = ee.p;
|
|
1354
|
+
Ie[T].getPath(), P = Ie[T], k = Re[T] = r.writeCursor();
|
|
1355
|
+
} else ee.r !== void 0 && (P = null);
|
|
1356
|
+
else s(l(P)) && (P = null);
|
|
1357
|
+
const fe = W.getComponent();
|
|
1358
|
+
if (fe) {
|
|
1359
|
+
let T;
|
|
1360
|
+
if ((T = fe.d) != null) {
|
|
1361
|
+
const G = te[T];
|
|
1362
|
+
G && (G.get(), k.mergeTree(G.get()), P = r.readCursor(G.get()));
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
let de = 0, ae = 0;
|
|
1366
|
+
const me = r.advancer(M, void 0, (T, G) => {
|
|
1367
|
+
_(G) && de--;
|
|
1368
|
+
}), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => {
|
|
1369
|
+
s(G) && ae++;
|
|
1370
|
+
});
|
|
1371
|
+
for (const T of W) if (typeof T == "number") {
|
|
1372
|
+
const G = me(T), he = T + de, we = H(he), xe = he + ae;
|
|
1373
|
+
k.descend(xe), A(W, G, we, k), k.ascend();
|
|
1374
|
+
} else k.descend(T), A(W, me(T), H(T), k), k.ascend();
|
|
1375
|
+
me.end(), H.end();
|
|
1376
|
+
}(ye, Q, Q.clone(), oe), oe.reset(), O) return {
|
|
1377
|
+
ok: !1,
|
|
1378
|
+
conflict: O
|
|
1379
|
+
};
|
|
1380
|
+
if (oe.get(), Re.length) {
|
|
1381
|
+
const A = Re.map((M) => M ? M.get() : null), W = r.readCursor(it(oe.get()));
|
|
1382
|
+
if (Te(W, oe, (M, P, k) => {
|
|
1383
|
+
const X = A[M];
|
|
1384
|
+
X && (k.mergeTree(X), A[M] = null);
|
|
1385
|
+
}), A.find((M) => M)) {
|
|
1386
|
+
const M = r.writeCursor(), P = r.writeCursor();
|
|
1387
|
+
let k = 0, X = 0;
|
|
1388
|
+
A.forEach((J) => {
|
|
1389
|
+
J != null && Te(r.readCursor(J), null, (ee) => {
|
|
1390
|
+
const fe = Le[ee];
|
|
1391
|
+
M.writeMove(I[fe].getPath(), R[fe].getPath(), k++);
|
|
1392
|
+
const de = se[fe];
|
|
1393
|
+
de && de.forEach((ae) => {
|
|
1394
|
+
g[ae] || D !== 1 && K[ae] != null || P.writeMove($[ae].getPath(), p[ae].getPath(), X++);
|
|
1395
|
+
});
|
|
1380
1396
|
});
|
|
1381
|
-
})
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
}
|
|
1397
|
+
}), O = {
|
|
1398
|
+
type: u.ConflictType.BLACKHOLE,
|
|
1399
|
+
op1: M.get(),
|
|
1400
|
+
op2: P.get()
|
|
1401
|
+
};
|
|
1402
|
+
}
|
|
1387
1403
|
}
|
|
1388
1404
|
}
|
|
1405
|
+
return O ? {
|
|
1406
|
+
ok: !1,
|
|
1407
|
+
conflict: O
|
|
1408
|
+
} : {
|
|
1409
|
+
ok: !0,
|
|
1410
|
+
result: oe.get()
|
|
1411
|
+
};
|
|
1389
1412
|
}
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
conflict
|
|
1393
|
-
} : {
|
|
1394
|
-
ok: !0,
|
|
1395
|
-
result: oe.get()
|
|
1413
|
+
const pt = (i) => {
|
|
1414
|
+
const d = new Error("Transform detected write conflict");
|
|
1415
|
+
throw d.conflict = i, d.type = d.name = "writeConflict", d;
|
|
1396
1416
|
};
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
};
|
|
1402
|
-
function At(r, u, y) {
|
|
1403
|
-
const D = nt(r, u, y);
|
|
1404
|
-
if (D.ok) return D.result;
|
|
1405
|
-
gt(D.conflict);
|
|
1406
|
-
}
|
|
1407
|
-
const qe = (r) => {
|
|
1408
|
-
const u = s.writeCursor();
|
|
1409
|
-
return s.readCursor(r).traverse(u, (y, D) => {
|
|
1410
|
-
(o(y) || ve(y)) && D.write("r", !0);
|
|
1411
|
-
}), u.get();
|
|
1412
|
-
}, Pt = (r, u) => {
|
|
1413
|
-
const { type: y, op1: D, op2: m } = r;
|
|
1414
|
-
switch (y) {
|
|
1415
|
-
case d.ConflictType.DROP_COLLISION:
|
|
1416
|
-
return u === "left" ? [null, qe(m)] : [qe(D), null];
|
|
1417
|
-
case d.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1418
|
-
let C = !1;
|
|
1419
|
-
return s.readCursor(D).traverse(null, ($) => {
|
|
1420
|
-
$.r !== void 0 && (C = !0);
|
|
1421
|
-
}), C ? [null, qe(m)] : [qe(D), null];
|
|
1422
|
-
case d.ConflictType.BLACKHOLE:
|
|
1423
|
-
return [qe(D), qe(m)];
|
|
1424
|
-
default:
|
|
1425
|
-
throw Error("Unrecognised conflict: " + y);
|
|
1417
|
+
function kt(i, d, m) {
|
|
1418
|
+
const D = st(i, d, m);
|
|
1419
|
+
if (D.ok) return D.result;
|
|
1420
|
+
pt(D.conflict);
|
|
1426
1421
|
}
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
{
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1422
|
+
const ze = (i) => {
|
|
1423
|
+
const d = r.writeCursor();
|
|
1424
|
+
return r.readCursor(i).traverse(d, (m, D) => {
|
|
1425
|
+
(s(m) || ve(m)) && D.write("r", !0);
|
|
1426
|
+
}), d.get();
|
|
1427
|
+
}, St = (i, d) => {
|
|
1428
|
+
const { type: m, op1: D, op2: O } = i;
|
|
1429
|
+
switch (m) {
|
|
1430
|
+
case u.ConflictType.DROP_COLLISION:
|
|
1431
|
+
return d === "left" ? [null, ze(O)] : [ze(D), null];
|
|
1432
|
+
case u.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1433
|
+
let I = !1;
|
|
1434
|
+
return r.readCursor(D).traverse(null, (R) => {
|
|
1435
|
+
R.r !== void 0 && (I = !0);
|
|
1436
|
+
}), I ? [null, ze(O)] : [ze(D), null];
|
|
1437
|
+
case u.ConflictType.BLACKHOLE:
|
|
1438
|
+
return [ze(D), ze(O)];
|
|
1439
|
+
default:
|
|
1440
|
+
throw Error("Unrecognised conflict: " + m);
|
|
1441
|
+
}
|
|
1442
|
+
};
|
|
1443
|
+
function gt(i, d, m, D) {
|
|
1444
|
+
let O = null;
|
|
1445
|
+
for (; ; ) {
|
|
1446
|
+
const I = st(d, m, D);
|
|
1447
|
+
if (I.ok) return ne(O, I.result);
|
|
1448
|
+
{
|
|
1449
|
+
const { conflict: R } = I;
|
|
1450
|
+
i(R) || pt(R);
|
|
1451
|
+
const [$, p] = St(R, D);
|
|
1452
|
+
d = ne(q(d), $), m = ne(q(m), p), O = ne(O, p);
|
|
1453
|
+
}
|
|
1438
1454
|
}
|
|
1439
1455
|
}
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1456
|
+
}(Ze)), Ze;
|
|
1457
|
+
}
|
|
1458
|
+
var Dt;
|
|
1459
|
+
function Qt() {
|
|
1460
|
+
return Dt || (Dt = 1, function(a) {
|
|
1461
|
+
var e = Ve && Ve.__createBinding || (Object.create ? function(u, o, l, E) {
|
|
1462
|
+
E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() {
|
|
1463
|
+
return o[l];
|
|
1464
|
+
} });
|
|
1465
|
+
} : function(u, o, l, E) {
|
|
1466
|
+
E === void 0 && (E = l), u[E] = o[l];
|
|
1467
|
+
}), n = Ve && Ve.__exportStar || function(u, o) {
|
|
1468
|
+
for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l);
|
|
1469
|
+
};
|
|
1470
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), n(Zt(), a);
|
|
1471
|
+
var t = At();
|
|
1472
|
+
Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() {
|
|
1473
|
+
return t.ReadCursor;
|
|
1474
|
+
} }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() {
|
|
1475
|
+
return t.WriteCursor;
|
|
1446
1476
|
} });
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
};
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
return i.ReadCursor;
|
|
1456
|
-
} }), Object.defineProperty(n, "WriteCursor", { enumerable: !0, get: function() {
|
|
1457
|
-
return i.WriteCursor;
|
|
1458
|
-
} });
|
|
1459
|
-
var s = ht;
|
|
1460
|
-
Object.defineProperty(n, "ConflictType", { enumerable: !0, get: function() {
|
|
1461
|
-
return s.ConflictType;
|
|
1462
|
-
} });
|
|
1463
|
-
})(F);
|
|
1464
|
-
class Vt {
|
|
1477
|
+
var r = Mt();
|
|
1478
|
+
Object.defineProperty(a, "ConflictType", { enumerable: !0, get: function() {
|
|
1479
|
+
return r.ConflictType;
|
|
1480
|
+
} });
|
|
1481
|
+
}(Ve)), Ve;
|
|
1482
|
+
}
|
|
1483
|
+
var V = Qt();
|
|
1484
|
+
class en {
|
|
1465
1485
|
constructor() {
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1486
|
+
F(this, "drawingManagerData", {});
|
|
1487
|
+
F(this, "_oldDrawingManagerData", {});
|
|
1488
|
+
F(this, "_focusDrawings", []);
|
|
1489
|
+
F(this, "_remove$", new be());
|
|
1490
|
+
F(this, "remove$", this._remove$.asObservable());
|
|
1491
|
+
F(this, "_add$", new be());
|
|
1492
|
+
F(this, "add$", this._add$.asObservable());
|
|
1493
|
+
F(this, "_update$", new be());
|
|
1494
|
+
F(this, "update$", this._update$.asObservable());
|
|
1495
|
+
F(this, "_order$", new be());
|
|
1496
|
+
F(this, "order$", this._order$.asObservable());
|
|
1497
|
+
F(this, "_group$", new be());
|
|
1498
|
+
F(this, "group$", this._group$.asObservable());
|
|
1499
|
+
F(this, "_ungroup$", new be());
|
|
1500
|
+
F(this, "ungroup$", this._ungroup$.asObservable());
|
|
1501
|
+
F(this, "_refreshTransform$", new be());
|
|
1502
|
+
F(this, "refreshTransform$", this._refreshTransform$.asObservable());
|
|
1503
|
+
F(this, "_visible$", new be());
|
|
1504
|
+
F(this, "visible$", this._visible$.asObservable());
|
|
1485
1505
|
// private readonly _externalUpdate$ = new Subject<T[]>();
|
|
1486
1506
|
// readonly externalUpdate$ = this._externalUpdate$.asObservable();
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1507
|
+
F(this, "_focus$", new be());
|
|
1508
|
+
F(this, "focus$", this._focus$.asObservable());
|
|
1509
|
+
F(this, "_featurePluginUpdate$", new be());
|
|
1510
|
+
F(this, "featurePluginUpdate$", this._featurePluginUpdate$.asObservable());
|
|
1511
|
+
F(this, "_featurePluginAdd$", new be());
|
|
1512
|
+
F(this, "featurePluginAdd$", this._featurePluginAdd$.asObservable());
|
|
1513
|
+
F(this, "_featurePluginRemove$", new be());
|
|
1514
|
+
F(this, "featurePluginRemove$", this._featurePluginRemove$.asObservable());
|
|
1515
|
+
F(this, "_featurePluginOrderUpdate$", new be());
|
|
1516
|
+
F(this, "featurePluginOrderUpdate$", this._featurePluginOrderUpdate$.asObservable());
|
|
1517
|
+
F(this, "_featurePluginGroupUpdate$", new be());
|
|
1518
|
+
F(this, "featurePluginGroupUpdate$", this._featurePluginGroupUpdate$.asObservable());
|
|
1519
|
+
F(this, "_featurePluginUngroupUpdate$", new be());
|
|
1520
|
+
F(this, "featurePluginUngroupUpdate$", this._featurePluginUngroupUpdate$.asObservable());
|
|
1521
|
+
F(this, "_visible", !0);
|
|
1522
|
+
F(this, "_editable", !0);
|
|
1503
1523
|
}
|
|
1504
1524
|
dispose() {
|
|
1505
1525
|
this._remove$.complete(), this._add$.complete(), this._update$.complete(), this._order$.complete(), this._focus$.complete(), this._featurePluginUpdate$.complete(), this._featurePluginAdd$.complete(), this._featurePluginRemove$.complete(), this._featurePluginOrderUpdate$.complete(), this.drawingManagerData = {}, this._oldDrawingManagerData = {};
|
|
@@ -1508,74 +1528,74 @@ class Vt {
|
|
|
1508
1528
|
this._visible$.next(e);
|
|
1509
1529
|
}
|
|
1510
1530
|
refreshTransform(e) {
|
|
1511
|
-
e.forEach((
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1531
|
+
e.forEach((n) => {
|
|
1532
|
+
const t = this._getCurrentBySearch(n);
|
|
1533
|
+
t != null && (t.transform = n.transform, t.transforms = n.transforms, t.isMultiTransform = n.isMultiTransform);
|
|
1514
1534
|
}), this.refreshTransformNotification(e);
|
|
1515
1535
|
}
|
|
1516
1536
|
getDrawingDataForUnit(e) {
|
|
1517
1537
|
return this.drawingManagerData[e] || {};
|
|
1518
1538
|
}
|
|
1519
1539
|
removeDrawingDataForUnit(e) {
|
|
1520
|
-
const
|
|
1521
|
-
if (
|
|
1540
|
+
const n = this.drawingManagerData[e];
|
|
1541
|
+
if (n == null)
|
|
1522
1542
|
return;
|
|
1523
1543
|
delete this.drawingManagerData[e];
|
|
1524
|
-
const
|
|
1525
|
-
Object.keys(
|
|
1526
|
-
const
|
|
1527
|
-
(
|
|
1528
|
-
|
|
1544
|
+
const t = [];
|
|
1545
|
+
Object.keys(n).forEach((r) => {
|
|
1546
|
+
const u = n[r];
|
|
1547
|
+
(u == null ? void 0 : u.data) != null && Object.keys(u.data).forEach((o) => {
|
|
1548
|
+
t.push({ unitId: e, subUnitId: r, drawingId: o });
|
|
1529
1549
|
});
|
|
1530
|
-
}),
|
|
1550
|
+
}), t.length > 0 && this.removeNotification(t);
|
|
1531
1551
|
}
|
|
1532
|
-
registerDrawingData(e,
|
|
1533
|
-
this.drawingManagerData[e] =
|
|
1552
|
+
registerDrawingData(e, n) {
|
|
1553
|
+
this.drawingManagerData[e] = n;
|
|
1534
1554
|
}
|
|
1535
1555
|
initializeNotification(e) {
|
|
1536
|
-
const
|
|
1537
|
-
|
|
1538
|
-
this._establishDrawingMap(e,
|
|
1539
|
-
const
|
|
1540
|
-
Object.keys(
|
|
1541
|
-
const
|
|
1542
|
-
|
|
1556
|
+
const n = [], t = this.drawingManagerData[e];
|
|
1557
|
+
t != null && (Object.keys(t).forEach((r) => {
|
|
1558
|
+
this._establishDrawingMap(e, r);
|
|
1559
|
+
const u = t[r];
|
|
1560
|
+
Object.keys(u.data).forEach((o) => {
|
|
1561
|
+
const l = u.data[o];
|
|
1562
|
+
l.unitId = e, l.subUnitId = r, n.push(l);
|
|
1543
1563
|
});
|
|
1544
|
-
}),
|
|
1564
|
+
}), n.length > 0 && this.addNotification(n));
|
|
1545
1565
|
}
|
|
1546
|
-
getDrawingData(e,
|
|
1547
|
-
return this._getDrawingData(e,
|
|
1566
|
+
getDrawingData(e, n) {
|
|
1567
|
+
return this._getDrawingData(e, n);
|
|
1548
1568
|
}
|
|
1549
1569
|
// Use in doc only.
|
|
1550
|
-
setDrawingData(e,
|
|
1551
|
-
this.drawingManagerData[e][
|
|
1570
|
+
setDrawingData(e, n, t) {
|
|
1571
|
+
this.drawingManagerData[e][n].data = t;
|
|
1552
1572
|
}
|
|
1553
1573
|
getBatchAddOp(e) {
|
|
1554
|
-
const
|
|
1555
|
-
e.forEach((
|
|
1556
|
-
const { op:
|
|
1557
|
-
|
|
1574
|
+
const n = [], t = [], r = [];
|
|
1575
|
+
e.forEach((x) => {
|
|
1576
|
+
const { op: _, invertOp: s } = this._addByParam(x);
|
|
1577
|
+
n.push({ unitId: x.unitId, subUnitId: x.subUnitId, drawingId: x.drawingId }), t.push(_), r.push(s);
|
|
1558
1578
|
});
|
|
1559
|
-
const
|
|
1560
|
-
return { undo:
|
|
1579
|
+
const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
|
|
1580
|
+
return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n };
|
|
1561
1581
|
}
|
|
1562
1582
|
getBatchRemoveOp(e) {
|
|
1563
|
-
const
|
|
1583
|
+
const n = [], t = [];
|
|
1564
1584
|
e.forEach((E) => {
|
|
1565
|
-
const { op:
|
|
1566
|
-
|
|
1585
|
+
const { op: x, invertOp: _ } = this._removeByParam(E);
|
|
1586
|
+
n.unshift(x), t.push(_);
|
|
1567
1587
|
});
|
|
1568
|
-
const
|
|
1569
|
-
return { undo:
|
|
1588
|
+
const r = n.reduce(V.type.compose, null), u = t.reduce(V.type.compose, null), { unitId: o, subUnitId: l } = e[0];
|
|
1589
|
+
return { undo: u, redo: r, unitId: o, subUnitId: l, objects: e };
|
|
1570
1590
|
}
|
|
1571
1591
|
getBatchUpdateOp(e) {
|
|
1572
|
-
const
|
|
1573
|
-
e.forEach((
|
|
1574
|
-
const { op:
|
|
1575
|
-
|
|
1592
|
+
const n = [], t = [], r = [];
|
|
1593
|
+
e.forEach((x) => {
|
|
1594
|
+
const { op: _, invertOp: s } = this._updateByParam(x);
|
|
1595
|
+
n.push({ unitId: x.unitId, subUnitId: x.subUnitId, drawingId: x.drawingId }), t.push(_), r.push(s);
|
|
1576
1596
|
});
|
|
1577
|
-
const
|
|
1578
|
-
return { undo:
|
|
1597
|
+
const u = t.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
|
|
1598
|
+
return { undo: o, redo: u, unitId: l, subUnitId: E, objects: n };
|
|
1579
1599
|
}
|
|
1580
1600
|
removeNotification(e) {
|
|
1581
1601
|
this._remove$.next(e);
|
|
@@ -1599,61 +1619,61 @@ class Vt {
|
|
|
1599
1619
|
this._refreshTransform$.next(e);
|
|
1600
1620
|
}
|
|
1601
1621
|
getGroupDrawingOp(e) {
|
|
1602
|
-
const
|
|
1603
|
-
e.forEach((
|
|
1604
|
-
|
|
1622
|
+
const n = [], { unitId: t, subUnitId: r } = e[0].parent;
|
|
1623
|
+
e.forEach((l) => {
|
|
1624
|
+
n.push(this._getGroupDrawingOp(l));
|
|
1605
1625
|
});
|
|
1606
|
-
const
|
|
1607
|
-
return { undo:
|
|
1626
|
+
const u = n.reduce(V.type.compose, null);
|
|
1627
|
+
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e };
|
|
1608
1628
|
}
|
|
1609
1629
|
getUngroupDrawingOp(e) {
|
|
1610
|
-
const
|
|
1611
|
-
e.forEach((
|
|
1612
|
-
|
|
1630
|
+
const n = [], { unitId: t, subUnitId: r } = e[0].parent;
|
|
1631
|
+
e.forEach((l) => {
|
|
1632
|
+
n.push(this._getUngroupDrawingOp(l));
|
|
1613
1633
|
});
|
|
1614
|
-
const
|
|
1615
|
-
return { undo:
|
|
1634
|
+
const u = n.reduce(V.type.compose, null);
|
|
1635
|
+
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: t, subUnitId: r, objects: e };
|
|
1616
1636
|
}
|
|
1617
1637
|
getDrawingsByGroup(e) {
|
|
1618
|
-
const { unitId:
|
|
1619
|
-
if (this.getDrawingByParam({ unitId:
|
|
1638
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1639
|
+
if (this.getDrawingByParam({ unitId: n, subUnitId: t, drawingId: r }) == null)
|
|
1620
1640
|
return [];
|
|
1621
|
-
const
|
|
1622
|
-
return Object.keys(
|
|
1623
|
-
const
|
|
1624
|
-
|
|
1625
|
-
}),
|
|
1641
|
+
const o = this._getDrawingData(n, t), l = [];
|
|
1642
|
+
return Object.keys(o).forEach((E) => {
|
|
1643
|
+
const x = o[E];
|
|
1644
|
+
x.groupId === r && l.push(x);
|
|
1645
|
+
}), l;
|
|
1626
1646
|
}
|
|
1627
1647
|
_getGroupDrawingOp(e) {
|
|
1628
|
-
const { parent:
|
|
1629
|
-
|
|
1630
|
-
|
|
1648
|
+
const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = [];
|
|
1649
|
+
l.push(
|
|
1650
|
+
V.insertOp([r, u, "data", o], n)
|
|
1631
1651
|
);
|
|
1632
1652
|
let E = Number.NEGATIVE_INFINITY;
|
|
1633
|
-
return
|
|
1634
|
-
const { unitId:
|
|
1635
|
-
E = Math.max(E, h),
|
|
1636
|
-
...this._getUpdateParamCompareOp(
|
|
1653
|
+
return t.forEach((x) => {
|
|
1654
|
+
const { unitId: _, subUnitId: s, drawingId: c } = x, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: c });
|
|
1655
|
+
E = Math.max(E, h), l.push(
|
|
1656
|
+
...this._getUpdateParamCompareOp(x, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: c }))
|
|
1637
1657
|
);
|
|
1638
|
-
}), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(
|
|
1639
|
-
|
|
1640
|
-
),
|
|
1658
|
+
}), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(r, u).length), l.push(
|
|
1659
|
+
V.insertOp([r, u, "order", E], o)
|
|
1660
|
+
), l.reduce(V.type.compose, null);
|
|
1641
1661
|
}
|
|
1642
1662
|
_getUngroupDrawingOp(e) {
|
|
1643
|
-
const { parent:
|
|
1644
|
-
return
|
|
1645
|
-
const { unitId:
|
|
1646
|
-
|
|
1647
|
-
...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId:
|
|
1663
|
+
const { parent: n, children: t } = e, { unitId: r, subUnitId: u, drawingId: o } = n, l = [];
|
|
1664
|
+
return t.forEach((E) => {
|
|
1665
|
+
const { unitId: x, subUnitId: _, drawingId: s } = E;
|
|
1666
|
+
l.push(
|
|
1667
|
+
...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId: x, subUnitId: _, drawingId: s }))
|
|
1648
1668
|
);
|
|
1649
|
-
}),
|
|
1650
|
-
|
|
1651
|
-
),
|
|
1652
|
-
|
|
1653
|
-
),
|
|
1669
|
+
}), l.push(
|
|
1670
|
+
V.removeOp([r, u, "data", o], !0)
|
|
1671
|
+
), l.push(
|
|
1672
|
+
V.removeOp([r, u, "order", this._getDrawingOrder(r, u).indexOf(o)], !0)
|
|
1673
|
+
), l.reduce(V.type.compose, null);
|
|
1654
1674
|
}
|
|
1655
|
-
applyJson1(e,
|
|
1656
|
-
this._establishDrawingMap(e,
|
|
1675
|
+
applyJson1(e, n, t) {
|
|
1676
|
+
this._establishDrawingMap(e, n), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = V.type.apply(this.drawingManagerData, t);
|
|
1657
1677
|
}
|
|
1658
1678
|
// private _fillMissingFields(jsonOp: JSONOp) {
|
|
1659
1679
|
// if (jsonOp == null) {
|
|
@@ -1700,138 +1720,138 @@ class Vt {
|
|
|
1700
1720
|
return this._getOldBySearch(e);
|
|
1701
1721
|
}
|
|
1702
1722
|
getDrawingOKey(e) {
|
|
1703
|
-
const [
|
|
1704
|
-
return this._getCurrentBySearch({ unitId:
|
|
1723
|
+
const [n, t, r] = e.split("#-#");
|
|
1724
|
+
return this._getCurrentBySearch({ unitId: n, subUnitId: t, drawingId: r });
|
|
1705
1725
|
}
|
|
1706
1726
|
focusDrawing(e) {
|
|
1707
1727
|
if (e == null) {
|
|
1708
1728
|
this._focusDrawings = [], this._focus$.next([]);
|
|
1709
1729
|
return;
|
|
1710
1730
|
}
|
|
1711
|
-
const
|
|
1712
|
-
e.forEach((
|
|
1731
|
+
const n = [];
|
|
1732
|
+
e.forEach((t) => {
|
|
1713
1733
|
var E;
|
|
1714
|
-
const { unitId:
|
|
1715
|
-
|
|
1716
|
-
}),
|
|
1734
|
+
const { unitId: r, subUnitId: u, drawingId: o } = t, l = (E = this._getDrawingData(r, u)) == null ? void 0 : E[o];
|
|
1735
|
+
l != null && n.push(l);
|
|
1736
|
+
}), n.length > 0 && (this._focusDrawings = n, this._focus$.next(n));
|
|
1717
1737
|
}
|
|
1718
1738
|
getFocusDrawings() {
|
|
1719
1739
|
const e = [];
|
|
1720
|
-
return this._focusDrawings.forEach((
|
|
1721
|
-
var
|
|
1722
|
-
const { unitId:
|
|
1723
|
-
|
|
1740
|
+
return this._focusDrawings.forEach((n) => {
|
|
1741
|
+
var l;
|
|
1742
|
+
const { unitId: t, subUnitId: r, drawingId: u } = n, o = (l = this._getDrawingData(t, r)) == null ? void 0 : l[u];
|
|
1743
|
+
o != null && e.push(o);
|
|
1724
1744
|
}), e;
|
|
1725
1745
|
}
|
|
1726
|
-
getDrawingOrder(e,
|
|
1727
|
-
return this._getDrawingOrder(e,
|
|
1746
|
+
getDrawingOrder(e, n) {
|
|
1747
|
+
return this._getDrawingOrder(e, n);
|
|
1728
1748
|
}
|
|
1729
1749
|
// Use in doc only.
|
|
1730
|
-
setDrawingOrder(e,
|
|
1731
|
-
this.drawingManagerData[e][
|
|
1750
|
+
setDrawingOrder(e, n, t) {
|
|
1751
|
+
this.drawingManagerData[e][n].order = t;
|
|
1732
1752
|
}
|
|
1733
1753
|
orderUpdateNotification(e) {
|
|
1734
1754
|
this._order$.next(e);
|
|
1735
1755
|
}
|
|
1736
1756
|
getForwardDrawingsOp(e) {
|
|
1737
|
-
const { unitId:
|
|
1738
|
-
|
|
1739
|
-
const
|
|
1740
|
-
if (
|
|
1757
|
+
const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r];
|
|
1758
|
+
r.forEach((_) => {
|
|
1759
|
+
const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
|
|
1760
|
+
if (s === -1 || s === o.length - 1)
|
|
1741
1761
|
return;
|
|
1742
|
-
const c =
|
|
1743
|
-
|
|
1762
|
+
const c = V.moveOp([n, t, "order", s], [n, t, "order", s + 1]);
|
|
1763
|
+
u.push(c), l.includes(o[s + 1]) || l.push(o[s + 1]);
|
|
1744
1764
|
});
|
|
1745
|
-
const E =
|
|
1746
|
-
return { undo:
|
|
1765
|
+
const E = u.reduce(V.type.compose, null);
|
|
1766
|
+
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
|
|
1747
1767
|
}
|
|
1748
1768
|
getBackwardDrawingOp(e) {
|
|
1749
|
-
const { unitId:
|
|
1750
|
-
|
|
1751
|
-
const
|
|
1752
|
-
if (
|
|
1769
|
+
const { unitId: n, subUnitId: t, drawingIds: r } = e, u = [], o = this.getDrawingOrder(n, t), l = [...r];
|
|
1770
|
+
r.forEach((_) => {
|
|
1771
|
+
const s = this._hasDrawingOrder({ unitId: n, subUnitId: t, drawingId: _ });
|
|
1772
|
+
if (s === -1 || s === 0)
|
|
1753
1773
|
return;
|
|
1754
|
-
const c =
|
|
1755
|
-
|
|
1774
|
+
const c = V.moveOp([n, t, "order", s], [n, t, "order", s - 1]);
|
|
1775
|
+
u.push(c), l.includes(o[s - 1]) || l.push(o[s - 1]);
|
|
1756
1776
|
});
|
|
1757
|
-
const E =
|
|
1758
|
-
return { undo:
|
|
1777
|
+
const E = u.reduce(V.type.compose, null);
|
|
1778
|
+
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: n, subUnitId: t, objects: { ...e, drawingIds: l } };
|
|
1759
1779
|
}
|
|
1760
1780
|
getFrontDrawingsOp(e) {
|
|
1761
|
-
const { unitId:
|
|
1762
|
-
|
|
1763
|
-
const { drawingId: c } =
|
|
1764
|
-
E.push(
|
|
1781
|
+
const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r), o = [...r], l = this.getDrawingOrder(n, t), E = [];
|
|
1782
|
+
u.forEach((s) => {
|
|
1783
|
+
const { drawingId: c } = s, h = this._getDrawingCount(n, t) - 1, S = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", h]);
|
|
1784
|
+
E.push(S), o.includes(l[h]) || o.push(l[h]);
|
|
1765
1785
|
});
|
|
1766
|
-
const
|
|
1767
|
-
return { undo:
|
|
1786
|
+
const x = E.reduce(V.type.compose, null);
|
|
1787
|
+
return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
|
|
1768
1788
|
}
|
|
1769
1789
|
getBackDrawingsOp(e) {
|
|
1770
|
-
const { unitId:
|
|
1771
|
-
|
|
1772
|
-
const { drawingId: c } =
|
|
1773
|
-
E.push(h),
|
|
1790
|
+
const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r, !0), o = [...r], l = this.getDrawingOrder(n, t), E = [];
|
|
1791
|
+
u.forEach((s) => {
|
|
1792
|
+
const { drawingId: c } = s, h = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", 0]);
|
|
1793
|
+
E.push(h), o.includes(l[0]) || o.push(l[0]);
|
|
1774
1794
|
});
|
|
1775
|
-
const
|
|
1776
|
-
return { undo:
|
|
1795
|
+
const x = E.reduce(V.type.compose, null);
|
|
1796
|
+
return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
|
|
1777
1797
|
}
|
|
1778
|
-
_getDrawingCount(e,
|
|
1779
|
-
return this.getDrawingOrder(e,
|
|
1798
|
+
_getDrawingCount(e, n) {
|
|
1799
|
+
return this.getDrawingOrder(e, n).length || 0;
|
|
1780
1800
|
}
|
|
1781
|
-
_getOrderFromSearchParams(e,
|
|
1782
|
-
return
|
|
1783
|
-
const
|
|
1784
|
-
return { drawingId:
|
|
1785
|
-
}).sort(
|
|
1801
|
+
_getOrderFromSearchParams(e, n, t, r = !1) {
|
|
1802
|
+
return t.map((u) => {
|
|
1803
|
+
const o = this._hasDrawingOrder({ unitId: e, subUnitId: n, drawingId: u });
|
|
1804
|
+
return { drawingId: u, zIndex: o };
|
|
1805
|
+
}).sort(r === !1 ? Nt : Rt);
|
|
1786
1806
|
}
|
|
1787
1807
|
_hasDrawingOrder(e) {
|
|
1788
1808
|
if (e == null)
|
|
1789
1809
|
return -1;
|
|
1790
|
-
const { unitId:
|
|
1791
|
-
return this._establishDrawingMap(
|
|
1810
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1811
|
+
return this._establishDrawingMap(n, t), this._getDrawingOrder(n, t).indexOf(r);
|
|
1792
1812
|
}
|
|
1793
1813
|
_getCurrentBySearch(e) {
|
|
1794
|
-
var
|
|
1814
|
+
var u, o, l;
|
|
1795
1815
|
if (e == null)
|
|
1796
1816
|
return;
|
|
1797
|
-
const { unitId:
|
|
1798
|
-
return (
|
|
1817
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1818
|
+
return (l = (o = (u = this.drawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r];
|
|
1799
1819
|
}
|
|
1800
1820
|
_getOldBySearch(e) {
|
|
1801
|
-
var
|
|
1821
|
+
var u, o, l;
|
|
1802
1822
|
if (e == null)
|
|
1803
1823
|
return;
|
|
1804
|
-
const { unitId:
|
|
1805
|
-
return (
|
|
1824
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1825
|
+
return (l = (o = (u = this._oldDrawingManagerData[n]) == null ? void 0 : u[t]) == null ? void 0 : o.data) == null ? void 0 : l[r];
|
|
1806
1826
|
}
|
|
1807
|
-
_establishDrawingMap(e,
|
|
1808
|
-
var
|
|
1809
|
-
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][
|
|
1827
|
+
_establishDrawingMap(e, n, t) {
|
|
1828
|
+
var r;
|
|
1829
|
+
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][n] || (this.drawingManagerData[e][n] = {
|
|
1810
1830
|
data: {},
|
|
1811
1831
|
order: []
|
|
1812
|
-
}),
|
|
1832
|
+
}), t == null ? null : (r = this.drawingManagerData[e][n].data) == null ? void 0 : r[t];
|
|
1813
1833
|
}
|
|
1814
1834
|
_addByParam(e) {
|
|
1815
|
-
const { unitId:
|
|
1816
|
-
this._establishDrawingMap(
|
|
1817
|
-
const
|
|
1818
|
-
return { op:
|
|
1835
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1836
|
+
this._establishDrawingMap(n, t, r);
|
|
1837
|
+
const u = V.insertOp([n, t, "data", r], e), o = V.insertOp([n, t, "order", this._getDrawingOrder(n, t).length], r), l = [u, o].reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
|
|
1838
|
+
return { op: l, invertOp: E };
|
|
1819
1839
|
}
|
|
1820
1840
|
_removeByParam(e) {
|
|
1821
1841
|
if (e == null)
|
|
1822
1842
|
return { op: [], invertOp: [] };
|
|
1823
|
-
const { unitId:
|
|
1824
|
-
if (this._establishDrawingMap(
|
|
1843
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e;
|
|
1844
|
+
if (this._establishDrawingMap(n, t, r) == null)
|
|
1825
1845
|
return { op: [], invertOp: [] };
|
|
1826
|
-
const
|
|
1827
|
-
return { op: E, invertOp:
|
|
1846
|
+
const o = V.removeOp([n, t, "data", r], !0), l = V.removeOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(r)], !0), E = [o, l].reduce(V.type.compose, null), x = V.type.invertWithDoc(E, this.drawingManagerData);
|
|
1847
|
+
return { op: E, invertOp: x };
|
|
1828
1848
|
}
|
|
1829
1849
|
_updateByParam(e) {
|
|
1830
|
-
const { unitId:
|
|
1831
|
-
if (
|
|
1850
|
+
const { unitId: n, subUnitId: t, drawingId: r } = e, u = this._establishDrawingMap(n, t, r);
|
|
1851
|
+
if (u == null)
|
|
1832
1852
|
return { op: [], invertOp: [] };
|
|
1833
|
-
const
|
|
1834
|
-
return { op:
|
|
1853
|
+
const l = this._getUpdateParamCompareOp(e, u).reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
|
|
1854
|
+
return { op: l, invertOp: E };
|
|
1835
1855
|
}
|
|
1836
1856
|
// private _initializeDrawingData(updateParam: T, oldParam: T) {
|
|
1837
1857
|
// Object.keys(updateParam).forEach((key) => {
|
|
@@ -1840,22 +1860,22 @@ class Vt {
|
|
|
1840
1860
|
// }
|
|
1841
1861
|
// });
|
|
1842
1862
|
// }
|
|
1843
|
-
_getUpdateParamCompareOp(e,
|
|
1844
|
-
const { unitId:
|
|
1845
|
-
return Object.keys(e).forEach((
|
|
1846
|
-
const E = e[
|
|
1847
|
-
|
|
1848
|
-
|
|
1863
|
+
_getUpdateParamCompareOp(e, n) {
|
|
1864
|
+
const { unitId: t, subUnitId: r, drawingId: u } = e, o = [];
|
|
1865
|
+
return Object.keys(e).forEach((l) => {
|
|
1866
|
+
const E = e[l], x = n[l];
|
|
1867
|
+
x !== E && o.push(
|
|
1868
|
+
V.replaceOp([t, r, "data", u, l], x, E)
|
|
1849
1869
|
);
|
|
1850
|
-
}),
|
|
1870
|
+
}), o;
|
|
1851
1871
|
}
|
|
1852
|
-
_getDrawingData(e,
|
|
1853
|
-
var
|
|
1854
|
-
return ((
|
|
1872
|
+
_getDrawingData(e, n) {
|
|
1873
|
+
var t, r;
|
|
1874
|
+
return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.data) || {};
|
|
1855
1875
|
}
|
|
1856
|
-
_getDrawingOrder(e,
|
|
1857
|
-
var
|
|
1858
|
-
return ((
|
|
1876
|
+
_getDrawingOrder(e, n) {
|
|
1877
|
+
var t, r;
|
|
1878
|
+
return ((r = (t = this.drawingManagerData[e]) == null ? void 0 : t[n]) == null ? void 0 : r.order) || [];
|
|
1859
1879
|
}
|
|
1860
1880
|
getDrawingVisible() {
|
|
1861
1881
|
return this._visible;
|
|
@@ -1870,73 +1890,71 @@ class Vt {
|
|
|
1870
1890
|
this._editable = e;
|
|
1871
1891
|
}
|
|
1872
1892
|
}
|
|
1873
|
-
class
|
|
1893
|
+
class tn extends en {
|
|
1874
1894
|
}
|
|
1875
|
-
function
|
|
1876
|
-
return typeof
|
|
1895
|
+
function _n({ unitId: a, subUnitId: e, drawingId: n }, t) {
|
|
1896
|
+
return typeof t == "number" ? `${a}#-#${e}#-#${n}#-#${t}` : `${a}#-#${e}#-#${n}`;
|
|
1877
1897
|
}
|
|
1878
|
-
const
|
|
1879
|
-
const
|
|
1880
|
-
|
|
1898
|
+
const vn = async (a) => new Promise((e, n) => {
|
|
1899
|
+
const t = new Image();
|
|
1900
|
+
t.src = a, t.onload = () => {
|
|
1881
1901
|
e({
|
|
1882
|
-
width:
|
|
1883
|
-
height:
|
|
1884
|
-
image:
|
|
1902
|
+
width: t.width,
|
|
1903
|
+
height: t.height,
|
|
1904
|
+
image: t
|
|
1885
1905
|
});
|
|
1886
|
-
},
|
|
1887
|
-
|
|
1906
|
+
}, t.onerror = (r) => {
|
|
1907
|
+
n(r);
|
|
1888
1908
|
};
|
|
1889
|
-
});
|
|
1890
|
-
|
|
1891
|
-
const qt = Ct("core.image-io.service");
|
|
1892
|
-
class zt {
|
|
1909
|
+
}), nn = "drawing.config", rn = {}, sn = xt("univer.drawing-manager.service");
|
|
1910
|
+
class on {
|
|
1893
1911
|
constructor() {
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1912
|
+
F(this, "_waitCount", 0);
|
|
1913
|
+
F(this, "_change$", new be());
|
|
1914
|
+
F(this, "change$", this._change$);
|
|
1915
|
+
F(this, "_imageSourceCache", /* @__PURE__ */ new Map());
|
|
1898
1916
|
}
|
|
1899
1917
|
setWaitCount(e) {
|
|
1900
1918
|
this._waitCount = e, this._change$.next(e);
|
|
1901
1919
|
}
|
|
1902
|
-
getImageSourceCache(e,
|
|
1903
|
-
if (
|
|
1904
|
-
const
|
|
1905
|
-
return
|
|
1920
|
+
getImageSourceCache(e, n) {
|
|
1921
|
+
if (n === at.BASE64) {
|
|
1922
|
+
const t = new Image();
|
|
1923
|
+
return t.src = e, t;
|
|
1906
1924
|
}
|
|
1907
1925
|
return this._imageSourceCache.get(e);
|
|
1908
1926
|
}
|
|
1909
|
-
addImageSourceCache(e,
|
|
1910
|
-
|
|
1927
|
+
addImageSourceCache(e, n, t) {
|
|
1928
|
+
n === at.BASE64 || t == null || this._imageSourceCache.set(e, t);
|
|
1911
1929
|
}
|
|
1912
1930
|
async getImage(e) {
|
|
1913
1931
|
return Promise.resolve(e);
|
|
1914
1932
|
}
|
|
1915
1933
|
async saveImage(e) {
|
|
1916
|
-
return new Promise((
|
|
1917
|
-
if (!
|
|
1918
|
-
|
|
1934
|
+
return new Promise((n, t) => {
|
|
1935
|
+
if (!Ht.includes(e.type)) {
|
|
1936
|
+
t(new Error(et.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
|
|
1919
1937
|
return;
|
|
1920
1938
|
}
|
|
1921
|
-
if (e.size >
|
|
1922
|
-
|
|
1939
|
+
if (e.size > Vt) {
|
|
1940
|
+
t(new Error(et.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
|
|
1923
1941
|
return;
|
|
1924
1942
|
}
|
|
1925
|
-
const
|
|
1926
|
-
|
|
1943
|
+
const r = new FileReader();
|
|
1944
|
+
r.readAsDataURL(e), r.onload = (u) => {
|
|
1927
1945
|
var E;
|
|
1928
|
-
const
|
|
1929
|
-
if (
|
|
1930
|
-
|
|
1946
|
+
const o = (E = u.target) == null ? void 0 : E.result;
|
|
1947
|
+
if (o == null) {
|
|
1948
|
+
t(new Error(et.ERROR_IMAGE)), this._decreaseWaiting();
|
|
1931
1949
|
return;
|
|
1932
1950
|
}
|
|
1933
|
-
const
|
|
1934
|
-
|
|
1935
|
-
imageId:
|
|
1936
|
-
imageSourceType:
|
|
1937
|
-
source:
|
|
1938
|
-
base64Cache:
|
|
1939
|
-
status:
|
|
1951
|
+
const l = Bt.generateRandomId(6);
|
|
1952
|
+
n({
|
|
1953
|
+
imageId: l,
|
|
1954
|
+
imageSourceType: at.BASE64,
|
|
1955
|
+
source: o,
|
|
1956
|
+
base64Cache: o,
|
|
1957
|
+
status: et.SUCCUSS
|
|
1940
1958
|
}), this._decreaseWaiting();
|
|
1941
1959
|
};
|
|
1942
1960
|
});
|
|
@@ -1945,54 +1963,48 @@ class zt {
|
|
|
1945
1963
|
this._waitCount -= 1, this._change$.next(this._waitCount);
|
|
1946
1964
|
}
|
|
1947
1965
|
}
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
super(), this._config = n, this._injector = e, this._configService = t;
|
|
1961
|
-
const { ...i } = this._config;
|
|
1962
|
-
this._configService.setConfig(Jt, i);
|
|
1966
|
+
var an = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, un = (a, e, n, t) => {
|
|
1967
|
+
for (var r = t > 1 ? void 0 : t ? ln(e, n) : e, u = a.length - 1, o; u >= 0; u--)
|
|
1968
|
+
(o = a[u]) && (r = (t ? o(e, n, r) : o(r)) || r);
|
|
1969
|
+
return t && r && an(e, n, r), r;
|
|
1970
|
+
}, Pt = (a, e) => (n, t) => e(n, t, a);
|
|
1971
|
+
const cn = "UNIVER_DRAWING_PLUGIN";
|
|
1972
|
+
var dt;
|
|
1973
|
+
let Tt = (dt = class extends Lt {
|
|
1974
|
+
constructor(a = rn, e, n) {
|
|
1975
|
+
super(), this._config = a, this._injector = e, this._configService = n;
|
|
1976
|
+
const { ...t } = this._config;
|
|
1977
|
+
this._configService.setConfig(nn, t);
|
|
1963
1978
|
}
|
|
1964
1979
|
onStarting() {
|
|
1965
1980
|
this._initDependencies();
|
|
1966
1981
|
}
|
|
1967
1982
|
_initDependencies() {
|
|
1968
|
-
var
|
|
1969
|
-
|
|
1970
|
-
[
|
|
1971
|
-
[
|
|
1972
|
-
], (
|
|
1973
|
-
}
|
|
1974
|
-
},
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
],
|
|
1983
|
+
var n;
|
|
1984
|
+
qt([
|
|
1985
|
+
[Ft, { useClass: on }],
|
|
1986
|
+
[sn, { useClass: tn }]
|
|
1987
|
+
], (n = this._config) == null ? void 0 : n.override).forEach((t) => this._injector.add(t));
|
|
1988
|
+
}
|
|
1989
|
+
}, F(dt, "pluginName", cn), dt);
|
|
1990
|
+
Tt = un([
|
|
1991
|
+
Pt(1, Wt(Gt)),
|
|
1992
|
+
Pt(2, Kt)
|
|
1993
|
+
], Tt);
|
|
1979
1994
|
export {
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
It as UniverDrawingPlugin,
|
|
1996
|
-
dn as getDrawingShapeKeyByDrawingSearch,
|
|
1997
|
-
fn as getImageSize
|
|
1995
|
+
Ht as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
1996
|
+
Vt as DRAWING_IMAGE_ALLOW_SIZE,
|
|
1997
|
+
yn as DRAWING_IMAGE_COUNT_LIMIT,
|
|
1998
|
+
gn as DRAWING_IMAGE_HEIGHT_LIMIT,
|
|
1999
|
+
pn as DRAWING_IMAGE_WIDTH_LIMIT,
|
|
2000
|
+
tn as DrawingManagerService,
|
|
2001
|
+
sn as IDrawingManagerService,
|
|
2002
|
+
wn as IImageIoService,
|
|
2003
|
+
on as ImageIoService,
|
|
2004
|
+
bn as ImageSourceType,
|
|
2005
|
+
Cn as ImageUploadStatusType,
|
|
2006
|
+
en as UnitDrawingService,
|
|
2007
|
+
Tt as UniverDrawingPlugin,
|
|
2008
|
+
_n as getDrawingShapeKeyByDrawingSearch,
|
|
2009
|
+
vn as getImageSize
|
|
1998
2010
|
};
|