@chrischall/warapp-mcp 0.4.0 → 0.5.0
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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +4 -0
- package/dist/bundle.js +899 -522
- package/dist/chat.js +11 -3
- package/dist/my-games.js +1 -1
- package/dist/protocol/bundle.js +28 -10
- package/dist/protocol/codec.js +1 -1
- package/dist/protocol/dialect.js +371 -0
- package/dist/protocol/interp.js +143 -66
- package/dist/protocol/methods.js +35 -29
- package/dist/protocol/rpc.js +27 -3
- package/dist/push/socketio.js +2 -2
- package/dist/surrender-pending.js +4 -4
- package/dist/tools/chat-inbox.js +32 -3
- package/dist/tools/chat-read-mark.js +3 -1
- package/dist/tools/my-games.js +10 -3
- package/dist/tools/notifications.js +2 -2
- package/dist/tools/push.js +2 -1
- package/dist/tools/surrender-pending.js +11 -6
- package/dist/version.js +1 -1
- package/manifest.json +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
package/dist/bundle.js
CHANGED
|
@@ -68,7 +68,7 @@ var require_util = __commonJS({
|
|
|
68
68
|
exports.getElementAtPath = getElementAtPath2;
|
|
69
69
|
exports.promiseAllObject = promiseAllObject2;
|
|
70
70
|
exports.randomString = randomString2;
|
|
71
|
-
exports.esc =
|
|
71
|
+
exports.esc = esc3;
|
|
72
72
|
exports.slugify = slugify2;
|
|
73
73
|
exports.isObject = isObject3;
|
|
74
74
|
exports.isPlainObject = isPlainObject4;
|
|
@@ -295,7 +295,7 @@ var require_util = __commonJS({
|
|
|
295
295
|
}
|
|
296
296
|
return str;
|
|
297
297
|
}
|
|
298
|
-
function
|
|
298
|
+
function esc3(str) {
|
|
299
299
|
return JSON.stringify(str);
|
|
300
300
|
}
|
|
301
301
|
function slugify2(input2) {
|
|
@@ -93667,34 +93667,34 @@ var StatsCollector = class {
|
|
|
93667
93667
|
var Method = {
|
|
93668
93668
|
/** Exists in the client's method table, but the web client never calls it (open games come from a page). */
|
|
93669
93669
|
GetOpenGames: 10,
|
|
93670
|
-
GetGameDetails:
|
|
93671
|
-
GameRefresh:
|
|
93672
|
-
GetLatestGameInfo:
|
|
93673
|
-
SendChat:
|
|
93674
|
-
RegisterChatView:
|
|
93675
|
-
GetGameSettings:
|
|
93676
|
-
GetMyGames:
|
|
93677
|
-
AcceptGame:
|
|
93678
|
-
AcceptOpenSeat:
|
|
93679
|
-
AcceptOpenAutoGame:
|
|
93680
|
-
GetOpenAutoGame:
|
|
93681
|
-
DeclineGame:
|
|
93682
|
-
Surrender:
|
|
93683
|
-
AcceptSurrender:
|
|
93684
|
-
GetMapDetails:
|
|
93685
|
-
SendOrders:
|
|
93686
|
-
SendInProgressOrders:
|
|
93687
|
-
SendTerritoryPicks:
|
|
93688
|
-
SendInProgressPicks:
|
|
93689
|
-
BeginFirstTurn:
|
|
93690
|
-
GetTerritoryPicks:
|
|
93691
|
-
UnCommit:
|
|
93692
|
-
GetTurns:
|
|
93693
|
-
Subscribe:
|
|
93694
|
-
GameUpdated:
|
|
93695
|
-
GetInAppNotifications:
|
|
93696
|
-
DeleteInAppNotification:
|
|
93697
|
-
AcknowledgeInAppNotifications:
|
|
93670
|
+
GetGameDetails: 39,
|
|
93671
|
+
GameRefresh: 40,
|
|
93672
|
+
GetLatestGameInfo: 41,
|
|
93673
|
+
SendChat: 43,
|
|
93674
|
+
RegisterChatView: 44,
|
|
93675
|
+
GetGameSettings: 49,
|
|
93676
|
+
GetMyGames: 51,
|
|
93677
|
+
AcceptGame: 61,
|
|
93678
|
+
AcceptOpenSeat: 62,
|
|
93679
|
+
AcceptOpenAutoGame: 63,
|
|
93680
|
+
GetOpenAutoGame: 64,
|
|
93681
|
+
DeclineGame: 65,
|
|
93682
|
+
Surrender: 68,
|
|
93683
|
+
AcceptSurrender: 69,
|
|
93684
|
+
GetMapDetails: 75,
|
|
93685
|
+
SendOrders: 76,
|
|
93686
|
+
SendInProgressOrders: 77,
|
|
93687
|
+
SendTerritoryPicks: 78,
|
|
93688
|
+
SendInProgressPicks: 79,
|
|
93689
|
+
BeginFirstTurn: 80,
|
|
93690
|
+
GetTerritoryPicks: 81,
|
|
93691
|
+
UnCommit: 82,
|
|
93692
|
+
GetTurns: 83,
|
|
93693
|
+
Subscribe: 242,
|
|
93694
|
+
GameUpdated: 245,
|
|
93695
|
+
GetInAppNotifications: 323,
|
|
93696
|
+
DeleteInAppNotification: 324,
|
|
93697
|
+
AcknowledgeInAppNotifications: 325
|
|
93698
93698
|
};
|
|
93699
93699
|
var NAMES = new Map(
|
|
93700
93700
|
Object.entries(Method).map(([name, id]) => [id, name])
|
|
@@ -93795,7 +93795,7 @@ function readSubscribeResult(body) {
|
|
|
93795
93795
|
var CHAT_CHANNEL_PUBLIC = -1;
|
|
93796
93796
|
var NO_CHAT_MARKER = "-1";
|
|
93797
93797
|
function writeGameRefreshParams(w, p) {
|
|
93798
|
-
w.int32(p.gameId).bool(p.chat).bool(p.nonChat).string(NO_CHAT_MARKER).string(NO_CHAT_MARKER).bool(p.lobby).bool(false).bool(false);
|
|
93798
|
+
w.int32(p.gameId).bool(p.chat).bool(p.nonChat).string(NO_CHAT_MARKER).string(NO_CHAT_MARKER).bool(p.lobby).bool(false).bool(false).bool(false);
|
|
93799
93799
|
}
|
|
93800
93800
|
var CHAT_MARK = /^(-1|\d{1,20})$/;
|
|
93801
93801
|
function writeMarkDict(w, marks) {
|
|
@@ -93820,7 +93820,7 @@ function writeSendChatParams(w, p) {
|
|
|
93820
93820
|
w.int32(p.gameId).string(p.text).int32(p.channel ?? CHAT_CHANNEL_PUBLIC);
|
|
93821
93821
|
if (p.recipient === void 0) w.bool(false);
|
|
93822
93822
|
else w.bool(true).int32(p.recipient);
|
|
93823
|
-
w.bool(false).string(null).string(null).bool(false).bool(false);
|
|
93823
|
+
w.bool(false).string(null).string(null).bool(false).bool(false).bool(false);
|
|
93824
93824
|
}
|
|
93825
93825
|
var AttackTransferMode = { Attack: 1, Transfer: 2, AttackTransfer: 3 };
|
|
93826
93826
|
var ORDER_TAG_ATTACK_TRANSFER = 1;
|
|
@@ -109738,6 +109738,432 @@ import { createHash as createHash4, randomBytes as randomBytes4 } from "node:cry
|
|
|
109738
109738
|
import { chmod, mkdir as mkdir4, readdir as readdir4, readFile as readFile4, rename as rename4, rm, stat as stat3, unlink as unlink4, writeFile as writeFile4 } from "node:fs/promises";
|
|
109739
109739
|
import { join as join7 } from "node:path";
|
|
109740
109740
|
|
|
109741
|
+
// src/protocol/codec.ts
|
|
109742
|
+
var PREAMBLE = 1514664249;
|
|
109743
|
+
var PROTOCOL_VERSION = 243;
|
|
109744
|
+
var REPLY_FLAG = 32768;
|
|
109745
|
+
var DATE_EPOCH_MS = Date.UTC(2e3, 0, 1);
|
|
109746
|
+
var NO_DATE_SENTINEL = -34028235e47;
|
|
109747
|
+
var MAX_DATE_SENTINEL = 34028235e47;
|
|
109748
|
+
var DATE_SENTINEL_THRESHOLD = 2524556148e5;
|
|
109749
|
+
var MAX_DATE = /* @__PURE__ */ new Date(864e13);
|
|
109750
|
+
var EXTRAS_PRESENT = 1;
|
|
109751
|
+
var ERROR_KIND = 5;
|
|
109752
|
+
var ProtocolError3 = class extends Error {
|
|
109753
|
+
constructor(kind, message) {
|
|
109754
|
+
super(message);
|
|
109755
|
+
this.kind = kind;
|
|
109756
|
+
this.name = "ProtocolError";
|
|
109757
|
+
}
|
|
109758
|
+
kind;
|
|
109759
|
+
};
|
|
109760
|
+
var MAX_WIRE_COUNT = 1e6;
|
|
109761
|
+
var MAX_EMPTY_ITEMS = 1024;
|
|
109762
|
+
var utf8Decoder = new TextDecoder("utf-8", { fatal: true });
|
|
109763
|
+
var utf8Encoder = new TextEncoder();
|
|
109764
|
+
var GUID_ORDER = [3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11, 12, 13, 14, 15];
|
|
109765
|
+
function checkInt(value, min, max, what) {
|
|
109766
|
+
if (!Number.isInteger(value) || value < min || value > max) {
|
|
109767
|
+
throw new ProtocolError3("out-of-range", `${what} out of range: ${value}`);
|
|
109768
|
+
}
|
|
109769
|
+
}
|
|
109770
|
+
var Writer = class {
|
|
109771
|
+
buf = new Uint8Array(64);
|
|
109772
|
+
view = new DataView(this.buf.buffer);
|
|
109773
|
+
len = 0;
|
|
109774
|
+
ensure(n) {
|
|
109775
|
+
if (this.len + n <= this.buf.length) return;
|
|
109776
|
+
let size = this.buf.length * 2;
|
|
109777
|
+
while (size < this.len + n) size *= 2;
|
|
109778
|
+
const next = new Uint8Array(size);
|
|
109779
|
+
next.set(this.buf.subarray(0, this.len));
|
|
109780
|
+
this.buf = next;
|
|
109781
|
+
this.view = new DataView(next.buffer);
|
|
109782
|
+
}
|
|
109783
|
+
get length() {
|
|
109784
|
+
return this.len;
|
|
109785
|
+
}
|
|
109786
|
+
bytes() {
|
|
109787
|
+
return this.buf.slice(0, this.len);
|
|
109788
|
+
}
|
|
109789
|
+
u8(value) {
|
|
109790
|
+
checkInt(value, 0, 255, "u8");
|
|
109791
|
+
this.ensure(1);
|
|
109792
|
+
this.buf[this.len++] = value;
|
|
109793
|
+
return this;
|
|
109794
|
+
}
|
|
109795
|
+
raw(bytes) {
|
|
109796
|
+
this.ensure(bytes.length);
|
|
109797
|
+
this.buf.set(bytes, this.len);
|
|
109798
|
+
this.len += bytes.length;
|
|
109799
|
+
return this;
|
|
109800
|
+
}
|
|
109801
|
+
bool(value) {
|
|
109802
|
+
return this.u8(value ? 1 : 0);
|
|
109803
|
+
}
|
|
109804
|
+
uint16(value) {
|
|
109805
|
+
checkInt(value, 0, 65535, "uint16");
|
|
109806
|
+
this.ensure(2);
|
|
109807
|
+
this.view.setUint16(this.len, value, true);
|
|
109808
|
+
this.len += 2;
|
|
109809
|
+
return this;
|
|
109810
|
+
}
|
|
109811
|
+
int16(value) {
|
|
109812
|
+
checkInt(value, -32768, 32767, "int16");
|
|
109813
|
+
this.ensure(2);
|
|
109814
|
+
this.view.setInt16(this.len, value, true);
|
|
109815
|
+
this.len += 2;
|
|
109816
|
+
return this;
|
|
109817
|
+
}
|
|
109818
|
+
int32(value) {
|
|
109819
|
+
checkInt(value, -2147483648, 2147483647, "int32");
|
|
109820
|
+
this.ensure(4);
|
|
109821
|
+
this.view.setInt32(this.len, value, true);
|
|
109822
|
+
this.len += 4;
|
|
109823
|
+
return this;
|
|
109824
|
+
}
|
|
109825
|
+
int64(value) {
|
|
109826
|
+
if (typeof value === "number") checkInt(value, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, "int64");
|
|
109827
|
+
const big = BigInt(value);
|
|
109828
|
+
if (big < -(1n << 63n) || big >= 1n << 63n) throw new ProtocolError3("out-of-range", `int64 out of range: ${big}`);
|
|
109829
|
+
this.ensure(8);
|
|
109830
|
+
this.view.setBigInt64(this.len, big, true);
|
|
109831
|
+
this.len += 8;
|
|
109832
|
+
return this;
|
|
109833
|
+
}
|
|
109834
|
+
float32(value) {
|
|
109835
|
+
this.ensure(4);
|
|
109836
|
+
this.view.setFloat32(this.len, value, true);
|
|
109837
|
+
this.len += 4;
|
|
109838
|
+
return this;
|
|
109839
|
+
}
|
|
109840
|
+
float64(value) {
|
|
109841
|
+
this.ensure(8);
|
|
109842
|
+
this.view.setFloat64(this.len, value, true);
|
|
109843
|
+
this.len += 8;
|
|
109844
|
+
return this;
|
|
109845
|
+
}
|
|
109846
|
+
varint(value) {
|
|
109847
|
+
checkInt(value, 0, 4294967295, "varint");
|
|
109848
|
+
let n = value;
|
|
109849
|
+
for (; ; ) {
|
|
109850
|
+
const low = n % 128;
|
|
109851
|
+
n = Math.floor(n / 128);
|
|
109852
|
+
this.u8(n > 0 ? low | 128 : low);
|
|
109853
|
+
if (n === 0) return this;
|
|
109854
|
+
}
|
|
109855
|
+
}
|
|
109856
|
+
/** A nullable string: present flag, varint byte length, UTF-8. */
|
|
109857
|
+
string(value) {
|
|
109858
|
+
if (value === null) return this.bool(false);
|
|
109859
|
+
const encoded = utf8Encoder.encode(value);
|
|
109860
|
+
return this.bool(true).varint(encoded.length).raw(encoded);
|
|
109861
|
+
}
|
|
109862
|
+
/** A datetime; null is the "no date" sentinel. */
|
|
109863
|
+
date(value) {
|
|
109864
|
+
if (value === null) return this.float64(NO_DATE_SENTINEL);
|
|
109865
|
+
const ms = value.getTime();
|
|
109866
|
+
if (Number.isNaN(ms)) throw new ProtocolError3("out-of-range", "invalid Date");
|
|
109867
|
+
if (ms >= MAX_DATE.getTime()) return this.float64(MAX_DATE_SENTINEL);
|
|
109868
|
+
return this.float64(ms - DATE_EPOCH_MS);
|
|
109869
|
+
}
|
|
109870
|
+
/** A GUID from its 32-hex-digit form (dashes allowed), written in .NET byte order. */
|
|
109871
|
+
guid(value) {
|
|
109872
|
+
const hex3 = value.replace(/-/g, "");
|
|
109873
|
+
if (!/^[0-9a-fA-F]{32}$/.test(hex3)) throw new ProtocolError3("out-of-range", `not a guid: ${value}`);
|
|
109874
|
+
const canonical = Array.from({ length: 16 }, (_, i2) => parseInt(hex3.slice(i2 * 2, i2 * 2 + 2), 16));
|
|
109875
|
+
const out = new Uint8Array(16);
|
|
109876
|
+
GUID_ORDER.forEach((src, i2) => {
|
|
109877
|
+
out[src] = canonical[i2];
|
|
109878
|
+
});
|
|
109879
|
+
return this.raw(out);
|
|
109880
|
+
}
|
|
109881
|
+
/** A nullable list: int32 count (-1 = null), then each item. */
|
|
109882
|
+
list(items, writeItem) {
|
|
109883
|
+
if (items === null) return this.int32(-1);
|
|
109884
|
+
this.int32(items.length);
|
|
109885
|
+
for (const item of items) writeItem(this, item);
|
|
109886
|
+
return this;
|
|
109887
|
+
}
|
|
109888
|
+
/** A nullable dict: int32 count (-1 = null), then key, value pairs. */
|
|
109889
|
+
dict(entries2, writeKey, writeValue) {
|
|
109890
|
+
if (entries2 === null) return this.int32(-1);
|
|
109891
|
+
this.int32(entries2.size);
|
|
109892
|
+
for (const [k, v] of entries2) {
|
|
109893
|
+
writeKey(this, k);
|
|
109894
|
+
writeValue(this, v);
|
|
109895
|
+
}
|
|
109896
|
+
return this;
|
|
109897
|
+
}
|
|
109898
|
+
};
|
|
109899
|
+
var Reader = class {
|
|
109900
|
+
constructor(buf, offset2 = 0) {
|
|
109901
|
+
this.buf = buf;
|
|
109902
|
+
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
109903
|
+
this.pos = offset2;
|
|
109904
|
+
}
|
|
109905
|
+
buf;
|
|
109906
|
+
view;
|
|
109907
|
+
pos;
|
|
109908
|
+
get position() {
|
|
109909
|
+
return this.pos;
|
|
109910
|
+
}
|
|
109911
|
+
get remaining() {
|
|
109912
|
+
return this.buf.length - this.pos;
|
|
109913
|
+
}
|
|
109914
|
+
need(n) {
|
|
109915
|
+
if (this.pos + n > this.buf.length) {
|
|
109916
|
+
throw new ProtocolError3("truncated", `read past end: need ${n} byte(s) at offset ${this.pos} of ${this.buf.length}`);
|
|
109917
|
+
}
|
|
109918
|
+
}
|
|
109919
|
+
u8() {
|
|
109920
|
+
this.need(1);
|
|
109921
|
+
return this.buf[this.pos++];
|
|
109922
|
+
}
|
|
109923
|
+
/**
|
|
109924
|
+
* `n` bytes. `n` often comes from the wire (a string or byte-array length), so anything but a
|
|
109925
|
+
* non-negative integer is refused before the position moves: a negative length would rewind the
|
|
109926
|
+
* reader and a NaN or fractional one would leave every later read misaligned.
|
|
109927
|
+
*/
|
|
109928
|
+
raw(n) {
|
|
109929
|
+
if (!Number.isInteger(n) || n < 0) {
|
|
109930
|
+
throw new ProtocolError3("bad-length", `bad byte count ${n} at offset ${this.pos}`);
|
|
109931
|
+
}
|
|
109932
|
+
this.need(n);
|
|
109933
|
+
const out = this.buf.slice(this.pos, this.pos + n);
|
|
109934
|
+
this.pos += n;
|
|
109935
|
+
return out;
|
|
109936
|
+
}
|
|
109937
|
+
bool() {
|
|
109938
|
+
const v = this.u8();
|
|
109939
|
+
if (v > 1) throw new ProtocolError3("bad-bool", `bad bool ${v} at offset ${this.pos - 1}`);
|
|
109940
|
+
return v === 1;
|
|
109941
|
+
}
|
|
109942
|
+
uint16() {
|
|
109943
|
+
this.need(2);
|
|
109944
|
+
const v = this.view.getUint16(this.pos, true);
|
|
109945
|
+
this.pos += 2;
|
|
109946
|
+
return v;
|
|
109947
|
+
}
|
|
109948
|
+
int16() {
|
|
109949
|
+
this.need(2);
|
|
109950
|
+
const v = this.view.getInt16(this.pos, true);
|
|
109951
|
+
this.pos += 2;
|
|
109952
|
+
return v;
|
|
109953
|
+
}
|
|
109954
|
+
int32() {
|
|
109955
|
+
this.need(4);
|
|
109956
|
+
const v = this.view.getInt32(this.pos, true);
|
|
109957
|
+
this.pos += 4;
|
|
109958
|
+
return v;
|
|
109959
|
+
}
|
|
109960
|
+
/** An int64 as a number (exact up to 2^53). */
|
|
109961
|
+
int64() {
|
|
109962
|
+
this.need(8);
|
|
109963
|
+
const v = this.view.getBigInt64(this.pos, true);
|
|
109964
|
+
this.pos += 8;
|
|
109965
|
+
return Number(v);
|
|
109966
|
+
}
|
|
109967
|
+
float32() {
|
|
109968
|
+
this.need(4);
|
|
109969
|
+
const v = this.view.getFloat32(this.pos, true);
|
|
109970
|
+
this.pos += 4;
|
|
109971
|
+
return v;
|
|
109972
|
+
}
|
|
109973
|
+
float64() {
|
|
109974
|
+
this.need(8);
|
|
109975
|
+
const v = this.view.getFloat64(this.pos, true);
|
|
109976
|
+
this.pos += 8;
|
|
109977
|
+
return v;
|
|
109978
|
+
}
|
|
109979
|
+
varint() {
|
|
109980
|
+
let n = 0;
|
|
109981
|
+
let scale = 1;
|
|
109982
|
+
for (let i2 = 0; i2 < 5; i2++) {
|
|
109983
|
+
const c = this.u8();
|
|
109984
|
+
n += (c & 127) * scale;
|
|
109985
|
+
if (!(c & 128)) return n;
|
|
109986
|
+
scale *= 128;
|
|
109987
|
+
}
|
|
109988
|
+
throw new ProtocolError3("bad-varint", `varint longer than 5 bytes ending at offset ${this.pos}`);
|
|
109989
|
+
}
|
|
109990
|
+
string() {
|
|
109991
|
+
if (!this.bool()) return null;
|
|
109992
|
+
const start = this.pos;
|
|
109993
|
+
const n = this.varint();
|
|
109994
|
+
const bytes = this.raw(n);
|
|
109995
|
+
try {
|
|
109996
|
+
return utf8Decoder.decode(bytes);
|
|
109997
|
+
} catch {
|
|
109998
|
+
throw new ProtocolError3("bad-string", `invalid UTF-8 in string at offset ${start}`);
|
|
109999
|
+
}
|
|
110000
|
+
}
|
|
110001
|
+
/** A datetime; the "no date" sentinel reads as null, the max sentinel as MAX_DATE. */
|
|
110002
|
+
date() {
|
|
110003
|
+
const ms = this.float64();
|
|
110004
|
+
if (ms <= -DATE_SENTINEL_THRESHOLD) return null;
|
|
110005
|
+
if (ms >= DATE_SENTINEL_THRESHOLD) return MAX_DATE;
|
|
110006
|
+
return new Date(DATE_EPOCH_MS + ms);
|
|
110007
|
+
}
|
|
110008
|
+
/** A GUID as 32 lowercase hex digits in canonical order. */
|
|
110009
|
+
guid() {
|
|
110010
|
+
const b = this.raw(16);
|
|
110011
|
+
return GUID_ORDER.map((i2) => b[i2].toString(16).padStart(2, "0")).join("");
|
|
110012
|
+
}
|
|
110013
|
+
count() {
|
|
110014
|
+
const at2 = this.pos;
|
|
110015
|
+
const n = this.int32();
|
|
110016
|
+
if (n === -1) return null;
|
|
110017
|
+
if (!Number.isInteger(n) || n < 0) throw new ProtocolError3("bad-length", `bad count ${n} at offset ${at2}`);
|
|
110018
|
+
if (n > MAX_WIRE_COUNT) {
|
|
110019
|
+
throw new ProtocolError3("bad-length", `count ${n} at offset ${at2} exceeds ${MAX_WIRE_COUNT}`);
|
|
110020
|
+
}
|
|
110021
|
+
return n;
|
|
110022
|
+
}
|
|
110023
|
+
/** Refuses a long collection once an item is seen to take no bytes (see MAX_EMPTY_ITEMS). */
|
|
110024
|
+
checkItemSize(n, before, at2) {
|
|
110025
|
+
if (n > MAX_EMPTY_ITEMS && this.pos === before) {
|
|
110026
|
+
throw new ProtocolError3(
|
|
110027
|
+
"bad-length",
|
|
110028
|
+
`count ${n} at offset ${at2} of items that take no bytes (at most ${MAX_EMPTY_ITEMS})`
|
|
110029
|
+
);
|
|
110030
|
+
}
|
|
110031
|
+
}
|
|
110032
|
+
list(readItem) {
|
|
110033
|
+
const at2 = this.pos;
|
|
110034
|
+
const n = this.count();
|
|
110035
|
+
if (n === null) return null;
|
|
110036
|
+
const out = [];
|
|
110037
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
110038
|
+
const before = this.pos;
|
|
110039
|
+
out.push(readItem(this));
|
|
110040
|
+
this.checkItemSize(n, before, at2);
|
|
110041
|
+
}
|
|
110042
|
+
return out;
|
|
110043
|
+
}
|
|
110044
|
+
dict(readKey, readValue) {
|
|
110045
|
+
const at2 = this.pos;
|
|
110046
|
+
const n = this.count();
|
|
110047
|
+
if (n === null) return null;
|
|
110048
|
+
const out = /* @__PURE__ */ new Map();
|
|
110049
|
+
for (let i2 = 0; i2 < n; i2++) {
|
|
110050
|
+
const before = this.pos;
|
|
110051
|
+
const k = readKey(this);
|
|
110052
|
+
out.set(k, readValue(this));
|
|
110053
|
+
this.checkItemSize(n, before, at2);
|
|
110054
|
+
}
|
|
110055
|
+
return out;
|
|
110056
|
+
}
|
|
110057
|
+
};
|
|
110058
|
+
function writeHeader(w, h) {
|
|
110059
|
+
w.uint16(h.version & 32767 | (h.reply ? REPLY_FLAG : 0)).int32(PREAMBLE).int32(h.msgNum).int32(h.method);
|
|
110060
|
+
}
|
|
110061
|
+
function readHeader(r) {
|
|
110062
|
+
const flags = r.uint16();
|
|
110063
|
+
const preamble = r.int32();
|
|
110064
|
+
if (preamble !== PREAMBLE) {
|
|
110065
|
+
throw new ProtocolError3("bad-preamble", `bad preamble ${preamble} (expected ${PREAMBLE})`);
|
|
110066
|
+
}
|
|
110067
|
+
return { version: flags & 32767, reply: (flags & REPLY_FLAG) !== 0, msgNum: r.int32(), method: r.int32() };
|
|
110068
|
+
}
|
|
110069
|
+
var writeIntStringDict = (w, d) => {
|
|
110070
|
+
if (d === null) {
|
|
110071
|
+
w.bool(false);
|
|
110072
|
+
return;
|
|
110073
|
+
}
|
|
110074
|
+
w.bool(true).dict(
|
|
110075
|
+
d,
|
|
110076
|
+
(ww, k) => ww.int32(k),
|
|
110077
|
+
(ww, v) => ww.string(v)
|
|
110078
|
+
);
|
|
110079
|
+
};
|
|
110080
|
+
var readIntStringDict = (r) => r.bool() ? r.dict(
|
|
110081
|
+
(rr) => rr.int32(),
|
|
110082
|
+
(rr) => rr.string()
|
|
110083
|
+
) : null;
|
|
110084
|
+
function writeExtrasUp(w, e) {
|
|
110085
|
+
writeIntStringDict(w, e.dict);
|
|
110086
|
+
w.string(e.client).int32(e.serverInfoVersionA).int32(e.serverInfoVersionB).date(e.fDb).date(e.kFa).int32(e.platform);
|
|
110087
|
+
}
|
|
110088
|
+
function readExtrasUp(r) {
|
|
110089
|
+
const dict = readIntStringDict(r);
|
|
110090
|
+
return {
|
|
110091
|
+
dict: dict === null ? null : new Map([...dict].map(([k, v]) => [k, v ?? ""])),
|
|
110092
|
+
client: r.string(),
|
|
110093
|
+
serverInfoVersionA: r.int32(),
|
|
110094
|
+
serverInfoVersionB: r.int32(),
|
|
110095
|
+
fDb: r.date(),
|
|
110096
|
+
kFa: r.date(),
|
|
110097
|
+
platform: r.int32()
|
|
110098
|
+
};
|
|
110099
|
+
}
|
|
110100
|
+
function optional4(r, read) {
|
|
110101
|
+
return r.bool() ? read(r) : null;
|
|
110102
|
+
}
|
|
110103
|
+
function readExtrasDown(r) {
|
|
110104
|
+
return {
|
|
110105
|
+
cAa: readIntStringDict(r),
|
|
110106
|
+
wca: optional4(r, (rr) => rr.int32()),
|
|
110107
|
+
c2a: r.string(),
|
|
110108
|
+
serverInfo: optional4(r, (rr) => ({
|
|
110109
|
+
okb: rr.string(),
|
|
110110
|
+
lbFlags: rr.string(),
|
|
110111
|
+
serverInfoVersionA: rr.int32(),
|
|
110112
|
+
livestream: optional4(rr, (l) => ({
|
|
110113
|
+
j7: l.string(),
|
|
110114
|
+
jdb: l.int32(),
|
|
110115
|
+
lr: l.date(),
|
|
110116
|
+
zfd: l.string(),
|
|
110117
|
+
yfd: l.string()
|
|
110118
|
+
})),
|
|
110119
|
+
serverInfoVersionB: rr.int32()
|
|
110120
|
+
})),
|
|
110121
|
+
j9: optional4(
|
|
110122
|
+
r,
|
|
110123
|
+
(rr) => rr.dict(
|
|
110124
|
+
(k) => k.int32(),
|
|
110125
|
+
(v) => optional4(v, (vv) => vv.list((s) => s.string()))
|
|
110126
|
+
)
|
|
110127
|
+
),
|
|
110128
|
+
unreadMail: optional4(r, (rr) => ({ cYa: rr.bool(), kFa: rr.date(), h9: rr.bool() }))
|
|
110129
|
+
};
|
|
110130
|
+
}
|
|
110131
|
+
var AUTH_TAG = 4;
|
|
110132
|
+
function encodeRequest(frame) {
|
|
110133
|
+
const w = new Writer();
|
|
110134
|
+
writeHeader(w, {
|
|
110135
|
+
version: frame.version ?? PROTOCOL_VERSION,
|
|
110136
|
+
reply: false,
|
|
110137
|
+
msgNum: frame.msgNum,
|
|
110138
|
+
method: frame.method
|
|
110139
|
+
});
|
|
110140
|
+
writeExtrasUp(w, frame.extras);
|
|
110141
|
+
if (frame.email !== null) w.bool(true).u8(AUTH_TAG).string(frame.email);
|
|
110142
|
+
frame.params?.(w);
|
|
110143
|
+
return w.bytes();
|
|
110144
|
+
}
|
|
110145
|
+
function decodeReplyEnvelope(bytes) {
|
|
110146
|
+
const r = new Reader(bytes);
|
|
110147
|
+
const header = readHeader(r);
|
|
110148
|
+
if (!header.reply) throw new ProtocolError3("not-a-reply", `frame for method ${header.method} is not a reply`);
|
|
110149
|
+
const env = { version: header.version, method: header.method, msgNum: header.msgNum, body: r };
|
|
110150
|
+
if (r.u8() === EXTRAS_PRESENT) env.extrasDown = readExtrasDown(r);
|
|
110151
|
+
if (r.u8() === ERROR_KIND) env.error = { code: r.int32(), message: r.string() };
|
|
110152
|
+
return env;
|
|
110153
|
+
}
|
|
110154
|
+
function toHex(bytes) {
|
|
110155
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
110156
|
+
}
|
|
110157
|
+
function fromHex(hex3) {
|
|
110158
|
+
const clean2 = hex3.trim();
|
|
110159
|
+
if (clean2.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(clean2)) {
|
|
110160
|
+
throw new ProtocolError3("bad-length", "not an even-length hex string");
|
|
110161
|
+
}
|
|
110162
|
+
const out = new Uint8Array(clean2.length / 2);
|
|
110163
|
+
for (let i2 = 0; i2 < out.length; i2++) out[i2] = parseInt(clean2.slice(i2 * 2, i2 * 2 + 2), 16);
|
|
110164
|
+
return out;
|
|
110165
|
+
}
|
|
110166
|
+
|
|
109741
110167
|
// node_modules/acorn/dist/acorn.mjs
|
|
109742
110168
|
var astralIdentifierCodes = [509, 0, 227, 0, 150, 4, 294, 9, 1368, 2, 2, 1, 6, 3, 41, 2, 5, 0, 166, 1, 574, 3, 9, 9, 7, 9, 32, 4, 318, 1, 31, 4, 33, 15, 71, 10, 50, 3, 123, 2, 54, 14, 32, 10, 3, 1, 11, 3, 46, 10, 8, 0, 46, 9, 7, 2, 37, 13, 2, 9, 6, 1, 45, 0, 13, 2, 49, 13, 9, 3, 2, 11, 83, 11, 7, 0, 3, 0, 158, 11, 6, 9, 7, 3, 56, 1, 2, 6, 3, 1, 3, 2, 10, 0, 11, 1, 3, 6, 4, 4, 68, 8, 2, 0, 3, 0, 2, 3, 2, 4, 2, 0, 15, 1, 83, 17, 10, 9, 5, 0, 82, 19, 13, 9, 214, 6, 3, 8, 28, 1, 83, 16, 16, 9, 82, 12, 9, 9, 7, 19, 58, 14, 5, 9, 243, 14, 166, 9, 71, 5, 2, 1, 3, 3, 2, 0, 2, 1, 13, 9, 120, 6, 3, 6, 4, 0, 29, 9, 41, 6, 2, 3, 9, 0, 10, 10, 47, 15, 199, 7, 137, 9, 54, 7, 2, 7, 17, 9, 57, 21, 2, 13, 123, 5, 4, 0, 2, 1, 2, 6, 2, 0, 9, 9, 49, 4, 2, 1, 2, 4, 9, 9, 55, 9, 7, 0, 259, 3, 10, 1, 2, 0, 49, 6, 4, 4, 14, 10, 5350, 0, 7, 14, 11465, 27, 2343, 9, 87, 9, 39, 4, 60, 6, 26, 9, 535, 9, 470, 0, 2, 54, 8, 3, 82, 0, 12, 1, 19628, 1, 4178, 9, 519, 45, 3, 22, 481, 1, 61, 4, 4, 5, 9, 7, 3, 6, 31, 3, 149, 2, 12, 2, 9, 1, 3, 0, 33, 1, 1357, 49, 513, 54, 5, 49, 9, 0, 15, 0, 23, 4, 2, 14, 1361, 6, 2, 16, 3, 6, 2, 1, 2, 4, 101, 0, 161, 6, 10, 9, 357, 0, 62, 13, 499, 13, 245, 1, 2, 9, 233, 0, 3, 0, 8, 1, 6, 0, 475, 6, 110, 6, 6, 9, 4759, 9, 787719, 239];
|
|
109743
110169
|
var astralIdentifierStartCodes = [0, 11, 2, 25, 2, 18, 2, 1, 2, 14, 3, 13, 35, 122, 70, 52, 268, 28, 4, 48, 48, 31, 14, 29, 6, 37, 11, 29, 3, 35, 5, 7, 2, 4, 43, 157, 19, 35, 5, 35, 5, 39, 9, 51, 13, 10, 2, 14, 2, 6, 2, 1, 2, 10, 2, 14, 2, 6, 2, 1, 4, 51, 13, 310, 10, 21, 11, 7, 25, 5, 2, 41, 2, 13, 65, 5, 3, 0, 2, 43, 2, 1, 4, 0, 3, 22, 11, 22, 10, 30, 66, 18, 2, 1, 11, 21, 11, 25, 7, 25, 39, 55, 7, 1, 65, 0, 16, 3, 2, 2, 2, 28, 43, 28, 4, 28, 36, 7, 2, 27, 28, 53, 11, 21, 11, 18, 14, 17, 111, 72, 56, 50, 14, 50, 14, 35, 39, 27, 10, 22, 251, 41, 7, 1, 17, 5, 18, 21, 18, 28, 11, 0, 9, 21, 43, 17, 47, 20, 28, 22, 13, 52, 58, 1, 3, 0, 14, 44, 33, 24, 27, 35, 30, 0, 3, 0, 9, 34, 4, 0, 13, 47, 15, 3, 22, 0, 2, 0, 36, 17, 2, 24, 20, 1, 64, 6, 2, 0, 2, 3, 2, 14, 2, 9, 8, 46, 39, 7, 3, 1, 3, 21, 2, 6, 2, 1, 2, 4, 4, 0, 19, 0, 13, 4, 31, 9, 2, 0, 3, 0, 2, 37, 2, 0, 26, 0, 2, 0, 45, 52, 19, 3, 21, 2, 31, 47, 21, 1, 2, 0, 185, 46, 42, 3, 37, 47, 21, 0, 60, 42, 14, 0, 72, 26, 38, 6, 186, 43, 117, 63, 32, 7, 3, 0, 3, 7, 2, 1, 2, 23, 16, 0, 2, 0, 95, 7, 3, 38, 17, 0, 2, 0, 29, 0, 11, 39, 8, 0, 22, 0, 12, 45, 20, 0, 19, 72, 18, 0, 182, 32, 32, 8, 2, 36, 18, 0, 50, 29, 113, 6, 2, 1, 2, 37, 22, 0, 26, 5, 2, 1, 2, 31, 15, 0, 24, 43, 22, 0, 239, 18, 16, 0, 2, 12, 2, 33, 125, 0, 80, 921, 103, 111, 6, 206, 13, 310, 2314, 96, 16, 1071, 18, 5, 26, 3994, 6, 582, 6842, 29, 1763, 568, 8, 30, 18, 78, 18, 29, 19, 47, 17, 3, 32, 20, 6, 18, 433, 44, 212, 63, 33, 24, 3, 24, 45, 74, 6, 0, 67, 12, 65, 1, 2, 0, 15, 4, 10, 7386, 37, 33, 96, 114, 14, 913, 15, 50, 7710, 3, 2, 6, 2, 1, 2, 296, 10, 0, 30, 2, 3, 0, 15, 4, 8, 395, 2309, 106, 6, 12, 4, 8, 8, 9, 5991, 84, 2, 70, 2, 1, 3, 0, 3, 1, 3, 3, 2, 11, 2, 0, 2, 6, 2, 64, 2, 3, 3, 7, 2, 6, 2, 27, 2, 3, 2, 4, 2, 0, 4, 6, 2, 340, 2, 24, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 30, 2, 24, 2, 7, 1845, 129, 15, 6, 55, 50, 49, 61, 147, 44, 11, 6, 17, 0, 322, 29, 19, 43, 485, 27, 229, 29, 3, 0, 208, 30, 2, 2, 2, 1, 2, 6, 3, 4, 10, 1, 225, 6, 2, 3, 2, 1, 2, 14, 2, 196, 60, 67, 8, 0, 1205, 3, 2, 26, 2, 1, 2, 0, 3, 0, 2, 9, 2, 3, 2, 0, 2, 0, 7, 0, 5, 0, 2, 0, 2, 0, 2, 2, 2, 1, 2, 0, 3, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 1, 2, 0, 3, 3, 2, 6, 2, 3, 2, 3, 2, 0, 2, 9, 2, 16, 6, 2, 2, 4, 2, 16, 4421, 42719, 33, 4382, 2, 5773, 3, 7472, 16, 621, 2467, 541, 1507, 4938, 6, 8489, 39815, 11327];
|
|
@@ -115418,11 +115844,11 @@ pp.readWord1 = function() {
|
|
|
115418
115844
|
this.invalidStringToken(this.pos, "Expecting Unicode escape sequence \\uXXXX");
|
|
115419
115845
|
}
|
|
115420
115846
|
++this.pos;
|
|
115421
|
-
var
|
|
115422
|
-
if (!(first ? isIdentifierStart : isIdentifierChar)(
|
|
115847
|
+
var esc3 = this.readCodePoint();
|
|
115848
|
+
if (!(first ? isIdentifierStart : isIdentifierChar)(esc3, astral)) {
|
|
115423
115849
|
this.invalidStringToken(escStart, "Invalid Unicode escape");
|
|
115424
115850
|
}
|
|
115425
|
-
word += codePointToString(
|
|
115851
|
+
word += codePointToString(esc3);
|
|
115426
115852
|
chunkStart = this.pos;
|
|
115427
115853
|
} else {
|
|
115428
115854
|
break;
|
|
@@ -115465,430 +115891,274 @@ function parseExpressionAt2(input2, pos, options) {
|
|
|
115465
115891
|
return Parser.parseExpressionAt(input2, pos, options);
|
|
115466
115892
|
}
|
|
115467
115893
|
|
|
115468
|
-
// src/protocol/
|
|
115469
|
-
var
|
|
115470
|
-
var
|
|
115471
|
-
var
|
|
115472
|
-
var
|
|
115473
|
-
var
|
|
115474
|
-
var
|
|
115475
|
-
var
|
|
115476
|
-
|
|
115477
|
-
|
|
115478
|
-
|
|
115479
|
-
|
|
115480
|
-
|
|
115481
|
-
|
|
115482
|
-
|
|
115483
|
-
|
|
115484
|
-
|
|
115485
|
-
|
|
115486
|
-
|
|
115487
|
-
|
|
115488
|
-
|
|
115489
|
-
|
|
115490
|
-
|
|
115491
|
-
|
|
115492
|
-
|
|
115493
|
-
|
|
115494
|
-
|
|
115894
|
+
// src/protocol/dialect.ts
|
|
115895
|
+
var INPUT_TYPE = "haxe.io.Input";
|
|
115896
|
+
var READER_TYPE = "system.io.BinaryReader";
|
|
115897
|
+
var SERIALIZER_TYPE = "warlight.shared.Serializer";
|
|
115898
|
+
var UTILITY_TYPE = "warlight.shared.SharedUtility";
|
|
115899
|
+
var PUMP_TYPE = "warlight.shared.MessagePump";
|
|
115900
|
+
var ENUMERABLE_TYPE = "system.linq.Enumerable";
|
|
115901
|
+
var WRAPPER_TYPES = [
|
|
115902
|
+
"system.Nullable_Int",
|
|
115903
|
+
"system.Nullable",
|
|
115904
|
+
"system.Nullable_Float",
|
|
115905
|
+
"system.Nullable_Bool",
|
|
115906
|
+
"system.CsRef",
|
|
115907
|
+
"system.TimeSpan",
|
|
115908
|
+
"system.DateTime"
|
|
115909
|
+
];
|
|
115910
|
+
var MAX_FN_SOURCE = 4e3;
|
|
115911
|
+
var REQUIRED_READER_ROLES = ["bool", "int32", "u8", "string", "float64", "float32", "uint16", "raw", "varint"];
|
|
115912
|
+
var REQUIRED_STATIC_ROLES = [
|
|
115913
|
+
"int32",
|
|
115914
|
+
"string",
|
|
115915
|
+
"bool",
|
|
115916
|
+
"u8",
|
|
115917
|
+
"float32",
|
|
115918
|
+
"float64",
|
|
115919
|
+
"timespan",
|
|
115920
|
+
"date",
|
|
115921
|
+
"guid",
|
|
115922
|
+
"uint16",
|
|
115923
|
+
"bytes",
|
|
115924
|
+
"list",
|
|
115925
|
+
"dict"
|
|
115926
|
+
];
|
|
115927
|
+
var KEYWORDS = new Set(
|
|
115928
|
+
"var let const function return if else for while do break continue new null true false this typeof instanceof in of throw try catch finally switch case default void delete".split(" ")
|
|
115929
|
+
);
|
|
115930
|
+
var TOKEN = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[A-Za-z_$][\w$]*|\d+(?:\.\d+)?(?:[eE][-+]?\d+)?|>>>=?|===|!==|<<=|>>=|[=!<>]=|&&|\|\||\+\+|--|<<|>>|[-+*/%&|^]=|\S/g;
|
|
115931
|
+
function canonicalize(src, roleOf, typeOf2) {
|
|
115932
|
+
const names2 = /* @__PURE__ */ new Map();
|
|
115933
|
+
const out = [];
|
|
115934
|
+
let prev = "";
|
|
115935
|
+
for (const t of src.match(TOKEN) ?? []) {
|
|
115936
|
+
const c = t[0];
|
|
115937
|
+
const isName = /[A-Za-z_$]/.test(c);
|
|
115938
|
+
if (!isName || KEYWORDS.has(t)) out.push(t);
|
|
115939
|
+
else if (prev === "." && roleOf(t) !== void 0) out.push(`@${roleOf(t)}`);
|
|
115940
|
+
else if (prev !== "." && typeOf2(t) !== void 0) out.push(`@T:${typeOf2(t)}`);
|
|
115941
|
+
else {
|
|
115942
|
+
let n = names2.get(t);
|
|
115943
|
+
if (n === void 0) {
|
|
115944
|
+
n = `#${names2.size}`;
|
|
115945
|
+
names2.set(t, n);
|
|
115946
|
+
}
|
|
115947
|
+
out.push(n);
|
|
115948
|
+
}
|
|
115949
|
+
prev = t;
|
|
115950
|
+
}
|
|
115951
|
+
return out.join(" ");
|
|
115952
|
+
}
|
|
115953
|
+
var SERIALIZER_TEMPLATES = {
|
|
115954
|
+
"function ( #0 ) { return #0 . @int32 ( ) }": "int32",
|
|
115955
|
+
"function ( #0 ) { return #0 . @bool ( ) ? #0 . @string ( ) : null }": "string",
|
|
115956
|
+
"function ( #0 ) { return #0 . @bool ( ) }": "bool",
|
|
115957
|
+
"function ( #0 ) { return #0 . @u8 ( ) }": "u8",
|
|
115958
|
+
"function ( #0 ) { return #0 . @float32 ( ) }": "float32",
|
|
115959
|
+
"function ( #0 ) { return #0 . @float64 ( ) }": "float64",
|
|
115960
|
+
"function ( #0 ) { return #0 . @uint16 ( ) }": "uint16",
|
|
115961
|
+
"function ( #0 ) { #0 = #0 . @float64 ( ) ; return - 922336666814565 >= #0 ? @T:system.TimeSpan . #1 : 922336666814565 <= #0 ? @T:system.TimeSpan . #2 : new @T:system.TimeSpan ( #0 ) }": "timespan",
|
|
115962
|
+
"function ( #0 ) { var #1 = #0 . @int32 ( ) ; return - 1 == #1 ? null : #0 . @raw ( #1 ) }": "bytes",
|
|
115963
|
+
"function ( #0 , #1 ) { #0 = #0 . @int32 ( ) ; if ( - 1 == #0 ) return null ; for ( var #2 = [ ] , #3 = 0 ; #3 < #0 ; ) #2 . #4 ( #1 ( ) ) , ++ #3 ; return #2 }": "list",
|
|
115964
|
+
"function ( #0 , #1 ) { #0 = #0 . @int32 ( ) ; if ( - 1 == #0 ) return null ; for ( var #2 = [ ] , #3 = 0 ; #3 < #0 ; ) #2 [ #3 ] = #1 ( ) , ++ #3 ; return #2 }": "list",
|
|
115965
|
+
'function ( #0 , #1 , #2 ) { #0 = #0 . @int32 ( ) ; if ( - 1 == #0 ) return null ; for ( var #3 = new @T:system.collections.generic.Dictionary ( #0 ) , #4 = 0 ; #4 < #0 ; ) { var #5 = #1 ( ) ; @T:warlight.shared.Assert . #6 ( ! #3 . #7 ( #5 ) , "Dupe keys deserialized" ) ; #3 . #8 ( #5 , #2 ( ) ) ; ++ #4 } return #3 }': "dict"
|
|
115966
|
+
};
|
|
115967
|
+
var UTILITY_CALL = "function ( #0 ) { return @T:warlight.shared.SharedUtility . #1 ( #0 ) }";
|
|
115968
|
+
var COLLECTION_LIST = /^function \( #0 , #1 \) \{ #0 = #0 \. @int32 \( \) ; if \( - 1 == #0 \) return null ; for \( var #2 = new (?:#\d+|@T:[\w.$]+) , #3 = 0 ; #3 < #0 ; \) #2 \. #\d+ \( #1 \( \) \) , \+\+ #3 ; return #2 \}$/;
|
|
115969
|
+
var UTILITY_IDENTITY_MARK = '"ParseLongSafe(null)"';
|
|
115970
|
+
var UTILITY_TRY_GET = /^function \( #0 , #1 , #2 \) \{ var #3 = new @T:system\.CsRef \( null \) ; return #0 \. #4 \( #1 , #3 \) \? #3 \. #5 : #2 \}$/;
|
|
115971
|
+
var IDENTITY = "function ( #0 ) { return #0 }";
|
|
115972
|
+
var SELECT = "function ( #0 , #1 ) { for ( var #2 = [ ] , #3 = 0 ; #3 < #0 . #4 ; ) { var #5 = #0 [ #3 ] ; ++ #3 ; #2 . #6 ( #1 ( #5 ) ) } return #2 }";
|
|
115973
|
+
var TO_ARRAY = "function ( #0 ) { for ( var #1 = [ ] , #2 = 0 ; #2 < #0 . #3 ; ) { var #4 = #0 [ #2 ] ; ++ #2 ; #1 . #5 ( #4 ) } return #1 }";
|
|
115974
|
+
function functionAt(src, at2) {
|
|
115975
|
+
try {
|
|
115976
|
+
const end = Math.min(src.length, at2 + MAX_FN_SOURCE);
|
|
115977
|
+
const node2 = parseExpressionAt2(src.slice(0, end), at2, { ecmaVersion: "latest" });
|
|
115978
|
+
if (node2.type !== "FunctionExpression") return void 0;
|
|
115979
|
+
return src.slice(at2, node2.end);
|
|
115980
|
+
} catch {
|
|
115981
|
+
return void 0;
|
|
115495
115982
|
}
|
|
115496
115983
|
}
|
|
115497
|
-
var
|
|
115498
|
-
|
|
115499
|
-
|
|
115500
|
-
|
|
115501
|
-
|
|
115502
|
-
|
|
115503
|
-
|
|
115504
|
-
while (size < this.len + n) size *= 2;
|
|
115505
|
-
const next = new Uint8Array(size);
|
|
115506
|
-
next.set(this.buf.subarray(0, this.len));
|
|
115507
|
-
this.buf = next;
|
|
115508
|
-
this.view = new DataView(next.buffer);
|
|
115509
|
-
}
|
|
115510
|
-
get length() {
|
|
115511
|
-
return this.len;
|
|
115512
|
-
}
|
|
115513
|
-
bytes() {
|
|
115514
|
-
return this.buf.slice(0, this.len);
|
|
115515
|
-
}
|
|
115516
|
-
u8(value) {
|
|
115517
|
-
checkInt(value, 0, 255, "u8");
|
|
115518
|
-
this.ensure(1);
|
|
115519
|
-
this.buf[this.len++] = value;
|
|
115520
|
-
return this;
|
|
115521
|
-
}
|
|
115522
|
-
raw(bytes) {
|
|
115523
|
-
this.ensure(bytes.length);
|
|
115524
|
-
this.buf.set(bytes, this.len);
|
|
115525
|
-
this.len += bytes.length;
|
|
115526
|
-
return this;
|
|
115527
|
-
}
|
|
115528
|
-
bool(value) {
|
|
115529
|
-
return this.u8(value ? 1 : 0);
|
|
115530
|
-
}
|
|
115531
|
-
uint16(value) {
|
|
115532
|
-
checkInt(value, 0, 65535, "uint16");
|
|
115533
|
-
this.ensure(2);
|
|
115534
|
-
this.view.setUint16(this.len, value, true);
|
|
115535
|
-
this.len += 2;
|
|
115536
|
-
return this;
|
|
115537
|
-
}
|
|
115538
|
-
int16(value) {
|
|
115539
|
-
checkInt(value, -32768, 32767, "int16");
|
|
115540
|
-
this.ensure(2);
|
|
115541
|
-
this.view.setInt16(this.len, value, true);
|
|
115542
|
-
this.len += 2;
|
|
115543
|
-
return this;
|
|
115544
|
-
}
|
|
115545
|
-
int32(value) {
|
|
115546
|
-
checkInt(value, -2147483648, 2147483647, "int32");
|
|
115547
|
-
this.ensure(4);
|
|
115548
|
-
this.view.setInt32(this.len, value, true);
|
|
115549
|
-
this.len += 4;
|
|
115550
|
-
return this;
|
|
115551
|
-
}
|
|
115552
|
-
int64(value) {
|
|
115553
|
-
if (typeof value === "number") checkInt(value, Number.MIN_SAFE_INTEGER, Number.MAX_SAFE_INTEGER, "int64");
|
|
115554
|
-
const big = BigInt(value);
|
|
115555
|
-
if (big < -(1n << 63n) || big >= 1n << 63n) throw new ProtocolError3("out-of-range", `int64 out of range: ${big}`);
|
|
115556
|
-
this.ensure(8);
|
|
115557
|
-
this.view.setBigInt64(this.len, big, true);
|
|
115558
|
-
this.len += 8;
|
|
115559
|
-
return this;
|
|
115560
|
-
}
|
|
115561
|
-
float32(value) {
|
|
115562
|
-
this.ensure(4);
|
|
115563
|
-
this.view.setFloat32(this.len, value, true);
|
|
115564
|
-
this.len += 4;
|
|
115565
|
-
return this;
|
|
115566
|
-
}
|
|
115567
|
-
float64(value) {
|
|
115568
|
-
this.ensure(8);
|
|
115569
|
-
this.view.setFloat64(this.len, value, true);
|
|
115570
|
-
this.len += 8;
|
|
115571
|
-
return this;
|
|
115572
|
-
}
|
|
115573
|
-
varint(value) {
|
|
115574
|
-
checkInt(value, 0, 4294967295, "varint");
|
|
115575
|
-
let n = value;
|
|
115576
|
-
for (; ; ) {
|
|
115577
|
-
const low = n % 128;
|
|
115578
|
-
n = Math.floor(n / 128);
|
|
115579
|
-
this.u8(n > 0 ? low | 128 : low);
|
|
115580
|
-
if (n === 0) return this;
|
|
115581
|
-
}
|
|
115582
|
-
}
|
|
115583
|
-
/** A nullable string: present flag, varint byte length, UTF-8. */
|
|
115584
|
-
string(value) {
|
|
115585
|
-
if (value === null) return this.bool(false);
|
|
115586
|
-
const encoded = utf8Encoder.encode(value);
|
|
115587
|
-
return this.bool(true).varint(encoded.length).raw(encoded);
|
|
115588
|
-
}
|
|
115589
|
-
/** A datetime; null is the "no date" sentinel. */
|
|
115590
|
-
date(value) {
|
|
115591
|
-
if (value === null) return this.float64(NO_DATE_SENTINEL);
|
|
115592
|
-
const ms = value.getTime();
|
|
115593
|
-
if (Number.isNaN(ms)) throw new ProtocolError3("out-of-range", "invalid Date");
|
|
115594
|
-
if (ms >= MAX_DATE.getTime()) return this.float64(MAX_DATE_SENTINEL);
|
|
115595
|
-
return this.float64(ms - DATE_EPOCH_MS);
|
|
115596
|
-
}
|
|
115597
|
-
/** A GUID from its 32-hex-digit form (dashes allowed), written in .NET byte order. */
|
|
115598
|
-
guid(value) {
|
|
115599
|
-
const hex3 = value.replace(/-/g, "");
|
|
115600
|
-
if (!/^[0-9a-fA-F]{32}$/.test(hex3)) throw new ProtocolError3("out-of-range", `not a guid: ${value}`);
|
|
115601
|
-
const canonical = Array.from({ length: 16 }, (_, i2) => parseInt(hex3.slice(i2 * 2, i2 * 2 + 2), 16));
|
|
115602
|
-
const out = new Uint8Array(16);
|
|
115603
|
-
GUID_ORDER.forEach((src, i2) => {
|
|
115604
|
-
out[src] = canonical[i2];
|
|
115605
|
-
});
|
|
115606
|
-
return this.raw(out);
|
|
115607
|
-
}
|
|
115608
|
-
/** A nullable list: int32 count (-1 = null), then each item. */
|
|
115609
|
-
list(items, writeItem) {
|
|
115610
|
-
if (items === null) return this.int32(-1);
|
|
115611
|
-
this.int32(items.length);
|
|
115612
|
-
for (const item of items) writeItem(this, item);
|
|
115613
|
-
return this;
|
|
115614
|
-
}
|
|
115615
|
-
/** A nullable dict: int32 count (-1 = null), then key, value pairs. */
|
|
115616
|
-
dict(entries2, writeKey, writeValue) {
|
|
115617
|
-
if (entries2 === null) return this.int32(-1);
|
|
115618
|
-
this.int32(entries2.size);
|
|
115619
|
-
for (const [k, v] of entries2) {
|
|
115620
|
-
writeKey(this, k);
|
|
115621
|
-
writeValue(this, v);
|
|
115622
|
-
}
|
|
115623
|
-
return this;
|
|
115624
|
-
}
|
|
115625
|
-
};
|
|
115626
|
-
var Reader = class {
|
|
115627
|
-
constructor(buf, offset2 = 0) {
|
|
115628
|
-
this.buf = buf;
|
|
115629
|
-
this.view = new DataView(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
115630
|
-
this.pos = offset2;
|
|
115631
|
-
}
|
|
115632
|
-
buf;
|
|
115633
|
-
view;
|
|
115634
|
-
pos;
|
|
115635
|
-
get position() {
|
|
115636
|
-
return this.pos;
|
|
115637
|
-
}
|
|
115638
|
-
get remaining() {
|
|
115639
|
-
return this.buf.length - this.pos;
|
|
115640
|
-
}
|
|
115641
|
-
need(n) {
|
|
115642
|
-
if (this.pos + n > this.buf.length) {
|
|
115643
|
-
throw new ProtocolError3("truncated", `read past end: need ${n} byte(s) at offset ${this.pos} of ${this.buf.length}`);
|
|
115644
|
-
}
|
|
115984
|
+
var esc2 = (s) => s.replace(/\$/g, "\\$");
|
|
115985
|
+
function staticsOf(src, cls) {
|
|
115986
|
+
const out = /* @__PURE__ */ new Map();
|
|
115987
|
+
for (const m of src.matchAll(new RegExp(`(?<![\\w$.])${esc2(cls)}\\.([\\w$]+)\\s*=\\s*(?=function\\b)`, "g"))) {
|
|
115988
|
+
if (out.has(m[1])) continue;
|
|
115989
|
+
const fn = functionAt(src, m.index + m[0].length);
|
|
115990
|
+
if (fn) out.set(m[1], fn);
|
|
115645
115991
|
}
|
|
115646
|
-
|
|
115647
|
-
|
|
115648
|
-
|
|
115992
|
+
return out;
|
|
115993
|
+
}
|
|
115994
|
+
function prototypeOf(src, cls) {
|
|
115995
|
+
const out = /* @__PURE__ */ new Map();
|
|
115996
|
+
const m = new RegExp(`(?<![\\w$.])${esc2(cls)}\\.prototype\\s*=\\s*`).exec(src);
|
|
115997
|
+
if (!m) return out;
|
|
115998
|
+
let at2 = m.index + m[0].length;
|
|
115999
|
+
if (src[at2] !== "{") {
|
|
116000
|
+
const brace = src.indexOf("{", at2);
|
|
116001
|
+
if (brace < 0 || brace - at2 > 200) return out;
|
|
116002
|
+
at2 = brace;
|
|
115649
116003
|
}
|
|
115650
|
-
|
|
115651
|
-
|
|
115652
|
-
|
|
115653
|
-
|
|
115654
|
-
*/
|
|
115655
|
-
raw(n) {
|
|
115656
|
-
if (!Number.isInteger(n) || n < 0) {
|
|
115657
|
-
throw new ProtocolError3("bad-length", `bad byte count ${n} at offset ${this.pos}`);
|
|
115658
|
-
}
|
|
115659
|
-
this.need(n);
|
|
115660
|
-
const out = this.buf.slice(this.pos, this.pos + n);
|
|
115661
|
-
this.pos += n;
|
|
116004
|
+
let obj;
|
|
116005
|
+
try {
|
|
116006
|
+
obj = parseExpressionAt2(src, at2, { ecmaVersion: "latest" });
|
|
116007
|
+
} catch {
|
|
115662
116008
|
return out;
|
|
115663
116009
|
}
|
|
115664
|
-
|
|
115665
|
-
|
|
115666
|
-
if (
|
|
115667
|
-
|
|
115668
|
-
|
|
115669
|
-
uint16() {
|
|
115670
|
-
this.need(2);
|
|
115671
|
-
const v = this.view.getUint16(this.pos, true);
|
|
115672
|
-
this.pos += 2;
|
|
115673
|
-
return v;
|
|
115674
|
-
}
|
|
115675
|
-
int16() {
|
|
115676
|
-
this.need(2);
|
|
115677
|
-
const v = this.view.getInt16(this.pos, true);
|
|
115678
|
-
this.pos += 2;
|
|
115679
|
-
return v;
|
|
115680
|
-
}
|
|
115681
|
-
int32() {
|
|
115682
|
-
this.need(4);
|
|
115683
|
-
const v = this.view.getInt32(this.pos, true);
|
|
115684
|
-
this.pos += 4;
|
|
115685
|
-
return v;
|
|
115686
|
-
}
|
|
115687
|
-
/** An int64 as a number (exact up to 2^53). */
|
|
115688
|
-
int64() {
|
|
115689
|
-
this.need(8);
|
|
115690
|
-
const v = this.view.getBigInt64(this.pos, true);
|
|
115691
|
-
this.pos += 8;
|
|
115692
|
-
return Number(v);
|
|
116010
|
+
if (obj.type !== "ObjectExpression") return out;
|
|
116011
|
+
for (const p of obj.properties ?? []) {
|
|
116012
|
+
if (p.type !== "Property" || p.key.type !== "Identifier" || !p.key.name) continue;
|
|
116013
|
+
if (p.value.type !== "FunctionExpression" || p.value.end - p.value.start > MAX_FN_SOURCE) continue;
|
|
116014
|
+
out.set(p.key.name, src.slice(p.value.start, p.value.end));
|
|
115693
116015
|
}
|
|
115694
|
-
|
|
115695
|
-
|
|
115696
|
-
|
|
115697
|
-
|
|
115698
|
-
|
|
115699
|
-
|
|
115700
|
-
|
|
115701
|
-
|
|
115702
|
-
|
|
115703
|
-
|
|
115704
|
-
|
|
115705
|
-
|
|
115706
|
-
|
|
115707
|
-
|
|
115708
|
-
|
|
115709
|
-
|
|
115710
|
-
|
|
115711
|
-
|
|
115712
|
-
|
|
115713
|
-
|
|
116016
|
+
return out;
|
|
116017
|
+
}
|
|
116018
|
+
function inputRoles(methods) {
|
|
116019
|
+
const roles = /* @__PURE__ */ new Map();
|
|
116020
|
+
let readByte;
|
|
116021
|
+
for (const [name, fn] of methods) {
|
|
116022
|
+
if (/methodName\s*:\s*"readByte"/.test(fn)) readByte = name;
|
|
116023
|
+
}
|
|
116024
|
+
if (!readByte) return roles;
|
|
116025
|
+
roles.set(readByte, "readByte");
|
|
116026
|
+
const calls = (fn, name) => fn.split(`this.${name}(`).length - 1;
|
|
116027
|
+
let readInt32;
|
|
116028
|
+
for (const [name, fn] of methods) {
|
|
116029
|
+
if (name === readByte) continue;
|
|
116030
|
+
const bytes = calls(fn, readByte);
|
|
116031
|
+
if (bytes === 4 && fn.includes("<<24")) {
|
|
116032
|
+
readInt32 = name;
|
|
116033
|
+
roles.set(name, "readInt32");
|
|
116034
|
+
} else if (bytes === 2 && fn.includes("32768")) roles.set(name, "readInt16");
|
|
116035
|
+
else if (bytes === 2) roles.set(name, "readUInt16");
|
|
116036
|
+
}
|
|
116037
|
+
if (readInt32) {
|
|
116038
|
+
for (const [name, fn] of methods) {
|
|
116039
|
+
if (roles.has(name)) continue;
|
|
116040
|
+
const ints3 = calls(fn, readInt32);
|
|
116041
|
+
if (ints3 === 2) roles.set(name, "readDouble");
|
|
116042
|
+
else if (ints3 === 1) roles.set(name, "readFloat");
|
|
116043
|
+
}
|
|
116044
|
+
}
|
|
116045
|
+
return roles;
|
|
116046
|
+
}
|
|
116047
|
+
var FROM_INPUT = {
|
|
116048
|
+
readByte: "u8",
|
|
116049
|
+
readInt32: "int32",
|
|
116050
|
+
readInt16: "int16",
|
|
116051
|
+
readUInt16: "uint16",
|
|
116052
|
+
readFloat: "float32",
|
|
116053
|
+
readDouble: "float64"
|
|
116054
|
+
};
|
|
116055
|
+
function readerRoles(methods, input2) {
|
|
116056
|
+
const roles = /* @__PURE__ */ new Map();
|
|
116057
|
+
for (const [name, fn] of methods) {
|
|
116058
|
+
if (fn.includes('"Bad format"') && /&127\)<</.test(fn)) roles.set(name, "varint");
|
|
116059
|
+
else if (/new [\w$]+\(new ArrayBuffer\(/.test(fn)) roles.set(name, "raw");
|
|
116060
|
+
else if (fn.includes("4294967296")) continue;
|
|
116061
|
+
else {
|
|
116062
|
+
const bool2 = /return\s*0\s*!=\s*this\.[\w$]+\.([\w$]+)\(\)/.exec(fn);
|
|
116063
|
+
if (bool2 && input2.get(bool2[1]) === "readByte") {
|
|
116064
|
+
roles.set(name, "bool");
|
|
116065
|
+
continue;
|
|
116066
|
+
}
|
|
116067
|
+
const direct = /return\s+this\.[\w$]+\.([\w$]+)\(\)/.exec(fn);
|
|
116068
|
+
const r = direct ? input2.get(direct[1]) : void 0;
|
|
116069
|
+
if (r) roles.set(name, FROM_INPUT[r]);
|
|
115714
116070
|
}
|
|
115715
|
-
throw new ProtocolError3("bad-varint", `varint longer than 5 bytes ending at offset ${this.pos}`);
|
|
115716
116071
|
}
|
|
115717
|
-
|
|
115718
|
-
|
|
115719
|
-
|
|
115720
|
-
|
|
115721
|
-
|
|
115722
|
-
|
|
115723
|
-
return
|
|
115724
|
-
} catch {
|
|
115725
|
-
throw new ProtocolError3("bad-string", `invalid UTF-8 in string at offset ${start}`);
|
|
116072
|
+
for (let pass = 0; pass < 3; pass++) {
|
|
116073
|
+
for (const [name, fn] of methods) {
|
|
116074
|
+
if (roles.has(name)) continue;
|
|
116075
|
+
const own2 = [...fn.matchAll(/this\.([\w$]+)\(/g)].map((m) => m[1]).filter((n) => methods.has(n));
|
|
116076
|
+
const ownRoles = own2.map((n) => roles.get(n));
|
|
116077
|
+
if (ownRoles.includes("varint") && ownRoles.includes("raw")) roles.set(name, "string");
|
|
116078
|
+
else if (own2.length === 1 && ownRoles[0] && /^function\(\)\{try\{return this\.[\w$]+\(\)\}/.test(fn)) roles.set(name, ownRoles[0]);
|
|
115726
116079
|
}
|
|
115727
116080
|
}
|
|
115728
|
-
|
|
115729
|
-
|
|
115730
|
-
|
|
115731
|
-
|
|
115732
|
-
|
|
115733
|
-
|
|
115734
|
-
|
|
115735
|
-
/** A GUID as 32 lowercase hex digits in canonical order. */
|
|
115736
|
-
guid() {
|
|
115737
|
-
const b = this.raw(16);
|
|
115738
|
-
return GUID_ORDER.map((i2) => b[i2].toString(16).padStart(2, "0")).join("");
|
|
116081
|
+
return roles;
|
|
116082
|
+
}
|
|
116083
|
+
function bundleProtocol(src) {
|
|
116084
|
+
const counts = /* @__PURE__ */ new Map();
|
|
116085
|
+
for (const m of src.matchAll(/null==([a-z])&&\(\1=(\d{3})\)/g)) {
|
|
116086
|
+
const v = Number(m[2]);
|
|
116087
|
+
counts.set(v, (counts.get(v) ?? 0) + 1);
|
|
115739
116088
|
}
|
|
115740
|
-
|
|
115741
|
-
|
|
115742
|
-
|
|
115743
|
-
if (
|
|
115744
|
-
|
|
115745
|
-
|
|
115746
|
-
|
|
116089
|
+
let best;
|
|
116090
|
+
let n = 0;
|
|
116091
|
+
for (const [v, c] of counts) {
|
|
116092
|
+
if (c > n) {
|
|
116093
|
+
best = v;
|
|
116094
|
+
n = c;
|
|
116095
|
+
}
|
|
116096
|
+
}
|
|
116097
|
+
return n >= 3 ? best : void 0;
|
|
116098
|
+
}
|
|
116099
|
+
function deriveDialect(bundle) {
|
|
116100
|
+
const { src, typeNameOf, varOf } = bundle;
|
|
116101
|
+
const inputVar = varOf.get(INPUT_TYPE);
|
|
116102
|
+
const readerVar = varOf.get(READER_TYPE);
|
|
116103
|
+
const serializer = varOf.get(SERIALIZER_TYPE);
|
|
116104
|
+
if (!inputVar || !readerVar || !serializer) return null;
|
|
116105
|
+
const input2 = inputRoles(prototypeOf(src, inputVar));
|
|
116106
|
+
const reader2 = readerRoles(prototypeOf(src, readerVar), input2);
|
|
116107
|
+
const readerMethods = {};
|
|
116108
|
+
for (const [n, r] of reader2) readerMethods[n] = r;
|
|
116109
|
+
const found = new Set(reader2.values());
|
|
116110
|
+
if (!REQUIRED_READER_ROLES.every((r) => found.has(r))) return null;
|
|
116111
|
+
const roleOf = (n) => reader2.get(n);
|
|
116112
|
+
const typeOf2 = (n) => typeNameOf.get(n);
|
|
116113
|
+
const canon = (fn) => canonicalize(fn, roleOf, typeOf2);
|
|
116114
|
+
const statics = {};
|
|
116115
|
+
const put = (cls, name, role) => {
|
|
116116
|
+
(statics[cls] ??= {})[name] = role;
|
|
116117
|
+
};
|
|
116118
|
+
const utility = varOf.get(UTILITY_TYPE);
|
|
116119
|
+
const utilityStatics = utility ? staticsOf(src, utility) : /* @__PURE__ */ new Map();
|
|
116120
|
+
const utilityRole = (name) => {
|
|
116121
|
+
const fn = utilityStatics.get(name);
|
|
116122
|
+
if (!fn) return void 0;
|
|
116123
|
+
if (/@raw \( 16 \)/.test(canon(fn)) || /\(16\)/.test(fn)) return "guid";
|
|
116124
|
+
if (canon(fn).includes("@float64")) return "date";
|
|
116125
|
+
return void 0;
|
|
116126
|
+
};
|
|
116127
|
+
for (const [name, fn] of staticsOf(src, serializer)) {
|
|
116128
|
+
const c = canon(fn);
|
|
116129
|
+
const role = SERIALIZER_TEMPLATES[c];
|
|
116130
|
+
if (role) put(serializer, name, role);
|
|
116131
|
+
else if (COLLECTION_LIST.test(c)) put(serializer, name, "list");
|
|
116132
|
+
else if (c === UTILITY_CALL) {
|
|
116133
|
+
const callee = /return [\w$]+\.([\w$]+)\(/.exec(fn)?.[1];
|
|
116134
|
+
const r = callee ? utilityRole(callee) : void 0;
|
|
116135
|
+
if (r) put(serializer, name, r);
|
|
115747
116136
|
}
|
|
115748
|
-
return n;
|
|
115749
116137
|
}
|
|
115750
|
-
|
|
115751
|
-
|
|
115752
|
-
|
|
115753
|
-
|
|
115754
|
-
|
|
115755
|
-
`count ${n} at offset ${at2} of items that take no bytes (at most ${MAX_EMPTY_ITEMS})`
|
|
115756
|
-
);
|
|
116138
|
+
const roles = new Set(Object.values(statics[serializer] ?? {}));
|
|
116139
|
+
if (!REQUIRED_STATIC_ROLES.every((r) => roles.has(r))) return null;
|
|
116140
|
+
if (utility) {
|
|
116141
|
+
for (const [name, fn] of utilityStatics) {
|
|
116142
|
+
if (fn.includes(UTILITY_IDENTITY_MARK) || UTILITY_TRY_GET.test(canon(fn))) put(utility, name, "identity");
|
|
115757
116143
|
}
|
|
115758
116144
|
}
|
|
115759
|
-
|
|
115760
|
-
|
|
115761
|
-
const
|
|
115762
|
-
if (n === null) return null;
|
|
115763
|
-
const out = [];
|
|
115764
|
-
for (let i2 = 0; i2 < n; i2++) {
|
|
115765
|
-
const before = this.pos;
|
|
115766
|
-
out.push(readItem(this));
|
|
115767
|
-
this.checkItemSize(n, before, at2);
|
|
115768
|
-
}
|
|
115769
|
-
return out;
|
|
116145
|
+
const pump = varOf.get(PUMP_TYPE);
|
|
116146
|
+
if (pump) {
|
|
116147
|
+
for (const [name, fn] of staticsOf(src, pump)) if (canon(fn) === IDENTITY) put(pump, name, "identity");
|
|
115770
116148
|
}
|
|
115771
|
-
|
|
115772
|
-
|
|
115773
|
-
const
|
|
115774
|
-
|
|
115775
|
-
|
|
115776
|
-
|
|
115777
|
-
|
|
115778
|
-
|
|
115779
|
-
|
|
115780
|
-
this.checkItemSize(n, before, at2);
|
|
116149
|
+
const enumerable = varOf.get(ENUMERABLE_TYPE);
|
|
116150
|
+
if (enumerable) {
|
|
116151
|
+
for (const [name, fn] of staticsOf(src, enumerable)) {
|
|
116152
|
+
if (name === "Range") put(enumerable, name, "range");
|
|
116153
|
+
else {
|
|
116154
|
+
const c = canon(fn);
|
|
116155
|
+
if (c === SELECT) put(enumerable, name, "select");
|
|
116156
|
+
else if (c === TO_ARRAY) put(enumerable, name, "toArray");
|
|
116157
|
+
}
|
|
115781
116158
|
}
|
|
115782
|
-
return out;
|
|
115783
|
-
}
|
|
115784
|
-
};
|
|
115785
|
-
function writeHeader(w, h) {
|
|
115786
|
-
w.uint16(h.version & 32767 | (h.reply ? REPLY_FLAG : 0)).int32(PREAMBLE).int32(h.msgNum).int32(h.method);
|
|
115787
|
-
}
|
|
115788
|
-
function readHeader(r) {
|
|
115789
|
-
const flags = r.uint16();
|
|
115790
|
-
const preamble = r.int32();
|
|
115791
|
-
if (preamble !== PREAMBLE) {
|
|
115792
|
-
throw new ProtocolError3("bad-preamble", `bad preamble ${preamble} (expected ${PREAMBLE})`);
|
|
115793
|
-
}
|
|
115794
|
-
return { version: flags & 32767, reply: (flags & REPLY_FLAG) !== 0, msgNum: r.int32(), method: r.int32() };
|
|
115795
|
-
}
|
|
115796
|
-
var writeIntStringDict = (w, d) => {
|
|
115797
|
-
if (d === null) {
|
|
115798
|
-
w.bool(false);
|
|
115799
|
-
return;
|
|
115800
|
-
}
|
|
115801
|
-
w.bool(true).dict(
|
|
115802
|
-
d,
|
|
115803
|
-
(ww, k) => ww.int32(k),
|
|
115804
|
-
(ww, v) => ww.string(v)
|
|
115805
|
-
);
|
|
115806
|
-
};
|
|
115807
|
-
var readIntStringDict = (r) => r.bool() ? r.dict(
|
|
115808
|
-
(rr) => rr.int32(),
|
|
115809
|
-
(rr) => rr.string()
|
|
115810
|
-
) : null;
|
|
115811
|
-
function writeExtrasUp(w, e) {
|
|
115812
|
-
writeIntStringDict(w, e.dict);
|
|
115813
|
-
w.string(e.client).int32(e.serverInfoVersionA).int32(e.serverInfoVersionB).date(e.fDb).date(e.kFa).int32(e.platform);
|
|
115814
|
-
}
|
|
115815
|
-
function readExtrasUp(r) {
|
|
115816
|
-
const dict = readIntStringDict(r);
|
|
115817
|
-
return {
|
|
115818
|
-
dict: dict === null ? null : new Map([...dict].map(([k, v]) => [k, v ?? ""])),
|
|
115819
|
-
client: r.string(),
|
|
115820
|
-
serverInfoVersionA: r.int32(),
|
|
115821
|
-
serverInfoVersionB: r.int32(),
|
|
115822
|
-
fDb: r.date(),
|
|
115823
|
-
kFa: r.date(),
|
|
115824
|
-
platform: r.int32()
|
|
115825
|
-
};
|
|
115826
|
-
}
|
|
115827
|
-
function optional4(r, read) {
|
|
115828
|
-
return r.bool() ? read(r) : null;
|
|
115829
|
-
}
|
|
115830
|
-
function readExtrasDown(r) {
|
|
115831
|
-
return {
|
|
115832
|
-
cAa: readIntStringDict(r),
|
|
115833
|
-
wca: optional4(r, (rr) => rr.int32()),
|
|
115834
|
-
c2a: r.string(),
|
|
115835
|
-
serverInfo: optional4(r, (rr) => ({
|
|
115836
|
-
okb: rr.string(),
|
|
115837
|
-
lbFlags: rr.string(),
|
|
115838
|
-
serverInfoVersionA: rr.int32(),
|
|
115839
|
-
livestream: optional4(rr, (l) => ({
|
|
115840
|
-
j7: l.string(),
|
|
115841
|
-
jdb: l.int32(),
|
|
115842
|
-
lr: l.date(),
|
|
115843
|
-
zfd: l.string(),
|
|
115844
|
-
yfd: l.string()
|
|
115845
|
-
})),
|
|
115846
|
-
serverInfoVersionB: rr.int32()
|
|
115847
|
-
})),
|
|
115848
|
-
j9: optional4(
|
|
115849
|
-
r,
|
|
115850
|
-
(rr) => rr.dict(
|
|
115851
|
-
(k) => k.int32(),
|
|
115852
|
-
(v) => optional4(v, (vv) => vv.list((s) => s.string()))
|
|
115853
|
-
)
|
|
115854
|
-
),
|
|
115855
|
-
unreadMail: optional4(r, (rr) => ({ cYa: rr.bool(), kFa: rr.date(), h9: rr.bool() }))
|
|
115856
|
-
};
|
|
115857
|
-
}
|
|
115858
|
-
var AUTH_TAG = 4;
|
|
115859
|
-
function encodeRequest(frame) {
|
|
115860
|
-
const w = new Writer();
|
|
115861
|
-
writeHeader(w, {
|
|
115862
|
-
version: frame.version ?? PROTOCOL_VERSION,
|
|
115863
|
-
reply: false,
|
|
115864
|
-
msgNum: frame.msgNum,
|
|
115865
|
-
method: frame.method
|
|
115866
|
-
});
|
|
115867
|
-
writeExtrasUp(w, frame.extras);
|
|
115868
|
-
if (frame.email !== null) w.bool(true).u8(AUTH_TAG).string(frame.email);
|
|
115869
|
-
frame.params?.(w);
|
|
115870
|
-
return w.bytes();
|
|
115871
|
-
}
|
|
115872
|
-
function decodeReplyEnvelope(bytes) {
|
|
115873
|
-
const r = new Reader(bytes);
|
|
115874
|
-
const header = readHeader(r);
|
|
115875
|
-
if (!header.reply) throw new ProtocolError3("not-a-reply", `frame for method ${header.method} is not a reply`);
|
|
115876
|
-
const env = { version: header.version, method: header.method, msgNum: header.msgNum, body: r };
|
|
115877
|
-
if (r.u8() === EXTRAS_PRESENT) env.extrasDown = readExtrasDown(r);
|
|
115878
|
-
if (r.u8() === ERROR_KIND) env.error = { code: r.int32(), message: r.string() };
|
|
115879
|
-
return env;
|
|
115880
|
-
}
|
|
115881
|
-
function toHex(bytes) {
|
|
115882
|
-
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("").toUpperCase();
|
|
115883
|
-
}
|
|
115884
|
-
function fromHex(hex3) {
|
|
115885
|
-
const clean2 = hex3.trim();
|
|
115886
|
-
if (clean2.length % 2 !== 0 || !/^[0-9a-fA-F]*$/.test(clean2)) {
|
|
115887
|
-
throw new ProtocolError3("bad-length", "not an even-length hex string");
|
|
115888
116159
|
}
|
|
115889
|
-
const
|
|
115890
|
-
|
|
115891
|
-
return out;
|
|
116160
|
+
const wrappers = WRAPPER_TYPES.map((t) => varOf.get(t)).filter((v) => v !== void 0);
|
|
116161
|
+
return { readerMethods, statics, wrappers, serializer, protocol: bundleProtocol(src) };
|
|
115892
116162
|
}
|
|
115893
116163
|
|
|
115894
116164
|
// src/protocol/interp.ts
|
|
@@ -115956,61 +116226,100 @@ function list2(r, item) {
|
|
|
115956
116226
|
const f = callback(item);
|
|
115957
116227
|
return asReader(r).list(() => f());
|
|
115958
116228
|
}
|
|
115959
|
-
var
|
|
116229
|
+
var READER_NATIVES = {
|
|
116230
|
+
bool: (r) => r.bool(),
|
|
116231
|
+
int32: (r) => r.int32(),
|
|
116232
|
+
u8: (r) => r.u8(),
|
|
116233
|
+
string: (r) => strBody(r),
|
|
116234
|
+
// The client's 8-byte read is a float64 (its two int32 halves reassembled as a double), not an
|
|
116235
|
+
// int64: kill rates, luck and TimeSpans (milliseconds) all arrive through it.
|
|
116236
|
+
float64: (r) => r.float64(),
|
|
116237
|
+
float32: (r) => r.float32(),
|
|
116238
|
+
uint16: (r) => r.uint16(),
|
|
116239
|
+
int16: (r) => r.int16(),
|
|
116240
|
+
raw: (r, n) => {
|
|
116241
|
+
if (typeof n !== "number" || !Number.isInteger(n) || n < 0) throw new InterpError("bad-value", `bad byte count ${String(n)}`);
|
|
116242
|
+
return r.raw(n);
|
|
116243
|
+
},
|
|
116244
|
+
varint: (r) => r.varint()
|
|
116245
|
+
};
|
|
116246
|
+
var STATIC_NATIVES = {
|
|
116247
|
+
int32: (r) => asReader(r).int32(),
|
|
116248
|
+
string: (r) => asReader(r).string(),
|
|
116249
|
+
bool: (r) => asReader(r).bool(),
|
|
116250
|
+
u8: (r) => asReader(r).u8(),
|
|
116251
|
+
float32: (r) => asReader(r).float32(),
|
|
116252
|
+
float64: (r) => asReader(r).float64(),
|
|
116253
|
+
timespan: (r) => asReader(r).float64(),
|
|
116254
|
+
date: (r) => asReader(r).date(),
|
|
116255
|
+
guid: (r) => asReader(r).guid(),
|
|
116256
|
+
uint16: (r) => asReader(r).uint16(),
|
|
116257
|
+
bytes: (r) => readBytes(asReader(r)),
|
|
116258
|
+
list: list2,
|
|
116259
|
+
dict: (r, k, v) => {
|
|
116260
|
+
const fk = callback(k);
|
|
116261
|
+
const fv = callback(v);
|
|
116262
|
+
return asReader(r).list(() => [fk(), fv()]);
|
|
116263
|
+
},
|
|
116264
|
+
identity: (x) => x,
|
|
116265
|
+
// Enumerable helpers (special-unit lists): Range → Select → ToArray.
|
|
116266
|
+
range,
|
|
116267
|
+
select: (xs, f) => {
|
|
116268
|
+
const fn = callback(f);
|
|
116269
|
+
return asArray(xs).map((x) => fn(x));
|
|
116270
|
+
},
|
|
116271
|
+
toArray: (xs) => [...asArray(xs)]
|
|
116272
|
+
};
|
|
116273
|
+
function dialectFrom(names2) {
|
|
116274
|
+
const readerMethods = {};
|
|
116275
|
+
for (const [n, role] of Object.entries(names2.readerMethods)) readerMethods[n] = READER_NATIVES[role];
|
|
116276
|
+
const statics = {};
|
|
116277
|
+
for (const [cls, fns] of Object.entries(names2.statics)) {
|
|
116278
|
+
statics[cls] = {};
|
|
116279
|
+
for (const [n, role] of Object.entries(fns)) statics[cls][n] = STATIC_NATIVES[role];
|
|
116280
|
+
}
|
|
116281
|
+
return { readerMethods, statics, wrappers: [...names2.wrappers] };
|
|
116282
|
+
}
|
|
116283
|
+
var V607_NAMES = {
|
|
115960
116284
|
readerMethods: {
|
|
115961
|
-
Ua:
|
|
115962
|
-
Og:
|
|
115963
|
-
bc:
|
|
115964
|
-
FJ:
|
|
115965
|
-
|
|
115966
|
-
|
|
115967
|
-
|
|
115968
|
-
|
|
115969
|
-
|
|
115970
|
-
|
|
115971
|
-
|
|
115972
|
-
JS: (r, n) => {
|
|
115973
|
-
if (typeof n !== "number" || !Number.isInteger(n) || n < 0) throw new InterpError("bad-value", `bad byte count ${String(n)}`);
|
|
115974
|
-
return r.raw(n);
|
|
115975
|
-
},
|
|
115976
|
-
I3c: (r) => r.varint()
|
|
116285
|
+
Ua: "bool",
|
|
116286
|
+
Og: "int32",
|
|
116287
|
+
bc: "u8",
|
|
116288
|
+
FJ: "string",
|
|
116289
|
+
E3a: "float64",
|
|
116290
|
+
Om: "float32",
|
|
116291
|
+
NGb: "uint16",
|
|
116292
|
+
S3c: "int16",
|
|
116293
|
+
MGb: "u8",
|
|
116294
|
+
JS: "raw",
|
|
116295
|
+
I3c: "varint"
|
|
115977
116296
|
},
|
|
115978
116297
|
statics: {
|
|
115979
116298
|
P: {
|
|
115980
|
-
Ya:
|
|
115981
|
-
wc:
|
|
115982
|
-
Yc:
|
|
115983
|
-
uq:
|
|
115984
|
-
Ao:
|
|
115985
|
-
ak:
|
|
115986
|
-
uy:
|
|
115987
|
-
Td:
|
|
115988
|
-
tL:
|
|
115989
|
-
Z5:
|
|
115990
|
-
sL:
|
|
115991
|
-
Sd:
|
|
115992
|
-
ms:
|
|
115993
|
-
uL:
|
|
115994
|
-
ef:
|
|
115995
|
-
const fk = callback(k);
|
|
115996
|
-
const fv = callback(v);
|
|
115997
|
-
return asReader(r).list(() => [fk(), fv()]);
|
|
115998
|
-
}
|
|
116299
|
+
Ya: "int32",
|
|
116300
|
+
wc: "string",
|
|
116301
|
+
Yc: "bool",
|
|
116302
|
+
uq: "u8",
|
|
116303
|
+
Ao: "float32",
|
|
116304
|
+
ak: "float64",
|
|
116305
|
+
uy: "timespan",
|
|
116306
|
+
Td: "date",
|
|
116307
|
+
tL: "guid",
|
|
116308
|
+
Z5: "uint16",
|
|
116309
|
+
sL: "bytes",
|
|
116310
|
+
Sd: "list",
|
|
116311
|
+
ms: "list",
|
|
116312
|
+
uL: "list",
|
|
116313
|
+
ef: "dict"
|
|
115999
116314
|
},
|
|
116000
|
-
O: { fA:
|
|
116001
|
-
za: { rc:
|
|
116002
|
-
|
|
116003
|
-
E: {
|
|
116004
|
-
Range: range,
|
|
116005
|
-
Za: (xs, f) => {
|
|
116006
|
-
const fn = callback(f);
|
|
116007
|
-
return asArray(xs).map((x) => fn(x));
|
|
116008
|
-
},
|
|
116009
|
-
Sa: (xs) => [...asArray(xs)]
|
|
116010
|
-
}
|
|
116315
|
+
O: { fA: "identity", Fy: "identity", rc: "identity" },
|
|
116316
|
+
za: { rc: "identity" },
|
|
116317
|
+
E: { Range: "range", Za: "select", Sa: "toArray" }
|
|
116011
116318
|
},
|
|
116012
116319
|
wrappers: ["Z", "Yb", "uc", "dc", "oc", "ec", "fc"]
|
|
116013
116320
|
};
|
|
116321
|
+
var DEFAULT_DIALECT = dialectFrom(V607_NAMES);
|
|
116322
|
+
var REQUIRED_ROLES = ["int32", "bool", "u8"];
|
|
116014
116323
|
var READER_HELPERS = "P";
|
|
116015
116324
|
var REQUIRED_HELPERS = ["Ya", "Yc", "uq"];
|
|
116016
116325
|
var MAX_LITERAL_SITES = 16;
|
|
@@ -116179,18 +116488,39 @@ var BundleInterpreter = class {
|
|
|
116179
116488
|
this.maxDepth = opts.maxDepth ?? DEFAULT_MAX_DEPTH;
|
|
116180
116489
|
this.maxMillis = opts.maxMillis ?? DEFAULT_MAX_MILLIS;
|
|
116181
116490
|
this.now = opts.now ?? (() => performance.now());
|
|
116182
|
-
const
|
|
116183
|
-
|
|
116184
|
-
|
|
116185
|
-
|
|
116186
|
-
|
|
116187
|
-
|
|
116491
|
+
const derived2 = opts.dialect ? null : deriveDialect(bundle);
|
|
116492
|
+
if (derived2) {
|
|
116493
|
+
this.dialect = dialectFrom(derived2);
|
|
116494
|
+
this.helperClass = derived2.serializer;
|
|
116495
|
+
const helpers = derived2.statics[derived2.serializer] ?? {};
|
|
116496
|
+
this.requiredHelpers = Object.keys(helpers).filter((n) => REQUIRED_ROLES.includes(helpers[n])).sort();
|
|
116497
|
+
this.derived = true;
|
|
116498
|
+
} else {
|
|
116499
|
+
const d = opts.dialect ?? {};
|
|
116500
|
+
this.dialect = {
|
|
116501
|
+
readerMethods: { ...DEFAULT_DIALECT.readerMethods, ...d.readerMethods },
|
|
116502
|
+
statics: { ...DEFAULT_DIALECT.statics, ...d.statics },
|
|
116503
|
+
wrappers: d.wrappers ?? DEFAULT_DIALECT.wrappers
|
|
116504
|
+
};
|
|
116505
|
+
this.helperClass = READER_HELPERS;
|
|
116506
|
+
this.requiredHelpers = REQUIRED_HELPERS;
|
|
116507
|
+
this.derived = false;
|
|
116508
|
+
}
|
|
116509
|
+
this.bundleProtocol = derived2 ? derived2.protocol : bundleProtocol(bundle.src);
|
|
116188
116510
|
this.wrappers = new Set(this.dialect.wrappers);
|
|
116189
116511
|
}
|
|
116190
116512
|
bundle;
|
|
116191
116513
|
opts;
|
|
116192
116514
|
version;
|
|
116193
116515
|
dialect;
|
|
116516
|
+
/** The class whose statics are the reader helpers `verifyDialect` checks (the Serializer). */
|
|
116517
|
+
helperClass;
|
|
116518
|
+
/** The reader helpers that must verify for the bundle to load (int32, bool and byte, by role). */
|
|
116519
|
+
requiredHelpers;
|
|
116520
|
+
/** The dialect was derived from this bundle (false: the built-in v6.07 names). */
|
|
116521
|
+
derived;
|
|
116522
|
+
/** The protocol version the bundle's readers default to, when clear (`null==d&&(d=243)`). */
|
|
116523
|
+
bundleProtocol;
|
|
116194
116524
|
wrappers;
|
|
116195
116525
|
/** Resolved functions by `Cls.fn` / `new Cls`: a hit, `null` (no constructor) or the cached failure. */
|
|
116196
116526
|
fnCache = /* @__PURE__ */ new Map();
|
|
@@ -116267,13 +116597,13 @@ var BundleInterpreter = class {
|
|
|
116267
116597
|
verifyDialect() {
|
|
116268
116598
|
const out = { verified: [], unverified: [], mismatched: [] };
|
|
116269
116599
|
const reasons = {};
|
|
116270
|
-
const natives = Object.hasOwn(this.dialect.statics,
|
|
116600
|
+
const natives = Object.hasOwn(this.dialect.statics, this.helperClass) ? this.dialect.statics[this.helperClass] : {};
|
|
116271
116601
|
const budget = { spent: 0 };
|
|
116272
|
-
const forms = this.helperForms(
|
|
116273
|
-
const order = [...forms.keys()].sort((a, b) => Number(
|
|
116602
|
+
const forms = this.helperForms(this.helperClass, Object.keys(natives), budget);
|
|
116603
|
+
const order = [...forms.keys()].sort((a, b) => Number(this.requiredHelpers.includes(b)) - Number(this.requiredHelpers.includes(a)) || (a < b ? -1 : 1));
|
|
116274
116604
|
for (const name of order) {
|
|
116275
116605
|
const native = natives[name];
|
|
116276
|
-
const key = `${
|
|
116606
|
+
const key = `${this.helperClass}.${name}`;
|
|
116277
116607
|
let mismatch = false;
|
|
116278
116608
|
let why;
|
|
116279
116609
|
for (const form of forms.get(name)) {
|
|
@@ -116307,12 +116637,12 @@ var BundleInterpreter = class {
|
|
|
116307
116637
|
}
|
|
116308
116638
|
}
|
|
116309
116639
|
const src = this.bundle.src;
|
|
116310
|
-
const
|
|
116311
|
-
for (const name of
|
|
116640
|
+
const esc3 = this.helperClass.replace(/\$/g, "\\$");
|
|
116641
|
+
for (const name of this.requiredHelpers) {
|
|
116312
116642
|
if (forms.has(name) || !Object.hasOwn(natives, name)) continue;
|
|
116313
|
-
const ref4 = new RegExp(`(?<![\\w$.])${
|
|
116643
|
+
const ref4 = new RegExp(`(?<![\\w$.])${esc3}\\s*(?:\\.\\s*${name}(?![\\w$])|\\[\\s*(["'\`])${name}\\1\\s*\\])`);
|
|
116314
116644
|
if (!ref4.test(src)) continue;
|
|
116315
|
-
const key = `${
|
|
116645
|
+
const key = `${this.helperClass}.${name}`;
|
|
116316
116646
|
out.unverified.push(key);
|
|
116317
116647
|
reasons[key] = "the bundle reads through it, but no definition was found in a form this check can follow";
|
|
116318
116648
|
}
|
|
@@ -116343,8 +116673,8 @@ var BundleInterpreter = class {
|
|
|
116343
116673
|
}
|
|
116344
116674
|
};
|
|
116345
116675
|
const src = this.bundle.src;
|
|
116346
|
-
const
|
|
116347
|
-
for (const m of src.matchAll(new RegExp(`(?<![\\w$.])${
|
|
116676
|
+
const esc3 = cls.replace(/\$/g, "\\$");
|
|
116677
|
+
for (const m of src.matchAll(new RegExp(`(?<![\\w$.])${esc3}\\.([\\w$]+)\\s*=(?!=)\\s*`, "g"))) {
|
|
116348
116678
|
const name = m[1];
|
|
116349
116679
|
if (!wanted.has(name)) continue;
|
|
116350
116680
|
const at2 = m.index + m[0].length;
|
|
@@ -116364,7 +116694,7 @@ var BundleInterpreter = class {
|
|
|
116364
116694
|
let litText = 0;
|
|
116365
116695
|
let litSites = 0;
|
|
116366
116696
|
let cutShort = false;
|
|
116367
|
-
for (const m of src.matchAll(new RegExp(`(?<![\\w$.])${
|
|
116697
|
+
for (const m of src.matchAll(new RegExp(`(?<![\\w$.])${esc3}\\s*=\\s*(?=\\{)`, "g"))) {
|
|
116368
116698
|
const room = this.maxSteps - litText;
|
|
116369
116699
|
if (litSites >= MAX_LITERAL_SITES || room <= 0) {
|
|
116370
116700
|
cutShort = true;
|
|
@@ -117329,6 +117659,14 @@ var WarappBundle = class {
|
|
|
117329
117659
|
constructor(src, version3, opts = {}) {
|
|
117330
117660
|
this.version = version3;
|
|
117331
117661
|
this.interp = new BundleInterpreter(parseBundle(src), opts);
|
|
117662
|
+
const protocol = this.interp.bundleProtocol;
|
|
117663
|
+
if (opts.version === void 0 && protocol !== void 0 && protocol !== PROTOCOL_VERSION) {
|
|
117664
|
+
throw new BundleError(
|
|
117665
|
+
"protocol-mismatch",
|
|
117666
|
+
`war.app's client bundle ${version3} speaks protocol ${protocol}, and this server speaks ${PROTOCOL_VERSION}; its readers would read the replies in the wrong layout, so it is not used. ` + (protocol > PROTOCOL_VERSION ? "The client changed and this server needs an update." : "It is an older client.")
|
|
117667
|
+
);
|
|
117668
|
+
}
|
|
117669
|
+
this.protocol = protocol;
|
|
117332
117670
|
this.dialectCheck = this.interp.verifyDialect();
|
|
117333
117671
|
if (this.dialectCheck.mismatched.length) {
|
|
117334
117672
|
throw new BundleError(
|
|
@@ -117336,7 +117674,7 @@ var WarappBundle = class {
|
|
|
117336
117674
|
`war.app's client bundle ${version3} reads ${this.dialectCheck.mismatched.join(", ")} differently from this server's built-in readers; the client changed and this server needs an update to read it.`
|
|
117337
117675
|
);
|
|
117338
117676
|
}
|
|
117339
|
-
const unverifiedRequired =
|
|
117677
|
+
const unverifiedRequired = this.interp.requiredHelpers.map((n) => `${this.interp.helperClass}.${n}`).filter(
|
|
117340
117678
|
(k) => this.dialectCheck.unverified.includes(k)
|
|
117341
117679
|
);
|
|
117342
117680
|
if (unverifiedRequired.length) {
|
|
@@ -117371,6 +117709,12 @@ var WarappBundle = class {
|
|
|
117371
117709
|
}
|
|
117372
117710
|
/** The built-in reader helpers checked against this bundle's own definitions at load. */
|
|
117373
117711
|
dialectCheck;
|
|
117712
|
+
/** The protocol version the bundle's readers default to, when it can be read from the bundle. */
|
|
117713
|
+
protocol;
|
|
117714
|
+
/** The reader names were derived from this bundle (false: the built-in v6.07 names). */
|
|
117715
|
+
get derivedDialect() {
|
|
117716
|
+
return this.interp.derived;
|
|
117717
|
+
}
|
|
117374
117718
|
/** What this bundle's decoding rests on, for the tools to show (#148). */
|
|
117375
117719
|
report() {
|
|
117376
117720
|
const { verified, unverified, reasons } = this.dialectCheck;
|
|
@@ -117403,8 +117747,8 @@ var WarappBundle = class {
|
|
|
117403
117747
|
}
|
|
117404
117748
|
};
|
|
117405
117749
|
var KNOWN_GOOD_BUNDLE = {
|
|
117406
|
-
version: "
|
|
117407
|
-
digest: "
|
|
117750
|
+
version: "639304508939095333",
|
|
117751
|
+
digest: "3c55e2d08681d05661eb350b3d72d02f25729130bb78dc9c5d3b1febd73febd1"
|
|
117408
117752
|
};
|
|
117409
117753
|
var bundleUrlOf = (version3) => `https://${BUNDLE_HOST}${BUNDLE_PATH}?v=${version3}`;
|
|
117410
117754
|
var BUNDLE_FILE = /^([A-Za-z0-9._-]{1,64})\.([0-9a-f]{64})\.js$/;
|
|
@@ -117499,7 +117843,7 @@ async function readVerified(file2, digest) {
|
|
|
117499
117843
|
await rm(file2, { force: true });
|
|
117500
117844
|
return null;
|
|
117501
117845
|
}
|
|
117502
|
-
var isDialectRefusal = (e) => e instanceof BundleError && (e.kind === "dialect-mismatch" || e.kind === "dialect-unverified");
|
|
117846
|
+
var isDialectRefusal = (e) => e instanceof BundleError && (e.kind === "dialect-mismatch" || e.kind === "dialect-unverified" || e.kind === "protocol-mismatch");
|
|
117503
117847
|
async function cacheBundle(dataDir2, dir, name, src) {
|
|
117504
117848
|
await ensurePrivateDir(dataDir2);
|
|
117505
117849
|
await ensurePrivateDir(dir);
|
|
@@ -117714,7 +118058,7 @@ var BundleProvider = class {
|
|
|
117714
118058
|
};
|
|
117715
118059
|
|
|
117716
118060
|
// src/protocol/rpc.ts
|
|
117717
|
-
var CLIENT_VERSION = "v6.
|
|
118061
|
+
var CLIENT_VERSION = "v6.08.0.2";
|
|
117718
118062
|
var PLATFORM_WEBSITE = 15;
|
|
117719
118063
|
var INITIAL_SERVER_INFO_A = 348;
|
|
117720
118064
|
var INITIAL_SERVER_INFO_B = 88732;
|
|
@@ -117752,8 +118096,8 @@ var ProtocolVersionError = class extends McpToolError {
|
|
|
117752
118096
|
name = "ProtocolVersionError";
|
|
117753
118097
|
};
|
|
117754
118098
|
var WarappServerError = class extends McpToolError {
|
|
117755
|
-
constructor(code2, message) {
|
|
117756
|
-
super(message, { kind: "unknown" });
|
|
118099
|
+
constructor(code2, message, hint) {
|
|
118100
|
+
super(message, { kind: "unknown", ...hint ? { hint } : {} });
|
|
117757
118101
|
this.code = code2;
|
|
117758
118102
|
}
|
|
117759
118103
|
code;
|
|
@@ -117872,7 +118216,20 @@ var WarappRpc = class {
|
|
|
117872
118216
|
if (down.unreadMail) this.state.kFa = down.unreadMail.kFa;
|
|
117873
118217
|
}
|
|
117874
118218
|
};
|
|
118219
|
+
var CLIENT_OUT_OF_DATE = 48;
|
|
118220
|
+
var CLIENT_VERSION_TOO_HIGH = 49;
|
|
118221
|
+
var ClientOutOfDateError = class extends WarappServerError {
|
|
118222
|
+
name = "ClientOutOfDateError";
|
|
118223
|
+
constructor(methodName, code2) {
|
|
118224
|
+
super(
|
|
118225
|
+
code2,
|
|
118226
|
+
code2 === CLIENT_OUT_OF_DATE ? `war.app refused ${methodName} as ClientOutOfDate (war.app error 48): it no longer accepts protocol ${PROTOCOL_VERSION}, the one this server speaks, so every war.app call through the web protocol will fail until this server is updated to war.app\u2019s current client.` : `war.app refused ${methodName} as ClientVersionTooHigh (war.app error 49): it does not know client ${CLIENT_VERSION}, the version this server sends.`,
|
|
118227
|
+
'This server needs an update to war.app\u2019s current client: see docs/CLIENT-RELEASES.md, "Updating to a new client". Retrying or signing in again will not help.'
|
|
118228
|
+
);
|
|
118229
|
+
}
|
|
118230
|
+
};
|
|
117875
118231
|
function serverError(methodName, code2, message, email4) {
|
|
118232
|
+
if (code2 === CLIENT_OUT_OF_DATE || code2 === CLIENT_VERSION_TOO_HIGH) return new ClientOutOfDateError(methodName, code2);
|
|
117876
118233
|
const known2 = SERVER_ERROR_MESSAGES[code2];
|
|
117877
118234
|
if (known2) return new WarappServerError(code2, `${known2} (war.app error ${code2})`);
|
|
117878
118235
|
let detail2 = (message ?? "").split(/\r?\n/, 1)[0].trim();
|
|
@@ -124961,7 +125318,7 @@ async function captureBearerHeader(opts) {
|
|
|
124961
125318
|
}
|
|
124962
125319
|
|
|
124963
125320
|
// src/version.ts
|
|
124964
|
-
var VERSION2 = "0.
|
|
125321
|
+
var VERSION2 = "0.5.0";
|
|
124965
125322
|
|
|
124966
125323
|
// src/transport-bridge.ts
|
|
124967
125324
|
var SERVER_NAME = "warapp-mcp";
|
|
@@ -126581,8 +126938,8 @@ function registerBoardTool(server, client, live) {
|
|
|
126581
126938
|
// src/chat.ts
|
|
126582
126939
|
var GAME_DETAILS_AND_CHAT = "warlight.shared.GameDetailsAndChat";
|
|
126583
126940
|
var GAME_MESSAGE = "warlight.shared.GameMessage";
|
|
126584
|
-
var GM = { date: 0, sender: 1, group: 2, id: 4,
|
|
126585
|
-
var GAME_MESSAGE_FIELDS =
|
|
126941
|
+
var GM = { date: 0, sender: 1, group: 2, id: 4, images: 5, text: 6, reactions: 7, channel: 8, to: 9, turn: 11 };
|
|
126942
|
+
var GAME_MESSAGE_FIELDS = 12;
|
|
126586
126943
|
var PUBLIC_CHANNEL = -1;
|
|
126587
126944
|
var CHAT_CHANNELS = ["public", "team", "private", "unknown"];
|
|
126588
126945
|
var isInt3 = (v) => typeof v === "number" && Number.isInteger(v);
|
|
@@ -126599,7 +126956,10 @@ function webLine(m) {
|
|
|
126599
126956
|
const channel = f[GM.channel];
|
|
126600
126957
|
const to = f[GM.to];
|
|
126601
126958
|
const turn = f[GM.turn];
|
|
126959
|
+
const images = f[GM.images];
|
|
126960
|
+
const reactions = f[GM.reactions];
|
|
126602
126961
|
if (!(date5 === null || date5 instanceof Date) || !optInt(sender) || !optInt(group) || !optInt(to) || !optInt(turn)) return void 0;
|
|
126962
|
+
if (!(images === null || Array.isArray(images)) || !(reactions === null || Array.isArray(reactions))) return void 0;
|
|
126603
126963
|
if (!(id === null || typeof id === "string" || isInt3(id)) || typeof text !== "string" || !isInt3(channel)) return void 0;
|
|
126604
126964
|
const line = { sender, text, turn, channel: "unknown" };
|
|
126605
126965
|
if (id !== null) line.id = String(id);
|
|
@@ -133276,7 +133636,7 @@ var GAME_WL = "warlight.shared.GameWL";
|
|
|
133276
133636
|
var GAME_PLAYER = "warlight.shared.GamePlayer";
|
|
133277
133637
|
var GAME_WL_FIELDS = 14;
|
|
133278
133638
|
var GW_PLAYERS = 7;
|
|
133279
|
-
var GAME_PLAYER_FIELDS =
|
|
133639
|
+
var GAME_PLAYER_FIELDS = 37;
|
|
133280
133640
|
var GPL = { aiId: 0, turnedAI: 14, id: 20, accepted: 21, state: 28, surrendered: 29 };
|
|
133281
133641
|
var seatPlaying = (s) => playerStateName(s.state) === "Playing";
|
|
133282
133642
|
var isInt9 = (v) => typeof v === "number" && Number.isInteger(v);
|
|
@@ -133343,7 +133703,7 @@ function pendingSurrenders(seats, me, feedIdOf = () => null) {
|
|
|
133343
133703
|
var surrenderOwed = (pending) => (pending ?? []).some((p) => p.owedByMe === true);
|
|
133344
133704
|
|
|
133345
133705
|
// src/tools/surrender-pending.ts
|
|
133346
|
-
var SURRENDER_PENDING_NOTE = "Read from the game details (the web client's GameRefresh), UNVERIFIED live: a list is what the details showed (empty: no surrender pending); null means they could not be read, not that none is pending. owedByMe true: the player is waiting for you to accept its surrender. Accepting is the owner's decision (it hands that player's land on and can end the game).";
|
|
133706
|
+
var SURRENDER_PENDING_NOTE = "Read from the game details (the web client's GameRefresh), UNVERIFIED live: a list is what the details showed (empty: no surrender pending); null means they could not be read, not that none is pending. A lobby, a finished game and a game you no longer play in are empty without a read (#327): no surrender there can wait on you. owedByMe true: the player is waiting for you to accept its surrender. Accepting is the owner's decision (it hands that player's land on and can end the game).";
|
|
133347
133707
|
var IN_PLAY = /* @__PURE__ */ new Set(["Playing", "DistributingTerritories"]);
|
|
133348
133708
|
function surrenderMayBePending(state, mySeatState) {
|
|
133349
133709
|
return IN_PLAY.has(state) && mySeatState === "Playing";
|
|
@@ -133364,7 +133724,8 @@ async function readDetailsSeats(ctx, gameId) {
|
|
|
133364
133724
|
}
|
|
133365
133725
|
}
|
|
133366
133726
|
async function readPendingSurrenders(ctx, game, me, read = (id) => readDetailsSeats(ctx, id)) {
|
|
133367
|
-
if (!me
|
|
133727
|
+
if (!me) return null;
|
|
133728
|
+
if (!surrenderMayBePending(game.state, me.state)) return [];
|
|
133368
133729
|
const seats = await read(game.id);
|
|
133369
133730
|
if (!seats) return null;
|
|
133370
133731
|
const byInGame = /* @__PURE__ */ new Map();
|
|
@@ -139425,6 +139786,7 @@ async function myGamesSurrenders(ctx, games, me) {
|
|
|
139425
139786
|
const mine2 = g.players.find((p) => p.id === me);
|
|
139426
139787
|
return surrenderMayBePending(gameStateName(g.stateCode), mine2 ? playerStateName(mine2.stateCode) : void 0);
|
|
139427
139788
|
});
|
|
139789
|
+
for (const g of games) if (!eligible.includes(g)) byGame.set(g.id, []);
|
|
139428
139790
|
const read = eligible.slice(0, MAX_SURRENDER_READS);
|
|
139429
139791
|
for (let i2 = 0; i2 < read.length; i2 += SURRENDER_READ_BATCH) {
|
|
139430
139792
|
const batch = read.slice(i2, i2 + SURRENDER_READ_BATCH);
|
|
@@ -139450,7 +139812,7 @@ function registerMyGamesTool(server, ctx, deps = {}) {
|
|
|
139450
139812
|
{
|
|
139451
139813
|
title: "List my war.app games and which need me",
|
|
139452
139814
|
description: untrustedDescription(
|
|
139453
|
-
`Your war.app (Warzone) games, games waiting on you first: each with its id, name, state (WaitingForPlayers, DistributingTerritories, Playing, Finished), turn, players (name, state, whether they have committed this turn) and waitingOnYou \u2014 true when the game is being played or distributing territories, you are still playing, and you have not committed \u2014 and surrenderPending: the surrenders other players asked for that are still pending, each with owedByMe (true: waiting for you to accept it), read from the game details (unverified live; null when not read or unreadable, never "none"); the top-level surrenderPending counts the games where one waits on you, and those games come first too. Finished games are left out unless \`include_finished\` (\`finishedLeftOut\` counts them). \`listed\` is how many games war.app returned and \`complete\` false (with a \`warning\`) means the list may be partial. Use the id with the other warapp tools. Each call also gives up to two of your newest 250 finished games not yet processed their end-of-game pass (\`endOfGame\`: each game's history read once from GameFeed and kept name-free for later games; \`pending\` counts the rest). ${BRIDGE_NOTE} Read-only.`
|
|
139815
|
+
`Your war.app (Warzone) games, games waiting on you first: each with its id, name, state (WaitingForPlayers, DistributingTerritories, Playing, Finished), turn, players (name, state, whether they have committed this turn) and waitingOnYou \u2014 true when the game is being played or distributing territories, you are still playing, and you have not committed \u2014 and surrenderPending: the surrenders other players asked for that are still pending, each with owedByMe (true: waiting for you to accept it), read from the game details (unverified live; null when not read or unreadable, never "none"; empty without a read for a lobby, a finished game or a game you no longer play in, where none can wait on you); the top-level surrenderPending counts the games where one waits on you, and those games come first too. Finished games are left out unless \`include_finished\` (\`finishedLeftOut\` counts them). \`listed\` is how many games war.app returned and \`complete\` false (with a \`warning\`) means the list may be partial. Use the id with the other warapp tools. Each call also gives up to two of your newest 250 finished games not yet processed their end-of-game pass (\`endOfGame\`: each game's history read once from GameFeed and kept name-free for later games; \`pending\` counts the rest). ${BRIDGE_NOTE} Read-only.`
|
|
139454
139816
|
),
|
|
139455
139817
|
_meta: canonicalMeta("whats-new", ["my games", "warzone", "whose turn", "games waiting on me", "which games need me"]),
|
|
139456
139818
|
annotations: readAnnotations("List my war.app games"),
|
|
@@ -140982,6 +141344,11 @@ function registerChatTools(server, ctx, opts = {}) {
|
|
|
140982
141344
|
}
|
|
140983
141345
|
|
|
140984
141346
|
// src/tools/chat-inbox.ts
|
|
141347
|
+
var FINISHED_CLEAR_WINDOW = 3;
|
|
141348
|
+
function recentClearFinished(games) {
|
|
141349
|
+
const listed = new Set(chatGameIds(games));
|
|
141350
|
+
return games.filter((g) => g.stateCode === GAME_FINISHED && !listed.has(g.id)).map((g) => g.id).sort((a, b) => b - a).slice(0, FINISHED_CLEAR_WINDOW).sort((a, b) => a - b);
|
|
141351
|
+
}
|
|
140985
141352
|
var MAX_INBOX_GAMES = 10;
|
|
140986
141353
|
var MAX_INBOX_GAME_IDS = 100;
|
|
140987
141354
|
var DEFAULT_INBOX_LIMIT = 20;
|
|
@@ -141017,7 +141384,10 @@ function registerChatInboxTool(server, ctx) {
|
|
|
141017
141384
|
const list3 = given2 ? void 0 : await fetchMyGames(ctx);
|
|
141018
141385
|
const me = await chatMe(ctx);
|
|
141019
141386
|
const after = cursor === void 0 ? void 0 : Number(cursor);
|
|
141020
|
-
const
|
|
141387
|
+
const clearFinished = list3 ? recentClearFinished(list3.games) : [];
|
|
141388
|
+
const ids2 = (given2 ?? [...chatGameIds(list3.games), ...clearFinished].sort((a, b) => a - b)).filter(
|
|
141389
|
+
(id) => after === void 0 || id > after
|
|
141390
|
+
);
|
|
141021
141391
|
const batch = ids2.slice(0, max_games ?? MAX_INBOX_GAMES);
|
|
141022
141392
|
const n = limit ?? DEFAULT_INBOX_LIMIT;
|
|
141023
141393
|
const channels = [...CHAT_CHANNELS];
|
|
@@ -141044,9 +141414,12 @@ function registerChatInboxTool(server, ctx) {
|
|
|
141044
141414
|
}
|
|
141045
141415
|
sources.add(read.source);
|
|
141046
141416
|
const messages = fresh_.slice(-n).map((l) => shown(l, true, game.players, byInGame, me));
|
|
141417
|
+
const name = game.name === void 0 ? null : untrustedText(game.name);
|
|
141047
141418
|
withNew.push({
|
|
141419
|
+
// #322/#323: the game as warapp_get_chat nests it; the top-level keys stay for existing callers.
|
|
141420
|
+
game: { id: game.id, name, state: game.state },
|
|
141048
141421
|
id: game.id,
|
|
141049
|
-
name
|
|
141422
|
+
name,
|
|
141050
141423
|
state: game.state,
|
|
141051
141424
|
source: read.source,
|
|
141052
141425
|
...feedFillFields(read),
|
|
@@ -141080,6 +141453,10 @@ function registerChatInboxTool(server, ctx) {
|
|
|
141080
141453
|
finishedUnflagged: unflagged,
|
|
141081
141454
|
finishedNote: `${unflagged} finished game(s) in your list carry unread-chat flags this server could not read, so they are read like the rest rather than left out (the flags are not yet verified against war.app).`
|
|
141082
141455
|
} : {},
|
|
141456
|
+
...clearFinished.length ? {
|
|
141457
|
+
finishedClearChecked: clearFinished.length,
|
|
141458
|
+
finishedClearNote: `${clearFinished.length} recent finished game(s) are read although war.app's unread flag for their chat is clear: a message GameFeed alone holds (a surrender line, say) leaves that flag clear (#322). Only the ${FINISHED_CLEAR_WINDOW} newest finished games are read so; older ones go by the flag.`
|
|
141459
|
+
} : {},
|
|
141083
141460
|
...sources.size ? { sourceNotes: Object.fromEntries([...sources].map((s) => [s, CHAT_SOURCE_NOTES[s]])) } : {}
|
|
141084
141461
|
}));
|
|
141085
141462
|
}
|
|
@@ -141131,7 +141508,7 @@ function registerMarkChatReadTool(server, ctx) {
|
|
|
141131
141508
|
if (!read || read.source === "gamefeed") {
|
|
141132
141509
|
refuse(
|
|
141133
141510
|
`The chat of game ${game.id} could be read only from GameFeed, which gives no message ids, so nothing was sent.`,
|
|
141134
|
-
"
|
|
141511
|
+
"A message read from GameFeed carries no id, so war.app has nothing to mark for it. Read the game with warapp_get_chat: if its `source` is `web`, those messages can be marked; if it stays `gamefeed`, the web read failed or the signed-in account could not be read, and marking waits until it reads."
|
|
141135
141512
|
);
|
|
141136
141513
|
}
|
|
141137
141514
|
if (read.feedFill?.web === 0) {
|
|
@@ -143971,7 +144348,7 @@ function registerPushTools(server, ctx, push, deps = {}) {
|
|
|
143971
144348
|
{
|
|
143972
144349
|
title: "Wait for my turn in war.app games",
|
|
143973
144350
|
description: untrustedDescription(
|
|
143974
|
-
"Wait until one of the given war.app (Warzone) games is waiting on you \u2014 the game is being played or its territories picked, you are still playing, and you have not committed \u2014 and return as soon as it is, or at the timeout (default 300 s, max 1800 s) \u2014 or at once with `game_over` when every game has finished or your seat is out (each says why in `ended`). It checks each game once at the start, then listens to war.app's push notifications \u2014 over a direct WebSocket while a linked war.app session serves calls, else through your signed-in war.app tab (ContextMint Bridge) \u2014 and re-checks a game whenever war.app says it changed, and every game after the push socket reconnects. It also returns (status `surrender_pending`) when another player's surrender waits for you to accept it (each game's `surrenderPending`, read from the game details, unverified live: null when unreadable, never \"none\"; after one failed read it stops asking for the rest of the wait and says why in `surrenderUnread`), unless `ignore_surrenders`. Pass the game ids to watch (1\u201320), or omit them to watch every game of yours being played or picked (the first 20, as warapp_my_games lists them). Reports progress while it waits and stops when the call is cancelled. Then plan with warapp_plan_turn (or pick with warapp_submit_picks). Read-only."
|
|
144351
|
+
"Wait until one of the given war.app (Warzone) games is waiting on you \u2014 the game is being played or its territories picked, you are still playing, and you have not committed \u2014 and return as soon as it is, or at the timeout (default 300 s, max 1800 s) \u2014 or at once with `game_over` when every game has finished or your seat is out (each says why in `ended`). It checks each game once at the start, then listens to war.app's push notifications \u2014 over a direct WebSocket while a linked war.app session serves calls, else through your signed-in war.app tab (ContextMint Bridge) \u2014 and re-checks a game whenever war.app says it changed, and every game after the push socket reconnects. It also returns (status `surrender_pending`) when another player's surrender waits for you to accept it (each game's `surrenderPending`, read from the game details, unverified live: null when unreadable, never \"none\"; empty without a read for a lobby, a finished game or one you no longer play in; after one failed read it stops asking for the rest of the wait and says why in `surrenderUnread`), unless `ignore_surrenders`. Pass the game ids to watch (1\u201320), or omit them to watch every game of yours being played or picked (the first 20, as warapp_my_games lists them). Reports progress while it waits and stops when the call is cancelled. Then plan with warapp_plan_turn (or pick with warapp_submit_picks). Read-only."
|
|
143975
144352
|
),
|
|
143976
144353
|
_meta: mintMeta("whats-new", ["is it my turn", "wait for my turn", "tell me when it is my turn", "warzone turn ready"]),
|
|
143977
144354
|
annotations: readAnnotations("Wait for my war.app turn"),
|