lightclawbot 1.1.2-beta.0 → 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.
- package/README.md +0 -1
- package/dist/index.js +38 -31
- package/dist/setup-entry.js +32 -0
- package/dist/src/channel.js +301 -257
- package/dist/src/channel.setup.js +16 -0
- package/dist/src/config.js +31 -124
- package/dist/src/dedup.js +0 -1
- package/dist/src/download-tool.js +0 -1
- package/dist/src/file-storage.js +2 -2
- package/dist/src/gateway.js +226 -178
- package/dist/src/history/cron-utils.js +0 -1
- package/dist/src/history/index.js +0 -1
- package/dist/src/history/message-parser.js +0 -1
- package/dist/src/history/session-reader.js +3 -1
- package/dist/src/history/session-store.js +0 -1
- package/dist/src/history/text-processing.js +0 -1
- package/dist/src/history/types.js +0 -1
- package/dist/src/inbound.js +183 -234
- package/dist/src/media.js +0 -1
- package/dist/src/messaging.js +65 -0
- package/dist/src/outbound.js +131 -45
- package/dist/src/runtime.js +29 -11
- package/dist/src/setup-core.js +27 -0
- package/dist/src/shared.js +141 -0
- package/dist/src/socket/handlers.js +72 -49
- package/dist/src/socket/index.js +0 -1
- package/dist/src/socket/native-socket.js +385 -0
- package/dist/src/socket/registry.js +0 -1
- package/dist/src/socket/reliable-emitter.js +188 -50
- package/dist/src/streaming/delta-tracker.js +140 -0
- package/dist/src/streaming/index.js +12 -0
- package/dist/src/streaming/stream-reply-sink.js +387 -0
- package/dist/src/streaming/types.js +4 -0
- package/dist/src/tools.js +13 -0
- package/dist/src/types.js +23 -2
- package/dist/src/upload-tool.js +0 -1
- package/dist/src/utils/account.js +73 -0
- package/dist/src/utils/common.js +48 -0
- package/dist/src/utils/index.js +2 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/constants.js +1 -0
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/permessage-deflate.js +6 -6
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket-server.js +10 -6
- package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/websocket.js +19 -14
- package/node_modules/{engine.io-client/node_modules/ws → ws}/package.json +4 -3
- package/node_modules/ws/wrapper.mjs +21 -0
- package/openclaw.plugin.json +0 -7
- package/package.json +8 -5
- package/dist/index.d.ts +0 -24
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/public/data/scripts/manifest.json +0 -11
- package/dist/public/data/scripts/upgrade.156d7999.sh +0 -384
- package/dist/public/data/scripts/upgrade.sh +0 -384
- package/dist/src/channel.d.ts +0 -11
- package/dist/src/channel.d.ts.map +0 -1
- package/dist/src/channel.js.map +0 -1
- package/dist/src/config.d.ts +0 -129
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/config.js.map +0 -1
- package/dist/src/dedup.d.ts +0 -12
- package/dist/src/dedup.d.ts.map +0 -1
- package/dist/src/dedup.js.map +0 -1
- package/dist/src/download-tool.d.ts +0 -32
- package/dist/src/download-tool.d.ts.map +0 -1
- package/dist/src/download-tool.js.map +0 -1
- package/dist/src/file-storage.d.ts +0 -74
- package/dist/src/file-storage.d.ts.map +0 -1
- package/dist/src/file-storage.js.map +0 -1
- package/dist/src/format-urls.d.ts +0 -26
- package/dist/src/format-urls.d.ts.map +0 -1
- package/dist/src/format-urls.js +0 -53
- package/dist/src/format-urls.js.map +0 -1
- package/dist/src/gateway.d.ts +0 -16
- package/dist/src/gateway.d.ts.map +0 -1
- package/dist/src/gateway.js.map +0 -1
- package/dist/src/history/cron-utils.d.ts +0 -76
- package/dist/src/history/cron-utils.d.ts.map +0 -1
- package/dist/src/history/cron-utils.js.map +0 -1
- package/dist/src/history/index.d.ts +0 -20
- package/dist/src/history/index.d.ts.map +0 -1
- package/dist/src/history/index.js.map +0 -1
- package/dist/src/history/message-parser.d.ts +0 -52
- package/dist/src/history/message-parser.d.ts.map +0 -1
- package/dist/src/history/message-parser.js.map +0 -1
- package/dist/src/history/session-reader.d.ts +0 -58
- package/dist/src/history/session-reader.d.ts.map +0 -1
- package/dist/src/history/session-reader.js.map +0 -1
- package/dist/src/history/session-store.d.ts +0 -42
- package/dist/src/history/session-store.d.ts.map +0 -1
- package/dist/src/history/session-store.js.map +0 -1
- package/dist/src/history/text-processing.d.ts +0 -41
- package/dist/src/history/text-processing.d.ts.map +0 -1
- package/dist/src/history/text-processing.js.map +0 -1
- package/dist/src/history/types.d.ts +0 -134
- package/dist/src/history/types.d.ts.map +0 -1
- package/dist/src/history/types.js.map +0 -1
- package/dist/src/inbound.d.ts +0 -18
- package/dist/src/inbound.d.ts.map +0 -1
- package/dist/src/inbound.js.map +0 -1
- package/dist/src/media.d.ts +0 -12
- package/dist/src/media.d.ts.map +0 -1
- package/dist/src/media.js.map +0 -1
- package/dist/src/outbound.d.ts +0 -28
- package/dist/src/outbound.d.ts.map +0 -1
- package/dist/src/outbound.js.map +0 -1
- package/dist/src/runtime.d.ts +0 -4
- package/dist/src/runtime.d.ts.map +0 -1
- package/dist/src/runtime.js.map +0 -1
- package/dist/src/socket/handlers.d.ts +0 -26
- package/dist/src/socket/handlers.d.ts.map +0 -1
- package/dist/src/socket/handlers.js.map +0 -1
- package/dist/src/socket/index.d.ts +0 -11
- package/dist/src/socket/index.d.ts.map +0 -1
- package/dist/src/socket/index.js.map +0 -1
- package/dist/src/socket/registry.d.ts +0 -59
- package/dist/src/socket/registry.d.ts.map +0 -1
- package/dist/src/socket/registry.js.map +0 -1
- package/dist/src/socket/reliable-emitter.d.ts +0 -79
- package/dist/src/socket/reliable-emitter.d.ts.map +0 -1
- package/dist/src/socket/reliable-emitter.js.map +0 -1
- package/dist/src/types.d.ts +0 -112
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
- package/dist/src/upload-tool.d.ts +0 -27
- package/dist/src/upload-tool.d.ts.map +0 -1
- package/dist/src/upload-tool.js.map +0 -1
- package/node_modules/@socket.io/component-emitter/LICENSE +0 -24
- package/node_modules/@socket.io/component-emitter/Readme.md +0 -79
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.d.ts +0 -179
- package/node_modules/@socket.io/component-emitter/lib/cjs/index.js +0 -176
- package/node_modules/@socket.io/component-emitter/lib/cjs/package.json +0 -4
- package/node_modules/@socket.io/component-emitter/lib/esm/index.d.ts +0 -179
- package/node_modules/@socket.io/component-emitter/lib/esm/index.js +0 -169
- package/node_modules/@socket.io/component-emitter/lib/esm/package.json +0 -4
- package/node_modules/@socket.io/component-emitter/package.json +0 -28
- package/node_modules/debug/LICENSE +0 -20
- package/node_modules/debug/README.md +0 -481
- package/node_modules/debug/package.json +0 -64
- package/node_modules/debug/src/browser.js +0 -272
- package/node_modules/debug/src/common.js +0 -292
- package/node_modules/debug/src/index.js +0 -10
- package/node_modules/debug/src/node.js +0 -263
- package/node_modules/engine.io-client/LICENSE +0 -22
- package/node_modules/engine.io-client/README.md +0 -331
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/cjs/browser-entrypoint.js +0 -4
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/cjs/contrib/has-cors.js +0 -14
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/contrib/parseqs.js +0 -38
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/cjs/contrib/parseuri.js +0 -67
- package/node_modules/engine.io-client/build/cjs/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/cjs/globals.js +0 -26
- package/node_modules/engine.io-client/build/cjs/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/cjs/globals.node.js +0 -97
- package/node_modules/engine.io-client/build/cjs/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/index.js +0 -32
- package/node_modules/engine.io-client/build/cjs/package.json +0 -10
- package/node_modules/engine.io-client/build/cjs/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/cjs/socket.js +0 -765
- package/node_modules/engine.io-client/build/cjs/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/cjs/transport.js +0 -153
- package/node_modules/engine.io-client/build/cjs/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/cjs/transports/index.js +0 -11
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/cjs/transports/polling-fetch.js +0 -60
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.js +0 -285
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/cjs/transports/polling-xhr.node.js +0 -44
- package/node_modules/engine.io-client/build/cjs/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/cjs/transports/polling.js +0 -165
- package/node_modules/engine.io-client/build/cjs/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/cjs/transports/websocket.js +0 -136
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/cjs/transports/websocket.node.js +0 -68
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/cjs/transports/webtransport.js +0 -94
- package/node_modules/engine.io-client/build/cjs/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/cjs/util.js +0 -65
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/esm/browser-entrypoint.js +0 -2
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm/contrib/has-cors.js +0 -11
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/contrib/parseqs.js +0 -34
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm/contrib/parseuri.js +0 -64
- package/node_modules/engine.io-client/build/esm/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/esm/globals.js +0 -22
- package/node_modules/engine.io-client/build/esm/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/esm/globals.node.js +0 -91
- package/node_modules/engine.io-client/build/esm/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/index.js +0 -15
- package/node_modules/engine.io-client/build/esm/package.json +0 -10
- package/node_modules/engine.io-client/build/esm/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/esm/socket.js +0 -727
- package/node_modules/engine.io-client/build/esm/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/esm/transport.js +0 -142
- package/node_modules/engine.io-client/build/esm/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/esm/transports/index.js +0 -8
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm/transports/polling-fetch.js +0 -56
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.js +0 -271
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/esm/transports/polling-xhr.node.js +0 -17
- package/node_modules/engine.io-client/build/esm/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/esm/transports/polling.js +0 -145
- package/node_modules/engine.io-client/build/esm/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/esm/transports/websocket.js +0 -125
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/esm/transports/websocket.node.js +0 -41
- package/node_modules/engine.io-client/build/esm/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/esm/transports/webtransport.js +0 -80
- package/node_modules/engine.io-client/build/esm/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/esm/util.js +0 -59
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -3
- package/node_modules/engine.io-client/build/esm-debug/browser-entrypoint.js +0 -2
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm-debug/contrib/has-cors.js +0 -11
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseqs.js +0 -34
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.d.ts +0 -1
- package/node_modules/engine.io-client/build/esm-debug/contrib/parseuri.js +0 -64
- package/node_modules/engine.io-client/build/esm-debug/globals.d.ts +0 -4
- package/node_modules/engine.io-client/build/esm-debug/globals.js +0 -22
- package/node_modules/engine.io-client/build/esm-debug/globals.node.d.ts +0 -21
- package/node_modules/engine.io-client/build/esm-debug/globals.node.js +0 -91
- package/node_modules/engine.io-client/build/esm-debug/index.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/index.js +0 -15
- package/node_modules/engine.io-client/build/esm-debug/package.json +0 -10
- package/node_modules/engine.io-client/build/esm-debug/socket.d.ts +0 -482
- package/node_modules/engine.io-client/build/esm-debug/socket.js +0 -756
- package/node_modules/engine.io-client/build/esm-debug/transport.d.ts +0 -106
- package/node_modules/engine.io-client/build/esm-debug/transport.js +0 -145
- package/node_modules/engine.io-client/build/esm-debug/transports/index.d.ts +0 -8
- package/node_modules/engine.io-client/build/esm-debug/transports/index.js +0 -8
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.d.ts +0 -15
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-fetch.js +0 -56
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.d.ts +0 -108
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.js +0 -276
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.d.ts +0 -11
- package/node_modules/engine.io-client/build/esm-debug/transports/polling-xhr.node.js +0 -17
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.d.ts +0 -52
- package/node_modules/engine.io-client/build/esm-debug/transports/polling.js +0 -158
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.d.ts +0 -36
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.js +0 -128
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.d.ts +0 -14
- package/node_modules/engine.io-client/build/esm-debug/transports/websocket.node.js +0 -41
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.d.ts +0 -18
- package/node_modules/engine.io-client/build/esm-debug/transports/webtransport.js +0 -87
- package/node_modules/engine.io-client/build/esm-debug/util.d.ts +0 -7
- package/node_modules/engine.io-client/build/esm-debug/util.js +0 -59
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js +0 -7
- package/node_modules/engine.io-client/dist/engine.io.esm.min.js.map +0 -1
- package/node_modules/engine.io-client/dist/engine.io.js +0 -3064
- package/node_modules/engine.io-client/dist/engine.io.js.map +0 -1
- package/node_modules/engine.io-client/dist/engine.io.min.js +0 -7
- package/node_modules/engine.io-client/dist/engine.io.min.js.map +0 -1
- package/node_modules/engine.io-client/node_modules/ws/index.js +0 -13
- package/node_modules/engine.io-client/node_modules/ws/wrapper.mjs +0 -8
- package/node_modules/engine.io-client/package.json +0 -95
- package/node_modules/engine.io-parser/LICENSE +0 -22
- package/node_modules/engine.io-parser/Readme.md +0 -158
- package/node_modules/engine.io-parser/build/cjs/commons.d.ts +0 -14
- package/node_modules/engine.io-parser/build/cjs/commons.js +0 -19
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/contrib/base64-arraybuffer.js +0 -48
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/decodePacket.browser.js +0 -66
- package/node_modules/engine.io-parser/build/cjs/decodePacket.d.ts +0 -2
- package/node_modules/engine.io-parser/build/cjs/decodePacket.js +0 -59
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.d.ts +0 -4
- package/node_modules/engine.io-parser/build/cjs/encodePacket.browser.js +0 -72
- package/node_modules/engine.io-parser/build/cjs/encodePacket.d.ts +0 -3
- package/node_modules/engine.io-parser/build/cjs/encodePacket.js +0 -38
- package/node_modules/engine.io-parser/build/cjs/index.d.ts +0 -9
- package/node_modules/engine.io-parser/build/cjs/index.js +0 -164
- package/node_modules/engine.io-parser/build/cjs/package.json +0 -8
- package/node_modules/engine.io-parser/build/esm/commons.d.ts +0 -14
- package/node_modules/engine.io-parser/build/esm/commons.js +0 -14
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.js +0 -43
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/decodePacket.browser.js +0 -62
- package/node_modules/engine.io-parser/build/esm/decodePacket.d.ts +0 -2
- package/node_modules/engine.io-parser/build/esm/decodePacket.js +0 -55
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.d.ts +0 -4
- package/node_modules/engine.io-parser/build/esm/encodePacket.browser.js +0 -68
- package/node_modules/engine.io-parser/build/esm/encodePacket.d.ts +0 -3
- package/node_modules/engine.io-parser/build/esm/encodePacket.js +0 -33
- package/node_modules/engine.io-parser/build/esm/index.d.ts +0 -9
- package/node_modules/engine.io-parser/build/esm/index.js +0 -156
- package/node_modules/engine.io-parser/build/esm/package.json +0 -8
- package/node_modules/engine.io-parser/package.json +0 -46
- package/node_modules/ms/index.js +0 -162
- package/node_modules/ms/license.md +0 -21
- package/node_modules/ms/package.json +0 -38
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/socket.io-client/LICENSE +0 -21
- package/node_modules/socket.io-client/README.md +0 -29
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/cjs/browser-entrypoint.js +0 -4
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/cjs/contrib/backo2.js +0 -69
- package/node_modules/socket.io-client/build/cjs/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/cjs/index.js +0 -76
- package/node_modules/socket.io-client/build/cjs/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/cjs/manager.js +0 -416
- package/node_modules/socket.io-client/build/cjs/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/cjs/on.js +0 -9
- package/node_modules/socket.io-client/build/cjs/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/cjs/socket.js +0 -909
- package/node_modules/socket.io-client/build/cjs/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/cjs/url.js +0 -69
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm/browser-entrypoint.js +0 -2
- package/node_modules/socket.io-client/build/esm/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/esm/contrib/backo2.js +0 -66
- package/node_modules/socket.io-client/build/esm/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/esm/index.js +0 -58
- package/node_modules/socket.io-client/build/esm/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/esm/manager.js +0 -367
- package/node_modules/socket.io-client/build/esm/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm/on.js +0 -6
- package/node_modules/socket.io-client/build/esm/package.json +0 -5
- package/node_modules/socket.io-client/build/esm/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/esm/socket.js +0 -880
- package/node_modules/socket.io-client/build/esm/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/esm/url.js +0 -59
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm-debug/browser-entrypoint.js +0 -2
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.d.ts +0 -12
- package/node_modules/socket.io-client/build/esm-debug/contrib/backo2.js +0 -66
- package/node_modules/socket.io-client/build/esm-debug/index.d.ts +0 -29
- package/node_modules/socket.io-client/build/esm-debug/index.js +0 -62
- package/node_modules/socket.io-client/build/esm-debug/manager.d.ts +0 -295
- package/node_modules/socket.io-client/build/esm-debug/manager.js +0 -386
- package/node_modules/socket.io-client/build/esm-debug/on.d.ts +0 -2
- package/node_modules/socket.io-client/build/esm-debug/on.js +0 -6
- package/node_modules/socket.io-client/build/esm-debug/package.json +0 -5
- package/node_modules/socket.io-client/build/esm-debug/socket.d.ts +0 -593
- package/node_modules/socket.io-client/build/esm-debug/socket.js +0 -902
- package/node_modules/socket.io-client/build/esm-debug/url.d.ts +0 -33
- package/node_modules/socket.io-client/build/esm-debug/url.js +0 -63
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.esm.min.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.js +0 -4955
- package/node_modules/socket.io-client/dist/socket.io.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.min.js.map +0 -1
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js +0 -7
- package/node_modules/socket.io-client/dist/socket.io.msgpack.min.js.map +0 -1
- package/node_modules/socket.io-client/package.json +0 -101
- package/node_modules/socket.io-parser/LICENSE +0 -20
- package/node_modules/socket.io-parser/Readme.md +0 -81
- package/node_modules/socket.io-parser/build/cjs/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/cjs/binary.js +0 -87
- package/node_modules/socket.io-parser/build/cjs/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/cjs/index.js +0 -367
- package/node_modules/socket.io-parser/build/cjs/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/cjs/is-binary.js +0 -54
- package/node_modules/socket.io-parser/build/cjs/package.json +0 -3
- package/node_modules/socket.io-parser/build/esm/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/esm/binary.js +0 -83
- package/node_modules/socket.io-parser/build/esm/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/esm/index.js +0 -356
- package/node_modules/socket.io-parser/build/esm/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/esm/is-binary.js +0 -50
- package/node_modules/socket.io-parser/build/esm/package.json +0 -3
- package/node_modules/socket.io-parser/build/esm-debug/binary.d.ts +0 -20
- package/node_modules/socket.io-parser/build/esm-debug/binary.js +0 -83
- package/node_modules/socket.io-parser/build/esm-debug/index.d.ts +0 -101
- package/node_modules/socket.io-parser/build/esm-debug/index.js +0 -361
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.d.ts +0 -7
- package/node_modules/socket.io-parser/build/esm-debug/is-binary.js +0 -50
- package/node_modules/socket.io-parser/build/esm-debug/package.json +0 -3
- package/node_modules/socket.io-parser/package.json +0 -44
- package/node_modules/xmlhttprequest-ssl/LICENSE +0 -22
- package/node_modules/xmlhttprequest-ssl/README.md +0 -67
- package/node_modules/xmlhttprequest-ssl/lib/XMLHttpRequest.js +0 -689
- package/node_modules/xmlhttprequest-ssl/package.json +0 -40
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/LICENSE +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/README.md +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/browser.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/buffer-util.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/event-target.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/extension.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/limiter.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/receiver.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/sender.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/stream.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/subprotocol.js +0 -0
- /package/node_modules/{engine.io-client/node_modules/ws → ws}/lib/validation.js +0 -0
package/dist/src/types.d.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LightClaw OpenClaw Channel Plugin — 类型定义
|
|
3
|
-
*
|
|
4
|
-
* 用户实际消息格式:
|
|
5
|
-
* { msgId, from, to, content, files, timestamp }
|
|
6
|
-
*
|
|
7
|
-
* files 格式为 FileAttachment[],每个文件包含 name, mimeType, bytes(data URL)。
|
|
8
|
-
*/
|
|
9
|
-
/** 用户上传的文件(files[] 数组中的元素) */
|
|
10
|
-
export interface FileAttachment {
|
|
11
|
-
/** 文件名 */
|
|
12
|
-
name: string;
|
|
13
|
-
/** MIME 类型 */
|
|
14
|
-
mimeType: string;
|
|
15
|
-
/** base64 data URL(如 "data:text/plain;base64,...") */
|
|
16
|
-
bytes?: string;
|
|
17
|
-
/** 远程文件 URI(如云端下载地址),与 bytes 二选一 */
|
|
18
|
-
uri?: string;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* message:private 事件的 data 结构
|
|
22
|
-
*
|
|
23
|
-
* 入站(用户 → 插件):{ msgId, from, to, content, files, timestamp }
|
|
24
|
-
* 出站(插件 → 用户):同结构,可附带 kind 用于流式/typing 控制
|
|
25
|
-
*/
|
|
26
|
-
export interface PrivateMessageData {
|
|
27
|
-
/** 消息唯一 ID */
|
|
28
|
-
msgId: string;
|
|
29
|
-
/** 发送者 ID */
|
|
30
|
-
from: string;
|
|
31
|
-
/** 接收者 ID */
|
|
32
|
-
to: string;
|
|
33
|
-
/** 消息文本内容(仅发送文件时可为空字符串) */
|
|
34
|
-
content: string;
|
|
35
|
-
/** 消息时间戳(ms) */
|
|
36
|
-
timestamp: number;
|
|
37
|
-
/** 文件列表({name, mimeType, bytes} 格式,bytes 为 data URL) */
|
|
38
|
-
files?: FileAttachment[];
|
|
39
|
-
/** 消息子类型:流式/typing 控制(出站使用) */
|
|
40
|
-
kind?: "text" | "stream_chunk" | "stream_end" | "typing_start" | "typing_stop";
|
|
41
|
-
/** 回复对应的原始消息 ID */
|
|
42
|
-
replyToMsgId?: string;
|
|
43
|
-
/**
|
|
44
|
-
* 幂等键:标识每次独立的 emit 调用,前端据此去重。
|
|
45
|
-
* 由 ReliableEmitter 在发送时自动注入,重试/重发时保持不变。
|
|
46
|
-
*/
|
|
47
|
-
idempotencyKey?: string;
|
|
48
|
-
}
|
|
49
|
-
/** 原始配置(config.yaml 中的内容) */
|
|
50
|
-
export interface AssistantAccountConfig {
|
|
51
|
-
/** @deprecated 不再使用,配置中只有 apiKeys */
|
|
52
|
-
apiKey?: string;
|
|
53
|
-
/** API Keys 列表(第一个作为主 key,用于获取 botId 等) */
|
|
54
|
-
apiKeys?: string[];
|
|
55
|
-
/** REST API 基础地址(用于 outbound 主动发送) */
|
|
56
|
-
apiBaseUrl?: string;
|
|
57
|
-
/** 是否启用 */
|
|
58
|
-
enabled?: boolean;
|
|
59
|
-
/** 账户名称 */
|
|
60
|
-
name?: string;
|
|
61
|
-
/** DM 策略 */
|
|
62
|
-
dmPolicy?: "open" | "allowlist" | "disabled";
|
|
63
|
-
/** 允许的用户 ID 列表(* 表示所有人) */
|
|
64
|
-
allowFrom?: string[];
|
|
65
|
-
/** 自定义系统提示词 */
|
|
66
|
-
systemPrompt?: string;
|
|
67
|
-
}
|
|
68
|
-
/** 解析后的完整账户(含默认值和环境变量 fallback) */
|
|
69
|
-
export interface ResolvedAssistantAccount {
|
|
70
|
-
accountId: string;
|
|
71
|
-
/** 主 apiKey(获取 botId、默认文件操作等) */
|
|
72
|
-
apiKey: string;
|
|
73
|
-
/** 所有 apiKey(含主 key),用于 WS 多 key 认证 */
|
|
74
|
-
allApiKeys: string[];
|
|
75
|
-
apiBaseUrl: string;
|
|
76
|
-
enabled: boolean;
|
|
77
|
-
name?: string;
|
|
78
|
-
dmPolicy: "open" | "allowlist" | "disabled";
|
|
79
|
-
allowFrom: string[];
|
|
80
|
-
systemPrompt?: string;
|
|
81
|
-
secretSource: "config" | "env" | "none";
|
|
82
|
-
}
|
|
83
|
-
export interface GatewayContext {
|
|
84
|
-
account: ResolvedAssistantAccount;
|
|
85
|
-
abortSignal: AbortSignal;
|
|
86
|
-
cfg: unknown;
|
|
87
|
-
onReady?: () => void;
|
|
88
|
-
onDisconnect?: () => void;
|
|
89
|
-
onError?: (error: Error) => void;
|
|
90
|
-
/** 收到任何入站事件时调用,用于通知框架更新 lastEventAt,防止 health-monitor 误判 stale-socket */
|
|
91
|
-
onEvent?: () => void;
|
|
92
|
-
log?: {
|
|
93
|
-
info: (msg: string) => void;
|
|
94
|
-
warn: (msg: string) => void;
|
|
95
|
-
error: (msg: string) => void;
|
|
96
|
-
debug?: (msg: string) => void;
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
/** 消息队列项 — 直接使用用户的 files[] 格式 */
|
|
100
|
-
export interface QueuedMessage {
|
|
101
|
-
/** 发送者 ID */
|
|
102
|
-
senderId: string;
|
|
103
|
-
/** 消息文本 */
|
|
104
|
-
text: string;
|
|
105
|
-
/** 消息 ID */
|
|
106
|
-
messageId: string;
|
|
107
|
-
/** 文件附件({name, mimeType, bytes} 格式) */
|
|
108
|
-
files: FileAttachment[];
|
|
109
|
-
/** 时间戳 */
|
|
110
|
-
timestamp: number;
|
|
111
|
-
}
|
|
112
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/src/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,8BAA8B;AAC9B,MAAM,WAAW,cAAc;IAC7B,UAAU;IACV,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;I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../../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* LightClaw — 文件上传工具
|
|
3
|
-
*
|
|
4
|
-
* 注册为 OpenClaw Agent Tool,允许 AI 将本地文件上传到云端存储,
|
|
5
|
-
* 获得公网可访问的 URL,方便用户直接下载。
|
|
6
|
-
*
|
|
7
|
-
* 工具名: lightclaw_upload_file
|
|
8
|
-
*/
|
|
9
|
-
import type { OpenClawPluginApi } from "openclaw/plugin-sdk/core";
|
|
10
|
-
export declare const UPLOAD_TOOL_NAME = "lightclaw_upload_file";
|
|
11
|
-
export declare const uploadToolSchema: {
|
|
12
|
-
type: "object";
|
|
13
|
-
properties: {
|
|
14
|
-
paths: {
|
|
15
|
-
type: "array";
|
|
16
|
-
items: {
|
|
17
|
-
type: "string";
|
|
18
|
-
};
|
|
19
|
-
minItems: number;
|
|
20
|
-
maxItems: number;
|
|
21
|
-
description: string;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
required: readonly ["paths"];
|
|
25
|
-
};
|
|
26
|
-
export declare function registerUploadTool(api: OpenClawPluginApi): void;
|
|
27
|
-
//# sourceMappingURL=upload-tool.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-tool.d.ts","sourceRoot":"","sources":["../../src/upload-tool.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,iBAAiB,EAAgB,MAAM,0BAA0B,CAAC;AAShF,eAAO,MAAM,gBAAgB,0BAA0B,CAAC;AAExD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;CAY5B,CAAC;AAMF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,iBAAiB,GAAG,IAAI,CA4I/D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"upload-tool.js","sourceRoot":"","sources":["../../src/upload-tool.ts"],"names":[],"mappings":"AAA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AAC,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG;wBACxF,CAAC,CAAC,uBAAuB,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE;oBAC7C,CAAC,CAAC,YAAY,cAAc,CAAC,MAAM,IAAI,OAAO,CAAC,MAAM,YAAY,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;gBAExF,OAAO;oBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oBAC1C,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE;iBAC9B,CAAC;YACJ,CAAC;SACyB,CAAC;IAC/B,CAAC,EACD,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAC3B,CAAC;AACJ,CAAC"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
(The MIT License)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2014 Component contributors <dev@component.io>
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person
|
|
6
|
-
obtaining a copy of this software and associated documentation
|
|
7
|
-
files (the "Software"), to deal in the Software without
|
|
8
|
-
restriction, including without limitation the rights to use,
|
|
9
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
copies of the Software, and to permit persons to whom the
|
|
11
|
-
Software is furnished to do so, subject to the following
|
|
12
|
-
conditions:
|
|
13
|
-
|
|
14
|
-
The above copyright notice and this permission notice shall be
|
|
15
|
-
included in all copies or substantial portions of the Software.
|
|
16
|
-
|
|
17
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
18
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
19
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
20
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
21
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
22
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
23
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
24
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
# `@socket.io/component-emitter`
|
|
2
|
-
|
|
3
|
-
Event emitter component.
|
|
4
|
-
|
|
5
|
-
This project is a fork of the [`component-emitter`](https://github.com/sindresorhus/component-emitter) project, with [Socket.IO](https://socket.io/)-specific TypeScript typings.
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
```
|
|
10
|
-
$ npm i @socket.io/component-emitter
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
## API
|
|
14
|
-
|
|
15
|
-
### Emitter(obj)
|
|
16
|
-
|
|
17
|
-
The `Emitter` may also be used as a mixin. For example
|
|
18
|
-
a "plain" object may become an emitter, or you may
|
|
19
|
-
extend an existing prototype.
|
|
20
|
-
|
|
21
|
-
As an `Emitter` instance:
|
|
22
|
-
|
|
23
|
-
```js
|
|
24
|
-
import { Emitter } from '@socket.io/component-emitter';
|
|
25
|
-
|
|
26
|
-
var emitter = new Emitter;
|
|
27
|
-
emitter.emit('something');
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
As a mixin:
|
|
31
|
-
|
|
32
|
-
```js
|
|
33
|
-
import { Emitter } from '@socket.io/component-emitter';
|
|
34
|
-
|
|
35
|
-
var user = { name: 'tobi' };
|
|
36
|
-
Emitter(user);
|
|
37
|
-
|
|
38
|
-
user.emit('im a user');
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
As a prototype mixin:
|
|
42
|
-
|
|
43
|
-
```js
|
|
44
|
-
import { Emitter } from '@socket.io/component-emitter';
|
|
45
|
-
|
|
46
|
-
Emitter(User.prototype);
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
### Emitter#on(event, fn)
|
|
50
|
-
|
|
51
|
-
Register an `event` handler `fn`.
|
|
52
|
-
|
|
53
|
-
### Emitter#once(event, fn)
|
|
54
|
-
|
|
55
|
-
Register a single-shot `event` handler `fn`,
|
|
56
|
-
removed immediately after it is invoked the
|
|
57
|
-
first time.
|
|
58
|
-
|
|
59
|
-
### Emitter#off(event, fn)
|
|
60
|
-
|
|
61
|
-
* Pass `event` and `fn` to remove a listener.
|
|
62
|
-
* Pass `event` to remove all listeners on that event.
|
|
63
|
-
* Pass nothing to remove all listeners on all events.
|
|
64
|
-
|
|
65
|
-
### Emitter#emit(event, ...)
|
|
66
|
-
|
|
67
|
-
Emit an `event` with variable option args.
|
|
68
|
-
|
|
69
|
-
### Emitter#listeners(event)
|
|
70
|
-
|
|
71
|
-
Return an array of callbacks, or an empty array.
|
|
72
|
-
|
|
73
|
-
### Emitter#hasListeners(event)
|
|
74
|
-
|
|
75
|
-
Check if this emitter has `event` handlers.
|
|
76
|
-
|
|
77
|
-
## License
|
|
78
|
-
|
|
79
|
-
MIT
|
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An events map is an interface that maps event names to their value, which
|
|
3
|
-
* represents the type of the `on` listener.
|
|
4
|
-
*/
|
|
5
|
-
export interface EventsMap {
|
|
6
|
-
[event: string]: any;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* The default events map, used if no EventsMap is given. Using this EventsMap
|
|
11
|
-
* is equivalent to accepting all event names, and any data.
|
|
12
|
-
*/
|
|
13
|
-
export interface DefaultEventsMap {
|
|
14
|
-
[event: string]: (...args: any[]) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Returns a union type containing all the keys of an event map.
|
|
19
|
-
*/
|
|
20
|
-
export type EventNames<Map extends EventsMap> = keyof Map & (string | symbol);
|
|
21
|
-
|
|
22
|
-
/** The tuple type representing the parameters of an event listener */
|
|
23
|
-
export type EventParams<
|
|
24
|
-
Map extends EventsMap,
|
|
25
|
-
Ev extends EventNames<Map>
|
|
26
|
-
> = Parameters<Map[Ev]>;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* The event names that are either in ReservedEvents or in UserEvents
|
|
30
|
-
*/
|
|
31
|
-
export type ReservedOrUserEventNames<
|
|
32
|
-
ReservedEventsMap extends EventsMap,
|
|
33
|
-
UserEvents extends EventsMap
|
|
34
|
-
> = EventNames<ReservedEventsMap> | EventNames<UserEvents>;
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Type of a listener of a user event or a reserved event. If `Ev` is in
|
|
38
|
-
* `ReservedEvents`, the reserved event listener is returned.
|
|
39
|
-
*/
|
|
40
|
-
export type ReservedOrUserListener<
|
|
41
|
-
ReservedEvents extends EventsMap,
|
|
42
|
-
UserEvents extends EventsMap,
|
|
43
|
-
Ev extends ReservedOrUserEventNames<ReservedEvents, UserEvents>
|
|
44
|
-
> = FallbackToUntypedListener<
|
|
45
|
-
Ev extends EventNames<ReservedEvents>
|
|
46
|
-
? ReservedEvents[Ev]
|
|
47
|
-
: Ev extends EventNames<UserEvents>
|
|
48
|
-
? UserEvents[Ev]
|
|
49
|
-
: never
|
|
50
|
-
>;
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns an untyped listener type if `T` is `never`; otherwise, returns `T`.
|
|
54
|
-
*
|
|
55
|
-
* This is a hack to mitigate https://github.com/socketio/socket.io/issues/3833.
|
|
56
|
-
* Needed because of https://github.com/microsoft/TypeScript/issues/41778
|
|
57
|
-
*/
|
|
58
|
-
type FallbackToUntypedListener<T> = [T] extends [never]
|
|
59
|
-
? (...args: any[]) => void | Promise<void>
|
|
60
|
-
: T;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Strictly typed version of an `EventEmitter`. A `TypedEventEmitter` takes type
|
|
64
|
-
* parameters for mappings of event names to event data types, and strictly
|
|
65
|
-
* types method calls to the `EventEmitter` according to these event maps.
|
|
66
|
-
*
|
|
67
|
-
* @typeParam ListenEvents - `EventsMap` of user-defined events that can be
|
|
68
|
-
* listened to with `on` or `once`
|
|
69
|
-
* @typeParam EmitEvents - `EventsMap` of user-defined events that can be
|
|
70
|
-
* emitted with `emit`
|
|
71
|
-
* @typeParam ReservedEvents - `EventsMap` of reserved events, that can be
|
|
72
|
-
* emitted by socket.io with `emitReserved`, and can be listened to with
|
|
73
|
-
* `listen`.
|
|
74
|
-
*/
|
|
75
|
-
export class Emitter<
|
|
76
|
-
ListenEvents extends EventsMap,
|
|
77
|
-
EmitEvents extends EventsMap,
|
|
78
|
-
ReservedEvents extends EventsMap = {}
|
|
79
|
-
> {
|
|
80
|
-
/**
|
|
81
|
-
* Adds the `listener` function as an event listener for `ev`.
|
|
82
|
-
*
|
|
83
|
-
* @param ev Name of the event
|
|
84
|
-
* @param listener Callback function
|
|
85
|
-
*/
|
|
86
|
-
on<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
|
|
87
|
-
ev: Ev,
|
|
88
|
-
listener: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
|
|
89
|
-
): this;
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Adds a one-time `listener` function as an event listener for `ev`.
|
|
93
|
-
*
|
|
94
|
-
* @param ev Name of the event
|
|
95
|
-
* @param listener Callback function
|
|
96
|
-
*/
|
|
97
|
-
once<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
|
|
98
|
-
ev: Ev,
|
|
99
|
-
listener: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
|
|
100
|
-
): this;
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Removes the `listener` function as an event listener for `ev`.
|
|
104
|
-
*
|
|
105
|
-
* @param ev Name of the event
|
|
106
|
-
* @param listener Callback function
|
|
107
|
-
*/
|
|
108
|
-
off<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
|
|
109
|
-
ev?: Ev,
|
|
110
|
-
listener?: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
|
|
111
|
-
): this;
|
|
112
|
-
|
|
113
|
-
/**
|
|
114
|
-
* Emits an event.
|
|
115
|
-
*
|
|
116
|
-
* @param ev Name of the event
|
|
117
|
-
* @param args Values to send to listeners of this event
|
|
118
|
-
*/
|
|
119
|
-
emit<Ev extends EventNames<EmitEvents>>(
|
|
120
|
-
ev: Ev,
|
|
121
|
-
...args: EventParams<EmitEvents, Ev>
|
|
122
|
-
): this;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Emits a reserved event.
|
|
126
|
-
*
|
|
127
|
-
* This method is `protected`, so that only a class extending
|
|
128
|
-
* `StrictEventEmitter` can emit its own reserved events.
|
|
129
|
-
*
|
|
130
|
-
* @param ev Reserved event name
|
|
131
|
-
* @param args Arguments to emit along with the event
|
|
132
|
-
*/
|
|
133
|
-
protected emitReserved<Ev extends EventNames<ReservedEvents>>(
|
|
134
|
-
ev: Ev,
|
|
135
|
-
...args: EventParams<ReservedEvents, Ev>
|
|
136
|
-
): this;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Returns the listeners listening to an event.
|
|
140
|
-
*
|
|
141
|
-
* @param event Event name
|
|
142
|
-
* @returns Array of listeners subscribed to `event`
|
|
143
|
-
*/
|
|
144
|
-
listeners<Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>>(
|
|
145
|
-
event: Ev
|
|
146
|
-
): ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>[];
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Returns true if there is a listener for this event.
|
|
150
|
-
*
|
|
151
|
-
* @param event Event name
|
|
152
|
-
* @returns boolean
|
|
153
|
-
*/
|
|
154
|
-
hasListeners<
|
|
155
|
-
Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
|
|
156
|
-
>(event: Ev): boolean;
|
|
157
|
-
|
|
158
|
-
/**
|
|
159
|
-
* Removes the `listener` function as an event listener for `ev`.
|
|
160
|
-
*
|
|
161
|
-
* @param ev Name of the event
|
|
162
|
-
* @param listener Callback function
|
|
163
|
-
*/
|
|
164
|
-
removeListener<
|
|
165
|
-
Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
|
|
166
|
-
>(
|
|
167
|
-
ev?: Ev,
|
|
168
|
-
listener?: ReservedOrUserListener<ReservedEvents, ListenEvents, Ev>
|
|
169
|
-
): this;
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* Removes all `listener` function as an event listener for `ev`.
|
|
173
|
-
*
|
|
174
|
-
* @param ev Name of the event
|
|
175
|
-
*/
|
|
176
|
-
removeAllListeners<
|
|
177
|
-
Ev extends ReservedOrUserEventNames<ReservedEvents, ListenEvents>
|
|
178
|
-
>(ev?: Ev): this;
|
|
179
|
-
}
|
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* Expose `Emitter`.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
exports.Emitter = Emitter;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Initialize a new `Emitter`.
|
|
10
|
-
*
|
|
11
|
-
* @api public
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
function Emitter(obj) {
|
|
15
|
-
if (obj) return mixin(obj);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Mixin the emitter properties.
|
|
20
|
-
*
|
|
21
|
-
* @param {Object} obj
|
|
22
|
-
* @return {Object}
|
|
23
|
-
* @api private
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
function mixin(obj) {
|
|
27
|
-
for (var key in Emitter.prototype) {
|
|
28
|
-
obj[key] = Emitter.prototype[key];
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Listen on the given `event` with `fn`.
|
|
35
|
-
*
|
|
36
|
-
* @param {String} event
|
|
37
|
-
* @param {Function} fn
|
|
38
|
-
* @return {Emitter}
|
|
39
|
-
* @api public
|
|
40
|
-
*/
|
|
41
|
-
|
|
42
|
-
Emitter.prototype.on =
|
|
43
|
-
Emitter.prototype.addEventListener = function(event, fn){
|
|
44
|
-
this._callbacks = this._callbacks || {};
|
|
45
|
-
(this._callbacks['$' + event] = this._callbacks['$' + event] || [])
|
|
46
|
-
.push(fn);
|
|
47
|
-
return this;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Adds an `event` listener that will be invoked a single
|
|
52
|
-
* time then automatically removed.
|
|
53
|
-
*
|
|
54
|
-
* @param {String} event
|
|
55
|
-
* @param {Function} fn
|
|
56
|
-
* @return {Emitter}
|
|
57
|
-
* @api public
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
Emitter.prototype.once = function(event, fn){
|
|
61
|
-
function on() {
|
|
62
|
-
this.off(event, on);
|
|
63
|
-
fn.apply(this, arguments);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
on.fn = fn;
|
|
67
|
-
this.on(event, on);
|
|
68
|
-
return this;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Remove the given callback for `event` or all
|
|
73
|
-
* registered callbacks.
|
|
74
|
-
*
|
|
75
|
-
* @param {String} event
|
|
76
|
-
* @param {Function} fn
|
|
77
|
-
* @return {Emitter}
|
|
78
|
-
* @api public
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
Emitter.prototype.off =
|
|
82
|
-
Emitter.prototype.removeListener =
|
|
83
|
-
Emitter.prototype.removeAllListeners =
|
|
84
|
-
Emitter.prototype.removeEventListener = function(event, fn){
|
|
85
|
-
this._callbacks = this._callbacks || {};
|
|
86
|
-
|
|
87
|
-
// all
|
|
88
|
-
if (0 == arguments.length) {
|
|
89
|
-
this._callbacks = {};
|
|
90
|
-
return this;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// specific event
|
|
94
|
-
var callbacks = this._callbacks['$' + event];
|
|
95
|
-
if (!callbacks) return this;
|
|
96
|
-
|
|
97
|
-
// remove all handlers
|
|
98
|
-
if (1 == arguments.length) {
|
|
99
|
-
delete this._callbacks['$' + event];
|
|
100
|
-
return this;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
// remove specific handler
|
|
104
|
-
var cb;
|
|
105
|
-
for (var i = 0; i < callbacks.length; i++) {
|
|
106
|
-
cb = callbacks[i];
|
|
107
|
-
if (cb === fn || cb.fn === fn) {
|
|
108
|
-
callbacks.splice(i, 1);
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Remove event specific arrays for event types that no
|
|
114
|
-
// one is subscribed for to avoid memory leak.
|
|
115
|
-
if (callbacks.length === 0) {
|
|
116
|
-
delete this._callbacks['$' + event];
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return this;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Emit `event` with the given args.
|
|
124
|
-
*
|
|
125
|
-
* @param {String} event
|
|
126
|
-
* @param {Mixed} ...
|
|
127
|
-
* @return {Emitter}
|
|
128
|
-
*/
|
|
129
|
-
|
|
130
|
-
Emitter.prototype.emit = function(event){
|
|
131
|
-
this._callbacks = this._callbacks || {};
|
|
132
|
-
|
|
133
|
-
var args = new Array(arguments.length - 1)
|
|
134
|
-
, callbacks = this._callbacks['$' + event];
|
|
135
|
-
|
|
136
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
137
|
-
args[i - 1] = arguments[i];
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (callbacks) {
|
|
141
|
-
callbacks = callbacks.slice(0);
|
|
142
|
-
for (var i = 0, len = callbacks.length; i < len; ++i) {
|
|
143
|
-
callbacks[i].apply(this, args);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return this;
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
// alias used for reserved events (protected method)
|
|
151
|
-
Emitter.prototype.emitReserved = Emitter.prototype.emit;
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Return array of callbacks for `event`.
|
|
155
|
-
*
|
|
156
|
-
* @param {String} event
|
|
157
|
-
* @return {Array}
|
|
158
|
-
* @api public
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
Emitter.prototype.listeners = function(event){
|
|
162
|
-
this._callbacks = this._callbacks || {};
|
|
163
|
-
return this._callbacks['$' + event] || [];
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Check if this emitter has `event` handlers.
|
|
168
|
-
*
|
|
169
|
-
* @param {String} event
|
|
170
|
-
* @return {Boolean}
|
|
171
|
-
* @api public
|
|
172
|
-
*/
|
|
173
|
-
|
|
174
|
-
Emitter.prototype.hasListeners = function(event){
|
|
175
|
-
return !! this.listeners(event).length;
|
|
176
|
-
};
|