@modlock/modlock 0.1.84 → 0.1.86
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/host.gen.d.ts +44 -2
- package/index.d.ts +4 -1
- package/index.js +1129 -121
- package/package.json +6 -6
- package/persist.d.ts +81 -0
- package/service-later.d.ts +17 -0
- package/stragglers.d.ts +36 -0
- package/ui.d.ts +15 -3
package/index.js
CHANGED
|
@@ -5,6 +5,27 @@ var __export = (target, all) => {
|
|
|
5
5
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
// node_modules/@aptre/protobuf-es-lite/dist/enum.js
|
|
9
|
+
function createEnumType(typeName, values) {
|
|
10
|
+
const list = [];
|
|
11
|
+
const names = /* @__PURE__ */ new Map();
|
|
12
|
+
const numbers = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const [no, name] of values) {
|
|
14
|
+
const info = { no, name };
|
|
15
|
+
list.push(info);
|
|
16
|
+
names.set(name, info);
|
|
17
|
+
if (!numbers.has(no)) {
|
|
18
|
+
numbers.set(no, info);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
return {
|
|
22
|
+
typeName,
|
|
23
|
+
values: list,
|
|
24
|
+
findName: (name) => names.get(name),
|
|
25
|
+
findNumber: (no) => numbers.get(no)
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
8
29
|
// node_modules/@aptre/protobuf-es-lite/dist/binary-encoding.js
|
|
9
30
|
var WireType;
|
|
10
31
|
(function(WireType2) {
|
|
@@ -35,16 +56,16 @@ var BinaryWriter = class {
|
|
|
35
56
|
return this.pos;
|
|
36
57
|
}
|
|
37
58
|
/** Close the length-delimited value that started at start. */
|
|
38
|
-
join(
|
|
39
|
-
const length3 = this.pos -
|
|
59
|
+
join(start2) {
|
|
60
|
+
const length3 = this.pos - start2;
|
|
40
61
|
let size = 1;
|
|
41
62
|
for (let rest2 = length3 >>> 7; rest2 > 0; rest2 >>>= 7) {
|
|
42
63
|
size += 1;
|
|
43
64
|
}
|
|
44
65
|
this.reserve(size);
|
|
45
|
-
this.buf.copyWithin(
|
|
66
|
+
this.buf.copyWithin(start2 + size, start2, this.pos);
|
|
46
67
|
this.pos += size;
|
|
47
|
-
let at3 =
|
|
68
|
+
let at3 = start2;
|
|
48
69
|
let rest = length3;
|
|
49
70
|
while (rest > 127) {
|
|
50
71
|
this.buf[at3] = rest & 127 | 128;
|
|
@@ -429,12 +450,12 @@ var BinaryReader = class {
|
|
|
429
450
|
/** Read length-delimited bytes, aliasing the input. */
|
|
430
451
|
bytes() {
|
|
431
452
|
const length3 = this.uint32();
|
|
432
|
-
const
|
|
453
|
+
const start2 = this.pos;
|
|
433
454
|
this.pos += length3;
|
|
434
455
|
if (this.pos > this.len) {
|
|
435
456
|
throw new RangeError("premature EOF");
|
|
436
457
|
}
|
|
437
|
-
return this.buf.subarray(
|
|
458
|
+
return this.buf.subarray(start2, this.pos);
|
|
438
459
|
}
|
|
439
460
|
/**
|
|
440
461
|
* Read a length-delimited UTF-8 string, replacing invalid sequences with
|
|
@@ -1641,8 +1662,8 @@ function createMessageType(typeName, fields, overrides) {
|
|
|
1641
1662
|
readJson: overrides?.readJson ? (j, o, m) => overrides.readJson(j, o, m) : (j, o, m) => readJsonFields(fs(), typeName, j, o, m)
|
|
1642
1663
|
};
|
|
1643
1664
|
const empty2 = () => ({});
|
|
1644
|
-
const
|
|
1645
|
-
const
|
|
1665
|
+
const encode2 = (m, w) => codec.encode(m, w);
|
|
1666
|
+
const decode2 = (r, end, m) => codec.decode(r, end, m);
|
|
1646
1667
|
const writeJson = (m, o) => codec.writeJson(m, o);
|
|
1647
1668
|
const readJson = (j, o, m) => codec.readJson(j, o, m);
|
|
1648
1669
|
const toJson = (a, options) => writeJson(a ?? empty2(), options ?? {});
|
|
@@ -1660,8 +1681,8 @@ function createMessageType(typeName, fields, overrides) {
|
|
|
1660
1681
|
return {
|
|
1661
1682
|
typeName,
|
|
1662
1683
|
codec,
|
|
1663
|
-
encode,
|
|
1664
|
-
decode,
|
|
1684
|
+
encode: encode2,
|
|
1685
|
+
decode: decode2,
|
|
1665
1686
|
writeJson,
|
|
1666
1687
|
readJson,
|
|
1667
1688
|
create: clone,
|
|
@@ -1670,7 +1691,7 @@ function createMessageType(typeName, fields, overrides) {
|
|
|
1670
1691
|
toBinary: (a) => {
|
|
1671
1692
|
const w = new BinaryWriter();
|
|
1672
1693
|
if (a) {
|
|
1673
|
-
|
|
1694
|
+
encode2(a, w);
|
|
1674
1695
|
}
|
|
1675
1696
|
return w.finish();
|
|
1676
1697
|
},
|
|
@@ -1679,7 +1700,7 @@ function createMessageType(typeName, fields, overrides) {
|
|
|
1679
1700
|
return empty2();
|
|
1680
1701
|
}
|
|
1681
1702
|
const r = new BinaryReader(bytes);
|
|
1682
|
-
return
|
|
1703
|
+
return decode2(r, r.len, empty2());
|
|
1683
1704
|
},
|
|
1684
1705
|
toJson,
|
|
1685
1706
|
toJsonString: (a, options) => JSON.stringify(toJson(a, options), null, options?.prettySpaces ?? 0),
|
|
@@ -1700,16 +1721,16 @@ function createMessageType(typeName, fields, overrides) {
|
|
|
1700
1721
|
if (m == null) {
|
|
1701
1722
|
return;
|
|
1702
1723
|
}
|
|
1703
|
-
const
|
|
1704
|
-
|
|
1705
|
-
w.join(
|
|
1724
|
+
const start2 = w.tag(fieldNo, WireType.LengthDelimited).fork();
|
|
1725
|
+
encode2(m, w);
|
|
1726
|
+
w.join(start2);
|
|
1706
1727
|
},
|
|
1707
1728
|
writeGroup: (w, fieldNo, m) => {
|
|
1708
1729
|
if (m == null) {
|
|
1709
1730
|
return;
|
|
1710
1731
|
}
|
|
1711
1732
|
w.tag(fieldNo, WireType.StartGroup);
|
|
1712
|
-
|
|
1733
|
+
encode2(m, w);
|
|
1713
1734
|
w.tag(fieldNo, WireType.EndGroup);
|
|
1714
1735
|
}
|
|
1715
1736
|
};
|
|
@@ -1721,27 +1742,6 @@ function jsonError(typeName, e) {
|
|
|
1721
1742
|
});
|
|
1722
1743
|
}
|
|
1723
1744
|
|
|
1724
|
-
// node_modules/@aptre/protobuf-es-lite/dist/enum.js
|
|
1725
|
-
function createEnumType(typeName, values) {
|
|
1726
|
-
const list = [];
|
|
1727
|
-
const names = /* @__PURE__ */ new Map();
|
|
1728
|
-
const numbers = /* @__PURE__ */ new Map();
|
|
1729
|
-
for (const [no, name] of values) {
|
|
1730
|
-
const info = { no, name };
|
|
1731
|
-
list.push(info);
|
|
1732
|
-
names.set(name, info);
|
|
1733
|
-
if (!numbers.has(no)) {
|
|
1734
|
-
numbers.set(no, info);
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
return {
|
|
1738
|
-
typeName,
|
|
1739
|
-
values: list,
|
|
1740
|
-
findName: (name) => names.get(name),
|
|
1741
|
-
findNumber: (no) => numbers.get(no)
|
|
1742
|
-
};
|
|
1743
|
-
}
|
|
1744
|
-
|
|
1745
1745
|
// src/geometry/geometry.pb.ts
|
|
1746
1746
|
var Vec3 = /* @__PURE__ */ createMessageType(
|
|
1747
1747
|
"modlock.geometry.Vec3",
|
|
@@ -2691,6 +2691,15 @@ var WatchMovementRequest = /* @__PURE__ */ createMessageType(
|
|
|
2691
2691
|
);
|
|
2692
2692
|
|
|
2693
2693
|
// src/wasm/wasm.pb.ts
|
|
2694
|
+
var ServiceFailure_Enum = /* @__PURE__ */ createEnumType(
|
|
2695
|
+
"modlock.wasm.ServiceFailure",
|
|
2696
|
+
[
|
|
2697
|
+
[0, "SERVICE_FAILURE_NONE"],
|
|
2698
|
+
[1, "SERVICE_FAILURE_REFUSED"],
|
|
2699
|
+
[2, "SERVICE_FAILURE_TIMEOUT"],
|
|
2700
|
+
[3, "SERVICE_FAILURE_UNAVAILABLE"]
|
|
2701
|
+
]
|
|
2702
|
+
);
|
|
2694
2703
|
var Call = /* @__PURE__ */ createMessageType(
|
|
2695
2704
|
"modlock.wasm.Call",
|
|
2696
2705
|
() => [
|
|
@@ -3195,6 +3204,136 @@ var ServiceReply = /* @__PURE__ */ createMessageType(
|
|
|
3195
3204
|
}
|
|
3196
3205
|
}
|
|
3197
3206
|
);
|
|
3207
|
+
var StartServiceCallRequest = /* @__PURE__ */ createMessageType(
|
|
3208
|
+
"modlock.wasm.StartServiceCallRequest",
|
|
3209
|
+
() => [
|
|
3210
|
+
[1, "service", 9],
|
|
3211
|
+
[2, "method", 9],
|
|
3212
|
+
[3, "payload", 12],
|
|
3213
|
+
[4, "timeout_milliseconds", 13]
|
|
3214
|
+
],
|
|
3215
|
+
{
|
|
3216
|
+
decode: (r, end, m) => {
|
|
3217
|
+
while (r.pos < end) {
|
|
3218
|
+
const t = r.tag();
|
|
3219
|
+
if ((t & 7) === 4) return m;
|
|
3220
|
+
switch (t >>> 3) {
|
|
3221
|
+
case 1:
|
|
3222
|
+
m.service = r.string();
|
|
3223
|
+
break;
|
|
3224
|
+
case 2:
|
|
3225
|
+
m.method = r.string();
|
|
3226
|
+
break;
|
|
3227
|
+
case 3:
|
|
3228
|
+
m.payload = r.bytes();
|
|
3229
|
+
break;
|
|
3230
|
+
case 4:
|
|
3231
|
+
m.timeoutMilliseconds = r.uint32();
|
|
3232
|
+
break;
|
|
3233
|
+
default:
|
|
3234
|
+
r.skip(t);
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
return m;
|
|
3238
|
+
},
|
|
3239
|
+
encode: (m, w) => {
|
|
3240
|
+
{
|
|
3241
|
+
const v = m.service;
|
|
3242
|
+
if (v) w.uint32(10).string(v);
|
|
3243
|
+
}
|
|
3244
|
+
{
|
|
3245
|
+
const v = m.method;
|
|
3246
|
+
if (v) w.uint32(18).string(v);
|
|
3247
|
+
}
|
|
3248
|
+
{
|
|
3249
|
+
const v = m.payload;
|
|
3250
|
+
if (v != null && v.length !== 0) w.uint32(26).bytes(v);
|
|
3251
|
+
}
|
|
3252
|
+
{
|
|
3253
|
+
const v = m.timeoutMilliseconds;
|
|
3254
|
+
if (v) w.uint32(32).uint32(v);
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
}
|
|
3258
|
+
);
|
|
3259
|
+
var ServiceCallStarted = /* @__PURE__ */ createMessageType(
|
|
3260
|
+
"modlock.wasm.ServiceCallStarted",
|
|
3261
|
+
() => [[1, "call", 4]],
|
|
3262
|
+
{
|
|
3263
|
+
decode: (r, end, m) => {
|
|
3264
|
+
while (r.pos < end) {
|
|
3265
|
+
const t = r.tag();
|
|
3266
|
+
if ((t & 7) === 4) return m;
|
|
3267
|
+
switch (t >>> 3) {
|
|
3268
|
+
case 1:
|
|
3269
|
+
m.call = r.uint64();
|
|
3270
|
+
break;
|
|
3271
|
+
default:
|
|
3272
|
+
r.skip(t);
|
|
3273
|
+
}
|
|
3274
|
+
}
|
|
3275
|
+
return m;
|
|
3276
|
+
},
|
|
3277
|
+
encode: (m, w) => {
|
|
3278
|
+
{
|
|
3279
|
+
const v = m.call;
|
|
3280
|
+
if (v) w.uint32(8).uint64(v);
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
}
|
|
3284
|
+
);
|
|
3285
|
+
var ServiceRepliedEvent = /* @__PURE__ */ createMessageType(
|
|
3286
|
+
"modlock.wasm.ServiceRepliedEvent",
|
|
3287
|
+
() => [
|
|
3288
|
+
[1, "call", 4],
|
|
3289
|
+
[2, "payload", 12],
|
|
3290
|
+
[3, "failure", 14, 0, ServiceFailure_Enum],
|
|
3291
|
+
[4, "error", 9]
|
|
3292
|
+
],
|
|
3293
|
+
{
|
|
3294
|
+
decode: (r, end, m) => {
|
|
3295
|
+
while (r.pos < end) {
|
|
3296
|
+
const t = r.tag();
|
|
3297
|
+
if ((t & 7) === 4) return m;
|
|
3298
|
+
switch (t >>> 3) {
|
|
3299
|
+
case 1:
|
|
3300
|
+
m.call = r.uint64();
|
|
3301
|
+
break;
|
|
3302
|
+
case 2:
|
|
3303
|
+
m.payload = r.bytes();
|
|
3304
|
+
break;
|
|
3305
|
+
case 3:
|
|
3306
|
+
m.failure = r.int32();
|
|
3307
|
+
break;
|
|
3308
|
+
case 4:
|
|
3309
|
+
m.error = r.string();
|
|
3310
|
+
break;
|
|
3311
|
+
default:
|
|
3312
|
+
r.skip(t);
|
|
3313
|
+
}
|
|
3314
|
+
}
|
|
3315
|
+
return m;
|
|
3316
|
+
},
|
|
3317
|
+
encode: (m, w) => {
|
|
3318
|
+
{
|
|
3319
|
+
const v = m.call;
|
|
3320
|
+
if (v) w.uint32(8).uint64(v);
|
|
3321
|
+
}
|
|
3322
|
+
{
|
|
3323
|
+
const v = m.payload;
|
|
3324
|
+
if (v != null && v.length !== 0) w.uint32(18).bytes(v);
|
|
3325
|
+
}
|
|
3326
|
+
{
|
|
3327
|
+
const v = m.failure;
|
|
3328
|
+
if (v) w.uint32(24).int32(v);
|
|
3329
|
+
}
|
|
3330
|
+
{
|
|
3331
|
+
const v = m.error;
|
|
3332
|
+
if (v) w.uint32(34).string(v);
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
}
|
|
3336
|
+
);
|
|
3198
3337
|
var LogRequest = /* @__PURE__ */ createMessageType(
|
|
3199
3338
|
"modlock.wasm.LogRequest",
|
|
3200
3339
|
() => [[1, "message", 9]],
|
|
@@ -13044,7 +13183,9 @@ var UiPressEvent = /* @__PURE__ */ createMessageType(
|
|
|
13044
13183
|
"modlock.wasm.ui.UiPressEvent",
|
|
13045
13184
|
() => [
|
|
13046
13185
|
[1, "player", 5],
|
|
13047
|
-
[2, "node", 9]
|
|
13186
|
+
[2, "node", 9],
|
|
13187
|
+
[3, "action", 9],
|
|
13188
|
+
[4, "payload", 9]
|
|
13048
13189
|
],
|
|
13049
13190
|
{
|
|
13050
13191
|
decode: (r, end, m) => {
|
|
@@ -13058,6 +13199,12 @@ var UiPressEvent = /* @__PURE__ */ createMessageType(
|
|
|
13058
13199
|
case 2:
|
|
13059
13200
|
m.node = r.string();
|
|
13060
13201
|
break;
|
|
13202
|
+
case 3:
|
|
13203
|
+
m.action = r.string();
|
|
13204
|
+
break;
|
|
13205
|
+
case 4:
|
|
13206
|
+
m.payload = r.string();
|
|
13207
|
+
break;
|
|
13061
13208
|
default:
|
|
13062
13209
|
r.skip(t);
|
|
13063
13210
|
}
|
|
@@ -13073,6 +13220,14 @@ var UiPressEvent = /* @__PURE__ */ createMessageType(
|
|
|
13073
13220
|
const v = m.node;
|
|
13074
13221
|
if (v) w.uint32(18).string(v);
|
|
13075
13222
|
}
|
|
13223
|
+
{
|
|
13224
|
+
const v = m.action;
|
|
13225
|
+
if (v) w.uint32(26).string(v);
|
|
13226
|
+
}
|
|
13227
|
+
{
|
|
13228
|
+
const v = m.payload;
|
|
13229
|
+
if (v) w.uint32(34).string(v);
|
|
13230
|
+
}
|
|
13076
13231
|
}
|
|
13077
13232
|
}
|
|
13078
13233
|
);
|
|
@@ -13486,8 +13641,8 @@ function findTitled(list, typed) {
|
|
|
13486
13641
|
if (key === "") {
|
|
13487
13642
|
return void 0;
|
|
13488
13643
|
}
|
|
13489
|
-
const title = (
|
|
13490
|
-
return list.find((
|
|
13644
|
+
const title = (entry2) => entry2.title.toLowerCase().replace(/[^a-z0-9]/g, "");
|
|
13645
|
+
return list.find((entry2) => entry2.name === key || title(entry2) === key) ?? list.find((entry2) => title(entry2).startsWith(key)) ?? list.find((entry2) => title(entry2).includes(key));
|
|
13491
13646
|
}
|
|
13492
13647
|
|
|
13493
13648
|
// js/src/host.gen.ts
|
|
@@ -13503,10 +13658,10 @@ function heroName(name) {
|
|
|
13503
13658
|
function angles(value) {
|
|
13504
13659
|
return { pitch: value?.pitch ?? 0, yaw: value?.yaw ?? 0, roll: value?.roll ?? 0 };
|
|
13505
13660
|
}
|
|
13506
|
-
function known(values,
|
|
13661
|
+
function known(values, decode2) {
|
|
13507
13662
|
const out = [];
|
|
13508
13663
|
for (const v of values ?? []) {
|
|
13509
|
-
const decoded =
|
|
13664
|
+
const decoded = decode2(v);
|
|
13510
13665
|
if (decoded !== void 0) {
|
|
13511
13666
|
out.push(decoded);
|
|
13512
13667
|
}
|
|
@@ -13711,6 +13866,12 @@ var cameraParamValues = {
|
|
|
13711
13866
|
verticalOffset: 3,
|
|
13712
13867
|
horizontalOffset: 4
|
|
13713
13868
|
};
|
|
13869
|
+
var serviceFailureNames = {
|
|
13870
|
+
0: "none",
|
|
13871
|
+
1: "refused",
|
|
13872
|
+
2: "timeout",
|
|
13873
|
+
3: "unavailable"
|
|
13874
|
+
};
|
|
13714
13875
|
function fromAbility(message) {
|
|
13715
13876
|
return {
|
|
13716
13877
|
name: message.name ?? "",
|
|
@@ -14293,7 +14454,9 @@ function fromWheel(message) {
|
|
|
14293
14454
|
function fromUiPressEvent(message) {
|
|
14294
14455
|
return {
|
|
14295
14456
|
player: Player.of(message.player ?? 0),
|
|
14296
|
-
node: message.node ?? ""
|
|
14457
|
+
node: message.node ?? "",
|
|
14458
|
+
action: message.action ?? "",
|
|
14459
|
+
payload: message.payload ?? ""
|
|
14297
14460
|
};
|
|
14298
14461
|
}
|
|
14299
14462
|
function fromUiInputEvent(message) {
|
|
@@ -14360,6 +14523,14 @@ function fromServiceCall(message) {
|
|
|
14360
14523
|
payload: message.payload ?? new Uint8Array()
|
|
14361
14524
|
};
|
|
14362
14525
|
}
|
|
14526
|
+
function fromServiceRepliedEvent(message) {
|
|
14527
|
+
return {
|
|
14528
|
+
call: message.call ?? 0n,
|
|
14529
|
+
payload: message.payload ?? new Uint8Array(),
|
|
14530
|
+
failure: serviceFailureNames[message.failure ?? 0],
|
|
14531
|
+
error: message.error ?? ""
|
|
14532
|
+
};
|
|
14533
|
+
}
|
|
14363
14534
|
function toPrecacheOptions(value) {
|
|
14364
14535
|
return {
|
|
14365
14536
|
heroes: value.heroes?.map((v) => heroName(v)),
|
|
@@ -15101,12 +15272,18 @@ function watchInput(buttons) {
|
|
|
15101
15272
|
function remapInput(from, to, repeat2) {
|
|
15102
15273
|
return call("RemapInput", RemapInputRequest.toBinary({ from, to, repeat: repeat2 })) !== void 0;
|
|
15103
15274
|
}
|
|
15104
|
-
function callService(
|
|
15105
|
-
const reply2 = call("CallService", ServiceCall.toBinary({ service:
|
|
15275
|
+
function callService(service3, method, payload) {
|
|
15276
|
+
const reply2 = call("CallService", ServiceCall.toBinary({ service: service3, method, payload }));
|
|
15106
15277
|
if (reply2 === void 0) return void 0;
|
|
15107
15278
|
const response = ServiceReply.fromBinary(reply2);
|
|
15108
15279
|
return response.payload ?? new Uint8Array();
|
|
15109
15280
|
}
|
|
15281
|
+
function startServiceCall(service3, method, payload, timeoutMilliseconds) {
|
|
15282
|
+
const reply2 = call("StartServiceCall", StartServiceCallRequest.toBinary({ service: service3, method, payload, timeoutMilliseconds }));
|
|
15283
|
+
if (reply2 === void 0) return void 0;
|
|
15284
|
+
const response = ServiceCallStarted.fromBinary(reply2);
|
|
15285
|
+
return response.call ?? 0n;
|
|
15286
|
+
}
|
|
15110
15287
|
function createEntity(options) {
|
|
15111
15288
|
const reply2 = call("CreateEntity", EntityOptions.toBinary(toEntityOptions(options)));
|
|
15112
15289
|
if (reply2 === void 0) return void 0;
|
|
@@ -15253,6 +15430,9 @@ function serveMod(handlers2, bytes) {
|
|
|
15253
15430
|
return reply();
|
|
15254
15431
|
case "Serve":
|
|
15255
15432
|
return reply(ServiceReply.toBinary(handlers2.serve(fromServiceCall(ServiceCall.fromBinary(input2)))));
|
|
15433
|
+
case "ServiceReplied":
|
|
15434
|
+
handlers2.serviceReplied(fromServiceRepliedEvent(ServiceRepliedEvent.fromBinary(input2)));
|
|
15435
|
+
return reply();
|
|
15256
15436
|
case "Damage":
|
|
15257
15437
|
return reply(DamageResult.toBinary(handlers2.damage(fromDamageEvent(DamageEvent.fromBinary(input2)))));
|
|
15258
15438
|
case "Damaged":
|
|
@@ -15328,8 +15508,8 @@ function keepPlayers(players2) {
|
|
|
15328
15508
|
}
|
|
15329
15509
|
function adopt(players2) {
|
|
15330
15510
|
const current = new Map(players2.map((c) => [c.player.slot, c.generation]));
|
|
15331
|
-
for (const [slot,
|
|
15332
|
-
if (current.get(slot) !==
|
|
15511
|
+
for (const [slot, generation2] of generations) {
|
|
15512
|
+
if (current.get(slot) !== generation2) Player.release(slot);
|
|
15333
15513
|
}
|
|
15334
15514
|
generations.clear();
|
|
15335
15515
|
return players2.map((c) => {
|
|
@@ -15620,8 +15800,8 @@ var Puppet = class _Puppet {
|
|
|
15620
15800
|
* could join. The bot appears at the track's first pose.
|
|
15621
15801
|
*/
|
|
15622
15802
|
static spawn(bot, track, options) {
|
|
15623
|
-
const
|
|
15624
|
-
const player = addBot({ ...bot, position: bot.position ??
|
|
15803
|
+
const start2 = poseAt(track, 0);
|
|
15804
|
+
const player = addBot({ ...bot, position: bot.position ?? start2?.position });
|
|
15625
15805
|
return player && new _Puppet(player, track, options);
|
|
15626
15806
|
}
|
|
15627
15807
|
/** state is where playback stands. */
|
|
@@ -15843,42 +16023,72 @@ function sequence(fn) {
|
|
|
15843
16023
|
return schedule(0, () => fn(++run) ?? void 0);
|
|
15844
16024
|
}
|
|
15845
16025
|
function schedule(delay, run) {
|
|
15846
|
-
const
|
|
15847
|
-
entries.push(
|
|
15848
|
-
return
|
|
16026
|
+
const entry2 = new Entry(delay, run);
|
|
16027
|
+
entries.push(entry2);
|
|
16028
|
+
return entry2;
|
|
15849
16029
|
}
|
|
15850
16030
|
function advance(seconds) {
|
|
15851
16031
|
if (now !== void 0 && seconds < now) {
|
|
15852
16032
|
const shift = seconds - now;
|
|
15853
|
-
for (const
|
|
15854
|
-
if (
|
|
15855
|
-
|
|
16033
|
+
for (const entry2 of entries) {
|
|
16034
|
+
if (entry2.at !== void 0) {
|
|
16035
|
+
entry2.at += shift;
|
|
15856
16036
|
}
|
|
15857
16037
|
}
|
|
15858
16038
|
}
|
|
15859
16039
|
now = seconds;
|
|
15860
|
-
for (const
|
|
15861
|
-
|
|
16040
|
+
for (const entry2 of entries) {
|
|
16041
|
+
entry2.start(seconds);
|
|
15862
16042
|
}
|
|
15863
|
-
const due = entries.filter((
|
|
15864
|
-
for (const
|
|
15865
|
-
if (
|
|
16043
|
+
const due = entries.filter((entry2) => !entry2.finished && entry2.at <= seconds).sort((a, b) => a.at - b.at);
|
|
16044
|
+
for (const entry2 of due) {
|
|
16045
|
+
if (entry2.finished) {
|
|
15866
16046
|
continue;
|
|
15867
16047
|
}
|
|
15868
16048
|
try {
|
|
15869
|
-
const wait =
|
|
16049
|
+
const wait = entry2.run();
|
|
15870
16050
|
if (wait === void 0) {
|
|
15871
|
-
|
|
16051
|
+
entry2.finished = true;
|
|
15872
16052
|
} else {
|
|
15873
|
-
const next =
|
|
15874
|
-
|
|
16053
|
+
const next = entry2.at + wait;
|
|
16054
|
+
entry2.at = next > seconds ? next : seconds + wait;
|
|
15875
16055
|
}
|
|
15876
16056
|
} catch (error) {
|
|
15877
|
-
|
|
16057
|
+
entry2.finished = true;
|
|
15878
16058
|
log(`timer failed: ${String(error)}`);
|
|
15879
16059
|
}
|
|
15880
16060
|
}
|
|
15881
|
-
entries = entries.filter((
|
|
16061
|
+
entries = entries.filter((entry2) => !entry2.finished);
|
|
16062
|
+
}
|
|
16063
|
+
|
|
16064
|
+
// js/src/service-later.ts
|
|
16065
|
+
var waiting2 = /* @__PURE__ */ new Map();
|
|
16066
|
+
function callServiceLater(service3, method, payload, done, timeoutMilliseconds = 0) {
|
|
16067
|
+
const call2 = startServiceCall(service3, method, payload, timeoutMilliseconds);
|
|
16068
|
+
if (call2 === void 0) {
|
|
16069
|
+
after(
|
|
16070
|
+
0,
|
|
16071
|
+
() => done(
|
|
16072
|
+
void 0,
|
|
16073
|
+
`the host did not start the call to ${service3}`,
|
|
16074
|
+
"unavailable"
|
|
16075
|
+
)
|
|
16076
|
+
);
|
|
16077
|
+
return;
|
|
16078
|
+
}
|
|
16079
|
+
waiting2.set(call2, done);
|
|
16080
|
+
}
|
|
16081
|
+
function endServiceCall(event) {
|
|
16082
|
+
const done = waiting2.get(event.call);
|
|
16083
|
+
if (!done) {
|
|
16084
|
+
return;
|
|
16085
|
+
}
|
|
16086
|
+
waiting2.delete(event.call);
|
|
16087
|
+
if (event.failure && event.failure !== "none") {
|
|
16088
|
+
done(void 0, event.error, event.failure);
|
|
16089
|
+
return;
|
|
16090
|
+
}
|
|
16091
|
+
done(event.payload);
|
|
15882
16092
|
}
|
|
15883
16093
|
|
|
15884
16094
|
// js/src/item-id.ts
|
|
@@ -16032,7 +16242,20 @@ function uiSound(player, sound, options = {}) {
|
|
|
16032
16242
|
});
|
|
16033
16243
|
return draw(player);
|
|
16034
16244
|
}
|
|
16035
|
-
function press(player, node) {
|
|
16245
|
+
function press(player, node, action = "", payload = "") {
|
|
16246
|
+
if (action !== "") {
|
|
16247
|
+
const pressed2 = screens.get(player.slot)?.actions.get(node);
|
|
16248
|
+
if (pressed2) {
|
|
16249
|
+
let value = void 0;
|
|
16250
|
+
try {
|
|
16251
|
+
value = payload === "" ? void 0 : JSON.parse(payload);
|
|
16252
|
+
} catch {
|
|
16253
|
+
value = void 0;
|
|
16254
|
+
}
|
|
16255
|
+
pressed2.handler(player, action, value);
|
|
16256
|
+
}
|
|
16257
|
+
return;
|
|
16258
|
+
}
|
|
16036
16259
|
const bar = abilityBarNode.exec(node);
|
|
16037
16260
|
if (bar) {
|
|
16038
16261
|
views.get(player.slot)?.bar?.handler(player, Number(bar[1]));
|
|
@@ -16195,6 +16418,7 @@ var Layout = class {
|
|
|
16195
16418
|
ids: /* @__PURE__ */ new Map(),
|
|
16196
16419
|
presses: /* @__PURE__ */ new Map(),
|
|
16197
16420
|
changes: /* @__PURE__ */ new Map(),
|
|
16421
|
+
actions: /* @__PURE__ */ new Map(),
|
|
16198
16422
|
wheels: /* @__PURE__ */ new Map(),
|
|
16199
16423
|
next: previous?.next ?? 0
|
|
16200
16424
|
};
|
|
@@ -16297,6 +16521,9 @@ function place(layout, child, at3) {
|
|
|
16297
16521
|
node.kind = 4 /* LAYOUT */;
|
|
16298
16522
|
node.layout = props.src ?? "";
|
|
16299
16523
|
node.data = props.data === void 0 ? "" : JSON.stringify(props.data) ?? "";
|
|
16524
|
+
if (props.onAction) {
|
|
16525
|
+
layout.screen.actions.set(node.id, { handler: props.onAction });
|
|
16526
|
+
}
|
|
16300
16527
|
break;
|
|
16301
16528
|
default:
|
|
16302
16529
|
node.kind = 0 /* PANEL */;
|
|
@@ -16867,7 +17094,7 @@ function through(points, options) {
|
|
|
16867
17094
|
function orbit(options) {
|
|
16868
17095
|
const { center, radius, duration } = options;
|
|
16869
17096
|
const turns = options.turns ?? 1;
|
|
16870
|
-
const
|
|
17097
|
+
const start2 = (options.start ?? 0) * Math.PI / 180;
|
|
16871
17098
|
const rise = options.rise ?? 0;
|
|
16872
17099
|
const shape = options.ease ?? ease.linear;
|
|
16873
17100
|
return [
|
|
@@ -16875,7 +17102,7 @@ function orbit(options) {
|
|
|
16875
17102
|
duration,
|
|
16876
17103
|
at: (u) => {
|
|
16877
17104
|
const t = shape.at(u);
|
|
16878
|
-
const angle =
|
|
17105
|
+
const angle = start2 + t * turns * 2 * Math.PI;
|
|
16879
17106
|
return {
|
|
16880
17107
|
x: center.x + radius * Math.cos(angle),
|
|
16881
17108
|
y: center.y + radius * Math.sin(angle),
|
|
@@ -16914,11 +17141,11 @@ function durationOf(curve) {
|
|
|
16914
17141
|
return curve.reduce((sum, span) => sum + Math.max(0, span.duration), 0);
|
|
16915
17142
|
}
|
|
16916
17143
|
function valueAt(curve, seconds) {
|
|
16917
|
-
let
|
|
17144
|
+
let left2 = seconds;
|
|
16918
17145
|
for (const span of curve) {
|
|
16919
17146
|
if (span.duration <= 0) continue;
|
|
16920
|
-
if (
|
|
16921
|
-
|
|
17147
|
+
if (left2 <= span.duration) return span.at(Math.max(0, left2) / span.duration);
|
|
17148
|
+
left2 -= span.duration;
|
|
16922
17149
|
}
|
|
16923
17150
|
return curve.at(-1)?.at(1);
|
|
16924
17151
|
}
|
|
@@ -17041,11 +17268,11 @@ function sendCurve(player, options, curve) {
|
|
|
17041
17268
|
const { context, param, relative, priority, target } = options;
|
|
17042
17269
|
const rate = options.rate ?? 30;
|
|
17043
17270
|
let delay = options.delay;
|
|
17044
|
-
const lerp3 = (
|
|
17271
|
+
const lerp3 = (start2, end, duration, shape = {}) => {
|
|
17045
17272
|
const sent = player.moveCamera({
|
|
17046
17273
|
context,
|
|
17047
17274
|
param,
|
|
17048
|
-
motion: { lerp: { start, end, duration, ...shape } },
|
|
17275
|
+
motion: { lerp: { start: start2, end, duration, ...shape } },
|
|
17049
17276
|
delay,
|
|
17050
17277
|
relative,
|
|
17051
17278
|
priority,
|
|
@@ -18016,9 +18243,9 @@ function band(plane, halfWidth, height, lit, faded, made) {
|
|
|
18016
18243
|
}
|
|
18017
18244
|
for (let row2 = openingRows; row2 < rows; row2++) {
|
|
18018
18245
|
const outer = row2 === rows - 1;
|
|
18019
|
-
const
|
|
18246
|
+
const start2 = outer ? 0 : margin;
|
|
18020
18247
|
const end = outer ? columns : columns - margin;
|
|
18021
|
-
const first =
|
|
18248
|
+
const first = start2 + (start2 + row2) % 2;
|
|
18022
18249
|
const count2 = Math.ceil((end - first) / 2);
|
|
18023
18250
|
strip(plane, {
|
|
18024
18251
|
text: Array(count2).fill(block).join(gap),
|
|
@@ -18332,6 +18559,62 @@ function layDown(entity) {
|
|
|
18332
18559
|
);
|
|
18333
18560
|
}
|
|
18334
18561
|
|
|
18562
|
+
// js/src/stragglers.ts
|
|
18563
|
+
var stragglerConnectSeconds = 120;
|
|
18564
|
+
var Stragglers = class {
|
|
18565
|
+
connectSeconds;
|
|
18566
|
+
strays;
|
|
18567
|
+
/** joining maps each connecting human's slot to its generation and when it was first seen. */
|
|
18568
|
+
joining = /* @__PURE__ */ new Map();
|
|
18569
|
+
/** kicked holds the generation each slot had when this kicked it. */
|
|
18570
|
+
kicked = /* @__PURE__ */ new Map();
|
|
18571
|
+
sweptAt = -Infinity;
|
|
18572
|
+
constructor(options = {}) {
|
|
18573
|
+
this.connectSeconds = options.connectSeconds ?? stragglerConnectSeconds;
|
|
18574
|
+
this.strays = options.heroes === false ? void 0 : new Strays();
|
|
18575
|
+
}
|
|
18576
|
+
/**
|
|
18577
|
+
* sweep kicks each human connecting for longer than connectSeconds, once
|
|
18578
|
+
* per connection, and lays down heroes no player holds, at most once a
|
|
18579
|
+
* second.
|
|
18580
|
+
*/
|
|
18581
|
+
sweep(now4) {
|
|
18582
|
+
this.strays?.sweep(now4);
|
|
18583
|
+
if (now4 - this.sweptAt < 1) {
|
|
18584
|
+
return;
|
|
18585
|
+
}
|
|
18586
|
+
this.sweptAt = now4;
|
|
18587
|
+
if (this.connectSeconds <= 0) {
|
|
18588
|
+
return;
|
|
18589
|
+
}
|
|
18590
|
+
const joining = /* @__PURE__ */ new Map();
|
|
18591
|
+
for (const connection2 of players()) {
|
|
18592
|
+
if (connection2.bot || connection2.ready) {
|
|
18593
|
+
continue;
|
|
18594
|
+
}
|
|
18595
|
+
const slot = connection2.player.slot;
|
|
18596
|
+
const seen = this.joining.get(slot);
|
|
18597
|
+
const since = seen?.generation === connection2.generation ? seen.since : now4;
|
|
18598
|
+
joining.set(slot, { generation: connection2.generation, since });
|
|
18599
|
+
if (now4 - since < this.connectSeconds) {
|
|
18600
|
+
continue;
|
|
18601
|
+
}
|
|
18602
|
+
if (this.kicked.get(slot) === connection2.generation) {
|
|
18603
|
+
continue;
|
|
18604
|
+
}
|
|
18605
|
+
this.kicked.set(slot, connection2.generation);
|
|
18606
|
+
const name = connection2.name;
|
|
18607
|
+
if (name === "" || name.includes('"')) {
|
|
18608
|
+
log(`slot ${slot} stuck joining, but its name cannot be kicked`);
|
|
18609
|
+
continue;
|
|
18610
|
+
}
|
|
18611
|
+
log(`kicked ${name}: still joining after ${this.connectSeconds} s`);
|
|
18612
|
+
serverCommand(`kick "${name}"`);
|
|
18613
|
+
}
|
|
18614
|
+
this.joining = joining;
|
|
18615
|
+
}
|
|
18616
|
+
};
|
|
18617
|
+
|
|
18335
18618
|
// js/src/probe.ts
|
|
18336
18619
|
var ProbeRun = class {
|
|
18337
18620
|
/**
|
|
@@ -18886,13 +19169,13 @@ var Dropper = class {
|
|
|
18886
19169
|
if (builder.held) {
|
|
18887
19170
|
return { ...builder.held, position, facing };
|
|
18888
19171
|
}
|
|
18889
|
-
const
|
|
19172
|
+
const entry2 = this.catalog[builder.entry];
|
|
18890
19173
|
return {
|
|
18891
|
-
model:
|
|
19174
|
+
model: entry2.model,
|
|
18892
19175
|
position,
|
|
18893
19176
|
facing,
|
|
18894
|
-
scale:
|
|
18895
|
-
bounce:
|
|
19177
|
+
scale: entry2.scale ?? 1,
|
|
19178
|
+
bounce: entry2.bounce ?? 0,
|
|
18896
19179
|
placedBy: builder.steamId
|
|
18897
19180
|
};
|
|
18898
19181
|
}
|
|
@@ -19008,7 +19291,7 @@ var Dropper = class {
|
|
|
19008
19291
|
/** draw shows the builder the catalog and their keys. */
|
|
19009
19292
|
draw(builder) {
|
|
19010
19293
|
const rows = this.catalog.map(
|
|
19011
|
-
(
|
|
19294
|
+
(entry2, index) => jsx(
|
|
19012
19295
|
"button",
|
|
19013
19296
|
{
|
|
19014
19297
|
style: {
|
|
@@ -19018,7 +19301,7 @@ var Dropper = class {
|
|
|
19018
19301
|
fontSize: 16
|
|
19019
19302
|
},
|
|
19020
19303
|
onPress: (player) => this.select(player, index),
|
|
19021
|
-
children: `${
|
|
19304
|
+
children: `${entry2.category} \xB7 ${entry2.name}`
|
|
19022
19305
|
},
|
|
19023
19306
|
index
|
|
19024
19307
|
)
|
|
@@ -19065,37 +19348,23 @@ var Dropper = class {
|
|
|
19065
19348
|
};
|
|
19066
19349
|
var windowShown = 12;
|
|
19067
19350
|
function windowOf(rows, selected) {
|
|
19068
|
-
const
|
|
19351
|
+
const start2 = Math.max(
|
|
19069
19352
|
0,
|
|
19070
19353
|
Math.min(selected - windowShown / 2, rows.length - windowShown)
|
|
19071
19354
|
);
|
|
19072
|
-
return rows.slice(
|
|
19355
|
+
return rows.slice(start2, start2 + windowShown);
|
|
19073
19356
|
}
|
|
19074
19357
|
function snap(value) {
|
|
19075
19358
|
return Math.round(value / grid) * grid;
|
|
19076
19359
|
}
|
|
19077
19360
|
|
|
19078
|
-
// src/wasm/
|
|
19079
|
-
var
|
|
19080
|
-
"modlock.wasm.
|
|
19081
|
-
[
|
|
19082
|
-
[0, "WINDOW_UNKNOWN"],
|
|
19083
|
-
[1, "WINDOW_ALL_TIME"],
|
|
19084
|
-
[2, "WINDOW_DAY"],
|
|
19085
|
-
[3, "WINDOW_WEEK"]
|
|
19086
|
-
]
|
|
19087
|
-
);
|
|
19088
|
-
var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
19089
|
-
"modlock.wasm.scores.ScoreReport",
|
|
19361
|
+
// src/wasm/persist/persist.pb.ts
|
|
19362
|
+
var Value = /* @__PURE__ */ createMessageType(
|
|
19363
|
+
"modlock.wasm.persist.Value",
|
|
19090
19364
|
() => [
|
|
19091
|
-
[1, "
|
|
19092
|
-
[2, "
|
|
19093
|
-
[3, "
|
|
19094
|
-
[4, "tiebreak", 3],
|
|
19095
|
-
[5, "partition", 9, 584],
|
|
19096
|
-
[6, "key", 9],
|
|
19097
|
-
[7, "earned_at_unix_millis", 3],
|
|
19098
|
-
[8, "evidence", 9]
|
|
19365
|
+
[1, "number", 1, 0, 0, "value"],
|
|
19366
|
+
[2, "text", 9, 0, 0, "value"],
|
|
19367
|
+
[3, "tags", 11, 0, Tags.codec, "value"]
|
|
19099
19368
|
],
|
|
19100
19369
|
{
|
|
19101
19370
|
decode: (r, end, m) => {
|
|
@@ -19104,22 +19373,753 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
19104
19373
|
if ((t & 7) === 4) return m;
|
|
19105
19374
|
switch (t >>> 3) {
|
|
19106
19375
|
case 1:
|
|
19107
|
-
m.
|
|
19376
|
+
m.value = { case: "number", value: r.double() };
|
|
19108
19377
|
break;
|
|
19109
19378
|
case 2:
|
|
19110
|
-
m.
|
|
19379
|
+
m.value = { case: "text", value: r.string() };
|
|
19111
19380
|
break;
|
|
19112
19381
|
case 3:
|
|
19113
|
-
m.value =
|
|
19114
|
-
|
|
19115
|
-
|
|
19116
|
-
|
|
19382
|
+
m.value = {
|
|
19383
|
+
case: "tags",
|
|
19384
|
+
value: Tags.decode(
|
|
19385
|
+
r,
|
|
19386
|
+
r.delimited(),
|
|
19387
|
+
m.value?.case === "tags" ? m.value.value : {}
|
|
19388
|
+
)
|
|
19389
|
+
};
|
|
19117
19390
|
break;
|
|
19118
|
-
|
|
19119
|
-
|
|
19120
|
-
|
|
19121
|
-
|
|
19122
|
-
|
|
19391
|
+
default:
|
|
19392
|
+
r.skip(t);
|
|
19393
|
+
}
|
|
19394
|
+
}
|
|
19395
|
+
return m;
|
|
19396
|
+
},
|
|
19397
|
+
encode: (m, w) => {
|
|
19398
|
+
{
|
|
19399
|
+
const o = m.value;
|
|
19400
|
+
if (o?.case === "number" && o.value != null)
|
|
19401
|
+
w.uint32(9).double(o.value);
|
|
19402
|
+
}
|
|
19403
|
+
{
|
|
19404
|
+
const o = m.value;
|
|
19405
|
+
if (o?.case === "text" && o.value != null)
|
|
19406
|
+
w.uint32(18).string(o.value);
|
|
19407
|
+
}
|
|
19408
|
+
{
|
|
19409
|
+
const o = m.value;
|
|
19410
|
+
if (o?.case === "tags" && o.value != null)
|
|
19411
|
+
Tags.writeField(w, 3, o.value);
|
|
19412
|
+
}
|
|
19413
|
+
}
|
|
19414
|
+
}
|
|
19415
|
+
);
|
|
19416
|
+
var Tags = /* @__PURE__ */ createMessageType(
|
|
19417
|
+
"modlock.wasm.persist.Tags",
|
|
19418
|
+
() => [[1, "members", 9, 1]],
|
|
19419
|
+
{
|
|
19420
|
+
decode: (r, end, m) => {
|
|
19421
|
+
while (r.pos < end) {
|
|
19422
|
+
const t = r.tag();
|
|
19423
|
+
if ((t & 7) === 4) return m;
|
|
19424
|
+
switch (t >>> 3) {
|
|
19425
|
+
case 1:
|
|
19426
|
+
;
|
|
19427
|
+
(m.members ??= []).push(r.string());
|
|
19428
|
+
break;
|
|
19429
|
+
default:
|
|
19430
|
+
r.skip(t);
|
|
19431
|
+
}
|
|
19432
|
+
}
|
|
19433
|
+
return m;
|
|
19434
|
+
},
|
|
19435
|
+
encode: (m, w) => {
|
|
19436
|
+
{
|
|
19437
|
+
const a = m.members;
|
|
19438
|
+
if (a != null) for (const e of a) w.uint32(10).string(e);
|
|
19439
|
+
}
|
|
19440
|
+
}
|
|
19441
|
+
}
|
|
19442
|
+
);
|
|
19443
|
+
var Record = /* @__PURE__ */ createMessageType(
|
|
19444
|
+
"modlock.wasm.persist.Record",
|
|
19445
|
+
() => [[1, "fields", 11, 584, Value.codec]],
|
|
19446
|
+
{
|
|
19447
|
+
decode: (r, end, m) => {
|
|
19448
|
+
while (r.pos < end) {
|
|
19449
|
+
const t = r.tag();
|
|
19450
|
+
if ((t & 7) === 4) return m;
|
|
19451
|
+
switch (t >>> 3) {
|
|
19452
|
+
case 1: {
|
|
19453
|
+
const [k, v] = r.entry(
|
|
19454
|
+
(r2) => r2.string(),
|
|
19455
|
+
(r2) => Value.decode(r2, r2.delimited(), {}),
|
|
19456
|
+
"",
|
|
19457
|
+
{}
|
|
19458
|
+
);
|
|
19459
|
+
m.fields ??= newMap();
|
|
19460
|
+
m.fields[k] = v;
|
|
19461
|
+
break;
|
|
19462
|
+
}
|
|
19463
|
+
default:
|
|
19464
|
+
r.skip(t);
|
|
19465
|
+
}
|
|
19466
|
+
}
|
|
19467
|
+
return m;
|
|
19468
|
+
},
|
|
19469
|
+
encode: (m, w) => {
|
|
19470
|
+
{
|
|
19471
|
+
const o = m.fields;
|
|
19472
|
+
if (o != null)
|
|
19473
|
+
for (const [k, v] of Object.entries(o)) {
|
|
19474
|
+
const s = w.uint32(10).fork();
|
|
19475
|
+
w.uint32(10).string(k);
|
|
19476
|
+
Value.writeField(w, 2, v);
|
|
19477
|
+
w.join(s);
|
|
19478
|
+
}
|
|
19479
|
+
}
|
|
19480
|
+
}
|
|
19481
|
+
}
|
|
19482
|
+
);
|
|
19483
|
+
var Op = /* @__PURE__ */ createMessageType(
|
|
19484
|
+
"modlock.wasm.persist.Op",
|
|
19485
|
+
() => [
|
|
19486
|
+
[1, "field", 9],
|
|
19487
|
+
[2, "add", 1, 0, 0, "op"],
|
|
19488
|
+
[3, "max", 1, 0, 0, "op"],
|
|
19489
|
+
[4, "min", 1, 0, 0, "op"],
|
|
19490
|
+
[5, "set", 11, 0, Value.codec, "op"],
|
|
19491
|
+
[6, "insert", 9, 0, 0, "op"],
|
|
19492
|
+
[7, "remove", 9, 0, 0, "op"]
|
|
19493
|
+
],
|
|
19494
|
+
{
|
|
19495
|
+
decode: (r, end, m) => {
|
|
19496
|
+
while (r.pos < end) {
|
|
19497
|
+
const t = r.tag();
|
|
19498
|
+
if ((t & 7) === 4) return m;
|
|
19499
|
+
switch (t >>> 3) {
|
|
19500
|
+
case 1:
|
|
19501
|
+
m.field = r.string();
|
|
19502
|
+
break;
|
|
19503
|
+
case 2:
|
|
19504
|
+
m.op = { case: "add", value: r.double() };
|
|
19505
|
+
break;
|
|
19506
|
+
case 3:
|
|
19507
|
+
m.op = { case: "max", value: r.double() };
|
|
19508
|
+
break;
|
|
19509
|
+
case 4:
|
|
19510
|
+
m.op = { case: "min", value: r.double() };
|
|
19511
|
+
break;
|
|
19512
|
+
case 5:
|
|
19513
|
+
m.op = {
|
|
19514
|
+
case: "set",
|
|
19515
|
+
value: Value.decode(
|
|
19516
|
+
r,
|
|
19517
|
+
r.delimited(),
|
|
19518
|
+
m.op?.case === "set" ? m.op.value : {}
|
|
19519
|
+
)
|
|
19520
|
+
};
|
|
19521
|
+
break;
|
|
19522
|
+
case 6:
|
|
19523
|
+
m.op = { case: "insert", value: r.string() };
|
|
19524
|
+
break;
|
|
19525
|
+
case 7:
|
|
19526
|
+
m.op = { case: "remove", value: r.string() };
|
|
19527
|
+
break;
|
|
19528
|
+
default:
|
|
19529
|
+
r.skip(t);
|
|
19530
|
+
}
|
|
19531
|
+
}
|
|
19532
|
+
return m;
|
|
19533
|
+
},
|
|
19534
|
+
encode: (m, w) => {
|
|
19535
|
+
{
|
|
19536
|
+
const v = m.field;
|
|
19537
|
+
if (v) w.uint32(10).string(v);
|
|
19538
|
+
}
|
|
19539
|
+
{
|
|
19540
|
+
const o = m.op;
|
|
19541
|
+
if (o?.case === "add" && o.value != null) w.uint32(17).double(o.value);
|
|
19542
|
+
}
|
|
19543
|
+
{
|
|
19544
|
+
const o = m.op;
|
|
19545
|
+
if (o?.case === "max" && o.value != null) w.uint32(25).double(o.value);
|
|
19546
|
+
}
|
|
19547
|
+
{
|
|
19548
|
+
const o = m.op;
|
|
19549
|
+
if (o?.case === "min" && o.value != null) w.uint32(33).double(o.value);
|
|
19550
|
+
}
|
|
19551
|
+
{
|
|
19552
|
+
const o = m.op;
|
|
19553
|
+
if (o?.case === "set" && o.value != null)
|
|
19554
|
+
Value.writeField(w, 5, o.value);
|
|
19555
|
+
}
|
|
19556
|
+
{
|
|
19557
|
+
const o = m.op;
|
|
19558
|
+
if (o?.case === "insert" && o.value != null)
|
|
19559
|
+
w.uint32(50).string(o.value);
|
|
19560
|
+
}
|
|
19561
|
+
{
|
|
19562
|
+
const o = m.op;
|
|
19563
|
+
if (o?.case === "remove" && o.value != null)
|
|
19564
|
+
w.uint32(58).string(o.value);
|
|
19565
|
+
}
|
|
19566
|
+
}
|
|
19567
|
+
}
|
|
19568
|
+
);
|
|
19569
|
+
var GetRequest = /* @__PURE__ */ createMessageType(
|
|
19570
|
+
"modlock.wasm.persist.GetRequest",
|
|
19571
|
+
() => [
|
|
19572
|
+
[1, "player", 5],
|
|
19573
|
+
[2, "type", 9],
|
|
19574
|
+
[3, "key", 9],
|
|
19575
|
+
[16, "generation", 13]
|
|
19576
|
+
],
|
|
19577
|
+
{
|
|
19578
|
+
decode: (r, end, m) => {
|
|
19579
|
+
while (r.pos < end) {
|
|
19580
|
+
const t = r.tag();
|
|
19581
|
+
if ((t & 7) === 4) return m;
|
|
19582
|
+
switch (t >>> 3) {
|
|
19583
|
+
case 1:
|
|
19584
|
+
m.player = r.int32();
|
|
19585
|
+
break;
|
|
19586
|
+
case 2:
|
|
19587
|
+
m.type = r.string();
|
|
19588
|
+
break;
|
|
19589
|
+
case 3:
|
|
19590
|
+
m.key = r.string();
|
|
19591
|
+
break;
|
|
19592
|
+
case 16:
|
|
19593
|
+
m.generation = r.uint32();
|
|
19594
|
+
break;
|
|
19595
|
+
default:
|
|
19596
|
+
r.skip(t);
|
|
19597
|
+
}
|
|
19598
|
+
}
|
|
19599
|
+
return m;
|
|
19600
|
+
},
|
|
19601
|
+
encode: (m, w) => {
|
|
19602
|
+
{
|
|
19603
|
+
const v = m.player;
|
|
19604
|
+
if (v) w.uint32(8).int32(v);
|
|
19605
|
+
}
|
|
19606
|
+
{
|
|
19607
|
+
const v = m.type;
|
|
19608
|
+
if (v) w.uint32(18).string(v);
|
|
19609
|
+
}
|
|
19610
|
+
{
|
|
19611
|
+
const v = m.key;
|
|
19612
|
+
if (v) w.uint32(26).string(v);
|
|
19613
|
+
}
|
|
19614
|
+
{
|
|
19615
|
+
const v = m.generation;
|
|
19616
|
+
if (v) w.uint32(128).uint32(v);
|
|
19617
|
+
}
|
|
19618
|
+
}
|
|
19619
|
+
}
|
|
19620
|
+
);
|
|
19621
|
+
var GetReply = /* @__PURE__ */ createMessageType(
|
|
19622
|
+
"modlock.wasm.persist.GetReply",
|
|
19623
|
+
() => [[1, "record", 11, 0, Record.codec]],
|
|
19624
|
+
{
|
|
19625
|
+
decode: (r, end, m) => {
|
|
19626
|
+
while (r.pos < end) {
|
|
19627
|
+
const t = r.tag();
|
|
19628
|
+
if ((t & 7) === 4) return m;
|
|
19629
|
+
switch (t >>> 3) {
|
|
19630
|
+
case 1:
|
|
19631
|
+
m.record = Record.decode(r, r.delimited(), m.record ?? {});
|
|
19632
|
+
break;
|
|
19633
|
+
default:
|
|
19634
|
+
r.skip(t);
|
|
19635
|
+
}
|
|
19636
|
+
}
|
|
19637
|
+
return m;
|
|
19638
|
+
},
|
|
19639
|
+
encode: (m, w) => {
|
|
19640
|
+
{
|
|
19641
|
+
const v = m.record;
|
|
19642
|
+
if (v != null) Record.writeField(w, 1, v);
|
|
19643
|
+
}
|
|
19644
|
+
}
|
|
19645
|
+
}
|
|
19646
|
+
);
|
|
19647
|
+
var GetManyRequest = /* @__PURE__ */ createMessageType(
|
|
19648
|
+
"modlock.wasm.persist.GetManyRequest",
|
|
19649
|
+
() => [
|
|
19650
|
+
[1, "players", 5, 3],
|
|
19651
|
+
[2, "type", 9],
|
|
19652
|
+
[16, "generations", 13, 3]
|
|
19653
|
+
],
|
|
19654
|
+
{
|
|
19655
|
+
decode: (r, end, m) => {
|
|
19656
|
+
while (r.pos < end) {
|
|
19657
|
+
const t = r.tag();
|
|
19658
|
+
if ((t & 7) === 4) return m;
|
|
19659
|
+
switch (t >>> 3) {
|
|
19660
|
+
case 1:
|
|
19661
|
+
for (const e = r.run(t), a = m.players ??= []; r.pos < e; )
|
|
19662
|
+
a.push(r.int32());
|
|
19663
|
+
break;
|
|
19664
|
+
case 2:
|
|
19665
|
+
m.type = r.string();
|
|
19666
|
+
break;
|
|
19667
|
+
case 16:
|
|
19668
|
+
for (const e = r.run(t), a = m.generations ??= []; r.pos < e; )
|
|
19669
|
+
a.push(r.uint32());
|
|
19670
|
+
break;
|
|
19671
|
+
default:
|
|
19672
|
+
r.skip(t);
|
|
19673
|
+
}
|
|
19674
|
+
}
|
|
19675
|
+
return m;
|
|
19676
|
+
},
|
|
19677
|
+
encode: (m, w) => {
|
|
19678
|
+
{
|
|
19679
|
+
const a = m.players;
|
|
19680
|
+
if (a != null && a.length > 0) {
|
|
19681
|
+
const s = w.uint32(10).fork();
|
|
19682
|
+
for (const e of a) w.int32(e);
|
|
19683
|
+
w.join(s);
|
|
19684
|
+
}
|
|
19685
|
+
}
|
|
19686
|
+
{
|
|
19687
|
+
const v = m.type;
|
|
19688
|
+
if (v) w.uint32(18).string(v);
|
|
19689
|
+
}
|
|
19690
|
+
{
|
|
19691
|
+
const a = m.generations;
|
|
19692
|
+
if (a != null && a.length > 0) {
|
|
19693
|
+
const s = w.uint32(130).fork();
|
|
19694
|
+
for (const e of a) w.uint32(e);
|
|
19695
|
+
w.join(s);
|
|
19696
|
+
}
|
|
19697
|
+
}
|
|
19698
|
+
}
|
|
19699
|
+
}
|
|
19700
|
+
);
|
|
19701
|
+
var GetManyReply = /* @__PURE__ */ createMessageType(
|
|
19702
|
+
"modlock.wasm.persist.GetManyReply",
|
|
19703
|
+
() => [[1, "records", 11, 1, PlayerRecord.codec]],
|
|
19704
|
+
{
|
|
19705
|
+
decode: (r, end, m) => {
|
|
19706
|
+
while (r.pos < end) {
|
|
19707
|
+
const t = r.tag();
|
|
19708
|
+
if ((t & 7) === 4) return m;
|
|
19709
|
+
switch (t >>> 3) {
|
|
19710
|
+
case 1:
|
|
19711
|
+
;
|
|
19712
|
+
(m.records ??= []).push(
|
|
19713
|
+
PlayerRecord.decode(r, r.delimited(), {})
|
|
19714
|
+
);
|
|
19715
|
+
break;
|
|
19716
|
+
default:
|
|
19717
|
+
r.skip(t);
|
|
19718
|
+
}
|
|
19719
|
+
}
|
|
19720
|
+
return m;
|
|
19721
|
+
},
|
|
19722
|
+
encode: (m, w) => {
|
|
19723
|
+
{
|
|
19724
|
+
const a = m.records;
|
|
19725
|
+
if (a != null) for (const e of a) PlayerRecord.writeField(w, 1, e);
|
|
19726
|
+
}
|
|
19727
|
+
}
|
|
19728
|
+
}
|
|
19729
|
+
);
|
|
19730
|
+
var PlayerRecord = /* @__PURE__ */ createMessageType(
|
|
19731
|
+
"modlock.wasm.persist.PlayerRecord",
|
|
19732
|
+
() => [
|
|
19733
|
+
[1, "player", 5],
|
|
19734
|
+
[2, "record", 11, 0, Record.codec]
|
|
19735
|
+
],
|
|
19736
|
+
{
|
|
19737
|
+
decode: (r, end, m) => {
|
|
19738
|
+
while (r.pos < end) {
|
|
19739
|
+
const t = r.tag();
|
|
19740
|
+
if ((t & 7) === 4) return m;
|
|
19741
|
+
switch (t >>> 3) {
|
|
19742
|
+
case 1:
|
|
19743
|
+
m.player = r.int32();
|
|
19744
|
+
break;
|
|
19745
|
+
case 2:
|
|
19746
|
+
m.record = Record.decode(r, r.delimited(), m.record ?? {});
|
|
19747
|
+
break;
|
|
19748
|
+
default:
|
|
19749
|
+
r.skip(t);
|
|
19750
|
+
}
|
|
19751
|
+
}
|
|
19752
|
+
return m;
|
|
19753
|
+
},
|
|
19754
|
+
encode: (m, w) => {
|
|
19755
|
+
{
|
|
19756
|
+
const v = m.player;
|
|
19757
|
+
if (v) w.uint32(8).int32(v);
|
|
19758
|
+
}
|
|
19759
|
+
{
|
|
19760
|
+
const v = m.record;
|
|
19761
|
+
if (v != null) Record.writeField(w, 2, v);
|
|
19762
|
+
}
|
|
19763
|
+
}
|
|
19764
|
+
}
|
|
19765
|
+
);
|
|
19766
|
+
var UpdateRequest = /* @__PURE__ */ createMessageType(
|
|
19767
|
+
"modlock.wasm.persist.UpdateRequest",
|
|
19768
|
+
() => [
|
|
19769
|
+
[1, "player", 5],
|
|
19770
|
+
[2, "type", 9],
|
|
19771
|
+
[3, "key", 9],
|
|
19772
|
+
[4, "ops", 11, 1, Op.codec],
|
|
19773
|
+
[5, "update_key", 9],
|
|
19774
|
+
[16, "generation", 13]
|
|
19775
|
+
],
|
|
19776
|
+
{
|
|
19777
|
+
decode: (r, end, m) => {
|
|
19778
|
+
while (r.pos < end) {
|
|
19779
|
+
const t = r.tag();
|
|
19780
|
+
if ((t & 7) === 4) return m;
|
|
19781
|
+
switch (t >>> 3) {
|
|
19782
|
+
case 1:
|
|
19783
|
+
m.player = r.int32();
|
|
19784
|
+
break;
|
|
19785
|
+
case 2:
|
|
19786
|
+
m.type = r.string();
|
|
19787
|
+
break;
|
|
19788
|
+
case 3:
|
|
19789
|
+
m.key = r.string();
|
|
19790
|
+
break;
|
|
19791
|
+
case 4:
|
|
19792
|
+
;
|
|
19793
|
+
(m.ops ??= []).push(Op.decode(r, r.delimited(), {}));
|
|
19794
|
+
break;
|
|
19795
|
+
case 5:
|
|
19796
|
+
m.updateKey = r.string();
|
|
19797
|
+
break;
|
|
19798
|
+
case 16:
|
|
19799
|
+
m.generation = r.uint32();
|
|
19800
|
+
break;
|
|
19801
|
+
default:
|
|
19802
|
+
r.skip(t);
|
|
19803
|
+
}
|
|
19804
|
+
}
|
|
19805
|
+
return m;
|
|
19806
|
+
},
|
|
19807
|
+
encode: (m, w) => {
|
|
19808
|
+
{
|
|
19809
|
+
const v = m.player;
|
|
19810
|
+
if (v) w.uint32(8).int32(v);
|
|
19811
|
+
}
|
|
19812
|
+
{
|
|
19813
|
+
const v = m.type;
|
|
19814
|
+
if (v) w.uint32(18).string(v);
|
|
19815
|
+
}
|
|
19816
|
+
{
|
|
19817
|
+
const v = m.key;
|
|
19818
|
+
if (v) w.uint32(26).string(v);
|
|
19819
|
+
}
|
|
19820
|
+
{
|
|
19821
|
+
const a = m.ops;
|
|
19822
|
+
if (a != null) for (const e of a) Op.writeField(w, 4, e);
|
|
19823
|
+
}
|
|
19824
|
+
{
|
|
19825
|
+
const v = m.updateKey;
|
|
19826
|
+
if (v) w.uint32(42).string(v);
|
|
19827
|
+
}
|
|
19828
|
+
{
|
|
19829
|
+
const v = m.generation;
|
|
19830
|
+
if (v) w.uint32(128).uint32(v);
|
|
19831
|
+
}
|
|
19832
|
+
}
|
|
19833
|
+
}
|
|
19834
|
+
);
|
|
19835
|
+
var UpdateReply = /* @__PURE__ */ createMessageType(
|
|
19836
|
+
"modlock.wasm.persist.UpdateReply",
|
|
19837
|
+
() => [
|
|
19838
|
+
[1, "record", 11, 0, Record.codec],
|
|
19839
|
+
[2, "repeated", 8]
|
|
19840
|
+
],
|
|
19841
|
+
{
|
|
19842
|
+
decode: (r, end, m) => {
|
|
19843
|
+
while (r.pos < end) {
|
|
19844
|
+
const t = r.tag();
|
|
19845
|
+
if ((t & 7) === 4) return m;
|
|
19846
|
+
switch (t >>> 3) {
|
|
19847
|
+
case 1:
|
|
19848
|
+
m.record = Record.decode(r, r.delimited(), m.record ?? {});
|
|
19849
|
+
break;
|
|
19850
|
+
case 2:
|
|
19851
|
+
m.repeated = r.bool();
|
|
19852
|
+
break;
|
|
19853
|
+
default:
|
|
19854
|
+
r.skip(t);
|
|
19855
|
+
}
|
|
19856
|
+
}
|
|
19857
|
+
return m;
|
|
19858
|
+
},
|
|
19859
|
+
encode: (m, w) => {
|
|
19860
|
+
{
|
|
19861
|
+
const v = m.record;
|
|
19862
|
+
if (v != null) Record.writeField(w, 1, v);
|
|
19863
|
+
}
|
|
19864
|
+
{
|
|
19865
|
+
const v = m.repeated;
|
|
19866
|
+
if (v) w.uint32(16).bool(v);
|
|
19867
|
+
}
|
|
19868
|
+
}
|
|
19869
|
+
}
|
|
19870
|
+
);
|
|
19871
|
+
|
|
19872
|
+
// js/src/persist.ts
|
|
19873
|
+
var service = "persist";
|
|
19874
|
+
var entries2 = /* @__PURE__ */ new WeakMap();
|
|
19875
|
+
var requests = 0;
|
|
19876
|
+
function entry(player, type) {
|
|
19877
|
+
let records = entries2.get(player);
|
|
19878
|
+
if (!records) {
|
|
19879
|
+
records = /* @__PURE__ */ new Map();
|
|
19880
|
+
entries2.set(player, records);
|
|
19881
|
+
}
|
|
19882
|
+
let known2 = records.get(type);
|
|
19883
|
+
if (!known2) {
|
|
19884
|
+
known2 = { read: { state: "loading" }, started: 0, applied: 0 };
|
|
19885
|
+
records.set(type, known2);
|
|
19886
|
+
}
|
|
19887
|
+
return known2;
|
|
19888
|
+
}
|
|
19889
|
+
function settle2(known2, request, read) {
|
|
19890
|
+
if (request < known2.applied) return;
|
|
19891
|
+
known2.applied = request;
|
|
19892
|
+
known2.read = read;
|
|
19893
|
+
}
|
|
19894
|
+
function start(known2) {
|
|
19895
|
+
known2.started = ++requests;
|
|
19896
|
+
return known2.started;
|
|
19897
|
+
}
|
|
19898
|
+
var left = "the player left; their Player no longer names a connection, and the slot may hold another player";
|
|
19899
|
+
function generation(player) {
|
|
19900
|
+
const held = connection(player);
|
|
19901
|
+
if (held === void 0 || held.player !== player || !held.generation) {
|
|
19902
|
+
return void 0;
|
|
19903
|
+
}
|
|
19904
|
+
return held.generation;
|
|
19905
|
+
}
|
|
19906
|
+
function load(player, type, known2) {
|
|
19907
|
+
const request = start(known2);
|
|
19908
|
+
const live2 = generation(player);
|
|
19909
|
+
if (live2 === void 0) {
|
|
19910
|
+
settle2(known2, request, unavailable(type, left));
|
|
19911
|
+
return;
|
|
19912
|
+
}
|
|
19913
|
+
callServiceLater(
|
|
19914
|
+
service,
|
|
19915
|
+
"Get",
|
|
19916
|
+
GetRequest.toBinary({
|
|
19917
|
+
player: player.slot,
|
|
19918
|
+
type,
|
|
19919
|
+
generation: live2
|
|
19920
|
+
}),
|
|
19921
|
+
(reply2, error) => {
|
|
19922
|
+
if (reply2 === void 0) {
|
|
19923
|
+
settle2(known2, request, unavailable(type, error));
|
|
19924
|
+
return;
|
|
19925
|
+
}
|
|
19926
|
+
const answer = GetReply.fromBinary(reply2);
|
|
19927
|
+
settle2(known2, request, { state: "loaded", record: decode(answer.record) });
|
|
19928
|
+
}
|
|
19929
|
+
);
|
|
19930
|
+
}
|
|
19931
|
+
function unavailable(type, error) {
|
|
19932
|
+
const why = error || "the host answered nothing";
|
|
19933
|
+
log(`persist ${type}: ${why}`);
|
|
19934
|
+
return { state: "unavailable", error: why };
|
|
19935
|
+
}
|
|
19936
|
+
var persist = {
|
|
19937
|
+
/**
|
|
19938
|
+
* get returns player's record of type, a record type the manifest
|
|
19939
|
+
* declares. The first get starts the read and answers loading; a later
|
|
19940
|
+
* get answers what the host sent. A record never written loads empty.
|
|
19941
|
+
*/
|
|
19942
|
+
get(player, type) {
|
|
19943
|
+
const known2 = entry(player, type);
|
|
19944
|
+
if (known2.started === 0) load(player, type, known2);
|
|
19945
|
+
return known2.read;
|
|
19946
|
+
},
|
|
19947
|
+
/**
|
|
19948
|
+
* getMany starts reading the record of type for each of players, up to
|
|
19949
|
+
* 16, in one call, such as everyone in a lobby at join. persist.get then
|
|
19950
|
+
* answers each; a Player kept after its player left answers unavailable.
|
|
19951
|
+
*/
|
|
19952
|
+
getMany(players2, type) {
|
|
19953
|
+
const pending = [];
|
|
19954
|
+
for (const player of players2) {
|
|
19955
|
+
const known2 = entry(player, type);
|
|
19956
|
+
const request = start(known2);
|
|
19957
|
+
const live2 = generation(player);
|
|
19958
|
+
if (live2 === void 0) {
|
|
19959
|
+
settle2(known2, request, unavailable(type, left));
|
|
19960
|
+
continue;
|
|
19961
|
+
}
|
|
19962
|
+
pending.push({ player, known: known2, request, generation: live2 });
|
|
19963
|
+
}
|
|
19964
|
+
if (pending.length === 0) return;
|
|
19965
|
+
callServiceLater(
|
|
19966
|
+
service,
|
|
19967
|
+
"GetMany",
|
|
19968
|
+
GetManyRequest.toBinary({
|
|
19969
|
+
players: pending.map((p) => p.player.slot),
|
|
19970
|
+
generations: pending.map((p) => p.generation),
|
|
19971
|
+
type
|
|
19972
|
+
}),
|
|
19973
|
+
(reply2, error) => {
|
|
19974
|
+
if (reply2 === void 0) {
|
|
19975
|
+
const read = unavailable(type, error);
|
|
19976
|
+
for (const p of pending) settle2(p.known, p.request, read);
|
|
19977
|
+
return;
|
|
19978
|
+
}
|
|
19979
|
+
const records = new Map(
|
|
19980
|
+
(GetManyReply.fromBinary(reply2).records ?? []).map((r) => [
|
|
19981
|
+
r.player ?? 0,
|
|
19982
|
+
decode(r.record)
|
|
19983
|
+
])
|
|
19984
|
+
);
|
|
19985
|
+
for (const p of pending) {
|
|
19986
|
+
settle2(p.known, p.request, {
|
|
19987
|
+
state: "loaded",
|
|
19988
|
+
record: records.get(p.player.slot) ?? {}
|
|
19989
|
+
});
|
|
19990
|
+
}
|
|
19991
|
+
}
|
|
19992
|
+
);
|
|
19993
|
+
},
|
|
19994
|
+
/**
|
|
19995
|
+
* update changes player's record of type by changes, which the host
|
|
19996
|
+
* applies all or none. With a key, an update the host already took is left
|
|
19997
|
+
* out, so resending after a lost answer counts once. An update with an add
|
|
19998
|
+
* and no key is refused without being sent, since a resend would count it
|
|
19999
|
+
* twice. An update the host answers as taking too long may still have been
|
|
20000
|
+
* kept: send it again with the same key, and do not act as if nothing was
|
|
20001
|
+
* written. persist.get answers the changed record once the host has
|
|
20002
|
+
* answered, and done runs then. An update for a Player kept after its
|
|
20003
|
+
* player left is refused without being sent.
|
|
20004
|
+
*/
|
|
20005
|
+
update(player, type, changes, options = {}, done) {
|
|
20006
|
+
const ops = encode(changes);
|
|
20007
|
+
if (!options.key && ops.some((op) => op.op?.case === "add")) {
|
|
20008
|
+
const why = "a persist update that adds needs an update key, so a resend counts once";
|
|
20009
|
+
log(`persist ${type} update: ${why}`);
|
|
20010
|
+
done?.(void 0, why);
|
|
20011
|
+
return;
|
|
20012
|
+
}
|
|
20013
|
+
const live2 = generation(player);
|
|
20014
|
+
if (live2 === void 0) {
|
|
20015
|
+
log(`persist ${type} update: ${left}`);
|
|
20016
|
+
done?.(void 0, left);
|
|
20017
|
+
return;
|
|
20018
|
+
}
|
|
20019
|
+
const known2 = entry(player, type);
|
|
20020
|
+
const request = start(known2);
|
|
20021
|
+
callServiceLater(
|
|
20022
|
+
service,
|
|
20023
|
+
"Update",
|
|
20024
|
+
UpdateRequest.toBinary({
|
|
20025
|
+
player: player.slot,
|
|
20026
|
+
generation: live2,
|
|
20027
|
+
type,
|
|
20028
|
+
key: options.record,
|
|
20029
|
+
ops,
|
|
20030
|
+
updateKey: options.key
|
|
20031
|
+
}),
|
|
20032
|
+
(reply2, error) => {
|
|
20033
|
+
if (reply2 === void 0) {
|
|
20034
|
+
const why = error || "the host answered nothing";
|
|
20035
|
+
log(`persist ${type} update: ${why}`);
|
|
20036
|
+
done?.(void 0, why);
|
|
20037
|
+
return;
|
|
20038
|
+
}
|
|
20039
|
+
const answer = UpdateReply.fromBinary(reply2);
|
|
20040
|
+
const record = decode(answer.record);
|
|
20041
|
+
settle2(known2, request, { state: "loaded", record });
|
|
20042
|
+
done?.(record, void 0, answer.repeated ?? false);
|
|
20043
|
+
}
|
|
20044
|
+
);
|
|
20045
|
+
},
|
|
20046
|
+
/** refresh reads player's record of type again, such as after unavailable. */
|
|
20047
|
+
refresh(player, type) {
|
|
20048
|
+
load(player, type, entry(player, type));
|
|
20049
|
+
}
|
|
20050
|
+
};
|
|
20051
|
+
function encode(changes) {
|
|
20052
|
+
const ops = [];
|
|
20053
|
+
for (const [field, change2] of Object.entries(changes)) {
|
|
20054
|
+
const list = Array.isArray(change2) ? change2 : [change2];
|
|
20055
|
+
for (const one of list) ops.push({ field, op: operation(one) });
|
|
20056
|
+
}
|
|
20057
|
+
return ops;
|
|
20058
|
+
}
|
|
20059
|
+
function operation(change2) {
|
|
20060
|
+
if ("add" in change2) return { case: "add", value: change2.add };
|
|
20061
|
+
if ("max" in change2) return { case: "max", value: change2.max };
|
|
20062
|
+
if ("min" in change2) return { case: "min", value: change2.min };
|
|
20063
|
+
if ("insert" in change2) return { case: "insert", value: change2.insert };
|
|
20064
|
+
if ("remove" in change2) return { case: "remove", value: change2.remove };
|
|
20065
|
+
const value = typeof change2.set === "string" ? { case: "text", value: change2.set } : { case: "number", value: change2.set };
|
|
20066
|
+
return { case: "set", value: { value } };
|
|
20067
|
+
}
|
|
20068
|
+
function decode(record) {
|
|
20069
|
+
const fields = {};
|
|
20070
|
+
for (const [name, value] of Object.entries(record?.fields ?? {})) {
|
|
20071
|
+
const v = value.value;
|
|
20072
|
+
if (v?.case === "number" || v?.case === "text") fields[name] = v.value;
|
|
20073
|
+
if (v?.case === "tags") fields[name] = v.value.members ?? [];
|
|
20074
|
+
}
|
|
20075
|
+
return fields;
|
|
20076
|
+
}
|
|
20077
|
+
|
|
20078
|
+
// src/wasm/scores/scores.pb.ts
|
|
20079
|
+
var Window_Enum = /* @__PURE__ */ createEnumType(
|
|
20080
|
+
"modlock.wasm.scores.Window",
|
|
20081
|
+
[
|
|
20082
|
+
[0, "WINDOW_UNKNOWN"],
|
|
20083
|
+
[1, "WINDOW_ALL_TIME"],
|
|
20084
|
+
[2, "WINDOW_DAY"],
|
|
20085
|
+
[3, "WINDOW_WEEK"]
|
|
20086
|
+
]
|
|
20087
|
+
);
|
|
20088
|
+
var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
20089
|
+
"modlock.wasm.scores.ScoreReport",
|
|
20090
|
+
() => [
|
|
20091
|
+
[1, "board", 9],
|
|
20092
|
+
[2, "player", 5],
|
|
20093
|
+
[3, "value", 3],
|
|
20094
|
+
[4, "tiebreak", 3],
|
|
20095
|
+
[5, "partition", 9, 584],
|
|
20096
|
+
[6, "key", 9],
|
|
20097
|
+
[7, "earned_at_unix_millis", 3],
|
|
20098
|
+
[8, "evidence", 9]
|
|
20099
|
+
],
|
|
20100
|
+
{
|
|
20101
|
+
decode: (r, end, m) => {
|
|
20102
|
+
while (r.pos < end) {
|
|
20103
|
+
const t = r.tag();
|
|
20104
|
+
if ((t & 7) === 4) return m;
|
|
20105
|
+
switch (t >>> 3) {
|
|
20106
|
+
case 1:
|
|
20107
|
+
m.board = r.string();
|
|
20108
|
+
break;
|
|
20109
|
+
case 2:
|
|
20110
|
+
m.player = r.int32();
|
|
20111
|
+
break;
|
|
20112
|
+
case 3:
|
|
20113
|
+
m.value = r.int64();
|
|
20114
|
+
break;
|
|
20115
|
+
case 4:
|
|
20116
|
+
m.tiebreak = r.int64();
|
|
20117
|
+
break;
|
|
20118
|
+
case 5: {
|
|
20119
|
+
const [k, v] = r.entry(
|
|
20120
|
+
(r2) => r2.string(),
|
|
20121
|
+
(r2) => r2.string(),
|
|
20122
|
+
"",
|
|
19123
20123
|
""
|
|
19124
20124
|
);
|
|
19125
20125
|
m.partition ??= newMap();
|
|
@@ -19507,7 +20507,7 @@ var Standing = /* @__PURE__ */ createMessageType(
|
|
|
19507
20507
|
);
|
|
19508
20508
|
|
|
19509
20509
|
// js/src/scores.ts
|
|
19510
|
-
var
|
|
20510
|
+
var service2 = "scores";
|
|
19511
20511
|
var windowValues = {
|
|
19512
20512
|
allTime: 1 /* ALL_TIME */,
|
|
19513
20513
|
day: 2 /* DAY */,
|
|
@@ -19559,7 +20559,7 @@ function readBoard(board, read = {}) {
|
|
|
19559
20559
|
limit: read.limit,
|
|
19560
20560
|
player: read.player?.slot
|
|
19561
20561
|
});
|
|
19562
|
-
const reply2 = callService(
|
|
20562
|
+
const reply2 = callService(service2, "Read", query);
|
|
19563
20563
|
if (reply2 === void 0) return void 0;
|
|
19564
20564
|
const page = BoardPage.fromBinary(reply2);
|
|
19565
20565
|
return {
|
|
@@ -19569,7 +20569,7 @@ function readBoard(board, read = {}) {
|
|
|
19569
20569
|
};
|
|
19570
20570
|
}
|
|
19571
20571
|
function taken(method, report, line2) {
|
|
19572
|
-
if (callService(
|
|
20572
|
+
if (callService(service2, method, report) !== void 0) return true;
|
|
19573
20573
|
log(`score ${line2} (not reported: the host keeps no scores)`);
|
|
19574
20574
|
return false;
|
|
19575
20575
|
}
|
|
@@ -19596,8 +20596,8 @@ function describe(partition) {
|
|
|
19596
20596
|
function log2(...parts) {
|
|
19597
20597
|
log(parts.map((part) => String(part)).join(" "));
|
|
19598
20598
|
}
|
|
19599
|
-
function serve(
|
|
19600
|
-
services.set(
|
|
20599
|
+
function serve(service3, handler) {
|
|
20600
|
+
services.set(service3, { handler });
|
|
19601
20601
|
}
|
|
19602
20602
|
function command(name, handler) {
|
|
19603
20603
|
commands.set(name, { handler });
|
|
@@ -19832,7 +20832,7 @@ var handlers = {
|
|
|
19832
20832
|
}
|
|
19833
20833
|
},
|
|
19834
20834
|
uiPress(event) {
|
|
19835
|
-
after(0, () => press(event.player, event.node));
|
|
20835
|
+
after(0, () => press(event.player, event.node, event.action, event.payload));
|
|
19836
20836
|
},
|
|
19837
20837
|
uiInput(event) {
|
|
19838
20838
|
after(0, () => change(event.player, event.node, event.value));
|
|
@@ -19844,6 +20844,9 @@ var handlers = {
|
|
|
19844
20844
|
}
|
|
19845
20845
|
return { payload: registered.handler(event.method, event.payload) };
|
|
19846
20846
|
},
|
|
20847
|
+
serviceReplied(event) {
|
|
20848
|
+
endServiceCall(event);
|
|
20849
|
+
},
|
|
19847
20850
|
// scriptc types an unannotated method that returns literals of different
|
|
19848
20851
|
// shapes by those literals rather than by ModHandlers, and the call throws.
|
|
19849
20852
|
damage(event) {
|
|
@@ -19984,6 +20987,7 @@ export {
|
|
|
19984
20987
|
Roster,
|
|
19985
20988
|
Score2 as Score,
|
|
19986
20989
|
Standings,
|
|
20990
|
+
Stragglers,
|
|
19987
20991
|
Strays,
|
|
19988
20992
|
Tag,
|
|
19989
20993
|
Text,
|
|
@@ -19998,6 +21002,7 @@ export {
|
|
|
19998
21002
|
blockInput,
|
|
19999
21003
|
bystanderStates,
|
|
20000
21004
|
callService,
|
|
21005
|
+
callServiceLater,
|
|
20001
21006
|
cameraPulse,
|
|
20002
21007
|
cameraShake,
|
|
20003
21008
|
clearMap,
|
|
@@ -20085,6 +21090,7 @@ export {
|
|
|
20085
21090
|
onStart,
|
|
20086
21091
|
onWorld,
|
|
20087
21092
|
pause,
|
|
21093
|
+
persist,
|
|
20088
21094
|
playCamera,
|
|
20089
21095
|
players,
|
|
20090
21096
|
poseAt,
|
|
@@ -20128,8 +21134,10 @@ export {
|
|
|
20128
21134
|
silenceVoice,
|
|
20129
21135
|
spawnNpc,
|
|
20130
21136
|
startRift,
|
|
21137
|
+
startServiceCall,
|
|
20131
21138
|
startingRating,
|
|
20132
21139
|
stopSound,
|
|
21140
|
+
stragglerConnectSeconds,
|
|
20133
21141
|
strayGraceSeconds,
|
|
20134
21142
|
theme_exports as theme,
|
|
20135
21143
|
ticksPerSecond,
|