@luckylillia-dev/luckylillia 0.0.0-stage → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chunks/preload-helper-D5R8FHQt.js +342 -0
- package/chunks/preload-helper-D5R8FHQt.js.map +1 -0
- package/default_config.json +83 -0
- package/llbot-core.js +35013 -0
- package/llbot-core.js.map +1 -0
- package/llbot.js +138 -0
- package/llbot.js.map +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/commands.d.ts +86 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/commands.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/config.d.ts +14 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/config.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/ffmpeg.d.ts +41 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/ffmpeg.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/http.d.ts +88 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/http.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/index.d.ts +17 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/index.js +6 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/internal.d.ts +430 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/internal.js +7 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/manifest.d.ts +68 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/manifest.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/server.d.ts +23 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/server.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/storage.d.ts +21 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/storage.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/testing.d.ts +71 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/testing.js +1123 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/universal.d.ts +299 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/universal.js +1 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/webui.d.ts +762 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/lib/webui.js +9 -0
- package/node_modules/@luckylillia-dev/plugin-sdk/package.json +63 -0
- package/node_modules/@satorijs/element/jsx-dev-runtime.d.ts +3 -0
- package/node_modules/@satorijs/element/jsx-runtime.d.ts +3 -0
- package/node_modules/@satorijs/element/lib/index.cjs +447 -0
- package/node_modules/@satorijs/element/lib/index.d.ts +116 -0
- package/node_modules/@satorijs/element/lib/index.mjs +455 -0
- package/node_modules/@satorijs/element/package.json +60 -0
- package/node_modules/@satorijs/element/src/index.ts +559 -0
- package/node_modules/@satorijs/protocol/lib/index.cjs +187 -0
- package/node_modules/@satorijs/protocol/lib/index.d.ts +328 -0
- package/node_modules/@satorijs/protocol/lib/index.mjs +148 -0
- package/node_modules/@satorijs/protocol/package.json +44 -0
- package/node_modules/@satorijs/protocol/src/index.ts +513 -0
- package/node_modules/@standard-schema/spec/LICENSE +21 -0
- package/node_modules/@standard-schema/spec/README.md +198 -0
- package/node_modules/@standard-schema/spec/dist/index.cjs +18 -0
- package/node_modules/@standard-schema/spec/dist/index.d.cts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.d.ts +119 -0
- package/node_modules/@standard-schema/spec/dist/index.js +0 -0
- package/node_modules/@standard-schema/spec/package.json +52 -0
- package/node_modules/cordis/README.md +10 -0
- package/node_modules/cordis/bin.js +16 -0
- package/node_modules/cordis/lib/context.d.ts +32 -0
- package/node_modules/cordis/lib/events.d.ts +62 -0
- package/node_modules/cordis/lib/fiber.d.ts +85 -0
- package/node_modules/cordis/lib/index.d.ts +7 -0
- package/node_modules/cordis/lib/index.js +1577 -0
- package/node_modules/cordis/lib/logger.d.ts +74 -0
- package/node_modules/cordis/lib/reflect.d.ts +54 -0
- package/node_modules/cordis/lib/registry.d.ts +78 -0
- package/node_modules/cordis/lib/service.d.ts +19 -0
- package/node_modules/cordis/lib/utils.d.ts +50 -0
- package/node_modules/cordis/package.json +49 -0
- package/node_modules/cosmokit/LICENSE +21 -0
- package/node_modules/cosmokit/README.md +24 -0
- package/node_modules/cosmokit/lib/index.cjs +419 -0
- package/node_modules/cosmokit/lib/index.cjs.map +6 -0
- package/node_modules/cosmokit/lib/index.d.ts +142 -0
- package/node_modules/cosmokit/lib/index.mjs +357 -0
- package/node_modules/cosmokit/lib/index.mjs.map +6 -0
- package/node_modules/cosmokit/package.json +57 -0
- package/node_modules/cosmokit/src/array.ts +35 -0
- package/node_modules/cosmokit/src/index.ts +5 -0
- package/node_modules/cosmokit/src/misc.ts +57 -0
- package/node_modules/cosmokit/src/string.ts +101 -0
- package/node_modules/cosmokit/src/time.ts +91 -0
- package/node_modules/cosmokit/src/types.ts +131 -0
- package/node_modules/schemastery/README.md +342 -0
- package/node_modules/schemastery/lib/index.cjs +648 -0
- package/node_modules/schemastery/lib/index.cjs.map +6 -0
- package/node_modules/schemastery/lib/index.d.ts +138 -0
- package/node_modules/schemastery/lib/index.mjs +656 -0
- package/node_modules/schemastery/lib/index.mjs.map +6 -0
- package/node_modules/schemastery/package.json +32 -0
- package/node_modules/schemastery/src/index.ts +841 -0
- package/node_modules/undici/LICENSE +21 -0
- package/node_modules/undici/README.md +741 -0
- package/node_modules/undici/docs/docs/api/Agent.md +84 -0
- package/node_modules/undici/docs/docs/api/BalancedPool.md +99 -0
- package/node_modules/undici/docs/docs/api/CacheStorage.md +30 -0
- package/node_modules/undici/docs/docs/api/CacheStore.md +164 -0
- package/node_modules/undici/docs/docs/api/Client.md +290 -0
- package/node_modules/undici/docs/docs/api/ClientStats.md +27 -0
- package/node_modules/undici/docs/docs/api/Connector.md +115 -0
- package/node_modules/undici/docs/docs/api/ContentType.md +57 -0
- package/node_modules/undici/docs/docs/api/Cookies.md +128 -0
- package/node_modules/undici/docs/docs/api/Debug.md +62 -0
- package/node_modules/undici/docs/docs/api/DiagnosticsChannel.md +317 -0
- package/node_modules/undici/docs/docs/api/Dispatcher.md +1393 -0
- package/node_modules/undici/docs/docs/api/EnvHttpProxyAgent.md +159 -0
- package/node_modules/undici/docs/docs/api/Errors.md +49 -0
- package/node_modules/undici/docs/docs/api/EventSource.md +45 -0
- package/node_modules/undici/docs/docs/api/Fetch.md +60 -0
- package/node_modules/undici/docs/docs/api/GlobalInstallation.md +139 -0
- package/node_modules/undici/docs/docs/api/H2CClient.md +263 -0
- package/node_modules/undici/docs/docs/api/MockAgent.md +603 -0
- package/node_modules/undici/docs/docs/api/MockCallHistory.md +197 -0
- package/node_modules/undici/docs/docs/api/MockCallHistoryLog.md +43 -0
- package/node_modules/undici/docs/docs/api/MockClient.md +81 -0
- package/node_modules/undici/docs/docs/api/MockErrors.md +12 -0
- package/node_modules/undici/docs/docs/api/MockPool.md +555 -0
- package/node_modules/undici/docs/docs/api/Pool.md +84 -0
- package/node_modules/undici/docs/docs/api/PoolStats.md +35 -0
- package/node_modules/undici/docs/docs/api/ProxyAgent.md +229 -0
- package/node_modules/undici/docs/docs/api/RedirectHandler.md +93 -0
- package/node_modules/undici/docs/docs/api/RetryAgent.md +50 -0
- package/node_modules/undici/docs/docs/api/RetryHandler.md +118 -0
- package/node_modules/undici/docs/docs/api/RoundRobinPool.md +145 -0
- package/node_modules/undici/docs/docs/api/SnapshotAgent.md +616 -0
- package/node_modules/undici/docs/docs/api/Socks5ProxyAgent.md +275 -0
- package/node_modules/undici/docs/docs/api/Util.md +25 -0
- package/node_modules/undici/docs/docs/api/WebSocket.md +141 -0
- package/node_modules/undici/docs/docs/api/api-lifecycle.md +91 -0
- package/node_modules/undici/docs/docs/best-practices/client-certificate.md +64 -0
- package/node_modules/undici/docs/docs/best-practices/crawling.md +58 -0
- package/node_modules/undici/docs/docs/best-practices/mocking-request.md +190 -0
- package/node_modules/undici/docs/docs/best-practices/proxy.md +127 -0
- package/node_modules/undici/docs/docs/best-practices/undici-vs-builtin-fetch.md +224 -0
- package/node_modules/undici/docs/docs/best-practices/writing-tests.md +63 -0
- package/node_modules/undici/index-fetch.js +65 -0
- package/node_modules/undici/index.d.ts +3 -0
- package/node_modules/undici/index.js +234 -0
- package/node_modules/undici/lib/api/abort-signal.js +59 -0
- package/node_modules/undici/lib/api/api-connect.js +110 -0
- package/node_modules/undici/lib/api/api-pipeline.js +252 -0
- package/node_modules/undici/lib/api/api-request.js +214 -0
- package/node_modules/undici/lib/api/api-stream.js +209 -0
- package/node_modules/undici/lib/api/api-upgrade.js +111 -0
- package/node_modules/undici/lib/api/index.js +7 -0
- package/node_modules/undici/lib/api/readable.js +580 -0
- package/node_modules/undici/lib/cache/memory-cache-store.js +279 -0
- package/node_modules/undici/lib/cache/sqlite-cache-store.js +467 -0
- package/node_modules/undici/lib/core/connect.js +159 -0
- package/node_modules/undici/lib/core/constants.js +143 -0
- package/node_modules/undici/lib/core/diagnostics.js +227 -0
- package/node_modules/undici/lib/core/errors.js +477 -0
- package/node_modules/undici/lib/core/request.js +485 -0
- package/node_modules/undici/lib/core/socks5-client.js +422 -0
- package/node_modules/undici/lib/core/socks5-utils.js +212 -0
- package/node_modules/undici/lib/core/symbols.js +76 -0
- package/node_modules/undici/lib/core/tree.js +160 -0
- package/node_modules/undici/lib/core/util.js +992 -0
- package/node_modules/undici/lib/dispatcher/agent.js +162 -0
- package/node_modules/undici/lib/dispatcher/balanced-pool.js +221 -0
- package/node_modules/undici/lib/dispatcher/client-h1.js +1744 -0
- package/node_modules/undici/lib/dispatcher/client-h2.js +1056 -0
- package/node_modules/undici/lib/dispatcher/client.js +669 -0
- package/node_modules/undici/lib/dispatcher/dispatcher-base.js +196 -0
- package/node_modules/undici/lib/dispatcher/dispatcher.js +48 -0
- package/node_modules/undici/lib/dispatcher/env-http-proxy-agent.js +146 -0
- package/node_modules/undici/lib/dispatcher/fixed-queue.js +135 -0
- package/node_modules/undici/lib/dispatcher/h2c-client.js +51 -0
- package/node_modules/undici/lib/dispatcher/pool-base.js +214 -0
- package/node_modules/undici/lib/dispatcher/pool.js +118 -0
- package/node_modules/undici/lib/dispatcher/proxy-agent.js +319 -0
- package/node_modules/undici/lib/dispatcher/retry-agent.js +35 -0
- package/node_modules/undici/lib/dispatcher/round-robin-pool.js +137 -0
- package/node_modules/undici/lib/dispatcher/socks5-proxy-agent.js +260 -0
- package/node_modules/undici/lib/encoding/index.js +33 -0
- package/node_modules/undici/lib/global.js +59 -0
- package/node_modules/undici/lib/handler/cache-handler.js +824 -0
- package/node_modules/undici/lib/handler/cache-revalidation-handler.js +124 -0
- package/node_modules/undici/lib/handler/decorator-handler.js +67 -0
- package/node_modules/undici/lib/handler/deduplication-handler.js +504 -0
- package/node_modules/undici/lib/handler/redirect-handler.js +245 -0
- package/node_modules/undici/lib/handler/retry-handler.js +504 -0
- package/node_modules/undici/lib/handler/unwrap-handler.js +106 -0
- package/node_modules/undici/lib/handler/wrap-handler.js +105 -0
- package/node_modules/undici/lib/interceptor/cache.js +621 -0
- package/node_modules/undici/lib/interceptor/decompress.js +561 -0
- package/node_modules/undici/lib/interceptor/deduplicate.js +117 -0
- package/node_modules/undici/lib/interceptor/dns.js +571 -0
- package/node_modules/undici/lib/interceptor/dump.js +99 -0
- package/node_modules/undici/lib/interceptor/redirect.js +21 -0
- package/node_modules/undici/lib/interceptor/response-error.js +95 -0
- package/node_modules/undici/lib/interceptor/retry.js +19 -0
- package/node_modules/undici/lib/llhttp/constants.d.ts +195 -0
- package/node_modules/undici/lib/llhttp/constants.js +531 -0
- package/node_modules/undici/lib/llhttp/llhttp-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/llhttp_simd-wasm.js +15 -0
- package/node_modules/undici/lib/llhttp/utils.d.ts +2 -0
- package/node_modules/undici/lib/llhttp/utils.js +12 -0
- package/node_modules/undici/lib/mock/mock-agent.js +232 -0
- package/node_modules/undici/lib/mock/mock-call-history.js +248 -0
- package/node_modules/undici/lib/mock/mock-client.js +68 -0
- package/node_modules/undici/lib/mock/mock-errors.js +29 -0
- package/node_modules/undici/lib/mock/mock-interceptor.js +209 -0
- package/node_modules/undici/lib/mock/mock-pool.js +68 -0
- package/node_modules/undici/lib/mock/mock-symbols.js +32 -0
- package/node_modules/undici/lib/mock/mock-utils.js +486 -0
- package/node_modules/undici/lib/mock/pending-interceptors-formatter.js +43 -0
- package/node_modules/undici/lib/mock/snapshot-agent.js +353 -0
- package/node_modules/undici/lib/mock/snapshot-recorder.js +588 -0
- package/node_modules/undici/lib/mock/snapshot-utils.js +158 -0
- package/node_modules/undici/lib/util/cache.js +676 -0
- package/node_modules/undici/lib/util/date.js +670 -0
- package/node_modules/undici/lib/util/promise.js +28 -0
- package/node_modules/undici/lib/util/runtime-features.js +124 -0
- package/node_modules/undici/lib/util/stats.js +32 -0
- package/node_modules/undici/lib/util/timers.js +425 -0
- package/node_modules/undici/lib/web/cache/cache.js +864 -0
- package/node_modules/undici/lib/web/cache/cachestorage.js +152 -0
- package/node_modules/undici/lib/web/cache/util.js +45 -0
- package/node_modules/undici/lib/web/cookies/constants.js +12 -0
- package/node_modules/undici/lib/web/cookies/index.js +201 -0
- package/node_modules/undici/lib/web/cookies/parse.js +315 -0
- package/node_modules/undici/lib/web/cookies/util.js +371 -0
- package/node_modules/undici/lib/web/eventsource/eventsource-stream.js +575 -0
- package/node_modules/undici/lib/web/eventsource/eventsource.js +504 -0
- package/node_modules/undici/lib/web/eventsource/util.js +29 -0
- package/node_modules/undici/lib/web/fetch/LICENSE +21 -0
- package/node_modules/undici/lib/web/fetch/body.js +509 -0
- package/node_modules/undici/lib/web/fetch/constants.js +131 -0
- package/node_modules/undici/lib/web/fetch/data-url.js +596 -0
- package/node_modules/undici/lib/web/fetch/formdata-parser.js +586 -0
- package/node_modules/undici/lib/web/fetch/formdata.js +259 -0
- package/node_modules/undici/lib/web/fetch/global.js +40 -0
- package/node_modules/undici/lib/web/fetch/headers.js +719 -0
- package/node_modules/undici/lib/web/fetch/index.js +2413 -0
- package/node_modules/undici/lib/web/fetch/request.js +1115 -0
- package/node_modules/undici/lib/web/fetch/response.js +641 -0
- package/node_modules/undici/lib/web/fetch/util.js +1522 -0
- package/node_modules/undici/lib/web/infra/index.js +243 -0
- package/node_modules/undici/lib/web/subresource-integrity/Readme.md +9 -0
- package/node_modules/undici/lib/web/subresource-integrity/subresource-integrity.js +307 -0
- package/node_modules/undici/lib/web/webidl/index.js +1006 -0
- package/node_modules/undici/lib/web/websocket/connection.js +339 -0
- package/node_modules/undici/lib/web/websocket/constants.js +126 -0
- package/node_modules/undici/lib/web/websocket/events.js +331 -0
- package/node_modules/undici/lib/web/websocket/frame.js +133 -0
- package/node_modules/undici/lib/web/websocket/permessage-deflate.js +105 -0
- package/node_modules/undici/lib/web/websocket/receiver.js +520 -0
- package/node_modules/undici/lib/web/websocket/sender.js +109 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketerror.js +104 -0
- package/node_modules/undici/lib/web/websocket/stream/websocketstream.js +496 -0
- package/node_modules/undici/lib/web/websocket/util.js +347 -0
- package/node_modules/undici/lib/web/websocket/websocket.js +758 -0
- package/node_modules/undici/package.json +152 -0
- package/node_modules/undici/scripts/strip-comments.js +10 -0
- package/node_modules/undici/types/README.md +6 -0
- package/node_modules/undici/types/agent.d.ts +32 -0
- package/node_modules/undici/types/api.d.ts +43 -0
- package/node_modules/undici/types/balanced-pool.d.ts +30 -0
- package/node_modules/undici/types/cache-interceptor.d.ts +179 -0
- package/node_modules/undici/types/cache.d.ts +36 -0
- package/node_modules/undici/types/client-stats.d.ts +15 -0
- package/node_modules/undici/types/client.d.ts +153 -0
- package/node_modules/undici/types/connector.d.ts +36 -0
- package/node_modules/undici/types/content-type.d.ts +21 -0
- package/node_modules/undici/types/cookies.d.ts +30 -0
- package/node_modules/undici/types/diagnostics-channel.d.ts +74 -0
- package/node_modules/undici/types/dispatcher.d.ts +275 -0
- package/node_modules/undici/types/env-http-proxy-agent.d.ts +22 -0
- package/node_modules/undici/types/errors.d.ts +177 -0
- package/node_modules/undici/types/eventsource.d.ts +66 -0
- package/node_modules/undici/types/fetch.d.ts +231 -0
- package/node_modules/undici/types/formdata.d.ts +114 -0
- package/node_modules/undici/types/global-dispatcher.d.ts +9 -0
- package/node_modules/undici/types/global-origin.d.ts +7 -0
- package/node_modules/undici/types/h2c-client.d.ts +73 -0
- package/node_modules/undici/types/handlers.d.ts +14 -0
- package/node_modules/undici/types/header.d.ts +160 -0
- package/node_modules/undici/types/index.d.ts +91 -0
- package/node_modules/undici/types/interceptors.d.ts +82 -0
- package/node_modules/undici/types/mock-agent.d.ts +68 -0
- package/node_modules/undici/types/mock-call-history.d.ts +111 -0
- package/node_modules/undici/types/mock-client.d.ts +27 -0
- package/node_modules/undici/types/mock-errors.d.ts +12 -0
- package/node_modules/undici/types/mock-interceptor.d.ts +94 -0
- package/node_modules/undici/types/mock-pool.d.ts +27 -0
- package/node_modules/undici/types/patch.d.ts +29 -0
- package/node_modules/undici/types/pool-stats.d.ts +19 -0
- package/node_modules/undici/types/pool.d.ts +41 -0
- package/node_modules/undici/types/proxy-agent.d.ts +29 -0
- package/node_modules/undici/types/readable.d.ts +68 -0
- package/node_modules/undici/types/retry-agent.d.ts +8 -0
- package/node_modules/undici/types/retry-handler.d.ts +125 -0
- package/node_modules/undici/types/round-robin-pool.d.ts +41 -0
- package/node_modules/undici/types/snapshot-agent.d.ts +109 -0
- package/node_modules/undici/types/socks5-proxy-agent.d.ts +25 -0
- package/node_modules/undici/types/util.d.ts +18 -0
- package/node_modules/undici/types/utility.d.ts +7 -0
- package/node_modules/undici/types/webidl.d.ts +347 -0
- package/node_modules/undici/types/websocket.d.ts +188 -0
- package/node_modules/ws/LICENSE +20 -0
- package/node_modules/ws/README.md +548 -0
- package/node_modules/ws/browser.js +8 -0
- package/node_modules/ws/index.js +22 -0
- package/node_modules/ws/lib/buffer-util.js +131 -0
- package/node_modules/ws/lib/constants.js +19 -0
- package/node_modules/ws/lib/event-target.js +292 -0
- package/node_modules/ws/lib/extension.js +203 -0
- package/node_modules/ws/lib/limiter.js +55 -0
- package/node_modules/ws/lib/permessage-deflate.js +530 -0
- package/node_modules/ws/lib/receiver.js +743 -0
- package/node_modules/ws/lib/sender.js +607 -0
- package/node_modules/ws/lib/stream.js +161 -0
- package/node_modules/ws/lib/subprotocol.js +62 -0
- package/node_modules/ws/lib/validation.js +152 -0
- package/node_modules/ws/lib/websocket-server.js +562 -0
- package/node_modules/ws/lib/websocket.js +1407 -0
- package/node_modules/ws/package.json +74 -0
- package/node_modules/ws/wrapper.mjs +21 -0
- package/package.json +17 -4
- package/webui/assets/group-bot-profile-CYK81678.jpg +0 -0
- package/webui/assets/group-bot-settings-BBQBbfgh.jpg +0 -0
- package/webui/assets/index-CuH0UYYo.js +28 -0
- package/webui/assets/index-DjbPiYmB.css +2 -0
- package/webui/favicon.ico +0 -0
- package/webui/index.html +26 -0
- package/webui/logo-128.webp +0 -0
- package/webui/logo-192.webp +0 -0
- package/webui/logo-256.webp +0 -0
- package/webui/logo-64.webp +0 -0
- package/webui/logo.jpg +0 -0
- package/webui/plugin-shared/plugin-sdk-webui.js +3 -0
- package/webui/plugin-shared/react-dom.js +3 -0
- package/webui/plugin-shared/react-jsx-runtime.js +3 -0
- package/webui/plugin-shared/react.js +3 -0
- package//344/275/277/347/224/250/350/257/264/346/230/216.txt +6 -0
- package//346/233/264/346/226/260/346/227/245/345/277/227.txt +1091 -0
- package/README.md +0 -3
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@satorijs/protocol",
|
|
3
|
+
"description": "Protocol types for Satori protocol",
|
|
4
|
+
"version": "1.7.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "lib/index.cjs",
|
|
7
|
+
"module": "lib/index.mjs",
|
|
8
|
+
"types": "lib/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./lib/index.d.ts",
|
|
12
|
+
"require": "./lib/index.cjs",
|
|
13
|
+
"import": "./lib/index.mjs"
|
|
14
|
+
},
|
|
15
|
+
"./src/*": "./src/*",
|
|
16
|
+
"./package.json": "./package.json"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"lib",
|
|
20
|
+
"src"
|
|
21
|
+
],
|
|
22
|
+
"author": "Shigma <shigma10826@gmail.com>",
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "git+https://github.com/satorijs/satori.git",
|
|
27
|
+
"directory": "packages/protocol"
|
|
28
|
+
},
|
|
29
|
+
"bugs": {
|
|
30
|
+
"url": "https://github.com/satorijs/satori/issues"
|
|
31
|
+
},
|
|
32
|
+
"homepage": "https://github.com/satorijs/satori/tree/master/packages/protocol",
|
|
33
|
+
"keywords": [
|
|
34
|
+
"satori",
|
|
35
|
+
"protocol",
|
|
36
|
+
"server",
|
|
37
|
+
"basic",
|
|
38
|
+
"api"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@satorijs/element": "^3.2.0",
|
|
42
|
+
"cosmokit": "^1.8.1"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
import Element from '@satorijs/element'
|
|
2
|
+
import { Dict, isNullable, pick } from 'cosmokit'
|
|
3
|
+
|
|
4
|
+
type PartialWithPick<T, K extends keyof T> = Partial<T> & Pick<T, K>
|
|
5
|
+
|
|
6
|
+
export interface SendOptions {
|
|
7
|
+
linkPreview?: boolean
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Upload {
|
|
11
|
+
type: string
|
|
12
|
+
filename?: string
|
|
13
|
+
data: ArrayBuffer
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface Response {
|
|
17
|
+
status: number
|
|
18
|
+
statusText?: string
|
|
19
|
+
body?: ArrayBuffer
|
|
20
|
+
headers?: Headers
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Field {
|
|
24
|
+
name: string
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function Field(name: string): Field {
|
|
28
|
+
return { name }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Method {
|
|
32
|
+
name: string
|
|
33
|
+
fields: Field[]
|
|
34
|
+
isForm: boolean
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function Method(name: string, fields: string[], isForm = false): Method {
|
|
38
|
+
return { name, fields: fields.map(Field), isForm }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const Methods: Dict<Method> = {
|
|
42
|
+
'channel.get': Method('getChannel', ['channel_id', 'guild_id']),
|
|
43
|
+
'channel.list': Method('getChannelList', ['guild_id', 'next']),
|
|
44
|
+
'channel.create': Method('createChannel', ['guild_id', 'data']),
|
|
45
|
+
'channel.update': Method('updateChannel', ['channel_id', 'data']),
|
|
46
|
+
'channel.delete': Method('deleteChannel', ['channel_id']),
|
|
47
|
+
'channel.mute': Method('muteChannel', ['channel_id', 'guild_id', 'enable']),
|
|
48
|
+
|
|
49
|
+
'message.create': Method('createMessage', ['channel_id', 'content', 'referrer']),
|
|
50
|
+
'message.update': Method('editMessage', ['channel_id', 'message_id', 'content']),
|
|
51
|
+
'message.delete': Method('deleteMessage', ['channel_id', 'message_id']),
|
|
52
|
+
'message.get': Method('getMessage', ['channel_id', 'message_id']),
|
|
53
|
+
'message.list': Method('getMessageList', ['channel_id', 'next', 'direction', 'limit', 'order']),
|
|
54
|
+
|
|
55
|
+
'reaction.create': Method('createReaction', ['channel_id', 'message_id', 'emoji_id']),
|
|
56
|
+
'reaction.delete': Method('deleteReaction', ['channel_id', 'message_id', 'emoji_id', 'user_id']),
|
|
57
|
+
'reaction.clear': Method('clearReaction', ['channel_id', 'message_id', 'emoji_id']),
|
|
58
|
+
'reaction.list': Method('getReactionList', ['channel_id', 'message_id', 'emoji_id', 'next']),
|
|
59
|
+
|
|
60
|
+
'upload.create': Method('createUpload', [], true),
|
|
61
|
+
|
|
62
|
+
'guild.get': Method('getGuild', ['guild_id']),
|
|
63
|
+
'guild.list': Method('getGuildList', ['next']),
|
|
64
|
+
|
|
65
|
+
'guild.member.get': Method('getGuildMember', ['guild_id', 'user_id']),
|
|
66
|
+
'guild.member.list': Method('getGuildMemberList', ['guild_id', 'next']),
|
|
67
|
+
'guild.member.kick': Method('kickGuildMember', ['guild_id', 'user_id', 'permanent']),
|
|
68
|
+
'guild.member.mute': Method('muteGuildMember', ['guild_id', 'user_id', 'duration', 'reason']),
|
|
69
|
+
'guild.member.role.set': Method('setGuildMemberRole', ['guild_id', 'user_id', 'role_id']),
|
|
70
|
+
'guild.member.role.unset': Method('unsetGuildMemberRole', ['guild_id', 'user_id', 'role_id']),
|
|
71
|
+
'guild.member.role.list': Method('getGuildMemberRoleList', ['guild_id', 'user_id', 'next']),
|
|
72
|
+
|
|
73
|
+
'guild.role.list': Method('getGuildRoleList', ['guild_id', 'next']),
|
|
74
|
+
'guild.role.create': Method('createGuildRole', ['guild_id', 'data']),
|
|
75
|
+
'guild.role.update': Method('updateGuildRole', ['guild_id', 'role_id', 'data']),
|
|
76
|
+
'guild.role.delete': Method('deleteGuildRole', ['guild_id', 'role_id']),
|
|
77
|
+
|
|
78
|
+
'login.get': Method('getLogin', []),
|
|
79
|
+
'user.get': Method('getUser', ['user_id']),
|
|
80
|
+
'user.channel.create': Method('createDirectChannel', ['user_id', 'guild_id']),
|
|
81
|
+
'friend.list': Method('getFriendList', ['next']),
|
|
82
|
+
'friend.delete': Method('deleteFriend', ['user_id']),
|
|
83
|
+
|
|
84
|
+
'friend.approve': Method('handleFriendRequest', ['message_id', 'approve', 'comment']),
|
|
85
|
+
'guild.approve': Method('handleGuildRequest', ['message_id', 'approve', 'comment']),
|
|
86
|
+
'guild.member.approve': Method('handleGuildMemberRequest', ['message_id', 'approve', 'comment']),
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export interface List<T = any> {
|
|
90
|
+
data: T[]
|
|
91
|
+
next?: string
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface BidiList<T = any> {
|
|
95
|
+
data: T[]
|
|
96
|
+
prev?: string
|
|
97
|
+
next?: string
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type Direction = 'before' | 'after' | 'around'
|
|
101
|
+
|
|
102
|
+
export type Order = 'asc' | 'desc'
|
|
103
|
+
|
|
104
|
+
export interface Methods {
|
|
105
|
+
// message
|
|
106
|
+
createMessage(channelId: string, content: Element.Fragment, referrer?: any, options?: SendOptions): Promise<Message[]>
|
|
107
|
+
sendMessage(channelId: string, content: Element.Fragment, referrer?: any, options?: SendOptions): Promise<string[]>
|
|
108
|
+
sendPrivateMessage(userId: string, content: Element.Fragment, guildId?: string, options?: SendOptions): Promise<string[]>
|
|
109
|
+
getMessage(channelId: string, messageId: string): Promise<Message>
|
|
110
|
+
getMessageList(channelId: string, next?: string, direction?: Direction, limit?: number, order?: Order): Promise<BidiList<Message>>
|
|
111
|
+
getMessageIter(channelId: string): AsyncIterable<Message>
|
|
112
|
+
editMessage(channelId: string, messageId: string, content: Element.Fragment): Promise<void>
|
|
113
|
+
deleteMessage(channelId: string, messageId: string): Promise<void>
|
|
114
|
+
|
|
115
|
+
// reaction
|
|
116
|
+
createReaction(channelId: string, messageId: string, emojiId: string): Promise<void>
|
|
117
|
+
deleteReaction(channelId: string, messageId: string, emojiId: string, userId?: string): Promise<void>
|
|
118
|
+
clearReaction(channelId: string, messageId: string, emojiId?: string): Promise<void>
|
|
119
|
+
getReactionList(channelId: string, messageId: string, emojiId: string, next?: string): Promise<List<User>>
|
|
120
|
+
getReactionIter(channelId: string, messageId: string, emojiId: string): AsyncIterable<User>
|
|
121
|
+
|
|
122
|
+
// upload
|
|
123
|
+
createUpload(...uploads: Upload[]): Promise<string[]>
|
|
124
|
+
|
|
125
|
+
// user
|
|
126
|
+
getLogin(): Promise<Login>
|
|
127
|
+
getUser(userId: string, guildId?: string): Promise<User>
|
|
128
|
+
getFriendList(next?: string): Promise<List<Friend>>
|
|
129
|
+
getFriendIter(): AsyncIterable<Friend>
|
|
130
|
+
deleteFriend(userId: string): Promise<void>
|
|
131
|
+
|
|
132
|
+
// guild
|
|
133
|
+
getGuild(guildId: string): Promise<Guild>
|
|
134
|
+
getGuildList(next?: string): Promise<List<Guild>>
|
|
135
|
+
getGuildIter(): AsyncIterable<Guild>
|
|
136
|
+
|
|
137
|
+
// guild member
|
|
138
|
+
getGuildMember(guildId: string, userId: string): Promise<GuildMember>
|
|
139
|
+
getGuildMemberList(guildId: string, next?: string): Promise<List<GuildMember>>
|
|
140
|
+
getGuildMemberIter(guildId: string): AsyncIterable<GuildMember>
|
|
141
|
+
kickGuildMember(guildId: string, userId: string, permanent?: boolean): Promise<void>
|
|
142
|
+
muteGuildMember(guildId: string, userId: string, duration: number, reason?: string): Promise<void>
|
|
143
|
+
setGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>
|
|
144
|
+
unsetGuildMemberRole(guildId: string, userId: string, roleId: string): Promise<void>
|
|
145
|
+
getGuildMemberRoleList(guildId: string, userId: string, next?: string): Promise<List<PartialWithPick<GuildRole, 'id'>>>
|
|
146
|
+
|
|
147
|
+
// role
|
|
148
|
+
getGuildRoleList(guildId: string, next?: string): Promise<List<GuildRole>>
|
|
149
|
+
getGuildRoleIter(guildId: string): AsyncIterable<GuildRole>
|
|
150
|
+
createGuildRole(guildId: string, data: Partial<GuildRole>): Promise<GuildRole>
|
|
151
|
+
updateGuildRole(guildId: string, roleId: string, data: Partial<GuildRole>): Promise<void>
|
|
152
|
+
deleteGuildRole(guildId: string, roleId: string): Promise<void>
|
|
153
|
+
|
|
154
|
+
// channel
|
|
155
|
+
getChannel(channelId: string, guildId?: string): Promise<Channel>
|
|
156
|
+
getChannelList(guildId: string, next?: string): Promise<List<Channel>>
|
|
157
|
+
getChannelIter(guildId: string): AsyncIterable<Channel>
|
|
158
|
+
createDirectChannel(userId: string, guildId?: string): Promise<Channel>
|
|
159
|
+
createChannel(guildId: string, data: Partial<Channel>): Promise<Channel>
|
|
160
|
+
updateChannel(channelId: string, data: Partial<Channel>): Promise<void>
|
|
161
|
+
deleteChannel(channelId: string): Promise<void>
|
|
162
|
+
muteChannel(channelId: string, guildId?: string, enable?: boolean): Promise<void>
|
|
163
|
+
|
|
164
|
+
// request
|
|
165
|
+
handleFriendRequest(messageId: string, approve: boolean, comment?: string): Promise<void>
|
|
166
|
+
handleGuildRequest(messageId: string, approve: boolean, comment?: string): Promise<void>
|
|
167
|
+
handleGuildMemberRequest(messageId: string, approve: boolean, comment?: string): Promise<void>
|
|
168
|
+
|
|
169
|
+
// commands
|
|
170
|
+
updateCommands(commands: Command[]): Promise<void>
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface Channel {
|
|
174
|
+
id: string
|
|
175
|
+
type: Channel.Type
|
|
176
|
+
name?: string
|
|
177
|
+
parentId?: string
|
|
178
|
+
position?: number
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export namespace Channel {
|
|
182
|
+
export const enum Type {
|
|
183
|
+
TEXT = 0,
|
|
184
|
+
DIRECT = 1,
|
|
185
|
+
CATEGORY = 2,
|
|
186
|
+
VOICE = 3,
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface Guild {
|
|
191
|
+
id: string
|
|
192
|
+
name?: string
|
|
193
|
+
avatar?: string
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface GuildRole {
|
|
197
|
+
id: string
|
|
198
|
+
name?: string
|
|
199
|
+
color?: number
|
|
200
|
+
position?: number
|
|
201
|
+
permissions?: bigint
|
|
202
|
+
hoist?: boolean
|
|
203
|
+
mentionable?: boolean
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export interface Emoji {
|
|
207
|
+
id: string
|
|
208
|
+
name?: string
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface User {
|
|
212
|
+
id: string
|
|
213
|
+
name?: string
|
|
214
|
+
nick?: string
|
|
215
|
+
/** @deprecated */
|
|
216
|
+
userId?: string
|
|
217
|
+
/** @deprecated */
|
|
218
|
+
username?: string
|
|
219
|
+
/** @deprecated */
|
|
220
|
+
nickname?: string
|
|
221
|
+
avatar?: string
|
|
222
|
+
discriminator?: string
|
|
223
|
+
isBot?: boolean
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface Resource<K = any> {
|
|
227
|
+
attrs: (keyof K)[]
|
|
228
|
+
children: (keyof K)[]
|
|
229
|
+
content?: keyof K
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export function Resource<K>(attrs: (keyof K)[] = [], children: (keyof K)[] = [], content?: keyof K): Resource<K> {
|
|
233
|
+
return { attrs, children, content }
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export namespace Resource {
|
|
237
|
+
export interface Definitions {
|
|
238
|
+
user: User
|
|
239
|
+
member: GuildMember
|
|
240
|
+
channel: Channel
|
|
241
|
+
guild: Guild
|
|
242
|
+
quote: Message
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const Definitions: { [K in keyof Definitions]: Resource<Definitions[K]> } = {
|
|
246
|
+
user: Resource(['id', 'name', 'nick', 'avatar', 'isBot']),
|
|
247
|
+
member: Resource(['name', 'nick', 'avatar']),
|
|
248
|
+
channel: Resource(['id', 'type', 'name']),
|
|
249
|
+
guild: Resource(['id', 'name', 'avatar']),
|
|
250
|
+
quote: Resource(['id'], ['quote', 'user', 'member', 'channel'], 'content'),
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
export function encode<K extends keyof Definitions>(type: K, data: Definitions[K]) {
|
|
254
|
+
const resource = Definitions[type]
|
|
255
|
+
const element = Element(type, pick(data, resource.attrs as any))
|
|
256
|
+
for (const key of resource.children) {
|
|
257
|
+
if (isNullable(data[key])) continue
|
|
258
|
+
element.children.push(encode(key as any, data[key]))
|
|
259
|
+
}
|
|
260
|
+
if (resource.content && !isNullable(data[resource.content])) {
|
|
261
|
+
element.children.push(...Element.parse(data[resource.content] as string))
|
|
262
|
+
}
|
|
263
|
+
return element
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
export function decode(element: Element) {
|
|
267
|
+
const data: any = element.attrs
|
|
268
|
+
const resource = Definitions[element.type]
|
|
269
|
+
for (const key of resource.children) {
|
|
270
|
+
const index = element.children.findIndex((el) => el.type === key)
|
|
271
|
+
if (index === -1) continue
|
|
272
|
+
const [child] = element.children.splice(index, 1)
|
|
273
|
+
data[key] = decode(child)
|
|
274
|
+
}
|
|
275
|
+
if (resource.content && element.children.length) {
|
|
276
|
+
data[resource.content] = element.children.join('')
|
|
277
|
+
}
|
|
278
|
+
return data
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
export function transformKey(source: any, callback: (key: string) => string) {
|
|
283
|
+
if (!source || typeof source !== 'object') return source
|
|
284
|
+
if (Array.isArray(source)) return source.map(value => transformKey(value, callback))
|
|
285
|
+
return Object.fromEntries(Object.entries(source).map(([key, value]) => {
|
|
286
|
+
if (key.startsWith('_') || key === 'referrer') return [key, value]
|
|
287
|
+
return [callback(key), transformKey(value, callback)]
|
|
288
|
+
}))
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
export interface Friend {
|
|
292
|
+
user?: User
|
|
293
|
+
nick?: string
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
export interface GuildMember {
|
|
297
|
+
user?: User
|
|
298
|
+
name?: string
|
|
299
|
+
nick?: string
|
|
300
|
+
avatar?: string
|
|
301
|
+
title?: string
|
|
302
|
+
roles?: GuildRole[]
|
|
303
|
+
joinedAt?: number
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export interface Login {
|
|
307
|
+
sn: number
|
|
308
|
+
adapter: string
|
|
309
|
+
user?: User
|
|
310
|
+
platform?: string
|
|
311
|
+
/** @deprecated use `login.user.id` instead */
|
|
312
|
+
selfId?: string
|
|
313
|
+
hidden?: boolean
|
|
314
|
+
status: Status
|
|
315
|
+
features: string[]
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
export const enum Status {
|
|
319
|
+
OFFLINE = 0,
|
|
320
|
+
ONLINE = 1,
|
|
321
|
+
CONNECT = 2,
|
|
322
|
+
DISCONNECT = 3,
|
|
323
|
+
RECONNECT = 4,
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export interface Message {
|
|
327
|
+
id?: string
|
|
328
|
+
/** @deprecated */
|
|
329
|
+
messageId?: string
|
|
330
|
+
channel?: Channel
|
|
331
|
+
guild?: Guild
|
|
332
|
+
user?: User
|
|
333
|
+
member?: GuildMember
|
|
334
|
+
content?: string
|
|
335
|
+
elements?: Element[]
|
|
336
|
+
timestamp?: number
|
|
337
|
+
quote?: Message
|
|
338
|
+
createdAt?: number
|
|
339
|
+
updatedAt?: number
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface Button {
|
|
343
|
+
id: string
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export interface Command {
|
|
347
|
+
name: string
|
|
348
|
+
description: Dict<string>
|
|
349
|
+
arguments: Command.Declaration[]
|
|
350
|
+
options: Command.Declaration[]
|
|
351
|
+
children: Command[]
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export namespace Command {
|
|
355
|
+
export interface Declaration {
|
|
356
|
+
name: string
|
|
357
|
+
description: Dict<string>
|
|
358
|
+
type: string
|
|
359
|
+
required: boolean
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export interface Argv {
|
|
364
|
+
name: string
|
|
365
|
+
arguments: any[]
|
|
366
|
+
options: Dict
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
type Genres = 'friend' | 'channel' | 'guild' | 'guild-member' | 'guild-role' | 'guild-file' | 'guild-emoji'
|
|
370
|
+
type Actions = 'added' | 'deleted' | 'updated'
|
|
371
|
+
|
|
372
|
+
export type EventName =
|
|
373
|
+
| `${Genres}-${Actions}`
|
|
374
|
+
| 'message'
|
|
375
|
+
| 'message-deleted'
|
|
376
|
+
| 'message-updated'
|
|
377
|
+
| 'message-pinned'
|
|
378
|
+
| 'message-unpinned'
|
|
379
|
+
| 'interaction/command'
|
|
380
|
+
| 'reaction-added'
|
|
381
|
+
| 'reaction-deleted'
|
|
382
|
+
| 'reaction-deleted/one'
|
|
383
|
+
| 'reaction-deleted/all'
|
|
384
|
+
| 'reaction-deleted/emoji'
|
|
385
|
+
| 'send'
|
|
386
|
+
| 'friend-request'
|
|
387
|
+
| 'guild-request'
|
|
388
|
+
| 'guild-member-request'
|
|
389
|
+
|
|
390
|
+
export interface Event {
|
|
391
|
+
sn: number
|
|
392
|
+
type: string
|
|
393
|
+
login: Login
|
|
394
|
+
selfId: string
|
|
395
|
+
platform: string
|
|
396
|
+
timestamp: number
|
|
397
|
+
argv?: Argv
|
|
398
|
+
channel?: Channel
|
|
399
|
+
guild?: Guild
|
|
400
|
+
friend?: Friend
|
|
401
|
+
member?: GuildMember
|
|
402
|
+
message?: Message
|
|
403
|
+
operator?: User
|
|
404
|
+
emoji?: Emoji
|
|
405
|
+
role?: GuildRole
|
|
406
|
+
user?: User
|
|
407
|
+
button?: Button
|
|
408
|
+
referrer: any
|
|
409
|
+
_type?: string
|
|
410
|
+
_data?: any
|
|
411
|
+
/** @deprecated */
|
|
412
|
+
subtype?: string
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export interface Meta {
|
|
416
|
+
logins: Login[]
|
|
417
|
+
proxyUrls: string[]
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
export type MessageLike = Message | Event
|
|
421
|
+
|
|
422
|
+
export const enum Opcode {
|
|
423
|
+
EVENT = 0,
|
|
424
|
+
PING = 1,
|
|
425
|
+
PONG = 2,
|
|
426
|
+
IDENTIFY = 3,
|
|
427
|
+
READY = 4,
|
|
428
|
+
META = 5,
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export interface GatewayPayloadStructure<O extends Opcode> {
|
|
432
|
+
op: O
|
|
433
|
+
body: GatewayBody[O]
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
export type ServerPayload = {
|
|
437
|
+
[O in Opcode]: GatewayPayloadStructure<O>
|
|
438
|
+
}[Opcode.EVENT | Opcode.PONG | Opcode.READY | Opcode.META]
|
|
439
|
+
|
|
440
|
+
export type ClientPayload = {
|
|
441
|
+
[O in Opcode]: GatewayPayloadStructure<O>
|
|
442
|
+
}[Opcode.PING | Opcode.IDENTIFY]
|
|
443
|
+
|
|
444
|
+
export interface GatewayBody {
|
|
445
|
+
[Opcode.EVENT]: Event
|
|
446
|
+
[Opcode.PING]: {}
|
|
447
|
+
[Opcode.PONG]: {}
|
|
448
|
+
[Opcode.IDENTIFY]: {
|
|
449
|
+
token?: string
|
|
450
|
+
sn?: number
|
|
451
|
+
}
|
|
452
|
+
[Opcode.READY]: Meta
|
|
453
|
+
[Opcode.META]: {
|
|
454
|
+
proxyUrls: string[]
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export namespace WebSocket {
|
|
459
|
+
/** The connection is not yet open. */
|
|
460
|
+
export const CONNECTING = 0
|
|
461
|
+
/** The connection is open and ready to communicate. */
|
|
462
|
+
export const OPEN = 1
|
|
463
|
+
/** The connection is in the process of closing. */
|
|
464
|
+
export const CLOSING = 2
|
|
465
|
+
/** The connection is closed. */
|
|
466
|
+
export const CLOSED = 3
|
|
467
|
+
|
|
468
|
+
export type ReadyState =
|
|
469
|
+
| typeof CONNECTING
|
|
470
|
+
| typeof OPEN
|
|
471
|
+
| typeof CLOSING
|
|
472
|
+
| typeof CLOSED
|
|
473
|
+
|
|
474
|
+
export interface EventMap {
|
|
475
|
+
open: Event
|
|
476
|
+
error: ErrorEvent
|
|
477
|
+
message: MessageEvent
|
|
478
|
+
close: CloseEvent
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
export interface EventListener {
|
|
482
|
+
(event: Event): void
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
export interface Event {
|
|
486
|
+
type: string
|
|
487
|
+
target: WebSocket
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
export interface CloseEvent extends Event {
|
|
491
|
+
code: number
|
|
492
|
+
reason: string
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
export interface MessageEvent extends Event {
|
|
496
|
+
data: string
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
export interface ErrorEvent extends Event {
|
|
500
|
+
message?: string
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
export interface WebSocket {
|
|
505
|
+
readonly url: string
|
|
506
|
+
readonly protocol?: string
|
|
507
|
+
readonly readyState?: number
|
|
508
|
+
close(code?: number, reason?: string): void
|
|
509
|
+
send(data: string): void
|
|
510
|
+
dispatchEvent?(event: any): boolean
|
|
511
|
+
addEventListener<K extends keyof WebSocket.EventMap>(type: K, listener: (event: WebSocket.EventMap[K]) => void): void
|
|
512
|
+
removeEventListener<K extends keyof WebSocket.EventMap>(type: K, listener: (event: WebSocket.EventMap[K]) => void): void
|
|
513
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Colin McDonnell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|