@modlock/modlock 0.1.87 → 0.1.89
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 +415 -98
- package/package.json +6 -6
- package/scores.d.ts +34 -38
- package/ui.d.ts +6 -1
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;
|
|
@@ -15989,23 +16106,22 @@ var Entry = class {
|
|
|
15989
16106
|
constructor(delay, run) {
|
|
15990
16107
|
this.delay = delay;
|
|
15991
16108
|
this.run = run;
|
|
15992
|
-
this.at = now === void 0 ? void 0 : now + delay;
|
|
15993
16109
|
}
|
|
15994
16110
|
delay;
|
|
15995
16111
|
run;
|
|
15996
16112
|
finished = false;
|
|
15997
|
-
/** at is the game time the entry next runs
|
|
15998
|
-
at;
|
|
15999
|
-
/**
|
|
16000
|
-
|
|
16001
|
-
this.at ??= seconds + this.delay;
|
|
16002
|
-
}
|
|
16113
|
+
/** at is the game time the entry next runs. */
|
|
16114
|
+
at = 0;
|
|
16115
|
+
/** order breaks ties in at, so timers due together run in schedule order. */
|
|
16116
|
+
order = 0;
|
|
16003
16117
|
cancel() {
|
|
16004
16118
|
this.finished = true;
|
|
16005
16119
|
}
|
|
16006
16120
|
};
|
|
16007
16121
|
var now;
|
|
16008
|
-
var
|
|
16122
|
+
var waiting2 = [];
|
|
16123
|
+
var heap = [];
|
|
16124
|
+
var scheduled = 0;
|
|
16009
16125
|
function after(seconds, fn) {
|
|
16010
16126
|
return schedule(seconds, () => {
|
|
16011
16127
|
fn();
|
|
@@ -16024,23 +16140,34 @@ function sequence(fn) {
|
|
|
16024
16140
|
}
|
|
16025
16141
|
function schedule(delay, run) {
|
|
16026
16142
|
const entry2 = new Entry(delay, run);
|
|
16027
|
-
|
|
16143
|
+
if (now === void 0) {
|
|
16144
|
+
waiting2.push(entry2);
|
|
16145
|
+
} else {
|
|
16146
|
+
push(entry2, now + delay);
|
|
16147
|
+
}
|
|
16028
16148
|
return entry2;
|
|
16029
16149
|
}
|
|
16030
16150
|
function advance(seconds) {
|
|
16031
16151
|
if (now !== void 0 && seconds < now) {
|
|
16032
16152
|
const shift = seconds - now;
|
|
16033
|
-
for (const entry2 of
|
|
16034
|
-
|
|
16035
|
-
entry2.at += shift;
|
|
16036
|
-
}
|
|
16153
|
+
for (const entry2 of heap) {
|
|
16154
|
+
entry2.at += shift;
|
|
16037
16155
|
}
|
|
16038
16156
|
}
|
|
16039
16157
|
now = seconds;
|
|
16040
|
-
|
|
16041
|
-
entry2
|
|
16158
|
+
if (waiting2.length !== 0) {
|
|
16159
|
+
for (const entry2 of waiting2) {
|
|
16160
|
+
push(entry2, seconds + entry2.delay);
|
|
16161
|
+
}
|
|
16162
|
+
waiting2 = [];
|
|
16163
|
+
}
|
|
16164
|
+
const due = [];
|
|
16165
|
+
for (let top = heap[0]; top !== void 0 && top.at <= seconds; top = heap[0]) {
|
|
16166
|
+
pop();
|
|
16167
|
+
if (!top.finished) {
|
|
16168
|
+
due.push(top);
|
|
16169
|
+
}
|
|
16042
16170
|
}
|
|
16043
|
-
const due = entries.filter((entry2) => !entry2.finished && entry2.at <= seconds).sort((a, b) => a.at - b.at);
|
|
16044
16171
|
for (const entry2 of due) {
|
|
16045
16172
|
if (entry2.finished) {
|
|
16046
16173
|
continue;
|
|
@@ -16049,20 +16176,60 @@ function advance(seconds) {
|
|
|
16049
16176
|
const wait = entry2.run();
|
|
16050
16177
|
if (wait === void 0) {
|
|
16051
16178
|
entry2.finished = true;
|
|
16052
|
-
} else {
|
|
16179
|
+
} else if (!entry2.finished) {
|
|
16053
16180
|
const next = entry2.at + wait;
|
|
16054
|
-
entry2
|
|
16181
|
+
push(entry2, next > seconds ? next : seconds + wait);
|
|
16055
16182
|
}
|
|
16056
16183
|
} catch (error) {
|
|
16057
16184
|
entry2.finished = true;
|
|
16058
16185
|
log(`timer failed: ${String(error)}`);
|
|
16059
16186
|
}
|
|
16060
16187
|
}
|
|
16061
|
-
|
|
16188
|
+
}
|
|
16189
|
+
function push(entry2, at3) {
|
|
16190
|
+
entry2.at = at3;
|
|
16191
|
+
entry2.order = scheduled++;
|
|
16192
|
+
heap.push(entry2);
|
|
16193
|
+
let index = heap.length - 1;
|
|
16194
|
+
for (; ; ) {
|
|
16195
|
+
const parent = index - 1 >> 1;
|
|
16196
|
+
const above = heap[parent];
|
|
16197
|
+
if (index === 0 || above === void 0 || !before(entry2, above)) {
|
|
16198
|
+
break;
|
|
16199
|
+
}
|
|
16200
|
+
heap[index] = above;
|
|
16201
|
+
index = parent;
|
|
16202
|
+
}
|
|
16203
|
+
heap[index] = entry2;
|
|
16204
|
+
}
|
|
16205
|
+
function pop() {
|
|
16206
|
+
const last = heap.pop();
|
|
16207
|
+
if (last === void 0 || heap.length === 0) {
|
|
16208
|
+
return;
|
|
16209
|
+
}
|
|
16210
|
+
let index = 0;
|
|
16211
|
+
for (; ; ) {
|
|
16212
|
+
let child = 2 * index + 1;
|
|
16213
|
+
let below = heap[child];
|
|
16214
|
+
const right = heap[child + 1];
|
|
16215
|
+
if (below !== void 0 && right !== void 0 && before(right, below)) {
|
|
16216
|
+
child++;
|
|
16217
|
+
below = right;
|
|
16218
|
+
}
|
|
16219
|
+
if (below === void 0 || !before(below, last)) {
|
|
16220
|
+
break;
|
|
16221
|
+
}
|
|
16222
|
+
heap[index] = below;
|
|
16223
|
+
index = child;
|
|
16224
|
+
}
|
|
16225
|
+
heap[index] = last;
|
|
16226
|
+
}
|
|
16227
|
+
function before(a, b) {
|
|
16228
|
+
return a.at < b.at || a.at === b.at && a.order < b.order;
|
|
16062
16229
|
}
|
|
16063
16230
|
|
|
16064
16231
|
// js/src/service-later.ts
|
|
16065
|
-
var
|
|
16232
|
+
var waiting3 = /* @__PURE__ */ new Map();
|
|
16066
16233
|
function callServiceLater(service3, method, payload, done, timeoutMilliseconds = 0) {
|
|
16067
16234
|
const call2 = startServiceCall(service3, method, payload, timeoutMilliseconds);
|
|
16068
16235
|
if (call2 === void 0) {
|
|
@@ -16076,14 +16243,14 @@ function callServiceLater(service3, method, payload, done, timeoutMilliseconds =
|
|
|
16076
16243
|
);
|
|
16077
16244
|
return;
|
|
16078
16245
|
}
|
|
16079
|
-
|
|
16246
|
+
waiting3.set(call2, done);
|
|
16080
16247
|
}
|
|
16081
16248
|
function endServiceCall(event) {
|
|
16082
|
-
const done =
|
|
16249
|
+
const done = waiting3.get(event.call);
|
|
16083
16250
|
if (!done) {
|
|
16084
16251
|
return;
|
|
16085
16252
|
}
|
|
16086
|
-
|
|
16253
|
+
waiting3.delete(event.call);
|
|
16087
16254
|
if (event.failure && event.failure !== "none") {
|
|
16088
16255
|
done(void 0, event.error, event.failure);
|
|
16089
16256
|
return;
|
|
@@ -16279,7 +16446,7 @@ function change(player, node, value) {
|
|
|
16279
16446
|
function tick(seconds) {
|
|
16280
16447
|
now2 = seconds;
|
|
16281
16448
|
for (const current of views.values()) {
|
|
16282
|
-
if (current.notices.
|
|
16449
|
+
if (!current.notices.some((notice) => notice.until <= now2)) {
|
|
16283
16450
|
continue;
|
|
16284
16451
|
}
|
|
16285
16452
|
current.notices = current.notices.filter((notice) => notice.until > now2);
|
|
@@ -17072,11 +17239,11 @@ function keyframes(keys, options = {}) {
|
|
|
17072
17239
|
spans.push(...line(from.value, to.value, duration, shape));
|
|
17073
17240
|
return;
|
|
17074
17241
|
}
|
|
17075
|
-
const
|
|
17242
|
+
const before2 = keys[i - 2]?.value ?? from.value;
|
|
17076
17243
|
const after2 = keys[i + 1]?.value ?? to.value;
|
|
17077
17244
|
spans.push({
|
|
17078
17245
|
duration,
|
|
17079
|
-
at: (u) => spline(
|
|
17246
|
+
at: (u) => spline(before2, from.value, to.value, after2, shape.at(u))
|
|
17080
17247
|
});
|
|
17081
17248
|
});
|
|
17082
17249
|
return spans;
|
|
@@ -18639,13 +18806,13 @@ var ProbeRun = class {
|
|
|
18639
18806
|
* tick runs check for the frame at now until the run ends. step names what
|
|
18640
18807
|
* the probe waits on, and describe adds the probe's state to a timeout.
|
|
18641
18808
|
*/
|
|
18642
|
-
tick(now4, step, check,
|
|
18809
|
+
tick(now4, step, check, describe) {
|
|
18643
18810
|
if (this.finished) {
|
|
18644
18811
|
return;
|
|
18645
18812
|
}
|
|
18646
18813
|
let result;
|
|
18647
18814
|
if (this.elapsed(now4) > this.timeout) {
|
|
18648
|
-
const state =
|
|
18815
|
+
const state = describe ? `: ${describe()}` : "";
|
|
18649
18816
|
result = `timed out waiting for ${step}${state}`;
|
|
18650
18817
|
} else {
|
|
18651
18818
|
result = check();
|
|
@@ -19871,13 +20038,13 @@ var UpdateReply = /* @__PURE__ */ createMessageType(
|
|
|
19871
20038
|
|
|
19872
20039
|
// js/src/persist.ts
|
|
19873
20040
|
var service = "persist";
|
|
19874
|
-
var
|
|
20041
|
+
var entries = /* @__PURE__ */ new WeakMap();
|
|
19875
20042
|
var requests = 0;
|
|
19876
20043
|
function entry(player, type) {
|
|
19877
|
-
let records =
|
|
20044
|
+
let records = entries.get(player);
|
|
19878
20045
|
if (!records) {
|
|
19879
20046
|
records = /* @__PURE__ */ new Map();
|
|
19880
|
-
|
|
20047
|
+
entries.set(player, records);
|
|
19881
20048
|
}
|
|
19882
20049
|
let known2 = records.get(type);
|
|
19883
20050
|
if (!known2) {
|
|
@@ -20085,6 +20252,58 @@ var Window_Enum = /* @__PURE__ */ createEnumType(
|
|
|
20085
20252
|
[3, "WINDOW_WEEK"]
|
|
20086
20253
|
]
|
|
20087
20254
|
);
|
|
20255
|
+
var ScoreConnection = /* @__PURE__ */ createMessageType(
|
|
20256
|
+
"modlock.wasm.scores.ScoreConnection",
|
|
20257
|
+
() => [
|
|
20258
|
+
[1, "slot", 5],
|
|
20259
|
+
[2, "steam_id", 4],
|
|
20260
|
+
[3, "generation", 13],
|
|
20261
|
+
[4, "proof", 9]
|
|
20262
|
+
],
|
|
20263
|
+
{
|
|
20264
|
+
decode: (r, end, m) => {
|
|
20265
|
+
while (r.pos < end) {
|
|
20266
|
+
const t = r.tag();
|
|
20267
|
+
if ((t & 7) === 4) return m;
|
|
20268
|
+
switch (t >>> 3) {
|
|
20269
|
+
case 1:
|
|
20270
|
+
m.slot = r.int32();
|
|
20271
|
+
break;
|
|
20272
|
+
case 2:
|
|
20273
|
+
m.steamId = r.uint64();
|
|
20274
|
+
break;
|
|
20275
|
+
case 3:
|
|
20276
|
+
m.generation = r.uint32();
|
|
20277
|
+
break;
|
|
20278
|
+
case 4:
|
|
20279
|
+
m.proof = r.string();
|
|
20280
|
+
break;
|
|
20281
|
+
default:
|
|
20282
|
+
r.skip(t);
|
|
20283
|
+
}
|
|
20284
|
+
}
|
|
20285
|
+
return m;
|
|
20286
|
+
},
|
|
20287
|
+
encode: (m, w) => {
|
|
20288
|
+
{
|
|
20289
|
+
const v = m.slot;
|
|
20290
|
+
if (v) w.uint32(8).int32(v);
|
|
20291
|
+
}
|
|
20292
|
+
{
|
|
20293
|
+
const v = m.steamId;
|
|
20294
|
+
if (v) w.uint32(16).uint64(v);
|
|
20295
|
+
}
|
|
20296
|
+
{
|
|
20297
|
+
const v = m.generation;
|
|
20298
|
+
if (v) w.uint32(24).uint32(v);
|
|
20299
|
+
}
|
|
20300
|
+
{
|
|
20301
|
+
const v = m.proof;
|
|
20302
|
+
if (v) w.uint32(34).string(v);
|
|
20303
|
+
}
|
|
20304
|
+
}
|
|
20305
|
+
}
|
|
20306
|
+
);
|
|
20088
20307
|
var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
20089
20308
|
"modlock.wasm.scores.ScoreReport",
|
|
20090
20309
|
() => [
|
|
@@ -20095,7 +20314,8 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20095
20314
|
[5, "partition", 9, 584],
|
|
20096
20315
|
[6, "key", 9],
|
|
20097
20316
|
[7, "earned_at_unix_millis", 3],
|
|
20098
|
-
[8, "evidence", 9]
|
|
20317
|
+
[8, "evidence", 9],
|
|
20318
|
+
[9, "connection", 11, 0, ScoreConnection.codec]
|
|
20099
20319
|
],
|
|
20100
20320
|
{
|
|
20101
20321
|
decode: (r, end, m) => {
|
|
@@ -20135,6 +20355,13 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20135
20355
|
case 8:
|
|
20136
20356
|
m.evidence = r.string();
|
|
20137
20357
|
break;
|
|
20358
|
+
case 9:
|
|
20359
|
+
m.connection = ScoreConnection.decode(
|
|
20360
|
+
r,
|
|
20361
|
+
r.delimited(),
|
|
20362
|
+
m.connection ?? {}
|
|
20363
|
+
);
|
|
20364
|
+
break;
|
|
20138
20365
|
default:
|
|
20139
20366
|
r.skip(t);
|
|
20140
20367
|
}
|
|
@@ -20180,6 +20407,10 @@ var ScoreReport = /* @__PURE__ */ createMessageType(
|
|
|
20180
20407
|
const v = m.evidence;
|
|
20181
20408
|
if (v) w.uint32(66).string(v);
|
|
20182
20409
|
}
|
|
20410
|
+
{
|
|
20411
|
+
const v = m.connection;
|
|
20412
|
+
if (v != null) ScoreConnection.writeField(w, 9, v);
|
|
20413
|
+
}
|
|
20183
20414
|
}
|
|
20184
20415
|
}
|
|
20185
20416
|
);
|
|
@@ -20271,7 +20502,8 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20271
20502
|
() => [
|
|
20272
20503
|
[1, "player", 5],
|
|
20273
20504
|
[2, "place", 13],
|
|
20274
|
-
[3, "value", 3]
|
|
20505
|
+
[3, "value", 3],
|
|
20506
|
+
[4, "connection", 11, 0, ScoreConnection.codec]
|
|
20275
20507
|
],
|
|
20276
20508
|
{
|
|
20277
20509
|
decode: (r, end, m) => {
|
|
@@ -20288,6 +20520,13 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20288
20520
|
case 3:
|
|
20289
20521
|
m.value = r.int64();
|
|
20290
20522
|
break;
|
|
20523
|
+
case 4:
|
|
20524
|
+
m.connection = ScoreConnection.decode(
|
|
20525
|
+
r,
|
|
20526
|
+
r.delimited(),
|
|
20527
|
+
m.connection ?? {}
|
|
20528
|
+
);
|
|
20529
|
+
break;
|
|
20291
20530
|
default:
|
|
20292
20531
|
r.skip(t);
|
|
20293
20532
|
}
|
|
@@ -20307,6 +20546,10 @@ var Place = /* @__PURE__ */ createMessageType(
|
|
|
20307
20546
|
const v = m.value;
|
|
20308
20547
|
if (v) w.uint32(24).int64(v);
|
|
20309
20548
|
}
|
|
20549
|
+
{
|
|
20550
|
+
const v = m.connection;
|
|
20551
|
+
if (v != null) ScoreConnection.writeField(w, 4, v);
|
|
20552
|
+
}
|
|
20310
20553
|
}
|
|
20311
20554
|
}
|
|
20312
20555
|
);
|
|
@@ -20318,7 +20561,8 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20318
20561
|
[3, "window", 14, 0, Window_Enum],
|
|
20319
20562
|
[4, "offset", 13],
|
|
20320
20563
|
[5, "limit", 13],
|
|
20321
|
-
[6, "player", 5, 4]
|
|
20564
|
+
[6, "player", 5, 4],
|
|
20565
|
+
[7, "connection", 11, 0, ScoreConnection.codec]
|
|
20322
20566
|
],
|
|
20323
20567
|
{
|
|
20324
20568
|
decode: (r, end, m) => {
|
|
@@ -20352,6 +20596,13 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20352
20596
|
case 6:
|
|
20353
20597
|
m.player = r.int32();
|
|
20354
20598
|
break;
|
|
20599
|
+
case 7:
|
|
20600
|
+
m.connection = ScoreConnection.decode(
|
|
20601
|
+
r,
|
|
20602
|
+
r.delimited(),
|
|
20603
|
+
m.connection ?? {}
|
|
20604
|
+
);
|
|
20605
|
+
break;
|
|
20355
20606
|
default:
|
|
20356
20607
|
r.skip(t);
|
|
20357
20608
|
}
|
|
@@ -20389,6 +20640,10 @@ var BoardQuery = /* @__PURE__ */ createMessageType(
|
|
|
20389
20640
|
const v = m.player;
|
|
20390
20641
|
if (v != null) w.uint32(48).int32(v);
|
|
20391
20642
|
}
|
|
20643
|
+
{
|
|
20644
|
+
const v = m.connection;
|
|
20645
|
+
if (v != null) ScoreConnection.writeField(w, 7, v);
|
|
20646
|
+
}
|
|
20392
20647
|
}
|
|
20393
20648
|
}
|
|
20394
20649
|
);
|
|
@@ -20396,8 +20651,7 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20396
20651
|
"modlock.wasm.scores.BoardPage",
|
|
20397
20652
|
() => [
|
|
20398
20653
|
[1, "rows", 11, 1, Standing.codec],
|
|
20399
|
-
[2, "player", 11, 0, Standing.codec]
|
|
20400
|
-
[3, "loading", 8]
|
|
20654
|
+
[2, "player", 11, 0, Standing.codec]
|
|
20401
20655
|
],
|
|
20402
20656
|
{
|
|
20403
20657
|
decode: (r, end, m) => {
|
|
@@ -20412,9 +20666,6 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20412
20666
|
case 2:
|
|
20413
20667
|
m.player = Standing.decode(r, r.delimited(), m.player ?? {});
|
|
20414
20668
|
break;
|
|
20415
|
-
case 3:
|
|
20416
|
-
m.loading = r.bool();
|
|
20417
|
-
break;
|
|
20418
20669
|
default:
|
|
20419
20670
|
r.skip(t);
|
|
20420
20671
|
}
|
|
@@ -20430,10 +20681,6 @@ var BoardPage = /* @__PURE__ */ createMessageType(
|
|
|
20430
20681
|
const v = m.player;
|
|
20431
20682
|
if (v != null) Standing.writeField(w, 2, v);
|
|
20432
20683
|
}
|
|
20433
|
-
{
|
|
20434
|
-
const v = m.loading;
|
|
20435
|
-
if (v) w.uint32(24).bool(v);
|
|
20436
|
-
}
|
|
20437
20684
|
}
|
|
20438
20685
|
}
|
|
20439
20686
|
);
|
|
@@ -20508,70 +20755,147 @@ var Standing = /* @__PURE__ */ createMessageType(
|
|
|
20508
20755
|
|
|
20509
20756
|
// js/src/scores.ts
|
|
20510
20757
|
var service2 = "scores";
|
|
20511
|
-
var
|
|
20758
|
+
var requestLimit = 16 * 1024;
|
|
20759
|
+
var tooLarge = "The score call must fit in 16 KiB";
|
|
20760
|
+
var windows = {
|
|
20512
20761
|
allTime: 1 /* ALL_TIME */,
|
|
20513
20762
|
day: 2 /* DAY */,
|
|
20514
20763
|
week: 3 /* WEEK */
|
|
20515
20764
|
};
|
|
20516
|
-
function
|
|
20517
|
-
const
|
|
20765
|
+
function bindScorePlayer(player) {
|
|
20766
|
+
const reply2 = callService(
|
|
20767
|
+
service2,
|
|
20768
|
+
"Bind",
|
|
20769
|
+
ScoreConnection.toBinary(identity(player))
|
|
20770
|
+
);
|
|
20771
|
+
const bound = reply2 === void 0 ? void 0 : ScoreConnection.fromBinary(reply2);
|
|
20772
|
+
if (!bound?.proof) return void 0;
|
|
20773
|
+
return {
|
|
20774
|
+
slot: bound.slot ?? 0,
|
|
20775
|
+
steamId: bound.steamId ?? 0n,
|
|
20776
|
+
generation: bound.generation ?? 0,
|
|
20777
|
+
proof: bound.proof
|
|
20778
|
+
};
|
|
20779
|
+
}
|
|
20780
|
+
function reportScore(player, board, value, done, options = {}) {
|
|
20781
|
+
if (player.proof.length > 64 || !fitsText(board, options)) {
|
|
20782
|
+
after(0, () => done(tooLarge));
|
|
20783
|
+
return;
|
|
20784
|
+
}
|
|
20785
|
+
const payload = encodeRequest(ScoreReport, {
|
|
20786
|
+
...writeFields(options),
|
|
20518
20787
|
board,
|
|
20519
20788
|
player: player.slot,
|
|
20520
|
-
value:
|
|
20521
|
-
tiebreak:
|
|
20522
|
-
|
|
20523
|
-
key: options.key,
|
|
20524
|
-
earnedAtUnixMillis: int64(options.earnedAt ?? 0),
|
|
20525
|
-
evidence: options.evidence
|
|
20789
|
+
value: integer(value),
|
|
20790
|
+
tiebreak: integer(options.tiebreak ?? 0),
|
|
20791
|
+
connection: player
|
|
20526
20792
|
});
|
|
20527
|
-
|
|
20528
|
-
|
|
20529
|
-
|
|
20530
|
-
|
|
20531
|
-
);
|
|
20793
|
+
if (!payload) {
|
|
20794
|
+
after(0, () => done(tooLarge));
|
|
20795
|
+
return;
|
|
20796
|
+
}
|
|
20797
|
+
submit("Report", payload, done);
|
|
20532
20798
|
}
|
|
20533
|
-
function reportMatch(board, places, options = {}) {
|
|
20534
|
-
|
|
20799
|
+
function reportMatch(board, places, done, options = {}) {
|
|
20800
|
+
if (places.length === 0 || places.length > 64) {
|
|
20801
|
+
after(0, () => done("The match needs one to 64 places"));
|
|
20802
|
+
return;
|
|
20803
|
+
}
|
|
20804
|
+
if (places.some(({ player }) => player.proof.length > 64) || !fitsText(board, options)) {
|
|
20805
|
+
after(0, () => done(tooLarge));
|
|
20806
|
+
return;
|
|
20807
|
+
}
|
|
20808
|
+
const payload = encodeRequest(MatchReport, {
|
|
20809
|
+
...writeFields(options),
|
|
20535
20810
|
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
|
|
20811
|
+
places: places.map(({ player, place: place2, value }) => ({
|
|
20812
|
+
player: player.slot,
|
|
20813
|
+
place: place2,
|
|
20814
|
+
value: integer(value ?? 0),
|
|
20815
|
+
connection: player
|
|
20816
|
+
}))
|
|
20545
20817
|
});
|
|
20546
|
-
|
|
20547
|
-
|
|
20548
|
-
|
|
20549
|
-
|
|
20550
|
-
|
|
20551
|
-
);
|
|
20818
|
+
if (!payload) {
|
|
20819
|
+
after(0, () => done(tooLarge));
|
|
20820
|
+
return;
|
|
20821
|
+
}
|
|
20822
|
+
submit("Match", payload, done);
|
|
20552
20823
|
}
|
|
20553
|
-
function readBoard(board, read
|
|
20554
|
-
|
|
20824
|
+
function readBoard(board, read, done) {
|
|
20825
|
+
if (!fitsText(board, read)) {
|
|
20826
|
+
after(0, () => done(void 0, tooLarge));
|
|
20827
|
+
return;
|
|
20828
|
+
}
|
|
20829
|
+
const payload = encodeRequest(BoardQuery, {
|
|
20555
20830
|
board,
|
|
20556
20831
|
partition: read.partition,
|
|
20557
|
-
window: read.window === void 0 ? void 0 :
|
|
20832
|
+
window: read.window === void 0 ? void 0 : windows[read.window],
|
|
20558
20833
|
offset: read.offset,
|
|
20559
20834
|
limit: read.limit,
|
|
20560
|
-
player: read.player?.slot
|
|
20835
|
+
player: read.player?.player.slot,
|
|
20836
|
+
connection: read.player && identity(read.player)
|
|
20561
20837
|
});
|
|
20562
|
-
|
|
20563
|
-
|
|
20564
|
-
|
|
20838
|
+
if (!payload) {
|
|
20839
|
+
after(0, () => done(void 0, tooLarge));
|
|
20840
|
+
return;
|
|
20841
|
+
}
|
|
20842
|
+
callServiceLater(service2, "Read", payload, (reply2, error) => {
|
|
20843
|
+
if (reply2 === void 0) {
|
|
20844
|
+
done(void 0, error);
|
|
20845
|
+
return;
|
|
20846
|
+
}
|
|
20847
|
+
const page = BoardPage.fromBinary(reply2);
|
|
20848
|
+
done({
|
|
20849
|
+
rows: (page.rows ?? []).map(row),
|
|
20850
|
+
player: page.player && row(page.player)
|
|
20851
|
+
});
|
|
20852
|
+
});
|
|
20853
|
+
}
|
|
20854
|
+
function fitsText(board, options) {
|
|
20855
|
+
let units = board.length + (options.key?.length ?? 0) + (options.evidence?.length ?? 0);
|
|
20856
|
+
if (units > requestLimit) {
|
|
20857
|
+
return false;
|
|
20858
|
+
}
|
|
20859
|
+
for (const name in options.partition) {
|
|
20860
|
+
units += 1 + name.length + (options.partition[name]?.length ?? 0);
|
|
20861
|
+
if (units > requestLimit) {
|
|
20862
|
+
return false;
|
|
20863
|
+
}
|
|
20864
|
+
}
|
|
20865
|
+
return true;
|
|
20866
|
+
}
|
|
20867
|
+
function encodeRequest(type, request) {
|
|
20868
|
+
return sizeOf(type, request, requestLimit) <= requestLimit ? type.toBinary(request) : void 0;
|
|
20869
|
+
}
|
|
20870
|
+
function writeFields(options) {
|
|
20565
20871
|
return {
|
|
20566
|
-
|
|
20567
|
-
|
|
20568
|
-
|
|
20872
|
+
key: options.key,
|
|
20873
|
+
earnedAtUnixMillis: integer(options.earnedAt ?? 0),
|
|
20874
|
+
partition: options.partition,
|
|
20875
|
+
evidence: options.evidence
|
|
20569
20876
|
};
|
|
20570
20877
|
}
|
|
20571
|
-
function
|
|
20572
|
-
|
|
20573
|
-
|
|
20574
|
-
|
|
20878
|
+
function submit(method, payload, done) {
|
|
20879
|
+
callServiceLater(service2, method, payload, (reply2, error) => {
|
|
20880
|
+
if (reply2 !== void 0) {
|
|
20881
|
+
done();
|
|
20882
|
+
return;
|
|
20883
|
+
}
|
|
20884
|
+
done(
|
|
20885
|
+
error ?? "The host did not confirm the score",
|
|
20886
|
+
(next) => submit(method, payload, next)
|
|
20887
|
+
);
|
|
20888
|
+
});
|
|
20889
|
+
}
|
|
20890
|
+
function identity(connection2) {
|
|
20891
|
+
return {
|
|
20892
|
+
slot: connection2.player.slot,
|
|
20893
|
+
steamId: connection2.steamId,
|
|
20894
|
+
generation: connection2.generation
|
|
20895
|
+
};
|
|
20896
|
+
}
|
|
20897
|
+
function integer(value) {
|
|
20898
|
+
return BigInt(Math.round(value));
|
|
20575
20899
|
}
|
|
20576
20900
|
function row(standing) {
|
|
20577
20901
|
return {
|
|
@@ -20583,14 +20907,6 @@ function row(standing) {
|
|
|
20583
20907
|
count: standing.count ?? 0
|
|
20584
20908
|
};
|
|
20585
20909
|
}
|
|
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
20910
|
|
|
20595
20911
|
// js/src/index.ts
|
|
20596
20912
|
function log2(...parts) {
|
|
@@ -20999,6 +21315,7 @@ export {
|
|
|
20999
21315
|
adjustSound,
|
|
21000
21316
|
after,
|
|
21001
21317
|
afterMatch,
|
|
21318
|
+
bindScorePlayer,
|
|
21002
21319
|
blockInput,
|
|
21003
21320
|
bystanderStates,
|
|
21004
21321
|
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.89",
|
|
11
|
+
"@modlock/darwin-x64": "0.1.89",
|
|
12
|
+
"@modlock/linux-arm64": "0.1.89",
|
|
13
|
+
"@modlock/linux-x64": "0.1.89",
|
|
14
|
+
"@modlock/win32-x64": "0.1.89"
|
|
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.89"
|
|
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;
|
package/ui.d.ts
CHANGED
|
@@ -537,6 +537,11 @@ export declare function press(player: Player, node: string, action?: string, pay
|
|
|
537
537
|
* the host checked it.
|
|
538
538
|
*/
|
|
539
539
|
export declare function change(player: Player, node: string, value: string | number | boolean | Wheel | undefined): void;
|
|
540
|
-
/**
|
|
540
|
+
/**
|
|
541
|
+
* tick advances the clock to the frame at seconds and fades expiring notices.
|
|
542
|
+
* It redraws a player only on the frame one of their notices expires, since
|
|
543
|
+
* the renderer animates the fade itself; a frame with no expiry renders
|
|
544
|
+
* nothing.
|
|
545
|
+
*/
|
|
541
546
|
export declare function tick(seconds: number): void;
|
|
542
547
|
export {};
|