playhtml 2.1.9 → 2.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/playhtml.es.js +1008 -972
- package/package.json +2 -2
package/dist/playhtml.es.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var y = (e, t, n) => (
|
|
1
|
+
var Xr = Object.defineProperty;
|
|
2
|
+
var Jr = (e, t, n) => t in e ? Xr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var y = (e, t, n) => (Jr(e, typeof t != "symbol" ? t + "" : t, n), n), Fn = (e, t, n) => {
|
|
4
4
|
if (!t.has(e))
|
|
5
5
|
throw TypeError("Cannot " + n);
|
|
6
6
|
};
|
|
7
|
-
var
|
|
7
|
+
var le = (e, t, n) => (Fn(e, t, "read from private field"), n ? n.call(e) : t.get(e)), Hn = (e, t, n) => {
|
|
8
8
|
if (t.has(e))
|
|
9
9
|
throw TypeError("Cannot add the same private member more than once");
|
|
10
10
|
t instanceof WeakSet ? t.add(e) : t.set(e, n);
|
|
11
|
-
},
|
|
12
|
-
var
|
|
13
|
-
if (e.byteLength <=
|
|
11
|
+
}, jn = (e, t, n, s) => (Fn(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n);
|
|
12
|
+
var ae = 1e6, Wr = "y-pk-batch", zn = !1, Nt = (e, t) => {
|
|
13
|
+
if (e.byteLength <= ae) {
|
|
14
14
|
t.send(e);
|
|
15
15
|
return;
|
|
16
16
|
}
|
|
17
|
-
|
|
17
|
+
zn || (console.warn(
|
|
18
18
|
"[y-partykit]",
|
|
19
19
|
"The Y.js update size exceeds 1MB, which is the maximum size for an individual update. The update will be split into chunks. This is an experimental feature.",
|
|
20
20
|
`Message size: ${(e.byteLength / 1e3 / 1e3).toFixed(1)}MB`
|
|
21
|
-
),
|
|
22
|
-
const n = (Date.now() + Math.random()).toString(36).substring(10), s = Math.ceil(e.byteLength /
|
|
21
|
+
), zn = !0);
|
|
22
|
+
const n = (Date.now() + Math.random()).toString(36).substring(10), s = Math.ceil(e.byteLength / ae);
|
|
23
23
|
t.send(
|
|
24
|
-
|
|
24
|
+
Kn({
|
|
25
25
|
id: n,
|
|
26
26
|
type: "start",
|
|
27
27
|
size: e.byteLength,
|
|
@@ -30,11 +30,11 @@ var ce = 1e6, Xr = "y-pk-batch", jn = !1, Nt = (e, t) => {
|
|
|
30
30
|
);
|
|
31
31
|
let r = 0, i = 0;
|
|
32
32
|
for (let o = 0; o < s; o++) {
|
|
33
|
-
const c = e.slice(
|
|
33
|
+
const c = e.slice(ae * o, ae * (o + 1));
|
|
34
34
|
t.send(c), i += 1, r += c.byteLength;
|
|
35
35
|
}
|
|
36
36
|
t.send(
|
|
37
|
-
|
|
37
|
+
Kn({
|
|
38
38
|
id: n,
|
|
39
39
|
type: "end",
|
|
40
40
|
size: r,
|
|
@@ -42,26 +42,26 @@ var ce = 1e6, Xr = "y-pk-batch", jn = !1, Nt = (e, t) => {
|
|
|
42
42
|
})
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
-
function
|
|
46
|
-
return `${
|
|
45
|
+
function Kn(e) {
|
|
46
|
+
return `${Wr}#${JSON.stringify(e)}`;
|
|
47
47
|
}
|
|
48
|
-
const _t = () => /* @__PURE__ */ new Map(),
|
|
48
|
+
const _t = () => /* @__PURE__ */ new Map(), ks = (e, t, n) => {
|
|
49
49
|
let s = e.get(t);
|
|
50
50
|
return s === void 0 && e.set(t, s = n()), s;
|
|
51
|
-
},
|
|
51
|
+
}, Ds = () => /* @__PURE__ */ new Set(), Pr = Array.from, Gr = String.fromCharCode, qr = (e) => e.toLowerCase(), Zr = /^\s*/g, Qr = (e) => e.replace(Zr, ""), ti = /([A-Z])/g, Yn = (e, t) => Qr(e.replace(ti, (n) => `${t}${qr(n)}`)), ei = (e) => {
|
|
52
52
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
53
53
|
for (let r = 0; r < n; r++)
|
|
54
54
|
s[r] = /** @type {number} */
|
|
55
55
|
t.codePointAt(r);
|
|
56
56
|
return s;
|
|
57
|
-
},
|
|
57
|
+
}, Ht = (
|
|
58
58
|
/** @type {TextEncoder} */
|
|
59
59
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
60
|
-
),
|
|
61
|
-
let
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
let
|
|
60
|
+
), ni = (e) => Ht.encode(e), si = Ht ? ni : ei;
|
|
61
|
+
let Ve = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
62
|
+
Ve && Ve.decode(new Uint8Array()).length === 1 && (Ve = null);
|
|
63
|
+
const Xn = (e) => e === void 0 ? null : e;
|
|
64
|
+
let ri = class {
|
|
65
65
|
constructor() {
|
|
66
66
|
this.map = /* @__PURE__ */ new Map();
|
|
67
67
|
}
|
|
@@ -78,27 +78,27 @@ let ni = class {
|
|
|
78
78
|
getItem(t) {
|
|
79
79
|
return this.map.get(t);
|
|
80
80
|
}
|
|
81
|
-
},
|
|
81
|
+
}, Es = new ri(), wn = !0;
|
|
82
82
|
try {
|
|
83
|
-
typeof localStorage < "u" && localStorage && (
|
|
83
|
+
typeof localStorage < "u" && localStorage && (Es = localStorage, wn = !1);
|
|
84
84
|
} catch {
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const Cs = Es, ii = (e) => wn || addEventListener(
|
|
87
87
|
"storage",
|
|
88
88
|
/** @type {any} */
|
|
89
89
|
e
|
|
90
|
-
),
|
|
90
|
+
), oi = (e) => wn || removeEventListener(
|
|
91
91
|
"storage",
|
|
92
92
|
/** @type {any} */
|
|
93
93
|
e
|
|
94
|
-
),
|
|
94
|
+
), ci = (e, t) => {
|
|
95
95
|
const n = [];
|
|
96
96
|
for (const s in e)
|
|
97
97
|
n.push(t(e[s], s));
|
|
98
98
|
return n;
|
|
99
|
-
},
|
|
99
|
+
}, li = (e, t) => t.includes(e), Lt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", As = typeof window < "u" && typeof document < "u" && !Lt;
|
|
100
100
|
let V;
|
|
101
|
-
const
|
|
101
|
+
const ai = () => {
|
|
102
102
|
if (V === void 0)
|
|
103
103
|
if (Lt) {
|
|
104
104
|
V = _t();
|
|
@@ -113,67 +113,67 @@ const ci = () => {
|
|
|
113
113
|
typeof location == "object" ? (V = _t(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
114
114
|
if (e.length !== 0) {
|
|
115
115
|
const [t, n] = e.split("=");
|
|
116
|
-
V.set(`--${
|
|
116
|
+
V.set(`--${Yn(t, "-")}`, n), V.set(`-${Yn(t, "-")}`, n);
|
|
117
117
|
}
|
|
118
118
|
})) : V = _t();
|
|
119
119
|
return V;
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
!
|
|
124
|
-
const
|
|
125
|
-
let
|
|
120
|
+
}, Ze = (e) => ai().has(e), Qe = (e) => Xn(Lt ? process.env[e.toUpperCase()] : Cs.getItem(e)), hi = (e) => Ze("--" + e) || Qe(e) !== null;
|
|
121
|
+
hi("production");
|
|
122
|
+
const Jn = Lt && li(process.env.FORCE_COLOR, ["true", "1", "2"]);
|
|
123
|
+
!Ze("no-colors") && (!Lt || process.stdout.isTTY || Jn) && (!Lt || Ze("color") || Jn || Qe("COLORTERM") !== null || (Qe("TERM") || "").includes("color"));
|
|
124
|
+
const ui = Math.floor, Ls = (e, t) => e < t ? e : t, di = (e, t) => e > t ? e : t, fi = Math.pow, Is = 128, ge = 127, gi = Number.MAX_SAFE_INTEGER;
|
|
125
|
+
let pi = class {
|
|
126
126
|
constructor() {
|
|
127
127
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
const
|
|
130
|
+
const $ = () => new pi(), mn = (e) => {
|
|
131
131
|
let t = e.cpos;
|
|
132
132
|
for (let n = 0; n < e.bufs.length; n++)
|
|
133
133
|
t += e.bufs[n].length;
|
|
134
134
|
return t;
|
|
135
|
-
},
|
|
136
|
-
const t = new Uint8Array(
|
|
135
|
+
}, T = (e) => {
|
|
136
|
+
const t = new Uint8Array(mn(e));
|
|
137
137
|
let n = 0;
|
|
138
138
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
139
139
|
const r = e.bufs[s];
|
|
140
140
|
t.set(r, n), n += r.length;
|
|
141
141
|
}
|
|
142
142
|
return t.set(new Uint8Array(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
143
|
-
},
|
|
143
|
+
}, be = (e, t) => {
|
|
144
144
|
const n = e.cbuf.length;
|
|
145
145
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
146
146
|
}, v = (e, t) => {
|
|
147
|
-
for (; t >
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
},
|
|
151
|
-
if (t.length <
|
|
152
|
-
const n =
|
|
147
|
+
for (; t > ge; )
|
|
148
|
+
be(e, Is | ge & t), t = ui(t / 128);
|
|
149
|
+
be(e, ge & t);
|
|
150
|
+
}, tn = new Uint8Array(3e4), wi = tn.length / 3, mi = (e, t) => {
|
|
151
|
+
if (t.length < wi) {
|
|
152
|
+
const n = Ht.encodeInto(t, tn).written || 0;
|
|
153
153
|
v(e, n);
|
|
154
154
|
for (let s = 0; s < n; s++)
|
|
155
|
-
|
|
155
|
+
be(e, tn[s]);
|
|
156
156
|
} else
|
|
157
|
-
kt(e,
|
|
158
|
-
},
|
|
157
|
+
kt(e, si(t));
|
|
158
|
+
}, yi = (e, t) => {
|
|
159
159
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
160
160
|
v(e, s);
|
|
161
161
|
for (let r = 0; r < s; r++)
|
|
162
|
-
|
|
162
|
+
be(
|
|
163
163
|
e,
|
|
164
164
|
/** @type {number} */
|
|
165
165
|
n.codePointAt(r)
|
|
166
166
|
);
|
|
167
167
|
};
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
const
|
|
171
|
-
const n = e.cbuf.length, s = e.cpos, r =
|
|
172
|
-
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(
|
|
168
|
+
Ht && /** @type {any} */
|
|
169
|
+
Ht.encodeInto;
|
|
170
|
+
const bi = (e, t) => {
|
|
171
|
+
const n = e.cbuf.length, s = e.cpos, r = Ls(n - s, t.length), i = t.length - r;
|
|
172
|
+
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(di(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
173
173
|
}, kt = (e, t) => {
|
|
174
|
-
v(e, t.byteLength),
|
|
175
|
-
},
|
|
176
|
-
let
|
|
174
|
+
v(e, t.byteLength), bi(e, t);
|
|
175
|
+
}, vs = (e) => new Error(e), Si = vs("Unexpected end of array"), _i = vs("Integer out of Range");
|
|
176
|
+
let ki = class {
|
|
177
177
|
/**
|
|
178
178
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
179
179
|
*/
|
|
@@ -181,65 +181,65 @@ let Si = class {
|
|
|
181
181
|
this.arr = t, this.pos = 0;
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
const
|
|
184
|
+
const Di = (e) => new ki(e), Ei = (e, t) => {
|
|
185
185
|
const n = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
186
186
|
return e.pos += t, n;
|
|
187
|
-
},
|
|
187
|
+
}, Ci = (e) => Ei(e, xs(e)), xs = (e) => {
|
|
188
188
|
let t = 0, n = 1;
|
|
189
189
|
const s = e.arr.length;
|
|
190
190
|
for (; e.pos < s; ) {
|
|
191
191
|
const r = e.arr[e.pos++];
|
|
192
|
-
if (t = t + (r &
|
|
192
|
+
if (t = t + (r & ge) * n, n *= 128, r < Is)
|
|
193
193
|
return t;
|
|
194
|
-
if (t >
|
|
195
|
-
throw
|
|
194
|
+
if (t > gi)
|
|
195
|
+
throw _i;
|
|
196
196
|
}
|
|
197
|
-
throw
|
|
198
|
-
},
|
|
197
|
+
throw Si;
|
|
198
|
+
}, Ai = (e) => new Uint8Array(e), Li = (e, t, n) => new Uint8Array(e, t, n), Ii = (e) => new Uint8Array(e), vi = (e) => {
|
|
199
199
|
let t = "";
|
|
200
200
|
for (let n = 0; n < e.byteLength; n++)
|
|
201
|
-
t +=
|
|
201
|
+
t += Gr(e[n]);
|
|
202
202
|
return btoa(t);
|
|
203
|
-
},
|
|
204
|
-
const t = atob(e), n =
|
|
203
|
+
}, xi = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Ti = (e) => {
|
|
204
|
+
const t = atob(e), n = Ai(t.length);
|
|
205
205
|
for (let s = 0; s < t.length; s++)
|
|
206
206
|
n[s] = t.charCodeAt(s);
|
|
207
207
|
return n;
|
|
208
208
|
}, Mi = (e) => {
|
|
209
209
|
const t = Buffer.from(e, "base64");
|
|
210
|
-
return
|
|
211
|
-
},
|
|
212
|
-
class
|
|
210
|
+
return Li(t.buffer, t.byteOffset, t.byteLength);
|
|
211
|
+
}, Ui = As ? vi : xi, Oi = As ? Ti : Mi, Ts = /* @__PURE__ */ new Map();
|
|
212
|
+
class Ri {
|
|
213
213
|
/**
|
|
214
214
|
* @param {string} room
|
|
215
215
|
*/
|
|
216
216
|
constructor(t) {
|
|
217
|
-
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data:
|
|
217
|
+
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: Oi(n.newValue || "") }), ii(this._onChange);
|
|
218
218
|
}
|
|
219
219
|
/**
|
|
220
220
|
* @param {ArrayBuffer} buf
|
|
221
221
|
*/
|
|
222
222
|
postMessage(t) {
|
|
223
|
-
|
|
223
|
+
Cs.setItem(this.room, Ui(Ii(t)));
|
|
224
224
|
}
|
|
225
225
|
close() {
|
|
226
|
-
|
|
226
|
+
oi(this._onChange);
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
|
-
const
|
|
230
|
-
const t =
|
|
229
|
+
const $i = typeof BroadcastChannel > "u" ? Ri : BroadcastChannel, yn = (e) => ks(Ts, e, () => {
|
|
230
|
+
const t = Ds(), n = new $i(e);
|
|
231
231
|
return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
232
232
|
bc: n,
|
|
233
233
|
subs: t
|
|
234
234
|
};
|
|
235
|
-
}),
|
|
236
|
-
const n =
|
|
237
|
-
return s && n.subs.size === 0 && (n.bc.close(),
|
|
235
|
+
}), Ni = (e, t) => (yn(e).subs.add(t), t), Bi = (e, t) => {
|
|
236
|
+
const n = yn(e), s = n.subs.delete(t);
|
|
237
|
+
return s && n.subs.size === 0 && (n.bc.close(), Ts.delete(e)), s;
|
|
238
238
|
}, bt = (e, t, n = null) => {
|
|
239
|
-
const s =
|
|
239
|
+
const s = yn(e);
|
|
240
240
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
|
|
241
241
|
};
|
|
242
|
-
let
|
|
242
|
+
let Vi = class {
|
|
243
243
|
constructor() {
|
|
244
244
|
this._observers = _t();
|
|
245
245
|
}
|
|
@@ -248,7 +248,7 @@ let $i = class {
|
|
|
248
248
|
* @param {function} f
|
|
249
249
|
*/
|
|
250
250
|
on(t, n) {
|
|
251
|
-
|
|
251
|
+
ks(this._observers, t, Ds).add(n);
|
|
252
252
|
}
|
|
253
253
|
/**
|
|
254
254
|
* @param {N} name
|
|
@@ -278,13 +278,13 @@ let $i = class {
|
|
|
278
278
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
279
279
|
*/
|
|
280
280
|
emit(t, n) {
|
|
281
|
-
return
|
|
281
|
+
return Pr((this._observers.get(t) || _t()).values()).forEach((s) => s(...n));
|
|
282
282
|
}
|
|
283
283
|
destroy() {
|
|
284
284
|
this._observers = _t();
|
|
285
285
|
}
|
|
286
286
|
};
|
|
287
|
-
const
|
|
287
|
+
const en = Date.now, Fi = (e) => ci(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), B = () => /* @__PURE__ */ new Map(), nn = (e) => {
|
|
288
288
|
const t = B();
|
|
289
289
|
return e.forEach((n, s) => {
|
|
290
290
|
t.set(s, n);
|
|
@@ -292,21 +292,21 @@ const tn = Date.now, Bi = (e) => ii(e, (t, n) => `${encodeURIComponent(n)}=${enc
|
|
|
292
292
|
}, rt = (e, t, n) => {
|
|
293
293
|
let s = e.get(t);
|
|
294
294
|
return s === void 0 && e.set(t, s = n()), s;
|
|
295
|
-
},
|
|
295
|
+
}, Hi = (e, t) => {
|
|
296
296
|
const n = [];
|
|
297
297
|
for (const [s, r] of e)
|
|
298
298
|
n.push(t(r, s));
|
|
299
299
|
return n;
|
|
300
|
-
},
|
|
300
|
+
}, ji = (e, t) => {
|
|
301
301
|
for (const [n, s] of e)
|
|
302
302
|
if (t(s, n))
|
|
303
303
|
return !0;
|
|
304
304
|
return !1;
|
|
305
|
-
}, It = () => /* @__PURE__ */ new Set(),
|
|
305
|
+
}, It = () => /* @__PURE__ */ new Set(), Fe = (e) => e[e.length - 1], zi = (e, t) => {
|
|
306
306
|
for (let n = 0; n < t.length; n++)
|
|
307
307
|
e.push(t[n]);
|
|
308
|
-
}, nt = Array.from,
|
|
309
|
-
class
|
|
308
|
+
}, nt = Array.from, Ki = Array.isArray;
|
|
309
|
+
class bn {
|
|
310
310
|
constructor() {
|
|
311
311
|
this._observers = B();
|
|
312
312
|
}
|
|
@@ -351,20 +351,20 @@ class yn {
|
|
|
351
351
|
this._observers = B();
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
const
|
|
354
|
+
const P = Math.floor, pe = Math.abs, Ms = (e, t) => e < t ? e : t, gt = (e, t) => e > t ? e : t, Us = (e) => e !== 0 ? e < 0 : 1 / e < 0, Yi = (e) => e.toLowerCase(), Xi = /^\s*/g, Ji = (e) => e.replace(Xi, ""), Wi = /([A-Z])/g, Wn = (e, t) => Ji(e.replace(Wi, (n) => `${t}${Yi(n)}`)), Pi = (e) => {
|
|
355
355
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
356
356
|
for (let r = 0; r < n; r++)
|
|
357
357
|
s[r] = /** @type {number} */
|
|
358
358
|
t.codePointAt(r);
|
|
359
359
|
return s;
|
|
360
|
-
},
|
|
360
|
+
}, jt = (
|
|
361
361
|
/** @type {TextEncoder} */
|
|
362
362
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
363
|
-
),
|
|
364
|
-
let
|
|
365
|
-
|
|
363
|
+
), Gi = (e) => jt.encode(e), qi = jt ? Gi : Pi;
|
|
364
|
+
let Bt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
365
|
+
Bt && Bt.decode(new Uint8Array()).length === 1 && (Bt = null);
|
|
366
366
|
const Pn = (e) => e === void 0 ? null : e;
|
|
367
|
-
class
|
|
367
|
+
class Zi {
|
|
368
368
|
constructor() {
|
|
369
369
|
this.map = /* @__PURE__ */ new Map();
|
|
370
370
|
}
|
|
@@ -382,33 +382,33 @@ class Gi {
|
|
|
382
382
|
return this.map.get(t);
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
|
-
let
|
|
385
|
+
let Os = new Zi(), Qi = !0;
|
|
386
386
|
try {
|
|
387
|
-
typeof localStorage < "u" && (
|
|
387
|
+
typeof localStorage < "u" && (Os = localStorage, Qi = !1);
|
|
388
388
|
} catch {
|
|
389
389
|
}
|
|
390
|
-
const
|
|
390
|
+
const to = Os, eo = Object.assign, no = Object.keys, so = (e, t) => {
|
|
391
391
|
for (const n in e)
|
|
392
392
|
t(e[n], n);
|
|
393
|
-
},
|
|
393
|
+
}, Se = (e) => no(e).length, ro = (e) => {
|
|
394
394
|
for (const t in e)
|
|
395
395
|
return !1;
|
|
396
396
|
return !0;
|
|
397
|
-
},
|
|
397
|
+
}, io = (e, t) => {
|
|
398
398
|
for (const n in e)
|
|
399
399
|
if (!t(e[n], n))
|
|
400
400
|
return !1;
|
|
401
401
|
return !0;
|
|
402
|
-
},
|
|
402
|
+
}, Rs = (e, t) => Object.prototype.hasOwnProperty.call(e, t), oo = (e, t) => e === t || Se(e) === Se(t) && io(e, (n, s) => (n !== void 0 || Rs(t, s)) && t[s] === n), Sn = (e, t, n = 0) => {
|
|
403
403
|
try {
|
|
404
404
|
for (; n < e.length; n++)
|
|
405
405
|
e[n](...t);
|
|
406
406
|
} finally {
|
|
407
|
-
n < e.length &&
|
|
407
|
+
n < e.length && Sn(e, t, n + 1);
|
|
408
408
|
}
|
|
409
|
-
},
|
|
409
|
+
}, co = (e) => e, lo = (e, t) => e === t, Vt = (e, t) => {
|
|
410
410
|
if (e == null || t == null)
|
|
411
|
-
return
|
|
411
|
+
return lo(e, t);
|
|
412
412
|
if (e.constructor !== t.constructor)
|
|
413
413
|
return !1;
|
|
414
414
|
if (e === t)
|
|
@@ -436,33 +436,33 @@ const Zi = Us, Qi = Object.assign, to = Object.keys, eo = (e, t) => {
|
|
|
436
436
|
if (e.size !== t.size)
|
|
437
437
|
return !1;
|
|
438
438
|
for (const n of e.keys())
|
|
439
|
-
if (!t.has(n) || !
|
|
439
|
+
if (!t.has(n) || !Vt(e.get(n), t.get(n)))
|
|
440
440
|
return !1;
|
|
441
441
|
break;
|
|
442
442
|
}
|
|
443
443
|
case Object:
|
|
444
|
-
if (
|
|
444
|
+
if (Se(e) !== Se(t))
|
|
445
445
|
return !1;
|
|
446
446
|
for (const n in e)
|
|
447
|
-
if (!
|
|
447
|
+
if (!Rs(e, n) || !Vt(e[n], t[n]))
|
|
448
448
|
return !1;
|
|
449
449
|
break;
|
|
450
450
|
case Array:
|
|
451
451
|
if (e.length !== t.length)
|
|
452
452
|
return !1;
|
|
453
453
|
for (let n = 0; n < e.length; n++)
|
|
454
|
-
if (!
|
|
454
|
+
if (!Vt(e[n], t[n]))
|
|
455
455
|
return !1;
|
|
456
456
|
break;
|
|
457
457
|
default:
|
|
458
458
|
return !1;
|
|
459
459
|
}
|
|
460
460
|
return !0;
|
|
461
|
-
},
|
|
461
|
+
}, ao = (e, t) => t.includes(e), zt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name);
|
|
462
462
|
let F;
|
|
463
|
-
const
|
|
463
|
+
const ho = () => {
|
|
464
464
|
if (F === void 0)
|
|
465
|
-
if (
|
|
465
|
+
if (zt) {
|
|
466
466
|
F = B();
|
|
467
467
|
const e = process.argv;
|
|
468
468
|
let t = null;
|
|
@@ -475,18 +475,18 @@ const lo = () => {
|
|
|
475
475
|
typeof location == "object" ? (F = B(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
476
476
|
if (e.length !== 0) {
|
|
477
477
|
const [t, n] = e.split("=");
|
|
478
|
-
F.set(`--${
|
|
478
|
+
F.set(`--${Wn(t, "-")}`, n), F.set(`-${Wn(t, "-")}`, n);
|
|
479
479
|
}
|
|
480
480
|
})) : F = B();
|
|
481
481
|
return F;
|
|
482
|
-
},
|
|
483
|
-
|
|
484
|
-
const
|
|
482
|
+
}, sn = (e) => ho().has(e), rn = (e) => Pn(zt ? process.env[e.toUpperCase()] : to.getItem(e)), uo = (e) => sn("--" + e) || rn(e) !== null;
|
|
483
|
+
uo("production");
|
|
484
|
+
const Gn = zt && ao(process.env.FORCE_COLOR, ["true", "1", "2"]), fo = !sn("no-colors") && (!zt || process.stdout.isTTY || Gn) && (!zt || sn("color") || Gn || rn("COLORTERM") !== null || (rn("TERM") || "").includes("color")), qn = 1, Zn = 2, He = 4, je = 8, Kt = 32, J = 64, x = 128, Te = 31, on = 63, ct = 127, go = 2147483647, $s = Number.MAX_SAFE_INTEGER, po = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && P(e) === e), G = (e) => new Error(e), H = () => {
|
|
485
485
|
throw G("Method unimplemented");
|
|
486
486
|
}, j = () => {
|
|
487
487
|
throw G("Unexpected case");
|
|
488
|
-
},
|
|
489
|
-
class
|
|
488
|
+
}, Ns = G("Unexpected end of array"), Bs = G("Integer out of Range");
|
|
489
|
+
class Me {
|
|
490
490
|
/**
|
|
491
491
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
492
492
|
*/
|
|
@@ -494,34 +494,34 @@ class xe {
|
|
|
494
494
|
this.arr = t, this.pos = 0;
|
|
495
495
|
}
|
|
496
496
|
}
|
|
497
|
-
const pt = (e) => new
|
|
498
|
-
const n =
|
|
497
|
+
const pt = (e) => new Me(e), wo = (e) => e.pos !== e.arr.length, mo = (e, t) => {
|
|
498
|
+
const n = Dn(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
499
499
|
return e.pos += t, n;
|
|
500
|
-
}, I = (e) =>
|
|
500
|
+
}, I = (e) => mo(e, w(e)), vt = (e) => e.arr[e.pos++], w = (e) => {
|
|
501
501
|
let t = 0, n = 1;
|
|
502
502
|
const s = e.arr.length;
|
|
503
503
|
for (; e.pos < s; ) {
|
|
504
504
|
const r = e.arr[e.pos++];
|
|
505
|
-
if (t = t + (r & ct) * n, n *= 128, r <
|
|
505
|
+
if (t = t + (r & ct) * n, n *= 128, r < x)
|
|
506
506
|
return t;
|
|
507
|
-
if (t >
|
|
508
|
-
throw
|
|
507
|
+
if (t > $s)
|
|
508
|
+
throw Bs;
|
|
509
509
|
}
|
|
510
|
-
throw
|
|
511
|
-
},
|
|
512
|
-
let t = e.arr[e.pos++], n = t &
|
|
510
|
+
throw Ns;
|
|
511
|
+
}, _n = (e) => {
|
|
512
|
+
let t = e.arr[e.pos++], n = t & on, s = 64;
|
|
513
513
|
const r = (t & J) > 0 ? -1 : 1;
|
|
514
|
-
if (!(t &
|
|
514
|
+
if (!(t & x))
|
|
515
515
|
return r * n;
|
|
516
516
|
const i = e.arr.length;
|
|
517
517
|
for (; e.pos < i; ) {
|
|
518
|
-
if (t = e.arr[e.pos++], n = n + (t & ct) * s, s *= 128, t <
|
|
518
|
+
if (t = e.arr[e.pos++], n = n + (t & ct) * s, s *= 128, t < x)
|
|
519
519
|
return r * n;
|
|
520
|
-
if (n >
|
|
521
|
-
throw
|
|
520
|
+
if (n > $s)
|
|
521
|
+
throw Bs;
|
|
522
522
|
}
|
|
523
|
-
throw
|
|
524
|
-
},
|
|
523
|
+
throw Ns;
|
|
524
|
+
}, yo = (e) => {
|
|
525
525
|
let t = w(e);
|
|
526
526
|
if (t === 0)
|
|
527
527
|
return "";
|
|
@@ -541,28 +541,28 @@ const pt = (e) => new xe(e), go = (e) => e.pos !== e.arr.length, po = (e, t) =>
|
|
|
541
541
|
}
|
|
542
542
|
return decodeURIComponent(escape(n));
|
|
543
543
|
}
|
|
544
|
-
},
|
|
544
|
+
}, bo = (e) => (
|
|
545
545
|
/** @type any */
|
|
546
|
-
|
|
547
|
-
), et =
|
|
546
|
+
Bt.decode(I(e))
|
|
547
|
+
), et = Bt ? bo : yo, kn = (e, t) => {
|
|
548
548
|
const n = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
|
|
549
549
|
return e.pos += t, n;
|
|
550
|
-
},
|
|
550
|
+
}, So = (e) => kn(e, 4).getFloat32(0, !1), _o = (e) => kn(e, 8).getFloat64(0, !1), ko = (e) => (
|
|
551
551
|
/** @type {any} */
|
|
552
|
-
|
|
553
|
-
),
|
|
552
|
+
kn(e, 8).getBigInt64(0, !1)
|
|
553
|
+
), Do = [
|
|
554
554
|
(e) => {
|
|
555
555
|
},
|
|
556
556
|
// CASE 127: undefined
|
|
557
557
|
(e) => null,
|
|
558
558
|
// CASE 126: null
|
|
559
|
-
|
|
559
|
+
_n,
|
|
560
560
|
// CASE 125: integer
|
|
561
|
-
|
|
561
|
+
So,
|
|
562
562
|
// CASE 124: float32
|
|
563
|
-
|
|
563
|
+
_o,
|
|
564
564
|
// CASE 123: float64
|
|
565
|
-
|
|
565
|
+
ko,
|
|
566
566
|
// CASE 122: bigint
|
|
567
567
|
(e) => !1,
|
|
568
568
|
// CASE 121: boolean (false)
|
|
@@ -574,20 +574,20 @@ const pt = (e) => new xe(e), go = (e) => e.pos !== e.arr.length, po = (e, t) =>
|
|
|
574
574
|
const t = w(e), n = {};
|
|
575
575
|
for (let s = 0; s < t; s++) {
|
|
576
576
|
const r = et(e);
|
|
577
|
-
n[r] =
|
|
577
|
+
n[r] = Yt(e);
|
|
578
578
|
}
|
|
579
579
|
return n;
|
|
580
580
|
},
|
|
581
581
|
(e) => {
|
|
582
582
|
const t = w(e), n = [];
|
|
583
583
|
for (let s = 0; s < t; s++)
|
|
584
|
-
n.push(
|
|
584
|
+
n.push(Yt(e));
|
|
585
585
|
return n;
|
|
586
586
|
},
|
|
587
587
|
I
|
|
588
588
|
// CASE 116: Uint8Array
|
|
589
|
-
],
|
|
590
|
-
class
|
|
589
|
+
], Yt = (e) => Do[127 - vt(e)](e);
|
|
590
|
+
class Qn extends Me {
|
|
591
591
|
/**
|
|
592
592
|
* @param {Uint8Array} uint8Array
|
|
593
593
|
* @param {function(Decoder):T} reader
|
|
@@ -596,11 +596,11 @@ class Zn extends xe {
|
|
|
596
596
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
597
597
|
}
|
|
598
598
|
read() {
|
|
599
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
599
|
+
return this.count === 0 && (this.s = this.reader(this), wo(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
600
600
|
this.s;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
class
|
|
603
|
+
class we extends Me {
|
|
604
604
|
/**
|
|
605
605
|
* @param {Uint8Array} uint8Array
|
|
606
606
|
*/
|
|
@@ -609,15 +609,15 @@ class ge extends xe {
|
|
|
609
609
|
}
|
|
610
610
|
read() {
|
|
611
611
|
if (this.count === 0) {
|
|
612
|
-
this.s =
|
|
613
|
-
const t =
|
|
612
|
+
this.s = _n(this);
|
|
613
|
+
const t = Us(this.s);
|
|
614
614
|
this.count = 1, t && (this.s = -this.s, this.count = w(this) + 2);
|
|
615
615
|
}
|
|
616
616
|
return this.count--, /** @type {number} */
|
|
617
617
|
this.s;
|
|
618
618
|
}
|
|
619
619
|
}
|
|
620
|
-
class
|
|
620
|
+
class ze extends Me {
|
|
621
621
|
/**
|
|
622
622
|
* @param {Uint8Array} uint8Array
|
|
623
623
|
*/
|
|
@@ -629,18 +629,18 @@ class je extends xe {
|
|
|
629
629
|
*/
|
|
630
630
|
read() {
|
|
631
631
|
if (this.count === 0) {
|
|
632
|
-
const t =
|
|
633
|
-
this.diff =
|
|
632
|
+
const t = _n(this), n = t & 1;
|
|
633
|
+
this.diff = P(t / 2), this.count = 1, n && (this.count = w(this) + 2);
|
|
634
634
|
}
|
|
635
635
|
return this.s += this.diff, this.count--, this.s;
|
|
636
636
|
}
|
|
637
637
|
}
|
|
638
|
-
class
|
|
638
|
+
class Eo {
|
|
639
639
|
/**
|
|
640
640
|
* @param {Uint8Array} uint8Array
|
|
641
641
|
*/
|
|
642
642
|
constructor(t) {
|
|
643
|
-
this.decoder = new
|
|
643
|
+
this.decoder = new we(t), this.str = et(this.decoder), this.spos = 0;
|
|
644
644
|
}
|
|
645
645
|
/**
|
|
646
646
|
* @return {string}
|
|
@@ -650,51 +650,51 @@ class ko {
|
|
|
650
650
|
return this.spos = t, n;
|
|
651
651
|
}
|
|
652
652
|
}
|
|
653
|
-
const
|
|
654
|
-
const t =
|
|
653
|
+
const Co = (e) => new Uint8Array(e), Dn = (e, t, n) => new Uint8Array(e, t, n), Ao = (e) => {
|
|
654
|
+
const t = Co(e.byteLength);
|
|
655
655
|
return t.set(e), t;
|
|
656
656
|
};
|
|
657
|
-
class
|
|
657
|
+
class te {
|
|
658
658
|
constructor() {
|
|
659
659
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
660
660
|
}
|
|
661
661
|
}
|
|
662
|
-
const
|
|
662
|
+
const ee = () => new te(), Lo = (e) => {
|
|
663
663
|
let t = e.cpos;
|
|
664
664
|
for (let n = 0; n < e.bufs.length; n++)
|
|
665
665
|
t += e.bufs[n].length;
|
|
666
666
|
return t;
|
|
667
|
-
},
|
|
668
|
-
const t = new Uint8Array(
|
|
667
|
+
}, N = (e) => {
|
|
668
|
+
const t = new Uint8Array(Lo(e));
|
|
669
669
|
let n = 0;
|
|
670
670
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
671
671
|
const r = e.bufs[s];
|
|
672
672
|
t.set(r, n), n += r.length;
|
|
673
673
|
}
|
|
674
|
-
return t.set(
|
|
675
|
-
},
|
|
674
|
+
return t.set(Dn(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
675
|
+
}, Io = (e, t) => {
|
|
676
676
|
const n = e.cbuf.length;
|
|
677
|
-
n - e.cpos < t && (e.bufs.push(
|
|
677
|
+
n - e.cpos < t && (e.bufs.push(Dn(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(gt(n, t) * 2), e.cpos = 0);
|
|
678
678
|
}, E = (e, t) => {
|
|
679
679
|
const n = e.cbuf.length;
|
|
680
680
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
681
|
-
},
|
|
681
|
+
}, cn = E, m = (e, t) => {
|
|
682
682
|
for (; t > ct; )
|
|
683
|
-
E(e,
|
|
683
|
+
E(e, x | ct & t), t = P(t / 128);
|
|
684
684
|
E(e, ct & t);
|
|
685
|
-
},
|
|
686
|
-
const n =
|
|
687
|
-
for (n && (t = -t), E(e, (t >
|
|
688
|
-
E(e, (t > ct ?
|
|
689
|
-
},
|
|
690
|
-
if (t.length <
|
|
691
|
-
const n =
|
|
685
|
+
}, En = (e, t) => {
|
|
686
|
+
const n = Us(t);
|
|
687
|
+
for (n && (t = -t), E(e, (t > on ? x : 0) | (n ? J : 0) | on & t), t = P(t / 64); t > 0; )
|
|
688
|
+
E(e, (t > ct ? x : 0) | ct & t), t = P(t / 128);
|
|
689
|
+
}, ln = new Uint8Array(3e4), vo = ln.length / 3, xo = (e, t) => {
|
|
690
|
+
if (t.length < vo) {
|
|
691
|
+
const n = jt.encodeInto(t, ln).written || 0;
|
|
692
692
|
m(e, n);
|
|
693
693
|
for (let s = 0; s < n; s++)
|
|
694
|
-
E(e,
|
|
694
|
+
E(e, ln[s]);
|
|
695
695
|
} else
|
|
696
|
-
L(e,
|
|
697
|
-
},
|
|
696
|
+
L(e, qi(t));
|
|
697
|
+
}, To = (e, t) => {
|
|
698
698
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
699
699
|
m(e, s);
|
|
700
700
|
for (let r = 0; r < s; r++)
|
|
@@ -703,37 +703,37 @@ const Qt = () => new Zt(), Co = (e) => {
|
|
|
703
703
|
/** @type {number} */
|
|
704
704
|
n.codePointAt(r)
|
|
705
705
|
);
|
|
706
|
-
}, lt =
|
|
707
|
-
|
|
706
|
+
}, lt = jt && /** @type {any} */
|
|
707
|
+
jt.encodeInto ? xo : To, Ue = (e, t) => {
|
|
708
708
|
const n = e.cbuf.length, s = e.cpos, r = Ms(n - s, t.length), i = t.length - r;
|
|
709
709
|
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(gt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
710
710
|
}, L = (e, t) => {
|
|
711
711
|
m(e, t.byteLength), Ue(e, t);
|
|
712
|
-
},
|
|
713
|
-
|
|
712
|
+
}, Cn = (e, t) => {
|
|
713
|
+
Io(e, t);
|
|
714
714
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
715
715
|
return e.cpos += t, n;
|
|
716
|
-
}, Mo = (e, t) =>
|
|
716
|
+
}, Mo = (e, t) => Cn(e, 4).setFloat32(0, t, !1), Uo = (e, t) => Cn(e, 8).setFloat64(0, t, !1), Oo = (e, t) => (
|
|
717
717
|
/** @type {any} */
|
|
718
|
-
|
|
719
|
-
),
|
|
718
|
+
Cn(e, 8).setBigInt64(0, t, !1)
|
|
719
|
+
), ts = new DataView(new ArrayBuffer(4)), Ro = (e) => (ts.setFloat32(0, e), ts.getFloat32(0) === e), Xt = (e, t) => {
|
|
720
720
|
switch (typeof t) {
|
|
721
721
|
case "string":
|
|
722
722
|
E(e, 119), lt(e, t);
|
|
723
723
|
break;
|
|
724
724
|
case "number":
|
|
725
|
-
|
|
725
|
+
po(t) && pe(t) <= go ? (E(e, 125), En(e, t)) : Ro(t) ? (E(e, 124), Mo(e, t)) : (E(e, 123), Uo(e, t));
|
|
726
726
|
break;
|
|
727
727
|
case "bigint":
|
|
728
|
-
E(e, 122),
|
|
728
|
+
E(e, 122), Oo(e, t);
|
|
729
729
|
break;
|
|
730
730
|
case "object":
|
|
731
731
|
if (t === null)
|
|
732
732
|
E(e, 126);
|
|
733
|
-
else if (
|
|
733
|
+
else if (Ki(t)) {
|
|
734
734
|
E(e, 117), m(e, t.length);
|
|
735
735
|
for (let n = 0; n < t.length; n++)
|
|
736
|
-
|
|
736
|
+
Xt(e, t[n]);
|
|
737
737
|
} else if (t instanceof Uint8Array)
|
|
738
738
|
E(e, 116), L(e, t);
|
|
739
739
|
else {
|
|
@@ -742,7 +742,7 @@ Ht.encodeInto ? Io : vo, Ue = (e, t) => {
|
|
|
742
742
|
m(e, n.length);
|
|
743
743
|
for (let s = 0; s < n.length; s++) {
|
|
744
744
|
const r = n[s];
|
|
745
|
-
lt(e, r),
|
|
745
|
+
lt(e, r), Xt(e, t[r]);
|
|
746
746
|
}
|
|
747
747
|
}
|
|
748
748
|
break;
|
|
@@ -753,7 +753,7 @@ Ht.encodeInto ? Io : vo, Ue = (e, t) => {
|
|
|
753
753
|
E(e, 127);
|
|
754
754
|
}
|
|
755
755
|
};
|
|
756
|
-
class
|
|
756
|
+
class es extends te {
|
|
757
757
|
/**
|
|
758
758
|
* @param {function(Encoder, T):void} writer
|
|
759
759
|
*/
|
|
@@ -767,46 +767,46 @@ class ts extends Zt {
|
|
|
767
767
|
this.s === t ? this.count++ : (this.count > 0 && m(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
768
768
|
}
|
|
769
769
|
}
|
|
770
|
-
const
|
|
771
|
-
e.count > 0 && (
|
|
770
|
+
const ns = (e) => {
|
|
771
|
+
e.count > 0 && (En(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && m(e.encoder, e.count - 2));
|
|
772
772
|
};
|
|
773
|
-
class
|
|
773
|
+
class me {
|
|
774
774
|
constructor() {
|
|
775
|
-
this.encoder = new
|
|
775
|
+
this.encoder = new te(), this.s = 0, this.count = 0;
|
|
776
776
|
}
|
|
777
777
|
/**
|
|
778
778
|
* @param {number} v
|
|
779
779
|
*/
|
|
780
780
|
write(t) {
|
|
781
|
-
this.s === t ? this.count++ : (
|
|
781
|
+
this.s === t ? this.count++ : (ns(this), this.count = 1, this.s = t);
|
|
782
782
|
}
|
|
783
783
|
toUint8Array() {
|
|
784
|
-
return
|
|
784
|
+
return ns(this), N(this.encoder);
|
|
785
785
|
}
|
|
786
786
|
}
|
|
787
|
-
const
|
|
787
|
+
const ss = (e) => {
|
|
788
788
|
if (e.count > 0) {
|
|
789
789
|
const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
|
|
790
|
-
|
|
790
|
+
En(e.encoder, t), e.count > 1 && m(e.encoder, e.count - 2);
|
|
791
791
|
}
|
|
792
792
|
};
|
|
793
|
-
class
|
|
793
|
+
class Ke {
|
|
794
794
|
constructor() {
|
|
795
|
-
this.encoder = new
|
|
795
|
+
this.encoder = new te(), this.s = 0, this.count = 0, this.diff = 0;
|
|
796
796
|
}
|
|
797
797
|
/**
|
|
798
798
|
* @param {number} v
|
|
799
799
|
*/
|
|
800
800
|
write(t) {
|
|
801
|
-
this.diff === t - this.s ? (this.s = t, this.count++) : (
|
|
801
|
+
this.diff === t - this.s ? (this.s = t, this.count++) : (ss(this), this.count = 1, this.diff = t - this.s, this.s = t);
|
|
802
802
|
}
|
|
803
803
|
toUint8Array() {
|
|
804
|
-
return
|
|
804
|
+
return ss(this), N(this.encoder);
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
class
|
|
807
|
+
class $o {
|
|
808
808
|
constructor() {
|
|
809
|
-
this.sarr = [], this.s = "", this.lensE = new
|
|
809
|
+
this.sarr = [], this.s = "", this.lensE = new me();
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* @param {string} string
|
|
@@ -815,20 +815,20 @@ class Oo {
|
|
|
815
815
|
this.s += t, this.s.length > 19 && (this.sarr.push(this.s), this.s = ""), this.lensE.write(t.length);
|
|
816
816
|
}
|
|
817
817
|
toUint8Array() {
|
|
818
|
-
const t = new
|
|
819
|
-
return this.sarr.push(this.s), this.s = "", lt(t, this.sarr.join("")), Ue(t, this.lensE.toUint8Array()),
|
|
818
|
+
const t = new te();
|
|
819
|
+
return this.sarr.push(this.s), this.s = "", lt(t, this.sarr.join("")), Ue(t, this.lensE.toUint8Array()), N(t);
|
|
820
820
|
}
|
|
821
821
|
}
|
|
822
|
-
const
|
|
822
|
+
const No = crypto.getRandomValues.bind(crypto), Vs = () => No(new Uint32Array(1))[0], Bo = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Vo = () => Bo.replace(
|
|
823
823
|
/[018]/g,
|
|
824
824
|
/** @param {number} c */
|
|
825
|
-
(e) => (e ^
|
|
826
|
-
),
|
|
825
|
+
(e) => (e ^ Vs() & 15 >> e / 4).toString(16)
|
|
826
|
+
), _e = Date.now, xt = (e) => (
|
|
827
827
|
/** @type {Promise<T>} */
|
|
828
828
|
new Promise(e)
|
|
829
829
|
);
|
|
830
830
|
Promise.all.bind(Promise);
|
|
831
|
-
class
|
|
831
|
+
class Fo {
|
|
832
832
|
/**
|
|
833
833
|
* @param {L} left
|
|
834
834
|
* @param {R} right
|
|
@@ -837,9 +837,9 @@ class Bo {
|
|
|
837
837
|
this.left = t, this.right = n;
|
|
838
838
|
}
|
|
839
839
|
}
|
|
840
|
-
const X = (e, t) => new
|
|
840
|
+
const X = (e, t) => new Fo(e, t);
|
|
841
841
|
typeof DOMParser < "u" && new DOMParser();
|
|
842
|
-
const
|
|
842
|
+
const Ho = (e) => Hi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Fs = q(), Hs = q(), jo = q(), zo = q(), Ko = q(), js = q(), Yo = q(), zs = q(), Xo = q(), Jo = (e) => {
|
|
843
843
|
const t = [];
|
|
844
844
|
let n = 0;
|
|
845
845
|
for (; n < e.length; n++) {
|
|
@@ -847,26 +847,26 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
847
847
|
s.constructor === String || s.constructor === Number || s.constructor === Object && t.push(JSON.stringify(s));
|
|
848
848
|
}
|
|
849
849
|
return t;
|
|
850
|
-
},
|
|
851
|
-
[
|
|
852
|
-
[
|
|
853
|
-
[
|
|
854
|
-
[
|
|
855
|
-
[
|
|
856
|
-
[
|
|
857
|
-
[
|
|
858
|
-
[
|
|
850
|
+
}, Wo = {
|
|
851
|
+
[Fs]: X("font-weight", "bold"),
|
|
852
|
+
[Hs]: X("font-weight", "normal"),
|
|
853
|
+
[jo]: X("color", "blue"),
|
|
854
|
+
[Ko]: X("color", "green"),
|
|
855
|
+
[zo]: X("color", "grey"),
|
|
856
|
+
[js]: X("color", "red"),
|
|
857
|
+
[Yo]: X("color", "purple"),
|
|
858
|
+
[zs]: X("color", "orange"),
|
|
859
859
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
860
|
-
[
|
|
861
|
-
},
|
|
860
|
+
[Xo]: X("color", "black")
|
|
861
|
+
}, Po = (e) => {
|
|
862
862
|
const t = [], n = [], s = B();
|
|
863
863
|
let r = [], i = 0;
|
|
864
864
|
for (; i < e.length; i++) {
|
|
865
|
-
const o = e[i], c =
|
|
865
|
+
const o = e[i], c = Wo[o];
|
|
866
866
|
if (c !== void 0)
|
|
867
867
|
s.set(c.left, c.right);
|
|
868
868
|
else if (o.constructor === String || o.constructor === Number) {
|
|
869
|
-
const l =
|
|
869
|
+
const l = Ho(s);
|
|
870
870
|
i > 0 || l.length > 0 ? (t.push("%c" + o), n.push(l)) : t.push(o);
|
|
871
871
|
} else
|
|
872
872
|
break;
|
|
@@ -876,9 +876,9 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
876
876
|
o instanceof Symbol || r.push(o);
|
|
877
877
|
}
|
|
878
878
|
return r;
|
|
879
|
-
},
|
|
880
|
-
console.log(...
|
|
881
|
-
},
|
|
879
|
+
}, Go = fo ? Po : Jo, qo = (...e) => {
|
|
880
|
+
console.log(...Go(e)), Zo.forEach((t) => t.print(e));
|
|
881
|
+
}, Zo = It(), Ks = (e) => ({
|
|
882
882
|
/**
|
|
883
883
|
* @return {IterableIterator<T>}
|
|
884
884
|
*/
|
|
@@ -887,17 +887,17 @@ const Vo = (e) => Vi(e, (t, n) => `${n}:${t};`).join(""), q = Symbol, Bs = q(),
|
|
|
887
887
|
},
|
|
888
888
|
// @ts-ignore
|
|
889
889
|
next: e
|
|
890
|
-
}),
|
|
890
|
+
}), Qo = (e, t) => Ks(() => {
|
|
891
891
|
let n;
|
|
892
892
|
do
|
|
893
893
|
n = e.next();
|
|
894
894
|
while (!n.done && !t(n.value));
|
|
895
895
|
return n;
|
|
896
|
-
}),
|
|
896
|
+
}), Ye = (e, t) => Ks(() => {
|
|
897
897
|
const { done: n, value: s } = e.next();
|
|
898
898
|
return { done: n, value: n ? void 0 : t(s) };
|
|
899
899
|
});
|
|
900
|
-
class
|
|
900
|
+
class An {
|
|
901
901
|
/**
|
|
902
902
|
* @param {number} clock
|
|
903
903
|
* @param {number} len
|
|
@@ -906,24 +906,24 @@ class Cn {
|
|
|
906
906
|
this.clock = t, this.len = n;
|
|
907
907
|
}
|
|
908
908
|
}
|
|
909
|
-
class
|
|
909
|
+
class ne {
|
|
910
910
|
constructor() {
|
|
911
911
|
this.clients = /* @__PURE__ */ new Map();
|
|
912
912
|
}
|
|
913
913
|
}
|
|
914
|
-
const
|
|
914
|
+
const Ys = (e, t, n) => t.clients.forEach((s, r) => {
|
|
915
915
|
const i = (
|
|
916
916
|
/** @type {Array<GC|Item>} */
|
|
917
917
|
e.doc.store.clients.get(r)
|
|
918
918
|
);
|
|
919
919
|
for (let o = 0; o < s.length; o++) {
|
|
920
920
|
const c = s[o];
|
|
921
|
-
|
|
921
|
+
ir(e, i, c.clock, c.len, n);
|
|
922
922
|
}
|
|
923
|
-
}),
|
|
923
|
+
}), tc = (e, t) => {
|
|
924
924
|
let n = 0, s = e.length - 1;
|
|
925
925
|
for (; n <= s; ) {
|
|
926
|
-
const r =
|
|
926
|
+
const r = P((n + s) / 2), i = e[r], o = i.clock;
|
|
927
927
|
if (o <= t) {
|
|
928
928
|
if (t < o + i.len)
|
|
929
929
|
return r;
|
|
@@ -932,10 +932,10 @@ const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
932
932
|
s = r - 1;
|
|
933
933
|
}
|
|
934
934
|
return null;
|
|
935
|
-
},
|
|
935
|
+
}, Xs = (e, t) => {
|
|
936
936
|
const n = e.clients.get(t.client);
|
|
937
|
-
return n !== void 0 &&
|
|
938
|
-
},
|
|
937
|
+
return n !== void 0 && tc(n, t.clock) !== null;
|
|
938
|
+
}, Ln = (e) => {
|
|
939
939
|
e.clients.forEach((t) => {
|
|
940
940
|
t.sort((r, i) => r.clock - i.clock);
|
|
941
941
|
let n, s;
|
|
@@ -945,25 +945,25 @@ const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
945
945
|
}
|
|
946
946
|
t.length = s;
|
|
947
947
|
});
|
|
948
|
-
},
|
|
949
|
-
const t = new
|
|
948
|
+
}, ec = (e) => {
|
|
949
|
+
const t = new ne();
|
|
950
950
|
for (let n = 0; n < e.length; n++)
|
|
951
951
|
e[n].clients.forEach((s, r) => {
|
|
952
952
|
if (!t.clients.has(r)) {
|
|
953
953
|
const i = s.slice();
|
|
954
954
|
for (let o = n + 1; o < e.length; o++)
|
|
955
|
-
|
|
955
|
+
zi(i, e[o].clients.get(r) || []);
|
|
956
956
|
t.clients.set(r, i);
|
|
957
957
|
}
|
|
958
958
|
});
|
|
959
|
-
return
|
|
960
|
-
},
|
|
959
|
+
return Ln(t), t;
|
|
960
|
+
}, ke = (e, t, n, s) => {
|
|
961
961
|
rt(e.clients, t, () => (
|
|
962
962
|
/** @type {Array<DeleteItem>} */
|
|
963
963
|
[]
|
|
964
|
-
)).push(new
|
|
965
|
-
},
|
|
966
|
-
const t =
|
|
964
|
+
)).push(new An(n, s));
|
|
965
|
+
}, nc = () => new ne(), sc = (e) => {
|
|
966
|
+
const t = nc();
|
|
967
967
|
return e.clients.forEach((n, s) => {
|
|
968
968
|
const r = [];
|
|
969
969
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -974,12 +974,12 @@ const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
974
974
|
if (i + 1 < n.length)
|
|
975
975
|
for (let a = n[i + 1]; i + 1 < n.length && a.deleted; a = n[++i + 1])
|
|
976
976
|
l += a.length;
|
|
977
|
-
r.push(new
|
|
977
|
+
r.push(new An(c, l));
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
980
|
r.length > 0 && t.clients.set(s, r);
|
|
981
981
|
}), t;
|
|
982
|
-
},
|
|
982
|
+
}, Ot = (e, t) => {
|
|
983
983
|
m(e.restEncoder, t.clients.size), nt(t.clients.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
984
984
|
e.resetDsCurVal(), m(e.restEncoder, n);
|
|
985
985
|
const r = s.length;
|
|
@@ -989,8 +989,8 @@ const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
989
989
|
e.writeDsClock(o.clock), e.writeDsLen(o.len);
|
|
990
990
|
}
|
|
991
991
|
});
|
|
992
|
-
},
|
|
993
|
-
const t = new
|
|
992
|
+
}, In = (e) => {
|
|
993
|
+
const t = new ne(), n = w(e.restDecoder);
|
|
994
994
|
for (let s = 0; s < n; s++) {
|
|
995
995
|
e.resetDsCurVal();
|
|
996
996
|
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
@@ -1000,43 +1000,43 @@ const zs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1000
1000
|
[]
|
|
1001
1001
|
));
|
|
1002
1002
|
for (let c = 0; c < i; c++)
|
|
1003
|
-
o.push(new
|
|
1003
|
+
o.push(new An(e.readDsClock(), e.readDsLen()));
|
|
1004
1004
|
}
|
|
1005
1005
|
}
|
|
1006
1006
|
return t;
|
|
1007
|
-
},
|
|
1008
|
-
const s = new
|
|
1007
|
+
}, rs = (e, t, n) => {
|
|
1008
|
+
const s = new ne(), r = w(e.restDecoder);
|
|
1009
1009
|
for (let i = 0; i < r; i++) {
|
|
1010
1010
|
e.resetDsCurVal();
|
|
1011
1011
|
const o = w(e.restDecoder), c = w(e.restDecoder), l = n.clients.get(o) || [], a = C(n, o);
|
|
1012
1012
|
for (let h = 0; h < c; h++) {
|
|
1013
1013
|
const d = e.readDsClock(), u = d + e.readDsLen();
|
|
1014
1014
|
if (d < a) {
|
|
1015
|
-
a < u &&
|
|
1015
|
+
a < u && ke(s, o, a, u - a);
|
|
1016
1016
|
let f = z(l, d), g = l[f];
|
|
1017
|
-
for (!g.deleted && g.id.clock < d && (l.splice(f + 1, 0,
|
|
1018
|
-
g.deleted || (u < g.id.clock + g.length && l.splice(f, 0,
|
|
1017
|
+
for (!g.deleted && g.id.clock < d && (l.splice(f + 1, 0, ve(t, g, d - g.id.clock)), f++); f < l.length && (g = l[f++], g.id.clock < u); )
|
|
1018
|
+
g.deleted || (u < g.id.clock + g.length && l.splice(f, 0, ve(t, g, u - g.id.clock)), g.delete(t));
|
|
1019
1019
|
} else
|
|
1020
|
-
|
|
1020
|
+
ke(s, o, d, u - d);
|
|
1021
1021
|
}
|
|
1022
1022
|
}
|
|
1023
1023
|
if (s.clients.size > 0) {
|
|
1024
1024
|
const i = new at();
|
|
1025
|
-
return m(i.restEncoder, 0),
|
|
1025
|
+
return m(i.restEncoder, 0), Ot(i, s), i.toUint8Array();
|
|
1026
1026
|
}
|
|
1027
1027
|
return null;
|
|
1028
|
-
},
|
|
1029
|
-
class wt extends
|
|
1028
|
+
}, Js = Vs;
|
|
1029
|
+
class wt extends bn {
|
|
1030
1030
|
/**
|
|
1031
1031
|
* @param {DocOpts} opts configuration
|
|
1032
1032
|
*/
|
|
1033
|
-
constructor({ guid: t =
|
|
1034
|
-
super(), this.gc = s, this.gcFilter = r, this.clientID =
|
|
1033
|
+
constructor({ guid: t = Vo(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
1034
|
+
super(), this.gc = s, this.gcFilter = r, this.clientID = Js(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new sr(), this._transaction = null, this._transactionCleanups = [], this.subdocs = /* @__PURE__ */ new Set(), this._item = null, this.shouldLoad = c, this.autoLoad = o, this.meta = i, this.isLoaded = !1, this.isSynced = !1, this.whenLoaded = xt((a) => {
|
|
1035
1035
|
this.on("load", () => {
|
|
1036
1036
|
this.isLoaded = !0, a(this);
|
|
1037
1037
|
});
|
|
1038
1038
|
});
|
|
1039
|
-
const l = () =>
|
|
1039
|
+
const l = () => xt((a) => {
|
|
1040
1040
|
const h = (d) => {
|
|
1041
1041
|
(d === void 0 || d === !0) && (this.off("sync", h), a());
|
|
1042
1042
|
};
|
|
@@ -1152,7 +1152,7 @@ class wt extends yn {
|
|
|
1152
1152
|
* @public
|
|
1153
1153
|
*/
|
|
1154
1154
|
getText(t = "") {
|
|
1155
|
-
return this.get(t,
|
|
1155
|
+
return this.get(t, Mt);
|
|
1156
1156
|
}
|
|
1157
1157
|
/**
|
|
1158
1158
|
* @template T
|
|
@@ -1227,7 +1227,7 @@ class wt extends yn {
|
|
|
1227
1227
|
super.off(t, n);
|
|
1228
1228
|
}
|
|
1229
1229
|
}
|
|
1230
|
-
class
|
|
1230
|
+
class Ws {
|
|
1231
1231
|
/**
|
|
1232
1232
|
* @param {decoding.Decoder} decoder
|
|
1233
1233
|
*/
|
|
@@ -1249,7 +1249,7 @@ class Xs {
|
|
|
1249
1249
|
return w(this.restDecoder);
|
|
1250
1250
|
}
|
|
1251
1251
|
}
|
|
1252
|
-
class
|
|
1252
|
+
class Ps extends Ws {
|
|
1253
1253
|
/**
|
|
1254
1254
|
* @return {ID}
|
|
1255
1255
|
*/
|
|
@@ -1305,13 +1305,13 @@ class Js extends Xs {
|
|
|
1305
1305
|
* @return {any}
|
|
1306
1306
|
*/
|
|
1307
1307
|
readAny() {
|
|
1308
|
-
return
|
|
1308
|
+
return Yt(this.restDecoder);
|
|
1309
1309
|
}
|
|
1310
1310
|
/**
|
|
1311
1311
|
* @return {Uint8Array}
|
|
1312
1312
|
*/
|
|
1313
1313
|
readBuf() {
|
|
1314
|
-
return
|
|
1314
|
+
return Ao(I(this.restDecoder));
|
|
1315
1315
|
}
|
|
1316
1316
|
/**
|
|
1317
1317
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1328,7 +1328,7 @@ class Js extends Xs {
|
|
|
1328
1328
|
return et(this.restDecoder);
|
|
1329
1329
|
}
|
|
1330
1330
|
}
|
|
1331
|
-
class
|
|
1331
|
+
class rc {
|
|
1332
1332
|
/**
|
|
1333
1333
|
* @param {decoding.Decoder} decoder
|
|
1334
1334
|
*/
|
|
@@ -1352,12 +1352,12 @@ class nc {
|
|
|
1352
1352
|
return this.dsCurrVal += t, t;
|
|
1353
1353
|
}
|
|
1354
1354
|
}
|
|
1355
|
-
class
|
|
1355
|
+
class Tt extends rc {
|
|
1356
1356
|
/**
|
|
1357
1357
|
* @param {decoding.Decoder} decoder
|
|
1358
1358
|
*/
|
|
1359
1359
|
constructor(t) {
|
|
1360
|
-
super(t), this.keys = [], w(t), this.keyClockDecoder = new
|
|
1360
|
+
super(t), this.keys = [], w(t), this.keyClockDecoder = new ze(I(t)), this.clientDecoder = new we(I(t)), this.leftClockDecoder = new ze(I(t)), this.rightClockDecoder = new ze(I(t)), this.infoDecoder = new Qn(I(t), vt), this.stringDecoder = new Eo(I(t)), this.parentInfoDecoder = new Qn(I(t), vt), this.typeRefDecoder = new we(I(t)), this.lenDecoder = new we(I(t));
|
|
1361
1361
|
}
|
|
1362
1362
|
/**
|
|
1363
1363
|
* @return {ID}
|
|
@@ -1417,7 +1417,7 @@ class xt extends nc {
|
|
|
1417
1417
|
* @return {any}
|
|
1418
1418
|
*/
|
|
1419
1419
|
readAny() {
|
|
1420
|
-
return
|
|
1420
|
+
return Yt(this.restDecoder);
|
|
1421
1421
|
}
|
|
1422
1422
|
/**
|
|
1423
1423
|
* @return {Uint8Array}
|
|
@@ -1433,7 +1433,7 @@ class xt extends nc {
|
|
|
1433
1433
|
* @return {any}
|
|
1434
1434
|
*/
|
|
1435
1435
|
readJSON() {
|
|
1436
|
-
return
|
|
1436
|
+
return Yt(this.restDecoder);
|
|
1437
1437
|
}
|
|
1438
1438
|
/**
|
|
1439
1439
|
* @return {string}
|
|
@@ -1448,12 +1448,12 @@ class xt extends nc {
|
|
|
1448
1448
|
}
|
|
1449
1449
|
}
|
|
1450
1450
|
}
|
|
1451
|
-
class
|
|
1451
|
+
class Gs {
|
|
1452
1452
|
constructor() {
|
|
1453
|
-
this.restEncoder =
|
|
1453
|
+
this.restEncoder = ee();
|
|
1454
1454
|
}
|
|
1455
1455
|
toUint8Array() {
|
|
1456
|
-
return
|
|
1456
|
+
return N(this.restEncoder);
|
|
1457
1457
|
}
|
|
1458
1458
|
resetDsCurVal() {
|
|
1459
1459
|
}
|
|
@@ -1470,7 +1470,7 @@ class Ps {
|
|
|
1470
1470
|
m(this.restEncoder, t);
|
|
1471
1471
|
}
|
|
1472
1472
|
}
|
|
1473
|
-
class
|
|
1473
|
+
class se extends Gs {
|
|
1474
1474
|
/**
|
|
1475
1475
|
* @param {ID} id
|
|
1476
1476
|
*/
|
|
@@ -1494,7 +1494,7 @@ class ee extends Ps {
|
|
|
1494
1494
|
* @param {number} info An unsigned 8-bit integer
|
|
1495
1495
|
*/
|
|
1496
1496
|
writeInfo(t) {
|
|
1497
|
-
|
|
1497
|
+
cn(this.restEncoder, t);
|
|
1498
1498
|
}
|
|
1499
1499
|
/**
|
|
1500
1500
|
* @param {string} s
|
|
@@ -1526,7 +1526,7 @@ class ee extends Ps {
|
|
|
1526
1526
|
* @param {any} any
|
|
1527
1527
|
*/
|
|
1528
1528
|
writeAny(t) {
|
|
1529
|
-
|
|
1529
|
+
Xt(this.restEncoder, t);
|
|
1530
1530
|
}
|
|
1531
1531
|
/**
|
|
1532
1532
|
* @param {Uint8Array} buf
|
|
@@ -1547,12 +1547,12 @@ class ee extends Ps {
|
|
|
1547
1547
|
lt(this.restEncoder, t);
|
|
1548
1548
|
}
|
|
1549
1549
|
}
|
|
1550
|
-
class
|
|
1550
|
+
class qs {
|
|
1551
1551
|
constructor() {
|
|
1552
|
-
this.restEncoder =
|
|
1552
|
+
this.restEncoder = ee(), this.dsCurrVal = 0;
|
|
1553
1553
|
}
|
|
1554
1554
|
toUint8Array() {
|
|
1555
|
-
return
|
|
1555
|
+
return N(this.restEncoder);
|
|
1556
1556
|
}
|
|
1557
1557
|
resetDsCurVal() {
|
|
1558
1558
|
this.dsCurrVal = 0;
|
|
@@ -1571,13 +1571,13 @@ class Ws {
|
|
|
1571
1571
|
t === 0 && j(), m(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
1572
1572
|
}
|
|
1573
1573
|
}
|
|
1574
|
-
class at extends
|
|
1574
|
+
class at extends qs {
|
|
1575
1575
|
constructor() {
|
|
1576
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new
|
|
1576
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Ke(), this.clientEncoder = new me(), this.leftClockEncoder = new Ke(), this.rightClockEncoder = new Ke(), this.infoEncoder = new es(cn), this.stringEncoder = new $o(), this.parentInfoEncoder = new es(cn), this.typeRefEncoder = new me(), this.lenEncoder = new me();
|
|
1577
1577
|
}
|
|
1578
1578
|
toUint8Array() {
|
|
1579
|
-
const t =
|
|
1580
|
-
return m(t, 0), L(t, this.keyClockEncoder.toUint8Array()), L(t, this.clientEncoder.toUint8Array()), L(t, this.leftClockEncoder.toUint8Array()), L(t, this.rightClockEncoder.toUint8Array()), L(t,
|
|
1579
|
+
const t = ee();
|
|
1580
|
+
return m(t, 0), L(t, this.keyClockEncoder.toUint8Array()), L(t, this.clientEncoder.toUint8Array()), L(t, this.leftClockEncoder.toUint8Array()), L(t, this.rightClockEncoder.toUint8Array()), L(t, N(this.infoEncoder)), L(t, this.stringEncoder.toUint8Array()), L(t, N(this.parentInfoEncoder)), L(t, this.typeRefEncoder.toUint8Array()), L(t, this.lenEncoder.toUint8Array()), Ue(t, N(this.restEncoder)), N(t);
|
|
1581
1581
|
}
|
|
1582
1582
|
/**
|
|
1583
1583
|
* @param {ID} id
|
|
@@ -1633,7 +1633,7 @@ class at extends Ws {
|
|
|
1633
1633
|
* @param {any} any
|
|
1634
1634
|
*/
|
|
1635
1635
|
writeAny(t) {
|
|
1636
|
-
|
|
1636
|
+
Xt(this.restEncoder, t);
|
|
1637
1637
|
}
|
|
1638
1638
|
/**
|
|
1639
1639
|
* @param {Uint8Array} buf
|
|
@@ -1649,7 +1649,7 @@ class at extends Ws {
|
|
|
1649
1649
|
* @param {any} embed
|
|
1650
1650
|
*/
|
|
1651
1651
|
writeJSON(t) {
|
|
1652
|
-
|
|
1652
|
+
Xt(this.restEncoder, t);
|
|
1653
1653
|
}
|
|
1654
1654
|
/**
|
|
1655
1655
|
* Property keys are often reused. For example, in y-prosemirror the key `bold` might
|
|
@@ -1664,7 +1664,7 @@ class at extends Ws {
|
|
|
1664
1664
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
1665
1665
|
}
|
|
1666
1666
|
}
|
|
1667
|
-
const
|
|
1667
|
+
const ic = (e, t, n, s) => {
|
|
1668
1668
|
s = gt(s, t[0].id.clock);
|
|
1669
1669
|
const r = z(t, s);
|
|
1670
1670
|
m(e.restEncoder, t.length - r), e.writeClient(n), m(e.restEncoder, s);
|
|
@@ -1672,14 +1672,14 @@ const sc = (e, t, n, s) => {
|
|
|
1672
1672
|
i.write(e, s - i.id.clock);
|
|
1673
1673
|
for (let o = r + 1; o < t.length; o++)
|
|
1674
1674
|
t[o].write(e, 0);
|
|
1675
|
-
},
|
|
1675
|
+
}, vn = (e, t, n) => {
|
|
1676
1676
|
const s = /* @__PURE__ */ new Map();
|
|
1677
1677
|
n.forEach((r, i) => {
|
|
1678
1678
|
C(t, i) > r && s.set(i, r);
|
|
1679
|
-
}),
|
|
1679
|
+
}), Oe(t).forEach((r, i) => {
|
|
1680
1680
|
n.has(i) || s.set(i, 0);
|
|
1681
1681
|
}), m(e.restEncoder, s.size), nt(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
1682
|
-
|
|
1682
|
+
ic(
|
|
1683
1683
|
e,
|
|
1684
1684
|
/** @type {Array<GC|Item>} */
|
|
1685
1685
|
t.clients.get(r),
|
|
@@ -1687,7 +1687,7 @@ const sc = (e, t, n, s) => {
|
|
|
1687
1687
|
i
|
|
1688
1688
|
);
|
|
1689
1689
|
});
|
|
1690
|
-
},
|
|
1690
|
+
}, oc = (e, t) => {
|
|
1691
1691
|
const n = B(), s = w(e.restDecoder);
|
|
1692
1692
|
for (let r = 0; r < s; r++) {
|
|
1693
1693
|
const i = w(e.restDecoder), o = new Array(i), c = e.readClient();
|
|
@@ -1695,23 +1695,23 @@ const sc = (e, t, n, s) => {
|
|
|
1695
1695
|
n.set(c, { i: 0, refs: o });
|
|
1696
1696
|
for (let a = 0; a < i; a++) {
|
|
1697
1697
|
const h = e.readInfo();
|
|
1698
|
-
switch (
|
|
1698
|
+
switch (Te & h) {
|
|
1699
1699
|
case 0: {
|
|
1700
1700
|
const d = e.readLen();
|
|
1701
|
-
o[a] = new
|
|
1701
|
+
o[a] = new M(b(c, l), d), l += d;
|
|
1702
1702
|
break;
|
|
1703
1703
|
}
|
|
1704
1704
|
case 10: {
|
|
1705
1705
|
const d = w(e.restDecoder);
|
|
1706
|
-
o[a] = new
|
|
1706
|
+
o[a] = new U(b(c, l), d), l += d;
|
|
1707
1707
|
break;
|
|
1708
1708
|
}
|
|
1709
1709
|
default: {
|
|
1710
|
-
const d = (h & (J |
|
|
1710
|
+
const d = (h & (J | x)) === 0, u = new k(
|
|
1711
1711
|
b(c, l),
|
|
1712
1712
|
null,
|
|
1713
1713
|
// leftd
|
|
1714
|
-
(h &
|
|
1714
|
+
(h & x) === x ? e.readLeftID() : null,
|
|
1715
1715
|
// origin
|
|
1716
1716
|
null,
|
|
1717
1717
|
// right
|
|
@@ -1719,9 +1719,9 @@ const sc = (e, t, n, s) => {
|
|
|
1719
1719
|
// right origin
|
|
1720
1720
|
d ? e.readParentInfo() ? t.get(e.readString()) : e.readLeftID() : null,
|
|
1721
1721
|
// parent
|
|
1722
|
-
d && (h &
|
|
1722
|
+
d && (h & Kt) === Kt ? e.readString() : null,
|
|
1723
1723
|
// parentSub
|
|
1724
|
-
|
|
1724
|
+
Er(e, h)
|
|
1725
1725
|
// item content
|
|
1726
1726
|
);
|
|
1727
1727
|
o[a] = u, l += u.length;
|
|
@@ -1730,7 +1730,7 @@ const sc = (e, t, n, s) => {
|
|
|
1730
1730
|
}
|
|
1731
1731
|
}
|
|
1732
1732
|
return n;
|
|
1733
|
-
},
|
|
1733
|
+
}, cc = (e, t, n) => {
|
|
1734
1734
|
const s = [];
|
|
1735
1735
|
let r = nt(n.keys()).sort((f, g) => f - g);
|
|
1736
1736
|
if (r.length === 0)
|
|
@@ -1753,7 +1753,7 @@ const sc = (e, t, n, s) => {
|
|
|
1753
1753
|
let o = i();
|
|
1754
1754
|
if (o === null)
|
|
1755
1755
|
return null;
|
|
1756
|
-
const c = new
|
|
1756
|
+
const c = new sr(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
|
|
1757
1757
|
const p = l.get(f);
|
|
1758
1758
|
(p == null || p > g) && l.set(f, g);
|
|
1759
1759
|
};
|
|
@@ -1772,7 +1772,7 @@ const sc = (e, t, n, s) => {
|
|
|
1772
1772
|
s.length = 0;
|
|
1773
1773
|
};
|
|
1774
1774
|
for (; ; ) {
|
|
1775
|
-
if (h.constructor !==
|
|
1775
|
+
if (h.constructor !== U) {
|
|
1776
1776
|
const g = rt(d, h.id.client, () => C(t, h.id.client)) - h.id.clock;
|
|
1777
1777
|
if (g < 0)
|
|
1778
1778
|
s.push(h), a(h.id.client, h.id.clock - 1), u();
|
|
@@ -1813,13 +1813,13 @@ const sc = (e, t, n, s) => {
|
|
|
1813
1813
|
}
|
|
1814
1814
|
if (c.clients.size > 0) {
|
|
1815
1815
|
const f = new at();
|
|
1816
|
-
return
|
|
1816
|
+
return vn(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
1817
1817
|
}
|
|
1818
1818
|
return null;
|
|
1819
|
-
},
|
|
1819
|
+
}, lc = (e, t) => vn(e, t.doc.store, t.beforeState), ac = (e, t, n, s = new Tt(e)) => S(t, (r) => {
|
|
1820
1820
|
r.local = !1;
|
|
1821
1821
|
let i = !1;
|
|
1822
|
-
const o = r.doc, c = o.store, l =
|
|
1822
|
+
const o = r.doc, c = o.store, l = oc(s, o), a = cc(r, c, l), h = c.pendingStructs;
|
|
1823
1823
|
if (h) {
|
|
1824
1824
|
for (const [u, f] of h.missing)
|
|
1825
1825
|
if (f < C(c, u)) {
|
|
@@ -1831,16 +1831,16 @@ const sc = (e, t, n, s) => {
|
|
|
1831
1831
|
const g = h.missing.get(u);
|
|
1832
1832
|
(g == null || g > f) && h.missing.set(u, f);
|
|
1833
1833
|
}
|
|
1834
|
-
h.update =
|
|
1834
|
+
h.update = De([h.update, a.update]);
|
|
1835
1835
|
}
|
|
1836
1836
|
} else
|
|
1837
1837
|
c.pendingStructs = a;
|
|
1838
|
-
const d =
|
|
1838
|
+
const d = rs(s, r, c);
|
|
1839
1839
|
if (c.pendingDs) {
|
|
1840
|
-
const u = new
|
|
1840
|
+
const u = new Tt(pt(c.pendingDs));
|
|
1841
1841
|
w(u.restDecoder);
|
|
1842
|
-
const f =
|
|
1843
|
-
d && f ? c.pendingDs =
|
|
1842
|
+
const f = rs(u, r, c);
|
|
1843
|
+
d && f ? c.pendingDs = De([d, f]) : c.pendingDs = d || f;
|
|
1844
1844
|
} else
|
|
1845
1845
|
c.pendingDs = d;
|
|
1846
1846
|
if (i) {
|
|
@@ -1848,43 +1848,43 @@ const sc = (e, t, n, s) => {
|
|
|
1848
1848
|
/** @type {{update: Uint8Array}} */
|
|
1849
1849
|
c.pendingStructs.update
|
|
1850
1850
|
);
|
|
1851
|
-
c.pendingStructs = null,
|
|
1851
|
+
c.pendingStructs = null, Zs(r.doc, u);
|
|
1852
1852
|
}
|
|
1853
|
-
}, n, !1),
|
|
1853
|
+
}, n, !1), Zs = (e, t, n, s = Tt) => {
|
|
1854
1854
|
const r = pt(t);
|
|
1855
|
-
|
|
1856
|
-
},
|
|
1857
|
-
|
|
1858
|
-
},
|
|
1859
|
-
const s =
|
|
1860
|
-
|
|
1855
|
+
ac(r, e, n, new s(r));
|
|
1856
|
+
}, Qs = (e, t, n) => Zs(e, t, n, Ps), hc = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
1857
|
+
vn(e, t.store, n), Ot(e, sc(t.store));
|
|
1858
|
+
}, uc = (e, t = new Uint8Array([0]), n = new at()) => {
|
|
1859
|
+
const s = tr(t);
|
|
1860
|
+
hc(n, e, s);
|
|
1861
1861
|
const r = [n.toUint8Array()];
|
|
1862
|
-
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(
|
|
1863
|
-
if (n.constructor ===
|
|
1864
|
-
return
|
|
1862
|
+
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Ac(e.store.pendingStructs.update, t)), r.length > 1) {
|
|
1863
|
+
if (n.constructor === se)
|
|
1864
|
+
return Ec(r.map((i, o) => o === 0 ? i : Ic(i)));
|
|
1865
1865
|
if (n.constructor === at)
|
|
1866
|
-
return
|
|
1866
|
+
return De(r);
|
|
1867
1867
|
}
|
|
1868
1868
|
return r[0];
|
|
1869
|
-
},
|
|
1869
|
+
}, xn = (e, t) => uc(e, t, new se()), dc = (e) => {
|
|
1870
1870
|
const t = /* @__PURE__ */ new Map(), n = w(e.restDecoder);
|
|
1871
1871
|
for (let s = 0; s < n; s++) {
|
|
1872
1872
|
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
1873
1873
|
t.set(r, i);
|
|
1874
1874
|
}
|
|
1875
1875
|
return t;
|
|
1876
|
-
},
|
|
1876
|
+
}, tr = (e) => dc(new Ws(pt(e))), er = (e, t) => (m(e.restEncoder, t.size), nt(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
1877
1877
|
m(e.restEncoder, n), m(e.restEncoder, s);
|
|
1878
|
-
}), e),
|
|
1879
|
-
class
|
|
1878
|
+
}), e), fc = (e, t) => er(e, Oe(t.store)), gc = (e, t = new qs()) => (e instanceof Map ? er(t, e) : fc(t, e), t.toUint8Array()), pc = (e) => gc(e, new Gs());
|
|
1879
|
+
class wc {
|
|
1880
1880
|
constructor() {
|
|
1881
1881
|
this.l = [];
|
|
1882
1882
|
}
|
|
1883
1883
|
}
|
|
1884
|
-
const
|
|
1884
|
+
const is = () => new wc(), os = (e, t) => e.l.push(t), cs = (e, t) => {
|
|
1885
1885
|
const n = e.l, s = n.length;
|
|
1886
1886
|
e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1887
|
-
},
|
|
1887
|
+
}, nr = (e, t, n) => Sn(e.l, [t, n]);
|
|
1888
1888
|
class Dt {
|
|
1889
1889
|
/**
|
|
1890
1890
|
* @param {number} client client id
|
|
@@ -1894,24 +1894,24 @@ class Dt {
|
|
|
1894
1894
|
this.client = t, this.clock = n;
|
|
1895
1895
|
}
|
|
1896
1896
|
}
|
|
1897
|
-
const
|
|
1897
|
+
const he = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, b = (e, t) => new Dt(e, t), mc = (e) => {
|
|
1898
1898
|
for (const [t, n] of e.doc.share.entries())
|
|
1899
1899
|
if (n === e)
|
|
1900
1900
|
return t;
|
|
1901
1901
|
throw j();
|
|
1902
|
-
}, St = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !
|
|
1903
|
-
const n = rt(e.meta,
|
|
1902
|
+
}, St = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !Xs(t.ds, e.id), an = (e, t) => {
|
|
1903
|
+
const n = rt(e.meta, an, It), s = e.doc.store;
|
|
1904
1904
|
n.has(t) || (t.sv.forEach((r, i) => {
|
|
1905
1905
|
r < C(s, i) && st(e, b(i, r));
|
|
1906
|
-
}),
|
|
1906
|
+
}), Ys(e, t.ds, (r) => {
|
|
1907
1907
|
}), n.add(t));
|
|
1908
1908
|
};
|
|
1909
|
-
class
|
|
1909
|
+
class sr {
|
|
1910
1910
|
constructor() {
|
|
1911
1911
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
1912
1912
|
}
|
|
1913
1913
|
}
|
|
1914
|
-
const
|
|
1914
|
+
const Oe = (e) => {
|
|
1915
1915
|
const t = /* @__PURE__ */ new Map();
|
|
1916
1916
|
return e.clients.forEach((n, s) => {
|
|
1917
1917
|
const r = n[n.length - 1];
|
|
@@ -1923,7 +1923,7 @@ const Te = (e) => {
|
|
|
1923
1923
|
return 0;
|
|
1924
1924
|
const s = n[n.length - 1];
|
|
1925
1925
|
return s.id.clock + s.length;
|
|
1926
|
-
},
|
|
1926
|
+
}, rr = (e, t) => {
|
|
1927
1927
|
let n = e.clients.get(t.id.client);
|
|
1928
1928
|
if (n === void 0)
|
|
1929
1929
|
n = [], e.clients.set(t.id.client, n);
|
|
@@ -1937,7 +1937,7 @@ const Te = (e) => {
|
|
|
1937
1937
|
let n = 0, s = e.length - 1, r = e[s], i = r.id.clock;
|
|
1938
1938
|
if (i === t)
|
|
1939
1939
|
return s;
|
|
1940
|
-
let o =
|
|
1940
|
+
let o = P(t / (i + r.length - 1) * s);
|
|
1941
1941
|
for (; n <= s; ) {
|
|
1942
1942
|
if (r = e[o], i = r.id.clock, i <= t) {
|
|
1943
1943
|
if (t < i + r.length)
|
|
@@ -1945,56 +1945,56 @@ const Te = (e) => {
|
|
|
1945
1945
|
n = o + 1;
|
|
1946
1946
|
} else
|
|
1947
1947
|
s = o - 1;
|
|
1948
|
-
o =
|
|
1948
|
+
o = P((n + s) / 2);
|
|
1949
1949
|
}
|
|
1950
1950
|
throw j();
|
|
1951
|
-
},
|
|
1951
|
+
}, yc = (e, t) => {
|
|
1952
1952
|
const n = e.clients.get(t.client);
|
|
1953
1953
|
return n[z(n, t.clock)];
|
|
1954
|
-
},
|
|
1954
|
+
}, Xe = (
|
|
1955
1955
|
/** @type {function(StructStore,ID):Item} */
|
|
1956
|
-
|
|
1957
|
-
),
|
|
1956
|
+
yc
|
|
1957
|
+
), hn = (e, t, n) => {
|
|
1958
1958
|
const s = z(t, n), r = t[s];
|
|
1959
|
-
return r.id.clock < n && r instanceof k ? (t.splice(s + 1, 0,
|
|
1959
|
+
return r.id.clock < n && r instanceof k ? (t.splice(s + 1, 0, ve(e, r, n - r.id.clock)), s + 1) : s;
|
|
1960
1960
|
}, st = (e, t) => {
|
|
1961
1961
|
const n = (
|
|
1962
1962
|
/** @type {Array<Item>} */
|
|
1963
1963
|
e.doc.store.clients.get(t.client)
|
|
1964
1964
|
);
|
|
1965
|
-
return n[
|
|
1966
|
-
},
|
|
1965
|
+
return n[hn(e, n, t.clock)];
|
|
1966
|
+
}, ls = (e, t, n) => {
|
|
1967
1967
|
const s = t.clients.get(n.client), r = z(s, n.clock), i = s[r];
|
|
1968
|
-
return n.clock !== i.id.clock + i.length - 1 && i.constructor !==
|
|
1969
|
-
},
|
|
1968
|
+
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== M && s.splice(r + 1, 0, ve(e, i, n.clock - i.id.clock + 1)), i;
|
|
1969
|
+
}, bc = (e, t, n) => {
|
|
1970
1970
|
const s = (
|
|
1971
1971
|
/** @type {Array<GC|Item>} */
|
|
1972
1972
|
e.clients.get(t.id.client)
|
|
1973
1973
|
);
|
|
1974
1974
|
s[z(s, t.id.clock)] = n;
|
|
1975
|
-
},
|
|
1975
|
+
}, ir = (e, t, n, s, r) => {
|
|
1976
1976
|
if (s === 0)
|
|
1977
1977
|
return;
|
|
1978
1978
|
const i = n + s;
|
|
1979
|
-
let o =
|
|
1979
|
+
let o = hn(e, t, n), c;
|
|
1980
1980
|
do
|
|
1981
|
-
c = t[o++], i < c.id.clock + c.length &&
|
|
1981
|
+
c = t[o++], i < c.id.clock + c.length && hn(e, t, i), r(c);
|
|
1982
1982
|
while (o < t.length && t[o].id.clock < i);
|
|
1983
1983
|
};
|
|
1984
|
-
class
|
|
1984
|
+
class Sc {
|
|
1985
1985
|
/**
|
|
1986
1986
|
* @param {Doc} doc
|
|
1987
1987
|
* @param {any} origin
|
|
1988
1988
|
* @param {boolean} local
|
|
1989
1989
|
*/
|
|
1990
1990
|
constructor(t, n, s) {
|
|
1991
|
-
this.doc = t, this.deleteSet = new
|
|
1991
|
+
this.doc = t, this.deleteSet = new ne(), this.beforeState = Oe(t.store), this.afterState = /* @__PURE__ */ new Map(), this.changed = /* @__PURE__ */ new Map(), this.changedParentTypes = /* @__PURE__ */ new Map(), this._mergeStructs = [], this.origin = n, this.meta = /* @__PURE__ */ new Map(), this.local = s, this.subdocsAdded = /* @__PURE__ */ new Set(), this.subdocsRemoved = /* @__PURE__ */ new Set(), this.subdocsLoaded = /* @__PURE__ */ new Set(), this._needFormattingCleanup = !1;
|
|
1992
1992
|
}
|
|
1993
1993
|
}
|
|
1994
|
-
const
|
|
1994
|
+
const as = (e, t) => t.deleteSet.clients.size === 0 && !ji(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (Ln(t.deleteSet), lc(e, t), Ot(e, t.deleteSet), !0), hs = (e, t, n) => {
|
|
1995
1995
|
const s = t._item;
|
|
1996
1996
|
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && rt(e.changed, t, It).add(n);
|
|
1997
|
-
},
|
|
1997
|
+
}, ye = (e, t) => {
|
|
1998
1998
|
let n = e[t], s = e[t - 1], r = t;
|
|
1999
1999
|
for (; r > 0; n = s, s = e[--r - 1]) {
|
|
2000
2000
|
if (s.deleted === n.deleted && s.constructor === n.constructor && s.mergeWith(n)) {
|
|
@@ -2010,7 +2010,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2010
2010
|
}
|
|
2011
2011
|
const i = t - r;
|
|
2012
2012
|
return i && e.splice(t + 1 - i, i), i;
|
|
2013
|
-
},
|
|
2013
|
+
}, _c = (e, t, n) => {
|
|
2014
2014
|
for (const [s, r] of e.clients.entries()) {
|
|
2015
2015
|
const i = (
|
|
2016
2016
|
/** @type {Array<GC|Item>} */
|
|
@@ -2026,7 +2026,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2026
2026
|
}
|
|
2027
2027
|
}
|
|
2028
2028
|
}
|
|
2029
|
-
},
|
|
2029
|
+
}, kc = (e, t) => {
|
|
2030
2030
|
e.clients.forEach((n, s) => {
|
|
2031
2031
|
const r = (
|
|
2032
2032
|
/** @type {Array<GC|Item>} */
|
|
@@ -2035,14 +2035,14 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2035
2035
|
for (let i = n.length - 1; i >= 0; i--) {
|
|
2036
2036
|
const o = n[i], c = Ms(r.length - 1, 1 + z(r, o.clock + o.len - 1));
|
|
2037
2037
|
for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[l])
|
|
2038
|
-
l -= 1 +
|
|
2038
|
+
l -= 1 + ye(r, l);
|
|
2039
2039
|
}
|
|
2040
2040
|
});
|
|
2041
|
-
},
|
|
2041
|
+
}, or = (e, t) => {
|
|
2042
2042
|
if (t < e.length) {
|
|
2043
2043
|
const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
|
|
2044
2044
|
try {
|
|
2045
|
-
|
|
2045
|
+
Ln(i), n.afterState = Oe(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
|
|
2046
2046
|
const c = [];
|
|
2047
2047
|
n.changed.forEach(
|
|
2048
2048
|
(l, a) => c.push(() => {
|
|
@@ -2054,11 +2054,11 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2054
2054
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
2055
2055
|
), l.forEach((h) => {
|
|
2056
2056
|
h.currentTarget = a, h._path = null;
|
|
2057
|
-
}), l.sort((h, d) => h.path.length - d.path.length),
|
|
2057
|
+
}), l.sort((h, d) => h.path.length - d.path.length), nr(a._dEH, l, n));
|
|
2058
2058
|
});
|
|
2059
|
-
}), c.push(() => s.emit("afterTransaction", [n, s])),
|
|
2059
|
+
}), c.push(() => s.emit("afterTransaction", [n, s])), Sn(c, []), n._needFormattingCleanup && jc(n);
|
|
2060
2060
|
} finally {
|
|
2061
|
-
s.gc &&
|
|
2061
|
+
s.gc && _c(i, r, s.gcFilter), kc(i, r), n.afterState.forEach((h, d) => {
|
|
2062
2062
|
const u = n.beforeState.get(d) || 0;
|
|
2063
2063
|
if (u !== h) {
|
|
2064
2064
|
const f = (
|
|
@@ -2066,7 +2066,7 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2066
2066
|
r.clients.get(d)
|
|
2067
2067
|
), g = gt(z(f, u), 1);
|
|
2068
2068
|
for (let p = f.length - 1; p >= g; )
|
|
2069
|
-
p -= 1 +
|
|
2069
|
+
p -= 1 + ye(f, p);
|
|
2070
2070
|
}
|
|
2071
2071
|
});
|
|
2072
2072
|
for (let h = o.length - 1; h >= 0; h--) {
|
|
@@ -2074,37 +2074,37 @@ const ls = (e, t) => t.deleteSet.clients.size === 0 && !Fi(t.afterState, (n, s)
|
|
|
2074
2074
|
/** @type {Array<GC|Item>} */
|
|
2075
2075
|
r.clients.get(d)
|
|
2076
2076
|
), g = z(f, u);
|
|
2077
|
-
g + 1 < f.length &&
|
|
2077
|
+
g + 1 < f.length && ye(f, g + 1) > 1 || g > 0 && ye(f, g);
|
|
2078
2078
|
}
|
|
2079
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
2080
|
-
const h = new
|
|
2081
|
-
|
|
2079
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (qo(zs, Fs, "[yjs] ", Hs, js, "Changed the client-id because another client seems to be using it."), s.clientID = Js()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
2080
|
+
const h = new se();
|
|
2081
|
+
as(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
|
|
2082
2082
|
}
|
|
2083
2083
|
if (s._observers.has("updateV2")) {
|
|
2084
2084
|
const h = new at();
|
|
2085
|
-
|
|
2085
|
+
as(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
|
|
2086
2086
|
}
|
|
2087
2087
|
const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
|
|
2088
2088
|
(c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
|
|
2089
2089
|
h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
|
|
2090
|
-
}), 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])) :
|
|
2090
|
+
}), 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])) : or(e, t + 1);
|
|
2091
2091
|
}
|
|
2092
2092
|
}
|
|
2093
2093
|
}, S = (e, t, n = null, s = !0) => {
|
|
2094
2094
|
const r = e._transactionCleanups;
|
|
2095
2095
|
let i = !1, o = null;
|
|
2096
|
-
e._transaction === null && (i = !0, e._transaction = new
|
|
2096
|
+
e._transaction === null && (i = !0, e._transaction = new Sc(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
2097
2097
|
try {
|
|
2098
2098
|
o = t(e._transaction);
|
|
2099
2099
|
} finally {
|
|
2100
2100
|
if (i) {
|
|
2101
2101
|
const c = e._transaction === r[0];
|
|
2102
|
-
e._transaction = null, c &&
|
|
2102
|
+
e._transaction = null, c && or(r, 0);
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
return o;
|
|
2106
2106
|
};
|
|
2107
|
-
function*
|
|
2107
|
+
function* Dc(e) {
|
|
2108
2108
|
const t = w(e.restDecoder);
|
|
2109
2109
|
for (let n = 0; n < t; n++) {
|
|
2110
2110
|
const s = w(e.restDecoder), r = e.readClient();
|
|
@@ -2113,13 +2113,13 @@ function* _c(e) {
|
|
|
2113
2113
|
const c = e.readInfo();
|
|
2114
2114
|
if (c === 10) {
|
|
2115
2115
|
const l = w(e.restDecoder);
|
|
2116
|
-
yield new
|
|
2117
|
-
} else if (
|
|
2118
|
-
const l = (c & (J |
|
|
2116
|
+
yield new U(b(r, i), l), i += l;
|
|
2117
|
+
} else if (Te & c) {
|
|
2118
|
+
const l = (c & (J | x)) === 0, a = new k(
|
|
2119
2119
|
b(r, i),
|
|
2120
2120
|
null,
|
|
2121
2121
|
// left
|
|
2122
|
-
(c &
|
|
2122
|
+
(c & x) === x ? e.readLeftID() : null,
|
|
2123
2123
|
// origin
|
|
2124
2124
|
null,
|
|
2125
2125
|
// right
|
|
@@ -2128,26 +2128,26 @@ function* _c(e) {
|
|
|
2128
2128
|
// @ts-ignore Force writing a string here.
|
|
2129
2129
|
l ? e.readParentInfo() ? e.readString() : e.readLeftID() : null,
|
|
2130
2130
|
// parent
|
|
2131
|
-
l && (c &
|
|
2131
|
+
l && (c & Kt) === Kt ? e.readString() : null,
|
|
2132
2132
|
// parentSub
|
|
2133
|
-
|
|
2133
|
+
Er(e, c)
|
|
2134
2134
|
// item content
|
|
2135
2135
|
);
|
|
2136
2136
|
yield a, i += a.length;
|
|
2137
2137
|
} else {
|
|
2138
2138
|
const l = e.readLen();
|
|
2139
|
-
yield new
|
|
2139
|
+
yield new M(b(r, i), l), i += l;
|
|
2140
2140
|
}
|
|
2141
2141
|
}
|
|
2142
2142
|
}
|
|
2143
2143
|
}
|
|
2144
|
-
class
|
|
2144
|
+
class Tn {
|
|
2145
2145
|
/**
|
|
2146
2146
|
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
|
|
2147
2147
|
* @param {boolean} filterSkips
|
|
2148
2148
|
*/
|
|
2149
2149
|
constructor(t, n) {
|
|
2150
|
-
this.gen =
|
|
2150
|
+
this.gen = Dc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
2151
2151
|
}
|
|
2152
2152
|
/**
|
|
2153
2153
|
* @return {Item | GC | Skip |null}
|
|
@@ -2155,11 +2155,11 @@ class Mn {
|
|
|
2155
2155
|
next() {
|
|
2156
2156
|
do
|
|
2157
2157
|
this.curr = this.gen.next().value || null;
|
|
2158
|
-
while (this.filterSkips && this.curr !== null && this.curr.constructor ===
|
|
2158
|
+
while (this.filterSkips && this.curr !== null && this.curr.constructor === U);
|
|
2159
2159
|
return this.curr;
|
|
2160
2160
|
}
|
|
2161
2161
|
}
|
|
2162
|
-
class
|
|
2162
|
+
class Mn {
|
|
2163
2163
|
/**
|
|
2164
2164
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2165
2165
|
*/
|
|
@@ -2167,13 +2167,13 @@ class xn {
|
|
|
2167
2167
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
2168
2168
|
}
|
|
2169
2169
|
}
|
|
2170
|
-
const
|
|
2171
|
-
if (e.constructor ===
|
|
2170
|
+
const Ec = (e) => De(e, Ps, se), Cc = (e, t) => {
|
|
2171
|
+
if (e.constructor === M) {
|
|
2172
2172
|
const { client: n, clock: s } = e.id;
|
|
2173
|
-
return new
|
|
2174
|
-
} else if (e.constructor ===
|
|
2173
|
+
return new M(b(n, s + t), e.length - t);
|
|
2174
|
+
} else if (e.constructor === U) {
|
|
2175
2175
|
const { client: n, clock: s } = e.id;
|
|
2176
|
-
return new
|
|
2176
|
+
return new U(b(n, s + t), e.length - t);
|
|
2177
2177
|
} else {
|
|
2178
2178
|
const n = (
|
|
2179
2179
|
/** @type {Item} */
|
|
@@ -2190,18 +2190,18 @@ const kc = (e) => _e(e, Js, ee), Dc = (e, t) => {
|
|
|
2190
2190
|
n.content.splice(t)
|
|
2191
2191
|
);
|
|
2192
2192
|
}
|
|
2193
|
-
},
|
|
2193
|
+
}, De = (e, t = Tt, n = at) => {
|
|
2194
2194
|
if (e.length === 1)
|
|
2195
2195
|
return e[0];
|
|
2196
2196
|
const s = e.map((h) => new t(pt(h)));
|
|
2197
|
-
let r = s.map((h) => new
|
|
2198
|
-
const o = new n(), c = new
|
|
2197
|
+
let r = s.map((h) => new Tn(h, !0)), i = null;
|
|
2198
|
+
const o = new n(), c = new Mn(o);
|
|
2199
2199
|
for (; r = r.filter((u) => u.curr !== null), r.sort(
|
|
2200
2200
|
/** @type {function(any,any):number} */
|
|
2201
2201
|
(u, f) => {
|
|
2202
2202
|
if (u.curr.id.client === f.curr.id.client) {
|
|
2203
2203
|
const g = u.curr.id.clock - f.curr.id.clock;
|
|
2204
|
-
return g === 0 ? u.curr.constructor === f.curr.constructor ? 0 : u.curr.constructor ===
|
|
2204
|
+
return g === 0 ? u.curr.constructor === f.curr.constructor ? 0 : u.curr.constructor === U ? 1 : -1 : g;
|
|
2205
2205
|
} else
|
|
2206
2206
|
return f.curr.id.client - u.curr.id.client;
|
|
2207
2207
|
}
|
|
@@ -2224,16 +2224,16 @@ const kc = (e) => _e(e, Js, ee), Dc = (e, t) => {
|
|
|
2224
2224
|
if (d !== i.struct.id.client)
|
|
2225
2225
|
Q(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next();
|
|
2226
2226
|
else if (i.struct.id.clock + i.struct.length < u.id.clock)
|
|
2227
|
-
if (i.struct.constructor ===
|
|
2227
|
+
if (i.struct.constructor === U)
|
|
2228
2228
|
i.struct.length = u.id.clock + u.length - i.struct.id.clock;
|
|
2229
2229
|
else {
|
|
2230
2230
|
Q(c, i.struct, i.offset);
|
|
2231
2231
|
const g = u.id.clock - i.struct.id.clock - i.struct.length;
|
|
2232
|
-
i = { struct: new
|
|
2232
|
+
i = { struct: new U(b(d, i.struct.id.clock + i.struct.length), g), offset: 0 };
|
|
2233
2233
|
}
|
|
2234
2234
|
else {
|
|
2235
2235
|
const g = i.struct.id.clock + i.struct.length - u.id.clock;
|
|
2236
|
-
g > 0 && (i.struct.constructor ===
|
|
2236
|
+
g > 0 && (i.struct.constructor === U ? i.struct.length -= g : u = Cc(u, g)), i.struct.mergeWith(
|
|
2237
2237
|
/** @type {any} */
|
|
2238
2238
|
u
|
|
2239
2239
|
) || (Q(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next());
|
|
@@ -2243,17 +2243,17 @@ const kc = (e) => _e(e, Js, ee), Dc = (e, t) => {
|
|
|
2243
2243
|
/** @type {Item | GC} */
|
|
2244
2244
|
h.curr
|
|
2245
2245
|
), offset: 0 }, h.next();
|
|
2246
|
-
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !==
|
|
2246
|
+
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== U; u = h.next())
|
|
2247
2247
|
Q(c, i.struct, i.offset), i = { struct: u, offset: 0 };
|
|
2248
2248
|
}
|
|
2249
2249
|
i !== null && (Q(c, i.struct, i.offset), i = null), Un(c);
|
|
2250
|
-
const l = s.map((h) =>
|
|
2251
|
-
return
|
|
2252
|
-
},
|
|
2253
|
-
const r =
|
|
2250
|
+
const l = s.map((h) => In(h)), a = ec(l);
|
|
2251
|
+
return Ot(o, a), o.toUint8Array();
|
|
2252
|
+
}, Ac = (e, t, n = Tt, s = at) => {
|
|
2253
|
+
const r = tr(t), i = new s(), o = new Mn(i), c = new n(pt(e)), l = new Tn(c, !1);
|
|
2254
2254
|
for (; l.curr; ) {
|
|
2255
2255
|
const h = l.curr, d = h.id.client, u = r.get(d) || 0;
|
|
2256
|
-
if (l.curr.constructor ===
|
|
2256
|
+
if (l.curr.constructor === U) {
|
|
2257
2257
|
l.next();
|
|
2258
2258
|
continue;
|
|
2259
2259
|
}
|
|
@@ -2265,29 +2265,29 @@ const kc = (e) => _e(e, Js, ee), Dc = (e, t) => {
|
|
|
2265
2265
|
l.next();
|
|
2266
2266
|
}
|
|
2267
2267
|
Un(o);
|
|
2268
|
-
const a =
|
|
2269
|
-
return
|
|
2270
|
-
},
|
|
2271
|
-
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder:
|
|
2268
|
+
const a = In(c);
|
|
2269
|
+
return Ot(i, a), i.toUint8Array();
|
|
2270
|
+
}, cr = (e) => {
|
|
2271
|
+
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: N(e.encoder.restEncoder) }), e.encoder.restEncoder = ee(), e.written = 0);
|
|
2272
2272
|
}, Q = (e, t, n) => {
|
|
2273
|
-
e.written > 0 && e.currClient !== t.id.client &&
|
|
2273
|
+
e.written > 0 && e.currClient !== t.id.client && cr(e), e.written === 0 && (e.currClient = t.id.client, e.encoder.writeClient(t.id.client), m(e.encoder.restEncoder, t.id.clock + n)), t.write(e.encoder, n), e.written++;
|
|
2274
2274
|
}, Un = (e) => {
|
|
2275
|
-
|
|
2275
|
+
cr(e);
|
|
2276
2276
|
const t = e.encoder.restEncoder;
|
|
2277
2277
|
m(t, e.clientStructs.length);
|
|
2278
2278
|
for (let n = 0; n < e.clientStructs.length; n++) {
|
|
2279
2279
|
const s = e.clientStructs[n];
|
|
2280
2280
|
m(t, s.written), Ue(t, s.restEncoder);
|
|
2281
2281
|
}
|
|
2282
|
-
},
|
|
2283
|
-
const r = new n(pt(e)), i = new
|
|
2282
|
+
}, Lc = (e, t, n, s) => {
|
|
2283
|
+
const r = new n(pt(e)), i = new Tn(r, !1), o = new s(), c = new Mn(o);
|
|
2284
2284
|
for (let a = i.curr; a !== null; a = i.next())
|
|
2285
2285
|
Q(c, t(a), 0);
|
|
2286
2286
|
Un(c);
|
|
2287
|
-
const l =
|
|
2288
|
-
return
|
|
2289
|
-
},
|
|
2290
|
-
class
|
|
2287
|
+
const l = In(r);
|
|
2288
|
+
return Ot(o, l), o.toUint8Array();
|
|
2289
|
+
}, Ic = (e) => Lc(e, co, Tt, se), us = "You must not compute changes after the event-handler fired.";
|
|
2290
|
+
class Re {
|
|
2291
2291
|
/**
|
|
2292
2292
|
* @param {T} target The changed type.
|
|
2293
2293
|
* @param {Transaction} transaction
|
|
@@ -2309,7 +2309,7 @@ class Oe {
|
|
|
2309
2309
|
* type === event.target // => true
|
|
2310
2310
|
*/
|
|
2311
2311
|
get path() {
|
|
2312
|
-
return this._path || (this._path =
|
|
2312
|
+
return this._path || (this._path = vc(this.currentTarget, this.target));
|
|
2313
2313
|
}
|
|
2314
2314
|
/**
|
|
2315
2315
|
* Check if a struct is deleted by this event.
|
|
@@ -2320,7 +2320,7 @@ class Oe {
|
|
|
2320
2320
|
* @return {boolean}
|
|
2321
2321
|
*/
|
|
2322
2322
|
deletes(t) {
|
|
2323
|
-
return
|
|
2323
|
+
return Xs(this.transaction.deleteSet, t.id);
|
|
2324
2324
|
}
|
|
2325
2325
|
/**
|
|
2326
2326
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2328,7 +2328,7 @@ class Oe {
|
|
|
2328
2328
|
get keys() {
|
|
2329
2329
|
if (this._keys === null) {
|
|
2330
2330
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2331
|
-
throw G(
|
|
2331
|
+
throw G(us);
|
|
2332
2332
|
const t = /* @__PURE__ */ new Map(), n = this.target;
|
|
2333
2333
|
/** @type Set<string|null> */
|
|
2334
2334
|
this.transaction.changed.get(n).forEach((r) => {
|
|
@@ -2344,13 +2344,13 @@ class Oe {
|
|
|
2344
2344
|
l = l.left;
|
|
2345
2345
|
if (this.deletes(i))
|
|
2346
2346
|
if (l !== null && this.deletes(l))
|
|
2347
|
-
o = "delete", c =
|
|
2347
|
+
o = "delete", c = Fe(l.content.getContent());
|
|
2348
2348
|
else
|
|
2349
2349
|
return;
|
|
2350
2350
|
else
|
|
2351
|
-
l !== null && this.deletes(l) ? (o = "update", c =
|
|
2351
|
+
l !== null && this.deletes(l) ? (o = "update", c = Fe(l.content.getContent())) : (o = "add", c = void 0);
|
|
2352
2352
|
} else if (this.deletes(i))
|
|
2353
|
-
o = "delete", c =
|
|
2353
|
+
o = "delete", c = Fe(
|
|
2354
2354
|
/** @type {Item} */
|
|
2355
2355
|
i.content.getContent()
|
|
2356
2356
|
);
|
|
@@ -2396,7 +2396,7 @@ class Oe {
|
|
|
2396
2396
|
let t = this._changes;
|
|
2397
2397
|
if (t === null) {
|
|
2398
2398
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2399
|
-
throw G(
|
|
2399
|
+
throw G(us);
|
|
2400
2400
|
const n = this.target, s = It(), r = It(), i = [];
|
|
2401
2401
|
if (t = {
|
|
2402
2402
|
added: s,
|
|
@@ -2421,7 +2421,7 @@ class Oe {
|
|
|
2421
2421
|
);
|
|
2422
2422
|
}
|
|
2423
2423
|
}
|
|
2424
|
-
const
|
|
2424
|
+
const vc = (e, t) => {
|
|
2425
2425
|
const n = [];
|
|
2426
2426
|
for (; t._item !== null && t !== e; ) {
|
|
2427
2427
|
if (t._item.parentSub !== null)
|
|
@@ -2439,35 +2439,35 @@ const Lc = (e, t) => {
|
|
|
2439
2439
|
t._item.parent;
|
|
2440
2440
|
}
|
|
2441
2441
|
return n;
|
|
2442
|
-
},
|
|
2443
|
-
let
|
|
2444
|
-
class
|
|
2442
|
+
}, lr = 80;
|
|
2443
|
+
let On = 0;
|
|
2444
|
+
class xc {
|
|
2445
2445
|
/**
|
|
2446
2446
|
* @param {Item} p
|
|
2447
2447
|
* @param {number} index
|
|
2448
2448
|
*/
|
|
2449
2449
|
constructor(t, n) {
|
|
2450
|
-
t.marker = !0, this.p = t, this.index = n, this.timestamp =
|
|
2450
|
+
t.marker = !0, this.p = t, this.index = n, this.timestamp = On++;
|
|
2451
2451
|
}
|
|
2452
2452
|
}
|
|
2453
|
-
const
|
|
2454
|
-
e.timestamp =
|
|
2455
|
-
},
|
|
2456
|
-
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp =
|
|
2453
|
+
const Tc = (e) => {
|
|
2454
|
+
e.timestamp = On++;
|
|
2455
|
+
}, ar = (e, t, n) => {
|
|
2456
|
+
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = On++;
|
|
2457
2457
|
}, Mc = (e, t, n) => {
|
|
2458
|
-
if (e.length >=
|
|
2458
|
+
if (e.length >= lr) {
|
|
2459
2459
|
const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
2460
|
-
return
|
|
2460
|
+
return ar(s, t, n), s;
|
|
2461
2461
|
} else {
|
|
2462
|
-
const s = new
|
|
2462
|
+
const s = new xc(t, n);
|
|
2463
2463
|
return e.push(s), s;
|
|
2464
2464
|
}
|
|
2465
|
-
},
|
|
2465
|
+
}, $e = (e, t) => {
|
|
2466
2466
|
if (e._start === null || t === 0 || e._searchMarker === null)
|
|
2467
2467
|
return null;
|
|
2468
|
-
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) =>
|
|
2468
|
+
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => pe(t - i.index) < pe(t - o.index) ? i : o);
|
|
2469
2469
|
let s = e._start, r = 0;
|
|
2470
|
-
for (n !== null && (s = n.p, r = n.index,
|
|
2470
|
+
for (n !== null && (s = n.p, r = n.index, Tc(n)); s.right !== null && r < t; ) {
|
|
2471
2471
|
if (!s.deleted && s.countable) {
|
|
2472
2472
|
if (t < r + s.length)
|
|
2473
2473
|
break;
|
|
@@ -2479,9 +2479,9 @@ const vc = (e) => {
|
|
|
2479
2479
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2480
2480
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
2481
2481
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2482
|
-
return n !== null &&
|
|
2483
|
-
s.parent.length /
|
|
2484
|
-
},
|
|
2482
|
+
return n !== null && pe(n.index - r) < /** @type {YText|YArray<any>} */
|
|
2483
|
+
s.parent.length / lr ? (ar(n, s, r), n) : Mc(e._searchMarker, s, r);
|
|
2484
|
+
}, Jt = (e, t, n) => {
|
|
2485
2485
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
2486
2486
|
const r = e[s];
|
|
2487
2487
|
if (n > 0) {
|
|
@@ -2501,11 +2501,11 @@ const vc = (e) => {
|
|
|
2501
2501
|
for (; rt(r, e, () => []).push(n), e._item !== null; )
|
|
2502
2502
|
e = /** @type {AbstractType<any>} */
|
|
2503
2503
|
e._item.parent;
|
|
2504
|
-
|
|
2504
|
+
nr(s._eH, n, t);
|
|
2505
2505
|
};
|
|
2506
2506
|
class A {
|
|
2507
2507
|
constructor() {
|
|
2508
|
-
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH =
|
|
2508
|
+
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = is(), this._dEH = is(), this._searchMarker = null;
|
|
2509
2509
|
}
|
|
2510
2510
|
/**
|
|
2511
2511
|
* @return {AbstractType<any>|null}
|
|
@@ -2571,7 +2571,7 @@ class A {
|
|
|
2571
2571
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2572
2572
|
*/
|
|
2573
2573
|
observe(t) {
|
|
2574
|
-
|
|
2574
|
+
os(this._eH, t);
|
|
2575
2575
|
}
|
|
2576
2576
|
/**
|
|
2577
2577
|
* Observe all events that are created by this type and its children.
|
|
@@ -2579,7 +2579,7 @@ class A {
|
|
|
2579
2579
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2580
2580
|
*/
|
|
2581
2581
|
observeDeep(t) {
|
|
2582
|
-
|
|
2582
|
+
os(this._dEH, t);
|
|
2583
2583
|
}
|
|
2584
2584
|
/**
|
|
2585
2585
|
* Unregister an observer function.
|
|
@@ -2587,7 +2587,7 @@ class A {
|
|
|
2587
2587
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2588
2588
|
*/
|
|
2589
2589
|
unobserve(t) {
|
|
2590
|
-
|
|
2590
|
+
cs(this._eH, t);
|
|
2591
2591
|
}
|
|
2592
2592
|
/**
|
|
2593
2593
|
* Unregister an observer function.
|
|
@@ -2595,7 +2595,7 @@ class A {
|
|
|
2595
2595
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2596
2596
|
*/
|
|
2597
2597
|
unobserveDeep(t) {
|
|
2598
|
-
|
|
2598
|
+
cs(this._dEH, t);
|
|
2599
2599
|
}
|
|
2600
2600
|
/**
|
|
2601
2601
|
* @abstract
|
|
@@ -2604,7 +2604,7 @@ class A {
|
|
|
2604
2604
|
toJSON() {
|
|
2605
2605
|
}
|
|
2606
2606
|
}
|
|
2607
|
-
const
|
|
2607
|
+
const hr = (e, t, n) => {
|
|
2608
2608
|
t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
|
|
2609
2609
|
let s = n - t;
|
|
2610
2610
|
const r = [];
|
|
@@ -2623,7 +2623,7 @@ const lr = (e, t, n) => {
|
|
|
2623
2623
|
i = i.right;
|
|
2624
2624
|
}
|
|
2625
2625
|
return r;
|
|
2626
|
-
},
|
|
2626
|
+
}, ur = (e) => {
|
|
2627
2627
|
const t = [];
|
|
2628
2628
|
let n = e._start;
|
|
2629
2629
|
for (; n !== null; ) {
|
|
@@ -2635,7 +2635,7 @@ const lr = (e, t, n) => {
|
|
|
2635
2635
|
n = n.right;
|
|
2636
2636
|
}
|
|
2637
2637
|
return t;
|
|
2638
|
-
},
|
|
2638
|
+
}, Wt = (e, t) => {
|
|
2639
2639
|
let n = 0, s = e._start;
|
|
2640
2640
|
for (; s !== null; ) {
|
|
2641
2641
|
if (s.countable && !s.deleted) {
|
|
@@ -2645,12 +2645,12 @@ const lr = (e, t, n) => {
|
|
|
2645
2645
|
}
|
|
2646
2646
|
s = s.right;
|
|
2647
2647
|
}
|
|
2648
|
-
},
|
|
2648
|
+
}, dr = (e, t) => {
|
|
2649
2649
|
const n = [];
|
|
2650
|
-
return
|
|
2650
|
+
return Wt(e, (s, r) => {
|
|
2651
2651
|
n.push(t(s, r, e));
|
|
2652
2652
|
}), n;
|
|
2653
|
-
},
|
|
2653
|
+
}, Uc = (e) => {
|
|
2654
2654
|
let t = e._start, n = null, s = 0;
|
|
2655
2655
|
return {
|
|
2656
2656
|
[Symbol.iterator]() {
|
|
@@ -2674,8 +2674,8 @@ const lr = (e, t, n) => {
|
|
|
2674
2674
|
};
|
|
2675
2675
|
}
|
|
2676
2676
|
};
|
|
2677
|
-
},
|
|
2678
|
-
const n =
|
|
2677
|
+
}, fr = (e, t) => {
|
|
2678
|
+
const n = $e(e, t);
|
|
2679
2679
|
let s = e._start;
|
|
2680
2680
|
for (n !== null && (s = n.p, t -= n.index); s !== null; s = s.right)
|
|
2681
2681
|
if (!s.deleted && s.countable) {
|
|
@@ -2683,7 +2683,7 @@ const lr = (e, t, n) => {
|
|
|
2683
2683
|
return s.content.getContent()[t];
|
|
2684
2684
|
t -= s.length;
|
|
2685
2685
|
}
|
|
2686
|
-
},
|
|
2686
|
+
}, Ee = (e, t, n, s) => {
|
|
2687
2687
|
let r = n;
|
|
2688
2688
|
const i = e.doc, o = i.clientID, c = i.store, l = n === null ? t._start : n.right;
|
|
2689
2689
|
let a = [];
|
|
@@ -2706,13 +2706,13 @@ const lr = (e, t, n) => {
|
|
|
2706
2706
|
switch (h(), d.constructor) {
|
|
2707
2707
|
case Uint8Array:
|
|
2708
2708
|
case ArrayBuffer:
|
|
2709
|
-
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2709
|
+
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new re(new Uint8Array(
|
|
2710
2710
|
/** @type {Uint8Array} */
|
|
2711
2711
|
d
|
|
2712
2712
|
))), r.integrate(e, 0);
|
|
2713
2713
|
break;
|
|
2714
2714
|
case wt:
|
|
2715
|
-
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new
|
|
2715
|
+
r = new k(b(o, C(c, o)), r, r && r.lastId, l, l && l.id, t, null, new ie(
|
|
2716
2716
|
/** @type {Doc} */
|
|
2717
2717
|
d
|
|
2718
2718
|
)), r.integrate(e, 0);
|
|
@@ -2725,12 +2725,12 @@ const lr = (e, t, n) => {
|
|
|
2725
2725
|
}
|
|
2726
2726
|
}
|
|
2727
2727
|
}), h();
|
|
2728
|
-
},
|
|
2728
|
+
}, gr = () => G("Length exceeded!"), pr = (e, t, n, s) => {
|
|
2729
2729
|
if (n > t._length)
|
|
2730
|
-
throw
|
|
2730
|
+
throw gr();
|
|
2731
2731
|
if (n === 0)
|
|
2732
|
-
return t._searchMarker &&
|
|
2733
|
-
const r = n, i =
|
|
2732
|
+
return t._searchMarker && Jt(t._searchMarker, n, s.length), Ee(e, t, null, s);
|
|
2733
|
+
const r = n, i = $e(t, n);
|
|
2734
2734
|
let o = t._start;
|
|
2735
2735
|
for (i !== null && (o = i.p, n -= i.index, n === 0 && (o = o.prev, n += o && o.countable && !o.deleted ? o.length : 0)); o !== null; o = o.right)
|
|
2736
2736
|
if (!o.deleted && o.countable) {
|
|
@@ -2740,34 +2740,34 @@ const lr = (e, t, n) => {
|
|
|
2740
2740
|
}
|
|
2741
2741
|
n -= o.length;
|
|
2742
2742
|
}
|
|
2743
|
-
return t._searchMarker &&
|
|
2744
|
-
},
|
|
2743
|
+
return t._searchMarker && Jt(t._searchMarker, r, s.length), Ee(e, t, o, s);
|
|
2744
|
+
}, Oc = (e, t, n) => {
|
|
2745
2745
|
let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
|
|
2746
2746
|
if (r)
|
|
2747
2747
|
for (; r.right; )
|
|
2748
2748
|
r = r.right;
|
|
2749
|
-
return
|
|
2750
|
-
},
|
|
2749
|
+
return Ee(e, t, r, n);
|
|
2750
|
+
}, wr = (e, t, n, s) => {
|
|
2751
2751
|
if (s === 0)
|
|
2752
2752
|
return;
|
|
2753
|
-
const r = n, i = s, o =
|
|
2753
|
+
const r = n, i = s, o = $e(t, n);
|
|
2754
2754
|
let c = t._start;
|
|
2755
2755
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
2756
2756
|
!c.deleted && c.countable && (n < c.length && st(e, b(c.id.client, c.id.clock + n)), n -= c.length);
|
|
2757
2757
|
for (; s > 0 && c !== null; )
|
|
2758
2758
|
c.deleted || (s < c.length && st(e, b(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
|
|
2759
2759
|
if (s > 0)
|
|
2760
|
-
throw
|
|
2761
|
-
t._searchMarker &&
|
|
2760
|
+
throw gr();
|
|
2761
|
+
t._searchMarker && Jt(
|
|
2762
2762
|
t._searchMarker,
|
|
2763
2763
|
r,
|
|
2764
2764
|
-i + s
|
|
2765
2765
|
/* in case we remove the above exception */
|
|
2766
2766
|
);
|
|
2767
|
-
},
|
|
2767
|
+
}, Ce = (e, t, n) => {
|
|
2768
2768
|
const s = t._map.get(n);
|
|
2769
2769
|
s !== void 0 && s.delete(e);
|
|
2770
|
-
},
|
|
2770
|
+
}, Rn = (e, t, n, s) => {
|
|
2771
2771
|
const r = t._map.get(n) || null, i = e.doc, o = i.clientID;
|
|
2772
2772
|
let c;
|
|
2773
2773
|
if (s == null)
|
|
@@ -2782,13 +2782,13 @@ const lr = (e, t, n) => {
|
|
|
2782
2782
|
c = new dt([s]);
|
|
2783
2783
|
break;
|
|
2784
2784
|
case Uint8Array:
|
|
2785
|
-
c = new
|
|
2785
|
+
c = new re(
|
|
2786
2786
|
/** @type {Uint8Array} */
|
|
2787
2787
|
s
|
|
2788
2788
|
);
|
|
2789
2789
|
break;
|
|
2790
2790
|
case wt:
|
|
2791
|
-
c = new
|
|
2791
|
+
c = new ie(
|
|
2792
2792
|
/** @type {Doc} */
|
|
2793
2793
|
s
|
|
2794
2794
|
);
|
|
@@ -2800,18 +2800,18 @@ const lr = (e, t, n) => {
|
|
|
2800
2800
|
throw new Error("Unexpected content type");
|
|
2801
2801
|
}
|
|
2802
2802
|
new k(b(o, C(i.store, o)), r, r && r.lastId, null, null, t, n, c).integrate(e, 0);
|
|
2803
|
-
},
|
|
2803
|
+
}, $n = (e, t) => {
|
|
2804
2804
|
const n = e._map.get(t);
|
|
2805
2805
|
return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
|
|
2806
|
-
},
|
|
2806
|
+
}, mr = (e) => {
|
|
2807
2807
|
const t = {};
|
|
2808
2808
|
return e._map.forEach((n, s) => {
|
|
2809
2809
|
n.deleted || (t[s] = n.content.getContent()[n.length - 1]);
|
|
2810
2810
|
}), t;
|
|
2811
|
-
},
|
|
2811
|
+
}, yr = (e, t) => {
|
|
2812
2812
|
const n = e._map.get(t);
|
|
2813
2813
|
return n !== void 0 && !n.deleted;
|
|
2814
|
-
},
|
|
2814
|
+
}, Rc = (e, t) => {
|
|
2815
2815
|
const n = {};
|
|
2816
2816
|
return e._map.forEach((s, r) => {
|
|
2817
2817
|
let i = s;
|
|
@@ -2819,12 +2819,12 @@ const lr = (e, t, n) => {
|
|
|
2819
2819
|
i = i.left;
|
|
2820
2820
|
i !== null && St(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
|
|
2821
2821
|
}), n;
|
|
2822
|
-
},
|
|
2822
|
+
}, ue = (e) => Qo(
|
|
2823
2823
|
e.entries(),
|
|
2824
2824
|
/** @param {any} entry */
|
|
2825
2825
|
(t) => !t[1].deleted
|
|
2826
2826
|
);
|
|
2827
|
-
class
|
|
2827
|
+
class $c extends Re {
|
|
2828
2828
|
/**
|
|
2829
2829
|
* @param {YArray<T>} yarray The changed type
|
|
2830
2830
|
* @param {Transaction} transaction The transaction object
|
|
@@ -2892,7 +2892,7 @@ class Et extends A {
|
|
|
2892
2892
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2893
2893
|
*/
|
|
2894
2894
|
_callObserver(t, n) {
|
|
2895
|
-
super._callObserver(t, n), Ne(this, t, new
|
|
2895
|
+
super._callObserver(t, n), Ne(this, t, new $c(this, t));
|
|
2896
2896
|
}
|
|
2897
2897
|
/**
|
|
2898
2898
|
* Inserts new content at an index.
|
|
@@ -2912,7 +2912,7 @@ class Et extends A {
|
|
|
2912
2912
|
*/
|
|
2913
2913
|
insert(t, n) {
|
|
2914
2914
|
this.doc !== null ? S(this.doc, (s) => {
|
|
2915
|
-
|
|
2915
|
+
pr(
|
|
2916
2916
|
s,
|
|
2917
2917
|
this,
|
|
2918
2918
|
t,
|
|
@@ -2930,7 +2930,7 @@ class Et extends A {
|
|
|
2930
2930
|
*/
|
|
2931
2931
|
push(t) {
|
|
2932
2932
|
this.doc !== null ? S(this.doc, (n) => {
|
|
2933
|
-
|
|
2933
|
+
Oc(
|
|
2934
2934
|
n,
|
|
2935
2935
|
this,
|
|
2936
2936
|
/** @type {any} */
|
|
@@ -2954,7 +2954,7 @@ class Et extends A {
|
|
|
2954
2954
|
*/
|
|
2955
2955
|
delete(t, n = 1) {
|
|
2956
2956
|
this.doc !== null ? S(this.doc, (s) => {
|
|
2957
|
-
|
|
2957
|
+
wr(s, this, t, n);
|
|
2958
2958
|
}) : this._prelimContent.splice(t, n);
|
|
2959
2959
|
}
|
|
2960
2960
|
/**
|
|
@@ -2964,7 +2964,7 @@ class Et extends A {
|
|
|
2964
2964
|
* @return {T}
|
|
2965
2965
|
*/
|
|
2966
2966
|
get(t) {
|
|
2967
|
-
return
|
|
2967
|
+
return fr(this, t);
|
|
2968
2968
|
}
|
|
2969
2969
|
/**
|
|
2970
2970
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2972,7 +2972,7 @@ class Et extends A {
|
|
|
2972
2972
|
* @return {Array<T>}
|
|
2973
2973
|
*/
|
|
2974
2974
|
toArray() {
|
|
2975
|
-
return
|
|
2975
|
+
return ur(this);
|
|
2976
2976
|
}
|
|
2977
2977
|
/**
|
|
2978
2978
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -2982,7 +2982,7 @@ class Et extends A {
|
|
|
2982
2982
|
* @return {Array<T>}
|
|
2983
2983
|
*/
|
|
2984
2984
|
slice(t = 0, n = this.length) {
|
|
2985
|
-
return
|
|
2985
|
+
return hr(this, t, n);
|
|
2986
2986
|
}
|
|
2987
2987
|
/**
|
|
2988
2988
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3002,7 +3002,7 @@ class Et extends A {
|
|
|
3002
3002
|
* callback function
|
|
3003
3003
|
*/
|
|
3004
3004
|
map(t) {
|
|
3005
|
-
return
|
|
3005
|
+
return dr(
|
|
3006
3006
|
this,
|
|
3007
3007
|
/** @type {any} */
|
|
3008
3008
|
t
|
|
@@ -3014,23 +3014,23 @@ class Et extends A {
|
|
|
3014
3014
|
* @param {function(T,number,YArray<T>):void} f A function to execute on every element of this YArray.
|
|
3015
3015
|
*/
|
|
3016
3016
|
forEach(t) {
|
|
3017
|
-
|
|
3017
|
+
Wt(this, t);
|
|
3018
3018
|
}
|
|
3019
3019
|
/**
|
|
3020
3020
|
* @return {IterableIterator<T>}
|
|
3021
3021
|
*/
|
|
3022
3022
|
[Symbol.iterator]() {
|
|
3023
|
-
return
|
|
3023
|
+
return Uc(this);
|
|
3024
3024
|
}
|
|
3025
3025
|
/**
|
|
3026
3026
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3027
3027
|
*/
|
|
3028
3028
|
_write(t) {
|
|
3029
|
-
t.writeTypeRef(
|
|
3029
|
+
t.writeTypeRef(ol);
|
|
3030
3030
|
}
|
|
3031
3031
|
}
|
|
3032
|
-
const
|
|
3033
|
-
class
|
|
3032
|
+
const Nc = (e) => new Et();
|
|
3033
|
+
class Bc extends Re {
|
|
3034
3034
|
/**
|
|
3035
3035
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
3036
3036
|
* @param {Transaction} transaction
|
|
@@ -3088,7 +3088,7 @@ class ht extends A {
|
|
|
3088
3088
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3089
3089
|
*/
|
|
3090
3090
|
_callObserver(t, n) {
|
|
3091
|
-
Ne(this, t, new
|
|
3091
|
+
Ne(this, t, new Bc(this, t, n));
|
|
3092
3092
|
}
|
|
3093
3093
|
/**
|
|
3094
3094
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3110,7 +3110,7 @@ class ht extends A {
|
|
|
3110
3110
|
* @return {number}
|
|
3111
3111
|
*/
|
|
3112
3112
|
get size() {
|
|
3113
|
-
return [...
|
|
3113
|
+
return [...ue(this._map)].length;
|
|
3114
3114
|
}
|
|
3115
3115
|
/**
|
|
3116
3116
|
* Returns the keys for each element in the YMap Type.
|
|
@@ -3118,8 +3118,8 @@ class ht extends A {
|
|
|
3118
3118
|
* @return {IterableIterator<string>}
|
|
3119
3119
|
*/
|
|
3120
3120
|
keys() {
|
|
3121
|
-
return
|
|
3122
|
-
|
|
3121
|
+
return Ye(
|
|
3122
|
+
ue(this._map),
|
|
3123
3123
|
/** @param {any} v */
|
|
3124
3124
|
(t) => t[0]
|
|
3125
3125
|
);
|
|
@@ -3130,8 +3130,8 @@ class ht extends A {
|
|
|
3130
3130
|
* @return {IterableIterator<MapType>}
|
|
3131
3131
|
*/
|
|
3132
3132
|
values() {
|
|
3133
|
-
return
|
|
3134
|
-
|
|
3133
|
+
return Ye(
|
|
3134
|
+
ue(this._map),
|
|
3135
3135
|
/** @param {any} v */
|
|
3136
3136
|
(t) => t[1].content.getContent()[t[1].length - 1]
|
|
3137
3137
|
);
|
|
@@ -3142,8 +3142,8 @@ class ht extends A {
|
|
|
3142
3142
|
* @return {IterableIterator<[string, MapType]>}
|
|
3143
3143
|
*/
|
|
3144
3144
|
entries() {
|
|
3145
|
-
return
|
|
3146
|
-
|
|
3145
|
+
return Ye(
|
|
3146
|
+
ue(this._map),
|
|
3147
3147
|
/** @param {any} v */
|
|
3148
3148
|
(t) => (
|
|
3149
3149
|
/** @type {any} */
|
|
@@ -3176,7 +3176,7 @@ class ht extends A {
|
|
|
3176
3176
|
*/
|
|
3177
3177
|
delete(t) {
|
|
3178
3178
|
this.doc !== null ? S(this.doc, (n) => {
|
|
3179
|
-
|
|
3179
|
+
Ce(n, this, t);
|
|
3180
3180
|
}) : this._prelimContent.delete(t);
|
|
3181
3181
|
}
|
|
3182
3182
|
/**
|
|
@@ -3189,7 +3189,7 @@ class ht extends A {
|
|
|
3189
3189
|
*/
|
|
3190
3190
|
set(t, n) {
|
|
3191
3191
|
return this.doc !== null ? S(this.doc, (s) => {
|
|
3192
|
-
|
|
3192
|
+
Rn(
|
|
3193
3193
|
s,
|
|
3194
3194
|
this,
|
|
3195
3195
|
t,
|
|
@@ -3207,7 +3207,7 @@ class ht extends A {
|
|
|
3207
3207
|
get(t) {
|
|
3208
3208
|
return (
|
|
3209
3209
|
/** @type {any} */
|
|
3210
|
-
|
|
3210
|
+
$n(this, t)
|
|
3211
3211
|
);
|
|
3212
3212
|
}
|
|
3213
3213
|
/**
|
|
@@ -3217,7 +3217,7 @@ class ht extends A {
|
|
|
3217
3217
|
* @return {boolean}
|
|
3218
3218
|
*/
|
|
3219
3219
|
has(t) {
|
|
3220
|
-
return
|
|
3220
|
+
return yr(this, t);
|
|
3221
3221
|
}
|
|
3222
3222
|
/**
|
|
3223
3223
|
* Removes all elements from this YMap.
|
|
@@ -3225,7 +3225,7 @@ class ht extends A {
|
|
|
3225
3225
|
clear() {
|
|
3226
3226
|
this.doc !== null ? S(this.doc, (t) => {
|
|
3227
3227
|
this.forEach(function(n, s, r) {
|
|
3228
|
-
|
|
3228
|
+
Ce(t, r, s);
|
|
3229
3229
|
});
|
|
3230
3230
|
}) : this._prelimContent.clear();
|
|
3231
3231
|
}
|
|
@@ -3233,11 +3233,11 @@ class ht extends A {
|
|
|
3233
3233
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3234
3234
|
*/
|
|
3235
3235
|
_write(t) {
|
|
3236
|
-
t.writeTypeRef(
|
|
3236
|
+
t.writeTypeRef(cl);
|
|
3237
3237
|
}
|
|
3238
3238
|
}
|
|
3239
|
-
const
|
|
3240
|
-
class
|
|
3239
|
+
const Vc = (e) => new ht(), tt = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && oo(e, t);
|
|
3240
|
+
class un {
|
|
3241
3241
|
/**
|
|
3242
3242
|
* @param {Item|null} left
|
|
3243
3243
|
* @param {Item|null} right
|
|
@@ -3253,7 +3253,7 @@ class hn {
|
|
|
3253
3253
|
forward() {
|
|
3254
3254
|
switch (this.right === null && j(), this.right.content.constructor) {
|
|
3255
3255
|
case D:
|
|
3256
|
-
this.right.deleted ||
|
|
3256
|
+
this.right.deleted || Rt(
|
|
3257
3257
|
this.currentAttributes,
|
|
3258
3258
|
/** @type {ContentFormat} */
|
|
3259
3259
|
this.right.content
|
|
@@ -3266,11 +3266,11 @@ class hn {
|
|
|
3266
3266
|
this.left = this.right, this.right = this.right.right;
|
|
3267
3267
|
}
|
|
3268
3268
|
}
|
|
3269
|
-
const
|
|
3269
|
+
const ds = (e, t, n) => {
|
|
3270
3270
|
for (; t.right !== null && n > 0; ) {
|
|
3271
3271
|
switch (t.right.content.constructor) {
|
|
3272
3272
|
case D:
|
|
3273
|
-
t.right.deleted ||
|
|
3273
|
+
t.right.deleted || Rt(
|
|
3274
3274
|
t.currentAttributes,
|
|
3275
3275
|
/** @type {ContentFormat} */
|
|
3276
3276
|
t.right.content
|
|
@@ -3283,16 +3283,16 @@ const us = (e, t, n) => {
|
|
|
3283
3283
|
t.left = t.right, t.right = t.right.right;
|
|
3284
3284
|
}
|
|
3285
3285
|
return t;
|
|
3286
|
-
},
|
|
3287
|
-
const r = /* @__PURE__ */ new Map(), i = s ?
|
|
3286
|
+
}, de = (e, t, n, s) => {
|
|
3287
|
+
const r = /* @__PURE__ */ new Map(), i = s ? $e(t, n) : null;
|
|
3288
3288
|
if (i) {
|
|
3289
|
-
const o = new
|
|
3290
|
-
return
|
|
3289
|
+
const o = new un(i.p.left, i.p, i.index, r);
|
|
3290
|
+
return ds(e, o, n - i.index);
|
|
3291
3291
|
} else {
|
|
3292
|
-
const o = new
|
|
3293
|
-
return
|
|
3292
|
+
const o = new un(null, t._start, 0, r);
|
|
3293
|
+
return ds(e, o, n);
|
|
3294
3294
|
}
|
|
3295
|
-
},
|
|
3295
|
+
}, br = (e, t, n, s) => {
|
|
3296
3296
|
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === D && tt(
|
|
3297
3297
|
s.get(
|
|
3298
3298
|
/** @type {ContentFormat} */
|
|
@@ -3310,10 +3310,10 @@ const us = (e, t, n) => {
|
|
|
3310
3310
|
const l = n.left, a = n.right, h = new k(b(i, C(r.store, i)), l, l && l.lastId, a, a && a.id, t, null, new D(c, o));
|
|
3311
3311
|
h.integrate(e, 0), n.right = h, n.forward();
|
|
3312
3312
|
});
|
|
3313
|
-
},
|
|
3313
|
+
}, Rt = (e, t) => {
|
|
3314
3314
|
const { key: n, value: s } = t;
|
|
3315
3315
|
s === null ? e.delete(n) : e.set(n, s);
|
|
3316
|
-
},
|
|
3316
|
+
}, Sr = (e, t) => {
|
|
3317
3317
|
for (; e.right !== null; ) {
|
|
3318
3318
|
if (!(e.right.deleted || e.right.content.constructor === D && tt(
|
|
3319
3319
|
t[
|
|
@@ -3326,7 +3326,7 @@ const us = (e, t, n) => {
|
|
|
3326
3326
|
break;
|
|
3327
3327
|
e.forward();
|
|
3328
3328
|
}
|
|
3329
|
-
},
|
|
3329
|
+
}, _r = (e, t, n, s) => {
|
|
3330
3330
|
const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
3331
3331
|
for (const c in s) {
|
|
3332
3332
|
const l = s[c], a = n.currentAttributes.get(c) || null;
|
|
@@ -3337,22 +3337,22 @@ const us = (e, t, n) => {
|
|
|
3337
3337
|
}
|
|
3338
3338
|
}
|
|
3339
3339
|
return o;
|
|
3340
|
-
},
|
|
3340
|
+
}, Je = (e, t, n, s, r) => {
|
|
3341
3341
|
n.currentAttributes.forEach((u, f) => {
|
|
3342
3342
|
r[f] === void 0 && (r[f] = null);
|
|
3343
3343
|
});
|
|
3344
3344
|
const i = e.doc, o = i.clientID;
|
|
3345
|
-
|
|
3346
|
-
const c =
|
|
3345
|
+
Sr(n, r);
|
|
3346
|
+
const c = _r(e, t, n, r), l = s.constructor === String ? new K(
|
|
3347
3347
|
/** @type {string} */
|
|
3348
3348
|
s
|
|
3349
3349
|
) : s instanceof A ? new Z(s) : new mt(s);
|
|
3350
3350
|
let { left: a, right: h, index: d } = n;
|
|
3351
|
-
t._searchMarker &&
|
|
3352
|
-
},
|
|
3351
|
+
t._searchMarker && Jt(t._searchMarker, n.index, l.getLength()), h = new k(b(o, C(i.store, o)), a, a && a.lastId, h, h && h.id, t, null, l), h.integrate(e, 0), n.right = h, n.index = d, n.forward(), br(e, t, n, c);
|
|
3352
|
+
}, fs = (e, t, n, s, r) => {
|
|
3353
3353
|
const i = e.doc, o = i.clientID;
|
|
3354
|
-
|
|
3355
|
-
const c =
|
|
3354
|
+
Sr(n, r);
|
|
3355
|
+
const c = _r(e, t, n, r);
|
|
3356
3356
|
t:
|
|
3357
3357
|
for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === D)); ) {
|
|
3358
3358
|
if (!n.right.deleted)
|
|
@@ -3388,8 +3388,8 @@ const us = (e, t, n) => {
|
|
|
3388
3388
|
`;
|
|
3389
3389
|
n.right = new k(b(o, C(i.store, o)), n.left, n.left && n.left.lastId, n.right, n.right && n.right.id, t, null, new K(l)), n.right.integrate(e, 0), n.forward();
|
|
3390
3390
|
}
|
|
3391
|
-
|
|
3392
|
-
},
|
|
3391
|
+
br(e, t, n, c);
|
|
3392
|
+
}, kr = (e, t, n, s, r) => {
|
|
3393
3393
|
let i = t;
|
|
3394
3394
|
const o = B();
|
|
3395
3395
|
for (; i && (!i.countable || i.deleted); ) {
|
|
@@ -3412,7 +3412,7 @@ const us = (e, t, n) => {
|
|
|
3412
3412
|
/** @type {ContentFormat} */
|
|
3413
3413
|
a
|
|
3414
3414
|
), u = s.get(h) || null;
|
|
3415
|
-
(o.get(h) !== a || u === d) && (t.delete(e), c++, !l && (r.get(h) || null) === d && u !== d && (u === null ? r.delete(h) : r.set(h, u))), !l && !t.deleted &&
|
|
3415
|
+
(o.get(h) !== a || u === d) && (t.delete(e), c++, !l && (r.get(h) || null) === d && u !== d && (u === null ? r.delete(h) : r.set(h, u))), !l && !t.deleted && Rt(
|
|
3416
3416
|
r,
|
|
3417
3417
|
/** @type {ContentFormat} */
|
|
3418
3418
|
a
|
|
@@ -3425,7 +3425,7 @@ const us = (e, t, n) => {
|
|
|
3425
3425
|
t.right;
|
|
3426
3426
|
}
|
|
3427
3427
|
return c;
|
|
3428
|
-
},
|
|
3428
|
+
}, Fc = (e, t) => {
|
|
3429
3429
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
3430
3430
|
t = t.right;
|
|
3431
3431
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -3439,7 +3439,7 @@ const us = (e, t, n) => {
|
|
|
3439
3439
|
}
|
|
3440
3440
|
t = t.left;
|
|
3441
3441
|
}
|
|
3442
|
-
},
|
|
3442
|
+
}, Hc = (e) => {
|
|
3443
3443
|
let t = 0;
|
|
3444
3444
|
return S(
|
|
3445
3445
|
/** @type {Doc} */
|
|
@@ -3449,30 +3449,30 @@ const us = (e, t, n) => {
|
|
|
3449
3449
|
/** @type {Item} */
|
|
3450
3450
|
e._start
|
|
3451
3451
|
), r = e._start, i = B();
|
|
3452
|
-
const o =
|
|
3452
|
+
const o = nn(i);
|
|
3453
3453
|
for (; r; ) {
|
|
3454
3454
|
if (r.deleted === !1)
|
|
3455
3455
|
switch (r.content.constructor) {
|
|
3456
3456
|
case D:
|
|
3457
|
-
|
|
3457
|
+
Rt(
|
|
3458
3458
|
o,
|
|
3459
3459
|
/** @type {ContentFormat} */
|
|
3460
3460
|
r.content
|
|
3461
3461
|
);
|
|
3462
3462
|
break;
|
|
3463
3463
|
default:
|
|
3464
|
-
t +=
|
|
3464
|
+
t += kr(n, s, r, i, o), i = nn(o), s = r;
|
|
3465
3465
|
break;
|
|
3466
3466
|
}
|
|
3467
3467
|
r = r.right;
|
|
3468
3468
|
}
|
|
3469
3469
|
}
|
|
3470
3470
|
), t;
|
|
3471
|
-
},
|
|
3471
|
+
}, jc = (e) => {
|
|
3472
3472
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
3473
3473
|
for (const [s, r] of e.afterState.entries()) {
|
|
3474
3474
|
const i = e.beforeState.get(s) || 0;
|
|
3475
|
-
r !== i &&
|
|
3475
|
+
r !== i && ir(
|
|
3476
3476
|
e,
|
|
3477
3477
|
/** @type {Array<Item|GC>} */
|
|
3478
3478
|
n.store.clients.get(s),
|
|
@@ -3480,7 +3480,7 @@ const us = (e, t, n) => {
|
|
|
3480
3480
|
r,
|
|
3481
3481
|
(o) => {
|
|
3482
3482
|
!o.deleted && /** @type {Item} */
|
|
3483
|
-
o.content.constructor === D && o.constructor !==
|
|
3483
|
+
o.content.constructor === D && o.constructor !== M && t.add(
|
|
3484
3484
|
/** @type {any} */
|
|
3485
3485
|
o.parent
|
|
3486
3486
|
);
|
|
@@ -3488,8 +3488,8 @@ const us = (e, t, n) => {
|
|
|
3488
3488
|
);
|
|
3489
3489
|
}
|
|
3490
3490
|
S(n, (s) => {
|
|
3491
|
-
|
|
3492
|
-
if (r instanceof
|
|
3491
|
+
Ys(e, e.deleteSet, (r) => {
|
|
3492
|
+
if (r instanceof M || !/** @type {YText} */
|
|
3493
3493
|
r.parent._hasFormatting || t.has(
|
|
3494
3494
|
/** @type {YText} */
|
|
3495
3495
|
r.parent
|
|
@@ -3499,13 +3499,13 @@ const us = (e, t, n) => {
|
|
|
3499
3499
|
/** @type {YText} */
|
|
3500
3500
|
r.parent
|
|
3501
3501
|
);
|
|
3502
|
-
r.content.constructor === D ? t.add(i) :
|
|
3502
|
+
r.content.constructor === D ? t.add(i) : Fc(s, r);
|
|
3503
3503
|
});
|
|
3504
3504
|
for (const r of t)
|
|
3505
|
-
|
|
3505
|
+
Hc(r);
|
|
3506
3506
|
});
|
|
3507
|
-
},
|
|
3508
|
-
const s = n, r =
|
|
3507
|
+
}, gs = (e, t, n) => {
|
|
3508
|
+
const s = n, r = nn(t.currentAttributes), i = t.right;
|
|
3509
3509
|
for (; n > 0 && t.right !== null; ) {
|
|
3510
3510
|
if (t.right.deleted === !1)
|
|
3511
3511
|
switch (t.right.content.constructor) {
|
|
@@ -3517,15 +3517,15 @@ const us = (e, t, n) => {
|
|
|
3517
3517
|
}
|
|
3518
3518
|
t.forward();
|
|
3519
3519
|
}
|
|
3520
|
-
i &&
|
|
3520
|
+
i && kr(e, i, t.right, r, t.currentAttributes);
|
|
3521
3521
|
const o = (
|
|
3522
3522
|
/** @type {AbstractType<any>} */
|
|
3523
3523
|
/** @type {Item} */
|
|
3524
3524
|
(t.left || t.right).parent
|
|
3525
3525
|
);
|
|
3526
|
-
return o._searchMarker &&
|
|
3526
|
+
return o._searchMarker && Jt(o._searchMarker, t.index, -s + n), t;
|
|
3527
3527
|
};
|
|
3528
|
-
class
|
|
3528
|
+
class zc extends Re {
|
|
3529
3529
|
/**
|
|
3530
3530
|
* @param {YText} ytext
|
|
3531
3531
|
* @param {Transaction} transaction
|
|
@@ -3586,7 +3586,7 @@ class Hc extends Oe {
|
|
|
3586
3586
|
}))), a = "";
|
|
3587
3587
|
break;
|
|
3588
3588
|
case "retain":
|
|
3589
|
-
h > 0 && (f = { retain: h },
|
|
3589
|
+
h > 0 && (f = { retain: h }, ro(l) || (f.attributes = eo({}, l))), h = 0;
|
|
3590
3590
|
break;
|
|
3591
3591
|
}
|
|
3592
3592
|
f && n.push(f), c = null;
|
|
@@ -3621,7 +3621,7 @@ class Hc extends Oe {
|
|
|
3621
3621
|
const p = l[f];
|
|
3622
3622
|
p !== void 0 && (tt(p, g) ? p !== null && o.delete(s) : (c === "retain" && u(), g === null ? delete l[f] : l[f] = g));
|
|
3623
3623
|
}
|
|
3624
|
-
o.deleted || (c === "insert" && u(),
|
|
3624
|
+
o.deleted || (c === "insert" && u(), Rt(
|
|
3625
3625
|
r,
|
|
3626
3626
|
/** @type {ContentFormat} */
|
|
3627
3627
|
o.content
|
|
@@ -3646,7 +3646,7 @@ class Hc extends Oe {
|
|
|
3646
3646
|
);
|
|
3647
3647
|
}
|
|
3648
3648
|
}
|
|
3649
|
-
class
|
|
3649
|
+
class Mt extends A {
|
|
3650
3650
|
/**
|
|
3651
3651
|
* @param {String} [string] The initial value of the YText.
|
|
3652
3652
|
*/
|
|
@@ -3675,13 +3675,13 @@ class Ut extends A {
|
|
|
3675
3675
|
this._pending = null;
|
|
3676
3676
|
}
|
|
3677
3677
|
_copy() {
|
|
3678
|
-
return new
|
|
3678
|
+
return new Mt();
|
|
3679
3679
|
}
|
|
3680
3680
|
/**
|
|
3681
3681
|
* @return {YText}
|
|
3682
3682
|
*/
|
|
3683
3683
|
clone() {
|
|
3684
|
-
const t = new
|
|
3684
|
+
const t = new Mt();
|
|
3685
3685
|
return t.applyDelta(this.toDelta()), t;
|
|
3686
3686
|
}
|
|
3687
3687
|
/**
|
|
@@ -3692,7 +3692,7 @@ class Ut extends A {
|
|
|
3692
3692
|
*/
|
|
3693
3693
|
_callObserver(t, n) {
|
|
3694
3694
|
super._callObserver(t, n);
|
|
3695
|
-
const s = new
|
|
3695
|
+
const s = new zc(this, t, n);
|
|
3696
3696
|
Ne(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
3697
3697
|
}
|
|
3698
3698
|
/**
|
|
@@ -3728,15 +3728,15 @@ class Ut extends A {
|
|
|
3728
3728
|
*/
|
|
3729
3729
|
applyDelta(t, { sanitize: n = !0 } = {}) {
|
|
3730
3730
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3731
|
-
const r = new
|
|
3731
|
+
const r = new un(null, this._start, 0, /* @__PURE__ */ new Map());
|
|
3732
3732
|
for (let i = 0; i < t.length; i++) {
|
|
3733
3733
|
const o = t[i];
|
|
3734
3734
|
if (o.insert !== void 0) {
|
|
3735
3735
|
const c = !n && typeof o.insert == "string" && i === t.length - 1 && r.right === null && o.insert.slice(-1) === `
|
|
3736
3736
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3737
|
-
(typeof c != "string" || c.length > 0) &&
|
|
3737
|
+
(typeof c != "string" || c.length > 0) && Je(s, this, r, c, o.attributes || {});
|
|
3738
3738
|
} else
|
|
3739
|
-
o.retain !== void 0 ?
|
|
3739
|
+
o.retain !== void 0 ? fs(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && gs(s, r, o.delete);
|
|
3740
3740
|
}
|
|
3741
3741
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
3742
3742
|
}
|
|
@@ -3796,7 +3796,7 @@ class Ut extends A {
|
|
|
3796
3796
|
break;
|
|
3797
3797
|
}
|
|
3798
3798
|
case D:
|
|
3799
|
-
St(l, t) && (a(),
|
|
3799
|
+
St(l, t) && (a(), Rt(
|
|
3800
3800
|
i,
|
|
3801
3801
|
/** @type {ContentFormat} */
|
|
3802
3802
|
l.content
|
|
@@ -3808,7 +3808,7 @@ class Ut extends A {
|
|
|
3808
3808
|
a();
|
|
3809
3809
|
};
|
|
3810
3810
|
return t || n ? S(o, (d) => {
|
|
3811
|
-
t &&
|
|
3811
|
+
t && an(d, t), n && an(d, n), h();
|
|
3812
3812
|
}, "cleanup") : h(), r;
|
|
3813
3813
|
}
|
|
3814
3814
|
/**
|
|
@@ -3826,10 +3826,10 @@ class Ut extends A {
|
|
|
3826
3826
|
return;
|
|
3827
3827
|
const r = this.doc;
|
|
3828
3828
|
r !== null ? S(r, (i) => {
|
|
3829
|
-
const o =
|
|
3829
|
+
const o = de(i, this, t, !s);
|
|
3830
3830
|
s || (s = {}, o.currentAttributes.forEach((c, l) => {
|
|
3831
3831
|
s[l] = c;
|
|
3832
|
-
})),
|
|
3832
|
+
})), Je(i, this, o, n, s);
|
|
3833
3833
|
}) : this._pending.push(() => this.insert(t, n, s));
|
|
3834
3834
|
}
|
|
3835
3835
|
/**
|
|
@@ -3845,8 +3845,8 @@ class Ut extends A {
|
|
|
3845
3845
|
insertEmbed(t, n, s) {
|
|
3846
3846
|
const r = this.doc;
|
|
3847
3847
|
r !== null ? S(r, (i) => {
|
|
3848
|
-
const o =
|
|
3849
|
-
|
|
3848
|
+
const o = de(i, this, t, !s);
|
|
3849
|
+
Je(i, this, o, n, s || {});
|
|
3850
3850
|
}) : this._pending.push(() => this.insertEmbed(t, n, s || {}));
|
|
3851
3851
|
}
|
|
3852
3852
|
/**
|
|
@@ -3862,7 +3862,7 @@ class Ut extends A {
|
|
|
3862
3862
|
return;
|
|
3863
3863
|
const s = this.doc;
|
|
3864
3864
|
s !== null ? S(s, (r) => {
|
|
3865
|
-
|
|
3865
|
+
gs(r, de(r, this, t, !0), n);
|
|
3866
3866
|
}) : this._pending.push(() => this.delete(t, n));
|
|
3867
3867
|
}
|
|
3868
3868
|
/**
|
|
@@ -3880,8 +3880,8 @@ class Ut extends A {
|
|
|
3880
3880
|
return;
|
|
3881
3881
|
const r = this.doc;
|
|
3882
3882
|
r !== null ? S(r, (i) => {
|
|
3883
|
-
const o =
|
|
3884
|
-
o.right !== null &&
|
|
3883
|
+
const o = de(i, this, t, !1);
|
|
3884
|
+
o.right !== null && fs(i, this, o, n, s);
|
|
3885
3885
|
}) : this._pending.push(() => this.format(t, n, s));
|
|
3886
3886
|
}
|
|
3887
3887
|
/**
|
|
@@ -3895,7 +3895,7 @@ class Ut extends A {
|
|
|
3895
3895
|
*/
|
|
3896
3896
|
removeAttribute(t) {
|
|
3897
3897
|
this.doc !== null ? S(this.doc, (n) => {
|
|
3898
|
-
|
|
3898
|
+
Ce(n, this, t);
|
|
3899
3899
|
}) : this._pending.push(() => this.removeAttribute(t));
|
|
3900
3900
|
}
|
|
3901
3901
|
/**
|
|
@@ -3910,7 +3910,7 @@ class Ut extends A {
|
|
|
3910
3910
|
*/
|
|
3911
3911
|
setAttribute(t, n) {
|
|
3912
3912
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3913
|
-
|
|
3913
|
+
Rn(s, this, t, n);
|
|
3914
3914
|
}) : this._pending.push(() => this.setAttribute(t, n));
|
|
3915
3915
|
}
|
|
3916
3916
|
/**
|
|
@@ -3927,7 +3927,7 @@ class Ut extends A {
|
|
|
3927
3927
|
getAttribute(t) {
|
|
3928
3928
|
return (
|
|
3929
3929
|
/** @type {any} */
|
|
3930
|
-
|
|
3930
|
+
$n(this, t)
|
|
3931
3931
|
);
|
|
3932
3932
|
}
|
|
3933
3933
|
/**
|
|
@@ -3940,17 +3940,17 @@ class Ut extends A {
|
|
|
3940
3940
|
* @public
|
|
3941
3941
|
*/
|
|
3942
3942
|
getAttributes() {
|
|
3943
|
-
return
|
|
3943
|
+
return mr(this);
|
|
3944
3944
|
}
|
|
3945
3945
|
/**
|
|
3946
3946
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3947
3947
|
*/
|
|
3948
3948
|
_write(t) {
|
|
3949
|
-
t.writeTypeRef(
|
|
3949
|
+
t.writeTypeRef(ll);
|
|
3950
3950
|
}
|
|
3951
3951
|
}
|
|
3952
|
-
const
|
|
3953
|
-
class
|
|
3952
|
+
const Kc = (e) => new Mt();
|
|
3953
|
+
class We {
|
|
3954
3954
|
/**
|
|
3955
3955
|
* @param {YXmlFragment | YXmlElement} root
|
|
3956
3956
|
* @param {function(AbstractType<any>):boolean} [f]
|
|
@@ -4054,7 +4054,7 @@ class ut extends A {
|
|
|
4054
4054
|
* @public
|
|
4055
4055
|
*/
|
|
4056
4056
|
createTreeWalker(t) {
|
|
4057
|
-
return new
|
|
4057
|
+
return new We(this, t);
|
|
4058
4058
|
}
|
|
4059
4059
|
/**
|
|
4060
4060
|
* Returns the first YXmlElement that matches the query.
|
|
@@ -4073,7 +4073,7 @@ class ut extends A {
|
|
|
4073
4073
|
*/
|
|
4074
4074
|
querySelector(t) {
|
|
4075
4075
|
t = t.toUpperCase();
|
|
4076
|
-
const s = new
|
|
4076
|
+
const s = new We(this, (r) => r.nodeName && r.nodeName.toUpperCase() === t).next();
|
|
4077
4077
|
return s.done ? null : s.value;
|
|
4078
4078
|
}
|
|
4079
4079
|
/**
|
|
@@ -4088,7 +4088,7 @@ class ut extends A {
|
|
|
4088
4088
|
* @public
|
|
4089
4089
|
*/
|
|
4090
4090
|
querySelectorAll(t) {
|
|
4091
|
-
return t = t.toUpperCase(), nt(new
|
|
4091
|
+
return t = t.toUpperCase(), nt(new We(this, (n) => n.nodeName && n.nodeName.toUpperCase() === t));
|
|
4092
4092
|
}
|
|
4093
4093
|
/**
|
|
4094
4094
|
* Creates YXmlEvent and calls observers.
|
|
@@ -4097,7 +4097,7 @@ class ut extends A {
|
|
|
4097
4097
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
4098
4098
|
*/
|
|
4099
4099
|
_callObserver(t, n) {
|
|
4100
|
-
Ne(this, t, new
|
|
4100
|
+
Ne(this, t, new Jc(this, n, t));
|
|
4101
4101
|
}
|
|
4102
4102
|
/**
|
|
4103
4103
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -4105,7 +4105,7 @@ class ut extends A {
|
|
|
4105
4105
|
* @return {string} The string representation of all children.
|
|
4106
4106
|
*/
|
|
4107
4107
|
toString() {
|
|
4108
|
-
return
|
|
4108
|
+
return dr(this, (t) => t.toString()).join("");
|
|
4109
4109
|
}
|
|
4110
4110
|
/**
|
|
4111
4111
|
* @return {string}
|
|
@@ -4130,7 +4130,7 @@ class ut extends A {
|
|
|
4130
4130
|
*/
|
|
4131
4131
|
toDOM(t = document, n = {}, s) {
|
|
4132
4132
|
const r = t.createDocumentFragment();
|
|
4133
|
-
return s !== void 0 && s._createAssociation(r, this),
|
|
4133
|
+
return s !== void 0 && s._createAssociation(r, this), Wt(this, (i) => {
|
|
4134
4134
|
r.insertBefore(i.toDOM(t, n, s), null);
|
|
4135
4135
|
}), r;
|
|
4136
4136
|
}
|
|
@@ -4146,7 +4146,7 @@ class ut extends A {
|
|
|
4146
4146
|
*/
|
|
4147
4147
|
insert(t, n) {
|
|
4148
4148
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4149
|
-
|
|
4149
|
+
pr(s, this, t, n);
|
|
4150
4150
|
}) : this._prelimContent.splice(t, 0, ...n);
|
|
4151
4151
|
}
|
|
4152
4152
|
/**
|
|
@@ -4163,7 +4163,7 @@ class ut extends A {
|
|
|
4163
4163
|
if (this.doc !== null)
|
|
4164
4164
|
S(this.doc, (s) => {
|
|
4165
4165
|
const r = t && t instanceof A ? t._item : t;
|
|
4166
|
-
|
|
4166
|
+
Ee(s, this, r, n);
|
|
4167
4167
|
});
|
|
4168
4168
|
else {
|
|
4169
4169
|
const s = (
|
|
@@ -4183,7 +4183,7 @@ class ut extends A {
|
|
|
4183
4183
|
*/
|
|
4184
4184
|
delete(t, n = 1) {
|
|
4185
4185
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4186
|
-
|
|
4186
|
+
wr(s, this, t, n);
|
|
4187
4187
|
}) : this._prelimContent.splice(t, n);
|
|
4188
4188
|
}
|
|
4189
4189
|
/**
|
|
@@ -4192,7 +4192,7 @@ class ut extends A {
|
|
|
4192
4192
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
4193
4193
|
*/
|
|
4194
4194
|
toArray() {
|
|
4195
|
-
return
|
|
4195
|
+
return ur(this);
|
|
4196
4196
|
}
|
|
4197
4197
|
/**
|
|
4198
4198
|
* Appends content to this YArray.
|
|
@@ -4217,7 +4217,7 @@ class ut extends A {
|
|
|
4217
4217
|
* @return {YXmlElement|YXmlText}
|
|
4218
4218
|
*/
|
|
4219
4219
|
get(t) {
|
|
4220
|
-
return
|
|
4220
|
+
return fr(this, t);
|
|
4221
4221
|
}
|
|
4222
4222
|
/**
|
|
4223
4223
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -4227,7 +4227,7 @@ class ut extends A {
|
|
|
4227
4227
|
* @return {Array<YXmlElement|YXmlText>}
|
|
4228
4228
|
*/
|
|
4229
4229
|
slice(t = 0, n = this.length) {
|
|
4230
|
-
return
|
|
4230
|
+
return hr(this, t, n);
|
|
4231
4231
|
}
|
|
4232
4232
|
/**
|
|
4233
4233
|
* Executes a provided function on once on overy child element.
|
|
@@ -4235,7 +4235,7 @@ class ut extends A {
|
|
|
4235
4235
|
* @param {function(YXmlElement|YXmlText,number, typeof self):void} f A function to execute on every element of this YArray.
|
|
4236
4236
|
*/
|
|
4237
4237
|
forEach(t) {
|
|
4238
|
-
|
|
4238
|
+
Wt(this, t);
|
|
4239
4239
|
}
|
|
4240
4240
|
/**
|
|
4241
4241
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -4246,10 +4246,10 @@ class ut extends A {
|
|
|
4246
4246
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4247
4247
|
*/
|
|
4248
4248
|
_write(t) {
|
|
4249
|
-
t.writeTypeRef(
|
|
4249
|
+
t.writeTypeRef(hl);
|
|
4250
4250
|
}
|
|
4251
4251
|
}
|
|
4252
|
-
const
|
|
4252
|
+
const Yc = (e) => new ut();
|
|
4253
4253
|
class Pt extends ut {
|
|
4254
4254
|
constructor(t = "UNDEFINED") {
|
|
4255
4255
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
@@ -4305,7 +4305,7 @@ class Pt extends ut {
|
|
|
4305
4305
|
*/
|
|
4306
4306
|
clone() {
|
|
4307
4307
|
const t = new Pt(this.nodeName), n = this.getAttributes();
|
|
4308
|
-
return
|
|
4308
|
+
return so(n, (s, r) => {
|
|
4309
4309
|
typeof s == "string" && t.setAttribute(r, s);
|
|
4310
4310
|
}), t.insert(0, this.toArray().map((s) => s instanceof A ? s.clone() : s)), t;
|
|
4311
4311
|
}
|
|
@@ -4340,7 +4340,7 @@ class Pt extends ut {
|
|
|
4340
4340
|
*/
|
|
4341
4341
|
removeAttribute(t) {
|
|
4342
4342
|
this.doc !== null ? S(this.doc, (n) => {
|
|
4343
|
-
|
|
4343
|
+
Ce(n, this, t);
|
|
4344
4344
|
}) : this._prelimAttrs.delete(t);
|
|
4345
4345
|
}
|
|
4346
4346
|
/**
|
|
@@ -4355,7 +4355,7 @@ class Pt extends ut {
|
|
|
4355
4355
|
*/
|
|
4356
4356
|
setAttribute(t, n) {
|
|
4357
4357
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4358
|
-
|
|
4358
|
+
Rn(s, this, t, n);
|
|
4359
4359
|
}) : this._prelimAttrs.set(t, n);
|
|
4360
4360
|
}
|
|
4361
4361
|
/**
|
|
@@ -4372,7 +4372,7 @@ class Pt extends ut {
|
|
|
4372
4372
|
getAttribute(t) {
|
|
4373
4373
|
return (
|
|
4374
4374
|
/** @type {any} */
|
|
4375
|
-
|
|
4375
|
+
$n(this, t)
|
|
4376
4376
|
);
|
|
4377
4377
|
}
|
|
4378
4378
|
/**
|
|
@@ -4386,7 +4386,7 @@ class Pt extends ut {
|
|
|
4386
4386
|
hasAttribute(t) {
|
|
4387
4387
|
return (
|
|
4388
4388
|
/** @type {any} */
|
|
4389
|
-
|
|
4389
|
+
yr(this, t)
|
|
4390
4390
|
);
|
|
4391
4391
|
}
|
|
4392
4392
|
/**
|
|
@@ -4400,7 +4400,7 @@ class Pt extends ut {
|
|
|
4400
4400
|
getAttributes(t) {
|
|
4401
4401
|
return (
|
|
4402
4402
|
/** @type {any} */
|
|
4403
|
-
t ?
|
|
4403
|
+
t ? Rc(this, t) : mr(this)
|
|
4404
4404
|
);
|
|
4405
4405
|
}
|
|
4406
4406
|
/**
|
|
@@ -4424,7 +4424,7 @@ class Pt extends ut {
|
|
|
4424
4424
|
const c = i[o];
|
|
4425
4425
|
typeof c == "string" && r.setAttribute(o, c);
|
|
4426
4426
|
}
|
|
4427
|
-
return
|
|
4427
|
+
return Wt(this, (o) => {
|
|
4428
4428
|
r.appendChild(o.toDOM(t, n, s));
|
|
4429
4429
|
}), s !== void 0 && s._createAssociation(r, this), r;
|
|
4430
4430
|
}
|
|
@@ -4437,11 +4437,11 @@ class Pt extends ut {
|
|
|
4437
4437
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4438
4438
|
*/
|
|
4439
4439
|
_write(t) {
|
|
4440
|
-
t.writeTypeRef(
|
|
4440
|
+
t.writeTypeRef(al), t.writeKey(this.nodeName);
|
|
4441
4441
|
}
|
|
4442
4442
|
}
|
|
4443
|
-
const
|
|
4444
|
-
class
|
|
4443
|
+
const Xc = (e) => new Pt(e.readKey());
|
|
4444
|
+
class Jc extends Re {
|
|
4445
4445
|
/**
|
|
4446
4446
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
4447
4447
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -4455,7 +4455,7 @@ class Yc extends Oe {
|
|
|
4455
4455
|
});
|
|
4456
4456
|
}
|
|
4457
4457
|
}
|
|
4458
|
-
class
|
|
4458
|
+
class Ae extends ht {
|
|
4459
4459
|
/**
|
|
4460
4460
|
* @param {string} hookName nodeName of the Dom Node.
|
|
4461
4461
|
*/
|
|
@@ -4466,13 +4466,13 @@ class Ee extends ht {
|
|
|
4466
4466
|
* Creates an Item with the same effect as this Item (without position effect)
|
|
4467
4467
|
*/
|
|
4468
4468
|
_copy() {
|
|
4469
|
-
return new
|
|
4469
|
+
return new Ae(this.hookName);
|
|
4470
4470
|
}
|
|
4471
4471
|
/**
|
|
4472
4472
|
* @return {YXmlHook}
|
|
4473
4473
|
*/
|
|
4474
4474
|
clone() {
|
|
4475
|
-
const t = new
|
|
4475
|
+
const t = new Ae(this.hookName);
|
|
4476
4476
|
return this.forEach((n, s) => {
|
|
4477
4477
|
t.set(s, n);
|
|
4478
4478
|
}), t;
|
|
@@ -4506,11 +4506,11 @@ class Ee extends ht {
|
|
|
4506
4506
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4507
4507
|
*/
|
|
4508
4508
|
_write(t) {
|
|
4509
|
-
t.writeTypeRef(
|
|
4509
|
+
t.writeTypeRef(ul), t.writeKey(this.hookName);
|
|
4510
4510
|
}
|
|
4511
4511
|
}
|
|
4512
|
-
const
|
|
4513
|
-
class
|
|
4512
|
+
const Wc = (e) => new Ae(e.readKey());
|
|
4513
|
+
class Le extends Mt {
|
|
4514
4514
|
/**
|
|
4515
4515
|
* @type {YXmlElement|YXmlText|null}
|
|
4516
4516
|
*/
|
|
@@ -4534,13 +4534,13 @@ class Ce extends Ut {
|
|
|
4534
4534
|
) : null;
|
|
4535
4535
|
}
|
|
4536
4536
|
_copy() {
|
|
4537
|
-
return new
|
|
4537
|
+
return new Le();
|
|
4538
4538
|
}
|
|
4539
4539
|
/**
|
|
4540
4540
|
* @return {YXmlText}
|
|
4541
4541
|
*/
|
|
4542
4542
|
clone() {
|
|
4543
|
-
const t = new
|
|
4543
|
+
const t = new Le();
|
|
4544
4544
|
return t.applyDelta(this.toDelta()), t;
|
|
4545
4545
|
}
|
|
4546
4546
|
/**
|
|
@@ -4598,10 +4598,10 @@ class Ce extends Ut {
|
|
|
4598
4598
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4599
4599
|
*/
|
|
4600
4600
|
_write(t) {
|
|
4601
|
-
t.writeTypeRef(
|
|
4601
|
+
t.writeTypeRef(dl);
|
|
4602
4602
|
}
|
|
4603
4603
|
}
|
|
4604
|
-
const
|
|
4604
|
+
const Pc = (e) => new Le();
|
|
4605
4605
|
class Nn {
|
|
4606
4606
|
/**
|
|
4607
4607
|
* @param {ID} id
|
|
@@ -4642,8 +4642,8 @@ class Nn {
|
|
|
4642
4642
|
throw H();
|
|
4643
4643
|
}
|
|
4644
4644
|
}
|
|
4645
|
-
const
|
|
4646
|
-
class
|
|
4645
|
+
const Gc = 0;
|
|
4646
|
+
class M extends Nn {
|
|
4647
4647
|
get deleted() {
|
|
4648
4648
|
return !0;
|
|
4649
4649
|
}
|
|
@@ -4661,14 +4661,14 @@ class U extends Nn {
|
|
|
4661
4661
|
* @param {number} offset
|
|
4662
4662
|
*/
|
|
4663
4663
|
integrate(t, n) {
|
|
4664
|
-
n > 0 && (this.id.clock += n, this.length -= n),
|
|
4664
|
+
n > 0 && (this.id.clock += n, this.length -= n), rr(t.doc.store, this);
|
|
4665
4665
|
}
|
|
4666
4666
|
/**
|
|
4667
4667
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4668
4668
|
* @param {number} offset
|
|
4669
4669
|
*/
|
|
4670
4670
|
write(t, n) {
|
|
4671
|
-
t.writeInfo(
|
|
4671
|
+
t.writeInfo(Gc), t.writeLen(this.length - n);
|
|
4672
4672
|
}
|
|
4673
4673
|
/**
|
|
4674
4674
|
* @param {Transaction} transaction
|
|
@@ -4679,7 +4679,7 @@ class U extends Nn {
|
|
|
4679
4679
|
return null;
|
|
4680
4680
|
}
|
|
4681
4681
|
}
|
|
4682
|
-
class
|
|
4682
|
+
class re {
|
|
4683
4683
|
/**
|
|
4684
4684
|
* @param {Uint8Array} content
|
|
4685
4685
|
*/
|
|
@@ -4708,7 +4708,7 @@ class ne {
|
|
|
4708
4708
|
* @return {ContentBinary}
|
|
4709
4709
|
*/
|
|
4710
4710
|
copy() {
|
|
4711
|
-
return new
|
|
4711
|
+
return new re(this.content);
|
|
4712
4712
|
}
|
|
4713
4713
|
/**
|
|
4714
4714
|
* @param {number} offset
|
|
@@ -4754,8 +4754,8 @@ class ne {
|
|
|
4754
4754
|
return 3;
|
|
4755
4755
|
}
|
|
4756
4756
|
}
|
|
4757
|
-
const
|
|
4758
|
-
class
|
|
4757
|
+
const qc = (e) => new re(e.readBuf());
|
|
4758
|
+
class Gt {
|
|
4759
4759
|
/**
|
|
4760
4760
|
* @param {number} len
|
|
4761
4761
|
*/
|
|
@@ -4784,14 +4784,14 @@ class Wt {
|
|
|
4784
4784
|
* @return {ContentDeleted}
|
|
4785
4785
|
*/
|
|
4786
4786
|
copy() {
|
|
4787
|
-
return new
|
|
4787
|
+
return new Gt(this.len);
|
|
4788
4788
|
}
|
|
4789
4789
|
/**
|
|
4790
4790
|
* @param {number} offset
|
|
4791
4791
|
* @return {ContentDeleted}
|
|
4792
4792
|
*/
|
|
4793
4793
|
splice(t) {
|
|
4794
|
-
const n = new
|
|
4794
|
+
const n = new Gt(this.len - t);
|
|
4795
4795
|
return this.len = t, n;
|
|
4796
4796
|
}
|
|
4797
4797
|
/**
|
|
@@ -4806,7 +4806,7 @@ class Wt {
|
|
|
4806
4806
|
* @param {Item} item
|
|
4807
4807
|
*/
|
|
4808
4808
|
integrate(t, n) {
|
|
4809
|
-
|
|
4809
|
+
ke(t.deleteSet, n.id.client, n.id.clock, this.len), n.markDeleted();
|
|
4810
4810
|
}
|
|
4811
4811
|
/**
|
|
4812
4812
|
* @param {Transaction} transaction
|
|
@@ -4832,8 +4832,8 @@ class Wt {
|
|
|
4832
4832
|
return 1;
|
|
4833
4833
|
}
|
|
4834
4834
|
}
|
|
4835
|
-
const
|
|
4836
|
-
class
|
|
4835
|
+
const Zc = (e) => new Gt(e.readLen()), Dr = (e, t) => new wt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
4836
|
+
class ie {
|
|
4837
4837
|
/**
|
|
4838
4838
|
* @param {Doc} doc
|
|
4839
4839
|
*/
|
|
@@ -4864,7 +4864,7 @@ class se {
|
|
|
4864
4864
|
* @return {ContentDoc}
|
|
4865
4865
|
*/
|
|
4866
4866
|
copy() {
|
|
4867
|
-
return new
|
|
4867
|
+
return new ie(Dr(this.doc.guid, this.opts));
|
|
4868
4868
|
}
|
|
4869
4869
|
/**
|
|
4870
4870
|
* @param {number} offset
|
|
@@ -4912,7 +4912,7 @@ class se {
|
|
|
4912
4912
|
return 9;
|
|
4913
4913
|
}
|
|
4914
4914
|
}
|
|
4915
|
-
const
|
|
4915
|
+
const Qc = (e) => new ie(Dr(e.readString(), e.readAny()));
|
|
4916
4916
|
class mt {
|
|
4917
4917
|
/**
|
|
4918
4918
|
* @param {Object} embed
|
|
@@ -4988,7 +4988,7 @@ class mt {
|
|
|
4988
4988
|
return 5;
|
|
4989
4989
|
}
|
|
4990
4990
|
}
|
|
4991
|
-
const
|
|
4991
|
+
const tl = (e) => new mt(e.readJSON());
|
|
4992
4992
|
class D {
|
|
4993
4993
|
/**
|
|
4994
4994
|
* @param {string} key
|
|
@@ -5070,8 +5070,8 @@ class D {
|
|
|
5070
5070
|
return 6;
|
|
5071
5071
|
}
|
|
5072
5072
|
}
|
|
5073
|
-
const
|
|
5074
|
-
class
|
|
5073
|
+
const el = (e) => new D(e.readKey(), e.readJSON());
|
|
5074
|
+
class Ie {
|
|
5075
5075
|
/**
|
|
5076
5076
|
* @param {Array<any>} arr
|
|
5077
5077
|
*/
|
|
@@ -5100,14 +5100,14 @@ class Ae {
|
|
|
5100
5100
|
* @return {ContentJSON}
|
|
5101
5101
|
*/
|
|
5102
5102
|
copy() {
|
|
5103
|
-
return new
|
|
5103
|
+
return new Ie(this.arr);
|
|
5104
5104
|
}
|
|
5105
5105
|
/**
|
|
5106
5106
|
* @param {number} offset
|
|
5107
5107
|
* @return {ContentJSON}
|
|
5108
5108
|
*/
|
|
5109
5109
|
splice(t) {
|
|
5110
|
-
const n = new
|
|
5110
|
+
const n = new Ie(this.arr.slice(t));
|
|
5111
5111
|
return this.arr = this.arr.slice(0, t), n;
|
|
5112
5112
|
}
|
|
5113
5113
|
/**
|
|
@@ -5152,13 +5152,13 @@ class Ae {
|
|
|
5152
5152
|
return 2;
|
|
5153
5153
|
}
|
|
5154
5154
|
}
|
|
5155
|
-
const
|
|
5155
|
+
const nl = (e) => {
|
|
5156
5156
|
const t = e.readLen(), n = [];
|
|
5157
5157
|
for (let s = 0; s < t; s++) {
|
|
5158
5158
|
const r = e.readString();
|
|
5159
5159
|
r === "undefined" ? n.push(void 0) : n.push(JSON.parse(r));
|
|
5160
5160
|
}
|
|
5161
|
-
return new
|
|
5161
|
+
return new Ie(n);
|
|
5162
5162
|
};
|
|
5163
5163
|
class dt {
|
|
5164
5164
|
/**
|
|
@@ -5241,7 +5241,7 @@ class dt {
|
|
|
5241
5241
|
return 8;
|
|
5242
5242
|
}
|
|
5243
5243
|
}
|
|
5244
|
-
const
|
|
5244
|
+
const sl = (e) => {
|
|
5245
5245
|
const t = e.readLen(), n = [];
|
|
5246
5246
|
for (let s = 0; s < t; s++)
|
|
5247
5247
|
n.push(e.readAny());
|
|
@@ -5325,15 +5325,15 @@ class K {
|
|
|
5325
5325
|
return 4;
|
|
5326
5326
|
}
|
|
5327
5327
|
}
|
|
5328
|
-
const
|
|
5329
|
-
|
|
5330
|
-
|
|
5331
|
-
jc,
|
|
5328
|
+
const rl = (e) => new K(e.readString()), il = [
|
|
5329
|
+
Nc,
|
|
5330
|
+
Vc,
|
|
5332
5331
|
Kc,
|
|
5333
|
-
zc,
|
|
5334
5332
|
Xc,
|
|
5335
|
-
|
|
5336
|
-
|
|
5333
|
+
Yc,
|
|
5334
|
+
Wc,
|
|
5335
|
+
Pc
|
|
5336
|
+
], ol = 0, cl = 1, ll = 2, al = 3, hl = 4, ul = 5, dl = 6;
|
|
5337
5337
|
class Z {
|
|
5338
5338
|
/**
|
|
5339
5339
|
* @param {AbstractType<any>} type
|
|
@@ -5426,7 +5426,7 @@ class Z {
|
|
|
5426
5426
|
return 7;
|
|
5427
5427
|
}
|
|
5428
5428
|
}
|
|
5429
|
-
const
|
|
5429
|
+
const fl = (e) => new Z(il[e.readTypeRef()](e)), ve = (e, t, n) => {
|
|
5430
5430
|
const { client: s, clock: r } = t.id, i = new k(
|
|
5431
5431
|
b(s, r + n),
|
|
5432
5432
|
t,
|
|
@@ -5451,7 +5451,7 @@ class k extends Nn {
|
|
|
5451
5451
|
* @param {AbstractContent} content
|
|
5452
5452
|
*/
|
|
5453
5453
|
constructor(t, n, s, r, i, o, c, l) {
|
|
5454
|
-
super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ?
|
|
5454
|
+
super(t, l.getLength()), this.origin = s, this.left = n, this.right = r, this.rightOrigin = i, this.parent = o, this.parentSub = c, this.redone = null, this.content = l, this.info = this.content.isCountable() ? Zn : 0;
|
|
5455
5455
|
}
|
|
5456
5456
|
/**
|
|
5457
5457
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5459,35 +5459,35 @@ class k extends Nn {
|
|
|
5459
5459
|
* @type {boolean}
|
|
5460
5460
|
*/
|
|
5461
5461
|
set marker(t) {
|
|
5462
|
-
(this.info &
|
|
5462
|
+
(this.info & je) > 0 !== t && (this.info ^= je);
|
|
5463
5463
|
}
|
|
5464
5464
|
get marker() {
|
|
5465
|
-
return (this.info &
|
|
5465
|
+
return (this.info & je) > 0;
|
|
5466
5466
|
}
|
|
5467
5467
|
/**
|
|
5468
5468
|
* If true, do not garbage collect this Item.
|
|
5469
5469
|
*/
|
|
5470
5470
|
get keep() {
|
|
5471
|
-
return (this.info &
|
|
5471
|
+
return (this.info & qn) > 0;
|
|
5472
5472
|
}
|
|
5473
5473
|
set keep(t) {
|
|
5474
|
-
this.keep !== t && (this.info ^=
|
|
5474
|
+
this.keep !== t && (this.info ^= qn);
|
|
5475
5475
|
}
|
|
5476
5476
|
get countable() {
|
|
5477
|
-
return (this.info &
|
|
5477
|
+
return (this.info & Zn) > 0;
|
|
5478
5478
|
}
|
|
5479
5479
|
/**
|
|
5480
5480
|
* Whether this item was deleted or not.
|
|
5481
5481
|
* @type {Boolean}
|
|
5482
5482
|
*/
|
|
5483
5483
|
get deleted() {
|
|
5484
|
-
return (this.info &
|
|
5484
|
+
return (this.info & He) > 0;
|
|
5485
5485
|
}
|
|
5486
5486
|
set deleted(t) {
|
|
5487
|
-
this.deleted !== t && (this.info ^=
|
|
5487
|
+
this.deleted !== t && (this.info ^= He);
|
|
5488
5488
|
}
|
|
5489
5489
|
markDeleted() {
|
|
5490
|
-
this.info |=
|
|
5490
|
+
this.info |= He;
|
|
5491
5491
|
}
|
|
5492
5492
|
/**
|
|
5493
5493
|
* Return the creator clientID of the missing op or define missing items and return null.
|
|
@@ -5503,13 +5503,13 @@ class k extends Nn {
|
|
|
5503
5503
|
return this.rightOrigin.client;
|
|
5504
5504
|
if (this.parent && this.parent.constructor === Dt && this.id.client !== this.parent.client && this.parent.clock >= C(n, this.parent.client))
|
|
5505
5505
|
return this.parent.client;
|
|
5506
|
-
if (this.origin && (this.left =
|
|
5506
|
+
if (this.origin && (this.left = ls(t, n, this.origin), this.origin = this.left.lastId), this.rightOrigin && (this.right = st(t, this.rightOrigin), this.rightOrigin = this.right.id), this.left && this.left.constructor === M || this.right && this.right.constructor === M)
|
|
5507
5507
|
this.parent = null;
|
|
5508
5508
|
else if (!this.parent)
|
|
5509
5509
|
this.left && this.left.constructor === k && (this.parent = this.left.parent, this.parentSub = this.left.parentSub), this.right && this.right.constructor === k && (this.parent = this.right.parent, this.parentSub = this.right.parentSub);
|
|
5510
5510
|
else if (this.parent.constructor === Dt) {
|
|
5511
|
-
const s =
|
|
5512
|
-
s.constructor ===
|
|
5511
|
+
const s = Xe(n, this.parent);
|
|
5512
|
+
s.constructor === M ? this.parent = null : this.parent = /** @type {ContentType} */
|
|
5513
5513
|
s.content.type;
|
|
5514
5514
|
}
|
|
5515
5515
|
return null;
|
|
@@ -5519,7 +5519,7 @@ class k extends Nn {
|
|
|
5519
5519
|
* @param {number} offset
|
|
5520
5520
|
*/
|
|
5521
5521
|
integrate(t, n) {
|
|
5522
|
-
if (n > 0 && (this.id.clock += n, this.left =
|
|
5522
|
+
if (n > 0 && (this.id.clock += n, this.left = ls(t, t.doc.store, b(this.id.client, this.id.clock - 1)), this.origin = this.left.lastId, this.content = this.content.splice(n), this.length -= n), this.parent) {
|
|
5523
5523
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5524
5524
|
let s = this.left, r;
|
|
5525
5525
|
if (s !== null)
|
|
@@ -5533,13 +5533,13 @@ class k extends Nn {
|
|
|
5533
5533
|
this.parent._start;
|
|
5534
5534
|
const i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set();
|
|
5535
5535
|
for (; r !== null && r !== this.right; ) {
|
|
5536
|
-
if (o.add(r), i.add(r),
|
|
5536
|
+
if (o.add(r), i.add(r), he(this.origin, r.origin)) {
|
|
5537
5537
|
if (r.id.client < this.id.client)
|
|
5538
5538
|
s = r, i.clear();
|
|
5539
|
-
else if (
|
|
5539
|
+
else if (he(this.rightOrigin, r.rightOrigin))
|
|
5540
5540
|
break;
|
|
5541
|
-
} else if (r.origin !== null && o.has(
|
|
5542
|
-
i.has(
|
|
5541
|
+
} else if (r.origin !== null && o.has(Xe(t.doc.store, r.origin)))
|
|
5542
|
+
i.has(Xe(t.doc.store, r.origin)) || (s = r, i.clear());
|
|
5543
5543
|
else
|
|
5544
5544
|
break;
|
|
5545
5545
|
r = r.right;
|
|
@@ -5560,7 +5560,7 @@ class k extends Nn {
|
|
|
5560
5560
|
this.parent._start, this.parent._start = this;
|
|
5561
5561
|
this.right = s;
|
|
5562
5562
|
}
|
|
5563
|
-
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length),
|
|
5563
|
+
this.right !== null ? this.right.left = this : this.parentSub !== null && (this.parent._map.set(this.parentSub, this), this.left !== null && this.left.delete(t)), this.parentSub === null && this.countable && !this.deleted && (this.parent._length += this.length), rr(t.doc.store, this), this.content.integrate(t, this), hs(
|
|
5564
5564
|
t,
|
|
5565
5565
|
/** @type {AbstractType<any>} */
|
|
5566
5566
|
this.parent,
|
|
@@ -5569,7 +5569,7 @@ class k extends Nn {
|
|
|
5569
5569
|
(this.parent._item !== null && /** @type {AbstractType<any>} */
|
|
5570
5570
|
this.parent._item.deleted || this.parentSub !== null && this.right !== null) && this.delete(t);
|
|
5571
5571
|
} else
|
|
5572
|
-
new
|
|
5572
|
+
new M(this.id, this.length).integrate(t, 0);
|
|
5573
5573
|
}
|
|
5574
5574
|
/**
|
|
5575
5575
|
* Returns the next non-deleted item
|
|
@@ -5602,7 +5602,7 @@ class k extends Nn {
|
|
|
5602
5602
|
* @return {boolean}
|
|
5603
5603
|
*/
|
|
5604
5604
|
mergeWith(t) {
|
|
5605
|
-
if (this.constructor === t.constructor &&
|
|
5605
|
+
if (this.constructor === t.constructor && he(t.origin, this.lastId) && this.right === t && he(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)) {
|
|
5606
5606
|
const n = (
|
|
5607
5607
|
/** @type {AbstractType<any>} */
|
|
5608
5608
|
this.parent._searchMarker
|
|
@@ -5624,7 +5624,7 @@ class k extends Nn {
|
|
|
5624
5624
|
/** @type {AbstractType<any>} */
|
|
5625
5625
|
this.parent
|
|
5626
5626
|
);
|
|
5627
|
-
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(),
|
|
5627
|
+
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), ke(t.deleteSet, this.id.client, this.id.clock, this.length), hs(t, n, this.parentSub), this.content.delete(t);
|
|
5628
5628
|
}
|
|
5629
5629
|
}
|
|
5630
5630
|
/**
|
|
@@ -5634,7 +5634,7 @@ class k extends Nn {
|
|
|
5634
5634
|
gc(t, n) {
|
|
5635
5635
|
if (!this.deleted)
|
|
5636
5636
|
throw j();
|
|
5637
|
-
this.content.gc(t), n ?
|
|
5637
|
+
this.content.gc(t), n ? bc(t, this, new M(this.id, this.length)) : this.content = new Gt(this.length);
|
|
5638
5638
|
}
|
|
5639
5639
|
/**
|
|
5640
5640
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -5646,9 +5646,9 @@ class k extends Nn {
|
|
|
5646
5646
|
* @param {number} offset
|
|
5647
5647
|
*/
|
|
5648
5648
|
write(t, n) {
|
|
5649
|
-
const s = n > 0 ? b(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() &
|
|
5649
|
+
const s = n > 0 ? b(this.id.client, this.id.clock + n - 1) : this.origin, r = this.rightOrigin, i = this.parentSub, o = this.content.getRef() & Te | (s === null ? 0 : x) | // origin is defined
|
|
5650
5650
|
(r === null ? 0 : J) | // right origin is defined
|
|
5651
|
-
(i === null ? 0 :
|
|
5651
|
+
(i === null ? 0 : Kt);
|
|
5652
5652
|
if (t.writeInfo(o), s !== null && t.writeLeftID(s), r !== null && t.writeRightID(r), s === null && r === null) {
|
|
5653
5653
|
const c = (
|
|
5654
5654
|
/** @type {AbstractType<any>} */
|
|
@@ -5657,7 +5657,7 @@ class k extends Nn {
|
|
|
5657
5657
|
if (c._item !== void 0) {
|
|
5658
5658
|
const l = c._item;
|
|
5659
5659
|
if (l === null) {
|
|
5660
|
-
const a =
|
|
5660
|
+
const a = mc(c);
|
|
5661
5661
|
t.writeParentInfo(!0), t.writeString(a);
|
|
5662
5662
|
} else
|
|
5663
5663
|
t.writeParentInfo(!1), t.writeLeftID(l.id);
|
|
@@ -5668,35 +5668,35 @@ class k extends Nn {
|
|
|
5668
5668
|
this.content.write(t, n);
|
|
5669
5669
|
}
|
|
5670
5670
|
}
|
|
5671
|
-
const
|
|
5671
|
+
const Er = (e, t) => gl[t & Te](e), gl = [
|
|
5672
5672
|
() => {
|
|
5673
5673
|
j();
|
|
5674
5674
|
},
|
|
5675
5675
|
// GC is not ItemContent
|
|
5676
|
-
|
|
5676
|
+
Zc,
|
|
5677
5677
|
// 1
|
|
5678
|
-
|
|
5678
|
+
nl,
|
|
5679
5679
|
// 2
|
|
5680
|
-
|
|
5680
|
+
qc,
|
|
5681
5681
|
// 3
|
|
5682
|
-
|
|
5682
|
+
rl,
|
|
5683
5683
|
// 4
|
|
5684
|
-
|
|
5684
|
+
tl,
|
|
5685
5685
|
// 5
|
|
5686
|
-
|
|
5686
|
+
el,
|
|
5687
5687
|
// 6
|
|
5688
|
-
|
|
5688
|
+
fl,
|
|
5689
5689
|
// 7
|
|
5690
|
-
|
|
5690
|
+
sl,
|
|
5691
5691
|
// 8
|
|
5692
|
-
|
|
5692
|
+
Qc,
|
|
5693
5693
|
// 9
|
|
5694
5694
|
() => {
|
|
5695
5695
|
j();
|
|
5696
5696
|
}
|
|
5697
5697
|
// 10 - Skip is not ItemContent
|
|
5698
|
-
],
|
|
5699
|
-
class
|
|
5698
|
+
], pl = 10;
|
|
5699
|
+
class U extends Nn {
|
|
5700
5700
|
get deleted() {
|
|
5701
5701
|
return !0;
|
|
5702
5702
|
}
|
|
@@ -5721,7 +5721,7 @@ class T extends Nn {
|
|
|
5721
5721
|
* @param {number} offset
|
|
5722
5722
|
*/
|
|
5723
5723
|
write(t, n) {
|
|
5724
|
-
t.writeInfo(
|
|
5724
|
+
t.writeInfo(pl), m(t.restEncoder, this.length - n);
|
|
5725
5725
|
}
|
|
5726
5726
|
/**
|
|
5727
5727
|
* @param {Transaction} transaction
|
|
@@ -5732,33 +5732,33 @@ class T extends Nn {
|
|
|
5732
5732
|
return null;
|
|
5733
5733
|
}
|
|
5734
5734
|
}
|
|
5735
|
-
const
|
|
5735
|
+
const Cr = (
|
|
5736
5736
|
/** @type {any} */
|
|
5737
5737
|
typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
|
|
5738
|
-
),
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
const
|
|
5738
|
+
), Ar = "__ $YJS$ __";
|
|
5739
|
+
Cr[Ar] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5740
|
+
Cr[Ar] = !0;
|
|
5741
|
+
const wl = 0, ml = (e, t, n) => {
|
|
5742
5742
|
switch (w(e)) {
|
|
5743
|
-
case
|
|
5743
|
+
case wl:
|
|
5744
5744
|
n(t, et(e));
|
|
5745
5745
|
}
|
|
5746
5746
|
}, Pe = 3e4;
|
|
5747
|
-
class
|
|
5747
|
+
class yl extends bn {
|
|
5748
5748
|
/**
|
|
5749
5749
|
* @param {Y.Doc} doc
|
|
5750
5750
|
*/
|
|
5751
5751
|
constructor(t) {
|
|
5752
5752
|
super(), this.doc = t, this.clientID = t.clientID, this.states = /* @__PURE__ */ new Map(), this.meta = /* @__PURE__ */ new Map(), this._checkInterval = /** @type {any} */
|
|
5753
5753
|
setInterval(() => {
|
|
5754
|
-
const n =
|
|
5754
|
+
const n = _e();
|
|
5755
5755
|
this.getLocalState() !== null && Pe / 2 <= n - /** @type {{lastUpdated:number}} */
|
|
5756
5756
|
this.meta.get(this.clientID).lastUpdated && this.setLocalState(this.getLocalState());
|
|
5757
5757
|
const s = [];
|
|
5758
5758
|
this.meta.forEach((r, i) => {
|
|
5759
5759
|
i !== this.clientID && Pe <= n - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
5760
|
-
}), s.length > 0 &&
|
|
5761
|
-
},
|
|
5760
|
+
}), s.length > 0 && Bn(this, s, "timeout");
|
|
5761
|
+
}, P(Pe / 10)), t.on("destroy", () => {
|
|
5762
5762
|
this.destroy();
|
|
5763
5763
|
}), this.setLocalState({});
|
|
5764
5764
|
}
|
|
@@ -5778,10 +5778,10 @@ class wl extends yn {
|
|
|
5778
5778
|
const n = this.clientID, s = this.meta.get(n), r = s === void 0 ? 0 : s.clock + 1, i = this.states.get(n);
|
|
5779
5779
|
t === null ? this.states.delete(n) : this.states.set(n, t), this.meta.set(n, {
|
|
5780
5780
|
clock: r,
|
|
5781
|
-
lastUpdated:
|
|
5781
|
+
lastUpdated: _e()
|
|
5782
5782
|
});
|
|
5783
5783
|
const o = [], c = [], l = [], a = [];
|
|
5784
|
-
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n),
|
|
5784
|
+
t === null ? a.push(n) : i == null ? t != null && o.push(n) : (c.push(n), Vt(i, t) || l.push(n)), (o.length > 0 || l.length > 0 || a.length > 0) && this.emit("change", [{ added: o, updated: l, removed: a }, "local"]), this.emit("update", [{ added: o, updated: c, removed: a }, "local"]);
|
|
5785
5785
|
}
|
|
5786
5786
|
/**
|
|
5787
5787
|
* @param {string} field
|
|
@@ -5801,7 +5801,7 @@ class wl extends yn {
|
|
|
5801
5801
|
return this.states;
|
|
5802
5802
|
}
|
|
5803
5803
|
}
|
|
5804
|
-
const
|
|
5804
|
+
const Bn = (e, t, n) => {
|
|
5805
5805
|
const s = [];
|
|
5806
5806
|
for (let r = 0; r < t.length; r++) {
|
|
5807
5807
|
const i = t[r];
|
|
@@ -5813,15 +5813,15 @@ const $n = (e, t, n) => {
|
|
|
5813
5813
|
);
|
|
5814
5814
|
e.meta.set(i, {
|
|
5815
5815
|
clock: o.clock + 1,
|
|
5816
|
-
lastUpdated:
|
|
5816
|
+
lastUpdated: _e()
|
|
5817
5817
|
});
|
|
5818
5818
|
}
|
|
5819
5819
|
s.push(i);
|
|
5820
5820
|
}
|
|
5821
5821
|
}
|
|
5822
5822
|
s.length > 0 && (e.emit("change", [{ added: [], updated: [], removed: s }, n]), e.emit("update", [{ added: [], updated: [], removed: s }, n]));
|
|
5823
|
-
},
|
|
5824
|
-
const s = t.length, r =
|
|
5823
|
+
}, Ft = (e, t, n = e.states) => {
|
|
5824
|
+
const s = t.length, r = ee();
|
|
5825
5825
|
m(r, s);
|
|
5826
5826
|
for (let i = 0; i < s; i++) {
|
|
5827
5827
|
const o = t[i], c = n.get(o) || null, l = (
|
|
@@ -5830,9 +5830,9 @@ const $n = (e, t, n) => {
|
|
|
5830
5830
|
);
|
|
5831
5831
|
m(r, o), m(r, l), lt(r, JSON.stringify(c));
|
|
5832
5832
|
}
|
|
5833
|
-
return
|
|
5834
|
-
},
|
|
5835
|
-
const s = pt(t), r =
|
|
5833
|
+
return N(r);
|
|
5834
|
+
}, bl = (e, t, n) => {
|
|
5835
|
+
const s = pt(t), r = _e(), i = [], o = [], c = [], l = [], a = w(s);
|
|
5836
5836
|
for (let h = 0; h < a; h++) {
|
|
5837
5837
|
const d = w(s);
|
|
5838
5838
|
let u = w(s);
|
|
@@ -5840,7 +5840,7 @@ const $n = (e, t, n) => {
|
|
|
5840
5840
|
(_ < u || _ === u && f === null && e.states.has(d)) && (f === null ? d === e.clientID && e.getLocalState() != null ? u++ : e.states.delete(d) : e.states.set(d, f), e.meta.set(d, {
|
|
5841
5841
|
clock: u,
|
|
5842
5842
|
lastUpdated: r
|
|
5843
|
-
}), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (
|
|
5843
|
+
}), g === void 0 && f !== null ? i.push(d) : g !== void 0 && f === null ? l.push(d) : f !== null && (Vt(f, p) || c.push(d), o.push(d)));
|
|
5844
5844
|
}
|
|
5845
5845
|
(i.length > 0 || c.length > 0 || l.length > 0) && e.emit("change", [{
|
|
5846
5846
|
added: i,
|
|
@@ -5851,86 +5851,86 @@ const $n = (e, t, n) => {
|
|
|
5851
5851
|
updated: o,
|
|
5852
5852
|
removed: l
|
|
5853
5853
|
}, n]);
|
|
5854
|
-
},
|
|
5855
|
-
m(e,
|
|
5856
|
-
const n =
|
|
5854
|
+
}, Lr = 0, Vn = 1, Ir = 2, dn = (e, t) => {
|
|
5855
|
+
m(e, Lr);
|
|
5856
|
+
const n = pc(t);
|
|
5857
5857
|
L(e, n);
|
|
5858
|
-
},
|
|
5859
|
-
m(e,
|
|
5860
|
-
},
|
|
5858
|
+
}, vr = (e, t, n) => {
|
|
5859
|
+
m(e, Vn), L(e, xn(t, n));
|
|
5860
|
+
}, Sl = (e, t, n) => vr(t, n, I(e)), xr = (e, t, n) => {
|
|
5861
5861
|
try {
|
|
5862
|
-
|
|
5862
|
+
Qs(t, I(e), n);
|
|
5863
5863
|
} catch (s) {
|
|
5864
5864
|
console.error("Caught error while handling a Yjs update", s);
|
|
5865
5865
|
}
|
|
5866
|
-
},
|
|
5867
|
-
m(e,
|
|
5868
|
-
},
|
|
5866
|
+
}, _l = (e, t) => {
|
|
5867
|
+
m(e, Ir), L(e, t);
|
|
5868
|
+
}, kl = xr, Dl = (e, t, n, s) => {
|
|
5869
5869
|
const r = w(e);
|
|
5870
5870
|
switch (r) {
|
|
5871
|
-
case
|
|
5872
|
-
|
|
5871
|
+
case Lr:
|
|
5872
|
+
Sl(e, t, n);
|
|
5873
5873
|
break;
|
|
5874
|
-
case
|
|
5875
|
-
|
|
5874
|
+
case Vn:
|
|
5875
|
+
xr(e, n, s);
|
|
5876
5876
|
break;
|
|
5877
|
-
case
|
|
5878
|
-
|
|
5877
|
+
case Ir:
|
|
5878
|
+
kl(e, n, s);
|
|
5879
5879
|
break;
|
|
5880
5880
|
default:
|
|
5881
5881
|
throw new Error("Unknown message type");
|
|
5882
5882
|
}
|
|
5883
5883
|
return r;
|
|
5884
5884
|
};
|
|
5885
|
-
var it = 0,
|
|
5886
|
-
function
|
|
5885
|
+
var it = 0, Tr = 3, Ct = 1, El = 2, Cl = typeof window > "u";
|
|
5886
|
+
function Al(e, t) {
|
|
5887
5887
|
if (!e)
|
|
5888
5888
|
throw new Error(t);
|
|
5889
5889
|
}
|
|
5890
|
-
var
|
|
5891
|
-
|
|
5890
|
+
var oe = [];
|
|
5891
|
+
oe[it] = (e, t, n, s, r) => {
|
|
5892
5892
|
v(e, it);
|
|
5893
|
-
const i =
|
|
5893
|
+
const i = Dl(
|
|
5894
5894
|
t,
|
|
5895
5895
|
e,
|
|
5896
5896
|
n.doc,
|
|
5897
5897
|
n
|
|
5898
5898
|
);
|
|
5899
|
-
s && i ===
|
|
5899
|
+
s && i === Vn && !n.synced && (n.synced = !0);
|
|
5900
5900
|
};
|
|
5901
|
-
|
|
5901
|
+
oe[Tr] = (e, t, n, s, r) => {
|
|
5902
5902
|
v(e, Ct), kt(
|
|
5903
5903
|
e,
|
|
5904
|
-
|
|
5904
|
+
Ft(
|
|
5905
5905
|
n.awareness,
|
|
5906
5906
|
Array.from(n.awareness.getStates().keys())
|
|
5907
5907
|
)
|
|
5908
5908
|
);
|
|
5909
5909
|
};
|
|
5910
|
-
|
|
5911
|
-
|
|
5910
|
+
oe[Ct] = (e, t, n, s, r) => {
|
|
5911
|
+
bl(
|
|
5912
5912
|
n.awareness,
|
|
5913
|
-
|
|
5913
|
+
Ci(t),
|
|
5914
5914
|
n
|
|
5915
5915
|
);
|
|
5916
5916
|
};
|
|
5917
|
-
|
|
5918
|
-
|
|
5917
|
+
oe[El] = (e, t, n, s, r) => {
|
|
5918
|
+
ml(
|
|
5919
5919
|
t,
|
|
5920
5920
|
n.doc,
|
|
5921
|
-
(i, o) =>
|
|
5921
|
+
(i, o) => Ll(n, o)
|
|
5922
5922
|
);
|
|
5923
5923
|
};
|
|
5924
|
-
var
|
|
5925
|
-
function
|
|
5924
|
+
var ps = 3e4;
|
|
5925
|
+
function Ll(e, t) {
|
|
5926
5926
|
console.warn(`Permission denied to access ${e.url}.
|
|
5927
5927
|
${t}`);
|
|
5928
5928
|
}
|
|
5929
5929
|
function Mr(e, t, n) {
|
|
5930
|
-
const s =
|
|
5930
|
+
const s = Di(t), r = $(), i = xs(s), o = e.messageHandlers[i];
|
|
5931
5931
|
return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
|
|
5932
5932
|
}
|
|
5933
|
-
function
|
|
5933
|
+
function Ur(e) {
|
|
5934
5934
|
if (e.shouldConnect && e.ws === null) {
|
|
5935
5935
|
if (!e._WS)
|
|
5936
5936
|
throw new Error(
|
|
@@ -5940,13 +5940,13 @@ function xr(e) {
|
|
|
5940
5940
|
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.onmessage = (n) => {
|
|
5941
5941
|
if (typeof n.data == "string")
|
|
5942
5942
|
return;
|
|
5943
|
-
e.wsLastMessageReceived =
|
|
5943
|
+
e.wsLastMessageReceived = en();
|
|
5944
5944
|
const s = Mr(e, new Uint8Array(n.data), !0);
|
|
5945
|
-
|
|
5945
|
+
mn(s) > 1 && Nt(T(s), t);
|
|
5946
5946
|
}, t.onerror = (n) => {
|
|
5947
5947
|
e.emit("connection-error", [n, e]);
|
|
5948
5948
|
}, t.onclose = (n) => {
|
|
5949
|
-
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1,
|
|
5949
|
+
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, Bn(
|
|
5950
5950
|
e.awareness,
|
|
5951
5951
|
Array.from(e.awareness.getStates().keys()).filter(
|
|
5952
5952
|
(s) => s !== e.doc.clientID
|
|
@@ -5957,28 +5957,28 @@ function xr(e) {
|
|
|
5957
5957
|
status: "disconnected"
|
|
5958
5958
|
}
|
|
5959
5959
|
])) : e.wsUnsuccessfulReconnects++, setTimeout(
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5960
|
+
Ur,
|
|
5961
|
+
Ls(
|
|
5962
|
+
fi(2, e.wsUnsuccessfulReconnects) * 100,
|
|
5963
5963
|
e.maxBackoffTime
|
|
5964
5964
|
),
|
|
5965
5965
|
e
|
|
5966
5966
|
);
|
|
5967
5967
|
}, t.onopen = () => {
|
|
5968
|
-
e.wsLastMessageReceived =
|
|
5968
|
+
e.wsLastMessageReceived = en(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [
|
|
5969
5969
|
{
|
|
5970
5970
|
status: "connected"
|
|
5971
5971
|
}
|
|
5972
5972
|
]);
|
|
5973
|
-
const n =
|
|
5974
|
-
if (v(n, it),
|
|
5975
|
-
const s =
|
|
5973
|
+
const n = $();
|
|
5974
|
+
if (v(n, it), dn(n, e.doc), Nt(T(n), t), e.awareness.getLocalState() !== null) {
|
|
5975
|
+
const s = $();
|
|
5976
5976
|
v(s, Ct), kt(
|
|
5977
5977
|
s,
|
|
5978
|
-
|
|
5978
|
+
Ft(e.awareness, [
|
|
5979
5979
|
e.doc.clientID
|
|
5980
5980
|
])
|
|
5981
|
-
), Nt(
|
|
5981
|
+
), Nt(T(s), t);
|
|
5982
5982
|
}
|
|
5983
5983
|
}, e.emit("status", [
|
|
5984
5984
|
{
|
|
@@ -5987,22 +5987,22 @@ function xr(e) {
|
|
|
5987
5987
|
]);
|
|
5988
5988
|
}
|
|
5989
5989
|
}
|
|
5990
|
-
function
|
|
5990
|
+
function Ge(e, t) {
|
|
5991
5991
|
const n = e.ws;
|
|
5992
5992
|
e.wsconnected && n && n.readyState === n.OPEN && Nt(t, n), e.bcconnected && bt(e.bcChannel, t, e);
|
|
5993
5993
|
}
|
|
5994
|
-
var
|
|
5994
|
+
var Il = typeof WebSocket > "u" ? null : WebSocket, vl = class extends Vi {
|
|
5995
5995
|
constructor(t, n, s, {
|
|
5996
5996
|
connect: r = !0,
|
|
5997
|
-
awareness: i = new
|
|
5997
|
+
awareness: i = new yl(s),
|
|
5998
5998
|
params: o = {},
|
|
5999
|
-
WebSocketPolyfill: c =
|
|
5999
|
+
WebSocketPolyfill: c = Il,
|
|
6000
6000
|
// Optionally provide a WebSocket polyfill
|
|
6001
6001
|
resyncInterval: l = -1,
|
|
6002
6002
|
// Request server state every `resyncInterval` milliseconds
|
|
6003
6003
|
maxBackoffTime: a = 2500,
|
|
6004
6004
|
// Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
6005
|
-
disableBc: h =
|
|
6005
|
+
disableBc: h = Cl
|
|
6006
6006
|
// Disable cross-tab BroadcastChannel communication
|
|
6007
6007
|
} = {}) {
|
|
6008
6008
|
super();
|
|
@@ -6032,39 +6032,39 @@ var Al = typeof WebSocket > "u" ? null : WebSocket, Ll = class extends $i {
|
|
|
6032
6032
|
y(this, "_checkInterval");
|
|
6033
6033
|
for (; t[t.length - 1] === "/"; )
|
|
6034
6034
|
t = t.slice(0, t.length - 1);
|
|
6035
|
-
const d =
|
|
6036
|
-
this.maxBackoffTime = a, this.bcChannel = t + "/" + n, this.url = t + "/" + n + (d.length === 0 ? "" : "?" + d), this.roomname = n, this.doc = s, this._WS = c, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers =
|
|
6035
|
+
const d = Fi(o);
|
|
6036
|
+
this.maxBackoffTime = a, this.bcChannel = t + "/" + n, this.url = t + "/" + n + (d.length === 0 ? "" : "?" + d), this.roomname = n, this.doc = s, this._WS = c, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = h, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = oe.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, l > 0 && (this._resyncInterval = /** @type {any} */
|
|
6037
6037
|
setInterval(() => {
|
|
6038
6038
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
6039
|
-
const u =
|
|
6040
|
-
v(u, it),
|
|
6039
|
+
const u = $();
|
|
6040
|
+
v(u, it), dn(u, s), Nt(T(u), this.ws);
|
|
6041
6041
|
}
|
|
6042
6042
|
}, l)), this._bcSubscriber = (u, f) => {
|
|
6043
6043
|
if (f !== this) {
|
|
6044
6044
|
const g = Mr(this, new Uint8Array(u), !1);
|
|
6045
|
-
|
|
6045
|
+
mn(g) > 1 && bt(this.bcChannel, T(g), this);
|
|
6046
6046
|
}
|
|
6047
6047
|
}, this._updateHandler = (u, f) => {
|
|
6048
6048
|
if (f !== this) {
|
|
6049
|
-
const g =
|
|
6050
|
-
v(g, it),
|
|
6049
|
+
const g = $();
|
|
6050
|
+
v(g, it), _l(g, u), Ge(this, T(g));
|
|
6051
6051
|
}
|
|
6052
6052
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: u, updated: f, removed: g }, p) => {
|
|
6053
|
-
const _ = u.concat(f).concat(g), Y =
|
|
6053
|
+
const _ = u.concat(f).concat(g), Y = $();
|
|
6054
6054
|
v(Y, Ct), kt(
|
|
6055
6055
|
Y,
|
|
6056
|
-
|
|
6057
|
-
),
|
|
6056
|
+
Ft(i, _)
|
|
6057
|
+
), Ge(this, T(Y));
|
|
6058
6058
|
}, this._unloadHandler = () => {
|
|
6059
|
-
|
|
6059
|
+
Bn(
|
|
6060
6060
|
this.awareness,
|
|
6061
6061
|
[s.clientID],
|
|
6062
6062
|
"window unload"
|
|
6063
6063
|
);
|
|
6064
6064
|
}, typeof window < "u" ? window.addEventListener("unload", this._unloadHandler) : typeof process < "u" && typeof process.on == "function" && process.on("exit", this._unloadHandler), i.on("update", this._awarenessUpdateHandler), this._checkInterval = /** @type {any} */
|
|
6065
6065
|
setInterval(() => {
|
|
6066
|
-
this.wsconnected &&
|
|
6067
|
-
},
|
|
6066
|
+
this.wsconnected && ps < en() - this.wsLastMessageReceived && (Al(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
6067
|
+
}, ps / 10), r && this.connect();
|
|
6068
6068
|
}
|
|
6069
6069
|
/**
|
|
6070
6070
|
* @type {boolean}
|
|
@@ -6081,48 +6081,48 @@ var Al = typeof WebSocket > "u" ? null : WebSocket, Ll = class extends $i {
|
|
|
6081
6081
|
connectBc() {
|
|
6082
6082
|
if (this.disableBc)
|
|
6083
6083
|
return;
|
|
6084
|
-
this.bcconnected || (
|
|
6085
|
-
const t =
|
|
6086
|
-
v(t, it),
|
|
6087
|
-
const n =
|
|
6088
|
-
v(n, it),
|
|
6089
|
-
const s =
|
|
6090
|
-
v(s,
|
|
6084
|
+
this.bcconnected || (Ni(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
6085
|
+
const t = $();
|
|
6086
|
+
v(t, it), dn(t, this.doc), bt(this.bcChannel, T(t), this);
|
|
6087
|
+
const n = $();
|
|
6088
|
+
v(n, it), vr(n, this.doc), bt(this.bcChannel, T(n), this);
|
|
6089
|
+
const s = $();
|
|
6090
|
+
v(s, Tr), bt(
|
|
6091
6091
|
this.bcChannel,
|
|
6092
|
-
|
|
6092
|
+
T(s),
|
|
6093
6093
|
this
|
|
6094
6094
|
);
|
|
6095
|
-
const r =
|
|
6095
|
+
const r = $();
|
|
6096
6096
|
v(r, Ct), kt(
|
|
6097
6097
|
r,
|
|
6098
|
-
|
|
6098
|
+
Ft(this.awareness, [
|
|
6099
6099
|
this.doc.clientID
|
|
6100
6100
|
])
|
|
6101
6101
|
), bt(
|
|
6102
6102
|
this.bcChannel,
|
|
6103
|
-
|
|
6103
|
+
T(r),
|
|
6104
6104
|
this
|
|
6105
6105
|
);
|
|
6106
6106
|
}
|
|
6107
6107
|
disconnectBc() {
|
|
6108
|
-
const t =
|
|
6108
|
+
const t = $();
|
|
6109
6109
|
v(t, Ct), kt(
|
|
6110
6110
|
t,
|
|
6111
|
-
|
|
6111
|
+
Ft(
|
|
6112
6112
|
this.awareness,
|
|
6113
6113
|
[this.doc.clientID],
|
|
6114
6114
|
/* @__PURE__ */ new Map()
|
|
6115
6115
|
)
|
|
6116
|
-
),
|
|
6116
|
+
), Ge(this, T(t)), this.bcconnected && (Bi(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
6117
6117
|
}
|
|
6118
6118
|
disconnect() {
|
|
6119
6119
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
6120
6120
|
}
|
|
6121
6121
|
connect() {
|
|
6122
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
6122
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (Ur(this), this.connectBc());
|
|
6123
6123
|
}
|
|
6124
6124
|
};
|
|
6125
|
-
function
|
|
6125
|
+
function xl() {
|
|
6126
6126
|
if (crypto.randomUUID)
|
|
6127
6127
|
return crypto.randomUUID();
|
|
6128
6128
|
let e = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
@@ -6131,27 +6131,27 @@ function Il() {
|
|
|
6131
6131
|
return e > 0 ? (s = (e + s) % 16 | 0, e = Math.floor(e / 16)) : (s = (t + s) % 16 | 0, t = Math.floor(t / 16)), (n === "x" ? s : s & 3 | 8).toString(16);
|
|
6132
6132
|
});
|
|
6133
6133
|
}
|
|
6134
|
-
function
|
|
6134
|
+
function ws(e, t, n) {
|
|
6135
6135
|
if (typeof e !== n)
|
|
6136
6136
|
throw new Error(
|
|
6137
6137
|
`Invalid "${t}" parameter provided to YPartyKitProvider. Expected: ${n}, received: ${e}`
|
|
6138
6138
|
);
|
|
6139
6139
|
}
|
|
6140
|
-
var ot,
|
|
6140
|
+
var ot, _s, Tl = (_s = class extends vl {
|
|
6141
6141
|
constructor(t, n, s, r = {}) {
|
|
6142
|
-
|
|
6143
|
-
const i = `${t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss"}://${t}${r.party ? `/parties/${r.party}` : "/party"}`, o = r.connectionId ??
|
|
6142
|
+
ws(t, "host", "string"), ws(n, "room", "string"), t = t.replace(/^(http|https|ws|wss):\/\//, ""), t.endsWith("/") && t.slice(0, -1);
|
|
6143
|
+
const i = `${t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss"}://${t}${r.party ? `/parties/${r.party}` : "/party"}`, o = r.connectionId ?? xl(), { params: c, connect: l = !0, ...a } = r, h = {
|
|
6144
6144
|
...a,
|
|
6145
6145
|
connect: !1
|
|
6146
6146
|
};
|
|
6147
6147
|
super(i, n, s ?? new wt(), h);
|
|
6148
6148
|
y(this, "id");
|
|
6149
|
-
|
|
6150
|
-
this.id = o,
|
|
6149
|
+
Hn(this, ot, void 0);
|
|
6150
|
+
this.id = o, jn(this, ot, c), l && this.connect();
|
|
6151
6151
|
}
|
|
6152
6152
|
connect() {
|
|
6153
6153
|
Promise.resolve(
|
|
6154
|
-
typeof
|
|
6154
|
+
typeof le(this, ot) == "function" ? le(this, ot).call(this) : le(this, ot)
|
|
6155
6155
|
).then((t) => {
|
|
6156
6156
|
const n = new URLSearchParams([["_pk", this.id]]);
|
|
6157
6157
|
if (t)
|
|
@@ -6163,10 +6163,10 @@ var ot, bs, vl = (bs = class extends Ll {
|
|
|
6163
6163
|
throw console.error("Failed to open connecton to PartyKit", t), new Error(t);
|
|
6164
6164
|
});
|
|
6165
6165
|
}
|
|
6166
|
-
}, ot = new WeakMap(),
|
|
6167
|
-
const yt = (e) =>
|
|
6166
|
+
}, ot = new WeakMap(), _s);
|
|
6167
|
+
const yt = (e) => xt((t, n) => {
|
|
6168
6168
|
e.onerror = (s) => n(new Error(s.target.error)), e.onsuccess = (s) => t(s.target.result);
|
|
6169
|
-
}), Ml = (e, t) =>
|
|
6169
|
+
}), Ml = (e, t) => xt((n, s) => {
|
|
6170
6170
|
const r = indexedDB.open(e);
|
|
6171
6171
|
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(G(i.target.error)), r.onsuccess = (i) => {
|
|
6172
6172
|
const o = i.target.result;
|
|
@@ -6174,47 +6174,47 @@ const yt = (e) => Mt((t, n) => {
|
|
|
6174
6174
|
o.close();
|
|
6175
6175
|
}, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), n(o);
|
|
6176
6176
|
};
|
|
6177
|
-
}),
|
|
6177
|
+
}), Ul = (e) => yt(indexedDB.deleteDatabase(e)), Ol = (e, t) => t.forEach(
|
|
6178
6178
|
(n) => (
|
|
6179
6179
|
// @ts-ignore
|
|
6180
6180
|
e.createObjectStore.apply(e, n)
|
|
6181
6181
|
)
|
|
6182
|
-
),
|
|
6182
|
+
), $t = (e, t, n = "readwrite") => {
|
|
6183
6183
|
const s = e.transaction(t, n);
|
|
6184
|
-
return t.map((r) =>
|
|
6185
|
-
},
|
|
6184
|
+
return t.map((r) => jl(s, r));
|
|
6185
|
+
}, Or = (e, t) => yt(e.count(t)), Rl = (e, t) => yt(e.get(t)), Rr = (e, t) => yt(e.delete(t)), $l = (e, t, n) => yt(e.put(t, n)), fn = (e, t) => yt(e.add(t)), Nl = (e, t, n) => yt(e.getAll(t, n)), Bl = (e, t, n) => {
|
|
6186
6186
|
let s = null;
|
|
6187
|
-
return
|
|
6188
|
-
},
|
|
6187
|
+
return Hl(e, t, (r) => (s = r, !1), n).then(() => s);
|
|
6188
|
+
}, Vl = (e, t = null) => Bl(e, t, "prev"), Fl = (e, t) => xt((n, s) => {
|
|
6189
6189
|
e.onerror = s, e.onsuccess = async (r) => {
|
|
6190
6190
|
const i = r.target.result;
|
|
6191
6191
|
if (i === null || await t(i) === !1)
|
|
6192
6192
|
return n();
|
|
6193
6193
|
i.continue();
|
|
6194
6194
|
};
|
|
6195
|
-
}),
|
|
6195
|
+
}), Hl = (e, t, n, s = "next") => Fl(e.openKeyCursor(t, s), (r) => n(r.key)), jl = (e, t) => e.objectStore(t), zl = (e, t) => IDBKeyRange.upperBound(e, t), Kl = (e, t) => IDBKeyRange.lowerBound(e, t), qe = "custom", $r = "updates", Nr = 500, Br = (e, t = () => {
|
|
6196
6196
|
}, n = () => {
|
|
6197
6197
|
}) => {
|
|
6198
|
-
const [s] =
|
|
6198
|
+
const [s] = $t(
|
|
6199
6199
|
/** @type {IDBDatabase} */
|
|
6200
6200
|
e.db,
|
|
6201
|
-
[
|
|
6201
|
+
[$r]
|
|
6202
6202
|
);
|
|
6203
|
-
return
|
|
6203
|
+
return Nl(s, Kl(e._dbref, !1)).then((r) => {
|
|
6204
6204
|
e._destroyed || (t(s), S(e.doc, () => {
|
|
6205
|
-
r.forEach((i) =>
|
|
6205
|
+
r.forEach((i) => Qs(e.doc, i));
|
|
6206
6206
|
}, e, !1), n(s));
|
|
6207
|
-
}).then(() =>
|
|
6207
|
+
}).then(() => Vl(s).then((r) => {
|
|
6208
6208
|
e._dbref = r + 1;
|
|
6209
|
-
})).then(() =>
|
|
6209
|
+
})).then(() => Or(s).then((r) => {
|
|
6210
6210
|
e._dbsize = r;
|
|
6211
6211
|
})).then(() => s);
|
|
6212
|
-
},
|
|
6213
|
-
(t || e._dbsize >=
|
|
6212
|
+
}, Yl = (e, t = !0) => Br(e).then((n) => {
|
|
6213
|
+
(t || e._dbsize >= Nr) && fn(n, xn(e.doc)).then(() => Rr(n, zl(e._dbref, !0))).then(() => Or(n).then((s) => {
|
|
6214
6214
|
e._dbsize = s;
|
|
6215
6215
|
}));
|
|
6216
6216
|
});
|
|
6217
|
-
class
|
|
6217
|
+
class Xl extends bn {
|
|
6218
6218
|
/**
|
|
6219
6219
|
* @param {string} name
|
|
6220
6220
|
* @param {Y.Doc} doc
|
|
@@ -6222,25 +6222,25 @@ class Kl extends yn {
|
|
|
6222
6222
|
constructor(t, n) {
|
|
6223
6223
|
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = Ml(
|
|
6224
6224
|
t,
|
|
6225
|
-
(s) =>
|
|
6225
|
+
(s) => Ol(s, [
|
|
6226
6226
|
["updates", { autoIncrement: !0 }],
|
|
6227
6227
|
["custom"]
|
|
6228
6228
|
])
|
|
6229
|
-
), this.whenSynced =
|
|
6230
|
-
this.db = s,
|
|
6229
|
+
), this.whenSynced = xt((s) => this.on("synced", () => s(this))), this._db.then((s) => {
|
|
6230
|
+
this.db = s, Br(this, (o) => fn(o, xn(n)), () => {
|
|
6231
6231
|
if (this._destroyed)
|
|
6232
6232
|
return this;
|
|
6233
6233
|
this.synced = !0, this.emit("synced", [this]);
|
|
6234
6234
|
});
|
|
6235
6235
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (s, r) => {
|
|
6236
6236
|
if (this.db && r !== this) {
|
|
6237
|
-
const [i] =
|
|
6237
|
+
const [i] = $t(
|
|
6238
6238
|
/** @type {IDBDatabase} */
|
|
6239
6239
|
this.db,
|
|
6240
|
-
[
|
|
6240
|
+
[$r]
|
|
6241
6241
|
);
|
|
6242
|
-
|
|
6243
|
-
|
|
6242
|
+
fn(i, s), ++this._dbsize >= Nr && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
|
|
6243
|
+
Yl(this, !1), this._storeTimeoutId = null;
|
|
6244
6244
|
}, this._storeTimeout));
|
|
6245
6245
|
}
|
|
6246
6246
|
}, n.on("update", this._storeUpdate), this.destroy = this.destroy.bind(this), n.on("destroy", this.destroy);
|
|
@@ -6257,7 +6257,7 @@ class Kl extends yn {
|
|
|
6257
6257
|
*/
|
|
6258
6258
|
clearData() {
|
|
6259
6259
|
return this.destroy().then(() => {
|
|
6260
|
-
|
|
6260
|
+
Ul(this.name);
|
|
6261
6261
|
});
|
|
6262
6262
|
}
|
|
6263
6263
|
/**
|
|
@@ -6266,8 +6266,8 @@ class Kl extends yn {
|
|
|
6266
6266
|
*/
|
|
6267
6267
|
get(t) {
|
|
6268
6268
|
return this._db.then((n) => {
|
|
6269
|
-
const [s] =
|
|
6270
|
-
return
|
|
6269
|
+
const [s] = $t(n, [qe], "readonly");
|
|
6270
|
+
return Rl(s, t);
|
|
6271
6271
|
});
|
|
6272
6272
|
}
|
|
6273
6273
|
/**
|
|
@@ -6277,8 +6277,8 @@ class Kl extends yn {
|
|
|
6277
6277
|
*/
|
|
6278
6278
|
set(t, n) {
|
|
6279
6279
|
return this._db.then((s) => {
|
|
6280
|
-
const [r] =
|
|
6281
|
-
return
|
|
6280
|
+
const [r] = $t(s, [qe]);
|
|
6281
|
+
return $l(r, n, t);
|
|
6282
6282
|
});
|
|
6283
6283
|
}
|
|
6284
6284
|
/**
|
|
@@ -6287,44 +6287,44 @@ class Kl extends yn {
|
|
|
6287
6287
|
*/
|
|
6288
6288
|
del(t) {
|
|
6289
6289
|
return this._db.then((n) => {
|
|
6290
|
-
const [s] =
|
|
6291
|
-
return
|
|
6290
|
+
const [s] = $t(n, [qe]);
|
|
6291
|
+
return Rr(s, t);
|
|
6292
6292
|
});
|
|
6293
6293
|
}
|
|
6294
6294
|
}
|
|
6295
|
-
const
|
|
6296
|
-
var
|
|
6297
|
-
function
|
|
6295
|
+
const Jl = "can-duplicate-to";
|
|
6296
|
+
var Be = /* @__PURE__ */ ((e) => (e.CanPlay = "can-play", e.CanMove = "can-move", e.CanSpin = "can-spin", e.CanGrow = "can-grow", e.CanToggle = "can-toggle", e.CanDuplicate = "can-duplicate", e.CanHover = "can-hover", e.CanResize = "can-resize", e.CanMirror = "can-mirror", e))(Be || {});
|
|
6297
|
+
function Wl(e) {
|
|
6298
6298
|
return e.id;
|
|
6299
6299
|
}
|
|
6300
|
-
const
|
|
6300
|
+
const Vr = `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>")
|
|
6301
6301
|
16 0,
|
|
6302
|
-
auto`,
|
|
6303
|
-
function
|
|
6302
|
+
auto`, Pl = `url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='48' viewport='0 0 100 100' style='fill:black;font-size:24px;'><text y='50%'>✂️</text></svg>") 16 0,auto`;
|
|
6303
|
+
function ms(e, { getData: t, getElement: n, getLocalData: s, setLocalData: r }) {
|
|
6304
6304
|
const i = t(), o = s(), c = n();
|
|
6305
6305
|
if (o.isHovering = !0, e.altKey) {
|
|
6306
6306
|
if (i.scale <= 0.5) {
|
|
6307
6307
|
c.style.cursor = "not-allowed";
|
|
6308
6308
|
return;
|
|
6309
6309
|
}
|
|
6310
|
-
c.style.cursor =
|
|
6310
|
+
c.style.cursor = Pl;
|
|
6311
6311
|
} else {
|
|
6312
6312
|
if (i.scale >= i.maxScale) {
|
|
6313
6313
|
c.style.cursor = "not-allowed";
|
|
6314
6314
|
return;
|
|
6315
6315
|
}
|
|
6316
|
-
c.style.cursor =
|
|
6316
|
+
c.style.cursor = Vr;
|
|
6317
6317
|
}
|
|
6318
6318
|
r(o);
|
|
6319
6319
|
}
|
|
6320
|
-
function
|
|
6320
|
+
function fe(e) {
|
|
6321
6321
|
if ("touches" in e) {
|
|
6322
6322
|
const { clientX: t, clientY: n } = e.touches[0];
|
|
6323
6323
|
return { clientX: t, clientY: n };
|
|
6324
6324
|
}
|
|
6325
6325
|
return { clientX: e.clientX, clientY: e.clientY };
|
|
6326
6326
|
}
|
|
6327
|
-
const
|
|
6327
|
+
const Gl = {
|
|
6328
6328
|
[
|
|
6329
6329
|
"can-move"
|
|
6330
6330
|
/* CanMove */
|
|
@@ -6335,14 +6335,14 @@ const Pl = {
|
|
|
6335
6335
|
e.style.transform = `translate(${t.x}px, ${t.y}px)`;
|
|
6336
6336
|
},
|
|
6337
6337
|
onDragStart: (e, { setLocalData: t }) => {
|
|
6338
|
-
const { clientX: n, clientY: s } =
|
|
6338
|
+
const { clientX: n, clientY: s } = fe(e);
|
|
6339
6339
|
t({
|
|
6340
6340
|
startMouseX: n,
|
|
6341
6341
|
startMouseY: s
|
|
6342
6342
|
});
|
|
6343
6343
|
},
|
|
6344
6344
|
onDrag: (e, { data: t, localData: n, setData: s, setLocalData: r, element: i }) => {
|
|
6345
|
-
const { clientX: o, clientY: c } =
|
|
6345
|
+
const { clientX: o, clientY: c } = fe(e), { top: l, left: a, bottom: h, right: d } = i.getBoundingClientRect();
|
|
6346
6346
|
d > window.outerWidth && o > n.startMouseX || h > window.innerHeight && c > n.startMouseY || a < 0 && o < n.startMouseX || l < 0 && c < n.startMouseY || (s({
|
|
6347
6347
|
x: t.x + o - n.startMouseX,
|
|
6348
6348
|
y: t.y + c - n.startMouseY
|
|
@@ -6360,13 +6360,13 @@ const Pl = {
|
|
|
6360
6360
|
e.style.transform = `rotate(${t.rotation}deg)`;
|
|
6361
6361
|
},
|
|
6362
6362
|
onDragStart: (e, { setLocalData: t }) => {
|
|
6363
|
-
const { clientX: n } =
|
|
6363
|
+
const { clientX: n } = fe(e);
|
|
6364
6364
|
t({
|
|
6365
6365
|
startMouseX: n
|
|
6366
6366
|
});
|
|
6367
6367
|
},
|
|
6368
6368
|
onDrag: (e, { data: t, localData: n, setData: s, setLocalData: r }) => {
|
|
6369
|
-
const { clientX: i } =
|
|
6369
|
+
const { clientX: i } = fe(e);
|
|
6370
6370
|
let o = Math.abs(i - n.startMouseX) * 2, c = t.rotation;
|
|
6371
6371
|
i > n.startMouseX ? c += o : i < n.startMouseX && (c -= o), s({ rotation: c }), r({ startMouseX: i });
|
|
6372
6372
|
},
|
|
@@ -6403,7 +6403,7 @@ const Pl = {
|
|
|
6403
6403
|
return;
|
|
6404
6404
|
i -= 0.1;
|
|
6405
6405
|
} else {
|
|
6406
|
-
if (n.style.cursor =
|
|
6406
|
+
if (n.style.cursor = Vr, t.scale >= r.maxScale)
|
|
6407
6407
|
return;
|
|
6408
6408
|
i += 0.1;
|
|
6409
6409
|
}
|
|
@@ -6411,8 +6411,8 @@ const Pl = {
|
|
|
6411
6411
|
},
|
|
6412
6412
|
onMount: (e) => {
|
|
6413
6413
|
e.getElement().addEventListener("mouseenter", (t) => {
|
|
6414
|
-
|
|
6415
|
-
const n = (s) =>
|
|
6414
|
+
ms(t, e);
|
|
6415
|
+
const n = (s) => ms(s, e);
|
|
6416
6416
|
document.addEventListener("keydown", n), document.addEventListener("keyup", n), e.getElement().addEventListener("mouseleave", (s) => {
|
|
6417
6417
|
document.removeEventListener("keydown", n), document.removeEventListener("keyup", n);
|
|
6418
6418
|
});
|
|
@@ -6442,7 +6442,7 @@ const Pl = {
|
|
|
6442
6442
|
);
|
|
6443
6443
|
return;
|
|
6444
6444
|
}
|
|
6445
|
-
const l = s.getAttribute(
|
|
6445
|
+
const l = s.getAttribute(Jl);
|
|
6446
6446
|
function a(d) {
|
|
6447
6447
|
if (l) {
|
|
6448
6448
|
const u = document.getElementById(l) || document.querySelector(l);
|
|
@@ -6486,37 +6486,52 @@ const Pl = {
|
|
|
6486
6486
|
"can-mirror"
|
|
6487
6487
|
/* CanMirror */
|
|
6488
6488
|
]: {
|
|
6489
|
-
defaultData: (e) =>
|
|
6489
|
+
defaultData: (e) => Ut(e),
|
|
6490
6490
|
onMount: ({ getElement: e, setData: t, getData: n }) => {
|
|
6491
6491
|
const s = e();
|
|
6492
|
-
|
|
6493
|
-
const i = n();
|
|
6494
|
-
|
|
6495
|
-
const o = ql(i, r);
|
|
6496
|
-
console.log("STATE UPDATED", o), t(o);
|
|
6492
|
+
ql(s, (r) => {
|
|
6493
|
+
const i = n(), o = Ql(i, r);
|
|
6494
|
+
t(o);
|
|
6497
6495
|
});
|
|
6498
6496
|
},
|
|
6499
6497
|
updateElement: ({ element: e, data: t }) => {
|
|
6500
|
-
const n =
|
|
6501
|
-
|
|
6498
|
+
const n = Ut(e);
|
|
6499
|
+
qt(n, t) || Fr(e, t);
|
|
6502
6500
|
}
|
|
6503
6501
|
}
|
|
6504
6502
|
};
|
|
6505
|
-
function
|
|
6506
|
-
|
|
6503
|
+
function ys(e) {
|
|
6504
|
+
return e.nodeType === "HTMLElement";
|
|
6505
|
+
}
|
|
6506
|
+
function qt(e, t) {
|
|
6507
|
+
if (e.nodeType !== t.nodeType)
|
|
6507
6508
|
return !1;
|
|
6508
|
-
|
|
6509
|
-
|
|
6509
|
+
if (e.nodeType === "Text" && t.nodeType === "Text")
|
|
6510
|
+
return e.textContent === t.textContent;
|
|
6511
|
+
if (ys(e) && ys(t)) {
|
|
6512
|
+
if (e.tagName !== t.tagName || Object.keys(e.attributes).length !== Object.keys(t.attributes).length)
|
|
6510
6513
|
return !1;
|
|
6511
|
-
|
|
6512
|
-
|
|
6513
|
-
|
|
6514
|
-
if (
|
|
6514
|
+
for (const [n, s] of Object.entries(e.attributes))
|
|
6515
|
+
if (t.attributes[n] !== s)
|
|
6516
|
+
return !1;
|
|
6517
|
+
if (e.children.length !== t.children.length)
|
|
6515
6518
|
return !1;
|
|
6519
|
+
for (let n = 0; n < e.children.length; n++)
|
|
6520
|
+
if (!qt(e.children[n], t.children[n]))
|
|
6521
|
+
return !1;
|
|
6522
|
+
}
|
|
6516
6523
|
return !0;
|
|
6517
6524
|
}
|
|
6518
|
-
function
|
|
6519
|
-
const s = {
|
|
6525
|
+
function ql(e, t, n) {
|
|
6526
|
+
const s = {
|
|
6527
|
+
childList: !0,
|
|
6528
|
+
attributes: !0,
|
|
6529
|
+
// NOTE: this makes it such that innerhtml changes aren't picked up.. for now let's just be okay with that
|
|
6530
|
+
// can get around this by putting subtree to true but ignoring any target that isn't the immediate element's content
|
|
6531
|
+
subtree: !1,
|
|
6532
|
+
characterData: !0,
|
|
6533
|
+
...n
|
|
6534
|
+
}, r = (o) => {
|
|
6520
6535
|
const c = o.filter((l) => {
|
|
6521
6536
|
if (l.target !== e)
|
|
6522
6537
|
return !1;
|
|
@@ -6534,68 +6549,84 @@ function Wl(e, t, n) {
|
|
|
6534
6549
|
}, i = new MutationObserver(r);
|
|
6535
6550
|
return i.observe(e, s), i;
|
|
6536
6551
|
}
|
|
6537
|
-
function
|
|
6552
|
+
function Zl(e) {
|
|
6538
6553
|
return JSON.parse(JSON.stringify(e));
|
|
6539
6554
|
}
|
|
6540
|
-
function
|
|
6541
|
-
let n =
|
|
6555
|
+
function Ql(e, t) {
|
|
6556
|
+
let n = Zl(e);
|
|
6542
6557
|
return t.forEach((s) => {
|
|
6543
6558
|
switch (s.type) {
|
|
6544
6559
|
case "attributes":
|
|
6545
|
-
|
|
6560
|
+
ta(n, s);
|
|
6546
6561
|
break;
|
|
6547
6562
|
case "childList":
|
|
6548
|
-
|
|
6563
|
+
ea(n, s);
|
|
6549
6564
|
break;
|
|
6550
6565
|
case "characterData":
|
|
6551
|
-
|
|
6566
|
+
na(n, s);
|
|
6552
6567
|
break;
|
|
6553
6568
|
}
|
|
6554
6569
|
}), n;
|
|
6555
6570
|
}
|
|
6556
|
-
function
|
|
6557
|
-
if (t.target instanceof HTMLElement) {
|
|
6571
|
+
function ta(e, t) {
|
|
6572
|
+
if (e.nodeType !== "Text" && t.target instanceof HTMLElement) {
|
|
6558
6573
|
const n = t.attributeName, s = t.target.getAttribute(n);
|
|
6559
6574
|
s !== null ? e.attributes[n] = s : delete e.attributes[n];
|
|
6560
6575
|
}
|
|
6561
6576
|
}
|
|
6562
|
-
function
|
|
6563
|
-
t.
|
|
6564
|
-
if (!(n
|
|
6565
|
-
return;
|
|
6566
|
-
const s = Gt(n);
|
|
6567
|
-
e.children.find((r) => Ie(r, s)) || e.children.push(s);
|
|
6568
|
-
}), t.removedNodes.length && t.removedNodes.forEach((n) => {
|
|
6569
|
-
if (!(n instanceof HTMLElement))
|
|
6577
|
+
function ea(e, t) {
|
|
6578
|
+
e.nodeType !== "Text" && (t.removedNodes.length && t.removedNodes.forEach((n) => {
|
|
6579
|
+
if (!Zt(n))
|
|
6570
6580
|
return;
|
|
6571
|
-
const s =
|
|
6572
|
-
(i) =>
|
|
6581
|
+
const s = Ut(n), r = e.children.findIndex(
|
|
6582
|
+
(i) => qt(i, s)
|
|
6573
6583
|
);
|
|
6574
6584
|
r !== -1 && e.children.splice(r, 1);
|
|
6575
|
-
})
|
|
6585
|
+
}), t.addedNodes.length && t.addedNodes.forEach((n) => {
|
|
6586
|
+
if (!Zt(n))
|
|
6587
|
+
return;
|
|
6588
|
+
const s = Ut(n);
|
|
6589
|
+
e.children.find((r) => qt(r, s)) || e.children.push(s);
|
|
6590
|
+
}));
|
|
6576
6591
|
}
|
|
6577
|
-
function
|
|
6578
|
-
|
|
6579
|
-
|
|
6580
|
-
|
|
6592
|
+
function na(e, t) {
|
|
6593
|
+
const n = t.target;
|
|
6594
|
+
switch (e.nodeType) {
|
|
6595
|
+
case "Text":
|
|
6596
|
+
if (n instanceof Text)
|
|
6597
|
+
return e.textContent = n.textContent || "", !0;
|
|
6598
|
+
break;
|
|
6599
|
+
}
|
|
6600
|
+
return !1;
|
|
6601
|
+
}
|
|
6602
|
+
function Zt(e) {
|
|
6603
|
+
return e instanceof HTMLElement || e instanceof Text;
|
|
6581
6604
|
}
|
|
6582
|
-
function
|
|
6605
|
+
function Ut(e) {
|
|
6606
|
+
if (e instanceof Text)
|
|
6607
|
+
return {
|
|
6608
|
+
nodeType: "Text",
|
|
6609
|
+
textContent: e.textContent || ""
|
|
6610
|
+
};
|
|
6583
6611
|
const t = {
|
|
6612
|
+
nodeType: "HTMLElement",
|
|
6584
6613
|
tagName: e.tagName.toLowerCase(),
|
|
6585
6614
|
attributes: {},
|
|
6586
|
-
children: []
|
|
6587
|
-
textContent: e.textContent
|
|
6615
|
+
children: []
|
|
6588
6616
|
};
|
|
6589
6617
|
for (const n of e.attributes)
|
|
6590
6618
|
t.attributes[n.name] = n.value;
|
|
6591
6619
|
return e.childNodes.forEach((n) => {
|
|
6592
|
-
n
|
|
6620
|
+
Zt(n) && t.children.push(Ut(n));
|
|
6593
6621
|
}), t;
|
|
6594
6622
|
}
|
|
6595
|
-
function
|
|
6596
|
-
|
|
6623
|
+
function Fr(e, t) {
|
|
6624
|
+
sa(e, t), t.nodeType === "HTMLElement" && (ra(e, t), t.children.length > 0 && ia(e, t));
|
|
6597
6625
|
}
|
|
6598
|
-
function
|
|
6626
|
+
function sa(e, t) {
|
|
6627
|
+
t && t.nodeType === "Text" && e.textContent !== t.textContent && (e.textContent = t.textContent || "");
|
|
6628
|
+
}
|
|
6629
|
+
function ra(e, t) {
|
|
6599
6630
|
if (t) {
|
|
6600
6631
|
for (const [n, s] of Object.entries(t.attributes))
|
|
6601
6632
|
e.getAttribute(n) !== s && e.setAttribute(n, s);
|
|
@@ -6604,24 +6635,29 @@ function ea(e, t) {
|
|
|
6604
6635
|
});
|
|
6605
6636
|
}
|
|
6606
6637
|
}
|
|
6607
|
-
function
|
|
6638
|
+
function ia(e, t) {
|
|
6608
6639
|
const n = /* @__PURE__ */ new Set();
|
|
6609
6640
|
t.children.forEach((s) => {
|
|
6610
|
-
let r = Array.from(
|
|
6611
|
-
|
|
6641
|
+
let r = Array.from(
|
|
6642
|
+
e.childNodes
|
|
6643
|
+
).filter(Zt).find(
|
|
6644
|
+
(i) => (
|
|
6645
|
+
// @ts-ignore
|
|
6646
|
+
qt(Ut(i), s) && !n.has(i)
|
|
6647
|
+
)
|
|
6612
6648
|
);
|
|
6613
|
-
r || (r = document.createElement(s.tagName), e.appendChild(r)), n.add(r),
|
|
6614
|
-
}), Array.from(e.
|
|
6649
|
+
r || (r = s.nodeType === "Text" ? document.createTextNode(s.textContent) : document.createElement(s.tagName), e.appendChild(r)), n.add(r), Fr(r, s);
|
|
6650
|
+
}), Array.from(e.childNodes).filter(Zt).forEach((s) => {
|
|
6615
6651
|
n.has(s) || e.removeChild(s);
|
|
6616
6652
|
});
|
|
6617
6653
|
}
|
|
6618
|
-
const
|
|
6654
|
+
const bs = (e, t = 300) => {
|
|
6619
6655
|
let n;
|
|
6620
6656
|
return function(...s) {
|
|
6621
6657
|
clearTimeout(n), n = setTimeout(() => e.apply(this, s), t);
|
|
6622
6658
|
};
|
|
6623
6659
|
};
|
|
6624
|
-
class
|
|
6660
|
+
class oa {
|
|
6625
6661
|
constructor(t) {
|
|
6626
6662
|
y(this, "defaultData");
|
|
6627
6663
|
y(this, "localData");
|
|
@@ -6657,7 +6693,7 @@ class sa {
|
|
|
6657
6693
|
debounceMs: f,
|
|
6658
6694
|
triggerAwarenessUpdate: g
|
|
6659
6695
|
} = t;
|
|
6660
|
-
this.element = n, this.defaultData = i instanceof Function ? i(n) : i, this.localData = o instanceof Function ? o(n) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange =
|
|
6696
|
+
this.element = n, this.defaultData = i instanceof Function ? i(n) : i, this.localData = o instanceof Function ? o(n) : o, this.triggerAwarenessUpdate = g, this.onChange = s, this.debouncedOnChange = bs(this.onChange, f), this.onAwarenessChange = r, this.updateElement = h, this.updateElementAwareness = d;
|
|
6661
6697
|
const p = l === void 0 ? this.defaultData : l;
|
|
6662
6698
|
a !== void 0 && (this.__awareness = a);
|
|
6663
6699
|
const _ = c instanceof Function ? c(n) : c;
|
|
@@ -6676,7 +6712,7 @@ class sa {
|
|
|
6676
6712
|
debounceMs: h,
|
|
6677
6713
|
triggerAwarenessUpdate: d
|
|
6678
6714
|
}) {
|
|
6679
|
-
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange =
|
|
6715
|
+
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange = bs(this.onChange, h), this.onAwarenessChange = s, this.updateElement = r, this.updateElementAwareness = i, o && !this.onClick && t.addEventListener("click", (u) => {
|
|
6680
6716
|
var f;
|
|
6681
6717
|
(f = this.onClick) == null || f.call(this, u, this.getEventHandlerData());
|
|
6682
6718
|
}), this.onClick = o, c && !this.onDrag && (t.addEventListener("touchstart", (u) => {
|
|
@@ -6791,25 +6827,25 @@ class sa {
|
|
|
6791
6827
|
this.setData(this.defaultData);
|
|
6792
6828
|
}
|
|
6793
6829
|
}
|
|
6794
|
-
async function
|
|
6830
|
+
async function ca(e, t) {
|
|
6795
6831
|
const n = new TextEncoder().encode(`${e}-${t.outerHTML}}`), s = await crypto.subtle.digest("SHA-1", n);
|
|
6796
6832
|
return Array.from(new Uint8Array(s)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
6797
6833
|
}
|
|
6798
|
-
const
|
|
6799
|
-
function
|
|
6834
|
+
const la = "playhtml.spencerc99.partykit.dev", gn = new wt();
|
|
6835
|
+
function aa(e) {
|
|
6800
6836
|
const t = window.location.pathname.replace(/\.[^/.]+$/, "");
|
|
6801
6837
|
return e ? t + window.location.search : t;
|
|
6802
6838
|
}
|
|
6803
|
-
let O,
|
|
6804
|
-
const
|
|
6805
|
-
let
|
|
6806
|
-
function
|
|
6807
|
-
return [
|
|
6839
|
+
let O, W = gn.getMap("playhtml-global"), R = /* @__PURE__ */ new Map(), ft = /* @__PURE__ */ new Map();
|
|
6840
|
+
const Ss = /* @__PURE__ */ new Map();
|
|
6841
|
+
let ha = 0, ce = Gl;
|
|
6842
|
+
function Hr() {
|
|
6843
|
+
return [Be.CanPlay, ...Object.keys(ce)];
|
|
6808
6844
|
}
|
|
6809
|
-
function
|
|
6845
|
+
function ua(e) {
|
|
6810
6846
|
O.ws && O.ws.send(JSON.stringify(e));
|
|
6811
6847
|
}
|
|
6812
|
-
function
|
|
6848
|
+
function da(e) {
|
|
6813
6849
|
if (e.data instanceof Blob)
|
|
6814
6850
|
return;
|
|
6815
6851
|
let t;
|
|
@@ -6823,17 +6859,17 @@ function aa(e) {
|
|
|
6823
6859
|
for (const i of r)
|
|
6824
6860
|
i.onEvent(s);
|
|
6825
6861
|
}
|
|
6826
|
-
let At = !1,
|
|
6827
|
-
async function
|
|
6862
|
+
let At = !1, pn = !0;
|
|
6863
|
+
async function fa({
|
|
6828
6864
|
// TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
|
|
6829
|
-
host: e =
|
|
6865
|
+
host: e = la,
|
|
6830
6866
|
extraCapabilities: t,
|
|
6831
6867
|
events: n,
|
|
6832
6868
|
defaultRoomOptions: s = {},
|
|
6833
|
-
room: r =
|
|
6869
|
+
room: r = aa(s.includeSearch),
|
|
6834
6870
|
onError: i
|
|
6835
6871
|
} = {}) {
|
|
6836
|
-
if (!
|
|
6872
|
+
if (!pn) {
|
|
6837
6873
|
console.error("playhtml already set up!");
|
|
6838
6874
|
return;
|
|
6839
6875
|
}
|
|
@@ -6845,29 +6881,29 @@ async function ha({
|
|
|
6845
6881
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
6846
6882
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
6847
6883
|
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
|
|
6848
|
-
), O = new
|
|
6884
|
+
), O = new Tl(c, o, gn), O.on("error", () => {
|
|
6849
6885
|
i == null || i();
|
|
6850
|
-
}), new
|
|
6886
|
+
}), new Xl(o, gn), t)
|
|
6851
6887
|
for (const [a, h] of Object.entries(t))
|
|
6852
|
-
|
|
6888
|
+
ce[a] = h;
|
|
6853
6889
|
if (n)
|
|
6854
6890
|
for (const [a, h] of Object.entries(n))
|
|
6855
|
-
|
|
6891
|
+
Yr(a, h);
|
|
6856
6892
|
const l = document.createElement("link");
|
|
6857
6893
|
return l.rel = "stylesheet", l.href = "https://unpkg.com/playhtml@latest/dist/style.css", document.head.appendChild(l), await new Promise((a) => {
|
|
6858
6894
|
At && a(!0), O.on("sync", (h) => {
|
|
6859
|
-
h ? h && O.ws.addEventListener("message",
|
|
6895
|
+
h ? h && O.ws.addEventListener("message", da) : console.error("Issue connecting to yjs..."), !At && (At = !0, console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝"), Kr(), a(!0));
|
|
6860
6896
|
});
|
|
6861
6897
|
}), O;
|
|
6862
6898
|
}
|
|
6863
|
-
function
|
|
6899
|
+
function ga(e, t) {
|
|
6864
6900
|
const n = O.awareness.getLocalState();
|
|
6865
6901
|
return ((n == null ? void 0 : n[e]) ?? {})[t];
|
|
6866
6902
|
}
|
|
6867
|
-
function
|
|
6903
|
+
function xe(e) {
|
|
6868
6904
|
return e instanceof HTMLElement;
|
|
6869
6905
|
}
|
|
6870
|
-
function
|
|
6906
|
+
function jr(e, t) {
|
|
6871
6907
|
if (e === t)
|
|
6872
6908
|
return !0;
|
|
6873
6909
|
if (e instanceof Object && t instanceof Object) {
|
|
@@ -6875,22 +6911,22 @@ function Fr(e, t) {
|
|
|
6875
6911
|
if (n.length !== s.length)
|
|
6876
6912
|
return !1;
|
|
6877
6913
|
for (const r of n)
|
|
6878
|
-
if (!
|
|
6914
|
+
if (!jr(e[r], t[r]))
|
|
6879
6915
|
return !1;
|
|
6880
6916
|
return !0;
|
|
6881
6917
|
}
|
|
6882
6918
|
return !1;
|
|
6883
6919
|
}
|
|
6884
|
-
function
|
|
6885
|
-
const r =
|
|
6920
|
+
function pa(e, t, n, s) {
|
|
6921
|
+
const r = W.get(t);
|
|
6886
6922
|
return {
|
|
6887
6923
|
...n,
|
|
6888
6924
|
// TODO: when adding save-state if no save state, then just use defaultData
|
|
6889
6925
|
data: r.get(s) ?? (n.defaultData instanceof Function ? n.defaultData(e) : n.defaultData),
|
|
6890
|
-
awareness:
|
|
6926
|
+
awareness: ga(t, s) ?? n.myDefaultAwareness !== void 0 ? [n.myDefaultAwareness] : void 0,
|
|
6891
6927
|
element: e,
|
|
6892
6928
|
onChange: (o) => {
|
|
6893
|
-
|
|
6929
|
+
jr(r.get(s), o) || r.set(s, o);
|
|
6894
6930
|
},
|
|
6895
6931
|
onAwarenessChange: (o) => {
|
|
6896
6932
|
var l;
|
|
@@ -6898,15 +6934,15 @@ function da(e, t, n, s) {
|
|
|
6898
6934
|
c[s] !== o && (c[s] = o, O.awareness.setLocalStateField(t, c));
|
|
6899
6935
|
},
|
|
6900
6936
|
triggerAwarenessUpdate: () => {
|
|
6901
|
-
|
|
6937
|
+
zr();
|
|
6902
6938
|
}
|
|
6903
6939
|
};
|
|
6904
6940
|
}
|
|
6905
|
-
function
|
|
6941
|
+
function wa(e) {
|
|
6906
6942
|
return e.defaultData !== void 0 && (typeof e.defaultData == "object" || typeof e.defaultData == "function") && e.updateElement !== void 0;
|
|
6907
6943
|
}
|
|
6908
|
-
function
|
|
6909
|
-
if (e ===
|
|
6944
|
+
function ma(e, t) {
|
|
6945
|
+
if (e === Be.CanPlay) {
|
|
6910
6946
|
const n = t;
|
|
6911
6947
|
return {
|
|
6912
6948
|
defaultData: n.defaultData,
|
|
@@ -6923,9 +6959,9 @@ function ga(e, t) {
|
|
|
6923
6959
|
isValidElementForTag: n.isValidElementForTag
|
|
6924
6960
|
};
|
|
6925
6961
|
}
|
|
6926
|
-
return
|
|
6962
|
+
return ce[e];
|
|
6927
6963
|
}
|
|
6928
|
-
function
|
|
6964
|
+
function zr() {
|
|
6929
6965
|
const e = /* @__PURE__ */ new Map();
|
|
6930
6966
|
function t(n, s, r, i) {
|
|
6931
6967
|
e.has(n) || e.set(n, /* @__PURE__ */ new Map());
|
|
@@ -6962,61 +6998,61 @@ function Hr() {
|
|
|
6962
6998
|
}
|
|
6963
6999
|
});
|
|
6964
7000
|
}
|
|
6965
|
-
function
|
|
7001
|
+
function Kr() {
|
|
6966
7002
|
if (At) {
|
|
6967
|
-
for (const e of
|
|
7003
|
+
for (const e of Hr()) {
|
|
6968
7004
|
const t = Array.from(
|
|
6969
7005
|
document.querySelectorAll(`[${e}]`)
|
|
6970
|
-
).filter(
|
|
7006
|
+
).filter(xe);
|
|
6971
7007
|
t.length && Promise.all(
|
|
6972
|
-
t.map((n) =>
|
|
7008
|
+
t.map((n) => Qt(n, e))
|
|
6973
7009
|
);
|
|
6974
7010
|
}
|
|
6975
|
-
|
|
7011
|
+
pn && (W.observe((e) => {
|
|
6976
7012
|
e.changes.keys.forEach((t, n) => {
|
|
6977
|
-
t.action === "add" &&
|
|
7013
|
+
t.action === "add" && W.set(n, W.get(n));
|
|
6978
7014
|
});
|
|
6979
|
-
}), O.awareness.on("change", () =>
|
|
7015
|
+
}), O.awareness.on("change", () => zr()), pn = !1);
|
|
6980
7016
|
}
|
|
6981
7017
|
}
|
|
6982
|
-
const
|
|
6983
|
-
init:
|
|
6984
|
-
setupPlayElements:
|
|
6985
|
-
setupPlayElement:
|
|
6986
|
-
removePlayElement:
|
|
6987
|
-
setupPlayElementForTag:
|
|
6988
|
-
globalData:
|
|
7018
|
+
const ya = {
|
|
7019
|
+
init: fa,
|
|
7020
|
+
setupPlayElements: Kr,
|
|
7021
|
+
setupPlayElement: _a,
|
|
7022
|
+
removePlayElement: ka,
|
|
7023
|
+
setupPlayElementForTag: Qt,
|
|
7024
|
+
globalData: W,
|
|
6989
7025
|
elementHandlers: R,
|
|
6990
7026
|
eventHandlers: ft,
|
|
6991
|
-
dispatchPlayEvent:
|
|
6992
|
-
registerPlayEventListener:
|
|
6993
|
-
removePlayEventListener:
|
|
7027
|
+
dispatchPlayEvent: Da,
|
|
7028
|
+
registerPlayEventListener: Yr,
|
|
7029
|
+
removePlayEventListener: Ea
|
|
6994
7030
|
};
|
|
6995
|
-
window.playhtml =
|
|
6996
|
-
function
|
|
7031
|
+
window.playhtml = ya;
|
|
7032
|
+
function ba(e) {
|
|
6997
7033
|
if (R.has(e) || !At)
|
|
6998
7034
|
return;
|
|
6999
|
-
R.has(e) || R.set(e, /* @__PURE__ */ new Map()), e !==
|
|
7000
|
-
const t =
|
|
7035
|
+
R.has(e) || R.set(e, /* @__PURE__ */ new Map()), e !== Be.CanPlay && ce[e], W.get(e) || W.set(e, new ht());
|
|
7036
|
+
const t = W.get(e);
|
|
7001
7037
|
t.observe((n) => {
|
|
7002
7038
|
n.changes.keys.forEach(async (s, r) => {
|
|
7003
7039
|
const i = R.get(e);
|
|
7004
7040
|
if (s.action === "add") {
|
|
7005
7041
|
const o = document.getElementById(r);
|
|
7006
|
-
if (!
|
|
7042
|
+
if (!xe(o)) {
|
|
7007
7043
|
console.log(`Element ${r} not an HTML element. Ignoring.`);
|
|
7008
7044
|
return;
|
|
7009
7045
|
}
|
|
7010
|
-
|
|
7046
|
+
Qt(o, e);
|
|
7011
7047
|
} else if (s.action === "update") {
|
|
7012
7048
|
let o = i.get(r);
|
|
7013
7049
|
if (!o) {
|
|
7014
7050
|
const c = document.getElementById(r);
|
|
7015
|
-
if (!
|
|
7051
|
+
if (!xe(c)) {
|
|
7016
7052
|
console.log(`Element ${r} not an HTML element. Ignoring.`);
|
|
7017
7053
|
return;
|
|
7018
7054
|
}
|
|
7019
|
-
await
|
|
7055
|
+
await Qt(c, e), o = i.get(r);
|
|
7020
7056
|
}
|
|
7021
7057
|
o.__data = t.get(r);
|
|
7022
7058
|
} else
|
|
@@ -7024,41 +7060,41 @@ function wa(e) {
|
|
|
7024
7060
|
});
|
|
7025
7061
|
});
|
|
7026
7062
|
}
|
|
7027
|
-
function
|
|
7063
|
+
function Sa(e, t) {
|
|
7028
7064
|
var n, s;
|
|
7029
|
-
return ((s = (n =
|
|
7065
|
+
return ((s = (n = ce[t]) == null ? void 0 : n.isValidElementForTag) == null ? void 0 : s.call(n, e)) ?? !0;
|
|
7030
7066
|
}
|
|
7031
|
-
async function
|
|
7067
|
+
async function Qt(e, t) {
|
|
7032
7068
|
var c;
|
|
7033
|
-
if (!
|
|
7069
|
+
if (!Sa(e, t) || !At)
|
|
7034
7070
|
return;
|
|
7035
7071
|
if (!e.id) {
|
|
7036
7072
|
const l = e.getAttribute("selector-id");
|
|
7037
7073
|
if (l) {
|
|
7038
|
-
const a =
|
|
7039
|
-
e.id = btoa(`${t}-${l}-${a}`),
|
|
7074
|
+
const a = Ss.get(l) ?? 0;
|
|
7075
|
+
e.id = btoa(`${t}-${l}-${a}`), Ss.set(l, a + 1);
|
|
7040
7076
|
} else
|
|
7041
|
-
e.id = await
|
|
7077
|
+
e.id = await ca(t, e);
|
|
7042
7078
|
}
|
|
7043
|
-
const n =
|
|
7079
|
+
const n = Wl(e);
|
|
7044
7080
|
if (!n) {
|
|
7045
7081
|
console.error(
|
|
7046
7082
|
`Element ${e} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`
|
|
7047
7083
|
);
|
|
7048
7084
|
return;
|
|
7049
7085
|
}
|
|
7050
|
-
|
|
7051
|
-
const s = R.get(t), r =
|
|
7086
|
+
ba(t);
|
|
7087
|
+
const s = R.get(t), r = ma(
|
|
7052
7088
|
t,
|
|
7053
7089
|
e
|
|
7054
7090
|
);
|
|
7055
|
-
if (!
|
|
7091
|
+
if (!wa(r)) {
|
|
7056
7092
|
console.error(
|
|
7057
7093
|
`Element ${n} does not have proper info to initial a playhtml element. Please refer to https://github.com/spencerc99/playhtml#can-play for troubleshooting help.`
|
|
7058
7094
|
);
|
|
7059
7095
|
return;
|
|
7060
7096
|
}
|
|
7061
|
-
const i =
|
|
7097
|
+
const i = W.get(t), o = pa(
|
|
7062
7098
|
e,
|
|
7063
7099
|
t,
|
|
7064
7100
|
r,
|
|
@@ -7068,51 +7104,51 @@ async function qt(e, t) {
|
|
|
7068
7104
|
s.get(n).reinitializeElementData(o);
|
|
7069
7105
|
return;
|
|
7070
7106
|
} else
|
|
7071
|
-
s.set(n, new
|
|
7107
|
+
s.set(n, new oa(o));
|
|
7072
7108
|
i.get(n) === void 0 && r.defaultData !== void 0 && i.set(
|
|
7073
7109
|
n,
|
|
7074
7110
|
r.defaultData instanceof Function ? r.defaultData(e) : r.defaultData
|
|
7075
7111
|
), (c = o.triggerAwarenessUpdate) == null || c.call(o), e.classList.add("__playhtml-element"), e.classList.add(`__playhtml-${t}`), e.style.setProperty("--jiggle-delay", `${Math.random() * 1}s;}`);
|
|
7076
7112
|
}
|
|
7077
|
-
function
|
|
7113
|
+
function _a(e, { ignoreIfAlreadySetup: t } = {}) {
|
|
7078
7114
|
if (!(t && Object.keys(R || {}).some(
|
|
7079
7115
|
(n) => {
|
|
7080
7116
|
var s;
|
|
7081
7117
|
return (s = R.get(n)) == null ? void 0 : s.has(e.id);
|
|
7082
7118
|
}
|
|
7083
7119
|
))) {
|
|
7084
|
-
if (!
|
|
7120
|
+
if (!xe(e)) {
|
|
7085
7121
|
console.log(`Element ${e.id} not an HTML element. Ignoring.`);
|
|
7086
7122
|
return;
|
|
7087
7123
|
}
|
|
7088
7124
|
Promise.all(
|
|
7089
|
-
|
|
7125
|
+
Hr().filter((n) => e.hasAttribute(n)).map((n) => Qt(e, n))
|
|
7090
7126
|
);
|
|
7091
7127
|
}
|
|
7092
7128
|
}
|
|
7093
|
-
function
|
|
7129
|
+
function ka(e) {
|
|
7094
7130
|
if (!(!e || !e.id))
|
|
7095
7131
|
for (const t of Object.keys(R)) {
|
|
7096
7132
|
const n = R.get(t);
|
|
7097
7133
|
n.has(e.id) && n.delete(e.id);
|
|
7098
7134
|
}
|
|
7099
7135
|
}
|
|
7100
|
-
function
|
|
7136
|
+
function Da(e) {
|
|
7101
7137
|
const { type: t } = e;
|
|
7102
7138
|
if (!ft.has(t)) {
|
|
7103
7139
|
console.error(`[playhtml] event "${t}" not registered.`);
|
|
7104
7140
|
return;
|
|
7105
7141
|
}
|
|
7106
|
-
|
|
7142
|
+
ua(e);
|
|
7107
7143
|
}
|
|
7108
|
-
function
|
|
7109
|
-
const n = String(
|
|
7144
|
+
function Yr(e, t) {
|
|
7145
|
+
const n = String(ha++);
|
|
7110
7146
|
return ft.set(e, [
|
|
7111
7147
|
...ft.get(e) ?? [],
|
|
7112
7148
|
{ type: e, ...t, id: n }
|
|
7113
7149
|
]), n;
|
|
7114
7150
|
}
|
|
7115
|
-
function
|
|
7151
|
+
function Ea(e, t) {
|
|
7116
7152
|
const n = ft.get(e);
|
|
7117
7153
|
if (!n)
|
|
7118
7154
|
return;
|
|
@@ -7120,5 +7156,5 @@ function _a(e, t) {
|
|
|
7120
7156
|
s !== -1 && (n.splice(s, 1), n.length === 0 && ft.delete(e));
|
|
7121
7157
|
}
|
|
7122
7158
|
export {
|
|
7123
|
-
|
|
7159
|
+
ya as playhtml
|
|
7124
7160
|
};
|