lightclaw2 0.0.1

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 (331) hide show
  1. package/README.md +1 -0
  2. package/dist/index.d.ts +21 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +26 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/channel.d.ts +11 -0
  7. package/dist/src/channel.d.ts.map +1 -0
  8. package/dist/src/channel.js +255 -0
  9. package/dist/src/channel.js.map +1 -0
  10. package/dist/src/config.d.ts +29 -0
  11. package/dist/src/config.d.ts.map +1 -0
  12. package/dist/src/config.js +99 -0
  13. package/dist/src/config.js.map +1 -0
  14. package/dist/src/dedup.d.ts +7 -0
  15. package/dist/src/dedup.d.ts.map +1 -0
  16. package/dist/src/dedup.js +52 -0
  17. package/dist/src/dedup.js.map +1 -0
  18. package/dist/src/gateway.d.ts +16 -0
  19. package/dist/src/gateway.d.ts.map +1 -0
  20. package/dist/src/gateway.js +283 -0
  21. package/dist/src/gateway.js.map +1 -0
  22. package/dist/src/inbound.d.ts +18 -0
  23. package/dist/src/inbound.d.ts.map +1 -0
  24. package/dist/src/inbound.js +252 -0
  25. package/dist/src/inbound.js.map +1 -0
  26. package/dist/src/media.d.ts +12 -0
  27. package/dist/src/media.d.ts.map +1 -0
  28. package/dist/src/media.js +87 -0
  29. package/dist/src/media.js.map +1 -0
  30. package/dist/src/outbound.d.ts +28 -0
  31. package/dist/src/outbound.d.ts.map +1 -0
  32. package/dist/src/outbound.js +172 -0
  33. package/dist/src/outbound.js.map +1 -0
  34. package/dist/src/runtime.d.ts +4 -0
  35. package/dist/src/runtime.d.ts.map +1 -0
  36. package/dist/src/runtime.js +11 -0
  37. package/dist/src/runtime.js.map +1 -0
  38. package/dist/src/session-history.d.ts +88 -0
  39. package/dist/src/session-history.d.ts.map +1 -0
  40. package/dist/src/session-history.js +545 -0
  41. package/dist/src/session-history.js.map +1 -0
  42. package/dist/src/socket-handlers.d.ts +21 -0
  43. package/dist/src/socket-handlers.d.ts.map +1 -0
  44. package/dist/src/socket-handlers.js +120 -0
  45. package/dist/src/socket-handlers.js.map +1 -0
  46. package/dist/src/socket-registry.d.ts +53 -0
  47. package/dist/src/socket-registry.d.ts.map +1 -0
  48. package/dist/src/socket-registry.js +115 -0
  49. package/dist/src/socket-registry.js.map +1 -0
  50. package/dist/src/types.d.ts +100 -0
  51. package/dist/src/types.d.ts.map +1 -0
  52. package/dist/src/types.js +10 -0
  53. package/dist/src/types.js.map +1 -0
  54. package/node_modules/@socket.io/component-emitter/LICENSE +24 -0
  55. package/node_modules/@socket.io/component-emitter/Readme.md +79 -0
  56. package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +179 -0
  57. package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +176 -0
  58. package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +4 -0
  59. package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +179 -0
  60. package/node_modules/@socket.io/component-emitter/lib/esm/index.js +169 -0
  61. package/node_modules/@socket.io/component-emitter/lib/esm/package.json +4 -0
  62. package/node_modules/@socket.io/component-emitter/package.json +28 -0
  63. package/node_modules/debug/LICENSE +20 -0
  64. package/node_modules/debug/README.md +481 -0
  65. package/node_modules/debug/package.json +64 -0
  66. package/node_modules/debug/src/browser.js +272 -0
  67. package/node_modules/debug/src/common.js +292 -0
  68. package/node_modules/debug/src/index.js +10 -0
  69. package/node_modules/debug/src/node.js +263 -0
  70. package/node_modules/engine.io-client/LICENSE +22 -0
  71. package/node_modules/engine.io-client/README.md +331 -0
  72. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +3 -0
  73. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +4 -0
  74. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +1 -0
  75. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +14 -0
  76. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +15 -0
  77. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +38 -0
  78. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +1 -0
  79. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +67 -0
  80. package/node_modules/engine.io-client/build/cjs/globals.d.ts +4 -0
  81. package/node_modules/engine.io-client/build/cjs/globals.js +26 -0
  82. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +21 -0
  83. package/node_modules/engine.io-client/build/cjs/globals.node.js +97 -0
  84. package/node_modules/engine.io-client/build/cjs/index.d.ts +15 -0
  85. package/node_modules/engine.io-client/build/cjs/index.js +32 -0
  86. package/node_modules/engine.io-client/build/cjs/package.json +10 -0
  87. package/node_modules/engine.io-client/build/cjs/socket.d.ts +482 -0
  88. package/node_modules/engine.io-client/build/cjs/socket.js +765 -0
  89. package/node_modules/engine.io-client/build/cjs/transport.d.ts +106 -0
  90. package/node_modules/engine.io-client/build/cjs/transport.js +153 -0
  91. package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +8 -0
  92. package/node_modules/engine.io-client/build/cjs/transports/index.js +11 -0
  93. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +15 -0
  94. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +60 -0
  95. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +108 -0
  96. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +285 -0
  97. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +11 -0
  98. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +44 -0
  99. package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +52 -0
  100. package/node_modules/engine.io-client/build/cjs/transports/polling.js +165 -0
  101. package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +36 -0
  102. package/node_modules/engine.io-client/build/cjs/transports/websocket.js +136 -0
  103. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +14 -0
  104. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +68 -0
  105. package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +18 -0
  106. package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +94 -0
  107. package/node_modules/engine.io-client/build/cjs/util.d.ts +7 -0
  108. package/node_modules/engine.io-client/build/cjs/util.js +65 -0
  109. package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +3 -0
  110. package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +2 -0
  111. package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +1 -0
  112. package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +11 -0
  113. package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +15 -0
  114. package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +34 -0
  115. package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +1 -0
  116. package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +64 -0
  117. package/node_modules/engine.io-client/build/esm/globals.d.ts +4 -0
  118. package/node_modules/engine.io-client/build/esm/globals.js +22 -0
  119. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +21 -0
  120. package/node_modules/engine.io-client/build/esm/globals.node.js +91 -0
  121. package/node_modules/engine.io-client/build/esm/index.d.ts +15 -0
  122. package/node_modules/engine.io-client/build/esm/index.js +15 -0
  123. package/node_modules/engine.io-client/build/esm/package.json +10 -0
  124. package/node_modules/engine.io-client/build/esm/socket.d.ts +482 -0
  125. package/node_modules/engine.io-client/build/esm/socket.js +727 -0
  126. package/node_modules/engine.io-client/build/esm/transport.d.ts +106 -0
  127. package/node_modules/engine.io-client/build/esm/transport.js +142 -0
  128. package/node_modules/engine.io-client/build/esm/transports/index.d.ts +8 -0
  129. package/node_modules/engine.io-client/build/esm/transports/index.js +8 -0
  130. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +15 -0
  131. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +56 -0
  132. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +108 -0
  133. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +271 -0
  134. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +11 -0
  135. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +17 -0
  136. package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +52 -0
  137. package/node_modules/engine.io-client/build/esm/transports/polling.js +145 -0
  138. package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +36 -0
  139. package/node_modules/engine.io-client/build/esm/transports/websocket.js +125 -0
  140. package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +14 -0
  141. package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +41 -0
  142. package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +18 -0
  143. package/node_modules/engine.io-client/build/esm/transports/webtransport.js +80 -0
  144. package/node_modules/engine.io-client/build/esm/util.d.ts +7 -0
  145. package/node_modules/engine.io-client/build/esm/util.js +59 -0
  146. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +3 -0
  147. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  148. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +1 -0
  149. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +11 -0
  150. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +15 -0
  151. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +34 -0
  152. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +1 -0
  153. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +64 -0
  154. package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +4 -0
  155. package/node_modules/engine.io-client/build/esm-debug/globals.js +22 -0
  156. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +21 -0
  157. package/node_modules/engine.io-client/build/esm-debug/globals.node.js +91 -0
  158. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +15 -0
  159. package/node_modules/engine.io-client/build/esm-debug/index.js +15 -0
  160. package/node_modules/engine.io-client/build/esm-debug/package.json +10 -0
  161. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +482 -0
  162. package/node_modules/engine.io-client/build/esm-debug/socket.js +756 -0
  163. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +106 -0
  164. package/node_modules/engine.io-client/build/esm-debug/transport.js +145 -0
  165. package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +8 -0
  166. package/node_modules/engine.io-client/build/esm-debug/transports/index.js +8 -0
  167. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +15 -0
  168. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +56 -0
  169. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +108 -0
  170. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +276 -0
  171. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +11 -0
  172. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +17 -0
  173. package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +52 -0
  174. package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +158 -0
  175. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +36 -0
  176. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +128 -0
  177. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +14 -0
  178. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +41 -0
  179. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +18 -0
  180. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +87 -0
  181. package/node_modules/engine.io-client/build/esm-debug/util.d.ts +7 -0
  182. package/node_modules/engine.io-client/build/esm-debug/util.js +59 -0
  183. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +7 -0
  184. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +1 -0
  185. package/node_modules/engine.io-client/dist/engine.io.js +3064 -0
  186. package/node_modules/engine.io-client/dist/engine.io.js.map +1 -0
  187. package/node_modules/engine.io-client/dist/engine.io.min.js +7 -0
  188. package/node_modules/engine.io-client/dist/engine.io.min.js.map +1 -0
  189. package/node_modules/engine.io-client/node_modules/ws/LICENSE +20 -0
  190. package/node_modules/engine.io-client/node_modules/ws/README.md +548 -0
  191. package/node_modules/engine.io-client/node_modules/ws/browser.js +8 -0
  192. package/node_modules/engine.io-client/node_modules/ws/index.js +13 -0
  193. package/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +131 -0
  194. package/node_modules/engine.io-client/node_modules/ws/lib/constants.js +18 -0
  195. package/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +292 -0
  196. package/node_modules/engine.io-client/node_modules/ws/lib/extension.js +203 -0
  197. package/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +55 -0
  198. package/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +528 -0
  199. package/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +706 -0
  200. package/node_modules/engine.io-client/node_modules/ws/lib/sender.js +602 -0
  201. package/node_modules/engine.io-client/node_modules/ws/lib/stream.js +161 -0
  202. package/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +62 -0
  203. package/node_modules/engine.io-client/node_modules/ws/lib/validation.js +152 -0
  204. package/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +550 -0
  205. package/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +1388 -0
  206. package/node_modules/engine.io-client/node_modules/ws/package.json +69 -0
  207. package/node_modules/engine.io-client/node_modules/ws/wrapper.mjs +8 -0
  208. package/node_modules/engine.io-client/package.json +95 -0
  209. package/node_modules/engine.io-parser/LICENSE +22 -0
  210. package/node_modules/engine.io-parser/Readme.md +158 -0
  211. package/node_modules/engine.io-parser/build/cjs/commons.d.ts +14 -0
  212. package/node_modules/engine.io-parser/build/cjs/commons.js +19 -0
  213. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +2 -0
  214. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +48 -0
  215. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +2 -0
  216. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +66 -0
  217. package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +2 -0
  218. package/node_modules/engine.io-parser/build/cjs/decodePacket.js +59 -0
  219. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +4 -0
  220. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +72 -0
  221. package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +3 -0
  222. package/node_modules/engine.io-parser/build/cjs/encodePacket.js +38 -0
  223. package/node_modules/engine.io-parser/build/cjs/index.d.ts +9 -0
  224. package/node_modules/engine.io-parser/build/cjs/index.js +164 -0
  225. package/node_modules/engine.io-parser/build/cjs/package.json +8 -0
  226. package/node_modules/engine.io-parser/build/esm/commons.d.ts +14 -0
  227. package/node_modules/engine.io-parser/build/esm/commons.js +14 -0
  228. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +2 -0
  229. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +43 -0
  230. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +2 -0
  231. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +62 -0
  232. package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +2 -0
  233. package/node_modules/engine.io-parser/build/esm/decodePacket.js +55 -0
  234. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +4 -0
  235. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +68 -0
  236. package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +3 -0
  237. package/node_modules/engine.io-parser/build/esm/encodePacket.js +33 -0
  238. package/node_modules/engine.io-parser/build/esm/index.d.ts +9 -0
  239. package/node_modules/engine.io-parser/build/esm/index.js +156 -0
  240. package/node_modules/engine.io-parser/build/esm/package.json +8 -0
  241. package/node_modules/engine.io-parser/package.json +46 -0
  242. package/node_modules/ms/index.js +162 -0
  243. package/node_modules/ms/license.md +21 -0
  244. package/node_modules/ms/package.json +38 -0
  245. package/node_modules/ms/readme.md +59 -0
  246. package/node_modules/socket.io-client/LICENSE +21 -0
  247. package/node_modules/socket.io-client/README.md +29 -0
  248. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +2 -0
  249. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +4 -0
  250. package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +12 -0
  251. package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +69 -0
  252. package/node_modules/socket.io-client/build/cjs/index.d.ts +29 -0
  253. package/node_modules/socket.io-client/build/cjs/index.js +76 -0
  254. package/node_modules/socket.io-client/build/cjs/manager.d.ts +295 -0
  255. package/node_modules/socket.io-client/build/cjs/manager.js +416 -0
  256. package/node_modules/socket.io-client/build/cjs/on.d.ts +2 -0
  257. package/node_modules/socket.io-client/build/cjs/on.js +9 -0
  258. package/node_modules/socket.io-client/build/cjs/socket.d.ts +593 -0
  259. package/node_modules/socket.io-client/build/cjs/socket.js +909 -0
  260. package/node_modules/socket.io-client/build/cjs/url.d.ts +33 -0
  261. package/node_modules/socket.io-client/build/cjs/url.js +69 -0
  262. package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +2 -0
  263. package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +2 -0
  264. package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +12 -0
  265. package/node_modules/socket.io-client/build/esm/contrib/backo2.js +66 -0
  266. package/node_modules/socket.io-client/build/esm/index.d.ts +29 -0
  267. package/node_modules/socket.io-client/build/esm/index.js +58 -0
  268. package/node_modules/socket.io-client/build/esm/manager.d.ts +295 -0
  269. package/node_modules/socket.io-client/build/esm/manager.js +367 -0
  270. package/node_modules/socket.io-client/build/esm/on.d.ts +2 -0
  271. package/node_modules/socket.io-client/build/esm/on.js +6 -0
  272. package/node_modules/socket.io-client/build/esm/package.json +5 -0
  273. package/node_modules/socket.io-client/build/esm/socket.d.ts +593 -0
  274. package/node_modules/socket.io-client/build/esm/socket.js +880 -0
  275. package/node_modules/socket.io-client/build/esm/url.d.ts +33 -0
  276. package/node_modules/socket.io-client/build/esm/url.js +59 -0
  277. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +2 -0
  278. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +2 -0
  279. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +12 -0
  280. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +66 -0
  281. package/node_modules/socket.io-client/build/esm-debug/index.d.ts +29 -0
  282. package/node_modules/socket.io-client/build/esm-debug/index.js +62 -0
  283. package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +295 -0
  284. package/node_modules/socket.io-client/build/esm-debug/manager.js +386 -0
  285. package/node_modules/socket.io-client/build/esm-debug/on.d.ts +2 -0
  286. package/node_modules/socket.io-client/build/esm-debug/on.js +6 -0
  287. package/node_modules/socket.io-client/build/esm-debug/package.json +5 -0
  288. package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +593 -0
  289. package/node_modules/socket.io-client/build/esm-debug/socket.js +902 -0
  290. package/node_modules/socket.io-client/build/esm-debug/url.d.ts +33 -0
  291. package/node_modules/socket.io-client/build/esm-debug/url.js +63 -0
  292. package/node_modules/socket.io-client/dist/socket.io.esm.min.js +7 -0
  293. package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +1 -0
  294. package/node_modules/socket.io-client/dist/socket.io.js +4955 -0
  295. package/node_modules/socket.io-client/dist/socket.io.js.map +1 -0
  296. package/node_modules/socket.io-client/dist/socket.io.min.js +7 -0
  297. package/node_modules/socket.io-client/dist/socket.io.min.js.map +1 -0
  298. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +7 -0
  299. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +1 -0
  300. package/node_modules/socket.io-client/package.json +101 -0
  301. package/node_modules/socket.io-parser/LICENSE +20 -0
  302. package/node_modules/socket.io-parser/Readme.md +81 -0
  303. package/node_modules/socket.io-parser/build/cjs/binary.d.ts +20 -0
  304. package/node_modules/socket.io-parser/build/cjs/binary.js +87 -0
  305. package/node_modules/socket.io-parser/build/cjs/index.d.ts +91 -0
  306. package/node_modules/socket.io-parser/build/cjs/index.js +359 -0
  307. package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +7 -0
  308. package/node_modules/socket.io-parser/build/cjs/is-binary.js +54 -0
  309. package/node_modules/socket.io-parser/build/cjs/package.json +3 -0
  310. package/node_modules/socket.io-parser/build/esm/binary.d.ts +20 -0
  311. package/node_modules/socket.io-parser/build/esm/binary.js +83 -0
  312. package/node_modules/socket.io-parser/build/esm/index.d.ts +91 -0
  313. package/node_modules/socket.io-parser/build/esm/index.js +348 -0
  314. package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +7 -0
  315. package/node_modules/socket.io-parser/build/esm/is-binary.js +50 -0
  316. package/node_modules/socket.io-parser/build/esm/package.json +3 -0
  317. package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +20 -0
  318. package/node_modules/socket.io-parser/build/esm-debug/binary.js +83 -0
  319. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +91 -0
  320. package/node_modules/socket.io-parser/build/esm-debug/index.js +353 -0
  321. package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +7 -0
  322. package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +50 -0
  323. package/node_modules/socket.io-parser/build/esm-debug/package.json +3 -0
  324. package/node_modules/socket.io-parser/package.json +44 -0
  325. package/node_modules/xmlhttprequest-ssl/LICENSE +22 -0
  326. package/node_modules/xmlhttprequest-ssl/README.md +67 -0
  327. package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +689 -0
  328. package/node_modules/xmlhttprequest-ssl/package.json +40 -0
  329. package/openclaw.plugin.json +17 -0
  330. package/package.json +61 -0
  331. package/skills/lightclaw-cron/SKILL.md +381 -0
@@ -0,0 +1,909 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.Socket = void 0;
7
+ const socket_io_parser_1 = require("socket.io-parser");
8
+ const on_js_1 = require("./on.js");
9
+ const component_emitter_1 = require("@socket.io/component-emitter");
10
+ const debug_1 = __importDefault(require("debug")); // debug()
11
+ const debug = (0, debug_1.default)("socket.io-client:socket"); // debug()
12
+ /**
13
+ * Internal events.
14
+ * These events can't be emitted by the user.
15
+ */
16
+ const RESERVED_EVENTS = Object.freeze({
17
+ connect: 1,
18
+ connect_error: 1,
19
+ disconnect: 1,
20
+ disconnecting: 1,
21
+ // EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
22
+ newListener: 1,
23
+ removeListener: 1,
24
+ });
25
+ /**
26
+ * A Socket is the fundamental class for interacting with the server.
27
+ *
28
+ * A Socket belongs to a certain Namespace (by default /) and uses an underlying {@link Manager} to communicate.
29
+ *
30
+ * @example
31
+ * const socket = io();
32
+ *
33
+ * socket.on("connect", () => {
34
+ * console.log("connected");
35
+ * });
36
+ *
37
+ * // send an event to the server
38
+ * socket.emit("foo", "bar");
39
+ *
40
+ * socket.on("foobar", () => {
41
+ * // an event was received from the server
42
+ * });
43
+ *
44
+ * // upon disconnection
45
+ * socket.on("disconnect", (reason) => {
46
+ * console.log(`disconnected due to ${reason}`);
47
+ * });
48
+ */
49
+ class Socket extends component_emitter_1.Emitter {
50
+ /**
51
+ * `Socket` constructor.
52
+ */
53
+ constructor(io, nsp, opts) {
54
+ super();
55
+ /**
56
+ * Whether the socket is currently connected to the server.
57
+ *
58
+ * @example
59
+ * const socket = io();
60
+ *
61
+ * socket.on("connect", () => {
62
+ * console.log(socket.connected); // true
63
+ * });
64
+ *
65
+ * socket.on("disconnect", () => {
66
+ * console.log(socket.connected); // false
67
+ * });
68
+ */
69
+ this.connected = false;
70
+ /**
71
+ * Whether the connection state was recovered after a temporary disconnection. In that case, any missed packets will
72
+ * be transmitted by the server.
73
+ */
74
+ this.recovered = false;
75
+ /**
76
+ * Buffer for packets received before the CONNECT packet
77
+ */
78
+ this.receiveBuffer = [];
79
+ /**
80
+ * Buffer for packets that will be sent once the socket is connected
81
+ */
82
+ this.sendBuffer = [];
83
+ /**
84
+ * The queue of packets to be sent with retry in case of failure.
85
+ *
86
+ * Packets are sent one by one, each waiting for the server acknowledgement, in order to guarantee the delivery order.
87
+ * @private
88
+ */
89
+ this._queue = [];
90
+ /**
91
+ * A sequence to generate the ID of the {@link QueuedPacket}.
92
+ * @private
93
+ */
94
+ this._queueSeq = 0;
95
+ this.ids = 0;
96
+ /**
97
+ * A map containing acknowledgement handlers.
98
+ *
99
+ * The `withError` attribute is used to differentiate handlers that accept an error as first argument:
100
+ *
101
+ * - `socket.emit("test", (err, value) => { ... })` with `ackTimeout` option
102
+ * - `socket.timeout(5000).emit("test", (err, value) => { ... })`
103
+ * - `const value = await socket.emitWithAck("test")`
104
+ *
105
+ * From those that don't:
106
+ *
107
+ * - `socket.emit("test", (value) => { ... });`
108
+ *
109
+ * In the first case, the handlers will be called with an error when:
110
+ *
111
+ * - the timeout is reached
112
+ * - the socket gets disconnected
113
+ *
114
+ * In the second case, the handlers will be simply discarded upon disconnection, since the client will never receive
115
+ * an acknowledgement from the server.
116
+ *
117
+ * @private
118
+ */
119
+ this.acks = {};
120
+ this.flags = {};
121
+ this.io = io;
122
+ this.nsp = nsp;
123
+ if (opts && opts.auth) {
124
+ this.auth = opts.auth;
125
+ }
126
+ this._opts = Object.assign({}, opts);
127
+ if (this.io._autoConnect)
128
+ this.open();
129
+ }
130
+ /**
131
+ * Whether the socket is currently disconnected
132
+ *
133
+ * @example
134
+ * const socket = io();
135
+ *
136
+ * socket.on("connect", () => {
137
+ * console.log(socket.disconnected); // false
138
+ * });
139
+ *
140
+ * socket.on("disconnect", () => {
141
+ * console.log(socket.disconnected); // true
142
+ * });
143
+ */
144
+ get disconnected() {
145
+ return !this.connected;
146
+ }
147
+ /**
148
+ * Subscribe to open, close and packet events
149
+ *
150
+ * @private
151
+ */
152
+ subEvents() {
153
+ if (this.subs)
154
+ return;
155
+ const io = this.io;
156
+ this.subs = [
157
+ (0, on_js_1.on)(io, "open", this.onopen.bind(this)),
158
+ (0, on_js_1.on)(io, "packet", this.onpacket.bind(this)),
159
+ (0, on_js_1.on)(io, "error", this.onerror.bind(this)),
160
+ (0, on_js_1.on)(io, "close", this.onclose.bind(this)),
161
+ ];
162
+ }
163
+ /**
164
+ * Whether the Socket will try to reconnect when its Manager connects or reconnects.
165
+ *
166
+ * @example
167
+ * const socket = io();
168
+ *
169
+ * console.log(socket.active); // true
170
+ *
171
+ * socket.on("disconnect", (reason) => {
172
+ * if (reason === "io server disconnect") {
173
+ * // the disconnection was initiated by the server, you need to manually reconnect
174
+ * console.log(socket.active); // false
175
+ * }
176
+ * // else the socket will automatically try to reconnect
177
+ * console.log(socket.active); // true
178
+ * });
179
+ */
180
+ get active() {
181
+ return !!this.subs;
182
+ }
183
+ /**
184
+ * "Opens" the socket.
185
+ *
186
+ * @example
187
+ * const socket = io({
188
+ * autoConnect: false
189
+ * });
190
+ *
191
+ * socket.connect();
192
+ */
193
+ connect() {
194
+ if (this.connected)
195
+ return this;
196
+ this.subEvents();
197
+ if (!this.io["_reconnecting"])
198
+ this.io.open(); // ensure open
199
+ if ("open" === this.io._readyState)
200
+ this.onopen();
201
+ return this;
202
+ }
203
+ /**
204
+ * Alias for {@link connect()}.
205
+ */
206
+ open() {
207
+ return this.connect();
208
+ }
209
+ /**
210
+ * Sends a `message` event.
211
+ *
212
+ * This method mimics the WebSocket.send() method.
213
+ *
214
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
215
+ *
216
+ * @example
217
+ * socket.send("hello");
218
+ *
219
+ * // this is equivalent to
220
+ * socket.emit("message", "hello");
221
+ *
222
+ * @return self
223
+ */
224
+ send(...args) {
225
+ args.unshift("message");
226
+ this.emit.apply(this, args);
227
+ return this;
228
+ }
229
+ /**
230
+ * Override `emit`.
231
+ * If the event is in `events`, it's emitted normally.
232
+ *
233
+ * @example
234
+ * socket.emit("hello", "world");
235
+ *
236
+ * // all serializable datastructures are supported (no need to call JSON.stringify)
237
+ * socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
238
+ *
239
+ * // with an acknowledgement from the server
240
+ * socket.emit("hello", "world", (val) => {
241
+ * // ...
242
+ * });
243
+ *
244
+ * @return self
245
+ */
246
+ emit(ev, ...args) {
247
+ var _a, _b, _c;
248
+ if (RESERVED_EVENTS.hasOwnProperty(ev)) {
249
+ throw new Error('"' + ev.toString() + '" is a reserved event name');
250
+ }
251
+ args.unshift(ev);
252
+ if (this._opts.retries && !this.flags.fromQueue && !this.flags.volatile) {
253
+ this._addToQueue(args);
254
+ return this;
255
+ }
256
+ const packet = {
257
+ type: socket_io_parser_1.PacketType.EVENT,
258
+ data: args,
259
+ };
260
+ packet.options = {};
261
+ packet.options.compress = this.flags.compress !== false;
262
+ // event ack callback
263
+ if ("function" === typeof args[args.length - 1]) {
264
+ const id = this.ids++;
265
+ debug("emitting packet with ack id %d", id);
266
+ const ack = args.pop();
267
+ this._registerAckCallback(id, ack);
268
+ packet.id = id;
269
+ }
270
+ const isTransportWritable = (_b = (_a = this.io.engine) === null || _a === void 0 ? void 0 : _a.transport) === null || _b === void 0 ? void 0 : _b.writable;
271
+ const isConnected = this.connected && !((_c = this.io.engine) === null || _c === void 0 ? void 0 : _c._hasPingExpired());
272
+ const discardPacket = this.flags.volatile && !isTransportWritable;
273
+ if (discardPacket) {
274
+ debug("discard packet as the transport is not currently writable");
275
+ }
276
+ else if (isConnected) {
277
+ this.notifyOutgoingListeners(packet);
278
+ this.packet(packet);
279
+ }
280
+ else {
281
+ this.sendBuffer.push(packet);
282
+ }
283
+ this.flags = {};
284
+ return this;
285
+ }
286
+ /**
287
+ * @private
288
+ */
289
+ _registerAckCallback(id, ack) {
290
+ var _a;
291
+ const timeout = (_a = this.flags.timeout) !== null && _a !== void 0 ? _a : this._opts.ackTimeout;
292
+ if (timeout === undefined) {
293
+ this.acks[id] = ack;
294
+ return;
295
+ }
296
+ // @ts-ignore
297
+ const timer = this.io.setTimeoutFn(() => {
298
+ delete this.acks[id];
299
+ for (let i = 0; i < this.sendBuffer.length; i++) {
300
+ if (this.sendBuffer[i].id === id) {
301
+ debug("removing packet with ack id %d from the buffer", id);
302
+ this.sendBuffer.splice(i, 1);
303
+ }
304
+ }
305
+ debug("event with ack id %d has timed out after %d ms", id, timeout);
306
+ ack.call(this, new Error("operation has timed out"));
307
+ }, timeout);
308
+ const fn = (...args) => {
309
+ // @ts-ignore
310
+ this.io.clearTimeoutFn(timer);
311
+ ack.apply(this, args);
312
+ };
313
+ fn.withError = true;
314
+ this.acks[id] = fn;
315
+ }
316
+ /**
317
+ * Emits an event and waits for an acknowledgement
318
+ *
319
+ * @example
320
+ * // without timeout
321
+ * const response = await socket.emitWithAck("hello", "world");
322
+ *
323
+ * // with a specific timeout
324
+ * try {
325
+ * const response = await socket.timeout(1000).emitWithAck("hello", "world");
326
+ * } catch (err) {
327
+ * // the server did not acknowledge the event in the given delay
328
+ * }
329
+ *
330
+ * @return a Promise that will be fulfilled when the server acknowledges the event
331
+ */
332
+ emitWithAck(ev, ...args) {
333
+ return new Promise((resolve, reject) => {
334
+ const fn = (arg1, arg2) => {
335
+ return arg1 ? reject(arg1) : resolve(arg2);
336
+ };
337
+ fn.withError = true;
338
+ args.push(fn);
339
+ this.emit(ev, ...args);
340
+ });
341
+ }
342
+ /**
343
+ * Add the packet to the queue.
344
+ * @param args
345
+ * @private
346
+ */
347
+ _addToQueue(args) {
348
+ let ack;
349
+ if (typeof args[args.length - 1] === "function") {
350
+ ack = args.pop();
351
+ }
352
+ const packet = {
353
+ id: this._queueSeq++,
354
+ tryCount: 0,
355
+ pending: false,
356
+ args,
357
+ flags: Object.assign({ fromQueue: true }, this.flags),
358
+ };
359
+ args.push((err, ...responseArgs) => {
360
+ if (packet !== this._queue[0]) {
361
+ return debug("packet [%d] already acknowledged", packet.id);
362
+ }
363
+ const hasError = err !== null;
364
+ if (hasError) {
365
+ if (packet.tryCount > this._opts.retries) {
366
+ debug("packet [%d] is discarded after %d tries", packet.id, packet.tryCount);
367
+ this._queue.shift();
368
+ if (ack) {
369
+ ack(err);
370
+ }
371
+ }
372
+ }
373
+ else {
374
+ debug("packet [%d] was successfully sent", packet.id);
375
+ this._queue.shift();
376
+ if (ack) {
377
+ ack(null, ...responseArgs);
378
+ }
379
+ }
380
+ packet.pending = false;
381
+ return this._drainQueue();
382
+ });
383
+ this._queue.push(packet);
384
+ this._drainQueue();
385
+ }
386
+ /**
387
+ * Send the first packet of the queue, and wait for an acknowledgement from the server.
388
+ * @param force - whether to resend a packet that has not been acknowledged yet
389
+ *
390
+ * @private
391
+ */
392
+ _drainQueue(force = false) {
393
+ debug("draining queue");
394
+ if (!this.connected || this._queue.length === 0) {
395
+ return;
396
+ }
397
+ const packet = this._queue[0];
398
+ if (packet.pending && !force) {
399
+ debug("packet [%d] has already been sent and is waiting for an ack", packet.id);
400
+ return;
401
+ }
402
+ packet.pending = true;
403
+ packet.tryCount++;
404
+ debug("sending packet [%d] (try n°%d)", packet.id, packet.tryCount);
405
+ this.flags = packet.flags;
406
+ this.emit.apply(this, packet.args);
407
+ }
408
+ /**
409
+ * Sends a packet.
410
+ *
411
+ * @param packet
412
+ * @private
413
+ */
414
+ packet(packet) {
415
+ packet.nsp = this.nsp;
416
+ this.io._packet(packet);
417
+ }
418
+ /**
419
+ * Called upon engine `open`.
420
+ *
421
+ * @private
422
+ */
423
+ onopen() {
424
+ debug("transport is open - connecting");
425
+ if (typeof this.auth == "function") {
426
+ this.auth((data) => {
427
+ this._sendConnectPacket(data);
428
+ });
429
+ }
430
+ else {
431
+ this._sendConnectPacket(this.auth);
432
+ }
433
+ }
434
+ /**
435
+ * Sends a CONNECT packet to initiate the Socket.IO session.
436
+ *
437
+ * @param data
438
+ * @private
439
+ */
440
+ _sendConnectPacket(data) {
441
+ this.packet({
442
+ type: socket_io_parser_1.PacketType.CONNECT,
443
+ data: this._pid
444
+ ? Object.assign({ pid: this._pid, offset: this._lastOffset }, data)
445
+ : data,
446
+ });
447
+ }
448
+ /**
449
+ * Called upon engine or manager `error`.
450
+ *
451
+ * @param err
452
+ * @private
453
+ */
454
+ onerror(err) {
455
+ if (!this.connected) {
456
+ this.emitReserved("connect_error", err);
457
+ }
458
+ }
459
+ /**
460
+ * Called upon engine `close`.
461
+ *
462
+ * @param reason
463
+ * @param description
464
+ * @private
465
+ */
466
+ onclose(reason, description) {
467
+ debug("close (%s)", reason);
468
+ this.connected = false;
469
+ delete this.id;
470
+ this.emitReserved("disconnect", reason, description);
471
+ this._clearAcks();
472
+ }
473
+ /**
474
+ * Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
475
+ * the server.
476
+ *
477
+ * @private
478
+ */
479
+ _clearAcks() {
480
+ Object.keys(this.acks).forEach((id) => {
481
+ const isBuffered = this.sendBuffer.some((packet) => String(packet.id) === id);
482
+ if (!isBuffered) {
483
+ // note: handlers that do not accept an error as first argument are ignored here
484
+ const ack = this.acks[id];
485
+ delete this.acks[id];
486
+ if (ack.withError) {
487
+ ack.call(this, new Error("socket has been disconnected"));
488
+ }
489
+ }
490
+ });
491
+ }
492
+ /**
493
+ * Called with socket packet.
494
+ *
495
+ * @param packet
496
+ * @private
497
+ */
498
+ onpacket(packet) {
499
+ const sameNamespace = packet.nsp === this.nsp;
500
+ if (!sameNamespace)
501
+ return;
502
+ switch (packet.type) {
503
+ case socket_io_parser_1.PacketType.CONNECT:
504
+ if (packet.data && packet.data.sid) {
505
+ this.onconnect(packet.data.sid, packet.data.pid);
506
+ }
507
+ else {
508
+ this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
509
+ }
510
+ break;
511
+ case socket_io_parser_1.PacketType.EVENT:
512
+ case socket_io_parser_1.PacketType.BINARY_EVENT:
513
+ this.onevent(packet);
514
+ break;
515
+ case socket_io_parser_1.PacketType.ACK:
516
+ case socket_io_parser_1.PacketType.BINARY_ACK:
517
+ this.onack(packet);
518
+ break;
519
+ case socket_io_parser_1.PacketType.DISCONNECT:
520
+ this.ondisconnect();
521
+ break;
522
+ case socket_io_parser_1.PacketType.CONNECT_ERROR:
523
+ this.destroy();
524
+ const err = new Error(packet.data.message);
525
+ // @ts-ignore
526
+ err.data = packet.data.data;
527
+ this.emitReserved("connect_error", err);
528
+ break;
529
+ }
530
+ }
531
+ /**
532
+ * Called upon a server event.
533
+ *
534
+ * @param packet
535
+ * @private
536
+ */
537
+ onevent(packet) {
538
+ const args = packet.data || [];
539
+ debug("emitting event %j", args);
540
+ if (null != packet.id) {
541
+ debug("attaching ack callback to event");
542
+ args.push(this.ack(packet.id));
543
+ }
544
+ if (this.connected) {
545
+ this.emitEvent(args);
546
+ }
547
+ else {
548
+ this.receiveBuffer.push(Object.freeze(args));
549
+ }
550
+ }
551
+ emitEvent(args) {
552
+ if (this._anyListeners && this._anyListeners.length) {
553
+ const listeners = this._anyListeners.slice();
554
+ for (const listener of listeners) {
555
+ listener.apply(this, args);
556
+ }
557
+ }
558
+ super.emit.apply(this, args);
559
+ if (this._pid && args.length && typeof args[args.length - 1] === "string") {
560
+ this._lastOffset = args[args.length - 1];
561
+ }
562
+ }
563
+ /**
564
+ * Produces an ack callback to emit with an event.
565
+ *
566
+ * @private
567
+ */
568
+ ack(id) {
569
+ const self = this;
570
+ let sent = false;
571
+ return function (...args) {
572
+ // prevent double callbacks
573
+ if (sent)
574
+ return;
575
+ sent = true;
576
+ debug("sending ack %j", args);
577
+ self.packet({
578
+ type: socket_io_parser_1.PacketType.ACK,
579
+ id: id,
580
+ data: args,
581
+ });
582
+ };
583
+ }
584
+ /**
585
+ * Called upon a server acknowledgement.
586
+ *
587
+ * @param packet
588
+ * @private
589
+ */
590
+ onack(packet) {
591
+ const ack = this.acks[packet.id];
592
+ if (typeof ack !== "function") {
593
+ debug("bad ack %s", packet.id);
594
+ return;
595
+ }
596
+ delete this.acks[packet.id];
597
+ debug("calling ack %s with %j", packet.id, packet.data);
598
+ // @ts-ignore FIXME ack is incorrectly inferred as 'never'
599
+ if (ack.withError) {
600
+ packet.data.unshift(null);
601
+ }
602
+ // @ts-ignore
603
+ ack.apply(this, packet.data);
604
+ }
605
+ /**
606
+ * Called upon server connect.
607
+ *
608
+ * @private
609
+ */
610
+ onconnect(id, pid) {
611
+ debug("socket connected with id %s", id);
612
+ this.id = id;
613
+ this.recovered = pid && this._pid === pid;
614
+ this._pid = pid; // defined only if connection state recovery is enabled
615
+ this.connected = true;
616
+ this.emitBuffered();
617
+ this._drainQueue(true);
618
+ this.emitReserved("connect");
619
+ }
620
+ /**
621
+ * Emit buffered events (received and emitted).
622
+ *
623
+ * @private
624
+ */
625
+ emitBuffered() {
626
+ this.receiveBuffer.forEach((args) => this.emitEvent(args));
627
+ this.receiveBuffer = [];
628
+ this.sendBuffer.forEach((packet) => {
629
+ this.notifyOutgoingListeners(packet);
630
+ this.packet(packet);
631
+ });
632
+ this.sendBuffer = [];
633
+ }
634
+ /**
635
+ * Called upon server disconnect.
636
+ *
637
+ * @private
638
+ */
639
+ ondisconnect() {
640
+ debug("server disconnect (%s)", this.nsp);
641
+ this.destroy();
642
+ this.onclose("io server disconnect");
643
+ }
644
+ /**
645
+ * Called upon forced client/server side disconnections,
646
+ * this method ensures the manager stops tracking us and
647
+ * that reconnections don't get triggered for this.
648
+ *
649
+ * @private
650
+ */
651
+ destroy() {
652
+ if (this.subs) {
653
+ // clean subscriptions to avoid reconnections
654
+ this.subs.forEach((subDestroy) => subDestroy());
655
+ this.subs = undefined;
656
+ }
657
+ this.io["_destroy"](this);
658
+ }
659
+ /**
660
+ * Disconnects the socket manually. In that case, the socket will not try to reconnect.
661
+ *
662
+ * If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
663
+ *
664
+ * @example
665
+ * const socket = io();
666
+ *
667
+ * socket.on("disconnect", (reason) => {
668
+ * // console.log(reason); prints "io client disconnect"
669
+ * });
670
+ *
671
+ * socket.disconnect();
672
+ *
673
+ * @return self
674
+ */
675
+ disconnect() {
676
+ if (this.connected) {
677
+ debug("performing disconnect (%s)", this.nsp);
678
+ this.packet({ type: socket_io_parser_1.PacketType.DISCONNECT });
679
+ }
680
+ // remove socket from pool
681
+ this.destroy();
682
+ if (this.connected) {
683
+ // fire events
684
+ this.onclose("io client disconnect");
685
+ }
686
+ return this;
687
+ }
688
+ /**
689
+ * Alias for {@link disconnect()}.
690
+ *
691
+ * @return self
692
+ */
693
+ close() {
694
+ return this.disconnect();
695
+ }
696
+ /**
697
+ * Sets the compress flag.
698
+ *
699
+ * @example
700
+ * socket.compress(false).emit("hello");
701
+ *
702
+ * @param compress - if `true`, compresses the sending data
703
+ * @return self
704
+ */
705
+ compress(compress) {
706
+ this.flags.compress = compress;
707
+ return this;
708
+ }
709
+ /**
710
+ * Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
711
+ * ready to send messages.
712
+ *
713
+ * @example
714
+ * socket.volatile.emit("hello"); // the server may or may not receive it
715
+ *
716
+ * @returns self
717
+ */
718
+ get volatile() {
719
+ this.flags.volatile = true;
720
+ return this;
721
+ }
722
+ /**
723
+ * Sets a modifier for a subsequent event emission that the callback will be called with an error when the
724
+ * given number of milliseconds have elapsed without an acknowledgement from the server:
725
+ *
726
+ * @example
727
+ * socket.timeout(5000).emit("my-event", (err) => {
728
+ * if (err) {
729
+ * // the server did not acknowledge the event in the given delay
730
+ * }
731
+ * });
732
+ *
733
+ * @returns self
734
+ */
735
+ timeout(timeout) {
736
+ this.flags.timeout = timeout;
737
+ return this;
738
+ }
739
+ /**
740
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
741
+ * callback.
742
+ *
743
+ * @example
744
+ * socket.onAny((event, ...args) => {
745
+ * console.log(`got ${event}`);
746
+ * });
747
+ *
748
+ * @param listener
749
+ */
750
+ onAny(listener) {
751
+ this._anyListeners = this._anyListeners || [];
752
+ this._anyListeners.push(listener);
753
+ return this;
754
+ }
755
+ /**
756
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
757
+ * callback. The listener is added to the beginning of the listeners array.
758
+ *
759
+ * @example
760
+ * socket.prependAny((event, ...args) => {
761
+ * console.log(`got event ${event}`);
762
+ * });
763
+ *
764
+ * @param listener
765
+ */
766
+ prependAny(listener) {
767
+ this._anyListeners = this._anyListeners || [];
768
+ this._anyListeners.unshift(listener);
769
+ return this;
770
+ }
771
+ /**
772
+ * Removes the listener that will be fired when any event is emitted.
773
+ *
774
+ * @example
775
+ * const catchAllListener = (event, ...args) => {
776
+ * console.log(`got event ${event}`);
777
+ * }
778
+ *
779
+ * socket.onAny(catchAllListener);
780
+ *
781
+ * // remove a specific listener
782
+ * socket.offAny(catchAllListener);
783
+ *
784
+ * // or remove all listeners
785
+ * socket.offAny();
786
+ *
787
+ * @param listener
788
+ */
789
+ offAny(listener) {
790
+ if (!this._anyListeners) {
791
+ return this;
792
+ }
793
+ if (listener) {
794
+ const listeners = this._anyListeners;
795
+ for (let i = 0; i < listeners.length; i++) {
796
+ if (listener === listeners[i]) {
797
+ listeners.splice(i, 1);
798
+ return this;
799
+ }
800
+ }
801
+ }
802
+ else {
803
+ this._anyListeners = [];
804
+ }
805
+ return this;
806
+ }
807
+ /**
808
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
809
+ * e.g. to remove listeners.
810
+ */
811
+ listenersAny() {
812
+ return this._anyListeners || [];
813
+ }
814
+ /**
815
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
816
+ * callback.
817
+ *
818
+ * Note: acknowledgements sent to the server are not included.
819
+ *
820
+ * @example
821
+ * socket.onAnyOutgoing((event, ...args) => {
822
+ * console.log(`sent event ${event}`);
823
+ * });
824
+ *
825
+ * @param listener
826
+ */
827
+ onAnyOutgoing(listener) {
828
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
829
+ this._anyOutgoingListeners.push(listener);
830
+ return this;
831
+ }
832
+ /**
833
+ * Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
834
+ * callback. The listener is added to the beginning of the listeners array.
835
+ *
836
+ * Note: acknowledgements sent to the server are not included.
837
+ *
838
+ * @example
839
+ * socket.prependAnyOutgoing((event, ...args) => {
840
+ * console.log(`sent event ${event}`);
841
+ * });
842
+ *
843
+ * @param listener
844
+ */
845
+ prependAnyOutgoing(listener) {
846
+ this._anyOutgoingListeners = this._anyOutgoingListeners || [];
847
+ this._anyOutgoingListeners.unshift(listener);
848
+ return this;
849
+ }
850
+ /**
851
+ * Removes the listener that will be fired when any event is emitted.
852
+ *
853
+ * @example
854
+ * const catchAllListener = (event, ...args) => {
855
+ * console.log(`sent event ${event}`);
856
+ * }
857
+ *
858
+ * socket.onAnyOutgoing(catchAllListener);
859
+ *
860
+ * // remove a specific listener
861
+ * socket.offAnyOutgoing(catchAllListener);
862
+ *
863
+ * // or remove all listeners
864
+ * socket.offAnyOutgoing();
865
+ *
866
+ * @param [listener] - the catch-all listener (optional)
867
+ */
868
+ offAnyOutgoing(listener) {
869
+ if (!this._anyOutgoingListeners) {
870
+ return this;
871
+ }
872
+ if (listener) {
873
+ const listeners = this._anyOutgoingListeners;
874
+ for (let i = 0; i < listeners.length; i++) {
875
+ if (listener === listeners[i]) {
876
+ listeners.splice(i, 1);
877
+ return this;
878
+ }
879
+ }
880
+ }
881
+ else {
882
+ this._anyOutgoingListeners = [];
883
+ }
884
+ return this;
885
+ }
886
+ /**
887
+ * Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
888
+ * e.g. to remove listeners.
889
+ */
890
+ listenersAnyOutgoing() {
891
+ return this._anyOutgoingListeners || [];
892
+ }
893
+ /**
894
+ * Notify the listeners for each packet sent
895
+ *
896
+ * @param packet
897
+ *
898
+ * @private
899
+ */
900
+ notifyOutgoingListeners(packet) {
901
+ if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
902
+ const listeners = this._anyOutgoingListeners.slice();
903
+ for (const listener of listeners) {
904
+ listener.apply(this, packet.data);
905
+ }
906
+ }
907
+ }
908
+ }
909
+ exports.Socket = Socket;