koishi-plugin-kkk 1.0.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/CHANGELOG.md +57 -0
- package/LICENSE +674 -0
- package/README.md +98 -0
- package/assets/web/assets/CronEditor-CYgFpX-g.js +1 -0
- package/assets/web/assets/DesktopLayout-iI43ij11.js +1 -0
- package/assets/web/assets/MobileLayout-CziU8MCR.js +1 -0
- package/assets/web/assets/ThemeSwitch-DFohhwd9.js +1 -0
- package/assets/web/assets/index-BRROK0vh.js +47 -0
- package/assets/web/assets/index-Dj-StEiS.css +2 -0
- package/assets/web/assets/separator-CxcFlCzz.js +1 -0
- package/assets/web/favicon.svg +1 -0
- package/assets/web/icons.svg +24 -0
- package/assets/web/index.html +15 -0
- package/assets/webui.html +115 -0
- package/client/index.ts +63 -0
- package/config/default_config/app.yaml +64 -0
- package/config/default_config/bilibili.yaml +116 -0
- package/config/default_config/config.json +157 -0
- package/config/default_config/cookies.yaml +11 -0
- package/config/default_config/douyin.yaml +99 -0
- package/config/default_config/kuaishou.yaml +8 -0
- package/config/default_config/pushlist.yaml +37 -0
- package/config/default_config/request.yaml +22 -0
- package/config/default_config/upload.yaml +50 -0
- package/config/default_config/xiaohongshu.yaml +23 -0
- package/dist/index.js +1 -0
- package/lib/compat/axios.js +23 -0
- package/lib/compat/cron.js +77 -0
- package/lib/compat/esm.js +15 -0
- package/lib/compat/express.js +23 -0
- package/lib/compat/heroui.js +12 -0
- package/lib/compat/lodash.js +33 -0
- package/lib/compat/logger.js +118 -0
- package/lib/compat/node-karin.js +1053 -0
- package/lib/compat/phosphor-icons.js +27 -0
- package/lib/compat/qqcard.js +256 -0
- package/lib/compat/root.js +44 -0
- package/lib/compat/runtime.js +87 -0
- package/lib/compat/segment.js +167 -0
- package/lib/compat/sqlite3.js +117 -0
- package/lib/compat/start.js +7 -0
- package/lib/compat/syncConfig.js +65 -0
- package/lib/compat/template-react.js +30 -0
- package/lib/compat/text.js +65 -0
- package/lib/compat/yaml.js +13 -0
- package/lib/configBridge.js +91 -0
- package/lib/index.js +775 -0
- package/lib/karin/app.js +34 -0
- package/lib/karin/apps/__ready.js +9 -0
- package/lib/karin/apps/admin.js +136 -0
- package/lib/karin/apps/help.js +233 -0
- package/lib/karin/apps/push.js +291 -0
- package/lib/karin/apps/qrlogin.js +176 -0
- package/lib/karin/apps/statistics.js +209 -0
- package/lib/karin/apps/testPush.js +247 -0
- package/lib/karin/apps/tools.js +473 -0
- package/lib/karin/apps/update.js +252 -0
- package/lib/karin/index.js +37 -0
- package/lib/karin/module/db/bilibili.js +831 -0
- package/lib/karin/module/db/douyin.js +918 -0
- package/lib/karin/module/db/index.js +165 -0
- package/lib/karin/module/db/migration.js +199 -0
- package/lib/karin/module/db/statistics.js +559 -0
- package/lib/karin/module/index.js +94 -0
- package/lib/karin/module/server/constants/routes.js +48 -0
- package/lib/karin/module/server/controllers/bots.js +230 -0
- package/lib/karin/module/server/controllers/config.js +75 -0
- package/lib/karin/module/server/controllers/video.js +208 -0
- package/lib/karin/module/server/index.js +26 -0
- package/lib/karin/module/server/middlewares/auth.js +133 -0
- package/lib/karin/module/server/routes/amagi.js +57 -0
- package/lib/karin/module/server/routes/api.js +40 -0
- package/lib/karin/module/server/routes/index.js +97 -0
- package/lib/karin/module/server/routes/ssr.js +16 -0
- package/lib/karin/module/server/routes/static.js +43 -0
- package/lib/karin/module/utils/Base.js +403 -0
- package/lib/karin/module/utils/CardParser.js +487 -0
- package/lib/karin/module/utils/Common.js +418 -0
- package/lib/karin/module/utils/Config.js +434 -0
- package/lib/karin/module/utils/EmojiReaction.js +242 -0
- package/lib/karin/module/utils/ErrorHandler/handler.js +114 -0
- package/lib/karin/module/utils/ErrorHandler/index.js +55 -0
- package/lib/karin/module/utils/ErrorHandler/render.js +182 -0
- package/lib/karin/module/utils/ErrorHandler/sender.js +206 -0
- package/lib/karin/module/utils/ErrorHandler/strategy.js +41 -0
- package/lib/karin/module/utils/ErrorHandler/types.js +2 -0
- package/lib/karin/module/utils/ErrorHandler/utils.js +108 -0
- package/lib/karin/module/utils/FFmpeg.js +298 -0
- package/lib/karin/module/utils/ImageHelper.js +91 -0
- package/lib/karin/module/utils/ImageSlice.js +429 -0
- package/lib/karin/module/utils/MotionPhoto.js +250 -0
- package/lib/karin/module/utils/Network/Downloader.js +413 -0
- package/lib/karin/module/utils/Network/ImageDownloader.js +250 -0
- package/lib/karin/module/utils/Network/Network.js +332 -0
- package/lib/karin/module/utils/Network/ThrottleStream.js +71 -0
- package/lib/karin/module/utils/Network/constants.js +129 -0
- package/lib/karin/module/utils/Network/helpers.js +174 -0
- package/lib/karin/module/utils/Network/index.js +34 -0
- package/lib/karin/module/utils/Network/types.js +12 -0
- package/lib/karin/module/utils/Networks.js +17 -0
- package/lib/karin/module/utils/ParseLock.js +34 -0
- package/lib/karin/module/utils/ParseOverride.js +88 -0
- package/lib/karin/module/utils/QqCardResolve.js +114 -0
- package/lib/karin/module/utils/QqPanel.js +879 -0
- package/lib/karin/module/utils/Render/coverTheme.js +256 -0
- package/lib/karin/module/utils/Render/index.js +582 -0
- package/lib/karin/module/utils/amagiClient.js +338 -0
- package/lib/karin/module/utils/avatar.js +201 -0
- package/lib/karin/module/utils/bot.js +141 -0
- package/lib/karin/module/utils/build-metadata.js +50 -0
- package/lib/karin/module/utils/changelog.js +166 -0
- package/lib/karin/module/utils/index.js +26 -0
- package/lib/karin/module/utils/loginSession.js +259 -0
- package/lib/karin/module/utils/parseTip.js +93 -0
- package/lib/karin/module/utils/runtime-report.js +140 -0
- package/lib/karin/module/utils/semver.js +72 -0
- package/lib/karin/module/utils/statisticsAggregate.js +415 -0
- package/lib/karin/platform/bilibili/bilibili.js +1805 -0
- package/lib/karin/platform/bilibili/comments.js +294 -0
- package/lib/karin/platform/bilibili/danmaku.js +555 -0
- package/lib/karin/platform/bilibili/dynamic-text.js +827 -0
- package/lib/karin/platform/bilibili/genParams.js +37 -0
- package/lib/karin/platform/bilibili/getID.js +159 -0
- package/lib/karin/platform/bilibili/index.js +24 -0
- package/lib/karin/platform/bilibili/live-status.js +40 -0
- package/lib/karin/platform/bilibili/login.js +132 -0
- package/lib/karin/platform/bilibili/push.js +1397 -0
- package/lib/karin/platform/bilibili/riskControl.js +133 -0
- package/lib/karin/platform/bilibili/search.js +299 -0
- package/lib/karin/platform/common/danmaku-types.js +12 -0
- package/lib/karin/platform/douyin/comments.js +310 -0
- package/lib/karin/platform/douyin/danmaku.js +893 -0
- package/lib/karin/platform/douyin/douyin.js +1145 -0
- package/lib/karin/platform/douyin/getID.js +94 -0
- package/lib/karin/platform/douyin/index.js +24 -0
- package/lib/karin/platform/douyin/login.js +230 -0
- package/lib/karin/platform/douyin/push/favorite.js +75 -0
- package/lib/karin/platform/douyin/push/index.js +21 -0
- package/lib/karin/platform/douyin/push/live.js +69 -0
- package/lib/karin/platform/douyin/push/post.js +60 -0
- package/lib/karin/platform/douyin/push/recommend.js +74 -0
- package/lib/karin/platform/douyin/push/render.js +621 -0
- package/lib/karin/platform/douyin/push/types.js +2 -0
- package/lib/karin/platform/douyin/push.js +1128 -0
- package/lib/karin/platform/douyin/types.js +13 -0
- package/lib/karin/platform/douyin/videoQuality.js +222 -0
- package/lib/karin/platform/douyin/workType.js +182 -0
- package/lib/karin/platform/index.js +20 -0
- package/lib/karin/platform/kuaishou/comments.js +91 -0
- package/lib/karin/platform/kuaishou/getID.js +43 -0
- package/lib/karin/platform/kuaishou/getdata.js +41 -0
- package/lib/karin/platform/kuaishou/index.js +20 -0
- package/lib/karin/platform/kuaishou/kuaishou.js +122 -0
- package/lib/karin/platform/xiaohongshu/comments.js +162 -0
- package/lib/karin/platform/xiaohongshu/getID.js +129 -0
- package/lib/karin/platform/xiaohongshu/index.js +18 -0
- package/lib/karin/platform/xiaohongshu/xiaohongshu.js +643 -0
- package/lib/karin/root.js +73 -0
- package/lib/karin/setup.js +99 -0
- package/lib/karin/types/config/amagi.js +2 -0
- package/lib/karin/types/config/app.js +2 -0
- package/lib/karin/types/config/bilibili.js +2 -0
- package/lib/karin/types/config/cookies.js +2 -0
- package/lib/karin/types/config/douyin.js +2 -0
- package/lib/karin/types/config/index.js +2 -0
- package/lib/karin/types/config/kuaishou.js +2 -0
- package/lib/karin/types/config/pushlist.js +2 -0
- package/lib/karin/types/config/request.js +2 -0
- package/lib/karin/types/config/upload.js +2 -0
- package/lib/karin/types/config/xiaohongshu.js +2 -0
- package/lib/karin/types/datatypes.js +2 -0
- package/lib/karin/types/index.js +18 -0
- package/lib/karin/types/netrorks/NetworksConfigType.js +2 -0
- package/lib/karin/types/netrorks/index.js +17 -0
- package/lib/karin/web.config.js +49 -0
- package/lib/ktr/registry.js +82 -0
- package/lib/ktr/template/_preview/components/PreviewInfoCard.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewLayout.js +10 -0
- package/lib/ktr/template/_preview/components/PreviewVideoCard.js +8 -0
- package/lib/ktr/template/_preview/render.js +142 -0
- package/lib/ktr/template/_preview/types.js +2 -0
- package/lib/ktr/template/_preview/utils/status.js +31 -0
- package/lib/ktr/template/_preview/utils/time.js +12 -0
- package/lib/ktr/template/bilibili/bangumi/components/bangumi.js +127 -0
- package/lib/ktr/template/bilibili/bangumi/components/types.js +2 -0
- package/lib/ktr/template/bilibili/bangumi/index.js +12 -0
- package/lib/ktr/template/bilibili/comment/components/Comment.js +193 -0
- package/lib/ktr/template/bilibili/comment/components/types.js +2 -0
- package/lib/ktr/template/bilibili/comment/index.js +10 -0
- package/lib/ktr/template/bilibili/components/Icons.js +66 -0
- package/lib/ktr/template/bilibili/components/shared.js +93 -0
- package/lib/ktr/template/bilibili/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.js +66 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.js +87 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.js +93 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.js +132 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.js +84 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.js +38 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.js +2 -0
- package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.js +10 -0
- package/lib/ktr/template/bilibili/dynamic/components/AdditionalCard.js +59 -0
- package/lib/ktr/template/bilibili/dynamic/components/CommonComponents.js +30 -0
- package/lib/ktr/template/bilibili/dynamic/types.js +2 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.js +48 -0
- package/lib/ktr/template/bilibili/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/bilibili/qrcodeImg/index.js +10 -0
- package/lib/ktr/template/bilibili/userlist/components/UserList.js +53 -0
- package/lib/ktr/template/bilibili/userlist/components/types.js +3 -0
- package/lib/ktr/template/bilibili/userlist/index.js +13 -0
- package/lib/ktr/template/bilibili/videoInfo/components/types.js +2 -0
- package/lib/ktr/template/bilibili/videoInfo/components/videoInfo.js +62 -0
- package/lib/ktr/template/bilibili/videoInfo/index.js +10 -0
- package/lib/ktr/template/components/AmbientCover.js +36 -0
- package/lib/ktr/template/components/DefaultLayout.js +33 -0
- package/lib/ktr/template/components/GlowImage.js +276 -0
- package/lib/ktr/template/components/QRCodeWithAvatar.js +34 -0
- package/lib/ktr/template/components/RolldownLogo.js +6 -0
- package/lib/ktr/template/components/ViteLogo.js +6 -0
- package/lib/ktr/template/components/iconRegistry.js +173 -0
- package/lib/ktr/template/douyin/article-work/components/ArticleWork.js +99 -0
- package/lib/ktr/template/douyin/article-work/components/types.js +3 -0
- package/lib/ktr/template/douyin/article-work/index.js +10 -0
- package/lib/ktr/template/douyin/comment/components/Comment.js +189 -0
- package/lib/ktr/template/douyin/comment/components/types.js +2 -0
- package/lib/ktr/template/douyin/comment/index.js +10 -0
- package/lib/ktr/template/douyin/components/Icons.js +29 -0
- package/lib/ktr/template/douyin/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/components/Dynamic.js +90 -0
- package/lib/ktr/template/douyin/dynamic/components/types.js +3 -0
- package/lib/ktr/template/douyin/dynamic/index.js +10 -0
- package/lib/ktr/template/douyin/favorite-list/components/FavoriteList.js +30 -0
- package/lib/ktr/template/douyin/favorite-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/favorite-list/index.js +10 -0
- package/lib/ktr/template/douyin/image-work/components/ImageWork.js +136 -0
- package/lib/ktr/template/douyin/image-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/image-work/index.js +10 -0
- package/lib/ktr/template/douyin/live/components/Live.js +51 -0
- package/lib/ktr/template/douyin/live/components/types.js +3 -0
- package/lib/ktr/template/douyin/live/index.js +10 -0
- package/lib/ktr/template/douyin/musicinfo/components/MusicInfo.js +60 -0
- package/lib/ktr/template/douyin/musicinfo/components/types.js +3 -0
- package/lib/ktr/template/douyin/musicinfo/index.js +10 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/qrcodeImg.js +39 -0
- package/lib/ktr/template/douyin/qrcodeImg/components/types.js +3 -0
- package/lib/ktr/template/douyin/qrcodeImg/index.js +9 -0
- package/lib/ktr/template/douyin/recommend-list/components/RecommendList.js +30 -0
- package/lib/ktr/template/douyin/recommend-list/components/types.js +3 -0
- package/lib/ktr/template/douyin/recommend-list/index.js +10 -0
- package/lib/ktr/template/douyin/user_profile/components/UserVideoList.js +54 -0
- package/lib/ktr/template/douyin/user_profile/components/types.js +3 -0
- package/lib/ktr/template/douyin/user_profile/index.js +9 -0
- package/lib/ktr/template/douyin/userlist/components/UserList.js +50 -0
- package/lib/ktr/template/douyin/userlist/components/types.js +3 -0
- package/lib/ktr/template/douyin/userlist/index.js +13 -0
- package/lib/ktr/template/douyin/video-work/components/VideoWork.js +127 -0
- package/lib/ktr/template/douyin/video-work/components/types.js +2 -0
- package/lib/ktr/template/douyin/video-work/index.js +10 -0
- package/lib/ktr/template/kuaishou/comment/components/Comment.js +88 -0
- package/lib/ktr/template/kuaishou/comment/components/types.js +2 -0
- package/lib/ktr/template/kuaishou/comment/index.js +10 -0
- package/lib/ktr/template/other/changelog/components/changelog.js +117 -0
- package/lib/ktr/template/other/changelog/components/types.js +3 -0
- package/lib/ktr/template/other/changelog/index.js +9 -0
- package/lib/ktr/template/other/handlerError/components/errorTitles.js +227 -0
- package/lib/ktr/template/other/handlerError/components/handlerError.js +392 -0
- package/lib/ktr/template/other/handlerError/components/stackHighlight.js +109 -0
- package/lib/ktr/template/other/handlerError/components/types.js +2 -0
- package/lib/ktr/template/other/handlerError/index.js +9 -0
- package/lib/ktr/template/other/help/components/Help.js +79 -0
- package/lib/ktr/template/other/help/components/types.js +3 -0
- package/lib/ktr/template/other/help/index.js +12 -0
- package/lib/ktr/template/other/live-photo-tip/components/LivePhotoTip.js +80 -0
- package/lib/ktr/template/other/live-photo-tip/components/types.js +3 -0
- package/lib/ktr/template/other/live-photo-tip/index.js +9 -0
- package/lib/ktr/template/other/qrlogin/components/qrlogin.js +58 -0
- package/lib/ktr/template/other/qrlogin/components/types.js +3 -0
- package/lib/ktr/template/other/qrlogin/index.js +9 -0
- package/lib/ktr/template/other/runtime/components/runtime.js +101 -0
- package/lib/ktr/template/other/runtime/components/types.js +3 -0
- package/lib/ktr/template/other/runtime/index.js +9 -0
- package/lib/ktr/template/other/version_warning/components/VersionWarning.js +38 -0
- package/lib/ktr/template/other/version_warning/components/types.js +3 -0
- package/lib/ktr/template/other/version_warning/index.js +9 -0
- package/lib/ktr/template/statistics/components/BoxplotGuide.js +17 -0
- package/lib/ktr/template/statistics/components/ChartCard.js +15 -0
- package/lib/ktr/template/statistics/components/KpiCard.js +14 -0
- package/lib/ktr/template/statistics/components/PlatformTable.js +20 -0
- package/lib/ktr/template/statistics/components/RankList.js +61 -0
- package/lib/ktr/template/statistics/components/SSRChart.js +22 -0
- package/lib/ktr/template/statistics/components/chartPresets.js +630 -0
- package/lib/ktr/template/statistics/components/chartTheme.js +226 -0
- package/lib/ktr/template/statistics/components/format.js +38 -0
- package/lib/ktr/template/statistics/components/types.js +9 -0
- package/lib/ktr/template/statistics/global/components/GlobalStatistics.js +246 -0
- package/lib/ktr/template/statistics/global/components/types.js +3 -0
- package/lib/ktr/template/statistics/global/index.js +9 -0
- package/lib/ktr/template/statistics/group/components/GroupStatistics.js +181 -0
- package/lib/ktr/template/statistics/group/components/types.js +3 -0
- package/lib/ktr/template/statistics/group/index.js +9 -0
- package/lib/ktr/template/types/ctx.js +2 -0
- package/lib/ktr/template/xiaohongshu/comment/components/Comment.js +99 -0
- package/lib/ktr/template/xiaohongshu/comment/components/types.js +3 -0
- package/lib/ktr/template/xiaohongshu/comment/index.js +9 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/noteInfo.js +93 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/components/types.js +2 -0
- package/lib/ktr/template/xiaohongshu/noteInfo/index.js +9 -0
- package/lib/ktr/utils/QRCodeAvatar.js +99 -0
- package/lib/ktr/utils/QRcode.js +56 -0
- package/lib/ktr/utils/avatarProxy.js +45 -0
- package/lib/ktr/utils/cn.js +11 -0
- package/lib/ktr/utils/theme.js +12 -0
- package/lib/qqFields.json +75 -0
- package/lib/qqOptions.js +44 -0
- package/lib/richtext/index.js +25 -0
- package/lib/richtext/parse/index.js +232 -0
- package/lib/richtext/react/cn.js +11 -0
- package/lib/richtext/react/index.js +221 -0
- package/lib/richtext/types.js +2 -0
- package/lib/schema.js +352 -0
- package/lib/webui.js +341 -0
- package/package.json +88 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_BV.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_GOODS.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_LOTTERY.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VIEW_PICTURE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VOTE.svg +1 -0
- package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_WEB.svg +1 -0
- package/resources/image/bilibili/bilibili-dark.png +0 -0
- package/resources/image/bilibili/bilibili-light.png +0 -0
- package/resources/image/bilibili/bilibili.png +0 -0
- package/resources/image/bilibili/id-dark.svg +1 -0
- package/resources/image/bilibili/id-light.svg +1 -0
- package/resources/image/bilibili/level/lv0.svg +1 -0
- package/resources/image/bilibili/level/lv1.svg +1 -0
- package/resources/image/bilibili/level/lv2.svg +1 -0
- package/resources/image/bilibili/level/lv3.svg +1 -0
- package/resources/image/bilibili/level/lv4.svg +1 -0
- package/resources/image/bilibili/level/lv5.svg +1 -0
- package/resources/image/bilibili/level/lv6.svg +1 -0
- package/resources/image/bilibili/level/lv7.svg +1 -0
- package/resources/image/bilibili/like-dark.svg +6 -0
- package/resources/image/bilibili/like-light.svg +6 -0
- package/resources/image/bilibili/play.svg +28 -0
- package/resources/image/bilibili/res-local1.png +0 -0
- package/resources/image/bilibili/up_pb.svg +1 -0
- package/resources/image/bilibili//347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/douyin/douyin.png +0 -0
- package/resources/image/douyin/dylogo-dark.svg +23 -0
- package/resources/image/douyin/dylogo-light.svg +38 -0
- package/resources/image/douyin/search-dark.svg +1 -0
- package/resources/image/douyin/search-light.svg +3 -0
- package/resources/image/douyin//346/212/226/351/237/263-/347/233/264/346/222/255/344/270/255.png +0 -0
- package/resources/image/frame-logo.png +0 -0
- package/resources/image/kuaishou/logo.png +0 -0
- package/resources/image/other/handlerError/Milky.png +0 -0
- package/resources/image/other/handlerError/chronocat.svg +43 -0
- package/resources/image/other/handlerError/conwechat.webp +0 -0
- package/resources/image/other/handlerError/gocq-http.webp +0 -0
- package/resources/image/other/handlerError/lagrange.webp +0 -0
- package/resources/image/other/handlerError/llonebot.webp +0 -0
- package/resources/image/other/handlerError/napcat.webp +0 -0
- package/resources/image/other/handlerError/onebot.png +0 -0
- package/resources/image/other/handlerError/satori.png +0 -0
- package/resources/image/xiaohongshu/logo.png +0 -0
- package/resources/template/style.css +23708 -0
- package/resources/vite.svg +130 -0
- package/scripts/build.mjs +129 -0
- package/scripts/check-schema.cjs +55 -0
- package/scripts/deploy.mjs +78 -0
- package/scripts/make-demo-placeholders.mjs +112 -0
- package/scripts/patch-deps.mjs +46 -0
- package/scripts/patch-webui.mjs +112 -0
- package/scripts/smoke-commands.cjs +39 -0
- package/scripts/smoke-config.cjs +122 -0
- package/scripts/smoke-douyin.cjs +170 -0
- package/scripts/smoke-koishi-commands.cjs +210 -0
- package/scripts/smoke-login.cjs +110 -0
- package/scripts/smoke-parse.cjs +54 -0
- package/scripts/smoke-push-mock.cjs +114 -0
- package/scripts/smoke-push.cjs +104 -0
- package/scripts/smoke-qq.cjs +147 -0
- package/scripts/smoke-qqcard.cjs +108 -0
- package/scripts/smoke-qqpanel.cjs +205 -0
- package/scripts/smoke-render.cjs +106 -0
- package/scripts/smoke-server.cjs +94 -0
- package/src/compat/axios.ts +5 -0
- package/src/compat/cron.ts +86 -0
- package/src/compat/esm.ts +13 -0
- package/src/compat/express.ts +5 -0
- package/src/compat/heroui.tsx +53 -0
- package/src/compat/lodash.ts +32 -0
- package/src/compat/logger.ts +121 -0
- package/src/compat/node-karin.ts +1064 -0
- package/src/compat/phosphor-icons.tsx +25 -0
- package/src/compat/qqcard.ts +251 -0
- package/src/compat/root.ts +44 -0
- package/src/compat/runtime.ts +120 -0
- package/src/compat/segment.ts +161 -0
- package/src/compat/sqlite3.ts +123 -0
- package/src/compat/start.ts +3 -0
- package/src/compat/syncConfig.ts +64 -0
- package/src/compat/template-react.ts +54 -0
- package/src/compat/text.ts +58 -0
- package/src/compat/yaml.ts +6 -0
- package/src/configBridge.ts +94 -0
- package/src/index.ts +769 -0
- package/src/karin/app.ts +1 -0
- package/src/karin/apps/__ready.ts +14 -0
- package/src/karin/apps/admin.ts +127 -0
- package/src/karin/apps/help.ts +228 -0
- package/src/karin/apps/push.ts +327 -0
- package/src/karin/apps/qrlogin.ts +160 -0
- package/src/karin/apps/statistics.ts +203 -0
- package/src/karin/apps/testPush.ts +226 -0
- package/src/karin/apps/tools.ts +510 -0
- package/src/karin/apps/update.ts +239 -0
- package/src/karin/index.ts +9 -0
- package/src/karin/module/db/bilibili.ts +1089 -0
- package/src/karin/module/db/douyin.ts +1218 -0
- package/src/karin/module/db/index.ts +159 -0
- package/src/karin/module/db/migration.ts +249 -0
- package/src/karin/module/db/statistics.ts +817 -0
- package/src/karin/module/index.ts +37 -0
- package/src/karin/module/server/constants/routes.ts +53 -0
- package/src/karin/module/server/controllers/bots.ts +289 -0
- package/src/karin/module/server/controllers/config.ts +85 -0
- package/src/karin/module/server/controllers/video.ts +212 -0
- package/src/karin/module/server/index.ts +11 -0
- package/src/karin/module/server/middlewares/auth.ts +147 -0
- package/src/karin/module/server/routes/amagi.ts +57 -0
- package/src/karin/module/server/routes/api.ts +42 -0
- package/src/karin/module/server/routes/index.ts +68 -0
- package/src/karin/module/server/routes/ssr.ts +14 -0
- package/src/karin/module/server/routes/static.ts +43 -0
- package/src/karin/module/utils/Base.ts +497 -0
- package/src/karin/module/utils/CardParser.ts +503 -0
- package/src/karin/module/utils/Common.ts +448 -0
- package/src/karin/module/utils/Config.ts +443 -0
- package/src/karin/module/utils/EmojiReaction.ts +268 -0
- package/src/karin/module/utils/ErrorHandler/handler.ts +124 -0
- package/src/karin/module/utils/ErrorHandler/index.ts +48 -0
- package/src/karin/module/utils/ErrorHandler/render.ts +180 -0
- package/src/karin/module/utils/ErrorHandler/sender.ts +192 -0
- package/src/karin/module/utils/ErrorHandler/strategy.ts +41 -0
- package/src/karin/module/utils/ErrorHandler/types.ts +122 -0
- package/src/karin/module/utils/ErrorHandler/utils.ts +108 -0
- package/src/karin/module/utils/FFmpeg.ts +357 -0
- package/src/karin/module/utils/ImageHelper.ts +90 -0
- package/src/karin/module/utils/ImageSlice.ts +383 -0
- package/src/karin/module/utils/MotionPhoto.ts +297 -0
- package/src/karin/module/utils/Network/Downloader.ts +481 -0
- package/src/karin/module/utils/Network/ImageDownloader.ts +291 -0
- package/src/karin/module/utils/Network/Network.ts +344 -0
- package/src/karin/module/utils/Network/ThrottleStream.ts +76 -0
- package/src/karin/module/utils/Network/constants.ts +135 -0
- package/src/karin/module/utils/Network/helpers.ts +183 -0
- package/src/karin/module/utils/Network/index.ts +28 -0
- package/src/karin/module/utils/Network/types.ts +46 -0
- package/src/karin/module/utils/Networks.ts +20 -0
- package/src/karin/module/utils/ParseLock.ts +33 -0
- package/src/karin/module/utils/ParseOverride.ts +128 -0
- package/src/karin/module/utils/QqCardResolve.ts +116 -0
- package/src/karin/module/utils/QqPanel.ts +880 -0
- package/src/karin/module/utils/Render/coverTheme.ts +294 -0
- package/src/karin/module/utils/Render/index.ts +574 -0
- package/src/karin/module/utils/amagiClient.ts +368 -0
- package/src/karin/module/utils/avatar.ts +220 -0
- package/src/karin/module/utils/bot.ts +115 -0
- package/src/karin/module/utils/build-metadata.ts +60 -0
- package/src/karin/module/utils/changelog.ts +175 -0
- package/src/karin/module/utils/index.ts +10 -0
- package/src/karin/module/utils/loginSession.ts +291 -0
- package/src/karin/module/utils/parseTip.ts +59 -0
- package/src/karin/module/utils/runtime-report.ts +142 -0
- package/src/karin/module/utils/semver.ts +60 -0
- package/src/karin/module/utils/statisticsAggregate.ts +507 -0
- package/src/karin/platform/bilibili/bilibili.ts +2004 -0
- package/src/karin/platform/bilibili/comments.ts +397 -0
- package/src/karin/platform/bilibili/danmaku.ts +653 -0
- package/src/karin/platform/bilibili/dynamic-text.ts +926 -0
- package/src/karin/platform/bilibili/genParams.ts +30 -0
- package/src/karin/platform/bilibili/getID.ts +163 -0
- package/src/karin/platform/bilibili/index.ts +8 -0
- package/src/karin/platform/bilibili/live-status.ts +36 -0
- package/src/karin/platform/bilibili/login.ts +130 -0
- package/src/karin/platform/bilibili/push.ts +1615 -0
- package/src/karin/platform/bilibili/riskControl.ts +114 -0
- package/src/karin/platform/bilibili/search.ts +305 -0
- package/src/karin/platform/common/danmaku-types.ts +18 -0
- package/src/karin/platform/douyin/comments.ts +404 -0
- package/src/karin/platform/douyin/danmaku.ts +1187 -0
- package/src/karin/platform/douyin/douyin.ts +1244 -0
- package/src/karin/platform/douyin/getID.ts +101 -0
- package/src/karin/platform/douyin/index.ts +8 -0
- package/src/karin/platform/douyin/login.ts +251 -0
- package/src/karin/platform/douyin/push/favorite.ts +97 -0
- package/src/karin/platform/douyin/push/index.ts +5 -0
- package/src/karin/platform/douyin/push/live.ts +86 -0
- package/src/karin/platform/douyin/push/post.ts +75 -0
- package/src/karin/platform/douyin/push/recommend.ts +96 -0
- package/src/karin/platform/douyin/push/render.ts +768 -0
- package/src/karin/platform/douyin/push/types.ts +41 -0
- package/src/karin/platform/douyin/push.ts +1241 -0
- package/src/karin/platform/douyin/types.ts +151 -0
- package/src/karin/platform/douyin/videoQuality.ts +234 -0
- package/src/karin/platform/douyin/workType.ts +238 -0
- package/src/karin/platform/index.ts +4 -0
- package/src/karin/platform/kuaishou/comments.ts +114 -0
- package/src/karin/platform/kuaishou/getID.ts +48 -0
- package/src/karin/platform/kuaishou/getdata.ts +78 -0
- package/src/karin/platform/kuaishou/index.ts +4 -0
- package/src/karin/platform/kuaishou/kuaishou.ts +130 -0
- package/src/karin/platform/xiaohongshu/comments.ts +227 -0
- package/src/karin/platform/xiaohongshu/getID.ts +127 -0
- package/src/karin/platform/xiaohongshu/index.ts +2 -0
- package/src/karin/platform/xiaohongshu/xiaohongshu.ts +733 -0
- package/src/karin/root.ts +78 -0
- package/src/karin/setup.ts +77 -0
- package/src/karin/types/config/amagi.ts +46 -0
- package/src/karin/types/config/app.ts +129 -0
- package/src/karin/types/config/bilibili.ts +121 -0
- package/src/karin/types/config/cookies.ts +11 -0
- package/src/karin/types/config/douyin.ts +93 -0
- package/src/karin/types/config/index.ts +41 -0
- package/src/karin/types/config/kuaishou.ts +10 -0
- package/src/karin/types/config/pushlist.ts +55 -0
- package/src/karin/types/config/request.ts +27 -0
- package/src/karin/types/config/upload.ts +49 -0
- package/src/karin/types/config/xiaohongshu.ts +24 -0
- package/src/karin/types/datatypes.ts +42 -0
- package/src/karin/types/index.ts +4 -0
- package/src/karin/types/netrorks/NetworksConfigType.ts +61 -0
- package/src/karin/types/netrorks/index.ts +1 -0
- package/src/karin/web.config.ts +48 -0
- package/src/ktr/registry.ts +55 -0
- package/src/ktr/template/_preview/components/PreviewInfoCard.tsx +33 -0
- package/src/ktr/template/_preview/components/PreviewLayout.tsx +65 -0
- package/src/ktr/template/_preview/components/PreviewVideoCard.tsx +22 -0
- package/src/ktr/template/_preview/render.ts +158 -0
- package/src/ktr/template/_preview/types.ts +15 -0
- package/src/ktr/template/_preview/utils/status.ts +29 -0
- package/src/ktr/template/_preview/utils/time.ts +8 -0
- package/src/ktr/template/bilibili/bangumi/components/bangumi.tsx +462 -0
- package/src/ktr/template/bilibili/bangumi/components/types.ts +36 -0
- package/src/ktr/template/bilibili/bangumi/index.tsx +9 -0
- package/src/ktr/template/bilibili/comment/components/Comment.tsx +657 -0
- package/src/ktr/template/bilibili/comment/components/types.ts +26 -0
- package/src/ktr/template/bilibili/comment/index.tsx +11 -0
- package/src/ktr/template/bilibili/components/Icons.tsx +209 -0
- package/src/ktr/template/bilibili/components/shared.tsx +162 -0
- package/src/ktr/template/bilibili/components/types.ts +388 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.tsx +251 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.ts +67 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.tsx +238 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.ts +39 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.tsx +205 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.ts +20 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.tsx +11 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.tsx +348 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.ts +16 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.tsx +264 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.ts +32 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.tsx +68 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.ts +14 -0
- package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.tsx +12 -0
- package/src/ktr/template/bilibili/dynamic/components/AdditionalCard.tsx +165 -0
- package/src/ktr/template/bilibili/dynamic/components/CommonComponents.tsx +142 -0
- package/src/ktr/template/bilibili/dynamic/types.ts +382 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.tsx +179 -0
- package/src/ktr/template/bilibili/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/bilibili/qrcodeImg/index.tsx +12 -0
- package/src/ktr/template/bilibili/userlist/components/UserList.tsx +246 -0
- package/src/ktr/template/bilibili/userlist/components/types.ts +35 -0
- package/src/ktr/template/bilibili/userlist/index.tsx +11 -0
- package/src/ktr/template/bilibili/videoInfo/components/types.ts +28 -0
- package/src/ktr/template/bilibili/videoInfo/components/videoInfo.tsx +217 -0
- package/src/ktr/template/bilibili/videoInfo/index.tsx +12 -0
- package/src/ktr/template/components/AmbientCover.tsx +50 -0
- package/src/ktr/template/components/DefaultLayout.tsx +166 -0
- package/src/ktr/template/components/GlowImage.tsx +572 -0
- package/src/ktr/template/components/QRCodeWithAvatar.tsx +52 -0
- package/src/ktr/template/components/RolldownLogo.tsx +110 -0
- package/src/ktr/template/components/ViteLogo.tsx +134 -0
- package/src/ktr/template/components/iconRegistry.ts +294 -0
- package/src/ktr/template/douyin/article-work/components/ArticleWork.tsx +301 -0
- package/src/ktr/template/douyin/article-work/components/types.ts +53 -0
- package/src/ktr/template/douyin/article-work/index.tsx +12 -0
- package/src/ktr/template/douyin/comment/components/Comment.tsx +612 -0
- package/src/ktr/template/douyin/comment/components/types.ts +85 -0
- package/src/ktr/template/douyin/comment/index.tsx +11 -0
- package/src/ktr/template/douyin/components/Icons.tsx +75 -0
- package/src/ktr/template/douyin/components/types.ts +83 -0
- package/src/ktr/template/douyin/dynamic/components/Dynamic.tsx +283 -0
- package/src/ktr/template/douyin/dynamic/components/types.ts +46 -0
- package/src/ktr/template/douyin/dynamic/index.tsx +11 -0
- package/src/ktr/template/douyin/favorite-list/components/FavoriteList.tsx +201 -0
- package/src/ktr/template/douyin/favorite-list/components/types.ts +38 -0
- package/src/ktr/template/douyin/favorite-list/index.tsx +12 -0
- package/src/ktr/template/douyin/image-work/components/ImageWork.tsx +437 -0
- package/src/ktr/template/douyin/image-work/components/types.ts +78 -0
- package/src/ktr/template/douyin/image-work/index.tsx +11 -0
- package/src/ktr/template/douyin/live/components/Live.tsx +229 -0
- package/src/ktr/template/douyin/live/components/types.ts +47 -0
- package/src/ktr/template/douyin/live/index.tsx +11 -0
- package/src/ktr/template/douyin/musicinfo/components/MusicInfo.tsx +187 -0
- package/src/ktr/template/douyin/musicinfo/components/types.ts +31 -0
- package/src/ktr/template/douyin/musicinfo/index.tsx +11 -0
- package/src/ktr/template/douyin/qrcodeImg/components/qrcodeImg.tsx +170 -0
- package/src/ktr/template/douyin/qrcodeImg/components/types.ts +9 -0
- package/src/ktr/template/douyin/qrcodeImg/index.tsx +9 -0
- package/src/ktr/template/douyin/recommend-list/components/RecommendList.tsx +201 -0
- package/src/ktr/template/douyin/recommend-list/components/types.ts +37 -0
- package/src/ktr/template/douyin/recommend-list/index.tsx +12 -0
- package/src/ktr/template/douyin/user_profile/components/UserVideoList.tsx +225 -0
- package/src/ktr/template/douyin/user_profile/components/types.ts +71 -0
- package/src/ktr/template/douyin/user_profile/index.tsx +9 -0
- package/src/ktr/template/douyin/userlist/components/UserList.tsx +229 -0
- package/src/ktr/template/douyin/userlist/components/types.ts +35 -0
- package/src/ktr/template/douyin/userlist/index.tsx +11 -0
- package/src/ktr/template/douyin/video-work/components/VideoWork.tsx +398 -0
- package/src/ktr/template/douyin/video-work/components/types.ts +80 -0
- package/src/ktr/template/douyin/video-work/index.tsx +11 -0
- package/src/ktr/template/font.css +6071 -0
- package/src/ktr/template/global.d.ts +69 -0
- package/src/ktr/template/kuaishou/comment/components/Comment.tsx +207 -0
- package/src/ktr/template/kuaishou/comment/components/types.ts +47 -0
- package/src/ktr/template/kuaishou/comment/index.tsx +11 -0
- package/src/ktr/template/other/changelog/components/changelog.tsx +411 -0
- package/src/ktr/template/other/changelog/components/types.ts +21 -0
- package/src/ktr/template/other/changelog/index.tsx +9 -0
- package/src/ktr/template/other/handlerError/components/errorTitles.ts +224 -0
- package/src/ktr/template/other/handlerError/components/handlerError.tsx +1076 -0
- package/src/ktr/template/other/handlerError/components/stackHighlight.ts +127 -0
- package/src/ktr/template/other/handlerError/components/types.ts +124 -0
- package/src/ktr/template/other/handlerError/index.tsx +9 -0
- package/src/ktr/template/other/help/components/Help.tsx +249 -0
- package/src/ktr/template/other/help/components/types.ts +47 -0
- package/src/ktr/template/other/help/index.tsx +9 -0
- package/src/ktr/template/other/live-photo-tip/components/LivePhotoTip.tsx +295 -0
- package/src/ktr/template/other/live-photo-tip/components/types.ts +8 -0
- package/src/ktr/template/other/live-photo-tip/index.tsx +9 -0
- package/src/ktr/template/other/qrlogin/components/qrlogin.tsx +295 -0
- package/src/ktr/template/other/qrlogin/components/types.ts +11 -0
- package/src/ktr/template/other/qrlogin/index.tsx +9 -0
- package/src/ktr/template/other/runtime/components/runtime.tsx +347 -0
- package/src/ktr/template/other/runtime/components/types.ts +75 -0
- package/src/ktr/template/other/runtime/index.tsx +9 -0
- package/src/ktr/template/other/version_warning/components/VersionWarning.tsx +392 -0
- package/src/ktr/template/other/version_warning/components/types.ts +8 -0
- package/src/ktr/template/other/version_warning/index.tsx +9 -0
- package/src/ktr/template/statistics/components/BoxplotGuide.tsx +57 -0
- package/src/ktr/template/statistics/components/ChartCard.tsx +40 -0
- package/src/ktr/template/statistics/components/KpiCard.tsx +39 -0
- package/src/ktr/template/statistics/components/PlatformTable.tsx +83 -0
- package/src/ktr/template/statistics/components/RankList.tsx +127 -0
- package/src/ktr/template/statistics/components/SSRChart.tsx +41 -0
- package/src/ktr/template/statistics/components/chartPresets.ts +700 -0
- package/src/ktr/template/statistics/components/chartTheme.ts +234 -0
- package/src/ktr/template/statistics/components/format.ts +33 -0
- package/src/ktr/template/statistics/components/types.ts +92 -0
- package/src/ktr/template/statistics/global/components/GlobalStatistics.tsx +597 -0
- package/src/ktr/template/statistics/global/components/types.ts +138 -0
- package/src/ktr/template/statistics/global/index.tsx +9 -0
- package/src/ktr/template/statistics/group/components/GroupStatistics.tsx +468 -0
- package/src/ktr/template/statistics/group/components/types.ts +113 -0
- package/src/ktr/template/statistics/group/index.tsx +9 -0
- package/src/ktr/template/style.css +65 -0
- package/src/ktr/template/types/ctx.ts +42 -0
- package/src/ktr/template/xiaohongshu/comment/components/Comment.tsx +264 -0
- package/src/ktr/template/xiaohongshu/comment/components/types.ts +119 -0
- package/src/ktr/template/xiaohongshu/comment/index.tsx +9 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/noteInfo.tsx +271 -0
- package/src/ktr/template/xiaohongshu/noteInfo/components/types.ts +66 -0
- package/src/ktr/template/xiaohongshu/noteInfo/index.tsx +9 -0
- package/src/ktr/utils/QRCodeAvatar.ts +102 -0
- package/src/ktr/utils/QRcode.ts +65 -0
- package/src/ktr/utils/avatarProxy.ts +42 -0
- package/src/ktr/utils/cn.ts +6 -0
- package/src/ktr/utils/theme.ts +10 -0
- package/src/qqFields.json +75 -0
- package/src/qqOptions.ts +64 -0
- package/src/richtext/index.ts +9 -0
- package/src/richtext/parse/index.ts +271 -0
- package/src/richtext/react/cn.ts +6 -0
- package/src/richtext/react/index.tsx +582 -0
- package/src/richtext/types.ts +320 -0
- package/src/schema.ts +372 -0
- package/src/webui.ts +352 -0
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.reloadAmagiConfig = exports.getAmagiClient = exports.xiaohongshuFetcher = exports.kuaishouFetcher = exports.douyinFetcher = exports.bilibiliFetcher = exports.registerAmagiReloadListener = exports.isSoftFailure = exports.softFetch = exports.SOFT_ERROR_CODES = exports.AmagiBase = exports.AmagiError = void 0;
|
|
37
|
+
const amagi_1 = __importStar(require("@ikenxuan/amagi"));
|
|
38
|
+
const node_karin_1 = require("../../../compat/node-karin.js");
|
|
39
|
+
const Config_1 = require("./Config");
|
|
40
|
+
const loginSession_1 = require("./loginSession");
|
|
41
|
+
/**
|
|
42
|
+
* 平台业务码。v7 的三种码各归各位:平台业务码 `error.platform.code`、HTTP 状态 `error.http.status`、
|
|
43
|
+
* amagi 自己的码 `error.code`(字符串)。按平台码分流的地方(B站 `-352` 风控、`-111` csrf 失效、
|
|
44
|
+
* `12061` 关闭评论区)要的是第一种;平台没给就退 HTTP 状态,再退 0。
|
|
45
|
+
*/
|
|
46
|
+
const legacyCode = (error, envelope) => {
|
|
47
|
+
const platformCode = error.platform?.code;
|
|
48
|
+
if (typeof platformCode === 'number')
|
|
49
|
+
return platformCode;
|
|
50
|
+
if (typeof platformCode === 'string' && platformCode.trim() !== '' && Number.isFinite(Number(platformCode))) {
|
|
51
|
+
return Number(platformCode);
|
|
52
|
+
}
|
|
53
|
+
// Koishi 移植补充:已发布的 amagi 6.6.0 失败信封是
|
|
54
|
+
// { success:false, error:{ errorDescription, requestType, requestUrl, responseCode }, message, code, data }
|
|
55
|
+
// —— 平台业务码在 error.responseCode / 顶层 code 上,没有 v7 的 kind/platform/http 字段。
|
|
56
|
+
const anyError = error;
|
|
57
|
+
if (typeof anyError.responseCode === 'number')
|
|
58
|
+
return anyError.responseCode;
|
|
59
|
+
if (typeof envelope?.code === 'number')
|
|
60
|
+
return envelope.code;
|
|
61
|
+
return error.http?.status ?? 0;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* 一行说清一次失败:`[大类/码] 平台原文 (端点 平台码 HTTP requestId attempts)`。
|
|
65
|
+
* `message` 会被 `logger.warn(...)` 直接拼进日志行,塞整个信封的转储会把日志顶成一屏 ANSI。
|
|
66
|
+
*/
|
|
67
|
+
const describeFailure = (envelope) => {
|
|
68
|
+
const error = envelope.error ?? {};
|
|
69
|
+
const meta = envelope.meta;
|
|
70
|
+
const kind = error.kind ?? (error.requestType ? 'api' : 'unknown');
|
|
71
|
+
const code = error.code ?? envelope.code;
|
|
72
|
+
const reason = error.errorDescription ?? error.message ?? envelope.message ?? '未知错误';
|
|
73
|
+
const facts = [
|
|
74
|
+
error.requestType ?? meta?.endpoint,
|
|
75
|
+
error.requestUrl ? String(error.requestUrl).split('?')[0].slice(0, 80) : undefined,
|
|
76
|
+
error.responseCode === undefined ? undefined : `平台码 ${error.responseCode}`,
|
|
77
|
+
error.platform?.code === undefined ? undefined : `平台码 ${error.platform.code}`,
|
|
78
|
+
error.http?.status === undefined ? undefined : `HTTP ${error.http.status}`,
|
|
79
|
+
meta?.requestId === undefined ? undefined : `requestId=${meta.requestId}`,
|
|
80
|
+
meta?.attempts === undefined ? undefined : `attempts=${meta.attempts}`
|
|
81
|
+
].filter((part) => typeof part === 'string' && part !== '');
|
|
82
|
+
return `[${kind}/${code ?? '-'}] ${reason}${facts.length > 0 ? ` (${facts.join(' ')})` : ''}`;
|
|
83
|
+
};
|
|
84
|
+
/** Amagi 失败异常:`message` 是一行摘要,结构化字段各有属性,完整信封在 {@link AmagiError.envelope} */
|
|
85
|
+
class AmagiError extends Error {
|
|
86
|
+
/** 平台业务码,见 {@link legacyCode} */
|
|
87
|
+
code;
|
|
88
|
+
/** 平台原始响应体。v7 只在 `debug: true` 下填 `error.raw`(B站风控要读里面的 `v_voucher`) */
|
|
89
|
+
data;
|
|
90
|
+
/** v7 错误契约本体,等价于失败信封的 `error` */
|
|
91
|
+
rawError;
|
|
92
|
+
/** 错误大类 */
|
|
93
|
+
kind;
|
|
94
|
+
/** amagi 自己的字符串错误码 */
|
|
95
|
+
amagiCode;
|
|
96
|
+
/** 平台返回的原文,不带前缀与归因 */
|
|
97
|
+
reason;
|
|
98
|
+
/** 是否值得重试 */
|
|
99
|
+
retryable;
|
|
100
|
+
/** 真实发生的 HTTP 状态 */
|
|
101
|
+
httpStatus;
|
|
102
|
+
/** 参数校验的字段级错误,仅 `kind === 'validation'` 时有 */
|
|
103
|
+
issues;
|
|
104
|
+
/** 整条失败信封,`meta.requestId` / `attempts` / `durationMs` 在里面 */
|
|
105
|
+
envelope;
|
|
106
|
+
constructor(envelope) {
|
|
107
|
+
const error = envelope.error ?? {};
|
|
108
|
+
super(describeFailure(envelope));
|
|
109
|
+
this.name = 'AmagiError';
|
|
110
|
+
this.code = legacyCode(error, envelope);
|
|
111
|
+
// 平台原始响应体:v7 在 error.raw,6.6.0 在信封顶层 data(B站风控要读里面的 v_voucher)
|
|
112
|
+
this.data = error.raw ?? envelope.data;
|
|
113
|
+
this.rawError = error;
|
|
114
|
+
this.kind = (error.kind ?? 'api');
|
|
115
|
+
this.amagiCode = error.code ?? envelope.code;
|
|
116
|
+
this.reason = error.errorDescription ?? error.message ?? envelope.message ?? '未知错误';
|
|
117
|
+
this.retryable = typeof error.retryable === 'boolean' ? error.retryable : false;
|
|
118
|
+
this.httpStatus = error.http?.status;
|
|
119
|
+
this.issues = error.issues;
|
|
120
|
+
this.envelope = envelope;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.AmagiError = AmagiError;
|
|
124
|
+
/**
|
|
125
|
+
* 判断一个值是不是失败信封。**只认 `success`**:v7 信封顶层没有 `code`(三种码各归各位),
|
|
126
|
+
* 拿 `code` 当特征判别恒假 —— 失败被原样透传、`try/catch` 全失效、取数失败但流程继续,且零编译错误。
|
|
127
|
+
*/
|
|
128
|
+
const isFailureEnvelope = (value) => {
|
|
129
|
+
if (!value || typeof value !== 'object')
|
|
130
|
+
return false;
|
|
131
|
+
const envelope = value;
|
|
132
|
+
return envelope.success === false && typeof envelope.message === 'string' && !!envelope.error;
|
|
133
|
+
};
|
|
134
|
+
/** 判断是不是 thenable,用来只包装异步方法 */
|
|
135
|
+
const isThenable = (value) => !!value && (typeof value === 'object' || typeof value === 'function') && typeof value.then === 'function';
|
|
136
|
+
/**
|
|
137
|
+
* 递归代理一个 fetcher 对象,把失败信封转成 `throw AmagiError`。返回类型与入参同形 ——
|
|
138
|
+
* 「只保留成功分支」是**类型层**由 {@link ThrowingClient} 声明的,这里只管运行时行为。
|
|
139
|
+
*/
|
|
140
|
+
const throwOnFailure = (target) => new Proxy(target, {
|
|
141
|
+
get(obj, prop) {
|
|
142
|
+
const value = obj[prop];
|
|
143
|
+
if (typeof value === 'function') {
|
|
144
|
+
return (...args) => {
|
|
145
|
+
const returned = value.apply(obj, args);
|
|
146
|
+
// 同步方法原样放行:包成 async 会把返回值套一层 Promise,破坏语义
|
|
147
|
+
if (!isThenable(returned))
|
|
148
|
+
return returned;
|
|
149
|
+
return returned.then((result) => {
|
|
150
|
+
if (isFailureEnvelope(result))
|
|
151
|
+
throw new AmagiError(result);
|
|
152
|
+
return result;
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
157
|
+
return throwOnFailure(value);
|
|
158
|
+
}
|
|
159
|
+
return value;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
/** 解析库基类 */
|
|
163
|
+
class AmagiBase {
|
|
164
|
+
/**
|
|
165
|
+
* 原始 v7 客户端。
|
|
166
|
+
*
|
|
167
|
+
* `events` / `on` / `once` / `login` / `startServer` 从这里取 —— 它们不是 fetcher,
|
|
168
|
+
* 不该被「失败必抛」的代理碰(`on` 返回退订函数,包成 async 就废了)。
|
|
169
|
+
*/
|
|
170
|
+
rawAmagi;
|
|
171
|
+
/** 解析库实例,四个平台的 fetcher 失败即抛 */
|
|
172
|
+
amagi;
|
|
173
|
+
/** 当前客户端使用的配置快照,用于避免文件监听与显式重载造成重复初始化 */
|
|
174
|
+
configSignature;
|
|
175
|
+
constructor() {
|
|
176
|
+
const client = this.createAmagiClient();
|
|
177
|
+
this.rawAmagi = client;
|
|
178
|
+
this.amagi = this.wrapAmagiClient(client);
|
|
179
|
+
this.configSignature = this.getConfigSignature();
|
|
180
|
+
}
|
|
181
|
+
/** 获取会影响 Amagi 运行状态的配置快照 */
|
|
182
|
+
getConfigSignature = () => JSON.stringify(Config_1.Config.amagi);
|
|
183
|
+
/** 创建解析库实例 */
|
|
184
|
+
createAmagiClient = () => {
|
|
185
|
+
const amagi = Config_1.Config.amagi;
|
|
186
|
+
return (0, amagi_1.default)({
|
|
187
|
+
cookies: amagi.cookies || {},
|
|
188
|
+
request: {
|
|
189
|
+
timeout: amagi.timeout,
|
|
190
|
+
headers: { 'User-Agent': amagi['User-Agent'] },
|
|
191
|
+
proxy: amagi.proxy?.switch ? amagi.proxy : false
|
|
192
|
+
},
|
|
193
|
+
// B站风控要读失败响应里的 `v_voucher`,而 v7 只在 debug 下才填 `error.raw`
|
|
194
|
+
// —— 不开的话 `AmagiError.data` 连键都没有,整条风控验证流程静默失效
|
|
195
|
+
debug: true
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
/**
|
|
199
|
+
* 重载配置 - 重新创建 Amagi Client 实例
|
|
200
|
+
* @returns 配置发生变化并完成重载时返回 true
|
|
201
|
+
*/
|
|
202
|
+
reloadConfig() {
|
|
203
|
+
const nextConfigSignature = this.getConfigSignature();
|
|
204
|
+
if (nextConfigSignature === this.configSignature) {
|
|
205
|
+
node_karin_1.logger.debug('[AmagiClient] 配置未变化,跳过重复重载');
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
node_karin_1.logger.debug('[AmagiClient] 检测到配置变化,正在重载...');
|
|
209
|
+
const client = this.createAmagiClient();
|
|
210
|
+
this.rawAmagi = client;
|
|
211
|
+
this.amagi = this.wrapAmagiClient(client);
|
|
212
|
+
this.configSignature = nextConfigSignature;
|
|
213
|
+
node_karin_1.logger.debug('[AmagiClient] 配置重载完成');
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
/** 只把四个平台的 fetcher 换成失败必抛形态,client 的其余键原样带过去 */
|
|
217
|
+
wrapAmagiClient = (client) => ({
|
|
218
|
+
...client,
|
|
219
|
+
bilibili: { ...client.bilibili, fetcher: throwOnFailure(client.bilibili.fetcher) },
|
|
220
|
+
douyin: { ...client.douyin, fetcher: throwOnFailure(client.douyin.fetcher) },
|
|
221
|
+
kuaishou: { ...client.kuaishou, fetcher: throwOnFailure(client.kuaishou.fetcher) },
|
|
222
|
+
xiaohongshu: { ...client.xiaohongshu, fetcher: throwOnFailure(client.xiaohongshu.fetcher) }
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
exports.AmagiBase = AmagiBase;
|
|
226
|
+
/** 软错误码:命中这些平台业务码时不抛异常,按失败信封返回。Bilibili `12061` - UP主已关闭评论区 */
|
|
227
|
+
exports.SOFT_ERROR_CODES = {
|
|
228
|
+
BILIBILI_COMMENTS_DISABLED: 12061
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* 调用 amagi fetcher 方法,允许特定平台业务码以失败信封返回而不是抛异常。
|
|
232
|
+
* @param fn - 经过代理包装的 amagi 方法调用
|
|
233
|
+
* @param allowedCodes - 不应抛出异常的平台业务码列表
|
|
234
|
+
* @returns 成功信封,或命中 `allowedCodes` 的软失败
|
|
235
|
+
*/
|
|
236
|
+
const softFetch = async (fn, allowedCodes) => {
|
|
237
|
+
try {
|
|
238
|
+
return await fn();
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
if (err instanceof AmagiError && allowedCodes.includes(err.code)) {
|
|
242
|
+
return { ...err.envelope, code: err.code };
|
|
243
|
+
}
|
|
244
|
+
throw err;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
exports.softFetch = softFetch;
|
|
248
|
+
/**
|
|
249
|
+
* {@link softFetch} 的结果是否命中某个软错误码。
|
|
250
|
+
*
|
|
251
|
+
* 是类型守卫而不是 `result.code === x`:`code` 的类型是 `number` 不是字面量,
|
|
252
|
+
* 直接比较不会收窄联合,`else` 分支里的 `data` 仍是 `T | undefined`。
|
|
253
|
+
*/
|
|
254
|
+
const isSoftFailure = (result, ...codes) => !result.success && codes.includes(result.code);
|
|
255
|
+
exports.isSoftFailure = isSoftFailure;
|
|
256
|
+
const amagiClientInstance = new AmagiBase();
|
|
257
|
+
/** 需要随 Amagi Client 一同刷新的运行时资源,例如已经挂载的 HTTP Router */
|
|
258
|
+
const amagiReloadListeners = new Set();
|
|
259
|
+
/**
|
|
260
|
+
* 注册 Amagi 配置重载监听器。
|
|
261
|
+
* @param listener - 重载后要执行的回调
|
|
262
|
+
* @returns 注销当前监听器的函数
|
|
263
|
+
*/
|
|
264
|
+
const registerAmagiReloadListener = (listener) => {
|
|
265
|
+
amagiReloadListeners.add(listener);
|
|
266
|
+
return () => amagiReloadListeners.delete(listener);
|
|
267
|
+
};
|
|
268
|
+
exports.registerAmagiReloadListener = registerAmagiReloadListener;
|
|
269
|
+
/**
|
|
270
|
+
* 四个平台的「失败必抛」fetcher。
|
|
271
|
+
*
|
|
272
|
+
* 类型必须显式标注:不标的话 TS 要在声明产物里展开 fetcher 的结构,而响应类型桶只导出
|
|
273
|
+
* `BilibiliVideoInfoResponse` 这样的具名别名、不导出底层的 `*_V0`,展开时叫不出名来报 TS2883。
|
|
274
|
+
*/
|
|
275
|
+
exports.bilibiliFetcher = amagiClientInstance.amagi.bilibili.fetcher;
|
|
276
|
+
exports.douyinFetcher = amagiClientInstance.amagi.douyin.fetcher;
|
|
277
|
+
exports.kuaishouFetcher = amagiClientInstance.amagi.kuaishou.fetcher;
|
|
278
|
+
exports.xiaohongshuFetcher = amagiClientInstance.amagi.xiaohongshu.fetcher;
|
|
279
|
+
/**
|
|
280
|
+
* 原始 v7 客户端。扫码登录会话(`douyin.login` / `bilibili.login`)、实例级事件总线
|
|
281
|
+
* (`events` / `on` / `once`)与 `startServer` 都从这里取。
|
|
282
|
+
*
|
|
283
|
+
* 返回类型显式写成 {@link AmagiClient}:不写的话 TS 要在声明产物里展开这个结构,
|
|
284
|
+
* 会碰到 amagi 内部才叫得出名字的类型(如 `SearchNoteType`),报 TS4023。
|
|
285
|
+
*/
|
|
286
|
+
/**
|
|
287
|
+
* 原始 v7 客户端,并补上 v7 才有的登录会话命名空间(`bilibili.login` / `douyin.login`)。
|
|
288
|
+
*
|
|
289
|
+
* 已发布的 amagi 6.6.0 的 client 上没有 `login`,上游登录代码会直接读崩,
|
|
290
|
+
* 因此这里用 Proxy 在读取 `bilibili` / `douyin` 时挂上本地实现的会话(见 ./loginSession)。
|
|
291
|
+
* 其余属性原样转发,并对函数做 bind,保证 `events` / `on` / `once` / `startServer` 行为不变。
|
|
292
|
+
*/
|
|
293
|
+
const clientWrapperCache = new WeakMap();
|
|
294
|
+
const getAmagiClient = () => {
|
|
295
|
+
const raw = amagiClientInstance.rawAmagi;
|
|
296
|
+
const cached = clientWrapperCache.get(raw);
|
|
297
|
+
if (cached)
|
|
298
|
+
return cached;
|
|
299
|
+
// 登录相关接口在**模块级 fetcher** 上(client.douyin.fetcher 是绑定过的精简版,没有 passport 方法);
|
|
300
|
+
// 这里用惰性代理,保证 reloadAmagiConfig() 重建 client 后拿到的仍是新实例。
|
|
301
|
+
const lazyFetcher = (get) => new Proxy({}, {
|
|
302
|
+
get: (_target, prop) => Reflect.get(get(), prop)
|
|
303
|
+
});
|
|
304
|
+
const wrapped = new Proxy(raw, {
|
|
305
|
+
get(target, prop) {
|
|
306
|
+
if (prop === 'bilibili') {
|
|
307
|
+
return { ...target.bilibili, login: (0, loginSession_1.createBilibiliLoginSession)(lazyFetcher(() => exports.bilibiliFetcher)) };
|
|
308
|
+
}
|
|
309
|
+
if (prop === 'douyin') {
|
|
310
|
+
return { ...target.douyin, login: (0, loginSession_1.createDouyinLoginSession)(lazyFetcher(() => amagi_1.douyinFetcher)) };
|
|
311
|
+
}
|
|
312
|
+
const value = Reflect.get(target, prop, target);
|
|
313
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
clientWrapperCache.set(raw, wrapped);
|
|
317
|
+
return wrapped;
|
|
318
|
+
};
|
|
319
|
+
exports.getAmagiClient = getAmagiClient;
|
|
320
|
+
const reloadAmagiConfig = () => {
|
|
321
|
+
if (!amagiClientInstance.reloadConfig())
|
|
322
|
+
return false;
|
|
323
|
+
// ESM 的 `export let` 是实时绑定:Client 重建后要同步替换,否则调用方还持有旧实例截取的引用
|
|
324
|
+
exports.bilibiliFetcher = amagiClientInstance.amagi.bilibili.fetcher;
|
|
325
|
+
exports.douyinFetcher = amagiClientInstance.amagi.douyin.fetcher;
|
|
326
|
+
exports.kuaishouFetcher = amagiClientInstance.amagi.kuaishou.fetcher;
|
|
327
|
+
exports.xiaohongshuFetcher = amagiClientInstance.amagi.xiaohongshu.fetcher;
|
|
328
|
+
for (const listener of amagiReloadListeners) {
|
|
329
|
+
try {
|
|
330
|
+
listener();
|
|
331
|
+
}
|
|
332
|
+
catch (error) {
|
|
333
|
+
node_karin_1.logger.error(`[AmagiClient] 运行时资源重载失败: ${error}`);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
};
|
|
338
|
+
exports.reloadAmagiConfig = reloadAmagiConfig;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveAvatar = exports.buildDitherAvatar = void 0;
|
|
4
|
+
const node_zlib_1 = require("node:zlib");
|
|
5
|
+
const avatars_1 = require("@outpacelabs/avatars");
|
|
6
|
+
const node_karin_1 = require("../../../compat/node-karin.js");
|
|
7
|
+
/**
|
|
8
|
+
* 头像解析:优先用平台给的真实头像,拿不到就**实时生成**一个 dither 头像。
|
|
9
|
+
*
|
|
10
|
+
* 为什么需要它:部分适配器(比如 QQBot)有概率拿不到群头像,
|
|
11
|
+
* 榜单里就会空出一排位置,看起来像数据缺了。生成头像保证**每一行都一定有个头像**,
|
|
12
|
+
* 而且种子取自群号/用户ID,同一个人每次渲染出的图案是稳定的,不会刷一次变一个样。
|
|
13
|
+
*
|
|
14
|
+
* ## 为什么不用库自带的 `<GradientAvatar>` 组件
|
|
15
|
+
*
|
|
16
|
+
* 那是个 `<canvas>` + effect 绘制的 React 组件,库自己也标了 "Browser only"。
|
|
17
|
+
* 而海报产物是**纯静态 HTML、不含任何 `<script>`**(ktr 模板链路的硬约束),
|
|
18
|
+
* 浏览器加载后没有任何 JS 去执行那个 effect,canvas 里会是一片空白。
|
|
19
|
+
*
|
|
20
|
+
* 所以这里走库的底层 API `drawDither`:它只用到 `fillStyle` 和 `fillRect`
|
|
21
|
+
* (纯格子填充,没有渐变也没有合成),而库把绘制接口抽象成了 `GradientContext`
|
|
22
|
+
* —— 注释里写明「HTMLCanvasElement 和 OffscreenCanvas 的 2D context 都满足它」,
|
|
23
|
+
* 也就是说这是个公开的扩展点。用一个只记录矩形的小对象驱动它即可,
|
|
24
|
+
* 不必为了画个头像往 Node 里塞一整个 Canvas 实现。
|
|
25
|
+
*/
|
|
26
|
+
/**
|
|
27
|
+
* 生成头像时喂给库的尺寸。
|
|
28
|
+
*
|
|
29
|
+
* **这个值直接决定图案的精细度**,不是"画多大":库内部按 `clamp(floor(size/3), 8, 64)` 算格数,
|
|
30
|
+
* 按 `log2(size/16)/log2(160/16)` 算用几种颜色 —— 传 40 只会得到 13×13 格、**3 种颜色**,
|
|
31
|
+
* 看起来就是一块粗糙的马赛克;160 才是它调色板拉满(4 色、53 格)的档位。
|
|
32
|
+
* 海报上头像是缩放着显示的,所以这里按满细节渲染,由显示端缩到 40~48px。
|
|
33
|
+
*/
|
|
34
|
+
const RENDER_SIZE = 160;
|
|
35
|
+
/** 拉取真实头像的超时 */
|
|
36
|
+
const FETCH_TIMEOUT_MS = 4000;
|
|
37
|
+
/** 解析结果缓存条数上限,防止长时间运行把内存吃满 */
|
|
38
|
+
const CACHE_LIMIT = 200;
|
|
39
|
+
/** 已解析过的头像(URL → data URI),避免反复打同一个 CDN */
|
|
40
|
+
const cache = new Map();
|
|
41
|
+
/**
|
|
42
|
+
* 跑一遍库的 dither 绘制,把方块录下来。
|
|
43
|
+
*
|
|
44
|
+
* 传进去的 context 只需满足 `GradientContext`:dither 路径只用 `fillStyle` + `fillRect`,
|
|
45
|
+
* `createRadialGradient` 是 mesh 路径才需要的,这里直接抛错 —— 真被调到说明库的用法变了。
|
|
46
|
+
*/
|
|
47
|
+
const recordDither = (seed, size) => {
|
|
48
|
+
const rects = [];
|
|
49
|
+
const context = {
|
|
50
|
+
fillStyle: '#000000',
|
|
51
|
+
fillRect(x, y, w, h) {
|
|
52
|
+
rects.push({ x, y, w, h, color: context.fillStyle });
|
|
53
|
+
},
|
|
54
|
+
createRadialGradient() {
|
|
55
|
+
throw new Error('dither 路径不应调用 createRadialGradient');
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
(0, avatars_1.drawDither)(context, seed, size);
|
|
59
|
+
return rects;
|
|
60
|
+
};
|
|
61
|
+
/** 把录到的方块画进一张 RGBA 位图,并裁成圆形 */
|
|
62
|
+
const rasterize = (rects, size) => {
|
|
63
|
+
// 起点全透明,圆形之外的部分自然留空
|
|
64
|
+
const rgba = Buffer.alloc(size * size * 4);
|
|
65
|
+
for (const rect of rects) {
|
|
66
|
+
const raw = rect.color.replace('#', '');
|
|
67
|
+
const r = parseInt(raw.slice(0, 2), 16);
|
|
68
|
+
const g = parseInt(raw.slice(2, 4), 16);
|
|
69
|
+
const b = parseInt(raw.slice(4, 6), 16);
|
|
70
|
+
const a = raw.length >= 8 ? parseInt(raw.slice(6, 8), 16) : 255;
|
|
71
|
+
for (let y = rect.y; y < rect.y + rect.h && y < size; y++) {
|
|
72
|
+
for (let x = rect.x; x < rect.x + rect.w && x < size; x++) {
|
|
73
|
+
const offset = (y * size + x) * 4;
|
|
74
|
+
rgba[offset] = r;
|
|
75
|
+
rgba[offset + 1] = g;
|
|
76
|
+
rgba[offset + 2] = b;
|
|
77
|
+
rgba[offset + 3] = a;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// 圆形裁切。边缘不做抗锯齿 —— 海报里头像是缩小显示的,降采样本身就会把边缘磨平
|
|
82
|
+
const half = size / 2;
|
|
83
|
+
for (let y = 0; y < size; y++) {
|
|
84
|
+
for (let x = 0; x < size; x++) {
|
|
85
|
+
const dx = x + 0.5 - half;
|
|
86
|
+
const dy = y + 0.5 - half;
|
|
87
|
+
if (dx * dx + dy * dy > half * half)
|
|
88
|
+
rgba[(y * size + x) * 4 + 3] = 0;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return rgba;
|
|
92
|
+
};
|
|
93
|
+
/** PNG 的 CRC32 查表 */
|
|
94
|
+
const CRC_TABLE = (() => {
|
|
95
|
+
const table = new Uint32Array(256);
|
|
96
|
+
for (let n = 0; n < 256; n++) {
|
|
97
|
+
let c = n;
|
|
98
|
+
for (let k = 0; k < 8; k++)
|
|
99
|
+
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
100
|
+
table[n] = c >>> 0;
|
|
101
|
+
}
|
|
102
|
+
return table;
|
|
103
|
+
})();
|
|
104
|
+
/** 算一段字节的 CRC32 */
|
|
105
|
+
const crc32 = (buffer) => {
|
|
106
|
+
let c = 0xffffffff;
|
|
107
|
+
for (const byte of buffer)
|
|
108
|
+
c = CRC_TABLE[(c ^ byte) & 0xff] ^ (c >>> 8);
|
|
109
|
+
return (c ^ 0xffffffff) >>> 0;
|
|
110
|
+
};
|
|
111
|
+
/** 拼一个 PNG 数据块:长度 + 类型 + 内容 + CRC */
|
|
112
|
+
const pngChunk = (type, data) => {
|
|
113
|
+
const length = Buffer.alloc(4);
|
|
114
|
+
length.writeUInt32BE(data.length);
|
|
115
|
+
const typeBuffer = Buffer.from(type, 'ascii');
|
|
116
|
+
const crc = Buffer.alloc(4);
|
|
117
|
+
crc.writeUInt32BE(crc32(Buffer.concat([typeBuffer, data])));
|
|
118
|
+
return Buffer.concat([length, typeBuffer, data, crc]);
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* 把 RGBA 位图编码成 PNG。
|
|
122
|
+
*
|
|
123
|
+
* 手写而不引依赖:这里只需要最朴素的 8 位真彩 + 无滤波,格式本身很短,
|
|
124
|
+
* 压缩交给 Node 自带的 zlib。**是无损的** —— 不存在因为"图太大"而掉画质的问题。
|
|
125
|
+
*/
|
|
126
|
+
const encodePng = (rgba, size) => {
|
|
127
|
+
const header = Buffer.alloc(13);
|
|
128
|
+
header.writeUInt32BE(size, 0);
|
|
129
|
+
header.writeUInt32BE(size, 4);
|
|
130
|
+
header[8] = 8; // 位深
|
|
131
|
+
header[9] = 6; // 颜色类型:真彩 + alpha
|
|
132
|
+
// 剩下三个字节保持 0:deflate 压缩、自适应滤波、非隔行
|
|
133
|
+
// 每一行前面要加一个滤波类型字节(0 = 不滤波)
|
|
134
|
+
const stride = size * 4;
|
|
135
|
+
const raw = Buffer.alloc((stride + 1) * size);
|
|
136
|
+
for (let y = 0; y < size; y++) {
|
|
137
|
+
raw[y * (stride + 1)] = 0;
|
|
138
|
+
rgba.copy(raw, y * (stride + 1) + 1, y * stride, (y + 1) * stride);
|
|
139
|
+
}
|
|
140
|
+
return Buffer.concat([
|
|
141
|
+
Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]),
|
|
142
|
+
pngChunk('IHDR', header),
|
|
143
|
+
pngChunk('IDAT', (0, node_zlib_1.deflateSync)(raw, { level: 9 })),
|
|
144
|
+
pngChunk('IEND', Buffer.alloc(0))
|
|
145
|
+
]);
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* 生成一个确定性头像(dither 类型)
|
|
149
|
+
* @param seed 种子,传群号或用户ID,保证同一实体每次得到的图案一致
|
|
150
|
+
*/
|
|
151
|
+
const buildDitherAvatar = (seed) => `data:image/png;base64,${encodePng(rasterize(recordDither(seed, RENDER_SIZE), RENDER_SIZE), RENDER_SIZE).toString('base64')}`;
|
|
152
|
+
exports.buildDitherAvatar = buildDitherAvatar;
|
|
153
|
+
/**
|
|
154
|
+
* 把真实头像包成一张圆形裁切的 SVG。
|
|
155
|
+
*
|
|
156
|
+
* 圆角只能在包装层做:ECharts 富文本的 `backgroundColor.image` 不支持 `borderRadius`
|
|
157
|
+
* (实测不会生成 clipPath),不包的话头像在图里是方的。
|
|
158
|
+
* 这里**不重新编码图片**,只是套一层带 clipPath 的 SVG 外壳。
|
|
159
|
+
*/
|
|
160
|
+
const buildRemoteAvatar = (bytes, mime, size) => {
|
|
161
|
+
const half = size / 2;
|
|
162
|
+
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${size}" height="${size}" viewBox="0 0 ${size} ${size}">` +
|
|
163
|
+
`<defs><clipPath id="c"><circle cx="${half}" cy="${half}" r="${half}"/></clipPath></defs>` +
|
|
164
|
+
`<g clip-path="url(#c)"><image href="data:${mime};base64,${bytes.toString('base64')}" width="${size}" height="${size}" preserveAspectRatio="xMidYMid slice"/></g>` +
|
|
165
|
+
`</svg>`;
|
|
166
|
+
return `data:image/svg+xml;base64,${Buffer.from(svg).toString('base64')}`;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* 解析一个头像:有 URL 就拉下来,任何一步失败都回落到生成头像。
|
|
170
|
+
*
|
|
171
|
+
* **绝不抛错** —— 统计海报是锦上添花的功能,不能因为某个 CDN 抽风就整张渲染不出来。
|
|
172
|
+
* @param seed 种子(群号 / 用户ID),决定生成头像的图案
|
|
173
|
+
* @param url 平台给的头像地址;拿不到时传 undefined
|
|
174
|
+
* @param size 圆形包装的边长(px),只影响真实头像那条路径
|
|
175
|
+
*/
|
|
176
|
+
const resolveAvatar = async (seed, url, size = 48) => {
|
|
177
|
+
if (url) {
|
|
178
|
+
const cached = cache.get(url);
|
|
179
|
+
if (cached)
|
|
180
|
+
return cached;
|
|
181
|
+
try {
|
|
182
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(FETCH_TIMEOUT_MS) });
|
|
183
|
+
if (response.ok) {
|
|
184
|
+
const bytes = Buffer.from(await response.arrayBuffer());
|
|
185
|
+
if (bytes.byteLength > 0) {
|
|
186
|
+
// 原样内联,不重新编码也不缩放 —— 尺寸由 `getAvatarUrl(id, size)` 那头定好了
|
|
187
|
+
const dataUri = buildRemoteAvatar(bytes, response.headers.get('content-type')?.split(';')[0] || 'image/png', size);
|
|
188
|
+
if (cache.size >= CACHE_LIMIT)
|
|
189
|
+
cache.delete(cache.keys().next().value);
|
|
190
|
+
cache.set(url, dataUri);
|
|
191
|
+
return dataUri;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
node_karin_1.logger.debug('[统计] 获取头像失败,改用生成头像:', error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return (0, exports.buildDitherAvatar)(seed);
|
|
200
|
+
};
|
|
201
|
+
exports.resolveAvatar = resolveAvatar;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.resolveTriggerAvatarUrl = exports.resolveUsableBot = exports.getReachableMasterBots = void 0;
|
|
37
|
+
const node_karin_1 = __importStar(require("../../../compat/node-karin.js"));
|
|
38
|
+
const Config_1 = require("../../module/utils/Config");
|
|
39
|
+
const Base_1 = require("./Base");
|
|
40
|
+
/**
|
|
41
|
+
* 获取候选机器人
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
const getCandidateBots = () => {
|
|
45
|
+
return node_karin_1.default
|
|
46
|
+
.getAllBotList()
|
|
47
|
+
.map((item) => item.bot)
|
|
48
|
+
.filter((bot) => bot.account.name !== 'console');
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* 获取非console主机器人ID列表
|
|
52
|
+
* @param masters - 主机器人ID列表
|
|
53
|
+
* @returns
|
|
54
|
+
*/
|
|
55
|
+
const getNonConsoleMasters = (masters = node_karin_1.config.master()) => {
|
|
56
|
+
return masters.filter((id) => id !== 'console');
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* 获取可访问的主机器人
|
|
60
|
+
* @param masters - 主机器人ID列表
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
const getReachableMasterBots = async (masters = node_karin_1.config.master()) => {
|
|
64
|
+
const owners = getNonConsoleMasters(masters);
|
|
65
|
+
if (owners.length === 0)
|
|
66
|
+
return [];
|
|
67
|
+
const bots = getCandidateBots();
|
|
68
|
+
if (bots.length === 0)
|
|
69
|
+
return [];
|
|
70
|
+
const friendsMap = new Map();
|
|
71
|
+
await Promise.all(bots.map(async (bot) => {
|
|
72
|
+
try {
|
|
73
|
+
const list = await bot.getFriendList();
|
|
74
|
+
friendsMap.set(bot.account.selfId, Array.isArray(list) ? list : []);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
friendsMap.set(bot.account.selfId, []);
|
|
78
|
+
}
|
|
79
|
+
}));
|
|
80
|
+
const result = [];
|
|
81
|
+
for (const master of owners) {
|
|
82
|
+
const matchedBot = bots.find((bot) => {
|
|
83
|
+
return (friendsMap.get(bot.account.selfId) || []).some((friend) => friend.userId === master);
|
|
84
|
+
});
|
|
85
|
+
if (matchedBot) {
|
|
86
|
+
result.push({ master, bot: matchedBot });
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return result;
|
|
90
|
+
};
|
|
91
|
+
exports.getReachableMasterBots = getReachableMasterBots;
|
|
92
|
+
/**
|
|
93
|
+
* 获取一个最少能用的机器人实例,优先级:1. selfId 参数指定的机器人 2. 可访问主人机器人中的第一个 3. pushlist 中活跃的机器人 4. 任意一个在线机器人
|
|
94
|
+
* @param selfId - 机器人ID
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
const resolveUsableBot = async (selfId) => {
|
|
98
|
+
if (selfId) {
|
|
99
|
+
const matchedBot = node_karin_1.default.getBot(selfId);
|
|
100
|
+
if (matchedBot)
|
|
101
|
+
return matchedBot;
|
|
102
|
+
}
|
|
103
|
+
const reachable = await (0, exports.getReachableMasterBots)();
|
|
104
|
+
if (reachable.length > 0)
|
|
105
|
+
return reachable[0].bot;
|
|
106
|
+
const { douyin, bilibili } = (0, Base_1.statBotId)(Config_1.Config.pushlist);
|
|
107
|
+
const preferredBotId = douyin.botId || bilibili.botId;
|
|
108
|
+
if (preferredBotId) {
|
|
109
|
+
const matchedBot = node_karin_1.default.getBot(preferredBotId);
|
|
110
|
+
if (matchedBot)
|
|
111
|
+
return matchedBot;
|
|
112
|
+
}
|
|
113
|
+
const fallbackBotId = node_karin_1.default.getAllBotID()[0];
|
|
114
|
+
if (!fallbackBotId)
|
|
115
|
+
return undefined;
|
|
116
|
+
return node_karin_1.default.getBot(fallbackBotId);
|
|
117
|
+
};
|
|
118
|
+
exports.resolveUsableBot = resolveUsableBot;
|
|
119
|
+
/**
|
|
120
|
+
* 取触发者头像 URL,用于嵌到登录二维码中心当 logo。
|
|
121
|
+
*
|
|
122
|
+
* 适配器(如 console)可能不实现 getAvatarUrl 或返回空串,模板侧 avatarUrl 缺省即退化为普通二维码,
|
|
123
|
+
* 所以这里任何失败都只记 debug 日志并返回 undefined,不影响登录流程。
|
|
124
|
+
*
|
|
125
|
+
* @param e - 触发登录的消息事件
|
|
126
|
+
* @returns 头像 URL,取不到时为 undefined
|
|
127
|
+
*/
|
|
128
|
+
const resolveTriggerAvatarUrl = async (e) => {
|
|
129
|
+
const userId = e.sender?.userId || e.userId;
|
|
130
|
+
if (!userId)
|
|
131
|
+
return undefined;
|
|
132
|
+
try {
|
|
133
|
+
const url = await e.bot.getAvatarUrl(userId);
|
|
134
|
+
return url || undefined;
|
|
135
|
+
}
|
|
136
|
+
catch (error) {
|
|
137
|
+
node_karin_1.logger.debug('[koishi-plugin-kkk] 获取触发者头像失败,二维码将不嵌入头像:', error);
|
|
138
|
+
return undefined;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
exports.resolveTriggerAvatarUrl = resolveTriggerAvatarUrl;
|