@modlock/modlock 0.1.86 → 0.1.88
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/index.d.ts +1 -1
- package/index.js +336 -69
- package/package.json +6 -6
- package/scores.d.ts +34 -38
package/index.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export { type HeroSnapshot, restoreHero } from './restore.js';
|
|
|
29
29
|
export { type ReplayedHit, replayDamage } from './replayed-damage.js';
|
|
30
30
|
export { type CatalogEntry, Dropper, dropperButtons } from './dropper.js';
|
|
31
31
|
export { persist, type PersistChange, type PersistChanges, type PersistDone, type PersistOptions, type PersistRead, type PersistRecord, type PersistValue, } from './persist.js';
|
|
32
|
-
export { type BoardPage, type BoardRead, type BoardRow, type BoardWindow, type MatchPlace, readBoard, reportMatch, reportScore, type ScoreOptions, } from './scores.js';
|
|
32
|
+
export { bindScorePlayer, type BoardPage, type BoardRead, type BoardRow, type BoardWindow, type MatchPlace, readBoard, reportMatch, reportScore, type ScoreDone, type ScoreOptions, type ScorePlayer, } from './scores.js';
|
|
33
33
|
export { decodeSpot, encodeSpot, LoadedSpot, loadSpot, type Placed, type Spot, type SpotObject, triggers, } from './spot.js';
|
|
34
34
|
export { type ButtonProps, type Child, type Component, type Edges, type ElementProps, Fragment, type Gradient, type HeroLookName, type HeroProps, hide, hideHud, cursorFree, freeCursor, abilityBarPresses, type AbilityBarHandler, abilityDisplay, type AbilityRow, type ShownAbility, type HudPart, type ImageProps, type JSX, jsx, jsxs, type LabelProps, type LayoutProps, type Length, type Overflow, type PanelProps, route, type Scaling, type Shadow, sheet, show, type Style, toast, type Transition, type UiElement, uiSound, } from './ui.js';
|
|
35
35
|
/** LogPart is a value log writes as text. */
|
package/index.js
CHANGED
|
@@ -218,6 +218,123 @@ var BinaryWriter = class {
|
|
|
218
218
|
}
|
|
219
219
|
};
|
|
220
220
|
var overLimit = new Error("size limit exceeded");
|
|
221
|
+
var SizeWriter = class {
|
|
222
|
+
/** Number of bytes counted so far. */
|
|
223
|
+
size = 0;
|
|
224
|
+
limit;
|
|
225
|
+
constructor(limit) {
|
|
226
|
+
this.limit = limit;
|
|
227
|
+
}
|
|
228
|
+
fork() {
|
|
229
|
+
return this.size;
|
|
230
|
+
}
|
|
231
|
+
join(start2) {
|
|
232
|
+
return this.add(varintSize(this.size - start2));
|
|
233
|
+
}
|
|
234
|
+
tag(fieldNo, wireType2) {
|
|
235
|
+
return this.add(varintSize((fieldNo << 3 | wireType2) >>> 0));
|
|
236
|
+
}
|
|
237
|
+
raw(chunk) {
|
|
238
|
+
return this.add(chunk.length);
|
|
239
|
+
}
|
|
240
|
+
uint32(value) {
|
|
241
|
+
return this.add(varintSize(value >>> 0));
|
|
242
|
+
}
|
|
243
|
+
int32(value) {
|
|
244
|
+
return this.add(value < 0 ? 10 : varintSize(value));
|
|
245
|
+
}
|
|
246
|
+
sint32(value) {
|
|
247
|
+
return this.uint32(value << 1 ^ value >> 31);
|
|
248
|
+
}
|
|
249
|
+
bool() {
|
|
250
|
+
return this.add(1);
|
|
251
|
+
}
|
|
252
|
+
int64(value) {
|
|
253
|
+
const hi = Number(BigInt.asUintN(32, value >> 32n));
|
|
254
|
+
if (hi === 0) {
|
|
255
|
+
return this.add(varintSize(Number(BigInt.asUintN(32, value))));
|
|
256
|
+
}
|
|
257
|
+
return this.add(4 + varintSize(hi * 16 + 15));
|
|
258
|
+
}
|
|
259
|
+
uint64(value) {
|
|
260
|
+
return this.int64(value);
|
|
261
|
+
}
|
|
262
|
+
sint64(value) {
|
|
263
|
+
return this.int64(value << 1n ^ value >> 63n);
|
|
264
|
+
}
|
|
265
|
+
fixed32() {
|
|
266
|
+
return this.add(4);
|
|
267
|
+
}
|
|
268
|
+
sfixed32() {
|
|
269
|
+
return this.add(4);
|
|
270
|
+
}
|
|
271
|
+
fixed64() {
|
|
272
|
+
return this.add(8);
|
|
273
|
+
}
|
|
274
|
+
sfixed64() {
|
|
275
|
+
return this.add(8);
|
|
276
|
+
}
|
|
277
|
+
float() {
|
|
278
|
+
return this.add(4);
|
|
279
|
+
}
|
|
280
|
+
double() {
|
|
281
|
+
return this.add(8);
|
|
282
|
+
}
|
|
283
|
+
bytes(value) {
|
|
284
|
+
return this.add(varintSize(value.length) + value.length);
|
|
285
|
+
}
|
|
286
|
+
string(value) {
|
|
287
|
+
const length3 = utf8Length(value);
|
|
288
|
+
return this.add(varintSize(length3) + length3);
|
|
289
|
+
}
|
|
290
|
+
add(n) {
|
|
291
|
+
this.size += n;
|
|
292
|
+
if (this.size > this.limit) {
|
|
293
|
+
throw overLimit;
|
|
294
|
+
}
|
|
295
|
+
return this;
|
|
296
|
+
}
|
|
297
|
+
};
|
|
298
|
+
function varintSize(value) {
|
|
299
|
+
let size = 1;
|
|
300
|
+
for (let rest = value; rest > 127; rest = Math.floor(rest / 128)) {
|
|
301
|
+
size += 1;
|
|
302
|
+
}
|
|
303
|
+
return size;
|
|
304
|
+
}
|
|
305
|
+
function utf8Length(value) {
|
|
306
|
+
let length3 = 0;
|
|
307
|
+
for (let i = 0; i < value.length; i++) {
|
|
308
|
+
const c = value.charCodeAt(i);
|
|
309
|
+
if (c < 128) {
|
|
310
|
+
length3 += 1;
|
|
311
|
+
} else if (c < 2048) {
|
|
312
|
+
length3 += 2;
|
|
313
|
+
} else if (c >= 55296 && c < 56320 && i + 1 < value.length) {
|
|
314
|
+
const next = value.charCodeAt(i + 1);
|
|
315
|
+
if (next >= 56320 && next < 57344) {
|
|
316
|
+
length3 += 4;
|
|
317
|
+
i += 1;
|
|
318
|
+
} else {
|
|
319
|
+
length3 += 3;
|
|
320
|
+
}
|
|
321
|
+
} else {
|
|
322
|
+
length3 += 3;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
return length3;
|
|
326
|
+
}
|
|
327
|
+
function sizeOf(type, m, limit) {
|
|
328
|
+
const w = new SizeWriter(limit ?? Infinity);
|
|
329
|
+
try {
|
|
330
|
+
type.encode(m, w);
|
|
331
|
+
} catch (e) {
|
|
332
|
+
if (e !== overLimit) {
|
|
333
|
+
throw e;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return w.size;
|
|
337
|
+
}
|
|
221
338
|
var BinaryReader = class {
|
|
222
339
|
/** Offset of the next byte to read. */
|
|
223
340
|
pos = 0;
|
|
@@ -3458,7 +3575,7 @@ function methodPrefix(method) {
|
|
|
3458
3575
|
prefixes.set(method, prefix);
|
|
3459
3576
|
return prefix;
|
|
3460
3577
|
}
|
|
3461
|
-
function
|
|
3578
|
+
function varintSize2(value) {
|
|
3462
3579
|
let size = 1;
|
|
3463
3580
|
for (let rest = value; rest > 127; rest >>>= 7) size++;
|
|
3464
3581
|
return size;
|
|
@@ -3467,7 +3584,7 @@ function encodeCall(method, request) {
|
|
|
3467
3584
|
const prefix = methodPrefix(method);
|
|
3468
3585
|
if (prefix === void 0) return Call.toBinary({ method, request });
|
|
3469
3586
|
const out = new Uint8Array(
|
|
3470
|
-
prefix.length + 1 +
|
|
3587
|
+
prefix.length + 1 + varintSize2(request.length) + request.length
|
|
3471
3588
|
);
|
|
3472
3589
|
out.set(prefix, 0);
|
|
3473
3590
|
let at3 = prefix.length;
|
|
@@ -18639,13 +18756,13 @@ var ProbeRun = class {
|
|
|
18639
18756
|
* tick runs check for the frame at now until the run ends. step names what
|
|
18640
18757
|
* the probe waits on, and describe adds the probe's state to a timeout.
|
|
18641
18758
|
*/
|
|
18642
|
-
tick(now4, step, check,
|
|
18759
|
+
tick(now4, step, check, describe) {
|
|
18643
18760
|
if (this.finished) {
|
|
18644
18761
|
return;
|
|
18645
18762
|
}
|
|
18646
18763
|
let result;
|
|
18647
18764
|
if (this.elapsed(now4) > this.timeout) {
|
|
18648
|
-
const state =
|
|
18765
|
+
const state = describe ? `: ${describe()}` : "";
|
|
18649
18766
|
result = `timed out waiting for ${step}${state}`;
|
|
18650
18767
|
} else {
|
|
18651
18768
|
result = check();
|
|
@@ -20085,6 +20202,58 @@ var Window_Enum = /* @__PURE__ */ createEnumType(
|
|
|
20085
20202
|
[3, "WINDOW_WEEK"]
|
|
20086
20203
|
]
|
|
20087
20204
|
);
|
|
20205
|
+
var ScoreConnection = /* @__PURE__ */ createMessageType(
|
|
20206
|
+
"modlock.wasm.scores.ScoreConnection",
|
|
20207
|
+
() => [
|
|
20208
|
+
[1, "slot", 5],
|
|
20209
|
+
[2, "steam_id", 4],
|
|
20210
|
+
[3, "generation", 13],
|
|
20211
|
+
[4, "proof", 9]
|
|
20212
|
+
],
|
|
20213
|
+
{
|
|
20214
|
+
decode: (r, end, m) => {
|
|
20215
|
+
while (r.pos < end) {
|
|
20216
|
+
const t = r.tag();
|
|
20217
|
+
if ((t & 7) === 4) return m;
|
|
20218
|
+
switch (t >>> 3) {
|
|
20219
|
+
case 1:
|
|
20220
|
+
m.slot = r.int32();
|
|
20221
|
+
break;
|
|
20222
|
+
case 2:
|
|
20223
|
+
m.steamId = r.uint64();
|
|
20224
|
+
break;
|
|
20225
|
+
case 3:
|
|
20226
|
+
m.generation = r.uint32();
|
|
20227
|
+
break;
|
|
20228
|
+
case 4:
|
|
20229
|
+
m.proof = r.string();
|
|
20230
|
+
break;
|
|
20231
|
+
default:
|
|
20232
|
+
r.skip(t);
|
|
20233
|
+
}
|
|
20234
|
+
}
|
|
20235
|
+
return m;
|
|
20236
|
+
},
|
|
20237
|
+
encode: (m, w) => {
|
|
20238
|
+
{
|
|
20239
|
+
const v = m.slot;
|
|
20240
|
+
if (v) w.uint32(8).int32(v);
|
|
20241
|
+
}
|
|
20242
|
+
{
|
|
20243
|
+
const v = m.steamId;
|
|
20244
|
+
if (v) w.uint32(16).uint64(v);
|
|
20245
|
+
}
|
|
20246
|
+
{
|
|
20247
|
+
const v = m.generation;
|
|
20248
|
+
if (v) w.uint32(24).uint32(v);
|
|
20249
|
+
}
|
|
20250
|
+
{
|
|
20251
|
+
const v = m.proof;
|
|
20252
|
+
if (v) w.uint32(34).string(v);
|
|
20253
|
+
}
|
|
20254
|
+
}
|
|
20255
|
+
}
|
|
20256
|
+
);
|
|
20088
20257
|
var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
20089
20258
|
"modlock.wasm.scores.ScoreReport",
|
|
20090
20259
|
() => [
|
|
@@ -20095,7 +20264,8 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20095
20264
|
[5, "partition", 9, 584],
|
|
20096
20265
|
[6, "key", 9],
|
|
20097
20266
|
[7, "earned_at_unix_millis", 3],
|
|
20098
|
-
[8, "evidence", 9]
|
|
20267
|
+
[8, "evidence", 9],
|
|
20268
|
+
[9, "connection", 11, 0, ScoreConnection.codec]
|
|
20099
20269
|
],
|
|
20100
20270
|
{
|
|
20101
20271
|
decode: (r, end, m) => {
|
|
@@ -20135,6 +20305,13 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20135
20305
|
case 8:
|
|
20136
20306
|
m.evidence = r.string();
|
|
20137
20307
|
break;
|
|
20308
|
+
case 9:
|
|
20309
|
+
m.connection = ScoreConnection.decode(
|
|
20310
|
+
r,
|
|
20311
|
+
r.delimited(),
|
|
20312
|
+
m.connection ?? {}
|
|
20313
|
+
);
|
|
20314
|
+
break;
|
|
20138
20315
|
default:
|
|
20139
20316
|
r.skip(t);
|
|
20140
20317
|
}
|
|
@@ -20180,6 +20357,10 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20180
20357
|
const v = m.evidence;
|
|
20181
20358
|
if (v) w.uint32(66).string(v);
|
|
20182
20359
|
}
|
|
20360
|
+
{
|
|
20361
|
+
const v = m.connection;
|
|
20362
|
+
if (v != null) ScoreConnection.writeField(w, 9, v);
|
|
20363
|
+
}
|
|
20183
20364
|
}
|
|
20184
20365
|
}
|
|
20185
20366
|
);
|
|
@@ -20271,7 +20452,8 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20271
20452
|
() => [
|
|
20272
20453
|
[1, "player", 5],
|
|
20273
20454
|
[2, "place", 13],
|
|
20274
|
-
[3, "value", 3]
|
|
20455
|
+
[3, "value", 3],
|
|
20456
|
+
[4, "connection", 11, 0, ScoreConnection.codec]
|
|
20275
20457
|
],
|
|
20276
20458
|
{
|
|
20277
20459
|
decode: (r, end, m) => {
|
|
@@ -20288,6 +20470,13 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20288
20470
|
case 3:
|
|
20289
20471
|
m.value = r.int64();
|
|
20290
20472
|
break;
|
|
20473
|
+
case 4:
|
|
20474
|
+
m.connection = ScoreConnection.decode(
|
|
20475
|
+
r,
|
|
20476
|
+
r.delimited(),
|
|
20477
|
+
m.connection ?? {}
|
|
20478
|
+
);
|
|
20479
|
+
break;
|
|
20291
20480
|
default:
|
|
20292
20481
|
r.skip(t);
|
|
20293
20482
|
}
|
|
@@ -20307,6 +20496,10 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20307
20496
|
const v = m.value;
|
|
20308
20497
|
if (v) w.uint32(24).int64(v);
|
|
20309
20498
|
}
|
|
20499
|
+
{
|
|
20500
|
+
const v = m.connection;
|
|
20501
|
+
if (v != null) ScoreConnection.writeField(w, 4, v);
|
|
20502
|
+
}
|
|
20310
20503
|
}
|
|
20311
20504
|
}
|
|
20312
20505
|
);
|
|
@@ -20318,7 +20511,8 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20318
20511
|
[3, "window", 14, 0, Window_Enum],
|
|
20319
20512
|
[4, "offset", 13],
|
|
20320
20513
|
[5, "limit", 13],
|
|
20321
|
-
[6, "player", 5, 4]
|
|
20514
|
+
[6, "player", 5, 4],
|
|
20515
|
+
[7, "connection", 11, 0, ScoreConnection.codec]
|
|
20322
20516
|
],
|
|
20323
20517
|
{
|
|
20324
20518
|
decode: (r, end, m) => {
|
|
@@ -20352,6 +20546,13 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20352
20546
|
case 6:
|
|
20353
20547
|
m.player = r.int32();
|
|
20354
20548
|
break;
|
|
20549
|
+
case 7:
|
|
20550
|
+
m.connection = ScoreConnection.decode(
|
|
20551
|
+
r,
|
|
20552
|
+
r.delimited(),
|
|
20553
|
+
m.connection ?? {}
|
|
20554
|
+
);
|
|
20555
|
+
break;
|
|
20355
20556
|
default:
|
|
20356
20557
|
r.skip(t);
|
|
20357
20558
|
}
|
|
@@ -20389,6 +20590,10 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20389
20590
|
const v = m.player;
|
|
20390
20591
|
if (v != null) w.uint32(48).int32(v);
|
|
20391
20592
|
}
|
|
20593
|
+
{
|
|
20594
|
+
const v = m.connection;
|
|
20595
|
+
if (v != null) ScoreConnection.writeField(w, 7, v);
|
|
20596
|
+
}
|
|
20392
20597
|
}
|
|
20393
20598
|
}
|
|
20394
20599
|
);
|
|
@@ -20396,8 +20601,7 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20396
20601
|
"modlock.wasm.scores.BoardPage",
|
|
20397
20602
|
() => [
|
|
20398
20603
|
[1, "rows", 11, 1, Standing.codec],
|
|
20399
|
-
[2, "player", 11, 0, Standing.codec]
|
|
20400
|
-
[3, "loading", 8]
|
|
20604
|
+
[2, "player", 11, 0, Standing.codec]
|
|
20401
20605
|
],
|
|
20402
20606
|
{
|
|
20403
20607
|
decode: (r, end, m) => {
|
|
@@ -20412,9 +20616,6 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20412
20616
|
case 2:
|
|
20413
20617
|
m.player = Standing.decode(r, r.delimited(), m.player ?? {});
|
|
20414
20618
|
break;
|
|
20415
|
-
case 3:
|
|
20416
|
-
m.loading = r.bool();
|
|
20417
|
-
break;
|
|
20418
20619
|
default:
|
|
20419
20620
|
r.skip(t);
|
|
20420
20621
|
}
|
|
@@ -20430,10 +20631,6 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20430
20631
|
const v = m.player;
|
|
20431
20632
|
if (v != null) Standing.writeField(w, 2, v);
|
|
20432
20633
|
}
|
|
20433
|
-
{
|
|
20434
|
-
const v = m.loading;
|
|
20435
|
-
if (v) w.uint32(24).bool(v);
|
|
20436
|
-
}
|
|
20437
20634
|
}
|
|
20438
20635
|
}
|
|
20439
20636
|
);
|
|
@@ -20508,70 +20705,147 @@ var Standing = /* @__PURE__ */ createMessageType(
|
|
|
20508
20705
|
|
|
20509
20706
|
// js/src/scores.ts
|
|
20510
20707
|
var service2 = "scores";
|
|
20511
|
-
var
|
|
20708
|
+
var requestLimit = 16 * 1024;
|
|
20709
|
+
var tooLarge = "The score call must fit in 16 KiB";
|
|
20710
|
+
var windows = {
|
|
20512
20711
|
allTime: 1 /* ALL_TIME */,
|
|
20513
20712
|
day: 2 /* DAY */,
|
|
20514
20713
|
week: 3 /* WEEK */
|
|
20515
20714
|
};
|
|
20516
|
-
function
|
|
20517
|
-
const
|
|
20715
|
+
function bindScorePlayer(player) {
|
|
20716
|
+
const reply2 = callService(
|
|
20717
|
+
service2,
|
|
20718
|
+
"Bind",
|
|
20719
|
+
ScoreConnection.toBinary(identity(player))
|
|
20720
|
+
);
|
|
20721
|
+
const bound = reply2 === void 0 ? void 0 : ScoreConnection.fromBinary(reply2);
|
|
20722
|
+
if (!bound?.proof) return void 0;
|
|
20723
|
+
return {
|
|
20724
|
+
slot: bound.slot ?? 0,
|
|
20725
|
+
steamId: bound.steamId ?? 0n,
|
|
20726
|
+
generation: bound.generation ?? 0,
|
|
20727
|
+
proof: bound.proof
|
|
20728
|
+
};
|
|
20729
|
+
}
|
|
20730
|
+
function reportScore(player, board, value, done, options = {}) {
|
|
20731
|
+
if (player.proof.length > 64 || !fitsText(board, options)) {
|
|
20732
|
+
after(0, () => done(tooLarge));
|
|
20733
|
+
return;
|
|
20734
|
+
}
|
|
20735
|
+
const payload = encodeRequest(ScoreReport, {
|
|
20736
|
+
...writeFields(options),
|
|
20518
20737
|
board,
|
|
20519
20738
|
player: player.slot,
|
|
20520
|
-
value:
|
|
20521
|
-
tiebreak:
|
|
20522
|
-
|
|
20523
|
-
key: options.key,
|
|
20524
|
-
earnedAtUnixMillis: int64(options.earnedAt ?? 0),
|
|
20525
|
-
evidence: options.evidence
|
|
20739
|
+
value: integer(value),
|
|
20740
|
+
tiebreak: integer(options.tiebreak ?? 0),
|
|
20741
|
+
connection: player
|
|
20526
20742
|
});
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
20530
|
-
|
|
20531
|
-
);
|
|
20743
|
+
if (!payload) {
|
|
20744
|
+
after(0, () => done(tooLarge));
|
|
20745
|
+
return;
|
|
20746
|
+
}
|
|
20747
|
+
submit("Report", payload, done);
|
|
20532
20748
|
}
|
|
20533
|
-
function reportMatch(board, places, options = {}) {
|
|
20534
|
-
|
|
20749
|
+
function reportMatch(board, places, done, options = {}) {
|
|
20750
|
+
if (places.length === 0 || places.length > 64) {
|
|
20751
|
+
after(0, () => done("The match needs one to 64 places"));
|
|
20752
|
+
return;
|
|
20753
|
+
}
|
|
20754
|
+
if (places.some(({ player }) => player.proof.length > 64) || !fitsText(board, options)) {
|
|
20755
|
+
after(0, () => done(tooLarge));
|
|
20756
|
+
return;
|
|
20757
|
+
}
|
|
20758
|
+
const payload = encodeRequest(MatchReport, {
|
|
20759
|
+
...writeFields(options),
|
|
20535
20760
|
board,
|
|
20536
|
-
places: places.map((
|
|
20537
|
-
player:
|
|
20538
|
-
place:
|
|
20539
|
-
value:
|
|
20540
|
-
|
|
20541
|
-
|
|
20542
|
-
key: options.key,
|
|
20543
|
-
earnedAtUnixMillis: int64(options.earnedAt ?? 0),
|
|
20544
|
-
evidence: options.evidence
|
|
20761
|
+
places: places.map(({ player, place: place2, value }) => ({
|
|
20762
|
+
player: player.slot,
|
|
20763
|
+
place: place2,
|
|
20764
|
+
value: integer(value ?? 0),
|
|
20765
|
+
connection: player
|
|
20766
|
+
}))
|
|
20545
20767
|
});
|
|
20546
|
-
|
|
20547
|
-
|
|
20548
|
-
|
|
20549
|
-
|
|
20550
|
-
|
|
20551
|
-
);
|
|
20768
|
+
if (!payload) {
|
|
20769
|
+
after(0, () => done(tooLarge));
|
|
20770
|
+
return;
|
|
20771
|
+
}
|
|
20772
|
+
submit("Match", payload, done);
|
|
20552
20773
|
}
|
|
20553
|
-
function readBoard(board, read
|
|
20554
|
-
|
|
20774
|
+
function readBoard(board, read, done) {
|
|
20775
|
+
if (!fitsText(board, read)) {
|
|
20776
|
+
after(0, () => done(void 0, tooLarge));
|
|
20777
|
+
return;
|
|
20778
|
+
}
|
|
20779
|
+
const payload = encodeRequest(BoardQuery, {
|
|
20555
20780
|
board,
|
|
20556
20781
|
partition: read.partition,
|
|
20557
|
-
window: read.window === void 0 ? void 0 :
|
|
20782
|
+
window: read.window === void 0 ? void 0 : windows[read.window],
|
|
20558
20783
|
offset: read.offset,
|
|
20559
20784
|
limit: read.limit,
|
|
20560
|
-
player: read.player?.slot
|
|
20785
|
+
player: read.player?.player.slot,
|
|
20786
|
+
connection: read.player && identity(read.player)
|
|
20561
20787
|
});
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20788
|
+
if (!payload) {
|
|
20789
|
+
after(0, () => done(void 0, tooLarge));
|
|
20790
|
+
return;
|
|
20791
|
+
}
|
|
20792
|
+
callServiceLater(service2, "Read", payload, (reply2, error) => {
|
|
20793
|
+
if (reply2 === void 0) {
|
|
20794
|
+
done(void 0, error);
|
|
20795
|
+
return;
|
|
20796
|
+
}
|
|
20797
|
+
const page = BoardPage.fromBinary(reply2);
|
|
20798
|
+
done({
|
|
20799
|
+
rows: (page.rows ?? []).map(row),
|
|
20800
|
+
player: page.player && row(page.player)
|
|
20801
|
+
});
|
|
20802
|
+
});
|
|
20803
|
+
}
|
|
20804
|
+
function fitsText(board, options) {
|
|
20805
|
+
let units = board.length + (options.key?.length ?? 0) + (options.evidence?.length ?? 0);
|
|
20806
|
+
if (units > requestLimit) {
|
|
20807
|
+
return false;
|
|
20808
|
+
}
|
|
20809
|
+
for (const name in options.partition) {
|
|
20810
|
+
units += 1 + name.length + (options.partition[name]?.length ?? 0);
|
|
20811
|
+
if (units > requestLimit) {
|
|
20812
|
+
return false;
|
|
20813
|
+
}
|
|
20814
|
+
}
|
|
20815
|
+
return true;
|
|
20816
|
+
}
|
|
20817
|
+
function encodeRequest(type, request) {
|
|
20818
|
+
return sizeOf(type, request, requestLimit) <= requestLimit ? type.toBinary(request) : void 0;
|
|
20819
|
+
}
|
|
20820
|
+
function writeFields(options) {
|
|
20565
20821
|
return {
|
|
20566
|
-
|
|
20567
|
-
|
|
20568
|
-
|
|
20822
|
+
key: options.key,
|
|
20823
|
+
earnedAtUnixMillis: integer(options.earnedAt ?? 0),
|
|
20824
|
+
partition: options.partition,
|
|
20825
|
+
evidence: options.evidence
|
|
20569
20826
|
};
|
|
20570
20827
|
}
|
|
20571
|
-
function
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20828
|
+
function submit(method, payload, done) {
|
|
20829
|
+
callServiceLater(service2, method, payload, (reply2, error) => {
|
|
20830
|
+
if (reply2 !== void 0) {
|
|
20831
|
+
done();
|
|
20832
|
+
return;
|
|
20833
|
+
}
|
|
20834
|
+
done(
|
|
20835
|
+
error ?? "The host did not confirm the score",
|
|
20836
|
+
(next) => submit(method, payload, next)
|
|
20837
|
+
);
|
|
20838
|
+
});
|
|
20839
|
+
}
|
|
20840
|
+
function identity(connection2) {
|
|
20841
|
+
return {
|
|
20842
|
+
slot: connection2.player.slot,
|
|
20843
|
+
steamId: connection2.steamId,
|
|
20844
|
+
generation: connection2.generation
|
|
20845
|
+
};
|
|
20846
|
+
}
|
|
20847
|
+
function integer(value) {
|
|
20848
|
+
return BigInt(Math.round(value));
|
|
20575
20849
|
}
|
|
20576
20850
|
function row(standing) {
|
|
20577
20851
|
return {
|
|
@@ -20583,14 +20857,6 @@ function row(standing) {
|
|
|
20583
20857
|
count: standing.count ?? 0
|
|
20584
20858
|
};
|
|
20585
20859
|
}
|
|
20586
|
-
function int64(value) {
|
|
20587
|
-
return BigInt(Math.round(value));
|
|
20588
|
-
}
|
|
20589
|
-
function describe(partition) {
|
|
20590
|
-
const names = Object.keys(partition ?? {}).sort();
|
|
20591
|
-
if (!names.length) return "";
|
|
20592
|
-
return `[${names.map((name) => `${name}=${partition[name]}`).join(" ")}]`;
|
|
20593
|
-
}
|
|
20594
20860
|
|
|
20595
20861
|
// js/src/index.ts
|
|
20596
20862
|
function log2(...parts) {
|
|
@@ -20999,6 +21265,7 @@ export {
|
|
|
20999
21265
|
adjustSound,
|
|
21000
21266
|
after,
|
|
21001
21267
|
afterMatch,
|
|
21268
|
+
bindScorePlayer,
|
|
21002
21269
|
blockInput,
|
|
21003
21270
|
bystanderStates,
|
|
21004
21271
|
callService,
|
package/package.json
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"name": "@modlock/modlock",
|
|
9
9
|
"optionalDependencies": {
|
|
10
|
-
"@modlock/darwin-arm64": "0.1.
|
|
11
|
-
"@modlock/darwin-x64": "0.1.
|
|
12
|
-
"@modlock/linux-arm64": "0.1.
|
|
13
|
-
"@modlock/linux-x64": "0.1.
|
|
14
|
-
"@modlock/win32-x64": "0.1.
|
|
10
|
+
"@modlock/darwin-arm64": "0.1.88",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.88",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.88",
|
|
13
|
+
"@modlock/linux-x64": "0.1.88",
|
|
14
|
+
"@modlock/win32-x64": "0.1.88"
|
|
15
15
|
},
|
|
16
16
|
"repository": {
|
|
17
17
|
"type": "git",
|
|
@@ -20,5 +20,5 @@
|
|
|
20
20
|
"sideEffects": false,
|
|
21
21
|
"type": "module",
|
|
22
22
|
"types": "index.d.ts",
|
|
23
|
-
"version": "0.1.
|
|
23
|
+
"version": "0.1.88"
|
|
24
24
|
}
|
package/scores.d.ts
CHANGED
|
@@ -1,38 +1,26 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
/** BoardWindow is a
|
|
1
|
+
import { type Connection } from './host.gen.js';
|
|
2
|
+
/** BoardWindow is a range of standings in UTC. A week starts Monday. */
|
|
3
3
|
export type BoardWindow = 'allTime' | 'day' | 'week';
|
|
4
|
-
/** ScoreOptions
|
|
4
|
+
/** ScoreOptions describes where a score ranks and the run it came from. */
|
|
5
5
|
export interface ScoreOptions {
|
|
6
6
|
/** partition names a value for each of the board's partitions. */
|
|
7
7
|
partition?: Record<string, string>;
|
|
8
8
|
/** tiebreak ranks equal values, lower first, such as fewer deaths. */
|
|
9
9
|
tiebreak?: number;
|
|
10
|
-
/** key identifies the run
|
|
10
|
+
/** key identifies the round or run in this game across retries and reloads. */
|
|
11
11
|
key?: string;
|
|
12
|
-
/** earnedAt is when the score was earned
|
|
12
|
+
/** earnedAt is when the score was earned in Unix milliseconds, or the host's receipt time. */
|
|
13
13
|
earnedAt?: number;
|
|
14
14
|
/** evidence names what shows the run, such as a recording. */
|
|
15
15
|
evidence?: string;
|
|
16
16
|
}
|
|
17
|
-
/**
|
|
18
|
-
export interface MatchPlace {
|
|
19
|
-
player: Player;
|
|
20
|
-
place: number;
|
|
21
|
-
/** value is the player's score in the match, for a board that keeps one. */
|
|
22
|
-
value?: number;
|
|
23
|
-
}
|
|
24
|
-
/** BoardRead selects a page of a board. */
|
|
17
|
+
/** BoardRead selects a page of a board. Omit window to read all time. */
|
|
25
18
|
export interface BoardRead {
|
|
26
|
-
/** partition names a value for each of the board's partitions. */
|
|
27
19
|
partition?: Record<string, string>;
|
|
28
|
-
/** window is one of the board's windows; all time by default. */
|
|
29
20
|
window?: BoardWindow;
|
|
30
|
-
/** offset skips that many rows from the top. */
|
|
31
21
|
offset?: number;
|
|
32
|
-
/** limit bounds the rows; ten by default. */
|
|
33
22
|
limit?: number;
|
|
34
|
-
|
|
35
|
-
player?: Player;
|
|
23
|
+
player?: Connection;
|
|
36
24
|
}
|
|
37
25
|
/** BoardRow is one player's place on a board. */
|
|
38
26
|
export interface BoardRow {
|
|
@@ -43,30 +31,38 @@ export interface BoardRow {
|
|
|
43
31
|
tiebreak: number;
|
|
44
32
|
count: number;
|
|
45
33
|
}
|
|
46
|
-
/** BoardPage is a page of
|
|
34
|
+
/** BoardPage is a page of standings and the requested player's own row. */
|
|
47
35
|
export interface BoardPage {
|
|
48
|
-
/** rows are the standings in rank order. */
|
|
49
36
|
rows: BoardRow[];
|
|
50
|
-
/** player is the asked player's row, when they hold a standing. */
|
|
51
37
|
player?: BoardRow;
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
}
|
|
39
|
+
/** ScoreDone hears backend acceptance, or the error and a retry of the same write. */
|
|
40
|
+
export type ScoreDone = (error?: string, retry?: (done: ScoreDone) => void) => void;
|
|
41
|
+
/** ScorePlayer is the connection a mode enrolled with bindScorePlayer. */
|
|
42
|
+
export interface ScorePlayer {
|
|
43
|
+
readonly slot: number;
|
|
44
|
+
readonly steamId: bigint;
|
|
45
|
+
readonly generation: number;
|
|
46
|
+
readonly proof: string;
|
|
47
|
+
}
|
|
48
|
+
/** MatchPlace is one enrolled participant's place and optional value. */
|
|
49
|
+
export interface MatchPlace {
|
|
50
|
+
player: ScorePlayer;
|
|
51
|
+
place: number;
|
|
52
|
+
value?: number;
|
|
54
53
|
}
|
|
55
54
|
/**
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
* takes none, and the mod logs the score instead.
|
|
59
|
-
*/
|
|
60
|
-
export declare function reportScore(player: Player, board: string, value: number, options?: ScoreOptions): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* reportMatch reports one match's places to a rating or match board the
|
|
63
|
-
* manifest declares. Players who tie, such as one team's members, share a
|
|
64
|
-
* place. It reports whether the host took it, as reportScore does.
|
|
55
|
+
* bindScorePlayer captures the connection while the mode serves it. Keep
|
|
56
|
+
* the result with the participant until the score or match is reported.
|
|
65
57
|
*/
|
|
66
|
-
export declare function
|
|
58
|
+
export declare function bindScorePlayer(player: Connection): ScorePlayer | undefined;
|
|
67
59
|
/**
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
60
|
+
* reportScore submits an enrolled player's result and answers on a later frame.
|
|
61
|
+
* Supply a stable key for each round or run if the game records more than one
|
|
62
|
+
* result per player and board.
|
|
71
63
|
*/
|
|
72
|
-
export declare function
|
|
64
|
+
export declare function reportScore(player: ScorePlayer, board: string, value: number, done: ScoreDone, options?: ScoreOptions): void;
|
|
65
|
+
/** reportMatch submits the enrolled cohort as one result, with shared places for ties. */
|
|
66
|
+
export declare function reportMatch(board: string, places: readonly MatchPlace[], done: ScoreDone, options?: Omit<ScoreOptions, 'tiebreak'>): void;
|
|
67
|
+
/** readBoard asks for a fresh page and delivers it or an error on a later frame. */
|
|
68
|
+
export declare function readBoard(board: string, read: BoardRead, done: (page: BoardPage | undefined, error?: string) => void): void;
|