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