@wabot-dev/framework 0.0.12 → 0.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/_virtual/XMLHttpRequest.js +7 -0
- package/dist/src/_virtual/_commonjsHelpers.js +32 -0
- package/dist/src/_virtual/base64id.js +3 -0
- package/dist/src/_virtual/binary.js +3 -0
- package/dist/src/_virtual/bom-handling.js +3 -0
- package/dist/src/_virtual/broadcast-operator.js +3 -0
- package/dist/src/_virtual/browser.js +3 -0
- package/dist/src/_virtual/browser2.js +3 -0
- package/dist/src/_virtual/browser3.js +3 -0
- package/dist/src/_virtual/browser4.js +3 -0
- package/dist/src/_virtual/browser5.js +3 -0
- package/dist/src/_virtual/buffer-util.js +3 -0
- package/dist/src/_virtual/buffer-util2.js +3 -0
- package/dist/src/_virtual/buffer-util3.js +3 -0
- package/dist/src/_virtual/charset.js +3 -0
- package/dist/src/_virtual/charset2.js +3 -0
- package/dist/src/_virtual/client.js +3 -0
- package/dist/src/_virtual/cluster-adapter.js +3 -0
- package/dist/src/_virtual/commons.js +3 -0
- package/dist/src/_virtual/dbcs-codec.js +3 -0
- package/dist/src/_virtual/decodePacket.js +3 -0
- package/dist/src/_virtual/encodePacket.js +3 -0
- package/dist/src/_virtual/encoding.js +3 -0
- package/dist/src/_virtual/encoding2.js +3 -0
- package/dist/src/_virtual/engine.io.js +3 -0
- package/dist/src/_virtual/in-memory-adapter.js +3 -0
- package/dist/src/_virtual/index.js +7 -0
- package/dist/src/_virtual/index10.js +3 -0
- package/dist/src/_virtual/index11.js +3 -0
- package/dist/src/_virtual/index12.js +3 -0
- package/dist/src/_virtual/index13.js +3 -0
- package/dist/src/_virtual/index14.js +3 -0
- package/dist/src/_virtual/index15.js +3 -0
- package/dist/src/_virtual/index16.js +3 -0
- package/dist/src/_virtual/index17.js +3 -0
- package/dist/src/_virtual/index18.js +3 -0
- package/dist/src/_virtual/index19.js +3 -0
- package/dist/src/_virtual/index2.js +7 -0
- package/dist/src/_virtual/index20.js +3 -0
- package/dist/src/_virtual/index21.js +3 -0
- package/dist/src/_virtual/index22.js +3 -0
- package/dist/src/_virtual/index23.js +3 -0
- package/dist/src/_virtual/index24.js +3 -0
- package/dist/src/_virtual/index25.js +3 -0
- package/dist/src/_virtual/index26.js +3 -0
- package/dist/src/_virtual/index27.js +3 -0
- package/dist/src/_virtual/index28.js +3 -0
- package/dist/src/_virtual/index29.js +3 -0
- package/dist/src/_virtual/index3.js +7 -0
- package/dist/src/_virtual/index30.js +3 -0
- package/dist/src/_virtual/index31.js +3 -0
- package/dist/src/_virtual/index32.js +3 -0
- package/dist/src/_virtual/index33.js +3 -0
- package/dist/src/_virtual/index4.js +3 -0
- package/dist/src/_virtual/index5.js +3 -0
- package/dist/src/_virtual/index6.js +3 -0
- package/dist/src/_virtual/index7.js +3 -0
- package/dist/src/_virtual/index8.js +6 -0
- package/dist/src/_virtual/index9.js +3 -0
- package/dist/src/_virtual/inherits.js +3 -0
- package/dist/src/_virtual/inherits_browser.js +3 -0
- package/dist/src/_virtual/is-binary.js +3 -0
- package/dist/src/_virtual/language.js +3 -0
- package/dist/src/_virtual/language2.js +3 -0
- package/dist/src/_virtual/mediaType.js +3 -0
- package/dist/src/_virtual/mediaType2.js +3 -0
- package/dist/src/_virtual/namespace.js +3 -0
- package/dist/src/_virtual/node.js +3 -0
- package/dist/src/_virtual/node2.js +3 -0
- package/dist/src/_virtual/node3.js +3 -0
- package/dist/src/_virtual/node4.js +3 -0
- package/dist/src/_virtual/node5.js +3 -0
- package/dist/src/_virtual/parent-namespace.js +3 -0
- package/dist/src/_virtual/polling-jsonp.js +3 -0
- package/dist/src/_virtual/polling.js +3 -0
- package/dist/src/_virtual/polling2.js +3 -0
- package/dist/src/_virtual/receiver.js +3 -0
- package/dist/src/_virtual/sbcs-codec.js +3 -0
- package/dist/src/_virtual/sender.js +3 -0
- package/dist/src/_virtual/server.js +3 -0
- package/dist/src/_virtual/socket-types.js +3 -0
- package/dist/src/_virtual/socket.js +3 -0
- package/dist/src/_virtual/socket2.js +3 -0
- package/dist/src/_virtual/stream.js +3 -0
- package/dist/src/_virtual/transport.js +3 -0
- package/dist/src/_virtual/typed-events.js +3 -0
- package/dist/src/_virtual/userver.js +3 -0
- package/dist/src/_virtual/utf16.js +3 -0
- package/dist/src/_virtual/utf32.js +3 -0
- package/dist/src/_virtual/utf7.js +3 -0
- package/dist/src/_virtual/uws.js +3 -0
- package/dist/src/_virtual/validation.js +3 -0
- package/dist/src/_virtual/validation2.js +3 -0
- package/dist/src/_virtual/validation3.js +3 -0
- package/dist/src/_virtual/websocket-server.js +3 -0
- package/dist/src/_virtual/websocket.js +7 -0
- package/dist/src/_virtual/websocket2.js +3 -0
- package/dist/src/_virtual/websocket3.js +3 -0
- package/dist/src/_virtual/webtransport.js +3 -0
- package/dist/src/_virtual/yeast.js +3 -0
- package/dist/src/channels/cmd/@cmd.js +2 -0
- package/dist/src/channels/cmd/CmdChannel.js +2 -0
- package/dist/src/channels/telegram/@telegram.js +2 -0
- package/dist/src/channels/telegram/TelegramChannel.js +2 -0
- package/dist/src/channels/whatsapp/@whatsapp.js +24 -0
- package/dist/src/channels/whatsapp/WhatsAppChannel.js +63 -0
- package/dist/src/channels/whatsapp/WhatsAppChannelConfig.js +8 -0
- package/dist/src/channels/whatsapp/WhatsAppConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppDevConnection.js +61 -0
- package/dist/src/channels/whatsapp/WhatsAppProdConnection.js +36 -0
- package/dist/src/channels/whatsapp/whatsAppDevSocketContracts.js +9 -0
- package/dist/src/controller/express/Express.js +5 -0
- package/dist/src/controller/socket.io/SocketIO.js +5 -0
- package/dist/src/env/WabotEnv.js +21 -0
- package/dist/src/index.d.ts +168 -1
- package/dist/src/index.js +12 -0
- package/dist/src/logger/Logger.js +65 -0
- package/dist/src/node_modules/@socket.io/component-emitter/lib/esm/index.js +171 -0
- package/dist/src/node_modules/base64id/lib/base64id.js +117 -0
- package/dist/src/node_modules/body-parser/index.js +96 -0
- package/dist/src/node_modules/body-parser/lib/read.js +225 -0
- package/dist/src/node_modules/body-parser/lib/types/json.js +222 -0
- package/dist/src/node_modules/body-parser/lib/types/raw.js +90 -0
- package/dist/src/node_modules/body-parser/lib/types/text.js +95 -0
- package/dist/src/node_modules/body-parser/lib/types/urlencoded.js +194 -0
- package/dist/src/node_modules/body-parser/lib/utils.js +96 -0
- package/dist/src/node_modules/bytes/index.js +180 -0
- package/dist/src/node_modules/call-bind-apply-helpers/actualApply.js +24 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionApply.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/functionCall.js +13 -0
- package/dist/src/node_modules/call-bind-apply-helpers/index.js +29 -0
- package/dist/src/node_modules/call-bind-apply-helpers/reflectApply.js +13 -0
- package/dist/src/node_modules/call-bound/index.js +31 -0
- package/dist/src/node_modules/content-type/index.js +235 -0
- package/dist/src/node_modules/cookie/index.js +345 -0
- package/dist/src/node_modules/cors/lib/index.js +249 -0
- package/dist/src/node_modules/debug/src/browser.js +286 -0
- package/dist/src/node_modules/debug/src/common.js +303 -0
- package/dist/src/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/depd/index.js +550 -0
- package/dist/src/node_modules/dunder-proto/get.js +42 -0
- package/dist/src/node_modules/ee-first/index.js +104 -0
- package/dist/src/node_modules/engine.io/build/engine.io.js +73 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/index.js +429 -0
- package/dist/src/node_modules/engine.io/build/parser-v3/utf8.js +198 -0
- package/dist/src/node_modules/engine.io/build/server.js +808 -0
- package/dist/src/node_modules/engine.io/build/socket.js +469 -0
- package/dist/src/node_modules/engine.io/build/transport.js +131 -0
- package/dist/src/node_modules/engine.io/build/transports/index.js +37 -0
- package/dist/src/node_modules/engine.io/build/transports/polling-jsonp.js +53 -0
- package/dist/src/node_modules/engine.io/build/transports/polling.js +346 -0
- package/dist/src/node_modules/engine.io/build/transports/websocket.js +106 -0
- package/dist/src/node_modules/engine.io/build/transports/webtransport.js +76 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/index.js +20 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/polling.js +378 -0
- package/dist/src/node_modules/engine.io/build/transports-uws/websocket.js +85 -0
- package/dist/src/node_modules/engine.io/build/userver.js +292 -0
- package/dist/src/node_modules/engine.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/engine.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/engine.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/engine.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/has-cors.js +13 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseqs.js +36 -0
- package/dist/src/node_modules/engine.io-client/build/esm/contrib/parseuri.js +66 -0
- package/dist/src/node_modules/engine.io-client/build/esm/globals.node.js +92 -0
- package/dist/src/node_modules/engine.io-client/build/esm/index.js +17 -0
- package/dist/src/node_modules/engine.io-client/build/esm/socket.js +728 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transport.js +143 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/index.js +11 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +256 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +21 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/polling.js +146 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.js +107 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/websocket.node.js +48 -0
- package/dist/src/node_modules/engine.io-client/build/esm/transports/webtransport.js +83 -0
- package/dist/src/node_modules/engine.io-client/build/esm/util.js +62 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/engine.io-client/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/commons.js +29 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/decodePacket.js +70 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/encodePacket.js +51 -0
- package/dist/src/node_modules/engine.io-parser/build/cjs/index.js +179 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/commons.js +15 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/decodePacket.js +58 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/encodePacket.js +36 -0
- package/dist/src/node_modules/engine.io-parser/build/esm/index.js +158 -0
- package/dist/src/node_modules/es-define-property/index.js +23 -0
- package/dist/src/node_modules/es-errors/eval.js +13 -0
- package/dist/src/node_modules/es-errors/index.js +13 -0
- package/dist/src/node_modules/es-errors/range.js +13 -0
- package/dist/src/node_modules/es-errors/ref.js +13 -0
- package/dist/src/node_modules/es-errors/syntax.js +13 -0
- package/dist/src/node_modules/es-errors/type.js +13 -0
- package/dist/src/node_modules/es-errors/uri.js +13 -0
- package/dist/src/node_modules/es-object-atoms/index.js +13 -0
- package/dist/src/node_modules/function-bind/implementation.js +93 -0
- package/dist/src/node_modules/function-bind/index.js +16 -0
- package/dist/src/node_modules/get-intrinsic/index.js +413 -0
- package/dist/src/node_modules/get-proto/Object.getPrototypeOf.js +17 -0
- package/dist/src/node_modules/get-proto/Reflect.getPrototypeOf.js +13 -0
- package/dist/src/node_modules/get-proto/index.js +40 -0
- package/dist/src/node_modules/gopd/gOPD.js +13 -0
- package/dist/src/node_modules/gopd/index.js +26 -0
- package/dist/src/node_modules/has-symbols/index.js +25 -0
- package/dist/src/node_modules/has-symbols/shams.js +54 -0
- package/dist/src/node_modules/hasown/index.js +19 -0
- package/dist/src/node_modules/http-errors/index.js +306 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-codec.js +598 -0
- package/dist/src/node_modules/iconv-lite/encodings/dbcs-data.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/index.js +44 -0
- package/dist/src/node_modules/iconv-lite/encodings/internal.js +210 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-codec.js +83 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data-generated.js +460 -0
- package/dist/src/node_modules/iconv-lite/encodings/sbcs-data.js +187 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/big5-added.json.js +506 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp936.json.js +2621 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp949.json.js +2380 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/cp950.json.js +729 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/eucjp.json.js +822 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json.js +424 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/gbk-added.json.js +264 -0
- package/dist/src/node_modules/iconv-lite/encodings/tables/shiftjis.json.js +548 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf16.js +206 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf32.js +329 -0
- package/dist/src/node_modules/iconv-lite/encodings/utf7.js +297 -0
- package/dist/src/node_modules/iconv-lite/lib/bom-handling.js +61 -0
- package/dist/src/node_modules/iconv-lite/lib/index.js +192 -0
- package/dist/src/node_modules/iconv-lite/lib/streams.js +120 -0
- package/dist/src/node_modules/inherits/inherits.js +21 -0
- package/dist/src/node_modules/inherits/inherits_browser.js +38 -0
- package/dist/src/node_modules/math-intrinsics/abs.js +13 -0
- package/dist/src/node_modules/math-intrinsics/floor.js +13 -0
- package/dist/src/node_modules/math-intrinsics/isNaN.js +15 -0
- package/dist/src/node_modules/math-intrinsics/max.js +13 -0
- package/dist/src/node_modules/math-intrinsics/min.js +13 -0
- package/dist/src/node_modules/math-intrinsics/pow.js +13 -0
- package/dist/src/node_modules/math-intrinsics/round.js +13 -0
- package/dist/src/node_modules/math-intrinsics/sign.js +22 -0
- package/dist/src/node_modules/media-typer/index.js +153 -0
- package/dist/src/node_modules/mime-db/db.json.js +11656 -0
- package/dist/src/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/mime-types/index.js +226 -0
- package/dist/src/node_modules/mime-types/mimeScore.js +62 -0
- package/dist/src/node_modules/ms/index.js +172 -0
- package/dist/src/node_modules/object-assign/index.js +99 -0
- package/dist/src/node_modules/object-inspect/index.js +557 -0
- package/dist/src/node_modules/object-inspect/util.inspect.js +13 -0
- package/dist/src/node_modules/on-finished/index.js +245 -0
- package/dist/src/node_modules/qs/lib/formats.js +32 -0
- package/dist/src/node_modules/qs/lib/index.js +24 -0
- package/dist/src/node_modules/qs/lib/parse.js +339 -0
- package/dist/src/node_modules/qs/lib/stringify.js +369 -0
- package/dist/src/node_modules/qs/lib/utils.js +279 -0
- package/dist/src/node_modules/raw-body/index.js +351 -0
- package/dist/src/node_modules/safer-buffer/safer.js +88 -0
- package/dist/src/node_modules/setprototypeof/index.js +26 -0
- package/dist/src/node_modules/side-channel/index.js +58 -0
- package/dist/src/node_modules/side-channel-list/index.js +125 -0
- package/dist/src/node_modules/side-channel-map/index.js +82 -0
- package/dist/src/node_modules/side-channel-weakmap/index.js +99 -0
- package/dist/src/node_modules/socket.io/dist/broadcast-operator.js +448 -0
- package/dist/src/node_modules/socket.io/dist/client.js +281 -0
- package/dist/src/node_modules/socket.io/dist/index.js +837 -0
- package/dist/src/node_modules/socket.io/dist/namespace.js +597 -0
- package/dist/src/node_modules/socket.io/dist/parent-namespace.js +101 -0
- package/dist/src/node_modules/socket.io/dist/socket-types.js +21 -0
- package/dist/src/node_modules/socket.io/dist/socket.js +993 -0
- package/dist/src/node_modules/socket.io/dist/typed-events.js +92 -0
- package/dist/src/node_modules/socket.io/dist/uws.js +149 -0
- package/dist/src/node_modules/socket.io/node_modules/accepts/index.js +250 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/db.json.js +10704 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-db/index.js +24 -0
- package/dist/src/node_modules/socket.io/node_modules/mime-types/index.js +202 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/index.js +96 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/charset.js +179 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/encoding.js +193 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/language.js +188 -0
- package/dist/src/node_modules/socket.io/node_modules/negotiator/lib/mediaType.js +304 -0
- package/dist/src/node_modules/socket.io/package.json.js +5 -0
- package/dist/src/node_modules/socket.io/wrapper.js +5 -0
- package/dist/src/node_modules/socket.io-adapter/dist/cluster-adapter.js +689 -0
- package/dist/src/node_modules/socket.io-adapter/dist/contrib/yeast.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/dist/in-memory-adapter.js +407 -0
- package/dist/src/node_modules/socket.io-adapter/dist/index.js +24 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/index.js +28 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/buffer-util.js +142 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/constants.js +21 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/event-target.js +303 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/extension.js +214 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/limiter.js +64 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/permessage-deflate.js +528 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/receiver.js +719 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/sender.js +513 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/stream.js +170 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/subprotocol.js +73 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/validation.js +141 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket-server.js +559 -0
- package/dist/src/node_modules/socket.io-adapter/node_modules/ws/lib/websocket.js +1363 -0
- package/dist/src/node_modules/socket.io-client/build/esm/contrib/backo2.js +68 -0
- package/dist/src/node_modules/socket.io-client/build/esm/index.js +50 -0
- package/dist/src/node_modules/socket.io-client/build/esm/manager.js +373 -0
- package/dist/src/node_modules/socket.io-client/build/esm/on.js +8 -0
- package/dist/src/node_modules/socket.io-client/build/esm/socket.js +884 -0
- package/dist/src/node_modules/socket.io-client/build/esm/url.js +63 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/binary.js +99 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/index.js +337 -0
- package/dist/src/node_modules/socket.io-parser/build/cjs/is-binary.js +65 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/binary.js +86 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/index.js +314 -0
- package/dist/src/node_modules/socket.io-parser/build/esm/is-binary.js +52 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/browser.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/common.js +285 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/index.js +23 -0
- package/dist/src/node_modules/socket.io-parser/node_modules/debug/src/node.js +279 -0
- package/dist/src/node_modules/statuses/codes.json.js +67 -0
- package/dist/src/node_modules/statuses/index.js +157 -0
- package/dist/src/node_modules/toidentifier/index.js +41 -0
- package/dist/src/node_modules/type-is/index.js +263 -0
- package/dist/src/node_modules/unpipe/index.js +78 -0
- package/dist/src/node_modules/vary/index.js +159 -0
- package/dist/src/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +702 -0
- package/dist/src/server/runChannel.js +8 -8
- package/dist/src/server/runServer.js +41 -2
- package/package.json +7 -3
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initialize backoff timer with `opts`.
|
|
3
|
+
*
|
|
4
|
+
* - `min` initial timeout in milliseconds [100]
|
|
5
|
+
* - `max` max timeout [10000]
|
|
6
|
+
* - `jitter` [0]
|
|
7
|
+
* - `factor` [2]
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} opts
|
|
10
|
+
* @api public
|
|
11
|
+
*/
|
|
12
|
+
function Backoff(opts) {
|
|
13
|
+
opts = opts || {};
|
|
14
|
+
this.ms = opts.min || 100;
|
|
15
|
+
this.max = opts.max || 10000;
|
|
16
|
+
this.factor = opts.factor || 2;
|
|
17
|
+
this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
|
|
18
|
+
this.attempts = 0;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Return the backoff duration.
|
|
22
|
+
*
|
|
23
|
+
* @return {Number}
|
|
24
|
+
* @api public
|
|
25
|
+
*/
|
|
26
|
+
Backoff.prototype.duration = function () {
|
|
27
|
+
var ms = this.ms * Math.pow(this.factor, this.attempts++);
|
|
28
|
+
if (this.jitter) {
|
|
29
|
+
var rand = Math.random();
|
|
30
|
+
var deviation = Math.floor(rand * this.jitter * ms);
|
|
31
|
+
ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
|
|
32
|
+
}
|
|
33
|
+
return Math.min(ms, this.max) | 0;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Reset the number of attempts.
|
|
37
|
+
*
|
|
38
|
+
* @api public
|
|
39
|
+
*/
|
|
40
|
+
Backoff.prototype.reset = function () {
|
|
41
|
+
this.attempts = 0;
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Set the minimum duration
|
|
45
|
+
*
|
|
46
|
+
* @api public
|
|
47
|
+
*/
|
|
48
|
+
Backoff.prototype.setMin = function (min) {
|
|
49
|
+
this.ms = min;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Set the maximum duration
|
|
53
|
+
*
|
|
54
|
+
* @api public
|
|
55
|
+
*/
|
|
56
|
+
Backoff.prototype.setMax = function (max) {
|
|
57
|
+
this.max = max;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Set the jitter
|
|
61
|
+
*
|
|
62
|
+
* @api public
|
|
63
|
+
*/
|
|
64
|
+
Backoff.prototype.setJitter = function (jitter) {
|
|
65
|
+
this.jitter = jitter;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export { Backoff };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { url } from './url.js';
|
|
2
|
+
import { Manager } from './manager.js';
|
|
3
|
+
import { Socket } from './socket.js';
|
|
4
|
+
export { protocol } from '../../../socket.io-parser/build/esm/index.js';
|
|
5
|
+
import '../../../engine.io-client/build/esm/index.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Managers cache.
|
|
9
|
+
*/
|
|
10
|
+
const cache = {};
|
|
11
|
+
function lookup(uri, opts) {
|
|
12
|
+
if (typeof uri === "object") {
|
|
13
|
+
opts = uri;
|
|
14
|
+
uri = undefined;
|
|
15
|
+
}
|
|
16
|
+
opts = opts || {};
|
|
17
|
+
const parsed = url(uri, opts.path || "/socket.io");
|
|
18
|
+
const source = parsed.source;
|
|
19
|
+
const id = parsed.id;
|
|
20
|
+
const path = parsed.path;
|
|
21
|
+
const sameNamespace = cache[id] && path in cache[id]["nsps"];
|
|
22
|
+
const newConnection = opts.forceNew ||
|
|
23
|
+
opts["force new connection"] ||
|
|
24
|
+
false === opts.multiplex ||
|
|
25
|
+
sameNamespace;
|
|
26
|
+
let io;
|
|
27
|
+
if (newConnection) {
|
|
28
|
+
io = new Manager(source, opts);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
if (!cache[id]) {
|
|
32
|
+
cache[id] = new Manager(source, opts);
|
|
33
|
+
}
|
|
34
|
+
io = cache[id];
|
|
35
|
+
}
|
|
36
|
+
if (parsed.query && !opts.query) {
|
|
37
|
+
opts.query = parsed.queryKey;
|
|
38
|
+
}
|
|
39
|
+
return io.socket(parsed.path, opts);
|
|
40
|
+
}
|
|
41
|
+
// so that "lookup" can be used both as a function (e.g. `io(...)`) and as a
|
|
42
|
+
// namespace (e.g. `io.connect(...)`), for backward compatibility
|
|
43
|
+
Object.assign(lookup, {
|
|
44
|
+
Manager,
|
|
45
|
+
Socket,
|
|
46
|
+
io: lookup,
|
|
47
|
+
connect: lookup,
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
export { Manager, Socket, lookup as connect, lookup as default, lookup as io };
|
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
import '../../../engine.io-client/build/esm/index.js';
|
|
2
|
+
import { Socket as Socket$1 } from './socket.js';
|
|
3
|
+
import * as index from '../../../socket.io-parser/build/esm/index.js';
|
|
4
|
+
import { on } from './on.js';
|
|
5
|
+
import { Backoff } from './contrib/backo2.js';
|
|
6
|
+
import { Emitter } from '../../../@socket.io/component-emitter/lib/esm/index.js';
|
|
7
|
+
import { installTimerFunctions } from '../../../engine.io-client/build/esm/util.js';
|
|
8
|
+
import { Socket } from '../../../engine.io-client/build/esm/socket.js';
|
|
9
|
+
import { nextTick } from '../../../engine.io-client/build/esm/globals.node.js';
|
|
10
|
+
|
|
11
|
+
class Manager extends Emitter {
|
|
12
|
+
constructor(uri, opts) {
|
|
13
|
+
var _a;
|
|
14
|
+
super();
|
|
15
|
+
this.nsps = {};
|
|
16
|
+
this.subs = [];
|
|
17
|
+
if (uri && "object" === typeof uri) {
|
|
18
|
+
opts = uri;
|
|
19
|
+
uri = undefined;
|
|
20
|
+
}
|
|
21
|
+
opts = opts || {};
|
|
22
|
+
opts.path = opts.path || "/socket.io";
|
|
23
|
+
this.opts = opts;
|
|
24
|
+
installTimerFunctions(this, opts);
|
|
25
|
+
this.reconnection(opts.reconnection !== false);
|
|
26
|
+
this.reconnectionAttempts(opts.reconnectionAttempts || Infinity);
|
|
27
|
+
this.reconnectionDelay(opts.reconnectionDelay || 1000);
|
|
28
|
+
this.reconnectionDelayMax(opts.reconnectionDelayMax || 5000);
|
|
29
|
+
this.randomizationFactor((_a = opts.randomizationFactor) !== null && _a !== void 0 ? _a : 0.5);
|
|
30
|
+
this.backoff = new Backoff({
|
|
31
|
+
min: this.reconnectionDelay(),
|
|
32
|
+
max: this.reconnectionDelayMax(),
|
|
33
|
+
jitter: this.randomizationFactor(),
|
|
34
|
+
});
|
|
35
|
+
this.timeout(null == opts.timeout ? 20000 : opts.timeout);
|
|
36
|
+
this._readyState = "closed";
|
|
37
|
+
this.uri = uri;
|
|
38
|
+
const _parser = opts.parser || index;
|
|
39
|
+
this.encoder = new _parser.Encoder();
|
|
40
|
+
this.decoder = new _parser.Decoder();
|
|
41
|
+
this._autoConnect = opts.autoConnect !== false;
|
|
42
|
+
if (this._autoConnect)
|
|
43
|
+
this.open();
|
|
44
|
+
}
|
|
45
|
+
reconnection(v) {
|
|
46
|
+
if (!arguments.length)
|
|
47
|
+
return this._reconnection;
|
|
48
|
+
this._reconnection = !!v;
|
|
49
|
+
if (!v) {
|
|
50
|
+
this.skipReconnect = true;
|
|
51
|
+
}
|
|
52
|
+
return this;
|
|
53
|
+
}
|
|
54
|
+
reconnectionAttempts(v) {
|
|
55
|
+
if (v === undefined)
|
|
56
|
+
return this._reconnectionAttempts;
|
|
57
|
+
this._reconnectionAttempts = v;
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
reconnectionDelay(v) {
|
|
61
|
+
var _a;
|
|
62
|
+
if (v === undefined)
|
|
63
|
+
return this._reconnectionDelay;
|
|
64
|
+
this._reconnectionDelay = v;
|
|
65
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMin(v);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
randomizationFactor(v) {
|
|
69
|
+
var _a;
|
|
70
|
+
if (v === undefined)
|
|
71
|
+
return this._randomizationFactor;
|
|
72
|
+
this._randomizationFactor = v;
|
|
73
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setJitter(v);
|
|
74
|
+
return this;
|
|
75
|
+
}
|
|
76
|
+
reconnectionDelayMax(v) {
|
|
77
|
+
var _a;
|
|
78
|
+
if (v === undefined)
|
|
79
|
+
return this._reconnectionDelayMax;
|
|
80
|
+
this._reconnectionDelayMax = v;
|
|
81
|
+
(_a = this.backoff) === null || _a === void 0 ? void 0 : _a.setMax(v);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
84
|
+
timeout(v) {
|
|
85
|
+
if (!arguments.length)
|
|
86
|
+
return this._timeout;
|
|
87
|
+
this._timeout = v;
|
|
88
|
+
return this;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
92
|
+
* started reconnecting yet
|
|
93
|
+
*
|
|
94
|
+
* @private
|
|
95
|
+
*/
|
|
96
|
+
maybeReconnectOnOpen() {
|
|
97
|
+
// Only try to reconnect if it's the first time we're connecting
|
|
98
|
+
if (!this._reconnecting &&
|
|
99
|
+
this._reconnection &&
|
|
100
|
+
this.backoff.attempts === 0) {
|
|
101
|
+
// keeps reconnection from firing twice for the same reconnection loop
|
|
102
|
+
this.reconnect();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Sets the current transport `socket`.
|
|
107
|
+
*
|
|
108
|
+
* @param {Function} fn - optional, callback
|
|
109
|
+
* @return self
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
open(fn) {
|
|
113
|
+
if (~this._readyState.indexOf("open"))
|
|
114
|
+
return this;
|
|
115
|
+
this.engine = new Socket(this.uri, this.opts);
|
|
116
|
+
const socket = this.engine;
|
|
117
|
+
const self = this;
|
|
118
|
+
this._readyState = "opening";
|
|
119
|
+
this.skipReconnect = false;
|
|
120
|
+
// emit `open`
|
|
121
|
+
const openSubDestroy = on(socket, "open", function () {
|
|
122
|
+
self.onopen();
|
|
123
|
+
fn && fn();
|
|
124
|
+
});
|
|
125
|
+
const onError = (err) => {
|
|
126
|
+
this.cleanup();
|
|
127
|
+
this._readyState = "closed";
|
|
128
|
+
this.emitReserved("error", err);
|
|
129
|
+
if (fn) {
|
|
130
|
+
fn(err);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Only do this if there is no fn to handle the error
|
|
134
|
+
this.maybeReconnectOnOpen();
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
// emit `error`
|
|
138
|
+
const errorSub = on(socket, "error", onError);
|
|
139
|
+
if (false !== this._timeout) {
|
|
140
|
+
const timeout = this._timeout;
|
|
141
|
+
// set timer
|
|
142
|
+
const timer = this.setTimeoutFn(() => {
|
|
143
|
+
openSubDestroy();
|
|
144
|
+
onError(new Error("timeout"));
|
|
145
|
+
socket.close();
|
|
146
|
+
}, timeout);
|
|
147
|
+
if (this.opts.autoUnref) {
|
|
148
|
+
timer.unref();
|
|
149
|
+
}
|
|
150
|
+
this.subs.push(() => {
|
|
151
|
+
this.clearTimeoutFn(timer);
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
this.subs.push(openSubDestroy);
|
|
155
|
+
this.subs.push(errorSub);
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Alias for open()
|
|
160
|
+
*
|
|
161
|
+
* @return self
|
|
162
|
+
* @public
|
|
163
|
+
*/
|
|
164
|
+
connect(fn) {
|
|
165
|
+
return this.open(fn);
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Called upon transport open.
|
|
169
|
+
*
|
|
170
|
+
* @private
|
|
171
|
+
*/
|
|
172
|
+
onopen() {
|
|
173
|
+
// clear old subs
|
|
174
|
+
this.cleanup();
|
|
175
|
+
// mark as open
|
|
176
|
+
this._readyState = "open";
|
|
177
|
+
this.emitReserved("open");
|
|
178
|
+
// add new subs
|
|
179
|
+
const socket = this.engine;
|
|
180
|
+
this.subs.push(on(socket, "ping", this.onping.bind(this)), on(socket, "data", this.ondata.bind(this)), on(socket, "error", this.onerror.bind(this)), on(socket, "close", this.onclose.bind(this)),
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
on(this.decoder, "decoded", this.ondecoded.bind(this)));
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Called upon a ping.
|
|
186
|
+
*
|
|
187
|
+
* @private
|
|
188
|
+
*/
|
|
189
|
+
onping() {
|
|
190
|
+
this.emitReserved("ping");
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Called with data.
|
|
194
|
+
*
|
|
195
|
+
* @private
|
|
196
|
+
*/
|
|
197
|
+
ondata(data) {
|
|
198
|
+
try {
|
|
199
|
+
this.decoder.add(data);
|
|
200
|
+
}
|
|
201
|
+
catch (e) {
|
|
202
|
+
this.onclose("parse error", e);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Called when parser fully decodes a packet.
|
|
207
|
+
*
|
|
208
|
+
* @private
|
|
209
|
+
*/
|
|
210
|
+
ondecoded(packet) {
|
|
211
|
+
// the nextTick call prevents an exception in a user-provided event listener from triggering a disconnection due to a "parse error"
|
|
212
|
+
nextTick(() => {
|
|
213
|
+
this.emitReserved("packet", packet);
|
|
214
|
+
}, this.setTimeoutFn);
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Called upon socket error.
|
|
218
|
+
*
|
|
219
|
+
* @private
|
|
220
|
+
*/
|
|
221
|
+
onerror(err) {
|
|
222
|
+
this.emitReserved("error", err);
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Creates a new socket for the given `nsp`.
|
|
226
|
+
*
|
|
227
|
+
* @return {Socket}
|
|
228
|
+
* @public
|
|
229
|
+
*/
|
|
230
|
+
socket(nsp, opts) {
|
|
231
|
+
let socket = this.nsps[nsp];
|
|
232
|
+
if (!socket) {
|
|
233
|
+
socket = new Socket$1(this, nsp, opts);
|
|
234
|
+
this.nsps[nsp] = socket;
|
|
235
|
+
}
|
|
236
|
+
else if (this._autoConnect && !socket.active) {
|
|
237
|
+
socket.connect();
|
|
238
|
+
}
|
|
239
|
+
return socket;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Called upon a socket close.
|
|
243
|
+
*
|
|
244
|
+
* @param socket
|
|
245
|
+
* @private
|
|
246
|
+
*/
|
|
247
|
+
_destroy(socket) {
|
|
248
|
+
const nsps = Object.keys(this.nsps);
|
|
249
|
+
for (const nsp of nsps) {
|
|
250
|
+
const socket = this.nsps[nsp];
|
|
251
|
+
if (socket.active) {
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
this._close();
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Writes a packet.
|
|
259
|
+
*
|
|
260
|
+
* @param packet
|
|
261
|
+
* @private
|
|
262
|
+
*/
|
|
263
|
+
_packet(packet) {
|
|
264
|
+
const encodedPackets = this.encoder.encode(packet);
|
|
265
|
+
for (let i = 0; i < encodedPackets.length; i++) {
|
|
266
|
+
this.engine.write(encodedPackets[i], packet.options);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Clean up transport subscriptions and packet buffer.
|
|
271
|
+
*
|
|
272
|
+
* @private
|
|
273
|
+
*/
|
|
274
|
+
cleanup() {
|
|
275
|
+
this.subs.forEach((subDestroy) => subDestroy());
|
|
276
|
+
this.subs.length = 0;
|
|
277
|
+
this.decoder.destroy();
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Close the current socket.
|
|
281
|
+
*
|
|
282
|
+
* @private
|
|
283
|
+
*/
|
|
284
|
+
_close() {
|
|
285
|
+
this.skipReconnect = true;
|
|
286
|
+
this._reconnecting = false;
|
|
287
|
+
this.onclose("forced close");
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Alias for close()
|
|
291
|
+
*
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
disconnect() {
|
|
295
|
+
return this._close();
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Called when:
|
|
299
|
+
*
|
|
300
|
+
* - the low-level engine is closed
|
|
301
|
+
* - the parser encountered a badly formatted packet
|
|
302
|
+
* - all sockets are disconnected
|
|
303
|
+
*
|
|
304
|
+
* @private
|
|
305
|
+
*/
|
|
306
|
+
onclose(reason, description) {
|
|
307
|
+
var _a;
|
|
308
|
+
this.cleanup();
|
|
309
|
+
(_a = this.engine) === null || _a === void 0 ? void 0 : _a.close();
|
|
310
|
+
this.backoff.reset();
|
|
311
|
+
this._readyState = "closed";
|
|
312
|
+
this.emitReserved("close", reason, description);
|
|
313
|
+
if (this._reconnection && !this.skipReconnect) {
|
|
314
|
+
this.reconnect();
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Attempt a reconnection.
|
|
319
|
+
*
|
|
320
|
+
* @private
|
|
321
|
+
*/
|
|
322
|
+
reconnect() {
|
|
323
|
+
if (this._reconnecting || this.skipReconnect)
|
|
324
|
+
return this;
|
|
325
|
+
const self = this;
|
|
326
|
+
if (this.backoff.attempts >= this._reconnectionAttempts) {
|
|
327
|
+
this.backoff.reset();
|
|
328
|
+
this.emitReserved("reconnect_failed");
|
|
329
|
+
this._reconnecting = false;
|
|
330
|
+
}
|
|
331
|
+
else {
|
|
332
|
+
const delay = this.backoff.duration();
|
|
333
|
+
this._reconnecting = true;
|
|
334
|
+
const timer = this.setTimeoutFn(() => {
|
|
335
|
+
if (self.skipReconnect)
|
|
336
|
+
return;
|
|
337
|
+
this.emitReserved("reconnect_attempt", self.backoff.attempts);
|
|
338
|
+
// check again for the case socket closed in above events
|
|
339
|
+
if (self.skipReconnect)
|
|
340
|
+
return;
|
|
341
|
+
self.open((err) => {
|
|
342
|
+
if (err) {
|
|
343
|
+
self._reconnecting = false;
|
|
344
|
+
self.reconnect();
|
|
345
|
+
this.emitReserved("reconnect_error", err);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
self.onreconnect();
|
|
349
|
+
}
|
|
350
|
+
});
|
|
351
|
+
}, delay);
|
|
352
|
+
if (this.opts.autoUnref) {
|
|
353
|
+
timer.unref();
|
|
354
|
+
}
|
|
355
|
+
this.subs.push(() => {
|
|
356
|
+
this.clearTimeoutFn(timer);
|
|
357
|
+
});
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Called upon successful reconnect.
|
|
362
|
+
*
|
|
363
|
+
* @private
|
|
364
|
+
*/
|
|
365
|
+
onreconnect() {
|
|
366
|
+
const attempt = this.backoff.attempts;
|
|
367
|
+
this._reconnecting = false;
|
|
368
|
+
this.backoff.reset();
|
|
369
|
+
this.emitReserved("reconnect", attempt);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
export { Manager };
|