ygopro-msg-encode 1.1.6 → 1.1.7
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/dist/index.cjs +22 -50
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +2 -5
- package/dist/index.mjs +24 -49
- package/dist/index.mjs.map +3 -3
- package/dist/src/proto-base/index.d.ts +3 -0
- package/dist/src/proto-base/ygopro-proto-base.d.ts +19 -0
- package/dist/src/protos/ctos/base.d.ts +3 -16
- package/dist/src/protos/index.d.ts +5 -0
- package/dist/src/protos/stoc/base.d.ts +3 -16
- package/index.ts +2 -5
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -54,7 +54,9 @@ __export(index_exports, {
|
|
|
54
54
|
NetPlayerType: () => NetPlayerType,
|
|
55
55
|
OcgcoreCommonConstants: () => OcgcoreCommonConstants,
|
|
56
56
|
OcgcoreScriptConstants: () => OcgcoreScriptConstants,
|
|
57
|
+
PayloadBase: () => PayloadBase,
|
|
57
58
|
PlayerChangeState: () => PlayerChangeState,
|
|
59
|
+
RegistryBase: () => RegistryBase,
|
|
58
60
|
RoomStatus: () => RoomStatus,
|
|
59
61
|
SEND_TO_ALL: () => SEND_TO_ALL,
|
|
60
62
|
SEND_TO_PLAYERS: () => SEND_TO_PLAYERS,
|
|
@@ -198,6 +200,7 @@ __export(index_exports, {
|
|
|
198
200
|
YGOProMsgUpdateData: () => YGOProMsgUpdateData,
|
|
199
201
|
YGOProMsgWaiting: () => YGOProMsgWaiting,
|
|
200
202
|
YGOProMsgWin: () => YGOProMsgWin,
|
|
203
|
+
YGOProProtoBase: () => YGOProProtoBase,
|
|
201
204
|
YGOProStoc: () => YGOProStoc,
|
|
202
205
|
YGOProStocBase: () => YGOProStocBase,
|
|
203
206
|
YGOProStocChangeSide: () => YGOProStocChangeSide,
|
|
@@ -1454,8 +1457,11 @@ var CardQuery = class {
|
|
|
1454
1457
|
}
|
|
1455
1458
|
};
|
|
1456
1459
|
|
|
1457
|
-
// src/
|
|
1458
|
-
var
|
|
1460
|
+
// src/proto-base/ygopro-proto-base.ts
|
|
1461
|
+
var YGOProProtoBase = class extends PayloadBase {
|
|
1462
|
+
get messageDirection() {
|
|
1463
|
+
return this.constructor.messageDirection;
|
|
1464
|
+
}
|
|
1459
1465
|
/**
|
|
1460
1466
|
* Serialize to full payload including header (length + identifier + body)
|
|
1461
1467
|
* Format: [length 2 bytes LE][identifier 1 byte][body]
|
|
@@ -1481,26 +1487,32 @@ var YGOProCtosBase = class extends PayloadBase {
|
|
|
1481
1487
|
fromFullPayload(data) {
|
|
1482
1488
|
if (data.length < 3) {
|
|
1483
1489
|
throw new Error(
|
|
1484
|
-
|
|
1490
|
+
`${this.messageDirection} payload too short: expected at least 3 bytes, got ${data.length}`
|
|
1485
1491
|
);
|
|
1486
1492
|
}
|
|
1487
1493
|
const declaredLength = data[0] | data[1] << 8;
|
|
1488
1494
|
const identifier = data[2];
|
|
1489
1495
|
if (identifier !== this.identifier) {
|
|
1490
1496
|
throw new Error(
|
|
1491
|
-
|
|
1497
|
+
`${this.messageDirection} identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
|
|
1492
1498
|
);
|
|
1493
1499
|
}
|
|
1494
1500
|
const expectedTotalLength = 3 + declaredLength - 1;
|
|
1495
1501
|
if (data.length < expectedTotalLength) {
|
|
1496
1502
|
throw new Error(
|
|
1497
|
-
|
|
1503
|
+
`${this.messageDirection} payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
|
|
1498
1504
|
);
|
|
1499
1505
|
}
|
|
1500
1506
|
const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
|
|
1501
1507
|
return this.fromPayload(bodyData);
|
|
1502
1508
|
}
|
|
1503
1509
|
};
|
|
1510
|
+
YGOProProtoBase.messageDirection = "";
|
|
1511
|
+
|
|
1512
|
+
// src/protos/ctos/base.ts
|
|
1513
|
+
var YGOProCtosBase = class extends YGOProProtoBase {
|
|
1514
|
+
};
|
|
1515
|
+
YGOProCtosBase.messageDirection = "CTOS";
|
|
1504
1516
|
|
|
1505
1517
|
// src/proto-base/registry-base.ts
|
|
1506
1518
|
var RegistryBase = class {
|
|
@@ -1808,52 +1820,9 @@ YGOProCtos.register(YGOProCtosHsStart);
|
|
|
1808
1820
|
YGOProCtos.register(YGOProCtosRequestField);
|
|
1809
1821
|
|
|
1810
1822
|
// src/protos/stoc/base.ts
|
|
1811
|
-
var YGOProStocBase = class extends
|
|
1812
|
-
/**
|
|
1813
|
-
* Serialize to full payload including header (length + identifier + body)
|
|
1814
|
-
* Format: [length 2 bytes LE][identifier 1 byte][body]
|
|
1815
|
-
* Length = 1 (identifier) + body.length
|
|
1816
|
-
*/
|
|
1817
|
-
toFullPayload() {
|
|
1818
|
-
const body = this.toPayload();
|
|
1819
|
-
const length = 1 + body.length;
|
|
1820
|
-
const fullPayload = new Uint8Array(3 + body.length);
|
|
1821
|
-
fullPayload[0] = length & 255;
|
|
1822
|
-
fullPayload[1] = length >> 8 & 255;
|
|
1823
|
-
fullPayload[2] = this.identifier;
|
|
1824
|
-
fullPayload.set(body, 3);
|
|
1825
|
-
return fullPayload;
|
|
1826
|
-
}
|
|
1827
|
-
/**
|
|
1828
|
-
* Deserialize from full payload including header (length + identifier + body)
|
|
1829
|
-
* Format: [length 2 bytes LE][identifier 1 byte][body]
|
|
1830
|
-
* @param data - Full payload data
|
|
1831
|
-
* @returns this instance
|
|
1832
|
-
* @throws Error if data is too short or identifier mismatch
|
|
1833
|
-
*/
|
|
1834
|
-
fromFullPayload(data) {
|
|
1835
|
-
if (data.length < 3) {
|
|
1836
|
-
throw new Error(
|
|
1837
|
-
`STOC payload too short: expected at least 3 bytes, got ${data.length}`
|
|
1838
|
-
);
|
|
1839
|
-
}
|
|
1840
|
-
const declaredLength = data[0] | data[1] << 8;
|
|
1841
|
-
const identifier = data[2];
|
|
1842
|
-
if (identifier !== this.identifier) {
|
|
1843
|
-
throw new Error(
|
|
1844
|
-
`STOC identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
|
|
1845
|
-
);
|
|
1846
|
-
}
|
|
1847
|
-
const expectedTotalLength = 3 + declaredLength - 1;
|
|
1848
|
-
if (data.length < expectedTotalLength) {
|
|
1849
|
-
throw new Error(
|
|
1850
|
-
`STOC payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
|
|
1851
|
-
);
|
|
1852
|
-
}
|
|
1853
|
-
const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
|
|
1854
|
-
return this.fromPayload(bodyData);
|
|
1855
|
-
}
|
|
1823
|
+
var YGOProStocBase = class extends YGOProProtoBase {
|
|
1856
1824
|
};
|
|
1825
|
+
YGOProStocBase.messageDirection = "STOC";
|
|
1857
1826
|
|
|
1858
1827
|
// src/protos/network-enums.ts
|
|
1859
1828
|
var HandResult = /* @__PURE__ */ ((HandResult2) => {
|
|
@@ -6006,7 +5975,9 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
|
|
|
6006
5975
|
NetPlayerType,
|
|
6007
5976
|
OcgcoreCommonConstants,
|
|
6008
5977
|
OcgcoreScriptConstants,
|
|
5978
|
+
PayloadBase,
|
|
6009
5979
|
PlayerChangeState,
|
|
5980
|
+
RegistryBase,
|
|
6010
5981
|
RoomStatus,
|
|
6011
5982
|
SEND_TO_ALL,
|
|
6012
5983
|
SEND_TO_PLAYERS,
|
|
@@ -6150,6 +6121,7 @@ YGOProStoc.register(YGOProStocSrvproRoomlist);
|
|
|
6150
6121
|
YGOProMsgUpdateData,
|
|
6151
6122
|
YGOProMsgWaiting,
|
|
6152
6123
|
YGOProMsgWin,
|
|
6124
|
+
YGOProProtoBase,
|
|
6153
6125
|
YGOProStoc,
|
|
6154
6126
|
YGOProStocBase,
|
|
6155
6127
|
YGOProStocChangeSide,
|