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.d.ts CHANGED
@@ -1,9 +1,6 @@
1
1
  export * from './src/binary/binary-meta';
2
2
  export * from './src/binary/fill-binary-fields';
3
- export * from './src/protos/common';
4
- export * from './src/protos/ctos';
5
- export * from './src/protos/stoc';
6
- export * from './src/protos/msg';
7
- export * from './src/protos/network-enums';
3
+ export * from './src/protos';
8
4
  export * from './src/vendor/ocgcore-constants';
9
5
  export * from './src/vendor/script-constants';
6
+ export * from './src/proto-base';
package/dist/index.mjs CHANGED
@@ -1234,8 +1234,14 @@ var CardQuery = class {
1234
1234
  }
1235
1235
  };
1236
1236
 
1237
- // src/protos/ctos/base.ts
1238
- var YGOProCtosBase = class extends PayloadBase {
1237
+ // src/proto-base/ygopro-proto-base.ts
1238
+ var YGOProProtoBase = class extends PayloadBase {
1239
+ static {
1240
+ this.messageDirection = "";
1241
+ }
1242
+ get messageDirection() {
1243
+ return this.constructor.messageDirection;
1244
+ }
1239
1245
  /**
1240
1246
  * Serialize to full payload including header (length + identifier + body)
1241
1247
  * Format: [length 2 bytes LE][identifier 1 byte][body]
@@ -1261,20 +1267,20 @@ var YGOProCtosBase = class extends PayloadBase {
1261
1267
  fromFullPayload(data) {
1262
1268
  if (data.length < 3) {
1263
1269
  throw new Error(
1264
- `CTOS payload too short: expected at least 3 bytes, got ${data.length}`
1270
+ `${this.messageDirection} payload too short: expected at least 3 bytes, got ${data.length}`
1265
1271
  );
1266
1272
  }
1267
1273
  const declaredLength = data[0] | data[1] << 8;
1268
1274
  const identifier = data[2];
1269
1275
  if (identifier !== this.identifier) {
1270
1276
  throw new Error(
1271
- `CTOS identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1277
+ `${this.messageDirection} identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1272
1278
  );
1273
1279
  }
1274
1280
  const expectedTotalLength = 3 + declaredLength - 1;
1275
1281
  if (data.length < expectedTotalLength) {
1276
1282
  throw new Error(
1277
- `CTOS payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1283
+ `${this.messageDirection} payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1278
1284
  );
1279
1285
  }
1280
1286
  const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
@@ -1282,6 +1288,13 @@ var YGOProCtosBase = class extends PayloadBase {
1282
1288
  }
1283
1289
  };
1284
1290
 
1291
+ // src/protos/ctos/base.ts
1292
+ var YGOProCtosBase = class extends YGOProProtoBase {
1293
+ static {
1294
+ this.messageDirection = "CTOS";
1295
+ }
1296
+ };
1297
+
1285
1298
  // src/proto-base/registry-base.ts
1286
1299
  var RegistryBase = class {
1287
1300
  constructor(payloadClass, options = {}) {
@@ -1626,50 +1639,9 @@ YGOProCtos.register(YGOProCtosHsStart);
1626
1639
  YGOProCtos.register(YGOProCtosRequestField);
1627
1640
 
1628
1641
  // src/protos/stoc/base.ts
1629
- var YGOProStocBase = class extends PayloadBase {
1630
- /**
1631
- * Serialize to full payload including header (length + identifier + body)
1632
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1633
- * Length = 1 (identifier) + body.length
1634
- */
1635
- toFullPayload() {
1636
- const body = this.toPayload();
1637
- const length = 1 + body.length;
1638
- const fullPayload = new Uint8Array(3 + body.length);
1639
- fullPayload[0] = length & 255;
1640
- fullPayload[1] = length >> 8 & 255;
1641
- fullPayload[2] = this.identifier;
1642
- fullPayload.set(body, 3);
1643
- return fullPayload;
1644
- }
1645
- /**
1646
- * Deserialize from full payload including header (length + identifier + body)
1647
- * Format: [length 2 bytes LE][identifier 1 byte][body]
1648
- * @param data - Full payload data
1649
- * @returns this instance
1650
- * @throws Error if data is too short or identifier mismatch
1651
- */
1652
- fromFullPayload(data) {
1653
- if (data.length < 3) {
1654
- throw new Error(
1655
- `STOC payload too short: expected at least 3 bytes, got ${data.length}`
1656
- );
1657
- }
1658
- const declaredLength = data[0] | data[1] << 8;
1659
- const identifier = data[2];
1660
- if (identifier !== this.identifier) {
1661
- throw new Error(
1662
- `STOC identifier mismatch: expected 0x${this.identifier.toString(16)}, got 0x${identifier.toString(16)}`
1663
- );
1664
- }
1665
- const expectedTotalLength = 3 + declaredLength - 1;
1666
- if (data.length < expectedTotalLength) {
1667
- throw new Error(
1668
- `STOC payload too short: declared length ${declaredLength} requires ${expectedTotalLength} bytes total, got ${data.length}`
1669
- );
1670
- }
1671
- const bodyData = data.length > expectedTotalLength ? data.slice(3, expectedTotalLength) : data.slice(3);
1672
- return this.fromPayload(bodyData);
1642
+ var YGOProStocBase = class extends YGOProProtoBase {
1643
+ static {
1644
+ this.messageDirection = "STOC";
1673
1645
  }
1674
1646
  };
1675
1647
 
@@ -6039,7 +6011,9 @@ export {
6039
6011
  NetPlayerType,
6040
6012
  OcgcoreCommonConstants,
6041
6013
  OcgcoreScriptConstants,
6014
+ PayloadBase,
6042
6015
  PlayerChangeState,
6016
+ RegistryBase,
6043
6017
  RoomStatus,
6044
6018
  SEND_TO_ALL,
6045
6019
  SEND_TO_PLAYERS,
@@ -6183,6 +6157,7 @@ export {
6183
6157
  YGOProMsgUpdateData,
6184
6158
  YGOProMsgWaiting,
6185
6159
  YGOProMsgWin,
6160
+ YGOProProtoBase,
6186
6161
  YGOProStoc,
6187
6162
  YGOProStocBase,
6188
6163
  YGOProStocChangeSide,