playhtml 0.1.6 → 0.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/LICENSE +21 -0
- package/README.md +11 -3
- package/dist/elements.d.ts +26 -13
- package/dist/main.d.ts +1 -0
- package/dist/noguchi-akari-a1.png +0 -0
- package/dist/playhtml.es.js +1030 -985
- package/dist/playhtml.umd.js +6 -5
- package/dist/types.d.ts +2 -4
- package/package.json +1 -1
package/dist/playhtml.es.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var _ = (e, t, n) => (
|
|
4
|
-
const
|
|
5
|
-
const t =
|
|
1
|
+
var tr = Object.defineProperty;
|
|
2
|
+
var er = (e, t, n) => t in e ? tr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var _ = (e, t, n) => (er(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
|
+
const R = () => /* @__PURE__ */ new Map(), xe = (e) => {
|
|
5
|
+
const t = R();
|
|
6
6
|
return e.forEach((n, s) => {
|
|
7
7
|
t.set(s, n);
|
|
8
8
|
}), t;
|
|
9
|
-
},
|
|
9
|
+
}, J = (e, t, n) => {
|
|
10
10
|
let s = e.get(t);
|
|
11
11
|
return s === void 0 && e.set(t, s = n()), s;
|
|
12
|
-
},
|
|
12
|
+
}, nr = (e, t) => {
|
|
13
13
|
const n = [];
|
|
14
14
|
for (const [s, r] of e)
|
|
15
15
|
n.push(t(r, s));
|
|
16
16
|
return n;
|
|
17
|
-
},
|
|
17
|
+
}, sr = (e, t) => {
|
|
18
18
|
for (const [n, s] of e)
|
|
19
19
|
if (t(s, n))
|
|
20
20
|
return !0;
|
|
21
21
|
return !1;
|
|
22
|
-
},
|
|
22
|
+
}, rt = () => /* @__PURE__ */ new Set(), we = (e) => e[e.length - 1], rr = (e, t) => {
|
|
23
23
|
for (let n = 0; n < t.length; n++)
|
|
24
24
|
e.push(t[n]);
|
|
25
|
-
},
|
|
25
|
+
}, Q = Array.from, ir = Array.isArray, or = String.fromCharCode, cr = (e) => e.toLowerCase(), lr = /^\s*/g, ar = (e) => e.replace(lr, ""), hr = /([A-Z])/g, pn = (e, t) => ar(e.replace(hr, (n) => `${t}${cr(n)}`)), ur = (e) => {
|
|
26
26
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
27
27
|
for (let r = 0; r < n; r++)
|
|
28
28
|
s[r] = /** @type {number} */
|
|
29
29
|
t.codePointAt(r);
|
|
30
30
|
return s;
|
|
31
|
-
},
|
|
31
|
+
}, Ut = (
|
|
32
32
|
/** @type {TextEncoder} */
|
|
33
33
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
34
|
-
),
|
|
35
|
-
let
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
class
|
|
34
|
+
), dr = (e) => Ut.encode(e), fr = Ut ? dr : ur;
|
|
35
|
+
let Lt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
36
|
+
Lt && Lt.decode(new Uint8Array()).length === 1 && (Lt = null);
|
|
37
|
+
const wn = (e) => e === void 0 ? null : e;
|
|
38
|
+
class gr {
|
|
39
39
|
constructor() {
|
|
40
40
|
this.map = /* @__PURE__ */ new Map();
|
|
41
41
|
}
|
|
@@ -53,46 +53,46 @@ class dr {
|
|
|
53
53
|
return this.map.get(t);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
let
|
|
56
|
+
let Fn = new gr(), $e = !0;
|
|
57
57
|
try {
|
|
58
|
-
typeof localStorage < "u" && (
|
|
58
|
+
typeof localStorage < "u" && (Fn = localStorage, $e = !1);
|
|
59
59
|
} catch {
|
|
60
60
|
}
|
|
61
|
-
const
|
|
61
|
+
const Hn = Fn, pr = (e) => $e || addEventListener(
|
|
62
62
|
"storage",
|
|
63
63
|
/** @type {any} */
|
|
64
64
|
e
|
|
65
|
-
),
|
|
65
|
+
), wr = (e) => $e || removeEventListener(
|
|
66
66
|
"storage",
|
|
67
67
|
/** @type {any} */
|
|
68
68
|
e
|
|
69
|
-
),
|
|
69
|
+
), mr = Object.assign, yr = Object.keys, _r = (e, t) => {
|
|
70
70
|
for (const n in e)
|
|
71
71
|
t(e[n], n);
|
|
72
|
-
},
|
|
72
|
+
}, br = (e, t) => {
|
|
73
73
|
const n = [];
|
|
74
74
|
for (const s in e)
|
|
75
75
|
n.push(t(e[s], s));
|
|
76
76
|
return n;
|
|
77
|
-
},
|
|
77
|
+
}, Zt = (e) => yr(e).length, kr = (e) => {
|
|
78
78
|
for (const t in e)
|
|
79
79
|
return !1;
|
|
80
80
|
return !0;
|
|
81
|
-
},
|
|
81
|
+
}, Sr = (e, t) => {
|
|
82
82
|
for (const n in e)
|
|
83
83
|
if (!t(e[n], n))
|
|
84
84
|
return !1;
|
|
85
85
|
return !0;
|
|
86
|
-
},
|
|
86
|
+
}, $n = (e, t) => Object.prototype.hasOwnProperty.call(e, t), Dr = (e, t) => e === t || Zt(e) === Zt(t) && Sr(e, (n, s) => (n !== void 0 || $n(t, s)) && t[s] === n), Ke = (e, t, n = 0) => {
|
|
87
87
|
try {
|
|
88
88
|
for (; n < e.length; n++)
|
|
89
89
|
e[n](...t);
|
|
90
90
|
} finally {
|
|
91
91
|
n < e.length && Ke(e, t, n + 1);
|
|
92
92
|
}
|
|
93
|
-
},
|
|
93
|
+
}, Cr = (e) => e, Er = (e, t) => e === t, xt = (e, t) => {
|
|
94
94
|
if (e == null || t == null)
|
|
95
|
-
return
|
|
95
|
+
return Er(e, t);
|
|
96
96
|
if (e.constructor !== t.constructor)
|
|
97
97
|
return !1;
|
|
98
98
|
if (e === t)
|
|
@@ -120,58 +120,58 @@ const Fn = Vn, fr = (e) => $e || addEventListener(
|
|
|
120
120
|
if (e.size !== t.size)
|
|
121
121
|
return !1;
|
|
122
122
|
for (const n of e.keys())
|
|
123
|
-
if (!t.has(n) || !
|
|
123
|
+
if (!t.has(n) || !xt(e.get(n), t.get(n)))
|
|
124
124
|
return !1;
|
|
125
125
|
break;
|
|
126
126
|
}
|
|
127
127
|
case Object:
|
|
128
|
-
if (
|
|
128
|
+
if (Zt(e) !== Zt(t))
|
|
129
129
|
return !1;
|
|
130
130
|
for (const n in e)
|
|
131
|
-
if (
|
|
131
|
+
if (!$n(e, n) || !xt(e[n], t[n]))
|
|
132
132
|
return !1;
|
|
133
133
|
break;
|
|
134
134
|
case Array:
|
|
135
135
|
if (e.length !== t.length)
|
|
136
136
|
return !1;
|
|
137
137
|
for (let n = 0; n < e.length; n++)
|
|
138
|
-
if (!
|
|
138
|
+
if (!xt(e[n], t[n]))
|
|
139
139
|
return !1;
|
|
140
140
|
break;
|
|
141
141
|
default:
|
|
142
142
|
return !1;
|
|
143
143
|
}
|
|
144
144
|
return !0;
|
|
145
|
-
},
|
|
146
|
-
let
|
|
147
|
-
const
|
|
148
|
-
if (
|
|
149
|
-
if (
|
|
150
|
-
|
|
145
|
+
}, Ir = (e, t) => t.includes(e), yt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name), Kn = typeof window < "u" && typeof document < "u" && !yt;
|
|
146
|
+
let N;
|
|
147
|
+
const Ar = () => {
|
|
148
|
+
if (N === void 0)
|
|
149
|
+
if (yt) {
|
|
150
|
+
N = R();
|
|
151
151
|
const e = process.argv;
|
|
152
152
|
let t = null;
|
|
153
153
|
for (let n = 0; n < e.length; n++) {
|
|
154
154
|
const s = e[n];
|
|
155
|
-
s[0] === "-" ? (t !== null &&
|
|
155
|
+
s[0] === "-" ? (t !== null && N.set(t, ""), t = s) : t !== null && (N.set(t, s), t = null);
|
|
156
156
|
}
|
|
157
|
-
t !== null &&
|
|
157
|
+
t !== null && N.set(t, "");
|
|
158
158
|
} else
|
|
159
|
-
typeof location == "object" ? (
|
|
159
|
+
typeof location == "object" ? (N = R(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
160
160
|
if (e.length !== 0) {
|
|
161
161
|
const [t, n] = e.split("=");
|
|
162
|
-
|
|
162
|
+
N.set(`--${pn(t, "-")}`, n), N.set(`-${pn(t, "-")}`, n);
|
|
163
163
|
}
|
|
164
|
-
})) :
|
|
165
|
-
return
|
|
166
|
-
}, Me = (e) =>
|
|
167
|
-
|
|
168
|
-
const
|
|
169
|
-
class
|
|
164
|
+
})) : N = R();
|
|
165
|
+
return N;
|
|
166
|
+
}, Me = (e) => Ar().has(e), Ue = (e) => wn(yt ? process.env[e.toUpperCase()] : Hn.getItem(e)), Lr = (e) => Me("--" + e) || Ue(e) !== null;
|
|
167
|
+
Lr("production");
|
|
168
|
+
const mn = yt && Ir(process.env.FORCE_COLOR, ["true", "1", "2"]), xr = !Me("no-colors") && (!yt || process.stdout.isTTY || mn) && (!yt || Me("color") || mn || Ue("COLORTERM") !== null || (Ue("TERM") || "").includes("color")), j = Math.floor, Gt = Math.abs, je = (e, t) => e < t ? e : t, ht = (e, t) => e > t ? e : t, Mr = Math.pow, jn = (e) => e !== 0 ? e < 0 : 1 / e < 0, yn = 1, _n = 2, me = 4, ye = 8, Tt = 32, K = 64, T = 128, ce = 31, Te = 63, nt = 127, Ur = 2147483647, Jn = Number.MAX_SAFE_INTEGER, Tr = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && j(e) === e);
|
|
169
|
+
class Ft {
|
|
170
170
|
constructor() {
|
|
171
171
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
const M = () => new
|
|
174
|
+
const M = () => new Ft(), Je = (e) => {
|
|
175
175
|
let t = e.cpos;
|
|
176
176
|
for (let n = 0; n < e.bufs.length; n++)
|
|
177
177
|
t += e.bufs[n].length;
|
|
@@ -184,29 +184,29 @@ const M = () => new Ht(), Je = (e) => {
|
|
|
184
184
|
t.set(r, n), n += r.length;
|
|
185
185
|
}
|
|
186
186
|
return t.set(We(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
187
|
-
},
|
|
187
|
+
}, vr = (e, t) => {
|
|
188
188
|
const n = e.cbuf.length;
|
|
189
|
-
n - e.cpos < t && (e.bufs.push(We(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(
|
|
189
|
+
n - e.cpos < t && (e.bufs.push(We(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(ht(n, t) * 2), e.cpos = 0);
|
|
190
190
|
}, I = (e, t) => {
|
|
191
191
|
const n = e.cbuf.length;
|
|
192
192
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
193
|
-
},
|
|
194
|
-
for (; t >
|
|
195
|
-
I(e,
|
|
196
|
-
I(e,
|
|
193
|
+
}, ve = I, p = (e, t) => {
|
|
194
|
+
for (; t > nt; )
|
|
195
|
+
I(e, T | nt & t), t = j(t / 128);
|
|
196
|
+
I(e, nt & t);
|
|
197
197
|
}, Xe = (e, t) => {
|
|
198
|
-
const n =
|
|
199
|
-
for (n && (t = -t), I(e, (t > Te ?
|
|
200
|
-
I(e, (t >
|
|
201
|
-
},
|
|
202
|
-
if (t.length <
|
|
203
|
-
const n =
|
|
198
|
+
const n = jn(t);
|
|
199
|
+
for (n && (t = -t), I(e, (t > Te ? T : 0) | (n ? K : 0) | Te & t), t = j(t / 64); t > 0; )
|
|
200
|
+
I(e, (t > nt ? T : 0) | nt & t), t = j(t / 128);
|
|
201
|
+
}, Oe = new Uint8Array(3e4), Or = Oe.length / 3, Rr = (e, t) => {
|
|
202
|
+
if (t.length < Or) {
|
|
203
|
+
const n = Ut.encodeInto(t, Oe).written || 0;
|
|
204
204
|
p(e, n);
|
|
205
205
|
for (let s = 0; s < n; s++)
|
|
206
|
-
I(e,
|
|
206
|
+
I(e, Oe[s]);
|
|
207
207
|
} else
|
|
208
|
-
D(e,
|
|
209
|
-
},
|
|
208
|
+
D(e, fr(t));
|
|
209
|
+
}, Nr = (e, t) => {
|
|
210
210
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
211
211
|
p(e, s);
|
|
212
212
|
for (let r = 0; r < s; r++)
|
|
@@ -215,34 +215,34 @@ const M = () => new Ht(), Je = (e) => {
|
|
|
215
215
|
/** @type {number} */
|
|
216
216
|
n.codePointAt(r)
|
|
217
217
|
);
|
|
218
|
-
},
|
|
219
|
-
|
|
218
|
+
}, st = Ut && /** @type {any} */
|
|
219
|
+
Ut.encodeInto ? Rr : Nr, le = (e, t) => {
|
|
220
220
|
const n = e.cbuf.length, s = e.cpos, r = je(n - s, t.length), i = t.length - r;
|
|
221
|
-
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(
|
|
221
|
+
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(ht(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
222
222
|
}, D = (e, t) => {
|
|
223
|
-
p(e, t.byteLength),
|
|
223
|
+
p(e, t.byteLength), le(e, t);
|
|
224
224
|
}, Ye = (e, t) => {
|
|
225
|
-
|
|
225
|
+
vr(e, t);
|
|
226
226
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
227
227
|
return e.cpos += t, n;
|
|
228
|
-
},
|
|
228
|
+
}, Br = (e, t) => Ye(e, 4).setFloat32(0, t, !1), Vr = (e, t) => Ye(e, 8).setFloat64(0, t, !1), Fr = (e, t) => (
|
|
229
229
|
/** @type {any} */
|
|
230
230
|
Ye(e, 8).setBigInt64(0, t, !1)
|
|
231
|
-
),
|
|
231
|
+
), bn = new DataView(new ArrayBuffer(4)), Hr = (e) => (bn.setFloat32(0, e), bn.getFloat32(0) === e), vt = (e, t) => {
|
|
232
232
|
switch (typeof t) {
|
|
233
233
|
case "string":
|
|
234
|
-
I(e, 119),
|
|
234
|
+
I(e, 119), st(e, t);
|
|
235
235
|
break;
|
|
236
236
|
case "number":
|
|
237
|
-
|
|
237
|
+
Tr(t) && Gt(t) <= Ur ? (I(e, 125), Xe(e, t)) : Hr(t) ? (I(e, 124), Br(e, t)) : (I(e, 123), Vr(e, t));
|
|
238
238
|
break;
|
|
239
239
|
case "bigint":
|
|
240
|
-
I(e, 122),
|
|
240
|
+
I(e, 122), Fr(e, t);
|
|
241
241
|
break;
|
|
242
242
|
case "object":
|
|
243
243
|
if (t === null)
|
|
244
244
|
I(e, 126);
|
|
245
|
-
else if (
|
|
245
|
+
else if (ir(t)) {
|
|
246
246
|
I(e, 117), p(e, t.length);
|
|
247
247
|
for (let n = 0; n < t.length; n++)
|
|
248
248
|
vt(e, t[n]);
|
|
@@ -254,7 +254,7 @@ Tt.encodeInto ? Or : vr, ae = (e, t) => {
|
|
|
254
254
|
p(e, n.length);
|
|
255
255
|
for (let s = 0; s < n.length; s++) {
|
|
256
256
|
const r = n[s];
|
|
257
|
-
|
|
257
|
+
st(e, r), vt(e, t[r]);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
break;
|
|
@@ -265,7 +265,7 @@ Tt.encodeInto ? Or : vr, ae = (e, t) => {
|
|
|
265
265
|
I(e, 127);
|
|
266
266
|
}
|
|
267
267
|
};
|
|
268
|
-
class
|
|
268
|
+
class kn extends Ft {
|
|
269
269
|
/**
|
|
270
270
|
* @param {function(Encoder, T):void} writer
|
|
271
271
|
*/
|
|
@@ -279,24 +279,24 @@ class bn extends Ht {
|
|
|
279
279
|
this.s === t ? this.count++ : (this.count > 0 && p(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
280
280
|
}
|
|
281
281
|
}
|
|
282
|
-
const
|
|
282
|
+
const Sn = (e) => {
|
|
283
283
|
e.count > 0 && (Xe(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && p(e.encoder, e.count - 2));
|
|
284
284
|
};
|
|
285
|
-
class
|
|
285
|
+
class Wt {
|
|
286
286
|
constructor() {
|
|
287
|
-
this.encoder = new
|
|
287
|
+
this.encoder = new Ft(), this.s = 0, this.count = 0;
|
|
288
288
|
}
|
|
289
289
|
/**
|
|
290
290
|
* @param {number} v
|
|
291
291
|
*/
|
|
292
292
|
write(t) {
|
|
293
|
-
this.s === t ? this.count++ : (
|
|
293
|
+
this.s === t ? this.count++ : (Sn(this), this.count = 1, this.s = t);
|
|
294
294
|
}
|
|
295
295
|
toUint8Array() {
|
|
296
|
-
return
|
|
296
|
+
return Sn(this), S(this.encoder);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
const
|
|
299
|
+
const Dn = (e) => {
|
|
300
300
|
if (e.count > 0) {
|
|
301
301
|
const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
|
|
302
302
|
Xe(e.encoder, t), e.count > 1 && p(e.encoder, e.count - 2);
|
|
@@ -304,21 +304,21 @@ const Sn = (e) => {
|
|
|
304
304
|
};
|
|
305
305
|
class _e {
|
|
306
306
|
constructor() {
|
|
307
|
-
this.encoder = new
|
|
307
|
+
this.encoder = new Ft(), this.s = 0, this.count = 0, this.diff = 0;
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* @param {number} v
|
|
311
311
|
*/
|
|
312
312
|
write(t) {
|
|
313
|
-
this.diff === t - this.s ? (this.s = t, this.count++) : (
|
|
313
|
+
this.diff === t - this.s ? (this.s = t, this.count++) : (Dn(this), this.count = 1, this.diff = t - this.s, this.s = t);
|
|
314
314
|
}
|
|
315
315
|
toUint8Array() {
|
|
316
|
-
return
|
|
316
|
+
return Dn(this), S(this.encoder);
|
|
317
317
|
}
|
|
318
318
|
}
|
|
319
|
-
class
|
|
319
|
+
class $r {
|
|
320
320
|
constructor() {
|
|
321
|
-
this.sarr = [], this.s = "", this.lensE = new
|
|
321
|
+
this.sarr = [], this.s = "", this.lensE = new Wt();
|
|
322
322
|
}
|
|
323
323
|
/**
|
|
324
324
|
* @param {string} string
|
|
@@ -327,16 +327,16 @@ class Fr {
|
|
|
327
327
|
this.s += t, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(t.length);
|
|
328
328
|
}
|
|
329
329
|
toUint8Array() {
|
|
330
|
-
const t = new
|
|
331
|
-
return this.sarr.push(this.s), this.s = "",
|
|
330
|
+
const t = new Ft();
|
|
331
|
+
return this.sarr.push(this.s), this.s = "", st(t, this.sarr.join("")), le(t, this.lensE.toUint8Array()), S(t);
|
|
332
332
|
}
|
|
333
333
|
}
|
|
334
|
-
const
|
|
335
|
-
throw
|
|
336
|
-
},
|
|
337
|
-
throw
|
|
338
|
-
},
|
|
339
|
-
class
|
|
334
|
+
const ut = (e) => new Error(e), B = () => {
|
|
335
|
+
throw ut("Method unimplemented");
|
|
336
|
+
}, V = () => {
|
|
337
|
+
throw ut("Unexpected case");
|
|
338
|
+
}, Xn = ut("Unexpected end of array"), Yn = ut("Integer out of Range");
|
|
339
|
+
class ae {
|
|
340
340
|
/**
|
|
341
341
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
342
342
|
*/
|
|
@@ -344,42 +344,42 @@ class he {
|
|
|
344
344
|
this.arr = t, this.pos = 0;
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
const
|
|
347
|
+
const P = (e) => new ae(e), Kr = (e) => e.pos !== e.arr.length, jr = (e, t) => {
|
|
348
348
|
const n = We(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
349
349
|
return e.pos += t, n;
|
|
350
|
-
}, x = (e) =>
|
|
350
|
+
}, x = (e) => jr(e, w(e)), _t = (e) => e.arr[e.pos++], w = (e) => {
|
|
351
351
|
let t = 0, n = 1;
|
|
352
352
|
const s = e.arr.length;
|
|
353
353
|
for (; e.pos < s; ) {
|
|
354
354
|
const r = e.arr[e.pos++];
|
|
355
|
-
if (t = t + (r &
|
|
355
|
+
if (t = t + (r & nt) * n, n *= 128, r < T)
|
|
356
356
|
return t;
|
|
357
|
-
if (t >
|
|
358
|
-
throw
|
|
357
|
+
if (t > Jn)
|
|
358
|
+
throw Yn;
|
|
359
359
|
}
|
|
360
|
-
throw
|
|
360
|
+
throw Xn;
|
|
361
361
|
}, ze = (e) => {
|
|
362
362
|
let t = e.arr[e.pos++], n = t & Te, s = 64;
|
|
363
|
-
const r = (t &
|
|
364
|
-
if (!(t &
|
|
363
|
+
const r = (t & K) > 0 ? -1 : 1;
|
|
364
|
+
if (!(t & T))
|
|
365
365
|
return r * n;
|
|
366
366
|
const i = e.arr.length;
|
|
367
367
|
for (; e.pos < i; ) {
|
|
368
|
-
if (t = e.arr[e.pos++], n = n + (t &
|
|
368
|
+
if (t = e.arr[e.pos++], n = n + (t & nt) * s, s *= 128, t < T)
|
|
369
369
|
return r * n;
|
|
370
|
-
if (n >
|
|
371
|
-
throw
|
|
370
|
+
if (n > Jn)
|
|
371
|
+
throw Yn;
|
|
372
372
|
}
|
|
373
|
-
throw
|
|
374
|
-
},
|
|
375
|
-
let t =
|
|
373
|
+
throw Xn;
|
|
374
|
+
}, Jr = (e) => {
|
|
375
|
+
let t = w(e);
|
|
376
376
|
if (t === 0)
|
|
377
377
|
return "";
|
|
378
378
|
{
|
|
379
|
-
let n = String.fromCodePoint(
|
|
379
|
+
let n = String.fromCodePoint(_t(e));
|
|
380
380
|
if (--t < 100)
|
|
381
381
|
for (; t--; )
|
|
382
|
-
n += String.fromCodePoint(
|
|
382
|
+
n += String.fromCodePoint(_t(e));
|
|
383
383
|
else
|
|
384
384
|
for (; t > 0; ) {
|
|
385
385
|
const s = t < 1e4 ? t : 1e4, r = e.arr.subarray(e.pos, e.pos + s);
|
|
@@ -391,16 +391,16 @@ const Z = (e) => new he(e), Hr = (e) => e.pos !== e.arr.length, $r = (e, t) => {
|
|
|
391
391
|
}
|
|
392
392
|
return decodeURIComponent(escape(n));
|
|
393
393
|
}
|
|
394
|
-
},
|
|
394
|
+
}, Xr = (e) => (
|
|
395
395
|
/** @type any */
|
|
396
|
-
|
|
397
|
-
),
|
|
396
|
+
Lt.decode(x(e))
|
|
397
|
+
), q = Lt ? Xr : Jr, Ge = (e, t) => {
|
|
398
398
|
const n = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
|
|
399
399
|
return e.pos += t, n;
|
|
400
|
-
},
|
|
400
|
+
}, Yr = (e) => Ge(e, 4).getFloat32(0, !1), zr = (e) => Ge(e, 8).getFloat64(0, !1), Gr = (e) => (
|
|
401
401
|
/** @type {any} */
|
|
402
402
|
Ge(e, 8).getBigInt64(0, !1)
|
|
403
|
-
),
|
|
403
|
+
), Wr = [
|
|
404
404
|
(e) => {
|
|
405
405
|
},
|
|
406
406
|
// CASE 127: undefined
|
|
@@ -408,36 +408,36 @@ const Z = (e) => new he(e), Hr = (e) => e.pos !== e.arr.length, $r = (e, t) => {
|
|
|
408
408
|
// CASE 126: null
|
|
409
409
|
ze,
|
|
410
410
|
// CASE 125: integer
|
|
411
|
-
|
|
411
|
+
Yr,
|
|
412
412
|
// CASE 124: float32
|
|
413
|
-
|
|
413
|
+
zr,
|
|
414
414
|
// CASE 123: float64
|
|
415
|
-
|
|
415
|
+
Gr,
|
|
416
416
|
// CASE 122: bigint
|
|
417
417
|
(e) => !1,
|
|
418
418
|
// CASE 121: boolean (false)
|
|
419
419
|
(e) => !0,
|
|
420
420
|
// CASE 120: boolean (true)
|
|
421
|
-
|
|
421
|
+
q,
|
|
422
422
|
// CASE 119: string
|
|
423
423
|
(e) => {
|
|
424
|
-
const t =
|
|
424
|
+
const t = w(e), n = {};
|
|
425
425
|
for (let s = 0; s < t; s++) {
|
|
426
|
-
const r =
|
|
427
|
-
n[r] =
|
|
426
|
+
const r = q(e);
|
|
427
|
+
n[r] = Ot(e);
|
|
428
428
|
}
|
|
429
429
|
return n;
|
|
430
430
|
},
|
|
431
431
|
(e) => {
|
|
432
|
-
const t =
|
|
432
|
+
const t = w(e), n = [];
|
|
433
433
|
for (let s = 0; s < t; s++)
|
|
434
|
-
n.push(
|
|
434
|
+
n.push(Ot(e));
|
|
435
435
|
return n;
|
|
436
436
|
},
|
|
437
437
|
x
|
|
438
438
|
// CASE 116: Uint8Array
|
|
439
|
-
],
|
|
440
|
-
class
|
|
439
|
+
], Ot = (e) => Wr[127 - _t(e)](e);
|
|
440
|
+
class Cn extends ae {
|
|
441
441
|
/**
|
|
442
442
|
* @param {Uint8Array} uint8Array
|
|
443
443
|
* @param {function(Decoder):T} reader
|
|
@@ -446,11 +446,11 @@ class Dn extends he {
|
|
|
446
446
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
447
447
|
}
|
|
448
448
|
read() {
|
|
449
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
449
|
+
return this.count === 0 && (this.s = this.reader(this), Kr(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
450
450
|
this.s;
|
|
451
451
|
}
|
|
452
452
|
}
|
|
453
|
-
class
|
|
453
|
+
class qt extends ae {
|
|
454
454
|
/**
|
|
455
455
|
* @param {Uint8Array} uint8Array
|
|
456
456
|
*/
|
|
@@ -460,14 +460,14 @@ class Qt extends he {
|
|
|
460
460
|
read() {
|
|
461
461
|
if (this.count === 0) {
|
|
462
462
|
this.s = ze(this);
|
|
463
|
-
const t =
|
|
464
|
-
this.count = 1, t && (this.s = -this.s, this.count =
|
|
463
|
+
const t = jn(this.s);
|
|
464
|
+
this.count = 1, t && (this.s = -this.s, this.count = w(this) + 2);
|
|
465
465
|
}
|
|
466
466
|
return this.count--, /** @type {number} */
|
|
467
467
|
this.s;
|
|
468
468
|
}
|
|
469
469
|
}
|
|
470
|
-
class be extends
|
|
470
|
+
class be extends ae {
|
|
471
471
|
/**
|
|
472
472
|
* @param {Uint8Array} uint8Array
|
|
473
473
|
*/
|
|
@@ -480,17 +480,17 @@ class be extends he {
|
|
|
480
480
|
read() {
|
|
481
481
|
if (this.count === 0) {
|
|
482
482
|
const t = ze(this), n = t & 1;
|
|
483
|
-
this.diff =
|
|
483
|
+
this.diff = j(t / 2), this.count = 1, n && (this.count = w(this) + 2);
|
|
484
484
|
}
|
|
485
485
|
return this.s += this.diff, this.count--, this.s;
|
|
486
486
|
}
|
|
487
487
|
}
|
|
488
|
-
class
|
|
488
|
+
class qr {
|
|
489
489
|
/**
|
|
490
490
|
* @param {Uint8Array} uint8Array
|
|
491
491
|
*/
|
|
492
492
|
constructor(t) {
|
|
493
|
-
this.decoder = new
|
|
493
|
+
this.decoder = new qt(t), this.str = q(this.decoder), this.spos = 0;
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* @return {string}
|
|
@@ -500,63 +500,63 @@ class Gr {
|
|
|
500
500
|
return this.spos = t, n;
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
|
-
const
|
|
503
|
+
const zn = (e) => new Uint8Array(e), We = (e, t, n) => new Uint8Array(e, t, n), Qr = (e) => new Uint8Array(e), Zr = (e) => {
|
|
504
504
|
let t = "";
|
|
505
505
|
for (let n = 0; n < e.byteLength; n++)
|
|
506
|
-
t +=
|
|
506
|
+
t += or(e[n]);
|
|
507
507
|
return btoa(t);
|
|
508
|
-
},
|
|
509
|
-
const t = atob(e), n =
|
|
508
|
+
}, Pr = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), ti = (e) => {
|
|
509
|
+
const t = atob(e), n = zn(t.length);
|
|
510
510
|
for (let s = 0; s < t.length; s++)
|
|
511
511
|
n[s] = t.charCodeAt(s);
|
|
512
512
|
return n;
|
|
513
|
-
},
|
|
513
|
+
}, ei = (e) => {
|
|
514
514
|
const t = Buffer.from(e, "base64");
|
|
515
515
|
return new Uint8Array(t.buffer, t.byteOffset, t.byteLength);
|
|
516
|
-
},
|
|
517
|
-
const t =
|
|
516
|
+
}, ni = Kn ? Zr : Pr, si = Kn ? ti : ei, ri = (e) => {
|
|
517
|
+
const t = zn(e.byteLength);
|
|
518
518
|
return t.set(e), t;
|
|
519
|
-
},
|
|
520
|
-
class
|
|
519
|
+
}, Gn = /* @__PURE__ */ new Map();
|
|
520
|
+
class ii {
|
|
521
521
|
/**
|
|
522
522
|
* @param {string} room
|
|
523
523
|
*/
|
|
524
524
|
constructor(t) {
|
|
525
|
-
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data:
|
|
525
|
+
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: si(n.newValue || "") }), pr(this._onChange);
|
|
526
526
|
}
|
|
527
527
|
/**
|
|
528
528
|
* @param {ArrayBuffer} buf
|
|
529
529
|
*/
|
|
530
530
|
postMessage(t) {
|
|
531
|
-
|
|
531
|
+
Hn.setItem(this.room, ni(Qr(t)));
|
|
532
532
|
}
|
|
533
533
|
close() {
|
|
534
|
-
|
|
534
|
+
wr(this._onChange);
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
const
|
|
538
|
-
const t =
|
|
537
|
+
const oi = typeof BroadcastChannel > "u" ? ii : BroadcastChannel, qe = (e) => J(Gn, e, () => {
|
|
538
|
+
const t = rt(), n = new oi(e);
|
|
539
539
|
return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
540
540
|
bc: n,
|
|
541
541
|
subs: t
|
|
542
542
|
};
|
|
543
|
-
}),
|
|
543
|
+
}), ci = (e, t) => (qe(e).subs.add(t), t), li = (e, t) => {
|
|
544
544
|
const n = qe(e), s = n.subs.delete(t);
|
|
545
|
-
return s && n.subs.size === 0 && (n.bc.close(),
|
|
545
|
+
return s && n.subs.size === 0 && (n.bc.close(), Gn.delete(e)), s;
|
|
546
546
|
}, gt = (e, t, n = null) => {
|
|
547
547
|
const s = qe(e);
|
|
548
548
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
|
|
549
|
-
},
|
|
550
|
-
class
|
|
549
|
+
}, it = Date.now;
|
|
550
|
+
class he {
|
|
551
551
|
constructor() {
|
|
552
|
-
this._observers =
|
|
552
|
+
this._observers = R();
|
|
553
553
|
}
|
|
554
554
|
/**
|
|
555
555
|
* @param {N} name
|
|
556
556
|
* @param {function} f
|
|
557
557
|
*/
|
|
558
558
|
on(t, n) {
|
|
559
|
-
|
|
559
|
+
J(this._observers, t, rt).add(n);
|
|
560
560
|
}
|
|
561
561
|
/**
|
|
562
562
|
* @param {N} name
|
|
@@ -586,22 +586,22 @@ class ue {
|
|
|
586
586
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
587
587
|
*/
|
|
588
588
|
emit(t, n) {
|
|
589
|
-
return
|
|
589
|
+
return Q((this._observers.get(t) || R()).values()).forEach((s) => s(...n));
|
|
590
590
|
}
|
|
591
591
|
destroy() {
|
|
592
|
-
this._observers =
|
|
592
|
+
this._observers = R();
|
|
593
593
|
}
|
|
594
594
|
}
|
|
595
|
-
const
|
|
595
|
+
const ai = crypto.getRandomValues.bind(crypto), Wn = () => ai(new Uint32Array(1))[0], hi = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, ui = () => hi.replace(
|
|
596
596
|
/[018]/g,
|
|
597
597
|
/** @param {number} c */
|
|
598
|
-
(e) => (e ^
|
|
599
|
-
),
|
|
598
|
+
(e) => (e ^ Wn() & 15 >> e / 4).toString(16)
|
|
599
|
+
), bt = (e) => (
|
|
600
600
|
/** @type {Promise<T>} */
|
|
601
601
|
new Promise(e)
|
|
602
602
|
);
|
|
603
603
|
Promise.all.bind(Promise);
|
|
604
|
-
class
|
|
604
|
+
class di {
|
|
605
605
|
/**
|
|
606
606
|
* @param {L} left
|
|
607
607
|
* @param {R} right
|
|
@@ -610,9 +610,9 @@ class hi {
|
|
|
610
610
|
this.left = t, this.right = n;
|
|
611
611
|
}
|
|
612
612
|
}
|
|
613
|
-
const
|
|
613
|
+
const $ = (e, t) => new di(e, t);
|
|
614
614
|
typeof DOMParser < "u" && new DOMParser();
|
|
615
|
-
const
|
|
615
|
+
const fi = (e) => nr(e, (t, n) => `${n}:${t};`).join(""), X = Symbol, qn = X(), Qn = X(), gi = X(), pi = X(), wi = X(), Zn = X(), mi = X(), Pn = X(), yi = X(), _i = (e) => {
|
|
616
616
|
const t = [];
|
|
617
617
|
let n = 0;
|
|
618
618
|
for (; n < e.length; n++) {
|
|
@@ -620,26 +620,26 @@ const ui = (e) => tr(e, (t, n) => `${n}:${t};`).join(""), J = Symbol, Wn = J(),
|
|
|
620
620
|
s.constructor === String || s.constructor === Number || s.constructor === Object && t.push(JSON.stringify(s));
|
|
621
621
|
}
|
|
622
622
|
return t;
|
|
623
|
-
},
|
|
624
|
-
[
|
|
625
|
-
[
|
|
626
|
-
[
|
|
627
|
-
[
|
|
628
|
-
[
|
|
629
|
-
[
|
|
630
|
-
[
|
|
631
|
-
[
|
|
623
|
+
}, bi = {
|
|
624
|
+
[qn]: $("font-weight", "bold"),
|
|
625
|
+
[Qn]: $("font-weight", "normal"),
|
|
626
|
+
[gi]: $("color", "blue"),
|
|
627
|
+
[wi]: $("color", "green"),
|
|
628
|
+
[pi]: $("color", "grey"),
|
|
629
|
+
[Zn]: $("color", "red"),
|
|
630
|
+
[mi]: $("color", "purple"),
|
|
631
|
+
[Pn]: $("color", "orange"),
|
|
632
632
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
633
|
-
[
|
|
634
|
-
},
|
|
635
|
-
const t = [], n = [], s =
|
|
633
|
+
[yi]: $("color", "black")
|
|
634
|
+
}, ki = (e) => {
|
|
635
|
+
const t = [], n = [], s = R();
|
|
636
636
|
let r = [], i = 0;
|
|
637
637
|
for (; i < e.length; i++) {
|
|
638
|
-
const o = e[i], c =
|
|
638
|
+
const o = e[i], c = bi[o];
|
|
639
639
|
if (c !== void 0)
|
|
640
640
|
s.set(c.left, c.right);
|
|
641
641
|
else if (o.constructor === String || o.constructor === Number) {
|
|
642
|
-
const l =
|
|
642
|
+
const l = fi(s);
|
|
643
643
|
i > 0 || l.length > 0 ? (t.push("%c" + o), n.push(l)) : t.push(o);
|
|
644
644
|
} else
|
|
645
645
|
break;
|
|
@@ -649,9 +649,9 @@ const ui = (e) => tr(e, (t, n) => `${n}:${t};`).join(""), J = Symbol, Wn = J(),
|
|
|
649
649
|
o instanceof Symbol || r.push(o);
|
|
650
650
|
}
|
|
651
651
|
return r;
|
|
652
|
-
},
|
|
653
|
-
console.log(...
|
|
654
|
-
},
|
|
652
|
+
}, Si = xr ? ki : _i, Di = (...e) => {
|
|
653
|
+
console.log(...Si(e)), Ci.forEach((t) => t.print(e));
|
|
654
|
+
}, Ci = rt(), ts = (e) => ({
|
|
655
655
|
/**
|
|
656
656
|
* @return {IterableIterator<T>}
|
|
657
657
|
*/
|
|
@@ -660,13 +660,13 @@ const ui = (e) => tr(e, (t, n) => `${n}:${t};`).join(""), J = Symbol, Wn = J(),
|
|
|
660
660
|
},
|
|
661
661
|
// @ts-ignore
|
|
662
662
|
next: e
|
|
663
|
-
}),
|
|
663
|
+
}), Ei = (e, t) => ts(() => {
|
|
664
664
|
let n;
|
|
665
665
|
do
|
|
666
666
|
n = e.next();
|
|
667
667
|
while (!n.done && !t(n.value));
|
|
668
668
|
return n;
|
|
669
|
-
}), ke = (e, t) =>
|
|
669
|
+
}), ke = (e, t) => ts(() => {
|
|
670
670
|
const { done: n, value: s } = e.next();
|
|
671
671
|
return { done: n, value: n ? void 0 : t(s) };
|
|
672
672
|
});
|
|
@@ -679,24 +679,24 @@ class Qe {
|
|
|
679
679
|
this.clock = t, this.len = n;
|
|
680
680
|
}
|
|
681
681
|
}
|
|
682
|
-
class
|
|
682
|
+
class Ht {
|
|
683
683
|
constructor() {
|
|
684
684
|
this.clients = /* @__PURE__ */ new Map();
|
|
685
685
|
}
|
|
686
686
|
}
|
|
687
|
-
const
|
|
687
|
+
const es = (e, t, n) => t.clients.forEach((s, r) => {
|
|
688
688
|
const i = (
|
|
689
689
|
/** @type {Array<GC|Item>} */
|
|
690
690
|
e.doc.store.clients.get(r)
|
|
691
691
|
);
|
|
692
692
|
for (let o = 0; o < s.length; o++) {
|
|
693
693
|
const c = s[o];
|
|
694
|
-
|
|
694
|
+
ps(e, i, c.clock, c.len, n);
|
|
695
695
|
}
|
|
696
|
-
}),
|
|
696
|
+
}), Ii = (e, t) => {
|
|
697
697
|
let n = 0, s = e.length - 1;
|
|
698
698
|
for (; n <= s; ) {
|
|
699
|
-
const r =
|
|
699
|
+
const r = j((n + s) / 2), i = e[r], o = i.clock;
|
|
700
700
|
if (o <= t) {
|
|
701
701
|
if (t < o + i.len)
|
|
702
702
|
return r;
|
|
@@ -705,38 +705,38 @@ const ts = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
705
705
|
s = r - 1;
|
|
706
706
|
}
|
|
707
707
|
return null;
|
|
708
|
-
},
|
|
708
|
+
}, ns = (e, t) => {
|
|
709
709
|
const n = e.clients.get(t.client);
|
|
710
|
-
return n !== void 0 &&
|
|
710
|
+
return n !== void 0 && Ii(n, t.clock) !== null;
|
|
711
711
|
}, Ze = (e) => {
|
|
712
712
|
e.clients.forEach((t) => {
|
|
713
713
|
t.sort((r, i) => r.clock - i.clock);
|
|
714
714
|
let n, s;
|
|
715
715
|
for (n = 1, s = 1; n < t.length; n++) {
|
|
716
716
|
const r = t[s - 1], i = t[n];
|
|
717
|
-
r.clock + r.len >= i.clock ? r.len =
|
|
717
|
+
r.clock + r.len >= i.clock ? r.len = ht(r.len, i.clock + i.len - r.clock) : (s < n && (t[s] = i), s++);
|
|
718
718
|
}
|
|
719
719
|
t.length = s;
|
|
720
720
|
});
|
|
721
|
-
},
|
|
722
|
-
const t = new
|
|
721
|
+
}, Ai = (e) => {
|
|
722
|
+
const t = new Ht();
|
|
723
723
|
for (let n = 0; n < e.length; n++)
|
|
724
724
|
e[n].clients.forEach((s, r) => {
|
|
725
725
|
if (!t.clients.has(r)) {
|
|
726
726
|
const i = s.slice();
|
|
727
727
|
for (let o = n + 1; o < e.length; o++)
|
|
728
|
-
|
|
728
|
+
rr(i, e[o].clients.get(r) || []);
|
|
729
729
|
t.clients.set(r, i);
|
|
730
730
|
}
|
|
731
731
|
});
|
|
732
732
|
return Ze(t), t;
|
|
733
|
-
},
|
|
734
|
-
|
|
733
|
+
}, Pt = (e, t, n, s) => {
|
|
734
|
+
J(e.clients, t, () => (
|
|
735
735
|
/** @type {Array<DeleteItem>} */
|
|
736
736
|
[]
|
|
737
737
|
)).push(new Qe(n, s));
|
|
738
|
-
},
|
|
739
|
-
const t =
|
|
738
|
+
}, Li = () => new Ht(), xi = (e) => {
|
|
739
|
+
const t = Li();
|
|
740
740
|
return e.clients.forEach((n, s) => {
|
|
741
741
|
const r = [];
|
|
742
742
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -752,8 +752,8 @@ const ts = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
752
752
|
}
|
|
753
753
|
r.length > 0 && t.clients.set(s, r);
|
|
754
754
|
}), t;
|
|
755
|
-
},
|
|
756
|
-
p(e.restEncoder, t.clients.size),
|
|
755
|
+
}, Dt = (e, t) => {
|
|
756
|
+
p(e.restEncoder, t.clients.size), Q(t.clients.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
757
757
|
e.resetDsCurVal(), p(e.restEncoder, n);
|
|
758
758
|
const r = s.length;
|
|
759
759
|
p(e.restEncoder, r);
|
|
@@ -763,12 +763,12 @@ const ts = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
763
763
|
}
|
|
764
764
|
});
|
|
765
765
|
}, Pe = (e) => {
|
|
766
|
-
const t = new
|
|
766
|
+
const t = new Ht(), n = w(e.restDecoder);
|
|
767
767
|
for (let s = 0; s < n; s++) {
|
|
768
768
|
e.resetDsCurVal();
|
|
769
|
-
const r =
|
|
769
|
+
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
770
770
|
if (i > 0) {
|
|
771
|
-
const o =
|
|
771
|
+
const o = J(t.clients, r, () => (
|
|
772
772
|
/** @type {Array<DeleteItem>} */
|
|
773
773
|
[]
|
|
774
774
|
));
|
|
@@ -777,39 +777,39 @@ const ts = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
777
777
|
}
|
|
778
778
|
}
|
|
779
779
|
return t;
|
|
780
|
-
},
|
|
781
|
-
const s = new
|
|
780
|
+
}, En = (e, t, n) => {
|
|
781
|
+
const s = new Ht(), r = w(e.restDecoder);
|
|
782
782
|
for (let i = 0; i < r; i++) {
|
|
783
783
|
e.resetDsCurVal();
|
|
784
|
-
const o =
|
|
784
|
+
const o = w(e.restDecoder), c = w(e.restDecoder), l = n.clients.get(o) || [], a = A(n, o);
|
|
785
785
|
for (let h = 0; h < c; h++) {
|
|
786
786
|
const u = e.readDsClock(), d = u + e.readDsLen();
|
|
787
787
|
if (u < a) {
|
|
788
|
-
a < d &&
|
|
789
|
-
let f =
|
|
790
|
-
for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0,
|
|
791
|
-
g.deleted || (d < g.id.clock + g.length && l.splice(f, 0,
|
|
788
|
+
a < d && Pt(s, o, a, d - a);
|
|
789
|
+
let f = F(l, u), g = l[f];
|
|
790
|
+
for (!g.deleted && g.id.clock < u && (l.splice(f + 1, 0, oe(t, g, u - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < d); )
|
|
791
|
+
g.deleted || (d < g.id.clock + g.length && l.splice(f, 0, oe(t, g, d - g.id.clock)), g.delete(t));
|
|
792
792
|
} else
|
|
793
|
-
|
|
793
|
+
Pt(s, o, u, d - u);
|
|
794
794
|
}
|
|
795
795
|
}
|
|
796
796
|
if (s.clients.size > 0) {
|
|
797
|
-
const i = new
|
|
798
|
-
return p(i.restEncoder, 0),
|
|
797
|
+
const i = new ot();
|
|
798
|
+
return p(i.restEncoder, 0), Dt(i, s), i.toUint8Array();
|
|
799
799
|
}
|
|
800
800
|
return null;
|
|
801
|
-
},
|
|
802
|
-
class
|
|
801
|
+
}, ss = Wn;
|
|
802
|
+
class Ct extends he {
|
|
803
803
|
/**
|
|
804
804
|
* @param {DocOpts} opts configuration
|
|
805
805
|
*/
|
|
806
|
-
constructor({ guid: t =
|
|
807
|
-
super(), this.gc = s, this.gcFilter = r, this.clientID =
|
|
806
|
+
constructor({ guid: t = ui(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
807
|
+
super(), this.gc = s, this.gcFilter = r, this.clientID = ss(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new fs(), 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 = bt((a) => {
|
|
808
808
|
this.on("load", () => {
|
|
809
809
|
this.isLoaded = !0, a(this);
|
|
810
810
|
});
|
|
811
811
|
});
|
|
812
|
-
const l = () =>
|
|
812
|
+
const l = () => bt((a) => {
|
|
813
813
|
const h = (u) => {
|
|
814
814
|
(u === void 0 || u === !0) && (this.off("sync", h), a());
|
|
815
815
|
};
|
|
@@ -842,7 +842,7 @@ class Et extends ue {
|
|
|
842
842
|
return this.subdocs;
|
|
843
843
|
}
|
|
844
844
|
getSubdocGuids() {
|
|
845
|
-
return new Set(
|
|
845
|
+
return new Set(Q(this.subdocs).map((t) => t.guid));
|
|
846
846
|
}
|
|
847
847
|
/**
|
|
848
848
|
* Changes that happen inside of a transaction are bundled. This means that
|
|
@@ -887,7 +887,7 @@ class Et extends ue {
|
|
|
887
887
|
* @public
|
|
888
888
|
*/
|
|
889
889
|
get(t, n = L) {
|
|
890
|
-
const s =
|
|
890
|
+
const s = J(this.share, t, () => {
|
|
891
891
|
const i = new n();
|
|
892
892
|
return i._integrate(this, null), i;
|
|
893
893
|
}), r = s.constructor;
|
|
@@ -916,7 +916,7 @@ class Et extends ue {
|
|
|
916
916
|
* @public
|
|
917
917
|
*/
|
|
918
918
|
getArray(t = "") {
|
|
919
|
-
return this.get(t,
|
|
919
|
+
return this.get(t, wt);
|
|
920
920
|
}
|
|
921
921
|
/**
|
|
922
922
|
* @param {string} [name]
|
|
@@ -925,7 +925,7 @@ class Et extends ue {
|
|
|
925
925
|
* @public
|
|
926
926
|
*/
|
|
927
927
|
getText(t = "") {
|
|
928
|
-
return this.get(t,
|
|
928
|
+
return this.get(t, St);
|
|
929
929
|
}
|
|
930
930
|
/**
|
|
931
931
|
* @template T
|
|
@@ -935,7 +935,7 @@ class Et extends ue {
|
|
|
935
935
|
* @public
|
|
936
936
|
*/
|
|
937
937
|
getMap(t = "") {
|
|
938
|
-
return this.get(t,
|
|
938
|
+
return this.get(t, ct);
|
|
939
939
|
}
|
|
940
940
|
/**
|
|
941
941
|
* @param {string} [name]
|
|
@@ -944,7 +944,7 @@ class Et extends ue {
|
|
|
944
944
|
* @public
|
|
945
945
|
*/
|
|
946
946
|
getXmlFragment(t = "") {
|
|
947
|
-
return this.get(t,
|
|
947
|
+
return this.get(t, lt);
|
|
948
948
|
}
|
|
949
949
|
/**
|
|
950
950
|
* Converts the entire document into a js object, recursively traversing each yjs type
|
|
@@ -964,7 +964,7 @@ class Et extends ue {
|
|
|
964
964
|
* Emit `destroy` event and unregister all event handlers.
|
|
965
965
|
*/
|
|
966
966
|
destroy() {
|
|
967
|
-
|
|
967
|
+
Q(this.subdocs).forEach((n) => n.destroy());
|
|
968
968
|
const t = this._item;
|
|
969
969
|
if (t !== null) {
|
|
970
970
|
this._item = null;
|
|
@@ -972,7 +972,7 @@ class Et extends ue {
|
|
|
972
972
|
/** @type {ContentDoc} */
|
|
973
973
|
t.content
|
|
974
974
|
);
|
|
975
|
-
n.doc = new
|
|
975
|
+
n.doc = new Ct({ guid: this.guid, ...n.opts, shouldLoad: !1 }), n.doc._item = t, b(
|
|
976
976
|
/** @type {any} */
|
|
977
977
|
t.parent.doc,
|
|
978
978
|
(s) => {
|
|
@@ -1000,7 +1000,7 @@ class Et extends ue {
|
|
|
1000
1000
|
super.off(t, n);
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
|
-
class
|
|
1003
|
+
class rs {
|
|
1004
1004
|
/**
|
|
1005
1005
|
* @param {decoding.Decoder} decoder
|
|
1006
1006
|
*/
|
|
@@ -1013,58 +1013,58 @@ class ss {
|
|
|
1013
1013
|
* @return {number}
|
|
1014
1014
|
*/
|
|
1015
1015
|
readDsClock() {
|
|
1016
|
-
return
|
|
1016
|
+
return w(this.restDecoder);
|
|
1017
1017
|
}
|
|
1018
1018
|
/**
|
|
1019
1019
|
* @return {number}
|
|
1020
1020
|
*/
|
|
1021
1021
|
readDsLen() {
|
|
1022
|
-
return
|
|
1022
|
+
return w(this.restDecoder);
|
|
1023
1023
|
}
|
|
1024
1024
|
}
|
|
1025
|
-
class
|
|
1025
|
+
class is extends rs {
|
|
1026
1026
|
/**
|
|
1027
1027
|
* @return {ID}
|
|
1028
1028
|
*/
|
|
1029
1029
|
readLeftID() {
|
|
1030
|
-
return y(
|
|
1030
|
+
return y(w(this.restDecoder), w(this.restDecoder));
|
|
1031
1031
|
}
|
|
1032
1032
|
/**
|
|
1033
1033
|
* @return {ID}
|
|
1034
1034
|
*/
|
|
1035
1035
|
readRightID() {
|
|
1036
|
-
return y(
|
|
1036
|
+
return y(w(this.restDecoder), w(this.restDecoder));
|
|
1037
1037
|
}
|
|
1038
1038
|
/**
|
|
1039
1039
|
* Read the next client id.
|
|
1040
1040
|
* Use this in favor of readID whenever possible to reduce the number of objects created.
|
|
1041
1041
|
*/
|
|
1042
1042
|
readClient() {
|
|
1043
|
-
return
|
|
1043
|
+
return w(this.restDecoder);
|
|
1044
1044
|
}
|
|
1045
1045
|
/**
|
|
1046
1046
|
* @return {number} info An unsigned 8-bit integer
|
|
1047
1047
|
*/
|
|
1048
1048
|
readInfo() {
|
|
1049
|
-
return
|
|
1049
|
+
return _t(this.restDecoder);
|
|
1050
1050
|
}
|
|
1051
1051
|
/**
|
|
1052
1052
|
* @return {string}
|
|
1053
1053
|
*/
|
|
1054
1054
|
readString() {
|
|
1055
|
-
return
|
|
1055
|
+
return q(this.restDecoder);
|
|
1056
1056
|
}
|
|
1057
1057
|
/**
|
|
1058
1058
|
* @return {boolean} isKey
|
|
1059
1059
|
*/
|
|
1060
1060
|
readParentInfo() {
|
|
1061
|
-
return
|
|
1061
|
+
return w(this.restDecoder) === 1;
|
|
1062
1062
|
}
|
|
1063
1063
|
/**
|
|
1064
1064
|
* @return {number} info An unsigned 8-bit integer
|
|
1065
1065
|
*/
|
|
1066
1066
|
readTypeRef() {
|
|
1067
|
-
return
|
|
1067
|
+
return w(this.restDecoder);
|
|
1068
1068
|
}
|
|
1069
1069
|
/**
|
|
1070
1070
|
* Write len of a struct - well suited for Opt RLE encoder.
|
|
@@ -1072,19 +1072,19 @@ class rs extends ss {
|
|
|
1072
1072
|
* @return {number} len
|
|
1073
1073
|
*/
|
|
1074
1074
|
readLen() {
|
|
1075
|
-
return
|
|
1075
|
+
return w(this.restDecoder);
|
|
1076
1076
|
}
|
|
1077
1077
|
/**
|
|
1078
1078
|
* @return {any}
|
|
1079
1079
|
*/
|
|
1080
1080
|
readAny() {
|
|
1081
|
-
return
|
|
1081
|
+
return Ot(this.restDecoder);
|
|
1082
1082
|
}
|
|
1083
1083
|
/**
|
|
1084
1084
|
* @return {Uint8Array}
|
|
1085
1085
|
*/
|
|
1086
1086
|
readBuf() {
|
|
1087
|
-
return
|
|
1087
|
+
return ri(x(this.restDecoder));
|
|
1088
1088
|
}
|
|
1089
1089
|
/**
|
|
1090
1090
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1092,16 +1092,16 @@ class rs extends ss {
|
|
|
1092
1092
|
* @return {any}
|
|
1093
1093
|
*/
|
|
1094
1094
|
readJSON() {
|
|
1095
|
-
return JSON.parse(
|
|
1095
|
+
return JSON.parse(q(this.restDecoder));
|
|
1096
1096
|
}
|
|
1097
1097
|
/**
|
|
1098
1098
|
* @return {string}
|
|
1099
1099
|
*/
|
|
1100
1100
|
readKey() {
|
|
1101
|
-
return
|
|
1101
|
+
return q(this.restDecoder);
|
|
1102
1102
|
}
|
|
1103
1103
|
}
|
|
1104
|
-
class
|
|
1104
|
+
class Mi {
|
|
1105
1105
|
/**
|
|
1106
1106
|
* @param {decoding.Decoder} decoder
|
|
1107
1107
|
*/
|
|
@@ -1115,34 +1115,34 @@ class Li {
|
|
|
1115
1115
|
* @return {number}
|
|
1116
1116
|
*/
|
|
1117
1117
|
readDsClock() {
|
|
1118
|
-
return this.dsCurrVal +=
|
|
1118
|
+
return this.dsCurrVal += w(this.restDecoder), this.dsCurrVal;
|
|
1119
1119
|
}
|
|
1120
1120
|
/**
|
|
1121
1121
|
* @return {number}
|
|
1122
1122
|
*/
|
|
1123
1123
|
readDsLen() {
|
|
1124
|
-
const t =
|
|
1124
|
+
const t = w(this.restDecoder) + 1;
|
|
1125
1125
|
return this.dsCurrVal += t, t;
|
|
1126
1126
|
}
|
|
1127
1127
|
}
|
|
1128
|
-
class
|
|
1128
|
+
class kt extends Mi {
|
|
1129
1129
|
/**
|
|
1130
1130
|
* @param {decoding.Decoder} decoder
|
|
1131
1131
|
*/
|
|
1132
1132
|
constructor(t) {
|
|
1133
|
-
super(t), this.keys = [],
|
|
1133
|
+
super(t), this.keys = [], w(t), this.keyClockDecoder = new be(x(t)), this.clientDecoder = new qt(x(t)), this.leftClockDecoder = new be(x(t)), this.rightClockDecoder = new be(x(t)), this.infoDecoder = new Cn(x(t), _t), this.stringDecoder = new qr(x(t)), this.parentInfoDecoder = new Cn(x(t), _t), this.typeRefDecoder = new qt(x(t)), this.lenDecoder = new qt(x(t));
|
|
1134
1134
|
}
|
|
1135
1135
|
/**
|
|
1136
1136
|
* @return {ID}
|
|
1137
1137
|
*/
|
|
1138
1138
|
readLeftID() {
|
|
1139
|
-
return new
|
|
1139
|
+
return new pt(this.clientDecoder.read(), this.leftClockDecoder.read());
|
|
1140
1140
|
}
|
|
1141
1141
|
/**
|
|
1142
1142
|
* @return {ID}
|
|
1143
1143
|
*/
|
|
1144
1144
|
readRightID() {
|
|
1145
|
-
return new
|
|
1145
|
+
return new pt(this.clientDecoder.read(), this.rightClockDecoder.read());
|
|
1146
1146
|
}
|
|
1147
1147
|
/**
|
|
1148
1148
|
* Read the next client id.
|
|
@@ -1190,7 +1190,7 @@ class St extends Li {
|
|
|
1190
1190
|
* @return {any}
|
|
1191
1191
|
*/
|
|
1192
1192
|
readAny() {
|
|
1193
|
-
return
|
|
1193
|
+
return Ot(this.restDecoder);
|
|
1194
1194
|
}
|
|
1195
1195
|
/**
|
|
1196
1196
|
* @return {Uint8Array}
|
|
@@ -1206,7 +1206,7 @@ class St extends Li {
|
|
|
1206
1206
|
* @return {any}
|
|
1207
1207
|
*/
|
|
1208
1208
|
readJSON() {
|
|
1209
|
-
return
|
|
1209
|
+
return Ot(this.restDecoder);
|
|
1210
1210
|
}
|
|
1211
1211
|
/**
|
|
1212
1212
|
* @return {string}
|
|
@@ -1221,7 +1221,7 @@ class St extends Li {
|
|
|
1221
1221
|
}
|
|
1222
1222
|
}
|
|
1223
1223
|
}
|
|
1224
|
-
class
|
|
1224
|
+
class os {
|
|
1225
1225
|
constructor() {
|
|
1226
1226
|
this.restEncoder = M();
|
|
1227
1227
|
}
|
|
@@ -1243,7 +1243,7 @@ class is {
|
|
|
1243
1243
|
p(this.restEncoder, t);
|
|
1244
1244
|
}
|
|
1245
1245
|
}
|
|
1246
|
-
class
|
|
1246
|
+
class $t extends os {
|
|
1247
1247
|
/**
|
|
1248
1248
|
* @param {ID} id
|
|
1249
1249
|
*/
|
|
@@ -1267,13 +1267,13 @@ class Kt extends is {
|
|
|
1267
1267
|
* @param {number} info An unsigned 8-bit integer
|
|
1268
1268
|
*/
|
|
1269
1269
|
writeInfo(t) {
|
|
1270
|
-
|
|
1270
|
+
ve(this.restEncoder, t);
|
|
1271
1271
|
}
|
|
1272
1272
|
/**
|
|
1273
1273
|
* @param {string} s
|
|
1274
1274
|
*/
|
|
1275
1275
|
writeString(t) {
|
|
1276
|
-
|
|
1276
|
+
st(this.restEncoder, t);
|
|
1277
1277
|
}
|
|
1278
1278
|
/**
|
|
1279
1279
|
* @param {boolean} isYKey
|
|
@@ -1311,16 +1311,16 @@ class Kt extends is {
|
|
|
1311
1311
|
* @param {any} embed
|
|
1312
1312
|
*/
|
|
1313
1313
|
writeJSON(t) {
|
|
1314
|
-
|
|
1314
|
+
st(this.restEncoder, JSON.stringify(t));
|
|
1315
1315
|
}
|
|
1316
1316
|
/**
|
|
1317
1317
|
* @param {string} key
|
|
1318
1318
|
*/
|
|
1319
1319
|
writeKey(t) {
|
|
1320
|
-
|
|
1320
|
+
st(this.restEncoder, t);
|
|
1321
1321
|
}
|
|
1322
1322
|
}
|
|
1323
|
-
class
|
|
1323
|
+
class cs {
|
|
1324
1324
|
constructor() {
|
|
1325
1325
|
this.restEncoder = M(), this.dsCurrVal = 0;
|
|
1326
1326
|
}
|
|
@@ -1341,16 +1341,16 @@ class os {
|
|
|
1341
1341
|
* @param {number} len
|
|
1342
1342
|
*/
|
|
1343
1343
|
writeDsLen(t) {
|
|
1344
|
-
t === 0 &&
|
|
1344
|
+
t === 0 && V(), p(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
1345
1345
|
}
|
|
1346
1346
|
}
|
|
1347
|
-
class
|
|
1347
|
+
class ot extends cs {
|
|
1348
1348
|
constructor() {
|
|
1349
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new _e(), this.clientEncoder = new
|
|
1349
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new _e(), this.clientEncoder = new Wt(), this.leftClockEncoder = new _e(), this.rightClockEncoder = new _e(), this.infoEncoder = new kn(ve), this.stringEncoder = new $r(), this.parentInfoEncoder = new kn(ve), this.typeRefEncoder = new Wt(), this.lenEncoder = new Wt();
|
|
1350
1350
|
}
|
|
1351
1351
|
toUint8Array() {
|
|
1352
1352
|
const t = M();
|
|
1353
|
-
return p(t, 0), D(t, this.keyClockEncoder.toUint8Array()), D(t, this.clientEncoder.toUint8Array()), D(t, this.leftClockEncoder.toUint8Array()), D(t, this.rightClockEncoder.toUint8Array()), D(t, S(this.infoEncoder)), D(t, this.stringEncoder.toUint8Array()), D(t, S(this.parentInfoEncoder)), D(t, this.typeRefEncoder.toUint8Array()), D(t, this.lenEncoder.toUint8Array()),
|
|
1353
|
+
return p(t, 0), D(t, this.keyClockEncoder.toUint8Array()), D(t, this.clientEncoder.toUint8Array()), D(t, this.leftClockEncoder.toUint8Array()), D(t, this.rightClockEncoder.toUint8Array()), D(t, S(this.infoEncoder)), D(t, this.stringEncoder.toUint8Array()), D(t, S(this.parentInfoEncoder)), D(t, this.typeRefEncoder.toUint8Array()), D(t, this.lenEncoder.toUint8Array()), le(t, S(this.restEncoder)), S(t);
|
|
1354
1354
|
}
|
|
1355
1355
|
/**
|
|
1356
1356
|
* @param {ID} id
|
|
@@ -1437,9 +1437,9 @@ class rt extends os {
|
|
|
1437
1437
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
|
-
const
|
|
1441
|
-
s =
|
|
1442
|
-
const r =
|
|
1440
|
+
const Ui = (e, t, n, s) => {
|
|
1441
|
+
s = ht(s, t[0].id.clock);
|
|
1442
|
+
const r = F(t, s);
|
|
1443
1443
|
p(e.restEncoder, t.length - r), e.writeClient(n), p(e.restEncoder, s);
|
|
1444
1444
|
const i = t[r];
|
|
1445
1445
|
i.write(e, s - i.id.clock);
|
|
@@ -1449,10 +1449,10 @@ const xi = (e, t, n, s) => {
|
|
|
1449
1449
|
const s = /* @__PURE__ */ new Map();
|
|
1450
1450
|
n.forEach((r, i) => {
|
|
1451
1451
|
A(t, i) > r && s.set(i, r);
|
|
1452
|
-
}),
|
|
1452
|
+
}), ue(t).forEach((r, i) => {
|
|
1453
1453
|
n.has(i) || s.set(i, 0);
|
|
1454
|
-
}), p(e.restEncoder, s.size),
|
|
1455
|
-
|
|
1454
|
+
}), p(e.restEncoder, s.size), Q(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
1455
|
+
Ui(
|
|
1456
1456
|
e,
|
|
1457
1457
|
/** @type {Array<GC|Item>} */
|
|
1458
1458
|
t.clients.get(r),
|
|
@@ -1460,39 +1460,39 @@ const xi = (e, t, n, s) => {
|
|
|
1460
1460
|
i
|
|
1461
1461
|
);
|
|
1462
1462
|
});
|
|
1463
|
-
},
|
|
1464
|
-
const n =
|
|
1463
|
+
}, Ti = (e, t) => {
|
|
1464
|
+
const n = R(), s = w(e.restDecoder);
|
|
1465
1465
|
for (let r = 0; r < s; r++) {
|
|
1466
|
-
const i =
|
|
1467
|
-
let l =
|
|
1466
|
+
const i = w(e.restDecoder), o = new Array(i), c = e.readClient();
|
|
1467
|
+
let l = w(e.restDecoder);
|
|
1468
1468
|
n.set(c, { i: 0, refs: o });
|
|
1469
1469
|
for (let a = 0; a < i; a++) {
|
|
1470
1470
|
const h = e.readInfo();
|
|
1471
|
-
switch (
|
|
1471
|
+
switch (ce & h) {
|
|
1472
1472
|
case 0: {
|
|
1473
1473
|
const u = e.readLen();
|
|
1474
|
-
o[a] = new
|
|
1474
|
+
o[a] = new v(y(c, l), u), l += u;
|
|
1475
1475
|
break;
|
|
1476
1476
|
}
|
|
1477
1477
|
case 10: {
|
|
1478
|
-
const u =
|
|
1478
|
+
const u = w(e.restDecoder);
|
|
1479
1479
|
o[a] = new O(y(c, l), u), l += u;
|
|
1480
1480
|
break;
|
|
1481
1481
|
}
|
|
1482
1482
|
default: {
|
|
1483
|
-
const u = (h & (
|
|
1483
|
+
const u = (h & (K | T)) === 0, d = new C(
|
|
1484
1484
|
y(c, l),
|
|
1485
1485
|
null,
|
|
1486
1486
|
// leftd
|
|
1487
|
-
(h &
|
|
1487
|
+
(h & T) === T ? e.readLeftID() : null,
|
|
1488
1488
|
// origin
|
|
1489
1489
|
null,
|
|
1490
1490
|
// right
|
|
1491
|
-
(h &
|
|
1491
|
+
(h & K) === K ? e.readRightID() : null,
|
|
1492
1492
|
// right origin
|
|
1493
1493
|
u ? e.readParentInfo() ? t.get(e.readString()) : e.readLeftID() : null,
|
|
1494
1494
|
// parent
|
|
1495
|
-
u && (h &
|
|
1495
|
+
u && (h & Tt) === Tt ? e.readString() : null,
|
|
1496
1496
|
// parentSub
|
|
1497
1497
|
Os(e, h)
|
|
1498
1498
|
// item content
|
|
@@ -1503,9 +1503,9 @@ const xi = (e, t, n, s) => {
|
|
|
1503
1503
|
}
|
|
1504
1504
|
}
|
|
1505
1505
|
return n;
|
|
1506
|
-
},
|
|
1506
|
+
}, vi = (e, t, n) => {
|
|
1507
1507
|
const s = [];
|
|
1508
|
-
let r =
|
|
1508
|
+
let r = Q(n.keys()).sort((f, g) => f - g);
|
|
1509
1509
|
if (r.length === 0)
|
|
1510
1510
|
return null;
|
|
1511
1511
|
const i = () => {
|
|
@@ -1526,9 +1526,9 @@ const xi = (e, t, n, s) => {
|
|
|
1526
1526
|
let o = i();
|
|
1527
1527
|
if (o === null && s.length === 0)
|
|
1528
1528
|
return null;
|
|
1529
|
-
const c = new
|
|
1530
|
-
const
|
|
1531
|
-
(
|
|
1529
|
+
const c = new fs(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
|
|
1530
|
+
const m = l.get(f);
|
|
1531
|
+
(m == null || m > g) && l.set(f, g);
|
|
1532
1532
|
};
|
|
1533
1533
|
let h = (
|
|
1534
1534
|
/** @type {any} */
|
|
@@ -1539,32 +1539,32 @@ const xi = (e, t, n, s) => {
|
|
|
1539
1539
|
);
|
|
1540
1540
|
const u = /* @__PURE__ */ new Map(), d = () => {
|
|
1541
1541
|
for (const f of s) {
|
|
1542
|
-
const g = f.id.client,
|
|
1543
|
-
|
|
1542
|
+
const g = f.id.client, m = n.get(g);
|
|
1543
|
+
m ? (m.i--, c.clients.set(g, m.refs.slice(m.i)), n.delete(g), m.i = 0, m.refs = []) : c.clients.set(g, [f]), r = r.filter((U) => U !== g);
|
|
1544
1544
|
}
|
|
1545
1545
|
s.length = 0;
|
|
1546
1546
|
};
|
|
1547
1547
|
for (; ; ) {
|
|
1548
1548
|
if (h.constructor !== O) {
|
|
1549
|
-
const g =
|
|
1549
|
+
const g = J(u, h.id.client, () => A(t, h.id.client)) - h.id.clock;
|
|
1550
1550
|
if (g < 0)
|
|
1551
1551
|
s.push(h), a(h.id.client, h.id.clock - 1), d();
|
|
1552
1552
|
else {
|
|
1553
|
-
const
|
|
1554
|
-
if (
|
|
1553
|
+
const m = h.getMissing(e, t);
|
|
1554
|
+
if (m !== null) {
|
|
1555
1555
|
s.push(h);
|
|
1556
|
-
const
|
|
1556
|
+
const U = n.get(
|
|
1557
1557
|
/** @type {number} */
|
|
1558
|
-
|
|
1558
|
+
m
|
|
1559
1559
|
) || { refs: [], i: 0 };
|
|
1560
|
-
if (
|
|
1560
|
+
if (U.refs.length === U.i)
|
|
1561
1561
|
a(
|
|
1562
1562
|
/** @type {number} */
|
|
1563
|
-
|
|
1564
|
-
A(t,
|
|
1563
|
+
m,
|
|
1564
|
+
A(t, m)
|
|
1565
1565
|
), d();
|
|
1566
1566
|
else {
|
|
1567
|
-
h =
|
|
1567
|
+
h = U.refs[U.i++];
|
|
1568
1568
|
continue;
|
|
1569
1569
|
}
|
|
1570
1570
|
} else
|
|
@@ -1585,14 +1585,14 @@ const xi = (e, t, n, s) => {
|
|
|
1585
1585
|
}
|
|
1586
1586
|
}
|
|
1587
1587
|
if (c.clients.size > 0) {
|
|
1588
|
-
const f = new
|
|
1588
|
+
const f = new ot();
|
|
1589
1589
|
return tn(f, c, /* @__PURE__ */ new Map()), p(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
1590
1590
|
}
|
|
1591
1591
|
return null;
|
|
1592
|
-
},
|
|
1592
|
+
}, Oi = (e, t) => tn(e, t.doc.store, t.beforeState), Ri = (e, t, n, s = new kt(e)) => b(t, (r) => {
|
|
1593
1593
|
r.local = !1;
|
|
1594
1594
|
let i = !1;
|
|
1595
|
-
const o = r.doc, c = o.store, l =
|
|
1595
|
+
const o = r.doc, c = o.store, l = Ti(s, o), a = vi(r, c, l), h = c.pendingStructs;
|
|
1596
1596
|
if (h) {
|
|
1597
1597
|
for (const [d, f] of h.missing)
|
|
1598
1598
|
if (f < A(c, d)) {
|
|
@@ -1604,16 +1604,16 @@ const xi = (e, t, n, s) => {
|
|
|
1604
1604
|
const g = h.missing.get(d);
|
|
1605
1605
|
(g == null || g > f) && h.missing.set(d, f);
|
|
1606
1606
|
}
|
|
1607
|
-
h.update =
|
|
1607
|
+
h.update = te([h.update, a.update]);
|
|
1608
1608
|
}
|
|
1609
1609
|
} else
|
|
1610
1610
|
c.pendingStructs = a;
|
|
1611
|
-
const u =
|
|
1611
|
+
const u = En(s, r, c);
|
|
1612
1612
|
if (c.pendingDs) {
|
|
1613
|
-
const d = new
|
|
1614
|
-
|
|
1615
|
-
const f =
|
|
1616
|
-
u && f ? c.pendingDs =
|
|
1613
|
+
const d = new kt(P(c.pendingDs));
|
|
1614
|
+
w(d.restDecoder);
|
|
1615
|
+
const f = En(d, r, c);
|
|
1616
|
+
u && f ? c.pendingDs = te([u, f]) : c.pendingDs = u || f;
|
|
1617
1617
|
} else
|
|
1618
1618
|
c.pendingDs = u;
|
|
1619
1619
|
if (i) {
|
|
@@ -1621,44 +1621,44 @@ const xi = (e, t, n, s) => {
|
|
|
1621
1621
|
/** @type {{update: Uint8Array}} */
|
|
1622
1622
|
c.pendingStructs.update
|
|
1623
1623
|
);
|
|
1624
|
-
c.pendingStructs = null,
|
|
1625
|
-
}
|
|
1626
|
-
}, n, !1),
|
|
1627
|
-
const r =
|
|
1628
|
-
|
|
1629
|
-
},
|
|
1630
|
-
tn(e, t.store, n),
|
|
1631
|
-
},
|
|
1632
|
-
const s =
|
|
1633
|
-
|
|
1624
|
+
c.pendingStructs = null, ls(r.doc, d);
|
|
1625
|
+
}
|
|
1626
|
+
}, n, !1), ls = (e, t, n, s = kt) => {
|
|
1627
|
+
const r = P(t);
|
|
1628
|
+
Ri(r, e, n, new s(r));
|
|
1629
|
+
}, as = (e, t, n) => ls(e, t, n, is), Ni = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
1630
|
+
tn(e, t.store, n), Dt(e, xi(t.store));
|
|
1631
|
+
}, Bi = (e, t = new Uint8Array([0]), n = new ot()) => {
|
|
1632
|
+
const s = hs(t);
|
|
1633
|
+
Ni(n, e, s);
|
|
1634
1634
|
const r = [n.toUint8Array()];
|
|
1635
|
-
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(
|
|
1636
|
-
if (n.constructor ===
|
|
1637
|
-
return
|
|
1638
|
-
if (n.constructor ===
|
|
1639
|
-
return
|
|
1635
|
+
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Zi(e.store.pendingStructs.update, t)), r.length > 1) {
|
|
1636
|
+
if (n.constructor === $t)
|
|
1637
|
+
return qi(r.map((i, o) => o === 0 ? i : to(i)));
|
|
1638
|
+
if (n.constructor === ot)
|
|
1639
|
+
return te(r);
|
|
1640
1640
|
}
|
|
1641
1641
|
return r[0];
|
|
1642
|
-
}, en = (e, t) =>
|
|
1643
|
-
const t = /* @__PURE__ */ new Map(), n =
|
|
1642
|
+
}, en = (e, t) => Bi(e, t, new $t()), Vi = (e) => {
|
|
1643
|
+
const t = /* @__PURE__ */ new Map(), n = w(e.restDecoder);
|
|
1644
1644
|
for (let s = 0; s < n; s++) {
|
|
1645
|
-
const r =
|
|
1645
|
+
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
1646
1646
|
t.set(r, i);
|
|
1647
1647
|
}
|
|
1648
1648
|
return t;
|
|
1649
|
-
},
|
|
1649
|
+
}, hs = (e) => Vi(new rs(P(e))), us = (e, t) => (p(e.restEncoder, t.size), Q(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
1650
1650
|
p(e.restEncoder, n), p(e.restEncoder, s);
|
|
1651
|
-
}), e),
|
|
1652
|
-
class
|
|
1651
|
+
}), e), Fi = (e, t) => us(e, ue(t.store)), Hi = (e, t = new cs()) => (e instanceof Map ? us(t, e) : Fi(t, e), t.toUint8Array()), $i = (e) => Hi(e, new os());
|
|
1652
|
+
class Ki {
|
|
1653
1653
|
constructor() {
|
|
1654
1654
|
this.l = [];
|
|
1655
1655
|
}
|
|
1656
1656
|
}
|
|
1657
|
-
const
|
|
1657
|
+
const In = () => new Ki(), An = (e, t) => e.l.push(t), Ln = (e, t) => {
|
|
1658
1658
|
const n = e.l, s = n.length;
|
|
1659
1659
|
e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1660
|
-
},
|
|
1661
|
-
class
|
|
1660
|
+
}, ds = (e, t, n) => Ke(e.l, [t, n]);
|
|
1661
|
+
class pt {
|
|
1662
1662
|
/**
|
|
1663
1663
|
* @param {number} client client id
|
|
1664
1664
|
* @param {number} clock unique per client id, continuous number
|
|
@@ -1667,24 +1667,24 @@ class wt {
|
|
|
1667
1667
|
this.client = t, this.clock = n;
|
|
1668
1668
|
}
|
|
1669
1669
|
}
|
|
1670
|
-
const
|
|
1670
|
+
const Xt = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, y = (e, t) => new pt(e, t), ji = (e) => {
|
|
1671
1671
|
for (const [t, n] of e.doc.share.entries())
|
|
1672
1672
|
if (n === e)
|
|
1673
1673
|
return t;
|
|
1674
|
-
throw
|
|
1675
|
-
},
|
|
1676
|
-
const n =
|
|
1674
|
+
throw V();
|
|
1675
|
+
}, It = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !ns(t.ds, e.id), Re = (e, t) => {
|
|
1676
|
+
const n = J(e.meta, Re, rt), s = e.doc.store;
|
|
1677
1677
|
n.has(t) || (t.sv.forEach((r, i) => {
|
|
1678
|
-
r < A(s, i) &&
|
|
1679
|
-
}),
|
|
1678
|
+
r < A(s, i) && Z(e, y(i, r));
|
|
1679
|
+
}), es(e, t.ds, (r) => {
|
|
1680
1680
|
}), n.add(t));
|
|
1681
1681
|
};
|
|
1682
|
-
class
|
|
1682
|
+
class fs {
|
|
1683
1683
|
constructor() {
|
|
1684
1684
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
1685
1685
|
}
|
|
1686
1686
|
}
|
|
1687
|
-
const
|
|
1687
|
+
const ue = (e) => {
|
|
1688
1688
|
const t = /* @__PURE__ */ new Map();
|
|
1689
1689
|
return e.clients.forEach((n, s) => {
|
|
1690
1690
|
const r = n[n.length - 1];
|
|
@@ -1696,21 +1696,21 @@ const de = (e) => {
|
|
|
1696
1696
|
return 0;
|
|
1697
1697
|
const s = n[n.length - 1];
|
|
1698
1698
|
return s.id.clock + s.length;
|
|
1699
|
-
},
|
|
1699
|
+
}, gs = (e, t) => {
|
|
1700
1700
|
let n = e.clients.get(t.id.client);
|
|
1701
1701
|
if (n === void 0)
|
|
1702
1702
|
n = [], e.clients.set(t.id.client, n);
|
|
1703
1703
|
else {
|
|
1704
1704
|
const s = n[n.length - 1];
|
|
1705
1705
|
if (s.id.clock + s.length !== t.id.clock)
|
|
1706
|
-
throw
|
|
1706
|
+
throw V();
|
|
1707
1707
|
}
|
|
1708
1708
|
n.push(t);
|
|
1709
|
-
},
|
|
1709
|
+
}, F = (e, t) => {
|
|
1710
1710
|
let n = 0, s = e.length - 1, r = e[s], i = r.id.clock;
|
|
1711
1711
|
if (i === t)
|
|
1712
1712
|
return s;
|
|
1713
|
-
let o =
|
|
1713
|
+
let o = j(t / (i + r.length - 1) * s);
|
|
1714
1714
|
for (; n <= s; ) {
|
|
1715
1715
|
if (r = e[o], i = r.id.clock, i <= t) {
|
|
1716
1716
|
if (t < i + r.length)
|
|
@@ -1718,34 +1718,34 @@ const de = (e) => {
|
|
|
1718
1718
|
n = o + 1;
|
|
1719
1719
|
} else
|
|
1720
1720
|
s = o - 1;
|
|
1721
|
-
o =
|
|
1721
|
+
o = j((n + s) / 2);
|
|
1722
1722
|
}
|
|
1723
|
-
throw
|
|
1724
|
-
},
|
|
1723
|
+
throw V();
|
|
1724
|
+
}, Ji = (e, t) => {
|
|
1725
1725
|
const n = e.clients.get(t.client);
|
|
1726
|
-
return n[
|
|
1726
|
+
return n[F(n, t.clock)];
|
|
1727
1727
|
}, Se = (
|
|
1728
1728
|
/** @type {function(StructStore,ID):Item} */
|
|
1729
|
-
|
|
1729
|
+
Ji
|
|
1730
1730
|
), Ne = (e, t, n) => {
|
|
1731
|
-
const s =
|
|
1732
|
-
return r.id.clock < n && r instanceof C ? (t.splice(s + 1, 0,
|
|
1733
|
-
},
|
|
1731
|
+
const s = F(t, n), r = t[s];
|
|
1732
|
+
return r.id.clock < n && r instanceof C ? (t.splice(s + 1, 0, oe(e, r, n - r.id.clock)), s + 1) : s;
|
|
1733
|
+
}, Z = (e, t) => {
|
|
1734
1734
|
const n = (
|
|
1735
1735
|
/** @type {Array<Item>} */
|
|
1736
1736
|
e.doc.store.clients.get(t.client)
|
|
1737
1737
|
);
|
|
1738
1738
|
return n[Ne(e, n, t.clock)];
|
|
1739
|
-
},
|
|
1740
|
-
const s = t.clients.get(n.client), r =
|
|
1741
|
-
return n.clock !== i.id.clock + i.length - 1 && i.constructor !==
|
|
1742
|
-
},
|
|
1739
|
+
}, xn = (e, t, n) => {
|
|
1740
|
+
const s = t.clients.get(n.client), r = F(s, n.clock), i = s[r];
|
|
1741
|
+
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== v && s.splice(r + 1, 0, oe(e, i, n.clock - i.id.clock + 1)), i;
|
|
1742
|
+
}, Xi = (e, t, n) => {
|
|
1743
1743
|
const s = (
|
|
1744
1744
|
/** @type {Array<GC|Item>} */
|
|
1745
1745
|
e.clients.get(t.id.client)
|
|
1746
1746
|
);
|
|
1747
|
-
s[
|
|
1748
|
-
},
|
|
1747
|
+
s[F(s, t.id.clock)] = n;
|
|
1748
|
+
}, ps = (e, t, n, s, r) => {
|
|
1749
1749
|
if (s === 0)
|
|
1750
1750
|
return;
|
|
1751
1751
|
const i = n + s;
|
|
@@ -1754,20 +1754,20 @@ const de = (e) => {
|
|
|
1754
1754
|
c = t[o++], i < c.id.clock + c.length && Ne(e, t, i), r(c);
|
|
1755
1755
|
while (o < t.length && t[o].id.clock < i);
|
|
1756
1756
|
};
|
|
1757
|
-
class
|
|
1757
|
+
class Yi {
|
|
1758
1758
|
/**
|
|
1759
1759
|
* @param {Doc} doc
|
|
1760
1760
|
* @param {any} origin
|
|
1761
1761
|
* @param {boolean} local
|
|
1762
1762
|
*/
|
|
1763
1763
|
constructor(t, n, s) {
|
|
1764
|
-
this.doc = t, this.deleteSet = new
|
|
1764
|
+
this.doc = t, this.deleteSet = new Ht(), this.beforeState = ue(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;
|
|
1765
1765
|
}
|
|
1766
1766
|
}
|
|
1767
|
-
const
|
|
1767
|
+
const Mn = (e, t) => t.deleteSet.clients.size === 0 && !sr(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (Ze(t.deleteSet), Oi(e, t), Dt(e, t.deleteSet), !0), Un = (e, t, n) => {
|
|
1768
1768
|
const s = t._item;
|
|
1769
|
-
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) &&
|
|
1770
|
-
},
|
|
1769
|
+
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && J(e.changed, t, rt).add(n);
|
|
1770
|
+
}, Qt = (e, t) => {
|
|
1771
1771
|
const n = e[t - 1], s = e[t];
|
|
1772
1772
|
n.deleted === s.deleted && n.constructor === s.constructor && n.mergeWith(s) && (e.splice(t, 1), s instanceof C && s.parentSub !== null && /** @type {AbstractType<any>} */
|
|
1773
1773
|
s.parent._map.get(s.parentSub) === s && s.parent._map.set(
|
|
@@ -1775,7 +1775,7 @@ const xn = (e, t) => t.deleteSet.clients.size === 0 && !er(t.afterState, (n, s)
|
|
|
1775
1775
|
/** @type {Item} */
|
|
1776
1776
|
n
|
|
1777
1777
|
));
|
|
1778
|
-
},
|
|
1778
|
+
}, zi = (e, t, n) => {
|
|
1779
1779
|
for (const [s, r] of e.clients.entries()) {
|
|
1780
1780
|
const i = (
|
|
1781
1781
|
/** @type {Array<GC|Item>} */
|
|
@@ -1783,7 +1783,7 @@ const xn = (e, t) => t.deleteSet.clients.size === 0 && !er(t.afterState, (n, s)
|
|
|
1783
1783
|
);
|
|
1784
1784
|
for (let o = r.length - 1; o >= 0; o--) {
|
|
1785
1785
|
const c = r[o], l = c.clock + c.len;
|
|
1786
|
-
for (let a =
|
|
1786
|
+
for (let a = F(i, c.clock), h = i[a]; a < i.length && h.id.clock < l; h = i[++a]) {
|
|
1787
1787
|
const u = i[a];
|
|
1788
1788
|
if (c.clock + c.len <= u.id.clock)
|
|
1789
1789
|
break;
|
|
@@ -1791,23 +1791,23 @@ const xn = (e, t) => t.deleteSet.clients.size === 0 && !er(t.afterState, (n, s)
|
|
|
1791
1791
|
}
|
|
1792
1792
|
}
|
|
1793
1793
|
}
|
|
1794
|
-
},
|
|
1794
|
+
}, Gi = (e, t) => {
|
|
1795
1795
|
e.clients.forEach((n, s) => {
|
|
1796
1796
|
const r = (
|
|
1797
1797
|
/** @type {Array<GC|Item>} */
|
|
1798
1798
|
t.clients.get(s)
|
|
1799
1799
|
);
|
|
1800
1800
|
for (let i = n.length - 1; i >= 0; i--) {
|
|
1801
|
-
const o = n[i], c = je(r.length - 1, 1 +
|
|
1801
|
+
const o = n[i], c = je(r.length - 1, 1 + F(r, o.clock + o.len - 1));
|
|
1802
1802
|
for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[--l])
|
|
1803
|
-
|
|
1803
|
+
Qt(r, l);
|
|
1804
1804
|
}
|
|
1805
1805
|
});
|
|
1806
|
-
},
|
|
1806
|
+
}, ws = (e, t) => {
|
|
1807
1807
|
if (t < e.length) {
|
|
1808
1808
|
const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
|
|
1809
1809
|
try {
|
|
1810
|
-
Ze(i), n.afterState =
|
|
1810
|
+
Ze(i), n.afterState = ue(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
|
|
1811
1811
|
const c = [];
|
|
1812
1812
|
n.changed.forEach(
|
|
1813
1813
|
(l, a) => c.push(() => {
|
|
@@ -1819,81 +1819,81 @@ const xn = (e, t) => t.deleteSet.clients.size === 0 && !er(t.afterState, (n, s)
|
|
|
1819
1819
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
1820
1820
|
), l.forEach((h) => {
|
|
1821
1821
|
h.currentTarget = a, h._path = null;
|
|
1822
|
-
}), l.sort((h, u) => h.path.length - u.path.length),
|
|
1822
|
+
}), l.sort((h, u) => h.path.length - u.path.length), ds(a._dEH, l, n));
|
|
1823
1823
|
});
|
|
1824
|
-
}), c.push(() => s.emit("afterTransaction", [n, s])), Ke(c, []), n._needFormattingCleanup &&
|
|
1824
|
+
}), c.push(() => s.emit("afterTransaction", [n, s])), Ke(c, []), n._needFormattingCleanup && go(n);
|
|
1825
1825
|
} finally {
|
|
1826
|
-
s.gc &&
|
|
1826
|
+
s.gc && zi(i, r, s.gcFilter), Gi(i, r), n.afterState.forEach((h, u) => {
|
|
1827
1827
|
const d = n.beforeState.get(u) || 0;
|
|
1828
1828
|
if (d !== h) {
|
|
1829
1829
|
const f = (
|
|
1830
1830
|
/** @type {Array<GC|Item>} */
|
|
1831
1831
|
r.clients.get(u)
|
|
1832
|
-
), g =
|
|
1833
|
-
for (let
|
|
1834
|
-
|
|
1832
|
+
), g = ht(F(f, d), 1);
|
|
1833
|
+
for (let m = f.length - 1; m >= g; m--)
|
|
1834
|
+
Qt(f, m);
|
|
1835
1835
|
}
|
|
1836
1836
|
});
|
|
1837
1837
|
for (let h = 0; h < o.length; h++) {
|
|
1838
1838
|
const { client: u, clock: d } = o[h].id, f = (
|
|
1839
1839
|
/** @type {Array<GC|Item>} */
|
|
1840
1840
|
r.clients.get(u)
|
|
1841
|
-
), g =
|
|
1842
|
-
g + 1 < f.length &&
|
|
1841
|
+
), g = F(f, d);
|
|
1842
|
+
g + 1 < f.length && Qt(f, g + 1), g > 0 && Qt(f, g);
|
|
1843
1843
|
}
|
|
1844
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
1845
|
-
const h = new
|
|
1846
|
-
|
|
1844
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (Di(Pn, qn, "[yjs] ", Qn, Zn, "Changed the client-id because another client seems to be using it."), s.clientID = ss()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
1845
|
+
const h = new $t();
|
|
1846
|
+
Mn(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
|
|
1847
1847
|
}
|
|
1848
1848
|
if (s._observers.has("updateV2")) {
|
|
1849
|
-
const h = new
|
|
1850
|
-
|
|
1849
|
+
const h = new ot();
|
|
1850
|
+
Mn(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
|
|
1851
1851
|
}
|
|
1852
1852
|
const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
|
|
1853
1853
|
(c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
|
|
1854
1854
|
h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
|
|
1855
|
-
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) :
|
|
1855
|
+
}), a.forEach((h) => s.subdocs.delete(h)), s.emit("subdocs", [{ loaded: l, added: c, removed: a }, s, n]), a.forEach((h) => h.destroy())), e.length <= t + 1 ? (s._transactionCleanups = [], s.emit("afterAllTransactions", [s, e])) : ws(e, t + 1);
|
|
1856
1856
|
}
|
|
1857
1857
|
}
|
|
1858
1858
|
}, b = (e, t, n = null, s = !0) => {
|
|
1859
1859
|
const r = e._transactionCleanups;
|
|
1860
1860
|
let i = !1, o = null;
|
|
1861
|
-
e._transaction === null && (i = !0, e._transaction = new
|
|
1861
|
+
e._transaction === null && (i = !0, e._transaction = new Yi(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
1862
1862
|
try {
|
|
1863
1863
|
o = t(e._transaction);
|
|
1864
1864
|
} finally {
|
|
1865
1865
|
if (i) {
|
|
1866
1866
|
const c = e._transaction === r[0];
|
|
1867
|
-
e._transaction = null, c &&
|
|
1867
|
+
e._transaction = null, c && ws(r, 0);
|
|
1868
1868
|
}
|
|
1869
1869
|
}
|
|
1870
1870
|
return o;
|
|
1871
1871
|
};
|
|
1872
|
-
function*
|
|
1873
|
-
const t =
|
|
1872
|
+
function* Wi(e) {
|
|
1873
|
+
const t = w(e.restDecoder);
|
|
1874
1874
|
for (let n = 0; n < t; n++) {
|
|
1875
|
-
const s =
|
|
1876
|
-
let i =
|
|
1875
|
+
const s = w(e.restDecoder), r = e.readClient();
|
|
1876
|
+
let i = w(e.restDecoder);
|
|
1877
1877
|
for (let o = 0; o < s; o++) {
|
|
1878
1878
|
const c = e.readInfo();
|
|
1879
1879
|
if (c === 10) {
|
|
1880
|
-
const l =
|
|
1880
|
+
const l = w(e.restDecoder);
|
|
1881
1881
|
yield new O(y(r, i), l), i += l;
|
|
1882
|
-
} else if (
|
|
1883
|
-
const l = (c & (
|
|
1882
|
+
} else if (ce & c) {
|
|
1883
|
+
const l = (c & (K | T)) === 0, a = new C(
|
|
1884
1884
|
y(r, i),
|
|
1885
1885
|
null,
|
|
1886
1886
|
// left
|
|
1887
|
-
(c &
|
|
1887
|
+
(c & T) === T ? e.readLeftID() : null,
|
|
1888
1888
|
// origin
|
|
1889
1889
|
null,
|
|
1890
1890
|
// right
|
|
1891
|
-
(c &
|
|
1891
|
+
(c & K) === K ? e.readRightID() : null,
|
|
1892
1892
|
// right origin
|
|
1893
1893
|
// @ts-ignore Force writing a string here.
|
|
1894
1894
|
l ? e.readParentInfo() ? e.readString() : e.readLeftID() : null,
|
|
1895
1895
|
// parent
|
|
1896
|
-
l && (c &
|
|
1896
|
+
l && (c & Tt) === Tt ? e.readString() : null,
|
|
1897
1897
|
// parentSub
|
|
1898
1898
|
Os(e, c)
|
|
1899
1899
|
// item content
|
|
@@ -1901,7 +1901,7 @@ function* zi(e) {
|
|
|
1901
1901
|
yield a, i += a.length;
|
|
1902
1902
|
} else {
|
|
1903
1903
|
const l = e.readLen();
|
|
1904
|
-
yield new
|
|
1904
|
+
yield new v(y(r, i), l), i += l;
|
|
1905
1905
|
}
|
|
1906
1906
|
}
|
|
1907
1907
|
}
|
|
@@ -1912,7 +1912,7 @@ class nn {
|
|
|
1912
1912
|
* @param {boolean} filterSkips
|
|
1913
1913
|
*/
|
|
1914
1914
|
constructor(t, n) {
|
|
1915
|
-
this.gen =
|
|
1915
|
+
this.gen = Wi(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
1916
1916
|
}
|
|
1917
1917
|
/**
|
|
1918
1918
|
* @return {Item | GC | Skip |null}
|
|
@@ -1932,10 +1932,10 @@ class sn {
|
|
|
1932
1932
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
1933
1933
|
}
|
|
1934
1934
|
}
|
|
1935
|
-
const
|
|
1936
|
-
if (e.constructor ===
|
|
1935
|
+
const qi = (e) => te(e, is, $t), Qi = (e, t) => {
|
|
1936
|
+
if (e.constructor === v) {
|
|
1937
1937
|
const { client: n, clock: s } = e.id;
|
|
1938
|
-
return new
|
|
1938
|
+
return new v(y(n, s + t), e.length - t);
|
|
1939
1939
|
} else if (e.constructor === O) {
|
|
1940
1940
|
const { client: n, clock: s } = e.id;
|
|
1941
1941
|
return new O(y(n, s + t), e.length - t);
|
|
@@ -1955,10 +1955,10 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
|
|
|
1955
1955
|
n.content.splice(t)
|
|
1956
1956
|
);
|
|
1957
1957
|
}
|
|
1958
|
-
},
|
|
1958
|
+
}, te = (e, t = kt, n = ot) => {
|
|
1959
1959
|
if (e.length === 1)
|
|
1960
1960
|
return e[0];
|
|
1961
|
-
const s = e.map((h) => new t(
|
|
1961
|
+
const s = e.map((h) => new t(P(h)));
|
|
1962
1962
|
let r = s.map((h) => new nn(h, !0)), i = null;
|
|
1963
1963
|
const o = new n(), c = new sn(o);
|
|
1964
1964
|
for (; r = r.filter((d) => d.curr !== null), r.sort(
|
|
@@ -1987,21 +1987,21 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
|
|
|
1987
1987
|
f && d.id.clock > i.struct.id.clock + i.struct.length)
|
|
1988
1988
|
continue;
|
|
1989
1989
|
if (u !== i.struct.id.client)
|
|
1990
|
-
|
|
1990
|
+
G(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next();
|
|
1991
1991
|
else if (i.struct.id.clock + i.struct.length < d.id.clock)
|
|
1992
1992
|
if (i.struct.constructor === O)
|
|
1993
1993
|
i.struct.length = d.id.clock + d.length - i.struct.id.clock;
|
|
1994
1994
|
else {
|
|
1995
|
-
|
|
1995
|
+
G(c, i.struct, i.offset);
|
|
1996
1996
|
const g = d.id.clock - i.struct.id.clock - i.struct.length;
|
|
1997
1997
|
i = { struct: new O(y(u, i.struct.id.clock + i.struct.length), g), offset: 0 };
|
|
1998
1998
|
}
|
|
1999
1999
|
else {
|
|
2000
2000
|
const g = i.struct.id.clock + i.struct.length - d.id.clock;
|
|
2001
|
-
g > 0 && (i.struct.constructor === O ? i.struct.length -= g : d =
|
|
2001
|
+
g > 0 && (i.struct.constructor === O ? i.struct.length -= g : d = Qi(d, g)), i.struct.mergeWith(
|
|
2002
2002
|
/** @type {any} */
|
|
2003
2003
|
d
|
|
2004
|
-
) || (
|
|
2004
|
+
) || (G(c, i.struct, i.offset), i = { struct: d, offset: 0 }, h.next());
|
|
2005
2005
|
}
|
|
2006
2006
|
} else
|
|
2007
2007
|
i = { struct: (
|
|
@@ -2009,13 +2009,13 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
|
|
|
2009
2009
|
h.curr
|
|
2010
2010
|
), offset: 0 }, h.next();
|
|
2011
2011
|
for (let d = h.curr; d !== null && d.id.client === u && d.id.clock === i.struct.id.clock + i.struct.length && d.constructor !== O; d = h.next())
|
|
2012
|
-
|
|
2012
|
+
G(c, i.struct, i.offset), i = { struct: d, offset: 0 };
|
|
2013
2013
|
}
|
|
2014
|
-
i !== null && (
|
|
2015
|
-
const l = s.map((h) => Pe(h)), a =
|
|
2016
|
-
return
|
|
2017
|
-
},
|
|
2018
|
-
const r =
|
|
2014
|
+
i !== null && (G(c, i.struct, i.offset), i = null), rn(c);
|
|
2015
|
+
const l = s.map((h) => Pe(h)), a = Ai(l);
|
|
2016
|
+
return Dt(o, a), o.toUint8Array();
|
|
2017
|
+
}, Zi = (e, t, n = kt, s = ot) => {
|
|
2018
|
+
const r = hs(t), i = new s(), o = new sn(i), c = new n(P(e)), l = new nn(c, !1);
|
|
2019
2019
|
for (; l.curr; ) {
|
|
2020
2020
|
const h = l.curr, u = h.id.client, d = r.get(u) || 0;
|
|
2021
2021
|
if (l.curr.constructor === O) {
|
|
@@ -2023,36 +2023,36 @@ const Gi = (e) => ee(e, rs, Kt), Wi = (e, t) => {
|
|
|
2023
2023
|
continue;
|
|
2024
2024
|
}
|
|
2025
2025
|
if (h.id.clock + h.length > d)
|
|
2026
|
-
for (
|
|
2027
|
-
|
|
2026
|
+
for (G(o, h, ht(d - h.id.clock, 0)), l.next(); l.curr && l.curr.id.client === u; )
|
|
2027
|
+
G(o, l.curr, 0), l.next();
|
|
2028
2028
|
else
|
|
2029
2029
|
for (; l.curr && l.curr.id.client === u && l.curr.id.clock + l.curr.length <= d; )
|
|
2030
2030
|
l.next();
|
|
2031
2031
|
}
|
|
2032
2032
|
rn(o);
|
|
2033
2033
|
const a = Pe(c);
|
|
2034
|
-
return
|
|
2035
|
-
},
|
|
2034
|
+
return Dt(i, a), i.toUint8Array();
|
|
2035
|
+
}, ms = (e) => {
|
|
2036
2036
|
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: S(e.encoder.restEncoder) }), e.encoder.restEncoder = M(), e.written = 0);
|
|
2037
|
-
},
|
|
2038
|
-
e.written > 0 && e.currClient !== t.id.client &&
|
|
2037
|
+
}, G = (e, t, n) => {
|
|
2038
|
+
e.written > 0 && e.currClient !== t.id.client && ms(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), p(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
|
|
2039
2039
|
}, rn = (e) => {
|
|
2040
|
-
|
|
2040
|
+
ms(e);
|
|
2041
2041
|
const t = e.encoder.restEncoder;
|
|
2042
2042
|
p(t, e.clientStructs.length);
|
|
2043
2043
|
for (let n = 0; n < e.clientStructs.length; n++) {
|
|
2044
2044
|
const s = e.clientStructs[n];
|
|
2045
|
-
p(t, s.written),
|
|
2045
|
+
p(t, s.written), le(t, s.restEncoder);
|
|
2046
2046
|
}
|
|
2047
|
-
},
|
|
2048
|
-
const r = new n(
|
|
2047
|
+
}, Pi = (e, t, n, s) => {
|
|
2048
|
+
const r = new n(P(e)), i = new nn(r, !1), o = new s(), c = new sn(o);
|
|
2049
2049
|
for (let a = i.curr; a !== null; a = i.next())
|
|
2050
|
-
|
|
2050
|
+
G(c, t(a), 0);
|
|
2051
2051
|
rn(c);
|
|
2052
2052
|
const l = Pe(r);
|
|
2053
|
-
return
|
|
2054
|
-
},
|
|
2055
|
-
class
|
|
2053
|
+
return Dt(o, l), o.toUint8Array();
|
|
2054
|
+
}, to = (e) => Pi(e, Cr, kt, $t);
|
|
2055
|
+
class de {
|
|
2056
2056
|
/**
|
|
2057
2057
|
* @param {T} target The changed type.
|
|
2058
2058
|
* @param {Transaction} transaction
|
|
@@ -2074,7 +2074,7 @@ class fe {
|
|
|
2074
2074
|
* type === event.target // => true
|
|
2075
2075
|
*/
|
|
2076
2076
|
get path() {
|
|
2077
|
-
return this._path || (this._path =
|
|
2077
|
+
return this._path || (this._path = eo(this.currentTarget, this.target));
|
|
2078
2078
|
}
|
|
2079
2079
|
/**
|
|
2080
2080
|
* Check if a struct is deleted by this event.
|
|
@@ -2085,7 +2085,7 @@ class fe {
|
|
|
2085
2085
|
* @return {boolean}
|
|
2086
2086
|
*/
|
|
2087
2087
|
deletes(t) {
|
|
2088
|
-
return
|
|
2088
|
+
return ns(this.transaction.deleteSet, t.id);
|
|
2089
2089
|
}
|
|
2090
2090
|
/**
|
|
2091
2091
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2158,7 +2158,7 @@ class fe {
|
|
|
2158
2158
|
get changes() {
|
|
2159
2159
|
let t = this._changes;
|
|
2160
2160
|
if (t === null) {
|
|
2161
|
-
const n = this.target, s =
|
|
2161
|
+
const n = this.target, s = rt(), r = rt(), i = [];
|
|
2162
2162
|
if (t = {
|
|
2163
2163
|
added: s,
|
|
2164
2164
|
deleted: r,
|
|
@@ -2182,7 +2182,7 @@ class fe {
|
|
|
2182
2182
|
);
|
|
2183
2183
|
}
|
|
2184
2184
|
}
|
|
2185
|
-
const
|
|
2185
|
+
const eo = (e, t) => {
|
|
2186
2186
|
const n = [];
|
|
2187
2187
|
for (; t._item !== null && t !== e; ) {
|
|
2188
2188
|
if (t._item.parentSub !== null)
|
|
@@ -2200,9 +2200,9 @@ const Pi = (e, t) => {
|
|
|
2200
2200
|
t._item.parent;
|
|
2201
2201
|
}
|
|
2202
2202
|
return n;
|
|
2203
|
-
},
|
|
2203
|
+
}, ys = 80;
|
|
2204
2204
|
let on = 0;
|
|
2205
|
-
class
|
|
2205
|
+
class no {
|
|
2206
2206
|
/**
|
|
2207
2207
|
* @param {Item} p
|
|
2208
2208
|
* @param {number} index
|
|
@@ -2211,24 +2211,24 @@ class to {
|
|
|
2211
2211
|
t.marker = !0, this.p = t, this.index = n, this.timestamp = on++;
|
|
2212
2212
|
}
|
|
2213
2213
|
}
|
|
2214
|
-
const
|
|
2214
|
+
const so = (e) => {
|
|
2215
2215
|
e.timestamp = on++;
|
|
2216
|
-
},
|
|
2216
|
+
}, _s = (e, t, n) => {
|
|
2217
2217
|
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = on++;
|
|
2218
|
-
},
|
|
2219
|
-
if (e.length >=
|
|
2218
|
+
}, ro = (e, t, n) => {
|
|
2219
|
+
if (e.length >= ys) {
|
|
2220
2220
|
const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
2221
|
-
return
|
|
2221
|
+
return _s(s, t, n), s;
|
|
2222
2222
|
} else {
|
|
2223
|
-
const s = new
|
|
2223
|
+
const s = new no(t, n);
|
|
2224
2224
|
return e.push(s), s;
|
|
2225
2225
|
}
|
|
2226
|
-
},
|
|
2226
|
+
}, fe = (e, t) => {
|
|
2227
2227
|
if (e._start === null || t === 0 || e._searchMarker === null)
|
|
2228
2228
|
return null;
|
|
2229
|
-
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) =>
|
|
2229
|
+
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => Gt(t - i.index) < Gt(t - o.index) ? i : o);
|
|
2230
2230
|
let s = e._start, r = 0;
|
|
2231
|
-
for (n !== null && (s = n.p, r = n.index,
|
|
2231
|
+
for (n !== null && (s = n.p, r = n.index, so(n)); s.right !== null && r < t; ) {
|
|
2232
2232
|
if (!s.deleted && s.countable) {
|
|
2233
2233
|
if (t < r + s.length)
|
|
2234
2234
|
break;
|
|
@@ -2240,9 +2240,9 @@ const eo = (e) => {
|
|
|
2240
2240
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2241
2241
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
2242
2242
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2243
|
-
return n !== null &&
|
|
2244
|
-
s.parent.length /
|
|
2245
|
-
},
|
|
2243
|
+
return n !== null && Gt(n.index - r) < /** @type {YText|YArray<any>} */
|
|
2244
|
+
s.parent.length / ys ? (_s(n, s, r), n) : ro(e._searchMarker, s, r);
|
|
2245
|
+
}, Rt = (e, t, n) => {
|
|
2246
2246
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
2247
2247
|
const r = e[s];
|
|
2248
2248
|
if (n > 0) {
|
|
@@ -2255,18 +2255,18 @@ const eo = (e) => {
|
|
|
2255
2255
|
}
|
|
2256
2256
|
r.p = i, i.marker = !0;
|
|
2257
2257
|
}
|
|
2258
|
-
(t < r.index || n > 0 && t === r.index) && (r.index =
|
|
2258
|
+
(t < r.index || n > 0 && t === r.index) && (r.index = ht(t, r.index + n));
|
|
2259
2259
|
}
|
|
2260
|
-
},
|
|
2260
|
+
}, ge = (e, t, n) => {
|
|
2261
2261
|
const s = e, r = t.changedParentTypes;
|
|
2262
|
-
for (;
|
|
2262
|
+
for (; J(r, e, () => []).push(n), e._item !== null; )
|
|
2263
2263
|
e = /** @type {AbstractType<any>} */
|
|
2264
2264
|
e._item.parent;
|
|
2265
|
-
|
|
2265
|
+
ds(s._eH, n, t);
|
|
2266
2266
|
};
|
|
2267
2267
|
class L {
|
|
2268
2268
|
constructor() {
|
|
2269
|
-
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH =
|
|
2269
|
+
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = In(), this._dEH = In(), this._searchMarker = null;
|
|
2270
2270
|
}
|
|
2271
2271
|
/**
|
|
2272
2272
|
* @return {AbstractType<any>|null}
|
|
@@ -2294,13 +2294,13 @@ class L {
|
|
|
2294
2294
|
* @return {AbstractType<EventType>}
|
|
2295
2295
|
*/
|
|
2296
2296
|
_copy() {
|
|
2297
|
-
throw
|
|
2297
|
+
throw B();
|
|
2298
2298
|
}
|
|
2299
2299
|
/**
|
|
2300
2300
|
* @return {AbstractType<EventType>}
|
|
2301
2301
|
*/
|
|
2302
2302
|
clone() {
|
|
2303
|
-
throw
|
|
2303
|
+
throw B();
|
|
2304
2304
|
}
|
|
2305
2305
|
/**
|
|
2306
2306
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} _encoder
|
|
@@ -2332,7 +2332,7 @@ class L {
|
|
|
2332
2332
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2333
2333
|
*/
|
|
2334
2334
|
observe(t) {
|
|
2335
|
-
|
|
2335
|
+
An(this._eH, t);
|
|
2336
2336
|
}
|
|
2337
2337
|
/**
|
|
2338
2338
|
* Observe all events that are created by this type and its children.
|
|
@@ -2340,7 +2340,7 @@ class L {
|
|
|
2340
2340
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2341
2341
|
*/
|
|
2342
2342
|
observeDeep(t) {
|
|
2343
|
-
|
|
2343
|
+
An(this._dEH, t);
|
|
2344
2344
|
}
|
|
2345
2345
|
/**
|
|
2346
2346
|
* Unregister an observer function.
|
|
@@ -2348,7 +2348,7 @@ class L {
|
|
|
2348
2348
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2349
2349
|
*/
|
|
2350
2350
|
unobserve(t) {
|
|
2351
|
-
|
|
2351
|
+
Ln(this._eH, t);
|
|
2352
2352
|
}
|
|
2353
2353
|
/**
|
|
2354
2354
|
* Unregister an observer function.
|
|
@@ -2356,7 +2356,7 @@ class L {
|
|
|
2356
2356
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2357
2357
|
*/
|
|
2358
2358
|
unobserveDeep(t) {
|
|
2359
|
-
|
|
2359
|
+
Ln(this._dEH, t);
|
|
2360
2360
|
}
|
|
2361
2361
|
/**
|
|
2362
2362
|
* @abstract
|
|
@@ -2365,7 +2365,7 @@ class L {
|
|
|
2365
2365
|
toJSON() {
|
|
2366
2366
|
}
|
|
2367
2367
|
}
|
|
2368
|
-
const
|
|
2368
|
+
const bs = (e, t, n) => {
|
|
2369
2369
|
t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
|
|
2370
2370
|
let s = n - t;
|
|
2371
2371
|
const r = [];
|
|
@@ -2384,7 +2384,7 @@ const _s = (e, t, n) => {
|
|
|
2384
2384
|
i = i.right;
|
|
2385
2385
|
}
|
|
2386
2386
|
return r;
|
|
2387
|
-
},
|
|
2387
|
+
}, ks = (e) => {
|
|
2388
2388
|
const t = [];
|
|
2389
2389
|
let n = e._start;
|
|
2390
2390
|
for (; n !== null; ) {
|
|
@@ -2396,7 +2396,7 @@ const _s = (e, t, n) => {
|
|
|
2396
2396
|
n = n.right;
|
|
2397
2397
|
}
|
|
2398
2398
|
return t;
|
|
2399
|
-
},
|
|
2399
|
+
}, Nt = (e, t) => {
|
|
2400
2400
|
let n = 0, s = e._start;
|
|
2401
2401
|
for (; s !== null; ) {
|
|
2402
2402
|
if (s.countable && !s.deleted) {
|
|
@@ -2406,12 +2406,12 @@ const _s = (e, t, n) => {
|
|
|
2406
2406
|
}
|
|
2407
2407
|
s = s.right;
|
|
2408
2408
|
}
|
|
2409
|
-
},
|
|
2409
|
+
}, Ss = (e, t) => {
|
|
2410
2410
|
const n = [];
|
|
2411
|
-
return
|
|
2411
|
+
return Nt(e, (s, r) => {
|
|
2412
2412
|
n.push(t(s, r, e));
|
|
2413
2413
|
}), n;
|
|
2414
|
-
},
|
|
2414
|
+
}, io = (e) => {
|
|
2415
2415
|
let t = e._start, n = null, s = 0;
|
|
2416
2416
|
return {
|
|
2417
2417
|
[Symbol.iterator]() {
|
|
@@ -2435,8 +2435,8 @@ const _s = (e, t, n) => {
|
|
|
2435
2435
|
};
|
|
2436
2436
|
}
|
|
2437
2437
|
};
|
|
2438
|
-
},
|
|
2439
|
-
const n =
|
|
2438
|
+
}, Ds = (e, t) => {
|
|
2439
|
+
const n = fe(e, t);
|
|
2440
2440
|
let s = e._start;
|
|
2441
2441
|
for (n !== null && (s = n.p, t -= n.index); s !== null; s = s.right)
|
|
2442
2442
|
if (!s.deleted && s.countable) {
|
|
@@ -2444,12 +2444,12 @@ const _s = (e, t, n) => {
|
|
|
2444
2444
|
return s.content.getContent()[t];
|
|
2445
2445
|
t -= s.length;
|
|
2446
2446
|
}
|
|
2447
|
-
},
|
|
2447
|
+
}, ee = (e, t, n, s) => {
|
|
2448
2448
|
let r = n;
|
|
2449
2449
|
const i = e.doc, o = i.clientID, c = i.store, l = n === null ? t._start : n.right;
|
|
2450
2450
|
let a = [];
|
|
2451
2451
|
const h = () => {
|
|
2452
|
-
a.length > 0 && (r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2452
|
+
a.length > 0 && (r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new at(a)), r.integrate(e, 0), a = []);
|
|
2453
2453
|
};
|
|
2454
2454
|
s.forEach((u) => {
|
|
2455
2455
|
if (u === null)
|
|
@@ -2467,72 +2467,72 @@ const _s = (e, t, n) => {
|
|
|
2467
2467
|
switch (h(), u.constructor) {
|
|
2468
2468
|
case Uint8Array:
|
|
2469
2469
|
case ArrayBuffer:
|
|
2470
|
-
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2470
|
+
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new Kt(new Uint8Array(
|
|
2471
2471
|
/** @type {Uint8Array} */
|
|
2472
2472
|
u
|
|
2473
2473
|
))), r.integrate(e, 0);
|
|
2474
2474
|
break;
|
|
2475
|
-
case
|
|
2476
|
-
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2475
|
+
case Ct:
|
|
2476
|
+
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new jt(
|
|
2477
2477
|
/** @type {Doc} */
|
|
2478
2478
|
u
|
|
2479
2479
|
)), r.integrate(e, 0);
|
|
2480
2480
|
break;
|
|
2481
2481
|
default:
|
|
2482
2482
|
if (u instanceof L)
|
|
2483
|
-
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2483
|
+
r = new C(y(o, A(c, o)), r, r && r.lastId, l, l && l.id, t, null, new Y(u)), r.integrate(e, 0);
|
|
2484
2484
|
else
|
|
2485
2485
|
throw new Error("Unexpected content type in insert operation");
|
|
2486
2486
|
}
|
|
2487
2487
|
}
|
|
2488
2488
|
}), h();
|
|
2489
|
-
},
|
|
2489
|
+
}, Cs = ut("Length exceeded!"), Es = (e, t, n, s) => {
|
|
2490
2490
|
if (n > t._length)
|
|
2491
|
-
throw
|
|
2491
|
+
throw Cs;
|
|
2492
2492
|
if (n === 0)
|
|
2493
|
-
return t._searchMarker &&
|
|
2494
|
-
const r = n, i =
|
|
2493
|
+
return t._searchMarker && Rt(t._searchMarker, n, s.length), ee(e, t, null, s);
|
|
2494
|
+
const r = n, i = fe(t, n);
|
|
2495
2495
|
let o = t._start;
|
|
2496
2496
|
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)
|
|
2497
2497
|
if (!o.deleted && o.countable) {
|
|
2498
2498
|
if (n <= o.length) {
|
|
2499
|
-
n < o.length &&
|
|
2499
|
+
n < o.length && Z(e, y(o.id.client, o.id.clock + n));
|
|
2500
2500
|
break;
|
|
2501
2501
|
}
|
|
2502
2502
|
n -= o.length;
|
|
2503
2503
|
}
|
|
2504
|
-
return t._searchMarker &&
|
|
2505
|
-
},
|
|
2504
|
+
return t._searchMarker && Rt(t._searchMarker, r, s.length), ee(e, t, o, s);
|
|
2505
|
+
}, oo = (e, t, n) => {
|
|
2506
2506
|
let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
|
|
2507
2507
|
if (r)
|
|
2508
2508
|
for (; r.right; )
|
|
2509
2509
|
r = r.right;
|
|
2510
|
-
return
|
|
2511
|
-
},
|
|
2510
|
+
return ee(e, t, r, n);
|
|
2511
|
+
}, Is = (e, t, n, s) => {
|
|
2512
2512
|
if (s === 0)
|
|
2513
2513
|
return;
|
|
2514
|
-
const r = n, i = s, o =
|
|
2514
|
+
const r = n, i = s, o = fe(t, n);
|
|
2515
2515
|
let c = t._start;
|
|
2516
2516
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
2517
|
-
!c.deleted && c.countable && (n < c.length &&
|
|
2517
|
+
!c.deleted && c.countable && (n < c.length && Z(e, y(c.id.client, c.id.clock + n)), n -= c.length);
|
|
2518
2518
|
for (; s > 0 && c !== null; )
|
|
2519
|
-
c.deleted || (s < c.length &&
|
|
2519
|
+
c.deleted || (s < c.length && Z(e, y(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
|
|
2520
2520
|
if (s > 0)
|
|
2521
|
-
throw
|
|
2522
|
-
t._searchMarker &&
|
|
2521
|
+
throw Cs;
|
|
2522
|
+
t._searchMarker && Rt(
|
|
2523
2523
|
t._searchMarker,
|
|
2524
2524
|
r,
|
|
2525
2525
|
-i + s
|
|
2526
2526
|
/* in case we remove the above exception */
|
|
2527
2527
|
);
|
|
2528
|
-
},
|
|
2528
|
+
}, ne = (e, t, n) => {
|
|
2529
2529
|
const s = t._map.get(n);
|
|
2530
2530
|
s !== void 0 && s.delete(e);
|
|
2531
2531
|
}, cn = (e, t, n, s) => {
|
|
2532
2532
|
const r = t._map.get(n) || null, i = e.doc, o = i.clientID;
|
|
2533
2533
|
let c;
|
|
2534
2534
|
if (s == null)
|
|
2535
|
-
c = new
|
|
2535
|
+
c = new at([s]);
|
|
2536
2536
|
else
|
|
2537
2537
|
switch (s.constructor) {
|
|
2538
2538
|
case Number:
|
|
@@ -2540,23 +2540,23 @@ const _s = (e, t, n) => {
|
|
|
2540
2540
|
case Boolean:
|
|
2541
2541
|
case Array:
|
|
2542
2542
|
case String:
|
|
2543
|
-
c = new
|
|
2543
|
+
c = new at([s]);
|
|
2544
2544
|
break;
|
|
2545
2545
|
case Uint8Array:
|
|
2546
|
-
c = new
|
|
2546
|
+
c = new Kt(
|
|
2547
2547
|
/** @type {Uint8Array} */
|
|
2548
2548
|
s
|
|
2549
2549
|
);
|
|
2550
2550
|
break;
|
|
2551
|
-
case
|
|
2552
|
-
c = new
|
|
2551
|
+
case Ct:
|
|
2552
|
+
c = new jt(
|
|
2553
2553
|
/** @type {Doc} */
|
|
2554
2554
|
s
|
|
2555
2555
|
);
|
|
2556
2556
|
break;
|
|
2557
2557
|
default:
|
|
2558
2558
|
if (s instanceof L)
|
|
2559
|
-
c = new
|
|
2559
|
+
c = new Y(s);
|
|
2560
2560
|
else
|
|
2561
2561
|
throw new Error("Unexpected content type");
|
|
2562
2562
|
}
|
|
@@ -2564,20 +2564,20 @@ const _s = (e, t, n) => {
|
|
|
2564
2564
|
}, ln = (e, t) => {
|
|
2565
2565
|
const n = e._map.get(t);
|
|
2566
2566
|
return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
|
|
2567
|
-
},
|
|
2567
|
+
}, As = (e) => {
|
|
2568
2568
|
const t = {};
|
|
2569
2569
|
return e._map.forEach((n, s) => {
|
|
2570
2570
|
n.deleted || (t[s] = n.content.getContent()[n.length - 1]);
|
|
2571
2571
|
}), t;
|
|
2572
|
-
},
|
|
2572
|
+
}, Ls = (e, t) => {
|
|
2573
2573
|
const n = e._map.get(t);
|
|
2574
2574
|
return n !== void 0 && !n.deleted;
|
|
2575
|
-
},
|
|
2575
|
+
}, Yt = (e) => Ei(
|
|
2576
2576
|
e.entries(),
|
|
2577
2577
|
/** @param {any} entry */
|
|
2578
2578
|
(t) => !t[1].deleted
|
|
2579
2579
|
);
|
|
2580
|
-
class
|
|
2580
|
+
class co extends de {
|
|
2581
2581
|
/**
|
|
2582
2582
|
* @param {YArray<T>} yarray The changed type
|
|
2583
2583
|
* @param {Transaction} transaction The transaction object
|
|
@@ -2586,7 +2586,7 @@ class io extends fe {
|
|
|
2586
2586
|
super(t, n), this._transaction = n;
|
|
2587
2587
|
}
|
|
2588
2588
|
}
|
|
2589
|
-
class
|
|
2589
|
+
class wt extends L {
|
|
2590
2590
|
constructor() {
|
|
2591
2591
|
super(), this._prelimContent = [], this._searchMarker = [];
|
|
2592
2592
|
}
|
|
@@ -2597,7 +2597,7 @@ class mt extends L {
|
|
|
2597
2597
|
* @return {YArray<T>}
|
|
2598
2598
|
*/
|
|
2599
2599
|
static from(t) {
|
|
2600
|
-
const n = new
|
|
2600
|
+
const n = new wt();
|
|
2601
2601
|
return n.push(t), n;
|
|
2602
2602
|
}
|
|
2603
2603
|
/**
|
|
@@ -2621,13 +2621,13 @@ class mt extends L {
|
|
|
2621
2621
|
* @return {YArray<T>}
|
|
2622
2622
|
*/
|
|
2623
2623
|
_copy() {
|
|
2624
|
-
return new
|
|
2624
|
+
return new wt();
|
|
2625
2625
|
}
|
|
2626
2626
|
/**
|
|
2627
2627
|
* @return {YArray<T>}
|
|
2628
2628
|
*/
|
|
2629
2629
|
clone() {
|
|
2630
|
-
const t = new
|
|
2630
|
+
const t = new wt();
|
|
2631
2631
|
return t.insert(0, this.toArray().map(
|
|
2632
2632
|
(n) => n instanceof L ? (
|
|
2633
2633
|
/** @type {typeof el} */
|
|
@@ -2645,7 +2645,7 @@ class mt extends L {
|
|
|
2645
2645
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2646
2646
|
*/
|
|
2647
2647
|
_callObserver(t, n) {
|
|
2648
|
-
super._callObserver(t, n),
|
|
2648
|
+
super._callObserver(t, n), ge(this, t, new co(this, t));
|
|
2649
2649
|
}
|
|
2650
2650
|
/**
|
|
2651
2651
|
* Inserts new content at an index.
|
|
@@ -2665,7 +2665,7 @@ class mt extends L {
|
|
|
2665
2665
|
*/
|
|
2666
2666
|
insert(t, n) {
|
|
2667
2667
|
this.doc !== null ? b(this.doc, (s) => {
|
|
2668
|
-
|
|
2668
|
+
Es(
|
|
2669
2669
|
s,
|
|
2670
2670
|
this,
|
|
2671
2671
|
t,
|
|
@@ -2683,7 +2683,7 @@ class mt extends L {
|
|
|
2683
2683
|
*/
|
|
2684
2684
|
push(t) {
|
|
2685
2685
|
this.doc !== null ? b(this.doc, (n) => {
|
|
2686
|
-
|
|
2686
|
+
oo(
|
|
2687
2687
|
n,
|
|
2688
2688
|
this,
|
|
2689
2689
|
/** @type {any} */
|
|
@@ -2707,7 +2707,7 @@ class mt extends L {
|
|
|
2707
2707
|
*/
|
|
2708
2708
|
delete(t, n = 1) {
|
|
2709
2709
|
this.doc !== null ? b(this.doc, (s) => {
|
|
2710
|
-
|
|
2710
|
+
Is(s, this, t, n);
|
|
2711
2711
|
}) : this._prelimContent.splice(t, n);
|
|
2712
2712
|
}
|
|
2713
2713
|
/**
|
|
@@ -2717,7 +2717,7 @@ class mt extends L {
|
|
|
2717
2717
|
* @return {T}
|
|
2718
2718
|
*/
|
|
2719
2719
|
get(t) {
|
|
2720
|
-
return
|
|
2720
|
+
return Ds(this, t);
|
|
2721
2721
|
}
|
|
2722
2722
|
/**
|
|
2723
2723
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2725,7 +2725,7 @@ class mt extends L {
|
|
|
2725
2725
|
* @return {Array<T>}
|
|
2726
2726
|
*/
|
|
2727
2727
|
toArray() {
|
|
2728
|
-
return
|
|
2728
|
+
return ks(this);
|
|
2729
2729
|
}
|
|
2730
2730
|
/**
|
|
2731
2731
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2735,7 +2735,7 @@ class mt extends L {
|
|
|
2735
2735
|
* @return {Array<T>}
|
|
2736
2736
|
*/
|
|
2737
2737
|
slice(t = 0, n = this.length) {
|
|
2738
|
-
return
|
|
2738
|
+
return bs(this, t, n);
|
|
2739
2739
|
}
|
|
2740
2740
|
/**
|
|
2741
2741
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -2755,7 +2755,7 @@ class mt extends L {
|
|
|
2755
2755
|
* callback function
|
|
2756
2756
|
*/
|
|
2757
2757
|
map(t) {
|
|
2758
|
-
return
|
|
2758
|
+
return Ss(
|
|
2759
2759
|
this,
|
|
2760
2760
|
/** @type {any} */
|
|
2761
2761
|
t
|
|
@@ -2767,23 +2767,23 @@ class mt extends L {
|
|
|
2767
2767
|
* @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
|
|
2768
2768
|
*/
|
|
2769
2769
|
forEach(t) {
|
|
2770
|
-
|
|
2770
|
+
Nt(this, t);
|
|
2771
2771
|
}
|
|
2772
2772
|
/**
|
|
2773
2773
|
* @return {IterableIterator<T>}
|
|
2774
2774
|
*/
|
|
2775
2775
|
[Symbol.iterator]() {
|
|
2776
|
-
return
|
|
2776
|
+
return io(this);
|
|
2777
2777
|
}
|
|
2778
2778
|
/**
|
|
2779
2779
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2780
2780
|
*/
|
|
2781
2781
|
_write(t) {
|
|
2782
|
-
t.writeTypeRef(
|
|
2782
|
+
t.writeTypeRef(To);
|
|
2783
2783
|
}
|
|
2784
2784
|
}
|
|
2785
|
-
const
|
|
2786
|
-
class
|
|
2785
|
+
const lo = (e) => new wt();
|
|
2786
|
+
class ao extends de {
|
|
2787
2787
|
/**
|
|
2788
2788
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
2789
2789
|
* @param {Transaction} transaction
|
|
@@ -2793,7 +2793,7 @@ class co extends fe {
|
|
|
2793
2793
|
super(t, n), this.keysChanged = s;
|
|
2794
2794
|
}
|
|
2795
2795
|
}
|
|
2796
|
-
class
|
|
2796
|
+
class ct extends L {
|
|
2797
2797
|
/**
|
|
2798
2798
|
*
|
|
2799
2799
|
* @param {Iterable<readonly [string, any]>=} entries - an optional iterable to initialize the YMap
|
|
@@ -2820,13 +2820,13 @@ class it extends L {
|
|
|
2820
2820
|
* @return {YMap<MapType>}
|
|
2821
2821
|
*/
|
|
2822
2822
|
_copy() {
|
|
2823
|
-
return new
|
|
2823
|
+
return new ct();
|
|
2824
2824
|
}
|
|
2825
2825
|
/**
|
|
2826
2826
|
* @return {YMap<MapType>}
|
|
2827
2827
|
*/
|
|
2828
2828
|
clone() {
|
|
2829
|
-
const t = new
|
|
2829
|
+
const t = new ct();
|
|
2830
2830
|
return this.forEach((n, s) => {
|
|
2831
2831
|
t.set(s, n instanceof L ? (
|
|
2832
2832
|
/** @type {typeof value} */
|
|
@@ -2841,7 +2841,7 @@ class it extends L {
|
|
|
2841
2841
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2842
2842
|
*/
|
|
2843
2843
|
_callObserver(t, n) {
|
|
2844
|
-
|
|
2844
|
+
ge(this, t, new ao(this, t, n));
|
|
2845
2845
|
}
|
|
2846
2846
|
/**
|
|
2847
2847
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -2863,7 +2863,7 @@ class it extends L {
|
|
|
2863
2863
|
* @return {number}
|
|
2864
2864
|
*/
|
|
2865
2865
|
get size() {
|
|
2866
|
-
return [...
|
|
2866
|
+
return [...Yt(this._map)].length;
|
|
2867
2867
|
}
|
|
2868
2868
|
/**
|
|
2869
2869
|
* Returns the keys for each element in the YMap Type.
|
|
@@ -2872,7 +2872,7 @@ class it extends L {
|
|
|
2872
2872
|
*/
|
|
2873
2873
|
keys() {
|
|
2874
2874
|
return ke(
|
|
2875
|
-
|
|
2875
|
+
Yt(this._map),
|
|
2876
2876
|
/** @param {any} v */
|
|
2877
2877
|
(t) => t[0]
|
|
2878
2878
|
);
|
|
@@ -2884,7 +2884,7 @@ class it extends L {
|
|
|
2884
2884
|
*/
|
|
2885
2885
|
values() {
|
|
2886
2886
|
return ke(
|
|
2887
|
-
|
|
2887
|
+
Yt(this._map),
|
|
2888
2888
|
/** @param {any} v */
|
|
2889
2889
|
(t) => t[1].content.getContent()[t[1].length - 1]
|
|
2890
2890
|
);
|
|
@@ -2896,7 +2896,7 @@ class it extends L {
|
|
|
2896
2896
|
*/
|
|
2897
2897
|
entries() {
|
|
2898
2898
|
return ke(
|
|
2899
|
-
|
|
2899
|
+
Yt(this._map),
|
|
2900
2900
|
/** @param {any} v */
|
|
2901
2901
|
(t) => [t[0], t[1].content.getContent()[t[1].length - 1]]
|
|
2902
2902
|
);
|
|
@@ -2926,7 +2926,7 @@ class it extends L {
|
|
|
2926
2926
|
*/
|
|
2927
2927
|
delete(t) {
|
|
2928
2928
|
this.doc !== null ? b(this.doc, (n) => {
|
|
2929
|
-
|
|
2929
|
+
ne(n, this, t);
|
|
2930
2930
|
}) : this._prelimContent.delete(t);
|
|
2931
2931
|
}
|
|
2932
2932
|
/**
|
|
@@ -2967,7 +2967,7 @@ class it extends L {
|
|
|
2967
2967
|
* @return {boolean}
|
|
2968
2968
|
*/
|
|
2969
2969
|
has(t) {
|
|
2970
|
-
return
|
|
2970
|
+
return Ls(this, t);
|
|
2971
2971
|
}
|
|
2972
2972
|
/**
|
|
2973
2973
|
* Removes all elements from this YMap.
|
|
@@ -2975,7 +2975,7 @@ class it extends L {
|
|
|
2975
2975
|
clear() {
|
|
2976
2976
|
this.doc !== null ? b(this.doc, (t) => {
|
|
2977
2977
|
this.forEach(function(n, s, r) {
|
|
2978
|
-
|
|
2978
|
+
ne(t, r, s);
|
|
2979
2979
|
});
|
|
2980
2980
|
}) : this._prelimContent.clear();
|
|
2981
2981
|
}
|
|
@@ -2983,10 +2983,10 @@ class it extends L {
|
|
|
2983
2983
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2984
2984
|
*/
|
|
2985
2985
|
_write(t) {
|
|
2986
|
-
t.writeTypeRef(
|
|
2986
|
+
t.writeTypeRef(vo);
|
|
2987
2987
|
}
|
|
2988
2988
|
}
|
|
2989
|
-
const
|
|
2989
|
+
const ho = (e) => new ct(), W = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && Dr(e, t);
|
|
2990
2990
|
class Be {
|
|
2991
2991
|
/**
|
|
2992
2992
|
* @param {Item|null} left
|
|
@@ -3001,9 +3001,9 @@ class Be {
|
|
|
3001
3001
|
* Only call this if you know that this.right is defined
|
|
3002
3002
|
*/
|
|
3003
3003
|
forward() {
|
|
3004
|
-
switch (this.right === null &&
|
|
3004
|
+
switch (this.right === null && V(), this.right.content.constructor) {
|
|
3005
3005
|
case E:
|
|
3006
|
-
this.right.deleted ||
|
|
3006
|
+
this.right.deleted || Et(
|
|
3007
3007
|
this.currentAttributes,
|
|
3008
3008
|
/** @type {ContentFormat} */
|
|
3009
3009
|
this.right.content
|
|
@@ -3016,34 +3016,34 @@ class Be {
|
|
|
3016
3016
|
this.left = this.right, this.right = this.right.right;
|
|
3017
3017
|
}
|
|
3018
3018
|
}
|
|
3019
|
-
const
|
|
3019
|
+
const Tn = (e, t, n) => {
|
|
3020
3020
|
for (; t.right !== null && n > 0; ) {
|
|
3021
3021
|
switch (t.right.content.constructor) {
|
|
3022
3022
|
case E:
|
|
3023
|
-
t.right.deleted ||
|
|
3023
|
+
t.right.deleted || Et(
|
|
3024
3024
|
t.currentAttributes,
|
|
3025
3025
|
/** @type {ContentFormat} */
|
|
3026
3026
|
t.right.content
|
|
3027
3027
|
);
|
|
3028
3028
|
break;
|
|
3029
3029
|
default:
|
|
3030
|
-
t.right.deleted || (n < t.right.length &&
|
|
3030
|
+
t.right.deleted || (n < t.right.length && Z(e, y(t.right.id.client, t.right.id.clock + n)), t.index += t.right.length, n -= t.right.length);
|
|
3031
3031
|
break;
|
|
3032
3032
|
}
|
|
3033
3033
|
t.left = t.right, t.right = t.right.right;
|
|
3034
3034
|
}
|
|
3035
3035
|
return t;
|
|
3036
|
-
},
|
|
3037
|
-
const s = /* @__PURE__ */ new Map(), r =
|
|
3036
|
+
}, zt = (e, t, n) => {
|
|
3037
|
+
const s = /* @__PURE__ */ new Map(), r = fe(t, n);
|
|
3038
3038
|
if (r) {
|
|
3039
3039
|
const i = new Be(r.p.left, r.p, r.index, s);
|
|
3040
|
-
return
|
|
3040
|
+
return Tn(e, i, n - r.index);
|
|
3041
3041
|
} else {
|
|
3042
3042
|
const i = new Be(null, t._start, 0, s);
|
|
3043
|
-
return
|
|
3043
|
+
return Tn(e, i, n);
|
|
3044
3044
|
}
|
|
3045
|
-
},
|
|
3046
|
-
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === E &&
|
|
3045
|
+
}, xs = (e, t, n, s) => {
|
|
3046
|
+
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === E && W(
|
|
3047
3047
|
s.get(
|
|
3048
3048
|
/** @type {ContentFormat} */
|
|
3049
3049
|
n.right.content.key
|
|
@@ -3060,12 +3060,12 @@ const Un = (e, t, n) => {
|
|
|
3060
3060
|
const l = n.left, a = n.right, h = new C(y(i, A(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new E(c, o));
|
|
3061
3061
|
h.integrate(e, 0), n.right = h, n.forward();
|
|
3062
3062
|
});
|
|
3063
|
-
},
|
|
3063
|
+
}, Et = (e, t) => {
|
|
3064
3064
|
const { key: n, value: s } = t;
|
|
3065
3065
|
s === null ? e.delete(n) : e.set(n, s);
|
|
3066
|
-
},
|
|
3066
|
+
}, Ms = (e, t) => {
|
|
3067
3067
|
for (; e.right !== null; ) {
|
|
3068
|
-
if (!(e.right.deleted || e.right.content.constructor === E &&
|
|
3068
|
+
if (!(e.right.deleted || e.right.content.constructor === E && W(
|
|
3069
3069
|
t[
|
|
3070
3070
|
/** @type {ContentFormat} */
|
|
3071
3071
|
e.right.content.key
|
|
@@ -3076,11 +3076,11 @@ const Un = (e, t, n) => {
|
|
|
3076
3076
|
break;
|
|
3077
3077
|
e.forward();
|
|
3078
3078
|
}
|
|
3079
|
-
},
|
|
3079
|
+
}, Us = (e, t, n, s) => {
|
|
3080
3080
|
const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
3081
3081
|
for (const c in s) {
|
|
3082
3082
|
const l = s[c], a = n.currentAttributes.get(c) || null;
|
|
3083
|
-
if (!
|
|
3083
|
+
if (!W(a, l)) {
|
|
3084
3084
|
o.set(c, a);
|
|
3085
3085
|
const { left: h, right: u } = n;
|
|
3086
3086
|
n.right = new C(y(i, A(r.store, i)), h, h && h.lastId, u, u && u.id, t, null, new E(c, l)), n.right.integrate(e, 0), n.forward();
|
|
@@ -3092,17 +3092,17 @@ const Un = (e, t, n) => {
|
|
|
3092
3092
|
r[f] === void 0 && (r[f] = null);
|
|
3093
3093
|
});
|
|
3094
3094
|
const i = e.doc, o = i.clientID;
|
|
3095
|
-
|
|
3096
|
-
const c =
|
|
3095
|
+
Ms(n, r);
|
|
3096
|
+
const c = Us(e, t, n, r), l = s.constructor === String ? new H(
|
|
3097
3097
|
/** @type {string} */
|
|
3098
3098
|
s
|
|
3099
|
-
) : s instanceof L ? new
|
|
3099
|
+
) : s instanceof L ? new Y(s) : new dt(s);
|
|
3100
3100
|
let { left: a, right: h, index: u } = n;
|
|
3101
|
-
t._searchMarker &&
|
|
3102
|
-
},
|
|
3101
|
+
t._searchMarker && Rt(t._searchMarker, n.index, l.getLength()), h = new C(y(o, A(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = u, n.forward(), xs(e, t, n, c);
|
|
3102
|
+
}, vn = (e, t, n, s, r) => {
|
|
3103
3103
|
const i = e.doc, o = i.clientID;
|
|
3104
|
-
|
|
3105
|
-
const c =
|
|
3104
|
+
Ms(n, r);
|
|
3105
|
+
const c = Us(e, t, n, r);
|
|
3106
3106
|
t:
|
|
3107
3107
|
for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === E)); ) {
|
|
3108
3108
|
if (!n.right.deleted)
|
|
@@ -3113,7 +3113,7 @@ const Un = (e, t, n) => {
|
|
|
3113
3113
|
n.right.content
|
|
3114
3114
|
), h = r[l];
|
|
3115
3115
|
if (h !== void 0) {
|
|
3116
|
-
if (
|
|
3116
|
+
if (W(h, a))
|
|
3117
3117
|
c.delete(l);
|
|
3118
3118
|
else {
|
|
3119
3119
|
if (s === 0)
|
|
@@ -3126,7 +3126,7 @@ const Un = (e, t, n) => {
|
|
|
3126
3126
|
break;
|
|
3127
3127
|
}
|
|
3128
3128
|
default:
|
|
3129
|
-
s < n.right.length &&
|
|
3129
|
+
s < n.right.length && Z(e, y(n.right.id.client, n.right.id.clock + s)), s -= n.right.length;
|
|
3130
3130
|
break;
|
|
3131
3131
|
}
|
|
3132
3132
|
n.forward();
|
|
@@ -3136,12 +3136,12 @@ const Un = (e, t, n) => {
|
|
|
3136
3136
|
for (; s > 0; s--)
|
|
3137
3137
|
l += `
|
|
3138
3138
|
`;
|
|
3139
|
-
n.right = new C(y(o, A(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new
|
|
3139
|
+
n.right = new C(y(o, A(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new H(l)), n.right.integrate(e, 0), n.forward();
|
|
3140
3140
|
}
|
|
3141
|
-
|
|
3142
|
-
},
|
|
3141
|
+
xs(e, t, n, c);
|
|
3142
|
+
}, Ts = (e, t, n, s, r) => {
|
|
3143
3143
|
let i = t;
|
|
3144
|
-
const o =
|
|
3144
|
+
const o = R();
|
|
3145
3145
|
for (; i && (!i.countable || i.deleted); ) {
|
|
3146
3146
|
if (!i.deleted && i.content.constructor === E) {
|
|
3147
3147
|
const a = (
|
|
@@ -3162,7 +3162,7 @@ const Un = (e, t, n) => {
|
|
|
3162
3162
|
/** @type {ContentFormat} */
|
|
3163
3163
|
a
|
|
3164
3164
|
), d = s.get(h) || null;
|
|
3165
|
-
(o.get(h) !== a || d === u) && (t.delete(e), c++, !l && (r.get(h) || null) === u && d !== u && (d === null ? r.delete(h) : r.set(h, d))), !l && !t.deleted &&
|
|
3165
|
+
(o.get(h) !== a || d === u) && (t.delete(e), c++, !l && (r.get(h) || null) === u && d !== u && (d === null ? r.delete(h) : r.set(h, d))), !l && !t.deleted && Et(
|
|
3166
3166
|
r,
|
|
3167
3167
|
/** @type {ContentFormat} */
|
|
3168
3168
|
a
|
|
@@ -3175,7 +3175,7 @@ const Un = (e, t, n) => {
|
|
|
3175
3175
|
t.right;
|
|
3176
3176
|
}
|
|
3177
3177
|
return c;
|
|
3178
|
-
},
|
|
3178
|
+
}, uo = (e, t) => {
|
|
3179
3179
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
3180
3180
|
t = t.right;
|
|
3181
3181
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -3189,7 +3189,7 @@ const Un = (e, t, n) => {
|
|
|
3189
3189
|
}
|
|
3190
3190
|
t = t.left;
|
|
3191
3191
|
}
|
|
3192
|
-
},
|
|
3192
|
+
}, fo = (e) => {
|
|
3193
3193
|
let t = 0;
|
|
3194
3194
|
return b(
|
|
3195
3195
|
/** @type {Doc} */
|
|
@@ -3198,31 +3198,31 @@ const Un = (e, t, n) => {
|
|
|
3198
3198
|
let s = (
|
|
3199
3199
|
/** @type {Item} */
|
|
3200
3200
|
e._start
|
|
3201
|
-
), r = e._start, i =
|
|
3201
|
+
), r = e._start, i = R();
|
|
3202
3202
|
const o = xe(i);
|
|
3203
3203
|
for (; r; ) {
|
|
3204
3204
|
if (r.deleted === !1)
|
|
3205
3205
|
switch (r.content.constructor) {
|
|
3206
3206
|
case E:
|
|
3207
|
-
|
|
3207
|
+
Et(
|
|
3208
3208
|
o,
|
|
3209
3209
|
/** @type {ContentFormat} */
|
|
3210
3210
|
r.content
|
|
3211
3211
|
);
|
|
3212
3212
|
break;
|
|
3213
3213
|
default:
|
|
3214
|
-
t +=
|
|
3214
|
+
t += Ts(n, s, r, i, o), i = xe(o), s = r;
|
|
3215
3215
|
break;
|
|
3216
3216
|
}
|
|
3217
3217
|
r = r.right;
|
|
3218
3218
|
}
|
|
3219
3219
|
}
|
|
3220
3220
|
), t;
|
|
3221
|
-
},
|
|
3221
|
+
}, go = (e) => {
|
|
3222
3222
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
3223
3223
|
for (const [s, r] of e.afterState.entries()) {
|
|
3224
3224
|
const i = e.beforeState.get(s) || 0;
|
|
3225
|
-
r !== i &&
|
|
3225
|
+
r !== i && ps(
|
|
3226
3226
|
e,
|
|
3227
3227
|
/** @type {Array<Item|GC>} */
|
|
3228
3228
|
n.store.clients.get(s),
|
|
@@ -3230,7 +3230,7 @@ const Un = (e, t, n) => {
|
|
|
3230
3230
|
r,
|
|
3231
3231
|
(o) => {
|
|
3232
3232
|
!o.deleted && /** @type {Item} */
|
|
3233
|
-
o.content.constructor === E && o.constructor !==
|
|
3233
|
+
o.content.constructor === E && o.constructor !== v && t.add(
|
|
3234
3234
|
/** @type {any} */
|
|
3235
3235
|
o.parent
|
|
3236
3236
|
);
|
|
@@ -3238,8 +3238,8 @@ const Un = (e, t, n) => {
|
|
|
3238
3238
|
);
|
|
3239
3239
|
}
|
|
3240
3240
|
b(n, (s) => {
|
|
3241
|
-
|
|
3242
|
-
if (r instanceof
|
|
3241
|
+
es(e, e.deleteSet, (r) => {
|
|
3242
|
+
if (r instanceof v || !/** @type {YText} */
|
|
3243
3243
|
r.parent._hasFormatting || t.has(
|
|
3244
3244
|
/** @type {YText} */
|
|
3245
3245
|
r.parent
|
|
@@ -3249,33 +3249,33 @@ const Un = (e, t, n) => {
|
|
|
3249
3249
|
/** @type {YText} */
|
|
3250
3250
|
r.parent
|
|
3251
3251
|
);
|
|
3252
|
-
r.content.constructor === E ? t.add(i) :
|
|
3252
|
+
r.content.constructor === E ? t.add(i) : uo(s, r);
|
|
3253
3253
|
});
|
|
3254
3254
|
for (const r of t)
|
|
3255
|
-
|
|
3255
|
+
fo(r);
|
|
3256
3256
|
});
|
|
3257
3257
|
}, On = (e, t, n) => {
|
|
3258
3258
|
const s = n, r = xe(t.currentAttributes), i = t.right;
|
|
3259
3259
|
for (; n > 0 && t.right !== null; ) {
|
|
3260
3260
|
if (t.right.deleted === !1)
|
|
3261
3261
|
switch (t.right.content.constructor) {
|
|
3262
|
-
case
|
|
3263
|
-
case
|
|
3264
|
-
case
|
|
3265
|
-
n < t.right.length &&
|
|
3262
|
+
case Y:
|
|
3263
|
+
case dt:
|
|
3264
|
+
case H:
|
|
3265
|
+
n < t.right.length && Z(e, y(t.right.id.client, t.right.id.clock + n)), n -= t.right.length, t.right.delete(e);
|
|
3266
3266
|
break;
|
|
3267
3267
|
}
|
|
3268
3268
|
t.forward();
|
|
3269
3269
|
}
|
|
3270
|
-
i &&
|
|
3270
|
+
i && Ts(e, i, t.right, r, t.currentAttributes);
|
|
3271
3271
|
const o = (
|
|
3272
3272
|
/** @type {AbstractType<any>} */
|
|
3273
3273
|
/** @type {Item} */
|
|
3274
3274
|
(t.left || t.right).parent
|
|
3275
3275
|
);
|
|
3276
|
-
return o._searchMarker &&
|
|
3276
|
+
return o._searchMarker && Rt(o._searchMarker, t.index, -s + n), t;
|
|
3277
3277
|
};
|
|
3278
|
-
class
|
|
3278
|
+
class po extends de {
|
|
3279
3279
|
/**
|
|
3280
3280
|
* @param {YText} ytext
|
|
3281
3281
|
* @param {Transaction} transaction
|
|
@@ -3331,12 +3331,12 @@ class fo extends fe {
|
|
|
3331
3331
|
u > 0 && (f = { delete: u }), u = 0;
|
|
3332
3332
|
break;
|
|
3333
3333
|
case "insert":
|
|
3334
|
-
(typeof a == "object" || a.length > 0) && (f = { insert: a }, r.size > 0 && (f.attributes = {}, r.forEach((g,
|
|
3335
|
-
g !== null && (f.attributes[
|
|
3334
|
+
(typeof a == "object" || a.length > 0) && (f = { insert: a }, r.size > 0 && (f.attributes = {}, r.forEach((g, m) => {
|
|
3335
|
+
g !== null && (f.attributes[m] = g);
|
|
3336
3336
|
}))), a = "";
|
|
3337
3337
|
break;
|
|
3338
3338
|
case "retain":
|
|
3339
|
-
h > 0 && (f = { retain: h },
|
|
3339
|
+
h > 0 && (f = { retain: h }, kr(l) || (f.attributes = mr({}, l))), h = 0;
|
|
3340
3340
|
break;
|
|
3341
3341
|
}
|
|
3342
3342
|
f && n.push(f), c = null;
|
|
@@ -3344,11 +3344,11 @@ class fo extends fe {
|
|
|
3344
3344
|
};
|
|
3345
3345
|
for (; o !== null; ) {
|
|
3346
3346
|
switch (o.content.constructor) {
|
|
3347
|
-
case
|
|
3348
|
-
case
|
|
3347
|
+
case Y:
|
|
3348
|
+
case dt:
|
|
3349
3349
|
this.adds(o) ? this.deletes(o) || (d(), c = "insert", a = o.content.getContent()[0], d()) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += 1) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += 1);
|
|
3350
3350
|
break;
|
|
3351
|
-
case
|
|
3351
|
+
case H:
|
|
3352
3352
|
this.adds(o) ? this.deletes(o) || (c !== "insert" && (d(), c = "insert"), a += /** @type {ContentString} */
|
|
3353
3353
|
o.content.str) : this.deletes(o) ? (c !== "delete" && (d(), c = "delete"), u += o.length) : o.deleted || (c !== "retain" && (d(), c = "retain"), h += o.length);
|
|
3354
3354
|
break;
|
|
@@ -3359,19 +3359,19 @@ class fo extends fe {
|
|
|
3359
3359
|
);
|
|
3360
3360
|
if (this.adds(o)) {
|
|
3361
3361
|
if (!this.deletes(o)) {
|
|
3362
|
-
const
|
|
3363
|
-
|
|
3362
|
+
const m = r.get(f) || null;
|
|
3363
|
+
W(m, g) ? g !== null && o.delete(s) : (c === "retain" && d(), W(g, i.get(f) || null) ? delete l[f] : l[f] = g);
|
|
3364
3364
|
}
|
|
3365
3365
|
} else if (this.deletes(o)) {
|
|
3366
3366
|
i.set(f, g);
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3367
|
+
const m = r.get(f) || null;
|
|
3368
|
+
W(m, g) || (c === "retain" && d(), l[f] = m);
|
|
3369
3369
|
} else if (!o.deleted) {
|
|
3370
3370
|
i.set(f, g);
|
|
3371
|
-
const
|
|
3372
|
-
|
|
3371
|
+
const m = l[f];
|
|
3372
|
+
m !== void 0 && (W(m, g) ? m !== null && o.delete(s) : (c === "retain" && d(), g === null ? delete l[f] : l[f] = g));
|
|
3373
3373
|
}
|
|
3374
|
-
o.deleted || (c === "insert" && d(),
|
|
3374
|
+
o.deleted || (c === "insert" && d(), Et(
|
|
3375
3375
|
r,
|
|
3376
3376
|
/** @type {ContentFormat} */
|
|
3377
3377
|
o.content
|
|
@@ -3396,7 +3396,7 @@ class fo extends fe {
|
|
|
3396
3396
|
);
|
|
3397
3397
|
}
|
|
3398
3398
|
}
|
|
3399
|
-
class
|
|
3399
|
+
class St extends L {
|
|
3400
3400
|
/**
|
|
3401
3401
|
* @param {String} [string] The initial value of the YText.
|
|
3402
3402
|
*/
|
|
@@ -3425,13 +3425,13 @@ class Dt extends L {
|
|
|
3425
3425
|
this._pending = null;
|
|
3426
3426
|
}
|
|
3427
3427
|
_copy() {
|
|
3428
|
-
return new
|
|
3428
|
+
return new St();
|
|
3429
3429
|
}
|
|
3430
3430
|
/**
|
|
3431
3431
|
* @return {YText}
|
|
3432
3432
|
*/
|
|
3433
3433
|
clone() {
|
|
3434
|
-
const t = new
|
|
3434
|
+
const t = new St();
|
|
3435
3435
|
return t.applyDelta(this.toDelta()), t;
|
|
3436
3436
|
}
|
|
3437
3437
|
/**
|
|
@@ -3442,8 +3442,8 @@ class Dt extends L {
|
|
|
3442
3442
|
*/
|
|
3443
3443
|
_callObserver(t, n) {
|
|
3444
3444
|
super._callObserver(t, n);
|
|
3445
|
-
const s = new
|
|
3446
|
-
|
|
3445
|
+
const s = new po(this, t, n);
|
|
3446
|
+
ge(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
3447
3447
|
}
|
|
3448
3448
|
/**
|
|
3449
3449
|
* Returns the unformatted string representation of this YText type.
|
|
@@ -3453,7 +3453,7 @@ class Dt extends L {
|
|
|
3453
3453
|
toString() {
|
|
3454
3454
|
let t = "", n = this._start;
|
|
3455
3455
|
for (; n !== null; )
|
|
3456
|
-
!n.deleted && n.countable && n.content.constructor ===
|
|
3456
|
+
!n.deleted && n.countable && n.content.constructor === H && (t += /** @type {ContentString} */
|
|
3457
3457
|
n.content.str), n = n.right;
|
|
3458
3458
|
return t;
|
|
3459
3459
|
}
|
|
@@ -3486,7 +3486,7 @@ class Dt extends L {
|
|
|
3486
3486
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3487
3487
|
(typeof c != "string" || c.length > 0) && De(s, this, r, c, o.attributes || {});
|
|
3488
3488
|
} else
|
|
3489
|
-
o.retain !== void 0 ?
|
|
3489
|
+
o.retain !== void 0 ? vn(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && On(s, r, o.delete);
|
|
3490
3490
|
}
|
|
3491
3491
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
3492
3492
|
}
|
|
@@ -3510,8 +3510,8 @@ class Dt extends L {
|
|
|
3510
3510
|
if (c.length > 0) {
|
|
3511
3511
|
const u = {};
|
|
3512
3512
|
let d = !1;
|
|
3513
|
-
i.forEach((g,
|
|
3514
|
-
d = !0, u[
|
|
3513
|
+
i.forEach((g, m) => {
|
|
3514
|
+
d = !0, u[m] = g;
|
|
3515
3515
|
});
|
|
3516
3516
|
const f = { insert: c };
|
|
3517
3517
|
d && (f.attributes = u), r.push(f), c = "";
|
|
@@ -3519,16 +3519,16 @@ class Dt extends L {
|
|
|
3519
3519
|
}
|
|
3520
3520
|
const h = () => {
|
|
3521
3521
|
for (; l !== null; ) {
|
|
3522
|
-
if (
|
|
3522
|
+
if (It(l, t) || n !== void 0 && It(l, n))
|
|
3523
3523
|
switch (l.content.constructor) {
|
|
3524
|
-
case
|
|
3524
|
+
case H: {
|
|
3525
3525
|
const u = i.get("ychange");
|
|
3526
|
-
t !== void 0 && !
|
|
3526
|
+
t !== void 0 && !It(l, t) ? (u === void 0 || u.user !== l.id.client || u.type !== "removed") && (a(), i.set("ychange", s ? s("removed", l.id) : { type: "removed" })) : n !== void 0 && !It(l, n) ? (u === void 0 || u.user !== l.id.client || u.type !== "added") && (a(), i.set("ychange", s ? s("added", l.id) : { type: "added" })) : u !== void 0 && (a(), i.delete("ychange")), c += /** @type {ContentString} */
|
|
3527
3527
|
l.content.str;
|
|
3528
3528
|
break;
|
|
3529
3529
|
}
|
|
3530
|
-
case
|
|
3531
|
-
case
|
|
3530
|
+
case Y:
|
|
3531
|
+
case dt: {
|
|
3532
3532
|
a();
|
|
3533
3533
|
const u = {
|
|
3534
3534
|
insert: l.content.getContent()[0]
|
|
@@ -3546,7 +3546,7 @@ class Dt extends L {
|
|
|
3546
3546
|
break;
|
|
3547
3547
|
}
|
|
3548
3548
|
case E:
|
|
3549
|
-
|
|
3549
|
+
It(l, t) && (a(), Et(
|
|
3550
3550
|
i,
|
|
3551
3551
|
/** @type {ContentFormat} */
|
|
3552
3552
|
l.content
|
|
@@ -3576,7 +3576,7 @@ class Dt extends L {
|
|
|
3576
3576
|
return;
|
|
3577
3577
|
const r = this.doc;
|
|
3578
3578
|
r !== null ? b(r, (i) => {
|
|
3579
|
-
const o =
|
|
3579
|
+
const o = zt(i, this, t);
|
|
3580
3580
|
s || (s = {}, o.currentAttributes.forEach((c, l) => {
|
|
3581
3581
|
s[l] = c;
|
|
3582
3582
|
})), De(i, this, o, n, s);
|
|
@@ -3595,7 +3595,7 @@ class Dt extends L {
|
|
|
3595
3595
|
insertEmbed(t, n, s = {}) {
|
|
3596
3596
|
const r = this.doc;
|
|
3597
3597
|
r !== null ? b(r, (i) => {
|
|
3598
|
-
const o =
|
|
3598
|
+
const o = zt(i, this, t);
|
|
3599
3599
|
De(i, this, o, n, s);
|
|
3600
3600
|
}) : this._pending.push(() => this.insertEmbed(t, n, s));
|
|
3601
3601
|
}
|
|
@@ -3612,7 +3612,7 @@ class Dt extends L {
|
|
|
3612
3612
|
return;
|
|
3613
3613
|
const s = this.doc;
|
|
3614
3614
|
s !== null ? b(s, (r) => {
|
|
3615
|
-
On(r,
|
|
3615
|
+
On(r, zt(r, this, t), n);
|
|
3616
3616
|
}) : this._pending.push(() => this.delete(t, n));
|
|
3617
3617
|
}
|
|
3618
3618
|
/**
|
|
@@ -3630,8 +3630,8 @@ class Dt extends L {
|
|
|
3630
3630
|
return;
|
|
3631
3631
|
const r = this.doc;
|
|
3632
3632
|
r !== null ? b(r, (i) => {
|
|
3633
|
-
const o =
|
|
3634
|
-
o.right !== null &&
|
|
3633
|
+
const o = zt(i, this, t);
|
|
3634
|
+
o.right !== null && vn(i, this, o, n, s);
|
|
3635
3635
|
}) : this._pending.push(() => this.format(t, n, s));
|
|
3636
3636
|
}
|
|
3637
3637
|
/**
|
|
@@ -3645,7 +3645,7 @@ class Dt extends L {
|
|
|
3645
3645
|
*/
|
|
3646
3646
|
removeAttribute(t) {
|
|
3647
3647
|
this.doc !== null ? b(this.doc, (n) => {
|
|
3648
|
-
|
|
3648
|
+
ne(n, this, t);
|
|
3649
3649
|
}) : this._pending.push(() => this.removeAttribute(t));
|
|
3650
3650
|
}
|
|
3651
3651
|
/**
|
|
@@ -3690,16 +3690,16 @@ class Dt extends L {
|
|
|
3690
3690
|
* @public
|
|
3691
3691
|
*/
|
|
3692
3692
|
getAttributes() {
|
|
3693
|
-
return
|
|
3693
|
+
return As(this);
|
|
3694
3694
|
}
|
|
3695
3695
|
/**
|
|
3696
3696
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3697
3697
|
*/
|
|
3698
3698
|
_write(t) {
|
|
3699
|
-
t.writeTypeRef(
|
|
3699
|
+
t.writeTypeRef(Oo);
|
|
3700
3700
|
}
|
|
3701
3701
|
}
|
|
3702
|
-
const
|
|
3702
|
+
const wo = (e) => new St();
|
|
3703
3703
|
class Ce {
|
|
3704
3704
|
/**
|
|
3705
3705
|
* @param {YXmlFragment | YXmlElement} root
|
|
@@ -3725,7 +3725,7 @@ class Ce {
|
|
|
3725
3725
|
if (t !== null && (!this._firstCall || t.deleted || !this._filter(n)))
|
|
3726
3726
|
do
|
|
3727
3727
|
if (n = /** @type {any} */
|
|
3728
|
-
t.content.type, !t.deleted && (n.constructor ===
|
|
3728
|
+
t.content.type, !t.deleted && (n.constructor === Bt || n.constructor === lt) && n._start !== null)
|
|
3729
3729
|
t = n._start;
|
|
3730
3730
|
else
|
|
3731
3731
|
for (; t !== null; )
|
|
@@ -3745,7 +3745,7 @@ class Ce {
|
|
|
3745
3745
|
), done: !1 });
|
|
3746
3746
|
}
|
|
3747
3747
|
}
|
|
3748
|
-
class
|
|
3748
|
+
class lt extends L {
|
|
3749
3749
|
constructor() {
|
|
3750
3750
|
super(), this._prelimContent = [];
|
|
3751
3751
|
}
|
|
@@ -3774,13 +3774,13 @@ class ot extends L {
|
|
|
3774
3774
|
), this._prelimContent = null;
|
|
3775
3775
|
}
|
|
3776
3776
|
_copy() {
|
|
3777
|
-
return new
|
|
3777
|
+
return new lt();
|
|
3778
3778
|
}
|
|
3779
3779
|
/**
|
|
3780
3780
|
* @return {YXmlFragment}
|
|
3781
3781
|
*/
|
|
3782
3782
|
clone() {
|
|
3783
|
-
const t = new
|
|
3783
|
+
const t = new lt();
|
|
3784
3784
|
return t.insert(0, this.toArray().map((n) => n instanceof L ? n.clone() : n)), t;
|
|
3785
3785
|
}
|
|
3786
3786
|
get length() {
|
|
@@ -3838,7 +3838,7 @@ class ot extends L {
|
|
|
3838
3838
|
* @public
|
|
3839
3839
|
*/
|
|
3840
3840
|
querySelectorAll(t) {
|
|
3841
|
-
return t = t.toUpperCase(),
|
|
3841
|
+
return t = t.toUpperCase(), Q(new Ce(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
|
|
3842
3842
|
}
|
|
3843
3843
|
/**
|
|
3844
3844
|
* Creates YXmlEvent and calls observers.
|
|
@@ -3847,7 +3847,7 @@ class ot extends L {
|
|
|
3847
3847
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3848
3848
|
*/
|
|
3849
3849
|
_callObserver(t, n) {
|
|
3850
|
-
|
|
3850
|
+
ge(this, t, new _o(this, n, t));
|
|
3851
3851
|
}
|
|
3852
3852
|
/**
|
|
3853
3853
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -3855,7 +3855,7 @@ class ot extends L {
|
|
|
3855
3855
|
* @return {string} The string representation of all children.
|
|
3856
3856
|
*/
|
|
3857
3857
|
toString() {
|
|
3858
|
-
return
|
|
3858
|
+
return Ss(this, (t) => t.toString()).join("");
|
|
3859
3859
|
}
|
|
3860
3860
|
/**
|
|
3861
3861
|
* @return {string}
|
|
@@ -3880,7 +3880,7 @@ class ot extends L {
|
|
|
3880
3880
|
*/
|
|
3881
3881
|
toDOM(t = document, n = {}, s) {
|
|
3882
3882
|
const r = t.createDocumentFragment();
|
|
3883
|
-
return s !== void 0 && s._createAssociation(r, this),
|
|
3883
|
+
return s !== void 0 && s._createAssociation(r, this), Nt(this, (i) => {
|
|
3884
3884
|
r.insertBefore(i.toDOM(t, n, s), null);
|
|
3885
3885
|
}), r;
|
|
3886
3886
|
}
|
|
@@ -3896,7 +3896,7 @@ class ot extends L {
|
|
|
3896
3896
|
*/
|
|
3897
3897
|
insert(t, n) {
|
|
3898
3898
|
this.doc !== null ? b(this.doc, (s) => {
|
|
3899
|
-
|
|
3899
|
+
Es(s, this, t, n);
|
|
3900
3900
|
}) : this._prelimContent.splice(t, 0, ...n);
|
|
3901
3901
|
}
|
|
3902
3902
|
/**
|
|
@@ -3913,7 +3913,7 @@ class ot extends L {
|
|
|
3913
3913
|
if (this.doc !== null)
|
|
3914
3914
|
b(this.doc, (s) => {
|
|
3915
3915
|
const r = t && t instanceof L ? t._item : t;
|
|
3916
|
-
|
|
3916
|
+
ee(s, this, r, n);
|
|
3917
3917
|
});
|
|
3918
3918
|
else {
|
|
3919
3919
|
const s = (
|
|
@@ -3921,7 +3921,7 @@ class ot extends L {
|
|
|
3921
3921
|
this._prelimContent
|
|
3922
3922
|
), r = t === null ? 0 : s.findIndex((i) => i === t) + 1;
|
|
3923
3923
|
if (r === 0 && t !== null)
|
|
3924
|
-
throw
|
|
3924
|
+
throw ut("Reference item not found");
|
|
3925
3925
|
s.splice(r, 0, ...n);
|
|
3926
3926
|
}
|
|
3927
3927
|
}
|
|
@@ -3933,7 +3933,7 @@ class ot extends L {
|
|
|
3933
3933
|
*/
|
|
3934
3934
|
delete(t, n = 1) {
|
|
3935
3935
|
this.doc !== null ? b(this.doc, (s) => {
|
|
3936
|
-
|
|
3936
|
+
Is(s, this, t, n);
|
|
3937
3937
|
}) : this._prelimContent.splice(t, n);
|
|
3938
3938
|
}
|
|
3939
3939
|
/**
|
|
@@ -3942,7 +3942,7 @@ class ot extends L {
|
|
|
3942
3942
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
3943
3943
|
*/
|
|
3944
3944
|
toArray() {
|
|
3945
|
-
return
|
|
3945
|
+
return ks(this);
|
|
3946
3946
|
}
|
|
3947
3947
|
/**
|
|
3948
3948
|
* Appends content to this YArray.
|
|
@@ -3967,7 +3967,7 @@ class ot extends L {
|
|
|
3967
3967
|
* @return {YXmlElement|YXmlText}
|
|
3968
3968
|
*/
|
|
3969
3969
|
get(t) {
|
|
3970
|
-
return
|
|
3970
|
+
return Ds(this, t);
|
|
3971
3971
|
}
|
|
3972
3972
|
/**
|
|
3973
3973
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -3977,7 +3977,7 @@ class ot extends L {
|
|
|
3977
3977
|
* @return {Array<YXmlElement|YXmlText>}
|
|
3978
3978
|
*/
|
|
3979
3979
|
slice(t = 0, n = this.length) {
|
|
3980
|
-
return
|
|
3980
|
+
return bs(this, t, n);
|
|
3981
3981
|
}
|
|
3982
3982
|
/**
|
|
3983
3983
|
* Executes a provided function on once on overy child element.
|
|
@@ -3985,7 +3985,7 @@ class ot extends L {
|
|
|
3985
3985
|
* @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
|
|
3986
3986
|
*/
|
|
3987
3987
|
forEach(t) {
|
|
3988
|
-
|
|
3988
|
+
Nt(this, t);
|
|
3989
3989
|
}
|
|
3990
3990
|
/**
|
|
3991
3991
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -3996,11 +3996,11 @@ class ot extends L {
|
|
|
3996
3996
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
3997
3997
|
*/
|
|
3998
3998
|
_write(t) {
|
|
3999
|
-
t.writeTypeRef(
|
|
3999
|
+
t.writeTypeRef(No);
|
|
4000
4000
|
}
|
|
4001
4001
|
}
|
|
4002
|
-
const
|
|
4003
|
-
class
|
|
4002
|
+
const mo = (e) => new lt();
|
|
4003
|
+
class Bt extends lt {
|
|
4004
4004
|
constructor(t = "UNDEFINED") {
|
|
4005
4005
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
4006
4006
|
}
|
|
@@ -4048,14 +4048,14 @@ class Vt extends ot {
|
|
|
4048
4048
|
* @return {YXmlElement}
|
|
4049
4049
|
*/
|
|
4050
4050
|
_copy() {
|
|
4051
|
-
return new
|
|
4051
|
+
return new Bt(this.nodeName);
|
|
4052
4052
|
}
|
|
4053
4053
|
/**
|
|
4054
4054
|
* @return {YXmlElement<KV>}
|
|
4055
4055
|
*/
|
|
4056
4056
|
clone() {
|
|
4057
|
-
const t = new
|
|
4058
|
-
return
|
|
4057
|
+
const t = new Bt(this.nodeName), n = this.getAttributes();
|
|
4058
|
+
return _r(n, (s, r) => {
|
|
4059
4059
|
typeof s == "string" && t.setAttribute(r, s);
|
|
4060
4060
|
}), t.insert(0, this.toArray().map((s) => s instanceof L ? s.clone() : s)), t;
|
|
4061
4061
|
}
|
|
@@ -4090,7 +4090,7 @@ class Vt extends ot {
|
|
|
4090
4090
|
*/
|
|
4091
4091
|
removeAttribute(t) {
|
|
4092
4092
|
this.doc !== null ? b(this.doc, (n) => {
|
|
4093
|
-
|
|
4093
|
+
ne(n, this, t);
|
|
4094
4094
|
}) : this._prelimAttrs.delete(t);
|
|
4095
4095
|
}
|
|
4096
4096
|
/**
|
|
@@ -4136,7 +4136,7 @@ class Vt extends ot {
|
|
|
4136
4136
|
hasAttribute(t) {
|
|
4137
4137
|
return (
|
|
4138
4138
|
/** @type {any} */
|
|
4139
|
-
|
|
4139
|
+
Ls(this, t)
|
|
4140
4140
|
);
|
|
4141
4141
|
}
|
|
4142
4142
|
/**
|
|
@@ -4149,7 +4149,7 @@ class Vt extends ot {
|
|
|
4149
4149
|
getAttributes() {
|
|
4150
4150
|
return (
|
|
4151
4151
|
/** @type {any} */
|
|
4152
|
-
|
|
4152
|
+
As(this)
|
|
4153
4153
|
);
|
|
4154
4154
|
}
|
|
4155
4155
|
/**
|
|
@@ -4173,7 +4173,7 @@ class Vt extends ot {
|
|
|
4173
4173
|
const c = i[o];
|
|
4174
4174
|
typeof c == "string" && r.setAttribute(o, c);
|
|
4175
4175
|
}
|
|
4176
|
-
return
|
|
4176
|
+
return Nt(this, (o) => {
|
|
4177
4177
|
r.appendChild(o.toDOM(t, n, s));
|
|
4178
4178
|
}), s !== void 0 && s._createAssociation(r, this), r;
|
|
4179
4179
|
}
|
|
@@ -4186,11 +4186,11 @@ class Vt extends ot {
|
|
|
4186
4186
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4187
4187
|
*/
|
|
4188
4188
|
_write(t) {
|
|
4189
|
-
t.writeTypeRef(
|
|
4189
|
+
t.writeTypeRef(Ro), t.writeKey(this.nodeName);
|
|
4190
4190
|
}
|
|
4191
4191
|
}
|
|
4192
|
-
const
|
|
4193
|
-
class
|
|
4192
|
+
const yo = (e) => new Bt(e.readKey());
|
|
4193
|
+
class _o extends de {
|
|
4194
4194
|
/**
|
|
4195
4195
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
4196
4196
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -4204,7 +4204,7 @@ class mo extends fe {
|
|
|
4204
4204
|
});
|
|
4205
4205
|
}
|
|
4206
4206
|
}
|
|
4207
|
-
class
|
|
4207
|
+
class se extends ct {
|
|
4208
4208
|
/**
|
|
4209
4209
|
* @param {string} hookName nodeName of the Dom Node.
|
|
4210
4210
|
*/
|
|
@@ -4215,13 +4215,13 @@ class re extends it {
|
|
|
4215
4215
|
* Creates an Item with the same effect as this Item (without position effect)
|
|
4216
4216
|
*/
|
|
4217
4217
|
_copy() {
|
|
4218
|
-
return new
|
|
4218
|
+
return new se(this.hookName);
|
|
4219
4219
|
}
|
|
4220
4220
|
/**
|
|
4221
4221
|
* @return {YXmlHook}
|
|
4222
4222
|
*/
|
|
4223
4223
|
clone() {
|
|
4224
|
-
const t = new
|
|
4224
|
+
const t = new se(this.hookName);
|
|
4225
4225
|
return this.forEach((n, s) => {
|
|
4226
4226
|
t.set(s, n);
|
|
4227
4227
|
}), t;
|
|
@@ -4255,11 +4255,11 @@ class re extends it {
|
|
|
4255
4255
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4256
4256
|
*/
|
|
4257
4257
|
_write(t) {
|
|
4258
|
-
t.writeTypeRef(
|
|
4258
|
+
t.writeTypeRef(Bo), t.writeKey(this.hookName);
|
|
4259
4259
|
}
|
|
4260
4260
|
}
|
|
4261
|
-
const
|
|
4262
|
-
class
|
|
4261
|
+
const bo = (e) => new se(e.readKey());
|
|
4262
|
+
class re extends St {
|
|
4263
4263
|
/**
|
|
4264
4264
|
* @type {YXmlElement|YXmlText|null}
|
|
4265
4265
|
*/
|
|
@@ -4283,13 +4283,13 @@ class ie extends Dt {
|
|
|
4283
4283
|
) : null;
|
|
4284
4284
|
}
|
|
4285
4285
|
_copy() {
|
|
4286
|
-
return new
|
|
4286
|
+
return new re();
|
|
4287
4287
|
}
|
|
4288
4288
|
/**
|
|
4289
4289
|
* @return {YXmlText}
|
|
4290
4290
|
*/
|
|
4291
4291
|
clone() {
|
|
4292
|
-
const t = new
|
|
4292
|
+
const t = new re();
|
|
4293
4293
|
return t.applyDelta(this.toDelta()), t;
|
|
4294
4294
|
}
|
|
4295
4295
|
/**
|
|
@@ -4347,10 +4347,10 @@ class ie extends Dt {
|
|
|
4347
4347
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4348
4348
|
*/
|
|
4349
4349
|
_write(t) {
|
|
4350
|
-
t.writeTypeRef(
|
|
4350
|
+
t.writeTypeRef(Vo);
|
|
4351
4351
|
}
|
|
4352
4352
|
}
|
|
4353
|
-
const
|
|
4353
|
+
const ko = (e) => new re();
|
|
4354
4354
|
class an {
|
|
4355
4355
|
/**
|
|
4356
4356
|
* @param {ID} id
|
|
@@ -4363,7 +4363,7 @@ class an {
|
|
|
4363
4363
|
* @type {boolean}
|
|
4364
4364
|
*/
|
|
4365
4365
|
get deleted() {
|
|
4366
|
-
throw
|
|
4366
|
+
throw B();
|
|
4367
4367
|
}
|
|
4368
4368
|
/**
|
|
4369
4369
|
* Merge this struct with the item to the right.
|
|
@@ -4381,18 +4381,18 @@ class an {
|
|
|
4381
4381
|
* @param {number} encodingRef
|
|
4382
4382
|
*/
|
|
4383
4383
|
write(t, n, s) {
|
|
4384
|
-
throw
|
|
4384
|
+
throw B();
|
|
4385
4385
|
}
|
|
4386
4386
|
/**
|
|
4387
4387
|
* @param {Transaction} transaction
|
|
4388
4388
|
* @param {number} offset
|
|
4389
4389
|
*/
|
|
4390
4390
|
integrate(t, n) {
|
|
4391
|
-
throw
|
|
4391
|
+
throw B();
|
|
4392
4392
|
}
|
|
4393
4393
|
}
|
|
4394
|
-
const
|
|
4395
|
-
class
|
|
4394
|
+
const So = 0;
|
|
4395
|
+
class v extends an {
|
|
4396
4396
|
get deleted() {
|
|
4397
4397
|
return !0;
|
|
4398
4398
|
}
|
|
@@ -4410,14 +4410,14 @@ class T extends an {
|
|
|
4410
4410
|
* @param {number} offset
|
|
4411
4411
|
*/
|
|
4412
4412
|
integrate(t, n) {
|
|
4413
|
-
n > 0 && (this.id.clock += n, this.length -= n),
|
|
4413
|
+
n > 0 && (this.id.clock += n, this.length -= n), gs(t.doc.store, this);
|
|
4414
4414
|
}
|
|
4415
4415
|
/**
|
|
4416
4416
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4417
4417
|
* @param {number} offset
|
|
4418
4418
|
*/
|
|
4419
4419
|
write(t, n) {
|
|
4420
|
-
t.writeInfo(
|
|
4420
|
+
t.writeInfo(So), t.writeLen(this.length - n);
|
|
4421
4421
|
}
|
|
4422
4422
|
/**
|
|
4423
4423
|
* @param {Transaction} transaction
|
|
@@ -4428,7 +4428,7 @@ class T extends an {
|
|
|
4428
4428
|
return null;
|
|
4429
4429
|
}
|
|
4430
4430
|
}
|
|
4431
|
-
class
|
|
4431
|
+
class Kt {
|
|
4432
4432
|
/**
|
|
4433
4433
|
* @param {Uint8Array} content
|
|
4434
4434
|
*/
|
|
@@ -4457,14 +4457,14 @@ class jt {
|
|
|
4457
4457
|
* @return {ContentBinary}
|
|
4458
4458
|
*/
|
|
4459
4459
|
copy() {
|
|
4460
|
-
return new
|
|
4460
|
+
return new Kt(this.content);
|
|
4461
4461
|
}
|
|
4462
4462
|
/**
|
|
4463
4463
|
* @param {number} offset
|
|
4464
4464
|
* @return {ContentBinary}
|
|
4465
4465
|
*/
|
|
4466
4466
|
splice(t) {
|
|
4467
|
-
throw
|
|
4467
|
+
throw B();
|
|
4468
4468
|
}
|
|
4469
4469
|
/**
|
|
4470
4470
|
* @param {ContentBinary} right
|
|
@@ -4503,8 +4503,8 @@ class jt {
|
|
|
4503
4503
|
return 3;
|
|
4504
4504
|
}
|
|
4505
4505
|
}
|
|
4506
|
-
const
|
|
4507
|
-
class
|
|
4506
|
+
const Do = (e) => new Kt(e.readBuf());
|
|
4507
|
+
class Vt {
|
|
4508
4508
|
/**
|
|
4509
4509
|
* @param {number} len
|
|
4510
4510
|
*/
|
|
@@ -4533,14 +4533,14 @@ class Ft {
|
|
|
4533
4533
|
* @return {ContentDeleted}
|
|
4534
4534
|
*/
|
|
4535
4535
|
copy() {
|
|
4536
|
-
return new
|
|
4536
|
+
return new Vt(this.len);
|
|
4537
4537
|
}
|
|
4538
4538
|
/**
|
|
4539
4539
|
* @param {number} offset
|
|
4540
4540
|
* @return {ContentDeleted}
|
|
4541
4541
|
*/
|
|
4542
4542
|
splice(t) {
|
|
4543
|
-
const n = new
|
|
4543
|
+
const n = new Vt(this.len - t);
|
|
4544
4544
|
return this.len = t, n;
|
|
4545
4545
|
}
|
|
4546
4546
|
/**
|
|
@@ -4555,7 +4555,7 @@ class Ft {
|
|
|
4555
4555
|
* @param {Item} item
|
|
4556
4556
|
*/
|
|
4557
4557
|
integrate(t, n) {
|
|
4558
|
-
|
|
4558
|
+
Pt(t.deleteSet, n.id.client, n.id.clock, this.len), n.markDeleted();
|
|
4559
4559
|
}
|
|
4560
4560
|
/**
|
|
4561
4561
|
* @param {Transaction} transaction
|
|
@@ -4581,8 +4581,8 @@ class Ft {
|
|
|
4581
4581
|
return 1;
|
|
4582
4582
|
}
|
|
4583
4583
|
}
|
|
4584
|
-
const
|
|
4585
|
-
class
|
|
4584
|
+
const Co = (e) => new Vt(e.readLen()), vs = (e, t) => new Ct({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
4585
|
+
class jt {
|
|
4586
4586
|
/**
|
|
4587
4587
|
* @param {Doc} doc
|
|
4588
4588
|
*/
|
|
@@ -4613,14 +4613,14 @@ class Jt {
|
|
|
4613
4613
|
* @return {ContentDoc}
|
|
4614
4614
|
*/
|
|
4615
4615
|
copy() {
|
|
4616
|
-
return new
|
|
4616
|
+
return new jt(vs(this.doc.guid, this.opts));
|
|
4617
4617
|
}
|
|
4618
4618
|
/**
|
|
4619
4619
|
* @param {number} offset
|
|
4620
4620
|
* @return {ContentDoc}
|
|
4621
4621
|
*/
|
|
4622
4622
|
splice(t) {
|
|
4623
|
-
throw
|
|
4623
|
+
throw B();
|
|
4624
4624
|
}
|
|
4625
4625
|
/**
|
|
4626
4626
|
* @param {ContentDoc} right
|
|
@@ -4661,8 +4661,8 @@ class Jt {
|
|
|
4661
4661
|
return 9;
|
|
4662
4662
|
}
|
|
4663
4663
|
}
|
|
4664
|
-
const
|
|
4665
|
-
class
|
|
4664
|
+
const Eo = (e) => new jt(vs(e.readString(), e.readAny()));
|
|
4665
|
+
class dt {
|
|
4666
4666
|
/**
|
|
4667
4667
|
* @param {Object} embed
|
|
4668
4668
|
*/
|
|
@@ -4691,14 +4691,14 @@ class ht {
|
|
|
4691
4691
|
* @return {ContentEmbed}
|
|
4692
4692
|
*/
|
|
4693
4693
|
copy() {
|
|
4694
|
-
return new
|
|
4694
|
+
return new dt(this.embed);
|
|
4695
4695
|
}
|
|
4696
4696
|
/**
|
|
4697
4697
|
* @param {number} offset
|
|
4698
4698
|
* @return {ContentEmbed}
|
|
4699
4699
|
*/
|
|
4700
4700
|
splice(t) {
|
|
4701
|
-
throw
|
|
4701
|
+
throw B();
|
|
4702
4702
|
}
|
|
4703
4703
|
/**
|
|
4704
4704
|
* @param {ContentEmbed} right
|
|
@@ -4737,7 +4737,7 @@ class ht {
|
|
|
4737
4737
|
return 5;
|
|
4738
4738
|
}
|
|
4739
4739
|
}
|
|
4740
|
-
const
|
|
4740
|
+
const Io = (e) => new dt(e.readJSON());
|
|
4741
4741
|
class E {
|
|
4742
4742
|
/**
|
|
4743
4743
|
* @param {string} key
|
|
@@ -4775,7 +4775,7 @@ class E {
|
|
|
4775
4775
|
* @return {ContentFormat}
|
|
4776
4776
|
*/
|
|
4777
4777
|
splice(t) {
|
|
4778
|
-
throw
|
|
4778
|
+
throw B();
|
|
4779
4779
|
}
|
|
4780
4780
|
/**
|
|
4781
4781
|
* @param {ContentFormat} _right
|
|
@@ -4819,8 +4819,8 @@ class E {
|
|
|
4819
4819
|
return 6;
|
|
4820
4820
|
}
|
|
4821
4821
|
}
|
|
4822
|
-
const
|
|
4823
|
-
class
|
|
4822
|
+
const Ao = (e) => new E(e.readKey(), e.readJSON());
|
|
4823
|
+
class ie {
|
|
4824
4824
|
/**
|
|
4825
4825
|
* @param {Array<any>} arr
|
|
4826
4826
|
*/
|
|
@@ -4849,14 +4849,14 @@ class oe {
|
|
|
4849
4849
|
* @return {ContentJSON}
|
|
4850
4850
|
*/
|
|
4851
4851
|
copy() {
|
|
4852
|
-
return new
|
|
4852
|
+
return new ie(this.arr);
|
|
4853
4853
|
}
|
|
4854
4854
|
/**
|
|
4855
4855
|
* @param {number} offset
|
|
4856
4856
|
* @return {ContentJSON}
|
|
4857
4857
|
*/
|
|
4858
4858
|
splice(t) {
|
|
4859
|
-
const n = new
|
|
4859
|
+
const n = new ie(this.arr.slice(t));
|
|
4860
4860
|
return this.arr = this.arr.slice(0, t), n;
|
|
4861
4861
|
}
|
|
4862
4862
|
/**
|
|
@@ -4901,15 +4901,15 @@ class oe {
|
|
|
4901
4901
|
return 2;
|
|
4902
4902
|
}
|
|
4903
4903
|
}
|
|
4904
|
-
const
|
|
4904
|
+
const Lo = (e) => {
|
|
4905
4905
|
const t = e.readLen(), n = [];
|
|
4906
4906
|
for (let s = 0; s < t; s++) {
|
|
4907
4907
|
const r = e.readString();
|
|
4908
4908
|
r === "undefined" ? n.push(void 0) : n.push(JSON.parse(r));
|
|
4909
4909
|
}
|
|
4910
|
-
return new
|
|
4910
|
+
return new ie(n);
|
|
4911
4911
|
};
|
|
4912
|
-
class
|
|
4912
|
+
class at {
|
|
4913
4913
|
/**
|
|
4914
4914
|
* @param {Array<any>} arr
|
|
4915
4915
|
*/
|
|
@@ -4938,14 +4938,14 @@ class ct {
|
|
|
4938
4938
|
* @return {ContentAny}
|
|
4939
4939
|
*/
|
|
4940
4940
|
copy() {
|
|
4941
|
-
return new
|
|
4941
|
+
return new at(this.arr);
|
|
4942
4942
|
}
|
|
4943
4943
|
/**
|
|
4944
4944
|
* @param {number} offset
|
|
4945
4945
|
* @return {ContentAny}
|
|
4946
4946
|
*/
|
|
4947
4947
|
splice(t) {
|
|
4948
|
-
const n = new
|
|
4948
|
+
const n = new at(this.arr.slice(t));
|
|
4949
4949
|
return this.arr = this.arr.slice(0, t), n;
|
|
4950
4950
|
}
|
|
4951
4951
|
/**
|
|
@@ -4990,13 +4990,13 @@ class ct {
|
|
|
4990
4990
|
return 8;
|
|
4991
4991
|
}
|
|
4992
4992
|
}
|
|
4993
|
-
const
|
|
4993
|
+
const xo = (e) => {
|
|
4994
4994
|
const t = e.readLen(), n = [];
|
|
4995
4995
|
for (let s = 0; s < t; s++)
|
|
4996
4996
|
n.push(e.readAny());
|
|
4997
|
-
return new
|
|
4997
|
+
return new at(n);
|
|
4998
4998
|
};
|
|
4999
|
-
class
|
|
4999
|
+
class H {
|
|
5000
5000
|
/**
|
|
5001
5001
|
* @param {string} str
|
|
5002
5002
|
*/
|
|
@@ -5025,14 +5025,14 @@ class F {
|
|
|
5025
5025
|
* @return {ContentString}
|
|
5026
5026
|
*/
|
|
5027
5027
|
copy() {
|
|
5028
|
-
return new
|
|
5028
|
+
return new H(this.str);
|
|
5029
5029
|
}
|
|
5030
5030
|
/**
|
|
5031
5031
|
* @param {number} offset
|
|
5032
5032
|
* @return {ContentString}
|
|
5033
5033
|
*/
|
|
5034
5034
|
splice(t) {
|
|
5035
|
-
const n = new
|
|
5035
|
+
const n = new H(this.str.slice(t));
|
|
5036
5036
|
this.str = this.str.slice(0, t);
|
|
5037
5037
|
const s = this.str.charCodeAt(t - 1);
|
|
5038
5038
|
return s >= 55296 && s <= 56319 && (this.str = this.str.slice(0, t - 1) + "�", n.str = "�" + n.str.slice(1)), n;
|
|
@@ -5074,16 +5074,16 @@ class F {
|
|
|
5074
5074
|
return 4;
|
|
5075
5075
|
}
|
|
5076
5076
|
}
|
|
5077
|
-
const
|
|
5078
|
-
oo,
|
|
5077
|
+
const Mo = (e) => new H(e.readString()), Uo = [
|
|
5079
5078
|
lo,
|
|
5080
|
-
|
|
5079
|
+
ho,
|
|
5081
5080
|
wo,
|
|
5082
|
-
po,
|
|
5083
5081
|
yo,
|
|
5084
|
-
|
|
5085
|
-
|
|
5086
|
-
|
|
5082
|
+
mo,
|
|
5083
|
+
bo,
|
|
5084
|
+
ko
|
|
5085
|
+
], To = 0, vo = 1, Oo = 2, Ro = 3, No = 4, Bo = 5, Vo = 6;
|
|
5086
|
+
class Y {
|
|
5087
5087
|
/**
|
|
5088
5088
|
* @param {AbstractType<any>} type
|
|
5089
5089
|
*/
|
|
@@ -5112,14 +5112,14 @@ class X {
|
|
|
5112
5112
|
* @return {ContentType}
|
|
5113
5113
|
*/
|
|
5114
5114
|
copy() {
|
|
5115
|
-
return new
|
|
5115
|
+
return new Y(this.type._copy());
|
|
5116
5116
|
}
|
|
5117
5117
|
/**
|
|
5118
5118
|
* @param {number} offset
|
|
5119
5119
|
* @return {ContentType}
|
|
5120
5120
|
*/
|
|
5121
5121
|
splice(t) {
|
|
5122
|
-
throw
|
|
5122
|
+
throw B();
|
|
5123
5123
|
}
|
|
5124
5124
|
/**
|
|
5125
5125
|
* @param {ContentType} right
|
|
@@ -5175,7 +5175,7 @@ class X {
|
|
|
5175
5175
|
return 7;
|
|
5176
5176
|
}
|
|
5177
5177
|
}
|
|
5178
|
-
const
|
|
5178
|
+
const Fo = (e) => new Y(Uo[e.readTypeRef()](e)), oe = (e, t, n) => {
|
|
5179
5179
|
const { client: s, clock: r } = t.id, i = new C(
|
|
5180
5180
|
y(s, r + n),
|
|
5181
5181
|
t,
|
|
@@ -5200,7 +5200,7 @@ class C extends an {
|
|
|
5200
5200
|
* @param {AbstractContent} content
|
|
5201
5201
|
*/
|
|
5202
5202
|
constructor(t, n, s, r, i, o, c, l) {
|
|
5203
|
-
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() ?
|
|
5203
|
+
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() ? _n : 0;
|
|
5204
5204
|
}
|
|
5205
5205
|
/**
|
|
5206
5206
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5217,13 +5217,13 @@ class C extends an {
|
|
|
5217
5217
|
* If true, do not garbage collect this Item.
|
|
5218
5218
|
*/
|
|
5219
5219
|
get keep() {
|
|
5220
|
-
return (this.info &
|
|
5220
|
+
return (this.info & yn) > 0;
|
|
5221
5221
|
}
|
|
5222
5222
|
set keep(t) {
|
|
5223
|
-
this.keep !== t && (this.info ^=
|
|
5223
|
+
this.keep !== t && (this.info ^= yn);
|
|
5224
5224
|
}
|
|
5225
5225
|
get countable() {
|
|
5226
|
-
return (this.info &
|
|
5226
|
+
return (this.info & _n) > 0;
|
|
5227
5227
|
}
|
|
5228
5228
|
/**
|
|
5229
5229
|
* Whether this item was deleted or not.
|
|
@@ -5250,13 +5250,13 @@ class C extends an {
|
|
|
5250
5250
|
return this.origin.client;
|
|
5251
5251
|
if (this.rightOrigin && this.rightOrigin.client !== this.id.client && this.rightOrigin.clock >= A(n, this.rightOrigin.client))
|
|
5252
5252
|
return this.rightOrigin.client;
|
|
5253
|
-
if (this.parent && this.parent.constructor ===
|
|
5253
|
+
if (this.parent && this.parent.constructor === pt && this.id.client !== this.parent.client && this.parent.clock >= A(n, this.parent.client))
|
|
5254
5254
|
return this.parent.client;
|
|
5255
|
-
if (this.origin && (this.left =
|
|
5255
|
+
if (this.origin && (this.left = xn(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = Z(t, this.rightOrigin), this.rightOrigin = this.right.id), (this.left && this.left.constructor === v || this.right && this.right.constructor === v) && (this.parent = null), !this.parent)
|
|
5256
5256
|
this.left && this.left.constructor === C && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === C && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
|
|
5257
|
-
else if (this.parent.constructor ===
|
|
5257
|
+
else if (this.parent.constructor === pt) {
|
|
5258
5258
|
const s = Se(n, this.parent);
|
|
5259
|
-
s.constructor ===
|
|
5259
|
+
s.constructor === v ? this.parent = null : this.parent = /** @type {ContentType} */
|
|
5260
5260
|
s.content.type;
|
|
5261
5261
|
}
|
|
5262
5262
|
return null;
|
|
@@ -5266,7 +5266,7 @@ class C extends an {
|
|
|
5266
5266
|
* @param {number} offset
|
|
5267
5267
|
*/
|
|
5268
5268
|
integrate(t, n) {
|
|
5269
|
-
if (n > 0 && (this.id.clock += n, this.left =
|
|
5269
|
+
if (n > 0 && (this.id.clock += n, this.left = xn(t, t.doc.store, y(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(n), this.length -= n), this.parent) {
|
|
5270
5270
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5271
5271
|
let s = this.left, r;
|
|
5272
5272
|
if (s !== null)
|
|
@@ -5280,10 +5280,10 @@ class C extends an {
|
|
|
5280
5280
|
this.parent._start;
|
|
5281
5281
|
const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
5282
5282
|
for (; r !== null && r !== this.right; ) {
|
|
5283
|
-
if (o.add(r), i.add(r),
|
|
5283
|
+
if (o.add(r), i.add(r), Xt(this.origin, r.origin)) {
|
|
5284
5284
|
if (r.id.client < this.id.client)
|
|
5285
5285
|
s = r, i.clear();
|
|
5286
|
-
else if (
|
|
5286
|
+
else if (Xt(this.rightOrigin, r.rightOrigin))
|
|
5287
5287
|
break;
|
|
5288
5288
|
} else if (r.origin !== null && o.has(Se(t.doc.store, r.origin)))
|
|
5289
5289
|
i.has(Se(t.doc.store, r.origin)) || (s = r, i.clear());
|
|
@@ -5307,7 +5307,7 @@ class C extends an {
|
|
|
5307
5307
|
this.parent._start, this.parent._start = this;
|
|
5308
5308
|
this.right = s;
|
|
5309
5309
|
}
|
|
5310
|
-
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),
|
|
5310
|
+
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), gs(t.doc.store, this), this.content.integrate(t, this), Un(
|
|
5311
5311
|
t,
|
|
5312
5312
|
/** @type {AbstractType<any>} */
|
|
5313
5313
|
this.parent,
|
|
@@ -5316,7 +5316,7 @@ class C extends an {
|
|
|
5316
5316
|
(this.parent._item !== null && /** @type {AbstractType<any>} */
|
|
5317
5317
|
this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(t);
|
|
5318
5318
|
} else
|
|
5319
|
-
new
|
|
5319
|
+
new v(this.id, this.length).integrate(t, 0);
|
|
5320
5320
|
}
|
|
5321
5321
|
/**
|
|
5322
5322
|
* Returns the next non-deleted item
|
|
@@ -5349,7 +5349,7 @@ class C extends an {
|
|
|
5349
5349
|
* @return {boolean}
|
|
5350
5350
|
*/
|
|
5351
5351
|
mergeWith(t) {
|
|
5352
|
-
if (this.constructor === t.constructor &&
|
|
5352
|
+
if (this.constructor === t.constructor && Xt(t.origin, this.lastId) && this.right === t && Xt(this.rightOrigin, t.rightOrigin) && this.id.client === t.id.client && this.id.clock + this.length === t.id.clock && this.deleted === t.deleted && this.redone === null && t.redone === null && this.content.constructor === t.content.constructor && this.content.mergeWith(t.content)) {
|
|
5353
5353
|
const n = (
|
|
5354
5354
|
/** @type {AbstractType<any>} */
|
|
5355
5355
|
this.parent._searchMarker
|
|
@@ -5371,7 +5371,7 @@ class C extends an {
|
|
|
5371
5371
|
/** @type {AbstractType<any>} */
|
|
5372
5372
|
this.parent
|
|
5373
5373
|
);
|
|
5374
|
-
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(),
|
|
5374
|
+
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), Pt(t.deleteSet, this.id.client, this.id.clock, this.length), Un(t, n, this.parentSub), this.content.delete(t);
|
|
5375
5375
|
}
|
|
5376
5376
|
}
|
|
5377
5377
|
/**
|
|
@@ -5380,8 +5380,8 @@ class C extends an {
|
|
|
5380
5380
|
*/
|
|
5381
5381
|
gc(t, n) {
|
|
5382
5382
|
if (!this.deleted)
|
|
5383
|
-
throw
|
|
5384
|
-
this.content.gc(t), n ?
|
|
5383
|
+
throw V();
|
|
5384
|
+
this.content.gc(t), n ? Xi(t, this, new v(this.id, this.length)) : this.content = new Vt(this.length);
|
|
5385
5385
|
}
|
|
5386
5386
|
/**
|
|
5387
5387
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -5393,9 +5393,9 @@ class C extends an {
|
|
|
5393
5393
|
* @param {number} offset
|
|
5394
5394
|
*/
|
|
5395
5395
|
write(t, n) {
|
|
5396
|
-
const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() &
|
|
5397
|
-
(r === null ? 0 :
|
|
5398
|
-
(i === null ? 0 :
|
|
5396
|
+
const s = n > 0 ? y(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & ce | (s === null ? 0 : T) | // origin is defined
|
|
5397
|
+
(r === null ? 0 : K) | // right origin is defined
|
|
5398
|
+
(i === null ? 0 : Tt);
|
|
5399
5399
|
if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
|
|
5400
5400
|
const c = (
|
|
5401
5401
|
/** @type {AbstractType<any>} */
|
|
@@ -5404,45 +5404,45 @@ class C extends an {
|
|
|
5404
5404
|
if (c._item !== void 0) {
|
|
5405
5405
|
const l = c._item;
|
|
5406
5406
|
if (l === null) {
|
|
5407
|
-
const a =
|
|
5407
|
+
const a = ji(c);
|
|
5408
5408
|
t.writeParentInfo(!0), t.writeString(a);
|
|
5409
5409
|
} else
|
|
5410
5410
|
t.writeParentInfo(!1), t.writeLeftID(l.id);
|
|
5411
5411
|
} else
|
|
5412
|
-
c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor ===
|
|
5412
|
+
c.constructor === String ? (t.writeParentInfo(!0), t.writeString(c)) : c.constructor === pt ? (t.writeParentInfo(!1), t.writeLeftID(c)) : V();
|
|
5413
5413
|
i !== null && t.writeString(i);
|
|
5414
5414
|
}
|
|
5415
5415
|
this.content.write(t, n);
|
|
5416
5416
|
}
|
|
5417
5417
|
}
|
|
5418
|
-
const Os = (e, t) =>
|
|
5418
|
+
const Os = (e, t) => Ho[t & ce](e), Ho = [
|
|
5419
5419
|
() => {
|
|
5420
|
-
|
|
5420
|
+
V();
|
|
5421
5421
|
},
|
|
5422
5422
|
// GC is not ItemContent
|
|
5423
|
-
|
|
5423
|
+
Co,
|
|
5424
5424
|
// 1
|
|
5425
|
-
|
|
5425
|
+
Lo,
|
|
5426
5426
|
// 2
|
|
5427
|
-
|
|
5427
|
+
Do,
|
|
5428
5428
|
// 3
|
|
5429
|
-
|
|
5429
|
+
Mo,
|
|
5430
5430
|
// 4
|
|
5431
|
-
|
|
5431
|
+
Io,
|
|
5432
5432
|
// 5
|
|
5433
|
-
|
|
5433
|
+
Ao,
|
|
5434
5434
|
// 6
|
|
5435
|
-
|
|
5435
|
+
Fo,
|
|
5436
5436
|
// 7
|
|
5437
|
-
|
|
5437
|
+
xo,
|
|
5438
5438
|
// 8
|
|
5439
|
-
|
|
5439
|
+
Eo,
|
|
5440
5440
|
// 9
|
|
5441
5441
|
() => {
|
|
5442
|
-
|
|
5442
|
+
V();
|
|
5443
5443
|
}
|
|
5444
5444
|
// 10 - Skip is not ItemContent
|
|
5445
|
-
],
|
|
5445
|
+
], $o = 10;
|
|
5446
5446
|
class O extends an {
|
|
5447
5447
|
get deleted() {
|
|
5448
5448
|
return !0;
|
|
@@ -5461,14 +5461,14 @@ class O extends an {
|
|
|
5461
5461
|
* @param {number} offset
|
|
5462
5462
|
*/
|
|
5463
5463
|
integrate(t, n) {
|
|
5464
|
-
|
|
5464
|
+
V();
|
|
5465
5465
|
}
|
|
5466
5466
|
/**
|
|
5467
5467
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
5468
5468
|
* @param {number} offset
|
|
5469
5469
|
*/
|
|
5470
5470
|
write(t, n) {
|
|
5471
|
-
t.writeInfo(
|
|
5471
|
+
t.writeInfo($o), p(t.restEncoder, this.length - n);
|
|
5472
5472
|
}
|
|
5473
5473
|
/**
|
|
5474
5474
|
* @param {Transaction} transaction
|
|
@@ -5479,63 +5479,63 @@ class O extends an {
|
|
|
5479
5479
|
return null;
|
|
5480
5480
|
}
|
|
5481
5481
|
}
|
|
5482
|
-
const
|
|
5482
|
+
const Rs = (
|
|
5483
5483
|
/** @type {any} */
|
|
5484
5484
|
typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
|
|
5485
|
-
),
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
const
|
|
5489
|
-
p(e,
|
|
5490
|
-
const n =
|
|
5485
|
+
), Ns = "__ $YJS$ __";
|
|
5486
|
+
Rs[Ns] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5487
|
+
Rs[Ns] = !0;
|
|
5488
|
+
const Bs = 0, hn = 1, Vs = 2, Ve = (e, t) => {
|
|
5489
|
+
p(e, Bs);
|
|
5490
|
+
const n = $i(t);
|
|
5491
5491
|
D(e, n);
|
|
5492
|
-
},
|
|
5492
|
+
}, Fs = (e, t, n) => {
|
|
5493
5493
|
p(e, hn), D(e, en(t, n));
|
|
5494
|
-
},
|
|
5494
|
+
}, Ko = (e, t, n) => Fs(t, n, x(e)), Hs = (e, t, n) => {
|
|
5495
5495
|
try {
|
|
5496
|
-
|
|
5496
|
+
as(t, x(e), n);
|
|
5497
5497
|
} catch (s) {
|
|
5498
5498
|
console.error("Caught error while handling a Yjs update", s);
|
|
5499
5499
|
}
|
|
5500
|
-
},
|
|
5501
|
-
p(e,
|
|
5502
|
-
},
|
|
5503
|
-
const r =
|
|
5500
|
+
}, jo = (e, t) => {
|
|
5501
|
+
p(e, Vs), D(e, t);
|
|
5502
|
+
}, Jo = Hs, Xo = (e, t, n, s) => {
|
|
5503
|
+
const r = w(e);
|
|
5504
5504
|
switch (r) {
|
|
5505
|
-
case
|
|
5506
|
-
|
|
5505
|
+
case Bs:
|
|
5506
|
+
Ko(e, t, n);
|
|
5507
5507
|
break;
|
|
5508
5508
|
case hn:
|
|
5509
|
-
|
|
5509
|
+
Hs(e, n, s);
|
|
5510
5510
|
break;
|
|
5511
|
-
case
|
|
5512
|
-
|
|
5511
|
+
case Vs:
|
|
5512
|
+
Jo(e, n, s);
|
|
5513
5513
|
break;
|
|
5514
5514
|
default:
|
|
5515
5515
|
throw new Error("Unknown message type");
|
|
5516
5516
|
}
|
|
5517
5517
|
return r;
|
|
5518
|
-
},
|
|
5519
|
-
switch (
|
|
5520
|
-
case
|
|
5521
|
-
n(t,
|
|
5518
|
+
}, Yo = 0, zo = (e, t, n) => {
|
|
5519
|
+
switch (w(e)) {
|
|
5520
|
+
case Yo:
|
|
5521
|
+
n(t, q(e));
|
|
5522
5522
|
}
|
|
5523
5523
|
}, Ee = 3e4;
|
|
5524
|
-
class
|
|
5524
|
+
class Go extends he {
|
|
5525
5525
|
/**
|
|
5526
5526
|
* @param {Y.Doc} doc
|
|
5527
5527
|
*/
|
|
5528
5528
|
constructor(t) {
|
|
5529
5529
|
super(), this.doc = t, this.clientID = t.clientID, this.states = /* @__PURE__ */ new Map(), this.meta = /* @__PURE__ */ new Map(), this._checkInterval = /** @type {any} */
|
|
5530
5530
|
setInterval(() => {
|
|
5531
|
-
const n =
|
|
5531
|
+
const n = it();
|
|
5532
5532
|
this.getLocalState() !== null && Ee / 2 <= n - /** @type {{lastUpdated:number}} */
|
|
5533
5533
|
this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
|
|
5534
5534
|
const s = [];
|
|
5535
5535
|
this.meta.forEach((r, i) => {
|
|
5536
5536
|
i !== this.clientID && Ee <= n - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
5537
5537
|
}), s.length > 0 && un(this, s, "timeout");
|
|
5538
|
-
},
|
|
5538
|
+
}, j(Ee / 10)), t.on("destroy", () => {
|
|
5539
5539
|
this.destroy();
|
|
5540
5540
|
}), this.setLocalState({});
|
|
5541
5541
|
}
|
|
@@ -5555,10 +5555,10 @@ class Yo extends ue {
|
|
|
5555
5555
|
const n = this.clientID, s = this.meta.get(n), r = s === void 0 ? 0 : s.clock + 1, i = this.states.get(n);
|
|
5556
5556
|
t === null ? this.states.delete(n) : this.states.set(n, t), this.meta.set(n, {
|
|
5557
5557
|
clock: r,
|
|
5558
|
-
lastUpdated:
|
|
5558
|
+
lastUpdated: it()
|
|
5559
5559
|
});
|
|
5560
5560
|
const o = [], c = [], l = [], a = [];
|
|
5561
|
-
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n),
|
|
5561
|
+
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n), xt(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"]);
|
|
5562
5562
|
}
|
|
5563
5563
|
/**
|
|
5564
5564
|
* @param {string} field
|
|
@@ -5590,14 +5590,14 @@ const un = (e, t, n) => {
|
|
|
5590
5590
|
);
|
|
5591
5591
|
e.meta.set(i, {
|
|
5592
5592
|
clock: o.clock + 1,
|
|
5593
|
-
lastUpdated:
|
|
5593
|
+
lastUpdated: it()
|
|
5594
5594
|
});
|
|
5595
5595
|
}
|
|
5596
5596
|
s.push(i);
|
|
5597
5597
|
}
|
|
5598
5598
|
}
|
|
5599
5599
|
s.length > 0 && (e.emit("change", [{ added: [], updated: [], removed: s }, n]), e.emit("update", [{ added: [], updated: [], removed: s }, n]));
|
|
5600
|
-
},
|
|
5600
|
+
}, Mt = (e, t, n = e.states) => {
|
|
5601
5601
|
const s = t.length, r = M();
|
|
5602
5602
|
p(r, s);
|
|
5603
5603
|
for (let i = 0; i < s; i++) {
|
|
@@ -5605,19 +5605,19 @@ const un = (e, t, n) => {
|
|
|
5605
5605
|
/** @type {MetaClientState} */
|
|
5606
5606
|
e.meta.get(o).clock
|
|
5607
5607
|
);
|
|
5608
|
-
p(r, o), p(r, l),
|
|
5608
|
+
p(r, o), p(r, l), st(r, JSON.stringify(c));
|
|
5609
5609
|
}
|
|
5610
5610
|
return S(r);
|
|
5611
|
-
},
|
|
5612
|
-
const s =
|
|
5611
|
+
}, Wo = (e, t, n) => {
|
|
5612
|
+
const s = P(t), r = it(), i = [], o = [], c = [], l = [], a = w(s);
|
|
5613
5613
|
for (let h = 0; h < a; h++) {
|
|
5614
|
-
const u =
|
|
5615
|
-
let d =
|
|
5616
|
-
const f = JSON.parse(
|
|
5617
|
-
(
|
|
5614
|
+
const u = w(s);
|
|
5615
|
+
let d = w(s);
|
|
5616
|
+
const f = JSON.parse(q(s)), g = e.meta.get(u), m = e.states.get(u), U = g === void 0 ? 0 : g.clock;
|
|
5617
|
+
(U < d || U === d && f === null && e.states.has(u)) && (f === null ? u === e.clientID && e.getLocalState() != null ? d++ : e.states.delete(u) : e.states.set(u, f), e.meta.set(u, {
|
|
5618
5618
|
clock: d,
|
|
5619
5619
|
lastUpdated: r
|
|
5620
|
-
}), g === void 0 && f !== null ? i.push(u) : g !== void 0 && f === null ? l.push(u) : f !== null && (
|
|
5620
|
+
}), g === void 0 && f !== null ? i.push(u) : g !== void 0 && f === null ? l.push(u) : f !== null && (xt(f, m) || c.push(u), o.push(u)));
|
|
5621
5621
|
}
|
|
5622
5622
|
(i.length > 0 || c.length > 0 || l.length > 0) && e.emit("change", [{
|
|
5623
5623
|
added: i,
|
|
@@ -5628,16 +5628,16 @@ const un = (e, t, n) => {
|
|
|
5628
5628
|
updated: o,
|
|
5629
5629
|
removed: l
|
|
5630
5630
|
}, n]);
|
|
5631
|
-
},
|
|
5632
|
-
var
|
|
5633
|
-
function
|
|
5631
|
+
}, qo = (e) => br(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&");
|
|
5632
|
+
var et = 0, $s = 3, mt = 1, Qo = 2;
|
|
5633
|
+
function Zo(e, t) {
|
|
5634
5634
|
if (!e)
|
|
5635
5635
|
throw new Error(t);
|
|
5636
5636
|
}
|
|
5637
|
-
var
|
|
5638
|
-
|
|
5639
|
-
p(e,
|
|
5640
|
-
const i =
|
|
5637
|
+
var Jt = [];
|
|
5638
|
+
Jt[et] = (e, t, n, s, r) => {
|
|
5639
|
+
p(e, et);
|
|
5640
|
+
const i = Xo(
|
|
5641
5641
|
t,
|
|
5642
5642
|
e,
|
|
5643
5643
|
n.doc,
|
|
@@ -5645,39 +5645,39 @@ Xt[P] = (e, t, n, s, r) => {
|
|
|
5645
5645
|
);
|
|
5646
5646
|
s && i === hn && !n.synced && (n.synced = !0);
|
|
5647
5647
|
};
|
|
5648
|
-
|
|
5649
|
-
p(e,
|
|
5648
|
+
Jt[$s] = (e, t, n, s, r) => {
|
|
5649
|
+
p(e, mt), D(
|
|
5650
5650
|
e,
|
|
5651
|
-
|
|
5651
|
+
Mt(
|
|
5652
5652
|
n.awareness,
|
|
5653
5653
|
Array.from(n.awareness.getStates().keys())
|
|
5654
5654
|
)
|
|
5655
5655
|
);
|
|
5656
5656
|
};
|
|
5657
|
-
|
|
5658
|
-
|
|
5657
|
+
Jt[mt] = (e, t, n, s, r) => {
|
|
5658
|
+
Wo(
|
|
5659
5659
|
n.awareness,
|
|
5660
5660
|
x(t),
|
|
5661
5661
|
n
|
|
5662
5662
|
);
|
|
5663
5663
|
};
|
|
5664
|
-
|
|
5665
|
-
|
|
5664
|
+
Jt[Qo] = (e, t, n, s, r) => {
|
|
5665
|
+
zo(
|
|
5666
5666
|
t,
|
|
5667
5667
|
n.doc,
|
|
5668
|
-
(i, o) =>
|
|
5668
|
+
(i, o) => Po(n, o)
|
|
5669
5669
|
);
|
|
5670
5670
|
};
|
|
5671
|
-
var
|
|
5672
|
-
function
|
|
5671
|
+
var Rn = 3e4;
|
|
5672
|
+
function Po(e, t) {
|
|
5673
5673
|
console.warn(`Permission denied to access ${e.url}.
|
|
5674
5674
|
${t}`);
|
|
5675
5675
|
}
|
|
5676
|
-
function
|
|
5677
|
-
const s =
|
|
5676
|
+
function Ks(e, t, n) {
|
|
5677
|
+
const s = P(t), r = M(), i = w(s), o = e.messageHandlers[i];
|
|
5678
5678
|
return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
|
|
5679
5679
|
}
|
|
5680
|
-
function
|
|
5680
|
+
function js(e) {
|
|
5681
5681
|
if (e.shouldConnect && e.ws === null) {
|
|
5682
5682
|
const t = new e._WS(e.url);
|
|
5683
5683
|
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.onmessage = (n) => {
|
|
@@ -5685,8 +5685,8 @@ function Ks(e) {
|
|
|
5685
5685
|
t.send("pong");
|
|
5686
5686
|
return;
|
|
5687
5687
|
}
|
|
5688
|
-
e.wsLastMessageReceived =
|
|
5689
|
-
const s =
|
|
5688
|
+
e.wsLastMessageReceived = it();
|
|
5689
|
+
const s = Ks(e, new Uint8Array(n.data), !0);
|
|
5690
5690
|
Je(s) > 1 && t.send(S(s));
|
|
5691
5691
|
}, t.onerror = (n) => {
|
|
5692
5692
|
e.emit("connection-error", [n, e]);
|
|
@@ -5702,25 +5702,25 @@ function Ks(e) {
|
|
|
5702
5702
|
status: "disconnected"
|
|
5703
5703
|
}
|
|
5704
5704
|
])) : e.wsUnsuccessfulReconnects++, setTimeout(
|
|
5705
|
-
|
|
5705
|
+
js,
|
|
5706
5706
|
je(
|
|
5707
|
-
|
|
5707
|
+
Mr(2, e.wsUnsuccessfulReconnects) * 100,
|
|
5708
5708
|
e.maxBackoffTime
|
|
5709
5709
|
),
|
|
5710
5710
|
e
|
|
5711
5711
|
);
|
|
5712
5712
|
}, t.onopen = () => {
|
|
5713
|
-
e.wsLastMessageReceived =
|
|
5713
|
+
e.wsLastMessageReceived = it(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [
|
|
5714
5714
|
{
|
|
5715
5715
|
status: "connected"
|
|
5716
5716
|
}
|
|
5717
5717
|
]);
|
|
5718
5718
|
const n = M();
|
|
5719
|
-
if (p(n,
|
|
5719
|
+
if (p(n, et), Ve(n, e.doc), t.send(S(n)), e.awareness.getLocalState() !== null) {
|
|
5720
5720
|
const s = M();
|
|
5721
|
-
p(s,
|
|
5721
|
+
p(s, mt), D(
|
|
5722
5722
|
s,
|
|
5723
|
-
|
|
5723
|
+
Mt(e.awareness, [
|
|
5724
5724
|
e.doc.clientID
|
|
5725
5725
|
])
|
|
5726
5726
|
), t.send(S(s));
|
|
@@ -5736,10 +5736,10 @@ function Ie(e, t) {
|
|
|
5736
5736
|
const n = e.ws;
|
|
5737
5737
|
e.wsconnected && n && n.readyState === n.OPEN && n.send(t), e.bcconnected && gt(e.bcChannel, t, e);
|
|
5738
5738
|
}
|
|
5739
|
-
var
|
|
5739
|
+
var tc = class extends he {
|
|
5740
5740
|
constructor(t, n, s, {
|
|
5741
5741
|
connect: r = !0,
|
|
5742
|
-
awareness: i = new
|
|
5742
|
+
awareness: i = new Go(s),
|
|
5743
5743
|
params: o = {},
|
|
5744
5744
|
WebSocketPolyfill: c = WebSocket,
|
|
5745
5745
|
// Optionally provide a WebSocket polyfill
|
|
@@ -5777,29 +5777,29 @@ var Zo = class extends ue {
|
|
|
5777
5777
|
_(this, "_checkInterval");
|
|
5778
5778
|
for (; t[t.length - 1] === "/"; )
|
|
5779
5779
|
t = t.slice(0, t.length - 1);
|
|
5780
|
-
const u =
|
|
5781
|
-
this.maxBackoffTime = a, this.bcChannel = t + "/" + n, this.url = t + "/" + n + (u.length === 0 ? "" : "?" + u), 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 =
|
|
5780
|
+
const u = qo(o);
|
|
5781
|
+
this.maxBackoffTime = a, this.bcChannel = t + "/" + n, this.url = t + "/" + n + (u.length === 0 ? "" : "?" + u), 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 = Jt.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, l > 0 && (this._resyncInterval = /** @type {any} */
|
|
5782
5782
|
setInterval(() => {
|
|
5783
5783
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
5784
5784
|
const d = M();
|
|
5785
|
-
p(d,
|
|
5785
|
+
p(d, et), Ve(d, s), this.ws.send(S(d));
|
|
5786
5786
|
}
|
|
5787
5787
|
}, l)), this._bcSubscriber = (d, f) => {
|
|
5788
5788
|
if (f !== this) {
|
|
5789
|
-
const g =
|
|
5789
|
+
const g = Ks(this, new Uint8Array(d), !1);
|
|
5790
5790
|
Je(g) > 1 && gt(this.bcChannel, S(g), this);
|
|
5791
5791
|
}
|
|
5792
5792
|
}, this._updateHandler = (d, f) => {
|
|
5793
5793
|
if (f !== this) {
|
|
5794
5794
|
const g = M();
|
|
5795
|
-
p(g,
|
|
5795
|
+
p(g, et), jo(g, d), Ie(this, S(g));
|
|
5796
5796
|
}
|
|
5797
|
-
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g },
|
|
5798
|
-
const
|
|
5799
|
-
p(
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
), Ie(this, S(
|
|
5797
|
+
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: d, updated: f, removed: g }, m) => {
|
|
5798
|
+
const U = d.concat(f).concat(g), k = M();
|
|
5799
|
+
p(k, mt), D(
|
|
5800
|
+
k,
|
|
5801
|
+
Mt(i, U)
|
|
5802
|
+
), Ie(this, S(k));
|
|
5803
5803
|
}, this._unloadHandler = () => {
|
|
5804
5804
|
un(
|
|
5805
5805
|
this.awareness,
|
|
@@ -5808,8 +5808,8 @@ var Zo = class extends ue {
|
|
|
5808
5808
|
);
|
|
5809
5809
|
}, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
|
|
5810
5810
|
setInterval(() => {
|
|
5811
|
-
this.wsconnected &&
|
|
5812
|
-
},
|
|
5811
|
+
this.wsconnected && Rn < it() - this.wsLastMessageReceived && (Zo(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
5812
|
+
}, Rn / 10), r && this.connect();
|
|
5813
5813
|
}
|
|
5814
5814
|
/**
|
|
5815
5815
|
* @type {boolean}
|
|
@@ -5826,21 +5826,21 @@ var Zo = class extends ue {
|
|
|
5826
5826
|
connectBc() {
|
|
5827
5827
|
if (this.disableBc)
|
|
5828
5828
|
return;
|
|
5829
|
-
this.bcconnected || (
|
|
5829
|
+
this.bcconnected || (ci(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
5830
5830
|
const t = M();
|
|
5831
|
-
p(t,
|
|
5831
|
+
p(t, et), Ve(t, this.doc), gt(this.bcChannel, S(t), this);
|
|
5832
5832
|
const n = M();
|
|
5833
|
-
p(n,
|
|
5833
|
+
p(n, et), Fs(n, this.doc), gt(this.bcChannel, S(n), this);
|
|
5834
5834
|
const s = M();
|
|
5835
|
-
p(s,
|
|
5835
|
+
p(s, $s), gt(
|
|
5836
5836
|
this.bcChannel,
|
|
5837
5837
|
S(s),
|
|
5838
5838
|
this
|
|
5839
5839
|
);
|
|
5840
5840
|
const r = M();
|
|
5841
|
-
p(r,
|
|
5841
|
+
p(r, mt), D(
|
|
5842
5842
|
r,
|
|
5843
|
-
|
|
5843
|
+
Mt(this.awareness, [
|
|
5844
5844
|
this.doc.clientID
|
|
5845
5845
|
])
|
|
5846
5846
|
), gt(
|
|
@@ -5851,23 +5851,23 @@ var Zo = class extends ue {
|
|
|
5851
5851
|
}
|
|
5852
5852
|
disconnectBc() {
|
|
5853
5853
|
const t = M();
|
|
5854
|
-
p(t,
|
|
5854
|
+
p(t, mt), D(
|
|
5855
5855
|
t,
|
|
5856
|
-
|
|
5856
|
+
Mt(
|
|
5857
5857
|
this.awareness,
|
|
5858
5858
|
[this.doc.clientID],
|
|
5859
5859
|
/* @__PURE__ */ new Map()
|
|
5860
5860
|
)
|
|
5861
|
-
), Ie(this, S(t)), this.bcconnected && (
|
|
5861
|
+
), Ie(this, S(t)), this.bcconnected && (li(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
5862
5862
|
}
|
|
5863
5863
|
disconnect() {
|
|
5864
5864
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
5865
5865
|
}
|
|
5866
5866
|
connect() {
|
|
5867
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
5867
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (js(this), this.connectBc());
|
|
5868
5868
|
}
|
|
5869
5869
|
};
|
|
5870
|
-
function
|
|
5870
|
+
function Nn() {
|
|
5871
5871
|
if (crypto.randomUUID)
|
|
5872
5872
|
return crypto.randomUUID();
|
|
5873
5873
|
let e = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
@@ -5876,91 +5876,91 @@ function Rn() {
|
|
|
5876
5876
|
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);
|
|
5877
5877
|
});
|
|
5878
5878
|
}
|
|
5879
|
-
var
|
|
5879
|
+
var ec = class extends tc {
|
|
5880
5880
|
constructor(e, t, n, s = {}) {
|
|
5881
5881
|
const r = `${e.startsWith("localhost:") || e.startsWith("127.0.0.1:") ? "ws" : "wss"}://${e}/party`;
|
|
5882
5882
|
s.params === void 0 ? s.params = {
|
|
5883
|
-
_pk:
|
|
5884
|
-
} : s.params._pk =
|
|
5883
|
+
_pk: Nn()
|
|
5884
|
+
} : s.params._pk = Nn(), super(r, t, n, s);
|
|
5885
5885
|
}
|
|
5886
5886
|
};
|
|
5887
|
-
const
|
|
5887
|
+
const ft = (e) => bt((t, n) => {
|
|
5888
5888
|
e.onerror = (s) => n(new Error(s.target.error)), e.onsuccess = (s) => t(s.target.result);
|
|
5889
|
-
}),
|
|
5889
|
+
}), nc = (e, t) => bt((n, s) => {
|
|
5890
5890
|
const r = indexedDB.open(e);
|
|
5891
|
-
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(
|
|
5891
|
+
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(ut(i.target.error)), r.onsuccess = (i) => {
|
|
5892
5892
|
const o = i.target.result;
|
|
5893
5893
|
o.onversionchange = () => {
|
|
5894
5894
|
o.close();
|
|
5895
5895
|
}, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), n(o);
|
|
5896
5896
|
};
|
|
5897
|
-
}),
|
|
5897
|
+
}), sc = (e) => ft(indexedDB.deleteDatabase(e)), rc = (e, t) => t.forEach(
|
|
5898
5898
|
(n) => (
|
|
5899
5899
|
// @ts-ignore
|
|
5900
5900
|
e.createObjectStore.apply(e, n)
|
|
5901
5901
|
)
|
|
5902
|
-
),
|
|
5902
|
+
), At = (e, t, n = "readwrite") => {
|
|
5903
5903
|
const s = e.transaction(t, n);
|
|
5904
|
-
return t.map((r) =>
|
|
5905
|
-
},
|
|
5904
|
+
return t.map((r) => dc(s, r));
|
|
5905
|
+
}, Js = (e, t) => ft(e.count(t)), ic = (e, t) => ft(e.get(t)), Xs = (e, t) => ft(e.delete(t)), oc = (e, t, n) => ft(e.put(t, n)), Fe = (e, t) => ft(e.add(t)), cc = (e, t, n) => ft(e.getAll(t, n)), lc = (e, t, n) => {
|
|
5906
5906
|
let s = null;
|
|
5907
|
-
return
|
|
5908
|
-
},
|
|
5907
|
+
return uc(e, t, (r) => (s = r, !1), n).then(() => s);
|
|
5908
|
+
}, ac = (e, t = null) => lc(e, t, "prev"), hc = (e, t) => bt((n, s) => {
|
|
5909
5909
|
e.onerror = s, e.onsuccess = async (r) => {
|
|
5910
5910
|
const i = r.target.result;
|
|
5911
5911
|
if (i === null || await t(i) === !1)
|
|
5912
5912
|
return n();
|
|
5913
5913
|
i.continue();
|
|
5914
5914
|
};
|
|
5915
|
-
}),
|
|
5915
|
+
}), uc = (e, t, n, s = "next") => hc(e.openKeyCursor(t, s), (r) => n(r.key)), dc = (e, t) => e.objectStore(t), fc = (e, t) => IDBKeyRange.upperBound(e, t), gc = (e, t) => IDBKeyRange.lowerBound(e, t), Ae = "custom", Ys = "updates", zs = 500, Gs = (e, t = () => {
|
|
5916
5916
|
}, n = () => {
|
|
5917
5917
|
}) => {
|
|
5918
|
-
const [s] =
|
|
5918
|
+
const [s] = At(
|
|
5919
5919
|
/** @type {IDBDatabase} */
|
|
5920
5920
|
e.db,
|
|
5921
|
-
[
|
|
5921
|
+
[Ys]
|
|
5922
5922
|
);
|
|
5923
|
-
return
|
|
5923
|
+
return cc(s, gc(e._dbref, !1)).then((r) => {
|
|
5924
5924
|
e._destroyed || (t(s), b(e.doc, () => {
|
|
5925
|
-
r.forEach((i) =>
|
|
5925
|
+
r.forEach((i) => as(e.doc, i));
|
|
5926
5926
|
}, e, !1), n(s));
|
|
5927
|
-
}).then(() =>
|
|
5927
|
+
}).then(() => ac(s).then((r) => {
|
|
5928
5928
|
e._dbref = r + 1;
|
|
5929
|
-
})).then(() =>
|
|
5929
|
+
})).then(() => Js(s).then((r) => {
|
|
5930
5930
|
e._dbsize = r;
|
|
5931
5931
|
})).then(() => s);
|
|
5932
|
-
},
|
|
5933
|
-
(t || e._dbsize >=
|
|
5932
|
+
}, pc = (e, t = !0) => Gs(e).then((n) => {
|
|
5933
|
+
(t || e._dbsize >= zs) && Fe(n, en(e.doc)).then(() => Xs(n, fc(e._dbref, !0))).then(() => Js(n).then((s) => {
|
|
5934
5934
|
e._dbsize = s;
|
|
5935
5935
|
}));
|
|
5936
5936
|
});
|
|
5937
|
-
class
|
|
5937
|
+
class wc extends he {
|
|
5938
5938
|
/**
|
|
5939
5939
|
* @param {string} name
|
|
5940
5940
|
* @param {Y.Doc} doc
|
|
5941
5941
|
*/
|
|
5942
5942
|
constructor(t, n) {
|
|
5943
|
-
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db =
|
|
5943
|
+
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = nc(
|
|
5944
5944
|
t,
|
|
5945
|
-
(s) =>
|
|
5945
|
+
(s) => rc(s, [
|
|
5946
5946
|
["updates", { autoIncrement: !0 }],
|
|
5947
5947
|
["custom"]
|
|
5948
5948
|
])
|
|
5949
|
-
), this.whenSynced =
|
|
5950
|
-
this.db = s,
|
|
5949
|
+
), this.whenSynced = bt((s) => this.on("synced", () => s(this))), this._db.then((s) => {
|
|
5950
|
+
this.db = s, Gs(this, (o) => Fe(o, en(n)), () => {
|
|
5951
5951
|
if (this._destroyed)
|
|
5952
5952
|
return this;
|
|
5953
5953
|
this.synced = !0, this.emit("synced", [this]);
|
|
5954
5954
|
});
|
|
5955
5955
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (s, r) => {
|
|
5956
5956
|
if (this.db && r !== this) {
|
|
5957
|
-
const [i] =
|
|
5957
|
+
const [i] = At(
|
|
5958
5958
|
/** @type {IDBDatabase} */
|
|
5959
5959
|
this.db,
|
|
5960
|
-
[
|
|
5960
|
+
[Ys]
|
|
5961
5961
|
);
|
|
5962
|
-
Fe(i, s), ++this._dbsize >=
|
|
5963
|
-
|
|
5962
|
+
Fe(i, s), ++this._dbsize >= zs && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
|
|
5963
|
+
pc(this, !1), this._storeTimeoutId = null;
|
|
5964
5964
|
}, this._storeTimeout));
|
|
5965
5965
|
}
|
|
5966
5966
|
}, n.on("update", this._storeUpdate), this.destroy = this.destroy.bind(this), n.on("destroy", this.destroy);
|
|
@@ -5977,7 +5977,7 @@ class gc extends ue {
|
|
|
5977
5977
|
*/
|
|
5978
5978
|
clearData() {
|
|
5979
5979
|
return this.destroy().then(() => {
|
|
5980
|
-
|
|
5980
|
+
sc(this.name);
|
|
5981
5981
|
});
|
|
5982
5982
|
}
|
|
5983
5983
|
/**
|
|
@@ -5986,8 +5986,8 @@ class gc extends ue {
|
|
|
5986
5986
|
*/
|
|
5987
5987
|
get(t) {
|
|
5988
5988
|
return this._db.then((n) => {
|
|
5989
|
-
const [s] =
|
|
5990
|
-
return
|
|
5989
|
+
const [s] = At(n, [Ae], "readonly");
|
|
5990
|
+
return ic(s, t);
|
|
5991
5991
|
});
|
|
5992
5992
|
}
|
|
5993
5993
|
/**
|
|
@@ -5997,8 +5997,8 @@ class gc extends ue {
|
|
|
5997
5997
|
*/
|
|
5998
5998
|
set(t, n) {
|
|
5999
5999
|
return this._db.then((s) => {
|
|
6000
|
-
const [r] =
|
|
6001
|
-
return
|
|
6000
|
+
const [r] = At(s, [Ae]);
|
|
6001
|
+
return oc(r, n, t);
|
|
6002
6002
|
});
|
|
6003
6003
|
}
|
|
6004
6004
|
/**
|
|
@@ -6007,189 +6007,221 @@ class gc extends ue {
|
|
|
6007
6007
|
*/
|
|
6008
6008
|
del(t) {
|
|
6009
6009
|
return this._db.then((n) => {
|
|
6010
|
-
const [s] =
|
|
6011
|
-
return
|
|
6010
|
+
const [s] = At(n, [Ae]);
|
|
6011
|
+
return Xs(s, t);
|
|
6012
6012
|
});
|
|
6013
6013
|
}
|
|
6014
6014
|
}
|
|
6015
|
-
var
|
|
6016
|
-
const
|
|
6015
|
+
var tt = /* @__PURE__ */ ((e) => (e.CanMove = "can-move", e.CanSpin = "can-spin", e.CanGrow = "can-grow", e.CanToggle = "can-toggle", e.CanPost = "can-post", e))(tt || {});
|
|
6016
|
+
const mc = (e, t = 300) => {
|
|
6017
6017
|
let n;
|
|
6018
6018
|
return function(...s) {
|
|
6019
6019
|
clearTimeout(n), n = setTimeout(() => e.apply(this, s), t);
|
|
6020
6020
|
};
|
|
6021
|
-
},
|
|
6021
|
+
}, yc = {
|
|
6022
6022
|
ctrlKey: "Control",
|
|
6023
6023
|
altKey: "Alt",
|
|
6024
6024
|
shiftKey: "Shift",
|
|
6025
6025
|
metaKey: "Meta"
|
|
6026
|
-
},
|
|
6026
|
+
}, Ws = `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>")
|
|
6027
6027
|
16 0,
|
|
6028
|
-
auto`,
|
|
6029
|
-
function Le(e, t, n) {
|
|
6030
|
-
if (
|
|
6028
|
+
auto`, _c = `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`;
|
|
6029
|
+
function Le(e, { data: t, element: n, localData: s, setLocalData: r }) {
|
|
6030
|
+
if (s.isHovering = !0, e.altKey) {
|
|
6031
6031
|
if (t.scale <= 0.5) {
|
|
6032
6032
|
n.style.cursor = "not-allowed";
|
|
6033
6033
|
return;
|
|
6034
6034
|
}
|
|
6035
|
-
n.style.cursor =
|
|
6035
|
+
n.style.cursor = _c;
|
|
6036
6036
|
} else {
|
|
6037
6037
|
if (t.scale >= t.maxScale) {
|
|
6038
6038
|
n.style.cursor = "not-allowed";
|
|
6039
6039
|
return;
|
|
6040
6040
|
}
|
|
6041
|
-
n.style.cursor =
|
|
6041
|
+
n.style.cursor = Ws;
|
|
6042
6042
|
}
|
|
6043
|
-
|
|
6043
|
+
r(s);
|
|
6044
6044
|
}
|
|
6045
|
-
const
|
|
6045
|
+
const qs = {
|
|
6046
6046
|
// [TagType.CanPlay]: {},
|
|
6047
|
-
[
|
|
6048
|
-
defaultData: { x: 0, y: 0
|
|
6049
|
-
|
|
6047
|
+
[tt.CanMove]: {
|
|
6048
|
+
defaultData: { x: 0, y: 0 },
|
|
6049
|
+
defaultLocalData: { startMouseX: 0, startMouseY: 0 },
|
|
6050
|
+
updateElement: ({ element: e, data: t }) => {
|
|
6050
6051
|
e.style.transform = `translate(${t.x}px, ${t.y}px)`;
|
|
6051
6052
|
},
|
|
6052
|
-
onDragStart: (e, t) =>
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6053
|
+
onDragStart: (e, { setLocalData: t }) => {
|
|
6054
|
+
t({
|
|
6055
|
+
startMouseX: e.clientX,
|
|
6056
|
+
startMouseY: e.clientY
|
|
6057
|
+
});
|
|
6058
|
+
},
|
|
6059
|
+
onDrag: (e, { data: t, localData: n, setData: s, setLocalData: r }) => {
|
|
6060
|
+
r({ startMouseX: e.pageX, startMouseY: e.pageY }), s({
|
|
6061
|
+
x: t.x + e.pageX - n.startMouseX,
|
|
6062
|
+
y: t.y + e.pageY - n.startMouseY
|
|
6063
|
+
});
|
|
6064
|
+
},
|
|
6063
6065
|
resetShortcut: "shiftKey"
|
|
6064
6066
|
},
|
|
6065
|
-
[
|
|
6066
|
-
defaultData: { rotation: 0
|
|
6067
|
-
|
|
6067
|
+
[tt.CanSpin]: {
|
|
6068
|
+
defaultData: { rotation: 0 },
|
|
6069
|
+
defaultLocalData: { startMouseX: 0 },
|
|
6070
|
+
updateElement: ({ element: e, data: t }) => {
|
|
6068
6071
|
e.style.transform = `rotate(${t.rotation}deg)`;
|
|
6069
6072
|
},
|
|
6070
|
-
onDragStart: (e, t) =>
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
startMouseX: e.pageX
|
|
6079
|
-
};
|
|
6073
|
+
onDragStart: (e, { setLocalData: t }) => {
|
|
6074
|
+
t({
|
|
6075
|
+
startMouseX: e.clientX
|
|
6076
|
+
});
|
|
6077
|
+
},
|
|
6078
|
+
onDrag: (e, { data: t, localData: n, setData: s, setLocalData: r }) => {
|
|
6079
|
+
let i = Math.abs(e.pageX - n.startMouseX) * 2, o = t.rotation;
|
|
6080
|
+
e.pageX > n.startMouseX ? o += i : e.pageX < n.startMouseX && (o -= i), s({ rotation: o }), r({ startMouseX: e.pageX });
|
|
6080
6081
|
},
|
|
6081
6082
|
resetShortcut: "shiftKey"
|
|
6082
6083
|
},
|
|
6083
|
-
[
|
|
6084
|
+
[tt.CanToggle]: {
|
|
6084
6085
|
defaultData: !1,
|
|
6085
|
-
updateElement: (e, t) => {
|
|
6086
|
+
updateElement: ({ element: e, data: t }) => {
|
|
6086
6087
|
e.classList.toggle("clicked", t);
|
|
6087
6088
|
},
|
|
6088
|
-
onClick: (e, t) =>
|
|
6089
|
+
onClick: (e, { data: t, setData: n }) => {
|
|
6090
|
+
console.log(t, n), e.preventDefault(), n(!t);
|
|
6091
|
+
},
|
|
6089
6092
|
resetShortcut: "shiftKey"
|
|
6090
6093
|
},
|
|
6091
|
-
[
|
|
6094
|
+
[tt.CanGrow]: {
|
|
6092
6095
|
// TODO: turn this into a function so you can accept arbitrary user input?
|
|
6093
|
-
defaultData: { scale: 1, maxScale: 2
|
|
6094
|
-
|
|
6096
|
+
defaultData: { scale: 1, maxScale: 2 },
|
|
6097
|
+
defaultLocalData: { isHovering: !1 },
|
|
6098
|
+
updateElement: ({ element: e, data: t }) => {
|
|
6095
6099
|
e.style.transform = `scale(${t.scale})`;
|
|
6096
6100
|
},
|
|
6097
|
-
onClick: (e, t, n) => {
|
|
6101
|
+
onClick: (e, { data: t, element: n, setData: s }) => {
|
|
6098
6102
|
if (e.altKey) {
|
|
6099
6103
|
if (t.scale <= 0.5)
|
|
6100
6104
|
return;
|
|
6101
6105
|
t.scale -= 0.1;
|
|
6102
6106
|
} else {
|
|
6103
|
-
if (n.style.cursor =
|
|
6107
|
+
if (n.style.cursor = Ws, t.scale >= t.maxScale)
|
|
6104
6108
|
return;
|
|
6105
6109
|
t.scale += 0.1;
|
|
6106
6110
|
}
|
|
6107
|
-
|
|
6108
|
-
...t
|
|
6109
|
-
};
|
|
6111
|
+
s(t);
|
|
6110
6112
|
},
|
|
6111
6113
|
onMouseEnter: Le,
|
|
6112
6114
|
onKeyDown: Le,
|
|
6113
6115
|
onKeyUp: Le
|
|
6116
|
+
},
|
|
6117
|
+
[tt.CanPost]: {
|
|
6118
|
+
defaultData: [],
|
|
6119
|
+
defaultLocalData: { addedEntries: /* @__PURE__ */ new Set() },
|
|
6120
|
+
updateElement: ({
|
|
6121
|
+
element: e,
|
|
6122
|
+
data: t,
|
|
6123
|
+
localData: { addedEntries: n },
|
|
6124
|
+
setLocalData: s,
|
|
6125
|
+
setData: r
|
|
6126
|
+
}) => {
|
|
6127
|
+
const i = t.filter(
|
|
6128
|
+
(c) => !n.has(c.id)
|
|
6129
|
+
), o = Ps("guestbookMessages");
|
|
6130
|
+
i.forEach((c) => {
|
|
6131
|
+
const l = document.createElement("div");
|
|
6132
|
+
l.classList.add("guestbook-entry");
|
|
6133
|
+
const a = new Date(c.timestamp), h = a.toTimeString().split(" ")[0], u = a.toDateString() === (/* @__PURE__ */ new Date()).toDateString();
|
|
6134
|
+
l.innerHTML = `
|
|
6135
|
+
<span class="guestbook-entry-timestamp">${u ? "" : a.toDateString() + " "}${h}</span><span class="guestbook-entry-name">${c.name}</span> <span class="guestbook-entry-message">${c.message}</span>`, o.prepend(l), n.add(c.id);
|
|
6136
|
+
}), s({ addedEntries: n });
|
|
6137
|
+
},
|
|
6138
|
+
onSubmit: (e, { data: t, setData: n }) => {
|
|
6139
|
+
e.preventDefault(), e.stopImmediatePropagation();
|
|
6140
|
+
const s = new FormData(e.target), r = Object.fromEntries(s.entries()), i = Date.now(), o = {
|
|
6141
|
+
name: "someone",
|
|
6142
|
+
message: "something",
|
|
6143
|
+
...r,
|
|
6144
|
+
timestamp: i,
|
|
6145
|
+
id: `${i}-${r.name}`
|
|
6146
|
+
};
|
|
6147
|
+
n([...t, o]);
|
|
6148
|
+
}
|
|
6114
6149
|
}
|
|
6115
6150
|
};
|
|
6116
|
-
class
|
|
6151
|
+
class bc {
|
|
6117
6152
|
constructor({
|
|
6118
6153
|
element: t,
|
|
6119
6154
|
onChange: n,
|
|
6120
6155
|
defaultData: s,
|
|
6121
|
-
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6156
|
+
defaultLocalData: r,
|
|
6157
|
+
data: i,
|
|
6158
|
+
updateElement: o,
|
|
6159
|
+
onClick: c,
|
|
6160
|
+
onDrag: l,
|
|
6161
|
+
onDragStart: a,
|
|
6162
|
+
onMouseEnter: h,
|
|
6163
|
+
onKeyDown: u,
|
|
6164
|
+
onKeyUp: d,
|
|
6165
|
+
onSubmit: f,
|
|
6166
|
+
resetShortcut: g,
|
|
6167
|
+
debounceMs: m
|
|
6131
6168
|
}) {
|
|
6132
6169
|
_(this, "defaultData");
|
|
6170
|
+
_(this, "localData");
|
|
6133
6171
|
_(this, "element");
|
|
6134
6172
|
_(this, "_data");
|
|
6135
6173
|
_(this, "onChange");
|
|
6136
6174
|
_(this, "debouncedOnChange");
|
|
6137
6175
|
_(this, "resetShortcut");
|
|
6138
6176
|
_(this, "updateElement");
|
|
6139
|
-
this.element = t, this.defaultData = s, this.onChange = n, this.resetShortcut =
|
|
6140
|
-
const
|
|
6141
|
-
this._data =
|
|
6142
|
-
|
|
6143
|
-
|
|
6144
|
-
|
|
6145
|
-
|
|
6146
|
-
|
|
6147
|
-
|
|
6148
|
-
|
|
6149
|
-
const k = (ft) => {
|
|
6150
|
-
ft.preventDefault();
|
|
6151
|
-
const fn = c(ft, this.data, this.element);
|
|
6152
|
-
fn !== void 0 && (this.data = fn);
|
|
6153
|
-
}, dt = (ft) => {
|
|
6154
|
-
document.removeEventListener("mousemove", k), document.removeEventListener("mouseup", dt);
|
|
6177
|
+
console.log("🔨 constructing ", t.id), this.element = t, this.defaultData = s, this.localData = r, this.onChange = n, this.resetShortcut = g, this.debouncedOnChange = mc(this.onChange, m), this.updateElement = o;
|
|
6178
|
+
const U = i === void 0 ? s : i;
|
|
6179
|
+
this._data = U, this.__data = U, c && t.addEventListener("click", (k) => {
|
|
6180
|
+
c(k, this.getEventHandlerData());
|
|
6181
|
+
}), l && t.addEventListener("mousedown", (k) => {
|
|
6182
|
+
a && a(k, this.getEventHandlerData());
|
|
6183
|
+
const fn = (pe) => {
|
|
6184
|
+
pe.preventDefault(), l(pe, this.getEventHandlerData());
|
|
6185
|
+
}, gn = (pe) => {
|
|
6186
|
+
document.removeEventListener("mousemove", fn), document.removeEventListener("mouseup", gn);
|
|
6155
6187
|
};
|
|
6156
|
-
document.addEventListener("mousemove",
|
|
6157
|
-
}),
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6161
|
-
|
|
6162
|
-
k
|
|
6163
|
-
}),
|
|
6164
|
-
|
|
6165
|
-
k !== void 0 && (this.data = k);
|
|
6166
|
-
}), d && (t.title || (t.title = `Hold down the ${wc[d]} key while clicking to reset.`), t.addEventListener("click", (w) => {
|
|
6167
|
-
switch (d) {
|
|
6188
|
+
document.addEventListener("mousemove", fn), document.addEventListener("mouseup", gn);
|
|
6189
|
+
}), h && t.addEventListener("mouseenter", (k) => {
|
|
6190
|
+
h(k, this.getEventHandlerData());
|
|
6191
|
+
}), u && t.addEventListener("keydown", (k) => {
|
|
6192
|
+
u(k, this.getEventHandlerData());
|
|
6193
|
+
}), d && t.addEventListener("keyup", (k) => {
|
|
6194
|
+
d(k, this.getEventHandlerData());
|
|
6195
|
+
}), f && t.addEventListener("submit", (k) => (k.preventDefault(), f(k, this.getEventHandlerData()), !1)), g && (t.title || (t.title = `Hold down the ${yc[g]} key while clicking to reset.`), t.addEventListener("click", (k) => {
|
|
6196
|
+
switch (g) {
|
|
6168
6197
|
case "ctrlKey":
|
|
6169
|
-
if (!
|
|
6198
|
+
if (!k.ctrlKey)
|
|
6170
6199
|
return;
|
|
6171
6200
|
break;
|
|
6172
6201
|
case "altKey":
|
|
6173
|
-
if (!
|
|
6202
|
+
if (!k.altKey)
|
|
6174
6203
|
return;
|
|
6175
6204
|
break;
|
|
6176
6205
|
case "shiftKey":
|
|
6177
|
-
if (!
|
|
6206
|
+
if (!k.shiftKey)
|
|
6178
6207
|
return;
|
|
6179
6208
|
break;
|
|
6180
6209
|
case "metaKey":
|
|
6181
|
-
if (!
|
|
6210
|
+
if (!k.metaKey)
|
|
6182
6211
|
return;
|
|
6183
6212
|
break;
|
|
6184
6213
|
default:
|
|
6185
6214
|
return;
|
|
6186
6215
|
}
|
|
6187
|
-
this.reset(),
|
|
6216
|
+
this.reset(), k.preventDefault(), k.stopPropagation();
|
|
6188
6217
|
}));
|
|
6189
6218
|
}
|
|
6190
6219
|
get data() {
|
|
6191
6220
|
return this._data;
|
|
6192
6221
|
}
|
|
6222
|
+
setLocalData(t) {
|
|
6223
|
+
this.localData = t;
|
|
6224
|
+
}
|
|
6193
6225
|
/**
|
|
6194
6226
|
* // PRIVATE USE ONLY \\
|
|
6195
6227
|
*
|
|
@@ -6198,13 +6230,22 @@ class yc {
|
|
|
6198
6230
|
* (e.g. calling `updateElement` and `onChange`)
|
|
6199
6231
|
*/
|
|
6200
6232
|
set __data(t) {
|
|
6201
|
-
this._data = t, this.updateElement(this.
|
|
6233
|
+
this._data = t, this.updateElement(this.getEventHandlerData());
|
|
6234
|
+
}
|
|
6235
|
+
getEventHandlerData() {
|
|
6236
|
+
return {
|
|
6237
|
+
element: this.element,
|
|
6238
|
+
data: this.data,
|
|
6239
|
+
localData: this.localData,
|
|
6240
|
+
setData: (t) => this.setData(t),
|
|
6241
|
+
setLocalData: (t) => this.setLocalData(t)
|
|
6242
|
+
};
|
|
6202
6243
|
}
|
|
6203
6244
|
// TODO: turn from setter into a method to allow for debouncing
|
|
6204
6245
|
/**
|
|
6205
6246
|
* Public-use setter for data that makes the change to all clients.
|
|
6206
6247
|
*/
|
|
6207
|
-
|
|
6248
|
+
setData(t) {
|
|
6208
6249
|
this.onChange(t);
|
|
6209
6250
|
}
|
|
6210
6251
|
setDataDebounced(t) {
|
|
@@ -6214,29 +6255,31 @@ class yc {
|
|
|
6214
6255
|
* Resets the element to its default state.
|
|
6215
6256
|
*/
|
|
6216
6257
|
reset() {
|
|
6217
|
-
this.
|
|
6258
|
+
this.setData(this.defaultData);
|
|
6218
6259
|
}
|
|
6219
6260
|
}
|
|
6220
|
-
const
|
|
6261
|
+
const kc = "playhtml.spencerc99.partykit.dev", dn = new Ct(), Qs = window.location.href, Zs = new ec(kc, Qs, dn, {
|
|
6221
6262
|
connect: !1
|
|
6222
6263
|
});
|
|
6223
|
-
new
|
|
6224
|
-
|
|
6225
|
-
const
|
|
6264
|
+
new wc(Qs, dn);
|
|
6265
|
+
Zs.connect();
|
|
6266
|
+
const z = dn.getMap("playhtml-global");
|
|
6226
6267
|
function He(e) {
|
|
6227
6268
|
return e.id;
|
|
6228
6269
|
}
|
|
6229
|
-
function
|
|
6270
|
+
function Ps(e) {
|
|
6230
6271
|
return document.getElementById(e);
|
|
6231
6272
|
}
|
|
6232
|
-
|
|
6233
|
-
e || console.error("Issue connecting to yjs..."),
|
|
6273
|
+
Zs.on("sync", (e) => {
|
|
6274
|
+
e || console.error("Issue connecting to yjs..."), Sc();
|
|
6234
6275
|
});
|
|
6235
|
-
function
|
|
6276
|
+
function Bn(e) {
|
|
6236
6277
|
return e instanceof HTMLElement;
|
|
6237
6278
|
}
|
|
6238
|
-
function
|
|
6239
|
-
const n =
|
|
6279
|
+
function Vn(e, t) {
|
|
6280
|
+
const n = qs[t], s = z.get(t), r = He(e);
|
|
6281
|
+
console.log(r, s.get(r));
|
|
6282
|
+
const i = {
|
|
6240
6283
|
...n,
|
|
6241
6284
|
data: s.get(r) || n.defaultData,
|
|
6242
6285
|
element: e,
|
|
@@ -6244,35 +6287,36 @@ function Bn(e, t) {
|
|
|
6244
6287
|
s.get(r) !== o && s.set(r, o);
|
|
6245
6288
|
}
|
|
6246
6289
|
};
|
|
6247
|
-
return new
|
|
6290
|
+
return new bc(i);
|
|
6248
6291
|
}
|
|
6249
|
-
function
|
|
6292
|
+
function Sc() {
|
|
6250
6293
|
const e = /* @__PURE__ */ new Map();
|
|
6251
|
-
console.log("EXISTING DATA",
|
|
6252
|
-
for (const t of Object.values(
|
|
6294
|
+
console.log("EXISTING DATA", z.toJSON());
|
|
6295
|
+
for (const t of Object.values(tt)) {
|
|
6253
6296
|
const n = Array.from(
|
|
6254
6297
|
document.querySelectorAll(`[${t}]`)
|
|
6255
|
-
).filter(
|
|
6256
|
-
if (!n.length)
|
|
6257
|
-
continue;
|
|
6258
|
-
const s = Ws[t];
|
|
6259
|
-
if (console.log(s), !s)
|
|
6298
|
+
).filter(Bn);
|
|
6299
|
+
if (!n.length || !qs[t])
|
|
6260
6300
|
continue;
|
|
6261
|
-
console.log(`initializing ${t}`),
|
|
6262
|
-
const r =
|
|
6301
|
+
console.log(`initializing ${t}`), z.get(t) || z.set(t, new ct());
|
|
6302
|
+
const r = z.get(t);
|
|
6263
6303
|
for (const i of n) {
|
|
6264
|
-
const o =
|
|
6304
|
+
const o = Vn(i, t);
|
|
6265
6305
|
e.set(He(i), o), i.classList.add("__playhtml-element"), i.classList.add(`__playhtml-${t}`);
|
|
6266
6306
|
}
|
|
6267
6307
|
r.observe((i) => {
|
|
6268
6308
|
i.changes.keys.forEach((o, c) => {
|
|
6269
6309
|
if (o.action === "add") {
|
|
6270
|
-
const l =
|
|
6271
|
-
if (!
|
|
6310
|
+
const l = Ps(c);
|
|
6311
|
+
if (!Bn(l)) {
|
|
6272
6312
|
console.log(`Element ${c} not an HTML element. Ignoring.`);
|
|
6273
6313
|
return;
|
|
6274
6314
|
}
|
|
6275
|
-
|
|
6315
|
+
if (e.has(c)) {
|
|
6316
|
+
console.log(`Element ${c} already registered. Ignoring.`);
|
|
6317
|
+
return;
|
|
6318
|
+
}
|
|
6319
|
+
const a = Vn(
|
|
6276
6320
|
l,
|
|
6277
6321
|
t
|
|
6278
6322
|
);
|
|
@@ -6285,13 +6329,14 @@ function kc() {
|
|
|
6285
6329
|
});
|
|
6286
6330
|
});
|
|
6287
6331
|
}
|
|
6288
|
-
|
|
6332
|
+
z.observe((t) => {
|
|
6289
6333
|
t.changes.keys.forEach((n, s) => {
|
|
6290
|
-
n.action === "add" &&
|
|
6334
|
+
n.action === "add" && z.set(s, z.get(s));
|
|
6291
6335
|
});
|
|
6292
6336
|
});
|
|
6293
6337
|
}
|
|
6294
6338
|
export {
|
|
6295
|
-
|
|
6296
|
-
|
|
6339
|
+
Ps as getElementFromId,
|
|
6340
|
+
z as globalData,
|
|
6341
|
+
Sc as setupElements
|
|
6297
6342
|
};
|