@serenityjs/raknet 0.5.0 → 0.5.1-beta-20240915201114

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.
Files changed (2) hide show
  1. package/dist/index.js +998 -673
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ var __defProp = Object.defineProperty;
3
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
5
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
7
  var __export = (target, all) => {
7
8
  for (var name in all)
8
9
  __defProp(target, name, { get: all[name], enumerable: true });
@@ -16,14 +17,6 @@ var __copyProps = (to, from, except, desc) => {
16
17
  return to;
17
18
  };
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var __decorateClass = (decorators, target, key, kind) => {
20
- var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
21
- for (var i = decorators.length - 1, decorator; i >= 0; i--)
22
- if (decorator = decorators[i])
23
- result = (kind ? decorator(target, key, result) : decorator(result)) || result;
24
- if (kind && result) __defProp(target, key, result);
25
- return result;
26
- };
27
20
 
28
21
  // src/index.ts
29
22
  var src_exports = {};
@@ -78,10 +71,7 @@ var import_nbt = require("@serenityjs/nbt");
78
71
  function Proto(id) {
79
72
  return function(target) {
80
73
  target.id = id;
81
- const metadata = Reflect.getOwnMetadata(
82
- "properties",
83
- target.prototype
84
- );
74
+ const metadata = Reflect.getOwnMetadata("properties", target.prototype);
85
75
  const properties = Object.getOwnPropertyNames(target.prototype);
86
76
  if (!properties.includes("serialize"))
87
77
  target.prototype.serialize = function() {
@@ -90,10 +80,7 @@ function Proto(id) {
90
80
  if (!metadata) return this.getBuffer();
91
81
  for (const { name, type, endian, parameter } of metadata) {
92
82
  if (parameter) {
93
- if (type.prototype === import_nbt.CompoundTag.prototype)
94
- throw new Error(
95
- "Parameters are not supported for CompoundTag serialization."
96
- );
83
+ if (type.prototype === import_nbt.CompoundTag.prototype) throw new Error("Parameters are not supported for CompoundTag serialization.");
97
84
  const value = this[parameter];
98
85
  const dtype = type;
99
86
  const data = this[name];
@@ -112,52 +99,37 @@ function Proto(id) {
112
99
  }
113
100
  return this.getBuffer();
114
101
  };
115
- if (!properties.includes("deserialize"))
116
- target.prototype.deserialize = function() {
117
- if (this.binary.length === 0) return this;
118
- target.id_type.read(this);
119
- if (!metadata) return this;
120
- for (const { name, type, endian, parameter } of metadata) {
121
- if (parameter) {
122
- if (type.prototype === import_nbt.CompoundTag.prototype)
123
- throw new Error(
124
- "Parameters are not supported for CompoundTag deserialization."
125
- );
126
- const value = this[parameter];
127
- const dtype = type;
128
- this[name] = dtype.read(
129
- this,
130
- endian,
131
- value
132
- );
102
+ if (!properties.includes("deserialize")) target.prototype.deserialize = function() {
103
+ if (this.binary.length === 0) return this;
104
+ target.id_type.read(this);
105
+ if (!metadata) return this;
106
+ for (const { name, type, endian, parameter } of metadata) {
107
+ if (parameter) {
108
+ if (type.prototype === import_nbt.CompoundTag.prototype) throw new Error("Parameters are not supported for CompoundTag deserialization.");
109
+ const value = this[parameter];
110
+ const dtype = type;
111
+ this[name] = dtype.read(this, endian, value);
112
+ } else {
113
+ if (type.prototype === import_nbt.CompoundTag.prototype) {
114
+ const ctype = type;
115
+ this[name] = ctype.read(this, endian);
133
116
  } else {
134
- if (type.prototype === import_nbt.CompoundTag.prototype) {
135
- const ctype = type;
136
- this[name] = ctype.read(
137
- this,
138
- endian
139
- );
140
- } else {
141
- const dtype = type;
142
- this[name] = dtype.read(
143
- this,
144
- endian
145
- );
146
- }
117
+ const dtype = type;
118
+ this[name] = dtype.read(this, endian);
147
119
  }
148
120
  }
149
- return this;
150
- };
151
- if (!properties.includes("getId"))
152
- target.prototype.getId = function() {
153
- return target.id;
154
- };
155
- if (!properties.includes("getIdType"))
156
- target.prototype.getIdType = function() {
157
- return target.id_type;
158
- };
121
+ }
122
+ return this;
123
+ };
124
+ if (!properties.includes("getId")) target.prototype.getId = function() {
125
+ return target.id;
126
+ };
127
+ if (!properties.includes("getIdType")) target.prototype.getIdType = function() {
128
+ return target.id_type;
129
+ };
159
130
  };
160
131
  }
132
+ __name(Proto, "Proto");
161
133
 
162
134
  // src/decorators/serialize.ts
163
135
  var import_binarystream = require("@serenityjs/binarystream");
@@ -165,105 +137,120 @@ function Serialize(type, endian = import_binarystream.Endianness.Big, parameter)
165
137
  if (!type) throw new Error("@Serialize() failed, no type provided.");
166
138
  return function(target, name) {
167
139
  const properties = Reflect.getMetadata("properties", target) || [];
168
- properties.push({ name, type, endian, parameter });
140
+ properties.push({
141
+ name,
142
+ type,
143
+ endian,
144
+ parameter
145
+ });
169
146
  Reflect.defineMetadata("properties", properties, target);
170
147
  };
171
148
  }
149
+ __name(Serialize, "Serialize");
172
150
 
173
151
  // src/proto/types/type.ts
174
152
  var import_binarystream2 = require("@serenityjs/binarystream");
175
- var DataType = class {
153
+ var DataType = class DataType2 {
154
+ static {
155
+ __name(this, "DataType");
156
+ }
176
157
  /**
177
- * Creates a new data type.
178
- */
158
+ * Creates a new data type.
159
+ */
179
160
  constructor(..._arguments_) {
180
161
  return;
181
162
  }
182
163
  /**
183
- * Reads the data type from a binary stream.
184
- * @param _stream The binary stream to read from.
185
- * @param _endian The endianness to use.
186
- * @param _parameter An optional parameter.
187
- * @returns The data type.
188
- */
164
+ * Reads the data type from a binary stream.
165
+ * @param _stream The binary stream to read from.
166
+ * @param _endian The endianness to use.
167
+ * @param _parameter An optional parameter.
168
+ * @returns The data type.
169
+ */
189
170
  static read(_stream, _endian = import_binarystream2.Endianness.Big, _parameter) {
190
171
  return;
191
172
  }
192
173
  /**
193
- * Writes the data type to a binary stream.
194
- * @param _stream The binary stream to write to.
195
- * @param _value The data type to write.
196
- * @param _endian The endianness to use.
197
- * @param _parameter An optional parameter.
198
- */
174
+ * Writes the data type to a binary stream.
175
+ * @param _stream The binary stream to write to.
176
+ * @param _value The data type to write.
177
+ * @param _endian The endianness to use.
178
+ * @param _parameter An optional parameter.
179
+ */
199
180
  static write(_stream, _value, _endian = import_binarystream2.Endianness.Big, _parameter) {
200
181
  return;
201
182
  }
202
183
  };
203
184
 
204
185
  // src/proto/types/magic.ts
205
- var MagicBuffer = Buffer.from(
206
- "\0\xFF\xFF\0\xFE\xFE\xFE\xFE\xFD\xFD\xFD\xFD4Vx",
207
- "binary"
208
- );
209
- var Magic = class extends DataType {
210
- /**
211
- * Reads the magic data type from a binary stream.
212
- * @param stream The binary stream to read from.
213
- * @returns The magic data type.
214
- */
186
+ var MagicBuffer = Buffer.from("\0\xFF\xFF\0\xFE\xFE\xFE\xFE\xFD\xFD\xFD\xFD4Vx", "binary");
187
+ var Magic = class Magic2 extends DataType {
188
+ static {
189
+ __name(this, "Magic");
190
+ }
191
+ /**
192
+ * Reads the magic data type from a binary stream.
193
+ * @param stream The binary stream to read from.
194
+ * @returns The magic data type.
195
+ */
215
196
  static read(stream) {
216
197
  return stream.readBuffer(MagicBuffer.length);
217
198
  }
218
199
  /**
219
- * Writes the magic data type to a binary stream.
220
- * @param stream The binary stream to write to.
221
- */
200
+ * Writes the magic data type to a binary stream.
201
+ * @param stream The binary stream to write to.
202
+ */
222
203
  static write(stream) {
223
204
  stream.writeBuffer(MagicBuffer);
224
205
  }
225
206
  };
226
207
 
227
208
  // src/proto/types/mtu.ts
228
- var MTU = class extends DataType {
209
+ var MTU = class MTU2 extends DataType {
210
+ static {
211
+ __name(this, "MTU");
212
+ }
229
213
  /**
230
- * Reads the mtu data type from a binary stream.
231
- * @param stream The binary stream to read from.
232
- * @returns The mtu data type.
233
- */
214
+ * Reads the mtu data type from a binary stream.
215
+ * @param stream The binary stream to read from.
216
+ * @returns The mtu data type.
217
+ */
234
218
  static read(stream) {
235
219
  return stream.getBuffer().byteLength;
236
220
  }
237
221
  /**
238
- * Writes the mtu data type to a binary stream.
239
- * @param stream The binary stream to write to.
240
- * @param value The value to write.
241
- */
222
+ * Writes the mtu data type to a binary stream.
223
+ * @param stream The binary stream to write to.
224
+ * @param value The value to write.
225
+ */
242
226
  static write(stream, value) {
243
227
  stream.writeBuffer(Buffer.alloc(value - stream.getBuffer().length));
244
228
  }
245
229
  };
246
230
 
247
231
  // src/proto/types/address.ts
248
- var Address = class _Address extends DataType {
232
+ var Address = class Address2 extends DataType {
233
+ static {
234
+ __name(this, "Address");
235
+ }
249
236
  /**
250
- * The address of the data type.
251
- */
237
+ * The address of the data type.
238
+ */
252
239
  address;
253
240
  /**
254
- * The port of the data type.
255
- */
241
+ * The port of the data type.
242
+ */
256
243
  port;
257
244
  /**
258
- * The version of the data type.
259
- */
245
+ * The version of the data type.
246
+ */
260
247
  version;
261
248
  /**
262
- * Initializes a new instance of the Address data type.
263
- * @param address The address of the data type.
264
- * @param port The port of the data type.
265
- * @param version The version of the data type.
266
- */
249
+ * Initializes a new instance of the Address data type.
250
+ * @param address The address of the data type.
251
+ * @param port The port of the data type.
252
+ * @param version The version of the data type.
253
+ */
267
254
  constructor(address, port, version) {
268
255
  super();
269
256
  this.address = address;
@@ -271,30 +258,26 @@ var Address = class _Address extends DataType {
271
258
  this.version = version;
272
259
  }
273
260
  /**
274
- * Converts the Address data type to a NetworkIdentifier.
275
- *
276
- * @param identifier The NetworkIdentifier.
277
- * @returns The NetworkIdentifier.
278
- */
261
+ * Converts the Address data type to a NetworkIdentifier.
262
+ *
263
+ * @param identifier The NetworkIdentifier.
264
+ * @returns The NetworkIdentifier.
265
+ */
279
266
  static fromIdentifier(identifier) {
280
- return new _Address(
281
- identifier.address,
282
- identifier.port,
283
- identifier.family === "IPv4" ? 4 : 6
284
- );
267
+ return new Address2(identifier.address, identifier.port, identifier.family === "IPv4" ? 4 : 6);
285
268
  }
286
269
  /**
287
- * Reads the Address data type from a binary stream.
288
- * @param stream The binary stream to read from.
289
- * @returns The Address data type.
290
- */
270
+ * Reads the Address data type from a binary stream.
271
+ * @param stream The binary stream to read from.
272
+ * @returns The Address data type.
273
+ */
291
274
  static read(stream) {
292
275
  const version = stream.readUint8();
293
276
  if (version === 4) {
294
277
  const addressBuffer = stream.read(4);
295
278
  const address = addressBuffer.map((byte) => -byte - 1 & 255).join(".");
296
279
  const port = stream.readUShort();
297
- return new _Address(address, port, version);
280
+ return new Address2(address, port, version);
298
281
  } else {
299
282
  stream.skip(2);
300
283
  const port = stream.readUShort();
@@ -302,14 +285,14 @@ var Address = class _Address extends DataType {
302
285
  const addressBuffer = stream.read(4);
303
286
  const address = addressBuffer.filter((byte) => byte !== 255).join(".");
304
287
  stream.skip(4);
305
- return new _Address(address, port, version);
288
+ return new Address2(address, port, version);
306
289
  }
307
290
  }
308
291
  /**
309
- * Writes the Address data type to a binary stream.
310
- * @param stream The binary stream to write to.
311
- * @param value The value to write.
312
- */
292
+ * Writes the Address data type to a binary stream.
293
+ * @param stream The binary stream to write to.
294
+ * @param value The value to write.
295
+ */
313
296
  static write(stream, value) {
314
297
  const { address, port, version } = value;
315
298
  stream.writeUint8(version);
@@ -325,7 +308,8 @@ var Address = class _Address extends DataType {
325
308
  var import_binarystream3 = require("@serenityjs/binarystream");
326
309
 
327
310
  // src/enums/packet.ts
328
- var Packet = /* @__PURE__ */ ((Packet2) => {
311
+ var Packet;
312
+ (function(Packet2) {
329
313
  Packet2[Packet2["ConnectedPing"] = 0] = "ConnectedPing";
330
314
  Packet2[Packet2["UnconnectedPing"] = 1] = "UnconnectedPing";
331
315
  Packet2[Packet2["ConnectedPong"] = 3] = "ConnectedPong";
@@ -342,36 +326,36 @@ var Packet = /* @__PURE__ */ ((Packet2) => {
342
326
  Packet2[Packet2["FrameSet"] = 128] = "FrameSet";
343
327
  Packet2[Packet2["Nack"] = 160] = "Nack";
344
328
  Packet2[Packet2["Ack"] = 192] = "Ack";
345
- return Packet2;
346
- })(Packet || {});
329
+ })(Packet || (Packet = {}));
347
330
 
348
331
  // src/enums/bit-flags.ts
349
- var Bitflags = /* @__PURE__ */ ((Bitflags2) => {
332
+ var Bitflags;
333
+ (function(Bitflags2) {
350
334
  Bitflags2[Bitflags2["Valid"] = 128] = "Valid";
351
335
  Bitflags2[Bitflags2["Ack"] = 64] = "Ack";
352
336
  Bitflags2[Bitflags2["Nak"] = 32] = "Nak";
353
337
  Bitflags2[Bitflags2["Split"] = 16] = "Split";
354
- return Bitflags2;
355
- })(Bitflags || {});
338
+ })(Bitflags || (Bitflags = {}));
356
339
 
357
340
  // src/enums/priority.ts
358
- var Priority = /* @__PURE__ */ ((Priority2) => {
341
+ var Priority;
342
+ (function(Priority2) {
359
343
  Priority2[Priority2["Normal"] = 0] = "Normal";
360
344
  Priority2[Priority2["Immediate"] = 1] = "Immediate";
361
- return Priority2;
362
- })(Priority || {});
345
+ })(Priority || (Priority = {}));
363
346
 
364
347
  // src/enums/status.ts
365
- var Status = /* @__PURE__ */ ((Status2) => {
348
+ var Status;
349
+ (function(Status2) {
366
350
  Status2[Status2["Connecting"] = 0] = "Connecting";
367
351
  Status2[Status2["Connected"] = 1] = "Connected";
368
352
  Status2[Status2["Disconnecting"] = 2] = "Disconnecting";
369
353
  Status2[Status2["Disconnected"] = 3] = "Disconnected";
370
- return Status2;
371
- })(Status || {});
354
+ })(Status || (Status = {}));
372
355
 
373
356
  // src/enums/reliability.ts
374
- var Reliability = /* @__PURE__ */ ((Reliability2) => {
357
+ var Reliability;
358
+ (function(Reliability2) {
375
359
  Reliability2[Reliability2["Unreliable"] = 0] = "Unreliable";
376
360
  Reliability2[Reliability2["UnreliableSequenced"] = 1] = "UnreliableSequenced";
377
361
  Reliability2[Reliability2["Reliable"] = 2] = "Reliable";
@@ -380,122 +364,124 @@ var Reliability = /* @__PURE__ */ ((Reliability2) => {
380
364
  Reliability2[Reliability2["UnreliableWithAckReceipt"] = 5] = "UnreliableWithAckReceipt";
381
365
  Reliability2[Reliability2["ReliableWithAckReceipt"] = 6] = "ReliableWithAckReceipt";
382
366
  Reliability2[Reliability2["ReliableOrderedWithAckReceipt"] = 7] = "ReliableOrderedWithAckReceipt";
383
- return Reliability2;
384
- })(Reliability || {});
367
+ })(Reliability || (Reliability = {}));
385
368
 
386
369
  // src/proto/types/frame.ts
387
- var Frame = class _Frame extends DataType {
370
+ var Frame = class Frame2 extends DataType {
371
+ static {
372
+ __name(this, "Frame");
373
+ }
388
374
  /**
389
- * The reliability of the frame.
390
- */
375
+ * The reliability of the frame.
376
+ */
391
377
  reliability;
392
378
  /**
393
- * The reliable index of the frame.
394
- */
379
+ * The reliable index of the frame.
380
+ */
395
381
  reliableIndex;
396
382
  /**
397
- * The sequence index of the frame.
398
- */
383
+ * The sequence index of the frame.
384
+ */
399
385
  sequenceIndex;
400
386
  /**
401
- * The order index of the frame.
402
- */
387
+ * The order index of the frame.
388
+ */
403
389
  orderIndex;
404
390
  /**
405
- * The order channel of the frame.
406
- */
391
+ * The order channel of the frame.
392
+ */
407
393
  orderChannel;
408
394
  /**
409
- * The split size of the frame.
410
- */
395
+ * The split size of the frame.
396
+ */
411
397
  splitSize;
412
398
  /**
413
- * The split id of the frame.
414
- */
399
+ * The split id of the frame.
400
+ */
415
401
  splitId;
416
402
  /**
417
- * The split index of the frame.
418
- */
403
+ * The split index of the frame.
404
+ */
419
405
  splitIndex;
420
406
  /**
421
- * The payload of the frame.
422
- */
407
+ * The payload of the frame.
408
+ */
423
409
  payload;
424
410
  /**
425
- * Checks if the frame is split.
426
- * @returns True if the frame is split; otherwise, false.
427
- */
411
+ * Checks if the frame is split.
412
+ * @returns True if the frame is split; otherwise, false.
413
+ */
428
414
  isSplit() {
429
415
  return this.splitSize > 0;
430
416
  }
431
417
  /**
432
- * Checks if the frame is reliable.
433
- * @returns True if the frame is reliable; otherwise, false.
434
- */
418
+ * Checks if the frame is reliable.
419
+ * @returns True if the frame is reliable; otherwise, false.
420
+ */
435
421
  isReliable() {
436
422
  const values = [
437
- 2 /* Reliable */,
438
- 3 /* ReliableOrdered */,
439
- 4 /* ReliableSequenced */,
440
- 6 /* ReliableWithAckReceipt */,
441
- 7 /* ReliableOrderedWithAckReceipt */
423
+ Reliability.Reliable,
424
+ Reliability.ReliableOrdered,
425
+ Reliability.ReliableSequenced,
426
+ Reliability.ReliableWithAckReceipt,
427
+ Reliability.ReliableOrderedWithAckReceipt
442
428
  ];
443
429
  return values.includes(this.reliability);
444
430
  }
445
431
  /**
446
- * Checks if the frame is sequenced.
447
- * @returns True if the frame is sequenced; otherwise, false.
448
- */
432
+ * Checks if the frame is sequenced.
433
+ * @returns True if the frame is sequenced; otherwise, false.
434
+ */
449
435
  isSequenced() {
450
436
  const values = [
451
- 4 /* ReliableSequenced */,
452
- 1 /* UnreliableSequenced */
437
+ Reliability.ReliableSequenced,
438
+ Reliability.UnreliableSequenced
453
439
  ];
454
440
  return values.includes(this.reliability);
455
441
  }
456
442
  /**
457
- * Checks if the frame is ordered.
458
- * @returns True if the frame is ordered; otherwise, false.
459
- */
443
+ * Checks if the frame is ordered.
444
+ * @returns True if the frame is ordered; otherwise, false.
445
+ */
460
446
  isOrdered() {
461
447
  const values = [
462
- 1 /* UnreliableSequenced */,
463
- 3 /* ReliableOrdered */,
464
- 4 /* ReliableSequenced */,
465
- 7 /* ReliableOrderedWithAckReceipt */
448
+ Reliability.UnreliableSequenced,
449
+ Reliability.ReliableOrdered,
450
+ Reliability.ReliableSequenced,
451
+ Reliability.ReliableOrderedWithAckReceipt
466
452
  ];
467
453
  return values.includes(this.reliability);
468
454
  }
469
455
  /**
470
- * Checks if the frame is order exclusive.
471
- * @returns True if the frame is order exclusive; otherwise, false.
472
- */
456
+ * Checks if the frame is order exclusive.
457
+ * @returns True if the frame is order exclusive; otherwise, false.
458
+ */
473
459
  isOrderExclusive() {
474
460
  const values = [
475
- 3 /* ReliableOrdered */,
476
- 7 /* ReliableOrderedWithAckReceipt */
461
+ Reliability.ReliableOrdered,
462
+ Reliability.ReliableOrderedWithAckReceipt
477
463
  ];
478
464
  return values.includes(this.reliability);
479
465
  }
480
466
  /**
481
- * Gets the byte length of the frame.
482
- * @returns The byte length of the frame.
483
- */
467
+ * Gets the byte length of the frame.
468
+ * @returns The byte length of the frame.
469
+ */
484
470
  getByteLength() {
485
471
  return 3 + this.payload.byteLength + (this.isReliable() ? 3 : 0) + (this.isSequenced() ? 3 : 0) + (this.isOrdered() ? 4 : 0) + (this.isSplit() ? 10 : 0);
486
472
  }
487
473
  /**
488
- * Reads the Frame data type from a binary stream.
489
- * @param stream The binary stream to read from.
490
- * @returns The Frame data type.
491
- */
474
+ * Reads the Frame data type from a binary stream.
475
+ * @param stream The binary stream to read from.
476
+ * @returns The Frame data type.
477
+ */
492
478
  static read(stream) {
493
479
  const frames = [];
494
480
  do {
495
- const frame = new _Frame();
481
+ const frame = new Frame2();
496
482
  const header = stream.readUint8();
497
483
  frame.reliability = (header & 224) >> 5;
498
- const split = (header & 16 /* Split */) !== 0;
484
+ const split = (header & Bitflags.Split) !== 0;
499
485
  const length = Math.ceil(stream.readUint16() / 8);
500
486
  if (frame.isReliable()) {
501
487
  frame.reliableIndex = stream.readUint24(import_binarystream3.Endianness.Little);
@@ -518,14 +504,12 @@ var Frame = class _Frame extends DataType {
518
504
  return frames;
519
505
  }
520
506
  /**
521
- * Writes the Frame data type to a binary stream.
522
- * @param stream The binary stream to write to.
523
- */
507
+ * Writes the Frame data type to a binary stream.
508
+ * @param stream The binary stream to write to.
509
+ */
524
510
  static write(stream, value) {
525
511
  for (const frame of value) {
526
- stream.writeUint8(
527
- frame.reliability << 5 | (frame.isSplit() ? 16 /* Split */ : 0)
528
- );
512
+ stream.writeUint8(frame.reliability << 5 | (frame.isSplit() ? Bitflags.Split : 0));
529
513
  stream.writeUint16(frame.payload.byteLength << 3);
530
514
  if (frame.isReliable()) {
531
515
  stream.writeUint24(frame.reliableIndex, import_binarystream3.Endianness.Little);
@@ -548,21 +532,24 @@ var Frame = class _Frame extends DataType {
548
532
  };
549
533
 
550
534
  // src/proto/types/system-address.ts
551
- var SystemAddress = class extends DataType {
535
+ var SystemAddress = class SystemAddress2 extends DataType {
536
+ static {
537
+ __name(this, "SystemAddress");
538
+ }
552
539
  /**
553
- * Converts the Address data type to a NetworkIdentifier.
554
- *
555
- * @param identifier The NetworkIdentifier.
556
- * @returns The NetworkIdentifier.
557
- */
540
+ * Converts the Address data type to a NetworkIdentifier.
541
+ *
542
+ * @param identifier The NetworkIdentifier.
543
+ * @returns The NetworkIdentifier.
544
+ */
558
545
  static fromIdentifier(identifier) {
559
546
  return new Address(identifier.address, identifier.port, identifier.version);
560
547
  }
561
548
  /**
562
- * Reads the Address data type from a binary stream.
563
- * @param stream The binary stream to read from.
564
- * @returns The Address data type.
565
- */
549
+ * Reads the Address data type from a binary stream.
550
+ * @param stream The binary stream to read from.
551
+ * @returns The Address data type.
552
+ */
566
553
  static read(stream) {
567
554
  const addresses = [];
568
555
  for (let index = 0; index < 20; index++) {
@@ -572,64 +559,72 @@ var SystemAddress = class extends DataType {
572
559
  return addresses;
573
560
  }
574
561
  /**
575
- * Writes the Address data type to a binary stream.
576
- * @param stream The binary stream to write to.
577
- * @param value The value to write.
578
- */
562
+ * Writes the Address data type to a binary stream.
563
+ * @param stream The binary stream to write to.
564
+ * @param value The value to write.
565
+ */
579
566
  static write(stream) {
580
567
  const addresses = [
581
- { address: "127.0.0.1", port: 0, version: 4 }
568
+ {
569
+ address: "127.0.0.1",
570
+ port: 0,
571
+ version: 4
572
+ }
582
573
  ];
583
574
  for (let index = 0; index < 20; index++) {
584
- Address.write(
585
- stream,
586
- addresses[index] || { address: "0.0.0.0", port: 0, version: 4 }
587
- );
575
+ Address.write(stream, addresses[index] || {
576
+ address: "0.0.0.0",
577
+ port: 0,
578
+ version: 4
579
+ });
588
580
  }
589
581
  }
590
582
  };
591
583
 
592
584
  // src/proto/data/base.ts
593
585
  var import_binarystream4 = require("@serenityjs/binarystream");
594
- var BasePacket = class extends import_binarystream4.BinaryStream {
586
+ var BasePacket = class BasePacket2 extends import_binarystream4.BinaryStream {
587
+ static {
588
+ __name(this, "BasePacket");
589
+ }
595
590
  /**
596
- * The packet id.
597
- */
591
+ * The packet id.
592
+ */
598
593
  static id;
599
594
  /**
600
- * The packet id data type.
601
- */
595
+ * The packet id data type.
596
+ */
602
597
  static id_type = import_binarystream4.Uint8;
603
598
  /**
604
- * Flushes the binary stream.
605
- */
599
+ * Flushes the binary stream.
600
+ */
606
601
  flush() {
607
602
  this.binary = [];
608
603
  }
609
604
  /**
610
- * Gets the packet id.
611
- * @returns The packet id.
612
- */
605
+ * Gets the packet id.
606
+ * @returns The packet id.
607
+ */
613
608
  getId() {
614
609
  throw new Error("BasePacket.getId() is not implemented.");
615
610
  }
616
611
  /**
617
- * Gets the packet id data type.
618
- * @returns The packet id data type.
619
- */
612
+ * Gets the packet id data type.
613
+ * @returns The packet id data type.
614
+ */
620
615
  getIdType() {
621
616
  throw new Error("BasePacket.getIdType() is not implemented.");
622
617
  }
623
618
  /**
624
- * Serializes the packet.
625
- * @returns The serialized packet.
626
- */
619
+ * Serializes the packet.
620
+ * @returns The serialized packet.
621
+ */
627
622
  serialize() {
628
623
  throw new Error("BasePacket.serialize() is not implemented.");
629
624
  }
630
625
  /**
631
- * Deserializes the packet.
632
- */
626
+ * Deserializes the packet.
627
+ */
633
628
  deserialize() {
634
629
  throw new Error("BasePacket.deserialize() is not implemented.");
635
630
  }
@@ -637,211 +632,481 @@ var BasePacket = class extends import_binarystream4.BinaryStream {
637
632
 
638
633
  // src/proto/data/unconnected-ping.ts
639
634
  var import_binarystream5 = require("@serenityjs/binarystream");
640
- var UnconnectedPing = class extends BasePacket {
635
+ function _ts_decorate(decorators, target, key, desc) {
636
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
637
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
638
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
639
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
640
+ }
641
+ __name(_ts_decorate, "_ts_decorate");
642
+ function _ts_metadata(k, v) {
643
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
644
+ }
645
+ __name(_ts_metadata, "_ts_metadata");
646
+ var UnconnectedPing = class UnconnectedPing2 extends BasePacket {
647
+ static {
648
+ __name(this, "UnconnectedPing");
649
+ }
650
+ /**
651
+ * The timestamp of the ping.
652
+ */
641
653
  timestamp;
654
+ /**
655
+ * The magic bytes of the ping.
656
+ */
642
657
  magic;
658
+ /**
659
+ * The client guid of the ping.
660
+ */
643
661
  client;
644
662
  };
645
- __decorateClass([
646
- Serialize(import_binarystream5.Long)
647
- ], UnconnectedPing.prototype, "timestamp", 2);
648
- __decorateClass([
649
- Serialize(Magic)
650
- ], UnconnectedPing.prototype, "magic", 2);
651
- __decorateClass([
652
- Serialize(import_binarystream5.Long)
653
- ], UnconnectedPing.prototype, "client", 2);
654
- UnconnectedPing = __decorateClass([
655
- Proto(1 /* UnconnectedPing */)
663
+ _ts_decorate([
664
+ Serialize(import_binarystream5.Long),
665
+ _ts_metadata("design:type", typeof BigInt === "undefined" ? Object : BigInt)
666
+ ], UnconnectedPing.prototype, "timestamp", void 0);
667
+ _ts_decorate([
668
+ Serialize(Magic),
669
+ _ts_metadata("design:type", typeof Buffer === "undefined" ? Object : Buffer)
670
+ ], UnconnectedPing.prototype, "magic", void 0);
671
+ _ts_decorate([
672
+ Serialize(import_binarystream5.Long),
673
+ _ts_metadata("design:type", typeof BigInt === "undefined" ? Object : BigInt)
674
+ ], UnconnectedPing.prototype, "client", void 0);
675
+ UnconnectedPing = _ts_decorate([
676
+ Proto(Packet.UnconnectedPing)
656
677
  ], UnconnectedPing);
657
678
 
658
679
  // src/proto/data/unconnected-pong.ts
659
680
  var import_binarystream6 = require("@serenityjs/binarystream");
660
- var UnconnectedPong = class extends BasePacket {
681
+ function _ts_decorate2(decorators, target, key, desc) {
682
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
683
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
684
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
685
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
686
+ }
687
+ __name(_ts_decorate2, "_ts_decorate");
688
+ function _ts_metadata2(k, v) {
689
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
690
+ }
691
+ __name(_ts_metadata2, "_ts_metadata");
692
+ var UnconnectedPong = class UnconnectedPong2 extends BasePacket {
693
+ static {
694
+ __name(this, "UnconnectedPong");
695
+ }
696
+ /**
697
+ * The timestamp of the pong.
698
+ */
661
699
  timestamp;
700
+ /**
701
+ * The server guid of the pong.
702
+ */
662
703
  guid;
704
+ /**
705
+ * The magic bytes of the pong.
706
+ */
663
707
  magic;
708
+ /**
709
+ * The server message of the pong.
710
+ */
664
711
  message;
665
712
  };
666
- __decorateClass([
667
- Serialize(import_binarystream6.Long)
668
- ], UnconnectedPong.prototype, "timestamp", 2);
669
- __decorateClass([
670
- Serialize(import_binarystream6.Long)
671
- ], UnconnectedPong.prototype, "guid", 2);
672
- __decorateClass([
673
- Serialize(Magic)
674
- ], UnconnectedPong.prototype, "magic", 2);
675
- __decorateClass([
676
- Serialize(import_binarystream6.String16)
677
- ], UnconnectedPong.prototype, "message", 2);
678
- UnconnectedPong = __decorateClass([
679
- Proto(28 /* UnconnectedPong */)
713
+ _ts_decorate2([
714
+ Serialize(import_binarystream6.Long),
715
+ _ts_metadata2("design:type", typeof BigInt === "undefined" ? Object : BigInt)
716
+ ], UnconnectedPong.prototype, "timestamp", void 0);
717
+ _ts_decorate2([
718
+ Serialize(import_binarystream6.Long),
719
+ _ts_metadata2("design:type", typeof BigInt === "undefined" ? Object : BigInt)
720
+ ], UnconnectedPong.prototype, "guid", void 0);
721
+ _ts_decorate2([
722
+ Serialize(Magic),
723
+ _ts_metadata2("design:type", typeof Buffer === "undefined" ? Object : Buffer)
724
+ ], UnconnectedPong.prototype, "magic", void 0);
725
+ _ts_decorate2([
726
+ Serialize(import_binarystream6.String16),
727
+ _ts_metadata2("design:type", String)
728
+ ], UnconnectedPong.prototype, "message", void 0);
729
+ UnconnectedPong = _ts_decorate2([
730
+ Proto(Packet.UnconnectedPong)
680
731
  ], UnconnectedPong);
681
732
 
682
733
  // src/proto/data/open-connection-request-1.ts
683
734
  var import_binarystream7 = require("@serenityjs/binarystream");
684
- var OpenConnectionRequest1 = class extends BasePacket {
735
+ function _ts_decorate3(decorators, target, key, desc) {
736
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
737
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
738
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
739
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
740
+ }
741
+ __name(_ts_decorate3, "_ts_decorate");
742
+ function _ts_metadata3(k, v) {
743
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
744
+ }
745
+ __name(_ts_metadata3, "_ts_metadata");
746
+ var OpenConnectionRequest1 = class OpenConnectionRequest12 extends BasePacket {
747
+ static {
748
+ __name(this, "OpenConnectionRequest1");
749
+ }
750
+ /**
751
+ * The magic bytes of the request.
752
+ */
685
753
  magic;
754
+ /**
755
+ * The protocol version of the request.
756
+ */
686
757
  protocol;
758
+ /**
759
+ * The maximum transfer unit of the request.
760
+ */
687
761
  mtu;
688
762
  };
689
- __decorateClass([
690
- Serialize(Magic)
691
- ], OpenConnectionRequest1.prototype, "magic", 2);
692
- __decorateClass([
693
- Serialize(import_binarystream7.Uint8)
694
- ], OpenConnectionRequest1.prototype, "protocol", 2);
695
- __decorateClass([
696
- Serialize(MTU)
697
- ], OpenConnectionRequest1.prototype, "mtu", 2);
698
- OpenConnectionRequest1 = __decorateClass([
699
- Proto(5 /* OpenConnectionRequest1 */)
763
+ _ts_decorate3([
764
+ Serialize(Magic),
765
+ _ts_metadata3("design:type", typeof Buffer === "undefined" ? Object : Buffer)
766
+ ], OpenConnectionRequest1.prototype, "magic", void 0);
767
+ _ts_decorate3([
768
+ Serialize(import_binarystream7.Uint8),
769
+ _ts_metadata3("design:type", Number)
770
+ ], OpenConnectionRequest1.prototype, "protocol", void 0);
771
+ _ts_decorate3([
772
+ Serialize(MTU),
773
+ _ts_metadata3("design:type", Number)
774
+ ], OpenConnectionRequest1.prototype, "mtu", void 0);
775
+ OpenConnectionRequest1 = _ts_decorate3([
776
+ Proto(Packet.OpenConnectionRequest1)
700
777
  ], OpenConnectionRequest1);
701
778
 
702
779
  // src/proto/data/open-connection-reply-1.ts
703
780
  var import_binarystream8 = require("@serenityjs/binarystream");
704
- var OpenConnectionReply1 = class extends BasePacket {
781
+ function _ts_decorate4(decorators, target, key, desc) {
782
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
783
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
784
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
785
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
786
+ }
787
+ __name(_ts_decorate4, "_ts_decorate");
788
+ function _ts_metadata4(k, v) {
789
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
790
+ }
791
+ __name(_ts_metadata4, "_ts_metadata");
792
+ var OpenConnectionReply1 = class OpenConnectionReply12 extends BasePacket {
793
+ static {
794
+ __name(this, "OpenConnectionReply1");
795
+ }
796
+ /**
797
+ * The magic bytes of the reply.
798
+ */
705
799
  magic;
800
+ /**
801
+ * The server guid of the reply.
802
+ */
706
803
  guid;
804
+ /**
805
+ * If raknet is using security.
806
+ */
707
807
  security;
808
+ /**
809
+ * The maximum transfer unit of the reply.
810
+ */
708
811
  mtu;
709
812
  };
710
- __decorateClass([
711
- Serialize(Magic)
712
- ], OpenConnectionReply1.prototype, "magic", 2);
713
- __decorateClass([
714
- Serialize(import_binarystream8.Long)
715
- ], OpenConnectionReply1.prototype, "guid", 2);
716
- __decorateClass([
717
- Serialize(import_binarystream8.Bool)
718
- ], OpenConnectionReply1.prototype, "security", 2);
719
- __decorateClass([
720
- Serialize(import_binarystream8.Short)
721
- ], OpenConnectionReply1.prototype, "mtu", 2);
722
- OpenConnectionReply1 = __decorateClass([
723
- Proto(6 /* OpenConnectionReply1 */)
813
+ _ts_decorate4([
814
+ Serialize(Magic),
815
+ _ts_metadata4("design:type", typeof Buffer === "undefined" ? Object : Buffer)
816
+ ], OpenConnectionReply1.prototype, "magic", void 0);
817
+ _ts_decorate4([
818
+ Serialize(import_binarystream8.Long),
819
+ _ts_metadata4("design:type", typeof BigInt === "undefined" ? Object : BigInt)
820
+ ], OpenConnectionReply1.prototype, "guid", void 0);
821
+ _ts_decorate4([
822
+ Serialize(import_binarystream8.Bool),
823
+ _ts_metadata4("design:type", Boolean)
824
+ ], OpenConnectionReply1.prototype, "security", void 0);
825
+ _ts_decorate4([
826
+ Serialize(import_binarystream8.Short),
827
+ _ts_metadata4("design:type", Number)
828
+ ], OpenConnectionReply1.prototype, "mtu", void 0);
829
+ OpenConnectionReply1 = _ts_decorate4([
830
+ Proto(Packet.OpenConnectionReply1)
724
831
  ], OpenConnectionReply1);
725
832
 
726
833
  // src/proto/data/open-connection-request-2.ts
727
834
  var import_binarystream9 = require("@serenityjs/binarystream");
728
- var OpenConnectionRequest2 = class extends BasePacket {
835
+ function _ts_decorate5(decorators, target, key, desc) {
836
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
837
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
838
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
839
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
840
+ }
841
+ __name(_ts_decorate5, "_ts_decorate");
842
+ function _ts_metadata5(k, v) {
843
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
844
+ }
845
+ __name(_ts_metadata5, "_ts_metadata");
846
+ var OpenConnectionRequest2 = class OpenConnectionRequest22 extends BasePacket {
847
+ static {
848
+ __name(this, "OpenConnectionRequest2");
849
+ }
850
+ /**
851
+ * The magic bytes of the request.
852
+ */
729
853
  magic;
854
+ /**
855
+ * The protocol version of the request.
856
+ */
730
857
  address;
858
+ /**
859
+ * The mtu of the request.
860
+ */
731
861
  mtu;
862
+ /**
863
+ * The client guid of the request.
864
+ */
732
865
  client;
733
866
  };
734
- __decorateClass([
735
- Serialize(Magic)
736
- ], OpenConnectionRequest2.prototype, "magic", 2);
737
- __decorateClass([
738
- Serialize(Address)
739
- ], OpenConnectionRequest2.prototype, "address", 2);
740
- __decorateClass([
741
- Serialize(import_binarystream9.Short)
742
- ], OpenConnectionRequest2.prototype, "mtu", 2);
743
- __decorateClass([
744
- Serialize(import_binarystream9.Long)
745
- ], OpenConnectionRequest2.prototype, "client", 2);
746
- OpenConnectionRequest2 = __decorateClass([
747
- Proto(7 /* OpenConnectionRequest2 */)
867
+ _ts_decorate5([
868
+ Serialize(Magic),
869
+ _ts_metadata5("design:type", typeof Buffer === "undefined" ? Object : Buffer)
870
+ ], OpenConnectionRequest2.prototype, "magic", void 0);
871
+ _ts_decorate5([
872
+ Serialize(Address),
873
+ _ts_metadata5("design:type", typeof Address === "undefined" ? Object : Address)
874
+ ], OpenConnectionRequest2.prototype, "address", void 0);
875
+ _ts_decorate5([
876
+ Serialize(import_binarystream9.Short),
877
+ _ts_metadata5("design:type", Number)
878
+ ], OpenConnectionRequest2.prototype, "mtu", void 0);
879
+ _ts_decorate5([
880
+ Serialize(import_binarystream9.Long),
881
+ _ts_metadata5("design:type", typeof BigInt === "undefined" ? Object : BigInt)
882
+ ], OpenConnectionRequest2.prototype, "client", void 0);
883
+ OpenConnectionRequest2 = _ts_decorate5([
884
+ Proto(Packet.OpenConnectionRequest2)
748
885
  ], OpenConnectionRequest2);
749
886
 
750
887
  // src/proto/data/open-connection-reply-2.ts
751
888
  var import_binarystream10 = require("@serenityjs/binarystream");
752
- var OpenConnectionReply2 = class extends BasePacket {
889
+ function _ts_decorate6(decorators, target, key, desc) {
890
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
891
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
892
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
893
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
894
+ }
895
+ __name(_ts_decorate6, "_ts_decorate");
896
+ function _ts_metadata6(k, v) {
897
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
898
+ }
899
+ __name(_ts_metadata6, "_ts_metadata");
900
+ var OpenConnectionReply2 = class OpenConnectionReply22 extends BasePacket {
901
+ static {
902
+ __name(this, "OpenConnectionReply2");
903
+ }
904
+ /**
905
+ * The magic bytes of the reply.
906
+ */
753
907
  magic;
908
+ /**
909
+ * The server guid of the reply.
910
+ */
754
911
  guid;
912
+ /**
913
+ * Client adrress.
914
+ */
755
915
  address;
916
+ /**
917
+ * The maximum transfer unit of the reply.
918
+ */
756
919
  mtu;
920
+ /**
921
+ * If raknet is using encryption.
922
+ */
757
923
  encryption;
758
924
  };
759
- __decorateClass([
760
- Serialize(Magic)
761
- ], OpenConnectionReply2.prototype, "magic", 2);
762
- __decorateClass([
763
- Serialize(import_binarystream10.Long)
764
- ], OpenConnectionReply2.prototype, "guid", 2);
765
- __decorateClass([
766
- Serialize(Address)
767
- ], OpenConnectionReply2.prototype, "address", 2);
768
- __decorateClass([
769
- Serialize(import_binarystream10.Short)
770
- ], OpenConnectionReply2.prototype, "mtu", 2);
771
- __decorateClass([
772
- Serialize(import_binarystream10.Bool)
773
- ], OpenConnectionReply2.prototype, "encryption", 2);
774
- OpenConnectionReply2 = __decorateClass([
775
- Proto(8 /* OpenConnectionReply2 */)
925
+ _ts_decorate6([
926
+ Serialize(Magic),
927
+ _ts_metadata6("design:type", typeof Buffer === "undefined" ? Object : Buffer)
928
+ ], OpenConnectionReply2.prototype, "magic", void 0);
929
+ _ts_decorate6([
930
+ Serialize(import_binarystream10.Long),
931
+ _ts_metadata6("design:type", typeof BigInt === "undefined" ? Object : BigInt)
932
+ ], OpenConnectionReply2.prototype, "guid", void 0);
933
+ _ts_decorate6([
934
+ Serialize(Address),
935
+ _ts_metadata6("design:type", typeof Address === "undefined" ? Object : Address)
936
+ ], OpenConnectionReply2.prototype, "address", void 0);
937
+ _ts_decorate6([
938
+ Serialize(import_binarystream10.Short),
939
+ _ts_metadata6("design:type", Number)
940
+ ], OpenConnectionReply2.prototype, "mtu", void 0);
941
+ _ts_decorate6([
942
+ Serialize(import_binarystream10.Bool),
943
+ _ts_metadata6("design:type", Boolean)
944
+ ], OpenConnectionReply2.prototype, "encryption", void 0);
945
+ OpenConnectionReply2 = _ts_decorate6([
946
+ Proto(Packet.OpenConnectionReply2)
776
947
  ], OpenConnectionReply2);
777
948
 
778
949
  // src/proto/data/connected-pong.ts
779
950
  var import_binarystream11 = require("@serenityjs/binarystream");
780
- var ConnectedPong = class extends BasePacket {
951
+ function _ts_decorate7(decorators, target, key, desc) {
952
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
953
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
954
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
955
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
956
+ }
957
+ __name(_ts_decorate7, "_ts_decorate");
958
+ function _ts_metadata7(k, v) {
959
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
960
+ }
961
+ __name(_ts_metadata7, "_ts_metadata");
962
+ var ConnectedPong = class ConnectedPong2 extends BasePacket {
963
+ static {
964
+ __name(this, "ConnectedPong");
965
+ }
966
+ /**
967
+ * The timestamp of the ping.
968
+ */
781
969
  pingTimestamp;
970
+ /**
971
+ * The timestamp of the pong.
972
+ */
782
973
  timestamp;
783
974
  };
784
- __decorateClass([
785
- Serialize(import_binarystream11.Long)
786
- ], ConnectedPong.prototype, "pingTimestamp", 2);
787
- __decorateClass([
788
- Serialize(import_binarystream11.Long)
789
- ], ConnectedPong.prototype, "timestamp", 2);
790
- ConnectedPong = __decorateClass([
791
- Proto(3 /* ConnectedPong */)
975
+ _ts_decorate7([
976
+ Serialize(import_binarystream11.Long),
977
+ _ts_metadata7("design:type", typeof BigInt === "undefined" ? Object : BigInt)
978
+ ], ConnectedPong.prototype, "pingTimestamp", void 0);
979
+ _ts_decorate7([
980
+ Serialize(import_binarystream11.Long),
981
+ _ts_metadata7("design:type", typeof BigInt === "undefined" ? Object : BigInt)
982
+ ], ConnectedPong.prototype, "timestamp", void 0);
983
+ ConnectedPong = _ts_decorate7([
984
+ Proto(Packet.ConnectedPong)
792
985
  ], ConnectedPong);
793
986
 
794
987
  // src/proto/data/connected-ping.ts
795
988
  var import_binarystream12 = require("@serenityjs/binarystream");
796
- var ConnectedPing = class extends BasePacket {
989
+ function _ts_decorate8(decorators, target, key, desc) {
990
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
991
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
992
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
993
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
994
+ }
995
+ __name(_ts_decorate8, "_ts_decorate");
996
+ function _ts_metadata8(k, v) {
997
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
998
+ }
999
+ __name(_ts_metadata8, "_ts_metadata");
1000
+ var ConnectedPing = class ConnectedPing2 extends BasePacket {
1001
+ static {
1002
+ __name(this, "ConnectedPing");
1003
+ }
1004
+ /**
1005
+ * The timestamp of the ping.
1006
+ */
797
1007
  timestamp;
798
1008
  };
799
- __decorateClass([
800
- Serialize(import_binarystream12.Long)
801
- ], ConnectedPing.prototype, "timestamp", 2);
802
- ConnectedPing = __decorateClass([
803
- Proto(0 /* ConnectedPing */)
1009
+ _ts_decorate8([
1010
+ Serialize(import_binarystream12.Long),
1011
+ _ts_metadata8("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1012
+ ], ConnectedPing.prototype, "timestamp", void 0);
1013
+ ConnectedPing = _ts_decorate8([
1014
+ Proto(Packet.ConnectedPing)
804
1015
  ], ConnectedPing);
805
1016
 
806
1017
  // src/proto/data/connection-request.ts
807
1018
  var import_binarystream13 = require("@serenityjs/binarystream");
808
- var ConnectionRequest = class extends BasePacket {
1019
+ function _ts_decorate9(decorators, target, key, desc) {
1020
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1021
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1022
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1023
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1024
+ }
1025
+ __name(_ts_decorate9, "_ts_decorate");
1026
+ function _ts_metadata9(k, v) {
1027
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1028
+ }
1029
+ __name(_ts_metadata9, "_ts_metadata");
1030
+ var ConnectionRequest = class ConnectionRequest2 extends BasePacket {
1031
+ static {
1032
+ __name(this, "ConnectionRequest");
1033
+ }
1034
+ /**
1035
+ * The client guid of the request.
1036
+ */
809
1037
  client;
1038
+ /**
1039
+ * The timestamp of the request.
1040
+ */
810
1041
  timestamp;
811
1042
  };
812
- __decorateClass([
813
- Serialize(import_binarystream13.Long)
814
- ], ConnectionRequest.prototype, "client", 2);
815
- __decorateClass([
816
- Serialize(import_binarystream13.Long)
817
- ], ConnectionRequest.prototype, "timestamp", 2);
818
- ConnectionRequest = __decorateClass([
819
- Proto(9 /* ConnectionRequest */)
1043
+ _ts_decorate9([
1044
+ Serialize(import_binarystream13.Long),
1045
+ _ts_metadata9("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1046
+ ], ConnectionRequest.prototype, "client", void 0);
1047
+ _ts_decorate9([
1048
+ Serialize(import_binarystream13.Long),
1049
+ _ts_metadata9("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1050
+ ], ConnectionRequest.prototype, "timestamp", void 0);
1051
+ ConnectionRequest = _ts_decorate9([
1052
+ Proto(Packet.ConnectionRequest)
820
1053
  ], ConnectionRequest);
821
1054
 
822
1055
  // src/proto/data/frame-set.ts
823
1056
  var import_binarystream14 = require("@serenityjs/binarystream");
824
- var FrameSet = class extends BasePacket {
1057
+ function _ts_decorate10(decorators, target, key, desc) {
1058
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1059
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1060
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1061
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1062
+ }
1063
+ __name(_ts_decorate10, "_ts_decorate");
1064
+ function _ts_metadata10(k, v) {
1065
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1066
+ }
1067
+ __name(_ts_metadata10, "_ts_metadata");
1068
+ var FrameSet = class FrameSet2 extends BasePacket {
1069
+ static {
1070
+ __name(this, "FrameSet");
1071
+ }
1072
+ /**
1073
+ * The sequence of the frame set.
1074
+ */
825
1075
  sequence;
1076
+ /**
1077
+ * The frames of the frame set.
1078
+ */
826
1079
  frames;
827
1080
  };
828
- __decorateClass([
829
- Serialize(import_binarystream14.Uint24, import_binarystream14.Endianness.Little)
830
- ], FrameSet.prototype, "sequence", 2);
831
- __decorateClass([
832
- Serialize(Frame)
833
- ], FrameSet.prototype, "frames", 2);
834
- FrameSet = __decorateClass([
835
- Proto(128 /* FrameSet */)
1081
+ _ts_decorate10([
1082
+ Serialize(import_binarystream14.Uint24, import_binarystream14.Endianness.Little),
1083
+ _ts_metadata10("design:type", Number)
1084
+ ], FrameSet.prototype, "sequence", void 0);
1085
+ _ts_decorate10([
1086
+ Serialize(Frame),
1087
+ _ts_metadata10("design:type", typeof Array === "undefined" ? Object : Array)
1088
+ ], FrameSet.prototype, "frames", void 0);
1089
+ FrameSet = _ts_decorate10([
1090
+ Proto(Packet.FrameSet)
836
1091
  ], FrameSet);
837
1092
 
838
1093
  // src/proto/data/ack.ts
839
1094
  var import_binarystream15 = require("@serenityjs/binarystream");
840
- var Ack = class extends BasePacket {
1095
+ function _ts_decorate11(decorators, target, key, desc) {
1096
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1097
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1098
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1099
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1100
+ }
1101
+ __name(_ts_decorate11, "_ts_decorate");
1102
+ var Ack = class Ack2 extends BasePacket {
1103
+ static {
1104
+ __name(this, "Ack");
1105
+ }
841
1106
  sequences = [];
842
1107
  // Override encode due to custom logic, maybe move into own type?
843
1108
  serialize() {
844
- this.writeUint8(Ack.id);
1109
+ this.writeUint8(Ack2.id);
845
1110
  const stream = new import_binarystream15.BinaryStream();
846
1111
  const count = this.sequences.length;
847
1112
  let records = 0;
@@ -902,17 +1167,27 @@ var Ack = class extends BasePacket {
902
1167
  return this;
903
1168
  }
904
1169
  };
905
- Ack = __decorateClass([
906
- Proto(192 /* Ack */)
1170
+ Ack = _ts_decorate11([
1171
+ Proto(Packet.Ack)
907
1172
  ], Ack);
908
1173
 
909
1174
  // src/proto/data/nack.ts
910
1175
  var import_binarystream16 = require("@serenityjs/binarystream");
911
- var Nack = class extends BasePacket {
1176
+ function _ts_decorate12(decorators, target, key, desc) {
1177
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1178
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1179
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1180
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1181
+ }
1182
+ __name(_ts_decorate12, "_ts_decorate");
1183
+ var Nack = class Nack2 extends BasePacket {
1184
+ static {
1185
+ __name(this, "Nack");
1186
+ }
912
1187
  sequences = [];
913
1188
  // Override encode due to custom logic, maybe move into own type?
914
1189
  serialize() {
915
- this.writeUint8(Nack.id);
1190
+ this.writeUint8(Nack2.id);
916
1191
  const stream = new import_binarystream16.BinaryStream();
917
1192
  const count = this.sequences.length;
918
1193
  let records = 0;
@@ -973,87 +1248,178 @@ var Nack = class extends BasePacket {
973
1248
  return this;
974
1249
  }
975
1250
  };
976
- Nack = __decorateClass([
977
- Proto(160 /* Nack */)
1251
+ Nack = _ts_decorate12([
1252
+ Proto(Packet.Nack)
978
1253
  ], Nack);
979
1254
 
980
1255
  // src/proto/data/disconnect.ts
981
- var Disconnect = class extends BasePacket {
1256
+ function _ts_decorate13(decorators, target, key, desc) {
1257
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1258
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1259
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1260
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1261
+ }
1262
+ __name(_ts_decorate13, "_ts_decorate");
1263
+ var Disconnect = class Disconnect2 extends BasePacket {
1264
+ static {
1265
+ __name(this, "Disconnect");
1266
+ }
982
1267
  };
983
- Disconnect = __decorateClass([
984
- Proto(21 /* Disconnect */)
1268
+ Disconnect = _ts_decorate13([
1269
+ Proto(Packet.Disconnect)
985
1270
  ], Disconnect);
986
1271
 
987
1272
  // src/proto/data/incompatible-protocol.ts
988
1273
  var import_binarystream17 = require("@serenityjs/binarystream");
989
- var IncompatibleProtocolVersion = class extends BasePacket {
1274
+ function _ts_decorate14(decorators, target, key, desc) {
1275
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1276
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1277
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1278
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1279
+ }
1280
+ __name(_ts_decorate14, "_ts_decorate");
1281
+ function _ts_metadata11(k, v) {
1282
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1283
+ }
1284
+ __name(_ts_metadata11, "_ts_metadata");
1285
+ var IncompatibleProtocolVersion = class IncompatibleProtocolVersion2 extends BasePacket {
1286
+ static {
1287
+ __name(this, "IncompatibleProtocolVersion");
1288
+ }
990
1289
  protocol;
991
1290
  magic;
992
1291
  guid;
993
1292
  };
994
- __decorateClass([
995
- Serialize(import_binarystream17.Uint8)
996
- ], IncompatibleProtocolVersion.prototype, "protocol", 2);
997
- __decorateClass([
998
- Serialize(Magic)
999
- ], IncompatibleProtocolVersion.prototype, "magic", 2);
1000
- __decorateClass([
1001
- Serialize(import_binarystream17.Uint64)
1002
- ], IncompatibleProtocolVersion.prototype, "guid", 2);
1003
- IncompatibleProtocolVersion = __decorateClass([
1004
- Proto(25 /* IncompatibleProtocolVersion */)
1293
+ _ts_decorate14([
1294
+ Serialize(import_binarystream17.Uint8),
1295
+ _ts_metadata11("design:type", Number)
1296
+ ], IncompatibleProtocolVersion.prototype, "protocol", void 0);
1297
+ _ts_decorate14([
1298
+ Serialize(Magic),
1299
+ _ts_metadata11("design:type", typeof Buffer === "undefined" ? Object : Buffer)
1300
+ ], IncompatibleProtocolVersion.prototype, "magic", void 0);
1301
+ _ts_decorate14([
1302
+ Serialize(import_binarystream17.Uint64),
1303
+ _ts_metadata11("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1304
+ ], IncompatibleProtocolVersion.prototype, "guid", void 0);
1305
+ IncompatibleProtocolVersion = _ts_decorate14([
1306
+ Proto(Packet.IncompatibleProtocolVersion)
1005
1307
  ], IncompatibleProtocolVersion);
1006
1308
 
1007
1309
  // src/proto/data/connection-request-accepted.ts
1008
1310
  var import_binarystream18 = require("@serenityjs/binarystream");
1009
- var ConnectionRequestAccepted = class extends BasePacket {
1311
+ function _ts_decorate15(decorators, target, key, desc) {
1312
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1313
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1314
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1315
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1316
+ }
1317
+ __name(_ts_decorate15, "_ts_decorate");
1318
+ function _ts_metadata12(k, v) {
1319
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1320
+ }
1321
+ __name(_ts_metadata12, "_ts_metadata");
1322
+ var ConnectionRequestAccepted = class ConnectionRequestAccepted2 extends BasePacket {
1323
+ static {
1324
+ __name(this, "ConnectionRequestAccepted");
1325
+ }
1326
+ /**
1327
+ * The client address of the request.
1328
+ */
1010
1329
  address;
1330
+ /**
1331
+ * The system index of the request.
1332
+ */
1011
1333
  systemIndex;
1334
+ /**
1335
+ * The system address of the request.
1336
+ */
1012
1337
  systemAddress;
1338
+ /**
1339
+ * The request timestamp of the request.
1340
+ */
1013
1341
  requestTimestamp;
1342
+ /**
1343
+ * The timestamp of the request.
1344
+ */
1014
1345
  timestamp;
1015
1346
  };
1016
- __decorateClass([
1017
- Serialize(Address)
1018
- ], ConnectionRequestAccepted.prototype, "address", 2);
1019
- __decorateClass([
1020
- Serialize(import_binarystream18.Short)
1021
- ], ConnectionRequestAccepted.prototype, "systemIndex", 2);
1022
- __decorateClass([
1023
- Serialize(SystemAddress)
1024
- ], ConnectionRequestAccepted.prototype, "systemAddress", 2);
1025
- __decorateClass([
1026
- Serialize(import_binarystream18.Long)
1027
- ], ConnectionRequestAccepted.prototype, "requestTimestamp", 2);
1028
- __decorateClass([
1029
- Serialize(import_binarystream18.Long)
1030
- ], ConnectionRequestAccepted.prototype, "timestamp", 2);
1031
- ConnectionRequestAccepted = __decorateClass([
1032
- Proto(16 /* ConnectionRequestAccepted */)
1347
+ _ts_decorate15([
1348
+ Serialize(Address),
1349
+ _ts_metadata12("design:type", typeof Address === "undefined" ? Object : Address)
1350
+ ], ConnectionRequestAccepted.prototype, "address", void 0);
1351
+ _ts_decorate15([
1352
+ Serialize(import_binarystream18.Short),
1353
+ _ts_metadata12("design:type", Number)
1354
+ ], ConnectionRequestAccepted.prototype, "systemIndex", void 0);
1355
+ _ts_decorate15([
1356
+ Serialize(SystemAddress),
1357
+ _ts_metadata12("design:type", typeof Array === "undefined" ? Object : Array)
1358
+ ], ConnectionRequestAccepted.prototype, "systemAddress", void 0);
1359
+ _ts_decorate15([
1360
+ Serialize(import_binarystream18.Long),
1361
+ _ts_metadata12("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1362
+ ], ConnectionRequestAccepted.prototype, "requestTimestamp", void 0);
1363
+ _ts_decorate15([
1364
+ Serialize(import_binarystream18.Long),
1365
+ _ts_metadata12("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1366
+ ], ConnectionRequestAccepted.prototype, "timestamp", void 0);
1367
+ ConnectionRequestAccepted = _ts_decorate15([
1368
+ Proto(Packet.ConnectionRequestAccepted)
1033
1369
  ], ConnectionRequestAccepted);
1034
1370
 
1035
1371
  // src/proto/data/new-incoming-connection.ts
1036
1372
  var import_binarystream19 = require("@serenityjs/binarystream");
1037
- var NewIncomingConnection = class extends BasePacket {
1373
+ function _ts_decorate16(decorators, target, key, desc) {
1374
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1375
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
1376
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1377
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
1378
+ }
1379
+ __name(_ts_decorate16, "_ts_decorate");
1380
+ function _ts_metadata13(k, v) {
1381
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
1382
+ }
1383
+ __name(_ts_metadata13, "_ts_metadata");
1384
+ var NewIncomingConnection = class NewIncomingConnection2 extends BasePacket {
1385
+ static {
1386
+ __name(this, "NewIncomingConnection");
1387
+ }
1388
+ /**
1389
+ * the server adress of the reply.
1390
+ */
1038
1391
  serverAddress;
1392
+ /**
1393
+ * unknown what this is used for.
1394
+ */
1039
1395
  internalAddress;
1396
+ /**
1397
+ * The incoming timestamp of the reply.
1398
+ */
1040
1399
  incomingTimestamp;
1400
+ /**
1401
+ * The server timestamp of the reply.
1402
+ */
1041
1403
  serverTimestamp;
1042
1404
  };
1043
- __decorateClass([
1044
- Serialize(Address)
1045
- ], NewIncomingConnection.prototype, "serverAddress", 2);
1046
- __decorateClass([
1047
- Serialize(Address)
1048
- ], NewIncomingConnection.prototype, "internalAddress", 2);
1049
- __decorateClass([
1050
- Serialize(import_binarystream19.Long)
1051
- ], NewIncomingConnection.prototype, "incomingTimestamp", 2);
1052
- __decorateClass([
1053
- Serialize(import_binarystream19.Long)
1054
- ], NewIncomingConnection.prototype, "serverTimestamp", 2);
1055
- NewIncomingConnection = __decorateClass([
1056
- Proto(19 /* NewIncomingConnection */)
1405
+ _ts_decorate16([
1406
+ Serialize(Address),
1407
+ _ts_metadata13("design:type", String)
1408
+ ], NewIncomingConnection.prototype, "serverAddress", void 0);
1409
+ _ts_decorate16([
1410
+ Serialize(Address),
1411
+ _ts_metadata13("design:type", String)
1412
+ ], NewIncomingConnection.prototype, "internalAddress", void 0);
1413
+ _ts_decorate16([
1414
+ Serialize(import_binarystream19.Long),
1415
+ _ts_metadata13("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1416
+ ], NewIncomingConnection.prototype, "incomingTimestamp", void 0);
1417
+ _ts_decorate16([
1418
+ Serialize(import_binarystream19.Long),
1419
+ _ts_metadata13("design:type", typeof BigInt === "undefined" ? Object : BigInt)
1420
+ ], NewIncomingConnection.prototype, "serverTimestamp", void 0);
1421
+ NewIncomingConnection = _ts_decorate16([
1422
+ Proto(Packet.NewIncomingConnection)
1057
1423
  ], NewIncomingConnection);
1058
1424
 
1059
1425
  // src/server/raknet.ts
@@ -1073,30 +1439,33 @@ var DGRAM_MTU_OVERHEAD = 36;
1073
1439
 
1074
1440
  // src/server/connection.ts
1075
1441
  var import_binarystream20 = require("@serenityjs/binarystream");
1076
- var Connection = class {
1442
+ var Connection = class Connection2 {
1443
+ static {
1444
+ __name(this, "Connection");
1445
+ }
1077
1446
  /**
1078
- * The server instance
1079
- */
1447
+ * The server instance
1448
+ */
1080
1449
  server;
1081
1450
  /**
1082
- * The status of the connection
1083
- */
1084
- status = 0 /* Connecting */;
1451
+ * The status of the connection
1452
+ */
1453
+ status = Status.Connecting;
1085
1454
  /**
1086
- * The last update time of the connection
1087
- */
1455
+ * The last update time of the connection
1456
+ */
1088
1457
  lastUpdate = Date.now();
1089
1458
  /**
1090
- * The network identifier of the connection
1091
- */
1459
+ * The network identifier of the connection
1460
+ */
1092
1461
  rinfo;
1093
1462
  /**
1094
- * The GUID of the connection
1095
- */
1463
+ * The GUID of the connection
1464
+ */
1096
1465
  guid;
1097
1466
  /**
1098
- * The maximum transmission unit of the connection
1099
- */
1467
+ * The maximum transmission unit of the connection
1468
+ */
1100
1469
  mtu;
1101
1470
  // Inputs
1102
1471
  receivedFrameSequences = /* @__PURE__ */ new Set();
@@ -1115,134 +1484,127 @@ var Connection = class {
1115
1484
  outputsplitIndex = 0;
1116
1485
  outputReliableIndex = 0;
1117
1486
  /**
1118
- * Creates a new connection
1119
- * @param server The server instance
1120
- * @param rinfo The remote info
1121
- * @param guid The GUID
1122
- * @param mtu The maximum transmission unit
1123
- */
1487
+ * Creates a new connection
1488
+ * @param server The server instance
1489
+ * @param rinfo The remote info
1490
+ * @param guid The GUID
1491
+ * @param mtu The maximum transmission unit
1492
+ */
1124
1493
  constructor(server, rinfo, guid, mtu) {
1125
1494
  this.server = server;
1126
1495
  this.rinfo = rinfo;
1127
1496
  this.guid = guid;
1128
1497
  this.mtu = mtu;
1129
- this.inputOrderIndex = Array.from({ length: 32 }).fill(0);
1498
+ this.inputOrderIndex = Array.from({
1499
+ length: 32
1500
+ }).fill(0);
1130
1501
  for (let index = 0; index < 32; index++) {
1131
1502
  this.inputOrderingQueue.set(index, /* @__PURE__ */ new Map());
1132
1503
  }
1133
- this.inputHighestSequenceIndex = Array.from({ length: 32 }).fill(0);
1134
- this.outputOrderIndex = Array.from({ length: 32 }).fill(0);
1135
- this.outputSequenceIndex = Array.from({ length: 32 }).fill(0);
1504
+ this.inputHighestSequenceIndex = Array.from({
1505
+ length: 32
1506
+ }).fill(0);
1507
+ this.outputOrderIndex = Array.from({
1508
+ length: 32
1509
+ }).fill(0);
1510
+ this.outputSequenceIndex = Array.from({
1511
+ length: 32
1512
+ }).fill(0);
1136
1513
  }
1137
1514
  /**
1138
- * Ticks the connection
1139
- */
1515
+ * Ticks the connection
1516
+ */
1140
1517
  tick() {
1141
1518
  if (this.lastUpdate + 5e3 < Date.now()) {
1142
- this.server.logger.warn(
1143
- `Detected stale connection from \xA7c${this.rinfo.address}\xA7r:\xA7c${this.rinfo.port}\xA7r, disconnecting...`
1144
- );
1519
+ this.server.logger.warn(`Detected stale connection from \xA7c${this.rinfo.address}\xA7r:\xA7c${this.rinfo.port}\xA7r, disconnecting...`);
1145
1520
  return this.disconnect();
1146
1521
  }
1147
- if (this.status === 2 /* Disconnecting */ || this.status === 3 /* Disconnected */)
1148
- return;
1522
+ if (this.status === Status.Disconnecting || this.status === Status.Disconnected) return;
1149
1523
  if (this.receivedFrameSequences.size > 0) {
1150
1524
  const ack = new Ack();
1151
- ack.sequences = [...this.receivedFrameSequences];
1152
- for (const sequence of this.receivedFrameSequences)
1153
- this.receivedFrameSequences.delete(sequence);
1525
+ ack.sequences = [
1526
+ ...this.receivedFrameSequences
1527
+ ];
1528
+ for (const sequence of this.receivedFrameSequences) this.receivedFrameSequences.delete(sequence);
1154
1529
  this.server.send(ack.serialize(), this.rinfo);
1155
1530
  }
1156
1531
  if (this.lostFrameSequences.size > 0) {
1157
1532
  const nack = new Nack();
1158
- nack.sequences = [...this.lostFrameSequences];
1159
- for (const sequence of this.lostFrameSequences)
1160
- this.lostFrameSequences.delete(sequence);
1533
+ nack.sequences = [
1534
+ ...this.lostFrameSequences
1535
+ ];
1536
+ for (const sequence of this.lostFrameSequences) this.lostFrameSequences.delete(sequence);
1161
1537
  this.server.send(nack.serialize(), this.rinfo);
1162
1538
  }
1163
1539
  return this.sendQueue(this.outputFrames.size);
1164
1540
  }
1165
1541
  /**
1166
- * Disconnects the connection
1167
- */
1542
+ * Disconnects the connection
1543
+ */
1168
1544
  disconnect() {
1169
- this.status = 2 /* Disconnecting */;
1545
+ this.status = Status.Disconnecting;
1170
1546
  const disconnect = new Disconnect();
1171
1547
  const frame = new Frame();
1172
- frame.reliability = 3 /* ReliableOrdered */;
1548
+ frame.reliability = Reliability.ReliableOrdered;
1173
1549
  frame.orderChannel = 0;
1174
1550
  frame.payload = disconnect.serialize();
1175
- this.sendFrame(frame, 1 /* Immediate */);
1551
+ this.sendFrame(frame, Priority.Immediate);
1176
1552
  void this.server.emit("disconnect", this);
1177
1553
  this.server.connections.delete(this);
1178
- this.status = 3 /* Disconnected */;
1554
+ this.status = Status.Disconnected;
1179
1555
  }
1180
1556
  /**
1181
- * Handles incoming packets
1182
- * @param buffer The packet buffer
1183
- */
1557
+ * Handles incoming packets
1558
+ * @param buffer The packet buffer
1559
+ */
1184
1560
  incoming(buffer) {
1185
1561
  this.lastUpdate = Date.now();
1186
1562
  const header = buffer[0] & 240;
1187
1563
  switch (header) {
1188
1564
  default: {
1189
1565
  const id = header.toString(16).length === 1 ? "0" + header.toString(16) : header.toString(16);
1190
- this.server.logger.debug(
1191
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1192
- );
1193
- return void this.server.emit(
1194
- "error",
1195
- new Error(
1196
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1197
- )
1198
- );
1566
+ this.server.logger.debug(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`);
1567
+ return void this.server.emit("error", new Error(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`));
1199
1568
  }
1200
- case 192 /* Ack */: {
1569
+ case Packet.Ack: {
1201
1570
  this.ack(buffer);
1202
1571
  break;
1203
1572
  }
1204
- case 160 /* Nack */: {
1573
+ case Packet.Nack: {
1205
1574
  this.nack(buffer);
1206
1575
  break;
1207
1576
  }
1208
- case 128 /* Valid */: {
1577
+ case Bitflags.Valid: {
1209
1578
  this.handleIncomingFrameSet(buffer);
1210
1579
  break;
1211
1580
  }
1212
1581
  }
1213
1582
  }
1214
1583
  /**
1215
- * Handles incoming batch packets
1216
- * @param buffer The packet buffer
1217
- */
1584
+ * Handles incoming batch packets
1585
+ * @param buffer The packet buffer
1586
+ */
1218
1587
  incomingBatch(buffer) {
1219
1588
  const header = buffer[0];
1220
- if (this.status === 0 /* Connecting */) {
1589
+ if (this.status === Status.Connecting) {
1221
1590
  switch (header) {
1222
1591
  default: {
1223
1592
  const id = header.toString(16).length === 1 ? "0" + header.toString(16) : header.toString(16);
1224
- this.server.logger.debug(
1225
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1226
- );
1227
- return void this.server.emit(
1228
- "error",
1229
- new Error(
1230
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1231
- )
1232
- );
1593
+ this.server.logger.debug(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`);
1594
+ return void this.server.emit("error", new Error(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`));
1233
1595
  }
1234
- case 21 /* Disconnect */: {
1235
- this.status = 2 /* Disconnecting */;
1596
+ case Packet.Disconnect: {
1597
+ this.status = Status.Disconnecting;
1236
1598
  this.server.connections.delete(this);
1237
- this.status = 3 /* Disconnected */;
1599
+ this.status = Status.Disconnected;
1238
1600
  break;
1239
1601
  }
1240
- case 9 /* ConnectionRequest */: {
1602
+ case Packet.ConnectionRequest: {
1241
1603
  this.handleIncomingConnectionRequest(buffer);
1242
1604
  break;
1243
1605
  }
1244
- case 19 /* NewIncomingConnection */: {
1245
- this.status = 1 /* Connected */;
1606
+ case Packet.NewIncomingConnection: {
1607
+ this.status = Status.Connected;
1246
1608
  void this.server.emit("connect", this);
1247
1609
  break;
1248
1610
  }
@@ -1252,24 +1614,17 @@ var Connection = class {
1252
1614
  switch (header) {
1253
1615
  default: {
1254
1616
  const id = header.toString(16).length === 1 ? "0" + header.toString(16) : header.toString(16);
1255
- this.server.logger.debug(
1256
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1257
- );
1258
- return void this.server.emit(
1259
- "error",
1260
- new Error(
1261
- `Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`
1262
- )
1263
- );
1617
+ this.server.logger.debug(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`);
1618
+ return void this.server.emit("error", new Error(`Received unknown online packet 0x${id} from ${this.rinfo.address}:${this.rinfo.port}!`));
1264
1619
  }
1265
- case 21 /* Disconnect */: {
1266
- this.status = 2 /* Disconnecting */;
1620
+ case Packet.Disconnect: {
1621
+ this.status = Status.Disconnecting;
1267
1622
  void this.server.emit("disconnect", this);
1268
1623
  this.server.connections.delete(this);
1269
- this.status = 3 /* Disconnected */;
1624
+ this.status = Status.Disconnected;
1270
1625
  break;
1271
1626
  }
1272
- case 0 /* ConnectedPing */: {
1627
+ case Packet.ConnectedPing: {
1273
1628
  return this.handleIncomingConnectedPing(buffer);
1274
1629
  }
1275
1630
  case 254: {
@@ -1278,65 +1633,47 @@ var Connection = class {
1278
1633
  }
1279
1634
  }
1280
1635
  /**
1281
- * Handles incoming acks
1282
- * @param buffer The packet buffer
1283
- */
1636
+ * Handles incoming acks
1637
+ * @param buffer The packet buffer
1638
+ */
1284
1639
  ack(buffer) {
1285
1640
  const ack = new Ack(buffer).deserialize();
1286
1641
  for (const sequence of ack.sequences) {
1287
- if (!this.outputBackup.has(sequence))
1288
- this.server.logger.debug(
1289
- `Received ack for unknown sequence ${sequence} from ${this.rinfo.address}:${this.rinfo.port}.`
1290
- );
1642
+ if (!this.outputBackup.has(sequence)) this.server.logger.debug(`Received ack for unknown sequence ${sequence} from ${this.rinfo.address}:${this.rinfo.port}.`);
1291
1643
  this.outputBackup.delete(sequence);
1292
1644
  }
1293
1645
  }
1294
1646
  /**
1295
- * Handles incoming nacks
1296
- * @param buffer The packet buffer
1297
- */
1647
+ * Handles incoming nacks
1648
+ * @param buffer The packet buffer
1649
+ */
1298
1650
  nack(buffer) {
1299
1651
  const nack = new Nack(buffer).deserialize();
1300
1652
  for (const sequence of nack.sequences) {
1301
1653
  const frames = this.outputBackup.get(sequence) ?? [];
1302
1654
  for (const frame of frames) {
1303
- this.sendFrame(frame, 1 /* Immediate */);
1655
+ this.sendFrame(frame, Priority.Immediate);
1304
1656
  }
1305
1657
  }
1306
1658
  }
1307
1659
  /**
1308
- * Handles incoming framesets
1309
- * @param buffer The packet buffer
1310
- */
1660
+ * Handles incoming framesets
1661
+ * @param buffer The packet buffer
1662
+ */
1311
1663
  handleIncomingFrameSet(buffer) {
1312
1664
  const frameset = new FrameSet(buffer).deserialize();
1313
1665
  if (this.receivedFrameSequences.has(frameset.sequence)) {
1314
- this.server.logger.debug(
1315
- `Received duplicate frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`
1316
- );
1317
- return void this.server.emit(
1318
- "error",
1319
- new Error(
1320
- `Recieved duplicate frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`
1321
- )
1322
- );
1666
+ this.server.logger.debug(`Received duplicate frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`);
1667
+ return void this.server.emit("error", new Error(`Recieved duplicate frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`));
1323
1668
  }
1324
1669
  this.lostFrameSequences.delete(frameset.sequence);
1325
1670
  if (frameset.sequence < this.lastInputSequence || frameset.sequence === this.lastInputSequence) {
1326
- this.server.logger.debug(
1327
- `Received out of order frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`
1328
- );
1329
- return void this.server.emit(
1330
- "error",
1331
- new Error(
1332
- `Recieved out of order frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`
1333
- )
1334
- );
1671
+ this.server.logger.debug(`Received out of order frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`);
1672
+ return void this.server.emit("error", new Error(`Recieved out of order frameset ${frameset.sequence} from ${this.rinfo.address}:${this.rinfo.port}!`));
1335
1673
  }
1336
1674
  this.receivedFrameSequences.add(frameset.sequence);
1337
1675
  if (frameset.sequence - this.lastInputSequence > 1) {
1338
- for (let index = this.lastInputSequence + 1; index < frameset.sequence; index++)
1339
- this.lostFrameSequences.add(index);
1676
+ for (let index = this.lastInputSequence + 1; index < frameset.sequence; index++) this.lostFrameSequences.add(index);
1340
1677
  }
1341
1678
  this.lastInputSequence = frameset.sequence;
1342
1679
  for (const frame of frameset.frames) {
@@ -1344,22 +1681,15 @@ var Connection = class {
1344
1681
  }
1345
1682
  }
1346
1683
  /**
1347
- * Handles incoming frames
1348
- * @param frame The frame
1349
- */
1684
+ * Handles incoming frames
1685
+ * @param frame The frame
1686
+ */
1350
1687
  handleFrame(frame) {
1351
1688
  if (frame.isSplit()) return this.handleFragment(frame);
1352
1689
  if (frame.isSequenced()) {
1353
1690
  if (frame.sequenceIndex < this.inputHighestSequenceIndex[frame.orderChannel] || frame.orderIndex < this.inputOrderIndex[frame.orderChannel]) {
1354
- this.server.logger.debug(
1355
- `Recieved out of order frame ${frame.sequenceIndex} from ${this.rinfo.address}:${this.rinfo.port}!`
1356
- );
1357
- return void this.server.emit(
1358
- "error",
1359
- new Error(
1360
- `Recieved out of order frame ${frame.sequenceIndex} from ${this.rinfo.address}:${this.rinfo.port}!`
1361
- )
1362
- );
1691
+ this.server.logger.debug(`Recieved out of order frame ${frame.sequenceIndex} from ${this.rinfo.address}:${this.rinfo.port}!`);
1692
+ return void this.server.emit("error", new Error(`Recieved out of order frame ${frame.sequenceIndex} from ${this.rinfo.address}:${this.rinfo.port}!`));
1363
1693
  }
1364
1694
  this.inputHighestSequenceIndex[frame.orderChannel] = frame.sequenceIndex + 1;
1365
1695
  return this.incomingBatch(frame.payload);
@@ -1369,9 +1699,7 @@ var Connection = class {
1369
1699
  this.inputOrderIndex[frame.orderChannel] = frame.orderIndex + 1;
1370
1700
  this.incomingBatch(frame.payload);
1371
1701
  let index = this.inputOrderIndex[frame.orderChannel];
1372
- const outOfOrderQueue = this.inputOrderingQueue.get(
1373
- frame.orderChannel
1374
- );
1702
+ const outOfOrderQueue = this.inputOrderingQueue.get(frame.orderChannel);
1375
1703
  for (; outOfOrderQueue.has(index); index++) {
1376
1704
  const frame2 = outOfOrderQueue.get(index);
1377
1705
  if (!frame2) break;
@@ -1390,9 +1718,9 @@ var Connection = class {
1390
1718
  }
1391
1719
  }
1392
1720
  /**
1393
- * Handles fragmented frames
1394
- * @param frame The frame
1395
- */
1721
+ * Handles fragmented frames
1722
+ * @param frame The frame
1723
+ */
1396
1724
  handleFragment(frame) {
1397
1725
  if (this.fragmentsQueue.has(frame.splitId)) {
1398
1726
  const fragment = this.fragmentsQueue.get(frame.splitId);
@@ -1415,18 +1743,20 @@ var Connection = class {
1415
1743
  return this.handleFrame(nframe);
1416
1744
  }
1417
1745
  } else {
1418
- this.fragmentsQueue.set(
1419
- frame.splitId,
1420
- /* @__PURE__ */ new Map([[frame.splitIndex, frame]])
1421
- );
1746
+ this.fragmentsQueue.set(frame.splitId, /* @__PURE__ */ new Map([
1747
+ [
1748
+ frame.splitIndex,
1749
+ frame
1750
+ ]
1751
+ ]));
1422
1752
  }
1423
1753
  }
1424
1754
  /**
1425
- * Sends a frame to the connection.
1426
- *
1427
- * @param frame - The frame to send
1428
- * @param priority - The priority of the frame
1429
- */
1755
+ * Sends a frame to the connection.
1756
+ *
1757
+ * @param frame - The frame to send
1758
+ * @param priority - The priority of the frame
1759
+ */
1430
1760
  sendFrame(frame, priority) {
1431
1761
  if (frame.isSequenced()) {
1432
1762
  frame.orderIndex = this.outputOrderIndex[frame.orderChannel];
@@ -1459,34 +1789,36 @@ var Connection = class {
1459
1789
  }
1460
1790
  }
1461
1791
  /**
1462
- * Adds a frame to the output queue
1463
- * @param frame The frame
1464
- * @param priority The priority
1465
- */
1792
+ * Adds a frame to the output queue
1793
+ * @param frame The frame
1794
+ * @param priority The priority
1795
+ */
1466
1796
  queueFrame(frame, priority) {
1467
1797
  let length = DGRAM_HEADER_SIZE;
1468
1798
  for (const frame2 of this.outputFrames) length += frame2.getByteLength();
1469
1799
  if (length + frame.getByteLength() > this.mtu - DGRAM_MTU_OVERHEAD)
1470
1800
  this.sendQueue(this.outputFrames.size);
1471
1801
  this.outputFrames.add(frame);
1472
- if (priority === 1 /* Immediate */) return this.sendQueue(1);
1802
+ if (priority === Priority.Immediate) return this.sendQueue(1);
1473
1803
  }
1474
1804
  /**
1475
- * Sends the output frame queue
1476
- */
1805
+ * Sends the output frame queue
1806
+ */
1477
1807
  sendQueue(amount) {
1478
1808
  if (this.outputFrames.size === 0) return;
1479
1809
  const frameset = new FrameSet();
1480
1810
  frameset.sequence = this.outputSequence++;
1481
- frameset.frames = [...this.outputFrames].slice(0, amount);
1811
+ frameset.frames = [
1812
+ ...this.outputFrames
1813
+ ].slice(0, amount);
1482
1814
  this.outputBackup.set(frameset.sequence, frameset.frames);
1483
1815
  for (const frame of frameset.frames) this.outputFrames.delete(frame);
1484
1816
  return this.server.send(frameset.serialize(), this.rinfo);
1485
1817
  }
1486
1818
  /**
1487
- * Handles an incoming connection request
1488
- * @param buffer The packet buffer
1489
- */
1819
+ * Handles an incoming connection request
1820
+ * @param buffer The packet buffer
1821
+ */
1490
1822
  handleIncomingConnectionRequest(buffer) {
1491
1823
  const request = new ConnectionRequest(buffer).deserialize();
1492
1824
  const accepted = new ConnectionRequestAccepted();
@@ -1496,15 +1828,15 @@ var Connection = class {
1496
1828
  accepted.requestTimestamp = request.timestamp;
1497
1829
  accepted.timestamp = BigInt(Date.now());
1498
1830
  const frame = new Frame();
1499
- frame.reliability = 3 /* ReliableOrdered */;
1831
+ frame.reliability = Reliability.ReliableOrdered;
1500
1832
  frame.orderChannel = 0;
1501
1833
  frame.payload = accepted.serialize();
1502
- return this.sendFrame(frame, 0 /* Normal */);
1834
+ return this.sendFrame(frame, Priority.Normal);
1503
1835
  }
1504
1836
  /**
1505
- * Handles an incoming connected ping
1506
- * @param buffer The packet buffer
1507
- */
1837
+ * Handles an incoming connected ping
1838
+ * @param buffer The packet buffer
1839
+ */
1508
1840
  handleIncomingConnectedPing(buffer) {
1509
1841
  const ping = new ConnectedPing(buffer).deserialize();
1510
1842
  const pong = new ConnectedPong();
@@ -1512,53 +1844,54 @@ var Connection = class {
1512
1844
  pong.pingTimestamp = ping.timestamp;
1513
1845
  pong.timestamp = BigInt(Date.now());
1514
1846
  const frame = new Frame();
1515
- frame.reliability = 3 /* ReliableOrdered */;
1847
+ frame.reliability = Reliability.ReliableOrdered;
1516
1848
  frame.orderChannel = 0;
1517
1849
  frame.payload = pong.serialize();
1518
- this.sendFrame(frame, 0 /* Normal */);
1850
+ this.sendFrame(frame, Priority.Normal);
1519
1851
  }
1520
1852
  };
1521
1853
 
1522
1854
  // src/server/offline.ts
1523
- var Offline = class {
1855
+ var Offline = class Offline2 {
1856
+ static {
1857
+ __name(this, "Offline");
1858
+ }
1524
1859
  /**
1525
- * The raknet server instance
1526
- */
1860
+ * The raknet server instance
1861
+ */
1527
1862
  static server;
1528
1863
  /**
1529
- * Handles all incoming offline datagrams from remote clients
1530
- * @param buffer The packet buffer from the remote client
1531
- * @param rinfo The remote client information
1532
- */
1864
+ * Handles all incoming offline datagrams from remote clients
1865
+ * @param buffer The packet buffer from the remote client
1866
+ * @param rinfo The remote client information
1867
+ */
1533
1868
  static handle(buffer, rinfo) {
1534
1869
  const header = buffer[0];
1535
1870
  if (!header) throw new Error("Invalid offline packet header");
1536
1871
  switch (header) {
1537
- case 1 /* UnconnectedPing */: {
1872
+ case Packet.UnconnectedPing: {
1538
1873
  this.unconnectedPing(buffer, rinfo);
1539
1874
  break;
1540
1875
  }
1541
- case 5 /* OpenConnectionRequest1 */: {
1876
+ case Packet.OpenConnectionRequest1: {
1542
1877
  this.openConnectionRequest1(buffer, rinfo);
1543
1878
  break;
1544
1879
  }
1545
- case 7 /* OpenConnectionRequest2 */: {
1880
+ case Packet.OpenConnectionRequest2: {
1546
1881
  this.openConnectionRequest2(buffer, rinfo);
1547
1882
  break;
1548
1883
  }
1549
1884
  default: {
1550
1885
  const id = header.toString(16).length === 1 ? "0" + header.toString(16) : header.toString(16);
1551
- this.server.logger.debug(
1552
- `Received an unknown offline packet identifier "0x${id}" from ${rinfo.address}:${rinfo.port}`
1553
- );
1886
+ this.server.logger.debug(`Received an unknown offline packet identifier "0x${id}" from ${rinfo.address}:${rinfo.port}`);
1554
1887
  }
1555
1888
  }
1556
1889
  }
1557
1890
  /**
1558
- * Handles an unconnected ping packet
1559
- * @param buffer The packet buffer from the remote client
1560
- * @param rinfo The remote client information
1561
- */
1891
+ * Handles an unconnected ping packet
1892
+ * @param buffer The packet buffer from the remote client
1893
+ * @param rinfo The remote client information
1894
+ */
1562
1895
  static unconnectedPing(buffer, rinfo) {
1563
1896
  const ping = new UnconnectedPing(buffer).deserialize();
1564
1897
  const pong = new UnconnectedPong();
@@ -1566,7 +1899,6 @@ var Offline = class {
1566
1899
  pong.guid = this.server.guid;
1567
1900
  pong.message = [
1568
1901
  "MCPE",
1569
- // MCEE = Minecraft: Education Edition
1570
1902
  this.server.message ?? "Raknet Server",
1571
1903
  this.server.protocol ?? 100,
1572
1904
  this.server.version ?? "1.0.0",
@@ -1582,19 +1914,17 @@ var Offline = class {
1582
1914
  this.server.send(pong.serialize(), rinfo);
1583
1915
  }
1584
1916
  /**
1585
- * Handles an open connection request 1 packet
1586
- * @param buffer The packet buffer from the remote client
1587
- * @param rinfo The remote client information
1588
- */
1917
+ * Handles an open connection request 1 packet
1918
+ * @param buffer The packet buffer from the remote client
1919
+ * @param rinfo The remote client information
1920
+ */
1589
1921
  static openConnectionRequest1(buffer, rinfo) {
1590
1922
  const request = new OpenConnectionRequest1(buffer).deserialize();
1591
1923
  if (request.protocol !== RAKNET_PROTOCOL) {
1592
1924
  const incompatible = new IncompatibleProtocolVersion();
1593
1925
  incompatible.protocol = RAKNET_PROTOCOL;
1594
1926
  incompatible.guid = this.server.guid;
1595
- this.server.logger.warn(
1596
- `Refusing connection from ${rinfo.address}:${rinfo.port} due to incompatible protocol version v${request.protocol}, expected v${RAKNET_PROTOCOL}.`
1597
- );
1927
+ this.server.logger.warn(`Refusing connection from ${rinfo.address}:${rinfo.port} due to incompatible protocol version v${request.protocol}, expected v${RAKNET_PROTOCOL}.`);
1598
1928
  return this.server.send(incompatible.serialize(), rinfo);
1599
1929
  }
1600
1930
  const reply = new OpenConnectionReply1();
@@ -1605,38 +1935,30 @@ var Offline = class {
1605
1935
  return this.server.send(reply.serialize(), rinfo);
1606
1936
  }
1607
1937
  /**
1608
- * Handles an open connection request 2 packet
1609
- * @param buffer The packet buffer from the remote client
1610
- * @param rinfo The remote client information
1611
- */
1938
+ * Handles an open connection request 2 packet
1939
+ * @param buffer The packet buffer from the remote client
1940
+ * @param rinfo The remote client information
1941
+ */
1612
1942
  static openConnectionRequest2(buffer, rinfo) {
1613
1943
  const request = new OpenConnectionRequest2(buffer).deserialize();
1614
1944
  if (request.address.port !== this.server.port) {
1615
- return this.server.logger.warn(
1616
- `Refusing connection from ${rinfo.address}:${rinfo.port} due to mismatched port.`
1617
- );
1945
+ return this.server.logger.warn(`Refusing connection from ${rinfo.address}:${rinfo.port} due to mismatched port.`);
1618
1946
  }
1619
1947
  if (request.mtu < this.server.minMtuSize || request.mtu > this.server.maxMtuSize) {
1620
- return this.server.logger.warn(
1621
- `Refusing connection from ${rinfo.address}:${rinfo.port} due to invalid mtu size.`
1622
- );
1948
+ return this.server.logger.warn(`Refusing connection from ${rinfo.address}:${rinfo.port} due to invalid mtu size.`);
1623
1949
  }
1624
- const connection = [...this.server.connections.values()].find(
1625
- (x) => x.rinfo.address === rinfo.address && x.rinfo.port === rinfo.port
1626
- );
1950
+ const connection = [
1951
+ ...this.server.connections.values()
1952
+ ].find((x) => x.rinfo.address === rinfo.address && x.rinfo.port === rinfo.port);
1627
1953
  if (connection) {
1628
- return this.server.logger.warn(
1629
- `Refusing connection from ${rinfo.address}:${rinfo.port} due to already established connection.`
1630
- );
1954
+ return this.server.logger.warn(`Refusing connection from ${rinfo.address}:${rinfo.port} due to already established connection.`);
1631
1955
  }
1632
1956
  const reply = new OpenConnectionReply2();
1633
1957
  reply.guid = this.server.guid;
1634
1958
  reply.address = Address.fromIdentifier(rinfo);
1635
1959
  reply.mtu = request.mtu;
1636
1960
  reply.encryption = false;
1637
- this.server.logger.debug(
1638
- `Establishing connection from ${rinfo.address}:${rinfo.port} with mtu size of ${request.mtu}.`
1639
- );
1961
+ this.server.logger.debug(`Establishing connection from ${rinfo.address}:${rinfo.port} with mtu size of ${request.mtu}.`);
1640
1962
  this.server.connections.add(
1641
1963
  // Build a new connection instance
1642
1964
  new Connection(this.server, rinfo, request.client, request.mtu)
@@ -1646,68 +1968,71 @@ var Offline = class {
1646
1968
  };
1647
1969
 
1648
1970
  // src/server/raknet.ts
1649
- var Server = class extends import_emitter.Emitter {
1971
+ var Server = class Server2 extends import_emitter.Emitter {
1972
+ static {
1973
+ __name(this, "Server");
1974
+ }
1650
1975
  /**
1651
- * The server tick interval
1652
- */
1976
+ * The server tick interval
1977
+ */
1653
1978
  interval = null;
1654
1979
  /**
1655
- * The raknet server logger
1656
- */
1980
+ * The raknet server logger
1981
+ */
1657
1982
  logger = new import_logger.Logger("Raknet", import_logger.LoggerColors.CyanBright);
1658
1983
  /**
1659
- * The server socket
1660
- */
1984
+ * The server socket
1985
+ */
1661
1986
  socket = (0, import_node_dgram.createSocket)("udp4");
1662
1987
  /**
1663
- * The server address
1664
- */
1988
+ * The server address
1989
+ */
1665
1990
  address;
1666
1991
  /**
1667
- * The server port
1668
- */
1992
+ * The server port
1993
+ */
1669
1994
  port;
1670
1995
  /**
1671
- * The server guid
1672
- */
1996
+ * The server guid
1997
+ */
1673
1998
  guid = BigInt(Math.floor(Math.random() * 2 ** 64));
1674
1999
  /**
1675
- * The server connections
1676
- */
2000
+ * The server connections
2001
+ */
1677
2002
  connections = /* @__PURE__ */ new Set();
1678
2003
  /**
1679
- * The server max mtu size
1680
- */
2004
+ * The server max mtu size
2005
+ */
1681
2006
  maxMtuSize;
1682
2007
  /**
1683
- * The server min mtu size
1684
- */
2008
+ * The server min mtu size
2009
+ */
1685
2010
  minMtuSize;
1686
2011
  /**
1687
- * The server protocol
1688
- */
2012
+ * The server protocol
2013
+ */
1689
2014
  protocol = null;
1690
2015
  /**
1691
- * The server version
1692
- */
2016
+ * The server version
2017
+ */
1693
2018
  version = null;
1694
2019
  /**
1695
- * The server message
1696
- */
2020
+ * The server message
2021
+ */
1697
2022
  message = null;
1698
2023
  /**
1699
- * The server max connections
1700
- */
2024
+ * The server max connections
2025
+ */
1701
2026
  maxConnections = null;
1702
2027
  /**
1703
- * Weather the server is alive
1704
- */
2028
+ * Weather the server is alive
2029
+ */
1705
2030
  alive = true;
1706
2031
  /**
1707
- * Creates a new raknet server
1708
- * @param address the server address
1709
- * @param port the server port
1710
- */
2032
+ * Creates a new raknet server
2033
+ * @param address the server address
2034
+ * @param port the server port
2035
+ */
1711
2036
  constructor(address, port = 19132, mtuMaxSize = MAX_MTU_SIZE, mtuMinSize = MIN_MTU_SIZE) {
1712
2037
  super();
1713
2038
  this.address = address;
@@ -1719,20 +2044,20 @@ var Server = class extends import_emitter.Emitter {
1719
2044
  Offline.server = this;
1720
2045
  }
1721
2046
  /**
1722
- * Starts the server
1723
- */
2047
+ * Starts the server
2048
+ */
1724
2049
  start() {
1725
2050
  this.socket.bind(this.port, this.address);
1726
- const tick = () => setTimeout(() => {
2051
+ const tick = /* @__PURE__ */ __name(() => setTimeout(() => {
1727
2052
  if (!this.alive || !this.interval) return;
1728
2053
  for (const connection of this.connections) connection.tick();
1729
2054
  return tick();
1730
- }, RAKNET_TICK_LEN);
2055
+ }, RAKNET_TICK_LEN), "tick");
1731
2056
  this.interval = tick().unref();
1732
2057
  }
1733
2058
  /**
1734
- * Stops the server
1735
- */
2059
+ * Stops the server
2060
+ */
1736
2061
  stop() {
1737
2062
  try {
1738
2063
  if (this.interval) this.interval = null;
@@ -1744,10 +2069,10 @@ var Server = class extends import_emitter.Emitter {
1744
2069
  handle(buffer, rinfo) {
1745
2070
  const header = buffer[0];
1746
2071
  if (!header) throw new Error("Invalid packet header");
1747
- const offline = (header & 128 /* Valid */) === 0;
1748
- const connection = [...this.connections.values()].find(
1749
- (x) => x.rinfo.address === rinfo.address && x.rinfo.port === rinfo.port
1750
- );
2072
+ const offline = (header & Bitflags.Valid) === 0;
2073
+ const connection = [
2074
+ ...this.connections.values()
2075
+ ].find((x) => x.rinfo.address === rinfo.address && x.rinfo.port === rinfo.port);
1751
2076
  if (offline)
1752
2077
  return Offline.handle(buffer, rinfo);
1753
2078
  if (!offline && connection)