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,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BASE_HEADERS = exports.RECOVERABLE_KEYWORDS = exports.RECOVERABLE_ERROR_CODES = exports.ERROR_CODE_MAP = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("../../../../compat/axios.js"));
|
|
8
|
+
/**
|
|
9
|
+
* 错误代码到中文描述的映射
|
|
10
|
+
*/
|
|
11
|
+
exports.ERROR_CODE_MAP = {
|
|
12
|
+
// 网络连接错误
|
|
13
|
+
ECONNRESET: '连接被重置',
|
|
14
|
+
ECONNREFUSED: '连接被拒绝',
|
|
15
|
+
ECONNABORTED: '连接中止',
|
|
16
|
+
ETIMEDOUT: '连接超时',
|
|
17
|
+
ENETUNREACH: '网络不可达',
|
|
18
|
+
EHOSTUNREACH: '主机不可达',
|
|
19
|
+
ENOTFOUND: 'DNS解析失败',
|
|
20
|
+
EPIPE: '管道破裂',
|
|
21
|
+
EAI_AGAIN: 'DNS临时失败',
|
|
22
|
+
// Axios 特定错误代码
|
|
23
|
+
ERR_BAD_OPTION_VALUE: '无效的配置选项值',
|
|
24
|
+
ERR_BAD_OPTION: '无效的配置选项',
|
|
25
|
+
ERR_NETWORK: '网络错误',
|
|
26
|
+
ERR_DEPRECATED: '使用了已弃用的功能',
|
|
27
|
+
ERR_BAD_RESPONSE: '无效的响应',
|
|
28
|
+
ERR_BAD_REQUEST: '无效的请求',
|
|
29
|
+
ERR_CANCELED: '请求被取消',
|
|
30
|
+
ERR_NOT_SUPPORT: '不支持的功能',
|
|
31
|
+
ERR_INVALID_URL: '无效的URL',
|
|
32
|
+
// HTTP 状态码相关
|
|
33
|
+
EHTTP: 'HTTP错误',
|
|
34
|
+
// 其他常见错误
|
|
35
|
+
EACCES: '权限不足',
|
|
36
|
+
ENOENT: '文件或目录不存在',
|
|
37
|
+
EMFILE: '打开的文件过多',
|
|
38
|
+
ENOSPC: '磁盘空间不足'
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* 可恢复的错误代码列表
|
|
42
|
+
*/
|
|
43
|
+
exports.RECOVERABLE_ERROR_CODES = [
|
|
44
|
+
'ECONNRESET', // 连接被重置(代理切换、网络切换、服务器断流)
|
|
45
|
+
'ETIMEDOUT', // 连接超时
|
|
46
|
+
'ECONNREFUSED', // 连接被拒绝
|
|
47
|
+
'ENOTFOUND', // DNS解析失败
|
|
48
|
+
'ENETUNREACH', // 网络不可达
|
|
49
|
+
'EHOSTUNREACH', // 主机不可达
|
|
50
|
+
'EPIPE', // 管道破裂
|
|
51
|
+
'EAI_AGAIN', // DNS临时失败
|
|
52
|
+
'ECONNABORTED' // 连接中止
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* 可恢复错误的关键词
|
|
56
|
+
*/
|
|
57
|
+
exports.RECOVERABLE_KEYWORDS = ['aborted', 'timeout', 'network', 'ECONNRESET', 'socket hang up', 'connection reset'];
|
|
58
|
+
/**
|
|
59
|
+
* Chrome 版本数据地址
|
|
60
|
+
* @remarks
|
|
61
|
+
* 访问失败时将自动尝试代理站
|
|
62
|
+
*/
|
|
63
|
+
const CHROME_VERSIONS_URL = 'https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json';
|
|
64
|
+
/**
|
|
65
|
+
* 代理前缀
|
|
66
|
+
* @remarks
|
|
67
|
+
* 直接将目标地址拼接在此域名后面即可
|
|
68
|
+
*/
|
|
69
|
+
const PROXY_PREFIX = 'https://jiashu.1win.eu.org/';
|
|
70
|
+
/**
|
|
71
|
+
* 构建浏览器 UA 字符串
|
|
72
|
+
* @param version - Chrome 版本号,例如 `146.0.7680.76`
|
|
73
|
+
* @returns UA 字符串
|
|
74
|
+
*/
|
|
75
|
+
const buildUserAgent = (version) => `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${version} Safari/537.36 Edg/${version}`;
|
|
76
|
+
/**
|
|
77
|
+
* 获取最新稳定版 Chrome 版本号
|
|
78
|
+
* @param url - 版本源地址
|
|
79
|
+
* @param proxyPrefix - 代理前缀地址,当直连失败时使用
|
|
80
|
+
* @returns 成功返回版本号,失败返回 null
|
|
81
|
+
*/
|
|
82
|
+
const fetchLatestChromeVersion = async (url, proxyPrefix) => {
|
|
83
|
+
try {
|
|
84
|
+
const resp = await axios_1.default.get(url, { timeout: 15000 });
|
|
85
|
+
const version = resp.data?.channels?.Stable?.version;
|
|
86
|
+
return typeof version === 'string' && version.length > 0 ? version : null;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
try {
|
|
90
|
+
const resp = await axios_1.default.get(`${proxyPrefix}${url}`, { timeout: 15000 });
|
|
91
|
+
const version = resp.data?.channels?.Stable?.version;
|
|
92
|
+
return typeof version === 'string' && version.length > 0 ? version : null;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* 默认 UA 字符串(降级兜底)
|
|
101
|
+
*/
|
|
102
|
+
const DEFAULT_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36 Edg/137.0.0.0';
|
|
103
|
+
/**
|
|
104
|
+
* 动态解析得到的 UA
|
|
105
|
+
* @remarks
|
|
106
|
+
* 优先使用「最新稳定版」Chrome 版本;失败时回退到内置 UA
|
|
107
|
+
*/
|
|
108
|
+
// Koishi 移植:原实现用顶层 await 拉取最新 Chrome 版本(CJS 构建不支持顶层 await),
|
|
109
|
+
// 改为先用内置 UA,随后在后台异步刷新。
|
|
110
|
+
const RESOLVED_UA = DEFAULT_UA;
|
|
111
|
+
/**
|
|
112
|
+
* 默认请求头
|
|
113
|
+
*/
|
|
114
|
+
exports.BASE_HEADERS = {
|
|
115
|
+
Accept: '*/*',
|
|
116
|
+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
|
117
|
+
'User-Agent': RESOLVED_UA
|
|
118
|
+
};
|
|
119
|
+
// 后台刷新 UA(失败保持内置兜底,不影响请求)
|
|
120
|
+
void (async () => {
|
|
121
|
+
try {
|
|
122
|
+
const latest = await fetchLatestChromeVersion(CHROME_VERSIONS_URL, PROXY_PREFIX);
|
|
123
|
+
if (latest)
|
|
124
|
+
exports.BASE_HEADERS['User-Agent'] = buildUserAgent(latest);
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
// 忽略:保持 DEFAULT_UA
|
|
128
|
+
}
|
|
129
|
+
})();
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sanitizeFilename = exports.extractTotalBytesFromHeaders = exports.formatBytes = exports.calculateBackoffDelay = exports.isThrottlingError = exports.isRecoverableNetworkError = exports.sanitizeHeaders = exports.sanitizeIP = exports.getErrorDescription = void 0;
|
|
4
|
+
const axios_1 = require("../../../../compat/axios.js");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
/**
|
|
7
|
+
* 获取错误的中英文描述
|
|
8
|
+
* @param error 错误对象
|
|
9
|
+
* @returns 格式化的错误描述
|
|
10
|
+
*/
|
|
11
|
+
const getErrorDescription = (error) => {
|
|
12
|
+
const code = error?.code || (error instanceof axios_1.AxiosError ? error.code : null);
|
|
13
|
+
const message = error?.message || String(error);
|
|
14
|
+
if (code && constants_1.ERROR_CODE_MAP[code]) {
|
|
15
|
+
return `${constants_1.ERROR_CODE_MAP[code]} (${code}): ${message}`;
|
|
16
|
+
}
|
|
17
|
+
else if (code) {
|
|
18
|
+
return `错误代码 ${code}: ${message}`;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
return message;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
exports.getErrorDescription = getErrorDescription;
|
|
25
|
+
/**
|
|
26
|
+
* 脱敏处理IP地址
|
|
27
|
+
* @param text 包含IP的文本
|
|
28
|
+
* @returns 脱敏后的文本
|
|
29
|
+
*/
|
|
30
|
+
const sanitizeIP = (text) => {
|
|
31
|
+
if (!text)
|
|
32
|
+
return text;
|
|
33
|
+
// IPv4 脱敏: 192.168.1.1 -> 192.168.*.*
|
|
34
|
+
text = text.replace(/\b(\d{1,3}\.\d{1,3})\.\d{1,3}\.\d{1,3}\b/g, '$1.*.*');
|
|
35
|
+
// IPv6 脱敏: 2001:0db8:85a3::8a2e:0370:7334 -> 2001:0db8:****
|
|
36
|
+
text = text.replace(/\b([0-9a-fA-F]{1,4}:[0-9a-fA-F]{1,4}):[0-9a-fA-F:]+\b/g, '$1:****');
|
|
37
|
+
return text;
|
|
38
|
+
};
|
|
39
|
+
exports.sanitizeIP = sanitizeIP;
|
|
40
|
+
/**
|
|
41
|
+
* 脱敏处理敏感请求头信息
|
|
42
|
+
* @param headers 原始请求头
|
|
43
|
+
* @returns 脱敏后的请求头(敏感字段直接删除)
|
|
44
|
+
*/
|
|
45
|
+
const sanitizeHeaders = (headers) => {
|
|
46
|
+
if (!headers)
|
|
47
|
+
return {};
|
|
48
|
+
const sanitized = {};
|
|
49
|
+
const sensitiveKeys = ['cookie', 'cookies', 'authorization', 'x-api-key', 'api-key', 'token'];
|
|
50
|
+
const ipSensitiveKeys = ['x-forwarded-for', 'x-real-ip', 'x-client-ip', 'x-originating-ip'];
|
|
51
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
52
|
+
const lowerKey = key.toLowerCase();
|
|
53
|
+
// 敏感字段直接跳过,不添加到结果中
|
|
54
|
+
if (sensitiveKeys.some((sk) => lowerKey.includes(sk))) {
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
// IP 相关字段也直接跳过
|
|
58
|
+
if (ipSensitiveKeys.some((sk) => lowerKey.includes(sk))) {
|
|
59
|
+
continue;
|
|
60
|
+
}
|
|
61
|
+
// 其他字段保留
|
|
62
|
+
sanitized[key] = String(value);
|
|
63
|
+
}
|
|
64
|
+
return sanitized;
|
|
65
|
+
};
|
|
66
|
+
exports.sanitizeHeaders = sanitizeHeaders;
|
|
67
|
+
/**
|
|
68
|
+
* 判断错误是否为可恢复的网络错误
|
|
69
|
+
* @param error 错误对象
|
|
70
|
+
* @returns 是否为可恢复错误
|
|
71
|
+
*/
|
|
72
|
+
const isRecoverableNetworkError = (error) => {
|
|
73
|
+
// 检查错误代码
|
|
74
|
+
if (error?.code && constants_1.RECOVERABLE_ERROR_CODES.includes(error.code)) {
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
// 检查 AxiosError
|
|
78
|
+
if (error instanceof axios_1.AxiosError) {
|
|
79
|
+
if (error.code && constants_1.RECOVERABLE_ERROR_CODES.includes(error.code)) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const errorMessage = error.message?.toLowerCase() || '';
|
|
83
|
+
if (constants_1.RECOVERABLE_KEYWORDS.some((keyword) => errorMessage.includes(keyword.toLowerCase()))) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// 检查普通 Error
|
|
88
|
+
if (error instanceof Error) {
|
|
89
|
+
const errorMessage = error.message?.toLowerCase() || '';
|
|
90
|
+
if (constants_1.RECOVERABLE_KEYWORDS.some((keyword) => errorMessage.includes(keyword.toLowerCase()))) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
96
|
+
exports.isRecoverableNetworkError = isRecoverableNetworkError;
|
|
97
|
+
/**
|
|
98
|
+
* 判断是否为服务器断流(风控)导致的错误
|
|
99
|
+
* @param error 错误对象
|
|
100
|
+
* @returns 是否为断流错误
|
|
101
|
+
*/
|
|
102
|
+
const isThrottlingError = (error) => {
|
|
103
|
+
const code = error?.code || (error instanceof axios_1.AxiosError ? error.code : null);
|
|
104
|
+
// ECONNRESET 是最常见的断流错误
|
|
105
|
+
if (code === 'ECONNRESET') {
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
// 检查错误消息
|
|
109
|
+
const message = error?.message?.toLowerCase() || '';
|
|
110
|
+
const throttlingKeywords = ['connection reset', 'socket hang up', 'econnreset'];
|
|
111
|
+
return throttlingKeywords.some((keyword) => message.includes(keyword));
|
|
112
|
+
};
|
|
113
|
+
exports.isThrottlingError = isThrottlingError;
|
|
114
|
+
/**
|
|
115
|
+
* 计算指数退避延迟
|
|
116
|
+
* @param retryCount 当前重试次数
|
|
117
|
+
* @param baseDelay 基础延迟(毫秒)
|
|
118
|
+
* @param maxDelay 最大延迟(毫秒)
|
|
119
|
+
* @returns 延迟时间(毫秒)
|
|
120
|
+
*/
|
|
121
|
+
const calculateBackoffDelay = (retryCount, baseDelay = 1000, maxDelay = 8000) => {
|
|
122
|
+
return Math.min(2 ** retryCount * baseDelay, maxDelay);
|
|
123
|
+
};
|
|
124
|
+
exports.calculateBackoffDelay = calculateBackoffDelay;
|
|
125
|
+
/**
|
|
126
|
+
* 格式化字节数为可读字符串
|
|
127
|
+
* @param bytes 字节数
|
|
128
|
+
* @returns 格式化后的字符串
|
|
129
|
+
*/
|
|
130
|
+
const formatBytes = (bytes) => {
|
|
131
|
+
if (bytes < 1024)
|
|
132
|
+
return `${bytes} B`;
|
|
133
|
+
if (bytes < 1024 * 1024)
|
|
134
|
+
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
135
|
+
if (bytes < 1024 * 1024 * 1024)
|
|
136
|
+
return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
|
|
137
|
+
return `${(bytes / (1024 * 1024 * 1024)).toFixed(2)} GB`;
|
|
138
|
+
};
|
|
139
|
+
exports.formatBytes = formatBytes;
|
|
140
|
+
/**
|
|
141
|
+
* 从响应头中提取文件总字节数
|
|
142
|
+
* @param headers 响应头
|
|
143
|
+
* @returns 文件总大小,无法提取时返回 0
|
|
144
|
+
*/
|
|
145
|
+
const extractTotalBytesFromHeaders = (headers) => {
|
|
146
|
+
if (!headers)
|
|
147
|
+
return 0;
|
|
148
|
+
const contentRange = headers['content-range'];
|
|
149
|
+
const contentRangeText = Array.isArray(contentRange) ? contentRange[0] : String(contentRange ?? '');
|
|
150
|
+
const rangeMatch = contentRangeText.match(/\/(\d+)(?:\s*$)/);
|
|
151
|
+
if (rangeMatch) {
|
|
152
|
+
return Number.parseInt(rangeMatch[1], 10);
|
|
153
|
+
}
|
|
154
|
+
const contentLength = headers['content-length'];
|
|
155
|
+
const contentLengthText = Array.isArray(contentLength) ? contentLength[0] : String(contentLength ?? '');
|
|
156
|
+
const parsedLength = Number.parseInt(contentLengthText, 10);
|
|
157
|
+
return Number.isFinite(parsedLength) ? parsedLength : 0;
|
|
158
|
+
};
|
|
159
|
+
exports.extractTotalBytesFromHeaders = extractTotalBytesFromHeaders;
|
|
160
|
+
/**
|
|
161
|
+
* 清理文件名,移除不安全字符
|
|
162
|
+
* @param filename 原始文件名
|
|
163
|
+
* @returns 安全的文件名
|
|
164
|
+
*/
|
|
165
|
+
const sanitizeFilename = (filename) => {
|
|
166
|
+
// 替换非法符号 + 控制字符
|
|
167
|
+
return filename
|
|
168
|
+
.replace(/[<>:"/\\|?*\p{Cc}]/gu, '_')
|
|
169
|
+
.replace(/^\.+/, '')
|
|
170
|
+
.replace(/\.+$/, '')
|
|
171
|
+
.replace(/\s+/g, '_')
|
|
172
|
+
.substring(0, 200);
|
|
173
|
+
};
|
|
174
|
+
exports.sanitizeFilename = sanitizeFilename;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Network 模块
|
|
4
|
+
* 提供网络请求、文件下载(支持限速和断点续传)等功能
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.baseHeaders = exports.DEFAULT_THROTTLE_CONFIG = exports.ThrottleStream = exports.Networks = exports.Network = exports.ImageDownloader = exports.sanitizeHeaders = exports.sanitizeFilename = exports.isThrottlingError = exports.isRecoverableNetworkError = exports.getErrorDescription = exports.formatBytes = exports.extractTotalBytesFromHeaders = exports.calculateBackoffDelay = exports.Downloader = exports.BASE_HEADERS = void 0;
|
|
8
|
+
var constants_1 = require("./constants");
|
|
9
|
+
Object.defineProperty(exports, "BASE_HEADERS", { enumerable: true, get: function () { return constants_1.BASE_HEADERS; } });
|
|
10
|
+
var Downloader_1 = require("./Downloader");
|
|
11
|
+
Object.defineProperty(exports, "Downloader", { enumerable: true, get: function () { return Downloader_1.Downloader; } });
|
|
12
|
+
var helpers_1 = require("./helpers");
|
|
13
|
+
Object.defineProperty(exports, "calculateBackoffDelay", { enumerable: true, get: function () { return helpers_1.calculateBackoffDelay; } });
|
|
14
|
+
Object.defineProperty(exports, "extractTotalBytesFromHeaders", { enumerable: true, get: function () { return helpers_1.extractTotalBytesFromHeaders; } });
|
|
15
|
+
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return helpers_1.formatBytes; } });
|
|
16
|
+
Object.defineProperty(exports, "getErrorDescription", { enumerable: true, get: function () { return helpers_1.getErrorDescription; } });
|
|
17
|
+
Object.defineProperty(exports, "isRecoverableNetworkError", { enumerable: true, get: function () { return helpers_1.isRecoverableNetworkError; } });
|
|
18
|
+
Object.defineProperty(exports, "isThrottlingError", { enumerable: true, get: function () { return helpers_1.isThrottlingError; } });
|
|
19
|
+
Object.defineProperty(exports, "sanitizeFilename", { enumerable: true, get: function () { return helpers_1.sanitizeFilename; } });
|
|
20
|
+
Object.defineProperty(exports, "sanitizeHeaders", { enumerable: true, get: function () { return helpers_1.sanitizeHeaders; } });
|
|
21
|
+
var ImageDownloader_1 = require("./ImageDownloader");
|
|
22
|
+
Object.defineProperty(exports, "ImageDownloader", { enumerable: true, get: function () { return ImageDownloader_1.ImageDownloader; } });
|
|
23
|
+
var Network_1 = require("./Network");
|
|
24
|
+
Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return Network_1.Network; } });
|
|
25
|
+
// 为了向后兼容,同时导出 Networks 别名
|
|
26
|
+
var Network_2 = require("./Network");
|
|
27
|
+
Object.defineProperty(exports, "Networks", { enumerable: true, get: function () { return Network_2.Network; } });
|
|
28
|
+
var ThrottleStream_1 = require("./ThrottleStream");
|
|
29
|
+
Object.defineProperty(exports, "ThrottleStream", { enumerable: true, get: function () { return ThrottleStream_1.ThrottleStream; } });
|
|
30
|
+
var types_1 = require("./types");
|
|
31
|
+
Object.defineProperty(exports, "DEFAULT_THROTTLE_CONFIG", { enumerable: true, get: function () { return types_1.DEFAULT_THROTTLE_CONFIG; } });
|
|
32
|
+
// 为了向后兼容,导出 baseHeaders 别名
|
|
33
|
+
var constants_2 = require("./constants");
|
|
34
|
+
Object.defineProperty(exports, "baseHeaders", { enumerable: true, get: function () { return constants_2.BASE_HEADERS; } });
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_THROTTLE_CONFIG = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 默认限速配置
|
|
6
|
+
*/
|
|
7
|
+
exports.DEFAULT_THROTTLE_CONFIG = {
|
|
8
|
+
enabled: true,
|
|
9
|
+
maxSpeed: 10 * 1024 * 1024, // 10 MB/s
|
|
10
|
+
autoReduceRatio: 0.7,
|
|
11
|
+
minSpeed: 1 * 1024 * 1024 // 1 MB/s
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThrottleStream = exports.sanitizeHeaders = exports.Networks = exports.Network = exports.isThrottlingError = exports.isRecoverableNetworkError = exports.getErrorDescription = exports.formatBytes = exports.extractTotalBytesFromHeaders = exports.Downloader = exports.DEFAULT_THROTTLE_CONFIG = exports.baseHeaders = exports.BASE_HEADERS = void 0;
|
|
4
|
+
var Network_1 = require("./Network");
|
|
5
|
+
Object.defineProperty(exports, "BASE_HEADERS", { enumerable: true, get: function () { return Network_1.BASE_HEADERS; } });
|
|
6
|
+
Object.defineProperty(exports, "baseHeaders", { enumerable: true, get: function () { return Network_1.baseHeaders; } });
|
|
7
|
+
Object.defineProperty(exports, "DEFAULT_THROTTLE_CONFIG", { enumerable: true, get: function () { return Network_1.DEFAULT_THROTTLE_CONFIG; } });
|
|
8
|
+
Object.defineProperty(exports, "Downloader", { enumerable: true, get: function () { return Network_1.Downloader; } });
|
|
9
|
+
Object.defineProperty(exports, "extractTotalBytesFromHeaders", { enumerable: true, get: function () { return Network_1.extractTotalBytesFromHeaders; } });
|
|
10
|
+
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return Network_1.formatBytes; } });
|
|
11
|
+
Object.defineProperty(exports, "getErrorDescription", { enumerable: true, get: function () { return Network_1.getErrorDescription; } });
|
|
12
|
+
Object.defineProperty(exports, "isRecoverableNetworkError", { enumerable: true, get: function () { return Network_1.isRecoverableNetworkError; } });
|
|
13
|
+
Object.defineProperty(exports, "isThrottlingError", { enumerable: true, get: function () { return Network_1.isThrottlingError; } });
|
|
14
|
+
Object.defineProperty(exports, "Network", { enumerable: true, get: function () { return Network_1.Network; } });
|
|
15
|
+
Object.defineProperty(exports, "Networks", { enumerable: true, get: function () { return Network_1.Networks; } });
|
|
16
|
+
Object.defineProperty(exports, "sanitizeHeaders", { enumerable: true, get: function () { return Network_1.sanitizeHeaders; } });
|
|
17
|
+
Object.defineProperty(exports, "ThrottleStream", { enumerable: true, get: function () { return Network_1.ThrottleStream; } });
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 解析去重锁。
|
|
4
|
+
*
|
|
5
|
+
* 同一次点击可能被 QQ 投递两遍(指令按钮既发消息又发交互事件、用户连点、客户端重发),
|
|
6
|
+
* 而解析本身是重活(取流 + 下载 + 发送),跑两遍的后果是:
|
|
7
|
+
* 用户看到两次「检测到链接,开始解析」,第二次还会因为缓存已被清理而失败。
|
|
8
|
+
*
|
|
9
|
+
* 这里按「会话 + 作品 + 画质 + 弹幕开关」在短时间内只放行一次;
|
|
10
|
+
* 换画质/换解析内容属于不同的键,不会被误伤。
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.acquireParseLock = acquireParseLock;
|
|
14
|
+
/** 去重窗口(毫秒) */
|
|
15
|
+
const WINDOW = 20 * 1000;
|
|
16
|
+
const recent = new Map();
|
|
17
|
+
/**
|
|
18
|
+
* 尝试取得一次解析许可。
|
|
19
|
+
* @param key 去重键(建议包含会话、作品 ID、画质与弹幕开关)
|
|
20
|
+
* @returns true = 可以解析;false = 刚刚已经跑过一次,忽略
|
|
21
|
+
*/
|
|
22
|
+
function acquireParseLock(key) {
|
|
23
|
+
const now = Date.now();
|
|
24
|
+
for (const [item, at] of recent) {
|
|
25
|
+
if (now - at > WINDOW)
|
|
26
|
+
recent.delete(item);
|
|
27
|
+
}
|
|
28
|
+
const last = recent.get(key);
|
|
29
|
+
if (last !== undefined && now - last < WINDOW)
|
|
30
|
+
return false;
|
|
31
|
+
recent.set(key, now);
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
exports.default = acquireParseLock;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runWithParseOverride = runWithParseOverride;
|
|
4
|
+
exports.getParseOverride = getParseOverride;
|
|
5
|
+
exports.parseParseFlags = parseParseFlags;
|
|
6
|
+
/**
|
|
7
|
+
* 单条消息的解析参数覆盖(画质 / 弹幕)。
|
|
8
|
+
*
|
|
9
|
+
* ## 为什么需要它
|
|
10
|
+
* QQ 平台的交互面板(见 module/utils/QqPanel.ts)让用户点按钮选画质,
|
|
11
|
+
* 但画质是**深埋在**业务代码里的全局配置读取:\`Config.bilibili.videoQuality\` 在
|
|
12
|
+
* 取流、选流、下载各写了一次,把参数一层层传下去要改十几个函数签名。
|
|
13
|
+
*
|
|
14
|
+
* 这里用 AsyncLocalStorage 把「本次解析的选择」挂在异步上下文上,
|
|
15
|
+
* Config 的 Proxy 读取时优先取覆盖值 —— 业务代码一行都不用改,
|
|
16
|
+
* 定时推送、其它会话也不会被串味(上下文只在本条消息的处理链里生效)。
|
|
17
|
+
*/
|
|
18
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
19
|
+
const storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
20
|
+
/**
|
|
21
|
+
* 在参数覆盖的上下文里执行解析。
|
|
22
|
+
* @param override 覆盖项(空对象则直接执行)
|
|
23
|
+
* @param fn 解析逻辑
|
|
24
|
+
*/
|
|
25
|
+
function runWithParseOverride(override, fn) {
|
|
26
|
+
if (!override || !Object.keys(override).length)
|
|
27
|
+
return fn();
|
|
28
|
+
return storage.run(override, fn);
|
|
29
|
+
}
|
|
30
|
+
/** 当前上下文里的覆盖项(不在解析链路里时返回 undefined) */
|
|
31
|
+
function getParseOverride() {
|
|
32
|
+
return storage.getStore();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* 解析消息里的 \`--xxx\` 参数。
|
|
36
|
+
*
|
|
37
|
+
* 约定(按钮 action.data 与手工输入通用,所以刻意做得短、好敲):
|
|
38
|
+
* - \`--qn=80\` B站画质
|
|
39
|
+
* - \`--q=1080p\` 抖音/小红书画质
|
|
40
|
+
* - \`--dm=1\` 烧录弹幕
|
|
41
|
+
* - \`--panel=1\` 只重发面板(1 = 带弹幕,0 = 纯视频)
|
|
42
|
+
* - \`--p=abc123\` 面板按钮的短令牌(真实链接存在插件内存里,见 QqPanel)
|
|
43
|
+
* @param msg 消息文本
|
|
44
|
+
* @returns 解析结果
|
|
45
|
+
*/
|
|
46
|
+
function parseParseFlags(msg) {
|
|
47
|
+
const text = String(msg ?? '');
|
|
48
|
+
const override = {};
|
|
49
|
+
let hasAny = false;
|
|
50
|
+
let panel;
|
|
51
|
+
let panelToken;
|
|
52
|
+
let bangumiPage;
|
|
53
|
+
const cleaned = text
|
|
54
|
+
.replace(/\s*--p=([0-9a-z]+)/i, (_all, value) => {
|
|
55
|
+
panelToken = value;
|
|
56
|
+
hasAny = true;
|
|
57
|
+
return '';
|
|
58
|
+
})
|
|
59
|
+
.replace(/\s*--qn=(\d+)/gi, (_all, value) => {
|
|
60
|
+
override.bilibiliQuality = Number(value);
|
|
61
|
+
hasAny = true;
|
|
62
|
+
return '';
|
|
63
|
+
})
|
|
64
|
+
.replace(/\s*--q=([0-9a-z]+)/gi, (_all, value) => {
|
|
65
|
+
override.douyinQuality = value;
|
|
66
|
+
override.xiaohongshuQuality = value;
|
|
67
|
+
hasAny = true;
|
|
68
|
+
return '';
|
|
69
|
+
})
|
|
70
|
+
.replace(/\s*--dm=1/gi, () => {
|
|
71
|
+
override.burnDanmaku = true;
|
|
72
|
+
hasAny = true;
|
|
73
|
+
return '';
|
|
74
|
+
})
|
|
75
|
+
.replace(/\s*--panel=([01])/gi, (_all, value) => {
|
|
76
|
+
panel = value === '1' ? 1 : 0;
|
|
77
|
+
hasAny = true;
|
|
78
|
+
return '';
|
|
79
|
+
})
|
|
80
|
+
.replace(/\s*--bgp=(\d+)/gi, (_all, value) => {
|
|
81
|
+
bangumiPage = Number(value);
|
|
82
|
+
hasAny = true;
|
|
83
|
+
return '';
|
|
84
|
+
})
|
|
85
|
+
.trim();
|
|
86
|
+
return { override, cleaned, hasAny, panel, panelToken, bangumiPage };
|
|
87
|
+
}
|
|
88
|
+
exports.default = parseParseFlags;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveBiliCard = resolveBiliCard;
|
|
4
|
+
exports.resolveQqCardContent = resolveQqCardContent;
|
|
5
|
+
/**
|
|
6
|
+
* QQ 卡片「无链接」还原。
|
|
7
|
+
*
|
|
8
|
+
* QQ 官方适配器把分享卡片整段当文本丢进来,而新版卡片**连跳转链接都没有**,
|
|
9
|
+
* 于是各平台的链接正则一条都匹配不上 —— 用户侧的表现就是「卡片发出来没反应」。
|
|
10
|
+
* 这里把卡片(详见 compat/qqcard.ts)还原成一条规范链接,追加到消息文本末尾,
|
|
11
|
+
* 让原有的解析命令照常命中:命令本身仍按前缀匹配,普通消息完全不受影响。
|
|
12
|
+
*
|
|
13
|
+
* 匹配策略(强 → 弱):
|
|
14
|
+
* 1. 卡片自带 B 站链接(b23.tv / bilibili.com)→ 直接规范化;
|
|
15
|
+
* 2. 卡片封面哈希 == 搜索结果的 \`pic\` 哈希 → 同一张稿件封面,直接认定;
|
|
16
|
+
* 3. 标题包含/相等(打分 ≥ 60)→ 认定。
|
|
17
|
+
* 认不出来就**不还原**,宁可让下游提示「未找到链接」,也不要猜错视频解析出别人的内容。
|
|
18
|
+
*/
|
|
19
|
+
const node_karin_1 = require("../../../compat/node-karin.js");
|
|
20
|
+
const qqcard_1 = require("../../../compat/qqcard");
|
|
21
|
+
const text_1 = require("../../../compat/text");
|
|
22
|
+
const search_1 = require("../../platform/bilibili/search");
|
|
23
|
+
/** B 站链接特征(消息里已经有链接就不用还原了) */
|
|
24
|
+
const BILI_URL = /bilibili\.com|b23\.tv|bili2233|\bBV[0-9A-Za-z]{10}\b/i;
|
|
25
|
+
/** 还原结果缓存:同一条卡片消息会被匹配、命令、统计等多处读取,没必要重复搜索 */
|
|
26
|
+
const cache = new Map();
|
|
27
|
+
const CACHE_LIMIT = 64;
|
|
28
|
+
/** 认不认这条搜索结果 */
|
|
29
|
+
const isConfident = (item) => item.coverMatch || item.score >= 60;
|
|
30
|
+
/** 纯平台名/占位词,拿去搜索只会搜到无关视频 */
|
|
31
|
+
const GENERIC_TITLE = /^(哔哩哔哩|bilibili|视频|弹幕|分享|网页链接|抖音|快手|小红书)+$/i;
|
|
32
|
+
/**
|
|
33
|
+
* 标题是否值得拿去搜索。
|
|
34
|
+
* 卡片字段缺失时标题可能是「哔哩哔哩」这类来源名,与其拿它赌一个视频,不如放弃还原。
|
|
35
|
+
* @param title 卡片标题
|
|
36
|
+
*/
|
|
37
|
+
const isSearchableTitle = (title) => {
|
|
38
|
+
const key = String(title ?? '').replace(/\s+/g, '');
|
|
39
|
+
return key.length >= 4 && !GENERIC_TITLE.test(key);
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* 把一张 B 站卡片还原成规范视频链接。
|
|
43
|
+
* @param card 卡片
|
|
44
|
+
* @returns 规范链接;无法确定时返回空串
|
|
45
|
+
*/
|
|
46
|
+
async function resolveBiliCard(card) {
|
|
47
|
+
const inline = card.urls.find((url) => BILI_URL.test(url) || /\bBV[0-9A-Za-z]{10}\b/.test(url));
|
|
48
|
+
if (inline)
|
|
49
|
+
return await (0, search_1.resolveBiliCanonicalUrl)(inline);
|
|
50
|
+
if (!isSearchableTitle(card.title)) {
|
|
51
|
+
node_karin_1.logger.debug('[QQ卡片] 标题「' + card.title + '」过于宽泛,放弃搜索还原');
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
const items = await (0, search_1.searchBilibiliVideos)({
|
|
55
|
+
keyword: card.title,
|
|
56
|
+
title: card.title,
|
|
57
|
+
author: card.author,
|
|
58
|
+
cover: card.cover,
|
|
59
|
+
limit: 8
|
|
60
|
+
});
|
|
61
|
+
const best = items.find(isConfident);
|
|
62
|
+
if (!best) {
|
|
63
|
+
node_karin_1.logger.debug('[QQ卡片] 标题「' + card.title + '」没有找到足够可信的B站视频,放弃还原' + (items[0] ? '(最高分 ' + items[0].score + ':' + items[0].title + ')' : ''));
|
|
64
|
+
return '';
|
|
65
|
+
}
|
|
66
|
+
node_karin_1.logger.debug('[QQ卡片] 还原B站视频: ' + best.title + ' → ' + best.bvid + '(分数 ' + best.score + (best.coverMatch ? ',封面命中' : '') + ')');
|
|
67
|
+
return 'https://www.bilibili.com/video/' + best.bvid;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* 归一化一条消息文本:JSON 转义还原 + 已有链接提取 + 无链接卡片搜索还原。
|
|
71
|
+
*
|
|
72
|
+
* 普通消息走同步快路径(一次 \`includes('{')\` 就返回),只有疑似卡片的文本才会触发网络搜索。
|
|
73
|
+
* @param content 原始消息文本
|
|
74
|
+
* @returns 可交给解析命令的文本
|
|
75
|
+
*/
|
|
76
|
+
async function resolveQqCardContent(content) {
|
|
77
|
+
const raw = String(content ?? '');
|
|
78
|
+
const base = (0, text_1.normalizeMessageText)(raw);
|
|
79
|
+
if (!raw || !raw.includes('{'))
|
|
80
|
+
return base;
|
|
81
|
+
const cached = cache.get(raw);
|
|
82
|
+
if (cached !== undefined)
|
|
83
|
+
return cached;
|
|
84
|
+
const result = await resolveCards(raw, base);
|
|
85
|
+
if (cache.size >= CACHE_LIMIT)
|
|
86
|
+
cache.delete(cache.keys().next().value);
|
|
87
|
+
cache.set(raw, result);
|
|
88
|
+
return result;
|
|
89
|
+
}
|
|
90
|
+
/** 实际的还原逻辑(与缓存分开,便于阅读) */
|
|
91
|
+
async function resolveCards(raw, base) {
|
|
92
|
+
const cards = (0, qqcard_1.parseQqCards)(raw);
|
|
93
|
+
if (!cards.length)
|
|
94
|
+
return base;
|
|
95
|
+
// 已经有 B 站链接的消息不用还原:解析命令自己就能处理短链
|
|
96
|
+
if ((0, text_1.extractUrls)(base).some((url) => BILI_URL.test(url)))
|
|
97
|
+
return base;
|
|
98
|
+
const targets = cards.filter((card) => card.platform === 'bilibili' && isSearchableTitle(card.title)).slice(0, 2);
|
|
99
|
+
if (!targets.length)
|
|
100
|
+
return base;
|
|
101
|
+
const extra = [];
|
|
102
|
+
for (const card of targets) {
|
|
103
|
+
try {
|
|
104
|
+
const url = await resolveBiliCard(card);
|
|
105
|
+
if (url && !base.includes(url) && !extra.includes(url))
|
|
106
|
+
extra.push(url);
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
node_karin_1.logger.debug('[QQ卡片] 还原失败: ' + String(error));
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return extra.length ? base + ' ' + extra.join(' ') : base;
|
|
113
|
+
}
|
|
114
|
+
exports.default = resolveQqCardContent;
|