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,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 冒烟测试:QQ 平台的解析交互面板(Markdown + 原生按钮)。
|
|
3
|
+
*
|
|
4
|
+
* 覆盖:
|
|
5
|
+
* 1. QQ 平台发链接 → 只回面板(不回解析结果,也不会真的去下载视频);
|
|
6
|
+
* 2. 面板里的画质按钮遵守体积上限(默认 200MB),超限档位不生成按钮;
|
|
7
|
+
* 3. 「视频+弹幕」按钮 = 带 --panel=1 的同一条命令,点了重新渲染面板并高亮;
|
|
8
|
+
* 4. 参数覆盖真的生效:runWithParseOverride 里 Config.bilibili.videoQuality 变成按钮选的档位;
|
|
9
|
+
* 5. 抖音走的是同一套面板逻辑(用固定数据验证:4K 300MB 那一档必须被隐藏);
|
|
10
|
+
* 6. 非 QQ 平台 / 关掉面板开关 → 行为不变。
|
|
11
|
+
*
|
|
12
|
+
* 用法:node scripts/smoke-qqpanel.cjs
|
|
13
|
+
*/
|
|
14
|
+
const path = require('node:path')
|
|
15
|
+
const { Context } = require('koishi')
|
|
16
|
+
|
|
17
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
18
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke')
|
|
19
|
+
const target = 'https://www.bilibili.com/video/BV1xx411c7mD'
|
|
20
|
+
|
|
21
|
+
/* ------------------------------------------------------------------ *
|
|
22
|
+
* 抖音侧固定数据(没有 Cookie 时抖音接口必被风控,这里只验证展示与选档逻辑)
|
|
23
|
+
* ------------------------------------------------------------------ */
|
|
24
|
+
const axios = require(path.join(pluginRoot, 'node_modules/axios'))
|
|
25
|
+
const realAxiosGet = axios.get
|
|
26
|
+
const LONG_URL = 'https://www.douyin.com/video/7123456789012345678'
|
|
27
|
+
axios.get = async (url, options) => {
|
|
28
|
+
if (typeof url === 'string' && url.includes('douyin')) return { request: { res: { responseUrl: LONG_URL } }, data: '' }
|
|
29
|
+
return realAxiosGet(url, options)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const makeBitRate = (definition, sizeMB) => ({
|
|
33
|
+
gear_name: definition,
|
|
34
|
+
quality_type: 28,
|
|
35
|
+
bit_rate: 1000000,
|
|
36
|
+
FPS: 30,
|
|
37
|
+
format: 'mp4',
|
|
38
|
+
video_extra: JSON.stringify({ definition }),
|
|
39
|
+
play_addr: { uri: 'v', url_list: ['https://www.w3schools.com/html/mov_bbb.mp4'], data_size: Math.round(sizeMB * 1024 * 1024) }
|
|
40
|
+
})
|
|
41
|
+
const douyinDetail = {
|
|
42
|
+
aweme_id: '7123456789012345678',
|
|
43
|
+
aweme_type: 0,
|
|
44
|
+
is_slides: false,
|
|
45
|
+
desc: '【面板验证】抖音视频解析测试',
|
|
46
|
+
preview_title: '【面板验证】抖音视频解析测试',
|
|
47
|
+
create_time: Math.floor(Date.now() / 1000) - 3600,
|
|
48
|
+
share_url: LONG_URL,
|
|
49
|
+
author: { uid: '1', sec_uid: 'SEC', nickname: '测试作者', avatar_thumb: { url_list: ['https://www.w3schools.com/html/pic_trulli.jpg'] } },
|
|
50
|
+
statistics: { digg_count: 1, comment_count: 1, share_count: 1, collect_count: 1, play_count: 1 },
|
|
51
|
+
images: null,
|
|
52
|
+
music: null,
|
|
53
|
+
video: {
|
|
54
|
+
play_addr: { uri: 'v', url_list: ['https://www.w3schools.com/html/mov_bbb.mp4'], data_size: 20971520 },
|
|
55
|
+
cover: { url_list: ['https://www.w3schools.com/html/pic_trulli.jpg'] },
|
|
56
|
+
origin_cover: { url_list: ['https://www.w3schools.com/html/pic_trulli.jpg'] },
|
|
57
|
+
duration: 15000,
|
|
58
|
+
// 4K 那档 300MB,超过 QQ 的 200MB 硬限制,必须被面板隐藏
|
|
59
|
+
bit_rate: [makeBitRate('4k', 300), makeBitRate('1080p', 80), makeBitRate('720p', 20), makeBitRate('540p', 8)]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const amagi = require('@ikenxuan/amagi')
|
|
64
|
+
const realFactory = amagi.default
|
|
65
|
+
amagi.default = function (options) {
|
|
66
|
+
const client = realFactory(options)
|
|
67
|
+
client.douyin.fetcher.parseWork = async () => ({ success: true, code: 200, message: 'OK', data: { aweme_detail: douyinDetail } })
|
|
68
|
+
return client
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'))
|
|
72
|
+
const ctx = new Context()
|
|
73
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, qqPanel: true, qqFileLimitMB: 200 })
|
|
74
|
+
|
|
75
|
+
/* ------------------------------------------------------------------ *
|
|
76
|
+
* 断言工具
|
|
77
|
+
* ------------------------------------------------------------------ */
|
|
78
|
+
const results = []
|
|
79
|
+
const check = (name, ok, detail) => {
|
|
80
|
+
results.push({ name, ok })
|
|
81
|
+
console.log((ok ? ' ✅ ' : ' ❌ ') + name + (detail ? ' —— ' + detail : ''))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** 直接跑某个已注册命令(不经过中间件,避免无关命令干扰) */
|
|
85
|
+
const runCommand = async (namePart, content, platform = 'qqguild') => {
|
|
86
|
+
const { commandQueue } = require(path.join(pluginRoot, 'lib/compat/runtime.js'))
|
|
87
|
+
const { Message } = require(path.join(pluginRoot, 'lib/compat/node-karin.js'))
|
|
88
|
+
const reg = commandQueue.find((item) => String(item.options?.name ?? '').includes(namePart))
|
|
89
|
+
if (!reg) throw new Error('没有注册命令: ' + namePart)
|
|
90
|
+
|
|
91
|
+
const sent = []
|
|
92
|
+
const bot = {
|
|
93
|
+
selfId: '10000', platform, status: 1, user: { id: '10000', name: 'smoke' }, ctx,
|
|
94
|
+
sendMessage: async (channel, payload) => { sent.push(payload); return ['msg-1'] },
|
|
95
|
+
getGuild: async () => ({ name: 'smoke-guild' })
|
|
96
|
+
}
|
|
97
|
+
const session = {
|
|
98
|
+
content, selfId: '10000', userId: '12345', guildId: '456', channelId: '456',
|
|
99
|
+
messageId: 'm1', bot, author: { nick: 'smoke' }, username: 'smoke', event: {},
|
|
100
|
+
send: async (payload) => { sent.push(payload); return ['msg-2'] }
|
|
101
|
+
}
|
|
102
|
+
await reg.handler(Message.fromSession(session), () => Symbol('next'))
|
|
103
|
+
return sent
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 把发出的元素压成 markdown 文本 + 按钮清单 */
|
|
107
|
+
const readPanel = (sent) => {
|
|
108
|
+
const flat = []
|
|
109
|
+
for (const item of sent) for (const el of (Array.isArray(item) ? item : [item])) flat.push(el)
|
|
110
|
+
const markdown = flat.filter((el) => el && el.type === 'markdown')
|
|
111
|
+
.map((el) => (el.children || []).map((child) => child.attrs && child.attrs.content).join('')).join('\n')
|
|
112
|
+
// 按钮现在是 markdown 内联的 <qqbot-cmd-input text="…" show="…" />(群聊唯一可用的指令标签)
|
|
113
|
+
const buttons = []
|
|
114
|
+
const pattern = /<qqbot-cmd-input\s+text="([^"]*)"\s+show="([^"]*)"\s+reference="[^"]*"\s*\/>/g
|
|
115
|
+
let matched
|
|
116
|
+
while ((matched = pattern.exec(markdown)) !== null) {
|
|
117
|
+
buttons.push({ data: decodeURIComponent(matched[1]), label: decodeURIComponent(matched[2]) })
|
|
118
|
+
}
|
|
119
|
+
return { flat, markdown, buttons }
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
setTimeout(async () => {
|
|
123
|
+
try {
|
|
124
|
+
const { getRuntime } = require(path.join(pluginRoot, 'lib/compat/runtime.js'))
|
|
125
|
+
|
|
126
|
+
console.log('\n[1] QQ 平台发 B站链接 → 只回面板(不解析、不下载)')
|
|
127
|
+
const sent = await runCommand('B站', target)
|
|
128
|
+
const panel = readPanel(sent)
|
|
129
|
+
check('只发了 1 条消息', sent.length === 1, '共 ' + sent.length + ' 条')
|
|
130
|
+
check('含 markdown 段', /解析设置/.test(panel.markdown))
|
|
131
|
+
check('用的是 markdown 指令标签 <qqbot-cmd-input>', panel.buttons.length > 0, panel.buttons.length + ' 个按钮')
|
|
132
|
+
check('不再发原生 keyboard 按钮', !panel.flat.some((el) => el && el.type === 'button-group'))
|
|
133
|
+
check('按钮文字是画质(不是整条指令)', panel.buttons.every((b) => b.label && !b.label.startsWith('#') && !/https?:/.test(b.label)), panel.buttons.map((b) => b.label).join(' / '))
|
|
134
|
+
check('按钮里不带链接(只放短令牌)', panel.buttons.every((b) => !/https?:/.test(b.data)), panel.buttons[0] && panel.buttons[0].data)
|
|
135
|
+
console.log(' —— markdown ——\n' + panel.markdown.split('\n').map((l) => ' ' + l).join('\n'))
|
|
136
|
+
console.log(' —— 按钮 ——')
|
|
137
|
+
for (const b of panel.buttons) console.log(' [' + b.label + '] → ' + b.data)
|
|
138
|
+
|
|
139
|
+
console.log('\n[2] 体积上限:上限压到 1MB 时只保留最小的一档')
|
|
140
|
+
const runtime = getRuntime()
|
|
141
|
+
const originalLimit = runtime.config.qqFileLimitMB
|
|
142
|
+
runtime.config.qqFileLimitMB = 1
|
|
143
|
+
const tiny = readPanel(await runCommand('B站', target))
|
|
144
|
+
runtime.config.qqFileLimitMB = originalLimit
|
|
145
|
+
const qualityButtons = tiny.buttons.filter((b) => /M/.test(b.label))
|
|
146
|
+
const distinct = [...new Set(qualityButtons.map((b) => b.label))]
|
|
147
|
+
check('最多保留 1 档画质(两行各一个按钮)', distinct.length <= 1, distinct.join(' / ') || '(无)')
|
|
148
|
+
check('markdown 给出「发送可能失败」的提示', /可能失败/.test(tiny.markdown), tiny.markdown.match(/⚠️.*/)?.[0] ?? '(无提示)')
|
|
149
|
+
|
|
150
|
+
console.log('\n[3] 每个按钮都直接解析(没有「切换面板」的按钮)')
|
|
151
|
+
const videoLine = panel.markdown.split('\n').find((line) => line.includes('**纯视频**')) || ''
|
|
152
|
+
const danmakuLine = panel.markdown.split('\n').find((line) => line.includes('视频 + 弹幕')) || ''
|
|
153
|
+
const videoButtons = panel.buttons.filter((b) => String(b.data).startsWith('解析 '))
|
|
154
|
+
const danmakuButtons = panel.buttons.filter((b) => String(b.data).startsWith('弹幕解析 '))
|
|
155
|
+
check('纯视频那一行的按钮发「解析」指令', videoLine.includes('qqbot-cmd-input') && videoButtons.length > 0, videoButtons.map((b) => b.data).join(' | '))
|
|
156
|
+
check('弹幕那一行的按钮发「弹幕解析」指令', danmakuLine.includes('qqbot-cmd-input') && danmakuButtons.length > 0, danmakuButtons.map((b) => b.data).join(' | '))
|
|
157
|
+
check('没有任何按钮带 --panel(点了不会再弹面板)', panel.buttons.every((b) => !String(b.data).includes('--panel')), panel.buttons.map((b) => b.data).join(' | '))
|
|
158
|
+
|
|
159
|
+
console.log('\n[4] 参数覆盖:按钮选的画质要真的作用到解析链路')
|
|
160
|
+
const { runWithParseOverride } = require(path.join(pluginRoot, 'lib/karin/module/utils/ParseOverride.js'))
|
|
161
|
+
const { Config } = require(path.join(pluginRoot, 'lib/karin/module/utils/Config.js'))
|
|
162
|
+
const configured = Config.bilibili.videoQuality
|
|
163
|
+
let inside = null
|
|
164
|
+
await runWithParseOverride({ bilibiliQuality: 116 }, async () => { inside = Config.bilibili.videoQuality })
|
|
165
|
+
check('作用域内取到覆盖值 116', inside === 116, 'inside=' + inside + ' / 配置=' + configured)
|
|
166
|
+
check('作用域外仍是配置值', Config.bilibili.videoQuality === configured, 'now=' + Config.bilibili.videoQuality)
|
|
167
|
+
let douyinInside = null
|
|
168
|
+
await runWithParseOverride({ douyinQuality: '720p' }, async () => { douyinInside = Config.douyin.videoQuality })
|
|
169
|
+
check('抖音画质同样可覆盖', douyinInside === '720p', 'inside=' + douyinInside)
|
|
170
|
+
|
|
171
|
+
console.log('\n[5] 抖音:同一套面板 + 200MB 硬限制过滤(固定数据)')
|
|
172
|
+
const dySent = await runCommand('抖音', 'https://v.douyin.com/iFakeTest/')
|
|
173
|
+
const dy = readPanel(dySent)
|
|
174
|
+
check('只发了 1 条消息(面板)', dySent.length === 1, '共 ' + dySent.length + ' 条')
|
|
175
|
+
check('面板标题是作品文案', /面板验证/.test(dy.markdown), dy.markdown.split('\n')[1])
|
|
176
|
+
const dyQuality = dy.buttons.filter((b) => /M/.test(b.label))
|
|
177
|
+
console.log(' 画质按钮:' + dyQuality.map((b) => b.label).join(' / '))
|
|
178
|
+
check('300MB 的 4K 档被隐藏', !dyQuality.some((b) => b.label.includes('4K')), dyQuality.map((b) => b.label).join(' / '))
|
|
179
|
+
check('80MB 的 1080P 档保留', dyQuality.some((b) => b.label.includes('1080P')), dyQuality.map((b) => b.label).join(' / '))
|
|
180
|
+
check('画质参数用抖音的 --q=', dyQuality.some((b) => String(b.data).includes('--q=1080p')), dyQuality[0] && dyQuality[0].data)
|
|
181
|
+
|
|
182
|
+
console.log('\n[6] 非 QQ 平台 / 关掉开关 → 不发面板')
|
|
183
|
+
const { sendQqParsePanel } = require(path.join(pluginRoot, 'lib/karin/module/utils/QqPanel.js'))
|
|
184
|
+
const { Message } = require(path.join(pluginRoot, 'lib/compat/node-karin.js'))
|
|
185
|
+
const makeMessage = (platform) => Message.fromSession({
|
|
186
|
+
content: target, selfId: '10000', userId: '1', guildId: '456', channelId: '456', messageId: 'm',
|
|
187
|
+
bot: { selfId: '10000', platform, status: 1, ctx, sendMessage: async () => ['x'] },
|
|
188
|
+
author: { nick: 's' }, username: 's', event: {}, send: async () => ['y']
|
|
189
|
+
})
|
|
190
|
+
const onebot = await sendQqParsePanel(makeMessage('onebot'), { platform: 'bilibili', url: target, id: 'BV1xx411c7mD' }, { danmaku: false })
|
|
191
|
+
check('onebot 平台不发面板', onebot === false)
|
|
192
|
+
runtime.config.qqPanel = false
|
|
193
|
+
const disabled = await sendQqParsePanel(makeMessage('qqguild'), { platform: 'bilibili', url: target, id: 'BV1xx411c7mD' }, { danmaku: false })
|
|
194
|
+
runtime.config.qqPanel = true
|
|
195
|
+
check('qqPanel=false 时不发面板', disabled === false)
|
|
196
|
+
|
|
197
|
+
const failed = results.filter((item) => !item.ok)
|
|
198
|
+
console.log('\n=== ' + (results.length - failed.length) + '/' + results.length + ' 通过 ===')
|
|
199
|
+
process.exitCode = failed.length ? 1 : 0
|
|
200
|
+
} catch (error) {
|
|
201
|
+
console.error('冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
202
|
+
process.exitCode = 1
|
|
203
|
+
}
|
|
204
|
+
process.exit(process.exitCode || 0)
|
|
205
|
+
}, 5000)
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 渲染冒烟测试:用固定数据直接跑模板 SSR(不依赖 puppeteer,也不需要外网)。
|
|
3
|
+
*
|
|
4
|
+
* 验证点:
|
|
5
|
+
* - 路由注册表能加载到上游模板(\`src/ktr/template/**\`)
|
|
6
|
+
* - react-dom/server 能把模板渲染成 HTML,且关键内容出现在 HTML 里
|
|
7
|
+
* - 模板样式(上游构建产物 style.css)被内联进 HTML
|
|
8
|
+
* - 不支持的路由/坏数据会回退到内置通用卡片
|
|
9
|
+
*
|
|
10
|
+
* 用法:node scripts/smoke-render.cjs
|
|
11
|
+
*/
|
|
12
|
+
const fs = require('node:fs')
|
|
13
|
+
const path = require('node:path')
|
|
14
|
+
const { Context } = require('koishi')
|
|
15
|
+
|
|
16
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
17
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-render')
|
|
18
|
+
fs.mkdirSync(path.join(dataRoot, 'koishi-plugin-kkk', 'config'), { recursive: true })
|
|
19
|
+
|
|
20
|
+
const plugin = require(path.join(pluginRoot, 'lib/index.js'))
|
|
21
|
+
const ctx = new Context()
|
|
22
|
+
const fakeBot = {
|
|
23
|
+
selfId: '10000', platform: 'smoke', status: 1, user: { id: '10000', name: 'smoke' }, ctx,
|
|
24
|
+
sendMessage: async () => ['m'], getGuild: async () => ({ name: 'g' }), getFriendList: async () => []
|
|
25
|
+
}
|
|
26
|
+
Object.defineProperty(ctx, 'bots', { get: () => [fakeBot] })
|
|
27
|
+
ctx.plugin(plugin, { dataPath: dataRoot, debug: true, masters: ['12345'] })
|
|
28
|
+
|
|
29
|
+
// 用富文本包自带的构造函数拼文档,保证形状与模板一致
|
|
30
|
+
const richtext = require(path.join(pluginRoot, 'lib/richtext/index.js'))
|
|
31
|
+
const descDoc = richtext.createRichTextDocument([
|
|
32
|
+
richtext.createParagraphNode([richtext.createTextNode('这里是视频简介,用于验证富文本渲染链路。')])
|
|
33
|
+
], { platform: 'bilibili' })
|
|
34
|
+
|
|
35
|
+
/** B站视频信息模板的固定数据 */
|
|
36
|
+
const videoInfoData = {
|
|
37
|
+
share_url: 'https://b23.tv/BV1xx411c7mD',
|
|
38
|
+
title: '【迁移验证】这是一条用于确认模板渲染的测试标题',
|
|
39
|
+
desc: descDoc,
|
|
40
|
+
stat: {
|
|
41
|
+
aid: 2, view: 1234567, danmaku: 4567, reply: 890, favorite: 2345, coin: 6789, share: 123,
|
|
42
|
+
now_rank: 0, his_rank: 8, like: 98765, dislike: 0, evaluation: '', argue_msg: ''
|
|
43
|
+
},
|
|
44
|
+
bvid: 'BV1xx411c7mD',
|
|
45
|
+
ctime: Math.floor(Date.now() / 1000) - 86400,
|
|
46
|
+
pic: 'https://i0.hdslb.com/bfs/archive/placeholder.jpg',
|
|
47
|
+
owner: { mid: 946974, name: '测试UP主', face: 'https://i0.hdslb.com/bfs/face/placeholder.jpg' },
|
|
48
|
+
hotDanmaku: [{ content: '测试弹幕', count: 12 }]
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const outDir = path.join(dataRoot, 'html')
|
|
52
|
+
fs.mkdirSync(outDir, { recursive: true })
|
|
53
|
+
|
|
54
|
+
setTimeout(async () => {
|
|
55
|
+
let failures = 0
|
|
56
|
+
try {
|
|
57
|
+
const render = require(path.join(pluginRoot, 'lib/karin/module/utils/Render/index.js'))
|
|
58
|
+
|
|
59
|
+
const cases = [
|
|
60
|
+
{ route: 'bilibili/videoInfo', data: videoInfoData, expect: '【迁移验证】' },
|
|
61
|
+
{ route: 'other/changelog', data: { markdown: '## [2.42.5]\n- 迁移验证用的更新日志', Tip: false }, expect: '迁移验证用的更新日志' },
|
|
62
|
+
{ route: '不存在的路由/xxx', data: videoInfoData, expect: '【迁移验证】', fallbackOnly: true }
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
for (const item of cases) {
|
|
66
|
+
const html = await render.renderTemplateHtml(item.route, item.data, false)
|
|
67
|
+
const finalHtml = html ?? render.buildFallbackHtml(item.route, item.data, false, 1)
|
|
68
|
+
const usedTemplate = !!html
|
|
69
|
+
const ok = finalHtml.includes(item.expect) && (!item.fallbackOnly || !usedTemplate)
|
|
70
|
+
if (!ok) failures++
|
|
71
|
+
const file = path.join(outDir, item.route.replace(/[\\/]/g, '_') + '.html')
|
|
72
|
+
fs.writeFileSync(file, finalHtml)
|
|
73
|
+
console.log(
|
|
74
|
+
(ok ? '✅' : '❌') + ' ' + item.route +
|
|
75
|
+
' | 模板 SSR: ' + (usedTemplate ? '是' : '否(回退卡片)') +
|
|
76
|
+
' | HTML ' + finalHtml.length + ' 字节' +
|
|
77
|
+
' | 含样式: ' + (finalHtml.includes('.flex') || finalHtml.includes('--tw') ? '是' : '否') +
|
|
78
|
+
' | 含关键内容: ' + ok
|
|
79
|
+
)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// 注册表健康检查:所有路由的模板是否都能被加载(缺依赖会在这里暴露)
|
|
83
|
+
const registry = require(path.join(pluginRoot, 'lib/ktr/registry.js'))
|
|
84
|
+
const routes = Object.keys(registry.templateRegistry)
|
|
85
|
+
const broken = []
|
|
86
|
+
for (const route of routes) {
|
|
87
|
+
try {
|
|
88
|
+
const mod = await registry.loadTemplate(route)
|
|
89
|
+
if (!mod?.component) broken.push(route + '(无 component)')
|
|
90
|
+
} catch (error) {
|
|
91
|
+
broken.push(route + '(' + String(error && error.message).split('\n')[0] + ')')
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
console.log('\n模板注册表:共 ' + routes.length + ' 个路由,可加载 ' + (routes.length - broken.length) + ' 个')
|
|
95
|
+
if (broken.length) {
|
|
96
|
+
console.log('暂不可用(依赖缺失等,运行时会自动回退通用卡片):')
|
|
97
|
+
for (const item of broken) console.log(' - ' + item)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
console.log('\nHTML 样例输出目录: ' + outDir)
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error('渲染冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
103
|
+
failures++
|
|
104
|
+
}
|
|
105
|
+
process.exit(failures ? 1 : 0)
|
|
106
|
+
}, 5000)
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Web 控制台冒烟测试:起一个真实的 Koishi HTTP 服务(koishi-plugin-server),
|
|
3
|
+
* 挂上插件后用 fetch 打控制台接口,验证:
|
|
4
|
+
* 1. GET /kkk 控制台页面(零构建 HTML)
|
|
5
|
+
* 2. GET /kkk/v1/version 版本接口(无需鉴权)
|
|
6
|
+
* 3. GET /kkk/v1/config 无 token 且非本机 → 401
|
|
7
|
+
* 4. GET /kkk/v1/config 带 token → 模块列表
|
|
8
|
+
* 5. POST /kkk/v1/config 改一个配置项 → 再读确认已落盘
|
|
9
|
+
* 6. GET /kkk/v1/bots 机器人列表
|
|
10
|
+
*
|
|
11
|
+
* 用法:node scripts/smoke-server.cjs
|
|
12
|
+
*/
|
|
13
|
+
const fs = require('node:fs')
|
|
14
|
+
const path = require('node:path')
|
|
15
|
+
const { Context } = require('koishi')
|
|
16
|
+
|
|
17
|
+
const pluginRoot = path.resolve(__dirname, '..')
|
|
18
|
+
const dataRoot = path.resolve(pluginRoot, 'data-smoke-server')
|
|
19
|
+
const cfgDir = path.join(dataRoot, 'koishi-plugin-kkk', 'config')
|
|
20
|
+
fs.mkdirSync(cfgDir, { recursive: true })
|
|
21
|
+
|
|
22
|
+
const config = JSON.parse(fs.readFileSync(path.join(pluginRoot, 'config/default_config/config.json'), 'utf8'))
|
|
23
|
+
config.pushlist = { douyin: [], bilibili: [] }
|
|
24
|
+
fs.writeFileSync(path.join(cfgDir, 'config.json'), JSON.stringify(config, null, 2))
|
|
25
|
+
|
|
26
|
+
const PORT = Number(process.argv[2] || 5311)
|
|
27
|
+
const TOKEN = 'kkk-smoke-token'
|
|
28
|
+
const base = 'http://127.0.0.1:' + PORT
|
|
29
|
+
|
|
30
|
+
const ctx = new Context()
|
|
31
|
+
const serverModule = require('@koishijs/plugin-server')
|
|
32
|
+
ctx.plugin(serverModule.default ?? serverModule, { port: PORT, host: '127.0.0.1' })
|
|
33
|
+
ctx.plugin(require(path.join(pluginRoot, 'lib/index.js')), {
|
|
34
|
+
dataPath: dataRoot,
|
|
35
|
+
masters: ['12345'],
|
|
36
|
+
apiToken: TOKEN,
|
|
37
|
+
webui: true,
|
|
38
|
+
debug: false
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const check = (name, ok, extra = '') => {
|
|
42
|
+
console.log((ok ? '✅' : '❌') + ' ' + name + (extra ? ' | ' + extra : ''))
|
|
43
|
+
if (!ok) failures++
|
|
44
|
+
}
|
|
45
|
+
let failures = 0
|
|
46
|
+
|
|
47
|
+
const call = async (route, options = {}) => {
|
|
48
|
+
const headers = Object.assign({}, options.headers)
|
|
49
|
+
if (options.token) headers.Authorization = 'Bearer ' + options.token
|
|
50
|
+
if (options.body) headers['Content-Type'] = 'application/json'
|
|
51
|
+
const response = await fetch(base + route, Object.assign({}, options, { headers }))
|
|
52
|
+
const text = await response.text()
|
|
53
|
+
let json
|
|
54
|
+
try { json = JSON.parse(text) } catch {}
|
|
55
|
+
return { status: response.status, text, json }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// koishi 的 server 插件在 `ready` 事件里才开始监听端口,所以要显式 start 上下文
|
|
59
|
+
void ctx.start().catch((error) => console.error('启动 Koishi 服务失败:', error))
|
|
60
|
+
|
|
61
|
+
setTimeout(async () => {
|
|
62
|
+
try {
|
|
63
|
+
const page = await call('/kkk')
|
|
64
|
+
check('控制台页面 /kkk', page.status === 200 && page.text.includes('koishi-plugin-kkk 控制台'), 'HTTP ' + page.status + ' ' + page.text.length + ' 字节')
|
|
65
|
+
|
|
66
|
+
const version = await call('/kkk/v1/version')
|
|
67
|
+
check('版本接口 /kkk/v1/version', version.status === 200 && version.json?.data?.version, JSON.stringify(version.json?.data))
|
|
68
|
+
|
|
69
|
+
const noToken = await call('/kkk/v1/config')
|
|
70
|
+
check('未授权访问 /kkk/v1/config', noToken.status === 401, 'HTTP ' + noToken.status + ' ' + (noToken.json?.message || ''))
|
|
71
|
+
|
|
72
|
+
const withToken = await call('/kkk/v1/config', { token: TOKEN })
|
|
73
|
+
const modules = withToken.json?.data ? Object.keys(withToken.json.data) : []
|
|
74
|
+
check('读取配置 /kkk/v1/config', withToken.status === 200 && modules.length > 0, modules.length + ' 个模块: ' + modules.slice(0, 8).join(','))
|
|
75
|
+
|
|
76
|
+
const before = withToken.json?.data?.app?.parseTip
|
|
77
|
+
const save = await call('/kkk/v1/config', {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
token: TOKEN,
|
|
80
|
+
body: JSON.stringify({ app: { ...withToken.json.data.app, parseTip: before === false } })
|
|
81
|
+
})
|
|
82
|
+
const after = await call('/kkk/v1/config', { token: TOKEN })
|
|
83
|
+
check('写入配置 POST /kkk/v1/config', save.json?.code === 200 && after.json?.data?.app?.parseTip === (before === false),
|
|
84
|
+
'parseTip: ' + before + ' → ' + after.json?.data?.app?.parseTip +
|
|
85
|
+
' | results: ' + JSON.stringify(save.json?.data?.results ?? save.json).slice(0, 200))
|
|
86
|
+
|
|
87
|
+
const bots = await call('/kkk/v1/bots', { token: TOKEN })
|
|
88
|
+
check('机器人列表 /kkk/v1/bots', bots.status === 200 && Array.isArray(bots.json?.data), 'HTTP ' + bots.status)
|
|
89
|
+
} catch (error) {
|
|
90
|
+
console.error('控制台冒烟测试失败:', error && error.stack ? error.stack : error)
|
|
91
|
+
failures++
|
|
92
|
+
}
|
|
93
|
+
process.exit(failures ? 1 : 0)
|
|
94
|
+
}, 7000)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 最小 cron 调度器(5 段:分 时 日 月 周)。
|
|
3
|
+
*
|
|
4
|
+
* 原插件通过 karin.task 注册定时任务,Koishi 侧没有等价 API,
|
|
5
|
+
* 这里自己实现匹配,用 ctx.setInterval 每 30 秒检查一次。
|
|
6
|
+
*/
|
|
7
|
+
import type { Context } from 'koishi'
|
|
8
|
+
|
|
9
|
+
function parseField (field: string, min: number, max: number): (value: number) => boolean {
|
|
10
|
+
if (field === '*' || field === '?') return () => true
|
|
11
|
+
const matchers: Array<(value: number) => boolean> = []
|
|
12
|
+
for (const part of field.split(',')) {
|
|
13
|
+
const stepMatch = part.match(/^(\*|\d+(?:-\d+)?)\/(\d+)$/)
|
|
14
|
+
if (stepMatch) {
|
|
15
|
+
const step = Number(stepMatch[2])
|
|
16
|
+
const [start, end] = stepMatch[1] === '*' ? [min, max] : stepMatch[1].split('-').map(Number)
|
|
17
|
+
matchers.push((value) => value >= start && value <= (end ?? start) && (value - start) % step === 0)
|
|
18
|
+
continue
|
|
19
|
+
}
|
|
20
|
+
const rangeMatch = part.match(/^(\d+)-(\d+)$/)
|
|
21
|
+
if (rangeMatch) {
|
|
22
|
+
const start = Number(rangeMatch[1])
|
|
23
|
+
const end = Number(rangeMatch[2])
|
|
24
|
+
matchers.push((value) => value >= start && value <= end)
|
|
25
|
+
continue
|
|
26
|
+
}
|
|
27
|
+
const num = Number(part)
|
|
28
|
+
if (!Number.isNaN(num)) matchers.push((value) => value === num)
|
|
29
|
+
}
|
|
30
|
+
if (!matchers.length) return () => true
|
|
31
|
+
return (value: number) => matchers.some((matcher) => matcher(value))
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function cronMatcher (expression: string) {
|
|
35
|
+
const fields = expression.trim().split(/\s+/)
|
|
36
|
+
if (fields.length < 5) return () => false
|
|
37
|
+
const [minute, hour, day, month, week] = fields
|
|
38
|
+
const matchMinute = parseField(minute, 0, 59)
|
|
39
|
+
const matchHour = parseField(hour, 0, 23)
|
|
40
|
+
const matchDay = parseField(day, 1, 31)
|
|
41
|
+
const matchMonth = parseField(month, 1, 12)
|
|
42
|
+
const matchWeek = parseField(week, 0, 6)
|
|
43
|
+
return (date: Date) => matchMinute(date.getMinutes())
|
|
44
|
+
&& matchHour(date.getHours())
|
|
45
|
+
&& matchDay(date.getDate())
|
|
46
|
+
&& matchMonth(date.getMonth() + 1)
|
|
47
|
+
&& matchWeek(date.getDay())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface ScheduledTask {
|
|
51
|
+
name: string
|
|
52
|
+
cron: string
|
|
53
|
+
handler: (...args: any[]) => any
|
|
54
|
+
options?: Record<string, any>
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function startScheduler (ctx: Context, logger: any, tasks: ScheduledTask[]) {
|
|
58
|
+
if (!tasks.length) return
|
|
59
|
+
const entries = tasks.map((task) => ({ task, match: cronMatcher(task.cron), running: false, lastKey: '' }))
|
|
60
|
+
|
|
61
|
+
for (const entry of entries) {
|
|
62
|
+
logger.info('注册定时任务 %s(%s)', entry.task.name, entry.task.cron)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const tick = async () => {
|
|
66
|
+
const now = new Date()
|
|
67
|
+
const key = now.toISOString().slice(0, 16)
|
|
68
|
+
for (const entry of entries) {
|
|
69
|
+
if (entry.lastKey === key) continue
|
|
70
|
+
if (!entry.match(now)) continue
|
|
71
|
+
entry.lastKey = key
|
|
72
|
+
if (entry.running) {
|
|
73
|
+
logger.warn('任务 %s 上一轮尚未结束,跳过本次触发', entry.task.name)
|
|
74
|
+
continue
|
|
75
|
+
}
|
|
76
|
+
entry.running = true
|
|
77
|
+
Promise.resolve()
|
|
78
|
+
.then(() => entry.task.handler())
|
|
79
|
+
.catch((error) => logger.error('任务 %s 执行失败: %s', entry.task.name, error?.stack ?? error))
|
|
80
|
+
.finally(() => { entry.running = false })
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
ctx.setInterval(tick, 30 * 1000)
|
|
85
|
+
void tick()
|
|
86
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 真实动态 import 的逃生舱。
|
|
3
|
+
*
|
|
4
|
+
* tsc 在 `module: commonjs` 下会把 `await import('x')` 降级成 `Promise.resolve().then(() => require('x'))`,
|
|
5
|
+
* 于是 ESM-only 的依赖(例如 `@ikenxuan/qrcode` 的 exports 没有 require 条件)依旧加载不了。
|
|
6
|
+
* 这里用 `new Function` 包一层,绕开编译期改写,运行时由 Node 走真正的 ESM 加载。
|
|
7
|
+
*/
|
|
8
|
+
export function importEsm<T = any> (specifier: string): Promise<T> {
|
|
9
|
+
const importer = new Function('specifier', 'return import(specifier)') as (specifier: string) => Promise<T>
|
|
10
|
+
return importer(specifier)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export default importEsm
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \`@heroui/react\` 的最小兼容实现(Koishi 迁移补充)。
|
|
3
|
+
*
|
|
4
|
+
* 上游只有 4 个模板用到 HeroUI,且只用到 \`Chip\` 与 \`Button\` 两个展示型组件。
|
|
5
|
+
* 而 @heroui/react v3 是 **ESM-only**(package.json 里 exports 只有 import 条件,没有 CJS 产物),
|
|
6
|
+
* 我们的 CJS 产物(tsc 直出、无打包器)没法 require 它。
|
|
7
|
+
*
|
|
8
|
+
* 这里用同语义的普通元素实现:调用方本来就通过 \`className\` / \`style\` 传入了绝大多数样式,
|
|
9
|
+
* 海报又是静态 HTML(没有交互),因此渲染结果与 HeroUI 基本一致。
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react'
|
|
12
|
+
|
|
13
|
+
interface CompatProps {
|
|
14
|
+
size?: 'sm' | 'md' | 'lg'
|
|
15
|
+
color?: string
|
|
16
|
+
variant?: string
|
|
17
|
+
className?: string
|
|
18
|
+
style?: React.CSSProperties
|
|
19
|
+
children?: React.ReactNode
|
|
20
|
+
[key: string]: unknown
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const join = (...parts: Array<string | undefined | false>) => parts.filter(Boolean).join(' ')
|
|
24
|
+
|
|
25
|
+
/** 对应 HeroUI 的 Chip(标签/徽章) */
|
|
26
|
+
export const Chip = ({ size = 'md', color, variant, className, style, children, ...rest }: CompatProps) => (
|
|
27
|
+
<span
|
|
28
|
+
className={join('inline-flex items-center justify-center rounded-full leading-none', className)}
|
|
29
|
+
style={style}
|
|
30
|
+
data-color={color}
|
|
31
|
+
data-variant={variant}
|
|
32
|
+
data-size={size}
|
|
33
|
+
{...(rest as any)}
|
|
34
|
+
>
|
|
35
|
+
{children}
|
|
36
|
+
</span>
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
/** 对应 HeroUI 的 Button(静态海报里就是一块按钮样式的容器) */
|
|
40
|
+
export const Button = ({ size = 'md', color, variant, className, style, children, ...rest }: CompatProps) => (
|
|
41
|
+
<span
|
|
42
|
+
className={join('inline-flex items-center justify-center gap-2 rounded-xl font-medium', className)}
|
|
43
|
+
style={style}
|
|
44
|
+
data-color={color}
|
|
45
|
+
data-variant={variant}
|
|
46
|
+
data-size={size}
|
|
47
|
+
{...(rest as any)}
|
|
48
|
+
>
|
|
49
|
+
{children}
|
|
50
|
+
</span>
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
export default { Chip, Button }
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* \`node-karin/lodash\` 的兼容实现。
|
|
3
|
+
*
|
|
4
|
+
* 上游只有一个模板用到它,且只用了 \`camelCase\` / \`upperFirst\` 两个纯函数,
|
|
5
|
+
* 因此这里不引入 lodash 全量依赖,直接实现同语义的小函数(并保留 lodash 的默认导出形态)。
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** lodash 的 camelCase:\`'QQ Bot' -> 'qqBot'\` */
|
|
9
|
+
export function camelCase (input: string): string {
|
|
10
|
+
const words = String(input ?? '')
|
|
11
|
+
.replace(/['\u2019]/g, '')
|
|
12
|
+
.replace(/([a-z\d])([A-Z])/g, '$1 $2')
|
|
13
|
+
.replace(/[^a-zA-Z0-9]+/g, ' ')
|
|
14
|
+
.trim()
|
|
15
|
+
.split(/\s+/)
|
|
16
|
+
.filter(Boolean)
|
|
17
|
+
return words
|
|
18
|
+
.map((word, index) => {
|
|
19
|
+
const lower = word.toLowerCase()
|
|
20
|
+
return index === 0 ? lower : lower.charAt(0).toUpperCase() + lower.slice(1)
|
|
21
|
+
})
|
|
22
|
+
.join('')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** lodash 的 upperFirst:只把首字母大写 */
|
|
26
|
+
export function upperFirst (input: string): string {
|
|
27
|
+
const text = String(input ?? '')
|
|
28
|
+
return text.charAt(0).toUpperCase() + text.slice(1)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const lodash = { camelCase, upperFirst }
|
|
32
|
+
export default lodash
|