@editora/plugins 1.2.3 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -6
- package/dist/collaboration.cjs.js +8 -8
- package/dist/collaboration.esm.js +685 -660
- package/dist/text-color.cjs.js +1 -1
- package/dist/text-color.esm.js +1 -1
- package/package.json +3 -3
|
@@ -6,17 +6,17 @@ const R = () => /* @__PURE__ */ new Map(), en = (e) => {
|
|
|
6
6
|
}, J = (e, t, n) => {
|
|
7
7
|
let s = e.get(t);
|
|
8
8
|
return s === void 0 && e.set(t, s = n()), s;
|
|
9
|
-
},
|
|
9
|
+
}, gi = (e, t) => {
|
|
10
10
|
const n = [];
|
|
11
11
|
for (const [s, r] of e)
|
|
12
12
|
n.push(t(r, s));
|
|
13
13
|
return n;
|
|
14
|
-
},
|
|
14
|
+
}, pi = (e, t) => {
|
|
15
15
|
for (const [n, s] of e)
|
|
16
16
|
if (t(s, n))
|
|
17
17
|
return !0;
|
|
18
18
|
return !1;
|
|
19
|
-
}, rt = () => /* @__PURE__ */ new Set(), He = (e) => e[e.length - 1],
|
|
19
|
+
}, rt = () => /* @__PURE__ */ new Set(), He = (e) => e[e.length - 1], wi = (e, t) => {
|
|
20
20
|
for (let n = 0; n < t.length; n++)
|
|
21
21
|
e.push(t[n]);
|
|
22
22
|
}, X = Array.from, pn = (e, t) => {
|
|
@@ -29,12 +29,12 @@ const R = () => /* @__PURE__ */ new Map(), en = (e) => {
|
|
|
29
29
|
if (t(e[n], n, e))
|
|
30
30
|
return !0;
|
|
31
31
|
return !1;
|
|
32
|
-
},
|
|
32
|
+
}, mi = (e, t) => {
|
|
33
33
|
const n = new Array(e);
|
|
34
34
|
for (let s = 0; s < e; s++)
|
|
35
35
|
n[s] = t(s, n);
|
|
36
36
|
return n;
|
|
37
|
-
},
|
|
37
|
+
}, xt = Array.isArray;
|
|
38
38
|
class mn {
|
|
39
39
|
constructor() {
|
|
40
40
|
this._observers = R();
|
|
@@ -97,7 +97,7 @@ class mn {
|
|
|
97
97
|
this._observers = R();
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
class
|
|
100
|
+
class yi {
|
|
101
101
|
constructor() {
|
|
102
102
|
this._observers = R();
|
|
103
103
|
}
|
|
@@ -142,7 +142,7 @@ class wi {
|
|
|
142
142
|
this._observers = R();
|
|
143
143
|
}
|
|
144
144
|
}
|
|
145
|
-
const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) => e > t ? e : t,
|
|
145
|
+
const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) => e > t ? e : t, bi = Math.pow, Ms = (e) => e !== 0 ? e < 0 : 1 / e < 0, qn = 1, Qn = 2, ze = 4, Pe = 8, jt = 32, W = 64, $ = 128, Te = 31, nn = 63, at = 127, ki = 2147483647, fe = Number.MAX_SAFE_INTEGER, Zn = Number.MIN_SAFE_INTEGER, _i = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && H(e) === e), vs = String.fromCharCode, Si = (e) => e.toLowerCase(), Ci = /^\s*/g, Ei = (e) => e.replace(Ci, ""), Di = /([A-Z])/g, ts = (e, t) => Ei(e.replace(Di, (n) => `${t}${Si(n)}`)), Ai = (e) => {
|
|
146
146
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
147
147
|
for (let r = 0; r < n; r++)
|
|
148
148
|
s[r] = /** @type {number} */
|
|
@@ -151,10 +151,10 @@ const H = Math.floor, ce = Math.abs, yn = (e, t) => e < t ? e : t, wt = (e, t) =
|
|
|
151
151
|
}, Ht = (
|
|
152
152
|
/** @type {TextEncoder} */
|
|
153
153
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
154
|
-
),
|
|
154
|
+
), Ti = (e) => Ht.encode(e), xi = Ht ? Ti : Ai;
|
|
155
155
|
let Ft = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
156
156
|
Ft && Ft.decode(new Uint8Array()).length === 1 && (Ft = null);
|
|
157
|
-
const
|
|
157
|
+
const Ii = (e, t) => mi(t, () => e).join("");
|
|
158
158
|
class qt {
|
|
159
159
|
constructor() {
|
|
160
160
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
@@ -173,72 +173,72 @@ const N = () => new qt(), bn = (e) => {
|
|
|
173
173
|
t.set(r, n), n += r.length;
|
|
174
174
|
}
|
|
175
175
|
return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
176
|
-
},
|
|
176
|
+
}, Li = (e, t) => {
|
|
177
177
|
const n = e.cbuf.length;
|
|
178
178
|
n - e.cpos < t && (e.bufs.push(new Uint8Array(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(wt(n, t) * 2), e.cpos = 0);
|
|
179
|
-
},
|
|
179
|
+
}, x = (e, t) => {
|
|
180
180
|
const n = e.cbuf.length;
|
|
181
181
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
182
|
-
}, sn =
|
|
182
|
+
}, sn = x, w = (e, t) => {
|
|
183
183
|
for (; t > at; )
|
|
184
|
-
|
|
185
|
-
|
|
184
|
+
x(e, $ | at & t), t = H(t / 128);
|
|
185
|
+
x(e, at & t);
|
|
186
186
|
}, kn = (e, t) => {
|
|
187
|
-
const n =
|
|
188
|
-
for (n && (t = -t),
|
|
189
|
-
|
|
190
|
-
}, rn = new Uint8Array(3e4),
|
|
191
|
-
if (t.length <
|
|
187
|
+
const n = Ms(t);
|
|
188
|
+
for (n && (t = -t), x(e, (t > nn ? $ : 0) | (n ? W : 0) | nn & t), t = H(t / 64); t > 0; )
|
|
189
|
+
x(e, (t > at ? $ : 0) | at & t), t = H(t / 128);
|
|
190
|
+
}, rn = new Uint8Array(3e4), Oi = rn.length / 3, Ni = (e, t) => {
|
|
191
|
+
if (t.length < Oi) {
|
|
192
192
|
const n = Ht.encodeInto(t, rn).written || 0;
|
|
193
193
|
w(e, n);
|
|
194
194
|
for (let s = 0; s < n; s++)
|
|
195
|
-
|
|
195
|
+
x(e, rn[s]);
|
|
196
196
|
} else
|
|
197
|
-
E(e,
|
|
198
|
-
},
|
|
197
|
+
E(e, xi(t));
|
|
198
|
+
}, Mi = (e, t) => {
|
|
199
199
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
200
200
|
w(e, s);
|
|
201
201
|
for (let r = 0; r < s; r++)
|
|
202
|
-
|
|
202
|
+
x(
|
|
203
203
|
e,
|
|
204
204
|
/** @type {number} */
|
|
205
205
|
n.codePointAt(r)
|
|
206
206
|
);
|
|
207
207
|
}, ht = Ht && /** @type {any} */
|
|
208
|
-
Ht.encodeInto ?
|
|
208
|
+
Ht.encodeInto ? Ni : Mi, xe = (e, t) => {
|
|
209
209
|
const n = e.cbuf.length, s = e.cpos, r = yn(n - s, t.length), i = t.length - r;
|
|
210
210
|
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(wt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
211
211
|
}, E = (e, t) => {
|
|
212
|
-
w(e, t.byteLength),
|
|
212
|
+
w(e, t.byteLength), xe(e, t);
|
|
213
213
|
}, _n = (e, t) => {
|
|
214
|
-
|
|
214
|
+
Li(e, t);
|
|
215
215
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
216
216
|
return e.cpos += t, n;
|
|
217
|
-
},
|
|
217
|
+
}, vi = (e, t) => _n(e, 4).setFloat32(0, t, !1), Ui = (e, t) => _n(e, 8).setFloat64(0, t, !1), Ri = (e, t) => (
|
|
218
218
|
/** @type {any} */
|
|
219
219
|
_n(e, 8).setBigInt64(0, t, !1)
|
|
220
|
-
), es = new DataView(new ArrayBuffer(4)),
|
|
220
|
+
), es = new DataView(new ArrayBuffer(4)), $i = (e) => (es.setFloat32(0, e), es.getFloat32(0) === e), zt = (e, t) => {
|
|
221
221
|
switch (typeof t) {
|
|
222
222
|
case "string":
|
|
223
|
-
|
|
223
|
+
x(e, 119), ht(e, t);
|
|
224
224
|
break;
|
|
225
225
|
case "number":
|
|
226
|
-
|
|
226
|
+
_i(t) && ce(t) <= ki ? (x(e, 125), kn(e, t)) : $i(t) ? (x(e, 124), vi(e, t)) : (x(e, 123), Ui(e, t));
|
|
227
227
|
break;
|
|
228
228
|
case "bigint":
|
|
229
|
-
|
|
229
|
+
x(e, 122), Ri(e, t);
|
|
230
230
|
break;
|
|
231
231
|
case "object":
|
|
232
232
|
if (t === null)
|
|
233
|
-
|
|
234
|
-
else if (
|
|
235
|
-
|
|
233
|
+
x(e, 126);
|
|
234
|
+
else if (xt(t)) {
|
|
235
|
+
x(e, 117), w(e, t.length);
|
|
236
236
|
for (let n = 0; n < t.length; n++)
|
|
237
237
|
zt(e, t[n]);
|
|
238
238
|
} else if (t instanceof Uint8Array)
|
|
239
|
-
|
|
239
|
+
x(e, 116), E(e, t);
|
|
240
240
|
else {
|
|
241
|
-
|
|
241
|
+
x(e, 118);
|
|
242
242
|
const n = Object.keys(t);
|
|
243
243
|
w(e, n.length);
|
|
244
244
|
for (let s = 0; s < n.length; s++) {
|
|
@@ -248,10 +248,10 @@ Ht.encodeInto ? Li : Oi, Te = (e, t) => {
|
|
|
248
248
|
}
|
|
249
249
|
break;
|
|
250
250
|
case "boolean":
|
|
251
|
-
|
|
251
|
+
x(e, t ? 120 : 121);
|
|
252
252
|
break;
|
|
253
253
|
default:
|
|
254
|
-
|
|
254
|
+
x(e, 127);
|
|
255
255
|
}
|
|
256
256
|
};
|
|
257
257
|
class ns extends qt {
|
|
@@ -296,7 +296,7 @@ const rs = (e) => {
|
|
|
296
296
|
kn(e.encoder, t), e.count > 1 && w(e.encoder, e.count - 2);
|
|
297
297
|
}
|
|
298
298
|
};
|
|
299
|
-
class
|
|
299
|
+
class Ye {
|
|
300
300
|
constructor() {
|
|
301
301
|
this.encoder = new qt(), this.s = 0, this.count = 0, this.diff = 0;
|
|
302
302
|
}
|
|
@@ -315,7 +315,7 @@ class Ge {
|
|
|
315
315
|
return rs(this), C(this.encoder);
|
|
316
316
|
}
|
|
317
317
|
}
|
|
318
|
-
class
|
|
318
|
+
class Bi {
|
|
319
319
|
constructor() {
|
|
320
320
|
this.sarr = [], this.s = "", this.lensE = new le();
|
|
321
321
|
}
|
|
@@ -327,18 +327,18 @@ class Ri {
|
|
|
327
327
|
}
|
|
328
328
|
toUint8Array() {
|
|
329
329
|
const t = new qt();
|
|
330
|
-
return this.sarr.push(this.s), this.s = "", ht(t, this.sarr.join("")),
|
|
330
|
+
return this.sarr.push(this.s), this.s = "", ht(t, this.sarr.join("")), xe(t, this.lensE.toUint8Array()), C(t);
|
|
331
331
|
}
|
|
332
332
|
}
|
|
333
|
-
const
|
|
334
|
-
throw
|
|
333
|
+
const P = (e) => new Error(e), j = () => {
|
|
334
|
+
throw P("Method unimplemented");
|
|
335
335
|
}, V = () => {
|
|
336
|
-
throw
|
|
337
|
-
}, Ie =
|
|
336
|
+
throw P("Unexpected case");
|
|
337
|
+
}, Ie = P("Unexpected end of array"), Us = P("Integer out of Range"), Fi = (e, t, n) => {
|
|
338
338
|
if (t < 0 || n < 0 || t + n > e.length)
|
|
339
339
|
throw Ie;
|
|
340
340
|
return new Uint8Array(e.buffer, e.byteOffset + t, n);
|
|
341
|
-
},
|
|
341
|
+
}, Vi = (e, t, n) => {
|
|
342
342
|
if (t < 0 || n < 0 || t + n > e.length)
|
|
343
343
|
throw Ie;
|
|
344
344
|
return new DataView(e.buffer, e.byteOffset + t, n);
|
|
@@ -351,10 +351,10 @@ class Le {
|
|
|
351
351
|
this.arr = t, this.pos = 0;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
const ct = (e) => new Le(e),
|
|
355
|
-
const n =
|
|
354
|
+
const ct = (e) => new Le(e), ji = (e) => e.pos !== e.arr.length, Hi = (e, t) => {
|
|
355
|
+
const n = Fi(e.arr, e.pos, t);
|
|
356
356
|
return e.pos += t, n;
|
|
357
|
-
}, O = (e) =>
|
|
357
|
+
}, O = (e) => Hi(e, m(e)), It = (e) => e.arr[e.pos++], m = (e) => {
|
|
358
358
|
let t = 0, n = 1;
|
|
359
359
|
const s = e.arr.length;
|
|
360
360
|
for (; e.pos < s; ) {
|
|
@@ -378,7 +378,7 @@ const ct = (e) => new Le(e), Fi = (e) => e.pos !== e.arr.length, Vi = (e, t) =>
|
|
|
378
378
|
throw Us;
|
|
379
379
|
}
|
|
380
380
|
throw Ie;
|
|
381
|
-
},
|
|
381
|
+
}, zi = (e) => {
|
|
382
382
|
let t = m(e);
|
|
383
383
|
if (t === 0)
|
|
384
384
|
return "";
|
|
@@ -398,16 +398,16 @@ const ct = (e) => new Le(e), Fi = (e) => e.pos !== e.arr.length, Vi = (e, t) =>
|
|
|
398
398
|
}
|
|
399
399
|
return decodeURIComponent(escape(n));
|
|
400
400
|
}
|
|
401
|
-
},
|
|
401
|
+
}, Pi = (e) => (
|
|
402
402
|
/** @type any */
|
|
403
403
|
Ft.decode(O(e))
|
|
404
|
-
), st = Ft ?
|
|
405
|
-
const n =
|
|
404
|
+
), st = Ft ? Pi : zi, Cn = (e, t) => {
|
|
405
|
+
const n = Vi(e.arr, e.pos, t);
|
|
406
406
|
return e.pos += t, n;
|
|
407
|
-
},
|
|
407
|
+
}, Yi = (e) => Cn(e, 4).getFloat32(0, !1), Gi = (e) => Cn(e, 8).getFloat64(0, !1), Ji = (e) => (
|
|
408
408
|
/** @type {any} */
|
|
409
409
|
Cn(e, 8).getBigInt64(0, !1)
|
|
410
|
-
),
|
|
410
|
+
), Ki = [
|
|
411
411
|
(e) => {
|
|
412
412
|
},
|
|
413
413
|
// CASE 127: undefined
|
|
@@ -415,11 +415,11 @@ const ct = (e) => new Le(e), Fi = (e) => e.pos !== e.arr.length, Vi = (e, t) =>
|
|
|
415
415
|
// CASE 126: null
|
|
416
416
|
Sn,
|
|
417
417
|
// CASE 125: integer
|
|
418
|
-
zi,
|
|
419
|
-
// CASE 124: float32
|
|
420
418
|
Yi,
|
|
421
|
-
// CASE
|
|
419
|
+
// CASE 124: float32
|
|
422
420
|
Gi,
|
|
421
|
+
// CASE 123: float64
|
|
422
|
+
Ji,
|
|
423
423
|
// CASE 122: bigint
|
|
424
424
|
(e) => !1,
|
|
425
425
|
// CASE 121: boolean (false)
|
|
@@ -431,19 +431,19 @@ const ct = (e) => new Le(e), Fi = (e) => e.pos !== e.arr.length, Vi = (e, t) =>
|
|
|
431
431
|
const t = m(e), n = {};
|
|
432
432
|
for (let s = 0; s < t; s++) {
|
|
433
433
|
const r = st(e);
|
|
434
|
-
n[r] =
|
|
434
|
+
n[r] = Pt(e);
|
|
435
435
|
}
|
|
436
436
|
return n;
|
|
437
437
|
},
|
|
438
438
|
(e) => {
|
|
439
439
|
const t = m(e), n = [];
|
|
440
440
|
for (let s = 0; s < t; s++)
|
|
441
|
-
n.push(
|
|
441
|
+
n.push(Pt(e));
|
|
442
442
|
return n;
|
|
443
443
|
},
|
|
444
444
|
O
|
|
445
445
|
// CASE 116: Uint8Array
|
|
446
|
-
],
|
|
446
|
+
], Pt = (e) => Ki[127 - It(e)](e);
|
|
447
447
|
class is extends Le {
|
|
448
448
|
/**
|
|
449
449
|
* @param {Uint8Array} uint8Array
|
|
@@ -453,7 +453,7 @@ class is extends Le {
|
|
|
453
453
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
454
454
|
}
|
|
455
455
|
read() {
|
|
456
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
456
|
+
return this.count === 0 && (this.s = this.reader(this), ji(this) ? this.count = m(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
457
457
|
this.s;
|
|
458
458
|
}
|
|
459
459
|
}
|
|
@@ -467,14 +467,14 @@ class ae extends Le {
|
|
|
467
467
|
read() {
|
|
468
468
|
if (this.count === 0) {
|
|
469
469
|
this.s = Sn(this);
|
|
470
|
-
const t =
|
|
470
|
+
const t = Ms(this.s);
|
|
471
471
|
this.count = 1, t && (this.s = -this.s, this.count = m(this) + 2);
|
|
472
472
|
}
|
|
473
473
|
return this.count--, /** @type {number} */
|
|
474
474
|
this.s;
|
|
475
475
|
}
|
|
476
476
|
}
|
|
477
|
-
class
|
|
477
|
+
class Ge extends Le {
|
|
478
478
|
/**
|
|
479
479
|
* @param {Uint8Array} uint8Array
|
|
480
480
|
*/
|
|
@@ -492,7 +492,7 @@ class Pe extends Le {
|
|
|
492
492
|
return this.s += this.diff, this.count--, this.s;
|
|
493
493
|
}
|
|
494
494
|
}
|
|
495
|
-
class
|
|
495
|
+
class Wi {
|
|
496
496
|
/**
|
|
497
497
|
* @param {Uint8Array} uint8Array
|
|
498
498
|
*/
|
|
@@ -507,17 +507,17 @@ class Ji {
|
|
|
507
507
|
return this.spos = t, n;
|
|
508
508
|
}
|
|
509
509
|
}
|
|
510
|
-
const
|
|
510
|
+
const Xi = crypto.getRandomValues.bind(crypto), Rs = () => Xi(new Uint32Array(1))[0], qi = "10000000-1000-4000-8000" + -1e11, Qi = () => qi.replace(
|
|
511
511
|
/[018]/g,
|
|
512
512
|
/** @param {number} c */
|
|
513
|
-
(e) => (e ^
|
|
513
|
+
(e) => (e ^ Rs() & 15 >> e / 4).toString(16)
|
|
514
514
|
), it = Date.now, os = (e) => (
|
|
515
515
|
/** @type {Promise<T>} */
|
|
516
516
|
new Promise(e)
|
|
517
517
|
);
|
|
518
518
|
Promise.all.bind(Promise);
|
|
519
519
|
const cs = (e) => e === void 0 ? null : e;
|
|
520
|
-
class
|
|
520
|
+
class Zi {
|
|
521
521
|
constructor() {
|
|
522
522
|
this.map = /* @__PURE__ */ new Map();
|
|
523
523
|
}
|
|
@@ -535,28 +535,28 @@ class qi {
|
|
|
535
535
|
return this.map.get(t);
|
|
536
536
|
}
|
|
537
537
|
}
|
|
538
|
-
let
|
|
538
|
+
let $s = new Zi(), En = !0;
|
|
539
539
|
try {
|
|
540
|
-
typeof localStorage < "u" && localStorage && (
|
|
540
|
+
typeof localStorage < "u" && localStorage && ($s = localStorage, En = !1);
|
|
541
541
|
} catch {
|
|
542
542
|
}
|
|
543
|
-
const
|
|
543
|
+
const Bs = $s, to = (e) => En || addEventListener(
|
|
544
544
|
"storage",
|
|
545
545
|
/** @type {any} */
|
|
546
546
|
e
|
|
547
|
-
),
|
|
547
|
+
), eo = (e) => En || removeEventListener(
|
|
548
548
|
"storage",
|
|
549
549
|
/** @type {any} */
|
|
550
550
|
e
|
|
551
|
-
),
|
|
551
|
+
), Yt = /* @__PURE__ */ Symbol("Equality"), Fs = (e, t) => e === t || !!e?.[Yt]?.(t) || !1, no = (e) => typeof e == "object", so = Object.assign, ro = Object.keys, io = (e, t) => {
|
|
552
552
|
for (const n in e)
|
|
553
553
|
t(e[n], n);
|
|
554
|
-
},
|
|
554
|
+
}, oo = (e, t) => {
|
|
555
555
|
const n = [];
|
|
556
556
|
for (const s in e)
|
|
557
557
|
n.push(t(e[s], s));
|
|
558
558
|
return n;
|
|
559
|
-
}, ge = (e) =>
|
|
559
|
+
}, ge = (e) => ro(e).length, co = (e) => {
|
|
560
560
|
for (const t in e)
|
|
561
561
|
return !1;
|
|
562
562
|
return !0;
|
|
@@ -565,12 +565,12 @@ const $s = Rs, Qi = (e) => En || addEventListener(
|
|
|
565
565
|
if (!t(e[n], n))
|
|
566
566
|
return !1;
|
|
567
567
|
return !0;
|
|
568
|
-
}, Dn = (e, t) => Object.prototype.hasOwnProperty.call(e, t),
|
|
568
|
+
}, Dn = (e, t) => Object.prototype.hasOwnProperty.call(e, t), lo = (e, t) => e === t || ge(e) === ge(t) && Qt(e, (n, s) => (n !== void 0 || Dn(t, s)) && Fs(t[s], n)), ao = Object.freeze, Vs = (e) => {
|
|
569
569
|
for (const t in e) {
|
|
570
570
|
const n = e[t];
|
|
571
|
-
(typeof n == "object" || typeof n == "function") &&
|
|
571
|
+
(typeof n == "object" || typeof n == "function") && Vs(e[t]);
|
|
572
572
|
}
|
|
573
|
-
return
|
|
573
|
+
return ao(e);
|
|
574
574
|
}, An = (e, t, n = 0) => {
|
|
575
575
|
try {
|
|
576
576
|
for (; n < e.length; n++)
|
|
@@ -578,13 +578,13 @@ const $s = Rs, Qi = (e) => En || addEventListener(
|
|
|
578
578
|
} finally {
|
|
579
579
|
n < e.length && An(e, t, n + 1);
|
|
580
580
|
}
|
|
581
|
-
},
|
|
581
|
+
}, ho = (e) => e, Ct = (e, t) => {
|
|
582
582
|
if (e === t)
|
|
583
583
|
return !0;
|
|
584
584
|
if (e == null || t == null || e.constructor !== t.constructor && (e.constructor || Object) !== (t.constructor || Object))
|
|
585
585
|
return !1;
|
|
586
|
-
if (e[
|
|
587
|
-
return e[
|
|
586
|
+
if (e[Yt] != null)
|
|
587
|
+
return e[Yt](t);
|
|
588
588
|
switch (e.constructor) {
|
|
589
589
|
case ArrayBuffer:
|
|
590
590
|
e = new Uint8Array(e), t = new Uint8Array(t);
|
|
@@ -632,9 +632,9 @@ const $s = Rs, Qi = (e) => En || addEventListener(
|
|
|
632
632
|
return !1;
|
|
633
633
|
}
|
|
634
634
|
return !0;
|
|
635
|
-
},
|
|
635
|
+
}, uo = (e, t) => t.includes(e), ot = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", js = typeof window < "u" && typeof document < "u" && !ot;
|
|
636
636
|
let z;
|
|
637
|
-
const
|
|
637
|
+
const fo = () => {
|
|
638
638
|
if (z === void 0)
|
|
639
639
|
if (ot) {
|
|
640
640
|
z = R();
|
|
@@ -652,22 +652,22 @@ const ho = () => {
|
|
|
652
652
|
}
|
|
653
653
|
})) : z = R();
|
|
654
654
|
return z;
|
|
655
|
-
}, on = (e) =>
|
|
656
|
-
!
|
|
655
|
+
}, on = (e) => fo().has(e), pe = (e) => cs(ot ? process.env[e.toUpperCase().replaceAll("-", "_")] : Bs.getItem(e)), Hs = (e) => on("--" + e) || pe(e) !== null, go = Hs("production"), po = ot && uo(process.env.FORCE_COLOR, ["true", "1", "2"]), wo = po || !on("--no-colors") && // @todo deprecate --no-colors
|
|
656
|
+
!Hs("no-color") && (!ot || process.stdout.isTTY) && (!ot || on("--color") || pe("COLORTERM") !== null || (pe("TERM") || "").includes("color")), zs = (e) => new Uint8Array(e), mo = (e) => new Uint8Array(e), yo = (e) => {
|
|
657
657
|
let t = "";
|
|
658
658
|
for (let n = 0; n < e.byteLength; n++)
|
|
659
|
-
t +=
|
|
659
|
+
t += vs(e[n]);
|
|
660
660
|
return btoa(t);
|
|
661
|
-
},
|
|
662
|
-
const t = atob(e), n =
|
|
661
|
+
}, bo = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), ko = (e) => {
|
|
662
|
+
const t = atob(e), n = zs(t.length);
|
|
663
663
|
for (let s = 0; s < t.length; s++)
|
|
664
664
|
n[s] = t.charCodeAt(s);
|
|
665
665
|
return n;
|
|
666
|
-
},
|
|
667
|
-
const t =
|
|
666
|
+
}, _o = (e) => new Uint8Array(Buffer.from(e, "base64")), So = js ? yo : bo, Co = js ? ko : _o, Eo = (e) => {
|
|
667
|
+
const t = zs(e.byteLength);
|
|
668
668
|
return t.set(e), t;
|
|
669
669
|
};
|
|
670
|
-
class
|
|
670
|
+
class Do {
|
|
671
671
|
/**
|
|
672
672
|
* @param {L} left
|
|
673
673
|
* @param {R} right
|
|
@@ -676,14 +676,14 @@ class Co {
|
|
|
676
676
|
this.left = t, this.right = n;
|
|
677
677
|
}
|
|
678
678
|
}
|
|
679
|
-
const K = (e, t) => new
|
|
680
|
-
const s =
|
|
679
|
+
const K = (e, t) => new Do(e, t), ls = (e) => e.next() >= 0.5, Je = (e, t, n) => H(e.next() * (n + 1 - t) + t), Ps = (e, t, n) => H(e.next() * (n + 1 - t) + t), Tn = (e, t, n) => Ps(e, t, n), Ao = (e) => vs(Tn(e, 97, 122)), To = (e, t = 0, n = 20) => {
|
|
680
|
+
const s = Tn(e, t, n);
|
|
681
681
|
let r = "";
|
|
682
682
|
for (let i = 0; i < s; i++)
|
|
683
|
-
r +=
|
|
683
|
+
r += Ao(e);
|
|
684
684
|
return r;
|
|
685
|
-
}, Ke = (e, t) => t[
|
|
686
|
-
class
|
|
685
|
+
}, Ke = (e, t) => t[Tn(e, 0, t.length - 1)], xo = /* @__PURE__ */ Symbol("0schema");
|
|
686
|
+
class Io {
|
|
687
687
|
constructor() {
|
|
688
688
|
this._rerrs = [];
|
|
689
689
|
}
|
|
@@ -700,20 +700,20 @@ class xo {
|
|
|
700
700
|
const t = [];
|
|
701
701
|
for (let n = this._rerrs.length - 1; n > 0; n--) {
|
|
702
702
|
const s = this._rerrs[n];
|
|
703
|
-
t.push(
|
|
703
|
+
t.push(Ii(" ", (this._rerrs.length - n) * 2) + `${s.path != null ? `[${s.path}] ` : ""}${s.has} doesn't match ${s.expected}. ${s.message}`);
|
|
704
704
|
}
|
|
705
705
|
return t.join(`
|
|
706
706
|
`);
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
|
-
const cn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[
|
|
709
|
+
const cn = (e, t) => e === t ? !0 : e == null || t == null || e.constructor !== t.constructor ? !1 : e[Yt] ? Fs(e, t) : xt(e) ? pn(
|
|
710
710
|
e,
|
|
711
711
|
(n) => wn(t, (s) => cn(n, s))
|
|
712
|
-
) :
|
|
712
|
+
) : no(e) ? Qt(
|
|
713
713
|
e,
|
|
714
714
|
(n, s) => cn(n, t[s])
|
|
715
715
|
) : !1;
|
|
716
|
-
class
|
|
716
|
+
class v {
|
|
717
717
|
// this.shape must not be defined on Schema. Otherwise typecheck on metatypes (e.g. $$object) won't work as expected anymore
|
|
718
718
|
/**
|
|
719
719
|
* If true, the more things are added to the shape the more objects this schema will accept (e.g.
|
|
@@ -744,13 +744,13 @@ class U {
|
|
|
744
744
|
equals(t) {
|
|
745
745
|
return this.constructor === t.constructor && Ct(this.shape, t.shape);
|
|
746
746
|
}
|
|
747
|
-
[
|
|
747
|
+
[xo]() {
|
|
748
748
|
return !0;
|
|
749
749
|
}
|
|
750
750
|
/**
|
|
751
751
|
* @param {object} other
|
|
752
752
|
*/
|
|
753
|
-
[
|
|
753
|
+
[Yt](t) {
|
|
754
754
|
return this.equals(
|
|
755
755
|
/** @type {any} */
|
|
756
756
|
t
|
|
@@ -783,13 +783,13 @@ class U {
|
|
|
783
783
|
* @type {Schema<T?>}
|
|
784
784
|
*/
|
|
785
785
|
get nullable() {
|
|
786
|
-
return
|
|
786
|
+
return Ut(this, Ue);
|
|
787
787
|
}
|
|
788
788
|
/**
|
|
789
789
|
* @type {$Optional<Schema<T>>}
|
|
790
790
|
*/
|
|
791
791
|
get optional() {
|
|
792
|
-
return new
|
|
792
|
+
return new Js(
|
|
793
793
|
/** @type {Schema<T>} */
|
|
794
794
|
this
|
|
795
795
|
);
|
|
@@ -833,7 +833,7 @@ class U {
|
|
|
833
833
|
return as(t, this), t;
|
|
834
834
|
}
|
|
835
835
|
}
|
|
836
|
-
class
|
|
836
|
+
class xn extends v {
|
|
837
837
|
/**
|
|
838
838
|
* @param {C} c
|
|
839
839
|
* @param {((o:Instance<C>)=>boolean)|null} check
|
|
@@ -851,9 +851,9 @@ class Tn extends U {
|
|
|
851
851
|
return !s && n?.extend(null, this.shape.name, t?.constructor.name, t?.constructor !== this.shape ? "Constructor match failed" : "Check failed"), s;
|
|
852
852
|
}
|
|
853
853
|
}
|
|
854
|
-
const D = (e, t = null) => new
|
|
855
|
-
D(
|
|
856
|
-
class In extends
|
|
854
|
+
const D = (e, t = null) => new xn(e, t);
|
|
855
|
+
D(xn);
|
|
856
|
+
class In extends v {
|
|
857
857
|
/**
|
|
858
858
|
* @param {(o:any) => boolean} check
|
|
859
859
|
*/
|
|
@@ -872,7 +872,7 @@ class In extends U {
|
|
|
872
872
|
}
|
|
873
873
|
const L = (e) => new In(e);
|
|
874
874
|
D(In);
|
|
875
|
-
class Oe extends
|
|
875
|
+
class Oe extends v {
|
|
876
876
|
/**
|
|
877
877
|
* @param {Array<T>} literals
|
|
878
878
|
*/
|
|
@@ -890,27 +890,27 @@ class Oe extends U {
|
|
|
890
890
|
return !s && n?.extend(null, this.shape.join(" | "), t.toString()), s;
|
|
891
891
|
}
|
|
892
892
|
}
|
|
893
|
-
const Ne = (...e) => new Oe(e), Ys = D(Oe),
|
|
893
|
+
const Ne = (...e) => new Oe(e), Ys = D(Oe), Lo = (
|
|
894
894
|
/** @type {any} */
|
|
895
895
|
RegExp.escape || /** @type {(str:string) => string} */
|
|
896
896
|
((e) => e.replace(/[().|&,$^[\]]/g, (t) => "\\" + t))
|
|
897
897
|
), Gs = (e) => {
|
|
898
898
|
if (Lt.check(e))
|
|
899
|
-
return [
|
|
899
|
+
return [Lo(e)];
|
|
900
900
|
if (Ys.check(e))
|
|
901
901
|
return (
|
|
902
902
|
/** @type {Array<string|number>} */
|
|
903
903
|
e.shape.map((t) => t + "")
|
|
904
904
|
);
|
|
905
|
-
if (er.check(e))
|
|
906
|
-
return ["[+-]?\\d+.?\\d*"];
|
|
907
905
|
if (nr.check(e))
|
|
906
|
+
return ["[+-]?\\d+.?\\d*"];
|
|
907
|
+
if (sr.check(e))
|
|
908
908
|
return [".*"];
|
|
909
909
|
if (we.check(e))
|
|
910
910
|
return e.shape.map(Gs).flat(1);
|
|
911
911
|
V();
|
|
912
912
|
};
|
|
913
|
-
class
|
|
913
|
+
class Oo extends v {
|
|
914
914
|
/**
|
|
915
915
|
* @param {T} shape
|
|
916
916
|
*/
|
|
@@ -927,9 +927,9 @@ class Io extends U {
|
|
|
927
927
|
return !s && n?.extend(null, this._r.toString(), t.toString(), "String doesn't match string template."), s;
|
|
928
928
|
}
|
|
929
929
|
}
|
|
930
|
-
D(
|
|
931
|
-
const
|
|
932
|
-
class
|
|
930
|
+
D(Oo);
|
|
931
|
+
const No = /* @__PURE__ */ Symbol("optional");
|
|
932
|
+
class Js extends v {
|
|
933
933
|
/**
|
|
934
934
|
* @param {S} shape
|
|
935
935
|
*/
|
|
@@ -945,12 +945,12 @@ class Ps extends U {
|
|
|
945
945
|
const s = t === void 0 || this.shape.check(t);
|
|
946
946
|
return !s && n?.extend(null, "undefined (optional)", "()"), s;
|
|
947
947
|
}
|
|
948
|
-
get [
|
|
948
|
+
get [No]() {
|
|
949
949
|
return !0;
|
|
950
950
|
}
|
|
951
951
|
}
|
|
952
|
-
const
|
|
953
|
-
class
|
|
952
|
+
const Mo = D(Js);
|
|
953
|
+
class vo extends v {
|
|
954
954
|
/**
|
|
955
955
|
* @param {any} _o
|
|
956
956
|
* @param {ValidationError} [err]
|
|
@@ -960,8 +960,8 @@ class No extends U {
|
|
|
960
960
|
return n?.extend(null, "never", typeof t), !1;
|
|
961
961
|
}
|
|
962
962
|
}
|
|
963
|
-
D(
|
|
964
|
-
class Me extends
|
|
963
|
+
D(vo);
|
|
964
|
+
class Me extends v {
|
|
965
965
|
/**
|
|
966
966
|
* @param {S} shape
|
|
967
967
|
* @param {boolean} partial
|
|
@@ -988,11 +988,11 @@ class Me extends U {
|
|
|
988
988
|
});
|
|
989
989
|
}
|
|
990
990
|
}
|
|
991
|
-
const
|
|
991
|
+
const Uo = (e) => (
|
|
992
992
|
/** @type {any} */
|
|
993
993
|
new Me(e)
|
|
994
|
-
),
|
|
995
|
-
class
|
|
994
|
+
), Ro = D(Me), $o = L((e) => e != null && (e.constructor === Object || e.constructor == null));
|
|
995
|
+
class Ks extends v {
|
|
996
996
|
/**
|
|
997
997
|
* @param {Keys} keys
|
|
998
998
|
* @param {Values} values
|
|
@@ -1015,8 +1015,8 @@ class Js extends U {
|
|
|
1015
1015
|
});
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
|
-
const
|
|
1019
|
-
class
|
|
1018
|
+
const Ws = (e, t) => new Ks(e, t), Bo = D(Ks);
|
|
1019
|
+
class Xs extends v {
|
|
1020
1020
|
/**
|
|
1021
1021
|
* @param {S} shape
|
|
1022
1022
|
*/
|
|
@@ -1038,9 +1038,9 @@ class Ws extends U {
|
|
|
1038
1038
|
});
|
|
1039
1039
|
}
|
|
1040
1040
|
}
|
|
1041
|
-
const
|
|
1042
|
-
D(
|
|
1043
|
-
class
|
|
1041
|
+
const Fo = (...e) => new Xs(e);
|
|
1042
|
+
D(Xs);
|
|
1043
|
+
class qs extends v {
|
|
1044
1044
|
/**
|
|
1045
1045
|
* @param {Array<S>} v
|
|
1046
1046
|
*/
|
|
@@ -1053,12 +1053,12 @@ class Xs extends U {
|
|
|
1053
1053
|
* @return {o is Array<S extends Schema<infer T> ? T : never>} o
|
|
1054
1054
|
*/
|
|
1055
1055
|
check(t, n) {
|
|
1056
|
-
const s =
|
|
1056
|
+
const s = xt(t) && pn(t, (r) => this.shape.check(r));
|
|
1057
1057
|
return !s && n?.extend(null, "Array", ""), s;
|
|
1058
1058
|
}
|
|
1059
1059
|
}
|
|
1060
|
-
const
|
|
1061
|
-
class
|
|
1060
|
+
const Qs = (...e) => new qs(e), Vo = D(qs), jo = L((e) => xt(e));
|
|
1061
|
+
class Zs extends v {
|
|
1062
1062
|
/**
|
|
1063
1063
|
* @param {new (...args:any) => T} constructor
|
|
1064
1064
|
* @param {((o:T) => boolean)|null} check
|
|
@@ -1076,15 +1076,15 @@ class Qs extends U {
|
|
|
1076
1076
|
return !s && n?.extend(null, this.shape.name, t?.constructor.name), s;
|
|
1077
1077
|
}
|
|
1078
1078
|
}
|
|
1079
|
-
const
|
|
1080
|
-
D(
|
|
1081
|
-
const
|
|
1082
|
-
class
|
|
1079
|
+
const Ho = (e, t = null) => new Zs(e, t);
|
|
1080
|
+
D(Zs);
|
|
1081
|
+
const zo = Ho(v);
|
|
1082
|
+
class Po extends v {
|
|
1083
1083
|
/**
|
|
1084
1084
|
* @param {Args} args
|
|
1085
1085
|
*/
|
|
1086
1086
|
constructor(t) {
|
|
1087
|
-
super(), this.len = t.length - 1, this.args =
|
|
1087
|
+
super(), this.len = t.length - 1, this.args = Fo(...t.slice(-1)), this.res = t[this.len];
|
|
1088
1088
|
}
|
|
1089
1089
|
/**
|
|
1090
1090
|
* @param {any} f
|
|
@@ -1096,8 +1096,8 @@ class Ho extends U {
|
|
|
1096
1096
|
return !s && n?.extend(null, "function", typeof t), s;
|
|
1097
1097
|
}
|
|
1098
1098
|
}
|
|
1099
|
-
const
|
|
1100
|
-
class
|
|
1099
|
+
const Yo = D(Po), Go = L((e) => typeof e == "function");
|
|
1100
|
+
class Jo extends v {
|
|
1101
1101
|
/**
|
|
1102
1102
|
* @param {T} v
|
|
1103
1103
|
*/
|
|
@@ -1114,8 +1114,8 @@ class Go extends U {
|
|
|
1114
1114
|
return !s && n?.extend(null, "Intersectinon", typeof t), s;
|
|
1115
1115
|
}
|
|
1116
1116
|
}
|
|
1117
|
-
D(
|
|
1118
|
-
class Ln extends
|
|
1117
|
+
D(Jo, (e) => e.shape.length > 0);
|
|
1118
|
+
class Ln extends v {
|
|
1119
1119
|
static _dilutes = !0;
|
|
1120
1120
|
/**
|
|
1121
1121
|
* @param {Array<Schema<S>>} v
|
|
@@ -1133,72 +1133,72 @@ class Ln extends U {
|
|
|
1133
1133
|
return n?.extend(null, "Union", typeof t), s;
|
|
1134
1134
|
}
|
|
1135
1135
|
}
|
|
1136
|
-
const
|
|
1136
|
+
const Ut = (...e) => e.findIndex((t) => we.check(t)) >= 0 ? Ut(...e.map((t) => Gt(t)).map((t) => we.check(t) ? t.shape : [t]).flat(1)) : e.length === 1 ? e[0] : new Ln(e), we = (
|
|
1137
1137
|
/** @type {Schema<$Union<any>>} */
|
|
1138
1138
|
D(Ln)
|
|
1139
|
-
),
|
|
1139
|
+
), tr = () => !0, me = L(tr), Ko = (
|
|
1140
1140
|
/** @type {Schema<Schema<any>>} */
|
|
1141
|
-
D(In, (e) => e.shape ===
|
|
1142
|
-
), On = L((e) => typeof e == "bigint"),
|
|
1141
|
+
D(In, (e) => e.shape === tr)
|
|
1142
|
+
), On = L((e) => typeof e == "bigint"), Wo = (
|
|
1143
1143
|
/** @type {Schema<Schema<BigInt>>} */
|
|
1144
1144
|
L((e) => e === On)
|
|
1145
|
-
),
|
|
1146
|
-
L((e) => e ===
|
|
1147
|
-
const Et = L((e) => typeof e == "number"),
|
|
1145
|
+
), er = L((e) => typeof e == "symbol");
|
|
1146
|
+
L((e) => e === er);
|
|
1147
|
+
const Et = L((e) => typeof e == "number"), nr = (
|
|
1148
1148
|
/** @type {Schema<Schema<number>>} */
|
|
1149
1149
|
L((e) => e === Et)
|
|
1150
|
-
), Lt = L((e) => typeof e == "string"),
|
|
1150
|
+
), Lt = L((e) => typeof e == "string"), sr = (
|
|
1151
1151
|
/** @type {Schema<Schema<string>>} */
|
|
1152
1152
|
L((e) => e === Lt)
|
|
1153
|
-
),
|
|
1153
|
+
), ve = L((e) => typeof e == "boolean"), Xo = (
|
|
1154
1154
|
/** @type {Schema<Schema<Boolean>>} */
|
|
1155
|
-
L((e) => e ===
|
|
1156
|
-
),
|
|
1155
|
+
L((e) => e === ve)
|
|
1156
|
+
), rr = Ne(void 0);
|
|
1157
1157
|
D(Oe, (e) => e.shape.length === 1 && e.shape[0] === void 0);
|
|
1158
1158
|
Ne(void 0);
|
|
1159
|
-
const
|
|
1159
|
+
const Ue = Ne(null), qo = (
|
|
1160
1160
|
/** @type {Schema<Schema<null>>} */
|
|
1161
1161
|
D(Oe, (e) => e.shape.length === 1 && e.shape[0] === null)
|
|
1162
1162
|
);
|
|
1163
1163
|
D(Uint8Array);
|
|
1164
|
-
D(
|
|
1165
|
-
const
|
|
1164
|
+
D(xn, (e) => e.shape === Uint8Array);
|
|
1165
|
+
const Qo = Ut(Et, Lt, Ue, rr, On, ve, er);
|
|
1166
1166
|
(() => {
|
|
1167
1167
|
const e = (
|
|
1168
1168
|
/** @type {$Array<$any>} */
|
|
1169
|
-
|
|
1169
|
+
Qs(me)
|
|
1170
1170
|
), t = (
|
|
1171
1171
|
/** @type {$Record<$string,$any>} */
|
|
1172
|
-
|
|
1173
|
-
), n =
|
|
1172
|
+
Ws(Lt, me)
|
|
1173
|
+
), n = Ut(Et, Lt, Ue, ve, e, t);
|
|
1174
1174
|
return e.shape = n, t.shape.values = n, n;
|
|
1175
1175
|
})();
|
|
1176
|
-
const
|
|
1177
|
-
if (
|
|
1176
|
+
const Gt = (e) => {
|
|
1177
|
+
if (zo.check(e))
|
|
1178
1178
|
return (
|
|
1179
1179
|
/** @type {any} */
|
|
1180
1180
|
e
|
|
1181
1181
|
);
|
|
1182
|
-
if (
|
|
1182
|
+
if ($o.check(e)) {
|
|
1183
1183
|
const t = {};
|
|
1184
1184
|
for (const n in e)
|
|
1185
|
-
t[n] =
|
|
1185
|
+
t[n] = Gt(e[n]);
|
|
1186
1186
|
return (
|
|
1187
1187
|
/** @type {any} */
|
|
1188
|
-
|
|
1188
|
+
Uo(t)
|
|
1189
1189
|
);
|
|
1190
1190
|
} else {
|
|
1191
|
-
if (
|
|
1191
|
+
if (jo.check(e))
|
|
1192
1192
|
return (
|
|
1193
1193
|
/** @type {any} */
|
|
1194
|
-
|
|
1194
|
+
Ut(...e.map(Gt))
|
|
1195
1195
|
);
|
|
1196
|
-
if (
|
|
1196
|
+
if (Qo.check(e))
|
|
1197
1197
|
return (
|
|
1198
1198
|
/** @type {any} */
|
|
1199
1199
|
Ne(e)
|
|
1200
1200
|
);
|
|
1201
|
-
if (
|
|
1201
|
+
if (Go.check(e))
|
|
1202
1202
|
return (
|
|
1203
1203
|
/** @type {any} */
|
|
1204
1204
|
D(
|
|
@@ -1208,14 +1208,14 @@ const Pt = (e) => {
|
|
|
1208
1208
|
);
|
|
1209
1209
|
}
|
|
1210
1210
|
V();
|
|
1211
|
-
}, as =
|
|
1211
|
+
}, as = go ? () => {
|
|
1212
1212
|
} : (e, t) => {
|
|
1213
|
-
const n = new
|
|
1213
|
+
const n = new Io();
|
|
1214
1214
|
if (!t.check(e, n))
|
|
1215
|
-
throw
|
|
1215
|
+
throw P(`Expected value to be of type ${t.constructor.name}.
|
|
1216
1216
|
${n.toString()}`);
|
|
1217
1217
|
};
|
|
1218
|
-
class
|
|
1218
|
+
class Zo {
|
|
1219
1219
|
/**
|
|
1220
1220
|
* @param {Schema<State>} [$state]
|
|
1221
1221
|
*/
|
|
@@ -1230,7 +1230,7 @@ class qo {
|
|
|
1230
1230
|
* @return {PatternMatcher<State,Patterns|Pattern<Unwrap<ReadSchema<P>>,R>>}
|
|
1231
1231
|
*/
|
|
1232
1232
|
if(t, n) {
|
|
1233
|
-
return this.patterns.push({ if:
|
|
1233
|
+
return this.patterns.push({ if: Gt(t), h: n }), this;
|
|
1234
1234
|
}
|
|
1235
1235
|
/**
|
|
1236
1236
|
* @template R
|
|
@@ -1253,49 +1253,49 @@ class qo {
|
|
|
1253
1253
|
if (r.if.check(t))
|
|
1254
1254
|
return r.h(t, n);
|
|
1255
1255
|
}
|
|
1256
|
-
throw
|
|
1256
|
+
throw P("Unhandled pattern");
|
|
1257
1257
|
}
|
|
1258
1258
|
);
|
|
1259
1259
|
}
|
|
1260
1260
|
}
|
|
1261
|
-
const
|
|
1261
|
+
const tc = (e) => new Zo(
|
|
1262
1262
|
/** @type {any} */
|
|
1263
1263
|
e
|
|
1264
|
-
),
|
|
1264
|
+
), ir = (
|
|
1265
1265
|
/** @type {any} */
|
|
1266
|
-
|
|
1266
|
+
tc(
|
|
1267
1267
|
/** @type {Schema<prng.PRNG>} */
|
|
1268
1268
|
me
|
|
1269
|
-
).if(
|
|
1269
|
+
).if(nr, (e, t) => Je(t, Zn, fe)).if(sr, (e, t) => To(t)).if(Xo, (e, t) => ls(t)).if(Wo, (e, t) => BigInt(Je(t, Zn, fe))).if(we, (e, t) => bt(t, Ke(t, e.shape))).if(Ro, (e, t) => {
|
|
1270
1270
|
const n = {};
|
|
1271
1271
|
for (const s in e.shape) {
|
|
1272
1272
|
let r = e.shape[s];
|
|
1273
|
-
if (
|
|
1273
|
+
if (Mo.check(r)) {
|
|
1274
1274
|
if (ls(t))
|
|
1275
1275
|
continue;
|
|
1276
1276
|
r = r.shape;
|
|
1277
1277
|
}
|
|
1278
|
-
n[s] =
|
|
1278
|
+
n[s] = ir(r, t);
|
|
1279
1279
|
}
|
|
1280
1280
|
return n;
|
|
1281
|
-
}).if(
|
|
1282
|
-
const n = [], s =
|
|
1281
|
+
}).if(Vo, (e, t) => {
|
|
1282
|
+
const n = [], s = Ps(t, 0, 42);
|
|
1283
1283
|
for (let r = 0; r < s; r++)
|
|
1284
1284
|
n.push(bt(t, e.shape));
|
|
1285
1285
|
return n;
|
|
1286
|
-
}).if(Ys, (e, t) => Ke(t, e.shape)).if(
|
|
1286
|
+
}).if(Ys, (e, t) => Ke(t, e.shape)).if(qo, (e, t) => null).if(Yo, (e, t) => {
|
|
1287
1287
|
const n = bt(t, e.res);
|
|
1288
1288
|
return () => n;
|
|
1289
|
-
}).if(
|
|
1289
|
+
}).if(Ko, (e, t) => bt(t, Ke(t, [
|
|
1290
1290
|
Et,
|
|
1291
1291
|
Lt,
|
|
1292
|
-
ve,
|
|
1293
|
-
sr,
|
|
1294
|
-
On,
|
|
1295
1292
|
Ue,
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1293
|
+
rr,
|
|
1294
|
+
On,
|
|
1295
|
+
ve,
|
|
1296
|
+
Qs(Et),
|
|
1297
|
+
Ws(Ut("a", "b", "c"), Et)
|
|
1298
|
+
]))).if(Bo, (e, t) => {
|
|
1299
1299
|
const n = {}, s = Je(t, 0, 3);
|
|
1300
1300
|
for (let r = 0; r < s; r++) {
|
|
1301
1301
|
const i = bt(t, e.shape.keys), o = bt(t, e.shape.values);
|
|
@@ -1305,18 +1305,18 @@ const Qo = (e) => new qo(
|
|
|
1305
1305
|
}).done()
|
|
1306
1306
|
), bt = (e, t) => (
|
|
1307
1307
|
/** @type {any} */
|
|
1308
|
-
|
|
1308
|
+
ir(Gt(t), e)
|
|
1309
1309
|
), Re = (
|
|
1310
1310
|
/** @type {Document} */
|
|
1311
1311
|
typeof document < "u" ? document : {}
|
|
1312
1312
|
);
|
|
1313
|
-
L((e) => e.nodeType ===
|
|
1313
|
+
L((e) => e.nodeType === ic);
|
|
1314
1314
|
typeof DOMParser < "u" && new DOMParser();
|
|
1315
|
-
L((e) => e.nodeType === tc);
|
|
1316
|
-
L((e) => e.nodeType === ec);
|
|
1317
|
-
const Zo = (e) => di(e, (t, n) => `${n}:${t};`).join(""), tc = Re.ELEMENT_NODE, ec = Re.TEXT_NODE, nc = Re.DOCUMENT_NODE, sc = Re.DOCUMENT_FRAGMENT_NODE;
|
|
1318
1315
|
L((e) => e.nodeType === nc);
|
|
1319
|
-
|
|
1316
|
+
L((e) => e.nodeType === sc);
|
|
1317
|
+
const ec = (e) => gi(e, (t, n) => `${n}:${t};`).join(""), nc = Re.ELEMENT_NODE, sc = Re.TEXT_NODE, rc = Re.DOCUMENT_NODE, ic = Re.DOCUMENT_FRAGMENT_NODE;
|
|
1318
|
+
L((e) => e.nodeType === rc);
|
|
1319
|
+
const Z = Symbol, or = Z(), cr = Z(), oc = Z(), cc = Z(), lc = Z(), lr = Z(), ac = Z(), Nn = Z(), hc = Z(), uc = (e) => {
|
|
1320
1320
|
e.length === 1 && e[0]?.constructor === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
|
|
1321
1321
|
/** @type {[function]} */
|
|
1322
1322
|
e[0]());
|
|
@@ -1336,32 +1336,32 @@ const Z = Symbol, ir = Z(), or = Z(), rc = Z(), ic = Z(), oc = Z(), cr = Z(), cc
|
|
|
1336
1336
|
r instanceof Symbol || n.push(r);
|
|
1337
1337
|
}
|
|
1338
1338
|
return n;
|
|
1339
|
-
},
|
|
1340
|
-
[
|
|
1341
|
-
[
|
|
1342
|
-
[
|
|
1343
|
-
[
|
|
1344
|
-
[
|
|
1345
|
-
[
|
|
1346
|
-
[
|
|
1339
|
+
}, dc = {
|
|
1340
|
+
[or]: K("font-weight", "bold"),
|
|
1341
|
+
[cr]: K("font-weight", "normal"),
|
|
1342
|
+
[oc]: K("color", "blue"),
|
|
1343
|
+
[lc]: K("color", "green"),
|
|
1344
|
+
[cc]: K("color", "grey"),
|
|
1345
|
+
[lr]: K("color", "red"),
|
|
1346
|
+
[ac]: K("color", "purple"),
|
|
1347
1347
|
[Nn]: K("color", "orange"),
|
|
1348
1348
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
1349
|
-
[
|
|
1350
|
-
},
|
|
1349
|
+
[hc]: K("color", "black")
|
|
1350
|
+
}, fc = (e) => {
|
|
1351
1351
|
e.length === 1 && e[0]?.constructor === Function && (e = /** @type {Array<string|Symbol|Object|number>} */
|
|
1352
1352
|
/** @type {[function]} */
|
|
1353
1353
|
e[0]());
|
|
1354
1354
|
const t = [], n = [], s = R();
|
|
1355
1355
|
let r = [], i = 0;
|
|
1356
1356
|
for (; i < e.length; i++) {
|
|
1357
|
-
const o = e[i], c =
|
|
1357
|
+
const o = e[i], c = dc[o];
|
|
1358
1358
|
if (c !== void 0)
|
|
1359
1359
|
s.set(c.left, c.right);
|
|
1360
1360
|
else {
|
|
1361
1361
|
if (o === void 0)
|
|
1362
1362
|
break;
|
|
1363
1363
|
if (o.constructor === String || o.constructor === Number) {
|
|
1364
|
-
const l =
|
|
1364
|
+
const l = ec(s);
|
|
1365
1365
|
i > 0 || l.length > 0 ? (t.push("%c" + o), n.push(l)) : t.push(o);
|
|
1366
1366
|
} else
|
|
1367
1367
|
break;
|
|
@@ -1372,11 +1372,11 @@ const Z = Symbol, ir = Z(), or = Z(), rc = Z(), ic = Z(), oc = Z(), cr = Z(), cc
|
|
|
1372
1372
|
o instanceof Symbol || r.push(o);
|
|
1373
1373
|
}
|
|
1374
1374
|
return r;
|
|
1375
|
-
},
|
|
1376
|
-
console.log(...
|
|
1377
|
-
},
|
|
1378
|
-
console.warn(...
|
|
1379
|
-
},
|
|
1375
|
+
}, ar = wo ? fc : uc, gc = (...e) => {
|
|
1376
|
+
console.log(...ar(e)), ur.forEach((t) => t.print(e));
|
|
1377
|
+
}, hr = (...e) => {
|
|
1378
|
+
console.warn(...ar(e)), e.unshift(Nn), ur.forEach((t) => t.print(e));
|
|
1379
|
+
}, ur = rt(), dr = (e) => ({
|
|
1380
1380
|
/**
|
|
1381
1381
|
* @return {IterableIterator<T>}
|
|
1382
1382
|
*/
|
|
@@ -1385,13 +1385,13 @@ const Z = Symbol, ir = Z(), or = Z(), rc = Z(), ic = Z(), oc = Z(), cr = Z(), cc
|
|
|
1385
1385
|
},
|
|
1386
1386
|
// @ts-ignore
|
|
1387
1387
|
next: e
|
|
1388
|
-
}),
|
|
1388
|
+
}), pc = (e, t) => dr(() => {
|
|
1389
1389
|
let n;
|
|
1390
1390
|
do
|
|
1391
1391
|
n = e.next();
|
|
1392
1392
|
while (!n.done && !t(n.value));
|
|
1393
1393
|
return n;
|
|
1394
|
-
}), We = (e, t) =>
|
|
1394
|
+
}), We = (e, t) => dr(() => {
|
|
1395
1395
|
const { done: n, value: s } = e.next();
|
|
1396
1396
|
return { done: n, value: n ? void 0 : t(s) };
|
|
1397
1397
|
});
|
|
@@ -1417,9 +1417,9 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1417
1417
|
if (i != null) {
|
|
1418
1418
|
const o = i[i.length - 1], c = o.id.clock + o.length;
|
|
1419
1419
|
for (let l = 0, a = s[l]; l < s.length && a.clock < c; a = s[++l])
|
|
1420
|
-
|
|
1420
|
+
Er(e, i, a.clock, a.len, n);
|
|
1421
1421
|
}
|
|
1422
|
-
}),
|
|
1422
|
+
}), wc = (e, t) => {
|
|
1423
1423
|
let n = 0, s = e.length - 1;
|
|
1424
1424
|
for (; n <= s; ) {
|
|
1425
1425
|
const r = H((n + s) / 2), i = e[r], o = i.clock;
|
|
@@ -1433,7 +1433,7 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1433
1433
|
return null;
|
|
1434
1434
|
}, Zt = (e, t) => {
|
|
1435
1435
|
const n = e.clients.get(t.client);
|
|
1436
|
-
return n !== void 0 &&
|
|
1436
|
+
return n !== void 0 && wc(n, t.clock) !== null;
|
|
1437
1437
|
}, Mn = (e) => {
|
|
1438
1438
|
e.clients.forEach((t) => {
|
|
1439
1439
|
t.sort((r, i) => r.clock - i.clock);
|
|
@@ -1451,7 +1451,7 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1451
1451
|
if (!t.clients.has(r)) {
|
|
1452
1452
|
const i = s.slice();
|
|
1453
1453
|
for (let o = n + 1; o < e.length; o++)
|
|
1454
|
-
|
|
1454
|
+
wi(i, e[o].clients.get(r) || []);
|
|
1455
1455
|
t.clients.set(r, i);
|
|
1456
1456
|
}
|
|
1457
1457
|
});
|
|
@@ -1461,8 +1461,8 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1461
1461
|
/** @type {Array<DeleteItem>} */
|
|
1462
1462
|
[]
|
|
1463
1463
|
)).push(new $e(n, s));
|
|
1464
|
-
},
|
|
1465
|
-
const t =
|
|
1464
|
+
}, mc = () => new Rt(), yc = (e) => {
|
|
1465
|
+
const t = mc();
|
|
1466
1466
|
return e.clients.forEach((n, s) => {
|
|
1467
1467
|
const r = [];
|
|
1468
1468
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -1488,7 +1488,7 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1488
1488
|
e.writeDsClock(o.clock), e.writeDsLen(o.len);
|
|
1489
1489
|
}
|
|
1490
1490
|
});
|
|
1491
|
-
},
|
|
1491
|
+
}, vn = (e) => {
|
|
1492
1492
|
const t = new Rt(), n = m(e.restDecoder);
|
|
1493
1493
|
for (let s = 0; s < n; s++) {
|
|
1494
1494
|
e.resetDsCurVal();
|
|
@@ -1512,7 +1512,7 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1512
1512
|
const u = e.readDsClock(), d = u + e.readDsLen();
|
|
1513
1513
|
if (u < a) {
|
|
1514
1514
|
a < d && Jt(s, o, a, d - a);
|
|
1515
|
-
let f =
|
|
1515
|
+
let f = Y(l, u), g = l[f];
|
|
1516
1516
|
for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0, Ee(t, g, u - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < d); )
|
|
1517
1517
|
g.deleted || (d < g.id.clock + g.length && l.splice(f, 0, Ee(t, g, d - g.id.clock)), g.delete(t));
|
|
1518
1518
|
} else
|
|
@@ -1524,13 +1524,13 @@ const Ot = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1524
1524
|
return w(i.restEncoder, 0), $t(i, s), i.toUint8Array();
|
|
1525
1525
|
}
|
|
1526
1526
|
return null;
|
|
1527
|
-
},
|
|
1527
|
+
}, fr = Rs;
|
|
1528
1528
|
class mt extends mn {
|
|
1529
1529
|
/**
|
|
1530
1530
|
* @param {DocOpts} opts configuration
|
|
1531
1531
|
*/
|
|
1532
|
-
constructor({ guid: t =
|
|
1533
|
-
super(), this.gc = s, this.gcFilter = r, this.clientID =
|
|
1532
|
+
constructor({ guid: t = Qi(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
1533
|
+
super(), this.gc = s, this.gcFilter = r, this.clientID = fr(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new Sr(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.isDestroyed = !1, this.whenLoaded = os((a) => {
|
|
1534
1534
|
this.on("load", () => {
|
|
1535
1535
|
this.isLoaded = !0, a(this);
|
|
1536
1536
|
});
|
|
@@ -1662,7 +1662,7 @@ class mt extends mn {
|
|
|
1662
1662
|
* @public
|
|
1663
1663
|
*/
|
|
1664
1664
|
getText(t = "") {
|
|
1665
|
-
return this.get(t,
|
|
1665
|
+
return this.get(t, vt);
|
|
1666
1666
|
}
|
|
1667
1667
|
/**
|
|
1668
1668
|
* @template T
|
|
@@ -1738,7 +1738,7 @@ class mt extends mn {
|
|
|
1738
1738
|
this.emit("destroyed", [!0]), this.emit("destroy", [this]), super.destroy();
|
|
1739
1739
|
}
|
|
1740
1740
|
}
|
|
1741
|
-
class
|
|
1741
|
+
class gr {
|
|
1742
1742
|
/**
|
|
1743
1743
|
* @param {decoding.Decoder} decoder
|
|
1744
1744
|
*/
|
|
@@ -1760,7 +1760,7 @@ class fr {
|
|
|
1760
1760
|
return m(this.restDecoder);
|
|
1761
1761
|
}
|
|
1762
1762
|
}
|
|
1763
|
-
class
|
|
1763
|
+
class pr extends gr {
|
|
1764
1764
|
/**
|
|
1765
1765
|
* @return {ID}
|
|
1766
1766
|
*/
|
|
@@ -1816,13 +1816,13 @@ class gr extends fr {
|
|
|
1816
1816
|
* @return {any}
|
|
1817
1817
|
*/
|
|
1818
1818
|
readAny() {
|
|
1819
|
-
return
|
|
1819
|
+
return Pt(this.restDecoder);
|
|
1820
1820
|
}
|
|
1821
1821
|
/**
|
|
1822
1822
|
* @return {Uint8Array}
|
|
1823
1823
|
*/
|
|
1824
1824
|
readBuf() {
|
|
1825
|
-
return
|
|
1825
|
+
return Eo(O(this.restDecoder));
|
|
1826
1826
|
}
|
|
1827
1827
|
/**
|
|
1828
1828
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1839,7 +1839,7 @@ class gr extends fr {
|
|
|
1839
1839
|
return st(this.restDecoder);
|
|
1840
1840
|
}
|
|
1841
1841
|
}
|
|
1842
|
-
class
|
|
1842
|
+
class bc {
|
|
1843
1843
|
/**
|
|
1844
1844
|
* @param {decoding.Decoder} decoder
|
|
1845
1845
|
*/
|
|
@@ -1863,12 +1863,12 @@ class mc {
|
|
|
1863
1863
|
return this.dsCurrVal += t, t;
|
|
1864
1864
|
}
|
|
1865
1865
|
}
|
|
1866
|
-
class Nt extends
|
|
1866
|
+
class Nt extends bc {
|
|
1867
1867
|
/**
|
|
1868
1868
|
* @param {decoding.Decoder} decoder
|
|
1869
1869
|
*/
|
|
1870
1870
|
constructor(t) {
|
|
1871
|
-
super(t), this.keys = [], m(t), this.keyClockDecoder = new
|
|
1871
|
+
super(t), this.keys = [], m(t), this.keyClockDecoder = new Ge(O(t)), this.clientDecoder = new ae(O(t)), this.leftClockDecoder = new Ge(O(t)), this.rightClockDecoder = new Ge(O(t)), this.infoDecoder = new is(O(t), It), this.stringDecoder = new Wi(O(t)), this.parentInfoDecoder = new is(O(t), It), this.typeRefDecoder = new ae(O(t)), this.lenDecoder = new ae(O(t));
|
|
1872
1872
|
}
|
|
1873
1873
|
/**
|
|
1874
1874
|
* @return {ID}
|
|
@@ -1928,7 +1928,7 @@ class Nt extends mc {
|
|
|
1928
1928
|
* @return {any}
|
|
1929
1929
|
*/
|
|
1930
1930
|
readAny() {
|
|
1931
|
-
return
|
|
1931
|
+
return Pt(this.restDecoder);
|
|
1932
1932
|
}
|
|
1933
1933
|
/**
|
|
1934
1934
|
* @return {Uint8Array}
|
|
@@ -1944,7 +1944,7 @@ class Nt extends mc {
|
|
|
1944
1944
|
* @return {any}
|
|
1945
1945
|
*/
|
|
1946
1946
|
readJSON() {
|
|
1947
|
-
return
|
|
1947
|
+
return Pt(this.restDecoder);
|
|
1948
1948
|
}
|
|
1949
1949
|
/**
|
|
1950
1950
|
* @return {string}
|
|
@@ -1959,7 +1959,7 @@ class Nt extends mc {
|
|
|
1959
1959
|
}
|
|
1960
1960
|
}
|
|
1961
1961
|
}
|
|
1962
|
-
class
|
|
1962
|
+
class wr {
|
|
1963
1963
|
constructor() {
|
|
1964
1964
|
this.restEncoder = N();
|
|
1965
1965
|
}
|
|
@@ -1981,7 +1981,7 @@ class pr {
|
|
|
1981
1981
|
w(this.restEncoder, t);
|
|
1982
1982
|
}
|
|
1983
1983
|
}
|
|
1984
|
-
class te extends
|
|
1984
|
+
class te extends wr {
|
|
1985
1985
|
/**
|
|
1986
1986
|
* @param {ID} id
|
|
1987
1987
|
*/
|
|
@@ -2058,7 +2058,7 @@ class te extends pr {
|
|
|
2058
2058
|
ht(this.restEncoder, t);
|
|
2059
2059
|
}
|
|
2060
2060
|
}
|
|
2061
|
-
class
|
|
2061
|
+
class mr {
|
|
2062
2062
|
constructor() {
|
|
2063
2063
|
this.restEncoder = N(), this.dsCurrVal = 0;
|
|
2064
2064
|
}
|
|
@@ -2082,13 +2082,13 @@ class wr {
|
|
|
2082
2082
|
t === 0 && V(), w(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
2083
2083
|
}
|
|
2084
2084
|
}
|
|
2085
|
-
class ut extends
|
|
2085
|
+
class ut extends mr {
|
|
2086
2086
|
constructor() {
|
|
2087
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new
|
|
2087
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Ye(), this.clientEncoder = new le(), this.leftClockEncoder = new Ye(), this.rightClockEncoder = new Ye(), this.infoEncoder = new ns(sn), this.stringEncoder = new Bi(), this.parentInfoEncoder = new ns(sn), this.typeRefEncoder = new le(), this.lenEncoder = new le();
|
|
2088
2088
|
}
|
|
2089
2089
|
toUint8Array() {
|
|
2090
2090
|
const t = N();
|
|
2091
|
-
return w(t, 0), E(t, this.keyClockEncoder.toUint8Array()), E(t, this.clientEncoder.toUint8Array()), E(t, this.leftClockEncoder.toUint8Array()), E(t, this.rightClockEncoder.toUint8Array()), E(t, C(this.infoEncoder)), E(t, this.stringEncoder.toUint8Array()), E(t, C(this.parentInfoEncoder)), E(t, this.typeRefEncoder.toUint8Array()), E(t, this.lenEncoder.toUint8Array()),
|
|
2091
|
+
return w(t, 0), E(t, this.keyClockEncoder.toUint8Array()), E(t, this.clientEncoder.toUint8Array()), E(t, this.leftClockEncoder.toUint8Array()), E(t, this.rightClockEncoder.toUint8Array()), E(t, C(this.infoEncoder)), E(t, this.stringEncoder.toUint8Array()), E(t, C(this.parentInfoEncoder)), E(t, this.typeRefEncoder.toUint8Array()), E(t, this.lenEncoder.toUint8Array()), xe(t, C(this.restEncoder)), C(t);
|
|
2092
2092
|
}
|
|
2093
2093
|
/**
|
|
2094
2094
|
* @param {ID} id
|
|
@@ -2175,22 +2175,22 @@ class ut extends wr {
|
|
|
2175
2175
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
2176
2176
|
}
|
|
2177
2177
|
}
|
|
2178
|
-
const
|
|
2178
|
+
const kc = (e, t, n, s) => {
|
|
2179
2179
|
s = wt(s, t[0].id.clock);
|
|
2180
|
-
const r =
|
|
2180
|
+
const r = Y(t, s);
|
|
2181
2181
|
w(e.restEncoder, t.length - r), e.writeClient(n), w(e.restEncoder, s);
|
|
2182
2182
|
const i = t[r];
|
|
2183
2183
|
i.write(e, s - i.id.clock);
|
|
2184
2184
|
for (let o = r + 1; o < t.length; o++)
|
|
2185
2185
|
t[o].write(e, 0);
|
|
2186
|
-
},
|
|
2186
|
+
}, Un = (e, t, n) => {
|
|
2187
2187
|
const s = /* @__PURE__ */ new Map();
|
|
2188
2188
|
n.forEach((r, i) => {
|
|
2189
2189
|
A(t, i) > r && s.set(i, r);
|
|
2190
2190
|
}), Be(t).forEach((r, i) => {
|
|
2191
2191
|
n.has(i) || s.set(i, 0);
|
|
2192
2192
|
}), w(e.restEncoder, s.size), X(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
2193
|
-
|
|
2193
|
+
kc(
|
|
2194
2194
|
e,
|
|
2195
2195
|
/** @type {Array<GC|Item>} */
|
|
2196
2196
|
t.clients.get(r),
|
|
@@ -2198,7 +2198,7 @@ const yc = (e, t, n, s) => {
|
|
|
2198
2198
|
i
|
|
2199
2199
|
);
|
|
2200
2200
|
});
|
|
2201
|
-
},
|
|
2201
|
+
}, _c = (e, t) => {
|
|
2202
2202
|
const n = R(), s = m(e.restDecoder);
|
|
2203
2203
|
for (let r = 0; r < s; r++) {
|
|
2204
2204
|
const i = m(e.restDecoder), o = new Array(i), c = e.readClient();
|
|
@@ -2206,7 +2206,7 @@ const yc = (e, t, n, s) => {
|
|
|
2206
2206
|
n.set(c, { i: 0, refs: o });
|
|
2207
2207
|
for (let a = 0; a < i; a++) {
|
|
2208
2208
|
const h = e.readInfo();
|
|
2209
|
-
switch (
|
|
2209
|
+
switch (Te & h) {
|
|
2210
2210
|
case 0: {
|
|
2211
2211
|
const u = e.readLen();
|
|
2212
2212
|
o[a] = new B(y(c, l), u), l += u;
|
|
@@ -2232,7 +2232,7 @@ const yc = (e, t, n, s) => {
|
|
|
2232
2232
|
// parent
|
|
2233
2233
|
u && (h & jt) === jt ? e.readString() : null,
|
|
2234
2234
|
// parentSub
|
|
2235
|
-
|
|
2235
|
+
Pr(e, h)
|
|
2236
2236
|
// item content
|
|
2237
2237
|
);
|
|
2238
2238
|
o[a] = d, l += d.length;
|
|
@@ -2241,7 +2241,7 @@ const yc = (e, t, n, s) => {
|
|
|
2241
2241
|
}
|
|
2242
2242
|
}
|
|
2243
2243
|
return n;
|
|
2244
|
-
},
|
|
2244
|
+
}, Sc = (e, t, n) => {
|
|
2245
2245
|
const s = [];
|
|
2246
2246
|
let r = X(n.keys()).sort((f, g) => f - g);
|
|
2247
2247
|
if (r.length === 0)
|
|
@@ -2264,7 +2264,7 @@ const yc = (e, t, n, s) => {
|
|
|
2264
2264
|
let o = i();
|
|
2265
2265
|
if (o === null)
|
|
2266
2266
|
return null;
|
|
2267
|
-
const c = new
|
|
2267
|
+
const c = new Sr(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
|
|
2268
2268
|
const p = l.get(f);
|
|
2269
2269
|
(p == null || p > g) && l.set(f, g);
|
|
2270
2270
|
};
|
|
@@ -2323,13 +2323,13 @@ const yc = (e, t, n, s) => {
|
|
|
2323
2323
|
}
|
|
2324
2324
|
if (c.clients.size > 0) {
|
|
2325
2325
|
const f = new ut();
|
|
2326
|
-
return
|
|
2326
|
+
return Un(f, c, /* @__PURE__ */ new Map()), w(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
2327
2327
|
}
|
|
2328
2328
|
return null;
|
|
2329
|
-
},
|
|
2329
|
+
}, Cc = (e, t) => Un(e, t.doc.store, t.beforeState), Ec = (e, t, n, s = new Nt(e)) => _(t, (r) => {
|
|
2330
2330
|
r.local = !1;
|
|
2331
2331
|
let i = !1;
|
|
2332
|
-
const o = r.doc, c = o.store, l =
|
|
2332
|
+
const o = r.doc, c = o.store, l = _c(s, o), a = Sc(r, c, l), h = c.pendingStructs;
|
|
2333
2333
|
if (h) {
|
|
2334
2334
|
for (const [d, f] of h.missing)
|
|
2335
2335
|
if (f < A(c, d)) {
|
|
@@ -2358,43 +2358,43 @@ const yc = (e, t, n, s) => {
|
|
|
2358
2358
|
/** @type {{update: Uint8Array}} */
|
|
2359
2359
|
c.pendingStructs.update
|
|
2360
2360
|
);
|
|
2361
|
-
c.pendingStructs = null,
|
|
2361
|
+
c.pendingStructs = null, yr(r.doc, d);
|
|
2362
2362
|
}
|
|
2363
|
-
}, n, !1),
|
|
2363
|
+
}, n, !1), yr = (e, t, n, s = Nt) => {
|
|
2364
2364
|
const r = ct(t);
|
|
2365
|
-
|
|
2366
|
-
},
|
|
2367
|
-
|
|
2368
|
-
},
|
|
2369
|
-
const s =
|
|
2370
|
-
|
|
2365
|
+
Ec(r, e, n, new s(r));
|
|
2366
|
+
}, Dc = (e, t, n) => yr(e, t, n, pr), Ac = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
2367
|
+
Un(e, t.store, n), $t(e, yc(t.store));
|
|
2368
|
+
}, Tc = (e, t = new Uint8Array([0]), n = new ut()) => {
|
|
2369
|
+
const s = br(t);
|
|
2370
|
+
Ac(n, e, s);
|
|
2371
2371
|
const r = [n.toUint8Array()];
|
|
2372
|
-
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(
|
|
2372
|
+
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Yc(e.store.pendingStructs.update, t)), r.length > 1) {
|
|
2373
2373
|
if (n.constructor === te)
|
|
2374
|
-
return
|
|
2374
|
+
return zc(r.map((i, o) => o === 0 ? i : Jc(i)));
|
|
2375
2375
|
if (n.constructor === ut)
|
|
2376
2376
|
return be(r);
|
|
2377
2377
|
}
|
|
2378
2378
|
return r[0];
|
|
2379
|
-
},
|
|
2379
|
+
}, xc = (e, t) => Tc(e, t, new te()), Ic = (e) => {
|
|
2380
2380
|
const t = /* @__PURE__ */ new Map(), n = m(e.restDecoder);
|
|
2381
2381
|
for (let s = 0; s < n; s++) {
|
|
2382
2382
|
const r = m(e.restDecoder), i = m(e.restDecoder);
|
|
2383
2383
|
t.set(r, i);
|
|
2384
2384
|
}
|
|
2385
2385
|
return t;
|
|
2386
|
-
},
|
|
2386
|
+
}, br = (e) => Ic(new gr(ct(e))), kr = (e, t) => (w(e.restEncoder, t.size), X(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
2387
2387
|
w(e.restEncoder, n), w(e.restEncoder, s);
|
|
2388
|
-
}), e),
|
|
2389
|
-
class
|
|
2388
|
+
}), e), Lc = (e, t) => kr(e, Be(t.store)), Oc = (e, t = new mr()) => (e instanceof Map ? kr(t, e) : Lc(t, e), t.toUint8Array()), Nc = (e) => Oc(e, new wr());
|
|
2389
|
+
class Mc {
|
|
2390
2390
|
constructor() {
|
|
2391
2391
|
this.l = [];
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
2394
|
-
const us = () => new
|
|
2394
|
+
const us = () => new Mc(), ds = (e, t) => e.l.push(t), fs = (e, t) => {
|
|
2395
2395
|
const n = e.l, s = n.length;
|
|
2396
2396
|
e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
2397
|
-
},
|
|
2397
|
+
}, _r = (e, t, n) => An(e.l, [t, n]);
|
|
2398
2398
|
class Dt {
|
|
2399
2399
|
/**
|
|
2400
2400
|
* @param {number} client client id
|
|
@@ -2404,7 +2404,7 @@ class Dt {
|
|
|
2404
2404
|
this.client = t, this.clock = n;
|
|
2405
2405
|
}
|
|
2406
2406
|
}
|
|
2407
|
-
const re = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, y = (e, t) => new Dt(e, t),
|
|
2407
|
+
const re = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, y = (e, t) => new Dt(e, t), vc = (e) => {
|
|
2408
2408
|
for (const [t, n] of e.doc.share.entries())
|
|
2409
2409
|
if (n === e)
|
|
2410
2410
|
return t;
|
|
@@ -2420,11 +2420,11 @@ const re = (e, t) => e === t || e !== null && t !== null && e.client === t.clien
|
|
|
2420
2420
|
}, kt = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !Zt(t.ds, e.id), an = (e, t) => {
|
|
2421
2421
|
const n = J(e.meta, an, rt), s = e.doc.store;
|
|
2422
2422
|
n.has(t) || (t.sv.forEach((r, i) => {
|
|
2423
|
-
r < A(s, i) &&
|
|
2423
|
+
r < A(s, i) && U(e, y(i, r));
|
|
2424
2424
|
}), Ot(e, t.ds, (r) => {
|
|
2425
2425
|
}), n.add(t));
|
|
2426
2426
|
};
|
|
2427
|
-
class
|
|
2427
|
+
class Sr {
|
|
2428
2428
|
constructor() {
|
|
2429
2429
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
2430
2430
|
}
|
|
@@ -2441,7 +2441,7 @@ const Be = (e) => {
|
|
|
2441
2441
|
return 0;
|
|
2442
2442
|
const s = n[n.length - 1];
|
|
2443
2443
|
return s.id.clock + s.length;
|
|
2444
|
-
},
|
|
2444
|
+
}, Cr = (e, t) => {
|
|
2445
2445
|
let n = e.clients.get(t.id.client);
|
|
2446
2446
|
if (n === void 0)
|
|
2447
2447
|
n = [], e.clients.set(t.id.client, n);
|
|
@@ -2451,7 +2451,7 @@ const Be = (e) => {
|
|
|
2451
2451
|
throw V();
|
|
2452
2452
|
}
|
|
2453
2453
|
n.push(t);
|
|
2454
|
-
},
|
|
2454
|
+
}, Y = (e, t) => {
|
|
2455
2455
|
let n = 0, s = e.length - 1, r = e[s], i = r.id.clock;
|
|
2456
2456
|
if (i === t)
|
|
2457
2457
|
return s;
|
|
@@ -2466,31 +2466,31 @@ const Be = (e) => {
|
|
|
2466
2466
|
o = H((n + s) / 2);
|
|
2467
2467
|
}
|
|
2468
2468
|
throw V();
|
|
2469
|
-
},
|
|
2469
|
+
}, Uc = (e, t) => {
|
|
2470
2470
|
const n = e.clients.get(t.client);
|
|
2471
|
-
return n[
|
|
2471
|
+
return n[Y(n, t.clock)];
|
|
2472
2472
|
}, he = (
|
|
2473
2473
|
/** @type {function(StructStore,ID):Item} */
|
|
2474
|
-
|
|
2474
|
+
Uc
|
|
2475
2475
|
), hn = (e, t, n) => {
|
|
2476
|
-
const s =
|
|
2476
|
+
const s = Y(t, n), r = t[s];
|
|
2477
2477
|
return r.id.clock < n && r instanceof S ? (t.splice(s + 1, 0, Ee(e, r, n - r.id.clock)), s + 1) : s;
|
|
2478
|
-
},
|
|
2478
|
+
}, U = (e, t) => {
|
|
2479
2479
|
const n = (
|
|
2480
2480
|
/** @type {Array<Item>} */
|
|
2481
2481
|
e.doc.store.clients.get(t.client)
|
|
2482
2482
|
);
|
|
2483
2483
|
return n[hn(e, n, t.clock)];
|
|
2484
2484
|
}, gs = (e, t, n) => {
|
|
2485
|
-
const s = t.clients.get(n.client), r =
|
|
2485
|
+
const s = t.clients.get(n.client), r = Y(s, n.clock), i = s[r];
|
|
2486
2486
|
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== B && s.splice(r + 1, 0, Ee(e, i, n.clock - i.id.clock + 1)), i;
|
|
2487
|
-
},
|
|
2487
|
+
}, Rc = (e, t, n) => {
|
|
2488
2488
|
const s = (
|
|
2489
2489
|
/** @type {Array<GC|Item>} */
|
|
2490
2490
|
e.clients.get(t.id.client)
|
|
2491
2491
|
);
|
|
2492
|
-
s[
|
|
2493
|
-
},
|
|
2492
|
+
s[Y(s, t.id.clock)] = n;
|
|
2493
|
+
}, Er = (e, t, n, s, r) => {
|
|
2494
2494
|
if (s === 0)
|
|
2495
2495
|
return;
|
|
2496
2496
|
const i = n + s;
|
|
@@ -2499,7 +2499,7 @@ const Be = (e) => {
|
|
|
2499
2499
|
c = t[o++], i < c.id.clock + c.length && hn(e, t, i), r(c);
|
|
2500
2500
|
while (o < t.length && t[o].id.clock < i);
|
|
2501
2501
|
};
|
|
2502
|
-
class
|
|
2502
|
+
class $c {
|
|
2503
2503
|
/**
|
|
2504
2504
|
* @param {Doc} doc
|
|
2505
2505
|
* @param {any} origin
|
|
@@ -2509,7 +2509,7 @@ class vc {
|
|
|
2509
2509
|
this.doc = t, this.deleteSet = new Rt(), this.beforeState = Be(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
2510
2510
|
}
|
|
2511
2511
|
}
|
|
2512
|
-
const ps = (e, t) => t.deleteSet.clients.size === 0 && !
|
|
2512
|
+
const ps = (e, t) => t.deleteSet.clients.size === 0 && !pi(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (Mn(t.deleteSet), Cc(e, t), $t(e, t.deleteSet), !0), ws = (e, t, n) => {
|
|
2513
2513
|
const s = t._item;
|
|
2514
2514
|
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && J(e.changed, t, rt).add(n);
|
|
2515
2515
|
}, ue = (e, t) => {
|
|
@@ -2528,7 +2528,7 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2528
2528
|
}
|
|
2529
2529
|
const i = t - r;
|
|
2530
2530
|
return i && e.splice(t + 1 - i, i), i;
|
|
2531
|
-
},
|
|
2531
|
+
}, Bc = (e, t, n) => {
|
|
2532
2532
|
for (const [s, r] of e.clients.entries()) {
|
|
2533
2533
|
const i = (
|
|
2534
2534
|
/** @type {Array<GC|Item>} */
|
|
@@ -2536,7 +2536,7 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2536
2536
|
);
|
|
2537
2537
|
for (let o = r.length - 1; o >= 0; o--) {
|
|
2538
2538
|
const c = r[o], l = c.clock + c.len;
|
|
2539
|
-
for (let a =
|
|
2539
|
+
for (let a = Y(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
|
|
2540
2540
|
const u = i[a];
|
|
2541
2541
|
if (c.clock + c.len <= u.id.clock)
|
|
2542
2542
|
break;
|
|
@@ -2544,19 +2544,19 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2544
2544
|
}
|
|
2545
2545
|
}
|
|
2546
2546
|
}
|
|
2547
|
-
},
|
|
2547
|
+
}, Fc = (e, t) => {
|
|
2548
2548
|
e.clients.forEach((n, s) => {
|
|
2549
2549
|
const r = (
|
|
2550
2550
|
/** @type {Array<GC|Item>} */
|
|
2551
2551
|
t.clients.get(s)
|
|
2552
2552
|
);
|
|
2553
2553
|
for (let i = n.length - 1; i >= 0; i--) {
|
|
2554
|
-
const o = n[i], c = yn(r.length - 1, 1 +
|
|
2554
|
+
const o = n[i], c = yn(r.length - 1, 1 + Y(r, o.clock + o.len - 1));
|
|
2555
2555
|
for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[l])
|
|
2556
2556
|
l -= 1 + ue(r, l);
|
|
2557
2557
|
}
|
|
2558
2558
|
});
|
|
2559
|
-
},
|
|
2559
|
+
}, Dr = (e, t) => {
|
|
2560
2560
|
if (t < e.length) {
|
|
2561
2561
|
const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
|
|
2562
2562
|
try {
|
|
@@ -2573,20 +2573,20 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2573
2573
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
2574
2574
|
), l.forEach((h) => {
|
|
2575
2575
|
h.currentTarget = a, h._path = null;
|
|
2576
|
-
}), l.sort((h, u) => h.path.length - u.path.length),
|
|
2576
|
+
}), l.sort((h, u) => h.path.length - u.path.length), _r(a._dEH, l, n);
|
|
2577
2577
|
});
|
|
2578
2578
|
}), c.push(() => s.emit("afterTransaction", [n, s])), c.push(() => {
|
|
2579
|
-
n._needFormattingCleanup &&
|
|
2579
|
+
n._needFormattingCleanup && cl(n);
|
|
2580
2580
|
});
|
|
2581
2581
|
}), An(c, []);
|
|
2582
2582
|
} finally {
|
|
2583
|
-
s.gc &&
|
|
2583
|
+
s.gc && Bc(i, r, s.gcFilter), Fc(i, r), n.afterState.forEach((h, u) => {
|
|
2584
2584
|
const d = n.beforeState.get(u) || 0;
|
|
2585
2585
|
if (d !== h) {
|
|
2586
2586
|
const f = (
|
|
2587
2587
|
/** @type {Array<GC|Item>} */
|
|
2588
2588
|
r.clients.get(u)
|
|
2589
|
-
), g = wt(
|
|
2589
|
+
), g = wt(Y(f, d), 1);
|
|
2590
2590
|
for (let p = f.length - 1; p >= g; )
|
|
2591
2591
|
p -= 1 + ue(f, p);
|
|
2592
2592
|
}
|
|
@@ -2595,10 +2595,10 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2595
2595
|
const { client: u, clock: d } = o[h].id, f = (
|
|
2596
2596
|
/** @type {Array<GC|Item>} */
|
|
2597
2597
|
r.clients.get(u)
|
|
2598
|
-
), g =
|
|
2598
|
+
), g = Y(f, d);
|
|
2599
2599
|
g + 1 < f.length && ue(f, g + 1) > 1 || g > 0 && ue(f, g);
|
|
2600
2600
|
}
|
|
2601
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
2601
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (gc(Nn, or, "[yjs] ", cr, lr, "Changed the client-id because another client seems to be using it."), s.clientID = fr()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
2602
2602
|
const h = new te();
|
|
2603
2603
|
ps(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
|
|
2604
2604
|
}
|
|
@@ -2609,24 +2609,24 @@ const ps = (e, t) => t.deleteSet.clients.size === 0 && !fi(t.afterState, (n, s)
|
|
|
2609
2609
|
const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
|
|
2610
2610
|
(c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
|
|
2611
2611
|
h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
|
|
2612
|
-
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) :
|
|
2612
|
+
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) : Dr(e, t + 1);
|
|
2613
2613
|
}
|
|
2614
2614
|
}
|
|
2615
2615
|
}, _ = (e, t, n = null, s = !0) => {
|
|
2616
2616
|
const r = e._transactionCleanups;
|
|
2617
2617
|
let i = !1, o = null;
|
|
2618
|
-
e._transaction === null && (i = !0, e._transaction = new
|
|
2618
|
+
e._transaction === null && (i = !0, e._transaction = new $c(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
2619
2619
|
try {
|
|
2620
2620
|
o = t(e._transaction);
|
|
2621
2621
|
} finally {
|
|
2622
2622
|
if (i) {
|
|
2623
2623
|
const c = e._transaction === r[0];
|
|
2624
|
-
e._transaction = null, c &&
|
|
2624
|
+
e._transaction = null, c && Dr(r, 0);
|
|
2625
2625
|
}
|
|
2626
2626
|
}
|
|
2627
2627
|
return o;
|
|
2628
2628
|
};
|
|
2629
|
-
class
|
|
2629
|
+
class Vc {
|
|
2630
2630
|
/**
|
|
2631
2631
|
* @param {DeleteSet} deletions
|
|
2632
2632
|
* @param {DeleteSet} insertions
|
|
@@ -2656,8 +2656,8 @@ const ms = (e, t, n) => {
|
|
|
2656
2656
|
Ot(c, a.insertions, (f) => {
|
|
2657
2657
|
if (f instanceof S) {
|
|
2658
2658
|
if (f.redone !== null) {
|
|
2659
|
-
let { item: g, diff: p } =
|
|
2660
|
-
p > 0 && (g =
|
|
2659
|
+
let { item: g, diff: p } = vl(l, f.id);
|
|
2660
|
+
p > 0 && (g = U(c, y(g.id.client, g.id.clock + p))), f = g;
|
|
2661
2661
|
}
|
|
2662
2662
|
!f.deleted && i.some((g) => g === c.doc || ye(
|
|
2663
2663
|
/** @type {AbstractType<any>} */
|
|
@@ -2674,7 +2674,7 @@ const ms = (e, t, n) => {
|
|
|
2674
2674
|
)) && // Never redo structs in stackItem.insertions because they were created and deleted in the same capture interval.
|
|
2675
2675
|
!Zt(a.insertions, f.id) && h.add(f);
|
|
2676
2676
|
}), h.forEach((f) => {
|
|
2677
|
-
d =
|
|
2677
|
+
d = zr(c, f, h, a.insertions, e.ignoreRemoteMapChanges, e) !== null || d;
|
|
2678
2678
|
});
|
|
2679
2679
|
for (let f = u.length - 1; f >= 0; f--) {
|
|
2680
2680
|
const g = u[f];
|
|
@@ -2693,7 +2693,7 @@ const ms = (e, t, n) => {
|
|
|
2693
2693
|
}
|
|
2694
2694
|
return o;
|
|
2695
2695
|
};
|
|
2696
|
-
class
|
|
2696
|
+
class jc extends mn {
|
|
2697
2697
|
/**
|
|
2698
2698
|
* @param {Doc|AbstractType<any>|Array<AbstractType<any>>} typeScope Limits the scope of the UndoManager. If this is set to a ydoc instance, all changes on that ydoc will be undone. If set to a specific type, only changes on that type or its children will be undone. Also accepts an array of types.
|
|
2699
2699
|
* @param {UndoManagerOptions} options
|
|
@@ -2706,7 +2706,7 @@ class Fc extends mn {
|
|
|
2706
2706
|
ignoreRemoteMapChanges: o = !1,
|
|
2707
2707
|
doc: c = (
|
|
2708
2708
|
/** @type {Doc} */
|
|
2709
|
-
|
|
2709
|
+
xt(t) ? t[0].doc : t instanceof mt ? t : t.doc
|
|
2710
2710
|
)
|
|
2711
2711
|
} = {}) {
|
|
2712
2712
|
super(), this.scope = [], this.doc = c, this.addToScope(t), this.deleteFilter = r, i.add(this), this.trackedOrigins = i, this.captureTransaction = s, this.undoStack = [], this.redoStack = [], this.undoing = !1, this.redoing = !1, this.currStackItem = null, this.lastChange = 0, this.ignoreRemoteMapChanges = o, this.captureTimeout = n, this.afterTransactionHandler = (l) => {
|
|
@@ -2728,7 +2728,7 @@ class Fc extends mn {
|
|
|
2728
2728
|
const b = u[u.length - 1];
|
|
2729
2729
|
b.deletions = ln([b.deletions, l.deleteSet]), b.insertions = ln([b.insertions, d]);
|
|
2730
2730
|
} else
|
|
2731
|
-
u.push(new
|
|
2731
|
+
u.push(new Vc(l.deleteSet, d)), g = !0;
|
|
2732
2732
|
!a && !h && (this.lastChange = f), Ot(
|
|
2733
2733
|
l,
|
|
2734
2734
|
l.deleteSet,
|
|
@@ -2752,8 +2752,8 @@ class Fc extends mn {
|
|
|
2752
2752
|
*/
|
|
2753
2753
|
addToScope(t) {
|
|
2754
2754
|
const n = new Set(this.scope);
|
|
2755
|
-
t =
|
|
2756
|
-
n.has(s) || (n.add(s), (s instanceof I ? s.doc !== this.doc : s !== this.doc) &&
|
|
2755
|
+
t = xt(t) ? t : [t], t.forEach((s) => {
|
|
2756
|
+
n.has(s) || (n.add(s), (s instanceof I ? s.doc !== this.doc : s !== this.doc) && hr("[yjs#509] Not same Y.Doc"), this.scope.push(s));
|
|
2757
2757
|
});
|
|
2758
2758
|
}
|
|
2759
2759
|
/**
|
|
@@ -2846,7 +2846,7 @@ class Fc extends mn {
|
|
|
2846
2846
|
this.trackedOrigins.delete(this), this.doc.off("afterTransaction", this.afterTransactionHandler), this.doc.off("destroy", this.destroy), super.destroy();
|
|
2847
2847
|
}
|
|
2848
2848
|
}
|
|
2849
|
-
function*
|
|
2849
|
+
function* Hc(e) {
|
|
2850
2850
|
const t = m(e.restDecoder);
|
|
2851
2851
|
for (let n = 0; n < t; n++) {
|
|
2852
2852
|
const s = m(e.restDecoder), r = e.readClient();
|
|
@@ -2856,7 +2856,7 @@ function* Vc(e) {
|
|
|
2856
2856
|
if (c === 10) {
|
|
2857
2857
|
const l = m(e.restDecoder);
|
|
2858
2858
|
yield new F(y(r, i), l), i += l;
|
|
2859
|
-
} else if ((
|
|
2859
|
+
} else if ((Te & c) !== 0) {
|
|
2860
2860
|
const l = (c & (W | $)) === 0, a = new S(
|
|
2861
2861
|
y(r, i),
|
|
2862
2862
|
null,
|
|
@@ -2872,7 +2872,7 @@ function* Vc(e) {
|
|
|
2872
2872
|
// parent
|
|
2873
2873
|
l && (c & jt) === jt ? e.readString() : null,
|
|
2874
2874
|
// parentSub
|
|
2875
|
-
|
|
2875
|
+
Pr(e, c)
|
|
2876
2876
|
// item content
|
|
2877
2877
|
);
|
|
2878
2878
|
yield a, i += a.length;
|
|
@@ -2889,7 +2889,7 @@ class Rn {
|
|
|
2889
2889
|
* @param {boolean} filterSkips
|
|
2890
2890
|
*/
|
|
2891
2891
|
constructor(t, n) {
|
|
2892
|
-
this.gen =
|
|
2892
|
+
this.gen = Hc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
2893
2893
|
}
|
|
2894
2894
|
/**
|
|
2895
2895
|
* @return {Item | GC | Skip |null}
|
|
@@ -2909,7 +2909,7 @@ class $n {
|
|
|
2909
2909
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
2910
2910
|
}
|
|
2911
2911
|
}
|
|
2912
|
-
const
|
|
2912
|
+
const zc = (e) => be(e, pr, te), Pc = (e, t) => {
|
|
2913
2913
|
if (e.constructor === B) {
|
|
2914
2914
|
const { client: n, clock: s } = e.id;
|
|
2915
2915
|
return new B(y(n, s + t), e.length - t);
|
|
@@ -2975,7 +2975,7 @@ const jc = (e) => be(e, gr, te), Hc = (e, t) => {
|
|
|
2975
2975
|
}
|
|
2976
2976
|
else {
|
|
2977
2977
|
const g = i.struct.id.clock + i.struct.length - d.id.clock;
|
|
2978
|
-
g > 0 && (i.struct.constructor === F ? i.struct.length -= g : d =
|
|
2978
|
+
g > 0 && (i.struct.constructor === F ? i.struct.length -= g : d = Pc(d, g)), i.struct.mergeWith(
|
|
2979
2979
|
/** @type {any} */
|
|
2980
2980
|
d
|
|
2981
2981
|
) || (et(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next());
|
|
@@ -2989,10 +2989,10 @@ const jc = (e) => be(e, gr, te), Hc = (e, t) => {
|
|
|
2989
2989
|
et(c, i.struct, i.offset), i = { struct: d, offset: 0 };
|
|
2990
2990
|
}
|
|
2991
2991
|
i !== null && (et(c, i.struct, i.offset), i = null), Bn(c);
|
|
2992
|
-
const l = s.map((h) =>
|
|
2992
|
+
const l = s.map((h) => vn(h)), a = ln(l);
|
|
2993
2993
|
return $t(o, a), o.toUint8Array();
|
|
2994
|
-
},
|
|
2995
|
-
const r =
|
|
2994
|
+
}, Yc = (e, t, n = Nt, s = ut) => {
|
|
2995
|
+
const r = br(t), i = new s(), o = new $n(i), c = new n(ct(e)), l = new Rn(c, !1);
|
|
2996
2996
|
for (; l.curr; ) {
|
|
2997
2997
|
const h = l.curr, u = h.id.client, d = r.get(u) || 0;
|
|
2998
2998
|
if (l.curr.constructor === F) {
|
|
@@ -3007,28 +3007,28 @@ const jc = (e) => be(e, gr, te), Hc = (e, t) => {
|
|
|
3007
3007
|
l.next();
|
|
3008
3008
|
}
|
|
3009
3009
|
Bn(o);
|
|
3010
|
-
const a =
|
|
3010
|
+
const a = vn(c);
|
|
3011
3011
|
return $t(i, a), i.toUint8Array();
|
|
3012
|
-
},
|
|
3012
|
+
}, Ar = (e) => {
|
|
3013
3013
|
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: C(e.encoder.restEncoder) }), e.encoder.restEncoder = N(), e.written = 0);
|
|
3014
3014
|
}, et = (e, t, n) => {
|
|
3015
|
-
e.written > 0 && e.currClient !== t.id.client &&
|
|
3015
|
+
e.written > 0 && e.currClient !== t.id.client && Ar(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), w(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
|
|
3016
3016
|
}, Bn = (e) => {
|
|
3017
|
-
|
|
3017
|
+
Ar(e);
|
|
3018
3018
|
const t = e.encoder.restEncoder;
|
|
3019
3019
|
w(t, e.clientStructs.length);
|
|
3020
3020
|
for (let n = 0; n < e.clientStructs.length; n++) {
|
|
3021
3021
|
const s = e.clientStructs[n];
|
|
3022
|
-
w(t, s.written),
|
|
3022
|
+
w(t, s.written), xe(t, s.restEncoder);
|
|
3023
3023
|
}
|
|
3024
|
-
},
|
|
3024
|
+
}, Gc = (e, t, n, s) => {
|
|
3025
3025
|
const r = new n(ct(e)), i = new Rn(r, !1), o = new s(), c = new $n(o);
|
|
3026
3026
|
for (let a = i.curr; a !== null; a = i.next())
|
|
3027
3027
|
et(c, t(a), 0);
|
|
3028
3028
|
Bn(c);
|
|
3029
|
-
const l =
|
|
3029
|
+
const l = vn(r);
|
|
3030
3030
|
return $t(o, l), o.toUint8Array();
|
|
3031
|
-
},
|
|
3031
|
+
}, Jc = (e) => Gc(e, ho, Nt, te), bs = "You must not compute changes after the event-handler fired.";
|
|
3032
3032
|
class Fe {
|
|
3033
3033
|
/**
|
|
3034
3034
|
* @param {T} target The changed type.
|
|
@@ -3051,7 +3051,7 @@ class Fe {
|
|
|
3051
3051
|
* type === event.target // => true
|
|
3052
3052
|
*/
|
|
3053
3053
|
get path() {
|
|
3054
|
-
return this._path || (this._path =
|
|
3054
|
+
return this._path || (this._path = Kc(this.currentTarget, this.target));
|
|
3055
3055
|
}
|
|
3056
3056
|
/**
|
|
3057
3057
|
* Check if a struct is deleted by this event.
|
|
@@ -3070,7 +3070,7 @@ class Fe {
|
|
|
3070
3070
|
get keys() {
|
|
3071
3071
|
if (this._keys === null) {
|
|
3072
3072
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
3073
|
-
throw
|
|
3073
|
+
throw P(bs);
|
|
3074
3074
|
const t = /* @__PURE__ */ new Map(), n = this.target;
|
|
3075
3075
|
/** @type Set<string|null> */
|
|
3076
3076
|
this.transaction.changed.get(n).forEach((r) => {
|
|
@@ -3138,7 +3138,7 @@ class Fe {
|
|
|
3138
3138
|
let t = this._changes;
|
|
3139
3139
|
if (t === null) {
|
|
3140
3140
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
3141
|
-
throw
|
|
3141
|
+
throw P(bs);
|
|
3142
3142
|
const n = this.target, s = rt(), r = rt(), i = [];
|
|
3143
3143
|
if (t = {
|
|
3144
3144
|
added: s,
|
|
@@ -3163,7 +3163,7 @@ class Fe {
|
|
|
3163
3163
|
);
|
|
3164
3164
|
}
|
|
3165
3165
|
}
|
|
3166
|
-
const
|
|
3166
|
+
const Kc = (e, t) => {
|
|
3167
3167
|
const n = [];
|
|
3168
3168
|
for (; t._item !== null && t !== e; ) {
|
|
3169
3169
|
if (t._item.parentSub !== null)
|
|
@@ -3182,10 +3182,10 @@ const Pc = (e, t) => {
|
|
|
3182
3182
|
}
|
|
3183
3183
|
return n;
|
|
3184
3184
|
}, M = () => {
|
|
3185
|
-
|
|
3186
|
-
},
|
|
3185
|
+
hr("Invalid access: Add Yjs type to a document before reading data.");
|
|
3186
|
+
}, Tr = 80;
|
|
3187
3187
|
let Fn = 0;
|
|
3188
|
-
class
|
|
3188
|
+
class Wc {
|
|
3189
3189
|
/**
|
|
3190
3190
|
* @param {Item} p
|
|
3191
3191
|
* @param {number} index
|
|
@@ -3194,16 +3194,16 @@ class Jc {
|
|
|
3194
3194
|
t.marker = !0, this.p = t, this.index = n, this.timestamp = Fn++;
|
|
3195
3195
|
}
|
|
3196
3196
|
}
|
|
3197
|
-
const
|
|
3197
|
+
const Xc = (e) => {
|
|
3198
3198
|
e.timestamp = Fn++;
|
|
3199
3199
|
}, xr = (e, t, n) => {
|
|
3200
3200
|
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = Fn++;
|
|
3201
|
-
},
|
|
3202
|
-
if (e.length >=
|
|
3201
|
+
}, qc = (e, t, n) => {
|
|
3202
|
+
if (e.length >= Tr) {
|
|
3203
3203
|
const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
3204
3204
|
return xr(s, t, n), s;
|
|
3205
3205
|
} else {
|
|
3206
|
-
const s = new
|
|
3206
|
+
const s = new Wc(t, n);
|
|
3207
3207
|
return e.push(s), s;
|
|
3208
3208
|
}
|
|
3209
3209
|
}, Ve = (e, t) => {
|
|
@@ -3211,7 +3211,7 @@ const Kc = (e) => {
|
|
|
3211
3211
|
return null;
|
|
3212
3212
|
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => ce(t - i.index) < ce(t - o.index) ? i : o);
|
|
3213
3213
|
let s = e._start, r = 0;
|
|
3214
|
-
for (n !== null && (s = n.p, r = n.index,
|
|
3214
|
+
for (n !== null && (s = n.p, r = n.index, Xc(n)); s.right !== null && r < t; ) {
|
|
3215
3215
|
if (!s.deleted && s.countable) {
|
|
3216
3216
|
if (t < r + s.length)
|
|
3217
3217
|
break;
|
|
@@ -3224,7 +3224,7 @@ const Kc = (e) => {
|
|
|
3224
3224
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
3225
3225
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
3226
3226
|
return n !== null && ce(n.index - r) < /** @type {YText|YArray<any>} */
|
|
3227
|
-
s.parent.length /
|
|
3227
|
+
s.parent.length / Tr ? (xr(n, s, r), n) : qc(e._searchMarker, s, r);
|
|
3228
3228
|
}, Kt = (e, t, n) => {
|
|
3229
3229
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
3230
3230
|
const r = e[s];
|
|
@@ -3245,7 +3245,7 @@ const Kc = (e) => {
|
|
|
3245
3245
|
for (; J(r, e, () => []).push(n), e._item !== null; )
|
|
3246
3246
|
e = /** @type {AbstractType<any>} */
|
|
3247
3247
|
e._item.parent;
|
|
3248
|
-
|
|
3248
|
+
_r(s._eH, n, t);
|
|
3249
3249
|
};
|
|
3250
3250
|
class I {
|
|
3251
3251
|
constructor() {
|
|
@@ -3352,7 +3352,7 @@ class I {
|
|
|
3352
3352
|
toJSON() {
|
|
3353
3353
|
}
|
|
3354
3354
|
}
|
|
3355
|
-
const
|
|
3355
|
+
const Ir = (e, t, n) => {
|
|
3356
3356
|
e.doc ?? M(), t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
|
|
3357
3357
|
let s = n - t;
|
|
3358
3358
|
const r = [];
|
|
@@ -3371,7 +3371,7 @@ const Tr = (e, t, n) => {
|
|
|
3371
3371
|
i = i.right;
|
|
3372
3372
|
}
|
|
3373
3373
|
return r;
|
|
3374
|
-
},
|
|
3374
|
+
}, Lr = (e) => {
|
|
3375
3375
|
e.doc ?? M();
|
|
3376
3376
|
const t = [];
|
|
3377
3377
|
let n = e._start;
|
|
@@ -3394,12 +3394,12 @@ const Tr = (e, t, n) => {
|
|
|
3394
3394
|
}
|
|
3395
3395
|
s = s.right;
|
|
3396
3396
|
}
|
|
3397
|
-
},
|
|
3397
|
+
}, Or = (e, t) => {
|
|
3398
3398
|
const n = [];
|
|
3399
3399
|
return Wt(e, (s, r) => {
|
|
3400
3400
|
n.push(t(s, r, e));
|
|
3401
3401
|
}), n;
|
|
3402
|
-
},
|
|
3402
|
+
}, Qc = (e) => {
|
|
3403
3403
|
let t = e._start, n = null, s = 0;
|
|
3404
3404
|
return {
|
|
3405
3405
|
[Symbol.iterator]() {
|
|
@@ -3423,7 +3423,7 @@ const Tr = (e, t, n) => {
|
|
|
3423
3423
|
};
|
|
3424
3424
|
}
|
|
3425
3425
|
};
|
|
3426
|
-
},
|
|
3426
|
+
}, Nr = (e, t) => {
|
|
3427
3427
|
e.doc ?? M();
|
|
3428
3428
|
const n = Ve(e, t);
|
|
3429
3429
|
let s = e._start;
|
|
@@ -3475,9 +3475,9 @@ const Tr = (e, t, n) => {
|
|
|
3475
3475
|
}
|
|
3476
3476
|
}
|
|
3477
3477
|
}), h();
|
|
3478
|
-
},
|
|
3478
|
+
}, Mr = () => P("Length exceeded!"), vr = (e, t, n, s) => {
|
|
3479
3479
|
if (n > t._length)
|
|
3480
|
-
throw
|
|
3480
|
+
throw Mr();
|
|
3481
3481
|
if (n === 0)
|
|
3482
3482
|
return t._searchMarker && Kt(t._searchMarker, n, s.length), ke(e, t, null, s);
|
|
3483
3483
|
const r = n, i = Ve(t, n);
|
|
@@ -3485,13 +3485,13 @@ const Tr = (e, t, n) => {
|
|
|
3485
3485
|
for (i !== null && (o = i.p, n -= i.index, n === 0 && (o = o.prev, n += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
|
|
3486
3486
|
if (!o.deleted && o.countable) {
|
|
3487
3487
|
if (n <= o.length) {
|
|
3488
|
-
n < o.length &&
|
|
3488
|
+
n < o.length && U(e, y(o.id.client, o.id.clock + n));
|
|
3489
3489
|
break;
|
|
3490
3490
|
}
|
|
3491
3491
|
n -= o.length;
|
|
3492
3492
|
}
|
|
3493
3493
|
return t._searchMarker && Kt(t._searchMarker, r, s.length), ke(e, t, o, s);
|
|
3494
|
-
},
|
|
3494
|
+
}, Zc = (e, t, n) => {
|
|
3495
3495
|
let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
|
|
3496
3496
|
if (r)
|
|
3497
3497
|
for (; r.right; )
|
|
@@ -3503,11 +3503,11 @@ const Tr = (e, t, n) => {
|
|
|
3503
3503
|
const r = n, i = s, o = Ve(t, n);
|
|
3504
3504
|
let c = t._start;
|
|
3505
3505
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
3506
|
-
!c.deleted && c.countable && (n < c.length &&
|
|
3506
|
+
!c.deleted && c.countable && (n < c.length && U(e, y(c.id.client, c.id.clock + n)), n -= c.length);
|
|
3507
3507
|
for (; s > 0 && c !== null; )
|
|
3508
|
-
c.deleted || (s < c.length &&
|
|
3508
|
+
c.deleted || (s < c.length && U(e, y(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
|
|
3509
3509
|
if (s > 0)
|
|
3510
|
-
throw
|
|
3510
|
+
throw Mr();
|
|
3511
3511
|
t._searchMarker && Kt(
|
|
3512
3512
|
t._searchMarker,
|
|
3513
3513
|
r,
|
|
@@ -3556,16 +3556,16 @@ const Tr = (e, t, n) => {
|
|
|
3556
3556
|
e.doc ?? M();
|
|
3557
3557
|
const n = e._map.get(t);
|
|
3558
3558
|
return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
|
|
3559
|
-
},
|
|
3559
|
+
}, Rr = (e) => {
|
|
3560
3560
|
const t = {};
|
|
3561
3561
|
return e.doc ?? M(), e._map.forEach((n, s) => {
|
|
3562
3562
|
n.deleted || (t[s] = n.content.getContent()[n.length - 1]);
|
|
3563
3563
|
}), t;
|
|
3564
|
-
},
|
|
3564
|
+
}, $r = (e, t) => {
|
|
3565
3565
|
e.doc ?? M();
|
|
3566
3566
|
const n = e._map.get(t);
|
|
3567
3567
|
return n !== void 0 && !n.deleted;
|
|
3568
|
-
},
|
|
3568
|
+
}, tl = (e, t) => {
|
|
3569
3569
|
const n = {};
|
|
3570
3570
|
return e._map.forEach((s, r) => {
|
|
3571
3571
|
let i = s;
|
|
@@ -3573,12 +3573,12 @@ const Tr = (e, t, n) => {
|
|
|
3573
3573
|
i = i.left;
|
|
3574
3574
|
i !== null && kt(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
|
|
3575
3575
|
}), n;
|
|
3576
|
-
}, ie = (e) => (e.doc ?? M(),
|
|
3576
|
+
}, ie = (e) => (e.doc ?? M(), pc(
|
|
3577
3577
|
e._map.entries(),
|
|
3578
3578
|
/** @param {any} entry */
|
|
3579
3579
|
(t) => !t[1].deleted
|
|
3580
3580
|
));
|
|
3581
|
-
class
|
|
3581
|
+
class el extends Fe {
|
|
3582
3582
|
}
|
|
3583
3583
|
class At extends I {
|
|
3584
3584
|
constructor() {
|
|
@@ -3643,7 +3643,7 @@ class At extends I {
|
|
|
3643
3643
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3644
3644
|
*/
|
|
3645
3645
|
_callObserver(t, n) {
|
|
3646
|
-
super._callObserver(t, n), je(this, t, new
|
|
3646
|
+
super._callObserver(t, n), je(this, t, new el(this, t));
|
|
3647
3647
|
}
|
|
3648
3648
|
/**
|
|
3649
3649
|
* Inserts new content at an index.
|
|
@@ -3663,7 +3663,7 @@ class At extends I {
|
|
|
3663
3663
|
*/
|
|
3664
3664
|
insert(t, n) {
|
|
3665
3665
|
this.doc !== null ? _(this.doc, (s) => {
|
|
3666
|
-
|
|
3666
|
+
vr(
|
|
3667
3667
|
s,
|
|
3668
3668
|
this,
|
|
3669
3669
|
t,
|
|
@@ -3681,7 +3681,7 @@ class At extends I {
|
|
|
3681
3681
|
*/
|
|
3682
3682
|
push(t) {
|
|
3683
3683
|
this.doc !== null ? _(this.doc, (n) => {
|
|
3684
|
-
|
|
3684
|
+
Zc(
|
|
3685
3685
|
n,
|
|
3686
3686
|
this,
|
|
3687
3687
|
/** @type {any} */
|
|
@@ -3715,7 +3715,7 @@ class At extends I {
|
|
|
3715
3715
|
* @return {T}
|
|
3716
3716
|
*/
|
|
3717
3717
|
get(t) {
|
|
3718
|
-
return
|
|
3718
|
+
return Nr(this, t);
|
|
3719
3719
|
}
|
|
3720
3720
|
/**
|
|
3721
3721
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -3723,7 +3723,7 @@ class At extends I {
|
|
|
3723
3723
|
* @return {Array<T>}
|
|
3724
3724
|
*/
|
|
3725
3725
|
toArray() {
|
|
3726
|
-
return
|
|
3726
|
+
return Lr(this);
|
|
3727
3727
|
}
|
|
3728
3728
|
/**
|
|
3729
3729
|
* Returns a portion of this YArray into a JavaScript Array selected
|
|
@@ -3734,7 +3734,7 @@ class At extends I {
|
|
|
3734
3734
|
* @return {Array<T>}
|
|
3735
3735
|
*/
|
|
3736
3736
|
slice(t = 0, n = this.length) {
|
|
3737
|
-
return
|
|
3737
|
+
return Ir(this, t, n);
|
|
3738
3738
|
}
|
|
3739
3739
|
/**
|
|
3740
3740
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3754,7 +3754,7 @@ class At extends I {
|
|
|
3754
3754
|
* callback function
|
|
3755
3755
|
*/
|
|
3756
3756
|
map(t) {
|
|
3757
|
-
return
|
|
3757
|
+
return Or(
|
|
3758
3758
|
this,
|
|
3759
3759
|
/** @type {any} */
|
|
3760
3760
|
t
|
|
@@ -3772,17 +3772,17 @@ class At extends I {
|
|
|
3772
3772
|
* @return {IterableIterator<T>}
|
|
3773
3773
|
*/
|
|
3774
3774
|
[Symbol.iterator]() {
|
|
3775
|
-
return
|
|
3775
|
+
return Qc(this);
|
|
3776
3776
|
}
|
|
3777
3777
|
/**
|
|
3778
3778
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3779
3779
|
*/
|
|
3780
3780
|
_write(t) {
|
|
3781
|
-
t.writeTypeRef(
|
|
3781
|
+
t.writeTypeRef(Al);
|
|
3782
3782
|
}
|
|
3783
3783
|
}
|
|
3784
|
-
const
|
|
3785
|
-
class
|
|
3784
|
+
const nl = (e) => new At();
|
|
3785
|
+
class sl extends Fe {
|
|
3786
3786
|
/**
|
|
3787
3787
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
3788
3788
|
* @param {Transaction} transaction
|
|
@@ -3844,7 +3844,7 @@ class Mt extends I {
|
|
|
3844
3844
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3845
3845
|
*/
|
|
3846
3846
|
_callObserver(t, n) {
|
|
3847
|
-
je(this, t, new
|
|
3847
|
+
je(this, t, new sl(this, t, n));
|
|
3848
3848
|
}
|
|
3849
3849
|
/**
|
|
3850
3850
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3974,7 +3974,7 @@ class Mt extends I {
|
|
|
3974
3974
|
* @return {boolean}
|
|
3975
3975
|
*/
|
|
3976
3976
|
has(t) {
|
|
3977
|
-
return
|
|
3977
|
+
return $r(this, t);
|
|
3978
3978
|
}
|
|
3979
3979
|
/**
|
|
3980
3980
|
* Removes all elements from this YMap.
|
|
@@ -3990,10 +3990,10 @@ class Mt extends I {
|
|
|
3990
3990
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3991
3991
|
*/
|
|
3992
3992
|
_write(t) {
|
|
3993
|
-
t.writeTypeRef(
|
|
3993
|
+
t.writeTypeRef(Tl);
|
|
3994
3994
|
}
|
|
3995
3995
|
}
|
|
3996
|
-
const
|
|
3996
|
+
const rl = (e) => new Mt(), nt = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && lo(e, t);
|
|
3997
3997
|
class un {
|
|
3998
3998
|
/**
|
|
3999
3999
|
* @param {Item|null} left
|
|
@@ -4008,7 +4008,7 @@ class un {
|
|
|
4008
4008
|
* Only call this if you know that this.right is defined
|
|
4009
4009
|
*/
|
|
4010
4010
|
forward() {
|
|
4011
|
-
this.right === null && V(), this.right.content.constructor ===
|
|
4011
|
+
this.right === null && V(), this.right.content.constructor === T ? this.right.deleted || Bt(
|
|
4012
4012
|
this.currentAttributes,
|
|
4013
4013
|
/** @type {ContentFormat} */
|
|
4014
4014
|
this.right.content
|
|
@@ -4017,11 +4017,11 @@ class un {
|
|
|
4017
4017
|
}
|
|
4018
4018
|
const ks = (e, t, n) => {
|
|
4019
4019
|
for (; t.right !== null && n > 0; )
|
|
4020
|
-
t.right.content.constructor ===
|
|
4020
|
+
t.right.content.constructor === T ? t.right.deleted || Bt(
|
|
4021
4021
|
t.currentAttributes,
|
|
4022
4022
|
/** @type {ContentFormat} */
|
|
4023
4023
|
t.right.content
|
|
4024
|
-
) : t.right.deleted || (n < t.right.length &&
|
|
4024
|
+
) : t.right.deleted || (n < t.right.length && U(e, y(t.right.id.client, t.right.id.clock + n)), t.index += t.right.length, n -= t.right.length), t.left = t.right, t.right = t.right.right;
|
|
4025
4025
|
return t;
|
|
4026
4026
|
}, oe = (e, t, n, s) => {
|
|
4027
4027
|
const r = /* @__PURE__ */ new Map(), i = s ? Ve(t, n) : null;
|
|
@@ -4032,8 +4032,8 @@ const ks = (e, t, n) => {
|
|
|
4032
4032
|
const o = new un(null, t._start, 0, r);
|
|
4033
4033
|
return ks(e, o, n);
|
|
4034
4034
|
}
|
|
4035
|
-
},
|
|
4036
|
-
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor ===
|
|
4035
|
+
}, Br = (e, t, n, s) => {
|
|
4036
|
+
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === T && nt(
|
|
4037
4037
|
s.get(
|
|
4038
4038
|
/** @type {ContentFormat} */
|
|
4039
4039
|
n.right.content.key
|
|
@@ -4047,15 +4047,15 @@ const ks = (e, t, n) => {
|
|
|
4047
4047
|
), n.forward();
|
|
4048
4048
|
const r = e.doc, i = r.clientID;
|
|
4049
4049
|
s.forEach((o, c) => {
|
|
4050
|
-
const l = n.left, a = n.right, h = new S(y(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new
|
|
4050
|
+
const l = n.left, a = n.right, h = new S(y(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new T(c, o));
|
|
4051
4051
|
h.integrate(e, 0), n.right = h, n.forward();
|
|
4052
4052
|
});
|
|
4053
4053
|
}, Bt = (e, t) => {
|
|
4054
4054
|
const { key: n, value: s } = t;
|
|
4055
4055
|
s === null ? e.delete(n) : e.set(n, s);
|
|
4056
|
-
},
|
|
4056
|
+
}, Fr = (e, t) => {
|
|
4057
4057
|
for (; e.right !== null; ) {
|
|
4058
|
-
if (!(e.right.deleted || e.right.content.constructor ===
|
|
4058
|
+
if (!(e.right.deleted || e.right.content.constructor === T && nt(
|
|
4059
4059
|
t[
|
|
4060
4060
|
/** @type {ContentFormat} */
|
|
4061
4061
|
e.right.content.key
|
|
@@ -4065,14 +4065,14 @@ const ks = (e, t, n) => {
|
|
|
4065
4065
|
))) break;
|
|
4066
4066
|
e.forward();
|
|
4067
4067
|
}
|
|
4068
|
-
},
|
|
4068
|
+
}, Vr = (e, t, n, s) => {
|
|
4069
4069
|
const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
4070
4070
|
for (const c in s) {
|
|
4071
4071
|
const l = s[c], a = n.currentAttributes.get(c) ?? null;
|
|
4072
4072
|
if (!nt(a, l)) {
|
|
4073
4073
|
o.set(c, a);
|
|
4074
4074
|
const { left: h, right: u } = n;
|
|
4075
|
-
n.right = new S(y(i, A(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new
|
|
4075
|
+
n.right = new S(y(i, A(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new T(c, l)), n.right.integrate(e, 0), n.forward();
|
|
4076
4076
|
}
|
|
4077
4077
|
}
|
|
4078
4078
|
return o;
|
|
@@ -4081,21 +4081,21 @@ const ks = (e, t, n) => {
|
|
|
4081
4081
|
r[f] === void 0 && (r[f] = null);
|
|
4082
4082
|
});
|
|
4083
4083
|
const i = e.doc, o = i.clientID;
|
|
4084
|
-
|
|
4085
|
-
const c =
|
|
4084
|
+
Fr(n, r);
|
|
4085
|
+
const c = Vr(e, t, n, r), l = s.constructor === String ? new G(
|
|
4086
4086
|
/** @type {string} */
|
|
4087
4087
|
s
|
|
4088
4088
|
) : s instanceof I ? new tt(s) : new yt(s);
|
|
4089
4089
|
let { left: a, right: h, index: u } = n;
|
|
4090
|
-
t._searchMarker && Kt(t._searchMarker, n.index, l.getLength()), h = new S(y(o, A(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = u, n.forward(),
|
|
4090
|
+
t._searchMarker && Kt(t._searchMarker, n.index, l.getLength()), h = new S(y(o, A(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = u, n.forward(), Br(e, t, n, c);
|
|
4091
4091
|
}, _s = (e, t, n, s, r) => {
|
|
4092
4092
|
const i = e.doc, o = i.clientID;
|
|
4093
|
-
|
|
4094
|
-
const c =
|
|
4095
|
-
t: for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor ===
|
|
4093
|
+
Fr(n, r);
|
|
4094
|
+
const c = Vr(e, t, n, r);
|
|
4095
|
+
t: for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === T)); ) {
|
|
4096
4096
|
if (!n.right.deleted)
|
|
4097
4097
|
switch (n.right.content.constructor) {
|
|
4098
|
-
case
|
|
4098
|
+
case T: {
|
|
4099
4099
|
const { key: l, value: a } = (
|
|
4100
4100
|
/** @type {ContentFormat} */
|
|
4101
4101
|
n.right.content
|
|
@@ -4114,7 +4114,7 @@ const ks = (e, t, n) => {
|
|
|
4114
4114
|
break;
|
|
4115
4115
|
}
|
|
4116
4116
|
default:
|
|
4117
|
-
s < n.right.length &&
|
|
4117
|
+
s < n.right.length && U(e, y(n.right.id.client, n.right.id.clock + s)), s -= n.right.length;
|
|
4118
4118
|
break;
|
|
4119
4119
|
}
|
|
4120
4120
|
n.forward();
|
|
@@ -4124,14 +4124,14 @@ const ks = (e, t, n) => {
|
|
|
4124
4124
|
for (; s > 0; s--)
|
|
4125
4125
|
l += `
|
|
4126
4126
|
`;
|
|
4127
|
-
n.right = new S(y(o, A(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new
|
|
4127
|
+
n.right = new S(y(o, A(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new G(l)), n.right.integrate(e, 0), n.forward();
|
|
4128
4128
|
}
|
|
4129
|
-
|
|
4130
|
-
},
|
|
4129
|
+
Br(e, t, n, c);
|
|
4130
|
+
}, jr = (e, t, n, s, r) => {
|
|
4131
4131
|
let i = t;
|
|
4132
4132
|
const o = R();
|
|
4133
4133
|
for (; i && (!i.countable || i.deleted); ) {
|
|
4134
|
-
if (!i.deleted && i.content.constructor ===
|
|
4134
|
+
if (!i.deleted && i.content.constructor === T) {
|
|
4135
4135
|
const a = (
|
|
4136
4136
|
/** @type {ContentFormat} */
|
|
4137
4137
|
i.content
|
|
@@ -4144,7 +4144,7 @@ const ks = (e, t, n) => {
|
|
|
4144
4144
|
for (; t !== i; ) {
|
|
4145
4145
|
if (n === t && (l = !0), !t.deleted) {
|
|
4146
4146
|
const a = t.content;
|
|
4147
|
-
if (a.constructor ===
|
|
4147
|
+
if (a.constructor === T) {
|
|
4148
4148
|
const { key: h, value: u } = (
|
|
4149
4149
|
/** @type {ContentFormat} */
|
|
4150
4150
|
a
|
|
@@ -4160,12 +4160,12 @@ const ks = (e, t, n) => {
|
|
|
4160
4160
|
t.right;
|
|
4161
4161
|
}
|
|
4162
4162
|
return c;
|
|
4163
|
-
},
|
|
4163
|
+
}, il = (e, t) => {
|
|
4164
4164
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
4165
4165
|
t = t.right;
|
|
4166
4166
|
const n = /* @__PURE__ */ new Set();
|
|
4167
4167
|
for (; t && (t.deleted || !t.countable); ) {
|
|
4168
|
-
if (!t.deleted && t.content.constructor ===
|
|
4168
|
+
if (!t.deleted && t.content.constructor === T) {
|
|
4169
4169
|
const s = (
|
|
4170
4170
|
/** @type {ContentFormat} */
|
|
4171
4171
|
t.content.key
|
|
@@ -4174,7 +4174,7 @@ const ks = (e, t, n) => {
|
|
|
4174
4174
|
}
|
|
4175
4175
|
t = t.left;
|
|
4176
4176
|
}
|
|
4177
|
-
},
|
|
4177
|
+
}, ol = (e) => {
|
|
4178
4178
|
let t = 0;
|
|
4179
4179
|
return _(
|
|
4180
4180
|
/** @type {Doc} */
|
|
@@ -4186,18 +4186,18 @@ const ks = (e, t, n) => {
|
|
|
4186
4186
|
), r = e._start, i = R();
|
|
4187
4187
|
const o = en(i);
|
|
4188
4188
|
for (; r; )
|
|
4189
|
-
r.deleted === !1 && (r.content.constructor ===
|
|
4189
|
+
r.deleted === !1 && (r.content.constructor === T ? Bt(
|
|
4190
4190
|
o,
|
|
4191
4191
|
/** @type {ContentFormat} */
|
|
4192
4192
|
r.content
|
|
4193
|
-
) : (t +=
|
|
4193
|
+
) : (t += jr(n, s, r, i, o), i = en(o), s = r)), r = r.right;
|
|
4194
4194
|
}
|
|
4195
4195
|
), t;
|
|
4196
|
-
},
|
|
4196
|
+
}, cl = (e) => {
|
|
4197
4197
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
4198
4198
|
for (const [s, r] of e.afterState.entries()) {
|
|
4199
4199
|
const i = e.beforeState.get(s) || 0;
|
|
4200
|
-
r !== i &&
|
|
4200
|
+
r !== i && Er(
|
|
4201
4201
|
e,
|
|
4202
4202
|
/** @type {Array<Item|GC>} */
|
|
4203
4203
|
n.store.clients.get(s),
|
|
@@ -4205,7 +4205,7 @@ const ks = (e, t, n) => {
|
|
|
4205
4205
|
r,
|
|
4206
4206
|
(o) => {
|
|
4207
4207
|
!o.deleted && /** @type {Item} */
|
|
4208
|
-
o.content.constructor ===
|
|
4208
|
+
o.content.constructor === T && o.constructor !== B && t.add(
|
|
4209
4209
|
/** @type {any} */
|
|
4210
4210
|
o.parent
|
|
4211
4211
|
);
|
|
@@ -4224,10 +4224,10 @@ const ks = (e, t, n) => {
|
|
|
4224
4224
|
/** @type {YText} */
|
|
4225
4225
|
r.parent
|
|
4226
4226
|
);
|
|
4227
|
-
r.content.constructor ===
|
|
4227
|
+
r.content.constructor === T ? t.add(i) : il(s, r);
|
|
4228
4228
|
});
|
|
4229
4229
|
for (const r of t)
|
|
4230
|
-
|
|
4230
|
+
ol(r);
|
|
4231
4231
|
});
|
|
4232
4232
|
}, Ss = (e, t, n) => {
|
|
4233
4233
|
const s = n, r = en(t.currentAttributes), i = t.right;
|
|
@@ -4236,13 +4236,13 @@ const ks = (e, t, n) => {
|
|
|
4236
4236
|
switch (t.right.content.constructor) {
|
|
4237
4237
|
case tt:
|
|
4238
4238
|
case yt:
|
|
4239
|
-
case
|
|
4240
|
-
n < t.right.length &&
|
|
4239
|
+
case G:
|
|
4240
|
+
n < t.right.length && U(e, y(t.right.id.client, t.right.id.clock + n)), n -= t.right.length, t.right.delete(e);
|
|
4241
4241
|
break;
|
|
4242
4242
|
}
|
|
4243
4243
|
t.forward();
|
|
4244
4244
|
}
|
|
4245
|
-
i &&
|
|
4245
|
+
i && jr(e, i, t.right, r, t.currentAttributes);
|
|
4246
4246
|
const o = (
|
|
4247
4247
|
/** @type {AbstractType<any>} */
|
|
4248
4248
|
/** @type {Item} */
|
|
@@ -4250,7 +4250,7 @@ const ks = (e, t, n) => {
|
|
|
4250
4250
|
);
|
|
4251
4251
|
return o._searchMarker && Kt(o._searchMarker, t.index, -s + n), t;
|
|
4252
4252
|
};
|
|
4253
|
-
class
|
|
4253
|
+
class ll extends Fe {
|
|
4254
4254
|
/**
|
|
4255
4255
|
* @param {YText} ytext
|
|
4256
4256
|
* @param {Transaction} transaction
|
|
@@ -4311,7 +4311,7 @@ class ol extends Fe {
|
|
|
4311
4311
|
}))), a = "";
|
|
4312
4312
|
break;
|
|
4313
4313
|
case "retain":
|
|
4314
|
-
h > 0 && (f = { retain: h },
|
|
4314
|
+
h > 0 && (f = { retain: h }, co(l) || (f.attributes = so({}, l))), h = 0;
|
|
4315
4315
|
break;
|
|
4316
4316
|
}
|
|
4317
4317
|
f && n.push(f), c = null;
|
|
@@ -4323,11 +4323,11 @@ class ol extends Fe {
|
|
|
4323
4323
|
case yt:
|
|
4324
4324
|
this.adds(o) ? this.deletes(o) || (d(), c = "insert", a = o.content.getContent()[0], d()) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += 1) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += 1);
|
|
4325
4325
|
break;
|
|
4326
|
-
case
|
|
4326
|
+
case G:
|
|
4327
4327
|
this.adds(o) ? this.deletes(o) || (c !== "insert" && (d(), c = "insert"), a += /** @type {ContentString} */
|
|
4328
4328
|
o.content.str) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += o.length) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += o.length);
|
|
4329
4329
|
break;
|
|
4330
|
-
case
|
|
4330
|
+
case T: {
|
|
4331
4331
|
const { key: f, value: g } = (
|
|
4332
4332
|
/** @type {ContentFormat} */
|
|
4333
4333
|
o.content
|
|
@@ -4371,7 +4371,7 @@ class ol extends Fe {
|
|
|
4371
4371
|
);
|
|
4372
4372
|
}
|
|
4373
4373
|
}
|
|
4374
|
-
class
|
|
4374
|
+
class vt extends I {
|
|
4375
4375
|
/**
|
|
4376
4376
|
* @param {String} [string] The initial value of the YText.
|
|
4377
4377
|
*/
|
|
@@ -4400,7 +4400,7 @@ class Ut extends I {
|
|
|
4400
4400
|
this._pending = null;
|
|
4401
4401
|
}
|
|
4402
4402
|
_copy() {
|
|
4403
|
-
return new
|
|
4403
|
+
return new vt();
|
|
4404
4404
|
}
|
|
4405
4405
|
/**
|
|
4406
4406
|
* Makes a copy of this data type that can be included somewhere else.
|
|
@@ -4410,7 +4410,7 @@ class Ut extends I {
|
|
|
4410
4410
|
* @return {YText}
|
|
4411
4411
|
*/
|
|
4412
4412
|
clone() {
|
|
4413
|
-
const t = new
|
|
4413
|
+
const t = new vt();
|
|
4414
4414
|
return t.applyDelta(this.toDelta()), t;
|
|
4415
4415
|
}
|
|
4416
4416
|
/**
|
|
@@ -4421,7 +4421,7 @@ class Ut extends I {
|
|
|
4421
4421
|
*/
|
|
4422
4422
|
_callObserver(t, n) {
|
|
4423
4423
|
super._callObserver(t, n);
|
|
4424
|
-
const s = new
|
|
4424
|
+
const s = new ll(this, t, n);
|
|
4425
4425
|
je(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
4426
4426
|
}
|
|
4427
4427
|
/**
|
|
@@ -4433,7 +4433,7 @@ class Ut extends I {
|
|
|
4433
4433
|
this.doc ?? M();
|
|
4434
4434
|
let t = "", n = this._start;
|
|
4435
4435
|
for (; n !== null; )
|
|
4436
|
-
!n.deleted && n.countable && n.content.constructor ===
|
|
4436
|
+
!n.deleted && n.countable && n.content.constructor === G && (t += /** @type {ContentString} */
|
|
4437
4437
|
n.content.str), n = n.right;
|
|
4438
4438
|
return t;
|
|
4439
4439
|
}
|
|
@@ -4501,7 +4501,7 @@ class Ut extends I {
|
|
|
4501
4501
|
for (; l !== null; ) {
|
|
4502
4502
|
if (kt(l, t) || n !== void 0 && kt(l, n))
|
|
4503
4503
|
switch (l.content.constructor) {
|
|
4504
|
-
case
|
|
4504
|
+
case G: {
|
|
4505
4505
|
const u = i.get("ychange");
|
|
4506
4506
|
t !== void 0 && !kt(l, t) ? (u === void 0 || u.user !== l.id.client || u.type !== "removed") && (a(), i.set("ychange", s ? s("removed", l.id) : { type: "removed" })) : n !== void 0 && !kt(l, n) ? (u === void 0 || u.user !== l.id.client || u.type !== "added") && (a(), i.set("ychange", s ? s("added", l.id) : { type: "added" })) : u !== void 0 && (a(), i.delete("ychange")), c += /** @type {ContentString} */
|
|
4507
4507
|
l.content.str;
|
|
@@ -4525,7 +4525,7 @@ class Ut extends I {
|
|
|
4525
4525
|
r.push(u);
|
|
4526
4526
|
break;
|
|
4527
4527
|
}
|
|
4528
|
-
case
|
|
4528
|
+
case T:
|
|
4529
4529
|
kt(l, t) && (a(), Bt(
|
|
4530
4530
|
i,
|
|
4531
4531
|
/** @type {ContentFormat} */
|
|
@@ -4670,16 +4670,16 @@ class Ut extends I {
|
|
|
4670
4670
|
* @public
|
|
4671
4671
|
*/
|
|
4672
4672
|
getAttributes() {
|
|
4673
|
-
return
|
|
4673
|
+
return Rr(this);
|
|
4674
4674
|
}
|
|
4675
4675
|
/**
|
|
4676
4676
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4677
4677
|
*/
|
|
4678
4678
|
_write(t) {
|
|
4679
|
-
t.writeTypeRef(
|
|
4679
|
+
t.writeTypeRef(xl);
|
|
4680
4680
|
}
|
|
4681
4681
|
}
|
|
4682
|
-
const
|
|
4682
|
+
const al = (e) => new vt();
|
|
4683
4683
|
class qe {
|
|
4684
4684
|
/**
|
|
4685
4685
|
* @param {YXmlFragment | YXmlElement} root
|
|
@@ -4832,7 +4832,7 @@ class dt extends I {
|
|
|
4832
4832
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
4833
4833
|
*/
|
|
4834
4834
|
_callObserver(t, n) {
|
|
4835
|
-
je(this, t, new
|
|
4835
|
+
je(this, t, new dl(this, n, t));
|
|
4836
4836
|
}
|
|
4837
4837
|
/**
|
|
4838
4838
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -4840,7 +4840,7 @@ class dt extends I {
|
|
|
4840
4840
|
* @return {string} The string representation of all children.
|
|
4841
4841
|
*/
|
|
4842
4842
|
toString() {
|
|
4843
|
-
return
|
|
4843
|
+
return Or(this, (t) => t.toString()).join("");
|
|
4844
4844
|
}
|
|
4845
4845
|
/**
|
|
4846
4846
|
* @return {string}
|
|
@@ -4881,7 +4881,7 @@ class dt extends I {
|
|
|
4881
4881
|
*/
|
|
4882
4882
|
insert(t, n) {
|
|
4883
4883
|
this.doc !== null ? _(this.doc, (s) => {
|
|
4884
|
-
|
|
4884
|
+
vr(s, this, t, n);
|
|
4885
4885
|
}) : this._prelimContent.splice(t, 0, ...n);
|
|
4886
4886
|
}
|
|
4887
4887
|
/**
|
|
@@ -4906,7 +4906,7 @@ class dt extends I {
|
|
|
4906
4906
|
this._prelimContent
|
|
4907
4907
|
), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
|
|
4908
4908
|
if (r === 0 && t !== null)
|
|
4909
|
-
throw
|
|
4909
|
+
throw P("Reference item not found");
|
|
4910
4910
|
s.splice(r, 0, ...n);
|
|
4911
4911
|
}
|
|
4912
4912
|
}
|
|
@@ -4927,7 +4927,7 @@ class dt extends I {
|
|
|
4927
4927
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
4928
4928
|
*/
|
|
4929
4929
|
toArray() {
|
|
4930
|
-
return
|
|
4930
|
+
return Lr(this);
|
|
4931
4931
|
}
|
|
4932
4932
|
/**
|
|
4933
4933
|
* Appends content to this YArray.
|
|
@@ -4952,7 +4952,7 @@ class dt extends I {
|
|
|
4952
4952
|
* @return {YXmlElement|YXmlText}
|
|
4953
4953
|
*/
|
|
4954
4954
|
get(t) {
|
|
4955
|
-
return
|
|
4955
|
+
return Nr(this, t);
|
|
4956
4956
|
}
|
|
4957
4957
|
/**
|
|
4958
4958
|
* Returns a portion of this YXmlFragment into a JavaScript Array selected
|
|
@@ -4963,7 +4963,7 @@ class dt extends I {
|
|
|
4963
4963
|
* @return {Array<YXmlElement|YXmlText>}
|
|
4964
4964
|
*/
|
|
4965
4965
|
slice(t = 0, n = this.length) {
|
|
4966
|
-
return
|
|
4966
|
+
return Ir(this, t, n);
|
|
4967
4967
|
}
|
|
4968
4968
|
/**
|
|
4969
4969
|
* Executes a provided function on once on every child element.
|
|
@@ -4982,10 +4982,10 @@ class dt extends I {
|
|
|
4982
4982
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4983
4983
|
*/
|
|
4984
4984
|
_write(t) {
|
|
4985
|
-
t.writeTypeRef(
|
|
4985
|
+
t.writeTypeRef(Ll);
|
|
4986
4986
|
}
|
|
4987
4987
|
}
|
|
4988
|
-
const
|
|
4988
|
+
const hl = (e) => new dt();
|
|
4989
4989
|
class q extends dt {
|
|
4990
4990
|
constructor(t = "UNDEFINED") {
|
|
4991
4991
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
@@ -5045,7 +5045,7 @@ class q extends dt {
|
|
|
5045
5045
|
*/
|
|
5046
5046
|
clone() {
|
|
5047
5047
|
const t = new q(this.nodeName), n = this.getAttributes();
|
|
5048
|
-
return
|
|
5048
|
+
return io(n, (s, r) => {
|
|
5049
5049
|
t.setAttribute(
|
|
5050
5050
|
r,
|
|
5051
5051
|
/** @type {any} */
|
|
@@ -5130,7 +5130,7 @@ class q extends dt {
|
|
|
5130
5130
|
hasAttribute(t) {
|
|
5131
5131
|
return (
|
|
5132
5132
|
/** @type {any} */
|
|
5133
|
-
|
|
5133
|
+
$r(this, t)
|
|
5134
5134
|
);
|
|
5135
5135
|
}
|
|
5136
5136
|
/**
|
|
@@ -5144,7 +5144,7 @@ class q extends dt {
|
|
|
5144
5144
|
getAttributes(t) {
|
|
5145
5145
|
return (
|
|
5146
5146
|
/** @type {any} */
|
|
5147
|
-
t ?
|
|
5147
|
+
t ? tl(this, t) : Rr(this)
|
|
5148
5148
|
);
|
|
5149
5149
|
}
|
|
5150
5150
|
/**
|
|
@@ -5181,11 +5181,11 @@ class q extends dt {
|
|
|
5181
5181
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
5182
5182
|
*/
|
|
5183
5183
|
_write(t) {
|
|
5184
|
-
t.writeTypeRef(
|
|
5184
|
+
t.writeTypeRef(Il), t.writeKey(this.nodeName);
|
|
5185
5185
|
}
|
|
5186
5186
|
}
|
|
5187
|
-
const
|
|
5188
|
-
class
|
|
5187
|
+
const ul = (e) => new q(e.readKey());
|
|
5188
|
+
class dl extends Fe {
|
|
5189
5189
|
/**
|
|
5190
5190
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
5191
5191
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -5254,11 +5254,11 @@ class Se extends Mt {
|
|
|
5254
5254
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
5255
5255
|
*/
|
|
5256
5256
|
_write(t) {
|
|
5257
|
-
t.writeTypeRef(
|
|
5257
|
+
t.writeTypeRef(Ol), t.writeKey(this.hookName);
|
|
5258
5258
|
}
|
|
5259
5259
|
}
|
|
5260
|
-
const
|
|
5261
|
-
class Q extends
|
|
5260
|
+
const fl = (e) => new Se(e.readKey());
|
|
5261
|
+
class Q extends vt {
|
|
5262
5262
|
/**
|
|
5263
5263
|
* @type {YXmlElement|YXmlText|null}
|
|
5264
5264
|
*/
|
|
@@ -5350,10 +5350,10 @@ class Q extends Ut {
|
|
|
5350
5350
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
5351
5351
|
*/
|
|
5352
5352
|
_write(t) {
|
|
5353
|
-
t.writeTypeRef(
|
|
5353
|
+
t.writeTypeRef(Nl);
|
|
5354
5354
|
}
|
|
5355
5355
|
}
|
|
5356
|
-
const
|
|
5356
|
+
const gl = (e) => new Q();
|
|
5357
5357
|
class Hn {
|
|
5358
5358
|
/**
|
|
5359
5359
|
* @param {ID} id
|
|
@@ -5394,7 +5394,7 @@ class Hn {
|
|
|
5394
5394
|
throw j();
|
|
5395
5395
|
}
|
|
5396
5396
|
}
|
|
5397
|
-
const
|
|
5397
|
+
const pl = 0;
|
|
5398
5398
|
class B extends Hn {
|
|
5399
5399
|
get deleted() {
|
|
5400
5400
|
return !0;
|
|
@@ -5413,14 +5413,14 @@ class B extends Hn {
|
|
|
5413
5413
|
* @param {number} offset
|
|
5414
5414
|
*/
|
|
5415
5415
|
integrate(t, n) {
|
|
5416
|
-
n > 0 && (this.id.clock += n, this.length -= n),
|
|
5416
|
+
n > 0 && (this.id.clock += n, this.length -= n), Cr(t.doc.store, this);
|
|
5417
5417
|
}
|
|
5418
5418
|
/**
|
|
5419
5419
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
5420
5420
|
* @param {number} offset
|
|
5421
5421
|
*/
|
|
5422
5422
|
write(t, n) {
|
|
5423
|
-
t.writeInfo(
|
|
5423
|
+
t.writeInfo(pl), t.writeLen(this.length - n);
|
|
5424
5424
|
}
|
|
5425
5425
|
/**
|
|
5426
5426
|
* @param {Transaction} transaction
|
|
@@ -5506,7 +5506,7 @@ class ee {
|
|
|
5506
5506
|
return 3;
|
|
5507
5507
|
}
|
|
5508
5508
|
}
|
|
5509
|
-
const
|
|
5509
|
+
const wl = (e) => new ee(e.readBuf());
|
|
5510
5510
|
class Xt {
|
|
5511
5511
|
/**
|
|
5512
5512
|
* @param {number} len
|
|
@@ -5584,7 +5584,7 @@ class Xt {
|
|
|
5584
5584
|
return 1;
|
|
5585
5585
|
}
|
|
5586
5586
|
}
|
|
5587
|
-
const
|
|
5587
|
+
const ml = (e) => new Xt(e.readLen()), Hr = (e, t) => new mt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
5588
5588
|
class ne {
|
|
5589
5589
|
/**
|
|
5590
5590
|
* @param {Doc} doc
|
|
@@ -5616,7 +5616,7 @@ class ne {
|
|
|
5616
5616
|
* @return {ContentDoc}
|
|
5617
5617
|
*/
|
|
5618
5618
|
copy() {
|
|
5619
|
-
return new ne(
|
|
5619
|
+
return new ne(Hr(this.doc.guid, this.opts));
|
|
5620
5620
|
}
|
|
5621
5621
|
/**
|
|
5622
5622
|
* @param {number} offset
|
|
@@ -5664,7 +5664,7 @@ class ne {
|
|
|
5664
5664
|
return 9;
|
|
5665
5665
|
}
|
|
5666
5666
|
}
|
|
5667
|
-
const
|
|
5667
|
+
const yl = (e) => new ne(Hr(e.readString(), e.readAny()));
|
|
5668
5668
|
class yt {
|
|
5669
5669
|
/**
|
|
5670
5670
|
* @param {Object} embed
|
|
@@ -5740,8 +5740,8 @@ class yt {
|
|
|
5740
5740
|
return 5;
|
|
5741
5741
|
}
|
|
5742
5742
|
}
|
|
5743
|
-
const
|
|
5744
|
-
class
|
|
5743
|
+
const bl = (e) => new yt(e.readJSON());
|
|
5744
|
+
class T {
|
|
5745
5745
|
/**
|
|
5746
5746
|
* @param {string} key
|
|
5747
5747
|
* @param {Object} value
|
|
@@ -5771,7 +5771,7 @@ class x {
|
|
|
5771
5771
|
* @return {ContentFormat}
|
|
5772
5772
|
*/
|
|
5773
5773
|
copy() {
|
|
5774
|
-
return new
|
|
5774
|
+
return new T(this.key, this.value);
|
|
5775
5775
|
}
|
|
5776
5776
|
/**
|
|
5777
5777
|
* @param {number} _offset
|
|
@@ -5822,7 +5822,7 @@ class x {
|
|
|
5822
5822
|
return 6;
|
|
5823
5823
|
}
|
|
5824
5824
|
}
|
|
5825
|
-
const
|
|
5825
|
+
const kl = (e) => new T(e.readKey(), e.readJSON());
|
|
5826
5826
|
class Ce {
|
|
5827
5827
|
/**
|
|
5828
5828
|
* @param {Array<any>} arr
|
|
@@ -5904,20 +5904,20 @@ class Ce {
|
|
|
5904
5904
|
return 2;
|
|
5905
5905
|
}
|
|
5906
5906
|
}
|
|
5907
|
-
const
|
|
5907
|
+
const _l = (e) => {
|
|
5908
5908
|
const t = e.readLen(), n = [];
|
|
5909
5909
|
for (let s = 0; s < t; s++) {
|
|
5910
5910
|
const r = e.readString();
|
|
5911
5911
|
r === "undefined" ? n.push(void 0) : n.push(JSON.parse(r));
|
|
5912
5912
|
}
|
|
5913
5913
|
return new Ce(n);
|
|
5914
|
-
},
|
|
5914
|
+
}, Sl = pe("node_env") === "development";
|
|
5915
5915
|
class ft {
|
|
5916
5916
|
/**
|
|
5917
5917
|
* @param {Array<any>} arr
|
|
5918
5918
|
*/
|
|
5919
5919
|
constructor(t) {
|
|
5920
|
-
this.arr = t,
|
|
5920
|
+
this.arr = t, Sl && Vs(t);
|
|
5921
5921
|
}
|
|
5922
5922
|
/**
|
|
5923
5923
|
* @return {number}
|
|
@@ -5993,13 +5993,13 @@ class ft {
|
|
|
5993
5993
|
return 8;
|
|
5994
5994
|
}
|
|
5995
5995
|
}
|
|
5996
|
-
const
|
|
5996
|
+
const Cl = (e) => {
|
|
5997
5997
|
const t = e.readLen(), n = [];
|
|
5998
5998
|
for (let s = 0; s < t; s++)
|
|
5999
5999
|
n.push(e.readAny());
|
|
6000
6000
|
return new ft(n);
|
|
6001
6001
|
};
|
|
6002
|
-
class
|
|
6002
|
+
class G {
|
|
6003
6003
|
/**
|
|
6004
6004
|
* @param {string} str
|
|
6005
6005
|
*/
|
|
@@ -6028,14 +6028,14 @@ class P {
|
|
|
6028
6028
|
* @return {ContentString}
|
|
6029
6029
|
*/
|
|
6030
6030
|
copy() {
|
|
6031
|
-
return new
|
|
6031
|
+
return new G(this.str);
|
|
6032
6032
|
}
|
|
6033
6033
|
/**
|
|
6034
6034
|
* @param {number} offset
|
|
6035
6035
|
* @return {ContentString}
|
|
6036
6036
|
*/
|
|
6037
6037
|
splice(t) {
|
|
6038
|
-
const n = new
|
|
6038
|
+
const n = new G(this.str.slice(t));
|
|
6039
6039
|
this.str = this.str.slice(0, t);
|
|
6040
6040
|
const s = this.str.charCodeAt(t - 1);
|
|
6041
6041
|
return s >= 55296 && s <= 56319 && (this.str = this.str.slice(0, t - 1) + "�", n.str = "�" + n.str.slice(1)), n;
|
|
@@ -6077,15 +6077,15 @@ class P {
|
|
|
6077
6077
|
return 4;
|
|
6078
6078
|
}
|
|
6079
6079
|
}
|
|
6080
|
-
const
|
|
6081
|
-
tl,
|
|
6080
|
+
const El = (e) => new G(e.readString()), Dl = [
|
|
6082
6081
|
nl,
|
|
6083
|
-
|
|
6082
|
+
rl,
|
|
6084
6083
|
al,
|
|
6085
|
-
ll,
|
|
6086
6084
|
ul,
|
|
6087
|
-
|
|
6088
|
-
|
|
6085
|
+
hl,
|
|
6086
|
+
fl,
|
|
6087
|
+
gl
|
|
6088
|
+
], Al = 0, Tl = 1, xl = 2, Il = 3, Ll = 4, Ol = 5, Nl = 6;
|
|
6089
6089
|
class tt {
|
|
6090
6090
|
/**
|
|
6091
6091
|
* @param {AbstractType<any>} type
|
|
@@ -6178,7 +6178,7 @@ class tt {
|
|
|
6178
6178
|
return 7;
|
|
6179
6179
|
}
|
|
6180
6180
|
}
|
|
6181
|
-
const
|
|
6181
|
+
const Ml = (e) => new tt(Dl[e.readTypeRef()](e)), vl = (e, t) => {
|
|
6182
6182
|
let n = t, s = 0, r;
|
|
6183
6183
|
do
|
|
6184
6184
|
s > 0 && (n = y(n.client, n.clock + s)), r = he(e, n), s = n.clock - r.id.clock, n = r.redone;
|
|
@@ -6207,19 +6207,19 @@ const Ol = (e) => new tt(Cl[e.readTypeRef()](e)), Nl = (e, t) => {
|
|
|
6207
6207
|
e,
|
|
6208
6208
|
/** @param {StackItem} s */
|
|
6209
6209
|
(n) => Zt(n.deletions, t)
|
|
6210
|
-
),
|
|
6210
|
+
), zr = (e, t, n, s, r, i) => {
|
|
6211
6211
|
const o = e.doc, c = o.store, l = o.clientID, a = t.redone;
|
|
6212
6212
|
if (a !== null)
|
|
6213
|
-
return
|
|
6213
|
+
return U(e, a);
|
|
6214
6214
|
let h = (
|
|
6215
6215
|
/** @type {AbstractType<any>} */
|
|
6216
6216
|
t.parent._item
|
|
6217
6217
|
), u = null, d;
|
|
6218
6218
|
if (h !== null && h.deleted === !0) {
|
|
6219
|
-
if (h.redone === null && (!n.has(h) ||
|
|
6219
|
+
if (h.redone === null && (!n.has(h) || zr(e, h, n, s, r, i) === null))
|
|
6220
6220
|
return null;
|
|
6221
6221
|
for (; h.redone !== null; )
|
|
6222
|
-
h =
|
|
6222
|
+
h = U(e, h.redone);
|
|
6223
6223
|
}
|
|
6224
6224
|
const f = h === null ? (
|
|
6225
6225
|
/** @type {AbstractType<any>} */
|
|
@@ -6233,7 +6233,7 @@ const Ol = (e) => new tt(Cl[e.readTypeRef()](e)), Nl = (e, t) => {
|
|
|
6233
6233
|
let k = u;
|
|
6234
6234
|
for (; k !== null && /** @type {AbstractType<any>} */
|
|
6235
6235
|
k.parent._item !== h; )
|
|
6236
|
-
k = k.redone === null ? null :
|
|
6236
|
+
k = k.redone === null ? null : U(e, k.redone);
|
|
6237
6237
|
if (k !== null && /** @type {AbstractType<any>} */
|
|
6238
6238
|
k.parent._item === h) {
|
|
6239
6239
|
u = k;
|
|
@@ -6245,7 +6245,7 @@ const Ol = (e) => new tt(Cl[e.readTypeRef()](e)), Nl = (e, t) => {
|
|
|
6245
6245
|
let k = d;
|
|
6246
6246
|
for (; k !== null && /** @type {AbstractType<any>} */
|
|
6247
6247
|
k.parent._item !== h; )
|
|
6248
|
-
k = k.redone === null ? null :
|
|
6248
|
+
k = k.redone === null ? null : U(e, k.redone);
|
|
6249
6249
|
if (k !== null && /** @type {AbstractType<any>} */
|
|
6250
6250
|
k.parent._item === h) {
|
|
6251
6251
|
d = k;
|
|
@@ -6256,7 +6256,7 @@ const Ol = (e) => new tt(Cl[e.readTypeRef()](e)), Nl = (e, t) => {
|
|
|
6256
6256
|
} else {
|
|
6257
6257
|
if (d = null, t.right && !r) {
|
|
6258
6258
|
for (u = t; u !== null && u.right !== null && (u.right.redone || Zt(s, u.right.id) || Cs(i.undoStack, u.right.id) || Cs(i.redoStack, u.right.id)); )
|
|
6259
|
-
for (u = u.right; u.redone; ) u =
|
|
6259
|
+
for (u = u.right; u.redone; ) u = U(e, u.redone);
|
|
6260
6260
|
if (u && u.right !== null)
|
|
6261
6261
|
return null;
|
|
6262
6262
|
} else
|
|
@@ -6296,10 +6296,10 @@ class S extends Hn {
|
|
|
6296
6296
|
* @type {boolean}
|
|
6297
6297
|
*/
|
|
6298
6298
|
set marker(t) {
|
|
6299
|
-
(this.info &
|
|
6299
|
+
(this.info & Pe) > 0 !== t && (this.info ^= Pe);
|
|
6300
6300
|
}
|
|
6301
6301
|
get marker() {
|
|
6302
|
-
return (this.info &
|
|
6302
|
+
return (this.info & Pe) > 0;
|
|
6303
6303
|
}
|
|
6304
6304
|
/**
|
|
6305
6305
|
* If true, do not garbage collect this Item.
|
|
@@ -6340,7 +6340,7 @@ class S extends Hn {
|
|
|
6340
6340
|
return this.rightOrigin.client;
|
|
6341
6341
|
if (this.parent && this.parent.constructor === Dt && this.id.client !== this.parent.client && this.parent.clock >= A(n, this.parent.client))
|
|
6342
6342
|
return this.parent.client;
|
|
6343
|
-
if (this.origin && (this.left = gs(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right =
|
|
6343
|
+
if (this.origin && (this.left = gs(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = U(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === B || this.right && this.right.constructor === B)
|
|
6344
6344
|
this.parent = null;
|
|
6345
6345
|
else if (!this.parent)
|
|
6346
6346
|
this.left && this.left.constructor === S ? (this.parent = this.left.parent, this.parentSub = this.left.parentSub) : this.right && this.right.constructor === S && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
|
|
@@ -6397,7 +6397,7 @@ class S extends Hn {
|
|
|
6397
6397
|
this.parent._start, this.parent._start = this;
|
|
6398
6398
|
this.right = s;
|
|
6399
6399
|
}
|
|
6400
|
-
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length),
|
|
6400
|
+
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), Cr(t.doc.store, this), this.content.integrate(t, this), ws(
|
|
6401
6401
|
t,
|
|
6402
6402
|
/** @type {AbstractType<any>} */
|
|
6403
6403
|
this.parent,
|
|
@@ -6471,7 +6471,7 @@ class S extends Hn {
|
|
|
6471
6471
|
gc(t, n) {
|
|
6472
6472
|
if (!this.deleted)
|
|
6473
6473
|
throw V();
|
|
6474
|
-
this.content.gc(t), n ?
|
|
6474
|
+
this.content.gc(t), n ? Rc(t, this, new B(this.id, this.length)) : this.content = new Xt(this.length);
|
|
6475
6475
|
}
|
|
6476
6476
|
/**
|
|
6477
6477
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -6483,7 +6483,7 @@ class S extends Hn {
|
|
|
6483
6483
|
* @param {number} offset
|
|
6484
6484
|
*/
|
|
6485
6485
|
write(t, n) {
|
|
6486
|
-
const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() &
|
|
6486
|
+
const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Te | (s === null ? 0 : $) | // origin is defined
|
|
6487
6487
|
(r === null ? 0 : W) | // right origin is defined
|
|
6488
6488
|
(i === null ? 0 : jt);
|
|
6489
6489
|
if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
|
|
@@ -6494,7 +6494,7 @@ class S extends Hn {
|
|
|
6494
6494
|
if (c._item !== void 0) {
|
|
6495
6495
|
const l = c._item;
|
|
6496
6496
|
if (l === null) {
|
|
6497
|
-
const a =
|
|
6497
|
+
const a = vc(c);
|
|
6498
6498
|
t.writeParentInfo(!0), t.writeString(a);
|
|
6499
6499
|
} else
|
|
6500
6500
|
t.writeParentInfo(!1), t.writeLeftID(l.id);
|
|
@@ -6504,34 +6504,34 @@ class S extends Hn {
|
|
|
6504
6504
|
this.content.write(t, n);
|
|
6505
6505
|
}
|
|
6506
6506
|
}
|
|
6507
|
-
const
|
|
6507
|
+
const Pr = (e, t) => Ul[t & Te](e), Ul = [
|
|
6508
6508
|
() => {
|
|
6509
6509
|
V();
|
|
6510
6510
|
},
|
|
6511
6511
|
// GC is not ItemContent
|
|
6512
|
-
|
|
6512
|
+
ml,
|
|
6513
6513
|
// 1
|
|
6514
|
-
|
|
6514
|
+
_l,
|
|
6515
6515
|
// 2
|
|
6516
|
-
|
|
6516
|
+
wl,
|
|
6517
6517
|
// 3
|
|
6518
|
-
|
|
6518
|
+
El,
|
|
6519
6519
|
// 4
|
|
6520
|
-
|
|
6520
|
+
bl,
|
|
6521
6521
|
// 5
|
|
6522
|
-
|
|
6522
|
+
kl,
|
|
6523
6523
|
// 6
|
|
6524
|
-
|
|
6524
|
+
Ml,
|
|
6525
6525
|
// 7
|
|
6526
|
-
|
|
6526
|
+
Cl,
|
|
6527
6527
|
// 8
|
|
6528
|
-
|
|
6528
|
+
yl,
|
|
6529
6529
|
// 9
|
|
6530
6530
|
() => {
|
|
6531
6531
|
V();
|
|
6532
6532
|
}
|
|
6533
6533
|
// 10 - Skip is not ItemContent
|
|
6534
|
-
],
|
|
6534
|
+
], Rl = 10;
|
|
6535
6535
|
class F extends Hn {
|
|
6536
6536
|
get deleted() {
|
|
6537
6537
|
return !0;
|
|
@@ -6557,7 +6557,7 @@ class F extends Hn {
|
|
|
6557
6557
|
* @param {number} offset
|
|
6558
6558
|
*/
|
|
6559
6559
|
write(t, n) {
|
|
6560
|
-
t.writeInfo(
|
|
6560
|
+
t.writeInfo(Rl), w(t.restEncoder, this.length - n);
|
|
6561
6561
|
}
|
|
6562
6562
|
/**
|
|
6563
6563
|
* @param {Transaction} transaction
|
|
@@ -6574,73 +6574,73 @@ const Yr = (
|
|
|
6574
6574
|
), Gr = "__ $YJS$ __";
|
|
6575
6575
|
Yr[Gr] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
6576
6576
|
Yr[Gr] = !0;
|
|
6577
|
-
const
|
|
6578
|
-
class
|
|
6577
|
+
const Jr = /* @__PURE__ */ new Map();
|
|
6578
|
+
class $l {
|
|
6579
6579
|
/**
|
|
6580
6580
|
* @param {string} room
|
|
6581
6581
|
*/
|
|
6582
6582
|
constructor(t) {
|
|
6583
|
-
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data:
|
|
6583
|
+
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: Co(n.newValue || "") }), to(this._onChange);
|
|
6584
6584
|
}
|
|
6585
6585
|
/**
|
|
6586
6586
|
* @param {ArrayBuffer} buf
|
|
6587
6587
|
*/
|
|
6588
6588
|
postMessage(t) {
|
|
6589
|
-
|
|
6589
|
+
Bs.setItem(this.room, So(mo(t)));
|
|
6590
6590
|
}
|
|
6591
6591
|
close() {
|
|
6592
|
-
|
|
6592
|
+
eo(this._onChange);
|
|
6593
6593
|
}
|
|
6594
6594
|
}
|
|
6595
|
-
const
|
|
6596
|
-
const t = rt(), n = new
|
|
6595
|
+
const Bl = typeof BroadcastChannel > "u" ? $l : BroadcastChannel, Pn = (e) => J(Jr, e, () => {
|
|
6596
|
+
const t = rt(), n = new Bl(e);
|
|
6597
6597
|
return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
6598
6598
|
bc: n,
|
|
6599
6599
|
subs: t
|
|
6600
6600
|
};
|
|
6601
|
-
}),
|
|
6602
|
-
const n =
|
|
6603
|
-
return s && n.subs.size === 0 && (n.bc.close(),
|
|
6601
|
+
}), Fl = (e, t) => (Pn(e).subs.add(t), t), Vl = (e, t) => {
|
|
6602
|
+
const n = Pn(e), s = n.subs.delete(t);
|
|
6603
|
+
return s && n.subs.size === 0 && (n.bc.close(), Jr.delete(e)), s;
|
|
6604
6604
|
}, _t = (e, t, n = null) => {
|
|
6605
|
-
const s =
|
|
6605
|
+
const s = Pn(e);
|
|
6606
6606
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
|
|
6607
|
-
},
|
|
6608
|
-
w(e,
|
|
6609
|
-
const n =
|
|
6607
|
+
}, Kr = 0, Yn = 1, Wr = 2, dn = (e, t) => {
|
|
6608
|
+
w(e, Kr);
|
|
6609
|
+
const n = Nc(t);
|
|
6610
6610
|
E(e, n);
|
|
6611
|
-
},
|
|
6612
|
-
w(e,
|
|
6613
|
-
},
|
|
6611
|
+
}, Xr = (e, t, n) => {
|
|
6612
|
+
w(e, Yn), E(e, xc(t, n));
|
|
6613
|
+
}, jl = (e, t, n) => Xr(t, n, O(e)), qr = (e, t, n, s) => {
|
|
6614
6614
|
try {
|
|
6615
|
-
|
|
6615
|
+
Dc(t, O(e), n);
|
|
6616
6616
|
} catch (r) {
|
|
6617
6617
|
s?.(
|
|
6618
6618
|
/** @type {Error} */
|
|
6619
6619
|
r
|
|
6620
6620
|
), console.error("Caught error while handling a Yjs update", r);
|
|
6621
6621
|
}
|
|
6622
|
-
},
|
|
6623
|
-
w(e,
|
|
6624
|
-
},
|
|
6622
|
+
}, Hl = (e, t) => {
|
|
6623
|
+
w(e, Wr), E(e, t);
|
|
6624
|
+
}, zl = qr, Pl = (e, t, n, s, r) => {
|
|
6625
6625
|
const i = m(e);
|
|
6626
6626
|
switch (i) {
|
|
6627
|
-
case
|
|
6628
|
-
|
|
6627
|
+
case Kr:
|
|
6628
|
+
jl(e, t, n);
|
|
6629
6629
|
break;
|
|
6630
|
-
case
|
|
6631
|
-
|
|
6630
|
+
case Yn:
|
|
6631
|
+
qr(e, n, s, r);
|
|
6632
6632
|
break;
|
|
6633
|
-
case
|
|
6634
|
-
|
|
6633
|
+
case Wr:
|
|
6634
|
+
zl(e, n, s, r);
|
|
6635
6635
|
break;
|
|
6636
6636
|
default:
|
|
6637
6637
|
throw new Error("Unknown message type");
|
|
6638
6638
|
}
|
|
6639
6639
|
return i;
|
|
6640
|
-
},
|
|
6641
|
-
m(e) ===
|
|
6640
|
+
}, Yl = 0, Gl = (e, t, n) => {
|
|
6641
|
+
m(e) === Yl && n(t, st(e));
|
|
6642
6642
|
}, Qe = 3e4;
|
|
6643
|
-
class
|
|
6643
|
+
class Jl extends yi {
|
|
6644
6644
|
/**
|
|
6645
6645
|
* @param {Y.Doc} doc
|
|
6646
6646
|
*/
|
|
@@ -6653,7 +6653,7 @@ class Gl extends wi {
|
|
|
6653
6653
|
const s = [];
|
|
6654
6654
|
this.meta.forEach((r, i) => {
|
|
6655
6655
|
i !== this.clientID && Qe <= n - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
6656
|
-
}), s.length > 0 &&
|
|
6656
|
+
}), s.length > 0 && Gn(this, s, "timeout");
|
|
6657
6657
|
}, H(Qe / 10)), t.on("destroy", () => {
|
|
6658
6658
|
this.destroy();
|
|
6659
6659
|
}), this.setLocalState({});
|
|
@@ -6697,7 +6697,7 @@ class Gl extends wi {
|
|
|
6697
6697
|
return this.states;
|
|
6698
6698
|
}
|
|
6699
6699
|
}
|
|
6700
|
-
const
|
|
6700
|
+
const Gn = (e, t, n) => {
|
|
6701
6701
|
const s = [];
|
|
6702
6702
|
for (let r = 0; r < t.length; r++) {
|
|
6703
6703
|
const i = t[r];
|
|
@@ -6727,7 +6727,7 @@ const Pn = (e, t, n) => {
|
|
|
6727
6727
|
w(r, o), w(r, l), ht(r, JSON.stringify(c));
|
|
6728
6728
|
}
|
|
6729
6729
|
return C(r);
|
|
6730
|
-
},
|
|
6730
|
+
}, Kl = (e, t, n) => {
|
|
6731
6731
|
const s = ct(t), r = it(), i = [], o = [], c = [], l = [], a = m(s);
|
|
6732
6732
|
for (let h = 0; h < a; h++) {
|
|
6733
6733
|
const u = m(s);
|
|
@@ -6747,19 +6747,19 @@ const Pn = (e, t, n) => {
|
|
|
6747
6747
|
updated: o,
|
|
6748
6748
|
removed: l
|
|
6749
6749
|
}, n]);
|
|
6750
|
-
},
|
|
6750
|
+
}, Wl = (e) => oo(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), lt = 0, Qr = 3, Tt = 1, Xl = 2, se = [];
|
|
6751
6751
|
se[lt] = (e, t, n, s, r) => {
|
|
6752
6752
|
w(e, lt);
|
|
6753
|
-
const i =
|
|
6753
|
+
const i = Pl(
|
|
6754
6754
|
t,
|
|
6755
6755
|
e,
|
|
6756
6756
|
n.doc,
|
|
6757
6757
|
n
|
|
6758
6758
|
);
|
|
6759
|
-
s && i ===
|
|
6759
|
+
s && i === Yn && !n.synced && (n.synced = !0);
|
|
6760
6760
|
};
|
|
6761
|
-
se[
|
|
6762
|
-
w(e,
|
|
6761
|
+
se[Qr] = (e, t, n, s, r) => {
|
|
6762
|
+
w(e, Tt), E(
|
|
6763
6763
|
e,
|
|
6764
6764
|
Vt(
|
|
6765
6765
|
n.awareness,
|
|
@@ -6767,26 +6767,26 @@ se[qr] = (e, t, n, s, r) => {
|
|
|
6767
6767
|
)
|
|
6768
6768
|
);
|
|
6769
6769
|
};
|
|
6770
|
-
se[
|
|
6771
|
-
|
|
6770
|
+
se[Tt] = (e, t, n, s, r) => {
|
|
6771
|
+
Kl(
|
|
6772
6772
|
n.awareness,
|
|
6773
6773
|
O(t),
|
|
6774
6774
|
n
|
|
6775
6775
|
);
|
|
6776
6776
|
};
|
|
6777
|
-
se[
|
|
6778
|
-
|
|
6777
|
+
se[Xl] = (e, t, n, s, r) => {
|
|
6778
|
+
Gl(
|
|
6779
6779
|
t,
|
|
6780
6780
|
n.doc,
|
|
6781
|
-
(i, o) =>
|
|
6781
|
+
(i, o) => ql(n, o)
|
|
6782
6782
|
);
|
|
6783
6783
|
};
|
|
6784
|
-
const Es = 3e4,
|
|
6785
|
-
${t}`),
|
|
6784
|
+
const Es = 3e4, ql = (e, t) => console.warn(`Permission denied to access ${e.url}.
|
|
6785
|
+
${t}`), Zr = (e, t, n) => {
|
|
6786
6786
|
const s = ct(t), r = N(), i = m(s), o = e.messageHandlers[i];
|
|
6787
6787
|
return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
|
|
6788
6788
|
}, fn = (e, t, n) => {
|
|
6789
|
-
t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1,
|
|
6789
|
+
t === e.ws && (e.emit("connection-close", [n, e]), e.ws = null, t.close(), e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, Gn(
|
|
6790
6790
|
e.awareness,
|
|
6791
6791
|
Array.from(e.awareness.getStates().keys()).filter(
|
|
6792
6792
|
(s) => s !== e.doc.clientID
|
|
@@ -6795,19 +6795,19 @@ ${t}`), Qr = (e, t, n) => {
|
|
|
6795
6795
|
), e.emit("status", [{
|
|
6796
6796
|
status: "disconnected"
|
|
6797
6797
|
}])) : e.wsUnsuccessfulReconnects++, setTimeout(
|
|
6798
|
-
|
|
6798
|
+
ti,
|
|
6799
6799
|
yn(
|
|
6800
|
-
|
|
6800
|
+
bi(2, e.wsUnsuccessfulReconnects) * 100,
|
|
6801
6801
|
e.maxBackoffTime
|
|
6802
6802
|
),
|
|
6803
6803
|
e
|
|
6804
6804
|
));
|
|
6805
|
-
},
|
|
6805
|
+
}, ti = (e) => {
|
|
6806
6806
|
if (e.shouldConnect && e.ws === null) {
|
|
6807
6807
|
const t = new e._WS(e.url, e.protocols);
|
|
6808
6808
|
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.onmessage = (n) => {
|
|
6809
6809
|
e.wsLastMessageReceived = it();
|
|
6810
|
-
const s =
|
|
6810
|
+
const s = Zr(e, new Uint8Array(n.data), !0);
|
|
6811
6811
|
bn(s) > 1 && t.send(C(s));
|
|
6812
6812
|
}, t.onerror = (n) => {
|
|
6813
6813
|
e.emit("connection-error", [n, e]);
|
|
@@ -6820,7 +6820,7 @@ ${t}`), Qr = (e, t, n) => {
|
|
|
6820
6820
|
const n = N();
|
|
6821
6821
|
if (w(n, lt), dn(n, e.doc), t.send(C(n)), e.awareness.getLocalState() !== null) {
|
|
6822
6822
|
const s = N();
|
|
6823
|
-
w(s,
|
|
6823
|
+
w(s, Tt), E(
|
|
6824
6824
|
s,
|
|
6825
6825
|
Vt(e.awareness, [
|
|
6826
6826
|
e.doc.clientID
|
|
@@ -6835,7 +6835,7 @@ ${t}`), Qr = (e, t, n) => {
|
|
|
6835
6835
|
const n = e.ws;
|
|
6836
6836
|
e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && _t(e.bcChannel, t, e);
|
|
6837
6837
|
};
|
|
6838
|
-
class
|
|
6838
|
+
class Ql extends mn {
|
|
6839
6839
|
/**
|
|
6840
6840
|
* @param {string} serverUrl
|
|
6841
6841
|
* @param {string} roomname
|
|
@@ -6852,7 +6852,7 @@ class Xl extends mn {
|
|
|
6852
6852
|
*/
|
|
6853
6853
|
constructor(t, n, s, {
|
|
6854
6854
|
connect: r = !0,
|
|
6855
|
-
awareness: i = new
|
|
6855
|
+
awareness: i = new Jl(s),
|
|
6856
6856
|
params: o = {},
|
|
6857
6857
|
protocols: c = [],
|
|
6858
6858
|
WebSocketPolyfill: l = WebSocket,
|
|
@@ -6870,22 +6870,22 @@ class Xl extends mn {
|
|
|
6870
6870
|
}
|
|
6871
6871
|
}, a)), this._bcSubscriber = (d, f) => {
|
|
6872
6872
|
if (f !== this) {
|
|
6873
|
-
const g =
|
|
6873
|
+
const g = Zr(this, new Uint8Array(d), !1);
|
|
6874
6874
|
bn(g) > 1 && _t(this.bcChannel, C(g), this);
|
|
6875
6875
|
}
|
|
6876
6876
|
}, this._updateHandler = (d, f) => {
|
|
6877
6877
|
if (f !== this) {
|
|
6878
6878
|
const g = N();
|
|
6879
|
-
w(g, lt),
|
|
6879
|
+
w(g, lt), Hl(g, d), Ze(this, C(g));
|
|
6880
6880
|
}
|
|
6881
6881
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, p) => {
|
|
6882
6882
|
const b = d.concat(f).concat(g), k = N();
|
|
6883
|
-
w(k,
|
|
6883
|
+
w(k, Tt), E(
|
|
6884
6884
|
k,
|
|
6885
6885
|
Vt(i, b)
|
|
6886
6886
|
), Ze(this, C(k));
|
|
6887
6887
|
}, this._exitHandler = () => {
|
|
6888
|
-
|
|
6888
|
+
Gn(
|
|
6889
6889
|
this.awareness,
|
|
6890
6890
|
[s.clientID],
|
|
6891
6891
|
"app closed"
|
|
@@ -6901,7 +6901,7 @@ class Xl extends mn {
|
|
|
6901
6901
|
}, Es / 10), r && this.connect();
|
|
6902
6902
|
}
|
|
6903
6903
|
get url() {
|
|
6904
|
-
const t =
|
|
6904
|
+
const t = Wl(this.params);
|
|
6905
6905
|
return this.serverUrl + "/" + this.roomname + (t.length === 0 ? "" : "?" + t);
|
|
6906
6906
|
}
|
|
6907
6907
|
/**
|
|
@@ -6919,19 +6919,19 @@ class Xl extends mn {
|
|
|
6919
6919
|
connectBc() {
|
|
6920
6920
|
if (this.disableBc)
|
|
6921
6921
|
return;
|
|
6922
|
-
this.bcconnected || (
|
|
6922
|
+
this.bcconnected || (Fl(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
6923
6923
|
const t = N();
|
|
6924
6924
|
w(t, lt), dn(t, this.doc), _t(this.bcChannel, C(t), this);
|
|
6925
6925
|
const n = N();
|
|
6926
|
-
w(n, lt),
|
|
6926
|
+
w(n, lt), Xr(n, this.doc), _t(this.bcChannel, C(n), this);
|
|
6927
6927
|
const s = N();
|
|
6928
|
-
w(s,
|
|
6928
|
+
w(s, Qr), _t(
|
|
6929
6929
|
this.bcChannel,
|
|
6930
6930
|
C(s),
|
|
6931
6931
|
this
|
|
6932
6932
|
);
|
|
6933
6933
|
const r = N();
|
|
6934
|
-
w(r,
|
|
6934
|
+
w(r, Tt), E(
|
|
6935
6935
|
r,
|
|
6936
6936
|
Vt(this.awareness, [
|
|
6937
6937
|
this.doc.clientID
|
|
@@ -6944,21 +6944,21 @@ class Xl extends mn {
|
|
|
6944
6944
|
}
|
|
6945
6945
|
disconnectBc() {
|
|
6946
6946
|
const t = N();
|
|
6947
|
-
w(t,
|
|
6947
|
+
w(t, Tt), E(
|
|
6948
6948
|
t,
|
|
6949
6949
|
Vt(this.awareness, [
|
|
6950
6950
|
this.doc.clientID
|
|
6951
6951
|
], /* @__PURE__ */ new Map())
|
|
6952
|
-
), Ze(this, C(t)), this.bcconnected && (
|
|
6952
|
+
), Ze(this, C(t)), this.bcconnected && (Vl(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
6953
6953
|
}
|
|
6954
6954
|
disconnect() {
|
|
6955
6955
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && fn(this, this.ws, null);
|
|
6956
6956
|
}
|
|
6957
6957
|
connect() {
|
|
6958
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
6958
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (ti(this), this.connectBc());
|
|
6959
6959
|
}
|
|
6960
6960
|
}
|
|
6961
|
-
const
|
|
6961
|
+
const ei = "data-collab-blocked", ni = /^[a-z][a-z0-9-]*$/, Zl = /^[a-z_:][-a-z0-9_:.]*$/i, ta = /* @__PURE__ */ new Set([
|
|
6962
6962
|
"script",
|
|
6963
6963
|
"style",
|
|
6964
6964
|
"iframe",
|
|
@@ -6973,7 +6973,7 @@ const ti = "data-collab-blocked", ei = /^[a-z][a-z0-9-]*$/, ql = /^[a-z_:][-a-z0
|
|
|
6973
6973
|
"noscript",
|
|
6974
6974
|
"template",
|
|
6975
6975
|
"portal"
|
|
6976
|
-
]),
|
|
6976
|
+
]), ea = /* @__PURE__ */ new Set([
|
|
6977
6977
|
"href",
|
|
6978
6978
|
"src",
|
|
6979
6979
|
"xlink:href",
|
|
@@ -6990,12 +6990,12 @@ const ti = "data-collab-blocked", ei = /^[a-z][a-z0-9-]*$/, ql = /^[a-z_:][-a-z0
|
|
|
6990
6990
|
"usemap",
|
|
6991
6991
|
"lowsrc",
|
|
6992
6992
|
"dynsrc"
|
|
6993
|
-
]),
|
|
6994
|
-
function
|
|
6995
|
-
const t = e.replace(
|
|
6996
|
-
return /^(?:javascript|vbscript|livescript|mocha):/.test(t) ? !1 : t.startsWith("data:") ?
|
|
6993
|
+
]), na = /^data:image\/(?:png|gif|jpe?g|webp|avif|bmp|x-icon);/, sa = new RegExp("[\\u0000-\\u0020\\u007f-\\u009f\\u00ad\\u200b-\\u200f\\u2028\\u2029\\ufeff]", "g");
|
|
6994
|
+
function ra(e) {
|
|
6995
|
+
const t = e.replace(sa, "").toLowerCase();
|
|
6996
|
+
return /^(?:javascript|vbscript|livescript|mocha):/.test(t) ? !1 : t.startsWith("data:") ? na.test(t) : !0;
|
|
6997
6997
|
}
|
|
6998
|
-
function
|
|
6998
|
+
function ia(e) {
|
|
6999
6999
|
if (!("data-editora-embed" in e)) return !1;
|
|
7000
7000
|
const t = e.src?.trim();
|
|
7001
7001
|
if (!t || /\s/.test(t)) return !1;
|
|
@@ -7006,29 +7006,29 @@ function sa(e) {
|
|
|
7006
7006
|
return !1;
|
|
7007
7007
|
}
|
|
7008
7008
|
}
|
|
7009
|
-
function
|
|
7009
|
+
function oa(e, t) {
|
|
7010
7010
|
const n = e.toLowerCase();
|
|
7011
|
-
return
|
|
7011
|
+
return ni.test(n) ? n === "iframe" ? !ia(t) : ta.has(n) : !0;
|
|
7012
7012
|
}
|
|
7013
|
-
function
|
|
7014
|
-
if (!
|
|
7013
|
+
function si(e, t) {
|
|
7014
|
+
if (!Zl.test(e)) return !1;
|
|
7015
7015
|
const n = e.toLowerCase();
|
|
7016
|
-
return n.startsWith("on") || n === "srcdoc" ? !1 :
|
|
7016
|
+
return n.startsWith("on") || n === "srcdoc" ? !1 : ea.has(n) ? ra(String(t)) : !0;
|
|
7017
7017
|
}
|
|
7018
|
-
function
|
|
7018
|
+
function ca(e, t) {
|
|
7019
7019
|
const n = e.createElement("span");
|
|
7020
|
-
return n.setAttribute(
|
|
7020
|
+
return n.setAttribute(ei, ni.test(t.toLowerCase()) ? t.toLowerCase().slice(0, 32) : "invalid"), n.hidden = !0, n;
|
|
7021
7021
|
}
|
|
7022
7022
|
function De(e) {
|
|
7023
|
-
return e.nodeType === Node.ELEMENT_NODE && e.hasAttribute(
|
|
7023
|
+
return e.nodeType === Node.ELEMENT_NODE && e.hasAttribute(ei);
|
|
7024
7024
|
}
|
|
7025
|
-
function
|
|
7025
|
+
function la(e) {
|
|
7026
7026
|
return e instanceof Q || e instanceof q;
|
|
7027
7027
|
}
|
|
7028
7028
|
function Jn(e) {
|
|
7029
|
-
return e.toArray().filter(
|
|
7029
|
+
return e.toArray().filter(la);
|
|
7030
7030
|
}
|
|
7031
|
-
function
|
|
7031
|
+
function aa(e, t) {
|
|
7032
7032
|
if (e === t) return null;
|
|
7033
7033
|
let n = 0;
|
|
7034
7034
|
const s = Math.min(e.length, t.length);
|
|
@@ -7042,36 +7042,36 @@ function ca(e, t) {
|
|
|
7042
7042
|
insertText: t.slice(n, t.length - r)
|
|
7043
7043
|
};
|
|
7044
7044
|
}
|
|
7045
|
-
function
|
|
7045
|
+
function ha(e) {
|
|
7046
7046
|
const t = new q(e.tagName.toLowerCase());
|
|
7047
7047
|
for (const s of Array.from(e.attributes))
|
|
7048
7048
|
t.setAttribute(s.name, s.value);
|
|
7049
|
-
const n =
|
|
7049
|
+
const n = ri(e.childNodes);
|
|
7050
7050
|
return n.length && t.insert(0, n), t;
|
|
7051
7051
|
}
|
|
7052
|
-
function
|
|
7052
|
+
function ri(e) {
|
|
7053
7053
|
const t = [];
|
|
7054
7054
|
for (const n of Array.from(e))
|
|
7055
|
-
n.nodeType === Node.TEXT_NODE ? t.push(new Q(n.textContent ?? "")) : n.nodeType === Node.ELEMENT_NODE && t.push(
|
|
7055
|
+
n.nodeType === Node.TEXT_NODE ? t.push(new Q(n.textContent ?? "")) : n.nodeType === Node.ELEMENT_NODE && t.push(ha(n));
|
|
7056
7056
|
return t;
|
|
7057
7057
|
}
|
|
7058
|
-
function
|
|
7059
|
-
return
|
|
7058
|
+
function ii(e) {
|
|
7059
|
+
return oa(e.nodeName, e.getAttributes());
|
|
7060
7060
|
}
|
|
7061
|
-
function
|
|
7062
|
-
if (
|
|
7061
|
+
function ua(e, t) {
|
|
7062
|
+
if (ii(e)) return ca(t, e.nodeName);
|
|
7063
7063
|
const n = t.createElement(e.nodeName);
|
|
7064
7064
|
for (const [s, r] of Object.entries(e.getAttributes()))
|
|
7065
|
-
|
|
7065
|
+
si(s, r) && n.setAttribute(s, r);
|
|
7066
7066
|
for (const s of Jn(e))
|
|
7067
|
-
n.appendChild(
|
|
7067
|
+
n.appendChild(oi(s, t));
|
|
7068
7068
|
return n;
|
|
7069
7069
|
}
|
|
7070
|
-
function ii(e, t) {
|
|
7071
|
-
return e instanceof Q ? t.createTextNode(e.toString()) : aa(e, t);
|
|
7072
|
-
}
|
|
7073
7070
|
function oi(e, t) {
|
|
7074
|
-
return
|
|
7071
|
+
return e instanceof Q ? t.createTextNode(e.toString()) : ua(e, t);
|
|
7072
|
+
}
|
|
7073
|
+
function ci(e, t) {
|
|
7074
|
+
return ii(t) ? De(e) : !De(e) && e.tagName.toLowerCase() === t.nodeName.toLowerCase();
|
|
7075
7075
|
}
|
|
7076
7076
|
function gn(e, t) {
|
|
7077
7077
|
const n = Array.from(t.childNodes).filter(
|
|
@@ -7082,32 +7082,32 @@ function gn(e, t) {
|
|
|
7082
7082
|
const o = n[i], c = s[i];
|
|
7083
7083
|
if (o.nodeType === Node.TEXT_NODE) {
|
|
7084
7084
|
if (c instanceof Q) {
|
|
7085
|
-
const l =
|
|
7085
|
+
const l = aa(c.toString(), o.textContent ?? "");
|
|
7086
7086
|
l && (l.deleteCount > 0 && c.delete(l.start, l.deleteCount), l.insertText && c.insert(l.start, l.insertText));
|
|
7087
7087
|
continue;
|
|
7088
7088
|
}
|
|
7089
7089
|
break;
|
|
7090
7090
|
}
|
|
7091
|
-
if (c instanceof q &&
|
|
7091
|
+
if (c instanceof q && ci(o, c)) {
|
|
7092
7092
|
if (De(o)) continue;
|
|
7093
|
-
|
|
7093
|
+
da(c, o), gn(c, o);
|
|
7094
7094
|
continue;
|
|
7095
7095
|
}
|
|
7096
7096
|
break;
|
|
7097
7097
|
}
|
|
7098
7098
|
if (i < s.length && e.delete(i, s.length - i), i < n.length) {
|
|
7099
|
-
const o =
|
|
7099
|
+
const o = ri(n.slice(i));
|
|
7100
7100
|
o.length && e.insert(i, o);
|
|
7101
7101
|
}
|
|
7102
7102
|
}
|
|
7103
|
-
function
|
|
7103
|
+
function da(e, t) {
|
|
7104
7104
|
const n = e.getAttributes(), s = new Set(Array.from(t.attributes).map((r) => r.name));
|
|
7105
7105
|
for (const r of Object.keys(n))
|
|
7106
7106
|
s.has(r) || e.removeAttribute(r);
|
|
7107
7107
|
for (const r of Array.from(t.attributes))
|
|
7108
7108
|
n[r.name] !== r.value && e.setAttribute(r.name, r.value);
|
|
7109
7109
|
}
|
|
7110
|
-
function
|
|
7110
|
+
function li(e, t, n) {
|
|
7111
7111
|
const s = Jn(t), r = Array.from(e.childNodes).filter(
|
|
7112
7112
|
(c) => c.nodeType === Node.TEXT_NODE || c.nodeType === Node.ELEMENT_NODE
|
|
7113
7113
|
), i = Math.min(s.length, r.length);
|
|
@@ -7122,9 +7122,9 @@ function ci(e, t, n) {
|
|
|
7122
7122
|
}
|
|
7123
7123
|
break;
|
|
7124
7124
|
}
|
|
7125
|
-
if (l.nodeType === Node.ELEMENT_NODE &&
|
|
7125
|
+
if (l.nodeType === Node.ELEMENT_NODE && ci(l, c)) {
|
|
7126
7126
|
if (De(l)) continue;
|
|
7127
|
-
|
|
7127
|
+
fa(l, c), li(l, c, n);
|
|
7128
7128
|
continue;
|
|
7129
7129
|
}
|
|
7130
7130
|
break;
|
|
@@ -7132,21 +7132,21 @@ function ci(e, t, n) {
|
|
|
7132
7132
|
for (let c = r.length - 1; c >= o; c--)
|
|
7133
7133
|
e.removeChild(r[c]);
|
|
7134
7134
|
for (let c = o; c < s.length; c++)
|
|
7135
|
-
e.appendChild(
|
|
7135
|
+
e.appendChild(oi(s[c], n));
|
|
7136
7136
|
}
|
|
7137
|
-
function
|
|
7137
|
+
function fa(e, t) {
|
|
7138
7138
|
const n = t.getAttributes(), s = new Set(Array.from(e.attributes).map((r) => r.name));
|
|
7139
7139
|
for (const r of s)
|
|
7140
7140
|
r in n || e.removeAttribute(r);
|
|
7141
7141
|
for (const [r, i] of Object.entries(n)) {
|
|
7142
|
-
if (!
|
|
7142
|
+
if (!si(r, i)) {
|
|
7143
7143
|
e.removeAttribute(r);
|
|
7144
7144
|
continue;
|
|
7145
7145
|
}
|
|
7146
7146
|
e.getAttribute(r) !== i && e.setAttribute(r, i);
|
|
7147
7147
|
}
|
|
7148
7148
|
}
|
|
7149
|
-
class
|
|
7149
|
+
class ga {
|
|
7150
7150
|
constructor(t, n, s) {
|
|
7151
7151
|
this.root = t, this.doc = n, this.fragment = s, this.pending = !1, this.destroyed = !1, this.onFragmentChange = (r, i) => {
|
|
7152
7152
|
i.origin !== this && this.applyRemoteToDom();
|
|
@@ -7162,7 +7162,7 @@ class da {
|
|
|
7162
7162
|
const t = this.captureSelection();
|
|
7163
7163
|
this.observer.disconnect(), this.root.dispatchEvent(new CustomEvent("provenance:expect", { detail: { kind: "collaborator", timeoutMs: 1e3 }, bubbles: !0 }));
|
|
7164
7164
|
try {
|
|
7165
|
-
|
|
7165
|
+
li(this.root, this.fragment, this.root.ownerDocument), this.root.dispatchEvent(new Event("input", { bubbles: !0, composed: !0 }));
|
|
7166
7166
|
} finally {
|
|
7167
7167
|
this.observer.observe(this.root, { childList: !0, characterData: !0, subtree: !0, attributes: !0 });
|
|
7168
7168
|
}
|
|
@@ -7211,7 +7211,7 @@ class da {
|
|
|
7211
7211
|
}
|
|
7212
7212
|
}
|
|
7213
7213
|
const Ds = "editora-collaboration-cursor-styles";
|
|
7214
|
-
function
|
|
7214
|
+
function pa() {
|
|
7215
7215
|
if (typeof document > "u" || document.getElementById(Ds)) return;
|
|
7216
7216
|
const e = document.createElement("style");
|
|
7217
7217
|
e.id = Ds, e.textContent = `
|
|
@@ -7243,19 +7243,19 @@ function fa() {
|
|
|
7243
7243
|
}
|
|
7244
7244
|
`, document.head.appendChild(e);
|
|
7245
7245
|
}
|
|
7246
|
-
const
|
|
7247
|
-
function
|
|
7246
|
+
const wa = /^(?:#[0-9a-f]{3,8}|[a-z]{3,20}|(?:rgb|hsl)a?\([\d\s.,%/-]+\))$/i, ma = "#64748b";
|
|
7247
|
+
function ai(e) {
|
|
7248
7248
|
if (!e || typeof e != "object") return null;
|
|
7249
7249
|
const { name: t, color: n } = e;
|
|
7250
7250
|
return typeof t != "string" || t.length === 0 ? null : {
|
|
7251
7251
|
name: t.slice(0, 64),
|
|
7252
|
-
color: typeof n == "string" &&
|
|
7252
|
+
color: typeof n == "string" && wa.test(n.trim()) ? n.trim() : ma
|
|
7253
7253
|
};
|
|
7254
7254
|
}
|
|
7255
7255
|
function As(e) {
|
|
7256
7256
|
return Array.isArray(e) && e.length <= 256 && e.every((t) => Number.isInteger(t) && t >= 0);
|
|
7257
7257
|
}
|
|
7258
|
-
function
|
|
7258
|
+
function ya(e) {
|
|
7259
7259
|
if (!e || typeof e != "object") return null;
|
|
7260
7260
|
const t = e;
|
|
7261
7261
|
if (!As(t.anchorPath)) return null;
|
|
@@ -7267,7 +7267,7 @@ function wa(e) {
|
|
|
7267
7267
|
focusOffset: n(t.focusOffset)
|
|
7268
7268
|
};
|
|
7269
7269
|
}
|
|
7270
|
-
function
|
|
7270
|
+
function Ts(e, t) {
|
|
7271
7271
|
let n = e;
|
|
7272
7272
|
for (const s of t) {
|
|
7273
7273
|
const r = n.childNodes[s];
|
|
@@ -7276,7 +7276,7 @@ function xs(e, t) {
|
|
|
7276
7276
|
}
|
|
7277
7277
|
return n;
|
|
7278
7278
|
}
|
|
7279
|
-
function
|
|
7279
|
+
function xs(e, t, n) {
|
|
7280
7280
|
if (!e.contains(t)) return null;
|
|
7281
7281
|
const s = [];
|
|
7282
7282
|
let r = t;
|
|
@@ -7287,9 +7287,9 @@ function Ts(e, t, n) {
|
|
|
7287
7287
|
}
|
|
7288
7288
|
return { path: s, offset: n };
|
|
7289
7289
|
}
|
|
7290
|
-
class
|
|
7290
|
+
class ba {
|
|
7291
7291
|
constructor(t, n, s) {
|
|
7292
|
-
this.root = t, this.awareness = n, this.user = s, this.caretElements = /* @__PURE__ */ new Map(), this.pendingBroadcast = !1, this.onSelectionChange = () => this.scheduleBroadcast(), this.onAwarenessChange = () => this.renderRemoteCursors(), this.onViewportChange = () => this.renderRemoteCursors(),
|
|
7292
|
+
this.root = t, this.awareness = n, this.user = s, this.caretElements = /* @__PURE__ */ new Map(), this.pendingBroadcast = !1, this.onSelectionChange = () => this.scheduleBroadcast(), this.onAwarenessChange = () => this.renderRemoteCursors(), this.onViewportChange = () => this.renderRemoteCursors(), pa(), this.awareness.setLocalStateField("user", this.user), document.addEventListener("selectionchange", this.onSelectionChange), this.awareness.on("change", this.onAwarenessChange), window.addEventListener("scroll", this.onViewportChange, !0), window.addEventListener("resize", this.onViewportChange);
|
|
7293
7293
|
}
|
|
7294
7294
|
scheduleBroadcast() {
|
|
7295
7295
|
this.pendingBroadcast || (this.pendingBroadcast = !0, queueMicrotask(() => {
|
|
@@ -7306,7 +7306,7 @@ class ma {
|
|
|
7306
7306
|
this.awareness.setLocalStateField("cursor", null);
|
|
7307
7307
|
return;
|
|
7308
7308
|
}
|
|
7309
|
-
const n =
|
|
7309
|
+
const n = xs(this.root, t.anchorNode, t.anchorOffset), s = xs(this.root, t.focusNode, t.focusOffset);
|
|
7310
7310
|
if (!n || !s) return;
|
|
7311
7311
|
const r = {
|
|
7312
7312
|
anchorPath: n.path,
|
|
@@ -7320,7 +7320,7 @@ class ma {
|
|
|
7320
7320
|
const t = this.awareness.getStates(), n = /* @__PURE__ */ new Set();
|
|
7321
7321
|
t.forEach((s, r) => {
|
|
7322
7322
|
if (r === this.awareness.clientID) return;
|
|
7323
|
-
const i =
|
|
7323
|
+
const i = ai(s?.user), o = ya(s?.cursor);
|
|
7324
7324
|
if (!i || !o) {
|
|
7325
7325
|
this.removeCursor(r);
|
|
7326
7326
|
return;
|
|
@@ -7331,7 +7331,7 @@ class ma {
|
|
|
7331
7331
|
n.has(s) || this.removeCursor(s);
|
|
7332
7332
|
}
|
|
7333
7333
|
renderCursor(t, n, s) {
|
|
7334
|
-
const r =
|
|
7334
|
+
const r = Ts(this.root, s.anchorPath);
|
|
7335
7335
|
if (!r) {
|
|
7336
7336
|
this.removeCursor(t);
|
|
7337
7337
|
return;
|
|
@@ -7352,7 +7352,7 @@ class ma {
|
|
|
7352
7352
|
c.setStart(r, l), c.setEnd(r, l);
|
|
7353
7353
|
const a = c.getBoundingClientRect();
|
|
7354
7354
|
if (i.caret.style.top = `${a.top}px`, i.caret.style.left = `${a.left}px`, i.caret.style.height = `${a.height || 16}px`, s.focusPath) {
|
|
7355
|
-
const h =
|
|
7355
|
+
const h = Ts(this.root, s.focusPath);
|
|
7356
7356
|
if (h) {
|
|
7357
7357
|
const u = Math.min(s.focusOffset ?? 0, (h.textContent ?? "").length), d = document.createRange();
|
|
7358
7358
|
d.setStart(r, l), d.setEnd(h, u);
|
|
@@ -7374,50 +7374,68 @@ class ma {
|
|
|
7374
7374
|
for (const t of Array.from(this.caretElements.keys())) this.removeCursor(t);
|
|
7375
7375
|
}
|
|
7376
7376
|
}
|
|
7377
|
-
const
|
|
7378
|
-
let Ls = !1;
|
|
7379
|
-
function
|
|
7377
|
+
const ka = "editora-content", hi = "wss://demos.yjs.dev", _a = "demos.yjs.dev", Sa = "editora-default-room", Is = ["#f97316", "#0ea5e9", "#22c55e", "#a855f7", "#ec4899", "#eab308", "#14b8a6", "#ef4444"], gt = /* @__PURE__ */ new WeakMap(), Kn = /* @__PURE__ */ new Set(), pt = /* @__PURE__ */ new Set(), Ae = /* @__PURE__ */ new Map();
|
|
7378
|
+
let Ls = !1, Os = !1;
|
|
7379
|
+
function Ca(e, t) {
|
|
7380
7380
|
Ls || (Ls = !0, console.warn(
|
|
7381
|
-
`[@editora/collaboration]
|
|
7381
|
+
`[@editora/collaboration] Room "${e}" is syncing through the public demo server (${t}); anyone who knows the room name can read and edit this document. Use it for demos only: pass your own y-websocket server via the websocketUrl option (or a provider) for real use.`
|
|
7382
7382
|
));
|
|
7383
7383
|
}
|
|
7384
|
-
function
|
|
7384
|
+
function Ea(e) {
|
|
7385
|
+
try {
|
|
7386
|
+
return new URL(e).hostname === _a;
|
|
7387
|
+
} catch {
|
|
7388
|
+
return !1;
|
|
7389
|
+
}
|
|
7390
|
+
}
|
|
7391
|
+
function ui(e) {
|
|
7392
|
+
return (typeof e.websocketUrl == "string" ? e.websocketUrl.trim() : "") || void 0;
|
|
7393
|
+
}
|
|
7394
|
+
function Da(e) {
|
|
7395
|
+
return e.provider || ui(e) ? !0 : e.allowPublicDemoServer === !0;
|
|
7396
|
+
}
|
|
7397
|
+
function Aa() {
|
|
7398
|
+
Os || (Os = !0, console.warn(
|
|
7399
|
+
`[@editora/collaboration] Not connecting: no websocketUrl or provider was configured. This plugin used to fall back to the public Yjs demo server (${hi}), where anyone who knows the room name can read and edit the document, so it now stays off until you pass your own y-websocket server via the websocketUrl option (or a provider). For a throwaway demo only, set allowPublicDemoServer: true.`
|
|
7400
|
+
));
|
|
7401
|
+
}
|
|
7402
|
+
function Ns() {
|
|
7385
7403
|
const e = Math.floor(Math.random() * 1e4);
|
|
7386
7404
|
return {
|
|
7387
7405
|
name: `Guest ${e}`,
|
|
7388
7406
|
color: Is[e % Is.length]
|
|
7389
7407
|
};
|
|
7390
7408
|
}
|
|
7391
|
-
let
|
|
7392
|
-
const St = [],
|
|
7409
|
+
let Ta = 1;
|
|
7410
|
+
const St = [], di = ".rte-content, .editora-content, [contenteditable]";
|
|
7393
7411
|
let tn = null;
|
|
7394
|
-
function
|
|
7395
|
-
return e.matches(
|
|
7412
|
+
function xa(e) {
|
|
7413
|
+
return e.matches(di);
|
|
7396
7414
|
}
|
|
7397
|
-
function
|
|
7415
|
+
function Ia(e) {
|
|
7398
7416
|
const t = [];
|
|
7399
|
-
return e instanceof HTMLElement &&
|
|
7417
|
+
return e instanceof HTMLElement && xa(e) && !gt.has(e) && !pt.has(e) && t.push(e), e.querySelectorAll(di).forEach((n) => {
|
|
7400
7418
|
n instanceof HTMLElement && !gt.has(n) && !pt.has(n) && t.push(n);
|
|
7401
7419
|
}), t;
|
|
7402
7420
|
}
|
|
7403
|
-
function
|
|
7421
|
+
function fi() {
|
|
7404
7422
|
if (St.length === 0 || typeof document > "u") return;
|
|
7405
|
-
const e =
|
|
7423
|
+
const e = Ia(document.body);
|
|
7406
7424
|
for (const t of e) {
|
|
7407
7425
|
const n = St.find((s) => !s.claimed);
|
|
7408
7426
|
if (!n) break;
|
|
7409
|
-
n.claimed = !0,
|
|
7427
|
+
n.claimed = !0, va(t, n.options);
|
|
7410
7428
|
}
|
|
7411
7429
|
for (; St.length && St[0].claimed; ) St.shift();
|
|
7412
7430
|
}
|
|
7413
|
-
function
|
|
7414
|
-
tn || typeof document > "u" || typeof MutationObserver > "u" || (tn = new MutationObserver(() =>
|
|
7431
|
+
function La() {
|
|
7432
|
+
tn || typeof document > "u" || typeof MutationObserver > "u" || (tn = new MutationObserver(() => fi()), tn.observe(document.body, { childList: !0, subtree: !0 }));
|
|
7415
7433
|
}
|
|
7416
|
-
function
|
|
7417
|
-
const t = { id:
|
|
7418
|
-
return St.push(t),
|
|
7434
|
+
function Oa(e) {
|
|
7435
|
+
const t = { id: Ta++, options: e, claimed: !1 };
|
|
7436
|
+
return St.push(t), La(), fi(), t;
|
|
7419
7437
|
}
|
|
7420
|
-
function
|
|
7438
|
+
function Na() {
|
|
7421
7439
|
const e = "editora-collaboration-presence-styles";
|
|
7422
7440
|
if (typeof document > "u" || document.getElementById(e)) return;
|
|
7423
7441
|
const t = document.createElement("style");
|
|
@@ -7458,8 +7476,8 @@ function Aa() {
|
|
|
7458
7476
|
}
|
|
7459
7477
|
`, document.head.appendChild(t);
|
|
7460
7478
|
}
|
|
7461
|
-
function
|
|
7462
|
-
|
|
7479
|
+
function Ma() {
|
|
7480
|
+
Na();
|
|
7463
7481
|
const e = document.createElement("div");
|
|
7464
7482
|
e.className = "editora-collab-presence";
|
|
7465
7483
|
const t = document.createElement("span");
|
|
@@ -7474,34 +7492,34 @@ function de(e, t, n) {
|
|
|
7474
7492
|
if (!r) return;
|
|
7475
7493
|
r.innerHTML = "", n.getStates().forEach((o, c) => {
|
|
7476
7494
|
if (c === n.clientID) return;
|
|
7477
|
-
const l =
|
|
7495
|
+
const l = ai(o?.user);
|
|
7478
7496
|
if (!l) return;
|
|
7479
7497
|
const a = document.createElement("span");
|
|
7480
7498
|
a.className = "editora-collab-presence__avatar", a.style.backgroundColor = l.color, a.title = l.name, a.textContent = Array.from(l.name)[0].toUpperCase(), r.appendChild(a);
|
|
7481
7499
|
});
|
|
7482
7500
|
}
|
|
7483
|
-
function
|
|
7501
|
+
function va(e, t) {
|
|
7484
7502
|
if (gt.has(e) || pt.has(e)) return;
|
|
7485
7503
|
pt.add(e);
|
|
7486
|
-
const n = t.doc ?? t.provider?.doc ?? new mt(), s = !t.doc && !t.provider, r = typeof t.roomName == "function" ? t.roomName(e) : t.roomName || e.id ||
|
|
7487
|
-
i &&
|
|
7488
|
-
const
|
|
7489
|
-
name: t.userName ??
|
|
7490
|
-
color: t.userColor ??
|
|
7491
|
-
},
|
|
7492
|
-
e.insertAdjacentElement("beforebegin",
|
|
7493
|
-
const
|
|
7494
|
-
|
|
7495
|
-
const
|
|
7496
|
-
|
|
7504
|
+
const n = t.doc ?? t.provider?.doc ?? new mt(), s = !t.doc && !t.provider, r = typeof t.roomName == "function" ? t.roomName(e) : t.roomName || e.id || Sa, i = !t.provider, o = ui(t) ?? hi;
|
|
7505
|
+
i && Ea(o) && Ca(r, o);
|
|
7506
|
+
const c = t.provider ?? new Ql(o, r, n), l = {
|
|
7507
|
+
name: t.userName ?? Ns().name,
|
|
7508
|
+
color: t.userColor ?? Ns().color
|
|
7509
|
+
}, a = Ma();
|
|
7510
|
+
e.insertAdjacentElement("beforebegin", a), de(a, "connecting", c.awareness);
|
|
7511
|
+
const h = ({ status: f }) => de(a, f, c.awareness), u = () => de(a, c.wsconnected ? "connected" : "connecting", c.awareness);
|
|
7512
|
+
c.on("status", h), c.awareness.on("change", u);
|
|
7513
|
+
const d = (f) => {
|
|
7514
|
+
f && (c.off("sync", d), Ae.delete(e), Ua(e, n, c, i, s, l, a, h, u));
|
|
7497
7515
|
};
|
|
7498
7516
|
Ae.set(e, () => {
|
|
7499
|
-
|
|
7500
|
-
}),
|
|
7517
|
+
c.off("sync", d), c.off("status", h), c.awareness.off("change", u), a.remove(), i && c.destroy(), s && n.destroy();
|
|
7518
|
+
}), c.synced ? d(!0) : c.on("sync", d);
|
|
7501
7519
|
}
|
|
7502
|
-
function
|
|
7520
|
+
function Ua(e, t, n, s, r, i, o, c, l) {
|
|
7503
7521
|
if (pt.delete(e), gt.has(e)) return;
|
|
7504
|
-
const a = t.getXmlFragment(
|
|
7522
|
+
const a = t.getXmlFragment(ka), h = new ga(e, t, a), u = new ba(e, n.awareness, i), d = new jc(a, { trackedOrigins: /* @__PURE__ */ new Set([h]) });
|
|
7505
7523
|
de(o, n.wsconnected ? "connected" : "connecting", n.awareness);
|
|
7506
7524
|
const f = (p) => {
|
|
7507
7525
|
(p.metaKey || p.ctrlKey) && (p.key.toLowerCase() === "z" && !p.shiftKey ? (p.preventDefault(), p.stopImmediatePropagation(), d.undo()) : (p.key.toLowerCase() === "z" && p.shiftKey || p.key.toLowerCase() === "y") && (p.preventDefault(), p.stopImmediatePropagation(), d.redo()));
|
|
@@ -7512,27 +7530,34 @@ function Ia(e, t, n, s, r, i, o, c, l) {
|
|
|
7512
7530
|
};
|
|
7513
7531
|
gt.set(e, { doc: t, provider: n, ownsProvider: s, ownsDoc: r, binding: h, undoManager: d, cursorCleanup: g, connectionIndicator: o }), Kn.add(e);
|
|
7514
7532
|
}
|
|
7515
|
-
function
|
|
7533
|
+
function Ra(e) {
|
|
7516
7534
|
const t = Ae.get(e);
|
|
7517
7535
|
t && (t(), Ae.delete(e), pt.delete(e));
|
|
7518
7536
|
const n = gt.get(e);
|
|
7519
7537
|
n && (n.cursorCleanup(), n.binding.destroy(), n.undoManager.destroy(), n.ownsProvider && n.provider.destroy(), n.ownsDoc && n.doc.destroy(), gt.delete(e), Kn.delete(e));
|
|
7520
7538
|
}
|
|
7521
|
-
const
|
|
7539
|
+
const $a = (e = {}) => {
|
|
7522
7540
|
let t = !1;
|
|
7523
7541
|
const n = {
|
|
7524
7542
|
name: "collaboration",
|
|
7525
7543
|
init: () => {
|
|
7526
|
-
|
|
7544
|
+
if (t) return;
|
|
7545
|
+
t = !0;
|
|
7546
|
+
const s = { ...e, ...n.__pluginConfig ?? {} };
|
|
7547
|
+
if (!Da(s)) {
|
|
7548
|
+
Aa();
|
|
7549
|
+
return;
|
|
7550
|
+
}
|
|
7551
|
+
Oa(s);
|
|
7527
7552
|
},
|
|
7528
7553
|
commands: {},
|
|
7529
7554
|
destroy: () => {
|
|
7530
7555
|
const s = /* @__PURE__ */ new Set([...Kn, ...pt]);
|
|
7531
|
-
Array.from(s).forEach((r) =>
|
|
7556
|
+
Array.from(s).forEach((r) => Ra(r));
|
|
7532
7557
|
}
|
|
7533
7558
|
};
|
|
7534
7559
|
return n;
|
|
7535
7560
|
};
|
|
7536
7561
|
export {
|
|
7537
|
-
|
|
7562
|
+
$a as CollaborationPlugin
|
|
7538
7563
|
};
|