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,320 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 富文本节点联合类型。
|
|
3
|
+
*
|
|
4
|
+
* 后端只需要生产这些纯 JSON 节点,前端可以再按 React、HTML、Canvas 等不同目标渲染。
|
|
5
|
+
*/
|
|
6
|
+
export type RichTextNode = RichTextInlineNode | RichTextBlockNode
|
|
7
|
+
|
|
8
|
+
/** 行内节点。 */
|
|
9
|
+
export type RichTextInlineNode =
|
|
10
|
+
| RichTextTextNode
|
|
11
|
+
| RichTextEmojiNode
|
|
12
|
+
| RichTextMentionNode
|
|
13
|
+
| RichTextSearchKeywordNode
|
|
14
|
+
| RichTextLineBreakNode
|
|
15
|
+
| RichTextTopicNode
|
|
16
|
+
| RichTextAtNode
|
|
17
|
+
| RichTextLotteryNode
|
|
18
|
+
| RichTextWebLinkNode
|
|
19
|
+
| RichTextOpusLinkNode
|
|
20
|
+
| RichTextVoteNode
|
|
21
|
+
| RichTextViewPictureNode
|
|
22
|
+
| RichTextHashtagNode
|
|
23
|
+
|
|
24
|
+
/** 块级节点。 */
|
|
25
|
+
export type RichTextBlockNode =
|
|
26
|
+
| RichTextHeadingNode
|
|
27
|
+
| RichTextParagraphNode
|
|
28
|
+
| RichTextImageNode
|
|
29
|
+
| RichTextBlockquoteNode
|
|
30
|
+
| RichTextListNode
|
|
31
|
+
| RichTextListItemNode
|
|
32
|
+
| RichTextCodeBlockNode
|
|
33
|
+
| RichTextLinkCardNode
|
|
34
|
+
| RichTextHorizontalRuleNode
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* 富文本文档。
|
|
38
|
+
*
|
|
39
|
+
* `version` 用来给后续节点协议升级留空间;`platform` 用来标记来源平台,方便后续按平台做兼容。
|
|
40
|
+
*/
|
|
41
|
+
export interface RichTextDocument {
|
|
42
|
+
version: 1
|
|
43
|
+
platform?: string
|
|
44
|
+
nodes: RichTextNode[]
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** 行内文本样式。 */
|
|
48
|
+
export interface RichTextInlineStyle {
|
|
49
|
+
/** 粗体 */
|
|
50
|
+
bold?: boolean
|
|
51
|
+
/** 斜体 */
|
|
52
|
+
italic?: boolean
|
|
53
|
+
/** 删除线 */
|
|
54
|
+
strike?: boolean
|
|
55
|
+
/** 文字颜色(CSS color 值) */
|
|
56
|
+
color?: string
|
|
57
|
+
/** 超链接地址 */
|
|
58
|
+
link?: string
|
|
59
|
+
/** 字体大小(CSS font-size 值) */
|
|
60
|
+
fontSize?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** 普通文本节点。文本永远作为文本渲染,不会当成 HTML 执行。 */
|
|
64
|
+
export interface RichTextTextNode {
|
|
65
|
+
type: 'text'
|
|
66
|
+
/** 文本内容 */
|
|
67
|
+
text: string
|
|
68
|
+
/** 可选的行内样式 */
|
|
69
|
+
style?: RichTextInlineStyle
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** 行内表情节点。用于评论文本中夹杂的平台表情图片。 */
|
|
73
|
+
export interface RichTextEmojiNode {
|
|
74
|
+
type: 'emoji'
|
|
75
|
+
/** 表情包名称 */
|
|
76
|
+
name: string
|
|
77
|
+
/** 表情包链接 */
|
|
78
|
+
src: string
|
|
79
|
+
/** 缩放倍率。默认 1,某些平台的大表情可以传 3。 */
|
|
80
|
+
scale?: number
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** @ 用户节点。`userId` 可选,因为有些平台只给历史昵称,不给稳定 ID。 */
|
|
84
|
+
export interface RichTextMentionNode {
|
|
85
|
+
type: 'mention'
|
|
86
|
+
/** @ 用户的文本 */
|
|
87
|
+
text: string
|
|
88
|
+
/** UID */
|
|
89
|
+
userId?: string
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* 搜索词高亮节点。
|
|
94
|
+
*
|
|
95
|
+
* 某些平台会把"评论里的高亮搜索词"独立放在元数据里,而不是单独拼进 HTML。
|
|
96
|
+
* 这里把它提升成独立节点,方便 template 渲染成高亮文本和上标搜索图标。
|
|
97
|
+
*/
|
|
98
|
+
export interface RichTextSearchKeywordNode {
|
|
99
|
+
type: 'searchKeyword'
|
|
100
|
+
/** 搜索词 */
|
|
101
|
+
text: string
|
|
102
|
+
/** 搜索ID */
|
|
103
|
+
queryId?: string
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** 换行节点。前端渲染成 `<br />`,避免后端直接拼 HTML。 */
|
|
107
|
+
export interface RichTextLineBreakNode {
|
|
108
|
+
type: 'lineBreak'
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** 话题节点。B站动态中以 #话题名称# 形式呈现,带彩色文字。 */
|
|
112
|
+
export interface RichTextTopicNode {
|
|
113
|
+
type: 'topic'
|
|
114
|
+
/** 话题名称(不含#号) */
|
|
115
|
+
text: string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** @用户节点。用于动态描述中的@提及。 */
|
|
119
|
+
export interface RichTextAtNode {
|
|
120
|
+
type: 'at'
|
|
121
|
+
/** @用户的显示文本 */
|
|
122
|
+
text: string
|
|
123
|
+
/** 用户ID(可选) */
|
|
124
|
+
userId?: string
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** 抽奖节点。带SVG图标,显示抽奖信息。 */
|
|
128
|
+
export interface RichTextLotteryNode {
|
|
129
|
+
type: 'lottery'
|
|
130
|
+
/** 显示文本 */
|
|
131
|
+
text: string
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** 网页链接节点。带SVG图标,显示链接的标题。 */
|
|
135
|
+
export interface RichTextWebLinkNode {
|
|
136
|
+
type: 'webLink'
|
|
137
|
+
/** 显示文本(如网页标题) */
|
|
138
|
+
text: string
|
|
139
|
+
/** 跳转链接 */
|
|
140
|
+
jumpUrl: string
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 站内图文链接节点。带SVG图标,显示图文标题。
|
|
145
|
+
*
|
|
146
|
+
* 对应 B站 opus 正文里的高亮链接(官方页面上的 `opus-text-rich-hl`)。
|
|
147
|
+
* 模板渲染不需要交互,所以只渲染图标和文本;`url` 留给纯文本场景(如合并转发)拼出链接。
|
|
148
|
+
*/
|
|
149
|
+
export interface RichTextOpusLinkNode {
|
|
150
|
+
type: 'opusLink'
|
|
151
|
+
/** 显示文本(如图文标题) */
|
|
152
|
+
text: string
|
|
153
|
+
/** 跳转链接 */
|
|
154
|
+
url: string
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** 投票节点。带SVG图标,显示投票标题。 */
|
|
158
|
+
export interface RichTextVoteNode {
|
|
159
|
+
type: 'vote'
|
|
160
|
+
/** 投票标题 */
|
|
161
|
+
text: string
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** 查看图片节点。带SVG图标,提示用户点击查看图片。 */
|
|
165
|
+
export interface RichTextViewPictureNode {
|
|
166
|
+
type: 'viewPicture'
|
|
167
|
+
/** 显示文本 */
|
|
168
|
+
text: string
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/**
|
|
172
|
+
* Hashtag 话题节点。
|
|
173
|
+
*
|
|
174
|
+
* 纯文本高亮,不带任何图标。用于抖音等平台的 #话题# 标签展示。
|
|
175
|
+
* 与 topic 节点的区别:topic 带有 B站风格的 # 图标,hashtag 只做纯文字高亮。
|
|
176
|
+
*/
|
|
177
|
+
export interface RichTextHashtagNode {
|
|
178
|
+
type: 'hashtag'
|
|
179
|
+
/** 话题文本(包含 # 号) */
|
|
180
|
+
text: string
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/** 标题节点。 */
|
|
184
|
+
export interface RichTextHeadingNode {
|
|
185
|
+
type: 'heading'
|
|
186
|
+
/** 标题级别 1-6 */
|
|
187
|
+
level: 1 | 2 | 3 | 4 | 5 | 6
|
|
188
|
+
/** 子节点 */
|
|
189
|
+
nodes: RichTextNode[]
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** 段落节点。 */
|
|
193
|
+
export interface RichTextParagraphNode {
|
|
194
|
+
type: 'paragraph'
|
|
195
|
+
/** 子节点 */
|
|
196
|
+
nodes: RichTextNode[]
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/** 图片节点。 */
|
|
200
|
+
export interface RichTextImageNode {
|
|
201
|
+
type: 'image'
|
|
202
|
+
/** 图片地址 */
|
|
203
|
+
src: string
|
|
204
|
+
/** 替代文本 */
|
|
205
|
+
alt?: string
|
|
206
|
+
/** 图片下方注释/说明文字 */
|
|
207
|
+
caption?: string
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/** 水平分隔线节点。 */
|
|
211
|
+
export interface RichTextHorizontalRuleNode {
|
|
212
|
+
type: 'horizontalRule'
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/** 引用块节点。 */
|
|
216
|
+
export interface RichTextBlockquoteNode {
|
|
217
|
+
type: 'blockquote'
|
|
218
|
+
/** 子节点 */
|
|
219
|
+
nodes: RichTextNode[]
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** 列表节点。 */
|
|
223
|
+
export interface RichTextListNode {
|
|
224
|
+
type: 'list'
|
|
225
|
+
/** 是否为有序列表 */
|
|
226
|
+
ordered: boolean
|
|
227
|
+
/** 列表项 */
|
|
228
|
+
items: RichTextListItemNode[]
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** 列表项节点。 */
|
|
232
|
+
export interface RichTextListItemNode {
|
|
233
|
+
type: 'listItem'
|
|
234
|
+
/** 子节点 */
|
|
235
|
+
nodes: RichTextNode[]
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** 代码块节点。 */
|
|
239
|
+
export interface RichTextCodeBlockNode {
|
|
240
|
+
type: 'codeBlock'
|
|
241
|
+
/** 代码语言 */
|
|
242
|
+
language?: string
|
|
243
|
+
/** 代码内容 */
|
|
244
|
+
content: string
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/** 链接卡片节点。 */
|
|
248
|
+
export interface RichTextLinkCardNode {
|
|
249
|
+
type: 'linkCard'
|
|
250
|
+
/** 卡片标题/显示文本 */
|
|
251
|
+
title: string
|
|
252
|
+
/** 跳转链接 */
|
|
253
|
+
url: string
|
|
254
|
+
/** 卡片类型标识 */
|
|
255
|
+
cardType?: string
|
|
256
|
+
/** 额外元数据 */
|
|
257
|
+
meta?: Record<string, any>
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** 平台表情定义,通常由 core 从平台表情接口转换得到。 */
|
|
261
|
+
export interface RichTextEmojiDefinition {
|
|
262
|
+
name: string
|
|
263
|
+
url: string
|
|
264
|
+
/** 缩放倍率。默认 1。 */
|
|
265
|
+
scale?: number
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* 单个富文本节点的样式配置。
|
|
270
|
+
*
|
|
271
|
+
* 平台模板传入它们想要的 className,渲染器直接应用。
|
|
272
|
+
* 只允许 className,不允许 style 对象——视觉样式全部由 Tailwind 接管。
|
|
273
|
+
*/
|
|
274
|
+
export interface RichTextNodeStyleConfig {
|
|
275
|
+
/** Tailwind className,控制该节点的视觉样式 */
|
|
276
|
+
className?: string
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* 搜索关键词节点需要额外的图标 className(普通节点不需要)。
|
|
281
|
+
*/
|
|
282
|
+
export interface RichTextSearchKeywordStyleConfig extends RichTextNodeStyleConfig {
|
|
283
|
+
/** 搜索图标的额外 className */
|
|
284
|
+
iconClassName?: string
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* HTML 渲染器配置。React 渲染器复用这些 className 约定。
|
|
289
|
+
*
|
|
290
|
+
* 传入的 className 会覆盖渲染器内部对这些节点的默认样式。
|
|
291
|
+
* 视觉样式全部由 Tailwind className 表达,渲染器只负责结构。
|
|
292
|
+
*/
|
|
293
|
+
export interface RichTextRenderOptions {
|
|
294
|
+
/** @提及节点 */
|
|
295
|
+
mention?: RichTextNodeStyleConfig
|
|
296
|
+
/** 搜索关键词节点(高亮词) */
|
|
297
|
+
searchKeyword?: RichTextSearchKeywordStyleConfig
|
|
298
|
+
/** 话题节点 */
|
|
299
|
+
topic?: RichTextNodeStyleConfig
|
|
300
|
+
/** @用户节点 */
|
|
301
|
+
at?: RichTextNodeStyleConfig
|
|
302
|
+
/** 抽奖节点 */
|
|
303
|
+
lottery?: RichTextNodeStyleConfig
|
|
304
|
+
/** 网页链接节点 */
|
|
305
|
+
webLink?: RichTextNodeStyleConfig
|
|
306
|
+
/** 站内图文链接节点 */
|
|
307
|
+
opusLink?: RichTextNodeStyleConfig
|
|
308
|
+
/** 投票节点 */
|
|
309
|
+
vote?: RichTextNodeStyleConfig
|
|
310
|
+
/** 查看图片节点 */
|
|
311
|
+
viewPicture?: RichTextNodeStyleConfig
|
|
312
|
+
/** 代码块节点 */
|
|
313
|
+
codeBlock?: RichTextNodeStyleConfig
|
|
314
|
+
/** 链接卡片节点 */
|
|
315
|
+
linkCard?: RichTextNodeStyleConfig
|
|
316
|
+
/** hashtag 话题节点 */
|
|
317
|
+
hashtag?: RichTextNodeStyleConfig
|
|
318
|
+
/** 图标缩放比例,默认 1。用于在不同字体大小下保持图标比例一致。 */
|
|
319
|
+
iconScale?: number
|
|
320
|
+
}
|
package/src/schema.ts
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把插件自己的配置(上游的 config.json)映射成 Koishi 的控制台表单。
|
|
3
|
+
*
|
|
4
|
+
* 上游 Karin 版把这些配置放在 \`config/config.json\`(amagi / app / douyin / bilibili / kuaishou /
|
|
5
|
+
* xiaohongshu / pushlist 七个模块),由它的 WebUI 编辑。Koishi 侧如果只声明集成选项,
|
|
6
|
+
* 控制台的「插件配置」里就看不到清晰度这类选项 —— 所以这里**按默认配置的形状动态生成 Schema**:
|
|
7
|
+
* - 结构、键名与上游完全一致,升级上游默认配置后表单会自动跟着变;
|
|
8
|
+
* - 描述取自上游 \`config/default_config/*.yaml\` 里每个字段上方的中文注释(Karin 版的字段说明);
|
|
9
|
+
* - **默认值取自同一份默认配置**:所有字段在控制台里都显示真实取值,而不是一片空白;
|
|
10
|
+
* - **枚举型字段渲染成下拉框**:取值直接从注释里解析(「可选值:'info'(视频信息)…」、
|
|
11
|
+
* \`- 6: 240P 极速\` 这类列表、\`all为所有人\` 这类权限说明),选项文案用注释里的中文说明。
|
|
12
|
+
*
|
|
13
|
+
* ⚠️ 默认值带来的副作用(已在 configBridge 里处理):Koishi 会把默认值填进配置对象,
|
|
14
|
+
* 于是「没填」和「填了默认值」不再靠有没有值来区分,改为**与上游默认值相等即视为没填**,
|
|
15
|
+
* 这样用户直接改 config.json 的内容不会在下次启动时被表单里的默认值覆盖。
|
|
16
|
+
* 代价:在控制台里把某项改回默认值,不会写回 config.json(想强制改回请用 /kkk 面板或直接改文件)。
|
|
17
|
+
*/
|
|
18
|
+
import fs from 'node:fs'
|
|
19
|
+
import path from 'node:path'
|
|
20
|
+
|
|
21
|
+
import { Schema } from 'koishi'
|
|
22
|
+
|
|
23
|
+
/** 递归深度上限,避免异常配置把 Schema 撑爆 */
|
|
24
|
+
const MAX_DEPTH = 6
|
|
25
|
+
|
|
26
|
+
/** \`douyin.videoQuality\` -> 「视频画质偏好设置…」 */
|
|
27
|
+
export type DescriptionMap = Record<string, string>
|
|
28
|
+
|
|
29
|
+
/** 一个下拉选项 */
|
|
30
|
+
export interface EnumOption {
|
|
31
|
+
value: string | number
|
|
32
|
+
label: string
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 一个字段的注释信息 */
|
|
36
|
+
export interface FieldMeta {
|
|
37
|
+
/** 注释正文(拼成一段) */
|
|
38
|
+
text: string
|
|
39
|
+
/** 从注释里解析出来的候选值;没有就是普通输入框 */
|
|
40
|
+
options?: EnumOption[]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type MetaMap = Record<string, FieldMeta>
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* 补充说明:上游 YAML 里没有(字段是后加的)或只作为模块容器出现的字段,
|
|
47
|
+
* 按 \`src/karin/types/config/*.ts\` 的 JSDoc 与实际用途补上。YAML 里已有的说明优先。
|
|
48
|
+
*/
|
|
49
|
+
const SUPPLEMENT: DescriptionMap = {
|
|
50
|
+
amagi: 'amagi 解析库配置:请求超时、UA、代理、各平台 Cookie、内置 API Server',
|
|
51
|
+
'amagi.proxy.switch': '是否启用代理',
|
|
52
|
+
'amagi.cookies': '各平台 Cookie,扫码登录成功后会自动写入这里',
|
|
53
|
+
'amagi.cookies.bilibili': 'B站 Cookie(SESSDATA 等),配置后才能拿高画质与动态推送',
|
|
54
|
+
'amagi.cookies.douyin': '抖音 Cookie,配置后才能解析作品与推送',
|
|
55
|
+
'amagi.cookies.kuaishou': '快手 Cookie',
|
|
56
|
+
'amagi.cookies.xiaohongshu': '小红书 Cookie',
|
|
57
|
+
app: '全局通用设置:解析总开关、渲染、缓存、错误上报等',
|
|
58
|
+
'app.ambientCover': '封面氛围背景参数:控制封面图对模板背景氛围的贡献度,取值 0~1',
|
|
59
|
+
'app.ambientCover.coverOpacity': '模糊封面层不透明度:封面色强度总闸,越大整体越浓',
|
|
60
|
+
'app.ambientCover.overlayEdgeOpacity': '主题色压色罩两端(顶/底)不透明度',
|
|
61
|
+
'app.ambientCover.overlayMiddleOpacity': '主题色压色罩中间带不透明度,越小封面色越透',
|
|
62
|
+
douyin: '抖音解析与推送设置',
|
|
63
|
+
bilibili: 'B站解析与推送设置',
|
|
64
|
+
kuaishou: '快手解析设置',
|
|
65
|
+
xiaohongshu: '小红书解析设置',
|
|
66
|
+
pushlist: '推送订阅列表:每一项是「关注对象 + 群号:机器人账号」,可加过滤词/标签',
|
|
67
|
+
'xiaohongshu.watermark': '小红书图片是否加水印(上游保留项)'
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 注释里解析不出来的枚举,手工补。
|
|
72
|
+
* 只补「取值域封闭、写错就跑不起来」的字段;普通数值/文本**不要**往这里加,
|
|
73
|
+
* 否则控制台会把人限制在几个选项里。
|
|
74
|
+
*/
|
|
75
|
+
const SUPPLEMENT_ENUMS: Record<string, EnumOption[]> = {
|
|
76
|
+
'app.Theme': [
|
|
77
|
+
{ value: 0, label: '自动(06:00-18:00 浅色,其余深色)' },
|
|
78
|
+
{ value: 1, label: '浅色' },
|
|
79
|
+
{ value: 2, label: '深色' },
|
|
80
|
+
{ value: 3, label: '智能场景(按封面判断深浅)' }
|
|
81
|
+
],
|
|
82
|
+
'douyin.push.shareType': [
|
|
83
|
+
{ value: 'web', label: '跳转到抖音网页' },
|
|
84
|
+
{ value: 'download', label: '视频下载直链' }
|
|
85
|
+
]
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** 权限类字段:值就是 all / admin / master / group.owner / group.admin */
|
|
89
|
+
const PERMISSION_VALUES: EnumOption[] = [
|
|
90
|
+
{ value: 'all', label: '所有人' },
|
|
91
|
+
{ value: 'admin', label: '管理员' },
|
|
92
|
+
{ value: 'master', label: '主人' },
|
|
93
|
+
{ value: 'group.owner', label: '群主' },
|
|
94
|
+
{ value: 'group.admin', label: '群管理员' }
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
/** 字段名命中权限域 */
|
|
98
|
+
const isPermissionField = (name: string): boolean => /^(loginPerm|permission)$/i.test(name)
|
|
99
|
+
|
|
100
|
+
/** 剥掉列表项的 \`[]\` 后缀,用于回查字段名 */
|
|
101
|
+
const shortName = (fieldPath: string): string => fieldPath.split('.').pop()!.replace(/\[\]$/, '')
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* 从注释行里抽枚举候选。
|
|
105
|
+
*
|
|
106
|
+
* 支持的三种写法(都是上游 YAML 里真实存在的):
|
|
107
|
+
* 1. \`可选值:'info'(视频信息)、'comment'(评论图片)\` —— 引号里的值 + 紧跟的中文说明;
|
|
108
|
+
* 2. 列表项 \`- 6: 240P 极速\` / \`- 'off': 关闭\` / \`- 'google' - Google Motion Photo\`;
|
|
109
|
+
* 3. \`all为所有人,admin为管理员…\` —— 权限字段常见写法。
|
|
110
|
+
* @param lines 该字段的注释行
|
|
111
|
+
* @param name 字段名(判断是不是权限域)
|
|
112
|
+
*/
|
|
113
|
+
function extractOptions (lines: string[], name: string): EnumOption[] | undefined {
|
|
114
|
+
const found = new Map<string, string>()
|
|
115
|
+
const add = (rawValue: string, label: string) => {
|
|
116
|
+
const value = String(rawValue ?? '').trim().replace(/^['"]|['"]$/g, '')
|
|
117
|
+
const text = String(label ?? '').replace(/^[\s::\-—]+/, '').replace(/[,,。;;]+$/, '').trim()
|
|
118
|
+
if (!value || found.has(value)) return
|
|
119
|
+
found.set(value, text)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
for (const line of lines) {
|
|
123
|
+
const bullet = line.match(/^\s*[-*·]\s+(.+)$/)
|
|
124
|
+
if (bullet) {
|
|
125
|
+
const item = bullet[1].match(/^['"]?([^'"\s::]+)['"]?\s*(?:[::\-—]\s*)?(.*)$/)
|
|
126
|
+
if (item) add(item[1], item[2])
|
|
127
|
+
continue
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (/可选值|可选:/.test(line)) {
|
|
131
|
+
const quoted = /['"]([^'"]+)['"]/g
|
|
132
|
+
let matched: RegExpExecArray | null
|
|
133
|
+
while ((matched = quoted.exec(line)) !== null) {
|
|
134
|
+
const rest = line.slice(quoted.lastIndex)
|
|
135
|
+
/**
|
|
136
|
+
* 候选值后面必须紧跟「说明括号 / 顿号 / 逗号 / 句号 / 结束」。
|
|
137
|
+
* 这条约束是为了滤掉解释性文字里的引号 —— 例如
|
|
138
|
+
* 「'master'(除'console'外的第一个主人)」里的 'console' 后面是「外」,
|
|
139
|
+
* 不加约束就会多出一个叫 console 的假选项。
|
|
140
|
+
*/
|
|
141
|
+
if (!/^\s*([((、,,。;;]|$)/.test(rest)) continue
|
|
142
|
+
const label = rest.match(/^\s*[((]([^))]*)[))]/)
|
|
143
|
+
add(matched[1], label ? label[1] : '')
|
|
144
|
+
}
|
|
145
|
+
continue
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
if (isPermissionField(name)) {
|
|
149
|
+
const words = /([a-zA-Z][\w.]*)为/g
|
|
150
|
+
let matched: RegExpExecArray | null
|
|
151
|
+
while ((matched = words.exec(line)) !== null) add(matched[1], '')
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// 「0为自动,1为浅色,2为深色」这类数字枚举:至少 3 个才算,避免把「0-100」这种区间误判成枚举
|
|
156
|
+
const numeric = new Map<string, string>()
|
|
157
|
+
for (const line of lines) {
|
|
158
|
+
const numbers = /(\d+(?:\.\d+)?)\s*为/g
|
|
159
|
+
let matched: RegExpExecArray | null
|
|
160
|
+
while ((matched = numbers.exec(line)) !== null) {
|
|
161
|
+
if (!numeric.has(matched[1])) numeric.set(matched[1], '')
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
if (numeric.size >= 3) for (const [value, label] of numeric) add(value, label)
|
|
165
|
+
|
|
166
|
+
return found.size >= 2 ? [...found].map(([value, label]) => ({ value, label })) : undefined
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* 解析 \`config/default_config/*.yaml\` 里的字段注释。
|
|
171
|
+
*
|
|
172
|
+
* 形如:
|
|
173
|
+
* \`\`\`yaml
|
|
174
|
+
* # 视频体积上限,自适应画质模式下可接受的最大视频大小(单位:MB)
|
|
175
|
+
* maxAutoVideoSize: 50
|
|
176
|
+
* \`\`\`
|
|
177
|
+
* 注释写在字段上方、连续若干行,用缩进判断层级。
|
|
178
|
+
* @param pluginRoot 插件根目录
|
|
179
|
+
*/
|
|
180
|
+
export function parseConfigMeta (pluginRoot: string): MetaMap {
|
|
181
|
+
const dir = path.join(pluginRoot, 'config', 'default_config')
|
|
182
|
+
const result: MetaMap = {}
|
|
183
|
+
let files: string[] = []
|
|
184
|
+
try {
|
|
185
|
+
files = fs.readdirSync(dir).filter((item) => item.endsWith('.yaml'))
|
|
186
|
+
} catch {
|
|
187
|
+
return result
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
for (const file of files) {
|
|
191
|
+
const mod = file.replace(/\.yaml$/, '')
|
|
192
|
+
let content = ''
|
|
193
|
+
try {
|
|
194
|
+
content = fs.readFileSync(path.join(dir, file), 'utf8')
|
|
195
|
+
} catch {
|
|
196
|
+
continue
|
|
197
|
+
}
|
|
198
|
+
const stack: Array<{ indent: number; key: string }> = []
|
|
199
|
+
let comments: string[] = []
|
|
200
|
+
|
|
201
|
+
for (const rawLine of content.split(/\r?\n/)) {
|
|
202
|
+
const trimmed = rawLine.trim()
|
|
203
|
+
if (!trimmed) {
|
|
204
|
+
comments = []
|
|
205
|
+
continue
|
|
206
|
+
}
|
|
207
|
+
if (trimmed.startsWith('#')) {
|
|
208
|
+
comments.push(trimmed.replace(/^#\s?/, '').trimEnd())
|
|
209
|
+
continue
|
|
210
|
+
}
|
|
211
|
+
const matched = rawLine.match(/^(\s*)([^\s:#][^:#]*?)\s*:/)
|
|
212
|
+
if (!matched) {
|
|
213
|
+
// 数组项、缩进文本等
|
|
214
|
+
comments = []
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
217
|
+
const indent = matched[1].length
|
|
218
|
+
const key = matched[2].trim().replace(/^['"]|['"]$/g, '')
|
|
219
|
+
while (stack.length && stack[stack.length - 1].indent >= indent) stack.pop()
|
|
220
|
+
stack.push({ indent, key })
|
|
221
|
+
|
|
222
|
+
const fullPath = [mod, ...stack.map((item) => item.key)].join('.')
|
|
223
|
+
const text = comments.join(' ').replace(/\s+/g, ' ').trim()
|
|
224
|
+
if (text && !result[fullPath]) {
|
|
225
|
+
result[fullPath] = { text, options: extractOptions(comments, key) }
|
|
226
|
+
}
|
|
227
|
+
comments = []
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
// 上游把若干旧 YAML 合并进了 config.json 的模块(例如 amagi 里混着 request/cookies 的字段),
|
|
232
|
+
// 这些字段的完整路径对不上,补一张「唯一短名 → 描述」的表兜底。
|
|
233
|
+
const flatCount: Record<string, number> = {}
|
|
234
|
+
const flat: MetaMap = {}
|
|
235
|
+
for (const [key, value] of Object.entries(result)) {
|
|
236
|
+
const name = key.split('.').pop()!
|
|
237
|
+
flatCount[name] = (flatCount[name] ?? 0) + 1
|
|
238
|
+
flat[name] = value
|
|
239
|
+
}
|
|
240
|
+
for (const [name, count] of Object.entries(flatCount)) {
|
|
241
|
+
if (count === 1) result['#' + name] = flat[name]
|
|
242
|
+
}
|
|
243
|
+
return result
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/** 只取描述文本(对外保留的旧接口) */
|
|
247
|
+
export function parseConfigDescriptions (pluginRoot: string): DescriptionMap {
|
|
248
|
+
const meta = parseConfigMeta(pluginRoot)
|
|
249
|
+
const result: DescriptionMap = {}
|
|
250
|
+
for (const [key, value] of Object.entries(meta)) result[key] = value.text
|
|
251
|
+
return result
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* 取某个字段路径的注释信息:完整路径 → 去掉 \`[]\` 的路径 → 唯一短名兜底。
|
|
256
|
+
*
|
|
257
|
+
* 中间那一跳是为数组元素准备的:枚举解析时用的是 \`xxx[]\`,
|
|
258
|
+
* 而注释是按 \`xxx\` 登记的;同名短名(douyin/bilibili 都有 displayContent)又轮不到兜底表,
|
|
259
|
+
* 少这一跳数组字段就永远拿不到下拉选项。
|
|
260
|
+
*/
|
|
261
|
+
function metaOf (meta: MetaMap, fieldPath: string): FieldMeta | undefined {
|
|
262
|
+
return meta[fieldPath]
|
|
263
|
+
?? meta[fieldPath.replace(/\[\]$/, '')]
|
|
264
|
+
?? meta['#' + shortName(fieldPath)]
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** 取某个字段路径的描述:YAML 说明 → 唯一的短名兜底 → 手工补充 */
|
|
268
|
+
function describe (meta: MetaMap, fieldPath: string): string | undefined {
|
|
269
|
+
return metaOf(meta, fieldPath)?.text ?? SUPPLEMENT[fieldPath]
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 把候选值对齐到字段的类型上。
|
|
274
|
+
* @param options 候选值
|
|
275
|
+
* @param sample 该字段的默认值(决定类型)
|
|
276
|
+
* @returns 可用的下拉选项;类型对不上或不足 2 个时返回 undefined
|
|
277
|
+
*/
|
|
278
|
+
function coerceOptions (options: EnumOption[] | undefined, sample: unknown): EnumOption[] | undefined {
|
|
279
|
+
if (!options || options.length < 2) return undefined
|
|
280
|
+
const seen = new Set<string | number>()
|
|
281
|
+
const result: EnumOption[] = []
|
|
282
|
+
for (const option of options) {
|
|
283
|
+
let value: string | number
|
|
284
|
+
if (typeof sample === 'number') {
|
|
285
|
+
value = Number(option.value)
|
|
286
|
+
if (!Number.isFinite(value)) continue
|
|
287
|
+
} else if (typeof sample === 'string') {
|
|
288
|
+
value = String(option.value)
|
|
289
|
+
} else {
|
|
290
|
+
return undefined
|
|
291
|
+
}
|
|
292
|
+
if (seen.has(value)) continue
|
|
293
|
+
seen.add(value)
|
|
294
|
+
result.push({ value, label: option.label })
|
|
295
|
+
}
|
|
296
|
+
return result.length >= 2 ? result : undefined
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** 生成叶子字段(枚举 → 下拉;否则按类型给输入框),并带上默认值与说明 */
|
|
300
|
+
function leafSchema (sample: unknown, fieldPath: string, meta: MetaMap, ensure: unknown[] = []): Schema {
|
|
301
|
+
const withDesc = (schema: Schema): Schema => {
|
|
302
|
+
const text = describe(meta, fieldPath)
|
|
303
|
+
return text ? schema.description(text) : schema
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// 手工枚举优先(选项文案更清楚),没有就用注释里解析出来的
|
|
307
|
+
const options = coerceOptions(SUPPLEMENT_ENUMS[fieldPath] ?? metaOf(meta, fieldPath)?.options, sample)
|
|
308
|
+
if (options) {
|
|
309
|
+
const list = [...options]
|
|
310
|
+
/**
|
|
311
|
+
* 默认值必须出现在选项里。
|
|
312
|
+
* 对数组字段这不是理论问题:上游注释里 \`douyin.displayContent\` 就漏写了 \`desc\`,
|
|
313
|
+
* 而默认值里有它 —— 不补进去,控制台一保存就会写出一个 Schema 校验不过的值。
|
|
314
|
+
*/
|
|
315
|
+
for (const value of [sample, ...ensure]) {
|
|
316
|
+
if (typeof value !== 'string' && typeof value !== 'number') continue
|
|
317
|
+
if (list.some((option) => option.value === value)) continue
|
|
318
|
+
list.unshift({ value, label: String(value) + '(默认值,注释里未列出)' })
|
|
319
|
+
}
|
|
320
|
+
const union = Schema.union(
|
|
321
|
+
list.map((option) => Schema.const(option.value as never).description(option.label || String(option.value)))
|
|
322
|
+
)
|
|
323
|
+
return withDesc(union.default(sample as never))
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (typeof sample === 'boolean') return withDesc(Schema.boolean().default(sample))
|
|
327
|
+
if (typeof sample === 'number') return withDesc(Schema.number().default(sample))
|
|
328
|
+
if (typeof sample === 'string') return withDesc(Schema.string().default(sample))
|
|
329
|
+
return withDesc(Schema.any())
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function toSchema (value: unknown, fieldPath: string, meta: MetaMap, depth = 0): Schema {
|
|
333
|
+
if (depth > MAX_DEPTH) return Schema.any()
|
|
334
|
+
|
|
335
|
+
if (Array.isArray(value)) {
|
|
336
|
+
const sample = value.find((item) => item !== null && item !== undefined)
|
|
337
|
+
const inner = sample === undefined ? Schema.any() : leafSchema(sample, fieldPath + '[]', meta, value)
|
|
338
|
+
const text = describe(meta, fieldPath)
|
|
339
|
+
const schema = Schema.array(inner).default(value as never)
|
|
340
|
+
return text ? schema.description(text) : schema
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
if (value && typeof value === 'object') {
|
|
344
|
+
const dict: Record<string, Schema> = {}
|
|
345
|
+
for (const [key, item] of Object.entries(value as Record<string, unknown>)) {
|
|
346
|
+
dict[key] = toSchema(item, fieldPath + '.' + key, meta, depth + 1)
|
|
347
|
+
}
|
|
348
|
+
const text = describe(meta, fieldPath)
|
|
349
|
+
const schema = Schema.object(dict)
|
|
350
|
+
return text ? schema.description(text) : schema
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
return leafSchema(value, fieldPath, meta)
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/** 读取插件的默认配置,生成对应的 Koishi Schema(读不到时给个空对象,不影响启动) */
|
|
357
|
+
export function buildUpstreamSchema (pluginRoot: string): Schema {
|
|
358
|
+
try {
|
|
359
|
+
const file = path.join(pluginRoot, 'config', 'default_config', 'config.json')
|
|
360
|
+
const defaults = JSON.parse(fs.readFileSync(file, 'utf8')) as Record<string, unknown>
|
|
361
|
+
const meta = parseConfigMeta(pluginRoot)
|
|
362
|
+
const dict: Record<string, Schema> = {}
|
|
363
|
+
for (const [key, value] of Object.entries(defaults)) {
|
|
364
|
+
dict[key] = toSchema(value, key, meta)
|
|
365
|
+
}
|
|
366
|
+
return Schema.object(dict)
|
|
367
|
+
} catch {
|
|
368
|
+
return Schema.object({})
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
export default buildUpstreamSchema
|