@univerjs/drawing 0.2.1 → 0.2.3
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/es/index.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Ut = (
|
|
3
|
-
var V = (
|
|
1
|
+
var Pt = Object.defineProperty;
|
|
2
|
+
var Ut = (n, e, t) => e in n ? Pt(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var V = (n, e, t) => Ut(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Subject as we } from "rxjs";
|
|
5
5
|
import { sortRules as Mt, sortRulesByDesc as Nt, Tools as kt, Plugin as Rt, mergeOverrideWithDependencies as St } from "@univerjs/core";
|
|
6
6
|
import { createIdentifier as It, Inject as jt, Injector as Tt } from "@wendellhu/redi";
|
|
7
7
|
const on = 500, ln = 500, an = 10, $t = 5 * 1024 * 1024, Wt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
|
|
8
8
|
var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, F = {}, Ct = {}, ct = {};
|
|
9
9
|
Object.defineProperty(ct, "__esModule", { value: !0 });
|
|
10
|
-
function Gt(
|
|
10
|
+
function Gt(n, e) {
|
|
11
11
|
if (Array.isArray(e))
|
|
12
12
|
return !1;
|
|
13
|
-
for (let
|
|
14
|
-
if (!ut(t
|
|
13
|
+
for (let t in n)
|
|
14
|
+
if (!ut(n[t], e[t]))
|
|
15
15
|
return !1;
|
|
16
|
-
for (let
|
|
17
|
-
if (t
|
|
16
|
+
for (let t in e)
|
|
17
|
+
if (n[t] === void 0)
|
|
18
18
|
return !1;
|
|
19
19
|
return !0;
|
|
20
20
|
}
|
|
21
|
-
function Bt(
|
|
22
|
-
if (!Array.isArray(e) ||
|
|
21
|
+
function Bt(n, e) {
|
|
22
|
+
if (!Array.isArray(e) || n.length !== e.length)
|
|
23
23
|
return !1;
|
|
24
|
-
for (let
|
|
25
|
-
if (!ut(t
|
|
24
|
+
for (let t = 0; t < n.length; t++)
|
|
25
|
+
if (!ut(n[t], e[t]))
|
|
26
26
|
return !1;
|
|
27
27
|
return !0;
|
|
28
28
|
}
|
|
29
|
-
function ut(
|
|
30
|
-
return
|
|
29
|
+
function ut(n, e) {
|
|
30
|
+
return n === e ? !0 : n === null || e === null || typeof n != "object" || typeof e != "object" ? !1 : Array.isArray(n) ? Bt(n, e) : Gt(n, e);
|
|
31
31
|
}
|
|
32
32
|
ct.default = ut;
|
|
33
33
|
var dt = {};
|
|
34
34
|
Object.defineProperty(dt, "__esModule", { value: !0 });
|
|
35
|
-
function lt(
|
|
36
|
-
if (
|
|
35
|
+
function lt(n) {
|
|
36
|
+
if (n === null)
|
|
37
37
|
return null;
|
|
38
|
-
if (Array.isArray(
|
|
39
|
-
return
|
|
40
|
-
if (typeof
|
|
38
|
+
if (Array.isArray(n))
|
|
39
|
+
return n.map(lt);
|
|
40
|
+
if (typeof n == "object") {
|
|
41
41
|
const e = {};
|
|
42
|
-
for (let
|
|
43
|
-
e[
|
|
42
|
+
for (let t in n)
|
|
43
|
+
e[t] = lt(n[t]);
|
|
44
44
|
return e;
|
|
45
45
|
} else
|
|
46
|
-
return
|
|
46
|
+
return n;
|
|
47
47
|
}
|
|
48
48
|
dt.default = lt;
|
|
49
49
|
var ft = {};
|
|
50
|
-
(function(
|
|
51
|
-
Object.defineProperty(
|
|
50
|
+
(function(n) {
|
|
51
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.eachChildOf = n.advancer = n.readCursor = n.writeCursor = n.WriteCursor = n.ReadCursor = n.isValidPathItem = void 0;
|
|
52
52
|
function e(O, o) {
|
|
53
53
|
if (!O)
|
|
54
54
|
throw new Error(o);
|
|
55
55
|
}
|
|
56
|
-
const
|
|
56
|
+
const t = (O) => O != null && typeof O == "object" && !Array.isArray(O), s = (O, o) => (
|
|
57
57
|
// All the numbers, then all the letters. Just as the gods of ascii intended.
|
|
58
58
|
typeof O == typeof o ? O > o : typeof O == "string" && typeof o == "number"
|
|
59
59
|
);
|
|
@@ -63,19 +63,19 @@ var ft = {};
|
|
|
63
63
|
o.write(h, O[h]);
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
n.isValidPathItem = (O) => typeof O == "number" || typeof O == "string" && O !== "__proto__";
|
|
67
67
|
class d {
|
|
68
68
|
constructor(o = null) {
|
|
69
69
|
this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = o;
|
|
70
70
|
}
|
|
71
71
|
ascend() {
|
|
72
|
-
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--,
|
|
72
|
+
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--);
|
|
73
73
|
}
|
|
74
74
|
getPath() {
|
|
75
75
|
const o = [];
|
|
76
76
|
let c = this.container, h = this.parents.length - 1, R = this.idx;
|
|
77
77
|
for (; R >= 0; )
|
|
78
|
-
o.unshift(c[R]), R === 0 ? (R = this.indexes[h * 2], c = this.parents[h--]) : R -=
|
|
78
|
+
o.unshift(c[R]), R === 0 ? (R = this.indexes[h * 2], c = this.parents[h--]) : R -= t(c[R - 1]) ? 2 : 1;
|
|
79
79
|
return o;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -89,13 +89,13 @@ var ft = {};
|
|
|
89
89
|
}
|
|
90
90
|
getComponent() {
|
|
91
91
|
let o;
|
|
92
|
-
return this.container && this.container.length > this.idx + 1 &&
|
|
92
|
+
return this.container && this.container.length > this.idx + 1 && t(o = this.container[this.idx + 1]) ? o : null;
|
|
93
93
|
}
|
|
94
94
|
descendFirst() {
|
|
95
95
|
let o = this.idx + 1;
|
|
96
|
-
if (!this.container || o >= this.container.length ||
|
|
96
|
+
if (!this.container || o >= this.container.length || t(this.container[o]) && o + 1 >= this.container.length)
|
|
97
97
|
return !1;
|
|
98
|
-
|
|
98
|
+
t(this.container[o]) && o++;
|
|
99
99
|
const c = this.container[o];
|
|
100
100
|
return Array.isArray(c) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(o), this.idx = 0, this.container = c) : this.idx = o, !0;
|
|
101
101
|
}
|
|
@@ -140,7 +140,7 @@ var ft = {};
|
|
|
140
140
|
});
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
|
|
143
|
+
n.ReadCursor = l;
|
|
144
144
|
class a extends d {
|
|
145
145
|
constructor(o = null) {
|
|
146
146
|
super(o), this.pendingDescent = [], this._op = o;
|
|
@@ -150,7 +150,7 @@ var ft = {};
|
|
|
150
150
|
for (let o = 0; o < this.pendingDescent.length; o++) {
|
|
151
151
|
const c = this.pendingDescent[o];
|
|
152
152
|
let h = this.idx + 1;
|
|
153
|
-
if (h < this.container.length &&
|
|
153
|
+
if (h < this.container.length && t(this.container[h]) && h++, e(h === this.container.length || !t(this.container[h])), h === this.container.length)
|
|
154
154
|
this.container.push(c), this.idx = h;
|
|
155
155
|
else if (this.container[h] === c)
|
|
156
156
|
this.idx = h;
|
|
@@ -180,7 +180,7 @@ var ft = {};
|
|
|
180
180
|
getComponent() {
|
|
181
181
|
this.flushDescent();
|
|
182
182
|
const o = this.idx + 1;
|
|
183
|
-
if (o < this.container.length &&
|
|
183
|
+
if (o < this.container.length && t(this.container[o]))
|
|
184
184
|
return this.container[o];
|
|
185
185
|
{
|
|
186
186
|
const c = {};
|
|
@@ -195,7 +195,7 @@ var ft = {};
|
|
|
195
195
|
return this._op;
|
|
196
196
|
}
|
|
197
197
|
descend(o) {
|
|
198
|
-
if (!
|
|
198
|
+
if (!n.isValidPathItem(o))
|
|
199
199
|
throw Error("Invalid JSON key");
|
|
200
200
|
this.pendingDescent.push(o);
|
|
201
201
|
}
|
|
@@ -239,7 +239,7 @@ var ft = {};
|
|
|
239
239
|
return o.push(...this.pendingDescent), o;
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
|
|
242
|
+
n.WriteCursor = a, n.writeCursor = () => new a(), n.readCursor = (O) => new l(O);
|
|
243
243
|
function E(O, o, c) {
|
|
244
244
|
let h, R;
|
|
245
245
|
R = h = O ? O.descendFirst() : !1;
|
|
@@ -262,7 +262,7 @@ var ft = {};
|
|
|
262
262
|
h && O.ascend();
|
|
263
263
|
}, Z;
|
|
264
264
|
}
|
|
265
|
-
|
|
265
|
+
n.advancer = E;
|
|
266
266
|
function W(O, o, c) {
|
|
267
267
|
let h, R, Z, pe;
|
|
268
268
|
for (h = R = O && O.descendFirst(), Z = pe = o && o.descendFirst(); h || Z; ) {
|
|
@@ -271,39 +271,39 @@ var ft = {};
|
|
|
271
271
|
}
|
|
272
272
|
R && O.ascend(), pe && o.ascend();
|
|
273
273
|
}
|
|
274
|
-
|
|
274
|
+
n.eachChildOf = W;
|
|
275
275
|
})(ft);
|
|
276
276
|
var ht = {};
|
|
277
|
-
(function(
|
|
278
|
-
Object.defineProperty(
|
|
277
|
+
(function(n) {
|
|
278
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.ConflictType = void 0, function(e) {
|
|
279
279
|
e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
|
|
280
|
-
}(
|
|
280
|
+
}(n.ConflictType || (n.ConflictType = {}));
|
|
281
281
|
})(ht);
|
|
282
282
|
var it = {}, Fe = {}, vt;
|
|
283
283
|
function pt() {
|
|
284
|
-
return vt || (vt = 1, Object.defineProperty(Fe, "__esModule", { value: !0 }), Fe.uniToStrPos = Fe.strPosToUni = void 0, Fe.strPosToUni = (
|
|
285
|
-
let
|
|
284
|
+
return vt || (vt = 1, Object.defineProperty(Fe, "__esModule", { value: !0 }), Fe.uniToStrPos = Fe.strPosToUni = void 0, Fe.strPosToUni = (n, e = n.length) => {
|
|
285
|
+
let t = 0, s = 0;
|
|
286
286
|
for (; s < e; s++) {
|
|
287
|
-
const i =
|
|
288
|
-
i >= 55296 && i <= 57343 && (
|
|
287
|
+
const i = n.charCodeAt(s);
|
|
288
|
+
i >= 55296 && i <= 57343 && (t++, s++);
|
|
289
289
|
}
|
|
290
290
|
if (s !== e)
|
|
291
291
|
throw Error("Invalid offset - splits unicode bytes");
|
|
292
|
-
return s -
|
|
293
|
-
}, Fe.uniToStrPos = (
|
|
294
|
-
let
|
|
292
|
+
return s - t;
|
|
293
|
+
}, Fe.uniToStrPos = (n, e) => {
|
|
294
|
+
let t = 0;
|
|
295
295
|
for (; e > 0; e--) {
|
|
296
|
-
const s =
|
|
297
|
-
|
|
296
|
+
const s = n.charCodeAt(t);
|
|
297
|
+
t += s >= 55296 && s <= 57343 ? 2 : 1;
|
|
298
298
|
}
|
|
299
|
-
return
|
|
299
|
+
return t;
|
|
300
300
|
}), Fe;
|
|
301
301
|
}
|
|
302
302
|
var st = {}, yt;
|
|
303
303
|
function at() {
|
|
304
|
-
return yt || (yt = 1, function(
|
|
305
|
-
Object.defineProperty(
|
|
306
|
-
const e = pt(),
|
|
304
|
+
return yt || (yt = 1, function(n) {
|
|
305
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.uniSlice = n.dlen = n.eachOp = void 0;
|
|
306
|
+
const e = pt(), t = (f) => {
|
|
307
307
|
if (!Array.isArray(f))
|
|
308
308
|
throw Error("Op must be an array of components");
|
|
309
309
|
let _ = null;
|
|
@@ -313,7 +313,7 @@ function at() {
|
|
|
313
313
|
case "object":
|
|
314
314
|
if (typeof L.d != "number" && typeof L.d != "string")
|
|
315
315
|
throw Error("Delete must be number or string");
|
|
316
|
-
if (
|
|
316
|
+
if (n.dlen(L.d) <= 0)
|
|
317
317
|
throw Error("Deletes must not be empty");
|
|
318
318
|
break;
|
|
319
319
|
case "string":
|
|
@@ -338,7 +338,7 @@ function at() {
|
|
|
338
338
|
const H = f[z];
|
|
339
339
|
switch (_(H, w, L), typeof H) {
|
|
340
340
|
case "object":
|
|
341
|
-
w +=
|
|
341
|
+
w += n.dlen(H.d);
|
|
342
342
|
break;
|
|
343
343
|
case "string":
|
|
344
344
|
L += e.strPosToUni(H);
|
|
@@ -349,34 +349,34 @@ function at() {
|
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
351
|
}
|
|
352
|
-
|
|
352
|
+
n.eachOp = s;
|
|
353
353
|
function i(f, _) {
|
|
354
354
|
const w = [], L = a(w);
|
|
355
|
-
return s(f, (z, H,
|
|
356
|
-
L(_(z, H,
|
|
355
|
+
return s(f, (z, H, De) => {
|
|
356
|
+
L(_(z, H, De));
|
|
357
357
|
}), o(w);
|
|
358
358
|
}
|
|
359
359
|
const d = (f) => f, l = (f) => i(f, d);
|
|
360
|
-
|
|
360
|
+
n.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f);
|
|
361
361
|
const a = (f) => (_) => {
|
|
362
362
|
if (!(!_ || _.d === 0 || _.d === "")) if (f.length === 0)
|
|
363
363
|
f.push(_);
|
|
364
364
|
else if (typeof _ == typeof f[f.length - 1])
|
|
365
365
|
if (typeof _ == "object") {
|
|
366
366
|
const w = f[f.length - 1];
|
|
367
|
-
w.d = typeof w.d == "string" && typeof _.d == "string" ? w.d + _.d :
|
|
367
|
+
w.d = typeof w.d == "string" && typeof _.d == "string" ? w.d + _.d : n.dlen(w.d) + n.dlen(_.d);
|
|
368
368
|
} else
|
|
369
369
|
f[f.length - 1] += _;
|
|
370
370
|
else
|
|
371
371
|
f.push(_);
|
|
372
372
|
}, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
|
|
373
|
-
|
|
373
|
+
n.uniSlice = (f, _, w) => {
|
|
374
374
|
const L = e.uniToStrPos(f, _), z = w == null ? 1 / 0 : e.uniToStrPos(f, w);
|
|
375
375
|
return f.slice(L, z);
|
|
376
376
|
};
|
|
377
|
-
const W = (f, _, w) => typeof f == "number" ? w == null ? f - _ : Math.min(f, w) - _ :
|
|
377
|
+
const W = (f, _, w) => typeof f == "number" ? w == null ? f - _ : Math.min(f, w) - _ : n.uniSlice(f, _, w), O = (f) => {
|
|
378
378
|
let _ = 0, w = 0;
|
|
379
|
-
return { take: (H,
|
|
379
|
+
return { take: (H, De) => {
|
|
380
380
|
if (_ === f.length)
|
|
381
381
|
return H === -1 ? null : H;
|
|
382
382
|
const ue = f[_];
|
|
@@ -384,14 +384,14 @@ function at() {
|
|
|
384
384
|
if (typeof ue == "number")
|
|
385
385
|
return H === -1 || ue - w <= H ? (ne = ue - w, ++_, w = 0, ne) : (w += H, H);
|
|
386
386
|
if (typeof ue == "string") {
|
|
387
|
-
if (H === -1 ||
|
|
387
|
+
if (H === -1 || De === "i" || e.strPosToUni(ue.slice(w)) <= H)
|
|
388
388
|
return ne = ue.slice(w), ++_, w = 0, ne;
|
|
389
389
|
{
|
|
390
390
|
const ae = w + e.uniToStrPos(ue.slice(w), H);
|
|
391
391
|
return ne = ue.slice(w, ae), w = ae, ne;
|
|
392
392
|
}
|
|
393
393
|
} else {
|
|
394
|
-
if (H === -1 ||
|
|
394
|
+
if (H === -1 || De === "d" || n.dlen(ue.d) - w <= H)
|
|
395
395
|
return ne = { d: W(ue.d, w) }, ++_, w = 0, ne;
|
|
396
396
|
{
|
|
397
397
|
let ae = W(ue.d, w, w + H);
|
|
@@ -403,30 +403,30 @@ function at() {
|
|
|
403
403
|
function c(f, _, w) {
|
|
404
404
|
if (w !== "left" && w !== "right")
|
|
405
405
|
throw Error("side (" + w + ") must be 'left' or 'right'");
|
|
406
|
-
|
|
407
|
-
const L = [], z = a(L), { take: H, peek:
|
|
406
|
+
t(f), t(_);
|
|
407
|
+
const L = [], z = a(L), { take: H, peek: De } = O(f);
|
|
408
408
|
for (let ne = 0; ne < _.length; ne++) {
|
|
409
409
|
const ae = _[ne];
|
|
410
|
-
let ge,
|
|
410
|
+
let ge, Ae;
|
|
411
411
|
switch (typeof ae) {
|
|
412
412
|
case "number":
|
|
413
413
|
for (ge = ae; ge > 0; )
|
|
414
|
-
|
|
414
|
+
Ae = H(ge, "i"), z(Ae), typeof Ae != "string" && (ge -= E(Ae));
|
|
415
415
|
break;
|
|
416
416
|
case "string":
|
|
417
|
-
w === "left" && typeof
|
|
417
|
+
w === "left" && typeof De() == "string" && z(H(-1)), z(e.strPosToUni(ae));
|
|
418
418
|
break;
|
|
419
419
|
case "object":
|
|
420
|
-
for (ge =
|
|
421
|
-
switch (
|
|
420
|
+
for (ge = n.dlen(ae.d); ge > 0; )
|
|
421
|
+
switch (Ae = H(ge, "i"), typeof Ae) {
|
|
422
422
|
case "number":
|
|
423
|
-
ge -=
|
|
423
|
+
ge -= Ae;
|
|
424
424
|
break;
|
|
425
425
|
case "string":
|
|
426
|
-
z(
|
|
426
|
+
z(Ae);
|
|
427
427
|
break;
|
|
428
428
|
case "object":
|
|
429
|
-
ge -=
|
|
429
|
+
ge -= n.dlen(Ae.d);
|
|
430
430
|
}
|
|
431
431
|
break;
|
|
432
432
|
}
|
|
@@ -437,10 +437,10 @@ function at() {
|
|
|
437
437
|
return o(L);
|
|
438
438
|
}
|
|
439
439
|
function h(f, _) {
|
|
440
|
-
|
|
440
|
+
t(f), t(_);
|
|
441
441
|
const w = [], L = a(w), { take: z } = O(f);
|
|
442
|
-
for (let
|
|
443
|
-
const ue = _[
|
|
442
|
+
for (let De = 0; De < _.length; De++) {
|
|
443
|
+
const ue = _[De];
|
|
444
444
|
let ne, ae;
|
|
445
445
|
switch (typeof ue) {
|
|
446
446
|
case "number":
|
|
@@ -451,7 +451,7 @@ function at() {
|
|
|
451
451
|
L(ue);
|
|
452
452
|
break;
|
|
453
453
|
case "object":
|
|
454
|
-
ne =
|
|
454
|
+
ne = n.dlen(ue.d);
|
|
455
455
|
let ge = 0;
|
|
456
456
|
for (; ge < ne; )
|
|
457
457
|
switch (ae = z(ne - ge, "d"), typeof ae) {
|
|
@@ -486,7 +486,7 @@ function at() {
|
|
|
486
486
|
w += H, f += H;
|
|
487
487
|
break;
|
|
488
488
|
case "object":
|
|
489
|
-
f -= Math.min(
|
|
489
|
+
f -= Math.min(n.dlen(z.d), f - w);
|
|
490
490
|
break;
|
|
491
491
|
}
|
|
492
492
|
}
|
|
@@ -524,7 +524,7 @@ function at() {
|
|
|
524
524
|
uri: "http://sharejs.org/types/text-unicode",
|
|
525
525
|
trim: o,
|
|
526
526
|
normalize: l,
|
|
527
|
-
checkOp:
|
|
527
|
+
checkOp: t,
|
|
528
528
|
/** Create a new text snapshot.
|
|
529
529
|
*
|
|
530
530
|
* @param {string} initial - initial snapshot data. Optional. Defaults to ''.
|
|
@@ -538,7 +538,7 @@ function at() {
|
|
|
538
538
|
/** Apply an operation to a document snapshot
|
|
539
539
|
*/
|
|
540
540
|
apply(_, w) {
|
|
541
|
-
|
|
541
|
+
t(w);
|
|
542
542
|
const L = f.builder(_);
|
|
543
543
|
for (let z = 0; z < w.length; z++) {
|
|
544
544
|
const H = w[z];
|
|
@@ -550,7 +550,7 @@ function at() {
|
|
|
550
550
|
L.append(H);
|
|
551
551
|
break;
|
|
552
552
|
case "object":
|
|
553
|
-
L.del(
|
|
553
|
+
L.del(n.dlen(H.d));
|
|
554
554
|
break;
|
|
555
555
|
}
|
|
556
556
|
}
|
|
@@ -572,15 +572,15 @@ function at() {
|
|
|
572
572
|
isNoop: (_) => _.length === 0
|
|
573
573
|
};
|
|
574
574
|
}
|
|
575
|
-
|
|
575
|
+
n.default = ve;
|
|
576
576
|
}(st)), st;
|
|
577
577
|
}
|
|
578
578
|
var Qe = {}, bt;
|
|
579
579
|
function xt() {
|
|
580
580
|
if (bt) return Qe;
|
|
581
581
|
bt = 1, Object.defineProperty(Qe, "__esModule", { value: !0 });
|
|
582
|
-
const
|
|
583
|
-
function
|
|
582
|
+
const n = at(), e = pt();
|
|
583
|
+
function t(s, i) {
|
|
584
584
|
return {
|
|
585
585
|
// Returns the text content of the document
|
|
586
586
|
get: s,
|
|
@@ -602,13 +602,13 @@ function xt() {
|
|
|
602
602
|
//onInsert: function(pos, text) {},
|
|
603
603
|
//onRemove: function(pos, removedLength) {},
|
|
604
604
|
_onOp(d) {
|
|
605
|
-
|
|
605
|
+
n.eachOp(d, (l, a, E) => {
|
|
606
606
|
switch (typeof l) {
|
|
607
607
|
case "string":
|
|
608
608
|
this.onInsert && this.onInsert(E, l);
|
|
609
609
|
break;
|
|
610
610
|
case "object":
|
|
611
|
-
const W =
|
|
611
|
+
const W = n.dlen(l.d);
|
|
612
612
|
this.onRemove && this.onRemove(E, W);
|
|
613
613
|
}
|
|
614
614
|
});
|
|
@@ -617,18 +617,18 @@ function xt() {
|
|
|
617
617
|
onRemove: null
|
|
618
618
|
};
|
|
619
619
|
}
|
|
620
|
-
return Qe.default =
|
|
620
|
+
return Qe.default = t, t.provides = { text: !0 }, Qe;
|
|
621
621
|
}
|
|
622
622
|
var mt;
|
|
623
623
|
function Lt() {
|
|
624
|
-
return mt || (mt = 1, function(
|
|
624
|
+
return mt || (mt = 1, function(n) {
|
|
625
625
|
var e = Ce && Ce.__createBinding || (Object.create ? function(c, h, R, Z) {
|
|
626
626
|
Z === void 0 && (Z = R), Object.defineProperty(c, Z, { enumerable: !0, get: function() {
|
|
627
627
|
return h[R];
|
|
628
628
|
} });
|
|
629
629
|
} : function(c, h, R, Z) {
|
|
630
630
|
Z === void 0 && (Z = R), c[Z] = h[R];
|
|
631
|
-
}),
|
|
631
|
+
}), t = Ce && Ce.__setModuleDefault || (Object.create ? function(c, h) {
|
|
632
632
|
Object.defineProperty(c, "default", { enumerable: !0, value: h });
|
|
633
633
|
} : function(c, h) {
|
|
634
634
|
c.default = h;
|
|
@@ -636,11 +636,11 @@ function Lt() {
|
|
|
636
636
|
if (c && c.__esModule) return c;
|
|
637
637
|
var h = {};
|
|
638
638
|
if (c != null) for (var R in c) Object.hasOwnProperty.call(c, R) && e(h, c, R);
|
|
639
|
-
return
|
|
639
|
+
return t(h, c), h;
|
|
640
640
|
}, i = Ce && Ce.__importDefault || function(c) {
|
|
641
641
|
return c && c.__esModule ? c : { default: c };
|
|
642
642
|
};
|
|
643
|
-
Object.defineProperty(
|
|
643
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), n.type = n.remove = n.insert = void 0;
|
|
644
644
|
const d = pt(), l = s(at()), a = i(xt()), E = {
|
|
645
645
|
create(c) {
|
|
646
646
|
return c;
|
|
@@ -672,27 +672,27 @@ function Lt() {
|
|
|
672
672
|
},
|
|
673
673
|
slice: l.uniSlice
|
|
674
674
|
}, W = l.default(E), O = Object.assign(Object.assign({}, W), { api: a.default });
|
|
675
|
-
|
|
675
|
+
n.type = O, n.insert = (c, h) => h.length === 0 ? [] : c === 0 ? [h] : [c, h], n.remove = (c, h) => l.dlen(h) === 0 ? [] : c === 0 ? [{ d: h }] : [c, { d: h }];
|
|
676
676
|
var o = at();
|
|
677
|
-
Object.defineProperty(
|
|
677
|
+
Object.defineProperty(n, "makeType", { enumerable: !0, get: function() {
|
|
678
678
|
return o.default;
|
|
679
679
|
} });
|
|
680
680
|
}(it)), it;
|
|
681
681
|
}
|
|
682
|
-
(function(
|
|
682
|
+
(function(n) {
|
|
683
683
|
var e = Ce && Ce.__importDefault || function(r) {
|
|
684
684
|
return r && r.__esModule ? r : {
|
|
685
685
|
default: r
|
|
686
686
|
};
|
|
687
687
|
};
|
|
688
|
-
Object.defineProperty(
|
|
688
|
+
Object.defineProperty(n, "__esModule", {
|
|
689
689
|
value: !0
|
|
690
|
-
}),
|
|
691
|
-
const
|
|
690
|
+
}), n.editOp = n.replaceOp = n.insertOp = n.moveOp = n.removeOp = n.type = void 0;
|
|
691
|
+
const t = e(ct), s = e(dt), i = ft, d = ht;
|
|
692
692
|
function l(r, u) {
|
|
693
693
|
if (!r) throw new Error(u);
|
|
694
694
|
}
|
|
695
|
-
|
|
695
|
+
n.type = {
|
|
696
696
|
name: "json1",
|
|
697
697
|
uri: "http://sharejs.org/types/JSONv1",
|
|
698
698
|
readCursor: i.readCursor,
|
|
@@ -704,20 +704,20 @@ function Lt() {
|
|
|
704
704
|
registerSubtype: J,
|
|
705
705
|
checkValidOp: z,
|
|
706
706
|
normalize: H,
|
|
707
|
-
apply:
|
|
707
|
+
apply: De,
|
|
708
708
|
transformPosition: ue,
|
|
709
709
|
compose: ne,
|
|
710
710
|
tryTransform: nt,
|
|
711
|
-
transform:
|
|
712
|
-
makeInvertible:
|
|
711
|
+
transform: Dt,
|
|
712
|
+
makeInvertible: Ae,
|
|
713
713
|
invert: ae,
|
|
714
714
|
invertWithDoc: Et,
|
|
715
715
|
RM_UNEXPECTED_CONTENT: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
716
716
|
DROP_COLLISION: d.ConflictType.DROP_COLLISION,
|
|
717
717
|
BLACKHOLE: d.ConflictType.BLACKHOLE,
|
|
718
718
|
transformNoConflict: (r, u, y) => _t(() => !0, r, u, y),
|
|
719
|
-
typeAllowingConflictsPred: (r) => Object.assign(Object.assign({},
|
|
720
|
-
transform: (u, y,
|
|
719
|
+
typeAllowingConflictsPred: (r) => Object.assign(Object.assign({}, n.type), {
|
|
720
|
+
transform: (u, y, D) => _t(r, u, y, D)
|
|
721
721
|
})
|
|
722
722
|
};
|
|
723
723
|
const a = (r) => r ? r.getComponent() : null;
|
|
@@ -731,9 +731,9 @@ function Lt() {
|
|
|
731
731
|
function h(r, u, y) {
|
|
732
732
|
return typeof u == "number" ? (l(r != null, "Container is missing for key"), l(Array.isArray(r), "Cannot use numerical key for object container"), l(r.length >= u, "Cannot insert into out of bounds index"), r.splice(u, 0, y)) : (l(E(r), "Cannot insert into missing item"), l(r[u] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), r[u] = y), y;
|
|
733
733
|
}
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}).get(),
|
|
734
|
+
n.removeOp = (r, u = !0) => i.writeCursor().writeAtPath(r, "r", u).get(), n.moveOp = (r, u) => i.writeCursor().writeMove(r, u).get(), n.insertOp = (r, u) => i.writeCursor().writeAtPath(r, "i", u).get(), n.replaceOp = (r, u, y) => i.writeCursor().at(r, (D) => {
|
|
735
|
+
D.write("r", u), D.write("i", y);
|
|
736
|
+
}).get(), n.editOp = (r, u, y, D = !1) => i.writeCursor().at(r, (b) => _(b, u, y, D)).get();
|
|
737
737
|
const R = (r, u) => r != null && (typeof u == "number" ? Array.isArray(r) : typeof r == "object"), Z = (r, u) => R(r, u) ? r[u] : void 0, pe = {};
|
|
738
738
|
function J(r) {
|
|
739
739
|
let u = r.type ? r.type : r;
|
|
@@ -753,9 +753,9 @@ function Lt() {
|
|
|
753
753
|
invert: (r) => -r,
|
|
754
754
|
transform: (r) => r
|
|
755
755
|
});
|
|
756
|
-
const ve = (r) => r == null ? null : r.et ? Ie(r.et) : r.es ? pe["text-unicode"] : r.ena != null ? pe.number : null, f = (r) => r.es ? r.es : r.ena != null ? r.ena : r.e, _ = (r, u, y,
|
|
756
|
+
const ve = (r) => r == null ? null : r.et ? Ie(r.et) : r.es ? pe["text-unicode"] : r.ena != null ? pe.number : null, f = (r) => r.es ? r.es : r.ena != null ? r.ena : r.e, _ = (r, u, y, D = !1) => {
|
|
757
757
|
const [b, C] = typeof u == "string" ? [Ie(u), u] : [u, u.name];
|
|
758
|
-
!
|
|
758
|
+
!D && b.isNoop && b.isNoop(y) || (C === "number" ? r.write("ena", y) : C === "text-unicode" ? r.write("es", y) : (r.write("et", C), r.write("e", y)));
|
|
759
759
|
};
|
|
760
760
|
function w(r) {
|
|
761
761
|
l(typeof r == "number"), l(r >= 0), l(r === (0 | r));
|
|
@@ -765,7 +765,7 @@ function Lt() {
|
|
|
765
765
|
}
|
|
766
766
|
function z(r) {
|
|
767
767
|
if (r === null) return;
|
|
768
|
-
const u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(),
|
|
768
|
+
const u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), D = (C) => {
|
|
769
769
|
let $ = !0, j = !1;
|
|
770
770
|
for (let p in C) {
|
|
771
771
|
const v = C[p];
|
|
@@ -792,7 +792,7 @@ function Lt() {
|
|
|
792
792
|
g === N ? l(m < G, "descent keys are not in order") : l(g === "number" && N === "string");
|
|
793
793
|
}
|
|
794
794
|
m = G, v++, p = 3;
|
|
795
|
-
} else typeof T == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`),
|
|
795
|
+
} else typeof T == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`), D(T), p = 2) : (l(p !== 3), L(T), l(i.isValidPathItem(T), "Invalid path key"), p = 1);
|
|
796
796
|
}
|
|
797
797
|
return l(v !== 1, "Operation makes multiple descents. Remove some []"), l(p === 2 || p === 3), C[0];
|
|
798
798
|
};
|
|
@@ -801,8 +801,8 @@ function Lt() {
|
|
|
801
801
|
}
|
|
802
802
|
function H(r) {
|
|
803
803
|
let u = 0, y = [];
|
|
804
|
-
const
|
|
805
|
-
return
|
|
804
|
+
const D = i.writeCursor();
|
|
805
|
+
return D.mergeTree(r, (b, C) => {
|
|
806
806
|
const $ = ve(b);
|
|
807
807
|
if ($) {
|
|
808
808
|
const p = f(b);
|
|
@@ -813,12 +813,12 @@ function Lt() {
|
|
|
813
813
|
C.write(p, v);
|
|
814
814
|
}
|
|
815
815
|
var j;
|
|
816
|
-
}),
|
|
816
|
+
}), D.get();
|
|
817
817
|
}
|
|
818
|
-
function
|
|
818
|
+
function De(r, u) {
|
|
819
819
|
if (z(u), u === null) return r;
|
|
820
820
|
const y = [];
|
|
821
|
-
return function
|
|
821
|
+
return function D(b, C) {
|
|
822
822
|
let $ = b, j = 0, p = {
|
|
823
823
|
root: b
|
|
824
824
|
}, v = 0, m = p, I = "root";
|
|
@@ -831,7 +831,7 @@ function Lt() {
|
|
|
831
831
|
for (; j < C.length; j++) {
|
|
832
832
|
const G = C[j];
|
|
833
833
|
if (Array.isArray(G)) {
|
|
834
|
-
const g =
|
|
834
|
+
const g = D($, G);
|
|
835
835
|
g !== $ && g !== void 0 && (T(), $ = m[I] = g);
|
|
836
836
|
} else if (typeof G == "object") {
|
|
837
837
|
G.d != null ? (T(), $ = h(m, I, y[G.d])) : G.i !== void 0 && (T(), $ = h(m, I, G.i));
|
|
@@ -841,7 +841,7 @@ function Lt() {
|
|
|
841
841
|
} else $ = Z($, G);
|
|
842
842
|
}
|
|
843
843
|
return p.root;
|
|
844
|
-
}(r = function
|
|
844
|
+
}(r = function D(b, C) {
|
|
845
845
|
const $ = [];
|
|
846
846
|
let j = 0;
|
|
847
847
|
for (; j < C.length; j++) {
|
|
@@ -849,7 +849,7 @@ function Lt() {
|
|
|
849
849
|
if (Array.isArray(I)) break;
|
|
850
850
|
typeof I != "object" && ($.push(b), b = Z(b, I));
|
|
851
851
|
}
|
|
852
|
-
for (let I = C.length - 1; I >= j; I--) b =
|
|
852
|
+
for (let I = C.length - 1; I >= j; I--) b = D(b, C[I]);
|
|
853
853
|
for (--j; j >= 0; j--) {
|
|
854
854
|
const I = C[j];
|
|
855
855
|
if (typeof I != "object") {
|
|
@@ -864,11 +864,11 @@ function Lt() {
|
|
|
864
864
|
function ue(r, u) {
|
|
865
865
|
r = r.slice(), z(u);
|
|
866
866
|
const y = i.readCursor(u);
|
|
867
|
-
let
|
|
867
|
+
let D, b, C = !1;
|
|
868
868
|
const $ = [];
|
|
869
869
|
for (let p = 0; ; p++) {
|
|
870
870
|
const v = r[p], m = y.getComponent();
|
|
871
|
-
if (m && (m.r !== void 0 ? C = !0 : m.p != null && (C = !1,
|
|
871
|
+
if (m && (m.r !== void 0 ? C = !0 : m.p != null && (C = !1, D = m.p, b = p)), p >= r.length) break;
|
|
872
872
|
let I = 0;
|
|
873
873
|
const T = i.advancer(y, void 0, (g, N) => {
|
|
874
874
|
O(N) && I++;
|
|
@@ -880,7 +880,7 @@ function Lt() {
|
|
|
880
880
|
if ($.forEach((p) => p.end()), C) return null;
|
|
881
881
|
const j = () => {
|
|
882
882
|
let p = 0;
|
|
883
|
-
if (
|
|
883
|
+
if (D != null) {
|
|
884
884
|
const v = y.getPath();
|
|
885
885
|
p = v.length, r = v.concat(r.slice(b));
|
|
886
886
|
}
|
|
@@ -898,80 +898,80 @@ function Lt() {
|
|
|
898
898
|
if (typeof v == "number" && (r[p] += T), !G) break;
|
|
899
899
|
}
|
|
900
900
|
};
|
|
901
|
-
return
|
|
902
|
-
p ===
|
|
901
|
+
return D != null ? y.eachDrop(null, (p) => {
|
|
902
|
+
p === D && j();
|
|
903
903
|
}) : j(), r;
|
|
904
904
|
}
|
|
905
905
|
function ne(r, u) {
|
|
906
906
|
if (z(r), z(u), r == null) return u;
|
|
907
907
|
if (u == null) return r;
|
|
908
908
|
let y = 0;
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
g.p != null && (p[g.p] =
|
|
909
|
+
const D = i.readCursor(r), b = i.readCursor(u), C = i.writeCursor(), $ = [], j = [], p = [], v = [], m = [], I = [], T = /* @__PURE__ */ new Set();
|
|
910
|
+
D.traverse(null, (g) => {
|
|
911
|
+
g.p != null && (p[g.p] = D.clone());
|
|
912
912
|
}), b.traverse(null, (g) => {
|
|
913
913
|
g.d != null && (v[g.d] = b.clone());
|
|
914
914
|
});
|
|
915
915
|
const G = i.writeCursor();
|
|
916
916
|
return function g(N, re, te, K, se, Te, be, _e) {
|
|
917
917
|
l(re || te);
|
|
918
|
-
const oe = a(re),
|
|
918
|
+
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;
|
|
919
919
|
if (Ee != null) K = v[Ee], be = j[Ee] = new i.WriteCursor();
|
|
920
|
-
else if (
|
|
920
|
+
else if (Pe && Pe.r !== void 0) K = null;
|
|
921
921
|
else {
|
|
922
|
-
const
|
|
923
|
-
|
|
922
|
+
const P = a(K);
|
|
923
|
+
P && P.d != null && (K = null);
|
|
924
924
|
}
|
|
925
925
|
const Q = a(K);
|
|
926
926
|
if (Ue != null) if (N = p[Ue], _e = $[Ue] = new i.WriteCursor(), $e) Te && !Me && _e.write("r", !0);
|
|
927
927
|
else {
|
|
928
|
-
const
|
|
929
|
-
be.write("d",
|
|
928
|
+
const P = m[Ue] = y++;
|
|
929
|
+
be.write("d", P);
|
|
930
930
|
}
|
|
931
931
|
else if (oe && oe.i !== void 0) N = null;
|
|
932
932
|
else {
|
|
933
|
-
const
|
|
934
|
-
|
|
933
|
+
const P = a(N);
|
|
934
|
+
P && P.p != null && (N = null);
|
|
935
935
|
}
|
|
936
936
|
let U;
|
|
937
937
|
Le ? (l(se === void 0), U = oe.i) : U = se;
|
|
938
938
|
const B = (Ee == null ? !Le || Te || Me : U === void 0) ? null : be.getComponent();
|
|
939
939
|
if (Ee != null) {
|
|
940
940
|
if (!(se !== void 0 || Le)) {
|
|
941
|
-
const
|
|
942
|
-
I[Ee] =
|
|
941
|
+
const P = Ue != null ? m[Ue] : y++;
|
|
942
|
+
I[Ee] = P, _e.write("p", P);
|
|
943
943
|
}
|
|
944
|
-
} else Me && (Le || se !== void 0 || (
|
|
945
|
-
const M = $e ? null : ve(oe),
|
|
946
|
-
if ((M ||
|
|
947
|
-
l(M ===
|
|
948
|
-
const
|
|
944
|
+
} else Me && (Le || se !== void 0 || (Pe.r, _e.write("r", Pe.r)));
|
|
945
|
+
const M = $e ? null : ve(oe), A = ve(Q);
|
|
946
|
+
if ((M || A) && (M && M.name, A && A.name), M && A) {
|
|
947
|
+
l(M === A);
|
|
948
|
+
const P = f(oe), x = f(Q), he = M.compose(P, x);
|
|
949
949
|
_(be, M, he), T.add(Q);
|
|
950
|
-
} else M ? _(be, M, f(oe)) :
|
|
950
|
+
} else M ? _(be, M, f(oe)) : A && (_(be, A, f(Q)), T.add(Q));
|
|
951
951
|
const k = typeof U == "object" && U != null;
|
|
952
952
|
let X = !1, Y = 0, ee = 0, fe = 0, de = 0, le = 0;
|
|
953
|
-
const ye = i.advancer(K, (
|
|
953
|
+
const ye = i.advancer(K, (P, x) => o(x) ? de - P - 1 : P - de, (P, x) => {
|
|
954
954
|
o(x) && de++;
|
|
955
|
-
}), q = i.advancer(N, (
|
|
955
|
+
}), q = i.advancer(N, (P, x) => O(x) ? Y - P - 1 : P - Y, (P, x) => {
|
|
956
956
|
O(x) && Y++;
|
|
957
957
|
});
|
|
958
|
-
if (i.eachChildOf(re, te, (
|
|
959
|
-
let me, We, He =
|
|
960
|
-
if (typeof
|
|
961
|
-
let Oe =
|
|
958
|
+
if (i.eachChildOf(re, te, (P, x, he) => {
|
|
959
|
+
let me, We, He = P, Ne = P, Ye = P;
|
|
960
|
+
if (typeof P == "number") {
|
|
961
|
+
let Oe = P + fe;
|
|
962
962
|
We = ye(Oe), Ne = Oe + de;
|
|
963
|
-
let ce =
|
|
964
|
-
me = q(ce), o(a(We)) && (me = null), He = ce + Y, Ye =
|
|
963
|
+
let ce = P + ee;
|
|
964
|
+
me = q(ce), o(a(We)) && (me = null), He = ce + Y, Ye = P + le, l(He >= 0, "p1PickKey is negative"), l(Ne >= 0, "p2DropKey is negative");
|
|
965
965
|
const ke = o(a(x)), Ge = O(a(he));
|
|
966
966
|
(ke || Ge && !$e) && le--, ke && ee--, Ge && fe--;
|
|
967
|
-
} else me = q(
|
|
967
|
+
} else me = q(P), We = ye(P);
|
|
968
968
|
_e.descend(He), be.descend(Ne);
|
|
969
969
|
const ze = k && !o(a(x)) ? U[Ye] : void 0, Se = g(me, x, he, We, ze, $e, be, _e);
|
|
970
970
|
var je, S, ie;
|
|
971
971
|
k && !$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), be.ascend(), _e.ascend();
|
|
972
972
|
}), q.end(), ye.end(), B != null) B.i = U;
|
|
973
973
|
else if (!Te && !Me && Ee == null) return U;
|
|
974
|
-
}(
|
|
974
|
+
}(D, D.clone(), b, b.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) => {
|
|
975
975
|
const re = g.p;
|
|
976
976
|
if (re != null) {
|
|
977
977
|
const te = m[re];
|
|
@@ -994,7 +994,7 @@ function Lt() {
|
|
|
994
994
|
function ae(r) {
|
|
995
995
|
if (r == null) return null;
|
|
996
996
|
const u = new i.ReadCursor(r), y = new i.WriteCursor();
|
|
997
|
-
let
|
|
997
|
+
let D;
|
|
998
998
|
const b = [], C = [];
|
|
999
999
|
return function $(j, p, v) {
|
|
1000
1000
|
const m = j.getComponent();
|
|
@@ -1002,7 +1002,7 @@ function Lt() {
|
|
|
1002
1002
|
if (m) {
|
|
1003
1003
|
m.p != null && (p.write("d", m.p), b[m.p] = j.clone()), m.r !== void 0 && p.write("i", m.r), m.d != null && (p.write("p", m.d), v = void 0), m.i !== void 0 && (v = I = m.i);
|
|
1004
1004
|
const g = ve(m);
|
|
1005
|
-
g && (v === void 0 ? (
|
|
1005
|
+
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(m)) : (f(m), v = g.apply(v, f(m)), T = !0));
|
|
1006
1006
|
}
|
|
1007
1007
|
let G = 0;
|
|
1008
1008
|
for (const g of j) {
|
|
@@ -1018,11 +1018,11 @@ function Lt() {
|
|
|
1018
1018
|
}
|
|
1019
1019
|
if (I === void 0) return T ? v : void 0;
|
|
1020
1020
|
p.write("r", v);
|
|
1021
|
-
}(u, y, void 0),
|
|
1021
|
+
}(u, y, void 0), D && (y.reset(), function $(j, p, v) {
|
|
1022
1022
|
const m = p.getComponent();
|
|
1023
1023
|
if (m) {
|
|
1024
1024
|
const g = m.d;
|
|
1025
|
-
if (g != null && (j = b[g], v = C[g] = i.writeCursor()),
|
|
1025
|
+
if (g != null && (j = b[g], v = C[g] = i.writeCursor()), D.has(m)) {
|
|
1026
1026
|
const N = ve(m);
|
|
1027
1027
|
if (!N.invert) throw Error(`Cannot invert subtype ${N.name}`);
|
|
1028
1028
|
_(v, N, N.invert(f(m)));
|
|
@@ -1046,12 +1046,12 @@ function Lt() {
|
|
|
1046
1046
|
}))), y.get();
|
|
1047
1047
|
}
|
|
1048
1048
|
const ge = (r, u) => r.some((y) => typeof y == "object" && (Array.isArray(y) ? ge(y, u) : u(y)));
|
|
1049
|
-
function
|
|
1049
|
+
function Ae(r, u) {
|
|
1050
1050
|
if (r == null || !ge(r, (p) => {
|
|
1051
1051
|
var v;
|
|
1052
1052
|
return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
|
|
1053
1053
|
})) return r;
|
|
1054
|
-
const y = new i.ReadCursor(r),
|
|
1054
|
+
const y = new i.ReadCursor(r), D = new i.WriteCursor();
|
|
1055
1055
|
let b = !1;
|
|
1056
1056
|
const C = [], $ = [], j = (p, v, m) => {
|
|
1057
1057
|
const I = p.getComponent();
|
|
@@ -1071,7 +1071,7 @@ function Lt() {
|
|
|
1071
1071
|
}
|
|
1072
1072
|
return I && (I.r !== void 0 ? (v.write("r", s.default(m)), m = void 0) : I.p != null && (m = void 0)), m;
|
|
1073
1073
|
};
|
|
1074
|
-
return j(y,
|
|
1074
|
+
return j(y, D, u), D.get(), b && (D.reset(), function p(v, m, I, T, G) {
|
|
1075
1075
|
const g = m.getComponent();
|
|
1076
1076
|
if (g) {
|
|
1077
1077
|
g.i !== void 0 ? (T = g.i, G = !0) : g.d != null && (T = $[g.d], v = C[g.d], G = !1, g.d);
|
|
@@ -1093,23 +1093,23 @@ function Lt() {
|
|
|
1093
1093
|
I.descend(K), p(te(K), m, I, se, G), I.ascend();
|
|
1094
1094
|
}
|
|
1095
1095
|
te.end();
|
|
1096
|
-
}(y.clone(), y,
|
|
1096
|
+
}(y.clone(), y, D, u, !1)), D.get();
|
|
1097
1097
|
}
|
|
1098
1098
|
function Et(r, u) {
|
|
1099
|
-
return ae(
|
|
1099
|
+
return ae(Ae(r, u));
|
|
1100
1100
|
}
|
|
1101
1101
|
const tt = (r) => {
|
|
1102
1102
|
if (r == null) return null;
|
|
1103
1103
|
const u = r.slice();
|
|
1104
1104
|
for (let y = 0; y < r.length; y++) {
|
|
1105
|
-
const
|
|
1106
|
-
Array.isArray(
|
|
1105
|
+
const D = u[y];
|
|
1106
|
+
Array.isArray(D) && (u[y] = tt(D));
|
|
1107
1107
|
}
|
|
1108
1108
|
return u;
|
|
1109
1109
|
};
|
|
1110
1110
|
function nt(r, u, y) {
|
|
1111
1111
|
l(y === "left" || y === "right", "Direction must be left or right");
|
|
1112
|
-
const
|
|
1112
|
+
const D = y === "left" ? 0 : 1;
|
|
1113
1113
|
if (u == null) return {
|
|
1114
1114
|
ok: !0,
|
|
1115
1115
|
result: r
|
|
@@ -1120,121 +1120,121 @@ function Lt() {
|
|
|
1120
1120
|
let Te = 0;
|
|
1121
1121
|
const be = i.readCursor(r), _e = i.readCursor(u), oe = i.writeCursor();
|
|
1122
1122
|
if (function Q(U, B = null, M) {
|
|
1123
|
-
const
|
|
1124
|
-
|
|
1123
|
+
const A = a(B);
|
|
1124
|
+
A && (A.r !== void 0 ? M = B.clone() : A.p != null && (M = null, m[A.p] = U.clone()));
|
|
1125
1125
|
const k = U.getComponent();
|
|
1126
1126
|
let X;
|
|
1127
|
-
k && (X = k.p) != null && (v[X] = B ? B.clone() : null, j[X] = U.clone(), M && (g[X] = !0, G[X] = M),
|
|
1127
|
+
k && (X = k.p) != null && (v[X] = B ? B.clone() : null, j[X] = U.clone(), M && (g[X] = !0, G[X] = M), A && A.p != null && (K[X] = A.p));
|
|
1128
1128
|
const Y = i.advancer(B);
|
|
1129
1129
|
for (const ee of U) Q(U, Y(ee), M);
|
|
1130
1130
|
Y.end();
|
|
1131
|
-
}(_e, be, null), function Q(U, B, M,
|
|
1131
|
+
}(_e, be, null), function Q(U, B, M, A, k) {
|
|
1132
1132
|
const X = M.getComponent();
|
|
1133
1133
|
let Y, ee = !1;
|
|
1134
|
-
X && ((Y = X.d) != null ? (p[Y] = M.clone(),
|
|
1134
|
+
X && ((Y = X.d) != null ? (p[Y] = M.clone(), A != null && (se[A] == null && (se[A] = []), se[A].push(Y)), U = v[Y] || null, B = j[Y] || null, g[Y] ? (k && (N[Y] = !0), k = G[Y] || null) : !k || D !== 1 && K[Y] != null || b == null && (b = {
|
|
1135
1135
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1136
|
-
op1:
|
|
1137
|
-
op2:
|
|
1136
|
+
op1: n.removeOp(k.getPath()),
|
|
1137
|
+
op2: n.moveOp(B.getPath(), M.getPath())
|
|
1138
1138
|
}), ee = !0) : X.i !== void 0 && (U = B = null, ee = !0, k && b == null && (b = {
|
|
1139
1139
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1140
|
-
op1:
|
|
1141
|
-
op2:
|
|
1140
|
+
op1: n.removeOp(k.getPath()),
|
|
1141
|
+
op2: n.insertOp(M.getPath(), X.i)
|
|
1142
1142
|
})));
|
|
1143
1143
|
const fe = a(U);
|
|
1144
|
-
fe && (fe.r !== void 0 ? k = U.clone() : fe.p != null && (fe.p,
|
|
1144
|
+
fe && (fe.r !== void 0 ? k = U.clone() : fe.p != null && (fe.p, A = fe.p, k = null));
|
|
1145
1145
|
const de = ve(X);
|
|
1146
1146
|
de && k && b == null && (b = {
|
|
1147
1147
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1148
|
-
op1:
|
|
1149
|
-
op2:
|
|
1148
|
+
op1: n.removeOp(k.getPath()),
|
|
1149
|
+
op2: n.editOp(M.getPath(), de, f(X), !0)
|
|
1150
1150
|
});
|
|
1151
1151
|
let le = 0, ye = 0;
|
|
1152
1152
|
const q = i.advancer(B, (x, he) => O(he) ? le - x - 1 : x - le, (x, he) => {
|
|
1153
1153
|
O(he) && le++;
|
|
1154
|
-
}),
|
|
1154
|
+
}), P = i.advancer(U);
|
|
1155
1155
|
for (const x of M) if (typeof x == "number") {
|
|
1156
1156
|
const he = x - ye, me = q(he);
|
|
1157
|
-
ye += +Q(
|
|
1157
|
+
ye += +Q(P(he + le), me, M, A, k);
|
|
1158
1158
|
} else {
|
|
1159
1159
|
const he = q(x);
|
|
1160
|
-
Q(
|
|
1160
|
+
Q(P(x), he, M, A, k);
|
|
1161
1161
|
}
|
|
1162
|
-
return q.end(),
|
|
1162
|
+
return q.end(), P.end(), ee;
|
|
1163
1163
|
}(be, _e, _e.clone(), null, null), p.map((Q) => Q && Q.get()), b) return {
|
|
1164
1164
|
ok: !1,
|
|
1165
1165
|
conflict: b
|
|
1166
1166
|
};
|
|
1167
1167
|
N.map((Q) => !!Q);
|
|
1168
|
-
const
|
|
1168
|
+
const Pe = [];
|
|
1169
1169
|
let Me = null;
|
|
1170
|
-
(function Q(U, B, M,
|
|
1170
|
+
(function Q(U, B, M, A, k) {
|
|
1171
1171
|
let X = !1;
|
|
1172
1172
|
const Y = a(B);
|
|
1173
1173
|
if (O(Y)) {
|
|
1174
1174
|
const q = Y.p;
|
|
1175
|
-
q != null ? (M = p[q],
|
|
1175
|
+
q != null ? (M = p[q], A = re[q] = i.writeCursor(), X = !0, k = null) : (M = null, k = B.clone());
|
|
1176
1176
|
} else o(a(M)) && (M = null);
|
|
1177
1177
|
const ee = U.getComponent();
|
|
1178
1178
|
if (ee) {
|
|
1179
1179
|
const q = ee.p;
|
|
1180
|
-
q != null ? (k && (T[q] = k),
|
|
1180
|
+
q != null ? (k && (T[q] = k), Pe[q] = k || D === 1 && X ? null : A.getComponent(), C[q] = U.clone(), M && (I[q] = M.clone())) : ee.r !== void 0 && (k || A.write("r", !0), (k || X) && (Me == null && (Me = /* @__PURE__ */ new Set()), Me.add(ee)));
|
|
1181
1181
|
}
|
|
1182
1182
|
let fe = 0, de = 0;
|
|
1183
|
-
const le = i.advancer(B, void 0, (q,
|
|
1184
|
-
O(
|
|
1185
|
-
}), ye = i.advancer(M, (q,
|
|
1186
|
-
o(
|
|
1183
|
+
const le = i.advancer(B, void 0, (q, P) => {
|
|
1184
|
+
O(P) && fe++;
|
|
1185
|
+
}), ye = i.advancer(M, (q, P) => o(P) ? ~(q - de) : q - de, (q, P) => {
|
|
1186
|
+
o(P) && de++;
|
|
1187
1187
|
});
|
|
1188
1188
|
if (U) for (const q of U) if (typeof q == "string") {
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1189
|
+
const P = le(q), x = ye(q);
|
|
1190
|
+
A.descend(q), Q(U, P, x, A, k), A.ascend();
|
|
1191
1191
|
} else {
|
|
1192
|
-
const
|
|
1193
|
-
l(me >= 0),
|
|
1192
|
+
const P = le(q), x = q - fe, he = O(a(P)) ? null : ye(x), me = x + de;
|
|
1193
|
+
l(me >= 0), A.descend(me), Q(U, P, he, A, k), A.ascend();
|
|
1194
1194
|
}
|
|
1195
1195
|
le.end(), ye.end();
|
|
1196
1196
|
})(be, _e, _e.clone(), oe, null), oe.reset();
|
|
1197
1197
|
let Le = [];
|
|
1198
|
-
if (function Q(U, B, M,
|
|
1198
|
+
if (function Q(U, B, M, A, k, X) {
|
|
1199
1199
|
l(B);
|
|
1200
1200
|
const Y = B.getComponent();
|
|
1201
|
-
let ee = a(
|
|
1202
|
-
const de = (S, ie, Oe) => S ?
|
|
1201
|
+
let ee = a(A), fe = !1;
|
|
1202
|
+
const de = (S, ie, Oe) => S ? n.moveOp(S.getPath(), ie.getPath()) : n.insertOp(ie.getPath(), Oe.i);
|
|
1203
1203
|
if (o(Y)) {
|
|
1204
1204
|
const S = Y.d;
|
|
1205
1205
|
S != null && ($[S] = B.clone());
|
|
1206
|
-
const ie = S != null ?
|
|
1206
|
+
const ie = S != null ? Pe[S] : null;
|
|
1207
1207
|
let Oe = !1;
|
|
1208
1208
|
if (Y.i !== void 0 || S != null && ie) {
|
|
1209
1209
|
let ce;
|
|
1210
|
-
ee && (ee.i !== void 0 || (ce = ee.d) != null && !g[ce]) && (Oe = ce != null ? S != null && S === K[ce] :
|
|
1210
|
+
ee && (ee.i !== void 0 || (ce = ee.d) != null && !g[ce]) && (Oe = ce != null ? S != null && S === K[ce] : t.default(ee.i, Y.i), Oe || ce != null && D !== 1 && K[ce] != null || b == null && (b = {
|
|
1211
1211
|
type: d.ConflictType.DROP_COLLISION,
|
|
1212
1212
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1213
|
-
op2: de(ce != null ? j[ce] : null,
|
|
1213
|
+
op2: de(ce != null ? j[ce] : null, A, ee)
|
|
1214
1214
|
})), Oe || (X ? b == null && (b = {
|
|
1215
1215
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1216
1216
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1217
|
-
op2:
|
|
1217
|
+
op2: n.removeOp(X.getPath())
|
|
1218
1218
|
}) : (S != null ? (Le[Te] = S, k.write("d", ie.p = Te++)) : k.write("i", s.default(Y.i)), fe = !0));
|
|
1219
1219
|
} else if (S != null && !ie) {
|
|
1220
1220
|
const ce = T[S];
|
|
1221
1221
|
ce && (X = ce.clone());
|
|
1222
1222
|
}
|
|
1223
|
-
S != null ? (U = C[S], M = m[S],
|
|
1224
|
-
} else O(a(U)) && (U = M =
|
|
1223
|
+
S != null ? (U = C[S], M = m[S], A = I[S]) : Y.i !== void 0 && (U = M = null, Oe || (A = null));
|
|
1224
|
+
} else O(a(U)) && (U = M = A = null);
|
|
1225
1225
|
const le = a(U), ye = a(M);
|
|
1226
1226
|
if (O(ye)) {
|
|
1227
1227
|
const S = ye.p;
|
|
1228
|
-
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (
|
|
1229
|
-
} else !o(Y) && o(ee) && (
|
|
1230
|
-
ee =
|
|
1228
|
+
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 || ((k = te[S]) || (k = te[S] = i.writeCursor()), k.reset(), X = null));
|
|
1229
|
+
} else !o(Y) && o(ee) && (A = null);
|
|
1230
|
+
ee = A != null ? A.getComponent() : null;
|
|
1231
1231
|
const q = ve(Y);
|
|
1232
1232
|
if (q) {
|
|
1233
1233
|
const S = f(Y);
|
|
1234
1234
|
if (X) b == null && (b = {
|
|
1235
1235
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1236
|
-
op1:
|
|
1237
|
-
op2:
|
|
1236
|
+
op1: n.editOp(B.getPath(), q, S, !0),
|
|
1237
|
+
op2: n.removeOp(X.getPath())
|
|
1238
1238
|
});
|
|
1239
1239
|
else {
|
|
1240
1240
|
const ie = ve(ee);
|
|
@@ -1247,58 +1247,58 @@ function Lt() {
|
|
|
1247
1247
|
_(k, q, Oe);
|
|
1248
1248
|
}
|
|
1249
1249
|
}
|
|
1250
|
-
let
|
|
1250
|
+
let P = 0, x = 0, he = 0, me = 0, We = 0, He = 0, Ne = U != null && U.descendFirst(), Ye = Ne;
|
|
1251
1251
|
const ze = i.advancer(M, void 0, (S, ie) => {
|
|
1252
1252
|
O(ie) && he++;
|
|
1253
1253
|
});
|
|
1254
|
-
let Se =
|
|
1254
|
+
let Se = A != null && A.descendFirst(), je = Se;
|
|
1255
1255
|
for (const S of B) if (typeof S == "number") {
|
|
1256
1256
|
let ie;
|
|
1257
1257
|
const Oe = o(B.getComponent()), ce = S - x;
|
|
1258
1258
|
{
|
|
1259
1259
|
let Be;
|
|
1260
1260
|
for (; Ne && typeof (Be = U.getKey()) == "number"; ) {
|
|
1261
|
-
Be +=
|
|
1261
|
+
Be += P;
|
|
1262
1262
|
const Re = U.getComponent(), Xe = O(Re);
|
|
1263
|
-
if (Be > ce || Be === ce && (!Xe ||
|
|
1263
|
+
if (Be > ce || Be === ce && (!Xe || D === 0 && Oe)) break;
|
|
1264
1264
|
if (Xe) {
|
|
1265
|
-
|
|
1265
|
+
P--;
|
|
1266
1266
|
const Ke = Re.p;
|
|
1267
|
-
K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Me && Me.has(Re)) && (Ke == null || !
|
|
1267
|
+
K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Me && Me.has(Re)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || We--;
|
|
1268
1268
|
}
|
|
1269
1269
|
Ne = U.nextSibling();
|
|
1270
1270
|
}
|
|
1271
1271
|
ie = Ne && Be === ce ? U : null;
|
|
1272
1272
|
}
|
|
1273
|
-
const ke = ce -
|
|
1273
|
+
const ke = ce - P;
|
|
1274
1274
|
let Ge = ze(ke);
|
|
1275
1275
|
const rt = ke - he;
|
|
1276
1276
|
let Je = null;
|
|
1277
1277
|
{
|
|
1278
1278
|
let Be, Re;
|
|
1279
|
-
for (; Se && typeof (Be =
|
|
1279
|
+
for (; Se && typeof (Be = A.getKey()) == "number"; ) {
|
|
1280
1280
|
Re = Be - me;
|
|
1281
|
-
const Xe =
|
|
1281
|
+
const Xe = A.getComponent(), Ke = o(Xe);
|
|
1282
1282
|
if (Re > rt) break;
|
|
1283
1283
|
if (Re === rt) {
|
|
1284
1284
|
if (!Ke) {
|
|
1285
|
-
Je =
|
|
1285
|
+
Je = A;
|
|
1286
1286
|
break;
|
|
1287
1287
|
}
|
|
1288
1288
|
{
|
|
1289
|
-
if (
|
|
1290
|
-
Je =
|
|
1289
|
+
if (D === 0 && Oe) {
|
|
1290
|
+
Je = A;
|
|
1291
1291
|
break;
|
|
1292
1292
|
}
|
|
1293
1293
|
const Ve = Ge && O(Ge.getComponent());
|
|
1294
|
-
if (
|
|
1294
|
+
if (D === 0 && Ve) break;
|
|
1295
1295
|
}
|
|
1296
1296
|
}
|
|
1297
1297
|
if (Ke) {
|
|
1298
1298
|
const Ve = Xe.d;
|
|
1299
|
-
K[Ve], Xe.i === void 0 && (g[Ve] || K[Ve] != null &&
|
|
1299
|
+
K[Ve], Xe.i === void 0 && (g[Ve] || K[Ve] != null && D !== 1) ? (g[Ve] || K[Ve] != null && D === 0) && (me++, He--) : me++;
|
|
1300
1300
|
}
|
|
1301
|
-
Se =
|
|
1301
|
+
Se = A.nextSibling();
|
|
1302
1302
|
}
|
|
1303
1303
|
}
|
|
1304
1304
|
const Ot = rt + me + We + He;
|
|
@@ -1308,18 +1308,18 @@ function Lt() {
|
|
|
1308
1308
|
for (; Ne && (ie = U.getKey(), typeof ie != "string" || !(ie > S || ie === S)); ) Ne = U.nextSibling();
|
|
1309
1309
|
const Oe = Ne && ie === S ? U : null, ce = ze(S);
|
|
1310
1310
|
let ke;
|
|
1311
|
-
for (; Se && (ke =
|
|
1312
|
-
const Ge = Se && ke === S ?
|
|
1311
|
+
for (; Se && (ke = A.getKey(), typeof ke != "string" || !(ke > S || ke === S)); ) Se = A.nextSibling();
|
|
1312
|
+
const Ge = Se && ke === S ? A : null;
|
|
1313
1313
|
k.descend(S), Q(Oe, B, ce, Ge, k, X), k.ascend();
|
|
1314
1314
|
}
|
|
1315
|
-
return ze.end(), Ye && U.ascend(), je &&
|
|
1315
|
+
return ze.end(), Ye && U.ascend(), je && A.ascend(), fe;
|
|
1316
1316
|
}(be, be.clone(), _e, _e.clone(), oe, null), b) return {
|
|
1317
1317
|
ok: !1,
|
|
1318
1318
|
conflict: b
|
|
1319
1319
|
};
|
|
1320
1320
|
oe.reset();
|
|
1321
|
-
const Ue = (Q, U, B) => Q.traverse(U, (M,
|
|
1322
|
-
M.d != null && B(M.d, Q,
|
|
1321
|
+
const Ue = (Q, U, B) => Q.traverse(U, (M, A) => {
|
|
1322
|
+
M.d != null && B(M.d, Q, A);
|
|
1323
1323
|
});
|
|
1324
1324
|
(g.length || re.length) && (Ue(_e, oe, (Q, U, B) => {
|
|
1325
1325
|
g[Q] && !N[Q] && B.write("r", !0), re[Q] && B.mergeTree(re[Q].get());
|
|
@@ -1333,31 +1333,31 @@ function Lt() {
|
|
|
1333
1333
|
U && Ue(i.readCursor(U.get()), null, (B, M) => {
|
|
1334
1334
|
Ee[B] = M.clone();
|
|
1335
1335
|
});
|
|
1336
|
-
}), function U(B, M,
|
|
1336
|
+
}), function U(B, M, A, k, X, Y) {
|
|
1337
1337
|
const ee = a(M);
|
|
1338
1338
|
if (ee && O(ee)) if (ee.p != null) {
|
|
1339
|
-
const
|
|
1340
|
-
Ee[
|
|
1341
|
-
} else ee.r !== void 0 && (
|
|
1342
|
-
else o(a(
|
|
1339
|
+
const P = ee.p;
|
|
1340
|
+
Ee[P].getPath(), A = Ee[P], k = $e[P] = i.writeCursor();
|
|
1341
|
+
} else ee.r !== void 0 && (A = null);
|
|
1342
|
+
else o(a(A)) && (A = null);
|
|
1343
1343
|
const fe = B.getComponent();
|
|
1344
1344
|
if (fe) {
|
|
1345
|
-
let
|
|
1346
|
-
if ((
|
|
1347
|
-
const x = te[
|
|
1348
|
-
x && (x.get(), k.mergeTree(x.get()),
|
|
1345
|
+
let P;
|
|
1346
|
+
if ((P = fe.d) != null) {
|
|
1347
|
+
const x = te[P];
|
|
1348
|
+
x && (x.get(), k.mergeTree(x.get()), A = i.readCursor(x.get()));
|
|
1349
1349
|
}
|
|
1350
1350
|
}
|
|
1351
1351
|
let de = 0, le = 0;
|
|
1352
|
-
const ye = i.advancer(M, void 0, (
|
|
1352
|
+
const ye = i.advancer(M, void 0, (P, x) => {
|
|
1353
1353
|
O(x) && de--;
|
|
1354
|
-
}), q = i.advancer(
|
|
1354
|
+
}), q = i.advancer(A, (P, x) => o(x) ? -(P - le) - 1 : P - le, (P, x) => {
|
|
1355
1355
|
o(x) && le++;
|
|
1356
1356
|
});
|
|
1357
|
-
for (const
|
|
1358
|
-
const x = ye(
|
|
1357
|
+
for (const P of B) if (typeof P == "number") {
|
|
1358
|
+
const x = ye(P), he = P + de, me = q(he), We = he + le;
|
|
1359
1359
|
k.descend(We), U(B, x, me, k), k.ascend();
|
|
1360
|
-
} else k.descend(
|
|
1360
|
+
} else k.descend(P), U(B, ye(P), q(P), k), k.ascend();
|
|
1361
1361
|
ye.end(), q.end();
|
|
1362
1362
|
}(_e, Q, Q.clone(), oe), oe.reset(), b) return {
|
|
1363
1363
|
ok: !1,
|
|
@@ -1365,11 +1365,11 @@ function Lt() {
|
|
|
1365
1365
|
};
|
|
1366
1366
|
if (oe.get(), $e.length) {
|
|
1367
1367
|
const U = $e.map((M) => M ? M.get() : null), B = i.readCursor(tt(oe.get()));
|
|
1368
|
-
if (Ue(B, oe, (M,
|
|
1368
|
+
if (Ue(B, oe, (M, A, k) => {
|
|
1369
1369
|
const X = U[M];
|
|
1370
1370
|
X && (k.mergeTree(X), U[M] = null);
|
|
1371
1371
|
}), U.find((M) => M)) {
|
|
1372
|
-
const M = i.writeCursor(),
|
|
1372
|
+
const M = i.writeCursor(), A = i.writeCursor();
|
|
1373
1373
|
let k = 0, X = 0;
|
|
1374
1374
|
U.forEach((Y) => {
|
|
1375
1375
|
Y != null && Ue(i.readCursor(Y), null, (ee) => {
|
|
@@ -1377,13 +1377,13 @@ function Lt() {
|
|
|
1377
1377
|
M.writeMove(C[fe].getPath(), $[fe].getPath(), k++);
|
|
1378
1378
|
const de = se[fe];
|
|
1379
1379
|
de && de.forEach((le) => {
|
|
1380
|
-
g[le] ||
|
|
1380
|
+
g[le] || D !== 1 && K[le] != null || A.writeMove(j[le].getPath(), p[le].getPath(), X++);
|
|
1381
1381
|
});
|
|
1382
1382
|
});
|
|
1383
1383
|
}), b = {
|
|
1384
1384
|
type: d.ConflictType.BLACKHOLE,
|
|
1385
1385
|
op1: M.get(),
|
|
1386
|
-
op2:
|
|
1386
|
+
op2: A.get()
|
|
1387
1387
|
};
|
|
1388
1388
|
}
|
|
1389
1389
|
}
|
|
@@ -1400,65 +1400,65 @@ function Lt() {
|
|
|
1400
1400
|
const u = new Error("Transform detected write conflict");
|
|
1401
1401
|
throw u.conflict = r, u.type = u.name = "writeConflict", u;
|
|
1402
1402
|
};
|
|
1403
|
-
function
|
|
1404
|
-
const
|
|
1405
|
-
if (
|
|
1406
|
-
gt(
|
|
1403
|
+
function Dt(r, u, y) {
|
|
1404
|
+
const D = nt(r, u, y);
|
|
1405
|
+
if (D.ok) return D.result;
|
|
1406
|
+
gt(D.conflict);
|
|
1407
1407
|
}
|
|
1408
1408
|
const qe = (r) => {
|
|
1409
1409
|
const u = i.writeCursor();
|
|
1410
|
-
return i.readCursor(r).traverse(u, (y,
|
|
1411
|
-
(o(y) || ve(y)) &&
|
|
1410
|
+
return i.readCursor(r).traverse(u, (y, D) => {
|
|
1411
|
+
(o(y) || ve(y)) && D.write("r", !0);
|
|
1412
1412
|
}), u.get();
|
|
1413
|
-
},
|
|
1414
|
-
const { type: y, op1:
|
|
1413
|
+
}, At = (r, u) => {
|
|
1414
|
+
const { type: y, op1: D, op2: b } = r;
|
|
1415
1415
|
switch (y) {
|
|
1416
1416
|
case d.ConflictType.DROP_COLLISION:
|
|
1417
|
-
return u === "left" ? [null, qe(b)] : [qe(
|
|
1417
|
+
return u === "left" ? [null, qe(b)] : [qe(D), null];
|
|
1418
1418
|
case d.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1419
1419
|
let C = !1;
|
|
1420
|
-
return i.readCursor(
|
|
1420
|
+
return i.readCursor(D).traverse(null, ($) => {
|
|
1421
1421
|
$.r !== void 0 && (C = !0);
|
|
1422
|
-
}), C ? [null, qe(b)] : [qe(
|
|
1422
|
+
}), C ? [null, qe(b)] : [qe(D), null];
|
|
1423
1423
|
case d.ConflictType.BLACKHOLE:
|
|
1424
|
-
return [qe(
|
|
1424
|
+
return [qe(D), qe(b)];
|
|
1425
1425
|
default:
|
|
1426
1426
|
throw Error("Unrecognised conflict: " + y);
|
|
1427
1427
|
}
|
|
1428
1428
|
};
|
|
1429
|
-
function _t(r, u, y,
|
|
1429
|
+
function _t(r, u, y, D) {
|
|
1430
1430
|
let b = null;
|
|
1431
1431
|
for (; ; ) {
|
|
1432
|
-
const C = nt(u, y,
|
|
1432
|
+
const C = nt(u, y, D);
|
|
1433
1433
|
if (C.ok) return ne(b, C.result);
|
|
1434
1434
|
{
|
|
1435
1435
|
const { conflict: $ } = C;
|
|
1436
1436
|
r($) || gt($);
|
|
1437
|
-
const [j, p] =
|
|
1437
|
+
const [j, p] = At($, D);
|
|
1438
1438
|
u = ne(H(u), j), y = ne(H(y), p), b = ne(b, p);
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
1441
|
}
|
|
1442
1442
|
})(Ct);
|
|
1443
|
-
(function(
|
|
1443
|
+
(function(n) {
|
|
1444
1444
|
var e = Ce && Ce.__createBinding || (Object.create ? function(d, l, a, E) {
|
|
1445
1445
|
E === void 0 && (E = a), Object.defineProperty(d, E, { enumerable: !0, get: function() {
|
|
1446
1446
|
return l[a];
|
|
1447
1447
|
} });
|
|
1448
1448
|
} : function(d, l, a, E) {
|
|
1449
1449
|
E === void 0 && (E = a), d[E] = l[a];
|
|
1450
|
-
}),
|
|
1450
|
+
}), t = Ce && Ce.__exportStar || function(d, l) {
|
|
1451
1451
|
for (var a in d) a !== "default" && !l.hasOwnProperty(a) && e(l, d, a);
|
|
1452
1452
|
};
|
|
1453
|
-
Object.defineProperty(
|
|
1453
|
+
Object.defineProperty(n, "__esModule", { value: !0 }), t(Ct, n);
|
|
1454
1454
|
var s = ft;
|
|
1455
|
-
Object.defineProperty(
|
|
1455
|
+
Object.defineProperty(n, "ReadCursor", { enumerable: !0, get: function() {
|
|
1456
1456
|
return s.ReadCursor;
|
|
1457
|
-
} }), Object.defineProperty(
|
|
1457
|
+
} }), Object.defineProperty(n, "WriteCursor", { enumerable: !0, get: function() {
|
|
1458
1458
|
return s.WriteCursor;
|
|
1459
1459
|
} });
|
|
1460
1460
|
var i = ht;
|
|
1461
|
-
Object.defineProperty(
|
|
1461
|
+
Object.defineProperty(n, "ConflictType", { enumerable: !0, get: function() {
|
|
1462
1462
|
return i.ConflictType;
|
|
1463
1463
|
} });
|
|
1464
1464
|
})(F);
|
|
@@ -1509,72 +1509,76 @@ class Ht {
|
|
|
1509
1509
|
this._visible$.next(e);
|
|
1510
1510
|
}
|
|
1511
1511
|
refreshTransform(e) {
|
|
1512
|
-
e.forEach((
|
|
1513
|
-
if (this.getDrawingByParam(
|
|
1512
|
+
e.forEach((t) => {
|
|
1513
|
+
if (this.getDrawingByParam(t) == null)
|
|
1514
1514
|
return;
|
|
1515
|
-
const i = this._getCurrentBySearch(
|
|
1516
|
-
i != null && (i.transform =
|
|
1515
|
+
const i = this._getCurrentBySearch(t);
|
|
1516
|
+
i != null && (i.transform = t.transform);
|
|
1517
1517
|
}), this.refreshTransformNotification(e);
|
|
1518
1518
|
}
|
|
1519
1519
|
getDrawingDataForUnit(e) {
|
|
1520
1520
|
return this.drawingManagerData[e];
|
|
1521
1521
|
}
|
|
1522
1522
|
removeDrawingDataForUnit(e) {
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1523
|
+
const t = this.drawingManagerData[e];
|
|
1524
|
+
if (t == null)
|
|
1525
1525
|
return;
|
|
1526
1526
|
delete this.drawingManagerData[e];
|
|
1527
1527
|
const s = [];
|
|
1528
|
-
Object.keys(
|
|
1529
|
-
const d =
|
|
1528
|
+
Object.keys(t).forEach((i) => {
|
|
1529
|
+
const d = t[i];
|
|
1530
1530
|
(d == null ? void 0 : d.data) != null && Object.keys(d.data).forEach((l) => {
|
|
1531
1531
|
s.push({ unitId: e, subUnitId: i, drawingId: l });
|
|
1532
1532
|
});
|
|
1533
1533
|
}), s.length > 0 && this.removeNotification(s);
|
|
1534
1534
|
}
|
|
1535
|
-
registerDrawingData(e,
|
|
1536
|
-
this.drawingManagerData[e] =
|
|
1535
|
+
registerDrawingData(e, t) {
|
|
1536
|
+
this.drawingManagerData[e] = t;
|
|
1537
1537
|
}
|
|
1538
1538
|
initializeNotification(e) {
|
|
1539
|
-
const
|
|
1539
|
+
const t = [], s = this.drawingManagerData[e];
|
|
1540
1540
|
s != null && (Object.keys(s).forEach((i) => {
|
|
1541
1541
|
this._establishDrawingMap(e, i);
|
|
1542
1542
|
const d = s[i];
|
|
1543
1543
|
Object.keys(d.data).forEach((l) => {
|
|
1544
1544
|
const a = d.data[l];
|
|
1545
|
-
a.unitId = e, a.subUnitId = i,
|
|
1545
|
+
a.unitId = e, a.subUnitId = i, t.push(a);
|
|
1546
1546
|
});
|
|
1547
|
-
}),
|
|
1547
|
+
}), t.length > 0 && this.addNotification(t));
|
|
1548
1548
|
}
|
|
1549
|
-
getDrawingData(e,
|
|
1550
|
-
return this._getDrawingData(e,
|
|
1549
|
+
getDrawingData(e, t) {
|
|
1550
|
+
return this._getDrawingData(e, t);
|
|
1551
|
+
}
|
|
1552
|
+
// Use in doc only.
|
|
1553
|
+
setDrawingData(e, t, s) {
|
|
1554
|
+
this.drawingManagerData[e][t].data = s;
|
|
1551
1555
|
}
|
|
1552
1556
|
getBatchAddOp(e) {
|
|
1553
|
-
const
|
|
1557
|
+
const t = [], s = [], i = [];
|
|
1554
1558
|
e.forEach((W) => {
|
|
1555
1559
|
const { op: O, invertOp: o } = this._addByParam(W);
|
|
1556
|
-
|
|
1560
|
+
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }), s.push(O), i.push(o);
|
|
1557
1561
|
});
|
|
1558
1562
|
const d = s.reduce(F.type.compose, null), l = i.reduce(F.type.compose, null), { unitId: a, subUnitId: E } = e[0];
|
|
1559
|
-
return { undo: l, redo: d, unitId: a, subUnitId: E, objects:
|
|
1563
|
+
return { undo: l, redo: d, unitId: a, subUnitId: E, objects: t };
|
|
1560
1564
|
}
|
|
1561
1565
|
getBatchRemoveOp(e) {
|
|
1562
|
-
const
|
|
1566
|
+
const t = [], s = [];
|
|
1563
1567
|
e.forEach((E) => {
|
|
1564
1568
|
const { op: W, invertOp: O } = this._removeByParam(E);
|
|
1565
|
-
|
|
1569
|
+
t.push(W), s.push(O);
|
|
1566
1570
|
});
|
|
1567
|
-
const i =
|
|
1571
|
+
const i = t.reduce(F.type.compose, null), d = s.reduce(F.type.compose, null), { unitId: l, subUnitId: a } = e[0];
|
|
1568
1572
|
return { undo: d, redo: i, unitId: l, subUnitId: a, objects: e };
|
|
1569
1573
|
}
|
|
1570
1574
|
getBatchUpdateOp(e) {
|
|
1571
|
-
const
|
|
1575
|
+
const t = [], s = [], i = [];
|
|
1572
1576
|
e.forEach((W) => {
|
|
1573
1577
|
const { op: O, invertOp: o } = this._updateByParam(W);
|
|
1574
|
-
|
|
1578
|
+
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }), s.push(O), i.push(o);
|
|
1575
1579
|
});
|
|
1576
1580
|
const d = s.reduce(F.type.compose, null), l = i.reduce(F.type.compose, null), { unitId: a, subUnitId: E } = e[0];
|
|
1577
|
-
return { undo: l, redo: d, unitId: a, subUnitId: E, objects:
|
|
1581
|
+
return { undo: l, redo: d, unitId: a, subUnitId: E, objects: t };
|
|
1578
1582
|
}
|
|
1579
1583
|
removeNotification(e) {
|
|
1580
1584
|
this._remove$.next(e);
|
|
@@ -1598,35 +1602,35 @@ class Ht {
|
|
|
1598
1602
|
this._refreshTransform$.next(e);
|
|
1599
1603
|
}
|
|
1600
1604
|
getGroupDrawingOp(e) {
|
|
1601
|
-
const
|
|
1605
|
+
const t = [], { unitId: s, subUnitId: i } = e[0].parent;
|
|
1602
1606
|
e.forEach((a) => {
|
|
1603
|
-
|
|
1607
|
+
t.push(this._getGroupDrawingOp(a));
|
|
1604
1608
|
});
|
|
1605
|
-
const d =
|
|
1609
|
+
const d = t.reduce(F.type.compose, null);
|
|
1606
1610
|
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId: s, subUnitId: i, objects: e };
|
|
1607
1611
|
}
|
|
1608
1612
|
getUngroupDrawingOp(e) {
|
|
1609
|
-
const
|
|
1613
|
+
const t = [], { unitId: s, subUnitId: i } = e[0].parent;
|
|
1610
1614
|
e.forEach((a) => {
|
|
1611
|
-
|
|
1615
|
+
t.push(this._getUngroupDrawingOp(a));
|
|
1612
1616
|
});
|
|
1613
|
-
const d =
|
|
1617
|
+
const d = t.reduce(F.type.compose, null);
|
|
1614
1618
|
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId: s, subUnitId: i, objects: e };
|
|
1615
1619
|
}
|
|
1616
1620
|
getDrawingsByGroup(e) {
|
|
1617
|
-
const { unitId:
|
|
1618
|
-
if (this.getDrawingByParam({ unitId:
|
|
1621
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1622
|
+
if (this.getDrawingByParam({ unitId: t, subUnitId: s, drawingId: i }) == null)
|
|
1619
1623
|
return [];
|
|
1620
|
-
const l = this._getDrawingData(
|
|
1624
|
+
const l = this._getDrawingData(t, s), a = [];
|
|
1621
1625
|
return Object.keys(l).forEach((E) => {
|
|
1622
1626
|
const W = l[E];
|
|
1623
1627
|
W.groupId === i && a.push(W);
|
|
1624
1628
|
}), a;
|
|
1625
1629
|
}
|
|
1626
1630
|
_getGroupDrawingOp(e) {
|
|
1627
|
-
const { parent:
|
|
1631
|
+
const { parent: t, children: s } = e, { unitId: i, subUnitId: d, drawingId: l } = t, a = [];
|
|
1628
1632
|
a.push(
|
|
1629
|
-
F.insertOp([i, d, "data", l],
|
|
1633
|
+
F.insertOp([i, d, "data", l], t)
|
|
1630
1634
|
);
|
|
1631
1635
|
let E = Number.NEGATIVE_INFINITY;
|
|
1632
1636
|
return s.forEach((W) => {
|
|
@@ -1639,7 +1643,7 @@ class Ht {
|
|
|
1639
1643
|
), a.reduce(F.type.compose, null);
|
|
1640
1644
|
}
|
|
1641
1645
|
_getUngroupDrawingOp(e) {
|
|
1642
|
-
const { parent:
|
|
1646
|
+
const { parent: t, children: s } = e, { unitId: i, subUnitId: d, drawingId: l } = t, a = [];
|
|
1643
1647
|
return s.forEach((E) => {
|
|
1644
1648
|
const { unitId: W, subUnitId: O, drawingId: o } = E;
|
|
1645
1649
|
a.push(
|
|
@@ -1651,8 +1655,8 @@ class Ht {
|
|
|
1651
1655
|
F.removeOp([i, d, "order", this._getDrawingOrder(i, d).indexOf(l)], !0)
|
|
1652
1656
|
), a.reduce(F.type.compose, null);
|
|
1653
1657
|
}
|
|
1654
|
-
applyJson1(e,
|
|
1655
|
-
this._establishDrawingMap(e,
|
|
1658
|
+
applyJson1(e, t, s) {
|
|
1659
|
+
this._establishDrawingMap(e, t), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = F.type.apply(this.drawingManagerData, s);
|
|
1656
1660
|
}
|
|
1657
1661
|
// private _fillMissingFields(jsonOp: JSONOp) {
|
|
1658
1662
|
// if (jsonOp == null) {
|
|
@@ -1699,130 +1703,134 @@ class Ht {
|
|
|
1699
1703
|
return this._getOldBySearch(e);
|
|
1700
1704
|
}
|
|
1701
1705
|
getDrawingOKey(e) {
|
|
1702
|
-
const [
|
|
1703
|
-
return this._getCurrentBySearch({ unitId:
|
|
1706
|
+
const [t, s, i] = e.split("#-#");
|
|
1707
|
+
return this._getCurrentBySearch({ unitId: t, subUnitId: s, drawingId: i });
|
|
1704
1708
|
}
|
|
1705
1709
|
focusDrawing(e) {
|
|
1706
1710
|
if (e == null) {
|
|
1707
1711
|
this._focusDrawings = [], this._focus$.next([]);
|
|
1708
1712
|
return;
|
|
1709
1713
|
}
|
|
1710
|
-
const
|
|
1714
|
+
const t = [];
|
|
1711
1715
|
e.forEach((s) => {
|
|
1712
1716
|
var E;
|
|
1713
1717
|
const { unitId: i, subUnitId: d, drawingId: l } = s, a = (E = this._getDrawingData(i, d)) == null ? void 0 : E[l];
|
|
1714
|
-
a != null &&
|
|
1715
|
-
}),
|
|
1718
|
+
a != null && t.push(a);
|
|
1719
|
+
}), t.length > 0 && (this._focusDrawings = t, this._focus$.next(t));
|
|
1716
1720
|
}
|
|
1717
1721
|
getFocusDrawings() {
|
|
1718
1722
|
const e = [];
|
|
1719
|
-
return this._focusDrawings.forEach((
|
|
1723
|
+
return this._focusDrawings.forEach((t) => {
|
|
1720
1724
|
var a;
|
|
1721
|
-
const { unitId: s, subUnitId: i, drawingId: d } =
|
|
1725
|
+
const { unitId: s, subUnitId: i, drawingId: d } = t, l = (a = this._getDrawingData(s, i)) == null ? void 0 : a[d];
|
|
1722
1726
|
l != null && e.push(l);
|
|
1723
1727
|
}), e;
|
|
1724
1728
|
}
|
|
1725
|
-
getDrawingOrder(e,
|
|
1726
|
-
return this._getDrawingOrder(e,
|
|
1729
|
+
getDrawingOrder(e, t) {
|
|
1730
|
+
return this._getDrawingOrder(e, t);
|
|
1731
|
+
}
|
|
1732
|
+
// Use in doc only.
|
|
1733
|
+
setDrawingOrder(e, t, s) {
|
|
1734
|
+
this.drawingManagerData[e][t].order = s;
|
|
1727
1735
|
}
|
|
1728
1736
|
orderUpdateNotification(e) {
|
|
1729
1737
|
this._order$.next(e);
|
|
1730
1738
|
}
|
|
1731
1739
|
getForwardDrawingsOp(e) {
|
|
1732
|
-
const { unitId:
|
|
1740
|
+
const { unitId: t, subUnitId: s, drawingIds: i } = e, d = [], l = this.getDrawingOrder(t, s), a = [...i];
|
|
1733
1741
|
i.forEach((O) => {
|
|
1734
|
-
const o = this._hasDrawingOrder({ unitId:
|
|
1742
|
+
const o = this._hasDrawingOrder({ unitId: t, subUnitId: s, drawingId: O });
|
|
1735
1743
|
if (o === -1 || o === l.length - 1)
|
|
1736
1744
|
return;
|
|
1737
|
-
const c = F.moveOp([
|
|
1745
|
+
const c = F.moveOp([t, s, "order", o], [t, s, "order", o + 1]);
|
|
1738
1746
|
d.push(c), a.includes(l[o + 1]) || a.push(l[o + 1]);
|
|
1739
1747
|
});
|
|
1740
1748
|
const E = d.reduce(F.type.compose, null);
|
|
1741
|
-
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId:
|
|
1749
|
+
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: s, objects: { ...e, drawingIds: a } };
|
|
1742
1750
|
}
|
|
1743
1751
|
getBackwardDrawingOp(e) {
|
|
1744
|
-
const { unitId:
|
|
1752
|
+
const { unitId: t, subUnitId: s, drawingIds: i } = e, d = [], l = this.getDrawingOrder(t, s), a = [...i];
|
|
1745
1753
|
i.forEach((O) => {
|
|
1746
|
-
const o = this._hasDrawingOrder({ unitId:
|
|
1754
|
+
const o = this._hasDrawingOrder({ unitId: t, subUnitId: s, drawingId: O });
|
|
1747
1755
|
if (o === -1 || o === 0)
|
|
1748
1756
|
return;
|
|
1749
|
-
const c = F.moveOp([
|
|
1757
|
+
const c = F.moveOp([t, s, "order", o], [t, s, "order", o - 1]);
|
|
1750
1758
|
d.push(c), a.includes(l[o - 1]) || a.push(l[o - 1]);
|
|
1751
1759
|
});
|
|
1752
1760
|
const E = d.reduce(F.type.compose, null);
|
|
1753
|
-
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId:
|
|
1761
|
+
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: s, objects: { ...e, drawingIds: a } };
|
|
1754
1762
|
}
|
|
1755
1763
|
getFrontDrawingsOp(e) {
|
|
1756
|
-
const { unitId:
|
|
1764
|
+
const { unitId: t, subUnitId: s, drawingIds: i } = e, d = this._getOrderFromSearchParams(t, s, i), l = [...i], a = this.getDrawingOrder(t, s), E = [];
|
|
1757
1765
|
d.forEach((o) => {
|
|
1758
|
-
const { drawingId: c } = o, h = this._getDrawingCount(
|
|
1766
|
+
const { drawingId: c } = o, h = this._getDrawingCount(t, s) - 1, R = F.moveOp([t, s, "order", this._getDrawingOrder(t, s).indexOf(c)], [t, s, "order", h]);
|
|
1759
1767
|
E.push(R), l.includes(a[h]) || l.push(a[h]);
|
|
1760
1768
|
});
|
|
1761
1769
|
const W = E.reduce(F.type.compose, null);
|
|
1762
|
-
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId:
|
|
1770
|
+
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId: s, objects: { ...e, drawingIds: l } };
|
|
1763
1771
|
}
|
|
1764
1772
|
getBackDrawingsOp(e) {
|
|
1765
|
-
const { unitId:
|
|
1773
|
+
const { unitId: t, subUnitId: s, drawingIds: i } = e, d = this._getOrderFromSearchParams(t, s, i, !0), l = [...i], a = this.getDrawingOrder(t, s), E = [];
|
|
1766
1774
|
d.forEach((o) => {
|
|
1767
|
-
const { drawingId: c } = o, h = F.moveOp([
|
|
1775
|
+
const { drawingId: c } = o, h = F.moveOp([t, s, "order", this._getDrawingOrder(t, s).indexOf(c)], [t, s, "order", 0]);
|
|
1768
1776
|
E.push(h), l.includes(a[0]) || l.push(a[0]);
|
|
1769
1777
|
});
|
|
1770
1778
|
const W = E.reduce(F.type.compose, null);
|
|
1771
|
-
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId:
|
|
1779
|
+
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId: s, objects: { ...e, drawingIds: l } };
|
|
1772
1780
|
}
|
|
1773
|
-
_getDrawingCount(e,
|
|
1774
|
-
return this.getDrawingOrder(e,
|
|
1781
|
+
_getDrawingCount(e, t) {
|
|
1782
|
+
return this.getDrawingOrder(e, t).length || 0;
|
|
1775
1783
|
}
|
|
1776
|
-
_getOrderFromSearchParams(e,
|
|
1784
|
+
_getOrderFromSearchParams(e, t, s, i = !1) {
|
|
1777
1785
|
return s.map((d) => {
|
|
1778
|
-
const l = this._hasDrawingOrder({ unitId: e, subUnitId:
|
|
1786
|
+
const l = this._hasDrawingOrder({ unitId: e, subUnitId: t, drawingId: d });
|
|
1779
1787
|
return { drawingId: d, zIndex: l };
|
|
1780
1788
|
}).sort(i === !1 ? Mt : Nt);
|
|
1781
1789
|
}
|
|
1782
1790
|
_hasDrawingOrder(e) {
|
|
1783
1791
|
if (e == null)
|
|
1784
1792
|
return -1;
|
|
1785
|
-
const { unitId:
|
|
1786
|
-
return this._establishDrawingMap(
|
|
1793
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1794
|
+
return this._establishDrawingMap(t, s), this._getDrawingOrder(t, s).indexOf(i);
|
|
1787
1795
|
}
|
|
1788
1796
|
_getCurrentBySearch(e) {
|
|
1789
1797
|
var d, l, a;
|
|
1790
1798
|
if (e == null)
|
|
1791
1799
|
return;
|
|
1792
|
-
const { unitId:
|
|
1793
|
-
return (a = (l = (d = this.drawingManagerData[
|
|
1800
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1801
|
+
return (a = (l = (d = this.drawingManagerData[t]) == null ? void 0 : d[s]) == null ? void 0 : l.data) == null ? void 0 : a[i];
|
|
1794
1802
|
}
|
|
1795
1803
|
_getOldBySearch(e) {
|
|
1796
1804
|
var d, l, a;
|
|
1797
1805
|
if (e == null)
|
|
1798
1806
|
return;
|
|
1799
|
-
const { unitId:
|
|
1800
|
-
return (a = (l = (d = this._oldDrawingManagerData[
|
|
1807
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1808
|
+
return (a = (l = (d = this._oldDrawingManagerData[t]) == null ? void 0 : d[s]) == null ? void 0 : l.data) == null ? void 0 : a[i];
|
|
1801
1809
|
}
|
|
1802
|
-
_establishDrawingMap(e,
|
|
1810
|
+
_establishDrawingMap(e, t, s) {
|
|
1803
1811
|
var i;
|
|
1804
|
-
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][
|
|
1812
|
+
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][t] || (this.drawingManagerData[e][t] = {
|
|
1805
1813
|
data: {},
|
|
1806
1814
|
order: []
|
|
1807
|
-
}), s == null ? null : (i = this.drawingManagerData[e][
|
|
1815
|
+
}), s == null ? null : (i = this.drawingManagerData[e][t].data) == null ? void 0 : i[s];
|
|
1808
1816
|
}
|
|
1809
1817
|
_addByParam(e) {
|
|
1810
|
-
const { unitId:
|
|
1811
|
-
this._establishDrawingMap(
|
|
1812
|
-
const d = F.insertOp([
|
|
1818
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1819
|
+
this._establishDrawingMap(t, s, i);
|
|
1820
|
+
const d = F.insertOp([t, s, "data", i], e), l = F.insertOp([t, s, "order", this._getDrawingOrder(t, s).length], i), a = [d, l].reduce(F.type.compose, null), E = F.type.invertWithDoc(a, this.drawingManagerData);
|
|
1813
1821
|
return { op: a, invertOp: E };
|
|
1814
1822
|
}
|
|
1815
1823
|
_removeByParam(e) {
|
|
1816
1824
|
if (e == null)
|
|
1817
1825
|
return { op: [], invertOp: [] };
|
|
1818
|
-
const { unitId:
|
|
1819
|
-
if (this._establishDrawingMap(
|
|
1826
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e;
|
|
1827
|
+
if (this._establishDrawingMap(t, s, i) == null)
|
|
1820
1828
|
return { op: [], invertOp: [] };
|
|
1821
|
-
const l = F.removeOp([
|
|
1829
|
+
const l = F.removeOp([t, s, "data", i], !0), a = F.removeOp([t, s, "order", this._getDrawingOrder(t, s).indexOf(i)], !0), E = [l, a].reduce(F.type.compose, null), W = F.type.invertWithDoc(E, this.drawingManagerData);
|
|
1822
1830
|
return { op: E, invertOp: W };
|
|
1823
1831
|
}
|
|
1824
1832
|
_updateByParam(e) {
|
|
1825
|
-
const { unitId:
|
|
1833
|
+
const { unitId: t, subUnitId: s, drawingId: i } = e, d = this._establishDrawingMap(t, s, i);
|
|
1826
1834
|
if (d == null)
|
|
1827
1835
|
return { op: [], invertOp: [] };
|
|
1828
1836
|
const a = this._getUpdateParamCompareOp(e, d).reduce(F.type.compose, null), E = F.type.invertWithDoc(a, this.drawingManagerData);
|
|
@@ -1835,22 +1843,22 @@ class Ht {
|
|
|
1835
1843
|
// }
|
|
1836
1844
|
// });
|
|
1837
1845
|
// }
|
|
1838
|
-
_getUpdateParamCompareOp(e,
|
|
1846
|
+
_getUpdateParamCompareOp(e, t) {
|
|
1839
1847
|
const { unitId: s, subUnitId: i, drawingId: d } = e, l = [];
|
|
1840
1848
|
return Object.keys(e).forEach((a) => {
|
|
1841
|
-
const E = e[a], W =
|
|
1849
|
+
const E = e[a], W = t[a];
|
|
1842
1850
|
W !== E && l.push(
|
|
1843
1851
|
F.replaceOp([s, i, "data", d, a], W, E)
|
|
1844
1852
|
);
|
|
1845
1853
|
}), l;
|
|
1846
1854
|
}
|
|
1847
|
-
_getDrawingData(e,
|
|
1855
|
+
_getDrawingData(e, t) {
|
|
1848
1856
|
var s, i;
|
|
1849
|
-
return ((i = (s = this.drawingManagerData[e]) == null ? void 0 : s[
|
|
1857
|
+
return ((i = (s = this.drawingManagerData[e]) == null ? void 0 : s[t]) == null ? void 0 : i.data) || {};
|
|
1850
1858
|
}
|
|
1851
|
-
_getDrawingOrder(e,
|
|
1859
|
+
_getDrawingOrder(e, t) {
|
|
1852
1860
|
var s, i;
|
|
1853
|
-
return ((i = (s = this.drawingManagerData[e]) == null ? void 0 : s[
|
|
1861
|
+
return ((i = (s = this.drawingManagerData[e]) == null ? void 0 : s[t]) == null ? void 0 : i.order) || [];
|
|
1854
1862
|
}
|
|
1855
1863
|
getDrawingVisible() {
|
|
1856
1864
|
return this._visible;
|
|
@@ -1867,23 +1875,23 @@ class Ht {
|
|
|
1867
1875
|
}
|
|
1868
1876
|
class Kt extends Ht {
|
|
1869
1877
|
}
|
|
1870
|
-
function cn(
|
|
1871
|
-
const { unitId: e, subUnitId:
|
|
1872
|
-
return `${e}#-#${
|
|
1878
|
+
function cn(n) {
|
|
1879
|
+
const { unitId: e, subUnitId: t, drawingId: s } = n;
|
|
1880
|
+
return `${e}#-#${t}#-#${s}`;
|
|
1873
1881
|
}
|
|
1874
|
-
const un = async (
|
|
1882
|
+
const un = async (n) => new Promise((e, t) => {
|
|
1875
1883
|
const s = new Image();
|
|
1876
|
-
s.src =
|
|
1884
|
+
s.src = n, s.onload = () => {
|
|
1877
1885
|
e({
|
|
1878
1886
|
width: s.width,
|
|
1879
1887
|
height: s.height,
|
|
1880
1888
|
image: s
|
|
1881
1889
|
});
|
|
1882
1890
|
}, s.onerror = (i) => {
|
|
1883
|
-
|
|
1891
|
+
t(i);
|
|
1884
1892
|
};
|
|
1885
1893
|
});
|
|
1886
|
-
var et = /* @__PURE__ */ ((
|
|
1894
|
+
var et = /* @__PURE__ */ ((n) => (n.URL = "URL", n.UUID = "UUID", n.BASE64 = "BASE64", n))(et || {}), Ze = /* @__PURE__ */ ((n) => (n.SUCCUSS = "0", n.ERROR_EXCEED_SIZE = "1", n.ERROR_IMAGE_TYPE = "2", n.ERROR_UPLOAD_COUNT_LIMIT = "3", n.ERROR_IMAGE = "4", n))(Ze || {});
|
|
1887
1895
|
const Vt = It("core.image-io.service");
|
|
1888
1896
|
class Ft {
|
|
1889
1897
|
constructor() {
|
|
@@ -1895,21 +1903,21 @@ class Ft {
|
|
|
1895
1903
|
setWaitCount(e) {
|
|
1896
1904
|
this._waitCount = e, this._change$.next(e);
|
|
1897
1905
|
}
|
|
1898
|
-
getImageSourceCache(e,
|
|
1899
|
-
if (
|
|
1906
|
+
getImageSourceCache(e, t) {
|
|
1907
|
+
if (t === et.BASE64) {
|
|
1900
1908
|
const s = new Image();
|
|
1901
1909
|
return s.src = e, s;
|
|
1902
1910
|
}
|
|
1903
1911
|
return this._imageSourceCache.get(e);
|
|
1904
1912
|
}
|
|
1905
|
-
addImageSourceCache(e,
|
|
1906
|
-
|
|
1913
|
+
addImageSourceCache(e, t, s) {
|
|
1914
|
+
t === et.BASE64 || s == null || this._imageSourceCache.set(e, s);
|
|
1907
1915
|
}
|
|
1908
1916
|
async getImage(e) {
|
|
1909
1917
|
return Promise.resolve(e);
|
|
1910
1918
|
}
|
|
1911
1919
|
async saveImage(e) {
|
|
1912
|
-
return new Promise((
|
|
1920
|
+
return new Promise((t, s) => {
|
|
1913
1921
|
if (!Wt.includes(e.type)) {
|
|
1914
1922
|
s(new Error(Ze.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
|
|
1915
1923
|
return;
|
|
@@ -1927,7 +1935,7 @@ class Ft {
|
|
|
1927
1935
|
return;
|
|
1928
1936
|
}
|
|
1929
1937
|
const a = kt.generateRandomId(6);
|
|
1930
|
-
|
|
1938
|
+
t({
|
|
1931
1939
|
imageId: a,
|
|
1932
1940
|
imageSourceType: et.BASE64,
|
|
1933
1941
|
source: l,
|
|
@@ -1942,28 +1950,28 @@ class Ft {
|
|
|
1942
1950
|
}
|
|
1943
1951
|
}
|
|
1944
1952
|
const dn = "__default_document_sub_component_id20231101__";
|
|
1945
|
-
var qt = /* @__PURE__ */ ((
|
|
1953
|
+
var qt = /* @__PURE__ */ ((n) => (n[n.forward = 0] = "forward", n[n.backward = 1] = "backward", n[n.front = 2] = "front", n[n.back = 3] = "back", n))(qt || {}), zt = /* @__PURE__ */ ((n) => (n[n.UNRECOGNIZED = -1] = "UNRECOGNIZED", n[n.DRAWING_IMAGE = 0] = "DRAWING_IMAGE", n[n.DRAWING_SHAPE = 1] = "DRAWING_SHAPE", n[n.DRAWING_CHART = 2] = "DRAWING_CHART", n[n.DRAWING_TABLE = 3] = "DRAWING_TABLE", n[n.DRAWING_SMART_ART = 4] = "DRAWING_SMART_ART", n[n.DRAWING_VIDEO = 5] = "DRAWING_VIDEO", n[n.DRAWING_GROUP = 6] = "DRAWING_GROUP", n[n.DRAWING_UNIT = 7] = "DRAWING_UNIT", n[n.DRAWING_DOM = 8] = "DRAWING_DOM", n))(zt || {});
|
|
1946
1954
|
const Xt = It("univer.drawing-manager.service");
|
|
1947
|
-
var Yt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Jt = (
|
|
1948
|
-
for (var i = s > 1 ? void 0 : s ? Zt(e,
|
|
1949
|
-
(l =
|
|
1950
|
-
return s && i && Yt(e,
|
|
1951
|
-
}, Qt = (
|
|
1955
|
+
var Yt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Jt = (n, e, t, s) => {
|
|
1956
|
+
for (var i = s > 1 ? void 0 : s ? Zt(e, t) : e, d = n.length - 1, l; d >= 0; d--)
|
|
1957
|
+
(l = n[d]) && (i = (s ? l(e, t, i) : l(i)) || i);
|
|
1958
|
+
return s && i && Yt(e, t, i), i;
|
|
1959
|
+
}, Qt = (n, e) => (t, s) => e(t, s, n);
|
|
1952
1960
|
const en = "DRAWING_PLUGIN";
|
|
1953
1961
|
var ot;
|
|
1954
1962
|
let wt = (ot = class extends Rt {
|
|
1955
|
-
constructor(
|
|
1956
|
-
super(), this._config =
|
|
1963
|
+
constructor(n, e) {
|
|
1964
|
+
super(), this._config = n, this._injector = e;
|
|
1957
1965
|
}
|
|
1958
|
-
onStarting(
|
|
1959
|
-
this._initDependencies(
|
|
1966
|
+
onStarting(n) {
|
|
1967
|
+
this._initDependencies(n);
|
|
1960
1968
|
}
|
|
1961
|
-
_initDependencies(
|
|
1969
|
+
_initDependencies(n) {
|
|
1962
1970
|
var s;
|
|
1963
1971
|
St([
|
|
1964
1972
|
[Vt, { useClass: Ft }],
|
|
1965
1973
|
[Xt, { useClass: Kt }]
|
|
1966
|
-
], (s = this._config) == null ? void 0 : s.override).forEach((i) =>
|
|
1974
|
+
], (s = this._config) == null ? void 0 : s.override).forEach((i) => n.add(i));
|
|
1967
1975
|
}
|
|
1968
1976
|
}, V(ot, "pluginName", en), ot);
|
|
1969
1977
|
wt = Jt([
|