playhtml 2.0.7 → 2.0.8
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/dist/main.d.ts +1 -1
- package/dist/playhtml.es.js +1017 -950
- package/dist/playhtml.umd.js +7 -7
- package/package.json +2 -2
package/dist/playhtml.es.js
CHANGED
|
@@ -1,29 +1,73 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var b = (s, e, t) => (
|
|
4
|
-
|
|
1
|
+
var gi = Object.defineProperty;
|
|
2
|
+
var pi = (s, e, t) => e in s ? gi(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var b = (s, e, t) => (pi(s, typeof e != "symbol" ? e + "" : e, t), t), ys = (s, e, t) => {
|
|
4
|
+
if (!e.has(s))
|
|
5
|
+
throw TypeError("Cannot " + t);
|
|
6
|
+
};
|
|
7
|
+
var Je = (s, e, t) => (ys(s, e, "read from private field"), t ? t.call(s) : e.get(s)), Ss = (s, e, t) => {
|
|
8
|
+
if (e.has(s))
|
|
9
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
+
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
+
}, _s = (s, e, t, n) => (ys(s, e, "write to private field"), n ? n.call(s, t) : e.set(s, t), t);
|
|
12
|
+
var We = 1e6, ki = "y-pk-batch", Ds = !1, mi = (s, e) => {
|
|
13
|
+
if (s.byteLength <= We) {
|
|
14
|
+
e(s);
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
Ds || (console.warn(
|
|
18
|
+
"[y-partykit]",
|
|
19
|
+
"The Y.js update size exceeds 1MB, which is the maximum size for an individual update. The update will be split into chunks. This is an experimental feature.",
|
|
20
|
+
`Message size: ${(s.byteLength / 1e3 / 1e3).toFixed(1)}MB`
|
|
21
|
+
), Ds = !0);
|
|
22
|
+
const t = (Date.now() + Math.random()).toString(36).substring(10), n = Math.ceil(s.byteLength / We);
|
|
23
|
+
e(
|
|
24
|
+
Es({
|
|
25
|
+
id: t,
|
|
26
|
+
type: "start",
|
|
27
|
+
size: s.byteLength,
|
|
28
|
+
count: n
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
let i = 0, r = 0;
|
|
32
|
+
for (let o = 0; o < n; o++) {
|
|
33
|
+
const a = s.slice(We * o, We * (o + 1));
|
|
34
|
+
e(a), r += 1, i += a.byteLength;
|
|
35
|
+
}
|
|
36
|
+
e(
|
|
37
|
+
Es({
|
|
38
|
+
id: t,
|
|
39
|
+
type: "end",
|
|
40
|
+
size: i,
|
|
41
|
+
count: r
|
|
42
|
+
})
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
function Es(s) {
|
|
46
|
+
return `${ki}#${JSON.stringify(s)}`;
|
|
47
|
+
}
|
|
48
|
+
const T = () => /* @__PURE__ */ new Map(), Tt = (s) => {
|
|
5
49
|
const e = T();
|
|
6
50
|
return s.forEach((t, n) => {
|
|
7
51
|
e.set(n, t);
|
|
8
52
|
}), e;
|
|
9
|
-
},
|
|
53
|
+
}, W = (s, e, t) => {
|
|
10
54
|
let n = s.get(e);
|
|
11
55
|
return n === void 0 && s.set(e, n = t()), n;
|
|
12
|
-
},
|
|
56
|
+
}, bi = (s, e) => {
|
|
13
57
|
const t = [];
|
|
14
58
|
for (const [n, i] of s)
|
|
15
59
|
t.push(e(i, n));
|
|
16
60
|
return t;
|
|
17
|
-
},
|
|
61
|
+
}, wi = (s, e) => {
|
|
18
62
|
for (const [t, n] of s)
|
|
19
63
|
if (e(n, t))
|
|
20
64
|
return !0;
|
|
21
65
|
return !1;
|
|
22
|
-
},
|
|
66
|
+
}, ce = () => /* @__PURE__ */ new Set(), _t = (s) => s[s.length - 1], yi = (s, e) => {
|
|
23
67
|
for (let t = 0; t < e.length; t++)
|
|
24
68
|
s.push(e[t]);
|
|
25
|
-
}, te = Array.from,
|
|
26
|
-
class
|
|
69
|
+
}, te = Array.from, Si = Array.isArray;
|
|
70
|
+
class ft {
|
|
27
71
|
constructor() {
|
|
28
72
|
this._observers = T();
|
|
29
73
|
}
|
|
@@ -32,7 +76,7 @@ class ht {
|
|
|
32
76
|
* @param {function} f
|
|
33
77
|
*/
|
|
34
78
|
on(e, t) {
|
|
35
|
-
|
|
79
|
+
W(this._observers, e, ce).add(t);
|
|
36
80
|
}
|
|
37
81
|
/**
|
|
38
82
|
* @param {N} name
|
|
@@ -68,7 +112,7 @@ class ht {
|
|
|
68
112
|
this._observers = T();
|
|
69
113
|
}
|
|
70
114
|
}
|
|
71
|
-
const X = Math.floor,
|
|
115
|
+
const X = Math.floor, et = Math.abs, Jt = (s, e) => s < e ? s : e, ge = (s, e) => s > e ? s : e, _i = Math.pow, Zs = (s) => s !== 0 ? s < 0 : 1 / s < 0, Di = String.fromCharCode, Ei = (s) => s.toLowerCase(), Ci = /^\s*/g, vi = (s) => s.replace(Ci, ""), Ai = /([A-Z])/g, Cs = (s, e) => vi(s.replace(Ai, (t) => `${e}${Ei(t)}`)), xi = (s) => {
|
|
72
116
|
const e = unescape(encodeURIComponent(s)), t = e.length, n = new Uint8Array(t);
|
|
73
117
|
for (let i = 0; i < t; i++)
|
|
74
118
|
n[i] = /** @type {number} */
|
|
@@ -77,11 +121,11 @@ const X = Math.floor, Pe = Math.abs, Yt = (s, e) => s < e ? s : e, fe = (s, e) =
|
|
|
77
121
|
}, Ue = (
|
|
78
122
|
/** @type {TextEncoder} */
|
|
79
123
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
80
|
-
),
|
|
81
|
-
let
|
|
82
|
-
|
|
83
|
-
const
|
|
84
|
-
class
|
|
124
|
+
), Li = (s) => Ue.encode(s), Ii = Ue ? Li : xi;
|
|
125
|
+
let je = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
126
|
+
je && je.decode(new Uint8Array()).length === 1 && (je = null);
|
|
127
|
+
const vs = (s) => s === void 0 ? null : s;
|
|
128
|
+
class ji {
|
|
85
129
|
constructor() {
|
|
86
130
|
this.map = /* @__PURE__ */ new Map();
|
|
87
131
|
}
|
|
@@ -99,46 +143,46 @@ class yi {
|
|
|
99
143
|
return this.map.get(e);
|
|
100
144
|
}
|
|
101
145
|
}
|
|
102
|
-
let
|
|
146
|
+
let Qs = new ji(), Wt = !0;
|
|
103
147
|
try {
|
|
104
|
-
typeof localStorage < "u" && (
|
|
148
|
+
typeof localStorage < "u" && (Qs = localStorage, Wt = !1);
|
|
105
149
|
} catch {
|
|
106
150
|
}
|
|
107
|
-
const
|
|
151
|
+
const en = Qs, Mi = (s) => Wt || addEventListener(
|
|
108
152
|
"storage",
|
|
109
153
|
/** @type {any} */
|
|
110
154
|
s
|
|
111
|
-
),
|
|
155
|
+
), zi = (s) => Wt || removeEventListener(
|
|
112
156
|
"storage",
|
|
113
157
|
/** @type {any} */
|
|
114
158
|
s
|
|
115
|
-
),
|
|
159
|
+
), Ui = Object.assign, Ti = Object.keys, Oi = (s, e) => {
|
|
116
160
|
for (const t in s)
|
|
117
161
|
e(s[t], t);
|
|
118
|
-
},
|
|
162
|
+
}, Ri = (s, e) => {
|
|
119
163
|
const t = [];
|
|
120
164
|
for (const n in s)
|
|
121
165
|
t.push(e(s[n], n));
|
|
122
166
|
return t;
|
|
123
|
-
},
|
|
167
|
+
}, it = (s) => Ti(s).length, Bi = (s) => {
|
|
124
168
|
for (const e in s)
|
|
125
169
|
return !1;
|
|
126
170
|
return !0;
|
|
127
|
-
},
|
|
171
|
+
}, Ni = (s, e) => {
|
|
128
172
|
for (const t in s)
|
|
129
173
|
if (!e(s[t], t))
|
|
130
174
|
return !1;
|
|
131
175
|
return !0;
|
|
132
|
-
},
|
|
176
|
+
}, tn = (s, e) => Object.prototype.hasOwnProperty.call(s, e), Fi = (s, e) => s === e || it(s) === it(e) && Ni(s, (t, n) => (t !== void 0 || tn(e, n)) && e[n] === t), Gt = (s, e, t = 0) => {
|
|
133
177
|
try {
|
|
134
178
|
for (; t < s.length; t++)
|
|
135
179
|
s[t](...e);
|
|
136
180
|
} finally {
|
|
137
|
-
t < s.length &&
|
|
181
|
+
t < s.length && Gt(s, e, t + 1);
|
|
138
182
|
}
|
|
139
|
-
},
|
|
183
|
+
}, Hi = (s) => s, Vi = (s, e) => s === e, Me = (s, e) => {
|
|
140
184
|
if (s == null || e == null)
|
|
141
|
-
return
|
|
185
|
+
return Vi(s, e);
|
|
142
186
|
if (s.constructor !== e.constructor)
|
|
143
187
|
return !1;
|
|
144
188
|
if (s === e)
|
|
@@ -166,31 +210,31 @@ const Ys = qs, _i = (s) => Kt || addEventListener(
|
|
|
166
210
|
if (s.size !== e.size)
|
|
167
211
|
return !1;
|
|
168
212
|
for (const t of s.keys())
|
|
169
|
-
if (!e.has(t) || !
|
|
213
|
+
if (!e.has(t) || !Me(s.get(t), e.get(t)))
|
|
170
214
|
return !1;
|
|
171
215
|
break;
|
|
172
216
|
}
|
|
173
217
|
case Object:
|
|
174
|
-
if (
|
|
218
|
+
if (it(s) !== it(e))
|
|
175
219
|
return !1;
|
|
176
220
|
for (const t in s)
|
|
177
|
-
if (!
|
|
221
|
+
if (!tn(s, t) || !Me(s[t], e[t]))
|
|
178
222
|
return !1;
|
|
179
223
|
break;
|
|
180
224
|
case Array:
|
|
181
225
|
if (s.length !== e.length)
|
|
182
226
|
return !1;
|
|
183
227
|
for (let t = 0; t < s.length; t++)
|
|
184
|
-
if (!
|
|
228
|
+
if (!Me(s[t], e[t]))
|
|
185
229
|
return !1;
|
|
186
230
|
break;
|
|
187
231
|
default:
|
|
188
232
|
return !1;
|
|
189
233
|
}
|
|
190
234
|
return !0;
|
|
191
|
-
},
|
|
235
|
+
}, $i = (s, e) => e.includes(s), _e = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), sn = typeof window < "u" && typeof document < "u" && !_e;
|
|
192
236
|
let O;
|
|
193
|
-
const
|
|
237
|
+
const qi = () => {
|
|
194
238
|
if (O === void 0)
|
|
195
239
|
if (_e) {
|
|
196
240
|
O = T();
|
|
@@ -205,18 +249,18 @@ const Ui = () => {
|
|
|
205
249
|
typeof location == "object" ? (O = T(), (location.search || "?").slice(1).split("&").forEach((s) => {
|
|
206
250
|
if (s.length !== 0) {
|
|
207
251
|
const [e, t] = s.split("=");
|
|
208
|
-
O.set(`--${
|
|
252
|
+
O.set(`--${Cs(e, "-")}`, t), O.set(`-${Cs(e, "-")}`, t);
|
|
209
253
|
}
|
|
210
254
|
})) : O = T();
|
|
211
255
|
return O;
|
|
212
|
-
},
|
|
213
|
-
|
|
214
|
-
const
|
|
256
|
+
}, Ot = (s) => qi().has(s), Rt = (s) => vs(_e ? process.env[s.toUpperCase()] : en.getItem(s)), Ki = (s) => Ot("--" + s) || Rt(s) !== null;
|
|
257
|
+
Ki("production");
|
|
258
|
+
const As = _e && $i(process.env.FORCE_COLOR, ["true", "1", "2"]), Yi = !Ot("no-colors") && (!_e || process.stdout.isTTY || As) && (!_e || Ot("color") || As || Rt("COLORTERM") !== null || (Rt("TERM") || "").includes("color")), xs = 1, Ls = 2, Dt = 4, Et = 8, Te = 32, K = 64, M = 128, gt = 31, Bt = 63, oe = 127, Xi = 2147483647, nn = Number.MAX_SAFE_INTEGER, Ji = Number.isInteger || ((s) => typeof s == "number" && isFinite(s) && X(s) === s), J = (s) => new Error(s), R = () => {
|
|
215
259
|
throw J("Method unimplemented");
|
|
216
260
|
}, F = () => {
|
|
217
261
|
throw J("Unexpected case");
|
|
218
|
-
},
|
|
219
|
-
class
|
|
262
|
+
}, rn = J("Unexpected end of array"), on = J("Integer out of Range");
|
|
263
|
+
class pt {
|
|
220
264
|
/**
|
|
221
265
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
222
266
|
*/
|
|
@@ -224,42 +268,42 @@ class dt {
|
|
|
224
268
|
this.arr = e, this.pos = 0;
|
|
225
269
|
}
|
|
226
270
|
}
|
|
227
|
-
const ne = (s) => new
|
|
228
|
-
const t =
|
|
271
|
+
const ne = (s) => new pt(s), Wi = (s) => s.pos !== s.arr.length, Gi = (s, e) => {
|
|
272
|
+
const t = Qt(s.arr.buffer, s.pos + s.arr.byteOffset, e);
|
|
229
273
|
return s.pos += e, t;
|
|
230
|
-
}, L = (s) =>
|
|
274
|
+
}, L = (s) => Gi(s, m(s)), De = (s) => s.arr[s.pos++], m = (s) => {
|
|
231
275
|
let e = 0, t = 1;
|
|
232
276
|
const n = s.arr.length;
|
|
233
277
|
for (; s.pos < n; ) {
|
|
234
278
|
const i = s.arr[s.pos++];
|
|
235
|
-
if (e = e + (i &
|
|
279
|
+
if (e = e + (i & oe) * t, t *= 128, i < M)
|
|
236
280
|
return e;
|
|
237
|
-
if (e >
|
|
238
|
-
throw
|
|
281
|
+
if (e > nn)
|
|
282
|
+
throw on;
|
|
239
283
|
}
|
|
240
|
-
throw
|
|
241
|
-
},
|
|
242
|
-
let e = s.arr[s.pos++], t = e &
|
|
243
|
-
const i = (e &
|
|
284
|
+
throw rn;
|
|
285
|
+
}, Pt = (s) => {
|
|
286
|
+
let e = s.arr[s.pos++], t = e & Bt, n = 64;
|
|
287
|
+
const i = (e & K) > 0 ? -1 : 1;
|
|
244
288
|
if (!(e & M))
|
|
245
289
|
return i * t;
|
|
246
290
|
const r = s.arr.length;
|
|
247
291
|
for (; s.pos < r; ) {
|
|
248
|
-
if (e = s.arr[s.pos++], t = t + (e &
|
|
292
|
+
if (e = s.arr[s.pos++], t = t + (e & oe) * n, n *= 128, e < M)
|
|
249
293
|
return i * t;
|
|
250
|
-
if (t >
|
|
251
|
-
throw
|
|
294
|
+
if (t > nn)
|
|
295
|
+
throw on;
|
|
252
296
|
}
|
|
253
|
-
throw
|
|
254
|
-
},
|
|
297
|
+
throw rn;
|
|
298
|
+
}, Pi = (s) => {
|
|
255
299
|
let e = m(s);
|
|
256
300
|
if (e === 0)
|
|
257
301
|
return "";
|
|
258
302
|
{
|
|
259
|
-
let t = String.fromCodePoint(
|
|
303
|
+
let t = String.fromCodePoint(De(s));
|
|
260
304
|
if (--e < 100)
|
|
261
305
|
for (; e--; )
|
|
262
|
-
t += String.fromCodePoint(
|
|
306
|
+
t += String.fromCodePoint(De(s));
|
|
263
307
|
else
|
|
264
308
|
for (; e > 0; ) {
|
|
265
309
|
const n = e < 1e4 ? e : 1e4, i = s.arr.subarray(s.pos, s.pos + n);
|
|
@@ -271,28 +315,28 @@ const ne = (s) => new dt(s), Bi = (s) => s.pos !== s.arr.length, Ni = (s, e) =>
|
|
|
271
315
|
}
|
|
272
316
|
return decodeURIComponent(escape(t));
|
|
273
317
|
}
|
|
274
|
-
},
|
|
318
|
+
}, Zi = (s) => (
|
|
275
319
|
/** @type any */
|
|
276
|
-
|
|
277
|
-
), ee =
|
|
320
|
+
je.decode(L(s))
|
|
321
|
+
), ee = je ? Zi : Pi, Zt = (s, e) => {
|
|
278
322
|
const t = new DataView(s.arr.buffer, s.arr.byteOffset + s.pos, e);
|
|
279
323
|
return s.pos += e, t;
|
|
280
|
-
},
|
|
324
|
+
}, Qi = (s) => Zt(s, 4).getFloat32(0, !1), er = (s) => Zt(s, 8).getFloat64(0, !1), tr = (s) => (
|
|
281
325
|
/** @type {any} */
|
|
282
|
-
|
|
283
|
-
),
|
|
326
|
+
Zt(s, 8).getBigInt64(0, !1)
|
|
327
|
+
), sr = [
|
|
284
328
|
(s) => {
|
|
285
329
|
},
|
|
286
330
|
// CASE 127: undefined
|
|
287
331
|
(s) => null,
|
|
288
332
|
// CASE 126: null
|
|
289
|
-
|
|
333
|
+
Pt,
|
|
290
334
|
// CASE 125: integer
|
|
291
|
-
|
|
335
|
+
Qi,
|
|
292
336
|
// CASE 124: float32
|
|
293
|
-
|
|
337
|
+
er,
|
|
294
338
|
// CASE 123: float64
|
|
295
|
-
|
|
339
|
+
tr,
|
|
296
340
|
// CASE 122: bigint
|
|
297
341
|
(s) => !1,
|
|
298
342
|
// CASE 121: boolean (false)
|
|
@@ -304,20 +348,20 @@ const ne = (s) => new dt(s), Bi = (s) => s.pos !== s.arr.length, Ni = (s, e) =>
|
|
|
304
348
|
const e = m(s), t = {};
|
|
305
349
|
for (let n = 0; n < e; n++) {
|
|
306
350
|
const i = ee(s);
|
|
307
|
-
t[i] =
|
|
351
|
+
t[i] = Oe(s);
|
|
308
352
|
}
|
|
309
353
|
return t;
|
|
310
354
|
},
|
|
311
355
|
(s) => {
|
|
312
356
|
const e = m(s), t = [];
|
|
313
357
|
for (let n = 0; n < e; n++)
|
|
314
|
-
t.push(
|
|
358
|
+
t.push(Oe(s));
|
|
315
359
|
return t;
|
|
316
360
|
},
|
|
317
361
|
L
|
|
318
362
|
// CASE 116: Uint8Array
|
|
319
|
-
],
|
|
320
|
-
class
|
|
363
|
+
], Oe = (s) => sr[127 - De(s)](s);
|
|
364
|
+
class Is extends pt {
|
|
321
365
|
/**
|
|
322
366
|
* @param {Uint8Array} uint8Array
|
|
323
367
|
* @param {function(Decoder):T} reader
|
|
@@ -326,11 +370,11 @@ class Ss extends dt {
|
|
|
326
370
|
super(e), this.reader = t, this.s = null, this.count = 0;
|
|
327
371
|
}
|
|
328
372
|
read() {
|
|
329
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
373
|
+
return this.count === 0 && (this.s = this.reader(this), Wi(this) ? this.count = m(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
330
374
|
this.s;
|
|
331
375
|
}
|
|
332
376
|
}
|
|
333
|
-
class
|
|
377
|
+
class tt extends pt {
|
|
334
378
|
/**
|
|
335
379
|
* @param {Uint8Array} uint8Array
|
|
336
380
|
*/
|
|
@@ -339,15 +383,15 @@ class Qe extends dt {
|
|
|
339
383
|
}
|
|
340
384
|
read() {
|
|
341
385
|
if (this.count === 0) {
|
|
342
|
-
this.s =
|
|
343
|
-
const e =
|
|
386
|
+
this.s = Pt(this);
|
|
387
|
+
const e = Zs(this.s);
|
|
344
388
|
this.count = 1, e && (this.s = -this.s, this.count = m(this) + 2);
|
|
345
389
|
}
|
|
346
390
|
return this.count--, /** @type {number} */
|
|
347
391
|
this.s;
|
|
348
392
|
}
|
|
349
393
|
}
|
|
350
|
-
class
|
|
394
|
+
class Ct extends pt {
|
|
351
395
|
/**
|
|
352
396
|
* @param {Uint8Array} uint8Array
|
|
353
397
|
*/
|
|
@@ -359,18 +403,18 @@ class St extends dt {
|
|
|
359
403
|
*/
|
|
360
404
|
read() {
|
|
361
405
|
if (this.count === 0) {
|
|
362
|
-
const e =
|
|
406
|
+
const e = Pt(this), t = e & 1;
|
|
363
407
|
this.diff = X(e / 2), this.count = 1, t && (this.count = m(this) + 2);
|
|
364
408
|
}
|
|
365
409
|
return this.s += this.diff, this.count--, this.s;
|
|
366
410
|
}
|
|
367
411
|
}
|
|
368
|
-
class
|
|
412
|
+
class nr {
|
|
369
413
|
/**
|
|
370
414
|
* @param {Uint8Array} uint8Array
|
|
371
415
|
*/
|
|
372
416
|
constructor(e) {
|
|
373
|
-
this.decoder = new
|
|
417
|
+
this.decoder = new tt(e), this.str = ee(this.decoder), this.spos = 0;
|
|
374
418
|
}
|
|
375
419
|
/**
|
|
376
420
|
* @return {string}
|
|
@@ -380,64 +424,64 @@ class Ki {
|
|
|
380
424
|
return this.spos = e, t;
|
|
381
425
|
}
|
|
382
426
|
}
|
|
383
|
-
const
|
|
427
|
+
const an = (s) => new Uint8Array(s), Qt = (s, e, t) => new Uint8Array(s, e, t), ir = (s) => new Uint8Array(s), rr = (s) => {
|
|
384
428
|
let e = "";
|
|
385
429
|
for (let t = 0; t < s.byteLength; t++)
|
|
386
|
-
e +=
|
|
430
|
+
e += Di(s[t]);
|
|
387
431
|
return btoa(e);
|
|
388
|
-
},
|
|
389
|
-
const e = atob(s), t =
|
|
432
|
+
}, or = (s) => Buffer.from(s.buffer, s.byteOffset, s.byteLength).toString("base64"), ar = (s) => {
|
|
433
|
+
const e = atob(s), t = an(e.length);
|
|
390
434
|
for (let n = 0; n < e.length; n++)
|
|
391
435
|
t[n] = e.charCodeAt(n);
|
|
392
436
|
return t;
|
|
393
|
-
},
|
|
437
|
+
}, cr = (s) => {
|
|
394
438
|
const e = Buffer.from(s, "base64");
|
|
395
439
|
return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
396
|
-
},
|
|
397
|
-
const e =
|
|
440
|
+
}, lr = sn ? rr : or, hr = sn ? ar : cr, ur = (s) => {
|
|
441
|
+
const e = an(s.byteLength);
|
|
398
442
|
return e.set(s), e;
|
|
399
443
|
};
|
|
400
|
-
class
|
|
444
|
+
class Ve {
|
|
401
445
|
constructor() {
|
|
402
446
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
403
447
|
}
|
|
404
448
|
}
|
|
405
|
-
const I = () => new
|
|
449
|
+
const I = () => new Ve(), es = (s) => {
|
|
406
450
|
let e = s.cpos;
|
|
407
451
|
for (let t = 0; t < s.bufs.length; t++)
|
|
408
452
|
e += s.bufs[t].length;
|
|
409
453
|
return e;
|
|
410
|
-
},
|
|
411
|
-
const e = new Uint8Array(
|
|
454
|
+
}, S = (s) => {
|
|
455
|
+
const e = new Uint8Array(es(s));
|
|
412
456
|
let t = 0;
|
|
413
457
|
for (let n = 0; n < s.bufs.length; n++) {
|
|
414
458
|
const i = s.bufs[n];
|
|
415
459
|
e.set(i, t), t += i.length;
|
|
416
460
|
}
|
|
417
|
-
return e.set(
|
|
418
|
-
},
|
|
461
|
+
return e.set(Qt(s.cbuf.buffer, 0, s.cpos), t), e;
|
|
462
|
+
}, dr = (s, e) => {
|
|
419
463
|
const t = s.cbuf.length;
|
|
420
|
-
t - s.cpos < e && (s.bufs.push(
|
|
464
|
+
t - s.cpos < e && (s.bufs.push(Qt(s.cbuf.buffer, 0, s.cpos)), s.cbuf = new Uint8Array(ge(t, e) * 2), s.cpos = 0);
|
|
421
465
|
}, v = (s, e) => {
|
|
422
466
|
const t = s.cbuf.length;
|
|
423
467
|
s.cpos === t && (s.bufs.push(s.cbuf), s.cbuf = new Uint8Array(t * 2), s.cpos = 0), s.cbuf[s.cpos++] = e;
|
|
424
|
-
},
|
|
425
|
-
for (; e >
|
|
426
|
-
v(s, M |
|
|
427
|
-
v(s,
|
|
428
|
-
},
|
|
429
|
-
const t =
|
|
430
|
-
for (t && (e = -e), v(s, (e >
|
|
431
|
-
v(s, (e >
|
|
432
|
-
},
|
|
433
|
-
if (e.length <
|
|
434
|
-
const t = Ue.encodeInto(e,
|
|
468
|
+
}, Nt = v, p = (s, e) => {
|
|
469
|
+
for (; e > oe; )
|
|
470
|
+
v(s, M | oe & e), e = X(e / 128);
|
|
471
|
+
v(s, oe & e);
|
|
472
|
+
}, ts = (s, e) => {
|
|
473
|
+
const t = Zs(e);
|
|
474
|
+
for (t && (e = -e), v(s, (e > Bt ? M : 0) | (t ? K : 0) | Bt & e), e = X(e / 64); e > 0; )
|
|
475
|
+
v(s, (e > oe ? M : 0) | oe & e), e = X(e / 128);
|
|
476
|
+
}, Ft = new Uint8Array(3e4), fr = Ft.length / 3, gr = (s, e) => {
|
|
477
|
+
if (e.length < fr) {
|
|
478
|
+
const t = Ue.encodeInto(e, Ft).written || 0;
|
|
435
479
|
p(s, t);
|
|
436
480
|
for (let n = 0; n < t; n++)
|
|
437
|
-
v(s,
|
|
481
|
+
v(s, Ft[n]);
|
|
438
482
|
} else
|
|
439
|
-
D(s,
|
|
440
|
-
},
|
|
483
|
+
D(s, Ii(e));
|
|
484
|
+
}, pr = (s, e) => {
|
|
441
485
|
const t = unescape(encodeURIComponent(e)), n = t.length;
|
|
442
486
|
p(s, n);
|
|
443
487
|
for (let i = 0; i < n; i++)
|
|
@@ -446,37 +490,37 @@ const I = () => new He(), Pt = (s) => {
|
|
|
446
490
|
/** @type {number} */
|
|
447
491
|
t.codePointAt(i)
|
|
448
492
|
);
|
|
449
|
-
},
|
|
450
|
-
Ue.encodeInto ?
|
|
451
|
-
const t = s.cbuf.length, n = s.cpos, i =
|
|
452
|
-
s.cbuf.set(e.subarray(0, i), n), s.cpos += i, r > 0 && (s.bufs.push(s.cbuf), s.cbuf = new Uint8Array(
|
|
493
|
+
}, ae = Ue && /** @type {any} */
|
|
494
|
+
Ue.encodeInto ? gr : pr, kt = (s, e) => {
|
|
495
|
+
const t = s.cbuf.length, n = s.cpos, i = Jt(t - n, e.length), r = e.length - i;
|
|
496
|
+
s.cbuf.set(e.subarray(0, i), n), s.cpos += i, r > 0 && (s.bufs.push(s.cbuf), s.cbuf = new Uint8Array(ge(t * 2, r)), s.cbuf.set(e.subarray(i)), s.cpos = r);
|
|
453
497
|
}, D = (s, e) => {
|
|
454
|
-
p(s, e.byteLength),
|
|
455
|
-
},
|
|
456
|
-
|
|
498
|
+
p(s, e.byteLength), kt(s, e);
|
|
499
|
+
}, ss = (s, e) => {
|
|
500
|
+
dr(s, e);
|
|
457
501
|
const t = new DataView(s.cbuf.buffer, s.cpos, e);
|
|
458
502
|
return s.cpos += e, t;
|
|
459
|
-
},
|
|
503
|
+
}, kr = (s, e) => ss(s, 4).setFloat32(0, e, !1), mr = (s, e) => ss(s, 8).setFloat64(0, e, !1), br = (s, e) => (
|
|
460
504
|
/** @type {any} */
|
|
461
|
-
|
|
462
|
-
),
|
|
505
|
+
ss(s, 8).setBigInt64(0, e, !1)
|
|
506
|
+
), js = new DataView(new ArrayBuffer(4)), wr = (s) => (js.setFloat32(0, s), js.getFloat32(0) === s), Re = (s, e) => {
|
|
463
507
|
switch (typeof e) {
|
|
464
508
|
case "string":
|
|
465
|
-
v(s, 119),
|
|
509
|
+
v(s, 119), ae(s, e);
|
|
466
510
|
break;
|
|
467
511
|
case "number":
|
|
468
|
-
|
|
512
|
+
Ji(e) && et(e) <= Xi ? (v(s, 125), ts(s, e)) : wr(e) ? (v(s, 124), kr(s, e)) : (v(s, 123), mr(s, e));
|
|
469
513
|
break;
|
|
470
514
|
case "bigint":
|
|
471
|
-
v(s, 122),
|
|
515
|
+
v(s, 122), br(s, e);
|
|
472
516
|
break;
|
|
473
517
|
case "object":
|
|
474
518
|
if (e === null)
|
|
475
519
|
v(s, 126);
|
|
476
|
-
else if (
|
|
520
|
+
else if (Si(e)) {
|
|
477
521
|
v(s, 117), p(s, e.length);
|
|
478
522
|
for (let t = 0; t < e.length; t++)
|
|
479
|
-
|
|
523
|
+
Re(s, e[t]);
|
|
480
524
|
} else if (e instanceof Uint8Array)
|
|
481
525
|
v(s, 116), D(s, e);
|
|
482
526
|
else {
|
|
@@ -485,7 +529,7 @@ Ue.encodeInto ? nr : ir, ft = (s, e) => {
|
|
|
485
529
|
p(s, t.length);
|
|
486
530
|
for (let n = 0; n < t.length; n++) {
|
|
487
531
|
const i = t[n];
|
|
488
|
-
|
|
532
|
+
ae(s, i), Re(s, e[i]);
|
|
489
533
|
}
|
|
490
534
|
}
|
|
491
535
|
break;
|
|
@@ -496,7 +540,7 @@ Ue.encodeInto ? nr : ir, ft = (s, e) => {
|
|
|
496
540
|
v(s, 127);
|
|
497
541
|
}
|
|
498
542
|
};
|
|
499
|
-
class
|
|
543
|
+
class Ms extends Ve {
|
|
500
544
|
/**
|
|
501
545
|
* @param {function(Encoder, T):void} writer
|
|
502
546
|
*/
|
|
@@ -510,46 +554,46 @@ class Es extends He {
|
|
|
510
554
|
this.s === e ? this.count++ : (this.count > 0 && p(this, this.count - 1), this.count = 1, this.w(this, e), this.s = e);
|
|
511
555
|
}
|
|
512
556
|
}
|
|
513
|
-
const
|
|
514
|
-
s.count > 0 && (
|
|
557
|
+
const zs = (s) => {
|
|
558
|
+
s.count > 0 && (ts(s.encoder, s.count === 1 ? s.s : -s.s), s.count > 1 && p(s.encoder, s.count - 2));
|
|
515
559
|
};
|
|
516
|
-
class
|
|
560
|
+
class st {
|
|
517
561
|
constructor() {
|
|
518
|
-
this.encoder = new
|
|
562
|
+
this.encoder = new Ve(), this.s = 0, this.count = 0;
|
|
519
563
|
}
|
|
520
564
|
/**
|
|
521
565
|
* @param {number} v
|
|
522
566
|
*/
|
|
523
567
|
write(e) {
|
|
524
|
-
this.s === e ? this.count++ : (
|
|
568
|
+
this.s === e ? this.count++ : (zs(this), this.count = 1, this.s = e);
|
|
525
569
|
}
|
|
526
570
|
toUint8Array() {
|
|
527
|
-
return
|
|
571
|
+
return zs(this), S(this.encoder);
|
|
528
572
|
}
|
|
529
573
|
}
|
|
530
|
-
const
|
|
574
|
+
const Us = (s) => {
|
|
531
575
|
if (s.count > 0) {
|
|
532
576
|
const e = s.diff * 2 + (s.count === 1 ? 0 : 1);
|
|
533
|
-
|
|
577
|
+
ts(s.encoder, e), s.count > 1 && p(s.encoder, s.count - 2);
|
|
534
578
|
}
|
|
535
579
|
};
|
|
536
|
-
class
|
|
580
|
+
class vt {
|
|
537
581
|
constructor() {
|
|
538
|
-
this.encoder = new
|
|
582
|
+
this.encoder = new Ve(), this.s = 0, this.count = 0, this.diff = 0;
|
|
539
583
|
}
|
|
540
584
|
/**
|
|
541
585
|
* @param {number} v
|
|
542
586
|
*/
|
|
543
587
|
write(e) {
|
|
544
|
-
this.diff === e - this.s ? (this.s = e, this.count++) : (
|
|
588
|
+
this.diff === e - this.s ? (this.s = e, this.count++) : (Us(this), this.count = 1, this.diff = e - this.s, this.s = e);
|
|
545
589
|
}
|
|
546
590
|
toUint8Array() {
|
|
547
|
-
return
|
|
591
|
+
return Us(this), S(this.encoder);
|
|
548
592
|
}
|
|
549
593
|
}
|
|
550
|
-
class
|
|
594
|
+
class yr {
|
|
551
595
|
constructor() {
|
|
552
|
-
this.sarr = [], this.s = "", this.lensE = new
|
|
596
|
+
this.sarr = [], this.s = "", this.lensE = new st();
|
|
553
597
|
}
|
|
554
598
|
/**
|
|
555
599
|
* @param {string} string
|
|
@@ -558,20 +602,20 @@ class lr {
|
|
|
558
602
|
this.s += e, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(e.length);
|
|
559
603
|
}
|
|
560
604
|
toUint8Array() {
|
|
561
|
-
const e = new
|
|
562
|
-
return this.sarr.push(this.s), this.s = "",
|
|
605
|
+
const e = new Ve();
|
|
606
|
+
return this.sarr.push(this.s), this.s = "", ae(e, this.sarr.join("")), kt(e, this.lensE.toUint8Array()), S(e);
|
|
563
607
|
}
|
|
564
608
|
}
|
|
565
|
-
const
|
|
609
|
+
const Sr = crypto.getRandomValues.bind(crypto), cn = () => Sr(new Uint32Array(1))[0], _r = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Dr = () => _r.replace(
|
|
566
610
|
/[018]/g,
|
|
567
611
|
/** @param {number} c */
|
|
568
|
-
(s) => (s ^
|
|
569
|
-
),
|
|
612
|
+
(s) => (s ^ cn() & 15 >> s / 4).toString(16)
|
|
613
|
+
), le = Date.now, Ee = (s) => (
|
|
570
614
|
/** @type {Promise<T>} */
|
|
571
615
|
new Promise(s)
|
|
572
616
|
);
|
|
573
617
|
Promise.all.bind(Promise);
|
|
574
|
-
class
|
|
618
|
+
class Er {
|
|
575
619
|
/**
|
|
576
620
|
* @param {L} left
|
|
577
621
|
* @param {R} right
|
|
@@ -580,9 +624,9 @@ class fr {
|
|
|
580
624
|
this.left = e, this.right = t;
|
|
581
625
|
}
|
|
582
626
|
}
|
|
583
|
-
const q = (s, e) => new
|
|
627
|
+
const q = (s, e) => new Er(s, e);
|
|
584
628
|
typeof DOMParser < "u" && new DOMParser();
|
|
585
|
-
const
|
|
629
|
+
const Cr = (s) => bi(s, (e, t) => `${t}:${e};`).join(""), G = Symbol, ln = G(), hn = G(), vr = G(), Ar = G(), xr = G(), un = G(), Lr = G(), dn = G(), Ir = G(), jr = (s) => {
|
|
586
630
|
const e = [];
|
|
587
631
|
let t = 0;
|
|
588
632
|
for (; t < s.length; t++) {
|
|
@@ -590,26 +634,26 @@ const gr = (s) => ai(s, (e, t) => `${t}:${e};`).join(""), W = Symbol, Zs = W(),
|
|
|
590
634
|
n.constructor === String || n.constructor === Number || n.constructor === Object && e.push(JSON.stringify(n));
|
|
591
635
|
}
|
|
592
636
|
return e;
|
|
593
|
-
},
|
|
594
|
-
[
|
|
595
|
-
[
|
|
596
|
-
[
|
|
597
|
-
[
|
|
598
|
-
[
|
|
599
|
-
[
|
|
600
|
-
[
|
|
601
|
-
[
|
|
637
|
+
}, Mr = {
|
|
638
|
+
[ln]: q("font-weight", "bold"),
|
|
639
|
+
[hn]: q("font-weight", "normal"),
|
|
640
|
+
[vr]: q("color", "blue"),
|
|
641
|
+
[xr]: q("color", "green"),
|
|
642
|
+
[Ar]: q("color", "grey"),
|
|
643
|
+
[un]: q("color", "red"),
|
|
644
|
+
[Lr]: q("color", "purple"),
|
|
645
|
+
[dn]: q("color", "orange"),
|
|
602
646
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
603
|
-
[
|
|
604
|
-
},
|
|
647
|
+
[Ir]: q("color", "black")
|
|
648
|
+
}, zr = (s) => {
|
|
605
649
|
const e = [], t = [], n = T();
|
|
606
650
|
let i = [], r = 0;
|
|
607
651
|
for (; r < s.length; r++) {
|
|
608
|
-
const o = s[r], a =
|
|
652
|
+
const o = s[r], a = Mr[o];
|
|
609
653
|
if (a !== void 0)
|
|
610
654
|
n.set(a.left, a.right);
|
|
611
655
|
else if (o.constructor === String || o.constructor === Number) {
|
|
612
|
-
const c =
|
|
656
|
+
const c = Cr(n);
|
|
613
657
|
r > 0 || c.length > 0 ? (e.push("%c" + o), t.push(c)) : e.push(o);
|
|
614
658
|
} else
|
|
615
659
|
break;
|
|
@@ -619,9 +663,9 @@ const gr = (s) => ai(s, (e, t) => `${t}:${e};`).join(""), W = Symbol, Zs = W(),
|
|
|
619
663
|
o instanceof Symbol || i.push(o);
|
|
620
664
|
}
|
|
621
665
|
return i;
|
|
622
|
-
},
|
|
623
|
-
console.log(...
|
|
624
|
-
},
|
|
666
|
+
}, Ur = Yi ? zr : jr, Tr = (...s) => {
|
|
667
|
+
console.log(...Ur(s)), Or.forEach((e) => e.print(s));
|
|
668
|
+
}, Or = ce(), fn = (s) => ({
|
|
625
669
|
/**
|
|
626
670
|
* @return {IterableIterator<T>}
|
|
627
671
|
*/
|
|
@@ -630,17 +674,17 @@ const gr = (s) => ai(s, (e, t) => `${t}:${e};`).join(""), W = Symbol, Zs = W(),
|
|
|
630
674
|
},
|
|
631
675
|
// @ts-ignore
|
|
632
676
|
next: s
|
|
633
|
-
}),
|
|
677
|
+
}), Rr = (s, e) => fn(() => {
|
|
634
678
|
let t;
|
|
635
679
|
do
|
|
636
680
|
t = s.next();
|
|
637
681
|
while (!t.done && !e(t.value));
|
|
638
682
|
return t;
|
|
639
|
-
}),
|
|
683
|
+
}), At = (s, e) => fn(() => {
|
|
640
684
|
const { done: t, value: n } = s.next();
|
|
641
685
|
return { done: t, value: t ? void 0 : e(n) };
|
|
642
686
|
});
|
|
643
|
-
class
|
|
687
|
+
class ns {
|
|
644
688
|
/**
|
|
645
689
|
* @param {number} clock
|
|
646
690
|
* @param {number} len
|
|
@@ -649,21 +693,21 @@ class es {
|
|
|
649
693
|
this.clock = e, this.len = t;
|
|
650
694
|
}
|
|
651
695
|
}
|
|
652
|
-
class
|
|
696
|
+
class $e {
|
|
653
697
|
constructor() {
|
|
654
698
|
this.clients = /* @__PURE__ */ new Map();
|
|
655
699
|
}
|
|
656
700
|
}
|
|
657
|
-
const
|
|
701
|
+
const gn = (s, e, t) => e.clients.forEach((n, i) => {
|
|
658
702
|
const r = (
|
|
659
703
|
/** @type {Array<GC|Item>} */
|
|
660
704
|
s.doc.store.clients.get(i)
|
|
661
705
|
);
|
|
662
706
|
for (let o = 0; o < n.length; o++) {
|
|
663
707
|
const a = n[o];
|
|
664
|
-
|
|
708
|
+
xn(s, r, a.clock, a.len, t);
|
|
665
709
|
}
|
|
666
|
-
}),
|
|
710
|
+
}), Br = (s, e) => {
|
|
667
711
|
let t = 0, n = s.length - 1;
|
|
668
712
|
for (; t <= n; ) {
|
|
669
713
|
const i = X((t + n) / 2), r = s[i], o = r.clock;
|
|
@@ -675,38 +719,38 @@ const rn = (s, e, t) => e.clients.forEach((n, i) => {
|
|
|
675
719
|
n = i - 1;
|
|
676
720
|
}
|
|
677
721
|
return null;
|
|
678
|
-
},
|
|
722
|
+
}, pn = (s, e) => {
|
|
679
723
|
const t = s.clients.get(e.client);
|
|
680
|
-
return t !== void 0 &&
|
|
681
|
-
},
|
|
724
|
+
return t !== void 0 && Br(t, e.clock) !== null;
|
|
725
|
+
}, is = (s) => {
|
|
682
726
|
s.clients.forEach((e) => {
|
|
683
727
|
e.sort((i, r) => i.clock - r.clock);
|
|
684
728
|
let t, n;
|
|
685
729
|
for (t = 1, n = 1; t < e.length; t++) {
|
|
686
730
|
const i = e[n - 1], r = e[t];
|
|
687
|
-
i.clock + i.len >= r.clock ? i.len =
|
|
731
|
+
i.clock + i.len >= r.clock ? i.len = ge(i.len, r.clock + r.len - i.clock) : (n < t && (e[n] = r), n++);
|
|
688
732
|
}
|
|
689
733
|
e.length = n;
|
|
690
734
|
});
|
|
691
|
-
},
|
|
692
|
-
const e = new
|
|
735
|
+
}, Nr = (s) => {
|
|
736
|
+
const e = new $e();
|
|
693
737
|
for (let t = 0; t < s.length; t++)
|
|
694
738
|
s[t].clients.forEach((n, i) => {
|
|
695
739
|
if (!e.clients.has(i)) {
|
|
696
740
|
const r = n.slice();
|
|
697
741
|
for (let o = t + 1; o < s.length; o++)
|
|
698
|
-
|
|
742
|
+
yi(r, s[o].clients.get(i) || []);
|
|
699
743
|
e.clients.set(i, r);
|
|
700
744
|
}
|
|
701
745
|
});
|
|
702
|
-
return
|
|
703
|
-
},
|
|
704
|
-
|
|
746
|
+
return is(e), e;
|
|
747
|
+
}, rt = (s, e, t, n) => {
|
|
748
|
+
W(s.clients, e, () => (
|
|
705
749
|
/** @type {Array<DeleteItem>} */
|
|
706
750
|
[]
|
|
707
|
-
)).push(new
|
|
708
|
-
},
|
|
709
|
-
const e =
|
|
751
|
+
)).push(new ns(t, n));
|
|
752
|
+
}, Fr = () => new $e(), Hr = (s) => {
|
|
753
|
+
const e = Fr();
|
|
710
754
|
return s.clients.forEach((t, n) => {
|
|
711
755
|
const i = [];
|
|
712
756
|
for (let r = 0; r < t.length; r++) {
|
|
@@ -717,12 +761,12 @@ const rn = (s, e, t) => e.clients.forEach((n, i) => {
|
|
|
717
761
|
if (r + 1 < t.length)
|
|
718
762
|
for (let l = t[r + 1]; r + 1 < t.length && l.deleted; l = t[++r + 1])
|
|
719
763
|
c += l.length;
|
|
720
|
-
i.push(new
|
|
764
|
+
i.push(new ns(a, c));
|
|
721
765
|
}
|
|
722
766
|
}
|
|
723
767
|
i.length > 0 && e.clients.set(n, i);
|
|
724
768
|
}), e;
|
|
725
|
-
},
|
|
769
|
+
}, Ae = (s, e) => {
|
|
726
770
|
p(s.restEncoder, e.clients.size), te(e.clients.entries()).sort((t, n) => n[0] - t[0]).forEach(([t, n]) => {
|
|
727
771
|
s.resetDsCurVal(), p(s.restEncoder, t);
|
|
728
772
|
const i = n.length;
|
|
@@ -732,54 +776,54 @@ const rn = (s, e, t) => e.clients.forEach((n, i) => {
|
|
|
732
776
|
s.writeDsClock(o.clock), s.writeDsLen(o.len);
|
|
733
777
|
}
|
|
734
778
|
});
|
|
735
|
-
},
|
|
736
|
-
const e = new
|
|
779
|
+
}, rs = (s) => {
|
|
780
|
+
const e = new $e(), t = m(s.restDecoder);
|
|
737
781
|
for (let n = 0; n < t; n++) {
|
|
738
782
|
s.resetDsCurVal();
|
|
739
783
|
const i = m(s.restDecoder), r = m(s.restDecoder);
|
|
740
784
|
if (r > 0) {
|
|
741
|
-
const o =
|
|
785
|
+
const o = W(e.clients, i, () => (
|
|
742
786
|
/** @type {Array<DeleteItem>} */
|
|
743
787
|
[]
|
|
744
788
|
));
|
|
745
789
|
for (let a = 0; a < r; a++)
|
|
746
|
-
o.push(new
|
|
790
|
+
o.push(new ns(s.readDsClock(), s.readDsLen()));
|
|
747
791
|
}
|
|
748
792
|
}
|
|
749
793
|
return e;
|
|
750
|
-
},
|
|
751
|
-
const n = new
|
|
794
|
+
}, Ts = (s, e, t) => {
|
|
795
|
+
const n = new $e(), i = m(s.restDecoder);
|
|
752
796
|
for (let r = 0; r < i; r++) {
|
|
753
797
|
s.resetDsCurVal();
|
|
754
798
|
const o = m(s.restDecoder), a = m(s.restDecoder), c = t.clients.get(o) || [], l = A(t, o);
|
|
755
799
|
for (let h = 0; h < a; h++) {
|
|
756
800
|
const u = s.readDsClock(), d = u + s.readDsLen();
|
|
757
801
|
if (u < l) {
|
|
758
|
-
l < d &&
|
|
802
|
+
l < d && rt(n, o, l, d - l);
|
|
759
803
|
let f = H(c, u), g = c[f];
|
|
760
|
-
for (!g.deleted && g.id.clock < u && (c.splice(f + 1, 0,
|
|
761
|
-
g.deleted || (d < g.id.clock + g.length && c.splice(f, 0,
|
|
804
|
+
for (!g.deleted && g.id.clock < u && (c.splice(f + 1, 0, dt(e, g, u - g.id.clock)), f++); f < c.length && (g = c[f++], g.id.clock < d); )
|
|
805
|
+
g.deleted || (d < g.id.clock + g.length && c.splice(f, 0, dt(e, g, d - g.id.clock)), g.delete(e));
|
|
762
806
|
} else
|
|
763
|
-
|
|
807
|
+
rt(n, o, u, d - u);
|
|
764
808
|
}
|
|
765
809
|
}
|
|
766
810
|
if (n.clients.size > 0) {
|
|
767
|
-
const r = new
|
|
768
|
-
return p(r.restEncoder, 0),
|
|
811
|
+
const r = new he();
|
|
812
|
+
return p(r.restEncoder, 0), Ae(r, n), r.toUint8Array();
|
|
769
813
|
}
|
|
770
814
|
return null;
|
|
771
|
-
},
|
|
772
|
-
class
|
|
815
|
+
}, kn = cn;
|
|
816
|
+
class pe extends ft {
|
|
773
817
|
/**
|
|
774
818
|
* @param {DocOpts} opts configuration
|
|
775
819
|
*/
|
|
776
|
-
constructor({ guid: e =
|
|
777
|
-
super(), this.gc = n, this.gcFilter = i, this.clientID =
|
|
820
|
+
constructor({ guid: e = Dr(), collectionid: t = null, gc: n = !0, gcFilter: i = () => !0, meta: r = null, autoLoad: o = !1, shouldLoad: a = !0 } = {}) {
|
|
821
|
+
super(), this.gc = n, this.gcFilter = i, this.clientID = kn(), this.guid = e, this.collectionid = t, this.share = /* @__PURE__ */ new Map(), this.store = new vn(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = a, this.autoLoad = o, this.meta = r, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = Ee((l) => {
|
|
778
822
|
this.on("load", () => {
|
|
779
823
|
this.isLoaded = !0, l(this);
|
|
780
824
|
});
|
|
781
825
|
});
|
|
782
|
-
const c = () =>
|
|
826
|
+
const c = () => Ee((l) => {
|
|
783
827
|
const h = (u) => {
|
|
784
828
|
(u === void 0 || u === !0) && (this.off("sync", h), l());
|
|
785
829
|
};
|
|
@@ -857,7 +901,7 @@ class ge extends ht {
|
|
|
857
901
|
* @public
|
|
858
902
|
*/
|
|
859
903
|
get(e, t = x) {
|
|
860
|
-
const n =
|
|
904
|
+
const n = W(this.share, e, () => {
|
|
861
905
|
const r = new t();
|
|
862
906
|
return r._integrate(this, null), r;
|
|
863
907
|
}), i = n.constructor;
|
|
@@ -886,7 +930,7 @@ class ge extends ht {
|
|
|
886
930
|
* @public
|
|
887
931
|
*/
|
|
888
932
|
getArray(e = "") {
|
|
889
|
-
return this.get(e,
|
|
933
|
+
return this.get(e, ye);
|
|
890
934
|
}
|
|
891
935
|
/**
|
|
892
936
|
* @param {string} [name]
|
|
@@ -895,7 +939,7 @@ class ge extends ht {
|
|
|
895
939
|
* @public
|
|
896
940
|
*/
|
|
897
941
|
getText(e = "") {
|
|
898
|
-
return this.get(e,
|
|
942
|
+
return this.get(e, ve);
|
|
899
943
|
}
|
|
900
944
|
/**
|
|
901
945
|
* @template T
|
|
@@ -905,7 +949,7 @@ class ge extends ht {
|
|
|
905
949
|
* @public
|
|
906
950
|
*/
|
|
907
951
|
getMap(e = "") {
|
|
908
|
-
return this.get(e,
|
|
952
|
+
return this.get(e, ue);
|
|
909
953
|
}
|
|
910
954
|
/**
|
|
911
955
|
* @param {string} [name]
|
|
@@ -914,7 +958,7 @@ class ge extends ht {
|
|
|
914
958
|
* @public
|
|
915
959
|
*/
|
|
916
960
|
getXmlFragment(e = "") {
|
|
917
|
-
return this.get(e,
|
|
961
|
+
return this.get(e, de);
|
|
918
962
|
}
|
|
919
963
|
/**
|
|
920
964
|
* Converts the entire document into a js object, recursively traversing each yjs type
|
|
@@ -942,7 +986,7 @@ class ge extends ht {
|
|
|
942
986
|
/** @type {ContentDoc} */
|
|
943
987
|
e.content
|
|
944
988
|
);
|
|
945
|
-
t.doc = new
|
|
989
|
+
t.doc = new pe({ guid: this.guid, ...t.opts, shouldLoad: !1 }), t.doc._item = e, y(
|
|
946
990
|
/** @type {any} */
|
|
947
991
|
e.parent.doc,
|
|
948
992
|
(n) => {
|
|
@@ -970,7 +1014,7 @@ class ge extends ht {
|
|
|
970
1014
|
super.off(e, t);
|
|
971
1015
|
}
|
|
972
1016
|
}
|
|
973
|
-
class
|
|
1017
|
+
class mn {
|
|
974
1018
|
/**
|
|
975
1019
|
* @param {decoding.Decoder} decoder
|
|
976
1020
|
*/
|
|
@@ -992,7 +1036,7 @@ class cn {
|
|
|
992
1036
|
return m(this.restDecoder);
|
|
993
1037
|
}
|
|
994
1038
|
}
|
|
995
|
-
class
|
|
1039
|
+
class bn extends mn {
|
|
996
1040
|
/**
|
|
997
1041
|
* @return {ID}
|
|
998
1042
|
*/
|
|
@@ -1016,7 +1060,7 @@ class ln extends cn {
|
|
|
1016
1060
|
* @return {number} info An unsigned 8-bit integer
|
|
1017
1061
|
*/
|
|
1018
1062
|
readInfo() {
|
|
1019
|
-
return
|
|
1063
|
+
return De(this.restDecoder);
|
|
1020
1064
|
}
|
|
1021
1065
|
/**
|
|
1022
1066
|
* @return {string}
|
|
@@ -1048,13 +1092,13 @@ class ln extends cn {
|
|
|
1048
1092
|
* @return {any}
|
|
1049
1093
|
*/
|
|
1050
1094
|
readAny() {
|
|
1051
|
-
return
|
|
1095
|
+
return Oe(this.restDecoder);
|
|
1052
1096
|
}
|
|
1053
1097
|
/**
|
|
1054
1098
|
* @return {Uint8Array}
|
|
1055
1099
|
*/
|
|
1056
1100
|
readBuf() {
|
|
1057
|
-
return
|
|
1101
|
+
return ur(L(this.restDecoder));
|
|
1058
1102
|
}
|
|
1059
1103
|
/**
|
|
1060
1104
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1071,7 +1115,7 @@ class ln extends cn {
|
|
|
1071
1115
|
return ee(this.restDecoder);
|
|
1072
1116
|
}
|
|
1073
1117
|
}
|
|
1074
|
-
class
|
|
1118
|
+
class Vr {
|
|
1075
1119
|
/**
|
|
1076
1120
|
* @param {decoding.Decoder} decoder
|
|
1077
1121
|
*/
|
|
@@ -1095,24 +1139,24 @@ class jr {
|
|
|
1095
1139
|
return this.dsCurrVal += e, e;
|
|
1096
1140
|
}
|
|
1097
1141
|
}
|
|
1098
|
-
class
|
|
1142
|
+
class Ce extends Vr {
|
|
1099
1143
|
/**
|
|
1100
1144
|
* @param {decoding.Decoder} decoder
|
|
1101
1145
|
*/
|
|
1102
1146
|
constructor(e) {
|
|
1103
|
-
super(e), this.keys = [], m(e), this.keyClockDecoder = new
|
|
1147
|
+
super(e), this.keys = [], m(e), this.keyClockDecoder = new Ct(L(e)), this.clientDecoder = new tt(L(e)), this.leftClockDecoder = new Ct(L(e)), this.rightClockDecoder = new Ct(L(e)), this.infoDecoder = new Is(L(e), De), this.stringDecoder = new nr(L(e)), this.parentInfoDecoder = new Is(L(e), De), this.typeRefDecoder = new tt(L(e)), this.lenDecoder = new tt(L(e));
|
|
1104
1148
|
}
|
|
1105
1149
|
/**
|
|
1106
1150
|
* @return {ID}
|
|
1107
1151
|
*/
|
|
1108
1152
|
readLeftID() {
|
|
1109
|
-
return new
|
|
1153
|
+
return new we(this.clientDecoder.read(), this.leftClockDecoder.read());
|
|
1110
1154
|
}
|
|
1111
1155
|
/**
|
|
1112
1156
|
* @return {ID}
|
|
1113
1157
|
*/
|
|
1114
1158
|
readRightID() {
|
|
1115
|
-
return new
|
|
1159
|
+
return new we(this.clientDecoder.read(), this.rightClockDecoder.read());
|
|
1116
1160
|
}
|
|
1117
1161
|
/**
|
|
1118
1162
|
* Read the next client id.
|
|
@@ -1160,7 +1204,7 @@ class Ee extends jr {
|
|
|
1160
1204
|
* @return {any}
|
|
1161
1205
|
*/
|
|
1162
1206
|
readAny() {
|
|
1163
|
-
return
|
|
1207
|
+
return Oe(this.restDecoder);
|
|
1164
1208
|
}
|
|
1165
1209
|
/**
|
|
1166
1210
|
* @return {Uint8Array}
|
|
@@ -1176,7 +1220,7 @@ class Ee extends jr {
|
|
|
1176
1220
|
* @return {any}
|
|
1177
1221
|
*/
|
|
1178
1222
|
readJSON() {
|
|
1179
|
-
return
|
|
1223
|
+
return Oe(this.restDecoder);
|
|
1180
1224
|
}
|
|
1181
1225
|
/**
|
|
1182
1226
|
* @return {string}
|
|
@@ -1191,12 +1235,12 @@ class Ee extends jr {
|
|
|
1191
1235
|
}
|
|
1192
1236
|
}
|
|
1193
1237
|
}
|
|
1194
|
-
class
|
|
1238
|
+
class wn {
|
|
1195
1239
|
constructor() {
|
|
1196
1240
|
this.restEncoder = I();
|
|
1197
1241
|
}
|
|
1198
1242
|
toUint8Array() {
|
|
1199
|
-
return
|
|
1243
|
+
return S(this.restEncoder);
|
|
1200
1244
|
}
|
|
1201
1245
|
resetDsCurVal() {
|
|
1202
1246
|
}
|
|
@@ -1213,7 +1257,7 @@ class hn {
|
|
|
1213
1257
|
p(this.restEncoder, e);
|
|
1214
1258
|
}
|
|
1215
1259
|
}
|
|
1216
|
-
class
|
|
1260
|
+
class qe extends wn {
|
|
1217
1261
|
/**
|
|
1218
1262
|
* @param {ID} id
|
|
1219
1263
|
*/
|
|
@@ -1237,13 +1281,13 @@ class $e extends hn {
|
|
|
1237
1281
|
* @param {number} info An unsigned 8-bit integer
|
|
1238
1282
|
*/
|
|
1239
1283
|
writeInfo(e) {
|
|
1240
|
-
|
|
1284
|
+
Nt(this.restEncoder, e);
|
|
1241
1285
|
}
|
|
1242
1286
|
/**
|
|
1243
1287
|
* @param {string} s
|
|
1244
1288
|
*/
|
|
1245
1289
|
writeString(e) {
|
|
1246
|
-
|
|
1290
|
+
ae(this.restEncoder, e);
|
|
1247
1291
|
}
|
|
1248
1292
|
/**
|
|
1249
1293
|
* @param {boolean} isYKey
|
|
@@ -1269,7 +1313,7 @@ class $e extends hn {
|
|
|
1269
1313
|
* @param {any} any
|
|
1270
1314
|
*/
|
|
1271
1315
|
writeAny(e) {
|
|
1272
|
-
|
|
1316
|
+
Re(this.restEncoder, e);
|
|
1273
1317
|
}
|
|
1274
1318
|
/**
|
|
1275
1319
|
* @param {Uint8Array} buf
|
|
@@ -1281,21 +1325,21 @@ class $e extends hn {
|
|
|
1281
1325
|
* @param {any} embed
|
|
1282
1326
|
*/
|
|
1283
1327
|
writeJSON(e) {
|
|
1284
|
-
|
|
1328
|
+
ae(this.restEncoder, JSON.stringify(e));
|
|
1285
1329
|
}
|
|
1286
1330
|
/**
|
|
1287
1331
|
* @param {string} key
|
|
1288
1332
|
*/
|
|
1289
1333
|
writeKey(e) {
|
|
1290
|
-
|
|
1334
|
+
ae(this.restEncoder, e);
|
|
1291
1335
|
}
|
|
1292
1336
|
}
|
|
1293
|
-
class
|
|
1337
|
+
class yn {
|
|
1294
1338
|
constructor() {
|
|
1295
1339
|
this.restEncoder = I(), this.dsCurrVal = 0;
|
|
1296
1340
|
}
|
|
1297
1341
|
toUint8Array() {
|
|
1298
|
-
return
|
|
1342
|
+
return S(this.restEncoder);
|
|
1299
1343
|
}
|
|
1300
1344
|
resetDsCurVal() {
|
|
1301
1345
|
this.dsCurrVal = 0;
|
|
@@ -1314,13 +1358,13 @@ class un {
|
|
|
1314
1358
|
e === 0 && F(), p(this.restEncoder, e - 1), this.dsCurrVal += e;
|
|
1315
1359
|
}
|
|
1316
1360
|
}
|
|
1317
|
-
class
|
|
1361
|
+
class he extends yn {
|
|
1318
1362
|
constructor() {
|
|
1319
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new
|
|
1363
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new vt(), this.clientEncoder = new st(), this.leftClockEncoder = new vt(), this.rightClockEncoder = new vt(), this.infoEncoder = new Ms(Nt), this.stringEncoder = new yr(), this.parentInfoEncoder = new Ms(Nt), this.typeRefEncoder = new st(), this.lenEncoder = new st();
|
|
1320
1364
|
}
|
|
1321
1365
|
toUint8Array() {
|
|
1322
1366
|
const e = I();
|
|
1323
|
-
return p(e, 0), D(e, this.keyClockEncoder.toUint8Array()), D(e, this.clientEncoder.toUint8Array()), D(e, this.leftClockEncoder.toUint8Array()), D(e, this.rightClockEncoder.toUint8Array()), D(e,
|
|
1367
|
+
return p(e, 0), D(e, this.keyClockEncoder.toUint8Array()), D(e, this.clientEncoder.toUint8Array()), D(e, this.leftClockEncoder.toUint8Array()), D(e, this.rightClockEncoder.toUint8Array()), D(e, S(this.infoEncoder)), D(e, this.stringEncoder.toUint8Array()), D(e, S(this.parentInfoEncoder)), D(e, this.typeRefEncoder.toUint8Array()), D(e, this.lenEncoder.toUint8Array()), kt(e, S(this.restEncoder)), S(e);
|
|
1324
1368
|
}
|
|
1325
1369
|
/**
|
|
1326
1370
|
* @param {ID} id
|
|
@@ -1376,7 +1420,7 @@ class le extends un {
|
|
|
1376
1420
|
* @param {any} any
|
|
1377
1421
|
*/
|
|
1378
1422
|
writeAny(e) {
|
|
1379
|
-
|
|
1423
|
+
Re(this.restEncoder, e);
|
|
1380
1424
|
}
|
|
1381
1425
|
/**
|
|
1382
1426
|
* @param {Uint8Array} buf
|
|
@@ -1392,7 +1436,7 @@ class le extends un {
|
|
|
1392
1436
|
* @param {any} embed
|
|
1393
1437
|
*/
|
|
1394
1438
|
writeJSON(e) {
|
|
1395
|
-
|
|
1439
|
+
Re(this.restEncoder, e);
|
|
1396
1440
|
}
|
|
1397
1441
|
/**
|
|
1398
1442
|
* Property keys are often reused. For example, in y-prosemirror the key `bold` might
|
|
@@ -1407,22 +1451,22 @@ class le extends un {
|
|
|
1407
1451
|
t === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(e)) : this.keyClockEncoder.write(t);
|
|
1408
1452
|
}
|
|
1409
1453
|
}
|
|
1410
|
-
const
|
|
1411
|
-
n =
|
|
1454
|
+
const $r = (s, e, t, n) => {
|
|
1455
|
+
n = ge(n, e[0].id.clock);
|
|
1412
1456
|
const i = H(e, n);
|
|
1413
1457
|
p(s.restEncoder, e.length - i), s.writeClient(t), p(s.restEncoder, n);
|
|
1414
1458
|
const r = e[i];
|
|
1415
1459
|
r.write(s, n - r.id.clock);
|
|
1416
1460
|
for (let o = i + 1; o < e.length; o++)
|
|
1417
1461
|
e[o].write(s, 0);
|
|
1418
|
-
},
|
|
1462
|
+
}, os = (s, e, t) => {
|
|
1419
1463
|
const n = /* @__PURE__ */ new Map();
|
|
1420
1464
|
t.forEach((i, r) => {
|
|
1421
1465
|
A(e, r) > i && n.set(r, i);
|
|
1422
|
-
}),
|
|
1466
|
+
}), mt(e).forEach((i, r) => {
|
|
1423
1467
|
t.has(r) || n.set(r, 0);
|
|
1424
1468
|
}), p(s.restEncoder, n.size), te(n.entries()).sort((i, r) => r[0] - i[0]).forEach(([i, r]) => {
|
|
1425
|
-
|
|
1469
|
+
$r(
|
|
1426
1470
|
s,
|
|
1427
1471
|
/** @type {Array<GC|Item>} */
|
|
1428
1472
|
e.clients.get(i),
|
|
@@ -1430,7 +1474,7 @@ const Mr = (s, e, t, n) => {
|
|
|
1430
1474
|
r
|
|
1431
1475
|
);
|
|
1432
1476
|
});
|
|
1433
|
-
},
|
|
1477
|
+
}, qr = (s, e) => {
|
|
1434
1478
|
const t = T(), n = m(s.restDecoder);
|
|
1435
1479
|
for (let i = 0; i < n; i++) {
|
|
1436
1480
|
const r = m(s.restDecoder), o = new Array(r), a = s.readClient();
|
|
@@ -1438,19 +1482,19 @@ const Mr = (s, e, t, n) => {
|
|
|
1438
1482
|
t.set(a, { i: 0, refs: o });
|
|
1439
1483
|
for (let l = 0; l < r; l++) {
|
|
1440
1484
|
const h = s.readInfo();
|
|
1441
|
-
switch (
|
|
1485
|
+
switch (gt & h) {
|
|
1442
1486
|
case 0: {
|
|
1443
1487
|
const u = s.readLen();
|
|
1444
|
-
o[l] = new
|
|
1488
|
+
o[l] = new z(w(a, c), u), c += u;
|
|
1445
1489
|
break;
|
|
1446
1490
|
}
|
|
1447
1491
|
case 10: {
|
|
1448
1492
|
const u = m(s.restDecoder);
|
|
1449
|
-
o[l] = new
|
|
1493
|
+
o[l] = new U(w(a, c), u), c += u;
|
|
1450
1494
|
break;
|
|
1451
1495
|
}
|
|
1452
1496
|
default: {
|
|
1453
|
-
const u = (h & (
|
|
1497
|
+
const u = (h & (K | M)) === 0, d = new E(
|
|
1454
1498
|
w(a, c),
|
|
1455
1499
|
null,
|
|
1456
1500
|
// leftd
|
|
@@ -1458,13 +1502,13 @@ const Mr = (s, e, t, n) => {
|
|
|
1458
1502
|
// origin
|
|
1459
1503
|
null,
|
|
1460
1504
|
// right
|
|
1461
|
-
(h &
|
|
1505
|
+
(h & K) === K ? s.readRightID() : null,
|
|
1462
1506
|
// right origin
|
|
1463
1507
|
u ? s.readParentInfo() ? e.get(s.readString()) : s.readLeftID() : null,
|
|
1464
1508
|
// parent
|
|
1465
|
-
u && (h &
|
|
1509
|
+
u && (h & Te) === Te ? s.readString() : null,
|
|
1466
1510
|
// parentSub
|
|
1467
|
-
|
|
1511
|
+
Xn(s, h)
|
|
1468
1512
|
// item content
|
|
1469
1513
|
);
|
|
1470
1514
|
o[l] = d, c += d.length;
|
|
@@ -1473,7 +1517,7 @@ const Mr = (s, e, t, n) => {
|
|
|
1473
1517
|
}
|
|
1474
1518
|
}
|
|
1475
1519
|
return t;
|
|
1476
|
-
},
|
|
1520
|
+
}, Kr = (s, e, t) => {
|
|
1477
1521
|
const n = [];
|
|
1478
1522
|
let i = te(t.keys()).sort((f, g) => f - g);
|
|
1479
1523
|
if (i.length === 0)
|
|
@@ -1496,7 +1540,7 @@ const Mr = (s, e, t, n) => {
|
|
|
1496
1540
|
let o = r();
|
|
1497
1541
|
if (o === null && n.length === 0)
|
|
1498
1542
|
return null;
|
|
1499
|
-
const a = new
|
|
1543
|
+
const a = new vn(), c = /* @__PURE__ */ new Map(), l = (f, g) => {
|
|
1500
1544
|
const k = c.get(f);
|
|
1501
1545
|
(k == null || k > g) && c.set(f, g);
|
|
1502
1546
|
};
|
|
@@ -1510,31 +1554,31 @@ const Mr = (s, e, t, n) => {
|
|
|
1510
1554
|
const u = /* @__PURE__ */ new Map(), d = () => {
|
|
1511
1555
|
for (const f of n) {
|
|
1512
1556
|
const g = f.id.client, k = t.get(g);
|
|
1513
|
-
k ? (k.i--, a.clients.set(g, k.refs.slice(k.i)), t.delete(g), k.i = 0, k.refs = []) : a.clients.set(g, [f]), i = i.filter((
|
|
1557
|
+
k ? (k.i--, a.clients.set(g, k.refs.slice(k.i)), t.delete(g), k.i = 0, k.refs = []) : a.clients.set(g, [f]), i = i.filter((_) => _ !== g);
|
|
1514
1558
|
}
|
|
1515
1559
|
n.length = 0;
|
|
1516
1560
|
};
|
|
1517
1561
|
for (; ; ) {
|
|
1518
|
-
if (h.constructor !==
|
|
1519
|
-
const g =
|
|
1562
|
+
if (h.constructor !== U) {
|
|
1563
|
+
const g = W(u, h.id.client, () => A(e, h.id.client)) - h.id.clock;
|
|
1520
1564
|
if (g < 0)
|
|
1521
1565
|
n.push(h), l(h.id.client, h.id.clock - 1), d();
|
|
1522
1566
|
else {
|
|
1523
1567
|
const k = h.getMissing(s, e);
|
|
1524
1568
|
if (k !== null) {
|
|
1525
1569
|
n.push(h);
|
|
1526
|
-
const
|
|
1570
|
+
const _ = t.get(
|
|
1527
1571
|
/** @type {number} */
|
|
1528
1572
|
k
|
|
1529
1573
|
) || { refs: [], i: 0 };
|
|
1530
|
-
if (
|
|
1574
|
+
if (_.refs.length === _.i)
|
|
1531
1575
|
l(
|
|
1532
1576
|
/** @type {number} */
|
|
1533
1577
|
k,
|
|
1534
1578
|
A(e, k)
|
|
1535
1579
|
), d();
|
|
1536
1580
|
else {
|
|
1537
|
-
h =
|
|
1581
|
+
h = _.refs[_.i++];
|
|
1538
1582
|
continue;
|
|
1539
1583
|
}
|
|
1540
1584
|
} else
|
|
@@ -1555,14 +1599,14 @@ const Mr = (s, e, t, n) => {
|
|
|
1555
1599
|
}
|
|
1556
1600
|
}
|
|
1557
1601
|
if (a.clients.size > 0) {
|
|
1558
|
-
const f = new
|
|
1559
|
-
return
|
|
1602
|
+
const f = new he();
|
|
1603
|
+
return os(f, a, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: c, update: f.toUint8Array() };
|
|
1560
1604
|
}
|
|
1561
1605
|
return null;
|
|
1562
|
-
},
|
|
1606
|
+
}, Yr = (s, e) => os(s, e.doc.store, e.beforeState), Xr = (s, e, t, n = new Ce(s)) => y(e, (i) => {
|
|
1563
1607
|
i.local = !1;
|
|
1564
1608
|
let r = !1;
|
|
1565
|
-
const o = i.doc, a = o.store, c =
|
|
1609
|
+
const o = i.doc, a = o.store, c = qr(n, o), l = Kr(i, a, c), h = a.pendingStructs;
|
|
1566
1610
|
if (h) {
|
|
1567
1611
|
for (const [d, f] of h.missing)
|
|
1568
1612
|
if (f < A(a, d)) {
|
|
@@ -1574,16 +1618,16 @@ const Mr = (s, e, t, n) => {
|
|
|
1574
1618
|
const g = h.missing.get(d);
|
|
1575
1619
|
(g == null || g > f) && h.missing.set(d, f);
|
|
1576
1620
|
}
|
|
1577
|
-
h.update =
|
|
1621
|
+
h.update = ot([h.update, l.update]);
|
|
1578
1622
|
}
|
|
1579
1623
|
} else
|
|
1580
1624
|
a.pendingStructs = l;
|
|
1581
|
-
const u =
|
|
1625
|
+
const u = Ts(n, i, a);
|
|
1582
1626
|
if (a.pendingDs) {
|
|
1583
|
-
const d = new
|
|
1627
|
+
const d = new Ce(ne(a.pendingDs));
|
|
1584
1628
|
m(d.restDecoder);
|
|
1585
|
-
const f =
|
|
1586
|
-
u && f ? a.pendingDs =
|
|
1629
|
+
const f = Ts(d, i, a);
|
|
1630
|
+
u && f ? a.pendingDs = ot([u, f]) : a.pendingDs = u || f;
|
|
1587
1631
|
} else
|
|
1588
1632
|
a.pendingDs = u;
|
|
1589
1633
|
if (r) {
|
|
@@ -1591,44 +1635,44 @@ const Mr = (s, e, t, n) => {
|
|
|
1591
1635
|
/** @type {{update: Uint8Array}} */
|
|
1592
1636
|
a.pendingStructs.update
|
|
1593
1637
|
);
|
|
1594
|
-
a.pendingStructs = null,
|
|
1638
|
+
a.pendingStructs = null, Sn(i.doc, d);
|
|
1595
1639
|
}
|
|
1596
|
-
}, t, !1),
|
|
1640
|
+
}, t, !1), Sn = (s, e, t, n = Ce) => {
|
|
1597
1641
|
const i = ne(e);
|
|
1598
|
-
|
|
1599
|
-
},
|
|
1600
|
-
|
|
1601
|
-
},
|
|
1602
|
-
const n =
|
|
1603
|
-
|
|
1642
|
+
Xr(i, s, t, new n(i));
|
|
1643
|
+
}, _n = (s, e, t) => Sn(s, e, t, bn), Jr = (s, e, t = /* @__PURE__ */ new Map()) => {
|
|
1644
|
+
os(s, e.store, t), Ae(s, Hr(e.store));
|
|
1645
|
+
}, Wr = (s, e = new Uint8Array([0]), t = new he()) => {
|
|
1646
|
+
const n = Dn(e);
|
|
1647
|
+
Jr(t, s, n);
|
|
1604
1648
|
const i = [t.toUint8Array()];
|
|
1605
|
-
if (s.store.pendingDs && i.push(s.store.pendingDs), s.store.pendingStructs && i.push(
|
|
1606
|
-
if (t.constructor ===
|
|
1607
|
-
return
|
|
1608
|
-
if (t.constructor ===
|
|
1609
|
-
return
|
|
1649
|
+
if (s.store.pendingDs && i.push(s.store.pendingDs), s.store.pendingStructs && i.push(ho(s.store.pendingStructs.update, e)), i.length > 1) {
|
|
1650
|
+
if (t.constructor === qe)
|
|
1651
|
+
return co(i.map((r, o) => o === 0 ? r : fo(r)));
|
|
1652
|
+
if (t.constructor === he)
|
|
1653
|
+
return ot(i);
|
|
1610
1654
|
}
|
|
1611
1655
|
return i[0];
|
|
1612
|
-
},
|
|
1656
|
+
}, as = (s, e) => Wr(s, e, new qe()), Gr = (s) => {
|
|
1613
1657
|
const e = /* @__PURE__ */ new Map(), t = m(s.restDecoder);
|
|
1614
1658
|
for (let n = 0; n < t; n++) {
|
|
1615
1659
|
const i = m(s.restDecoder), r = m(s.restDecoder);
|
|
1616
1660
|
e.set(i, r);
|
|
1617
1661
|
}
|
|
1618
1662
|
return e;
|
|
1619
|
-
},
|
|
1663
|
+
}, Dn = (s) => Gr(new mn(ne(s))), En = (s, e) => (p(s.restEncoder, e.size), te(e.entries()).sort((t, n) => n[0] - t[0]).forEach(([t, n]) => {
|
|
1620
1664
|
p(s.restEncoder, t), p(s.restEncoder, n);
|
|
1621
|
-
}), s),
|
|
1622
|
-
class
|
|
1665
|
+
}), s), Pr = (s, e) => En(s, mt(e.store)), Zr = (s, e = new yn()) => (s instanceof Map ? En(e, s) : Pr(e, s), e.toUint8Array()), Qr = (s) => Zr(s, new wn());
|
|
1666
|
+
class eo {
|
|
1623
1667
|
constructor() {
|
|
1624
1668
|
this.l = [];
|
|
1625
1669
|
}
|
|
1626
1670
|
}
|
|
1627
|
-
const
|
|
1671
|
+
const Os = () => new eo(), Rs = (s, e) => s.l.push(e), Bs = (s, e) => {
|
|
1628
1672
|
const t = s.l, n = t.length;
|
|
1629
1673
|
s.l = t.filter((i) => e !== i), n === s.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1630
|
-
},
|
|
1631
|
-
class
|
|
1674
|
+
}, Cn = (s, e, t) => Gt(s.l, [e, t]);
|
|
1675
|
+
class we {
|
|
1632
1676
|
/**
|
|
1633
1677
|
* @param {number} client client id
|
|
1634
1678
|
* @param {number} clock unique per client id, continuous number
|
|
@@ -1637,24 +1681,24 @@ class be {
|
|
|
1637
1681
|
this.client = e, this.clock = t;
|
|
1638
1682
|
}
|
|
1639
1683
|
}
|
|
1640
|
-
const
|
|
1684
|
+
const Ge = (s, e) => s === e || s !== null && e !== null && s.client === e.client && s.clock === e.clock, w = (s, e) => new we(s, e), to = (s) => {
|
|
1641
1685
|
for (const [e, t] of s.doc.share.entries())
|
|
1642
1686
|
if (t === s)
|
|
1643
1687
|
return e;
|
|
1644
1688
|
throw F();
|
|
1645
|
-
},
|
|
1646
|
-
const t =
|
|
1689
|
+
}, Le = (s, e) => e === void 0 ? !s.deleted : e.sv.has(s.id.client) && (e.sv.get(s.id.client) || 0) > s.id.clock && !pn(e.ds, s.id), Ht = (s, e) => {
|
|
1690
|
+
const t = W(s.meta, Ht, ce), n = s.doc.store;
|
|
1647
1691
|
t.has(e) || (e.sv.forEach((i, r) => {
|
|
1648
1692
|
i < A(n, r) && se(s, w(r, i));
|
|
1649
|
-
}),
|
|
1693
|
+
}), gn(s, e.ds, (i) => {
|
|
1650
1694
|
}), t.add(e));
|
|
1651
1695
|
};
|
|
1652
|
-
class
|
|
1696
|
+
class vn {
|
|
1653
1697
|
constructor() {
|
|
1654
1698
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
1655
1699
|
}
|
|
1656
1700
|
}
|
|
1657
|
-
const
|
|
1701
|
+
const mt = (s) => {
|
|
1658
1702
|
const e = /* @__PURE__ */ new Map();
|
|
1659
1703
|
return s.clients.forEach((t, n) => {
|
|
1660
1704
|
const i = t[t.length - 1];
|
|
@@ -1666,7 +1710,7 @@ const gt = (s) => {
|
|
|
1666
1710
|
return 0;
|
|
1667
1711
|
const n = t[t.length - 1];
|
|
1668
1712
|
return n.id.clock + n.length;
|
|
1669
|
-
},
|
|
1713
|
+
}, An = (s, e) => {
|
|
1670
1714
|
let t = s.clients.get(e.id.client);
|
|
1671
1715
|
if (t === void 0)
|
|
1672
1716
|
t = [], s.clients.set(e.id.client, t);
|
|
@@ -1691,53 +1735,53 @@ const gt = (s) => {
|
|
|
1691
1735
|
o = X((t + n) / 2);
|
|
1692
1736
|
}
|
|
1693
1737
|
throw F();
|
|
1694
|
-
},
|
|
1738
|
+
}, so = (s, e) => {
|
|
1695
1739
|
const t = s.clients.get(e.client);
|
|
1696
1740
|
return t[H(t, e.clock)];
|
|
1697
|
-
},
|
|
1741
|
+
}, xt = (
|
|
1698
1742
|
/** @type {function(StructStore,ID):Item} */
|
|
1699
|
-
|
|
1700
|
-
),
|
|
1743
|
+
so
|
|
1744
|
+
), Vt = (s, e, t) => {
|
|
1701
1745
|
const n = H(e, t), i = e[n];
|
|
1702
|
-
return i.id.clock < t && i instanceof E ? (e.splice(n + 1, 0,
|
|
1746
|
+
return i.id.clock < t && i instanceof E ? (e.splice(n + 1, 0, dt(s, i, t - i.id.clock)), n + 1) : n;
|
|
1703
1747
|
}, se = (s, e) => {
|
|
1704
1748
|
const t = (
|
|
1705
1749
|
/** @type {Array<Item>} */
|
|
1706
1750
|
s.doc.store.clients.get(e.client)
|
|
1707
1751
|
);
|
|
1708
|
-
return t[
|
|
1709
|
-
},
|
|
1752
|
+
return t[Vt(s, t, e.clock)];
|
|
1753
|
+
}, Ns = (s, e, t) => {
|
|
1710
1754
|
const n = e.clients.get(t.client), i = H(n, t.clock), r = n[i];
|
|
1711
|
-
return t.clock !== r.id.clock + r.length - 1 && r.constructor !==
|
|
1712
|
-
},
|
|
1755
|
+
return t.clock !== r.id.clock + r.length - 1 && r.constructor !== z && n.splice(i + 1, 0, dt(s, r, t.clock - r.id.clock + 1)), r;
|
|
1756
|
+
}, no = (s, e, t) => {
|
|
1713
1757
|
const n = (
|
|
1714
1758
|
/** @type {Array<GC|Item>} */
|
|
1715
1759
|
s.clients.get(e.id.client)
|
|
1716
1760
|
);
|
|
1717
1761
|
n[H(n, e.id.clock)] = t;
|
|
1718
|
-
},
|
|
1762
|
+
}, xn = (s, e, t, n, i) => {
|
|
1719
1763
|
if (n === 0)
|
|
1720
1764
|
return;
|
|
1721
1765
|
const r = t + n;
|
|
1722
|
-
let o =
|
|
1766
|
+
let o = Vt(s, e, t), a;
|
|
1723
1767
|
do
|
|
1724
|
-
a = e[o++], r < a.id.clock + a.length &&
|
|
1768
|
+
a = e[o++], r < a.id.clock + a.length && Vt(s, e, r), i(a);
|
|
1725
1769
|
while (o < e.length && e[o].id.clock < r);
|
|
1726
1770
|
};
|
|
1727
|
-
class
|
|
1771
|
+
class io {
|
|
1728
1772
|
/**
|
|
1729
1773
|
* @param {Doc} doc
|
|
1730
1774
|
* @param {any} origin
|
|
1731
1775
|
* @param {boolean} local
|
|
1732
1776
|
*/
|
|
1733
1777
|
constructor(e, t, n) {
|
|
1734
|
-
this.doc = e, this.deleteSet = new
|
|
1778
|
+
this.doc = e, this.deleteSet = new $e(), this.beforeState = mt(e.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = t, this.meta = /* @__PURE__ */ new Map(), this.local = n, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
1735
1779
|
}
|
|
1736
1780
|
}
|
|
1737
|
-
const
|
|
1781
|
+
const Fs = (s, e) => e.deleteSet.clients.size === 0 && !wi(e.afterState, (t, n) => e.beforeState.get(n) !== t) ? !1 : (is(e.deleteSet), Yr(s, e), Ae(s, e.deleteSet), !0), Hs = (s, e, t) => {
|
|
1738
1782
|
const n = e._item;
|
|
1739
|
-
(n === null || n.id.clock < (s.beforeState.get(n.id.client) || 0) && !n.deleted) &&
|
|
1740
|
-
},
|
|
1783
|
+
(n === null || n.id.clock < (s.beforeState.get(n.id.client) || 0) && !n.deleted) && W(s.changed, e, ce).add(t);
|
|
1784
|
+
}, nt = (s, e) => {
|
|
1741
1785
|
let t = s[e], n = s[e - 1], i = e;
|
|
1742
1786
|
for (; i > 0; t = n, n = s[--i - 1]) {
|
|
1743
1787
|
if (n.deleted === t.deleted && n.constructor === t.constructor && n.mergeWith(t)) {
|
|
@@ -1753,7 +1797,7 @@ const Ms = (s, e) => e.deleteSet.clients.size === 0 && !ci(e.afterState, (t, n)
|
|
|
1753
1797
|
}
|
|
1754
1798
|
const r = e - i;
|
|
1755
1799
|
return r && s.splice(e + 1 - r, r), r;
|
|
1756
|
-
},
|
|
1800
|
+
}, ro = (s, e, t) => {
|
|
1757
1801
|
for (const [n, i] of s.clients.entries()) {
|
|
1758
1802
|
const r = (
|
|
1759
1803
|
/** @type {Array<GC|Item>} */
|
|
@@ -1769,23 +1813,23 @@ const Ms = (s, e) => e.deleteSet.clients.size === 0 && !ci(e.afterState, (t, n)
|
|
|
1769
1813
|
}
|
|
1770
1814
|
}
|
|
1771
1815
|
}
|
|
1772
|
-
},
|
|
1816
|
+
}, oo = (s, e) => {
|
|
1773
1817
|
s.clients.forEach((t, n) => {
|
|
1774
1818
|
const i = (
|
|
1775
1819
|
/** @type {Array<GC|Item>} */
|
|
1776
1820
|
e.clients.get(n)
|
|
1777
1821
|
);
|
|
1778
1822
|
for (let r = t.length - 1; r >= 0; r--) {
|
|
1779
|
-
const o = t[r], a =
|
|
1823
|
+
const o = t[r], a = Jt(i.length - 1, 1 + H(i, o.clock + o.len - 1));
|
|
1780
1824
|
for (let c = a, l = i[c]; c > 0 && l.id.clock >= o.clock; l = i[c])
|
|
1781
|
-
c -= 1 +
|
|
1825
|
+
c -= 1 + nt(i, c);
|
|
1782
1826
|
}
|
|
1783
1827
|
});
|
|
1784
|
-
},
|
|
1828
|
+
}, Ln = (s, e) => {
|
|
1785
1829
|
if (e < s.length) {
|
|
1786
1830
|
const t = s[e], n = t.doc, i = n.store, r = t.deleteSet, o = t._mergeStructs;
|
|
1787
1831
|
try {
|
|
1788
|
-
|
|
1832
|
+
is(r), t.afterState = mt(t.doc.store), n.emit("beforeObserverCalls", [t, n]);
|
|
1789
1833
|
const a = [];
|
|
1790
1834
|
t.changed.forEach(
|
|
1791
1835
|
(c, l) => a.push(() => {
|
|
@@ -1797,19 +1841,19 @@ const Ms = (s, e) => e.deleteSet.clients.size === 0 && !ci(e.afterState, (t, n)
|
|
|
1797
1841
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
1798
1842
|
), c.forEach((h) => {
|
|
1799
1843
|
h.currentTarget = l, h._path = null;
|
|
1800
|
-
}), c.sort((h, u) => h.path.length - u.path.length),
|
|
1844
|
+
}), c.sort((h, u) => h.path.length - u.path.length), Cn(l._dEH, c, t));
|
|
1801
1845
|
});
|
|
1802
|
-
}), a.push(() => n.emit("afterTransaction", [t, n])),
|
|
1846
|
+
}), a.push(() => n.emit("afterTransaction", [t, n])), Gt(a, []), t._needFormattingCleanup && vo(t);
|
|
1803
1847
|
} finally {
|
|
1804
|
-
n.gc &&
|
|
1848
|
+
n.gc && ro(r, i, n.gcFilter), oo(r, i), t.afterState.forEach((h, u) => {
|
|
1805
1849
|
const d = t.beforeState.get(u) || 0;
|
|
1806
1850
|
if (d !== h) {
|
|
1807
1851
|
const f = (
|
|
1808
1852
|
/** @type {Array<GC|Item>} */
|
|
1809
1853
|
i.clients.get(u)
|
|
1810
|
-
), g =
|
|
1854
|
+
), g = ge(H(f, d), 1);
|
|
1811
1855
|
for (let k = f.length - 1; k >= g; )
|
|
1812
|
-
k -= 1 +
|
|
1856
|
+
k -= 1 + nt(f, k);
|
|
1813
1857
|
}
|
|
1814
1858
|
});
|
|
1815
1859
|
for (let h = o.length - 1; h >= 0; h--) {
|
|
@@ -1817,37 +1861,37 @@ const Ms = (s, e) => e.deleteSet.clients.size === 0 && !ci(e.afterState, (t, n)
|
|
|
1817
1861
|
/** @type {Array<GC|Item>} */
|
|
1818
1862
|
i.clients.get(u)
|
|
1819
1863
|
), g = H(f, d);
|
|
1820
|
-
g + 1 < f.length &&
|
|
1864
|
+
g + 1 < f.length && nt(f, g + 1) > 1 || g > 0 && nt(f, g);
|
|
1821
1865
|
}
|
|
1822
|
-
if (!t.local && t.afterState.get(n.clientID) !== t.beforeState.get(n.clientID) && (
|
|
1823
|
-
const h = new
|
|
1824
|
-
|
|
1866
|
+
if (!t.local && t.afterState.get(n.clientID) !== t.beforeState.get(n.clientID) && (Tr(dn, ln, "[yjs] ", hn, un, "Changed the client-id because another client seems to be using it."), n.clientID = kn()), n.emit("afterTransactionCleanup", [t, n]), n._observers.has("update")) {
|
|
1867
|
+
const h = new qe();
|
|
1868
|
+
Fs(h, t) && n.emit("update", [h.toUint8Array(), t.origin, n, t]);
|
|
1825
1869
|
}
|
|
1826
1870
|
if (n._observers.has("updateV2")) {
|
|
1827
|
-
const h = new
|
|
1828
|
-
|
|
1871
|
+
const h = new he();
|
|
1872
|
+
Fs(h, t) && n.emit("updateV2", [h.toUint8Array(), t.origin, n, t]);
|
|
1829
1873
|
}
|
|
1830
1874
|
const { subdocsAdded: a, subdocsLoaded: c, subdocsRemoved: l } = t;
|
|
1831
1875
|
(a.size > 0 || l.size > 0 || c.size > 0) && (a.forEach((h) => {
|
|
1832
1876
|
h.clientID = n.clientID, h.collectionid == null && (h.collectionid = n.collectionid), n.subdocs.add(h);
|
|
1833
|
-
}), l.forEach((h) => n.subdocs.delete(h)), n.emit("subdocs", [{ loaded: c, added: a, removed: l }, n, t]), l.forEach((h) => h.destroy())), s.length <= e + 1 ? (n._transactionCleanups = [], n.emit("afterAllTransactions", [n, s])) :
|
|
1877
|
+
}), l.forEach((h) => n.subdocs.delete(h)), n.emit("subdocs", [{ loaded: c, added: a, removed: l }, n, t]), l.forEach((h) => h.destroy())), s.length <= e + 1 ? (n._transactionCleanups = [], n.emit("afterAllTransactions", [n, s])) : Ln(s, e + 1);
|
|
1834
1878
|
}
|
|
1835
1879
|
}
|
|
1836
1880
|
}, y = (s, e, t = null, n = !0) => {
|
|
1837
1881
|
const i = s._transactionCleanups;
|
|
1838
1882
|
let r = !1, o = null;
|
|
1839
|
-
s._transaction === null && (r = !0, s._transaction = new
|
|
1883
|
+
s._transaction === null && (r = !0, s._transaction = new io(s, t, n), i.push(s._transaction), i.length === 1 && s.emit("beforeAllTransactions", [s]), s.emit("beforeTransaction", [s._transaction, s]));
|
|
1840
1884
|
try {
|
|
1841
1885
|
o = e(s._transaction);
|
|
1842
1886
|
} finally {
|
|
1843
1887
|
if (r) {
|
|
1844
1888
|
const a = s._transaction === i[0];
|
|
1845
|
-
s._transaction = null, a &&
|
|
1889
|
+
s._transaction = null, a && Ln(i, 0);
|
|
1846
1890
|
}
|
|
1847
1891
|
}
|
|
1848
1892
|
return o;
|
|
1849
1893
|
};
|
|
1850
|
-
function*
|
|
1894
|
+
function* ao(s) {
|
|
1851
1895
|
const e = m(s.restDecoder);
|
|
1852
1896
|
for (let t = 0; t < e; t++) {
|
|
1853
1897
|
const n = m(s.restDecoder), i = s.readClient();
|
|
@@ -1856,9 +1900,9 @@ function* Wr(s) {
|
|
|
1856
1900
|
const a = s.readInfo();
|
|
1857
1901
|
if (a === 10) {
|
|
1858
1902
|
const c = m(s.restDecoder);
|
|
1859
|
-
yield new
|
|
1860
|
-
} else if (
|
|
1861
|
-
const c = (a & (
|
|
1903
|
+
yield new U(w(i, r), c), r += c;
|
|
1904
|
+
} else if (gt & a) {
|
|
1905
|
+
const c = (a & (K | M)) === 0, l = new E(
|
|
1862
1906
|
w(i, r),
|
|
1863
1907
|
null,
|
|
1864
1908
|
// left
|
|
@@ -1866,31 +1910,31 @@ function* Wr(s) {
|
|
|
1866
1910
|
// origin
|
|
1867
1911
|
null,
|
|
1868
1912
|
// right
|
|
1869
|
-
(a &
|
|
1913
|
+
(a & K) === K ? s.readRightID() : null,
|
|
1870
1914
|
// right origin
|
|
1871
1915
|
// @ts-ignore Force writing a string here.
|
|
1872
1916
|
c ? s.readParentInfo() ? s.readString() : s.readLeftID() : null,
|
|
1873
1917
|
// parent
|
|
1874
|
-
c && (a &
|
|
1918
|
+
c && (a & Te) === Te ? s.readString() : null,
|
|
1875
1919
|
// parentSub
|
|
1876
|
-
|
|
1920
|
+
Xn(s, a)
|
|
1877
1921
|
// item content
|
|
1878
1922
|
);
|
|
1879
1923
|
yield l, r += l.length;
|
|
1880
1924
|
} else {
|
|
1881
1925
|
const c = s.readLen();
|
|
1882
|
-
yield new
|
|
1926
|
+
yield new z(w(i, r), c), r += c;
|
|
1883
1927
|
}
|
|
1884
1928
|
}
|
|
1885
1929
|
}
|
|
1886
1930
|
}
|
|
1887
|
-
class
|
|
1931
|
+
class cs {
|
|
1888
1932
|
/**
|
|
1889
1933
|
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
|
|
1890
1934
|
* @param {boolean} filterSkips
|
|
1891
1935
|
*/
|
|
1892
1936
|
constructor(e, t) {
|
|
1893
|
-
this.gen =
|
|
1937
|
+
this.gen = ao(e), this.curr = null, this.done = !1, this.filterSkips = t, this.next();
|
|
1894
1938
|
}
|
|
1895
1939
|
/**
|
|
1896
1940
|
* @return {Item | GC | Skip |null}
|
|
@@ -1898,11 +1942,11 @@ class rs {
|
|
|
1898
1942
|
next() {
|
|
1899
1943
|
do
|
|
1900
1944
|
this.curr = this.gen.next().value || null;
|
|
1901
|
-
while (this.filterSkips && this.curr !== null && this.curr.constructor ===
|
|
1945
|
+
while (this.filterSkips && this.curr !== null && this.curr.constructor === U);
|
|
1902
1946
|
return this.curr;
|
|
1903
1947
|
}
|
|
1904
1948
|
}
|
|
1905
|
-
class
|
|
1949
|
+
class ls {
|
|
1906
1950
|
/**
|
|
1907
1951
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
1908
1952
|
*/
|
|
@@ -1910,13 +1954,13 @@ class os {
|
|
|
1910
1954
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = e, this.clientStructs = [];
|
|
1911
1955
|
}
|
|
1912
1956
|
}
|
|
1913
|
-
const
|
|
1914
|
-
if (s.constructor ===
|
|
1915
|
-
const { client: t, clock: n } = s.id;
|
|
1916
|
-
return new U(w(t, n + e), s.length - e);
|
|
1917
|
-
} else if (s.constructor === z) {
|
|
1957
|
+
const co = (s) => ot(s, bn, qe), lo = (s, e) => {
|
|
1958
|
+
if (s.constructor === z) {
|
|
1918
1959
|
const { client: t, clock: n } = s.id;
|
|
1919
1960
|
return new z(w(t, n + e), s.length - e);
|
|
1961
|
+
} else if (s.constructor === U) {
|
|
1962
|
+
const { client: t, clock: n } = s.id;
|
|
1963
|
+
return new U(w(t, n + e), s.length - e);
|
|
1920
1964
|
} else {
|
|
1921
1965
|
const t = (
|
|
1922
1966
|
/** @type {Item} */
|
|
@@ -1933,18 +1977,18 @@ const Pr = (s) => nt(s, ln, $e), Qr = (s, e) => {
|
|
|
1933
1977
|
t.content.splice(e)
|
|
1934
1978
|
);
|
|
1935
1979
|
}
|
|
1936
|
-
},
|
|
1980
|
+
}, ot = (s, e = Ce, t = he) => {
|
|
1937
1981
|
if (s.length === 1)
|
|
1938
1982
|
return s[0];
|
|
1939
1983
|
const n = s.map((h) => new e(ne(h)));
|
|
1940
|
-
let i = n.map((h) => new
|
|
1941
|
-
const o = new t(), a = new
|
|
1984
|
+
let i = n.map((h) => new cs(h, !0)), r = null;
|
|
1985
|
+
const o = new t(), a = new ls(o);
|
|
1942
1986
|
for (; i = i.filter((d) => d.curr !== null), i.sort(
|
|
1943
1987
|
/** @type {function(any,any):number} */
|
|
1944
1988
|
(d, f) => {
|
|
1945
1989
|
if (d.curr.id.client === f.curr.id.client) {
|
|
1946
1990
|
const g = d.curr.id.clock - f.curr.id.clock;
|
|
1947
|
-
return g === 0 ? d.curr.constructor === f.curr.constructor ? 0 : d.curr.constructor ===
|
|
1991
|
+
return g === 0 ? d.curr.constructor === f.curr.constructor ? 0 : d.curr.constructor === U ? 1 : -1 : g;
|
|
1948
1992
|
} else
|
|
1949
1993
|
return f.curr.id.client - d.curr.id.client;
|
|
1950
1994
|
}
|
|
@@ -1965,72 +2009,72 @@ const Pr = (s) => nt(s, ln, $e), Qr = (s, e) => {
|
|
|
1965
2009
|
f && d.id.clock > r.struct.id.clock + r.struct.length)
|
|
1966
2010
|
continue;
|
|
1967
2011
|
if (u !== r.struct.id.client)
|
|
1968
|
-
|
|
2012
|
+
Z(a, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next();
|
|
1969
2013
|
else if (r.struct.id.clock + r.struct.length < d.id.clock)
|
|
1970
|
-
if (r.struct.constructor ===
|
|
2014
|
+
if (r.struct.constructor === U)
|
|
1971
2015
|
r.struct.length = d.id.clock + d.length - r.struct.id.clock;
|
|
1972
2016
|
else {
|
|
1973
|
-
|
|
2017
|
+
Z(a, r.struct, r.offset);
|
|
1974
2018
|
const g = d.id.clock - r.struct.id.clock - r.struct.length;
|
|
1975
|
-
r = { struct: new
|
|
2019
|
+
r = { struct: new U(w(u, r.struct.id.clock + r.struct.length), g), offset: 0 };
|
|
1976
2020
|
}
|
|
1977
2021
|
else {
|
|
1978
2022
|
const g = r.struct.id.clock + r.struct.length - d.id.clock;
|
|
1979
|
-
g > 0 && (r.struct.constructor ===
|
|
2023
|
+
g > 0 && (r.struct.constructor === U ? r.struct.length -= g : d = lo(d, g)), r.struct.mergeWith(
|
|
1980
2024
|
/** @type {any} */
|
|
1981
2025
|
d
|
|
1982
|
-
) || (
|
|
2026
|
+
) || (Z(a, r.struct, r.offset), r = { struct: d, offset: 0 }, h.next());
|
|
1983
2027
|
}
|
|
1984
2028
|
} else
|
|
1985
2029
|
r = { struct: (
|
|
1986
2030
|
/** @type {Item | GC} */
|
|
1987
2031
|
h.curr
|
|
1988
2032
|
), offset: 0 }, h.next();
|
|
1989
|
-
for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === r.struct.id.clock + r.struct.length && d.constructor !==
|
|
1990
|
-
|
|
1991
|
-
}
|
|
1992
|
-
r !== null && (
|
|
1993
|
-
const c = n.map((h) =>
|
|
1994
|
-
return
|
|
1995
|
-
},
|
|
1996
|
-
const i =
|
|
2033
|
+
for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === r.struct.id.clock + r.struct.length && d.constructor !== U; d = h.next())
|
|
2034
|
+
Z(a, r.struct, r.offset), r = { struct: d, offset: 0 };
|
|
2035
|
+
}
|
|
2036
|
+
r !== null && (Z(a, r.struct, r.offset), r = null), hs(a);
|
|
2037
|
+
const c = n.map((h) => rs(h)), l = Nr(c);
|
|
2038
|
+
return Ae(o, l), o.toUint8Array();
|
|
2039
|
+
}, ho = (s, e, t = Ce, n = he) => {
|
|
2040
|
+
const i = Dn(e), r = new n(), o = new ls(r), a = new t(ne(s)), c = new cs(a, !1);
|
|
1997
2041
|
for (; c.curr; ) {
|
|
1998
2042
|
const h = c.curr, u = h.id.client, d = i.get(u) || 0;
|
|
1999
|
-
if (c.curr.constructor ===
|
|
2043
|
+
if (c.curr.constructor === U) {
|
|
2000
2044
|
c.next();
|
|
2001
2045
|
continue;
|
|
2002
2046
|
}
|
|
2003
2047
|
if (h.id.clock + h.length > d)
|
|
2004
|
-
for (
|
|
2005
|
-
|
|
2048
|
+
for (Z(o, h, ge(d - h.id.clock, 0)), c.next(); c.curr && c.curr.id.client === u; )
|
|
2049
|
+
Z(o, c.curr, 0), c.next();
|
|
2006
2050
|
else
|
|
2007
2051
|
for (; c.curr && c.curr.id.client === u && c.curr.id.clock + c.curr.length <= d; )
|
|
2008
2052
|
c.next();
|
|
2009
2053
|
}
|
|
2010
|
-
|
|
2011
|
-
const l =
|
|
2012
|
-
return
|
|
2013
|
-
},
|
|
2014
|
-
s.written > 0 && (s.clientStructs.push({ written: s.written, restEncoder:
|
|
2015
|
-
},
|
|
2016
|
-
s.written > 0 && s.currClient !== e.id.client &&
|
|
2017
|
-
},
|
|
2018
|
-
|
|
2054
|
+
hs(o);
|
|
2055
|
+
const l = rs(a);
|
|
2056
|
+
return Ae(r, l), r.toUint8Array();
|
|
2057
|
+
}, In = (s) => {
|
|
2058
|
+
s.written > 0 && (s.clientStructs.push({ written: s.written, restEncoder: S(s.encoder.restEncoder) }), s.encoder.restEncoder = I(), s.written = 0);
|
|
2059
|
+
}, Z = (s, e, t) => {
|
|
2060
|
+
s.written > 0 && s.currClient !== e.id.client && In(s), s.written === 0 && (s.currClient = e.id.client, s.encoder.writeClient(e.id.client), p(s.encoder.restEncoder, e.id.clock + t)), e.write(s.encoder, t), s.written++;
|
|
2061
|
+
}, hs = (s) => {
|
|
2062
|
+
In(s);
|
|
2019
2063
|
const e = s.encoder.restEncoder;
|
|
2020
2064
|
p(e, s.clientStructs.length);
|
|
2021
2065
|
for (let t = 0; t < s.clientStructs.length; t++) {
|
|
2022
2066
|
const n = s.clientStructs[t];
|
|
2023
|
-
p(e, n.written),
|
|
2067
|
+
p(e, n.written), kt(e, n.restEncoder);
|
|
2024
2068
|
}
|
|
2025
|
-
},
|
|
2026
|
-
const i = new t(ne(s)), r = new
|
|
2069
|
+
}, uo = (s, e, t, n) => {
|
|
2070
|
+
const i = new t(ne(s)), r = new cs(i, !1), o = new n(), a = new ls(o);
|
|
2027
2071
|
for (let l = r.curr; l !== null; l = r.next())
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
const c =
|
|
2031
|
-
return
|
|
2032
|
-
},
|
|
2033
|
-
class
|
|
2072
|
+
Z(a, e(l), 0);
|
|
2073
|
+
hs(a);
|
|
2074
|
+
const c = rs(i);
|
|
2075
|
+
return Ae(o, c), o.toUint8Array();
|
|
2076
|
+
}, fo = (s) => uo(s, Hi, Ce, qe), Vs = "You must not compute changes after the event-handler fired.";
|
|
2077
|
+
class bt {
|
|
2034
2078
|
/**
|
|
2035
2079
|
* @param {T} target The changed type.
|
|
2036
2080
|
* @param {Transaction} transaction
|
|
@@ -2052,7 +2096,7 @@ class pt {
|
|
|
2052
2096
|
* type === event.target // => true
|
|
2053
2097
|
*/
|
|
2054
2098
|
get path() {
|
|
2055
|
-
return this._path || (this._path =
|
|
2099
|
+
return this._path || (this._path = go(this.currentTarget, this.target));
|
|
2056
2100
|
}
|
|
2057
2101
|
/**
|
|
2058
2102
|
* Check if a struct is deleted by this event.
|
|
@@ -2063,7 +2107,7 @@ class pt {
|
|
|
2063
2107
|
* @return {boolean}
|
|
2064
2108
|
*/
|
|
2065
2109
|
deletes(e) {
|
|
2066
|
-
return
|
|
2110
|
+
return pn(this.transaction.deleteSet, e.id);
|
|
2067
2111
|
}
|
|
2068
2112
|
/**
|
|
2069
2113
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2071,7 +2115,7 @@ class pt {
|
|
|
2071
2115
|
get keys() {
|
|
2072
2116
|
if (this._keys === null) {
|
|
2073
2117
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2074
|
-
throw J(
|
|
2118
|
+
throw J(Vs);
|
|
2075
2119
|
const e = /* @__PURE__ */ new Map(), t = this.target;
|
|
2076
2120
|
/** @type Set<string|null> */
|
|
2077
2121
|
this.transaction.changed.get(t).forEach((i) => {
|
|
@@ -2087,13 +2131,13 @@ class pt {
|
|
|
2087
2131
|
c = c.left;
|
|
2088
2132
|
if (this.deletes(r))
|
|
2089
2133
|
if (c !== null && this.deletes(c))
|
|
2090
|
-
o = "delete", a =
|
|
2134
|
+
o = "delete", a = _t(c.content.getContent());
|
|
2091
2135
|
else
|
|
2092
2136
|
return;
|
|
2093
2137
|
else
|
|
2094
|
-
c !== null && this.deletes(c) ? (o = "update", a =
|
|
2138
|
+
c !== null && this.deletes(c) ? (o = "update", a = _t(c.content.getContent())) : (o = "add", a = void 0);
|
|
2095
2139
|
} else if (this.deletes(r))
|
|
2096
|
-
o = "delete", a =
|
|
2140
|
+
o = "delete", a = _t(
|
|
2097
2141
|
/** @type {Item} */
|
|
2098
2142
|
r.content.getContent()
|
|
2099
2143
|
);
|
|
@@ -2139,8 +2183,8 @@ class pt {
|
|
|
2139
2183
|
let e = this._changes;
|
|
2140
2184
|
if (e === null) {
|
|
2141
2185
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2142
|
-
throw J(
|
|
2143
|
-
const t = this.target, n =
|
|
2186
|
+
throw J(Vs);
|
|
2187
|
+
const t = this.target, n = ce(), i = ce(), r = [];
|
|
2144
2188
|
if (e = {
|
|
2145
2189
|
added: n,
|
|
2146
2190
|
deleted: i,
|
|
@@ -2164,7 +2208,7 @@ class pt {
|
|
|
2164
2208
|
);
|
|
2165
2209
|
}
|
|
2166
2210
|
}
|
|
2167
|
-
const
|
|
2211
|
+
const go = (s, e) => {
|
|
2168
2212
|
const t = [];
|
|
2169
2213
|
for (; e._item !== null && e !== s; ) {
|
|
2170
2214
|
if (e._item.parentSub !== null)
|
|
@@ -2182,35 +2226,35 @@ const so = (s, e) => {
|
|
|
2182
2226
|
e._item.parent;
|
|
2183
2227
|
}
|
|
2184
2228
|
return t;
|
|
2185
|
-
},
|
|
2186
|
-
let
|
|
2187
|
-
class
|
|
2229
|
+
}, jn = 80;
|
|
2230
|
+
let us = 0;
|
|
2231
|
+
class po {
|
|
2188
2232
|
/**
|
|
2189
2233
|
* @param {Item} p
|
|
2190
2234
|
* @param {number} index
|
|
2191
2235
|
*/
|
|
2192
2236
|
constructor(e, t) {
|
|
2193
|
-
e.marker = !0, this.p = e, this.index = t, this.timestamp =
|
|
2237
|
+
e.marker = !0, this.p = e, this.index = t, this.timestamp = us++;
|
|
2194
2238
|
}
|
|
2195
2239
|
}
|
|
2196
|
-
const
|
|
2197
|
-
s.timestamp =
|
|
2198
|
-
},
|
|
2199
|
-
s.p.marker = !1, s.p = e, e.marker = !0, s.index = t, s.timestamp =
|
|
2200
|
-
},
|
|
2201
|
-
if (s.length >=
|
|
2240
|
+
const ko = (s) => {
|
|
2241
|
+
s.timestamp = us++;
|
|
2242
|
+
}, Mn = (s, e, t) => {
|
|
2243
|
+
s.p.marker = !1, s.p = e, e.marker = !0, s.index = t, s.timestamp = us++;
|
|
2244
|
+
}, mo = (s, e, t) => {
|
|
2245
|
+
if (s.length >= jn) {
|
|
2202
2246
|
const n = s.reduce((i, r) => i.timestamp < r.timestamp ? i : r);
|
|
2203
|
-
return
|
|
2247
|
+
return Mn(n, e, t), n;
|
|
2204
2248
|
} else {
|
|
2205
|
-
const n = new
|
|
2249
|
+
const n = new po(e, t);
|
|
2206
2250
|
return s.push(n), n;
|
|
2207
2251
|
}
|
|
2208
|
-
},
|
|
2252
|
+
}, wt = (s, e) => {
|
|
2209
2253
|
if (s._start === null || e === 0 || s._searchMarker === null)
|
|
2210
2254
|
return null;
|
|
2211
|
-
const t = s._searchMarker.length === 0 ? null : s._searchMarker.reduce((r, o) =>
|
|
2255
|
+
const t = s._searchMarker.length === 0 ? null : s._searchMarker.reduce((r, o) => et(e - r.index) < et(e - o.index) ? r : o);
|
|
2212
2256
|
let n = s._start, i = 0;
|
|
2213
|
-
for (t !== null && (n = t.p, i = t.index,
|
|
2257
|
+
for (t !== null && (n = t.p, i = t.index, ko(t)); n.right !== null && i < e; ) {
|
|
2214
2258
|
if (!n.deleted && n.countable) {
|
|
2215
2259
|
if (e < i + n.length)
|
|
2216
2260
|
break;
|
|
@@ -2222,9 +2266,9 @@ const io = (s) => {
|
|
|
2222
2266
|
n = n.left, !n.deleted && n.countable && (i -= n.length);
|
|
2223
2267
|
for (; n.left !== null && n.left.id.client === n.id.client && n.left.id.clock + n.left.length === n.id.clock; )
|
|
2224
2268
|
n = n.left, !n.deleted && n.countable && (i -= n.length);
|
|
2225
|
-
return t !== null &&
|
|
2226
|
-
n.parent.length /
|
|
2227
|
-
},
|
|
2269
|
+
return t !== null && et(t.index - i) < /** @type {YText|YArray<any>} */
|
|
2270
|
+
n.parent.length / jn ? (Mn(t, n, i), t) : mo(s._searchMarker, n, i);
|
|
2271
|
+
}, Be = (s, e, t) => {
|
|
2228
2272
|
for (let n = s.length - 1; n >= 0; n--) {
|
|
2229
2273
|
const i = s[n];
|
|
2230
2274
|
if (t > 0) {
|
|
@@ -2237,18 +2281,18 @@ const io = (s) => {
|
|
|
2237
2281
|
}
|
|
2238
2282
|
i.p = r, r.marker = !0;
|
|
2239
2283
|
}
|
|
2240
|
-
(e < i.index || t > 0 && e === i.index) && (i.index =
|
|
2284
|
+
(e < i.index || t > 0 && e === i.index) && (i.index = ge(e, i.index + t));
|
|
2241
2285
|
}
|
|
2242
|
-
},
|
|
2286
|
+
}, yt = (s, e, t) => {
|
|
2243
2287
|
const n = s, i = e.changedParentTypes;
|
|
2244
|
-
for (;
|
|
2288
|
+
for (; W(i, s, () => []).push(t), s._item !== null; )
|
|
2245
2289
|
s = /** @type {AbstractType<any>} */
|
|
2246
2290
|
s._item.parent;
|
|
2247
|
-
|
|
2291
|
+
Cn(n._eH, t, e);
|
|
2248
2292
|
};
|
|
2249
2293
|
class x {
|
|
2250
2294
|
constructor() {
|
|
2251
|
-
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH =
|
|
2295
|
+
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = Os(), this._dEH = Os(), this._searchMarker = null;
|
|
2252
2296
|
}
|
|
2253
2297
|
/**
|
|
2254
2298
|
* @return {AbstractType<any>|null}
|
|
@@ -2314,7 +2358,7 @@ class x {
|
|
|
2314
2358
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2315
2359
|
*/
|
|
2316
2360
|
observe(e) {
|
|
2317
|
-
|
|
2361
|
+
Rs(this._eH, e);
|
|
2318
2362
|
}
|
|
2319
2363
|
/**
|
|
2320
2364
|
* Observe all events that are created by this type and its children.
|
|
@@ -2322,7 +2366,7 @@ class x {
|
|
|
2322
2366
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2323
2367
|
*/
|
|
2324
2368
|
observeDeep(e) {
|
|
2325
|
-
|
|
2369
|
+
Rs(this._dEH, e);
|
|
2326
2370
|
}
|
|
2327
2371
|
/**
|
|
2328
2372
|
* Unregister an observer function.
|
|
@@ -2330,7 +2374,7 @@ class x {
|
|
|
2330
2374
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2331
2375
|
*/
|
|
2332
2376
|
unobserve(e) {
|
|
2333
|
-
|
|
2377
|
+
Bs(this._eH, e);
|
|
2334
2378
|
}
|
|
2335
2379
|
/**
|
|
2336
2380
|
* Unregister an observer function.
|
|
@@ -2338,7 +2382,7 @@ class x {
|
|
|
2338
2382
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2339
2383
|
*/
|
|
2340
2384
|
unobserveDeep(e) {
|
|
2341
|
-
|
|
2385
|
+
Bs(this._dEH, e);
|
|
2342
2386
|
}
|
|
2343
2387
|
/**
|
|
2344
2388
|
* @abstract
|
|
@@ -2347,7 +2391,7 @@ class x {
|
|
|
2347
2391
|
toJSON() {
|
|
2348
2392
|
}
|
|
2349
2393
|
}
|
|
2350
|
-
const
|
|
2394
|
+
const zn = (s, e, t) => {
|
|
2351
2395
|
e < 0 && (e = s._length + e), t < 0 && (t = s._length + t);
|
|
2352
2396
|
let n = t - e;
|
|
2353
2397
|
const i = [];
|
|
@@ -2366,7 +2410,7 @@ const En = (s, e, t) => {
|
|
|
2366
2410
|
r = r.right;
|
|
2367
2411
|
}
|
|
2368
2412
|
return i;
|
|
2369
|
-
},
|
|
2413
|
+
}, Un = (s) => {
|
|
2370
2414
|
const e = [];
|
|
2371
2415
|
let t = s._start;
|
|
2372
2416
|
for (; t !== null; ) {
|
|
@@ -2378,7 +2422,7 @@ const En = (s, e, t) => {
|
|
|
2378
2422
|
t = t.right;
|
|
2379
2423
|
}
|
|
2380
2424
|
return e;
|
|
2381
|
-
},
|
|
2425
|
+
}, Ne = (s, e) => {
|
|
2382
2426
|
let t = 0, n = s._start;
|
|
2383
2427
|
for (; n !== null; ) {
|
|
2384
2428
|
if (n.countable && !n.deleted) {
|
|
@@ -2388,12 +2432,12 @@ const En = (s, e, t) => {
|
|
|
2388
2432
|
}
|
|
2389
2433
|
n = n.right;
|
|
2390
2434
|
}
|
|
2391
|
-
},
|
|
2435
|
+
}, Tn = (s, e) => {
|
|
2392
2436
|
const t = [];
|
|
2393
|
-
return
|
|
2437
|
+
return Ne(s, (n, i) => {
|
|
2394
2438
|
t.push(e(n, i, s));
|
|
2395
2439
|
}), t;
|
|
2396
|
-
},
|
|
2440
|
+
}, bo = (s) => {
|
|
2397
2441
|
let e = s._start, t = null, n = 0;
|
|
2398
2442
|
return {
|
|
2399
2443
|
[Symbol.iterator]() {
|
|
@@ -2417,8 +2461,8 @@ const En = (s, e, t) => {
|
|
|
2417
2461
|
};
|
|
2418
2462
|
}
|
|
2419
2463
|
};
|
|
2420
|
-
},
|
|
2421
|
-
const t =
|
|
2464
|
+
}, On = (s, e) => {
|
|
2465
|
+
const t = wt(s, e);
|
|
2422
2466
|
let n = s._start;
|
|
2423
2467
|
for (t !== null && (n = t.p, e -= t.index); n !== null; n = n.right)
|
|
2424
2468
|
if (!n.deleted && n.countable) {
|
|
@@ -2426,12 +2470,12 @@ const En = (s, e, t) => {
|
|
|
2426
2470
|
return n.content.getContent()[e];
|
|
2427
2471
|
e -= n.length;
|
|
2428
2472
|
}
|
|
2429
|
-
},
|
|
2473
|
+
}, at = (s, e, t, n) => {
|
|
2430
2474
|
let i = t;
|
|
2431
2475
|
const r = s.doc, o = r.clientID, a = r.store, c = t === null ? e._start : t.right;
|
|
2432
2476
|
let l = [];
|
|
2433
2477
|
const h = () => {
|
|
2434
|
-
l.length > 0 && (i = new E(w(o, A(a, o)), i, i && i.lastId, c, c && c.id, e, null, new
|
|
2478
|
+
l.length > 0 && (i = new E(w(o, A(a, o)), i, i && i.lastId, c, c && c.id, e, null, new fe(l)), i.integrate(s, 0), l = []);
|
|
2435
2479
|
};
|
|
2436
2480
|
n.forEach((u) => {
|
|
2437
2481
|
if (u === null)
|
|
@@ -2449,12 +2493,12 @@ const En = (s, e, t) => {
|
|
|
2449
2493
|
switch (h(), u.constructor) {
|
|
2450
2494
|
case Uint8Array:
|
|
2451
2495
|
case ArrayBuffer:
|
|
2452
|
-
i = new E(w(o, A(a, o)), i, i && i.lastId, c, c && c.id, e, null, new
|
|
2496
|
+
i = new E(w(o, A(a, o)), i, i && i.lastId, c, c && c.id, e, null, new Ke(new Uint8Array(
|
|
2453
2497
|
/** @type {Uint8Array} */
|
|
2454
2498
|
u
|
|
2455
2499
|
))), i.integrate(s, 0);
|
|
2456
2500
|
break;
|
|
2457
|
-
case
|
|
2501
|
+
case pe:
|
|
2458
2502
|
i = new E(w(o, A(a, o)), i, i && i.lastId, c, c && c.id, e, null, new Ye(
|
|
2459
2503
|
/** @type {Doc} */
|
|
2460
2504
|
u
|
|
@@ -2468,12 +2512,12 @@ const En = (s, e, t) => {
|
|
|
2468
2512
|
}
|
|
2469
2513
|
}
|
|
2470
2514
|
}), h();
|
|
2471
|
-
},
|
|
2515
|
+
}, Rn = () => J("Length exceeded!"), Bn = (s, e, t, n) => {
|
|
2472
2516
|
if (t > e._length)
|
|
2473
|
-
throw
|
|
2517
|
+
throw Rn();
|
|
2474
2518
|
if (t === 0)
|
|
2475
|
-
return e._searchMarker &&
|
|
2476
|
-
const i = t, r =
|
|
2519
|
+
return e._searchMarker && Be(e._searchMarker, t, n.length), at(s, e, null, n);
|
|
2520
|
+
const i = t, r = wt(e, t);
|
|
2477
2521
|
let o = e._start;
|
|
2478
2522
|
for (r !== null && (o = r.p, t -= r.index, t === 0 && (o = o.prev, t += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
|
|
2479
2523
|
if (!o.deleted && o.countable) {
|
|
@@ -2483,38 +2527,38 @@ const En = (s, e, t) => {
|
|
|
2483
2527
|
}
|
|
2484
2528
|
t -= o.length;
|
|
2485
2529
|
}
|
|
2486
|
-
return e._searchMarker &&
|
|
2487
|
-
},
|
|
2530
|
+
return e._searchMarker && Be(e._searchMarker, i, n.length), at(s, e, o, n);
|
|
2531
|
+
}, wo = (s, e, t) => {
|
|
2488
2532
|
let i = (e._searchMarker || []).reduce((r, o) => o.index > r.index ? o : r, { index: 0, p: e._start }).p;
|
|
2489
2533
|
if (i)
|
|
2490
2534
|
for (; i.right; )
|
|
2491
2535
|
i = i.right;
|
|
2492
|
-
return
|
|
2493
|
-
},
|
|
2536
|
+
return at(s, e, i, t);
|
|
2537
|
+
}, Nn = (s, e, t, n) => {
|
|
2494
2538
|
if (n === 0)
|
|
2495
2539
|
return;
|
|
2496
|
-
const i = t, r = n, o =
|
|
2540
|
+
const i = t, r = n, o = wt(e, t);
|
|
2497
2541
|
let a = e._start;
|
|
2498
2542
|
for (o !== null && (a = o.p, t -= o.index); a !== null && t > 0; a = a.right)
|
|
2499
2543
|
!a.deleted && a.countable && (t < a.length && se(s, w(a.id.client, a.id.clock + t)), t -= a.length);
|
|
2500
2544
|
for (; n > 0 && a !== null; )
|
|
2501
2545
|
a.deleted || (n < a.length && se(s, w(a.id.client, a.id.clock + n)), a.delete(s), n -= a.length), a = a.right;
|
|
2502
2546
|
if (n > 0)
|
|
2503
|
-
throw
|
|
2504
|
-
e._searchMarker &&
|
|
2547
|
+
throw Rn();
|
|
2548
|
+
e._searchMarker && Be(
|
|
2505
2549
|
e._searchMarker,
|
|
2506
2550
|
i,
|
|
2507
2551
|
-r + n
|
|
2508
2552
|
/* in case we remove the above exception */
|
|
2509
2553
|
);
|
|
2510
|
-
},
|
|
2554
|
+
}, ct = (s, e, t) => {
|
|
2511
2555
|
const n = e._map.get(t);
|
|
2512
2556
|
n !== void 0 && n.delete(s);
|
|
2513
|
-
},
|
|
2557
|
+
}, ds = (s, e, t, n) => {
|
|
2514
2558
|
const i = e._map.get(t) || null, r = s.doc, o = r.clientID;
|
|
2515
2559
|
let a;
|
|
2516
2560
|
if (n == null)
|
|
2517
|
-
a = new
|
|
2561
|
+
a = new fe([n]);
|
|
2518
2562
|
else
|
|
2519
2563
|
switch (n.constructor) {
|
|
2520
2564
|
case Number:
|
|
@@ -2522,15 +2566,15 @@ const En = (s, e, t) => {
|
|
|
2522
2566
|
case Boolean:
|
|
2523
2567
|
case Array:
|
|
2524
2568
|
case String:
|
|
2525
|
-
a = new
|
|
2569
|
+
a = new fe([n]);
|
|
2526
2570
|
break;
|
|
2527
2571
|
case Uint8Array:
|
|
2528
|
-
a = new
|
|
2572
|
+
a = new Ke(
|
|
2529
2573
|
/** @type {Uint8Array} */
|
|
2530
2574
|
n
|
|
2531
2575
|
);
|
|
2532
2576
|
break;
|
|
2533
|
-
case
|
|
2577
|
+
case pe:
|
|
2534
2578
|
a = new Ye(
|
|
2535
2579
|
/** @type {Doc} */
|
|
2536
2580
|
n
|
|
@@ -2543,23 +2587,23 @@ const En = (s, e, t) => {
|
|
|
2543
2587
|
throw new Error("Unexpected content type");
|
|
2544
2588
|
}
|
|
2545
2589
|
new E(w(o, A(r.store, o)), i, i && i.lastId, null, null, e, t, a).integrate(s, 0);
|
|
2546
|
-
},
|
|
2590
|
+
}, fs = (s, e) => {
|
|
2547
2591
|
const t = s._map.get(e);
|
|
2548
2592
|
return t !== void 0 && !t.deleted ? t.content.getContent()[t.length - 1] : void 0;
|
|
2549
|
-
},
|
|
2593
|
+
}, Fn = (s) => {
|
|
2550
2594
|
const e = {};
|
|
2551
2595
|
return s._map.forEach((t, n) => {
|
|
2552
2596
|
t.deleted || (e[n] = t.content.getContent()[t.length - 1]);
|
|
2553
2597
|
}), e;
|
|
2554
|
-
},
|
|
2598
|
+
}, Hn = (s, e) => {
|
|
2555
2599
|
const t = s._map.get(e);
|
|
2556
2600
|
return t !== void 0 && !t.deleted;
|
|
2557
|
-
},
|
|
2601
|
+
}, Pe = (s) => Rr(
|
|
2558
2602
|
s.entries(),
|
|
2559
2603
|
/** @param {any} entry */
|
|
2560
2604
|
(e) => !e[1].deleted
|
|
2561
2605
|
);
|
|
2562
|
-
class
|
|
2606
|
+
class yo extends bt {
|
|
2563
2607
|
/**
|
|
2564
2608
|
* @param {YArray<T>} yarray The changed type
|
|
2565
2609
|
* @param {Transaction} transaction The transaction object
|
|
@@ -2568,7 +2612,7 @@ class co extends pt {
|
|
|
2568
2612
|
super(e, t), this._transaction = t;
|
|
2569
2613
|
}
|
|
2570
2614
|
}
|
|
2571
|
-
class
|
|
2615
|
+
class ye extends x {
|
|
2572
2616
|
constructor() {
|
|
2573
2617
|
super(), this._prelimContent = [], this._searchMarker = [];
|
|
2574
2618
|
}
|
|
@@ -2579,7 +2623,7 @@ class we extends x {
|
|
|
2579
2623
|
* @return {YArray<T>}
|
|
2580
2624
|
*/
|
|
2581
2625
|
static from(e) {
|
|
2582
|
-
const t = new
|
|
2626
|
+
const t = new ye();
|
|
2583
2627
|
return t.push(e), t;
|
|
2584
2628
|
}
|
|
2585
2629
|
/**
|
|
@@ -2603,13 +2647,13 @@ class we extends x {
|
|
|
2603
2647
|
* @return {YArray<T>}
|
|
2604
2648
|
*/
|
|
2605
2649
|
_copy() {
|
|
2606
|
-
return new
|
|
2650
|
+
return new ye();
|
|
2607
2651
|
}
|
|
2608
2652
|
/**
|
|
2609
2653
|
* @return {YArray<T>}
|
|
2610
2654
|
*/
|
|
2611
2655
|
clone() {
|
|
2612
|
-
const e = new
|
|
2656
|
+
const e = new ye();
|
|
2613
2657
|
return e.insert(0, this.toArray().map(
|
|
2614
2658
|
(t) => t instanceof x ? (
|
|
2615
2659
|
/** @type {typeof el} */
|
|
@@ -2627,7 +2671,7 @@ class we extends x {
|
|
|
2627
2671
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2628
2672
|
*/
|
|
2629
2673
|
_callObserver(e, t) {
|
|
2630
|
-
super._callObserver(e, t),
|
|
2674
|
+
super._callObserver(e, t), yt(this, e, new yo(this, e));
|
|
2631
2675
|
}
|
|
2632
2676
|
/**
|
|
2633
2677
|
* Inserts new content at an index.
|
|
@@ -2647,7 +2691,7 @@ class we extends x {
|
|
|
2647
2691
|
*/
|
|
2648
2692
|
insert(e, t) {
|
|
2649
2693
|
this.doc !== null ? y(this.doc, (n) => {
|
|
2650
|
-
|
|
2694
|
+
Bn(
|
|
2651
2695
|
n,
|
|
2652
2696
|
this,
|
|
2653
2697
|
e,
|
|
@@ -2665,7 +2709,7 @@ class we extends x {
|
|
|
2665
2709
|
*/
|
|
2666
2710
|
push(e) {
|
|
2667
2711
|
this.doc !== null ? y(this.doc, (t) => {
|
|
2668
|
-
|
|
2712
|
+
wo(
|
|
2669
2713
|
t,
|
|
2670
2714
|
this,
|
|
2671
2715
|
/** @type {any} */
|
|
@@ -2689,7 +2733,7 @@ class we extends x {
|
|
|
2689
2733
|
*/
|
|
2690
2734
|
delete(e, t = 1) {
|
|
2691
2735
|
this.doc !== null ? y(this.doc, (n) => {
|
|
2692
|
-
|
|
2736
|
+
Nn(n, this, e, t);
|
|
2693
2737
|
}) : this._prelimContent.splice(e, t);
|
|
2694
2738
|
}
|
|
2695
2739
|
/**
|
|
@@ -2699,7 +2743,7 @@ class we extends x {
|
|
|
2699
2743
|
* @return {T}
|
|
2700
2744
|
*/
|
|
2701
2745
|
get(e) {
|
|
2702
|
-
return
|
|
2746
|
+
return On(this, e);
|
|
2703
2747
|
}
|
|
2704
2748
|
/**
|
|
2705
2749
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2707,7 +2751,7 @@ class we extends x {
|
|
|
2707
2751
|
* @return {Array<T>}
|
|
2708
2752
|
*/
|
|
2709
2753
|
toArray() {
|
|
2710
|
-
return
|
|
2754
|
+
return Un(this);
|
|
2711
2755
|
}
|
|
2712
2756
|
/**
|
|
2713
2757
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2717,7 +2761,7 @@ class we extends x {
|
|
|
2717
2761
|
* @return {Array<T>}
|
|
2718
2762
|
*/
|
|
2719
2763
|
slice(e = 0, t = this.length) {
|
|
2720
|
-
return
|
|
2764
|
+
return zn(this, e, t);
|
|
2721
2765
|
}
|
|
2722
2766
|
/**
|
|
2723
2767
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -2737,7 +2781,7 @@ class we extends x {
|
|
|
2737
2781
|
* callback function
|
|
2738
2782
|
*/
|
|
2739
2783
|
map(e) {
|
|
2740
|
-
return
|
|
2784
|
+
return Tn(
|
|
2741
2785
|
this,
|
|
2742
2786
|
/** @type {any} */
|
|
2743
2787
|
e
|
|
@@ -2749,23 +2793,23 @@ class we extends x {
|
|
|
2749
2793
|
* @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
|
|
2750
2794
|
*/
|
|
2751
2795
|
forEach(e) {
|
|
2752
|
-
|
|
2796
|
+
Ne(this, e);
|
|
2753
2797
|
}
|
|
2754
2798
|
/**
|
|
2755
2799
|
* @return {IterableIterator<T>}
|
|
2756
2800
|
*/
|
|
2757
2801
|
[Symbol.iterator]() {
|
|
2758
|
-
return
|
|
2802
|
+
return bo(this);
|
|
2759
2803
|
}
|
|
2760
2804
|
/**
|
|
2761
2805
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2762
2806
|
*/
|
|
2763
2807
|
_write(e) {
|
|
2764
|
-
e.writeTypeRef(
|
|
2808
|
+
e.writeTypeRef(qo);
|
|
2765
2809
|
}
|
|
2766
2810
|
}
|
|
2767
|
-
const
|
|
2768
|
-
class
|
|
2811
|
+
const So = (s) => new ye();
|
|
2812
|
+
class _o extends bt {
|
|
2769
2813
|
/**
|
|
2770
2814
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
2771
2815
|
* @param {Transaction} transaction
|
|
@@ -2775,7 +2819,7 @@ class ho extends pt {
|
|
|
2775
2819
|
super(e, t), this.keysChanged = n;
|
|
2776
2820
|
}
|
|
2777
2821
|
}
|
|
2778
|
-
class
|
|
2822
|
+
class ue extends x {
|
|
2779
2823
|
/**
|
|
2780
2824
|
*
|
|
2781
2825
|
* @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
|
|
@@ -2802,13 +2846,13 @@ class he extends x {
|
|
|
2802
2846
|
* @return {YMap<MapType>}
|
|
2803
2847
|
*/
|
|
2804
2848
|
_copy() {
|
|
2805
|
-
return new
|
|
2849
|
+
return new ue();
|
|
2806
2850
|
}
|
|
2807
2851
|
/**
|
|
2808
2852
|
* @return {YMap<MapType>}
|
|
2809
2853
|
*/
|
|
2810
2854
|
clone() {
|
|
2811
|
-
const e = new
|
|
2855
|
+
const e = new ue();
|
|
2812
2856
|
return this.forEach((t, n) => {
|
|
2813
2857
|
e.set(n, t instanceof x ? (
|
|
2814
2858
|
/** @type {typeof value} */
|
|
@@ -2823,7 +2867,7 @@ class he extends x {
|
|
|
2823
2867
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2824
2868
|
*/
|
|
2825
2869
|
_callObserver(e, t) {
|
|
2826
|
-
|
|
2870
|
+
yt(this, e, new _o(this, e, t));
|
|
2827
2871
|
}
|
|
2828
2872
|
/**
|
|
2829
2873
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -2845,7 +2889,7 @@ class he extends x {
|
|
|
2845
2889
|
* @return {number}
|
|
2846
2890
|
*/
|
|
2847
2891
|
get size() {
|
|
2848
|
-
return [...
|
|
2892
|
+
return [...Pe(this._map)].length;
|
|
2849
2893
|
}
|
|
2850
2894
|
/**
|
|
2851
2895
|
* Returns the keys for each element in the YMap Type.
|
|
@@ -2853,8 +2897,8 @@ class he extends x {
|
|
|
2853
2897
|
* @return {IterableIterator<string>}
|
|
2854
2898
|
*/
|
|
2855
2899
|
keys() {
|
|
2856
|
-
return
|
|
2857
|
-
|
|
2900
|
+
return At(
|
|
2901
|
+
Pe(this._map),
|
|
2858
2902
|
/** @param {any} v */
|
|
2859
2903
|
(e) => e[0]
|
|
2860
2904
|
);
|
|
@@ -2865,8 +2909,8 @@ class he extends x {
|
|
|
2865
2909
|
* @return {IterableIterator<any>}
|
|
2866
2910
|
*/
|
|
2867
2911
|
values() {
|
|
2868
|
-
return
|
|
2869
|
-
|
|
2912
|
+
return At(
|
|
2913
|
+
Pe(this._map),
|
|
2870
2914
|
/** @param {any} v */
|
|
2871
2915
|
(e) => e[1].content.getContent()[e[1].length - 1]
|
|
2872
2916
|
);
|
|
@@ -2877,8 +2921,8 @@ class he extends x {
|
|
|
2877
2921
|
* @return {IterableIterator<any>}
|
|
2878
2922
|
*/
|
|
2879
2923
|
entries() {
|
|
2880
|
-
return
|
|
2881
|
-
|
|
2924
|
+
return At(
|
|
2925
|
+
Pe(this._map),
|
|
2882
2926
|
/** @param {any} v */
|
|
2883
2927
|
(e) => [e[0], e[1].content.getContent()[e[1].length - 1]]
|
|
2884
2928
|
);
|
|
@@ -2908,7 +2952,7 @@ class he extends x {
|
|
|
2908
2952
|
*/
|
|
2909
2953
|
delete(e) {
|
|
2910
2954
|
this.doc !== null ? y(this.doc, (t) => {
|
|
2911
|
-
|
|
2955
|
+
ct(t, this, e);
|
|
2912
2956
|
}) : this._prelimContent.delete(e);
|
|
2913
2957
|
}
|
|
2914
2958
|
/**
|
|
@@ -2921,7 +2965,7 @@ class he extends x {
|
|
|
2921
2965
|
*/
|
|
2922
2966
|
set(e, t) {
|
|
2923
2967
|
return this.doc !== null ? y(this.doc, (n) => {
|
|
2924
|
-
|
|
2968
|
+
ds(
|
|
2925
2969
|
n,
|
|
2926
2970
|
this,
|
|
2927
2971
|
e,
|
|
@@ -2939,7 +2983,7 @@ class he extends x {
|
|
|
2939
2983
|
get(e) {
|
|
2940
2984
|
return (
|
|
2941
2985
|
/** @type {any} */
|
|
2942
|
-
|
|
2986
|
+
fs(this, e)
|
|
2943
2987
|
);
|
|
2944
2988
|
}
|
|
2945
2989
|
/**
|
|
@@ -2949,7 +2993,7 @@ class he extends x {
|
|
|
2949
2993
|
* @return {boolean}
|
|
2950
2994
|
*/
|
|
2951
2995
|
has(e) {
|
|
2952
|
-
return
|
|
2996
|
+
return Hn(this, e);
|
|
2953
2997
|
}
|
|
2954
2998
|
/**
|
|
2955
2999
|
* Removes all elements from this YMap.
|
|
@@ -2957,7 +3001,7 @@ class he extends x {
|
|
|
2957
3001
|
clear() {
|
|
2958
3002
|
this.doc !== null ? y(this.doc, (e) => {
|
|
2959
3003
|
this.forEach(function(t, n, i) {
|
|
2960
|
-
|
|
3004
|
+
ct(e, i, n);
|
|
2961
3005
|
});
|
|
2962
3006
|
}) : this._prelimContent.clear();
|
|
2963
3007
|
}
|
|
@@ -2965,11 +3009,11 @@ class he extends x {
|
|
|
2965
3009
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2966
3010
|
*/
|
|
2967
3011
|
_write(e) {
|
|
2968
|
-
e.writeTypeRef(
|
|
3012
|
+
e.writeTypeRef(Ko);
|
|
2969
3013
|
}
|
|
2970
3014
|
}
|
|
2971
|
-
const
|
|
2972
|
-
class
|
|
3015
|
+
const Do = (s) => new ue(), Q = (s, e) => s === e || typeof s == "object" && typeof e == "object" && s && e && Fi(s, e);
|
|
3016
|
+
class $t {
|
|
2973
3017
|
/**
|
|
2974
3018
|
* @param {Item|null} left
|
|
2975
3019
|
* @param {Item|null} right
|
|
@@ -2985,7 +3029,7 @@ class Ft {
|
|
|
2985
3029
|
forward() {
|
|
2986
3030
|
switch (this.right === null && F(), this.right.content.constructor) {
|
|
2987
3031
|
case C:
|
|
2988
|
-
this.right.deleted ||
|
|
3032
|
+
this.right.deleted || xe(
|
|
2989
3033
|
this.currentAttributes,
|
|
2990
3034
|
/** @type {ContentFormat} */
|
|
2991
3035
|
this.right.content
|
|
@@ -2998,11 +3042,11 @@ class Ft {
|
|
|
2998
3042
|
this.left = this.right, this.right = this.right.right;
|
|
2999
3043
|
}
|
|
3000
3044
|
}
|
|
3001
|
-
const
|
|
3045
|
+
const $s = (s, e, t) => {
|
|
3002
3046
|
for (; e.right !== null && t > 0; ) {
|
|
3003
3047
|
switch (e.right.content.constructor) {
|
|
3004
3048
|
case C:
|
|
3005
|
-
e.right.deleted ||
|
|
3049
|
+
e.right.deleted || xe(
|
|
3006
3050
|
e.currentAttributes,
|
|
3007
3051
|
/** @type {ContentFormat} */
|
|
3008
3052
|
e.right.content
|
|
@@ -3015,17 +3059,17 @@ const Ts = (s, e, t) => {
|
|
|
3015
3059
|
e.left = e.right, e.right = e.right.right;
|
|
3016
3060
|
}
|
|
3017
3061
|
return e;
|
|
3018
|
-
},
|
|
3019
|
-
const n = /* @__PURE__ */ new Map(), i =
|
|
3062
|
+
}, Ze = (s, e, t) => {
|
|
3063
|
+
const n = /* @__PURE__ */ new Map(), i = wt(e, t);
|
|
3020
3064
|
if (i) {
|
|
3021
|
-
const r = new
|
|
3022
|
-
return
|
|
3065
|
+
const r = new $t(i.p.left, i.p, i.index, n);
|
|
3066
|
+
return $s(s, r, t - i.index);
|
|
3023
3067
|
} else {
|
|
3024
|
-
const r = new
|
|
3025
|
-
return
|
|
3068
|
+
const r = new $t(null, e._start, 0, n);
|
|
3069
|
+
return $s(s, r, t);
|
|
3026
3070
|
}
|
|
3027
|
-
},
|
|
3028
|
-
for (; t.right !== null && (t.right.deleted === !0 || t.right.content.constructor === C &&
|
|
3071
|
+
}, Vn = (s, e, t, n) => {
|
|
3072
|
+
for (; t.right !== null && (t.right.deleted === !0 || t.right.content.constructor === C && Q(
|
|
3029
3073
|
n.get(
|
|
3030
3074
|
/** @type {ContentFormat} */
|
|
3031
3075
|
t.right.content.key
|
|
@@ -3042,12 +3086,12 @@ const Ts = (s, e, t) => {
|
|
|
3042
3086
|
const c = t.left, l = t.right, h = new E(w(r, A(i.store, r)), c, c && c.lastId, l, l && l.id, e, null, new C(a, o));
|
|
3043
3087
|
h.integrate(s, 0), t.right = h, t.forward();
|
|
3044
3088
|
});
|
|
3045
|
-
},
|
|
3089
|
+
}, xe = (s, e) => {
|
|
3046
3090
|
const { key: t, value: n } = e;
|
|
3047
3091
|
n === null ? s.delete(t) : s.set(t, n);
|
|
3048
|
-
},
|
|
3092
|
+
}, $n = (s, e) => {
|
|
3049
3093
|
for (; s.right !== null; ) {
|
|
3050
|
-
if (!(s.right.deleted || s.right.content.constructor === C &&
|
|
3094
|
+
if (!(s.right.deleted || s.right.content.constructor === C && Q(
|
|
3051
3095
|
e[
|
|
3052
3096
|
/** @type {ContentFormat} */
|
|
3053
3097
|
s.right.content.key
|
|
@@ -3058,33 +3102,33 @@ const Ts = (s, e, t) => {
|
|
|
3058
3102
|
break;
|
|
3059
3103
|
s.forward();
|
|
3060
3104
|
}
|
|
3061
|
-
},
|
|
3105
|
+
}, qn = (s, e, t, n) => {
|
|
3062
3106
|
const i = s.doc, r = i.clientID, o = /* @__PURE__ */ new Map();
|
|
3063
3107
|
for (const a in n) {
|
|
3064
3108
|
const c = n[a], l = t.currentAttributes.get(a) || null;
|
|
3065
|
-
if (!
|
|
3109
|
+
if (!Q(l, c)) {
|
|
3066
3110
|
o.set(a, l);
|
|
3067
3111
|
const { left: h, right: u } = t;
|
|
3068
3112
|
t.right = new E(w(r, A(i.store, r)), h, h && h.lastId, u, u && u.id, e, null, new C(a, c)), t.right.integrate(s, 0), t.forward();
|
|
3069
3113
|
}
|
|
3070
3114
|
}
|
|
3071
3115
|
return o;
|
|
3072
|
-
},
|
|
3116
|
+
}, Lt = (s, e, t, n, i) => {
|
|
3073
3117
|
t.currentAttributes.forEach((d, f) => {
|
|
3074
3118
|
i[f] === void 0 && (i[f] = null);
|
|
3075
3119
|
});
|
|
3076
3120
|
const r = s.doc, o = r.clientID;
|
|
3077
|
-
|
|
3078
|
-
const a =
|
|
3121
|
+
$n(t, i);
|
|
3122
|
+
const a = qn(s, e, t, i), c = n.constructor === String ? new V(
|
|
3079
3123
|
/** @type {string} */
|
|
3080
3124
|
n
|
|
3081
|
-
) : n instanceof x ? new P(n) : new
|
|
3125
|
+
) : n instanceof x ? new P(n) : new ke(n);
|
|
3082
3126
|
let { left: l, right: h, index: u } = t;
|
|
3083
|
-
e._searchMarker &&
|
|
3084
|
-
},
|
|
3127
|
+
e._searchMarker && Be(e._searchMarker, t.index, c.getLength()), h = new E(w(o, A(r.store, o)), l, l && l.lastId, h, h && h.id, e, null, c), h.integrate(s, 0), t.right = h, t.index = u, t.forward(), Vn(s, e, t, a);
|
|
3128
|
+
}, qs = (s, e, t, n, i) => {
|
|
3085
3129
|
const r = s.doc, o = r.clientID;
|
|
3086
|
-
|
|
3087
|
-
const a =
|
|
3130
|
+
$n(t, i);
|
|
3131
|
+
const a = qn(s, e, t, i);
|
|
3088
3132
|
e:
|
|
3089
3133
|
for (; t.right !== null && (n > 0 || a.size > 0 && (t.right.deleted || t.right.content.constructor === C)); ) {
|
|
3090
3134
|
if (!t.right.deleted)
|
|
@@ -3095,7 +3139,7 @@ const Ts = (s, e, t) => {
|
|
|
3095
3139
|
t.right.content
|
|
3096
3140
|
), h = i[c];
|
|
3097
3141
|
if (h !== void 0) {
|
|
3098
|
-
if (
|
|
3142
|
+
if (Q(h, l))
|
|
3099
3143
|
a.delete(c);
|
|
3100
3144
|
else {
|
|
3101
3145
|
if (n === 0)
|
|
@@ -3120,8 +3164,8 @@ const Ts = (s, e, t) => {
|
|
|
3120
3164
|
`;
|
|
3121
3165
|
t.right = new E(w(o, A(r.store, o)), t.left, t.left && t.left.lastId, t.right, t.right && t.right.id, e, null, new V(c)), t.right.integrate(s, 0), t.forward();
|
|
3122
3166
|
}
|
|
3123
|
-
|
|
3124
|
-
},
|
|
3167
|
+
Vn(s, e, t, a);
|
|
3168
|
+
}, Kn = (s, e, t, n, i) => {
|
|
3125
3169
|
let r = e;
|
|
3126
3170
|
const o = T();
|
|
3127
3171
|
for (; r && (!r.countable || r.deleted); ) {
|
|
@@ -3144,7 +3188,7 @@ const Ts = (s, e, t) => {
|
|
|
3144
3188
|
/** @type {ContentFormat} */
|
|
3145
3189
|
l
|
|
3146
3190
|
), d = n.get(h) || null;
|
|
3147
|
-
(o.get(h) !== l || d === u) && (e.delete(s), a++, !c && (i.get(h) || null) === u && d !== u && (d === null ? i.delete(h) : i.set(h, d))), !c && !e.deleted &&
|
|
3191
|
+
(o.get(h) !== l || d === u) && (e.delete(s), a++, !c && (i.get(h) || null) === u && d !== u && (d === null ? i.delete(h) : i.set(h, d))), !c && !e.deleted && xe(
|
|
3148
3192
|
i,
|
|
3149
3193
|
/** @type {ContentFormat} */
|
|
3150
3194
|
l
|
|
@@ -3157,7 +3201,7 @@ const Ts = (s, e, t) => {
|
|
|
3157
3201
|
e.right;
|
|
3158
3202
|
}
|
|
3159
3203
|
return a;
|
|
3160
|
-
},
|
|
3204
|
+
}, Eo = (s, e) => {
|
|
3161
3205
|
for (; e && e.right && (e.right.deleted || !e.right.countable); )
|
|
3162
3206
|
e = e.right;
|
|
3163
3207
|
const t = /* @__PURE__ */ new Set();
|
|
@@ -3171,7 +3215,7 @@ const Ts = (s, e, t) => {
|
|
|
3171
3215
|
}
|
|
3172
3216
|
e = e.left;
|
|
3173
3217
|
}
|
|
3174
|
-
},
|
|
3218
|
+
}, Co = (s) => {
|
|
3175
3219
|
let e = 0;
|
|
3176
3220
|
return y(
|
|
3177
3221
|
/** @type {Doc} */
|
|
@@ -3181,30 +3225,30 @@ const Ts = (s, e, t) => {
|
|
|
3181
3225
|
/** @type {Item} */
|
|
3182
3226
|
s._start
|
|
3183
3227
|
), i = s._start, r = T();
|
|
3184
|
-
const o =
|
|
3228
|
+
const o = Tt(r);
|
|
3185
3229
|
for (; i; ) {
|
|
3186
3230
|
if (i.deleted === !1)
|
|
3187
3231
|
switch (i.content.constructor) {
|
|
3188
3232
|
case C:
|
|
3189
|
-
|
|
3233
|
+
xe(
|
|
3190
3234
|
o,
|
|
3191
3235
|
/** @type {ContentFormat} */
|
|
3192
3236
|
i.content
|
|
3193
3237
|
);
|
|
3194
3238
|
break;
|
|
3195
3239
|
default:
|
|
3196
|
-
e +=
|
|
3240
|
+
e += Kn(t, n, i, r, o), r = Tt(o), n = i;
|
|
3197
3241
|
break;
|
|
3198
3242
|
}
|
|
3199
3243
|
i = i.right;
|
|
3200
3244
|
}
|
|
3201
3245
|
}
|
|
3202
3246
|
), e;
|
|
3203
|
-
},
|
|
3247
|
+
}, vo = (s) => {
|
|
3204
3248
|
const e = /* @__PURE__ */ new Set(), t = s.doc;
|
|
3205
3249
|
for (const [n, i] of s.afterState.entries()) {
|
|
3206
3250
|
const r = s.beforeState.get(n) || 0;
|
|
3207
|
-
i !== r &&
|
|
3251
|
+
i !== r && xn(
|
|
3208
3252
|
s,
|
|
3209
3253
|
/** @type {Array<Item|GC>} */
|
|
3210
3254
|
t.store.clients.get(n),
|
|
@@ -3212,7 +3256,7 @@ const Ts = (s, e, t) => {
|
|
|
3212
3256
|
i,
|
|
3213
3257
|
(o) => {
|
|
3214
3258
|
!o.deleted && /** @type {Item} */
|
|
3215
|
-
o.content.constructor === C && o.constructor !==
|
|
3259
|
+
o.content.constructor === C && o.constructor !== z && e.add(
|
|
3216
3260
|
/** @type {any} */
|
|
3217
3261
|
o.parent
|
|
3218
3262
|
);
|
|
@@ -3220,8 +3264,8 @@ const Ts = (s, e, t) => {
|
|
|
3220
3264
|
);
|
|
3221
3265
|
}
|
|
3222
3266
|
y(t, (n) => {
|
|
3223
|
-
|
|
3224
|
-
if (i instanceof
|
|
3267
|
+
gn(s, s.deleteSet, (i) => {
|
|
3268
|
+
if (i instanceof z || !/** @type {YText} */
|
|
3225
3269
|
i.parent._hasFormatting || e.has(
|
|
3226
3270
|
/** @type {YText} */
|
|
3227
3271
|
i.parent
|
|
@@ -3231,33 +3275,33 @@ const Ts = (s, e, t) => {
|
|
|
3231
3275
|
/** @type {YText} */
|
|
3232
3276
|
i.parent
|
|
3233
3277
|
);
|
|
3234
|
-
i.content.constructor === C ? e.add(r) :
|
|
3278
|
+
i.content.constructor === C ? e.add(r) : Eo(n, i);
|
|
3235
3279
|
});
|
|
3236
3280
|
for (const i of e)
|
|
3237
|
-
|
|
3281
|
+
Co(i);
|
|
3238
3282
|
});
|
|
3239
|
-
},
|
|
3240
|
-
const n = t, i =
|
|
3283
|
+
}, Ks = (s, e, t) => {
|
|
3284
|
+
const n = t, i = Tt(e.currentAttributes), r = e.right;
|
|
3241
3285
|
for (; t > 0 && e.right !== null; ) {
|
|
3242
3286
|
if (e.right.deleted === !1)
|
|
3243
3287
|
switch (e.right.content.constructor) {
|
|
3244
3288
|
case P:
|
|
3245
|
-
case
|
|
3289
|
+
case ke:
|
|
3246
3290
|
case V:
|
|
3247
3291
|
t < e.right.length && se(s, w(e.right.id.client, e.right.id.clock + t)), t -= e.right.length, e.right.delete(s);
|
|
3248
3292
|
break;
|
|
3249
3293
|
}
|
|
3250
3294
|
e.forward();
|
|
3251
3295
|
}
|
|
3252
|
-
r &&
|
|
3296
|
+
r && Kn(s, r, e.right, i, e.currentAttributes);
|
|
3253
3297
|
const o = (
|
|
3254
3298
|
/** @type {AbstractType<any>} */
|
|
3255
3299
|
/** @type {Item} */
|
|
3256
3300
|
(e.left || e.right).parent
|
|
3257
3301
|
);
|
|
3258
|
-
return o._searchMarker &&
|
|
3302
|
+
return o._searchMarker && Be(o._searchMarker, e.index, -n + t), e;
|
|
3259
3303
|
};
|
|
3260
|
-
class
|
|
3304
|
+
class Ao extends bt {
|
|
3261
3305
|
/**
|
|
3262
3306
|
* @param {YText} ytext
|
|
3263
3307
|
* @param {Transaction} transaction
|
|
@@ -3318,7 +3362,7 @@ class ko extends pt {
|
|
|
3318
3362
|
}))), l = "";
|
|
3319
3363
|
break;
|
|
3320
3364
|
case "retain":
|
|
3321
|
-
h > 0 && (f = { retain: h },
|
|
3365
|
+
h > 0 && (f = { retain: h }, Bi(c) || (f.attributes = Ui({}, c))), h = 0;
|
|
3322
3366
|
break;
|
|
3323
3367
|
}
|
|
3324
3368
|
f && t.push(f), a = null;
|
|
@@ -3327,7 +3371,7 @@ class ko extends pt {
|
|
|
3327
3371
|
for (; o !== null; ) {
|
|
3328
3372
|
switch (o.content.constructor) {
|
|
3329
3373
|
case P:
|
|
3330
|
-
case
|
|
3374
|
+
case ke:
|
|
3331
3375
|
this.adds(o) ? this.deletes(o) || (d(), a = "insert", l = o.content.getContent()[0], d()) : this.deletes(o) ? (a !== "delete" && (d(), a = "delete"), u += 1) : o.deleted || (a !== "retain" && (d(), a = "retain"), h += 1);
|
|
3332
3376
|
break;
|
|
3333
3377
|
case V:
|
|
@@ -3342,18 +3386,18 @@ class ko extends pt {
|
|
|
3342
3386
|
if (this.adds(o)) {
|
|
3343
3387
|
if (!this.deletes(o)) {
|
|
3344
3388
|
const k = i.get(f) || null;
|
|
3345
|
-
|
|
3389
|
+
Q(k, g) ? g !== null && o.delete(n) : (a === "retain" && d(), Q(g, r.get(f) || null) ? delete c[f] : c[f] = g);
|
|
3346
3390
|
}
|
|
3347
3391
|
} else if (this.deletes(o)) {
|
|
3348
3392
|
r.set(f, g);
|
|
3349
3393
|
const k = i.get(f) || null;
|
|
3350
|
-
|
|
3394
|
+
Q(k, g) || (a === "retain" && d(), c[f] = k);
|
|
3351
3395
|
} else if (!o.deleted) {
|
|
3352
3396
|
r.set(f, g);
|
|
3353
3397
|
const k = c[f];
|
|
3354
|
-
k !== void 0 && (
|
|
3398
|
+
k !== void 0 && (Q(k, g) ? k !== null && o.delete(n) : (a === "retain" && d(), g === null ? delete c[f] : c[f] = g));
|
|
3355
3399
|
}
|
|
3356
|
-
o.deleted || (a === "insert" && d(),
|
|
3400
|
+
o.deleted || (a === "insert" && d(), xe(
|
|
3357
3401
|
i,
|
|
3358
3402
|
/** @type {ContentFormat} */
|
|
3359
3403
|
o.content
|
|
@@ -3378,7 +3422,7 @@ class ko extends pt {
|
|
|
3378
3422
|
);
|
|
3379
3423
|
}
|
|
3380
3424
|
}
|
|
3381
|
-
class
|
|
3425
|
+
class ve extends x {
|
|
3382
3426
|
/**
|
|
3383
3427
|
* @param {String} [string] The initial value of the YText.
|
|
3384
3428
|
*/
|
|
@@ -3407,13 +3451,13 @@ class Ce extends x {
|
|
|
3407
3451
|
this._pending = null;
|
|
3408
3452
|
}
|
|
3409
3453
|
_copy() {
|
|
3410
|
-
return new
|
|
3454
|
+
return new ve();
|
|
3411
3455
|
}
|
|
3412
3456
|
/**
|
|
3413
3457
|
* @return {YText}
|
|
3414
3458
|
*/
|
|
3415
3459
|
clone() {
|
|
3416
|
-
const e = new
|
|
3460
|
+
const e = new ve();
|
|
3417
3461
|
return e.applyDelta(this.toDelta()), e;
|
|
3418
3462
|
}
|
|
3419
3463
|
/**
|
|
@@ -3424,8 +3468,8 @@ class Ce extends x {
|
|
|
3424
3468
|
*/
|
|
3425
3469
|
_callObserver(e, t) {
|
|
3426
3470
|
super._callObserver(e, t);
|
|
3427
|
-
const n = new
|
|
3428
|
-
|
|
3471
|
+
const n = new Ao(this, e, t);
|
|
3472
|
+
yt(this, e, n), !e.local && this._hasFormatting && (e._needFormattingCleanup = !0);
|
|
3429
3473
|
}
|
|
3430
3474
|
/**
|
|
3431
3475
|
* Returns the unformatted string representation of this YText type.
|
|
@@ -3460,15 +3504,15 @@ class Ce extends x {
|
|
|
3460
3504
|
*/
|
|
3461
3505
|
applyDelta(e, { sanitize: t = !0 } = {}) {
|
|
3462
3506
|
this.doc !== null ? y(this.doc, (n) => {
|
|
3463
|
-
const i = new
|
|
3507
|
+
const i = new $t(null, this._start, 0, /* @__PURE__ */ new Map());
|
|
3464
3508
|
for (let r = 0; r < e.length; r++) {
|
|
3465
3509
|
const o = e[r];
|
|
3466
3510
|
if (o.insert !== void 0) {
|
|
3467
3511
|
const a = !t && typeof o.insert == "string" && r === e.length - 1 && i.right === null && o.insert.slice(-1) === `
|
|
3468
3512
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3469
|
-
(typeof a != "string" || a.length > 0) &&
|
|
3513
|
+
(typeof a != "string" || a.length > 0) && Lt(n, this, i, a, o.attributes || {});
|
|
3470
3514
|
} else
|
|
3471
|
-
o.retain !== void 0 ?
|
|
3515
|
+
o.retain !== void 0 ? qs(n, this, i, o.retain, o.attributes || {}) : o.delete !== void 0 && Ks(n, i, o.delete);
|
|
3472
3516
|
}
|
|
3473
3517
|
}) : this._pending.push(() => this.applyDelta(e));
|
|
3474
3518
|
}
|
|
@@ -3501,16 +3545,16 @@ class Ce extends x {
|
|
|
3501
3545
|
}
|
|
3502
3546
|
const h = () => {
|
|
3503
3547
|
for (; c !== null; ) {
|
|
3504
|
-
if (
|
|
3548
|
+
if (Le(c, e) || t !== void 0 && Le(c, t))
|
|
3505
3549
|
switch (c.content.constructor) {
|
|
3506
3550
|
case V: {
|
|
3507
3551
|
const u = r.get("ychange");
|
|
3508
|
-
e !== void 0 && !
|
|
3552
|
+
e !== void 0 && !Le(c, e) ? (u === void 0 || u.user !== c.id.client || u.type !== "removed") && (l(), r.set("ychange", n ? n("removed", c.id) : { type: "removed" })) : t !== void 0 && !Le(c, t) ? (u === void 0 || u.user !== c.id.client || u.type !== "added") && (l(), r.set("ychange", n ? n("added", c.id) : { type: "added" })) : u !== void 0 && (l(), r.delete("ychange")), a += /** @type {ContentString} */
|
|
3509
3553
|
c.content.str;
|
|
3510
3554
|
break;
|
|
3511
3555
|
}
|
|
3512
3556
|
case P:
|
|
3513
|
-
case
|
|
3557
|
+
case ke: {
|
|
3514
3558
|
l();
|
|
3515
3559
|
const u = {
|
|
3516
3560
|
insert: c.content.getContent()[0]
|
|
@@ -3528,7 +3572,7 @@ class Ce extends x {
|
|
|
3528
3572
|
break;
|
|
3529
3573
|
}
|
|
3530
3574
|
case C:
|
|
3531
|
-
|
|
3575
|
+
Le(c, e) && (l(), xe(
|
|
3532
3576
|
r,
|
|
3533
3577
|
/** @type {ContentFormat} */
|
|
3534
3578
|
c.content
|
|
@@ -3540,7 +3584,7 @@ class Ce extends x {
|
|
|
3540
3584
|
l();
|
|
3541
3585
|
};
|
|
3542
3586
|
return e || t ? y(o, (u) => {
|
|
3543
|
-
e &&
|
|
3587
|
+
e && Ht(u, e), t && Ht(u, t), h();
|
|
3544
3588
|
}, "cleanup") : h(), i;
|
|
3545
3589
|
}
|
|
3546
3590
|
/**
|
|
@@ -3558,10 +3602,10 @@ class Ce extends x {
|
|
|
3558
3602
|
return;
|
|
3559
3603
|
const i = this.doc;
|
|
3560
3604
|
i !== null ? y(i, (r) => {
|
|
3561
|
-
const o =
|
|
3605
|
+
const o = Ze(r, this, e);
|
|
3562
3606
|
n || (n = {}, o.currentAttributes.forEach((a, c) => {
|
|
3563
3607
|
n[c] = a;
|
|
3564
|
-
})),
|
|
3608
|
+
})), Lt(r, this, o, t, n);
|
|
3565
3609
|
}) : this._pending.push(() => this.insert(e, t, n));
|
|
3566
3610
|
}
|
|
3567
3611
|
/**
|
|
@@ -3577,8 +3621,8 @@ class Ce extends x {
|
|
|
3577
3621
|
insertEmbed(e, t, n = {}) {
|
|
3578
3622
|
const i = this.doc;
|
|
3579
3623
|
i !== null ? y(i, (r) => {
|
|
3580
|
-
const o =
|
|
3581
|
-
|
|
3624
|
+
const o = Ze(r, this, e);
|
|
3625
|
+
Lt(r, this, o, t, n);
|
|
3582
3626
|
}) : this._pending.push(() => this.insertEmbed(e, t, n));
|
|
3583
3627
|
}
|
|
3584
3628
|
/**
|
|
@@ -3594,7 +3638,7 @@ class Ce extends x {
|
|
|
3594
3638
|
return;
|
|
3595
3639
|
const n = this.doc;
|
|
3596
3640
|
n !== null ? y(n, (i) => {
|
|
3597
|
-
|
|
3641
|
+
Ks(i, Ze(i, this, e), t);
|
|
3598
3642
|
}) : this._pending.push(() => this.delete(e, t));
|
|
3599
3643
|
}
|
|
3600
3644
|
/**
|
|
@@ -3612,8 +3656,8 @@ class Ce extends x {
|
|
|
3612
3656
|
return;
|
|
3613
3657
|
const i = this.doc;
|
|
3614
3658
|
i !== null ? y(i, (r) => {
|
|
3615
|
-
const o =
|
|
3616
|
-
o.right !== null &&
|
|
3659
|
+
const o = Ze(r, this, e);
|
|
3660
|
+
o.right !== null && qs(r, this, o, t, n);
|
|
3617
3661
|
}) : this._pending.push(() => this.format(e, t, n));
|
|
3618
3662
|
}
|
|
3619
3663
|
/**
|
|
@@ -3627,7 +3671,7 @@ class Ce extends x {
|
|
|
3627
3671
|
*/
|
|
3628
3672
|
removeAttribute(e) {
|
|
3629
3673
|
this.doc !== null ? y(this.doc, (t) => {
|
|
3630
|
-
|
|
3674
|
+
ct(t, this, e);
|
|
3631
3675
|
}) : this._pending.push(() => this.removeAttribute(e));
|
|
3632
3676
|
}
|
|
3633
3677
|
/**
|
|
@@ -3642,7 +3686,7 @@ class Ce extends x {
|
|
|
3642
3686
|
*/
|
|
3643
3687
|
setAttribute(e, t) {
|
|
3644
3688
|
this.doc !== null ? y(this.doc, (n) => {
|
|
3645
|
-
|
|
3689
|
+
ds(n, this, e, t);
|
|
3646
3690
|
}) : this._pending.push(() => this.setAttribute(e, t));
|
|
3647
3691
|
}
|
|
3648
3692
|
/**
|
|
@@ -3659,7 +3703,7 @@ class Ce extends x {
|
|
|
3659
3703
|
getAttribute(e) {
|
|
3660
3704
|
return (
|
|
3661
3705
|
/** @type {any} */
|
|
3662
|
-
|
|
3706
|
+
fs(this, e)
|
|
3663
3707
|
);
|
|
3664
3708
|
}
|
|
3665
3709
|
/**
|
|
@@ -3672,17 +3716,17 @@ class Ce extends x {
|
|
|
3672
3716
|
* @public
|
|
3673
3717
|
*/
|
|
3674
3718
|
getAttributes() {
|
|
3675
|
-
return
|
|
3719
|
+
return Fn(this);
|
|
3676
3720
|
}
|
|
3677
3721
|
/**
|
|
3678
3722
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3679
3723
|
*/
|
|
3680
3724
|
_write(e) {
|
|
3681
|
-
e.writeTypeRef(
|
|
3725
|
+
e.writeTypeRef(Yo);
|
|
3682
3726
|
}
|
|
3683
3727
|
}
|
|
3684
|
-
const
|
|
3685
|
-
class
|
|
3728
|
+
const xo = (s) => new ve();
|
|
3729
|
+
class It {
|
|
3686
3730
|
/**
|
|
3687
3731
|
* @param {YXmlFragment | YXmlElement} root
|
|
3688
3732
|
* @param {function(AbstractType<any>):boolean} [f]
|
|
@@ -3707,7 +3751,7 @@ class At {
|
|
|
3707
3751
|
if (e !== null && (!this._firstCall || e.deleted || !this._filter(t)))
|
|
3708
3752
|
do
|
|
3709
3753
|
if (t = /** @type {any} */
|
|
3710
|
-
e.content.type, !e.deleted && (t.constructor ===
|
|
3754
|
+
e.content.type, !e.deleted && (t.constructor === Fe || t.constructor === de) && t._start !== null)
|
|
3711
3755
|
e = t._start;
|
|
3712
3756
|
else
|
|
3713
3757
|
for (; e !== null; )
|
|
@@ -3727,7 +3771,7 @@ class At {
|
|
|
3727
3771
|
), done: !1 });
|
|
3728
3772
|
}
|
|
3729
3773
|
}
|
|
3730
|
-
class
|
|
3774
|
+
class de extends x {
|
|
3731
3775
|
constructor() {
|
|
3732
3776
|
super(), this._prelimContent = [];
|
|
3733
3777
|
}
|
|
@@ -3756,13 +3800,13 @@ class ue extends x {
|
|
|
3756
3800
|
), this._prelimContent = null;
|
|
3757
3801
|
}
|
|
3758
3802
|
_copy() {
|
|
3759
|
-
return new
|
|
3803
|
+
return new de();
|
|
3760
3804
|
}
|
|
3761
3805
|
/**
|
|
3762
3806
|
* @return {YXmlFragment}
|
|
3763
3807
|
*/
|
|
3764
3808
|
clone() {
|
|
3765
|
-
const e = new
|
|
3809
|
+
const e = new de();
|
|
3766
3810
|
return e.insert(0, this.toArray().map((t) => t instanceof x ? t.clone() : t)), e;
|
|
3767
3811
|
}
|
|
3768
3812
|
get length() {
|
|
@@ -3786,7 +3830,7 @@ class ue extends x {
|
|
|
3786
3830
|
* @public
|
|
3787
3831
|
*/
|
|
3788
3832
|
createTreeWalker(e) {
|
|
3789
|
-
return new
|
|
3833
|
+
return new It(this, e);
|
|
3790
3834
|
}
|
|
3791
3835
|
/**
|
|
3792
3836
|
* Returns the first YXmlElement that matches the query.
|
|
@@ -3805,7 +3849,7 @@ class ue extends x {
|
|
|
3805
3849
|
*/
|
|
3806
3850
|
querySelector(e) {
|
|
3807
3851
|
e = e.toUpperCase();
|
|
3808
|
-
const n = new
|
|
3852
|
+
const n = new It(this, (i) => i.nodeName && i.nodeName.toUpperCase() === e).next();
|
|
3809
3853
|
return n.done ? null : n.value;
|
|
3810
3854
|
}
|
|
3811
3855
|
/**
|
|
@@ -3820,7 +3864,7 @@ class ue extends x {
|
|
|
3820
3864
|
* @public
|
|
3821
3865
|
*/
|
|
3822
3866
|
querySelectorAll(e) {
|
|
3823
|
-
return e = e.toUpperCase(), te(new
|
|
3867
|
+
return e = e.toUpperCase(), te(new It(this, (t) => t.nodeName && t.nodeName.toUpperCase() === e));
|
|
3824
3868
|
}
|
|
3825
3869
|
/**
|
|
3826
3870
|
* Creates YXmlEvent and calls observers.
|
|
@@ -3829,7 +3873,7 @@ class ue extends x {
|
|
|
3829
3873
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3830
3874
|
*/
|
|
3831
3875
|
_callObserver(e, t) {
|
|
3832
|
-
|
|
3876
|
+
yt(this, e, new jo(this, t, e));
|
|
3833
3877
|
}
|
|
3834
3878
|
/**
|
|
3835
3879
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -3837,7 +3881,7 @@ class ue extends x {
|
|
|
3837
3881
|
* @return {string} The string representation of all children.
|
|
3838
3882
|
*/
|
|
3839
3883
|
toString() {
|
|
3840
|
-
return
|
|
3884
|
+
return Tn(this, (e) => e.toString()).join("");
|
|
3841
3885
|
}
|
|
3842
3886
|
/**
|
|
3843
3887
|
* @return {string}
|
|
@@ -3862,7 +3906,7 @@ class ue extends x {
|
|
|
3862
3906
|
*/
|
|
3863
3907
|
toDOM(e = document, t = {}, n) {
|
|
3864
3908
|
const i = e.createDocumentFragment();
|
|
3865
|
-
return n !== void 0 && n._createAssociation(i, this),
|
|
3909
|
+
return n !== void 0 && n._createAssociation(i, this), Ne(this, (r) => {
|
|
3866
3910
|
i.insertBefore(r.toDOM(e, t, n), null);
|
|
3867
3911
|
}), i;
|
|
3868
3912
|
}
|
|
@@ -3878,7 +3922,7 @@ class ue extends x {
|
|
|
3878
3922
|
*/
|
|
3879
3923
|
insert(e, t) {
|
|
3880
3924
|
this.doc !== null ? y(this.doc, (n) => {
|
|
3881
|
-
|
|
3925
|
+
Bn(n, this, e, t);
|
|
3882
3926
|
}) : this._prelimContent.splice(e, 0, ...t);
|
|
3883
3927
|
}
|
|
3884
3928
|
/**
|
|
@@ -3895,7 +3939,7 @@ class ue extends x {
|
|
|
3895
3939
|
if (this.doc !== null)
|
|
3896
3940
|
y(this.doc, (n) => {
|
|
3897
3941
|
const i = e && e instanceof x ? e._item : e;
|
|
3898
|
-
|
|
3942
|
+
at(n, this, i, t);
|
|
3899
3943
|
});
|
|
3900
3944
|
else {
|
|
3901
3945
|
const n = (
|
|
@@ -3915,7 +3959,7 @@ class ue extends x {
|
|
|
3915
3959
|
*/
|
|
3916
3960
|
delete(e, t = 1) {
|
|
3917
3961
|
this.doc !== null ? y(this.doc, (n) => {
|
|
3918
|
-
|
|
3962
|
+
Nn(n, this, e, t);
|
|
3919
3963
|
}) : this._prelimContent.splice(e, t);
|
|
3920
3964
|
}
|
|
3921
3965
|
/**
|
|
@@ -3924,7 +3968,7 @@ class ue extends x {
|
|
|
3924
3968
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
3925
3969
|
*/
|
|
3926
3970
|
toArray() {
|
|
3927
|
-
return
|
|
3971
|
+
return Un(this);
|
|
3928
3972
|
}
|
|
3929
3973
|
/**
|
|
3930
3974
|
* Appends content to this YArray.
|
|
@@ -3949,7 +3993,7 @@ class ue extends x {
|
|
|
3949
3993
|
* @return {YXmlElement|YXmlText}
|
|
3950
3994
|
*/
|
|
3951
3995
|
get(e) {
|
|
3952
|
-
return
|
|
3996
|
+
return On(this, e);
|
|
3953
3997
|
}
|
|
3954
3998
|
/**
|
|
3955
3999
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -3959,7 +4003,7 @@ class ue extends x {
|
|
|
3959
4003
|
* @return {Array<YXmlElement|YXmlText>}
|
|
3960
4004
|
*/
|
|
3961
4005
|
slice(e = 0, t = this.length) {
|
|
3962
|
-
return
|
|
4006
|
+
return zn(this, e, t);
|
|
3963
4007
|
}
|
|
3964
4008
|
/**
|
|
3965
4009
|
* Executes a provided function on once on overy child element.
|
|
@@ -3967,7 +4011,7 @@ class ue extends x {
|
|
|
3967
4011
|
* @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
|
|
3968
4012
|
*/
|
|
3969
4013
|
forEach(e) {
|
|
3970
|
-
|
|
4014
|
+
Ne(this, e);
|
|
3971
4015
|
}
|
|
3972
4016
|
/**
|
|
3973
4017
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -3978,11 +4022,11 @@ class ue extends x {
|
|
|
3978
4022
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
3979
4023
|
*/
|
|
3980
4024
|
_write(e) {
|
|
3981
|
-
e.writeTypeRef(
|
|
4025
|
+
e.writeTypeRef(Jo);
|
|
3982
4026
|
}
|
|
3983
4027
|
}
|
|
3984
|
-
const
|
|
3985
|
-
class
|
|
4028
|
+
const Lo = (s) => new de();
|
|
4029
|
+
class Fe extends de {
|
|
3986
4030
|
constructor(e = "UNDEFINED") {
|
|
3987
4031
|
super(), this.nodeName = e, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
3988
4032
|
}
|
|
@@ -4030,14 +4074,14 @@ class Ne extends ue {
|
|
|
4030
4074
|
* @return {YXmlElement}
|
|
4031
4075
|
*/
|
|
4032
4076
|
_copy() {
|
|
4033
|
-
return new
|
|
4077
|
+
return new Fe(this.nodeName);
|
|
4034
4078
|
}
|
|
4035
4079
|
/**
|
|
4036
4080
|
* @return {YXmlElement<KV>}
|
|
4037
4081
|
*/
|
|
4038
4082
|
clone() {
|
|
4039
|
-
const e = new
|
|
4040
|
-
return
|
|
4083
|
+
const e = new Fe(this.nodeName), t = this.getAttributes();
|
|
4084
|
+
return Oi(t, (n, i) => {
|
|
4041
4085
|
typeof n == "string" && e.setAttribute(i, n);
|
|
4042
4086
|
}), e.insert(0, this.toArray().map((n) => n instanceof x ? n.clone() : n)), e;
|
|
4043
4087
|
}
|
|
@@ -4072,7 +4116,7 @@ class Ne extends ue {
|
|
|
4072
4116
|
*/
|
|
4073
4117
|
removeAttribute(e) {
|
|
4074
4118
|
this.doc !== null ? y(this.doc, (t) => {
|
|
4075
|
-
|
|
4119
|
+
ct(t, this, e);
|
|
4076
4120
|
}) : this._prelimAttrs.delete(e);
|
|
4077
4121
|
}
|
|
4078
4122
|
/**
|
|
@@ -4087,7 +4131,7 @@ class Ne extends ue {
|
|
|
4087
4131
|
*/
|
|
4088
4132
|
setAttribute(e, t) {
|
|
4089
4133
|
this.doc !== null ? y(this.doc, (n) => {
|
|
4090
|
-
|
|
4134
|
+
ds(n, this, e, t);
|
|
4091
4135
|
}) : this._prelimAttrs.set(e, t);
|
|
4092
4136
|
}
|
|
4093
4137
|
/**
|
|
@@ -4104,7 +4148,7 @@ class Ne extends ue {
|
|
|
4104
4148
|
getAttribute(e) {
|
|
4105
4149
|
return (
|
|
4106
4150
|
/** @type {any} */
|
|
4107
|
-
|
|
4151
|
+
fs(this, e)
|
|
4108
4152
|
);
|
|
4109
4153
|
}
|
|
4110
4154
|
/**
|
|
@@ -4118,7 +4162,7 @@ class Ne extends ue {
|
|
|
4118
4162
|
hasAttribute(e) {
|
|
4119
4163
|
return (
|
|
4120
4164
|
/** @type {any} */
|
|
4121
|
-
|
|
4165
|
+
Hn(this, e)
|
|
4122
4166
|
);
|
|
4123
4167
|
}
|
|
4124
4168
|
/**
|
|
@@ -4131,7 +4175,7 @@ class Ne extends ue {
|
|
|
4131
4175
|
getAttributes() {
|
|
4132
4176
|
return (
|
|
4133
4177
|
/** @type {any} */
|
|
4134
|
-
|
|
4178
|
+
Fn(this)
|
|
4135
4179
|
);
|
|
4136
4180
|
}
|
|
4137
4181
|
/**
|
|
@@ -4155,7 +4199,7 @@ class Ne extends ue {
|
|
|
4155
4199
|
const a = r[o];
|
|
4156
4200
|
typeof a == "string" && i.setAttribute(o, a);
|
|
4157
4201
|
}
|
|
4158
|
-
return
|
|
4202
|
+
return Ne(this, (o) => {
|
|
4159
4203
|
i.appendChild(o.toDOM(e, t, n));
|
|
4160
4204
|
}), n !== void 0 && n._createAssociation(i, this), i;
|
|
4161
4205
|
}
|
|
@@ -4168,11 +4212,11 @@ class Ne extends ue {
|
|
|
4168
4212
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4169
4213
|
*/
|
|
4170
4214
|
_write(e) {
|
|
4171
|
-
e.writeTypeRef(
|
|
4215
|
+
e.writeTypeRef(Xo), e.writeKey(this.nodeName);
|
|
4172
4216
|
}
|
|
4173
4217
|
}
|
|
4174
|
-
const
|
|
4175
|
-
class
|
|
4218
|
+
const Io = (s) => new Fe(s.readKey());
|
|
4219
|
+
class jo extends bt {
|
|
4176
4220
|
/**
|
|
4177
4221
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
4178
4222
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -4186,7 +4230,7 @@ class yo extends pt {
|
|
|
4186
4230
|
});
|
|
4187
4231
|
}
|
|
4188
4232
|
}
|
|
4189
|
-
class
|
|
4233
|
+
class lt extends ue {
|
|
4190
4234
|
/**
|
|
4191
4235
|
* @param {string} hookName nodeName of the Dom Node.
|
|
4192
4236
|
*/
|
|
@@ -4197,13 +4241,13 @@ class ot extends he {
|
|
|
4197
4241
|
* Creates an Item with the same effect as this Item (without position effect)
|
|
4198
4242
|
*/
|
|
4199
4243
|
_copy() {
|
|
4200
|
-
return new
|
|
4244
|
+
return new lt(this.hookName);
|
|
4201
4245
|
}
|
|
4202
4246
|
/**
|
|
4203
4247
|
* @return {YXmlHook}
|
|
4204
4248
|
*/
|
|
4205
4249
|
clone() {
|
|
4206
|
-
const e = new
|
|
4250
|
+
const e = new lt(this.hookName);
|
|
4207
4251
|
return this.forEach((t, n) => {
|
|
4208
4252
|
e.set(n, t);
|
|
4209
4253
|
}), e;
|
|
@@ -4237,11 +4281,11 @@ class ot extends he {
|
|
|
4237
4281
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4238
4282
|
*/
|
|
4239
4283
|
_write(e) {
|
|
4240
|
-
e.writeTypeRef(
|
|
4284
|
+
e.writeTypeRef(Wo), e.writeKey(this.hookName);
|
|
4241
4285
|
}
|
|
4242
4286
|
}
|
|
4243
|
-
const
|
|
4244
|
-
class
|
|
4287
|
+
const Mo = (s) => new lt(s.readKey());
|
|
4288
|
+
class ht extends ve {
|
|
4245
4289
|
/**
|
|
4246
4290
|
* @type {YXmlElement|YXmlText|null}
|
|
4247
4291
|
*/
|
|
@@ -4265,13 +4309,13 @@ class at extends Ce {
|
|
|
4265
4309
|
) : null;
|
|
4266
4310
|
}
|
|
4267
4311
|
_copy() {
|
|
4268
|
-
return new
|
|
4312
|
+
return new ht();
|
|
4269
4313
|
}
|
|
4270
4314
|
/**
|
|
4271
4315
|
* @return {YXmlText}
|
|
4272
4316
|
*/
|
|
4273
4317
|
clone() {
|
|
4274
|
-
const e = new
|
|
4318
|
+
const e = new ht();
|
|
4275
4319
|
return e.applyDelta(this.toDelta()), e;
|
|
4276
4320
|
}
|
|
4277
4321
|
/**
|
|
@@ -4329,11 +4373,11 @@ class at extends Ce {
|
|
|
4329
4373
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4330
4374
|
*/
|
|
4331
4375
|
_write(e) {
|
|
4332
|
-
e.writeTypeRef(
|
|
4376
|
+
e.writeTypeRef(Go);
|
|
4333
4377
|
}
|
|
4334
4378
|
}
|
|
4335
|
-
const
|
|
4336
|
-
class
|
|
4379
|
+
const zo = (s) => new ht();
|
|
4380
|
+
class gs {
|
|
4337
4381
|
/**
|
|
4338
4382
|
* @param {ID} id
|
|
4339
4383
|
* @param {number} length
|
|
@@ -4373,8 +4417,8 @@ class us {
|
|
|
4373
4417
|
throw R();
|
|
4374
4418
|
}
|
|
4375
4419
|
}
|
|
4376
|
-
const
|
|
4377
|
-
class
|
|
4420
|
+
const Uo = 0;
|
|
4421
|
+
class z extends gs {
|
|
4378
4422
|
get deleted() {
|
|
4379
4423
|
return !0;
|
|
4380
4424
|
}
|
|
@@ -4392,14 +4436,14 @@ class U extends us {
|
|
|
4392
4436
|
* @param {number} offset
|
|
4393
4437
|
*/
|
|
4394
4438
|
integrate(e, t) {
|
|
4395
|
-
t > 0 && (this.id.clock += t, this.length -= t),
|
|
4439
|
+
t > 0 && (this.id.clock += t, this.length -= t), An(e.doc.store, this);
|
|
4396
4440
|
}
|
|
4397
4441
|
/**
|
|
4398
4442
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4399
4443
|
* @param {number} offset
|
|
4400
4444
|
*/
|
|
4401
4445
|
write(e, t) {
|
|
4402
|
-
e.writeInfo(
|
|
4446
|
+
e.writeInfo(Uo), e.writeLen(this.length - t);
|
|
4403
4447
|
}
|
|
4404
4448
|
/**
|
|
4405
4449
|
* @param {Transaction} transaction
|
|
@@ -4410,7 +4454,7 @@ class U extends us {
|
|
|
4410
4454
|
return null;
|
|
4411
4455
|
}
|
|
4412
4456
|
}
|
|
4413
|
-
class
|
|
4457
|
+
class Ke {
|
|
4414
4458
|
/**
|
|
4415
4459
|
* @param {Uint8Array} content
|
|
4416
4460
|
*/
|
|
@@ -4439,7 +4483,7 @@ class qe {
|
|
|
4439
4483
|
* @return {ContentBinary}
|
|
4440
4484
|
*/
|
|
4441
4485
|
copy() {
|
|
4442
|
-
return new
|
|
4486
|
+
return new Ke(this.content);
|
|
4443
4487
|
}
|
|
4444
4488
|
/**
|
|
4445
4489
|
* @param {number} offset
|
|
@@ -4485,8 +4529,8 @@ class qe {
|
|
|
4485
4529
|
return 3;
|
|
4486
4530
|
}
|
|
4487
4531
|
}
|
|
4488
|
-
const
|
|
4489
|
-
class
|
|
4532
|
+
const To = (s) => new Ke(s.readBuf());
|
|
4533
|
+
class He {
|
|
4490
4534
|
/**
|
|
4491
4535
|
* @param {number} len
|
|
4492
4536
|
*/
|
|
@@ -4515,14 +4559,14 @@ class Fe {
|
|
|
4515
4559
|
* @return {ContentDeleted}
|
|
4516
4560
|
*/
|
|
4517
4561
|
copy() {
|
|
4518
|
-
return new
|
|
4562
|
+
return new He(this.len);
|
|
4519
4563
|
}
|
|
4520
4564
|
/**
|
|
4521
4565
|
* @param {number} offset
|
|
4522
4566
|
* @return {ContentDeleted}
|
|
4523
4567
|
*/
|
|
4524
4568
|
splice(e) {
|
|
4525
|
-
const t = new
|
|
4569
|
+
const t = new He(this.len - e);
|
|
4526
4570
|
return this.len = e, t;
|
|
4527
4571
|
}
|
|
4528
4572
|
/**
|
|
@@ -4537,7 +4581,7 @@ class Fe {
|
|
|
4537
4581
|
* @param {Item} item
|
|
4538
4582
|
*/
|
|
4539
4583
|
integrate(e, t) {
|
|
4540
|
-
|
|
4584
|
+
rt(e.deleteSet, t.id.client, t.id.clock, this.len), t.markDeleted();
|
|
4541
4585
|
}
|
|
4542
4586
|
/**
|
|
4543
4587
|
* @param {Transaction} transaction
|
|
@@ -4563,7 +4607,7 @@ class Fe {
|
|
|
4563
4607
|
return 1;
|
|
4564
4608
|
}
|
|
4565
4609
|
}
|
|
4566
|
-
const
|
|
4610
|
+
const Oo = (s) => new He(s.readLen()), Yn = (s, e) => new pe({ guid: s, ...e, shouldLoad: e.shouldLoad || e.autoLoad || !1 });
|
|
4567
4611
|
class Ye {
|
|
4568
4612
|
/**
|
|
4569
4613
|
* @param {Doc} doc
|
|
@@ -4595,7 +4639,7 @@ class Ye {
|
|
|
4595
4639
|
* @return {ContentDoc}
|
|
4596
4640
|
*/
|
|
4597
4641
|
copy() {
|
|
4598
|
-
return new Ye(
|
|
4642
|
+
return new Ye(Yn(this.doc.guid, this.opts));
|
|
4599
4643
|
}
|
|
4600
4644
|
/**
|
|
4601
4645
|
* @param {number} offset
|
|
@@ -4643,8 +4687,8 @@ class Ye {
|
|
|
4643
4687
|
return 9;
|
|
4644
4688
|
}
|
|
4645
4689
|
}
|
|
4646
|
-
const
|
|
4647
|
-
class
|
|
4690
|
+
const Ro = (s) => new Ye(Yn(s.readString(), s.readAny()));
|
|
4691
|
+
class ke {
|
|
4648
4692
|
/**
|
|
4649
4693
|
* @param {Object} embed
|
|
4650
4694
|
*/
|
|
@@ -4673,7 +4717,7 @@ class pe {
|
|
|
4673
4717
|
* @return {ContentEmbed}
|
|
4674
4718
|
*/
|
|
4675
4719
|
copy() {
|
|
4676
|
-
return new
|
|
4720
|
+
return new ke(this.embed);
|
|
4677
4721
|
}
|
|
4678
4722
|
/**
|
|
4679
4723
|
* @param {number} offset
|
|
@@ -4719,7 +4763,7 @@ class pe {
|
|
|
4719
4763
|
return 5;
|
|
4720
4764
|
}
|
|
4721
4765
|
}
|
|
4722
|
-
const
|
|
4766
|
+
const Bo = (s) => new ke(s.readJSON());
|
|
4723
4767
|
class C {
|
|
4724
4768
|
/**
|
|
4725
4769
|
* @param {string} key
|
|
@@ -4801,8 +4845,8 @@ class C {
|
|
|
4801
4845
|
return 6;
|
|
4802
4846
|
}
|
|
4803
4847
|
}
|
|
4804
|
-
const
|
|
4805
|
-
class
|
|
4848
|
+
const No = (s) => new C(s.readKey(), s.readJSON());
|
|
4849
|
+
class ut {
|
|
4806
4850
|
/**
|
|
4807
4851
|
* @param {Array<any>} arr
|
|
4808
4852
|
*/
|
|
@@ -4831,14 +4875,14 @@ class ct {
|
|
|
4831
4875
|
* @return {ContentJSON}
|
|
4832
4876
|
*/
|
|
4833
4877
|
copy() {
|
|
4834
|
-
return new
|
|
4878
|
+
return new ut(this.arr);
|
|
4835
4879
|
}
|
|
4836
4880
|
/**
|
|
4837
4881
|
* @param {number} offset
|
|
4838
4882
|
* @return {ContentJSON}
|
|
4839
4883
|
*/
|
|
4840
4884
|
splice(e) {
|
|
4841
|
-
const t = new
|
|
4885
|
+
const t = new ut(this.arr.slice(e));
|
|
4842
4886
|
return this.arr = this.arr.slice(0, e), t;
|
|
4843
4887
|
}
|
|
4844
4888
|
/**
|
|
@@ -4883,15 +4927,15 @@ class ct {
|
|
|
4883
4927
|
return 2;
|
|
4884
4928
|
}
|
|
4885
4929
|
}
|
|
4886
|
-
const
|
|
4930
|
+
const Fo = (s) => {
|
|
4887
4931
|
const e = s.readLen(), t = [];
|
|
4888
4932
|
for (let n = 0; n < e; n++) {
|
|
4889
4933
|
const i = s.readString();
|
|
4890
4934
|
i === "undefined" ? t.push(void 0) : t.push(JSON.parse(i));
|
|
4891
4935
|
}
|
|
4892
|
-
return new
|
|
4936
|
+
return new ut(t);
|
|
4893
4937
|
};
|
|
4894
|
-
class
|
|
4938
|
+
class fe {
|
|
4895
4939
|
/**
|
|
4896
4940
|
* @param {Array<any>} arr
|
|
4897
4941
|
*/
|
|
@@ -4920,14 +4964,14 @@ class de {
|
|
|
4920
4964
|
* @return {ContentAny}
|
|
4921
4965
|
*/
|
|
4922
4966
|
copy() {
|
|
4923
|
-
return new
|
|
4967
|
+
return new fe(this.arr);
|
|
4924
4968
|
}
|
|
4925
4969
|
/**
|
|
4926
4970
|
* @param {number} offset
|
|
4927
4971
|
* @return {ContentAny}
|
|
4928
4972
|
*/
|
|
4929
4973
|
splice(e) {
|
|
4930
|
-
const t = new
|
|
4974
|
+
const t = new fe(this.arr.slice(e));
|
|
4931
4975
|
return this.arr = this.arr.slice(0, e), t;
|
|
4932
4976
|
}
|
|
4933
4977
|
/**
|
|
@@ -4972,11 +5016,11 @@ class de {
|
|
|
4972
5016
|
return 8;
|
|
4973
5017
|
}
|
|
4974
5018
|
}
|
|
4975
|
-
const
|
|
5019
|
+
const Ho = (s) => {
|
|
4976
5020
|
const e = s.readLen(), t = [];
|
|
4977
5021
|
for (let n = 0; n < e; n++)
|
|
4978
5022
|
t.push(s.readAny());
|
|
4979
|
-
return new
|
|
5023
|
+
return new fe(t);
|
|
4980
5024
|
};
|
|
4981
5025
|
class V {
|
|
4982
5026
|
/**
|
|
@@ -5056,15 +5100,15 @@ class V {
|
|
|
5056
5100
|
return 4;
|
|
5057
5101
|
}
|
|
5058
5102
|
}
|
|
5059
|
-
const
|
|
5060
|
-
|
|
5061
|
-
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
],
|
|
5103
|
+
const Vo = (s) => new V(s.readString()), $o = [
|
|
5104
|
+
So,
|
|
5105
|
+
Do,
|
|
5106
|
+
xo,
|
|
5107
|
+
Io,
|
|
5108
|
+
Lo,
|
|
5109
|
+
Mo,
|
|
5110
|
+
zo
|
|
5111
|
+
], qo = 0, Ko = 1, Yo = 2, Xo = 3, Jo = 4, Wo = 5, Go = 6;
|
|
5068
5112
|
class P {
|
|
5069
5113
|
/**
|
|
5070
5114
|
* @param {AbstractType<any>} type
|
|
@@ -5157,7 +5201,7 @@ class P {
|
|
|
5157
5201
|
return 7;
|
|
5158
5202
|
}
|
|
5159
5203
|
}
|
|
5160
|
-
const
|
|
5204
|
+
const Po = (s) => new P($o[s.readTypeRef()](s)), dt = (s, e, t) => {
|
|
5161
5205
|
const { client: n, clock: i } = e.id, r = new E(
|
|
5162
5206
|
w(n, i + t),
|
|
5163
5207
|
e,
|
|
@@ -5170,7 +5214,7 @@ const Fo = (s) => new P(Mo[s.readTypeRef()](s)), lt = (s, e, t) => {
|
|
|
5170
5214
|
);
|
|
5171
5215
|
return e.deleted && r.markDeleted(), e.keep && (r.keep = !0), e.redone !== null && (r.redone = w(e.redone.client, e.redone.clock + t)), e.right = r, r.right !== null && (r.right.left = r), s._mergeStructs.push(r), r.parentSub !== null && r.right === null && r.parent._map.set(r.parentSub, r), e.length = t, r;
|
|
5172
5216
|
};
|
|
5173
|
-
class E extends
|
|
5217
|
+
class E extends gs {
|
|
5174
5218
|
/**
|
|
5175
5219
|
* @param {ID} id
|
|
5176
5220
|
* @param {Item | null} left
|
|
@@ -5182,7 +5226,7 @@ class E extends us {
|
|
|
5182
5226
|
* @param {AbstractContent} content
|
|
5183
5227
|
*/
|
|
5184
5228
|
constructor(e, t, n, i, r, o, a, c) {
|
|
5185
|
-
super(e, c.getLength()), this.origin = n, this.left = t, this.right = i, this.rightOrigin = r, this.parent = o, this.parentSub = a, this.redone = null, this.content = c, this.info = this.content.isCountable() ?
|
|
5229
|
+
super(e, c.getLength()), this.origin = n, this.left = t, this.right = i, this.rightOrigin = r, this.parent = o, this.parentSub = a, this.redone = null, this.content = c, this.info = this.content.isCountable() ? Ls : 0;
|
|
5186
5230
|
}
|
|
5187
5231
|
/**
|
|
5188
5232
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5190,35 +5234,35 @@ class E extends us {
|
|
|
5190
5234
|
* @type {boolean}
|
|
5191
5235
|
*/
|
|
5192
5236
|
set marker(e) {
|
|
5193
|
-
(this.info &
|
|
5237
|
+
(this.info & Et) > 0 !== e && (this.info ^= Et);
|
|
5194
5238
|
}
|
|
5195
5239
|
get marker() {
|
|
5196
|
-
return (this.info &
|
|
5240
|
+
return (this.info & Et) > 0;
|
|
5197
5241
|
}
|
|
5198
5242
|
/**
|
|
5199
5243
|
* If true, do not garbage collect this Item.
|
|
5200
5244
|
*/
|
|
5201
5245
|
get keep() {
|
|
5202
|
-
return (this.info &
|
|
5246
|
+
return (this.info & xs) > 0;
|
|
5203
5247
|
}
|
|
5204
5248
|
set keep(e) {
|
|
5205
|
-
this.keep !== e && (this.info ^=
|
|
5249
|
+
this.keep !== e && (this.info ^= xs);
|
|
5206
5250
|
}
|
|
5207
5251
|
get countable() {
|
|
5208
|
-
return (this.info &
|
|
5252
|
+
return (this.info & Ls) > 0;
|
|
5209
5253
|
}
|
|
5210
5254
|
/**
|
|
5211
5255
|
* Whether this item was deleted or not.
|
|
5212
5256
|
* @type {Boolean}
|
|
5213
5257
|
*/
|
|
5214
5258
|
get deleted() {
|
|
5215
|
-
return (this.info &
|
|
5259
|
+
return (this.info & Dt) > 0;
|
|
5216
5260
|
}
|
|
5217
5261
|
set deleted(e) {
|
|
5218
|
-
this.deleted !== e && (this.info ^=
|
|
5262
|
+
this.deleted !== e && (this.info ^= Dt);
|
|
5219
5263
|
}
|
|
5220
5264
|
markDeleted() {
|
|
5221
|
-
this.info |=
|
|
5265
|
+
this.info |= Dt;
|
|
5222
5266
|
}
|
|
5223
5267
|
/**
|
|
5224
5268
|
* Return the creator clientID of the missing op or define missing items and return null.
|
|
@@ -5232,15 +5276,15 @@ class E extends us {
|
|
|
5232
5276
|
return this.origin.client;
|
|
5233
5277
|
if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= A(t, this.rightOrigin.client))
|
|
5234
5278
|
return this.rightOrigin.client;
|
|
5235
|
-
if (this.parent && this.parent.constructor ===
|
|
5279
|
+
if (this.parent && this.parent.constructor === we && this.id.client !== this.parent.client && this.parent.clock >= A(t, this.parent.client))
|
|
5236
5280
|
return this.parent.client;
|
|
5237
|
-
if (this.origin && (this.left =
|
|
5281
|
+
if (this.origin && (this.left = Ns(e, t, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = se(e, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === z || this.right && this.right.constructor === z)
|
|
5238
5282
|
this.parent = null;
|
|
5239
5283
|
else if (!this.parent)
|
|
5240
5284
|
this.left && this.left.constructor === E && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === E && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
|
|
5241
|
-
else if (this.parent.constructor ===
|
|
5242
|
-
const n =
|
|
5243
|
-
n.constructor ===
|
|
5285
|
+
else if (this.parent.constructor === we) {
|
|
5286
|
+
const n = xt(t, this.parent);
|
|
5287
|
+
n.constructor === z ? this.parent = null : this.parent = /** @type {ContentType} */
|
|
5244
5288
|
n.content.type;
|
|
5245
5289
|
}
|
|
5246
5290
|
return null;
|
|
@@ -5250,7 +5294,7 @@ class E extends us {
|
|
|
5250
5294
|
* @param {number} offset
|
|
5251
5295
|
*/
|
|
5252
5296
|
integrate(e, t) {
|
|
5253
|
-
if (t > 0 && (this.id.clock += t, this.left =
|
|
5297
|
+
if (t > 0 && (this.id.clock += t, this.left = Ns(e, e.doc.store, w(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(t), this.length -= t), this.parent) {
|
|
5254
5298
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5255
5299
|
let n = this.left, i;
|
|
5256
5300
|
if (n !== null)
|
|
@@ -5264,13 +5308,13 @@ class E extends us {
|
|
|
5264
5308
|
this.parent._start;
|
|
5265
5309
|
const r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
5266
5310
|
for (; i !== null && i !== this.right; ) {
|
|
5267
|
-
if (o.add(i), r.add(i),
|
|
5311
|
+
if (o.add(i), r.add(i), Ge(this.origin, i.origin)) {
|
|
5268
5312
|
if (i.id.client < this.id.client)
|
|
5269
5313
|
n = i, r.clear();
|
|
5270
|
-
else if (
|
|
5314
|
+
else if (Ge(this.rightOrigin, i.rightOrigin))
|
|
5271
5315
|
break;
|
|
5272
|
-
} else if (i.origin !== null && o.has(
|
|
5273
|
-
r.has(
|
|
5316
|
+
} else if (i.origin !== null && o.has(xt(e.doc.store, i.origin)))
|
|
5317
|
+
r.has(xt(e.doc.store, i.origin)) || (n = i, r.clear());
|
|
5274
5318
|
else
|
|
5275
5319
|
break;
|
|
5276
5320
|
i = i.right;
|
|
@@ -5291,7 +5335,7 @@ class E extends us {
|
|
|
5291
5335
|
this.parent._start, this.parent._start = this;
|
|
5292
5336
|
this.right = n;
|
|
5293
5337
|
}
|
|
5294
|
-
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(e)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length),
|
|
5338
|
+
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(e)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), An(e.doc.store, this), this.content.integrate(e, this), Hs(
|
|
5295
5339
|
e,
|
|
5296
5340
|
/** @type {AbstractType<any>} */
|
|
5297
5341
|
this.parent,
|
|
@@ -5300,7 +5344,7 @@ class E extends us {
|
|
|
5300
5344
|
(this.parent._item !== null && /** @type {AbstractType<any>} */
|
|
5301
5345
|
this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(e);
|
|
5302
5346
|
} else
|
|
5303
|
-
new
|
|
5347
|
+
new z(this.id, this.length).integrate(e, 0);
|
|
5304
5348
|
}
|
|
5305
5349
|
/**
|
|
5306
5350
|
* Returns the next non-deleted item
|
|
@@ -5333,7 +5377,7 @@ class E extends us {
|
|
|
5333
5377
|
* @return {boolean}
|
|
5334
5378
|
*/
|
|
5335
5379
|
mergeWith(e) {
|
|
5336
|
-
if (this.constructor === e.constructor &&
|
|
5380
|
+
if (this.constructor === e.constructor && Ge(e.origin, this.lastId) && this.right === e && Ge(this.rightOrigin, e.rightOrigin) && this.id.client === e.id.client && this.id.clock + this.length === e.id.clock && this.deleted === e.deleted && this.redone === null && e.redone === null && this.content.constructor === e.content.constructor && this.content.mergeWith(e.content)) {
|
|
5337
5381
|
const t = (
|
|
5338
5382
|
/** @type {AbstractType<any>} */
|
|
5339
5383
|
this.parent._searchMarker
|
|
@@ -5355,7 +5399,7 @@ class E extends us {
|
|
|
5355
5399
|
/** @type {AbstractType<any>} */
|
|
5356
5400
|
this.parent
|
|
5357
5401
|
);
|
|
5358
|
-
this.countable && this.parentSub === null && (t._length -= this.length), this.markDeleted(),
|
|
5402
|
+
this.countable && this.parentSub === null && (t._length -= this.length), this.markDeleted(), rt(e.deleteSet, this.id.client, this.id.clock, this.length), Hs(e, t, this.parentSub), this.content.delete(e);
|
|
5359
5403
|
}
|
|
5360
5404
|
}
|
|
5361
5405
|
/**
|
|
@@ -5365,7 +5409,7 @@ class E extends us {
|
|
|
5365
5409
|
gc(e, t) {
|
|
5366
5410
|
if (!this.deleted)
|
|
5367
5411
|
throw F();
|
|
5368
|
-
this.content.gc(e), t ?
|
|
5412
|
+
this.content.gc(e), t ? no(e, this, new z(this.id, this.length)) : this.content = new He(this.length);
|
|
5369
5413
|
}
|
|
5370
5414
|
/**
|
|
5371
5415
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -5377,9 +5421,9 @@ class E extends us {
|
|
|
5377
5421
|
* @param {number} offset
|
|
5378
5422
|
*/
|
|
5379
5423
|
write(e, t) {
|
|
5380
|
-
const n = t > 0 ? w(this.id.client, this.id.clock + t - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() &
|
|
5381
|
-
(i === null ? 0 :
|
|
5382
|
-
(r === null ? 0 :
|
|
5424
|
+
const n = t > 0 ? w(this.id.client, this.id.clock + t - 1) : this.origin, i = this.rightOrigin, r = this.parentSub, o = this.content.getRef() & gt | (n === null ? 0 : M) | // origin is defined
|
|
5425
|
+
(i === null ? 0 : K) | // right origin is defined
|
|
5426
|
+
(r === null ? 0 : Te);
|
|
5383
5427
|
if (e.writeInfo(o), n !== null && e.writeLeftID(n), i !== null && e.writeRightID(i), n === null && i === null) {
|
|
5384
5428
|
const a = (
|
|
5385
5429
|
/** @type {AbstractType<any>} */
|
|
@@ -5388,46 +5432,46 @@ class E extends us {
|
|
|
5388
5432
|
if (a._item !== void 0) {
|
|
5389
5433
|
const c = a._item;
|
|
5390
5434
|
if (c === null) {
|
|
5391
|
-
const l =
|
|
5435
|
+
const l = to(a);
|
|
5392
5436
|
e.writeParentInfo(!0), e.writeString(l);
|
|
5393
5437
|
} else
|
|
5394
5438
|
e.writeParentInfo(!1), e.writeLeftID(c.id);
|
|
5395
5439
|
} else
|
|
5396
|
-
a.constructor === String ? (e.writeParentInfo(!0), e.writeString(a)) : a.constructor ===
|
|
5440
|
+
a.constructor === String ? (e.writeParentInfo(!0), e.writeString(a)) : a.constructor === we ? (e.writeParentInfo(!1), e.writeLeftID(a)) : F();
|
|
5397
5441
|
r !== null && e.writeString(r);
|
|
5398
5442
|
}
|
|
5399
5443
|
this.content.write(e, t);
|
|
5400
5444
|
}
|
|
5401
5445
|
}
|
|
5402
|
-
const
|
|
5446
|
+
const Xn = (s, e) => Zo[e & gt](s), Zo = [
|
|
5403
5447
|
() => {
|
|
5404
5448
|
F();
|
|
5405
5449
|
},
|
|
5406
5450
|
// GC is not ItemContent
|
|
5407
|
-
|
|
5451
|
+
Oo,
|
|
5408
5452
|
// 1
|
|
5409
|
-
|
|
5453
|
+
Fo,
|
|
5410
5454
|
// 2
|
|
5411
|
-
|
|
5455
|
+
To,
|
|
5412
5456
|
// 3
|
|
5413
|
-
|
|
5457
|
+
Vo,
|
|
5414
5458
|
// 4
|
|
5415
|
-
|
|
5459
|
+
Bo,
|
|
5416
5460
|
// 5
|
|
5417
|
-
|
|
5461
|
+
No,
|
|
5418
5462
|
// 6
|
|
5419
|
-
|
|
5463
|
+
Po,
|
|
5420
5464
|
// 7
|
|
5421
|
-
|
|
5465
|
+
Ho,
|
|
5422
5466
|
// 8
|
|
5423
|
-
|
|
5467
|
+
Ro,
|
|
5424
5468
|
// 9
|
|
5425
5469
|
() => {
|
|
5426
5470
|
F();
|
|
5427
5471
|
}
|
|
5428
5472
|
// 10 - Skip is not ItemContent
|
|
5429
|
-
],
|
|
5430
|
-
class
|
|
5473
|
+
], Qo = 10;
|
|
5474
|
+
class U extends gs {
|
|
5431
5475
|
get deleted() {
|
|
5432
5476
|
return !0;
|
|
5433
5477
|
}
|
|
@@ -5452,7 +5496,7 @@ class z extends us {
|
|
|
5452
5496
|
* @param {number} offset
|
|
5453
5497
|
*/
|
|
5454
5498
|
write(e, t) {
|
|
5455
|
-
e.writeInfo(
|
|
5499
|
+
e.writeInfo(Qo), p(e.restEncoder, this.length - t);
|
|
5456
5500
|
}
|
|
5457
5501
|
/**
|
|
5458
5502
|
* @param {Transaction} transaction
|
|
@@ -5463,93 +5507,93 @@ class z extends us {
|
|
|
5463
5507
|
return null;
|
|
5464
5508
|
}
|
|
5465
5509
|
}
|
|
5466
|
-
const
|
|
5510
|
+
const Jn = (
|
|
5467
5511
|
/** @type {any} */
|
|
5468
5512
|
typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
|
|
5469
|
-
),
|
|
5470
|
-
|
|
5471
|
-
|
|
5472
|
-
const
|
|
5473
|
-
class
|
|
5513
|
+
), Wn = "__ $YJS$ __";
|
|
5514
|
+
Jn[Wn] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5515
|
+
Jn[Wn] = !0;
|
|
5516
|
+
const Gn = /* @__PURE__ */ new Map();
|
|
5517
|
+
class ea {
|
|
5474
5518
|
/**
|
|
5475
5519
|
* @param {string} room
|
|
5476
5520
|
*/
|
|
5477
5521
|
constructor(e) {
|
|
5478
|
-
this.room = e, this.onmessage = null, this._onChange = (t) => t.key === e && this.onmessage !== null && this.onmessage({ data:
|
|
5522
|
+
this.room = e, this.onmessage = null, this._onChange = (t) => t.key === e && this.onmessage !== null && this.onmessage({ data: hr(t.newValue || "") }), Mi(this._onChange);
|
|
5479
5523
|
}
|
|
5480
5524
|
/**
|
|
5481
5525
|
* @param {ArrayBuffer} buf
|
|
5482
5526
|
*/
|
|
5483
5527
|
postMessage(e) {
|
|
5484
|
-
|
|
5528
|
+
en.setItem(this.room, lr(ir(e)));
|
|
5485
5529
|
}
|
|
5486
5530
|
close() {
|
|
5487
|
-
|
|
5531
|
+
zi(this._onChange);
|
|
5488
5532
|
}
|
|
5489
5533
|
}
|
|
5490
|
-
const
|
|
5491
|
-
const e =
|
|
5534
|
+
const ta = typeof BroadcastChannel > "u" ? ea : BroadcastChannel, ps = (s) => W(Gn, s, () => {
|
|
5535
|
+
const e = ce(), t = new ta(s);
|
|
5492
5536
|
return t.onmessage = (n) => e.forEach((i) => i(n.data, "broadcastchannel")), {
|
|
5493
5537
|
bc: t,
|
|
5494
5538
|
subs: e
|
|
5495
5539
|
};
|
|
5496
|
-
}),
|
|
5497
|
-
const t =
|
|
5498
|
-
return n && t.subs.size === 0 && (t.bc.close(),
|
|
5499
|
-
},
|
|
5500
|
-
const n =
|
|
5540
|
+
}), sa = (s, e) => (ps(s).subs.add(e), e), na = (s, e) => {
|
|
5541
|
+
const t = ps(s), n = t.subs.delete(e);
|
|
5542
|
+
return n && t.subs.size === 0 && (t.bc.close(), Gn.delete(s)), n;
|
|
5543
|
+
}, be = (s, e, t = null) => {
|
|
5544
|
+
const n = ps(s);
|
|
5501
5545
|
n.bc.postMessage(e), n.subs.forEach((i) => i(e, t));
|
|
5502
|
-
},
|
|
5503
|
-
p(s,
|
|
5504
|
-
const t =
|
|
5546
|
+
}, Pn = 0, ks = 1, Zn = 2, qt = (s, e) => {
|
|
5547
|
+
p(s, Pn);
|
|
5548
|
+
const t = Qr(e);
|
|
5505
5549
|
D(s, t);
|
|
5506
|
-
},
|
|
5507
|
-
p(s,
|
|
5508
|
-
},
|
|
5550
|
+
}, Qn = (s, e, t) => {
|
|
5551
|
+
p(s, ks), D(s, as(e, t));
|
|
5552
|
+
}, ia = (s, e, t) => Qn(e, t, L(s)), ei = (s, e, t) => {
|
|
5509
5553
|
try {
|
|
5510
|
-
|
|
5554
|
+
_n(e, L(s), t);
|
|
5511
5555
|
} catch (n) {
|
|
5512
5556
|
console.error("Caught error while handling a Yjs update", n);
|
|
5513
5557
|
}
|
|
5514
|
-
},
|
|
5515
|
-
p(s,
|
|
5516
|
-
},
|
|
5558
|
+
}, ra = (s, e) => {
|
|
5559
|
+
p(s, Zn), D(s, e);
|
|
5560
|
+
}, oa = ei, aa = (s, e, t, n) => {
|
|
5517
5561
|
const i = m(s);
|
|
5518
5562
|
switch (i) {
|
|
5519
|
-
case
|
|
5520
|
-
|
|
5563
|
+
case Pn:
|
|
5564
|
+
ia(s, e, t);
|
|
5521
5565
|
break;
|
|
5522
|
-
case
|
|
5523
|
-
|
|
5566
|
+
case ks:
|
|
5567
|
+
ei(s, t, n);
|
|
5524
5568
|
break;
|
|
5525
|
-
case
|
|
5526
|
-
|
|
5569
|
+
case Zn:
|
|
5570
|
+
oa(s, t, n);
|
|
5527
5571
|
break;
|
|
5528
5572
|
default:
|
|
5529
5573
|
throw new Error("Unknown message type");
|
|
5530
5574
|
}
|
|
5531
5575
|
return i;
|
|
5532
|
-
},
|
|
5576
|
+
}, ca = 0, la = (s, e, t) => {
|
|
5533
5577
|
switch (m(s)) {
|
|
5534
|
-
case
|
|
5578
|
+
case ca:
|
|
5535
5579
|
t(e, ee(s));
|
|
5536
5580
|
}
|
|
5537
|
-
},
|
|
5538
|
-
class
|
|
5581
|
+
}, jt = 3e4;
|
|
5582
|
+
class ha extends ft {
|
|
5539
5583
|
/**
|
|
5540
5584
|
* @param {Y.Doc} doc
|
|
5541
5585
|
*/
|
|
5542
5586
|
constructor(e) {
|
|
5543
5587
|
super(), this.doc = e, this.clientID = e.clientID, this.states = /* @__PURE__ */ new Map(), this.meta = /* @__PURE__ */ new Map(), this._checkInterval = /** @type {any} */
|
|
5544
5588
|
setInterval(() => {
|
|
5545
|
-
const t =
|
|
5546
|
-
this.getLocalState() !== null &&
|
|
5589
|
+
const t = le();
|
|
5590
|
+
this.getLocalState() !== null && jt / 2 <= t - /** @type {{lastUpdated:number}} */
|
|
5547
5591
|
this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
|
|
5548
5592
|
const n = [];
|
|
5549
5593
|
this.meta.forEach((i, r) => {
|
|
5550
|
-
r !== this.clientID &&
|
|
5551
|
-
}), n.length > 0 &&
|
|
5552
|
-
}, X(
|
|
5594
|
+
r !== this.clientID && jt <= t - i.lastUpdated && this.states.has(r) && n.push(r);
|
|
5595
|
+
}), n.length > 0 && ms(this, n, "timeout");
|
|
5596
|
+
}, X(jt / 10)), e.on("destroy", () => {
|
|
5553
5597
|
this.destroy();
|
|
5554
5598
|
}), this.setLocalState({});
|
|
5555
5599
|
}
|
|
@@ -5569,10 +5613,10 @@ class Zo extends ht {
|
|
|
5569
5613
|
const t = this.clientID, n = this.meta.get(t), i = n === void 0 ? 0 : n.clock + 1, r = this.states.get(t);
|
|
5570
5614
|
e === null ? this.states.delete(t) : this.states.set(t, e), this.meta.set(t, {
|
|
5571
5615
|
clock: i,
|
|
5572
|
-
lastUpdated:
|
|
5616
|
+
lastUpdated: le()
|
|
5573
5617
|
});
|
|
5574
5618
|
const o = [], a = [], c = [], l = [];
|
|
5575
|
-
e === null ? l.push(t) : r == null ? e != null && o.push(t) : (a.push(t),
|
|
5619
|
+
e === null ? l.push(t) : r == null ? e != null && o.push(t) : (a.push(t), Me(r, e) || c.push(t)), (o.length > 0 || c.length > 0 || l.length > 0) && this.emit("change", [{ added: o, updated: c, removed: l }, "local"]), this.emit("update", [{ added: o, updated: a, removed: l }, "local"]);
|
|
5576
5620
|
}
|
|
5577
5621
|
/**
|
|
5578
5622
|
* @param {string} field
|
|
@@ -5592,7 +5636,7 @@ class Zo extends ht {
|
|
|
5592
5636
|
return this.states;
|
|
5593
5637
|
}
|
|
5594
5638
|
}
|
|
5595
|
-
const
|
|
5639
|
+
const ms = (s, e, t) => {
|
|
5596
5640
|
const n = [];
|
|
5597
5641
|
for (let i = 0; i < e.length; i++) {
|
|
5598
5642
|
const r = e[i];
|
|
@@ -5604,14 +5648,14 @@ const gs = (s, e, t) => {
|
|
|
5604
5648
|
);
|
|
5605
5649
|
s.meta.set(r, {
|
|
5606
5650
|
clock: o.clock + 1,
|
|
5607
|
-
lastUpdated:
|
|
5651
|
+
lastUpdated: le()
|
|
5608
5652
|
});
|
|
5609
5653
|
}
|
|
5610
5654
|
n.push(r);
|
|
5611
5655
|
}
|
|
5612
5656
|
}
|
|
5613
5657
|
n.length > 0 && (s.emit("change", [{ added: [], updated: [], removed: n }, t]), s.emit("update", [{ added: [], updated: [], removed: n }, t]));
|
|
5614
|
-
},
|
|
5658
|
+
}, ze = (s, e, t = s.states) => {
|
|
5615
5659
|
const n = e.length, i = I();
|
|
5616
5660
|
p(i, n);
|
|
5617
5661
|
for (let r = 0; r < n; r++) {
|
|
@@ -5619,19 +5663,19 @@ const gs = (s, e, t) => {
|
|
|
5619
5663
|
/** @type {MetaClientState} */
|
|
5620
5664
|
s.meta.get(o).clock
|
|
5621
5665
|
);
|
|
5622
|
-
p(i, o), p(i, c),
|
|
5666
|
+
p(i, o), p(i, c), ae(i, JSON.stringify(a));
|
|
5623
5667
|
}
|
|
5624
|
-
return
|
|
5625
|
-
},
|
|
5626
|
-
const n = ne(e), i =
|
|
5668
|
+
return S(i);
|
|
5669
|
+
}, ua = (s, e, t) => {
|
|
5670
|
+
const n = ne(e), i = le(), r = [], o = [], a = [], c = [], l = m(n);
|
|
5627
5671
|
for (let h = 0; h < l; h++) {
|
|
5628
5672
|
const u = m(n);
|
|
5629
5673
|
let d = m(n);
|
|
5630
|
-
const f = JSON.parse(ee(n)), g = s.meta.get(u), k = s.states.get(u),
|
|
5631
|
-
(
|
|
5674
|
+
const f = JSON.parse(ee(n)), g = s.meta.get(u), k = s.states.get(u), _ = g === void 0 ? 0 : g.clock;
|
|
5675
|
+
(_ < d || _ === d && f === null && s.states.has(u)) && (f === null ? u === s.clientID && s.getLocalState() != null ? d++ : s.states.delete(u) : s.states.set(u, f), s.meta.set(u, {
|
|
5632
5676
|
clock: d,
|
|
5633
5677
|
lastUpdated: i
|
|
5634
|
-
}), g === void 0 && f !== null ? r.push(u) : g !== void 0 && f === null ? c.push(u) : f !== null && (
|
|
5678
|
+
}), g === void 0 && f !== null ? r.push(u) : g !== void 0 && f === null ? c.push(u) : f !== null && (Me(f, k) || a.push(u), o.push(u)));
|
|
5635
5679
|
}
|
|
5636
5680
|
(r.length > 0 || a.length > 0 || c.length > 0) && s.emit("change", [{
|
|
5637
5681
|
added: r,
|
|
@@ -5642,68 +5686,68 @@ const gs = (s, e, t) => {
|
|
|
5642
5686
|
updated: o,
|
|
5643
5687
|
removed: c
|
|
5644
5688
|
}, t]);
|
|
5645
|
-
},
|
|
5646
|
-
var ie = 0,
|
|
5647
|
-
function
|
|
5689
|
+
}, da = (s) => Ri(s, (e, t) => `${encodeURIComponent(t)}=${encodeURIComponent(e)}`).join("&");
|
|
5690
|
+
var ie = 0, ti = 3, Se = 1, fa = 2, ga = typeof window > "u";
|
|
5691
|
+
function pa(s, e) {
|
|
5648
5692
|
if (!s)
|
|
5649
5693
|
throw new Error(e);
|
|
5650
5694
|
}
|
|
5651
|
-
var
|
|
5652
|
-
|
|
5695
|
+
var Xe = [];
|
|
5696
|
+
Xe[ie] = (s, e, t, n, i) => {
|
|
5653
5697
|
p(s, ie);
|
|
5654
|
-
const r =
|
|
5698
|
+
const r = aa(
|
|
5655
5699
|
e,
|
|
5656
5700
|
s,
|
|
5657
5701
|
t.doc,
|
|
5658
5702
|
t
|
|
5659
5703
|
);
|
|
5660
|
-
n && r ===
|
|
5704
|
+
n && r === ks && !t.synced && (t.synced = !0);
|
|
5661
5705
|
};
|
|
5662
|
-
|
|
5663
|
-
p(s,
|
|
5706
|
+
Xe[ti] = (s, e, t, n, i) => {
|
|
5707
|
+
p(s, Se), D(
|
|
5664
5708
|
s,
|
|
5665
|
-
|
|
5709
|
+
ze(
|
|
5666
5710
|
t.awareness,
|
|
5667
5711
|
Array.from(t.awareness.getStates().keys())
|
|
5668
5712
|
)
|
|
5669
5713
|
);
|
|
5670
5714
|
};
|
|
5671
|
-
|
|
5672
|
-
|
|
5715
|
+
Xe[Se] = (s, e, t, n, i) => {
|
|
5716
|
+
ua(
|
|
5673
5717
|
t.awareness,
|
|
5674
5718
|
L(e),
|
|
5675
5719
|
t
|
|
5676
5720
|
);
|
|
5677
5721
|
};
|
|
5678
|
-
|
|
5679
|
-
|
|
5722
|
+
Xe[fa] = (s, e, t, n, i) => {
|
|
5723
|
+
la(
|
|
5680
5724
|
e,
|
|
5681
5725
|
t.doc,
|
|
5682
|
-
(r, o) =>
|
|
5726
|
+
(r, o) => ka(t, o)
|
|
5683
5727
|
);
|
|
5684
5728
|
};
|
|
5685
|
-
var
|
|
5686
|
-
function
|
|
5729
|
+
var Ys = 3e4;
|
|
5730
|
+
function ka(s, e) {
|
|
5687
5731
|
console.warn(`Permission denied to access ${s.url}.
|
|
5688
5732
|
${e}`);
|
|
5689
5733
|
}
|
|
5690
|
-
function
|
|
5734
|
+
function si(s, e, t) {
|
|
5691
5735
|
const n = ne(e), i = I(), r = m(n), o = s.messageHandlers[r];
|
|
5692
5736
|
return /** @type {any} */ o ? o(i, n, s, t, r) : console.error("Unable to compute message"), i;
|
|
5693
5737
|
}
|
|
5694
|
-
function
|
|
5738
|
+
function ni(s) {
|
|
5695
5739
|
if (s.shouldConnect && s.ws === null) {
|
|
5696
5740
|
const e = new s._WS(s.url);
|
|
5697
5741
|
e.binaryType = "arraybuffer", s.ws = e, s.wsconnecting = !0, s.wsconnected = !1, s.synced = !1, e.onmessage = (t) => {
|
|
5698
5742
|
if (typeof t.data == "string")
|
|
5699
5743
|
return;
|
|
5700
|
-
s.wsLastMessageReceived =
|
|
5701
|
-
const n =
|
|
5702
|
-
|
|
5744
|
+
s.wsLastMessageReceived = le();
|
|
5745
|
+
const n = si(s, new Uint8Array(t.data), !0);
|
|
5746
|
+
es(n) > 1 && e.send(S(n));
|
|
5703
5747
|
}, e.onerror = (t) => {
|
|
5704
5748
|
s.emit("connection-error", [t, s]);
|
|
5705
5749
|
}, e.onclose = (t) => {
|
|
5706
|
-
s.emit("connection-close", [t, s]), s.ws = null, s.wsconnecting = !1, s.wsconnected ? (s.wsconnected = !1, s.synced = !1,
|
|
5750
|
+
s.emit("connection-close", [t, s]), s.ws = null, s.wsconnecting = !1, s.wsconnected ? (s.wsconnected = !1, s.synced = !1, ms(
|
|
5707
5751
|
s.awareness,
|
|
5708
5752
|
Array.from(s.awareness.getStates().keys()).filter(
|
|
5709
5753
|
(n) => n !== s.doc.clientID
|
|
@@ -5714,28 +5758,28 @@ function Jn(s) {
|
|
|
5714
5758
|
status: "disconnected"
|
|
5715
5759
|
}
|
|
5716
5760
|
])) : s.wsUnsuccessfulReconnects++, setTimeout(
|
|
5717
|
-
|
|
5718
|
-
|
|
5719
|
-
|
|
5761
|
+
ni,
|
|
5762
|
+
Jt(
|
|
5763
|
+
_i(2, s.wsUnsuccessfulReconnects) * 100,
|
|
5720
5764
|
s.maxBackoffTime
|
|
5721
5765
|
),
|
|
5722
5766
|
s
|
|
5723
5767
|
);
|
|
5724
5768
|
}, e.onopen = () => {
|
|
5725
|
-
s.wsLastMessageReceived =
|
|
5769
|
+
s.wsLastMessageReceived = le(), s.wsconnecting = !1, s.wsconnected = !0, s.wsUnsuccessfulReconnects = 0, s.emit("status", [
|
|
5726
5770
|
{
|
|
5727
5771
|
status: "connected"
|
|
5728
5772
|
}
|
|
5729
5773
|
]);
|
|
5730
5774
|
const t = I();
|
|
5731
|
-
if (p(t, ie),
|
|
5775
|
+
if (p(t, ie), qt(t, s.doc), e.send(S(t)), s.awareness.getLocalState() !== null) {
|
|
5732
5776
|
const n = I();
|
|
5733
|
-
p(n,
|
|
5777
|
+
p(n, Se), D(
|
|
5734
5778
|
n,
|
|
5735
|
-
|
|
5779
|
+
ze(s.awareness, [
|
|
5736
5780
|
s.doc.clientID
|
|
5737
5781
|
])
|
|
5738
|
-
), e.send(
|
|
5782
|
+
), e.send(S(n));
|
|
5739
5783
|
}
|
|
5740
5784
|
}, s.emit("status", [
|
|
5741
5785
|
{
|
|
@@ -5744,14 +5788,14 @@ function Jn(s) {
|
|
|
5744
5788
|
]);
|
|
5745
5789
|
}
|
|
5746
5790
|
}
|
|
5747
|
-
function
|
|
5791
|
+
function Mt(s, e) {
|
|
5748
5792
|
const t = s.ws;
|
|
5749
|
-
s.wsconnected && t && t.readyState === t.OPEN && t.send(e), s.bcconnected &&
|
|
5793
|
+
s.wsconnected && t && t.readyState === t.OPEN && t.send(e), s.bcconnected && be(s.bcChannel, e, s);
|
|
5750
5794
|
}
|
|
5751
|
-
var
|
|
5795
|
+
var ma = class extends ft {
|
|
5752
5796
|
constructor(e, t, n, {
|
|
5753
5797
|
connect: i = !0,
|
|
5754
|
-
awareness: r = new
|
|
5798
|
+
awareness: r = new ha(n),
|
|
5755
5799
|
params: o = {},
|
|
5756
5800
|
WebSocketPolyfill: a = WebSocket,
|
|
5757
5801
|
// Optionally provide a WebSocket polyfill
|
|
@@ -5759,7 +5803,7 @@ var oa = class extends ht {
|
|
|
5759
5803
|
// Request server state every `resyncInterval` milliseconds
|
|
5760
5804
|
maxBackoffTime: l = 2500,
|
|
5761
5805
|
// Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
5762
|
-
disableBc: h =
|
|
5806
|
+
disableBc: h = ga
|
|
5763
5807
|
// Disable cross-tab BroadcastChannel communication
|
|
5764
5808
|
} = {}) {
|
|
5765
5809
|
super();
|
|
@@ -5789,39 +5833,39 @@ var oa = class extends ht {
|
|
|
5789
5833
|
b(this, "_checkInterval");
|
|
5790
5834
|
for (; e[e.length - 1] === "/"; )
|
|
5791
5835
|
e = e.slice(0, e.length - 1);
|
|
5792
|
-
const u =
|
|
5793
|
-
this.maxBackoffTime = l, this.bcChannel = e + "/" + t, this.url = e + "/" + t + (u.length === 0 ? "" : "?" + u), this.roomname = t, this.doc = n, this._WS = a, this.awareness = r, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers =
|
|
5836
|
+
const u = da(o);
|
|
5837
|
+
this.maxBackoffTime = l, this.bcChannel = e + "/" + t, this.url = e + "/" + t + (u.length === 0 ? "" : "?" + u), this.roomname = t, this.doc = n, this._WS = a, this.awareness = r, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Xe.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = i, this._resyncInterval = 0, c > 0 && (this._resyncInterval = /** @type {any} */
|
|
5794
5838
|
setInterval(() => {
|
|
5795
5839
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
5796
5840
|
const d = I();
|
|
5797
|
-
p(d, ie),
|
|
5841
|
+
p(d, ie), qt(d, n), this.ws.send(S(d));
|
|
5798
5842
|
}
|
|
5799
5843
|
}, c)), this._bcSubscriber = (d, f) => {
|
|
5800
5844
|
if (f !== this) {
|
|
5801
|
-
const g =
|
|
5802
|
-
|
|
5845
|
+
const g = si(this, new Uint8Array(d), !1);
|
|
5846
|
+
es(g) > 1 && be(this.bcChannel, S(g), this);
|
|
5803
5847
|
}
|
|
5804
5848
|
}, this._updateHandler = (d, f) => {
|
|
5805
5849
|
if (f !== this) {
|
|
5806
5850
|
const g = I();
|
|
5807
|
-
p(g, ie),
|
|
5851
|
+
p(g, ie), ra(g, d), Mt(this, S(g));
|
|
5808
5852
|
}
|
|
5809
5853
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, k) => {
|
|
5810
|
-
const
|
|
5811
|
-
p($,
|
|
5854
|
+
const _ = d.concat(f).concat(g), $ = I();
|
|
5855
|
+
p($, Se), D(
|
|
5812
5856
|
$,
|
|
5813
|
-
|
|
5814
|
-
),
|
|
5857
|
+
ze(r, _)
|
|
5858
|
+
), Mt(this, S($));
|
|
5815
5859
|
}, this._unloadHandler = () => {
|
|
5816
|
-
|
|
5860
|
+
ms(
|
|
5817
5861
|
this.awareness,
|
|
5818
5862
|
[n.clientID],
|
|
5819
5863
|
"window unload"
|
|
5820
5864
|
);
|
|
5821
5865
|
}, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), r.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
|
|
5822
5866
|
setInterval(() => {
|
|
5823
|
-
this.wsconnected &&
|
|
5824
|
-
},
|
|
5867
|
+
this.wsconnected && Ys < le() - this.wsLastMessageReceived && (pa(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
5868
|
+
}, Ys / 10), i && this.connect();
|
|
5825
5869
|
}
|
|
5826
5870
|
/**
|
|
5827
5871
|
* @type {boolean}
|
|
@@ -5838,48 +5882,48 @@ var oa = class extends ht {
|
|
|
5838
5882
|
connectBc() {
|
|
5839
5883
|
if (this.disableBc)
|
|
5840
5884
|
return;
|
|
5841
|
-
this.bcconnected || (
|
|
5885
|
+
this.bcconnected || (sa(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
5842
5886
|
const e = I();
|
|
5843
|
-
p(e, ie),
|
|
5887
|
+
p(e, ie), qt(e, this.doc), be(this.bcChannel, S(e), this);
|
|
5844
5888
|
const t = I();
|
|
5845
|
-
p(t, ie),
|
|
5889
|
+
p(t, ie), Qn(t, this.doc), be(this.bcChannel, S(t), this);
|
|
5846
5890
|
const n = I();
|
|
5847
|
-
p(n,
|
|
5891
|
+
p(n, ti), be(
|
|
5848
5892
|
this.bcChannel,
|
|
5849
|
-
|
|
5893
|
+
S(n),
|
|
5850
5894
|
this
|
|
5851
5895
|
);
|
|
5852
5896
|
const i = I();
|
|
5853
|
-
p(i,
|
|
5897
|
+
p(i, Se), D(
|
|
5854
5898
|
i,
|
|
5855
|
-
|
|
5899
|
+
ze(this.awareness, [
|
|
5856
5900
|
this.doc.clientID
|
|
5857
5901
|
])
|
|
5858
|
-
),
|
|
5902
|
+
), be(
|
|
5859
5903
|
this.bcChannel,
|
|
5860
|
-
|
|
5904
|
+
S(i),
|
|
5861
5905
|
this
|
|
5862
5906
|
);
|
|
5863
5907
|
}
|
|
5864
5908
|
disconnectBc() {
|
|
5865
5909
|
const e = I();
|
|
5866
|
-
p(e,
|
|
5910
|
+
p(e, Se), D(
|
|
5867
5911
|
e,
|
|
5868
|
-
|
|
5912
|
+
ze(
|
|
5869
5913
|
this.awareness,
|
|
5870
5914
|
[this.doc.clientID],
|
|
5871
5915
|
/* @__PURE__ */ new Map()
|
|
5872
5916
|
)
|
|
5873
|
-
),
|
|
5917
|
+
), Mt(this, S(e)), this.bcconnected && (na(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
5874
5918
|
}
|
|
5875
5919
|
disconnect() {
|
|
5876
5920
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
5877
5921
|
}
|
|
5878
5922
|
connect() {
|
|
5879
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
5923
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (ni(this), this.connectBc());
|
|
5880
5924
|
}
|
|
5881
5925
|
};
|
|
5882
|
-
function
|
|
5926
|
+
function ba() {
|
|
5883
5927
|
if (crypto.randomUUID)
|
|
5884
5928
|
return crypto.randomUUID();
|
|
5885
5929
|
let s = (/* @__PURE__ */ new Date()).getTime(), e = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
@@ -5888,27 +5932,47 @@ function aa() {
|
|
|
5888
5932
|
return s > 0 ? (n = (s + n) % 16 | 0, s = Math.floor(s / 16)) : (n = (e + n) % 16 | 0, e = Math.floor(e / 16)), (t === "x" ? n : n & 3 | 8).toString(16);
|
|
5889
5933
|
});
|
|
5890
5934
|
}
|
|
5891
|
-
function
|
|
5935
|
+
function Xs(s, e, t) {
|
|
5892
5936
|
if (typeof s !== t)
|
|
5893
5937
|
throw new Error(
|
|
5894
5938
|
`Invalid "${e}" parameter provided to YPartyKitProvider. Expected: ${t}, received: ${s}`
|
|
5895
5939
|
);
|
|
5896
5940
|
}
|
|
5897
|
-
var
|
|
5941
|
+
var wa = class extends WebSocket {
|
|
5942
|
+
send(s) {
|
|
5943
|
+
typeof s != "string" && mi(s, (e) => super.send(e));
|
|
5944
|
+
}
|
|
5945
|
+
}, re, Ps, ya = (Ps = class extends ma {
|
|
5898
5946
|
constructor(e, t, n, i = {}) {
|
|
5899
|
-
|
|
5900
|
-
const r = `${e.startsWith("localhost:") || e.startsWith("127.0.0.1:") ? "ws" : "wss"}://${e}${i.party ? `/parties/${i.party}` : "/party"}`, o =
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5904
|
-
|
|
5947
|
+
Xs(e, "host", "string"), Xs(t, "room", "string"), e = e.replace(/^(http|https|ws|wss):\/\//, ""), e.endsWith("/") && e.slice(0, -1);
|
|
5948
|
+
const r = `${e.startsWith("localhost:") || e.startsWith("127.0.0.1:") ? "ws" : "wss"}://${e}${i.party ? `/parties/${i.party}` : "/party"}`, o = i.connectionId ?? ba(), { params: a, connect: c = !0, ...l } = i, h = {
|
|
5949
|
+
...l,
|
|
5950
|
+
connect: !1,
|
|
5951
|
+
WebSocketPolyfill: wa
|
|
5952
|
+
};
|
|
5953
|
+
super(r, t, n ?? new pe(), h);
|
|
5905
5954
|
b(this, "id");
|
|
5906
|
-
this
|
|
5955
|
+
Ss(this, re, void 0);
|
|
5956
|
+
this.id = o, _s(this, re, a), c && this.connect();
|
|
5907
5957
|
}
|
|
5908
|
-
|
|
5909
|
-
|
|
5958
|
+
connect() {
|
|
5959
|
+
Promise.resolve(
|
|
5960
|
+
typeof Je(this, re) == "function" ? Je(this, re).call(this) : Je(this, re)
|
|
5961
|
+
).then((e) => {
|
|
5962
|
+
const t = new URLSearchParams([["_pk", this.id]]);
|
|
5963
|
+
if (e)
|
|
5964
|
+
for (const [i, r] of Object.entries(e))
|
|
5965
|
+
r != null && t.append(i, r);
|
|
5966
|
+
const n = new URL(this.url);
|
|
5967
|
+
n.search = t.toString(), this.url = n.toString(), super.connect();
|
|
5968
|
+
}).catch((e) => {
|
|
5969
|
+
throw console.error("Failed to open connecton to PartyKit", e), new Error(e);
|
|
5970
|
+
});
|
|
5971
|
+
}
|
|
5972
|
+
}, re = new WeakMap(), Ps);
|
|
5973
|
+
const me = (s) => Ee((e, t) => {
|
|
5910
5974
|
s.onerror = (n) => t(new Error(n.target.error)), s.onsuccess = (n) => e(n.target.result);
|
|
5911
|
-
}),
|
|
5975
|
+
}), Sa = (s, e) => Ee((t, n) => {
|
|
5912
5976
|
const i = indexedDB.open(s);
|
|
5913
5977
|
i.onupgradeneeded = (r) => e(r.target.result), i.onerror = (r) => n(J(r.target.error)), i.onsuccess = (r) => {
|
|
5914
5978
|
const o = r.target.result;
|
|
@@ -5916,73 +5980,73 @@ const ke = (s) => De((e, t) => {
|
|
|
5916
5980
|
o.close();
|
|
5917
5981
|
}, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), t(o);
|
|
5918
5982
|
};
|
|
5919
|
-
}),
|
|
5983
|
+
}), _a = (s) => me(indexedDB.deleteDatabase(s)), Da = (s, e) => e.forEach(
|
|
5920
5984
|
(t) => (
|
|
5921
5985
|
// @ts-ignore
|
|
5922
5986
|
s.createObjectStore.apply(s, t)
|
|
5923
5987
|
)
|
|
5924
|
-
),
|
|
5988
|
+
), Ie = (s, e, t = "readwrite") => {
|
|
5925
5989
|
const n = s.transaction(e, t);
|
|
5926
|
-
return e.map((i) =>
|
|
5927
|
-
},
|
|
5990
|
+
return e.map((i) => ja(n, i));
|
|
5991
|
+
}, ii = (s, e) => me(s.count(e)), Ea = (s, e) => me(s.get(e)), ri = (s, e) => me(s.delete(e)), Ca = (s, e, t) => me(s.put(e, t)), Kt = (s, e) => me(s.add(e)), va = (s, e, t) => me(s.getAll(e, t)), Aa = (s, e, t) => {
|
|
5928
5992
|
let n = null;
|
|
5929
|
-
return
|
|
5930
|
-
},
|
|
5993
|
+
return Ia(s, e, (i) => (n = i, !1), t).then(() => n);
|
|
5994
|
+
}, xa = (s, e = null) => Aa(s, e, "prev"), La = (s, e) => Ee((t, n) => {
|
|
5931
5995
|
s.onerror = n, s.onsuccess = async (i) => {
|
|
5932
5996
|
const r = i.target.result;
|
|
5933
5997
|
if (r === null || await e(r) === !1)
|
|
5934
5998
|
return t();
|
|
5935
5999
|
r.continue();
|
|
5936
6000
|
};
|
|
5937
|
-
}),
|
|
6001
|
+
}), Ia = (s, e, t, n = "next") => La(s.openKeyCursor(e, n), (i) => t(i.key)), ja = (s, e) => s.objectStore(e), Ma = (s, e) => IDBKeyRange.upperBound(s, e), za = (s, e) => IDBKeyRange.lowerBound(s, e), zt = "custom", oi = "updates", ai = 500, ci = (s, e = () => {
|
|
5938
6002
|
}, t = () => {
|
|
5939
6003
|
}) => {
|
|
5940
|
-
const [n] =
|
|
6004
|
+
const [n] = Ie(
|
|
5941
6005
|
/** @type {IDBDatabase} */
|
|
5942
6006
|
s.db,
|
|
5943
|
-
[
|
|
6007
|
+
[oi]
|
|
5944
6008
|
);
|
|
5945
|
-
return
|
|
6009
|
+
return va(n, za(s._dbref, !1)).then((i) => {
|
|
5946
6010
|
s._destroyed || (e(n), y(s.doc, () => {
|
|
5947
|
-
i.forEach((r) =>
|
|
6011
|
+
i.forEach((r) => _n(s.doc, r));
|
|
5948
6012
|
}, s, !1), t(n));
|
|
5949
|
-
}).then(() =>
|
|
6013
|
+
}).then(() => xa(n).then((i) => {
|
|
5950
6014
|
s._dbref = i + 1;
|
|
5951
|
-
})).then(() =>
|
|
6015
|
+
})).then(() => ii(n).then((i) => {
|
|
5952
6016
|
s._dbsize = i;
|
|
5953
6017
|
})).then(() => n);
|
|
5954
|
-
},
|
|
5955
|
-
(e || s._dbsize >=
|
|
6018
|
+
}, Ua = (s, e = !0) => ci(s).then((t) => {
|
|
6019
|
+
(e || s._dbsize >= ai) && Kt(t, as(s.doc)).then(() => ri(t, Ma(s._dbref, !0))).then(() => ii(t).then((n) => {
|
|
5956
6020
|
s._dbsize = n;
|
|
5957
6021
|
}));
|
|
5958
6022
|
});
|
|
5959
|
-
class
|
|
6023
|
+
class Ta extends ft {
|
|
5960
6024
|
/**
|
|
5961
6025
|
* @param {string} name
|
|
5962
6026
|
* @param {Y.Doc} doc
|
|
5963
6027
|
*/
|
|
5964
6028
|
constructor(e, t) {
|
|
5965
|
-
super(), this.doc = t, this.name = e, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db =
|
|
6029
|
+
super(), this.doc = t, this.name = e, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = Sa(
|
|
5966
6030
|
e,
|
|
5967
|
-
(n) =>
|
|
6031
|
+
(n) => Da(n, [
|
|
5968
6032
|
["updates", { autoIncrement: !0 }],
|
|
5969
6033
|
["custom"]
|
|
5970
6034
|
])
|
|
5971
|
-
), this.whenSynced =
|
|
5972
|
-
this.db = n,
|
|
6035
|
+
), this.whenSynced = Ee((n) => this.on("synced", () => n(this))), this._db.then((n) => {
|
|
6036
|
+
this.db = n, ci(this, (o) => Kt(o, as(t)), () => {
|
|
5973
6037
|
if (this._destroyed)
|
|
5974
6038
|
return this;
|
|
5975
6039
|
this.synced = !0, this.emit("synced", [this]);
|
|
5976
6040
|
});
|
|
5977
6041
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (n, i) => {
|
|
5978
6042
|
if (this.db && i !== this) {
|
|
5979
|
-
const [r] =
|
|
6043
|
+
const [r] = Ie(
|
|
5980
6044
|
/** @type {IDBDatabase} */
|
|
5981
6045
|
this.db,
|
|
5982
|
-
[
|
|
6046
|
+
[oi]
|
|
5983
6047
|
);
|
|
5984
|
-
|
|
5985
|
-
|
|
6048
|
+
Kt(r, n), ++this._dbsize >= ai && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
|
|
6049
|
+
Ua(this, !1), this._storeTimeoutId = null;
|
|
5986
6050
|
}, this._storeTimeout));
|
|
5987
6051
|
}
|
|
5988
6052
|
}, t.on("update", this._storeUpdate), this.destroy = this.destroy.bind(this), t.on("destroy", this.destroy);
|
|
@@ -5999,7 +6063,7 @@ class Da extends ht {
|
|
|
5999
6063
|
*/
|
|
6000
6064
|
clearData() {
|
|
6001
6065
|
return this.destroy().then(() => {
|
|
6002
|
-
|
|
6066
|
+
_a(this.name);
|
|
6003
6067
|
});
|
|
6004
6068
|
}
|
|
6005
6069
|
/**
|
|
@@ -6008,8 +6072,8 @@ class Da extends ht {
|
|
|
6008
6072
|
*/
|
|
6009
6073
|
get(e) {
|
|
6010
6074
|
return this._db.then((t) => {
|
|
6011
|
-
const [n] =
|
|
6012
|
-
return
|
|
6075
|
+
const [n] = Ie(t, [zt], "readonly");
|
|
6076
|
+
return Ea(n, e);
|
|
6013
6077
|
});
|
|
6014
6078
|
}
|
|
6015
6079
|
/**
|
|
@@ -6019,8 +6083,8 @@ class Da extends ht {
|
|
|
6019
6083
|
*/
|
|
6020
6084
|
set(e, t) {
|
|
6021
6085
|
return this._db.then((n) => {
|
|
6022
|
-
const [i] =
|
|
6023
|
-
return
|
|
6086
|
+
const [i] = Ie(n, [zt]);
|
|
6087
|
+
return Ca(i, t, e);
|
|
6024
6088
|
});
|
|
6025
6089
|
}
|
|
6026
6090
|
/**
|
|
@@ -6029,15 +6093,15 @@ class Da extends ht {
|
|
|
6029
6093
|
*/
|
|
6030
6094
|
del(e) {
|
|
6031
6095
|
return this._db.then((t) => {
|
|
6032
|
-
const [n] =
|
|
6033
|
-
return
|
|
6096
|
+
const [n] = Ie(t, [zt]);
|
|
6097
|
+
return ri(n, e);
|
|
6034
6098
|
});
|
|
6035
6099
|
}
|
|
6036
6100
|
}
|
|
6037
|
-
function
|
|
6101
|
+
function Oa(s) {
|
|
6038
6102
|
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
6039
6103
|
}
|
|
6040
|
-
const
|
|
6104
|
+
const Ra = [
|
|
6041
6105
|
"2 girls 1 cup",
|
|
6042
6106
|
"2g1c",
|
|
6043
6107
|
"4r5e",
|
|
@@ -8863,48 +8927,48 @@ const Ca = [
|
|
|
8863
8927
|
"zoophilia",
|
|
8864
8928
|
"🖕"
|
|
8865
8929
|
];
|
|
8866
|
-
var
|
|
8867
|
-
const
|
|
8930
|
+
var Ba = Ra;
|
|
8931
|
+
const Na = /* @__PURE__ */ Oa(Ba), Fa = {
|
|
8868
8932
|
ctrlKey: "Control",
|
|
8869
8933
|
altKey: "Alt",
|
|
8870
8934
|
shiftKey: "Shift",
|
|
8871
8935
|
metaKey: "Meta"
|
|
8872
|
-
},
|
|
8936
|
+
}, Ha = "can-duplicate-to";
|
|
8873
8937
|
var j = /* @__PURE__ */ ((s) => (s.CanPlay = "can-play", s.CanMove = "can-move", s.CanSpin = "can-spin", s.CanGrow = "can-grow", s.CanToggle = "can-toggle", s.CanDuplicate = "can-duplicate", s.CanPost = "can-post", s))(j || {});
|
|
8874
|
-
function
|
|
8938
|
+
function Va(s) {
|
|
8875
8939
|
return s.id;
|
|
8876
8940
|
}
|
|
8877
|
-
function
|
|
8941
|
+
function li(s) {
|
|
8878
8942
|
return document.getElementById(s);
|
|
8879
8943
|
}
|
|
8880
|
-
const
|
|
8944
|
+
const hi = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='44' height='53' viewport='0 0 100 100' style='fill:black;font-size:26px;'><text y='40%'>🚿</text></svg>")
|
|
8881
8945
|
16 0,
|
|
8882
|
-
auto`,
|
|
8883
|
-
function
|
|
8946
|
+
auto`, $a = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;
|
|
8947
|
+
function Js(s, { getData: e, getElement: t, getLocalData: n, setLocalData: i }) {
|
|
8884
8948
|
const r = e(), o = n(), a = t();
|
|
8885
8949
|
if (o.isHovering = !0, s.altKey) {
|
|
8886
8950
|
if (r.scale <= 0.5) {
|
|
8887
8951
|
a.style.cursor = "not-allowed";
|
|
8888
8952
|
return;
|
|
8889
8953
|
}
|
|
8890
|
-
a.style.cursor =
|
|
8954
|
+
a.style.cursor = $a;
|
|
8891
8955
|
} else {
|
|
8892
8956
|
if (r.scale >= r.maxScale) {
|
|
8893
8957
|
a.style.cursor = "not-allowed";
|
|
8894
8958
|
return;
|
|
8895
8959
|
}
|
|
8896
|
-
a.style.cursor =
|
|
8960
|
+
a.style.cursor = hi;
|
|
8897
8961
|
}
|
|
8898
8962
|
i(o);
|
|
8899
8963
|
}
|
|
8900
|
-
function
|
|
8964
|
+
function Qe(s) {
|
|
8901
8965
|
if ("touches" in s) {
|
|
8902
8966
|
const { clientX: e, clientY: t } = s.touches[0];
|
|
8903
8967
|
return { clientX: e, clientY: t };
|
|
8904
8968
|
}
|
|
8905
8969
|
return { clientX: s.clientX, clientY: s.clientY };
|
|
8906
8970
|
}
|
|
8907
|
-
const
|
|
8971
|
+
const ui = {
|
|
8908
8972
|
[
|
|
8909
8973
|
"can-move"
|
|
8910
8974
|
/* CanMove */
|
|
@@ -8915,14 +8979,14 @@ const si = {
|
|
|
8915
8979
|
s.style.transform = `translate(${e.x}px, ${e.y}px)`;
|
|
8916
8980
|
},
|
|
8917
8981
|
onDragStart: (s, { setLocalData: e }) => {
|
|
8918
|
-
const { clientX: t, clientY: n } =
|
|
8982
|
+
const { clientX: t, clientY: n } = Qe(s);
|
|
8919
8983
|
e({
|
|
8920
8984
|
startMouseX: t,
|
|
8921
8985
|
startMouseY: n
|
|
8922
8986
|
});
|
|
8923
8987
|
},
|
|
8924
8988
|
onDrag: (s, { data: e, localData: t, setData: n, setLocalData: i, element: r }) => {
|
|
8925
|
-
const { clientX: o, clientY: a } =
|
|
8989
|
+
const { clientX: o, clientY: a } = Qe(s), { top: c, left: l, bottom: h, right: u } = r.getBoundingClientRect();
|
|
8926
8990
|
u > window.outerWidth && o > t.startMouseX || h > window.innerHeight && a > t.startMouseY || l < 0 && o < t.startMouseX || c < 0 && a < t.startMouseY || (n({
|
|
8927
8991
|
x: e.x + o - t.startMouseX,
|
|
8928
8992
|
y: e.y + a - t.startMouseY
|
|
@@ -8940,13 +9004,13 @@ const si = {
|
|
|
8940
9004
|
s.style.transform = `rotate(${e.rotation}deg)`;
|
|
8941
9005
|
},
|
|
8942
9006
|
onDragStart: (s, { setLocalData: e }) => {
|
|
8943
|
-
const { clientX: t } =
|
|
9007
|
+
const { clientX: t } = Qe(s);
|
|
8944
9008
|
e({
|
|
8945
9009
|
startMouseX: t
|
|
8946
9010
|
});
|
|
8947
9011
|
},
|
|
8948
9012
|
onDrag: (s, { data: e, localData: t, setData: n, setLocalData: i }) => {
|
|
8949
|
-
const { clientX: r } =
|
|
9013
|
+
const { clientX: r } = Qe(s);
|
|
8950
9014
|
let o = Math.abs(r - t.startMouseX) * 2, a = e.rotation;
|
|
8951
9015
|
r > t.startMouseX ? a += o : r < t.startMouseX && (a -= o), n({ rotation: a }), i({ startMouseX: r });
|
|
8952
9016
|
},
|
|
@@ -8981,7 +9045,7 @@ const si = {
|
|
|
8981
9045
|
return;
|
|
8982
9046
|
r -= 0.1;
|
|
8983
9047
|
} else {
|
|
8984
|
-
if (t.style.cursor =
|
|
9048
|
+
if (t.style.cursor = hi, e.scale >= i.maxScale)
|
|
8985
9049
|
return;
|
|
8986
9050
|
r += 0.1;
|
|
8987
9051
|
}
|
|
@@ -8989,8 +9053,8 @@ const si = {
|
|
|
8989
9053
|
},
|
|
8990
9054
|
additionalSetup: (s) => {
|
|
8991
9055
|
s.getElement().addEventListener("mouseenter", (e) => {
|
|
8992
|
-
|
|
8993
|
-
const t = (n) =>
|
|
9056
|
+
Js(e, s);
|
|
9057
|
+
const t = (n) => Js(n, s);
|
|
8994
9058
|
document.addEventListener("keydown", t), document.addEventListener("keyup", t), s.getElement().addEventListener("mouseleave", (n) => {
|
|
8995
9059
|
document.removeEventListener("keydown", t), document.removeEventListener("keyup", t);
|
|
8996
9060
|
});
|
|
@@ -9012,7 +9076,7 @@ const si = {
|
|
|
9012
9076
|
}) => {
|
|
9013
9077
|
const n = s.filter(
|
|
9014
9078
|
(r) => !e.has(r.id)
|
|
9015
|
-
), i =
|
|
9079
|
+
), i = li("guestbookMessages");
|
|
9016
9080
|
n.forEach((r) => {
|
|
9017
9081
|
const o = document.createElement("div");
|
|
9018
9082
|
o.classList.add("guestbook-entry");
|
|
@@ -9036,7 +9100,7 @@ const si = {
|
|
|
9036
9100
|
const c = Object.fromEntries(o.entries());
|
|
9037
9101
|
if (!c.name)
|
|
9038
9102
|
return a(), !1;
|
|
9039
|
-
if (
|
|
9103
|
+
if (Na.some((u) => {
|
|
9040
9104
|
const d = new RegExp(`\\b${u}\\b`, "gi");
|
|
9041
9105
|
return d.test(c.message) || d.test(c.name);
|
|
9042
9106
|
}))
|
|
@@ -9074,7 +9138,7 @@ const si = {
|
|
|
9074
9138
|
);
|
|
9075
9139
|
return;
|
|
9076
9140
|
}
|
|
9077
|
-
const c = n.getAttribute(
|
|
9141
|
+
const c = n.getAttribute(Ha);
|
|
9078
9142
|
function l(u) {
|
|
9079
9143
|
if (c) {
|
|
9080
9144
|
const d = document.getElementById(c) || document.querySelector(c);
|
|
@@ -9105,13 +9169,13 @@ const si = {
|
|
|
9105
9169
|
n([...e, i]);
|
|
9106
9170
|
}
|
|
9107
9171
|
}
|
|
9108
|
-
},
|
|
9172
|
+
}, Ws = (s, e = 300) => {
|
|
9109
9173
|
let t;
|
|
9110
9174
|
return function(...n) {
|
|
9111
9175
|
clearTimeout(t), t = setTimeout(() => s.apply(this, n), e);
|
|
9112
9176
|
};
|
|
9113
9177
|
};
|
|
9114
|
-
class
|
|
9178
|
+
class qa {
|
|
9115
9179
|
constructor(e) {
|
|
9116
9180
|
b(this, "defaultData");
|
|
9117
9181
|
b(this, "localData");
|
|
@@ -9147,11 +9211,11 @@ class Ma {
|
|
|
9147
9211
|
debounceMs: f,
|
|
9148
9212
|
triggerAwarenessUpdate: g
|
|
9149
9213
|
} = e;
|
|
9150
|
-
this.element = t, this.defaultData = r instanceof Function ? r(t) : r, this.localData = o instanceof Function ? o(t) : o, this.triggerAwarenessUpdate = g, this.onChange = n, this.debouncedOnChange =
|
|
9214
|
+
this.element = t, this.defaultData = r instanceof Function ? r(t) : r, this.localData = o instanceof Function ? o(t) : o, this.triggerAwarenessUpdate = g, this.onChange = n, this.debouncedOnChange = Ws(this.onChange, f), this.onAwarenessChange = i, this.updateElement = h, this.updateElementAwareness = u;
|
|
9151
9215
|
const k = c === void 0 ? this.defaultData : c;
|
|
9152
9216
|
l !== void 0 && (this.__awareness = l);
|
|
9153
|
-
const
|
|
9154
|
-
|
|
9217
|
+
const _ = a instanceof Function ? a(t) : a;
|
|
9218
|
+
_ !== void 0 && this.setLocalAwareness(_), this._data = k, this.__data = k, this.reinitializeElementData(e), d && d(this.getSetupData());
|
|
9155
9219
|
}
|
|
9156
9220
|
reinitializeElementData({
|
|
9157
9221
|
element: e,
|
|
@@ -9166,30 +9230,30 @@ class Ma {
|
|
|
9166
9230
|
debounceMs: h,
|
|
9167
9231
|
triggerAwarenessUpdate: u
|
|
9168
9232
|
}) {
|
|
9169
|
-
this.triggerAwarenessUpdate = u, this.onChange = t, this.resetShortcut = l, this.debouncedOnChange =
|
|
9233
|
+
this.triggerAwarenessUpdate = u, this.onChange = t, this.resetShortcut = l, this.debouncedOnChange = Ws(this.onChange, h), this.onAwarenessChange = n, this.updateElement = i, this.updateElementAwareness = r, o && !this.onClick && e.addEventListener("click", (d) => {
|
|
9170
9234
|
var f;
|
|
9171
9235
|
(f = this.onClick) == null || f.call(this, d, this.getEventHandlerData());
|
|
9172
9236
|
}), this.onClick = o, a && !this.onDrag && (e.addEventListener("touchstart", (d) => {
|
|
9173
9237
|
var k;
|
|
9174
9238
|
d.preventDefault(), (k = this.onDragStart) == null || k.call(this, d, this.getEventHandlerData());
|
|
9175
|
-
const f = (
|
|
9239
|
+
const f = (_) => {
|
|
9176
9240
|
var $;
|
|
9177
|
-
|
|
9178
|
-
}, g = (
|
|
9241
|
+
_.preventDefault(), ($ = this.onDrag) == null || $.call(this, _, this.getEventHandlerData());
|
|
9242
|
+
}, g = (_) => {
|
|
9179
9243
|
document.removeEventListener("touchmove", f), document.removeEventListener("touchend", g);
|
|
9180
9244
|
};
|
|
9181
9245
|
document.addEventListener("touchmove", f), document.addEventListener("touchend", g);
|
|
9182
9246
|
}), e.addEventListener("mousedown", (d) => {
|
|
9183
9247
|
var k;
|
|
9184
9248
|
(k = this.onDragStart) == null || k.call(this, d, this.getEventHandlerData());
|
|
9185
|
-
const f = (
|
|
9249
|
+
const f = (_) => {
|
|
9186
9250
|
var $;
|
|
9187
|
-
|
|
9188
|
-
}, g = (
|
|
9251
|
+
_.preventDefault(), ($ = this.onDrag) == null || $.call(this, _, this.getEventHandlerData());
|
|
9252
|
+
}, g = (_) => {
|
|
9189
9253
|
document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", g);
|
|
9190
9254
|
};
|
|
9191
9255
|
document.addEventListener("mousemove", f), document.addEventListener("mouseup", g);
|
|
9192
|
-
})), this.onDrag = a, this.onDragStart = c, l && !this.resetShortcut && (e.title || (e.title = `Hold down the ${
|
|
9256
|
+
})), this.onDrag = a, this.onDragStart = c, l && !this.resetShortcut && (e.title || (e.title = `Hold down the ${Fa[l]} key while clicking to reset.`), e.reset = this.reset, e.addEventListener("click", (d) => {
|
|
9193
9257
|
switch (this.resetShortcut) {
|
|
9194
9258
|
case "ctrlKey":
|
|
9195
9259
|
if (!d.ctrlKey)
|
|
@@ -9280,20 +9344,23 @@ class Ma {
|
|
|
9280
9344
|
this.setData(this.defaultData);
|
|
9281
9345
|
}
|
|
9282
9346
|
}
|
|
9283
|
-
const
|
|
9284
|
-
|
|
9285
|
-
|
|
9286
|
-
|
|
9287
|
-
|
|
9347
|
+
const Ka = "playhtml.spencerc99.partykit.dev", Ut = new pe();
|
|
9348
|
+
function Ya() {
|
|
9349
|
+
return window.location.pathname + window.location.search;
|
|
9350
|
+
}
|
|
9351
|
+
let Y, B, N;
|
|
9352
|
+
const Gs = /* @__PURE__ */ new Map();
|
|
9353
|
+
let bs = !1, Yt = !0;
|
|
9354
|
+
function di({
|
|
9288
9355
|
// TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
|
|
9289
|
-
room: s =
|
|
9290
|
-
host: e =
|
|
9356
|
+
room: s = Ya(),
|
|
9357
|
+
host: e = Ka
|
|
9291
9358
|
} = {}) {
|
|
9292
|
-
if (
|
|
9359
|
+
if (!Yt) {
|
|
9293
9360
|
console.error("playhtml already set up!");
|
|
9294
9361
|
return;
|
|
9295
9362
|
}
|
|
9296
|
-
const t = e;
|
|
9363
|
+
const t = encodeURIComponent(window.location.hostname + "-" + s), n = e;
|
|
9297
9364
|
return console.log(
|
|
9298
9365
|
`࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂
|
|
9299
9366
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
@@ -9301,46 +9368,46 @@ function ni({
|
|
|
9301
9368
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
9302
9369
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
9303
9370
|
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
|
|
9304
|
-
),
|
|
9305
|
-
|
|
9306
|
-
}),
|
|
9371
|
+
), Y = new ya(n, t, Ut), B = Ut.getMap("playhtml-global"), N = /* @__PURE__ */ new Map(), new Ta(t, Ut), Xt.globalData = B, Xt.elementHandlers = N, Y.on("sync", (i) => {
|
|
9372
|
+
i || console.error("Issue connecting to yjs..."), bs = !0, Pa();
|
|
9373
|
+
}), Y;
|
|
9307
9374
|
}
|
|
9308
9375
|
setTimeout(() => {
|
|
9309
|
-
|
|
9376
|
+
Y || (console.error(
|
|
9310
9377
|
"You are using a deprecated version of playhtml. Please call `playhtml.init()` explicitly rather than just importing the library. Refer to https://github.com/spencerc99/playhtml#usage for reference."
|
|
9311
|
-
),
|
|
9378
|
+
), di());
|
|
9312
9379
|
}, 3e3);
|
|
9313
|
-
function
|
|
9314
|
-
const t =
|
|
9380
|
+
function Xa(s, e) {
|
|
9381
|
+
const t = Y.awareness.getLocalState();
|
|
9315
9382
|
return ((t == null ? void 0 : t[s]) ?? {})[e];
|
|
9316
9383
|
}
|
|
9317
|
-
function
|
|
9384
|
+
function ws(s) {
|
|
9318
9385
|
return s instanceof HTMLElement;
|
|
9319
9386
|
}
|
|
9320
|
-
function
|
|
9387
|
+
function Ja(s, e, t, n) {
|
|
9321
9388
|
const i = B.get(e);
|
|
9322
9389
|
return {
|
|
9323
9390
|
...t,
|
|
9324
9391
|
data: i.get(n) ?? t.defaultData,
|
|
9325
|
-
awareness:
|
|
9392
|
+
awareness: Xa(e, n) ?? t.myDefaultAwareness !== void 0 ? [t.myDefaultAwareness] : void 0,
|
|
9326
9393
|
element: s,
|
|
9327
9394
|
onChange: (o) => {
|
|
9328
9395
|
i.get(n) !== o && i.set(n, o);
|
|
9329
9396
|
},
|
|
9330
9397
|
onAwarenessChange: (o) => {
|
|
9331
9398
|
var c;
|
|
9332
|
-
const a = ((c =
|
|
9333
|
-
a[n] !== o && (a[n] = o,
|
|
9399
|
+
const a = ((c = Y.awareness.getLocalState()) == null ? void 0 : c[e]) || {};
|
|
9400
|
+
a[n] !== o && (a[n] = o, Y.awareness.setLocalStateField(e, a));
|
|
9334
9401
|
},
|
|
9335
9402
|
triggerAwarenessUpdate: () => {
|
|
9336
|
-
|
|
9403
|
+
fi();
|
|
9337
9404
|
}
|
|
9338
9405
|
};
|
|
9339
9406
|
}
|
|
9340
|
-
function
|
|
9407
|
+
function Wa(s) {
|
|
9341
9408
|
return s.defaultData !== void 0 && s.updateElement !== void 0;
|
|
9342
9409
|
}
|
|
9343
|
-
function
|
|
9410
|
+
function Ga(s, e) {
|
|
9344
9411
|
if (s === j.CanPlay) {
|
|
9345
9412
|
const t = e;
|
|
9346
9413
|
return {
|
|
@@ -9357,16 +9424,16 @@ function Ba(s, e) {
|
|
|
9357
9424
|
debounceMs: t.debounceMs
|
|
9358
9425
|
};
|
|
9359
9426
|
}
|
|
9360
|
-
return
|
|
9427
|
+
return ui[s];
|
|
9361
9428
|
}
|
|
9362
|
-
function
|
|
9429
|
+
function fi() {
|
|
9363
9430
|
const s = /* @__PURE__ */ new Map();
|
|
9364
9431
|
function e(t, n, i, r) {
|
|
9365
9432
|
s.has(t) || s.set(t, /* @__PURE__ */ new Map());
|
|
9366
9433
|
const o = s.get(t);
|
|
9367
9434
|
o.has(n) || o.set(n, /* @__PURE__ */ new Map()), o.get(n).set(i, r);
|
|
9368
9435
|
}
|
|
9369
|
-
|
|
9436
|
+
Y.awareness.getStates().forEach((t, n) => {
|
|
9370
9437
|
var i;
|
|
9371
9438
|
for (const [r, o] of Object.entries(t)) {
|
|
9372
9439
|
const a = N.get(r);
|
|
@@ -9396,48 +9463,48 @@ function ii() {
|
|
|
9396
9463
|
}
|
|
9397
9464
|
});
|
|
9398
9465
|
}
|
|
9399
|
-
function
|
|
9466
|
+
function Pa() {
|
|
9400
9467
|
console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝");
|
|
9401
9468
|
for (const s of Object.values(j)) {
|
|
9402
9469
|
const e = Array.from(
|
|
9403
9470
|
document.querySelectorAll(`[${s}]`)
|
|
9404
|
-
).filter(
|
|
9471
|
+
).filter(ws);
|
|
9405
9472
|
if (e.length)
|
|
9406
9473
|
for (let t = 0; t < e.length; t++) {
|
|
9407
9474
|
const n = e[t];
|
|
9408
|
-
|
|
9475
|
+
St(n, s);
|
|
9409
9476
|
}
|
|
9410
9477
|
}
|
|
9411
|
-
|
|
9478
|
+
Yt && (B.observe((s) => {
|
|
9412
9479
|
s.changes.keys.forEach((e, t) => {
|
|
9413
9480
|
e.action === "add" && B.set(t, B.get(t));
|
|
9414
9481
|
});
|
|
9415
|
-
}),
|
|
9482
|
+
}), Y.awareness.on("change", () => fi()), Yt = !1);
|
|
9416
9483
|
}
|
|
9417
|
-
const
|
|
9418
|
-
init:
|
|
9419
|
-
setupPlayElement:
|
|
9420
|
-
removePlayElement:
|
|
9421
|
-
setupPlayElementForTag:
|
|
9484
|
+
const Xt = {
|
|
9485
|
+
init: di,
|
|
9486
|
+
setupPlayElement: ec,
|
|
9487
|
+
removePlayElement: tc,
|
|
9488
|
+
setupPlayElementForTag: St,
|
|
9422
9489
|
globalData: void 0,
|
|
9423
9490
|
elementHandlers: void 0
|
|
9424
9491
|
};
|
|
9425
|
-
window.playhtml =
|
|
9426
|
-
function
|
|
9427
|
-
if (N.has(s) || !
|
|
9492
|
+
window.playhtml = Xt;
|
|
9493
|
+
function Za(s) {
|
|
9494
|
+
if (N.has(s) || !bs)
|
|
9428
9495
|
return;
|
|
9429
|
-
N.set(s, /* @__PURE__ */ new Map()), s !== j.CanPlay &&
|
|
9496
|
+
N.set(s, /* @__PURE__ */ new Map()), s !== j.CanPlay && ui[s], B.get(s) || B.set(s, new ue());
|
|
9430
9497
|
const e = B.get(s);
|
|
9431
9498
|
e.observe((t) => {
|
|
9432
9499
|
t.changes.keys.forEach((n, i) => {
|
|
9433
9500
|
const r = N.get(s);
|
|
9434
9501
|
if (n.action === "add") {
|
|
9435
|
-
const o =
|
|
9436
|
-
if (!
|
|
9502
|
+
const o = li(i);
|
|
9503
|
+
if (!ws(o)) {
|
|
9437
9504
|
console.log(`Element ${i} not an HTML element. Ignoring.`);
|
|
9438
9505
|
return;
|
|
9439
9506
|
}
|
|
9440
|
-
|
|
9507
|
+
St(o, s);
|
|
9441
9508
|
} else if (n.action === "update") {
|
|
9442
9509
|
const o = r.get(i);
|
|
9443
9510
|
o.__data = e.get(i);
|
|
@@ -9446,7 +9513,7 @@ function Fa(s) {
|
|
|
9446
9513
|
});
|
|
9447
9514
|
});
|
|
9448
9515
|
}
|
|
9449
|
-
function
|
|
9516
|
+
function Qa(s, e) {
|
|
9450
9517
|
const t = s.getAttribute(e);
|
|
9451
9518
|
switch (e) {
|
|
9452
9519
|
case j.CanPlay:
|
|
@@ -9464,37 +9531,37 @@ function Ha(s, e) {
|
|
|
9464
9531
|
return console.error(`Unhandled tag found in validation: ${e}`), !1;
|
|
9465
9532
|
}
|
|
9466
9533
|
}
|
|
9467
|
-
function
|
|
9534
|
+
function St(s, e) {
|
|
9468
9535
|
var a;
|
|
9469
|
-
if (!
|
|
9536
|
+
if (!Qa(s, e) || !bs)
|
|
9470
9537
|
return;
|
|
9471
9538
|
if (!s.id) {
|
|
9472
9539
|
const c = s.getAttribute("selector-id");
|
|
9473
9540
|
if (c) {
|
|
9474
|
-
const l =
|
|
9475
|
-
s.id = btoa(`${e}-${c}-${l}`),
|
|
9541
|
+
const l = Gs.get(c) ?? 0;
|
|
9542
|
+
s.id = btoa(`${e}-${c}-${l}`), Gs.set(c, l + 1);
|
|
9476
9543
|
} else
|
|
9477
9544
|
s.id = btoa(`${e}-${s.innerHTML}}`);
|
|
9478
9545
|
}
|
|
9479
|
-
const t =
|
|
9546
|
+
const t = Va(s);
|
|
9480
9547
|
if (!t) {
|
|
9481
9548
|
console.error(
|
|
9482
9549
|
`Element ${s} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`
|
|
9483
9550
|
);
|
|
9484
9551
|
return;
|
|
9485
9552
|
}
|
|
9486
|
-
|
|
9487
|
-
const n = N.get(e), i =
|
|
9553
|
+
Za(e);
|
|
9554
|
+
const n = N.get(e), i = Ga(
|
|
9488
9555
|
e,
|
|
9489
9556
|
s
|
|
9490
9557
|
);
|
|
9491
|
-
if (!
|
|
9558
|
+
if (!Wa(i)) {
|
|
9492
9559
|
console.error(
|
|
9493
9560
|
`Element ${t} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`
|
|
9494
9561
|
);
|
|
9495
9562
|
return;
|
|
9496
9563
|
}
|
|
9497
|
-
const r = B.get(e), o =
|
|
9564
|
+
const r = B.get(e), o = Ja(
|
|
9498
9565
|
s,
|
|
9499
9566
|
e,
|
|
9500
9567
|
i,
|
|
@@ -9504,18 +9571,18 @@ function bt(s, e) {
|
|
|
9504
9571
|
n.get(t).reinitializeElementData(o);
|
|
9505
9572
|
return;
|
|
9506
9573
|
} else
|
|
9507
|
-
n.set(t, new
|
|
9574
|
+
n.set(t, new qa(o));
|
|
9508
9575
|
r.get(t) === void 0 && i.defaultData !== void 0 && r.set(t, i.defaultData), (a = o.triggerAwarenessUpdate) == null || a.call(o), s.classList.add("__playhtml-element"), s.classList.add(`__playhtml-${e}`), s.style.setProperty("--jiggle-delay", `${Math.random() * 1}s;}`);
|
|
9509
9576
|
}
|
|
9510
|
-
function
|
|
9511
|
-
if (!
|
|
9577
|
+
function ec(s) {
|
|
9578
|
+
if (!ws(s)) {
|
|
9512
9579
|
console.log(`Element ${s.id} not an HTML element. Ignoring.`);
|
|
9513
9580
|
return;
|
|
9514
9581
|
}
|
|
9515
9582
|
for (const e of Object.values(j))
|
|
9516
|
-
s.hasAttribute(e) &&
|
|
9583
|
+
s.hasAttribute(e) && St(s, e);
|
|
9517
9584
|
}
|
|
9518
|
-
function
|
|
9585
|
+
function tc(s) {
|
|
9519
9586
|
if (!(!s || !s.id))
|
|
9520
9587
|
for (const e of Object.keys(N)) {
|
|
9521
9588
|
const t = N.get(e);
|
|
@@ -9523,5 +9590,5 @@ function $a(s) {
|
|
|
9523
9590
|
}
|
|
9524
9591
|
}
|
|
9525
9592
|
export {
|
|
9526
|
-
|
|
9593
|
+
Xt as playhtml
|
|
9527
9594
|
};
|