@univerjs/drawing 0.5.0-nightly.202411291606 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +176 -0
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +479 -480
- package/lib/types/services/image-io.service.d.ts +16 -30
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/es/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var F = (a, e, n) =>
|
|
4
|
-
import { sortRules as
|
|
1
|
+
var jt = Object.defineProperty;
|
|
2
|
+
var $t = (a, e, n) => e in a ? jt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : a[e] = n;
|
|
3
|
+
var F = (a, e, n) => $t(a, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { sortRules as Nt, sortRulesByDesc as Rt, createIdentifier as xt, ImageSourceType as at, ImageUploadStatusType as et, Tools as Bt, Inject as Wt, Injector as Gt, Plugin as Lt, mergeOverrideWithDependencies as qt, IConfigService as Kt, IImageIoService as Ft } from "@univerjs/core";
|
|
5
|
+
import { IImageIoService as wn, ImageSourceType as bn, ImageUploadStatusType as Cn } from "@univerjs/core";
|
|
5
6
|
import { Subject as be } from "rxjs";
|
|
6
|
-
const pn = 500, gn = 500, yn = 10,
|
|
7
|
+
const pn = 500, gn = 500, yn = 10, Vt = 5 * 1024 * 1024, Ht = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"];
|
|
7
8
|
var Ve = {}, Ze = {}, tt = {}, _t;
|
|
8
|
-
function
|
|
9
|
+
function zt() {
|
|
9
10
|
if (_t) return tt;
|
|
10
11
|
_t = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
|
|
11
12
|
function a(t, r) {
|
|
@@ -33,7 +34,7 @@ function Ht() {
|
|
|
33
34
|
return tt.default = n, tt;
|
|
34
35
|
}
|
|
35
36
|
var nt = {}, vt;
|
|
36
|
-
function
|
|
37
|
+
function Xt() {
|
|
37
38
|
if (vt) return nt;
|
|
38
39
|
vt = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
|
|
39
40
|
function a(e) {
|
|
@@ -51,9 +52,9 @@ function zt() {
|
|
|
51
52
|
}
|
|
52
53
|
return nt.default = a, nt;
|
|
53
54
|
}
|
|
54
|
-
var lt = {},
|
|
55
|
-
function
|
|
56
|
-
return
|
|
55
|
+
var lt = {}, mt;
|
|
56
|
+
function At() {
|
|
57
|
+
return mt || (mt = 1, function(a) {
|
|
57
58
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0;
|
|
58
59
|
function e(_, s) {
|
|
59
60
|
if (!_)
|
|
@@ -79,9 +80,9 @@ function Ut() {
|
|
|
79
80
|
}
|
|
80
81
|
getPath() {
|
|
81
82
|
const s = [];
|
|
82
|
-
let c = this.container, h = this.parents.length - 1,
|
|
83
|
-
for (;
|
|
84
|
-
s.unshift(c[
|
|
83
|
+
let c = this.container, h = this.parents.length - 1, S = this.idx;
|
|
84
|
+
for (; S >= 0; )
|
|
85
|
+
s.unshift(c[S]), S === 0 ? (S = this.indexes[h * 2], c = this.parents[h--]) : S -= n(c[S - 1]) ? 2 : 1;
|
|
85
86
|
return s;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
@@ -111,8 +112,8 @@ function Ut() {
|
|
|
111
112
|
const s = this.indexes[this.indexes.length - 1] + 1, c = this.parents[this.parents.length - 1];
|
|
112
113
|
return s >= c.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = c[s], !0);
|
|
113
114
|
}
|
|
114
|
-
_init(s, c, h,
|
|
115
|
-
this.container = s, this.idx = c, this.parents = h.slice(), this.indexes =
|
|
115
|
+
_init(s, c, h, S) {
|
|
116
|
+
this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = S.slice();
|
|
116
117
|
}
|
|
117
118
|
clone() {
|
|
118
119
|
const s = new o();
|
|
@@ -132,17 +133,17 @@ function Ut() {
|
|
|
132
133
|
traverse(s, c) {
|
|
133
134
|
const h = this.getComponent();
|
|
134
135
|
h && c(h, s);
|
|
135
|
-
for (const
|
|
136
|
-
s && s.descend(
|
|
136
|
+
for (const S of this)
|
|
137
|
+
s && s.descend(S), this.traverse(s, c), s && s.ascend();
|
|
137
138
|
}
|
|
138
139
|
eachPick(s, c) {
|
|
139
|
-
this.traverse(s, (h,
|
|
140
|
-
h.p != null && c(h.p,
|
|
140
|
+
this.traverse(s, (h, S) => {
|
|
141
|
+
h.p != null && c(h.p, S);
|
|
141
142
|
});
|
|
142
143
|
}
|
|
143
144
|
eachDrop(s, c) {
|
|
144
|
-
this.traverse(s, (h,
|
|
145
|
-
h.d != null && c(h.d,
|
|
145
|
+
this.traverse(s, (h, S) => {
|
|
146
|
+
h.d != null && c(h.d, S);
|
|
146
147
|
});
|
|
147
148
|
}
|
|
148
149
|
}
|
|
@@ -162,16 +163,16 @@ function Ut() {
|
|
|
162
163
|
this.idx = h;
|
|
163
164
|
else {
|
|
164
165
|
if (!Array.isArray(this.container[h])) {
|
|
165
|
-
const
|
|
166
|
-
this.container.push(
|
|
166
|
+
const S = this.container.splice(h, this.container.length - h);
|
|
167
|
+
this.container.push(S), this.lcIdx > -1 && (this.lcIdx = h);
|
|
167
168
|
}
|
|
168
169
|
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(t(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && t(c, this.container[h][0]); )
|
|
169
170
|
h++;
|
|
170
171
|
if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
|
|
171
172
|
this.container = this.container[h];
|
|
172
173
|
else {
|
|
173
|
-
const
|
|
174
|
-
this.container.splice(h, 0,
|
|
174
|
+
const S = [c];
|
|
175
|
+
this.container.splice(h, 0, S), this.container = S;
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
}
|
|
@@ -216,15 +217,15 @@ function Ut() {
|
|
|
216
217
|
return;
|
|
217
218
|
if (e(Array.isArray(s)), s === this._op)
|
|
218
219
|
throw Error("Cannot merge into my own tree");
|
|
219
|
-
const h = this.lcIdx,
|
|
220
|
-
let
|
|
220
|
+
const h = this.lcIdx, S = this.parents.length;
|
|
221
|
+
let Y = 0;
|
|
221
222
|
for (let pe = 0; pe < s.length; pe++) {
|
|
222
223
|
const Z = s[pe];
|
|
223
|
-
typeof Z == "string" || typeof Z == "number" ? (
|
|
224
|
+
typeof Z == "string" || typeof Z == "number" ? (Y++, this.descend(Z)) : Array.isArray(Z) ? this.mergeTree(Z, c) : typeof Z == "object" && c(Z, this);
|
|
224
225
|
}
|
|
225
|
-
for (;
|
|
226
|
+
for (; Y--; )
|
|
226
227
|
this.ascend();
|
|
227
|
-
this.lcIdx = this.parents.length ===
|
|
228
|
+
this.lcIdx = this.parents.length === S ? h : -1;
|
|
228
229
|
}
|
|
229
230
|
at(s, c) {
|
|
230
231
|
this.descendPath(s), c(this);
|
|
@@ -247,48 +248,48 @@ function Ut() {
|
|
|
247
248
|
}
|
|
248
249
|
a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_);
|
|
249
250
|
function E(_, s, c) {
|
|
250
|
-
let h,
|
|
251
|
-
|
|
252
|
-
function
|
|
251
|
+
let h, S;
|
|
252
|
+
S = h = _ ? _.descendFirst() : !1;
|
|
253
|
+
function Y(pe) {
|
|
253
254
|
let Z;
|
|
254
|
-
for (;
|
|
255
|
+
for (; S; ) {
|
|
255
256
|
const Ce = Z = _.getKey();
|
|
256
257
|
if (pe != null) {
|
|
257
|
-
let
|
|
258
|
-
if (s && typeof Ce == "number" && (Z = s(Ce, _.getComponent()), Z < 0 && (Z = ~Z,
|
|
258
|
+
let Ge = !1;
|
|
259
|
+
if (s && typeof Ce == "number" && (Z = s(Ce, _.getComponent()), Z < 0 && (Z = ~Z, Ge = !0)), t(Z, pe))
|
|
259
260
|
return null;
|
|
260
|
-
if (Z === pe && !
|
|
261
|
+
if (Z === pe && !Ge)
|
|
261
262
|
return _;
|
|
262
263
|
}
|
|
263
|
-
c && typeof Z == "number" && c(Z, _.getComponent()),
|
|
264
|
+
c && typeof Z == "number" && c(Z, _.getComponent()), S = _.nextSibling();
|
|
264
265
|
}
|
|
265
266
|
return null;
|
|
266
267
|
}
|
|
267
|
-
return
|
|
268
|
+
return Y.end = () => {
|
|
268
269
|
h && _.ascend();
|
|
269
|
-
},
|
|
270
|
+
}, Y;
|
|
270
271
|
}
|
|
271
272
|
a.advancer = E;
|
|
272
273
|
function x(_, s, c) {
|
|
273
|
-
let h,
|
|
274
|
-
for (h =
|
|
275
|
-
let Z = h ? _.getKey() : null, Ce =
|
|
276
|
-
Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), c(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null &&
|
|
274
|
+
let h, S, Y, pe;
|
|
275
|
+
for (h = S = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
|
|
276
|
+
let Z = h ? _.getKey() : null, Ce = Y ? s.getKey() : null;
|
|
277
|
+
Z !== null && Ce !== null && (t(Ce, Z) ? Ce = null : Z !== Ce && (Z = null)), c(Z == null ? Ce : Z, Z != null ? _ : null, Ce != null ? s : null), Z != null && h && (h = _.nextSibling()), Ce != null && Y && (Y = s.nextSibling());
|
|
277
278
|
}
|
|
278
|
-
|
|
279
|
+
S && _.ascend(), pe && s.ascend();
|
|
279
280
|
}
|
|
280
281
|
a.eachChildOf = x;
|
|
281
282
|
}(lt)), lt;
|
|
282
283
|
}
|
|
283
|
-
var ut = {},
|
|
284
|
+
var ut = {}, Ot;
|
|
284
285
|
function Mt() {
|
|
285
|
-
return
|
|
286
|
+
return Ot || (Ot = 1, function(a) {
|
|
286
287
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, function(e) {
|
|
287
288
|
e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
|
|
288
289
|
}(a.ConflictType || (a.ConflictType = {}));
|
|
289
290
|
}(ut)), ut;
|
|
290
291
|
}
|
|
291
|
-
var
|
|
292
|
+
var Se = {}, He = {}, wt;
|
|
292
293
|
function ht() {
|
|
293
294
|
return wt || (wt = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.uniToStrPos = He.strPosToUni = void 0, He.strPosToUni = (a, e = a.length) => {
|
|
294
295
|
let n = 0, t = 0;
|
|
@@ -317,52 +318,52 @@ function ft() {
|
|
|
317
318
|
throw Error("Op must be an array of components");
|
|
318
319
|
let y = null;
|
|
319
320
|
for (let b = 0; b < f.length; b++) {
|
|
320
|
-
const
|
|
321
|
-
switch (typeof
|
|
321
|
+
const L = f[b];
|
|
322
|
+
switch (typeof L) {
|
|
322
323
|
case "object":
|
|
323
|
-
if (typeof
|
|
324
|
+
if (typeof L.d != "number" && typeof L.d != "string")
|
|
324
325
|
throw Error("Delete must be number or string");
|
|
325
|
-
if (a.dlen(
|
|
326
|
+
if (a.dlen(L.d) <= 0)
|
|
326
327
|
throw Error("Deletes must not be empty");
|
|
327
328
|
break;
|
|
328
329
|
case "string":
|
|
329
|
-
if (!(
|
|
330
|
+
if (!(L.length > 0))
|
|
330
331
|
throw Error("Inserts cannot be empty");
|
|
331
332
|
break;
|
|
332
333
|
case "number":
|
|
333
|
-
if (!(
|
|
334
|
+
if (!(L > 0))
|
|
334
335
|
throw Error("Skip components must be >0");
|
|
335
336
|
if (typeof y == "number")
|
|
336
337
|
throw Error("Adjacent skip components should be combined");
|
|
337
338
|
break;
|
|
338
339
|
}
|
|
339
|
-
y =
|
|
340
|
+
y = L;
|
|
340
341
|
}
|
|
341
342
|
if (typeof y == "number")
|
|
342
343
|
throw Error("Op has a trailing skip");
|
|
343
344
|
};
|
|
344
345
|
function t(f, y) {
|
|
345
|
-
let b = 0,
|
|
346
|
+
let b = 0, L = 0;
|
|
346
347
|
for (let z = 0; z < f.length; z++) {
|
|
347
348
|
const q = f[z];
|
|
348
|
-
switch (y(q, b,
|
|
349
|
+
switch (y(q, b, L), typeof q) {
|
|
349
350
|
case "object":
|
|
350
351
|
b += a.dlen(q.d);
|
|
351
352
|
break;
|
|
352
353
|
case "string":
|
|
353
|
-
|
|
354
|
+
L += e.strPosToUni(q);
|
|
354
355
|
break;
|
|
355
356
|
case "number":
|
|
356
|
-
b += q,
|
|
357
|
+
b += q, L += q;
|
|
357
358
|
break;
|
|
358
359
|
}
|
|
359
360
|
}
|
|
360
361
|
}
|
|
361
362
|
a.eachOp = t;
|
|
362
363
|
function r(f, y) {
|
|
363
|
-
const b = [],
|
|
364
|
+
const b = [], L = l(b);
|
|
364
365
|
return t(f, (z, q, Ee) => {
|
|
365
|
-
|
|
366
|
+
L(y(z, q, Ee));
|
|
366
367
|
}), s(b);
|
|
367
368
|
}
|
|
368
369
|
const u = (f) => f, o = (f) => r(f, u);
|
|
@@ -380,8 +381,8 @@ function ft() {
|
|
|
380
381
|
f.push(y);
|
|
381
382
|
}, E = (f) => typeof f == "number" ? f : typeof f == "string" ? e.strPosToUni(f) : typeof f.d == "number" ? f.d : e.strPosToUni(f.d);
|
|
382
383
|
a.uniSlice = (f, y, b) => {
|
|
383
|
-
const
|
|
384
|
-
return f.slice(
|
|
384
|
+
const L = e.uniToStrPos(f, y), z = b == null ? 1 / 0 : e.uniToStrPos(f, b);
|
|
385
|
+
return f.slice(L, z);
|
|
385
386
|
};
|
|
386
387
|
const x = (f, y, b) => typeof f == "number" ? b == null ? f - y : Math.min(f, b) - y : a.uniSlice(f, y, b), _ = (f) => {
|
|
387
388
|
let y = 0, b = 0;
|
|
@@ -413,7 +414,7 @@ function ft() {
|
|
|
413
414
|
if (b !== "left" && b !== "right")
|
|
414
415
|
throw Error("side (" + b + ") must be 'left' or 'right'");
|
|
415
416
|
n(f), n(y);
|
|
416
|
-
const
|
|
417
|
+
const L = [], z = l(L), { take: q, peek: Ee } = _(f);
|
|
417
418
|
for (let ne = 0; ne < y.length; ne++) {
|
|
418
419
|
const le = y[ne];
|
|
419
420
|
let ge, De;
|
|
@@ -443,21 +444,21 @@ function ft() {
|
|
|
443
444
|
let ce;
|
|
444
445
|
for (; ce = q(-1); )
|
|
445
446
|
z(ce);
|
|
446
|
-
return s(
|
|
447
|
+
return s(L);
|
|
447
448
|
}
|
|
448
449
|
function h(f, y) {
|
|
449
450
|
n(f), n(y);
|
|
450
|
-
const b = [],
|
|
451
|
+
const b = [], L = l(b), { take: z } = _(f);
|
|
451
452
|
for (let Ee = 0; Ee < y.length; Ee++) {
|
|
452
453
|
const ce = y[Ee];
|
|
453
454
|
let ne, le;
|
|
454
455
|
switch (typeof ce) {
|
|
455
456
|
case "number":
|
|
456
457
|
for (ne = ce; ne > 0; )
|
|
457
|
-
le = z(ne, "d"),
|
|
458
|
+
le = z(ne, "d"), L(le), typeof le != "object" && (ne -= E(le));
|
|
458
459
|
break;
|
|
459
460
|
case "string":
|
|
460
|
-
|
|
461
|
+
L(ce);
|
|
461
462
|
break;
|
|
462
463
|
case "object":
|
|
463
464
|
ne = a.dlen(ce.d);
|
|
@@ -465,26 +466,26 @@ function ft() {
|
|
|
465
466
|
for (; ge < ne; )
|
|
466
467
|
switch (le = z(ne - ge, "d"), typeof le) {
|
|
467
468
|
case "number":
|
|
468
|
-
|
|
469
|
+
L({ d: x(ce.d, ge, ge + le) }), ge += le;
|
|
469
470
|
break;
|
|
470
471
|
case "string":
|
|
471
472
|
ge += e.strPosToUni(le);
|
|
472
473
|
break;
|
|
473
474
|
case "object":
|
|
474
|
-
|
|
475
|
+
L(le);
|
|
475
476
|
}
|
|
476
477
|
break;
|
|
477
478
|
}
|
|
478
479
|
}
|
|
479
480
|
let q;
|
|
480
481
|
for (; q = z(-1); )
|
|
481
|
-
|
|
482
|
+
L(q);
|
|
482
483
|
return s(b);
|
|
483
484
|
}
|
|
484
|
-
const
|
|
485
|
+
const S = (f, y) => {
|
|
485
486
|
let b = 0;
|
|
486
|
-
for (let
|
|
487
|
-
const z = y[
|
|
487
|
+
for (let L = 0; L < y.length && f > b; L++) {
|
|
488
|
+
const z = y[L];
|
|
488
489
|
switch (typeof z) {
|
|
489
490
|
case "number": {
|
|
490
491
|
b += z;
|
|
@@ -500,9 +501,9 @@ function ft() {
|
|
|
500
501
|
}
|
|
501
502
|
}
|
|
502
503
|
return f;
|
|
503
|
-
},
|
|
504
|
+
}, Y = (f, y) => typeof f == "number" ? S(f, y) : f.map((b) => S(b, y));
|
|
504
505
|
function pe(f, y, b) {
|
|
505
|
-
return r(f, (
|
|
506
|
+
return r(f, (L, z) => typeof L == "object" && typeof L.d == "number" ? { d: b.slice(y, z, z + L.d) } : L);
|
|
506
507
|
}
|
|
507
508
|
function Z(f) {
|
|
508
509
|
return r(f, (y) => {
|
|
@@ -523,7 +524,7 @@ function ft() {
|
|
|
523
524
|
function Ce(f) {
|
|
524
525
|
return r(f, (y) => typeof y == "object" && typeof y.d == "string" ? { d: e.strPosToUni(y.d) } : y);
|
|
525
526
|
}
|
|
526
|
-
function
|
|
527
|
+
function Ge(f) {
|
|
527
528
|
let y = !0;
|
|
528
529
|
return t(f, (b) => {
|
|
529
530
|
typeof b == "object" && typeof b.d == "number" && (y = !1);
|
|
@@ -550,28 +551,28 @@ function ft() {
|
|
|
550
551
|
*/
|
|
551
552
|
apply(y, b) {
|
|
552
553
|
n(b);
|
|
553
|
-
const
|
|
554
|
+
const L = f.builder(y);
|
|
554
555
|
for (let z = 0; z < b.length; z++) {
|
|
555
556
|
const q = b[z];
|
|
556
557
|
switch (typeof q) {
|
|
557
558
|
case "number":
|
|
558
|
-
|
|
559
|
+
L.skip(q);
|
|
559
560
|
break;
|
|
560
561
|
case "string":
|
|
561
|
-
|
|
562
|
+
L.append(q);
|
|
562
563
|
break;
|
|
563
564
|
case "object":
|
|
564
|
-
|
|
565
|
+
L.del(a.dlen(q.d));
|
|
565
566
|
break;
|
|
566
567
|
}
|
|
567
568
|
}
|
|
568
|
-
return
|
|
569
|
+
return L.build();
|
|
569
570
|
},
|
|
570
571
|
transform: c,
|
|
571
572
|
compose: h,
|
|
572
|
-
transformPosition:
|
|
573
|
-
transformSelection:
|
|
574
|
-
isInvertible:
|
|
573
|
+
transformPosition: S,
|
|
574
|
+
transformSelection: Y,
|
|
575
|
+
isInvertible: Ge,
|
|
575
576
|
makeInvertible(y, b) {
|
|
576
577
|
return pe(y, b, f);
|
|
577
578
|
},
|
|
@@ -587,7 +588,7 @@ function ft() {
|
|
|
587
588
|
}(ct)), ct;
|
|
588
589
|
}
|
|
589
590
|
var rt = {}, Ct;
|
|
590
|
-
function
|
|
591
|
+
function Jt() {
|
|
591
592
|
if (Ct) return rt;
|
|
592
593
|
Ct = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
|
|
593
594
|
const a = ft(), e = ht();
|
|
@@ -633,26 +634,26 @@ function Xt() {
|
|
|
633
634
|
var It;
|
|
634
635
|
function Yt() {
|
|
635
636
|
return It || (It = 1, function(a) {
|
|
636
|
-
var e =
|
|
637
|
-
|
|
638
|
-
return h[
|
|
637
|
+
var e = Se && Se.__createBinding || (Object.create ? function(c, h, S, Y) {
|
|
638
|
+
Y === void 0 && (Y = S), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
|
|
639
|
+
return h[S];
|
|
639
640
|
} });
|
|
640
|
-
} : function(c, h,
|
|
641
|
-
|
|
642
|
-
}), n =
|
|
641
|
+
} : function(c, h, S, Y) {
|
|
642
|
+
Y === void 0 && (Y = S), c[Y] = h[S];
|
|
643
|
+
}), n = Se && Se.__setModuleDefault || (Object.create ? function(c, h) {
|
|
643
644
|
Object.defineProperty(c, "default", { enumerable: !0, value: h });
|
|
644
645
|
} : function(c, h) {
|
|
645
646
|
c.default = h;
|
|
646
|
-
}), t =
|
|
647
|
+
}), t = Se && Se.__importStar || function(c) {
|
|
647
648
|
if (c && c.__esModule) return c;
|
|
648
649
|
var h = {};
|
|
649
|
-
if (c != null) for (var
|
|
650
|
+
if (c != null) for (var S in c) Object.hasOwnProperty.call(c, S) && e(h, c, S);
|
|
650
651
|
return n(h, c), h;
|
|
651
|
-
}, r =
|
|
652
|
+
}, r = Se && Se.__importDefault || function(c) {
|
|
652
653
|
return c && c.__esModule ? c : { default: c };
|
|
653
654
|
};
|
|
654
655
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0;
|
|
655
|
-
const u = ht(), o = t(ft()), l = r(
|
|
656
|
+
const u = ht(), o = t(ft()), l = r(Jt()), E = {
|
|
656
657
|
create(c) {
|
|
657
658
|
return c;
|
|
658
659
|
},
|
|
@@ -664,17 +665,17 @@ function Yt() {
|
|
|
664
665
|
throw Error("Invalid document snapshot: " + c);
|
|
665
666
|
const h = [];
|
|
666
667
|
return {
|
|
667
|
-
skip(
|
|
668
|
-
let
|
|
669
|
-
if (
|
|
668
|
+
skip(S) {
|
|
669
|
+
let Y = u.uniToStrPos(c, S);
|
|
670
|
+
if (Y > c.length)
|
|
670
671
|
throw Error("The op is too long for this document");
|
|
671
|
-
h.push(c.slice(0,
|
|
672
|
+
h.push(c.slice(0, Y)), c = c.slice(Y);
|
|
672
673
|
},
|
|
673
|
-
append(
|
|
674
|
-
h.push(
|
|
674
|
+
append(S) {
|
|
675
|
+
h.push(S);
|
|
675
676
|
},
|
|
676
|
-
del(
|
|
677
|
-
c = c.slice(u.uniToStrPos(c,
|
|
677
|
+
del(S) {
|
|
678
|
+
c = c.slice(u.uniToStrPos(c, S));
|
|
678
679
|
},
|
|
679
680
|
build() {
|
|
680
681
|
return h.join("") + c;
|
|
@@ -688,10 +689,10 @@ function Yt() {
|
|
|
688
689
|
Object.defineProperty(a, "makeType", { enumerable: !0, get: function() {
|
|
689
690
|
return s.default;
|
|
690
691
|
} });
|
|
691
|
-
}(
|
|
692
|
+
}(Se)), Se;
|
|
692
693
|
}
|
|
693
694
|
var Et;
|
|
694
|
-
function
|
|
695
|
+
function Zt() {
|
|
695
696
|
return Et || (Et = 1, function(a) {
|
|
696
697
|
var e = Ze && Ze.__importDefault || function(i) {
|
|
697
698
|
return i && i.__esModule ? i : {
|
|
@@ -701,7 +702,7 @@ function Jt() {
|
|
|
701
702
|
Object.defineProperty(a, "__esModule", {
|
|
702
703
|
value: !0
|
|
703
704
|
}), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0;
|
|
704
|
-
const n = e(
|
|
705
|
+
const n = e(zt()), t = e(Xt()), r = At(), u = Mt();
|
|
705
706
|
function o(i, d) {
|
|
706
707
|
if (!i) throw new Error(d);
|
|
707
708
|
}
|
|
@@ -720,17 +721,17 @@ function Jt() {
|
|
|
720
721
|
apply: Ee,
|
|
721
722
|
transformPosition: ce,
|
|
722
723
|
compose: ne,
|
|
723
|
-
tryTransform:
|
|
724
|
-
transform:
|
|
724
|
+
tryTransform: st,
|
|
725
|
+
transform: kt,
|
|
725
726
|
makeInvertible: De,
|
|
726
727
|
invert: le,
|
|
727
|
-
invertWithDoc:
|
|
728
|
+
invertWithDoc: Ut,
|
|
728
729
|
RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
729
730
|
DROP_COLLISION: u.ConflictType.DROP_COLLISION,
|
|
730
731
|
BLACKHOLE: u.ConflictType.BLACKHOLE,
|
|
731
|
-
transformNoConflict: (i, d,
|
|
732
|
+
transformNoConflict: (i, d, m) => gt(() => !0, i, d, m),
|
|
732
733
|
typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), {
|
|
733
|
-
transform: (d,
|
|
734
|
+
transform: (d, m, D) => gt(i, d, m, D)
|
|
734
735
|
})
|
|
735
736
|
};
|
|
736
737
|
const l = (i) => i ? i.getComponent() : null;
|
|
@@ -741,13 +742,13 @@ function Jt() {
|
|
|
741
742
|
function c(i, d) {
|
|
742
743
|
return o(i != null), typeof d == "number" ? (o(Array.isArray(i), "Invalid key - child is not an array"), (i = i.slice()).splice(d, 1)) : (o(E(i), "Invalid key - child is not an object"), delete (i = Object.assign({}, i))[d]), i;
|
|
743
744
|
}
|
|
744
|
-
function h(i, d,
|
|
745
|
-
return typeof d == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= d, "Cannot insert into out of bounds index"), i.splice(d, 0,
|
|
745
|
+
function h(i, d, m) {
|
|
746
|
+
return typeof d == "number" ? (o(i != null, "Container is missing for key"), o(Array.isArray(i), "Cannot use numerical key for object container"), o(i.length >= d, "Cannot insert into out of bounds index"), i.splice(d, 0, m)) : (o(E(i), "Cannot insert into missing item"), o(i[d] === void 0, "Trying to overwrite value at key. Your op needs to remove it first"), i[d] = m), m;
|
|
746
747
|
}
|
|
747
|
-
a.removeOp = (i, d = !0) => r.writeCursor().writeAtPath(i, "r", d).get(), a.moveOp = (i, d) => r.writeCursor().writeMove(i, d).get(), a.insertOp = (i, d) => r.writeCursor().writeAtPath(i, "i", d).get(), a.replaceOp = (i, d,
|
|
748
|
-
D.write("r", d), D.write("i",
|
|
749
|
-
}).get(), a.editOp = (i, d,
|
|
750
|
-
const
|
|
748
|
+
a.removeOp = (i, d = !0) => r.writeCursor().writeAtPath(i, "r", d).get(), a.moveOp = (i, d) => r.writeCursor().writeMove(i, d).get(), a.insertOp = (i, d) => r.writeCursor().writeAtPath(i, "i", d).get(), a.replaceOp = (i, d, m) => r.writeCursor().at(i, (D) => {
|
|
749
|
+
D.write("r", d), D.write("i", m);
|
|
750
|
+
}).get(), a.editOp = (i, d, m, D = !1) => r.writeCursor().at(i, (O) => y(O, d, m, D)).get();
|
|
751
|
+
const S = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => S(i, d) ? i[d] : void 0, pe = {};
|
|
751
752
|
function Z(i) {
|
|
752
753
|
let d = i.type ? i.type : i;
|
|
753
754
|
d.name && (pe[d.name] = d), d.uri && (pe[d.uri] = d);
|
|
@@ -758,32 +759,32 @@ function Jt() {
|
|
|
758
759
|
throw Error("Missing type: " + i);
|
|
759
760
|
};
|
|
760
761
|
Z(Yt());
|
|
761
|
-
const
|
|
762
|
+
const Ge = (i, d) => i + d;
|
|
762
763
|
Z({
|
|
763
764
|
name: "number",
|
|
764
|
-
apply:
|
|
765
|
-
compose:
|
|
765
|
+
apply: Ge,
|
|
766
|
+
compose: Ge,
|
|
766
767
|
invert: (i) => -i,
|
|
767
768
|
transform: (i) => i
|
|
768
769
|
});
|
|
769
|
-
const ve = (i) => i == null ? null : i.et ? Ce(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, d,
|
|
770
|
-
const [
|
|
771
|
-
!D &&
|
|
770
|
+
const ve = (i) => i == null ? null : i.et ? Ce(i.et) : i.es ? pe["text-unicode"] : i.ena != null ? pe.number : null, f = (i) => i.es ? i.es : i.ena != null ? i.ena : i.e, y = (i, d, m, D = !1) => {
|
|
771
|
+
const [O, I] = typeof d == "string" ? [Ce(d), d] : [d, d.name];
|
|
772
|
+
!D && O.isNoop && O.isNoop(m) || (I === "number" ? i.write("ena", m) : I === "text-unicode" ? i.write("es", m) : (i.write("et", I), i.write("e", m)));
|
|
772
773
|
};
|
|
773
774
|
function b(i) {
|
|
774
775
|
o(typeof i == "number"), o(i >= 0), o(i === (0 | i));
|
|
775
776
|
}
|
|
776
|
-
function
|
|
777
|
+
function L(i) {
|
|
777
778
|
typeof i == "number" ? b(i) : o(typeof i == "string");
|
|
778
779
|
}
|
|
779
780
|
function z(i) {
|
|
780
781
|
if (i === null) return;
|
|
781
|
-
const d = /* @__PURE__ */ new Set(),
|
|
782
|
+
const d = /* @__PURE__ */ new Set(), m = /* @__PURE__ */ new Set(), D = (I) => {
|
|
782
783
|
let R = !0, $ = !1;
|
|
783
784
|
for (let p in I) {
|
|
784
785
|
const v = I[p];
|
|
785
786
|
if (R = !1, o(p === "p" || p === "r" || p === "d" || p === "i" || p === "e" || p === "es" || p === "ena" || p === "et", "Invalid component item '" + p + "'"), p === "p") b(v), o(!d.has(v)), d.add(v), o(I.r === void 0);
|
|
786
|
-
else if (p === "d") b(v), o(!
|
|
787
|
+
else if (p === "d") b(v), o(!m.has(v)), m.add(v), o(I.i === void 0);
|
|
787
788
|
else if (p === "e" || p === "es" || p === "ena") {
|
|
788
789
|
o(!$), $ = !0;
|
|
789
790
|
const w = ve(I);
|
|
@@ -791,38 +792,38 @@ function Jt() {
|
|
|
791
792
|
}
|
|
792
793
|
}
|
|
793
794
|
o(!R);
|
|
794
|
-
},
|
|
795
|
+
}, O = (I, R, $) => {
|
|
795
796
|
if (!Array.isArray(I)) throw Error("Op must be null or a list");
|
|
796
797
|
if (I.length === 0) throw Error("Empty descent");
|
|
797
|
-
R ||
|
|
798
|
+
R || L(I[0]);
|
|
798
799
|
let p = 1, v = 0, w = 0;
|
|
799
800
|
for (let C = 0; C < I.length; C++) {
|
|
800
801
|
const N = I[C];
|
|
801
802
|
if (o(N != null), Array.isArray(N)) {
|
|
802
|
-
const B =
|
|
803
|
+
const B = O(N, !1);
|
|
803
804
|
if (v) {
|
|
804
|
-
const g = typeof w,
|
|
805
|
-
g ===
|
|
805
|
+
const g = typeof w, U = typeof B;
|
|
806
|
+
g === U ? o(w < B, "descent keys are not in order") : o(g === "number" && U === "string");
|
|
806
807
|
}
|
|
807
808
|
w = B, v++, p = 3;
|
|
808
|
-
} else typeof N == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(N), p = 2) : (o(p !== 3),
|
|
809
|
+
} else typeof N == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(N), p = 2) : (o(p !== 3), L(N), o(r.isValidPathItem(N), "Invalid path key"), p = 1);
|
|
809
810
|
}
|
|
810
811
|
return o(v !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), I[0];
|
|
811
812
|
};
|
|
812
|
-
|
|
813
|
-
for (let I = 0; I < d.size; I++) o(d.has(I)), o(
|
|
813
|
+
O(i, !0), o(d.size === m.size, "Mismatched picks and drops in op");
|
|
814
|
+
for (let I = 0; I < d.size; I++) o(d.has(I)), o(m.has(I));
|
|
814
815
|
}
|
|
815
816
|
function q(i) {
|
|
816
|
-
let d = 0,
|
|
817
|
+
let d = 0, m = [];
|
|
817
818
|
const D = r.writeCursor();
|
|
818
|
-
return D.mergeTree(i, (
|
|
819
|
-
const R = ve(
|
|
819
|
+
return D.mergeTree(i, (O, I) => {
|
|
820
|
+
const R = ve(O);
|
|
820
821
|
if (R) {
|
|
821
|
-
const p = f(
|
|
822
|
+
const p = f(O);
|
|
822
823
|
y(I, R, R.normalize ? R.normalize(p) : p);
|
|
823
824
|
}
|
|
824
|
-
for (const p of ["r", "p", "i", "d"]) if (
|
|
825
|
-
const v = p === "p" || p === "d" ? ($ =
|
|
825
|
+
for (const p of ["r", "p", "i", "d"]) if (O[p] !== void 0) {
|
|
826
|
+
const v = p === "p" || p === "d" ? ($ = O[p], m[$] == null && (m[$] = d++), m[$]) : O[p];
|
|
826
827
|
I.write(p, v);
|
|
827
828
|
}
|
|
828
829
|
var $;
|
|
@@ -830,15 +831,15 @@ function Jt() {
|
|
|
830
831
|
}
|
|
831
832
|
function Ee(i, d) {
|
|
832
833
|
if (z(d), d === null) return i;
|
|
833
|
-
const
|
|
834
|
-
return function D(
|
|
835
|
-
let R =
|
|
836
|
-
root:
|
|
834
|
+
const m = [];
|
|
835
|
+
return function D(O, I) {
|
|
836
|
+
let R = O, $ = 0, p = {
|
|
837
|
+
root: O
|
|
837
838
|
}, v = 0, w = p, C = "root";
|
|
838
839
|
function N() {
|
|
839
840
|
for (; v < $; v++) {
|
|
840
841
|
let B = I[v];
|
|
841
|
-
typeof B != "object" && (o(
|
|
842
|
+
typeof B != "object" && (o(S(w, C)), w = w[C] = x(w[C]), C = B);
|
|
842
843
|
}
|
|
843
844
|
}
|
|
844
845
|
for (; $ < I.length; $++) {
|
|
@@ -847,44 +848,44 @@ function Jt() {
|
|
|
847
848
|
const g = D(R, B);
|
|
848
849
|
g !== R && g !== void 0 && (N(), R = w[C] = g);
|
|
849
850
|
} else if (typeof B == "object") {
|
|
850
|
-
B.d != null ? (N(), R = h(w, C,
|
|
851
|
+
B.d != null ? (N(), R = h(w, C, m[B.d])) : B.i !== void 0 && (N(), R = h(w, C, B.i));
|
|
851
852
|
const g = ve(B);
|
|
852
853
|
if (g) N(), R = w[C] = g.apply(R, f(B));
|
|
853
854
|
else if (B.e !== void 0) throw Error("Subtype " + B.et + " undefined");
|
|
854
|
-
} else R =
|
|
855
|
+
} else R = Y(R, B);
|
|
855
856
|
}
|
|
856
857
|
return p.root;
|
|
857
|
-
}(i = function D(
|
|
858
|
+
}(i = function D(O, I) {
|
|
858
859
|
const R = [];
|
|
859
860
|
let $ = 0;
|
|
860
861
|
for (; $ < I.length; $++) {
|
|
861
862
|
const C = I[$];
|
|
862
863
|
if (Array.isArray(C)) break;
|
|
863
|
-
typeof C != "object" && (R.push(
|
|
864
|
+
typeof C != "object" && (R.push(O), O = Y(O, C));
|
|
864
865
|
}
|
|
865
|
-
for (let C = I.length - 1; C >= $; C--)
|
|
866
|
+
for (let C = I.length - 1; C >= $; C--) O = D(O, I[C]);
|
|
866
867
|
for (--$; $ >= 0; $--) {
|
|
867
868
|
const C = I[$];
|
|
868
869
|
if (typeof C != "object") {
|
|
869
870
|
const N = R.pop();
|
|
870
|
-
|
|
871
|
-
} else _(C) && (o(
|
|
871
|
+
O = O === Y(N, C) ? N : O === void 0 ? c(N, C) : (v = C, w = O, (p = x(p = N))[v] = w, p);
|
|
872
|
+
} else _(C) && (o(O !== void 0, "Cannot pick up or remove undefined"), C.p != null && (m[C.p] = O), O = void 0);
|
|
872
873
|
}
|
|
873
874
|
var p, v, w;
|
|
874
|
-
return
|
|
875
|
+
return O;
|
|
875
876
|
}(i, d), d);
|
|
876
877
|
}
|
|
877
878
|
function ce(i, d) {
|
|
878
879
|
i = i.slice(), z(d);
|
|
879
|
-
const
|
|
880
|
-
let D,
|
|
880
|
+
const m = r.readCursor(d);
|
|
881
|
+
let D, O, I = !1;
|
|
881
882
|
const R = [];
|
|
882
883
|
for (let p = 0; ; p++) {
|
|
883
|
-
const v = i[p], w =
|
|
884
|
-
if (w && (w.r !== void 0 ? I = !0 : w.p != null && (I = !1, D = w.p,
|
|
884
|
+
const v = i[p], w = m.getComponent();
|
|
885
|
+
if (w && (w.r !== void 0 ? I = !0 : w.p != null && (I = !1, D = w.p, O = p)), p >= i.length) break;
|
|
885
886
|
let C = 0;
|
|
886
|
-
const N = r.advancer(
|
|
887
|
-
_(
|
|
887
|
+
const N = r.advancer(m, void 0, (g, U) => {
|
|
888
|
+
_(U) && C++;
|
|
888
889
|
});
|
|
889
890
|
R.unshift(N);
|
|
890
891
|
const B = N(v);
|
|
@@ -894,178 +895,178 @@ function Jt() {
|
|
|
894
895
|
const $ = () => {
|
|
895
896
|
let p = 0;
|
|
896
897
|
if (D != null) {
|
|
897
|
-
const v =
|
|
898
|
-
p = v.length, i = v.concat(i.slice(
|
|
898
|
+
const v = m.getPath();
|
|
899
|
+
p = v.length, i = v.concat(i.slice(O));
|
|
899
900
|
}
|
|
900
901
|
for (; p < i.length; p++) {
|
|
901
|
-
const v = i[p], w = l(
|
|
902
|
+
const v = i[p], w = l(m), C = ve(w);
|
|
902
903
|
if (C) {
|
|
903
904
|
const g = f(w);
|
|
904
905
|
C.transformPosition && (i[p] = C.transformPosition(i[p], g));
|
|
905
906
|
break;
|
|
906
907
|
}
|
|
907
908
|
let N = 0;
|
|
908
|
-
const B = r.advancer(
|
|
909
|
-
s(
|
|
909
|
+
const B = r.advancer(m, (g, U) => s(U) ? ~(g - N) : g - N, (g, U) => {
|
|
910
|
+
s(U) && N++;
|
|
910
911
|
})(v);
|
|
911
912
|
if (typeof v == "number" && (i[p] += N), !B) break;
|
|
912
913
|
}
|
|
913
914
|
};
|
|
914
|
-
return D != null ?
|
|
915
|
+
return D != null ? m.eachDrop(null, (p) => {
|
|
915
916
|
p === D && $();
|
|
916
917
|
}) : $(), i;
|
|
917
918
|
}
|
|
918
919
|
function ne(i, d) {
|
|
919
920
|
if (z(i), z(d), i == null) return d;
|
|
920
921
|
if (d == null) return i;
|
|
921
|
-
let
|
|
922
|
-
const D = r.readCursor(i),
|
|
922
|
+
let m = 0;
|
|
923
|
+
const D = r.readCursor(i), O = r.readCursor(d), I = r.writeCursor(), R = [], $ = [], p = [], v = [], w = [], C = [], N = /* @__PURE__ */ new Set();
|
|
923
924
|
D.traverse(null, (g) => {
|
|
924
925
|
g.p != null && (p[g.p] = D.clone());
|
|
925
|
-
}),
|
|
926
|
-
g.d != null && (v[g.d] =
|
|
926
|
+
}), O.traverse(null, (g) => {
|
|
927
|
+
g.d != null && (v[g.d] = O.clone());
|
|
927
928
|
});
|
|
928
929
|
const B = r.writeCursor();
|
|
929
|
-
return function g(
|
|
930
|
+
return function g(U, re, te, K, se, Ne, Oe, ye) {
|
|
930
931
|
o(re || te);
|
|
931
|
-
const oe = l(re), Pe = l(te),
|
|
932
|
-
if (Ie != null) K = v[Ie],
|
|
932
|
+
const oe = l(re), Pe = l(te), Ae = !!Pe && Pe.r !== void 0, Le = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ie = Pe ? Pe.p : null, Re = (Ne || Ae) && Ie == null;
|
|
933
|
+
if (Ie != null) K = v[Ie], Oe = $[Ie] = new r.WriteCursor();
|
|
933
934
|
else if (Pe && Pe.r !== void 0) K = null;
|
|
934
935
|
else {
|
|
935
|
-
const
|
|
936
|
-
|
|
936
|
+
const T = l(K);
|
|
937
|
+
T && T.d != null && (K = null);
|
|
937
938
|
}
|
|
938
939
|
const Q = l(K);
|
|
939
|
-
if (
|
|
940
|
+
if (Te != null) if (U = p[Te], ye = R[Te] = new r.WriteCursor(), Re) Ne && !Ae && ye.write("r", !0);
|
|
940
941
|
else {
|
|
941
|
-
const
|
|
942
|
-
|
|
942
|
+
const T = w[Te] = m++;
|
|
943
|
+
Oe.write("d", T);
|
|
943
944
|
}
|
|
944
|
-
else if (oe && oe.i !== void 0)
|
|
945
|
+
else if (oe && oe.i !== void 0) U = null;
|
|
945
946
|
else {
|
|
946
|
-
const
|
|
947
|
-
|
|
947
|
+
const T = l(U);
|
|
948
|
+
T && T.p != null && (U = null);
|
|
948
949
|
}
|
|
949
|
-
let
|
|
950
|
-
|
|
951
|
-
const W = (Ie == null ? !
|
|
950
|
+
let A;
|
|
951
|
+
Le ? (o(se === void 0), A = oe.i) : A = se;
|
|
952
|
+
const W = (Ie == null ? !Le || Ne || Ae : A === void 0) ? null : Oe.getComponent();
|
|
952
953
|
if (Ie != null) {
|
|
953
|
-
if (!(se !== void 0 ||
|
|
954
|
-
const
|
|
955
|
-
C[Ie] =
|
|
954
|
+
if (!(se !== void 0 || Le)) {
|
|
955
|
+
const T = Te != null ? w[Te] : m++;
|
|
956
|
+
C[Ie] = T, ye.write("p", T);
|
|
956
957
|
}
|
|
957
|
-
} else
|
|
958
|
-
const
|
|
959
|
-
if ((
|
|
960
|
-
o(
|
|
961
|
-
const
|
|
962
|
-
y(
|
|
963
|
-
} else
|
|
964
|
-
const k = typeof
|
|
965
|
-
let X = !1,
|
|
966
|
-
const
|
|
967
|
-
s(
|
|
968
|
-
}), H = r.advancer(
|
|
969
|
-
_(
|
|
958
|
+
} else Ae && (Le || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
|
|
959
|
+
const M = Re ? null : ve(oe), P = ve(Q);
|
|
960
|
+
if ((M || P) && (M && M.name, P && P.name), M && P) {
|
|
961
|
+
o(M === P);
|
|
962
|
+
const T = f(oe), G = f(Q), he = M.compose(T, G);
|
|
963
|
+
y(Oe, M, he), N.add(Q);
|
|
964
|
+
} else M ? y(Oe, M, f(oe)) : P && (y(Oe, P, f(Q)), N.add(Q));
|
|
965
|
+
const k = typeof A == "object" && A != null;
|
|
966
|
+
let X = !1, J = 0, ee = 0, fe = 0, de = 0, ae = 0;
|
|
967
|
+
const me = r.advancer(K, (T, G) => s(G) ? de - T - 1 : T - de, (T, G) => {
|
|
968
|
+
s(G) && de++;
|
|
969
|
+
}), H = r.advancer(U, (T, G) => _(G) ? J - T - 1 : T - J, (T, G) => {
|
|
970
|
+
_(G) && J++;
|
|
970
971
|
});
|
|
971
|
-
if (r.eachChildOf(re, te, (
|
|
972
|
-
let we, xe, qe =
|
|
973
|
-
if (typeof
|
|
974
|
-
let _e =
|
|
975
|
-
xe =
|
|
976
|
-
let ue =
|
|
977
|
-
we = H(ue), s(l(xe)) && (we = null), qe = ue +
|
|
978
|
-
const
|
|
979
|
-
(
|
|
980
|
-
} else we = H(
|
|
981
|
-
ye.descend(qe),
|
|
982
|
-
const Xe = k && !s(l(
|
|
983
|
-
var $e,
|
|
984
|
-
k && !Re ? Xe !==
|
|
985
|
-
}), H.end(),
|
|
986
|
-
else if (!Ne && !
|
|
987
|
-
}(D, D.clone(),
|
|
972
|
+
if (r.eachChildOf(re, te, (T, G, he) => {
|
|
973
|
+
let we, xe, qe = T, Me = T, Ye = T;
|
|
974
|
+
if (typeof T == "number") {
|
|
975
|
+
let _e = T + fe;
|
|
976
|
+
xe = me(_e), Me = _e + de;
|
|
977
|
+
let ue = T + ee;
|
|
978
|
+
we = H(ue), s(l(xe)) && (we = null), qe = ue + J, Ye = T + ae, o(qe >= 0, "p1PickKey is negative"), o(Me >= 0, "p2DropKey is negative");
|
|
979
|
+
const Ue = s(l(G)), Be = _(l(he));
|
|
980
|
+
(Ue || Be && !Re) && ae--, Ue && ee--, Be && fe--;
|
|
981
|
+
} else we = H(T), xe = me(T);
|
|
982
|
+
ye.descend(qe), Oe.descend(Me);
|
|
983
|
+
const Xe = k && !s(l(G)) ? A[Ye] : void 0, je = g(we, G, he, xe, Xe, Re, Oe, ye);
|
|
984
|
+
var $e, j, ie;
|
|
985
|
+
k && !Re ? Xe !== je && (X || (A = Array.isArray(A) ? A.slice() : Object.assign({}, A), X = !0), $e = A, ie = je, typeof (j = Ye) == "number" ? (o(Array.isArray($e)), o(j < $e.length)) : (o(!Array.isArray($e)), o($e[j] !== void 0)), ie === void 0 ? typeof j == "number" ? $e.splice(j, 1) : delete $e[j] : $e[j] = ie) : o(je === void 0), Oe.ascend(), ye.ascend();
|
|
986
|
+
}), H.end(), me.end(), W != null) W.i = A;
|
|
987
|
+
else if (!Ne && !Ae && Ie == null) return A;
|
|
988
|
+
}(D, D.clone(), O, O.clone(), void 0, !1, I, B), I.reset(), I.mergeTree(B.get()), I.reset(), I.get(), R.map((g) => g.get()), $.map((g) => g.get()), D.traverse(I, (g, U) => {
|
|
988
989
|
const re = g.p;
|
|
989
990
|
if (re != null) {
|
|
990
991
|
const te = w[re];
|
|
991
|
-
te != null &&
|
|
992
|
+
te != null && U.write("p", te);
|
|
992
993
|
const K = R[re];
|
|
993
|
-
K && K.get(), K &&
|
|
994
|
-
} else g.r !== void 0 &&
|
|
995
|
-
}), I.reset(), I.get(),
|
|
994
|
+
K && K.get(), K && U.mergeTree(K.get());
|
|
995
|
+
} else g.r !== void 0 && U.write("r", g.r);
|
|
996
|
+
}), I.reset(), I.get(), O.traverse(I, (g, U) => {
|
|
996
997
|
const re = g.d;
|
|
997
998
|
if (re != null) {
|
|
998
999
|
const K = C[re];
|
|
999
|
-
K != null &&
|
|
1000
|
+
K != null && U.write("d", K);
|
|
1000
1001
|
const se = $[re];
|
|
1001
|
-
se &&
|
|
1002
|
-
} else g.i !== void 0 &&
|
|
1002
|
+
se && U.mergeTree(se.get());
|
|
1003
|
+
} else g.i !== void 0 && U.write("i", g.i);
|
|
1003
1004
|
const te = ve(g);
|
|
1004
|
-
te && !N.has(g) && y(
|
|
1005
|
+
te && !N.has(g) && y(U, te, f(g));
|
|
1005
1006
|
}), I.get();
|
|
1006
1007
|
}
|
|
1007
1008
|
function le(i) {
|
|
1008
1009
|
if (i == null) return null;
|
|
1009
|
-
const d = new r.ReadCursor(i),
|
|
1010
|
+
const d = new r.ReadCursor(i), m = new r.WriteCursor();
|
|
1010
1011
|
let D;
|
|
1011
|
-
const
|
|
1012
|
+
const O = [], I = [];
|
|
1012
1013
|
return function R($, p, v) {
|
|
1013
1014
|
const w = $.getComponent();
|
|
1014
1015
|
let C, N = !1;
|
|
1015
1016
|
if (w) {
|
|
1016
|
-
w.p != null && (p.write("d", w.p),
|
|
1017
|
+
w.p != null && (p.write("d", w.p), O[w.p] = $.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d), v = void 0), w.i !== void 0 && (v = C = w.i);
|
|
1017
1018
|
const g = ve(w);
|
|
1018
1019
|
g && (v === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), v = g.apply(v, f(w)), N = !0));
|
|
1019
1020
|
}
|
|
1020
1021
|
let B = 0;
|
|
1021
1022
|
for (const g of $) {
|
|
1022
1023
|
p.descend(g);
|
|
1023
|
-
const
|
|
1024
|
+
const U = typeof g == "number" ? g - B : g, re = Y(v, U);
|
|
1024
1025
|
s($.getComponent()) && B++;
|
|
1025
1026
|
const te = R($, p, re);
|
|
1026
1027
|
if (v !== void 0 && te !== void 0) {
|
|
1027
|
-
if (N || (N = !0, v = x(v)), !
|
|
1028
|
-
v[
|
|
1028
|
+
if (N || (N = !0, v = x(v)), !S(v, U)) throw Error("Cannot modify child - invalid operation");
|
|
1029
|
+
v[U] = te;
|
|
1029
1030
|
}
|
|
1030
1031
|
p.ascend();
|
|
1031
1032
|
}
|
|
1032
1033
|
if (C === void 0) return N ? v : void 0;
|
|
1033
1034
|
p.write("r", v);
|
|
1034
|
-
}(d,
|
|
1035
|
+
}(d, m, void 0), D && (m.reset(), function R($, p, v) {
|
|
1035
1036
|
const w = p.getComponent();
|
|
1036
1037
|
if (w) {
|
|
1037
1038
|
const g = w.d;
|
|
1038
|
-
if (g != null && ($ =
|
|
1039
|
-
const
|
|
1040
|
-
if (!
|
|
1041
|
-
y(v,
|
|
1039
|
+
if (g != null && ($ = O[g], v = I[g] = r.writeCursor()), D.has(w)) {
|
|
1040
|
+
const U = ve(w);
|
|
1041
|
+
if (!U.invert) throw Error(`Cannot invert subtype ${U.name}`);
|
|
1042
|
+
y(v, U, U.invert(f(w)));
|
|
1042
1043
|
}
|
|
1043
1044
|
}
|
|
1044
1045
|
let C = 0, N = 0;
|
|
1045
|
-
const B = r.advancer($, (g,
|
|
1046
|
-
_(
|
|
1046
|
+
const B = r.advancer($, (g, U) => _(U) ? C - g - 1 : g - C, (g, U) => {
|
|
1047
|
+
_(U) && C++;
|
|
1047
1048
|
});
|
|
1048
1049
|
for (const g of p) if (typeof g == "number") {
|
|
1049
|
-
const
|
|
1050
|
+
const U = g - N, re = B(U), te = U + C;
|
|
1050
1051
|
v.descend(te), R(re, p, v), s(p.getComponent()) && N++, v.ascend();
|
|
1051
1052
|
} else v.descend(g), R(B(g), p, v), v.ascend();
|
|
1052
1053
|
B.end();
|
|
1053
|
-
}(d.clone(), d,
|
|
1054
|
+
}(d.clone(), d, m), I.length && (m.reset(), d.traverse(m, (R, $) => {
|
|
1054
1055
|
const p = R.p;
|
|
1055
1056
|
if (p != null) {
|
|
1056
1057
|
const v = I[p];
|
|
1057
1058
|
v && v.get(), v && $.mergeTree(v.get());
|
|
1058
1059
|
}
|
|
1059
|
-
}))),
|
|
1060
|
+
}))), m.get();
|
|
1060
1061
|
}
|
|
1061
|
-
const ge = (i, d) => i.some((
|
|
1062
|
+
const ge = (i, d) => i.some((m) => typeof m == "object" && (Array.isArray(m) ? ge(m, d) : d(m)));
|
|
1062
1063
|
function De(i, d) {
|
|
1063
1064
|
if (i == null || !ge(i, (p) => {
|
|
1064
1065
|
var v;
|
|
1065
1066
|
return p.r !== void 0 || ((v = ve(p)) === null || v === void 0 ? void 0 : v.makeInvertible) != null;
|
|
1066
1067
|
})) return i;
|
|
1067
|
-
const
|
|
1068
|
-
let
|
|
1068
|
+
const m = new r.ReadCursor(i), D = new r.WriteCursor();
|
|
1069
|
+
let O = !1;
|
|
1069
1070
|
const I = [], R = [], $ = (p, v, w) => {
|
|
1070
1071
|
const C = p.getComponent();
|
|
1071
1072
|
let N = !1;
|
|
@@ -1073,18 +1074,18 @@ function Jt() {
|
|
|
1073
1074
|
C.d != null && v.write("d", C.d), C.i !== void 0 && v.write("i", C.i);
|
|
1074
1075
|
const g = C.p;
|
|
1075
1076
|
if (g != null && (I[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), R[g] = w, v.write("p", C.p)), C.r !== void 0 && w === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
|
|
1076
|
-
const
|
|
1077
|
-
|
|
1077
|
+
const U = ve(C);
|
|
1078
|
+
U && (U.makeInvertible ? O = !0 : y(v, U, f(C), !0));
|
|
1078
1079
|
}
|
|
1079
1080
|
let B = 0;
|
|
1080
1081
|
for (const g of p) {
|
|
1081
1082
|
v.descend(g);
|
|
1082
|
-
const
|
|
1083
|
-
re !== te && (N || (N = !0, w = x(w)), te === void 0 ? (w = c(w,
|
|
1083
|
+
const U = typeof g == "number" ? g - B : g, re = Y(w, U), te = $(p, v, re);
|
|
1084
|
+
re !== te && (N || (N = !0, w = x(w)), te === void 0 ? (w = c(w, U), typeof g == "number" && B++) : w[U] = te), v.ascend();
|
|
1084
1085
|
}
|
|
1085
1086
|
return C && (C.r !== void 0 ? (v.write("r", t.default(w)), w = void 0) : C.p != null && (w = void 0)), w;
|
|
1086
1087
|
};
|
|
1087
|
-
return $(
|
|
1088
|
+
return $(m, D, d), D.get(), O && (D.reset(), function p(v, w, C, N, B) {
|
|
1088
1089
|
const g = w.getComponent();
|
|
1089
1090
|
if (g) {
|
|
1090
1091
|
g.i !== void 0 ? (N = g.i, B = !0) : g.d != null && (N = R[g.d], v = I[g.d], B = !1, g.d);
|
|
@@ -1094,159 +1095,159 @@ function Jt() {
|
|
|
1094
1095
|
y(C, K, K.makeInvertible(se, N), !0);
|
|
1095
1096
|
}
|
|
1096
1097
|
}
|
|
1097
|
-
let
|
|
1098
|
-
const te = r.advancer(v, (K, se) => _(se) ?
|
|
1099
|
-
_(se) &&
|
|
1098
|
+
let U = 0, re = 0;
|
|
1099
|
+
const te = r.advancer(v, (K, se) => _(se) ? U - K - 1 : K - U, (K, se) => {
|
|
1100
|
+
_(se) && U++;
|
|
1100
1101
|
});
|
|
1101
1102
|
for (const K of w) if (typeof K == "number") {
|
|
1102
|
-
const se = K - re, Ne = te(se),
|
|
1103
|
+
const se = K - re, Ne = te(se), Oe = se + U, ye = Y(N, B ? se : Oe);
|
|
1103
1104
|
C.descend(K), p(Ne, w, C, ye, B), s(w.getComponent()) && re++, C.ascend();
|
|
1104
1105
|
} else {
|
|
1105
|
-
const se =
|
|
1106
|
+
const se = Y(N, K);
|
|
1106
1107
|
C.descend(K), p(te(K), w, C, se, B), C.ascend();
|
|
1107
1108
|
}
|
|
1108
1109
|
te.end();
|
|
1109
|
-
}(
|
|
1110
|
+
}(m.clone(), m, D, d, !1)), D.get();
|
|
1110
1111
|
}
|
|
1111
|
-
function
|
|
1112
|
+
function Ut(i, d) {
|
|
1112
1113
|
return le(De(i, d));
|
|
1113
1114
|
}
|
|
1114
|
-
const
|
|
1115
|
+
const it = (i) => {
|
|
1115
1116
|
if (i == null) return null;
|
|
1116
1117
|
const d = i.slice();
|
|
1117
|
-
for (let
|
|
1118
|
-
const D = d[
|
|
1119
|
-
Array.isArray(D) && (d[
|
|
1118
|
+
for (let m = 0; m < i.length; m++) {
|
|
1119
|
+
const D = d[m];
|
|
1120
|
+
Array.isArray(D) && (d[m] = it(D));
|
|
1120
1121
|
}
|
|
1121
1122
|
return d;
|
|
1122
1123
|
};
|
|
1123
|
-
function
|
|
1124
|
-
o(
|
|
1125
|
-
const D =
|
|
1124
|
+
function st(i, d, m) {
|
|
1125
|
+
o(m === "left" || m === "right", "Direction must be left or right");
|
|
1126
|
+
const D = m === "left" ? 0 : 1;
|
|
1126
1127
|
if (d == null) return {
|
|
1127
1128
|
ok: !0,
|
|
1128
1129
|
result: i
|
|
1129
1130
|
};
|
|
1130
1131
|
z(i), z(d);
|
|
1131
|
-
let
|
|
1132
|
-
const I = [], R = [], $ = [], p = [], v = [], w = [], C = [], N = [], B = [], g = [],
|
|
1132
|
+
let O = null;
|
|
1133
|
+
const I = [], R = [], $ = [], p = [], v = [], w = [], C = [], N = [], B = [], g = [], U = [], re = [], te = [], K = [], se = [];
|
|
1133
1134
|
let Ne = 0;
|
|
1134
|
-
const
|
|
1135
|
-
if (function Q(
|
|
1135
|
+
const Oe = r.readCursor(i), ye = r.readCursor(d), oe = r.writeCursor();
|
|
1136
|
+
if (function Q(A, W = null, M) {
|
|
1136
1137
|
const P = l(W);
|
|
1137
|
-
P && (P.r !== void 0 ?
|
|
1138
|
-
const k =
|
|
1138
|
+
P && (P.r !== void 0 ? M = W.clone() : P.p != null && (M = null, w[P.p] = A.clone()));
|
|
1139
|
+
const k = A.getComponent();
|
|
1139
1140
|
let X;
|
|
1140
|
-
k && (X = k.p) != null && (v[X] = W ? W.clone() : null, $[X] =
|
|
1141
|
-
const
|
|
1142
|
-
for (const ee of
|
|
1143
|
-
|
|
1144
|
-
}(ye,
|
|
1145
|
-
const X =
|
|
1146
|
-
let
|
|
1147
|
-
X && ((
|
|
1141
|
+
k && (X = k.p) != null && (v[X] = W ? W.clone() : null, $[X] = A.clone(), M && (g[X] = !0, B[X] = M), P && P.p != null && (K[X] = P.p));
|
|
1142
|
+
const J = r.advancer(W);
|
|
1143
|
+
for (const ee of A) Q(A, J(ee), M);
|
|
1144
|
+
J.end();
|
|
1145
|
+
}(ye, Oe, null), function Q(A, W, M, P, k) {
|
|
1146
|
+
const X = M.getComponent();
|
|
1147
|
+
let J, ee = !1;
|
|
1148
|
+
X && ((J = X.d) != null ? (p[J] = M.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(J)), A = v[J] || null, W = $[J] || null, g[J] ? (k && (U[J] = !0), k = B[J] || null) : !k || D !== 1 && K[J] != null || O == null && (O = {
|
|
1148
1149
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1149
1150
|
op1: a.removeOp(k.getPath()),
|
|
1150
|
-
op2: a.moveOp(W.getPath(),
|
|
1151
|
-
}), ee = !0) : X.i !== void 0 && (
|
|
1151
|
+
op2: a.moveOp(W.getPath(), M.getPath())
|
|
1152
|
+
}), ee = !0) : X.i !== void 0 && (A = W = null, ee = !0, k && O == null && (O = {
|
|
1152
1153
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1153
1154
|
op1: a.removeOp(k.getPath()),
|
|
1154
|
-
op2: a.insertOp(
|
|
1155
|
+
op2: a.insertOp(M.getPath(), X.i)
|
|
1155
1156
|
})));
|
|
1156
|
-
const fe = l(
|
|
1157
|
-
fe && (fe.r !== void 0 ? k =
|
|
1157
|
+
const fe = l(A);
|
|
1158
|
+
fe && (fe.r !== void 0 ? k = A.clone() : fe.p != null && (fe.p, P = fe.p, k = null));
|
|
1158
1159
|
const de = ve(X);
|
|
1159
|
-
de && k &&
|
|
1160
|
+
de && k && O == null && (O = {
|
|
1160
1161
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1161
1162
|
op1: a.removeOp(k.getPath()),
|
|
1162
|
-
op2: a.editOp(
|
|
1163
|
+
op2: a.editOp(M.getPath(), de, f(X), !0)
|
|
1163
1164
|
});
|
|
1164
|
-
let ae = 0,
|
|
1165
|
-
const H = r.advancer(W, (
|
|
1165
|
+
let ae = 0, me = 0;
|
|
1166
|
+
const H = r.advancer(W, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => {
|
|
1166
1167
|
_(he) && ae++;
|
|
1167
|
-
}),
|
|
1168
|
-
for (const
|
|
1169
|
-
const he =
|
|
1170
|
-
|
|
1168
|
+
}), T = r.advancer(A);
|
|
1169
|
+
for (const G of M) if (typeof G == "number") {
|
|
1170
|
+
const he = G - me, we = H(he);
|
|
1171
|
+
me += +Q(T(he + ae), we, M, P, k);
|
|
1171
1172
|
} else {
|
|
1172
|
-
const he = H(
|
|
1173
|
-
Q(
|
|
1173
|
+
const he = H(G);
|
|
1174
|
+
Q(T(G), he, M, P, k);
|
|
1174
1175
|
}
|
|
1175
|
-
return H.end(),
|
|
1176
|
-
}(
|
|
1176
|
+
return H.end(), T.end(), ee;
|
|
1177
|
+
}(Oe, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), O) return {
|
|
1177
1178
|
ok: !1,
|
|
1178
|
-
conflict:
|
|
1179
|
+
conflict: O
|
|
1179
1180
|
};
|
|
1180
|
-
|
|
1181
|
+
U.map((Q) => !!Q);
|
|
1181
1182
|
const Pe = [];
|
|
1182
|
-
let
|
|
1183
|
-
(function Q(
|
|
1183
|
+
let Ae = null;
|
|
1184
|
+
(function Q(A, W, M, P, k) {
|
|
1184
1185
|
let X = !1;
|
|
1185
|
-
const
|
|
1186
|
-
if (_(
|
|
1187
|
-
const H =
|
|
1188
|
-
H != null ? (
|
|
1189
|
-
} else s(l(
|
|
1190
|
-
const ee =
|
|
1186
|
+
const J = l(W);
|
|
1187
|
+
if (_(J)) {
|
|
1188
|
+
const H = J.p;
|
|
1189
|
+
H != null ? (M = p[H], P = re[H] = r.writeCursor(), X = !0, k = null) : (M = null, k = W.clone());
|
|
1190
|
+
} else s(l(M)) && (M = null);
|
|
1191
|
+
const ee = A.getComponent();
|
|
1191
1192
|
if (ee) {
|
|
1192
1193
|
const H = ee.p;
|
|
1193
|
-
H != null ? (k && (N[H] = k), Pe[H] = k || D === 1 && X ? null : P.getComponent(), I[H] =
|
|
1194
|
+
H != null ? (k && (N[H] = k), Pe[H] = k || D === 1 && X ? null : P.getComponent(), I[H] = A.clone(), M && (C[H] = M.clone())) : ee.r !== void 0 && (k || P.write("r", !0), (k || X) && (Ae == null && (Ae = /* @__PURE__ */ new Set()), Ae.add(ee)));
|
|
1194
1195
|
}
|
|
1195
1196
|
let fe = 0, de = 0;
|
|
1196
|
-
const ae = r.advancer(W, void 0, (H,
|
|
1197
|
-
_(
|
|
1198
|
-
}),
|
|
1199
|
-
s(
|
|
1197
|
+
const ae = r.advancer(W, void 0, (H, T) => {
|
|
1198
|
+
_(T) && fe++;
|
|
1199
|
+
}), me = r.advancer(M, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
|
|
1200
|
+
s(T) && de++;
|
|
1200
1201
|
});
|
|
1201
|
-
if (
|
|
1202
|
-
const
|
|
1203
|
-
P.descend(H), Q(
|
|
1202
|
+
if (A) for (const H of A) if (typeof H == "string") {
|
|
1203
|
+
const T = ae(H), G = me(H);
|
|
1204
|
+
P.descend(H), Q(A, T, G, P, k), P.ascend();
|
|
1204
1205
|
} else {
|
|
1205
|
-
const
|
|
1206
|
-
o(we >= 0), P.descend(we), Q(
|
|
1206
|
+
const T = ae(H), G = H - fe, he = _(l(T)) ? null : me(G), we = G + de;
|
|
1207
|
+
o(we >= 0), P.descend(we), Q(A, T, he, P, k), P.ascend();
|
|
1207
1208
|
}
|
|
1208
|
-
ae.end(),
|
|
1209
|
-
})(
|
|
1210
|
-
let
|
|
1211
|
-
if (function Q(
|
|
1209
|
+
ae.end(), me.end();
|
|
1210
|
+
})(Oe, ye, ye.clone(), oe, null), oe.reset();
|
|
1211
|
+
let Le = [];
|
|
1212
|
+
if (function Q(A, W, M, P, k, X) {
|
|
1212
1213
|
o(W);
|
|
1213
|
-
const
|
|
1214
|
+
const J = W.getComponent();
|
|
1214
1215
|
let ee = l(P), fe = !1;
|
|
1215
|
-
const de = (
|
|
1216
|
-
if (s(
|
|
1217
|
-
const
|
|
1218
|
-
|
|
1219
|
-
const ie =
|
|
1216
|
+
const de = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
|
|
1217
|
+
if (s(J)) {
|
|
1218
|
+
const j = J.d;
|
|
1219
|
+
j != null && (R[j] = W.clone());
|
|
1220
|
+
const ie = j != null ? Pe[j] : null;
|
|
1220
1221
|
let _e = !1;
|
|
1221
|
-
if (
|
|
1222
|
+
if (J.i !== void 0 || j != null && ie) {
|
|
1222
1223
|
let ue;
|
|
1223
|
-
ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ?
|
|
1224
|
+
ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : n.default(ee.i, J.i), _e || ue != null && D !== 1 && K[ue] != null || O == null && (O = {
|
|
1224
1225
|
type: u.ConflictType.DROP_COLLISION,
|
|
1225
|
-
op1: de(
|
|
1226
|
+
op1: de(j != null ? I[j] : null, W, J),
|
|
1226
1227
|
op2: de(ue != null ? $[ue] : null, P, ee)
|
|
1227
|
-
})), _e || (X ?
|
|
1228
|
+
})), _e || (X ? O == null && (O = {
|
|
1228
1229
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1229
|
-
op1: de(
|
|
1230
|
+
op1: de(j != null ? I[j] : null, W, J),
|
|
1230
1231
|
op2: a.removeOp(X.getPath())
|
|
1231
|
-
}) : (
|
|
1232
|
-
} else if (
|
|
1233
|
-
const ue = N[
|
|
1232
|
+
}) : (j != null ? (Le[Ne] = j, k.write("d", ie.p = Ne++)) : k.write("i", t.default(J.i)), fe = !0));
|
|
1233
|
+
} else if (j != null && !ie) {
|
|
1234
|
+
const ue = N[j];
|
|
1234
1235
|
ue && (X = ue.clone());
|
|
1235
1236
|
}
|
|
1236
|
-
|
|
1237
|
-
} else _(l(
|
|
1238
|
-
const ae = l(
|
|
1239
|
-
if (_(
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
} else !s(
|
|
1237
|
+
j != null ? (A = I[j], M = w[j], P = C[j]) : J.i !== void 0 && (A = M = null, _e || (P = null));
|
|
1238
|
+
} else _(l(A)) && (A = M = P = null);
|
|
1239
|
+
const ae = l(A), me = l(M);
|
|
1240
|
+
if (_(me)) {
|
|
1241
|
+
const j = me.p;
|
|
1242
|
+
me.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, X = M.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((k = te[j]) || (k = te[j] = r.writeCursor()), k.reset(), X = null));
|
|
1243
|
+
} else !s(J) && s(ee) && (P = null);
|
|
1243
1244
|
ee = P != null ? P.getComponent() : null;
|
|
1244
|
-
const H = ve(
|
|
1245
|
+
const H = ve(J);
|
|
1245
1246
|
if (H) {
|
|
1246
|
-
const
|
|
1247
|
-
if (X)
|
|
1247
|
+
const j = f(J);
|
|
1248
|
+
if (X) O == null && (O = {
|
|
1248
1249
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1249
|
-
op1: a.editOp(W.getPath(), H,
|
|
1250
|
+
op1: a.editOp(W.getPath(), H, j, !0),
|
|
1250
1251
|
op2: a.removeOp(X.getPath())
|
|
1251
1252
|
});
|
|
1252
1253
|
else {
|
|
@@ -1255,52 +1256,52 @@ function Jt() {
|
|
|
1255
1256
|
if (ie) {
|
|
1256
1257
|
if (H !== ie) throw Error("Transforming incompatible types");
|
|
1257
1258
|
const ue = f(ee);
|
|
1258
|
-
_e = H.transform(
|
|
1259
|
-
} else _e = t.default(
|
|
1259
|
+
_e = H.transform(j, ue, m);
|
|
1260
|
+
} else _e = t.default(j);
|
|
1260
1261
|
y(k, H, _e);
|
|
1261
1262
|
}
|
|
1262
1263
|
}
|
|
1263
|
-
let
|
|
1264
|
-
const Xe = r.advancer(
|
|
1264
|
+
let T = 0, G = 0, he = 0, we = 0, xe = 0, qe = 0, Me = A != null && A.descendFirst(), Ye = Me;
|
|
1265
|
+
const Xe = r.advancer(M, void 0, (j, ie) => {
|
|
1265
1266
|
_(ie) && he++;
|
|
1266
1267
|
});
|
|
1267
|
-
let
|
|
1268
|
-
for (const
|
|
1268
|
+
let je = P != null && P.descendFirst(), $e = je;
|
|
1269
|
+
for (const j of W) if (typeof j == "number") {
|
|
1269
1270
|
let ie;
|
|
1270
|
-
const _e = s(W.getComponent()), ue =
|
|
1271
|
+
const _e = s(W.getComponent()), ue = j - G;
|
|
1271
1272
|
{
|
|
1272
1273
|
let We;
|
|
1273
|
-
for (;
|
|
1274
|
-
We +=
|
|
1275
|
-
const ke =
|
|
1276
|
-
if (We > ue || We === ue && (!
|
|
1277
|
-
if (
|
|
1278
|
-
|
|
1274
|
+
for (; Me && typeof (We = A.getKey()) == "number"; ) {
|
|
1275
|
+
We += T;
|
|
1276
|
+
const ke = A.getComponent(), Je = _(ke);
|
|
1277
|
+
if (We > ue || We === ue && (!Je || D === 0 && _e)) break;
|
|
1278
|
+
if (Je) {
|
|
1279
|
+
T--;
|
|
1279
1280
|
const Ke = ke.p;
|
|
1280
|
-
K.includes(Ke), ke.d, l(te[ke.d]), _(l(te[ke.d])), (ke.r === void 0 ||
|
|
1281
|
+
K.includes(Ke), ke.d, l(te[ke.d]), _(l(te[ke.d])), (ke.r === void 0 || Ae && Ae.has(ke)) && (Ke == null || !Pe[Ke] || D !== 1 && K.includes(Ke)) || xe--;
|
|
1281
1282
|
}
|
|
1282
|
-
|
|
1283
|
+
Me = A.nextSibling();
|
|
1283
1284
|
}
|
|
1284
|
-
ie =
|
|
1285
|
+
ie = Me && We === ue ? A : null;
|
|
1285
1286
|
}
|
|
1286
|
-
const
|
|
1287
|
-
let Be = Xe(
|
|
1288
|
-
const
|
|
1289
|
-
let
|
|
1287
|
+
const Ue = ue - T;
|
|
1288
|
+
let Be = Xe(Ue);
|
|
1289
|
+
const ot = Ue - he;
|
|
1290
|
+
let Qe = null;
|
|
1290
1291
|
{
|
|
1291
1292
|
let We, ke;
|
|
1292
|
-
for (;
|
|
1293
|
+
for (; je && typeof (We = P.getKey()) == "number"; ) {
|
|
1293
1294
|
ke = We - we;
|
|
1294
|
-
const
|
|
1295
|
-
if (ke >
|
|
1296
|
-
if (ke ===
|
|
1295
|
+
const Je = P.getComponent(), Ke = s(Je);
|
|
1296
|
+
if (ke > ot) break;
|
|
1297
|
+
if (ke === ot) {
|
|
1297
1298
|
if (!Ke) {
|
|
1298
|
-
|
|
1299
|
+
Qe = P;
|
|
1299
1300
|
break;
|
|
1300
1301
|
}
|
|
1301
1302
|
{
|
|
1302
1303
|
if (D === 0 && _e) {
|
|
1303
|
-
|
|
1304
|
+
Qe = P;
|
|
1304
1305
|
break;
|
|
1305
1306
|
}
|
|
1306
1307
|
const Fe = Be && _(Be.getComponent());
|
|
@@ -1308,102 +1309,102 @@ function Jt() {
|
|
|
1308
1309
|
}
|
|
1309
1310
|
}
|
|
1310
1311
|
if (Ke) {
|
|
1311
|
-
const Fe =
|
|
1312
|
-
K[Fe],
|
|
1312
|
+
const Fe = Je.d;
|
|
1313
|
+
K[Fe], Je.i === void 0 && (g[Fe] || K[Fe] != null && D !== 1) ? (g[Fe] || K[Fe] != null && D === 0) && (we++, qe--) : we++;
|
|
1313
1314
|
}
|
|
1314
|
-
|
|
1315
|
+
je = P.nextSibling();
|
|
1315
1316
|
}
|
|
1316
1317
|
}
|
|
1317
|
-
const yt =
|
|
1318
|
-
o(yt >= 0, "trying to descend to a negative index"), k.descend(yt), _e && (ie = Be =
|
|
1318
|
+
const yt = ot + we + xe + qe;
|
|
1319
|
+
o(yt >= 0, "trying to descend to a negative index"), k.descend(yt), _e && (ie = Be = Qe = null, G++), Q(ie, W, Be, Qe, k, X) && qe++, k.ascend();
|
|
1319
1320
|
} else {
|
|
1320
1321
|
let ie;
|
|
1321
|
-
for (;
|
|
1322
|
-
const _e =
|
|
1323
|
-
let
|
|
1324
|
-
for (;
|
|
1325
|
-
const Be =
|
|
1326
|
-
k.descend(
|
|
1322
|
+
for (; Me && (ie = A.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) Me = A.nextSibling();
|
|
1323
|
+
const _e = Me && ie === j ? A : null, ue = Xe(j);
|
|
1324
|
+
let Ue;
|
|
1325
|
+
for (; je && (Ue = P.getKey(), typeof Ue != "string" || !(Ue > j || Ue === j)); ) je = P.nextSibling();
|
|
1326
|
+
const Be = je && Ue === j ? P : null;
|
|
1327
|
+
k.descend(j), Q(_e, W, ue, Be, k, X), k.ascend();
|
|
1327
1328
|
}
|
|
1328
|
-
return Xe.end(),
|
|
1329
|
-
}(
|
|
1329
|
+
return Xe.end(), Ye && A.ascend(), $e && P.ascend(), fe;
|
|
1330
|
+
}(Oe, Oe.clone(), ye, ye.clone(), oe, null), O) return {
|
|
1330
1331
|
ok: !1,
|
|
1331
|
-
conflict:
|
|
1332
|
+
conflict: O
|
|
1332
1333
|
};
|
|
1333
1334
|
oe.reset();
|
|
1334
|
-
const
|
|
1335
|
-
|
|
1335
|
+
const Te = (Q, A, W) => Q.traverse(A, (M, P) => {
|
|
1336
|
+
M.d != null && W(M.d, Q, P);
|
|
1336
1337
|
});
|
|
1337
|
-
(g.length || re.length) && (
|
|
1338
|
-
g[Q] && !
|
|
1338
|
+
(g.length || re.length) && (Te(ye, oe, (Q, A, W) => {
|
|
1339
|
+
g[Q] && !U[Q] && W.write("r", !0), re[Q] && W.mergeTree(re[Q].get());
|
|
1339
1340
|
}), oe.reset());
|
|
1340
1341
|
const Ie = [], Re = [];
|
|
1341
|
-
if ((te.length || g.length) && !
|
|
1342
|
-
const Q = r.readCursor(
|
|
1343
|
-
if (
|
|
1344
|
-
Ie[
|
|
1345
|
-
}), te.forEach((
|
|
1346
|
-
|
|
1347
|
-
Ie[W] =
|
|
1342
|
+
if ((te.length || g.length) && !O) {
|
|
1343
|
+
const Q = r.readCursor(it(oe.get()));
|
|
1344
|
+
if (Te(Q, null, (A, W) => {
|
|
1345
|
+
Ie[A] = W.clone();
|
|
1346
|
+
}), te.forEach((A) => {
|
|
1347
|
+
A && Te(r.readCursor(A.get()), null, (W, M) => {
|
|
1348
|
+
Ie[W] = M.clone();
|
|
1348
1349
|
});
|
|
1349
|
-
}), function
|
|
1350
|
-
const ee = l(
|
|
1350
|
+
}), function A(W, M, P, k, X, J) {
|
|
1351
|
+
const ee = l(M);
|
|
1351
1352
|
if (ee && _(ee)) if (ee.p != null) {
|
|
1352
|
-
const
|
|
1353
|
-
Ie[
|
|
1353
|
+
const T = ee.p;
|
|
1354
|
+
Ie[T].getPath(), P = Ie[T], k = Re[T] = r.writeCursor();
|
|
1354
1355
|
} else ee.r !== void 0 && (P = null);
|
|
1355
1356
|
else s(l(P)) && (P = null);
|
|
1356
1357
|
const fe = W.getComponent();
|
|
1357
1358
|
if (fe) {
|
|
1358
|
-
let
|
|
1359
|
-
if ((
|
|
1360
|
-
const
|
|
1361
|
-
|
|
1359
|
+
let T;
|
|
1360
|
+
if ((T = fe.d) != null) {
|
|
1361
|
+
const G = te[T];
|
|
1362
|
+
G && (G.get(), k.mergeTree(G.get()), P = r.readCursor(G.get()));
|
|
1362
1363
|
}
|
|
1363
1364
|
}
|
|
1364
1365
|
let de = 0, ae = 0;
|
|
1365
|
-
const
|
|
1366
|
-
_(
|
|
1367
|
-
}), H = r.advancer(P, (
|
|
1368
|
-
s(
|
|
1366
|
+
const me = r.advancer(M, void 0, (T, G) => {
|
|
1367
|
+
_(G) && de--;
|
|
1368
|
+
}), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => {
|
|
1369
|
+
s(G) && ae++;
|
|
1369
1370
|
});
|
|
1370
|
-
for (const
|
|
1371
|
-
const
|
|
1372
|
-
k.descend(xe),
|
|
1373
|
-
} else k.descend(
|
|
1374
|
-
|
|
1375
|
-
}(ye, Q, Q.clone(), oe), oe.reset(),
|
|
1371
|
+
for (const T of W) if (typeof T == "number") {
|
|
1372
|
+
const G = me(T), he = T + de, we = H(he), xe = he + ae;
|
|
1373
|
+
k.descend(xe), A(W, G, we, k), k.ascend();
|
|
1374
|
+
} else k.descend(T), A(W, me(T), H(T), k), k.ascend();
|
|
1375
|
+
me.end(), H.end();
|
|
1376
|
+
}(ye, Q, Q.clone(), oe), oe.reset(), O) return {
|
|
1376
1377
|
ok: !1,
|
|
1377
|
-
conflict:
|
|
1378
|
+
conflict: O
|
|
1378
1379
|
};
|
|
1379
1380
|
if (oe.get(), Re.length) {
|
|
1380
|
-
const
|
|
1381
|
-
if (
|
|
1382
|
-
const X =
|
|
1383
|
-
X && (k.mergeTree(X),
|
|
1384
|
-
}),
|
|
1385
|
-
const
|
|
1381
|
+
const A = Re.map((M) => M ? M.get() : null), W = r.readCursor(it(oe.get()));
|
|
1382
|
+
if (Te(W, oe, (M, P, k) => {
|
|
1383
|
+
const X = A[M];
|
|
1384
|
+
X && (k.mergeTree(X), A[M] = null);
|
|
1385
|
+
}), A.find((M) => M)) {
|
|
1386
|
+
const M = r.writeCursor(), P = r.writeCursor();
|
|
1386
1387
|
let k = 0, X = 0;
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
const fe =
|
|
1390
|
-
|
|
1388
|
+
A.forEach((J) => {
|
|
1389
|
+
J != null && Te(r.readCursor(J), null, (ee) => {
|
|
1390
|
+
const fe = Le[ee];
|
|
1391
|
+
M.writeMove(I[fe].getPath(), R[fe].getPath(), k++);
|
|
1391
1392
|
const de = se[fe];
|
|
1392
1393
|
de && de.forEach((ae) => {
|
|
1393
1394
|
g[ae] || D !== 1 && K[ae] != null || P.writeMove($[ae].getPath(), p[ae].getPath(), X++);
|
|
1394
1395
|
});
|
|
1395
1396
|
});
|
|
1396
|
-
}),
|
|
1397
|
+
}), O = {
|
|
1397
1398
|
type: u.ConflictType.BLACKHOLE,
|
|
1398
|
-
op1:
|
|
1399
|
+
op1: M.get(),
|
|
1399
1400
|
op2: P.get()
|
|
1400
1401
|
};
|
|
1401
1402
|
}
|
|
1402
1403
|
}
|
|
1403
1404
|
}
|
|
1404
|
-
return
|
|
1405
|
+
return O ? {
|
|
1405
1406
|
ok: !1,
|
|
1406
|
-
conflict:
|
|
1407
|
+
conflict: O
|
|
1407
1408
|
} : {
|
|
1408
1409
|
ok: !0,
|
|
1409
1410
|
result: oe.get()
|
|
@@ -1413,49 +1414,49 @@ function Jt() {
|
|
|
1413
1414
|
const d = new Error("Transform detected write conflict");
|
|
1414
1415
|
throw d.conflict = i, d.type = d.name = "writeConflict", d;
|
|
1415
1416
|
};
|
|
1416
|
-
function
|
|
1417
|
-
const D =
|
|
1417
|
+
function kt(i, d, m) {
|
|
1418
|
+
const D = st(i, d, m);
|
|
1418
1419
|
if (D.ok) return D.result;
|
|
1419
1420
|
pt(D.conflict);
|
|
1420
1421
|
}
|
|
1421
1422
|
const ze = (i) => {
|
|
1422
1423
|
const d = r.writeCursor();
|
|
1423
|
-
return r.readCursor(i).traverse(d, (
|
|
1424
|
-
(s(
|
|
1424
|
+
return r.readCursor(i).traverse(d, (m, D) => {
|
|
1425
|
+
(s(m) || ve(m)) && D.write("r", !0);
|
|
1425
1426
|
}), d.get();
|
|
1426
1427
|
}, St = (i, d) => {
|
|
1427
|
-
const { type:
|
|
1428
|
-
switch (
|
|
1428
|
+
const { type: m, op1: D, op2: O } = i;
|
|
1429
|
+
switch (m) {
|
|
1429
1430
|
case u.ConflictType.DROP_COLLISION:
|
|
1430
|
-
return d === "left" ? [null, ze(
|
|
1431
|
+
return d === "left" ? [null, ze(O)] : [ze(D), null];
|
|
1431
1432
|
case u.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1432
1433
|
let I = !1;
|
|
1433
1434
|
return r.readCursor(D).traverse(null, (R) => {
|
|
1434
1435
|
R.r !== void 0 && (I = !0);
|
|
1435
|
-
}), I ? [null, ze(
|
|
1436
|
+
}), I ? [null, ze(O)] : [ze(D), null];
|
|
1436
1437
|
case u.ConflictType.BLACKHOLE:
|
|
1437
|
-
return [ze(D), ze(
|
|
1438
|
+
return [ze(D), ze(O)];
|
|
1438
1439
|
default:
|
|
1439
|
-
throw Error("Unrecognised conflict: " +
|
|
1440
|
+
throw Error("Unrecognised conflict: " + m);
|
|
1440
1441
|
}
|
|
1441
1442
|
};
|
|
1442
|
-
function gt(i, d,
|
|
1443
|
-
let
|
|
1443
|
+
function gt(i, d, m, D) {
|
|
1444
|
+
let O = null;
|
|
1444
1445
|
for (; ; ) {
|
|
1445
|
-
const I =
|
|
1446
|
-
if (I.ok) return ne(
|
|
1446
|
+
const I = st(d, m, D);
|
|
1447
|
+
if (I.ok) return ne(O, I.result);
|
|
1447
1448
|
{
|
|
1448
1449
|
const { conflict: R } = I;
|
|
1449
1450
|
i(R) || pt(R);
|
|
1450
1451
|
const [$, p] = St(R, D);
|
|
1451
|
-
d = ne(q(d), $),
|
|
1452
|
+
d = ne(q(d), $), m = ne(q(m), p), O = ne(O, p);
|
|
1452
1453
|
}
|
|
1453
1454
|
}
|
|
1454
1455
|
}
|
|
1455
1456
|
}(Ze)), Ze;
|
|
1456
1457
|
}
|
|
1457
1458
|
var Dt;
|
|
1458
|
-
function
|
|
1459
|
+
function Qt() {
|
|
1459
1460
|
return Dt || (Dt = 1, function(a) {
|
|
1460
1461
|
var e = Ve && Ve.__createBinding || (Object.create ? function(u, o, l, E) {
|
|
1461
1462
|
E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() {
|
|
@@ -1466,8 +1467,8 @@ function Zt() {
|
|
|
1466
1467
|
}), n = Ve && Ve.__exportStar || function(u, o) {
|
|
1467
1468
|
for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l);
|
|
1468
1469
|
};
|
|
1469
|
-
Object.defineProperty(a, "__esModule", { value: !0 }), n(
|
|
1470
|
-
var t =
|
|
1470
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), n(Zt(), a);
|
|
1471
|
+
var t = At();
|
|
1471
1472
|
Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() {
|
|
1472
1473
|
return t.ReadCursor;
|
|
1473
1474
|
} }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() {
|
|
@@ -1479,8 +1480,8 @@ function Zt() {
|
|
|
1479
1480
|
} });
|
|
1480
1481
|
}(Ve)), Ve;
|
|
1481
1482
|
}
|
|
1482
|
-
var V =
|
|
1483
|
-
class
|
|
1483
|
+
var V = Qt();
|
|
1484
|
+
class en {
|
|
1484
1485
|
constructor() {
|
|
1485
1486
|
F(this, "drawingManagerData", {});
|
|
1486
1487
|
F(this, "_oldDrawingManagerData", {});
|
|
@@ -1779,8 +1780,8 @@ class Qt {
|
|
|
1779
1780
|
getFrontDrawingsOp(e) {
|
|
1780
1781
|
const { unitId: n, subUnitId: t, drawingIds: r } = e, u = this._getOrderFromSearchParams(n, t, r), o = [...r], l = this.getDrawingOrder(n, t), E = [];
|
|
1781
1782
|
u.forEach((s) => {
|
|
1782
|
-
const { drawingId: c } = s, h = this._getDrawingCount(n, t) - 1,
|
|
1783
|
-
E.push(
|
|
1783
|
+
const { drawingId: c } = s, h = this._getDrawingCount(n, t) - 1, S = V.moveOp([n, t, "order", this._getDrawingOrder(n, t).indexOf(c)], [n, t, "order", h]);
|
|
1784
|
+
E.push(S), o.includes(l[h]) || o.push(l[h]);
|
|
1784
1785
|
});
|
|
1785
1786
|
const x = E.reduce(V.type.compose, null);
|
|
1786
1787
|
return { undo: V.type.invertWithDoc(x, this.drawingManagerData), redo: x, unitId: n, subUnitId: t, objects: { ...e, drawingIds: o } };
|
|
@@ -1801,7 +1802,7 @@ class Qt {
|
|
|
1801
1802
|
return t.map((u) => {
|
|
1802
1803
|
const o = this._hasDrawingOrder({ unitId: e, subUnitId: n, drawingId: u });
|
|
1803
1804
|
return { drawingId: u, zIndex: o };
|
|
1804
|
-
}).sort(r === !1 ?
|
|
1805
|
+
}).sort(r === !1 ? Nt : Rt);
|
|
1805
1806
|
}
|
|
1806
1807
|
_hasDrawingOrder(e) {
|
|
1807
1808
|
if (e == null)
|
|
@@ -1889,7 +1890,7 @@ class Qt {
|
|
|
1889
1890
|
this._editable = e;
|
|
1890
1891
|
}
|
|
1891
1892
|
}
|
|
1892
|
-
class
|
|
1893
|
+
class tn extends en {
|
|
1893
1894
|
}
|
|
1894
1895
|
function _n({ unitId: a, subUnitId: e, drawingId: n }, t) {
|
|
1895
1896
|
return typeof t == "number" ? `${a}#-#${e}#-#${n}#-#${t}` : `${a}#-#${e}#-#${n}`;
|
|
@@ -1905,9 +1906,7 @@ const vn = async (a) => new Promise((e, n) => {
|
|
|
1905
1906
|
}, t.onerror = (r) => {
|
|
1906
1907
|
n(r);
|
|
1907
1908
|
};
|
|
1908
|
-
}),
|
|
1909
|
-
var it = /* @__PURE__ */ ((a) => (a.URL = "URL", a.UUID = "UUID", a.BASE64 = "BASE64", a))(it || {}), Qe = /* @__PURE__ */ ((a) => (a.SUCCUSS = "0", a.ERROR_EXCEED_SIZE = "1", a.ERROR_IMAGE_TYPE = "2", a.ERROR_UPLOAD_COUNT_LIMIT = "3", a.ERROR_IMAGE = "4", a))(Qe || {});
|
|
1910
|
-
const sn = Tt("core.image-io.service");
|
|
1909
|
+
}), nn = "drawing.config", rn = {}, sn = xt("univer.drawing-manager.service");
|
|
1911
1910
|
class on {
|
|
1912
1911
|
constructor() {
|
|
1913
1912
|
F(this, "_waitCount", 0);
|
|
@@ -1919,26 +1918,26 @@ class on {
|
|
|
1919
1918
|
this._waitCount = e, this._change$.next(e);
|
|
1920
1919
|
}
|
|
1921
1920
|
getImageSourceCache(e, n) {
|
|
1922
|
-
if (n ===
|
|
1921
|
+
if (n === at.BASE64) {
|
|
1923
1922
|
const t = new Image();
|
|
1924
1923
|
return t.src = e, t;
|
|
1925
1924
|
}
|
|
1926
1925
|
return this._imageSourceCache.get(e);
|
|
1927
1926
|
}
|
|
1928
1927
|
addImageSourceCache(e, n, t) {
|
|
1929
|
-
n ===
|
|
1928
|
+
n === at.BASE64 || t == null || this._imageSourceCache.set(e, t);
|
|
1930
1929
|
}
|
|
1931
1930
|
async getImage(e) {
|
|
1932
1931
|
return Promise.resolve(e);
|
|
1933
1932
|
}
|
|
1934
1933
|
async saveImage(e) {
|
|
1935
1934
|
return new Promise((n, t) => {
|
|
1936
|
-
if (!
|
|
1937
|
-
t(new Error(
|
|
1935
|
+
if (!Ht.includes(e.type)) {
|
|
1936
|
+
t(new Error(et.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
|
|
1938
1937
|
return;
|
|
1939
1938
|
}
|
|
1940
|
-
if (e.size >
|
|
1941
|
-
t(new Error(
|
|
1939
|
+
if (e.size > Vt) {
|
|
1940
|
+
t(new Error(et.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
|
|
1942
1941
|
return;
|
|
1943
1942
|
}
|
|
1944
1943
|
const r = new FileReader();
|
|
@@ -1946,16 +1945,16 @@ class on {
|
|
|
1946
1945
|
var E;
|
|
1947
1946
|
const o = (E = u.target) == null ? void 0 : E.result;
|
|
1948
1947
|
if (o == null) {
|
|
1949
|
-
t(new Error(
|
|
1948
|
+
t(new Error(et.ERROR_IMAGE)), this._decreaseWaiting();
|
|
1950
1949
|
return;
|
|
1951
1950
|
}
|
|
1952
1951
|
const l = Bt.generateRandomId(6);
|
|
1953
1952
|
n({
|
|
1954
1953
|
imageId: l,
|
|
1955
|
-
imageSourceType:
|
|
1954
|
+
imageSourceType: at.BASE64,
|
|
1956
1955
|
source: o,
|
|
1957
1956
|
base64Cache: o,
|
|
1958
|
-
status:
|
|
1957
|
+
status: et.SUCCUSS
|
|
1959
1958
|
}), this._decreaseWaiting();
|
|
1960
1959
|
};
|
|
1961
1960
|
});
|
|
@@ -1971,11 +1970,11 @@ var an = Object.defineProperty, ln = Object.getOwnPropertyDescriptor, un = (a, e
|
|
|
1971
1970
|
}, Pt = (a, e) => (n, t) => e(n, t, a);
|
|
1972
1971
|
const cn = "UNIVER_DRAWING_PLUGIN";
|
|
1973
1972
|
var dt;
|
|
1974
|
-
let
|
|
1975
|
-
constructor(a =
|
|
1973
|
+
let Tt = (dt = class extends Lt {
|
|
1974
|
+
constructor(a = rn, e, n) {
|
|
1976
1975
|
super(), this._config = a, this._injector = e, this._configService = n;
|
|
1977
1976
|
const { ...t } = this._config;
|
|
1978
|
-
this._configService.setConfig(
|
|
1977
|
+
this._configService.setConfig(nn, t);
|
|
1979
1978
|
}
|
|
1980
1979
|
onStarting() {
|
|
1981
1980
|
this._initDependencies();
|
|
@@ -1983,29 +1982,29 @@ let At = (dt = class extends Gt {
|
|
|
1983
1982
|
_initDependencies() {
|
|
1984
1983
|
var n;
|
|
1985
1984
|
qt([
|
|
1986
|
-
[
|
|
1987
|
-
[
|
|
1985
|
+
[Ft, { useClass: on }],
|
|
1986
|
+
[sn, { useClass: tn }]
|
|
1988
1987
|
], (n = this._config) == null ? void 0 : n.override).forEach((t) => this._injector.add(t));
|
|
1989
1988
|
}
|
|
1990
1989
|
}, F(dt, "pluginName", cn), dt);
|
|
1991
|
-
|
|
1992
|
-
Pt(1, Wt(
|
|
1990
|
+
Tt = un([
|
|
1991
|
+
Pt(1, Wt(Gt)),
|
|
1993
1992
|
Pt(2, Kt)
|
|
1994
|
-
],
|
|
1993
|
+
], Tt);
|
|
1995
1994
|
export {
|
|
1996
|
-
|
|
1997
|
-
|
|
1995
|
+
Ht as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
1996
|
+
Vt as DRAWING_IMAGE_ALLOW_SIZE,
|
|
1998
1997
|
yn as DRAWING_IMAGE_COUNT_LIMIT,
|
|
1999
1998
|
gn as DRAWING_IMAGE_HEIGHT_LIMIT,
|
|
2000
1999
|
pn as DRAWING_IMAGE_WIDTH_LIMIT,
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2000
|
+
tn as DrawingManagerService,
|
|
2001
|
+
sn as IDrawingManagerService,
|
|
2002
|
+
wn as IImageIoService,
|
|
2004
2003
|
on as ImageIoService,
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2004
|
+
bn as ImageSourceType,
|
|
2005
|
+
Cn as ImageUploadStatusType,
|
|
2006
|
+
en as UnitDrawingService,
|
|
2007
|
+
Tt as UniverDrawingPlugin,
|
|
2009
2008
|
_n as getDrawingShapeKeyByDrawingSearch,
|
|
2010
2009
|
vn as getImageSize
|
|
2011
2010
|
};
|