@univerjs/drawing 0.2.4-alpha.0 → 0.2.4
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 +445 -447
- package/lib/types/plugin.d.ts +2 -1
- package/lib/types/services/drawing-manager.service.d.ts +5 -2
- package/lib/types/services/image-io.service.d.ts +1 -1
- package/lib/types/utils/get-image-shape-key.d.ts +1 -1
- package/lib/umd/index.js +1 -1
- package/package.json +7 -5
package/lib/es/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
var Pt = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var V = (n, e, t) =>
|
|
2
|
+
var Mt = (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) => Mt(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { Subject as we } from "rxjs";
|
|
5
|
-
import { sortRules as
|
|
6
|
-
|
|
5
|
+
import { sortRules as Ut, sortRulesByDesc as Nt, Tools as kt, Plugin as Rt, mergeOverrideWithDependencies as St } from "@univerjs/core";
|
|
6
|
+
import { createIdentifier as It, Inject as Tt, Injector as jt } from "@wendellhu/redi";
|
|
7
|
+
const on = 500, ln = 500, an = 10, $t = 5 * 1024 * 1024, Wt = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
|
|
7
8
|
var Ce = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, F = {}, Ct = {}, ct = {};
|
|
8
9
|
Object.defineProperty(ct, "__esModule", { value: !0 });
|
|
9
10
|
function Gt(n, e) {
|
|
@@ -52,11 +53,11 @@ var ft = {};
|
|
|
52
53
|
if (!O)
|
|
53
54
|
throw new Error(o);
|
|
54
55
|
}
|
|
55
|
-
const t = (O) => O != null && typeof O == "object" && !Array.isArray(O),
|
|
56
|
+
const t = (O) => O != null && typeof O == "object" && !Array.isArray(O), i = (O, o) => (
|
|
56
57
|
// All the numbers, then all the letters. Just as the gods of ascii intended.
|
|
57
58
|
typeof O == typeof o ? O > o : typeof O == "string" && typeof o == "number"
|
|
58
59
|
);
|
|
59
|
-
function
|
|
60
|
+
function s(O, o) {
|
|
60
61
|
for (let c in O) {
|
|
61
62
|
const h = c;
|
|
62
63
|
o.write(h, O[h]);
|
|
@@ -158,7 +159,7 @@ var ft = {};
|
|
|
158
159
|
const R = this.container.splice(h, this.container.length - h);
|
|
159
160
|
this.container.push(R), this.lcIdx > -1 && (this.lcIdx = h);
|
|
160
161
|
}
|
|
161
|
-
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(
|
|
162
|
+
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
163
|
h++;
|
|
163
164
|
if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
|
|
164
165
|
this.container = this.container[h];
|
|
@@ -204,7 +205,7 @@ var ft = {};
|
|
|
204
205
|
ascend() {
|
|
205
206
|
this.pendingDescent.length ? this.pendingDescent.pop() : super.ascend();
|
|
206
207
|
}
|
|
207
|
-
mergeTree(o, c =
|
|
208
|
+
mergeTree(o, c = s) {
|
|
208
209
|
if (o === null)
|
|
209
210
|
return;
|
|
210
211
|
if (e(Array.isArray(o)), o === this._op)
|
|
@@ -248,7 +249,7 @@ var ft = {};
|
|
|
248
249
|
const Ie = J = O.getKey();
|
|
249
250
|
if (pe != null) {
|
|
250
251
|
let xe = !1;
|
|
251
|
-
if (o && typeof Ie == "number" && (J = o(Ie, O.getComponent()), J < 0 && (J = ~J, xe = !0)),
|
|
252
|
+
if (o && typeof Ie == "number" && (J = o(Ie, O.getComponent()), J < 0 && (J = ~J, xe = !0)), i(J, pe))
|
|
252
253
|
return null;
|
|
253
254
|
if (J === pe && !xe)
|
|
254
255
|
return O;
|
|
@@ -266,7 +267,7 @@ var ft = {};
|
|
|
266
267
|
let h, R, Z, pe;
|
|
267
268
|
for (h = R = O && O.descendFirst(), Z = pe = o && o.descendFirst(); h || Z; ) {
|
|
268
269
|
let J = h ? O.getKey() : null, Ie = Z ? o.getKey() : null;
|
|
269
|
-
J !== null && Ie !== null && (
|
|
270
|
+
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());
|
|
270
271
|
}
|
|
271
272
|
R && O.ascend(), pe && o.ascend();
|
|
272
273
|
}
|
|
@@ -281,19 +282,19 @@ var ht = {};
|
|
|
281
282
|
var it = {}, Fe = {}, vt;
|
|
282
283
|
function pt() {
|
|
283
284
|
return vt || (vt = 1, Object.defineProperty(Fe, "__esModule", { value: !0 }), Fe.uniToStrPos = Fe.strPosToUni = void 0, Fe.strPosToUni = (n, e = n.length) => {
|
|
284
|
-
let t = 0,
|
|
285
|
-
for (;
|
|
286
|
-
const
|
|
287
|
-
|
|
285
|
+
let t = 0, i = 0;
|
|
286
|
+
for (; i < e; i++) {
|
|
287
|
+
const s = n.charCodeAt(i);
|
|
288
|
+
s >= 55296 && s <= 57343 && (t++, i++);
|
|
288
289
|
}
|
|
289
|
-
if (
|
|
290
|
+
if (i !== e)
|
|
290
291
|
throw Error("Invalid offset - splits unicode bytes");
|
|
291
|
-
return
|
|
292
|
+
return i - t;
|
|
292
293
|
}, Fe.uniToStrPos = (n, e) => {
|
|
293
294
|
let t = 0;
|
|
294
295
|
for (; e > 0; e--) {
|
|
295
|
-
const
|
|
296
|
-
t +=
|
|
296
|
+
const i = n.charCodeAt(t);
|
|
297
|
+
t += i >= 55296 && i <= 57343 ? 2 : 1;
|
|
297
298
|
}
|
|
298
299
|
return t;
|
|
299
300
|
}), Fe;
|
|
@@ -331,7 +332,7 @@ function at() {
|
|
|
331
332
|
if (typeof _ == "number")
|
|
332
333
|
throw Error("Op has a trailing skip");
|
|
333
334
|
};
|
|
334
|
-
function
|
|
335
|
+
function i(f, _) {
|
|
335
336
|
let w = 0, L = 0;
|
|
336
337
|
for (let z = 0; z < f.length; z++) {
|
|
337
338
|
const H = f[z];
|
|
@@ -348,14 +349,14 @@ function at() {
|
|
|
348
349
|
}
|
|
349
350
|
}
|
|
350
351
|
}
|
|
351
|
-
n.eachOp =
|
|
352
|
-
function
|
|
352
|
+
n.eachOp = i;
|
|
353
|
+
function s(f, _) {
|
|
353
354
|
const w = [], L = a(w);
|
|
354
|
-
return
|
|
355
|
+
return i(f, (z, H, De) => {
|
|
355
356
|
L(_(z, H, De));
|
|
356
357
|
}), o(w);
|
|
357
358
|
}
|
|
358
|
-
const d = (f) => f, l = (f) =>
|
|
359
|
+
const d = (f) => f, l = (f) => s(f, d);
|
|
359
360
|
n.dlen = (f) => typeof f == "number" ? f : e.strPosToUni(f);
|
|
360
361
|
const a = (f) => (_) => {
|
|
361
362
|
if (!(!_ || _.d === 0 || _.d === "")) if (f.length === 0)
|
|
@@ -492,10 +493,10 @@ function at() {
|
|
|
492
493
|
return f;
|
|
493
494
|
}, Z = (f, _) => typeof f == "number" ? R(f, _) : f.map((w) => R(w, _));
|
|
494
495
|
function pe(f, _, w) {
|
|
495
|
-
return
|
|
496
|
+
return s(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: w.slice(_, z, z + L.d) } : L);
|
|
496
497
|
}
|
|
497
498
|
function J(f) {
|
|
498
|
-
return
|
|
499
|
+
return s(f, (_) => {
|
|
499
500
|
switch (typeof _) {
|
|
500
501
|
case "object":
|
|
501
502
|
if (typeof _.d == "number")
|
|
@@ -509,11 +510,11 @@ function at() {
|
|
|
509
510
|
});
|
|
510
511
|
}
|
|
511
512
|
function Ie(f) {
|
|
512
|
-
return
|
|
513
|
+
return s(f, (_) => typeof _ == "object" && typeof _.d == "string" ? { d: e.strPosToUni(_.d) } : _);
|
|
513
514
|
}
|
|
514
515
|
function xe(f) {
|
|
515
516
|
let _ = !0;
|
|
516
|
-
return
|
|
517
|
+
return i(f, (w) => {
|
|
517
518
|
typeof w == "object" && typeof w.d == "number" && (_ = !1);
|
|
518
519
|
}), _;
|
|
519
520
|
}
|
|
@@ -574,27 +575,27 @@ function at() {
|
|
|
574
575
|
n.default = ve;
|
|
575
576
|
}(st)), st;
|
|
576
577
|
}
|
|
577
|
-
var Qe = {},
|
|
578
|
+
var Qe = {}, mt;
|
|
578
579
|
function xt() {
|
|
579
|
-
if (
|
|
580
|
-
|
|
580
|
+
if (mt) return Qe;
|
|
581
|
+
mt = 1, Object.defineProperty(Qe, "__esModule", { value: !0 });
|
|
581
582
|
const n = at(), e = pt();
|
|
582
|
-
function t(
|
|
583
|
+
function t(i, s) {
|
|
583
584
|
return {
|
|
584
585
|
// Returns the text content of the document
|
|
585
|
-
get:
|
|
586
|
+
get: i,
|
|
586
587
|
// Returns the number of characters in the string
|
|
587
588
|
getLength() {
|
|
588
|
-
return
|
|
589
|
+
return i().length;
|
|
589
590
|
},
|
|
590
591
|
// Insert the specified text at the given position in the document
|
|
591
592
|
insert(d, l, a) {
|
|
592
|
-
const E = e.strPosToUni(
|
|
593
|
-
return
|
|
593
|
+
const E = e.strPosToUni(i(), d);
|
|
594
|
+
return s([E, l], a);
|
|
594
595
|
},
|
|
595
596
|
remove(d, l, a) {
|
|
596
|
-
const E = e.strPosToUni(
|
|
597
|
-
return
|
|
597
|
+
const E = e.strPosToUni(i(), d);
|
|
598
|
+
return s([E, { d: l }], a);
|
|
598
599
|
},
|
|
599
600
|
// When you use this API, you should implement these two methods
|
|
600
601
|
// in your editing context.
|
|
@@ -618,9 +619,9 @@ function xt() {
|
|
|
618
619
|
}
|
|
619
620
|
return Qe.default = t, t.provides = { text: !0 }, Qe;
|
|
620
621
|
}
|
|
621
|
-
var
|
|
622
|
+
var bt;
|
|
622
623
|
function Lt() {
|
|
623
|
-
return
|
|
624
|
+
return bt || (bt = 1, function(n) {
|
|
624
625
|
var e = Ce && Ce.__createBinding || (Object.create ? function(c, h, R, Z) {
|
|
625
626
|
Z === void 0 && (Z = R), Object.defineProperty(c, Z, { enumerable: !0, get: function() {
|
|
626
627
|
return h[R];
|
|
@@ -631,16 +632,16 @@ function Lt() {
|
|
|
631
632
|
Object.defineProperty(c, "default", { enumerable: !0, value: h });
|
|
632
633
|
} : function(c, h) {
|
|
633
634
|
c.default = h;
|
|
634
|
-
}),
|
|
635
|
+
}), i = Ce && Ce.__importStar || function(c) {
|
|
635
636
|
if (c && c.__esModule) return c;
|
|
636
637
|
var h = {};
|
|
637
638
|
if (c != null) for (var R in c) Object.hasOwnProperty.call(c, R) && e(h, c, R);
|
|
638
639
|
return t(h, c), h;
|
|
639
|
-
},
|
|
640
|
+
}, s = Ce && Ce.__importDefault || function(c) {
|
|
640
641
|
return c && c.__esModule ? c : { default: c };
|
|
641
642
|
};
|
|
642
643
|
Object.defineProperty(n, "__esModule", { value: !0 }), n.type = n.remove = n.insert = void 0;
|
|
643
|
-
const d = pt(), l =
|
|
644
|
+
const d = pt(), l = i(at()), a = s(xt()), E = {
|
|
644
645
|
create(c) {
|
|
645
646
|
return c;
|
|
646
647
|
},
|
|
@@ -687,15 +688,15 @@ function Lt() {
|
|
|
687
688
|
Object.defineProperty(n, "__esModule", {
|
|
688
689
|
value: !0
|
|
689
690
|
}), n.editOp = n.replaceOp = n.insertOp = n.moveOp = n.removeOp = n.type = void 0;
|
|
690
|
-
const t = e(ct),
|
|
691
|
+
const t = e(ct), i = e(dt), s = ft, d = ht;
|
|
691
692
|
function l(r, u) {
|
|
692
693
|
if (!r) throw new Error(u);
|
|
693
694
|
}
|
|
694
695
|
n.type = {
|
|
695
696
|
name: "json1",
|
|
696
697
|
uri: "http://sharejs.org/types/JSONv1",
|
|
697
|
-
readCursor:
|
|
698
|
-
writeCursor:
|
|
698
|
+
readCursor: s.readCursor,
|
|
699
|
+
writeCursor: s.writeCursor,
|
|
699
700
|
create: (r) => r,
|
|
700
701
|
isNoop: (r) => r == null,
|
|
701
702
|
setDebug(r) {
|
|
@@ -730,9 +731,9 @@ function Lt() {
|
|
|
730
731
|
function h(r, u, y) {
|
|
731
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;
|
|
732
733
|
}
|
|
733
|
-
n.removeOp = (r, u = !0) =>
|
|
734
|
+
n.removeOp = (r, u = !0) => s.writeCursor().writeAtPath(r, "r", u).get(), n.moveOp = (r, u) => s.writeCursor().writeMove(r, u).get(), n.insertOp = (r, u) => s.writeCursor().writeAtPath(r, "i", u).get(), n.replaceOp = (r, u, y) => s.writeCursor().at(r, (D) => {
|
|
734
735
|
D.write("r", u), D.write("i", y);
|
|
735
|
-
}).get(), n.editOp = (r, u, y, D = !1) =>
|
|
736
|
+
}).get(), n.editOp = (r, u, y, D = !1) => s.writeCursor().at(r, (m) => _(m, u, y, D)).get();
|
|
736
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 = {};
|
|
737
738
|
function J(r) {
|
|
738
739
|
let u = r.type ? r.type : r;
|
|
@@ -753,8 +754,8 @@ function Lt() {
|
|
|
753
754
|
transform: (r) => r
|
|
754
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, D = !1) => {
|
|
756
|
-
const [
|
|
757
|
-
!D &&
|
|
757
|
+
const [m, C] = typeof u == "string" ? [Ie(u), u] : [u, u.name];
|
|
758
|
+
!D && m.isNoop && m.isNoop(y) || (C === "number" ? r.write("ena", y) : C === "text-unicode" ? r.write("es", y) : (r.write("et", C), r.write("e", y)));
|
|
758
759
|
};
|
|
759
760
|
function w(r) {
|
|
760
761
|
l(typeof r == "number"), l(r >= 0), l(r === (0 | r));
|
|
@@ -765,282 +766,282 @@ function Lt() {
|
|
|
765
766
|
function z(r) {
|
|
766
767
|
if (r === null) return;
|
|
767
768
|
const u = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new Set(), D = (C) => {
|
|
768
|
-
let $ = !0,
|
|
769
|
+
let $ = !0, T = !1;
|
|
769
770
|
for (let p in C) {
|
|
770
771
|
const v = C[p];
|
|
771
772
|
if ($ = !1, l(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") w(v), l(!u.has(v)), u.add(v), l(C.r === void 0);
|
|
772
773
|
else if (p === "d") w(v), l(!y.has(v)), y.add(v), l(C.i === void 0);
|
|
773
774
|
else if (p === "e" || p === "es" || p === "ena") {
|
|
774
|
-
l(!
|
|
775
|
-
const
|
|
776
|
-
l(
|
|
775
|
+
l(!T), T = !0;
|
|
776
|
+
const b = ve(C);
|
|
777
|
+
l(b, "Missing type in edit"), b.checkValidOp && b.checkValidOp(f(C));
|
|
777
778
|
}
|
|
778
779
|
}
|
|
779
780
|
l(!$);
|
|
780
|
-
},
|
|
781
|
+
}, m = (C, $, T) => {
|
|
781
782
|
if (!Array.isArray(C)) throw Error("Op must be null or a list");
|
|
782
783
|
if (C.length === 0) throw Error("Empty descent");
|
|
783
784
|
$ || L(C[0]);
|
|
784
|
-
let p = 1, v = 0,
|
|
785
|
+
let p = 1, v = 0, b = 0;
|
|
785
786
|
for (let I = 0; I < C.length; I++) {
|
|
786
|
-
const
|
|
787
|
-
if (l(
|
|
788
|
-
const G =
|
|
787
|
+
const j = C[I];
|
|
788
|
+
if (l(j != null), Array.isArray(j)) {
|
|
789
|
+
const G = m(j, !1);
|
|
789
790
|
if (v) {
|
|
790
|
-
const g = typeof
|
|
791
|
-
g === N ? l(
|
|
791
|
+
const g = typeof b, N = typeof G;
|
|
792
|
+
g === N ? l(b < G, "descent keys are not in order") : l(g === "number" && N === "string");
|
|
792
793
|
}
|
|
793
|
-
|
|
794
|
-
} else typeof
|
|
794
|
+
b = G, v++, p = 3;
|
|
795
|
+
} else typeof j == "object" ? (l(p === 1, `Prev not scalar - instead ${p}`), D(j), p = 2) : (l(p !== 3), L(j), l(s.isValidPathItem(j), "Invalid path key"), p = 1);
|
|
795
796
|
}
|
|
796
797
|
return l(v !== 1, "Operation makes multiple descents. Remove some []"), l(p === 2 || p === 3), C[0];
|
|
797
798
|
};
|
|
798
|
-
|
|
799
|
+
m(r, !0), l(u.size === y.size, "Mismatched picks and drops in op");
|
|
799
800
|
for (let C = 0; C < u.size; C++) l(u.has(C)), l(y.has(C));
|
|
800
801
|
}
|
|
801
802
|
function H(r) {
|
|
802
803
|
let u = 0, y = [];
|
|
803
|
-
const D =
|
|
804
|
-
return D.mergeTree(r, (
|
|
805
|
-
const $ = ve(
|
|
804
|
+
const D = s.writeCursor();
|
|
805
|
+
return D.mergeTree(r, (m, C) => {
|
|
806
|
+
const $ = ve(m);
|
|
806
807
|
if ($) {
|
|
807
|
-
const p = f(
|
|
808
|
+
const p = f(m);
|
|
808
809
|
_(C, $, $.normalize ? $.normalize(p) : p);
|
|
809
810
|
}
|
|
810
|
-
for (const p of ["r", "p", "i", "d"]) if (
|
|
811
|
-
const v = p === "p" || p === "d" ? (
|
|
811
|
+
for (const p of ["r", "p", "i", "d"]) if (m[p] !== void 0) {
|
|
812
|
+
const v = p === "p" || p === "d" ? (T = m[p], y[T] == null && (y[T] = u++), y[T]) : m[p];
|
|
812
813
|
C.write(p, v);
|
|
813
814
|
}
|
|
814
|
-
var
|
|
815
|
+
var T;
|
|
815
816
|
}), D.get();
|
|
816
817
|
}
|
|
817
818
|
function De(r, u) {
|
|
818
819
|
if (z(u), u === null) return r;
|
|
819
820
|
const y = [];
|
|
820
|
-
return function D(
|
|
821
|
-
let $ =
|
|
822
|
-
root:
|
|
823
|
-
}, v = 0,
|
|
824
|
-
function
|
|
825
|
-
for (; v <
|
|
821
|
+
return function D(m, C) {
|
|
822
|
+
let $ = m, T = 0, p = {
|
|
823
|
+
root: m
|
|
824
|
+
}, v = 0, b = p, I = "root";
|
|
825
|
+
function j() {
|
|
826
|
+
for (; v < T; v++) {
|
|
826
827
|
let G = C[v];
|
|
827
|
-
typeof G != "object" && (l(R(
|
|
828
|
+
typeof G != "object" && (l(R(b, I)), b = b[I] = W(b[I]), I = G);
|
|
828
829
|
}
|
|
829
830
|
}
|
|
830
|
-
for (;
|
|
831
|
-
const G = C[
|
|
831
|
+
for (; T < C.length; T++) {
|
|
832
|
+
const G = C[T];
|
|
832
833
|
if (Array.isArray(G)) {
|
|
833
834
|
const g = D($, G);
|
|
834
|
-
g !== $ && g !== void 0 && (
|
|
835
|
+
g !== $ && g !== void 0 && (j(), $ = b[I] = g);
|
|
835
836
|
} else if (typeof G == "object") {
|
|
836
|
-
G.d != null ? (
|
|
837
|
+
G.d != null ? (j(), $ = h(b, I, y[G.d])) : G.i !== void 0 && (j(), $ = h(b, I, G.i));
|
|
837
838
|
const g = ve(G);
|
|
838
|
-
if (g)
|
|
839
|
+
if (g) j(), $ = b[I] = g.apply($, f(G));
|
|
839
840
|
else if (G.e !== void 0) throw Error("Subtype " + G.et + " undefined");
|
|
840
841
|
} else $ = Z($, G);
|
|
841
842
|
}
|
|
842
843
|
return p.root;
|
|
843
|
-
}(r = function D(
|
|
844
|
+
}(r = function D(m, C) {
|
|
844
845
|
const $ = [];
|
|
845
|
-
let
|
|
846
|
-
for (;
|
|
847
|
-
const I = C[
|
|
846
|
+
let T = 0;
|
|
847
|
+
for (; T < C.length; T++) {
|
|
848
|
+
const I = C[T];
|
|
848
849
|
if (Array.isArray(I)) break;
|
|
849
|
-
typeof I != "object" && ($.push(
|
|
850
|
+
typeof I != "object" && ($.push(m), m = Z(m, I));
|
|
850
851
|
}
|
|
851
|
-
for (let I = C.length - 1; I >=
|
|
852
|
-
for (--
|
|
853
|
-
const I = C[
|
|
852
|
+
for (let I = C.length - 1; I >= T; I--) m = D(m, C[I]);
|
|
853
|
+
for (--T; T >= 0; T--) {
|
|
854
|
+
const I = C[T];
|
|
854
855
|
if (typeof I != "object") {
|
|
855
|
-
const
|
|
856
|
-
|
|
857
|
-
} else O(I) && (l(
|
|
856
|
+
const j = $.pop();
|
|
857
|
+
m = m === Z(j, I) ? j : m === void 0 ? c(j, I) : (v = I, b = m, (p = W(p = j))[v] = b, p);
|
|
858
|
+
} else O(I) && (l(m !== void 0, "Cannot pick up or remove undefined"), I.p != null && (y[I.p] = m), m = void 0);
|
|
858
859
|
}
|
|
859
|
-
var p, v,
|
|
860
|
-
return
|
|
860
|
+
var p, v, b;
|
|
861
|
+
return m;
|
|
861
862
|
}(r, u), u);
|
|
862
863
|
}
|
|
863
864
|
function ue(r, u) {
|
|
864
865
|
r = r.slice(), z(u);
|
|
865
|
-
const y =
|
|
866
|
-
let D,
|
|
866
|
+
const y = s.readCursor(u);
|
|
867
|
+
let D, m, C = !1;
|
|
867
868
|
const $ = [];
|
|
868
869
|
for (let p = 0; ; p++) {
|
|
869
|
-
const v = r[p],
|
|
870
|
-
if (
|
|
870
|
+
const v = r[p], b = y.getComponent();
|
|
871
|
+
if (b && (b.r !== void 0 ? C = !0 : b.p != null && (C = !1, D = b.p, m = p)), p >= r.length) break;
|
|
871
872
|
let I = 0;
|
|
872
|
-
const
|
|
873
|
+
const j = s.advancer(y, void 0, (g, N) => {
|
|
873
874
|
O(N) && I++;
|
|
874
875
|
});
|
|
875
|
-
$.unshift(
|
|
876
|
-
const G =
|
|
876
|
+
$.unshift(j);
|
|
877
|
+
const G = j(v);
|
|
877
878
|
if (typeof v == "number" && (r[p] -= I), !G) break;
|
|
878
879
|
}
|
|
879
880
|
if ($.forEach((p) => p.end()), C) return null;
|
|
880
|
-
const
|
|
881
|
+
const T = () => {
|
|
881
882
|
let p = 0;
|
|
882
883
|
if (D != null) {
|
|
883
884
|
const v = y.getPath();
|
|
884
|
-
p = v.length, r = v.concat(r.slice(
|
|
885
|
+
p = v.length, r = v.concat(r.slice(m));
|
|
885
886
|
}
|
|
886
887
|
for (; p < r.length; p++) {
|
|
887
|
-
const v = r[p],
|
|
888
|
+
const v = r[p], b = a(y), I = ve(b);
|
|
888
889
|
if (I) {
|
|
889
|
-
const g = f(
|
|
890
|
+
const g = f(b);
|
|
890
891
|
I.transformPosition && (r[p] = I.transformPosition(r[p], g));
|
|
891
892
|
break;
|
|
892
893
|
}
|
|
893
|
-
let
|
|
894
|
-
const G =
|
|
895
|
-
o(N) &&
|
|
894
|
+
let j = 0;
|
|
895
|
+
const G = s.advancer(y, (g, N) => o(N) ? ~(g - j) : g - j, (g, N) => {
|
|
896
|
+
o(N) && j++;
|
|
896
897
|
})(v);
|
|
897
|
-
if (typeof v == "number" && (r[p] +=
|
|
898
|
+
if (typeof v == "number" && (r[p] += j), !G) break;
|
|
898
899
|
}
|
|
899
900
|
};
|
|
900
901
|
return D != null ? y.eachDrop(null, (p) => {
|
|
901
|
-
p === D &&
|
|
902
|
-
}) :
|
|
902
|
+
p === D && T();
|
|
903
|
+
}) : T(), r;
|
|
903
904
|
}
|
|
904
905
|
function ne(r, u) {
|
|
905
906
|
if (z(r), z(u), r == null) return u;
|
|
906
907
|
if (u == null) return r;
|
|
907
908
|
let y = 0;
|
|
908
|
-
const D =
|
|
909
|
+
const D = s.readCursor(r), m = s.readCursor(u), C = s.writeCursor(), $ = [], T = [], p = [], v = [], b = [], I = [], j = /* @__PURE__ */ new Set();
|
|
909
910
|
D.traverse(null, (g) => {
|
|
910
911
|
g.p != null && (p[g.p] = D.clone());
|
|
911
|
-
}),
|
|
912
|
-
g.d != null && (v[g.d] =
|
|
912
|
+
}), m.traverse(null, (g) => {
|
|
913
|
+
g.d != null && (v[g.d] = m.clone());
|
|
913
914
|
});
|
|
914
|
-
const G =
|
|
915
|
-
return function g(N, re, te, K, se,
|
|
915
|
+
const G = s.writeCursor();
|
|
916
|
+
return function g(N, re, te, K, se, je, me, _e) {
|
|
916
917
|
l(re || te);
|
|
917
|
-
const oe = a(re), Pe = a(te),
|
|
918
|
-
if (Ee != null) K = v[Ee],
|
|
918
|
+
const oe = a(re), Pe = a(te), Ue = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Me = oe ? oe.d : null, Ee = Pe ? Pe.p : null, $e = (je || Ue) && Ee == null;
|
|
919
|
+
if (Ee != null) K = v[Ee], me = T[Ee] = new s.WriteCursor();
|
|
919
920
|
else if (Pe && Pe.r !== void 0) K = null;
|
|
920
921
|
else {
|
|
921
922
|
const P = a(K);
|
|
922
923
|
P && P.d != null && (K = null);
|
|
923
924
|
}
|
|
924
925
|
const Q = a(K);
|
|
925
|
-
if (
|
|
926
|
+
if (Me != null) if (N = p[Me], _e = $[Me] = new s.WriteCursor(), $e) je && !Ue && _e.write("r", !0);
|
|
926
927
|
else {
|
|
927
|
-
const P =
|
|
928
|
-
|
|
928
|
+
const P = b[Me] = y++;
|
|
929
|
+
me.write("d", P);
|
|
929
930
|
}
|
|
930
931
|
else if (oe && oe.i !== void 0) N = null;
|
|
931
932
|
else {
|
|
932
933
|
const P = a(N);
|
|
933
934
|
P && P.p != null && (N = null);
|
|
934
935
|
}
|
|
935
|
-
let
|
|
936
|
-
Le ? (l(se === void 0),
|
|
937
|
-
const B = (Ee == null ? !Le ||
|
|
936
|
+
let M;
|
|
937
|
+
Le ? (l(se === void 0), M = oe.i) : M = se;
|
|
938
|
+
const B = (Ee == null ? !Le || je || Ue : M === void 0) ? null : me.getComponent();
|
|
938
939
|
if (Ee != null) {
|
|
939
940
|
if (!(se !== void 0 || Le)) {
|
|
940
|
-
const P =
|
|
941
|
+
const P = Me != null ? b[Me] : y++;
|
|
941
942
|
I[Ee] = P, _e.write("p", P);
|
|
942
943
|
}
|
|
943
|
-
} else
|
|
944
|
-
const
|
|
945
|
-
if ((
|
|
946
|
-
l(
|
|
947
|
-
const P = f(oe), x = f(Q), he =
|
|
948
|
-
_(
|
|
949
|
-
} else
|
|
950
|
-
const k = typeof
|
|
944
|
+
} else Ue && (Le || se !== void 0 || (Pe.r, _e.write("r", Pe.r)));
|
|
945
|
+
const U = $e ? null : ve(oe), A = ve(Q);
|
|
946
|
+
if ((U || A) && (U && U.name, A && A.name), U && A) {
|
|
947
|
+
l(U === A);
|
|
948
|
+
const P = f(oe), x = f(Q), he = U.compose(P, x);
|
|
949
|
+
_(me, U, he), j.add(Q);
|
|
950
|
+
} else U ? _(me, U, f(oe)) : A && (_(me, A, f(Q)), j.add(Q));
|
|
951
|
+
const k = typeof M == "object" && M != null;
|
|
951
952
|
let X = !1, Y = 0, ee = 0, fe = 0, de = 0, le = 0;
|
|
952
|
-
const ye =
|
|
953
|
+
const ye = s.advancer(K, (P, x) => o(x) ? de - P - 1 : P - de, (P, x) => {
|
|
953
954
|
o(x) && de++;
|
|
954
|
-
}), q =
|
|
955
|
+
}), q = s.advancer(N, (P, x) => O(x) ? Y - P - 1 : P - Y, (P, x) => {
|
|
955
956
|
O(x) && Y++;
|
|
956
957
|
});
|
|
957
|
-
if (
|
|
958
|
-
let
|
|
958
|
+
if (s.eachChildOf(re, te, (P, x, he) => {
|
|
959
|
+
let be, We, He = P, Ne = P, Ye = P;
|
|
959
960
|
if (typeof P == "number") {
|
|
960
961
|
let Oe = P + fe;
|
|
961
962
|
We = ye(Oe), Ne = Oe + de;
|
|
962
963
|
let ce = P + ee;
|
|
963
|
-
|
|
964
|
+
be = q(ce), o(a(We)) && (be = null), He = ce + Y, Ye = P + le, l(He >= 0, "p1PickKey is negative"), l(Ne >= 0, "p2DropKey is negative");
|
|
964
965
|
const ke = o(a(x)), Ge = O(a(he));
|
|
965
966
|
(ke || Ge && !$e) && le--, ke && ee--, Ge && fe--;
|
|
966
|
-
} else
|
|
967
|
-
_e.descend(He),
|
|
968
|
-
const ze = k && !o(a(x)) ?
|
|
969
|
-
var
|
|
970
|
-
k && !$e ? ze !== Se && (X || (
|
|
971
|
-
}), q.end(), ye.end(), B != null) B.i =
|
|
972
|
-
else if (!
|
|
973
|
-
}(D, D.clone(),
|
|
967
|
+
} else be = q(P), We = ye(P);
|
|
968
|
+
_e.descend(He), me.descend(Ne);
|
|
969
|
+
const ze = k && !o(a(x)) ? M[Ye] : void 0, Se = g(be, x, he, We, ze, $e, me, _e);
|
|
970
|
+
var Te, S, ie;
|
|
971
|
+
k && !$e ? ze !== Se && (X || (M = Array.isArray(M) ? M.slice() : Object.assign({}, M), X = !0), Te = M, ie = Se, typeof (S = Ye) == "number" ? (l(Array.isArray(Te)), l(S < Te.length)) : (l(!Array.isArray(Te)), l(Te[S] !== void 0)), ie === void 0 ? typeof S == "number" ? Te.splice(S, 1) : delete Te[S] : Te[S] = ie) : l(Se === void 0), me.ascend(), _e.ascend();
|
|
972
|
+
}), q.end(), ye.end(), B != null) B.i = M;
|
|
973
|
+
else if (!je && !Ue && Ee == null) return M;
|
|
974
|
+
}(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()), T.map((g) => g.get()), D.traverse(C, (g, N) => {
|
|
974
975
|
const re = g.p;
|
|
975
976
|
if (re != null) {
|
|
976
|
-
const te =
|
|
977
|
+
const te = b[re];
|
|
977
978
|
te != null && N.write("p", te);
|
|
978
979
|
const K = $[re];
|
|
979
980
|
K && K.get(), K && N.mergeTree(K.get());
|
|
980
981
|
} else g.r !== void 0 && N.write("r", g.r);
|
|
981
|
-
}), C.reset(), C.get(),
|
|
982
|
+
}), C.reset(), C.get(), m.traverse(C, (g, N) => {
|
|
982
983
|
const re = g.d;
|
|
983
984
|
if (re != null) {
|
|
984
985
|
const K = I[re];
|
|
985
986
|
K != null && N.write("d", K);
|
|
986
|
-
const se =
|
|
987
|
+
const se = T[re];
|
|
987
988
|
se && N.mergeTree(se.get());
|
|
988
989
|
} else g.i !== void 0 && N.write("i", g.i);
|
|
989
990
|
const te = ve(g);
|
|
990
|
-
te && !
|
|
991
|
+
te && !j.has(g) && _(N, te, f(g));
|
|
991
992
|
}), C.get();
|
|
992
993
|
}
|
|
993
994
|
function ae(r) {
|
|
994
995
|
if (r == null) return null;
|
|
995
|
-
const u = new
|
|
996
|
+
const u = new s.ReadCursor(r), y = new s.WriteCursor();
|
|
996
997
|
let D;
|
|
997
|
-
const
|
|
998
|
-
return function $(
|
|
999
|
-
const
|
|
1000
|
-
let I,
|
|
1001
|
-
if (
|
|
1002
|
-
|
|
1003
|
-
const g = ve(
|
|
1004
|
-
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(
|
|
998
|
+
const m = [], C = [];
|
|
999
|
+
return function $(T, p, v) {
|
|
1000
|
+
const b = T.getComponent();
|
|
1001
|
+
let I, j = !1;
|
|
1002
|
+
if (b) {
|
|
1003
|
+
b.p != null && (p.write("d", b.p), m[b.p] = T.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);
|
|
1004
|
+
const g = ve(b);
|
|
1005
|
+
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(b)) : (f(b), v = g.apply(v, f(b)), j = !0));
|
|
1005
1006
|
}
|
|
1006
1007
|
let G = 0;
|
|
1007
|
-
for (const g of
|
|
1008
|
+
for (const g of T) {
|
|
1008
1009
|
p.descend(g);
|
|
1009
1010
|
const N = typeof g == "number" ? g - G : g, re = Z(v, N);
|
|
1010
|
-
o(
|
|
1011
|
-
const te = $(
|
|
1011
|
+
o(T.getComponent()) && G++;
|
|
1012
|
+
const te = $(T, p, re);
|
|
1012
1013
|
if (v !== void 0 && te !== void 0) {
|
|
1013
|
-
if (
|
|
1014
|
+
if (j || (j = !0, v = W(v)), !R(v, N)) throw Error("Cannot modify child - invalid operation");
|
|
1014
1015
|
v[N] = te;
|
|
1015
1016
|
}
|
|
1016
1017
|
p.ascend();
|
|
1017
1018
|
}
|
|
1018
|
-
if (I === void 0) return
|
|
1019
|
+
if (I === void 0) return j ? v : void 0;
|
|
1019
1020
|
p.write("r", v);
|
|
1020
|
-
}(u, y, void 0), D && (y.reset(), function $(
|
|
1021
|
-
const
|
|
1022
|
-
if (
|
|
1023
|
-
const g =
|
|
1024
|
-
if (g != null && (
|
|
1025
|
-
const N = ve(
|
|
1021
|
+
}(u, y, void 0), D && (y.reset(), function $(T, p, v) {
|
|
1022
|
+
const b = p.getComponent();
|
|
1023
|
+
if (b) {
|
|
1024
|
+
const g = b.d;
|
|
1025
|
+
if (g != null && (T = m[g], v = C[g] = s.writeCursor()), D.has(b)) {
|
|
1026
|
+
const N = ve(b);
|
|
1026
1027
|
if (!N.invert) throw Error(`Cannot invert subtype ${N.name}`);
|
|
1027
|
-
_(v, N, N.invert(f(
|
|
1028
|
+
_(v, N, N.invert(f(b)));
|
|
1028
1029
|
}
|
|
1029
1030
|
}
|
|
1030
|
-
let I = 0,
|
|
1031
|
-
const G =
|
|
1031
|
+
let I = 0, j = 0;
|
|
1032
|
+
const G = s.advancer(T, (g, N) => O(N) ? I - g - 1 : g - I, (g, N) => {
|
|
1032
1033
|
O(N) && I++;
|
|
1033
1034
|
});
|
|
1034
1035
|
for (const g of p) if (typeof g == "number") {
|
|
1035
|
-
const N = g -
|
|
1036
|
-
v.descend(te), $(re, p, v), o(p.getComponent()) &&
|
|
1036
|
+
const N = g - j, re = G(N), te = N + I;
|
|
1037
|
+
v.descend(te), $(re, p, v), o(p.getComponent()) && j++, v.ascend();
|
|
1037
1038
|
} else v.descend(g), $(G(g), p, v), v.ascend();
|
|
1038
1039
|
G.end();
|
|
1039
|
-
}(u.clone(), u, y), C.length && (y.reset(), u.traverse(y, ($,
|
|
1040
|
+
}(u.clone(), u, y), C.length && (y.reset(), u.traverse(y, ($, T) => {
|
|
1040
1041
|
const p = $.p;
|
|
1041
1042
|
if (p != null) {
|
|
1042
1043
|
const v = C[p];
|
|
1043
|
-
v && v.get(), v &&
|
|
1044
|
+
v && v.get(), v && T.mergeTree(v.get());
|
|
1044
1045
|
}
|
|
1045
1046
|
}))), y.get();
|
|
1046
1047
|
}
|
|
@@ -1050,46 +1051,46 @@ function Lt() {
|
|
|
1050
1051
|
var v;
|
|
1051
1052
|
return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
|
|
1052
1053
|
})) return r;
|
|
1053
|
-
const y = new
|
|
1054
|
-
let
|
|
1055
|
-
const C = [], $ = [],
|
|
1054
|
+
const y = new s.ReadCursor(r), D = new s.WriteCursor();
|
|
1055
|
+
let m = !1;
|
|
1056
|
+
const C = [], $ = [], T = (p, v, b) => {
|
|
1056
1057
|
const I = p.getComponent();
|
|
1057
|
-
let
|
|
1058
|
+
let j = !1;
|
|
1058
1059
|
if (I) {
|
|
1059
1060
|
I.d != null && v.write("d", I.d), I.i !== void 0 && v.write("i", I.i);
|
|
1060
1061
|
const g = I.p;
|
|
1061
|
-
if (g != null && (C[g] = p.clone(), l(
|
|
1062
|
+
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
1063
|
const N = ve(I);
|
|
1063
|
-
N && (N.makeInvertible ?
|
|
1064
|
+
N && (N.makeInvertible ? m = !0 : _(v, N, f(I), !0));
|
|
1064
1065
|
}
|
|
1065
1066
|
let G = 0;
|
|
1066
1067
|
for (const g of p) {
|
|
1067
1068
|
v.descend(g);
|
|
1068
|
-
const N = typeof g == "number" ? g - G : g, re = Z(
|
|
1069
|
-
re !== te && (
|
|
1069
|
+
const N = typeof g == "number" ? g - G : g, re = Z(b, N), te = T(p, v, re);
|
|
1070
|
+
re !== te && (j || (j = !0, b = W(b)), te === void 0 ? (b = c(b, N), typeof g == "number" && G++) : b[N] = te), v.ascend();
|
|
1070
1071
|
}
|
|
1071
|
-
return I && (I.r !== void 0 ? (v.write("r",
|
|
1072
|
+
return I && (I.r !== void 0 ? (v.write("r", i.default(b)), b = void 0) : I.p != null && (b = void 0)), b;
|
|
1072
1073
|
};
|
|
1073
|
-
return
|
|
1074
|
-
const g =
|
|
1074
|
+
return T(y, D, u), D.get(), m && (D.reset(), function p(v, b, I, j, G) {
|
|
1075
|
+
const g = b.getComponent();
|
|
1075
1076
|
if (g) {
|
|
1076
|
-
g.i !== void 0 ? (
|
|
1077
|
+
g.i !== void 0 ? (j = g.i, G = !0) : g.d != null && (j = $[g.d], v = C[g.d], G = !1, g.d);
|
|
1077
1078
|
let K = ve(g);
|
|
1078
1079
|
if (K && K.makeInvertible) {
|
|
1079
1080
|
const se = f(g);
|
|
1080
|
-
_(I, K, K.makeInvertible(se,
|
|
1081
|
+
_(I, K, K.makeInvertible(se, j), !0);
|
|
1081
1082
|
}
|
|
1082
1083
|
}
|
|
1083
1084
|
let N = 0, re = 0;
|
|
1084
|
-
const te =
|
|
1085
|
+
const te = s.advancer(v, (K, se) => O(se) ? N - K - 1 : K - N, (K, se) => {
|
|
1085
1086
|
O(se) && N++;
|
|
1086
1087
|
});
|
|
1087
|
-
for (const K of
|
|
1088
|
-
const se = K - re,
|
|
1089
|
-
I.descend(K), p(
|
|
1088
|
+
for (const K of b) if (typeof K == "number") {
|
|
1089
|
+
const se = K - re, je = te(se), me = se + N, _e = Z(j, G ? se : me);
|
|
1090
|
+
I.descend(K), p(je, b, I, _e, G), o(b.getComponent()) && re++, I.ascend();
|
|
1090
1091
|
} else {
|
|
1091
|
-
const se = Z(
|
|
1092
|
-
I.descend(K), p(te(K),
|
|
1092
|
+
const se = Z(j, K);
|
|
1093
|
+
I.descend(K), p(te(K), b, I, se, G), I.ascend();
|
|
1093
1094
|
}
|
|
1094
1095
|
te.end();
|
|
1095
1096
|
}(y.clone(), y, D, u, !1)), D.get();
|
|
@@ -1114,87 +1115,87 @@ function Lt() {
|
|
|
1114
1115
|
result: r
|
|
1115
1116
|
};
|
|
1116
1117
|
z(r), z(u);
|
|
1117
|
-
let
|
|
1118
|
-
const C = [], $ = [],
|
|
1119
|
-
let
|
|
1120
|
-
const
|
|
1121
|
-
if (function Q(
|
|
1118
|
+
let m = null;
|
|
1119
|
+
const C = [], $ = [], T = [], p = [], v = [], b = [], I = [], j = [], G = [], g = [], N = [], re = [], te = [], K = [], se = [];
|
|
1120
|
+
let je = 0;
|
|
1121
|
+
const me = s.readCursor(r), _e = s.readCursor(u), oe = s.writeCursor();
|
|
1122
|
+
if (function Q(M, B = null, U) {
|
|
1122
1123
|
const A = a(B);
|
|
1123
|
-
A && (A.r !== void 0 ?
|
|
1124
|
-
const k =
|
|
1124
|
+
A && (A.r !== void 0 ? U = B.clone() : A.p != null && (U = null, b[A.p] = M.clone()));
|
|
1125
|
+
const k = M.getComponent();
|
|
1125
1126
|
let X;
|
|
1126
|
-
k && (X = k.p) != null && (v[X] = B ? B.clone() : null,
|
|
1127
|
-
const Y =
|
|
1128
|
-
for (const ee of
|
|
1127
|
+
k && (X = k.p) != null && (v[X] = B ? B.clone() : null, T[X] = M.clone(), U && (g[X] = !0, G[X] = U), A && A.p != null && (K[X] = A.p));
|
|
1128
|
+
const Y = s.advancer(B);
|
|
1129
|
+
for (const ee of M) Q(M, Y(ee), U);
|
|
1129
1130
|
Y.end();
|
|
1130
|
-
}(_e,
|
|
1131
|
-
const X =
|
|
1131
|
+
}(_e, me, null), function Q(M, B, U, A, k) {
|
|
1132
|
+
const X = U.getComponent();
|
|
1132
1133
|
let Y, ee = !1;
|
|
1133
|
-
X && ((Y = X.d) != null ? (p[Y] =
|
|
1134
|
+
X && ((Y = X.d) != null ? (p[Y] = U.clone(), A != null && (se[A] == null && (se[A] = []), se[A].push(Y)), M = v[Y] || null, B = T[Y] || null, g[Y] ? (k && (N[Y] = !0), k = G[Y] || null) : !k || D !== 1 && K[Y] != null || m == null && (m = {
|
|
1134
1135
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1135
1136
|
op1: n.removeOp(k.getPath()),
|
|
1136
|
-
op2: n.moveOp(B.getPath(),
|
|
1137
|
-
}), ee = !0) : X.i !== void 0 && (
|
|
1137
|
+
op2: n.moveOp(B.getPath(), U.getPath())
|
|
1138
|
+
}), ee = !0) : X.i !== void 0 && (M = B = null, ee = !0, k && m == null && (m = {
|
|
1138
1139
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1139
1140
|
op1: n.removeOp(k.getPath()),
|
|
1140
|
-
op2: n.insertOp(
|
|
1141
|
+
op2: n.insertOp(U.getPath(), X.i)
|
|
1141
1142
|
})));
|
|
1142
|
-
const fe = a(
|
|
1143
|
-
fe && (fe.r !== void 0 ? k =
|
|
1143
|
+
const fe = a(M);
|
|
1144
|
+
fe && (fe.r !== void 0 ? k = M.clone() : fe.p != null && (fe.p, A = fe.p, k = null));
|
|
1144
1145
|
const de = ve(X);
|
|
1145
|
-
de && k &&
|
|
1146
|
+
de && k && m == null && (m = {
|
|
1146
1147
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1147
1148
|
op1: n.removeOp(k.getPath()),
|
|
1148
|
-
op2: n.editOp(
|
|
1149
|
+
op2: n.editOp(U.getPath(), de, f(X), !0)
|
|
1149
1150
|
});
|
|
1150
1151
|
let le = 0, ye = 0;
|
|
1151
|
-
const q =
|
|
1152
|
+
const q = s.advancer(B, (x, he) => O(he) ? le - x - 1 : x - le, (x, he) => {
|
|
1152
1153
|
O(he) && le++;
|
|
1153
|
-
}), P =
|
|
1154
|
-
for (const x of
|
|
1155
|
-
const he = x - ye,
|
|
1156
|
-
ye += +Q(P(he + le),
|
|
1154
|
+
}), P = s.advancer(M);
|
|
1155
|
+
for (const x of U) if (typeof x == "number") {
|
|
1156
|
+
const he = x - ye, be = q(he);
|
|
1157
|
+
ye += +Q(P(he + le), be, U, A, k);
|
|
1157
1158
|
} else {
|
|
1158
1159
|
const he = q(x);
|
|
1159
|
-
Q(P(x), he,
|
|
1160
|
+
Q(P(x), he, U, A, k);
|
|
1160
1161
|
}
|
|
1161
1162
|
return q.end(), P.end(), ee;
|
|
1162
|
-
}(
|
|
1163
|
+
}(me, _e, _e.clone(), null, null), p.map((Q) => Q && Q.get()), m) return {
|
|
1163
1164
|
ok: !1,
|
|
1164
|
-
conflict:
|
|
1165
|
+
conflict: m
|
|
1165
1166
|
};
|
|
1166
1167
|
N.map((Q) => !!Q);
|
|
1167
1168
|
const Pe = [];
|
|
1168
|
-
let
|
|
1169
|
-
(function Q(
|
|
1169
|
+
let Ue = null;
|
|
1170
|
+
(function Q(M, B, U, A, k) {
|
|
1170
1171
|
let X = !1;
|
|
1171
1172
|
const Y = a(B);
|
|
1172
1173
|
if (O(Y)) {
|
|
1173
1174
|
const q = Y.p;
|
|
1174
|
-
q != null ? (
|
|
1175
|
-
} else o(a(
|
|
1176
|
-
const ee =
|
|
1175
|
+
q != null ? (U = p[q], A = re[q] = s.writeCursor(), X = !0, k = null) : (U = null, k = B.clone());
|
|
1176
|
+
} else o(a(U)) && (U = null);
|
|
1177
|
+
const ee = M.getComponent();
|
|
1177
1178
|
if (ee) {
|
|
1178
1179
|
const q = ee.p;
|
|
1179
|
-
q != null ? (k && (
|
|
1180
|
+
q != null ? (k && (j[q] = k), Pe[q] = k || D === 1 && X ? null : A.getComponent(), C[q] = M.clone(), U && (I[q] = U.clone())) : ee.r !== void 0 && (k || A.write("r", !0), (k || X) && (Ue == null && (Ue = /* @__PURE__ */ new Set()), Ue.add(ee)));
|
|
1180
1181
|
}
|
|
1181
1182
|
let fe = 0, de = 0;
|
|
1182
|
-
const le =
|
|
1183
|
+
const le = s.advancer(B, void 0, (q, P) => {
|
|
1183
1184
|
O(P) && fe++;
|
|
1184
|
-
}), ye =
|
|
1185
|
+
}), ye = s.advancer(U, (q, P) => o(P) ? ~(q - de) : q - de, (q, P) => {
|
|
1185
1186
|
o(P) && de++;
|
|
1186
1187
|
});
|
|
1187
|
-
if (
|
|
1188
|
+
if (M) for (const q of M) if (typeof q == "string") {
|
|
1188
1189
|
const P = le(q), x = ye(q);
|
|
1189
|
-
A.descend(q), Q(
|
|
1190
|
+
A.descend(q), Q(M, P, x, A, k), A.ascend();
|
|
1190
1191
|
} else {
|
|
1191
|
-
const P = le(q), x = q - fe, he = O(a(P)) ? null : ye(x),
|
|
1192
|
-
l(
|
|
1192
|
+
const P = le(q), x = q - fe, he = O(a(P)) ? null : ye(x), be = x + de;
|
|
1193
|
+
l(be >= 0), A.descend(be), Q(M, P, he, A, k), A.ascend();
|
|
1193
1194
|
}
|
|
1194
1195
|
le.end(), ye.end();
|
|
1195
|
-
})(
|
|
1196
|
+
})(me, _e, _e.clone(), oe, null), oe.reset();
|
|
1196
1197
|
let Le = [];
|
|
1197
|
-
if (function Q(
|
|
1198
|
+
if (function Q(M, B, U, A, k, X) {
|
|
1198
1199
|
l(B);
|
|
1199
1200
|
const Y = B.getComponent();
|
|
1200
1201
|
let ee = a(A), fe = !1;
|
|
@@ -1206,31 +1207,31 @@ function Lt() {
|
|
|
1206
1207
|
let Oe = !1;
|
|
1207
1208
|
if (Y.i !== void 0 || S != null && ie) {
|
|
1208
1209
|
let ce;
|
|
1209
|
-
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 ||
|
|
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 || m == null && (m = {
|
|
1210
1211
|
type: d.ConflictType.DROP_COLLISION,
|
|
1211
1212
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1212
|
-
op2: de(ce != null ?
|
|
1213
|
-
})), Oe || (X ?
|
|
1213
|
+
op2: de(ce != null ? T[ce] : null, A, ee)
|
|
1214
|
+
})), Oe || (X ? m == null && (m = {
|
|
1214
1215
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1215
1216
|
op1: de(S != null ? C[S] : null, B, Y),
|
|
1216
1217
|
op2: n.removeOp(X.getPath())
|
|
1217
|
-
}) : (S != null ? (Le[
|
|
1218
|
+
}) : (S != null ? (Le[je] = S, k.write("d", ie.p = je++)) : k.write("i", i.default(Y.i)), fe = !0));
|
|
1218
1219
|
} else if (S != null && !ie) {
|
|
1219
|
-
const ce =
|
|
1220
|
+
const ce = j[S];
|
|
1220
1221
|
ce && (X = ce.clone());
|
|
1221
1222
|
}
|
|
1222
|
-
S != null ? (
|
|
1223
|
-
} else O(a(
|
|
1224
|
-
const le = a(
|
|
1223
|
+
S != null ? (M = C[S], U = b[S], A = I[S]) : Y.i !== void 0 && (M = U = null, Oe || (A = null));
|
|
1224
|
+
} else O(a(M)) && (M = U = A = null);
|
|
1225
|
+
const le = a(M), ye = a(U);
|
|
1225
1226
|
if (O(ye)) {
|
|
1226
1227
|
const S = ye.p;
|
|
1227
|
-
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (A = null, X =
|
|
1228
|
+
ye.r !== void 0 && (!le || le.r === void 0) || g[S] ? (A = null, X = U.clone()) : S != null && (A = p[S], D !== 1 && K[S] != null || ((k = te[S]) || (k = te[S] = s.writeCursor()), k.reset(), X = null));
|
|
1228
1229
|
} else !o(Y) && o(ee) && (A = null);
|
|
1229
1230
|
ee = A != null ? A.getComponent() : null;
|
|
1230
1231
|
const q = ve(Y);
|
|
1231
1232
|
if (q) {
|
|
1232
1233
|
const S = f(Y);
|
|
1233
|
-
if (X)
|
|
1234
|
+
if (X) m == null && (m = {
|
|
1234
1235
|
type: d.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1235
1236
|
op1: n.editOp(B.getPath(), q, S, !0),
|
|
1236
1237
|
op2: n.removeOp(X.getPath())
|
|
@@ -1242,32 +1243,32 @@ function Lt() {
|
|
|
1242
1243
|
if (q !== ie) throw Error("Transforming incompatible types");
|
|
1243
1244
|
const ce = f(ee);
|
|
1244
1245
|
Oe = q.transform(S, ce, y);
|
|
1245
|
-
} else Oe =
|
|
1246
|
+
} else Oe = i.default(S);
|
|
1246
1247
|
_(k, q, Oe);
|
|
1247
1248
|
}
|
|
1248
1249
|
}
|
|
1249
|
-
let P = 0, x = 0, he = 0,
|
|
1250
|
-
const ze =
|
|
1250
|
+
let P = 0, x = 0, he = 0, be = 0, We = 0, He = 0, Ne = M != null && M.descendFirst(), Ye = Ne;
|
|
1251
|
+
const ze = s.advancer(U, void 0, (S, ie) => {
|
|
1251
1252
|
O(ie) && he++;
|
|
1252
1253
|
});
|
|
1253
|
-
let Se = A != null && A.descendFirst(),
|
|
1254
|
+
let Se = A != null && A.descendFirst(), Te = Se;
|
|
1254
1255
|
for (const S of B) if (typeof S == "number") {
|
|
1255
1256
|
let ie;
|
|
1256
1257
|
const Oe = o(B.getComponent()), ce = S - x;
|
|
1257
1258
|
{
|
|
1258
1259
|
let Be;
|
|
1259
|
-
for (; Ne && typeof (Be =
|
|
1260
|
+
for (; Ne && typeof (Be = M.getKey()) == "number"; ) {
|
|
1260
1261
|
Be += P;
|
|
1261
|
-
const Re =
|
|
1262
|
+
const Re = M.getComponent(), Xe = O(Re);
|
|
1262
1263
|
if (Be > ce || Be === ce && (!Xe || D === 0 && Oe)) break;
|
|
1263
1264
|
if (Xe) {
|
|
1264
1265
|
P--;
|
|
1265
1266
|
const Ke = Re.p;
|
|
1266
|
-
K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 ||
|
|
1267
|
+
K.includes(Ke), Re.d, a(te[Re.d]), O(a(te[Re.d])), (Re.r === void 0 || Ue && Ue.has(Re)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || We--;
|
|
1267
1268
|
}
|
|
1268
|
-
Ne =
|
|
1269
|
+
Ne = M.nextSibling();
|
|
1269
1270
|
}
|
|
1270
|
-
ie = Ne && Be === ce ?
|
|
1271
|
+
ie = Ne && Be === ce ? M : null;
|
|
1271
1272
|
}
|
|
1272
1273
|
const ke = ce - P;
|
|
1273
1274
|
let Ge = ze(ke);
|
|
@@ -1276,7 +1277,7 @@ function Lt() {
|
|
|
1276
1277
|
{
|
|
1277
1278
|
let Be, Re;
|
|
1278
1279
|
for (; Se && typeof (Be = A.getKey()) == "number"; ) {
|
|
1279
|
-
Re = Be -
|
|
1280
|
+
Re = Be - be;
|
|
1280
1281
|
const Xe = A.getComponent(), Ke = o(Xe);
|
|
1281
1282
|
if (Re > rt) break;
|
|
1282
1283
|
if (Re === rt) {
|
|
@@ -1295,48 +1296,48 @@ function Lt() {
|
|
|
1295
1296
|
}
|
|
1296
1297
|
if (Ke) {
|
|
1297
1298
|
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) && (
|
|
1299
|
+
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
|
}
|
|
1300
1301
|
Se = A.nextSibling();
|
|
1301
1302
|
}
|
|
1302
1303
|
}
|
|
1303
|
-
const Ot = rt +
|
|
1304
|
+
const Ot = rt + be + We + He;
|
|
1304
1305
|
l(Ot >= 0, "trying to descend to a negative index"), k.descend(Ot), Oe && (ie = Ge = Je = null, x++), Q(ie, B, Ge, Je, k, X) && He++, k.ascend();
|
|
1305
1306
|
} else {
|
|
1306
1307
|
let ie;
|
|
1307
|
-
for (; Ne && (ie =
|
|
1308
|
-
const Oe = Ne && ie === S ?
|
|
1308
|
+
for (; Ne && (ie = M.getKey(), typeof ie != "string" || !(ie > S || ie === S)); ) Ne = M.nextSibling();
|
|
1309
|
+
const Oe = Ne && ie === S ? M : null, ce = ze(S);
|
|
1309
1310
|
let ke;
|
|
1310
1311
|
for (; Se && (ke = A.getKey(), typeof ke != "string" || !(ke > S || ke === S)); ) Se = A.nextSibling();
|
|
1311
1312
|
const Ge = Se && ke === S ? A : null;
|
|
1312
1313
|
k.descend(S), Q(Oe, B, ce, Ge, k, X), k.ascend();
|
|
1313
1314
|
}
|
|
1314
|
-
return ze.end(), Ye &&
|
|
1315
|
-
}(
|
|
1315
|
+
return ze.end(), Ye && M.ascend(), Te && A.ascend(), fe;
|
|
1316
|
+
}(me, me.clone(), _e, _e.clone(), oe, null), m) return {
|
|
1316
1317
|
ok: !1,
|
|
1317
|
-
conflict:
|
|
1318
|
+
conflict: m
|
|
1318
1319
|
};
|
|
1319
1320
|
oe.reset();
|
|
1320
|
-
const
|
|
1321
|
-
|
|
1321
|
+
const Me = (Q, M, B) => Q.traverse(M, (U, A) => {
|
|
1322
|
+
U.d != null && B(U.d, Q, A);
|
|
1322
1323
|
});
|
|
1323
|
-
(g.length || re.length) && (
|
|
1324
|
+
(g.length || re.length) && (Me(_e, oe, (Q, M, B) => {
|
|
1324
1325
|
g[Q] && !N[Q] && B.write("r", !0), re[Q] && B.mergeTree(re[Q].get());
|
|
1325
1326
|
}), oe.reset());
|
|
1326
1327
|
const Ee = [], $e = [];
|
|
1327
|
-
if ((te.length || g.length) && !
|
|
1328
|
-
const Q =
|
|
1329
|
-
if (
|
|
1330
|
-
Ee[
|
|
1331
|
-
}), te.forEach((
|
|
1332
|
-
|
|
1333
|
-
Ee[B] =
|
|
1328
|
+
if ((te.length || g.length) && !m) {
|
|
1329
|
+
const Q = s.readCursor(tt(oe.get()));
|
|
1330
|
+
if (Me(Q, null, (M, B) => {
|
|
1331
|
+
Ee[M] = B.clone();
|
|
1332
|
+
}), te.forEach((M) => {
|
|
1333
|
+
M && Me(s.readCursor(M.get()), null, (B, U) => {
|
|
1334
|
+
Ee[B] = U.clone();
|
|
1334
1335
|
});
|
|
1335
|
-
}), function
|
|
1336
|
-
const ee = a(
|
|
1336
|
+
}), function M(B, U, A, k, X, Y) {
|
|
1337
|
+
const ee = a(U);
|
|
1337
1338
|
if (ee && O(ee)) if (ee.p != null) {
|
|
1338
1339
|
const P = ee.p;
|
|
1339
|
-
Ee[P].getPath(), A = Ee[P], k = $e[P] =
|
|
1340
|
+
Ee[P].getPath(), A = Ee[P], k = $e[P] = s.writeCursor();
|
|
1340
1341
|
} else ee.r !== void 0 && (A = null);
|
|
1341
1342
|
else o(a(A)) && (A = null);
|
|
1342
1343
|
const fe = B.getComponent();
|
|
@@ -1344,52 +1345,52 @@ function Lt() {
|
|
|
1344
1345
|
let P;
|
|
1345
1346
|
if ((P = fe.d) != null) {
|
|
1346
1347
|
const x = te[P];
|
|
1347
|
-
x && (x.get(), k.mergeTree(x.get()), A =
|
|
1348
|
+
x && (x.get(), k.mergeTree(x.get()), A = s.readCursor(x.get()));
|
|
1348
1349
|
}
|
|
1349
1350
|
}
|
|
1350
1351
|
let de = 0, le = 0;
|
|
1351
|
-
const ye =
|
|
1352
|
+
const ye = s.advancer(U, void 0, (P, x) => {
|
|
1352
1353
|
O(x) && de--;
|
|
1353
|
-
}), q =
|
|
1354
|
+
}), q = s.advancer(A, (P, x) => o(x) ? -(P - le) - 1 : P - le, (P, x) => {
|
|
1354
1355
|
o(x) && le++;
|
|
1355
1356
|
});
|
|
1356
1357
|
for (const P of B) if (typeof P == "number") {
|
|
1357
|
-
const x = ye(P), he = P + de,
|
|
1358
|
-
k.descend(We),
|
|
1359
|
-
} else k.descend(P),
|
|
1358
|
+
const x = ye(P), he = P + de, be = q(he), We = he + le;
|
|
1359
|
+
k.descend(We), M(B, x, be, k), k.ascend();
|
|
1360
|
+
} else k.descend(P), M(B, ye(P), q(P), k), k.ascend();
|
|
1360
1361
|
ye.end(), q.end();
|
|
1361
|
-
}(_e, Q, Q.clone(), oe), oe.reset(),
|
|
1362
|
+
}(_e, Q, Q.clone(), oe), oe.reset(), m) return {
|
|
1362
1363
|
ok: !1,
|
|
1363
|
-
conflict:
|
|
1364
|
+
conflict: m
|
|
1364
1365
|
};
|
|
1365
1366
|
if (oe.get(), $e.length) {
|
|
1366
|
-
const
|
|
1367
|
-
if (
|
|
1368
|
-
const X = U
|
|
1369
|
-
X && (k.mergeTree(X), U
|
|
1370
|
-
}),
|
|
1371
|
-
const
|
|
1367
|
+
const M = $e.map((U) => U ? U.get() : null), B = s.readCursor(tt(oe.get()));
|
|
1368
|
+
if (Me(B, oe, (U, A, k) => {
|
|
1369
|
+
const X = M[U];
|
|
1370
|
+
X && (k.mergeTree(X), M[U] = null);
|
|
1371
|
+
}), M.find((U) => U)) {
|
|
1372
|
+
const U = s.writeCursor(), A = s.writeCursor();
|
|
1372
1373
|
let k = 0, X = 0;
|
|
1373
|
-
|
|
1374
|
-
Y != null &&
|
|
1374
|
+
M.forEach((Y) => {
|
|
1375
|
+
Y != null && Me(s.readCursor(Y), null, (ee) => {
|
|
1375
1376
|
const fe = Le[ee];
|
|
1376
|
-
|
|
1377
|
+
U.writeMove(C[fe].getPath(), $[fe].getPath(), k++);
|
|
1377
1378
|
const de = se[fe];
|
|
1378
1379
|
de && de.forEach((le) => {
|
|
1379
|
-
g[le] || D !== 1 && K[le] != null || A.writeMove(
|
|
1380
|
+
g[le] || D !== 1 && K[le] != null || A.writeMove(T[le].getPath(), p[le].getPath(), X++);
|
|
1380
1381
|
});
|
|
1381
1382
|
});
|
|
1382
|
-
}),
|
|
1383
|
+
}), m = {
|
|
1383
1384
|
type: d.ConflictType.BLACKHOLE,
|
|
1384
|
-
op1:
|
|
1385
|
+
op1: U.get(),
|
|
1385
1386
|
op2: A.get()
|
|
1386
1387
|
};
|
|
1387
1388
|
}
|
|
1388
1389
|
}
|
|
1389
1390
|
}
|
|
1390
|
-
return
|
|
1391
|
+
return m ? {
|
|
1391
1392
|
ok: !1,
|
|
1392
|
-
conflict:
|
|
1393
|
+
conflict: m
|
|
1393
1394
|
} : {
|
|
1394
1395
|
ok: !0,
|
|
1395
1396
|
result: oe.get()
|
|
@@ -1405,36 +1406,36 @@ function Lt() {
|
|
|
1405
1406
|
gt(D.conflict);
|
|
1406
1407
|
}
|
|
1407
1408
|
const qe = (r) => {
|
|
1408
|
-
const u =
|
|
1409
|
-
return
|
|
1409
|
+
const u = s.writeCursor();
|
|
1410
|
+
return s.readCursor(r).traverse(u, (y, D) => {
|
|
1410
1411
|
(o(y) || ve(y)) && D.write("r", !0);
|
|
1411
1412
|
}), u.get();
|
|
1412
1413
|
}, At = (r, u) => {
|
|
1413
|
-
const { type: y, op1: D, op2:
|
|
1414
|
+
const { type: y, op1: D, op2: m } = r;
|
|
1414
1415
|
switch (y) {
|
|
1415
1416
|
case d.ConflictType.DROP_COLLISION:
|
|
1416
|
-
return u === "left" ? [null, qe(
|
|
1417
|
+
return u === "left" ? [null, qe(m)] : [qe(D), null];
|
|
1417
1418
|
case d.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1418
1419
|
let C = !1;
|
|
1419
|
-
return
|
|
1420
|
+
return s.readCursor(D).traverse(null, ($) => {
|
|
1420
1421
|
$.r !== void 0 && (C = !0);
|
|
1421
|
-
}), C ? [null, qe(
|
|
1422
|
+
}), C ? [null, qe(m)] : [qe(D), null];
|
|
1422
1423
|
case d.ConflictType.BLACKHOLE:
|
|
1423
|
-
return [qe(D), qe(
|
|
1424
|
+
return [qe(D), qe(m)];
|
|
1424
1425
|
default:
|
|
1425
1426
|
throw Error("Unrecognised conflict: " + y);
|
|
1426
1427
|
}
|
|
1427
1428
|
};
|
|
1428
1429
|
function _t(r, u, y, D) {
|
|
1429
|
-
let
|
|
1430
|
+
let m = null;
|
|
1430
1431
|
for (; ; ) {
|
|
1431
1432
|
const C = nt(u, y, D);
|
|
1432
|
-
if (C.ok) return ne(
|
|
1433
|
+
if (C.ok) return ne(m, C.result);
|
|
1433
1434
|
{
|
|
1434
1435
|
const { conflict: $ } = C;
|
|
1435
1436
|
r($) || gt($);
|
|
1436
|
-
const [
|
|
1437
|
-
u = ne(H(u),
|
|
1437
|
+
const [T, p] = At($, D);
|
|
1438
|
+
u = ne(H(u), T), y = ne(H(y), p), m = ne(m, p);
|
|
1438
1439
|
}
|
|
1439
1440
|
}
|
|
1440
1441
|
}
|
|
@@ -1450,15 +1451,15 @@ function Lt() {
|
|
|
1450
1451
|
for (var a in d) a !== "default" && !l.hasOwnProperty(a) && e(l, d, a);
|
|
1451
1452
|
};
|
|
1452
1453
|
Object.defineProperty(n, "__esModule", { value: !0 }), t(Ct, n);
|
|
1453
|
-
var
|
|
1454
|
+
var i = ft;
|
|
1454
1455
|
Object.defineProperty(n, "ReadCursor", { enumerable: !0, get: function() {
|
|
1455
|
-
return
|
|
1456
|
+
return i.ReadCursor;
|
|
1456
1457
|
} }), Object.defineProperty(n, "WriteCursor", { enumerable: !0, get: function() {
|
|
1457
|
-
return
|
|
1458
|
+
return i.WriteCursor;
|
|
1458
1459
|
} });
|
|
1459
|
-
var
|
|
1460
|
+
var s = ht;
|
|
1460
1461
|
Object.defineProperty(n, "ConflictType", { enumerable: !0, get: function() {
|
|
1461
|
-
return
|
|
1462
|
+
return s.ConflictType;
|
|
1462
1463
|
} });
|
|
1463
1464
|
})(F);
|
|
1464
1465
|
class Ht {
|
|
@@ -1509,10 +1510,8 @@ class Ht {
|
|
|
1509
1510
|
}
|
|
1510
1511
|
refreshTransform(e) {
|
|
1511
1512
|
e.forEach((t) => {
|
|
1512
|
-
if (this.getDrawingByParam(t) == null)
|
|
1513
|
-
return;
|
|
1514
1513
|
const i = this._getCurrentBySearch(t);
|
|
1515
|
-
i != null && (i.transform = t.transform);
|
|
1514
|
+
i != null && (i.transform = t.transform, i.transforms = t.transforms, i.isMultiTransform = t.isMultiTransform);
|
|
1516
1515
|
}), this.refreshTransformNotification(e);
|
|
1517
1516
|
}
|
|
1518
1517
|
getDrawingDataForUnit(e) {
|
|
@@ -1523,25 +1522,25 @@ class Ht {
|
|
|
1523
1522
|
if (t == null)
|
|
1524
1523
|
return;
|
|
1525
1524
|
delete this.drawingManagerData[e];
|
|
1526
|
-
const
|
|
1527
|
-
Object.keys(t).forEach((
|
|
1528
|
-
const d = t[
|
|
1525
|
+
const i = [];
|
|
1526
|
+
Object.keys(t).forEach((s) => {
|
|
1527
|
+
const d = t[s];
|
|
1529
1528
|
(d == null ? void 0 : d.data) != null && Object.keys(d.data).forEach((l) => {
|
|
1530
|
-
|
|
1529
|
+
i.push({ unitId: e, subUnitId: s, drawingId: l });
|
|
1531
1530
|
});
|
|
1532
|
-
}),
|
|
1531
|
+
}), i.length > 0 && this.removeNotification(i);
|
|
1533
1532
|
}
|
|
1534
1533
|
registerDrawingData(e, t) {
|
|
1535
1534
|
this.drawingManagerData[e] = t;
|
|
1536
1535
|
}
|
|
1537
1536
|
initializeNotification(e) {
|
|
1538
|
-
const t = [],
|
|
1539
|
-
|
|
1540
|
-
this._establishDrawingMap(e,
|
|
1541
|
-
const d = s
|
|
1537
|
+
const t = [], i = this.drawingManagerData[e];
|
|
1538
|
+
i != null && (Object.keys(i).forEach((s) => {
|
|
1539
|
+
this._establishDrawingMap(e, s);
|
|
1540
|
+
const d = i[s];
|
|
1542
1541
|
Object.keys(d.data).forEach((l) => {
|
|
1543
1542
|
const a = d.data[l];
|
|
1544
|
-
a.unitId = e, a.subUnitId =
|
|
1543
|
+
a.unitId = e, a.subUnitId = s, t.push(a);
|
|
1545
1544
|
});
|
|
1546
1545
|
}), t.length > 0 && this.addNotification(t));
|
|
1547
1546
|
}
|
|
@@ -1549,34 +1548,34 @@ class Ht {
|
|
|
1549
1548
|
return this._getDrawingData(e, t);
|
|
1550
1549
|
}
|
|
1551
1550
|
// Use in doc only.
|
|
1552
|
-
setDrawingData(e, t,
|
|
1553
|
-
this.drawingManagerData[e][t].data =
|
|
1551
|
+
setDrawingData(e, t, i) {
|
|
1552
|
+
this.drawingManagerData[e][t].data = i;
|
|
1554
1553
|
}
|
|
1555
1554
|
getBatchAddOp(e) {
|
|
1556
|
-
const t = [],
|
|
1555
|
+
const t = [], i = [], s = [];
|
|
1557
1556
|
e.forEach((W) => {
|
|
1558
1557
|
const { op: O, invertOp: o } = this._addByParam(W);
|
|
1559
|
-
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }),
|
|
1558
|
+
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }), i.push(O), s.push(o);
|
|
1560
1559
|
});
|
|
1561
|
-
const d =
|
|
1560
|
+
const d = i.reduce(F.type.compose, null), l = s.reduce(F.type.compose, null), { unitId: a, subUnitId: E } = e[0];
|
|
1562
1561
|
return { undo: l, redo: d, unitId: a, subUnitId: E, objects: t };
|
|
1563
1562
|
}
|
|
1564
1563
|
getBatchRemoveOp(e) {
|
|
1565
|
-
const t = [],
|
|
1564
|
+
const t = [], i = [];
|
|
1566
1565
|
e.forEach((E) => {
|
|
1567
1566
|
const { op: W, invertOp: O } = this._removeByParam(E);
|
|
1568
|
-
t.push(W),
|
|
1567
|
+
t.push(W), i.push(O);
|
|
1569
1568
|
});
|
|
1570
|
-
const
|
|
1571
|
-
return { undo: d, redo:
|
|
1569
|
+
const s = t.reduce(F.type.compose, null), d = i.reduce(F.type.compose, null), { unitId: l, subUnitId: a } = e[0];
|
|
1570
|
+
return { undo: d, redo: s, unitId: l, subUnitId: a, objects: e };
|
|
1572
1571
|
}
|
|
1573
1572
|
getBatchUpdateOp(e) {
|
|
1574
|
-
const t = [],
|
|
1573
|
+
const t = [], i = [], s = [];
|
|
1575
1574
|
e.forEach((W) => {
|
|
1576
1575
|
const { op: O, invertOp: o } = this._updateByParam(W);
|
|
1577
|
-
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }),
|
|
1576
|
+
t.push({ unitId: W.unitId, subUnitId: W.subUnitId, drawingId: W.drawingId }), i.push(O), s.push(o);
|
|
1578
1577
|
});
|
|
1579
|
-
const d =
|
|
1578
|
+
const d = i.reduce(F.type.compose, null), l = s.reduce(F.type.compose, null), { unitId: a, subUnitId: E } = e[0];
|
|
1580
1579
|
return { undo: l, redo: d, unitId: a, subUnitId: E, objects: t };
|
|
1581
1580
|
}
|
|
1582
1581
|
removeNotification(e) {
|
|
@@ -1601,61 +1600,61 @@ class Ht {
|
|
|
1601
1600
|
this._refreshTransform$.next(e);
|
|
1602
1601
|
}
|
|
1603
1602
|
getGroupDrawingOp(e) {
|
|
1604
|
-
const t = [], { unitId:
|
|
1603
|
+
const t = [], { unitId: i, subUnitId: s } = e[0].parent;
|
|
1605
1604
|
e.forEach((a) => {
|
|
1606
1605
|
t.push(this._getGroupDrawingOp(a));
|
|
1607
1606
|
});
|
|
1608
1607
|
const d = t.reduce(F.type.compose, null);
|
|
1609
|
-
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId:
|
|
1608
|
+
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId: i, subUnitId: s, objects: e };
|
|
1610
1609
|
}
|
|
1611
1610
|
getUngroupDrawingOp(e) {
|
|
1612
|
-
const t = [], { unitId:
|
|
1611
|
+
const t = [], { unitId: i, subUnitId: s } = e[0].parent;
|
|
1613
1612
|
e.forEach((a) => {
|
|
1614
1613
|
t.push(this._getUngroupDrawingOp(a));
|
|
1615
1614
|
});
|
|
1616
1615
|
const d = t.reduce(F.type.compose, null);
|
|
1617
|
-
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId:
|
|
1616
|
+
return { undo: F.type.invertWithDoc(d, this.drawingManagerData), redo: d, unitId: i, subUnitId: s, objects: e };
|
|
1618
1617
|
}
|
|
1619
1618
|
getDrawingsByGroup(e) {
|
|
1620
|
-
const { unitId: t, subUnitId:
|
|
1621
|
-
if (this.getDrawingByParam({ unitId: t, subUnitId:
|
|
1619
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1620
|
+
if (this.getDrawingByParam({ unitId: t, subUnitId: i, drawingId: s }) == null)
|
|
1622
1621
|
return [];
|
|
1623
|
-
const l = this._getDrawingData(t,
|
|
1622
|
+
const l = this._getDrawingData(t, i), a = [];
|
|
1624
1623
|
return Object.keys(l).forEach((E) => {
|
|
1625
1624
|
const W = l[E];
|
|
1626
|
-
W.groupId ===
|
|
1625
|
+
W.groupId === s && a.push(W);
|
|
1627
1626
|
}), a;
|
|
1628
1627
|
}
|
|
1629
1628
|
_getGroupDrawingOp(e) {
|
|
1630
|
-
const { parent: t, children:
|
|
1629
|
+
const { parent: t, children: i } = e, { unitId: s, subUnitId: d, drawingId: l } = t, a = [];
|
|
1631
1630
|
a.push(
|
|
1632
|
-
F.insertOp([
|
|
1631
|
+
F.insertOp([s, d, "data", l], t)
|
|
1633
1632
|
);
|
|
1634
1633
|
let E = Number.NEGATIVE_INFINITY;
|
|
1635
|
-
return
|
|
1634
|
+
return i.forEach((W) => {
|
|
1636
1635
|
const { unitId: O, subUnitId: o, drawingId: c } = W, h = this._hasDrawingOrder({ unitId: O, subUnitId: o, drawingId: c });
|
|
1637
1636
|
E = Math.max(E, h), a.push(
|
|
1638
1637
|
...this._getUpdateParamCompareOp(W, this.getDrawingByParam({ unitId: O, subUnitId: o, drawingId: c }))
|
|
1639
1638
|
);
|
|
1640
|
-
}), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(
|
|
1641
|
-
F.insertOp([
|
|
1639
|
+
}), E === Number.NEGATIVE_INFINITY && (E = this._getDrawingOrder(s, d).length), a.push(
|
|
1640
|
+
F.insertOp([s, d, "order", E], l)
|
|
1642
1641
|
), a.reduce(F.type.compose, null);
|
|
1643
1642
|
}
|
|
1644
1643
|
_getUngroupDrawingOp(e) {
|
|
1645
|
-
const { parent: t, children:
|
|
1646
|
-
return
|
|
1644
|
+
const { parent: t, children: i } = e, { unitId: s, subUnitId: d, drawingId: l } = t, a = [];
|
|
1645
|
+
return i.forEach((E) => {
|
|
1647
1646
|
const { unitId: W, subUnitId: O, drawingId: o } = E;
|
|
1648
1647
|
a.push(
|
|
1649
1648
|
...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId: W, subUnitId: O, drawingId: o }))
|
|
1650
1649
|
);
|
|
1651
1650
|
}), a.push(
|
|
1652
|
-
F.removeOp([
|
|
1651
|
+
F.removeOp([s, d, "data", l], !0)
|
|
1653
1652
|
), a.push(
|
|
1654
|
-
F.removeOp([
|
|
1653
|
+
F.removeOp([s, d, "order", this._getDrawingOrder(s, d).indexOf(l)], !0)
|
|
1655
1654
|
), a.reduce(F.type.compose, null);
|
|
1656
1655
|
}
|
|
1657
|
-
applyJson1(e, t,
|
|
1658
|
-
this._establishDrawingMap(e, t), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = F.type.apply(this.drawingManagerData,
|
|
1656
|
+
applyJson1(e, t, i) {
|
|
1657
|
+
this._establishDrawingMap(e, t), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = F.type.apply(this.drawingManagerData, i);
|
|
1659
1658
|
}
|
|
1660
1659
|
// private _fillMissingFields(jsonOp: JSONOp) {
|
|
1661
1660
|
// if (jsonOp == null) {
|
|
@@ -1702,8 +1701,8 @@ class Ht {
|
|
|
1702
1701
|
return this._getOldBySearch(e);
|
|
1703
1702
|
}
|
|
1704
1703
|
getDrawingOKey(e) {
|
|
1705
|
-
const [t,
|
|
1706
|
-
return this._getCurrentBySearch({ unitId: t, subUnitId:
|
|
1704
|
+
const [t, i, s] = e.split("#-#");
|
|
1705
|
+
return this._getCurrentBySearch({ unitId: t, subUnitId: i, drawingId: s });
|
|
1707
1706
|
}
|
|
1708
1707
|
focusDrawing(e) {
|
|
1709
1708
|
if (e == null) {
|
|
@@ -1711,9 +1710,9 @@ class Ht {
|
|
|
1711
1710
|
return;
|
|
1712
1711
|
}
|
|
1713
1712
|
const t = [];
|
|
1714
|
-
e.forEach((
|
|
1713
|
+
e.forEach((i) => {
|
|
1715
1714
|
var E;
|
|
1716
|
-
const { unitId:
|
|
1715
|
+
const { unitId: s, subUnitId: d, drawingId: l } = i, a = (E = this._getDrawingData(s, d)) == null ? void 0 : E[l];
|
|
1717
1716
|
a != null && t.push(a);
|
|
1718
1717
|
}), t.length > 0 && (this._focusDrawings = t, this._focus$.next(t));
|
|
1719
1718
|
}
|
|
@@ -1721,7 +1720,7 @@ class Ht {
|
|
|
1721
1720
|
const e = [];
|
|
1722
1721
|
return this._focusDrawings.forEach((t) => {
|
|
1723
1722
|
var a;
|
|
1724
|
-
const { unitId:
|
|
1723
|
+
const { unitId: i, subUnitId: s, drawingId: d } = t, l = (a = this._getDrawingData(i, s)) == null ? void 0 : a[d];
|
|
1725
1724
|
l != null && e.push(l);
|
|
1726
1725
|
}), e;
|
|
1727
1726
|
}
|
|
@@ -1729,107 +1728,107 @@ class Ht {
|
|
|
1729
1728
|
return this._getDrawingOrder(e, t);
|
|
1730
1729
|
}
|
|
1731
1730
|
// Use in doc only.
|
|
1732
|
-
setDrawingOrder(e, t,
|
|
1733
|
-
this.drawingManagerData[e][t].order =
|
|
1731
|
+
setDrawingOrder(e, t, i) {
|
|
1732
|
+
this.drawingManagerData[e][t].order = i;
|
|
1734
1733
|
}
|
|
1735
1734
|
orderUpdateNotification(e) {
|
|
1736
1735
|
this._order$.next(e);
|
|
1737
1736
|
}
|
|
1738
1737
|
getForwardDrawingsOp(e) {
|
|
1739
|
-
const { unitId: t, subUnitId:
|
|
1740
|
-
|
|
1741
|
-
const o = this._hasDrawingOrder({ unitId: t, subUnitId:
|
|
1738
|
+
const { unitId: t, subUnitId: i, drawingIds: s } = e, d = [], l = this.getDrawingOrder(t, i), a = [...s];
|
|
1739
|
+
s.forEach((O) => {
|
|
1740
|
+
const o = this._hasDrawingOrder({ unitId: t, subUnitId: i, drawingId: O });
|
|
1742
1741
|
if (o === -1 || o === l.length - 1)
|
|
1743
1742
|
return;
|
|
1744
|
-
const c = F.moveOp([t,
|
|
1743
|
+
const c = F.moveOp([t, i, "order", o], [t, i, "order", o + 1]);
|
|
1745
1744
|
d.push(c), a.includes(l[o + 1]) || a.push(l[o + 1]);
|
|
1746
1745
|
});
|
|
1747
1746
|
const E = d.reduce(F.type.compose, null);
|
|
1748
|
-
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId:
|
|
1747
|
+
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: i, objects: { ...e, drawingIds: a } };
|
|
1749
1748
|
}
|
|
1750
1749
|
getBackwardDrawingOp(e) {
|
|
1751
|
-
const { unitId: t, subUnitId:
|
|
1752
|
-
|
|
1753
|
-
const o = this._hasDrawingOrder({ unitId: t, subUnitId:
|
|
1750
|
+
const { unitId: t, subUnitId: i, drawingIds: s } = e, d = [], l = this.getDrawingOrder(t, i), a = [...s];
|
|
1751
|
+
s.forEach((O) => {
|
|
1752
|
+
const o = this._hasDrawingOrder({ unitId: t, subUnitId: i, drawingId: O });
|
|
1754
1753
|
if (o === -1 || o === 0)
|
|
1755
1754
|
return;
|
|
1756
|
-
const c = F.moveOp([t,
|
|
1755
|
+
const c = F.moveOp([t, i, "order", o], [t, i, "order", o - 1]);
|
|
1757
1756
|
d.push(c), a.includes(l[o - 1]) || a.push(l[o - 1]);
|
|
1758
1757
|
});
|
|
1759
1758
|
const E = d.reduce(F.type.compose, null);
|
|
1760
|
-
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId:
|
|
1759
|
+
return { undo: F.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: i, objects: { ...e, drawingIds: a } };
|
|
1761
1760
|
}
|
|
1762
1761
|
getFrontDrawingsOp(e) {
|
|
1763
|
-
const { unitId: t, subUnitId:
|
|
1762
|
+
const { unitId: t, subUnitId: i, drawingIds: s } = e, d = this._getOrderFromSearchParams(t, i, s), l = [...s], a = this.getDrawingOrder(t, i), E = [];
|
|
1764
1763
|
d.forEach((o) => {
|
|
1765
|
-
const { drawingId: c } = o, h = this._getDrawingCount(t,
|
|
1764
|
+
const { drawingId: c } = o, h = this._getDrawingCount(t, i) - 1, R = F.moveOp([t, i, "order", this._getDrawingOrder(t, i).indexOf(c)], [t, i, "order", h]);
|
|
1766
1765
|
E.push(R), l.includes(a[h]) || l.push(a[h]);
|
|
1767
1766
|
});
|
|
1768
1767
|
const W = E.reduce(F.type.compose, null);
|
|
1769
|
-
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId:
|
|
1768
|
+
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId: i, objects: { ...e, drawingIds: l } };
|
|
1770
1769
|
}
|
|
1771
1770
|
getBackDrawingsOp(e) {
|
|
1772
|
-
const { unitId: t, subUnitId:
|
|
1771
|
+
const { unitId: t, subUnitId: i, drawingIds: s } = e, d = this._getOrderFromSearchParams(t, i, s, !0), l = [...s], a = this.getDrawingOrder(t, i), E = [];
|
|
1773
1772
|
d.forEach((o) => {
|
|
1774
|
-
const { drawingId: c } = o, h = F.moveOp([t,
|
|
1773
|
+
const { drawingId: c } = o, h = F.moveOp([t, i, "order", this._getDrawingOrder(t, i).indexOf(c)], [t, i, "order", 0]);
|
|
1775
1774
|
E.push(h), l.includes(a[0]) || l.push(a[0]);
|
|
1776
1775
|
});
|
|
1777
1776
|
const W = E.reduce(F.type.compose, null);
|
|
1778
|
-
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId:
|
|
1777
|
+
return { undo: F.type.invertWithDoc(W, this.drawingManagerData), redo: W, unitId: t, subUnitId: i, objects: { ...e, drawingIds: l } };
|
|
1779
1778
|
}
|
|
1780
1779
|
_getDrawingCount(e, t) {
|
|
1781
1780
|
return this.getDrawingOrder(e, t).length || 0;
|
|
1782
1781
|
}
|
|
1783
|
-
_getOrderFromSearchParams(e, t,
|
|
1784
|
-
return
|
|
1782
|
+
_getOrderFromSearchParams(e, t, i, s = !1) {
|
|
1783
|
+
return i.map((d) => {
|
|
1785
1784
|
const l = this._hasDrawingOrder({ unitId: e, subUnitId: t, drawingId: d });
|
|
1786
1785
|
return { drawingId: d, zIndex: l };
|
|
1787
|
-
}).sort(
|
|
1786
|
+
}).sort(s === !1 ? Ut : Nt);
|
|
1788
1787
|
}
|
|
1789
1788
|
_hasDrawingOrder(e) {
|
|
1790
1789
|
if (e == null)
|
|
1791
1790
|
return -1;
|
|
1792
|
-
const { unitId: t, subUnitId:
|
|
1793
|
-
return this._establishDrawingMap(t,
|
|
1791
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1792
|
+
return this._establishDrawingMap(t, i), this._getDrawingOrder(t, i).indexOf(s);
|
|
1794
1793
|
}
|
|
1795
1794
|
_getCurrentBySearch(e) {
|
|
1796
1795
|
var d, l, a;
|
|
1797
1796
|
if (e == null)
|
|
1798
1797
|
return;
|
|
1799
|
-
const { unitId: t, subUnitId:
|
|
1800
|
-
return (a = (l = (d = this.drawingManagerData[t]) == null ? void 0 : d[
|
|
1798
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1799
|
+
return (a = (l = (d = this.drawingManagerData[t]) == null ? void 0 : d[i]) == null ? void 0 : l.data) == null ? void 0 : a[s];
|
|
1801
1800
|
}
|
|
1802
1801
|
_getOldBySearch(e) {
|
|
1803
1802
|
var d, l, a;
|
|
1804
1803
|
if (e == null)
|
|
1805
1804
|
return;
|
|
1806
|
-
const { unitId: t, subUnitId:
|
|
1807
|
-
return (a = (l = (d = this._oldDrawingManagerData[t]) == null ? void 0 : d[
|
|
1805
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1806
|
+
return (a = (l = (d = this._oldDrawingManagerData[t]) == null ? void 0 : d[i]) == null ? void 0 : l.data) == null ? void 0 : a[s];
|
|
1808
1807
|
}
|
|
1809
|
-
_establishDrawingMap(e, t,
|
|
1810
|
-
var
|
|
1808
|
+
_establishDrawingMap(e, t, i) {
|
|
1809
|
+
var s;
|
|
1811
1810
|
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][t] || (this.drawingManagerData[e][t] = {
|
|
1812
1811
|
data: {},
|
|
1813
1812
|
order: []
|
|
1814
|
-
}),
|
|
1813
|
+
}), i == null ? null : (s = this.drawingManagerData[e][t].data) == null ? void 0 : s[i];
|
|
1815
1814
|
}
|
|
1816
1815
|
_addByParam(e) {
|
|
1817
|
-
const { unitId: t, subUnitId:
|
|
1818
|
-
this._establishDrawingMap(t,
|
|
1819
|
-
const d = F.insertOp([t,
|
|
1816
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1817
|
+
this._establishDrawingMap(t, i, s);
|
|
1818
|
+
const d = F.insertOp([t, i, "data", s], e), l = F.insertOp([t, i, "order", this._getDrawingOrder(t, i).length], s), a = [d, l].reduce(F.type.compose, null), E = F.type.invertWithDoc(a, this.drawingManagerData);
|
|
1820
1819
|
return { op: a, invertOp: E };
|
|
1821
1820
|
}
|
|
1822
1821
|
_removeByParam(e) {
|
|
1823
1822
|
if (e == null)
|
|
1824
1823
|
return { op: [], invertOp: [] };
|
|
1825
|
-
const { unitId: t, subUnitId:
|
|
1826
|
-
if (this._establishDrawingMap(t,
|
|
1824
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e;
|
|
1825
|
+
if (this._establishDrawingMap(t, i, s) == null)
|
|
1827
1826
|
return { op: [], invertOp: [] };
|
|
1828
|
-
const l = F.removeOp([t,
|
|
1827
|
+
const l = F.removeOp([t, i, "data", s], !0), a = F.removeOp([t, i, "order", this._getDrawingOrder(t, i).indexOf(s)], !0), E = [l, a].reduce(F.type.compose, null), W = F.type.invertWithDoc(E, this.drawingManagerData);
|
|
1829
1828
|
return { op: E, invertOp: W };
|
|
1830
1829
|
}
|
|
1831
1830
|
_updateByParam(e) {
|
|
1832
|
-
const { unitId: t, subUnitId:
|
|
1831
|
+
const { unitId: t, subUnitId: i, drawingId: s } = e, d = this._establishDrawingMap(t, i, s);
|
|
1833
1832
|
if (d == null)
|
|
1834
1833
|
return { op: [], invertOp: [] };
|
|
1835
1834
|
const a = this._getUpdateParamCompareOp(e, d).reduce(F.type.compose, null), E = F.type.invertWithDoc(a, this.drawingManagerData);
|
|
@@ -1843,21 +1842,21 @@ class Ht {
|
|
|
1843
1842
|
// });
|
|
1844
1843
|
// }
|
|
1845
1844
|
_getUpdateParamCompareOp(e, t) {
|
|
1846
|
-
const { unitId:
|
|
1845
|
+
const { unitId: i, subUnitId: s, drawingId: d } = e, l = [];
|
|
1847
1846
|
return Object.keys(e).forEach((a) => {
|
|
1848
1847
|
const E = e[a], W = t[a];
|
|
1849
1848
|
W !== E && l.push(
|
|
1850
|
-
F.replaceOp([
|
|
1849
|
+
F.replaceOp([i, s, "data", d, a], W, E)
|
|
1851
1850
|
);
|
|
1852
1851
|
}), l;
|
|
1853
1852
|
}
|
|
1854
1853
|
_getDrawingData(e, t) {
|
|
1855
|
-
var
|
|
1856
|
-
return ((
|
|
1854
|
+
var i, s;
|
|
1855
|
+
return ((s = (i = this.drawingManagerData[e]) == null ? void 0 : i[t]) == null ? void 0 : s.data) || {};
|
|
1857
1856
|
}
|
|
1858
1857
|
_getDrawingOrder(e, t) {
|
|
1859
|
-
var
|
|
1860
|
-
return ((
|
|
1858
|
+
var i, s;
|
|
1859
|
+
return ((s = (i = this.drawingManagerData[e]) == null ? void 0 : i[t]) == null ? void 0 : s.order) || [];
|
|
1861
1860
|
}
|
|
1862
1861
|
getDrawingVisible() {
|
|
1863
1862
|
return this._visible;
|
|
@@ -1874,20 +1873,19 @@ class Ht {
|
|
|
1874
1873
|
}
|
|
1875
1874
|
class Kt extends Ht {
|
|
1876
1875
|
}
|
|
1877
|
-
function
|
|
1878
|
-
|
|
1879
|
-
return `${e}#-#${t}#-#${s}`;
|
|
1876
|
+
function cn({ unitId: n, subUnitId: e, drawingId: t }, i) {
|
|
1877
|
+
return typeof i == "number" ? `${n}#-#${e}#-#${t}#-#${i}` : `${n}#-#${e}#-#${t}`;
|
|
1880
1878
|
}
|
|
1881
|
-
const
|
|
1882
|
-
const
|
|
1883
|
-
|
|
1879
|
+
const un = async (n) => new Promise((e, t) => {
|
|
1880
|
+
const i = new Image();
|
|
1881
|
+
i.src = n, i.onload = () => {
|
|
1884
1882
|
e({
|
|
1885
|
-
width:
|
|
1886
|
-
height:
|
|
1887
|
-
image:
|
|
1883
|
+
width: i.width,
|
|
1884
|
+
height: i.height,
|
|
1885
|
+
image: i
|
|
1888
1886
|
});
|
|
1889
|
-
},
|
|
1890
|
-
t(
|
|
1887
|
+
}, i.onerror = (s) => {
|
|
1888
|
+
t(s);
|
|
1891
1889
|
};
|
|
1892
1890
|
});
|
|
1893
1891
|
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 || {});
|
|
@@ -1904,33 +1902,33 @@ class Ft {
|
|
|
1904
1902
|
}
|
|
1905
1903
|
getImageSourceCache(e, t) {
|
|
1906
1904
|
if (t === et.BASE64) {
|
|
1907
|
-
const
|
|
1908
|
-
return
|
|
1905
|
+
const i = new Image();
|
|
1906
|
+
return i.src = e, i;
|
|
1909
1907
|
}
|
|
1910
1908
|
return this._imageSourceCache.get(e);
|
|
1911
1909
|
}
|
|
1912
|
-
addImageSourceCache(e, t,
|
|
1913
|
-
t === et.BASE64 ||
|
|
1910
|
+
addImageSourceCache(e, t, i) {
|
|
1911
|
+
t === et.BASE64 || i == null || this._imageSourceCache.set(e, i);
|
|
1914
1912
|
}
|
|
1915
1913
|
async getImage(e) {
|
|
1916
1914
|
return Promise.resolve(e);
|
|
1917
1915
|
}
|
|
1918
1916
|
async saveImage(e) {
|
|
1919
|
-
return new Promise((t,
|
|
1917
|
+
return new Promise((t, i) => {
|
|
1920
1918
|
if (!Wt.includes(e.type)) {
|
|
1921
|
-
|
|
1919
|
+
i(new Error(Ze.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
|
|
1922
1920
|
return;
|
|
1923
1921
|
}
|
|
1924
1922
|
if (e.size > $t) {
|
|
1925
|
-
|
|
1923
|
+
i(new Error(Ze.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
|
|
1926
1924
|
return;
|
|
1927
1925
|
}
|
|
1928
|
-
const
|
|
1929
|
-
|
|
1926
|
+
const s = new FileReader();
|
|
1927
|
+
s.readAsDataURL(e), s.onload = (d) => {
|
|
1930
1928
|
var E;
|
|
1931
1929
|
const l = (E = d.target) == null ? void 0 : E.result;
|
|
1932
1930
|
if (l == null) {
|
|
1933
|
-
|
|
1931
|
+
i(new Error(Ze.ERROR_IMAGE)), this._decreaseWaiting();
|
|
1934
1932
|
return;
|
|
1935
1933
|
}
|
|
1936
1934
|
const a = kt.generateRandomId(6);
|
|
@@ -1948,17 +1946,17 @@ class Ft {
|
|
|
1948
1946
|
this._waitCount -= 1, this._change$.next(this._waitCount);
|
|
1949
1947
|
}
|
|
1950
1948
|
}
|
|
1951
|
-
const
|
|
1949
|
+
const dn = "__default_document_sub_component_id20231101__";
|
|
1952
1950
|
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 || {});
|
|
1953
1951
|
const Xt = It("univer.drawing-manager.service");
|
|
1954
|
-
var Yt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Jt = (n, e, t,
|
|
1955
|
-
for (var
|
|
1956
|
-
(l = n[d]) && (
|
|
1957
|
-
return
|
|
1958
|
-
}, Qt = (n, e) => (t,
|
|
1952
|
+
var Yt = Object.defineProperty, Zt = Object.getOwnPropertyDescriptor, Jt = (n, e, t, i) => {
|
|
1953
|
+
for (var s = i > 1 ? void 0 : i ? Zt(e, t) : e, d = n.length - 1, l; d >= 0; d--)
|
|
1954
|
+
(l = n[d]) && (s = (i ? l(e, t, s) : l(s)) || s);
|
|
1955
|
+
return i && s && Yt(e, t, s), s;
|
|
1956
|
+
}, Qt = (n, e) => (t, i) => e(t, i, n);
|
|
1959
1957
|
const en = "DRAWING_PLUGIN";
|
|
1960
1958
|
var ot;
|
|
1961
|
-
let wt = (ot = class extends
|
|
1959
|
+
let wt = (ot = class extends Rt {
|
|
1962
1960
|
constructor(n, e) {
|
|
1963
1961
|
super(), this._config = n, this._injector = e;
|
|
1964
1962
|
}
|
|
@@ -1966,24 +1964,24 @@ let wt = (ot = class extends jt {
|
|
|
1966
1964
|
this._initDependencies(n);
|
|
1967
1965
|
}
|
|
1968
1966
|
_initDependencies(n) {
|
|
1969
|
-
var
|
|
1970
|
-
|
|
1967
|
+
var i;
|
|
1968
|
+
St([
|
|
1971
1969
|
[Vt, { useClass: Ft }],
|
|
1972
1970
|
[Xt, { useClass: Kt }]
|
|
1973
|
-
], (
|
|
1971
|
+
], (i = this._config) == null ? void 0 : i.override).forEach((s) => n.add(s));
|
|
1974
1972
|
}
|
|
1975
1973
|
}, V(ot, "pluginName", en), ot);
|
|
1976
1974
|
wt = Jt([
|
|
1977
|
-
Qt(1,
|
|
1975
|
+
Qt(1, Tt(jt))
|
|
1978
1976
|
], wt);
|
|
1979
1977
|
export {
|
|
1980
1978
|
qt as ArrangeTypeEnum,
|
|
1981
|
-
|
|
1979
|
+
dn as DEFAULT_DOCUMENT_SUB_COMPONENT_ID,
|
|
1982
1980
|
Wt as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
1983
1981
|
$t as DRAWING_IMAGE_ALLOW_SIZE,
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1982
|
+
an as DRAWING_IMAGE_COUNT_LIMIT,
|
|
1983
|
+
ln as DRAWING_IMAGE_HEIGHT_LIMIT,
|
|
1984
|
+
on as DRAWING_IMAGE_WIDTH_LIMIT,
|
|
1987
1985
|
Kt as DrawingManagerService,
|
|
1988
1986
|
zt as DrawingTypeEnum,
|
|
1989
1987
|
Xt as IDrawingManagerService,
|
|
@@ -1993,6 +1991,6 @@ export {
|
|
|
1993
1991
|
Ze as ImageUploadStatusType,
|
|
1994
1992
|
Ht as UnitDrawingService,
|
|
1995
1993
|
wt as UniverDrawingPlugin,
|
|
1996
|
-
|
|
1997
|
-
|
|
1994
|
+
cn as getDrawingShapeKeyByDrawingSearch,
|
|
1995
|
+
un as getImageSize
|
|
1998
1996
|
};
|