@gamention/pulse-core 0.3.1 → 0.3.3
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.
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
var Zs = Object.defineProperty;
|
|
2
2
|
var Qs = (n, t, e) => t in n ? Zs(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
-
var
|
|
3
|
+
var y = (n, t, e) => Qs(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import { Emitter as Ye } from "./pulse-core.js";
|
|
5
5
|
class tr extends Ye {
|
|
6
|
-
constructor(e, s, r) {
|
|
6
|
+
constructor(e, s, r, i) {
|
|
7
7
|
super();
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
this
|
|
8
|
+
y(this, "peers", /* @__PURE__ */ new Map());
|
|
9
|
+
y(this, "iceServers");
|
|
10
|
+
y(this, "meshLimit");
|
|
11
|
+
y(this, "localUserId");
|
|
12
|
+
y(this, "sendSignal");
|
|
13
|
+
this.iceServers = e, this.meshLimit = s, this.localUserId = r, this.sendSignal = i;
|
|
13
14
|
}
|
|
14
15
|
get peerStates() {
|
|
15
16
|
var s;
|
|
@@ -33,6 +34,8 @@ class tr extends Ye {
|
|
|
33
34
|
this.emit("peer:fallback", e);
|
|
34
35
|
return;
|
|
35
36
|
}
|
|
37
|
+
if (this.localUserId > e)
|
|
38
|
+
return;
|
|
36
39
|
const s = this.createPeerConnection(e), r = this.peers.get(e);
|
|
37
40
|
r.crdtChannel = s.createDataChannel("crdt", { ordered: !0 }), r.rawChannel = s.createDataChannel("raw", { ordered: !1 }), this.setupDataChannelHandlers(e, r.crdtChannel, "crdt"), this.setupDataChannelHandlers(e, r.rawChannel, "raw");
|
|
38
41
|
const i = await s.createOffer();
|
|
@@ -256,7 +259,7 @@ const fe = () => new Rt(), yr = (n) => {
|
|
|
256
259
|
}, E = (n, t) => {
|
|
257
260
|
const e = n.cbuf.length;
|
|
258
261
|
n.cpos === e && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(e * 2), n.cpos = 0), n.cbuf[n.cpos++] = t;
|
|
259
|
-
}, Fe = E,
|
|
262
|
+
}, Fe = E, m = (n, t) => {
|
|
260
263
|
for (; t > Z; )
|
|
261
264
|
E(n, T | Z & t), t = F(t / 128);
|
|
262
265
|
E(n, Z & t);
|
|
@@ -267,14 +270,14 @@ const fe = () => new Rt(), yr = (n) => {
|
|
|
267
270
|
}, Be = new Uint8Array(3e4), kr = Be.length / 3, br = (n, t) => {
|
|
268
271
|
if (t.length < kr) {
|
|
269
272
|
const e = It.encodeInto(t, Be).written || 0;
|
|
270
|
-
|
|
273
|
+
m(n, e);
|
|
271
274
|
for (let s = 0; s < e; s++)
|
|
272
275
|
E(n, Be[s]);
|
|
273
276
|
} else
|
|
274
277
|
x(n, pr(t));
|
|
275
278
|
}, Sr = (n, t) => {
|
|
276
279
|
const e = unescape(encodeURIComponent(t)), s = e.length;
|
|
277
|
-
|
|
280
|
+
m(n, s);
|
|
278
281
|
for (let r = 0; r < s; r++)
|
|
279
282
|
E(
|
|
280
283
|
n,
|
|
@@ -286,7 +289,7 @@ It.encodeInto ? br : Sr, ge = (n, t) => {
|
|
|
286
289
|
const e = n.cbuf.length, s = n.cpos, r = zn(e - s, t.length), i = t.length - r;
|
|
287
290
|
n.cbuf.set(t.subarray(0, r), s), n.cpos += r, i > 0 && (n.bufs.push(n.cbuf), n.cbuf = new Uint8Array(st(e * 2, i)), n.cbuf.set(t.subarray(r)), n.cpos = i);
|
|
288
291
|
}, x = (n, t) => {
|
|
289
|
-
|
|
292
|
+
m(n, t.byteLength), ge(n, t);
|
|
290
293
|
}, Xe = (n, t) => {
|
|
291
294
|
mr(n, t);
|
|
292
295
|
const e = new DataView(n.cbuf.buffer, n.cpos, t);
|
|
@@ -309,7 +312,7 @@ It.encodeInto ? br : Sr, ge = (n, t) => {
|
|
|
309
312
|
if (t === null)
|
|
310
313
|
E(n, 126);
|
|
311
314
|
else if (ue(t)) {
|
|
312
|
-
E(n, 117),
|
|
315
|
+
E(n, 117), m(n, t.length);
|
|
313
316
|
for (let e = 0; e < t.length; e++)
|
|
314
317
|
Ot(n, t[e]);
|
|
315
318
|
} else if (t instanceof Uint8Array)
|
|
@@ -317,7 +320,7 @@ It.encodeInto ? br : Sr, ge = (n, t) => {
|
|
|
317
320
|
else {
|
|
318
321
|
E(n, 118);
|
|
319
322
|
const e = Object.keys(t);
|
|
320
|
-
|
|
323
|
+
m(n, e.length);
|
|
321
324
|
for (let s = 0; s < e.length; s++) {
|
|
322
325
|
const r = e[s];
|
|
323
326
|
lt(n, r), Ot(n, t[r]);
|
|
@@ -342,11 +345,11 @@ class Cn extends Rt {
|
|
|
342
345
|
* @param {T} v
|
|
343
346
|
*/
|
|
344
347
|
write(t) {
|
|
345
|
-
this.s === t ? this.count++ : (this.count > 0 &&
|
|
348
|
+
this.s === t ? this.count++ : (this.count > 0 && m(this, this.count - 1), this.count = 1, this.w(this, t), this.s = t);
|
|
346
349
|
}
|
|
347
350
|
}
|
|
348
351
|
const En = (n) => {
|
|
349
|
-
n.count > 0 && (We(n.encoder, n.count === 1 ? n.s : -n.s), n.count > 1 &&
|
|
352
|
+
n.count > 0 && (We(n.encoder, n.count === 1 ? n.s : -n.s), n.count > 1 && m(n.encoder, n.count - 2));
|
|
350
353
|
};
|
|
351
354
|
class Pt {
|
|
352
355
|
constructor() {
|
|
@@ -370,7 +373,7 @@ class Pt {
|
|
|
370
373
|
const Dn = (n) => {
|
|
371
374
|
if (n.count > 0) {
|
|
372
375
|
const t = n.diff * 2 + (n.count === 1 ? 0 : 1);
|
|
373
|
-
We(n.encoder, t), n.count > 1 &&
|
|
376
|
+
We(n.encoder, t), n.count > 1 && m(n.encoder, n.count - 2);
|
|
374
377
|
}
|
|
375
378
|
};
|
|
376
379
|
class Me {
|
|
@@ -881,7 +884,7 @@ class M {
|
|
|
881
884
|
* union). By default, the more objects are added, the the fewer objects this schema will accept.
|
|
882
885
|
* @protected
|
|
883
886
|
*/
|
|
884
|
-
|
|
887
|
+
y(M, "_dilutes", !1);
|
|
885
888
|
class nn extends M {
|
|
886
889
|
/**
|
|
887
890
|
* @param {C} c
|
|
@@ -1036,7 +1039,7 @@ const ae = class ae extends M {
|
|
|
1036
1039
|
});
|
|
1037
1040
|
}
|
|
1038
1041
|
};
|
|
1039
|
-
|
|
1042
|
+
y(ae, "_dilutes", !0);
|
|
1040
1043
|
let Qt = ae;
|
|
1041
1044
|
const fi = (n) => (
|
|
1042
1045
|
/** @type {any} */
|
|
@@ -1182,7 +1185,7 @@ class me extends M {
|
|
|
1182
1185
|
return e == null || e.extend(null, "Union", typeof t), s;
|
|
1183
1186
|
}
|
|
1184
1187
|
}
|
|
1185
|
-
|
|
1188
|
+
y(me, "_dilutes", !0);
|
|
1186
1189
|
const St = (...n) => n.findIndex((t) => te.check(t)) >= 0 ? St(...n.map((t) => Tt(t)).map((t) => te.check(t) ? t.shape : [t]).flat(1)) : n.length === 1 ? n[0] : new me(n), te = (
|
|
1187
1190
|
/** @type {Schema<$Union<any>>} */
|
|
1188
1191
|
S(me)
|
|
@@ -1531,10 +1534,10 @@ const bs = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
1531
1534
|
r.length > 0 && t.clients.set(s, r);
|
|
1532
1535
|
}), t;
|
|
1533
1536
|
}, _t = (n, t) => {
|
|
1534
|
-
|
|
1535
|
-
n.resetDsCurVal(),
|
|
1537
|
+
m(n.restEncoder, t.clients.size), Q(t.clients.entries()).sort((e, s) => s[0] - e[0]).forEach(([e, s]) => {
|
|
1538
|
+
n.resetDsCurVal(), m(n.restEncoder, e);
|
|
1536
1539
|
const r = s.length;
|
|
1537
|
-
|
|
1540
|
+
m(n.restEncoder, r);
|
|
1538
1541
|
for (let i = 0; i < r; i++) {
|
|
1539
1542
|
const o = s[i];
|
|
1540
1543
|
n.writeDsClock(o.clock), n.writeDsLen(o.len);
|
|
@@ -1573,7 +1576,7 @@ const bs = (n, t, e) => t.clients.forEach((s, r) => {
|
|
|
1573
1576
|
}
|
|
1574
1577
|
if (s.clients.size > 0) {
|
|
1575
1578
|
const i = new tt();
|
|
1576
|
-
return
|
|
1579
|
+
return m(i.restEncoder, 0), _t(i, s), i.toUint8Array();
|
|
1577
1580
|
}
|
|
1578
1581
|
return null;
|
|
1579
1582
|
}, _s = Yn;
|
|
@@ -2024,13 +2027,13 @@ class to {
|
|
|
2024
2027
|
* @param {number} clock
|
|
2025
2028
|
*/
|
|
2026
2029
|
writeDsClock(t) {
|
|
2027
|
-
|
|
2030
|
+
m(this.restEncoder, t);
|
|
2028
2031
|
}
|
|
2029
2032
|
/**
|
|
2030
2033
|
* @param {number} len
|
|
2031
2034
|
*/
|
|
2032
2035
|
writeDsLen(t) {
|
|
2033
|
-
|
|
2036
|
+
m(this.restEncoder, t);
|
|
2034
2037
|
}
|
|
2035
2038
|
}
|
|
2036
2039
|
class jt extends to {
|
|
@@ -2038,20 +2041,20 @@ class jt extends to {
|
|
|
2038
2041
|
* @param {ID} id
|
|
2039
2042
|
*/
|
|
2040
2043
|
writeLeftID(t) {
|
|
2041
|
-
|
|
2044
|
+
m(this.restEncoder, t.client), m(this.restEncoder, t.clock);
|
|
2042
2045
|
}
|
|
2043
2046
|
/**
|
|
2044
2047
|
* @param {ID} id
|
|
2045
2048
|
*/
|
|
2046
2049
|
writeRightID(t) {
|
|
2047
|
-
|
|
2050
|
+
m(this.restEncoder, t.client), m(this.restEncoder, t.clock);
|
|
2048
2051
|
}
|
|
2049
2052
|
/**
|
|
2050
2053
|
* Use writeClient and writeClock instead of writeID if possible.
|
|
2051
2054
|
* @param {number} client
|
|
2052
2055
|
*/
|
|
2053
2056
|
writeClient(t) {
|
|
2054
|
-
|
|
2057
|
+
m(this.restEncoder, t);
|
|
2055
2058
|
}
|
|
2056
2059
|
/**
|
|
2057
2060
|
* @param {number} info An unsigned 8-bit integer
|
|
@@ -2069,13 +2072,13 @@ class jt extends to {
|
|
|
2069
2072
|
* @param {boolean} isYKey
|
|
2070
2073
|
*/
|
|
2071
2074
|
writeParentInfo(t) {
|
|
2072
|
-
|
|
2075
|
+
m(this.restEncoder, t ? 1 : 0);
|
|
2073
2076
|
}
|
|
2074
2077
|
/**
|
|
2075
2078
|
* @param {number} info An unsigned 8-bit integer
|
|
2076
2079
|
*/
|
|
2077
2080
|
writeTypeRef(t) {
|
|
2078
|
-
|
|
2081
|
+
m(this.restEncoder, t);
|
|
2079
2082
|
}
|
|
2080
2083
|
/**
|
|
2081
2084
|
* Write len of a struct - well suited for Opt RLE encoder.
|
|
@@ -2083,7 +2086,7 @@ class jt extends to {
|
|
|
2083
2086
|
* @param {number} len
|
|
2084
2087
|
*/
|
|
2085
2088
|
writeLen(t) {
|
|
2086
|
-
|
|
2089
|
+
m(this.restEncoder, t);
|
|
2087
2090
|
}
|
|
2088
2091
|
/**
|
|
2089
2092
|
* @param {any} any
|
|
@@ -2125,13 +2128,13 @@ class eo {
|
|
|
2125
2128
|
*/
|
|
2126
2129
|
writeDsClock(t) {
|
|
2127
2130
|
const e = t - this.dsCurrVal;
|
|
2128
|
-
this.dsCurrVal = t,
|
|
2131
|
+
this.dsCurrVal = t, m(this.restEncoder, e);
|
|
2129
2132
|
}
|
|
2130
2133
|
/**
|
|
2131
2134
|
* @param {number} len
|
|
2132
2135
|
*/
|
|
2133
2136
|
writeDsLen(t) {
|
|
2134
|
-
t === 0 && N(),
|
|
2137
|
+
t === 0 && N(), m(this.restEncoder, t - 1), this.dsCurrVal += t;
|
|
2135
2138
|
}
|
|
2136
2139
|
}
|
|
2137
2140
|
class tt extends eo {
|
|
@@ -2140,7 +2143,7 @@ class tt extends eo {
|
|
|
2140
2143
|
}
|
|
2141
2144
|
toUint8Array() {
|
|
2142
2145
|
const t = fe();
|
|
2143
|
-
return
|
|
2146
|
+
return m(t, 0), x(t, this.keyClockEncoder.toUint8Array()), x(t, this.clientEncoder.toUint8Array()), x(t, this.leftClockEncoder.toUint8Array()), x(t, this.rightClockEncoder.toUint8Array()), x(t, j(this.infoEncoder)), x(t, this.stringEncoder.toUint8Array()), x(t, j(this.parentInfoEncoder)), x(t, this.typeRefEncoder.toUint8Array()), x(t, this.lenEncoder.toUint8Array()), ge(t, j(this.restEncoder)), j(t);
|
|
2144
2147
|
}
|
|
2145
2148
|
/**
|
|
2146
2149
|
* @param {ID} id
|
|
@@ -2230,7 +2233,7 @@ class tt extends eo {
|
|
|
2230
2233
|
const no = (n, t, e, s) => {
|
|
2231
2234
|
s = st(s, t[0].id.clock);
|
|
2232
2235
|
const r = J(t, s);
|
|
2233
|
-
|
|
2236
|
+
m(n.restEncoder, t.length - r), n.writeClient(e), m(n.restEncoder, s);
|
|
2234
2237
|
const i = t[r];
|
|
2235
2238
|
i.write(n, s - i.id.clock);
|
|
2236
2239
|
for (let o = r + 1; o < t.length; o++)
|
|
@@ -2241,7 +2244,7 @@ const no = (n, t, e, s) => {
|
|
|
2241
2244
|
D(t, i) > r && s.set(i, r);
|
|
2242
2245
|
}), an(t).forEach((r, i) => {
|
|
2243
2246
|
e.has(i) || s.set(i, 0);
|
|
2244
|
-
}),
|
|
2247
|
+
}), m(n.restEncoder, s.size), Q(s.entries()).sort((r, i) => i[0] - r[0]).forEach(([r, i]) => {
|
|
2245
2248
|
no(
|
|
2246
2249
|
n,
|
|
2247
2250
|
/** @type {Array<GC|Item>} */
|
|
@@ -2317,8 +2320,8 @@ const no = (n, t, e, s) => {
|
|
|
2317
2320
|
if (o === null)
|
|
2318
2321
|
return null;
|
|
2319
2322
|
const c = new Os(), l = /* @__PURE__ */ new Map(), h = (f, g) => {
|
|
2320
|
-
const
|
|
2321
|
-
(
|
|
2323
|
+
const k = l.get(f);
|
|
2324
|
+
(k == null || k > g) && l.set(f, g);
|
|
2322
2325
|
};
|
|
2323
2326
|
let a = (
|
|
2324
2327
|
/** @type {any} */
|
|
@@ -2329,8 +2332,8 @@ const no = (n, t, e, s) => {
|
|
|
2329
2332
|
);
|
|
2330
2333
|
const u = /* @__PURE__ */ new Map(), d = () => {
|
|
2331
2334
|
for (const f of s) {
|
|
2332
|
-
const g = f.id.client,
|
|
2333
|
-
|
|
2335
|
+
const g = f.id.client, k = e.get(g);
|
|
2336
|
+
k ? (k.i--, c.clients.set(g, k.refs.slice(k.i)), e.delete(g), k.i = 0, k.refs = []) : c.clients.set(g, [f]), r = r.filter((it) => it !== g);
|
|
2334
2337
|
}
|
|
2335
2338
|
s.length = 0;
|
|
2336
2339
|
};
|
|
@@ -2340,18 +2343,18 @@ const no = (n, t, e, s) => {
|
|
|
2340
2343
|
if (g < 0)
|
|
2341
2344
|
s.push(a), h(a.id.client, a.id.clock - 1), d();
|
|
2342
2345
|
else {
|
|
2343
|
-
const
|
|
2344
|
-
if (
|
|
2346
|
+
const k = a.getMissing(n, t);
|
|
2347
|
+
if (k !== null) {
|
|
2345
2348
|
s.push(a);
|
|
2346
2349
|
const it = e.get(
|
|
2347
2350
|
/** @type {number} */
|
|
2348
|
-
|
|
2351
|
+
k
|
|
2349
2352
|
) || { refs: [], i: 0 };
|
|
2350
2353
|
if (it.refs.length === it.i)
|
|
2351
2354
|
h(
|
|
2352
2355
|
/** @type {number} */
|
|
2353
|
-
|
|
2354
|
-
D(t,
|
|
2356
|
+
k,
|
|
2357
|
+
D(t, k)
|
|
2355
2358
|
), d();
|
|
2356
2359
|
else {
|
|
2357
2360
|
a = it.refs[it.i++];
|
|
@@ -2375,7 +2378,7 @@ const no = (n, t, e, s) => {
|
|
|
2375
2378
|
}
|
|
2376
2379
|
if (c.clients.size > 0) {
|
|
2377
2380
|
const f = new tt();
|
|
2378
|
-
return hn(f, c, /* @__PURE__ */ new Map()),
|
|
2381
|
+
return hn(f, c, /* @__PURE__ */ new Map()), m(f.restEncoder, 0), { missing: l, update: f.toUint8Array() };
|
|
2379
2382
|
}
|
|
2380
2383
|
return null;
|
|
2381
2384
|
}, io = (n, t) => hn(n, t.doc.store, t.beforeState), oo = (n, t, e, s = new wt(n)) => b(t, (r) => {
|
|
@@ -2629,8 +2632,8 @@ const Rn = (n, t) => t.deleteSet.clients.size === 0 && !nr(t.afterState, (e, s)
|
|
|
2629
2632
|
/** @type {Array<GC|Item>} */
|
|
2630
2633
|
r.clients.get(u)
|
|
2631
2634
|
), g = st(J(f, d), 1);
|
|
2632
|
-
for (let
|
|
2633
|
-
|
|
2635
|
+
for (let k = f.length - 1; k >= g; )
|
|
2636
|
+
k -= 1 + Wt(f, k);
|
|
2634
2637
|
}
|
|
2635
2638
|
});
|
|
2636
2639
|
for (let a = o.length - 1; a >= 0; a--) {
|
|
@@ -2834,14 +2837,14 @@ const bo = (n) => se(n, Es, jt), So = (n, t) => {
|
|
|
2834
2837
|
}, Ts = (n) => {
|
|
2835
2838
|
n.written > 0 && (n.clientStructs.push({ written: n.written, restEncoder: j(n.encoder.restEncoder) }), n.encoder.restEncoder = fe(), n.written = 0);
|
|
2836
2839
|
}, K = (n, t, e) => {
|
|
2837
|
-
n.written > 0 && n.currClient !== t.id.client && Ts(n), n.written === 0 && (n.currClient = t.id.client, n.encoder.writeClient(t.id.client),
|
|
2840
|
+
n.written > 0 && n.currClient !== t.id.client && Ts(n), n.written === 0 && (n.currClient = t.id.client, n.encoder.writeClient(t.id.client), m(n.encoder.restEncoder, t.id.clock + e)), t.write(n.encoder, e), n.written++;
|
|
2838
2841
|
}, fn = (n) => {
|
|
2839
2842
|
Ts(n);
|
|
2840
2843
|
const t = n.encoder.restEncoder;
|
|
2841
|
-
|
|
2844
|
+
m(t, n.clientStructs.length);
|
|
2842
2845
|
for (let e = 0; e < n.clientStructs.length; e++) {
|
|
2843
2846
|
const s = n.clientStructs[e];
|
|
2844
|
-
|
|
2847
|
+
m(t, s.written), ge(t, s.restEncoder);
|
|
2845
2848
|
}
|
|
2846
2849
|
}, Co = (n, t, e, s) => {
|
|
2847
2850
|
const r = new e(bt(n)), i = new un(r, !1), o = new s(), c = new dn(o);
|
|
@@ -4158,8 +4161,8 @@ class jo extends Ce {
|
|
|
4158
4161
|
u > 0 && (f = { delete: u }), u = 0;
|
|
4159
4162
|
break;
|
|
4160
4163
|
case "insert":
|
|
4161
|
-
(typeof h == "object" || h.length > 0) && (f = { insert: h }, r.size > 0 && (f.attributes = {}, r.forEach((g,
|
|
4162
|
-
g !== null && (f.attributes[
|
|
4164
|
+
(typeof h == "object" || h.length > 0) && (f = { insert: h }, r.size > 0 && (f.attributes = {}, r.forEach((g, k) => {
|
|
4165
|
+
g !== null && (f.attributes[k] = g);
|
|
4163
4166
|
}))), h = "";
|
|
4164
4167
|
break;
|
|
4165
4168
|
case "retain":
|
|
@@ -4186,17 +4189,17 @@ class jo extends Ce {
|
|
|
4186
4189
|
);
|
|
4187
4190
|
if (this.adds(o)) {
|
|
4188
4191
|
if (!this.deletes(o)) {
|
|
4189
|
-
const
|
|
4190
|
-
W(
|
|
4192
|
+
const k = r.get(f) ?? null;
|
|
4193
|
+
W(k, g) ? g !== null && o.delete(s) : (c === "retain" && d(), W(g, i.get(f) ?? null) ? delete l[f] : l[f] = g);
|
|
4191
4194
|
}
|
|
4192
4195
|
} else if (this.deletes(o)) {
|
|
4193
4196
|
i.set(f, g);
|
|
4194
|
-
const
|
|
4195
|
-
W(
|
|
4197
|
+
const k = r.get(f) ?? null;
|
|
4198
|
+
W(k, g) || (c === "retain" && d(), l[f] = k);
|
|
4196
4199
|
} else if (!o.deleted) {
|
|
4197
4200
|
i.set(f, g);
|
|
4198
|
-
const
|
|
4199
|
-
|
|
4201
|
+
const k = l[f];
|
|
4202
|
+
k !== void 0 && (W(k, g) ? k !== null && o.delete(s) : (c === "retain" && d(), g === null ? delete l[f] : l[f] = g));
|
|
4200
4203
|
}
|
|
4201
4204
|
o.deleted || (c === "insert" && d(), Et(
|
|
4202
4205
|
r,
|
|
@@ -4342,8 +4345,8 @@ class mt extends I {
|
|
|
4342
4345
|
if (c.length > 0) {
|
|
4343
4346
|
const u = {};
|
|
4344
4347
|
let d = !1;
|
|
4345
|
-
i.forEach((g,
|
|
4346
|
-
d = !0, u[
|
|
4348
|
+
i.forEach((g, k) => {
|
|
4349
|
+
d = !0, u[k] = g;
|
|
4347
4350
|
});
|
|
4348
4351
|
const f = { insert: c };
|
|
4349
4352
|
d && (f.attributes = u), r.push(f), c = "";
|
|
@@ -6324,7 +6327,7 @@ class U extends yn {
|
|
|
6324
6327
|
* @param {number} offset
|
|
6325
6328
|
*/
|
|
6326
6329
|
write(t, e) {
|
|
6327
|
-
t.writeInfo(dc),
|
|
6330
|
+
t.writeInfo(dc), m(t.restEncoder, this.length - e);
|
|
6328
6331
|
}
|
|
6329
6332
|
/**
|
|
6330
6333
|
* @param {Transaction} transaction
|
|
@@ -6344,13 +6347,13 @@ Xs[qs] = !0;
|
|
|
6344
6347
|
class fc extends Ye {
|
|
6345
6348
|
constructor(e) {
|
|
6346
6349
|
super();
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6350
|
+
y(this, "doc");
|
|
6351
|
+
y(this, "config");
|
|
6352
|
+
y(this, "transport", "websocket");
|
|
6353
|
+
y(this, "persistTimer", null);
|
|
6354
|
+
y(this, "dirty", !1);
|
|
6355
|
+
y(this, "sharedObjectCount", 0);
|
|
6356
|
+
y(this, "destroyed", !1);
|
|
6354
6357
|
this.config = e, this.doc = new Ct(), this.doc.on("update", (s, r) => {
|
|
6355
6358
|
r !== "remote" && (this.dirty = !0, this.broadcastUpdate(s));
|
|
6356
6359
|
}), this.persistTimer = setInterval(() => {
|
|
@@ -6445,9 +6448,9 @@ class fc extends Ye {
|
|
|
6445
6448
|
}
|
|
6446
6449
|
class gc {
|
|
6447
6450
|
constructor(t) {
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6451
|
+
y(this, "ymap");
|
|
6452
|
+
y(this, "listeners", /* @__PURE__ */ new Set());
|
|
6453
|
+
y(this, "observer");
|
|
6451
6454
|
this.ymap = t, this.observer = (e) => {
|
|
6452
6455
|
const s = [];
|
|
6453
6456
|
if (e.changes.keys.forEach((r, i) => {
|
|
@@ -6505,9 +6508,9 @@ class gc {
|
|
|
6505
6508
|
}
|
|
6506
6509
|
class pc {
|
|
6507
6510
|
constructor(t) {
|
|
6508
|
-
|
|
6509
|
-
|
|
6510
|
-
|
|
6511
|
+
y(this, "yarray");
|
|
6512
|
+
y(this, "listeners", /* @__PURE__ */ new Set());
|
|
6513
|
+
y(this, "observer");
|
|
6511
6514
|
this.yarray = t, this.observer = (e) => {
|
|
6512
6515
|
const s = [];
|
|
6513
6516
|
let r = 0;
|
|
@@ -6562,10 +6565,10 @@ class pc {
|
|
|
6562
6565
|
}
|
|
6563
6566
|
class wc {
|
|
6564
6567
|
constructor(t, e) {
|
|
6565
|
-
|
|
6566
|
-
|
|
6567
|
-
|
|
6568
|
-
|
|
6568
|
+
y(this, "ymap");
|
|
6569
|
+
y(this, "clientKey");
|
|
6570
|
+
y(this, "listeners", /* @__PURE__ */ new Set());
|
|
6571
|
+
y(this, "observer");
|
|
6569
6572
|
this.ymap = t, this.clientKey = e, this.observer = () => {
|
|
6570
6573
|
const s = this.value;
|
|
6571
6574
|
for (const r of this.listeners)
|
|
@@ -6595,16 +6598,17 @@ class wc {
|
|
|
6595
6598
|
class kc extends Ye {
|
|
6596
6599
|
constructor(e) {
|
|
6597
6600
|
super();
|
|
6598
|
-
|
|
6599
|
-
|
|
6600
|
-
|
|
6601
|
-
|
|
6602
|
-
|
|
6603
|
-
|
|
6604
|
-
|
|
6601
|
+
y(this, "peerManager");
|
|
6602
|
+
y(this, "syncEngine");
|
|
6603
|
+
y(this, "config");
|
|
6604
|
+
y(this, "sharedMaps", /* @__PURE__ */ new Map());
|
|
6605
|
+
y(this, "sharedLists", /* @__PURE__ */ new Map());
|
|
6606
|
+
y(this, "sharedCounters", /* @__PURE__ */ new Map());
|
|
6607
|
+
y(this, "destroyed", !1);
|
|
6605
6608
|
this.config = e, this.peerManager = new tr(
|
|
6606
6609
|
e.iceServers,
|
|
6607
6610
|
e.p2pConfig.meshLimit,
|
|
6611
|
+
e.userId,
|
|
6608
6612
|
(s) => e.sendWS(s)
|
|
6609
6613
|
), this.syncEngine = new fc({
|
|
6610
6614
|
roomId: e.roomId,
|