@univerjs/drawing 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +731 -699
- package/lib/index.js +731 -699
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/url-image.service.d.ts +7 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
package/lib/es/index.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
1
|
var Rt = Object.defineProperty;
|
|
2
|
-
var xt = (a, e,
|
|
3
|
-
var F = (a, e,
|
|
4
|
-
import { createIdentifier as Bt, CommandType as Wt, sortRules as
|
|
5
|
-
import { IImageIoService as
|
|
2
|
+
var xt = (a, e, t) => e in a ? Rt(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var F = (a, e, t) => xt(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { createIdentifier as Bt, CommandType as Wt, sortRules as Lt, sortRulesByDesc as Gt, ImageSourceType as at, ImageUploadStatusType as et, generateRandomId as qt, Disposable as $t, toDisposable as Kt, Inject as Ft, Injector as Vt, IConfigService as Ht, ICommandService as zt, Plugin as Xt, merge as Jt, mergeOverrideWithDependencies as Yt, IImageIoService as Zt, IURLImageService as Qt } from "@univerjs/core";
|
|
5
|
+
import { IImageIoService as Tn, ImageSourceType as Sn, ImageUploadStatusType as kn } from "@univerjs/core";
|
|
6
6
|
import { Subject as be } from "rxjs";
|
|
7
|
-
const
|
|
7
|
+
const wn = 500, bn = 500, In = 10, en = 5 * 1024 * 1024, tn = ["image/png", "image/jpeg", "image/jpg", "image/gif", "image/bmp"], kt = Bt("univer.drawing-manager.service"), nn = {
|
|
8
8
|
id: "drawing.operation.set-drawing-selected",
|
|
9
9
|
type: Wt.OPERATION,
|
|
10
10
|
handler: (a, e) => {
|
|
11
|
-
const
|
|
12
|
-
return e == null ? !1 : (
|
|
13
|
-
}
|
|
14
|
-
},
|
|
15
|
-
var Ve = {}, Ze = {}, tt = {},
|
|
16
|
-
function
|
|
17
|
-
if (
|
|
18
|
-
|
|
19
|
-
function a(
|
|
11
|
+
const t = a.get(kt);
|
|
12
|
+
return e == null ? !1 : (t.focusDrawing(e), !0);
|
|
13
|
+
}
|
|
14
|
+
}, rn = "drawing.config", mt = {};
|
|
15
|
+
var Ve = {}, Ze = {}, tt = {}, vt;
|
|
16
|
+
function sn() {
|
|
17
|
+
if (vt) return tt;
|
|
18
|
+
vt = 1, Object.defineProperty(tt, "__esModule", { value: !0 });
|
|
19
|
+
function a(n, r) {
|
|
20
20
|
if (Array.isArray(r))
|
|
21
21
|
return !1;
|
|
22
|
-
for (let u in
|
|
23
|
-
if (!n
|
|
22
|
+
for (let u in n)
|
|
23
|
+
if (!t(n[u], r[u]))
|
|
24
24
|
return !1;
|
|
25
25
|
for (let u in r)
|
|
26
|
-
if (
|
|
26
|
+
if (n[u] === void 0)
|
|
27
27
|
return !1;
|
|
28
28
|
return !0;
|
|
29
29
|
}
|
|
30
|
-
function e(
|
|
31
|
-
if (!Array.isArray(r) ||
|
|
30
|
+
function e(n, r) {
|
|
31
|
+
if (!Array.isArray(r) || n.length !== r.length)
|
|
32
32
|
return !1;
|
|
33
|
-
for (let u = 0; u <
|
|
34
|
-
if (!n
|
|
33
|
+
for (let u = 0; u < n.length; u++)
|
|
34
|
+
if (!t(n[u], r[u]))
|
|
35
35
|
return !1;
|
|
36
36
|
return !0;
|
|
37
37
|
}
|
|
38
|
-
function n
|
|
39
|
-
return
|
|
38
|
+
function t(n, r) {
|
|
39
|
+
return n === r ? !0 : n === null || r === null || typeof n != "object" || typeof r != "object" ? !1 : Array.isArray(n) ? e(n, r) : a(n, r);
|
|
40
40
|
}
|
|
41
|
-
return tt.default =
|
|
41
|
+
return tt.default = t, tt;
|
|
42
42
|
}
|
|
43
43
|
var nt = {}, Ot;
|
|
44
|
-
function
|
|
44
|
+
function on() {
|
|
45
45
|
if (Ot) return nt;
|
|
46
46
|
Ot = 1, Object.defineProperty(nt, "__esModule", { value: !0 });
|
|
47
47
|
function a(e) {
|
|
@@ -50,24 +50,24 @@ function nn() {
|
|
|
50
50
|
if (Array.isArray(e))
|
|
51
51
|
return e.map(a);
|
|
52
52
|
if (typeof e == "object") {
|
|
53
|
-
const
|
|
54
|
-
for (let
|
|
55
|
-
n
|
|
56
|
-
return
|
|
53
|
+
const t = {};
|
|
54
|
+
for (let n in e)
|
|
55
|
+
t[n] = a(e[n]);
|
|
56
|
+
return t;
|
|
57
57
|
} else
|
|
58
58
|
return e;
|
|
59
59
|
}
|
|
60
60
|
return nt.default = a, nt;
|
|
61
61
|
}
|
|
62
62
|
var lt = {}, wt;
|
|
63
|
-
function
|
|
63
|
+
function Ut() {
|
|
64
64
|
return wt || (wt = 1, (function(a) {
|
|
65
65
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.eachChildOf = a.advancer = a.readCursor = a.writeCursor = a.WriteCursor = a.ReadCursor = a.isValidPathItem = void 0;
|
|
66
66
|
function e(_, s) {
|
|
67
67
|
if (!_)
|
|
68
68
|
throw new Error(s);
|
|
69
69
|
}
|
|
70
|
-
const
|
|
70
|
+
const t = (_) => _ != null && typeof _ == "object" && !Array.isArray(_), n = (_, s) => (
|
|
71
71
|
// All the numbers, then all the letters. Just as the gods of ascii intended.
|
|
72
72
|
typeof _ == typeof s ? _ > s : typeof _ == "string" && typeof s == "number"
|
|
73
73
|
);
|
|
@@ -83,13 +83,13 @@ function St() {
|
|
|
83
83
|
this.parents = [], this.indexes = [], this.lcIdx = -1, this.idx = -1, this.container = s;
|
|
84
84
|
}
|
|
85
85
|
ascend() {
|
|
86
|
-
e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--,
|
|
86
|
+
e(this.parents.length === this.indexes.length / 2), this.idx === 0 ? this.parents.length ? (this.lcIdx = this.indexes.pop(), this.container = this.parents.pop(), this.idx = this.indexes.pop()) : (this.lcIdx = 0, this.idx = -1) : (e(this.idx > 0), this.idx--, t(this.container[this.idx]) && this.idx--);
|
|
87
87
|
}
|
|
88
88
|
getPath() {
|
|
89
89
|
const s = [];
|
|
90
|
-
let c = this.container, h = this.parents.length - 1,
|
|
91
|
-
for (;
|
|
92
|
-
s.unshift(c[
|
|
90
|
+
let c = this.container, h = this.parents.length - 1, M = this.idx;
|
|
91
|
+
for (; M >= 0; )
|
|
92
|
+
s.unshift(c[M]), M === 0 ? (M = this.indexes[h * 2], c = this.parents[h--]) : M -= t(c[M - 1]) ? 2 : 1;
|
|
93
93
|
return s;
|
|
94
94
|
}
|
|
95
95
|
}
|
|
@@ -103,13 +103,13 @@ function St() {
|
|
|
103
103
|
}
|
|
104
104
|
getComponent() {
|
|
105
105
|
let s;
|
|
106
|
-
return this.container && this.container.length > this.idx + 1 &&
|
|
106
|
+
return this.container && this.container.length > this.idx + 1 && t(s = this.container[this.idx + 1]) ? s : null;
|
|
107
107
|
}
|
|
108
108
|
descendFirst() {
|
|
109
109
|
let s = this.idx + 1;
|
|
110
|
-
if (!this.container || s >= this.container.length ||
|
|
110
|
+
if (!this.container || s >= this.container.length || t(this.container[s]) && s + 1 >= this.container.length)
|
|
111
111
|
return !1;
|
|
112
|
-
|
|
112
|
+
t(this.container[s]) && s++;
|
|
113
113
|
const c = this.container[s];
|
|
114
114
|
return Array.isArray(c) ? (this.indexes.push(this.idx), this.parents.push(this.container), this.indexes.push(s), this.idx = 0, this.container = c) : this.idx = s, !0;
|
|
115
115
|
}
|
|
@@ -119,8 +119,8 @@ function St() {
|
|
|
119
119
|
const s = this.indexes[this.indexes.length - 1] + 1, c = this.parents[this.parents.length - 1];
|
|
120
120
|
return s >= c.length ? !1 : (e(!isNaN(s)), this.indexes[this.indexes.length - 1] = s, this.container = c[s], !0);
|
|
121
121
|
}
|
|
122
|
-
_init(s, c, h,
|
|
123
|
-
this.container = s, this.idx = c, this.parents = h.slice(), this.indexes =
|
|
122
|
+
_init(s, c, h, M) {
|
|
123
|
+
this.container = s, this.idx = c, this.parents = h.slice(), this.indexes = M.slice();
|
|
124
124
|
}
|
|
125
125
|
clone() {
|
|
126
126
|
const s = new o();
|
|
@@ -140,17 +140,17 @@ function St() {
|
|
|
140
140
|
traverse(s, c) {
|
|
141
141
|
const h = this.getComponent();
|
|
142
142
|
h && c(h, s);
|
|
143
|
-
for (const
|
|
144
|
-
s && s.descend(
|
|
143
|
+
for (const M of this)
|
|
144
|
+
s && s.descend(M), this.traverse(s, c), s && s.ascend();
|
|
145
145
|
}
|
|
146
146
|
eachPick(s, c) {
|
|
147
|
-
this.traverse(s, (h,
|
|
148
|
-
h.p != null && c(h.p,
|
|
147
|
+
this.traverse(s, (h, M) => {
|
|
148
|
+
h.p != null && c(h.p, M);
|
|
149
149
|
});
|
|
150
150
|
}
|
|
151
151
|
eachDrop(s, c) {
|
|
152
|
-
this.traverse(s, (h,
|
|
153
|
-
h.d != null && c(h.d,
|
|
152
|
+
this.traverse(s, (h, M) => {
|
|
153
|
+
h.d != null && c(h.d, M);
|
|
154
154
|
});
|
|
155
155
|
}
|
|
156
156
|
}
|
|
@@ -164,22 +164,22 @@ function St() {
|
|
|
164
164
|
for (let s = 0; s < this.pendingDescent.length; s++) {
|
|
165
165
|
const c = this.pendingDescent[s];
|
|
166
166
|
let h = this.idx + 1;
|
|
167
|
-
if (h < this.container.length &&
|
|
167
|
+
if (h < this.container.length && t(this.container[h]) && h++, e(h === this.container.length || !t(this.container[h])), h === this.container.length)
|
|
168
168
|
this.container.push(c), this.idx = h;
|
|
169
169
|
else if (this.container[h] === c)
|
|
170
170
|
this.idx = h;
|
|
171
171
|
else {
|
|
172
172
|
if (!Array.isArray(this.container[h])) {
|
|
173
|
-
const
|
|
174
|
-
this.container.push(
|
|
173
|
+
const M = this.container.splice(h, this.container.length - h);
|
|
174
|
+
this.container.push(M), this.lcIdx > -1 && (this.lcIdx = h);
|
|
175
175
|
}
|
|
176
|
-
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(
|
|
176
|
+
for (this.indexes.push(this.idx), this.parents.push(this.container), this.lcIdx !== -1 && (e(n(c, this.container[this.lcIdx][0])), h = this.lcIdx + 1, this.lcIdx = -1); h < this.container.length && n(c, this.container[h][0]); )
|
|
177
177
|
h++;
|
|
178
178
|
if (this.indexes.push(h), this.idx = 0, h < this.container.length && this.container[h][0] === c)
|
|
179
179
|
this.container = this.container[h];
|
|
180
180
|
else {
|
|
181
|
-
const
|
|
182
|
-
this.container.splice(h, 0,
|
|
181
|
+
const M = [c];
|
|
182
|
+
this.container.splice(h, 0, M), this.container = M;
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
}
|
|
@@ -194,7 +194,7 @@ function St() {
|
|
|
194
194
|
getComponent() {
|
|
195
195
|
this.flushDescent();
|
|
196
196
|
const s = this.idx + 1;
|
|
197
|
-
if (s < this.container.length &&
|
|
197
|
+
if (s < this.container.length && t(this.container[s]))
|
|
198
198
|
return this.container[s];
|
|
199
199
|
{
|
|
200
200
|
const c = {};
|
|
@@ -224,7 +224,7 @@ function St() {
|
|
|
224
224
|
return;
|
|
225
225
|
if (e(Array.isArray(s)), s === this._op)
|
|
226
226
|
throw Error("Cannot merge into my own tree");
|
|
227
|
-
const h = this.lcIdx,
|
|
227
|
+
const h = this.lcIdx, M = this.parents.length;
|
|
228
228
|
let Y = 0;
|
|
229
229
|
for (let pe = 0; pe < s.length; pe++) {
|
|
230
230
|
const Z = s[pe];
|
|
@@ -232,7 +232,7 @@ function St() {
|
|
|
232
232
|
}
|
|
233
233
|
for (; Y--; )
|
|
234
234
|
this.ascend();
|
|
235
|
-
this.lcIdx = this.parents.length ===
|
|
235
|
+
this.lcIdx = this.parents.length === M ? h : -1;
|
|
236
236
|
}
|
|
237
237
|
at(s, c) {
|
|
238
238
|
this.descendPath(s), c(this);
|
|
@@ -255,20 +255,20 @@ function St() {
|
|
|
255
255
|
}
|
|
256
256
|
a.WriteCursor = l, a.writeCursor = () => new l(), a.readCursor = (_) => new o(_);
|
|
257
257
|
function E(_, s, c) {
|
|
258
|
-
let h,
|
|
259
|
-
|
|
258
|
+
let h, M;
|
|
259
|
+
M = h = _ ? _.descendFirst() : !1;
|
|
260
260
|
function Y(pe) {
|
|
261
261
|
let Z;
|
|
262
|
-
for (;
|
|
263
|
-
const
|
|
262
|
+
for (; M; ) {
|
|
263
|
+
const Ie = Z = _.getKey();
|
|
264
264
|
if (pe != null) {
|
|
265
265
|
let qe = !1;
|
|
266
|
-
if (s && typeof
|
|
266
|
+
if (s && typeof Ie == "number" && (Z = s(Ie, _.getComponent()), Z < 0 && (Z = ~Z, qe = !0)), n(Z, pe))
|
|
267
267
|
return null;
|
|
268
268
|
if (Z === pe && !qe)
|
|
269
269
|
return _;
|
|
270
270
|
}
|
|
271
|
-
c && typeof Z == "number" && c(Z, _.getComponent()),
|
|
271
|
+
c && typeof Z == "number" && c(Z, _.getComponent()), M = _.nextSibling();
|
|
272
272
|
}
|
|
273
273
|
return null;
|
|
274
274
|
}
|
|
@@ -278,49 +278,49 @@ function St() {
|
|
|
278
278
|
}
|
|
279
279
|
a.advancer = E;
|
|
280
280
|
function B(_, s, c) {
|
|
281
|
-
let h,
|
|
282
|
-
for (h =
|
|
283
|
-
let Z = h ? _.getKey() : null,
|
|
284
|
-
Z !== null &&
|
|
281
|
+
let h, M, Y, pe;
|
|
282
|
+
for (h = M = _ && _.descendFirst(), Y = pe = s && s.descendFirst(); h || Y; ) {
|
|
283
|
+
let Z = h ? _.getKey() : null, Ie = Y ? s.getKey() : null;
|
|
284
|
+
Z !== null && Ie !== null && (n(Ie, Z) ? Ie = null : Z !== Ie && (Z = null)), c(Z == null ? Ie : Z, Z != null ? _ : null, Ie != null ? s : null), Z != null && h && (h = _.nextSibling()), Ie != null && Y && (Y = s.nextSibling());
|
|
285
285
|
}
|
|
286
|
-
|
|
286
|
+
M && _.ascend(), pe && s.ascend();
|
|
287
287
|
}
|
|
288
288
|
a.eachChildOf = B;
|
|
289
289
|
})(lt)), lt;
|
|
290
290
|
}
|
|
291
291
|
var ut = {}, bt;
|
|
292
|
-
function
|
|
292
|
+
function At() {
|
|
293
293
|
return bt || (bt = 1, (function(a) {
|
|
294
294
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.ConflictType = void 0, (function(e) {
|
|
295
295
|
e[e.RM_UNEXPECTED_CONTENT = 1] = "RM_UNEXPECTED_CONTENT", e[e.DROP_COLLISION = 2] = "DROP_COLLISION", e[e.BLACKHOLE = 3] = "BLACKHOLE";
|
|
296
296
|
})(a.ConflictType || (a.ConflictType = {}));
|
|
297
297
|
})(ut)), ut;
|
|
298
298
|
}
|
|
299
|
-
var
|
|
299
|
+
var Me = {}, He = {}, It;
|
|
300
300
|
function pt() {
|
|
301
|
-
return
|
|
302
|
-
let
|
|
303
|
-
for (;
|
|
304
|
-
const r = a.charCodeAt(
|
|
305
|
-
r >= 55296 && r <= 57343 && (
|
|
301
|
+
return It || (It = 1, Object.defineProperty(He, "__esModule", { value: !0 }), He.uniToStrPos = He.strPosToUni = void 0, He.strPosToUni = (a, e = a.length) => {
|
|
302
|
+
let t = 0, n = 0;
|
|
303
|
+
for (; n < e; n++) {
|
|
304
|
+
const r = a.charCodeAt(n);
|
|
305
|
+
r >= 55296 && r <= 57343 && (t++, n++);
|
|
306
306
|
}
|
|
307
|
-
if (
|
|
307
|
+
if (n !== e)
|
|
308
308
|
throw Error("Invalid offset - splits unicode bytes");
|
|
309
|
-
return
|
|
309
|
+
return n - t;
|
|
310
310
|
}, He.uniToStrPos = (a, e) => {
|
|
311
|
-
let
|
|
311
|
+
let t = 0;
|
|
312
312
|
for (; e > 0; e--) {
|
|
313
|
-
const
|
|
314
|
-
|
|
313
|
+
const n = a.charCodeAt(t);
|
|
314
|
+
t += n >= 55296 && n <= 57343 ? 2 : 1;
|
|
315
315
|
}
|
|
316
|
-
return
|
|
316
|
+
return t;
|
|
317
317
|
}), He;
|
|
318
318
|
}
|
|
319
|
-
var ct = {},
|
|
319
|
+
var ct = {}, Ct;
|
|
320
320
|
function ht() {
|
|
321
|
-
return
|
|
321
|
+
return Ct || (Ct = 1, (function(a) {
|
|
322
322
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.uniSlice = a.dlen = a.eachOp = void 0;
|
|
323
|
-
const e = pt(),
|
|
323
|
+
const e = pt(), t = (f) => {
|
|
324
324
|
if (!Array.isArray(f))
|
|
325
325
|
throw Error("Op must be an array of components");
|
|
326
326
|
let y = null;
|
|
@@ -349,28 +349,28 @@ function ht() {
|
|
|
349
349
|
if (typeof y == "number")
|
|
350
350
|
throw Error("Op has a trailing skip");
|
|
351
351
|
};
|
|
352
|
-
function
|
|
352
|
+
function n(f, y) {
|
|
353
353
|
let b = 0, q = 0;
|
|
354
354
|
for (let z = 0; z < f.length; z++) {
|
|
355
|
-
const
|
|
356
|
-
switch (y(
|
|
355
|
+
const $ = f[z];
|
|
356
|
+
switch (y($, b, q), typeof $) {
|
|
357
357
|
case "object":
|
|
358
|
-
b += a.dlen(
|
|
358
|
+
b += a.dlen($.d);
|
|
359
359
|
break;
|
|
360
360
|
case "string":
|
|
361
|
-
q += e.strPosToUni(
|
|
361
|
+
q += e.strPosToUni($);
|
|
362
362
|
break;
|
|
363
363
|
case "number":
|
|
364
|
-
b +=
|
|
364
|
+
b += $, q += $;
|
|
365
365
|
break;
|
|
366
366
|
}
|
|
367
367
|
}
|
|
368
368
|
}
|
|
369
|
-
a.eachOp =
|
|
369
|
+
a.eachOp = n;
|
|
370
370
|
function r(f, y) {
|
|
371
371
|
const b = [], q = l(b);
|
|
372
|
-
return
|
|
373
|
-
q(y(z,
|
|
372
|
+
return n(f, (z, $, Ee) => {
|
|
373
|
+
q(y(z, $, Ee));
|
|
374
374
|
}), s(b);
|
|
375
375
|
}
|
|
376
376
|
const u = (f) => f, o = (f) => r(f, u);
|
|
@@ -393,26 +393,26 @@ function ht() {
|
|
|
393
393
|
};
|
|
394
394
|
const B = (f, y, b) => typeof f == "number" ? b == null ? f - y : Math.min(f, b) - y : a.uniSlice(f, y, b), _ = (f) => {
|
|
395
395
|
let y = 0, b = 0;
|
|
396
|
-
return { take: (
|
|
396
|
+
return { take: ($, Ee) => {
|
|
397
397
|
if (y === f.length)
|
|
398
|
-
return
|
|
398
|
+
return $ === -1 ? null : $;
|
|
399
399
|
const ce = f[y];
|
|
400
400
|
let ne;
|
|
401
401
|
if (typeof ce == "number")
|
|
402
|
-
return
|
|
402
|
+
return $ === -1 || ce - b <= $ ? (ne = ce - b, ++y, b = 0, ne) : (b += $, $);
|
|
403
403
|
if (typeof ce == "string") {
|
|
404
|
-
if (
|
|
404
|
+
if ($ === -1 || Ee === "i" || e.strPosToUni(ce.slice(b)) <= $)
|
|
405
405
|
return ne = ce.slice(b), ++y, b = 0, ne;
|
|
406
406
|
{
|
|
407
|
-
const le = b + e.uniToStrPos(ce.slice(b),
|
|
407
|
+
const le = b + e.uniToStrPos(ce.slice(b), $);
|
|
408
408
|
return ne = ce.slice(b, le), b = le, ne;
|
|
409
409
|
}
|
|
410
410
|
} else {
|
|
411
|
-
if (
|
|
411
|
+
if ($ === -1 || Ee === "d" || a.dlen(ce.d) - b <= $)
|
|
412
412
|
return ne = { d: B(ce.d, b) }, ++y, b = 0, ne;
|
|
413
413
|
{
|
|
414
|
-
let le = B(ce.d, b, b +
|
|
415
|
-
return b +=
|
|
414
|
+
let le = B(ce.d, b, b + $);
|
|
415
|
+
return b += $, { d: le };
|
|
416
416
|
}
|
|
417
417
|
}
|
|
418
418
|
}, peek: () => f[y] };
|
|
@@ -420,22 +420,22 @@ function ht() {
|
|
|
420
420
|
function c(f, y, b) {
|
|
421
421
|
if (b !== "left" && b !== "right")
|
|
422
422
|
throw Error("side (" + b + ") must be 'left' or 'right'");
|
|
423
|
-
|
|
424
|
-
const q = [], z = l(q), { take:
|
|
423
|
+
t(f), t(y);
|
|
424
|
+
const q = [], z = l(q), { take: $, peek: Ee } = _(f);
|
|
425
425
|
for (let ne = 0; ne < y.length; ne++) {
|
|
426
426
|
const le = y[ne];
|
|
427
427
|
let ge, De;
|
|
428
428
|
switch (typeof le) {
|
|
429
429
|
case "number":
|
|
430
430
|
for (ge = le; ge > 0; )
|
|
431
|
-
De =
|
|
431
|
+
De = $(ge, "i"), z(De), typeof De != "string" && (ge -= E(De));
|
|
432
432
|
break;
|
|
433
433
|
case "string":
|
|
434
|
-
b === "left" && typeof Ee() == "string" && z(
|
|
434
|
+
b === "left" && typeof Ee() == "string" && z($(-1)), z(e.strPosToUni(le));
|
|
435
435
|
break;
|
|
436
436
|
case "object":
|
|
437
437
|
for (ge = a.dlen(le.d); ge > 0; )
|
|
438
|
-
switch (De =
|
|
438
|
+
switch (De = $(ge, "i"), typeof De) {
|
|
439
439
|
case "number":
|
|
440
440
|
ge -= De;
|
|
441
441
|
break;
|
|
@@ -449,12 +449,12 @@ function ht() {
|
|
|
449
449
|
}
|
|
450
450
|
}
|
|
451
451
|
let ce;
|
|
452
|
-
for (; ce =
|
|
452
|
+
for (; ce = $(-1); )
|
|
453
453
|
z(ce);
|
|
454
454
|
return s(q);
|
|
455
455
|
}
|
|
456
456
|
function h(f, y) {
|
|
457
|
-
|
|
457
|
+
t(f), t(y);
|
|
458
458
|
const b = [], q = l(b), { take: z } = _(f);
|
|
459
459
|
for (let Ee = 0; Ee < y.length; Ee++) {
|
|
460
460
|
const ce = y[Ee];
|
|
@@ -484,12 +484,12 @@ function ht() {
|
|
|
484
484
|
break;
|
|
485
485
|
}
|
|
486
486
|
}
|
|
487
|
-
let
|
|
488
|
-
for (;
|
|
489
|
-
q(
|
|
487
|
+
let $;
|
|
488
|
+
for (; $ = z(-1); )
|
|
489
|
+
q($);
|
|
490
490
|
return s(b);
|
|
491
491
|
}
|
|
492
|
-
const
|
|
492
|
+
const M = (f, y) => {
|
|
493
493
|
let b = 0;
|
|
494
494
|
for (let q = 0; q < y.length && f > b; q++) {
|
|
495
495
|
const z = y[q];
|
|
@@ -499,8 +499,8 @@ function ht() {
|
|
|
499
499
|
break;
|
|
500
500
|
}
|
|
501
501
|
case "string":
|
|
502
|
-
const
|
|
503
|
-
b +=
|
|
502
|
+
const $ = e.strPosToUni(z);
|
|
503
|
+
b += $, f += $;
|
|
504
504
|
break;
|
|
505
505
|
case "object":
|
|
506
506
|
f -= Math.min(a.dlen(z.d), f - b);
|
|
@@ -508,7 +508,7 @@ function ht() {
|
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
510
|
return f;
|
|
511
|
-
}, Y = (f, y) => typeof f == "number" ?
|
|
511
|
+
}, Y = (f, y) => typeof f == "number" ? M(f, y) : f.map((b) => M(b, y));
|
|
512
512
|
function pe(f, y, b) {
|
|
513
513
|
return r(f, (q, z) => typeof q == "object" && typeof q.d == "number" ? { d: b.slice(y, z, z + q.d) } : q);
|
|
514
514
|
}
|
|
@@ -528,22 +528,22 @@ function ht() {
|
|
|
528
528
|
}
|
|
529
529
|
});
|
|
530
530
|
}
|
|
531
|
-
function
|
|
531
|
+
function Ie(f) {
|
|
532
532
|
return r(f, (y) => typeof y == "object" && typeof y.d == "string" ? { d: e.strPosToUni(y.d) } : y);
|
|
533
533
|
}
|
|
534
534
|
function qe(f) {
|
|
535
535
|
let y = !0;
|
|
536
|
-
return
|
|
536
|
+
return n(f, (b) => {
|
|
537
537
|
typeof b == "object" && typeof b.d == "number" && (y = !1);
|
|
538
538
|
}), y;
|
|
539
539
|
}
|
|
540
|
-
function
|
|
540
|
+
function me(f) {
|
|
541
541
|
return {
|
|
542
542
|
name: "text-unicode",
|
|
543
543
|
uri: "http://sharejs.org/types/text-unicode",
|
|
544
544
|
trim: s,
|
|
545
545
|
normalize: o,
|
|
546
|
-
checkOp:
|
|
546
|
+
checkOp: t,
|
|
547
547
|
/** Create a new text snapshot.
|
|
548
548
|
*
|
|
549
549
|
* @param {string} initial - initial snapshot data. Optional. Defaults to ''.
|
|
@@ -557,19 +557,19 @@ function ht() {
|
|
|
557
557
|
/** Apply an operation to a document snapshot
|
|
558
558
|
*/
|
|
559
559
|
apply(y, b) {
|
|
560
|
-
|
|
560
|
+
t(b);
|
|
561
561
|
const q = f.builder(y);
|
|
562
562
|
for (let z = 0; z < b.length; z++) {
|
|
563
|
-
const
|
|
564
|
-
switch (typeof
|
|
563
|
+
const $ = b[z];
|
|
564
|
+
switch (typeof $) {
|
|
565
565
|
case "number":
|
|
566
|
-
q.skip(
|
|
566
|
+
q.skip($);
|
|
567
567
|
break;
|
|
568
568
|
case "string":
|
|
569
|
-
q.append(
|
|
569
|
+
q.append($);
|
|
570
570
|
break;
|
|
571
571
|
case "object":
|
|
572
|
-
q.del(a.dlen(
|
|
572
|
+
q.del(a.dlen($.d));
|
|
573
573
|
break;
|
|
574
574
|
}
|
|
575
575
|
}
|
|
@@ -577,13 +577,13 @@ function ht() {
|
|
|
577
577
|
},
|
|
578
578
|
transform: c,
|
|
579
579
|
compose: h,
|
|
580
|
-
transformPosition:
|
|
580
|
+
transformPosition: M,
|
|
581
581
|
transformSelection: Y,
|
|
582
582
|
isInvertible: qe,
|
|
583
583
|
makeInvertible(y, b) {
|
|
584
584
|
return pe(y, b, f);
|
|
585
585
|
},
|
|
586
|
-
stripInvertible:
|
|
586
|
+
stripInvertible: Ie,
|
|
587
587
|
invert: Z,
|
|
588
588
|
invertWithDoc(y, b) {
|
|
589
589
|
return Z(pe(y, b, f));
|
|
@@ -591,29 +591,29 @@ function ht() {
|
|
|
591
591
|
isNoop: (y) => y.length === 0
|
|
592
592
|
};
|
|
593
593
|
}
|
|
594
|
-
a.default =
|
|
594
|
+
a.default = me;
|
|
595
595
|
})(ct)), ct;
|
|
596
596
|
}
|
|
597
597
|
var rt = {}, Et;
|
|
598
|
-
function
|
|
598
|
+
function an() {
|
|
599
599
|
if (Et) return rt;
|
|
600
600
|
Et = 1, Object.defineProperty(rt, "__esModule", { value: !0 });
|
|
601
601
|
const a = ht(), e = pt();
|
|
602
|
-
function n
|
|
602
|
+
function t(n, r) {
|
|
603
603
|
return {
|
|
604
604
|
// Returns the text content of the document
|
|
605
|
-
get:
|
|
605
|
+
get: n,
|
|
606
606
|
// Returns the number of characters in the string
|
|
607
607
|
getLength() {
|
|
608
|
-
return
|
|
608
|
+
return n().length;
|
|
609
609
|
},
|
|
610
610
|
// Insert the specified text at the given position in the document
|
|
611
611
|
insert(u, o, l) {
|
|
612
|
-
const E = e.strPosToUni(
|
|
612
|
+
const E = e.strPosToUni(n(), u);
|
|
613
613
|
return r([E, o], l);
|
|
614
614
|
},
|
|
615
615
|
remove(u, o, l) {
|
|
616
|
-
const E = e.strPosToUni(
|
|
616
|
+
const E = e.strPosToUni(n(), u);
|
|
617
617
|
return r([E, { d: o }], l);
|
|
618
618
|
},
|
|
619
619
|
// When you use this API, you should implement these two methods
|
|
@@ -636,31 +636,31 @@ function rn() {
|
|
|
636
636
|
onRemove: null
|
|
637
637
|
};
|
|
638
638
|
}
|
|
639
|
-
return rt.default =
|
|
639
|
+
return rt.default = t, t.provides = { text: !0 }, rt;
|
|
640
640
|
}
|
|
641
641
|
var Dt;
|
|
642
|
-
function
|
|
642
|
+
function ln() {
|
|
643
643
|
return Dt || (Dt = 1, (function(a) {
|
|
644
|
-
var e =
|
|
645
|
-
Y === void 0 && (Y =
|
|
646
|
-
return h[
|
|
644
|
+
var e = Me && Me.__createBinding || (Object.create ? (function(c, h, M, Y) {
|
|
645
|
+
Y === void 0 && (Y = M), Object.defineProperty(c, Y, { enumerable: !0, get: function() {
|
|
646
|
+
return h[M];
|
|
647
647
|
} });
|
|
648
|
-
}) : (function(c, h,
|
|
649
|
-
Y === void 0 && (Y =
|
|
650
|
-
})),
|
|
648
|
+
}) : (function(c, h, M, Y) {
|
|
649
|
+
Y === void 0 && (Y = M), c[Y] = h[M];
|
|
650
|
+
})), t = Me && Me.__setModuleDefault || (Object.create ? (function(c, h) {
|
|
651
651
|
Object.defineProperty(c, "default", { enumerable: !0, value: h });
|
|
652
652
|
}) : function(c, h) {
|
|
653
653
|
c.default = h;
|
|
654
|
-
}),
|
|
654
|
+
}), n = Me && Me.__importStar || function(c) {
|
|
655
655
|
if (c && c.__esModule) return c;
|
|
656
656
|
var h = {};
|
|
657
|
-
if (c != null) for (var
|
|
658
|
-
return
|
|
659
|
-
}, r =
|
|
657
|
+
if (c != null) for (var M in c) Object.hasOwnProperty.call(c, M) && e(h, c, M);
|
|
658
|
+
return t(h, c), h;
|
|
659
|
+
}, r = Me && Me.__importDefault || function(c) {
|
|
660
660
|
return c && c.__esModule ? c : { default: c };
|
|
661
661
|
};
|
|
662
662
|
Object.defineProperty(a, "__esModule", { value: !0 }), a.type = a.remove = a.insert = void 0;
|
|
663
|
-
const u = pt(), o =
|
|
663
|
+
const u = pt(), o = n(ht()), l = r(an()), E = {
|
|
664
664
|
create(c) {
|
|
665
665
|
return c;
|
|
666
666
|
},
|
|
@@ -672,17 +672,17 @@ function sn() {
|
|
|
672
672
|
throw Error("Invalid document snapshot: " + c);
|
|
673
673
|
const h = [];
|
|
674
674
|
return {
|
|
675
|
-
skip(
|
|
676
|
-
let Y = u.uniToStrPos(c,
|
|
675
|
+
skip(M) {
|
|
676
|
+
let Y = u.uniToStrPos(c, M);
|
|
677
677
|
if (Y > c.length)
|
|
678
678
|
throw Error("The op is too long for this document");
|
|
679
679
|
h.push(c.slice(0, Y)), c = c.slice(Y);
|
|
680
680
|
},
|
|
681
|
-
append(
|
|
682
|
-
h.push(
|
|
681
|
+
append(M) {
|
|
682
|
+
h.push(M);
|
|
683
683
|
},
|
|
684
|
-
del(
|
|
685
|
-
c = c.slice(u.uniToStrPos(c,
|
|
684
|
+
del(M) {
|
|
685
|
+
c = c.slice(u.uniToStrPos(c, M));
|
|
686
686
|
},
|
|
687
687
|
build() {
|
|
688
688
|
return h.join("") + c;
|
|
@@ -696,10 +696,10 @@ function sn() {
|
|
|
696
696
|
Object.defineProperty(a, "makeType", { enumerable: !0, get: function() {
|
|
697
697
|
return s.default;
|
|
698
698
|
} });
|
|
699
|
-
})(
|
|
699
|
+
})(Me)), Me;
|
|
700
700
|
}
|
|
701
701
|
var Pt;
|
|
702
|
-
function
|
|
702
|
+
function un() {
|
|
703
703
|
return Pt || (Pt = 1, (function(a) {
|
|
704
704
|
var e = Ze && Ze.__importDefault || function(i) {
|
|
705
705
|
return i && i.__esModule ? i : {
|
|
@@ -709,7 +709,7 @@ function on() {
|
|
|
709
709
|
Object.defineProperty(a, "__esModule", {
|
|
710
710
|
value: !0
|
|
711
711
|
}), a.editOp = a.replaceOp = a.insertOp = a.moveOp = a.removeOp = a.type = void 0;
|
|
712
|
-
const
|
|
712
|
+
const t = e(sn()), n = e(on()), r = Ut(), u = At();
|
|
713
713
|
function o(i, d) {
|
|
714
714
|
if (!i) throw new Error(d);
|
|
715
715
|
}
|
|
@@ -724,7 +724,7 @@ function on() {
|
|
|
724
724
|
},
|
|
725
725
|
registerSubtype: Z,
|
|
726
726
|
checkValidOp: z,
|
|
727
|
-
normalize:
|
|
727
|
+
normalize: $,
|
|
728
728
|
apply: Ee,
|
|
729
729
|
transformPosition: ce,
|
|
730
730
|
compose: ne,
|
|
@@ -732,13 +732,13 @@ function on() {
|
|
|
732
732
|
transform: jt,
|
|
733
733
|
makeInvertible: De,
|
|
734
734
|
invert: le,
|
|
735
|
-
invertWithDoc:
|
|
735
|
+
invertWithDoc: Mt,
|
|
736
736
|
RM_UNEXPECTED_CONTENT: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
737
737
|
DROP_COLLISION: u.ConflictType.DROP_COLLISION,
|
|
738
738
|
BLACKHOLE: u.ConflictType.BLACKHOLE,
|
|
739
|
-
transformNoConflict: (i, d,
|
|
739
|
+
transformNoConflict: (i, d, v) => yt(() => !0, i, d, v),
|
|
740
740
|
typeAllowingConflictsPred: (i) => Object.assign(Object.assign({}, a.type), {
|
|
741
|
-
transform: (d,
|
|
741
|
+
transform: (d, v, D) => yt(i, d, v, D)
|
|
742
742
|
})
|
|
743
743
|
};
|
|
744
744
|
const l = (i) => i ? i.getComponent() : null;
|
|
@@ -749,23 +749,23 @@ function on() {
|
|
|
749
749
|
function c(i, d) {
|
|
750
750
|
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;
|
|
751
751
|
}
|
|
752
|
-
function h(i, d,
|
|
753
|
-
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,
|
|
752
|
+
function h(i, d, v) {
|
|
753
|
+
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, v)) : (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] = v), v;
|
|
754
754
|
}
|
|
755
|
-
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,
|
|
756
|
-
D.write("r", d), D.write("i",
|
|
757
|
-
}).get(), a.editOp = (i, d,
|
|
758
|
-
const
|
|
755
|
+
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, v) => r.writeCursor().at(i, (D) => {
|
|
756
|
+
D.write("r", d), D.write("i", v);
|
|
757
|
+
}).get(), a.editOp = (i, d, v, D = !1) => r.writeCursor().at(i, (O) => y(O, d, v, D)).get();
|
|
758
|
+
const M = (i, d) => i != null && (typeof d == "number" ? Array.isArray(i) : typeof i == "object"), Y = (i, d) => M(i, d) ? i[d] : void 0, pe = {};
|
|
759
759
|
function Z(i) {
|
|
760
760
|
let d = i.type ? i.type : i;
|
|
761
761
|
d.name && (pe[d.name] = d), d.uri && (pe[d.uri] = d);
|
|
762
762
|
}
|
|
763
|
-
const
|
|
763
|
+
const Ie = (i) => {
|
|
764
764
|
const d = pe[i];
|
|
765
765
|
if (d) return d;
|
|
766
766
|
throw Error("Missing type: " + i);
|
|
767
767
|
};
|
|
768
|
-
Z(
|
|
768
|
+
Z(ln());
|
|
769
769
|
const qe = (i, d) => i + d;
|
|
770
770
|
Z({
|
|
771
771
|
name: "number",
|
|
@@ -774,9 +774,9 @@ function on() {
|
|
|
774
774
|
invert: (i) => -i,
|
|
775
775
|
transform: (i) => i
|
|
776
776
|
});
|
|
777
|
-
const
|
|
778
|
-
const [O,
|
|
779
|
-
!D && O.isNoop && O.isNoop(
|
|
777
|
+
const me = (i) => i == null ? null : i.et ? Ie(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, v, D = !1) => {
|
|
778
|
+
const [O, C] = typeof d == "string" ? [Ie(d), d] : [d, d.name];
|
|
779
|
+
!D && O.isNoop && O.isNoop(v) || (C === "number" ? i.write("ena", v) : C === "text-unicode" ? i.write("es", v) : (i.write("et", C), i.write("e", v)));
|
|
780
780
|
};
|
|
781
781
|
function b(i) {
|
|
782
782
|
o(typeof i == "number"), o(i >= 0), o(i === (0 | i));
|
|
@@ -786,522 +786,522 @@ function on() {
|
|
|
786
786
|
}
|
|
787
787
|
function z(i) {
|
|
788
788
|
if (i === null) return;
|
|
789
|
-
const d = /* @__PURE__ */ new Set(),
|
|
789
|
+
const d = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), D = (C) => {
|
|
790
790
|
let x = !0, N = !1;
|
|
791
|
-
for (let p in
|
|
792
|
-
const
|
|
793
|
-
if (x = !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(
|
|
794
|
-
else if (p === "d") b(
|
|
791
|
+
for (let p in C) {
|
|
792
|
+
const m = C[p];
|
|
793
|
+
if (x = !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(m), o(!d.has(m)), d.add(m), o(C.r === void 0);
|
|
794
|
+
else if (p === "d") b(m), o(!v.has(m)), v.add(m), o(C.i === void 0);
|
|
795
795
|
else if (p === "e" || p === "es" || p === "ena") {
|
|
796
796
|
o(!N), N = !0;
|
|
797
|
-
const w =
|
|
798
|
-
o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(
|
|
797
|
+
const w = me(C);
|
|
798
|
+
o(w, "Missing type in edit"), w.checkValidOp && w.checkValidOp(f(C));
|
|
799
799
|
}
|
|
800
800
|
}
|
|
801
801
|
o(!x);
|
|
802
|
-
}, O = (
|
|
803
|
-
if (!Array.isArray(
|
|
804
|
-
if (
|
|
805
|
-
x || q(
|
|
806
|
-
let p = 1,
|
|
807
|
-
for (let
|
|
808
|
-
const R = I
|
|
802
|
+
}, O = (C, x, N) => {
|
|
803
|
+
if (!Array.isArray(C)) throw Error("Op must be null or a list");
|
|
804
|
+
if (C.length === 0) throw Error("Empty descent");
|
|
805
|
+
x || q(C[0]);
|
|
806
|
+
let p = 1, m = 0, w = 0;
|
|
807
|
+
for (let I = 0; I < C.length; I++) {
|
|
808
|
+
const R = C[I];
|
|
809
809
|
if (o(R != null), Array.isArray(R)) {
|
|
810
810
|
const W = O(R, !1);
|
|
811
|
-
if (
|
|
812
|
-
const g = typeof w,
|
|
813
|
-
g ===
|
|
811
|
+
if (m) {
|
|
812
|
+
const g = typeof w, U = typeof W;
|
|
813
|
+
g === U ? o(w < W, "descent keys are not in order") : o(g === "number" && U === "string");
|
|
814
814
|
}
|
|
815
|
-
w = W,
|
|
815
|
+
w = W, m++, p = 3;
|
|
816
816
|
} else typeof R == "object" ? (o(p === 1, `Prev not scalar - instead ${p}`), D(R), p = 2) : (o(p !== 3), q(R), o(r.isValidPathItem(R), "Invalid path key"), p = 1);
|
|
817
817
|
}
|
|
818
|
-
return o(
|
|
818
|
+
return o(m !== 1, "Operation makes multiple descents. Remove some []"), o(p === 2 || p === 3), C[0];
|
|
819
819
|
};
|
|
820
|
-
O(i, !0), o(d.size ===
|
|
821
|
-
for (let
|
|
820
|
+
O(i, !0), o(d.size === v.size, "Mismatched picks and drops in op");
|
|
821
|
+
for (let C = 0; C < d.size; C++) o(d.has(C)), o(v.has(C));
|
|
822
822
|
}
|
|
823
|
-
function
|
|
824
|
-
let d = 0,
|
|
823
|
+
function $(i) {
|
|
824
|
+
let d = 0, v = [];
|
|
825
825
|
const D = r.writeCursor();
|
|
826
|
-
return D.mergeTree(i, (O,
|
|
827
|
-
const x =
|
|
826
|
+
return D.mergeTree(i, (O, C) => {
|
|
827
|
+
const x = me(O);
|
|
828
828
|
if (x) {
|
|
829
829
|
const p = f(O);
|
|
830
|
-
y(
|
|
830
|
+
y(C, x, x.normalize ? x.normalize(p) : p);
|
|
831
831
|
}
|
|
832
832
|
for (const p of ["r", "p", "i", "d"]) if (O[p] !== void 0) {
|
|
833
|
-
const
|
|
834
|
-
|
|
833
|
+
const m = p === "p" || p === "d" ? (N = O[p], v[N] == null && (v[N] = d++), v[N]) : O[p];
|
|
834
|
+
C.write(p, m);
|
|
835
835
|
}
|
|
836
836
|
var N;
|
|
837
837
|
}), D.get();
|
|
838
838
|
}
|
|
839
839
|
function Ee(i, d) {
|
|
840
840
|
if (z(d), d === null) return i;
|
|
841
|
-
const
|
|
842
|
-
return (function D(O,
|
|
841
|
+
const v = [];
|
|
842
|
+
return (function D(O, C) {
|
|
843
843
|
let x = O, N = 0, p = {
|
|
844
844
|
root: O
|
|
845
|
-
},
|
|
845
|
+
}, m = 0, w = p, I = "root";
|
|
846
846
|
function R() {
|
|
847
|
-
for (;
|
|
848
|
-
let W =
|
|
849
|
-
typeof W != "object" && (o(
|
|
847
|
+
for (; m < N; m++) {
|
|
848
|
+
let W = C[m];
|
|
849
|
+
typeof W != "object" && (o(M(w, I)), w = w[I] = B(w[I]), I = W);
|
|
850
850
|
}
|
|
851
851
|
}
|
|
852
|
-
for (; N <
|
|
853
|
-
const W =
|
|
852
|
+
for (; N < C.length; N++) {
|
|
853
|
+
const W = C[N];
|
|
854
854
|
if (Array.isArray(W)) {
|
|
855
855
|
const g = D(x, W);
|
|
856
|
-
g !== x && g !== void 0 && (R(), x = w[
|
|
856
|
+
g !== x && g !== void 0 && (R(), x = w[I] = g);
|
|
857
857
|
} else if (typeof W == "object") {
|
|
858
|
-
W.d != null ? (R(), x = h(w,
|
|
859
|
-
const g =
|
|
860
|
-
if (g) R(), x = w[
|
|
858
|
+
W.d != null ? (R(), x = h(w, I, v[W.d])) : W.i !== void 0 && (R(), x = h(w, I, W.i));
|
|
859
|
+
const g = me(W);
|
|
860
|
+
if (g) R(), x = w[I] = g.apply(x, f(W));
|
|
861
861
|
else if (W.e !== void 0) throw Error("Subtype " + W.et + " undefined");
|
|
862
862
|
} else x = Y(x, W);
|
|
863
863
|
}
|
|
864
864
|
return p.root;
|
|
865
|
-
})(i = (function D(O,
|
|
865
|
+
})(i = (function D(O, C) {
|
|
866
866
|
const x = [];
|
|
867
867
|
let N = 0;
|
|
868
|
-
for (; N <
|
|
869
|
-
const
|
|
870
|
-
if (Array.isArray(
|
|
871
|
-
typeof
|
|
868
|
+
for (; N < C.length; N++) {
|
|
869
|
+
const I = C[N];
|
|
870
|
+
if (Array.isArray(I)) break;
|
|
871
|
+
typeof I != "object" && (x.push(O), O = Y(O, I));
|
|
872
872
|
}
|
|
873
|
-
for (let
|
|
873
|
+
for (let I = C.length - 1; I >= N; I--) O = D(O, C[I]);
|
|
874
874
|
for (--N; N >= 0; N--) {
|
|
875
|
-
const
|
|
876
|
-
if (typeof
|
|
875
|
+
const I = C[N];
|
|
876
|
+
if (typeof I != "object") {
|
|
877
877
|
const R = x.pop();
|
|
878
|
-
O = O === Y(R,
|
|
879
|
-
} else _(
|
|
878
|
+
O = O === Y(R, I) ? R : O === void 0 ? c(R, I) : (m = I, w = O, (p = B(p = R))[m] = w, p);
|
|
879
|
+
} else _(I) && (o(O !== void 0, "Cannot pick up or remove undefined"), I.p != null && (v[I.p] = O), O = void 0);
|
|
880
880
|
}
|
|
881
|
-
var p,
|
|
881
|
+
var p, m, w;
|
|
882
882
|
return O;
|
|
883
883
|
})(i, d), d);
|
|
884
884
|
}
|
|
885
885
|
function ce(i, d) {
|
|
886
886
|
i = i.slice(), z(d);
|
|
887
|
-
const
|
|
888
|
-
let D, O,
|
|
887
|
+
const v = r.readCursor(d);
|
|
888
|
+
let D, O, C = !1;
|
|
889
889
|
const x = [];
|
|
890
890
|
for (let p = 0; ; p++) {
|
|
891
|
-
const
|
|
892
|
-
if (w && (w.r !== void 0 ?
|
|
893
|
-
let
|
|
894
|
-
const R = r.advancer(
|
|
895
|
-
_(
|
|
891
|
+
const m = i[p], w = v.getComponent();
|
|
892
|
+
if (w && (w.r !== void 0 ? C = !0 : w.p != null && (C = !1, D = w.p, O = p)), p >= i.length) break;
|
|
893
|
+
let I = 0;
|
|
894
|
+
const R = r.advancer(v, void 0, (g, U) => {
|
|
895
|
+
_(U) && I++;
|
|
896
896
|
});
|
|
897
897
|
x.unshift(R);
|
|
898
|
-
const W = R(
|
|
899
|
-
if (typeof
|
|
898
|
+
const W = R(m);
|
|
899
|
+
if (typeof m == "number" && (i[p] -= I), !W) break;
|
|
900
900
|
}
|
|
901
|
-
if (x.forEach((p) => p.end()),
|
|
901
|
+
if (x.forEach((p) => p.end()), C) return null;
|
|
902
902
|
const N = () => {
|
|
903
903
|
let p = 0;
|
|
904
904
|
if (D != null) {
|
|
905
|
-
const
|
|
906
|
-
p =
|
|
905
|
+
const m = v.getPath();
|
|
906
|
+
p = m.length, i = m.concat(i.slice(O));
|
|
907
907
|
}
|
|
908
908
|
for (; p < i.length; p++) {
|
|
909
|
-
const
|
|
910
|
-
if (
|
|
909
|
+
const m = i[p], w = l(v), I = me(w);
|
|
910
|
+
if (I) {
|
|
911
911
|
const g = f(w);
|
|
912
|
-
|
|
912
|
+
I.transformPosition && (i[p] = I.transformPosition(i[p], g));
|
|
913
913
|
break;
|
|
914
914
|
}
|
|
915
915
|
let R = 0;
|
|
916
|
-
const W = r.advancer(
|
|
917
|
-
s(
|
|
918
|
-
})(
|
|
919
|
-
if (typeof
|
|
916
|
+
const W = r.advancer(v, (g, U) => s(U) ? ~(g - R) : g - R, (g, U) => {
|
|
917
|
+
s(U) && R++;
|
|
918
|
+
})(m);
|
|
919
|
+
if (typeof m == "number" && (i[p] += R), !W) break;
|
|
920
920
|
}
|
|
921
921
|
};
|
|
922
|
-
return D != null ?
|
|
922
|
+
return D != null ? v.eachDrop(null, (p) => {
|
|
923
923
|
p === D && N();
|
|
924
924
|
}) : N(), i;
|
|
925
925
|
}
|
|
926
926
|
function ne(i, d) {
|
|
927
927
|
if (z(i), z(d), i == null) return d;
|
|
928
928
|
if (d == null) return i;
|
|
929
|
-
let
|
|
930
|
-
const D = r.readCursor(i), O = r.readCursor(d),
|
|
929
|
+
let v = 0;
|
|
930
|
+
const D = r.readCursor(i), O = r.readCursor(d), C = r.writeCursor(), x = [], N = [], p = [], m = [], w = [], I = [], R = /* @__PURE__ */ new Set();
|
|
931
931
|
D.traverse(null, (g) => {
|
|
932
932
|
g.p != null && (p[g.p] = D.clone());
|
|
933
933
|
}), O.traverse(null, (g) => {
|
|
934
|
-
g.d != null && (
|
|
934
|
+
g.d != null && (m[g.d] = O.clone());
|
|
935
935
|
});
|
|
936
936
|
const W = r.writeCursor();
|
|
937
|
-
return (function g(
|
|
937
|
+
return (function g(U, re, te, K, se, Re, Oe, ye) {
|
|
938
938
|
o(re || te);
|
|
939
|
-
const oe = l(re), Pe = l(te),
|
|
940
|
-
if (
|
|
941
|
-
else if (Pe && Pe.r !== void 0)
|
|
939
|
+
const oe = l(re), Pe = l(te), Se = !!Pe && Pe.r !== void 0, $e = !!oe && oe.i !== void 0, Te = oe ? oe.d : null, Ce = Pe ? Pe.p : null, xe = (Re || Se) && Ce == null;
|
|
940
|
+
if (Ce != null) K = m[Ce], Oe = N[Ce] = new r.WriteCursor();
|
|
941
|
+
else if (Pe && Pe.r !== void 0) K = null;
|
|
942
942
|
else {
|
|
943
|
-
const T = l(
|
|
944
|
-
T && T.d != null && (
|
|
943
|
+
const T = l(K);
|
|
944
|
+
T && T.d != null && (K = null);
|
|
945
945
|
}
|
|
946
|
-
const Q = l(
|
|
947
|
-
if (Te != null) if (
|
|
946
|
+
const Q = l(K);
|
|
947
|
+
if (Te != null) if (U = p[Te], ye = x[Te] = new r.WriteCursor(), xe) Re && !Se && ye.write("r", !0);
|
|
948
948
|
else {
|
|
949
|
-
const T = w[Te] =
|
|
949
|
+
const T = w[Te] = v++;
|
|
950
950
|
Oe.write("d", T);
|
|
951
951
|
}
|
|
952
|
-
else if (oe && oe.i !== void 0)
|
|
952
|
+
else if (oe && oe.i !== void 0) U = null;
|
|
953
953
|
else {
|
|
954
|
-
const T = l(
|
|
955
|
-
T && T.p != null && (
|
|
954
|
+
const T = l(U);
|
|
955
|
+
T && T.p != null && (U = null);
|
|
956
956
|
}
|
|
957
|
-
let
|
|
958
|
-
|
|
959
|
-
const
|
|
960
|
-
if (
|
|
961
|
-
if (!(se !== void 0 ||
|
|
962
|
-
const T = Te != null ? w[Te] :
|
|
963
|
-
|
|
957
|
+
let S;
|
|
958
|
+
$e ? (o(se === void 0), S = oe.i) : S = se;
|
|
959
|
+
const L = (Ce == null ? !$e || Re || Se : S === void 0) ? null : Oe.getComponent();
|
|
960
|
+
if (Ce != null) {
|
|
961
|
+
if (!(se !== void 0 || $e)) {
|
|
962
|
+
const T = Te != null ? w[Te] : v++;
|
|
963
|
+
I[Ce] = T, ye.write("p", T);
|
|
964
964
|
}
|
|
965
|
-
} else
|
|
966
|
-
const
|
|
967
|
-
if ((
|
|
968
|
-
o(
|
|
969
|
-
const T = f(oe),
|
|
970
|
-
y(Oe,
|
|
971
|
-
} else
|
|
972
|
-
const
|
|
965
|
+
} else Se && ($e || se !== void 0 || (Pe.r, ye.write("r", Pe.r)));
|
|
966
|
+
const k = xe ? null : me(oe), P = me(Q);
|
|
967
|
+
if ((k || P) && (k && k.name, P && P.name), k && P) {
|
|
968
|
+
o(k === P);
|
|
969
|
+
const T = f(oe), G = f(Q), he = k.compose(T, G);
|
|
970
|
+
y(Oe, k, he), R.add(Q);
|
|
971
|
+
} else k ? y(Oe, k, f(oe)) : P && (y(Oe, P, f(Q)), R.add(Q));
|
|
972
|
+
const A = typeof S == "object" && S != null;
|
|
973
973
|
let J = !1, X = 0, ee = 0, fe = 0, de = 0, ae = 0;
|
|
974
|
-
const
|
|
975
|
-
s(
|
|
976
|
-
}), H = r.advancer(
|
|
977
|
-
_(
|
|
974
|
+
const ve = r.advancer(K, (T, G) => s(G) ? de - T - 1 : T - de, (T, G) => {
|
|
975
|
+
s(G) && de++;
|
|
976
|
+
}), H = r.advancer(U, (T, G) => _(G) ? X - T - 1 : T - X, (T, G) => {
|
|
977
|
+
_(G) && X++;
|
|
978
978
|
});
|
|
979
|
-
if (r.eachChildOf(re, te, (T,
|
|
980
|
-
let we, Be,
|
|
979
|
+
if (r.eachChildOf(re, te, (T, G, he) => {
|
|
980
|
+
let we, Be, Ke = T, ke = T, Ye = T;
|
|
981
981
|
if (typeof T == "number") {
|
|
982
982
|
let _e = T + fe;
|
|
983
|
-
Be =
|
|
983
|
+
Be = ve(_e), ke = _e + de;
|
|
984
984
|
let ue = T + ee;
|
|
985
|
-
we = H(ue), s(l(Be)) && (we = null),
|
|
986
|
-
const
|
|
987
|
-
(
|
|
988
|
-
} else we = H(T), Be =
|
|
989
|
-
ye.descend(
|
|
990
|
-
const Xe =
|
|
985
|
+
we = H(ue), s(l(Be)) && (we = null), Ke = ue + X, Ye = T + ae, o(Ke >= 0, "p1PickKey is negative"), o(ke >= 0, "p2DropKey is negative");
|
|
986
|
+
const Ue = s(l(G)), We = _(l(he));
|
|
987
|
+
(Ue || We && !xe) && ae--, Ue && ee--, We && fe--;
|
|
988
|
+
} else we = H(T), Be = ve(T);
|
|
989
|
+
ye.descend(Ke), Oe.descend(ke);
|
|
990
|
+
const Xe = A && !s(l(G)) ? S[Ye] : void 0, je = g(we, G, he, Be, Xe, xe, Oe, ye);
|
|
991
991
|
var Ne, j, ie;
|
|
992
|
-
|
|
993
|
-
}), H.end(),
|
|
994
|
-
else if (!Re && !
|
|
995
|
-
})(D, D.clone(), O, O.clone(), void 0, !1,
|
|
992
|
+
A && !xe ? Xe !== je && (J || (S = Array.isArray(S) ? S.slice() : Object.assign({}, S), J = !0), Ne = S, ie = je, typeof (j = Ye) == "number" ? (o(Array.isArray(Ne)), o(j < Ne.length)) : (o(!Array.isArray(Ne)), o(Ne[j] !== void 0)), ie === void 0 ? typeof j == "number" ? Ne.splice(j, 1) : delete Ne[j] : Ne[j] = ie) : o(je === void 0), Oe.ascend(), ye.ascend();
|
|
993
|
+
}), H.end(), ve.end(), L != null) L.i = S;
|
|
994
|
+
else if (!Re && !Se && Ce == null) return S;
|
|
995
|
+
})(D, D.clone(), O, O.clone(), void 0, !1, C, W), C.reset(), C.mergeTree(W.get()), C.reset(), C.get(), x.map((g) => g.get()), N.map((g) => g.get()), D.traverse(C, (g, U) => {
|
|
996
996
|
const re = g.p;
|
|
997
997
|
if (re != null) {
|
|
998
998
|
const te = w[re];
|
|
999
|
-
te != null &&
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
} else g.r !== void 0 &&
|
|
1003
|
-
}),
|
|
999
|
+
te != null && U.write("p", te);
|
|
1000
|
+
const K = x[re];
|
|
1001
|
+
K && K.get(), K && U.mergeTree(K.get());
|
|
1002
|
+
} else g.r !== void 0 && U.write("r", g.r);
|
|
1003
|
+
}), C.reset(), C.get(), O.traverse(C, (g, U) => {
|
|
1004
1004
|
const re = g.d;
|
|
1005
1005
|
if (re != null) {
|
|
1006
|
-
const
|
|
1007
|
-
|
|
1006
|
+
const K = I[re];
|
|
1007
|
+
K != null && U.write("d", K);
|
|
1008
1008
|
const se = N[re];
|
|
1009
|
-
se &&
|
|
1010
|
-
} else g.i !== void 0 &&
|
|
1011
|
-
const te =
|
|
1012
|
-
te && !R.has(g) && y(
|
|
1013
|
-
}),
|
|
1009
|
+
se && U.mergeTree(se.get());
|
|
1010
|
+
} else g.i !== void 0 && U.write("i", g.i);
|
|
1011
|
+
const te = me(g);
|
|
1012
|
+
te && !R.has(g) && y(U, te, f(g));
|
|
1013
|
+
}), C.get();
|
|
1014
1014
|
}
|
|
1015
1015
|
function le(i) {
|
|
1016
1016
|
if (i == null) return null;
|
|
1017
|
-
const d = new r.ReadCursor(i),
|
|
1017
|
+
const d = new r.ReadCursor(i), v = new r.WriteCursor();
|
|
1018
1018
|
let D;
|
|
1019
|
-
const O = [],
|
|
1020
|
-
return (function x(N, p,
|
|
1019
|
+
const O = [], C = [];
|
|
1020
|
+
return (function x(N, p, m) {
|
|
1021
1021
|
const w = N.getComponent();
|
|
1022
|
-
let
|
|
1022
|
+
let I, R = !1;
|
|
1023
1023
|
if (w) {
|
|
1024
|
-
w.p != null && (p.write("d", w.p), O[w.p] = N.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d),
|
|
1025
|
-
const g =
|
|
1026
|
-
g && (
|
|
1024
|
+
w.p != null && (p.write("d", w.p), O[w.p] = N.clone()), w.r !== void 0 && p.write("i", w.r), w.d != null && (p.write("p", w.d), m = void 0), w.i !== void 0 && (m = I = w.i);
|
|
1025
|
+
const g = me(w);
|
|
1026
|
+
g && (m === void 0 ? (D || (D = /* @__PURE__ */ new Set()), D.add(w)) : (f(w), m = g.apply(m, f(w)), R = !0));
|
|
1027
1027
|
}
|
|
1028
1028
|
let W = 0;
|
|
1029
1029
|
for (const g of N) {
|
|
1030
1030
|
p.descend(g);
|
|
1031
|
-
const
|
|
1031
|
+
const U = typeof g == "number" ? g - W : g, re = Y(m, U);
|
|
1032
1032
|
s(N.getComponent()) && W++;
|
|
1033
1033
|
const te = x(N, p, re);
|
|
1034
|
-
if (
|
|
1035
|
-
if (R || (R = !0,
|
|
1036
|
-
|
|
1034
|
+
if (m !== void 0 && te !== void 0) {
|
|
1035
|
+
if (R || (R = !0, m = B(m)), !M(m, U)) throw Error("Cannot modify child - invalid operation");
|
|
1036
|
+
m[U] = te;
|
|
1037
1037
|
}
|
|
1038
1038
|
p.ascend();
|
|
1039
1039
|
}
|
|
1040
|
-
if (
|
|
1041
|
-
p.write("r",
|
|
1042
|
-
})(d,
|
|
1040
|
+
if (I === void 0) return R ? m : void 0;
|
|
1041
|
+
p.write("r", m);
|
|
1042
|
+
})(d, v, void 0), D && (v.reset(), (function x(N, p, m) {
|
|
1043
1043
|
const w = p.getComponent();
|
|
1044
1044
|
if (w) {
|
|
1045
1045
|
const g = w.d;
|
|
1046
|
-
if (g != null && (N = O[g],
|
|
1047
|
-
const
|
|
1048
|
-
if (!
|
|
1049
|
-
y(
|
|
1046
|
+
if (g != null && (N = O[g], m = C[g] = r.writeCursor()), D.has(w)) {
|
|
1047
|
+
const U = me(w);
|
|
1048
|
+
if (!U.invert) throw Error(`Cannot invert subtype ${U.name}`);
|
|
1049
|
+
y(m, U, U.invert(f(w)));
|
|
1050
1050
|
}
|
|
1051
1051
|
}
|
|
1052
|
-
let
|
|
1053
|
-
const W = r.advancer(N, (g,
|
|
1054
|
-
_(
|
|
1052
|
+
let I = 0, R = 0;
|
|
1053
|
+
const W = r.advancer(N, (g, U) => _(U) ? I - g - 1 : g - I, (g, U) => {
|
|
1054
|
+
_(U) && I++;
|
|
1055
1055
|
});
|
|
1056
1056
|
for (const g of p) if (typeof g == "number") {
|
|
1057
|
-
const
|
|
1058
|
-
|
|
1059
|
-
} else
|
|
1057
|
+
const U = g - R, re = W(U), te = U + I;
|
|
1058
|
+
m.descend(te), x(re, p, m), s(p.getComponent()) && R++, m.ascend();
|
|
1059
|
+
} else m.descend(g), x(W(g), p, m), m.ascend();
|
|
1060
1060
|
W.end();
|
|
1061
|
-
})(d.clone(), d,
|
|
1061
|
+
})(d.clone(), d, v), C.length && (v.reset(), d.traverse(v, (x, N) => {
|
|
1062
1062
|
const p = x.p;
|
|
1063
1063
|
if (p != null) {
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1064
|
+
const m = C[p];
|
|
1065
|
+
m && m.get(), m && N.mergeTree(m.get());
|
|
1066
1066
|
}
|
|
1067
|
-
}))),
|
|
1067
|
+
}))), v.get();
|
|
1068
1068
|
}
|
|
1069
|
-
const ge = (i, d) => i.some((
|
|
1069
|
+
const ge = (i, d) => i.some((v) => typeof v == "object" && (Array.isArray(v) ? ge(v, d) : d(v)));
|
|
1070
1070
|
function De(i, d) {
|
|
1071
1071
|
if (i == null || !ge(i, (p) => {
|
|
1072
|
-
var
|
|
1073
|
-
return p.r !== void 0 || ((
|
|
1072
|
+
var m;
|
|
1073
|
+
return p.r !== void 0 || ((m = me(p)) === null || m === void 0 ? void 0 : m.makeInvertible) != null;
|
|
1074
1074
|
})) return i;
|
|
1075
|
-
const
|
|
1075
|
+
const v = new r.ReadCursor(i), D = new r.WriteCursor();
|
|
1076
1076
|
let O = !1;
|
|
1077
|
-
const
|
|
1078
|
-
const
|
|
1077
|
+
const C = [], x = [], N = (p, m, w) => {
|
|
1078
|
+
const I = p.getComponent();
|
|
1079
1079
|
let R = !1;
|
|
1080
|
-
if (
|
|
1081
|
-
|
|
1082
|
-
const g =
|
|
1083
|
-
if (g != null && (
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1080
|
+
if (I) {
|
|
1081
|
+
I.d != null && m.write("d", I.d), I.i !== void 0 && m.write("i", I.i);
|
|
1082
|
+
const g = I.p;
|
|
1083
|
+
if (g != null && (C[g] = p.clone(), o(w !== void 0, "Operation picks up at an invalid key"), x[g] = w, m.write("p", I.p)), I.r !== void 0 && w === void 0) throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");
|
|
1084
|
+
const U = me(I);
|
|
1085
|
+
U && (U.makeInvertible ? O = !0 : y(m, U, f(I), !0));
|
|
1086
1086
|
}
|
|
1087
1087
|
let W = 0;
|
|
1088
1088
|
for (const g of p) {
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
re !== te && (R || (R = !0, w = B(w)), te === void 0 ? (w = c(w,
|
|
1089
|
+
m.descend(g);
|
|
1090
|
+
const U = typeof g == "number" ? g - W : g, re = Y(w, U), te = N(p, m, re);
|
|
1091
|
+
re !== te && (R || (R = !0, w = B(w)), te === void 0 ? (w = c(w, U), typeof g == "number" && W++) : w[U] = te), m.ascend();
|
|
1092
1092
|
}
|
|
1093
|
-
return
|
|
1093
|
+
return I && (I.r !== void 0 ? (m.write("r", n.default(w)), w = void 0) : I.p != null && (w = void 0)), w;
|
|
1094
1094
|
};
|
|
1095
|
-
return N(
|
|
1095
|
+
return N(v, D, d), D.get(), O && (D.reset(), (function p(m, w, I, R, W) {
|
|
1096
1096
|
const g = w.getComponent();
|
|
1097
1097
|
if (g) {
|
|
1098
|
-
g.i !== void 0 ? (R = g.i, W = !0) : g.d != null && (R = x[g.d],
|
|
1099
|
-
let
|
|
1100
|
-
if (
|
|
1098
|
+
g.i !== void 0 ? (R = g.i, W = !0) : g.d != null && (R = x[g.d], m = C[g.d], W = !1, g.d);
|
|
1099
|
+
let K = me(g);
|
|
1100
|
+
if (K && K.makeInvertible) {
|
|
1101
1101
|
const se = f(g);
|
|
1102
|
-
y(
|
|
1102
|
+
y(I, K, K.makeInvertible(se, R), !0);
|
|
1103
1103
|
}
|
|
1104
1104
|
}
|
|
1105
|
-
let
|
|
1106
|
-
const te = r.advancer(
|
|
1107
|
-
_(se) &&
|
|
1105
|
+
let U = 0, re = 0;
|
|
1106
|
+
const te = r.advancer(m, (K, se) => _(se) ? U - K - 1 : K - U, (K, se) => {
|
|
1107
|
+
_(se) && U++;
|
|
1108
1108
|
});
|
|
1109
|
-
for (const
|
|
1110
|
-
const se =
|
|
1111
|
-
|
|
1109
|
+
for (const K of w) if (typeof K == "number") {
|
|
1110
|
+
const se = K - re, Re = te(se), Oe = se + U, ye = Y(R, W ? se : Oe);
|
|
1111
|
+
I.descend(K), p(Re, w, I, ye, W), s(w.getComponent()) && re++, I.ascend();
|
|
1112
1112
|
} else {
|
|
1113
|
-
const se = Y(R,
|
|
1114
|
-
|
|
1113
|
+
const se = Y(R, K);
|
|
1114
|
+
I.descend(K), p(te(K), w, I, se, W), I.ascend();
|
|
1115
1115
|
}
|
|
1116
1116
|
te.end();
|
|
1117
|
-
})(
|
|
1117
|
+
})(v.clone(), v, D, d, !1)), D.get();
|
|
1118
1118
|
}
|
|
1119
|
-
function
|
|
1119
|
+
function Mt(i, d) {
|
|
1120
1120
|
return le(De(i, d));
|
|
1121
1121
|
}
|
|
1122
1122
|
const it = (i) => {
|
|
1123
1123
|
if (i == null) return null;
|
|
1124
1124
|
const d = i.slice();
|
|
1125
|
-
for (let
|
|
1126
|
-
const D = d[
|
|
1127
|
-
Array.isArray(D) && (d[
|
|
1125
|
+
for (let v = 0; v < i.length; v++) {
|
|
1126
|
+
const D = d[v];
|
|
1127
|
+
Array.isArray(D) && (d[v] = it(D));
|
|
1128
1128
|
}
|
|
1129
1129
|
return d;
|
|
1130
1130
|
};
|
|
1131
|
-
function st(i, d,
|
|
1132
|
-
o(
|
|
1133
|
-
const D =
|
|
1131
|
+
function st(i, d, v) {
|
|
1132
|
+
o(v === "left" || v === "right", "Direction must be left or right");
|
|
1133
|
+
const D = v === "left" ? 0 : 1;
|
|
1134
1134
|
if (d == null) return {
|
|
1135
1135
|
ok: !0,
|
|
1136
1136
|
result: i
|
|
1137
1137
|
};
|
|
1138
1138
|
z(i), z(d);
|
|
1139
1139
|
let O = null;
|
|
1140
|
-
const
|
|
1140
|
+
const C = [], x = [], N = [], p = [], m = [], w = [], I = [], R = [], W = [], g = [], U = [], re = [], te = [], K = [], se = [];
|
|
1141
1141
|
let Re = 0;
|
|
1142
1142
|
const Oe = r.readCursor(i), ye = r.readCursor(d), oe = r.writeCursor();
|
|
1143
|
-
if ((function Q(
|
|
1144
|
-
const P = l(
|
|
1145
|
-
P && (P.r !== void 0 ?
|
|
1146
|
-
const
|
|
1143
|
+
if ((function Q(S, L = null, k) {
|
|
1144
|
+
const P = l(L);
|
|
1145
|
+
P && (P.r !== void 0 ? k = L.clone() : P.p != null && (k = null, w[P.p] = S.clone()));
|
|
1146
|
+
const A = S.getComponent();
|
|
1147
1147
|
let J;
|
|
1148
|
-
|
|
1149
|
-
const X = r.advancer(
|
|
1150
|
-
for (const ee of
|
|
1148
|
+
A && (J = A.p) != null && (m[J] = L ? L.clone() : null, N[J] = S.clone(), k && (g[J] = !0, W[J] = k), P && P.p != null && (K[J] = P.p));
|
|
1149
|
+
const X = r.advancer(L);
|
|
1150
|
+
for (const ee of S) Q(S, X(ee), k);
|
|
1151
1151
|
X.end();
|
|
1152
|
-
})(ye, Oe, null), (function Q(
|
|
1153
|
-
const J =
|
|
1152
|
+
})(ye, Oe, null), (function Q(S, L, k, P, A) {
|
|
1153
|
+
const J = k.getComponent();
|
|
1154
1154
|
let X, ee = !1;
|
|
1155
|
-
J && ((X = J.d) != null ? (p[X] =
|
|
1155
|
+
J && ((X = J.d) != null ? (p[X] = k.clone(), P != null && (se[P] == null && (se[P] = []), se[P].push(X)), g[X], S = m[X] || null, L = N[X] || null, g[X] ? (A && (U[X] = !0), A = W[X] || null) : !A || D !== 1 && K[X] != null || O == null && (O = {
|
|
1156
1156
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1157
|
-
op1: a.removeOp(
|
|
1158
|
-
op2: a.moveOp(
|
|
1159
|
-
}), ee = !0) : J.i !== void 0 && (
|
|
1157
|
+
op1: a.removeOp(A.getPath()),
|
|
1158
|
+
op2: a.moveOp(L.getPath(), k.getPath())
|
|
1159
|
+
}), ee = !0) : J.i !== void 0 && (S = L = null, ee = !0, A && O == null && (O = {
|
|
1160
1160
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1161
|
-
op1: a.removeOp(
|
|
1162
|
-
op2: a.insertOp(
|
|
1161
|
+
op1: a.removeOp(A.getPath()),
|
|
1162
|
+
op2: a.insertOp(k.getPath(), J.i)
|
|
1163
1163
|
})));
|
|
1164
|
-
const fe = l(
|
|
1165
|
-
fe && (fe.r !== void 0 ?
|
|
1166
|
-
const de =
|
|
1167
|
-
de &&
|
|
1164
|
+
const fe = l(S);
|
|
1165
|
+
fe && (fe.r !== void 0 ? A = S.clone() : fe.p != null && (fe.p, P = fe.p, A = null));
|
|
1166
|
+
const de = me(J);
|
|
1167
|
+
de && A && O == null && (O = {
|
|
1168
1168
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1169
|
-
op1: a.removeOp(
|
|
1170
|
-
op2: a.editOp(
|
|
1169
|
+
op1: a.removeOp(A.getPath()),
|
|
1170
|
+
op2: a.editOp(k.getPath(), de, f(J), !0)
|
|
1171
1171
|
});
|
|
1172
|
-
let ae = 0,
|
|
1173
|
-
const H = r.advancer(
|
|
1172
|
+
let ae = 0, ve = 0;
|
|
1173
|
+
const H = r.advancer(L, (G, he) => _(he) ? ae - G - 1 : G - ae, (G, he) => {
|
|
1174
1174
|
_(he) && ae++;
|
|
1175
|
-
}), T = r.advancer(
|
|
1176
|
-
for (const
|
|
1177
|
-
const he =
|
|
1178
|
-
|
|
1175
|
+
}), T = r.advancer(S);
|
|
1176
|
+
for (const G of k) if (typeof G == "number") {
|
|
1177
|
+
const he = G - ve, we = H(he);
|
|
1178
|
+
ve += +Q(T(he + ae), we, k, P, A);
|
|
1179
1179
|
} else {
|
|
1180
|
-
const he = H(
|
|
1181
|
-
Q(T(
|
|
1180
|
+
const he = H(G);
|
|
1181
|
+
Q(T(G), he, k, P, A);
|
|
1182
1182
|
}
|
|
1183
1183
|
return H.end(), T.end(), ee;
|
|
1184
1184
|
})(Oe, ye, ye.clone(), null, null), p.map((Q) => Q && Q.get()), O) return {
|
|
1185
1185
|
ok: !1,
|
|
1186
1186
|
conflict: O
|
|
1187
1187
|
};
|
|
1188
|
-
|
|
1188
|
+
U.map((Q) => !!Q);
|
|
1189
1189
|
const Pe = [];
|
|
1190
|
-
let
|
|
1191
|
-
(function Q(
|
|
1190
|
+
let Se = null;
|
|
1191
|
+
(function Q(S, L, k, P, A) {
|
|
1192
1192
|
let J = !1;
|
|
1193
|
-
const X = l(
|
|
1193
|
+
const X = l(L);
|
|
1194
1194
|
if (_(X)) {
|
|
1195
1195
|
const H = X.p;
|
|
1196
|
-
H != null ? (
|
|
1197
|
-
} else s(l(
|
|
1198
|
-
const ee =
|
|
1196
|
+
H != null ? (k = p[H], P = re[H] = r.writeCursor(), J = !0, A = null) : (k = null, A = L.clone());
|
|
1197
|
+
} else s(l(k)) && (k = null);
|
|
1198
|
+
const ee = S.getComponent();
|
|
1199
1199
|
if (ee) {
|
|
1200
1200
|
const H = ee.p;
|
|
1201
|
-
H != null ? (
|
|
1201
|
+
H != null ? (A && (R[H] = A), Pe[H] = A || D === 1 && J ? null : P.getComponent(), C[H] = S.clone(), k && (I[H] = k.clone())) : ee.r !== void 0 && (A || P.write("r", !0), (A || J) && (Se == null && (Se = /* @__PURE__ */ new Set()), Se.add(ee)));
|
|
1202
1202
|
}
|
|
1203
1203
|
let fe = 0, de = 0;
|
|
1204
|
-
const ae = r.advancer(
|
|
1204
|
+
const ae = r.advancer(L, void 0, (H, T) => {
|
|
1205
1205
|
_(T) && fe++;
|
|
1206
|
-
}),
|
|
1206
|
+
}), ve = r.advancer(k, (H, T) => s(T) ? ~(H - de) : H - de, (H, T) => {
|
|
1207
1207
|
s(T) && de++;
|
|
1208
1208
|
});
|
|
1209
|
-
if (
|
|
1210
|
-
const T = ae(H),
|
|
1211
|
-
P.descend(H), Q(
|
|
1209
|
+
if (S) for (const H of S) if (typeof H == "string") {
|
|
1210
|
+
const T = ae(H), G = ve(H);
|
|
1211
|
+
P.descend(H), Q(S, T, G, P, A), P.ascend();
|
|
1212
1212
|
} else {
|
|
1213
|
-
const T = ae(H),
|
|
1214
|
-
o(we >= 0), P.descend(we), Q(
|
|
1213
|
+
const T = ae(H), G = H - fe, he = _(l(T)) ? null : ve(G), we = G + de;
|
|
1214
|
+
o(we >= 0), P.descend(we), Q(S, T, he, P, A), P.ascend();
|
|
1215
1215
|
}
|
|
1216
|
-
ae.end(),
|
|
1216
|
+
ae.end(), ve.end();
|
|
1217
1217
|
})(Oe, ye, ye.clone(), oe, null), oe.reset();
|
|
1218
|
-
let
|
|
1219
|
-
if ((function Q(
|
|
1220
|
-
o(
|
|
1221
|
-
const X =
|
|
1218
|
+
let $e = [];
|
|
1219
|
+
if ((function Q(S, L, k, P, A, J) {
|
|
1220
|
+
o(L);
|
|
1221
|
+
const X = L.getComponent();
|
|
1222
1222
|
let ee = l(P), fe = !1;
|
|
1223
1223
|
const de = (j, ie, _e) => j ? a.moveOp(j.getPath(), ie.getPath()) : a.insertOp(ie.getPath(), _e.i);
|
|
1224
1224
|
if (s(X)) {
|
|
1225
1225
|
const j = X.d;
|
|
1226
|
-
j != null && (x[j] =
|
|
1226
|
+
j != null && (x[j] = L.clone());
|
|
1227
1227
|
const ie = j != null ? Pe[j] : null;
|
|
1228
1228
|
let _e = !1;
|
|
1229
1229
|
if (X.i !== void 0 || j != null && ie) {
|
|
1230
1230
|
let ue;
|
|
1231
|
-
ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j ===
|
|
1231
|
+
ee && (ee.i !== void 0 || (ue = ee.d) != null && !g[ue]) && (_e = ue != null ? j != null && j === K[ue] : t.default(ee.i, X.i), _e || ue != null && D !== 1 && K[ue] != null || O == null && (O = {
|
|
1232
1232
|
type: u.ConflictType.DROP_COLLISION,
|
|
1233
|
-
op1: de(j != null ?
|
|
1233
|
+
op1: de(j != null ? C[j] : null, L, X),
|
|
1234
1234
|
op2: de(ue != null ? N[ue] : null, P, ee)
|
|
1235
1235
|
})), _e || (J ? O == null && (O = {
|
|
1236
1236
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1237
|
-
op1: de(j != null ?
|
|
1237
|
+
op1: de(j != null ? C[j] : null, L, X),
|
|
1238
1238
|
op2: a.removeOp(J.getPath())
|
|
1239
|
-
}) : (j != null ? (
|
|
1239
|
+
}) : (j != null ? ($e[Re] = j, A.write("d", ie.p = Re++)) : A.write("i", n.default(X.i)), fe = !0));
|
|
1240
1240
|
} else if (j != null && !ie) {
|
|
1241
1241
|
const ue = R[j];
|
|
1242
1242
|
ue && (J = ue.clone());
|
|
1243
1243
|
}
|
|
1244
|
-
j != null ? (
|
|
1245
|
-
} else _(l(
|
|
1246
|
-
const ae = l(
|
|
1247
|
-
if (_(
|
|
1248
|
-
const j =
|
|
1249
|
-
|
|
1244
|
+
j != null ? (S = C[j], k = w[j], P = I[j]) : X.i !== void 0 && (S = k = null, _e || (P = null));
|
|
1245
|
+
} else _(l(S)) && (S = k = P = null);
|
|
1246
|
+
const ae = l(S), ve = l(k);
|
|
1247
|
+
if (_(ve)) {
|
|
1248
|
+
const j = ve.p;
|
|
1249
|
+
ve.r !== void 0 && (!ae || ae.r === void 0) || g[j] ? (P = null, J = k.clone()) : j != null && (P = p[j], D !== 1 && K[j] != null || ((A = te[j]) || (A = te[j] = r.writeCursor()), A.reset(), J = null));
|
|
1250
1250
|
} else !s(X) && s(ee) && (P = null);
|
|
1251
1251
|
ee = P != null ? P.getComponent() : null;
|
|
1252
|
-
const H =
|
|
1252
|
+
const H = me(X);
|
|
1253
1253
|
if (H) {
|
|
1254
1254
|
const j = f(X);
|
|
1255
1255
|
if (J) O == null && (O = {
|
|
1256
1256
|
type: u.ConflictType.RM_UNEXPECTED_CONTENT,
|
|
1257
|
-
op1: a.editOp(
|
|
1257
|
+
op1: a.editOp(L.getPath(), H, j, !0),
|
|
1258
1258
|
op2: a.removeOp(J.getPath())
|
|
1259
1259
|
});
|
|
1260
1260
|
else {
|
|
1261
|
-
const ie =
|
|
1261
|
+
const ie = me(ee);
|
|
1262
1262
|
let _e;
|
|
1263
1263
|
if (ie) {
|
|
1264
1264
|
if (H !== ie) throw Error("Transforming incompatible types");
|
|
1265
1265
|
const ue = f(ee);
|
|
1266
|
-
_e = H.transform(j, ue,
|
|
1267
|
-
} else _e =
|
|
1268
|
-
y(
|
|
1266
|
+
_e = H.transform(j, ue, v);
|
|
1267
|
+
} else _e = n.default(j);
|
|
1268
|
+
y(A, H, _e);
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
|
-
let T = 0,
|
|
1272
|
-
const Xe = r.advancer(
|
|
1271
|
+
let T = 0, G = 0, he = 0, we = 0, Be = 0, Ke = 0, ke = S != null && S.descendFirst(), Ye = ke;
|
|
1272
|
+
const Xe = r.advancer(k, void 0, (j, ie) => {
|
|
1273
1273
|
_(ie) && he++;
|
|
1274
1274
|
});
|
|
1275
1275
|
let je = P != null && P.descendFirst(), Ne = je;
|
|
1276
|
-
for (const j of
|
|
1276
|
+
for (const j of L) if (typeof j == "number") {
|
|
1277
1277
|
let ie;
|
|
1278
|
-
const _e = s(
|
|
1278
|
+
const _e = s(L.getComponent()), ue = j - G;
|
|
1279
1279
|
{
|
|
1280
|
-
let
|
|
1281
|
-
for (;
|
|
1282
|
-
|
|
1283
|
-
const
|
|
1284
|
-
if (
|
|
1280
|
+
let Le;
|
|
1281
|
+
for (; ke && typeof (Le = S.getKey()) == "number"; ) {
|
|
1282
|
+
Le += T;
|
|
1283
|
+
const Ae = S.getComponent(), Je = _(Ae);
|
|
1284
|
+
if (Le > ue || Le === ue && (!Je || D === 0 && _e)) break;
|
|
1285
1285
|
if (Je) {
|
|
1286
1286
|
T--;
|
|
1287
|
-
const Fe =
|
|
1288
|
-
|
|
1287
|
+
const Fe = Ae.p;
|
|
1288
|
+
K.includes(Fe), Ae.d, l(te[Ae.d]), _(l(te[Ae.d])), (Ae.r === void 0 || Se && Se.has(Ae)) && (Fe == null || !Pe[Fe] || D !== 1 && K.includes(Fe)) || Be--;
|
|
1289
1289
|
}
|
|
1290
|
-
|
|
1290
|
+
ke = S.nextSibling();
|
|
1291
1291
|
}
|
|
1292
|
-
ie =
|
|
1292
|
+
ie = ke && Le === ue ? S : null;
|
|
1293
1293
|
}
|
|
1294
|
-
const
|
|
1295
|
-
let We = Xe(
|
|
1296
|
-
const ot =
|
|
1294
|
+
const Ue = ue - T;
|
|
1295
|
+
let We = Xe(Ue);
|
|
1296
|
+
const ot = Ue - he;
|
|
1297
1297
|
let Qe = null;
|
|
1298
1298
|
{
|
|
1299
|
-
let
|
|
1300
|
-
for (; je && typeof (
|
|
1301
|
-
|
|
1299
|
+
let Le, Ae;
|
|
1300
|
+
for (; je && typeof (Le = P.getKey()) == "number"; ) {
|
|
1301
|
+
Ae = Le - we;
|
|
1302
1302
|
const Je = P.getComponent(), Fe = s(Je);
|
|
1303
|
-
if (
|
|
1304
|
-
if (
|
|
1303
|
+
if (Ae > ot) break;
|
|
1304
|
+
if (Ae === ot) {
|
|
1305
1305
|
if (!Fe) {
|
|
1306
1306
|
Qe = P;
|
|
1307
1307
|
break;
|
|
@@ -1311,99 +1311,99 @@ function on() {
|
|
|
1311
1311
|
Qe = P;
|
|
1312
1312
|
break;
|
|
1313
1313
|
}
|
|
1314
|
-
const
|
|
1315
|
-
if (D === 0 &&
|
|
1314
|
+
const Ge = We && _(We.getComponent());
|
|
1315
|
+
if (D === 0 && Ge) break;
|
|
1316
1316
|
}
|
|
1317
1317
|
}
|
|
1318
1318
|
if (Fe) {
|
|
1319
|
-
const
|
|
1320
|
-
g[
|
|
1319
|
+
const Ge = Je.d;
|
|
1320
|
+
g[Ge], K[Ge], Je.i === void 0 && (g[Ge] || K[Ge] != null && D !== 1) ? (g[Ge] || K[Ge] != null && D === 0) && (we++, Ke--) : we++;
|
|
1321
1321
|
}
|
|
1322
1322
|
je = P.nextSibling();
|
|
1323
1323
|
}
|
|
1324
1324
|
}
|
|
1325
|
-
const _t = ot + we + Be +
|
|
1326
|
-
o(_t >= 0, "trying to descend to a negative index"),
|
|
1325
|
+
const _t = ot + we + Be + Ke;
|
|
1326
|
+
o(_t >= 0, "trying to descend to a negative index"), A.descend(_t), _e && (ie = We = Qe = null, G++), Q(ie, L, We, Qe, A, J) && Ke++, A.ascend();
|
|
1327
1327
|
} else {
|
|
1328
1328
|
let ie;
|
|
1329
|
-
for (;
|
|
1330
|
-
const _e =
|
|
1331
|
-
let
|
|
1332
|
-
for (; je && (
|
|
1333
|
-
const We = je &&
|
|
1334
|
-
|
|
1329
|
+
for (; ke && (ie = S.getKey(), typeof ie != "string" || !(ie > j || ie === j)); ) ke = S.nextSibling();
|
|
1330
|
+
const _e = ke && ie === j ? S : null, ue = Xe(j);
|
|
1331
|
+
let Ue;
|
|
1332
|
+
for (; je && (Ue = P.getKey(), typeof Ue != "string" || !(Ue > j || Ue === j)); ) je = P.nextSibling();
|
|
1333
|
+
const We = je && Ue === j ? P : null;
|
|
1334
|
+
A.descend(j), Q(_e, L, ue, We, A, J), A.ascend();
|
|
1335
1335
|
}
|
|
1336
|
-
return Xe.end(), Ye &&
|
|
1336
|
+
return Xe.end(), Ye && S.ascend(), Ne && P.ascend(), fe;
|
|
1337
1337
|
})(Oe, Oe.clone(), ye, ye.clone(), oe, null), O) return {
|
|
1338
1338
|
ok: !1,
|
|
1339
1339
|
conflict: O
|
|
1340
1340
|
};
|
|
1341
1341
|
oe.reset();
|
|
1342
|
-
const Te = (Q,
|
|
1343
|
-
|
|
1342
|
+
const Te = (Q, S, L) => Q.traverse(S, (k, P) => {
|
|
1343
|
+
k.d != null && L(k.d, Q, P);
|
|
1344
1344
|
});
|
|
1345
|
-
(g.length || re.length) && (Te(ye, oe, (Q,
|
|
1346
|
-
g[Q] && !
|
|
1345
|
+
(g.length || re.length) && (Te(ye, oe, (Q, S, L) => {
|
|
1346
|
+
g[Q] && !U[Q] && L.write("r", !0), re[Q] && L.mergeTree(re[Q].get());
|
|
1347
1347
|
}), oe.reset());
|
|
1348
|
-
const
|
|
1348
|
+
const Ce = [], xe = [];
|
|
1349
1349
|
if ((te.length || g.length) && !O) {
|
|
1350
1350
|
const Q = r.readCursor(it(oe.get()));
|
|
1351
|
-
if (Te(Q, null, (
|
|
1352
|
-
|
|
1353
|
-
}), te.forEach((
|
|
1354
|
-
|
|
1355
|
-
|
|
1351
|
+
if (Te(Q, null, (S, L) => {
|
|
1352
|
+
Ce[S] = L.clone();
|
|
1353
|
+
}), te.forEach((S) => {
|
|
1354
|
+
S && Te(r.readCursor(S.get()), null, (L, k) => {
|
|
1355
|
+
Ce[L] = k.clone();
|
|
1356
1356
|
});
|
|
1357
|
-
}), (function
|
|
1358
|
-
const ee = l(
|
|
1357
|
+
}), (function S(L, k, P, A, J, X) {
|
|
1358
|
+
const ee = l(k);
|
|
1359
1359
|
if (ee && _(ee)) if (ee.p != null) {
|
|
1360
1360
|
const T = ee.p;
|
|
1361
|
-
|
|
1361
|
+
Ce[T].getPath(), P = Ce[T], A = xe[T] = r.writeCursor();
|
|
1362
1362
|
} else ee.r !== void 0 && (P = null);
|
|
1363
1363
|
else s(l(P)) && (P = null);
|
|
1364
|
-
const fe =
|
|
1364
|
+
const fe = L.getComponent();
|
|
1365
1365
|
if (fe) {
|
|
1366
1366
|
let T;
|
|
1367
1367
|
if ((T = fe.d) != null) {
|
|
1368
|
-
const
|
|
1369
|
-
|
|
1368
|
+
const G = te[T];
|
|
1369
|
+
G && (G.get(), A.mergeTree(G.get()), P = r.readCursor(G.get()));
|
|
1370
1370
|
}
|
|
1371
1371
|
}
|
|
1372
1372
|
let de = 0, ae = 0;
|
|
1373
|
-
const
|
|
1374
|
-
_(
|
|
1375
|
-
}), H = r.advancer(P, (T,
|
|
1376
|
-
s(
|
|
1373
|
+
const ve = r.advancer(k, void 0, (T, G) => {
|
|
1374
|
+
_(G) && de--;
|
|
1375
|
+
}), H = r.advancer(P, (T, G) => s(G) ? -(T - ae) - 1 : T - ae, (T, G) => {
|
|
1376
|
+
s(G) && ae++;
|
|
1377
1377
|
});
|
|
1378
|
-
for (const T of
|
|
1379
|
-
const
|
|
1380
|
-
|
|
1381
|
-
} else
|
|
1382
|
-
|
|
1378
|
+
for (const T of L) if (typeof T == "number") {
|
|
1379
|
+
const G = ve(T), he = T + de, we = H(he), Be = he + ae;
|
|
1380
|
+
A.descend(Be), S(L, G, we, A), A.ascend();
|
|
1381
|
+
} else A.descend(T), S(L, ve(T), H(T), A), A.ascend();
|
|
1382
|
+
ve.end(), H.end();
|
|
1383
1383
|
})(ye, Q, Q.clone(), oe), oe.reset(), O) return {
|
|
1384
1384
|
ok: !1,
|
|
1385
1385
|
conflict: O
|
|
1386
1386
|
};
|
|
1387
1387
|
if (oe.get(), xe.length) {
|
|
1388
|
-
const
|
|
1389
|
-
if (Te(
|
|
1390
|
-
const J =
|
|
1391
|
-
J && (
|
|
1392
|
-
}),
|
|
1393
|
-
const
|
|
1394
|
-
let
|
|
1395
|
-
|
|
1388
|
+
const S = xe.map((k) => k ? k.get() : null), L = r.readCursor(it(oe.get()));
|
|
1389
|
+
if (Te(L, oe, (k, P, A) => {
|
|
1390
|
+
const J = S[k];
|
|
1391
|
+
J && (A.mergeTree(J), S[k] = null);
|
|
1392
|
+
}), S.find((k) => k)) {
|
|
1393
|
+
const k = r.writeCursor(), P = r.writeCursor();
|
|
1394
|
+
let A = 0, J = 0;
|
|
1395
|
+
S.forEach((X) => {
|
|
1396
1396
|
X != null && Te(r.readCursor(X), null, (ee) => {
|
|
1397
|
-
const fe =
|
|
1398
|
-
|
|
1397
|
+
const fe = $e[ee];
|
|
1398
|
+
k.writeMove(C[fe].getPath(), x[fe].getPath(), A++);
|
|
1399
1399
|
const de = se[fe];
|
|
1400
1400
|
de && de.forEach((ae) => {
|
|
1401
|
-
g[ae] || D !== 1 &&
|
|
1401
|
+
g[ae] || D !== 1 && K[ae] != null || P.writeMove(N[ae].getPath(), p[ae].getPath(), J++);
|
|
1402
1402
|
});
|
|
1403
1403
|
});
|
|
1404
1404
|
}), O = {
|
|
1405
1405
|
type: u.ConflictType.BLACKHOLE,
|
|
1406
|
-
op1:
|
|
1406
|
+
op1: k.get(),
|
|
1407
1407
|
op2: P.get()
|
|
1408
1408
|
};
|
|
1409
1409
|
}
|
|
@@ -1421,49 +1421,49 @@ function on() {
|
|
|
1421
1421
|
const d = new Error("Transform detected write conflict");
|
|
1422
1422
|
throw d.conflict = i, d.type = d.name = "writeConflict", d;
|
|
1423
1423
|
};
|
|
1424
|
-
function jt(i, d,
|
|
1425
|
-
const D = st(i, d,
|
|
1424
|
+
function jt(i, d, v) {
|
|
1425
|
+
const D = st(i, d, v);
|
|
1426
1426
|
if (D.ok) return D.result;
|
|
1427
1427
|
gt(D.conflict);
|
|
1428
1428
|
}
|
|
1429
1429
|
const ze = (i) => {
|
|
1430
1430
|
const d = r.writeCursor();
|
|
1431
|
-
return r.readCursor(i).traverse(d, (
|
|
1432
|
-
(s(
|
|
1431
|
+
return r.readCursor(i).traverse(d, (v, D) => {
|
|
1432
|
+
(s(v) || me(v)) && D.write("r", !0);
|
|
1433
1433
|
}), d.get();
|
|
1434
1434
|
}, Nt = (i, d) => {
|
|
1435
|
-
const { type:
|
|
1436
|
-
switch (
|
|
1435
|
+
const { type: v, op1: D, op2: O } = i;
|
|
1436
|
+
switch (v) {
|
|
1437
1437
|
case u.ConflictType.DROP_COLLISION:
|
|
1438
1438
|
return d === "left" ? [null, ze(O)] : [ze(D), null];
|
|
1439
1439
|
case u.ConflictType.RM_UNEXPECTED_CONTENT:
|
|
1440
|
-
let
|
|
1440
|
+
let C = !1;
|
|
1441
1441
|
return r.readCursor(D).traverse(null, (x) => {
|
|
1442
|
-
x.r !== void 0 && (
|
|
1443
|
-
}),
|
|
1442
|
+
x.r !== void 0 && (C = !0);
|
|
1443
|
+
}), C ? [null, ze(O)] : [ze(D), null];
|
|
1444
1444
|
case u.ConflictType.BLACKHOLE:
|
|
1445
1445
|
return [ze(D), ze(O)];
|
|
1446
1446
|
default:
|
|
1447
|
-
throw Error("Unrecognised conflict: " +
|
|
1447
|
+
throw Error("Unrecognised conflict: " + v);
|
|
1448
1448
|
}
|
|
1449
1449
|
};
|
|
1450
|
-
function yt(i, d,
|
|
1450
|
+
function yt(i, d, v, D) {
|
|
1451
1451
|
let O = null;
|
|
1452
1452
|
for (; ; ) {
|
|
1453
|
-
const
|
|
1454
|
-
if (
|
|
1453
|
+
const C = st(d, v, D);
|
|
1454
|
+
if (C.ok) return ne(O, C.result);
|
|
1455
1455
|
{
|
|
1456
|
-
const { conflict: x } =
|
|
1456
|
+
const { conflict: x } = C;
|
|
1457
1457
|
i(x) || gt(x);
|
|
1458
1458
|
const [N, p] = Nt(x, D);
|
|
1459
|
-
d = ne(
|
|
1459
|
+
d = ne($(d), N), v = ne($(v), p), O = ne(O, p);
|
|
1460
1460
|
}
|
|
1461
1461
|
}
|
|
1462
1462
|
}
|
|
1463
1463
|
})(Ze)), Ze;
|
|
1464
1464
|
}
|
|
1465
1465
|
var Tt;
|
|
1466
|
-
function
|
|
1466
|
+
function cn() {
|
|
1467
1467
|
return Tt || (Tt = 1, (function(a) {
|
|
1468
1468
|
var e = Ve && Ve.__createBinding || (Object.create ? (function(u, o, l, E) {
|
|
1469
1469
|
E === void 0 && (E = l), Object.defineProperty(u, E, { enumerable: !0, get: function() {
|
|
@@ -1471,24 +1471,24 @@ function an() {
|
|
|
1471
1471
|
} });
|
|
1472
1472
|
}) : (function(u, o, l, E) {
|
|
1473
1473
|
E === void 0 && (E = l), u[E] = o[l];
|
|
1474
|
-
})),
|
|
1474
|
+
})), t = Ve && Ve.__exportStar || function(u, o) {
|
|
1475
1475
|
for (var l in u) l !== "default" && !o.hasOwnProperty(l) && e(o, u, l);
|
|
1476
1476
|
};
|
|
1477
|
-
Object.defineProperty(a, "__esModule", { value: !0 }),
|
|
1478
|
-
var
|
|
1477
|
+
Object.defineProperty(a, "__esModule", { value: !0 }), t(un(), a);
|
|
1478
|
+
var n = Ut();
|
|
1479
1479
|
Object.defineProperty(a, "ReadCursor", { enumerable: !0, get: function() {
|
|
1480
|
-
return
|
|
1480
|
+
return n.ReadCursor;
|
|
1481
1481
|
} }), Object.defineProperty(a, "WriteCursor", { enumerable: !0, get: function() {
|
|
1482
|
-
return
|
|
1482
|
+
return n.WriteCursor;
|
|
1483
1483
|
} });
|
|
1484
|
-
var r =
|
|
1484
|
+
var r = At();
|
|
1485
1485
|
Object.defineProperty(a, "ConflictType", { enumerable: !0, get: function() {
|
|
1486
1486
|
return r.ConflictType;
|
|
1487
1487
|
} });
|
|
1488
1488
|
})(Ve)), Ve;
|
|
1489
1489
|
}
|
|
1490
|
-
var V =
|
|
1491
|
-
class
|
|
1490
|
+
var V = cn();
|
|
1491
|
+
class dn {
|
|
1492
1492
|
constructor() {
|
|
1493
1493
|
F(this, "drawingManagerData", {});
|
|
1494
1494
|
F(this, "_oldDrawingManagerData", {});
|
|
@@ -1535,74 +1535,74 @@ class ln {
|
|
|
1535
1535
|
this._visible$.next(e);
|
|
1536
1536
|
}
|
|
1537
1537
|
refreshTransform(e) {
|
|
1538
|
-
e.forEach((
|
|
1539
|
-
const
|
|
1540
|
-
|
|
1538
|
+
e.forEach((t) => {
|
|
1539
|
+
const n = this._getCurrentBySearch(t);
|
|
1540
|
+
n != null && (n.transform = t.transform, n.transforms = t.transforms, n.isMultiTransform = t.isMultiTransform);
|
|
1541
1541
|
}), this.refreshTransformNotification(e);
|
|
1542
1542
|
}
|
|
1543
1543
|
getDrawingDataForUnit(e) {
|
|
1544
1544
|
return this.drawingManagerData[e] || {};
|
|
1545
1545
|
}
|
|
1546
1546
|
removeDrawingDataForUnit(e) {
|
|
1547
|
-
const
|
|
1548
|
-
if (
|
|
1547
|
+
const t = this.drawingManagerData[e];
|
|
1548
|
+
if (t == null)
|
|
1549
1549
|
return;
|
|
1550
1550
|
delete this.drawingManagerData[e];
|
|
1551
|
-
const
|
|
1552
|
-
Object.keys(
|
|
1553
|
-
const u =
|
|
1551
|
+
const n = [];
|
|
1552
|
+
Object.keys(t).forEach((r) => {
|
|
1553
|
+
const u = t[r];
|
|
1554
1554
|
(u == null ? void 0 : u.data) != null && Object.keys(u.data).forEach((o) => {
|
|
1555
|
-
|
|
1555
|
+
n.push({ unitId: e, subUnitId: r, drawingId: o });
|
|
1556
1556
|
});
|
|
1557
|
-
}),
|
|
1557
|
+
}), n.length > 0 && this.removeNotification(n);
|
|
1558
1558
|
}
|
|
1559
|
-
registerDrawingData(e,
|
|
1560
|
-
this.drawingManagerData[e] =
|
|
1559
|
+
registerDrawingData(e, t) {
|
|
1560
|
+
this.drawingManagerData[e] = t;
|
|
1561
1561
|
}
|
|
1562
1562
|
initializeNotification(e) {
|
|
1563
|
-
const
|
|
1564
|
-
|
|
1563
|
+
const t = [], n = this.drawingManagerData[e];
|
|
1564
|
+
n != null && (Object.keys(n).forEach((r) => {
|
|
1565
1565
|
this._establishDrawingMap(e, r);
|
|
1566
|
-
const u =
|
|
1566
|
+
const u = n[r];
|
|
1567
1567
|
Object.keys(u.data).forEach((o) => {
|
|
1568
1568
|
const l = u.data[o];
|
|
1569
|
-
l.unitId = e, l.subUnitId = r,
|
|
1569
|
+
l.unitId = e, l.subUnitId = r, t.push(l);
|
|
1570
1570
|
});
|
|
1571
|
-
}),
|
|
1571
|
+
}), t.length > 0 && this.addNotification(t));
|
|
1572
1572
|
}
|
|
1573
|
-
getDrawingData(e,
|
|
1574
|
-
return this._getDrawingData(e,
|
|
1573
|
+
getDrawingData(e, t) {
|
|
1574
|
+
return this._getDrawingData(e, t);
|
|
1575
1575
|
}
|
|
1576
1576
|
// Use in doc only.
|
|
1577
|
-
setDrawingData(e,
|
|
1578
|
-
this.drawingManagerData[e][
|
|
1577
|
+
setDrawingData(e, t, n) {
|
|
1578
|
+
this.drawingManagerData[e][t].data = n;
|
|
1579
1579
|
}
|
|
1580
1580
|
getBatchAddOp(e) {
|
|
1581
|
-
const
|
|
1581
|
+
const t = [], n = [], r = [];
|
|
1582
1582
|
e.forEach((B) => {
|
|
1583
1583
|
const { op: _, invertOp: s } = this._addByParam(B);
|
|
1584
|
-
|
|
1584
|
+
t.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), n.push(_), r.push(s);
|
|
1585
1585
|
});
|
|
1586
|
-
const u =
|
|
1587
|
-
return { undo: o, redo: u, unitId: l, subUnitId: E, objects:
|
|
1586
|
+
const u = n.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
|
|
1587
|
+
return { undo: o, redo: u, unitId: l, subUnitId: E, objects: t };
|
|
1588
1588
|
}
|
|
1589
1589
|
getBatchRemoveOp(e) {
|
|
1590
|
-
const
|
|
1590
|
+
const t = [], n = [];
|
|
1591
1591
|
e.forEach((E) => {
|
|
1592
1592
|
const { op: B, invertOp: _ } = this._removeByParam(E);
|
|
1593
|
-
|
|
1593
|
+
t.unshift(B), n.push(_);
|
|
1594
1594
|
});
|
|
1595
|
-
const r =
|
|
1595
|
+
const r = t.reduce(V.type.compose, null), u = n.reduce(V.type.compose, null), { unitId: o, subUnitId: l } = e[0];
|
|
1596
1596
|
return { undo: u, redo: r, unitId: o, subUnitId: l, objects: e };
|
|
1597
1597
|
}
|
|
1598
1598
|
getBatchUpdateOp(e) {
|
|
1599
|
-
const
|
|
1599
|
+
const t = [], n = [], r = [];
|
|
1600
1600
|
e.forEach((B) => {
|
|
1601
1601
|
const { op: _, invertOp: s } = this._updateByParam(B);
|
|
1602
|
-
|
|
1602
|
+
t.push({ unitId: B.unitId, subUnitId: B.subUnitId, drawingId: B.drawingId }), n.push(_), r.push(s);
|
|
1603
1603
|
});
|
|
1604
|
-
const u =
|
|
1605
|
-
return { undo: o, redo: u, unitId: l, subUnitId: E, objects:
|
|
1604
|
+
const u = n.reduce(V.type.compose, null), o = r.reduce(V.type.compose, null), { unitId: l, subUnitId: E } = e[0];
|
|
1605
|
+
return { undo: o, redo: u, unitId: l, subUnitId: E, objects: t };
|
|
1606
1606
|
}
|
|
1607
1607
|
removeNotification(e) {
|
|
1608
1608
|
this._remove$.next(e);
|
|
@@ -1626,38 +1626,38 @@ class ln {
|
|
|
1626
1626
|
this._refreshTransform$.next(e);
|
|
1627
1627
|
}
|
|
1628
1628
|
getGroupDrawingOp(e) {
|
|
1629
|
-
const
|
|
1629
|
+
const t = [], { unitId: n, subUnitId: r } = e[0].parent;
|
|
1630
1630
|
e.forEach((l) => {
|
|
1631
|
-
|
|
1631
|
+
t.push(this._getGroupDrawingOp(l));
|
|
1632
1632
|
});
|
|
1633
|
-
const u =
|
|
1634
|
-
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId:
|
|
1633
|
+
const u = t.reduce(V.type.compose, null);
|
|
1634
|
+
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: n, subUnitId: r, objects: e };
|
|
1635
1635
|
}
|
|
1636
1636
|
getUngroupDrawingOp(e) {
|
|
1637
|
-
const
|
|
1637
|
+
const t = [], { unitId: n, subUnitId: r } = e[0].parent;
|
|
1638
1638
|
e.forEach((l) => {
|
|
1639
|
-
|
|
1639
|
+
t.push(this._getUngroupDrawingOp(l));
|
|
1640
1640
|
});
|
|
1641
|
-
const u =
|
|
1642
|
-
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId:
|
|
1641
|
+
const u = t.reduce(V.type.compose, null);
|
|
1642
|
+
return { undo: V.type.invertWithDoc(u, this.drawingManagerData), redo: u, unitId: n, subUnitId: r, objects: e };
|
|
1643
1643
|
}
|
|
1644
1644
|
getDrawingsByGroup(e) {
|
|
1645
|
-
const { unitId:
|
|
1646
|
-
if (this.getDrawingByParam({ unitId:
|
|
1645
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1646
|
+
if (this.getDrawingByParam({ unitId: t, subUnitId: n, drawingId: r }) == null)
|
|
1647
1647
|
return [];
|
|
1648
|
-
const o = this._getDrawingData(
|
|
1648
|
+
const o = this._getDrawingData(t, n), l = [];
|
|
1649
1649
|
return Object.keys(o).forEach((E) => {
|
|
1650
1650
|
const B = o[E];
|
|
1651
1651
|
B.groupId === r && l.push(B);
|
|
1652
1652
|
}), l;
|
|
1653
1653
|
}
|
|
1654
1654
|
_getGroupDrawingOp(e) {
|
|
1655
|
-
const { parent:
|
|
1655
|
+
const { parent: t, children: n } = e, { unitId: r, subUnitId: u, drawingId: o } = t, l = [];
|
|
1656
1656
|
l.push(
|
|
1657
|
-
V.insertOp([r, u, "data", o],
|
|
1657
|
+
V.insertOp([r, u, "data", o], t)
|
|
1658
1658
|
);
|
|
1659
1659
|
let E = Number.NEGATIVE_INFINITY;
|
|
1660
|
-
return
|
|
1660
|
+
return n.forEach((B) => {
|
|
1661
1661
|
const { unitId: _, subUnitId: s, drawingId: c } = B, h = this._hasDrawingOrder({ unitId: _, subUnitId: s, drawingId: c });
|
|
1662
1662
|
E = Math.max(E, h), l.push(
|
|
1663
1663
|
...this._getUpdateParamCompareOp(B, this.getDrawingByParam({ unitId: _, subUnitId: s, drawingId: c }))
|
|
@@ -1667,8 +1667,8 @@ class ln {
|
|
|
1667
1667
|
), l.reduce(V.type.compose, null);
|
|
1668
1668
|
}
|
|
1669
1669
|
_getUngroupDrawingOp(e) {
|
|
1670
|
-
const { parent:
|
|
1671
|
-
return
|
|
1670
|
+
const { parent: t, children: n } = e, { unitId: r, subUnitId: u, drawingId: o } = t, l = [];
|
|
1671
|
+
return n.forEach((E) => {
|
|
1672
1672
|
const { unitId: B, subUnitId: _, drawingId: s } = E;
|
|
1673
1673
|
l.push(
|
|
1674
1674
|
...this._getUpdateParamCompareOp(E, this.getDrawingByParam({ unitId: B, subUnitId: _, drawingId: s }))
|
|
@@ -1679,8 +1679,8 @@ class ln {
|
|
|
1679
1679
|
V.removeOp([r, u, "order", this._getDrawingOrder(r, u).indexOf(o)], !0)
|
|
1680
1680
|
), l.reduce(V.type.compose, null);
|
|
1681
1681
|
}
|
|
1682
|
-
applyJson1(e,
|
|
1683
|
-
this._establishDrawingMap(e,
|
|
1682
|
+
applyJson1(e, t, n) {
|
|
1683
|
+
this._establishDrawingMap(e, t), this._oldDrawingManagerData = { ...this.drawingManagerData }, this.drawingManagerData = V.type.apply(this.drawingManagerData, n);
|
|
1684
1684
|
}
|
|
1685
1685
|
// private _fillMissingFields(jsonOp: JSONOp) {
|
|
1686
1686
|
// if (jsonOp == null) {
|
|
@@ -1727,134 +1727,134 @@ class ln {
|
|
|
1727
1727
|
return this._getOldBySearch(e);
|
|
1728
1728
|
}
|
|
1729
1729
|
getDrawingOKey(e) {
|
|
1730
|
-
const [
|
|
1731
|
-
return this._getCurrentBySearch({ unitId:
|
|
1730
|
+
const [t, n, r] = e.split("#-#");
|
|
1731
|
+
return this._getCurrentBySearch({ unitId: t, subUnitId: n, drawingId: r });
|
|
1732
1732
|
}
|
|
1733
1733
|
focusDrawing(e) {
|
|
1734
1734
|
if (e == null || e.length === 0) {
|
|
1735
1735
|
this._focusDrawings = [], this._focus$.next([]);
|
|
1736
1736
|
return;
|
|
1737
1737
|
}
|
|
1738
|
-
const
|
|
1739
|
-
e.forEach((
|
|
1738
|
+
const t = [];
|
|
1739
|
+
e.forEach((n) => {
|
|
1740
1740
|
var E;
|
|
1741
|
-
const { unitId: r, subUnitId: u, drawingId: o } =
|
|
1742
|
-
l != null &&
|
|
1743
|
-
}),
|
|
1741
|
+
const { unitId: r, subUnitId: u, drawingId: o } = n, l = (E = this._getDrawingData(r, u)) == null ? void 0 : E[o];
|
|
1742
|
+
l != null && t.push(l);
|
|
1743
|
+
}), t.length > 0 && (this._focusDrawings = t, this._focus$.next(t));
|
|
1744
1744
|
}
|
|
1745
1745
|
getFocusDrawings() {
|
|
1746
1746
|
const e = [];
|
|
1747
|
-
return this._focusDrawings.forEach((
|
|
1747
|
+
return this._focusDrawings.forEach((t) => {
|
|
1748
1748
|
var l;
|
|
1749
|
-
const { unitId:
|
|
1749
|
+
const { unitId: n, subUnitId: r, drawingId: u } = t, o = (l = this._getDrawingData(n, r)) == null ? void 0 : l[u];
|
|
1750
1750
|
o != null && e.push(o);
|
|
1751
1751
|
}), e;
|
|
1752
1752
|
}
|
|
1753
|
-
getDrawingOrder(e,
|
|
1754
|
-
return this._getDrawingOrder(e,
|
|
1753
|
+
getDrawingOrder(e, t) {
|
|
1754
|
+
return this._getDrawingOrder(e, t);
|
|
1755
1755
|
}
|
|
1756
1756
|
// Use in doc only.
|
|
1757
|
-
setDrawingOrder(e,
|
|
1758
|
-
this.drawingManagerData[e][
|
|
1757
|
+
setDrawingOrder(e, t, n) {
|
|
1758
|
+
this.drawingManagerData[e][t].order = n;
|
|
1759
1759
|
}
|
|
1760
1760
|
orderUpdateNotification(e) {
|
|
1761
1761
|
this._order$.next(e);
|
|
1762
1762
|
}
|
|
1763
1763
|
getForwardDrawingsOp(e) {
|
|
1764
|
-
const { unitId:
|
|
1764
|
+
const { unitId: t, subUnitId: n, drawingIds: r } = e, u = [], o = this.getDrawingOrder(t, n), l = [...r];
|
|
1765
1765
|
r.forEach((_) => {
|
|
1766
|
-
const s = this._hasDrawingOrder({ unitId:
|
|
1766
|
+
const s = this._hasDrawingOrder({ unitId: t, subUnitId: n, drawingId: _ });
|
|
1767
1767
|
if (s === -1 || s === o.length - 1)
|
|
1768
1768
|
return;
|
|
1769
|
-
const c = V.moveOp([
|
|
1769
|
+
const c = V.moveOp([t, n, "order", s], [t, n, "order", s + 1]);
|
|
1770
1770
|
u.push(c), l.includes(o[s + 1]) || l.push(o[s + 1]);
|
|
1771
1771
|
});
|
|
1772
1772
|
const E = u.reduce(V.type.compose, null);
|
|
1773
|
-
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId:
|
|
1773
|
+
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: n, objects: { ...e, drawingIds: l } };
|
|
1774
1774
|
}
|
|
1775
1775
|
getBackwardDrawingOp(e) {
|
|
1776
|
-
const { unitId:
|
|
1776
|
+
const { unitId: t, subUnitId: n, drawingIds: r } = e, u = [], o = this.getDrawingOrder(t, n), l = [...r];
|
|
1777
1777
|
r.forEach((_) => {
|
|
1778
|
-
const s = this._hasDrawingOrder({ unitId:
|
|
1778
|
+
const s = this._hasDrawingOrder({ unitId: t, subUnitId: n, drawingId: _ });
|
|
1779
1779
|
if (s === -1 || s === 0)
|
|
1780
1780
|
return;
|
|
1781
|
-
const c = V.moveOp([
|
|
1781
|
+
const c = V.moveOp([t, n, "order", s], [t, n, "order", s - 1]);
|
|
1782
1782
|
u.push(c), l.includes(o[s - 1]) || l.push(o[s - 1]);
|
|
1783
1783
|
});
|
|
1784
1784
|
const E = u.reduce(V.type.compose, null);
|
|
1785
|
-
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId:
|
|
1785
|
+
return { undo: V.type.invertWithDoc(E, this.drawingManagerData), redo: E, unitId: t, subUnitId: n, objects: { ...e, drawingIds: l } };
|
|
1786
1786
|
}
|
|
1787
1787
|
getFrontDrawingsOp(e) {
|
|
1788
|
-
const { unitId:
|
|
1788
|
+
const { unitId: t, subUnitId: n, drawingIds: r } = e, u = this._getOrderFromSearchParams(t, n, r), o = [...r], l = this.getDrawingOrder(t, n), E = [];
|
|
1789
1789
|
u.forEach((s) => {
|
|
1790
|
-
const { drawingId: c } = s, h = this._getDrawingCount(
|
|
1791
|
-
E.push(
|
|
1790
|
+
const { drawingId: c } = s, h = this._getDrawingCount(t, n) - 1, M = V.moveOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(c)], [t, n, "order", h]);
|
|
1791
|
+
E.push(M), o.includes(l[h]) || o.push(l[h]);
|
|
1792
1792
|
});
|
|
1793
1793
|
const B = E.reduce(V.type.compose, null);
|
|
1794
|
-
return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId:
|
|
1794
|
+
return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: t, subUnitId: n, objects: { ...e, drawingIds: o } };
|
|
1795
1795
|
}
|
|
1796
1796
|
getBackDrawingsOp(e) {
|
|
1797
|
-
const { unitId:
|
|
1797
|
+
const { unitId: t, subUnitId: n, drawingIds: r } = e, u = this._getOrderFromSearchParams(t, n, r, !0), o = [...r], l = this.getDrawingOrder(t, n), E = [];
|
|
1798
1798
|
u.forEach((s) => {
|
|
1799
|
-
const { drawingId: c } = s, h = V.moveOp([
|
|
1799
|
+
const { drawingId: c } = s, h = V.moveOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(c)], [t, n, "order", 0]);
|
|
1800
1800
|
E.push(h), o.includes(l[0]) || o.push(l[0]);
|
|
1801
1801
|
});
|
|
1802
1802
|
const B = E.reduce(V.type.compose, null);
|
|
1803
|
-
return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId:
|
|
1803
|
+
return { undo: V.type.invertWithDoc(B, this.drawingManagerData), redo: B, unitId: t, subUnitId: n, objects: { ...e, drawingIds: o } };
|
|
1804
1804
|
}
|
|
1805
|
-
_getDrawingCount(e,
|
|
1806
|
-
return this.getDrawingOrder(e,
|
|
1805
|
+
_getDrawingCount(e, t) {
|
|
1806
|
+
return this.getDrawingOrder(e, t).length || 0;
|
|
1807
1807
|
}
|
|
1808
|
-
_getOrderFromSearchParams(e,
|
|
1809
|
-
return
|
|
1810
|
-
const o = this._hasDrawingOrder({ unitId: e, subUnitId:
|
|
1808
|
+
_getOrderFromSearchParams(e, t, n, r = !1) {
|
|
1809
|
+
return n.map((u) => {
|
|
1810
|
+
const o = this._hasDrawingOrder({ unitId: e, subUnitId: t, drawingId: u });
|
|
1811
1811
|
return { drawingId: u, zIndex: o };
|
|
1812
|
-
}).sort(r === !1 ?
|
|
1812
|
+
}).sort(r === !1 ? Lt : Gt);
|
|
1813
1813
|
}
|
|
1814
1814
|
_hasDrawingOrder(e) {
|
|
1815
1815
|
if (e == null)
|
|
1816
1816
|
return -1;
|
|
1817
|
-
const { unitId:
|
|
1818
|
-
return this._establishDrawingMap(
|
|
1817
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1818
|
+
return this._establishDrawingMap(t, n), this._getDrawingOrder(t, n).indexOf(r);
|
|
1819
1819
|
}
|
|
1820
1820
|
_getCurrentBySearch(e) {
|
|
1821
1821
|
var u, o, l;
|
|
1822
1822
|
if (e == null)
|
|
1823
1823
|
return;
|
|
1824
|
-
const { unitId:
|
|
1825
|
-
return (l = (o = (u = this.drawingManagerData[
|
|
1824
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1825
|
+
return (l = (o = (u = this.drawingManagerData[t]) == null ? void 0 : u[n]) == null ? void 0 : o.data) == null ? void 0 : l[r];
|
|
1826
1826
|
}
|
|
1827
1827
|
_getOldBySearch(e) {
|
|
1828
1828
|
var u, o, l;
|
|
1829
1829
|
if (e == null)
|
|
1830
1830
|
return;
|
|
1831
|
-
const { unitId:
|
|
1832
|
-
return (l = (o = (u = this._oldDrawingManagerData[
|
|
1831
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1832
|
+
return (l = (o = (u = this._oldDrawingManagerData[t]) == null ? void 0 : u[n]) == null ? void 0 : o.data) == null ? void 0 : l[r];
|
|
1833
1833
|
}
|
|
1834
|
-
_establishDrawingMap(e,
|
|
1834
|
+
_establishDrawingMap(e, t, n) {
|
|
1835
1835
|
var r;
|
|
1836
|
-
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][
|
|
1836
|
+
return this.drawingManagerData[e] || (this.drawingManagerData[e] = {}), this.drawingManagerData[e][t] || (this.drawingManagerData[e][t] = {
|
|
1837
1837
|
data: {},
|
|
1838
1838
|
order: []
|
|
1839
|
-
}),
|
|
1839
|
+
}), n == null ? null : (r = this.drawingManagerData[e][t].data) == null ? void 0 : r[n];
|
|
1840
1840
|
}
|
|
1841
1841
|
_addByParam(e) {
|
|
1842
|
-
const { unitId:
|
|
1843
|
-
this._establishDrawingMap(
|
|
1844
|
-
const u = V.insertOp([
|
|
1842
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1843
|
+
this._establishDrawingMap(t, n, r);
|
|
1844
|
+
const u = V.insertOp([t, n, "data", r], e), o = V.insertOp([t, n, "order", this._getDrawingOrder(t, n).length], r), l = [u, o].reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
|
|
1845
1845
|
return { op: l, invertOp: E };
|
|
1846
1846
|
}
|
|
1847
1847
|
_removeByParam(e) {
|
|
1848
1848
|
if (e == null)
|
|
1849
1849
|
return { op: [], invertOp: [] };
|
|
1850
|
-
const { unitId:
|
|
1851
|
-
if (this._establishDrawingMap(
|
|
1850
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e;
|
|
1851
|
+
if (this._establishDrawingMap(t, n, r) == null)
|
|
1852
1852
|
return { op: [], invertOp: [] };
|
|
1853
|
-
const o = V.removeOp([
|
|
1853
|
+
const o = V.removeOp([t, n, "data", r], !0), l = V.removeOp([t, n, "order", this._getDrawingOrder(t, n).indexOf(r)], !0), E = [o, l].reduce(V.type.compose, null), B = V.type.invertWithDoc(E, this.drawingManagerData);
|
|
1854
1854
|
return { op: E, invertOp: B };
|
|
1855
1855
|
}
|
|
1856
1856
|
_updateByParam(e) {
|
|
1857
|
-
const { unitId:
|
|
1857
|
+
const { unitId: t, subUnitId: n, drawingId: r } = e, u = this._establishDrawingMap(t, n, r);
|
|
1858
1858
|
if (u == null)
|
|
1859
1859
|
return { op: [], invertOp: [] };
|
|
1860
1860
|
const l = this._getUpdateParamCompareOp(e, u).reduce(V.type.compose, null), E = V.type.invertWithDoc(l, this.drawingManagerData);
|
|
@@ -1867,22 +1867,22 @@ class ln {
|
|
|
1867
1867
|
// }
|
|
1868
1868
|
// });
|
|
1869
1869
|
// }
|
|
1870
|
-
_getUpdateParamCompareOp(e,
|
|
1871
|
-
const { unitId:
|
|
1870
|
+
_getUpdateParamCompareOp(e, t) {
|
|
1871
|
+
const { unitId: n, subUnitId: r, drawingId: u } = e, o = [];
|
|
1872
1872
|
return Object.keys(e).forEach((l) => {
|
|
1873
|
-
const E = e[l], B =
|
|
1873
|
+
const E = e[l], B = t[l];
|
|
1874
1874
|
B !== E && o.push(
|
|
1875
|
-
V.replaceOp([
|
|
1875
|
+
V.replaceOp([n, r, "data", u, l], B, E)
|
|
1876
1876
|
);
|
|
1877
1877
|
}), o;
|
|
1878
1878
|
}
|
|
1879
|
-
_getDrawingData(e,
|
|
1880
|
-
var
|
|
1881
|
-
return ((r = (
|
|
1879
|
+
_getDrawingData(e, t) {
|
|
1880
|
+
var n, r;
|
|
1881
|
+
return ((r = (n = this.drawingManagerData[e]) == null ? void 0 : n[t]) == null ? void 0 : r.data) || {};
|
|
1882
1882
|
}
|
|
1883
|
-
_getDrawingOrder(e,
|
|
1884
|
-
var
|
|
1885
|
-
return ((r = (
|
|
1883
|
+
_getDrawingOrder(e, t) {
|
|
1884
|
+
var n, r;
|
|
1885
|
+
return ((r = (n = this.drawingManagerData[e]) == null ? void 0 : n[t]) == null ? void 0 : r.order) || [];
|
|
1886
1886
|
}
|
|
1887
1887
|
getDrawingVisible() {
|
|
1888
1888
|
return this._visible;
|
|
@@ -1897,9 +1897,9 @@ class ln {
|
|
|
1897
1897
|
this._editable = e;
|
|
1898
1898
|
}
|
|
1899
1899
|
}
|
|
1900
|
-
class
|
|
1900
|
+
class fn extends dn {
|
|
1901
1901
|
}
|
|
1902
|
-
class
|
|
1902
|
+
class hn {
|
|
1903
1903
|
constructor() {
|
|
1904
1904
|
F(this, "_waitCount", 0);
|
|
1905
1905
|
F(this, "_change$", new be());
|
|
@@ -1909,27 +1909,27 @@ class cn {
|
|
|
1909
1909
|
setWaitCount(e) {
|
|
1910
1910
|
this._waitCount = e, this._change$.next(e);
|
|
1911
1911
|
}
|
|
1912
|
-
getImageSourceCache(e,
|
|
1913
|
-
if (
|
|
1914
|
-
const
|
|
1915
|
-
return
|
|
1912
|
+
getImageSourceCache(e, t) {
|
|
1913
|
+
if (t === at.BASE64) {
|
|
1914
|
+
const n = new Image();
|
|
1915
|
+
return n.src = e, n;
|
|
1916
1916
|
}
|
|
1917
1917
|
return this._imageSourceCache.get(e);
|
|
1918
1918
|
}
|
|
1919
|
-
addImageSourceCache(e,
|
|
1920
|
-
|
|
1919
|
+
addImageSourceCache(e, t, n) {
|
|
1920
|
+
t === at.BASE64 || n == null || this._imageSourceCache.set(e, n);
|
|
1921
1921
|
}
|
|
1922
1922
|
async getImage(e) {
|
|
1923
1923
|
return Promise.resolve(e);
|
|
1924
1924
|
}
|
|
1925
1925
|
async saveImage(e) {
|
|
1926
|
-
return new Promise((
|
|
1927
|
-
if (!
|
|
1928
|
-
|
|
1926
|
+
return new Promise((t, n) => {
|
|
1927
|
+
if (!tn.includes(e.type)) {
|
|
1928
|
+
n(new Error(et.ERROR_IMAGE_TYPE)), this._decreaseWaiting();
|
|
1929
1929
|
return;
|
|
1930
1930
|
}
|
|
1931
|
-
if (e.size >
|
|
1932
|
-
|
|
1931
|
+
if (e.size > en) {
|
|
1932
|
+
n(new Error(et.ERROR_EXCEED_SIZE)), this._decreaseWaiting();
|
|
1933
1933
|
return;
|
|
1934
1934
|
}
|
|
1935
1935
|
const r = new FileReader();
|
|
@@ -1937,11 +1937,11 @@ class cn {
|
|
|
1937
1937
|
var E;
|
|
1938
1938
|
const o = (E = u.target) == null ? void 0 : E.result;
|
|
1939
1939
|
if (o == null) {
|
|
1940
|
-
|
|
1940
|
+
n(new Error(et.ERROR_IMAGE)), this._decreaseWaiting();
|
|
1941
1941
|
return;
|
|
1942
1942
|
}
|
|
1943
1943
|
const l = qt(6);
|
|
1944
|
-
|
|
1944
|
+
t({
|
|
1945
1945
|
imageId: l,
|
|
1946
1946
|
imageSourceType: at.BASE64,
|
|
1947
1947
|
source: o,
|
|
@@ -1955,74 +1955,106 @@ class cn {
|
|
|
1955
1955
|
this._waitCount -= 1, this._change$.next(this._waitCount);
|
|
1956
1956
|
}
|
|
1957
1957
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1958
|
+
class pn extends $t {
|
|
1959
|
+
constructor() {
|
|
1960
|
+
super(...arguments);
|
|
1961
|
+
F(this, "_urlImageDownloader", null);
|
|
1962
|
+
}
|
|
1963
|
+
registerURLImageDownloader(t) {
|
|
1964
|
+
return this._urlImageDownloader = t, Kt(() => {
|
|
1965
|
+
this._urlImageDownloader = null;
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
async getImage(t) {
|
|
1969
|
+
if (this._urlImageDownloader)
|
|
1970
|
+
try {
|
|
1971
|
+
return await this._urlImageDownloader(t);
|
|
1972
|
+
} catch (n) {
|
|
1973
|
+
console.error(`Custom downloader failed for ${t}, falling back to default behavior:`, n);
|
|
1974
|
+
}
|
|
1975
|
+
return t;
|
|
1976
|
+
}
|
|
1977
|
+
async downloadImage(t) {
|
|
1978
|
+
if (this._urlImageDownloader)
|
|
1979
|
+
try {
|
|
1980
|
+
const r = await this._urlImageDownloader(t);
|
|
1981
|
+
return await (await fetch(r)).blob();
|
|
1982
|
+
} catch (r) {
|
|
1983
|
+
console.error(`Custom downloader failed for ${t}, falling back to default fetch:`, r);
|
|
1984
|
+
}
|
|
1985
|
+
return await (await fetch(t)).blob();
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
var gn = Object.getOwnPropertyDescriptor, yn = (a, e, t, n) => {
|
|
1989
|
+
for (var r = n > 1 ? void 0 : n ? gn(e, t) : e, u = a.length - 1, o; u >= 0; u--)
|
|
1960
1990
|
(o = a[u]) && (r = o(r) || r);
|
|
1961
1991
|
return r;
|
|
1962
|
-
}, dt = (a, e) => (
|
|
1963
|
-
const
|
|
1992
|
+
}, dt = (a, e) => (t, n) => e(t, n, a);
|
|
1993
|
+
const _n = "UNIVER_DRAWING_PLUGIN";
|
|
1964
1994
|
var ft;
|
|
1965
|
-
let
|
|
1966
|
-
constructor(a =
|
|
1967
|
-
super(), this._config = a, this._injector = e, this._configService =
|
|
1968
|
-
const { ...r } =
|
|
1995
|
+
let St = (ft = class extends Xt {
|
|
1996
|
+
constructor(a = mt, e, t, n) {
|
|
1997
|
+
super(), this._config = a, this._injector = e, this._configService = t, this._commandService = n;
|
|
1998
|
+
const { ...r } = Jt(
|
|
1969
1999
|
{},
|
|
1970
|
-
|
|
2000
|
+
mt,
|
|
1971
2001
|
this._config
|
|
1972
2002
|
);
|
|
1973
|
-
this._configService.setConfig(
|
|
2003
|
+
this._configService.setConfig(rn, r);
|
|
1974
2004
|
}
|
|
1975
2005
|
onStarting() {
|
|
1976
2006
|
this._initCommands(), this._initDependencies();
|
|
1977
2007
|
}
|
|
1978
2008
|
_initDependencies() {
|
|
1979
|
-
var
|
|
1980
|
-
|
|
1981
|
-
[
|
|
1982
|
-
[
|
|
1983
|
-
|
|
2009
|
+
var t;
|
|
2010
|
+
Yt([
|
|
2011
|
+
[Zt, { useClass: hn }],
|
|
2012
|
+
[Qt, { useClass: pn }],
|
|
2013
|
+
[kt, { useClass: fn }]
|
|
2014
|
+
], (t = this._config) == null ? void 0 : t.override).forEach((n) => this._injector.add(n));
|
|
1984
2015
|
}
|
|
1985
2016
|
_initCommands() {
|
|
1986
2017
|
[
|
|
1987
|
-
|
|
2018
|
+
nn
|
|
1988
2019
|
].forEach((a) => this.disposeWithMe(this._commandService.registerCommand(a)));
|
|
1989
2020
|
}
|
|
1990
|
-
}, F(ft, "pluginName",
|
|
1991
|
-
|
|
1992
|
-
dt(1,
|
|
1993
|
-
dt(2,
|
|
1994
|
-
dt(3,
|
|
1995
|
-
],
|
|
1996
|
-
function
|
|
1997
|
-
return typeof
|
|
2021
|
+
}, F(ft, "pluginName", _n), ft);
|
|
2022
|
+
St = yn([
|
|
2023
|
+
dt(1, Ft(Vt)),
|
|
2024
|
+
dt(2, Ht),
|
|
2025
|
+
dt(3, zt)
|
|
2026
|
+
], St);
|
|
2027
|
+
function Cn({ unitId: a, subUnitId: e, drawingId: t }, n) {
|
|
2028
|
+
return typeof n == "number" ? `${a}#-#${e}#-#${t}#-#${n}` : `${a}#-#${e}#-#${t}`;
|
|
1998
2029
|
}
|
|
1999
|
-
const
|
|
2000
|
-
const
|
|
2001
|
-
|
|
2030
|
+
const En = async (a) => new Promise((e, t) => {
|
|
2031
|
+
const n = new Image();
|
|
2032
|
+
n.src = a, n.onload = () => {
|
|
2002
2033
|
e({
|
|
2003
|
-
width:
|
|
2004
|
-
height:
|
|
2005
|
-
image:
|
|
2034
|
+
width: n.width,
|
|
2035
|
+
height: n.height,
|
|
2036
|
+
image: n
|
|
2006
2037
|
});
|
|
2007
|
-
},
|
|
2008
|
-
|
|
2038
|
+
}, n.onerror = (r) => {
|
|
2039
|
+
t(r);
|
|
2009
2040
|
};
|
|
2010
2041
|
});
|
|
2011
2042
|
export {
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2043
|
+
tn as DRAWING_IMAGE_ALLOW_IMAGE_LIST,
|
|
2044
|
+
en as DRAWING_IMAGE_ALLOW_SIZE,
|
|
2045
|
+
In as DRAWING_IMAGE_COUNT_LIMIT,
|
|
2046
|
+
bn as DRAWING_IMAGE_HEIGHT_LIMIT,
|
|
2047
|
+
wn as DRAWING_IMAGE_WIDTH_LIMIT,
|
|
2048
|
+
fn as DrawingManagerService,
|
|
2049
|
+
kt as IDrawingManagerService,
|
|
2050
|
+
Tn as IImageIoService,
|
|
2051
|
+
hn as ImageIoService,
|
|
2052
|
+
Sn as ImageSourceType,
|
|
2053
|
+
kn as ImageUploadStatusType,
|
|
2054
|
+
nn as SetDrawingSelectedOperation,
|
|
2055
|
+
pn as URLImageService,
|
|
2056
|
+
dn as UnitDrawingService,
|
|
2057
|
+
St as UniverDrawingPlugin,
|
|
2058
|
+
Cn as getDrawingShapeKeyByDrawingSearch,
|
|
2059
|
+
En as getImageSize
|
|
2028
2060
|
};
|