yolkbot 1.4.5 → 1.4.6

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 (112) hide show
  1. package/browser/build/global.js +1 -1
  2. package/browser/build/module.js +1 -1
  3. package/dist/api.js +200 -1
  4. package/dist/bot/GamePlayer.js +74 -1
  5. package/dist/bot.js +1679 -1
  6. package/dist/comm/CommIn.js +79 -1
  7. package/dist/comm/CommOut.js +60 -1
  8. package/dist/comm/index.js +11 -1
  9. package/dist/constants/CloseCode.js +27 -1
  10. package/dist/constants/CommCode.js +53 -1
  11. package/dist/constants/challenges.js +1821 -1
  12. package/dist/constants/findItemById.js +2 -3
  13. package/dist/constants/guns.js +277 -1
  14. package/dist/constants/index.js +139 -1
  15. package/dist/constants/items.js +45042 -1
  16. package/dist/constants/maps.js +1263 -1
  17. package/dist/constants/regions.js +30 -1
  18. package/dist/dispatches/BanPlayerDispatch.js +32 -1
  19. package/dist/dispatches/BootPlayerDispatch.js +21 -1
  20. package/dist/dispatches/ChatDispatch.js +32 -1
  21. package/dist/dispatches/FireDispatch.js +15 -1
  22. package/dist/dispatches/GameOptionsDispatch.js +66 -1
  23. package/dist/dispatches/GoToAmmoDispatch.js +38 -1
  24. package/dist/dispatches/GoToCoopDispatch.js +38 -1
  25. package/dist/dispatches/GoToGrenadeDispatch.js +38 -1
  26. package/dist/dispatches/GoToPlayerDispatch.js +39 -1
  27. package/dist/dispatches/GoToSpatulaDispatch.js +26 -1
  28. package/dist/dispatches/LookAtDispatch.js +35 -1
  29. package/dist/dispatches/LookAtPosDispatch.js +29 -1
  30. package/dist/dispatches/MeleeDispatch.js +26 -1
  31. package/dist/dispatches/MovementDispatch.js +26 -1
  32. package/dist/dispatches/PauseDispatch.js +18 -1
  33. package/dist/dispatches/ReloadDispatch.js +28 -1
  34. package/dist/dispatches/ReportPlayerDispatch.js +42 -1
  35. package/dist/dispatches/ResetGameDispatch.js +19 -1
  36. package/dist/dispatches/SaveLoadoutDispatch.js +105 -1
  37. package/dist/dispatches/SpawnDispatch.js +22 -1
  38. package/dist/dispatches/SwapWeaponDispatch.js +25 -1
  39. package/dist/dispatches/SwitchTeamDispatch.js +33 -1
  40. package/dist/dispatches/ThrowGrenadeDispatch.js +21 -1
  41. package/dist/dispatches/index.js +74 -1
  42. package/dist/env/fetch.js +97 -10
  43. package/dist/env/globals.js +15 -1
  44. package/dist/index.js +14 -2
  45. package/dist/matchmaker.js +141 -1
  46. package/dist/pathing/astar.js +55 -1
  47. package/dist/pathing/binaryheap.js +79 -1
  48. package/dist/pathing/mapnode.js +179 -1
  49. package/dist/socket.js +97 -1
  50. package/dist/util.js +68 -1
  51. package/dist/wasm/bytes.js +8 -1
  52. package/dist/wasm/direct.js +84 -1
  53. package/dist/wasm/legacy.js +170 -1
  54. package/dist/wasm/util.js +19 -1
  55. package/package.json +38 -39
  56. /package/dist/{types/api.d.ts → api.d.ts} +0 -0
  57. /package/dist/{types/bot → bot}/GamePlayer.d.ts +0 -0
  58. /package/dist/{types/bot.d.ts → bot.d.ts} +0 -0
  59. /package/dist/{types/comm → comm}/CommIn.d.ts +0 -0
  60. /package/dist/{types/comm → comm}/CommOut.d.ts +0 -0
  61. /package/dist/{types/comm → comm}/index.d.ts +0 -0
  62. /package/dist/{types/constants → constants}/CloseCode.d.ts +0 -0
  63. /package/dist/{types/constants → constants}/CommCode.d.ts +0 -0
  64. /package/dist/{types/constants → constants}/challenges.d.ts +0 -0
  65. /package/dist/{types/constants → constants}/changelog.d.ts +0 -0
  66. /package/dist/{types/constants → constants}/findItemById.d.ts +0 -0
  67. /package/dist/{types/constants → constants}/guns.d.ts +0 -0
  68. /package/dist/{types/constants → constants}/housePromo.d.ts +0 -0
  69. /package/dist/{types/constants → constants}/index.d.ts +0 -0
  70. /package/dist/{types/constants → constants}/items.d.ts +0 -0
  71. /package/dist/{types/constants → constants}/language.d.ts +0 -0
  72. /package/dist/{types/constants → constants}/maps.d.ts +0 -0
  73. /package/dist/{types/constants → constants}/notices.d.ts +0 -0
  74. /package/dist/{types/constants → constants}/regions.d.ts +0 -0
  75. /package/dist/{types/constants → constants}/shellNews.d.ts +0 -0
  76. /package/dist/{types/constants → constants}/shellYoutube.d.ts +0 -0
  77. /package/dist/{types/constants → constants}/shopItems.d.ts +0 -0
  78. /package/dist/{types/constants → constants}/sounds.d.ts +0 -0
  79. /package/dist/{types/dispatches → dispatches}/BanPlayerDispatch.d.ts +0 -0
  80. /package/dist/{types/dispatches → dispatches}/BootPlayerDispatch.d.ts +0 -0
  81. /package/dist/{types/dispatches → dispatches}/ChatDispatch.d.ts +0 -0
  82. /package/dist/{types/dispatches → dispatches}/FireDispatch.d.ts +0 -0
  83. /package/dist/{types/dispatches → dispatches}/GameOptionsDispatch.d.ts +0 -0
  84. /package/dist/{types/dispatches → dispatches}/GoToAmmoDispatch.d.ts +0 -0
  85. /package/dist/{types/dispatches → dispatches}/GoToCoopDispatch.d.ts +0 -0
  86. /package/dist/{types/dispatches → dispatches}/GoToGrenadeDispatch.d.ts +0 -0
  87. /package/dist/{types/dispatches → dispatches}/GoToPlayerDispatch.d.ts +0 -0
  88. /package/dist/{types/dispatches → dispatches}/GoToSpatulaDispatch.d.ts +0 -0
  89. /package/dist/{types/dispatches → dispatches}/LookAtDispatch.d.ts +0 -0
  90. /package/dist/{types/dispatches → dispatches}/LookAtPosDispatch.d.ts +0 -0
  91. /package/dist/{types/dispatches → dispatches}/MeleeDispatch.d.ts +0 -0
  92. /package/dist/{types/dispatches → dispatches}/MovementDispatch.d.ts +0 -0
  93. /package/dist/{types/dispatches → dispatches}/PauseDispatch.d.ts +0 -0
  94. /package/dist/{types/dispatches → dispatches}/ReloadDispatch.d.ts +0 -0
  95. /package/dist/{types/dispatches → dispatches}/ReportPlayerDispatch.d.ts +0 -0
  96. /package/dist/{types/dispatches → dispatches}/ResetGameDispatch.d.ts +0 -0
  97. /package/dist/{types/dispatches → dispatches}/SaveLoadoutDispatch.d.ts +0 -0
  98. /package/dist/{types/dispatches → dispatches}/SpawnDispatch.d.ts +0 -0
  99. /package/dist/{types/dispatches → dispatches}/SwapWeaponDispatch.d.ts +0 -0
  100. /package/dist/{types/dispatches → dispatches}/SwitchTeamDispatch.d.ts +0 -0
  101. /package/dist/{types/dispatches → dispatches}/ThrowGrenadeDispatch.d.ts +0 -0
  102. /package/dist/{types/dispatches → dispatches}/index.d.ts +0 -0
  103. /package/dist/{types/matchmaker.d.ts → matchmaker.d.ts} +0 -0
  104. /package/dist/{types/pathing → pathing}/astar.d.ts +0 -0
  105. /package/dist/{types/pathing → pathing}/binaryheap.d.ts +0 -0
  106. /package/dist/{types/pathing → pathing}/mapnode.d.ts +0 -0
  107. /package/dist/{types/socket.d.ts → socket.d.ts} +0 -0
  108. /package/dist/{types/util.d.ts → util.d.ts} +0 -0
  109. /package/dist/{types/wasm → wasm}/bytes.d.ts +0 -0
  110. /package/dist/{types/wasm → wasm}/direct.d.ts +0 -0
  111. /package/dist/{types/wasm → wasm}/legacy.d.ts +0 -0
  112. /package/dist/{types/wasm → wasm}/util.d.ts +0 -0
@@ -1 +1,19 @@
1
- import o from"../comm/CommOut.js";import m from"../constants/CommCode.js";import{GameAction as r}from"../constants/index.js";export class ResetGameDispatch{validate(){return!0}check(e){return e.game.isGameOwner}execute(e){const t=new o;t.packInt8(m.gameAction);t.packInt8(r.Reset);t.send(e.game.socket)}}export default ResetGameDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+ import { GameAction } from "../constants/index.js";
4
+
5
+ export class ResetGameDispatch {
6
+ validate() {
7
+ return true;
8
+ }
9
+ check(bot) {
10
+ return bot.game.isGameOwner;
11
+ }
12
+ execute(bot) {
13
+ const out = new CommOut;
14
+ out.packInt8(CommCode.gameAction);
15
+ out.packInt8(GameAction.Reset);
16
+ out.send(bot.game.socket);
17
+ }
18
+ }
19
+ export default ResetGameDispatch;
@@ -1 +1,105 @@
1
- import W from"../comm/CommOut.js";import X from"../constants/CommCode.js";import{findItemById as J,GunList as Z,ItemType as N}from"../constants/index.js";const Q=(q)=>J(q)&&J(q).unlock==="default",U=(q,z)=>J(q)&&J(q).item_type_id===z;export class SaveLoadoutDispatch{constructor(q){this.changes={classIdx:q.gunId,hatId:q.hatId,stampId:q.stampId,grenadeId:q.grenadeId,meleeId:q.meleeId,colorIdx:q.eggColor,primaryId:q.primaryIds,secondaryId:q.secondaryIds};this.changes=Object.fromEntries(Object.entries(this.changes).filter(([,z])=>!!z))}validate(q){const z=this.changes;if(z.colorIdx&&z.colorIdx>=7&&!q.account.vip)return!1;if(z.colorIdx&&z.colorIdx>=14)return!1;if(U(z.hatId,N.Hat)&&!Q(z.hatId)&&!q.account.ownedItemIds.includes(z.hatId))return!1;if(U(z.stampId,N.Stamp)&&!Q(z.stampId)&&!q.account.ownedItemIds.includes(z.stampId))return!1;if(U(z.grenadeId,N.Grenade)&&!Q(z.grenadeId)&&!q.account.ownedItemIds.includes(z.grenadeId))return!1;if(U(z.meleeId,N.Melee)&&!Q(z.meleeId)&&!q.account.ownedItemIds.includes(z.meleeId))return!1;if(typeof z.classIdx==="number"&&z.classIdx>6||z.classIdx<0)return!1;if(this.changes.primaryId)for(let M=0;M<7;M++){const E=this.changes.primaryId[M];if(!U(E,N.Primary)||!Q(E)&&!q.account.ownedItemIds.includes(E))return!1}if(this.changes.secondaryId)for(let M=0;M<7;M++){const E=this.changes.secondaryId[M];if(!U(E,N.Secondary)||!Q(E)&&!q.account.ownedItemIds.includes(E))return!1}return!0}check(q){return!q.me.playing}execute(q){if(q.me&&this.changes.classIdx&&this.changes.classIdx!==q.me.selectedGun)q.me.weapons[0]=new Z[this.changes.classIdx];q.state.weaponIdx=this.changes.classIdx||q.state.weaponIdx;const z={...q.account.loadout,...this.changes},M=q.api.queryServices({cmd:"saveLoadout",save:!0,firebaseId:q.account.firebaseId,sessionId:q.account.sessionId,loadout:z});q.account.loadout=z;if(q.me)M.then(()=>{if(q.state.inGame){const H=new W;H.packInt8(X.changeCharacter);H.packInt8(this.changes?.classIdx||q.me.selectedGun);H.send(q.game.socket)}const E=q.intents.includes(q.Intents.COSMETIC_DATA);Object.entries(this.changes).forEach(([H,F])=>{if(H==="classIdx")q.me.selectedGun=F;else if(H==="hatId")q.me.character.hat=E?J(F):F;else if(H==="stampId")q.me.character.stamp=E?J(F):F;else if(H==="grenadeId")q.me.character.grenade=E?J(F):F;else if(H==="meleeId")q.me.character.melee=E?J(F):F;else if(H==="colorIdx")q.me.character.eggColor=F;else if(H==="primaryId")q.me.character.primaryGun=E?J(F[q.me.selectedGun]):F;else if(H==="secondaryId")q.me.character.secondaryGun=E?J(F[q.me.selectedGun]):F})})}}export default SaveLoadoutDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+ import { findItemById, GunList, ItemType } from "../constants/index.js";
4
+ const isDefault = (itemId) => findItemById(itemId) && findItemById(itemId).unlock === "default";
5
+ const isType = (itemId, type) => findItemById(itemId) && findItemById(itemId).item_type_id === type;
6
+
7
+ export class SaveLoadoutDispatch {
8
+ constructor(opts) {
9
+ this.changes = {
10
+ classIdx: opts.gunId,
11
+ hatId: opts.hatId,
12
+ stampId: opts.stampId,
13
+ grenadeId: opts.grenadeId,
14
+ meleeId: opts.meleeId,
15
+ colorIdx: opts.eggColor,
16
+ primaryId: opts.primaryIds,
17
+ secondaryId: opts.secondaryIds
18
+ };
19
+ this.changes = Object.fromEntries(Object.entries(this.changes).filter(([, v]) => !!v));
20
+ }
21
+ validate(bot) {
22
+ const load = this.changes;
23
+ if (load.colorIdx && load.colorIdx >= 7 && !bot.account.vip)
24
+ return false;
25
+ if (load.colorIdx && load.colorIdx >= 14)
26
+ return false;
27
+ if (isType(load.hatId, ItemType.Hat) && !isDefault(load.hatId) && !bot.account.ownedItemIds.includes(load.hatId))
28
+ return false;
29
+ if (isType(load.stampId, ItemType.Stamp) && !isDefault(load.stampId) && !bot.account.ownedItemIds.includes(load.stampId))
30
+ return false;
31
+ if (isType(load.grenadeId, ItemType.Grenade) && !isDefault(load.grenadeId) && !bot.account.ownedItemIds.includes(load.grenadeId))
32
+ return false;
33
+ if (isType(load.meleeId, ItemType.Melee) && !isDefault(load.meleeId) && !bot.account.ownedItemIds.includes(load.meleeId))
34
+ return false;
35
+ if (typeof load.classIdx === "number" && load.classIdx > 6 || load.classIdx < 0)
36
+ return false;
37
+ if (this.changes.primaryId) {
38
+ for (let i = 0;i < 7; i++) {
39
+ const testingId = this.changes.primaryId[i];
40
+ if (!isType(testingId, ItemType.Primary) || !isDefault(testingId) && !bot.account.ownedItemIds.includes(testingId)) {
41
+ return false;
42
+ }
43
+ }
44
+ }
45
+ if (this.changes.secondaryId) {
46
+ for (let i = 0;i < 7; i++) {
47
+ const testingId = this.changes.secondaryId[i];
48
+ if (!isType(testingId, ItemType.Secondary) || !isDefault(testingId) && !bot.account.ownedItemIds.includes(testingId)) {
49
+ return false;
50
+ }
51
+ }
52
+ }
53
+ return true;
54
+ }
55
+ check(bot) {
56
+ return !bot.me.playing;
57
+ }
58
+ execute(bot) {
59
+ if (bot.me && this.changes.classIdx && this.changes.classIdx !== bot.me.selectedGun) {
60
+ bot.me.weapons[0] = new GunList[this.changes.classIdx];
61
+ }
62
+ bot.state.weaponIdx = this.changes.classIdx || bot.state.weaponIdx;
63
+ const loadout = {
64
+ ...bot.account.loadout,
65
+ ...this.changes
66
+ };
67
+ const saveLoadout = bot.api.queryServices({
68
+ cmd: "saveLoadout",
69
+ save: true,
70
+ firebaseId: bot.account.firebaseId,
71
+ sessionId: bot.account.sessionId,
72
+ loadout
73
+ });
74
+ bot.account.loadout = loadout;
75
+ if (bot.me)
76
+ saveLoadout.then(() => {
77
+ if (bot.state.inGame) {
78
+ const out = new CommOut;
79
+ out.packInt8(CommCode.changeCharacter);
80
+ out.packInt8(this.changes?.classIdx || bot.me.selectedGun);
81
+ out.send(bot.game.socket);
82
+ }
83
+ const findCosmetics = bot.intents.includes(bot.Intents.COSMETIC_DATA);
84
+ Object.entries(this.changes).forEach(([changeKey, changeValue]) => {
85
+ if (changeKey === "classIdx")
86
+ bot.me.selectedGun = changeValue;
87
+ else if (changeKey === "hatId")
88
+ bot.me.character.hat = findCosmetics ? findItemById(changeValue) : changeValue;
89
+ else if (changeKey === "stampId")
90
+ bot.me.character.stamp = findCosmetics ? findItemById(changeValue) : changeValue;
91
+ else if (changeKey === "grenadeId")
92
+ bot.me.character.grenade = findCosmetics ? findItemById(changeValue) : changeValue;
93
+ else if (changeKey === "meleeId")
94
+ bot.me.character.melee = findCosmetics ? findItemById(changeValue) : changeValue;
95
+ else if (changeKey === "colorIdx")
96
+ bot.me.character.eggColor = changeValue;
97
+ else if (changeKey === "primaryId")
98
+ bot.me.character.primaryGun = findCosmetics ? findItemById(changeValue[bot.me.selectedGun]) : changeValue;
99
+ else if (changeKey === "secondaryId")
100
+ bot.me.character.secondaryGun = findCosmetics ? findItemById(changeValue[bot.me.selectedGun]) : changeValue;
101
+ });
102
+ });
103
+ }
104
+ }
105
+ export default SaveLoadoutDispatch;
@@ -1 +1,22 @@
1
- import r from"../comm/CommOut.js";import n from"../constants/CommCode.js";export class SpawnDispatch{validate(){return!0}check(e){if(e.me.playing)return!1;if(e.lastDeathTime+6000<Date.now())return!1;if(e.intents.includes(e.Intents.OBSERVE_GAME))return!1;return!0}execute(e){const t=new r;t.packInt8(n.requestRespawn);t.send(e.game.socket);e.state.buffer=[]}}export default SpawnDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+
4
+ export class SpawnDispatch {
5
+ validate() {
6
+ return true;
7
+ }
8
+ check(bot) {
9
+ if (bot.me.playing)
10
+ return false;
11
+ if (bot.intents.includes(bot.Intents.OBSERVE_GAME))
12
+ return false;
13
+ return true;
14
+ }
15
+ execute(bot) {
16
+ const out = new CommOut;
17
+ out.packInt8(CommCode.requestRespawn);
18
+ out.send(bot.game.socket);
19
+ bot.state.buffer = [];
20
+ }
21
+ }
22
+ export default SpawnDispatch;
@@ -1 +1,25 @@
1
- import t from"../comm/CommOut.js";import m from"../constants/CommCode.js";export class SwapWeaponDispatch{constructor(e){this.manualWeapon=e}validate(){return typeof this.manualWeapon==="number"||typeof this.manualWeapon>"u"}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){let n=+!e.me.activeGun;if(typeof this.manualWeapon==="number")n=this.manualWeapon;e.me.activeGun=n;const a=new t;a.packInt8(m.swapWeapon);a.packInt8(e.me.activeGun);a.send(e.game.socket)}}export default SwapWeaponDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+
4
+ export class SwapWeaponDispatch {
5
+ constructor(manualWeapon) {
6
+ this.manualWeapon = manualWeapon;
7
+ }
8
+ validate() {
9
+ return typeof this.manualWeapon === "number" || typeof this.manualWeapon === "undefined";
10
+ }
11
+ check(bot) {
12
+ return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
13
+ }
14
+ execute(bot) {
15
+ let chosenWeapon = +!bot.me.activeGun;
16
+ if (typeof this.manualWeapon === "number")
17
+ chosenWeapon = this.manualWeapon;
18
+ bot.me.activeGun = chosenWeapon;
19
+ const out = new CommOut;
20
+ out.packInt8(CommCode.swapWeapon);
21
+ out.packInt8(bot.me.activeGun);
22
+ out.send(bot.game.socket);
23
+ }
24
+ }
25
+ export default SwapWeaponDispatch;
@@ -1 +1,33 @@
1
- import B from"../comm/CommOut.js";import E from"../constants/CommCode.js";export class SwitchTeamDispatch{validate(){return!0}check(f){if(!f.state.inGame||f.me.playing)return!1;if(f.game.gameModeId===0)return!1;if(f.intents.includes(f.Intents.OBSERVE_GAME))return!1;if(f.game.isPrivate)return!f.game.options.noTeamChange;const k=f.players,x=f.me.team,z=k.filter((q)=>q.team===x).length,A=k.filter((q)=>q.team!==x).length;if(A>z)return!1;if(z===A)return!1;return!0}execute(f){const k=new B;k.packInt8(E.switchTeam);k.send(f.game.socket)}}export default SwitchTeamDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+
4
+ export class SwitchTeamDispatch {
5
+ validate() {
6
+ return true;
7
+ }
8
+ check(bot) {
9
+ if (!bot.state.inGame || bot.me.playing)
10
+ return false;
11
+ if (bot.game.gameModeId === 0)
12
+ return false;
13
+ if (bot.intents.includes(bot.Intents.OBSERVE_GAME))
14
+ return false;
15
+ if (bot.game.isPrivate)
16
+ return !bot.game.options.noTeamChange;
17
+ const players = bot.players;
18
+ const myTeam = bot.me.team;
19
+ const playersWithMyTeam = players.filter((player) => player.team === myTeam).length;
20
+ const playersWithOtherTeam = players.filter((player) => player.team !== myTeam).length;
21
+ if (playersWithOtherTeam > playersWithMyTeam)
22
+ return false;
23
+ if (playersWithMyTeam === playersWithOtherTeam)
24
+ return false;
25
+ return true;
26
+ }
27
+ execute(bot) {
28
+ const out = new CommOut;
29
+ out.packInt8(CommCode.switchTeam);
30
+ out.send(bot.game.socket);
31
+ }
32
+ }
33
+ export default SwitchTeamDispatch;
@@ -1 +1,21 @@
1
- import r from"../comm/CommOut.js";import o from"../constants/CommCode.js";export class ThrowGrenadeDispatch{constructor(e=1){this.power=e}validate(){return typeof this.power==="number"&&this.power>=0&&this.power<=1}check(e){return e.me.playing&&!e.state.reloading&&!e.state.swappingGun&&!e.state.usingMelee}execute(e){const t=new r;t.packInt8(o.throwGrenade);t.packFloat(this.power);t.send(e.game.socket)}}export default ThrowGrenadeDispatch;
1
+ import CommOut from "../comm/CommOut.js";
2
+ import CommCode from "../constants/CommCode.js";
3
+
4
+ export class ThrowGrenadeDispatch {
5
+ constructor(power = 1) {
6
+ this.power = power;
7
+ }
8
+ validate() {
9
+ return typeof this.power === "number" && this.power >= 0 && this.power <= 1;
10
+ }
11
+ check(bot) {
12
+ return bot.me.playing && !bot.state.reloading && !bot.state.swappingGun && !bot.state.usingMelee;
13
+ }
14
+ execute(bot) {
15
+ const out = new CommOut;
16
+ out.packInt8(CommCode.throwGrenade);
17
+ out.packFloat(this.power);
18
+ out.send(bot.game.socket);
19
+ }
20
+ }
21
+ export default ThrowGrenadeDispatch;
@@ -1 +1,74 @@
1
- import BanPlayerDispatch from"./BanPlayerDispatch.js";import BootPlayerDispatch from"./BootPlayerDispatch.js";import ChatDispatch from"./ChatDispatch.js";import FireDispatch from"./FireDispatch.js";import GameOptionsDispatch from"./GameOptionsDispatch.js";import GoToAmmoDispatch from"./GoToAmmoDispatch.js";import GoToCoopDispatch from"./GoToCoopDispatch.js";import GoToGrenadeDispatch from"./GoToGrenadeDispatch.js";import GoToPlayerDispatch from"./GoToPlayerDispatch.js";import GoToSpatulaDispatch from"./GoToSpatulaDispatch.js";import LookAtDispatch from"./LookAtDispatch.js";import LookAtPosDispatch from"./LookAtPosDispatch.js";import MeleeDispatch from"./MeleeDispatch.js";import MovementDispatch from"./MovementDispatch.js";import PauseDispatch from"./PauseDispatch.js";import ReloadDispatch from"./ReloadDispatch.js";import ReportPlayerDispatch from"./ReportPlayerDispatch.js";import ResetGameDispatch from"./ResetGameDispatch.js";import SaveLoadoutDispatch from"./SaveLoadoutDispatch.js";import SpawnDispatch from"./SpawnDispatch.js";import SwapWeaponDispatch from"./SwapWeaponDispatch.js";import SwitchTeamDispatch from"./SwitchTeamDispatch.js";import ThrowGrenadeDispatch from"./ThrowGrenadeDispatch.js";export{BanPlayerDispatch,BootPlayerDispatch,ChatDispatch,FireDispatch,GameOptionsDispatch,GoToAmmoDispatch,GoToCoopDispatch,GoToGrenadeDispatch,GoToPlayerDispatch,GoToSpatulaDispatch,LookAtDispatch,LookAtPosDispatch,MeleeDispatch,MovementDispatch,PauseDispatch,ReloadDispatch,ReportPlayerDispatch,ResetGameDispatch,SaveLoadoutDispatch,SpawnDispatch,SwapWeaponDispatch,SwitchTeamDispatch,ThrowGrenadeDispatch};export default {BanPlayerDispatch,BootPlayerDispatch,ChatDispatch,FireDispatch,GameOptionsDispatch,GoToAmmoDispatch,GoToCoopDispatch,GoToGrenadeDispatch,GoToPlayerDispatch,GoToSpatulaDispatch,LookAtDispatch,LookAtPosDispatch,MeleeDispatch,MovementDispatch,PauseDispatch,ReloadDispatch,ReportPlayerDispatch,ResetGameDispatch,SaveLoadoutDispatch,SpawnDispatch,SwapWeaponDispatch,SwitchTeamDispatch,ThrowGrenadeDispatch};
1
+ import BanPlayerDispatch from "./BanPlayerDispatch.js";
2
+ import BootPlayerDispatch from "./BootPlayerDispatch.js";
3
+ import ChatDispatch from "./ChatDispatch.js";
4
+ import FireDispatch from "./FireDispatch.js";
5
+ import GameOptionsDispatch from "./GameOptionsDispatch.js";
6
+ import GoToAmmoDispatch from "./GoToAmmoDispatch.js";
7
+ import GoToCoopDispatch from "./GoToCoopDispatch.js";
8
+ import GoToGrenadeDispatch from "./GoToGrenadeDispatch.js";
9
+ import GoToPlayerDispatch from "./GoToPlayerDispatch.js";
10
+ import GoToSpatulaDispatch from "./GoToSpatulaDispatch.js";
11
+ import LookAtDispatch from "./LookAtDispatch.js";
12
+ import LookAtPosDispatch from "./LookAtPosDispatch.js";
13
+ import MeleeDispatch from "./MeleeDispatch.js";
14
+ import MovementDispatch from "./MovementDispatch.js";
15
+ import PauseDispatch from "./PauseDispatch.js";
16
+ import ReloadDispatch from "./ReloadDispatch.js";
17
+ import ReportPlayerDispatch from "./ReportPlayerDispatch.js";
18
+ import ResetGameDispatch from "./ResetGameDispatch.js";
19
+ import SaveLoadoutDispatch from "./SaveLoadoutDispatch.js";
20
+ import SpawnDispatch from "./SpawnDispatch.js";
21
+ import SwapWeaponDispatch from "./SwapWeaponDispatch.js";
22
+ import SwitchTeamDispatch from "./SwitchTeamDispatch.js";
23
+ import ThrowGrenadeDispatch from "./ThrowGrenadeDispatch.js";
24
+
25
+ export {
26
+ BanPlayerDispatch,
27
+ BootPlayerDispatch,
28
+ ChatDispatch,
29
+ FireDispatch,
30
+ GameOptionsDispatch,
31
+ GoToAmmoDispatch,
32
+ GoToCoopDispatch,
33
+ GoToGrenadeDispatch,
34
+ GoToPlayerDispatch,
35
+ GoToSpatulaDispatch,
36
+ LookAtDispatch,
37
+ LookAtPosDispatch,
38
+ MeleeDispatch,
39
+ MovementDispatch,
40
+ PauseDispatch,
41
+ ReloadDispatch,
42
+ ReportPlayerDispatch,
43
+ ResetGameDispatch,
44
+ SaveLoadoutDispatch,
45
+ SpawnDispatch,
46
+ SwapWeaponDispatch,
47
+ SwitchTeamDispatch,
48
+ ThrowGrenadeDispatch
49
+ };
50
+ export default {
51
+ BanPlayerDispatch,
52
+ BootPlayerDispatch,
53
+ ChatDispatch,
54
+ FireDispatch,
55
+ GameOptionsDispatch,
56
+ GoToAmmoDispatch,
57
+ GoToCoopDispatch,
58
+ GoToGrenadeDispatch,
59
+ GoToPlayerDispatch,
60
+ GoToSpatulaDispatch,
61
+ LookAtDispatch,
62
+ LookAtPosDispatch,
63
+ MeleeDispatch,
64
+ MovementDispatch,
65
+ PauseDispatch,
66
+ ReloadDispatch,
67
+ ReportPlayerDispatch,
68
+ ResetGameDispatch,
69
+ SaveLoadoutDispatch,
70
+ SpawnDispatch,
71
+ SwapWeaponDispatch,
72
+ SwitchTeamDispatch,
73
+ ThrowGrenadeDispatch
74
+ };
package/dist/env/fetch.js CHANGED
@@ -1,15 +1,102 @@
1
- import{socksConnect as B}from"wwws";const H=(o,{method:f,pathname:k,hostname:u,port:g,headers:a,body:d},L)=>{let m="";for(const[l,t]of Object.entries(a))m+=`${l}: ${t}\r
2
- `;if(d&&!("Content-Length"in a))m+=`Content-Length: ${Buffer.byteLength(d)}\r
3
- `;let r=`${f} ${k} HTTP/1.1\r
4
- Host: ${u}:${g}\r
5
- ${m}Connection: close\r
1
+ import { socksConnect } from "wwws";
2
+ import globals from "./globals.js";
3
+ const sendHttpRequest = (socket, { method, pathname, hostname, port, headers, body }, resolve) => {
4
+ let reqHeaders = "";
5
+ for (const [k, v] of Object.entries(headers))
6
+ reqHeaders += `${k}: ${v}\r
7
+ `;
8
+ if (body && !("Content-Length" in headers))
9
+ reqHeaders += `Content-Length: ${Buffer.byteLength(body)}\r
10
+ `;
11
+ let req = `${method} ${pathname} HTTP/1.1\r
12
+ Host: ${hostname}:${port}\r
13
+ ${reqHeaders}Connection: close\r
6
14
  \r
7
- `;if(d)r+=d;o.write(r);let n="";o.on("data",(l)=>{n+=l.toString();if(/transfer-encoding:\s*chunked/i.test(n)){if(n.includes(`\r
15
+ `;
16
+ if (body)
17
+ req += body;
18
+ socket.write(req);
19
+ let response = "";
20
+ socket.on("data", (data) => {
21
+ response += data.toString();
22
+ if (/transfer-encoding:\s*chunked/i.test(response)) {
23
+ if (response.includes(`\r
8
24
  0\r
9
25
  \r
10
- `))o.end()}else{const t=n.match(/content-length:\s*(?<len>\d+)/i);if(t){const c=parseInt(t.groups.len,10),i=n.indexOf(`\r
26
+ `))
27
+ socket.end();
28
+ } else {
29
+ const contentLengthMatch = response.match(/content-length:\s*(?<len>\d+)/i);
30
+ if (contentLengthMatch) {
31
+ const contentLength = parseInt(contentLengthMatch.groups.len, 10);
32
+ const bodyStart = response.indexOf(`\r
11
33
  \r
12
- `)+4;if(n.slice(i).length>=c)o.end()}}});o.on("end",()=>{const l=/transfer-encoding:\s*chunked/i.test(n);let t=n.split(`\r
34
+ `) + 4;
35
+ const body3 = response.slice(bodyStart);
36
+ if (body3.length >= contentLength)
37
+ socket.end();
38
+ }
39
+ }
40
+ });
41
+ socket.on("end", () => {
42
+ const isChunked = /transfer-encoding:\s*chunked/i.test(response);
43
+ let parsedBody = response.split(`\r
13
44
  \r
14
- `)[1];if(l){const c=t,i=[];let e=0;while(e<c.length){const s=c.indexOf(`\r
15
- `,e);if(s===-1)break;const p=c.slice(e,s).trim(),h=parseInt(p,16);if(h===0)break;e=s+2;i.push(c.slice(e,e+h));e+=h+2}t=i.join("")}L({json:()=>JSON.parse(t),text:()=>t})})},y=(o,{method:f="GET",proxy:k,headers:u={},body:g=null}={})=>new Promise((a)=>{if(typeof process>"u"||!process.getBuiltinModule)return fetch(o,{method:f,headers:u,body:g}).then(a);const d=process.getBuiltinModule("node:dns"),L=process.getBuiltinModule("node:net"),m=process.getBuiltinModule("node:tls"),{hostname:r,port:n,pathname:l,protocol:t,search:c}=new URL(o),i=t==="https:",e=l+c,s=n?parseInt(n):i?443:80;if(!k)return d.lookup(r,(w,x)=>{if(w)throw w;const $=i?m.connect({port:s,host:x,servername:r}):L.connect({port:s,host:x});$.on("connect",()=>H($,{method:f,pathname:e,hostname:r,port:s,headers:u,body:g},a))});const p=new URL(k),h=p.protocol.replace(":","");if(h!=="socks5"&&h!=="socks5h")throw Error("iFetch only supports socks5 & socks5h proxies");B({proxy:{hostname:p.hostname,port:Number(p.port),username:p.username,password:p.password},destHost:r,destPort:s,useTLS:i,resolveDnsLocally:p.protocol==="socks5"}).then((w)=>H(w,{method:f,pathname:e,hostname:r,port:s,headers:u,body:g},a))});export default y;
45
+ `)[1];
46
+ if (isChunked) {
47
+ const body2 = parsedBody;
48
+ const chunks = [];
49
+ let i = 0;
50
+ while (i < body2.length) {
51
+ const rnIdx = body2.indexOf(`\r
52
+ `, i);
53
+ if (rnIdx === -1)
54
+ break;
55
+ const sizeHex = body2.slice(i, rnIdx).trim();
56
+ const size = parseInt(sizeHex, 16);
57
+ if (size === 0)
58
+ break;
59
+ i = rnIdx + 2;
60
+ chunks.push(body2.slice(i, i + size));
61
+ i += size + 2;
62
+ }
63
+ parsedBody = chunks.join("");
64
+ }
65
+ resolve({ json: () => JSON.parse(parsedBody), text: () => parsedBody });
66
+ });
67
+ };
68
+ const iFetch = (url, { method = "GET", proxy, headers = {}, body = null } = {}) => new Promise((resolve) => {
69
+ if (typeof process === "undefined" || !process.getBuiltinModule)
70
+ return globals.fetch(url, { method, headers, body }).then(resolve);
71
+ const dns = process.getBuiltinModule("node:dns");
72
+ const net = process.getBuiltinModule("node:net");
73
+ const tls = process.getBuiltinModule("node:tls");
74
+ const { hostname, port: rawPort, pathname: path, protocol, search } = new URL(url);
75
+ const isHttps = protocol === "https:";
76
+ const pathname = path + search;
77
+ const port = rawPort ? parseInt(rawPort) : isHttps ? 443 : 80;
78
+ if (!proxy)
79
+ return dns.lookup(hostname, { family: 4 }, (err, host) => {
80
+ if (err)
81
+ throw err;
82
+ const socket = isHttps ? tls.connect({ port, host, servername: hostname }) : net.connect({ port, host });
83
+ socket.on("connect", () => sendHttpRequest(socket, { method, pathname, hostname, port, headers, body }, resolve));
84
+ });
85
+ const proxyInfo = new URL(proxy);
86
+ const scheme = proxyInfo.protocol.replace(":", "");
87
+ if (scheme !== "socks5" && scheme !== "socks5h")
88
+ throw new Error("iFetch only supports socks5 & socks5h proxies");
89
+ socksConnect({
90
+ proxy: {
91
+ hostname: proxyInfo.hostname,
92
+ port: Number(proxyInfo.port),
93
+ username: proxyInfo.username,
94
+ password: proxyInfo.password
95
+ },
96
+ destHost: hostname,
97
+ destPort: port,
98
+ useTLS: isHttps,
99
+ resolveDnsLocally: proxyInfo.protocol === "socks5"
100
+ }).then((socket) => sendHttpRequest(socket, { method, pathname, hostname, port, headers, body }, resolve));
101
+ });
102
+ export default iFetch;
@@ -1 +1,15 @@
1
- import r from"./fetch.js";const e={},o=typeof window<"u"&&typeof HTMLElement<"u",n=typeof WebSocketPair<"u"&&typeof Cloudflare<"u",t=typeof process<"u"&&process.moduleLoadList?.length>0,s=typeof Deno<"u",i=typeof process<"u"&&!!process.versions?.bun;if(!o&&!n&&!t&&!s&&!i)throw Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");e.isBrowser=o;e.isIsolated=!t&&!s&&!i;import{WWWebSocket as d}from"wwws";e.fetch=o||n?globalThis.fetch:r;e.WebSocket=o||n?globalThis.WebSocket:d;export default e;
1
+ import iFetch from "./fetch.js";
2
+ const globals = {};
3
+ const isBrowser = typeof window !== "undefined" && typeof HTMLElement !== "undefined";
4
+ const isWorker = typeof WebSocketPair !== "undefined" && typeof Cloudflare !== "undefined";
5
+ const isNode = typeof process !== "undefined" && process.moduleLoadList?.length > 0;
6
+ const isDeno = typeof Deno !== "undefined";
7
+ const isBun = typeof process !== "undefined" && !!process.versions?.bun;
8
+ if (!isBrowser && !isWorker && !isNode && !isDeno && !isBun)
9
+ throw new Error("yolkbot doesn't know how to run in this environment. Please open an issue on GitHub with information on where you run yolkbot.");
10
+ globals.isBrowser = isBrowser;
11
+ globals.isIsolated = !isNode && !isDeno && !isBun;
12
+ import { WWWebSocket } from "wwws";
13
+ globals.fetch = isBrowser || isWorker ? (...args) => globalThis.fetch(...args) : iFetch;
14
+ globals.WebSocket = isBrowser || isWorker ? globalThis.WebSocket : WWWebSocket;
15
+ export default globals;
package/dist/index.js CHANGED
@@ -1,2 +1,14 @@
1
- const o="\x1B[31m",t="\x1B[32m",r="\x1B[0m";console.error(["\x1B[31m","how NOT to import yolkbot:",'> import yolkbot from "yolkbot";',"\x1B[32m","how to PROPERLY import yolkbot:",'> import yolkbot from "yolkbot/bot";',"please adjust your code.","\x1B[0m"].join(`
2
- `));
1
+ const red = "\x1B[31m";
2
+ const green = "\x1B[32m";
3
+ const reset = "\x1B[0m";
4
+ console.error([
5
+ red,
6
+ "how NOT to import yolkbot:",
7
+ '> import yolkbot from "yolkbot";',
8
+ green,
9
+ "how to PROPERLY import yolkbot:",
10
+ '> import yolkbot from "yolkbot/bot";',
11
+ "please adjust your code.",
12
+ reset
13
+ ].join(`
14
+ `));
@@ -1 +1,141 @@
1
- import r from"./api.js";import{validate as h}from"./wasm/direct.js";import c from"./env/globals.js";import f from"./socket.js";export class Matchmaker{connected=!1;onceConnected=[];regionList=[];proxy=null;sessionId="";onListeners=new Map;onceListeners=new Map;#e=!1;#t=!1;constructor(s={}){this.#e=s.noExitOnError||!1;if(!s.instance)s.instance="shellshock.io";if(!s.protocol)s.protocol="wss";if(s.api)this.api=s.api;else this.api=new r({proxy:s.proxy,protocol:s.protocol,instance:s.instance,connectionTimeout:s.connectionTimeout});if(s.sessionId||s.noLogin)this.sessionId=s.sessionId;else this.#n();if(s.proxy&&c.isBrowser)this.#i("proxies do not work and hence are not supported in the browser");else if(s.proxy)this.proxy=s.proxy;this.#o(s.instance,s.protocol,s.noLogin,s.connectionTimeout)}async#o(s,i,e,t){this.ws=new f(`${i}://${s}/matchmaker/`,this.proxy);this.ws.connectionTimeout=t||5000;if(!await this.ws.tryConnect())return this.#i("WebSocket did not connect...");this.ws.onmessage=async(o)=>{const n=JSON.parse(o.data);if(n.command==="validateUUID")return this.ws.send(JSON.stringify({command:"validateUUID",hash:await h(n.uuid)}));this.#s("msg",n)};this.ws.onclose=()=>{this.connected=!1;if(!this.#t)this.#o(s,i,e,t)};this.connected=!0;if(this.sessionId||e)this.onceConnected.forEach((o)=>o())}async#n(){const s=await this.api.loginAnonymously();if(!s||typeof s==="string")this.#s("authFail",s);this.sessionId=s.sessionId;if(this.connected)this.onceConnected.forEach((i)=>i())}send(s){this.ws.send(JSON.stringify(s))}async waitForConnect(){return new Promise((s)=>{if(this.connected)s();else this.onceConnected.push(s)})}async getRegions(){await this.waitForConnect();const s=this;return new Promise((i)=>{const e=(t)=>{if(t.command==="regionList"){this.regionList=t.regionList;this.off("msg",e);i(t.regionList)}};this.on("msg",e);this.ws.onerror=(t)=>s.#i("failed to get regions",t);this.ws.send(JSON.stringify({command:"regionList"}))})}close(){this.#t=!0;this.connected=!1;this.ws.close()}on(s,i){if(!this.onListeners.has(s))this.onListeners.set(s,[]);this.onListeners.get(s).push(i)}once(s,i){if(!this.onceListeners.has(s))this.onceListeners.set(s,[]);this.onceListeners.get(s).push(i)}off(s,i){if(this.onListeners.has(s))this.onListeners.set(s,this.onListeners.get(s).filter((e)=>e!==i));if(this.onceListeners.has(s))this.onceListeners.set(s,this.onceListeners.get(s).filter((e)=>e!==i))}#s(s,...i){if(this.onListeners.has(s))this.onListeners.get(s).forEach((e)=>e(...i));if(this.onceListeners.has(s)){this.onceListeners.get(s).forEach((e)=>e(...i));this.onceListeners.delete(s)}}#i(s){if(this.onListeners.has("error"))this.#s("error",s);else if(this.#e)console.error(s);else throw Error(s)}}export default Matchmaker;
1
+ import API from "./api.js";
2
+ import { validate } from "./wasm/direct.js";
3
+ import globals from "./env/globals.js";
4
+ import yolkws from "./socket.js";
5
+
6
+ export class Matchmaker {
7
+ connected = false;
8
+ onceConnected = [];
9
+ regionList = [];
10
+ proxy = null;
11
+ sessionId = "";
12
+ onListeners = new Map;
13
+ onceListeners = new Map;
14
+ #noExitOnError = false;
15
+ #forceClose = false;
16
+ constructor(params = {}) {
17
+ this.#noExitOnError = params.noExitOnError || false;
18
+ if (!params.instance)
19
+ params.instance = "shellshock.io";
20
+ if (!params.protocol)
21
+ params.protocol = "wss";
22
+ if (params.api)
23
+ this.api = params.api;
24
+ else
25
+ this.api = new API({
26
+ proxy: params.proxy,
27
+ protocol: params.protocol,
28
+ instance: params.instance,
29
+ connectionTimeout: params.connectionTimeout
30
+ });
31
+ if (params.sessionId || params.noLogin)
32
+ this.sessionId = params.sessionId;
33
+ else
34
+ this.#createSessionId();
35
+ if (params.proxy && globals.isBrowser)
36
+ this.#processError("proxies do not work and hence are not supported in the browser");
37
+ else if (params.proxy)
38
+ this.proxy = params.proxy;
39
+ this.#createSocket(params.instance, params.protocol, params.noLogin, params.connectionTimeout);
40
+ }
41
+ async#createSocket(instance, protocol, noLogin, connectionTimeout) {
42
+ this.ws = new yolkws(`${protocol}://${instance}/matchmaker/`, this.proxy);
43
+ this.ws.connectionTimeout = connectionTimeout || 5000;
44
+ const didConnect = await this.ws.tryConnect();
45
+ if (!didConnect)
46
+ return this.#processError("WebSocket did not connect...");
47
+ this.ws.onmessage = async (e) => {
48
+ const data = JSON.parse(e.data);
49
+ if (data.command === "validateUUID")
50
+ return this.ws.send(JSON.stringify({ command: "validateUUID", hash: await validate(data.uuid) }));
51
+ this.#emit("msg", data);
52
+ };
53
+ this.ws.onclose = () => {
54
+ this.connected = false;
55
+ if (!this.#forceClose)
56
+ this.#createSocket(instance, protocol, noLogin, connectionTimeout);
57
+ };
58
+ this.connected = true;
59
+ if (this.sessionId || noLogin)
60
+ this.onceConnected.forEach((func) => func());
61
+ }
62
+ async#createSessionId() {
63
+ const anonLogin = await this.api.loginAnonymously();
64
+ if (!anonLogin || typeof anonLogin === "string")
65
+ this.#emit("authFail", anonLogin);
66
+ this.sessionId = anonLogin.sessionId;
67
+ if (this.connected)
68
+ this.onceConnected.forEach((func) => func());
69
+ }
70
+ send(msg) {
71
+ this.ws.send(JSON.stringify(msg));
72
+ }
73
+ async waitForConnect() {
74
+ return new Promise((res) => {
75
+ if (this.connected) {
76
+ res();
77
+ } else {
78
+ this.onceConnected.push(res);
79
+ }
80
+ });
81
+ }
82
+ async getRegions() {
83
+ await this.waitForConnect();
84
+ const that = this;
85
+ return new Promise((res) => {
86
+ const listener = (data2) => {
87
+ if (data2.command === "regionList") {
88
+ this.regionList = data2.regionList;
89
+ this.off("msg", listener);
90
+ res(data2.regionList);
91
+ }
92
+ };
93
+ this.on("msg", listener);
94
+ this.ws.onerror = (e2) => that.#processError("failed to get regions", e2);
95
+ this.ws.send(JSON.stringify({ command: "regionList" }));
96
+ });
97
+ }
98
+ close() {
99
+ this.#forceClose = true;
100
+ this.connected = false;
101
+ this.ws.close();
102
+ }
103
+ on(event, callback) {
104
+ if (!this.onListeners.has(event)) {
105
+ this.onListeners.set(event, []);
106
+ }
107
+ this.onListeners.get(event).push(callback);
108
+ }
109
+ once(event, callback) {
110
+ if (!this.onceListeners.has(event)) {
111
+ this.onceListeners.set(event, []);
112
+ }
113
+ this.onceListeners.get(event).push(callback);
114
+ }
115
+ off(event, callback) {
116
+ if (this.onListeners.has(event)) {
117
+ this.onListeners.set(event, this.onListeners.get(event).filter((func) => func !== callback));
118
+ }
119
+ if (this.onceListeners.has(event)) {
120
+ this.onceListeners.set(event, this.onceListeners.get(event).filter((func) => func !== callback));
121
+ }
122
+ }
123
+ #emit(event, ...args) {
124
+ if (this.onListeners.has(event)) {
125
+ this.onListeners.get(event).forEach((func) => func(...args));
126
+ }
127
+ if (this.onceListeners.has(event)) {
128
+ this.onceListeners.get(event).forEach((func) => func(...args));
129
+ this.onceListeners.delete(event);
130
+ }
131
+ }
132
+ #processError(error) {
133
+ if (this.onListeners.has("error"))
134
+ this.#emit("error", error);
135
+ else if (this.#noExitOnError)
136
+ console.error(error);
137
+ else
138
+ throw new Error(error);
139
+ }
140
+ }
141
+ export default Matchmaker;