lightclawbot 1.1.2 → 1.2.0-beta.0

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 (397) hide show
  1. package/README.md +0 -1
  2. package/dist/index.js +38 -31
  3. package/dist/setup-entry.js +32 -0
  4. package/dist/src/channel.js +301 -257
  5. package/dist/src/channel.setup.js +16 -0
  6. package/dist/src/config.js +31 -124
  7. package/dist/src/dedup.js +0 -1
  8. package/dist/src/download-tool.js +0 -1
  9. package/dist/src/file-storage.js +2 -2
  10. package/dist/src/gateway.js +226 -178
  11. package/dist/src/history/cron-utils.js +0 -1
  12. package/dist/src/history/index.js +0 -1
  13. package/dist/src/history/message-parser.js +0 -1
  14. package/dist/src/history/session-reader.js +3 -1
  15. package/dist/src/history/session-store.js +0 -1
  16. package/dist/src/history/text-processing.js +0 -1
  17. package/dist/src/history/types.js +0 -1
  18. package/dist/src/inbound.js +183 -234
  19. package/dist/src/media.js +0 -1
  20. package/dist/src/messaging.js +65 -0
  21. package/dist/src/outbound.js +131 -45
  22. package/dist/src/runtime.js +29 -11
  23. package/dist/src/setup-core.js +27 -0
  24. package/dist/src/shared.js +141 -0
  25. package/dist/src/socket/handlers.js +72 -49
  26. package/dist/src/socket/index.js +0 -1
  27. package/dist/src/socket/native-socket.js +385 -0
  28. package/dist/src/socket/registry.js +0 -1
  29. package/dist/src/socket/reliable-emitter.js +188 -50
  30. package/dist/src/streaming/delta-tracker.js +140 -0
  31. package/dist/src/streaming/index.js +12 -0
  32. package/dist/src/streaming/stream-reply-sink.js +387 -0
  33. package/dist/src/streaming/types.js +4 -0
  34. package/dist/src/tools.js +13 -0
  35. package/dist/src/types.js +23 -2
  36. package/dist/src/upload-tool.js +0 -1
  37. package/dist/src/utils/account.js +73 -0
  38. package/dist/src/utils/common.js +48 -0
  39. package/dist/src/utils/index.js +2 -0
  40. package/node_modules/ws/index.js +22 -0
  41. package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/constants.js +1 -0
  42. package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/permessage-deflate.js +6 -6
  43. package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket-server.js +10 -6
  44. package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket.js +19 -14
  45. package/node_modules/{engine.io-client/node_modules/ws → ws}/package.json +4 -3
  46. package/node_modules/ws/wrapper.mjs +21 -0
  47. package/openclaw.plugin.json +0 -7
  48. package/package.json +8 -5
  49. package/dist/index.d.ts +0 -24
  50. package/dist/index.d.ts.map +0 -1
  51. package/dist/index.js.map +0 -1
  52. package/dist/public/data/scripts/manifest.json +0 -11
  53. package/dist/public/data/scripts/preflight.9af62b39.sh +0 -191
  54. package/dist/public/data/scripts/preflight.sh +0 -191
  55. package/dist/src/channel.d.ts +0 -11
  56. package/dist/src/channel.d.ts.map +0 -1
  57. package/dist/src/channel.js.map +0 -1
  58. package/dist/src/config.d.ts +0 -129
  59. package/dist/src/config.d.ts.map +0 -1
  60. package/dist/src/config.js.map +0 -1
  61. package/dist/src/dedup.d.ts +0 -12
  62. package/dist/src/dedup.d.ts.map +0 -1
  63. package/dist/src/dedup.js.map +0 -1
  64. package/dist/src/download-tool.d.ts +0 -32
  65. package/dist/src/download-tool.d.ts.map +0 -1
  66. package/dist/src/download-tool.js.map +0 -1
  67. package/dist/src/file-storage.d.ts +0 -74
  68. package/dist/src/file-storage.d.ts.map +0 -1
  69. package/dist/src/file-storage.js.map +0 -1
  70. package/dist/src/format-urls.d.ts +0 -26
  71. package/dist/src/format-urls.d.ts.map +0 -1
  72. package/dist/src/format-urls.js +0 -53
  73. package/dist/src/format-urls.js.map +0 -1
  74. package/dist/src/gateway.d.ts +0 -16
  75. package/dist/src/gateway.d.ts.map +0 -1
  76. package/dist/src/gateway.js.map +0 -1
  77. package/dist/src/history/cron-utils.d.ts +0 -76
  78. package/dist/src/history/cron-utils.d.ts.map +0 -1
  79. package/dist/src/history/cron-utils.js.map +0 -1
  80. package/dist/src/history/index.d.ts +0 -20
  81. package/dist/src/history/index.d.ts.map +0 -1
  82. package/dist/src/history/index.js.map +0 -1
  83. package/dist/src/history/message-parser.d.ts +0 -52
  84. package/dist/src/history/message-parser.d.ts.map +0 -1
  85. package/dist/src/history/message-parser.js.map +0 -1
  86. package/dist/src/history/session-reader.d.ts +0 -58
  87. package/dist/src/history/session-reader.d.ts.map +0 -1
  88. package/dist/src/history/session-reader.js.map +0 -1
  89. package/dist/src/history/session-store.d.ts +0 -42
  90. package/dist/src/history/session-store.d.ts.map +0 -1
  91. package/dist/src/history/session-store.js.map +0 -1
  92. package/dist/src/history/text-processing.d.ts +0 -41
  93. package/dist/src/history/text-processing.d.ts.map +0 -1
  94. package/dist/src/history/text-processing.js.map +0 -1
  95. package/dist/src/history/types.d.ts +0 -134
  96. package/dist/src/history/types.d.ts.map +0 -1
  97. package/dist/src/history/types.js.map +0 -1
  98. package/dist/src/inbound.d.ts +0 -18
  99. package/dist/src/inbound.d.ts.map +0 -1
  100. package/dist/src/inbound.js.map +0 -1
  101. package/dist/src/media.d.ts +0 -12
  102. package/dist/src/media.d.ts.map +0 -1
  103. package/dist/src/media.js.map +0 -1
  104. package/dist/src/outbound.d.ts +0 -28
  105. package/dist/src/outbound.d.ts.map +0 -1
  106. package/dist/src/outbound.js.map +0 -1
  107. package/dist/src/runtime.d.ts +0 -4
  108. package/dist/src/runtime.d.ts.map +0 -1
  109. package/dist/src/runtime.js.map +0 -1
  110. package/dist/src/socket/handlers.d.ts +0 -26
  111. package/dist/src/socket/handlers.d.ts.map +0 -1
  112. package/dist/src/socket/handlers.js.map +0 -1
  113. package/dist/src/socket/index.d.ts +0 -11
  114. package/dist/src/socket/index.d.ts.map +0 -1
  115. package/dist/src/socket/index.js.map +0 -1
  116. package/dist/src/socket/registry.d.ts +0 -59
  117. package/dist/src/socket/registry.d.ts.map +0 -1
  118. package/dist/src/socket/registry.js.map +0 -1
  119. package/dist/src/socket/reliable-emitter.d.ts +0 -79
  120. package/dist/src/socket/reliable-emitter.d.ts.map +0 -1
  121. package/dist/src/socket/reliable-emitter.js.map +0 -1
  122. package/dist/src/types.d.ts +0 -112
  123. package/dist/src/types.d.ts.map +0 -1
  124. package/dist/src/types.js.map +0 -1
  125. package/dist/src/upload-tool.d.ts +0 -27
  126. package/dist/src/upload-tool.d.ts.map +0 -1
  127. package/dist/src/upload-tool.js.map +0 -1
  128. package/node_modules/@socket.io/component-emitter/LICENSE +0 -24
  129. package/node_modules/@socket.io/component-emitter/Readme.md +0 -79
  130. package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +0 -179
  131. package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +0 -176
  132. package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +0 -4
  133. package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +0 -179
  134. package/node_modules/@socket.io/component-emitter/lib/esm/index.js +0 -169
  135. package/node_modules/@socket.io/component-emitter/lib/esm/package.json +0 -4
  136. package/node_modules/@socket.io/component-emitter/package.json +0 -28
  137. package/node_modules/debug/LICENSE +0 -20
  138. package/node_modules/debug/README.md +0 -481
  139. package/node_modules/debug/package.json +0 -64
  140. package/node_modules/debug/src/browser.js +0 -272
  141. package/node_modules/debug/src/common.js +0 -292
  142. package/node_modules/debug/src/index.js +0 -10
  143. package/node_modules/debug/src/node.js +0 -263
  144. package/node_modules/engine.io-client/LICENSE +0 -22
  145. package/node_modules/engine.io-client/README.md +0 -331
  146. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +0 -3
  147. package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +0 -4
  148. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +0 -1
  149. package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +0 -14
  150. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +0 -15
  151. package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +0 -38
  152. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +0 -1
  153. package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +0 -67
  154. package/node_modules/engine.io-client/build/cjs/globals.d.ts +0 -4
  155. package/node_modules/engine.io-client/build/cjs/globals.js +0 -26
  156. package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +0 -21
  157. package/node_modules/engine.io-client/build/cjs/globals.node.js +0 -97
  158. package/node_modules/engine.io-client/build/cjs/index.d.ts +0 -15
  159. package/node_modules/engine.io-client/build/cjs/index.js +0 -32
  160. package/node_modules/engine.io-client/build/cjs/package.json +0 -10
  161. package/node_modules/engine.io-client/build/cjs/socket.d.ts +0 -482
  162. package/node_modules/engine.io-client/build/cjs/socket.js +0 -765
  163. package/node_modules/engine.io-client/build/cjs/transport.d.ts +0 -106
  164. package/node_modules/engine.io-client/build/cjs/transport.js +0 -153
  165. package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +0 -8
  166. package/node_modules/engine.io-client/build/cjs/transports/index.js +0 -11
  167. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +0 -15
  168. package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +0 -60
  169. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +0 -108
  170. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +0 -285
  171. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +0 -11
  172. package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +0 -44
  173. package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +0 -52
  174. package/node_modules/engine.io-client/build/cjs/transports/polling.js +0 -165
  175. package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +0 -36
  176. package/node_modules/engine.io-client/build/cjs/transports/websocket.js +0 -136
  177. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +0 -14
  178. package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +0 -68
  179. package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +0 -18
  180. package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +0 -94
  181. package/node_modules/engine.io-client/build/cjs/util.d.ts +0 -7
  182. package/node_modules/engine.io-client/build/cjs/util.js +0 -65
  183. package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +0 -3
  184. package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +0 -2
  185. package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +0 -1
  186. package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +0 -11
  187. package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +0 -15
  188. package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +0 -34
  189. package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +0 -1
  190. package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +0 -64
  191. package/node_modules/engine.io-client/build/esm/globals.d.ts +0 -4
  192. package/node_modules/engine.io-client/build/esm/globals.js +0 -22
  193. package/node_modules/engine.io-client/build/esm/globals.node.d.ts +0 -21
  194. package/node_modules/engine.io-client/build/esm/globals.node.js +0 -91
  195. package/node_modules/engine.io-client/build/esm/index.d.ts +0 -15
  196. package/node_modules/engine.io-client/build/esm/index.js +0 -15
  197. package/node_modules/engine.io-client/build/esm/package.json +0 -10
  198. package/node_modules/engine.io-client/build/esm/socket.d.ts +0 -482
  199. package/node_modules/engine.io-client/build/esm/socket.js +0 -727
  200. package/node_modules/engine.io-client/build/esm/transport.d.ts +0 -106
  201. package/node_modules/engine.io-client/build/esm/transport.js +0 -142
  202. package/node_modules/engine.io-client/build/esm/transports/index.d.ts +0 -8
  203. package/node_modules/engine.io-client/build/esm/transports/index.js +0 -8
  204. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +0 -15
  205. package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +0 -56
  206. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +0 -108
  207. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +0 -271
  208. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +0 -11
  209. package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +0 -17
  210. package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +0 -52
  211. package/node_modules/engine.io-client/build/esm/transports/polling.js +0 -145
  212. package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +0 -36
  213. package/node_modules/engine.io-client/build/esm/transports/websocket.js +0 -125
  214. package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +0 -14
  215. package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +0 -41
  216. package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +0 -18
  217. package/node_modules/engine.io-client/build/esm/transports/webtransport.js +0 -80
  218. package/node_modules/engine.io-client/build/esm/util.d.ts +0 -7
  219. package/node_modules/engine.io-client/build/esm/util.js +0 -59
  220. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -3
  221. package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +0 -2
  222. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +0 -1
  223. package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +0 -11
  224. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +0 -15
  225. package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +0 -34
  226. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +0 -1
  227. package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +0 -64
  228. package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +0 -4
  229. package/node_modules/engine.io-client/build/esm-debug/globals.js +0 -22
  230. package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +0 -21
  231. package/node_modules/engine.io-client/build/esm-debug/globals.node.js +0 -91
  232. package/node_modules/engine.io-client/build/esm-debug/index.d.ts +0 -15
  233. package/node_modules/engine.io-client/build/esm-debug/index.js +0 -15
  234. package/node_modules/engine.io-client/build/esm-debug/package.json +0 -10
  235. package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +0 -482
  236. package/node_modules/engine.io-client/build/esm-debug/socket.js +0 -756
  237. package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +0 -106
  238. package/node_modules/engine.io-client/build/esm-debug/transport.js +0 -145
  239. package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +0 -8
  240. package/node_modules/engine.io-client/build/esm-debug/transports/index.js +0 -8
  241. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +0 -15
  242. package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +0 -56
  243. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +0 -108
  244. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +0 -276
  245. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +0 -11
  246. package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +0 -17
  247. package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +0 -52
  248. package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +0 -158
  249. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +0 -36
  250. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +0 -128
  251. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +0 -14
  252. package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +0 -41
  253. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +0 -18
  254. package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +0 -87
  255. package/node_modules/engine.io-client/build/esm-debug/util.d.ts +0 -7
  256. package/node_modules/engine.io-client/build/esm-debug/util.js +0 -59
  257. package/node_modules/engine.io-client/dist/engine.io.esm.min.js +0 -7
  258. package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +0 -1
  259. package/node_modules/engine.io-client/dist/engine.io.js +0 -3064
  260. package/node_modules/engine.io-client/dist/engine.io.js.map +0 -1
  261. package/node_modules/engine.io-client/dist/engine.io.min.js +0 -7
  262. package/node_modules/engine.io-client/dist/engine.io.min.js.map +0 -1
  263. package/node_modules/engine.io-client/node_modules/ws/index.js +0 -13
  264. package/node_modules/engine.io-client/node_modules/ws/wrapper.mjs +0 -8
  265. package/node_modules/engine.io-client/package.json +0 -95
  266. package/node_modules/engine.io-parser/LICENSE +0 -22
  267. package/node_modules/engine.io-parser/Readme.md +0 -158
  268. package/node_modules/engine.io-parser/build/cjs/commons.d.ts +0 -14
  269. package/node_modules/engine.io-parser/build/cjs/commons.js +0 -19
  270. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +0 -2
  271. package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +0 -48
  272. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +0 -2
  273. package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +0 -66
  274. package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +0 -2
  275. package/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -59
  276. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +0 -4
  277. package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +0 -72
  278. package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +0 -3
  279. package/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -38
  280. package/node_modules/engine.io-parser/build/cjs/index.d.ts +0 -9
  281. package/node_modules/engine.io-parser/build/cjs/index.js +0 -164
  282. package/node_modules/engine.io-parser/build/cjs/package.json +0 -8
  283. package/node_modules/engine.io-parser/build/esm/commons.d.ts +0 -14
  284. package/node_modules/engine.io-parser/build/esm/commons.js +0 -14
  285. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +0 -2
  286. package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +0 -43
  287. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +0 -2
  288. package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +0 -62
  289. package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +0 -2
  290. package/node_modules/engine.io-parser/build/esm/decodePacket.js +0 -55
  291. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +0 -4
  292. package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +0 -68
  293. package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +0 -3
  294. package/node_modules/engine.io-parser/build/esm/encodePacket.js +0 -33
  295. package/node_modules/engine.io-parser/build/esm/index.d.ts +0 -9
  296. package/node_modules/engine.io-parser/build/esm/index.js +0 -156
  297. package/node_modules/engine.io-parser/build/esm/package.json +0 -8
  298. package/node_modules/engine.io-parser/package.json +0 -46
  299. package/node_modules/ms/index.js +0 -162
  300. package/node_modules/ms/license.md +0 -21
  301. package/node_modules/ms/package.json +0 -38
  302. package/node_modules/ms/readme.md +0 -59
  303. package/node_modules/socket.io-client/LICENSE +0 -21
  304. package/node_modules/socket.io-client/README.md +0 -29
  305. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +0 -2
  306. package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +0 -4
  307. package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +0 -12
  308. package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +0 -69
  309. package/node_modules/socket.io-client/build/cjs/index.d.ts +0 -29
  310. package/node_modules/socket.io-client/build/cjs/index.js +0 -76
  311. package/node_modules/socket.io-client/build/cjs/manager.d.ts +0 -295
  312. package/node_modules/socket.io-client/build/cjs/manager.js +0 -416
  313. package/node_modules/socket.io-client/build/cjs/on.d.ts +0 -2
  314. package/node_modules/socket.io-client/build/cjs/on.js +0 -9
  315. package/node_modules/socket.io-client/build/cjs/socket.d.ts +0 -593
  316. package/node_modules/socket.io-client/build/cjs/socket.js +0 -909
  317. package/node_modules/socket.io-client/build/cjs/url.d.ts +0 -33
  318. package/node_modules/socket.io-client/build/cjs/url.js +0 -69
  319. package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +0 -2
  320. package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +0 -2
  321. package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +0 -12
  322. package/node_modules/socket.io-client/build/esm/contrib/backo2.js +0 -66
  323. package/node_modules/socket.io-client/build/esm/index.d.ts +0 -29
  324. package/node_modules/socket.io-client/build/esm/index.js +0 -58
  325. package/node_modules/socket.io-client/build/esm/manager.d.ts +0 -295
  326. package/node_modules/socket.io-client/build/esm/manager.js +0 -367
  327. package/node_modules/socket.io-client/build/esm/on.d.ts +0 -2
  328. package/node_modules/socket.io-client/build/esm/on.js +0 -6
  329. package/node_modules/socket.io-client/build/esm/package.json +0 -5
  330. package/node_modules/socket.io-client/build/esm/socket.d.ts +0 -593
  331. package/node_modules/socket.io-client/build/esm/socket.js +0 -880
  332. package/node_modules/socket.io-client/build/esm/url.d.ts +0 -33
  333. package/node_modules/socket.io-client/build/esm/url.js +0 -59
  334. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -2
  335. package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +0 -2
  336. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +0 -12
  337. package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +0 -66
  338. package/node_modules/socket.io-client/build/esm-debug/index.d.ts +0 -29
  339. package/node_modules/socket.io-client/build/esm-debug/index.js +0 -62
  340. package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +0 -295
  341. package/node_modules/socket.io-client/build/esm-debug/manager.js +0 -386
  342. package/node_modules/socket.io-client/build/esm-debug/on.d.ts +0 -2
  343. package/node_modules/socket.io-client/build/esm-debug/on.js +0 -6
  344. package/node_modules/socket.io-client/build/esm-debug/package.json +0 -5
  345. package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +0 -593
  346. package/node_modules/socket.io-client/build/esm-debug/socket.js +0 -902
  347. package/node_modules/socket.io-client/build/esm-debug/url.d.ts +0 -33
  348. package/node_modules/socket.io-client/build/esm-debug/url.js +0 -63
  349. package/node_modules/socket.io-client/dist/socket.io.esm.min.js +0 -7
  350. package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +0 -1
  351. package/node_modules/socket.io-client/dist/socket.io.js +0 -4955
  352. package/node_modules/socket.io-client/dist/socket.io.js.map +0 -1
  353. package/node_modules/socket.io-client/dist/socket.io.min.js +0 -7
  354. package/node_modules/socket.io-client/dist/socket.io.min.js.map +0 -1
  355. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +0 -7
  356. package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +0 -1
  357. package/node_modules/socket.io-client/package.json +0 -101
  358. package/node_modules/socket.io-parser/LICENSE +0 -20
  359. package/node_modules/socket.io-parser/Readme.md +0 -81
  360. package/node_modules/socket.io-parser/build/cjs/binary.d.ts +0 -20
  361. package/node_modules/socket.io-parser/build/cjs/binary.js +0 -87
  362. package/node_modules/socket.io-parser/build/cjs/index.d.ts +0 -101
  363. package/node_modules/socket.io-parser/build/cjs/index.js +0 -367
  364. package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +0 -7
  365. package/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -54
  366. package/node_modules/socket.io-parser/build/cjs/package.json +0 -3
  367. package/node_modules/socket.io-parser/build/esm/binary.d.ts +0 -20
  368. package/node_modules/socket.io-parser/build/esm/binary.js +0 -83
  369. package/node_modules/socket.io-parser/build/esm/index.d.ts +0 -101
  370. package/node_modules/socket.io-parser/build/esm/index.js +0 -356
  371. package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +0 -7
  372. package/node_modules/socket.io-parser/build/esm/is-binary.js +0 -50
  373. package/node_modules/socket.io-parser/build/esm/package.json +0 -3
  374. package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +0 -20
  375. package/node_modules/socket.io-parser/build/esm-debug/binary.js +0 -83
  376. package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +0 -101
  377. package/node_modules/socket.io-parser/build/esm-debug/index.js +0 -361
  378. package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +0 -7
  379. package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +0 -50
  380. package/node_modules/socket.io-parser/build/esm-debug/package.json +0 -3
  381. package/node_modules/socket.io-parser/package.json +0 -44
  382. package/node_modules/xmlhttprequest-ssl/LICENSE +0 -22
  383. package/node_modules/xmlhttprequest-ssl/README.md +0 -67
  384. package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +0 -689
  385. package/node_modules/xmlhttprequest-ssl/package.json +0 -40
  386. /package/node_modules/{engine.io-client/node_modules/ws → ws}/LICENSE +0 -0
  387. /package/node_modules/{engine.io-client/node_modules/ws → ws}/README.md +0 -0
  388. /package/node_modules/{engine.io-client/node_modules/ws → ws}/browser.js +0 -0
  389. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/buffer-util.js +0 -0
  390. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/event-target.js +0 -0
  391. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/extension.js +0 -0
  392. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/limiter.js +0 -0
  393. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/receiver.js +0 -0
  394. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/sender.js +0 -0
  395. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/stream.js +0 -0
  396. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/subprotocol.js +0 -0
  397. /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/validation.js +0 -0
@@ -1,367 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Decoder = exports.Encoder = exports.PacketType = exports.protocol = void 0;
4
- exports.isPacketValid = isPacketValid;
5
- const component_emitter_1 = require("@socket.io/component-emitter");
6
- const binary_js_1 = require("./binary.js");
7
- const is_binary_js_1 = require("./is-binary.js");
8
- const debug_1 = require("debug"); // debug()
9
- const debug = (0, debug_1.default)("socket.io-parser"); // debug()
10
- /**
11
- * These strings must not be used as event names, as they have a special meaning.
12
- */
13
- const RESERVED_EVENTS = [
14
- "connect", // used on the client side
15
- "connect_error", // used on the client side
16
- "disconnect", // used on both sides
17
- "disconnecting", // used on the server side
18
- "newListener", // used by the Node.js EventEmitter
19
- "removeListener", // used by the Node.js EventEmitter
20
- ];
21
- /**
22
- * Protocol version.
23
- *
24
- * @public
25
- */
26
- exports.protocol = 5;
27
- var PacketType;
28
- (function (PacketType) {
29
- PacketType[PacketType["CONNECT"] = 0] = "CONNECT";
30
- PacketType[PacketType["DISCONNECT"] = 1] = "DISCONNECT";
31
- PacketType[PacketType["EVENT"] = 2] = "EVENT";
32
- PacketType[PacketType["ACK"] = 3] = "ACK";
33
- PacketType[PacketType["CONNECT_ERROR"] = 4] = "CONNECT_ERROR";
34
- PacketType[PacketType["BINARY_EVENT"] = 5] = "BINARY_EVENT";
35
- PacketType[PacketType["BINARY_ACK"] = 6] = "BINARY_ACK";
36
- })(PacketType || (exports.PacketType = PacketType = {}));
37
- /**
38
- * A socket.io Encoder instance
39
- */
40
- class Encoder {
41
- /**
42
- * Encoder constructor
43
- *
44
- * @param {function} replacer - custom replacer to pass down to JSON.parse
45
- */
46
- constructor(replacer) {
47
- this.replacer = replacer;
48
- }
49
- /**
50
- * Encode a packet as a single string if non-binary, or as a
51
- * buffer sequence, depending on packet type.
52
- *
53
- * @param {Object} obj - packet object
54
- */
55
- encode(obj) {
56
- debug("encoding packet %j", obj);
57
- if (obj.type === PacketType.EVENT || obj.type === PacketType.ACK) {
58
- if ((0, is_binary_js_1.hasBinary)(obj)) {
59
- return this.encodeAsBinary({
60
- type: obj.type === PacketType.EVENT
61
- ? PacketType.BINARY_EVENT
62
- : PacketType.BINARY_ACK,
63
- nsp: obj.nsp,
64
- data: obj.data,
65
- id: obj.id,
66
- });
67
- }
68
- }
69
- return [this.encodeAsString(obj)];
70
- }
71
- /**
72
- * Encode packet as string.
73
- */
74
- encodeAsString(obj) {
75
- // first is type
76
- let str = "" + obj.type;
77
- // attachments if we have them
78
- if (obj.type === PacketType.BINARY_EVENT ||
79
- obj.type === PacketType.BINARY_ACK) {
80
- str += obj.attachments + "-";
81
- }
82
- // if we have a namespace other than `/`
83
- // we append it followed by a comma `,`
84
- if (obj.nsp && "/" !== obj.nsp) {
85
- str += obj.nsp + ",";
86
- }
87
- // immediately followed by the id
88
- if (null != obj.id) {
89
- str += obj.id;
90
- }
91
- // json data
92
- if (null != obj.data) {
93
- str += JSON.stringify(obj.data, this.replacer);
94
- }
95
- debug("encoded %j as %s", obj, str);
96
- return str;
97
- }
98
- /**
99
- * Encode packet as 'buffer sequence' by removing blobs, and
100
- * deconstructing packet into object with placeholders and
101
- * a list of buffers.
102
- */
103
- encodeAsBinary(obj) {
104
- const deconstruction = (0, binary_js_1.deconstructPacket)(obj);
105
- const pack = this.encodeAsString(deconstruction.packet);
106
- const buffers = deconstruction.buffers;
107
- buffers.unshift(pack); // add packet info to beginning of data list
108
- return buffers; // write all the buffers
109
- }
110
- }
111
- exports.Encoder = Encoder;
112
- /**
113
- * A socket.io Decoder instance
114
- *
115
- * @return {Object} decoder
116
- */
117
- class Decoder extends component_emitter_1.Emitter {
118
- /**
119
- * Decoder constructor
120
- */
121
- constructor(opts) {
122
- super();
123
- this.opts = Object.assign({
124
- reviver: undefined,
125
- maxAttachments: 10,
126
- }, typeof opts === "function" ? { reviver: opts } : opts);
127
- }
128
- /**
129
- * Decodes an encoded packet string into packet JSON.
130
- *
131
- * @param {String} obj - encoded packet
132
- */
133
- add(obj) {
134
- let packet;
135
- if (typeof obj === "string") {
136
- if (this.reconstructor) {
137
- throw new Error("got plaintext data when reconstructing a packet");
138
- }
139
- packet = this.decodeString(obj);
140
- const isBinaryEvent = packet.type === PacketType.BINARY_EVENT;
141
- if (isBinaryEvent || packet.type === PacketType.BINARY_ACK) {
142
- packet.type = isBinaryEvent ? PacketType.EVENT : PacketType.ACK;
143
- // binary packet's json
144
- this.reconstructor = new BinaryReconstructor(packet);
145
- // no attachments, labeled binary but no binary data to follow
146
- if (packet.attachments === 0) {
147
- super.emitReserved("decoded", packet);
148
- }
149
- }
150
- else {
151
- // non-binary full packet
152
- super.emitReserved("decoded", packet);
153
- }
154
- }
155
- else if ((0, is_binary_js_1.isBinary)(obj) || obj.base64) {
156
- // raw binary data
157
- if (!this.reconstructor) {
158
- throw new Error("got binary data when not reconstructing a packet");
159
- }
160
- else {
161
- packet = this.reconstructor.takeBinaryData(obj);
162
- if (packet) {
163
- // received final buffer
164
- this.reconstructor = null;
165
- super.emitReserved("decoded", packet);
166
- }
167
- }
168
- }
169
- else {
170
- throw new Error("Unknown type: " + obj);
171
- }
172
- }
173
- /**
174
- * Decode a packet String (JSON data)
175
- *
176
- * @param {String} str
177
- * @return {Object} packet
178
- */
179
- decodeString(str) {
180
- let i = 0;
181
- // look up type
182
- const p = {
183
- type: Number(str.charAt(0)),
184
- };
185
- if (PacketType[p.type] === undefined) {
186
- throw new Error("unknown packet type " + p.type);
187
- }
188
- // look up attachments if type binary
189
- if (p.type === PacketType.BINARY_EVENT ||
190
- p.type === PacketType.BINARY_ACK) {
191
- const start = i + 1;
192
- while (str.charAt(++i) !== "-" && i != str.length) { }
193
- const buf = str.substring(start, i);
194
- if (buf != Number(buf) || str.charAt(i) !== "-") {
195
- throw new Error("Illegal attachments");
196
- }
197
- const n = Number(buf);
198
- if (!isInteger(n) || n < 0) {
199
- throw new Error("Illegal attachments");
200
- }
201
- else if (n > this.opts.maxAttachments) {
202
- throw new Error("too many attachments");
203
- }
204
- p.attachments = n;
205
- }
206
- // look up namespace (if any)
207
- if ("/" === str.charAt(i + 1)) {
208
- const start = i + 1;
209
- while (++i) {
210
- const c = str.charAt(i);
211
- if ("," === c)
212
- break;
213
- if (i === str.length)
214
- break;
215
- }
216
- p.nsp = str.substring(start, i);
217
- }
218
- else {
219
- p.nsp = "/";
220
- }
221
- // look up id
222
- const next = str.charAt(i + 1);
223
- if ("" !== next && Number(next) == next) {
224
- const start = i + 1;
225
- while (++i) {
226
- const c = str.charAt(i);
227
- if (null == c || Number(c) != c) {
228
- --i;
229
- break;
230
- }
231
- if (i === str.length)
232
- break;
233
- }
234
- p.id = Number(str.substring(start, i + 1));
235
- }
236
- // look up json data
237
- if (str.charAt(++i)) {
238
- const payload = this.tryParse(str.substr(i));
239
- if (Decoder.isPayloadValid(p.type, payload)) {
240
- p.data = payload;
241
- }
242
- else {
243
- throw new Error("invalid payload");
244
- }
245
- }
246
- debug("decoded %s as %j", str, p);
247
- return p;
248
- }
249
- tryParse(str) {
250
- try {
251
- return JSON.parse(str, this.opts.reviver);
252
- }
253
- catch (e) {
254
- return false;
255
- }
256
- }
257
- static isPayloadValid(type, payload) {
258
- switch (type) {
259
- case PacketType.CONNECT:
260
- return isObject(payload);
261
- case PacketType.DISCONNECT:
262
- return payload === undefined;
263
- case PacketType.CONNECT_ERROR:
264
- return typeof payload === "string" || isObject(payload);
265
- case PacketType.EVENT:
266
- case PacketType.BINARY_EVENT:
267
- return (Array.isArray(payload) &&
268
- (typeof payload[0] === "number" ||
269
- (typeof payload[0] === "string" &&
270
- RESERVED_EVENTS.indexOf(payload[0]) === -1)));
271
- case PacketType.ACK:
272
- case PacketType.BINARY_ACK:
273
- return Array.isArray(payload);
274
- }
275
- }
276
- /**
277
- * Deallocates a parser's resources
278
- */
279
- destroy() {
280
- if (this.reconstructor) {
281
- this.reconstructor.finishedReconstruction();
282
- this.reconstructor = null;
283
- }
284
- }
285
- }
286
- exports.Decoder = Decoder;
287
- /**
288
- * A manager of a binary event's 'buffer sequence'. Should
289
- * be constructed whenever a packet of type BINARY_EVENT is
290
- * decoded.
291
- *
292
- * @param {Object} packet
293
- * @return {BinaryReconstructor} initialized reconstructor
294
- */
295
- class BinaryReconstructor {
296
- constructor(packet) {
297
- this.packet = packet;
298
- this.buffers = [];
299
- this.reconPack = packet;
300
- }
301
- /**
302
- * Method to be called when binary data received from connection
303
- * after a BINARY_EVENT packet.
304
- *
305
- * @param {Buffer | ArrayBuffer} binData - the raw binary data received
306
- * @return {null | Object} returns null if more binary data is expected or
307
- * a reconstructed packet object if all buffers have been received.
308
- */
309
- takeBinaryData(binData) {
310
- this.buffers.push(binData);
311
- if (this.buffers.length === this.reconPack.attachments) {
312
- // done with buffer list
313
- const packet = (0, binary_js_1.reconstructPacket)(this.reconPack, this.buffers);
314
- this.finishedReconstruction();
315
- return packet;
316
- }
317
- return null;
318
- }
319
- /**
320
- * Cleans up binary packet reconstruction variables.
321
- */
322
- finishedReconstruction() {
323
- this.reconPack = null;
324
- this.buffers = [];
325
- }
326
- }
327
- function isNamespaceValid(nsp) {
328
- return typeof nsp === "string";
329
- }
330
- // see https://caniuse.com/mdn-javascript_builtins_number_isinteger
331
- const isInteger = Number.isInteger ||
332
- function (value) {
333
- return (typeof value === "number" &&
334
- isFinite(value) &&
335
- Math.floor(value) === value);
336
- };
337
- function isAckIdValid(id) {
338
- return id === undefined || isInteger(id);
339
- }
340
- // see https://stackoverflow.com/questions/8511281/check-if-a-value-is-an-object-in-javascript
341
- function isObject(value) {
342
- return Object.prototype.toString.call(value) === "[object Object]";
343
- }
344
- function isDataValid(type, payload) {
345
- switch (type) {
346
- case PacketType.CONNECT:
347
- return payload === undefined || isObject(payload);
348
- case PacketType.DISCONNECT:
349
- return payload === undefined;
350
- case PacketType.EVENT:
351
- return (Array.isArray(payload) &&
352
- (typeof payload[0] === "number" ||
353
- (typeof payload[0] === "string" &&
354
- RESERVED_EVENTS.indexOf(payload[0]) === -1)));
355
- case PacketType.ACK:
356
- return Array.isArray(payload);
357
- case PacketType.CONNECT_ERROR:
358
- return typeof payload === "string" || isObject(payload);
359
- default:
360
- return false;
361
- }
362
- }
363
- function isPacketValid(packet) {
364
- return (isNamespaceValid(packet.nsp) &&
365
- isAckIdValid(packet.id) &&
366
- isDataValid(packet.type, packet.data));
367
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
3
- *
4
- * @private
5
- */
6
- export declare function isBinary(obj: any): boolean;
7
- export declare function hasBinary(obj: any, toJSON?: boolean): boolean;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isBinary = isBinary;
4
- exports.hasBinary = hasBinary;
5
- const withNativeArrayBuffer = typeof ArrayBuffer === "function";
6
- const isView = (obj) => {
7
- return typeof ArrayBuffer.isView === "function"
8
- ? ArrayBuffer.isView(obj)
9
- : obj.buffer instanceof ArrayBuffer;
10
- };
11
- const toString = Object.prototype.toString;
12
- const withNativeBlob = typeof Blob === "function" ||
13
- (typeof Blob !== "undefined" &&
14
- toString.call(Blob) === "[object BlobConstructor]");
15
- const withNativeFile = typeof File === "function" ||
16
- (typeof File !== "undefined" &&
17
- toString.call(File) === "[object FileConstructor]");
18
- /**
19
- * Returns true if obj is a Buffer, an ArrayBuffer, a Blob or a File.
20
- *
21
- * @private
22
- */
23
- function isBinary(obj) {
24
- return ((withNativeArrayBuffer && (obj instanceof ArrayBuffer || isView(obj))) ||
25
- (withNativeBlob && obj instanceof Blob) ||
26
- (withNativeFile && obj instanceof File));
27
- }
28
- function hasBinary(obj, toJSON) {
29
- if (!obj || typeof obj !== "object") {
30
- return false;
31
- }
32
- if (Array.isArray(obj)) {
33
- for (let i = 0, l = obj.length; i < l; i++) {
34
- if (hasBinary(obj[i])) {
35
- return true;
36
- }
37
- }
38
- return false;
39
- }
40
- if (isBinary(obj)) {
41
- return true;
42
- }
43
- if (obj.toJSON &&
44
- typeof obj.toJSON === "function" &&
45
- arguments.length === 1) {
46
- return hasBinary(obj.toJSON(), true);
47
- }
48
- for (const key in obj) {
49
- if (Object.prototype.hasOwnProperty.call(obj, key) && hasBinary(obj[key])) {
50
- return true;
51
- }
52
- }
53
- return false;
54
- }
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
3
- *
4
- * @param {Object} packet - socket.io event packet
5
- * @return {Object} with deconstructed packet and list of buffers
6
- * @public
7
- */
8
- export declare function deconstructPacket(packet: any): {
9
- packet: any;
10
- buffers: any[];
11
- };
12
- /**
13
- * Reconstructs a binary packet from its placeholder packet and buffers
14
- *
15
- * @param {Object} packet - event packet with placeholders
16
- * @param {Array} buffers - binary buffers to put in placeholder positions
17
- * @return {Object} reconstructed packet
18
- * @public
19
- */
20
- export declare function reconstructPacket(packet: any, buffers: any): any;
@@ -1,83 +0,0 @@
1
- import { isBinary } from "./is-binary.js";
2
- /**
3
- * Replaces every Buffer | ArrayBuffer | Blob | File in packet with a numbered placeholder.
4
- *
5
- * @param {Object} packet - socket.io event packet
6
- * @return {Object} with deconstructed packet and list of buffers
7
- * @public
8
- */
9
- export function deconstructPacket(packet) {
10
- const buffers = [];
11
- const packetData = packet.data;
12
- const pack = packet;
13
- pack.data = _deconstructPacket(packetData, buffers);
14
- pack.attachments = buffers.length; // number of binary 'attachments'
15
- return { packet: pack, buffers: buffers };
16
- }
17
- function _deconstructPacket(data, buffers) {
18
- if (!data)
19
- return data;
20
- if (isBinary(data)) {
21
- const placeholder = { _placeholder: true, num: buffers.length };
22
- buffers.push(data);
23
- return placeholder;
24
- }
25
- else if (Array.isArray(data)) {
26
- const newData = new Array(data.length);
27
- for (let i = 0; i < data.length; i++) {
28
- newData[i] = _deconstructPacket(data[i], buffers);
29
- }
30
- return newData;
31
- }
32
- else if (typeof data === "object" && !(data instanceof Date)) {
33
- const newData = {};
34
- for (const key in data) {
35
- if (Object.prototype.hasOwnProperty.call(data, key)) {
36
- newData[key] = _deconstructPacket(data[key], buffers);
37
- }
38
- }
39
- return newData;
40
- }
41
- return data;
42
- }
43
- /**
44
- * Reconstructs a binary packet from its placeholder packet and buffers
45
- *
46
- * @param {Object} packet - event packet with placeholders
47
- * @param {Array} buffers - binary buffers to put in placeholder positions
48
- * @return {Object} reconstructed packet
49
- * @public
50
- */
51
- export function reconstructPacket(packet, buffers) {
52
- packet.data = _reconstructPacket(packet.data, buffers);
53
- delete packet.attachments; // no longer useful
54
- return packet;
55
- }
56
- function _reconstructPacket(data, buffers) {
57
- if (!data)
58
- return data;
59
- if (data && data._placeholder === true) {
60
- const isIndexValid = typeof data.num === "number" &&
61
- data.num >= 0 &&
62
- data.num < buffers.length;
63
- if (isIndexValid) {
64
- return buffers[data.num]; // appropriate buffer (should be natural order anyway)
65
- }
66
- else {
67
- throw new Error("illegal attachments");
68
- }
69
- }
70
- else if (Array.isArray(data)) {
71
- for (let i = 0; i < data.length; i++) {
72
- data[i] = _reconstructPacket(data[i], buffers);
73
- }
74
- }
75
- else if (typeof data === "object") {
76
- for (const key in data) {
77
- if (Object.prototype.hasOwnProperty.call(data, key)) {
78
- data[key] = _reconstructPacket(data[key], buffers);
79
- }
80
- }
81
- }
82
- return data;
83
- }
@@ -1,101 +0,0 @@
1
- import { Emitter } from "@socket.io/component-emitter";
2
- /**
3
- * Protocol version.
4
- *
5
- * @public
6
- */
7
- export declare const protocol: number;
8
- export declare enum PacketType {
9
- CONNECT = 0,
10
- DISCONNECT = 1,
11
- EVENT = 2,
12
- ACK = 3,
13
- CONNECT_ERROR = 4,
14
- BINARY_EVENT = 5,
15
- BINARY_ACK = 6
16
- }
17
- export interface Packet {
18
- type: PacketType;
19
- nsp: string;
20
- data?: any;
21
- id?: number;
22
- attachments?: number;
23
- }
24
- /**
25
- * A socket.io Encoder instance
26
- */
27
- export declare class Encoder {
28
- private replacer?;
29
- /**
30
- * Encoder constructor
31
- *
32
- * @param {function} replacer - custom replacer to pass down to JSON.parse
33
- */
34
- constructor(replacer?: (this: any, key: string, value: any) => any);
35
- /**
36
- * Encode a packet as a single string if non-binary, or as a
37
- * buffer sequence, depending on packet type.
38
- *
39
- * @param {Object} obj - packet object
40
- */
41
- encode(obj: Packet): any[];
42
- /**
43
- * Encode packet as string.
44
- */
45
- private encodeAsString;
46
- /**
47
- * Encode packet as 'buffer sequence' by removing blobs, and
48
- * deconstructing packet into object with placeholders and
49
- * a list of buffers.
50
- */
51
- private encodeAsBinary;
52
- }
53
- interface DecoderReservedEvents {
54
- decoded: (packet: Packet) => void;
55
- }
56
- type JSONReviver = (this: any, key: string, value: any) => any;
57
- export interface DecoderOptions {
58
- /**
59
- * Custom reviver to pass down to JSON.parse()
60
- */
61
- reviver?: JSONReviver;
62
- /**
63
- * Maximum number of binary attachments per packet
64
- * @default 10
65
- */
66
- maxAttachments?: number;
67
- }
68
- /**
69
- * A socket.io Decoder instance
70
- *
71
- * @return {Object} decoder
72
- */
73
- export declare class Decoder extends Emitter<{}, {}, DecoderReservedEvents> {
74
- private reconstructor;
75
- private opts;
76
- /**
77
- * Decoder constructor
78
- */
79
- constructor(opts?: DecoderOptions | JSONReviver);
80
- /**
81
- * Decodes an encoded packet string into packet JSON.
82
- *
83
- * @param {String} obj - encoded packet
84
- */
85
- add(obj: any): void;
86
- /**
87
- * Decode a packet String (JSON data)
88
- *
89
- * @param {String} str
90
- * @return {Object} packet
91
- */
92
- private decodeString;
93
- private tryParse;
94
- private static isPayloadValid;
95
- /**
96
- * Deallocates a parser's resources
97
- */
98
- destroy(): void;
99
- }
100
- export declare function isPacketValid(packet: Packet): boolean;
101
- export {};