playhtml 2.1.11 → 2.1.12
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/README.md +6 -0
- package/dist/playhtml.es.js +731 -792
- 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 Jr = Object.defineProperty;
|
|
2
|
+
var Wr = (e, t, n) => t in e ? Jr(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var y = (e, t, n) => (Wr(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 le = (e, t, n) => (
|
|
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 ae = 1e6,
|
|
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, Pr = "y-pk-batch", zn = !1, Bt = (e, t) => {
|
|
13
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
|
-
),
|
|
21
|
+
), zn = !0);
|
|
22
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,
|
|
@@ -34,7 +34,7 @@ var ae = 1e6, qr = "y-pk-batch", Kn = !1, Bt = (e, t) => {
|
|
|
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,13 +42,13 @@ var ae = 1e6, qr = "y-pk-batch", Kn = !1, Bt = (e, t) => {
|
|
|
42
42
|
})
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
-
function
|
|
46
|
-
return `${
|
|
45
|
+
function Kn(e) {
|
|
46
|
+
return `${Pr}#${JSON.stringify(e)}`;
|
|
47
47
|
}
|
|
48
|
-
const kt = () => /* @__PURE__ */ new Map(),
|
|
48
|
+
const kt = () => /* @__PURE__ */ new Map(), _s = (e, t, n) => {
|
|
49
49
|
let s = e.get(t);
|
|
50
50
|
return s === void 0 && e.set(t, s = n()), s;
|
|
51
|
-
},
|
|
51
|
+
}, ks = () => /* @__PURE__ */ new Set(), Gr = Array.from, qr = String.fromCharCode, Zr = (e) => e.toLowerCase(), Qr = /^\s*/g, ti = (e) => e.replace(Qr, ""), ei = /([A-Z])/g, Yn = (e, t) => ti(e.replace(ei, (n) => `${t}${Zr(n)}`)), ni = (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} */
|
|
@@ -57,11 +57,11 @@ const kt = () => /* @__PURE__ */ new Map(), Ds = (e, t, n) => {
|
|
|
57
57
|
}, jt = (
|
|
58
58
|
/** @type {TextEncoder} */
|
|
59
59
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
60
|
-
),
|
|
60
|
+
), si = (e) => jt.encode(e), ri = jt ? si : ni;
|
|
61
61
|
let Fe = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
62
62
|
Fe && Fe.decode(new Uint8Array()).length === 1 && (Fe = null);
|
|
63
|
-
const
|
|
64
|
-
let
|
|
63
|
+
const Xn = (e) => e === void 0 ? null : e;
|
|
64
|
+
let ii = class {
|
|
65
65
|
constructor() {
|
|
66
66
|
this.map = /* @__PURE__ */ new Map();
|
|
67
67
|
}
|
|
@@ -78,29 +78,29 @@ let ci = class {
|
|
|
78
78
|
getItem(t) {
|
|
79
79
|
return this.map.get(t);
|
|
80
80
|
}
|
|
81
|
-
},
|
|
81
|
+
}, Ds = new ii(), mn = !0;
|
|
82
82
|
try {
|
|
83
|
-
typeof localStorage < "u" && localStorage && (
|
|
83
|
+
typeof localStorage < "u" && localStorage && (Ds = localStorage, mn = !1);
|
|
84
84
|
} catch {
|
|
85
85
|
}
|
|
86
|
-
const
|
|
86
|
+
const Es = Ds, oi = (e) => mn || addEventListener(
|
|
87
87
|
"storage",
|
|
88
88
|
/** @type {any} */
|
|
89
89
|
e
|
|
90
|
-
),
|
|
90
|
+
), ci = (e) => mn || removeEventListener(
|
|
91
91
|
"storage",
|
|
92
92
|
/** @type {any} */
|
|
93
93
|
e
|
|
94
|
-
),
|
|
94
|
+
), li = (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
|
+
}, ai = (e, t) => t.includes(e), It = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process < "u" ? process : 0) === "[object process]", Cs = typeof window < "u" && typeof document < "u" && !It;
|
|
100
100
|
let V;
|
|
101
|
-
const
|
|
101
|
+
const hi = () => {
|
|
102
102
|
if (V === void 0)
|
|
103
|
-
if (
|
|
103
|
+
if (It) {
|
|
104
104
|
V = kt();
|
|
105
105
|
const e = process.argv;
|
|
106
106
|
let t = null;
|
|
@@ -113,28 +113,28 @@ const di = () => {
|
|
|
113
113
|
typeof location == "object" ? (V = kt(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
114
114
|
if (e.length !== 0) {
|
|
115
115
|
const [t, n] = e.split("=");
|
|
116
|
-
V.set(`--${
|
|
116
|
+
V.set(`--${Yn(t, "-")}`, n), V.set(`-${Yn(t, "-")}`, n);
|
|
117
117
|
}
|
|
118
118
|
})) : V = kt();
|
|
119
119
|
return V;
|
|
120
|
-
},
|
|
121
|
-
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
!
|
|
125
|
-
const
|
|
126
|
-
let
|
|
120
|
+
}, Qe = (e) => hi().has(e), tn = (e) => Xn(It ? process.env[e.toUpperCase().replaceAll("-", "_")] : Es.getItem(e)), As = (e) => Qe("--" + e) || tn(e) !== null;
|
|
121
|
+
As("production");
|
|
122
|
+
const ui = It && ai(process.env.FORCE_COLOR, ["true", "1", "2"]);
|
|
123
|
+
ui || !Qe("--no-colors") && // @todo deprecate --no-colors
|
|
124
|
+
!As("no-color") && (!It || process.stdout.isTTY) && (!It || Qe("--color") || tn("COLORTERM") !== null || (tn("TERM") || "").includes("color"));
|
|
125
|
+
const di = Math.floor, Ls = (e, t) => e < t ? e : t, fi = (e, t) => e > t ? e : t, gi = Math.pow, Is = 128, ge = 127, pi = Number.MAX_SAFE_INTEGER;
|
|
126
|
+
let wi = class {
|
|
127
127
|
constructor() {
|
|
128
128
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
129
129
|
}
|
|
130
130
|
};
|
|
131
|
-
const
|
|
131
|
+
const N = () => new wi(), yn = (e) => {
|
|
132
132
|
let t = e.cpos;
|
|
133
133
|
for (let n = 0; n < e.bufs.length; n++)
|
|
134
134
|
t += e.bufs[n].length;
|
|
135
135
|
return t;
|
|
136
136
|
}, M = (e) => {
|
|
137
|
-
const t = new Uint8Array(
|
|
137
|
+
const t = new Uint8Array(yn(e));
|
|
138
138
|
let n = 0;
|
|
139
139
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
140
140
|
const r = e.bufs[s];
|
|
@@ -144,21 +144,21 @@ const $ = () => new yi(), bn = (e) => {
|
|
|
144
144
|
}, be = (e, t) => {
|
|
145
145
|
const n = e.cbuf.length;
|
|
146
146
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
147
|
-
},
|
|
147
|
+
}, v = (e, t) => {
|
|
148
148
|
for (; t > ge; )
|
|
149
|
-
be(e,
|
|
149
|
+
be(e, Is | ge & t), t = di(t / 128);
|
|
150
150
|
be(e, ge & t);
|
|
151
|
-
},
|
|
152
|
-
if (t.length <
|
|
153
|
-
const n = jt.encodeInto(t,
|
|
154
|
-
|
|
151
|
+
}, en = new Uint8Array(3e4), mi = en.length / 3, yi = (e, t) => {
|
|
152
|
+
if (t.length < mi) {
|
|
153
|
+
const n = jt.encodeInto(t, en).written || 0;
|
|
154
|
+
v(e, n);
|
|
155
155
|
for (let s = 0; s < n; s++)
|
|
156
|
-
be(e,
|
|
156
|
+
be(e, en[s]);
|
|
157
157
|
} else
|
|
158
|
-
Dt(e,
|
|
159
|
-
},
|
|
158
|
+
Dt(e, ri(t));
|
|
159
|
+
}, bi = (e, t) => {
|
|
160
160
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
161
|
-
|
|
161
|
+
v(e, s);
|
|
162
162
|
for (let r = 0; r < s; r++)
|
|
163
163
|
be(
|
|
164
164
|
e,
|
|
@@ -168,13 +168,13 @@ const $ = () => new yi(), bn = (e) => {
|
|
|
168
168
|
};
|
|
169
169
|
jt && /** @type {any} */
|
|
170
170
|
jt.encodeInto;
|
|
171
|
-
const
|
|
172
|
-
const n = e.cbuf.length, s = e.cpos, r =
|
|
173
|
-
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(
|
|
171
|
+
const Si = (e, t) => {
|
|
172
|
+
const n = e.cbuf.length, s = e.cpos, r = Ls(n - s, t.length), i = t.length - r;
|
|
173
|
+
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(fi(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
174
174
|
}, Dt = (e, t) => {
|
|
175
|
-
|
|
176
|
-
},
|
|
177
|
-
let
|
|
175
|
+
v(e, t.byteLength), Si(e, t);
|
|
176
|
+
}, vs = (e) => new Error(e), _i = vs("Unexpected end of array"), ki = vs("Integer out of Range");
|
|
177
|
+
let Di = class {
|
|
178
178
|
/**
|
|
179
179
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
180
180
|
*/
|
|
@@ -182,65 +182,65 @@ let Ci = class {
|
|
|
182
182
|
this.arr = t, this.pos = 0;
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
const
|
|
185
|
+
const Ei = (e) => new Di(e), Ci = (e, t) => {
|
|
186
186
|
const n = new Uint8Array(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
187
187
|
return e.pos += t, n;
|
|
188
|
-
},
|
|
188
|
+
}, Ai = (e) => Ci(e, xs(e)), xs = (e) => {
|
|
189
189
|
let t = 0, n = 1;
|
|
190
190
|
const s = e.arr.length;
|
|
191
191
|
for (; e.pos < s; ) {
|
|
192
192
|
const r = e.arr[e.pos++];
|
|
193
|
-
if (t = t + (r & ge) * n, n *= 128, r <
|
|
193
|
+
if (t = t + (r & ge) * n, n *= 128, r < Is)
|
|
194
194
|
return t;
|
|
195
|
-
if (t >
|
|
196
|
-
throw
|
|
195
|
+
if (t > pi)
|
|
196
|
+
throw ki;
|
|
197
197
|
}
|
|
198
|
-
throw
|
|
199
|
-
},
|
|
198
|
+
throw _i;
|
|
199
|
+
}, Li = (e) => new Uint8Array(e), Ii = (e, t, n) => new Uint8Array(e, t, n), vi = (e) => new Uint8Array(e), xi = (e) => {
|
|
200
200
|
let t = "";
|
|
201
201
|
for (let n = 0; n < e.byteLength; n++)
|
|
202
|
-
t +=
|
|
202
|
+
t += qr(e[n]);
|
|
203
203
|
return btoa(t);
|
|
204
|
-
},
|
|
205
|
-
const t = atob(e), n =
|
|
204
|
+
}, Ti = (e) => Buffer.from(e.buffer, e.byteOffset, e.byteLength).toString("base64"), Mi = (e) => {
|
|
205
|
+
const t = atob(e), n = Li(t.length);
|
|
206
206
|
for (let s = 0; s < t.length; s++)
|
|
207
207
|
n[s] = t.charCodeAt(s);
|
|
208
208
|
return n;
|
|
209
|
-
},
|
|
209
|
+
}, Ui = (e) => {
|
|
210
210
|
const t = Buffer.from(e, "base64");
|
|
211
|
-
return
|
|
212
|
-
},
|
|
213
|
-
class
|
|
211
|
+
return Ii(t.buffer, t.byteOffset, t.byteLength);
|
|
212
|
+
}, Oi = Cs ? xi : Ti, Ri = Cs ? Mi : Ui, Ts = /* @__PURE__ */ new Map();
|
|
213
|
+
class $i {
|
|
214
214
|
/**
|
|
215
215
|
* @param {string} room
|
|
216
216
|
*/
|
|
217
217
|
constructor(t) {
|
|
218
|
-
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data:
|
|
218
|
+
this.room = t, this.onmessage = null, this._onChange = (n) => n.key === t && this.onmessage !== null && this.onmessage({ data: Ri(n.newValue || "") }), oi(this._onChange);
|
|
219
219
|
}
|
|
220
220
|
/**
|
|
221
221
|
* @param {ArrayBuffer} buf
|
|
222
222
|
*/
|
|
223
223
|
postMessage(t) {
|
|
224
|
-
|
|
224
|
+
Es.setItem(this.room, Oi(vi(t)));
|
|
225
225
|
}
|
|
226
226
|
close() {
|
|
227
|
-
|
|
227
|
+
ci(this._onChange);
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
const t =
|
|
230
|
+
const Ni = typeof BroadcastChannel > "u" ? $i : BroadcastChannel, bn = (e) => _s(Ts, e, () => {
|
|
231
|
+
const t = ks(), n = new Ni(e);
|
|
232
232
|
return n.onmessage = (s) => t.forEach((r) => r(s.data, "broadcastchannel")), {
|
|
233
233
|
bc: n,
|
|
234
234
|
subs: t
|
|
235
235
|
};
|
|
236
|
-
}),
|
|
237
|
-
const n =
|
|
238
|
-
return s && n.subs.size === 0 && (n.bc.close(),
|
|
236
|
+
}), Bi = (e, t) => (bn(e).subs.add(t), t), Vi = (e, t) => {
|
|
237
|
+
const n = bn(e), s = n.subs.delete(t);
|
|
238
|
+
return s && n.subs.size === 0 && (n.bc.close(), Ts.delete(e)), s;
|
|
239
239
|
}, St = (e, t, n = null) => {
|
|
240
|
-
const s =
|
|
240
|
+
const s = bn(e);
|
|
241
241
|
s.bc.postMessage(t), s.subs.forEach((r) => r(t, n));
|
|
242
242
|
};
|
|
243
|
-
let
|
|
243
|
+
let Fi = class {
|
|
244
244
|
constructor() {
|
|
245
245
|
this._observers = kt();
|
|
246
246
|
}
|
|
@@ -249,7 +249,7 @@ let ji = class {
|
|
|
249
249
|
* @param {function} f
|
|
250
250
|
*/
|
|
251
251
|
on(t, n) {
|
|
252
|
-
|
|
252
|
+
_s(this._observers, t, ks).add(n);
|
|
253
253
|
}
|
|
254
254
|
/**
|
|
255
255
|
* @param {N} name
|
|
@@ -279,13 +279,13 @@ let ji = class {
|
|
|
279
279
|
* @param {Array<any>} args The arguments that are applied to the event listener.
|
|
280
280
|
*/
|
|
281
281
|
emit(t, n) {
|
|
282
|
-
return
|
|
282
|
+
return Gr((this._observers.get(t) || kt()).values()).forEach((s) => s(...n));
|
|
283
283
|
}
|
|
284
284
|
destroy() {
|
|
285
285
|
this._observers = kt();
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
|
-
const
|
|
288
|
+
const nn = Date.now, Hi = (e) => li(e, (t, n) => `${encodeURIComponent(n)}=${encodeURIComponent(t)}`).join("&"), x = () => /* @__PURE__ */ new Map(), sn = (e) => {
|
|
289
289
|
const t = x();
|
|
290
290
|
return e.forEach((n, s) => {
|
|
291
291
|
t.set(s, n);
|
|
@@ -293,21 +293,21 @@ const sn = Date.now, zi = (e) => hi(e, (t, n) => `${encodeURIComponent(n)}=${enc
|
|
|
293
293
|
}, q = (e, t, n) => {
|
|
294
294
|
let s = e.get(t);
|
|
295
295
|
return s === void 0 && e.set(t, s = n()), s;
|
|
296
|
-
},
|
|
296
|
+
}, ji = (e, t) => {
|
|
297
297
|
const n = [];
|
|
298
298
|
for (const [s, r] of e)
|
|
299
299
|
n.push(t(r, s));
|
|
300
300
|
return n;
|
|
301
|
-
},
|
|
301
|
+
}, zi = (e, t) => {
|
|
302
302
|
for (const [n, s] of e)
|
|
303
303
|
if (t(s, n))
|
|
304
304
|
return !0;
|
|
305
305
|
return !1;
|
|
306
|
-
}, at = () => /* @__PURE__ */ new Set(), He = (e) => e[e.length - 1],
|
|
306
|
+
}, at = () => /* @__PURE__ */ new Set(), He = (e) => e[e.length - 1], Ki = (e, t) => {
|
|
307
307
|
for (let n = 0; n < t.length; n++)
|
|
308
308
|
e.push(t[n]);
|
|
309
|
-
}, W = Array.from,
|
|
310
|
-
class
|
|
309
|
+
}, W = Array.from, Yi = Array.isArray;
|
|
310
|
+
class Xi {
|
|
311
311
|
constructor() {
|
|
312
312
|
this._observers = x();
|
|
313
313
|
}
|
|
@@ -369,7 +369,7 @@ class Wi {
|
|
|
369
369
|
this._observers = x();
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
class
|
|
372
|
+
class Ms {
|
|
373
373
|
constructor() {
|
|
374
374
|
this._observers = x();
|
|
375
375
|
}
|
|
@@ -414,7 +414,7 @@ class Os {
|
|
|
414
414
|
this._observers = x();
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
-
const P = Math.floor, pe = Math.abs,
|
|
417
|
+
const P = Math.floor, pe = Math.abs, Us = (e, t) => e < t ? e : t, pt = (e, t) => e > t ? e : t, Os = (e) => e !== 0 ? e < 0 : 1 / e < 0, Ji = (e) => e.toLowerCase(), Wi = /^\s*/g, Pi = (e) => e.replace(Wi, ""), Gi = /([A-Z])/g, Jn = (e, t) => Pi(e.replace(Gi, (n) => `${t}${Ji(n)}`)), qi = (e) => {
|
|
418
418
|
const t = unescape(encodeURIComponent(e)), n = t.length, s = new Uint8Array(n);
|
|
419
419
|
for (let r = 0; r < n; r++)
|
|
420
420
|
s[r] = /** @type {number} */
|
|
@@ -423,11 +423,11 @@ const P = Math.floor, pe = Math.abs, Rs = (e, t) => e < t ? e : t, pt = (e, t) =
|
|
|
423
423
|
}, zt = (
|
|
424
424
|
/** @type {TextEncoder} */
|
|
425
425
|
typeof TextEncoder < "u" ? new TextEncoder() : null
|
|
426
|
-
),
|
|
426
|
+
), Zi = (e) => zt.encode(e), Qi = zt ? Zi : qi;
|
|
427
427
|
let Vt = typeof TextDecoder > "u" ? null : new TextDecoder("utf-8", { fatal: !0, ignoreBOM: !0 });
|
|
428
428
|
Vt && Vt.decode(new Uint8Array()).length === 1 && (Vt = null);
|
|
429
|
-
const
|
|
430
|
-
class
|
|
429
|
+
const Wn = (e) => e === void 0 ? null : e;
|
|
430
|
+
class to {
|
|
431
431
|
constructor() {
|
|
432
432
|
this.map = /* @__PURE__ */ new Map();
|
|
433
433
|
}
|
|
@@ -445,33 +445,33 @@ class no {
|
|
|
445
445
|
return this.map.get(t);
|
|
446
446
|
}
|
|
447
447
|
}
|
|
448
|
-
let
|
|
448
|
+
let Rs = new to(), eo = !0;
|
|
449
449
|
try {
|
|
450
|
-
typeof localStorage < "u" && (
|
|
450
|
+
typeof localStorage < "u" && (Rs = localStorage, eo = !1);
|
|
451
451
|
} catch {
|
|
452
452
|
}
|
|
453
|
-
const
|
|
453
|
+
const no = Rs, so = Object.assign, ro = Object.keys, io = (e, t) => {
|
|
454
454
|
for (const n in e)
|
|
455
455
|
t(e[n], n);
|
|
456
|
-
}, Se = (e) =>
|
|
456
|
+
}, Se = (e) => ro(e).length, oo = (e) => {
|
|
457
457
|
for (const t in e)
|
|
458
458
|
return !1;
|
|
459
459
|
return !0;
|
|
460
|
-
},
|
|
460
|
+
}, co = (e, t) => {
|
|
461
461
|
for (const n in e)
|
|
462
462
|
if (!t(e[n], n))
|
|
463
463
|
return !1;
|
|
464
464
|
return !0;
|
|
465
|
-
},
|
|
465
|
+
}, $s = (e, t) => Object.prototype.hasOwnProperty.call(e, t), lo = (e, t) => e === t || Se(e) === Se(t) && co(e, (n, s) => (n !== void 0 || $s(t, s)) && t[s] === n), Sn = (e, t, n = 0) => {
|
|
466
466
|
try {
|
|
467
467
|
for (; n < e.length; n++)
|
|
468
468
|
e[n](...t);
|
|
469
469
|
} finally {
|
|
470
|
-
n < e.length &&
|
|
470
|
+
n < e.length && Sn(e, t, n + 1);
|
|
471
471
|
}
|
|
472
|
-
},
|
|
472
|
+
}, ao = (e) => e, ho = (e, t) => e === t, Ft = (e, t) => {
|
|
473
473
|
if (e == null || t == null)
|
|
474
|
-
return
|
|
474
|
+
return ho(e, t);
|
|
475
475
|
if (e.constructor !== t.constructor)
|
|
476
476
|
return !1;
|
|
477
477
|
if (e === t)
|
|
@@ -507,7 +507,7 @@ const ro = $s, io = Object.assign, oo = Object.keys, co = (e, t) => {
|
|
|
507
507
|
if (Se(e) !== Se(t))
|
|
508
508
|
return !1;
|
|
509
509
|
for (const n in e)
|
|
510
|
-
if (
|
|
510
|
+
if (!$s(e, n) || !Ft(e[n], t[n]))
|
|
511
511
|
return !1;
|
|
512
512
|
break;
|
|
513
513
|
case Array:
|
|
@@ -521,9 +521,9 @@ const ro = $s, io = Object.assign, oo = Object.keys, co = (e, t) => {
|
|
|
521
521
|
return !1;
|
|
522
522
|
}
|
|
523
523
|
return !0;
|
|
524
|
-
},
|
|
524
|
+
}, uo = (e, t) => t.includes(e), Kt = typeof process < "u" && process.release && /node|io\.js/.test(process.release.name);
|
|
525
525
|
let F;
|
|
526
|
-
const
|
|
526
|
+
const fo = () => {
|
|
527
527
|
if (F === void 0)
|
|
528
528
|
if (Kt) {
|
|
529
529
|
F = x();
|
|
@@ -538,17 +538,17 @@ const po = () => {
|
|
|
538
538
|
typeof location == "object" ? (F = x(), (location.search || "?").slice(1).split("&").forEach((e) => {
|
|
539
539
|
if (e.length !== 0) {
|
|
540
540
|
const [t, n] = e.split("=");
|
|
541
|
-
F.set(`--${
|
|
541
|
+
F.set(`--${Jn(t, "-")}`, n), F.set(`-${Jn(t, "-")}`, n);
|
|
542
542
|
}
|
|
543
543
|
})) : F = x();
|
|
544
544
|
return F;
|
|
545
|
-
},
|
|
546
|
-
|
|
547
|
-
const
|
|
545
|
+
}, rn = (e) => fo().has(e), on = (e) => Wn(Kt ? process.env[e.toUpperCase()] : no.getItem(e)), go = (e) => rn("--" + e) || on(e) !== null;
|
|
546
|
+
go("production");
|
|
547
|
+
const Pn = Kt && uo(process.env.FORCE_COLOR, ["true", "1", "2"]), po = !rn("no-colors") && (!Kt || process.stdout.isTTY || Pn) && (!Kt || rn("color") || Pn || on("COLORTERM") !== null || (on("TERM") || "").includes("color")), Gn = 1, qn = 2, je = 4, ze = 8, Yt = 32, X = 64, T = 128, Te = 31, cn = 63, ct = 127, wo = 2147483647, Ns = Number.MAX_SAFE_INTEGER, mo = Number.isInteger || ((e) => typeof e == "number" && isFinite(e) && P(e) === e), G = (e) => new Error(e), H = () => {
|
|
548
548
|
throw G("Method unimplemented");
|
|
549
549
|
}, j = () => {
|
|
550
550
|
throw G("Unexpected case");
|
|
551
|
-
},
|
|
551
|
+
}, Bs = G("Unexpected end of array"), Vs = G("Integer out of Range");
|
|
552
552
|
class Me {
|
|
553
553
|
/**
|
|
554
554
|
* @param {Uint8Array} uint8Array Binary data to decode
|
|
@@ -557,22 +557,22 @@ class Me {
|
|
|
557
557
|
this.arr = t, this.pos = 0;
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
const wt = (e) => new Me(e),
|
|
561
|
-
const n =
|
|
560
|
+
const wt = (e) => new Me(e), yo = (e) => e.pos !== e.arr.length, bo = (e, t) => {
|
|
561
|
+
const n = Dn(e.arr.buffer, e.pos + e.arr.byteOffset, t);
|
|
562
562
|
return e.pos += t, n;
|
|
563
|
-
},
|
|
563
|
+
}, I = (e) => bo(e, w(e)), vt = (e) => e.arr[e.pos++], w = (e) => {
|
|
564
564
|
let t = 0, n = 1;
|
|
565
565
|
const s = e.arr.length;
|
|
566
566
|
for (; e.pos < s; ) {
|
|
567
567
|
const r = e.arr[e.pos++];
|
|
568
568
|
if (t = t + (r & ct) * n, n *= 128, r < T)
|
|
569
569
|
return t;
|
|
570
|
-
if (t >
|
|
571
|
-
throw
|
|
570
|
+
if (t > Ns)
|
|
571
|
+
throw Vs;
|
|
572
572
|
}
|
|
573
|
-
throw
|
|
574
|
-
},
|
|
575
|
-
let t = e.arr[e.pos++], n = t &
|
|
573
|
+
throw Bs;
|
|
574
|
+
}, _n = (e) => {
|
|
575
|
+
let t = e.arr[e.pos++], n = t & cn, s = 64;
|
|
576
576
|
const r = (t & X) > 0 ? -1 : 1;
|
|
577
577
|
if (!(t & T))
|
|
578
578
|
return r * n;
|
|
@@ -580,19 +580,19 @@ const wt = (e) => new Me(e), So = (e) => e.pos !== e.arr.length, _o = (e, t) =>
|
|
|
580
580
|
for (; e.pos < i; ) {
|
|
581
581
|
if (t = e.arr[e.pos++], n = n + (t & ct) * s, s *= 128, t < T)
|
|
582
582
|
return r * n;
|
|
583
|
-
if (n >
|
|
584
|
-
throw
|
|
583
|
+
if (n > Ns)
|
|
584
|
+
throw Vs;
|
|
585
585
|
}
|
|
586
|
-
throw
|
|
587
|
-
},
|
|
586
|
+
throw Bs;
|
|
587
|
+
}, So = (e) => {
|
|
588
588
|
let t = w(e);
|
|
589
589
|
if (t === 0)
|
|
590
590
|
return "";
|
|
591
591
|
{
|
|
592
|
-
let n = String.fromCodePoint(
|
|
592
|
+
let n = String.fromCodePoint(vt(e));
|
|
593
593
|
if (--t < 100)
|
|
594
594
|
for (; t--; )
|
|
595
|
-
n += String.fromCodePoint(
|
|
595
|
+
n += String.fromCodePoint(vt(e));
|
|
596
596
|
else
|
|
597
597
|
for (; t > 0; ) {
|
|
598
598
|
const s = t < 1e4 ? t : 1e4, r = e.arr.subarray(e.pos, e.pos + s);
|
|
@@ -604,28 +604,28 @@ const wt = (e) => new Me(e), So = (e) => e.pos !== e.arr.length, _o = (e, t) =>
|
|
|
604
604
|
}
|
|
605
605
|
return decodeURIComponent(escape(n));
|
|
606
606
|
}
|
|
607
|
-
},
|
|
607
|
+
}, _o = (e) => (
|
|
608
608
|
/** @type any */
|
|
609
|
-
Vt.decode(
|
|
610
|
-
), nt = Vt ?
|
|
609
|
+
Vt.decode(I(e))
|
|
610
|
+
), nt = Vt ? _o : So, kn = (e, t) => {
|
|
611
611
|
const n = new DataView(e.arr.buffer, e.arr.byteOffset + e.pos, t);
|
|
612
612
|
return e.pos += t, n;
|
|
613
|
-
},
|
|
613
|
+
}, ko = (e) => kn(e, 4).getFloat32(0, !1), Do = (e) => kn(e, 8).getFloat64(0, !1), Eo = (e) => (
|
|
614
614
|
/** @type {any} */
|
|
615
|
-
|
|
616
|
-
),
|
|
615
|
+
kn(e, 8).getBigInt64(0, !1)
|
|
616
|
+
), Co = [
|
|
617
617
|
(e) => {
|
|
618
618
|
},
|
|
619
619
|
// CASE 127: undefined
|
|
620
620
|
(e) => null,
|
|
621
621
|
// CASE 126: null
|
|
622
|
-
|
|
622
|
+
_n,
|
|
623
623
|
// CASE 125: integer
|
|
624
|
-
|
|
624
|
+
ko,
|
|
625
625
|
// CASE 124: float32
|
|
626
|
-
|
|
626
|
+
Do,
|
|
627
627
|
// CASE 123: float64
|
|
628
|
-
|
|
628
|
+
Eo,
|
|
629
629
|
// CASE 122: bigint
|
|
630
630
|
(e) => !1,
|
|
631
631
|
// CASE 121: boolean (false)
|
|
@@ -647,10 +647,10 @@ const wt = (e) => new Me(e), So = (e) => e.pos !== e.arr.length, _o = (e, t) =>
|
|
|
647
647
|
n.push(Xt(e));
|
|
648
648
|
return n;
|
|
649
649
|
},
|
|
650
|
-
|
|
650
|
+
I
|
|
651
651
|
// CASE 116: Uint8Array
|
|
652
|
-
], Xt = (e) =>
|
|
653
|
-
class
|
|
652
|
+
], Xt = (e) => Co[127 - vt(e)](e);
|
|
653
|
+
class Zn extends Me {
|
|
654
654
|
/**
|
|
655
655
|
* @param {Uint8Array} uint8Array
|
|
656
656
|
* @param {function(Decoder):T} reader
|
|
@@ -659,7 +659,7 @@ class Qn extends Me {
|
|
|
659
659
|
super(t), this.reader = n, this.s = null, this.count = 0;
|
|
660
660
|
}
|
|
661
661
|
read() {
|
|
662
|
-
return this.count === 0 && (this.s = this.reader(this),
|
|
662
|
+
return this.count === 0 && (this.s = this.reader(this), yo(this) ? this.count = w(this) + 1 : this.count = -1), this.count--, /** @type {T} */
|
|
663
663
|
this.s;
|
|
664
664
|
}
|
|
665
665
|
}
|
|
@@ -672,8 +672,8 @@ class we extends Me {
|
|
|
672
672
|
}
|
|
673
673
|
read() {
|
|
674
674
|
if (this.count === 0) {
|
|
675
|
-
this.s =
|
|
676
|
-
const t =
|
|
675
|
+
this.s = _n(this);
|
|
676
|
+
const t = Os(this.s);
|
|
677
677
|
this.count = 1, t && (this.s = -this.s, this.count = w(this) + 2);
|
|
678
678
|
}
|
|
679
679
|
return this.count--, /** @type {number} */
|
|
@@ -692,13 +692,13 @@ class Ke extends Me {
|
|
|
692
692
|
*/
|
|
693
693
|
read() {
|
|
694
694
|
if (this.count === 0) {
|
|
695
|
-
const t =
|
|
695
|
+
const t = _n(this), n = t & 1;
|
|
696
696
|
this.diff = P(t / 2), this.count = 1, n && (this.count = w(this) + 2);
|
|
697
697
|
}
|
|
698
698
|
return this.s += this.diff, this.count--, this.s;
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
|
-
class
|
|
701
|
+
class Ao {
|
|
702
702
|
/**
|
|
703
703
|
* @param {Uint8Array} uint8Array
|
|
704
704
|
*/
|
|
@@ -713,8 +713,8 @@ class vo {
|
|
|
713
713
|
return this.spos = t, n;
|
|
714
714
|
}
|
|
715
715
|
}
|
|
716
|
-
const
|
|
717
|
-
const t =
|
|
716
|
+
const Lo = (e) => new Uint8Array(e), Dn = (e, t, n) => new Uint8Array(e, t, n), Io = (e) => {
|
|
717
|
+
const t = Lo(e.byteLength);
|
|
718
718
|
return t.set(e), t;
|
|
719
719
|
};
|
|
720
720
|
class te {
|
|
@@ -722,42 +722,42 @@ class te {
|
|
|
722
722
|
this.cpos = 0, this.cbuf = new Uint8Array(100), this.bufs = [];
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
|
-
const ee = () => new te(),
|
|
725
|
+
const ee = () => new te(), vo = (e) => {
|
|
726
726
|
let t = e.cpos;
|
|
727
727
|
for (let n = 0; n < e.bufs.length; n++)
|
|
728
728
|
t += e.bufs[n].length;
|
|
729
729
|
return t;
|
|
730
730
|
}, B = (e) => {
|
|
731
|
-
const t = new Uint8Array(
|
|
731
|
+
const t = new Uint8Array(vo(e));
|
|
732
732
|
let n = 0;
|
|
733
733
|
for (let s = 0; s < e.bufs.length; s++) {
|
|
734
734
|
const r = e.bufs[s];
|
|
735
735
|
t.set(r, n), n += r.length;
|
|
736
736
|
}
|
|
737
|
-
return t.set(
|
|
738
|
-
},
|
|
737
|
+
return t.set(Dn(e.cbuf.buffer, 0, e.cpos), n), t;
|
|
738
|
+
}, xo = (e, t) => {
|
|
739
739
|
const n = e.cbuf.length;
|
|
740
|
-
n - e.cpos < t && (e.bufs.push(
|
|
740
|
+
n - e.cpos < t && (e.bufs.push(Dn(e.cbuf.buffer, 0, e.cpos)), e.cbuf = new Uint8Array(pt(n, t) * 2), e.cpos = 0);
|
|
741
741
|
}, E = (e, t) => {
|
|
742
742
|
const n = e.cbuf.length;
|
|
743
743
|
e.cpos === n && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(n * 2), e.cpos = 0), e.cbuf[e.cpos++] = t;
|
|
744
|
-
},
|
|
744
|
+
}, ln = E, m = (e, t) => {
|
|
745
745
|
for (; t > ct; )
|
|
746
746
|
E(e, T | ct & t), t = P(t / 128);
|
|
747
747
|
E(e, ct & t);
|
|
748
|
-
},
|
|
749
|
-
const n =
|
|
750
|
-
for (n && (t = -t), E(e, (t >
|
|
748
|
+
}, En = (e, t) => {
|
|
749
|
+
const n = Os(t);
|
|
750
|
+
for (n && (t = -t), E(e, (t > cn ? T : 0) | (n ? X : 0) | cn & t), t = P(t / 64); t > 0; )
|
|
751
751
|
E(e, (t > ct ? T : 0) | ct & t), t = P(t / 128);
|
|
752
|
-
},
|
|
753
|
-
if (t.length <
|
|
754
|
-
const n = zt.encodeInto(t,
|
|
752
|
+
}, an = new Uint8Array(3e4), To = an.length / 3, Mo = (e, t) => {
|
|
753
|
+
if (t.length < To) {
|
|
754
|
+
const n = zt.encodeInto(t, an).written || 0;
|
|
755
755
|
m(e, n);
|
|
756
756
|
for (let s = 0; s < n; s++)
|
|
757
|
-
E(e,
|
|
757
|
+
E(e, an[s]);
|
|
758
758
|
} else
|
|
759
|
-
L(e,
|
|
760
|
-
},
|
|
759
|
+
L(e, Qi(t));
|
|
760
|
+
}, Uo = (e, t) => {
|
|
761
761
|
const n = unescape(encodeURIComponent(t)), s = n.length;
|
|
762
762
|
m(e, s);
|
|
763
763
|
for (let r = 0; r < s; r++)
|
|
@@ -767,33 +767,33 @@ const ee = () => new te(), To = (e) => {
|
|
|
767
767
|
n.codePointAt(r)
|
|
768
768
|
);
|
|
769
769
|
}, lt = zt && /** @type {any} */
|
|
770
|
-
zt.encodeInto ?
|
|
771
|
-
const n = e.cbuf.length, s = e.cpos, r =
|
|
770
|
+
zt.encodeInto ? Mo : Uo, Ue = (e, t) => {
|
|
771
|
+
const n = e.cbuf.length, s = e.cpos, r = Us(n - s, t.length), i = t.length - r;
|
|
772
772
|
e.cbuf.set(t.subarray(0, r), s), e.cpos += r, i > 0 && (e.bufs.push(e.cbuf), e.cbuf = new Uint8Array(pt(n * 2, i)), e.cbuf.set(t.subarray(r)), e.cpos = i);
|
|
773
773
|
}, L = (e, t) => {
|
|
774
774
|
m(e, t.byteLength), Ue(e, t);
|
|
775
|
-
},
|
|
776
|
-
|
|
775
|
+
}, Cn = (e, t) => {
|
|
776
|
+
xo(e, t);
|
|
777
777
|
const n = new DataView(e.cbuf.buffer, e.cpos, t);
|
|
778
778
|
return e.cpos += t, n;
|
|
779
|
-
},
|
|
779
|
+
}, Oo = (e, t) => Cn(e, 4).setFloat32(0, t, !1), Ro = (e, t) => Cn(e, 8).setFloat64(0, t, !1), $o = (e, t) => (
|
|
780
780
|
/** @type {any} */
|
|
781
|
-
|
|
782
|
-
),
|
|
781
|
+
Cn(e, 8).setBigInt64(0, t, !1)
|
|
782
|
+
), Qn = new DataView(new ArrayBuffer(4)), No = (e) => (Qn.setFloat32(0, e), Qn.getFloat32(0) === e), Jt = (e, t) => {
|
|
783
783
|
switch (typeof t) {
|
|
784
784
|
case "string":
|
|
785
785
|
E(e, 119), lt(e, t);
|
|
786
786
|
break;
|
|
787
787
|
case "number":
|
|
788
|
-
|
|
788
|
+
mo(t) && pe(t) <= wo ? (E(e, 125), En(e, t)) : No(t) ? (E(e, 124), Oo(e, t)) : (E(e, 123), Ro(e, t));
|
|
789
789
|
break;
|
|
790
790
|
case "bigint":
|
|
791
|
-
E(e, 122),
|
|
791
|
+
E(e, 122), $o(e, t);
|
|
792
792
|
break;
|
|
793
793
|
case "object":
|
|
794
794
|
if (t === null)
|
|
795
795
|
E(e, 126);
|
|
796
|
-
else if (
|
|
796
|
+
else if (Yi(t)) {
|
|
797
797
|
E(e, 117), m(e, t.length);
|
|
798
798
|
for (let n = 0; n < t.length; n++)
|
|
799
799
|
Jt(e, t[n]);
|
|
@@ -816,7 +816,7 @@ zt.encodeInto ? Oo : Ro, Ue = (e, t) => {
|
|
|
816
816
|
E(e, 127);
|
|
817
817
|
}
|
|
818
818
|
};
|
|
819
|
-
class
|
|
819
|
+
class ts extends te {
|
|
820
820
|
/**
|
|
821
821
|
* @param {function(Encoder, T):void} writer
|
|
822
822
|
*/
|
|
@@ -830,8 +830,8 @@ class es extends te {
|
|
|
830
830
|
this.s === t ? this.count++ : (this.count > 0 && m(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
const
|
|
834
|
-
e.count > 0 && (
|
|
833
|
+
const es = (e) => {
|
|
834
|
+
e.count > 0 && (En(e.encoder, e.count === 1 ? e.s : -e.s), e.count > 1 && m(e.encoder, e.count - 2));
|
|
835
835
|
};
|
|
836
836
|
class me {
|
|
837
837
|
constructor() {
|
|
@@ -841,16 +841,16 @@ class me {
|
|
|
841
841
|
* @param {number} v
|
|
842
842
|
*/
|
|
843
843
|
write(t) {
|
|
844
|
-
this.s === t ? this.count++ : (
|
|
844
|
+
this.s === t ? this.count++ : (es(this), this.count = 1, this.s = t);
|
|
845
845
|
}
|
|
846
846
|
toUint8Array() {
|
|
847
|
-
return
|
|
847
|
+
return es(this), B(this.encoder);
|
|
848
848
|
}
|
|
849
849
|
}
|
|
850
|
-
const
|
|
850
|
+
const ns = (e) => {
|
|
851
851
|
if (e.count > 0) {
|
|
852
852
|
const t = e.diff * 2 + (e.count === 1 ? 0 : 1);
|
|
853
|
-
|
|
853
|
+
En(e.encoder, t), e.count > 1 && m(e.encoder, e.count - 2);
|
|
854
854
|
}
|
|
855
855
|
};
|
|
856
856
|
class Ye {
|
|
@@ -861,13 +861,13 @@ class Ye {
|
|
|
861
861
|
* @param {number} v
|
|
862
862
|
*/
|
|
863
863
|
write(t) {
|
|
864
|
-
this.diff === t - this.s ? (this.s = t, this.count++) : (
|
|
864
|
+
this.diff === t - this.s ? (this.s = t, this.count++) : (ns(this), this.count = 1, this.diff = t - this.s, this.s = t);
|
|
865
865
|
}
|
|
866
866
|
toUint8Array() {
|
|
867
|
-
return
|
|
867
|
+
return ns(this), B(this.encoder);
|
|
868
868
|
}
|
|
869
869
|
}
|
|
870
|
-
class
|
|
870
|
+
class Bo {
|
|
871
871
|
constructor() {
|
|
872
872
|
this.sarr = [], this.s = "", this.lensE = new me();
|
|
873
873
|
}
|
|
@@ -882,16 +882,16 @@ class Fo {
|
|
|
882
882
|
return this.sarr.push(this.s), this.s = "", lt(t, this.sarr.join("")), Ue(t, this.lensE.toUint8Array()), B(t);
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
const
|
|
885
|
+
const Vo = crypto.getRandomValues.bind(crypto), Fs = () => Vo(new Uint32Array(1))[0], Fo = [1e7] + -1e3 + -4e3 + -8e3 + -1e11, Ho = () => Fo.replace(
|
|
886
886
|
/[018]/g,
|
|
887
887
|
/** @param {number} c */
|
|
888
|
-
(e) => (e ^
|
|
888
|
+
(e) => (e ^ Fs() & 15 >> e / 4).toString(16)
|
|
889
889
|
), _e = Date.now, xt = (e) => (
|
|
890
890
|
/** @type {Promise<T>} */
|
|
891
891
|
new Promise(e)
|
|
892
892
|
);
|
|
893
893
|
Promise.all.bind(Promise);
|
|
894
|
-
class
|
|
894
|
+
class jo {
|
|
895
895
|
/**
|
|
896
896
|
* @param {L} left
|
|
897
897
|
* @param {R} right
|
|
@@ -900,9 +900,9 @@ class Ko {
|
|
|
900
900
|
this.left = t, this.right = n;
|
|
901
901
|
}
|
|
902
902
|
}
|
|
903
|
-
const Y = (e, t) => new
|
|
903
|
+
const Y = (e, t) => new jo(e, t);
|
|
904
904
|
typeof DOMParser < "u" && new DOMParser();
|
|
905
|
-
const
|
|
905
|
+
const zo = (e) => ji(e, (t, n) => `${n}:${t};`).join(""), Z = Symbol, Hs = Z(), js = Z(), Ko = Z(), Yo = Z(), Xo = Z(), zs = Z(), Jo = Z(), Ks = Z(), Wo = Z(), Po = (e) => {
|
|
906
906
|
const t = [];
|
|
907
907
|
let n = 0;
|
|
908
908
|
for (; n < e.length; n++) {
|
|
@@ -910,26 +910,26 @@ const Yo = (e) => Ki(e, (t, n) => `${n}:${t};`).join(""), Z = Symbol, zs = Z(),
|
|
|
910
910
|
s.constructor === String || s.constructor === Number || s.constructor === Object && t.push(JSON.stringify(s));
|
|
911
911
|
}
|
|
912
912
|
return t;
|
|
913
|
-
},
|
|
914
|
-
[
|
|
915
|
-
[
|
|
916
|
-
[
|
|
917
|
-
[
|
|
918
|
-
[
|
|
919
|
-
[
|
|
920
|
-
[
|
|
921
|
-
[
|
|
913
|
+
}, Go = {
|
|
914
|
+
[Hs]: Y("font-weight", "bold"),
|
|
915
|
+
[js]: Y("font-weight", "normal"),
|
|
916
|
+
[Ko]: Y("color", "blue"),
|
|
917
|
+
[Xo]: Y("color", "green"),
|
|
918
|
+
[Yo]: Y("color", "grey"),
|
|
919
|
+
[zs]: Y("color", "red"),
|
|
920
|
+
[Jo]: Y("color", "purple"),
|
|
921
|
+
[Ks]: Y("color", "orange"),
|
|
922
922
|
// not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
923
|
-
[
|
|
924
|
-
},
|
|
923
|
+
[Wo]: Y("color", "black")
|
|
924
|
+
}, qo = (e) => {
|
|
925
925
|
const t = [], n = [], s = x();
|
|
926
926
|
let r = [], i = 0;
|
|
927
927
|
for (; i < e.length; i++) {
|
|
928
|
-
const o = e[i], c =
|
|
928
|
+
const o = e[i], c = Go[o];
|
|
929
929
|
if (c !== void 0)
|
|
930
930
|
s.set(c.left, c.right);
|
|
931
931
|
else if (o.constructor === String || o.constructor === Number) {
|
|
932
|
-
const l =
|
|
932
|
+
const l = zo(s);
|
|
933
933
|
i > 0 || l.length > 0 ? (t.push("%c" + o), n.push(l)) : t.push(o);
|
|
934
934
|
} else
|
|
935
935
|
break;
|
|
@@ -939,9 +939,9 @@ const Yo = (e) => Ki(e, (t, n) => `${n}:${t};`).join(""), Z = Symbol, zs = Z(),
|
|
|
939
939
|
o instanceof Symbol || r.push(o);
|
|
940
940
|
}
|
|
941
941
|
return r;
|
|
942
|
-
},
|
|
943
|
-
console.log(...
|
|
944
|
-
},
|
|
942
|
+
}, Zo = po ? qo : Po, Qo = (...e) => {
|
|
943
|
+
console.log(...Zo(e)), tc.forEach((t) => t.print(e));
|
|
944
|
+
}, tc = at(), Ys = (e) => ({
|
|
945
945
|
/**
|
|
946
946
|
* @return {IterableIterator<T>}
|
|
947
947
|
*/
|
|
@@ -950,17 +950,17 @@ const Yo = (e) => Ki(e, (t, n) => `${n}:${t};`).join(""), Z = Symbol, zs = Z(),
|
|
|
950
950
|
},
|
|
951
951
|
// @ts-ignore
|
|
952
952
|
next: e
|
|
953
|
-
}),
|
|
953
|
+
}), ec = (e, t) => Ys(() => {
|
|
954
954
|
let n;
|
|
955
955
|
do
|
|
956
956
|
n = e.next();
|
|
957
957
|
while (!n.done && !t(n.value));
|
|
958
958
|
return n;
|
|
959
|
-
}), Xe = (e, t) =>
|
|
959
|
+
}), Xe = (e, t) => Ys(() => {
|
|
960
960
|
const { done: n, value: s } = e.next();
|
|
961
961
|
return { done: n, value: n ? void 0 : t(s) };
|
|
962
962
|
});
|
|
963
|
-
class
|
|
963
|
+
class An {
|
|
964
964
|
/**
|
|
965
965
|
* @param {number} clock
|
|
966
966
|
* @param {number} len
|
|
@@ -974,16 +974,16 @@ class ne {
|
|
|
974
974
|
this.clients = /* @__PURE__ */ new Map();
|
|
975
975
|
}
|
|
976
976
|
}
|
|
977
|
-
const
|
|
977
|
+
const Xs = (e, t, n) => t.clients.forEach((s, r) => {
|
|
978
978
|
const i = (
|
|
979
979
|
/** @type {Array<GC|Item>} */
|
|
980
980
|
e.doc.store.clients.get(r)
|
|
981
981
|
);
|
|
982
982
|
for (let o = 0; o < s.length; o++) {
|
|
983
983
|
const c = s[o];
|
|
984
|
-
|
|
984
|
+
or(e, i, c.clock, c.len, n);
|
|
985
985
|
}
|
|
986
|
-
}),
|
|
986
|
+
}), nc = (e, t) => {
|
|
987
987
|
let n = 0, s = e.length - 1;
|
|
988
988
|
for (; n <= s; ) {
|
|
989
989
|
const r = P((n + s) / 2), i = e[r], o = i.clock;
|
|
@@ -995,10 +995,10 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
995
995
|
s = r - 1;
|
|
996
996
|
}
|
|
997
997
|
return null;
|
|
998
|
-
},
|
|
998
|
+
}, Js = (e, t) => {
|
|
999
999
|
const n = e.clients.get(t.client);
|
|
1000
|
-
return n !== void 0 &&
|
|
1001
|
-
},
|
|
1000
|
+
return n !== void 0 && nc(n, t.clock) !== null;
|
|
1001
|
+
}, Ln = (e) => {
|
|
1002
1002
|
e.clients.forEach((t) => {
|
|
1003
1003
|
t.sort((r, i) => r.clock - i.clock);
|
|
1004
1004
|
let n, s;
|
|
@@ -1008,25 +1008,25 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
t.length = s;
|
|
1010
1010
|
});
|
|
1011
|
-
},
|
|
1011
|
+
}, sc = (e) => {
|
|
1012
1012
|
const t = new ne();
|
|
1013
1013
|
for (let n = 0; n < e.length; n++)
|
|
1014
1014
|
e[n].clients.forEach((s, r) => {
|
|
1015
1015
|
if (!t.clients.has(r)) {
|
|
1016
1016
|
const i = s.slice();
|
|
1017
1017
|
for (let o = n + 1; o < e.length; o++)
|
|
1018
|
-
|
|
1018
|
+
Ki(i, e[o].clients.get(r) || []);
|
|
1019
1019
|
t.clients.set(r, i);
|
|
1020
1020
|
}
|
|
1021
1021
|
});
|
|
1022
|
-
return
|
|
1022
|
+
return Ln(t), t;
|
|
1023
1023
|
}, ke = (e, t, n, s) => {
|
|
1024
1024
|
q(e.clients, t, () => (
|
|
1025
1025
|
/** @type {Array<DeleteItem>} */
|
|
1026
1026
|
[]
|
|
1027
|
-
)).push(new
|
|
1028
|
-
},
|
|
1029
|
-
const t =
|
|
1027
|
+
)).push(new An(n, s));
|
|
1028
|
+
}, rc = () => new ne(), ic = (e) => {
|
|
1029
|
+
const t = rc();
|
|
1030
1030
|
return e.clients.forEach((n, s) => {
|
|
1031
1031
|
const r = [];
|
|
1032
1032
|
for (let i = 0; i < n.length; i++) {
|
|
@@ -1037,7 +1037,7 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1037
1037
|
if (i + 1 < n.length)
|
|
1038
1038
|
for (let a = n[i + 1]; i + 1 < n.length && a.deleted; a = n[++i + 1])
|
|
1039
1039
|
l += a.length;
|
|
1040
|
-
r.push(new
|
|
1040
|
+
r.push(new An(c, l));
|
|
1041
1041
|
}
|
|
1042
1042
|
}
|
|
1043
1043
|
r.length > 0 && t.clients.set(s, r);
|
|
@@ -1063,11 +1063,11 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1063
1063
|
[]
|
|
1064
1064
|
));
|
|
1065
1065
|
for (let c = 0; c < i; c++)
|
|
1066
|
-
o.push(new
|
|
1066
|
+
o.push(new An(e.readDsClock(), e.readDsLen()));
|
|
1067
1067
|
}
|
|
1068
1068
|
}
|
|
1069
1069
|
return t;
|
|
1070
|
-
},
|
|
1070
|
+
}, ss = (e, t, n) => {
|
|
1071
1071
|
const s = new ne(), r = w(e.restDecoder);
|
|
1072
1072
|
for (let i = 0; i < r; i++) {
|
|
1073
1073
|
e.resetDsCurVal();
|
|
@@ -1077,8 +1077,8 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1077
1077
|
if (d < a) {
|
|
1078
1078
|
a < u && ke(s, o, a, u - a);
|
|
1079
1079
|
let f = z(l, d), g = l[f];
|
|
1080
|
-
for (!g.deleted && g.id.clock < d && (l.splice(f + 1, 0,
|
|
1081
|
-
g.deleted || (u < g.id.clock + g.length && l.splice(f, 0,
|
|
1080
|
+
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); )
|
|
1081
|
+
g.deleted || (u < g.id.clock + g.length && l.splice(f, 0, ve(t, g, u - g.id.clock)), g.delete(t));
|
|
1082
1082
|
} else
|
|
1083
1083
|
ke(s, o, d, u - d);
|
|
1084
1084
|
}
|
|
@@ -1088,13 +1088,13 @@ const Ws = (e, t, n) => t.clients.forEach((s, r) => {
|
|
|
1088
1088
|
return m(i.restEncoder, 0), Rt(i, s), i.toUint8Array();
|
|
1089
1089
|
}
|
|
1090
1090
|
return null;
|
|
1091
|
-
},
|
|
1092
|
-
class mt extends
|
|
1091
|
+
}, Ws = Fs;
|
|
1092
|
+
class mt extends Xi {
|
|
1093
1093
|
/**
|
|
1094
1094
|
* @param {DocOpts} opts configuration
|
|
1095
1095
|
*/
|
|
1096
|
-
constructor({ guid: t =
|
|
1097
|
-
super(), this.gc = s, this.gcFilter = r, this.clientID =
|
|
1096
|
+
constructor({ guid: t = Ho(), collectionid: n = null, gc: s = !0, gcFilter: r = () => !0, meta: i = null, autoLoad: o = !1, shouldLoad: c = !0 } = {}) {
|
|
1097
|
+
super(), this.gc = s, this.gcFilter = r, this.clientID = Ws(), this.guid = t, this.collectionid = n, this.share = /* @__PURE__ */ new Map(), this.store = new rr(), 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) => {
|
|
1098
1098
|
this.on("load", () => {
|
|
1099
1099
|
this.isLoaded = !0, a(this);
|
|
1100
1100
|
});
|
|
@@ -1302,7 +1302,7 @@ class mt extends Wi {
|
|
|
1302
1302
|
this.emit("destroyed", [!0]), this.emit("destroy", [this]), super.destroy();
|
|
1303
1303
|
}
|
|
1304
1304
|
}
|
|
1305
|
-
class
|
|
1305
|
+
class Ps {
|
|
1306
1306
|
/**
|
|
1307
1307
|
* @param {decoding.Decoder} decoder
|
|
1308
1308
|
*/
|
|
@@ -1324,7 +1324,7 @@ class qs {
|
|
|
1324
1324
|
return w(this.restDecoder);
|
|
1325
1325
|
}
|
|
1326
1326
|
}
|
|
1327
|
-
class
|
|
1327
|
+
class Gs extends Ps {
|
|
1328
1328
|
/**
|
|
1329
1329
|
* @return {ID}
|
|
1330
1330
|
*/
|
|
@@ -1348,7 +1348,7 @@ class Zs extends qs {
|
|
|
1348
1348
|
* @return {number} info An unsigned 8-bit integer
|
|
1349
1349
|
*/
|
|
1350
1350
|
readInfo() {
|
|
1351
|
-
return
|
|
1351
|
+
return vt(this.restDecoder);
|
|
1352
1352
|
}
|
|
1353
1353
|
/**
|
|
1354
1354
|
* @return {string}
|
|
@@ -1386,7 +1386,7 @@ class Zs extends qs {
|
|
|
1386
1386
|
* @return {Uint8Array}
|
|
1387
1387
|
*/
|
|
1388
1388
|
readBuf() {
|
|
1389
|
-
return
|
|
1389
|
+
return Io(I(this.restDecoder));
|
|
1390
1390
|
}
|
|
1391
1391
|
/**
|
|
1392
1392
|
* Legacy implementation uses JSON parse. We use any-decoding in v2.
|
|
@@ -1403,7 +1403,7 @@ class Zs extends qs {
|
|
|
1403
1403
|
return nt(this.restDecoder);
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
|
-
class
|
|
1406
|
+
class oc {
|
|
1407
1407
|
/**
|
|
1408
1408
|
* @param {decoding.Decoder} decoder
|
|
1409
1409
|
*/
|
|
@@ -1427,12 +1427,12 @@ class lc {
|
|
|
1427
1427
|
return this.dsCurrVal += t, t;
|
|
1428
1428
|
}
|
|
1429
1429
|
}
|
|
1430
|
-
class Tt extends
|
|
1430
|
+
class Tt extends oc {
|
|
1431
1431
|
/**
|
|
1432
1432
|
* @param {decoding.Decoder} decoder
|
|
1433
1433
|
*/
|
|
1434
1434
|
constructor(t) {
|
|
1435
|
-
super(t), this.keys = [], w(t), this.keyClockDecoder = new Ke(
|
|
1435
|
+
super(t), this.keys = [], w(t), this.keyClockDecoder = new Ke(I(t)), this.clientDecoder = new we(I(t)), this.leftClockDecoder = new Ke(I(t)), this.rightClockDecoder = new Ke(I(t)), this.infoDecoder = new Zn(I(t), vt), this.stringDecoder = new Ao(I(t)), this.parentInfoDecoder = new Zn(I(t), vt), this.typeRefDecoder = new we(I(t)), this.lenDecoder = new we(I(t));
|
|
1436
1436
|
}
|
|
1437
1437
|
/**
|
|
1438
1438
|
* @return {ID}
|
|
@@ -1498,7 +1498,7 @@ class Tt extends lc {
|
|
|
1498
1498
|
* @return {Uint8Array}
|
|
1499
1499
|
*/
|
|
1500
1500
|
readBuf() {
|
|
1501
|
-
return
|
|
1501
|
+
return I(this.restDecoder);
|
|
1502
1502
|
}
|
|
1503
1503
|
/**
|
|
1504
1504
|
* This is mainly here for legacy purposes.
|
|
@@ -1523,7 +1523,7 @@ class Tt extends lc {
|
|
|
1523
1523
|
}
|
|
1524
1524
|
}
|
|
1525
1525
|
}
|
|
1526
|
-
class
|
|
1526
|
+
class qs {
|
|
1527
1527
|
constructor() {
|
|
1528
1528
|
this.restEncoder = ee();
|
|
1529
1529
|
}
|
|
@@ -1545,7 +1545,7 @@ class Qs {
|
|
|
1545
1545
|
m(this.restEncoder, t);
|
|
1546
1546
|
}
|
|
1547
1547
|
}
|
|
1548
|
-
class se extends
|
|
1548
|
+
class se extends qs {
|
|
1549
1549
|
/**
|
|
1550
1550
|
* @param {ID} id
|
|
1551
1551
|
*/
|
|
@@ -1569,7 +1569,7 @@ class se extends Qs {
|
|
|
1569
1569
|
* @param {number} info An unsigned 8-bit integer
|
|
1570
1570
|
*/
|
|
1571
1571
|
writeInfo(t) {
|
|
1572
|
-
|
|
1572
|
+
ln(this.restEncoder, t);
|
|
1573
1573
|
}
|
|
1574
1574
|
/**
|
|
1575
1575
|
* @param {string} s
|
|
@@ -1622,7 +1622,7 @@ class se extends Qs {
|
|
|
1622
1622
|
lt(this.restEncoder, t);
|
|
1623
1623
|
}
|
|
1624
1624
|
}
|
|
1625
|
-
class
|
|
1625
|
+
class Zs {
|
|
1626
1626
|
constructor() {
|
|
1627
1627
|
this.restEncoder = ee(), this.dsCurrVal = 0;
|
|
1628
1628
|
}
|
|
@@ -1646,9 +1646,9 @@ class tr {
|
|
|
1646
1646
|
t === 0 && j(), m(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
1647
1647
|
}
|
|
1648
1648
|
}
|
|
1649
|
-
class ht extends
|
|
1649
|
+
class ht extends Zs {
|
|
1650
1650
|
constructor() {
|
|
1651
|
-
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Ye(), this.clientEncoder = new me(), this.leftClockEncoder = new Ye(), this.rightClockEncoder = new Ye(), this.infoEncoder = new
|
|
1651
|
+
super(), this.keyMap = /* @__PURE__ */ new Map(), this.keyClock = 0, this.keyClockEncoder = new Ye(), this.clientEncoder = new me(), this.leftClockEncoder = new Ye(), this.rightClockEncoder = new Ye(), this.infoEncoder = new ts(ln), this.stringEncoder = new Bo(), this.parentInfoEncoder = new ts(ln), this.typeRefEncoder = new me(), this.lenEncoder = new me();
|
|
1652
1652
|
}
|
|
1653
1653
|
toUint8Array() {
|
|
1654
1654
|
const t = ee();
|
|
@@ -1739,7 +1739,7 @@ class ht extends tr {
|
|
|
1739
1739
|
n === void 0 ? (this.keyClockEncoder.write(this.keyClock++), this.stringEncoder.write(t)) : this.keyClockEncoder.write(n);
|
|
1740
1740
|
}
|
|
1741
1741
|
}
|
|
1742
|
-
const
|
|
1742
|
+
const cc = (e, t, n, s) => {
|
|
1743
1743
|
s = pt(s, t[0].id.clock);
|
|
1744
1744
|
const r = z(t, s);
|
|
1745
1745
|
m(e.restEncoder, t.length - r), e.writeClient(n), m(e.restEncoder, s);
|
|
@@ -1747,14 +1747,14 @@ const ac = (e, t, n, s) => {
|
|
|
1747
1747
|
i.write(e, s - i.id.clock);
|
|
1748
1748
|
for (let o = r + 1; o < t.length; o++)
|
|
1749
1749
|
t[o].write(e, 0);
|
|
1750
|
-
},
|
|
1750
|
+
}, vn = (e, t, n) => {
|
|
1751
1751
|
const s = /* @__PURE__ */ new Map();
|
|
1752
1752
|
n.forEach((r, i) => {
|
|
1753
1753
|
C(t, i) > r && s.set(i, r);
|
|
1754
1754
|
}), Oe(t).forEach((r, i) => {
|
|
1755
1755
|
n.has(i) || s.set(i, 0);
|
|
1756
1756
|
}), m(e.restEncoder, s.size), W(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
1757
|
-
|
|
1757
|
+
cc(
|
|
1758
1758
|
e,
|
|
1759
1759
|
/** @type {Array<GC|Item>} */
|
|
1760
1760
|
t.clients.get(r),
|
|
@@ -1762,7 +1762,7 @@ const ac = (e, t, n, s) => {
|
|
|
1762
1762
|
i
|
|
1763
1763
|
);
|
|
1764
1764
|
});
|
|
1765
|
-
},
|
|
1765
|
+
}, lc = (e, t) => {
|
|
1766
1766
|
const n = x(), s = w(e.restDecoder);
|
|
1767
1767
|
for (let r = 0; r < s; r++) {
|
|
1768
1768
|
const i = w(e.restDecoder), o = new Array(i), c = e.readClient();
|
|
@@ -1796,7 +1796,7 @@ const ac = (e, t, n, s) => {
|
|
|
1796
1796
|
// parent
|
|
1797
1797
|
d && (h & Yt) === Yt ? e.readString() : null,
|
|
1798
1798
|
// parentSub
|
|
1799
|
-
|
|
1799
|
+
Cr(e, h)
|
|
1800
1800
|
// item content
|
|
1801
1801
|
);
|
|
1802
1802
|
o[a] = u, l += u.length;
|
|
@@ -1805,7 +1805,7 @@ const ac = (e, t, n, s) => {
|
|
|
1805
1805
|
}
|
|
1806
1806
|
}
|
|
1807
1807
|
return n;
|
|
1808
|
-
},
|
|
1808
|
+
}, ac = (e, t, n) => {
|
|
1809
1809
|
const s = [];
|
|
1810
1810
|
let r = W(n.keys()).sort((f, g) => f - g);
|
|
1811
1811
|
if (r.length === 0)
|
|
@@ -1828,7 +1828,7 @@ const ac = (e, t, n, s) => {
|
|
|
1828
1828
|
let o = i();
|
|
1829
1829
|
if (o === null)
|
|
1830
1830
|
return null;
|
|
1831
|
-
const c = new
|
|
1831
|
+
const c = new rr(), l = /* @__PURE__ */ new Map(), a = (f, g) => {
|
|
1832
1832
|
const p = l.get(f);
|
|
1833
1833
|
(p == null || p > g) && l.set(f, g);
|
|
1834
1834
|
};
|
|
@@ -1888,13 +1888,13 @@ const ac = (e, t, n, s) => {
|
|
|
1888
1888
|
}
|
|
1889
1889
|
if (c.clients.size > 0) {
|
|
1890
1890
|
const f = new ht();
|
|
1891
|
-
return
|
|
1891
|
+
return vn(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
1892
1892
|
}
|
|
1893
1893
|
return null;
|
|
1894
|
-
},
|
|
1894
|
+
}, hc = (e, t) => vn(e, t.doc.store, t.beforeState), uc = (e, t, n, s = new Tt(e)) => S(t, (r) => {
|
|
1895
1895
|
r.local = !1;
|
|
1896
1896
|
let i = !1;
|
|
1897
|
-
const o = r.doc, c = o.store, l =
|
|
1897
|
+
const o = r.doc, c = o.store, l = lc(s, o), a = ac(r, c, l), h = c.pendingStructs;
|
|
1898
1898
|
if (h) {
|
|
1899
1899
|
for (const [u, f] of h.missing)
|
|
1900
1900
|
if (f < C(c, u)) {
|
|
@@ -1910,11 +1910,11 @@ const ac = (e, t, n, s) => {
|
|
|
1910
1910
|
}
|
|
1911
1911
|
} else
|
|
1912
1912
|
c.pendingStructs = a;
|
|
1913
|
-
const d =
|
|
1913
|
+
const d = ss(s, r, c);
|
|
1914
1914
|
if (c.pendingDs) {
|
|
1915
1915
|
const u = new Tt(wt(c.pendingDs));
|
|
1916
1916
|
w(u.restDecoder);
|
|
1917
|
-
const f =
|
|
1917
|
+
const f = ss(u, r, c);
|
|
1918
1918
|
d && f ? c.pendingDs = De([d, f]) : c.pendingDs = d || f;
|
|
1919
1919
|
} else
|
|
1920
1920
|
c.pendingDs = d;
|
|
@@ -1923,43 +1923,43 @@ const ac = (e, t, n, s) => {
|
|
|
1923
1923
|
/** @type {{update: Uint8Array}} */
|
|
1924
1924
|
c.pendingStructs.update
|
|
1925
1925
|
);
|
|
1926
|
-
c.pendingStructs = null,
|
|
1926
|
+
c.pendingStructs = null, Qs(r.doc, u);
|
|
1927
1927
|
}
|
|
1928
|
-
}, n, !1),
|
|
1928
|
+
}, n, !1), Qs = (e, t, n, s = Tt) => {
|
|
1929
1929
|
const r = wt(t);
|
|
1930
|
-
|
|
1931
|
-
},
|
|
1932
|
-
|
|
1933
|
-
},
|
|
1934
|
-
const s =
|
|
1935
|
-
|
|
1930
|
+
uc(r, e, n, new s(r));
|
|
1931
|
+
}, tr = (e, t, n) => Qs(e, t, n, Gs), dc = (e, t, n = /* @__PURE__ */ new Map()) => {
|
|
1932
|
+
vn(e, t.store, n), Rt(e, ic(t.store));
|
|
1933
|
+
}, fc = (e, t = new Uint8Array([0]), n = new ht()) => {
|
|
1934
|
+
const s = er(t);
|
|
1935
|
+
dc(n, e, s);
|
|
1936
1936
|
const r = [n.toUint8Array()];
|
|
1937
|
-
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(
|
|
1937
|
+
if (e.store.pendingDs && r.push(e.store.pendingDs), e.store.pendingStructs && r.push(Ic(e.store.pendingStructs.update, t)), r.length > 1) {
|
|
1938
1938
|
if (n.constructor === se)
|
|
1939
|
-
return
|
|
1939
|
+
return Ac(r.map((i, o) => o === 0 ? i : xc(i)));
|
|
1940
1940
|
if (n.constructor === ht)
|
|
1941
1941
|
return De(r);
|
|
1942
1942
|
}
|
|
1943
1943
|
return r[0];
|
|
1944
|
-
},
|
|
1944
|
+
}, xn = (e, t) => fc(e, t, new se()), gc = (e) => {
|
|
1945
1945
|
const t = /* @__PURE__ */ new Map(), n = w(e.restDecoder);
|
|
1946
1946
|
for (let s = 0; s < n; s++) {
|
|
1947
1947
|
const r = w(e.restDecoder), i = w(e.restDecoder);
|
|
1948
1948
|
t.set(r, i);
|
|
1949
1949
|
}
|
|
1950
1950
|
return t;
|
|
1951
|
-
},
|
|
1951
|
+
}, er = (e) => gc(new Ps(wt(e))), nr = (e, t) => (m(e.restEncoder, t.size), W(t.entries()).sort((n, s) => s[0] - n[0]).forEach(([n, s]) => {
|
|
1952
1952
|
m(e.restEncoder, n), m(e.restEncoder, s);
|
|
1953
|
-
}), e),
|
|
1954
|
-
class
|
|
1953
|
+
}), e), pc = (e, t) => nr(e, Oe(t.store)), wc = (e, t = new Zs()) => (e instanceof Map ? nr(t, e) : pc(t, e), t.toUint8Array()), mc = (e) => wc(e, new qs());
|
|
1954
|
+
class yc {
|
|
1955
1955
|
constructor() {
|
|
1956
1956
|
this.l = [];
|
|
1957
1957
|
}
|
|
1958
1958
|
}
|
|
1959
|
-
const
|
|
1959
|
+
const rs = () => new yc(), is = (e, t) => e.l.push(t), os = (e, t) => {
|
|
1960
1960
|
const n = e.l, s = n.length;
|
|
1961
1961
|
e.l = n.filter((r) => t !== r), s === e.l.length && console.error("[yjs] Tried to remove event handler that doesn't exist.");
|
|
1962
|
-
},
|
|
1962
|
+
}, sr = (e, t, n) => Sn(e.l, [t, n]);
|
|
1963
1963
|
class Et {
|
|
1964
1964
|
/**
|
|
1965
1965
|
* @param {number} client client id
|
|
@@ -1969,19 +1969,19 @@ class Et {
|
|
|
1969
1969
|
this.client = t, this.clock = n;
|
|
1970
1970
|
}
|
|
1971
1971
|
}
|
|
1972
|
-
const he = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, b = (e, t) => new Et(e, t),
|
|
1972
|
+
const he = (e, t) => e === t || e !== null && t !== null && e.client === t.client && e.clock === t.clock, b = (e, t) => new Et(e, t), bc = (e) => {
|
|
1973
1973
|
for (const [t, n] of e.doc.share.entries())
|
|
1974
1974
|
if (n === e)
|
|
1975
1975
|
return t;
|
|
1976
1976
|
throw j();
|
|
1977
|
-
}, _t = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !
|
|
1978
|
-
const n = q(e.meta,
|
|
1977
|
+
}, _t = (e, t) => t === void 0 ? !e.deleted : t.sv.has(e.id.client) && (t.sv.get(e.id.client) || 0) > e.id.clock && !Js(t.ds, e.id), hn = (e, t) => {
|
|
1978
|
+
const n = q(e.meta, hn, at), s = e.doc.store;
|
|
1979
1979
|
n.has(t) || (t.sv.forEach((r, i) => {
|
|
1980
1980
|
r < C(s, i) && st(e, b(i, r));
|
|
1981
|
-
}),
|
|
1981
|
+
}), Xs(e, t.ds, (r) => {
|
|
1982
1982
|
}), n.add(t));
|
|
1983
1983
|
};
|
|
1984
|
-
class
|
|
1984
|
+
class rr {
|
|
1985
1985
|
constructor() {
|
|
1986
1986
|
this.clients = /* @__PURE__ */ new Map(), this.pendingStructs = null, this.pendingDs = null;
|
|
1987
1987
|
}
|
|
@@ -1998,7 +1998,7 @@ const Oe = (e) => {
|
|
|
1998
1998
|
return 0;
|
|
1999
1999
|
const s = n[n.length - 1];
|
|
2000
2000
|
return s.id.clock + s.length;
|
|
2001
|
-
},
|
|
2001
|
+
}, ir = (e, t) => {
|
|
2002
2002
|
let n = e.clients.get(t.id.client);
|
|
2003
2003
|
if (n === void 0)
|
|
2004
2004
|
n = [], e.clients.set(t.id.client, n);
|
|
@@ -2023,40 +2023,40 @@ const Oe = (e) => {
|
|
|
2023
2023
|
o = P((n + s) / 2);
|
|
2024
2024
|
}
|
|
2025
2025
|
throw j();
|
|
2026
|
-
},
|
|
2026
|
+
}, Sc = (e, t) => {
|
|
2027
2027
|
const n = e.clients.get(t.client);
|
|
2028
2028
|
return n[z(n, t.clock)];
|
|
2029
2029
|
}, Je = (
|
|
2030
2030
|
/** @type {function(StructStore,ID):Item} */
|
|
2031
|
-
|
|
2032
|
-
),
|
|
2031
|
+
Sc
|
|
2032
|
+
), un = (e, t, n) => {
|
|
2033
2033
|
const s = z(t, n), r = t[s];
|
|
2034
|
-
return r.id.clock < n && r instanceof k ? (t.splice(s + 1, 0,
|
|
2034
|
+
return r.id.clock < n && r instanceof k ? (t.splice(s + 1, 0, ve(e, r, n - r.id.clock)), s + 1) : s;
|
|
2035
2035
|
}, st = (e, t) => {
|
|
2036
2036
|
const n = (
|
|
2037
2037
|
/** @type {Array<Item>} */
|
|
2038
2038
|
e.doc.store.clients.get(t.client)
|
|
2039
2039
|
);
|
|
2040
|
-
return n[
|
|
2041
|
-
},
|
|
2040
|
+
return n[un(e, n, t.clock)];
|
|
2041
|
+
}, cs = (e, t, n) => {
|
|
2042
2042
|
const s = t.clients.get(n.client), r = z(s, n.clock), i = s[r];
|
|
2043
|
-
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== U && s.splice(r + 1, 0,
|
|
2044
|
-
},
|
|
2043
|
+
return n.clock !== i.id.clock + i.length - 1 && i.constructor !== U && s.splice(r + 1, 0, ve(e, i, n.clock - i.id.clock + 1)), i;
|
|
2044
|
+
}, _c = (e, t, n) => {
|
|
2045
2045
|
const s = (
|
|
2046
2046
|
/** @type {Array<GC|Item>} */
|
|
2047
2047
|
e.clients.get(t.id.client)
|
|
2048
2048
|
);
|
|
2049
2049
|
s[z(s, t.id.clock)] = n;
|
|
2050
|
-
},
|
|
2050
|
+
}, or = (e, t, n, s, r) => {
|
|
2051
2051
|
if (s === 0)
|
|
2052
2052
|
return;
|
|
2053
2053
|
const i = n + s;
|
|
2054
|
-
let o =
|
|
2054
|
+
let o = un(e, t, n), c;
|
|
2055
2055
|
do
|
|
2056
|
-
c = t[o++], i < c.id.clock + c.length &&
|
|
2056
|
+
c = t[o++], i < c.id.clock + c.length && un(e, t, i), r(c);
|
|
2057
2057
|
while (o < t.length && t[o].id.clock < i);
|
|
2058
2058
|
};
|
|
2059
|
-
class
|
|
2059
|
+
class kc {
|
|
2060
2060
|
/**
|
|
2061
2061
|
* @param {Doc} doc
|
|
2062
2062
|
* @param {any} origin
|
|
@@ -2066,7 +2066,7 @@ class Ec {
|
|
|
2066
2066
|
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;
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
|
-
const
|
|
2069
|
+
const ls = (e, t) => t.deleteSet.clients.size === 0 && !zi(t.afterState, (n, s) => t.beforeState.get(s) !== n) ? !1 : (Ln(t.deleteSet), hc(e, t), Rt(e, t.deleteSet), !0), as = (e, t, n) => {
|
|
2070
2070
|
const s = t._item;
|
|
2071
2071
|
(s === null || s.id.clock < (e.beforeState.get(s.id.client) || 0) && !s.deleted) && q(e.changed, t, at).add(n);
|
|
2072
2072
|
}, ye = (e, t) => {
|
|
@@ -2085,7 +2085,7 @@ const as = (e, t) => t.deleteSet.clients.size === 0 && !Yi(t.afterState, (n, s)
|
|
|
2085
2085
|
}
|
|
2086
2086
|
const i = t - r;
|
|
2087
2087
|
return i && e.splice(t + 1 - i, i), i;
|
|
2088
|
-
},
|
|
2088
|
+
}, Dc = (e, t, n) => {
|
|
2089
2089
|
for (const [s, r] of e.clients.entries()) {
|
|
2090
2090
|
const i = (
|
|
2091
2091
|
/** @type {Array<GC|Item>} */
|
|
@@ -2101,23 +2101,23 @@ const as = (e, t) => t.deleteSet.clients.size === 0 && !Yi(t.afterState, (n, s)
|
|
|
2101
2101
|
}
|
|
2102
2102
|
}
|
|
2103
2103
|
}
|
|
2104
|
-
},
|
|
2104
|
+
}, Ec = (e, t) => {
|
|
2105
2105
|
e.clients.forEach((n, s) => {
|
|
2106
2106
|
const r = (
|
|
2107
2107
|
/** @type {Array<GC|Item>} */
|
|
2108
2108
|
t.clients.get(s)
|
|
2109
2109
|
);
|
|
2110
2110
|
for (let i = n.length - 1; i >= 0; i--) {
|
|
2111
|
-
const o = n[i], c =
|
|
2111
|
+
const o = n[i], c = Us(r.length - 1, 1 + z(r, o.clock + o.len - 1));
|
|
2112
2112
|
for (let l = c, a = r[l]; l > 0 && a.id.clock >= o.clock; a = r[l])
|
|
2113
2113
|
l -= 1 + ye(r, l);
|
|
2114
2114
|
}
|
|
2115
2115
|
});
|
|
2116
|
-
},
|
|
2116
|
+
}, cr = (e, t) => {
|
|
2117
2117
|
if (t < e.length) {
|
|
2118
2118
|
const n = e[t], s = n.doc, r = s.store, i = n.deleteSet, o = n._mergeStructs;
|
|
2119
2119
|
try {
|
|
2120
|
-
|
|
2120
|
+
Ln(i), n.afterState = Oe(n.doc.store), s.emit("beforeObserverCalls", [n, s]);
|
|
2121
2121
|
const c = [];
|
|
2122
2122
|
n.changed.forEach(
|
|
2123
2123
|
(l, a) => c.push(() => {
|
|
@@ -2129,11 +2129,11 @@ const as = (e, t) => t.deleteSet.clients.size === 0 && !Yi(t.afterState, (n, s)
|
|
|
2129
2129
|
(h) => h.target._item === null || !h.target._item.deleted
|
|
2130
2130
|
), l.forEach((h) => {
|
|
2131
2131
|
h.currentTarget = a, h._path = null;
|
|
2132
|
-
}), l.sort((h, d) => h.path.length - d.path.length),
|
|
2132
|
+
}), l.sort((h, d) => h.path.length - d.path.length), sr(a._dEH, l, n));
|
|
2133
2133
|
});
|
|
2134
|
-
}), c.push(() => s.emit("afterTransaction", [n, s])),
|
|
2134
|
+
}), c.push(() => s.emit("afterTransaction", [n, s])), Sn(c, []), n._needFormattingCleanup && Kc(n);
|
|
2135
2135
|
} finally {
|
|
2136
|
-
s.gc &&
|
|
2136
|
+
s.gc && Dc(i, r, s.gcFilter), Ec(i, r), n.afterState.forEach((h, d) => {
|
|
2137
2137
|
const u = n.beforeState.get(d) || 0;
|
|
2138
2138
|
if (u !== h) {
|
|
2139
2139
|
const f = (
|
|
@@ -2151,35 +2151,35 @@ const as = (e, t) => t.deleteSet.clients.size === 0 && !Yi(t.afterState, (n, s)
|
|
|
2151
2151
|
), g = z(f, u);
|
|
2152
2152
|
g + 1 < f.length && ye(f, g + 1) > 1 || g > 0 && ye(f, g);
|
|
2153
2153
|
}
|
|
2154
|
-
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (
|
|
2154
|
+
if (!n.local && n.afterState.get(s.clientID) !== n.beforeState.get(s.clientID) && (Qo(Ks, Hs, "[yjs] ", js, zs, "Changed the client-id because another client seems to be using it."), s.clientID = Ws()), s.emit("afterTransactionCleanup", [n, s]), s._observers.has("update")) {
|
|
2155
2155
|
const h = new se();
|
|
2156
|
-
|
|
2156
|
+
ls(h, n) && s.emit("update", [h.toUint8Array(), n.origin, s, n]);
|
|
2157
2157
|
}
|
|
2158
2158
|
if (s._observers.has("updateV2")) {
|
|
2159
2159
|
const h = new ht();
|
|
2160
|
-
|
|
2160
|
+
ls(h, n) && s.emit("updateV2", [h.toUint8Array(), n.origin, s, n]);
|
|
2161
2161
|
}
|
|
2162
2162
|
const { subdocsAdded: c, subdocsLoaded: l, subdocsRemoved: a } = n;
|
|
2163
2163
|
(c.size > 0 || a.size > 0 || l.size > 0) && (c.forEach((h) => {
|
|
2164
2164
|
h.clientID = s.clientID, h.collectionid == null && (h.collectionid = s.collectionid), s.subdocs.add(h);
|
|
2165
|
-
}), 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])) :
|
|
2165
|
+
}), 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])) : cr(e, t + 1);
|
|
2166
2166
|
}
|
|
2167
2167
|
}
|
|
2168
2168
|
}, S = (e, t, n = null, s = !0) => {
|
|
2169
2169
|
const r = e._transactionCleanups;
|
|
2170
2170
|
let i = !1, o = null;
|
|
2171
|
-
e._transaction === null && (i = !0, e._transaction = new
|
|
2171
|
+
e._transaction === null && (i = !0, e._transaction = new kc(e, n, s), r.push(e._transaction), r.length === 1 && e.emit("beforeAllTransactions", [e]), e.emit("beforeTransaction", [e._transaction, e]));
|
|
2172
2172
|
try {
|
|
2173
2173
|
o = t(e._transaction);
|
|
2174
2174
|
} finally {
|
|
2175
2175
|
if (i) {
|
|
2176
2176
|
const c = e._transaction === r[0];
|
|
2177
|
-
e._transaction = null, c &&
|
|
2177
|
+
e._transaction = null, c && cr(r, 0);
|
|
2178
2178
|
}
|
|
2179
2179
|
}
|
|
2180
2180
|
return o;
|
|
2181
2181
|
};
|
|
2182
|
-
function*
|
|
2182
|
+
function* Cc(e) {
|
|
2183
2183
|
const t = w(e.restDecoder);
|
|
2184
2184
|
for (let n = 0; n < t; n++) {
|
|
2185
2185
|
const s = w(e.restDecoder), r = e.readClient();
|
|
@@ -2205,7 +2205,7 @@ function* Lc(e) {
|
|
|
2205
2205
|
// parent
|
|
2206
2206
|
l && (c & Yt) === Yt ? e.readString() : null,
|
|
2207
2207
|
// parentSub
|
|
2208
|
-
|
|
2208
|
+
Cr(e, c)
|
|
2209
2209
|
// item content
|
|
2210
2210
|
);
|
|
2211
2211
|
yield a, i += a.length;
|
|
@@ -2216,13 +2216,13 @@ function* Lc(e) {
|
|
|
2216
2216
|
}
|
|
2217
2217
|
}
|
|
2218
2218
|
}
|
|
2219
|
-
class
|
|
2219
|
+
class Tn {
|
|
2220
2220
|
/**
|
|
2221
2221
|
* @param {UpdateDecoderV1 | UpdateDecoderV2} decoder
|
|
2222
2222
|
* @param {boolean} filterSkips
|
|
2223
2223
|
*/
|
|
2224
2224
|
constructor(t, n) {
|
|
2225
|
-
this.gen =
|
|
2225
|
+
this.gen = Cc(t), this.curr = null, this.done = !1, this.filterSkips = n, this.next();
|
|
2226
2226
|
}
|
|
2227
2227
|
/**
|
|
2228
2228
|
* @return {Item | GC | Skip |null}
|
|
@@ -2234,7 +2234,7 @@ class Mn {
|
|
|
2234
2234
|
return this.curr;
|
|
2235
2235
|
}
|
|
2236
2236
|
}
|
|
2237
|
-
class
|
|
2237
|
+
class Mn {
|
|
2238
2238
|
/**
|
|
2239
2239
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
2240
2240
|
*/
|
|
@@ -2242,7 +2242,7 @@ class Un {
|
|
|
2242
2242
|
this.currClient = 0, this.startClock = 0, this.written = 0, this.encoder = t, this.clientStructs = [];
|
|
2243
2243
|
}
|
|
2244
2244
|
}
|
|
2245
|
-
const
|
|
2245
|
+
const Ac = (e) => De(e, Gs, se), Lc = (e, t) => {
|
|
2246
2246
|
if (e.constructor === U) {
|
|
2247
2247
|
const { client: n, clock: s } = e.id;
|
|
2248
2248
|
return new U(b(n, s + t), e.length - t);
|
|
@@ -2269,8 +2269,8 @@ const vc = (e) => De(e, Zs, se), Ic = (e, t) => {
|
|
|
2269
2269
|
if (e.length === 1)
|
|
2270
2270
|
return e[0];
|
|
2271
2271
|
const s = e.map((h) => new t(wt(h)));
|
|
2272
|
-
let r = s.map((h) => new
|
|
2273
|
-
const o = new n(), c = new
|
|
2272
|
+
let r = s.map((h) => new Tn(h, !0)), i = null;
|
|
2273
|
+
const o = new n(), c = new Mn(o);
|
|
2274
2274
|
for (; r = r.filter((u) => u.curr !== null), r.sort(
|
|
2275
2275
|
/** @type {function(any,any):number} */
|
|
2276
2276
|
(u, f) => {
|
|
@@ -2308,7 +2308,7 @@ const vc = (e) => De(e, Zs, se), Ic = (e, t) => {
|
|
|
2308
2308
|
}
|
|
2309
2309
|
else {
|
|
2310
2310
|
const g = i.struct.id.clock + i.struct.length - u.id.clock;
|
|
2311
|
-
g > 0 && (i.struct.constructor === O ? i.struct.length -= g : u =
|
|
2311
|
+
g > 0 && (i.struct.constructor === O ? i.struct.length -= g : u = Lc(u, g)), i.struct.mergeWith(
|
|
2312
2312
|
/** @type {any} */
|
|
2313
2313
|
u
|
|
2314
2314
|
) || (tt(c, i.struct, i.offset), i = { struct: u, offset: 0 }, h.next());
|
|
@@ -2321,11 +2321,11 @@ const vc = (e) => De(e, Zs, se), Ic = (e, t) => {
|
|
|
2321
2321
|
for (let u = h.curr; u !== null && u.id.client === d && u.id.clock === i.struct.id.clock + i.struct.length && u.constructor !== O; u = h.next())
|
|
2322
2322
|
tt(c, i.struct, i.offset), i = { struct: u, offset: 0 };
|
|
2323
2323
|
}
|
|
2324
|
-
i !== null && (tt(c, i.struct, i.offset), i = null),
|
|
2325
|
-
const l = s.map((h) => In(h)), a =
|
|
2324
|
+
i !== null && (tt(c, i.struct, i.offset), i = null), Un(c);
|
|
2325
|
+
const l = s.map((h) => In(h)), a = sc(l);
|
|
2326
2326
|
return Rt(o, a), o.toUint8Array();
|
|
2327
|
-
},
|
|
2328
|
-
const r =
|
|
2327
|
+
}, Ic = (e, t, n = Tt, s = ht) => {
|
|
2328
|
+
const r = er(t), i = new s(), o = new Mn(i), c = new n(wt(e)), l = new Tn(c, !1);
|
|
2329
2329
|
for (; l.curr; ) {
|
|
2330
2330
|
const h = l.curr, d = h.id.client, u = r.get(d) || 0;
|
|
2331
2331
|
if (l.curr.constructor === O) {
|
|
@@ -2339,29 +2339,29 @@ const vc = (e) => De(e, Zs, se), Ic = (e, t) => {
|
|
|
2339
2339
|
for (; l.curr && l.curr.id.client === d && l.curr.id.clock + l.curr.length <= u; )
|
|
2340
2340
|
l.next();
|
|
2341
2341
|
}
|
|
2342
|
-
|
|
2342
|
+
Un(o);
|
|
2343
2343
|
const a = In(c);
|
|
2344
2344
|
return Rt(i, a), i.toUint8Array();
|
|
2345
|
-
},
|
|
2345
|
+
}, lr = (e) => {
|
|
2346
2346
|
e.written > 0 && (e.clientStructs.push({ written: e.written, restEncoder: B(e.encoder.restEncoder) }), e.encoder.restEncoder = ee(), e.written = 0);
|
|
2347
2347
|
}, tt = (e, t, n) => {
|
|
2348
|
-
e.written > 0 && e.currClient !== t.id.client &&
|
|
2349
|
-
},
|
|
2350
|
-
|
|
2348
|
+
e.written > 0 && e.currClient !== t.id.client && lr(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++;
|
|
2349
|
+
}, Un = (e) => {
|
|
2350
|
+
lr(e);
|
|
2351
2351
|
const t = e.encoder.restEncoder;
|
|
2352
2352
|
m(t, e.clientStructs.length);
|
|
2353
2353
|
for (let n = 0; n < e.clientStructs.length; n++) {
|
|
2354
2354
|
const s = e.clientStructs[n];
|
|
2355
2355
|
m(t, s.written), Ue(t, s.restEncoder);
|
|
2356
2356
|
}
|
|
2357
|
-
},
|
|
2358
|
-
const r = new n(wt(e)), i = new
|
|
2357
|
+
}, vc = (e, t, n, s) => {
|
|
2358
|
+
const r = new n(wt(e)), i = new Tn(r, !1), o = new s(), c = new Mn(o);
|
|
2359
2359
|
for (let a = i.curr; a !== null; a = i.next())
|
|
2360
2360
|
tt(c, t(a), 0);
|
|
2361
|
-
|
|
2361
|
+
Un(c);
|
|
2362
2362
|
const l = In(r);
|
|
2363
2363
|
return Rt(o, l), o.toUint8Array();
|
|
2364
|
-
},
|
|
2364
|
+
}, xc = (e) => vc(e, ao, Tt, se), hs = "You must not compute changes after the event-handler fired.";
|
|
2365
2365
|
class Re {
|
|
2366
2366
|
/**
|
|
2367
2367
|
* @param {T} target The changed type.
|
|
@@ -2384,7 +2384,7 @@ class Re {
|
|
|
2384
2384
|
* type === event.target // => true
|
|
2385
2385
|
*/
|
|
2386
2386
|
get path() {
|
|
2387
|
-
return this._path || (this._path =
|
|
2387
|
+
return this._path || (this._path = Tc(this.currentTarget, this.target));
|
|
2388
2388
|
}
|
|
2389
2389
|
/**
|
|
2390
2390
|
* Check if a struct is deleted by this event.
|
|
@@ -2395,7 +2395,7 @@ class Re {
|
|
|
2395
2395
|
* @return {boolean}
|
|
2396
2396
|
*/
|
|
2397
2397
|
deletes(t) {
|
|
2398
|
-
return
|
|
2398
|
+
return Js(this.transaction.deleteSet, t.id);
|
|
2399
2399
|
}
|
|
2400
2400
|
/**
|
|
2401
2401
|
* @type {Map<string, { action: 'add' | 'update' | 'delete', oldValue: any, newValue: any }>}
|
|
@@ -2403,7 +2403,7 @@ class Re {
|
|
|
2403
2403
|
get keys() {
|
|
2404
2404
|
if (this._keys === null) {
|
|
2405
2405
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2406
|
-
throw G(
|
|
2406
|
+
throw G(hs);
|
|
2407
2407
|
const t = /* @__PURE__ */ new Map(), n = this.target;
|
|
2408
2408
|
/** @type Set<string|null> */
|
|
2409
2409
|
this.transaction.changed.get(n).forEach((r) => {
|
|
@@ -2471,7 +2471,7 @@ class Re {
|
|
|
2471
2471
|
let t = this._changes;
|
|
2472
2472
|
if (t === null) {
|
|
2473
2473
|
if (this.transaction.doc._transactionCleanups.length === 0)
|
|
2474
|
-
throw G(
|
|
2474
|
+
throw G(hs);
|
|
2475
2475
|
const n = this.target, s = at(), r = at(), i = [];
|
|
2476
2476
|
if (t = {
|
|
2477
2477
|
added: s,
|
|
@@ -2496,7 +2496,7 @@ class Re {
|
|
|
2496
2496
|
);
|
|
2497
2497
|
}
|
|
2498
2498
|
}
|
|
2499
|
-
const
|
|
2499
|
+
const Tc = (e, t) => {
|
|
2500
2500
|
const n = [];
|
|
2501
2501
|
for (; t._item !== null && t !== e; ) {
|
|
2502
2502
|
if (t._item.parentSub !== null)
|
|
@@ -2514,35 +2514,35 @@ const Uc = (e, t) => {
|
|
|
2514
2514
|
t._item.parent;
|
|
2515
2515
|
}
|
|
2516
2516
|
return n;
|
|
2517
|
-
},
|
|
2518
|
-
let
|
|
2519
|
-
class
|
|
2517
|
+
}, ar = 80;
|
|
2518
|
+
let On = 0;
|
|
2519
|
+
class Mc {
|
|
2520
2520
|
/**
|
|
2521
2521
|
* @param {Item} p
|
|
2522
2522
|
* @param {number} index
|
|
2523
2523
|
*/
|
|
2524
2524
|
constructor(t, n) {
|
|
2525
|
-
t.marker = !0, this.p = t, this.index = n, this.timestamp =
|
|
2525
|
+
t.marker = !0, this.p = t, this.index = n, this.timestamp = On++;
|
|
2526
2526
|
}
|
|
2527
2527
|
}
|
|
2528
|
-
const
|
|
2529
|
-
e.timestamp =
|
|
2530
|
-
},
|
|
2531
|
-
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp =
|
|
2532
|
-
},
|
|
2533
|
-
if (e.length >=
|
|
2528
|
+
const Uc = (e) => {
|
|
2529
|
+
e.timestamp = On++;
|
|
2530
|
+
}, hr = (e, t, n) => {
|
|
2531
|
+
e.p.marker = !1, e.p = t, t.marker = !0, e.index = n, e.timestamp = On++;
|
|
2532
|
+
}, Oc = (e, t, n) => {
|
|
2533
|
+
if (e.length >= ar) {
|
|
2534
2534
|
const s = e.reduce((r, i) => r.timestamp < i.timestamp ? r : i);
|
|
2535
|
-
return
|
|
2535
|
+
return hr(s, t, n), s;
|
|
2536
2536
|
} else {
|
|
2537
|
-
const s = new
|
|
2537
|
+
const s = new Mc(t, n);
|
|
2538
2538
|
return e.push(s), s;
|
|
2539
2539
|
}
|
|
2540
|
-
},
|
|
2540
|
+
}, $e = (e, t) => {
|
|
2541
2541
|
if (e._start === null || t === 0 || e._searchMarker === null)
|
|
2542
2542
|
return null;
|
|
2543
2543
|
const n = e._searchMarker.length === 0 ? null : e._searchMarker.reduce((i, o) => pe(t - i.index) < pe(t - o.index) ? i : o);
|
|
2544
2544
|
let s = e._start, r = 0;
|
|
2545
|
-
for (n !== null && (s = n.p, r = n.index,
|
|
2545
|
+
for (n !== null && (s = n.p, r = n.index, Uc(n)); s.right !== null && r < t; ) {
|
|
2546
2546
|
if (!s.deleted && s.countable) {
|
|
2547
2547
|
if (t < r + s.length)
|
|
2548
2548
|
break;
|
|
@@ -2555,7 +2555,7 @@ const Rc = (e) => {
|
|
|
2555
2555
|
for (; s.left !== null && s.left.id.client === s.id.client && s.left.id.clock + s.left.length === s.id.clock; )
|
|
2556
2556
|
s = s.left, !s.deleted && s.countable && (r -= s.length);
|
|
2557
2557
|
return n !== null && pe(n.index - r) < /** @type {YText|YArray<any>} */
|
|
2558
|
-
s.parent.length /
|
|
2558
|
+
s.parent.length / ar ? (hr(n, s, r), n) : Oc(e._searchMarker, s, r);
|
|
2559
2559
|
}, Wt = (e, t, n) => {
|
|
2560
2560
|
for (let s = e.length - 1; s >= 0; s--) {
|
|
2561
2561
|
const r = e[s];
|
|
@@ -2571,16 +2571,16 @@ const Rc = (e) => {
|
|
|
2571
2571
|
}
|
|
2572
2572
|
(t < r.index || n > 0 && t === r.index) && (r.index = pt(t, r.index + n));
|
|
2573
2573
|
}
|
|
2574
|
-
},
|
|
2574
|
+
}, Ne = (e, t, n) => {
|
|
2575
2575
|
const s = e, r = t.changedParentTypes;
|
|
2576
2576
|
for (; q(r, e, () => []).push(n), e._item !== null; )
|
|
2577
2577
|
e = /** @type {AbstractType<any>} */
|
|
2578
2578
|
e._item.parent;
|
|
2579
|
-
|
|
2579
|
+
sr(s._eH, n, t);
|
|
2580
2580
|
};
|
|
2581
2581
|
class A {
|
|
2582
2582
|
constructor() {
|
|
2583
|
-
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH =
|
|
2583
|
+
this._item = null, this._map = /* @__PURE__ */ new Map(), this._start = null, this.doc = null, this._length = 0, this._eH = rs(), this._dEH = rs(), this._searchMarker = null;
|
|
2584
2584
|
}
|
|
2585
2585
|
/**
|
|
2586
2586
|
* @return {AbstractType<any>|null}
|
|
@@ -2650,7 +2650,7 @@ class A {
|
|
|
2650
2650
|
* @param {function(EventType, Transaction):void} f Observer function
|
|
2651
2651
|
*/
|
|
2652
2652
|
observe(t) {
|
|
2653
|
-
|
|
2653
|
+
is(this._eH, t);
|
|
2654
2654
|
}
|
|
2655
2655
|
/**
|
|
2656
2656
|
* Observe all events that are created by this type and its children.
|
|
@@ -2658,7 +2658,7 @@ class A {
|
|
|
2658
2658
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2659
2659
|
*/
|
|
2660
2660
|
observeDeep(t) {
|
|
2661
|
-
|
|
2661
|
+
is(this._dEH, t);
|
|
2662
2662
|
}
|
|
2663
2663
|
/**
|
|
2664
2664
|
* Unregister an observer function.
|
|
@@ -2666,7 +2666,7 @@ class A {
|
|
|
2666
2666
|
* @param {function(EventType,Transaction):void} f Observer function
|
|
2667
2667
|
*/
|
|
2668
2668
|
unobserve(t) {
|
|
2669
|
-
|
|
2669
|
+
os(this._eH, t);
|
|
2670
2670
|
}
|
|
2671
2671
|
/**
|
|
2672
2672
|
* Unregister an observer function.
|
|
@@ -2674,7 +2674,7 @@ class A {
|
|
|
2674
2674
|
* @param {function(Array<YEvent<any>>,Transaction):void} f Observer function
|
|
2675
2675
|
*/
|
|
2676
2676
|
unobserveDeep(t) {
|
|
2677
|
-
|
|
2677
|
+
os(this._dEH, t);
|
|
2678
2678
|
}
|
|
2679
2679
|
/**
|
|
2680
2680
|
* @abstract
|
|
@@ -2683,7 +2683,7 @@ class A {
|
|
|
2683
2683
|
toJSON() {
|
|
2684
2684
|
}
|
|
2685
2685
|
}
|
|
2686
|
-
const
|
|
2686
|
+
const ur = (e, t, n) => {
|
|
2687
2687
|
t < 0 && (t = e._length + t), n < 0 && (n = e._length + n);
|
|
2688
2688
|
let s = n - t;
|
|
2689
2689
|
const r = [];
|
|
@@ -2702,7 +2702,7 @@ const fr = (e, t, n) => {
|
|
|
2702
2702
|
i = i.right;
|
|
2703
2703
|
}
|
|
2704
2704
|
return r;
|
|
2705
|
-
},
|
|
2705
|
+
}, dr = (e) => {
|
|
2706
2706
|
const t = [];
|
|
2707
2707
|
let n = e._start;
|
|
2708
2708
|
for (; n !== null; ) {
|
|
@@ -2724,12 +2724,12 @@ const fr = (e, t, n) => {
|
|
|
2724
2724
|
}
|
|
2725
2725
|
s = s.right;
|
|
2726
2726
|
}
|
|
2727
|
-
},
|
|
2727
|
+
}, fr = (e, t) => {
|
|
2728
2728
|
const n = [];
|
|
2729
2729
|
return Pt(e, (s, r) => {
|
|
2730
2730
|
n.push(t(s, r, e));
|
|
2731
2731
|
}), n;
|
|
2732
|
-
},
|
|
2732
|
+
}, Rc = (e) => {
|
|
2733
2733
|
let t = e._start, n = null, s = 0;
|
|
2734
2734
|
return {
|
|
2735
2735
|
[Symbol.iterator]() {
|
|
@@ -2753,8 +2753,8 @@ const fr = (e, t, n) => {
|
|
|
2753
2753
|
};
|
|
2754
2754
|
}
|
|
2755
2755
|
};
|
|
2756
|
-
},
|
|
2757
|
-
const n =
|
|
2756
|
+
}, gr = (e, t) => {
|
|
2757
|
+
const n = $e(e, t);
|
|
2758
2758
|
let s = e._start;
|
|
2759
2759
|
for (n !== null && (s = n.p, t -= n.index); s !== null; s = s.right)
|
|
2760
2760
|
if (!s.deleted && s.countable) {
|
|
@@ -2804,12 +2804,12 @@ const fr = (e, t, n) => {
|
|
|
2804
2804
|
}
|
|
2805
2805
|
}
|
|
2806
2806
|
}), h();
|
|
2807
|
-
},
|
|
2807
|
+
}, pr = () => G("Length exceeded!"), wr = (e, t, n, s) => {
|
|
2808
2808
|
if (n > t._length)
|
|
2809
|
-
throw
|
|
2809
|
+
throw pr();
|
|
2810
2810
|
if (n === 0)
|
|
2811
2811
|
return t._searchMarker && Wt(t._searchMarker, n, s.length), Ee(e, t, null, s);
|
|
2812
|
-
const r = n, i =
|
|
2812
|
+
const r = n, i = $e(t, n);
|
|
2813
2813
|
let o = t._start;
|
|
2814
2814
|
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)
|
|
2815
2815
|
if (!o.deleted && o.countable) {
|
|
@@ -2820,23 +2820,23 @@ const fr = (e, t, n) => {
|
|
|
2820
2820
|
n -= o.length;
|
|
2821
2821
|
}
|
|
2822
2822
|
return t._searchMarker && Wt(t._searchMarker, r, s.length), Ee(e, t, o, s);
|
|
2823
|
-
},
|
|
2823
|
+
}, $c = (e, t, n) => {
|
|
2824
2824
|
let r = (t._searchMarker || []).reduce((i, o) => o.index > i.index ? o : i, { index: 0, p: t._start }).p;
|
|
2825
2825
|
if (r)
|
|
2826
2826
|
for (; r.right; )
|
|
2827
2827
|
r = r.right;
|
|
2828
2828
|
return Ee(e, t, r, n);
|
|
2829
|
-
},
|
|
2829
|
+
}, mr = (e, t, n, s) => {
|
|
2830
2830
|
if (s === 0)
|
|
2831
2831
|
return;
|
|
2832
|
-
const r = n, i = s, o =
|
|
2832
|
+
const r = n, i = s, o = $e(t, n);
|
|
2833
2833
|
let c = t._start;
|
|
2834
2834
|
for (o !== null && (c = o.p, n -= o.index); c !== null && n > 0; c = c.right)
|
|
2835
2835
|
!c.deleted && c.countable && (n < c.length && st(e, b(c.id.client, c.id.clock + n)), n -= c.length);
|
|
2836
2836
|
for (; s > 0 && c !== null; )
|
|
2837
2837
|
c.deleted || (s < c.length && st(e, b(c.id.client, c.id.clock + s)), c.delete(e), s -= c.length), c = c.right;
|
|
2838
2838
|
if (s > 0)
|
|
2839
|
-
throw
|
|
2839
|
+
throw pr();
|
|
2840
2840
|
t._searchMarker && Wt(
|
|
2841
2841
|
t._searchMarker,
|
|
2842
2842
|
r,
|
|
@@ -2846,7 +2846,7 @@ const fr = (e, t, n) => {
|
|
|
2846
2846
|
}, Ce = (e, t, n) => {
|
|
2847
2847
|
const s = t._map.get(n);
|
|
2848
2848
|
s !== void 0 && s.delete(e);
|
|
2849
|
-
},
|
|
2849
|
+
}, Rn = (e, t, n, s) => {
|
|
2850
2850
|
const r = t._map.get(n) || null, i = e.doc, o = i.clientID;
|
|
2851
2851
|
let c;
|
|
2852
2852
|
if (s == null)
|
|
@@ -2882,15 +2882,15 @@ const fr = (e, t, n) => {
|
|
|
2882
2882
|
}, $n = (e, t) => {
|
|
2883
2883
|
const n = e._map.get(t);
|
|
2884
2884
|
return n !== void 0 && !n.deleted ? n.content.getContent()[n.length - 1] : void 0;
|
|
2885
|
-
},
|
|
2885
|
+
}, yr = (e) => {
|
|
2886
2886
|
const t = {};
|
|
2887
2887
|
return e._map.forEach((n, s) => {
|
|
2888
2888
|
n.deleted || (t[s] = n.content.getContent()[n.length - 1]);
|
|
2889
2889
|
}), t;
|
|
2890
|
-
},
|
|
2890
|
+
}, br = (e, t) => {
|
|
2891
2891
|
const n = e._map.get(t);
|
|
2892
2892
|
return n !== void 0 && !n.deleted;
|
|
2893
|
-
},
|
|
2893
|
+
}, Nc = (e, t) => {
|
|
2894
2894
|
const n = {};
|
|
2895
2895
|
return e._map.forEach((s, r) => {
|
|
2896
2896
|
let i = s;
|
|
@@ -2898,12 +2898,12 @@ const fr = (e, t, n) => {
|
|
|
2898
2898
|
i = i.left;
|
|
2899
2899
|
i !== null && _t(i, t) && (n[r] = i.content.getContent()[i.length - 1]);
|
|
2900
2900
|
}), n;
|
|
2901
|
-
}, ue = (e) =>
|
|
2901
|
+
}, ue = (e) => ec(
|
|
2902
2902
|
e.entries(),
|
|
2903
2903
|
/** @param {any} entry */
|
|
2904
2904
|
(t) => !t[1].deleted
|
|
2905
2905
|
);
|
|
2906
|
-
class
|
|
2906
|
+
class Bc extends Re {
|
|
2907
2907
|
}
|
|
2908
2908
|
class Ct extends A {
|
|
2909
2909
|
constructor() {
|
|
@@ -2968,7 +2968,7 @@ class Ct extends A {
|
|
|
2968
2968
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
2969
2969
|
*/
|
|
2970
2970
|
_callObserver(t, n) {
|
|
2971
|
-
super._callObserver(t, n),
|
|
2971
|
+
super._callObserver(t, n), Ne(this, t, new Bc(this, t));
|
|
2972
2972
|
}
|
|
2973
2973
|
/**
|
|
2974
2974
|
* Inserts new content at an index.
|
|
@@ -2988,7 +2988,7 @@ class Ct extends A {
|
|
|
2988
2988
|
*/
|
|
2989
2989
|
insert(t, n) {
|
|
2990
2990
|
this.doc !== null ? S(this.doc, (s) => {
|
|
2991
|
-
|
|
2991
|
+
wr(
|
|
2992
2992
|
s,
|
|
2993
2993
|
this,
|
|
2994
2994
|
t,
|
|
@@ -3006,7 +3006,7 @@ class Ct extends A {
|
|
|
3006
3006
|
*/
|
|
3007
3007
|
push(t) {
|
|
3008
3008
|
this.doc !== null ? S(this.doc, (n) => {
|
|
3009
|
-
|
|
3009
|
+
$c(
|
|
3010
3010
|
n,
|
|
3011
3011
|
this,
|
|
3012
3012
|
/** @type {any} */
|
|
@@ -3030,7 +3030,7 @@ class Ct extends A {
|
|
|
3030
3030
|
*/
|
|
3031
3031
|
delete(t, n = 1) {
|
|
3032
3032
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3033
|
-
|
|
3033
|
+
mr(s, this, t, n);
|
|
3034
3034
|
}) : this._prelimContent.splice(t, n);
|
|
3035
3035
|
}
|
|
3036
3036
|
/**
|
|
@@ -3040,7 +3040,7 @@ class Ct extends A {
|
|
|
3040
3040
|
* @return {T}
|
|
3041
3041
|
*/
|
|
3042
3042
|
get(t) {
|
|
3043
|
-
return
|
|
3043
|
+
return gr(this, t);
|
|
3044
3044
|
}
|
|
3045
3045
|
/**
|
|
3046
3046
|
* Transforms this YArray to a JavaScript Array.
|
|
@@ -3048,7 +3048,7 @@ class Ct extends A {
|
|
|
3048
3048
|
* @return {Array<T>}
|
|
3049
3049
|
*/
|
|
3050
3050
|
toArray() {
|
|
3051
|
-
return
|
|
3051
|
+
return dr(this);
|
|
3052
3052
|
}
|
|
3053
3053
|
/**
|
|
3054
3054
|
* Returns a portion of this YArray into a JavaScript Array selected
|
|
@@ -3059,7 +3059,7 @@ class Ct extends A {
|
|
|
3059
3059
|
* @return {Array<T>}
|
|
3060
3060
|
*/
|
|
3061
3061
|
slice(t = 0, n = this.length) {
|
|
3062
|
-
return
|
|
3062
|
+
return ur(this, t, n);
|
|
3063
3063
|
}
|
|
3064
3064
|
/**
|
|
3065
3065
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3079,7 +3079,7 @@ class Ct extends A {
|
|
|
3079
3079
|
* callback function
|
|
3080
3080
|
*/
|
|
3081
3081
|
map(t) {
|
|
3082
|
-
return
|
|
3082
|
+
return fr(
|
|
3083
3083
|
this,
|
|
3084
3084
|
/** @type {any} */
|
|
3085
3085
|
t
|
|
@@ -3097,17 +3097,17 @@ class Ct extends A {
|
|
|
3097
3097
|
* @return {IterableIterator<T>}
|
|
3098
3098
|
*/
|
|
3099
3099
|
[Symbol.iterator]() {
|
|
3100
|
-
return
|
|
3100
|
+
return Rc(this);
|
|
3101
3101
|
}
|
|
3102
3102
|
/**
|
|
3103
3103
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3104
3104
|
*/
|
|
3105
3105
|
_write(t) {
|
|
3106
|
-
t.writeTypeRef(
|
|
3106
|
+
t.writeTypeRef(ll);
|
|
3107
3107
|
}
|
|
3108
3108
|
}
|
|
3109
|
-
const
|
|
3110
|
-
class
|
|
3109
|
+
const Vc = (e) => new Ct();
|
|
3110
|
+
class Fc extends Re {
|
|
3111
3111
|
/**
|
|
3112
3112
|
* @param {YMap<T>} ymap The YArray that changed.
|
|
3113
3113
|
* @param {Transaction} transaction
|
|
@@ -3169,7 +3169,7 @@ class ut extends A {
|
|
|
3169
3169
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
3170
3170
|
*/
|
|
3171
3171
|
_callObserver(t, n) {
|
|
3172
|
-
|
|
3172
|
+
Ne(this, t, new Fc(this, t, n));
|
|
3173
3173
|
}
|
|
3174
3174
|
/**
|
|
3175
3175
|
* Transforms this Shared Type to a JSON object.
|
|
@@ -3270,7 +3270,7 @@ class ut extends A {
|
|
|
3270
3270
|
*/
|
|
3271
3271
|
set(t, n) {
|
|
3272
3272
|
return this.doc !== null ? S(this.doc, (s) => {
|
|
3273
|
-
|
|
3273
|
+
Rn(
|
|
3274
3274
|
s,
|
|
3275
3275
|
this,
|
|
3276
3276
|
t,
|
|
@@ -3298,7 +3298,7 @@ class ut extends A {
|
|
|
3298
3298
|
* @return {boolean}
|
|
3299
3299
|
*/
|
|
3300
3300
|
has(t) {
|
|
3301
|
-
return
|
|
3301
|
+
return br(this, t);
|
|
3302
3302
|
}
|
|
3303
3303
|
/**
|
|
3304
3304
|
* Removes all elements from this YMap.
|
|
@@ -3314,11 +3314,11 @@ class ut extends A {
|
|
|
3314
3314
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
3315
3315
|
*/
|
|
3316
3316
|
_write(t) {
|
|
3317
|
-
t.writeTypeRef(
|
|
3317
|
+
t.writeTypeRef(al);
|
|
3318
3318
|
}
|
|
3319
3319
|
}
|
|
3320
|
-
const
|
|
3321
|
-
class
|
|
3320
|
+
const Hc = (e) => new ut(), et = (e, t) => e === t || typeof e == "object" && typeof t == "object" && e && t && lo(e, t);
|
|
3321
|
+
class dn {
|
|
3322
3322
|
/**
|
|
3323
3323
|
* @param {Item|null} left
|
|
3324
3324
|
* @param {Item|null} right
|
|
@@ -3334,7 +3334,7 @@ class fn {
|
|
|
3334
3334
|
forward() {
|
|
3335
3335
|
switch (this.right === null && j(), this.right.content.constructor) {
|
|
3336
3336
|
case D:
|
|
3337
|
-
this.right.deleted ||
|
|
3337
|
+
this.right.deleted || $t(
|
|
3338
3338
|
this.currentAttributes,
|
|
3339
3339
|
/** @type {ContentFormat} */
|
|
3340
3340
|
this.right.content
|
|
@@ -3347,11 +3347,11 @@ class fn {
|
|
|
3347
3347
|
this.left = this.right, this.right = this.right.right;
|
|
3348
3348
|
}
|
|
3349
3349
|
}
|
|
3350
|
-
const
|
|
3350
|
+
const us = (e, t, n) => {
|
|
3351
3351
|
for (; t.right !== null && n > 0; ) {
|
|
3352
3352
|
switch (t.right.content.constructor) {
|
|
3353
3353
|
case D:
|
|
3354
|
-
t.right.deleted ||
|
|
3354
|
+
t.right.deleted || $t(
|
|
3355
3355
|
t.currentAttributes,
|
|
3356
3356
|
/** @type {ContentFormat} */
|
|
3357
3357
|
t.right.content
|
|
@@ -3365,15 +3365,15 @@ const ds = (e, t, n) => {
|
|
|
3365
3365
|
}
|
|
3366
3366
|
return t;
|
|
3367
3367
|
}, de = (e, t, n, s) => {
|
|
3368
|
-
const r = /* @__PURE__ */ new Map(), i = s ?
|
|
3368
|
+
const r = /* @__PURE__ */ new Map(), i = s ? $e(t, n) : null;
|
|
3369
3369
|
if (i) {
|
|
3370
|
-
const o = new
|
|
3371
|
-
return
|
|
3370
|
+
const o = new dn(i.p.left, i.p, i.index, r);
|
|
3371
|
+
return us(e, o, n - i.index);
|
|
3372
3372
|
} else {
|
|
3373
|
-
const o = new
|
|
3374
|
-
return
|
|
3373
|
+
const o = new dn(null, t._start, 0, r);
|
|
3374
|
+
return us(e, o, n);
|
|
3375
3375
|
}
|
|
3376
|
-
},
|
|
3376
|
+
}, Sr = (e, t, n, s) => {
|
|
3377
3377
|
for (; n.right !== null && (n.right.deleted === !0 || n.right.content.constructor === D && et(
|
|
3378
3378
|
s.get(
|
|
3379
3379
|
/** @type {ContentFormat} */
|
|
@@ -3391,10 +3391,10 @@ const ds = (e, t, n) => {
|
|
|
3391
3391
|
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));
|
|
3392
3392
|
h.integrate(e, 0), n.right = h, n.forward();
|
|
3393
3393
|
});
|
|
3394
|
-
},
|
|
3394
|
+
}, $t = (e, t) => {
|
|
3395
3395
|
const { key: n, value: s } = t;
|
|
3396
3396
|
s === null ? e.delete(n) : e.set(n, s);
|
|
3397
|
-
},
|
|
3397
|
+
}, _r = (e, t) => {
|
|
3398
3398
|
for (; e.right !== null; ) {
|
|
3399
3399
|
if (!(e.right.deleted || e.right.content.constructor === D && et(
|
|
3400
3400
|
t[
|
|
@@ -3407,7 +3407,7 @@ const ds = (e, t, n) => {
|
|
|
3407
3407
|
break;
|
|
3408
3408
|
e.forward();
|
|
3409
3409
|
}
|
|
3410
|
-
},
|
|
3410
|
+
}, kr = (e, t, n, s) => {
|
|
3411
3411
|
const r = e.doc, i = r.clientID, o = /* @__PURE__ */ new Map();
|
|
3412
3412
|
for (const c in s) {
|
|
3413
3413
|
const l = s[c], a = n.currentAttributes.get(c) ?? null;
|
|
@@ -3423,17 +3423,17 @@ const ds = (e, t, n) => {
|
|
|
3423
3423
|
r[f] === void 0 && (r[f] = null);
|
|
3424
3424
|
});
|
|
3425
3425
|
const i = e.doc, o = i.clientID;
|
|
3426
|
-
|
|
3427
|
-
const c =
|
|
3426
|
+
_r(n, r);
|
|
3427
|
+
const c = kr(e, t, n, r), l = s.constructor === String ? new K(
|
|
3428
3428
|
/** @type {string} */
|
|
3429
3429
|
s
|
|
3430
3430
|
) : s instanceof A ? new Q(s) : new yt(s);
|
|
3431
3431
|
let { left: a, right: h, index: d } = n;
|
|
3432
|
-
t._searchMarker && Wt(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(),
|
|
3433
|
-
},
|
|
3432
|
+
t._searchMarker && Wt(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(), Sr(e, t, n, c);
|
|
3433
|
+
}, ds = (e, t, n, s, r) => {
|
|
3434
3434
|
const i = e.doc, o = i.clientID;
|
|
3435
|
-
|
|
3436
|
-
const c =
|
|
3435
|
+
_r(n, r);
|
|
3436
|
+
const c = kr(e, t, n, r);
|
|
3437
3437
|
t:
|
|
3438
3438
|
for (; n.right !== null && (s > 0 || c.size > 0 && (n.right.deleted || n.right.content.constructor === D)); ) {
|
|
3439
3439
|
if (!n.right.deleted)
|
|
@@ -3469,8 +3469,8 @@ const ds = (e, t, n) => {
|
|
|
3469
3469
|
`;
|
|
3470
3470
|
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();
|
|
3471
3471
|
}
|
|
3472
|
-
|
|
3473
|
-
},
|
|
3472
|
+
Sr(e, t, n, c);
|
|
3473
|
+
}, Dr = (e, t, n, s, r) => {
|
|
3474
3474
|
let i = t;
|
|
3475
3475
|
const o = x();
|
|
3476
3476
|
for (; i && (!i.countable || i.deleted); ) {
|
|
@@ -3493,7 +3493,7 @@ const ds = (e, t, n) => {
|
|
|
3493
3493
|
/** @type {ContentFormat} */
|
|
3494
3494
|
a
|
|
3495
3495
|
), u = s.get(h) ?? null;
|
|
3496
|
-
(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 &&
|
|
3496
|
+
(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 && $t(
|
|
3497
3497
|
r,
|
|
3498
3498
|
/** @type {ContentFormat} */
|
|
3499
3499
|
a
|
|
@@ -3506,7 +3506,7 @@ const ds = (e, t, n) => {
|
|
|
3506
3506
|
t.right;
|
|
3507
3507
|
}
|
|
3508
3508
|
return c;
|
|
3509
|
-
},
|
|
3509
|
+
}, jc = (e, t) => {
|
|
3510
3510
|
for (; t && t.right && (t.right.deleted || !t.right.countable); )
|
|
3511
3511
|
t = t.right;
|
|
3512
3512
|
const n = /* @__PURE__ */ new Set();
|
|
@@ -3520,7 +3520,7 @@ const ds = (e, t, n) => {
|
|
|
3520
3520
|
}
|
|
3521
3521
|
t = t.left;
|
|
3522
3522
|
}
|
|
3523
|
-
},
|
|
3523
|
+
}, zc = (e) => {
|
|
3524
3524
|
let t = 0;
|
|
3525
3525
|
return S(
|
|
3526
3526
|
/** @type {Doc} */
|
|
@@ -3530,30 +3530,30 @@ const ds = (e, t, n) => {
|
|
|
3530
3530
|
/** @type {Item} */
|
|
3531
3531
|
e._start
|
|
3532
3532
|
), r = e._start, i = x();
|
|
3533
|
-
const o =
|
|
3533
|
+
const o = sn(i);
|
|
3534
3534
|
for (; r; ) {
|
|
3535
3535
|
if (r.deleted === !1)
|
|
3536
3536
|
switch (r.content.constructor) {
|
|
3537
3537
|
case D:
|
|
3538
|
-
|
|
3538
|
+
$t(
|
|
3539
3539
|
o,
|
|
3540
3540
|
/** @type {ContentFormat} */
|
|
3541
3541
|
r.content
|
|
3542
3542
|
);
|
|
3543
3543
|
break;
|
|
3544
3544
|
default:
|
|
3545
|
-
t +=
|
|
3545
|
+
t += Dr(n, s, r, i, o), i = sn(o), s = r;
|
|
3546
3546
|
break;
|
|
3547
3547
|
}
|
|
3548
3548
|
r = r.right;
|
|
3549
3549
|
}
|
|
3550
3550
|
}
|
|
3551
3551
|
), t;
|
|
3552
|
-
},
|
|
3552
|
+
}, Kc = (e) => {
|
|
3553
3553
|
const t = /* @__PURE__ */ new Set(), n = e.doc;
|
|
3554
3554
|
for (const [s, r] of e.afterState.entries()) {
|
|
3555
3555
|
const i = e.beforeState.get(s) || 0;
|
|
3556
|
-
r !== i &&
|
|
3556
|
+
r !== i && or(
|
|
3557
3557
|
e,
|
|
3558
3558
|
/** @type {Array<Item|GC>} */
|
|
3559
3559
|
n.store.clients.get(s),
|
|
@@ -3569,7 +3569,7 @@ const ds = (e, t, n) => {
|
|
|
3569
3569
|
);
|
|
3570
3570
|
}
|
|
3571
3571
|
S(n, (s) => {
|
|
3572
|
-
|
|
3572
|
+
Xs(e, e.deleteSet, (r) => {
|
|
3573
3573
|
if (r instanceof U || !/** @type {YText} */
|
|
3574
3574
|
r.parent._hasFormatting || t.has(
|
|
3575
3575
|
/** @type {YText} */
|
|
@@ -3580,13 +3580,13 @@ const ds = (e, t, n) => {
|
|
|
3580
3580
|
/** @type {YText} */
|
|
3581
3581
|
r.parent
|
|
3582
3582
|
);
|
|
3583
|
-
r.content.constructor === D ? t.add(i) :
|
|
3583
|
+
r.content.constructor === D ? t.add(i) : jc(s, r);
|
|
3584
3584
|
});
|
|
3585
3585
|
for (const r of t)
|
|
3586
|
-
|
|
3586
|
+
zc(r);
|
|
3587
3587
|
});
|
|
3588
|
-
},
|
|
3589
|
-
const s = n, r =
|
|
3588
|
+
}, fs = (e, t, n) => {
|
|
3589
|
+
const s = n, r = sn(t.currentAttributes), i = t.right;
|
|
3590
3590
|
for (; n > 0 && t.right !== null; ) {
|
|
3591
3591
|
if (t.right.deleted === !1)
|
|
3592
3592
|
switch (t.right.content.constructor) {
|
|
@@ -3598,7 +3598,7 @@ const ds = (e, t, n) => {
|
|
|
3598
3598
|
}
|
|
3599
3599
|
t.forward();
|
|
3600
3600
|
}
|
|
3601
|
-
i &&
|
|
3601
|
+
i && Dr(e, i, t.right, r, t.currentAttributes);
|
|
3602
3602
|
const o = (
|
|
3603
3603
|
/** @type {AbstractType<any>} */
|
|
3604
3604
|
/** @type {Item} */
|
|
@@ -3606,7 +3606,7 @@ const ds = (e, t, n) => {
|
|
|
3606
3606
|
);
|
|
3607
3607
|
return o._searchMarker && Wt(o._searchMarker, t.index, -s + n), t;
|
|
3608
3608
|
};
|
|
3609
|
-
class
|
|
3609
|
+
class Yc extends Re {
|
|
3610
3610
|
/**
|
|
3611
3611
|
* @param {YText} ytext
|
|
3612
3612
|
* @param {Transaction} transaction
|
|
@@ -3667,7 +3667,7 @@ class Jc extends Re {
|
|
|
3667
3667
|
}))), a = "";
|
|
3668
3668
|
break;
|
|
3669
3669
|
case "retain":
|
|
3670
|
-
h > 0 && (f = { retain: h },
|
|
3670
|
+
h > 0 && (f = { retain: h }, oo(l) || (f.attributes = so({}, l))), h = 0;
|
|
3671
3671
|
break;
|
|
3672
3672
|
}
|
|
3673
3673
|
f && n.push(f), c = null;
|
|
@@ -3702,7 +3702,7 @@ class Jc extends Re {
|
|
|
3702
3702
|
const p = l[f];
|
|
3703
3703
|
p !== void 0 && (et(p, g) ? p !== null && o.delete(s) : (c === "retain" && u(), g === null ? delete l[f] : l[f] = g));
|
|
3704
3704
|
}
|
|
3705
|
-
o.deleted || (c === "insert" && u(),
|
|
3705
|
+
o.deleted || (c === "insert" && u(), $t(
|
|
3706
3706
|
r,
|
|
3707
3707
|
/** @type {ContentFormat} */
|
|
3708
3708
|
o.content
|
|
@@ -3777,8 +3777,8 @@ class Mt extends A {
|
|
|
3777
3777
|
*/
|
|
3778
3778
|
_callObserver(t, n) {
|
|
3779
3779
|
super._callObserver(t, n);
|
|
3780
|
-
const s = new
|
|
3781
|
-
|
|
3780
|
+
const s = new Yc(this, t, n);
|
|
3781
|
+
Ne(this, t, s), !t.local && this._hasFormatting && (t._needFormattingCleanup = !0);
|
|
3782
3782
|
}
|
|
3783
3783
|
/**
|
|
3784
3784
|
* Returns the unformatted string representation of this YText type.
|
|
@@ -3813,7 +3813,7 @@ class Mt extends A {
|
|
|
3813
3813
|
*/
|
|
3814
3814
|
applyDelta(t, { sanitize: n = !0 } = {}) {
|
|
3815
3815
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3816
|
-
const r = new
|
|
3816
|
+
const r = new dn(null, this._start, 0, /* @__PURE__ */ new Map());
|
|
3817
3817
|
for (let i = 0; i < t.length; i++) {
|
|
3818
3818
|
const o = t[i];
|
|
3819
3819
|
if (o.insert !== void 0) {
|
|
@@ -3821,7 +3821,7 @@ class Mt extends A {
|
|
|
3821
3821
|
` ? o.insert.slice(0, -1) : o.insert;
|
|
3822
3822
|
(typeof c != "string" || c.length > 0) && We(s, this, r, c, o.attributes || {});
|
|
3823
3823
|
} else
|
|
3824
|
-
o.retain !== void 0 ?
|
|
3824
|
+
o.retain !== void 0 ? ds(s, this, r, o.retain, o.attributes || {}) : o.delete !== void 0 && fs(s, r, o.delete);
|
|
3825
3825
|
}
|
|
3826
3826
|
}) : this._pending.push(() => this.applyDelta(t));
|
|
3827
3827
|
}
|
|
@@ -3881,7 +3881,7 @@ class Mt extends A {
|
|
|
3881
3881
|
break;
|
|
3882
3882
|
}
|
|
3883
3883
|
case D:
|
|
3884
|
-
_t(l, t) && (a(),
|
|
3884
|
+
_t(l, t) && (a(), $t(
|
|
3885
3885
|
i,
|
|
3886
3886
|
/** @type {ContentFormat} */
|
|
3887
3887
|
l.content
|
|
@@ -3893,7 +3893,7 @@ class Mt extends A {
|
|
|
3893
3893
|
a();
|
|
3894
3894
|
};
|
|
3895
3895
|
return t || n ? S(o, (d) => {
|
|
3896
|
-
t &&
|
|
3896
|
+
t && hn(d, t), n && hn(d, n), h();
|
|
3897
3897
|
}, "cleanup") : h(), r;
|
|
3898
3898
|
}
|
|
3899
3899
|
/**
|
|
@@ -3947,7 +3947,7 @@ class Mt extends A {
|
|
|
3947
3947
|
return;
|
|
3948
3948
|
const s = this.doc;
|
|
3949
3949
|
s !== null ? S(s, (r) => {
|
|
3950
|
-
|
|
3950
|
+
fs(r, de(r, this, t, !0), n);
|
|
3951
3951
|
}) : this._pending.push(() => this.delete(t, n));
|
|
3952
3952
|
}
|
|
3953
3953
|
/**
|
|
@@ -3966,7 +3966,7 @@ class Mt extends A {
|
|
|
3966
3966
|
const r = this.doc;
|
|
3967
3967
|
r !== null ? S(r, (i) => {
|
|
3968
3968
|
const o = de(i, this, t, !1);
|
|
3969
|
-
o.right !== null &&
|
|
3969
|
+
o.right !== null && ds(i, this, o, n, s);
|
|
3970
3970
|
}) : this._pending.push(() => this.format(t, n, s));
|
|
3971
3971
|
}
|
|
3972
3972
|
/**
|
|
@@ -3995,7 +3995,7 @@ class Mt extends A {
|
|
|
3995
3995
|
*/
|
|
3996
3996
|
setAttribute(t, n) {
|
|
3997
3997
|
this.doc !== null ? S(this.doc, (s) => {
|
|
3998
|
-
|
|
3998
|
+
Rn(s, this, t, n);
|
|
3999
3999
|
}) : this._pending.push(() => this.setAttribute(t, n));
|
|
4000
4000
|
}
|
|
4001
4001
|
/**
|
|
@@ -4025,16 +4025,16 @@ class Mt extends A {
|
|
|
4025
4025
|
* @public
|
|
4026
4026
|
*/
|
|
4027
4027
|
getAttributes() {
|
|
4028
|
-
return
|
|
4028
|
+
return yr(this);
|
|
4029
4029
|
}
|
|
4030
4030
|
/**
|
|
4031
4031
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4032
4032
|
*/
|
|
4033
4033
|
_write(t) {
|
|
4034
|
-
t.writeTypeRef(
|
|
4034
|
+
t.writeTypeRef(hl);
|
|
4035
4035
|
}
|
|
4036
4036
|
}
|
|
4037
|
-
const
|
|
4037
|
+
const Xc = (e) => new Mt();
|
|
4038
4038
|
class Pe {
|
|
4039
4039
|
/**
|
|
4040
4040
|
* @param {YXmlFragment | YXmlElement} root
|
|
@@ -4186,7 +4186,7 @@ class dt extends A {
|
|
|
4186
4186
|
* @param {Set<null|string>} parentSubs Keys changed on this type. `null` if list was modified.
|
|
4187
4187
|
*/
|
|
4188
4188
|
_callObserver(t, n) {
|
|
4189
|
-
|
|
4189
|
+
Ne(this, t, new Pc(this, n, t));
|
|
4190
4190
|
}
|
|
4191
4191
|
/**
|
|
4192
4192
|
* Get the string representation of all the children of this YXmlFragment.
|
|
@@ -4194,7 +4194,7 @@ class dt extends A {
|
|
|
4194
4194
|
* @return {string} The string representation of all children.
|
|
4195
4195
|
*/
|
|
4196
4196
|
toString() {
|
|
4197
|
-
return
|
|
4197
|
+
return fr(this, (t) => t.toString()).join("");
|
|
4198
4198
|
}
|
|
4199
4199
|
/**
|
|
4200
4200
|
* @return {string}
|
|
@@ -4235,7 +4235,7 @@ class dt extends A {
|
|
|
4235
4235
|
*/
|
|
4236
4236
|
insert(t, n) {
|
|
4237
4237
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4238
|
-
|
|
4238
|
+
wr(s, this, t, n);
|
|
4239
4239
|
}) : this._prelimContent.splice(t, 0, ...n);
|
|
4240
4240
|
}
|
|
4241
4241
|
/**
|
|
@@ -4272,7 +4272,7 @@ class dt extends A {
|
|
|
4272
4272
|
*/
|
|
4273
4273
|
delete(t, n = 1) {
|
|
4274
4274
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4275
|
-
|
|
4275
|
+
mr(s, this, t, n);
|
|
4276
4276
|
}) : this._prelimContent.splice(t, n);
|
|
4277
4277
|
}
|
|
4278
4278
|
/**
|
|
@@ -4281,7 +4281,7 @@ class dt extends A {
|
|
|
4281
4281
|
* @return {Array<YXmlElement|YXmlText|YXmlHook>}
|
|
4282
4282
|
*/
|
|
4283
4283
|
toArray() {
|
|
4284
|
-
return
|
|
4284
|
+
return dr(this);
|
|
4285
4285
|
}
|
|
4286
4286
|
/**
|
|
4287
4287
|
* Appends content to this YArray.
|
|
@@ -4306,7 +4306,7 @@ class dt extends A {
|
|
|
4306
4306
|
* @return {YXmlElement|YXmlText}
|
|
4307
4307
|
*/
|
|
4308
4308
|
get(t) {
|
|
4309
|
-
return
|
|
4309
|
+
return gr(this, t);
|
|
4310
4310
|
}
|
|
4311
4311
|
/**
|
|
4312
4312
|
* Returns a portion of this YXmlFragment into a JavaScript Array selected
|
|
@@ -4317,7 +4317,7 @@ class dt extends A {
|
|
|
4317
4317
|
* @return {Array<YXmlElement|YXmlText>}
|
|
4318
4318
|
*/
|
|
4319
4319
|
slice(t = 0, n = this.length) {
|
|
4320
|
-
return
|
|
4320
|
+
return ur(this, t, n);
|
|
4321
4321
|
}
|
|
4322
4322
|
/**
|
|
4323
4323
|
* Executes a provided function on once on every child element.
|
|
@@ -4336,10 +4336,10 @@ class dt extends A {
|
|
|
4336
4336
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4337
4337
|
*/
|
|
4338
4338
|
_write(t) {
|
|
4339
|
-
t.writeTypeRef(
|
|
4339
|
+
t.writeTypeRef(dl);
|
|
4340
4340
|
}
|
|
4341
4341
|
}
|
|
4342
|
-
const
|
|
4342
|
+
const Jc = (e) => new dt();
|
|
4343
4343
|
class Ut extends dt {
|
|
4344
4344
|
constructor(t = "UNDEFINED") {
|
|
4345
4345
|
super(), this.nodeName = t, this._prelimAttrs = /* @__PURE__ */ new Map();
|
|
@@ -4399,7 +4399,7 @@ class Ut extends dt {
|
|
|
4399
4399
|
*/
|
|
4400
4400
|
clone() {
|
|
4401
4401
|
const t = new Ut(this.nodeName), n = this.getAttributes();
|
|
4402
|
-
return
|
|
4402
|
+
return io(n, (s, r) => {
|
|
4403
4403
|
typeof s == "string" && t.setAttribute(r, s);
|
|
4404
4404
|
}), t.insert(0, this.toArray().map((s) => s instanceof A ? s.clone() : s)), t;
|
|
4405
4405
|
}
|
|
@@ -4449,7 +4449,7 @@ class Ut extends dt {
|
|
|
4449
4449
|
*/
|
|
4450
4450
|
setAttribute(t, n) {
|
|
4451
4451
|
this.doc !== null ? S(this.doc, (s) => {
|
|
4452
|
-
|
|
4452
|
+
Rn(s, this, t, n);
|
|
4453
4453
|
}) : this._prelimAttrs.set(t, n);
|
|
4454
4454
|
}
|
|
4455
4455
|
/**
|
|
@@ -4480,7 +4480,7 @@ class Ut extends dt {
|
|
|
4480
4480
|
hasAttribute(t) {
|
|
4481
4481
|
return (
|
|
4482
4482
|
/** @type {any} */
|
|
4483
|
-
|
|
4483
|
+
br(this, t)
|
|
4484
4484
|
);
|
|
4485
4485
|
}
|
|
4486
4486
|
/**
|
|
@@ -4494,7 +4494,7 @@ class Ut extends dt {
|
|
|
4494
4494
|
getAttributes(t) {
|
|
4495
4495
|
return (
|
|
4496
4496
|
/** @type {any} */
|
|
4497
|
-
t ?
|
|
4497
|
+
t ? Nc(this, t) : yr(this)
|
|
4498
4498
|
);
|
|
4499
4499
|
}
|
|
4500
4500
|
/**
|
|
@@ -4531,11 +4531,11 @@ class Ut extends dt {
|
|
|
4531
4531
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4532
4532
|
*/
|
|
4533
4533
|
_write(t) {
|
|
4534
|
-
t.writeTypeRef(
|
|
4534
|
+
t.writeTypeRef(ul), t.writeKey(this.nodeName);
|
|
4535
4535
|
}
|
|
4536
4536
|
}
|
|
4537
|
-
const
|
|
4538
|
-
class
|
|
4537
|
+
const Wc = (e) => new Ut(e.readKey());
|
|
4538
|
+
class Pc extends Re {
|
|
4539
4539
|
/**
|
|
4540
4540
|
* @param {YXmlElement|YXmlText|YXmlFragment} target The target on which the event is created.
|
|
4541
4541
|
* @param {Set<string|null>} subs The set of changed attributes. `null` is included if the
|
|
@@ -4604,10 +4604,10 @@ class Ae extends ut {
|
|
|
4604
4604
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder The encoder to write data to.
|
|
4605
4605
|
*/
|
|
4606
4606
|
_write(t) {
|
|
4607
|
-
t.writeTypeRef(
|
|
4607
|
+
t.writeTypeRef(fl), t.writeKey(this.hookName);
|
|
4608
4608
|
}
|
|
4609
4609
|
}
|
|
4610
|
-
const
|
|
4610
|
+
const Gc = (e) => new Ae(e.readKey());
|
|
4611
4611
|
class Le extends Mt {
|
|
4612
4612
|
/**
|
|
4613
4613
|
* @type {YXmlElement|YXmlText|null}
|
|
@@ -4700,11 +4700,11 @@ class Le extends Mt {
|
|
|
4700
4700
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4701
4701
|
*/
|
|
4702
4702
|
_write(t) {
|
|
4703
|
-
t.writeTypeRef(
|
|
4703
|
+
t.writeTypeRef(gl);
|
|
4704
4704
|
}
|
|
4705
4705
|
}
|
|
4706
|
-
const
|
|
4707
|
-
class
|
|
4706
|
+
const qc = (e) => new Le();
|
|
4707
|
+
class Nn {
|
|
4708
4708
|
/**
|
|
4709
4709
|
* @param {ID} id
|
|
4710
4710
|
* @param {number} length
|
|
@@ -4744,8 +4744,8 @@ class Bn {
|
|
|
4744
4744
|
throw H();
|
|
4745
4745
|
}
|
|
4746
4746
|
}
|
|
4747
|
-
const
|
|
4748
|
-
class U extends
|
|
4747
|
+
const Zc = 0;
|
|
4748
|
+
class U extends Nn {
|
|
4749
4749
|
get deleted() {
|
|
4750
4750
|
return !0;
|
|
4751
4751
|
}
|
|
@@ -4763,14 +4763,14 @@ class U extends Bn {
|
|
|
4763
4763
|
* @param {number} offset
|
|
4764
4764
|
*/
|
|
4765
4765
|
integrate(t, n) {
|
|
4766
|
-
n > 0 && (this.id.clock += n, this.length -= n),
|
|
4766
|
+
n > 0 && (this.id.clock += n, this.length -= n), ir(t.doc.store, this);
|
|
4767
4767
|
}
|
|
4768
4768
|
/**
|
|
4769
4769
|
* @param {UpdateEncoderV1 | UpdateEncoderV2} encoder
|
|
4770
4770
|
* @param {number} offset
|
|
4771
4771
|
*/
|
|
4772
4772
|
write(t, n) {
|
|
4773
|
-
t.writeInfo(
|
|
4773
|
+
t.writeInfo(Zc), t.writeLen(this.length - n);
|
|
4774
4774
|
}
|
|
4775
4775
|
/**
|
|
4776
4776
|
* @param {Transaction} transaction
|
|
@@ -4856,7 +4856,7 @@ class re {
|
|
|
4856
4856
|
return 3;
|
|
4857
4857
|
}
|
|
4858
4858
|
}
|
|
4859
|
-
const
|
|
4859
|
+
const Qc = (e) => new re(e.readBuf());
|
|
4860
4860
|
class Gt {
|
|
4861
4861
|
/**
|
|
4862
4862
|
* @param {number} len
|
|
@@ -4934,7 +4934,7 @@ class Gt {
|
|
|
4934
4934
|
return 1;
|
|
4935
4935
|
}
|
|
4936
4936
|
}
|
|
4937
|
-
const
|
|
4937
|
+
const tl = (e) => new Gt(e.readLen()), Er = (e, t) => new mt({ guid: e, ...t, shouldLoad: t.shouldLoad || t.autoLoad || !1 });
|
|
4938
4938
|
class ie {
|
|
4939
4939
|
/**
|
|
4940
4940
|
* @param {Doc} doc
|
|
@@ -4966,7 +4966,7 @@ class ie {
|
|
|
4966
4966
|
* @return {ContentDoc}
|
|
4967
4967
|
*/
|
|
4968
4968
|
copy() {
|
|
4969
|
-
return new ie(
|
|
4969
|
+
return new ie(Er(this.doc.guid, this.opts));
|
|
4970
4970
|
}
|
|
4971
4971
|
/**
|
|
4972
4972
|
* @param {number} offset
|
|
@@ -5014,7 +5014,7 @@ class ie {
|
|
|
5014
5014
|
return 9;
|
|
5015
5015
|
}
|
|
5016
5016
|
}
|
|
5017
|
-
const
|
|
5017
|
+
const el = (e) => new ie(Er(e.readString(), e.readAny()));
|
|
5018
5018
|
class yt {
|
|
5019
5019
|
/**
|
|
5020
5020
|
* @param {Object} embed
|
|
@@ -5090,7 +5090,7 @@ class yt {
|
|
|
5090
5090
|
return 5;
|
|
5091
5091
|
}
|
|
5092
5092
|
}
|
|
5093
|
-
const
|
|
5093
|
+
const nl = (e) => new yt(e.readJSON());
|
|
5094
5094
|
class D {
|
|
5095
5095
|
/**
|
|
5096
5096
|
* @param {string} key
|
|
@@ -5172,8 +5172,8 @@ class D {
|
|
|
5172
5172
|
return 6;
|
|
5173
5173
|
}
|
|
5174
5174
|
}
|
|
5175
|
-
const
|
|
5176
|
-
class
|
|
5175
|
+
const sl = (e) => new D(e.readKey(), e.readJSON());
|
|
5176
|
+
class Ie {
|
|
5177
5177
|
/**
|
|
5178
5178
|
* @param {Array<any>} arr
|
|
5179
5179
|
*/
|
|
@@ -5202,14 +5202,14 @@ class ve {
|
|
|
5202
5202
|
* @return {ContentJSON}
|
|
5203
5203
|
*/
|
|
5204
5204
|
copy() {
|
|
5205
|
-
return new
|
|
5205
|
+
return new Ie(this.arr);
|
|
5206
5206
|
}
|
|
5207
5207
|
/**
|
|
5208
5208
|
* @param {number} offset
|
|
5209
5209
|
* @return {ContentJSON}
|
|
5210
5210
|
*/
|
|
5211
5211
|
splice(t) {
|
|
5212
|
-
const n = new
|
|
5212
|
+
const n = new Ie(this.arr.slice(t));
|
|
5213
5213
|
return this.arr = this.arr.slice(0, t), n;
|
|
5214
5214
|
}
|
|
5215
5215
|
/**
|
|
@@ -5254,13 +5254,13 @@ class ve {
|
|
|
5254
5254
|
return 2;
|
|
5255
5255
|
}
|
|
5256
5256
|
}
|
|
5257
|
-
const
|
|
5257
|
+
const rl = (e) => {
|
|
5258
5258
|
const t = e.readLen(), n = [];
|
|
5259
5259
|
for (let s = 0; s < t; s++) {
|
|
5260
5260
|
const r = e.readString();
|
|
5261
5261
|
r === "undefined" ? n.push(void 0) : n.push(JSON.parse(r));
|
|
5262
5262
|
}
|
|
5263
|
-
return new
|
|
5263
|
+
return new Ie(n);
|
|
5264
5264
|
};
|
|
5265
5265
|
class ft {
|
|
5266
5266
|
/**
|
|
@@ -5343,7 +5343,7 @@ class ft {
|
|
|
5343
5343
|
return 8;
|
|
5344
5344
|
}
|
|
5345
5345
|
}
|
|
5346
|
-
const
|
|
5346
|
+
const il = (e) => {
|
|
5347
5347
|
const t = e.readLen(), n = [];
|
|
5348
5348
|
for (let s = 0; s < t; s++)
|
|
5349
5349
|
n.push(e.readAny());
|
|
@@ -5427,15 +5427,15 @@ class K {
|
|
|
5427
5427
|
return 4;
|
|
5428
5428
|
}
|
|
5429
5429
|
}
|
|
5430
|
-
const
|
|
5430
|
+
const ol = (e) => new K(e.readString()), cl = [
|
|
5431
|
+
Vc,
|
|
5431
5432
|
Hc,
|
|
5432
|
-
|
|
5433
|
+
Xc,
|
|
5433
5434
|
Wc,
|
|
5435
|
+
Jc,
|
|
5434
5436
|
Gc,
|
|
5435
|
-
|
|
5436
|
-
|
|
5437
|
-
Qc
|
|
5438
|
-
], hl = 0, ul = 1, dl = 2, fl = 3, gl = 4, pl = 5, wl = 6;
|
|
5437
|
+
qc
|
|
5438
|
+
], ll = 0, al = 1, hl = 2, ul = 3, dl = 4, fl = 5, gl = 6;
|
|
5439
5439
|
class Q {
|
|
5440
5440
|
/**
|
|
5441
5441
|
* @param {AbstractType<any>} type
|
|
@@ -5528,7 +5528,7 @@ class Q {
|
|
|
5528
5528
|
return 7;
|
|
5529
5529
|
}
|
|
5530
5530
|
}
|
|
5531
|
-
const
|
|
5531
|
+
const pl = (e) => new Q(cl[e.readTypeRef()](e)), ve = (e, t, n) => {
|
|
5532
5532
|
const { client: s, clock: r } = t.id, i = new k(
|
|
5533
5533
|
b(s, r + n),
|
|
5534
5534
|
t,
|
|
@@ -5541,7 +5541,7 @@ const ml = (e) => new Q(al[e.readTypeRef()](e)), Ie = (e, t, n) => {
|
|
|
5541
5541
|
);
|
|
5542
5542
|
return t.deleted && i.markDeleted(), t.keep && (i.keep = !0), t.redone !== null && (i.redone = b(t.redone.client, t.redone.clock + n)), t.right = i, i.right !== null && (i.right.left = i), e._mergeStructs.push(i), i.parentSub !== null && i.right === null && i.parent._map.set(i.parentSub, i), t.length = n, i;
|
|
5543
5543
|
};
|
|
5544
|
-
class k extends
|
|
5544
|
+
class k extends Nn {
|
|
5545
5545
|
/**
|
|
5546
5546
|
* @param {ID} id
|
|
5547
5547
|
* @param {Item | null} left
|
|
@@ -5553,7 +5553,7 @@ class k extends Bn {
|
|
|
5553
5553
|
* @param {AbstractContent} content
|
|
5554
5554
|
*/
|
|
5555
5555
|
constructor(t, n, s, r, i, o, c, l) {
|
|
5556
|
-
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() ?
|
|
5556
|
+
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() ? qn : 0;
|
|
5557
5557
|
}
|
|
5558
5558
|
/**
|
|
5559
5559
|
* This is used to mark the item as an indexed fast-search marker
|
|
@@ -5570,13 +5570,13 @@ class k extends Bn {
|
|
|
5570
5570
|
* If true, do not garbage collect this Item.
|
|
5571
5571
|
*/
|
|
5572
5572
|
get keep() {
|
|
5573
|
-
return (this.info &
|
|
5573
|
+
return (this.info & Gn) > 0;
|
|
5574
5574
|
}
|
|
5575
5575
|
set keep(t) {
|
|
5576
|
-
this.keep !== t && (this.info ^=
|
|
5576
|
+
this.keep !== t && (this.info ^= Gn);
|
|
5577
5577
|
}
|
|
5578
5578
|
get countable() {
|
|
5579
|
-
return (this.info &
|
|
5579
|
+
return (this.info & qn) > 0;
|
|
5580
5580
|
}
|
|
5581
5581
|
/**
|
|
5582
5582
|
* Whether this item was deleted or not.
|
|
@@ -5605,7 +5605,7 @@ class k extends Bn {
|
|
|
5605
5605
|
return this.rightOrigin.client;
|
|
5606
5606
|
if (this.parent && this.parent.constructor === Et && this.id.client !== this.parent.client && this.parent.clock >= C(n, this.parent.client))
|
|
5607
5607
|
return this.parent.client;
|
|
5608
|
-
if (this.origin && (this.left =
|
|
5608
|
+
if (this.origin && (this.left = cs(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 === U || this.right && this.right.constructor === U)
|
|
5609
5609
|
this.parent = null;
|
|
5610
5610
|
else if (!this.parent)
|
|
5611
5611
|
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);
|
|
@@ -5621,7 +5621,7 @@ class k extends Bn {
|
|
|
5621
5621
|
* @param {number} offset
|
|
5622
5622
|
*/
|
|
5623
5623
|
integrate(t, n) {
|
|
5624
|
-
if (n > 0 && (this.id.clock += n, this.left =
|
|
5624
|
+
if (n > 0 && (this.id.clock += n, this.left = cs(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) {
|
|
5625
5625
|
if (!this.left && (!this.right || this.right.left !== null) || this.left && this.left.right !== this.right) {
|
|
5626
5626
|
let s = this.left, r;
|
|
5627
5627
|
if (s !== null)
|
|
@@ -5662,7 +5662,7 @@ class k extends Bn {
|
|
|
5662
5662
|
this.parent._start, this.parent._start = this;
|
|
5663
5663
|
this.right = s;
|
|
5664
5664
|
}
|
|
5665
|
-
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),
|
|
5665
|
+
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), ir(t.doc.store, this), this.content.integrate(t, this), as(
|
|
5666
5666
|
t,
|
|
5667
5667
|
/** @type {AbstractType<any>} */
|
|
5668
5668
|
this.parent,
|
|
@@ -5726,7 +5726,7 @@ class k extends Bn {
|
|
|
5726
5726
|
/** @type {AbstractType<any>} */
|
|
5727
5727
|
this.parent
|
|
5728
5728
|
);
|
|
5729
|
-
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), ke(t.deleteSet, this.id.client, this.id.clock, this.length),
|
|
5729
|
+
this.countable && this.parentSub === null && (n._length -= this.length), this.markDeleted(), ke(t.deleteSet, this.id.client, this.id.clock, this.length), as(t, n, this.parentSub), this.content.delete(t);
|
|
5730
5730
|
}
|
|
5731
5731
|
}
|
|
5732
5732
|
/**
|
|
@@ -5736,7 +5736,7 @@ class k extends Bn {
|
|
|
5736
5736
|
gc(t, n) {
|
|
5737
5737
|
if (!this.deleted)
|
|
5738
5738
|
throw j();
|
|
5739
|
-
this.content.gc(t), n ?
|
|
5739
|
+
this.content.gc(t), n ? _c(t, this, new U(this.id, this.length)) : this.content = new Gt(this.length);
|
|
5740
5740
|
}
|
|
5741
5741
|
/**
|
|
5742
5742
|
* Transform the properties of this type to binary and write it to an
|
|
@@ -5759,7 +5759,7 @@ class k extends Bn {
|
|
|
5759
5759
|
if (c._item !== void 0) {
|
|
5760
5760
|
const l = c._item;
|
|
5761
5761
|
if (l === null) {
|
|
5762
|
-
const a =
|
|
5762
|
+
const a = bc(c);
|
|
5763
5763
|
t.writeParentInfo(!0), t.writeString(a);
|
|
5764
5764
|
} else
|
|
5765
5765
|
t.writeParentInfo(!1), t.writeLeftID(l.id);
|
|
@@ -5770,35 +5770,35 @@ class k extends Bn {
|
|
|
5770
5770
|
this.content.write(t, n);
|
|
5771
5771
|
}
|
|
5772
5772
|
}
|
|
5773
|
-
const
|
|
5773
|
+
const Cr = (e, t) => wl[t & Te](e), wl = [
|
|
5774
5774
|
() => {
|
|
5775
5775
|
j();
|
|
5776
5776
|
},
|
|
5777
5777
|
// GC is not ItemContent
|
|
5778
|
-
|
|
5778
|
+
tl,
|
|
5779
5779
|
// 1
|
|
5780
|
-
|
|
5780
|
+
rl,
|
|
5781
5781
|
// 2
|
|
5782
|
-
|
|
5782
|
+
Qc,
|
|
5783
5783
|
// 3
|
|
5784
|
-
|
|
5784
|
+
ol,
|
|
5785
5785
|
// 4
|
|
5786
|
-
|
|
5786
|
+
nl,
|
|
5787
5787
|
// 5
|
|
5788
|
-
|
|
5788
|
+
sl,
|
|
5789
5789
|
// 6
|
|
5790
|
-
|
|
5790
|
+
pl,
|
|
5791
5791
|
// 7
|
|
5792
|
-
|
|
5792
|
+
il,
|
|
5793
5793
|
// 8
|
|
5794
|
-
|
|
5794
|
+
el,
|
|
5795
5795
|
// 9
|
|
5796
5796
|
() => {
|
|
5797
5797
|
j();
|
|
5798
5798
|
}
|
|
5799
5799
|
// 10 - Skip is not ItemContent
|
|
5800
|
-
],
|
|
5801
|
-
class O extends
|
|
5800
|
+
], ml = 10;
|
|
5801
|
+
class O extends Nn {
|
|
5802
5802
|
get deleted() {
|
|
5803
5803
|
return !0;
|
|
5804
5804
|
}
|
|
@@ -5823,7 +5823,7 @@ class O extends Bn {
|
|
|
5823
5823
|
* @param {number} offset
|
|
5824
5824
|
*/
|
|
5825
5825
|
write(t, n) {
|
|
5826
|
-
t.writeInfo(
|
|
5826
|
+
t.writeInfo(ml), m(t.restEncoder, this.length - n);
|
|
5827
5827
|
}
|
|
5828
5828
|
/**
|
|
5829
5829
|
* @param {Transaction} transaction
|
|
@@ -5834,19 +5834,19 @@ class O extends Bn {
|
|
|
5834
5834
|
return null;
|
|
5835
5835
|
}
|
|
5836
5836
|
}
|
|
5837
|
-
const
|
|
5837
|
+
const Ar = (
|
|
5838
5838
|
/** @type {any} */
|
|
5839
5839
|
typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : {}
|
|
5840
|
-
),
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
const
|
|
5840
|
+
), Lr = "__ $YJS$ __";
|
|
5841
|
+
Ar[Lr] === !0 && console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");
|
|
5842
|
+
Ar[Lr] = !0;
|
|
5843
|
+
const yl = 0, bl = (e, t, n) => {
|
|
5844
5844
|
switch (w(e)) {
|
|
5845
|
-
case
|
|
5845
|
+
case yl:
|
|
5846
5846
|
n(t, nt(e));
|
|
5847
5847
|
}
|
|
5848
5848
|
}, Ge = 3e4;
|
|
5849
|
-
class
|
|
5849
|
+
class Sl extends Ms {
|
|
5850
5850
|
/**
|
|
5851
5851
|
* @param {Y.Doc} doc
|
|
5852
5852
|
*/
|
|
@@ -5859,7 +5859,7 @@ class kl extends Os {
|
|
|
5859
5859
|
const s = [];
|
|
5860
5860
|
this.meta.forEach((r, i) => {
|
|
5861
5861
|
i !== this.clientID && Ge <= n - r.lastUpdated && this.states.has(i) && s.push(i);
|
|
5862
|
-
}), s.length > 0 &&
|
|
5862
|
+
}), s.length > 0 && Bn(this, s, "timeout");
|
|
5863
5863
|
}, P(Ge / 10)), t.on("destroy", () => {
|
|
5864
5864
|
this.destroy();
|
|
5865
5865
|
}), this.setLocalState({});
|
|
@@ -5903,7 +5903,7 @@ class kl extends Os {
|
|
|
5903
5903
|
return this.states;
|
|
5904
5904
|
}
|
|
5905
5905
|
}
|
|
5906
|
-
const
|
|
5906
|
+
const Bn = (e, t, n) => {
|
|
5907
5907
|
const s = [];
|
|
5908
5908
|
for (let r = 0; r < t.length; r++) {
|
|
5909
5909
|
const i = t[r];
|
|
@@ -5933,7 +5933,7 @@ const Vn = (e, t, n) => {
|
|
|
5933
5933
|
m(r, o), m(r, l), lt(r, JSON.stringify(c));
|
|
5934
5934
|
}
|
|
5935
5935
|
return B(r);
|
|
5936
|
-
},
|
|
5936
|
+
}, _l = (e, t, n) => {
|
|
5937
5937
|
const s = wt(t), r = _e(), i = [], o = [], c = [], l = [], a = w(s);
|
|
5938
5938
|
for (let h = 0; h < a; h++) {
|
|
5939
5939
|
const d = w(s);
|
|
@@ -5953,55 +5953,55 @@ const Vn = (e, t, n) => {
|
|
|
5953
5953
|
updated: o,
|
|
5954
5954
|
removed: l
|
|
5955
5955
|
}, n]);
|
|
5956
|
-
},
|
|
5957
|
-
m(e,
|
|
5958
|
-
const n =
|
|
5956
|
+
}, Ir = 0, Vn = 1, vr = 2, fn = (e, t) => {
|
|
5957
|
+
m(e, Ir);
|
|
5958
|
+
const n = mc(t);
|
|
5959
5959
|
L(e, n);
|
|
5960
|
-
},
|
|
5961
|
-
m(e,
|
|
5962
|
-
},
|
|
5960
|
+
}, xr = (e, t, n) => {
|
|
5961
|
+
m(e, Vn), L(e, xn(t, n));
|
|
5962
|
+
}, kl = (e, t, n) => xr(t, n, I(e)), Tr = (e, t, n) => {
|
|
5963
5963
|
try {
|
|
5964
|
-
|
|
5964
|
+
tr(t, I(e), n);
|
|
5965
5965
|
} catch (s) {
|
|
5966
5966
|
console.error("Caught error while handling a Yjs update", s);
|
|
5967
5967
|
}
|
|
5968
|
-
},
|
|
5969
|
-
m(e,
|
|
5970
|
-
},
|
|
5968
|
+
}, Dl = (e, t) => {
|
|
5969
|
+
m(e, vr), L(e, t);
|
|
5970
|
+
}, El = Tr, Cl = (e, t, n, s) => {
|
|
5971
5971
|
const r = w(e);
|
|
5972
5972
|
switch (r) {
|
|
5973
|
-
case
|
|
5974
|
-
|
|
5973
|
+
case Ir:
|
|
5974
|
+
kl(e, t, n);
|
|
5975
5975
|
break;
|
|
5976
|
-
case
|
|
5977
|
-
|
|
5976
|
+
case Vn:
|
|
5977
|
+
Tr(e, n, s);
|
|
5978
5978
|
break;
|
|
5979
|
-
case
|
|
5980
|
-
|
|
5979
|
+
case vr:
|
|
5980
|
+
El(e, n, s);
|
|
5981
5981
|
break;
|
|
5982
5982
|
default:
|
|
5983
5983
|
throw new Error("Unknown message type");
|
|
5984
5984
|
}
|
|
5985
5985
|
return r;
|
|
5986
5986
|
};
|
|
5987
|
-
var it = 0,
|
|
5988
|
-
function
|
|
5987
|
+
var it = 0, Mr = 3, At = 1, Al = 2, Ll = typeof window > "u";
|
|
5988
|
+
function Il(e, t) {
|
|
5989
5989
|
if (!e)
|
|
5990
5990
|
throw new Error(t);
|
|
5991
5991
|
}
|
|
5992
5992
|
var oe = [];
|
|
5993
5993
|
oe[it] = (e, t, n, s, r) => {
|
|
5994
|
-
|
|
5995
|
-
const i =
|
|
5994
|
+
v(e, it);
|
|
5995
|
+
const i = Cl(
|
|
5996
5996
|
t,
|
|
5997
5997
|
e,
|
|
5998
5998
|
n.doc,
|
|
5999
5999
|
n
|
|
6000
6000
|
);
|
|
6001
|
-
s && i ===
|
|
6001
|
+
s && i === Vn && !n.synced && (n.synced = !0);
|
|
6002
6002
|
};
|
|
6003
|
-
oe[
|
|
6004
|
-
|
|
6003
|
+
oe[Mr] = (e, t, n, s, r) => {
|
|
6004
|
+
v(e, At), Dt(
|
|
6005
6005
|
e,
|
|
6006
6006
|
Ht(
|
|
6007
6007
|
n.awareness,
|
|
@@ -6010,29 +6010,29 @@ oe[Or] = (e, t, n, s, r) => {
|
|
|
6010
6010
|
);
|
|
6011
6011
|
};
|
|
6012
6012
|
oe[At] = (e, t, n, s, r) => {
|
|
6013
|
-
|
|
6013
|
+
_l(
|
|
6014
6014
|
n.awareness,
|
|
6015
|
-
|
|
6015
|
+
Ai(t),
|
|
6016
6016
|
n
|
|
6017
6017
|
);
|
|
6018
6018
|
};
|
|
6019
|
-
oe[
|
|
6020
|
-
|
|
6019
|
+
oe[Al] = (e, t, n, s, r) => {
|
|
6020
|
+
bl(
|
|
6021
6021
|
t,
|
|
6022
6022
|
n.doc,
|
|
6023
|
-
(i, o) =>
|
|
6023
|
+
(i, o) => vl(n, o)
|
|
6024
6024
|
);
|
|
6025
6025
|
};
|
|
6026
|
-
var
|
|
6027
|
-
function
|
|
6026
|
+
var gs = 3e4;
|
|
6027
|
+
function vl(e, t) {
|
|
6028
6028
|
console.warn(`Permission denied to access ${e.url}.
|
|
6029
6029
|
${t}`);
|
|
6030
6030
|
}
|
|
6031
|
-
function
|
|
6032
|
-
const s =
|
|
6031
|
+
function Ur(e, t, n) {
|
|
6032
|
+
const s = Ei(t), r = N(), i = xs(s), o = e.messageHandlers[i];
|
|
6033
6033
|
return /** @type {any} */ o ? o(r, s, e, n, i) : console.error("Unable to compute message"), r;
|
|
6034
6034
|
}
|
|
6035
|
-
function
|
|
6035
|
+
function Or(e) {
|
|
6036
6036
|
if (e.shouldConnect && e.ws === null) {
|
|
6037
6037
|
if (!e._WS)
|
|
6038
6038
|
throw new Error(
|
|
@@ -6042,13 +6042,13 @@ function Nr(e) {
|
|
|
6042
6042
|
t.binaryType = "arraybuffer", e.ws = t, e.wsconnecting = !0, e.wsconnected = !1, e.synced = !1, t.addEventListener("message", (n) => {
|
|
6043
6043
|
if (typeof n.data == "string")
|
|
6044
6044
|
return;
|
|
6045
|
-
e.wsLastMessageReceived =
|
|
6046
|
-
const s =
|
|
6047
|
-
|
|
6045
|
+
e.wsLastMessageReceived = nn();
|
|
6046
|
+
const s = Ur(e, new Uint8Array(n.data), !0);
|
|
6047
|
+
yn(s) > 1 && Bt(M(s), t);
|
|
6048
6048
|
}), t.addEventListener("error", (n) => {
|
|
6049
6049
|
e.emit("connection-error", [n, e]);
|
|
6050
6050
|
}), t.addEventListener("close", (n) => {
|
|
6051
|
-
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1,
|
|
6051
|
+
e.emit("connection-close", [n, e]), e.ws = null, e.wsconnecting = !1, e.wsconnected ? (e.wsconnected = !1, e.synced = !1, Bn(
|
|
6052
6052
|
e.awareness,
|
|
6053
6053
|
Array.from(e.awareness.getStates().keys()).filter(
|
|
6054
6054
|
(s) => s !== e.doc.clientID
|
|
@@ -6059,23 +6059,23 @@ function Nr(e) {
|
|
|
6059
6059
|
status: "disconnected"
|
|
6060
6060
|
}
|
|
6061
6061
|
])) : e.wsUnsuccessfulReconnects++, setTimeout(
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6062
|
+
Or,
|
|
6063
|
+
Ls(
|
|
6064
|
+
gi(2, e.wsUnsuccessfulReconnects) * 100,
|
|
6065
6065
|
e.maxBackoffTime
|
|
6066
6066
|
),
|
|
6067
6067
|
e
|
|
6068
6068
|
);
|
|
6069
6069
|
}), t.addEventListener("open", () => {
|
|
6070
|
-
e.wsLastMessageReceived =
|
|
6070
|
+
e.wsLastMessageReceived = nn(), e.wsconnecting = !1, e.wsconnected = !0, e.wsUnsuccessfulReconnects = 0, e.emit("status", [
|
|
6071
6071
|
{
|
|
6072
6072
|
status: "connected"
|
|
6073
6073
|
}
|
|
6074
6074
|
]);
|
|
6075
|
-
const n =
|
|
6076
|
-
if (
|
|
6077
|
-
const s =
|
|
6078
|
-
|
|
6075
|
+
const n = N();
|
|
6076
|
+
if (v(n, it), fn(n, e.doc), Bt(M(n), t), e.awareness.getLocalState() !== null) {
|
|
6077
|
+
const s = N();
|
|
6078
|
+
v(s, At), Dt(
|
|
6079
6079
|
s,
|
|
6080
6080
|
Ht(e.awareness, [
|
|
6081
6081
|
e.doc.clientID
|
|
@@ -6093,19 +6093,19 @@ function qe(e, t) {
|
|
|
6093
6093
|
const n = e.ws;
|
|
6094
6094
|
e.wsconnected && n && n.readyState === n.OPEN && Bt(t, n), e.bcconnected && St(e.bcChannel, t, e);
|
|
6095
6095
|
}
|
|
6096
|
-
var
|
|
6096
|
+
var xl = typeof WebSocket > "u" ? null : WebSocket, Tl = class extends Fi {
|
|
6097
6097
|
constructor(t, n, s, {
|
|
6098
6098
|
connect: r = !0,
|
|
6099
|
-
awareness: i = new
|
|
6099
|
+
awareness: i = new Sl(s),
|
|
6100
6100
|
params: o = {},
|
|
6101
6101
|
isPrefixedUrl: c = !1,
|
|
6102
|
-
WebSocketPolyfill: l =
|
|
6102
|
+
WebSocketPolyfill: l = xl,
|
|
6103
6103
|
// Optionally provide a WebSocket polyfill
|
|
6104
6104
|
resyncInterval: a = -1,
|
|
6105
6105
|
// Request server state every `resyncInterval` milliseconds
|
|
6106
6106
|
maxBackoffTime: h = 2500,
|
|
6107
6107
|
// Maximum amount of time to wait before trying to reconnect (we try to reconnect using exponential backoff)
|
|
6108
|
-
disableBc: d =
|
|
6108
|
+
disableBc: d = Ll
|
|
6109
6109
|
// Disable cross-tab BroadcastChannel communication
|
|
6110
6110
|
} = {}) {
|
|
6111
6111
|
super();
|
|
@@ -6135,39 +6135,39 @@ var Ml = typeof WebSocket > "u" ? null : WebSocket, Ul = class extends ji {
|
|
|
6135
6135
|
y(this, "_checkInterval");
|
|
6136
6136
|
for (; t[t.length - 1] === "/"; )
|
|
6137
6137
|
t = t.slice(0, t.length - 1);
|
|
6138
|
-
const u =
|
|
6138
|
+
const u = Hi(o);
|
|
6139
6139
|
this.maxBackoffTime = h, this.bcChannel = t + "/" + n, this.url = c ? t : t + "/" + n + (u.length === 0 ? "" : "?" + u), this.roomname = n, this.doc = s, this._WS = l, this.awareness = i, this.wsconnected = !1, this.wsconnecting = !1, this.bcconnected = !1, this.disableBc = d, this.wsUnsuccessfulReconnects = 0, this.messageHandlers = oe.slice(), this._synced = !1, this.ws = null, this.wsLastMessageReceived = 0, this.shouldConnect = r, this._resyncInterval = 0, a > 0 && (this._resyncInterval = /** @type {any} */
|
|
6140
6140
|
setInterval(() => {
|
|
6141
6141
|
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
6142
|
-
const f =
|
|
6143
|
-
|
|
6142
|
+
const f = N();
|
|
6143
|
+
v(f, it), fn(f, s), Bt(M(f), this.ws);
|
|
6144
6144
|
}
|
|
6145
6145
|
}, a)), this._bcSubscriber = (f, g) => {
|
|
6146
6146
|
if (g !== this) {
|
|
6147
|
-
const p =
|
|
6148
|
-
|
|
6147
|
+
const p = Ur(this, new Uint8Array(f), !1);
|
|
6148
|
+
yn(p) > 1 && St(this.bcChannel, M(p), this);
|
|
6149
6149
|
}
|
|
6150
6150
|
}, this._updateHandler = (f, g) => {
|
|
6151
6151
|
if (g !== this) {
|
|
6152
|
-
const p =
|
|
6153
|
-
|
|
6152
|
+
const p = N();
|
|
6153
|
+
v(p, it), Dl(p, f), qe(this, M(p));
|
|
6154
6154
|
}
|
|
6155
6155
|
}, this.doc.on("update", this._updateHandler), this._awarenessUpdateHandler = ({ added: f, updated: g, removed: p }, _) => {
|
|
6156
|
-
const rt = f.concat(g).concat(p), Ve =
|
|
6157
|
-
|
|
6156
|
+
const rt = f.concat(g).concat(p), Ve = N();
|
|
6157
|
+
v(Ve, At), Dt(
|
|
6158
6158
|
Ve,
|
|
6159
6159
|
Ht(i, rt)
|
|
6160
6160
|
), qe(this, M(Ve));
|
|
6161
6161
|
}, this._unloadHandler = () => {
|
|
6162
|
-
|
|
6162
|
+
Bn(
|
|
6163
6163
|
this.awareness,
|
|
6164
6164
|
[s.clientID],
|
|
6165
6165
|
"window unload"
|
|
6166
6166
|
);
|
|
6167
6167
|
}, 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} */
|
|
6168
6168
|
setInterval(() => {
|
|
6169
|
-
this.wsconnected &&
|
|
6170
|
-
},
|
|
6169
|
+
this.wsconnected && gs < nn() - this.wsLastMessageReceived && (Il(this.ws !== null, "ws must not be null"), this.ws.close());
|
|
6170
|
+
}, gs / 10), r && this.connect();
|
|
6171
6171
|
}
|
|
6172
6172
|
/**
|
|
6173
6173
|
* @type {boolean}
|
|
@@ -6184,19 +6184,19 @@ var Ml = typeof WebSocket > "u" ? null : WebSocket, Ul = class extends ji {
|
|
|
6184
6184
|
connectBc() {
|
|
6185
6185
|
if (this.disableBc)
|
|
6186
6186
|
return;
|
|
6187
|
-
this.bcconnected || (
|
|
6188
|
-
const t =
|
|
6189
|
-
|
|
6190
|
-
const n =
|
|
6191
|
-
|
|
6192
|
-
const s =
|
|
6193
|
-
|
|
6187
|
+
this.bcconnected || (Bi(this.bcChannel, this._bcSubscriber), this.bcconnected = !0);
|
|
6188
|
+
const t = N();
|
|
6189
|
+
v(t, it), fn(t, this.doc), St(this.bcChannel, M(t), this);
|
|
6190
|
+
const n = N();
|
|
6191
|
+
v(n, it), xr(n, this.doc), St(this.bcChannel, M(n), this);
|
|
6192
|
+
const s = N();
|
|
6193
|
+
v(s, Mr), St(
|
|
6194
6194
|
this.bcChannel,
|
|
6195
6195
|
M(s),
|
|
6196
6196
|
this
|
|
6197
6197
|
);
|
|
6198
|
-
const r =
|
|
6199
|
-
|
|
6198
|
+
const r = N();
|
|
6199
|
+
v(r, At), Dt(
|
|
6200
6200
|
r,
|
|
6201
6201
|
Ht(this.awareness, [
|
|
6202
6202
|
this.doc.clientID
|
|
@@ -6208,24 +6208,24 @@ var Ml = typeof WebSocket > "u" ? null : WebSocket, Ul = class extends ji {
|
|
|
6208
6208
|
);
|
|
6209
6209
|
}
|
|
6210
6210
|
disconnectBc() {
|
|
6211
|
-
const t =
|
|
6212
|
-
|
|
6211
|
+
const t = N();
|
|
6212
|
+
v(t, At), Dt(
|
|
6213
6213
|
t,
|
|
6214
6214
|
Ht(
|
|
6215
6215
|
this.awareness,
|
|
6216
6216
|
[this.doc.clientID],
|
|
6217
6217
|
/* @__PURE__ */ new Map()
|
|
6218
6218
|
)
|
|
6219
|
-
), qe(this, M(t)), this.bcconnected && (
|
|
6219
|
+
), qe(this, M(t)), this.bcconnected && (Vi(this.bcChannel, this._bcSubscriber), this.bcconnected = !1);
|
|
6220
6220
|
}
|
|
6221
6221
|
disconnect() {
|
|
6222
6222
|
this.shouldConnect = !1, this.disconnectBc(), this.ws !== null && this.ws.close();
|
|
6223
6223
|
}
|
|
6224
6224
|
connect() {
|
|
6225
|
-
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (
|
|
6225
|
+
this.shouldConnect = !0, !this.wsconnected && this.ws === null && (Or(this), this.connectBc());
|
|
6226
6226
|
}
|
|
6227
6227
|
};
|
|
6228
|
-
function
|
|
6228
|
+
function Ml() {
|
|
6229
6229
|
if (crypto && crypto.randomUUID)
|
|
6230
6230
|
return crypto.randomUUID();
|
|
6231
6231
|
let e = (/* @__PURE__ */ new Date()).getTime(), t = typeof performance < "u" && performance.now && performance.now() * 1e3 || 0;
|
|
@@ -6234,24 +6234,24 @@ function Ol() {
|
|
|
6234
6234
|
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);
|
|
6235
6235
|
});
|
|
6236
6236
|
}
|
|
6237
|
-
function
|
|
6237
|
+
function ps(e, t, n) {
|
|
6238
6238
|
if (typeof e !== n)
|
|
6239
6239
|
throw new Error(
|
|
6240
6240
|
`Invalid "${t}" parameter provided to YPartyKitProvider. Expected: ${n}, received: ${e}`
|
|
6241
6241
|
);
|
|
6242
6242
|
}
|
|
6243
|
-
var ot,
|
|
6243
|
+
var ot, Ss, Ul = (Ss = class extends Tl {
|
|
6244
6244
|
constructor(t, n, s, r = {}) {
|
|
6245
|
-
|
|
6246
|
-
const i = `${r.protocol || (t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss")}://${t}${r.prefix || `/parties/${r.party || "main"}`}`, o = r.connectionId ??
|
|
6245
|
+
ps(t, "host", "string"), ps(n, "room", "string"), t = t.replace(/^(http|https|ws|wss):\/\//, ""), t.endsWith("/") && t.slice(0, -1);
|
|
6246
|
+
const i = `${r.protocol || (t.startsWith("localhost:") || t.startsWith("127.0.0.1:") || t.startsWith("192.168.") || t.startsWith("10.") || t.startsWith("172.") && t.split(".")[1] >= "16" && t.split(".")[1] <= "31" ? "ws" : "wss")}://${t}${r.prefix || `/parties/${r.party || "main"}`}`, o = r.connectionId ?? Ml(), { params: c, connect: l = !0, ...a } = r, h = {
|
|
6247
6247
|
...a,
|
|
6248
6248
|
isPrefixedUrl: !!r.prefix,
|
|
6249
6249
|
connect: !1
|
|
6250
6250
|
};
|
|
6251
6251
|
super(i, n, s ?? new mt(), h);
|
|
6252
6252
|
y(this, "id");
|
|
6253
|
-
|
|
6254
|
-
this.id = o,
|
|
6253
|
+
Hn(this, ot, void 0);
|
|
6254
|
+
this.id = o, jn(this, ot, c), l && this.connect();
|
|
6255
6255
|
}
|
|
6256
6256
|
connect() {
|
|
6257
6257
|
Promise.resolve(
|
|
@@ -6267,10 +6267,10 @@ var ot, ks, Rl = (ks = class extends Ul {
|
|
|
6267
6267
|
throw console.error("Failed to open connecton to PartyKit", t), new Error(t);
|
|
6268
6268
|
});
|
|
6269
6269
|
}
|
|
6270
|
-
}, ot = new WeakMap(),
|
|
6270
|
+
}, ot = new WeakMap(), Ss);
|
|
6271
6271
|
const bt = (e) => xt((t, n) => {
|
|
6272
6272
|
e.onerror = (s) => n(new Error(s.target.error)), e.onsuccess = (s) => t(s.target.result);
|
|
6273
|
-
}),
|
|
6273
|
+
}), Ol = (e, t) => xt((n, s) => {
|
|
6274
6274
|
const r = indexedDB.open(e);
|
|
6275
6275
|
r.onupgradeneeded = (i) => t(i.target.result), r.onerror = (i) => s(G(i.target.error)), r.onsuccess = (i) => {
|
|
6276
6276
|
const o = i.target.result;
|
|
@@ -6278,73 +6278,73 @@ const bt = (e) => xt((t, n) => {
|
|
|
6278
6278
|
o.close();
|
|
6279
6279
|
}, typeof addEventListener < "u" && addEventListener("unload", () => o.close()), n(o);
|
|
6280
6280
|
};
|
|
6281
|
-
}),
|
|
6281
|
+
}), Rl = (e) => bt(indexedDB.deleteDatabase(e)), $l = (e, t) => t.forEach(
|
|
6282
6282
|
(n) => (
|
|
6283
6283
|
// @ts-ignore
|
|
6284
6284
|
e.createObjectStore.apply(e, n)
|
|
6285
6285
|
)
|
|
6286
|
-
),
|
|
6286
|
+
), Nt = (e, t, n = "readwrite") => {
|
|
6287
6287
|
const s = e.transaction(t, n);
|
|
6288
|
-
return t.map((r) =>
|
|
6289
|
-
},
|
|
6288
|
+
return t.map((r) => Kl(s, r));
|
|
6289
|
+
}, Rr = (e, t) => bt(e.count(t)), Nl = (e, t) => bt(e.get(t)), $r = (e, t) => bt(e.delete(t)), Bl = (e, t, n) => bt(e.put(t, n)), gn = (e, t) => bt(e.add(t)), Vl = (e, t, n) => bt(e.getAll(t, n)), Fl = (e, t, n) => {
|
|
6290
6290
|
let s = null;
|
|
6291
|
-
return
|
|
6292
|
-
},
|
|
6291
|
+
return zl(e, t, (r) => (s = r, !1), n).then(() => s);
|
|
6292
|
+
}, Hl = (e, t = null) => Fl(e, t, "prev"), jl = (e, t) => xt((n, s) => {
|
|
6293
6293
|
e.onerror = s, e.onsuccess = async (r) => {
|
|
6294
6294
|
const i = r.target.result;
|
|
6295
6295
|
if (i === null || await t(i) === !1)
|
|
6296
6296
|
return n();
|
|
6297
6297
|
i.continue();
|
|
6298
6298
|
};
|
|
6299
|
-
}),
|
|
6299
|
+
}), zl = (e, t, n, s = "next") => jl(e.openKeyCursor(t, s), (r) => n(r.key)), Kl = (e, t) => e.objectStore(t), Yl = (e, t) => IDBKeyRange.upperBound(e, t), Xl = (e, t) => IDBKeyRange.lowerBound(e, t), Ze = "custom", Nr = "updates", Br = 500, Vr = (e, t = () => {
|
|
6300
6300
|
}, n = () => {
|
|
6301
6301
|
}) => {
|
|
6302
|
-
const [s] =
|
|
6302
|
+
const [s] = Nt(
|
|
6303
6303
|
/** @type {IDBDatabase} */
|
|
6304
6304
|
e.db,
|
|
6305
|
-
[
|
|
6305
|
+
[Nr]
|
|
6306
6306
|
);
|
|
6307
|
-
return
|
|
6307
|
+
return Vl(s, Xl(e._dbref, !1)).then((r) => {
|
|
6308
6308
|
e._destroyed || (t(s), S(e.doc, () => {
|
|
6309
|
-
r.forEach((i) =>
|
|
6309
|
+
r.forEach((i) => tr(e.doc, i));
|
|
6310
6310
|
}, e, !1), n(s));
|
|
6311
|
-
}).then(() =>
|
|
6311
|
+
}).then(() => Hl(s).then((r) => {
|
|
6312
6312
|
e._dbref = r + 1;
|
|
6313
|
-
})).then(() =>
|
|
6313
|
+
})).then(() => Rr(s).then((r) => {
|
|
6314
6314
|
e._dbsize = r;
|
|
6315
6315
|
})).then(() => s);
|
|
6316
|
-
},
|
|
6317
|
-
(t || e._dbsize >=
|
|
6316
|
+
}, Jl = (e, t = !0) => Vr(e).then((n) => {
|
|
6317
|
+
(t || e._dbsize >= Br) && gn(n, xn(e.doc)).then(() => $r(n, Yl(e._dbref, !0))).then(() => Rr(n).then((s) => {
|
|
6318
6318
|
e._dbsize = s;
|
|
6319
6319
|
}));
|
|
6320
6320
|
});
|
|
6321
|
-
class
|
|
6321
|
+
class Wl extends Ms {
|
|
6322
6322
|
/**
|
|
6323
6323
|
* @param {string} name
|
|
6324
6324
|
* @param {Y.Doc} doc
|
|
6325
6325
|
*/
|
|
6326
6326
|
constructor(t, n) {
|
|
6327
|
-
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db =
|
|
6327
|
+
super(), this.doc = n, this.name = t, this._dbref = 0, this._dbsize = 0, this._destroyed = !1, this.db = null, this.synced = !1, this._db = Ol(
|
|
6328
6328
|
t,
|
|
6329
|
-
(s) =>
|
|
6329
|
+
(s) => $l(s, [
|
|
6330
6330
|
["updates", { autoIncrement: !0 }],
|
|
6331
6331
|
["custom"]
|
|
6332
6332
|
])
|
|
6333
6333
|
), this.whenSynced = xt((s) => this.on("synced", () => s(this))), this._db.then((s) => {
|
|
6334
|
-
this.db = s,
|
|
6334
|
+
this.db = s, Vr(this, (o) => gn(o, xn(n)), () => {
|
|
6335
6335
|
if (this._destroyed)
|
|
6336
6336
|
return this;
|
|
6337
6337
|
this.synced = !0, this.emit("synced", [this]);
|
|
6338
6338
|
});
|
|
6339
6339
|
}), this._storeTimeout = 1e3, this._storeTimeoutId = null, this._storeUpdate = (s, r) => {
|
|
6340
6340
|
if (this.db && r !== this) {
|
|
6341
|
-
const [i] =
|
|
6341
|
+
const [i] = Nt(
|
|
6342
6342
|
/** @type {IDBDatabase} */
|
|
6343
6343
|
this.db,
|
|
6344
|
-
[
|
|
6344
|
+
[Nr]
|
|
6345
6345
|
);
|
|
6346
|
-
|
|
6347
|
-
|
|
6346
|
+
gn(i, s), ++this._dbsize >= Br && (this._storeTimeoutId !== null && clearTimeout(this._storeTimeoutId), this._storeTimeoutId = setTimeout(() => {
|
|
6347
|
+
Jl(this, !1), this._storeTimeoutId = null;
|
|
6348
6348
|
}, this._storeTimeout));
|
|
6349
6349
|
}
|
|
6350
6350
|
}, n.on("update", this._storeUpdate), this.destroy = this.destroy.bind(this), n.on("destroy", this.destroy);
|
|
@@ -6361,7 +6361,7 @@ class Gl extends Os {
|
|
|
6361
6361
|
*/
|
|
6362
6362
|
clearData() {
|
|
6363
6363
|
return this.destroy().then(() => {
|
|
6364
|
-
|
|
6364
|
+
Rl(this.name);
|
|
6365
6365
|
});
|
|
6366
6366
|
}
|
|
6367
6367
|
/**
|
|
@@ -6370,8 +6370,8 @@ class Gl extends Os {
|
|
|
6370
6370
|
*/
|
|
6371
6371
|
get(t) {
|
|
6372
6372
|
return this._db.then((n) => {
|
|
6373
|
-
const [s] =
|
|
6374
|
-
return
|
|
6373
|
+
const [s] = Nt(n, [Ze], "readonly");
|
|
6374
|
+
return Nl(s, t);
|
|
6375
6375
|
});
|
|
6376
6376
|
}
|
|
6377
6377
|
/**
|
|
@@ -6381,8 +6381,8 @@ class Gl extends Os {
|
|
|
6381
6381
|
*/
|
|
6382
6382
|
set(t, n) {
|
|
6383
6383
|
return this._db.then((s) => {
|
|
6384
|
-
const [r] =
|
|
6385
|
-
return
|
|
6384
|
+
const [r] = Nt(s, [Ze]);
|
|
6385
|
+
return Bl(r, n, t);
|
|
6386
6386
|
});
|
|
6387
6387
|
}
|
|
6388
6388
|
/**
|
|
@@ -6391,33 +6391,33 @@ class Gl extends Os {
|
|
|
6391
6391
|
*/
|
|
6392
6392
|
del(t) {
|
|
6393
6393
|
return this._db.then((n) => {
|
|
6394
|
-
const [s] =
|
|
6395
|
-
return
|
|
6394
|
+
const [s] = Nt(n, [Ze]);
|
|
6395
|
+
return $r(s, t);
|
|
6396
6396
|
});
|
|
6397
6397
|
}
|
|
6398
6398
|
}
|
|
6399
|
-
const
|
|
6400
|
-
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
|
|
6401
|
-
function
|
|
6399
|
+
const Pl = "can-duplicate-to";
|
|
6400
|
+
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 || {});
|
|
6401
|
+
function Gl(e) {
|
|
6402
6402
|
return e.id;
|
|
6403
6403
|
}
|
|
6404
|
-
const
|
|
6404
|
+
const Fr = `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>")
|
|
6405
6405
|
16 0,
|
|
6406
|
-
auto`,
|
|
6407
|
-
function
|
|
6406
|
+
auto`, ql = `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`;
|
|
6407
|
+
function ws(e, { getData: t, getElement: n, getLocalData: s, setLocalData: r }) {
|
|
6408
6408
|
const i = t(), o = s(), c = n();
|
|
6409
6409
|
if (o.isHovering = !0, e.altKey) {
|
|
6410
6410
|
if (i.scale <= 0.5) {
|
|
6411
6411
|
c.style.cursor = "not-allowed";
|
|
6412
6412
|
return;
|
|
6413
6413
|
}
|
|
6414
|
-
c.style.cursor =
|
|
6414
|
+
c.style.cursor = ql;
|
|
6415
6415
|
} else {
|
|
6416
6416
|
if (i.scale >= i.maxScale) {
|
|
6417
6417
|
c.style.cursor = "not-allowed";
|
|
6418
6418
|
return;
|
|
6419
6419
|
}
|
|
6420
|
-
c.style.cursor =
|
|
6420
|
+
c.style.cursor = Fr;
|
|
6421
6421
|
}
|
|
6422
6422
|
r(o);
|
|
6423
6423
|
}
|
|
@@ -6428,7 +6428,7 @@ function fe(e) {
|
|
|
6428
6428
|
}
|
|
6429
6429
|
return { clientX: e.clientX, clientY: e.clientY };
|
|
6430
6430
|
}
|
|
6431
|
-
const
|
|
6431
|
+
const Zl = {
|
|
6432
6432
|
[
|
|
6433
6433
|
"can-move"
|
|
6434
6434
|
/* CanMove */
|
|
@@ -6507,7 +6507,7 @@ const ta = {
|
|
|
6507
6507
|
return;
|
|
6508
6508
|
i -= 0.1;
|
|
6509
6509
|
} else {
|
|
6510
|
-
if (n.style.cursor =
|
|
6510
|
+
if (n.style.cursor = Fr, t.scale >= r.maxScale)
|
|
6511
6511
|
return;
|
|
6512
6512
|
i += 0.1;
|
|
6513
6513
|
}
|
|
@@ -6515,8 +6515,8 @@ const ta = {
|
|
|
6515
6515
|
},
|
|
6516
6516
|
onMount: (e) => {
|
|
6517
6517
|
e.getElement().addEventListener("mouseenter", (t) => {
|
|
6518
|
-
|
|
6519
|
-
const n = (s) =>
|
|
6518
|
+
ws(t, e);
|
|
6519
|
+
const n = (s) => ws(s, e);
|
|
6520
6520
|
document.addEventListener("keydown", n), document.addEventListener("keyup", n), e.getElement().addEventListener("mouseleave", (s) => {
|
|
6521
6521
|
document.removeEventListener("keydown", n), document.removeEventListener("keyup", n);
|
|
6522
6522
|
});
|
|
@@ -6546,7 +6546,7 @@ const ta = {
|
|
|
6546
6546
|
);
|
|
6547
6547
|
return;
|
|
6548
6548
|
}
|
|
6549
|
-
const l = s.getAttribute(
|
|
6549
|
+
const l = s.getAttribute(Pl);
|
|
6550
6550
|
function a(d) {
|
|
6551
6551
|
if (l) {
|
|
6552
6552
|
const u = document.getElementById(l) || document.querySelector(l);
|
|
@@ -6593,79 +6593,18 @@ const ta = {
|
|
|
6593
6593
|
defaultData: (e) => Ot(e),
|
|
6594
6594
|
onMount: ({ getElement: e, setData: t, getData: n }) => {
|
|
6595
6595
|
const s = e();
|
|
6596
|
-
|
|
6597
|
-
const i = n(), o =
|
|
6596
|
+
Ql(s, (r) => {
|
|
6597
|
+
const i = n(), o = ea(i, r);
|
|
6598
6598
|
t(o);
|
|
6599
6599
|
});
|
|
6600
6600
|
},
|
|
6601
6601
|
updateElement: ({ element: e, data: t }) => {
|
|
6602
|
-
console.log("new data", t);
|
|
6603
6602
|
const n = Ot(e);
|
|
6604
|
-
qt(n, t) ||
|
|
6605
|
-
}
|
|
6606
|
-
},
|
|
6607
|
-
[
|
|
6608
|
-
"can-sync"
|
|
6609
|
-
/* CanSync */
|
|
6610
|
-
]: {
|
|
6611
|
-
defaultData: (e) => Qe(e),
|
|
6612
|
-
updateElement: ({ element: e, data: t }) => {
|
|
6613
|
-
ea(e, t);
|
|
6614
|
-
},
|
|
6615
|
-
onMount: ({ getElement: e, setData: t, getData: n }) => {
|
|
6616
|
-
console.log("hello");
|
|
6617
|
-
const s = e();
|
|
6618
|
-
bs(s, () => {
|
|
6619
|
-
const r = Qe(s);
|
|
6620
|
-
t(r), console.log("element changed", r);
|
|
6621
|
-
}), s.addEventListener("change", () => {
|
|
6622
|
-
const r = Qe(s);
|
|
6623
|
-
t(r);
|
|
6624
|
-
});
|
|
6603
|
+
qt(n, t) || Hr(e, t);
|
|
6625
6604
|
}
|
|
6626
6605
|
}
|
|
6627
6606
|
};
|
|
6628
|
-
function
|
|
6629
|
-
switch (e.tagName.toLowerCase()) {
|
|
6630
|
-
case "select":
|
|
6631
|
-
return { value: e.value };
|
|
6632
|
-
case "input":
|
|
6633
|
-
const t = e;
|
|
6634
|
-
switch (t.type) {
|
|
6635
|
-
case "checkbox":
|
|
6636
|
-
case "radio":
|
|
6637
|
-
return { checked: t.checked };
|
|
6638
|
-
default:
|
|
6639
|
-
return { value: t.value };
|
|
6640
|
-
}
|
|
6641
|
-
case "textarea":
|
|
6642
|
-
return { value: e.value };
|
|
6643
|
-
default:
|
|
6644
|
-
return {};
|
|
6645
|
-
}
|
|
6646
|
-
}
|
|
6647
|
-
function ea(e, t) {
|
|
6648
|
-
switch (e.tagName.toLowerCase()) {
|
|
6649
|
-
case "select":
|
|
6650
|
-
e.value = t.value;
|
|
6651
|
-
break;
|
|
6652
|
-
case "input":
|
|
6653
|
-
const n = e;
|
|
6654
|
-
switch (n.type) {
|
|
6655
|
-
case "checkbox":
|
|
6656
|
-
case "radio":
|
|
6657
|
-
n.checked = t.checked;
|
|
6658
|
-
break;
|
|
6659
|
-
default:
|
|
6660
|
-
n.value = t.value;
|
|
6661
|
-
}
|
|
6662
|
-
break;
|
|
6663
|
-
case "textarea":
|
|
6664
|
-
e.value = t.value;
|
|
6665
|
-
break;
|
|
6666
|
-
}
|
|
6667
|
-
}
|
|
6668
|
-
function ys(e) {
|
|
6607
|
+
function ms(e) {
|
|
6669
6608
|
return e.nodeType === "HTMLElement";
|
|
6670
6609
|
}
|
|
6671
6610
|
function qt(e, t) {
|
|
@@ -6673,7 +6612,7 @@ function qt(e, t) {
|
|
|
6673
6612
|
return !1;
|
|
6674
6613
|
if (e.nodeType === "Text" && t.nodeType === "Text")
|
|
6675
6614
|
return e.textContent === t.textContent;
|
|
6676
|
-
if (
|
|
6615
|
+
if (ms(e) && ms(t)) {
|
|
6677
6616
|
if (e.tagName !== t.tagName || Object.keys(e.attributes).length !== Object.keys(t.attributes).length)
|
|
6678
6617
|
return !1;
|
|
6679
6618
|
for (const [n, s] of Object.entries(e.attributes))
|
|
@@ -6687,7 +6626,7 @@ function qt(e, t) {
|
|
|
6687
6626
|
}
|
|
6688
6627
|
return !0;
|
|
6689
6628
|
}
|
|
6690
|
-
function
|
|
6629
|
+
function Ql(e, t, n) {
|
|
6691
6630
|
const s = {
|
|
6692
6631
|
childList: !0,
|
|
6693
6632
|
attributes: !0,
|
|
@@ -6714,32 +6653,32 @@ function bs(e, t, n) {
|
|
|
6714
6653
|
}, i = new MutationObserver(r);
|
|
6715
6654
|
return i.observe(e, s), i;
|
|
6716
6655
|
}
|
|
6717
|
-
function
|
|
6656
|
+
function ta(e) {
|
|
6718
6657
|
return JSON.parse(JSON.stringify(e));
|
|
6719
6658
|
}
|
|
6720
|
-
function
|
|
6721
|
-
let n =
|
|
6659
|
+
function ea(e, t) {
|
|
6660
|
+
let n = ta(e);
|
|
6722
6661
|
return t.forEach((s) => {
|
|
6723
6662
|
switch (s.type) {
|
|
6724
6663
|
case "attributes":
|
|
6725
|
-
|
|
6664
|
+
na(n, s);
|
|
6726
6665
|
break;
|
|
6727
6666
|
case "childList":
|
|
6728
|
-
|
|
6667
|
+
sa(n, s);
|
|
6729
6668
|
break;
|
|
6730
6669
|
case "characterData":
|
|
6731
|
-
|
|
6670
|
+
ra(n, s);
|
|
6732
6671
|
break;
|
|
6733
6672
|
}
|
|
6734
6673
|
}), n;
|
|
6735
6674
|
}
|
|
6736
|
-
function
|
|
6675
|
+
function na(e, t) {
|
|
6737
6676
|
if (e.nodeType !== "Text" && t.target instanceof HTMLElement) {
|
|
6738
6677
|
const n = t.attributeName, s = t.target.getAttribute(n);
|
|
6739
6678
|
s !== null ? e.attributes[n] = s : delete e.attributes[n];
|
|
6740
6679
|
}
|
|
6741
6680
|
}
|
|
6742
|
-
function
|
|
6681
|
+
function sa(e, t) {
|
|
6743
6682
|
e.nodeType !== "Text" && (t.removedNodes.length && t.removedNodes.forEach((n) => {
|
|
6744
6683
|
if (!Zt(n))
|
|
6745
6684
|
return;
|
|
@@ -6754,7 +6693,7 @@ function ia(e, t) {
|
|
|
6754
6693
|
e.children.find((r) => qt(r, s)) || e.children.push(s);
|
|
6755
6694
|
}));
|
|
6756
6695
|
}
|
|
6757
|
-
function
|
|
6696
|
+
function ra(e, t) {
|
|
6758
6697
|
const n = t.target;
|
|
6759
6698
|
switch (e.nodeType) {
|
|
6760
6699
|
case "Text":
|
|
@@ -6785,14 +6724,14 @@ function Ot(e) {
|
|
|
6785
6724
|
Zt(n) && t.children.push(Ot(n));
|
|
6786
6725
|
}), t;
|
|
6787
6726
|
}
|
|
6788
|
-
function
|
|
6789
|
-
|
|
6727
|
+
function Hr(e, t) {
|
|
6728
|
+
ia(e, t), t.nodeType === "HTMLElement" && (oa(e, t), t.children.length > 0 && ca(e, t));
|
|
6790
6729
|
}
|
|
6791
|
-
function
|
|
6730
|
+
function ia(e, t) {
|
|
6792
6731
|
t && t.nodeType === "Text" && e.textContent !== t.textContent && (e.textContent = t.textContent || "");
|
|
6793
6732
|
}
|
|
6794
|
-
function
|
|
6795
|
-
if (
|
|
6733
|
+
function oa(e, t) {
|
|
6734
|
+
if (t) {
|
|
6796
6735
|
for (const [n, s] of Object.entries(t.attributes))
|
|
6797
6736
|
e.getAttribute(n) !== s && e.setAttribute(n, s);
|
|
6798
6737
|
Array.from(e.attributes).forEach((n) => {
|
|
@@ -6800,7 +6739,7 @@ function la(e, t) {
|
|
|
6800
6739
|
});
|
|
6801
6740
|
}
|
|
6802
6741
|
}
|
|
6803
|
-
function
|
|
6742
|
+
function ca(e, t) {
|
|
6804
6743
|
const n = /* @__PURE__ */ new Set();
|
|
6805
6744
|
t.children.forEach((s) => {
|
|
6806
6745
|
let r = Array.from(
|
|
@@ -6811,18 +6750,18 @@ function aa(e, t) {
|
|
|
6811
6750
|
qt(Ot(i), s) && !n.has(i)
|
|
6812
6751
|
)
|
|
6813
6752
|
);
|
|
6814
|
-
r || (r = s.nodeType === "Text" ? document.createTextNode(s.textContent) : document.createElement(s.tagName), e.appendChild(r)), n.add(r),
|
|
6753
|
+
r || (r = s.nodeType === "Text" ? document.createTextNode(s.textContent) : document.createElement(s.tagName), e.appendChild(r)), n.add(r), Hr(r, s);
|
|
6815
6754
|
}), Array.from(e.childNodes).filter(Zt).forEach((s) => {
|
|
6816
6755
|
n.has(s) || e.removeChild(s);
|
|
6817
6756
|
});
|
|
6818
6757
|
}
|
|
6819
|
-
const
|
|
6758
|
+
const ys = (e, t = 300) => {
|
|
6820
6759
|
let n;
|
|
6821
6760
|
return function(...s) {
|
|
6822
6761
|
clearTimeout(n), n = setTimeout(() => e.apply(this, s), t);
|
|
6823
6762
|
};
|
|
6824
6763
|
};
|
|
6825
|
-
class
|
|
6764
|
+
class la {
|
|
6826
6765
|
constructor(t) {
|
|
6827
6766
|
y(this, "defaultData");
|
|
6828
6767
|
y(this, "localData");
|
|
@@ -6858,7 +6797,7 @@ class ha {
|
|
|
6858
6797
|
debounceMs: f,
|
|
6859
6798
|
triggerAwarenessUpdate: g
|
|
6860
6799
|
} = t;
|
|
6861
|
-
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 =
|
|
6800
|
+
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 = ys(this.onChange, f), this.onAwarenessChange = r, this.updateElement = h, this.updateElementAwareness = d;
|
|
6862
6801
|
const p = l === void 0 ? this.defaultData : l;
|
|
6863
6802
|
a !== void 0 && (this.__awareness = a);
|
|
6864
6803
|
const _ = c instanceof Function ? c(n) : c;
|
|
@@ -6877,7 +6816,7 @@ class ha {
|
|
|
6877
6816
|
debounceMs: h,
|
|
6878
6817
|
triggerAwarenessUpdate: d
|
|
6879
6818
|
}) {
|
|
6880
|
-
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange =
|
|
6819
|
+
this.triggerAwarenessUpdate = d, this.onChange = n, this.debouncedOnChange = ys(this.onChange, h), this.onAwarenessChange = s, this.updateElement = r, this.updateElementAwareness = i, o && !this.onClick && t.addEventListener("click", (u) => {
|
|
6881
6820
|
var f;
|
|
6882
6821
|
(f = this.onClick) == null || f.call(this, u, this.getEventHandlerData());
|
|
6883
6822
|
}), this.onClick = o, c && !this.onDrag && (t.addEventListener("touchstart", (u) => {
|
|
@@ -6992,25 +6931,25 @@ class ha {
|
|
|
6992
6931
|
this.setData(this.defaultData);
|
|
6993
6932
|
}
|
|
6994
6933
|
}
|
|
6995
|
-
async function
|
|
6934
|
+
async function aa(e, t) {
|
|
6996
6935
|
const n = new TextEncoder().encode(`${e}-${t.outerHTML}}`), s = await crypto.subtle.digest("SHA-1", n);
|
|
6997
6936
|
return Array.from(new Uint8Array(s)).map((o) => o.toString(16).padStart(2, "0")).join("");
|
|
6998
6937
|
}
|
|
6999
|
-
const
|
|
7000
|
-
function
|
|
6938
|
+
const ha = "playhtml.spencerc99.partykit.dev", pn = new mt();
|
|
6939
|
+
function ua(e) {
|
|
7001
6940
|
const t = window.location.pathname.replace(/\.[^/.]+$/, "");
|
|
7002
6941
|
return e ? t + window.location.search : t;
|
|
7003
6942
|
}
|
|
7004
|
-
let R, J =
|
|
7005
|
-
const
|
|
7006
|
-
let
|
|
7007
|
-
function
|
|
6943
|
+
let R, J = pn.getMap("playhtml-global"), $ = /* @__PURE__ */ new Map(), gt = /* @__PURE__ */ new Map();
|
|
6944
|
+
const bs = /* @__PURE__ */ new Map();
|
|
6945
|
+
let da = 0, ce = Zl;
|
|
6946
|
+
function jr() {
|
|
7008
6947
|
return [Be.CanPlay, ...Object.keys(ce)];
|
|
7009
6948
|
}
|
|
7010
|
-
function
|
|
6949
|
+
function fa(e) {
|
|
7011
6950
|
R.ws && R.ws.send(JSON.stringify(e));
|
|
7012
6951
|
}
|
|
7013
|
-
function
|
|
6952
|
+
function ga(e) {
|
|
7014
6953
|
if (e.data instanceof Blob)
|
|
7015
6954
|
return;
|
|
7016
6955
|
let t;
|
|
@@ -7024,17 +6963,17 @@ function wa(e) {
|
|
|
7024
6963
|
for (const i of r)
|
|
7025
6964
|
i.onEvent(s);
|
|
7026
6965
|
}
|
|
7027
|
-
let Lt = !1,
|
|
7028
|
-
async function
|
|
6966
|
+
let Lt = !1, wn = !0;
|
|
6967
|
+
async function pa({
|
|
7029
6968
|
// TODO: if it is a localhost url, need to make some deterministic way to connect to the same room.
|
|
7030
|
-
host: e =
|
|
6969
|
+
host: e = ha,
|
|
7031
6970
|
extraCapabilities: t,
|
|
7032
6971
|
events: n,
|
|
7033
6972
|
defaultRoomOptions: s = {},
|
|
7034
|
-
room: r =
|
|
6973
|
+
room: r = ua(s.includeSearch),
|
|
7035
6974
|
onError: i
|
|
7036
6975
|
} = {}) {
|
|
7037
|
-
if (!
|
|
6976
|
+
if (!wn) {
|
|
7038
6977
|
console.error("playhtml already set up!");
|
|
7039
6978
|
return;
|
|
7040
6979
|
}
|
|
@@ -7046,29 +6985,29 @@ async function ma({
|
|
|
7046
6985
|
࿂࿂࿂࿂ https://playhtml.fun ࿂࿂࿂࿂
|
|
7047
6986
|
࿂࿂࿂࿂ ࿂ ࿂ ࿂ ࿂ ࿂࿂࿂࿂
|
|
7048
6987
|
࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂࿂`
|
|
7049
|
-
), R = new
|
|
6988
|
+
), R = new Ul(c, o, pn), R.on("error", () => {
|
|
7050
6989
|
i == null || i();
|
|
7051
|
-
}), new
|
|
6990
|
+
}), new Wl(o, pn), t)
|
|
7052
6991
|
for (const [a, h] of Object.entries(t))
|
|
7053
6992
|
ce[a] = h;
|
|
7054
6993
|
if (n)
|
|
7055
6994
|
for (const [a, h] of Object.entries(n))
|
|
7056
|
-
|
|
6995
|
+
Xr(a, h);
|
|
7057
6996
|
const l = document.createElement("link");
|
|
7058
6997
|
return l.rel = "stylesheet", l.href = "https://unpkg.com/playhtml@latest/dist/style.css", document.head.appendChild(l), await new Promise((a) => {
|
|
7059
6998
|
Lt && a(!0), R.on("sync", (h) => {
|
|
7060
|
-
h ? h && R.ws.addEventListener("message",
|
|
6999
|
+
h ? h && R.ws.addEventListener("message", ga) : console.error("Issue connecting to yjs..."), !Lt && (Lt = !0, console.log("[PLAYHTML]: Setting up elements... Time to have some fun 🛝"), Yr(), a(!0));
|
|
7061
7000
|
});
|
|
7062
7001
|
}), R;
|
|
7063
7002
|
}
|
|
7064
|
-
function
|
|
7003
|
+
function wa(e, t) {
|
|
7065
7004
|
const n = R.awareness.getLocalState();
|
|
7066
7005
|
return ((n == null ? void 0 : n[e]) ?? {})[t];
|
|
7067
7006
|
}
|
|
7068
7007
|
function xe(e) {
|
|
7069
7008
|
return e instanceof HTMLElement;
|
|
7070
7009
|
}
|
|
7071
|
-
function
|
|
7010
|
+
function zr(e, t) {
|
|
7072
7011
|
if (e === t)
|
|
7073
7012
|
return !0;
|
|
7074
7013
|
if (e instanceof Object && t instanceof Object) {
|
|
@@ -7076,22 +7015,22 @@ function Yr(e, t) {
|
|
|
7076
7015
|
if (n.length !== s.length)
|
|
7077
7016
|
return !1;
|
|
7078
7017
|
for (const r of n)
|
|
7079
|
-
if (!
|
|
7018
|
+
if (!zr(e[r], t[r]))
|
|
7080
7019
|
return !1;
|
|
7081
7020
|
return !0;
|
|
7082
7021
|
}
|
|
7083
7022
|
return !1;
|
|
7084
7023
|
}
|
|
7085
|
-
function
|
|
7024
|
+
function ma(e, t, n, s) {
|
|
7086
7025
|
const r = J.get(t);
|
|
7087
7026
|
return {
|
|
7088
7027
|
...n,
|
|
7089
7028
|
// TODO: when adding save-state if no save state, then just use defaultData
|
|
7090
7029
|
data: r.get(s) ?? (n.defaultData instanceof Function ? n.defaultData(e) : n.defaultData),
|
|
7091
|
-
awareness:
|
|
7030
|
+
awareness: wa(t, s) ?? n.myDefaultAwareness !== void 0 ? [n.myDefaultAwareness] : void 0,
|
|
7092
7031
|
element: e,
|
|
7093
7032
|
onChange: (o) => {
|
|
7094
|
-
|
|
7033
|
+
zr(r.get(s), o) || r.set(s, o);
|
|
7095
7034
|
},
|
|
7096
7035
|
onAwarenessChange: (o) => {
|
|
7097
7036
|
var l;
|
|
@@ -7099,14 +7038,14 @@ function ba(e, t, n, s) {
|
|
|
7099
7038
|
c[s] !== o && (c[s] = o, R.awareness.setLocalStateField(t, c));
|
|
7100
7039
|
},
|
|
7101
7040
|
triggerAwarenessUpdate: () => {
|
|
7102
|
-
|
|
7041
|
+
Kr();
|
|
7103
7042
|
}
|
|
7104
7043
|
};
|
|
7105
7044
|
}
|
|
7106
|
-
function
|
|
7045
|
+
function ya(e) {
|
|
7107
7046
|
return e.defaultData !== void 0 && (typeof e.defaultData == "object" || typeof e.defaultData == "function") && e.updateElement !== void 0;
|
|
7108
7047
|
}
|
|
7109
|
-
function
|
|
7048
|
+
function ba(e, t) {
|
|
7110
7049
|
if (e === Be.CanPlay) {
|
|
7111
7050
|
const n = t;
|
|
7112
7051
|
return {
|
|
@@ -7126,7 +7065,7 @@ function _a(e, t) {
|
|
|
7126
7065
|
}
|
|
7127
7066
|
return ce[e];
|
|
7128
7067
|
}
|
|
7129
|
-
function
|
|
7068
|
+
function Kr() {
|
|
7130
7069
|
const e = /* @__PURE__ */ new Map();
|
|
7131
7070
|
function t(n, s, r, i) {
|
|
7132
7071
|
e.has(n) || e.set(n, /* @__PURE__ */ new Map());
|
|
@@ -7136,7 +7075,7 @@ function Xr() {
|
|
|
7136
7075
|
R.awareness.getStates().forEach((n, s) => {
|
|
7137
7076
|
var r;
|
|
7138
7077
|
for (const [i, o] of Object.entries(n)) {
|
|
7139
|
-
const c =
|
|
7078
|
+
const c = $.get(i);
|
|
7140
7079
|
if (c)
|
|
7141
7080
|
for (const [l, a] of c) {
|
|
7142
7081
|
if (!(l in o))
|
|
@@ -7151,7 +7090,7 @@ function Xr() {
|
|
|
7151
7090
|
}
|
|
7152
7091
|
}
|
|
7153
7092
|
for (const [i, o] of e) {
|
|
7154
|
-
const c =
|
|
7093
|
+
const c = $.get(i);
|
|
7155
7094
|
if (c)
|
|
7156
7095
|
for (const [l, a] of c) {
|
|
7157
7096
|
const h = (r = o.get(l)) == null ? void 0 : r.values();
|
|
@@ -7163,9 +7102,9 @@ function Xr() {
|
|
|
7163
7102
|
}
|
|
7164
7103
|
});
|
|
7165
7104
|
}
|
|
7166
|
-
function
|
|
7105
|
+
function Yr() {
|
|
7167
7106
|
if (Lt) {
|
|
7168
|
-
for (const e of
|
|
7107
|
+
for (const e of jr()) {
|
|
7169
7108
|
const t = Array.from(
|
|
7170
7109
|
document.querySelectorAll(`[${e}]`)
|
|
7171
7110
|
).filter(xe);
|
|
@@ -7173,35 +7112,35 @@ function Jr() {
|
|
|
7173
7112
|
t.map((n) => Qt(n, e))
|
|
7174
7113
|
);
|
|
7175
7114
|
}
|
|
7176
|
-
|
|
7115
|
+
wn && (J.observe((e) => {
|
|
7177
7116
|
e.changes.keys.forEach((t, n) => {
|
|
7178
7117
|
t.action === "add" && J.set(n, J.get(n));
|
|
7179
7118
|
});
|
|
7180
|
-
}), R.awareness.on("change", () =>
|
|
7119
|
+
}), R.awareness.on("change", () => Kr()), wn = !1);
|
|
7181
7120
|
}
|
|
7182
7121
|
}
|
|
7183
|
-
const
|
|
7184
|
-
init:
|
|
7185
|
-
setupPlayElements:
|
|
7186
|
-
setupPlayElement:
|
|
7187
|
-
removePlayElement:
|
|
7122
|
+
const Sa = {
|
|
7123
|
+
init: pa,
|
|
7124
|
+
setupPlayElements: Yr,
|
|
7125
|
+
setupPlayElement: Da,
|
|
7126
|
+
removePlayElement: Ea,
|
|
7188
7127
|
setupPlayElementForTag: Qt,
|
|
7189
7128
|
globalData: J,
|
|
7190
|
-
elementHandlers:
|
|
7129
|
+
elementHandlers: $,
|
|
7191
7130
|
eventHandlers: gt,
|
|
7192
|
-
dispatchPlayEvent:
|
|
7193
|
-
registerPlayEventListener:
|
|
7194
|
-
removePlayEventListener:
|
|
7131
|
+
dispatchPlayEvent: Ca,
|
|
7132
|
+
registerPlayEventListener: Xr,
|
|
7133
|
+
removePlayEventListener: Aa
|
|
7195
7134
|
};
|
|
7196
|
-
window.playhtml =
|
|
7197
|
-
function
|
|
7198
|
-
if (
|
|
7135
|
+
window.playhtml = Sa;
|
|
7136
|
+
function _a(e) {
|
|
7137
|
+
if ($.has(e) || !Lt)
|
|
7199
7138
|
return;
|
|
7200
|
-
|
|
7139
|
+
$.has(e) || $.set(e, /* @__PURE__ */ new Map()), e !== Be.CanPlay && ce[e], J.get(e) || J.set(e, new ut());
|
|
7201
7140
|
const t = J.get(e);
|
|
7202
7141
|
t.observe((n) => {
|
|
7203
7142
|
n.changes.keys.forEach(async (s, r) => {
|
|
7204
|
-
const i =
|
|
7143
|
+
const i = $.get(e);
|
|
7205
7144
|
if (s.action === "add") {
|
|
7206
7145
|
const o = document.getElementById(r);
|
|
7207
7146
|
if (!xe(o)) {
|
|
@@ -7225,41 +7164,41 @@ function Da(e) {
|
|
|
7225
7164
|
});
|
|
7226
7165
|
});
|
|
7227
7166
|
}
|
|
7228
|
-
function
|
|
7167
|
+
function ka(e, t) {
|
|
7229
7168
|
var n, s;
|
|
7230
7169
|
return ((s = (n = ce[t]) == null ? void 0 : n.isValidElementForTag) == null ? void 0 : s.call(n, e)) ?? !0;
|
|
7231
7170
|
}
|
|
7232
7171
|
async function Qt(e, t) {
|
|
7233
7172
|
var c;
|
|
7234
|
-
if (!
|
|
7173
|
+
if (!ka(e, t) || !Lt)
|
|
7235
7174
|
return;
|
|
7236
7175
|
if (!e.id) {
|
|
7237
7176
|
const l = e.getAttribute("selector-id");
|
|
7238
7177
|
if (l) {
|
|
7239
|
-
const a =
|
|
7240
|
-
e.id = btoa(`${t}-${l}-${a}`),
|
|
7178
|
+
const a = bs.get(l) ?? 0;
|
|
7179
|
+
e.id = btoa(`${t}-${l}-${a}`), bs.set(l, a + 1);
|
|
7241
7180
|
} else
|
|
7242
|
-
e.id = await
|
|
7181
|
+
e.id = await aa(t, e);
|
|
7243
7182
|
}
|
|
7244
|
-
const n =
|
|
7183
|
+
const n = Gl(e);
|
|
7245
7184
|
if (!n) {
|
|
7246
7185
|
console.error(
|
|
7247
7186
|
`Element ${e} does not have an acceptable ID. Please add an ID to the element to register it as a playhtml element.`
|
|
7248
7187
|
);
|
|
7249
7188
|
return;
|
|
7250
7189
|
}
|
|
7251
|
-
|
|
7252
|
-
const s =
|
|
7190
|
+
_a(t);
|
|
7191
|
+
const s = $.get(t), r = ba(
|
|
7253
7192
|
t,
|
|
7254
7193
|
e
|
|
7255
7194
|
);
|
|
7256
|
-
if (!
|
|
7195
|
+
if (!ya(r)) {
|
|
7257
7196
|
console.error(
|
|
7258
7197
|
`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.`
|
|
7259
7198
|
);
|
|
7260
7199
|
return;
|
|
7261
7200
|
}
|
|
7262
|
-
const i = J.get(t), o =
|
|
7201
|
+
const i = J.get(t), o = ma(
|
|
7263
7202
|
e,
|
|
7264
7203
|
t,
|
|
7265
7204
|
r,
|
|
@@ -7269,17 +7208,17 @@ async function Qt(e, t) {
|
|
|
7269
7208
|
s.get(n).reinitializeElementData(o);
|
|
7270
7209
|
return;
|
|
7271
7210
|
} else
|
|
7272
|
-
s.set(n, new
|
|
7211
|
+
s.set(n, new la(o));
|
|
7273
7212
|
i.get(n) === void 0 && r.defaultData !== void 0 && i.set(
|
|
7274
7213
|
n,
|
|
7275
7214
|
r.defaultData instanceof Function ? r.defaultData(e) : r.defaultData
|
|
7276
7215
|
), (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;}`);
|
|
7277
7216
|
}
|
|
7278
|
-
function
|
|
7279
|
-
if (!(t && Object.keys(
|
|
7217
|
+
function Da(e, { ignoreIfAlreadySetup: t } = {}) {
|
|
7218
|
+
if (!(t && Object.keys($ || {}).some(
|
|
7280
7219
|
(n) => {
|
|
7281
7220
|
var s;
|
|
7282
|
-
return (s =
|
|
7221
|
+
return (s = $.get(n)) == null ? void 0 : s.has(e.id);
|
|
7283
7222
|
}
|
|
7284
7223
|
))) {
|
|
7285
7224
|
if (!xe(e)) {
|
|
@@ -7287,33 +7226,33 @@ function Ca(e, { ignoreIfAlreadySetup: t } = {}) {
|
|
|
7287
7226
|
return;
|
|
7288
7227
|
}
|
|
7289
7228
|
Promise.all(
|
|
7290
|
-
|
|
7229
|
+
jr().filter((n) => e.hasAttribute(n)).map((n) => Qt(e, n))
|
|
7291
7230
|
);
|
|
7292
7231
|
}
|
|
7293
7232
|
}
|
|
7294
|
-
function
|
|
7233
|
+
function Ea(e) {
|
|
7295
7234
|
if (!(!e || !e.id))
|
|
7296
|
-
for (const t of Object.keys(
|
|
7297
|
-
const n =
|
|
7235
|
+
for (const t of Object.keys($)) {
|
|
7236
|
+
const n = $.get(t);
|
|
7298
7237
|
n.has(e.id) && n.delete(e.id);
|
|
7299
7238
|
}
|
|
7300
7239
|
}
|
|
7301
|
-
function
|
|
7240
|
+
function Ca(e) {
|
|
7302
7241
|
const { type: t } = e;
|
|
7303
7242
|
if (!gt.has(t)) {
|
|
7304
7243
|
console.error(`[playhtml] event "${t}" not registered.`);
|
|
7305
7244
|
return;
|
|
7306
7245
|
}
|
|
7307
|
-
|
|
7246
|
+
fa(e);
|
|
7308
7247
|
}
|
|
7309
|
-
function
|
|
7310
|
-
const n = String(
|
|
7248
|
+
function Xr(e, t) {
|
|
7249
|
+
const n = String(da++);
|
|
7311
7250
|
return gt.set(e, [
|
|
7312
7251
|
...gt.get(e) ?? [],
|
|
7313
7252
|
{ type: e, ...t, id: n }
|
|
7314
7253
|
]), n;
|
|
7315
7254
|
}
|
|
7316
|
-
function
|
|
7255
|
+
function Aa(e, t) {
|
|
7317
7256
|
const n = gt.get(e);
|
|
7318
7257
|
if (!n)
|
|
7319
7258
|
return;
|
|
@@ -7321,5 +7260,5 @@ function va(e, t) {
|
|
|
7321
7260
|
s !== -1 && (n.splice(s, 1), n.length === 0 && gt.delete(e));
|
|
7322
7261
|
}
|
|
7323
7262
|
export {
|
|
7324
|
-
|
|
7263
|
+
Sa as playhtml
|
|
7325
7264
|
};
|