@wabot-dev/framework 0.0.12 → 0.0.14

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 (367) hide show
  1. package/dist/src/_virtual/XMLHttpRequest.js +7 -0
  2. package/dist/src/_virtual/_commonjsHelpers.js +32 -0
  3. package/dist/src/_virtual/base64id.js +3 -0
  4. package/dist/src/_virtual/binary.js +3 -0
  5. package/dist/src/_virtual/bom-handling.js +3 -0
  6. package/dist/src/_virtual/broadcast-operator.js +3 -0
  7. package/dist/src/_virtual/browser.js +3 -0
  8. package/dist/src/_virtual/browser2.js +3 -0
  9. package/dist/src/_virtual/browser3.js +3 -0
  10. package/dist/src/_virtual/browser4.js +3 -0
  11. package/dist/src/_virtual/browser5.js +3 -0
  12. package/dist/src/_virtual/buffer-util.js +3 -0
  13. package/dist/src/_virtual/buffer-util2.js +3 -0
  14. package/dist/src/_virtual/buffer-util3.js +3 -0
  15. package/dist/src/_virtual/charset.js +3 -0
  16. package/dist/src/_virtual/charset2.js +3 -0
  17. package/dist/src/_virtual/client.js +3 -0
  18. package/dist/src/_virtual/cluster-adapter.js +3 -0
  19. package/dist/src/_virtual/commons.js +3 -0
  20. package/dist/src/_virtual/dbcs-codec.js +3 -0
  21. package/dist/src/_virtual/decodePacket.js +3 -0
  22. package/dist/src/_virtual/encodePacket.js +3 -0
  23. package/dist/src/_virtual/encoding.js +3 -0
  24. package/dist/src/_virtual/encoding2.js +3 -0
  25. package/dist/src/_virtual/engine.io.js +3 -0
  26. package/dist/src/_virtual/in-memory-adapter.js +3 -0
  27. package/dist/src/_virtual/index.js +7 -0
  28. package/dist/src/_virtual/index10.js +3 -0
  29. package/dist/src/_virtual/index11.js +3 -0
  30. package/dist/src/_virtual/index12.js +3 -0
  31. package/dist/src/_virtual/index13.js +3 -0
  32. package/dist/src/_virtual/index14.js +3 -0
  33. package/dist/src/_virtual/index15.js +3 -0
  34. package/dist/src/_virtual/index16.js +3 -0
  35. package/dist/src/_virtual/index17.js +3 -0
  36. package/dist/src/_virtual/index18.js +3 -0
  37. package/dist/src/_virtual/index19.js +3 -0
  38. package/dist/src/_virtual/index2.js +7 -0
  39. package/dist/src/_virtual/index20.js +3 -0
  40. package/dist/src/_virtual/index21.js +3 -0
  41. package/dist/src/_virtual/index22.js +3 -0
  42. package/dist/src/_virtual/index23.js +3 -0
  43. package/dist/src/_virtual/index24.js +3 -0
  44. package/dist/src/_virtual/index25.js +3 -0
  45. package/dist/src/_virtual/index26.js +3 -0
  46. package/dist/src/_virtual/index27.js +3 -0
  47. package/dist/src/_virtual/index28.js +3 -0
  48. package/dist/src/_virtual/index29.js +3 -0
  49. package/dist/src/_virtual/index3.js +7 -0
  50. package/dist/src/_virtual/index30.js +3 -0
  51. package/dist/src/_virtual/index31.js +3 -0
  52. package/dist/src/_virtual/index32.js +3 -0
  53. package/dist/src/_virtual/index33.js +3 -0
  54. package/dist/src/_virtual/index4.js +3 -0
  55. package/dist/src/_virtual/index5.js +3 -0
  56. package/dist/src/_virtual/index6.js +3 -0
  57. package/dist/src/_virtual/index7.js +3 -0
  58. package/dist/src/_virtual/index8.js +6 -0
  59. package/dist/src/_virtual/index9.js +3 -0
  60. package/dist/src/_virtual/inherits.js +3 -0
  61. package/dist/src/_virtual/inherits_browser.js +3 -0
  62. package/dist/src/_virtual/is-binary.js +3 -0
  63. package/dist/src/_virtual/language.js +3 -0
  64. package/dist/src/_virtual/language2.js +3 -0
  65. package/dist/src/_virtual/mediaType.js +3 -0
  66. package/dist/src/_virtual/mediaType2.js +3 -0
  67. package/dist/src/_virtual/namespace.js +3 -0
  68. package/dist/src/_virtual/node.js +3 -0
  69. package/dist/src/_virtual/node2.js +3 -0
  70. package/dist/src/_virtual/node3.js +3 -0
  71. package/dist/src/_virtual/node4.js +3 -0
  72. package/dist/src/_virtual/node5.js +3 -0
  73. package/dist/src/_virtual/parent-namespace.js +3 -0
  74. package/dist/src/_virtual/polling-jsonp.js +3 -0
  75. package/dist/src/_virtual/polling.js +3 -0
  76. package/dist/src/_virtual/polling2.js +3 -0
  77. package/dist/src/_virtual/receiver.js +3 -0
  78. package/dist/src/_virtual/sbcs-codec.js +3 -0
  79. package/dist/src/_virtual/sender.js +3 -0
  80. package/dist/src/_virtual/server.js +3 -0
  81. package/dist/src/_virtual/socket-types.js +3 -0
  82. package/dist/src/_virtual/socket.js +3 -0
  83. package/dist/src/_virtual/socket2.js +3 -0
  84. package/dist/src/_virtual/stream.js +3 -0
  85. package/dist/src/_virtual/transport.js +3 -0
  86. package/dist/src/_virtual/typed-events.js +3 -0
  87. package/dist/src/_virtual/userver.js +3 -0
  88. package/dist/src/_virtual/utf16.js +3 -0
  89. package/dist/src/_virtual/utf32.js +3 -0
  90. package/dist/src/_virtual/utf7.js +3 -0
  91. package/dist/src/_virtual/uws.js +3 -0
  92. package/dist/src/_virtual/validation.js +3 -0
  93. package/dist/src/_virtual/validation2.js +3 -0
  94. package/dist/src/_virtual/validation3.js +3 -0
  95. package/dist/src/_virtual/websocket-server.js +3 -0
  96. package/dist/src/_virtual/websocket.js +7 -0
  97. package/dist/src/_virtual/websocket2.js +3 -0
  98. package/dist/src/_virtual/websocket3.js +3 -0
  99. package/dist/src/_virtual/webtransport.js +3 -0
  100. package/dist/src/_virtual/yeast.js +3 -0
  101. package/dist/src/channels/cmd/@cmd.js +2 -0
  102. package/dist/src/channels/cmd/CmdChannel.js +2 -0
  103. package/dist/src/channels/telegram/@telegram.js +2 -0
  104. package/dist/src/channels/telegram/TelegramChannel.js +2 -0
  105. package/dist/src/channels/whatsapp/@whatsapp.js +24 -0
  106. package/dist/src/channels/whatsapp/WhatsAppChannel.js +63 -0
  107. package/dist/src/channels/whatsapp/WhatsAppChannelConfig.js +8 -0
  108. package/dist/src/channels/whatsapp/WhatsAppConnection.js +61 -0
  109. package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +61 -0
  110. package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +36 -0
  111. package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +9 -0
  112. package/dist/src/controller/express/Express.js +5 -0
  113. package/dist/src/controller/socket.io/SocketIO.js +5 -0
  114. package/dist/src/env/WabotEnv.js +21 -0
  115. package/dist/src/index.d.ts +168 -1
  116. package/dist/src/index.js +12 -0
  117. package/dist/src/logger/Logger.js +65 -0
  118. package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +171 -0
  119. package/dist/src/node_modules/base64id/lib/base64id.js +117 -0
  120. package/dist/src/node_modules/body-parser/index.js +96 -0
  121. package/dist/src/node_modules/body-parser/lib/read.js +225 -0
  122. package/dist/src/node_modules/body-parser/lib/types/json.js +222 -0
  123. package/dist/src/node_modules/body-parser/lib/types/raw.js +90 -0
  124. package/dist/src/node_modules/body-parser/lib/types/text.js +95 -0
  125. package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +194 -0
  126. package/dist/src/node_modules/body-parser/lib/utils.js +96 -0
  127. package/dist/src/node_modules/bytes/index.js +180 -0
  128. package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +24 -0
  129. package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +13 -0
  130. package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +13 -0
  131. package/dist/src/node_modules/call-bind-apply-helpers/index.js +29 -0
  132. package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +13 -0
  133. package/dist/src/node_modules/call-bound/index.js +31 -0
  134. package/dist/src/node_modules/content-type/index.js +235 -0
  135. package/dist/src/node_modules/cookie/index.js +345 -0
  136. package/dist/src/node_modules/cors/lib/index.js +249 -0
  137. package/dist/src/node_modules/debug/src/browser.js +286 -0
  138. package/dist/src/node_modules/debug/src/common.js +303 -0
  139. package/dist/src/node_modules/debug/src/index.js +23 -0
  140. package/dist/src/node_modules/debug/src/node.js +279 -0
  141. package/dist/src/node_modules/depd/index.js +550 -0
  142. package/dist/src/node_modules/dunder-proto/get.js +42 -0
  143. package/dist/src/node_modules/ee-first/index.js +104 -0
  144. package/dist/src/node_modules/engine.io/build/engine.io.js +73 -0
  145. package/dist/src/node_modules/engine.io/build/parser-v3/index.js +429 -0
  146. package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +198 -0
  147. package/dist/src/node_modules/engine.io/build/server.js +808 -0
  148. package/dist/src/node_modules/engine.io/build/socket.js +469 -0
  149. package/dist/src/node_modules/engine.io/build/transport.js +131 -0
  150. package/dist/src/node_modules/engine.io/build/transports/index.js +37 -0
  151. package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +53 -0
  152. package/dist/src/node_modules/engine.io/build/transports/polling.js +346 -0
  153. package/dist/src/node_modules/engine.io/build/transports/websocket.js +106 -0
  154. package/dist/src/node_modules/engine.io/build/transports/webtransport.js +76 -0
  155. package/dist/src/node_modules/engine.io/build/transports-uws/index.js +20 -0
  156. package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +378 -0
  157. package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +85 -0
  158. package/dist/src/node_modules/engine.io/build/userver.js +292 -0
  159. package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +250 -0
  160. package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +285 -0
  161. package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +285 -0
  162. package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +23 -0
  163. package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +279 -0
  164. package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +10704 -0
  165. package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +24 -0
  166. package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +202 -0
  167. package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +96 -0
  168. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +179 -0
  169. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +193 -0
  170. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +188 -0
  171. package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +304 -0
  172. package/dist/src/node_modules/engine.io/node_modules/ws/index.js +28 -0
  173. package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +142 -0
  174. package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +21 -0
  175. package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +303 -0
  176. package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +214 -0
  177. package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +64 -0
  178. package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +528 -0
  179. package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +719 -0
  180. package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +513 -0
  181. package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +170 -0
  182. package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +73 -0
  183. package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +141 -0
  184. package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +559 -0
  185. package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +1363 -0
  186. package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +13 -0
  187. package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +36 -0
  188. package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +66 -0
  189. package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +92 -0
  190. package/dist/src/node_modules/engine.io-client/build/esm/index.js +17 -0
  191. package/dist/src/node_modules/engine.io-client/build/esm/socket.js +728 -0
  192. package/dist/src/node_modules/engine.io-client/build/esm/transport.js +143 -0
  193. package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +11 -0
  194. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +256 -0
  195. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +21 -0
  196. package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +146 -0
  197. package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +107 -0
  198. package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +48 -0
  199. package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +83 -0
  200. package/dist/src/node_modules/engine.io-client/build/esm/util.js +62 -0
  201. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +142 -0
  202. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +21 -0
  203. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +303 -0
  204. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +214 -0
  205. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +64 -0
  206. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +528 -0
  207. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +719 -0
  208. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +513 -0
  209. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +170 -0
  210. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +73 -0
  211. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +141 -0
  212. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +559 -0
  213. package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +1363 -0
  214. package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +29 -0
  215. package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +70 -0
  216. package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +51 -0
  217. package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +179 -0
  218. package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +15 -0
  219. package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +58 -0
  220. package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +36 -0
  221. package/dist/src/node_modules/engine.io-parser/build/esm/index.js +158 -0
  222. package/dist/src/node_modules/es-define-property/index.js +23 -0
  223. package/dist/src/node_modules/es-errors/eval.js +13 -0
  224. package/dist/src/node_modules/es-errors/index.js +13 -0
  225. package/dist/src/node_modules/es-errors/range.js +13 -0
  226. package/dist/src/node_modules/es-errors/ref.js +13 -0
  227. package/dist/src/node_modules/es-errors/syntax.js +13 -0
  228. package/dist/src/node_modules/es-errors/type.js +13 -0
  229. package/dist/src/node_modules/es-errors/uri.js +13 -0
  230. package/dist/src/node_modules/es-object-atoms/index.js +13 -0
  231. package/dist/src/node_modules/function-bind/implementation.js +93 -0
  232. package/dist/src/node_modules/function-bind/index.js +16 -0
  233. package/dist/src/node_modules/get-intrinsic/index.js +413 -0
  234. package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +17 -0
  235. package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +13 -0
  236. package/dist/src/node_modules/get-proto/index.js +40 -0
  237. package/dist/src/node_modules/gopd/gOPD.js +13 -0
  238. package/dist/src/node_modules/gopd/index.js +26 -0
  239. package/dist/src/node_modules/has-symbols/index.js +25 -0
  240. package/dist/src/node_modules/has-symbols/shams.js +54 -0
  241. package/dist/src/node_modules/hasown/index.js +19 -0
  242. package/dist/src/node_modules/http-errors/index.js +306 -0
  243. package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +598 -0
  244. package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +206 -0
  245. package/dist/src/node_modules/iconv-lite/encodings/index.js +44 -0
  246. package/dist/src/node_modules/iconv-lite/encodings/internal.js +210 -0
  247. package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +83 -0
  248. package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +460 -0
  249. package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +187 -0
  250. package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +506 -0
  251. package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +2621 -0
  252. package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +2380 -0
  253. package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +729 -0
  254. package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +822 -0
  255. package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +424 -0
  256. package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +264 -0
  257. package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +548 -0
  258. package/dist/src/node_modules/iconv-lite/encodings/utf16.js +206 -0
  259. package/dist/src/node_modules/iconv-lite/encodings/utf32.js +329 -0
  260. package/dist/src/node_modules/iconv-lite/encodings/utf7.js +297 -0
  261. package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +61 -0
  262. package/dist/src/node_modules/iconv-lite/lib/index.js +192 -0
  263. package/dist/src/node_modules/iconv-lite/lib/streams.js +120 -0
  264. package/dist/src/node_modules/inherits/inherits.js +21 -0
  265. package/dist/src/node_modules/inherits/inherits_browser.js +38 -0
  266. package/dist/src/node_modules/math-intrinsics/abs.js +13 -0
  267. package/dist/src/node_modules/math-intrinsics/floor.js +13 -0
  268. package/dist/src/node_modules/math-intrinsics/isNaN.js +15 -0
  269. package/dist/src/node_modules/math-intrinsics/max.js +13 -0
  270. package/dist/src/node_modules/math-intrinsics/min.js +13 -0
  271. package/dist/src/node_modules/math-intrinsics/pow.js +13 -0
  272. package/dist/src/node_modules/math-intrinsics/round.js +13 -0
  273. package/dist/src/node_modules/math-intrinsics/sign.js +22 -0
  274. package/dist/src/node_modules/media-typer/index.js +153 -0
  275. package/dist/src/node_modules/mime-db/db.json.js +11656 -0
  276. package/dist/src/node_modules/mime-db/index.js +24 -0
  277. package/dist/src/node_modules/mime-types/index.js +226 -0
  278. package/dist/src/node_modules/mime-types/mimeScore.js +62 -0
  279. package/dist/src/node_modules/ms/index.js +172 -0
  280. package/dist/src/node_modules/object-assign/index.js +99 -0
  281. package/dist/src/node_modules/object-inspect/index.js +557 -0
  282. package/dist/src/node_modules/object-inspect/util.inspect.js +13 -0
  283. package/dist/src/node_modules/on-finished/index.js +245 -0
  284. package/dist/src/node_modules/qs/lib/formats.js +32 -0
  285. package/dist/src/node_modules/qs/lib/index.js +24 -0
  286. package/dist/src/node_modules/qs/lib/parse.js +339 -0
  287. package/dist/src/node_modules/qs/lib/stringify.js +369 -0
  288. package/dist/src/node_modules/qs/lib/utils.js +279 -0
  289. package/dist/src/node_modules/raw-body/index.js +351 -0
  290. package/dist/src/node_modules/safer-buffer/safer.js +88 -0
  291. package/dist/src/node_modules/setprototypeof/index.js +26 -0
  292. package/dist/src/node_modules/side-channel/index.js +58 -0
  293. package/dist/src/node_modules/side-channel-list/index.js +125 -0
  294. package/dist/src/node_modules/side-channel-map/index.js +82 -0
  295. package/dist/src/node_modules/side-channel-weakmap/index.js +99 -0
  296. package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +448 -0
  297. package/dist/src/node_modules/socket.io/dist/client.js +281 -0
  298. package/dist/src/node_modules/socket.io/dist/index.js +837 -0
  299. package/dist/src/node_modules/socket.io/dist/namespace.js +597 -0
  300. package/dist/src/node_modules/socket.io/dist/parent-namespace.js +101 -0
  301. package/dist/src/node_modules/socket.io/dist/socket-types.js +21 -0
  302. package/dist/src/node_modules/socket.io/dist/socket.js +993 -0
  303. package/dist/src/node_modules/socket.io/dist/typed-events.js +92 -0
  304. package/dist/src/node_modules/socket.io/dist/uws.js +149 -0
  305. package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +250 -0
  306. package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +285 -0
  307. package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +285 -0
  308. package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +23 -0
  309. package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +279 -0
  310. package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +10704 -0
  311. package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +24 -0
  312. package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +202 -0
  313. package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +96 -0
  314. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +179 -0
  315. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +193 -0
  316. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +188 -0
  317. package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +304 -0
  318. package/dist/src/node_modules/socket.io/package.json.js +5 -0
  319. package/dist/src/node_modules/socket.io/wrapper.js +5 -0
  320. package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +689 -0
  321. package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +64 -0
  322. package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +407 -0
  323. package/dist/src/node_modules/socket.io-adapter/dist/index.js +24 -0
  324. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +285 -0
  325. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +285 -0
  326. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +23 -0
  327. package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +279 -0
  328. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +28 -0
  329. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +142 -0
  330. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +21 -0
  331. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +303 -0
  332. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +214 -0
  333. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +64 -0
  334. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +528 -0
  335. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +719 -0
  336. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +513 -0
  337. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +170 -0
  338. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +73 -0
  339. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +141 -0
  340. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +559 -0
  341. package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +1363 -0
  342. package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +68 -0
  343. package/dist/src/node_modules/socket.io-client/build/esm/index.js +50 -0
  344. package/dist/src/node_modules/socket.io-client/build/esm/manager.js +373 -0
  345. package/dist/src/node_modules/socket.io-client/build/esm/on.js +8 -0
  346. package/dist/src/node_modules/socket.io-client/build/esm/socket.js +884 -0
  347. package/dist/src/node_modules/socket.io-client/build/esm/url.js +63 -0
  348. package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +99 -0
  349. package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +337 -0
  350. package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +65 -0
  351. package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +86 -0
  352. package/dist/src/node_modules/socket.io-parser/build/esm/index.js +314 -0
  353. package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +52 -0
  354. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +285 -0
  355. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +285 -0
  356. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +23 -0
  357. package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +279 -0
  358. package/dist/src/node_modules/statuses/codes.json.js +67 -0
  359. package/dist/src/node_modules/statuses/index.js +157 -0
  360. package/dist/src/node_modules/toidentifier/index.js +41 -0
  361. package/dist/src/node_modules/type-is/index.js +263 -0
  362. package/dist/src/node_modules/unpipe/index.js +78 -0
  363. package/dist/src/node_modules/vary/index.js +159 -0
  364. package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +702 -0
  365. package/dist/src/server/runChannel.js +8 -8
  366. package/dist/src/server/runServer.js +41 -2
  367. package/package.json +7 -3
@@ -0,0 +1,837 @@
1
+ import { __module as dist$1 } from '../../../_virtual/index6.js';
2
+ import require$$2 from 'http';
3
+ import require$$1 from 'fs';
4
+ import require$$0$1 from 'zlib';
5
+ import { __require as requireAccepts } from '../node_modules/accepts/index.js';
6
+ import require$$0 from 'stream';
7
+ import path from 'path';
8
+ import { __require as requireEngine_io } from '../../engine.io/build/engine.io.js';
9
+ import { __require as requireClient } from './client.js';
10
+ import require$$0$2 from 'events';
11
+ import { __require as requireNamespace } from './namespace.js';
12
+ import { __require as requireParentNamespace } from './parent-namespace.js';
13
+ import { __require as requireDist$1 } from '../../socket.io-adapter/dist/index.js';
14
+ import { __require as requireCjs } from '../../socket.io-parser/build/cjs/index.js';
15
+ import { __require as requireSrc } from '../node_modules/debug/src/index.js';
16
+ import { __require as requireSocket } from './socket.js';
17
+ import { __require as requireTypedEvents } from './typed-events.js';
18
+ import { __require as requireUws } from './uws.js';
19
+ import { __require as requireLib } from '../../cors/lib/index.js';
20
+ import require$$18 from '../package.json.js';
21
+
22
+ var dist = dist$1.exports;
23
+
24
+ var hasRequiredDist;
25
+
26
+ function requireDist () {
27
+ if (hasRequiredDist) return dist$1.exports;
28
+ hasRequiredDist = 1;
29
+ (function (module, exports) {
30
+ var __createBinding = (dist && dist.__createBinding) || (Object.create ? (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ var desc = Object.getOwnPropertyDescriptor(m, k);
33
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
34
+ desc = { enumerable: true, get: function() { return m[k]; } };
35
+ }
36
+ Object.defineProperty(o, k2, desc);
37
+ }) : (function(o, m, k, k2) {
38
+ if (k2 === undefined) k2 = k;
39
+ o[k2] = m[k];
40
+ }));
41
+ var __setModuleDefault = (dist && dist.__setModuleDefault) || (Object.create ? (function(o, v) {
42
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
43
+ }) : function(o, v) {
44
+ o["default"] = v;
45
+ });
46
+ var __importStar = (dist && dist.__importStar) || function (mod) {
47
+ if (mod && mod.__esModule) return mod;
48
+ var result = {};
49
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
50
+ __setModuleDefault(result, mod);
51
+ return result;
52
+ };
53
+ var __importDefault = (dist && dist.__importDefault) || function (mod) {
54
+ return (mod && mod.__esModule) ? mod : { "default": mod };
55
+ };
56
+ Object.defineProperty(exports, "__esModule", { value: true });
57
+ exports.Namespace = exports.Socket = exports.Server = void 0;
58
+ const http = require$$2;
59
+ const fs_1 = require$$1;
60
+ const zlib_1 = require$$0$1;
61
+ const accepts = requireAccepts();
62
+ const stream_1 = require$$0;
63
+ const path$1 = path;
64
+ const engine_io_1 = requireEngine_io();
65
+ const client_1 = requireClient();
66
+ const events_1 = require$$0$2;
67
+ const namespace_1 = requireNamespace();
68
+ Object.defineProperty(exports, "Namespace", { enumerable: true, get: function () { return namespace_1.Namespace; } });
69
+ const parent_namespace_1 = requireParentNamespace();
70
+ const socket_io_adapter_1 = requireDist$1();
71
+ const parser = __importStar(requireCjs());
72
+ const debug_1 = __importDefault(requireSrc());
73
+ const socket_1 = requireSocket();
74
+ Object.defineProperty(exports, "Socket", { enumerable: true, get: function () { return socket_1.Socket; } });
75
+ const typed_events_1 = requireTypedEvents();
76
+ const uws_1 = requireUws();
77
+ const cors_1 = __importDefault(requireLib());
78
+ const debug = (0, debug_1.default)("socket.io:server");
79
+ const clientVersion = require$$18.version;
80
+ const dotMapRegex = /\.map/;
81
+ /**
82
+ * Represents a Socket.IO server.
83
+ *
84
+ * @example
85
+ * import { Server } from "socket.io";
86
+ *
87
+ * const io = new Server();
88
+ *
89
+ * io.on("connection", (socket) => {
90
+ * console.log(`socket ${socket.id} connected`);
91
+ *
92
+ * // send an event to the client
93
+ * socket.emit("foo", "bar");
94
+ *
95
+ * socket.on("foobar", () => {
96
+ * // an event was received from the client
97
+ * });
98
+ *
99
+ * // upon disconnection
100
+ * socket.on("disconnect", (reason) => {
101
+ * console.log(`socket ${socket.id} disconnected due to ${reason}`);
102
+ * });
103
+ * });
104
+ *
105
+ * io.listen(3000);
106
+ */
107
+ class Server extends typed_events_1.StrictEventEmitter {
108
+ constructor(srv, opts = {}) {
109
+ super();
110
+ /**
111
+ * @private
112
+ */
113
+ this._nsps = new Map();
114
+ this.parentNsps = new Map();
115
+ /**
116
+ * A subset of the {@link parentNsps} map, only containing {@link ParentNamespace} which are based on a regular
117
+ * expression.
118
+ *
119
+ * @private
120
+ */
121
+ this.parentNamespacesFromRegExp = new Map();
122
+ if ("object" === typeof srv &&
123
+ srv instanceof Object &&
124
+ !srv.listen) {
125
+ opts = srv;
126
+ srv = undefined;
127
+ }
128
+ this.path(opts.path || "/socket.io");
129
+ this.connectTimeout(opts.connectTimeout || 45000);
130
+ this.serveClient(false !== opts.serveClient);
131
+ this._parser = opts.parser || parser;
132
+ this.encoder = new this._parser.Encoder();
133
+ this.opts = opts;
134
+ if (opts.connectionStateRecovery) {
135
+ opts.connectionStateRecovery = Object.assign({
136
+ maxDisconnectionDuration: 2 * 60 * 1000,
137
+ skipMiddlewares: true,
138
+ }, opts.connectionStateRecovery);
139
+ this.adapter(opts.adapter || socket_io_adapter_1.SessionAwareAdapter);
140
+ }
141
+ else {
142
+ this.adapter(opts.adapter || socket_io_adapter_1.Adapter);
143
+ }
144
+ opts.cleanupEmptyChildNamespaces = !!opts.cleanupEmptyChildNamespaces;
145
+ this.sockets = this.of("/");
146
+ if (srv || typeof srv == "number")
147
+ this.attach(srv);
148
+ if (this.opts.cors) {
149
+ this._corsMiddleware = (0, cors_1.default)(this.opts.cors);
150
+ }
151
+ }
152
+ get _opts() {
153
+ return this.opts;
154
+ }
155
+ serveClient(v) {
156
+ if (!arguments.length)
157
+ return this._serveClient;
158
+ this._serveClient = v;
159
+ return this;
160
+ }
161
+ /**
162
+ * Executes the middleware for an incoming namespace not already created on the server.
163
+ *
164
+ * @param name - name of incoming namespace
165
+ * @param auth - the auth parameters
166
+ * @param fn - callback
167
+ *
168
+ * @private
169
+ */
170
+ _checkNamespace(name, auth, fn) {
171
+ if (this.parentNsps.size === 0)
172
+ return fn(false);
173
+ const keysIterator = this.parentNsps.keys();
174
+ const run = () => {
175
+ const nextFn = keysIterator.next();
176
+ if (nextFn.done) {
177
+ return fn(false);
178
+ }
179
+ nextFn.value(name, auth, (err, allow) => {
180
+ if (err || !allow) {
181
+ return run();
182
+ }
183
+ if (this._nsps.has(name)) {
184
+ // the namespace was created in the meantime
185
+ debug("dynamic namespace %s already exists", name);
186
+ return fn(this._nsps.get(name));
187
+ }
188
+ const namespace = this.parentNsps.get(nextFn.value).createChild(name);
189
+ debug("dynamic namespace %s was created", name);
190
+ fn(namespace);
191
+ });
192
+ };
193
+ run();
194
+ }
195
+ path(v) {
196
+ if (!arguments.length)
197
+ return this._path;
198
+ this._path = v.replace(/\/$/, "");
199
+ const escapedPath = this._path.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
200
+ this.clientPathRegex = new RegExp("^" +
201
+ escapedPath +
202
+ "/socket\\.io(\\.msgpack|\\.esm)?(\\.min)?\\.js(\\.map)?(?:\\?|$)");
203
+ return this;
204
+ }
205
+ connectTimeout(v) {
206
+ if (v === undefined)
207
+ return this._connectTimeout;
208
+ this._connectTimeout = v;
209
+ return this;
210
+ }
211
+ adapter(v) {
212
+ if (!arguments.length)
213
+ return this._adapter;
214
+ this._adapter = v;
215
+ for (const nsp of this._nsps.values()) {
216
+ nsp._initAdapter();
217
+ }
218
+ return this;
219
+ }
220
+ /**
221
+ * Attaches socket.io to a server or port.
222
+ *
223
+ * @param srv - server or port
224
+ * @param opts - options passed to engine.io
225
+ * @return self
226
+ */
227
+ listen(srv, opts = {}) {
228
+ return this.attach(srv, opts);
229
+ }
230
+ /**
231
+ * Attaches socket.io to a server or port.
232
+ *
233
+ * @param srv - server or port
234
+ * @param opts - options passed to engine.io
235
+ * @return self
236
+ */
237
+ attach(srv, opts = {}) {
238
+ if ("function" == typeof srv) {
239
+ const msg = "You are trying to attach socket.io to an express " +
240
+ "request handler function. Please pass a http.Server instance.";
241
+ throw new Error(msg);
242
+ }
243
+ // handle a port as a string
244
+ if (Number(srv) == srv) {
245
+ srv = Number(srv);
246
+ }
247
+ if ("number" == typeof srv) {
248
+ debug("creating http server and binding to %d", srv);
249
+ const port = srv;
250
+ srv = http.createServer((req, res) => {
251
+ res.writeHead(404);
252
+ res.end();
253
+ });
254
+ srv.listen(port);
255
+ }
256
+ // merge the options passed to the Socket.IO server
257
+ Object.assign(opts, this.opts);
258
+ // set engine.io path to `/socket.io`
259
+ opts.path = opts.path || this._path;
260
+ this.initEngine(srv, opts);
261
+ return this;
262
+ }
263
+ attachApp(app /*: TemplatedApp */, opts = {}) {
264
+ // merge the options passed to the Socket.IO server
265
+ Object.assign(opts, this.opts);
266
+ // set engine.io path to `/socket.io`
267
+ opts.path = opts.path || this._path;
268
+ // initialize engine
269
+ debug("creating uWebSockets.js-based engine with opts %j", opts);
270
+ const engine = new engine_io_1.uServer(opts);
271
+ engine.attach(app, opts);
272
+ // bind to engine events
273
+ this.bind(engine);
274
+ if (this._serveClient) {
275
+ // attach static file serving
276
+ app.get(`${this._path}/*`, (res, req) => {
277
+ if (!this.clientPathRegex.test(req.getUrl())) {
278
+ req.setYield(true);
279
+ return;
280
+ }
281
+ const filename = req
282
+ .getUrl()
283
+ .replace(this._path, "")
284
+ .replace(/\?.*$/, "")
285
+ .replace(/^\//, "");
286
+ const isMap = dotMapRegex.test(filename);
287
+ const type = isMap ? "map" : "source";
288
+ // Per the standard, ETags must be quoted:
289
+ // https://tools.ietf.org/html/rfc7232#section-2.3
290
+ const expectedEtag = '"' + clientVersion + '"';
291
+ const weakEtag = "W/" + expectedEtag;
292
+ const etag = req.getHeader("if-none-match");
293
+ if (etag) {
294
+ if (expectedEtag === etag || weakEtag === etag) {
295
+ debug("serve client %s 304", type);
296
+ res.writeStatus("304 Not Modified");
297
+ res.end();
298
+ return;
299
+ }
300
+ }
301
+ debug("serve client %s", type);
302
+ res.writeHeader("cache-control", "public, max-age=0");
303
+ res.writeHeader("content-type", "application/" + (isMap ? "json" : "javascript") + "; charset=utf-8");
304
+ res.writeHeader("etag", expectedEtag);
305
+ const filepath = path$1.join(__dirname, "../client-dist/", filename);
306
+ (0, uws_1.serveFile)(res, filepath);
307
+ });
308
+ }
309
+ (0, uws_1.patchAdapter)(app);
310
+ }
311
+ /**
312
+ * Initialize engine
313
+ *
314
+ * @param srv - the server to attach to
315
+ * @param opts - options passed to engine.io
316
+ * @private
317
+ */
318
+ initEngine(srv, opts) {
319
+ // initialize engine
320
+ debug("creating engine.io instance with opts %j", opts);
321
+ this.eio = (0, engine_io_1.attach)(srv, opts);
322
+ // attach static file serving
323
+ if (this._serveClient)
324
+ this.attachServe(srv);
325
+ // Export http server
326
+ this.httpServer = srv;
327
+ // bind to engine events
328
+ this.bind(this.eio);
329
+ }
330
+ /**
331
+ * Attaches the static file serving.
332
+ *
333
+ * @param srv http server
334
+ * @private
335
+ */
336
+ attachServe(srv) {
337
+ debug("attaching client serving req handler");
338
+ const evs = srv.listeners("request").slice(0);
339
+ srv.removeAllListeners("request");
340
+ srv.on("request", (req, res) => {
341
+ if (this.clientPathRegex.test(req.url)) {
342
+ if (this._corsMiddleware) {
343
+ this._corsMiddleware(req, res, () => {
344
+ this.serve(req, res);
345
+ });
346
+ }
347
+ else {
348
+ this.serve(req, res);
349
+ }
350
+ }
351
+ else {
352
+ for (let i = 0; i < evs.length; i++) {
353
+ evs[i].call(srv, req, res);
354
+ }
355
+ }
356
+ });
357
+ }
358
+ /**
359
+ * Handles a request serving of client source and map
360
+ *
361
+ * @param req
362
+ * @param res
363
+ * @private
364
+ */
365
+ serve(req, res) {
366
+ const filename = req.url.replace(this._path, "").replace(/\?.*$/, "");
367
+ const isMap = dotMapRegex.test(filename);
368
+ const type = isMap ? "map" : "source";
369
+ // Per the standard, ETags must be quoted:
370
+ // https://tools.ietf.org/html/rfc7232#section-2.3
371
+ const expectedEtag = '"' + clientVersion + '"';
372
+ const weakEtag = "W/" + expectedEtag;
373
+ const etag = req.headers["if-none-match"];
374
+ if (etag) {
375
+ if (expectedEtag === etag || weakEtag === etag) {
376
+ debug("serve client %s 304", type);
377
+ res.writeHead(304);
378
+ res.end();
379
+ return;
380
+ }
381
+ }
382
+ debug("serve client %s", type);
383
+ res.setHeader("Cache-Control", "public, max-age=0");
384
+ res.setHeader("Content-Type", "application/" + (isMap ? "json" : "javascript") + "; charset=utf-8");
385
+ res.setHeader("ETag", expectedEtag);
386
+ Server.sendFile(filename, req, res);
387
+ }
388
+ /**
389
+ * @param filename
390
+ * @param req
391
+ * @param res
392
+ * @private
393
+ */
394
+ static sendFile(filename, req, res) {
395
+ const readStream = (0, fs_1.createReadStream)(path$1.join(__dirname, "../client-dist/", filename));
396
+ const encoding = accepts(req).encodings(["br", "gzip", "deflate"]);
397
+ const onError = (err) => {
398
+ if (err) {
399
+ res.end();
400
+ }
401
+ };
402
+ switch (encoding) {
403
+ case "br":
404
+ res.writeHead(200, { "content-encoding": "br" });
405
+ (0, stream_1.pipeline)(readStream, (0, zlib_1.createBrotliCompress)(), res, onError);
406
+ break;
407
+ case "gzip":
408
+ res.writeHead(200, { "content-encoding": "gzip" });
409
+ (0, stream_1.pipeline)(readStream, (0, zlib_1.createGzip)(), res, onError);
410
+ break;
411
+ case "deflate":
412
+ res.writeHead(200, { "content-encoding": "deflate" });
413
+ (0, stream_1.pipeline)(readStream, (0, zlib_1.createDeflate)(), res, onError);
414
+ break;
415
+ default:
416
+ res.writeHead(200);
417
+ (0, stream_1.pipeline)(readStream, res, onError);
418
+ }
419
+ }
420
+ /**
421
+ * Binds socket.io to an engine.io instance.
422
+ *
423
+ * @param engine engine.io (or compatible) server
424
+ * @return self
425
+ */
426
+ bind(engine) {
427
+ // TODO apply strict types to the engine: "connection" event, `close()` and a method to serve static content
428
+ // this would allow to provide any custom engine, like one based on Deno or Bun built-in HTTP server
429
+ this.engine = engine;
430
+ this.engine.on("connection", this.onconnection.bind(this));
431
+ return this;
432
+ }
433
+ /**
434
+ * Called with each incoming transport connection.
435
+ *
436
+ * @param {engine.Socket} conn
437
+ * @return self
438
+ * @private
439
+ */
440
+ onconnection(conn) {
441
+ debug("incoming connection with id %s", conn.id);
442
+ const client = new client_1.Client(this, conn);
443
+ if (conn.protocol === 3) {
444
+ // @ts-ignore
445
+ client.connect("/");
446
+ }
447
+ return this;
448
+ }
449
+ /**
450
+ * Looks up a namespace.
451
+ *
452
+ * @example
453
+ * // with a simple string
454
+ * const myNamespace = io.of("/my-namespace");
455
+ *
456
+ * // with a regex
457
+ * const dynamicNsp = io.of(/^\/dynamic-\d+$/).on("connection", (socket) => {
458
+ * const namespace = socket.nsp; // newNamespace.name === "/dynamic-101"
459
+ *
460
+ * // broadcast to all clients in the given sub-namespace
461
+ * namespace.emit("hello");
462
+ * });
463
+ *
464
+ * @param name - nsp name
465
+ * @param fn optional, nsp `connection` ev handler
466
+ */
467
+ of(name, fn) {
468
+ if (typeof name === "function" || name instanceof RegExp) {
469
+ const parentNsp = new parent_namespace_1.ParentNamespace(this);
470
+ debug("initializing parent namespace %s", parentNsp.name);
471
+ if (typeof name === "function") {
472
+ this.parentNsps.set(name, parentNsp);
473
+ }
474
+ else {
475
+ this.parentNsps.set((nsp, conn, next) => next(null, name.test(nsp)), parentNsp);
476
+ this.parentNamespacesFromRegExp.set(name, parentNsp);
477
+ }
478
+ if (fn) {
479
+ // @ts-ignore
480
+ parentNsp.on("connect", fn);
481
+ }
482
+ return parentNsp;
483
+ }
484
+ if (String(name)[0] !== "/")
485
+ name = "/" + name;
486
+ let nsp = this._nsps.get(name);
487
+ if (!nsp) {
488
+ for (const [regex, parentNamespace] of this.parentNamespacesFromRegExp) {
489
+ if (regex.test(name)) {
490
+ debug("attaching namespace %s to parent namespace %s", name, regex);
491
+ return parentNamespace.createChild(name);
492
+ }
493
+ }
494
+ debug("initializing namespace %s", name);
495
+ nsp = new namespace_1.Namespace(this, name);
496
+ this._nsps.set(name, nsp);
497
+ if (name !== "/") {
498
+ // @ts-ignore
499
+ this.sockets.emitReserved("new_namespace", nsp);
500
+ }
501
+ }
502
+ if (fn)
503
+ nsp.on("connect", fn);
504
+ return nsp;
505
+ }
506
+ /**
507
+ * Closes server connection
508
+ *
509
+ * @param [fn] optional, called as `fn([err])` on error OR all conns closed
510
+ */
511
+ async close(fn) {
512
+ await Promise.allSettled([...this._nsps.values()].map(async (nsp) => {
513
+ nsp.sockets.forEach((socket) => {
514
+ socket._onclose("server shutting down");
515
+ });
516
+ await nsp.adapter.close();
517
+ }));
518
+ this.engine.close();
519
+ // restore the Adapter prototype, when the Socket.IO server was attached to a uWebSockets.js server
520
+ (0, uws_1.restoreAdapter)();
521
+ if (this.httpServer) {
522
+ this.httpServer.close(fn);
523
+ }
524
+ else {
525
+ fn && fn();
526
+ }
527
+ }
528
+ /**
529
+ * Registers a middleware, which is a function that gets executed for every incoming {@link Socket}.
530
+ *
531
+ * @example
532
+ * io.use((socket, next) => {
533
+ * // ...
534
+ * next();
535
+ * });
536
+ *
537
+ * @param fn - the middleware function
538
+ */
539
+ use(fn) {
540
+ this.sockets.use(fn);
541
+ return this;
542
+ }
543
+ /**
544
+ * Targets a room when emitting.
545
+ *
546
+ * @example
547
+ * // the “foo” event will be broadcast to all connected clients in the “room-101” room
548
+ * io.to("room-101").emit("foo", "bar");
549
+ *
550
+ * // with an array of rooms (a client will be notified at most once)
551
+ * io.to(["room-101", "room-102"]).emit("foo", "bar");
552
+ *
553
+ * // with multiple chained calls
554
+ * io.to("room-101").to("room-102").emit("foo", "bar");
555
+ *
556
+ * @param room - a room, or an array of rooms
557
+ * @return a new {@link BroadcastOperator} instance for chaining
558
+ */
559
+ to(room) {
560
+ return this.sockets.to(room);
561
+ }
562
+ /**
563
+ * Targets a room when emitting. Similar to `to()`, but might feel clearer in some cases:
564
+ *
565
+ * @example
566
+ * // disconnect all clients in the "room-101" room
567
+ * io.in("room-101").disconnectSockets();
568
+ *
569
+ * @param room - a room, or an array of rooms
570
+ * @return a new {@link BroadcastOperator} instance for chaining
571
+ */
572
+ in(room) {
573
+ return this.sockets.in(room);
574
+ }
575
+ /**
576
+ * Excludes a room when emitting.
577
+ *
578
+ * @example
579
+ * // the "foo" event will be broadcast to all connected clients, except the ones that are in the "room-101" room
580
+ * io.except("room-101").emit("foo", "bar");
581
+ *
582
+ * // with an array of rooms
583
+ * io.except(["room-101", "room-102"]).emit("foo", "bar");
584
+ *
585
+ * // with multiple chained calls
586
+ * io.except("room-101").except("room-102").emit("foo", "bar");
587
+ *
588
+ * @param room - a room, or an array of rooms
589
+ * @return a new {@link BroadcastOperator} instance for chaining
590
+ */
591
+ except(room) {
592
+ return this.sockets.except(room);
593
+ }
594
+ /**
595
+ * Sends a `message` event to all clients.
596
+ *
597
+ * This method mimics the WebSocket.send() method.
598
+ *
599
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
600
+ *
601
+ * @example
602
+ * io.send("hello");
603
+ *
604
+ * // this is equivalent to
605
+ * io.emit("message", "hello");
606
+ *
607
+ * @return self
608
+ */
609
+ send(...args) {
610
+ // This type-cast is needed because EmitEvents likely doesn't have `message` as a key.
611
+ // if you specify the EmitEvents, the type of args will be never.
612
+ this.sockets.emit("message", ...args);
613
+ return this;
614
+ }
615
+ /**
616
+ * Sends a `message` event to all clients. Alias of {@link send}.
617
+ *
618
+ * @return self
619
+ */
620
+ write(...args) {
621
+ // This type-cast is needed because EmitEvents likely doesn't have `message` as a key.
622
+ // if you specify the EmitEvents, the type of args will be never.
623
+ this.sockets.emit("message", ...args);
624
+ return this;
625
+ }
626
+ /**
627
+ * Sends a message to the other Socket.IO servers of the cluster.
628
+ *
629
+ * @example
630
+ * io.serverSideEmit("hello", "world");
631
+ *
632
+ * io.on("hello", (arg1) => {
633
+ * console.log(arg1); // prints "world"
634
+ * });
635
+ *
636
+ * // acknowledgements (without binary content) are supported too:
637
+ * io.serverSideEmit("ping", (err, responses) => {
638
+ * if (err) {
639
+ * // some servers did not acknowledge the event in the given delay
640
+ * } else {
641
+ * console.log(responses); // one response per server (except the current one)
642
+ * }
643
+ * });
644
+ *
645
+ * io.on("ping", (cb) => {
646
+ * cb("pong");
647
+ * });
648
+ *
649
+ * @param ev - the event name
650
+ * @param args - an array of arguments, which may include an acknowledgement callback at the end
651
+ */
652
+ serverSideEmit(ev, ...args) {
653
+ return this.sockets.serverSideEmit(ev, ...args);
654
+ }
655
+ /**
656
+ * Sends a message and expect an acknowledgement from the other Socket.IO servers of the cluster.
657
+ *
658
+ * @example
659
+ * try {
660
+ * const responses = await io.serverSideEmitWithAck("ping");
661
+ * console.log(responses); // one response per server (except the current one)
662
+ * } catch (e) {
663
+ * // some servers did not acknowledge the event in the given delay
664
+ * }
665
+ *
666
+ * @param ev - the event name
667
+ * @param args - an array of arguments
668
+ *
669
+ * @return a Promise that will be fulfilled when all servers have acknowledged the event
670
+ */
671
+ serverSideEmitWithAck(ev, ...args) {
672
+ return this.sockets.serverSideEmitWithAck(ev, ...args);
673
+ }
674
+ /**
675
+ * Gets a list of socket ids.
676
+ *
677
+ * @deprecated this method will be removed in the next major release, please use {@link Server#serverSideEmit} or
678
+ * {@link Server#fetchSockets} instead.
679
+ */
680
+ allSockets() {
681
+ return this.sockets.allSockets();
682
+ }
683
+ /**
684
+ * Sets the compress flag.
685
+ *
686
+ * @example
687
+ * io.compress(false).emit("hello");
688
+ *
689
+ * @param compress - if `true`, compresses the sending data
690
+ * @return a new {@link BroadcastOperator} instance for chaining
691
+ */
692
+ compress(compress) {
693
+ return this.sockets.compress(compress);
694
+ }
695
+ /**
696
+ * Sets a modifier for a subsequent event emission that the event data may be lost if the client is not ready to
697
+ * receive messages (because of network slowness or other issues, or because they’re connected through long polling
698
+ * and is in the middle of a request-response cycle).
699
+ *
700
+ * @example
701
+ * io.volatile.emit("hello"); // the clients may or may not receive it
702
+ *
703
+ * @return a new {@link BroadcastOperator} instance for chaining
704
+ */
705
+ get volatile() {
706
+ return this.sockets.volatile;
707
+ }
708
+ /**
709
+ * Sets a modifier for a subsequent event emission that the event data will only be broadcast to the current node.
710
+ *
711
+ * @example
712
+ * // the “foo” event will be broadcast to all connected clients on this node
713
+ * io.local.emit("foo", "bar");
714
+ *
715
+ * @return a new {@link BroadcastOperator} instance for chaining
716
+ */
717
+ get local() {
718
+ return this.sockets.local;
719
+ }
720
+ /**
721
+ * Adds a timeout in milliseconds for the next operation.
722
+ *
723
+ * @example
724
+ * io.timeout(1000).emit("some-event", (err, responses) => {
725
+ * if (err) {
726
+ * // some clients did not acknowledge the event in the given delay
727
+ * } else {
728
+ * console.log(responses); // one response per client
729
+ * }
730
+ * });
731
+ *
732
+ * @param timeout
733
+ */
734
+ timeout(timeout) {
735
+ return this.sockets.timeout(timeout);
736
+ }
737
+ /**
738
+ * Returns the matching socket instances.
739
+ *
740
+ * Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
741
+ *
742
+ * @example
743
+ * // return all Socket instances
744
+ * const sockets = await io.fetchSockets();
745
+ *
746
+ * // return all Socket instances in the "room1" room
747
+ * const sockets = await io.in("room1").fetchSockets();
748
+ *
749
+ * for (const socket of sockets) {
750
+ * console.log(socket.id);
751
+ * console.log(socket.handshake);
752
+ * console.log(socket.rooms);
753
+ * console.log(socket.data);
754
+ *
755
+ * socket.emit("hello");
756
+ * socket.join("room1");
757
+ * socket.leave("room2");
758
+ * socket.disconnect();
759
+ * }
760
+ */
761
+ fetchSockets() {
762
+ return this.sockets.fetchSockets();
763
+ }
764
+ /**
765
+ * Makes the matching socket instances join the specified rooms.
766
+ *
767
+ * Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
768
+ *
769
+ * @example
770
+ *
771
+ * // make all socket instances join the "room1" room
772
+ * io.socketsJoin("room1");
773
+ *
774
+ * // make all socket instances in the "room1" room join the "room2" and "room3" rooms
775
+ * io.in("room1").socketsJoin(["room2", "room3"]);
776
+ *
777
+ * @param room - a room, or an array of rooms
778
+ */
779
+ socketsJoin(room) {
780
+ return this.sockets.socketsJoin(room);
781
+ }
782
+ /**
783
+ * Makes the matching socket instances leave the specified rooms.
784
+ *
785
+ * Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
786
+ *
787
+ * @example
788
+ * // make all socket instances leave the "room1" room
789
+ * io.socketsLeave("room1");
790
+ *
791
+ * // make all socket instances in the "room1" room leave the "room2" and "room3" rooms
792
+ * io.in("room1").socketsLeave(["room2", "room3"]);
793
+ *
794
+ * @param room - a room, or an array of rooms
795
+ */
796
+ socketsLeave(room) {
797
+ return this.sockets.socketsLeave(room);
798
+ }
799
+ /**
800
+ * Makes the matching socket instances disconnect.
801
+ *
802
+ * Note: this method also works within a cluster of multiple Socket.IO servers, with a compatible {@link Adapter}.
803
+ *
804
+ * @example
805
+ * // make all socket instances disconnect (the connections might be kept alive for other namespaces)
806
+ * io.disconnectSockets();
807
+ *
808
+ * // make all socket instances in the "room1" room disconnect and close the underlying connections
809
+ * io.in("room1").disconnectSockets(true);
810
+ *
811
+ * @param close - whether to close the underlying connection
812
+ */
813
+ disconnectSockets(close = false) {
814
+ return this.sockets.disconnectSockets(close);
815
+ }
816
+ }
817
+ exports.Server = Server;
818
+ /**
819
+ * Expose main namespace (/).
820
+ */
821
+ const emitterMethods = Object.keys(events_1.EventEmitter.prototype).filter(function (key) {
822
+ return typeof events_1.EventEmitter.prototype[key] === "function";
823
+ });
824
+ emitterMethods.forEach(function (fn) {
825
+ Server.prototype[fn] = function () {
826
+ return this.sockets[fn].apply(this.sockets, arguments);
827
+ };
828
+ });
829
+ module.exports = (srv, opts) => new Server(srv, opts);
830
+ module.exports.Server = Server;
831
+ module.exports.Namespace = namespace_1.Namespace;
832
+ module.exports.Socket = socket_1.Socket;
833
+ } (dist$1, dist$1.exports));
834
+ return dist$1.exports;
835
+ }
836
+
837
+ export { requireDist as __require };