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,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VideoCameraIcon = exports.UsersThreeIcon = exports.UsersIcon = exports.UserPlusIcon = exports.Question = exports.Play = exports.PlayIcon = exports.MusicNoteIcon = exports.MapPinIcon = exports.ImageIcon = exports.ClockIcon = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* `@phosphor-icons/react` 的替代实现。
|
|
6
|
+
*
|
|
7
|
+
* 为什么要替:这个包 **本身有 bug** —— 它的 package.json 是 `"type": "module"`,
|
|
8
|
+
* 但 `exports.require` 指向 `./dist/index.cjs.js`(`.js` 在 ESM 包里会被当成 ESM ✗),
|
|
9
|
+
* 于是模板一旦 `require` 它就抛:
|
|
10
|
+
* `exports is not defined in ES module scope ... @phosphor-icons/react/package.json contains "type": "module"`
|
|
11
|
+
* 结果是**所有卡片模板都加载失败、退化成通用兜底卡**(用户看到的就是「模板怎么崩了」)。
|
|
12
|
+
*
|
|
13
|
+
* 这里接一层:用已经在依赖里的 `lucide-react`(CJS 正常 ✓)逐个映射成同名导出,
|
|
14
|
+
* 调用方(模板)不用改任何代码,图标风格略有差异但卡片能正常渲染。
|
|
15
|
+
*/
|
|
16
|
+
var lucide_react_1 = require("lucide-react");
|
|
17
|
+
Object.defineProperty(exports, "ClockIcon", { enumerable: true, get: function () { return lucide_react_1.Clock; } });
|
|
18
|
+
Object.defineProperty(exports, "ImageIcon", { enumerable: true, get: function () { return lucide_react_1.Image; } });
|
|
19
|
+
Object.defineProperty(exports, "MapPinIcon", { enumerable: true, get: function () { return lucide_react_1.MapPin; } });
|
|
20
|
+
Object.defineProperty(exports, "MusicNoteIcon", { enumerable: true, get: function () { return lucide_react_1.Music; } });
|
|
21
|
+
Object.defineProperty(exports, "PlayIcon", { enumerable: true, get: function () { return lucide_react_1.Play; } });
|
|
22
|
+
Object.defineProperty(exports, "Play", { enumerable: true, get: function () { return lucide_react_1.Play; } });
|
|
23
|
+
Object.defineProperty(exports, "Question", { enumerable: true, get: function () { return lucide_react_1.CircleHelp; } });
|
|
24
|
+
Object.defineProperty(exports, "UserPlusIcon", { enumerable: true, get: function () { return lucide_react_1.UserPlus; } });
|
|
25
|
+
Object.defineProperty(exports, "UsersIcon", { enumerable: true, get: function () { return lucide_react_1.Users; } });
|
|
26
|
+
Object.defineProperty(exports, "UsersThreeIcon", { enumerable: true, get: function () { return lucide_react_1.UsersRound; } });
|
|
27
|
+
Object.defineProperty(exports, "VideoCameraIcon", { enumerable: true, get: function () { return lucide_react_1.Video; } });
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* QQ 分享卡片解析 + 「无链接卡片」还原。
|
|
4
|
+
*
|
|
5
|
+
* ## 背景
|
|
6
|
+
* QQ 官方适配器(koishi-plugin-adapter-qq-crack,platform=\`qqguild\`)把卡片消息**整段塞进文本**,
|
|
7
|
+
* 不同来源的卡片长的也不一样,常见三种:
|
|
8
|
+
*
|
|
9
|
+
* \`\`\`text
|
|
10
|
+
* // 1. 小程序卡片(B站/抖音),meta.detail_1 里带 qqdocurl
|
|
11
|
+
* {"app":"com.tencent.structmsg","meta":{"detail_1":{"qqdocurl":"https:\\/\\/b23.tv\\/xxxx"}}}
|
|
12
|
+
* // 2. 新版分享卡片,链接在 meta.news.jumpUrl
|
|
13
|
+
* {"app":"com.tencent.structmsg","view":"news","meta":{"news":{"tag":"哔哩哔哩","title":"...","jumpUrl":"..."}}}
|
|
14
|
+
* // 3. 只有标题和封面,**一个链接都没有**(QQ 端把跳转吞了)
|
|
15
|
+
* {"app":"com.tencent.miniapp_01","desc":"哔哩哔哩","meta":{"detail_1":{"appid":"1109937557","title":"..."}}}
|
|
16
|
+
* \`\`\`
|
|
17
|
+
*
|
|
18
|
+
* 第 3 种是纯解析链路救不回来的:插件拿到的文本里没有 URL,各平台的链接正则必然匹配不到。
|
|
19
|
+
* koishi-plugin-qq-chat 的做法是「标题 + 封面 OCR 出的 UP 主」去 B 站搜索匹配;
|
|
20
|
+
* 这里做得更直接 —— 卡片封面往往就是 B 站图床的稿件封面,
|
|
21
|
+
* 直接用**封面哈希**和搜索结果里的 \`pic\` 对齐(见 platform/bilibili/search.ts),
|
|
22
|
+
* 哈希认不出来再退化成标题/作者打分。
|
|
23
|
+
*
|
|
24
|
+
* 因此本模块只做两件事:
|
|
25
|
+
* 1. {@link parseQqCards}:把消息文本里的卡片 JSON 挖出来,归一化成 {@link QqCard};
|
|
26
|
+
* 2. {@link resolveCardsInText}:对「没有链接的 B 站卡片」做搜索还原,把规范链接追加到文本末尾,
|
|
27
|
+
* 让下游的解析命令照常命中(命令本身仍按前缀匹配,不受影响)。
|
|
28
|
+
*/
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.extractJsonObjects = extractJsonObjects;
|
|
31
|
+
exports.toQqCard = toQqCard;
|
|
32
|
+
exports.parseQqCards = parseQqCards;
|
|
33
|
+
exports.coverArchiveHash = coverArchiveHash;
|
|
34
|
+
/** 小程序 appid → 平台 */
|
|
35
|
+
const APPID_PLATFORM = {
|
|
36
|
+
// 哔哩哔哩小程序
|
|
37
|
+
'1109937557': 'bilibili',
|
|
38
|
+
// 抖音小程序
|
|
39
|
+
'1109937556': 'douyin',
|
|
40
|
+
'1110083189': 'douyin',
|
|
41
|
+
// 快手小程序
|
|
42
|
+
'1109937559': 'kuaishou'
|
|
43
|
+
};
|
|
44
|
+
/** 文本特征 → 平台 */
|
|
45
|
+
const TEXT_PLATFORM = [
|
|
46
|
+
{ platform: 'bilibili', pattern: /哔哩哔哩|bilibili|b23\.tv|bili2233|\bBV[0-9A-Za-z]{10}\b/i },
|
|
47
|
+
{ platform: 'douyin', pattern: /抖音|douyin|iesdouyin/i },
|
|
48
|
+
{ platform: 'kuaishou', pattern: /快手|kuaishou/i },
|
|
49
|
+
{ platform: 'xiaohongshu', pattern: /小红书|xiaohongshu|xhslink/i }
|
|
50
|
+
];
|
|
51
|
+
/** 取字段用的键名表 */
|
|
52
|
+
const TITLE_KEYS = /^(title|desc|description|summary|subtitle|prompt|tag|source|from|appname)$/i;
|
|
53
|
+
/**
|
|
54
|
+
* 「真标题」键名。
|
|
55
|
+
*
|
|
56
|
+
* 必须和 {@link TITLE_KEYS} 区分开:ark 里 `desc`/`tag` 是「哔哩哔哩」这种来源名,
|
|
57
|
+
* 而它们**排在 title 前面**,混在一起取第一个字段会把来源名当成视频标题
|
|
58
|
+
* (后果是拿「哔哩哔哩」去搜索,匹配到完全无关的视频)。
|
|
59
|
+
*/
|
|
60
|
+
const REAL_TITLE_KEY = /^title$/i;
|
|
61
|
+
const COVER_KEYS = /^(preview|icon|image|imageurl|picurl|pic|cover|coverurl|thumb|thumbnail|img|imgurl|headimg)$/i;
|
|
62
|
+
const URL_KEYS = /^(jumpurl|qqdocurl|url|contenturl|shareurl|link|targeturl|weburl|h5url|pageurl|sourceurl)$/i;
|
|
63
|
+
const AUTHOR_KEYS = /^(author|nickname|nick|upname|up_name|username|name|uploader)$/i;
|
|
64
|
+
/** JSON 转义还原(与 compat/text.ts 保持同一套规则,但这里要能解析回对象) */
|
|
65
|
+
function unescapeJson(input) {
|
|
66
|
+
return input
|
|
67
|
+
.replace(/\\u002[fF]/g, '/')
|
|
68
|
+
.replace(/\\\//g, '/')
|
|
69
|
+
.replace(/\\"/g, '"')
|
|
70
|
+
.replace(/\\u0026/gi, '&');
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 从一段文本里挖出所有「括号配平」的 JSON 对象字面量。
|
|
74
|
+
*
|
|
75
|
+
* 不能用 \`/\{[^{}]*\}/\` 这类正则:ark 是嵌套结构,正则只能匹配到最内层;
|
|
76
|
+
* 也不能按 \`{"app"\` 切分:一张卡片里可能同时出现多个对象(实测有 \`meta\` 和 \`config\`)。
|
|
77
|
+
* 所以老老实实扫一遍括号,并且**跳过字符串内部的括号**(卡片里就有标题带花括号的)。
|
|
78
|
+
* @param text 原始文本
|
|
79
|
+
* @returns JSON 子串数组
|
|
80
|
+
*/
|
|
81
|
+
function extractJsonObjects(text) {
|
|
82
|
+
const result = [];
|
|
83
|
+
let depth = 0;
|
|
84
|
+
let start = -1;
|
|
85
|
+
let inString = false;
|
|
86
|
+
let escaped = false;
|
|
87
|
+
for (let i = 0; i < text.length; i++) {
|
|
88
|
+
const char = text[i];
|
|
89
|
+
if (inString) {
|
|
90
|
+
if (escaped)
|
|
91
|
+
escaped = false;
|
|
92
|
+
else if (char === '\\')
|
|
93
|
+
escaped = true;
|
|
94
|
+
else if (char === '"')
|
|
95
|
+
inString = false;
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
if (char === '"') {
|
|
99
|
+
inString = true;
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
if (char === '{') {
|
|
103
|
+
if (depth === 0)
|
|
104
|
+
start = i;
|
|
105
|
+
depth += 1;
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
if (char === '}') {
|
|
109
|
+
if (depth > 0) {
|
|
110
|
+
depth -= 1;
|
|
111
|
+
if (depth === 0 && start >= 0)
|
|
112
|
+
result.push(text.slice(start, i + 1));
|
|
113
|
+
}
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
119
|
+
/** 递归收集卡片里的文本 / 封面 / 链接 / 作者字段(保持出现顺序,去重) */
|
|
120
|
+
function collectFields(node, bucket, depth = 0) {
|
|
121
|
+
if (!node || typeof node !== 'object' || depth > 8)
|
|
122
|
+
return;
|
|
123
|
+
if (Array.isArray(node)) {
|
|
124
|
+
for (const item of node)
|
|
125
|
+
collectFields(item, bucket, depth + 1);
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
for (const [key, value] of Object.entries(node)) {
|
|
129
|
+
if (typeof value === 'string') {
|
|
130
|
+
const text = value.trim();
|
|
131
|
+
if (!text)
|
|
132
|
+
continue;
|
|
133
|
+
if (key === 'appid') {
|
|
134
|
+
bucket.appids.push(text);
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
const isUrlLike = /^https?:\/\//i.test(text) || text.startsWith('//');
|
|
138
|
+
// 判定顺序很关键:按「键名」判断必须早于「值长得像 URL」。
|
|
139
|
+
// 卡片封面(preview/icon)的值本身就是 http 链接,先按值判会把封面当跳转链接收进 urls,
|
|
140
|
+
// 结果就是 cover 永远是空 —— 封面哈希这条最硬的匹配路径直接失效。
|
|
141
|
+
if (URL_KEYS.test(key) && !COVER_KEYS.test(key)) {
|
|
142
|
+
bucket.urls.push(text);
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (COVER_KEYS.test(key)) {
|
|
146
|
+
if (isUrlLike)
|
|
147
|
+
bucket.covers.push(text);
|
|
148
|
+
continue;
|
|
149
|
+
}
|
|
150
|
+
if (REAL_TITLE_KEY.test(key)) {
|
|
151
|
+
bucket.titles.push(text);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (TITLE_KEYS.test(key)) {
|
|
155
|
+
bucket.texts.push(text);
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
if (AUTHOR_KEYS.test(key)) {
|
|
159
|
+
bucket.authors.push(text);
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
if (isUrlLike) {
|
|
163
|
+
bucket.urls.push(text);
|
|
164
|
+
continue;
|
|
165
|
+
}
|
|
166
|
+
// 兜底:任何字符串里的 URL 也收进来(有的卡片把链接塞在 desc 里)
|
|
167
|
+
const matched = text.match(/https?:\/\/[^\s"'<>\\]+/gi);
|
|
168
|
+
if (matched)
|
|
169
|
+
for (const url of matched)
|
|
170
|
+
bucket.urls.push(url);
|
|
171
|
+
continue;
|
|
172
|
+
}
|
|
173
|
+
if (value && typeof value === 'object')
|
|
174
|
+
collectFields(value, bucket, depth + 1);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/** 判定平台:appid 优先,其次看所有文本里的平台特征 */
|
|
178
|
+
function detectPlatform(bucket, app, view) {
|
|
179
|
+
for (const appid of bucket.appids) {
|
|
180
|
+
const platform = APPID_PLATFORM[appid];
|
|
181
|
+
if (platform)
|
|
182
|
+
return platform;
|
|
183
|
+
}
|
|
184
|
+
const haystack = [...bucket.titles, ...bucket.texts, ...bucket.covers, ...bucket.urls, app, view].join(' ');
|
|
185
|
+
for (const { platform, pattern } of TEXT_PLATFORM) {
|
|
186
|
+
if (pattern.test(haystack))
|
|
187
|
+
return platform;
|
|
188
|
+
}
|
|
189
|
+
return 'unknown';
|
|
190
|
+
}
|
|
191
|
+
/** 从已经 JSON.parse 好的对象里归一化出一张卡片 */
|
|
192
|
+
function toQqCard(raw) {
|
|
193
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
194
|
+
return null;
|
|
195
|
+
if (typeof raw.app !== 'string' && !raw.meta && !raw.prompt)
|
|
196
|
+
return null;
|
|
197
|
+
const bucket = { titles: [], texts: [], covers: [], urls: [], authors: [], appids: [] };
|
|
198
|
+
if (typeof raw.appid === 'string')
|
|
199
|
+
bucket.appids.push(raw.appid);
|
|
200
|
+
collectFields(raw, bucket);
|
|
201
|
+
const app = typeof raw.app === 'string' ? raw.app : '';
|
|
202
|
+
const view = typeof raw.view === 'string' ? raw.view : '';
|
|
203
|
+
const prompt = typeof raw.prompt === 'string' ? raw.prompt.replace(/^\[[^\]]*\]\s*/, '') : '';
|
|
204
|
+
const unique = (list) => [...new Set(list.filter(Boolean))];
|
|
205
|
+
const texts = unique(bucket.texts);
|
|
206
|
+
const title = unique(bucket.titles)[0] ?? texts[0] ?? prompt;
|
|
207
|
+
const desc = texts.find((text) => text !== title) ?? '';
|
|
208
|
+
return {
|
|
209
|
+
app,
|
|
210
|
+
view,
|
|
211
|
+
platform: detectPlatform(bucket, app, view),
|
|
212
|
+
title,
|
|
213
|
+
desc,
|
|
214
|
+
author: unique(bucket.authors)[0] ?? '',
|
|
215
|
+
cover: unique(bucket.covers)[0] ?? '',
|
|
216
|
+
urls: unique(bucket.urls),
|
|
217
|
+
raw
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 解析一段消息文本里的所有 QQ 卡片。
|
|
222
|
+
* 普通聊天文本(没有 JSON 对象)返回空数组,代价只有一次括号扫描。
|
|
223
|
+
* @param input 消息原文(可以是 JSON 转义过的)
|
|
224
|
+
*/
|
|
225
|
+
function parseQqCards(input) {
|
|
226
|
+
const text = String(input ?? '');
|
|
227
|
+
if (!text.includes('{'))
|
|
228
|
+
return [];
|
|
229
|
+
const cards = [];
|
|
230
|
+
const seen = new Set();
|
|
231
|
+
for (const snippet of extractJsonObjects(text)) {
|
|
232
|
+
for (const candidate of [snippet, unescapeJson(snippet)]) {
|
|
233
|
+
try {
|
|
234
|
+
const card = toQqCard(JSON.parse(candidate));
|
|
235
|
+
if (!card)
|
|
236
|
+
continue;
|
|
237
|
+
const key = card.app + '|' + card.title + '|' + card.urls.join(',');
|
|
238
|
+
if (seen.has(key))
|
|
239
|
+
continue;
|
|
240
|
+
seen.add(key);
|
|
241
|
+
cards.push(card);
|
|
242
|
+
break;
|
|
243
|
+
}
|
|
244
|
+
catch {
|
|
245
|
+
// 不是合法 JSON 就换下一种写法
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
return cards;
|
|
250
|
+
}
|
|
251
|
+
/** 从卡片封面里取出 B 站图床的稿件哈希(\`.../bfs/archive/<hash>.jpg\`) */
|
|
252
|
+
function coverArchiveHash(url) {
|
|
253
|
+
const matched = String(url ?? '').match(/\/bfs\/archive\/([0-9a-f]+)(?:\.\w+)?/i);
|
|
254
|
+
return matched ? matched[1].toLowerCase() : '';
|
|
255
|
+
}
|
|
256
|
+
exports.default = parseQqCards;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.isDocker = exports.karinPathRoot = exports.karinPathTemp = exports.karinPathHtml = exports.karinPathData = exports.karinPathBase = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* `node-karin/root` 的兼容实现。
|
|
9
|
+
*
|
|
10
|
+
* 注意:karin 里 `karinPathBase` / `karinPathHtml` 是**字符串常量**(不是函数),
|
|
11
|
+
* 移植代码直接写 \`\${karinPathBase}/\${Root.pluginName}/config\`,所以这里按值导出。
|
|
12
|
+
* 值在模块首次 require 时确定,因此兼容层运行时必须在加载移植代码之前完成绑定。
|
|
13
|
+
*/
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const runtime_1 = require("./runtime");
|
|
16
|
+
/** Karin 的数据根目录 */
|
|
17
|
+
exports.karinPathBase = (() => {
|
|
18
|
+
const runtime = (0, runtime_1.tryGetRuntime)();
|
|
19
|
+
if (runtime)
|
|
20
|
+
return runtime.dataRoot;
|
|
21
|
+
// 兜底:允许在未绑定运行时时读取(例如工具脚本里)
|
|
22
|
+
return node_path_1.default.resolve(process.cwd(), 'data');
|
|
23
|
+
})();
|
|
24
|
+
/** 插件私有数据目录 */
|
|
25
|
+
exports.karinPathData = node_path_1.default.resolve(exports.karinPathBase, runtime_1.PLUGIN_DIR_NAME, 'data');
|
|
26
|
+
/**
|
|
27
|
+
* 渲染产物目录。
|
|
28
|
+
* 与 Karin 一致:这里只给根目录,具体子目录由调用方拼 \`\${karinPathHtml}/\${pluginName}\`。
|
|
29
|
+
*/
|
|
30
|
+
exports.karinPathHtml = node_path_1.default.resolve(exports.karinPathBase, 'html');
|
|
31
|
+
/** 临时文件目录(同样只给根目录,Common.tempDri 会再拼一层插件名) */
|
|
32
|
+
exports.karinPathTemp = node_path_1.default.resolve(exports.karinPathBase, 'temp');
|
|
33
|
+
/** Karin 根目录(Koishi 下即插件根目录) */
|
|
34
|
+
exports.karinPathRoot = (0, runtime_1.tryGetRuntime)()?.pluginRoot ?? process.cwd();
|
|
35
|
+
const isDocker = () => false;
|
|
36
|
+
exports.isDocker = isDocker;
|
|
37
|
+
exports.default = {
|
|
38
|
+
karinPathBase: exports.karinPathBase,
|
|
39
|
+
karinPathData: exports.karinPathData,
|
|
40
|
+
karinPathHtml: exports.karinPathHtml,
|
|
41
|
+
karinPathTemp: exports.karinPathTemp,
|
|
42
|
+
karinPathRoot: exports.karinPathRoot,
|
|
43
|
+
isDocker: exports.isDocker
|
|
44
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
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.eventQueue = exports.taskQueue = exports.commandQueue = exports.PLUGIN_DIR_NAME = void 0;
|
|
7
|
+
exports.bindRuntime = bindRuntime;
|
|
8
|
+
exports.tryGetRuntime = tryGetRuntime;
|
|
9
|
+
exports.getRuntime = getRuntime;
|
|
10
|
+
exports.commandPrefixes = commandPrefixes;
|
|
11
|
+
exports.commandInvocation = commandInvocation;
|
|
12
|
+
exports.karinPathBase = karinPathBase;
|
|
13
|
+
exports.pluginDataDir = pluginDataDir;
|
|
14
|
+
exports.karinPathHtml = karinPathHtml;
|
|
15
|
+
exports.karinPathTemp = karinPathTemp;
|
|
16
|
+
/**
|
|
17
|
+
* 兼容层运行时状态。
|
|
18
|
+
*
|
|
19
|
+
* 原 koishi-plugin-kkk 的代码在模块顶层就会调用 `karin.command(...)` / `karin.task(...)`,
|
|
20
|
+
* 这些调用发生在 Koishi 插件 apply 之前,因此先进入队列,等 apply 时绑定 ctx 再统一落地。
|
|
21
|
+
*/
|
|
22
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
23
|
+
let runtime = null;
|
|
24
|
+
function bindRuntime(value) {
|
|
25
|
+
runtime = value;
|
|
26
|
+
}
|
|
27
|
+
function tryGetRuntime() {
|
|
28
|
+
return runtime;
|
|
29
|
+
}
|
|
30
|
+
function getRuntime() {
|
|
31
|
+
if (!runtime)
|
|
32
|
+
throw new Error('[kkk] Karin 兼容层尚未初始化,请通过 koishi-plugin-kkk 插件加载');
|
|
33
|
+
return runtime;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Koishi 当前配置的命令前缀。
|
|
37
|
+
*
|
|
38
|
+
* 用户在 koishi.yml 里可以配多个,例如 \`['/', '']\`:\`''\` 表示「不带前缀直接敲指令」。
|
|
39
|
+
* 面板按钮要按这个来决定发出去的命令文本长什么样。
|
|
40
|
+
* @returns 前缀列表(可能是空串)
|
|
41
|
+
*/
|
|
42
|
+
function commandPrefixes() {
|
|
43
|
+
const value = tryGetRuntime()?.ctx?.config?.prefix;
|
|
44
|
+
if (Array.isArray(value)) {
|
|
45
|
+
const list = value.filter((item) => typeof item === 'string');
|
|
46
|
+
if (list.length)
|
|
47
|
+
return list;
|
|
48
|
+
}
|
|
49
|
+
if (typeof value === 'string')
|
|
50
|
+
return [value];
|
|
51
|
+
return [''];
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 拼一条「用户视角」的指令文本(用于 QQ 面板按钮)。
|
|
55
|
+
* @param name 指令名,例如 \`解析\`
|
|
56
|
+
* @returns 带前缀的指令(配置了空前缀时就是指令名本身)
|
|
57
|
+
*/
|
|
58
|
+
function commandInvocation(name) {
|
|
59
|
+
const prefixes = commandPrefixes();
|
|
60
|
+
if (prefixes.includes(''))
|
|
61
|
+
return name;
|
|
62
|
+
return (prefixes.find((item) => item) ?? '') + name;
|
|
63
|
+
}
|
|
64
|
+
/** 插件在数据目录下的子目录名(对应 karin 的 Root.pluginName) */
|
|
65
|
+
exports.PLUGIN_DIR_NAME = 'koishi-plugin-kkk';
|
|
66
|
+
/** Karin 的数据根目录(等价 karinPathBase),移植代码按 \`\${karinPathBase}/\${pluginName}\` 组织文件 */
|
|
67
|
+
function karinPathBase() {
|
|
68
|
+
return getRuntime().dataRoot;
|
|
69
|
+
}
|
|
70
|
+
/** 插件私有数据目录 */
|
|
71
|
+
function pluginDataDir() {
|
|
72
|
+
return node_path_1.default.resolve(karinPathBase(), exports.PLUGIN_DIR_NAME);
|
|
73
|
+
}
|
|
74
|
+
/** 渲染产物目录 */
|
|
75
|
+
function karinPathHtml() {
|
|
76
|
+
return node_path_1.default.resolve(pluginDataDir(), 'html');
|
|
77
|
+
}
|
|
78
|
+
/** 临时文件目录 */
|
|
79
|
+
function karinPathTemp() {
|
|
80
|
+
return node_path_1.default.resolve(pluginDataDir(), 'temp');
|
|
81
|
+
}
|
|
82
|
+
/** 模块顶层注册、等待 apply 落地的命令 */
|
|
83
|
+
exports.commandQueue = [];
|
|
84
|
+
/** 模块顶层注册、等待 apply 落地的定时任务 */
|
|
85
|
+
exports.taskQueue = [];
|
|
86
|
+
/** 模块顶层注册的事件监听 */
|
|
87
|
+
exports.eventQueue = [];
|
|
@@ -0,0 +1,167 @@
|
|
|
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.segment = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* karin `segment` 的 Koishi 兼容实现。
|
|
9
|
+
*
|
|
10
|
+
* karin 的 segment 与 Koishi 的 `h`(Satori element)语义接近,
|
|
11
|
+
* 这里主要补两件事:把 `base64://` / `file://` / 本地路径统一成适配器能发的资源,以及补上残留的 QQ 专有段。
|
|
12
|
+
*/
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
15
|
+
const node_url_1 = require("node:url");
|
|
16
|
+
const koishi_1 = require("koishi");
|
|
17
|
+
const MIME = {
|
|
18
|
+
'.png': 'image/png',
|
|
19
|
+
'.jpg': 'image/jpeg',
|
|
20
|
+
'.jpeg': 'image/jpeg',
|
|
21
|
+
'.gif': 'image/gif',
|
|
22
|
+
'.webp': 'image/webp',
|
|
23
|
+
'.bmp': 'image/bmp',
|
|
24
|
+
'.svg': 'image/svg+xml',
|
|
25
|
+
'.mp4': 'video/mp4',
|
|
26
|
+
'.mov': 'video/quicktime',
|
|
27
|
+
'.webm': 'video/webm',
|
|
28
|
+
'.m4a': 'audio/mp4',
|
|
29
|
+
'.mp3': 'audio/mpeg',
|
|
30
|
+
'.wav': 'audio/wav',
|
|
31
|
+
'.silk': 'audio/silk',
|
|
32
|
+
'.amr': 'audio/amr'
|
|
33
|
+
};
|
|
34
|
+
const guessMime = (filePath, kind) => {
|
|
35
|
+
const ext = node_path_1.default.extname(filePath).toLowerCase();
|
|
36
|
+
if (MIME[ext])
|
|
37
|
+
return MIME[ext];
|
|
38
|
+
if (kind === 'image')
|
|
39
|
+
return 'image/png';
|
|
40
|
+
if (kind === 'video')
|
|
41
|
+
return 'video/mp4';
|
|
42
|
+
if (kind === 'audio')
|
|
43
|
+
return 'audio/mpeg';
|
|
44
|
+
return 'application/octet-stream';
|
|
45
|
+
};
|
|
46
|
+
const asBuffer = (src, kind) => {
|
|
47
|
+
if (src.startsWith('base64://')) {
|
|
48
|
+
const raw = Buffer.from(src.slice('base64://'.length), 'base64');
|
|
49
|
+
return { data: raw, type: guessMime('.' + (kind === 'image' ? 'png' : kind === 'video' ? 'mp4' : 'mp3'), kind) };
|
|
50
|
+
}
|
|
51
|
+
if (src.startsWith('data:'))
|
|
52
|
+
return null;
|
|
53
|
+
if (/^[a-z]+:\/\//i.test(src) && !src.startsWith('file://'))
|
|
54
|
+
return null;
|
|
55
|
+
const filePath = src.startsWith('file://') ? (0, node_url_1.fileURLToPath)(src) : src;
|
|
56
|
+
if (!node_fs_1.default.existsSync(filePath))
|
|
57
|
+
return null;
|
|
58
|
+
return { data: node_fs_1.default.readFileSync(filePath), type: guessMime(filePath, kind) };
|
|
59
|
+
};
|
|
60
|
+
/** 把 karin 支持的资源写法统一成 Satori 元素可用的资源 */
|
|
61
|
+
function resource(src, kind) {
|
|
62
|
+
if (Buffer.isBuffer(src) || src instanceof ArrayBuffer)
|
|
63
|
+
return src;
|
|
64
|
+
if (typeof src !== 'string')
|
|
65
|
+
return String(src ?? '');
|
|
66
|
+
const buf = asBuffer(src, kind);
|
|
67
|
+
if (buf)
|
|
68
|
+
return buf.data;
|
|
69
|
+
if (src.startsWith('base64://'))
|
|
70
|
+
return 'data:' + guessMime('', kind) + ';base64,' + src.slice(9);
|
|
71
|
+
return src;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* karin 的媒体段是 `{ type, file }`,而 Koishi 的元素把内容放在 `attrs.src`。
|
|
75
|
+
* 上游 karin 代码经常直接读 `segment.file`(例如登录二维码:`qrimg[0].file` →
|
|
76
|
+
* 落盘 + 发送),在 Koishi 下这个属性根本不存在,于是「生成二维码图片失败」。
|
|
77
|
+
*
|
|
78
|
+
* 这里给元素补一个**只读的 `file` 兼容属性**(不可枚举,不会进 JSON / 不会影响发送):
|
|
79
|
+
* - data URL → 还原成 karin 习惯的 `base64://xxx`
|
|
80
|
+
* - 其它(http 链接 / 路径)原样返回
|
|
81
|
+
*/
|
|
82
|
+
function withKarinFile(element) {
|
|
83
|
+
if (!element || typeof element !== 'object' || 'file' in element)
|
|
84
|
+
return element;
|
|
85
|
+
Object.defineProperty(element, 'file', {
|
|
86
|
+
enumerable: false,
|
|
87
|
+
configurable: true,
|
|
88
|
+
get() {
|
|
89
|
+
const src = element.attrs?.src ?? element.attrs?.url;
|
|
90
|
+
if (typeof src === 'string' && src.startsWith('data:')) {
|
|
91
|
+
const comma = src.indexOf(',');
|
|
92
|
+
return comma >= 0 ? 'base64://' + src.slice(comma + 1) : src;
|
|
93
|
+
}
|
|
94
|
+
return src;
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return element;
|
|
98
|
+
}
|
|
99
|
+
function resElement(type, src, ...rest) {
|
|
100
|
+
if (Buffer.isBuffer(src) || src instanceof ArrayBuffer) {
|
|
101
|
+
return withKarinFile(koishi_1.h[type](src, rest[0] ?? guessMime('', type === 'audio' ? 'audio' : type)));
|
|
102
|
+
}
|
|
103
|
+
const buf = typeof src === 'string' ? asBuffer(src, type) : null;
|
|
104
|
+
if (buf)
|
|
105
|
+
return withKarinFile(koishi_1.h[type](buf.data, buf.type));
|
|
106
|
+
if (typeof src === 'string' && src.startsWith('base64://')) {
|
|
107
|
+
return withKarinFile(koishi_1.h[type](('data:' + guessMime('', type === 'audio' ? 'audio' : type) + ';base64,' + src.slice(9))));
|
|
108
|
+
}
|
|
109
|
+
return withKarinFile(koishi_1.h[type](src));
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* QQ 原生按钮的属性名修复。
|
|
113
|
+
*
|
|
114
|
+
* Koishi 的 `h()` 会把**顶层属性名** camelize(`render_data` → `renderData`),
|
|
115
|
+
* 而 koishi-plugin-adapter-qq-crack 是按 snake_case 读的(`attrs.render_data`)。
|
|
116
|
+
* 不改回来的话按钮渲染数据整个丢失,适配器会退化成「按钮文字 = action.data」——
|
|
117
|
+
* 也就是按钮上直接糊一整条 `#解析 https://… --qn=80`。
|
|
118
|
+
* 嵌套对象不会被 camelize,所以只需要补顶层这一层。
|
|
119
|
+
* @param element 按钮元素
|
|
120
|
+
*/
|
|
121
|
+
function restoreButtonAttrs(element) {
|
|
122
|
+
const attrs = element.attrs;
|
|
123
|
+
if (attrs.renderData && !attrs.render_data)
|
|
124
|
+
attrs.render_data = attrs.renderData;
|
|
125
|
+
if (attrs.visitedLabel && !attrs.visited_label)
|
|
126
|
+
attrs.visited_label = attrs.visitedLabel;
|
|
127
|
+
return element;
|
|
128
|
+
}
|
|
129
|
+
exports.segment = {
|
|
130
|
+
text: (value) => koishi_1.h.text(String(value ?? '')),
|
|
131
|
+
image: (src, ..._rest) => resElement('image', src),
|
|
132
|
+
video: (src, ..._rest) => resElement('video', src),
|
|
133
|
+
audio: (src, ..._rest) => resElement('audio', src),
|
|
134
|
+
record: (src, ..._rest) => resElement('audio', src),
|
|
135
|
+
reply: (id) => koishi_1.h.quote(String(id)),
|
|
136
|
+
at: (id) => koishi_1.h.at(String(id)),
|
|
137
|
+
face: (id) => (0, koishi_1.h)('face', { id: String(id) }),
|
|
138
|
+
file: (src, name) => {
|
|
139
|
+
// base64:// 与本地路径都要转成真正的资源再交给适配器:
|
|
140
|
+
// 直接把 `base64://xxx` 字符串塞进 h.file(),适配器会去 fetch 这个地址而失败
|
|
141
|
+
// (日志里就是「QQ 消息发送失败 fetch base64://AAAAHGZ0eXBpc29t…」——那是 mp4 的头)
|
|
142
|
+
if (typeof src === 'string' && src.startsWith('base64://')) {
|
|
143
|
+
return withKarinFile(koishi_1.h.file(Buffer.from(src.slice('base64://'.length), 'base64'), guessMime(name ?? '', 'file'), name ? { title: name } : undefined));
|
|
144
|
+
}
|
|
145
|
+
if (typeof src === 'string' && node_fs_1.default.existsSync(src.startsWith('file://') ? (0, node_url_1.fileURLToPath)(src) : src)) {
|
|
146
|
+
const filePath = src.startsWith('file://') ? (0, node_url_1.fileURLToPath)(src) : src;
|
|
147
|
+
return withKarinFile(koishi_1.h.file(node_fs_1.default.readFileSync(filePath), guessMime(filePath, 'file'), { title: name ?? node_path_1.default.basename(filePath) }));
|
|
148
|
+
}
|
|
149
|
+
if (Buffer.isBuffer(src) || src instanceof ArrayBuffer) {
|
|
150
|
+
return withKarinFile(koishi_1.h.file(src, guessMime(name ?? '', 'file'), name ? { title: name } : undefined));
|
|
151
|
+
}
|
|
152
|
+
return withKarinFile(koishi_1.h.file(src, name ? { title: name } : undefined));
|
|
153
|
+
},
|
|
154
|
+
/** markdown:传字符串等价于 `h('markdown', text)`;传对象则作为 attrs(如 `{ content, stream }`) */
|
|
155
|
+
markdown: (content, ...rest) => (0, koishi_1.h)('markdown', ...(rest.length ? rest : [content && typeof content === 'object' ? content : String(content ?? '')])),
|
|
156
|
+
button: (...args) => restoreButtonAttrs((0, koishi_1.h)('button', ...args)),
|
|
157
|
+
/** QQ 原生按钮换行分组:一行最多 5 个按钮 */
|
|
158
|
+
buttonGroup: (children) => (0, koishi_1.h)('button-group', {}, Array.isArray(children) ? children : [children]),
|
|
159
|
+
count: (value) => koishi_1.h.text(String(value ?? '')),
|
|
160
|
+
raw: (type, data) => (0, koishi_1.h)(type, data),
|
|
161
|
+
/** 兼容 karin 的 segment 常量表 */
|
|
162
|
+
Image: 'image',
|
|
163
|
+
Video: 'video',
|
|
164
|
+
Text: 'text',
|
|
165
|
+
Reply: 'reply'
|
|
166
|
+
};
|
|
167
|
+
exports.default = exports.segment;
|