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