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