@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,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The WebUI side of a plugin: the ES module named by `llbot.webui` in package.json. Its default export
|
|
3
|
+
* receives a WebUIContext and registers what the plugin adds to the WebUI.
|
|
4
|
+
*
|
|
5
|
+
* The WebUI hands the module its own `react`, `react/jsx-runtime`, `react-dom` and this module through an
|
|
6
|
+
* import map, so components share its React. Mark all four external when bundling. The `declare`d values below
|
|
7
|
+
* are those the WebUI supplies at runtime.
|
|
8
|
+
*/
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@luckylillia-dev/plugin-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "SDK for writing LuckyLillia Bot plugins",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./lib/index.js",
|
|
7
|
+
"types": "./lib/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./lib/index.d.ts",
|
|
11
|
+
"default": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./webui": {
|
|
14
|
+
"types": "./lib/webui.d.ts",
|
|
15
|
+
"default": "./lib/webui.js"
|
|
16
|
+
},
|
|
17
|
+
"./testing": {
|
|
18
|
+
"types": "./lib/testing.d.ts",
|
|
19
|
+
"default": "./lib/testing.js"
|
|
20
|
+
},
|
|
21
|
+
"./package.json": "./package.json"
|
|
22
|
+
},
|
|
23
|
+
"bin": {
|
|
24
|
+
"luckylillia-plugin": "bin/luckylillia-plugin.mjs"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"lib",
|
|
28
|
+
"bin",
|
|
29
|
+
"template"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsc -p . && node scripts/build-testing.mjs",
|
|
33
|
+
"prepack": "tsc -p . && node scripts/build-testing.mjs"
|
|
34
|
+
},
|
|
35
|
+
"repository": {
|
|
36
|
+
"type": "git",
|
|
37
|
+
"url": "git+https://github.com/LuckyLilliaDev/LuckyLilliaBot.git",
|
|
38
|
+
"directory": "packages/plugin-sdk"
|
|
39
|
+
},
|
|
40
|
+
"author": "linyuchen",
|
|
41
|
+
"license": "GPL-2.0",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@cordisjs/plugin-database": "^4.2.0",
|
|
44
|
+
"@cordisjs/plugin-timer": "^1.1.4",
|
|
45
|
+
"@satorijs/element": "^3.2.0",
|
|
46
|
+
"@satorijs/protocol": "^1.7.0",
|
|
47
|
+
"cordis": "4.0.0-rc.11",
|
|
48
|
+
"schemastery": "^3.18.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@cordisjs/plugin-database": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^24.12.4",
|
|
57
|
+
"esbuild": "~0.28.0",
|
|
58
|
+
"typescript": "^7.0.2"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
|
|
5
|
+
// src/index.ts
|
|
6
|
+
var import_cosmokit = require("cosmokit");
|
|
7
|
+
var kElement = /* @__PURE__ */ Symbol.for("satori.element");
|
|
8
|
+
var ElementConstructor = class {
|
|
9
|
+
static {
|
|
10
|
+
__name(this, "ElementConstructor");
|
|
11
|
+
}
|
|
12
|
+
get data() {
|
|
13
|
+
return this.attrs;
|
|
14
|
+
}
|
|
15
|
+
getTagName() {
|
|
16
|
+
if (this.type === "component") {
|
|
17
|
+
return this.attrs.is?.name ?? "component";
|
|
18
|
+
} else {
|
|
19
|
+
return this.type;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
toAttrString() {
|
|
23
|
+
return Object.entries(this.attrs).map(([key, value]) => {
|
|
24
|
+
if ((0, import_cosmokit.isNullable)(value)) return "";
|
|
25
|
+
key = (0, import_cosmokit.hyphenate)(key);
|
|
26
|
+
if (value === true) return ` ${key}`;
|
|
27
|
+
if (value === false) return ` no-${key}`;
|
|
28
|
+
return ` ${key}="${Element.escape("" + value, true)}"`;
|
|
29
|
+
}).join("");
|
|
30
|
+
}
|
|
31
|
+
toString(strip = false) {
|
|
32
|
+
if (this.type === "text" && "content" in this.attrs) {
|
|
33
|
+
return strip ? this.attrs.content : Element.escape(this.attrs.content);
|
|
34
|
+
}
|
|
35
|
+
const inner = this.children.map((child) => child.toString(strip)).join("");
|
|
36
|
+
if (strip) return inner;
|
|
37
|
+
const attrs = this.toAttrString();
|
|
38
|
+
const tag = this.getTagName();
|
|
39
|
+
if (!this.children.length) return `<${tag}${attrs}/>`;
|
|
40
|
+
return `<${tag}${attrs}>${inner}</${tag}>`;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
(0, import_cosmokit.defineProperty)(ElementConstructor, "name", "Element");
|
|
44
|
+
(0, import_cosmokit.defineProperty)(ElementConstructor.prototype, kElement, true);
|
|
45
|
+
function Element(type, ...args) {
|
|
46
|
+
const el = Object.create(ElementConstructor.prototype);
|
|
47
|
+
const attrs = {}, children = [];
|
|
48
|
+
if (args[0] && typeof args[0] === "object" && !Element.isElement(args[0]) && !Array.isArray(args[0])) {
|
|
49
|
+
const props = args.shift();
|
|
50
|
+
for (const [key, value] of Object.entries(props)) {
|
|
51
|
+
if ((0, import_cosmokit.isNullable)(value)) continue;
|
|
52
|
+
if (key === "children") {
|
|
53
|
+
args.push(...(0, import_cosmokit.makeArray)(value));
|
|
54
|
+
} else {
|
|
55
|
+
attrs[(0, import_cosmokit.camelize)(key)] = value;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
for (const child of args) {
|
|
60
|
+
children.push(...Element.toElementArray(child));
|
|
61
|
+
}
|
|
62
|
+
if (typeof type === "function") {
|
|
63
|
+
attrs.is = type;
|
|
64
|
+
type = "component";
|
|
65
|
+
}
|
|
66
|
+
return Object.assign(el, { type, attrs, children });
|
|
67
|
+
}
|
|
68
|
+
__name(Element, "Element");
|
|
69
|
+
var evaluate = new Function("expr", "context", `
|
|
70
|
+
try {
|
|
71
|
+
with (context) {
|
|
72
|
+
return eval(expr)
|
|
73
|
+
}
|
|
74
|
+
} catch {}
|
|
75
|
+
`);
|
|
76
|
+
((Element2) => {
|
|
77
|
+
Element2.jsx = Element2;
|
|
78
|
+
Element2.jsxs = Element2;
|
|
79
|
+
Element2.jsxDEV = Element2;
|
|
80
|
+
Element2.Fragment = "template";
|
|
81
|
+
function isElement(source) {
|
|
82
|
+
return source && typeof source === "object" && source[kElement];
|
|
83
|
+
}
|
|
84
|
+
Element2.isElement = isElement;
|
|
85
|
+
__name(isElement, "isElement");
|
|
86
|
+
function toElement(content) {
|
|
87
|
+
if (typeof content === "string" || typeof content === "number" || typeof content === "boolean") {
|
|
88
|
+
content = "" + content;
|
|
89
|
+
if (content) return Element2("text", { content });
|
|
90
|
+
} else if (isElement(content)) {
|
|
91
|
+
return content;
|
|
92
|
+
} else if (!(0, import_cosmokit.isNullable)(content)) {
|
|
93
|
+
throw new TypeError(`Invalid content: ${content}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
Element2.toElement = toElement;
|
|
97
|
+
__name(toElement, "toElement");
|
|
98
|
+
function toElementArray(content) {
|
|
99
|
+
if (Array.isArray(content)) {
|
|
100
|
+
return content.map(toElement).filter(import_cosmokit.isNonNullable);
|
|
101
|
+
} else {
|
|
102
|
+
return [toElement(content)].filter(import_cosmokit.isNonNullable);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
Element2.toElementArray = toElementArray;
|
|
106
|
+
__name(toElementArray, "toElementArray");
|
|
107
|
+
function normalize(source, context) {
|
|
108
|
+
return typeof source === "string" ? parse(source, context) : toElementArray(source);
|
|
109
|
+
}
|
|
110
|
+
Element2.normalize = normalize;
|
|
111
|
+
__name(normalize, "normalize");
|
|
112
|
+
function escape(source, inline = false) {
|
|
113
|
+
const result = (source ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
114
|
+
return inline ? result.replace(/"/g, """) : result;
|
|
115
|
+
}
|
|
116
|
+
Element2.escape = escape;
|
|
117
|
+
__name(escape, "escape");
|
|
118
|
+
function unescape(source) {
|
|
119
|
+
return source.replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/&#(\d+);/g, (_, code) => code === "38" ? _ : String.fromCharCode(+code)).replace(/&#x([0-9a-f]+);/gi, (_, code) => code === "26" ? _ : String.fromCharCode(parseInt(code, 16))).replace(/&(amp|#38|#x26);/g, "&");
|
|
120
|
+
}
|
|
121
|
+
Element2.unescape = unescape;
|
|
122
|
+
__name(unescape, "unescape");
|
|
123
|
+
function from(source, options = {}) {
|
|
124
|
+
const elements = parse(source);
|
|
125
|
+
if (options.caret) {
|
|
126
|
+
if (options.type && elements[0]?.type !== options.type) return;
|
|
127
|
+
return elements[0];
|
|
128
|
+
}
|
|
129
|
+
return select(elements, options.type || "*")[0];
|
|
130
|
+
}
|
|
131
|
+
Element2.from = from;
|
|
132
|
+
__name(from, "from");
|
|
133
|
+
const combRegExp = / *([ >+~]) */g;
|
|
134
|
+
function parseSelector(input) {
|
|
135
|
+
return input.split(",").map((query) => {
|
|
136
|
+
const selectors = [];
|
|
137
|
+
query = query.trim();
|
|
138
|
+
let combCap, combinator = " ";
|
|
139
|
+
while (combCap = combRegExp.exec(query)) {
|
|
140
|
+
selectors.push({ type: query.slice(0, combCap.index), combinator });
|
|
141
|
+
combinator = combCap[1];
|
|
142
|
+
query = query.slice(combCap.index + combCap[0].length);
|
|
143
|
+
}
|
|
144
|
+
selectors.push({ type: query, combinator });
|
|
145
|
+
return selectors;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
Element2.parseSelector = parseSelector;
|
|
149
|
+
__name(parseSelector, "parseSelector");
|
|
150
|
+
function select(source, query) {
|
|
151
|
+
if (!source || !query) return [];
|
|
152
|
+
if (typeof source === "string") source = parse(source);
|
|
153
|
+
if (typeof query === "string") query = parseSelector(query);
|
|
154
|
+
if (!query.length) return [];
|
|
155
|
+
let adjacent = [];
|
|
156
|
+
const results = [];
|
|
157
|
+
for (const [index, element] of source.entries()) {
|
|
158
|
+
const inner = [];
|
|
159
|
+
const local = [...query, ...adjacent];
|
|
160
|
+
adjacent = [];
|
|
161
|
+
let matched = false;
|
|
162
|
+
for (const group of local) {
|
|
163
|
+
const { type, combinator } = group[0];
|
|
164
|
+
if (type === element.type || type === "*") {
|
|
165
|
+
if (group.length === 1) {
|
|
166
|
+
matched = true;
|
|
167
|
+
} else if ([" ", ">"].includes(group[1].combinator)) {
|
|
168
|
+
inner.push(group.slice(1));
|
|
169
|
+
} else if (group[1].combinator === "+") {
|
|
170
|
+
adjacent.push(group.slice(1));
|
|
171
|
+
} else {
|
|
172
|
+
query.push(group.slice(1));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (combinator === " ") {
|
|
176
|
+
inner.push(group);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
if (matched) results.push(source[index]);
|
|
180
|
+
results.push(...select(element.children, inner));
|
|
181
|
+
}
|
|
182
|
+
return results;
|
|
183
|
+
}
|
|
184
|
+
Element2.select = select;
|
|
185
|
+
__name(select, "select");
|
|
186
|
+
function interpolate(expr, context) {
|
|
187
|
+
expr = expr.trim();
|
|
188
|
+
if (!/^[\w.]+$/.test(expr)) {
|
|
189
|
+
return evaluate(expr, context) ?? "";
|
|
190
|
+
}
|
|
191
|
+
let value = context;
|
|
192
|
+
for (const part of expr.split(".")) {
|
|
193
|
+
value = value[part];
|
|
194
|
+
if ((0, import_cosmokit.isNullable)(value)) return "";
|
|
195
|
+
}
|
|
196
|
+
return value ?? "";
|
|
197
|
+
}
|
|
198
|
+
Element2.interpolate = interpolate;
|
|
199
|
+
__name(interpolate, "interpolate");
|
|
200
|
+
const tagRegExp1 = /(?<comment><!--[\s\S]*?-->)|(?<tag><(\/?)([^!\s>/]*)([^>]*?)\s*(\/?)>)/;
|
|
201
|
+
const tagRegExp2 = /(?<comment><!--[\s\S]*?-->)|(?<tag><(\/?)([^!\s>/]*)([^>]*?)\s*(\/?)>)|(?<curly>\{(?<derivative>[@:/#][^\s}]*)?[\s\S]*?\})/;
|
|
202
|
+
const attrRegExp1 = /([^\s=]+)(?:="(?<value1>[^"]*)"|='(?<value2>[^']*)')?/g;
|
|
203
|
+
const attrRegExp2 = /([^\s=]+)(?:="(?<value1>[^"]*)"|='(?<value2>[^']*)'|=\{(?<curly>[^}]+)\})?/g;
|
|
204
|
+
let Position;
|
|
205
|
+
((Position2) => {
|
|
206
|
+
Position2[Position2["OPEN"] = 0] = "OPEN";
|
|
207
|
+
Position2[Position2["CLOSE"] = 1] = "CLOSE";
|
|
208
|
+
Position2[Position2["EMPTY"] = 2] = "EMPTY";
|
|
209
|
+
Position2[Position2["CONTINUE"] = 3] = "CONTINUE";
|
|
210
|
+
})(Position || (Position = {}));
|
|
211
|
+
function parse(source, context) {
|
|
212
|
+
const tokens = [];
|
|
213
|
+
function pushText(content) {
|
|
214
|
+
if (content) tokens.push(content);
|
|
215
|
+
}
|
|
216
|
+
__name(pushText, "pushText");
|
|
217
|
+
const tagRegExp = context ? tagRegExp2 : tagRegExp1;
|
|
218
|
+
let tagCap;
|
|
219
|
+
let trimStart = true;
|
|
220
|
+
while (tagCap = tagRegExp.exec(source)) {
|
|
221
|
+
const { curly, comment, derivative } = tagCap.groups;
|
|
222
|
+
const trimEnd = !curly;
|
|
223
|
+
parseContent(source.slice(0, tagCap.index), trimStart, trimEnd);
|
|
224
|
+
trimStart = trimEnd;
|
|
225
|
+
source = source.slice(tagCap.index + tagCap[0].length);
|
|
226
|
+
const [_, , , close, type, extra, empty] = tagCap;
|
|
227
|
+
if (comment) continue;
|
|
228
|
+
if (curly) {
|
|
229
|
+
let name = "", position = 2 /* EMPTY */;
|
|
230
|
+
if (derivative) {
|
|
231
|
+
name = derivative.slice(1);
|
|
232
|
+
position = {
|
|
233
|
+
"@": 2 /* EMPTY */,
|
|
234
|
+
"#": 0 /* OPEN */,
|
|
235
|
+
"/": 1 /* CLOSE */,
|
|
236
|
+
":": 3 /* CONTINUE */
|
|
237
|
+
}[derivative[0]];
|
|
238
|
+
}
|
|
239
|
+
tokens.push({
|
|
240
|
+
type: "curly",
|
|
241
|
+
name,
|
|
242
|
+
position,
|
|
243
|
+
source: curly,
|
|
244
|
+
extra: curly.slice(1 + (derivative ?? "").length, -1)
|
|
245
|
+
});
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
tokens.push({
|
|
249
|
+
type: "angle",
|
|
250
|
+
source: _,
|
|
251
|
+
name: type || Element2.Fragment,
|
|
252
|
+
position: close ? 1 /* CLOSE */ : empty ? 2 /* EMPTY */ : 0 /* OPEN */,
|
|
253
|
+
extra
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
parseContent(source, trimStart, true);
|
|
257
|
+
function parseContent(source2, trimStart2, trimEnd) {
|
|
258
|
+
source2 = unescape(source2);
|
|
259
|
+
if (trimStart2) source2 = source2.replace(/^\s*\n\s*/, "");
|
|
260
|
+
if (trimEnd) source2 = source2.replace(/\s*\n\s*$/, "");
|
|
261
|
+
pushText(source2);
|
|
262
|
+
}
|
|
263
|
+
__name(parseContent, "parseContent");
|
|
264
|
+
return parseTokens(foldTokens(tokens), context);
|
|
265
|
+
}
|
|
266
|
+
Element2.parse = parse;
|
|
267
|
+
__name(parse, "parse");
|
|
268
|
+
function foldTokens(tokens) {
|
|
269
|
+
const stack = [[{
|
|
270
|
+
type: "angle",
|
|
271
|
+
name: Element2.Fragment,
|
|
272
|
+
position: 0 /* OPEN */,
|
|
273
|
+
source: "",
|
|
274
|
+
extra: "",
|
|
275
|
+
children: { default: [] }
|
|
276
|
+
}, "default"]];
|
|
277
|
+
function pushToken(...tokens2) {
|
|
278
|
+
const [token, slot] = stack[0];
|
|
279
|
+
token.children[slot].push(...tokens2);
|
|
280
|
+
}
|
|
281
|
+
__name(pushToken, "pushToken");
|
|
282
|
+
for (const token of tokens) {
|
|
283
|
+
if (typeof token === "string") {
|
|
284
|
+
pushToken(token);
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
const { name, position } = token;
|
|
288
|
+
if (position === 1 /* CLOSE */) {
|
|
289
|
+
if (stack[0][0].name === name) {
|
|
290
|
+
stack.shift();
|
|
291
|
+
}
|
|
292
|
+
} else if (position === 3 /* CONTINUE */) {
|
|
293
|
+
stack[0][0].children[name] = [];
|
|
294
|
+
stack[0][1] = name;
|
|
295
|
+
} else if (position === 0 /* OPEN */) {
|
|
296
|
+
pushToken(token);
|
|
297
|
+
token.children = { default: [] };
|
|
298
|
+
stack.unshift([token, "default"]);
|
|
299
|
+
} else {
|
|
300
|
+
pushToken(token);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
return stack[stack.length - 1][0].children.default;
|
|
304
|
+
}
|
|
305
|
+
__name(foldTokens, "foldTokens");
|
|
306
|
+
function parseTokens(tokens, context) {
|
|
307
|
+
const result = [];
|
|
308
|
+
for (const token of tokens) {
|
|
309
|
+
if (typeof token === "string") {
|
|
310
|
+
result.push(Element2("text", { content: token }));
|
|
311
|
+
} else if (token.type === "angle") {
|
|
312
|
+
const attrs = {};
|
|
313
|
+
const attrRegExp = context ? attrRegExp2 : attrRegExp1;
|
|
314
|
+
let attrCap;
|
|
315
|
+
while (attrCap = attrRegExp.exec(token.extra)) {
|
|
316
|
+
const [, key, v1, v2 = v1, v3] = attrCap;
|
|
317
|
+
if (v3) {
|
|
318
|
+
attrs[key] = interpolate(v3, context);
|
|
319
|
+
} else if (!(0, import_cosmokit.isNullable)(v2)) {
|
|
320
|
+
attrs[key] = unescape(v2);
|
|
321
|
+
} else if (key.startsWith("no-")) {
|
|
322
|
+
attrs[key.slice(3)] = false;
|
|
323
|
+
} else {
|
|
324
|
+
attrs[key] = true;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
result.push(Element2(token.name, attrs, token.children && parseTokens(token.children.default, context)));
|
|
328
|
+
} else if (!token.name) {
|
|
329
|
+
result.push(...toElementArray(interpolate(token.extra, context)));
|
|
330
|
+
} else if (token.name === "if") {
|
|
331
|
+
if (evaluate(token.extra, context)) {
|
|
332
|
+
result.push(...parseTokens(token.children.default, context));
|
|
333
|
+
} else {
|
|
334
|
+
result.push(...parseTokens(token.children.else || [], context));
|
|
335
|
+
}
|
|
336
|
+
} else if (token.name === "each") {
|
|
337
|
+
const [expr, ident] = token.extra.split(/\s+as\s+/);
|
|
338
|
+
const items = interpolate(expr, context);
|
|
339
|
+
if (!items || !items[Symbol.iterator]) continue;
|
|
340
|
+
for (const item of items) {
|
|
341
|
+
result.push(...parseTokens(token.children.default, { ...context, [ident]: item }));
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
return result;
|
|
346
|
+
}
|
|
347
|
+
__name(parseTokens, "parseTokens");
|
|
348
|
+
function visit(element, rules, session) {
|
|
349
|
+
const { type, attrs, children } = element;
|
|
350
|
+
if (typeof rules === "function") {
|
|
351
|
+
return rules(element, session);
|
|
352
|
+
} else {
|
|
353
|
+
let result = rules[typeof type === "string" ? type : ""] ?? rules.default ?? true;
|
|
354
|
+
if (typeof result === "function") {
|
|
355
|
+
result = result(attrs, children, session);
|
|
356
|
+
}
|
|
357
|
+
return result;
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
__name(visit, "visit");
|
|
361
|
+
function transform(source, rules, session) {
|
|
362
|
+
const elements = typeof source === "string" ? parse(source) : source;
|
|
363
|
+
const output = [];
|
|
364
|
+
elements.forEach((element) => {
|
|
365
|
+
const { type, attrs, children } = element;
|
|
366
|
+
const result = visit(element, rules, session);
|
|
367
|
+
if (result === true) {
|
|
368
|
+
output.push(Element2(type, attrs, transform(children, rules, session)));
|
|
369
|
+
} else if (result !== false) {
|
|
370
|
+
output.push(...toElementArray(result));
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
return typeof source === "string" ? output.join("") : output;
|
|
374
|
+
}
|
|
375
|
+
Element2.transform = transform;
|
|
376
|
+
__name(transform, "transform");
|
|
377
|
+
async function transformAsync(source, rules, session) {
|
|
378
|
+
const elements = typeof source === "string" ? parse(source) : source;
|
|
379
|
+
const children = (await Promise.all(elements.map(async (element) => {
|
|
380
|
+
const { type, attrs, children: children2 } = element;
|
|
381
|
+
const result = await visit(element, rules, session);
|
|
382
|
+
if (result === true) {
|
|
383
|
+
return [Element2(type, attrs, await transformAsync(children2, rules, session))];
|
|
384
|
+
} else if (result !== false) {
|
|
385
|
+
return toElementArray(result);
|
|
386
|
+
} else {
|
|
387
|
+
return [];
|
|
388
|
+
}
|
|
389
|
+
}))).flat(1);
|
|
390
|
+
return typeof source === "string" ? children.join("") : children;
|
|
391
|
+
}
|
|
392
|
+
Element2.transformAsync = transformAsync;
|
|
393
|
+
__name(transformAsync, "transformAsync");
|
|
394
|
+
function createFactory(type, ...keys) {
|
|
395
|
+
return (...args) => {
|
|
396
|
+
const element = Element2(type);
|
|
397
|
+
keys.forEach((key, index) => {
|
|
398
|
+
if (!(0, import_cosmokit.isNullable)(args[index])) {
|
|
399
|
+
element.attrs[key] = args[index];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
if (args[keys.length]) {
|
|
403
|
+
Object.assign(element.attrs, args[keys.length]);
|
|
404
|
+
}
|
|
405
|
+
return element;
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
__name(createFactory, "createFactory");
|
|
409
|
+
Element2.warn = /* @__PURE__ */ __name(() => {
|
|
410
|
+
}, "warn");
|
|
411
|
+
function createAssetFactory(type) {
|
|
412
|
+
return (src, ...args) => {
|
|
413
|
+
let prefix = "base64://";
|
|
414
|
+
if (typeof args[0] === "string") {
|
|
415
|
+
prefix = `data:${args.shift()};base64,`;
|
|
416
|
+
}
|
|
417
|
+
if ((0, import_cosmokit.is)("Buffer", src)) {
|
|
418
|
+
src = prefix + src.toString("base64");
|
|
419
|
+
} else if ((0, import_cosmokit.is)("ArrayBuffer", src)) {
|
|
420
|
+
src = prefix + import_cosmokit.Binary.toBase64(src);
|
|
421
|
+
} else if (ArrayBuffer.isView(src)) {
|
|
422
|
+
src = prefix + import_cosmokit.Binary.toBase64(src.buffer);
|
|
423
|
+
}
|
|
424
|
+
if (src.startsWith("base64://")) {
|
|
425
|
+
(0, Element2.warn)(`protocol "base64:" is deprecated and will be removed in the future, please use "data:" instead`);
|
|
426
|
+
}
|
|
427
|
+
return Element2(type, { ...args[0], src });
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
__name(createAssetFactory, "createAssetFactory");
|
|
431
|
+
Element2.text = createFactory("text", "content");
|
|
432
|
+
Element2.at = createFactory("at", "id");
|
|
433
|
+
Element2.sharp = createFactory("sharp", "id");
|
|
434
|
+
Element2.quote = createFactory("quote", "id");
|
|
435
|
+
Element2.emoji = createFactory("emoji", "id");
|
|
436
|
+
Element2.image = createAssetFactory("img");
|
|
437
|
+
Element2.img = createAssetFactory("img");
|
|
438
|
+
Element2.video = createAssetFactory("video");
|
|
439
|
+
Element2.audio = createAssetFactory("audio");
|
|
440
|
+
Element2.file = createAssetFactory("file");
|
|
441
|
+
function i18n(path, children) {
|
|
442
|
+
return Element2("i18n", typeof path === "string" ? { path } : path, children);
|
|
443
|
+
}
|
|
444
|
+
Element2.i18n = i18n;
|
|
445
|
+
__name(i18n, "i18n");
|
|
446
|
+
})(Element || (Element = {}));
|
|
447
|
+
module.exports = Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { Awaitable, Dict } from 'cosmokit';
|
|
2
|
+
declare global {
|
|
3
|
+
namespace JSX {
|
|
4
|
+
interface IntrinsicElements {
|
|
5
|
+
[key: string]: any;
|
|
6
|
+
message: {
|
|
7
|
+
id?: string;
|
|
8
|
+
forward?: boolean;
|
|
9
|
+
children?: any;
|
|
10
|
+
};
|
|
11
|
+
quote: {
|
|
12
|
+
id?: string;
|
|
13
|
+
name?: string;
|
|
14
|
+
avatar?: string;
|
|
15
|
+
children?: any;
|
|
16
|
+
};
|
|
17
|
+
at: {
|
|
18
|
+
id?: string;
|
|
19
|
+
name?: string;
|
|
20
|
+
avatar?: string;
|
|
21
|
+
role?: string;
|
|
22
|
+
type?: string;
|
|
23
|
+
};
|
|
24
|
+
sharp: {
|
|
25
|
+
id?: string;
|
|
26
|
+
name?: string;
|
|
27
|
+
avatar?: string;
|
|
28
|
+
};
|
|
29
|
+
emoji: {
|
|
30
|
+
id?: string;
|
|
31
|
+
name?: string;
|
|
32
|
+
};
|
|
33
|
+
img: ResourceElement;
|
|
34
|
+
audio: ResourceElement;
|
|
35
|
+
video: ResourceElement;
|
|
36
|
+
file: ResourceElement;
|
|
37
|
+
}
|
|
38
|
+
interface ResourceElement {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
src?: string;
|
|
41
|
+
title?: string;
|
|
42
|
+
width?: string | number;
|
|
43
|
+
height?: string | number;
|
|
44
|
+
duration?: string | number;
|
|
45
|
+
poster?: string;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
declare const kElement: unique symbol;
|
|
50
|
+
interface Element {
|
|
51
|
+
[kElement]: true;
|
|
52
|
+
type: string;
|
|
53
|
+
attrs: Dict;
|
|
54
|
+
/** @deprecated use `attrs` instead */
|
|
55
|
+
data: Dict;
|
|
56
|
+
children: Element[];
|
|
57
|
+
source?: string;
|
|
58
|
+
toString(strip?: boolean): string;
|
|
59
|
+
}
|
|
60
|
+
type RenderFunction = Element.Render<Element.Fragment, Awaitable<Element.Fragment>>;
|
|
61
|
+
declare function Element(type: string | RenderFunction, ...children: (Element.Fragment | undefined)[]): Element;
|
|
62
|
+
declare function Element(type: string | RenderFunction, attrs: Dict, ...children: (Element.Fragment | undefined)[]): Element;
|
|
63
|
+
declare namespace Element {
|
|
64
|
+
export const jsx: typeof Element;
|
|
65
|
+
export const jsxs: typeof Element;
|
|
66
|
+
export const jsxDEV: typeof Element;
|
|
67
|
+
export const Fragment = "template";
|
|
68
|
+
export type Fragment = string | Element | (string | Element)[];
|
|
69
|
+
export type Visit<T, S> = (element: Element, session: S) => T;
|
|
70
|
+
export type Render<T, S> = (attrs: Dict, children: Element[], session: S) => T;
|
|
71
|
+
export type SyncTransformer<S = never> = boolean | Fragment | Render<boolean | Fragment, S>;
|
|
72
|
+
export type Transformer<S = never> = boolean | Fragment | Render<Awaitable<boolean | Fragment>, S>;
|
|
73
|
+
type SyncVisitor<S> = Dict<SyncTransformer<S>> | Visit<boolean | Fragment, S>;
|
|
74
|
+
type Visitor<S> = Dict<Transformer<S>> | Visit<Awaitable<boolean | Fragment>, S>;
|
|
75
|
+
export function isElement(source: any): source is Element;
|
|
76
|
+
export function toElement(content: string | Element | undefined): Element | undefined;
|
|
77
|
+
export function toElementArray(content?: Element.Fragment): Element[];
|
|
78
|
+
export function normalize(source: Fragment, context?: any): Element[];
|
|
79
|
+
export function escape(source: string, inline?: boolean): string;
|
|
80
|
+
export function unescape(source: string): string;
|
|
81
|
+
export interface FindOptions {
|
|
82
|
+
type?: string;
|
|
83
|
+
caret?: boolean;
|
|
84
|
+
}
|
|
85
|
+
/** @deprecated use `Element.select()` instead */
|
|
86
|
+
export function from(source: string, options?: FindOptions): Element | undefined;
|
|
87
|
+
type Combinator = ' ' | '>' | '+' | '~';
|
|
88
|
+
export interface Selector {
|
|
89
|
+
type: string;
|
|
90
|
+
combinator: Combinator;
|
|
91
|
+
}
|
|
92
|
+
export function parseSelector(input: string): Selector[][];
|
|
93
|
+
export function select(source: string | Element[], query: string | Selector[][]): Element[];
|
|
94
|
+
export function interpolate(expr: string, context: any): any;
|
|
95
|
+
export function parse(source: string, context?: any): Element[];
|
|
96
|
+
type Rest<T> = [T] extends [never] ? [session?: T] : [session: T];
|
|
97
|
+
export function transform<S = never>(source: string, rules: SyncVisitor<S>, ...rest: Rest<S>): string;
|
|
98
|
+
export function transform<S = never>(source: Element[], rules: SyncVisitor<S>, ...rest: Rest<S>): Element[];
|
|
99
|
+
export function transformAsync<S = never>(source: string, rules: Visitor<S>, ...rest: Rest<S>): Promise<string>;
|
|
100
|
+
export function transformAsync<S = never>(source: Element[], rules: Visitor<S>, ...rest: Rest<S>): Promise<Element[]>;
|
|
101
|
+
export type Factory<R extends any[]> = (...args: [...rest: R, attrs?: Dict]) => Element;
|
|
102
|
+
export let warn: (message: string) => void;
|
|
103
|
+
export const text: Factory<[content: any]>;
|
|
104
|
+
export const at: Factory<[id: any]>;
|
|
105
|
+
export const sharp: Factory<[id: any]>;
|
|
106
|
+
export const quote: Factory<[id: any]>;
|
|
107
|
+
export const emoji: Factory<[id: any]>;
|
|
108
|
+
export const image: Factory<[data: string] | [data: ArrayBuffer | Buffer<ArrayBufferLike> | ArrayBufferView<ArrayBufferLike>, type: string]>;
|
|
109
|
+
export const img: Factory<[data: string] | [data: ArrayBuffer | Buffer<ArrayBufferLike> | ArrayBufferView<ArrayBufferLike>, type: string]>;
|
|
110
|
+
export const video: Factory<[data: string] | [data: ArrayBuffer | Buffer<ArrayBufferLike> | ArrayBufferView<ArrayBufferLike>, type: string]>;
|
|
111
|
+
export const audio: Factory<[data: string] | [data: ArrayBuffer | Buffer<ArrayBufferLike> | ArrayBufferView<ArrayBufferLike>, type: string]>;
|
|
112
|
+
export const file: Factory<[data: string] | [data: ArrayBuffer | Buffer<ArrayBufferLike> | ArrayBufferView<ArrayBufferLike>, type: string]>;
|
|
113
|
+
export function i18n(path: string | Dict, children?: any[]): Element;
|
|
114
|
+
export {};
|
|
115
|
+
}
|
|
116
|
+
export = Element;
|