ball2d 0.2.0 → 0.2.2
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 +14 -4
- package/dist/browser.js +649 -627
- package/dist/node.js +33 -33
- package/dist/types/player.d.ts +2 -0
- package/dist/types/room.d.ts +3 -0
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -7,7 +7,17 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
7
7
|
}, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
|
|
8
8
|
value: n,
|
|
9
9
|
enumerable: !0
|
|
10
|
-
}) : o, n)), l =
|
|
10
|
+
}) : o, n)), l = "/api/v1", u = {
|
|
11
|
+
rooms: `${l}/rooms`,
|
|
12
|
+
sdkRooms: `${l}/sdk/rooms`,
|
|
13
|
+
account: `${l}/account`,
|
|
14
|
+
accountConfig: `${l}/account/config`,
|
|
15
|
+
profile: `${l}/account/profile`,
|
|
16
|
+
notifications: `${l}/account/notifications`,
|
|
17
|
+
keys: `${l}/account/keys`,
|
|
18
|
+
signal: (e) => `${l}/rooms/${encodeURIComponent(e)}/signal`,
|
|
19
|
+
lease: (e) => `${l}/sdk/rooms/${encodeURIComponent(e)}/lease`
|
|
20
|
+
}, d = Uint8Array, f = Uint16Array, p = Int32Array, m = new d([
|
|
11
21
|
0,
|
|
12
22
|
0,
|
|
13
23
|
0,
|
|
@@ -40,7 +50,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
40
50
|
0,
|
|
41
51
|
0,
|
|
42
52
|
0
|
|
43
|
-
]),
|
|
53
|
+
]), h = new d([
|
|
44
54
|
0,
|
|
45
55
|
0,
|
|
46
56
|
0,
|
|
@@ -73,7 +83,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
73
83
|
13,
|
|
74
84
|
0,
|
|
75
85
|
0
|
|
76
|
-
]),
|
|
86
|
+
]), g = new d([
|
|
77
87
|
16,
|
|
78
88
|
17,
|
|
79
89
|
18,
|
|
@@ -93,49 +103,49 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
|
|
|
93
103
|
14,
|
|
94
104
|
1,
|
|
95
105
|
15
|
|
96
|
-
]),
|
|
97
|
-
for (var n = new
|
|
98
|
-
for (var i = new
|
|
106
|
+
]), _ = function(e, t) {
|
|
107
|
+
for (var n = new f(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
|
|
108
|
+
for (var i = new p(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
|
|
99
109
|
return {
|
|
100
110
|
b: n,
|
|
101
111
|
r: i
|
|
102
112
|
};
|
|
103
|
-
},
|
|
104
|
-
|
|
105
|
-
for (var
|
|
106
|
-
var
|
|
107
|
-
|
|
113
|
+
}, v = _(m, 2), y = v.b, b = v.r;
|
|
114
|
+
y[28] = 258, b[258] = 28;
|
|
115
|
+
for (var x = _(h, 0), S = x.b, ee = x.r, C = new f(32768), w = 0; w < 32768; ++w) {
|
|
116
|
+
var T = (w & 43690) >> 1 | (w & 21845) << 1;
|
|
117
|
+
T = (T & 52428) >> 2 | (T & 13107) << 2, T = (T & 61680) >> 4 | (T & 3855) << 4, C[w] = ((T & 65280) >> 8 | (T & 255) << 8) >> 1;
|
|
108
118
|
}
|
|
109
|
-
for (var
|
|
110
|
-
for (var r = e.length, i = 0, a = new
|
|
111
|
-
var o = new
|
|
119
|
+
for (var E = (function(e, t, n) {
|
|
120
|
+
for (var r = e.length, i = 0, a = new f(t); i < r; ++i) e[i] && ++a[e[i] - 1];
|
|
121
|
+
var o = new f(t);
|
|
112
122
|
for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
|
|
113
123
|
var s;
|
|
114
124
|
if (n) {
|
|
115
|
-
s = new
|
|
125
|
+
s = new f(1 << t);
|
|
116
126
|
var c = 15 - t;
|
|
117
|
-
for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i],
|
|
118
|
-
} else for (s = new
|
|
127
|
+
for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, p = d | (1 << u) - 1; d <= p; ++d) s[C[d] >> c] = l;
|
|
128
|
+
} else for (s = new f(r), i = 0; i < r; ++i) e[i] && (s[i] = C[o[e[i] - 1]++] >> 15 - e[i]);
|
|
119
129
|
return s;
|
|
120
|
-
}),
|
|
121
|
-
for (var
|
|
122
|
-
for (var
|
|
123
|
-
for (var
|
|
124
|
-
for (var
|
|
125
|
-
var te = /*#__PURE__*/
|
|
130
|
+
}), D = new d(288), w = 0; w < 144; ++w) D[w] = 8;
|
|
131
|
+
for (var w = 144; w < 256; ++w) D[w] = 9;
|
|
132
|
+
for (var w = 256; w < 280; ++w) D[w] = 7;
|
|
133
|
+
for (var w = 280; w < 288; ++w) D[w] = 8;
|
|
134
|
+
for (var O = new d(32), w = 0; w < 32; ++w) O[w] = 5;
|
|
135
|
+
var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__*/ E(O, 5, 0), j = /*#__PURE__*/ E(O, 5, 1), ne = function(e) {
|
|
126
136
|
for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
|
|
127
137
|
return t;
|
|
128
|
-
},
|
|
138
|
+
}, M = function(e, t, n) {
|
|
129
139
|
var r = t / 8 | 0;
|
|
130
140
|
return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
|
|
131
|
-
},
|
|
141
|
+
}, re = function(e, t) {
|
|
132
142
|
var n = t / 8 | 0;
|
|
133
143
|
return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
|
|
134
|
-
},
|
|
144
|
+
}, ie = function(e) {
|
|
135
145
|
return (e + 7) / 8 | 0;
|
|
136
|
-
},
|
|
137
|
-
return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new
|
|
138
|
-
},
|
|
146
|
+
}, ae = function(e, t, n) {
|
|
147
|
+
return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new d(e.subarray(t, n));
|
|
148
|
+
}, N = [
|
|
139
149
|
"unexpected EOF",
|
|
140
150
|
"invalid block type",
|
|
141
151
|
"invalid length/literal",
|
|
@@ -150,119 +160,119 @@ var te = /*#__PURE__*/ w(T, 9, 0), ne = /*#__PURE__*/ w(T, 9, 1), re = /*#__PURE
|
|
|
150
160
|
"filename too long",
|
|
151
161
|
"stream finishing",
|
|
152
162
|
"invalid zip data"
|
|
153
|
-
],
|
|
154
|
-
var r = Error(t ||
|
|
155
|
-
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r,
|
|
163
|
+
], P = function(e, t, n) {
|
|
164
|
+
var r = Error(t || N[e]);
|
|
165
|
+
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, P), !n) throw r;
|
|
156
166
|
return r;
|
|
157
|
-
},
|
|
167
|
+
}, F = function(e, t, n, r) {
|
|
158
168
|
var i = e.length, a = r ? r.length : 0;
|
|
159
|
-
if (!i || t.f && !t.l) return n || new
|
|
169
|
+
if (!i || t.f && !t.l) return n || new d(0);
|
|
160
170
|
var o = !n, s = o || t.i != 2, c = t.i;
|
|
161
|
-
o && (n = new
|
|
162
|
-
var
|
|
171
|
+
o && (n = new d(i * 3));
|
|
172
|
+
var l = function(e) {
|
|
163
173
|
var t = n.length;
|
|
164
174
|
if (e > t) {
|
|
165
|
-
var r = new
|
|
175
|
+
var r = new d(Math.max(t * 2, e));
|
|
166
176
|
r.set(n), n = r;
|
|
167
177
|
}
|
|
168
|
-
},
|
|
178
|
+
}, u = t.f || 0, f = t.p || 0, p = t.b || 0, _ = t.l, v = t.d, b = t.m, x = t.n, ee = i * 8;
|
|
169
179
|
do {
|
|
170
|
-
if (!
|
|
171
|
-
|
|
172
|
-
var C =
|
|
173
|
-
if (
|
|
174
|
-
var
|
|
175
|
-
if (
|
|
176
|
-
c &&
|
|
180
|
+
if (!_) {
|
|
181
|
+
u = M(e, f, 1);
|
|
182
|
+
var C = M(e, f + 1, 3);
|
|
183
|
+
if (f += 3, !C) {
|
|
184
|
+
var w = ie(f) + 4, T = e[w - 4] | e[w - 3] << 8, D = w + T;
|
|
185
|
+
if (D > i) {
|
|
186
|
+
c && P(0);
|
|
177
187
|
break;
|
|
178
188
|
}
|
|
179
|
-
s &&
|
|
189
|
+
s && l(p + T), n.set(e.subarray(w, D), p), t.b = p += T, t.p = f = D * 8, t.f = u;
|
|
180
190
|
continue;
|
|
181
191
|
}
|
|
182
|
-
if (C == 1)
|
|
192
|
+
if (C == 1) _ = k, v = j, b = 9, x = 5;
|
|
183
193
|
else if (C == 2) {
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
for (var
|
|
187
|
-
|
|
188
|
-
for (var
|
|
189
|
-
var
|
|
190
|
-
|
|
191
|
-
var
|
|
192
|
-
if (
|
|
194
|
+
var O = M(e, f, 31) + 257, te = M(e, f + 10, 15) + 4, A = O + M(e, f + 5, 31) + 1;
|
|
195
|
+
f += 14;
|
|
196
|
+
for (var N = new d(A), F = new d(19), I = 0; I < te; ++I) F[g[I]] = M(e, f + I * 3, 7);
|
|
197
|
+
f += te * 3;
|
|
198
|
+
for (var L = ne(F), R = (1 << L) - 1, z = E(F, L, 1), I = 0; I < A;) {
|
|
199
|
+
var B = z[M(e, f, R)];
|
|
200
|
+
f += B & 15;
|
|
201
|
+
var w = B >> 4;
|
|
202
|
+
if (w < 16) N[I++] = w;
|
|
193
203
|
else {
|
|
194
|
-
var
|
|
195
|
-
for (
|
|
204
|
+
var V = 0, oe = 0;
|
|
205
|
+
for (w == 16 ? (oe = 3 + M(e, f, 3), f += 2, V = N[I - 1]) : w == 17 ? (oe = 3 + M(e, f, 7), f += 3) : w == 18 && (oe = 11 + M(e, f, 127), f += 7); oe--;) N[I++] = V;
|
|
196
206
|
}
|
|
197
207
|
}
|
|
198
|
-
var
|
|
199
|
-
b =
|
|
200
|
-
} else
|
|
201
|
-
if (
|
|
202
|
-
c &&
|
|
208
|
+
var se = N.subarray(0, O), H = N.subarray(O);
|
|
209
|
+
b = ne(se), x = ne(H), _ = E(se, b, 1), v = E(H, x, 1);
|
|
210
|
+
} else P(1);
|
|
211
|
+
if (f > ee) {
|
|
212
|
+
c && P(0);
|
|
203
213
|
break;
|
|
204
214
|
}
|
|
205
215
|
}
|
|
206
|
-
s &&
|
|
207
|
-
for (var U = (1 << b) - 1, W = (1 << x) - 1, G =
|
|
208
|
-
var
|
|
209
|
-
if (
|
|
210
|
-
c &&
|
|
216
|
+
s && l(p + 131072);
|
|
217
|
+
for (var U = (1 << b) - 1, W = (1 << x) - 1, G = f;; G = f) {
|
|
218
|
+
var V = _[re(e, f) & U], K = V >> 4;
|
|
219
|
+
if (f += V & 15, f > ee) {
|
|
220
|
+
c && P(0);
|
|
211
221
|
break;
|
|
212
222
|
}
|
|
213
|
-
if (
|
|
223
|
+
if (V || P(2), K < 256) n[p++] = K;
|
|
214
224
|
else if (K == 256) {
|
|
215
|
-
G =
|
|
225
|
+
G = f, _ = null;
|
|
216
226
|
break;
|
|
217
227
|
} else {
|
|
218
228
|
var q = K - 254;
|
|
219
229
|
if (K > 264) {
|
|
220
|
-
var
|
|
221
|
-
q =
|
|
230
|
+
var I = K - 257, J = m[I];
|
|
231
|
+
q = M(e, f, (1 << J) - 1) + y[I], f += J;
|
|
222
232
|
}
|
|
223
|
-
var Y =
|
|
224
|
-
Y ||
|
|
225
|
-
var H =
|
|
233
|
+
var Y = v[re(e, f) & W], X = Y >> 4;
|
|
234
|
+
Y || P(3), f += Y & 15;
|
|
235
|
+
var H = S[X];
|
|
226
236
|
if (X > 3) {
|
|
227
|
-
var J =
|
|
228
|
-
H +=
|
|
237
|
+
var J = h[X];
|
|
238
|
+
H += re(e, f) & (1 << J) - 1, f += J;
|
|
229
239
|
}
|
|
230
|
-
if (
|
|
231
|
-
c &&
|
|
240
|
+
if (f > ee) {
|
|
241
|
+
c && P(0);
|
|
232
242
|
break;
|
|
233
243
|
}
|
|
234
|
-
s &&
|
|
235
|
-
var ce =
|
|
236
|
-
if (
|
|
244
|
+
s && l(p + 131072);
|
|
245
|
+
var ce = p + q;
|
|
246
|
+
if (p < H) {
|
|
237
247
|
var Z = a - H, le = Math.min(H, ce);
|
|
238
|
-
for (Z +
|
|
248
|
+
for (Z + p < 0 && P(3); p < le; ++p) n[p] = r[Z + p];
|
|
239
249
|
}
|
|
240
|
-
for (;
|
|
250
|
+
for (; p < ce; ++p) n[p] = n[p - H];
|
|
241
251
|
}
|
|
242
252
|
}
|
|
243
|
-
t.l =
|
|
244
|
-
} while (!
|
|
245
|
-
return
|
|
246
|
-
},
|
|
253
|
+
t.l = _, t.p = G, t.b = p, t.f = u, _ && (u = 1, t.m = b, t.d = v, t.n = x);
|
|
254
|
+
} while (!u);
|
|
255
|
+
return p != n.length && o ? ae(n, 0, p) : n.subarray(0, p);
|
|
256
|
+
}, I = function(e, t, n) {
|
|
247
257
|
n <<= t & 7;
|
|
248
258
|
var r = t / 8 | 0;
|
|
249
259
|
e[r] |= n, e[r + 1] |= n >> 8;
|
|
250
|
-
},
|
|
260
|
+
}, L = function(e, t, n) {
|
|
251
261
|
n <<= t & 7;
|
|
252
262
|
var r = t / 8 | 0;
|
|
253
263
|
e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
|
|
254
|
-
},
|
|
264
|
+
}, R = function(e, t) {
|
|
255
265
|
for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
|
|
256
266
|
s: r,
|
|
257
267
|
f: e[r]
|
|
258
268
|
});
|
|
259
269
|
var i = n.length, a = n.slice();
|
|
260
270
|
if (!i) return {
|
|
261
|
-
t:
|
|
271
|
+
t: U,
|
|
262
272
|
l: 0
|
|
263
273
|
};
|
|
264
274
|
if (i == 1) {
|
|
265
|
-
var o = new
|
|
275
|
+
var o = new d(n[0].s + 1);
|
|
266
276
|
return o[n[0].s] = 1, {
|
|
267
277
|
t: o,
|
|
268
278
|
l: 1
|
|
@@ -274,48 +284,48 @@ var te = /*#__PURE__*/ w(T, 9, 0), ne = /*#__PURE__*/ w(T, 9, 1), re = /*#__PURE
|
|
|
274
284
|
s: -1,
|
|
275
285
|
f: 25001
|
|
276
286
|
});
|
|
277
|
-
var s = n[0], c = n[1],
|
|
287
|
+
var s = n[0], c = n[1], l = 0, u = 1, p = 2;
|
|
278
288
|
for (n[0] = {
|
|
279
289
|
s: -1,
|
|
280
290
|
f: s.f + c.f,
|
|
281
291
|
l: s,
|
|
282
292
|
r: c
|
|
283
|
-
};
|
|
293
|
+
}; u != i - 1;) s = n[n[l].f < n[p].f ? l++ : p++], c = n[l != u && n[l].f < n[p].f ? l++ : p++], n[u++] = {
|
|
284
294
|
s: -1,
|
|
285
295
|
f: s.f + c.f,
|
|
286
296
|
l: s,
|
|
287
297
|
r: c
|
|
288
298
|
};
|
|
289
299
|
for (var m = a[0].s, r = 1; r < i; ++r) a[r].s > m && (m = a[r].s);
|
|
290
|
-
var h = new
|
|
300
|
+
var h = new f(m + 1), g = z(n[u - 1], h, 0);
|
|
291
301
|
if (g > t) {
|
|
292
302
|
var r = 0, _ = 0, v = g - t, y = 1 << v;
|
|
293
303
|
for (a.sort(function(e, t) {
|
|
294
304
|
return h[t.s] - h[e.s] || e.f - t.f;
|
|
295
305
|
}); r < i; ++r) {
|
|
296
|
-
var
|
|
297
|
-
if (h[
|
|
306
|
+
var b = a[r].s;
|
|
307
|
+
if (h[b] > t) _ += y - (1 << g - h[b]), h[b] = t;
|
|
298
308
|
else break;
|
|
299
309
|
}
|
|
300
310
|
for (_ >>= v; _ > 0;) {
|
|
301
|
-
var
|
|
302
|
-
h[
|
|
311
|
+
var x = a[r].s;
|
|
312
|
+
h[x] < t ? _ -= 1 << t - h[x]++ - 1 : ++r;
|
|
303
313
|
}
|
|
304
314
|
for (; r >= 0 && _; --r) {
|
|
305
|
-
var
|
|
306
|
-
h[
|
|
315
|
+
var S = a[r].s;
|
|
316
|
+
h[S] == t && (--h[S], ++_);
|
|
307
317
|
}
|
|
308
318
|
g = t;
|
|
309
319
|
}
|
|
310
320
|
return {
|
|
311
|
-
t: new
|
|
321
|
+
t: new d(h),
|
|
312
322
|
l: g
|
|
313
323
|
};
|
|
314
|
-
},
|
|
315
|
-
return e.s == -1 ? Math.max(
|
|
316
|
-
},
|
|
324
|
+
}, z = function(e, t, n) {
|
|
325
|
+
return e.s == -1 ? Math.max(z(e.l, t, n + 1), z(e.r, t, n + 1)) : t[e.s] = n;
|
|
326
|
+
}, B = function(e) {
|
|
317
327
|
for (var t = e.length; t && !e[--t];);
|
|
318
|
-
for (var n = new
|
|
328
|
+
for (var n = new f(++t), r = 0, i = e[0], a = 1, o = function(e) {
|
|
319
329
|
n[r++] = e;
|
|
320
330
|
}, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
|
|
321
331
|
else {
|
|
@@ -333,44 +343,44 @@ var te = /*#__PURE__*/ w(T, 9, 0), ne = /*#__PURE__*/ w(T, 9, 1), re = /*#__PURE
|
|
|
333
343
|
c: n.subarray(0, r),
|
|
334
344
|
n: t
|
|
335
345
|
};
|
|
336
|
-
},
|
|
346
|
+
}, V = function(e, t) {
|
|
337
347
|
for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
|
|
338
348
|
return n;
|
|
339
|
-
},
|
|
340
|
-
var r = n.length, i =
|
|
349
|
+
}, oe = function(e, t, n) {
|
|
350
|
+
var r = n.length, i = ie(t + 2);
|
|
341
351
|
e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
|
|
342
352
|
for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
|
|
343
353
|
return (i + 4 + r) * 8;
|
|
344
|
-
},
|
|
345
|
-
|
|
346
|
-
for (var
|
|
347
|
-
for (var
|
|
348
|
-
for (var
|
|
349
|
-
var
|
|
350
|
-
if (c >= 0 &&
|
|
351
|
-
var
|
|
352
|
-
if (
|
|
353
|
-
|
|
354
|
-
var U =
|
|
355
|
-
|
|
356
|
-
for (var
|
|
357
|
-
|
|
358
|
-
for (var W = [
|
|
359
|
-
var q = K[
|
|
360
|
-
|
|
354
|
+
}, se = function(e, t, n, r, i, a, o, s, c, l, u) {
|
|
355
|
+
I(t, u++, n), ++i[256];
|
|
356
|
+
for (var d = R(i, 15), p = d.t, _ = d.l, v = R(a, 15), y = v.t, b = v.l, x = B(p), S = x.c, ee = x.n, C = B(y), w = C.c, T = C.n, k = new f(19), j = 0; j < S.length; ++j) ++k[S[j] & 31];
|
|
357
|
+
for (var j = 0; j < w.length; ++j) ++k[w[j] & 31];
|
|
358
|
+
for (var ne = R(k, 7), M = ne.t, re = ne.l, ie = 19; ie > 4 && !M[g[ie - 1]]; --ie);
|
|
359
|
+
var ae = l + 5 << 3, N = V(i, D) + V(a, O) + o, P = V(i, p) + V(a, y) + o + 14 + 3 * ie + V(k, M) + 2 * k[16] + 3 * k[17] + 7 * k[18];
|
|
360
|
+
if (c >= 0 && ae <= N && ae <= P) return oe(t, u, e.subarray(c, c + l));
|
|
361
|
+
var F, z, se, H;
|
|
362
|
+
if (I(t, u, 1 + (P < N)), u += 2, P < N) {
|
|
363
|
+
F = E(p, _, 0), z = p, se = E(y, b, 0), H = y;
|
|
364
|
+
var U = E(M, re, 0);
|
|
365
|
+
I(t, u, ee - 257), I(t, u + 5, T - 1), I(t, u + 10, ie - 4), u += 14;
|
|
366
|
+
for (var j = 0; j < ie; ++j) I(t, u + 3 * j, M[g[j]]);
|
|
367
|
+
u += 3 * ie;
|
|
368
|
+
for (var W = [S, w], G = 0; G < 2; ++G) for (var K = W[G], j = 0; j < K.length; ++j) {
|
|
369
|
+
var q = K[j] & 31;
|
|
370
|
+
I(t, u, U[q]), u += M[q], q > 15 && (I(t, u, K[j] >> 5 & 127), u += K[j] >> 12);
|
|
361
371
|
}
|
|
362
|
-
} else
|
|
363
|
-
for (var
|
|
364
|
-
var J = r[
|
|
372
|
+
} else F = te, z = D, se = A, H = O;
|
|
373
|
+
for (var j = 0; j < s; ++j) {
|
|
374
|
+
var J = r[j];
|
|
365
375
|
if (J > 255) {
|
|
366
376
|
var q = J >> 18 & 31;
|
|
367
|
-
|
|
377
|
+
L(t, u, F[q + 257]), u += z[q + 257], q > 7 && (I(t, u, J >> 23 & 31), u += m[q]);
|
|
368
378
|
var Y = J & 31;
|
|
369
|
-
|
|
370
|
-
} else
|
|
379
|
+
L(t, u, se[Y]), u += H[Y], Y > 3 && (L(t, u, J >> 5 & 8191), u += h[Y]);
|
|
380
|
+
} else L(t, u, F[J]), u += z[J];
|
|
371
381
|
}
|
|
372
|
-
return
|
|
373
|
-
},
|
|
382
|
+
return L(t, u, F[256]), u + z[256];
|
|
383
|
+
}, H = /*#__PURE__*/ new p([
|
|
374
384
|
65540,
|
|
375
385
|
131080,
|
|
376
386
|
131088,
|
|
@@ -380,96 +390,96 @@ var te = /*#__PURE__*/ w(T, 9, 0), ne = /*#__PURE__*/ w(T, 9, 1), re = /*#__PURE
|
|
|
380
390
|
1048832,
|
|
381
391
|
2114560,
|
|
382
392
|
2117632
|
|
383
|
-
]),
|
|
384
|
-
var o = a.z || e.length, s = new
|
|
393
|
+
]), U = /*#__PURE__*/ new d(0), W = function(e, t, n, r, i, a) {
|
|
394
|
+
var o = a.z || e.length, s = new d(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
|
|
385
395
|
if (t) {
|
|
386
|
-
|
|
387
|
-
for (var g =
|
|
388
|
-
return (e[t] ^ e[t + 1] << C ^ e[t + 2] << w) &
|
|
389
|
-
}, E = new
|
|
390
|
-
var
|
|
391
|
-
if (x[
|
|
392
|
-
var
|
|
393
|
-
if ((
|
|
394
|
-
|
|
395
|
-
for (var
|
|
396
|
-
for (var
|
|
396
|
+
u && (c[0] = a.r >> 3);
|
|
397
|
+
for (var g = H[t - 1], _ = g >> 13, v = g & 8191, y = (1 << n) - 1, x = a.p || new f(32768), S = a.h || new f(y + 1), C = Math.ceil(n / 3), w = 2 * C, T = function(t) {
|
|
398
|
+
return (e[t] ^ e[t + 1] << C ^ e[t + 2] << w) & y;
|
|
399
|
+
}, E = new p(25e3), D = new f(288), O = new f(32), te = 0, k = 0, A = a.i || 0, j = 0, ne = a.w || 0, M = 0; A + 2 < o; ++A) {
|
|
400
|
+
var re = T(A), N = A & 32767, P = S[re];
|
|
401
|
+
if (x[N] = P, S[re] = N, ne <= A) {
|
|
402
|
+
var F = o - A;
|
|
403
|
+
if ((te > 7e3 || j > 24576) && (F > 423 || !l)) {
|
|
404
|
+
u = se(e, c, 0, E, D, O, k, j, M, A - M, u), j = te = k = 0, M = A;
|
|
405
|
+
for (var I = 0; I < 286; ++I) D[I] = 0;
|
|
406
|
+
for (var I = 0; I < 30; ++I) O[I] = 0;
|
|
397
407
|
}
|
|
398
|
-
var
|
|
399
|
-
if (
|
|
400
|
-
if (e[
|
|
401
|
-
for (var G = 0; G < W && e[
|
|
402
|
-
if (G >
|
|
403
|
-
if (
|
|
404
|
-
for (var K = Math.min(
|
|
405
|
-
var J =
|
|
406
|
-
Y > q && (q = Y,
|
|
408
|
+
var L = 2, R = 0, z = v, B = N - P & 32767;
|
|
409
|
+
if (F > 2 && re == T(A - B)) for (var V = Math.min(_, F) - 1, U = Math.min(32767, A), W = Math.min(258, F); B <= U && --z && N != P;) {
|
|
410
|
+
if (e[A + L] == e[A + L - B]) {
|
|
411
|
+
for (var G = 0; G < W && e[A + G] == e[A + G - B]; ++G);
|
|
412
|
+
if (G > L) {
|
|
413
|
+
if (L = G, R = B, G > V) break;
|
|
414
|
+
for (var K = Math.min(B, G - 2), q = 0, I = 0; I < K; ++I) {
|
|
415
|
+
var J = A - B + I & 32767, Y = J - x[J] & 32767;
|
|
416
|
+
Y > q && (q = Y, P = J);
|
|
407
417
|
}
|
|
408
418
|
}
|
|
409
419
|
}
|
|
410
|
-
|
|
420
|
+
N = P, P = x[N], B += N - P & 32767;
|
|
411
421
|
}
|
|
412
|
-
if (
|
|
413
|
-
E[
|
|
414
|
-
var X =
|
|
415
|
-
|
|
416
|
-
} else E[
|
|
422
|
+
if (R) {
|
|
423
|
+
E[j++] = 268435456 | b[L] << 18 | ee[R];
|
|
424
|
+
var X = b[L] & 31, ce = ee[R] & 31;
|
|
425
|
+
k += m[X] + h[ce], ++D[257 + X], ++O[ce], ne = A + L, ++te;
|
|
426
|
+
} else E[j++] = e[A], ++D[e[A]];
|
|
417
427
|
}
|
|
418
428
|
}
|
|
419
|
-
for (
|
|
420
|
-
|
|
429
|
+
for (A = Math.max(A, ne); A < o; ++A) E[j++] = e[A], ++D[e[A]];
|
|
430
|
+
u = se(e, c, l, E, D, O, k, j, M, A - M, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = S, a.p = x, a.i = A, a.w = ne);
|
|
421
431
|
} else {
|
|
422
|
-
for (var
|
|
423
|
-
var Z =
|
|
424
|
-
Z >= o && (c[
|
|
432
|
+
for (var A = a.w || 0; A < o + l; A += 65535) {
|
|
433
|
+
var Z = A + 65535;
|
|
434
|
+
Z >= o && (c[u / 8 | 0] = l, Z = o), u = oe(c, u + 1, e.subarray(A, Z));
|
|
425
435
|
}
|
|
426
436
|
a.i = o;
|
|
427
437
|
}
|
|
428
|
-
return
|
|
429
|
-
},
|
|
438
|
+
return ae(s, 0, r + ie(u) + i);
|
|
439
|
+
}, G = function(e, t, n, r, i) {
|
|
430
440
|
if (!i && (i = { l: 1 }, t.dictionary)) {
|
|
431
|
-
var a = t.dictionary.subarray(-32768), o = new
|
|
441
|
+
var a = t.dictionary.subarray(-32768), o = new d(a.length + e.length);
|
|
432
442
|
o.set(a), o.set(e, a.length), e = o, i.w = a.length;
|
|
433
443
|
}
|
|
434
|
-
return
|
|
444
|
+
return W(e, t.level == null ? 6 : t.level, t.mem == null ? i.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, n, r, i);
|
|
435
445
|
};
|
|
436
|
-
function
|
|
437
|
-
return
|
|
446
|
+
function K(e, t) {
|
|
447
|
+
return G(e, t || {}, 0, 0);
|
|
438
448
|
}
|
|
439
|
-
var
|
|
449
|
+
var q = /* @__PURE__ */ function() {
|
|
440
450
|
function e(e, t) {
|
|
441
451
|
typeof e == "function" && (t = e, e = {}), this.ondata = t;
|
|
442
452
|
var n = e && e.dictionary && e.dictionary.subarray(-32768);
|
|
443
453
|
this.s = {
|
|
444
454
|
i: 0,
|
|
445
455
|
b: n ? n.length : 0
|
|
446
|
-
}, this.o = new
|
|
456
|
+
}, this.o = new d(32768), this.p = new d(0), n && this.o.set(n);
|
|
447
457
|
}
|
|
448
458
|
return e.prototype.e = function(e) {
|
|
449
|
-
if (this.ondata ||
|
|
459
|
+
if (this.ondata || P(5), this.d && P(4), !this.p.length) this.p = e;
|
|
450
460
|
else if (e.length) {
|
|
451
|
-
var t = new
|
|
461
|
+
var t = new d(this.p.length + e.length);
|
|
452
462
|
t.set(this.p), t.set(e, this.p.length), this.p = t;
|
|
453
463
|
}
|
|
454
464
|
}, e.prototype.c = function(e) {
|
|
455
465
|
this.s.i = +(this.d = e || !1);
|
|
456
|
-
var t = this.s.b, n =
|
|
457
|
-
this.ondata(
|
|
466
|
+
var t = this.s.b, n = F(this.p, this.s, this.o);
|
|
467
|
+
this.ondata(ae(n, t, this.s.b), this.d), this.o = ae(n, this.s.b - 32768), this.s.b = this.o.length, this.p = ae(this.p, this.s.p / 8 | 0), this.s.p &= 7;
|
|
458
468
|
}, e.prototype.push = function(e, t) {
|
|
459
469
|
this.e(e), this.c(t);
|
|
460
470
|
}, e;
|
|
461
|
-
}(),
|
|
471
|
+
}(), J = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
|
|
462
472
|
try {
|
|
463
|
-
|
|
473
|
+
J.decode(U, { stream: !0 });
|
|
464
474
|
} catch {}
|
|
465
|
-
var
|
|
475
|
+
var Y = 5389, X = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, ce = (e) => Number.isFinite(e) && e >= 1 && e <= 1e5, Z = class {
|
|
466
476
|
core;
|
|
467
477
|
enabled = !1;
|
|
468
478
|
constructor(e) {
|
|
469
479
|
if (this.core = e, e.surface_state_capacity() !== 5389) throw Error("Unsupported surface state version");
|
|
470
480
|
}
|
|
471
481
|
configure(e) {
|
|
472
|
-
if (!
|
|
482
|
+
if (!X(e.seed, 0, 4294967295) || !ce(e.halfWidth) || !ce(e.halfHeight) || !X(e.moisturePermille, 0, 1e3)) throw Error("Invalid surface configuration");
|
|
473
483
|
if (!this.core.surface_configure(e.seed, e.halfWidth, e.halfHeight, e.moisturePermille)) throw Error("Surface configuration rejected");
|
|
474
484
|
this.enabled = !0;
|
|
475
485
|
}
|
|
@@ -477,7 +487,7 @@ var q = 5389, J = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, Y = (e)
|
|
|
477
487
|
this.core.surface_disable(), this.enabled = !1;
|
|
478
488
|
}
|
|
479
489
|
setWeather(e) {
|
|
480
|
-
if (!
|
|
490
|
+
if (!X(e.rainMilliMmH, 0, 2e5) || !X(e.temperatureMilliC, -3e4, 6e4) || !X(e.humidityPermille, 0, 1e3) || !X(e.windMilliMS, 0, 6e4)) throw Error("Invalid surface weather");
|
|
481
491
|
if (!this.core.surface_weather(e.rainMilliMmH, e.temperatureMilliC, e.humidityPermille, e.windMilliMS)) throw Error("Surface is disabled");
|
|
482
492
|
}
|
|
483
493
|
sample(e, t) {
|
|
@@ -496,22 +506,22 @@ var q = 5389, J = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, Y = (e)
|
|
|
496
506
|
return Array.from(this.buffer());
|
|
497
507
|
}
|
|
498
508
|
restore(e) {
|
|
499
|
-
if (!Array.isArray(e) || e.length !== 0 && e.length !== 5389 || !e.every((e) =>
|
|
509
|
+
if (!Array.isArray(e) || e.length !== 0 && e.length !== 5389 || !e.every((e) => X(e, 0, 4294967295)) || (e.length && this.buffer().set(e), !this.core.surface_restore(e.length))) throw Error("Invalid surface checkpoint");
|
|
500
510
|
this.enabled = e.length > 0;
|
|
501
511
|
}
|
|
502
512
|
buffer() {
|
|
503
513
|
let e = this.core.surface_state_ptr();
|
|
504
|
-
return new Uint32Array(this.core.memory.buffer, e,
|
|
514
|
+
return new Uint32Array(this.core.memory.buffer, e, Y);
|
|
505
515
|
}
|
|
506
|
-
},
|
|
516
|
+
}, le = 131072, ue = 49152, de = new TextEncoder();
|
|
507
517
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
508
|
-
var
|
|
509
|
-
function
|
|
510
|
-
if (!
|
|
511
|
-
let n =
|
|
512
|
-
if (n.length >
|
|
513
|
-
let r =
|
|
514
|
-
if (r.length >
|
|
518
|
+
var fe = (e, t) => typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= t;
|
|
519
|
+
function pe(e, t) {
|
|
520
|
+
if (!fe(t, 65535) || !fe(e.tick, 4294967295) || !Array.isArray(e.surface) || e.surface.length !== 5389) throw Error("Invalid terrain snapshot");
|
|
521
|
+
let n = de.encode(JSON.stringify(e));
|
|
522
|
+
if (n.length > le) throw Error("Terrain snapshot exceeds size limit");
|
|
523
|
+
let r = K(n, { level: 1 });
|
|
524
|
+
if (r.length > ue) throw Error("Compressed terrain snapshot exceeds size limit");
|
|
515
525
|
let i = "";
|
|
516
526
|
for (let e of r) i += String.fromCharCode(e);
|
|
517
527
|
return {
|
|
@@ -521,7 +531,7 @@ function de(e, t) {
|
|
|
521
531
|
payload: btoa(i)
|
|
522
532
|
};
|
|
523
533
|
}
|
|
524
|
-
function
|
|
534
|
+
function me(e) {
|
|
525
535
|
let t = new AbortController(), n = () => t.abort(e?.reason);
|
|
526
536
|
e?.aborted ? n() : e?.addEventListener("abort", n, { once: !0 });
|
|
527
537
|
let r = setTimeout(() => t.abort(new DOMException("Room startup timed out", "TimeoutError")), 15e3);
|
|
@@ -543,7 +553,7 @@ function fe(e) {
|
|
|
543
553
|
}
|
|
544
554
|
};
|
|
545
555
|
}
|
|
546
|
-
var
|
|
556
|
+
var he = /* @__PURE__ */ new Set([
|
|
547
557
|
"noPlayer",
|
|
548
558
|
"playerName",
|
|
549
559
|
"roomName",
|
|
@@ -552,12 +562,12 @@ var pe = /* @__PURE__ */ new Set([
|
|
|
552
562
|
"public",
|
|
553
563
|
"stadium"
|
|
554
564
|
]);
|
|
555
|
-
function
|
|
565
|
+
function Q(e) {
|
|
556
566
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
|
|
557
567
|
for (let t of Object.keys(e)) {
|
|
558
568
|
if (t === "token") throw Error("External service tokens are not supported. Ball2D join verification is configured on the room.");
|
|
559
569
|
if (t === "geo") throw Error("Geolocation overrides are not supported. Room country comes from the host connection.");
|
|
560
|
-
if (!
|
|
570
|
+
if (!he.has(t)) throw Error(`Unknown room setting: ${t}`);
|
|
561
571
|
}
|
|
562
572
|
let t = { ...e };
|
|
563
573
|
if (typeof t.roomName != "string" || !t.roomName.trim() || t.roomName.length > 64) throw Error("Room name must contain 1–64 characters");
|
|
@@ -576,15 +586,15 @@ function me(e) {
|
|
|
576
586
|
stadium: t.stadium
|
|
577
587
|
};
|
|
578
588
|
}
|
|
579
|
-
function
|
|
589
|
+
function ge(e) {
|
|
580
590
|
return /^(?:[0-9a-f]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.test(e) ? e.toLowerCase() : null;
|
|
581
591
|
}
|
|
582
|
-
function
|
|
583
|
-
let t =
|
|
592
|
+
function _e(e) {
|
|
593
|
+
let t = ge(e);
|
|
584
594
|
if (!t) throw Error("Invalid room code");
|
|
585
595
|
return `/r/${t}`;
|
|
586
596
|
}
|
|
587
|
-
function
|
|
597
|
+
function ve(e, t, n) {
|
|
588
598
|
if (!Number.isFinite(e) || !Number.isInteger(t) || t < 0 || t > 16777215 || !Array.isArray(n) || n.length < 1 || n.length > 3 || n.some((e) => !Number.isInteger(e) || e < 0 || e > 16777215)) throw Error("Invalid team colors");
|
|
589
599
|
return {
|
|
590
600
|
angle: (e % 360 + 360) % 360,
|
|
@@ -592,12 +602,12 @@ function ge(e, t, n) {
|
|
|
592
602
|
colors: [...n]
|
|
593
603
|
};
|
|
594
604
|
}
|
|
595
|
-
function
|
|
605
|
+
function ye(e) {
|
|
596
606
|
if (e === void 0) return [null, null];
|
|
597
607
|
if (!Array.isArray(e) || e.length !== 2) throw Error("Invalid team styles");
|
|
598
|
-
return e.map((e) => e === null ? null :
|
|
608
|
+
return e.map((e) => e === null ? null : ve(e.angle, e.textColor, e.colors));
|
|
599
609
|
}
|
|
600
|
-
var
|
|
610
|
+
var be = [
|
|
601
611
|
"normal",
|
|
602
612
|
"bold",
|
|
603
613
|
"italic",
|
|
@@ -605,10 +615,10 @@ var ve = [
|
|
|
605
615
|
"small-bold",
|
|
606
616
|
"small-italic"
|
|
607
617
|
];
|
|
608
|
-
function
|
|
618
|
+
function xe(e, t, n, r) {
|
|
609
619
|
if (typeof e != "string" || e.length > 1e3) throw Error("Announcement exceeds 1000 characters");
|
|
610
620
|
if (t != null && (!Number.isInteger(t) || t < 0 || t > 16777215)) throw Error("Invalid announcement color");
|
|
611
|
-
if (n != null && !
|
|
621
|
+
if (n != null && !be.includes(n)) throw Error("Invalid announcement style");
|
|
612
622
|
if (r != null && ![
|
|
613
623
|
0,
|
|
614
624
|
1,
|
|
@@ -622,10 +632,10 @@ function ye(e, t, n, r) {
|
|
|
622
632
|
sound: r ?? 1
|
|
623
633
|
};
|
|
624
634
|
}
|
|
625
|
-
function
|
|
635
|
+
function Se(e) {
|
|
626
636
|
return e === null || typeof e == "string" && Array.from(e).length <= 2 && !/[\p{Cc}\p{Cf}]/u.test(e);
|
|
627
637
|
}
|
|
628
|
-
var
|
|
638
|
+
var Ce = [
|
|
629
639
|
[
|
|
630
640
|
"x",
|
|
631
641
|
0,
|
|
@@ -705,11 +715,11 @@ var xe = [
|
|
|
705
715
|
2147483647
|
|
706
716
|
]
|
|
707
717
|
];
|
|
708
|
-
function
|
|
718
|
+
function we(e) {
|
|
709
719
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Invalid disc property update");
|
|
710
720
|
let t = e, n = {};
|
|
711
|
-
for (let e = 0; e <
|
|
712
|
-
let [r, , i, a] =
|
|
721
|
+
for (let e = 0; e < Ce.length; e++) {
|
|
722
|
+
let [r, , i, a] = Ce[e], o = t[r];
|
|
713
723
|
if (o == null) continue;
|
|
714
724
|
if (typeof o != "number" || !Number.isFinite(o)) throw Error(`Invalid disc property: ${r}`);
|
|
715
725
|
let s = e < 10 ? Math.fround(o) : o | 0;
|
|
@@ -718,7 +728,7 @@ function Se(e) {
|
|
|
718
728
|
}
|
|
719
729
|
return n;
|
|
720
730
|
}
|
|
721
|
-
var
|
|
731
|
+
var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
|
|
722
732
|
(function(n, r) {
|
|
723
733
|
typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : n.JSON5 = r();
|
|
724
734
|
})(e, (function() {
|
|
@@ -778,9 +788,9 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
778
788
|
return e[t] = n, e;
|
|
779
789
|
}, g = {}.hasOwnProperty, _ = function(e, t) {
|
|
780
790
|
return g.call(e, t);
|
|
781
|
-
}, v = 0, y = Math.random(),
|
|
791
|
+
}, v = 0, y = Math.random(), b = function(e) {
|
|
782
792
|
return `Symbol(${e === void 0 ? "" : e})_${(++v + y).toString(36)}`;
|
|
783
|
-
},
|
|
793
|
+
}, x = e(function(e) {
|
|
784
794
|
var r = "__core-js_shared__", i = t[r] || (t[r] = {});
|
|
785
795
|
(e.exports = function(e, t) {
|
|
786
796
|
return i[e] || (i[e] = t === void 0 ? {} : t);
|
|
@@ -789,21 +799,21 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
789
799
|
mode: "global",
|
|
790
800
|
copyright: "© 2019 Denis Pushkarev (zloirock.ru)"
|
|
791
801
|
});
|
|
792
|
-
})("native-function-to-string", Function.toString),
|
|
793
|
-
var r =
|
|
802
|
+
})("native-function-to-string", Function.toString), S = e(function(e) {
|
|
803
|
+
var r = b("src"), i = "toString", a = ("" + x).split(i);
|
|
794
804
|
n.inspectSource = function(e) {
|
|
795
|
-
return
|
|
805
|
+
return x.call(e);
|
|
796
806
|
}, (e.exports = function(e, n, i, o) {
|
|
797
807
|
var s = typeof i == "function";
|
|
798
808
|
s && (_(i, "name") || h(i, "name", n)), e[n] !== i && (s && (_(i, r) || h(i, r, e[n] ? "" + e[n] : a.join(String(n)))), e === t ? e[n] = i : o ? e[n] ? e[n] = i : h(e, n, i) : (delete e[n], h(e, n, i)));
|
|
799
809
|
})(Function.prototype, i, function() {
|
|
800
|
-
return typeof this == "function" && this[r] ||
|
|
810
|
+
return typeof this == "function" && this[r] || x.call(this);
|
|
801
811
|
});
|
|
802
|
-
}),
|
|
812
|
+
}), ee = function(e) {
|
|
803
813
|
if (typeof e != "function") throw TypeError(e + " is not a function!");
|
|
804
814
|
return e;
|
|
805
815
|
}, C = function(e, t, n) {
|
|
806
|
-
if (
|
|
816
|
+
if (ee(e), t === void 0) return e;
|
|
807
817
|
switch (n) {
|
|
808
818
|
case 1: return function(n) {
|
|
809
819
|
return e.call(t, n);
|
|
@@ -820,46 +830,46 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
820
830
|
};
|
|
821
831
|
}, w = "prototype", T = function(e, r, i) {
|
|
822
832
|
var a = e & T.F, o = e & T.G, s = e & T.S, c = e & T.P, l = e & T.B, u = o ? t : s ? t[r] || (t[r] = {}) : (t[r] || {})[w], d = o ? n : n[r] || (n[r] = {}), f = d[w] || (d[w] = {}), p, m, g, _;
|
|
823
|
-
for (p in o && (i = r), i) m = !a && u && u[p] !== void 0, g = (m ? u : i)[p], _ = l && m ? C(g, t) : c && typeof g == "function" ? C(Function.call, g) : g, u &&
|
|
833
|
+
for (p in o && (i = r), i) m = !a && u && u[p] !== void 0, g = (m ? u : i)[p], _ = l && m ? C(g, t) : c && typeof g == "function" ? C(Function.call, g) : g, u && S(u, p, g, e & T.U), d[p] != g && h(d, p, _), c && f[p] != g && (f[p] = g);
|
|
824
834
|
};
|
|
825
835
|
t.core = n, T.F = 1, T.G = 2, T.S = 4, T.P = 8, T.B = 16, T.W = 32, T.U = 64, T.R = 128;
|
|
826
|
-
var E = T,
|
|
827
|
-
return isNaN(e = +e) ? 0 : (e > 0 ?
|
|
828
|
-
},
|
|
836
|
+
var E = T, D = Math.ceil, O = Math.floor, te = function(e) {
|
|
837
|
+
return isNaN(e = +e) ? 0 : (e > 0 ? O : D)(e);
|
|
838
|
+
}, k = function(e) {
|
|
829
839
|
if (e == null) throw TypeError("Can't call method on " + e);
|
|
830
840
|
return e;
|
|
831
|
-
},
|
|
841
|
+
}, A = function(e) {
|
|
832
842
|
return function(t, n) {
|
|
833
|
-
var r = String(
|
|
843
|
+
var r = String(k(t)), i = te(n), a = r.length, o, s;
|
|
834
844
|
return i < 0 || i >= a ? e ? "" : void 0 : (o = r.charCodeAt(i), o < 55296 || o > 56319 || i + 1 === a || (s = r.charCodeAt(i + 1)) < 56320 || s > 57343 ? e ? r.charAt(i) : o : e ? r.slice(i, i + 2) : (o - 55296 << 10) + (s - 56320) + 65536);
|
|
835
845
|
};
|
|
836
846
|
}(!1);
|
|
837
847
|
E(E.P, "String", { codePointAt: function(e) {
|
|
838
|
-
return
|
|
848
|
+
return A(this, e);
|
|
839
849
|
} }), n.String.codePointAt;
|
|
840
|
-
var
|
|
841
|
-
return e =
|
|
842
|
-
},
|
|
843
|
-
E(E.S + E.F * (!!
|
|
850
|
+
var j = Math.max, ne = Math.min, M = function(e, t) {
|
|
851
|
+
return e = te(e), e < 0 ? j(e + t, 0) : ne(e, t);
|
|
852
|
+
}, re = String.fromCharCode, ie = String.fromCodePoint;
|
|
853
|
+
E(E.S + E.F * (!!ie && ie.length != 1), "String", { fromCodePoint: function(e) {
|
|
844
854
|
for (var t = arguments, n = [], r = arguments.length, i = 0, a; r > i;) {
|
|
845
|
-
if (a = +t[i++],
|
|
846
|
-
n.push(a < 65536 ?
|
|
855
|
+
if (a = +t[i++], M(a, 1114111) !== a) throw RangeError(a + " is not a valid code point");
|
|
856
|
+
n.push(a < 65536 ? re(a) : re(((a -= 65536) >> 10) + 55296, a % 1024 + 56320));
|
|
847
857
|
}
|
|
848
858
|
return n.join("");
|
|
849
859
|
} }), n.String.fromCodePoint;
|
|
850
|
-
var
|
|
860
|
+
var ae = {
|
|
851
861
|
Space_Separator: /[\u1680\u2000-\u200A\u202F\u205F\u3000]/,
|
|
852
862
|
ID_Start: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,
|
|
853
863
|
ID_Continue: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
|
|
854
|
-
},
|
|
864
|
+
}, N = {
|
|
855
865
|
isSpaceSeparator: function(e) {
|
|
856
|
-
return typeof e == "string" &&
|
|
866
|
+
return typeof e == "string" && ae.Space_Separator.test(e);
|
|
857
867
|
},
|
|
858
868
|
isIdStartChar: function(e) {
|
|
859
|
-
return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" ||
|
|
869
|
+
return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" || ae.ID_Start.test(e));
|
|
860
870
|
},
|
|
861
871
|
isIdContinueChar: function(e) {
|
|
862
|
-
return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "" || e === "" ||
|
|
872
|
+
return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "" || e === "" || ae.ID_Continue.test(e));
|
|
863
873
|
},
|
|
864
874
|
isDigit: function(e) {
|
|
865
875
|
return typeof e == "string" && /[0-9]/.test(e);
|
|
@@ -867,12 +877,12 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
867
877
|
isHexDigit: function(e) {
|
|
868
878
|
return typeof e == "string" && /[0-9A-Fa-f]/.test(e);
|
|
869
879
|
}
|
|
870
|
-
},
|
|
871
|
-
|
|
880
|
+
}, P, F, I, L, R, z, B, V, oe, se = function(e, t) {
|
|
881
|
+
P = String(e), F = "start", I = [], L = 0, R = 1, z = 0, B = void 0, V = void 0, oe = void 0;
|
|
872
882
|
do
|
|
873
|
-
|
|
874
|
-
while (
|
|
875
|
-
return typeof t == "function" ? H({ "":
|
|
883
|
+
B = J(), pe[F]();
|
|
884
|
+
while (B.type !== "eof");
|
|
885
|
+
return typeof t == "function" ? H({ "": oe }, "", t) : oe;
|
|
876
886
|
};
|
|
877
887
|
function H(e, t, n) {
|
|
878
888
|
var r = e[t];
|
|
@@ -907,11 +917,11 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
907
917
|
}
|
|
908
918
|
}
|
|
909
919
|
function Y() {
|
|
910
|
-
if (
|
|
920
|
+
if (P[L]) return String.fromCodePoint(P.codePointAt(L));
|
|
911
921
|
}
|
|
912
922
|
function X() {
|
|
913
923
|
var e = Y();
|
|
914
|
-
return e === "\n" ? (
|
|
924
|
+
return e === "\n" ? (R++, z = 0) : e ? z += e.length : z++, e && (L += e.length), e;
|
|
915
925
|
}
|
|
916
926
|
var ce = {
|
|
917
927
|
default: function() {
|
|
@@ -933,11 +943,11 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
933
943
|
return;
|
|
934
944
|
case void 0: return X(), Z("eof");
|
|
935
945
|
}
|
|
936
|
-
if (
|
|
946
|
+
if (N.isSpaceSeparator(q)) {
|
|
937
947
|
X();
|
|
938
948
|
return;
|
|
939
949
|
}
|
|
940
|
-
return ce[
|
|
950
|
+
return ce[F]();
|
|
941
951
|
},
|
|
942
952
|
comment: function() {
|
|
943
953
|
switch (q) {
|
|
@@ -1027,7 +1037,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1027
1037
|
switch (e) {
|
|
1028
1038
|
case "$":
|
|
1029
1039
|
case "_": break;
|
|
1030
|
-
default: if (!
|
|
1040
|
+
default: if (!N.isIdStartChar(e)) throw _e();
|
|
1031
1041
|
}
|
|
1032
1042
|
W += e, U = "identifierName";
|
|
1033
1043
|
},
|
|
@@ -1043,7 +1053,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1043
1053
|
X(), U = "identifierNameEscape";
|
|
1044
1054
|
return;
|
|
1045
1055
|
}
|
|
1046
|
-
if (
|
|
1056
|
+
if (N.isIdContinueChar(q)) {
|
|
1047
1057
|
W += X();
|
|
1048
1058
|
return;
|
|
1049
1059
|
}
|
|
@@ -1058,7 +1068,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1058
1068
|
case "_":
|
|
1059
1069
|
case "":
|
|
1060
1070
|
case "": break;
|
|
1061
|
-
default: if (!
|
|
1071
|
+
default: if (!N.isIdContinueChar(e)) throw _e();
|
|
1062
1072
|
}
|
|
1063
1073
|
W += e, U = "identifierName";
|
|
1064
1074
|
},
|
|
@@ -1112,14 +1122,14 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1112
1122
|
W += X(), U = "decimalExponent";
|
|
1113
1123
|
return;
|
|
1114
1124
|
}
|
|
1115
|
-
if (
|
|
1125
|
+
if (N.isDigit(q)) {
|
|
1116
1126
|
W += X();
|
|
1117
1127
|
return;
|
|
1118
1128
|
}
|
|
1119
1129
|
return Z("numeric", K * Number(W));
|
|
1120
1130
|
},
|
|
1121
1131
|
decimalPointLeading: function() {
|
|
1122
|
-
if (
|
|
1132
|
+
if (N.isDigit(q)) {
|
|
1123
1133
|
W += X(), U = "decimalFraction";
|
|
1124
1134
|
return;
|
|
1125
1135
|
}
|
|
@@ -1132,7 +1142,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1132
1142
|
W += X(), U = "decimalExponent";
|
|
1133
1143
|
return;
|
|
1134
1144
|
}
|
|
1135
|
-
if (
|
|
1145
|
+
if (N.isDigit(q)) {
|
|
1136
1146
|
W += X(), U = "decimalFraction";
|
|
1137
1147
|
return;
|
|
1138
1148
|
}
|
|
@@ -1145,7 +1155,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1145
1155
|
W += X(), U = "decimalExponent";
|
|
1146
1156
|
return;
|
|
1147
1157
|
}
|
|
1148
|
-
if (
|
|
1158
|
+
if (N.isDigit(q)) {
|
|
1149
1159
|
W += X();
|
|
1150
1160
|
return;
|
|
1151
1161
|
}
|
|
@@ -1158,35 +1168,35 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1158
1168
|
W += X(), U = "decimalExponentSign";
|
|
1159
1169
|
return;
|
|
1160
1170
|
}
|
|
1161
|
-
if (
|
|
1171
|
+
if (N.isDigit(q)) {
|
|
1162
1172
|
W += X(), U = "decimalExponentInteger";
|
|
1163
1173
|
return;
|
|
1164
1174
|
}
|
|
1165
1175
|
throw Q(X());
|
|
1166
1176
|
},
|
|
1167
1177
|
decimalExponentSign: function() {
|
|
1168
|
-
if (
|
|
1178
|
+
if (N.isDigit(q)) {
|
|
1169
1179
|
W += X(), U = "decimalExponentInteger";
|
|
1170
1180
|
return;
|
|
1171
1181
|
}
|
|
1172
1182
|
throw Q(X());
|
|
1173
1183
|
},
|
|
1174
1184
|
decimalExponentInteger: function() {
|
|
1175
|
-
if (
|
|
1185
|
+
if (N.isDigit(q)) {
|
|
1176
1186
|
W += X();
|
|
1177
1187
|
return;
|
|
1178
1188
|
}
|
|
1179
1189
|
return Z("numeric", K * Number(W));
|
|
1180
1190
|
},
|
|
1181
1191
|
hexadecimal: function() {
|
|
1182
|
-
if (
|
|
1192
|
+
if (N.isHexDigit(q)) {
|
|
1183
1193
|
W += X(), U = "hexadecimalInteger";
|
|
1184
1194
|
return;
|
|
1185
1195
|
}
|
|
1186
1196
|
throw Q(X());
|
|
1187
1197
|
},
|
|
1188
1198
|
hexadecimalInteger: function() {
|
|
1189
|
-
if (
|
|
1199
|
+
if (N.isHexDigit(q)) {
|
|
1190
1200
|
W += X();
|
|
1191
1201
|
return;
|
|
1192
1202
|
}
|
|
@@ -1237,7 +1247,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1237
1247
|
G = X() === "\"", U = "string";
|
|
1238
1248
|
return;
|
|
1239
1249
|
}
|
|
1240
|
-
if (
|
|
1250
|
+
if (N.isIdStartChar(q)) {
|
|
1241
1251
|
W += X(), U = "identifierName";
|
|
1242
1252
|
return;
|
|
1243
1253
|
}
|
|
@@ -1276,8 +1286,8 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1276
1286
|
return {
|
|
1277
1287
|
type: e,
|
|
1278
1288
|
value: t,
|
|
1279
|
-
line:
|
|
1280
|
-
column:
|
|
1289
|
+
line: R,
|
|
1290
|
+
column: z
|
|
1281
1291
|
};
|
|
1282
1292
|
}
|
|
1283
1293
|
function le(e) {
|
|
@@ -1296,7 +1306,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1296
1306
|
case "t": return X(), " ";
|
|
1297
1307
|
case "v": return X(), "\v";
|
|
1298
1308
|
case "0":
|
|
1299
|
-
if (X(),
|
|
1309
|
+
if (X(), N.isDigit(Y())) throw Q(X());
|
|
1300
1310
|
return "\0";
|
|
1301
1311
|
case "x": return X(), de();
|
|
1302
1312
|
case "u": return X(), fe();
|
|
@@ -1319,27 +1329,27 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1319
1329
|
}
|
|
1320
1330
|
function de() {
|
|
1321
1331
|
var e = "", t = Y();
|
|
1322
|
-
if (!
|
|
1332
|
+
if (!N.isHexDigit(t) || (e += X(), t = Y(), !N.isHexDigit(t))) throw Q(X());
|
|
1323
1333
|
return e += X(), String.fromCodePoint(parseInt(e, 16));
|
|
1324
1334
|
}
|
|
1325
1335
|
function fe() {
|
|
1326
1336
|
for (var e = "", t = 4; t-- > 0;) {
|
|
1327
1337
|
var n = Y();
|
|
1328
|
-
if (!
|
|
1338
|
+
if (!N.isHexDigit(n)) throw Q(X());
|
|
1329
1339
|
e += X();
|
|
1330
1340
|
}
|
|
1331
1341
|
return String.fromCodePoint(parseInt(e, 16));
|
|
1332
1342
|
}
|
|
1333
1343
|
var pe = {
|
|
1334
1344
|
start: function() {
|
|
1335
|
-
if (
|
|
1345
|
+
if (B.type === "eof") throw ge();
|
|
1336
1346
|
me();
|
|
1337
1347
|
},
|
|
1338
1348
|
beforePropertyName: function() {
|
|
1339
|
-
switch (
|
|
1349
|
+
switch (B.type) {
|
|
1340
1350
|
case "identifier":
|
|
1341
1351
|
case "string":
|
|
1342
|
-
|
|
1352
|
+
V = B.value, F = "afterPropertyName";
|
|
1343
1353
|
return;
|
|
1344
1354
|
case "punctuator":
|
|
1345
1355
|
he();
|
|
@@ -1348,35 +1358,35 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1348
1358
|
}
|
|
1349
1359
|
},
|
|
1350
1360
|
afterPropertyName: function() {
|
|
1351
|
-
if (
|
|
1352
|
-
|
|
1361
|
+
if (B.type === "eof") throw ge();
|
|
1362
|
+
F = "beforePropertyValue";
|
|
1353
1363
|
},
|
|
1354
1364
|
beforePropertyValue: function() {
|
|
1355
|
-
if (
|
|
1365
|
+
if (B.type === "eof") throw ge();
|
|
1356
1366
|
me();
|
|
1357
1367
|
},
|
|
1358
1368
|
beforeArrayValue: function() {
|
|
1359
|
-
if (
|
|
1360
|
-
if (
|
|
1369
|
+
if (B.type === "eof") throw ge();
|
|
1370
|
+
if (B.type === "punctuator" && B.value === "]") {
|
|
1361
1371
|
he();
|
|
1362
1372
|
return;
|
|
1363
1373
|
}
|
|
1364
1374
|
me();
|
|
1365
1375
|
},
|
|
1366
1376
|
afterPropertyValue: function() {
|
|
1367
|
-
if (
|
|
1368
|
-
switch (
|
|
1377
|
+
if (B.type === "eof") throw ge();
|
|
1378
|
+
switch (B.value) {
|
|
1369
1379
|
case ",":
|
|
1370
|
-
|
|
1380
|
+
F = "beforePropertyName";
|
|
1371
1381
|
return;
|
|
1372
1382
|
case "}": he();
|
|
1373
1383
|
}
|
|
1374
1384
|
},
|
|
1375
1385
|
afterArrayValue: function() {
|
|
1376
|
-
if (
|
|
1377
|
-
switch (
|
|
1386
|
+
if (B.type === "eof") throw ge();
|
|
1387
|
+
switch (B.value) {
|
|
1378
1388
|
case ",":
|
|
1379
|
-
|
|
1389
|
+
F = "beforeArrayValue";
|
|
1380
1390
|
return;
|
|
1381
1391
|
case "]": he();
|
|
1382
1392
|
}
|
|
@@ -1385,9 +1395,9 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1385
1395
|
};
|
|
1386
1396
|
function me() {
|
|
1387
1397
|
var e;
|
|
1388
|
-
switch (
|
|
1398
|
+
switch (B.type) {
|
|
1389
1399
|
case "punctuator":
|
|
1390
|
-
switch (
|
|
1400
|
+
switch (B.value) {
|
|
1391
1401
|
case "{":
|
|
1392
1402
|
e = {};
|
|
1393
1403
|
break;
|
|
@@ -1397,37 +1407,37 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1397
1407
|
case "null":
|
|
1398
1408
|
case "boolean":
|
|
1399
1409
|
case "numeric":
|
|
1400
|
-
case "string": e =
|
|
1410
|
+
case "string": e = B.value;
|
|
1401
1411
|
}
|
|
1402
|
-
if (
|
|
1412
|
+
if (oe === void 0) oe = e;
|
|
1403
1413
|
else {
|
|
1404
|
-
var t =
|
|
1405
|
-
Array.isArray(t) ? t.push(e) : Object.defineProperty(t,
|
|
1414
|
+
var t = I[I.length - 1];
|
|
1415
|
+
Array.isArray(t) ? t.push(e) : Object.defineProperty(t, V, {
|
|
1406
1416
|
value: e,
|
|
1407
1417
|
writable: !0,
|
|
1408
1418
|
enumerable: !0,
|
|
1409
1419
|
configurable: !0
|
|
1410
1420
|
});
|
|
1411
1421
|
}
|
|
1412
|
-
if (typeof e == "object" && e)
|
|
1422
|
+
if (typeof e == "object" && e) I.push(e), F = Array.isArray(e) ? "beforeArrayValue" : "beforePropertyName";
|
|
1413
1423
|
else {
|
|
1414
|
-
var n =
|
|
1415
|
-
|
|
1424
|
+
var n = I[I.length - 1];
|
|
1425
|
+
F = n == null ? "end" : Array.isArray(n) ? "afterArrayValue" : "afterPropertyValue";
|
|
1416
1426
|
}
|
|
1417
1427
|
}
|
|
1418
1428
|
function he() {
|
|
1419
|
-
|
|
1420
|
-
var e =
|
|
1421
|
-
|
|
1429
|
+
I.pop();
|
|
1430
|
+
var e = I[I.length - 1];
|
|
1431
|
+
F = e == null ? "end" : Array.isArray(e) ? "afterArrayValue" : "afterPropertyValue";
|
|
1422
1432
|
}
|
|
1423
1433
|
function Q(e) {
|
|
1424
|
-
return be(e === void 0 ? "JSON5: invalid end of input at " +
|
|
1434
|
+
return be(e === void 0 ? "JSON5: invalid end of input at " + R + ":" + z : "JSON5: invalid character '" + ye(e) + "' at " + R + ":" + z);
|
|
1425
1435
|
}
|
|
1426
1436
|
function ge() {
|
|
1427
|
-
return be("JSON5: invalid end of input at " +
|
|
1437
|
+
return be("JSON5: invalid end of input at " + R + ":" + z);
|
|
1428
1438
|
}
|
|
1429
1439
|
function _e() {
|
|
1430
|
-
return
|
|
1440
|
+
return z -= 5, be("JSON5: invalid identifier character at " + R + ":" + z);
|
|
1431
1441
|
}
|
|
1432
1442
|
function ve(e) {
|
|
1433
1443
|
console.warn("JSON5: '" + ye(e) + "' in strings is not valid ECMAScript; consider escaping");
|
|
@@ -1456,10 +1466,10 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1456
1466
|
}
|
|
1457
1467
|
function be(e) {
|
|
1458
1468
|
var t = SyntaxError(e);
|
|
1459
|
-
return t.lineNumber =
|
|
1469
|
+
return t.lineNumber = R, t.columnNumber = z, t;
|
|
1460
1470
|
}
|
|
1461
1471
|
return {
|
|
1462
|
-
parse:
|
|
1472
|
+
parse: se,
|
|
1463
1473
|
stringify: function(e, t, n) {
|
|
1464
1474
|
var r = [], i = "", a, o, s = "", c;
|
|
1465
1475
|
if (typeof t == "object" && t && !Array.isArray(t) && (n = t.space, c = t.quote, t = t.replacer), typeof t == "function") o = t;
|
|
@@ -1506,7 +1516,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1506
1516
|
case "\"":
|
|
1507
1517
|
t[a]++, r += a;
|
|
1508
1518
|
continue;
|
|
1509
|
-
case "\0": if (
|
|
1519
|
+
case "\0": if (N.isDigit(e[i + 1])) {
|
|
1510
1520
|
r += "\\x00";
|
|
1511
1521
|
continue;
|
|
1512
1522
|
}
|
|
@@ -1554,8 +1564,8 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1554
1564
|
function g(e) {
|
|
1555
1565
|
if (e.length === 0) return m(e, !0);
|
|
1556
1566
|
var t = String.fromCodePoint(e.codePointAt(0));
|
|
1557
|
-
if (!
|
|
1558
|
-
for (var n = t.length; n < e.length; n++) if (!
|
|
1567
|
+
if (!N.isIdStartChar(t)) return m(e, !0);
|
|
1568
|
+
for (var n = t.length; n < e.length; n++) if (!N.isIdContinueChar(String.fromCodePoint(e.codePointAt(n)))) return m(e, !0);
|
|
1559
1569
|
return e;
|
|
1560
1570
|
}
|
|
1561
1571
|
function _(e) {
|
|
@@ -1579,7 +1589,7 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1579
1589
|
}
|
|
1580
1590
|
};
|
|
1581
1591
|
}));
|
|
1582
|
-
})))(), 1),
|
|
1592
|
+
})))(), 1), De = {
|
|
1583
1593
|
ball: 1,
|
|
1584
1594
|
red: 2,
|
|
1585
1595
|
blue: 4,
|
|
@@ -1593,36 +1603,36 @@ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
|
|
|
1593
1603
|
c2: 1073741824,
|
|
1594
1604
|
c3: -2147483648,
|
|
1595
1605
|
all: 63
|
|
1596
|
-
},
|
|
1606
|
+
}, Oe = (e) => {
|
|
1597
1607
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Expected an object");
|
|
1598
1608
|
return e;
|
|
1599
1609
|
}, $ = (e, t, n = -4096, r = 4096) => {
|
|
1600
1610
|
let i = e === void 0 ? t : e;
|
|
1601
1611
|
if (typeof i != "number" || !Number.isFinite(i) || i < n || i > r) throw Error(`Number must be between ${n} and ${r}`);
|
|
1602
1612
|
return i;
|
|
1603
|
-
},
|
|
1613
|
+
}, ke = (e, t = [0, 0]) => {
|
|
1604
1614
|
if (e === void 0) return [...t];
|
|
1605
1615
|
if (!Array.isArray(e) || e.length !== 2) throw Error("Expected [x, y]");
|
|
1606
1616
|
return [$(e[0], 0), $(e[1], 0)];
|
|
1607
|
-
},
|
|
1617
|
+
}, Ae = (e, t) => {
|
|
1608
1618
|
if (e === void 0) return [];
|
|
1609
1619
|
if (!Array.isArray(e) || e.length > t) throw Error(`Array limit: ${t}`);
|
|
1610
1620
|
return e;
|
|
1611
1621
|
};
|
|
1612
|
-
function
|
|
1613
|
-
return e === void 0 ? t : typeof e == "number" ? $(e, t, -2147483648, 4294967295) | 0 :
|
|
1614
|
-
if (typeof t != "string" || !Object.hasOwn(
|
|
1615
|
-
return e |
|
|
1622
|
+
function je(e, t) {
|
|
1623
|
+
return e === void 0 ? t : typeof e == "number" ? $(e, t, -2147483648, 4294967295) | 0 : Ae(e, 16).reduce((e, t) => {
|
|
1624
|
+
if (typeof t != "string" || !Object.hasOwn(De, t)) throw Error("Unknown collision flag");
|
|
1625
|
+
return e | De[t];
|
|
1616
1626
|
}, 0);
|
|
1617
1627
|
}
|
|
1618
|
-
function
|
|
1628
|
+
function Me(e, t = "FFFFFF") {
|
|
1619
1629
|
if (e === void 0) return t;
|
|
1620
1630
|
if (e === "transparent") return e;
|
|
1621
1631
|
if (Array.isArray(e) && e.length === 3) return e.map((e) => Math.round($(e, 0, 0, 255)).toString(16).padStart(2, "0")).join("");
|
|
1622
1632
|
if (typeof e == "string" && /^[0-9a-f]{6}$/i.test(e)) return e;
|
|
1623
1633
|
throw Error("Invalid color");
|
|
1624
1634
|
}
|
|
1625
|
-
var
|
|
1635
|
+
var Ne = Object.fromEntries(Object.entries({
|
|
1626
1636
|
root: "version physicsMode name width height maxViewWidth cameraFollow spawnDistance canBeStored kickOffReset bg traits vertexes segments goals discs planes joints redSpawnPoints blueSpawnPoints playerPhysics ballPhysics",
|
|
1627
1637
|
bg: "type width height kickOffRadius cornerRadius goalLine color",
|
|
1628
1638
|
vertexes: "trait x y bCoef cMask cGroup",
|
|
@@ -1632,7 +1642,7 @@ var je = Object.fromEntries(Object.entries({
|
|
|
1632
1642
|
goals: "trait p0 p1 team",
|
|
1633
1643
|
joints: "trait d0 d1 length strength color",
|
|
1634
1644
|
playerPhysics: "trait pos speed gravity radius invMass damping bCoef cGroup cMask color acceleration kickingAcceleration kickingDamping kickStrength kickback"
|
|
1635
|
-
}).map(([e, t]) => [e, new Set(t.split(" "))])),
|
|
1645
|
+
}).map(([e, t]) => [e, new Set(t.split(" "))])), Pe = new Set([
|
|
1636
1646
|
"vertexes",
|
|
1637
1647
|
"segments",
|
|
1638
1648
|
"discs",
|
|
@@ -1640,15 +1650,15 @@ var je = Object.fromEntries(Object.entries({
|
|
|
1640
1650
|
"goals",
|
|
1641
1651
|
"joints",
|
|
1642
1652
|
"playerPhysics"
|
|
1643
|
-
].flatMap((e) => [...
|
|
1644
|
-
function
|
|
1653
|
+
].flatMap((e) => [...Ne[e]]));
|
|
1654
|
+
function Fe(e) {
|
|
1645
1655
|
let t = [], n = (e, t) => {
|
|
1646
|
-
let n = t.length > 80 ? t.slice(0, 80)
|
|
1647
|
-
return e + (/^[A-Za-z_$][\w$]*$/.test(n) ?
|
|
1656
|
+
let n = t.length > 80 ? `${t.slice(0, 80)}…` : t;
|
|
1657
|
+
return e + (/^[A-Za-z_$][\w$]*$/.test(n) ? `.${n}` : `[${JSON.stringify(n)}]`);
|
|
1648
1658
|
}, r = (e, r, i) => {
|
|
1649
|
-
if (e && typeof e == "object" && !Array.isArray(e)) for (let a of Object.keys(e)) r.has(a) || (t.length < 64 ? t.push(
|
|
1659
|
+
if (e && typeof e == "object" && !Array.isArray(e)) for (let a of Object.keys(e)) r.has(a) || (t.length < 64 ? t.push(`Unsupported stadium field: ${n(i, a)}`) : t.length === 64 && t.push("Additional unsupported stadium fields omitted."));
|
|
1650
1660
|
};
|
|
1651
|
-
r(e,
|
|
1661
|
+
r(e, Ne.root, "$"), r(e.bg, Ne.bg, "$.bg");
|
|
1652
1662
|
for (let t of [
|
|
1653
1663
|
"vertexes",
|
|
1654
1664
|
"segments",
|
|
@@ -1658,66 +1668,68 @@ function Ne(e) {
|
|
|
1658
1668
|
"joints"
|
|
1659
1669
|
]) {
|
|
1660
1670
|
let n = e[t];
|
|
1661
|
-
Array.isArray(n) && n.forEach((e, n) =>
|
|
1671
|
+
Array.isArray(n) && n.forEach((e, n) => {
|
|
1672
|
+
r(e, Ne[t], `$.${t}[${n}]`);
|
|
1673
|
+
});
|
|
1662
1674
|
}
|
|
1663
|
-
if (r(e.ballPhysics,
|
|
1675
|
+
if (r(e.ballPhysics, Ne.discs, "$.ballPhysics"), r(e.playerPhysics, Ne.playerPhysics, "$.playerPhysics"), e.traits && typeof e.traits == "object" && !Array.isArray(e.traits)) for (let [t, i] of Object.entries(e.traits)) r(i, Pe, n("$.traits", t));
|
|
1664
1676
|
return t;
|
|
1665
1677
|
}
|
|
1666
|
-
function
|
|
1678
|
+
function Ie(e, t, n, r, i) {
|
|
1667
1679
|
let a = e === "hbs" ? 1 : Math.ceil(2 * Math.SQRT2 * 100 / Math.min(10, i));
|
|
1668
1680
|
if ((t + 32) * (n + t + 32 + r) * a > 2e6) throw Error("Stadium collision complexity exceeds the room budget");
|
|
1669
1681
|
}
|
|
1670
|
-
function
|
|
1682
|
+
function Le(e) {
|
|
1671
1683
|
if (new TextEncoder().encode(e).length > 262144) throw Error("Stadium exceeds 256 KB");
|
|
1672
|
-
let t = Ee
|
|
1684
|
+
let t = Oe(Ee.default.parse(e));
|
|
1673
1685
|
if (t.physicsMode !== void 0 && t.physicsMode !== "hbs" && t.physicsMode !== "substeps") throw Error("Invalid physics mode");
|
|
1674
1686
|
let n = t.physicsMode === "substeps" ? "substeps" : "hbs";
|
|
1675
1687
|
if (t.version !== void 0 && t.version !== 1) throw Error("Unsupported stadium version");
|
|
1676
|
-
let r = t.traits === void 0 ? {} :
|
|
1677
|
-
let t =
|
|
1688
|
+
let r = t.traits === void 0 ? {} : Oe(t.traits), i = (e) => {
|
|
1689
|
+
let t = Oe(e);
|
|
1678
1690
|
if (t.trait === void 0) return t;
|
|
1679
1691
|
if (typeof t.trait != "string" || !Object.hasOwn(r, t.trait)) throw Error("Unknown trait");
|
|
1680
1692
|
return {
|
|
1681
|
-
...
|
|
1693
|
+
...Oe(r[t.trait]),
|
|
1682
1694
|
...t
|
|
1683
1695
|
};
|
|
1684
1696
|
}, a = (e, t = !1) => ({
|
|
1685
|
-
pos:
|
|
1686
|
-
speed:
|
|
1687
|
-
gravity:
|
|
1697
|
+
pos: ke(e.pos),
|
|
1698
|
+
speed: ke(e.speed),
|
|
1699
|
+
gravity: ke(e.gravity),
|
|
1688
1700
|
radius: $(e.radius, 10, .5, 100),
|
|
1689
1701
|
invMass: $(e.invMass, 1, 0, 8192),
|
|
1690
1702
|
damping: $(e.damping, .99, 0, 8192),
|
|
1691
1703
|
bCoef: $(e.bCoef, .5, -1, 8192),
|
|
1692
|
-
cGroup:
|
|
1693
|
-
cMask:
|
|
1694
|
-
color:
|
|
1695
|
-
}), o =
|
|
1704
|
+
cGroup: je(e.cGroup, t ? 193 : 63),
|
|
1705
|
+
cMask: je(e.cMask, 63),
|
|
1706
|
+
color: Me(e.color)
|
|
1707
|
+
}), o = Ae(t.discs, 63).map((e) => a(i(e)));
|
|
1696
1708
|
if (t.ballPhysics !== "disc0") {
|
|
1697
1709
|
let e = a(t.ballPhysics === void 0 ? {} : i(t.ballPhysics), !0);
|
|
1698
1710
|
e.cGroup |= 192, o.unshift(e);
|
|
1699
1711
|
} else if (!o.length) throw Error("disc0 needs a disc");
|
|
1700
|
-
let s =
|
|
1712
|
+
let s = Ae(t.vertexes, 1024).map((e) => i(e)), c = [], l = [], u = Fe(t);
|
|
1701
1713
|
for (let e of s) c.push({
|
|
1702
1714
|
a: [$(e.x, 0), $(e.y, 0)],
|
|
1703
1715
|
b: [$(e.x, 0), $(e.y, 0)],
|
|
1704
1716
|
bCoef: $(e.bCoef, 1, -1, 8192),
|
|
1705
|
-
cGroup:
|
|
1706
|
-
cMask:
|
|
1717
|
+
cGroup: je(e.cGroup, 32),
|
|
1718
|
+
cMask: je(e.cMask, 63),
|
|
1707
1719
|
bias: 0,
|
|
1708
1720
|
color: "transparent",
|
|
1709
1721
|
vis: !1
|
|
1710
1722
|
});
|
|
1711
1723
|
let d = [...c];
|
|
1712
|
-
for (let e of
|
|
1724
|
+
for (let e of Ae(t.segments, 1024)) {
|
|
1713
1725
|
let t = i(e), n = $(t.v0, -1, 0, s.length - 1), r = $(t.v1, -1, 0, s.length - 1);
|
|
1714
1726
|
if (!Number.isInteger(n) || !Number.isInteger(r)) throw Error("Vertex indices must be integers");
|
|
1715
1727
|
let a = [$(s[n].x, 0), $(s[n].y, 0)], o = [$(s[r].x, 0), $(s[r].y, 0)], u = {
|
|
1716
1728
|
bCoef: $(t.bCoef, 1, -1, 8192),
|
|
1717
|
-
cGroup:
|
|
1718
|
-
cMask:
|
|
1729
|
+
cGroup: je(t.cGroup, 32),
|
|
1730
|
+
cMask: je(t.cMask, 63),
|
|
1719
1731
|
bias: $(t.bias, 0, -100, 100),
|
|
1720
|
-
color:
|
|
1732
|
+
color: Me(t.color, "000000"),
|
|
1721
1733
|
vis: t.vis !== !1
|
|
1722
1734
|
}, f = t.curveF === void 0 ? $(t.curve, 0, -359, 359) : 2 * Math.atan2(1, $(t.curveF, 0, -1e8, 1e8)) * 180 / Math.PI;
|
|
1723
1735
|
if (Math.abs(f) < 1e-4) {
|
|
@@ -1731,9 +1743,9 @@ function Fe(e) {
|
|
|
1731
1743
|
}
|
|
1732
1744
|
let p = f * Math.PI / 180, m = o[0] - a[0], h = o[1] - a[1];
|
|
1733
1745
|
if (Math.hypot(m, h) < .001) throw Error("Arc endpoints overlap");
|
|
1734
|
-
let g = 1 / (2 * Math.tan(p / 2)), _ = [(a[0] + o[0]) / 2 - h * g, (a[1] + o[1]) / 2 + m * g], v = Math.hypot(a[0] - _[0], a[1] - _[1]), y = Math.atan2(a[1] - _[1], a[0] - _[0]),
|
|
1735
|
-
if (c.length +
|
|
1736
|
-
let
|
|
1746
|
+
let g = 1 / (2 * Math.tan(p / 2)), _ = [(a[0] + o[0]) / 2 - h * g, (a[1] + o[1]) / 2 + m * g], v = Math.hypot(a[0] - _[0], a[1] - _[1]), y = Math.atan2(a[1] - _[1], a[0] - _[0]), b = Math.ceil(Math.abs(p) / Math.max(1e-8, 2 * Math.acos(Math.max(-1, 1 - .15 / v))));
|
|
1747
|
+
if (c.length + b > 4096) throw Error("Compiled geometry exceeds 4096 segments");
|
|
1748
|
+
let x = {
|
|
1737
1749
|
a,
|
|
1738
1750
|
b: o,
|
|
1739
1751
|
...u,
|
|
@@ -1743,16 +1755,16 @@ function Fe(e) {
|
|
|
1743
1755
|
sweep: p,
|
|
1744
1756
|
major: t.curveF === void 0 ? Math.abs(f) > 180 : Number(t.curveF) <= 0
|
|
1745
1757
|
};
|
|
1746
|
-
l.push(
|
|
1747
|
-
let
|
|
1748
|
-
for (let e = 1; e <=
|
|
1749
|
-
let t = e ===
|
|
1758
|
+
l.push(x), d.push(x);
|
|
1759
|
+
let S = a;
|
|
1760
|
+
for (let e = 1; e <= b; e++) {
|
|
1761
|
+
let t = e === b ? o : [_[0] + v * Math.cos(y + p * e / b), _[1] + v * Math.sin(y + p * e / b)];
|
|
1750
1762
|
c.push({
|
|
1751
|
-
a:
|
|
1763
|
+
a: S,
|
|
1752
1764
|
b: t,
|
|
1753
1765
|
...u,
|
|
1754
1766
|
renderOnly: !0
|
|
1755
|
-
}),
|
|
1767
|
+
}), S = t;
|
|
1756
1768
|
}
|
|
1757
1769
|
}
|
|
1758
1770
|
if (c.length > 4096) throw Error("Compiled geometry exceeds 4096 segments");
|
|
@@ -1770,8 +1782,8 @@ function Fe(e) {
|
|
|
1770
1782
|
kickStrength: $(f.kickStrength, 5, -8192, 8192),
|
|
1771
1783
|
kickback: $(f.kickback, 0, -8192, 8192)
|
|
1772
1784
|
};
|
|
1773
|
-
|
|
1774
|
-
let m = t.bg === void 0 ? {} :
|
|
1785
|
+
Ie(n, o.length, c.length, Ae(t.planes, 64).length + Ae(t.joints, 128).length, Math.min(p.radius, ...o.map((e) => e.radius)));
|
|
1786
|
+
let m = t.bg === void 0 ? {} : Oe(t.bg);
|
|
1775
1787
|
return {
|
|
1776
1788
|
version: 1,
|
|
1777
1789
|
physicsMode: n,
|
|
@@ -1787,7 +1799,7 @@ function Fe(e) {
|
|
|
1787
1799
|
goalLine: $(m.goalLine, 0, 0, 2048),
|
|
1788
1800
|
width: $(m.width, 0, 0, 2048),
|
|
1789
1801
|
height: $(m.height, 0, 0, 2048),
|
|
1790
|
-
color:
|
|
1802
|
+
color: Me(m.color, "718C5A"),
|
|
1791
1803
|
kickOffRadius: $(m.kickOffRadius, 0, 0, 500)
|
|
1792
1804
|
},
|
|
1793
1805
|
discs: o,
|
|
@@ -1797,24 +1809,24 @@ function Fe(e) {
|
|
|
1797
1809
|
player: p,
|
|
1798
1810
|
spawnDistance: $(t.spawnDistance, 200, 0, 1500),
|
|
1799
1811
|
kickOffReset: t.kickOffReset === "full" ? "full" : "partial",
|
|
1800
|
-
redSpawnPoints:
|
|
1801
|
-
blueSpawnPoints:
|
|
1812
|
+
redSpawnPoints: Ae(t.redSpawnPoints, 32).map((e) => ke(e)),
|
|
1813
|
+
blueSpawnPoints: Ae(t.blueSpawnPoints, 32).map((e) => ke(e)),
|
|
1802
1814
|
warnings: u,
|
|
1803
|
-
planes:
|
|
1804
|
-
let t = i(e), n =
|
|
1815
|
+
planes: Ae(t.planes, 64).map((e) => {
|
|
1816
|
+
let t = i(e), n = ke(t.normal);
|
|
1805
1817
|
if (Math.hypot(...n) < 1e-6) throw Error("Plane normal is zero");
|
|
1806
1818
|
return {
|
|
1807
1819
|
normal: n,
|
|
1808
1820
|
dist: $(t.dist, 0),
|
|
1809
1821
|
bCoef: $(t.bCoef, 1, -1, 8192),
|
|
1810
|
-
cGroup:
|
|
1811
|
-
cMask:
|
|
1822
|
+
cGroup: je(t.cGroup, 32),
|
|
1823
|
+
cMask: je(t.cMask, 63)
|
|
1812
1824
|
};
|
|
1813
1825
|
}),
|
|
1814
|
-
goals:
|
|
1826
|
+
goals: Ae(t.goals, 16).map((e) => {
|
|
1815
1827
|
let t = i(e);
|
|
1816
1828
|
if (t.team !== "red" && t.team !== "blue") throw Error("Invalid goal team");
|
|
1817
|
-
let n =
|
|
1829
|
+
let n = ke(t.p0), r = ke(t.p1);
|
|
1818
1830
|
if (Math.hypot(r[0] - n[0], r[1] - n[1]) < 1) throw Error("Goal has zero length");
|
|
1819
1831
|
return {
|
|
1820
1832
|
p0: n,
|
|
@@ -1822,22 +1834,22 @@ function Fe(e) {
|
|
|
1822
1834
|
team: t.team === "red" ? 1 : 2
|
|
1823
1835
|
};
|
|
1824
1836
|
}),
|
|
1825
|
-
joints:
|
|
1837
|
+
joints: Ae(t.joints, 128).map((e) => {
|
|
1826
1838
|
let t = i(e), n = $(t.d0, -1, 0, o.length - 1), r = $(t.d1, -1, 0, o.length - 1);
|
|
1827
1839
|
if (!Number.isInteger(n) || !Number.isInteger(r) || n === r) throw Error("Invalid joint indices");
|
|
1828
|
-
let a = Math.hypot(o[r].pos[0] - o[n].pos[0], o[r].pos[1] - o[n].pos[1]), s = t.length == null ? [a, a] : typeof t.length == "number" ? [t.length, t.length] :
|
|
1840
|
+
let a = Math.hypot(o[r].pos[0] - o[n].pos[0], o[r].pos[1] - o[n].pos[1]), s = t.length == null ? [a, a] : typeof t.length == "number" ? [t.length, t.length] : ke(t.length);
|
|
1829
1841
|
return {
|
|
1830
1842
|
d0: n,
|
|
1831
1843
|
d1: r,
|
|
1832
1844
|
min: $(s[0], 0, 0),
|
|
1833
1845
|
max: $(s[1], 0, 0),
|
|
1834
1846
|
strength: t.strength === void 0 || t.strength === "rigid" ? "rigid" : $(t.strength, 0, -8192, 8192),
|
|
1835
|
-
color:
|
|
1847
|
+
color: Me(t.color, "000000")
|
|
1836
1848
|
};
|
|
1837
1849
|
})
|
|
1838
1850
|
};
|
|
1839
1851
|
}
|
|
1840
|
-
function
|
|
1852
|
+
function Re(e = "Emerald Arena", t = 440, n = 220) {
|
|
1841
1853
|
let r = [
|
|
1842
1854
|
[-t, -n],
|
|
1843
1855
|
[t, -n],
|
|
@@ -1977,7 +1989,7 @@ function Ie(e = "Emerald Arena", t = 440, n = 220) {
|
|
|
1977
1989
|
}
|
|
1978
1990
|
}, null, 2);
|
|
1979
1991
|
}
|
|
1980
|
-
var
|
|
1992
|
+
var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
|
|
1981
1993
|
core;
|
|
1982
1994
|
terrain;
|
|
1983
1995
|
stadium;
|
|
@@ -1999,10 +2011,10 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
1999
2011
|
lastGoal = 0;
|
|
2000
2012
|
kickRate = 2;
|
|
2001
2013
|
setKickRateLimit(e, t, n) {
|
|
2002
|
-
this.kickRate =
|
|
2014
|
+
this.kickRate = He(e, t, n), this.core.kick_limits(this.kickRate & 255, this.kickRate >>> 8 & 255, this.kickRate >>> 16);
|
|
2003
2015
|
}
|
|
2004
2016
|
constructor(e) {
|
|
2005
|
-
this.core = e.exports, this.terrain = new
|
|
2017
|
+
this.core = e.exports, this.terrain = new Z(this.core);
|
|
2006
2018
|
}
|
|
2007
2019
|
configureSurface(e) {
|
|
2008
2020
|
if (this.phase !== "lobby" && this.phase !== "finished") throw Error("Stop the match before configuring its surface");
|
|
@@ -2018,7 +2030,7 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2018
2030
|
return this.terrain.enabled;
|
|
2019
2031
|
}
|
|
2020
2032
|
static async create(t, n) {
|
|
2021
|
-
let r = t ?? await (await fetch("/core.wasm?v=
|
|
2033
|
+
let r = t ?? await (await fetch("/core.wasm?v=5a27b77ea69c9f5e179f", { signal: n })).arrayBuffer();
|
|
2022
2034
|
if (Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", r))).map((e) => e.toString(16).padStart(2, "0")).join("") !== "1229b1b4ba3892d6073fb85b3b6231282c2d81ee270808cb0acda874d49cb87e") throw Error("Physics build changed. Refresh the page to load a matching version.");
|
|
2023
2035
|
return new e(await WebAssembly.instantiate(await WebAssembly.compile(r)));
|
|
2024
2036
|
}
|
|
@@ -2026,9 +2038,9 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2026
2038
|
return new Float64Array(this.core.memory.buffer, this.core.data_ptr(), this.core.count() * 18);
|
|
2027
2039
|
}
|
|
2028
2040
|
load(e) {
|
|
2029
|
-
this.stadium =
|
|
2041
|
+
this.stadium = Le(e), this.source = e, this.core.reset(), this.terrain.disable(), this.colors = [], this.core.physics_mode(+(this.stadium.physicsMode === "substeps")), this.tick = 0, this.elapsed = 0, this.red = this.blue = 0, this.phase = "lobby", this.paused = !1, this.resumeTicks = 0, this.countdown = 0, this.kickoffActive = !0;
|
|
2030
2042
|
for (let e of this.stadium.discs) this.add(e);
|
|
2031
|
-
for (let e = 0; e <
|
|
2043
|
+
for (let e = 0; e < Be; e++) this.add(this.stadium.player, e + 1);
|
|
2032
2044
|
for (let e of this.stadium.colliders) if ("center" in e) {
|
|
2033
2045
|
let t = e;
|
|
2034
2046
|
this.core.arc(...t.center, t.radius, ...t.a, ...t.b, t.sweep, +t.major, t.bCoef, t.cGroup, t.cMask, t.bias);
|
|
@@ -2061,10 +2073,12 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2061
2073
|
0,
|
|
2062
2074
|
e.pos[0],
|
|
2063
2075
|
t ? 0 : e.pos[1]
|
|
2064
|
-
].forEach((e, t) =>
|
|
2076
|
+
].forEach((e, t) => {
|
|
2077
|
+
this.core.set_disc(n, t, e);
|
|
2078
|
+
});
|
|
2065
2079
|
}
|
|
2066
2080
|
index(e) {
|
|
2067
|
-
if (!Number.isInteger(e) || e < 0 || e >=
|
|
2081
|
+
if (!Number.isInteger(e) || e < 0 || e >= Be) throw Error("Invalid slot");
|
|
2068
2082
|
return this.stadium.discs.length + e;
|
|
2069
2083
|
}
|
|
2070
2084
|
joinPlayer(e) {
|
|
@@ -2087,8 +2101,8 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2087
2101
|
applyDiscProperties(e, t) {
|
|
2088
2102
|
let n = this.data;
|
|
2089
2103
|
if (this.phase === "lobby" || !Number.isInteger(e) || e < 0 || e >= this.colors.length || n[e * 18 + 12] > 0 && n[e * 18 + 13] === 0) return !1;
|
|
2090
|
-
let r =
|
|
2091
|
-
for (let [t, a] of
|
|
2104
|
+
let r = we(t), i = !1;
|
|
2105
|
+
for (let [t, a] of Ce) {
|
|
2092
2106
|
let o = r[t];
|
|
2093
2107
|
if (o === void 0) continue;
|
|
2094
2108
|
let s = a === -1 ? this.colors[e] : n[e * 18 + a];
|
|
@@ -2098,9 +2112,9 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2098
2112
|
if (r.radius !== void 0) {
|
|
2099
2113
|
let t = r.radius;
|
|
2100
2114
|
for (let r = 0; r < this.colors.length; r++) r !== e && (t = Math.min(t, n[r * 18 + 4]));
|
|
2101
|
-
|
|
2115
|
+
Ie(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, t);
|
|
2102
2116
|
}
|
|
2103
|
-
for (let [t, i] of
|
|
2117
|
+
for (let [t, i] of Ce) {
|
|
2104
2118
|
let a = r[t];
|
|
2105
2119
|
a !== void 0 && (i === -1 ? this.colors[e] = a : n[e * 18 + i] = a);
|
|
2106
2120
|
}
|
|
@@ -2124,7 +2138,7 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2124
2138
|
let r = this.stadium.discs[n];
|
|
2125
2139
|
(e || n === 0 || this.stadium.kickOffReset === "full") && (this.restoreDiscProperties(n, r), t[n * 18] = r.pos[0], t[n * 18 + 1] = r.pos[1], t[n * 18 + 2] = r.speed[0], t[n * 18 + 3] = r.speed[1]);
|
|
2126
2140
|
}
|
|
2127
|
-
for (let e = 0; e <
|
|
2141
|
+
for (let e = 0; e < Be; e++) {
|
|
2128
2142
|
let n = this.index(e);
|
|
2129
2143
|
this.spawn(n, e, t[n * 18 + 13]);
|
|
2130
2144
|
}
|
|
@@ -2158,7 +2172,7 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2158
2172
|
--this.countdown <= 0 && (this.scoreLimit > 0 && Math.max(this.red, this.blue) >= this.scoreLimit || this.timeLimit > 0 && this.elapsed >= this.timeLimit * 60 && this.red !== this.blue ? this.finish() : (this.phase = "playing", this.resetPositions()));
|
|
2159
2173
|
return;
|
|
2160
2174
|
}
|
|
2161
|
-
for (let t = 0; t <
|
|
2175
|
+
for (let t = 0; t < Be; t++) {
|
|
2162
2176
|
let n = this.index(t) * 18, r = this.stadium.player.cMask;
|
|
2163
2177
|
e[n + 11] = r & -25 | (this.kickoffActive ? r & (this.kickoff === 1 ? 8 : 16) : 0);
|
|
2164
2178
|
}
|
|
@@ -2211,10 +2225,10 @@ var Le = `ball2d-core/1/${Ce}`, Re = class e {
|
|
|
2211
2225
|
for (let n = 0; n < e.discs.length; n += 18) if (e.discs[n + 4] < .5 || e.discs[n + 4] > 100 || e.discs[n + 5] < 0 || e.discs[n + 5] > 8192 || e.discs[n + 6] < 0 || e.discs[n + 6] > 8192 || e.discs[n + 7] < -1 || e.discs[n + 7] > 8192 || !t(e.discs[n + 10], 2147483647, -2147483648) || !t(e.discs[n + 11], 2147483647, -2147483648) || !t(e.discs[n + 13], 2) || !t(e.discs[n + 14], 31) || !t(e.discs[n + 15], 2047) || e.discs[n + 12] > 0 && (!Number.isInteger(e.discs[n + 17]) || e.discs[n + 17] < -255 || e.discs[n + 17] > 25500)) throw Error("Invalid disc properties");
|
|
2212
2226
|
let n = 10;
|
|
2213
2227
|
for (let t = 4; t < e.discs.length; t += 18) n = Math.min(n, e.discs[t]);
|
|
2214
|
-
|
|
2228
|
+
Ie(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, n), this.terrain.restore(e.surface === void 0 ? [] : e.surface), this.setKickRateLimit(e.kickRate & 255, e.kickRate >>> 8 & 255, e.kickRate >>> 16), this.tick = e.tick, this.elapsed = e.elapsed, this.red = e.red, this.blue = e.blue, this.phase = e.phase, this.paused = e.paused, this.resumeTicks = e.resumeTicks, this.countdown = e.countdown, this.kickoff = e.kickoff, this.kickoffActive = e.kickoffActive, this.scoreLimit = e.scoreLimit, this.timeLimit = e.timeLimit, this.data.set(e.discs), this.colors = [...e.colors];
|
|
2215
2229
|
}
|
|
2216
2230
|
};
|
|
2217
|
-
function
|
|
2231
|
+
function He(e, t, n) {
|
|
2218
2232
|
if (![
|
|
2219
2233
|
e,
|
|
2220
2234
|
t,
|
|
@@ -2222,12 +2236,12 @@ function ze(e, t, n) {
|
|
|
2222
2236
|
].every(Number.isInteger)) throw Error("Invalid kick rate limit");
|
|
2223
2237
|
return Math.max(0, Math.min(255, e)) | Math.max(0, Math.min(255, t)) << 8 | Math.max(0, Math.min(100, n)) << 16;
|
|
2224
2238
|
}
|
|
2225
|
-
function
|
|
2239
|
+
function Ue(e) {
|
|
2226
2240
|
let t = new URL(e);
|
|
2227
2241
|
if (!["http:", "https:"].includes(t.protocol) || t.username || t.password || t.pathname !== "/" || t.search || t.hash) throw Error("Expected an HTTP(S) service origin without credentials or a path");
|
|
2228
2242
|
return t.origin;
|
|
2229
2243
|
}
|
|
2230
|
-
function
|
|
2244
|
+
function We() {
|
|
2231
2245
|
return {
|
|
2232
2246
|
serviceOrigin: location.origin,
|
|
2233
2247
|
signalingResume: !0,
|
|
@@ -2235,7 +2249,7 @@ function Ve() {
|
|
|
2235
2249
|
createPeerConnection: (e) => new RTCPeerConnection(e)
|
|
2236
2250
|
};
|
|
2237
2251
|
}
|
|
2238
|
-
var
|
|
2252
|
+
var Ge = [
|
|
2239
2253
|
["classic", "Classic"],
|
|
2240
2254
|
["easy", "Easy"],
|
|
2241
2255
|
["small", "Small"],
|
|
@@ -2247,30 +2261,30 @@ var He = [
|
|
|
2247
2261
|
["big_hockey", "Big Hockey"],
|
|
2248
2262
|
["huge", "Huge"]
|
|
2249
2263
|
];
|
|
2250
|
-
function
|
|
2264
|
+
function Ke(e) {
|
|
2251
2265
|
let t = /* @__PURE__ */ new Map();
|
|
2252
2266
|
return async (n) => {
|
|
2253
|
-
let r =
|
|
2267
|
+
let r = Ge.find(([e, t]) => e === n || t === n);
|
|
2254
2268
|
if (!r) throw Error("Unknown default stadium");
|
|
2255
2269
|
let i = t.get(r[0]);
|
|
2256
2270
|
return i || (i = (async () => {
|
|
2257
2271
|
let t = await e(`/stadiums/${r[0]}.hbs`);
|
|
2258
2272
|
if (!t.ok) throw Error("Could not load stadium");
|
|
2259
2273
|
let n = await t.text();
|
|
2260
|
-
return
|
|
2274
|
+
return Le(n), n;
|
|
2261
2275
|
})(), t.set(r[0], i), i.catch(() => t.delete(r[0]))), i;
|
|
2262
2276
|
};
|
|
2263
2277
|
}
|
|
2264
|
-
function
|
|
2265
|
-
let e =
|
|
2278
|
+
function qe() {
|
|
2279
|
+
let e = We(), t = (e, t) => fetch(e, t);
|
|
2266
2280
|
return {
|
|
2267
2281
|
network: e,
|
|
2268
2282
|
request: t,
|
|
2269
|
-
loadEngine: (e) =>
|
|
2270
|
-
loadStadium:
|
|
2283
|
+
loadEngine: (e) => Ve.create(void 0, e),
|
|
2284
|
+
loadStadium: Ke((n) => t(new URL(n, e.serviceOrigin)))
|
|
2271
2285
|
};
|
|
2272
2286
|
}
|
|
2273
|
-
var
|
|
2287
|
+
var Je = {
|
|
2274
2288
|
message: {
|
|
2275
2289
|
burst: 240,
|
|
2276
2290
|
perSecond: 160
|
|
@@ -2283,12 +2297,12 @@ var Ge = {
|
|
|
2283
2297
|
burst: 4,
|
|
2284
2298
|
perSecond: 1
|
|
2285
2299
|
}
|
|
2286
|
-
},
|
|
2300
|
+
}, Ye = class {
|
|
2287
2301
|
peers = /* @__PURE__ */ new Map();
|
|
2288
2302
|
allow(e, t, n = performance.now()) {
|
|
2289
2303
|
let r = this.peers.get(e);
|
|
2290
2304
|
r || (r = {}, this.peers.set(e, r));
|
|
2291
|
-
let { burst: i, perSecond: a } =
|
|
2305
|
+
let { burst: i, perSecond: a } = Je[t], o = r[t] ?? {
|
|
2292
2306
|
tokens: i,
|
|
2293
2307
|
at: n
|
|
2294
2308
|
};
|
|
@@ -2300,16 +2314,16 @@ var Ge = {
|
|
|
2300
2314
|
clear() {
|
|
2301
2315
|
this.peers.clear();
|
|
2302
2316
|
}
|
|
2303
|
-
},
|
|
2317
|
+
}, Xe = 33554432, Ze = new TextEncoder();
|
|
2304
2318
|
new TextDecoder("utf-8", { fatal: !0 });
|
|
2305
|
-
function
|
|
2319
|
+
function Qe(e) {
|
|
2306
2320
|
let t = 2166136261;
|
|
2307
2321
|
for (let n of e) t = Math.imul(t ^ n, 16777619);
|
|
2308
2322
|
return t >>> 0;
|
|
2309
2323
|
}
|
|
2310
|
-
function
|
|
2324
|
+
function $e(e) {
|
|
2311
2325
|
if (e.length > 33554432) throw Error("Replay exceeds 32 MB");
|
|
2312
|
-
let t =
|
|
2326
|
+
let t = K(e, { level: 6 }), n = new Uint8Array(16 + t.length), r = new DataView(n.buffer);
|
|
2313
2327
|
return n.set([
|
|
2314
2328
|
66,
|
|
2315
2329
|
50,
|
|
@@ -2319,12 +2333,12 @@ function Xe(e) {
|
|
|
2319
2333
|
0,
|
|
2320
2334
|
0,
|
|
2321
2335
|
0
|
|
2322
|
-
]), r.setUint32(8, e.length, !0), r.setUint32(12,
|
|
2336
|
+
]), r.setUint32(8, e.length, !0), r.setUint32(12, Qe(e), !0), n.set(t, 16), n;
|
|
2323
2337
|
}
|
|
2324
|
-
function
|
|
2338
|
+
function et(e) {
|
|
2325
2339
|
if (typeof e == "string") {
|
|
2326
|
-
if (
|
|
2327
|
-
return
|
|
2340
|
+
if (Ze.encode(e).length > 33554432) throw Error("Replay exceeds 32 MB");
|
|
2341
|
+
return Ze.encode(e);
|
|
2328
2342
|
}
|
|
2329
2343
|
let t = e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
2330
2344
|
if (t.length > 33554432) throw Error("Replay exceeds 32 MB");
|
|
@@ -2332,15 +2346,15 @@ function Ze(e) {
|
|
|
2332
2346
|
if (t.length < 17 || t[4] !== 1 || t[5] || t[6] || t[7]) throw Error("Invalid compressed replay header");
|
|
2333
2347
|
let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0);
|
|
2334
2348
|
if (!r || r > 33554432) throw Error("Invalid expanded replay size");
|
|
2335
|
-
let i = new Uint8Array(r), a = 0, o = !1, s = new
|
|
2349
|
+
let i = new Uint8Array(r), a = 0, o = !1, s = new q((e, t) => {
|
|
2336
2350
|
if (a + e.length > r) throw Error("Expanded replay exceeds declared size");
|
|
2337
2351
|
i.set(e, a), a += e.length, o = t;
|
|
2338
2352
|
});
|
|
2339
2353
|
for (let e = 16; e < t.length; e += 1024) s.push(t.subarray(e, e + 1024), e + 1024 >= t.length);
|
|
2340
|
-
if (!o || a !== r ||
|
|
2354
|
+
if (!o || a !== r || Qe(i) !== n.getUint32(12, !0)) throw Error("Compressed replay integrity failure");
|
|
2341
2355
|
return i;
|
|
2342
2356
|
}
|
|
2343
|
-
var
|
|
2357
|
+
var tt = [
|
|
2344
2358
|
"input",
|
|
2345
2359
|
"team",
|
|
2346
2360
|
"start",
|
|
@@ -2352,11 +2366,11 @@ var Qe = [
|
|
|
2352
2366
|
"join",
|
|
2353
2367
|
"disc",
|
|
2354
2368
|
"surface"
|
|
2355
|
-
],
|
|
2356
|
-
function
|
|
2357
|
-
return
|
|
2369
|
+
], nt = new TextEncoder(), rt = new TextDecoder("utf-8", { fatal: !0 });
|
|
2370
|
+
function it(e) {
|
|
2371
|
+
return $e(at(e));
|
|
2358
2372
|
}
|
|
2359
|
-
function
|
|
2373
|
+
function at(e) {
|
|
2360
2374
|
let { commands: t, ...n } = e, r = t.some((e) => e.kind === "surface") || e.initial.surface !== void 0 || e.checkpoints.some((e) => e.state.surface !== void 0) ? 4 : t.some((e) => e.kind === "disc") ? 3 : e.checkpoints.length ? 2 : 1, i = 0, a = e.checkpoints.map((e) => {
|
|
2361
2375
|
let t = e.state.discs;
|
|
2362
2376
|
if (!Array.isArray(t) || t.length > 1728 || t.some((e) => !Number.isFinite(e))) throw Error("Invalid checkpoint discs");
|
|
@@ -2376,12 +2390,12 @@ function nt(e) {
|
|
|
2376
2390
|
};
|
|
2377
2391
|
});
|
|
2378
2392
|
if (a.length > 721) throw Error("Too many replay checkpoints");
|
|
2379
|
-
let o =
|
|
2393
|
+
let o = nt.encode(JSON.stringify(r >= 2 ? {
|
|
2380
2394
|
...n,
|
|
2381
2395
|
checkpoints: a
|
|
2382
2396
|
} : n));
|
|
2383
2397
|
if (t.length > 5e5 || o.length + 16 > 33554432) throw Error("Replay exceeds bounds");
|
|
2384
|
-
let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(
|
|
2398
|
+
let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(Xe, s)), l = new DataView(c.buffer), u = (e) => {
|
|
2385
2399
|
if (d + e > c.length) throw Error("Replay exceeds bounds");
|
|
2386
2400
|
}, d = 0, f = e.initial.tick, p = (e) => {
|
|
2387
2401
|
if (!Number.isInteger(e) || e < 0 || e > 4294967295) throw Error("Invalid replay integer");
|
|
@@ -2392,15 +2406,15 @@ function nt(e) {
|
|
|
2392
2406
|
} while (e);
|
|
2393
2407
|
};
|
|
2394
2408
|
for (let e of t) {
|
|
2395
|
-
let t =
|
|
2409
|
+
let t = tt.indexOf(r < 3 && e.kind === "join" ? "team" : e.kind);
|
|
2396
2410
|
if (e.kind === "join" && e.value !== 0 || e.kind === "team" && e.value > 2) throw Error("Invalid replay team command");
|
|
2397
2411
|
if (t < 0 || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31)) throw Error("Invalid replay command");
|
|
2398
2412
|
if (p(e.tick - f), u(1), c[d++] = r >= 3 ? t : t << 5 | e.slot, r >= 3 && p(e.slot), p(r < 3 && e.kind === "join" ? 3 : e.value), e.kind === "disc") {
|
|
2399
|
-
let t =
|
|
2400
|
-
|
|
2413
|
+
let t = we(e.properties), n = 0;
|
|
2414
|
+
Ce.forEach(([e], r) => {
|
|
2401
2415
|
t[e] !== void 0 && (n |= 1 << r);
|
|
2402
2416
|
}), p(n);
|
|
2403
|
-
for (let [e] of
|
|
2417
|
+
for (let [e] of Ce) {
|
|
2404
2418
|
let n = t[e];
|
|
2405
2419
|
n !== void 0 && (u(8), l.setFloat64(d, n, !0), d += 8);
|
|
2406
2420
|
}
|
|
@@ -2427,9 +2441,9 @@ function nt(e) {
|
|
|
2427
2441
|
}
|
|
2428
2442
|
return h.set(c.subarray(0, d), _), h;
|
|
2429
2443
|
}
|
|
2430
|
-
function
|
|
2431
|
-
let t =
|
|
2432
|
-
if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(
|
|
2444
|
+
function ot(e) {
|
|
2445
|
+
let t = et(e);
|
|
2446
|
+
if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(rt.decode(t));
|
|
2433
2447
|
if (t.length < 16 || ![
|
|
2434
2448
|
1,
|
|
2435
2449
|
2,
|
|
@@ -2438,7 +2452,7 @@ function rt(e) {
|
|
|
2438
2452
|
].includes(t[4]) || t[5] || t[6] || t[7]) throw Error("Invalid packed replay header");
|
|
2439
2453
|
let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0), i = n.getUint32(12, !0);
|
|
2440
2454
|
if (r > t.length - 16 || i > 5e5 || i > (t.length - 16 - r) / 3) throw Error("Invalid packed replay bounds");
|
|
2441
|
-
let a = JSON.parse(
|
|
2455
|
+
let a = JSON.parse(rt.decode(t.subarray(16, 16 + r)));
|
|
2442
2456
|
if (!a || !Number.isSafeInteger(a.initial?.tick) || a.initial.tick < 0) throw Error("Invalid replay initial tick");
|
|
2443
2457
|
a.commands = [];
|
|
2444
2458
|
let o = 16 + r, s = a.initial.tick;
|
|
@@ -2484,14 +2498,14 @@ function rt(e) {
|
|
|
2484
2498
|
};
|
|
2485
2499
|
for (let e = 0; e < i; e++) {
|
|
2486
2500
|
if (s += c(), !Number.isSafeInteger(s) || o >= t.length) throw Error("Invalid replay tick");
|
|
2487
|
-
let e = t[o++], r =
|
|
2501
|
+
let e = t[o++], r = tt[t[4] >= 3 ? e : e >> 5];
|
|
2488
2502
|
if (!r) throw Error("Unknown replay command");
|
|
2489
2503
|
let i = t[4] >= 3 ? c() : e & 31, l = c();
|
|
2490
2504
|
if (r === "disc") {
|
|
2491
2505
|
let e = c();
|
|
2492
2506
|
if (e > 8191) throw Error("Invalid disc property mask");
|
|
2493
2507
|
let u = {};
|
|
2494
|
-
|
|
2508
|
+
Ce.forEach(([r], i) => {
|
|
2495
2509
|
if (e & 1 << i) {
|
|
2496
2510
|
if (o + 8 > t.length) throw Error("Truncated disc properties");
|
|
2497
2511
|
u[r] = n.getFloat64(o, !0), o += 8;
|
|
@@ -2501,7 +2515,7 @@ function rt(e) {
|
|
|
2501
2515
|
kind: r,
|
|
2502
2516
|
slot: i,
|
|
2503
2517
|
value: l,
|
|
2504
|
-
properties:
|
|
2518
|
+
properties: we(u)
|
|
2505
2519
|
});
|
|
2506
2520
|
continue;
|
|
2507
2521
|
}
|
|
@@ -2520,12 +2534,12 @@ function rt(e) {
|
|
|
2520
2534
|
if (o !== t.length) throw Error("Trailing replay command data");
|
|
2521
2535
|
return a;
|
|
2522
2536
|
}
|
|
2523
|
-
function
|
|
2537
|
+
function st(e) {
|
|
2524
2538
|
let t = JSON.stringify(e), n = 2166136261;
|
|
2525
2539
|
for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
|
|
2526
2540
|
return (n >>> 0).toString(16).padStart(8, "0");
|
|
2527
2541
|
}
|
|
2528
|
-
function
|
|
2542
|
+
function ct(e, t) {
|
|
2529
2543
|
switch (t.kind) {
|
|
2530
2544
|
case "surface":
|
|
2531
2545
|
if (t.slot !== 0 || t.value !== 0 && t.value !== 1) throw Error("Invalid surface command");
|
|
@@ -2542,6 +2556,7 @@ function at(e, t) {
|
|
|
2542
2556
|
});
|
|
2543
2557
|
break;
|
|
2544
2558
|
case "disc":
|
|
2559
|
+
if (!t.properties) throw Error("Missing replay disc properties");
|
|
2545
2560
|
e.applyDiscProperties(t.slot, t.properties);
|
|
2546
2561
|
break;
|
|
2547
2562
|
case "input":
|
|
@@ -2571,7 +2586,7 @@ function at(e, t) {
|
|
|
2571
2586
|
case "pause": e.setPaused(!!t.value);
|
|
2572
2587
|
}
|
|
2573
2588
|
}
|
|
2574
|
-
var
|
|
2589
|
+
var lt = class {
|
|
2575
2590
|
replay;
|
|
2576
2591
|
playerOrder = [];
|
|
2577
2592
|
lastInputs = /* @__PURE__ */ new Map();
|
|
@@ -2585,7 +2600,7 @@ var ot = class {
|
|
|
2585
2600
|
this.playerOrder = t.map((e) => e.slot), this.replay = {
|
|
2586
2601
|
magic: "B2DR",
|
|
2587
2602
|
version: 1,
|
|
2588
|
-
engine:
|
|
2603
|
+
engine: ze,
|
|
2589
2604
|
stadium: e.source,
|
|
2590
2605
|
initial: r,
|
|
2591
2606
|
commands: [],
|
|
@@ -2596,14 +2611,14 @@ var ot = class {
|
|
|
2596
2611
|
})),
|
|
2597
2612
|
styles: [{
|
|
2598
2613
|
tick: r.tick,
|
|
2599
|
-
teams:
|
|
2614
|
+
teams: ye(n)
|
|
2600
2615
|
}],
|
|
2601
2616
|
orders: [{
|
|
2602
2617
|
tick: r.tick,
|
|
2603
2618
|
slots: [...this.playerOrder]
|
|
2604
2619
|
}],
|
|
2605
2620
|
end: r.tick,
|
|
2606
|
-
finalHash:
|
|
2621
|
+
finalHash: st(r)
|
|
2607
2622
|
}, this.bytes = new TextEncoder().encode(JSON.stringify(this.replay)).length;
|
|
2608
2623
|
for (let t = 0; t < 32; t++) this.lastInputs.set(t, e.data[e.index(t) * 18 + 14]);
|
|
2609
2624
|
}
|
|
@@ -2623,7 +2638,7 @@ var ot = class {
|
|
|
2623
2638
|
style(e, t) {
|
|
2624
2639
|
let n = {
|
|
2625
2640
|
tick: e,
|
|
2626
|
-
teams:
|
|
2641
|
+
teams: ye(t)
|
|
2627
2642
|
}, r = this.replay.styles;
|
|
2628
2643
|
return r.length >= 4096 || !this.reserve(n) ? (this.full = !0, !1) : (r.push(n), !0);
|
|
2629
2644
|
}
|
|
@@ -2638,7 +2653,7 @@ var ot = class {
|
|
|
2638
2653
|
command(e) {
|
|
2639
2654
|
return e.kind === "input" && this.lastInputs.get(e.slot) === e.value ? !0 : this.replay.commands.length >= 5e5 || !this.reserve(e) ? (this.full = !0, !1) : (e.kind === "input" && this.lastInputs.set(e.slot, e.value), (e.kind === "team" || e.kind === "join") && this.lastInputs.set(e.slot, 0), e.kind === "start" && this.lastInputs.clear(), this.replay.commands.push(e.kind === "disc" ? {
|
|
2640
2655
|
...e,
|
|
2641
|
-
properties:
|
|
2656
|
+
properties: we(e.properties)
|
|
2642
2657
|
} : { ...e }), !0);
|
|
2643
2658
|
}
|
|
2644
2659
|
step(e) {
|
|
@@ -2647,26 +2662,26 @@ var ot = class {
|
|
|
2647
2662
|
let t = e.snapshot(), n = {
|
|
2648
2663
|
tick: e.tick,
|
|
2649
2664
|
state: t,
|
|
2650
|
-
hash:
|
|
2665
|
+
hash: st(t)
|
|
2651
2666
|
};
|
|
2652
2667
|
this.reserve(n) && this.replay.checkpoints.push(n);
|
|
2653
2668
|
}
|
|
2654
2669
|
this.replay.end = e.tick;
|
|
2655
2670
|
}
|
|
2656
2671
|
pack(e) {
|
|
2657
|
-
return this.replay.end = e.tick, this.replay.finalHash =
|
|
2672
|
+
return this.replay.end = e.tick, this.replay.finalHash = st(e.snapshot()), at(this.replay);
|
|
2658
2673
|
}
|
|
2659
2674
|
finish(e) {
|
|
2660
|
-
return this.replay.end = e.tick, this.replay.finalHash =
|
|
2675
|
+
return this.replay.end = e.tick, this.replay.finalHash = st(e.snapshot()), new Blob([it(this.replay)], { type: "application/x-ball2d-replay" });
|
|
2661
2676
|
}
|
|
2662
2677
|
};
|
|
2663
|
-
async function
|
|
2678
|
+
async function ut(e) {
|
|
2664
2679
|
if (e.size > 33554432) throw Error("Replay exceeds 32 MB");
|
|
2665
|
-
return
|
|
2680
|
+
return dt(await e.arrayBuffer());
|
|
2666
2681
|
}
|
|
2667
|
-
function
|
|
2668
|
-
let t =
|
|
2669
|
-
if (t.magic !== "B2DR" || t.version !== 1 || t.engine !==
|
|
2682
|
+
function dt(e) {
|
|
2683
|
+
let t = ot(e);
|
|
2684
|
+
if (t.magic !== "B2DR" || t.version !== 1 || t.engine !== ze) throw Error("Unsupported replay engine/version");
|
|
2670
2685
|
if (!Array.isArray(t.commands) || t.commands.length > 5e5 || !Array.isArray(t.checkpoints) || t.checkpoints.length > 721 || !Number.isInteger(t.end) || t.end < t.initial.tick || t.end - t.initial.tick > 216e3) throw Error("Invalid replay bounds");
|
|
2671
2686
|
let n = t.initial.tick;
|
|
2672
2687
|
for (let e of t.commands) {
|
|
@@ -2683,12 +2698,12 @@ function ct(e) {
|
|
|
2683
2698
|
"disc",
|
|
2684
2699
|
"surface"
|
|
2685
2700
|
].includes(e.kind) || e.kind === "surface" && e.slot !== 0 || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31) || !Number.isInteger(e.value) || e.value < 0 || e.value > (e.kind === "disc" || e.kind === "join" ? 0 : e.kind === "kickRate" ? 6619135 : e.kind === "timeLimit" ? 5940 : e.kind === "scoreLimit" ? 99 : e.kind === "team" ? 2 : e.kind === "pause" || e.kind === "surface" ? 1 : 31)) throw Error("Invalid replay command");
|
|
2686
|
-
e.kind === "disc" && (e.properties =
|
|
2701
|
+
e.kind === "disc" && (e.properties = we(e.properties)), n = e.tick;
|
|
2687
2702
|
}
|
|
2688
2703
|
if (!Array.isArray(t.roster) || t.roster.length > 4096) throw Error("Invalid replay roster");
|
|
2689
2704
|
n = t.initial.tick;
|
|
2690
2705
|
for (let e of t.roster) {
|
|
2691
|
-
if (!Number.isInteger(e.tick) || e.tick < n || e.tick > t.end || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > 31 || e.name !== null && (typeof e.name != "string" || e.name.length > 24) || e.avatar !== void 0 && !
|
|
2706
|
+
if (!Number.isInteger(e.tick) || e.tick < n || e.tick > t.end || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > 31 || e.name !== null && (typeof e.name != "string" || e.name.length > 24) || e.avatar !== void 0 && !Se(e.avatar)) throw Error("Invalid roster event");
|
|
2692
2707
|
n = e.tick;
|
|
2693
2708
|
}
|
|
2694
2709
|
if (t.styles !== void 0) {
|
|
@@ -2696,7 +2711,7 @@ function ct(e) {
|
|
|
2696
2711
|
let e = t.initial.tick;
|
|
2697
2712
|
for (let n of t.styles) {
|
|
2698
2713
|
if (!n || !Number.isInteger(n.tick) || n.tick < e || n.tick > t.end || n.teams === void 0) throw Error("Invalid replay style");
|
|
2699
|
-
n.teams =
|
|
2714
|
+
n.teams = ye(n.teams), e = n.tick;
|
|
2700
2715
|
}
|
|
2701
2716
|
}
|
|
2702
2717
|
if (t.orders !== void 0) {
|
|
@@ -2714,7 +2729,7 @@ function ct(e) {
|
|
|
2714
2729
|
}
|
|
2715
2730
|
return t;
|
|
2716
2731
|
}
|
|
2717
|
-
var
|
|
2732
|
+
var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
|
|
2718
2733
|
io;
|
|
2719
2734
|
state = "admitted";
|
|
2720
2735
|
currentEpoch = 0;
|
|
@@ -2727,7 +2742,7 @@ var lt = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, ut = class {
|
|
|
2727
2742
|
timerVersion = 0;
|
|
2728
2743
|
transport;
|
|
2729
2744
|
constructor(e, t) {
|
|
2730
|
-
if (this.io = e, !
|
|
2745
|
+
if (this.io = e, !ft(t)) throw RangeError("Invalid membership duration");
|
|
2731
2746
|
this.membershipDeadline = e.now() + t, this.arm();
|
|
2732
2747
|
}
|
|
2733
2748
|
get epoch() {
|
|
@@ -2740,16 +2755,18 @@ var lt = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, ut = class {
|
|
|
2740
2755
|
e !== this.currentEpoch || this.terminal() || this.checkExpiry() || (this.state === "admitted" ? (this.recoveryDeadline = Math.min(this.io.now() + 3e4, this.membershipDeadline), this.attemptId = this.io.newAttemptId(), this.retry = 0, this.wait()) : (this.state === "connecting" || this.state === "awaiting-ack") && this.wait());
|
|
2741
2756
|
}
|
|
2742
2757
|
acknowledge(e, t) {
|
|
2743
|
-
if (e !== this.currentEpoch || this.state !== "awaiting-ack" || t !== void 0 && !
|
|
2758
|
+
if (e !== this.currentEpoch || this.state !== "awaiting-ack" || t !== void 0 && !ft(t) || this.checkExpiry() || this.checkAttemptTimeout()) return !1;
|
|
2744
2759
|
t !== void 0 && (this.membershipDeadline = Math.min(this.membershipDeadline, this.io.now() + t));
|
|
2745
|
-
let n =
|
|
2746
|
-
|
|
2760
|
+
let n = this.attemptId;
|
|
2761
|
+
if (n === void 0) return !1;
|
|
2762
|
+
let r = {
|
|
2763
|
+
attemptId: n,
|
|
2747
2764
|
epoch: e
|
|
2748
2765
|
};
|
|
2749
|
-
return this.state = "admitted", this.recoveryDeadline = Infinity, this.phaseDeadline = Infinity, this.attemptId = void 0, this.retry = 0, this.arm(), this.io.onRecovered(
|
|
2766
|
+
return this.state = "admitted", this.recoveryDeadline = Infinity, this.phaseDeadline = Infinity, this.attemptId = void 0, this.retry = 0, this.arm(), this.io.onRecovered(r), !0;
|
|
2750
2767
|
}
|
|
2751
2768
|
heartbeat(e, t) {
|
|
2752
|
-
return e !== this.currentEpoch || this.state !== "admitted" || !
|
|
2769
|
+
return e !== this.currentEpoch || this.state !== "admitted" || !ft(t) || this.checkExpiry() ? !1 : (this.membershipDeadline = this.io.now() + t, this.arm(), !0);
|
|
2753
2770
|
}
|
|
2754
2771
|
cancel() {
|
|
2755
2772
|
this.terminal() || (this.state = "cancelled", this.clearTimer(), this.retire());
|
|
@@ -2795,42 +2812,44 @@ var lt = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, ut = class {
|
|
|
2795
2812
|
}
|
|
2796
2813
|
attempt() {
|
|
2797
2814
|
if (this.checkExpiry()) return;
|
|
2815
|
+
let e = this.attemptId;
|
|
2816
|
+
if (e === void 0) throw Error("Recovery attempt identity is unavailable");
|
|
2798
2817
|
this.state = "connecting";
|
|
2799
|
-
let
|
|
2818
|
+
let t = ++this.currentEpoch;
|
|
2800
2819
|
this.phaseDeadline = this.io.now() + 5e3, this.arm();
|
|
2801
|
-
let
|
|
2820
|
+
let n;
|
|
2802
2821
|
try {
|
|
2803
|
-
|
|
2804
|
-
attemptId:
|
|
2805
|
-
epoch:
|
|
2822
|
+
n = this.io.createAttempt({
|
|
2823
|
+
attemptId: e,
|
|
2824
|
+
epoch: t
|
|
2806
2825
|
}, {
|
|
2807
2826
|
opened: () => {
|
|
2808
|
-
|
|
2827
|
+
t !== this.currentEpoch || this.state !== "connecting" || this.checkExpiry() || this.checkAttemptTimeout() || (this.state = "awaiting-ack");
|
|
2809
2828
|
},
|
|
2810
|
-
closed: () => this.disconnected(
|
|
2829
|
+
closed: () => this.disconnected(t)
|
|
2811
2830
|
});
|
|
2812
2831
|
} catch {
|
|
2813
|
-
|
|
2832
|
+
t === this.currentEpoch && this.disconnected(t);
|
|
2814
2833
|
return;
|
|
2815
2834
|
}
|
|
2816
|
-
if (
|
|
2835
|
+
if (t === this.currentEpoch && (this.state === "connecting" || this.state === "awaiting-ack" || this.state === "admitted")) this.transport = n;
|
|
2817
2836
|
else try {
|
|
2818
|
-
|
|
2837
|
+
n.close();
|
|
2819
2838
|
} catch {}
|
|
2820
2839
|
}
|
|
2821
|
-
};
|
|
2822
|
-
function
|
|
2840
|
+
}, mt = 2, ht = 9e4, gt = 33;
|
|
2841
|
+
function _t(e, t) {
|
|
2823
2842
|
return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === t.length && t.every((t) => Object.hasOwn(e, t));
|
|
2824
2843
|
}
|
|
2825
|
-
var
|
|
2826
|
-
function
|
|
2827
|
-
return !
|
|
2844
|
+
var vt = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(e), yt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), bt = (e, t) => Number.isSafeInteger(e) && e >= t, xt = (e) => bt(e, 1) && e <= ht, St = (e) => e === "host" || e === "guest";
|
|
2845
|
+
function Ct(e) {
|
|
2846
|
+
return !_t(e, [
|
|
2828
2847
|
"version",
|
|
2829
2848
|
"roomGeneration",
|
|
2830
2849
|
"secret",
|
|
2831
2850
|
"connectionEpoch",
|
|
2832
2851
|
"membershipValidForMs"
|
|
2833
|
-
]) || e.version !==
|
|
2852
|
+
]) || e.version !== mt || !vt(e.roomGeneration) || !yt(e.secret) || !bt(e.connectionEpoch, 1) || !xt(e.membershipValidForMs) ? null : {
|
|
2834
2853
|
version: 2,
|
|
2835
2854
|
roomGeneration: e.roomGeneration,
|
|
2836
2855
|
secret: e.secret,
|
|
@@ -2838,8 +2857,8 @@ function _t(e) {
|
|
|
2838
2857
|
membershipValidForMs: e.membershipValidForMs
|
|
2839
2858
|
};
|
|
2840
2859
|
}
|
|
2841
|
-
function
|
|
2842
|
-
if (!
|
|
2860
|
+
function wt(e) {
|
|
2861
|
+
if (!_t(e, [
|
|
2843
2862
|
"type",
|
|
2844
2863
|
"version",
|
|
2845
2864
|
"roomGeneration",
|
|
@@ -2853,9 +2872,9 @@ function vt(e) {
|
|
|
2853
2872
|
"members",
|
|
2854
2873
|
"requireVerification",
|
|
2855
2874
|
"locked"
|
|
2856
|
-
]) || e.type !== "resumed" || e.version !==
|
|
2857
|
-
let t =
|
|
2858
|
-
return
|
|
2875
|
+
]) || e.type !== "resumed" || e.version !== mt || !vt(e.roomGeneration) || !vt(e.attemptId) || !vt(e.id) || !vt(e.hostId) || !St(e.role) || !bt(e.connectionEpoch, 1) || !xt(e.membershipValidForMs) || !bt(e.rosterRevision, 0) || typeof e.requireVerification != "boolean" || typeof e.locked != "boolean" || !Array.isArray(e.members) || e.members.length < 1 || e.members.length > gt) return null;
|
|
2876
|
+
let t = Et(e.members, e.hostId);
|
|
2877
|
+
return t?.some((t) => t.id === e.id && t.role === e.role && t.attached && t.connectionEpoch === e.connectionEpoch) ? {
|
|
2859
2878
|
type: "resumed",
|
|
2860
2879
|
version: 2,
|
|
2861
2880
|
roomGeneration: e.roomGeneration,
|
|
@@ -2869,10 +2888,10 @@ function vt(e) {
|
|
|
2869
2888
|
members: t,
|
|
2870
2889
|
requireVerification: e.requireVerification,
|
|
2871
2890
|
locked: e.locked
|
|
2872
|
-
};
|
|
2891
|
+
} : null;
|
|
2873
2892
|
}
|
|
2874
|
-
function
|
|
2875
|
-
if (!
|
|
2893
|
+
function Tt(e) {
|
|
2894
|
+
if (!_t(e, [
|
|
2876
2895
|
"type",
|
|
2877
2896
|
"id",
|
|
2878
2897
|
"hostId",
|
|
@@ -2883,9 +2902,9 @@ function yt(e) {
|
|
|
2883
2902
|
"requireVerification",
|
|
2884
2903
|
"locked"
|
|
2885
2904
|
]) || e.type !== "ready") return null;
|
|
2886
|
-
let t =
|
|
2905
|
+
let t = Ct(e.resumeGrant);
|
|
2887
2906
|
if (!t) return null;
|
|
2888
|
-
let n =
|
|
2907
|
+
let n = wt({
|
|
2889
2908
|
type: "resumed",
|
|
2890
2909
|
version: 2,
|
|
2891
2910
|
roomGeneration: t.roomGeneration,
|
|
@@ -2912,16 +2931,16 @@ function yt(e) {
|
|
|
2912
2931
|
locked: n.locked
|
|
2913
2932
|
} : null;
|
|
2914
2933
|
}
|
|
2915
|
-
function
|
|
2916
|
-
if (!Array.isArray(e) || e.length < 1 || e.length >
|
|
2934
|
+
function Et(e, t) {
|
|
2935
|
+
if (!Array.isArray(e) || e.length < 1 || e.length > gt) return null;
|
|
2917
2936
|
let n = [], r = /* @__PURE__ */ new Set();
|
|
2918
2937
|
for (let t of e) {
|
|
2919
|
-
if (!
|
|
2938
|
+
if (!_t(t, [
|
|
2920
2939
|
"id",
|
|
2921
2940
|
"role",
|
|
2922
2941
|
"attached",
|
|
2923
2942
|
"connectionEpoch"
|
|
2924
|
-
]) || !
|
|
2943
|
+
]) || !vt(t.id) || !St(t.role) || typeof t.attached != "boolean" || !bt(t.connectionEpoch, 1) || r.has(t.id)) return null;
|
|
2925
2944
|
r.add(t.id), n.push({
|
|
2926
2945
|
id: t.id,
|
|
2927
2946
|
role: t.role,
|
|
@@ -2932,15 +2951,15 @@ function bt(e, t) {
|
|
|
2932
2951
|
let i = n.filter((e) => e.role === "host");
|
|
2933
2952
|
return i.length === 1 && i[0].id === t ? n : null;
|
|
2934
2953
|
}
|
|
2935
|
-
function
|
|
2936
|
-
if (!
|
|
2954
|
+
function Dt(e) {
|
|
2955
|
+
if (!_t(e, [
|
|
2937
2956
|
"type",
|
|
2938
2957
|
"roomGeneration",
|
|
2939
2958
|
"hostId",
|
|
2940
2959
|
"rosterRevision",
|
|
2941
2960
|
"members"
|
|
2942
|
-
]) || e.type !== "roster" || !
|
|
2943
|
-
let t =
|
|
2961
|
+
]) || e.type !== "roster" || !vt(e.roomGeneration) || !vt(e.hostId) || !bt(e.rosterRevision, 0)) return null;
|
|
2962
|
+
let t = Et(e.members, e.hostId);
|
|
2944
2963
|
return t ? {
|
|
2945
2964
|
type: "roster",
|
|
2946
2965
|
roomGeneration: e.roomGeneration,
|
|
@@ -2949,31 +2968,31 @@ function xt(e) {
|
|
|
2949
2968
|
members: t
|
|
2950
2969
|
} : null;
|
|
2951
2970
|
}
|
|
2952
|
-
function
|
|
2971
|
+
function Ot(e) {
|
|
2953
2972
|
let t = [...e], n = new Set(t.filter((e) => e.type === "transport" && e.selectedCandidatePairId).map((e) => e.selectedCandidatePairId)), r = t.filter((e) => e.type === "candidate-pair" && e.state === "succeeded"), i = n.size ? r.filter((e) => n.has(e.id)) : r.filter((e) => e.nominated === !0);
|
|
2954
2973
|
if (i.length !== 1) return null;
|
|
2955
2974
|
let a = i[0].currentRoundTripTime;
|
|
2956
2975
|
return typeof a == "number" && Number.isFinite(a) && a >= 0 ? a * 1e3 : null;
|
|
2957
2976
|
}
|
|
2958
|
-
var
|
|
2959
|
-
function
|
|
2977
|
+
var kt = 524288, At = 16384, jt = 12;
|
|
2978
|
+
function Mt(e, t) {
|
|
2960
2979
|
let n = JSON.stringify(e);
|
|
2961
2980
|
if (n === void 0) throw Error("Missing control message");
|
|
2962
2981
|
let r = new TextEncoder().encode(n);
|
|
2963
|
-
if (r.length >
|
|
2964
|
-
if (r.length <=
|
|
2965
|
-
let i = Math.ceil(r.length /
|
|
2982
|
+
if (r.length > kt) throw Error("Control message exceeds 512 KB");
|
|
2983
|
+
if (r.length <= At) return [n];
|
|
2984
|
+
let i = Math.ceil(r.length / At), a = [];
|
|
2966
2985
|
for (let e = 0; e < i; e++) {
|
|
2967
|
-
let n = r.subarray(e *
|
|
2968
|
-
s.setUint16(0, 45635), s.setUint8(2, 1), s.setUint32(4, t, !0), s.setUint16(8, e, !0), s.setUint16(10, i, !0), new Uint8Array(o,
|
|
2986
|
+
let n = r.subarray(e * At, (e + 1) * At), o = new ArrayBuffer(jt + n.length), s = new DataView(o);
|
|
2987
|
+
s.setUint16(0, 45635), s.setUint8(2, 1), s.setUint32(4, t, !0), s.setUint16(8, e, !0), s.setUint16(10, i, !0), new Uint8Array(o, jt).set(n), a.push(o);
|
|
2969
2988
|
}
|
|
2970
2989
|
return a;
|
|
2971
2990
|
}
|
|
2972
|
-
var
|
|
2991
|
+
var Nt = class {
|
|
2973
2992
|
partial;
|
|
2974
2993
|
push(e, t = performance.now()) {
|
|
2975
2994
|
if (typeof e == "string") {
|
|
2976
|
-
if (this.partial || new TextEncoder().encode(e).length >
|
|
2995
|
+
if (this.partial || new TextEncoder().encode(e).length > At) throw Error("Invalid control message");
|
|
2977
2996
|
return JSON.parse(e);
|
|
2978
2997
|
}
|
|
2979
2998
|
if (e.byteLength < 13 || e.byteLength > 16396) throw Error("Control fragment length");
|
|
@@ -2994,13 +3013,13 @@ var Dt = class {
|
|
|
2994
3013
|
}
|
|
2995
3014
|
let o = this.partial;
|
|
2996
3015
|
if (o.id !== r || o.count !== a || o.next !== i || t - o.since > 1e4) throw Error("Control fragment sequence");
|
|
2997
|
-
if (o.next++, o.bytes += e.byteLength -
|
|
2998
|
-
if (o.parts.push(new Uint8Array(e.slice(
|
|
3016
|
+
if (o.next++, o.bytes += e.byteLength - jt, o.bytes > kt) throw Error("Control size limit");
|
|
3017
|
+
if (o.parts.push(new Uint8Array(e.slice(jt))), o.next !== a) return;
|
|
2999
3018
|
let s = new Uint8Array(o.bytes), c = 0;
|
|
3000
3019
|
for (let e of o.parts) s.set(e, c), c += e.length;
|
|
3001
3020
|
return this.partial = void 0, JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(s));
|
|
3002
3021
|
}
|
|
3003
|
-
},
|
|
3022
|
+
}, Pt = class extends Error {}, Ft = 1, It = (e) => typeof e == "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e), Lt = (e) => Number.isSafeInteger(e) && e > 0, Rt = (e) => e?.match(/(?:^|\r?\n)a=ice-ufrag:([^\s]+)/)?.[1], zt = (e) => e.usernameFragment ?? e.candidate?.match(/(?:^| )ufrag ([^ ]+)/)?.[1], Bt = class {
|
|
3004
3023
|
room;
|
|
3005
3024
|
credentials;
|
|
3006
3025
|
hooks;
|
|
@@ -3051,13 +3070,14 @@ var Dt = class {
|
|
|
3051
3070
|
sendHeartbeat() {
|
|
3052
3071
|
let e = this.heartbeatDeadline - performance.now();
|
|
3053
3072
|
if (!this.signalingReady || !this.resumeGrant || !this.recovery || e <= 0) return;
|
|
3054
|
-
|
|
3073
|
+
this.heartbeatRequest ??= {
|
|
3055
3074
|
id: ++this.heartbeatSequence,
|
|
3056
3075
|
sentAt: performance.now(),
|
|
3057
3076
|
localEpoch: this.recovery.epoch,
|
|
3058
3077
|
transmissions: 0,
|
|
3059
3078
|
retryDelay: Math.max(1, Math.floor(Math.min(5e3, e / 3)))
|
|
3060
3079
|
};
|
|
3080
|
+
let t = this.heartbeatRequest;
|
|
3061
3081
|
if (!(t.transmissions >= 3)) {
|
|
3062
3082
|
t.transmissions++;
|
|
3063
3083
|
try {
|
|
@@ -3071,7 +3091,7 @@ var Dt = class {
|
|
|
3071
3091
|
}
|
|
3072
3092
|
}
|
|
3073
3093
|
get signalingReady() {
|
|
3074
|
-
return !this.closed && !!this.id && this.ws.readyState ===
|
|
3094
|
+
return !this.closed && !!this.id && this.ws.readyState === Ft && this.signalingAdmitted;
|
|
3075
3095
|
}
|
|
3076
3096
|
get signalingAdmitted() {
|
|
3077
3097
|
return !this.recovery || this.recovery.status === "admitted";
|
|
@@ -3088,7 +3108,7 @@ var Dt = class {
|
|
|
3088
3108
|
n && (this.verificationRequest = void 0, clearTimeout(n.timer), t && (this.verificationState = null), n.reject(Error(e)));
|
|
3089
3109
|
}
|
|
3090
3110
|
setRequireVerification(e) {
|
|
3091
|
-
return typeof e == "boolean" ? this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !==
|
|
3111
|
+
return typeof e == "boolean" ? this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Ft ? Promise.reject(Error("An active room-owner connection is required.")) : this.verificationRequest ? Promise.reject(Error("A verification update is already pending.")) : new Promise((t, n) => {
|
|
3092
3112
|
let r = ++this.verificationSequence, i = setTimeout(() => this.rejectVerification("Verification update was not confirmed."), 1e4);
|
|
3093
3113
|
this.verificationRequest = {
|
|
3094
3114
|
id: r,
|
|
@@ -3114,7 +3134,7 @@ var Dt = class {
|
|
|
3114
3134
|
t && (this.passwordRequest = void 0, clearTimeout(t.timer), t.reject(Error(e)));
|
|
3115
3135
|
}
|
|
3116
3136
|
setPassword(e) {
|
|
3117
|
-
return e !== null && (typeof e != "string" || e.length > 64) ? Promise.reject(Error("Password must contain at most 64 characters.")) : this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !==
|
|
3137
|
+
return e !== null && (typeof e != "string" || e.length > 64) ? Promise.reject(Error("Password must contain at most 64 characters.")) : this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Ft ? Promise.reject(Error("An active room-owner connection is required.")) : this.passwordRequest ? Promise.reject(Error("A password update is already pending.")) : new Promise((t, n) => {
|
|
3118
3138
|
let r = ++this.passwordRequestId, i = setTimeout(() => this.rejectPasswordUpdate("Password update was not confirmed."), 1e4);
|
|
3119
3139
|
this.passwordRequest = {
|
|
3120
3140
|
id: r,
|
|
@@ -3137,10 +3157,10 @@ var Dt = class {
|
|
|
3137
3157
|
banRequest;
|
|
3138
3158
|
rejectBan(e, t = !0) {
|
|
3139
3159
|
let n = this.banRequest;
|
|
3140
|
-
n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new
|
|
3160
|
+
n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new Pt(e) : Error(e)));
|
|
3141
3161
|
}
|
|
3142
3162
|
updateBan(e, t) {
|
|
3143
|
-
return this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !==
|
|
3163
|
+
return this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Ft ? Promise.reject(Error("An active room-owner connection is required.")) : this.banRequest ? Promise.reject(Error("A ban operation is already pending.")) : new Promise((n, r) => {
|
|
3144
3164
|
let i = ++this.banSequence, a = setTimeout(() => this.rejectBan("Ban operation was not confirmed."), 1e4);
|
|
3145
3165
|
this.banRequest = {
|
|
3146
3166
|
id: i,
|
|
@@ -3167,9 +3187,9 @@ var Dt = class {
|
|
|
3167
3187
|
lastHeartbeat = 0;
|
|
3168
3188
|
controlId = 0;
|
|
3169
3189
|
controlAssemblers = /* @__PURE__ */ new Map();
|
|
3170
|
-
constructor(e, t, n, r =
|
|
3190
|
+
constructor(e, t, n, r = We()) {
|
|
3171
3191
|
this.room = e, this.credentials = t, this.hooks = n, this.runtime = r;
|
|
3172
|
-
let i = new URL(
|
|
3192
|
+
let i = new URL(u.signal(e), Ue(r.serviceOrigin));
|
|
3173
3193
|
i.protocol = i.protocol === "https:" ? "wss:" : "ws:", this.ws = r.createWebSocket(i), this.attachSocket(this.ws, () => {
|
|
3174
3194
|
this.requestSentAt = performance.now(), this.signal({
|
|
3175
3195
|
type: "hello",
|
|
@@ -3177,7 +3197,7 @@ var Dt = class {
|
|
|
3177
3197
|
...r.signalingResume ? { signalingVersion: 2 } : {}
|
|
3178
3198
|
});
|
|
3179
3199
|
}, 0), this.timer = setInterval(() => {
|
|
3180
|
-
!this.resumeGrant && this.signalingAdmitted && this.ws.readyState ===
|
|
3200
|
+
!this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Ft && performance.now() - this.lastHeartbeat >= 3e4 && (this.signal({ type: "heartbeat" }), this.lastHeartbeat = performance.now());
|
|
3181
3201
|
for (let e of this.peers.values()) {
|
|
3182
3202
|
if (!e.connected && performance.now() - e.created > 2e4) {
|
|
3183
3203
|
n.status("Direct connection failed. This network pair may require a relay; this game does not use TURN."), this.remove(e.id);
|
|
@@ -3227,7 +3247,7 @@ var Dt = class {
|
|
|
3227
3247
|
this.close(), this.hooks.ended?.("Room membership expired.");
|
|
3228
3248
|
return;
|
|
3229
3249
|
}
|
|
3230
|
-
this.resumeGrant = e, this.recovery = new
|
|
3250
|
+
this.resumeGrant = e, this.recovery = new pt({
|
|
3231
3251
|
now: () => performance.now(),
|
|
3232
3252
|
setTimer: (e, t) => setTimeout(e, t),
|
|
3233
3253
|
clearTimer: (e) => clearTimeout(e),
|
|
@@ -3235,18 +3255,20 @@ var Dt = class {
|
|
|
3235
3255
|
newAttemptId: () => crypto.randomUUID(),
|
|
3236
3256
|
createAttempt: (e, t) => {
|
|
3237
3257
|
this.resumeAttempt = e;
|
|
3238
|
-
let n = new URL(
|
|
3258
|
+
let n = new URL(u.signal(this.room), Ue(this.runtime.serviceOrigin));
|
|
3239
3259
|
n.protocol = n.protocol === "https:" ? "wss:" : "ws:";
|
|
3240
3260
|
let r = this.runtime.createWebSocket(n);
|
|
3241
3261
|
return this.ws = r, this.attachSocket(r, () => {
|
|
3242
|
-
t.opened()
|
|
3262
|
+
t.opened();
|
|
3263
|
+
let n = this.resumeGrant;
|
|
3264
|
+
this.recovery?.status === "awaiting-ack" && n && (this.requestSentAt = performance.now(), r.send(JSON.stringify({
|
|
3243
3265
|
type: "resume",
|
|
3244
3266
|
version: 2,
|
|
3245
|
-
roomGeneration:
|
|
3267
|
+
roomGeneration: n.roomGeneration,
|
|
3246
3268
|
peerId: this.id,
|
|
3247
|
-
secret:
|
|
3269
|
+
secret: n.secret,
|
|
3248
3270
|
attemptId: e.attemptId,
|
|
3249
|
-
expectedEpoch:
|
|
3271
|
+
expectedEpoch: n.connectionEpoch
|
|
3250
3272
|
})));
|
|
3251
3273
|
}, e.epoch), { close: () => {
|
|
3252
3274
|
this.ws === r && this.socketSerial++, r.onopen = null, r.onmessage = null, r.onclose = null, r.onerror = null, r.close();
|
|
@@ -3259,12 +3281,12 @@ var Dt = class {
|
|
|
3259
3281
|
}, t), this.scheduleHeartbeat(t, !0);
|
|
3260
3282
|
}
|
|
3261
3283
|
signal(e) {
|
|
3262
|
-
!this.closed && this.signalingAdmitted && this.ws.readyState ===
|
|
3284
|
+
!this.closed && this.signalingAdmitted && this.ws.readyState === Ft && this.ws.send(JSON.stringify(e));
|
|
3263
3285
|
}
|
|
3264
3286
|
async message(e, t = this.socketSerial) {
|
|
3265
3287
|
if (this.closed || t !== this.socketSerial) return;
|
|
3266
3288
|
if (e.type === "resumed") {
|
|
3267
|
-
let n =
|
|
3289
|
+
let n = wt(e), r = this.resumeGrant, i = this.resumeAttempt;
|
|
3268
3290
|
if (!n || !r || !i || !this.recovery || n.roomGeneration !== r.roomGeneration || n.attemptId !== i.attemptId || n.id !== this.id || n.hostId !== this.hostId || n.role === "host" !== this.host || n.connectionEpoch <= r.connectionEpoch || n.rosterRevision < this.rosterRevision || n.members.some((e) => e.connectionEpoch < (this.members.get(e.id)?.connectionEpoch ?? 0))) return;
|
|
3269
3291
|
let a = Math.floor(n.membershipValidForMs - (performance.now() - this.requestSentAt));
|
|
3270
3292
|
if (a <= 0 || !this.recovery.acknowledge(i.epoch, a)) return;
|
|
@@ -3277,17 +3299,17 @@ var Dt = class {
|
|
|
3277
3299
|
}
|
|
3278
3300
|
if (e.type === "heartbeat" && this.resumeGrant && this.recovery) {
|
|
3279
3301
|
let t = this.heartbeatRequest;
|
|
3280
|
-
if (!t || e.requestId !== t.id || e.connectionEpoch !== this.resumeGrant.connectionEpoch || !Number.isSafeInteger(e.membershipValidForMs) || e.membershipValidForMs < 1 || e.membershipValidForMs > 9e4) return;
|
|
3302
|
+
if (!t || e.requestId !== t.id || e.connectionEpoch !== this.resumeGrant.connectionEpoch || typeof e.membershipValidForMs != "number" || !Number.isSafeInteger(e.membershipValidForMs) || e.membershipValidForMs < 1 || e.membershipValidForMs > 9e4) return;
|
|
3281
3303
|
let n = Math.floor(e.membershipValidForMs - (performance.now() - t.sentAt));
|
|
3282
3304
|
n > 0 && this.recovery.heartbeat(t.localEpoch, n) && this.scheduleHeartbeat(n, !0);
|
|
3283
3305
|
return;
|
|
3284
3306
|
}
|
|
3285
3307
|
if (this.recovery && !this.signalingAdmitted) return;
|
|
3286
3308
|
if (e.type === "roster" && this.resumeGrant) {
|
|
3287
|
-
let n =
|
|
3309
|
+
let n = Dt(e);
|
|
3288
3310
|
if (!n || n.roomGeneration !== this.resumeGrant.roomGeneration || n.hostId !== this.hostId || n.rosterRevision <= this.rosterRevision) return;
|
|
3289
3311
|
let r = n.members.find((e) => e.id === this.id);
|
|
3290
|
-
if (!r
|
|
3312
|
+
if (!r?.attached || r.connectionEpoch !== this.resumeGrant.connectionEpoch || r.role === "host" !== this.host) {
|
|
3291
3313
|
this.close(), this.hooks.ended?.("Room membership ended.");
|
|
3292
3314
|
return;
|
|
3293
3315
|
}
|
|
@@ -3316,7 +3338,7 @@ var Dt = class {
|
|
|
3316
3338
|
siteKey: e.siteKey,
|
|
3317
3339
|
roomId: this.room
|
|
3318
3340
|
}, t.signal);
|
|
3319
|
-
if (t.signal.aborted || this.closed || this.ws.readyState !==
|
|
3341
|
+
if (t.signal.aborted || this.closed || this.ws.readyState !== Ft) return;
|
|
3320
3342
|
if (typeof n != "string" || n.length === 0 || n.length > 2048) throw Error("Invalid verification response.");
|
|
3321
3343
|
this.requestSentAt = performance.now(), this.signal({
|
|
3322
3344
|
type: "hello",
|
|
@@ -3355,7 +3377,7 @@ var Dt = class {
|
|
|
3355
3377
|
if (e.type === "ready") {
|
|
3356
3378
|
if (this.id) return;
|
|
3357
3379
|
if (this.runtime.signalingResume && e.resumeGrant !== void 0) {
|
|
3358
|
-
let t =
|
|
3380
|
+
let t = Tt(e);
|
|
3359
3381
|
if (!t) {
|
|
3360
3382
|
this.close(), this.hooks.ended?.("Invalid room admission.");
|
|
3361
3383
|
return;
|
|
@@ -3368,7 +3390,7 @@ var Dt = class {
|
|
|
3368
3390
|
}
|
|
3369
3391
|
if (e.type === "peer" || e.type === "leave") {
|
|
3370
3392
|
if (this.resumeGrant) {
|
|
3371
|
-
if (!
|
|
3393
|
+
if (!It(e.id) || !Lt(e.connectionEpoch) || typeof e.rosterRevision != "number" || !Number.isSafeInteger(e.rosterRevision) || e.rosterRevision <= this.rosterRevision || e.id === this.id) return;
|
|
3372
3394
|
let t = this.members.get(e.id);
|
|
3373
3395
|
if (t && e.connectionEpoch < t.connectionEpoch) return;
|
|
3374
3396
|
this.rosterRevision = e.rosterRevision, e.type === "peer" ? this.members.set(e.id, {
|
|
@@ -3385,51 +3407,52 @@ var Dt = class {
|
|
|
3385
3407
|
this.host && !this.peers.has(e.id) && await this.offerPeer(e.id, t);
|
|
3386
3408
|
return;
|
|
3387
3409
|
}
|
|
3388
|
-
if (e.type !== "signal" || this.resumeGrant && (!
|
|
3410
|
+
if (e.type !== "signal" || this.resumeGrant && (!It(e.negotiationId) || e.toConnectionEpoch !== this.resumeGrant.connectionEpoch || e.fromConnectionEpoch !== this.members.get(e.from)?.connectionEpoch || !this.members.get(e.from)?.attached)) return;
|
|
3389
3411
|
let n = this.peers.get(e.from);
|
|
3390
3412
|
if (!n) {
|
|
3391
3413
|
if (this.host || e.from !== this.hostId || !["offer", "candidate"].includes(e.signal.type)) return;
|
|
3392
3414
|
n = this.make(e.from);
|
|
3393
3415
|
}
|
|
3394
3416
|
if (this.resumeGrant) {
|
|
3417
|
+
if (!It(e.negotiationId)) return;
|
|
3395
3418
|
if (e.signal.type === "offer") {
|
|
3396
|
-
if (this.host || !
|
|
3397
|
-
n.negotiationId !== e.negotiationId && (n.candidates = []), this.beginNegotiation(n, e.negotiationId), n.remoteIceUfrag =
|
|
3419
|
+
if (this.host || !Rt(e.signal.sdp)) return;
|
|
3420
|
+
n.negotiationId !== e.negotiationId && (n.candidates = []), this.beginNegotiation(n, e.negotiationId), n.remoteIceUfrag = Rt(e.signal.sdp), n.localIceUfrag = void 0;
|
|
3398
3421
|
} else if (e.signal.type === "candidate" && !n.negotiationId && !this.host) this.beginNegotiation(n, e.negotiationId);
|
|
3399
3422
|
else if (n.negotiationId !== e.negotiationId) return;
|
|
3400
3423
|
if (n.negotiationLocalEpoch !== e.toConnectionEpoch || n.negotiationRemoteEpoch !== e.fromConnectionEpoch) return;
|
|
3401
3424
|
if (e.signal.type === "answer") {
|
|
3402
|
-
if (!
|
|
3403
|
-
n.remoteIceUfrag =
|
|
3425
|
+
if (!Rt(e.signal.sdp)) return;
|
|
3426
|
+
n.remoteIceUfrag = Rt(e.signal.sdp);
|
|
3404
3427
|
}
|
|
3405
3428
|
}
|
|
3406
|
-
let r = n.negotiationId,
|
|
3429
|
+
let r = n, i = r.negotiationId, a = () => this.current(r) && t === this.socketSerial && this.signalingAdmitted && r.negotiationId === i && this.negotiationCurrent(r);
|
|
3407
3430
|
if (e.signal.type === "offer") {
|
|
3408
3431
|
if (this.host) throw Error("Only the host can offer");
|
|
3409
3432
|
if (await n.pc.setRemoteDescription({
|
|
3410
3433
|
type: "offer",
|
|
3411
3434
|
sdp: e.signal.sdp
|
|
3412
|
-
}), !
|
|
3435
|
+
}), !a() || (await this.flushCandidates(n, a), !a())) return;
|
|
3413
3436
|
let t = await n.pc.createAnswer();
|
|
3414
|
-
if (!
|
|
3437
|
+
if (!a() || (n.localIceUfrag = Rt(t.sdp), await n.pc.setLocalDescription(t), !a())) return;
|
|
3415
3438
|
this.peerSignal(n, {
|
|
3416
3439
|
type: "answer",
|
|
3417
|
-
sdp: n
|
|
3440
|
+
sdp: this.localSdp(n)
|
|
3418
3441
|
});
|
|
3419
3442
|
} else if (e.signal.type === "answer") {
|
|
3420
3443
|
if (!this.host) throw Error("Only guests can answer");
|
|
3421
3444
|
if (await n.pc.setRemoteDescription({
|
|
3422
3445
|
type: "answer",
|
|
3423
3446
|
sdp: e.signal.sdp
|
|
3424
|
-
}), !
|
|
3425
|
-
await this.flushCandidates(n,
|
|
3447
|
+
}), !a()) return;
|
|
3448
|
+
await this.flushCandidates(n, a), this.noteHealthy(n);
|
|
3426
3449
|
} else if (e.signal.type === "candidate" && e.signal.candidate) {
|
|
3427
|
-
if (this.resumeGrant && (!
|
|
3450
|
+
if (this.resumeGrant && (!zt(e.signal.candidate) || n.remoteIceUfrag && zt(e.signal.candidate) !== n.remoteIceUfrag)) return;
|
|
3428
3451
|
if (!n.pc.remoteDescription) this.queueCandidate(n, e.signal.candidate);
|
|
3429
3452
|
else try {
|
|
3430
3453
|
await n.pc.addIceCandidate(e.signal.candidate);
|
|
3431
3454
|
} catch {
|
|
3432
|
-
|
|
3455
|
+
a() && this.queueCandidate(n, e.signal.candidate);
|
|
3433
3456
|
}
|
|
3434
3457
|
}
|
|
3435
3458
|
}
|
|
@@ -3452,7 +3475,7 @@ var Dt = class {
|
|
|
3452
3475
|
type: "signal",
|
|
3453
3476
|
to: e.id,
|
|
3454
3477
|
signal: t,
|
|
3455
|
-
...n ? {
|
|
3478
|
+
...n && r ? {
|
|
3456
3479
|
fromConnectionEpoch: n.connectionEpoch,
|
|
3457
3480
|
toConnectionEpoch: r.connectionEpoch,
|
|
3458
3481
|
negotiationId: e.negotiationId
|
|
@@ -3466,11 +3489,16 @@ var Dt = class {
|
|
|
3466
3489
|
maxRetransmits: 0
|
|
3467
3490
|
})), this.resumeGrant && this.beginNegotiation(n, crypto.randomUUID());
|
|
3468
3491
|
let r = n.negotiationId, i = () => this.current(n) && t === this.socketSerial && this.signalingAdmitted && n.negotiationId === r && this.negotiationCurrent(n), a = await n.pc.createOffer();
|
|
3469
|
-
i() && (n.localIceUfrag =
|
|
3492
|
+
i() && (n.localIceUfrag = Rt(a.sdp), await n.pc.setLocalDescription(a), i() && this.peerSignal(n, {
|
|
3470
3493
|
type: "offer",
|
|
3471
|
-
sdp: n
|
|
3494
|
+
sdp: this.localSdp(n)
|
|
3472
3495
|
}));
|
|
3473
3496
|
}
|
|
3497
|
+
localSdp(e) {
|
|
3498
|
+
let t = e.pc.localDescription;
|
|
3499
|
+
if (!t) throw Error("Local peer description is unavailable");
|
|
3500
|
+
return t.sdp;
|
|
3501
|
+
}
|
|
3474
3502
|
current(e) {
|
|
3475
3503
|
return !this.closed && this.peers.get(e.id) === e;
|
|
3476
3504
|
}
|
|
@@ -3489,23 +3517,23 @@ var Dt = class {
|
|
|
3489
3517
|
let n = e.candidates.splice(0);
|
|
3490
3518
|
for (let r of n) {
|
|
3491
3519
|
if (!t()) return;
|
|
3492
|
-
if (!this.resumeGrant || e.remoteIceUfrag &&
|
|
3520
|
+
if (!this.resumeGrant || e.remoteIceUfrag && zt(r) === e.remoteIceUfrag) try {
|
|
3493
3521
|
await e.pc.addIceCandidate(r);
|
|
3494
3522
|
} catch {}
|
|
3495
3523
|
}
|
|
3496
3524
|
}
|
|
3497
3525
|
async restartPeer(e) {
|
|
3498
3526
|
let t = this.peers.get(e);
|
|
3499
|
-
if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || !this.signalingAdmitted || this.ws.readyState !==
|
|
3527
|
+
if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || !this.signalingAdmitted || this.ws.readyState !== Ft) return !1;
|
|
3500
3528
|
let n = this.socketSerial;
|
|
3501
3529
|
this.resumeGrant && (this.beginNegotiation(t, crypto.randomUUID()), t.localIceUfrag = void 0, t.remoteIceUfrag = void 0, t.candidates = []);
|
|
3502
3530
|
let r = t.negotiationId, i = () => this.current(t) && n === this.socketSerial && this.signalingAdmitted && t.negotiationId === r && this.negotiationCurrent(t);
|
|
3503
3531
|
t.restarting = !0, t.lastRestart = performance.now(), t.lostAt ??= t.lastRestart, t.restarts++;
|
|
3504
3532
|
try {
|
|
3505
3533
|
let e = await t.pc.createOffer({ iceRestart: !0 });
|
|
3506
|
-
return !i() || (t.localIceUfrag =
|
|
3534
|
+
return !i() || (t.localIceUfrag = Rt(e.sdp), await t.pc.setLocalDescription(e), !i()) ? !1 : (this.peerSignal(t, {
|
|
3507
3535
|
type: "offer",
|
|
3508
|
-
sdp: t
|
|
3536
|
+
sdp: this.localSdp(t)
|
|
3509
3537
|
}), !0);
|
|
3510
3538
|
} catch {
|
|
3511
3539
|
return !this.closed && this.peers.get(e) === t && this.hooks.status("Direct connection recovery is still pending."), !1;
|
|
@@ -3530,7 +3558,7 @@ var Dt = class {
|
|
|
3530
3558
|
this.peers.set(e, n), t.onicecandidate = (e) => {
|
|
3531
3559
|
if (!this.current(n) || !e.candidate || !this.signalingAdmitted) return;
|
|
3532
3560
|
let t = e.candidate.toJSON();
|
|
3533
|
-
(!this.resumeGrant || n.localIceUfrag &&
|
|
3561
|
+
(!this.resumeGrant || n.localIceUfrag && zt(t) === n.localIceUfrag) && this.peerSignal(n, {
|
|
3534
3562
|
type: "candidate",
|
|
3535
3563
|
candidate: t
|
|
3536
3564
|
});
|
|
@@ -3564,7 +3592,7 @@ var Dt = class {
|
|
|
3564
3592
|
if (this.host && t && !this.hooks.allowStadiumUpload?.(e)) throw Error("Guest control size or permission");
|
|
3565
3593
|
if (typeof n.data != "string" && !(n.data instanceof ArrayBuffer)) throw Error("Invalid control type");
|
|
3566
3594
|
let r = this.controlAssemblers.get(e.id);
|
|
3567
|
-
r || (r = new
|
|
3595
|
+
r || (r = new Nt(), this.controlAssemblers.set(e.id, r));
|
|
3568
3596
|
let i = r.push(n.data);
|
|
3569
3597
|
if (i !== void 0) {
|
|
3570
3598
|
if (this.host && t && (!i || typeof i != "object" || i.type !== "action" || i.action !== "customStadium")) throw Error("Invalid bulk action");
|
|
@@ -3583,7 +3611,7 @@ var Dt = class {
|
|
|
3583
3611
|
}
|
|
3584
3612
|
control(e, t) {
|
|
3585
3613
|
if (e.control?.readyState !== "open") return;
|
|
3586
|
-
let n =
|
|
3614
|
+
let n = Mt(t, this.controlId++), r = n.reduce((e, t) => e + (typeof t == "string" ? new TextEncoder().encode(t).length : t.byteLength), 0);
|
|
3587
3615
|
if (e.control.bufferedAmount + r > 1048576) {
|
|
3588
3616
|
this.remove(e.id);
|
|
3589
3617
|
return;
|
|
@@ -3608,7 +3636,7 @@ var Dt = class {
|
|
|
3608
3636
|
}
|
|
3609
3637
|
try {
|
|
3610
3638
|
let t = await e.pc.getStats();
|
|
3611
|
-
!this.closed && this.peers.get(e.id) === e && (e.rtt =
|
|
3639
|
+
!this.closed && this.peers.get(e.id) === e && (e.rtt = Ot(t.values()));
|
|
3612
3640
|
} catch {
|
|
3613
3641
|
e.rtt = null;
|
|
3614
3642
|
}
|
|
@@ -3627,7 +3655,7 @@ var Dt = class {
|
|
|
3627
3655
|
}
|
|
3628
3656
|
close() {
|
|
3629
3657
|
if (!this.closed) {
|
|
3630
|
-
this.resumeGrant && this.signalingAdmitted && this.ws.readyState ===
|
|
3658
|
+
this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Ft && this.signal({
|
|
3631
3659
|
type: "leave",
|
|
3632
3660
|
connectionEpoch: this.resumeGrant.connectionEpoch
|
|
3633
3661
|
}), this.recovery?.cancel(), this.resumeGrant = void 0, this.resumeAttempt = void 0, this.cancelHeartbeat(), this.socketSerial++, this.challenge?.abort(), this.rejectVerification("Room closed before verification confirmation."), this.verificationState = null, this.rejectBan("Room closed before ban confirmation."), this.rejectPasswordUpdate("Room closed before password confirmation."), this.closed = !0, clearInterval(this.timer), this.ws.close(1e3, "Left room");
|
|
@@ -3635,14 +3663,14 @@ var Dt = class {
|
|
|
3635
3663
|
this.peers.clear(), this.controlAssemblers.clear();
|
|
3636
3664
|
}
|
|
3637
3665
|
}
|
|
3638
|
-
};
|
|
3639
|
-
function
|
|
3666
|
+
}, Vt = 5;
|
|
3667
|
+
function Ht(e, t) {
|
|
3640
3668
|
return e !== t && e - t >>> 0 < 2147483648;
|
|
3641
3669
|
}
|
|
3642
|
-
function
|
|
3670
|
+
function Ut(e) {
|
|
3643
3671
|
if (e.byteLength !== 14) throw Error("Input length");
|
|
3644
3672
|
let t = new DataView(e);
|
|
3645
|
-
if (t.getUint8(0) !== 1 || t.getUint8(1) !==
|
|
3673
|
+
if (t.getUint8(0) !== 1 || t.getUint8(1) !== Vt || t.getUint8(6) > 31 || t.getUint8(7)) throw Error("Input format");
|
|
3646
3674
|
return {
|
|
3647
3675
|
seq: t.getUint32(2, !0),
|
|
3648
3676
|
keys: t.getUint8(6),
|
|
@@ -3650,7 +3678,7 @@ function It(e) {
|
|
|
3650
3678
|
epoch: t.getUint16(12, !0)
|
|
3651
3679
|
};
|
|
3652
3680
|
}
|
|
3653
|
-
function
|
|
3681
|
+
function Wt(e, t, n = 0) {
|
|
3654
3682
|
if (e.surface?.length) throw Error("Terrain transport is not enabled");
|
|
3655
3683
|
let r = [];
|
|
3656
3684
|
for (let t = 0; t < e.discs.length / 18; t++) {
|
|
@@ -3672,11 +3700,11 @@ function Lt(e, t, n = 0) {
|
|
|
3672
3700
|
let s = new Uint8Array(a), c = [], l = Math.ceil(s.length / 1188);
|
|
3673
3701
|
for (let t = 0; t < l; t++) {
|
|
3674
3702
|
let r = s.subarray(t * 1188, (t + 1) * 1188), i = new ArrayBuffer(12 + r.length), a = new DataView(i);
|
|
3675
|
-
a.setUint8(0, 2), a.setUint8(1,
|
|
3703
|
+
a.setUint8(0, 2), a.setUint8(1, Vt), a.setUint32(2, e.tick, !0), a.setUint8(6, t), a.setUint8(7, l), a.setUint16(8, n, !0), a.setUint16(10, r.length, !0), new Uint8Array(i, 12).set(r), c.push(i);
|
|
3676
3704
|
}
|
|
3677
3705
|
return c;
|
|
3678
3706
|
}
|
|
3679
|
-
var
|
|
3707
|
+
var Gt = Object.freeze({ ...De }), Kt = class e {
|
|
3680
3708
|
runtime;
|
|
3681
3709
|
engine;
|
|
3682
3710
|
network;
|
|
@@ -3702,10 +3730,11 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3702
3730
|
locked = !1;
|
|
3703
3731
|
teamStyles = [null, null];
|
|
3704
3732
|
inputs = /* @__PURE__ */ new Map();
|
|
3705
|
-
traffic = new
|
|
3733
|
+
traffic = new Ye();
|
|
3706
3734
|
onRoomLink;
|
|
3707
3735
|
onPlayerJoin;
|
|
3708
3736
|
onPlayerTeamChange;
|
|
3737
|
+
onPlayerMuteChange;
|
|
3709
3738
|
onPlayerAdminChange;
|
|
3710
3739
|
onGameStart;
|
|
3711
3740
|
onGameStop;
|
|
@@ -3744,17 +3773,17 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3744
3773
|
constructor(e, t) {
|
|
3745
3774
|
this.runtime = t, this.engine = e;
|
|
3746
3775
|
}
|
|
3747
|
-
static async create(t, n =
|
|
3748
|
-
let i =
|
|
3749
|
-
if (t =
|
|
3776
|
+
static async create(t, n = qe(), r) {
|
|
3777
|
+
let i = Ue(n.network.serviceOrigin);
|
|
3778
|
+
if (t = Q(t), t.noPlayer !== void 0 && typeof t.noPlayer != "boolean") throw Error("Invalid noPlayer setting");
|
|
3750
3779
|
let a = t.noPlayer === !1, o = t.playerName ?? "Host";
|
|
3751
3780
|
if (a && (typeof o != "string" || !o.trim() || o.length > 24)) throw Error("Invalid host player name");
|
|
3752
|
-
let s =
|
|
3781
|
+
let s = me(r), c;
|
|
3753
3782
|
try {
|
|
3754
3783
|
s.signal.throwIfAborted();
|
|
3755
3784
|
let r = await s.run(n.loadEngine(s.signal));
|
|
3756
|
-
r.load(t.stadium ??
|
|
3757
|
-
let l = c,
|
|
3785
|
+
r.load(t.stadium ?? Re()), c = new e(r, n);
|
|
3786
|
+
let l = c, d = await s.run(n.request(new URL(u.rooms, i), {
|
|
3758
3787
|
signal: s.signal,
|
|
3759
3788
|
method: "POST",
|
|
3760
3789
|
headers: { "Content-Type": "application/json" },
|
|
@@ -3766,13 +3795,13 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3766
3795
|
hostPlayer: a
|
|
3767
3796
|
})
|
|
3768
3797
|
}));
|
|
3769
|
-
if (!
|
|
3770
|
-
let
|
|
3771
|
-
l.roomId =
|
|
3772
|
-
let
|
|
3798
|
+
if (!d.ok) throw Error(`Room creation failed (${d.status})`);
|
|
3799
|
+
let f = await s.run(d.json());
|
|
3800
|
+
l.roomId = f.id, l.roomName = t.roomName, l.roomLink = `${i}${_e(f.id)}`;
|
|
3801
|
+
let p;
|
|
3773
3802
|
try {
|
|
3774
3803
|
await s.run(new Promise((e, t) => {
|
|
3775
|
-
|
|
3804
|
+
p = setTimeout(() => t(Error("Signaling timed out")), 12e3), l.network = new Bt(f.id, { hostToken: f.hostToken }, {
|
|
3776
3805
|
ready: (n, r) => {
|
|
3777
3806
|
if (!r) {
|
|
3778
3807
|
t(Error("Host authority was not granted"));
|
|
@@ -3785,7 +3814,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3785
3814
|
name: o.trim(),
|
|
3786
3815
|
team: 0,
|
|
3787
3816
|
admin: !0
|
|
3788
|
-
}), l.engine.joinPlayer(0)), clearTimeout(
|
|
3817
|
+
}), l.engine.joinPlayer(0)), clearTimeout(p), e();
|
|
3789
3818
|
},
|
|
3790
3819
|
allowStadiumUpload: (e) => !!l.players.find((t) => t.peerId === e.id)?.admin && ["lobby", "finished"].includes(l.engine.phase) && l.traffic.allow(e.id, "message"),
|
|
3791
3820
|
open: () => {},
|
|
@@ -3794,20 +3823,20 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3794
3823
|
leave: (e) => l.leave(e),
|
|
3795
3824
|
status: (e) => l.report(e),
|
|
3796
3825
|
ended: (e) => {
|
|
3797
|
-
clearTimeout(
|
|
3826
|
+
clearTimeout(p), t(Error(e)), l.close(), l.report(e);
|
|
3798
3827
|
}
|
|
3799
3828
|
}, n.network);
|
|
3800
3829
|
}));
|
|
3801
3830
|
} catch (e) {
|
|
3802
3831
|
throw l.close(), e;
|
|
3803
3832
|
} finally {
|
|
3804
|
-
clearTimeout(
|
|
3833
|
+
clearTimeout(p);
|
|
3805
3834
|
}
|
|
3806
3835
|
if (l.closed) throw Error("Room closed during startup");
|
|
3807
3836
|
l.last = performance.now(), l.loop = setInterval(() => l.advance(), 1e3 / 60);
|
|
3808
|
-
let
|
|
3837
|
+
let m = l.roomLink;
|
|
3809
3838
|
return l.linkNotification = setTimeout(() => {
|
|
3810
|
-
l.linkNotification = void 0, l.invoke("onRoomLink", l.onRoomLink,
|
|
3839
|
+
l.linkNotification = void 0, l.invoke("onRoomLink", l.onRoomLink, m);
|
|
3811
3840
|
}, 0), c;
|
|
3812
3841
|
} catch (e) {
|
|
3813
3842
|
throw c?.close(), e;
|
|
@@ -3842,13 +3871,13 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3842
3871
|
let e = this.engine.snapshot();
|
|
3843
3872
|
if (e.surface?.length) {
|
|
3844
3873
|
if (this.engine.tick % 6 == 0) {
|
|
3845
|
-
let t =
|
|
3874
|
+
let t = pe(e, this.epoch);
|
|
3846
3875
|
for (let e of this.network.peers.values()) e.control?.readyState === "open" && e.control.bufferedAmount < 65536 && this.network.control(e, {
|
|
3847
3876
|
...t,
|
|
3848
3877
|
ack: this.inputs.get(e.id)?.seq ?? 0
|
|
3849
3878
|
});
|
|
3850
3879
|
}
|
|
3851
|
-
} else for (let t of this.network.peers.values()) for (let n of
|
|
3880
|
+
} else for (let t of this.network.peers.values()) for (let n of Wt(e, this.inputs.get(t.id)?.seq ?? 0, this.epoch)) this.network.fast(t, n);
|
|
3852
3881
|
}
|
|
3853
3882
|
this.accumulator -= 1e3 / 60;
|
|
3854
3883
|
}
|
|
@@ -3863,7 +3892,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3863
3892
|
if (!this.allowed(e) || !t || typeof t != "object") return;
|
|
3864
3893
|
let n = t, r = this.players.find((t) => t.peerId === e.id);
|
|
3865
3894
|
if (n.type === "join" && !r) {
|
|
3866
|
-
if (n.version !== 1 || n.engine !==
|
|
3895
|
+
if (n.version !== 1 || n.engine !== ze || typeof n.name != "string" || !n.name.trim() || n.name.length > 24) {
|
|
3867
3896
|
this.network.remove(e.id);
|
|
3868
3897
|
return;
|
|
3869
3898
|
}
|
|
@@ -3883,7 +3912,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3883
3912
|
type: "welcome",
|
|
3884
3913
|
epoch: this.epoch,
|
|
3885
3914
|
roomName: this.roomName,
|
|
3886
|
-
engine:
|
|
3915
|
+
engine: ze,
|
|
3887
3916
|
slot: t,
|
|
3888
3917
|
stadium: this.engine.source,
|
|
3889
3918
|
state: this.engine.snapshot(),
|
|
@@ -3895,15 +3924,15 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3895
3924
|
}
|
|
3896
3925
|
if (r && n.type === "action") {
|
|
3897
3926
|
if (n.action === "chat" && typeof n.text == "string" && n.text.length <= 200) {
|
|
3898
|
-
if (!n.text.trim() || !this.traffic.allow(e.id, "chat") || (this.invoke("onPlayerActivity", this.onPlayerActivity, this.playerCopy(r)), this.closed || !this.players.includes(r))) return;
|
|
3899
|
-
this.invoke("onPlayerChat", this.onPlayerChat, this.playerCopy(r), n.text) !== !1 && this.network.broadcast({
|
|
3927
|
+
if (r.muted || !n.text.trim() || !this.traffic.allow(e.id, "chat") || (this.invoke("onPlayerActivity", this.onPlayerActivity, this.playerCopy(r)), this.closed || !this.players.includes(r))) return;
|
|
3928
|
+
this.invoke("onPlayerChat", this.onPlayerChat, this.playerCopy(r), n.text) !== !1 && !this.closed && this.players.includes(r) && !r.muted && this.network.broadcast({
|
|
3900
3929
|
type: "chat",
|
|
3901
3930
|
name: r.name,
|
|
3902
3931
|
text: n.text
|
|
3903
3932
|
});
|
|
3904
3933
|
}
|
|
3905
3934
|
if (n.action === "chat" || this.traffic.allow(e.id, "action")) {
|
|
3906
|
-
if (n.action === "avatar" &&
|
|
3935
|
+
if (n.action === "avatar" && Se(n.avatar)) {
|
|
3907
3936
|
r.avatar = n.avatar, this.recorder?.player(this.engine.tick, r.slot, r.name, r.avatarOverride ?? r.avatar), this.sync();
|
|
3908
3937
|
return;
|
|
3909
3938
|
}
|
|
@@ -3940,6 +3969,11 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3940
3969
|
return;
|
|
3941
3970
|
}
|
|
3942
3971
|
if (r.admin) {
|
|
3972
|
+
if (n.action === "mute" && typeof n.muted == "boolean") {
|
|
3973
|
+
let e = this.players.find((e) => e.slot === n.slot);
|
|
3974
|
+
e && e !== r && e.peerId !== this.network.hostId && this.changePlayerMuted(e.id, n.muted, this.playerCopy(r));
|
|
3975
|
+
return;
|
|
3976
|
+
}
|
|
3943
3977
|
if (n.action === "surface" && typeof n.enabled == "boolean" && ["lobby", "finished"].includes(this.engine.phase)) {
|
|
3944
3978
|
this.setSurfaceEnabled(n.enabled);
|
|
3945
3979
|
return;
|
|
@@ -3957,12 +3991,13 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3957
3991
|
i("Only the room owner can clear bans.");
|
|
3958
3992
|
return;
|
|
3959
3993
|
}
|
|
3994
|
+
if (!t) return;
|
|
3960
3995
|
this.banPlayer(t.id, "Removed by admin", this.playerCopy(r)).then(() => i("Player banned.")).catch((e) => i(e instanceof Error ? e.message : "Moderation failed."));
|
|
3961
3996
|
return;
|
|
3962
3997
|
}
|
|
3963
3998
|
if (n.action === "teamColors" && (n.team === 1 || n.team === 2)) {
|
|
3964
3999
|
let e = n.palette;
|
|
3965
|
-
this.changeTeamColors(n.team, e === null ? null :
|
|
4000
|
+
this.changeTeamColors(n.team, e === null ? null : ve(e.angle, e.textColor, e.colors));
|
|
3966
4001
|
}
|
|
3967
4002
|
if (n.action === "kickRate" && Number.isInteger(n.value) && Number(n.value) >= 0 && Number(n.value) <= 6619135) {
|
|
3968
4003
|
let e = Number(n.value);
|
|
@@ -3990,10 +4025,10 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
3990
4025
|
if (!this.allowed(e)) return;
|
|
3991
4026
|
let n = this.players.find((t) => t.peerId === e.id);
|
|
3992
4027
|
if (!n) return;
|
|
3993
|
-
let r =
|
|
4028
|
+
let r = Ut(t);
|
|
3994
4029
|
if (r.epoch !== this.epoch) return;
|
|
3995
4030
|
let i = this.inputs.get(e.id);
|
|
3996
|
-
(!i ||
|
|
4031
|
+
(!i || Ht(r.seq, i.seq)) && (this.inputs.set(e.id, {
|
|
3997
4032
|
seq: r.seq,
|
|
3998
4033
|
received: performance.now(),
|
|
3999
4034
|
keys: r.keys
|
|
@@ -4008,7 +4043,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4008
4043
|
value: n
|
|
4009
4044
|
};
|
|
4010
4045
|
if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(r)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
|
|
4011
|
-
|
|
4046
|
+
ct(this.engine, r);
|
|
4012
4047
|
}
|
|
4013
4048
|
roster() {
|
|
4014
4049
|
return this.players.map((e) => ({
|
|
@@ -4017,7 +4052,8 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4017
4052
|
slot: e.slot,
|
|
4018
4053
|
name: e.name,
|
|
4019
4054
|
team: e.team,
|
|
4020
|
-
admin: e.admin
|
|
4055
|
+
admin: e.admin,
|
|
4056
|
+
muted: !!e.muted
|
|
4021
4057
|
}));
|
|
4022
4058
|
}
|
|
4023
4059
|
sync() {
|
|
@@ -4046,6 +4082,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4046
4082
|
let t = this.engine.index(e.slot) * 18, n = !this.closed && this.engine.phase !== "lobby" && this.engine.data[t + 13] > 0, { slot: r, avatarOverride: i, ...a } = e;
|
|
4047
4083
|
return {
|
|
4048
4084
|
...a,
|
|
4085
|
+
muted: !!e.muted,
|
|
4049
4086
|
avatar: e.avatarOverride ?? e.avatar ?? null,
|
|
4050
4087
|
position: n ? {
|
|
4051
4088
|
x: this.engine.data[t],
|
|
@@ -4061,7 +4098,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4061
4098
|
return t ? this.playerCopy(t) : null;
|
|
4062
4099
|
}
|
|
4063
4100
|
setTeamColors(e, t, n, r) {
|
|
4064
|
-
this.changeTeamColors(e,
|
|
4101
|
+
this.changeTeamColors(e, ve(t, n, r));
|
|
4065
4102
|
}
|
|
4066
4103
|
changeTeamColors(e, t) {
|
|
4067
4104
|
if (this.closed) throw Error("Room is closed");
|
|
@@ -4079,7 +4116,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4079
4116
|
}
|
|
4080
4117
|
setPlayerAvatar(e, t) {
|
|
4081
4118
|
if (this.closed) throw Error("Room is closed");
|
|
4082
|
-
if (!
|
|
4119
|
+
if (!Se(t)) throw Error("Avatar must be null or at most two visible characters.");
|
|
4083
4120
|
let n = this.players.find((t) => t.id === e);
|
|
4084
4121
|
n && (n.avatarOverride = t, this.recorder?.player(this.engine.tick, n.slot, n.name, t ?? n.avatar), this.sync());
|
|
4085
4122
|
}
|
|
@@ -4101,6 +4138,15 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4101
4138
|
let n = this.players.find((t) => t.id === e);
|
|
4102
4139
|
n && n.admin !== !!t && (n.admin = !!t, this.sync(), this.invoke("onPlayerAdminChange", this.onPlayerAdminChange, this.playerCopy(n), null));
|
|
4103
4140
|
}
|
|
4141
|
+
setPlayerMuted(e, t) {
|
|
4142
|
+
this.changePlayerMuted(e, t, null);
|
|
4143
|
+
}
|
|
4144
|
+
changePlayerMuted(e, t, n) {
|
|
4145
|
+
if (this.closed) throw Error("Room is closed");
|
|
4146
|
+
if (!Number.isInteger(e) || typeof t != "boolean") throw Error("Invalid player mute");
|
|
4147
|
+
let r = this.players.find((t) => t.id === e);
|
|
4148
|
+
r && r.peerId !== this.network.hostId && !!r.muted !== t && (r.muted = t, this.sync(), this.invoke("onPlayerMuteChange", this.onPlayerMuteChange, this.playerCopy(r), n));
|
|
4149
|
+
}
|
|
4104
4150
|
setTeamsLock(e) {
|
|
4105
4151
|
this.changeTeamsLock(e, null);
|
|
4106
4152
|
}
|
|
@@ -4123,7 +4169,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4123
4169
|
try {
|
|
4124
4170
|
await this.network.updateBan("ban", r.peerId);
|
|
4125
4171
|
} catch (t) {
|
|
4126
|
-
throw t instanceof
|
|
4172
|
+
throw t instanceof Pt && this.bans.set(e, r.peerId), t;
|
|
4127
4173
|
}
|
|
4128
4174
|
this.bans.set(e, r.peerId), this.network.remove(r.peerId), this.invoke("onPlayerKicked", this.onPlayerKicked, i, a, !0, n);
|
|
4129
4175
|
}
|
|
@@ -4168,7 +4214,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4168
4214
|
}
|
|
4169
4215
|
sendAnnouncement(e, t, n, r, i) {
|
|
4170
4216
|
if (this.closed) throw Error("Room is closed");
|
|
4171
|
-
let a =
|
|
4217
|
+
let a = xe(e, n, r, i);
|
|
4172
4218
|
if (t != null && (!Number.isSafeInteger(t) || t < 0)) throw Error("Invalid announcement target");
|
|
4173
4219
|
if (t == null) this.network.broadcast(a);
|
|
4174
4220
|
else {
|
|
@@ -4210,7 +4256,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4210
4256
|
}
|
|
4211
4257
|
changeKickRateLimit(e, t, n, r) {
|
|
4212
4258
|
if (this.closed) throw Error("Room is closed");
|
|
4213
|
-
let i =
|
|
4259
|
+
let i = He(e, t, n);
|
|
4214
4260
|
i !== this.engine.kickRate && (this.command("kickRate", 0, i), this.state(), this.invoke("onKickRateLimitSet", this.onKickRateLimitSet, i & 255, i >>> 8 & 255, i >>> 16, r));
|
|
4215
4261
|
}
|
|
4216
4262
|
async setPassword(e) {
|
|
@@ -4255,7 +4301,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4255
4301
|
changeStadium(e, t) {
|
|
4256
4302
|
if (this.closed) throw Error("Room is closed");
|
|
4257
4303
|
if (!["lobby", "finished"].includes(this.engine.phase)) return;
|
|
4258
|
-
|
|
4304
|
+
Le(e);
|
|
4259
4305
|
let n = ++this.stadiumSelection;
|
|
4260
4306
|
if (this.recorder && this.finishRecording("Stadium changed"), this.closed) throw Error("Room is closed");
|
|
4261
4307
|
if (["lobby", "finished"].includes(this.engine.phase)) {
|
|
@@ -4305,7 +4351,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4305
4351
|
};
|
|
4306
4352
|
}
|
|
4307
4353
|
get CollisionFlags() {
|
|
4308
|
-
return
|
|
4354
|
+
return Gt;
|
|
4309
4355
|
}
|
|
4310
4356
|
getDiscCount() {
|
|
4311
4357
|
return this.closed || this.engine.phase === "lobby" ? 0 : this.engine.stadium.discs.length + this.players.filter((e) => e.team !== 0).length;
|
|
@@ -4330,7 +4376,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4330
4376
|
n && this.changeDisc(this.engine.index(n.slot), t);
|
|
4331
4377
|
}
|
|
4332
4378
|
changeDisc(e, t) {
|
|
4333
|
-
let n =
|
|
4379
|
+
let n = we(t), r = this.readDisc(e);
|
|
4334
4380
|
if (Object.entries(n).every(([e, t]) => r[e] === t)) return;
|
|
4335
4381
|
let i = {
|
|
4336
4382
|
tick: this.engine.tick,
|
|
@@ -4340,7 +4386,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4340
4386
|
properties: n
|
|
4341
4387
|
};
|
|
4342
4388
|
if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(i)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
|
|
4343
|
-
|
|
4389
|
+
ct(this.engine, i), this.state();
|
|
4344
4390
|
}
|
|
4345
4391
|
getPlayerDiscProperties(e) {
|
|
4346
4392
|
if (this.closed || this.engine.phase === "lobby") return null;
|
|
@@ -4354,7 +4400,7 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4354
4400
|
if (this.closed) throw Error("Room is closed");
|
|
4355
4401
|
if (this.finishingRecording) throw Error("Recording completion is in progress");
|
|
4356
4402
|
if (this.recorder) throw Error("Recording is already active");
|
|
4357
|
-
this.recorder = new
|
|
4403
|
+
this.recorder = new lt(this.engine, this.players.map((e) => ({
|
|
4358
4404
|
slot: e.slot,
|
|
4359
4405
|
name: e.name,
|
|
4360
4406
|
avatar: e.avatarOverride ?? e.avatar
|
|
@@ -4384,11 +4430,11 @@ var Rt = Object.freeze({ ...Te }), zt = class e {
|
|
|
4384
4430
|
}
|
|
4385
4431
|
}
|
|
4386
4432
|
};
|
|
4387
|
-
function
|
|
4433
|
+
function qt(e) {
|
|
4388
4434
|
if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
|
|
4389
4435
|
let t = { ...e }, n = t.maxPlayers ?? 12;
|
|
4390
4436
|
if (typeof n != "number" || !Number.isFinite(n) || !Number.isInteger(n)) throw Error("maxPlayers must be a finite integer");
|
|
4391
|
-
return
|
|
4437
|
+
return Q({
|
|
4392
4438
|
...t,
|
|
4393
4439
|
roomName: t.roomName ?? "Headless Room",
|
|
4394
4440
|
playerName: t.playerName ?? "Host",
|
|
@@ -4398,7 +4444,7 @@ function Bt(e) {
|
|
|
4398
4444
|
password: t.password ?? ""
|
|
4399
4445
|
});
|
|
4400
4446
|
}
|
|
4401
|
-
var
|
|
4447
|
+
var Jt = class {
|
|
4402
4448
|
onError;
|
|
4403
4449
|
pending = [];
|
|
4404
4450
|
active;
|
|
@@ -4434,6 +4480,7 @@ var Vt = class {
|
|
|
4434
4480
|
async drain() {
|
|
4435
4481
|
for (; !this.closed && this.pending.length;) {
|
|
4436
4482
|
let e = this.pending.shift();
|
|
4483
|
+
if (!e) break;
|
|
4437
4484
|
this.active = e;
|
|
4438
4485
|
try {
|
|
4439
4486
|
e.resolve(await e.run());
|
|
@@ -4451,45 +4498,19 @@ var Vt = class {
|
|
|
4451
4498
|
this.active?.reject(e);
|
|
4452
4499
|
for (let t of this.pending.splice(0)) t.reject(e);
|
|
4453
4500
|
}
|
|
4454
|
-
},
|
|
4455
|
-
|
|
4456
|
-
"sendAnnouncement",
|
|
4457
|
-
"setPlayerAdmin",
|
|
4458
|
-
"setPlayerTeam",
|
|
4459
|
-
"kickPlayer",
|
|
4460
|
-
"clearBan",
|
|
4461
|
-
"clearBans",
|
|
4462
|
-
"setScoreLimit",
|
|
4463
|
-
"setTimeLimit",
|
|
4464
|
-
"setCustomStadium",
|
|
4465
|
-
"setDefaultStadium",
|
|
4466
|
-
"setTeamsLock",
|
|
4467
|
-
"setTeamColors",
|
|
4468
|
-
"startGame",
|
|
4469
|
-
"stopGame",
|
|
4470
|
-
"pauseGame",
|
|
4471
|
-
"setPassword",
|
|
4472
|
-
"setRequireVerification",
|
|
4473
|
-
"setRequireRecaptcha",
|
|
4474
|
-
"reorderPlayers",
|
|
4475
|
-
"setKickRateLimit",
|
|
4476
|
-
"setSurfaceEnabled",
|
|
4477
|
-
"setPlayerAvatar",
|
|
4478
|
-
"setDiscProperties",
|
|
4479
|
-
"setPlayerDiscProperties"
|
|
4480
|
-
];
|
|
4481
|
-
function Ut(e, t) {
|
|
4501
|
+
}, Yt = /* @__PURE__ */ "sendChat.sendAnnouncement.setPlayerAdmin.setPlayerMuted.setPlayerTeam.kickPlayer.clearBan.clearBans.setScoreLimit.setTimeLimit.setCustomStadium.setDefaultStadium.setTeamsLock.setTeamColors.startGame.stopGame.pauseGame.setPassword.setRequireVerification.setRequireRecaptcha.reorderPlayers.setKickRateLimit.setSurfaceEnabled.setPlayerAvatar.setDiscProperties.setPlayerDiscProperties".split(".");
|
|
4502
|
+
function Xt(e, t) {
|
|
4482
4503
|
let n = Object.create(null);
|
|
4483
4504
|
t && Object.defineProperty(n, "closed", {
|
|
4484
4505
|
enumerable: !0,
|
|
4485
4506
|
value: t
|
|
4486
4507
|
});
|
|
4487
|
-
let r = new
|
|
4508
|
+
let r = new Jt((t) => {
|
|
4488
4509
|
let n = e.onError?.(String(t));
|
|
4489
4510
|
n instanceof Promise && n.catch(() => {});
|
|
4490
4511
|
});
|
|
4491
4512
|
e.signal.addEventListener("abort", () => r.close(), { once: !0 }), e.signal.aborted && r.close();
|
|
4492
|
-
for (let t of
|
|
4513
|
+
for (let t of Yt) Object.defineProperty(n, t, {
|
|
4493
4514
|
enumerable: !0,
|
|
4494
4515
|
value: (...n) => {
|
|
4495
4516
|
try {
|
|
@@ -4536,6 +4557,7 @@ function Ut(e, t) {
|
|
|
4536
4557
|
"onPlayerChat",
|
|
4537
4558
|
"onPlayerTeamChange",
|
|
4538
4559
|
"onPlayerAdminChange",
|
|
4560
|
+
"onPlayerMuteChange",
|
|
4539
4561
|
"onPlayerKicked",
|
|
4540
4562
|
"onPlayerActivity",
|
|
4541
4563
|
"onPlayerBallKick",
|
|
@@ -4572,19 +4594,19 @@ function Ut(e, t) {
|
|
|
4572
4594
|
}
|
|
4573
4595
|
}), Object.preventExtensions(n);
|
|
4574
4596
|
}
|
|
4575
|
-
function
|
|
4576
|
-
return
|
|
4597
|
+
function Zt(e) {
|
|
4598
|
+
return ut(e);
|
|
4577
4599
|
}
|
|
4578
|
-
function
|
|
4600
|
+
function Qt(e) {
|
|
4579
4601
|
if (typeof e != "string") throw TypeError("Stadium source must be a string");
|
|
4580
|
-
let t =
|
|
4602
|
+
let t = Le(e);
|
|
4581
4603
|
return Object.freeze({
|
|
4582
4604
|
name: t.name,
|
|
4583
4605
|
canBeStored: t.canBeStored,
|
|
4584
4606
|
warnings: Object.freeze([...t.warnings])
|
|
4585
4607
|
});
|
|
4586
4608
|
}
|
|
4587
|
-
async function
|
|
4588
|
-
return
|
|
4609
|
+
async function $t(e = {}, t = {}) {
|
|
4610
|
+
return Xt(await Kt.create(qt(e), void 0, t.signal));
|
|
4589
4611
|
}
|
|
4590
|
-
export {
|
|
4612
|
+
export { $t as createRoom, Zt as readReplay, Qt as validateStadium };
|