playhtml 2.1.5 → 2.1.7
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 +4 -0
- package/README.md +1 -3
- package/dist/playhtml.es.js +906 -832
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/playhtml.es.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
var Yr = (e, t, n) => t in e ?
|
|
3
|
-
var y = (e, t, n) => (Yr(e, typeof t != "symbol" ? t + "" : t, n), n),
|
|
1
|
+
var Kr = Object.defineProperty;
|
|
2
|
+
var Yr = (e, t, n) => t in e ? Kr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var y = (e, t, n) => (Yr(e, typeof t != "symbol" ? t + "" : t, n), n), Bn = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var ie = (e, t, n) => (
|
|
7
|
+
var ie = (e, t, n) => (Bn(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Vn = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
|
-
},
|
|
12
|
-
var oe = 1e6, Xr = "y-pk-batch",
|
|
11
|
+
}, Fn = (e, t, n, s) => (Bn(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n);
|
|
12
|
+
var oe = 1e6, Xr = "y-pk-batch", Hn = !1, Nt = (e, t) => {
|
|
13
13
|
if (e.byteLength <= oe) {
|
|
14
14
|
t.send(e);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
Hn || (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: ${(e.byteLength / 1e3 / 1e3).toFixed(1)}MB`
|
|
21
|
-
),
|
|
21
|
+
), Hn = !0);
|
|
22
22
|
const n = (Date.now() + Math.random()).toString(36).substring(10), s = Math.ceil(e.byteLength / oe);
|
|
23
23
|
t.send(
|
|
24
|
-
|
|
24
|
+
jn({
|
|
25
25
|
id: n,
|
|
26
26
|
type: "start",
|
|
27
27
|
size: e.byteLength,
|
|
@@ -34,7 +34,7 @@ var oe = 1e6, Xr = "y-pk-batch", jn = !1, $t = (e, t) => {
|
|
|
34
34
|
t.send(c), i += 1, r += c.byteLength;
|
|
35
35
|
}
|
|
36
36
|
t.send(
|
|
37
|
-
|
|
37
|
+
jn({
|
|
38
38
|
id: n,
|
|
39
39
|
type: "end",
|
|
40
40
|
size: r,
|
|
@@ -42,25 +42,25 @@ var oe = 1e6, Xr = "y-pk-batch", jn = !1, $t = (e, t) => {
|
|
|
42
42
|
})
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
-
function
|
|
45
|
+
function jn(e) {
|
|
46
46
|
return `${Xr}#${JSON.stringify(e)}`;
|
|
47
47
|
}
|
|
48
|
-
const
|
|
48
|
+
const kt = () => /* @__PURE__ */ new Map(), bs = (e, t, n) => {
|
|
49
49
|
let s = e.get(t);
|
|
50
50
|
return s === void 0 && e.set(t, s = n()), s;
|
|
51
|
-
},
|
|
51
|
+
}, Ss = () => /* @__PURE__ */ new Set(), Jr = Array.from, Wr = String.fromCharCode, Pr = (e) => e.toLowerCase(), Gr = /^\s*/g, qr = (e) => e.replace(Gr, ""), Zr = /([A-Z])/g, zn = (e, t) => qr(e.replace(Zr, (n) => `${t}${Pr(n)}`)), Qr = (e) => {
|
|
52
52
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
53
53
|
for (let r = 0; r < n; r++)
|
|
54
54
|
s[r] = /** @type {number} */
|
|
55
55
|
t.codePointAt(r);
|
|
56
56
|
return s;
|
|
57
|
-
},
|
|
57
|
+
}, Ht = (
|
|
58
58
|
/** @type {TextEncoder} */
|
|
59
59
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
60
|
-
), ti = (e) =>
|
|
60
|
+
), ti = (e) => Ht.encode(e), ei = Ht ? ti : Qr;
|
|
61
61
|
let Ne = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
62
62
|
Ne && Ne.decode(new Uint8Array()).length === 1 && (Ne = null);
|
|
63
|
-
const
|
|
63
|
+
const Kn = (e) => e === void 0 ? null : e;
|
|
64
64
|
let ni = class {
|
|
65
65
|
constructor() {
|
|
66
66
|
this.map = /* @__PURE__ */ new Map();
|
|
@@ -78,12 +78,12 @@ let ni = class {
|
|
|
78
78
|
getItem(t) {
|
|
79
79
|
return this.map.get(t);
|
|
80
80
|
}
|
|
81
|
-
},
|
|
81
|
+
}, _s = new ni(), gn = !0;
|
|
82
82
|
try {
|
|
83
|
-
typeof localStorage < "u" && localStorage && (
|
|
83
|
+
typeof localStorage < "u" && localStorage && (_s = localStorage, gn = !1);
|
|
84
84
|
} catch {
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const ks = _s, si = (e) => gn || addEventListener(
|
|
87
87
|
"storage",
|
|
88
88
|
/** @type {any} */
|
|
89
89
|
e
|
|
@@ -96,12 +96,12 @@ const Ds = ks, si = (e) => gn || addEventListener(
|
|
|
96
96
|
for (const s in e)
|
|
97
97
|
n.push(t(e[s], s));
|
|
98
98
|
return n;
|
|
99
|
-
}, oi = (e, t) => t.includes(e),
|
|
99
|
+
}, oi = (e, t) => t.includes(e), It = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", Ds = typeof window < "u" && typeof document < "u" && !It;
|
|
100
100
|
let V;
|
|
101
101
|
const ci = () => {
|
|
102
102
|
if (V === void 0)
|
|
103
|
-
if (
|
|
104
|
-
V =
|
|
103
|
+
if (It) {
|
|
104
|
+
V = kt();
|
|
105
105
|
const e = process.argv;
|
|
106
106
|
let t = null;
|
|
107
107
|
for (let n = 0; n < e.length; n++) {
|
|
@@ -110,29 +110,29 @@ const ci = () => {
|
|
|
110
110
|
}
|
|
111
111
|
t !== null && V.set(t, "");
|
|
112
112
|
} else
|
|
113
|
-
typeof location == "object" ? (V =
|
|
113
|
+
typeof location == "object" ? (V = kt(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
114
114
|
if (e.length !== 0) {
|
|
115
115
|
const [t, n] = e.split("=");
|
|
116
116
|
V.set(`--${zn(t, "-")}`, n), V.set(`-${zn(t, "-")}`, n);
|
|
117
117
|
}
|
|
118
|
-
})) : V =
|
|
118
|
+
})) : V = kt();
|
|
119
119
|
return V;
|
|
120
|
-
}, Ge = (e) => ci().has(e), qe = (e) =>
|
|
120
|
+
}, Ge = (e) => ci().has(e), qe = (e) => Kn(It ? process.env[e.toUpperCase().replaceAll("-", "_")] : ks.getItem(e)), li = (e) => Ge("--" + e) || qe(e) !== null;
|
|
121
121
|
li("production");
|
|
122
|
-
const
|
|
123
|
-
!Ge("no-colors") && (!
|
|
124
|
-
const ai = Math.floor,
|
|
122
|
+
const Yn = It && oi(process.env.FORCE_COLOR, ["true", "1", "2"]);
|
|
123
|
+
!Ge("no-colors") && (!It || process.stdout.isTTY || Yn) && (!It || Ge("color") || Yn || qe("COLORTERM") !== null || (qe("TERM") || "").includes("color"));
|
|
124
|
+
const ai = Math.floor, Es = (e, t) => e < t ? e : t, hi = (e, t) => e > t ? e : t, ui = Math.pow, Cs = 128, ue = 127, di = Number.MAX_SAFE_INTEGER;
|
|
125
125
|
let fi = class {
|
|
126
126
|
constructor() {
|
|
127
127
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
const
|
|
130
|
+
const $ = () => new fi(), pn = (e) => {
|
|
131
131
|
let t = e.cpos;
|
|
132
132
|
for (let n = 0; n < e.bufs.length; n++)
|
|
133
133
|
t += e.bufs[n].length;
|
|
134
134
|
return t;
|
|
135
|
-
},
|
|
135
|
+
}, U = (e) => {
|
|
136
136
|
const t = new Uint8Array(pn(e));
|
|
137
137
|
let n = 0;
|
|
138
138
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
@@ -145,16 +145,16 @@ const R = () => new fi(), pn = (e) => {
|
|
|
145
145
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
146
146
|
}, v = (e, t) => {
|
|
147
147
|
for (; t > ue; )
|
|
148
|
-
we(e,
|
|
148
|
+
we(e, Cs | ue & t), t = ai(t / 128);
|
|
149
149
|
we(e, ue & t);
|
|
150
150
|
}, Ze = new Uint8Array(3e4), gi = Ze.length / 3, pi = (e, t) => {
|
|
151
151
|
if (t.length < gi) {
|
|
152
|
-
const n =
|
|
152
|
+
const n = Ht.encodeInto(t, Ze).written || 0;
|
|
153
153
|
v(e, n);
|
|
154
154
|
for (let s = 0; s < n; s++)
|
|
155
155
|
we(e, Ze[s]);
|
|
156
156
|
} else
|
|
157
|
-
|
|
157
|
+
Dt(e, ei(t));
|
|
158
158
|
}, wi = (e, t) => {
|
|
159
159
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
160
160
|
v(e, s);
|
|
@@ -165,14 +165,14 @@ const R = () => new fi(), pn = (e) => {
|
|
|
165
165
|
n.codePointAt(r)
|
|
166
166
|
);
|
|
167
167
|
};
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
Ht && /** @type {any} */
|
|
169
|
+
Ht.encodeInto;
|
|
170
170
|
const mi = (e, t) => {
|
|
171
|
-
const n = e.cbuf.length, s = e.cpos, r =
|
|
171
|
+
const n = e.cbuf.length, s = e.cpos, r = Es(n - s, t.length), i = t.length - r;
|
|
172
172
|
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(hi(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
173
|
-
},
|
|
173
|
+
}, Dt = (e, t) => {
|
|
174
174
|
v(e, t.byteLength), mi(e, t);
|
|
175
|
-
},
|
|
175
|
+
}, As = (e) => new Error(e), yi = As("Unexpected end of array"), bi = As("Integer out of Range");
|
|
176
176
|
let Si = class {
|
|
177
177
|
/**
|
|
178
178
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
@@ -184,12 +184,12 @@ let Si = class {
|
|
|
184
184
|
const _i = (e) => new Si(e), ki = (e, t) => {
|
|
185
185
|
const n = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
186
186
|
return e.pos += t, n;
|
|
187
|
-
}, Di = (e) => ki(e,
|
|
187
|
+
}, Di = (e) => ki(e, Ls(e)), Ls = (e) => {
|
|
188
188
|
let t = 0, n = 1;
|
|
189
189
|
const s = e.arr.length;
|
|
190
190
|
for (; e.pos < s; ) {
|
|
191
191
|
const r = e.arr[e.pos++];
|
|
192
|
-
if (t = t + (r & ue) * n, n *= 128, r <
|
|
192
|
+
if (t = t + (r & ue) * n, n *= 128, r < Cs)
|
|
193
193
|
return t;
|
|
194
194
|
if (t > di)
|
|
195
195
|
throw bi;
|
|
@@ -208,7 +208,7 @@ const _i = (e) => new Si(e), ki = (e, t) => {
|
|
|
208
208
|
}, Mi = (e) => {
|
|
209
209
|
const t = Buffer.from(e, "base64");
|
|
210
210
|
return Ci(t.buffer, t.byteOffset, t.byteLength);
|
|
211
|
-
}, xi =
|
|
211
|
+
}, xi = Ds ? Li : Ii, Ui = Ds ? vi : Mi, Is = /* @__PURE__ */ new Map();
|
|
212
212
|
class Ti {
|
|
213
213
|
/**
|
|
214
214
|
* @param {string} room
|
|
@@ -220,35 +220,35 @@ class Ti {
|
|
|
220
220
|
* @param {ArrayBuffer} buf
|
|
221
221
|
*/
|
|
222
222
|
postMessage(t) {
|
|
223
|
-
|
|
223
|
+
ks.setItem(this.room, xi(Ai(t)));
|
|
224
224
|
}
|
|
225
225
|
close() {
|
|
226
226
|
ri(this._onChange);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
const Oi = typeof BroadcastChannel > "u" ? Ti : BroadcastChannel, wn = (e) =>
|
|
230
|
-
const t =
|
|
229
|
+
const Oi = typeof BroadcastChannel > "u" ? Ti : BroadcastChannel, wn = (e) => bs(Is, e, () => {
|
|
230
|
+
const t = Ss(), n = new Oi(e);
|
|
231
231
|
return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
232
232
|
bc: n,
|
|
233
233
|
subs: t
|
|
234
234
|
};
|
|
235
235
|
}), Ri = (e, t) => (wn(e).subs.add(t), t), $i = (e, t) => {
|
|
236
236
|
const n = wn(e), s = n.subs.delete(t);
|
|
237
|
-
return s && n.subs.size === 0 && (n.bc.close(),
|
|
238
|
-
},
|
|
237
|
+
return s && n.subs.size === 0 && (n.bc.close(), Is.delete(e)), s;
|
|
238
|
+
}, St = (e, t, n = null) => {
|
|
239
239
|
const s = wn(e);
|
|
240
240
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
|
|
241
241
|
};
|
|
242
242
|
let Ni = class {
|
|
243
243
|
constructor() {
|
|
244
|
-
this._observers =
|
|
244
|
+
this._observers = kt();
|
|
245
245
|
}
|
|
246
246
|
/**
|
|
247
247
|
* @param {N} name
|
|
248
248
|
* @param {function} f
|
|
249
249
|
*/
|
|
250
250
|
on(t, n) {
|
|
251
|
-
|
|
251
|
+
bs(this._observers, t, Ss).add(n);
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* @param {N} name
|
|
@@ -278,18 +278,18 @@ let Ni = class {
|
|
|
278
278
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
279
279
|
*/
|
|
280
280
|
emit(t, n) {
|
|
281
|
-
return Jr((this._observers.get(t) ||
|
|
281
|
+
return Jr((this._observers.get(t) || kt()).values()).forEach((s) => s(...n));
|
|
282
282
|
}
|
|
283
283
|
destroy() {
|
|
284
|
-
this._observers =
|
|
284
|
+
this._observers = kt();
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
const Qe = Date.now, Bi = (e) => ii(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"),
|
|
288
|
-
const t =
|
|
287
|
+
const Qe = Date.now, Bi = (e) => ii(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), M = () => /* @__PURE__ */ new Map(), tn = (e) => {
|
|
288
|
+
const t = M();
|
|
289
289
|
return e.forEach((n, s) => {
|
|
290
290
|
t.set(s, n);
|
|
291
291
|
}), t;
|
|
292
|
-
},
|
|
292
|
+
}, Z = (e, t, n) => {
|
|
293
293
|
let s = e.get(t);
|
|
294
294
|
return s === void 0 && e.set(t, s = n()), s;
|
|
295
295
|
}, Vi = (e, t) => {
|
|
@@ -302,20 +302,82 @@ const Qe = Date.now, Bi = (e) => ii(e, (t, n) => `${encodeURIComponent(n)}=${enc
|
|
|
302
302
|
if (t(s, n))
|
|
303
303
|
return !0;
|
|
304
304
|
return !1;
|
|
305
|
-
},
|
|
305
|
+
}, at = () => /* @__PURE__ */ new Set(), Be = (e) => e[e.length - 1], Hi = (e, t) => {
|
|
306
306
|
for (let n = 0; n < t.length; n++)
|
|
307
307
|
e.push(t[n]);
|
|
308
|
-
},
|
|
309
|
-
class
|
|
308
|
+
}, P = Array.from, ji = Array.isArray;
|
|
309
|
+
class zi {
|
|
310
310
|
constructor() {
|
|
311
|
-
this._observers =
|
|
311
|
+
this._observers = M();
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* @template {string} NAME
|
|
315
|
+
* @param {NAME} name
|
|
316
|
+
* @param {EVENTS[NAME]} f
|
|
317
|
+
*/
|
|
318
|
+
on(t, n) {
|
|
319
|
+
return Z(
|
|
320
|
+
this._observers,
|
|
321
|
+
/** @type {string} */
|
|
322
|
+
t,
|
|
323
|
+
at
|
|
324
|
+
).add(n), n;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* @template {string} NAME
|
|
328
|
+
* @param {NAME} name
|
|
329
|
+
* @param {EVENTS[NAME]} f
|
|
330
|
+
*/
|
|
331
|
+
once(t, n) {
|
|
332
|
+
const s = (...r) => {
|
|
333
|
+
this.off(
|
|
334
|
+
t,
|
|
335
|
+
/** @type {any} */
|
|
336
|
+
s
|
|
337
|
+
), n(...r);
|
|
338
|
+
};
|
|
339
|
+
this.on(
|
|
340
|
+
t,
|
|
341
|
+
/** @type {any} */
|
|
342
|
+
s
|
|
343
|
+
);
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* @template {string} NAME
|
|
347
|
+
* @param {NAME} name
|
|
348
|
+
* @param {EVENTS[NAME]} f
|
|
349
|
+
*/
|
|
350
|
+
off(t, n) {
|
|
351
|
+
const s = this._observers.get(t);
|
|
352
|
+
s !== void 0 && (s.delete(n), s.size === 0 && this._observers.delete(t));
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Emit a named event. All registered event listeners that listen to the
|
|
356
|
+
* specified name will receive the event.
|
|
357
|
+
*
|
|
358
|
+
* @todo This should catch exceptions
|
|
359
|
+
*
|
|
360
|
+
* @template {string} NAME
|
|
361
|
+
* @param {NAME} name The event name.
|
|
362
|
+
* @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.
|
|
363
|
+
*/
|
|
364
|
+
emit(t, n) {
|
|
365
|
+
return P((this._observers.get(t) || M()).values()).forEach((s) => s(...n));
|
|
366
|
+
}
|
|
367
|
+
destroy() {
|
|
368
|
+
this._observers = M();
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
class vs {
|
|
372
|
+
constructor() {
|
|
373
|
+
this._observers = M();
|
|
312
374
|
}
|
|
313
375
|
/**
|
|
314
376
|
* @param {N} name
|
|
315
377
|
* @param {function} f
|
|
316
378
|
*/
|
|
317
379
|
on(t, n) {
|
|
318
|
-
|
|
380
|
+
Z(this._observers, t, at).add(n);
|
|
319
381
|
}
|
|
320
382
|
/**
|
|
321
383
|
* @param {N} name
|
|
@@ -345,26 +407,26 @@ class mn {
|
|
|
345
407
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
346
408
|
*/
|
|
347
409
|
emit(t, n) {
|
|
348
|
-
return
|
|
410
|
+
return P((this._observers.get(t) || M()).values()).forEach((s) => s(...n));
|
|
349
411
|
}
|
|
350
412
|
destroy() {
|
|
351
|
-
this._observers =
|
|
413
|
+
this._observers = M();
|
|
352
414
|
}
|
|
353
415
|
}
|
|
354
|
-
const
|
|
416
|
+
const G = Math.floor, de = Math.abs, Ms = (e, t) => e < t ? e : t, pt = (e, t) => e > t ? e : t, xs = (e) => e !== 0 ? e < 0 : 1 / e < 0, Ki = (e) => e.toLowerCase(), Yi = /^\s*/g, Xi = (e) => e.replace(Yi, ""), Ji = /([A-Z])/g, Xn = (e, t) => Xi(e.replace(Ji, (n) => `${t}${Ki(n)}`)), Wi = (e) => {
|
|
355
417
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
356
418
|
for (let r = 0; r < n; r++)
|
|
357
419
|
s[r] = /** @type {number} */
|
|
358
420
|
t.codePointAt(r);
|
|
359
421
|
return s;
|
|
360
|
-
},
|
|
422
|
+
}, jt = (
|
|
361
423
|
/** @type {TextEncoder} */
|
|
362
424
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
363
|
-
),
|
|
364
|
-
let
|
|
365
|
-
|
|
366
|
-
const
|
|
367
|
-
class
|
|
425
|
+
), Pi = (e) => jt.encode(e), Gi = jt ? Pi : Wi;
|
|
426
|
+
let Bt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
427
|
+
Bt && Bt.decode(new Uint8Array()).length === 1 && (Bt = null);
|
|
428
|
+
const Jn = (e) => e === void 0 ? null : e;
|
|
429
|
+
class qi {
|
|
368
430
|
constructor() {
|
|
369
431
|
this.map = /* @__PURE__ */ new Map();
|
|
370
432
|
}
|
|
@@ -382,33 +444,33 @@ class Gi {
|
|
|
382
444
|
return this.map.get(t);
|
|
383
445
|
}
|
|
384
446
|
}
|
|
385
|
-
let Us = new
|
|
447
|
+
let Us = new qi(), Zi = !0;
|
|
386
448
|
try {
|
|
387
|
-
typeof localStorage < "u" && (Us = localStorage,
|
|
449
|
+
typeof localStorage < "u" && (Us = localStorage, Zi = !1);
|
|
388
450
|
} catch {
|
|
389
451
|
}
|
|
390
|
-
const
|
|
452
|
+
const Qi = Us, to = Object.assign, eo = Object.keys, no = (e, t) => {
|
|
391
453
|
for (const n in e)
|
|
392
454
|
t(e[n], n);
|
|
393
|
-
}, me = (e) =>
|
|
455
|
+
}, me = (e) => eo(e).length, so = (e) => {
|
|
394
456
|
for (const t in e)
|
|
395
457
|
return !1;
|
|
396
458
|
return !0;
|
|
397
|
-
},
|
|
459
|
+
}, ro = (e, t) => {
|
|
398
460
|
for (const n in e)
|
|
399
461
|
if (!t(e[n], n))
|
|
400
462
|
return !1;
|
|
401
463
|
return !0;
|
|
402
|
-
}, Ts = (e, t) => Object.prototype.hasOwnProperty.call(e, t),
|
|
464
|
+
}, Ts = (e, t) => Object.prototype.hasOwnProperty.call(e, t), io = (e, t) => e === t || me(e) === me(t) && ro(e, (n, s) => (n !== void 0 || Ts(t, s)) && t[s] === n), mn = (e, t, n = 0) => {
|
|
403
465
|
try {
|
|
404
466
|
for (; n < e.length; n++)
|
|
405
467
|
e[n](...t);
|
|
406
468
|
} finally {
|
|
407
|
-
n < e.length &&
|
|
469
|
+
n < e.length && mn(e, t, n + 1);
|
|
408
470
|
}
|
|
409
|
-
},
|
|
471
|
+
}, oo = (e) => e, co = (e, t) => e === t, Vt = (e, t) => {
|
|
410
472
|
if (e == null || t == null)
|
|
411
|
-
return
|
|
473
|
+
return co(e, t);
|
|
412
474
|
if (e.constructor !== t.constructor)
|
|
413
475
|
return !1;
|
|
414
476
|
if (e === t)
|
|
@@ -436,7 +498,7 @@ const Zi = Us, Qi = Object.assign, to = Object.keys, eo = (e, t) => {
|
|
|
436
498
|
if (e.size !== t.size)
|
|
437
499
|
return !1;
|
|
438
500
|
for (const n of e.keys())
|
|
439
|
-
if (!t.has(n) || !
|
|
501
|
+
if (!t.has(n) || !Vt(e.get(n), t.get(n)))
|
|
440
502
|
return !1;
|
|
441
503
|
break;
|
|
442
504
|
}
|
|
@@ -444,26 +506,26 @@ const Zi = Us, Qi = Object.assign, to = Object.keys, eo = (e, t) => {
|
|
|
444
506
|
if (me(e) !== me(t))
|
|
445
507
|
return !1;
|
|
446
508
|
for (const n in e)
|
|
447
|
-
if (!Ts(e, n) || !
|
|
509
|
+
if (!Ts(e, n) || !Vt(e[n], t[n]))
|
|
448
510
|
return !1;
|
|
449
511
|
break;
|
|
450
512
|
case Array:
|
|
451
513
|
if (e.length !== t.length)
|
|
452
514
|
return !1;
|
|
453
515
|
for (let n = 0; n < e.length; n++)
|
|
454
|
-
if (!
|
|
516
|
+
if (!Vt(e[n], t[n]))
|
|
455
517
|
return !1;
|
|
456
518
|
break;
|
|
457
519
|
default:
|
|
458
520
|
return !1;
|
|
459
521
|
}
|
|
460
522
|
return !0;
|
|
461
|
-
},
|
|
523
|
+
}, lo = (e, t) => t.includes(e), zt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name);
|
|
462
524
|
let F;
|
|
463
|
-
const
|
|
525
|
+
const ao = () => {
|
|
464
526
|
if (F === void 0)
|
|
465
|
-
if (
|
|
466
|
-
F =
|
|
527
|
+
if (zt) {
|
|
528
|
+
F = M();
|
|
467
529
|
const e = process.argv;
|
|
468
530
|
let t = null;
|
|
469
531
|
for (let n = 0; n < e.length; n++) {
|
|
@@ -472,20 +534,20 @@ const lo = () => {
|
|
|
472
534
|
}
|
|
473
535
|
t !== null && F.set(t, "");
|
|
474
536
|
} else
|
|
475
|
-
typeof location == "object" ? (F =
|
|
537
|
+
typeof location == "object" ? (F = M(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
476
538
|
if (e.length !== 0) {
|
|
477
539
|
const [t, n] = e.split("=");
|
|
478
|
-
F.set(`--${
|
|
540
|
+
F.set(`--${Xn(t, "-")}`, n), F.set(`-${Xn(t, "-")}`, n);
|
|
479
541
|
}
|
|
480
|
-
})) : F =
|
|
542
|
+
})) : F = M();
|
|
481
543
|
return F;
|
|
482
|
-
}, en = (e) =>
|
|
483
|
-
|
|
484
|
-
const
|
|
485
|
-
throw
|
|
544
|
+
}, en = (e) => ao().has(e), nn = (e) => Jn(zt ? process.env[e.toUpperCase()] : Qi.getItem(e)), ho = (e) => en("--" + e) || nn(e) !== null;
|
|
545
|
+
ho("production");
|
|
546
|
+
const Wn = zt && lo(process.env.FORCE_COLOR, ["true", "1", "2"]), uo = !en("no-colors") && (!zt || process.stdout.isTTY || Wn) && (!zt || en("color") || Wn || nn("COLORTERM") !== null || (nn("TERM") || "").includes("color")), Pn = 1, Gn = 2, Ve = 4, Fe = 8, Kt = 32, J = 64, x = 128, Ie = 31, sn = 63, ct = 127, fo = 2147483647, Os = Number.MAX_SAFE_INTEGER, go = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && G(e) === e), q = (e) => new Error(e), H = () => {
|
|
547
|
+
throw q("Method unimplemented");
|
|
486
548
|
}, j = () => {
|
|
487
|
-
throw
|
|
488
|
-
}, Rs =
|
|
549
|
+
throw q("Unexpected case");
|
|
550
|
+
}, Rs = q("Unexpected end of array"), $s = q("Integer out of Range");
|
|
489
551
|
class ve {
|
|
490
552
|
/**
|
|
491
553
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
@@ -494,34 +556,34 @@ class ve {
|
|
|
494
556
|
this.arr = t, this.pos = 0;
|
|
495
557
|
}
|
|
496
558
|
}
|
|
497
|
-
const
|
|
498
|
-
const n =
|
|
559
|
+
const wt = (e) => new ve(e), po = (e) => e.pos !== e.arr.length, wo = (e, t) => {
|
|
560
|
+
const n = Sn(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
499
561
|
return e.pos += t, n;
|
|
500
|
-
}, I = (e) =>
|
|
562
|
+
}, I = (e) => wo(e, w(e)), vt = (e) => e.arr[e.pos++], w = (e) => {
|
|
501
563
|
let t = 0, n = 1;
|
|
502
564
|
const s = e.arr.length;
|
|
503
565
|
for (; e.pos < s; ) {
|
|
504
566
|
const r = e.arr[e.pos++];
|
|
505
|
-
if (t = t + (r & ct) * n, n *= 128, r <
|
|
567
|
+
if (t = t + (r & ct) * n, n *= 128, r < x)
|
|
506
568
|
return t;
|
|
507
569
|
if (t > Os)
|
|
508
570
|
throw $s;
|
|
509
571
|
}
|
|
510
572
|
throw Rs;
|
|
511
|
-
},
|
|
573
|
+
}, yn = (e) => {
|
|
512
574
|
let t = e.arr[e.pos++], n = t & sn, s = 64;
|
|
513
575
|
const r = (t & J) > 0 ? -1 : 1;
|
|
514
|
-
if (!(t &
|
|
576
|
+
if (!(t & x))
|
|
515
577
|
return r * n;
|
|
516
578
|
const i = e.arr.length;
|
|
517
579
|
for (; e.pos < i; ) {
|
|
518
|
-
if (t = e.arr[e.pos++], n = n + (t & ct) * s, s *= 128, t <
|
|
580
|
+
if (t = e.arr[e.pos++], n = n + (t & ct) * s, s *= 128, t < x)
|
|
519
581
|
return r * n;
|
|
520
582
|
if (n > Os)
|
|
521
583
|
throw $s;
|
|
522
584
|
}
|
|
523
585
|
throw Rs;
|
|
524
|
-
},
|
|
586
|
+
}, mo = (e) => {
|
|
525
587
|
let t = w(e);
|
|
526
588
|
if (t === 0)
|
|
527
589
|
return "";
|
|
@@ -541,53 +603,53 @@ const pt = (e) => new ve(e), go = (e) => e.pos !== e.arr.length, po = (e, t) =>
|
|
|
541
603
|
}
|
|
542
604
|
return decodeURIComponent(escape(n));
|
|
543
605
|
}
|
|
544
|
-
},
|
|
606
|
+
}, yo = (e) => (
|
|
545
607
|
/** @type any */
|
|
546
|
-
|
|
547
|
-
),
|
|
608
|
+
Bt.decode(I(e))
|
|
609
|
+
), st = Bt ? yo : mo, bn = (e, t) => {
|
|
548
610
|
const n = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
|
|
549
611
|
return e.pos += t, n;
|
|
550
|
-
},
|
|
612
|
+
}, bo = (e) => bn(e, 4).getFloat32(0, !1), So = (e) => bn(e, 8).getFloat64(0, !1), _o = (e) => (
|
|
551
613
|
/** @type {any} */
|
|
552
|
-
|
|
553
|
-
),
|
|
614
|
+
bn(e, 8).getBigInt64(0, !1)
|
|
615
|
+
), ko = [
|
|
554
616
|
(e) => {
|
|
555
617
|
},
|
|
556
618
|
// CASE 127: undefined
|
|
557
619
|
(e) => null,
|
|
558
620
|
// CASE 126: null
|
|
559
|
-
|
|
621
|
+
yn,
|
|
560
622
|
// CASE 125: integer
|
|
561
|
-
yo,
|
|
562
|
-
// CASE 124: float32
|
|
563
623
|
bo,
|
|
564
|
-
// CASE
|
|
624
|
+
// CASE 124: float32
|
|
565
625
|
So,
|
|
626
|
+
// CASE 123: float64
|
|
627
|
+
_o,
|
|
566
628
|
// CASE 122: bigint
|
|
567
629
|
(e) => !1,
|
|
568
630
|
// CASE 121: boolean (false)
|
|
569
631
|
(e) => !0,
|
|
570
632
|
// CASE 120: boolean (true)
|
|
571
|
-
|
|
633
|
+
st,
|
|
572
634
|
// CASE 119: string
|
|
573
635
|
(e) => {
|
|
574
636
|
const t = w(e), n = {};
|
|
575
637
|
for (let s = 0; s < t; s++) {
|
|
576
|
-
const r =
|
|
577
|
-
n[r] =
|
|
638
|
+
const r = st(e);
|
|
639
|
+
n[r] = Yt(e);
|
|
578
640
|
}
|
|
579
641
|
return n;
|
|
580
642
|
},
|
|
581
643
|
(e) => {
|
|
582
644
|
const t = w(e), n = [];
|
|
583
645
|
for (let s = 0; s < t; s++)
|
|
584
|
-
n.push(
|
|
646
|
+
n.push(Yt(e));
|
|
585
647
|
return n;
|
|
586
648
|
},
|
|
587
649
|
I
|
|
588
650
|
// CASE 116: Uint8Array
|
|
589
|
-
],
|
|
590
|
-
class
|
|
651
|
+
], Yt = (e) => ko[127 - vt(e)](e);
|
|
652
|
+
class qn extends ve {
|
|
591
653
|
/**
|
|
592
654
|
* @param {Uint8Array} uint8Array
|
|
593
655
|
* @param {function(Decoder):T} reader
|
|
@@ -596,7 +658,7 @@ class Zn extends ve {
|
|
|
596
658
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
597
659
|
}
|
|
598
660
|
read() {
|
|
599
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
661
|
+
return this.count === 0 && (this.s = this.reader(this), po(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
600
662
|
this.s;
|
|
601
663
|
}
|
|
602
664
|
}
|
|
@@ -609,7 +671,7 @@ class fe extends ve {
|
|
|
609
671
|
}
|
|
610
672
|
read() {
|
|
611
673
|
if (this.count === 0) {
|
|
612
|
-
this.s =
|
|
674
|
+
this.s = yn(this);
|
|
613
675
|
const t = xs(this.s);
|
|
614
676
|
this.count = 1, t && (this.s = -this.s, this.count = w(this) + 2);
|
|
615
677
|
}
|
|
@@ -629,18 +691,18 @@ class He extends ve {
|
|
|
629
691
|
*/
|
|
630
692
|
read() {
|
|
631
693
|
if (this.count === 0) {
|
|
632
|
-
const t =
|
|
633
|
-
this.diff =
|
|
694
|
+
const t = yn(this), n = t & 1;
|
|
695
|
+
this.diff = G(t / 2), this.count = 1, n && (this.count = w(this) + 2);
|
|
634
696
|
}
|
|
635
697
|
return this.s += this.diff, this.count--, this.s;
|
|
636
698
|
}
|
|
637
699
|
}
|
|
638
|
-
class
|
|
700
|
+
class Do {
|
|
639
701
|
/**
|
|
640
702
|
* @param {Uint8Array} uint8Array
|
|
641
703
|
*/
|
|
642
704
|
constructor(t) {
|
|
643
|
-
this.decoder = new fe(t), this.str =
|
|
705
|
+
this.decoder = new fe(t), this.str = st(this.decoder), this.spos = 0;
|
|
644
706
|
}
|
|
645
707
|
/**
|
|
646
708
|
* @return {string}
|
|
@@ -650,8 +712,8 @@ class ko {
|
|
|
650
712
|
return this.spos = t, n;
|
|
651
713
|
}
|
|
652
714
|
}
|
|
653
|
-
const
|
|
654
|
-
const t =
|
|
715
|
+
const Eo = (e) => new Uint8Array(e), Sn = (e, t, n) => new Uint8Array(e, t, n), Co = (e) => {
|
|
716
|
+
const t = Eo(e.byteLength);
|
|
655
717
|
return t.set(e), t;
|
|
656
718
|
};
|
|
657
719
|
class qt {
|
|
@@ -659,42 +721,42 @@ class qt {
|
|
|
659
721
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
660
722
|
}
|
|
661
723
|
}
|
|
662
|
-
const Zt = () => new qt(),
|
|
724
|
+
const Zt = () => new qt(), Ao = (e) => {
|
|
663
725
|
let t = e.cpos;
|
|
664
726
|
for (let n = 0; n < e.bufs.length; n++)
|
|
665
727
|
t += e.bufs[n].length;
|
|
666
728
|
return t;
|
|
667
|
-
},
|
|
668
|
-
const t = new Uint8Array(
|
|
729
|
+
}, N = (e) => {
|
|
730
|
+
const t = new Uint8Array(Ao(e));
|
|
669
731
|
let n = 0;
|
|
670
732
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
671
733
|
const r = e.bufs[s];
|
|
672
734
|
t.set(r, n), n += r.length;
|
|
673
735
|
}
|
|
674
|
-
return t.set(
|
|
675
|
-
},
|
|
736
|
+
return t.set(Sn(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
737
|
+
}, Lo = (e, t) => {
|
|
676
738
|
const n = e.cbuf.length;
|
|
677
|
-
n - e.cpos < t && (e.bufs.push(
|
|
739
|
+
n - e.cpos < t && (e.bufs.push(Sn(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(pt(n, t) * 2), e.cpos = 0);
|
|
678
740
|
}, E = (e, t) => {
|
|
679
741
|
const n = e.cbuf.length;
|
|
680
742
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
681
743
|
}, rn = E, m = (e, t) => {
|
|
682
744
|
for (; t > ct; )
|
|
683
|
-
E(e,
|
|
745
|
+
E(e, x | ct & t), t = G(t / 128);
|
|
684
746
|
E(e, ct & t);
|
|
685
|
-
},
|
|
747
|
+
}, _n = (e, t) => {
|
|
686
748
|
const n = xs(t);
|
|
687
|
-
for (n && (t = -t), E(e, (t > sn ?
|
|
688
|
-
E(e, (t > ct ?
|
|
689
|
-
}, on = new Uint8Array(3e4),
|
|
690
|
-
if (t.length <
|
|
691
|
-
const n =
|
|
749
|
+
for (n && (t = -t), E(e, (t > sn ? x : 0) | (n ? J : 0) | sn & t), t = G(t / 64); t > 0; )
|
|
750
|
+
E(e, (t > ct ? x : 0) | ct & t), t = G(t / 128);
|
|
751
|
+
}, on = new Uint8Array(3e4), Io = on.length / 3, vo = (e, t) => {
|
|
752
|
+
if (t.length < Io) {
|
|
753
|
+
const n = jt.encodeInto(t, on).written || 0;
|
|
692
754
|
m(e, n);
|
|
693
755
|
for (let s = 0; s < n; s++)
|
|
694
756
|
E(e, on[s]);
|
|
695
757
|
} else
|
|
696
|
-
L(e,
|
|
697
|
-
},
|
|
758
|
+
L(e, Gi(t));
|
|
759
|
+
}, Mo = (e, t) => {
|
|
698
760
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
699
761
|
m(e, s);
|
|
700
762
|
for (let r = 0; r < s; r++)
|
|
@@ -703,29 +765,29 @@ const Zt = () => new qt(), Co = (e) => {
|
|
|
703
765
|
/** @type {number} */
|
|
704
766
|
n.codePointAt(r)
|
|
705
767
|
);
|
|
706
|
-
}, lt =
|
|
707
|
-
|
|
768
|
+
}, lt = jt && /** @type {any} */
|
|
769
|
+
jt.encodeInto ? vo : Mo, Me = (e, t) => {
|
|
708
770
|
const n = e.cbuf.length, s = e.cpos, r = Ms(n - s, t.length), i = t.length - r;
|
|
709
|
-
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(
|
|
771
|
+
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(pt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
710
772
|
}, L = (e, t) => {
|
|
711
773
|
m(e, t.byteLength), Me(e, t);
|
|
712
|
-
},
|
|
713
|
-
|
|
774
|
+
}, kn = (e, t) => {
|
|
775
|
+
Lo(e, t);
|
|
714
776
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
715
777
|
return e.cpos += t, n;
|
|
716
|
-
},
|
|
778
|
+
}, xo = (e, t) => kn(e, 4).setFloat32(0, t, !1), Uo = (e, t) => kn(e, 8).setFloat64(0, t, !1), To = (e, t) => (
|
|
717
779
|
/** @type {any} */
|
|
718
|
-
|
|
719
|
-
),
|
|
780
|
+
kn(e, 8).setBigInt64(0, t, !1)
|
|
781
|
+
), Zn = new DataView(new ArrayBuffer(4)), Oo = (e) => (Zn.setFloat32(0, e), Zn.getFloat32(0) === e), Xt = (e, t) => {
|
|
720
782
|
switch (typeof t) {
|
|
721
783
|
case "string":
|
|
722
784
|
E(e, 119), lt(e, t);
|
|
723
785
|
break;
|
|
724
786
|
case "number":
|
|
725
|
-
|
|
787
|
+
go(t) && de(t) <= fo ? (E(e, 125), _n(e, t)) : Oo(t) ? (E(e, 124), xo(e, t)) : (E(e, 123), Uo(e, t));
|
|
726
788
|
break;
|
|
727
789
|
case "bigint":
|
|
728
|
-
E(e, 122),
|
|
790
|
+
E(e, 122), To(e, t);
|
|
729
791
|
break;
|
|
730
792
|
case "object":
|
|
731
793
|
if (t === null)
|
|
@@ -733,7 +795,7 @@ Ht.encodeInto ? Io : vo, Me = (e, t) => {
|
|
|
733
795
|
else if (ji(t)) {
|
|
734
796
|
E(e, 117), m(e, t.length);
|
|
735
797
|
for (let n = 0; n < t.length; n++)
|
|
736
|
-
|
|
798
|
+
Xt(e, t[n]);
|
|
737
799
|
} else if (t instanceof Uint8Array)
|
|
738
800
|
E(e, 116), L(e, t);
|
|
739
801
|
else {
|
|
@@ -742,7 +804,7 @@ Ht.encodeInto ? Io : vo, Me = (e, t) => {
|
|
|
742
804
|
m(e, n.length);
|
|
743
805
|
for (let s = 0; s < n.length; s++) {
|
|
744
806
|
const r = n[s];
|
|
745
|
-
lt(e, r),
|
|
807
|
+
lt(e, r), Xt(e, t[r]);
|
|
746
808
|
}
|
|
747
809
|
}
|
|
748
810
|
break;
|
|
@@ -753,7 +815,7 @@ Ht.encodeInto ? Io : vo, Me = (e, t) => {
|
|
|
753
815
|
E(e, 127);
|
|
754
816
|
}
|
|
755
817
|
};
|
|
756
|
-
class
|
|
818
|
+
class Qn extends qt {
|
|
757
819
|
/**
|
|
758
820
|
* @param {function(Encoder, T):void} writer
|
|
759
821
|
*/
|
|
@@ -767,8 +829,8 @@ class ts extends qt {
|
|
|
767
829
|
this.s === t ? this.count++ : (this.count > 0 && m(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
768
830
|
}
|
|
769
831
|
}
|
|
770
|
-
const
|
|
771
|
-
e.count > 0 && (
|
|
832
|
+
const ts = (e) => {
|
|
833
|
+
e.count > 0 && (_n(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && m(e.encoder, e.count - 2));
|
|
772
834
|
};
|
|
773
835
|
class ge {
|
|
774
836
|
constructor() {
|
|
@@ -778,16 +840,16 @@ class ge {
|
|
|
778
840
|
* @param {number} v
|
|
779
841
|
*/
|
|
780
842
|
write(t) {
|
|
781
|
-
this.s === t ? this.count++ : (
|
|
843
|
+
this.s === t ? this.count++ : (ts(this), this.count = 1, this.s = t);
|
|
782
844
|
}
|
|
783
845
|
toUint8Array() {
|
|
784
|
-
return
|
|
846
|
+
return ts(this), N(this.encoder);
|
|
785
847
|
}
|
|
786
848
|
}
|
|
787
|
-
const
|
|
849
|
+
const es = (e) => {
|
|
788
850
|
if (e.count > 0) {
|
|
789
851
|
const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
|
|
790
|
-
|
|
852
|
+
_n(e.encoder, t), e.count > 1 && m(e.encoder, e.count - 2);
|
|
791
853
|
}
|
|
792
854
|
};
|
|
793
855
|
class je {
|
|
@@ -798,13 +860,13 @@ class je {
|
|
|
798
860
|
* @param {number} v
|
|
799
861
|
*/
|
|
800
862
|
write(t) {
|
|
801
|
-
this.diff === t - this.s ? (this.s = t, this.count++) : (
|
|
863
|
+
this.diff === t - this.s ? (this.s = t, this.count++) : (es(this), this.count = 1, this.diff = t - this.s, this.s = t);
|
|
802
864
|
}
|
|
803
865
|
toUint8Array() {
|
|
804
|
-
return
|
|
866
|
+
return es(this), N(this.encoder);
|
|
805
867
|
}
|
|
806
868
|
}
|
|
807
|
-
class
|
|
869
|
+
class Ro {
|
|
808
870
|
constructor() {
|
|
809
871
|
this.sarr = [], this.s = "", this.lensE = new ge();
|
|
810
872
|
}
|
|
@@ -816,10 +878,10 @@ class Oo {
|
|
|
816
878
|
}
|
|
817
879
|
toUint8Array() {
|
|
818
880
|
const t = new qt();
|
|
819
|
-
return this.sarr.push(this.s), this.s = "", lt(t, this.sarr.join("")), Me(t, this.lensE.toUint8Array()),
|
|
881
|
+
return this.sarr.push(this.s), this.s = "", lt(t, this.sarr.join("")), Me(t, this.lensE.toUint8Array()), N(t);
|
|
820
882
|
}
|
|
821
883
|
}
|
|
822
|
-
const
|
|
884
|
+
const $o = crypto.getRandomValues.bind(crypto), Ns = () => $o(new Uint32Array(1))[0], No = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Bo = () => No.replace(
|
|
823
885
|
/[018]/g,
|
|
824
886
|
/** @param {number} c */
|
|
825
887
|
(e) => (e ^ Ns() & 15 >> e / 4).toString(16)
|
|
@@ -828,7 +890,7 @@ const Ro = crypto.getRandomValues.bind(crypto), Ns = () => Ro(new Uint32Array(1)
|
|
|
828
890
|
new Promise(e)
|
|
829
891
|
);
|
|
830
892
|
Promise.all.bind(Promise);
|
|
831
|
-
class
|
|
893
|
+
class Vo {
|
|
832
894
|
/**
|
|
833
895
|
* @param {L} left
|
|
834
896
|
* @param {R} right
|
|
@@ -837,9 +899,9 @@ class Bo {
|
|
|
837
899
|
this.left = t, this.right = n;
|
|
838
900
|
}
|
|
839
901
|
}
|
|
840
|
-
const X = (e, t) => new
|
|
902
|
+
const X = (e, t) => new Vo(e, t);
|
|
841
903
|
typeof DOMParser < "u" && new DOMParser();
|
|
842
|
-
const
|
|
904
|
+
const Fo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), Q = Symbol, Bs = Q(), Vs = Q(), Ho = Q(), jo = Q(), zo = Q(), Fs = Q(), Ko = Q(), Hs = Q(), Yo = Q(), Xo = (e) => {
|
|
843
905
|
const t = [];
|
|
844
906
|
let n = 0;
|
|
845
907
|
for (; n < e.length; n++) {
|
|
@@ -847,26 +909,26 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
847
909
|
s.constructor === String || s.constructor === Number || s.constructor === Object && t.push(JSON.stringify(s));
|
|
848
910
|
}
|
|
849
911
|
return t;
|
|
850
|
-
},
|
|
912
|
+
}, Jo = {
|
|
851
913
|
[Bs]: X("font-weight", "bold"),
|
|
852
914
|
[Vs]: X("font-weight", "normal"),
|
|
853
|
-
[
|
|
854
|
-
[
|
|
855
|
-
[
|
|
915
|
+
[Ho]: X("color", "blue"),
|
|
916
|
+
[zo]: X("color", "green"),
|
|
917
|
+
[jo]: X("color", "grey"),
|
|
856
918
|
[Fs]: X("color", "red"),
|
|
857
919
|
[Ko]: X("color", "purple"),
|
|
858
920
|
[Hs]: X("color", "orange"),
|
|
859
921
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
860
|
-
[
|
|
861
|
-
},
|
|
862
|
-
const t = [], n = [], s =
|
|
922
|
+
[Yo]: X("color", "black")
|
|
923
|
+
}, Wo = (e) => {
|
|
924
|
+
const t = [], n = [], s = M();
|
|
863
925
|
let r = [], i = 0;
|
|
864
926
|
for (; i < e.length; i++) {
|
|
865
|
-
const o = e[i], c =
|
|
927
|
+
const o = e[i], c = Jo[o];
|
|
866
928
|
if (c !== void 0)
|
|
867
929
|
s.set(c.left, c.right);
|
|
868
930
|
else if (o.constructor === String || o.constructor === Number) {
|
|
869
|
-
const l =
|
|
931
|
+
const l = Fo(s);
|
|
870
932
|
i > 0 || l.length > 0 ? (t.push("%c" + o), n.push(l)) : t.push(o);
|
|
871
933
|
} else
|
|
872
934
|
break;
|
|
@@ -876,9 +938,9 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
876
938
|
o instanceof Symbol || r.push(o);
|
|
877
939
|
}
|
|
878
940
|
return r;
|
|
879
|
-
},
|
|
880
|
-
console.log(...
|
|
881
|
-
},
|
|
941
|
+
}, Po = uo ? Wo : Xo, Go = (...e) => {
|
|
942
|
+
console.log(...Po(e)), qo.forEach((t) => t.print(e));
|
|
943
|
+
}, qo = at(), js = (e) => ({
|
|
882
944
|
/**
|
|
883
945
|
* @return {IterableIterator<T>}
|
|
884
946
|
*/
|
|
@@ -887,17 +949,17 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
887
949
|
},
|
|
888
950
|
// @ts-ignore
|
|
889
951
|
next: e
|
|
890
|
-
}),
|
|
952
|
+
}), Zo = (e, t) => js(() => {
|
|
891
953
|
let n;
|
|
892
954
|
do
|
|
893
955
|
n = e.next();
|
|
894
956
|
while (!n.done && !t(n.value));
|
|
895
957
|
return n;
|
|
896
|
-
}),
|
|
958
|
+
}), ze = (e, t) => js(() => {
|
|
897
959
|
const { done: n, value: s } = e.next();
|
|
898
960
|
return { done: n, value: n ? void 0 : t(s) };
|
|
899
961
|
});
|
|
900
|
-
class
|
|
962
|
+
class Dn {
|
|
901
963
|
/**
|
|
902
964
|
* @param {number} clock
|
|
903
965
|
* @param {number} len
|
|
@@ -911,7 +973,7 @@ class Qt {
|
|
|
911
973
|
this.clients = /* @__PURE__ */ new Map();
|
|
912
974
|
}
|
|
913
975
|
}
|
|
914
|
-
const
|
|
976
|
+
const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
915
977
|
const i = (
|
|
916
978
|
/** @type {Array<GC|Item>} */
|
|
917
979
|
e.doc.store.clients.get(r)
|
|
@@ -920,10 +982,10 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
920
982
|
const c = s[o];
|
|
921
983
|
sr(e, i, c.clock, c.len, n);
|
|
922
984
|
}
|
|
923
|
-
}),
|
|
985
|
+
}), Qo = (e, t) => {
|
|
924
986
|
let n = 0, s = e.length - 1;
|
|
925
987
|
for (; n <= s; ) {
|
|
926
|
-
const r =
|
|
988
|
+
const r = G((n + s) / 2), i = e[r], o = i.clock;
|
|
927
989
|
if (o <= t) {
|
|
928
990
|
if (t < o + i.len)
|
|
929
991
|
return r;
|
|
@@ -932,20 +994,20 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
932
994
|
s = r - 1;
|
|
933
995
|
}
|
|
934
996
|
return null;
|
|
935
|
-
},
|
|
997
|
+
}, Ks = (e, t) => {
|
|
936
998
|
const n = e.clients.get(t.client);
|
|
937
|
-
return n !== void 0 &&
|
|
938
|
-
},
|
|
999
|
+
return n !== void 0 && Qo(n, t.clock) !== null;
|
|
1000
|
+
}, En = (e) => {
|
|
939
1001
|
e.clients.forEach((t) => {
|
|
940
1002
|
t.sort((r, i) => r.clock - i.clock);
|
|
941
1003
|
let n, s;
|
|
942
1004
|
for (n = 1, s = 1; n < t.length; n++) {
|
|
943
1005
|
const r = t[s - 1], i = t[n];
|
|
944
|
-
r.clock + r.len >= i.clock ? r.len =
|
|
1006
|
+
r.clock + r.len >= i.clock ? r.len = pt(r.len, i.clock + i.len - r.clock) : (s < n && (t[s] = i), s++);
|
|
945
1007
|
}
|
|
946
1008
|
t.length = s;
|
|
947
1009
|
});
|
|
948
|
-
},
|
|
1010
|
+
}, tc = (e) => {
|
|
949
1011
|
const t = new Qt();
|
|
950
1012
|
for (let n = 0; n < e.length; n++)
|
|
951
1013
|
e[n].clients.forEach((s, r) => {
|
|
@@ -956,14 +1018,14 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
956
1018
|
t.clients.set(r, i);
|
|
957
1019
|
}
|
|
958
1020
|
});
|
|
959
|
-
return
|
|
1021
|
+
return En(t), t;
|
|
960
1022
|
}, be = (e, t, n, s) => {
|
|
961
|
-
|
|
1023
|
+
Z(e.clients, t, () => (
|
|
962
1024
|
/** @type {Array<DeleteItem>} */
|
|
963
1025
|
[]
|
|
964
|
-
)).push(new
|
|
965
|
-
},
|
|
966
|
-
const t =
|
|
1026
|
+
)).push(new Dn(n, s));
|
|
1027
|
+
}, ec = () => new Qt(), nc = (e) => {
|
|
1028
|
+
const t = ec();
|
|
967
1029
|
return e.clients.forEach((n, s) => {
|
|
968
1030
|
const r = [];
|
|
969
1031
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -974,13 +1036,13 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
974
1036
|
if (i + 1 < n.length)
|
|
975
1037
|
for (let a = n[i + 1]; i + 1 < n.length && a.deleted; a = n[++i + 1])
|
|
976
1038
|
l += a.length;
|
|
977
|
-
r.push(new
|
|
1039
|
+
r.push(new Dn(c, l));
|
|
978
1040
|
}
|
|
979
1041
|
}
|
|
980
1042
|
r.length > 0 && t.clients.set(s, r);
|
|
981
1043
|
}), t;
|
|
982
|
-
},
|
|
983
|
-
m(e.restEncoder, t.clients.size),
|
|
1044
|
+
}, Ot = (e, t) => {
|
|
1045
|
+
m(e.restEncoder, t.clients.size), P(t.clients.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
984
1046
|
e.resetDsCurVal(), m(e.restEncoder, n);
|
|
985
1047
|
const r = s.length;
|
|
986
1048
|
m(e.restEncoder, r);
|
|
@@ -989,22 +1051,22 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
989
1051
|
e.writeDsClock(o.clock), e.writeDsLen(o.len);
|
|
990
1052
|
}
|
|
991
1053
|
});
|
|
992
|
-
},
|
|
1054
|
+
}, Cn = (e) => {
|
|
993
1055
|
const t = new Qt(), n = w(e.restDecoder);
|
|
994
1056
|
for (let s = 0; s < n; s++) {
|
|
995
1057
|
e.resetDsCurVal();
|
|
996
1058
|
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
997
1059
|
if (i > 0) {
|
|
998
|
-
const o =
|
|
1060
|
+
const o = Z(t.clients, r, () => (
|
|
999
1061
|
/** @type {Array<DeleteItem>} */
|
|
1000
1062
|
[]
|
|
1001
1063
|
));
|
|
1002
1064
|
for (let c = 0; c < i; c++)
|
|
1003
|
-
o.push(new
|
|
1065
|
+
o.push(new Dn(e.readDsClock(), e.readDsLen()));
|
|
1004
1066
|
}
|
|
1005
1067
|
}
|
|
1006
1068
|
return t;
|
|
1007
|
-
},
|
|
1069
|
+
}, ns = (e, t, n) => {
|
|
1008
1070
|
const s = new Qt(), r = w(e.restDecoder);
|
|
1009
1071
|
for (let i = 0; i < r; i++) {
|
|
1010
1072
|
e.resetDsCurVal();
|
|
@@ -1013,7 +1075,7 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1013
1075
|
const d = e.readDsClock(), u = d + e.readDsLen();
|
|
1014
1076
|
if (d < a) {
|
|
1015
1077
|
a < u && be(s, o, a, u - a);
|
|
1016
|
-
let f =
|
|
1078
|
+
let f = z(l, d), g = l[f];
|
|
1017
1079
|
for (!g.deleted && g.id.clock < d && (l.splice(f + 1, 0, Ae(t, g, d - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < u); )
|
|
1018
1080
|
g.deleted || (u < g.id.clock + g.length && l.splice(f, 0, Ae(t, g, u - g.id.clock)), g.delete(t));
|
|
1019
1081
|
} else
|
|
@@ -1021,16 +1083,16 @@ const Ks = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1021
1083
|
}
|
|
1022
1084
|
}
|
|
1023
1085
|
if (s.clients.size > 0) {
|
|
1024
|
-
const i = new
|
|
1025
|
-
return m(i.restEncoder, 0),
|
|
1086
|
+
const i = new ht();
|
|
1087
|
+
return m(i.restEncoder, 0), Ot(i, s), i.toUint8Array();
|
|
1026
1088
|
}
|
|
1027
1089
|
return null;
|
|
1028
1090
|
}, Ys = Ns;
|
|
1029
|
-
class
|
|
1091
|
+
class mt extends zi {
|
|
1030
1092
|
/**
|
|
1031
1093
|
* @param {DocOpts} opts configuration
|
|
1032
1094
|
*/
|
|
1033
|
-
constructor({ guid: t =
|
|
1095
|
+
constructor({ guid: t = Bo(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
1034
1096
|
super(), this.gc = s, this.gcFilter = r, this.clientID = Ys(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new er(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = Mt((a) => {
|
|
1035
1097
|
this.on("load", () => {
|
|
1036
1098
|
this.isLoaded = !0, a(this);
|
|
@@ -1043,7 +1105,7 @@ class wt extends mn {
|
|
|
1043
1105
|
this.on("sync", h);
|
|
1044
1106
|
});
|
|
1045
1107
|
this.on("sync", (a) => {
|
|
1046
|
-
a === !1 && this.isSynced && (this.whenSynced = l()), this.isSynced = a === void 0 || a === !0, this.isSynced && !this.isLoaded && this.emit("load", []);
|
|
1108
|
+
a === !1 && this.isSynced && (this.whenSynced = l()), this.isSynced = a === void 0 || a === !0, this.isSynced && !this.isLoaded && this.emit("load", [this]);
|
|
1047
1109
|
}), this.whenSynced = l();
|
|
1048
1110
|
}
|
|
1049
1111
|
/**
|
|
@@ -1069,7 +1131,7 @@ class wt extends mn {
|
|
|
1069
1131
|
return this.subdocs;
|
|
1070
1132
|
}
|
|
1071
1133
|
getSubdocGuids() {
|
|
1072
|
-
return new Set(
|
|
1134
|
+
return new Set(P(this.subdocs).map((t) => t.guid));
|
|
1073
1135
|
}
|
|
1074
1136
|
/**
|
|
1075
1137
|
* Changes that happen inside of a transaction are bundled. This means that
|
|
@@ -1100,6 +1162,7 @@ class wt extends mn {
|
|
|
1100
1162
|
* Define all types right after the Yjs instance is created and store them in a separate object.
|
|
1101
1163
|
* Also use the typed methods `getText(name)`, `getArray(name)`, ..
|
|
1102
1164
|
*
|
|
1165
|
+
* @template {typeof AbstractType<any>} Type
|
|
1103
1166
|
* @example
|
|
1104
1167
|
* const y = new Y(..)
|
|
1105
1168
|
* const appState = {
|
|
@@ -1108,13 +1171,16 @@ class wt extends mn {
|
|
|
1108
1171
|
* }
|
|
1109
1172
|
*
|
|
1110
1173
|
* @param {string} name
|
|
1111
|
-
* @param {
|
|
1112
|
-
* @return {
|
|
1174
|
+
* @param {Type} TypeConstructor The constructor of the type definition. E.g. Y.Text, Y.Array, Y.Map, ...
|
|
1175
|
+
* @return {InstanceType<Type>} The created type. Constructed with TypeConstructor
|
|
1113
1176
|
*
|
|
1114
1177
|
* @public
|
|
1115
1178
|
*/
|
|
1116
|
-
get(t, n =
|
|
1117
|
-
|
|
1179
|
+
get(t, n = (
|
|
1180
|
+
/** @type {any} */
|
|
1181
|
+
A
|
|
1182
|
+
)) {
|
|
1183
|
+
const s = Z(this.share, t, () => {
|
|
1118
1184
|
const i = new n();
|
|
1119
1185
|
return i._integrate(this, null), i;
|
|
1120
1186
|
}), r = s.constructor;
|
|
@@ -1130,10 +1196,14 @@ class wt extends mn {
|
|
|
1130
1196
|
), i._start = s._start;
|
|
1131
1197
|
for (let o = i._start; o !== null; o = o.right)
|
|
1132
1198
|
o.parent = i;
|
|
1133
|
-
return i._length = s._length, this.share.set(t, i), i._integrate(this, null),
|
|
1199
|
+
return i._length = s._length, this.share.set(t, i), i._integrate(this, null), /** @type {InstanceType<Type>} */
|
|
1200
|
+
i;
|
|
1134
1201
|
} else
|
|
1135
1202
|
throw new Error(`Type with the name ${t} has already been defined with a different constructor`);
|
|
1136
|
-
return
|
|
1203
|
+
return (
|
|
1204
|
+
/** @type {InstanceType<Type>} */
|
|
1205
|
+
s
|
|
1206
|
+
);
|
|
1137
1207
|
}
|
|
1138
1208
|
/**
|
|
1139
1209
|
* @template T
|
|
@@ -1143,7 +1213,10 @@ class wt extends mn {
|
|
|
1143
1213
|
* @public
|
|
1144
1214
|
*/
|
|
1145
1215
|
getArray(t = "") {
|
|
1146
|
-
return
|
|
1216
|
+
return (
|
|
1217
|
+
/** @type {YArray<T>} */
|
|
1218
|
+
this.get(t, Ct)
|
|
1219
|
+
);
|
|
1147
1220
|
}
|
|
1148
1221
|
/**
|
|
1149
1222
|
* @param {string} [name]
|
|
@@ -1162,7 +1235,22 @@ class wt extends mn {
|
|
|
1162
1235
|
* @public
|
|
1163
1236
|
*/
|
|
1164
1237
|
getMap(t = "") {
|
|
1165
|
-
return
|
|
1238
|
+
return (
|
|
1239
|
+
/** @type {YMap<T>} */
|
|
1240
|
+
this.get(t, ut)
|
|
1241
|
+
);
|
|
1242
|
+
}
|
|
1243
|
+
/**
|
|
1244
|
+
* @param {string} [name]
|
|
1245
|
+
* @return {YXmlElement}
|
|
1246
|
+
*
|
|
1247
|
+
* @public
|
|
1248
|
+
*/
|
|
1249
|
+
getXmlElement(t = "") {
|
|
1250
|
+
return (
|
|
1251
|
+
/** @type {YXmlElement<{[key:string]:string}>} */
|
|
1252
|
+
this.get(t, Tt)
|
|
1253
|
+
);
|
|
1166
1254
|
}
|
|
1167
1255
|
/**
|
|
1168
1256
|
* @param {string} [name]
|
|
@@ -1171,7 +1259,7 @@ class wt extends mn {
|
|
|
1171
1259
|
* @public
|
|
1172
1260
|
*/
|
|
1173
1261
|
getXmlFragment(t = "") {
|
|
1174
|
-
return this.get(t,
|
|
1262
|
+
return this.get(t, dt);
|
|
1175
1263
|
}
|
|
1176
1264
|
/**
|
|
1177
1265
|
* Converts the entire document into a js object, recursively traversing each yjs type
|
|
@@ -1191,7 +1279,7 @@ class wt extends mn {
|
|
|
1191
1279
|
* Emit `destroy` event and unregister all event handlers.
|
|
1192
1280
|
*/
|
|
1193
1281
|
destroy() {
|
|
1194
|
-
|
|
1282
|
+
P(this.subdocs).forEach((n) => n.destroy());
|
|
1195
1283
|
const t = this._item;
|
|
1196
1284
|
if (t !== null) {
|
|
1197
1285
|
this._item = null;
|
|
@@ -1199,7 +1287,7 @@ class wt extends mn {
|
|
|
1199
1287
|
/** @type {ContentDoc} */
|
|
1200
1288
|
t.content
|
|
1201
1289
|
);
|
|
1202
|
-
n.doc = new
|
|
1290
|
+
n.doc = new mt({ guid: this.guid, ...n.opts, shouldLoad: !1 }), n.doc._item = t, S(
|
|
1203
1291
|
/** @type {any} */
|
|
1204
1292
|
t.parent.doc,
|
|
1205
1293
|
(s) => {
|
|
@@ -1212,20 +1300,6 @@ class wt extends mn {
|
|
|
1212
1300
|
}
|
|
1213
1301
|
this.emit("destroyed", [!0]), this.emit("destroy", [this]), super.destroy();
|
|
1214
1302
|
}
|
|
1215
|
-
/**
|
|
1216
|
-
* @param {string} eventName
|
|
1217
|
-
* @param {function(...any):any} f
|
|
1218
|
-
*/
|
|
1219
|
-
on(t, n) {
|
|
1220
|
-
super.on(t, n);
|
|
1221
|
-
}
|
|
1222
|
-
/**
|
|
1223
|
-
* @param {string} eventName
|
|
1224
|
-
* @param {function} f
|
|
1225
|
-
*/
|
|
1226
|
-
off(t, n) {
|
|
1227
|
-
super.off(t, n);
|
|
1228
|
-
}
|
|
1229
1303
|
}
|
|
1230
1304
|
class Xs {
|
|
1231
1305
|
/**
|
|
@@ -1279,7 +1353,7 @@ class Js extends Xs {
|
|
|
1279
1353
|
* @return {string}
|
|
1280
1354
|
*/
|
|
1281
1355
|
readString() {
|
|
1282
|
-
return
|
|
1356
|
+
return st(this.restDecoder);
|
|
1283
1357
|
}
|
|
1284
1358
|
/**
|
|
1285
1359
|
* @return {boolean} isKey
|
|
@@ -1305,13 +1379,13 @@ class Js extends Xs {
|
|
|
1305
1379
|
* @return {any}
|
|
1306
1380
|
*/
|
|
1307
1381
|
readAny() {
|
|
1308
|
-
return
|
|
1382
|
+
return Yt(this.restDecoder);
|
|
1309
1383
|
}
|
|
1310
1384
|
/**
|
|
1311
1385
|
* @return {Uint8Array}
|
|
1312
1386
|
*/
|
|
1313
1387
|
readBuf() {
|
|
1314
|
-
return
|
|
1388
|
+
return Co(I(this.restDecoder));
|
|
1315
1389
|
}
|
|
1316
1390
|
/**
|
|
1317
1391
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1319,16 +1393,16 @@ class Js extends Xs {
|
|
|
1319
1393
|
* @return {any}
|
|
1320
1394
|
*/
|
|
1321
1395
|
readJSON() {
|
|
1322
|
-
return JSON.parse(
|
|
1396
|
+
return JSON.parse(st(this.restDecoder));
|
|
1323
1397
|
}
|
|
1324
1398
|
/**
|
|
1325
1399
|
* @return {string}
|
|
1326
1400
|
*/
|
|
1327
1401
|
readKey() {
|
|
1328
|
-
return
|
|
1402
|
+
return st(this.restDecoder);
|
|
1329
1403
|
}
|
|
1330
1404
|
}
|
|
1331
|
-
class
|
|
1405
|
+
class sc {
|
|
1332
1406
|
/**
|
|
1333
1407
|
* @param {decoding.Decoder} decoder
|
|
1334
1408
|
*/
|
|
@@ -1352,24 +1426,24 @@ class nc {
|
|
|
1352
1426
|
return this.dsCurrVal += t, t;
|
|
1353
1427
|
}
|
|
1354
1428
|
}
|
|
1355
|
-
class xt extends
|
|
1429
|
+
class xt extends sc {
|
|
1356
1430
|
/**
|
|
1357
1431
|
* @param {decoding.Decoder} decoder
|
|
1358
1432
|
*/
|
|
1359
1433
|
constructor(t) {
|
|
1360
|
-
super(t), this.keys = [], w(t), this.keyClockDecoder = new He(I(t)), this.clientDecoder = new fe(I(t)), this.leftClockDecoder = new He(I(t)), this.rightClockDecoder = new He(I(t)), this.infoDecoder = new
|
|
1434
|
+
super(t), this.keys = [], w(t), this.keyClockDecoder = new He(I(t)), this.clientDecoder = new fe(I(t)), this.leftClockDecoder = new He(I(t)), this.rightClockDecoder = new He(I(t)), this.infoDecoder = new qn(I(t), vt), this.stringDecoder = new Do(I(t)), this.parentInfoDecoder = new qn(I(t), vt), this.typeRefDecoder = new fe(I(t)), this.lenDecoder = new fe(I(t));
|
|
1361
1435
|
}
|
|
1362
1436
|
/**
|
|
1363
1437
|
* @return {ID}
|
|
1364
1438
|
*/
|
|
1365
1439
|
readLeftID() {
|
|
1366
|
-
return new
|
|
1440
|
+
return new Et(this.clientDecoder.read(), this.leftClockDecoder.read());
|
|
1367
1441
|
}
|
|
1368
1442
|
/**
|
|
1369
1443
|
* @return {ID}
|
|
1370
1444
|
*/
|
|
1371
1445
|
readRightID() {
|
|
1372
|
-
return new
|
|
1446
|
+
return new Et(this.clientDecoder.read(), this.rightClockDecoder.read());
|
|
1373
1447
|
}
|
|
1374
1448
|
/**
|
|
1375
1449
|
* Read the next client id.
|
|
@@ -1417,7 +1491,7 @@ class xt extends nc {
|
|
|
1417
1491
|
* @return {any}
|
|
1418
1492
|
*/
|
|
1419
1493
|
readAny() {
|
|
1420
|
-
return
|
|
1494
|
+
return Yt(this.restDecoder);
|
|
1421
1495
|
}
|
|
1422
1496
|
/**
|
|
1423
1497
|
* @return {Uint8Array}
|
|
@@ -1433,7 +1507,7 @@ class xt extends nc {
|
|
|
1433
1507
|
* @return {any}
|
|
1434
1508
|
*/
|
|
1435
1509
|
readJSON() {
|
|
1436
|
-
return
|
|
1510
|
+
return Yt(this.restDecoder);
|
|
1437
1511
|
}
|
|
1438
1512
|
/**
|
|
1439
1513
|
* @return {string}
|
|
@@ -1453,7 +1527,7 @@ class Ws {
|
|
|
1453
1527
|
this.restEncoder = Zt();
|
|
1454
1528
|
}
|
|
1455
1529
|
toUint8Array() {
|
|
1456
|
-
return
|
|
1530
|
+
return N(this.restEncoder);
|
|
1457
1531
|
}
|
|
1458
1532
|
resetDsCurVal() {
|
|
1459
1533
|
}
|
|
@@ -1526,7 +1600,7 @@ class te extends Ws {
|
|
|
1526
1600
|
* @param {any} any
|
|
1527
1601
|
*/
|
|
1528
1602
|
writeAny(t) {
|
|
1529
|
-
|
|
1603
|
+
Xt(this.restEncoder, t);
|
|
1530
1604
|
}
|
|
1531
1605
|
/**
|
|
1532
1606
|
* @param {Uint8Array} buf
|
|
@@ -1552,7 +1626,7 @@ class Ps {
|
|
|
1552
1626
|
this.restEncoder = Zt(), this.dsCurrVal = 0;
|
|
1553
1627
|
}
|
|
1554
1628
|
toUint8Array() {
|
|
1555
|
-
return
|
|
1629
|
+
return N(this.restEncoder);
|
|
1556
1630
|
}
|
|
1557
1631
|
resetDsCurVal() {
|
|
1558
1632
|
this.dsCurrVal = 0;
|
|
@@ -1571,13 +1645,13 @@ class Ps {
|
|
|
1571
1645
|
t === 0 && j(), m(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
1572
1646
|
}
|
|
1573
1647
|
}
|
|
1574
|
-
class
|
|
1648
|
+
class ht extends Ps {
|
|
1575
1649
|
constructor() {
|
|
1576
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new je(), this.clientEncoder = new ge(), this.leftClockEncoder = new je(), this.rightClockEncoder = new je(), this.infoEncoder = new
|
|
1650
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new je(), this.clientEncoder = new ge(), this.leftClockEncoder = new je(), this.rightClockEncoder = new je(), this.infoEncoder = new Qn(rn), this.stringEncoder = new Ro(), this.parentInfoEncoder = new Qn(rn), this.typeRefEncoder = new ge(), this.lenEncoder = new ge();
|
|
1577
1651
|
}
|
|
1578
1652
|
toUint8Array() {
|
|
1579
1653
|
const t = Zt();
|
|
1580
|
-
return m(t, 0), L(t, this.keyClockEncoder.toUint8Array()), L(t, this.clientEncoder.toUint8Array()), L(t, this.leftClockEncoder.toUint8Array()), L(t, this.rightClockEncoder.toUint8Array()), L(t,
|
|
1654
|
+
return m(t, 0), L(t, this.keyClockEncoder.toUint8Array()), L(t, this.clientEncoder.toUint8Array()), L(t, this.leftClockEncoder.toUint8Array()), L(t, this.rightClockEncoder.toUint8Array()), L(t, N(this.infoEncoder)), L(t, this.stringEncoder.toUint8Array()), L(t, N(this.parentInfoEncoder)), L(t, this.typeRefEncoder.toUint8Array()), L(t, this.lenEncoder.toUint8Array()), Me(t, N(this.restEncoder)), N(t);
|
|
1581
1655
|
}
|
|
1582
1656
|
/**
|
|
1583
1657
|
* @param {ID} id
|
|
@@ -1633,7 +1707,7 @@ class at extends Ps {
|
|
|
1633
1707
|
* @param {any} any
|
|
1634
1708
|
*/
|
|
1635
1709
|
writeAny(t) {
|
|
1636
|
-
|
|
1710
|
+
Xt(this.restEncoder, t);
|
|
1637
1711
|
}
|
|
1638
1712
|
/**
|
|
1639
1713
|
* @param {Uint8Array} buf
|
|
@@ -1649,7 +1723,7 @@ class at extends Ps {
|
|
|
1649
1723
|
* @param {any} embed
|
|
1650
1724
|
*/
|
|
1651
1725
|
writeJSON(t) {
|
|
1652
|
-
|
|
1726
|
+
Xt(this.restEncoder, t);
|
|
1653
1727
|
}
|
|
1654
1728
|
/**
|
|
1655
1729
|
* Property keys are often reused. For example, in y-prosemirror the key `bold` might
|
|
@@ -1664,22 +1738,22 @@ class at extends Ps {
|
|
|
1664
1738
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
1665
1739
|
}
|
|
1666
1740
|
}
|
|
1667
|
-
const
|
|
1668
|
-
s =
|
|
1669
|
-
const r =
|
|
1741
|
+
const rc = (e, t, n, s) => {
|
|
1742
|
+
s = pt(s, t[0].id.clock);
|
|
1743
|
+
const r = z(t, s);
|
|
1670
1744
|
m(e.restEncoder, t.length - r), e.writeClient(n), m(e.restEncoder, s);
|
|
1671
1745
|
const i = t[r];
|
|
1672
1746
|
i.write(e, s - i.id.clock);
|
|
1673
1747
|
for (let o = r + 1; o < t.length; o++)
|
|
1674
1748
|
t[o].write(e, 0);
|
|
1675
|
-
},
|
|
1749
|
+
}, An = (e, t, n) => {
|
|
1676
1750
|
const s = /* @__PURE__ */ new Map();
|
|
1677
1751
|
n.forEach((r, i) => {
|
|
1678
1752
|
C(t, i) > r && s.set(i, r);
|
|
1679
1753
|
}), xe(t).forEach((r, i) => {
|
|
1680
1754
|
n.has(i) || s.set(i, 0);
|
|
1681
|
-
}), m(e.restEncoder, s.size),
|
|
1682
|
-
|
|
1755
|
+
}), m(e.restEncoder, s.size), P(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
1756
|
+
rc(
|
|
1683
1757
|
e,
|
|
1684
1758
|
/** @type {Array<GC|Item>} */
|
|
1685
1759
|
t.clients.get(r),
|
|
@@ -1687,8 +1761,8 @@ const sc = (e, t, n, s) => {
|
|
|
1687
1761
|
i
|
|
1688
1762
|
);
|
|
1689
1763
|
});
|
|
1690
|
-
},
|
|
1691
|
-
const n =
|
|
1764
|
+
}, ic = (e, t) => {
|
|
1765
|
+
const n = M(), s = w(e.restDecoder);
|
|
1692
1766
|
for (let r = 0; r < s; r++) {
|
|
1693
1767
|
const i = w(e.restDecoder), o = new Array(i), c = e.readClient();
|
|
1694
1768
|
let l = w(e.restDecoder);
|
|
@@ -1698,20 +1772,20 @@ const sc = (e, t, n, s) => {
|
|
|
1698
1772
|
switch (Ie & h) {
|
|
1699
1773
|
case 0: {
|
|
1700
1774
|
const d = e.readLen();
|
|
1701
|
-
o[a] = new
|
|
1775
|
+
o[a] = new T(b(c, l), d), l += d;
|
|
1702
1776
|
break;
|
|
1703
1777
|
}
|
|
1704
1778
|
case 10: {
|
|
1705
1779
|
const d = w(e.restDecoder);
|
|
1706
|
-
o[a] = new
|
|
1780
|
+
o[a] = new O(b(c, l), d), l += d;
|
|
1707
1781
|
break;
|
|
1708
1782
|
}
|
|
1709
1783
|
default: {
|
|
1710
|
-
const d = (h & (J |
|
|
1784
|
+
const d = (h & (J | x)) === 0, u = new k(
|
|
1711
1785
|
b(c, l),
|
|
1712
1786
|
null,
|
|
1713
1787
|
// leftd
|
|
1714
|
-
(h &
|
|
1788
|
+
(h & x) === x ? e.readLeftID() : null,
|
|
1715
1789
|
// origin
|
|
1716
1790
|
null,
|
|
1717
1791
|
// right
|
|
@@ -1730,9 +1804,9 @@ const sc = (e, t, n, s) => {
|
|
|
1730
1804
|
}
|
|
1731
1805
|
}
|
|
1732
1806
|
return n;
|
|
1733
|
-
},
|
|
1807
|
+
}, oc = (e, t, n) => {
|
|
1734
1808
|
const s = [];
|
|
1735
|
-
let r =
|
|
1809
|
+
let r = P(n.keys()).sort((f, g) => f - g);
|
|
1736
1810
|
if (r.length === 0)
|
|
1737
1811
|
return null;
|
|
1738
1812
|
const i = () => {
|
|
@@ -1772,8 +1846,8 @@ const sc = (e, t, n, s) => {
|
|
|
1772
1846
|
s.length = 0;
|
|
1773
1847
|
};
|
|
1774
1848
|
for (; ; ) {
|
|
1775
|
-
if (h.constructor !==
|
|
1776
|
-
const g =
|
|
1849
|
+
if (h.constructor !== O) {
|
|
1850
|
+
const g = Z(d, h.id.client, () => C(t, h.id.client)) - h.id.clock;
|
|
1777
1851
|
if (g < 0)
|
|
1778
1852
|
s.push(h), a(h.id.client, h.id.clock - 1), u();
|
|
1779
1853
|
else {
|
|
@@ -1812,14 +1886,14 @@ const sc = (e, t, n, s) => {
|
|
|
1812
1886
|
}
|
|
1813
1887
|
}
|
|
1814
1888
|
if (c.clients.size > 0) {
|
|
1815
|
-
const f = new
|
|
1816
|
-
return
|
|
1889
|
+
const f = new ht();
|
|
1890
|
+
return An(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
1817
1891
|
}
|
|
1818
1892
|
return null;
|
|
1819
|
-
},
|
|
1893
|
+
}, cc = (e, t) => An(e, t.doc.store, t.beforeState), lc = (e, t, n, s = new xt(e)) => S(t, (r) => {
|
|
1820
1894
|
r.local = !1;
|
|
1821
1895
|
let i = !1;
|
|
1822
|
-
const o = r.doc, c = o.store, l =
|
|
1896
|
+
const o = r.doc, c = o.store, l = ic(s, o), a = oc(r, c, l), h = c.pendingStructs;
|
|
1823
1897
|
if (h) {
|
|
1824
1898
|
for (const [u, f] of h.missing)
|
|
1825
1899
|
if (f < C(c, u)) {
|
|
@@ -1835,11 +1909,11 @@ const sc = (e, t, n, s) => {
|
|
|
1835
1909
|
}
|
|
1836
1910
|
} else
|
|
1837
1911
|
c.pendingStructs = a;
|
|
1838
|
-
const d =
|
|
1912
|
+
const d = ns(s, r, c);
|
|
1839
1913
|
if (c.pendingDs) {
|
|
1840
|
-
const u = new xt(
|
|
1914
|
+
const u = new xt(wt(c.pendingDs));
|
|
1841
1915
|
w(u.restDecoder);
|
|
1842
|
-
const f =
|
|
1916
|
+
const f = ns(u, r, c);
|
|
1843
1917
|
d && f ? c.pendingDs = Se([d, f]) : c.pendingDs = d || f;
|
|
1844
1918
|
} else
|
|
1845
1919
|
c.pendingDs = d;
|
|
@@ -1851,41 +1925,41 @@ const sc = (e, t, n, s) => {
|
|
|
1851
1925
|
c.pendingStructs = null, Gs(r.doc, u);
|
|
1852
1926
|
}
|
|
1853
1927
|
}, n, !1), Gs = (e, t, n, s = xt) => {
|
|
1854
|
-
const r =
|
|
1855
|
-
|
|
1856
|
-
}, qs = (e, t, n) => Gs(e, t, n, Js),
|
|
1857
|
-
|
|
1858
|
-
},
|
|
1928
|
+
const r = wt(t);
|
|
1929
|
+
lc(r, e, n, new s(r));
|
|
1930
|
+
}, qs = (e, t, n) => Gs(e, t, n, Js), ac = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
1931
|
+
An(e, t.store, n), Ot(e, nc(t.store));
|
|
1932
|
+
}, hc = (e, t = new Uint8Array([0]), n = new ht()) => {
|
|
1859
1933
|
const s = Zs(t);
|
|
1860
|
-
|
|
1934
|
+
ac(n, e, s);
|
|
1861
1935
|
const r = [n.toUint8Array()];
|
|
1862
|
-
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(
|
|
1936
|
+
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Cc(e.store.pendingStructs.update, t)), r.length > 1) {
|
|
1863
1937
|
if (n.constructor === te)
|
|
1864
|
-
return
|
|
1865
|
-
if (n.constructor ===
|
|
1938
|
+
return Dc(r.map((i, o) => o === 0 ? i : Lc(i)));
|
|
1939
|
+
if (n.constructor === ht)
|
|
1866
1940
|
return Se(r);
|
|
1867
1941
|
}
|
|
1868
1942
|
return r[0];
|
|
1869
|
-
},
|
|
1943
|
+
}, Ln = (e, t) => hc(e, t, new te()), uc = (e) => {
|
|
1870
1944
|
const t = /* @__PURE__ */ new Map(), n = w(e.restDecoder);
|
|
1871
1945
|
for (let s = 0; s < n; s++) {
|
|
1872
1946
|
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
1873
1947
|
t.set(r, i);
|
|
1874
1948
|
}
|
|
1875
1949
|
return t;
|
|
1876
|
-
}, Zs = (e) =>
|
|
1950
|
+
}, Zs = (e) => uc(new Xs(wt(e))), Qs = (e, t) => (m(e.restEncoder, t.size), P(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
1877
1951
|
m(e.restEncoder, n), m(e.restEncoder, s);
|
|
1878
|
-
}), e),
|
|
1879
|
-
class
|
|
1952
|
+
}), e), dc = (e, t) => Qs(e, xe(t.store)), fc = (e, t = new Ps()) => (e instanceof Map ? Qs(t, e) : dc(t, e), t.toUint8Array()), gc = (e) => fc(e, new Ws());
|
|
1953
|
+
class pc {
|
|
1880
1954
|
constructor() {
|
|
1881
1955
|
this.l = [];
|
|
1882
1956
|
}
|
|
1883
1957
|
}
|
|
1884
|
-
const
|
|
1958
|
+
const ss = () => new pc(), rs = (e, t) => e.l.push(t), is = (e, t) => {
|
|
1885
1959
|
const n = e.l, s = n.length;
|
|
1886
1960
|
e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1887
|
-
}, tr = (e, t, n) =>
|
|
1888
|
-
class
|
|
1961
|
+
}, tr = (e, t, n) => mn(e.l, [t, n]);
|
|
1962
|
+
class Et {
|
|
1889
1963
|
/**
|
|
1890
1964
|
* @param {number} client client id
|
|
1891
1965
|
* @param {number} clock unique per client id, continuous number
|
|
@@ -1894,16 +1968,16 @@ class Dt {
|
|
|
1894
1968
|
this.client = t, this.clock = n;
|
|
1895
1969
|
}
|
|
1896
1970
|
}
|
|
1897
|
-
const ce = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, b = (e, t) => new
|
|
1971
|
+
const ce = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, b = (e, t) => new Et(e, t), wc = (e) => {
|
|
1898
1972
|
for (const [t, n] of e.doc.share.entries())
|
|
1899
1973
|
if (n === e)
|
|
1900
1974
|
return t;
|
|
1901
1975
|
throw j();
|
|
1902
|
-
},
|
|
1903
|
-
const n =
|
|
1976
|
+
}, _t = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !Ks(t.ds, e.id), cn = (e, t) => {
|
|
1977
|
+
const n = Z(e.meta, cn, at), s = e.doc.store;
|
|
1904
1978
|
n.has(t) || (t.sv.forEach((r, i) => {
|
|
1905
|
-
r < C(s, i) &&
|
|
1906
|
-
}),
|
|
1979
|
+
r < C(s, i) && rt(e, b(i, r));
|
|
1980
|
+
}), zs(e, t.ds, (r) => {
|
|
1907
1981
|
}), n.add(t));
|
|
1908
1982
|
};
|
|
1909
1983
|
class er {
|
|
@@ -1933,11 +2007,11 @@ const xe = (e) => {
|
|
|
1933
2007
|
throw j();
|
|
1934
2008
|
}
|
|
1935
2009
|
n.push(t);
|
|
1936
|
-
},
|
|
2010
|
+
}, z = (e, t) => {
|
|
1937
2011
|
let n = 0, s = e.length - 1, r = e[s], i = r.id.clock;
|
|
1938
2012
|
if (i === t)
|
|
1939
2013
|
return s;
|
|
1940
|
-
let o =
|
|
2014
|
+
let o = G(t / (i + r.length - 1) * s);
|
|
1941
2015
|
for (; n <= s; ) {
|
|
1942
2016
|
if (r = e[o], i = r.id.clock, i <= t) {
|
|
1943
2017
|
if (t < i + r.length)
|
|
@@ -1945,33 +2019,33 @@ const xe = (e) => {
|
|
|
1945
2019
|
n = o + 1;
|
|
1946
2020
|
} else
|
|
1947
2021
|
s = o - 1;
|
|
1948
|
-
o =
|
|
2022
|
+
o = G((n + s) / 2);
|
|
1949
2023
|
}
|
|
1950
2024
|
throw j();
|
|
1951
|
-
},
|
|
2025
|
+
}, mc = (e, t) => {
|
|
1952
2026
|
const n = e.clients.get(t.client);
|
|
1953
|
-
return n[
|
|
1954
|
-
},
|
|
2027
|
+
return n[z(n, t.clock)];
|
|
2028
|
+
}, Ke = (
|
|
1955
2029
|
/** @type {function(StructStore,ID):Item} */
|
|
1956
|
-
|
|
2030
|
+
mc
|
|
1957
2031
|
), ln = (e, t, n) => {
|
|
1958
|
-
const s =
|
|
2032
|
+
const s = z(t, n), r = t[s];
|
|
1959
2033
|
return r.id.clock < n && r instanceof k ? (t.splice(s + 1, 0, Ae(e, r, n - r.id.clock)), s + 1) : s;
|
|
1960
|
-
},
|
|
2034
|
+
}, rt = (e, t) => {
|
|
1961
2035
|
const n = (
|
|
1962
2036
|
/** @type {Array<Item>} */
|
|
1963
2037
|
e.doc.store.clients.get(t.client)
|
|
1964
2038
|
);
|
|
1965
2039
|
return n[ln(e, n, t.clock)];
|
|
1966
|
-
},
|
|
1967
|
-
const s = t.clients.get(n.client), r =
|
|
1968
|
-
return n.clock !== i.id.clock + i.length - 1 && i.constructor !==
|
|
1969
|
-
},
|
|
2040
|
+
}, os = (e, t, n) => {
|
|
2041
|
+
const s = t.clients.get(n.client), r = z(s, n.clock), i = s[r];
|
|
2042
|
+
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== T && s.splice(r + 1, 0, Ae(e, i, n.clock - i.id.clock + 1)), i;
|
|
2043
|
+
}, yc = (e, t, n) => {
|
|
1970
2044
|
const s = (
|
|
1971
2045
|
/** @type {Array<GC|Item>} */
|
|
1972
2046
|
e.clients.get(t.id.client)
|
|
1973
2047
|
);
|
|
1974
|
-
s[
|
|
2048
|
+
s[z(s, t.id.clock)] = n;
|
|
1975
2049
|
}, sr = (e, t, n, s, r) => {
|
|
1976
2050
|
if (s === 0)
|
|
1977
2051
|
return;
|
|
@@ -1981,7 +2055,7 @@ const xe = (e) => {
|
|
|
1981
2055
|
c = t[o++], i < c.id.clock + c.length && ln(e, t, i), r(c);
|
|
1982
2056
|
while (o < t.length && t[o].id.clock < i);
|
|
1983
2057
|
};
|
|
1984
|
-
class
|
|
2058
|
+
class bc {
|
|
1985
2059
|
/**
|
|
1986
2060
|
* @param {Doc} doc
|
|
1987
2061
|
* @param {any} origin
|
|
@@ -1991,9 +2065,9 @@ class yc {
|
|
|
1991
2065
|
this.doc = t, this.deleteSet = new Qt(), this.beforeState = xe(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
1992
2066
|
}
|
|
1993
2067
|
}
|
|
1994
|
-
const
|
|
2068
|
+
const cs = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (En(t.deleteSet), cc(e, t), Ot(e, t.deleteSet), !0), ls = (e, t, n) => {
|
|
1995
2069
|
const s = t._item;
|
|
1996
|
-
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) &&
|
|
2070
|
+
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && Z(e.changed, t, at).add(n);
|
|
1997
2071
|
}, pe = (e, t) => {
|
|
1998
2072
|
let n = e[t], s = e[t - 1], r = t;
|
|
1999
2073
|
for (; r > 0; n = s, s = e[--r - 1]) {
|
|
@@ -2010,7 +2084,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2010
2084
|
}
|
|
2011
2085
|
const i = t - r;
|
|
2012
2086
|
return i && e.splice(t + 1 - i, i), i;
|
|
2013
|
-
},
|
|
2087
|
+
}, Sc = (e, t, n) => {
|
|
2014
2088
|
for (const [s, r] of e.clients.entries()) {
|
|
2015
2089
|
const i = (
|
|
2016
2090
|
/** @type {Array<GC|Item>} */
|
|
@@ -2018,7 +2092,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2018
2092
|
);
|
|
2019
2093
|
for (let o = r.length - 1; o >= 0; o--) {
|
|
2020
2094
|
const c = r[o], l = c.clock + c.len;
|
|
2021
|
-
for (let a =
|
|
2095
|
+
for (let a = z(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
|
|
2022
2096
|
const d = i[a];
|
|
2023
2097
|
if (c.clock + c.len <= d.id.clock)
|
|
2024
2098
|
break;
|
|
@@ -2026,14 +2100,14 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2026
2100
|
}
|
|
2027
2101
|
}
|
|
2028
2102
|
}
|
|
2029
|
-
},
|
|
2103
|
+
}, _c = (e, t) => {
|
|
2030
2104
|
e.clients.forEach((n, s) => {
|
|
2031
2105
|
const r = (
|
|
2032
2106
|
/** @type {Array<GC|Item>} */
|
|
2033
2107
|
t.clients.get(s)
|
|
2034
2108
|
);
|
|
2035
2109
|
for (let i = n.length - 1; i >= 0; i--) {
|
|
2036
|
-
const o = n[i], c = Ms(r.length - 1, 1 +
|
|
2110
|
+
const o = n[i], c = Ms(r.length - 1, 1 + z(r, o.clock + o.len - 1));
|
|
2037
2111
|
for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[l])
|
|
2038
2112
|
l -= 1 + pe(r, l);
|
|
2039
2113
|
}
|
|
@@ -2042,7 +2116,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2042
2116
|
if (t < e.length) {
|
|
2043
2117
|
const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
|
|
2044
2118
|
try {
|
|
2045
|
-
|
|
2119
|
+
En(i), n.afterState = xe(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
|
|
2046
2120
|
const c = [];
|
|
2047
2121
|
n.changed.forEach(
|
|
2048
2122
|
(l, a) => c.push(() => {
|
|
@@ -2056,15 +2130,15 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2056
2130
|
h.currentTarget = a, h._path = null;
|
|
2057
2131
|
}), l.sort((h, d) => h.path.length - d.path.length), tr(a._dEH, l, n));
|
|
2058
2132
|
});
|
|
2059
|
-
}), c.push(() => s.emit("afterTransaction", [n, s])),
|
|
2133
|
+
}), c.push(() => s.emit("afterTransaction", [n, s])), mn(c, []), n._needFormattingCleanup && Hc(n);
|
|
2060
2134
|
} finally {
|
|
2061
|
-
s.gc &&
|
|
2135
|
+
s.gc && Sc(i, r, s.gcFilter), _c(i, r), n.afterState.forEach((h, d) => {
|
|
2062
2136
|
const u = n.beforeState.get(d) || 0;
|
|
2063
2137
|
if (u !== h) {
|
|
2064
2138
|
const f = (
|
|
2065
2139
|
/** @type {Array<GC|Item>} */
|
|
2066
2140
|
r.clients.get(d)
|
|
2067
|
-
), g =
|
|
2141
|
+
), g = pt(z(f, u), 1);
|
|
2068
2142
|
for (let p = f.length - 1; p >= g; )
|
|
2069
2143
|
p -= 1 + pe(f, p);
|
|
2070
2144
|
}
|
|
@@ -2073,16 +2147,16 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2073
2147
|
const { client: d, clock: u } = o[h].id, f = (
|
|
2074
2148
|
/** @type {Array<GC|Item>} */
|
|
2075
2149
|
r.clients.get(d)
|
|
2076
|
-
), g =
|
|
2150
|
+
), g = z(f, u);
|
|
2077
2151
|
g + 1 < f.length && pe(f, g + 1) > 1 || g > 0 && pe(f, g);
|
|
2078
2152
|
}
|
|
2079
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
2153
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (Go(Hs, Bs, "[yjs] ", Vs, Fs, "Changed the client-id because another client seems to be using it."), s.clientID = Ys()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
2080
2154
|
const h = new te();
|
|
2081
|
-
|
|
2155
|
+
cs(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
|
|
2082
2156
|
}
|
|
2083
2157
|
if (s._observers.has("updateV2")) {
|
|
2084
|
-
const h = new
|
|
2085
|
-
|
|
2158
|
+
const h = new ht();
|
|
2159
|
+
cs(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
|
|
2086
2160
|
}
|
|
2087
2161
|
const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
|
|
2088
2162
|
(c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
|
|
@@ -2093,7 +2167,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2093
2167
|
}, S = (e, t, n = null, s = !0) => {
|
|
2094
2168
|
const r = e._transactionCleanups;
|
|
2095
2169
|
let i = !1, o = null;
|
|
2096
|
-
e._transaction === null && (i = !0, e._transaction = new
|
|
2170
|
+
e._transaction === null && (i = !0, e._transaction = new bc(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
2097
2171
|
try {
|
|
2098
2172
|
o = t(e._transaction);
|
|
2099
2173
|
} finally {
|
|
@@ -2104,7 +2178,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2104
2178
|
}
|
|
2105
2179
|
return o;
|
|
2106
2180
|
};
|
|
2107
|
-
function*
|
|
2181
|
+
function* kc(e) {
|
|
2108
2182
|
const t = w(e.restDecoder);
|
|
2109
2183
|
for (let n = 0; n < t; n++) {
|
|
2110
2184
|
const s = w(e.restDecoder), r = e.readClient();
|
|
@@ -2113,13 +2187,13 @@ function* _c(e) {
|
|
|
2113
2187
|
const c = e.readInfo();
|
|
2114
2188
|
if (c === 10) {
|
|
2115
2189
|
const l = w(e.restDecoder);
|
|
2116
|
-
yield new
|
|
2190
|
+
yield new O(b(r, i), l), i += l;
|
|
2117
2191
|
} else if (Ie & c) {
|
|
2118
|
-
const l = (c & (J |
|
|
2192
|
+
const l = (c & (J | x)) === 0, a = new k(
|
|
2119
2193
|
b(r, i),
|
|
2120
2194
|
null,
|
|
2121
2195
|
// left
|
|
2122
|
-
(c &
|
|
2196
|
+
(c & x) === x ? e.readLeftID() : null,
|
|
2123
2197
|
// origin
|
|
2124
2198
|
null,
|
|
2125
2199
|
// right
|
|
@@ -2136,18 +2210,18 @@ function* _c(e) {
|
|
|
2136
2210
|
yield a, i += a.length;
|
|
2137
2211
|
} else {
|
|
2138
2212
|
const l = e.readLen();
|
|
2139
|
-
yield new
|
|
2213
|
+
yield new T(b(r, i), l), i += l;
|
|
2140
2214
|
}
|
|
2141
2215
|
}
|
|
2142
2216
|
}
|
|
2143
2217
|
}
|
|
2144
|
-
class
|
|
2218
|
+
class In {
|
|
2145
2219
|
/**
|
|
2146
2220
|
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
|
|
2147
2221
|
* @param {boolean} filterSkips
|
|
2148
2222
|
*/
|
|
2149
2223
|
constructor(t, n) {
|
|
2150
|
-
this.gen =
|
|
2224
|
+
this.gen = kc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
2151
2225
|
}
|
|
2152
2226
|
/**
|
|
2153
2227
|
* @return {Item | GC | Skip |null}
|
|
@@ -2155,11 +2229,11 @@ class vn {
|
|
|
2155
2229
|
next() {
|
|
2156
2230
|
do
|
|
2157
2231
|
this.curr = this.gen.next().value || null;
|
|
2158
|
-
while (this.filterSkips && this.curr !== null && this.curr.constructor ===
|
|
2232
|
+
while (this.filterSkips && this.curr !== null && this.curr.constructor === O);
|
|
2159
2233
|
return this.curr;
|
|
2160
2234
|
}
|
|
2161
2235
|
}
|
|
2162
|
-
class
|
|
2236
|
+
class vn {
|
|
2163
2237
|
/**
|
|
2164
2238
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2165
2239
|
*/
|
|
@@ -2167,13 +2241,13 @@ class Mn {
|
|
|
2167
2241
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
2168
2242
|
}
|
|
2169
2243
|
}
|
|
2170
|
-
const
|
|
2171
|
-
if (e.constructor ===
|
|
2172
|
-
const { client: n, clock: s } = e.id;
|
|
2173
|
-
return new U(b(n, s + t), e.length - t);
|
|
2174
|
-
} else if (e.constructor === T) {
|
|
2244
|
+
const Dc = (e) => Se(e, Js, te), Ec = (e, t) => {
|
|
2245
|
+
if (e.constructor === T) {
|
|
2175
2246
|
const { client: n, clock: s } = e.id;
|
|
2176
2247
|
return new T(b(n, s + t), e.length - t);
|
|
2248
|
+
} else if (e.constructor === O) {
|
|
2249
|
+
const { client: n, clock: s } = e.id;
|
|
2250
|
+
return new O(b(n, s + t), e.length - t);
|
|
2177
2251
|
} else {
|
|
2178
2252
|
const n = (
|
|
2179
2253
|
/** @type {Item} */
|
|
@@ -2190,18 +2264,18 @@ const kc = (e) => Se(e, Js, te), Dc = (e, t) => {
|
|
|
2190
2264
|
n.content.splice(t)
|
|
2191
2265
|
);
|
|
2192
2266
|
}
|
|
2193
|
-
}, Se = (e, t = xt, n =
|
|
2267
|
+
}, Se = (e, t = xt, n = ht) => {
|
|
2194
2268
|
if (e.length === 1)
|
|
2195
2269
|
return e[0];
|
|
2196
|
-
const s = e.map((h) => new t(
|
|
2197
|
-
let r = s.map((h) => new
|
|
2198
|
-
const o = new n(), c = new
|
|
2270
|
+
const s = e.map((h) => new t(wt(h)));
|
|
2271
|
+
let r = s.map((h) => new In(h, !0)), i = null;
|
|
2272
|
+
const o = new n(), c = new vn(o);
|
|
2199
2273
|
for (; r = r.filter((u) => u.curr !== null), r.sort(
|
|
2200
2274
|
/** @type {function(any,any):number} */
|
|
2201
2275
|
(u, f) => {
|
|
2202
2276
|
if (u.curr.id.client === f.curr.id.client) {
|
|
2203
2277
|
const g = u.curr.id.clock - f.curr.id.clock;
|
|
2204
|
-
return g === 0 ? u.curr.constructor === f.curr.constructor ? 0 : u.curr.constructor ===
|
|
2278
|
+
return g === 0 ? u.curr.constructor === f.curr.constructor ? 0 : u.curr.constructor === O ? 1 : -1 : g;
|
|
2205
2279
|
} else
|
|
2206
2280
|
return f.curr.id.client - u.curr.id.client;
|
|
2207
2281
|
}
|
|
@@ -2222,56 +2296,56 @@ const kc = (e) => Se(e, Js, te), Dc = (e, t) => {
|
|
|
2222
2296
|
f && u.id.clock > i.struct.id.clock + i.struct.length)
|
|
2223
2297
|
continue;
|
|
2224
2298
|
if (d !== i.struct.id.client)
|
|
2225
|
-
|
|
2299
|
+
et(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next();
|
|
2226
2300
|
else if (i.struct.id.clock + i.struct.length < u.id.clock)
|
|
2227
|
-
if (i.struct.constructor ===
|
|
2301
|
+
if (i.struct.constructor === O)
|
|
2228
2302
|
i.struct.length = u.id.clock + u.length - i.struct.id.clock;
|
|
2229
2303
|
else {
|
|
2230
|
-
|
|
2304
|
+
et(c, i.struct, i.offset);
|
|
2231
2305
|
const g = u.id.clock - i.struct.id.clock - i.struct.length;
|
|
2232
|
-
i = { struct: new
|
|
2306
|
+
i = { struct: new O(b(d, i.struct.id.clock + i.struct.length), g), offset: 0 };
|
|
2233
2307
|
}
|
|
2234
2308
|
else {
|
|
2235
2309
|
const g = i.struct.id.clock + i.struct.length - u.id.clock;
|
|
2236
|
-
g > 0 && (i.struct.constructor ===
|
|
2310
|
+
g > 0 && (i.struct.constructor === O ? i.struct.length -= g : u = Ec(u, g)), i.struct.mergeWith(
|
|
2237
2311
|
/** @type {any} */
|
|
2238
2312
|
u
|
|
2239
|
-
) || (
|
|
2313
|
+
) || (et(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next());
|
|
2240
2314
|
}
|
|
2241
2315
|
} else
|
|
2242
2316
|
i = { struct: (
|
|
2243
2317
|
/** @type {Item | GC} */
|
|
2244
2318
|
h.curr
|
|
2245
2319
|
), offset: 0 }, h.next();
|
|
2246
|
-
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !==
|
|
2247
|
-
|
|
2248
|
-
}
|
|
2249
|
-
i !== null && (
|
|
2250
|
-
const l = s.map((h) =>
|
|
2251
|
-
return
|
|
2252
|
-
},
|
|
2253
|
-
const r = Zs(t), i = new s(), o = new
|
|
2320
|
+
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== O; u = h.next())
|
|
2321
|
+
et(c, i.struct, i.offset), i = { struct: u, offset: 0 };
|
|
2322
|
+
}
|
|
2323
|
+
i !== null && (et(c, i.struct, i.offset), i = null), Mn(c);
|
|
2324
|
+
const l = s.map((h) => Cn(h)), a = tc(l);
|
|
2325
|
+
return Ot(o, a), o.toUint8Array();
|
|
2326
|
+
}, Cc = (e, t, n = xt, s = ht) => {
|
|
2327
|
+
const r = Zs(t), i = new s(), o = new vn(i), c = new n(wt(e)), l = new In(c, !1);
|
|
2254
2328
|
for (; l.curr; ) {
|
|
2255
2329
|
const h = l.curr, d = h.id.client, u = r.get(d) || 0;
|
|
2256
|
-
if (l.curr.constructor ===
|
|
2330
|
+
if (l.curr.constructor === O) {
|
|
2257
2331
|
l.next();
|
|
2258
2332
|
continue;
|
|
2259
2333
|
}
|
|
2260
2334
|
if (h.id.clock + h.length > u)
|
|
2261
|
-
for (
|
|
2262
|
-
|
|
2335
|
+
for (et(o, h, pt(u - h.id.clock, 0)), l.next(); l.curr && l.curr.id.client === d; )
|
|
2336
|
+
et(o, l.curr, 0), l.next();
|
|
2263
2337
|
else
|
|
2264
2338
|
for (; l.curr && l.curr.id.client === d && l.curr.id.clock + l.curr.length <= u; )
|
|
2265
2339
|
l.next();
|
|
2266
2340
|
}
|
|
2267
|
-
|
|
2268
|
-
const a =
|
|
2269
|
-
return
|
|
2341
|
+
Mn(o);
|
|
2342
|
+
const a = Cn(c);
|
|
2343
|
+
return Ot(i, a), i.toUint8Array();
|
|
2270
2344
|
}, ir = (e) => {
|
|
2271
|
-
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder:
|
|
2272
|
-
},
|
|
2345
|
+
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: N(e.encoder.restEncoder) }), e.encoder.restEncoder = Zt(), e.written = 0);
|
|
2346
|
+
}, et = (e, t, n) => {
|
|
2273
2347
|
e.written > 0 && e.currClient !== t.id.client && ir(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), m(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
|
|
2274
|
-
},
|
|
2348
|
+
}, Mn = (e) => {
|
|
2275
2349
|
ir(e);
|
|
2276
2350
|
const t = e.encoder.restEncoder;
|
|
2277
2351
|
m(t, e.clientStructs.length);
|
|
@@ -2279,14 +2353,14 @@ const kc = (e) => Se(e, Js, te), Dc = (e, t) => {
|
|
|
2279
2353
|
const s = e.clientStructs[n];
|
|
2280
2354
|
m(t, s.written), Me(t, s.restEncoder);
|
|
2281
2355
|
}
|
|
2282
|
-
},
|
|
2283
|
-
const r = new n(
|
|
2356
|
+
}, Ac = (e, t, n, s) => {
|
|
2357
|
+
const r = new n(wt(e)), i = new In(r, !1), o = new s(), c = new vn(o);
|
|
2284
2358
|
for (let a = i.curr; a !== null; a = i.next())
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
const l =
|
|
2288
|
-
return
|
|
2289
|
-
},
|
|
2359
|
+
et(c, t(a), 0);
|
|
2360
|
+
Mn(c);
|
|
2361
|
+
const l = Cn(r);
|
|
2362
|
+
return Ot(o, l), o.toUint8Array();
|
|
2363
|
+
}, Lc = (e) => Ac(e, oo, xt, te), as = "You must not compute changes after the event-handler fired.";
|
|
2290
2364
|
class Ue {
|
|
2291
2365
|
/**
|
|
2292
2366
|
* @param {T} target The changed type.
|
|
@@ -2309,7 +2383,7 @@ class Ue {
|
|
|
2309
2383
|
* type === event.target // => true
|
|
2310
2384
|
*/
|
|
2311
2385
|
get path() {
|
|
2312
|
-
return this._path || (this._path =
|
|
2386
|
+
return this._path || (this._path = Ic(this.currentTarget, this.target));
|
|
2313
2387
|
}
|
|
2314
2388
|
/**
|
|
2315
2389
|
* Check if a struct is deleted by this event.
|
|
@@ -2320,7 +2394,7 @@ class Ue {
|
|
|
2320
2394
|
* @return {boolean}
|
|
2321
2395
|
*/
|
|
2322
2396
|
deletes(t) {
|
|
2323
|
-
return
|
|
2397
|
+
return Ks(this.transaction.deleteSet, t.id);
|
|
2324
2398
|
}
|
|
2325
2399
|
/**
|
|
2326
2400
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2328,7 +2402,7 @@ class Ue {
|
|
|
2328
2402
|
get keys() {
|
|
2329
2403
|
if (this._keys === null) {
|
|
2330
2404
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2331
|
-
throw
|
|
2405
|
+
throw q(as);
|
|
2332
2406
|
const t = /* @__PURE__ */ new Map(), n = this.target;
|
|
2333
2407
|
/** @type Set<string|null> */
|
|
2334
2408
|
this.transaction.changed.get(n).forEach((r) => {
|
|
@@ -2396,8 +2470,8 @@ class Ue {
|
|
|
2396
2470
|
let t = this._changes;
|
|
2397
2471
|
if (t === null) {
|
|
2398
2472
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2399
|
-
throw
|
|
2400
|
-
const n = this.target, s =
|
|
2473
|
+
throw q(as);
|
|
2474
|
+
const n = this.target, s = at(), r = at(), i = [];
|
|
2401
2475
|
if (t = {
|
|
2402
2476
|
added: s,
|
|
2403
2477
|
deleted: r,
|
|
@@ -2421,7 +2495,7 @@ class Ue {
|
|
|
2421
2495
|
);
|
|
2422
2496
|
}
|
|
2423
2497
|
}
|
|
2424
|
-
const
|
|
2498
|
+
const Ic = (e, t) => {
|
|
2425
2499
|
const n = [];
|
|
2426
2500
|
for (; t._item !== null && t !== e; ) {
|
|
2427
2501
|
if (t._item.parentSub !== null)
|
|
@@ -2440,26 +2514,26 @@ const Lc = (e, t) => {
|
|
|
2440
2514
|
}
|
|
2441
2515
|
return n;
|
|
2442
2516
|
}, or = 80;
|
|
2443
|
-
let
|
|
2444
|
-
class
|
|
2517
|
+
let xn = 0;
|
|
2518
|
+
class vc {
|
|
2445
2519
|
/**
|
|
2446
2520
|
* @param {Item} p
|
|
2447
2521
|
* @param {number} index
|
|
2448
2522
|
*/
|
|
2449
2523
|
constructor(t, n) {
|
|
2450
|
-
t.marker = !0, this.p = t, this.index = n, this.timestamp =
|
|
2524
|
+
t.marker = !0, this.p = t, this.index = n, this.timestamp = xn++;
|
|
2451
2525
|
}
|
|
2452
2526
|
}
|
|
2453
|
-
const
|
|
2454
|
-
e.timestamp =
|
|
2527
|
+
const Mc = (e) => {
|
|
2528
|
+
e.timestamp = xn++;
|
|
2455
2529
|
}, cr = (e, t, n) => {
|
|
2456
|
-
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp =
|
|
2457
|
-
},
|
|
2530
|
+
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = xn++;
|
|
2531
|
+
}, xc = (e, t, n) => {
|
|
2458
2532
|
if (e.length >= or) {
|
|
2459
2533
|
const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
2460
2534
|
return cr(s, t, n), s;
|
|
2461
2535
|
} else {
|
|
2462
|
-
const s = new
|
|
2536
|
+
const s = new vc(t, n);
|
|
2463
2537
|
return e.push(s), s;
|
|
2464
2538
|
}
|
|
2465
2539
|
}, Te = (e, t) => {
|
|
@@ -2467,7 +2541,7 @@ const vc = (e) => {
|
|
|
2467
2541
|
return null;
|
|
2468
2542
|
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => de(t - i.index) < de(t - o.index) ? i : o);
|
|
2469
2543
|
let s = e._start, r = 0;
|
|
2470
|
-
for (n !== null && (s = n.p, r = n.index,
|
|
2544
|
+
for (n !== null && (s = n.p, r = n.index, Mc(n)); s.right !== null && r < t; ) {
|
|
2471
2545
|
if (!s.deleted && s.countable) {
|
|
2472
2546
|
if (t < r + s.length)
|
|
2473
2547
|
break;
|
|
@@ -2480,8 +2554,8 @@ const vc = (e) => {
|
|
|
2480
2554
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
2481
2555
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2482
2556
|
return n !== null && de(n.index - r) < /** @type {YText|YArray<any>} */
|
|
2483
|
-
s.parent.length / or ? (cr(n, s, r), n) :
|
|
2484
|
-
},
|
|
2557
|
+
s.parent.length / or ? (cr(n, s, r), n) : xc(e._searchMarker, s, r);
|
|
2558
|
+
}, Jt = (e, t, n) => {
|
|
2485
2559
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
2486
2560
|
const r = e[s];
|
|
2487
2561
|
if (n > 0) {
|
|
@@ -2494,18 +2568,18 @@ const vc = (e) => {
|
|
|
2494
2568
|
}
|
|
2495
2569
|
r.p = i, i.marker = !0;
|
|
2496
2570
|
}
|
|
2497
|
-
(t < r.index || n > 0 && t === r.index) && (r.index =
|
|
2571
|
+
(t < r.index || n > 0 && t === r.index) && (r.index = pt(t, r.index + n));
|
|
2498
2572
|
}
|
|
2499
2573
|
}, Oe = (e, t, n) => {
|
|
2500
2574
|
const s = e, r = t.changedParentTypes;
|
|
2501
|
-
for (;
|
|
2575
|
+
for (; Z(r, e, () => []).push(n), e._item !== null; )
|
|
2502
2576
|
e = /** @type {AbstractType<any>} */
|
|
2503
2577
|
e._item.parent;
|
|
2504
2578
|
tr(s._eH, n, t);
|
|
2505
2579
|
};
|
|
2506
2580
|
class A {
|
|
2507
2581
|
constructor() {
|
|
2508
|
-
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH =
|
|
2582
|
+
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = ss(), this._dEH = ss(), this._searchMarker = null;
|
|
2509
2583
|
}
|
|
2510
2584
|
/**
|
|
2511
2585
|
* @return {AbstractType<any>|null}
|
|
@@ -2571,7 +2645,7 @@ class A {
|
|
|
2571
2645
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2572
2646
|
*/
|
|
2573
2647
|
observe(t) {
|
|
2574
|
-
|
|
2648
|
+
rs(this._eH, t);
|
|
2575
2649
|
}
|
|
2576
2650
|
/**
|
|
2577
2651
|
* Observe all events that are created by this type and its children.
|
|
@@ -2579,7 +2653,7 @@ class A {
|
|
|
2579
2653
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2580
2654
|
*/
|
|
2581
2655
|
observeDeep(t) {
|
|
2582
|
-
|
|
2656
|
+
rs(this._dEH, t);
|
|
2583
2657
|
}
|
|
2584
2658
|
/**
|
|
2585
2659
|
* Unregister an observer function.
|
|
@@ -2587,7 +2661,7 @@ class A {
|
|
|
2587
2661
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2588
2662
|
*/
|
|
2589
2663
|
unobserve(t) {
|
|
2590
|
-
|
|
2664
|
+
is(this._eH, t);
|
|
2591
2665
|
}
|
|
2592
2666
|
/**
|
|
2593
2667
|
* Unregister an observer function.
|
|
@@ -2595,7 +2669,7 @@ class A {
|
|
|
2595
2669
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2596
2670
|
*/
|
|
2597
2671
|
unobserveDeep(t) {
|
|
2598
|
-
|
|
2672
|
+
is(this._dEH, t);
|
|
2599
2673
|
}
|
|
2600
2674
|
/**
|
|
2601
2675
|
* @abstract
|
|
@@ -2635,7 +2709,7 @@ const lr = (e, t, n) => {
|
|
|
2635
2709
|
n = n.right;
|
|
2636
2710
|
}
|
|
2637
2711
|
return t;
|
|
2638
|
-
},
|
|
2712
|
+
}, Wt = (e, t) => {
|
|
2639
2713
|
let n = 0, s = e._start;
|
|
2640
2714
|
for (; s !== null; ) {
|
|
2641
2715
|
if (s.countable && !s.deleted) {
|
|
@@ -2647,10 +2721,10 @@ const lr = (e, t, n) => {
|
|
|
2647
2721
|
}
|
|
2648
2722
|
}, hr = (e, t) => {
|
|
2649
2723
|
const n = [];
|
|
2650
|
-
return
|
|
2724
|
+
return Wt(e, (s, r) => {
|
|
2651
2725
|
n.push(t(s, r, e));
|
|
2652
2726
|
}), n;
|
|
2653
|
-
},
|
|
2727
|
+
}, Uc = (e) => {
|
|
2654
2728
|
let t = e._start, n = null, s = 0;
|
|
2655
2729
|
return {
|
|
2656
2730
|
[Symbol.iterator]() {
|
|
@@ -2688,7 +2762,7 @@ const lr = (e, t, n) => {
|
|
|
2688
2762
|
const i = e.doc, o = i.clientID, c = i.store, l = n === null ? t._start : n.right;
|
|
2689
2763
|
let a = [];
|
|
2690
2764
|
const h = () => {
|
|
2691
|
-
a.length > 0 && (r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2765
|
+
a.length > 0 && (r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new ft(a)), r.integrate(e, 0), a = []);
|
|
2692
2766
|
};
|
|
2693
2767
|
s.forEach((d) => {
|
|
2694
2768
|
if (d === null)
|
|
@@ -2711,7 +2785,7 @@ const lr = (e, t, n) => {
|
|
|
2711
2785
|
d
|
|
2712
2786
|
))), r.integrate(e, 0);
|
|
2713
2787
|
break;
|
|
2714
|
-
case
|
|
2788
|
+
case mt:
|
|
2715
2789
|
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new ne(
|
|
2716
2790
|
/** @type {Doc} */
|
|
2717
2791
|
d
|
|
@@ -2719,29 +2793,29 @@ const lr = (e, t, n) => {
|
|
|
2719
2793
|
break;
|
|
2720
2794
|
default:
|
|
2721
2795
|
if (d instanceof A)
|
|
2722
|
-
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2796
|
+
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new tt(d)), r.integrate(e, 0);
|
|
2723
2797
|
else
|
|
2724
2798
|
throw new Error("Unexpected content type in insert operation");
|
|
2725
2799
|
}
|
|
2726
2800
|
}
|
|
2727
2801
|
}), h();
|
|
2728
|
-
}, dr = () =>
|
|
2802
|
+
}, dr = () => q("Length exceeded!"), fr = (e, t, n, s) => {
|
|
2729
2803
|
if (n > t._length)
|
|
2730
2804
|
throw dr();
|
|
2731
2805
|
if (n === 0)
|
|
2732
|
-
return t._searchMarker &&
|
|
2806
|
+
return t._searchMarker && Jt(t._searchMarker, n, s.length), _e(e, t, null, s);
|
|
2733
2807
|
const r = n, i = Te(t, n);
|
|
2734
2808
|
let o = t._start;
|
|
2735
2809
|
for (i !== null && (o = i.p, n -= i.index, n === 0 && (o = o.prev, n += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
|
|
2736
2810
|
if (!o.deleted && o.countable) {
|
|
2737
2811
|
if (n <= o.length) {
|
|
2738
|
-
n < o.length &&
|
|
2812
|
+
n < o.length && rt(e, b(o.id.client, o.id.clock + n));
|
|
2739
2813
|
break;
|
|
2740
2814
|
}
|
|
2741
2815
|
n -= o.length;
|
|
2742
2816
|
}
|
|
2743
|
-
return t._searchMarker &&
|
|
2744
|
-
},
|
|
2817
|
+
return t._searchMarker && Jt(t._searchMarker, r, s.length), _e(e, t, o, s);
|
|
2818
|
+
}, Tc = (e, t, n) => {
|
|
2745
2819
|
let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
|
|
2746
2820
|
if (r)
|
|
2747
2821
|
for (; r.right; )
|
|
@@ -2753,12 +2827,12 @@ const lr = (e, t, n) => {
|
|
|
2753
2827
|
const r = n, i = s, o = Te(t, n);
|
|
2754
2828
|
let c = t._start;
|
|
2755
2829
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
2756
|
-
!c.deleted && c.countable && (n < c.length &&
|
|
2830
|
+
!c.deleted && c.countable && (n < c.length && rt(e, b(c.id.client, c.id.clock + n)), n -= c.length);
|
|
2757
2831
|
for (; s > 0 && c !== null; )
|
|
2758
|
-
c.deleted || (s < c.length &&
|
|
2832
|
+
c.deleted || (s < c.length && rt(e, b(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
|
|
2759
2833
|
if (s > 0)
|
|
2760
2834
|
throw dr();
|
|
2761
|
-
t._searchMarker &&
|
|
2835
|
+
t._searchMarker && Jt(
|
|
2762
2836
|
t._searchMarker,
|
|
2763
2837
|
r,
|
|
2764
2838
|
-i + s
|
|
@@ -2767,11 +2841,11 @@ const lr = (e, t, n) => {
|
|
|
2767
2841
|
}, ke = (e, t, n) => {
|
|
2768
2842
|
const s = t._map.get(n);
|
|
2769
2843
|
s !== void 0 && s.delete(e);
|
|
2770
|
-
},
|
|
2844
|
+
}, Un = (e, t, n, s) => {
|
|
2771
2845
|
const r = t._map.get(n) || null, i = e.doc, o = i.clientID;
|
|
2772
2846
|
let c;
|
|
2773
2847
|
if (s == null)
|
|
2774
|
-
c = new
|
|
2848
|
+
c = new ft([s]);
|
|
2775
2849
|
else
|
|
2776
2850
|
switch (s.constructor) {
|
|
2777
2851
|
case Number:
|
|
@@ -2779,7 +2853,7 @@ const lr = (e, t, n) => {
|
|
|
2779
2853
|
case Boolean:
|
|
2780
2854
|
case Array:
|
|
2781
2855
|
case String:
|
|
2782
|
-
c = new
|
|
2856
|
+
c = new ft([s]);
|
|
2783
2857
|
break;
|
|
2784
2858
|
case Uint8Array:
|
|
2785
2859
|
c = new ee(
|
|
@@ -2787,7 +2861,7 @@ const lr = (e, t, n) => {
|
|
|
2787
2861
|
s
|
|
2788
2862
|
);
|
|
2789
2863
|
break;
|
|
2790
|
-
case
|
|
2864
|
+
case mt:
|
|
2791
2865
|
c = new ne(
|
|
2792
2866
|
/** @type {Doc} */
|
|
2793
2867
|
s
|
|
@@ -2795,12 +2869,12 @@ const lr = (e, t, n) => {
|
|
|
2795
2869
|
break;
|
|
2796
2870
|
default:
|
|
2797
2871
|
if (s instanceof A)
|
|
2798
|
-
c = new
|
|
2872
|
+
c = new tt(s);
|
|
2799
2873
|
else
|
|
2800
2874
|
throw new Error("Unexpected content type");
|
|
2801
2875
|
}
|
|
2802
2876
|
new k(b(o, C(i.store, o)), r, r && r.lastId, null, null, t, n, c).integrate(e, 0);
|
|
2803
|
-
},
|
|
2877
|
+
}, Tn = (e, t) => {
|
|
2804
2878
|
const n = e._map.get(t);
|
|
2805
2879
|
return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
|
|
2806
2880
|
}, pr = (e) => {
|
|
@@ -2811,20 +2885,20 @@ const lr = (e, t, n) => {
|
|
|
2811
2885
|
}, wr = (e, t) => {
|
|
2812
2886
|
const n = e._map.get(t);
|
|
2813
2887
|
return n !== void 0 && !n.deleted;
|
|
2814
|
-
},
|
|
2888
|
+
}, Oc = (e, t) => {
|
|
2815
2889
|
const n = {};
|
|
2816
2890
|
return e._map.forEach((s, r) => {
|
|
2817
2891
|
let i = s;
|
|
2818
2892
|
for (; i !== null && (!t.sv.has(i.id.client) || i.id.clock >= (t.sv.get(i.id.client) || 0)); )
|
|
2819
2893
|
i = i.left;
|
|
2820
|
-
i !== null &&
|
|
2894
|
+
i !== null && _t(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
|
|
2821
2895
|
}), n;
|
|
2822
|
-
}, le = (e) =>
|
|
2896
|
+
}, le = (e) => Zo(
|
|
2823
2897
|
e.entries(),
|
|
2824
2898
|
/** @param {any} entry */
|
|
2825
2899
|
(t) => !t[1].deleted
|
|
2826
2900
|
);
|
|
2827
|
-
class
|
|
2901
|
+
class Rc extends Ue {
|
|
2828
2902
|
/**
|
|
2829
2903
|
* @param {YArray<T>} yarray The changed type
|
|
2830
2904
|
* @param {Transaction} transaction The transaction object
|
|
@@ -2833,7 +2907,7 @@ class Oc extends Ue {
|
|
|
2833
2907
|
super(t, n), this._transaction = n;
|
|
2834
2908
|
}
|
|
2835
2909
|
}
|
|
2836
|
-
class
|
|
2910
|
+
class Ct extends A {
|
|
2837
2911
|
constructor() {
|
|
2838
2912
|
super(), this._prelimContent = [], this._searchMarker = [];
|
|
2839
2913
|
}
|
|
@@ -2844,7 +2918,7 @@ class Et extends A {
|
|
|
2844
2918
|
* @return {YArray<T>}
|
|
2845
2919
|
*/
|
|
2846
2920
|
static from(t) {
|
|
2847
|
-
const n = new
|
|
2921
|
+
const n = new Ct();
|
|
2848
2922
|
return n.push(t), n;
|
|
2849
2923
|
}
|
|
2850
2924
|
/**
|
|
@@ -2868,13 +2942,13 @@ class Et extends A {
|
|
|
2868
2942
|
* @return {YArray<T>}
|
|
2869
2943
|
*/
|
|
2870
2944
|
_copy() {
|
|
2871
|
-
return new
|
|
2945
|
+
return new Ct();
|
|
2872
2946
|
}
|
|
2873
2947
|
/**
|
|
2874
2948
|
* @return {YArray<T>}
|
|
2875
2949
|
*/
|
|
2876
2950
|
clone() {
|
|
2877
|
-
const t = new
|
|
2951
|
+
const t = new Ct();
|
|
2878
2952
|
return t.insert(0, this.toArray().map(
|
|
2879
2953
|
(n) => n instanceof A ? (
|
|
2880
2954
|
/** @type {typeof el} */
|
|
@@ -2892,7 +2966,7 @@ class Et extends A {
|
|
|
2892
2966
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2893
2967
|
*/
|
|
2894
2968
|
_callObserver(t, n) {
|
|
2895
|
-
super._callObserver(t, n), Oe(this, t, new
|
|
2969
|
+
super._callObserver(t, n), Oe(this, t, new Rc(this, t));
|
|
2896
2970
|
}
|
|
2897
2971
|
/**
|
|
2898
2972
|
* Inserts new content at an index.
|
|
@@ -2930,7 +3004,7 @@ class Et extends A {
|
|
|
2930
3004
|
*/
|
|
2931
3005
|
push(t) {
|
|
2932
3006
|
this.doc !== null ? S(this.doc, (n) => {
|
|
2933
|
-
|
|
3007
|
+
Tc(
|
|
2934
3008
|
n,
|
|
2935
3009
|
this,
|
|
2936
3010
|
/** @type {any} */
|
|
@@ -3014,23 +3088,23 @@ class Et extends A {
|
|
|
3014
3088
|
* @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
|
|
3015
3089
|
*/
|
|
3016
3090
|
forEach(t) {
|
|
3017
|
-
|
|
3091
|
+
Wt(this, t);
|
|
3018
3092
|
}
|
|
3019
3093
|
/**
|
|
3020
3094
|
* @return {IterableIterator<T>}
|
|
3021
3095
|
*/
|
|
3022
3096
|
[Symbol.iterator]() {
|
|
3023
|
-
return
|
|
3097
|
+
return Uc(this);
|
|
3024
3098
|
}
|
|
3025
3099
|
/**
|
|
3026
3100
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3027
3101
|
*/
|
|
3028
3102
|
_write(t) {
|
|
3029
|
-
t.writeTypeRef(
|
|
3103
|
+
t.writeTypeRef(il);
|
|
3030
3104
|
}
|
|
3031
3105
|
}
|
|
3032
|
-
const
|
|
3033
|
-
class
|
|
3106
|
+
const $c = (e) => new Ct();
|
|
3107
|
+
class Nc extends Ue {
|
|
3034
3108
|
/**
|
|
3035
3109
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
3036
3110
|
* @param {Transaction} transaction
|
|
@@ -3040,7 +3114,7 @@ class $c extends Ue {
|
|
|
3040
3114
|
super(t, n), this.keysChanged = s;
|
|
3041
3115
|
}
|
|
3042
3116
|
}
|
|
3043
|
-
class
|
|
3117
|
+
class ut extends A {
|
|
3044
3118
|
/**
|
|
3045
3119
|
*
|
|
3046
3120
|
* @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
|
|
@@ -3067,13 +3141,13 @@ class ht extends A {
|
|
|
3067
3141
|
* @return {YMap<MapType>}
|
|
3068
3142
|
*/
|
|
3069
3143
|
_copy() {
|
|
3070
|
-
return new
|
|
3144
|
+
return new ut();
|
|
3071
3145
|
}
|
|
3072
3146
|
/**
|
|
3073
3147
|
* @return {YMap<MapType>}
|
|
3074
3148
|
*/
|
|
3075
3149
|
clone() {
|
|
3076
|
-
const t = new
|
|
3150
|
+
const t = new ut();
|
|
3077
3151
|
return this.forEach((n, s) => {
|
|
3078
3152
|
t.set(s, n instanceof A ? (
|
|
3079
3153
|
/** @type {typeof value} */
|
|
@@ -3088,7 +3162,7 @@ class ht extends A {
|
|
|
3088
3162
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3089
3163
|
*/
|
|
3090
3164
|
_callObserver(t, n) {
|
|
3091
|
-
Oe(this, t, new
|
|
3165
|
+
Oe(this, t, new Nc(this, t, n));
|
|
3092
3166
|
}
|
|
3093
3167
|
/**
|
|
3094
3168
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3118,7 +3192,7 @@ class ht extends A {
|
|
|
3118
3192
|
* @return {IterableIterator<string>}
|
|
3119
3193
|
*/
|
|
3120
3194
|
keys() {
|
|
3121
|
-
return
|
|
3195
|
+
return ze(
|
|
3122
3196
|
le(this._map),
|
|
3123
3197
|
/** @param {any} v */
|
|
3124
3198
|
(t) => t[0]
|
|
@@ -3130,7 +3204,7 @@ class ht extends A {
|
|
|
3130
3204
|
* @return {IterableIterator<MapType>}
|
|
3131
3205
|
*/
|
|
3132
3206
|
values() {
|
|
3133
|
-
return
|
|
3207
|
+
return ze(
|
|
3134
3208
|
le(this._map),
|
|
3135
3209
|
/** @param {any} v */
|
|
3136
3210
|
(t) => t[1].content.getContent()[t[1].length - 1]
|
|
@@ -3142,7 +3216,7 @@ class ht extends A {
|
|
|
3142
3216
|
* @return {IterableIterator<[string, MapType]>}
|
|
3143
3217
|
*/
|
|
3144
3218
|
entries() {
|
|
3145
|
-
return
|
|
3219
|
+
return ze(
|
|
3146
3220
|
le(this._map),
|
|
3147
3221
|
/** @param {any} v */
|
|
3148
3222
|
(t) => (
|
|
@@ -3189,7 +3263,7 @@ class ht extends A {
|
|
|
3189
3263
|
*/
|
|
3190
3264
|
set(t, n) {
|
|
3191
3265
|
return this.doc !== null ? S(this.doc, (s) => {
|
|
3192
|
-
|
|
3266
|
+
Un(
|
|
3193
3267
|
s,
|
|
3194
3268
|
this,
|
|
3195
3269
|
t,
|
|
@@ -3207,7 +3281,7 @@ class ht extends A {
|
|
|
3207
3281
|
get(t) {
|
|
3208
3282
|
return (
|
|
3209
3283
|
/** @type {any} */
|
|
3210
|
-
|
|
3284
|
+
Tn(this, t)
|
|
3211
3285
|
);
|
|
3212
3286
|
}
|
|
3213
3287
|
/**
|
|
@@ -3233,10 +3307,10 @@ class ht extends A {
|
|
|
3233
3307
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3234
3308
|
*/
|
|
3235
3309
|
_write(t) {
|
|
3236
|
-
t.writeTypeRef(
|
|
3310
|
+
t.writeTypeRef(ol);
|
|
3237
3311
|
}
|
|
3238
3312
|
}
|
|
3239
|
-
const
|
|
3313
|
+
const Bc = (e) => new ut(), nt = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && io(e, t);
|
|
3240
3314
|
class an {
|
|
3241
3315
|
/**
|
|
3242
3316
|
* @param {Item|null} left
|
|
@@ -3253,7 +3327,7 @@ class an {
|
|
|
3253
3327
|
forward() {
|
|
3254
3328
|
switch (this.right === null && j(), this.right.content.constructor) {
|
|
3255
3329
|
case D:
|
|
3256
|
-
this.right.deleted ||
|
|
3330
|
+
this.right.deleted || Rt(
|
|
3257
3331
|
this.currentAttributes,
|
|
3258
3332
|
/** @type {ContentFormat} */
|
|
3259
3333
|
this.right.content
|
|
@@ -3266,18 +3340,18 @@ class an {
|
|
|
3266
3340
|
this.left = this.right, this.right = this.right.right;
|
|
3267
3341
|
}
|
|
3268
3342
|
}
|
|
3269
|
-
const
|
|
3343
|
+
const hs = (e, t, n) => {
|
|
3270
3344
|
for (; t.right !== null && n > 0; ) {
|
|
3271
3345
|
switch (t.right.content.constructor) {
|
|
3272
3346
|
case D:
|
|
3273
|
-
t.right.deleted ||
|
|
3347
|
+
t.right.deleted || Rt(
|
|
3274
3348
|
t.currentAttributes,
|
|
3275
3349
|
/** @type {ContentFormat} */
|
|
3276
3350
|
t.right.content
|
|
3277
3351
|
);
|
|
3278
3352
|
break;
|
|
3279
3353
|
default:
|
|
3280
|
-
t.right.deleted || (n < t.right.length &&
|
|
3354
|
+
t.right.deleted || (n < t.right.length && rt(e, b(t.right.id.client, t.right.id.clock + n)), t.index += t.right.length, n -= t.right.length);
|
|
3281
3355
|
break;
|
|
3282
3356
|
}
|
|
3283
3357
|
t.left = t.right, t.right = t.right.right;
|
|
@@ -3287,13 +3361,13 @@ const us = (e, t, n) => {
|
|
|
3287
3361
|
const r = /* @__PURE__ */ new Map(), i = s ? Te(t, n) : null;
|
|
3288
3362
|
if (i) {
|
|
3289
3363
|
const o = new an(i.p.left, i.p, i.index, r);
|
|
3290
|
-
return
|
|
3364
|
+
return hs(e, o, n - i.index);
|
|
3291
3365
|
} else {
|
|
3292
3366
|
const o = new an(null, t._start, 0, r);
|
|
3293
|
-
return
|
|
3367
|
+
return hs(e, o, n);
|
|
3294
3368
|
}
|
|
3295
3369
|
}, mr = (e, t, n, s) => {
|
|
3296
|
-
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === D &&
|
|
3370
|
+
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === D && nt(
|
|
3297
3371
|
s.get(
|
|
3298
3372
|
/** @type {ContentFormat} */
|
|
3299
3373
|
n.right.content.key
|
|
@@ -3310,16 +3384,16 @@ const us = (e, t, n) => {
|
|
|
3310
3384
|
const l = n.left, a = n.right, h = new k(b(i, C(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new D(c, o));
|
|
3311
3385
|
h.integrate(e, 0), n.right = h, n.forward();
|
|
3312
3386
|
});
|
|
3313
|
-
},
|
|
3387
|
+
}, Rt = (e, t) => {
|
|
3314
3388
|
const { key: n, value: s } = t;
|
|
3315
3389
|
s === null ? e.delete(n) : e.set(n, s);
|
|
3316
3390
|
}, yr = (e, t) => {
|
|
3317
3391
|
for (; e.right !== null; ) {
|
|
3318
|
-
if (!(e.right.deleted || e.right.content.constructor === D &&
|
|
3392
|
+
if (!(e.right.deleted || e.right.content.constructor === D && nt(
|
|
3319
3393
|
t[
|
|
3320
3394
|
/** @type {ContentFormat} */
|
|
3321
3395
|
e.right.content.key
|
|
3322
|
-
]
|
|
3396
|
+
] ?? null,
|
|
3323
3397
|
/** @type {ContentFormat} */
|
|
3324
3398
|
e.right.content.value
|
|
3325
3399
|
)))
|
|
@@ -3329,8 +3403,8 @@ const us = (e, t, n) => {
|
|
|
3329
3403
|
}, br = (e, t, n, s) => {
|
|
3330
3404
|
const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
3331
3405
|
for (const c in s) {
|
|
3332
|
-
const l = s[c], a = n.currentAttributes.get(c)
|
|
3333
|
-
if (!
|
|
3406
|
+
const l = s[c], a = n.currentAttributes.get(c) ?? null;
|
|
3407
|
+
if (!nt(a, l)) {
|
|
3334
3408
|
o.set(c, a);
|
|
3335
3409
|
const { left: h, right: d } = n;
|
|
3336
3410
|
n.right = new k(b(i, C(r.store, i)), h, h && h.lastId, d, d && d.id, t, null, new D(c, l)), n.right.integrate(e, 0), n.forward();
|
|
@@ -3343,13 +3417,13 @@ const us = (e, t, n) => {
|
|
|
3343
3417
|
});
|
|
3344
3418
|
const i = e.doc, o = i.clientID;
|
|
3345
3419
|
yr(n, r);
|
|
3346
|
-
const c = br(e, t, n, r), l = s.constructor === String ? new
|
|
3420
|
+
const c = br(e, t, n, r), l = s.constructor === String ? new K(
|
|
3347
3421
|
/** @type {string} */
|
|
3348
3422
|
s
|
|
3349
|
-
) : s instanceof A ? new
|
|
3423
|
+
) : s instanceof A ? new tt(s) : new yt(s);
|
|
3350
3424
|
let { left: a, right: h, index: d } = n;
|
|
3351
|
-
t._searchMarker &&
|
|
3352
|
-
},
|
|
3425
|
+
t._searchMarker && Jt(t._searchMarker, n.index, l.getLength()), h = new k(b(o, C(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = d, n.forward(), mr(e, t, n, c);
|
|
3426
|
+
}, us = (e, t, n, s, r) => {
|
|
3353
3427
|
const i = e.doc, o = i.clientID;
|
|
3354
3428
|
yr(n, r);
|
|
3355
3429
|
const c = br(e, t, n, r);
|
|
@@ -3363,7 +3437,7 @@ const us = (e, t, n) => {
|
|
|
3363
3437
|
n.right.content
|
|
3364
3438
|
), h = r[l];
|
|
3365
3439
|
if (h !== void 0) {
|
|
3366
|
-
if (
|
|
3440
|
+
if (nt(h, a))
|
|
3367
3441
|
c.delete(l);
|
|
3368
3442
|
else {
|
|
3369
3443
|
if (s === 0)
|
|
@@ -3376,7 +3450,7 @@ const us = (e, t, n) => {
|
|
|
3376
3450
|
break;
|
|
3377
3451
|
}
|
|
3378
3452
|
default:
|
|
3379
|
-
s < n.right.length &&
|
|
3453
|
+
s < n.right.length && rt(e, b(n.right.id.client, n.right.id.clock + s)), s -= n.right.length;
|
|
3380
3454
|
break;
|
|
3381
3455
|
}
|
|
3382
3456
|
n.forward();
|
|
@@ -3386,12 +3460,12 @@ const us = (e, t, n) => {
|
|
|
3386
3460
|
for (; s > 0; s--)
|
|
3387
3461
|
l += `
|
|
3388
3462
|
`;
|
|
3389
|
-
n.right = new k(b(o, C(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new
|
|
3463
|
+
n.right = new k(b(o, C(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new K(l)), n.right.integrate(e, 0), n.forward();
|
|
3390
3464
|
}
|
|
3391
3465
|
mr(e, t, n, c);
|
|
3392
3466
|
}, Sr = (e, t, n, s, r) => {
|
|
3393
3467
|
let i = t;
|
|
3394
|
-
const o =
|
|
3468
|
+
const o = M();
|
|
3395
3469
|
for (; i && (!i.countable || i.deleted); ) {
|
|
3396
3470
|
if (!i.deleted && i.content.constructor === D) {
|
|
3397
3471
|
const a = (
|
|
@@ -3411,8 +3485,8 @@ const us = (e, t, n) => {
|
|
|
3411
3485
|
const { key: h, value: d } = (
|
|
3412
3486
|
/** @type {ContentFormat} */
|
|
3413
3487
|
a
|
|
3414
|
-
), u = s.get(h)
|
|
3415
|
-
(o.get(h) !== a || u === d) && (t.delete(e), c++, !l && (r.get(h)
|
|
3488
|
+
), u = s.get(h) ?? null;
|
|
3489
|
+
(o.get(h) !== a || u === d) && (t.delete(e), c++, !l && (r.get(h) ?? null) === d && u !== d && (u === null ? r.delete(h) : r.set(h, u))), !l && !t.deleted && Rt(
|
|
3416
3490
|
r,
|
|
3417
3491
|
/** @type {ContentFormat} */
|
|
3418
3492
|
a
|
|
@@ -3425,7 +3499,7 @@ const us = (e, t, n) => {
|
|
|
3425
3499
|
t.right;
|
|
3426
3500
|
}
|
|
3427
3501
|
return c;
|
|
3428
|
-
},
|
|
3502
|
+
}, Vc = (e, t) => {
|
|
3429
3503
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
3430
3504
|
t = t.right;
|
|
3431
3505
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -3439,7 +3513,7 @@ const us = (e, t, n) => {
|
|
|
3439
3513
|
}
|
|
3440
3514
|
t = t.left;
|
|
3441
3515
|
}
|
|
3442
|
-
},
|
|
3516
|
+
}, Fc = (e) => {
|
|
3443
3517
|
let t = 0;
|
|
3444
3518
|
return S(
|
|
3445
3519
|
/** @type {Doc} */
|
|
@@ -3448,13 +3522,13 @@ const us = (e, t, n) => {
|
|
|
3448
3522
|
let s = (
|
|
3449
3523
|
/** @type {Item} */
|
|
3450
3524
|
e._start
|
|
3451
|
-
), r = e._start, i =
|
|
3525
|
+
), r = e._start, i = M();
|
|
3452
3526
|
const o = tn(i);
|
|
3453
3527
|
for (; r; ) {
|
|
3454
3528
|
if (r.deleted === !1)
|
|
3455
3529
|
switch (r.content.constructor) {
|
|
3456
3530
|
case D:
|
|
3457
|
-
|
|
3531
|
+
Rt(
|
|
3458
3532
|
o,
|
|
3459
3533
|
/** @type {ContentFormat} */
|
|
3460
3534
|
r.content
|
|
@@ -3468,7 +3542,7 @@ const us = (e, t, n) => {
|
|
|
3468
3542
|
}
|
|
3469
3543
|
}
|
|
3470
3544
|
), t;
|
|
3471
|
-
},
|
|
3545
|
+
}, Hc = (e) => {
|
|
3472
3546
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
3473
3547
|
for (const [s, r] of e.afterState.entries()) {
|
|
3474
3548
|
const i = e.beforeState.get(s) || 0;
|
|
@@ -3480,7 +3554,7 @@ const us = (e, t, n) => {
|
|
|
3480
3554
|
r,
|
|
3481
3555
|
(o) => {
|
|
3482
3556
|
!o.deleted && /** @type {Item} */
|
|
3483
|
-
o.content.constructor === D && o.constructor !==
|
|
3557
|
+
o.content.constructor === D && o.constructor !== T && t.add(
|
|
3484
3558
|
/** @type {any} */
|
|
3485
3559
|
o.parent
|
|
3486
3560
|
);
|
|
@@ -3488,8 +3562,8 @@ const us = (e, t, n) => {
|
|
|
3488
3562
|
);
|
|
3489
3563
|
}
|
|
3490
3564
|
S(n, (s) => {
|
|
3491
|
-
|
|
3492
|
-
if (r instanceof
|
|
3565
|
+
zs(e, e.deleteSet, (r) => {
|
|
3566
|
+
if (r instanceof T || !/** @type {YText} */
|
|
3493
3567
|
r.parent._hasFormatting || t.has(
|
|
3494
3568
|
/** @type {YText} */
|
|
3495
3569
|
r.parent
|
|
@@ -3499,20 +3573,20 @@ const us = (e, t, n) => {
|
|
|
3499
3573
|
/** @type {YText} */
|
|
3500
3574
|
r.parent
|
|
3501
3575
|
);
|
|
3502
|
-
r.content.constructor === D ? t.add(i) :
|
|
3576
|
+
r.content.constructor === D ? t.add(i) : Vc(s, r);
|
|
3503
3577
|
});
|
|
3504
3578
|
for (const r of t)
|
|
3505
|
-
|
|
3579
|
+
Fc(r);
|
|
3506
3580
|
});
|
|
3507
|
-
},
|
|
3581
|
+
}, ds = (e, t, n) => {
|
|
3508
3582
|
const s = n, r = tn(t.currentAttributes), i = t.right;
|
|
3509
3583
|
for (; n > 0 && t.right !== null; ) {
|
|
3510
3584
|
if (t.right.deleted === !1)
|
|
3511
3585
|
switch (t.right.content.constructor) {
|
|
3512
|
-
case
|
|
3513
|
-
case
|
|
3514
|
-
case
|
|
3515
|
-
n < t.right.length &&
|
|
3586
|
+
case tt:
|
|
3587
|
+
case yt:
|
|
3588
|
+
case K:
|
|
3589
|
+
n < t.right.length && rt(e, b(t.right.id.client, t.right.id.clock + n)), n -= t.right.length, t.right.delete(e);
|
|
3516
3590
|
break;
|
|
3517
3591
|
}
|
|
3518
3592
|
t.forward();
|
|
@@ -3523,9 +3597,9 @@ const us = (e, t, n) => {
|
|
|
3523
3597
|
/** @type {Item} */
|
|
3524
3598
|
(t.left || t.right).parent
|
|
3525
3599
|
);
|
|
3526
|
-
return o._searchMarker &&
|
|
3600
|
+
return o._searchMarker && Jt(o._searchMarker, t.index, -s + n), t;
|
|
3527
3601
|
};
|
|
3528
|
-
class
|
|
3602
|
+
class jc extends Ue {
|
|
3529
3603
|
/**
|
|
3530
3604
|
* @param {YText} ytext
|
|
3531
3605
|
* @param {Transaction} transaction
|
|
@@ -3586,7 +3660,7 @@ class Hc extends Ue {
|
|
|
3586
3660
|
}))), a = "";
|
|
3587
3661
|
break;
|
|
3588
3662
|
case "retain":
|
|
3589
|
-
h > 0 && (f = { retain: h },
|
|
3663
|
+
h > 0 && (f = { retain: h }, so(l) || (f.attributes = to({}, l))), h = 0;
|
|
3590
3664
|
break;
|
|
3591
3665
|
}
|
|
3592
3666
|
f && n.push(f), c = null;
|
|
@@ -3594,11 +3668,11 @@ class Hc extends Ue {
|
|
|
3594
3668
|
};
|
|
3595
3669
|
for (; o !== null; ) {
|
|
3596
3670
|
switch (o.content.constructor) {
|
|
3597
|
-
case
|
|
3598
|
-
case
|
|
3671
|
+
case tt:
|
|
3672
|
+
case yt:
|
|
3599
3673
|
this.adds(o) ? this.deletes(o) || (u(), c = "insert", a = o.content.getContent()[0], u()) : this.deletes(o) ? (c !== "delete" && (u(), c = "delete"), d += 1) : o.deleted || (c !== "retain" && (u(), c = "retain"), h += 1);
|
|
3600
3674
|
break;
|
|
3601
|
-
case
|
|
3675
|
+
case K:
|
|
3602
3676
|
this.adds(o) ? this.deletes(o) || (c !== "insert" && (u(), c = "insert"), a += /** @type {ContentString} */
|
|
3603
3677
|
o.content.str) : this.deletes(o) ? (c !== "delete" && (u(), c = "delete"), d += o.length) : o.deleted || (c !== "retain" && (u(), c = "retain"), h += o.length);
|
|
3604
3678
|
break;
|
|
@@ -3609,19 +3683,19 @@ class Hc extends Ue {
|
|
|
3609
3683
|
);
|
|
3610
3684
|
if (this.adds(o)) {
|
|
3611
3685
|
if (!this.deletes(o)) {
|
|
3612
|
-
const p = r.get(f)
|
|
3613
|
-
|
|
3686
|
+
const p = r.get(f) ?? null;
|
|
3687
|
+
nt(p, g) ? g !== null && o.delete(s) : (c === "retain" && u(), nt(g, i.get(f) ?? null) ? delete l[f] : l[f] = g);
|
|
3614
3688
|
}
|
|
3615
3689
|
} else if (this.deletes(o)) {
|
|
3616
3690
|
i.set(f, g);
|
|
3617
|
-
const p = r.get(f)
|
|
3618
|
-
|
|
3691
|
+
const p = r.get(f) ?? null;
|
|
3692
|
+
nt(p, g) || (c === "retain" && u(), l[f] = p);
|
|
3619
3693
|
} else if (!o.deleted) {
|
|
3620
3694
|
i.set(f, g);
|
|
3621
3695
|
const p = l[f];
|
|
3622
|
-
p !== void 0 && (
|
|
3696
|
+
p !== void 0 && (nt(p, g) ? p !== null && o.delete(s) : (c === "retain" && u(), g === null ? delete l[f] : l[f] = g));
|
|
3623
3697
|
}
|
|
3624
|
-
o.deleted || (c === "insert" && u(),
|
|
3698
|
+
o.deleted || (c === "insert" && u(), Rt(
|
|
3625
3699
|
r,
|
|
3626
3700
|
/** @type {ContentFormat} */
|
|
3627
3701
|
o.content
|
|
@@ -3692,7 +3766,7 @@ class Ut extends A {
|
|
|
3692
3766
|
*/
|
|
3693
3767
|
_callObserver(t, n) {
|
|
3694
3768
|
super._callObserver(t, n);
|
|
3695
|
-
const s = new
|
|
3769
|
+
const s = new jc(this, t, n);
|
|
3696
3770
|
Oe(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
3697
3771
|
}
|
|
3698
3772
|
/**
|
|
@@ -3703,7 +3777,7 @@ class Ut extends A {
|
|
|
3703
3777
|
toString() {
|
|
3704
3778
|
let t = "", n = this._start;
|
|
3705
3779
|
for (; n !== null; )
|
|
3706
|
-
!n.deleted && n.countable && n.content.constructor ===
|
|
3780
|
+
!n.deleted && n.countable && n.content.constructor === K && (t += /** @type {ContentString} */
|
|
3707
3781
|
n.content.str), n = n.right;
|
|
3708
3782
|
return t;
|
|
3709
3783
|
}
|
|
@@ -3736,7 +3810,7 @@ class Ut extends A {
|
|
|
3736
3810
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3737
3811
|
(typeof c != "string" || c.length > 0) && Ye(s, this, r, c, o.attributes || {});
|
|
3738
3812
|
} else
|
|
3739
|
-
o.retain !== void 0 ?
|
|
3813
|
+
o.retain !== void 0 ? us(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && ds(s, r, o.delete);
|
|
3740
3814
|
}
|
|
3741
3815
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
3742
3816
|
}
|
|
@@ -3769,16 +3843,16 @@ class Ut extends A {
|
|
|
3769
3843
|
}
|
|
3770
3844
|
const h = () => {
|
|
3771
3845
|
for (; l !== null; ) {
|
|
3772
|
-
if (
|
|
3846
|
+
if (_t(l, t) || n !== void 0 && _t(l, n))
|
|
3773
3847
|
switch (l.content.constructor) {
|
|
3774
|
-
case
|
|
3848
|
+
case K: {
|
|
3775
3849
|
const d = i.get("ychange");
|
|
3776
|
-
t !== void 0 && !
|
|
3850
|
+
t !== void 0 && !_t(l, t) ? (d === void 0 || d.user !== l.id.client || d.type !== "removed") && (a(), i.set("ychange", s ? s("removed", l.id) : { type: "removed" })) : n !== void 0 && !_t(l, n) ? (d === void 0 || d.user !== l.id.client || d.type !== "added") && (a(), i.set("ychange", s ? s("added", l.id) : { type: "added" })) : d !== void 0 && (a(), i.delete("ychange")), c += /** @type {ContentString} */
|
|
3777
3851
|
l.content.str;
|
|
3778
3852
|
break;
|
|
3779
3853
|
}
|
|
3780
|
-
case
|
|
3781
|
-
case
|
|
3854
|
+
case tt:
|
|
3855
|
+
case yt: {
|
|
3782
3856
|
a();
|
|
3783
3857
|
const d = {
|
|
3784
3858
|
insert: l.content.getContent()[0]
|
|
@@ -3796,7 +3870,7 @@ class Ut extends A {
|
|
|
3796
3870
|
break;
|
|
3797
3871
|
}
|
|
3798
3872
|
case D:
|
|
3799
|
-
|
|
3873
|
+
_t(l, t) && (a(), Rt(
|
|
3800
3874
|
i,
|
|
3801
3875
|
/** @type {ContentFormat} */
|
|
3802
3876
|
l.content
|
|
@@ -3862,7 +3936,7 @@ class Ut extends A {
|
|
|
3862
3936
|
return;
|
|
3863
3937
|
const s = this.doc;
|
|
3864
3938
|
s !== null ? S(s, (r) => {
|
|
3865
|
-
|
|
3939
|
+
ds(r, ae(r, this, t, !0), n);
|
|
3866
3940
|
}) : this._pending.push(() => this.delete(t, n));
|
|
3867
3941
|
}
|
|
3868
3942
|
/**
|
|
@@ -3881,7 +3955,7 @@ class Ut extends A {
|
|
|
3881
3955
|
const r = this.doc;
|
|
3882
3956
|
r !== null ? S(r, (i) => {
|
|
3883
3957
|
const o = ae(i, this, t, !1);
|
|
3884
|
-
o.right !== null &&
|
|
3958
|
+
o.right !== null && us(i, this, o, n, s);
|
|
3885
3959
|
}) : this._pending.push(() => this.format(t, n, s));
|
|
3886
3960
|
}
|
|
3887
3961
|
/**
|
|
@@ -3910,7 +3984,7 @@ class Ut extends A {
|
|
|
3910
3984
|
*/
|
|
3911
3985
|
setAttribute(t, n) {
|
|
3912
3986
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3913
|
-
|
|
3987
|
+
Un(s, this, t, n);
|
|
3914
3988
|
}) : this._pending.push(() => this.setAttribute(t, n));
|
|
3915
3989
|
}
|
|
3916
3990
|
/**
|
|
@@ -3927,7 +4001,7 @@ class Ut extends A {
|
|
|
3927
4001
|
getAttribute(t) {
|
|
3928
4002
|
return (
|
|
3929
4003
|
/** @type {any} */
|
|
3930
|
-
|
|
4004
|
+
Tn(this, t)
|
|
3931
4005
|
);
|
|
3932
4006
|
}
|
|
3933
4007
|
/**
|
|
@@ -3946,10 +4020,10 @@ class Ut extends A {
|
|
|
3946
4020
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3947
4021
|
*/
|
|
3948
4022
|
_write(t) {
|
|
3949
|
-
t.writeTypeRef(
|
|
4023
|
+
t.writeTypeRef(cl);
|
|
3950
4024
|
}
|
|
3951
4025
|
}
|
|
3952
|
-
const
|
|
4026
|
+
const zc = (e) => new Ut();
|
|
3953
4027
|
class Xe {
|
|
3954
4028
|
/**
|
|
3955
4029
|
* @param {YXmlFragment | YXmlElement} root
|
|
@@ -3975,7 +4049,7 @@ class Xe {
|
|
|
3975
4049
|
if (t !== null && (!this._firstCall || t.deleted || !this._filter(n)))
|
|
3976
4050
|
do
|
|
3977
4051
|
if (n = /** @type {any} */
|
|
3978
|
-
t.content.type, !t.deleted && (n.constructor ===
|
|
4052
|
+
t.content.type, !t.deleted && (n.constructor === Tt || n.constructor === dt) && n._start !== null)
|
|
3979
4053
|
t = n._start;
|
|
3980
4054
|
else
|
|
3981
4055
|
for (; t !== null; )
|
|
@@ -3995,7 +4069,7 @@ class Xe {
|
|
|
3995
4069
|
), done: !1 });
|
|
3996
4070
|
}
|
|
3997
4071
|
}
|
|
3998
|
-
class
|
|
4072
|
+
class dt extends A {
|
|
3999
4073
|
constructor() {
|
|
4000
4074
|
super(), this._prelimContent = [];
|
|
4001
4075
|
}
|
|
@@ -4024,13 +4098,13 @@ class ut extends A {
|
|
|
4024
4098
|
), this._prelimContent = null;
|
|
4025
4099
|
}
|
|
4026
4100
|
_copy() {
|
|
4027
|
-
return new
|
|
4101
|
+
return new dt();
|
|
4028
4102
|
}
|
|
4029
4103
|
/**
|
|
4030
4104
|
* @return {YXmlFragment}
|
|
4031
4105
|
*/
|
|
4032
4106
|
clone() {
|
|
4033
|
-
const t = new
|
|
4107
|
+
const t = new dt();
|
|
4034
4108
|
return t.insert(0, this.toArray().map((n) => n instanceof A ? n.clone() : n)), t;
|
|
4035
4109
|
}
|
|
4036
4110
|
get length() {
|
|
@@ -4088,7 +4162,7 @@ class ut extends A {
|
|
|
4088
4162
|
* @public
|
|
4089
4163
|
*/
|
|
4090
4164
|
querySelectorAll(t) {
|
|
4091
|
-
return t = t.toUpperCase(),
|
|
4165
|
+
return t = t.toUpperCase(), P(new Xe(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
|
|
4092
4166
|
}
|
|
4093
4167
|
/**
|
|
4094
4168
|
* Creates YXmlEvent and calls observers.
|
|
@@ -4097,7 +4171,7 @@ class ut extends A {
|
|
|
4097
4171
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
4098
4172
|
*/
|
|
4099
4173
|
_callObserver(t, n) {
|
|
4100
|
-
Oe(this, t, new
|
|
4174
|
+
Oe(this, t, new Xc(this, n, t));
|
|
4101
4175
|
}
|
|
4102
4176
|
/**
|
|
4103
4177
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -4130,7 +4204,7 @@ class ut extends A {
|
|
|
4130
4204
|
*/
|
|
4131
4205
|
toDOM(t = document, n = {}, s) {
|
|
4132
4206
|
const r = t.createDocumentFragment();
|
|
4133
|
-
return s !== void 0 && s._createAssociation(r, this),
|
|
4207
|
+
return s !== void 0 && s._createAssociation(r, this), Wt(this, (i) => {
|
|
4134
4208
|
r.insertBefore(i.toDOM(t, n, s), null);
|
|
4135
4209
|
}), r;
|
|
4136
4210
|
}
|
|
@@ -4171,7 +4245,7 @@ class ut extends A {
|
|
|
4171
4245
|
this._prelimContent
|
|
4172
4246
|
), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
|
|
4173
4247
|
if (r === 0 && t !== null)
|
|
4174
|
-
throw
|
|
4248
|
+
throw q("Reference item not found");
|
|
4175
4249
|
s.splice(r, 0, ...n);
|
|
4176
4250
|
}
|
|
4177
4251
|
}
|
|
@@ -4235,7 +4309,7 @@ class ut extends A {
|
|
|
4235
4309
|
* @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
|
|
4236
4310
|
*/
|
|
4237
4311
|
forEach(t) {
|
|
4238
|
-
|
|
4312
|
+
Wt(this, t);
|
|
4239
4313
|
}
|
|
4240
4314
|
/**
|
|
4241
4315
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -4246,11 +4320,11 @@ class ut extends A {
|
|
|
4246
4320
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4247
4321
|
*/
|
|
4248
4322
|
_write(t) {
|
|
4249
|
-
t.writeTypeRef(
|
|
4323
|
+
t.writeTypeRef(al);
|
|
4250
4324
|
}
|
|
4251
4325
|
}
|
|
4252
|
-
const Kc = (e) => new
|
|
4253
|
-
class
|
|
4326
|
+
const Kc = (e) => new dt();
|
|
4327
|
+
class Tt extends dt {
|
|
4254
4328
|
constructor(t = "UNDEFINED") {
|
|
4255
4329
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
4256
4330
|
}
|
|
@@ -4298,14 +4372,14 @@ class Wt extends ut {
|
|
|
4298
4372
|
* @return {YXmlElement}
|
|
4299
4373
|
*/
|
|
4300
4374
|
_copy() {
|
|
4301
|
-
return new
|
|
4375
|
+
return new Tt(this.nodeName);
|
|
4302
4376
|
}
|
|
4303
4377
|
/**
|
|
4304
4378
|
* @return {YXmlElement<KV>}
|
|
4305
4379
|
*/
|
|
4306
4380
|
clone() {
|
|
4307
|
-
const t = new
|
|
4308
|
-
return
|
|
4381
|
+
const t = new Tt(this.nodeName), n = this.getAttributes();
|
|
4382
|
+
return no(n, (s, r) => {
|
|
4309
4383
|
typeof s == "string" && t.setAttribute(r, s);
|
|
4310
4384
|
}), t.insert(0, this.toArray().map((s) => s instanceof A ? s.clone() : s)), t;
|
|
4311
4385
|
}
|
|
@@ -4355,7 +4429,7 @@ class Wt extends ut {
|
|
|
4355
4429
|
*/
|
|
4356
4430
|
setAttribute(t, n) {
|
|
4357
4431
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4358
|
-
|
|
4432
|
+
Un(s, this, t, n);
|
|
4359
4433
|
}) : this._prelimAttrs.set(t, n);
|
|
4360
4434
|
}
|
|
4361
4435
|
/**
|
|
@@ -4372,7 +4446,7 @@ class Wt extends ut {
|
|
|
4372
4446
|
getAttribute(t) {
|
|
4373
4447
|
return (
|
|
4374
4448
|
/** @type {any} */
|
|
4375
|
-
|
|
4449
|
+
Tn(this, t)
|
|
4376
4450
|
);
|
|
4377
4451
|
}
|
|
4378
4452
|
/**
|
|
@@ -4400,7 +4474,7 @@ class Wt extends ut {
|
|
|
4400
4474
|
getAttributes(t) {
|
|
4401
4475
|
return (
|
|
4402
4476
|
/** @type {any} */
|
|
4403
|
-
t ?
|
|
4477
|
+
t ? Oc(this, t) : pr(this)
|
|
4404
4478
|
);
|
|
4405
4479
|
}
|
|
4406
4480
|
/**
|
|
@@ -4424,7 +4498,7 @@ class Wt extends ut {
|
|
|
4424
4498
|
const c = i[o];
|
|
4425
4499
|
typeof c == "string" && r.setAttribute(o, c);
|
|
4426
4500
|
}
|
|
4427
|
-
return
|
|
4501
|
+
return Wt(this, (o) => {
|
|
4428
4502
|
r.appendChild(o.toDOM(t, n, s));
|
|
4429
4503
|
}), s !== void 0 && s._createAssociation(r, this), r;
|
|
4430
4504
|
}
|
|
@@ -4437,11 +4511,11 @@ class Wt extends ut {
|
|
|
4437
4511
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4438
4512
|
*/
|
|
4439
4513
|
_write(t) {
|
|
4440
|
-
t.writeTypeRef(
|
|
4514
|
+
t.writeTypeRef(ll), t.writeKey(this.nodeName);
|
|
4441
4515
|
}
|
|
4442
4516
|
}
|
|
4443
|
-
const
|
|
4444
|
-
class
|
|
4517
|
+
const Yc = (e) => new Tt(e.readKey());
|
|
4518
|
+
class Xc extends Ue {
|
|
4445
4519
|
/**
|
|
4446
4520
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
4447
4521
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -4455,7 +4529,7 @@ class Yc extends Ue {
|
|
|
4455
4529
|
});
|
|
4456
4530
|
}
|
|
4457
4531
|
}
|
|
4458
|
-
class De extends
|
|
4532
|
+
class De extends ut {
|
|
4459
4533
|
/**
|
|
4460
4534
|
* @param {string} hookName nodeName of the Dom Node.
|
|
4461
4535
|
*/
|
|
@@ -4506,10 +4580,10 @@ class De extends ht {
|
|
|
4506
4580
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4507
4581
|
*/
|
|
4508
4582
|
_write(t) {
|
|
4509
|
-
t.writeTypeRef(
|
|
4583
|
+
t.writeTypeRef(hl), t.writeKey(this.hookName);
|
|
4510
4584
|
}
|
|
4511
4585
|
}
|
|
4512
|
-
const
|
|
4586
|
+
const Jc = (e) => new De(e.readKey());
|
|
4513
4587
|
class Ee extends Ut {
|
|
4514
4588
|
/**
|
|
4515
4589
|
* @type {YXmlElement|YXmlText|null}
|
|
@@ -4598,11 +4672,11 @@ class Ee extends Ut {
|
|
|
4598
4672
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4599
4673
|
*/
|
|
4600
4674
|
_write(t) {
|
|
4601
|
-
t.writeTypeRef(
|
|
4675
|
+
t.writeTypeRef(ul);
|
|
4602
4676
|
}
|
|
4603
4677
|
}
|
|
4604
|
-
const
|
|
4605
|
-
class
|
|
4678
|
+
const Wc = (e) => new Ee();
|
|
4679
|
+
class On {
|
|
4606
4680
|
/**
|
|
4607
4681
|
* @param {ID} id
|
|
4608
4682
|
* @param {number} length
|
|
@@ -4642,8 +4716,8 @@ class Rn {
|
|
|
4642
4716
|
throw H();
|
|
4643
4717
|
}
|
|
4644
4718
|
}
|
|
4645
|
-
const
|
|
4646
|
-
class
|
|
4719
|
+
const Pc = 0;
|
|
4720
|
+
class T extends On {
|
|
4647
4721
|
get deleted() {
|
|
4648
4722
|
return !0;
|
|
4649
4723
|
}
|
|
@@ -4668,7 +4742,7 @@ class U extends Rn {
|
|
|
4668
4742
|
* @param {number} offset
|
|
4669
4743
|
*/
|
|
4670
4744
|
write(t, n) {
|
|
4671
|
-
t.writeInfo(
|
|
4745
|
+
t.writeInfo(Pc), t.writeLen(this.length - n);
|
|
4672
4746
|
}
|
|
4673
4747
|
/**
|
|
4674
4748
|
* @param {Transaction} transaction
|
|
@@ -4754,7 +4828,7 @@ class ee {
|
|
|
4754
4828
|
return 3;
|
|
4755
4829
|
}
|
|
4756
4830
|
}
|
|
4757
|
-
const
|
|
4831
|
+
const Gc = (e) => new ee(e.readBuf());
|
|
4758
4832
|
class Pt {
|
|
4759
4833
|
/**
|
|
4760
4834
|
* @param {number} len
|
|
@@ -4832,7 +4906,7 @@ class Pt {
|
|
|
4832
4906
|
return 1;
|
|
4833
4907
|
}
|
|
4834
4908
|
}
|
|
4835
|
-
const
|
|
4909
|
+
const qc = (e) => new Pt(e.readLen()), _r = (e, t) => new mt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
4836
4910
|
class ne {
|
|
4837
4911
|
/**
|
|
4838
4912
|
* @param {Doc} doc
|
|
@@ -4912,8 +4986,8 @@ class ne {
|
|
|
4912
4986
|
return 9;
|
|
4913
4987
|
}
|
|
4914
4988
|
}
|
|
4915
|
-
const
|
|
4916
|
-
class
|
|
4989
|
+
const Zc = (e) => new ne(_r(e.readString(), e.readAny()));
|
|
4990
|
+
class yt {
|
|
4917
4991
|
/**
|
|
4918
4992
|
* @param {Object} embed
|
|
4919
4993
|
*/
|
|
@@ -4942,7 +5016,7 @@ class mt {
|
|
|
4942
5016
|
* @return {ContentEmbed}
|
|
4943
5017
|
*/
|
|
4944
5018
|
copy() {
|
|
4945
|
-
return new
|
|
5019
|
+
return new yt(this.embed);
|
|
4946
5020
|
}
|
|
4947
5021
|
/**
|
|
4948
5022
|
* @param {number} offset
|
|
@@ -4988,7 +5062,7 @@ class mt {
|
|
|
4988
5062
|
return 5;
|
|
4989
5063
|
}
|
|
4990
5064
|
}
|
|
4991
|
-
const
|
|
5065
|
+
const Qc = (e) => new yt(e.readJSON());
|
|
4992
5066
|
class D {
|
|
4993
5067
|
/**
|
|
4994
5068
|
* @param {string} key
|
|
@@ -5070,7 +5144,7 @@ class D {
|
|
|
5070
5144
|
return 6;
|
|
5071
5145
|
}
|
|
5072
5146
|
}
|
|
5073
|
-
const
|
|
5147
|
+
const tl = (e) => new D(e.readKey(), e.readJSON());
|
|
5074
5148
|
class Ce {
|
|
5075
5149
|
/**
|
|
5076
5150
|
* @param {Array<any>} arr
|
|
@@ -5152,7 +5226,7 @@ class Ce {
|
|
|
5152
5226
|
return 2;
|
|
5153
5227
|
}
|
|
5154
5228
|
}
|
|
5155
|
-
const
|
|
5229
|
+
const el = (e) => {
|
|
5156
5230
|
const t = e.readLen(), n = [];
|
|
5157
5231
|
for (let s = 0; s < t; s++) {
|
|
5158
5232
|
const r = e.readString();
|
|
@@ -5160,7 +5234,7 @@ const tl = (e) => {
|
|
|
5160
5234
|
}
|
|
5161
5235
|
return new Ce(n);
|
|
5162
5236
|
};
|
|
5163
|
-
class
|
|
5237
|
+
class ft {
|
|
5164
5238
|
/**
|
|
5165
5239
|
* @param {Array<any>} arr
|
|
5166
5240
|
*/
|
|
@@ -5189,14 +5263,14 @@ class dt {
|
|
|
5189
5263
|
* @return {ContentAny}
|
|
5190
5264
|
*/
|
|
5191
5265
|
copy() {
|
|
5192
|
-
return new
|
|
5266
|
+
return new ft(this.arr);
|
|
5193
5267
|
}
|
|
5194
5268
|
/**
|
|
5195
5269
|
* @param {number} offset
|
|
5196
5270
|
* @return {ContentAny}
|
|
5197
5271
|
*/
|
|
5198
5272
|
splice(t) {
|
|
5199
|
-
const n = new
|
|
5273
|
+
const n = new ft(this.arr.slice(t));
|
|
5200
5274
|
return this.arr = this.arr.slice(0, t), n;
|
|
5201
5275
|
}
|
|
5202
5276
|
/**
|
|
@@ -5241,13 +5315,13 @@ class dt {
|
|
|
5241
5315
|
return 8;
|
|
5242
5316
|
}
|
|
5243
5317
|
}
|
|
5244
|
-
const
|
|
5318
|
+
const nl = (e) => {
|
|
5245
5319
|
const t = e.readLen(), n = [];
|
|
5246
5320
|
for (let s = 0; s < t; s++)
|
|
5247
5321
|
n.push(e.readAny());
|
|
5248
|
-
return new
|
|
5322
|
+
return new ft(n);
|
|
5249
5323
|
};
|
|
5250
|
-
class
|
|
5324
|
+
class K {
|
|
5251
5325
|
/**
|
|
5252
5326
|
* @param {string} str
|
|
5253
5327
|
*/
|
|
@@ -5276,14 +5350,14 @@ class z {
|
|
|
5276
5350
|
* @return {ContentString}
|
|
5277
5351
|
*/
|
|
5278
5352
|
copy() {
|
|
5279
|
-
return new
|
|
5353
|
+
return new K(this.str);
|
|
5280
5354
|
}
|
|
5281
5355
|
/**
|
|
5282
5356
|
* @param {number} offset
|
|
5283
5357
|
* @return {ContentString}
|
|
5284
5358
|
*/
|
|
5285
5359
|
splice(t) {
|
|
5286
|
-
const n = new
|
|
5360
|
+
const n = new K(this.str.slice(t));
|
|
5287
5361
|
this.str = this.str.slice(0, t);
|
|
5288
5362
|
const s = this.str.charCodeAt(t - 1);
|
|
5289
5363
|
return s >= 55296 && s <= 56319 && (this.str = this.str.slice(0, t - 1) + "�", n.str = "�" + n.str.slice(1)), n;
|
|
@@ -5325,16 +5399,16 @@ class z {
|
|
|
5325
5399
|
return 4;
|
|
5326
5400
|
}
|
|
5327
5401
|
}
|
|
5328
|
-
const
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
jc,
|
|
5402
|
+
const sl = (e) => new K(e.readString()), rl = [
|
|
5403
|
+
$c,
|
|
5404
|
+
Bc,
|
|
5332
5405
|
zc,
|
|
5406
|
+
Yc,
|
|
5333
5407
|
Kc,
|
|
5334
|
-
|
|
5335
|
-
|
|
5336
|
-
],
|
|
5337
|
-
class
|
|
5408
|
+
Jc,
|
|
5409
|
+
Wc
|
|
5410
|
+
], il = 0, ol = 1, cl = 2, ll = 3, al = 4, hl = 5, ul = 6;
|
|
5411
|
+
class tt {
|
|
5338
5412
|
/**
|
|
5339
5413
|
* @param {AbstractType<any>} type
|
|
5340
5414
|
*/
|
|
@@ -5363,7 +5437,7 @@ class Z {
|
|
|
5363
5437
|
* @return {ContentType}
|
|
5364
5438
|
*/
|
|
5365
5439
|
copy() {
|
|
5366
|
-
return new
|
|
5440
|
+
return new tt(this.type._copy());
|
|
5367
5441
|
}
|
|
5368
5442
|
/**
|
|
5369
5443
|
* @param {number} offset
|
|
@@ -5426,7 +5500,7 @@ class Z {
|
|
|
5426
5500
|
return 7;
|
|
5427
5501
|
}
|
|
5428
5502
|
}
|
|
5429
|
-
const
|
|
5503
|
+
const dl = (e) => new tt(rl[e.readTypeRef()](e)), Ae = (e, t, n) => {
|
|
5430
5504
|
const { client: s, clock: r } = t.id, i = new k(
|
|
5431
5505
|
b(s, r + n),
|
|
5432
5506
|
t,
|
|
@@ -5439,7 +5513,7 @@ const ul = (e) => new Z(sl[e.readTypeRef()](e)), Ae = (e, t, n) => {
|
|
|
5439
5513
|
);
|
|
5440
5514
|
return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = b(t.redone.client, t.redone.clock + n)), t.right = i, i.right !== null && (i.right.left = i), e._mergeStructs.push(i), i.parentSub !== null && i.right === null && i.parent._map.set(i.parentSub, i), t.length = n, i;
|
|
5441
5515
|
};
|
|
5442
|
-
class k extends
|
|
5516
|
+
class k extends On {
|
|
5443
5517
|
/**
|
|
5444
5518
|
* @param {ID} id
|
|
5445
5519
|
* @param {Item | null} left
|
|
@@ -5451,7 +5525,7 @@ class k extends Rn {
|
|
|
5451
5525
|
* @param {AbstractContent} content
|
|
5452
5526
|
*/
|
|
5453
5527
|
constructor(t, n, s, r, i, o, c, l) {
|
|
5454
|
-
super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ?
|
|
5528
|
+
super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ? Gn : 0;
|
|
5455
5529
|
}
|
|
5456
5530
|
/**
|
|
5457
5531
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5468,13 +5542,13 @@ class k extends Rn {
|
|
|
5468
5542
|
* If true, do not garbage collect this Item.
|
|
5469
5543
|
*/
|
|
5470
5544
|
get keep() {
|
|
5471
|
-
return (this.info &
|
|
5545
|
+
return (this.info & Pn) > 0;
|
|
5472
5546
|
}
|
|
5473
5547
|
set keep(t) {
|
|
5474
|
-
this.keep !== t && (this.info ^=
|
|
5548
|
+
this.keep !== t && (this.info ^= Pn);
|
|
5475
5549
|
}
|
|
5476
5550
|
get countable() {
|
|
5477
|
-
return (this.info &
|
|
5551
|
+
return (this.info & Gn) > 0;
|
|
5478
5552
|
}
|
|
5479
5553
|
/**
|
|
5480
5554
|
* Whether this item was deleted or not.
|
|
@@ -5501,15 +5575,15 @@ class k extends Rn {
|
|
|
5501
5575
|
return this.origin.client;
|
|
5502
5576
|
if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= C(n, this.rightOrigin.client))
|
|
5503
5577
|
return this.rightOrigin.client;
|
|
5504
|
-
if (this.parent && this.parent.constructor ===
|
|
5578
|
+
if (this.parent && this.parent.constructor === Et && this.id.client !== this.parent.client && this.parent.clock >= C(n, this.parent.client))
|
|
5505
5579
|
return this.parent.client;
|
|
5506
|
-
if (this.origin && (this.left =
|
|
5580
|
+
if (this.origin && (this.left = os(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = rt(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === T || this.right && this.right.constructor === T)
|
|
5507
5581
|
this.parent = null;
|
|
5508
5582
|
else if (!this.parent)
|
|
5509
5583
|
this.left && this.left.constructor === k && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === k && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
|
|
5510
|
-
else if (this.parent.constructor ===
|
|
5511
|
-
const s =
|
|
5512
|
-
s.constructor ===
|
|
5584
|
+
else if (this.parent.constructor === Et) {
|
|
5585
|
+
const s = Ke(n, this.parent);
|
|
5586
|
+
s.constructor === T ? this.parent = null : this.parent = /** @type {ContentType} */
|
|
5513
5587
|
s.content.type;
|
|
5514
5588
|
}
|
|
5515
5589
|
return null;
|
|
@@ -5519,7 +5593,7 @@ class k extends Rn {
|
|
|
5519
5593
|
* @param {number} offset
|
|
5520
5594
|
*/
|
|
5521
5595
|
integrate(t, n) {
|
|
5522
|
-
if (n > 0 && (this.id.clock += n, this.left =
|
|
5596
|
+
if (n > 0 && (this.id.clock += n, this.left = os(t, t.doc.store, b(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(n), this.length -= n), this.parent) {
|
|
5523
5597
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5524
5598
|
let s = this.left, r;
|
|
5525
5599
|
if (s !== null)
|
|
@@ -5538,8 +5612,8 @@ class k extends Rn {
|
|
|
5538
5612
|
s = r, i.clear();
|
|
5539
5613
|
else if (ce(this.rightOrigin, r.rightOrigin))
|
|
5540
5614
|
break;
|
|
5541
|
-
} else if (r.origin !== null && o.has(
|
|
5542
|
-
i.has(
|
|
5615
|
+
} else if (r.origin !== null && o.has(Ke(t.doc.store, r.origin)))
|
|
5616
|
+
i.has(Ke(t.doc.store, r.origin)) || (s = r, i.clear());
|
|
5543
5617
|
else
|
|
5544
5618
|
break;
|
|
5545
5619
|
r = r.right;
|
|
@@ -5560,7 +5634,7 @@ class k extends Rn {
|
|
|
5560
5634
|
this.parent._start, this.parent._start = this;
|
|
5561
5635
|
this.right = s;
|
|
5562
5636
|
}
|
|
5563
|
-
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), nr(t.doc.store, this), this.content.integrate(t, this),
|
|
5637
|
+
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), nr(t.doc.store, this), this.content.integrate(t, this), ls(
|
|
5564
5638
|
t,
|
|
5565
5639
|
/** @type {AbstractType<any>} */
|
|
5566
5640
|
this.parent,
|
|
@@ -5569,7 +5643,7 @@ class k extends Rn {
|
|
|
5569
5643
|
(this.parent._item !== null && /** @type {AbstractType<any>} */
|
|
5570
5644
|
this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(t);
|
|
5571
5645
|
} else
|
|
5572
|
-
new
|
|
5646
|
+
new T(this.id, this.length).integrate(t, 0);
|
|
5573
5647
|
}
|
|
5574
5648
|
/**
|
|
5575
5649
|
* Returns the next non-deleted item
|
|
@@ -5624,7 +5698,7 @@ class k extends Rn {
|
|
|
5624
5698
|
/** @type {AbstractType<any>} */
|
|
5625
5699
|
this.parent
|
|
5626
5700
|
);
|
|
5627
|
-
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), be(t.deleteSet, this.id.client, this.id.clock, this.length),
|
|
5701
|
+
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), be(t.deleteSet, this.id.client, this.id.clock, this.length), ls(t, n, this.parentSub), this.content.delete(t);
|
|
5628
5702
|
}
|
|
5629
5703
|
}
|
|
5630
5704
|
/**
|
|
@@ -5634,7 +5708,7 @@ class k extends Rn {
|
|
|
5634
5708
|
gc(t, n) {
|
|
5635
5709
|
if (!this.deleted)
|
|
5636
5710
|
throw j();
|
|
5637
|
-
this.content.gc(t), n ?
|
|
5711
|
+
this.content.gc(t), n ? yc(t, this, new T(this.id, this.length)) : this.content = new Pt(this.length);
|
|
5638
5712
|
}
|
|
5639
5713
|
/**
|
|
5640
5714
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -5646,7 +5720,7 @@ class k extends Rn {
|
|
|
5646
5720
|
* @param {number} offset
|
|
5647
5721
|
*/
|
|
5648
5722
|
write(t, n) {
|
|
5649
|
-
const s = n > 0 ? b(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Ie | (s === null ? 0 :
|
|
5723
|
+
const s = n > 0 ? b(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Ie | (s === null ? 0 : x) | // origin is defined
|
|
5650
5724
|
(r === null ? 0 : J) | // right origin is defined
|
|
5651
5725
|
(i === null ? 0 : Kt);
|
|
5652
5726
|
if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
|
|
@@ -5657,46 +5731,46 @@ class k extends Rn {
|
|
|
5657
5731
|
if (c._item !== void 0) {
|
|
5658
5732
|
const l = c._item;
|
|
5659
5733
|
if (l === null) {
|
|
5660
|
-
const a =
|
|
5734
|
+
const a = wc(c);
|
|
5661
5735
|
t.writeParentInfo(!0), t.writeString(a);
|
|
5662
5736
|
} else
|
|
5663
5737
|
t.writeParentInfo(!1), t.writeLeftID(l.id);
|
|
5664
5738
|
} else
|
|
5665
|
-
c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor ===
|
|
5739
|
+
c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor === Et ? (t.writeParentInfo(!1), t.writeLeftID(c)) : j();
|
|
5666
5740
|
i !== null && t.writeString(i);
|
|
5667
5741
|
}
|
|
5668
5742
|
this.content.write(t, n);
|
|
5669
5743
|
}
|
|
5670
5744
|
}
|
|
5671
|
-
const kr = (e, t) =>
|
|
5745
|
+
const kr = (e, t) => fl[t & Ie](e), fl = [
|
|
5672
5746
|
() => {
|
|
5673
5747
|
j();
|
|
5674
5748
|
},
|
|
5675
5749
|
// GC is not ItemContent
|
|
5676
|
-
|
|
5750
|
+
qc,
|
|
5677
5751
|
// 1
|
|
5678
|
-
|
|
5752
|
+
el,
|
|
5679
5753
|
// 2
|
|
5680
|
-
|
|
5754
|
+
Gc,
|
|
5681
5755
|
// 3
|
|
5682
|
-
|
|
5756
|
+
sl,
|
|
5683
5757
|
// 4
|
|
5684
|
-
Zc,
|
|
5685
|
-
// 5
|
|
5686
5758
|
Qc,
|
|
5759
|
+
// 5
|
|
5760
|
+
tl,
|
|
5687
5761
|
// 6
|
|
5688
|
-
|
|
5762
|
+
dl,
|
|
5689
5763
|
// 7
|
|
5690
|
-
|
|
5764
|
+
nl,
|
|
5691
5765
|
// 8
|
|
5692
|
-
|
|
5766
|
+
Zc,
|
|
5693
5767
|
// 9
|
|
5694
5768
|
() => {
|
|
5695
5769
|
j();
|
|
5696
5770
|
}
|
|
5697
5771
|
// 10 - Skip is not ItemContent
|
|
5698
|
-
],
|
|
5699
|
-
class
|
|
5772
|
+
], gl = 10;
|
|
5773
|
+
class O extends On {
|
|
5700
5774
|
get deleted() {
|
|
5701
5775
|
return !0;
|
|
5702
5776
|
}
|
|
@@ -5721,7 +5795,7 @@ class T extends Rn {
|
|
|
5721
5795
|
* @param {number} offset
|
|
5722
5796
|
*/
|
|
5723
5797
|
write(t, n) {
|
|
5724
|
-
t.writeInfo(
|
|
5798
|
+
t.writeInfo(gl), m(t.restEncoder, this.length - n);
|
|
5725
5799
|
}
|
|
5726
5800
|
/**
|
|
5727
5801
|
* @param {Transaction} transaction
|
|
@@ -5738,13 +5812,13 @@ const Dr = (
|
|
|
5738
5812
|
), Er = "__ $YJS$ __";
|
|
5739
5813
|
Dr[Er] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5740
5814
|
Dr[Er] = !0;
|
|
5741
|
-
const
|
|
5815
|
+
const pl = 0, wl = (e, t, n) => {
|
|
5742
5816
|
switch (w(e)) {
|
|
5743
|
-
case
|
|
5744
|
-
n(t,
|
|
5817
|
+
case pl:
|
|
5818
|
+
n(t, st(e));
|
|
5745
5819
|
}
|
|
5746
5820
|
}, Je = 3e4;
|
|
5747
|
-
class
|
|
5821
|
+
class ml extends vs {
|
|
5748
5822
|
/**
|
|
5749
5823
|
* @param {Y.Doc} doc
|
|
5750
5824
|
*/
|
|
@@ -5757,8 +5831,8 @@ class wl extends mn {
|
|
|
5757
5831
|
const s = [];
|
|
5758
5832
|
this.meta.forEach((r, i) => {
|
|
5759
5833
|
i !== this.clientID && Je <= n - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
5760
|
-
}), s.length > 0 &&
|
|
5761
|
-
},
|
|
5834
|
+
}), s.length > 0 && Rn(this, s, "timeout");
|
|
5835
|
+
}, G(Je / 10)), t.on("destroy", () => {
|
|
5762
5836
|
this.destroy();
|
|
5763
5837
|
}), this.setLocalState({});
|
|
5764
5838
|
}
|
|
@@ -5781,7 +5855,7 @@ class wl extends mn {
|
|
|
5781
5855
|
lastUpdated: ye()
|
|
5782
5856
|
});
|
|
5783
5857
|
const o = [], c = [], l = [], a = [];
|
|
5784
|
-
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n),
|
|
5858
|
+
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n), Vt(i, t) || l.push(n)), (o.length > 0 || l.length > 0 || a.length > 0) && this.emit("change", [{ added: o, updated: l, removed: a }, "local"]), this.emit("update", [{ added: o, updated: c, removed: a }, "local"]);
|
|
5785
5859
|
}
|
|
5786
5860
|
/**
|
|
5787
5861
|
* @param {string} field
|
|
@@ -5801,7 +5875,7 @@ class wl extends mn {
|
|
|
5801
5875
|
return this.states;
|
|
5802
5876
|
}
|
|
5803
5877
|
}
|
|
5804
|
-
const
|
|
5878
|
+
const Rn = (e, t, n) => {
|
|
5805
5879
|
const s = [];
|
|
5806
5880
|
for (let r = 0; r < t.length; r++) {
|
|
5807
5881
|
const i = t[r];
|
|
@@ -5820,7 +5894,7 @@ const $n = (e, t, n) => {
|
|
|
5820
5894
|
}
|
|
5821
5895
|
}
|
|
5822
5896
|
s.length > 0 && (e.emit("change", [{ added: [], updated: [], removed: s }, n]), e.emit("update", [{ added: [], updated: [], removed: s }, n]));
|
|
5823
|
-
},
|
|
5897
|
+
}, Ft = (e, t, n = e.states) => {
|
|
5824
5898
|
const s = t.length, r = Zt();
|
|
5825
5899
|
m(r, s);
|
|
5826
5900
|
for (let i = 0; i < s; i++) {
|
|
@@ -5830,17 +5904,17 @@ const $n = (e, t, n) => {
|
|
|
5830
5904
|
);
|
|
5831
5905
|
m(r, o), m(r, l), lt(r, JSON.stringify(c));
|
|
5832
5906
|
}
|
|
5833
|
-
return
|
|
5834
|
-
},
|
|
5835
|
-
const s =
|
|
5907
|
+
return N(r);
|
|
5908
|
+
}, yl = (e, t, n) => {
|
|
5909
|
+
const s = wt(t), r = ye(), i = [], o = [], c = [], l = [], a = w(s);
|
|
5836
5910
|
for (let h = 0; h < a; h++) {
|
|
5837
5911
|
const d = w(s);
|
|
5838
5912
|
let u = w(s);
|
|
5839
|
-
const f = JSON.parse(
|
|
5913
|
+
const f = JSON.parse(st(s)), g = e.meta.get(d), p = e.states.get(d), _ = g === void 0 ? 0 : g.clock;
|
|
5840
5914
|
(_ < u || _ === u && f === null && e.states.has(d)) && (f === null ? d === e.clientID && e.getLocalState() != null ? u++ : e.states.delete(d) : e.states.set(d, f), e.meta.set(d, {
|
|
5841
5915
|
clock: u,
|
|
5842
5916
|
lastUpdated: r
|
|
5843
|
-
}), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (
|
|
5917
|
+
}), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (Vt(f, p) || c.push(d), o.push(d)));
|
|
5844
5918
|
}
|
|
5845
5919
|
(i.length > 0 || c.length > 0 || l.length > 0) && e.emit("change", [{
|
|
5846
5920
|
added: i,
|
|
@@ -5851,83 +5925,83 @@ const $n = (e, t, n) => {
|
|
|
5851
5925
|
updated: o,
|
|
5852
5926
|
removed: l
|
|
5853
5927
|
}, n]);
|
|
5854
|
-
}, Cr = 0,
|
|
5928
|
+
}, Cr = 0, $n = 1, Ar = 2, hn = (e, t) => {
|
|
5855
5929
|
m(e, Cr);
|
|
5856
|
-
const n =
|
|
5930
|
+
const n = gc(t);
|
|
5857
5931
|
L(e, n);
|
|
5858
5932
|
}, Lr = (e, t, n) => {
|
|
5859
|
-
m(e,
|
|
5860
|
-
},
|
|
5933
|
+
m(e, $n), L(e, Ln(t, n));
|
|
5934
|
+
}, bl = (e, t, n) => Lr(t, n, I(e)), Ir = (e, t, n) => {
|
|
5861
5935
|
try {
|
|
5862
5936
|
qs(t, I(e), n);
|
|
5863
5937
|
} catch (s) {
|
|
5864
5938
|
console.error("Caught error while handling a Yjs update", s);
|
|
5865
5939
|
}
|
|
5866
|
-
},
|
|
5940
|
+
}, Sl = (e, t) => {
|
|
5867
5941
|
m(e, Ar), L(e, t);
|
|
5868
|
-
},
|
|
5942
|
+
}, _l = Ir, kl = (e, t, n, s) => {
|
|
5869
5943
|
const r = w(e);
|
|
5870
5944
|
switch (r) {
|
|
5871
5945
|
case Cr:
|
|
5872
|
-
|
|
5946
|
+
bl(e, t, n);
|
|
5873
5947
|
break;
|
|
5874
|
-
case
|
|
5948
|
+
case $n:
|
|
5875
5949
|
Ir(e, n, s);
|
|
5876
5950
|
break;
|
|
5877
5951
|
case Ar:
|
|
5878
|
-
|
|
5952
|
+
_l(e, n, s);
|
|
5879
5953
|
break;
|
|
5880
5954
|
default:
|
|
5881
5955
|
throw new Error("Unknown message type");
|
|
5882
5956
|
}
|
|
5883
5957
|
return r;
|
|
5884
5958
|
};
|
|
5885
|
-
var it = 0, vr = 3,
|
|
5886
|
-
function
|
|
5959
|
+
var it = 0, vr = 3, At = 1, Dl = 2, El = typeof window > "u";
|
|
5960
|
+
function Cl(e, t) {
|
|
5887
5961
|
if (!e)
|
|
5888
5962
|
throw new Error(t);
|
|
5889
5963
|
}
|
|
5890
5964
|
var se = [];
|
|
5891
5965
|
se[it] = (e, t, n, s, r) => {
|
|
5892
5966
|
v(e, it);
|
|
5893
|
-
const i =
|
|
5967
|
+
const i = kl(
|
|
5894
5968
|
t,
|
|
5895
5969
|
e,
|
|
5896
5970
|
n.doc,
|
|
5897
5971
|
n
|
|
5898
5972
|
);
|
|
5899
|
-
s && i ===
|
|
5973
|
+
s && i === $n && !n.synced && (n.synced = !0);
|
|
5900
5974
|
};
|
|
5901
5975
|
se[vr] = (e, t, n, s, r) => {
|
|
5902
|
-
v(e,
|
|
5976
|
+
v(e, At), Dt(
|
|
5903
5977
|
e,
|
|
5904
|
-
|
|
5978
|
+
Ft(
|
|
5905
5979
|
n.awareness,
|
|
5906
5980
|
Array.from(n.awareness.getStates().keys())
|
|
5907
5981
|
)
|
|
5908
5982
|
);
|
|
5909
5983
|
};
|
|
5910
|
-
se[
|
|
5911
|
-
|
|
5984
|
+
se[At] = (e, t, n, s, r) => {
|
|
5985
|
+
yl(
|
|
5912
5986
|
n.awareness,
|
|
5913
5987
|
Di(t),
|
|
5914
5988
|
n
|
|
5915
5989
|
);
|
|
5916
5990
|
};
|
|
5917
|
-
se[
|
|
5918
|
-
|
|
5991
|
+
se[Dl] = (e, t, n, s, r) => {
|
|
5992
|
+
wl(
|
|
5919
5993
|
t,
|
|
5920
5994
|
n.doc,
|
|
5921
|
-
(i, o) =>
|
|
5995
|
+
(i, o) => Al(n, o)
|
|
5922
5996
|
);
|
|
5923
5997
|
};
|
|
5924
|
-
var
|
|
5925
|
-
function
|
|
5998
|
+
var fs = 3e4;
|
|
5999
|
+
function Al(e, t) {
|
|
5926
6000
|
console.warn(`Permission denied to access ${e.url}.
|
|
5927
6001
|
${t}`);
|
|
5928
6002
|
}
|
|
5929
6003
|
function Mr(e, t, n) {
|
|
5930
|
-
const s = _i(t), r =
|
|
6004
|
+
const s = _i(t), r = $(), i = Ls(s), o = e.messageHandlers[i];
|
|
5931
6005
|
return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
|
|
5932
6006
|
}
|
|
5933
6007
|
function xr(e) {
|
|
@@ -5937,16 +6011,16 @@ function xr(e) {
|
|
|
5937
6011
|
"No WebSocket implementation available, did you forget to pass options.WebSocketPolyfill?"
|
|
5938
6012
|
);
|
|
5939
6013
|
const t = new e._WS(e.url);
|
|
5940
|
-
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.
|
|
6014
|
+
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.addEventListener("message", (n) => {
|
|
5941
6015
|
if (typeof n.data == "string")
|
|
5942
6016
|
return;
|
|
5943
6017
|
e.wsLastMessageReceived = Qe();
|
|
5944
6018
|
const s = Mr(e, new Uint8Array(n.data), !0);
|
|
5945
|
-
pn(s) > 1 &&
|
|
5946
|
-
}, t.
|
|
6019
|
+
pn(s) > 1 && Nt(U(s), t);
|
|
6020
|
+
}), t.addEventListener("error", (n) => {
|
|
5947
6021
|
e.emit("connection-error", [n, e]);
|
|
5948
|
-
}, t.
|
|
5949
|
-
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1,
|
|
6022
|
+
}), t.addEventListener("close", (n) => {
|
|
6023
|
+
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, Rn(
|
|
5950
6024
|
e.awareness,
|
|
5951
6025
|
Array.from(e.awareness.getStates().keys()).filter(
|
|
5952
6026
|
(s) => s !== e.doc.clientID
|
|
@@ -5958,29 +6032,29 @@ function xr(e) {
|
|
|
5958
6032
|
}
|
|
5959
6033
|
])) : e.wsUnsuccessfulReconnects++, setTimeout(
|
|
5960
6034
|
xr,
|
|
5961
|
-
|
|
6035
|
+
Es(
|
|
5962
6036
|
ui(2, e.wsUnsuccessfulReconnects) * 100,
|
|
5963
6037
|
e.maxBackoffTime
|
|
5964
6038
|
),
|
|
5965
6039
|
e
|
|
5966
6040
|
);
|
|
5967
|
-
}, t.
|
|
6041
|
+
}), t.addEventListener("open", () => {
|
|
5968
6042
|
e.wsLastMessageReceived = Qe(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [
|
|
5969
6043
|
{
|
|
5970
6044
|
status: "connected"
|
|
5971
6045
|
}
|
|
5972
6046
|
]);
|
|
5973
|
-
const n =
|
|
5974
|
-
if (v(n, it), hn(n, e.doc),
|
|
5975
|
-
const s =
|
|
5976
|
-
v(s,
|
|
6047
|
+
const n = $();
|
|
6048
|
+
if (v(n, it), hn(n, e.doc), Nt(U(n), t), e.awareness.getLocalState() !== null) {
|
|
6049
|
+
const s = $();
|
|
6050
|
+
v(s, At), Dt(
|
|
5977
6051
|
s,
|
|
5978
|
-
|
|
6052
|
+
Ft(e.awareness, [
|
|
5979
6053
|
e.doc.clientID
|
|
5980
6054
|
])
|
|
5981
|
-
),
|
|
6055
|
+
), Nt(U(s), t);
|
|
5982
6056
|
}
|
|
5983
|
-
}, e.emit("status", [
|
|
6057
|
+
}), e.emit("status", [
|
|
5984
6058
|
{
|
|
5985
6059
|
status: "connecting"
|
|
5986
6060
|
}
|
|
@@ -5989,20 +6063,20 @@ function xr(e) {
|
|
|
5989
6063
|
}
|
|
5990
6064
|
function We(e, t) {
|
|
5991
6065
|
const n = e.ws;
|
|
5992
|
-
e.wsconnected && n && n.readyState === n.OPEN &&
|
|
6066
|
+
e.wsconnected && n && n.readyState === n.OPEN && Nt(t, n), e.bcconnected && St(e.bcChannel, t, e);
|
|
5993
6067
|
}
|
|
5994
|
-
var
|
|
6068
|
+
var Ll = typeof WebSocket > "u" ? null : WebSocket, Il = class extends Ni {
|
|
5995
6069
|
constructor(t, n, s, {
|
|
5996
6070
|
connect: r = !0,
|
|
5997
|
-
awareness: i = new
|
|
6071
|
+
awareness: i = new ml(s),
|
|
5998
6072
|
params: o = {},
|
|
5999
|
-
WebSocketPolyfill: c =
|
|
6073
|
+
WebSocketPolyfill: c = Ll,
|
|
6000
6074
|
// Optionally provide a WebSocket polyfill
|
|
6001
6075
|
resyncInterval: l = -1,
|
|
6002
6076
|
// Request server state every `resyncInterval` milliseconds
|
|
6003
6077
|
maxBackoffTime: a = 2500,
|
|
6004
6078
|
// Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
6005
|
-
disableBc: h =
|
|
6079
|
+
disableBc: h = El
|
|
6006
6080
|
// Disable cross-tab BroadcastChannel communication
|
|
6007
6081
|
} = {}) {
|
|
6008
6082
|
super();
|
|
@@ -6036,35 +6110,35 @@ var Al = typeof WebSocket > "u" ? null : WebSocket, Ll = class extends Ni {
|
|
|
6036
6110
|
this.maxBackoffTime = a, this.bcChannel = t + "/" + n, this.url = t + "/" + n + (d.length === 0 ? "" : "?" + d), this.roomname = n, this.doc = s, this._WS = c, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = se.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, l > 0 && (this._resyncInterval = /** @type {any} */
|
|
6037
6111
|
setInterval(() => {
|
|
6038
6112
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
6039
|
-
const u =
|
|
6040
|
-
v(u, it), hn(u, s),
|
|
6113
|
+
const u = $();
|
|
6114
|
+
v(u, it), hn(u, s), Nt(U(u), this.ws);
|
|
6041
6115
|
}
|
|
6042
6116
|
}, l)), this._bcSubscriber = (u, f) => {
|
|
6043
6117
|
if (f !== this) {
|
|
6044
6118
|
const g = Mr(this, new Uint8Array(u), !1);
|
|
6045
|
-
pn(g) > 1 &&
|
|
6119
|
+
pn(g) > 1 && St(this.bcChannel, U(g), this);
|
|
6046
6120
|
}
|
|
6047
6121
|
}, this._updateHandler = (u, f) => {
|
|
6048
6122
|
if (f !== this) {
|
|
6049
|
-
const g =
|
|
6050
|
-
v(g, it),
|
|
6123
|
+
const g = $();
|
|
6124
|
+
v(g, it), Sl(g, u), We(this, U(g));
|
|
6051
6125
|
}
|
|
6052
6126
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: u, updated: f, removed: g }, p) => {
|
|
6053
|
-
const _ = u.concat(f).concat(g), Y =
|
|
6054
|
-
v(Y,
|
|
6127
|
+
const _ = u.concat(f).concat(g), Y = $();
|
|
6128
|
+
v(Y, At), Dt(
|
|
6055
6129
|
Y,
|
|
6056
|
-
|
|
6057
|
-
), We(this,
|
|
6130
|
+
Ft(i, _)
|
|
6131
|
+
), We(this, U(Y));
|
|
6058
6132
|
}, this._unloadHandler = () => {
|
|
6059
|
-
|
|
6133
|
+
Rn(
|
|
6060
6134
|
this.awareness,
|
|
6061
6135
|
[s.clientID],
|
|
6062
6136
|
"window unload"
|
|
6063
6137
|
);
|
|
6064
6138
|
}, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && typeof process.on == "function" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
|
|
6065
6139
|
setInterval(() => {
|
|
6066
|
-
this.wsconnected &&
|
|
6067
|
-
},
|
|
6140
|
+
this.wsconnected && fs < Qe() - this.wsLastMessageReceived && (Cl(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
6141
|
+
}, fs / 10), r && this.connect();
|
|
6068
6142
|
}
|
|
6069
6143
|
/**
|
|
6070
6144
|
* @type {boolean}
|
|
@@ -6082,38 +6156,38 @@ var Al = typeof WebSocket > "u" ? null : WebSocket, Ll = class extends Ni {
|
|
|
6082
6156
|
if (this.disableBc)
|
|
6083
6157
|
return;
|
|
6084
6158
|
this.bcconnected || (Ri(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
6085
|
-
const t =
|
|
6086
|
-
v(t, it), hn(t, this.doc),
|
|
6087
|
-
const n =
|
|
6088
|
-
v(n, it), Lr(n, this.doc),
|
|
6089
|
-
const s =
|
|
6090
|
-
v(s, vr),
|
|
6159
|
+
const t = $();
|
|
6160
|
+
v(t, it), hn(t, this.doc), St(this.bcChannel, U(t), this);
|
|
6161
|
+
const n = $();
|
|
6162
|
+
v(n, it), Lr(n, this.doc), St(this.bcChannel, U(n), this);
|
|
6163
|
+
const s = $();
|
|
6164
|
+
v(s, vr), St(
|
|
6091
6165
|
this.bcChannel,
|
|
6092
|
-
|
|
6166
|
+
U(s),
|
|
6093
6167
|
this
|
|
6094
6168
|
);
|
|
6095
|
-
const r =
|
|
6096
|
-
v(r,
|
|
6169
|
+
const r = $();
|
|
6170
|
+
v(r, At), Dt(
|
|
6097
6171
|
r,
|
|
6098
|
-
|
|
6172
|
+
Ft(this.awareness, [
|
|
6099
6173
|
this.doc.clientID
|
|
6100
6174
|
])
|
|
6101
|
-
),
|
|
6175
|
+
), St(
|
|
6102
6176
|
this.bcChannel,
|
|
6103
|
-
|
|
6177
|
+
U(r),
|
|
6104
6178
|
this
|
|
6105
6179
|
);
|
|
6106
6180
|
}
|
|
6107
6181
|
disconnectBc() {
|
|
6108
|
-
const t =
|
|
6109
|
-
v(t,
|
|
6182
|
+
const t = $();
|
|
6183
|
+
v(t, At), Dt(
|
|
6110
6184
|
t,
|
|
6111
|
-
|
|
6185
|
+
Ft(
|
|
6112
6186
|
this.awareness,
|
|
6113
6187
|
[this.doc.clientID],
|
|
6114
6188
|
/* @__PURE__ */ new Map()
|
|
6115
6189
|
)
|
|
6116
|
-
), We(this,
|
|
6190
|
+
), We(this, U(t)), this.bcconnected && ($i(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
6117
6191
|
}
|
|
6118
6192
|
disconnect() {
|
|
6119
6193
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
@@ -6122,8 +6196,8 @@ var Al = typeof WebSocket > "u" ? null : WebSocket, Ll = class extends Ni {
|
|
|
6122
6196
|
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (xr(this), this.connectBc());
|
|
6123
6197
|
}
|
|
6124
6198
|
};
|
|
6125
|
-
function
|
|
6126
|
-
if (crypto.randomUUID)
|
|
6199
|
+
function vl() {
|
|
6200
|
+
if (crypto && crypto.randomUUID)
|
|
6127
6201
|
return crypto.randomUUID();
|
|
6128
6202
|
let e = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
6129
6203
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(n) {
|
|
@@ -6131,23 +6205,23 @@ function Il() {
|
|
|
6131
6205
|
return e > 0 ? (s = (e + s) % 16 | 0, e = Math.floor(e / 16)) : (s = (t + s) % 16 | 0, t = Math.floor(t / 16)), (n === "x" ? s : s & 3 | 8).toString(16);
|
|
6132
6206
|
});
|
|
6133
6207
|
}
|
|
6134
|
-
function
|
|
6208
|
+
function gs(e, t, n) {
|
|
6135
6209
|
if (typeof e !== n)
|
|
6136
6210
|
throw new Error(
|
|
6137
6211
|
`Invalid "${t}" parameter provided to YPartyKitProvider. Expected: ${n}, received: ${e}`
|
|
6138
6212
|
);
|
|
6139
6213
|
}
|
|
6140
|
-
var ot,
|
|
6214
|
+
var ot, ys, Ml = (ys = class extends Il {
|
|
6141
6215
|
constructor(t, n, s, r = {}) {
|
|
6142
|
-
|
|
6143
|
-
const i = `${t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss"}://${t}${r.party ? `/parties/${r.party}` : "/party"}`, o = r.connectionId ??
|
|
6216
|
+
gs(t, "host", "string"), gs(n, "room", "string"), t = t.replace(/^(http|https|ws|wss):\/\//, ""), t.endsWith("/") && t.slice(0, -1);
|
|
6217
|
+
const i = `${r.protocol || (t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss")}://${t}${r.party ? `/parties/${r.party}` : "/party"}`, o = r.connectionId ?? vl(), { params: c, connect: l = !0, ...a } = r, h = {
|
|
6144
6218
|
...a,
|
|
6145
6219
|
connect: !1
|
|
6146
6220
|
};
|
|
6147
|
-
super(i, n, s ?? new
|
|
6221
|
+
super(i, n, s ?? new mt(), h);
|
|
6148
6222
|
y(this, "id");
|
|
6149
|
-
|
|
6150
|
-
this.id = o,
|
|
6223
|
+
Vn(this, ot, void 0);
|
|
6224
|
+
this.id = o, Fn(this, ot, c), l && this.connect();
|
|
6151
6225
|
}
|
|
6152
6226
|
connect() {
|
|
6153
6227
|
Promise.resolve(
|
|
@@ -6163,78 +6237,78 @@ var ot, bs, vl = (bs = class extends Ll {
|
|
|
6163
6237
|
throw console.error("Failed to open connecton to PartyKit", t), new Error(t);
|
|
6164
6238
|
});
|
|
6165
6239
|
}
|
|
6166
|
-
}, ot = new WeakMap(),
|
|
6167
|
-
const
|
|
6240
|
+
}, ot = new WeakMap(), ys);
|
|
6241
|
+
const bt = (e) => Mt((t, n) => {
|
|
6168
6242
|
e.onerror = (s) => n(new Error(s.target.error)), e.onsuccess = (s) => t(s.target.result);
|
|
6169
|
-
}),
|
|
6243
|
+
}), xl = (e, t) => Mt((n, s) => {
|
|
6170
6244
|
const r = indexedDB.open(e);
|
|
6171
|
-
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(
|
|
6245
|
+
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(q(i.target.error)), r.onsuccess = (i) => {
|
|
6172
6246
|
const o = i.target.result;
|
|
6173
6247
|
o.onversionchange = () => {
|
|
6174
6248
|
o.close();
|
|
6175
6249
|
}, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), n(o);
|
|
6176
6250
|
};
|
|
6177
|
-
}),
|
|
6251
|
+
}), Ul = (e) => bt(indexedDB.deleteDatabase(e)), Tl = (e, t) => t.forEach(
|
|
6178
6252
|
(n) => (
|
|
6179
6253
|
// @ts-ignore
|
|
6180
6254
|
e.createObjectStore.apply(e, n)
|
|
6181
6255
|
)
|
|
6182
|
-
),
|
|
6256
|
+
), $t = (e, t, n = "readwrite") => {
|
|
6183
6257
|
const s = e.transaction(t, n);
|
|
6184
|
-
return t.map((r) =>
|
|
6185
|
-
}, Ur = (e, t) =>
|
|
6258
|
+
return t.map((r) => Hl(s, r));
|
|
6259
|
+
}, Ur = (e, t) => bt(e.count(t)), Ol = (e, t) => bt(e.get(t)), Tr = (e, t) => bt(e.delete(t)), Rl = (e, t, n) => bt(e.put(t, n)), un = (e, t) => bt(e.add(t)), $l = (e, t, n) => bt(e.getAll(t, n)), Nl = (e, t, n) => {
|
|
6186
6260
|
let s = null;
|
|
6187
|
-
return
|
|
6188
|
-
},
|
|
6261
|
+
return Fl(e, t, (r) => (s = r, !1), n).then(() => s);
|
|
6262
|
+
}, Bl = (e, t = null) => Nl(e, t, "prev"), Vl = (e, t) => Mt((n, s) => {
|
|
6189
6263
|
e.onerror = s, e.onsuccess = async (r) => {
|
|
6190
6264
|
const i = r.target.result;
|
|
6191
6265
|
if (i === null || await t(i) === !1)
|
|
6192
6266
|
return n();
|
|
6193
6267
|
i.continue();
|
|
6194
6268
|
};
|
|
6195
|
-
}),
|
|
6269
|
+
}), Fl = (e, t, n, s = "next") => Vl(e.openKeyCursor(t, s), (r) => n(r.key)), Hl = (e, t) => e.objectStore(t), jl = (e, t) => IDBKeyRange.upperBound(e, t), zl = (e, t) => IDBKeyRange.lowerBound(e, t), Pe = "custom", Or = "updates", Rr = 500, $r = (e, t = () => {
|
|
6196
6270
|
}, n = () => {
|
|
6197
6271
|
}) => {
|
|
6198
|
-
const [s] =
|
|
6272
|
+
const [s] = $t(
|
|
6199
6273
|
/** @type {IDBDatabase} */
|
|
6200
6274
|
e.db,
|
|
6201
6275
|
[Or]
|
|
6202
6276
|
);
|
|
6203
|
-
return
|
|
6277
|
+
return $l(s, zl(e._dbref, !1)).then((r) => {
|
|
6204
6278
|
e._destroyed || (t(s), S(e.doc, () => {
|
|
6205
6279
|
r.forEach((i) => qs(e.doc, i));
|
|
6206
6280
|
}, e, !1), n(s));
|
|
6207
|
-
}).then(() =>
|
|
6281
|
+
}).then(() => Bl(s).then((r) => {
|
|
6208
6282
|
e._dbref = r + 1;
|
|
6209
6283
|
})).then(() => Ur(s).then((r) => {
|
|
6210
6284
|
e._dbsize = r;
|
|
6211
6285
|
})).then(() => s);
|
|
6212
6286
|
}, Kl = (e, t = !0) => $r(e).then((n) => {
|
|
6213
|
-
(t || e._dbsize >= Rr) && un(n,
|
|
6287
|
+
(t || e._dbsize >= Rr) && un(n, Ln(e.doc)).then(() => Tr(n, jl(e._dbref, !0))).then(() => Ur(n).then((s) => {
|
|
6214
6288
|
e._dbsize = s;
|
|
6215
6289
|
}));
|
|
6216
6290
|
});
|
|
6217
|
-
class
|
|
6291
|
+
class Yl extends vs {
|
|
6218
6292
|
/**
|
|
6219
6293
|
* @param {string} name
|
|
6220
6294
|
* @param {Y.Doc} doc
|
|
6221
6295
|
*/
|
|
6222
6296
|
constructor(t, n) {
|
|
6223
|
-
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db =
|
|
6297
|
+
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = xl(
|
|
6224
6298
|
t,
|
|
6225
|
-
(s) =>
|
|
6299
|
+
(s) => Tl(s, [
|
|
6226
6300
|
["updates", { autoIncrement: !0 }],
|
|
6227
6301
|
["custom"]
|
|
6228
6302
|
])
|
|
6229
6303
|
), this.whenSynced = Mt((s) => this.on("synced", () => s(this))), this._db.then((s) => {
|
|
6230
|
-
this.db = s, $r(this, (o) => un(o,
|
|
6304
|
+
this.db = s, $r(this, (o) => un(o, Ln(n)), () => {
|
|
6231
6305
|
if (this._destroyed)
|
|
6232
6306
|
return this;
|
|
6233
6307
|
this.synced = !0, this.emit("synced", [this]);
|
|
6234
6308
|
});
|
|
6235
6309
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (s, r) => {
|
|
6236
6310
|
if (this.db && r !== this) {
|
|
6237
|
-
const [i] =
|
|
6311
|
+
const [i] = $t(
|
|
6238
6312
|
/** @type {IDBDatabase} */
|
|
6239
6313
|
this.db,
|
|
6240
6314
|
[Or]
|
|
@@ -6257,7 +6331,7 @@ class zl extends mn {
|
|
|
6257
6331
|
*/
|
|
6258
6332
|
clearData() {
|
|
6259
6333
|
return this.destroy().then(() => {
|
|
6260
|
-
|
|
6334
|
+
Ul(this.name);
|
|
6261
6335
|
});
|
|
6262
6336
|
}
|
|
6263
6337
|
/**
|
|
@@ -6266,8 +6340,8 @@ class zl extends mn {
|
|
|
6266
6340
|
*/
|
|
6267
6341
|
get(t) {
|
|
6268
6342
|
return this._db.then((n) => {
|
|
6269
|
-
const [s] =
|
|
6270
|
-
return
|
|
6343
|
+
const [s] = $t(n, [Pe], "readonly");
|
|
6344
|
+
return Ol(s, t);
|
|
6271
6345
|
});
|
|
6272
6346
|
}
|
|
6273
6347
|
/**
|
|
@@ -6277,8 +6351,8 @@ class zl extends mn {
|
|
|
6277
6351
|
*/
|
|
6278
6352
|
set(t, n) {
|
|
6279
6353
|
return this._db.then((s) => {
|
|
6280
|
-
const [r] =
|
|
6281
|
-
return
|
|
6354
|
+
const [r] = $t(s, [Pe]);
|
|
6355
|
+
return Rl(r, n, t);
|
|
6282
6356
|
});
|
|
6283
6357
|
}
|
|
6284
6358
|
/**
|
|
@@ -6287,32 +6361,32 @@ class zl extends mn {
|
|
|
6287
6361
|
*/
|
|
6288
6362
|
del(t) {
|
|
6289
6363
|
return this._db.then((n) => {
|
|
6290
|
-
const [s] =
|
|
6364
|
+
const [s] = $t(n, [Pe]);
|
|
6291
6365
|
return Tr(s, t);
|
|
6292
6366
|
});
|
|
6293
6367
|
}
|
|
6294
6368
|
}
|
|
6295
|
-
const
|
|
6369
|
+
const Xl = {
|
|
6296
6370
|
ctrlKey: "Control",
|
|
6297
6371
|
altKey: "Alt",
|
|
6298
6372
|
shiftKey: "Shift",
|
|
6299
6373
|
metaKey: "Meta"
|
|
6300
|
-
},
|
|
6374
|
+
}, Jl = "can-duplicate-to";
|
|
6301
6375
|
var Re = /* @__PURE__ */ ((e) => (e.CanPlay = "can-play", e.CanMove = "can-move", e.CanSpin = "can-spin", e.CanGrow = "can-grow", e.CanToggle = "can-toggle", e.CanDuplicate = "can-duplicate", e.CanHover = "can-hover", e.CanResize = "can-resize", e.CanMirror = "can-mirror", e))(Re || {});
|
|
6302
|
-
function
|
|
6376
|
+
function Wl(e) {
|
|
6303
6377
|
return e.id;
|
|
6304
6378
|
}
|
|
6305
6379
|
const Nr = `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>")
|
|
6306
6380
|
16 0,
|
|
6307
|
-
auto`,
|
|
6308
|
-
function
|
|
6381
|
+
auto`, Pl = `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`;
|
|
6382
|
+
function ps(e, { getData: t, getElement: n, getLocalData: s, setLocalData: r }) {
|
|
6309
6383
|
const i = t(), o = s(), c = n();
|
|
6310
6384
|
if (o.isHovering = !0, e.altKey) {
|
|
6311
6385
|
if (i.scale <= 0.5) {
|
|
6312
6386
|
c.style.cursor = "not-allowed";
|
|
6313
6387
|
return;
|
|
6314
6388
|
}
|
|
6315
|
-
c.style.cursor =
|
|
6389
|
+
c.style.cursor = Pl;
|
|
6316
6390
|
} else {
|
|
6317
6391
|
if (i.scale >= i.maxScale) {
|
|
6318
6392
|
c.style.cursor = "not-allowed";
|
|
@@ -6329,7 +6403,7 @@ function he(e) {
|
|
|
6329
6403
|
}
|
|
6330
6404
|
return { clientX: e.clientX, clientY: e.clientY };
|
|
6331
6405
|
}
|
|
6332
|
-
const
|
|
6406
|
+
const Gl = {
|
|
6333
6407
|
[
|
|
6334
6408
|
"can-move"
|
|
6335
6409
|
/* CanMove */
|
|
@@ -6416,8 +6490,8 @@ const Pl = {
|
|
|
6416
6490
|
},
|
|
6417
6491
|
onMount: (e) => {
|
|
6418
6492
|
e.getElement().addEventListener("mouseenter", (t) => {
|
|
6419
|
-
|
|
6420
|
-
const n = (s) =>
|
|
6493
|
+
ps(t, e);
|
|
6494
|
+
const n = (s) => ps(s, e);
|
|
6421
6495
|
document.addEventListener("keydown", n), document.addEventListener("keyup", n), e.getElement().addEventListener("mouseleave", (s) => {
|
|
6422
6496
|
document.removeEventListener("keydown", n), document.removeEventListener("keyup", n);
|
|
6423
6497
|
});
|
|
@@ -6447,7 +6521,7 @@ const Pl = {
|
|
|
6447
6521
|
);
|
|
6448
6522
|
return;
|
|
6449
6523
|
}
|
|
6450
|
-
const l = s.getAttribute(
|
|
6524
|
+
const l = s.getAttribute(Jl);
|
|
6451
6525
|
function a(d) {
|
|
6452
6526
|
if (l) {
|
|
6453
6527
|
const u = document.getElementById(l) || document.querySelector(l);
|
|
@@ -6494,8 +6568,8 @@ const Pl = {
|
|
|
6494
6568
|
defaultData: (e) => Gt(e),
|
|
6495
6569
|
onMount: ({ getElement: e, setData: t, getData: n }) => {
|
|
6496
6570
|
const s = e();
|
|
6497
|
-
|
|
6498
|
-
const i = n(), o =
|
|
6571
|
+
ql(s, (r) => {
|
|
6572
|
+
const i = n(), o = Ql(i, r);
|
|
6499
6573
|
t(o);
|
|
6500
6574
|
});
|
|
6501
6575
|
},
|
|
@@ -6518,7 +6592,7 @@ function Le(e, t) {
|
|
|
6518
6592
|
return !1;
|
|
6519
6593
|
return !0;
|
|
6520
6594
|
}
|
|
6521
|
-
function
|
|
6595
|
+
function ql(e, t, n) {
|
|
6522
6596
|
const s = { childList: !0, attributes: !0, subtree: !0, characterData: !0, ...n }, r = (o) => {
|
|
6523
6597
|
const c = o.filter((l) => {
|
|
6524
6598
|
if (s.childList && l.type === "childList")
|
|
@@ -6535,32 +6609,32 @@ function Gl(e, t, n) {
|
|
|
6535
6609
|
}, i = new MutationObserver(r);
|
|
6536
6610
|
return i.observe(e, s), i;
|
|
6537
6611
|
}
|
|
6538
|
-
function
|
|
6612
|
+
function Zl(e) {
|
|
6539
6613
|
return JSON.parse(JSON.stringify(e));
|
|
6540
6614
|
}
|
|
6541
|
-
function
|
|
6542
|
-
let n =
|
|
6615
|
+
function Ql(e, t) {
|
|
6616
|
+
let n = Zl(e);
|
|
6543
6617
|
return t.forEach((s) => {
|
|
6544
6618
|
switch (s.type) {
|
|
6545
6619
|
case "attributes":
|
|
6546
|
-
|
|
6620
|
+
ta(n, s);
|
|
6547
6621
|
break;
|
|
6548
6622
|
case "childList":
|
|
6549
|
-
|
|
6623
|
+
ea(n, s);
|
|
6550
6624
|
break;
|
|
6551
6625
|
case "characterData":
|
|
6552
|
-
|
|
6626
|
+
na(n, s);
|
|
6553
6627
|
break;
|
|
6554
6628
|
}
|
|
6555
6629
|
}), n;
|
|
6556
6630
|
}
|
|
6557
|
-
function
|
|
6631
|
+
function ta(e, t) {
|
|
6558
6632
|
if (t.target instanceof HTMLElement) {
|
|
6559
6633
|
const n = t.attributeName, s = t.target.getAttribute(n);
|
|
6560
6634
|
s !== null ? e.attributes[n] = s : delete e.attributes[n];
|
|
6561
6635
|
}
|
|
6562
6636
|
}
|
|
6563
|
-
function
|
|
6637
|
+
function ea(e, t) {
|
|
6564
6638
|
t.addedNodes.length && t.addedNodes.forEach((n) => {
|
|
6565
6639
|
if (!(n instanceof HTMLElement))
|
|
6566
6640
|
return;
|
|
@@ -6575,7 +6649,7 @@ function ta(e, t) {
|
|
|
6575
6649
|
r !== -1 && e.children.splice(r, 1);
|
|
6576
6650
|
});
|
|
6577
6651
|
}
|
|
6578
|
-
function
|
|
6652
|
+
function na(e, t) {
|
|
6579
6653
|
t.target === e && (e.textContent = t.target.textContent);
|
|
6580
6654
|
}
|
|
6581
6655
|
function Gt(e) {
|
|
@@ -6592,9 +6666,9 @@ function Gt(e) {
|
|
|
6592
6666
|
}), t;
|
|
6593
6667
|
}
|
|
6594
6668
|
function Br(e, t) {
|
|
6595
|
-
|
|
6669
|
+
sa(e, t), t.children.length === 0 && e.textContent !== t.textContent ? e.textContent = t.textContent : t.children.length > 0 && ra(e, t);
|
|
6596
6670
|
}
|
|
6597
|
-
function
|
|
6671
|
+
function sa(e, t) {
|
|
6598
6672
|
if (t) {
|
|
6599
6673
|
for (const [n, s] of Object.entries(t.attributes))
|
|
6600
6674
|
e.getAttribute(n) !== s && e.setAttribute(n, s);
|
|
@@ -6603,7 +6677,7 @@ function na(e, t) {
|
|
|
6603
6677
|
});
|
|
6604
6678
|
}
|
|
6605
6679
|
}
|
|
6606
|
-
function
|
|
6680
|
+
function ra(e, t) {
|
|
6607
6681
|
const n = /* @__PURE__ */ new Set();
|
|
6608
6682
|
t.children.forEach((s) => {
|
|
6609
6683
|
let r = Array.from(e.children).find(
|
|
@@ -6614,13 +6688,13 @@ function sa(e, t) {
|
|
|
6614
6688
|
n.has(s) || e.removeChild(s);
|
|
6615
6689
|
});
|
|
6616
6690
|
}
|
|
6617
|
-
const
|
|
6691
|
+
const ws = (e, t = 300) => {
|
|
6618
6692
|
let n;
|
|
6619
6693
|
return function(...s) {
|
|
6620
6694
|
clearTimeout(n), n = setTimeout(() => e.apply(this, s), t);
|
|
6621
6695
|
};
|
|
6622
6696
|
};
|
|
6623
|
-
class
|
|
6697
|
+
class ia {
|
|
6624
6698
|
constructor(t) {
|
|
6625
6699
|
y(this, "defaultData");
|
|
6626
6700
|
y(this, "localData");
|
|
@@ -6656,7 +6730,7 @@ class ra {
|
|
|
6656
6730
|
debounceMs: f,
|
|
6657
6731
|
triggerAwarenessUpdate: g
|
|
6658
6732
|
} = t;
|
|
6659
|
-
this.element = n, this.defaultData = i instanceof Function ? i(n) : i, this.localData = o instanceof Function ? o(n) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange =
|
|
6733
|
+
this.element = n, this.defaultData = i instanceof Function ? i(n) : i, this.localData = o instanceof Function ? o(n) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange = ws(this.onChange, f), this.onAwarenessChange = r, this.updateElement = h, this.updateElementAwareness = d;
|
|
6660
6734
|
const p = l === void 0 ? this.defaultData : l;
|
|
6661
6735
|
a !== void 0 && (this.__awareness = a);
|
|
6662
6736
|
const _ = c instanceof Function ? c(n) : c;
|
|
@@ -6675,30 +6749,30 @@ class ra {
|
|
|
6675
6749
|
debounceMs: h,
|
|
6676
6750
|
triggerAwarenessUpdate: d
|
|
6677
6751
|
}) {
|
|
6678
|
-
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange =
|
|
6752
|
+
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange = ws(this.onChange, h), this.onAwarenessChange = s, this.updateElement = r, this.updateElementAwareness = i, o && !this.onClick && t.addEventListener("click", (u) => {
|
|
6679
6753
|
var f;
|
|
6680
6754
|
(f = this.onClick) == null || f.call(this, u, this.getEventHandlerData());
|
|
6681
6755
|
}), this.onClick = o, c && !this.onDrag && (t.addEventListener("touchstart", (u) => {
|
|
6682
6756
|
var p;
|
|
6683
|
-
u.preventDefault(), (p = this.onDragStart) == null || p.call(this, u, this.getEventHandlerData());
|
|
6757
|
+
u.preventDefault(), t.classList.add("cursordown"), (p = this.onDragStart) == null || p.call(this, u, this.getEventHandlerData());
|
|
6684
6758
|
const f = (_) => {
|
|
6685
6759
|
var Y;
|
|
6686
6760
|
_.preventDefault(), (Y = this.onDrag) == null || Y.call(this, _, this.getEventHandlerData());
|
|
6687
6761
|
}, g = (_) => {
|
|
6688
|
-
document.removeEventListener("touchmove", f), document.removeEventListener("touchend", g);
|
|
6762
|
+
t.classList.remove("cursordown"), document.removeEventListener("touchmove", f), document.removeEventListener("touchend", g);
|
|
6689
6763
|
};
|
|
6690
6764
|
document.addEventListener("touchmove", f), document.addEventListener("touchend", g);
|
|
6691
6765
|
}), t.addEventListener("mousedown", (u) => {
|
|
6692
6766
|
var p;
|
|
6693
|
-
(p = this.onDragStart) == null || p.call(this, u, this.getEventHandlerData());
|
|
6767
|
+
u.preventDefault(), (p = this.onDragStart) == null || p.call(this, u, this.getEventHandlerData()), t.classList.add("cursordown");
|
|
6694
6768
|
const f = (_) => {
|
|
6695
6769
|
var Y;
|
|
6696
6770
|
_.preventDefault(), (Y = this.onDrag) == null || Y.call(this, _, this.getEventHandlerData());
|
|
6697
6771
|
}, g = (_) => {
|
|
6698
|
-
document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", g);
|
|
6772
|
+
t.classList.remove("cursordown"), document.removeEventListener("mousemove", f), document.removeEventListener("mouseup", g);
|
|
6699
6773
|
};
|
|
6700
6774
|
document.addEventListener("mousemove", f), document.addEventListener("mouseup", g);
|
|
6701
|
-
})), this.onDrag = c, this.onDragStart = l, a && !this.resetShortcut && (t.title || (t.title = `Hold down the ${
|
|
6775
|
+
})), this.onDrag = c, this.onDragStart = l, a && !this.resetShortcut && (t.title || (t.title = `Hold down the ${Xl[a]} key while clicking to reset.`), t.reset = this.reset, t.addEventListener("click", (u) => {
|
|
6702
6776
|
switch (this.resetShortcut) {
|
|
6703
6777
|
case "ctrlKey":
|
|
6704
6778
|
if (!u.ctrlKey)
|
|
@@ -6790,25 +6864,25 @@ class ra {
|
|
|
6790
6864
|
this.setData(this.defaultData);
|
|
6791
6865
|
}
|
|
6792
6866
|
}
|
|
6793
|
-
async function
|
|
6867
|
+
async function oa(e, t) {
|
|
6794
6868
|
const n = new TextEncoder().encode(`${e}-${t.outerHTML}}`), s = await crypto.subtle.digest("SHA-1", n);
|
|
6795
6869
|
return Array.from(new Uint8Array(s)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
6796
6870
|
}
|
|
6797
|
-
const
|
|
6798
|
-
function
|
|
6871
|
+
const ca = "playhtml.spencerc99.partykit.dev", dn = new mt();
|
|
6872
|
+
function la(e) {
|
|
6799
6873
|
const t = window.location.pathname.replace(/\.[^/.]+$/, "");
|
|
6800
6874
|
return e ? t + window.location.search : t;
|
|
6801
6875
|
}
|
|
6802
|
-
let
|
|
6803
|
-
const
|
|
6804
|
-
let
|
|
6876
|
+
let B, W = dn.getMap("playhtml-global"), R = /* @__PURE__ */ new Map(), gt = /* @__PURE__ */ new Map();
|
|
6877
|
+
const ms = /* @__PURE__ */ new Map();
|
|
6878
|
+
let aa = 0, re = Gl;
|
|
6805
6879
|
function Vr() {
|
|
6806
6880
|
return [Re.CanPlay, ...Object.keys(re)];
|
|
6807
6881
|
}
|
|
6808
|
-
function aa(e) {
|
|
6809
|
-
N.ws && N.ws.send(JSON.stringify(e));
|
|
6810
|
-
}
|
|
6811
6882
|
function ha(e) {
|
|
6883
|
+
B.ws && B.ws.send(JSON.stringify(e));
|
|
6884
|
+
}
|
|
6885
|
+
function ua(e) {
|
|
6812
6886
|
if (e.data instanceof Blob)
|
|
6813
6887
|
return;
|
|
6814
6888
|
let t;
|
|
@@ -6817,19 +6891,19 @@ function ha(e) {
|
|
|
6817
6891
|
} catch {
|
|
6818
6892
|
return;
|
|
6819
6893
|
}
|
|
6820
|
-
const { type: n, eventPayload: s } = t, r =
|
|
6894
|
+
const { type: n, eventPayload: s } = t, r = gt.get(n);
|
|
6821
6895
|
if (r)
|
|
6822
6896
|
for (const i of r)
|
|
6823
6897
|
i.onEvent(s);
|
|
6824
6898
|
}
|
|
6825
|
-
let
|
|
6826
|
-
async function
|
|
6899
|
+
let Lt = !1, fn = !0;
|
|
6900
|
+
async function da({
|
|
6827
6901
|
// TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
|
|
6828
|
-
host: e =
|
|
6902
|
+
host: e = ca,
|
|
6829
6903
|
extraCapabilities: t,
|
|
6830
6904
|
events: n,
|
|
6831
6905
|
defaultRoomOptions: s = {},
|
|
6832
|
-
room: r =
|
|
6906
|
+
room: r = la(s.includeSearch)
|
|
6833
6907
|
} = {}) {
|
|
6834
6908
|
if (!fn) {
|
|
6835
6909
|
console.error("playhtml already set up!");
|
|
@@ -6843,24 +6917,24 @@ async function ua({
|
|
|
6843
6917
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
6844
6918
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
6845
6919
|
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
|
|
6846
|
-
),
|
|
6920
|
+
), B = new Ml(o, i, dn), new Yl(i, dn), t)
|
|
6847
6921
|
for (const [l, a] of Object.entries(t))
|
|
6848
6922
|
re[l] = a;
|
|
6849
6923
|
if (n)
|
|
6850
6924
|
for (const [l, a] of Object.entries(n))
|
|
6851
|
-
|
|
6925
|
+
zr(l, a);
|
|
6852
6926
|
const c = document.createElement("link");
|
|
6853
6927
|
return c.rel = "stylesheet", c.href = "https://unpkg.com/playhtml@latest/dist/style.css", document.head.appendChild(c), await new Promise((l) => {
|
|
6854
|
-
|
|
6855
|
-
a ? a &&
|
|
6928
|
+
Lt && l(!0), B.on("sync", (a) => {
|
|
6929
|
+
a ? a && B.ws.addEventListener("message", ua) : console.error("Issue connecting to yjs..."), !Lt && (Lt = !0, console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝"), jr(), l(!0));
|
|
6856
6930
|
});
|
|
6857
|
-
}),
|
|
6931
|
+
}), B;
|
|
6858
6932
|
}
|
|
6859
|
-
function
|
|
6860
|
-
const n =
|
|
6933
|
+
function fa(e, t) {
|
|
6934
|
+
const n = B.awareness.getLocalState();
|
|
6861
6935
|
return ((n == null ? void 0 : n[e]) ?? {})[t];
|
|
6862
6936
|
}
|
|
6863
|
-
function
|
|
6937
|
+
function Nn(e) {
|
|
6864
6938
|
return e instanceof HTMLElement;
|
|
6865
6939
|
}
|
|
6866
6940
|
function Fr(e, t) {
|
|
@@ -6877,31 +6951,31 @@ function Fr(e, t) {
|
|
|
6877
6951
|
}
|
|
6878
6952
|
return !1;
|
|
6879
6953
|
}
|
|
6880
|
-
function
|
|
6954
|
+
function ga(e, t, n, s) {
|
|
6881
6955
|
const r = W.get(t);
|
|
6882
6956
|
return {
|
|
6883
6957
|
...n,
|
|
6884
6958
|
// TODO: when adding save-state if no save state, then just use defaultData
|
|
6885
6959
|
data: r.get(s) ?? (n.defaultData instanceof Function ? n.defaultData(e) : n.defaultData),
|
|
6886
|
-
awareness:
|
|
6960
|
+
awareness: fa(t, s) ?? n.myDefaultAwareness !== void 0 ? [n.myDefaultAwareness] : void 0,
|
|
6887
6961
|
element: e,
|
|
6888
6962
|
onChange: (o) => {
|
|
6889
6963
|
Fr(r.get(s), o) || r.set(s, o);
|
|
6890
6964
|
},
|
|
6891
6965
|
onAwarenessChange: (o) => {
|
|
6892
6966
|
var l;
|
|
6893
|
-
const c = ((l =
|
|
6894
|
-
c[s] !== o && (c[s] = o,
|
|
6967
|
+
const c = ((l = B.awareness.getLocalState()) == null ? void 0 : l[t]) || {};
|
|
6968
|
+
c[s] !== o && (c[s] = o, B.awareness.setLocalStateField(t, c));
|
|
6895
6969
|
},
|
|
6896
6970
|
triggerAwarenessUpdate: () => {
|
|
6897
6971
|
Hr();
|
|
6898
6972
|
}
|
|
6899
6973
|
};
|
|
6900
6974
|
}
|
|
6901
|
-
function
|
|
6975
|
+
function pa(e) {
|
|
6902
6976
|
return e.defaultData !== void 0 && (typeof e.defaultData == "object" || typeof e.defaultData == "function") && e.updateElement !== void 0;
|
|
6903
6977
|
}
|
|
6904
|
-
function
|
|
6978
|
+
function wa(e, t) {
|
|
6905
6979
|
if (e === Re.CanPlay) {
|
|
6906
6980
|
const n = t;
|
|
6907
6981
|
return {
|
|
@@ -6928,10 +7002,10 @@ function Hr() {
|
|
|
6928
7002
|
const o = e.get(n);
|
|
6929
7003
|
o.has(s) || o.set(s, /* @__PURE__ */ new Map()), o.get(s).set(r, i);
|
|
6930
7004
|
}
|
|
6931
|
-
|
|
7005
|
+
B.awareness.getStates().forEach((n, s) => {
|
|
6932
7006
|
var r;
|
|
6933
7007
|
for (const [i, o] of Object.entries(n)) {
|
|
6934
|
-
const c =
|
|
7008
|
+
const c = R.get(i);
|
|
6935
7009
|
if (c)
|
|
6936
7010
|
for (const [l, a] of c) {
|
|
6937
7011
|
if (!(l in o))
|
|
@@ -6946,7 +7020,7 @@ function Hr() {
|
|
|
6946
7020
|
}
|
|
6947
7021
|
}
|
|
6948
7022
|
for (const [i, o] of e) {
|
|
6949
|
-
const c =
|
|
7023
|
+
const c = R.get(i);
|
|
6950
7024
|
if (c)
|
|
6951
7025
|
for (const [l, a] of c) {
|
|
6952
7026
|
const h = (r = o.get(l)) == null ? void 0 : r.values();
|
|
@@ -6959,11 +7033,11 @@ function Hr() {
|
|
|
6959
7033
|
});
|
|
6960
7034
|
}
|
|
6961
7035
|
function jr() {
|
|
6962
|
-
if (
|
|
7036
|
+
if (Lt) {
|
|
6963
7037
|
for (const e of Vr()) {
|
|
6964
7038
|
const t = Array.from(
|
|
6965
7039
|
document.querySelectorAll(`[${e}]`)
|
|
6966
|
-
).filter(
|
|
7040
|
+
).filter(Nn);
|
|
6967
7041
|
t.length && Promise.all(
|
|
6968
7042
|
t.map((n) => $e(n, e))
|
|
6969
7043
|
);
|
|
@@ -6972,34 +7046,34 @@ function jr() {
|
|
|
6972
7046
|
e.changes.keys.forEach((t, n) => {
|
|
6973
7047
|
t.action === "add" && W.set(n, W.get(n));
|
|
6974
7048
|
});
|
|
6975
|
-
}),
|
|
7049
|
+
}), B.awareness.on("change", () => Hr()), fn = !1);
|
|
6976
7050
|
}
|
|
6977
7051
|
}
|
|
6978
|
-
const
|
|
6979
|
-
init:
|
|
7052
|
+
const ma = {
|
|
7053
|
+
init: da,
|
|
6980
7054
|
setupPlayElements: jr,
|
|
6981
|
-
setupPlayElement:
|
|
6982
|
-
removePlayElement:
|
|
7055
|
+
setupPlayElement: Sa,
|
|
7056
|
+
removePlayElement: _a,
|
|
6983
7057
|
setupPlayElementForTag: $e,
|
|
6984
7058
|
globalData: W,
|
|
6985
|
-
elementHandlers:
|
|
6986
|
-
eventHandlers:
|
|
6987
|
-
dispatchPlayEvent:
|
|
6988
|
-
registerPlayEventListener:
|
|
6989
|
-
removePlayEventListener:
|
|
7059
|
+
elementHandlers: R,
|
|
7060
|
+
eventHandlers: gt,
|
|
7061
|
+
dispatchPlayEvent: ka,
|
|
7062
|
+
registerPlayEventListener: zr,
|
|
7063
|
+
removePlayEventListener: Da
|
|
6990
7064
|
};
|
|
6991
|
-
window.playhtml =
|
|
6992
|
-
function
|
|
6993
|
-
if (
|
|
7065
|
+
window.playhtml = ma;
|
|
7066
|
+
function ya(e) {
|
|
7067
|
+
if (R.has(e) || !Lt)
|
|
6994
7068
|
return;
|
|
6995
|
-
|
|
7069
|
+
R.has(e) || R.set(e, /* @__PURE__ */ new Map()), e !== Re.CanPlay && re[e], W.get(e) || W.set(e, new ut());
|
|
6996
7070
|
const t = W.get(e);
|
|
6997
7071
|
t.observe((n) => {
|
|
6998
7072
|
n.changes.keys.forEach((s, r) => {
|
|
6999
|
-
const i =
|
|
7073
|
+
const i = R.get(e);
|
|
7000
7074
|
if (s.action === "add") {
|
|
7001
7075
|
const o = document.getElementById(r);
|
|
7002
|
-
if (!
|
|
7076
|
+
if (!Nn(o)) {
|
|
7003
7077
|
console.log(`Element ${r} not an HTML element. Ignoring.`);
|
|
7004
7078
|
return;
|
|
7005
7079
|
}
|
|
@@ -7012,41 +7086,41 @@ function ma(e) {
|
|
|
7012
7086
|
});
|
|
7013
7087
|
});
|
|
7014
7088
|
}
|
|
7015
|
-
function
|
|
7089
|
+
function ba(e, t) {
|
|
7016
7090
|
var n, s;
|
|
7017
7091
|
return ((s = (n = re[t]) == null ? void 0 : n.isValidElementForTag) == null ? void 0 : s.call(n, e)) ?? !0;
|
|
7018
7092
|
}
|
|
7019
7093
|
async function $e(e, t) {
|
|
7020
7094
|
var c;
|
|
7021
|
-
if (!
|
|
7095
|
+
if (!ba(e, t) || !Lt)
|
|
7022
7096
|
return;
|
|
7023
7097
|
if (!e.id) {
|
|
7024
7098
|
const l = e.getAttribute("selector-id");
|
|
7025
7099
|
if (l) {
|
|
7026
|
-
const a =
|
|
7027
|
-
e.id = btoa(`${t}-${l}-${a}`),
|
|
7100
|
+
const a = ms.get(l) ?? 0;
|
|
7101
|
+
e.id = btoa(`${t}-${l}-${a}`), ms.set(l, a + 1);
|
|
7028
7102
|
} else
|
|
7029
|
-
e.id = await
|
|
7103
|
+
e.id = await oa(t, e);
|
|
7030
7104
|
}
|
|
7031
|
-
const n =
|
|
7105
|
+
const n = Wl(e);
|
|
7032
7106
|
if (!n) {
|
|
7033
7107
|
console.error(
|
|
7034
7108
|
`Element ${e} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`
|
|
7035
7109
|
);
|
|
7036
7110
|
return;
|
|
7037
7111
|
}
|
|
7038
|
-
|
|
7039
|
-
const s =
|
|
7112
|
+
ya(t);
|
|
7113
|
+
const s = R.get(t), r = wa(
|
|
7040
7114
|
t,
|
|
7041
7115
|
e
|
|
7042
7116
|
);
|
|
7043
|
-
if (!
|
|
7117
|
+
if (!pa(r)) {
|
|
7044
7118
|
console.error(
|
|
7045
7119
|
`Element ${n} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`
|
|
7046
7120
|
);
|
|
7047
7121
|
return;
|
|
7048
7122
|
}
|
|
7049
|
-
const i = W.get(t), o =
|
|
7123
|
+
const i = W.get(t), o = ga(
|
|
7050
7124
|
e,
|
|
7051
7125
|
t,
|
|
7052
7126
|
r,
|
|
@@ -7056,20 +7130,20 @@ async function $e(e, t) {
|
|
|
7056
7130
|
s.get(n).reinitializeElementData(o);
|
|
7057
7131
|
return;
|
|
7058
7132
|
} else
|
|
7059
|
-
s.set(n, new
|
|
7133
|
+
s.set(n, new ia(o));
|
|
7060
7134
|
i.get(n) === void 0 && r.defaultData !== void 0 && i.set(
|
|
7061
7135
|
n,
|
|
7062
7136
|
r.defaultData instanceof Function ? r.defaultData(e) : r.defaultData
|
|
7063
7137
|
), (c = o.triggerAwarenessUpdate) == null || c.call(o), e.classList.add("__playhtml-element"), e.classList.add(`__playhtml-${t}`), e.style.setProperty("--jiggle-delay", `${Math.random() * 1}s;}`);
|
|
7064
7138
|
}
|
|
7065
|
-
function
|
|
7066
|
-
if (!(t && Object.keys(
|
|
7139
|
+
function Sa(e, { ignoreIfAlreadySetup: t } = {}) {
|
|
7140
|
+
if (!(t && Object.keys(R || {}).some(
|
|
7067
7141
|
(n) => {
|
|
7068
7142
|
var s;
|
|
7069
|
-
return (s =
|
|
7143
|
+
return (s = R.get(n)) == null ? void 0 : s.has(e.id);
|
|
7070
7144
|
}
|
|
7071
7145
|
))) {
|
|
7072
|
-
if (!
|
|
7146
|
+
if (!Nn(e)) {
|
|
7073
7147
|
console.log(`Element ${e.id} not an HTML element. Ignoring.`);
|
|
7074
7148
|
return;
|
|
7075
7149
|
}
|
|
@@ -7078,35 +7152,35 @@ function ba(e, { ignoreIfAlreadySetup: t } = {}) {
|
|
|
7078
7152
|
);
|
|
7079
7153
|
}
|
|
7080
7154
|
}
|
|
7081
|
-
function
|
|
7155
|
+
function _a(e) {
|
|
7082
7156
|
if (!(!e || !e.id))
|
|
7083
|
-
for (const t of Object.keys(
|
|
7084
|
-
const n =
|
|
7157
|
+
for (const t of Object.keys(R)) {
|
|
7158
|
+
const n = R.get(t);
|
|
7085
7159
|
n.has(e.id) && n.delete(e.id);
|
|
7086
7160
|
}
|
|
7087
7161
|
}
|
|
7088
|
-
function
|
|
7162
|
+
function ka(e) {
|
|
7089
7163
|
const { type: t } = e;
|
|
7090
|
-
if (!
|
|
7164
|
+
if (!gt.has(t)) {
|
|
7091
7165
|
console.error(`[playhtml] event "${t}" not registered.`);
|
|
7092
7166
|
return;
|
|
7093
7167
|
}
|
|
7094
|
-
|
|
7168
|
+
ha(e);
|
|
7095
7169
|
}
|
|
7096
|
-
function
|
|
7097
|
-
const n = String(
|
|
7098
|
-
return
|
|
7099
|
-
...
|
|
7170
|
+
function zr(e, t) {
|
|
7171
|
+
const n = String(aa++);
|
|
7172
|
+
return gt.set(e, [
|
|
7173
|
+
...gt.get(e) ?? [],
|
|
7100
7174
|
{ type: e, ...t, id: n }
|
|
7101
7175
|
]), n;
|
|
7102
7176
|
}
|
|
7103
|
-
function
|
|
7104
|
-
const n =
|
|
7177
|
+
function Da(e, t) {
|
|
7178
|
+
const n = gt.get(e);
|
|
7105
7179
|
if (!n)
|
|
7106
7180
|
return;
|
|
7107
7181
|
const s = n.findIndex((r) => r.id === t);
|
|
7108
|
-
s !== -1 && (n.splice(s, 1), n.length === 0 &&
|
|
7182
|
+
s !== -1 && (n.splice(s, 1), n.length === 0 && gt.delete(e));
|
|
7109
7183
|
}
|
|
7110
7184
|
export {
|
|
7111
|
-
|
|
7185
|
+
ma as playhtml
|
|
7112
7186
|
};
|