playhtml 2.0.12 → 2.0.14
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/CHANGELOG.md +8 -0
- package/README.md +21 -6
- package/dist/init.cjs.js +1 -0
- package/dist/init.d.ts +1 -0
- package/dist/init.es.js +6 -0
- package/dist/main.d.ts +10 -1
- package/dist/playhtml.cjs.js +11 -0
- package/dist/playhtml.es.js +491 -494
- package/package.json +4 -3
- package/dist/playhtml.umd.js +0 -11
package/dist/playhtml.es.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
var gr = Object.defineProperty;
|
|
2
2
|
var pr = (n, t, e) => t in n ? gr(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var y = (n, t, e) => (pr(n, typeof t != "symbol" ? t + "" : t, e), e),
|
|
3
|
+
var y = (n, t, e) => (pr(n, typeof t != "symbol" ? t + "" : t, e), e), Sn = (n, t, e) => {
|
|
4
4
|
if (!t.has(n))
|
|
5
5
|
throw TypeError("Cannot " + e);
|
|
6
6
|
};
|
|
7
|
-
var Wt = (n, t, e) => (
|
|
7
|
+
var Wt = (n, t, e) => (Sn(n, t, "read from private field"), e ? e.call(n) : t.get(n)), Dn = (n, t, e) => {
|
|
8
8
|
if (t.has(n))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(n) : t.set(n, e);
|
|
11
|
-
},
|
|
12
|
-
var Gt = 1e6, wr = "y-pk-batch",
|
|
11
|
+
}, En = (n, t, e, s) => (Sn(n, t, "write to private field"), s ? s.call(n, e) : t.set(n, e), e);
|
|
12
|
+
var Gt = 1e6, wr = "y-pk-batch", Cn = !1, mr = (n, t) => {
|
|
13
13
|
if (n.byteLength <= Gt) {
|
|
14
14
|
t(n);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
Cn || (console.warn(
|
|
18
18
|
"[y-partykit]",
|
|
19
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
20
|
`Message size: ${(n.byteLength / 1e3 / 1e3).toFixed(1)}MB`
|
|
21
|
-
),
|
|
21
|
+
), Cn = !0);
|
|
22
22
|
const e = (Date.now() + Math.random()).toString(36).substring(10), s = Math.ceil(n.byteLength / Gt);
|
|
23
23
|
t(
|
|
24
|
-
|
|
24
|
+
An({
|
|
25
25
|
id: e,
|
|
26
26
|
type: "start",
|
|
27
27
|
size: n.byteLength,
|
|
@@ -34,7 +34,7 @@ var Gt = 1e6, wr = "y-pk-batch", An = !1, mr = (n, t) => {
|
|
|
34
34
|
t(l), i += 1, r += l.byteLength;
|
|
35
35
|
}
|
|
36
36
|
t(
|
|
37
|
-
|
|
37
|
+
An({
|
|
38
38
|
id: e,
|
|
39
39
|
type: "end",
|
|
40
40
|
size: r,
|
|
@@ -42,15 +42,15 @@ var Gt = 1e6, wr = "y-pk-batch", An = !1, mr = (n, t) => {
|
|
|
42
42
|
})
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
-
function
|
|
45
|
+
function An(n) {
|
|
46
46
|
return `${wr}#${JSON.stringify(n)}`;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
49
|
-
const t =
|
|
48
|
+
const R = () => /* @__PURE__ */ new Map(), Be = (n) => {
|
|
49
|
+
const t = R();
|
|
50
50
|
return n.forEach((e, s) => {
|
|
51
51
|
t.set(s, e);
|
|
52
52
|
}), t;
|
|
53
|
-
},
|
|
53
|
+
}, J = (n, t, e) => {
|
|
54
54
|
let s = n.get(t);
|
|
55
55
|
return s === void 0 && n.set(t, s = e()), s;
|
|
56
56
|
}, yr = (n, t) => {
|
|
@@ -69,14 +69,14 @@ const O = () => /* @__PURE__ */ new Map(), Be = (n) => {
|
|
|
69
69
|
}, tt = Array.from, _r = Array.isArray;
|
|
70
70
|
class fe {
|
|
71
71
|
constructor() {
|
|
72
|
-
this._observers =
|
|
72
|
+
this._observers = R();
|
|
73
73
|
}
|
|
74
74
|
/**
|
|
75
75
|
* @param {N} name
|
|
76
76
|
* @param {function} f
|
|
77
77
|
*/
|
|
78
78
|
on(t, e) {
|
|
79
|
-
|
|
79
|
+
J(this._observers, t, lt).add(e);
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* @param {N} name
|
|
@@ -106,13 +106,13 @@ class fe {
|
|
|
106
106
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
107
107
|
*/
|
|
108
108
|
emit(t, e) {
|
|
109
|
-
return tt((this._observers.get(t) ||
|
|
109
|
+
return tt((this._observers.get(t) || R()).values()).forEach((s) => s(...e));
|
|
110
110
|
}
|
|
111
111
|
destroy() {
|
|
112
|
-
this._observers =
|
|
112
|
+
this._observers = R();
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
const
|
|
115
|
+
const Y = Math.floor, te = Math.abs, Ge = (n, t) => n < t ? n : t, ft = (n, t) => n > t ? n : t, Sr = Math.pow, ts = (n) => n !== 0 ? n < 0 : 1 / n < 0, Dr = String.fromCharCode, Er = (n) => n.toLowerCase(), Cr = /^\s*/g, Ar = (n) => n.replace(Cr, ""), Lr = /([A-Z])/g, Ln = (n, t) => Ar(n.replace(Lr, (e) => `${t}${Er(e)}`)), Ir = (n) => {
|
|
116
116
|
const t = unescape(encodeURIComponent(n)), e = t.length, s = new Uint8Array(e);
|
|
117
117
|
for (let r = 0; r < e; r++)
|
|
118
118
|
s[r] = /** @type {number} */
|
|
@@ -121,10 +121,10 @@ const X = Math.floor, te = Math.abs, Pe = (n, t) => n < t ? n : t, ft = (n, t) =
|
|
|
121
121
|
}, Tt = (
|
|
122
122
|
/** @type {TextEncoder} */
|
|
123
123
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
124
|
-
),
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
const
|
|
124
|
+
), Mr = (n) => Tt.encode(n), vr = Tt ? Mr : Ir;
|
|
125
|
+
let vt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
126
|
+
vt && vt.decode(new Uint8Array()).length === 1 && (vt = null);
|
|
127
|
+
const In = (n) => n === void 0 ? null : n;
|
|
128
128
|
class xr {
|
|
129
129
|
constructor() {
|
|
130
130
|
this.map = /* @__PURE__ */ new Map();
|
|
@@ -143,16 +143,16 @@ class xr {
|
|
|
143
143
|
return this.map.get(t);
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
|
-
let
|
|
146
|
+
let es = new xr(), Pe = !0;
|
|
147
147
|
try {
|
|
148
|
-
typeof localStorage < "u" && (
|
|
148
|
+
typeof localStorage < "u" && (es = localStorage, Pe = !1);
|
|
149
149
|
} catch {
|
|
150
150
|
}
|
|
151
|
-
const
|
|
151
|
+
const ns = es, Ur = (n) => Pe || addEventListener(
|
|
152
152
|
"storage",
|
|
153
153
|
/** @type {any} */
|
|
154
154
|
n
|
|
155
|
-
), Tr = (n) =>
|
|
155
|
+
), Tr = (n) => Pe || removeEventListener(
|
|
156
156
|
"storage",
|
|
157
157
|
/** @type {any} */
|
|
158
158
|
n
|
|
@@ -173,12 +173,12 @@ const ss = ns, Ur = (n) => qe || addEventListener(
|
|
|
173
173
|
if (!t(n[e], e))
|
|
174
174
|
return !1;
|
|
175
175
|
return !0;
|
|
176
|
-
},
|
|
176
|
+
}, ss = (n, t) => Object.prototype.hasOwnProperty.call(n, t), Hr = (n, t) => n === t || re(n) === re(t) && Vr(n, (e, s) => (e !== void 0 || ss(t, s)) && t[s] === e), qe = (n, t, e = 0) => {
|
|
177
177
|
try {
|
|
178
178
|
for (; e < n.length; e++)
|
|
179
179
|
n[e](...t);
|
|
180
180
|
} finally {
|
|
181
|
-
e < n.length &&
|
|
181
|
+
e < n.length && qe(n, t, e + 1);
|
|
182
182
|
}
|
|
183
183
|
}, $r = (n) => n, jr = (n, t) => n === t, xt = (n, t) => {
|
|
184
184
|
if (n == null || t == null)
|
|
@@ -218,7 +218,7 @@ const ss = ns, Ur = (n) => qe || addEventListener(
|
|
|
218
218
|
if (re(n) !== re(t))
|
|
219
219
|
return !1;
|
|
220
220
|
for (const e in n)
|
|
221
|
-
if (!
|
|
221
|
+
if (!ss(n, e) || !xt(n[e], t[e]))
|
|
222
222
|
return !1;
|
|
223
223
|
break;
|
|
224
224
|
case Array:
|
|
@@ -232,34 +232,34 @@ const ss = ns, Ur = (n) => qe || addEventListener(
|
|
|
232
232
|
return !1;
|
|
233
233
|
}
|
|
234
234
|
return !0;
|
|
235
|
-
}, Kr = (n, t) => t.includes(n), _t = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name),
|
|
236
|
-
let
|
|
235
|
+
}, Kr = (n, t) => t.includes(n), _t = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), rs = typeof window < "u" && typeof document < "u" && !_t;
|
|
236
|
+
let B;
|
|
237
237
|
const zr = () => {
|
|
238
|
-
if (
|
|
238
|
+
if (B === void 0)
|
|
239
239
|
if (_t) {
|
|
240
|
-
|
|
240
|
+
B = R();
|
|
241
241
|
const n = process.argv;
|
|
242
242
|
let t = null;
|
|
243
243
|
for (let e = 0; e < n.length; e++) {
|
|
244
244
|
const s = n[e];
|
|
245
|
-
s[0] === "-" ? (t !== null &&
|
|
245
|
+
s[0] === "-" ? (t !== null && B.set(t, ""), t = s) : t !== null && (B.set(t, s), t = null);
|
|
246
246
|
}
|
|
247
|
-
t !== null &&
|
|
247
|
+
t !== null && B.set(t, "");
|
|
248
248
|
} else
|
|
249
|
-
typeof location == "object" ? (
|
|
249
|
+
typeof location == "object" ? (B = R(), (location.search || "?").slice(1).split("&").forEach((n) => {
|
|
250
250
|
if (n.length !== 0) {
|
|
251
251
|
const [t, e] = n.split("=");
|
|
252
|
-
|
|
252
|
+
B.set(`--${Ln(t, "-")}`, e), B.set(`-${Ln(t, "-")}`, e);
|
|
253
253
|
}
|
|
254
|
-
})) :
|
|
255
|
-
return
|
|
256
|
-
}, Ne = (n) => zr().has(n), Fe = (n) =>
|
|
254
|
+
})) : B = R();
|
|
255
|
+
return B;
|
|
256
|
+
}, Ne = (n) => zr().has(n), Fe = (n) => In(_t ? process.env[n.toUpperCase()] : ns.getItem(n)), Yr = (n) => Ne("--" + n) || Fe(n) !== null;
|
|
257
257
|
Yr("production");
|
|
258
|
-
const Mn = _t && Kr(process.env.FORCE_COLOR, ["true", "1", "2"]), Xr = !Ne("no-colors") && (!_t || process.stdout.isTTY || Mn) && (!_t || Ne("color") || Mn || Fe("COLORTERM") !== null || (Fe("TERM") || "").includes("color")),
|
|
259
|
-
throw
|
|
258
|
+
const Mn = _t && Kr(process.env.FORCE_COLOR, ["true", "1", "2"]), Xr = !Ne("no-colors") && (!_t || process.stdout.isTTY || Mn) && (!_t || Ne("color") || Mn || Fe("COLORTERM") !== null || (Fe("TERM") || "").includes("color")), vn = 1, xn = 2, Ee = 4, Ce = 8, Ot = 32, z = 64, x = 128, ge = 31, Ve = 63, it = 127, Jr = 2147483647, is = Number.MAX_SAFE_INTEGER, Wr = Number.isInteger || ((n) => typeof n == "number" && isFinite(n) && Y(n) === n), X = (n) => new Error(n), N = () => {
|
|
259
|
+
throw X("Method unimplemented");
|
|
260
260
|
}, V = () => {
|
|
261
|
-
throw
|
|
262
|
-
},
|
|
261
|
+
throw X("Unexpected case");
|
|
262
|
+
}, os = X("Unexpected end of array"), ls = X("Integer out of Range");
|
|
263
263
|
class pe {
|
|
264
264
|
/**
|
|
265
265
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
@@ -269,20 +269,20 @@ class pe {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
const nt = (n) => new pe(n), Gr = (n) => n.pos !== n.arr.length, Pr = (n, t) => {
|
|
272
|
-
const e =
|
|
272
|
+
const e = tn(n.arr.buffer, n.pos + n.arr.byteOffset, t);
|
|
273
273
|
return n.pos += t, e;
|
|
274
|
-
},
|
|
274
|
+
}, M = (n) => Pr(n, m(n)), St = (n) => n.arr[n.pos++], m = (n) => {
|
|
275
275
|
let t = 0, e = 1;
|
|
276
276
|
const s = n.arr.length;
|
|
277
277
|
for (; n.pos < s; ) {
|
|
278
278
|
const r = n.arr[n.pos++];
|
|
279
279
|
if (t = t + (r & it) * e, e *= 128, r < x)
|
|
280
280
|
return t;
|
|
281
|
-
if (t >
|
|
282
|
-
throw
|
|
281
|
+
if (t > is)
|
|
282
|
+
throw ls;
|
|
283
283
|
}
|
|
284
|
-
throw
|
|
285
|
-
},
|
|
284
|
+
throw os;
|
|
285
|
+
}, Ze = (n) => {
|
|
286
286
|
let t = n.arr[n.pos++], e = t & Ve, s = 64;
|
|
287
287
|
const r = (t & z) > 0 ? -1 : 1;
|
|
288
288
|
if (!(t & x))
|
|
@@ -291,10 +291,10 @@ const nt = (n) => new pe(n), Gr = (n) => n.pos !== n.arr.length, Pr = (n, t) =>
|
|
|
291
291
|
for (; n.pos < i; ) {
|
|
292
292
|
if (t = n.arr[n.pos++], e = e + (t & it) * s, s *= 128, t < x)
|
|
293
293
|
return r * e;
|
|
294
|
-
if (e >
|
|
295
|
-
throw
|
|
294
|
+
if (e > is)
|
|
295
|
+
throw ls;
|
|
296
296
|
}
|
|
297
|
-
throw
|
|
297
|
+
throw os;
|
|
298
298
|
}, qr = (n) => {
|
|
299
299
|
let t = m(n);
|
|
300
300
|
if (t === 0)
|
|
@@ -317,20 +317,20 @@ const nt = (n) => new pe(n), Gr = (n) => n.pos !== n.arr.length, Pr = (n, t) =>
|
|
|
317
317
|
}
|
|
318
318
|
}, Zr = (n) => (
|
|
319
319
|
/** @type any */
|
|
320
|
-
|
|
321
|
-
),
|
|
320
|
+
vt.decode(M(n))
|
|
321
|
+
), Z = vt ? Zr : qr, Qe = (n, t) => {
|
|
322
322
|
const e = new DataView(n.arr.buffer, n.arr.byteOffset + n.pos, t);
|
|
323
323
|
return n.pos += t, e;
|
|
324
|
-
}, Qr = (n) =>
|
|
324
|
+
}, Qr = (n) => Qe(n, 4).getFloat32(0, !1), ti = (n) => Qe(n, 8).getFloat64(0, !1), ei = (n) => (
|
|
325
325
|
/** @type {any} */
|
|
326
|
-
|
|
326
|
+
Qe(n, 8).getBigInt64(0, !1)
|
|
327
327
|
), ni = [
|
|
328
328
|
(n) => {
|
|
329
329
|
},
|
|
330
330
|
// CASE 127: undefined
|
|
331
331
|
(n) => null,
|
|
332
332
|
// CASE 126: null
|
|
333
|
-
|
|
333
|
+
Ze,
|
|
334
334
|
// CASE 125: integer
|
|
335
335
|
Qr,
|
|
336
336
|
// CASE 124: float32
|
|
@@ -342,12 +342,12 @@ const nt = (n) => new pe(n), Gr = (n) => n.pos !== n.arr.length, Pr = (n, t) =>
|
|
|
342
342
|
// CASE 121: boolean (false)
|
|
343
343
|
(n) => !0,
|
|
344
344
|
// CASE 120: boolean (true)
|
|
345
|
-
|
|
345
|
+
Z,
|
|
346
346
|
// CASE 119: string
|
|
347
347
|
(n) => {
|
|
348
348
|
const t = m(n), e = {};
|
|
349
349
|
for (let s = 0; s < t; s++) {
|
|
350
|
-
const r =
|
|
350
|
+
const r = Z(n);
|
|
351
351
|
e[r] = Rt(n);
|
|
352
352
|
}
|
|
353
353
|
return e;
|
|
@@ -358,10 +358,10 @@ const nt = (n) => new pe(n), Gr = (n) => n.pos !== n.arr.length, Pr = (n, t) =>
|
|
|
358
358
|
e.push(Rt(n));
|
|
359
359
|
return e;
|
|
360
360
|
},
|
|
361
|
-
|
|
361
|
+
M
|
|
362
362
|
// CASE 116: Uint8Array
|
|
363
363
|
], Rt = (n) => ni[127 - St(n)](n);
|
|
364
|
-
class
|
|
364
|
+
class Un extends pe {
|
|
365
365
|
/**
|
|
366
366
|
* @param {Uint8Array} uint8Array
|
|
367
367
|
* @param {function(Decoder):T} reader
|
|
@@ -383,8 +383,8 @@ class ee extends pe {
|
|
|
383
383
|
}
|
|
384
384
|
read() {
|
|
385
385
|
if (this.count === 0) {
|
|
386
|
-
this.s =
|
|
387
|
-
const t =
|
|
386
|
+
this.s = Ze(this);
|
|
387
|
+
const t = ts(this.s);
|
|
388
388
|
this.count = 1, t && (this.s = -this.s, this.count = m(this) + 2);
|
|
389
389
|
}
|
|
390
390
|
return this.count--, /** @type {number} */
|
|
@@ -403,8 +403,8 @@ class Ae extends pe {
|
|
|
403
403
|
*/
|
|
404
404
|
read() {
|
|
405
405
|
if (this.count === 0) {
|
|
406
|
-
const t =
|
|
407
|
-
this.diff =
|
|
406
|
+
const t = Ze(this), e = t & 1;
|
|
407
|
+
this.diff = Y(t / 2), this.count = 1, e && (this.count = m(this) + 2);
|
|
408
408
|
}
|
|
409
409
|
return this.s += this.diff, this.count--, this.s;
|
|
410
410
|
}
|
|
@@ -414,7 +414,7 @@ class si {
|
|
|
414
414
|
* @param {Uint8Array} uint8Array
|
|
415
415
|
*/
|
|
416
416
|
constructor(t) {
|
|
417
|
-
this.decoder = new ee(t), this.str =
|
|
417
|
+
this.decoder = new ee(t), this.str = Z(this.decoder), this.spos = 0;
|
|
418
418
|
}
|
|
419
419
|
/**
|
|
420
420
|
* @return {string}
|
|
@@ -424,21 +424,21 @@ class si {
|
|
|
424
424
|
return this.spos = t, e;
|
|
425
425
|
}
|
|
426
426
|
}
|
|
427
|
-
const
|
|
427
|
+
const cs = (n) => new Uint8Array(n), tn = (n, t, e) => new Uint8Array(n, t, e), ri = (n) => new Uint8Array(n), ii = (n) => {
|
|
428
428
|
let t = "";
|
|
429
429
|
for (let e = 0; e < n.byteLength; e++)
|
|
430
430
|
t += Dr(n[e]);
|
|
431
431
|
return btoa(t);
|
|
432
432
|
}, oi = (n) => Buffer.from(n.buffer, n.byteOffset, n.byteLength).toString("base64"), li = (n) => {
|
|
433
|
-
const t = atob(n), e =
|
|
433
|
+
const t = atob(n), e = cs(t.length);
|
|
434
434
|
for (let s = 0; s < t.length; s++)
|
|
435
435
|
e[s] = t.charCodeAt(s);
|
|
436
436
|
return e;
|
|
437
437
|
}, ci = (n) => {
|
|
438
438
|
const t = Buffer.from(n, "base64");
|
|
439
439
|
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
440
|
-
}, ai =
|
|
441
|
-
const t =
|
|
440
|
+
}, ai = rs ? ii : oi, hi = rs ? li : ci, ui = (n) => {
|
|
441
|
+
const t = cs(n.byteLength);
|
|
442
442
|
return t.set(n), t;
|
|
443
443
|
};
|
|
444
444
|
class $t {
|
|
@@ -446,33 +446,33 @@ class $t {
|
|
|
446
446
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
447
447
|
}
|
|
448
448
|
}
|
|
449
|
-
const
|
|
449
|
+
const v = () => new $t(), en = (n) => {
|
|
450
450
|
let t = n.cpos;
|
|
451
451
|
for (let e = 0; e < n.bufs.length; e++)
|
|
452
452
|
t += n.bufs[e].length;
|
|
453
453
|
return t;
|
|
454
454
|
}, _ = (n) => {
|
|
455
|
-
const t = new Uint8Array(
|
|
455
|
+
const t = new Uint8Array(en(n));
|
|
456
456
|
let e = 0;
|
|
457
457
|
for (let s = 0; s < n.bufs.length; s++) {
|
|
458
458
|
const r = n.bufs[s];
|
|
459
459
|
t.set(r, e), e += r.length;
|
|
460
460
|
}
|
|
461
|
-
return t.set(
|
|
461
|
+
return t.set(tn(n.cbuf.buffer, 0, n.cpos), e), t;
|
|
462
462
|
}, di = (n, t) => {
|
|
463
463
|
const e = n.cbuf.length;
|
|
464
|
-
e - n.cpos < t && (n.bufs.push(
|
|
464
|
+
e - n.cpos < t && (n.bufs.push(tn(n.cbuf.buffer, 0, n.cpos)), n.cbuf = new Uint8Array(ft(e, t) * 2), n.cpos = 0);
|
|
465
465
|
}, A = (n, t) => {
|
|
466
466
|
const e = n.cbuf.length;
|
|
467
467
|
n.cpos === e && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(e * 2), n.cpos = 0), n.cbuf[n.cpos++] = t;
|
|
468
468
|
}, He = A, p = (n, t) => {
|
|
469
469
|
for (; t > it; )
|
|
470
|
-
A(n, x | it & t), t =
|
|
470
|
+
A(n, x | it & t), t = Y(t / 128);
|
|
471
471
|
A(n, it & t);
|
|
472
|
-
},
|
|
473
|
-
const e =
|
|
474
|
-
for (e && (t = -t), A(n, (t > Ve ? x : 0) | (e ? z : 0) | Ve & t), t =
|
|
475
|
-
A(n, (t > it ? x : 0) | it & t), t =
|
|
472
|
+
}, nn = (n, t) => {
|
|
473
|
+
const e = ts(t);
|
|
474
|
+
for (e && (t = -t), A(n, (t > Ve ? x : 0) | (e ? z : 0) | Ve & t), t = Y(t / 64); t > 0; )
|
|
475
|
+
A(n, (t > it ? x : 0) | it & t), t = Y(t / 128);
|
|
476
476
|
}, $e = new Uint8Array(3e4), fi = $e.length / 3, gi = (n, t) => {
|
|
477
477
|
if (t.length < fi) {
|
|
478
478
|
const e = Tt.encodeInto(t, $e).written || 0;
|
|
@@ -480,7 +480,7 @@ const M = () => new $t(), nn = (n) => {
|
|
|
480
480
|
for (let s = 0; s < e; s++)
|
|
481
481
|
A(n, $e[s]);
|
|
482
482
|
} else
|
|
483
|
-
D(n,
|
|
483
|
+
D(n, vr(t));
|
|
484
484
|
}, pi = (n, t) => {
|
|
485
485
|
const e = unescape(encodeURIComponent(t)), s = e.length;
|
|
486
486
|
p(n, s);
|
|
@@ -492,24 +492,24 @@ const M = () => new $t(), nn = (n) => {
|
|
|
492
492
|
);
|
|
493
493
|
}, ot = Tt && /** @type {any} */
|
|
494
494
|
Tt.encodeInto ? gi : pi, we = (n, t) => {
|
|
495
|
-
const e = n.cbuf.length, s = n.cpos, r =
|
|
495
|
+
const e = n.cbuf.length, s = n.cpos, r = Ge(e - s, t.length), i = t.length - r;
|
|
496
496
|
n.cbuf.set(t.subarray(0, r), s), n.cpos += r, i > 0 && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(ft(e * 2, i)), n.cbuf.set(t.subarray(r)), n.cpos = i);
|
|
497
497
|
}, D = (n, t) => {
|
|
498
498
|
p(n, t.byteLength), we(n, t);
|
|
499
|
-
},
|
|
499
|
+
}, sn = (n, t) => {
|
|
500
500
|
di(n, t);
|
|
501
501
|
const e = new DataView(n.cbuf.buffer, n.cpos, t);
|
|
502
502
|
return n.cpos += t, e;
|
|
503
|
-
}, wi = (n, t) =>
|
|
503
|
+
}, wi = (n, t) => sn(n, 4).setFloat32(0, t, !1), mi = (n, t) => sn(n, 8).setFloat64(0, t, !1), yi = (n, t) => (
|
|
504
504
|
/** @type {any} */
|
|
505
|
-
|
|
506
|
-
),
|
|
505
|
+
sn(n, 8).setBigInt64(0, t, !1)
|
|
506
|
+
), Tn = new DataView(new ArrayBuffer(4)), bi = (n) => (Tn.setFloat32(0, n), Tn.getFloat32(0) === n), Bt = (n, t) => {
|
|
507
507
|
switch (typeof t) {
|
|
508
508
|
case "string":
|
|
509
509
|
A(n, 119), ot(n, t);
|
|
510
510
|
break;
|
|
511
511
|
case "number":
|
|
512
|
-
Wr(t) && te(t) <= Jr ? (A(n, 125),
|
|
512
|
+
Wr(t) && te(t) <= Jr ? (A(n, 125), nn(n, t)) : bi(t) ? (A(n, 124), wi(n, t)) : (A(n, 123), mi(n, t));
|
|
513
513
|
break;
|
|
514
514
|
case "bigint":
|
|
515
515
|
A(n, 122), yi(n, t);
|
|
@@ -540,7 +540,7 @@ Tt.encodeInto ? gi : pi, we = (n, t) => {
|
|
|
540
540
|
A(n, 127);
|
|
541
541
|
}
|
|
542
542
|
};
|
|
543
|
-
class
|
|
543
|
+
class On extends $t {
|
|
544
544
|
/**
|
|
545
545
|
* @param {function(Encoder, T):void} writer
|
|
546
546
|
*/
|
|
@@ -554,8 +554,8 @@ class Rn extends $t {
|
|
|
554
554
|
this.s === t ? this.count++ : (this.count > 0 && p(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
const
|
|
558
|
-
n.count > 0 && (
|
|
557
|
+
const Rn = (n) => {
|
|
558
|
+
n.count > 0 && (nn(n.encoder, n.count === 1 ? n.s : -n.s), n.count > 1 && p(n.encoder, n.count - 2));
|
|
559
559
|
};
|
|
560
560
|
class ne {
|
|
561
561
|
constructor() {
|
|
@@ -565,16 +565,16 @@ class ne {
|
|
|
565
565
|
* @param {number} v
|
|
566
566
|
*/
|
|
567
567
|
write(t) {
|
|
568
|
-
this.s === t ? this.count++ : (
|
|
568
|
+
this.s === t ? this.count++ : (Rn(this), this.count = 1, this.s = t);
|
|
569
569
|
}
|
|
570
570
|
toUint8Array() {
|
|
571
|
-
return
|
|
571
|
+
return Rn(this), _(this.encoder);
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
const
|
|
574
|
+
const Bn = (n) => {
|
|
575
575
|
if (n.count > 0) {
|
|
576
576
|
const t = n.diff * 2 + (n.count === 1 ? 0 : 1);
|
|
577
|
-
|
|
577
|
+
nn(n.encoder, t), n.count > 1 && p(n.encoder, n.count - 2);
|
|
578
578
|
}
|
|
579
579
|
};
|
|
580
580
|
class Le {
|
|
@@ -585,10 +585,10 @@ class Le {
|
|
|
585
585
|
* @param {number} v
|
|
586
586
|
*/
|
|
587
587
|
write(t) {
|
|
588
|
-
this.diff === t - this.s ? (this.s = t, this.count++) : (
|
|
588
|
+
this.diff === t - this.s ? (this.s = t, this.count++) : (Bn(this), this.count = 1, this.diff = t - this.s, this.s = t);
|
|
589
589
|
}
|
|
590
590
|
toUint8Array() {
|
|
591
|
-
return
|
|
591
|
+
return Bn(this), _(this.encoder);
|
|
592
592
|
}
|
|
593
593
|
}
|
|
594
594
|
class ki {
|
|
@@ -606,10 +606,10 @@ class ki {
|
|
|
606
606
|
return this.sarr.push(this.s), this.s = "", ot(t, this.sarr.join("")), we(t, this.lensE.toUint8Array()), _(t);
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
const _i = crypto.getRandomValues.bind(crypto),
|
|
609
|
+
const _i = crypto.getRandomValues.bind(crypto), as = () => _i(new Uint32Array(1))[0], Si = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Di = () => Si.replace(
|
|
610
610
|
/[018]/g,
|
|
611
611
|
/** @param {number} c */
|
|
612
|
-
(n) => (n ^
|
|
612
|
+
(n) => (n ^ as() & 15 >> n / 4).toString(16)
|
|
613
613
|
), ct = Date.now, Dt = (n) => (
|
|
614
614
|
/** @type {Promise<T>} */
|
|
615
615
|
new Promise(n)
|
|
@@ -626,7 +626,7 @@ class Ei {
|
|
|
626
626
|
}
|
|
627
627
|
const K = (n, t) => new Ei(n, t);
|
|
628
628
|
typeof DOMParser < "u" && new DOMParser();
|
|
629
|
-
const Ci = (n) => yr(n, (t, e) => `${e}:${t};`).join(""),
|
|
629
|
+
const Ci = (n) => yr(n, (t, e) => `${e}:${t};`).join(""), W = Symbol, hs = W(), us = W(), Ai = W(), Li = W(), Ii = W(), ds = W(), Mi = W(), fs = W(), vi = W(), xi = (n) => {
|
|
630
630
|
const t = [];
|
|
631
631
|
let e = 0;
|
|
632
632
|
for (; e < n.length; e++) {
|
|
@@ -635,18 +635,18 @@ const Ci = (n) => yr(n, (t, e) => `${e}:${t};`).join(""), G = Symbol, us = G(),
|
|
|
635
635
|
}
|
|
636
636
|
return t;
|
|
637
637
|
}, Ui = {
|
|
638
|
-
[
|
|
639
|
-
[
|
|
638
|
+
[hs]: K("font-weight", "bold"),
|
|
639
|
+
[us]: K("font-weight", "normal"),
|
|
640
640
|
[Ai]: K("color", "blue"),
|
|
641
641
|
[Ii]: K("color", "green"),
|
|
642
642
|
[Li]: K("color", "grey"),
|
|
643
|
-
[
|
|
644
|
-
[
|
|
645
|
-
[
|
|
643
|
+
[ds]: K("color", "red"),
|
|
644
|
+
[Mi]: K("color", "purple"),
|
|
645
|
+
[fs]: K("color", "orange"),
|
|
646
646
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
647
|
-
[
|
|
647
|
+
[vi]: K("color", "black")
|
|
648
648
|
}, Ti = (n) => {
|
|
649
|
-
const t = [], e = [], s =
|
|
649
|
+
const t = [], e = [], s = R();
|
|
650
650
|
let r = [], i = 0;
|
|
651
651
|
for (; i < n.length; i++) {
|
|
652
652
|
const o = n[i], l = Ui[o];
|
|
@@ -665,7 +665,7 @@ const Ci = (n) => yr(n, (t, e) => `${e}:${t};`).join(""), G = Symbol, us = G(),
|
|
|
665
665
|
return r;
|
|
666
666
|
}, Oi = Xr ? Ti : xi, Ri = (...n) => {
|
|
667
667
|
console.log(...Oi(n)), Bi.forEach((t) => t.print(n));
|
|
668
|
-
}, Bi = lt(),
|
|
668
|
+
}, Bi = lt(), gs = (n) => ({
|
|
669
669
|
/**
|
|
670
670
|
* @return {IterableIterator<T>}
|
|
671
671
|
*/
|
|
@@ -674,17 +674,17 @@ const Ci = (n) => yr(n, (t, e) => `${e}:${t};`).join(""), G = Symbol, us = G(),
|
|
|
674
674
|
},
|
|
675
675
|
// @ts-ignore
|
|
676
676
|
next: n
|
|
677
|
-
}), Ni = (n, t) =>
|
|
677
|
+
}), Ni = (n, t) => gs(() => {
|
|
678
678
|
let e;
|
|
679
679
|
do
|
|
680
680
|
e = n.next();
|
|
681
681
|
while (!e.done && !t(e.value));
|
|
682
682
|
return e;
|
|
683
|
-
}), Ie = (n, t) =>
|
|
683
|
+
}), Ie = (n, t) => gs(() => {
|
|
684
684
|
const { done: e, value: s } = n.next();
|
|
685
685
|
return { done: e, value: e ? void 0 : t(s) };
|
|
686
686
|
});
|
|
687
|
-
class
|
|
687
|
+
class rn {
|
|
688
688
|
/**
|
|
689
689
|
* @param {number} clock
|
|
690
690
|
* @param {number} len
|
|
@@ -698,7 +698,7 @@ class jt {
|
|
|
698
698
|
this.clients = /* @__PURE__ */ new Map();
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
const
|
|
701
|
+
const ps = (n, t, e) => t.clients.forEach((s, r) => {
|
|
702
702
|
const i = (
|
|
703
703
|
/** @type {Array<GC|Item>} */
|
|
704
704
|
n.doc.store.clients.get(r)
|
|
@@ -710,7 +710,7 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
710
710
|
}), Fi = (n, t) => {
|
|
711
711
|
let e = 0, s = n.length - 1;
|
|
712
712
|
for (; e <= s; ) {
|
|
713
|
-
const r =
|
|
713
|
+
const r = Y((e + s) / 2), i = n[r], o = i.clock;
|
|
714
714
|
if (o <= t) {
|
|
715
715
|
if (t < o + i.len)
|
|
716
716
|
return r;
|
|
@@ -719,10 +719,10 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
719
719
|
s = r - 1;
|
|
720
720
|
}
|
|
721
721
|
return null;
|
|
722
|
-
},
|
|
722
|
+
}, ws = (n, t) => {
|
|
723
723
|
const e = n.clients.get(t.client);
|
|
724
724
|
return e !== void 0 && Fi(e, t.clock) !== null;
|
|
725
|
-
},
|
|
725
|
+
}, on = (n) => {
|
|
726
726
|
n.clients.forEach((t) => {
|
|
727
727
|
t.sort((r, i) => r.clock - i.clock);
|
|
728
728
|
let e, s;
|
|
@@ -743,12 +743,12 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
743
743
|
t.clients.set(r, i);
|
|
744
744
|
}
|
|
745
745
|
});
|
|
746
|
-
return
|
|
746
|
+
return on(t), t;
|
|
747
747
|
}, ie = (n, t, e, s) => {
|
|
748
|
-
|
|
748
|
+
J(n.clients, t, () => (
|
|
749
749
|
/** @type {Array<DeleteItem>} */
|
|
750
750
|
[]
|
|
751
|
-
)).push(new
|
|
751
|
+
)).push(new rn(e, s));
|
|
752
752
|
}, Hi = () => new jt(), $i = (n) => {
|
|
753
753
|
const t = Hi();
|
|
754
754
|
return n.clients.forEach((e, s) => {
|
|
@@ -761,7 +761,7 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
761
761
|
if (i + 1 < e.length)
|
|
762
762
|
for (let a = e[i + 1]; i + 1 < e.length && a.deleted; a = e[++i + 1])
|
|
763
763
|
c += a.length;
|
|
764
|
-
r.push(new
|
|
764
|
+
r.push(new rn(l, c));
|
|
765
765
|
}
|
|
766
766
|
}
|
|
767
767
|
r.length > 0 && t.clients.set(s, r);
|
|
@@ -776,22 +776,22 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
776
776
|
n.writeDsClock(o.clock), n.writeDsLen(o.len);
|
|
777
777
|
}
|
|
778
778
|
});
|
|
779
|
-
},
|
|
779
|
+
}, ln = (n) => {
|
|
780
780
|
const t = new jt(), e = m(n.restDecoder);
|
|
781
781
|
for (let s = 0; s < e; s++) {
|
|
782
782
|
n.resetDsCurVal();
|
|
783
783
|
const r = m(n.restDecoder), i = m(n.restDecoder);
|
|
784
784
|
if (i > 0) {
|
|
785
|
-
const o =
|
|
785
|
+
const o = J(t.clients, r, () => (
|
|
786
786
|
/** @type {Array<DeleteItem>} */
|
|
787
787
|
[]
|
|
788
788
|
));
|
|
789
789
|
for (let l = 0; l < i; l++)
|
|
790
|
-
o.push(new
|
|
790
|
+
o.push(new rn(n.readDsClock(), n.readDsLen()));
|
|
791
791
|
}
|
|
792
792
|
}
|
|
793
793
|
return t;
|
|
794
|
-
},
|
|
794
|
+
}, Nn = (n, t, e) => {
|
|
795
795
|
const s = new jt(), r = m(n.restDecoder);
|
|
796
796
|
for (let i = 0; i < r; i++) {
|
|
797
797
|
n.resetDsCurVal();
|
|
@@ -812,13 +812,13 @@ const ws = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
812
812
|
return p(i.restEncoder, 0), At(i, s), i.toUint8Array();
|
|
813
813
|
}
|
|
814
814
|
return null;
|
|
815
|
-
},
|
|
815
|
+
}, ms = as;
|
|
816
816
|
class gt extends fe {
|
|
817
817
|
/**
|
|
818
818
|
* @param {DocOpts} opts configuration
|
|
819
819
|
*/
|
|
820
820
|
constructor({ guid: t = Di(), collectionid: e = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: l = !0 } = {}) {
|
|
821
|
-
super(), this.gc = s, this.gcFilter = r, this.clientID =
|
|
821
|
+
super(), this.gc = s, this.gcFilter = r, this.clientID = ms(), this.guid = t, this.collectionid = e, this.share = /* @__PURE__ */ new Map(), this.store = new Ls(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = l, this.autoLoad = o, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = Dt((a) => {
|
|
822
822
|
this.on("load", () => {
|
|
823
823
|
this.isLoaded = !0, a(this);
|
|
824
824
|
});
|
|
@@ -901,7 +901,7 @@ class gt extends fe {
|
|
|
901
901
|
* @public
|
|
902
902
|
*/
|
|
903
903
|
get(t, e = I) {
|
|
904
|
-
const s =
|
|
904
|
+
const s = J(this.share, t, () => {
|
|
905
905
|
const i = new e();
|
|
906
906
|
return i._integrate(this, null), i;
|
|
907
907
|
}), r = s.constructor;
|
|
@@ -1014,7 +1014,7 @@ class gt extends fe {
|
|
|
1014
1014
|
super.off(t, e);
|
|
1015
1015
|
}
|
|
1016
1016
|
}
|
|
1017
|
-
class
|
|
1017
|
+
class ys {
|
|
1018
1018
|
/**
|
|
1019
1019
|
* @param {decoding.Decoder} decoder
|
|
1020
1020
|
*/
|
|
@@ -1036,7 +1036,7 @@ class bs {
|
|
|
1036
1036
|
return m(this.restDecoder);
|
|
1037
1037
|
}
|
|
1038
1038
|
}
|
|
1039
|
-
class
|
|
1039
|
+
class bs extends ys {
|
|
1040
1040
|
/**
|
|
1041
1041
|
* @return {ID}
|
|
1042
1042
|
*/
|
|
@@ -1066,7 +1066,7 @@ class ks extends bs {
|
|
|
1066
1066
|
* @return {string}
|
|
1067
1067
|
*/
|
|
1068
1068
|
readString() {
|
|
1069
|
-
return
|
|
1069
|
+
return Z(this.restDecoder);
|
|
1070
1070
|
}
|
|
1071
1071
|
/**
|
|
1072
1072
|
* @return {boolean} isKey
|
|
@@ -1098,7 +1098,7 @@ class ks extends bs {
|
|
|
1098
1098
|
* @return {Uint8Array}
|
|
1099
1099
|
*/
|
|
1100
1100
|
readBuf() {
|
|
1101
|
-
return ui(
|
|
1101
|
+
return ui(M(this.restDecoder));
|
|
1102
1102
|
}
|
|
1103
1103
|
/**
|
|
1104
1104
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1106,13 +1106,13 @@ class ks extends bs {
|
|
|
1106
1106
|
* @return {any}
|
|
1107
1107
|
*/
|
|
1108
1108
|
readJSON() {
|
|
1109
|
-
return JSON.parse(
|
|
1109
|
+
return JSON.parse(Z(this.restDecoder));
|
|
1110
1110
|
}
|
|
1111
1111
|
/**
|
|
1112
1112
|
* @return {string}
|
|
1113
1113
|
*/
|
|
1114
1114
|
readKey() {
|
|
1115
|
-
return
|
|
1115
|
+
return Z(this.restDecoder);
|
|
1116
1116
|
}
|
|
1117
1117
|
}
|
|
1118
1118
|
class ji {
|
|
@@ -1144,7 +1144,7 @@ class Et extends ji {
|
|
|
1144
1144
|
* @param {decoding.Decoder} decoder
|
|
1145
1145
|
*/
|
|
1146
1146
|
constructor(t) {
|
|
1147
|
-
super(t), this.keys = [], m(t), this.keyClockDecoder = new Ae(
|
|
1147
|
+
super(t), this.keys = [], m(t), this.keyClockDecoder = new Ae(M(t)), this.clientDecoder = new ee(M(t)), this.leftClockDecoder = new Ae(M(t)), this.rightClockDecoder = new Ae(M(t)), this.infoDecoder = new Un(M(t), St), this.stringDecoder = new si(M(t)), this.parentInfoDecoder = new Un(M(t), St), this.typeRefDecoder = new ee(M(t)), this.lenDecoder = new ee(M(t));
|
|
1148
1148
|
}
|
|
1149
1149
|
/**
|
|
1150
1150
|
* @return {ID}
|
|
@@ -1210,7 +1210,7 @@ class Et extends ji {
|
|
|
1210
1210
|
* @return {Uint8Array}
|
|
1211
1211
|
*/
|
|
1212
1212
|
readBuf() {
|
|
1213
|
-
return
|
|
1213
|
+
return M(this.restDecoder);
|
|
1214
1214
|
}
|
|
1215
1215
|
/**
|
|
1216
1216
|
* This is mainly here for legacy purposes.
|
|
@@ -1235,9 +1235,9 @@ class Et extends ji {
|
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
1237
|
}
|
|
1238
|
-
class
|
|
1238
|
+
class ks {
|
|
1239
1239
|
constructor() {
|
|
1240
|
-
this.restEncoder =
|
|
1240
|
+
this.restEncoder = v();
|
|
1241
1241
|
}
|
|
1242
1242
|
toUint8Array() {
|
|
1243
1243
|
return _(this.restEncoder);
|
|
@@ -1257,7 +1257,7 @@ class _s {
|
|
|
1257
1257
|
p(this.restEncoder, t);
|
|
1258
1258
|
}
|
|
1259
1259
|
}
|
|
1260
|
-
class Kt extends
|
|
1260
|
+
class Kt extends ks {
|
|
1261
1261
|
/**
|
|
1262
1262
|
* @param {ID} id
|
|
1263
1263
|
*/
|
|
@@ -1334,9 +1334,9 @@ class Kt extends _s {
|
|
|
1334
1334
|
ot(this.restEncoder, t);
|
|
1335
1335
|
}
|
|
1336
1336
|
}
|
|
1337
|
-
class
|
|
1337
|
+
class _s {
|
|
1338
1338
|
constructor() {
|
|
1339
|
-
this.restEncoder =
|
|
1339
|
+
this.restEncoder = v(), this.dsCurrVal = 0;
|
|
1340
1340
|
}
|
|
1341
1341
|
toUint8Array() {
|
|
1342
1342
|
return _(this.restEncoder);
|
|
@@ -1358,12 +1358,12 @@ class Ss {
|
|
|
1358
1358
|
t === 0 && V(), p(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
|
-
class at extends
|
|
1361
|
+
class at extends _s {
|
|
1362
1362
|
constructor() {
|
|
1363
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Le(), this.clientEncoder = new ne(), this.leftClockEncoder = new Le(), this.rightClockEncoder = new Le(), this.infoEncoder = new
|
|
1363
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Le(), this.clientEncoder = new ne(), this.leftClockEncoder = new Le(), this.rightClockEncoder = new Le(), this.infoEncoder = new On(He), this.stringEncoder = new ki(), this.parentInfoEncoder = new On(He), this.typeRefEncoder = new ne(), this.lenEncoder = new ne();
|
|
1364
1364
|
}
|
|
1365
1365
|
toUint8Array() {
|
|
1366
|
-
const t =
|
|
1366
|
+
const t = v();
|
|
1367
1367
|
return p(t, 0), D(t, this.keyClockEncoder.toUint8Array()), D(t, this.clientEncoder.toUint8Array()), D(t, this.leftClockEncoder.toUint8Array()), D(t, this.rightClockEncoder.toUint8Array()), D(t, _(this.infoEncoder)), D(t, this.stringEncoder.toUint8Array()), D(t, _(this.parentInfoEncoder)), D(t, this.typeRefEncoder.toUint8Array()), D(t, this.lenEncoder.toUint8Array()), we(t, _(this.restEncoder)), _(t);
|
|
1368
1368
|
}
|
|
1369
1369
|
/**
|
|
@@ -1459,7 +1459,7 @@ const Ki = (n, t, e, s) => {
|
|
|
1459
1459
|
i.write(n, s - i.id.clock);
|
|
1460
1460
|
for (let o = r + 1; o < t.length; o++)
|
|
1461
1461
|
t[o].write(n, 0);
|
|
1462
|
-
},
|
|
1462
|
+
}, cn = (n, t, e) => {
|
|
1463
1463
|
const s = /* @__PURE__ */ new Map();
|
|
1464
1464
|
e.forEach((r, i) => {
|
|
1465
1465
|
L(t, i) > r && s.set(i, r);
|
|
@@ -1475,7 +1475,7 @@ const Ki = (n, t, e, s) => {
|
|
|
1475
1475
|
);
|
|
1476
1476
|
});
|
|
1477
1477
|
}, zi = (n, t) => {
|
|
1478
|
-
const e =
|
|
1478
|
+
const e = R(), s = m(n.restDecoder);
|
|
1479
1479
|
for (let r = 0; r < s; r++) {
|
|
1480
1480
|
const i = m(n.restDecoder), o = new Array(i), l = n.readClient();
|
|
1481
1481
|
let c = m(n.restDecoder);
|
|
@@ -1508,7 +1508,7 @@ const Ki = (n, t, e, s) => {
|
|
|
1508
1508
|
// parent
|
|
1509
1509
|
d && (h & Ot) === Ot ? n.readString() : null,
|
|
1510
1510
|
// parentSub
|
|
1511
|
-
|
|
1511
|
+
Ws(n, h)
|
|
1512
1512
|
// item content
|
|
1513
1513
|
);
|
|
1514
1514
|
o[a] = u, c += u.length;
|
|
@@ -1540,7 +1540,7 @@ const Ki = (n, t, e, s) => {
|
|
|
1540
1540
|
let o = i();
|
|
1541
1541
|
if (o === null && s.length === 0)
|
|
1542
1542
|
return null;
|
|
1543
|
-
const l = new
|
|
1543
|
+
const l = new Ls(), c = /* @__PURE__ */ new Map(), a = (f, g) => {
|
|
1544
1544
|
const w = c.get(f);
|
|
1545
1545
|
(w == null || w > g) && c.set(f, g);
|
|
1546
1546
|
};
|
|
@@ -1560,7 +1560,7 @@ const Ki = (n, t, e, s) => {
|
|
|
1560
1560
|
};
|
|
1561
1561
|
for (; ; ) {
|
|
1562
1562
|
if (h.constructor !== T) {
|
|
1563
|
-
const g =
|
|
1563
|
+
const g = J(d, h.id.client, () => L(t, h.id.client)) - h.id.clock;
|
|
1564
1564
|
if (g < 0)
|
|
1565
1565
|
s.push(h), a(h.id.client, h.id.clock - 1), u();
|
|
1566
1566
|
else {
|
|
@@ -1600,10 +1600,10 @@ const Ki = (n, t, e, s) => {
|
|
|
1600
1600
|
}
|
|
1601
1601
|
if (l.clients.size > 0) {
|
|
1602
1602
|
const f = new at();
|
|
1603
|
-
return
|
|
1603
|
+
return cn(f, l, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: c, update: f.toUint8Array() };
|
|
1604
1604
|
}
|
|
1605
1605
|
return null;
|
|
1606
|
-
}, Xi = (n, t) =>
|
|
1606
|
+
}, Xi = (n, t) => cn(n, t.doc.store, t.beforeState), Ji = (n, t, e, s = new Et(n)) => k(t, (r) => {
|
|
1607
1607
|
r.local = !1;
|
|
1608
1608
|
let i = !1;
|
|
1609
1609
|
const o = r.doc, l = o.store, c = zi(s, o), a = Yi(r, l, c), h = l.pendingStructs;
|
|
@@ -1622,11 +1622,11 @@ const Ki = (n, t, e, s) => {
|
|
|
1622
1622
|
}
|
|
1623
1623
|
} else
|
|
1624
1624
|
l.pendingStructs = a;
|
|
1625
|
-
const d =
|
|
1625
|
+
const d = Nn(s, r, l);
|
|
1626
1626
|
if (l.pendingDs) {
|
|
1627
1627
|
const u = new Et(nt(l.pendingDs));
|
|
1628
1628
|
m(u.restDecoder);
|
|
1629
|
-
const f =
|
|
1629
|
+
const f = Nn(u, r, l);
|
|
1630
1630
|
d && f ? l.pendingDs = oe([d, f]) : l.pendingDs = d || f;
|
|
1631
1631
|
} else
|
|
1632
1632
|
l.pendingDs = d;
|
|
@@ -1635,15 +1635,15 @@ const Ki = (n, t, e, s) => {
|
|
|
1635
1635
|
/** @type {{update: Uint8Array}} */
|
|
1636
1636
|
l.pendingStructs.update
|
|
1637
1637
|
);
|
|
1638
|
-
l.pendingStructs = null,
|
|
1638
|
+
l.pendingStructs = null, Ss(r.doc, u);
|
|
1639
1639
|
}
|
|
1640
|
-
}, e, !1),
|
|
1640
|
+
}, e, !1), Ss = (n, t, e, s = Et) => {
|
|
1641
1641
|
const r = nt(t);
|
|
1642
1642
|
Ji(r, n, e, new s(r));
|
|
1643
|
-
},
|
|
1644
|
-
|
|
1643
|
+
}, Ds = (n, t, e) => Ss(n, t, e, bs), Wi = (n, t, e = /* @__PURE__ */ new Map()) => {
|
|
1644
|
+
cn(n, t.store, e), At(n, $i(t.store));
|
|
1645
1645
|
}, Gi = (n, t = new Uint8Array([0]), e = new at()) => {
|
|
1646
|
-
const s =
|
|
1646
|
+
const s = Es(t);
|
|
1647
1647
|
Wi(e, n, s);
|
|
1648
1648
|
const r = [e.toUint8Array()];
|
|
1649
1649
|
if (n.store.pendingDs && r.push(n.store.pendingDs), n.store.pendingStructs && r.push(ho(n.store.pendingStructs.update, t)), r.length > 1) {
|
|
@@ -1653,25 +1653,25 @@ const Ki = (n, t, e, s) => {
|
|
|
1653
1653
|
return oe(r);
|
|
1654
1654
|
}
|
|
1655
1655
|
return r[0];
|
|
1656
|
-
},
|
|
1656
|
+
}, an = (n, t) => Gi(n, t, new Kt()), Pi = (n) => {
|
|
1657
1657
|
const t = /* @__PURE__ */ new Map(), e = m(n.restDecoder);
|
|
1658
1658
|
for (let s = 0; s < e; s++) {
|
|
1659
1659
|
const r = m(n.restDecoder), i = m(n.restDecoder);
|
|
1660
1660
|
t.set(r, i);
|
|
1661
1661
|
}
|
|
1662
1662
|
return t;
|
|
1663
|
-
},
|
|
1663
|
+
}, Es = (n) => Pi(new ys(nt(n))), Cs = (n, t) => (p(n.restEncoder, t.size), tt(t.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
|
|
1664
1664
|
p(n.restEncoder, e), p(n.restEncoder, s);
|
|
1665
|
-
}), n), qi = (n, t) =>
|
|
1665
|
+
}), n), qi = (n, t) => Cs(n, me(t.store)), Zi = (n, t = new _s()) => (n instanceof Map ? Cs(t, n) : qi(t, n), t.toUint8Array()), Qi = (n) => Zi(n, new ks());
|
|
1666
1666
|
class to {
|
|
1667
1667
|
constructor() {
|
|
1668
1668
|
this.l = [];
|
|
1669
1669
|
}
|
|
1670
1670
|
}
|
|
1671
|
-
const
|
|
1671
|
+
const Fn = () => new to(), Vn = (n, t) => n.l.push(t), Hn = (n, t) => {
|
|
1672
1672
|
const e = n.l, s = e.length;
|
|
1673
1673
|
n.l = e.filter((r) => t !== r), s === n.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1674
|
-
},
|
|
1674
|
+
}, As = (n, t, e) => qe(n.l, [t, e]);
|
|
1675
1675
|
class yt {
|
|
1676
1676
|
/**
|
|
1677
1677
|
* @param {number} client client id
|
|
@@ -1686,14 +1686,14 @@ const Pt = (n, t) => n === t || n !== null && t !== null && n.client === t.clien
|
|
|
1686
1686
|
if (e === n)
|
|
1687
1687
|
return t;
|
|
1688
1688
|
throw V();
|
|
1689
|
-
}, It = (n, t) => t === void 0 ? !n.deleted : t.sv.has(n.id.client) && (t.sv.get(n.id.client) || 0) > n.id.clock && !
|
|
1690
|
-
const e =
|
|
1689
|
+
}, It = (n, t) => t === void 0 ? !n.deleted : t.sv.has(n.id.client) && (t.sv.get(n.id.client) || 0) > n.id.clock && !ws(t.ds, n.id), je = (n, t) => {
|
|
1690
|
+
const e = J(n.meta, je, lt), s = n.doc.store;
|
|
1691
1691
|
e.has(t) || (t.sv.forEach((r, i) => {
|
|
1692
1692
|
r < L(s, i) && et(n, b(i, r));
|
|
1693
|
-
}),
|
|
1693
|
+
}), ps(n, t.ds, (r) => {
|
|
1694
1694
|
}), e.add(t));
|
|
1695
1695
|
};
|
|
1696
|
-
class
|
|
1696
|
+
class Ls {
|
|
1697
1697
|
constructor() {
|
|
1698
1698
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
1699
1699
|
}
|
|
@@ -1710,7 +1710,7 @@ const me = (n) => {
|
|
|
1710
1710
|
return 0;
|
|
1711
1711
|
const s = e[e.length - 1];
|
|
1712
1712
|
return s.id.clock + s.length;
|
|
1713
|
-
},
|
|
1713
|
+
}, Is = (n, t) => {
|
|
1714
1714
|
let e = n.clients.get(t.id.client);
|
|
1715
1715
|
if (e === void 0)
|
|
1716
1716
|
e = [], n.clients.set(t.id.client, e);
|
|
@@ -1724,7 +1724,7 @@ const me = (n) => {
|
|
|
1724
1724
|
let e = 0, s = n.length - 1, r = n[s], i = r.id.clock;
|
|
1725
1725
|
if (i === t)
|
|
1726
1726
|
return s;
|
|
1727
|
-
let o =
|
|
1727
|
+
let o = Y(t / (i + r.length - 1) * s);
|
|
1728
1728
|
for (; e <= s; ) {
|
|
1729
1729
|
if (r = n[o], i = r.id.clock, i <= t) {
|
|
1730
1730
|
if (t < i + r.length)
|
|
@@ -1732,13 +1732,13 @@ const me = (n) => {
|
|
|
1732
1732
|
e = o + 1;
|
|
1733
1733
|
} else
|
|
1734
1734
|
s = o - 1;
|
|
1735
|
-
o =
|
|
1735
|
+
o = Y((e + s) / 2);
|
|
1736
1736
|
}
|
|
1737
1737
|
throw V();
|
|
1738
1738
|
}, no = (n, t) => {
|
|
1739
1739
|
const e = n.clients.get(t.client);
|
|
1740
1740
|
return e[H(e, t.clock)];
|
|
1741
|
-
},
|
|
1741
|
+
}, Me = (
|
|
1742
1742
|
/** @type {function(StructStore,ID):Item} */
|
|
1743
1743
|
no
|
|
1744
1744
|
), Ke = (n, t, e) => {
|
|
@@ -1750,7 +1750,7 @@ const me = (n) => {
|
|
|
1750
1750
|
n.doc.store.clients.get(t.client)
|
|
1751
1751
|
);
|
|
1752
1752
|
return e[Ke(n, e, t.clock)];
|
|
1753
|
-
},
|
|
1753
|
+
}, $n = (n, t, e) => {
|
|
1754
1754
|
const s = t.clients.get(e.client), r = H(s, e.clock), i = s[r];
|
|
1755
1755
|
return e.clock !== i.id.clock + i.length - 1 && i.constructor !== U && s.splice(r + 1, 0, de(n, i, e.clock - i.id.clock + 1)), i;
|
|
1756
1756
|
}, so = (n, t, e) => {
|
|
@@ -1778,9 +1778,9 @@ class ro {
|
|
|
1778
1778
|
this.doc = t, this.deleteSet = new jt(), this.beforeState = me(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = e, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
1779
1779
|
}
|
|
1780
1780
|
}
|
|
1781
|
-
const
|
|
1781
|
+
const jn = (n, t) => t.deleteSet.clients.size === 0 && !br(t.afterState, (e, s) => t.beforeState.get(s) !== e) ? !1 : (on(t.deleteSet), Xi(n, t), At(n, t.deleteSet), !0), Kn = (n, t, e) => {
|
|
1782
1782
|
const s = t._item;
|
|
1783
|
-
(s === null || s.id.clock < (n.beforeState.get(s.id.client) || 0) && !s.deleted) &&
|
|
1783
|
+
(s === null || s.id.clock < (n.beforeState.get(s.id.client) || 0) && !s.deleted) && J(n.changed, t, lt).add(e);
|
|
1784
1784
|
}, se = (n, t) => {
|
|
1785
1785
|
let e = n[t], s = n[t - 1], r = t;
|
|
1786
1786
|
for (; r > 0; e = s, s = n[--r - 1]) {
|
|
@@ -1820,16 +1820,16 @@ const Kn = (n, t) => t.deleteSet.clients.size === 0 && !br(t.afterState, (e, s)
|
|
|
1820
1820
|
t.clients.get(s)
|
|
1821
1821
|
);
|
|
1822
1822
|
for (let i = e.length - 1; i >= 0; i--) {
|
|
1823
|
-
const o = e[i], l =
|
|
1823
|
+
const o = e[i], l = Ge(r.length - 1, 1 + H(r, o.clock + o.len - 1));
|
|
1824
1824
|
for (let c = l, a = r[c]; c > 0 && a.id.clock >= o.clock; a = r[c])
|
|
1825
1825
|
c -= 1 + se(r, c);
|
|
1826
1826
|
}
|
|
1827
1827
|
});
|
|
1828
|
-
},
|
|
1828
|
+
}, vs = (n, t) => {
|
|
1829
1829
|
if (t < n.length) {
|
|
1830
1830
|
const e = n[t], s = e.doc, r = s.store, i = e.deleteSet, o = e._mergeStructs;
|
|
1831
1831
|
try {
|
|
1832
|
-
|
|
1832
|
+
on(i), e.afterState = me(e.doc.store), s.emit("beforeObserverCalls", [e, s]);
|
|
1833
1833
|
const l = [];
|
|
1834
1834
|
e.changed.forEach(
|
|
1835
1835
|
(c, a) => l.push(() => {
|
|
@@ -1841,9 +1841,9 @@ const Kn = (n, t) => t.deleteSet.clients.size === 0 && !br(t.afterState, (e, s)
|
|
|
1841
1841
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
1842
1842
|
), c.forEach((h) => {
|
|
1843
1843
|
h.currentTarget = a, h._path = null;
|
|
1844
|
-
}), c.sort((h, d) => h.path.length - d.path.length),
|
|
1844
|
+
}), c.sort((h, d) => h.path.length - d.path.length), As(a._dEH, c, e));
|
|
1845
1845
|
});
|
|
1846
|
-
}), l.push(() => s.emit("afterTransaction", [e, s])),
|
|
1846
|
+
}), l.push(() => s.emit("afterTransaction", [e, s])), qe(l, []), e._needFormattingCleanup && Ao(e);
|
|
1847
1847
|
} finally {
|
|
1848
1848
|
s.gc && io(i, r, s.gcFilter), oo(i, r), e.afterState.forEach((h, d) => {
|
|
1849
1849
|
const u = e.beforeState.get(d) || 0;
|
|
@@ -1863,18 +1863,18 @@ const Kn = (n, t) => t.deleteSet.clients.size === 0 && !br(t.afterState, (e, s)
|
|
|
1863
1863
|
), g = H(f, u);
|
|
1864
1864
|
g + 1 < f.length && se(f, g + 1) > 1 || g > 0 && se(f, g);
|
|
1865
1865
|
}
|
|
1866
|
-
if (!e.local && e.afterState.get(s.clientID) !== e.beforeState.get(s.clientID) && (Ri(
|
|
1866
|
+
if (!e.local && e.afterState.get(s.clientID) !== e.beforeState.get(s.clientID) && (Ri(fs, hs, "[yjs] ", us, ds, "Changed the client-id because another client seems to be using it."), s.clientID = ms()), s.emit("afterTransactionCleanup", [e, s]), s._observers.has("update")) {
|
|
1867
1867
|
const h = new Kt();
|
|
1868
|
-
|
|
1868
|
+
jn(h, e) && s.emit("update", [h.toUint8Array(), e.origin, s, e]);
|
|
1869
1869
|
}
|
|
1870
1870
|
if (s._observers.has("updateV2")) {
|
|
1871
1871
|
const h = new at();
|
|
1872
|
-
|
|
1872
|
+
jn(h, e) && s.emit("updateV2", [h.toUint8Array(), e.origin, s, e]);
|
|
1873
1873
|
}
|
|
1874
1874
|
const { subdocsAdded: l, subdocsLoaded: c, subdocsRemoved: a } = e;
|
|
1875
1875
|
(l.size > 0 || a.size > 0 || c.size > 0) && (l.forEach((h) => {
|
|
1876
1876
|
h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
|
|
1877
|
-
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: c, added: l, removed: a }, s, e]), a.forEach((h) => h.destroy())), n.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, n])) :
|
|
1877
|
+
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: c, added: l, removed: a }, s, e]), a.forEach((h) => h.destroy())), n.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, n])) : vs(n, t + 1);
|
|
1878
1878
|
}
|
|
1879
1879
|
}
|
|
1880
1880
|
}, k = (n, t, e = null, s = !0) => {
|
|
@@ -1886,7 +1886,7 @@ const Kn = (n, t) => t.deleteSet.clients.size === 0 && !br(t.afterState, (e, s)
|
|
|
1886
1886
|
} finally {
|
|
1887
1887
|
if (i) {
|
|
1888
1888
|
const l = n._transaction === r[0];
|
|
1889
|
-
n._transaction = null, l &&
|
|
1889
|
+
n._transaction = null, l && vs(r, 0);
|
|
1890
1890
|
}
|
|
1891
1891
|
}
|
|
1892
1892
|
return o;
|
|
@@ -1917,7 +1917,7 @@ function* lo(n) {
|
|
|
1917
1917
|
// parent
|
|
1918
1918
|
c && (l & Ot) === Ot ? n.readString() : null,
|
|
1919
1919
|
// parentSub
|
|
1920
|
-
|
|
1920
|
+
Ws(n, l)
|
|
1921
1921
|
// item content
|
|
1922
1922
|
);
|
|
1923
1923
|
yield a, i += a.length;
|
|
@@ -1928,7 +1928,7 @@ function* lo(n) {
|
|
|
1928
1928
|
}
|
|
1929
1929
|
}
|
|
1930
1930
|
}
|
|
1931
|
-
class
|
|
1931
|
+
class hn {
|
|
1932
1932
|
/**
|
|
1933
1933
|
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
|
|
1934
1934
|
* @param {boolean} filterSkips
|
|
@@ -1946,7 +1946,7 @@ class un {
|
|
|
1946
1946
|
return this.curr;
|
|
1947
1947
|
}
|
|
1948
1948
|
}
|
|
1949
|
-
class
|
|
1949
|
+
class un {
|
|
1950
1950
|
/**
|
|
1951
1951
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
1952
1952
|
*/
|
|
@@ -1954,7 +1954,7 @@ class dn {
|
|
|
1954
1954
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
1955
1955
|
}
|
|
1956
1956
|
}
|
|
1957
|
-
const co = (n) => oe(n,
|
|
1957
|
+
const co = (n) => oe(n, bs, Kt), ao = (n, t) => {
|
|
1958
1958
|
if (n.constructor === U) {
|
|
1959
1959
|
const { client: e, clock: s } = n.id;
|
|
1960
1960
|
return new U(b(e, s + t), n.length - t);
|
|
@@ -1981,8 +1981,8 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
1981
1981
|
if (n.length === 1)
|
|
1982
1982
|
return n[0];
|
|
1983
1983
|
const s = n.map((h) => new t(nt(h)));
|
|
1984
|
-
let r = s.map((h) => new
|
|
1985
|
-
const o = new e(), l = new
|
|
1984
|
+
let r = s.map((h) => new hn(h, !0)), i = null;
|
|
1985
|
+
const o = new e(), l = new un(o);
|
|
1986
1986
|
for (; r = r.filter((u) => u.curr !== null), r.sort(
|
|
1987
1987
|
/** @type {function(any,any):number} */
|
|
1988
1988
|
(u, f) => {
|
|
@@ -2009,12 +2009,12 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
2009
2009
|
f && u.id.clock > i.struct.id.clock + i.struct.length)
|
|
2010
2010
|
continue;
|
|
2011
2011
|
if (d !== i.struct.id.client)
|
|
2012
|
-
|
|
2012
|
+
P(l, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next();
|
|
2013
2013
|
else if (i.struct.id.clock + i.struct.length < u.id.clock)
|
|
2014
2014
|
if (i.struct.constructor === T)
|
|
2015
2015
|
i.struct.length = u.id.clock + u.length - i.struct.id.clock;
|
|
2016
2016
|
else {
|
|
2017
|
-
|
|
2017
|
+
P(l, i.struct, i.offset);
|
|
2018
2018
|
const g = u.id.clock - i.struct.id.clock - i.struct.length;
|
|
2019
2019
|
i = { struct: new T(b(d, i.struct.id.clock + i.struct.length), g), offset: 0 };
|
|
2020
2020
|
}
|
|
@@ -2023,7 +2023,7 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
2023
2023
|
g > 0 && (i.struct.constructor === T ? i.struct.length -= g : u = ao(u, g)), i.struct.mergeWith(
|
|
2024
2024
|
/** @type {any} */
|
|
2025
2025
|
u
|
|
2026
|
-
) || (
|
|
2026
|
+
) || (P(l, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next());
|
|
2027
2027
|
}
|
|
2028
2028
|
} else
|
|
2029
2029
|
i = { struct: (
|
|
@@ -2031,13 +2031,13 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
2031
2031
|
h.curr
|
|
2032
2032
|
), offset: 0 }, h.next();
|
|
2033
2033
|
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== T; u = h.next())
|
|
2034
|
-
|
|
2034
|
+
P(l, i.struct, i.offset), i = { struct: u, offset: 0 };
|
|
2035
2035
|
}
|
|
2036
|
-
i !== null && (
|
|
2037
|
-
const c = s.map((h) =>
|
|
2036
|
+
i !== null && (P(l, i.struct, i.offset), i = null), dn(l);
|
|
2037
|
+
const c = s.map((h) => ln(h)), a = Vi(c);
|
|
2038
2038
|
return At(o, a), o.toUint8Array();
|
|
2039
2039
|
}, ho = (n, t, e = Et, s = at) => {
|
|
2040
|
-
const r =
|
|
2040
|
+
const r = Es(t), i = new s(), o = new un(i), l = new e(nt(n)), c = new hn(l, !1);
|
|
2041
2041
|
for (; c.curr; ) {
|
|
2042
2042
|
const h = c.curr, d = h.id.client, u = r.get(d) || 0;
|
|
2043
2043
|
if (c.curr.constructor === T) {
|
|
@@ -2045,21 +2045,21 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
2045
2045
|
continue;
|
|
2046
2046
|
}
|
|
2047
2047
|
if (h.id.clock + h.length > u)
|
|
2048
|
-
for (
|
|
2049
|
-
|
|
2048
|
+
for (P(o, h, ft(u - h.id.clock, 0)), c.next(); c.curr && c.curr.id.client === d; )
|
|
2049
|
+
P(o, c.curr, 0), c.next();
|
|
2050
2050
|
else
|
|
2051
2051
|
for (; c.curr && c.curr.id.client === d && c.curr.id.clock + c.curr.length <= u; )
|
|
2052
2052
|
c.next();
|
|
2053
2053
|
}
|
|
2054
|
-
|
|
2055
|
-
const a =
|
|
2054
|
+
dn(o);
|
|
2055
|
+
const a = ln(l);
|
|
2056
2056
|
return At(i, a), i.toUint8Array();
|
|
2057
|
-
},
|
|
2058
|
-
n.written > 0 && (n.clientStructs.push({ written: n.written, restEncoder: _(n.encoder.restEncoder) }), n.encoder.restEncoder =
|
|
2059
|
-
},
|
|
2060
|
-
n.written > 0 && n.currClient !== t.id.client &&
|
|
2061
|
-
},
|
|
2062
|
-
|
|
2057
|
+
}, xs = (n) => {
|
|
2058
|
+
n.written > 0 && (n.clientStructs.push({ written: n.written, restEncoder: _(n.encoder.restEncoder) }), n.encoder.restEncoder = v(), n.written = 0);
|
|
2059
|
+
}, P = (n, t, e) => {
|
|
2060
|
+
n.written > 0 && n.currClient !== t.id.client && xs(n), n.written === 0 && (n.currClient = t.id.client, n.encoder.writeClient(t.id.client), p(n.encoder.restEncoder, t.id.clock + e)), t.write(n.encoder, e), n.written++;
|
|
2061
|
+
}, dn = (n) => {
|
|
2062
|
+
xs(n);
|
|
2063
2063
|
const t = n.encoder.restEncoder;
|
|
2064
2064
|
p(t, n.clientStructs.length);
|
|
2065
2065
|
for (let e = 0; e < n.clientStructs.length; e++) {
|
|
@@ -2067,13 +2067,13 @@ const co = (n) => oe(n, ks, Kt), ao = (n, t) => {
|
|
|
2067
2067
|
p(t, s.written), we(t, s.restEncoder);
|
|
2068
2068
|
}
|
|
2069
2069
|
}, uo = (n, t, e, s) => {
|
|
2070
|
-
const r = new e(nt(n)), i = new
|
|
2070
|
+
const r = new e(nt(n)), i = new hn(r, !1), o = new s(), l = new un(o);
|
|
2071
2071
|
for (let a = i.curr; a !== null; a = i.next())
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
const c =
|
|
2072
|
+
P(l, t(a), 0);
|
|
2073
|
+
dn(l);
|
|
2074
|
+
const c = ln(r);
|
|
2075
2075
|
return At(o, c), o.toUint8Array();
|
|
2076
|
-
}, fo = (n) => uo(n, $r, Et, Kt),
|
|
2076
|
+
}, fo = (n) => uo(n, $r, Et, Kt), zn = "You must not compute changes after the event-handler fired.";
|
|
2077
2077
|
class ye {
|
|
2078
2078
|
/**
|
|
2079
2079
|
* @param {T} target The changed type.
|
|
@@ -2107,7 +2107,7 @@ class ye {
|
|
|
2107
2107
|
* @return {boolean}
|
|
2108
2108
|
*/
|
|
2109
2109
|
deletes(t) {
|
|
2110
|
-
return
|
|
2110
|
+
return ws(this.transaction.deleteSet, t.id);
|
|
2111
2111
|
}
|
|
2112
2112
|
/**
|
|
2113
2113
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2115,7 +2115,7 @@ class ye {
|
|
|
2115
2115
|
get keys() {
|
|
2116
2116
|
if (this._keys === null) {
|
|
2117
2117
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2118
|
-
throw
|
|
2118
|
+
throw X(zn);
|
|
2119
2119
|
const t = /* @__PURE__ */ new Map(), e = this.target;
|
|
2120
2120
|
/** @type Set<string|null> */
|
|
2121
2121
|
this.transaction.changed.get(e).forEach((r) => {
|
|
@@ -2183,7 +2183,7 @@ class ye {
|
|
|
2183
2183
|
let t = this._changes;
|
|
2184
2184
|
if (t === null) {
|
|
2185
2185
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2186
|
-
throw
|
|
2186
|
+
throw X(zn);
|
|
2187
2187
|
const e = this.target, s = lt(), r = lt(), i = [];
|
|
2188
2188
|
if (t = {
|
|
2189
2189
|
added: s,
|
|
@@ -2226,25 +2226,25 @@ const go = (n, t) => {
|
|
|
2226
2226
|
t._item.parent;
|
|
2227
2227
|
}
|
|
2228
2228
|
return e;
|
|
2229
|
-
},
|
|
2230
|
-
let
|
|
2229
|
+
}, Us = 80;
|
|
2230
|
+
let fn = 0;
|
|
2231
2231
|
class po {
|
|
2232
2232
|
/**
|
|
2233
2233
|
* @param {Item} p
|
|
2234
2234
|
* @param {number} index
|
|
2235
2235
|
*/
|
|
2236
2236
|
constructor(t, e) {
|
|
2237
|
-
t.marker = !0, this.p = t, this.index = e, this.timestamp =
|
|
2237
|
+
t.marker = !0, this.p = t, this.index = e, this.timestamp = fn++;
|
|
2238
2238
|
}
|
|
2239
2239
|
}
|
|
2240
2240
|
const wo = (n) => {
|
|
2241
|
-
n.timestamp =
|
|
2242
|
-
},
|
|
2243
|
-
n.p.marker = !1, n.p = t, t.marker = !0, n.index = e, n.timestamp =
|
|
2241
|
+
n.timestamp = fn++;
|
|
2242
|
+
}, Ts = (n, t, e) => {
|
|
2243
|
+
n.p.marker = !1, n.p = t, t.marker = !0, n.index = e, n.timestamp = fn++;
|
|
2244
2244
|
}, mo = (n, t, e) => {
|
|
2245
|
-
if (n.length >=
|
|
2245
|
+
if (n.length >= Us) {
|
|
2246
2246
|
const s = n.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
2247
|
-
return
|
|
2247
|
+
return Ts(s, t, e), s;
|
|
2248
2248
|
} else {
|
|
2249
2249
|
const s = new po(t, e);
|
|
2250
2250
|
return n.push(s), s;
|
|
@@ -2267,7 +2267,7 @@ const wo = (n) => {
|
|
|
2267
2267
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
2268
2268
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2269
2269
|
return e !== null && te(e.index - r) < /** @type {YText|YArray<any>} */
|
|
2270
|
-
s.parent.length /
|
|
2270
|
+
s.parent.length / Us ? (Ts(e, s, r), e) : mo(n._searchMarker, s, r);
|
|
2271
2271
|
}, Nt = (n, t, e) => {
|
|
2272
2272
|
for (let s = n.length - 1; s >= 0; s--) {
|
|
2273
2273
|
const r = n[s];
|
|
@@ -2285,14 +2285,14 @@ const wo = (n) => {
|
|
|
2285
2285
|
}
|
|
2286
2286
|
}, ke = (n, t, e) => {
|
|
2287
2287
|
const s = n, r = t.changedParentTypes;
|
|
2288
|
-
for (;
|
|
2288
|
+
for (; J(r, n, () => []).push(e), n._item !== null; )
|
|
2289
2289
|
n = /** @type {AbstractType<any>} */
|
|
2290
2290
|
n._item.parent;
|
|
2291
|
-
|
|
2291
|
+
As(s._eH, e, t);
|
|
2292
2292
|
};
|
|
2293
2293
|
class I {
|
|
2294
2294
|
constructor() {
|
|
2295
|
-
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 = Fn(), this._dEH = Fn(), this._searchMarker = null;
|
|
2296
2296
|
}
|
|
2297
2297
|
/**
|
|
2298
2298
|
* @return {AbstractType<any>|null}
|
|
@@ -2320,13 +2320,13 @@ class I {
|
|
|
2320
2320
|
* @return {AbstractType<EventType>}
|
|
2321
2321
|
*/
|
|
2322
2322
|
_copy() {
|
|
2323
|
-
throw
|
|
2323
|
+
throw N();
|
|
2324
2324
|
}
|
|
2325
2325
|
/**
|
|
2326
2326
|
* @return {AbstractType<EventType>}
|
|
2327
2327
|
*/
|
|
2328
2328
|
clone() {
|
|
2329
|
-
throw
|
|
2329
|
+
throw N();
|
|
2330
2330
|
}
|
|
2331
2331
|
/**
|
|
2332
2332
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder
|
|
@@ -2358,7 +2358,7 @@ class I {
|
|
|
2358
2358
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2359
2359
|
*/
|
|
2360
2360
|
observe(t) {
|
|
2361
|
-
|
|
2361
|
+
Vn(this._eH, t);
|
|
2362
2362
|
}
|
|
2363
2363
|
/**
|
|
2364
2364
|
* Observe all events that are created by this type and its children.
|
|
@@ -2366,7 +2366,7 @@ class I {
|
|
|
2366
2366
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2367
2367
|
*/
|
|
2368
2368
|
observeDeep(t) {
|
|
2369
|
-
|
|
2369
|
+
Vn(this._dEH, t);
|
|
2370
2370
|
}
|
|
2371
2371
|
/**
|
|
2372
2372
|
* Unregister an observer function.
|
|
@@ -2374,7 +2374,7 @@ class I {
|
|
|
2374
2374
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2375
2375
|
*/
|
|
2376
2376
|
unobserve(t) {
|
|
2377
|
-
|
|
2377
|
+
Hn(this._eH, t);
|
|
2378
2378
|
}
|
|
2379
2379
|
/**
|
|
2380
2380
|
* Unregister an observer function.
|
|
@@ -2382,7 +2382,7 @@ class I {
|
|
|
2382
2382
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2383
2383
|
*/
|
|
2384
2384
|
unobserveDeep(t) {
|
|
2385
|
-
|
|
2385
|
+
Hn(this._dEH, t);
|
|
2386
2386
|
}
|
|
2387
2387
|
/**
|
|
2388
2388
|
* @abstract
|
|
@@ -2391,7 +2391,7 @@ class I {
|
|
|
2391
2391
|
toJSON() {
|
|
2392
2392
|
}
|
|
2393
2393
|
}
|
|
2394
|
-
const
|
|
2394
|
+
const Os = (n, t, e) => {
|
|
2395
2395
|
t < 0 && (t = n._length + t), e < 0 && (e = n._length + e);
|
|
2396
2396
|
let s = e - t;
|
|
2397
2397
|
const r = [];
|
|
@@ -2410,7 +2410,7 @@ const Rs = (n, t, e) => {
|
|
|
2410
2410
|
i = i.right;
|
|
2411
2411
|
}
|
|
2412
2412
|
return r;
|
|
2413
|
-
},
|
|
2413
|
+
}, Rs = (n) => {
|
|
2414
2414
|
const t = [];
|
|
2415
2415
|
let e = n._start;
|
|
2416
2416
|
for (; e !== null; ) {
|
|
@@ -2432,7 +2432,7 @@ const Rs = (n, t, e) => {
|
|
|
2432
2432
|
}
|
|
2433
2433
|
s = s.right;
|
|
2434
2434
|
}
|
|
2435
|
-
},
|
|
2435
|
+
}, Bs = (n, t) => {
|
|
2436
2436
|
const e = [];
|
|
2437
2437
|
return Ft(n, (s, r) => {
|
|
2438
2438
|
e.push(t(s, r, n));
|
|
@@ -2461,7 +2461,7 @@ const Rs = (n, t, e) => {
|
|
|
2461
2461
|
};
|
|
2462
2462
|
}
|
|
2463
2463
|
};
|
|
2464
|
-
},
|
|
2464
|
+
}, Ns = (n, t) => {
|
|
2465
2465
|
const e = be(n, t);
|
|
2466
2466
|
let s = n._start;
|
|
2467
2467
|
for (e !== null && (s = e.p, t -= e.index); s !== null; s = s.right)
|
|
@@ -2506,15 +2506,15 @@ const Rs = (n, t, e) => {
|
|
|
2506
2506
|
break;
|
|
2507
2507
|
default:
|
|
2508
2508
|
if (d instanceof I)
|
|
2509
|
-
r = new E(b(o, L(l, o)), r, r && r.lastId, c, c && c.id, t, null, new
|
|
2509
|
+
r = new E(b(o, L(l, o)), r, r && r.lastId, c, c && c.id, t, null, new G(d)), r.integrate(n, 0);
|
|
2510
2510
|
else
|
|
2511
2511
|
throw new Error("Unexpected content type in insert operation");
|
|
2512
2512
|
}
|
|
2513
2513
|
}
|
|
2514
2514
|
}), h();
|
|
2515
|
-
},
|
|
2515
|
+
}, Fs = () => X("Length exceeded!"), Vs = (n, t, e, s) => {
|
|
2516
2516
|
if (e > t._length)
|
|
2517
|
-
throw
|
|
2517
|
+
throw Fs();
|
|
2518
2518
|
if (e === 0)
|
|
2519
2519
|
return t._searchMarker && Nt(t._searchMarker, e, s.length), le(n, t, null, s);
|
|
2520
2520
|
const r = e, i = be(t, e);
|
|
@@ -2534,7 +2534,7 @@ const Rs = (n, t, e) => {
|
|
|
2534
2534
|
for (; r.right; )
|
|
2535
2535
|
r = r.right;
|
|
2536
2536
|
return le(n, t, r, e);
|
|
2537
|
-
},
|
|
2537
|
+
}, Hs = (n, t, e, s) => {
|
|
2538
2538
|
if (s === 0)
|
|
2539
2539
|
return;
|
|
2540
2540
|
const r = e, i = s, o = be(t, e);
|
|
@@ -2544,7 +2544,7 @@ const Rs = (n, t, e) => {
|
|
|
2544
2544
|
for (; s > 0 && l !== null; )
|
|
2545
2545
|
l.deleted || (s < l.length && et(n, b(l.id.client, l.id.clock + s)), l.delete(n), s -= l.length), l = l.right;
|
|
2546
2546
|
if (s > 0)
|
|
2547
|
-
throw
|
|
2547
|
+
throw Fs();
|
|
2548
2548
|
t._searchMarker && Nt(
|
|
2549
2549
|
t._searchMarker,
|
|
2550
2550
|
r,
|
|
@@ -2554,7 +2554,7 @@ const Rs = (n, t, e) => {
|
|
|
2554
2554
|
}, ce = (n, t, e) => {
|
|
2555
2555
|
const s = t._map.get(e);
|
|
2556
2556
|
s !== void 0 && s.delete(n);
|
|
2557
|
-
},
|
|
2557
|
+
}, gn = (n, t, e, s) => {
|
|
2558
2558
|
const r = t._map.get(e) || null, i = n.doc, o = i.clientID;
|
|
2559
2559
|
let l;
|
|
2560
2560
|
if (s == null)
|
|
@@ -2582,20 +2582,20 @@ const Rs = (n, t, e) => {
|
|
|
2582
2582
|
break;
|
|
2583
2583
|
default:
|
|
2584
2584
|
if (s instanceof I)
|
|
2585
|
-
l = new
|
|
2585
|
+
l = new G(s);
|
|
2586
2586
|
else
|
|
2587
2587
|
throw new Error("Unexpected content type");
|
|
2588
2588
|
}
|
|
2589
2589
|
new E(b(o, L(i.store, o)), r, r && r.lastId, null, null, t, e, l).integrate(n, 0);
|
|
2590
|
-
},
|
|
2590
|
+
}, pn = (n, t) => {
|
|
2591
2591
|
const e = n._map.get(t);
|
|
2592
2592
|
return e !== void 0 && !e.deleted ? e.content.getContent()[e.length - 1] : void 0;
|
|
2593
|
-
},
|
|
2593
|
+
}, $s = (n) => {
|
|
2594
2594
|
const t = {};
|
|
2595
2595
|
return n._map.forEach((e, s) => {
|
|
2596
2596
|
e.deleted || (t[s] = e.content.getContent()[e.length - 1]);
|
|
2597
2597
|
}), t;
|
|
2598
|
-
},
|
|
2598
|
+
}, js = (n, t) => {
|
|
2599
2599
|
const e = n._map.get(t);
|
|
2600
2600
|
return e !== void 0 && !e.deleted;
|
|
2601
2601
|
}, qt = (n) => Ni(
|
|
@@ -2691,7 +2691,7 @@ class bt extends I {
|
|
|
2691
2691
|
*/
|
|
2692
2692
|
insert(t, e) {
|
|
2693
2693
|
this.doc !== null ? k(this.doc, (s) => {
|
|
2694
|
-
|
|
2694
|
+
Vs(
|
|
2695
2695
|
s,
|
|
2696
2696
|
this,
|
|
2697
2697
|
t,
|
|
@@ -2733,7 +2733,7 @@ class bt extends I {
|
|
|
2733
2733
|
*/
|
|
2734
2734
|
delete(t, e = 1) {
|
|
2735
2735
|
this.doc !== null ? k(this.doc, (s) => {
|
|
2736
|
-
|
|
2736
|
+
Hs(s, this, t, e);
|
|
2737
2737
|
}) : this._prelimContent.splice(t, e);
|
|
2738
2738
|
}
|
|
2739
2739
|
/**
|
|
@@ -2743,7 +2743,7 @@ class bt extends I {
|
|
|
2743
2743
|
* @return {T}
|
|
2744
2744
|
*/
|
|
2745
2745
|
get(t) {
|
|
2746
|
-
return
|
|
2746
|
+
return Ns(this, t);
|
|
2747
2747
|
}
|
|
2748
2748
|
/**
|
|
2749
2749
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2751,7 +2751,7 @@ class bt extends I {
|
|
|
2751
2751
|
* @return {Array<T>}
|
|
2752
2752
|
*/
|
|
2753
2753
|
toArray() {
|
|
2754
|
-
return
|
|
2754
|
+
return Rs(this);
|
|
2755
2755
|
}
|
|
2756
2756
|
/**
|
|
2757
2757
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2761,7 +2761,7 @@ class bt extends I {
|
|
|
2761
2761
|
* @return {Array<T>}
|
|
2762
2762
|
*/
|
|
2763
2763
|
slice(t = 0, e = this.length) {
|
|
2764
|
-
return
|
|
2764
|
+
return Os(this, t, e);
|
|
2765
2765
|
}
|
|
2766
2766
|
/**
|
|
2767
2767
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -2781,7 +2781,7 @@ class bt extends I {
|
|
|
2781
2781
|
* callback function
|
|
2782
2782
|
*/
|
|
2783
2783
|
map(t) {
|
|
2784
|
-
return
|
|
2784
|
+
return Bs(
|
|
2785
2785
|
this,
|
|
2786
2786
|
/** @type {any} */
|
|
2787
2787
|
t
|
|
@@ -2965,7 +2965,7 @@ class ht extends I {
|
|
|
2965
2965
|
*/
|
|
2966
2966
|
set(t, e) {
|
|
2967
2967
|
return this.doc !== null ? k(this.doc, (s) => {
|
|
2968
|
-
|
|
2968
|
+
gn(
|
|
2969
2969
|
s,
|
|
2970
2970
|
this,
|
|
2971
2971
|
t,
|
|
@@ -2983,7 +2983,7 @@ class ht extends I {
|
|
|
2983
2983
|
get(t) {
|
|
2984
2984
|
return (
|
|
2985
2985
|
/** @type {any} */
|
|
2986
|
-
|
|
2986
|
+
pn(this, t)
|
|
2987
2987
|
);
|
|
2988
2988
|
}
|
|
2989
2989
|
/**
|
|
@@ -2993,7 +2993,7 @@ class ht extends I {
|
|
|
2993
2993
|
* @return {boolean}
|
|
2994
2994
|
*/
|
|
2995
2995
|
has(t) {
|
|
2996
|
-
return
|
|
2996
|
+
return js(this, t);
|
|
2997
2997
|
}
|
|
2998
2998
|
/**
|
|
2999
2999
|
* Removes all elements from this YMap.
|
|
@@ -3012,7 +3012,7 @@ class ht extends I {
|
|
|
3012
3012
|
t.writeTypeRef(Yo);
|
|
3013
3013
|
}
|
|
3014
3014
|
}
|
|
3015
|
-
const Do = (n) => new ht(),
|
|
3015
|
+
const Do = (n) => new ht(), q = (n, t) => n === t || typeof n == "object" && typeof t == "object" && n && t && Hr(n, t);
|
|
3016
3016
|
class ze {
|
|
3017
3017
|
/**
|
|
3018
3018
|
* @param {Item|null} left
|
|
@@ -3042,7 +3042,7 @@ class ze {
|
|
|
3042
3042
|
this.left = this.right, this.right = this.right.right;
|
|
3043
3043
|
}
|
|
3044
3044
|
}
|
|
3045
|
-
const
|
|
3045
|
+
const Yn = (n, t, e) => {
|
|
3046
3046
|
for (; t.right !== null && e > 0; ) {
|
|
3047
3047
|
switch (t.right.content.constructor) {
|
|
3048
3048
|
case C:
|
|
@@ -3063,13 +3063,13 @@ const Xn = (n, t, e) => {
|
|
|
3063
3063
|
const s = /* @__PURE__ */ new Map(), r = be(t, e);
|
|
3064
3064
|
if (r) {
|
|
3065
3065
|
const i = new ze(r.p.left, r.p, r.index, s);
|
|
3066
|
-
return
|
|
3066
|
+
return Yn(n, i, e - r.index);
|
|
3067
3067
|
} else {
|
|
3068
3068
|
const i = new ze(null, t._start, 0, s);
|
|
3069
|
-
return
|
|
3069
|
+
return Yn(n, i, e);
|
|
3070
3070
|
}
|
|
3071
|
-
},
|
|
3072
|
-
for (; e.right !== null && (e.right.deleted === !0 || e.right.content.constructor === C &&
|
|
3071
|
+
}, Ks = (n, t, e, s) => {
|
|
3072
|
+
for (; e.right !== null && (e.right.deleted === !0 || e.right.content.constructor === C && q(
|
|
3073
3073
|
s.get(
|
|
3074
3074
|
/** @type {ContentFormat} */
|
|
3075
3075
|
e.right.content.key
|
|
@@ -3089,9 +3089,9 @@ const Xn = (n, t, e) => {
|
|
|
3089
3089
|
}, Lt = (n, t) => {
|
|
3090
3090
|
const { key: e, value: s } = t;
|
|
3091
3091
|
s === null ? n.delete(e) : n.set(e, s);
|
|
3092
|
-
},
|
|
3092
|
+
}, zs = (n, t) => {
|
|
3093
3093
|
for (; n.right !== null; ) {
|
|
3094
|
-
if (!(n.right.deleted || n.right.content.constructor === C &&
|
|
3094
|
+
if (!(n.right.deleted || n.right.content.constructor === C && q(
|
|
3095
3095
|
t[
|
|
3096
3096
|
/** @type {ContentFormat} */
|
|
3097
3097
|
n.right.content.key
|
|
@@ -3102,33 +3102,33 @@ const Xn = (n, t, e) => {
|
|
|
3102
3102
|
break;
|
|
3103
3103
|
n.forward();
|
|
3104
3104
|
}
|
|
3105
|
-
},
|
|
3105
|
+
}, Ys = (n, t, e, s) => {
|
|
3106
3106
|
const r = n.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
3107
3107
|
for (const l in s) {
|
|
3108
3108
|
const c = s[l], a = e.currentAttributes.get(l) || null;
|
|
3109
|
-
if (!
|
|
3109
|
+
if (!q(a, c)) {
|
|
3110
3110
|
o.set(l, a);
|
|
3111
3111
|
const { left: h, right: d } = e;
|
|
3112
3112
|
e.right = new E(b(i, L(r.store, i)), h, h && h.lastId, d, d && d.id, t, null, new C(l, c)), e.right.integrate(n, 0), e.forward();
|
|
3113
3113
|
}
|
|
3114
3114
|
}
|
|
3115
3115
|
return o;
|
|
3116
|
-
},
|
|
3116
|
+
}, ve = (n, t, e, s, r) => {
|
|
3117
3117
|
e.currentAttributes.forEach((u, f) => {
|
|
3118
3118
|
r[f] === void 0 && (r[f] = null);
|
|
3119
3119
|
});
|
|
3120
3120
|
const i = n.doc, o = i.clientID;
|
|
3121
|
-
|
|
3122
|
-
const l =
|
|
3121
|
+
zs(e, r);
|
|
3122
|
+
const l = Ys(n, t, e, r), c = s.constructor === String ? new $(
|
|
3123
3123
|
/** @type {string} */
|
|
3124
3124
|
s
|
|
3125
|
-
) : s instanceof I ? new
|
|
3125
|
+
) : s instanceof I ? new G(s) : new pt(s);
|
|
3126
3126
|
let { left: a, right: h, index: d } = e;
|
|
3127
|
-
t._searchMarker && Nt(t._searchMarker, e.index, c.getLength()), h = new E(b(o, L(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, c), h.integrate(n, 0), e.right = h, e.index = d, e.forward(),
|
|
3128
|
-
},
|
|
3127
|
+
t._searchMarker && Nt(t._searchMarker, e.index, c.getLength()), h = new E(b(o, L(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, c), h.integrate(n, 0), e.right = h, e.index = d, e.forward(), Ks(n, t, e, l);
|
|
3128
|
+
}, Xn = (n, t, e, s, r) => {
|
|
3129
3129
|
const i = n.doc, o = i.clientID;
|
|
3130
|
-
|
|
3131
|
-
const l =
|
|
3130
|
+
zs(e, r);
|
|
3131
|
+
const l = Ys(n, t, e, r);
|
|
3132
3132
|
t:
|
|
3133
3133
|
for (; e.right !== null && (s > 0 || l.size > 0 && (e.right.deleted || e.right.content.constructor === C)); ) {
|
|
3134
3134
|
if (!e.right.deleted)
|
|
@@ -3139,7 +3139,7 @@ const Xn = (n, t, e) => {
|
|
|
3139
3139
|
e.right.content
|
|
3140
3140
|
), h = r[c];
|
|
3141
3141
|
if (h !== void 0) {
|
|
3142
|
-
if (
|
|
3142
|
+
if (q(h, a))
|
|
3143
3143
|
l.delete(c);
|
|
3144
3144
|
else {
|
|
3145
3145
|
if (s === 0)
|
|
@@ -3164,10 +3164,10 @@ const Xn = (n, t, e) => {
|
|
|
3164
3164
|
`;
|
|
3165
3165
|
e.right = new E(b(o, L(i.store, o)), e.left, e.left && e.left.lastId, e.right, e.right && e.right.id, t, null, new $(c)), e.right.integrate(n, 0), e.forward();
|
|
3166
3166
|
}
|
|
3167
|
-
|
|
3168
|
-
},
|
|
3167
|
+
Ks(n, t, e, l);
|
|
3168
|
+
}, Xs = (n, t, e, s, r) => {
|
|
3169
3169
|
let i = t;
|
|
3170
|
-
const o =
|
|
3170
|
+
const o = R();
|
|
3171
3171
|
for (; i && (!i.countable || i.deleted); ) {
|
|
3172
3172
|
if (!i.deleted && i.content.constructor === C) {
|
|
3173
3173
|
const a = (
|
|
@@ -3224,7 +3224,7 @@ const Xn = (n, t, e) => {
|
|
|
3224
3224
|
let s = (
|
|
3225
3225
|
/** @type {Item} */
|
|
3226
3226
|
n._start
|
|
3227
|
-
), r = n._start, i =
|
|
3227
|
+
), r = n._start, i = R();
|
|
3228
3228
|
const o = Be(i);
|
|
3229
3229
|
for (; r; ) {
|
|
3230
3230
|
if (r.deleted === !1)
|
|
@@ -3237,7 +3237,7 @@ const Xn = (n, t, e) => {
|
|
|
3237
3237
|
);
|
|
3238
3238
|
break;
|
|
3239
3239
|
default:
|
|
3240
|
-
t +=
|
|
3240
|
+
t += Xs(e, s, r, i, o), i = Be(o), s = r;
|
|
3241
3241
|
break;
|
|
3242
3242
|
}
|
|
3243
3243
|
r = r.right;
|
|
@@ -3264,7 +3264,7 @@ const Xn = (n, t, e) => {
|
|
|
3264
3264
|
);
|
|
3265
3265
|
}
|
|
3266
3266
|
k(e, (s) => {
|
|
3267
|
-
|
|
3267
|
+
ps(n, n.deleteSet, (r) => {
|
|
3268
3268
|
if (r instanceof U || !/** @type {YText} */
|
|
3269
3269
|
r.parent._hasFormatting || t.has(
|
|
3270
3270
|
/** @type {YText} */
|
|
@@ -3280,12 +3280,12 @@ const Xn = (n, t, e) => {
|
|
|
3280
3280
|
for (const r of t)
|
|
3281
3281
|
Co(r);
|
|
3282
3282
|
});
|
|
3283
|
-
},
|
|
3283
|
+
}, Jn = (n, t, e) => {
|
|
3284
3284
|
const s = e, r = Be(t.currentAttributes), i = t.right;
|
|
3285
3285
|
for (; e > 0 && t.right !== null; ) {
|
|
3286
3286
|
if (t.right.deleted === !1)
|
|
3287
3287
|
switch (t.right.content.constructor) {
|
|
3288
|
-
case
|
|
3288
|
+
case G:
|
|
3289
3289
|
case pt:
|
|
3290
3290
|
case $:
|
|
3291
3291
|
e < t.right.length && et(n, b(t.right.id.client, t.right.id.clock + e)), e -= t.right.length, t.right.delete(n);
|
|
@@ -3293,7 +3293,7 @@ const Xn = (n, t, e) => {
|
|
|
3293
3293
|
}
|
|
3294
3294
|
t.forward();
|
|
3295
3295
|
}
|
|
3296
|
-
i &&
|
|
3296
|
+
i && Xs(n, i, t.right, r, t.currentAttributes);
|
|
3297
3297
|
const o = (
|
|
3298
3298
|
/** @type {AbstractType<any>} */
|
|
3299
3299
|
/** @type {Item} */
|
|
@@ -3370,7 +3370,7 @@ class Lo extends ye {
|
|
|
3370
3370
|
};
|
|
3371
3371
|
for (; o !== null; ) {
|
|
3372
3372
|
switch (o.content.constructor) {
|
|
3373
|
-
case
|
|
3373
|
+
case G:
|
|
3374
3374
|
case pt:
|
|
3375
3375
|
this.adds(o) ? this.deletes(o) || (u(), l = "insert", a = o.content.getContent()[0], u()) : this.deletes(o) ? (l !== "delete" && (u(), l = "delete"), d += 1) : o.deleted || (l !== "retain" && (u(), l = "retain"), h += 1);
|
|
3376
3376
|
break;
|
|
@@ -3386,16 +3386,16 @@ class Lo extends ye {
|
|
|
3386
3386
|
if (this.adds(o)) {
|
|
3387
3387
|
if (!this.deletes(o)) {
|
|
3388
3388
|
const w = r.get(f) || null;
|
|
3389
|
-
|
|
3389
|
+
q(w, g) ? g !== null && o.delete(s) : (l === "retain" && u(), q(g, i.get(f) || null) ? delete c[f] : c[f] = g);
|
|
3390
3390
|
}
|
|
3391
3391
|
} else if (this.deletes(o)) {
|
|
3392
3392
|
i.set(f, g);
|
|
3393
3393
|
const w = r.get(f) || null;
|
|
3394
|
-
|
|
3394
|
+
q(w, g) || (l === "retain" && u(), c[f] = w);
|
|
3395
3395
|
} else if (!o.deleted) {
|
|
3396
3396
|
i.set(f, g);
|
|
3397
3397
|
const w = c[f];
|
|
3398
|
-
w !== void 0 && (
|
|
3398
|
+
w !== void 0 && (q(w, g) ? w !== null && o.delete(s) : (l === "retain" && u(), g === null ? delete c[f] : c[f] = g));
|
|
3399
3399
|
}
|
|
3400
3400
|
o.deleted || (l === "insert" && u(), Lt(
|
|
3401
3401
|
r,
|
|
@@ -3510,9 +3510,9 @@ class Ct extends I {
|
|
|
3510
3510
|
if (o.insert !== void 0) {
|
|
3511
3511
|
const l = !e && typeof o.insert == "string" && i === t.length - 1 && r.right === null && o.insert.slice(-1) === `
|
|
3512
3512
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3513
|
-
(typeof l != "string" || l.length > 0) &&
|
|
3513
|
+
(typeof l != "string" || l.length > 0) && ve(s, this, r, l, o.attributes || {});
|
|
3514
3514
|
} else
|
|
3515
|
-
o.retain !== void 0 ?
|
|
3515
|
+
o.retain !== void 0 ? Xn(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && Jn(s, r, o.delete);
|
|
3516
3516
|
}
|
|
3517
3517
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
3518
3518
|
}
|
|
@@ -3553,7 +3553,7 @@ class Ct extends I {
|
|
|
3553
3553
|
c.content.str;
|
|
3554
3554
|
break;
|
|
3555
3555
|
}
|
|
3556
|
-
case
|
|
3556
|
+
case G:
|
|
3557
3557
|
case pt: {
|
|
3558
3558
|
a();
|
|
3559
3559
|
const d = {
|
|
@@ -3605,7 +3605,7 @@ class Ct extends I {
|
|
|
3605
3605
|
const o = Zt(i, this, t);
|
|
3606
3606
|
s || (s = {}, o.currentAttributes.forEach((l, c) => {
|
|
3607
3607
|
s[c] = l;
|
|
3608
|
-
})),
|
|
3608
|
+
})), ve(i, this, o, e, s);
|
|
3609
3609
|
}) : this._pending.push(() => this.insert(t, e, s));
|
|
3610
3610
|
}
|
|
3611
3611
|
/**
|
|
@@ -3622,7 +3622,7 @@ class Ct extends I {
|
|
|
3622
3622
|
const r = this.doc;
|
|
3623
3623
|
r !== null ? k(r, (i) => {
|
|
3624
3624
|
const o = Zt(i, this, t);
|
|
3625
|
-
|
|
3625
|
+
ve(i, this, o, e, s);
|
|
3626
3626
|
}) : this._pending.push(() => this.insertEmbed(t, e, s));
|
|
3627
3627
|
}
|
|
3628
3628
|
/**
|
|
@@ -3638,7 +3638,7 @@ class Ct extends I {
|
|
|
3638
3638
|
return;
|
|
3639
3639
|
const s = this.doc;
|
|
3640
3640
|
s !== null ? k(s, (r) => {
|
|
3641
|
-
|
|
3641
|
+
Jn(r, Zt(r, this, t), e);
|
|
3642
3642
|
}) : this._pending.push(() => this.delete(t, e));
|
|
3643
3643
|
}
|
|
3644
3644
|
/**
|
|
@@ -3657,7 +3657,7 @@ class Ct extends I {
|
|
|
3657
3657
|
const r = this.doc;
|
|
3658
3658
|
r !== null ? k(r, (i) => {
|
|
3659
3659
|
const o = Zt(i, this, t);
|
|
3660
|
-
o.right !== null &&
|
|
3660
|
+
o.right !== null && Xn(i, this, o, e, s);
|
|
3661
3661
|
}) : this._pending.push(() => this.format(t, e, s));
|
|
3662
3662
|
}
|
|
3663
3663
|
/**
|
|
@@ -3686,7 +3686,7 @@ class Ct extends I {
|
|
|
3686
3686
|
*/
|
|
3687
3687
|
setAttribute(t, e) {
|
|
3688
3688
|
this.doc !== null ? k(this.doc, (s) => {
|
|
3689
|
-
|
|
3689
|
+
gn(s, this, t, e);
|
|
3690
3690
|
}) : this._pending.push(() => this.setAttribute(t, e));
|
|
3691
3691
|
}
|
|
3692
3692
|
/**
|
|
@@ -3703,7 +3703,7 @@ class Ct extends I {
|
|
|
3703
3703
|
getAttribute(t) {
|
|
3704
3704
|
return (
|
|
3705
3705
|
/** @type {any} */
|
|
3706
|
-
|
|
3706
|
+
pn(this, t)
|
|
3707
3707
|
);
|
|
3708
3708
|
}
|
|
3709
3709
|
/**
|
|
@@ -3716,7 +3716,7 @@ class Ct extends I {
|
|
|
3716
3716
|
* @public
|
|
3717
3717
|
*/
|
|
3718
3718
|
getAttributes() {
|
|
3719
|
-
return
|
|
3719
|
+
return $s(this);
|
|
3720
3720
|
}
|
|
3721
3721
|
/**
|
|
3722
3722
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
@@ -3881,7 +3881,7 @@ class ut extends I {
|
|
|
3881
3881
|
* @return {string} The string representation of all children.
|
|
3882
3882
|
*/
|
|
3883
3883
|
toString() {
|
|
3884
|
-
return
|
|
3884
|
+
return Bs(this, (t) => t.toString()).join("");
|
|
3885
3885
|
}
|
|
3886
3886
|
/**
|
|
3887
3887
|
* @return {string}
|
|
@@ -3922,7 +3922,7 @@ class ut extends I {
|
|
|
3922
3922
|
*/
|
|
3923
3923
|
insert(t, e) {
|
|
3924
3924
|
this.doc !== null ? k(this.doc, (s) => {
|
|
3925
|
-
|
|
3925
|
+
Vs(s, this, t, e);
|
|
3926
3926
|
}) : this._prelimContent.splice(t, 0, ...e);
|
|
3927
3927
|
}
|
|
3928
3928
|
/**
|
|
@@ -3947,7 +3947,7 @@ class ut extends I {
|
|
|
3947
3947
|
this._prelimContent
|
|
3948
3948
|
), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
|
|
3949
3949
|
if (r === 0 && t !== null)
|
|
3950
|
-
throw
|
|
3950
|
+
throw X("Reference item not found");
|
|
3951
3951
|
s.splice(r, 0, ...e);
|
|
3952
3952
|
}
|
|
3953
3953
|
}
|
|
@@ -3959,7 +3959,7 @@ class ut extends I {
|
|
|
3959
3959
|
*/
|
|
3960
3960
|
delete(t, e = 1) {
|
|
3961
3961
|
this.doc !== null ? k(this.doc, (s) => {
|
|
3962
|
-
|
|
3962
|
+
Hs(s, this, t, e);
|
|
3963
3963
|
}) : this._prelimContent.splice(t, e);
|
|
3964
3964
|
}
|
|
3965
3965
|
/**
|
|
@@ -3968,7 +3968,7 @@ class ut extends I {
|
|
|
3968
3968
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
3969
3969
|
*/
|
|
3970
3970
|
toArray() {
|
|
3971
|
-
return
|
|
3971
|
+
return Rs(this);
|
|
3972
3972
|
}
|
|
3973
3973
|
/**
|
|
3974
3974
|
* Appends content to this YArray.
|
|
@@ -3993,7 +3993,7 @@ class ut extends I {
|
|
|
3993
3993
|
* @return {YXmlElement|YXmlText}
|
|
3994
3994
|
*/
|
|
3995
3995
|
get(t) {
|
|
3996
|
-
return
|
|
3996
|
+
return Ns(this, t);
|
|
3997
3997
|
}
|
|
3998
3998
|
/**
|
|
3999
3999
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -4003,7 +4003,7 @@ class ut extends I {
|
|
|
4003
4003
|
* @return {Array<YXmlElement|YXmlText>}
|
|
4004
4004
|
*/
|
|
4005
4005
|
slice(t = 0, e = this.length) {
|
|
4006
|
-
return
|
|
4006
|
+
return Os(this, t, e);
|
|
4007
4007
|
}
|
|
4008
4008
|
/**
|
|
4009
4009
|
* Executes a provided function on once on overy child element.
|
|
@@ -4025,7 +4025,7 @@ class ut extends I {
|
|
|
4025
4025
|
t.writeTypeRef(Wo);
|
|
4026
4026
|
}
|
|
4027
4027
|
}
|
|
4028
|
-
const
|
|
4028
|
+
const Mo = (n) => new ut();
|
|
4029
4029
|
class Vt extends ut {
|
|
4030
4030
|
constructor(t = "UNDEFINED") {
|
|
4031
4031
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
@@ -4131,7 +4131,7 @@ class Vt extends ut {
|
|
|
4131
4131
|
*/
|
|
4132
4132
|
setAttribute(t, e) {
|
|
4133
4133
|
this.doc !== null ? k(this.doc, (s) => {
|
|
4134
|
-
|
|
4134
|
+
gn(s, this, t, e);
|
|
4135
4135
|
}) : this._prelimAttrs.set(t, e);
|
|
4136
4136
|
}
|
|
4137
4137
|
/**
|
|
@@ -4148,7 +4148,7 @@ class Vt extends ut {
|
|
|
4148
4148
|
getAttribute(t) {
|
|
4149
4149
|
return (
|
|
4150
4150
|
/** @type {any} */
|
|
4151
|
-
|
|
4151
|
+
pn(this, t)
|
|
4152
4152
|
);
|
|
4153
4153
|
}
|
|
4154
4154
|
/**
|
|
@@ -4162,7 +4162,7 @@ class Vt extends ut {
|
|
|
4162
4162
|
hasAttribute(t) {
|
|
4163
4163
|
return (
|
|
4164
4164
|
/** @type {any} */
|
|
4165
|
-
|
|
4165
|
+
js(this, t)
|
|
4166
4166
|
);
|
|
4167
4167
|
}
|
|
4168
4168
|
/**
|
|
@@ -4175,7 +4175,7 @@ class Vt extends ut {
|
|
|
4175
4175
|
getAttributes() {
|
|
4176
4176
|
return (
|
|
4177
4177
|
/** @type {any} */
|
|
4178
|
-
|
|
4178
|
+
$s(this)
|
|
4179
4179
|
);
|
|
4180
4180
|
}
|
|
4181
4181
|
/**
|
|
@@ -4215,7 +4215,7 @@ class Vt extends ut {
|
|
|
4215
4215
|
t.writeTypeRef(Jo), t.writeKey(this.nodeName);
|
|
4216
4216
|
}
|
|
4217
4217
|
}
|
|
4218
|
-
const
|
|
4218
|
+
const vo = (n) => new Vt(n.readKey());
|
|
4219
4219
|
class xo extends ye {
|
|
4220
4220
|
/**
|
|
4221
4221
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
@@ -4377,7 +4377,7 @@ class he extends Ct {
|
|
|
4377
4377
|
}
|
|
4378
4378
|
}
|
|
4379
4379
|
const To = (n) => new he();
|
|
4380
|
-
class
|
|
4380
|
+
class wn {
|
|
4381
4381
|
/**
|
|
4382
4382
|
* @param {ID} id
|
|
4383
4383
|
* @param {number} length
|
|
@@ -4389,7 +4389,7 @@ class mn {
|
|
|
4389
4389
|
* @type {boolean}
|
|
4390
4390
|
*/
|
|
4391
4391
|
get deleted() {
|
|
4392
|
-
throw
|
|
4392
|
+
throw N();
|
|
4393
4393
|
}
|
|
4394
4394
|
/**
|
|
4395
4395
|
* Merge this struct with the item to the right.
|
|
@@ -4407,18 +4407,18 @@ class mn {
|
|
|
4407
4407
|
* @param {number} encodingRef
|
|
4408
4408
|
*/
|
|
4409
4409
|
write(t, e, s) {
|
|
4410
|
-
throw
|
|
4410
|
+
throw N();
|
|
4411
4411
|
}
|
|
4412
4412
|
/**
|
|
4413
4413
|
* @param {Transaction} transaction
|
|
4414
4414
|
* @param {number} offset
|
|
4415
4415
|
*/
|
|
4416
4416
|
integrate(t, e) {
|
|
4417
|
-
throw
|
|
4417
|
+
throw N();
|
|
4418
4418
|
}
|
|
4419
4419
|
}
|
|
4420
4420
|
const Oo = 0;
|
|
4421
|
-
class U extends
|
|
4421
|
+
class U extends wn {
|
|
4422
4422
|
get deleted() {
|
|
4423
4423
|
return !0;
|
|
4424
4424
|
}
|
|
@@ -4436,7 +4436,7 @@ class U extends mn {
|
|
|
4436
4436
|
* @param {number} offset
|
|
4437
4437
|
*/
|
|
4438
4438
|
integrate(t, e) {
|
|
4439
|
-
e > 0 && (this.id.clock += e, this.length -= e),
|
|
4439
|
+
e > 0 && (this.id.clock += e, this.length -= e), Is(t.doc.store, this);
|
|
4440
4440
|
}
|
|
4441
4441
|
/**
|
|
4442
4442
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
@@ -4490,7 +4490,7 @@ class zt {
|
|
|
4490
4490
|
* @return {ContentBinary}
|
|
4491
4491
|
*/
|
|
4492
4492
|
splice(t) {
|
|
4493
|
-
throw
|
|
4493
|
+
throw N();
|
|
4494
4494
|
}
|
|
4495
4495
|
/**
|
|
4496
4496
|
* @param {ContentBinary} right
|
|
@@ -4607,7 +4607,7 @@ class Ht {
|
|
|
4607
4607
|
return 1;
|
|
4608
4608
|
}
|
|
4609
4609
|
}
|
|
4610
|
-
const Bo = (n) => new Ht(n.readLen()),
|
|
4610
|
+
const Bo = (n) => new Ht(n.readLen()), Js = (n, t) => new gt({ guid: n, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
4611
4611
|
class Yt {
|
|
4612
4612
|
/**
|
|
4613
4613
|
* @param {Doc} doc
|
|
@@ -4639,14 +4639,14 @@ class Yt {
|
|
|
4639
4639
|
* @return {ContentDoc}
|
|
4640
4640
|
*/
|
|
4641
4641
|
copy() {
|
|
4642
|
-
return new Yt(
|
|
4642
|
+
return new Yt(Js(this.doc.guid, this.opts));
|
|
4643
4643
|
}
|
|
4644
4644
|
/**
|
|
4645
4645
|
* @param {number} offset
|
|
4646
4646
|
* @return {ContentDoc}
|
|
4647
4647
|
*/
|
|
4648
4648
|
splice(t) {
|
|
4649
|
-
throw
|
|
4649
|
+
throw N();
|
|
4650
4650
|
}
|
|
4651
4651
|
/**
|
|
4652
4652
|
* @param {ContentDoc} right
|
|
@@ -4687,7 +4687,7 @@ class Yt {
|
|
|
4687
4687
|
return 9;
|
|
4688
4688
|
}
|
|
4689
4689
|
}
|
|
4690
|
-
const No = (n) => new Yt(
|
|
4690
|
+
const No = (n) => new Yt(Js(n.readString(), n.readAny()));
|
|
4691
4691
|
class pt {
|
|
4692
4692
|
/**
|
|
4693
4693
|
* @param {Object} embed
|
|
@@ -4724,7 +4724,7 @@ class pt {
|
|
|
4724
4724
|
* @return {ContentEmbed}
|
|
4725
4725
|
*/
|
|
4726
4726
|
splice(t) {
|
|
4727
|
-
throw
|
|
4727
|
+
throw N();
|
|
4728
4728
|
}
|
|
4729
4729
|
/**
|
|
4730
4730
|
* @param {ContentEmbed} right
|
|
@@ -4801,7 +4801,7 @@ class C {
|
|
|
4801
4801
|
* @return {ContentFormat}
|
|
4802
4802
|
*/
|
|
4803
4803
|
splice(t) {
|
|
4804
|
-
throw
|
|
4804
|
+
throw N();
|
|
4805
4805
|
}
|
|
4806
4806
|
/**
|
|
4807
4807
|
* @param {ContentFormat} _right
|
|
@@ -5104,12 +5104,12 @@ const jo = (n) => new $(n.readString()), Ko = [
|
|
|
5104
5104
|
_o,
|
|
5105
5105
|
Do,
|
|
5106
5106
|
Io,
|
|
5107
|
-
Mo,
|
|
5108
5107
|
vo,
|
|
5108
|
+
Mo,
|
|
5109
5109
|
Uo,
|
|
5110
5110
|
To
|
|
5111
5111
|
], zo = 0, Yo = 1, Xo = 2, Jo = 3, Wo = 4, Go = 5, Po = 6;
|
|
5112
|
-
class
|
|
5112
|
+
class G {
|
|
5113
5113
|
/**
|
|
5114
5114
|
* @param {AbstractType<any>} type
|
|
5115
5115
|
*/
|
|
@@ -5138,14 +5138,14 @@ class P {
|
|
|
5138
5138
|
* @return {ContentType}
|
|
5139
5139
|
*/
|
|
5140
5140
|
copy() {
|
|
5141
|
-
return new
|
|
5141
|
+
return new G(this.type._copy());
|
|
5142
5142
|
}
|
|
5143
5143
|
/**
|
|
5144
5144
|
* @param {number} offset
|
|
5145
5145
|
* @return {ContentType}
|
|
5146
5146
|
*/
|
|
5147
5147
|
splice(t) {
|
|
5148
|
-
throw
|
|
5148
|
+
throw N();
|
|
5149
5149
|
}
|
|
5150
5150
|
/**
|
|
5151
5151
|
* @param {ContentType} right
|
|
@@ -5201,7 +5201,7 @@ class P {
|
|
|
5201
5201
|
return 7;
|
|
5202
5202
|
}
|
|
5203
5203
|
}
|
|
5204
|
-
const qo = (n) => new
|
|
5204
|
+
const qo = (n) => new G(Ko[n.readTypeRef()](n)), de = (n, t, e) => {
|
|
5205
5205
|
const { client: s, clock: r } = t.id, i = new E(
|
|
5206
5206
|
b(s, r + e),
|
|
5207
5207
|
t,
|
|
@@ -5214,7 +5214,7 @@ const qo = (n) => new P(Ko[n.readTypeRef()](n)), de = (n, t, e) => {
|
|
|
5214
5214
|
);
|
|
5215
5215
|
return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = b(t.redone.client, t.redone.clock + e)), t.right = i, i.right !== null && (i.right.left = i), n._mergeStructs.push(i), i.parentSub !== null && i.right === null && i.parent._map.set(i.parentSub, i), t.length = e, i;
|
|
5216
5216
|
};
|
|
5217
|
-
class E extends
|
|
5217
|
+
class E extends wn {
|
|
5218
5218
|
/**
|
|
5219
5219
|
* @param {ID} id
|
|
5220
5220
|
* @param {Item | null} left
|
|
@@ -5226,7 +5226,7 @@ class E extends mn {
|
|
|
5226
5226
|
* @param {AbstractContent} content
|
|
5227
5227
|
*/
|
|
5228
5228
|
constructor(t, e, s, r, i, o, l, c) {
|
|
5229
|
-
super(t, c.getLength()), this.origin = s, this.left = e, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = l, this.redone = null, this.content = c, this.info = this.content.isCountable() ?
|
|
5229
|
+
super(t, c.getLength()), this.origin = s, this.left = e, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = l, this.redone = null, this.content = c, this.info = this.content.isCountable() ? xn : 0;
|
|
5230
5230
|
}
|
|
5231
5231
|
/**
|
|
5232
5232
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5243,13 +5243,13 @@ class E extends mn {
|
|
|
5243
5243
|
* If true, do not garbage collect this Item.
|
|
5244
5244
|
*/
|
|
5245
5245
|
get keep() {
|
|
5246
|
-
return (this.info &
|
|
5246
|
+
return (this.info & vn) > 0;
|
|
5247
5247
|
}
|
|
5248
5248
|
set keep(t) {
|
|
5249
|
-
this.keep !== t && (this.info ^=
|
|
5249
|
+
this.keep !== t && (this.info ^= vn);
|
|
5250
5250
|
}
|
|
5251
5251
|
get countable() {
|
|
5252
|
-
return (this.info &
|
|
5252
|
+
return (this.info & xn) > 0;
|
|
5253
5253
|
}
|
|
5254
5254
|
/**
|
|
5255
5255
|
* Whether this item was deleted or not.
|
|
@@ -5278,12 +5278,12 @@ class E extends mn {
|
|
|
5278
5278
|
return this.rightOrigin.client;
|
|
5279
5279
|
if (this.parent && this.parent.constructor === yt && this.id.client !== this.parent.client && this.parent.clock >= L(e, this.parent.client))
|
|
5280
5280
|
return this.parent.client;
|
|
5281
|
-
if (this.origin && (this.left =
|
|
5281
|
+
if (this.origin && (this.left = $n(t, e, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = et(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === U || this.right && this.right.constructor === U)
|
|
5282
5282
|
this.parent = null;
|
|
5283
5283
|
else if (!this.parent)
|
|
5284
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);
|
|
5285
5285
|
else if (this.parent.constructor === yt) {
|
|
5286
|
-
const s =
|
|
5286
|
+
const s = Me(e, this.parent);
|
|
5287
5287
|
s.constructor === U ? this.parent = null : this.parent = /** @type {ContentType} */
|
|
5288
5288
|
s.content.type;
|
|
5289
5289
|
}
|
|
@@ -5294,7 +5294,7 @@ class E extends mn {
|
|
|
5294
5294
|
* @param {number} offset
|
|
5295
5295
|
*/
|
|
5296
5296
|
integrate(t, e) {
|
|
5297
|
-
if (e > 0 && (this.id.clock += e, this.left =
|
|
5297
|
+
if (e > 0 && (this.id.clock += e, this.left = $n(t, t.doc.store, b(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(e), this.length -= e), this.parent) {
|
|
5298
5298
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5299
5299
|
let s = this.left, r;
|
|
5300
5300
|
if (s !== null)
|
|
@@ -5313,8 +5313,8 @@ class E extends mn {
|
|
|
5313
5313
|
s = r, i.clear();
|
|
5314
5314
|
else if (Pt(this.rightOrigin, r.rightOrigin))
|
|
5315
5315
|
break;
|
|
5316
|
-
} else if (r.origin !== null && o.has(
|
|
5317
|
-
i.has(
|
|
5316
|
+
} else if (r.origin !== null && o.has(Me(t.doc.store, r.origin)))
|
|
5317
|
+
i.has(Me(t.doc.store, r.origin)) || (s = r, i.clear());
|
|
5318
5318
|
else
|
|
5319
5319
|
break;
|
|
5320
5320
|
r = r.right;
|
|
@@ -5335,7 +5335,7 @@ class E extends mn {
|
|
|
5335
5335
|
this.parent._start, this.parent._start = this;
|
|
5336
5336
|
this.right = s;
|
|
5337
5337
|
}
|
|
5338
|
-
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length),
|
|
5338
|
+
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), Is(t.doc.store, this), this.content.integrate(t, this), Kn(
|
|
5339
5339
|
t,
|
|
5340
5340
|
/** @type {AbstractType<any>} */
|
|
5341
5341
|
this.parent,
|
|
@@ -5399,7 +5399,7 @@ class E extends mn {
|
|
|
5399
5399
|
/** @type {AbstractType<any>} */
|
|
5400
5400
|
this.parent
|
|
5401
5401
|
);
|
|
5402
|
-
this.countable && this.parentSub === null && (e._length -= this.length), this.markDeleted(), ie(t.deleteSet, this.id.client, this.id.clock, this.length),
|
|
5402
|
+
this.countable && this.parentSub === null && (e._length -= this.length), this.markDeleted(), ie(t.deleteSet, this.id.client, this.id.clock, this.length), Kn(t, e, this.parentSub), this.content.delete(t);
|
|
5403
5403
|
}
|
|
5404
5404
|
}
|
|
5405
5405
|
/**
|
|
@@ -5443,7 +5443,7 @@ class E extends mn {
|
|
|
5443
5443
|
this.content.write(t, e);
|
|
5444
5444
|
}
|
|
5445
5445
|
}
|
|
5446
|
-
const
|
|
5446
|
+
const Ws = (n, t) => Zo[t & ge](n), Zo = [
|
|
5447
5447
|
() => {
|
|
5448
5448
|
V();
|
|
5449
5449
|
},
|
|
@@ -5471,7 +5471,7 @@ const Gs = (n, t) => Zo[t & ge](n), Zo = [
|
|
|
5471
5471
|
}
|
|
5472
5472
|
// 10 - Skip is not ItemContent
|
|
5473
5473
|
], Qo = 10;
|
|
5474
|
-
class T extends
|
|
5474
|
+
class T extends wn {
|
|
5475
5475
|
get deleted() {
|
|
5476
5476
|
return !0;
|
|
5477
5477
|
}
|
|
@@ -5507,13 +5507,13 @@ class T extends mn {
|
|
|
5507
5507
|
return null;
|
|
5508
5508
|
}
|
|
5509
5509
|
}
|
|
5510
|
-
const
|
|
5510
|
+
const Gs = (
|
|
5511
5511
|
/** @type {any} */
|
|
5512
5512
|
typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
|
|
5513
|
-
),
|
|
5514
|
-
Ps
|
|
5515
|
-
Ps
|
|
5516
|
-
const
|
|
5513
|
+
), Ps = "__ $YJS$ __";
|
|
5514
|
+
Gs[Ps] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5515
|
+
Gs[Ps] = !0;
|
|
5516
|
+
const qs = /* @__PURE__ */ new Map();
|
|
5517
5517
|
class tl {
|
|
5518
5518
|
/**
|
|
5519
5519
|
* @param {string} room
|
|
@@ -5525,48 +5525,48 @@ class tl {
|
|
|
5525
5525
|
* @param {ArrayBuffer} buf
|
|
5526
5526
|
*/
|
|
5527
5527
|
postMessage(t) {
|
|
5528
|
-
|
|
5528
|
+
ns.setItem(this.room, ai(ri(t)));
|
|
5529
5529
|
}
|
|
5530
5530
|
close() {
|
|
5531
5531
|
Tr(this._onChange);
|
|
5532
5532
|
}
|
|
5533
5533
|
}
|
|
5534
|
-
const el = typeof BroadcastChannel > "u" ? tl : BroadcastChannel,
|
|
5534
|
+
const el = typeof BroadcastChannel > "u" ? tl : BroadcastChannel, mn = (n) => J(qs, n, () => {
|
|
5535
5535
|
const t = lt(), e = new el(n);
|
|
5536
5536
|
return e.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
5537
5537
|
bc: e,
|
|
5538
5538
|
subs: t
|
|
5539
5539
|
};
|
|
5540
|
-
}), nl = (n, t) => (
|
|
5541
|
-
const e =
|
|
5542
|
-
return s && e.subs.size === 0 && (e.bc.close(),
|
|
5540
|
+
}), nl = (n, t) => (mn(n).subs.add(t), t), sl = (n, t) => {
|
|
5541
|
+
const e = mn(n), s = e.subs.delete(t);
|
|
5542
|
+
return s && e.subs.size === 0 && (e.bc.close(), qs.delete(n)), s;
|
|
5543
5543
|
}, mt = (n, t, e = null) => {
|
|
5544
|
-
const s =
|
|
5544
|
+
const s = mn(n);
|
|
5545
5545
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, e));
|
|
5546
|
-
},
|
|
5547
|
-
p(n,
|
|
5546
|
+
}, Zs = 0, yn = 1, Qs = 2, Ye = (n, t) => {
|
|
5547
|
+
p(n, Zs);
|
|
5548
5548
|
const e = Qi(t);
|
|
5549
5549
|
D(n, e);
|
|
5550
|
-
},
|
|
5551
|
-
p(n,
|
|
5552
|
-
}, rl = (n, t, e) =>
|
|
5550
|
+
}, tr = (n, t, e) => {
|
|
5551
|
+
p(n, yn), D(n, an(t, e));
|
|
5552
|
+
}, rl = (n, t, e) => tr(t, e, M(n)), er = (n, t, e) => {
|
|
5553
5553
|
try {
|
|
5554
|
-
|
|
5554
|
+
Ds(t, M(n), e);
|
|
5555
5555
|
} catch (s) {
|
|
5556
5556
|
console.error("Caught error while handling a Yjs update", s);
|
|
5557
5557
|
}
|
|
5558
5558
|
}, il = (n, t) => {
|
|
5559
|
-
p(n,
|
|
5560
|
-
}, ol =
|
|
5559
|
+
p(n, Qs), D(n, t);
|
|
5560
|
+
}, ol = er, ll = (n, t, e, s) => {
|
|
5561
5561
|
const r = m(n);
|
|
5562
5562
|
switch (r) {
|
|
5563
|
-
case
|
|
5563
|
+
case Zs:
|
|
5564
5564
|
rl(n, t, e);
|
|
5565
5565
|
break;
|
|
5566
|
-
case
|
|
5567
|
-
|
|
5566
|
+
case yn:
|
|
5567
|
+
er(n, e, s);
|
|
5568
5568
|
break;
|
|
5569
|
-
case
|
|
5569
|
+
case Qs:
|
|
5570
5570
|
ol(n, e, s);
|
|
5571
5571
|
break;
|
|
5572
5572
|
default:
|
|
@@ -5576,7 +5576,7 @@ const el = typeof BroadcastChannel > "u" ? tl : BroadcastChannel, yn = (n) => W(
|
|
|
5576
5576
|
}, cl = 0, al = (n, t, e) => {
|
|
5577
5577
|
switch (m(n)) {
|
|
5578
5578
|
case cl:
|
|
5579
|
-
e(t,
|
|
5579
|
+
e(t, Z(n));
|
|
5580
5580
|
}
|
|
5581
5581
|
}, Ue = 3e4;
|
|
5582
5582
|
class hl extends fe {
|
|
@@ -5592,8 +5592,8 @@ class hl extends fe {
|
|
|
5592
5592
|
const s = [];
|
|
5593
5593
|
this.meta.forEach((r, i) => {
|
|
5594
5594
|
i !== this.clientID && Ue <= e - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
5595
|
-
}), s.length > 0 &&
|
|
5596
|
-
},
|
|
5595
|
+
}), s.length > 0 && bn(this, s, "timeout");
|
|
5596
|
+
}, Y(Ue / 10)), t.on("destroy", () => {
|
|
5597
5597
|
this.destroy();
|
|
5598
5598
|
}), this.setLocalState({});
|
|
5599
5599
|
}
|
|
@@ -5636,7 +5636,7 @@ class hl extends fe {
|
|
|
5636
5636
|
return this.states;
|
|
5637
5637
|
}
|
|
5638
5638
|
}
|
|
5639
|
-
const
|
|
5639
|
+
const bn = (n, t, e) => {
|
|
5640
5640
|
const s = [];
|
|
5641
5641
|
for (let r = 0; r < t.length; r++) {
|
|
5642
5642
|
const i = t[r];
|
|
@@ -5656,7 +5656,7 @@ const kn = (n, t, e) => {
|
|
|
5656
5656
|
}
|
|
5657
5657
|
s.length > 0 && (n.emit("change", [{ added: [], updated: [], removed: s }, e]), n.emit("update", [{ added: [], updated: [], removed: s }, e]));
|
|
5658
5658
|
}, Ut = (n, t, e = n.states) => {
|
|
5659
|
-
const s = t.length, r =
|
|
5659
|
+
const s = t.length, r = v();
|
|
5660
5660
|
p(r, s);
|
|
5661
5661
|
for (let i = 0; i < s; i++) {
|
|
5662
5662
|
const o = t[i], l = e.get(o) || null, c = (
|
|
@@ -5671,7 +5671,7 @@ const kn = (n, t, e) => {
|
|
|
5671
5671
|
for (let h = 0; h < a; h++) {
|
|
5672
5672
|
const d = m(s);
|
|
5673
5673
|
let u = m(s);
|
|
5674
|
-
const f = JSON.parse(
|
|
5674
|
+
const f = JSON.parse(Z(s)), g = n.meta.get(d), w = n.states.get(d), S = g === void 0 ? 0 : g.clock;
|
|
5675
5675
|
(S < u || S === u && f === null && n.states.has(d)) && (f === null ? d === n.clientID && n.getLocalState() != null ? u++ : n.states.delete(d) : n.states.set(d, f), n.meta.set(d, {
|
|
5676
5676
|
clock: u,
|
|
5677
5677
|
lastUpdated: r
|
|
@@ -5687,7 +5687,7 @@ const kn = (n, t, e) => {
|
|
|
5687
5687
|
removed: c
|
|
5688
5688
|
}, e]);
|
|
5689
5689
|
}, dl = (n) => Nr(n, (t, e) => `${encodeURIComponent(e)}=${encodeURIComponent(t)}`).join("&");
|
|
5690
|
-
var st = 0,
|
|
5690
|
+
var st = 0, nr = 3, kt = 1, fl = 2, gl = typeof window > "u";
|
|
5691
5691
|
function pl(n, t) {
|
|
5692
5692
|
if (!n)
|
|
5693
5693
|
throw new Error(t);
|
|
@@ -5701,9 +5701,9 @@ Xt[st] = (n, t, e, s, r) => {
|
|
|
5701
5701
|
e.doc,
|
|
5702
5702
|
e
|
|
5703
5703
|
);
|
|
5704
|
-
s && i ===
|
|
5704
|
+
s && i === yn && !e.synced && (e.synced = !0);
|
|
5705
5705
|
};
|
|
5706
|
-
Xt[
|
|
5706
|
+
Xt[nr] = (n, t, e, s, r) => {
|
|
5707
5707
|
p(n, kt), D(
|
|
5708
5708
|
n,
|
|
5709
5709
|
Ut(
|
|
@@ -5715,7 +5715,7 @@ Xt[sr] = (n, t, e, s, r) => {
|
|
|
5715
5715
|
Xt[kt] = (n, t, e, s, r) => {
|
|
5716
5716
|
ul(
|
|
5717
5717
|
e.awareness,
|
|
5718
|
-
|
|
5718
|
+
M(t),
|
|
5719
5719
|
e
|
|
5720
5720
|
);
|
|
5721
5721
|
};
|
|
@@ -5726,28 +5726,28 @@ Xt[fl] = (n, t, e, s, r) => {
|
|
|
5726
5726
|
(i, o) => wl(e, o)
|
|
5727
5727
|
);
|
|
5728
5728
|
};
|
|
5729
|
-
var
|
|
5729
|
+
var Wn = 3e4;
|
|
5730
5730
|
function wl(n, t) {
|
|
5731
5731
|
console.warn(`Permission denied to access ${n.url}.
|
|
5732
5732
|
${t}`);
|
|
5733
5733
|
}
|
|
5734
|
-
function
|
|
5735
|
-
const s = nt(t), r =
|
|
5734
|
+
function sr(n, t, e) {
|
|
5735
|
+
const s = nt(t), r = v(), i = m(s), o = n.messageHandlers[i];
|
|
5736
5736
|
return /** @type {any} */ o ? o(r, s, n, e, i) : console.error("Unable to compute message"), r;
|
|
5737
5737
|
}
|
|
5738
|
-
function
|
|
5738
|
+
function rr(n) {
|
|
5739
5739
|
if (n.shouldConnect && n.ws === null) {
|
|
5740
5740
|
const t = new n._WS(n.url);
|
|
5741
5741
|
t.binaryType = "arraybuffer", n.ws = t, n.wsconnecting = !0, n.wsconnected = !1, n.synced = !1, t.onmessage = (e) => {
|
|
5742
5742
|
if (typeof e.data == "string")
|
|
5743
5743
|
return;
|
|
5744
5744
|
n.wsLastMessageReceived = ct();
|
|
5745
|
-
const s =
|
|
5746
|
-
|
|
5745
|
+
const s = sr(n, new Uint8Array(e.data), !0);
|
|
5746
|
+
en(s) > 1 && t.send(_(s));
|
|
5747
5747
|
}, t.onerror = (e) => {
|
|
5748
5748
|
n.emit("connection-error", [e, n]);
|
|
5749
5749
|
}, t.onclose = (e) => {
|
|
5750
|
-
n.emit("connection-close", [e, n]), n.ws = null, n.wsconnecting = !1, n.wsconnected ? (n.wsconnected = !1, n.synced = !1,
|
|
5750
|
+
n.emit("connection-close", [e, n]), n.ws = null, n.wsconnecting = !1, n.wsconnected ? (n.wsconnected = !1, n.synced = !1, bn(
|
|
5751
5751
|
n.awareness,
|
|
5752
5752
|
Array.from(n.awareness.getStates().keys()).filter(
|
|
5753
5753
|
(s) => s !== n.doc.clientID
|
|
@@ -5758,8 +5758,8 @@ function ir(n) {
|
|
|
5758
5758
|
status: "disconnected"
|
|
5759
5759
|
}
|
|
5760
5760
|
])) : n.wsUnsuccessfulReconnects++, setTimeout(
|
|
5761
|
-
|
|
5762
|
-
|
|
5761
|
+
rr,
|
|
5762
|
+
Ge(
|
|
5763
5763
|
Sr(2, n.wsUnsuccessfulReconnects) * 100,
|
|
5764
5764
|
n.maxBackoffTime
|
|
5765
5765
|
),
|
|
@@ -5771,9 +5771,9 @@ function ir(n) {
|
|
|
5771
5771
|
status: "connected"
|
|
5772
5772
|
}
|
|
5773
5773
|
]);
|
|
5774
|
-
const e =
|
|
5774
|
+
const e = v();
|
|
5775
5775
|
if (p(e, st), Ye(e, n.doc), t.send(_(e)), n.awareness.getLocalState() !== null) {
|
|
5776
|
-
const s =
|
|
5776
|
+
const s = v();
|
|
5777
5777
|
p(s, kt), D(
|
|
5778
5778
|
s,
|
|
5779
5779
|
Ut(n.awareness, [
|
|
@@ -5837,35 +5837,35 @@ var ml = class extends fe {
|
|
|
5837
5837
|
this.maxBackoffTime = a, this.bcChannel = t + "/" + e, this.url = t + "/" + e + (d.length === 0 ? "" : "?" + d), this.roomname = e, this.doc = s, this._WS = l, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = Xt.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, c > 0 && (this._resyncInterval = /** @type {any} */
|
|
5838
5838
|
setInterval(() => {
|
|
5839
5839
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
5840
|
-
const u =
|
|
5840
|
+
const u = v();
|
|
5841
5841
|
p(u, st), Ye(u, s), this.ws.send(_(u));
|
|
5842
5842
|
}
|
|
5843
5843
|
}, c)), this._bcSubscriber = (u, f) => {
|
|
5844
5844
|
if (f !== this) {
|
|
5845
|
-
const g =
|
|
5846
|
-
|
|
5845
|
+
const g = sr(this, new Uint8Array(u), !1);
|
|
5846
|
+
en(g) > 1 && mt(this.bcChannel, _(g), this);
|
|
5847
5847
|
}
|
|
5848
5848
|
}, this._updateHandler = (u, f) => {
|
|
5849
5849
|
if (f !== this) {
|
|
5850
|
-
const g =
|
|
5850
|
+
const g = v();
|
|
5851
5851
|
p(g, st), il(g, u), Te(this, _(g));
|
|
5852
5852
|
}
|
|
5853
5853
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: u, updated: f, removed: g }, w) => {
|
|
5854
|
-
const S = u.concat(f).concat(g), j =
|
|
5854
|
+
const S = u.concat(f).concat(g), j = v();
|
|
5855
5855
|
p(j, kt), D(
|
|
5856
5856
|
j,
|
|
5857
5857
|
Ut(i, S)
|
|
5858
5858
|
), Te(this, _(j));
|
|
5859
5859
|
}, this._unloadHandler = () => {
|
|
5860
|
-
|
|
5860
|
+
bn(
|
|
5861
5861
|
this.awareness,
|
|
5862
5862
|
[s.clientID],
|
|
5863
5863
|
"window unload"
|
|
5864
5864
|
);
|
|
5865
5865
|
}, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
|
|
5866
5866
|
setInterval(() => {
|
|
5867
|
-
this.wsconnected &&
|
|
5868
|
-
},
|
|
5867
|
+
this.wsconnected && Wn < ct() - this.wsLastMessageReceived && (pl(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
5868
|
+
}, Wn / 10), r && this.connect();
|
|
5869
5869
|
}
|
|
5870
5870
|
/**
|
|
5871
5871
|
* @type {boolean}
|
|
@@ -5883,17 +5883,17 @@ var ml = class extends fe {
|
|
|
5883
5883
|
if (this.disableBc)
|
|
5884
5884
|
return;
|
|
5885
5885
|
this.bcconnected || (nl(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
5886
|
-
const t =
|
|
5886
|
+
const t = v();
|
|
5887
5887
|
p(t, st), Ye(t, this.doc), mt(this.bcChannel, _(t), this);
|
|
5888
|
-
const e =
|
|
5889
|
-
p(e, st),
|
|
5890
|
-
const s =
|
|
5891
|
-
p(s,
|
|
5888
|
+
const e = v();
|
|
5889
|
+
p(e, st), tr(e, this.doc), mt(this.bcChannel, _(e), this);
|
|
5890
|
+
const s = v();
|
|
5891
|
+
p(s, nr), mt(
|
|
5892
5892
|
this.bcChannel,
|
|
5893
5893
|
_(s),
|
|
5894
5894
|
this
|
|
5895
5895
|
);
|
|
5896
|
-
const r =
|
|
5896
|
+
const r = v();
|
|
5897
5897
|
p(r, kt), D(
|
|
5898
5898
|
r,
|
|
5899
5899
|
Ut(this.awareness, [
|
|
@@ -5906,7 +5906,7 @@ var ml = class extends fe {
|
|
|
5906
5906
|
);
|
|
5907
5907
|
}
|
|
5908
5908
|
disconnectBc() {
|
|
5909
|
-
const t =
|
|
5909
|
+
const t = v();
|
|
5910
5910
|
p(t, kt), D(
|
|
5911
5911
|
t,
|
|
5912
5912
|
Ut(
|
|
@@ -5920,7 +5920,7 @@ var ml = class extends fe {
|
|
|
5920
5920
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
5921
5921
|
}
|
|
5922
5922
|
connect() {
|
|
5923
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
5923
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (rr(this), this.connectBc());
|
|
5924
5924
|
}
|
|
5925
5925
|
};
|
|
5926
5926
|
function yl() {
|
|
@@ -5932,7 +5932,7 @@ function yl() {
|
|
|
5932
5932
|
return n > 0 ? (s = (n + s) % 16 | 0, n = Math.floor(n / 16)) : (s = (t + s) % 16 | 0, t = Math.floor(t / 16)), (e === "x" ? s : s & 3 | 8).toString(16);
|
|
5933
5933
|
});
|
|
5934
5934
|
}
|
|
5935
|
-
function
|
|
5935
|
+
function Gn(n, t, e) {
|
|
5936
5936
|
if (typeof n !== e)
|
|
5937
5937
|
throw new Error(
|
|
5938
5938
|
`Invalid "${t}" parameter provided to YPartyKitProvider. Expected: ${e}, received: ${n}`
|
|
@@ -5942,9 +5942,9 @@ var bl = class extends WebSocket {
|
|
|
5942
5942
|
send(n) {
|
|
5943
5943
|
typeof n != "string" && mr(n, (t) => super.send(t));
|
|
5944
5944
|
}
|
|
5945
|
-
}, rt,
|
|
5945
|
+
}, rt, Qn, kl = (Qn = class extends ml {
|
|
5946
5946
|
constructor(t, e, s, r = {}) {
|
|
5947
|
-
|
|
5947
|
+
Gn(t, "host", "string"), Gn(e, "room", "string"), t = t.replace(/^(http|https|ws|wss):\/\//, ""), t.endsWith("/") && t.slice(0, -1);
|
|
5948
5948
|
const i = `${t.startsWith("localhost:") || t.startsWith("127.0.0.1:") ? "ws" : "wss"}://${t}${r.party ? `/parties/${r.party}` : "/party"}`, o = r.connectionId ?? yl(), { params: l, connect: c = !0, ...a } = r, h = {
|
|
5949
5949
|
...a,
|
|
5950
5950
|
connect: !1,
|
|
@@ -5952,8 +5952,8 @@ var bl = class extends WebSocket {
|
|
|
5952
5952
|
};
|
|
5953
5953
|
super(i, e, s ?? new gt(), h);
|
|
5954
5954
|
y(this, "id");
|
|
5955
|
-
|
|
5956
|
-
this.id = o,
|
|
5955
|
+
Dn(this, rt, void 0);
|
|
5956
|
+
this.id = o, En(this, rt, l), c && this.connect();
|
|
5957
5957
|
}
|
|
5958
5958
|
connect() {
|
|
5959
5959
|
Promise.resolve(
|
|
@@ -5969,12 +5969,12 @@ var bl = class extends WebSocket {
|
|
|
5969
5969
|
throw console.error("Failed to open connecton to PartyKit", t), new Error(t);
|
|
5970
5970
|
});
|
|
5971
5971
|
}
|
|
5972
|
-
}, rt = new WeakMap(),
|
|
5972
|
+
}, rt = new WeakMap(), Qn);
|
|
5973
5973
|
const wt = (n) => Dt((t, e) => {
|
|
5974
5974
|
n.onerror = (s) => e(new Error(s.target.error)), n.onsuccess = (s) => t(s.target.result);
|
|
5975
5975
|
}), _l = (n, t) => Dt((e, s) => {
|
|
5976
5976
|
const r = indexedDB.open(n);
|
|
5977
|
-
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(
|
|
5977
|
+
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(X(i.target.error)), r.onsuccess = (i) => {
|
|
5978
5978
|
const o = i.target.result;
|
|
5979
5979
|
o.onversionchange = () => {
|
|
5980
5980
|
o.close();
|
|
@@ -5985,38 +5985,38 @@ const wt = (n) => Dt((t, e) => {
|
|
|
5985
5985
|
// @ts-ignore
|
|
5986
5986
|
n.createObjectStore.apply(n, e)
|
|
5987
5987
|
)
|
|
5988
|
-
),
|
|
5988
|
+
), Mt = (n, t, e = "readwrite") => {
|
|
5989
5989
|
const s = n.transaction(t, e);
|
|
5990
5990
|
return t.map((r) => xl(s, r));
|
|
5991
|
-
},
|
|
5991
|
+
}, ir = (n, t) => wt(n.count(t)), El = (n, t) => wt(n.get(t)), or = (n, t) => wt(n.delete(t)), Cl = (n, t, e) => wt(n.put(t, e)), Xe = (n, t) => wt(n.add(t)), Al = (n, t, e) => wt(n.getAll(t, e)), Ll = (n, t, e) => {
|
|
5992
5992
|
let s = null;
|
|
5993
|
-
return
|
|
5994
|
-
}, Il = (n, t = null) => Ll(n, t, "prev"),
|
|
5993
|
+
return vl(n, t, (r) => (s = r, !1), e).then(() => s);
|
|
5994
|
+
}, Il = (n, t = null) => Ll(n, t, "prev"), Ml = (n, t) => Dt((e, s) => {
|
|
5995
5995
|
n.onerror = s, n.onsuccess = async (r) => {
|
|
5996
5996
|
const i = r.target.result;
|
|
5997
5997
|
if (i === null || await t(i) === !1)
|
|
5998
5998
|
return e();
|
|
5999
5999
|
i.continue();
|
|
6000
6000
|
};
|
|
6001
|
-
}),
|
|
6001
|
+
}), vl = (n, t, e, s = "next") => Ml(n.openKeyCursor(t, s), (r) => e(r.key)), xl = (n, t) => n.objectStore(t), Ul = (n, t) => IDBKeyRange.upperBound(n, t), Tl = (n, t) => IDBKeyRange.lowerBound(n, t), Oe = "custom", lr = "updates", cr = 500, ar = (n, t = () => {
|
|
6002
6002
|
}, e = () => {
|
|
6003
6003
|
}) => {
|
|
6004
|
-
const [s] =
|
|
6004
|
+
const [s] = Mt(
|
|
6005
6005
|
/** @type {IDBDatabase} */
|
|
6006
6006
|
n.db,
|
|
6007
|
-
[
|
|
6007
|
+
[lr]
|
|
6008
6008
|
);
|
|
6009
6009
|
return Al(s, Tl(n._dbref, !1)).then((r) => {
|
|
6010
6010
|
n._destroyed || (t(s), k(n.doc, () => {
|
|
6011
|
-
r.forEach((i) =>
|
|
6011
|
+
r.forEach((i) => Ds(n.doc, i));
|
|
6012
6012
|
}, n, !1), e(s));
|
|
6013
6013
|
}).then(() => Il(s).then((r) => {
|
|
6014
6014
|
n._dbref = r + 1;
|
|
6015
|
-
})).then(() =>
|
|
6015
|
+
})).then(() => ir(s).then((r) => {
|
|
6016
6016
|
n._dbsize = r;
|
|
6017
6017
|
})).then(() => s);
|
|
6018
|
-
}, Ol = (n, t = !0) =>
|
|
6019
|
-
(t || n._dbsize >=
|
|
6018
|
+
}, Ol = (n, t = !0) => ar(n).then((e) => {
|
|
6019
|
+
(t || n._dbsize >= cr) && Xe(e, an(n.doc)).then(() => or(e, Ul(n._dbref, !0))).then(() => ir(e).then((s) => {
|
|
6020
6020
|
n._dbsize = s;
|
|
6021
6021
|
}));
|
|
6022
6022
|
});
|
|
@@ -6033,19 +6033,19 @@ class Rl extends fe {
|
|
|
6033
6033
|
["custom"]
|
|
6034
6034
|
])
|
|
6035
6035
|
), this.whenSynced = Dt((s) => this.on("synced", () => s(this))), this._db.then((s) => {
|
|
6036
|
-
this.db = s,
|
|
6036
|
+
this.db = s, ar(this, (o) => Xe(o, an(e)), () => {
|
|
6037
6037
|
if (this._destroyed)
|
|
6038
6038
|
return this;
|
|
6039
6039
|
this.synced = !0, this.emit("synced", [this]);
|
|
6040
6040
|
});
|
|
6041
6041
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (s, r) => {
|
|
6042
6042
|
if (this.db && r !== this) {
|
|
6043
|
-
const [i] =
|
|
6043
|
+
const [i] = Mt(
|
|
6044
6044
|
/** @type {IDBDatabase} */
|
|
6045
6045
|
this.db,
|
|
6046
|
-
[
|
|
6046
|
+
[lr]
|
|
6047
6047
|
);
|
|
6048
|
-
Xe(i, s), ++this._dbsize >=
|
|
6048
|
+
Xe(i, s), ++this._dbsize >= cr && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
|
|
6049
6049
|
Ol(this, !1), this._storeTimeoutId = null;
|
|
6050
6050
|
}, this._storeTimeout));
|
|
6051
6051
|
}
|
|
@@ -6072,7 +6072,7 @@ class Rl extends fe {
|
|
|
6072
6072
|
*/
|
|
6073
6073
|
get(t) {
|
|
6074
6074
|
return this._db.then((e) => {
|
|
6075
|
-
const [s] =
|
|
6075
|
+
const [s] = Mt(e, [Oe], "readonly");
|
|
6076
6076
|
return El(s, t);
|
|
6077
6077
|
});
|
|
6078
6078
|
}
|
|
@@ -6083,7 +6083,7 @@ class Rl extends fe {
|
|
|
6083
6083
|
*/
|
|
6084
6084
|
set(t, e) {
|
|
6085
6085
|
return this._db.then((s) => {
|
|
6086
|
-
const [r] =
|
|
6086
|
+
const [r] = Mt(s, [Oe]);
|
|
6087
6087
|
return Cl(r, e, t);
|
|
6088
6088
|
});
|
|
6089
6089
|
}
|
|
@@ -6093,8 +6093,8 @@ class Rl extends fe {
|
|
|
6093
6093
|
*/
|
|
6094
6094
|
del(t) {
|
|
6095
6095
|
return this._db.then((e) => {
|
|
6096
|
-
const [s] =
|
|
6097
|
-
return
|
|
6096
|
+
const [s] = Mt(e, [Oe]);
|
|
6097
|
+
return or(s, t);
|
|
6098
6098
|
});
|
|
6099
6099
|
}
|
|
6100
6100
|
}
|
|
@@ -6108,10 +6108,10 @@ var _e = /* @__PURE__ */ ((n) => (n.CanPlay = "can-play", n.CanMove = "can-move"
|
|
|
6108
6108
|
function Fl(n) {
|
|
6109
6109
|
return n.id;
|
|
6110
6110
|
}
|
|
6111
|
-
const
|
|
6111
|
+
const hr = `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>")
|
|
6112
6112
|
16 0,
|
|
6113
6113
|
auto`, Vl = `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`;
|
|
6114
|
-
function
|
|
6114
|
+
function Pn(n, { getData: t, getElement: e, getLocalData: s, setLocalData: r }) {
|
|
6115
6115
|
const i = t(), o = s(), l = e();
|
|
6116
6116
|
if (o.isHovering = !0, n.altKey) {
|
|
6117
6117
|
if (i.scale <= 0.5) {
|
|
@@ -6124,7 +6124,7 @@ function qn(n, { getData: t, getElement: e, getLocalData: s, setLocalData: r })
|
|
|
6124
6124
|
l.style.cursor = "not-allowed";
|
|
6125
6125
|
return;
|
|
6126
6126
|
}
|
|
6127
|
-
l.style.cursor =
|
|
6127
|
+
l.style.cursor = hr;
|
|
6128
6128
|
}
|
|
6129
6129
|
r(o);
|
|
6130
6130
|
}
|
|
@@ -6187,12 +6187,14 @@ const Hl = {
|
|
|
6187
6187
|
"can-toggle"
|
|
6188
6188
|
/* CanToggle */
|
|
6189
6189
|
]: {
|
|
6190
|
-
defaultData: !1,
|
|
6190
|
+
defaultData: { on: !1 },
|
|
6191
6191
|
updateElement: ({ element: n, data: t }) => {
|
|
6192
|
-
|
|
6192
|
+
const e = typeof t == "object" ? t.on : t;
|
|
6193
|
+
n.classList.toggle("clicked", e);
|
|
6193
6194
|
},
|
|
6194
6195
|
onClick: (n, { data: t, setData: e }) => {
|
|
6195
|
-
|
|
6196
|
+
const s = typeof t == "object" ? t.on : t;
|
|
6197
|
+
e({ on: !s });
|
|
6196
6198
|
},
|
|
6197
6199
|
resetShortcut: "shiftKey"
|
|
6198
6200
|
},
|
|
@@ -6212,7 +6214,7 @@ const Hl = {
|
|
|
6212
6214
|
return;
|
|
6213
6215
|
i -= 0.1;
|
|
6214
6216
|
} else {
|
|
6215
|
-
if (e.style.cursor =
|
|
6217
|
+
if (e.style.cursor = hr, t.scale >= r.maxScale)
|
|
6216
6218
|
return;
|
|
6217
6219
|
i += 0.1;
|
|
6218
6220
|
}
|
|
@@ -6220,8 +6222,8 @@ const Hl = {
|
|
|
6220
6222
|
},
|
|
6221
6223
|
additionalSetup: (n) => {
|
|
6222
6224
|
n.getElement().addEventListener("mouseenter", (t) => {
|
|
6223
|
-
|
|
6224
|
-
const e = (s) =>
|
|
6225
|
+
Pn(t, n);
|
|
6226
|
+
const e = (s) => Pn(s, n);
|
|
6225
6227
|
document.addEventListener("keydown", e), document.addEventListener("keyup", e), n.getElement().addEventListener("mouseleave", (s) => {
|
|
6226
6228
|
document.removeEventListener("keydown", e), document.removeEventListener("keyup", e);
|
|
6227
6229
|
});
|
|
@@ -6291,7 +6293,7 @@ const Hl = {
|
|
|
6291
6293
|
), !0) : !1;
|
|
6292
6294
|
}
|
|
6293
6295
|
}
|
|
6294
|
-
},
|
|
6296
|
+
}, qn = (n, t = 300) => {
|
|
6295
6297
|
let e;
|
|
6296
6298
|
return function(...s) {
|
|
6297
6299
|
clearTimeout(e), e = setTimeout(() => n.apply(this, s), t);
|
|
@@ -6333,7 +6335,7 @@ class $l {
|
|
|
6333
6335
|
debounceMs: f,
|
|
6334
6336
|
triggerAwarenessUpdate: g
|
|
6335
6337
|
} = t;
|
|
6336
|
-
this.element = e, this.defaultData = i instanceof Function ? i(e) : i, this.localData = o instanceof Function ? o(e) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange =
|
|
6338
|
+
this.element = e, this.defaultData = i instanceof Function ? i(e) : i, this.localData = o instanceof Function ? o(e) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange = qn(this.onChange, f), this.onAwarenessChange = r, this.updateElement = h, this.updateElementAwareness = d;
|
|
6337
6339
|
const w = c === void 0 ? this.defaultData : c;
|
|
6338
6340
|
a !== void 0 && (this.__awareness = a);
|
|
6339
6341
|
const S = l instanceof Function ? l(e) : l;
|
|
@@ -6352,7 +6354,7 @@ class $l {
|
|
|
6352
6354
|
debounceMs: h,
|
|
6353
6355
|
triggerAwarenessUpdate: d
|
|
6354
6356
|
}) {
|
|
6355
|
-
this.triggerAwarenessUpdate = d, this.onChange = e, this.debouncedOnChange =
|
|
6357
|
+
this.triggerAwarenessUpdate = d, this.onChange = e, this.debouncedOnChange = qn(this.onChange, h), this.onAwarenessChange = s, this.updateElement = r, this.updateElementAwareness = i, o && !this.onClick && t.addEventListener("click", (u) => {
|
|
6356
6358
|
var f;
|
|
6357
6359
|
(f = this.onClick) == null || f.call(this, u, this.getEventHandlerData());
|
|
6358
6360
|
}), this.onClick = o, l && !this.onDrag && (t.addEventListener("touchstart", (u) => {
|
|
@@ -6470,20 +6472,20 @@ const jl = "playhtml.spencerc99.partykit.dev", Re = new gt();
|
|
|
6470
6472
|
function Kl() {
|
|
6471
6473
|
return window.location.pathname + window.location.search;
|
|
6472
6474
|
}
|
|
6473
|
-
let
|
|
6474
|
-
const
|
|
6475
|
+
let Q, F, O;
|
|
6476
|
+
const Zn = /* @__PURE__ */ new Map();
|
|
6475
6477
|
let Jt = Hl;
|
|
6476
|
-
function
|
|
6478
|
+
function ur() {
|
|
6477
6479
|
return [_e.CanPlay, ...Object.keys(Jt)];
|
|
6478
6480
|
}
|
|
6479
|
-
let
|
|
6480
|
-
function
|
|
6481
|
+
let kn = !1, Je = !0;
|
|
6482
|
+
function zl({
|
|
6481
6483
|
// TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
|
|
6482
6484
|
room: n = Kl(),
|
|
6483
6485
|
host: t = jl,
|
|
6484
6486
|
extraCapabilities: e
|
|
6485
6487
|
} = {}) {
|
|
6486
|
-
if (!
|
|
6488
|
+
if (!Je) {
|
|
6487
6489
|
console.error("playhtml already set up!");
|
|
6488
6490
|
return;
|
|
6489
6491
|
}
|
|
@@ -6495,49 +6497,44 @@ function dr({
|
|
|
6495
6497
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
6496
6498
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
6497
6499
|
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
|
|
6498
|
-
),
|
|
6500
|
+
), Q = new kl(r, s, Re), F = Re.getMap("playhtml-global"), O = /* @__PURE__ */ new Map(), new Rl(s, Re), We.globalData = F, We.elementHandlers = O, e)
|
|
6499
6501
|
for (const [i, o] of Object.entries(e))
|
|
6500
6502
|
Jt[i] = o;
|
|
6501
|
-
return
|
|
6502
|
-
i || console.error("Issue connecting to yjs..."),
|
|
6503
|
-
}),
|
|
6503
|
+
return Q.on("sync", (i) => {
|
|
6504
|
+
i || console.error("Issue connecting to yjs..."), kn = !0, console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝"), fr();
|
|
6505
|
+
}), Q;
|
|
6504
6506
|
}
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
"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."
|
|
6508
|
-
), dr());
|
|
6509
|
-
}, 3e3);
|
|
6510
|
-
function zl(n, t) {
|
|
6511
|
-
const e = Y.awareness.getLocalState();
|
|
6507
|
+
function Yl(n, t) {
|
|
6508
|
+
const e = Q.awareness.getLocalState();
|
|
6512
6509
|
return ((e == null ? void 0 : e[n]) ?? {})[t];
|
|
6513
6510
|
}
|
|
6514
|
-
function
|
|
6511
|
+
function _n(n) {
|
|
6515
6512
|
return n instanceof HTMLElement;
|
|
6516
6513
|
}
|
|
6517
|
-
function
|
|
6518
|
-
const r =
|
|
6514
|
+
function Xl(n, t, e, s) {
|
|
6515
|
+
const r = F.get(t);
|
|
6519
6516
|
return {
|
|
6520
6517
|
...e,
|
|
6521
6518
|
data: r.get(s) ?? e.defaultData,
|
|
6522
|
-
awareness:
|
|
6519
|
+
awareness: Yl(t, s) ?? e.myDefaultAwareness !== void 0 ? [e.myDefaultAwareness] : void 0,
|
|
6523
6520
|
element: n,
|
|
6524
6521
|
onChange: (o) => {
|
|
6525
6522
|
r.get(s) !== o && r.set(s, o);
|
|
6526
6523
|
},
|
|
6527
6524
|
onAwarenessChange: (o) => {
|
|
6528
6525
|
var c;
|
|
6529
|
-
const l = ((c =
|
|
6530
|
-
l[s] !== o && (l[s] = o,
|
|
6526
|
+
const l = ((c = Q.awareness.getLocalState()) == null ? void 0 : c[t]) || {};
|
|
6527
|
+
l[s] !== o && (l[s] = o, Q.awareness.setLocalStateField(t, l));
|
|
6531
6528
|
},
|
|
6532
6529
|
triggerAwarenessUpdate: () => {
|
|
6533
|
-
|
|
6530
|
+
dr();
|
|
6534
6531
|
}
|
|
6535
6532
|
};
|
|
6536
6533
|
}
|
|
6537
|
-
function
|
|
6538
|
-
return n.defaultData !== void 0 && n.updateElement !== void 0;
|
|
6534
|
+
function Jl(n) {
|
|
6535
|
+
return n.defaultData !== void 0 && typeof n.defaultData == "object" && n.updateElement !== void 0;
|
|
6539
6536
|
}
|
|
6540
|
-
function
|
|
6537
|
+
function Wl(n, t) {
|
|
6541
6538
|
if (n === _e.CanPlay) {
|
|
6542
6539
|
const e = t;
|
|
6543
6540
|
return {
|
|
@@ -6557,17 +6554,17 @@ function Jl(n, t) {
|
|
|
6557
6554
|
}
|
|
6558
6555
|
return Jt[n];
|
|
6559
6556
|
}
|
|
6560
|
-
function
|
|
6557
|
+
function dr() {
|
|
6561
6558
|
const n = /* @__PURE__ */ new Map();
|
|
6562
6559
|
function t(e, s, r, i) {
|
|
6563
6560
|
n.has(e) || n.set(e, /* @__PURE__ */ new Map());
|
|
6564
6561
|
const o = n.get(e);
|
|
6565
6562
|
o.has(s) || o.set(s, /* @__PURE__ */ new Map()), o.get(s).set(r, i);
|
|
6566
6563
|
}
|
|
6567
|
-
|
|
6564
|
+
Q.awareness.getStates().forEach((e, s) => {
|
|
6568
6565
|
var r;
|
|
6569
6566
|
for (const [i, o] of Object.entries(e)) {
|
|
6570
|
-
const l =
|
|
6567
|
+
const l = O.get(i);
|
|
6571
6568
|
if (l)
|
|
6572
6569
|
for (const [c, a] of l) {
|
|
6573
6570
|
if (!(c in o))
|
|
@@ -6582,7 +6579,7 @@ function fr() {
|
|
|
6582
6579
|
}
|
|
6583
6580
|
}
|
|
6584
6581
|
for (const [i, o] of n) {
|
|
6585
|
-
const l =
|
|
6582
|
+
const l = O.get(i);
|
|
6586
6583
|
if (l)
|
|
6587
6584
|
for (const [c, a] of l) {
|
|
6588
6585
|
const h = (r = o.get(c)) == null ? void 0 : r.values();
|
|
@@ -6594,44 +6591,44 @@ function fr() {
|
|
|
6594
6591
|
}
|
|
6595
6592
|
});
|
|
6596
6593
|
}
|
|
6597
|
-
function
|
|
6598
|
-
|
|
6599
|
-
for (const n of Je()) {
|
|
6594
|
+
function fr() {
|
|
6595
|
+
for (const n of ur()) {
|
|
6600
6596
|
const t = Array.from(
|
|
6601
6597
|
document.querySelectorAll(`[${n}]`)
|
|
6602
|
-
).filter(
|
|
6598
|
+
).filter(_n);
|
|
6603
6599
|
if (t.length)
|
|
6604
6600
|
for (let e = 0; e < t.length; e++) {
|
|
6605
6601
|
const s = t[e];
|
|
6606
6602
|
Se(s, n);
|
|
6607
6603
|
}
|
|
6608
6604
|
}
|
|
6609
|
-
|
|
6605
|
+
Je && (F.observe((n) => {
|
|
6610
6606
|
n.changes.keys.forEach((t, e) => {
|
|
6611
|
-
t.action === "add" &&
|
|
6607
|
+
t.action === "add" && F.set(e, F.get(e));
|
|
6612
6608
|
});
|
|
6613
|
-
}),
|
|
6609
|
+
}), Q.awareness.on("change", () => dr()), Je = !1);
|
|
6614
6610
|
}
|
|
6615
|
-
const
|
|
6616
|
-
init:
|
|
6611
|
+
const We = {
|
|
6612
|
+
init: zl,
|
|
6613
|
+
setupPlayElements: fr,
|
|
6617
6614
|
setupPlayElement: ql,
|
|
6618
6615
|
removePlayElement: Zl,
|
|
6619
6616
|
setupPlayElementForTag: Se,
|
|
6620
6617
|
globalData: void 0,
|
|
6621
6618
|
elementHandlers: void 0
|
|
6622
6619
|
};
|
|
6623
|
-
window.playhtml =
|
|
6620
|
+
window.playhtml = We;
|
|
6624
6621
|
function Gl(n) {
|
|
6625
|
-
if (
|
|
6622
|
+
if (O.has(n) || !kn)
|
|
6626
6623
|
return;
|
|
6627
|
-
|
|
6628
|
-
const t =
|
|
6624
|
+
O.has(n) || O.set(n, /* @__PURE__ */ new Map()), n !== _e.CanPlay && Jt[n], F.get(n) || F.set(n, new ht());
|
|
6625
|
+
const t = F.get(n);
|
|
6629
6626
|
t.observe((e) => {
|
|
6630
6627
|
e.changes.keys.forEach((s, r) => {
|
|
6631
|
-
const i =
|
|
6628
|
+
const i = O.get(n);
|
|
6632
6629
|
if (s.action === "add") {
|
|
6633
6630
|
const o = document.getElementById(r);
|
|
6634
|
-
if (!
|
|
6631
|
+
if (!_n(o)) {
|
|
6635
6632
|
console.log(`Element ${r} not an HTML element. Ignoring.`);
|
|
6636
6633
|
return;
|
|
6637
6634
|
}
|
|
@@ -6650,13 +6647,13 @@ function Pl(n, t) {
|
|
|
6650
6647
|
}
|
|
6651
6648
|
function Se(n, t) {
|
|
6652
6649
|
var l;
|
|
6653
|
-
if (!Pl(n, t) || !
|
|
6650
|
+
if (!Pl(n, t) || !kn)
|
|
6654
6651
|
return;
|
|
6655
6652
|
if (!n.id) {
|
|
6656
6653
|
const c = n.getAttribute("selector-id");
|
|
6657
6654
|
if (c) {
|
|
6658
|
-
const a =
|
|
6659
|
-
n.id = btoa(`${t}-${c}-${a}`),
|
|
6655
|
+
const a = Zn.get(c) ?? 0;
|
|
6656
|
+
n.id = btoa(`${t}-${c}-${a}`), Zn.set(c, a + 1);
|
|
6660
6657
|
} else
|
|
6661
6658
|
n.id = btoa(`${t}-${n.innerHTML}}`);
|
|
6662
6659
|
}
|
|
@@ -6668,17 +6665,17 @@ function Se(n, t) {
|
|
|
6668
6665
|
return;
|
|
6669
6666
|
}
|
|
6670
6667
|
Gl(t);
|
|
6671
|
-
const s =
|
|
6668
|
+
const s = O.get(t), r = Wl(
|
|
6672
6669
|
t,
|
|
6673
6670
|
n
|
|
6674
6671
|
);
|
|
6675
|
-
if (!
|
|
6672
|
+
if (!Jl(r)) {
|
|
6676
6673
|
console.error(
|
|
6677
6674
|
`Element ${e} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`
|
|
6678
6675
|
);
|
|
6679
6676
|
return;
|
|
6680
6677
|
}
|
|
6681
|
-
const i =
|
|
6678
|
+
const i = F.get(t), o = Xl(
|
|
6682
6679
|
n,
|
|
6683
6680
|
t,
|
|
6684
6681
|
r,
|
|
@@ -6692,20 +6689,20 @@ function Se(n, t) {
|
|
|
6692
6689
|
i.get(e) === void 0 && r.defaultData !== void 0 && i.set(e, r.defaultData), (l = o.triggerAwarenessUpdate) == null || l.call(o), n.classList.add("__playhtml-element"), n.classList.add(`__playhtml-${t}`), n.style.setProperty("--jiggle-delay", `${Math.random() * 1}s;}`);
|
|
6693
6690
|
}
|
|
6694
6691
|
function ql(n) {
|
|
6695
|
-
if (!
|
|
6692
|
+
if (!_n(n)) {
|
|
6696
6693
|
console.log(`Element ${n.id} not an HTML element. Ignoring.`);
|
|
6697
6694
|
return;
|
|
6698
6695
|
}
|
|
6699
|
-
for (const t of
|
|
6696
|
+
for (const t of ur())
|
|
6700
6697
|
n.hasAttribute(t) && Se(n, t);
|
|
6701
6698
|
}
|
|
6702
6699
|
function Zl(n) {
|
|
6703
6700
|
if (!(!n || !n.id))
|
|
6704
|
-
for (const t of Object.keys(
|
|
6705
|
-
const e =
|
|
6701
|
+
for (const t of Object.keys(O)) {
|
|
6702
|
+
const e = O.get(t);
|
|
6706
6703
|
e.has(n.id) && e.delete(n.id);
|
|
6707
6704
|
}
|
|
6708
6705
|
}
|
|
6709
6706
|
export {
|
|
6710
|
-
|
|
6707
|
+
We as playhtml
|
|
6711
6708
|
};
|