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.
Files changed (702) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +674 -0
  3. package/README.md +98 -0
  4. package/assets/web/assets/CronEditor-CYgFpX-g.js +1 -0
  5. package/assets/web/assets/DesktopLayout-iI43ij11.js +1 -0
  6. package/assets/web/assets/MobileLayout-CziU8MCR.js +1 -0
  7. package/assets/web/assets/ThemeSwitch-DFohhwd9.js +1 -0
  8. package/assets/web/assets/index-BRROK0vh.js +47 -0
  9. package/assets/web/assets/index-Dj-StEiS.css +2 -0
  10. package/assets/web/assets/separator-CxcFlCzz.js +1 -0
  11. package/assets/web/favicon.svg +1 -0
  12. package/assets/web/icons.svg +24 -0
  13. package/assets/web/index.html +15 -0
  14. package/assets/webui.html +115 -0
  15. package/client/index.ts +63 -0
  16. package/config/default_config/app.yaml +64 -0
  17. package/config/default_config/bilibili.yaml +116 -0
  18. package/config/default_config/config.json +157 -0
  19. package/config/default_config/cookies.yaml +11 -0
  20. package/config/default_config/douyin.yaml +99 -0
  21. package/config/default_config/kuaishou.yaml +8 -0
  22. package/config/default_config/pushlist.yaml +37 -0
  23. package/config/default_config/request.yaml +22 -0
  24. package/config/default_config/upload.yaml +50 -0
  25. package/config/default_config/xiaohongshu.yaml +23 -0
  26. package/dist/index.js +1 -0
  27. package/lib/compat/axios.js +23 -0
  28. package/lib/compat/cron.js +77 -0
  29. package/lib/compat/esm.js +15 -0
  30. package/lib/compat/express.js +23 -0
  31. package/lib/compat/heroui.js +12 -0
  32. package/lib/compat/lodash.js +33 -0
  33. package/lib/compat/logger.js +118 -0
  34. package/lib/compat/node-karin.js +1053 -0
  35. package/lib/compat/phosphor-icons.js +27 -0
  36. package/lib/compat/qqcard.js +256 -0
  37. package/lib/compat/root.js +44 -0
  38. package/lib/compat/runtime.js +87 -0
  39. package/lib/compat/segment.js +167 -0
  40. package/lib/compat/sqlite3.js +117 -0
  41. package/lib/compat/start.js +7 -0
  42. package/lib/compat/syncConfig.js +65 -0
  43. package/lib/compat/template-react.js +30 -0
  44. package/lib/compat/text.js +65 -0
  45. package/lib/compat/yaml.js +13 -0
  46. package/lib/configBridge.js +91 -0
  47. package/lib/index.js +775 -0
  48. package/lib/karin/app.js +34 -0
  49. package/lib/karin/apps/__ready.js +9 -0
  50. package/lib/karin/apps/admin.js +136 -0
  51. package/lib/karin/apps/help.js +233 -0
  52. package/lib/karin/apps/push.js +291 -0
  53. package/lib/karin/apps/qrlogin.js +176 -0
  54. package/lib/karin/apps/statistics.js +209 -0
  55. package/lib/karin/apps/testPush.js +247 -0
  56. package/lib/karin/apps/tools.js +473 -0
  57. package/lib/karin/apps/update.js +252 -0
  58. package/lib/karin/index.js +37 -0
  59. package/lib/karin/module/db/bilibili.js +831 -0
  60. package/lib/karin/module/db/douyin.js +918 -0
  61. package/lib/karin/module/db/index.js +165 -0
  62. package/lib/karin/module/db/migration.js +199 -0
  63. package/lib/karin/module/db/statistics.js +559 -0
  64. package/lib/karin/module/index.js +94 -0
  65. package/lib/karin/module/server/constants/routes.js +48 -0
  66. package/lib/karin/module/server/controllers/bots.js +230 -0
  67. package/lib/karin/module/server/controllers/config.js +75 -0
  68. package/lib/karin/module/server/controllers/video.js +208 -0
  69. package/lib/karin/module/server/index.js +26 -0
  70. package/lib/karin/module/server/middlewares/auth.js +133 -0
  71. package/lib/karin/module/server/routes/amagi.js +57 -0
  72. package/lib/karin/module/server/routes/api.js +40 -0
  73. package/lib/karin/module/server/routes/index.js +97 -0
  74. package/lib/karin/module/server/routes/ssr.js +16 -0
  75. package/lib/karin/module/server/routes/static.js +43 -0
  76. package/lib/karin/module/utils/Base.js +403 -0
  77. package/lib/karin/module/utils/CardParser.js +487 -0
  78. package/lib/karin/module/utils/Common.js +418 -0
  79. package/lib/karin/module/utils/Config.js +434 -0
  80. package/lib/karin/module/utils/EmojiReaction.js +242 -0
  81. package/lib/karin/module/utils/ErrorHandler/handler.js +114 -0
  82. package/lib/karin/module/utils/ErrorHandler/index.js +55 -0
  83. package/lib/karin/module/utils/ErrorHandler/render.js +182 -0
  84. package/lib/karin/module/utils/ErrorHandler/sender.js +206 -0
  85. package/lib/karin/module/utils/ErrorHandler/strategy.js +41 -0
  86. package/lib/karin/module/utils/ErrorHandler/types.js +2 -0
  87. package/lib/karin/module/utils/ErrorHandler/utils.js +108 -0
  88. package/lib/karin/module/utils/FFmpeg.js +298 -0
  89. package/lib/karin/module/utils/ImageHelper.js +91 -0
  90. package/lib/karin/module/utils/ImageSlice.js +429 -0
  91. package/lib/karin/module/utils/MotionPhoto.js +250 -0
  92. package/lib/karin/module/utils/Network/Downloader.js +413 -0
  93. package/lib/karin/module/utils/Network/ImageDownloader.js +250 -0
  94. package/lib/karin/module/utils/Network/Network.js +332 -0
  95. package/lib/karin/module/utils/Network/ThrottleStream.js +71 -0
  96. package/lib/karin/module/utils/Network/constants.js +129 -0
  97. package/lib/karin/module/utils/Network/helpers.js +174 -0
  98. package/lib/karin/module/utils/Network/index.js +34 -0
  99. package/lib/karin/module/utils/Network/types.js +12 -0
  100. package/lib/karin/module/utils/Networks.js +17 -0
  101. package/lib/karin/module/utils/ParseLock.js +34 -0
  102. package/lib/karin/module/utils/ParseOverride.js +88 -0
  103. package/lib/karin/module/utils/QqCardResolve.js +114 -0
  104. package/lib/karin/module/utils/QqPanel.js +879 -0
  105. package/lib/karin/module/utils/Render/coverTheme.js +256 -0
  106. package/lib/karin/module/utils/Render/index.js +582 -0
  107. package/lib/karin/module/utils/amagiClient.js +338 -0
  108. package/lib/karin/module/utils/avatar.js +201 -0
  109. package/lib/karin/module/utils/bot.js +141 -0
  110. package/lib/karin/module/utils/build-metadata.js +50 -0
  111. package/lib/karin/module/utils/changelog.js +166 -0
  112. package/lib/karin/module/utils/index.js +26 -0
  113. package/lib/karin/module/utils/loginSession.js +259 -0
  114. package/lib/karin/module/utils/parseTip.js +93 -0
  115. package/lib/karin/module/utils/runtime-report.js +140 -0
  116. package/lib/karin/module/utils/semver.js +72 -0
  117. package/lib/karin/module/utils/statisticsAggregate.js +415 -0
  118. package/lib/karin/platform/bilibili/bilibili.js +1805 -0
  119. package/lib/karin/platform/bilibili/comments.js +294 -0
  120. package/lib/karin/platform/bilibili/danmaku.js +555 -0
  121. package/lib/karin/platform/bilibili/dynamic-text.js +827 -0
  122. package/lib/karin/platform/bilibili/genParams.js +37 -0
  123. package/lib/karin/platform/bilibili/getID.js +159 -0
  124. package/lib/karin/platform/bilibili/index.js +24 -0
  125. package/lib/karin/platform/bilibili/live-status.js +40 -0
  126. package/lib/karin/platform/bilibili/login.js +132 -0
  127. package/lib/karin/platform/bilibili/push.js +1397 -0
  128. package/lib/karin/platform/bilibili/riskControl.js +133 -0
  129. package/lib/karin/platform/bilibili/search.js +299 -0
  130. package/lib/karin/platform/common/danmaku-types.js +12 -0
  131. package/lib/karin/platform/douyin/comments.js +310 -0
  132. package/lib/karin/platform/douyin/danmaku.js +893 -0
  133. package/lib/karin/platform/douyin/douyin.js +1145 -0
  134. package/lib/karin/platform/douyin/getID.js +94 -0
  135. package/lib/karin/platform/douyin/index.js +24 -0
  136. package/lib/karin/platform/douyin/login.js +230 -0
  137. package/lib/karin/platform/douyin/push/favorite.js +75 -0
  138. package/lib/karin/platform/douyin/push/index.js +21 -0
  139. package/lib/karin/platform/douyin/push/live.js +69 -0
  140. package/lib/karin/platform/douyin/push/post.js +60 -0
  141. package/lib/karin/platform/douyin/push/recommend.js +74 -0
  142. package/lib/karin/platform/douyin/push/render.js +621 -0
  143. package/lib/karin/platform/douyin/push/types.js +2 -0
  144. package/lib/karin/platform/douyin/push.js +1128 -0
  145. package/lib/karin/platform/douyin/types.js +13 -0
  146. package/lib/karin/platform/douyin/videoQuality.js +222 -0
  147. package/lib/karin/platform/douyin/workType.js +182 -0
  148. package/lib/karin/platform/index.js +20 -0
  149. package/lib/karin/platform/kuaishou/comments.js +91 -0
  150. package/lib/karin/platform/kuaishou/getID.js +43 -0
  151. package/lib/karin/platform/kuaishou/getdata.js +41 -0
  152. package/lib/karin/platform/kuaishou/index.js +20 -0
  153. package/lib/karin/platform/kuaishou/kuaishou.js +122 -0
  154. package/lib/karin/platform/xiaohongshu/comments.js +162 -0
  155. package/lib/karin/platform/xiaohongshu/getID.js +129 -0
  156. package/lib/karin/platform/xiaohongshu/index.js +18 -0
  157. package/lib/karin/platform/xiaohongshu/xiaohongshu.js +643 -0
  158. package/lib/karin/root.js +73 -0
  159. package/lib/karin/setup.js +99 -0
  160. package/lib/karin/types/config/amagi.js +2 -0
  161. package/lib/karin/types/config/app.js +2 -0
  162. package/lib/karin/types/config/bilibili.js +2 -0
  163. package/lib/karin/types/config/cookies.js +2 -0
  164. package/lib/karin/types/config/douyin.js +2 -0
  165. package/lib/karin/types/config/index.js +2 -0
  166. package/lib/karin/types/config/kuaishou.js +2 -0
  167. package/lib/karin/types/config/pushlist.js +2 -0
  168. package/lib/karin/types/config/request.js +2 -0
  169. package/lib/karin/types/config/upload.js +2 -0
  170. package/lib/karin/types/config/xiaohongshu.js +2 -0
  171. package/lib/karin/types/datatypes.js +2 -0
  172. package/lib/karin/types/index.js +18 -0
  173. package/lib/karin/types/netrorks/NetworksConfigType.js +2 -0
  174. package/lib/karin/types/netrorks/index.js +17 -0
  175. package/lib/karin/web.config.js +49 -0
  176. package/lib/ktr/registry.js +82 -0
  177. package/lib/ktr/template/_preview/components/PreviewInfoCard.js +10 -0
  178. package/lib/ktr/template/_preview/components/PreviewLayout.js +10 -0
  179. package/lib/ktr/template/_preview/components/PreviewVideoCard.js +8 -0
  180. package/lib/ktr/template/_preview/render.js +142 -0
  181. package/lib/ktr/template/_preview/types.js +2 -0
  182. package/lib/ktr/template/_preview/utils/status.js +31 -0
  183. package/lib/ktr/template/_preview/utils/time.js +12 -0
  184. package/lib/ktr/template/bilibili/bangumi/components/bangumi.js +127 -0
  185. package/lib/ktr/template/bilibili/bangumi/components/types.js +2 -0
  186. package/lib/ktr/template/bilibili/bangumi/index.js +12 -0
  187. package/lib/ktr/template/bilibili/comment/components/Comment.js +193 -0
  188. package/lib/ktr/template/bilibili/comment/components/types.js +2 -0
  189. package/lib/ktr/template/bilibili/comment/index.js +10 -0
  190. package/lib/ktr/template/bilibili/components/Icons.js +66 -0
  191. package/lib/ktr/template/bilibili/components/shared.js +93 -0
  192. package/lib/ktr/template/bilibili/components/types.js +2 -0
  193. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.js +66 -0
  194. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.js +2 -0
  195. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.js +10 -0
  196. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.js +87 -0
  197. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.js +2 -0
  198. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.js +10 -0
  199. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.js +93 -0
  200. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.js +2 -0
  201. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.js +10 -0
  202. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.js +132 -0
  203. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.js +2 -0
  204. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.js +10 -0
  205. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.js +84 -0
  206. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.js +2 -0
  207. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.js +10 -0
  208. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.js +38 -0
  209. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.js +2 -0
  210. package/lib/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.js +10 -0
  211. package/lib/ktr/template/bilibili/dynamic/components/AdditionalCard.js +59 -0
  212. package/lib/ktr/template/bilibili/dynamic/components/CommonComponents.js +30 -0
  213. package/lib/ktr/template/bilibili/dynamic/types.js +2 -0
  214. package/lib/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.js +48 -0
  215. package/lib/ktr/template/bilibili/qrcodeImg/components/types.js +3 -0
  216. package/lib/ktr/template/bilibili/qrcodeImg/index.js +10 -0
  217. package/lib/ktr/template/bilibili/userlist/components/UserList.js +53 -0
  218. package/lib/ktr/template/bilibili/userlist/components/types.js +3 -0
  219. package/lib/ktr/template/bilibili/userlist/index.js +13 -0
  220. package/lib/ktr/template/bilibili/videoInfo/components/types.js +2 -0
  221. package/lib/ktr/template/bilibili/videoInfo/components/videoInfo.js +62 -0
  222. package/lib/ktr/template/bilibili/videoInfo/index.js +10 -0
  223. package/lib/ktr/template/components/AmbientCover.js +36 -0
  224. package/lib/ktr/template/components/DefaultLayout.js +33 -0
  225. package/lib/ktr/template/components/GlowImage.js +276 -0
  226. package/lib/ktr/template/components/QRCodeWithAvatar.js +34 -0
  227. package/lib/ktr/template/components/RolldownLogo.js +6 -0
  228. package/lib/ktr/template/components/ViteLogo.js +6 -0
  229. package/lib/ktr/template/components/iconRegistry.js +173 -0
  230. package/lib/ktr/template/douyin/article-work/components/ArticleWork.js +99 -0
  231. package/lib/ktr/template/douyin/article-work/components/types.js +3 -0
  232. package/lib/ktr/template/douyin/article-work/index.js +10 -0
  233. package/lib/ktr/template/douyin/comment/components/Comment.js +189 -0
  234. package/lib/ktr/template/douyin/comment/components/types.js +2 -0
  235. package/lib/ktr/template/douyin/comment/index.js +10 -0
  236. package/lib/ktr/template/douyin/components/Icons.js +29 -0
  237. package/lib/ktr/template/douyin/components/types.js +3 -0
  238. package/lib/ktr/template/douyin/dynamic/components/Dynamic.js +90 -0
  239. package/lib/ktr/template/douyin/dynamic/components/types.js +3 -0
  240. package/lib/ktr/template/douyin/dynamic/index.js +10 -0
  241. package/lib/ktr/template/douyin/favorite-list/components/FavoriteList.js +30 -0
  242. package/lib/ktr/template/douyin/favorite-list/components/types.js +3 -0
  243. package/lib/ktr/template/douyin/favorite-list/index.js +10 -0
  244. package/lib/ktr/template/douyin/image-work/components/ImageWork.js +136 -0
  245. package/lib/ktr/template/douyin/image-work/components/types.js +2 -0
  246. package/lib/ktr/template/douyin/image-work/index.js +10 -0
  247. package/lib/ktr/template/douyin/live/components/Live.js +51 -0
  248. package/lib/ktr/template/douyin/live/components/types.js +3 -0
  249. package/lib/ktr/template/douyin/live/index.js +10 -0
  250. package/lib/ktr/template/douyin/musicinfo/components/MusicInfo.js +60 -0
  251. package/lib/ktr/template/douyin/musicinfo/components/types.js +3 -0
  252. package/lib/ktr/template/douyin/musicinfo/index.js +10 -0
  253. package/lib/ktr/template/douyin/qrcodeImg/components/qrcodeImg.js +39 -0
  254. package/lib/ktr/template/douyin/qrcodeImg/components/types.js +3 -0
  255. package/lib/ktr/template/douyin/qrcodeImg/index.js +9 -0
  256. package/lib/ktr/template/douyin/recommend-list/components/RecommendList.js +30 -0
  257. package/lib/ktr/template/douyin/recommend-list/components/types.js +3 -0
  258. package/lib/ktr/template/douyin/recommend-list/index.js +10 -0
  259. package/lib/ktr/template/douyin/user_profile/components/UserVideoList.js +54 -0
  260. package/lib/ktr/template/douyin/user_profile/components/types.js +3 -0
  261. package/lib/ktr/template/douyin/user_profile/index.js +9 -0
  262. package/lib/ktr/template/douyin/userlist/components/UserList.js +50 -0
  263. package/lib/ktr/template/douyin/userlist/components/types.js +3 -0
  264. package/lib/ktr/template/douyin/userlist/index.js +13 -0
  265. package/lib/ktr/template/douyin/video-work/components/VideoWork.js +127 -0
  266. package/lib/ktr/template/douyin/video-work/components/types.js +2 -0
  267. package/lib/ktr/template/douyin/video-work/index.js +10 -0
  268. package/lib/ktr/template/kuaishou/comment/components/Comment.js +88 -0
  269. package/lib/ktr/template/kuaishou/comment/components/types.js +2 -0
  270. package/lib/ktr/template/kuaishou/comment/index.js +10 -0
  271. package/lib/ktr/template/other/changelog/components/changelog.js +117 -0
  272. package/lib/ktr/template/other/changelog/components/types.js +3 -0
  273. package/lib/ktr/template/other/changelog/index.js +9 -0
  274. package/lib/ktr/template/other/handlerError/components/errorTitles.js +227 -0
  275. package/lib/ktr/template/other/handlerError/components/handlerError.js +392 -0
  276. package/lib/ktr/template/other/handlerError/components/stackHighlight.js +109 -0
  277. package/lib/ktr/template/other/handlerError/components/types.js +2 -0
  278. package/lib/ktr/template/other/handlerError/index.js +9 -0
  279. package/lib/ktr/template/other/help/components/Help.js +79 -0
  280. package/lib/ktr/template/other/help/components/types.js +3 -0
  281. package/lib/ktr/template/other/help/index.js +12 -0
  282. package/lib/ktr/template/other/live-photo-tip/components/LivePhotoTip.js +80 -0
  283. package/lib/ktr/template/other/live-photo-tip/components/types.js +3 -0
  284. package/lib/ktr/template/other/live-photo-tip/index.js +9 -0
  285. package/lib/ktr/template/other/qrlogin/components/qrlogin.js +58 -0
  286. package/lib/ktr/template/other/qrlogin/components/types.js +3 -0
  287. package/lib/ktr/template/other/qrlogin/index.js +9 -0
  288. package/lib/ktr/template/other/runtime/components/runtime.js +101 -0
  289. package/lib/ktr/template/other/runtime/components/types.js +3 -0
  290. package/lib/ktr/template/other/runtime/index.js +9 -0
  291. package/lib/ktr/template/other/version_warning/components/VersionWarning.js +38 -0
  292. package/lib/ktr/template/other/version_warning/components/types.js +3 -0
  293. package/lib/ktr/template/other/version_warning/index.js +9 -0
  294. package/lib/ktr/template/statistics/components/BoxplotGuide.js +17 -0
  295. package/lib/ktr/template/statistics/components/ChartCard.js +15 -0
  296. package/lib/ktr/template/statistics/components/KpiCard.js +14 -0
  297. package/lib/ktr/template/statistics/components/PlatformTable.js +20 -0
  298. package/lib/ktr/template/statistics/components/RankList.js +61 -0
  299. package/lib/ktr/template/statistics/components/SSRChart.js +22 -0
  300. package/lib/ktr/template/statistics/components/chartPresets.js +630 -0
  301. package/lib/ktr/template/statistics/components/chartTheme.js +226 -0
  302. package/lib/ktr/template/statistics/components/format.js +38 -0
  303. package/lib/ktr/template/statistics/components/types.js +9 -0
  304. package/lib/ktr/template/statistics/global/components/GlobalStatistics.js +246 -0
  305. package/lib/ktr/template/statistics/global/components/types.js +3 -0
  306. package/lib/ktr/template/statistics/global/index.js +9 -0
  307. package/lib/ktr/template/statistics/group/components/GroupStatistics.js +181 -0
  308. package/lib/ktr/template/statistics/group/components/types.js +3 -0
  309. package/lib/ktr/template/statistics/group/index.js +9 -0
  310. package/lib/ktr/template/types/ctx.js +2 -0
  311. package/lib/ktr/template/xiaohongshu/comment/components/Comment.js +99 -0
  312. package/lib/ktr/template/xiaohongshu/comment/components/types.js +3 -0
  313. package/lib/ktr/template/xiaohongshu/comment/index.js +9 -0
  314. package/lib/ktr/template/xiaohongshu/noteInfo/components/noteInfo.js +93 -0
  315. package/lib/ktr/template/xiaohongshu/noteInfo/components/types.js +2 -0
  316. package/lib/ktr/template/xiaohongshu/noteInfo/index.js +9 -0
  317. package/lib/ktr/utils/QRCodeAvatar.js +99 -0
  318. package/lib/ktr/utils/QRcode.js +56 -0
  319. package/lib/ktr/utils/avatarProxy.js +45 -0
  320. package/lib/ktr/utils/cn.js +11 -0
  321. package/lib/ktr/utils/theme.js +12 -0
  322. package/lib/qqFields.json +75 -0
  323. package/lib/qqOptions.js +44 -0
  324. package/lib/richtext/index.js +25 -0
  325. package/lib/richtext/parse/index.js +232 -0
  326. package/lib/richtext/react/cn.js +11 -0
  327. package/lib/richtext/react/index.js +221 -0
  328. package/lib/richtext/types.js +2 -0
  329. package/lib/schema.js +352 -0
  330. package/lib/webui.js +341 -0
  331. package/package.json +88 -0
  332. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_BV.svg +1 -0
  333. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_GOODS.svg +1 -0
  334. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_LOTTERY.svg +1 -0
  335. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VIEW_PICTURE.svg +1 -0
  336. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_VOTE.svg +1 -0
  337. package/resources/image/bilibili/RICH_TEXT_NODE_TYPE/RICH_TEXT_NODE_TYPE_WEB.svg +1 -0
  338. package/resources/image/bilibili/bilibili-dark.png +0 -0
  339. package/resources/image/bilibili/bilibili-light.png +0 -0
  340. package/resources/image/bilibili/bilibili.png +0 -0
  341. package/resources/image/bilibili/id-dark.svg +1 -0
  342. package/resources/image/bilibili/id-light.svg +1 -0
  343. package/resources/image/bilibili/level/lv0.svg +1 -0
  344. package/resources/image/bilibili/level/lv1.svg +1 -0
  345. package/resources/image/bilibili/level/lv2.svg +1 -0
  346. package/resources/image/bilibili/level/lv3.svg +1 -0
  347. package/resources/image/bilibili/level/lv4.svg +1 -0
  348. package/resources/image/bilibili/level/lv5.svg +1 -0
  349. package/resources/image/bilibili/level/lv6.svg +1 -0
  350. package/resources/image/bilibili/level/lv7.svg +1 -0
  351. package/resources/image/bilibili/like-dark.svg +6 -0
  352. package/resources/image/bilibili/like-light.svg +6 -0
  353. package/resources/image/bilibili/play.svg +28 -0
  354. package/resources/image/bilibili/res-local1.png +0 -0
  355. package/resources/image/bilibili/up_pb.svg +1 -0
  356. package/resources/image/bilibili//347/233/264/346/222/255/344/270/255.png +0 -0
  357. package/resources/image/douyin/douyin.png +0 -0
  358. package/resources/image/douyin/dylogo-dark.svg +23 -0
  359. package/resources/image/douyin/dylogo-light.svg +38 -0
  360. package/resources/image/douyin/search-dark.svg +1 -0
  361. package/resources/image/douyin/search-light.svg +3 -0
  362. package/resources/image/douyin//346/212/226/351/237/263-/347/233/264/346/222/255/344/270/255.png +0 -0
  363. package/resources/image/frame-logo.png +0 -0
  364. package/resources/image/kuaishou/logo.png +0 -0
  365. package/resources/image/other/handlerError/Milky.png +0 -0
  366. package/resources/image/other/handlerError/chronocat.svg +43 -0
  367. package/resources/image/other/handlerError/conwechat.webp +0 -0
  368. package/resources/image/other/handlerError/gocq-http.webp +0 -0
  369. package/resources/image/other/handlerError/lagrange.webp +0 -0
  370. package/resources/image/other/handlerError/llonebot.webp +0 -0
  371. package/resources/image/other/handlerError/napcat.webp +0 -0
  372. package/resources/image/other/handlerError/onebot.png +0 -0
  373. package/resources/image/other/handlerError/satori.png +0 -0
  374. package/resources/image/xiaohongshu/logo.png +0 -0
  375. package/resources/template/style.css +23708 -0
  376. package/resources/vite.svg +130 -0
  377. package/scripts/build.mjs +129 -0
  378. package/scripts/check-schema.cjs +55 -0
  379. package/scripts/deploy.mjs +78 -0
  380. package/scripts/make-demo-placeholders.mjs +112 -0
  381. package/scripts/patch-deps.mjs +46 -0
  382. package/scripts/patch-webui.mjs +112 -0
  383. package/scripts/smoke-commands.cjs +39 -0
  384. package/scripts/smoke-config.cjs +122 -0
  385. package/scripts/smoke-douyin.cjs +170 -0
  386. package/scripts/smoke-koishi-commands.cjs +210 -0
  387. package/scripts/smoke-login.cjs +110 -0
  388. package/scripts/smoke-parse.cjs +54 -0
  389. package/scripts/smoke-push-mock.cjs +114 -0
  390. package/scripts/smoke-push.cjs +104 -0
  391. package/scripts/smoke-qq.cjs +147 -0
  392. package/scripts/smoke-qqcard.cjs +108 -0
  393. package/scripts/smoke-qqpanel.cjs +205 -0
  394. package/scripts/smoke-render.cjs +106 -0
  395. package/scripts/smoke-server.cjs +94 -0
  396. package/src/compat/axios.ts +5 -0
  397. package/src/compat/cron.ts +86 -0
  398. package/src/compat/esm.ts +13 -0
  399. package/src/compat/express.ts +5 -0
  400. package/src/compat/heroui.tsx +53 -0
  401. package/src/compat/lodash.ts +32 -0
  402. package/src/compat/logger.ts +121 -0
  403. package/src/compat/node-karin.ts +1064 -0
  404. package/src/compat/phosphor-icons.tsx +25 -0
  405. package/src/compat/qqcard.ts +251 -0
  406. package/src/compat/root.ts +44 -0
  407. package/src/compat/runtime.ts +120 -0
  408. package/src/compat/segment.ts +161 -0
  409. package/src/compat/sqlite3.ts +123 -0
  410. package/src/compat/start.ts +3 -0
  411. package/src/compat/syncConfig.ts +64 -0
  412. package/src/compat/template-react.ts +54 -0
  413. package/src/compat/text.ts +58 -0
  414. package/src/compat/yaml.ts +6 -0
  415. package/src/configBridge.ts +94 -0
  416. package/src/index.ts +769 -0
  417. package/src/karin/app.ts +1 -0
  418. package/src/karin/apps/__ready.ts +14 -0
  419. package/src/karin/apps/admin.ts +127 -0
  420. package/src/karin/apps/help.ts +228 -0
  421. package/src/karin/apps/push.ts +327 -0
  422. package/src/karin/apps/qrlogin.ts +160 -0
  423. package/src/karin/apps/statistics.ts +203 -0
  424. package/src/karin/apps/testPush.ts +226 -0
  425. package/src/karin/apps/tools.ts +510 -0
  426. package/src/karin/apps/update.ts +239 -0
  427. package/src/karin/index.ts +9 -0
  428. package/src/karin/module/db/bilibili.ts +1089 -0
  429. package/src/karin/module/db/douyin.ts +1218 -0
  430. package/src/karin/module/db/index.ts +159 -0
  431. package/src/karin/module/db/migration.ts +249 -0
  432. package/src/karin/module/db/statistics.ts +817 -0
  433. package/src/karin/module/index.ts +37 -0
  434. package/src/karin/module/server/constants/routes.ts +53 -0
  435. package/src/karin/module/server/controllers/bots.ts +289 -0
  436. package/src/karin/module/server/controllers/config.ts +85 -0
  437. package/src/karin/module/server/controllers/video.ts +212 -0
  438. package/src/karin/module/server/index.ts +11 -0
  439. package/src/karin/module/server/middlewares/auth.ts +147 -0
  440. package/src/karin/module/server/routes/amagi.ts +57 -0
  441. package/src/karin/module/server/routes/api.ts +42 -0
  442. package/src/karin/module/server/routes/index.ts +68 -0
  443. package/src/karin/module/server/routes/ssr.ts +14 -0
  444. package/src/karin/module/server/routes/static.ts +43 -0
  445. package/src/karin/module/utils/Base.ts +497 -0
  446. package/src/karin/module/utils/CardParser.ts +503 -0
  447. package/src/karin/module/utils/Common.ts +448 -0
  448. package/src/karin/module/utils/Config.ts +443 -0
  449. package/src/karin/module/utils/EmojiReaction.ts +268 -0
  450. package/src/karin/module/utils/ErrorHandler/handler.ts +124 -0
  451. package/src/karin/module/utils/ErrorHandler/index.ts +48 -0
  452. package/src/karin/module/utils/ErrorHandler/render.ts +180 -0
  453. package/src/karin/module/utils/ErrorHandler/sender.ts +192 -0
  454. package/src/karin/module/utils/ErrorHandler/strategy.ts +41 -0
  455. package/src/karin/module/utils/ErrorHandler/types.ts +122 -0
  456. package/src/karin/module/utils/ErrorHandler/utils.ts +108 -0
  457. package/src/karin/module/utils/FFmpeg.ts +357 -0
  458. package/src/karin/module/utils/ImageHelper.ts +90 -0
  459. package/src/karin/module/utils/ImageSlice.ts +383 -0
  460. package/src/karin/module/utils/MotionPhoto.ts +297 -0
  461. package/src/karin/module/utils/Network/Downloader.ts +481 -0
  462. package/src/karin/module/utils/Network/ImageDownloader.ts +291 -0
  463. package/src/karin/module/utils/Network/Network.ts +344 -0
  464. package/src/karin/module/utils/Network/ThrottleStream.ts +76 -0
  465. package/src/karin/module/utils/Network/constants.ts +135 -0
  466. package/src/karin/module/utils/Network/helpers.ts +183 -0
  467. package/src/karin/module/utils/Network/index.ts +28 -0
  468. package/src/karin/module/utils/Network/types.ts +46 -0
  469. package/src/karin/module/utils/Networks.ts +20 -0
  470. package/src/karin/module/utils/ParseLock.ts +33 -0
  471. package/src/karin/module/utils/ParseOverride.ts +128 -0
  472. package/src/karin/module/utils/QqCardResolve.ts +116 -0
  473. package/src/karin/module/utils/QqPanel.ts +880 -0
  474. package/src/karin/module/utils/Render/coverTheme.ts +294 -0
  475. package/src/karin/module/utils/Render/index.ts +574 -0
  476. package/src/karin/module/utils/amagiClient.ts +368 -0
  477. package/src/karin/module/utils/avatar.ts +220 -0
  478. package/src/karin/module/utils/bot.ts +115 -0
  479. package/src/karin/module/utils/build-metadata.ts +60 -0
  480. package/src/karin/module/utils/changelog.ts +175 -0
  481. package/src/karin/module/utils/index.ts +10 -0
  482. package/src/karin/module/utils/loginSession.ts +291 -0
  483. package/src/karin/module/utils/parseTip.ts +59 -0
  484. package/src/karin/module/utils/runtime-report.ts +142 -0
  485. package/src/karin/module/utils/semver.ts +60 -0
  486. package/src/karin/module/utils/statisticsAggregate.ts +507 -0
  487. package/src/karin/platform/bilibili/bilibili.ts +2004 -0
  488. package/src/karin/platform/bilibili/comments.ts +397 -0
  489. package/src/karin/platform/bilibili/danmaku.ts +653 -0
  490. package/src/karin/platform/bilibili/dynamic-text.ts +926 -0
  491. package/src/karin/platform/bilibili/genParams.ts +30 -0
  492. package/src/karin/platform/bilibili/getID.ts +163 -0
  493. package/src/karin/platform/bilibili/index.ts +8 -0
  494. package/src/karin/platform/bilibili/live-status.ts +36 -0
  495. package/src/karin/platform/bilibili/login.ts +130 -0
  496. package/src/karin/platform/bilibili/push.ts +1615 -0
  497. package/src/karin/platform/bilibili/riskControl.ts +114 -0
  498. package/src/karin/platform/bilibili/search.ts +305 -0
  499. package/src/karin/platform/common/danmaku-types.ts +18 -0
  500. package/src/karin/platform/douyin/comments.ts +404 -0
  501. package/src/karin/platform/douyin/danmaku.ts +1187 -0
  502. package/src/karin/platform/douyin/douyin.ts +1244 -0
  503. package/src/karin/platform/douyin/getID.ts +101 -0
  504. package/src/karin/platform/douyin/index.ts +8 -0
  505. package/src/karin/platform/douyin/login.ts +251 -0
  506. package/src/karin/platform/douyin/push/favorite.ts +97 -0
  507. package/src/karin/platform/douyin/push/index.ts +5 -0
  508. package/src/karin/platform/douyin/push/live.ts +86 -0
  509. package/src/karin/platform/douyin/push/post.ts +75 -0
  510. package/src/karin/platform/douyin/push/recommend.ts +96 -0
  511. package/src/karin/platform/douyin/push/render.ts +768 -0
  512. package/src/karin/platform/douyin/push/types.ts +41 -0
  513. package/src/karin/platform/douyin/push.ts +1241 -0
  514. package/src/karin/platform/douyin/types.ts +151 -0
  515. package/src/karin/platform/douyin/videoQuality.ts +234 -0
  516. package/src/karin/platform/douyin/workType.ts +238 -0
  517. package/src/karin/platform/index.ts +4 -0
  518. package/src/karin/platform/kuaishou/comments.ts +114 -0
  519. package/src/karin/platform/kuaishou/getID.ts +48 -0
  520. package/src/karin/platform/kuaishou/getdata.ts +78 -0
  521. package/src/karin/platform/kuaishou/index.ts +4 -0
  522. package/src/karin/platform/kuaishou/kuaishou.ts +130 -0
  523. package/src/karin/platform/xiaohongshu/comments.ts +227 -0
  524. package/src/karin/platform/xiaohongshu/getID.ts +127 -0
  525. package/src/karin/platform/xiaohongshu/index.ts +2 -0
  526. package/src/karin/platform/xiaohongshu/xiaohongshu.ts +733 -0
  527. package/src/karin/root.ts +78 -0
  528. package/src/karin/setup.ts +77 -0
  529. package/src/karin/types/config/amagi.ts +46 -0
  530. package/src/karin/types/config/app.ts +129 -0
  531. package/src/karin/types/config/bilibili.ts +121 -0
  532. package/src/karin/types/config/cookies.ts +11 -0
  533. package/src/karin/types/config/douyin.ts +93 -0
  534. package/src/karin/types/config/index.ts +41 -0
  535. package/src/karin/types/config/kuaishou.ts +10 -0
  536. package/src/karin/types/config/pushlist.ts +55 -0
  537. package/src/karin/types/config/request.ts +27 -0
  538. package/src/karin/types/config/upload.ts +49 -0
  539. package/src/karin/types/config/xiaohongshu.ts +24 -0
  540. package/src/karin/types/datatypes.ts +42 -0
  541. package/src/karin/types/index.ts +4 -0
  542. package/src/karin/types/netrorks/NetworksConfigType.ts +61 -0
  543. package/src/karin/types/netrorks/index.ts +1 -0
  544. package/src/karin/web.config.ts +48 -0
  545. package/src/ktr/registry.ts +55 -0
  546. package/src/ktr/template/_preview/components/PreviewInfoCard.tsx +33 -0
  547. package/src/ktr/template/_preview/components/PreviewLayout.tsx +65 -0
  548. package/src/ktr/template/_preview/components/PreviewVideoCard.tsx +22 -0
  549. package/src/ktr/template/_preview/render.ts +158 -0
  550. package/src/ktr/template/_preview/types.ts +15 -0
  551. package/src/ktr/template/_preview/utils/status.ts +29 -0
  552. package/src/ktr/template/_preview/utils/time.ts +8 -0
  553. package/src/ktr/template/bilibili/bangumi/components/bangumi.tsx +462 -0
  554. package/src/ktr/template/bilibili/bangumi/components/types.ts +36 -0
  555. package/src/ktr/template/bilibili/bangumi/index.tsx +9 -0
  556. package/src/ktr/template/bilibili/comment/components/Comment.tsx +657 -0
  557. package/src/ktr/template/bilibili/comment/components/types.ts +26 -0
  558. package/src/ktr/template/bilibili/comment/index.tsx +11 -0
  559. package/src/ktr/template/bilibili/components/Icons.tsx +209 -0
  560. package/src/ktr/template/bilibili/components/shared.tsx +162 -0
  561. package/src/ktr/template/bilibili/components/types.ts +388 -0
  562. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/DYNAMIC_TYPE_ARTICLE.tsx +251 -0
  563. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/components/types.ts +67 -0
  564. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_ARTICLE/index.tsx +12 -0
  565. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/DYNAMIC_TYPE_AV.tsx +238 -0
  566. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/components/types.ts +39 -0
  567. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_AV/index.tsx +12 -0
  568. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/DYNAMIC_TYPE_DRAW.tsx +205 -0
  569. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/components/types.ts +20 -0
  570. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_DRAW/index.tsx +11 -0
  571. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/DYNAMIC_TYPE_FORWARD.tsx +348 -0
  572. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/components/types.ts +16 -0
  573. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_FORWARD/index.tsx +12 -0
  574. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/DYNAMIC_TYPE_LIVE_RCMD.tsx +264 -0
  575. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/components/types.ts +32 -0
  576. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_LIVE_RCMD/index.tsx +12 -0
  577. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/DYNAMIC_TYPE_WORD.tsx +68 -0
  578. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/components/types.ts +14 -0
  579. package/src/ktr/template/bilibili/dynamic/DYNAMIC_TYPE_WORD/index.tsx +12 -0
  580. package/src/ktr/template/bilibili/dynamic/components/AdditionalCard.tsx +165 -0
  581. package/src/ktr/template/bilibili/dynamic/components/CommonComponents.tsx +142 -0
  582. package/src/ktr/template/bilibili/dynamic/types.ts +382 -0
  583. package/src/ktr/template/bilibili/qrcodeImg/components/qrcodeImg.tsx +179 -0
  584. package/src/ktr/template/bilibili/qrcodeImg/components/types.ts +9 -0
  585. package/src/ktr/template/bilibili/qrcodeImg/index.tsx +12 -0
  586. package/src/ktr/template/bilibili/userlist/components/UserList.tsx +246 -0
  587. package/src/ktr/template/bilibili/userlist/components/types.ts +35 -0
  588. package/src/ktr/template/bilibili/userlist/index.tsx +11 -0
  589. package/src/ktr/template/bilibili/videoInfo/components/types.ts +28 -0
  590. package/src/ktr/template/bilibili/videoInfo/components/videoInfo.tsx +217 -0
  591. package/src/ktr/template/bilibili/videoInfo/index.tsx +12 -0
  592. package/src/ktr/template/components/AmbientCover.tsx +50 -0
  593. package/src/ktr/template/components/DefaultLayout.tsx +166 -0
  594. package/src/ktr/template/components/GlowImage.tsx +572 -0
  595. package/src/ktr/template/components/QRCodeWithAvatar.tsx +52 -0
  596. package/src/ktr/template/components/RolldownLogo.tsx +110 -0
  597. package/src/ktr/template/components/ViteLogo.tsx +134 -0
  598. package/src/ktr/template/components/iconRegistry.ts +294 -0
  599. package/src/ktr/template/douyin/article-work/components/ArticleWork.tsx +301 -0
  600. package/src/ktr/template/douyin/article-work/components/types.ts +53 -0
  601. package/src/ktr/template/douyin/article-work/index.tsx +12 -0
  602. package/src/ktr/template/douyin/comment/components/Comment.tsx +612 -0
  603. package/src/ktr/template/douyin/comment/components/types.ts +85 -0
  604. package/src/ktr/template/douyin/comment/index.tsx +11 -0
  605. package/src/ktr/template/douyin/components/Icons.tsx +75 -0
  606. package/src/ktr/template/douyin/components/types.ts +83 -0
  607. package/src/ktr/template/douyin/dynamic/components/Dynamic.tsx +283 -0
  608. package/src/ktr/template/douyin/dynamic/components/types.ts +46 -0
  609. package/src/ktr/template/douyin/dynamic/index.tsx +11 -0
  610. package/src/ktr/template/douyin/favorite-list/components/FavoriteList.tsx +201 -0
  611. package/src/ktr/template/douyin/favorite-list/components/types.ts +38 -0
  612. package/src/ktr/template/douyin/favorite-list/index.tsx +12 -0
  613. package/src/ktr/template/douyin/image-work/components/ImageWork.tsx +437 -0
  614. package/src/ktr/template/douyin/image-work/components/types.ts +78 -0
  615. package/src/ktr/template/douyin/image-work/index.tsx +11 -0
  616. package/src/ktr/template/douyin/live/components/Live.tsx +229 -0
  617. package/src/ktr/template/douyin/live/components/types.ts +47 -0
  618. package/src/ktr/template/douyin/live/index.tsx +11 -0
  619. package/src/ktr/template/douyin/musicinfo/components/MusicInfo.tsx +187 -0
  620. package/src/ktr/template/douyin/musicinfo/components/types.ts +31 -0
  621. package/src/ktr/template/douyin/musicinfo/index.tsx +11 -0
  622. package/src/ktr/template/douyin/qrcodeImg/components/qrcodeImg.tsx +170 -0
  623. package/src/ktr/template/douyin/qrcodeImg/components/types.ts +9 -0
  624. package/src/ktr/template/douyin/qrcodeImg/index.tsx +9 -0
  625. package/src/ktr/template/douyin/recommend-list/components/RecommendList.tsx +201 -0
  626. package/src/ktr/template/douyin/recommend-list/components/types.ts +37 -0
  627. package/src/ktr/template/douyin/recommend-list/index.tsx +12 -0
  628. package/src/ktr/template/douyin/user_profile/components/UserVideoList.tsx +225 -0
  629. package/src/ktr/template/douyin/user_profile/components/types.ts +71 -0
  630. package/src/ktr/template/douyin/user_profile/index.tsx +9 -0
  631. package/src/ktr/template/douyin/userlist/components/UserList.tsx +229 -0
  632. package/src/ktr/template/douyin/userlist/components/types.ts +35 -0
  633. package/src/ktr/template/douyin/userlist/index.tsx +11 -0
  634. package/src/ktr/template/douyin/video-work/components/VideoWork.tsx +398 -0
  635. package/src/ktr/template/douyin/video-work/components/types.ts +80 -0
  636. package/src/ktr/template/douyin/video-work/index.tsx +11 -0
  637. package/src/ktr/template/font.css +6071 -0
  638. package/src/ktr/template/global.d.ts +69 -0
  639. package/src/ktr/template/kuaishou/comment/components/Comment.tsx +207 -0
  640. package/src/ktr/template/kuaishou/comment/components/types.ts +47 -0
  641. package/src/ktr/template/kuaishou/comment/index.tsx +11 -0
  642. package/src/ktr/template/other/changelog/components/changelog.tsx +411 -0
  643. package/src/ktr/template/other/changelog/components/types.ts +21 -0
  644. package/src/ktr/template/other/changelog/index.tsx +9 -0
  645. package/src/ktr/template/other/handlerError/components/errorTitles.ts +224 -0
  646. package/src/ktr/template/other/handlerError/components/handlerError.tsx +1076 -0
  647. package/src/ktr/template/other/handlerError/components/stackHighlight.ts +127 -0
  648. package/src/ktr/template/other/handlerError/components/types.ts +124 -0
  649. package/src/ktr/template/other/handlerError/index.tsx +9 -0
  650. package/src/ktr/template/other/help/components/Help.tsx +249 -0
  651. package/src/ktr/template/other/help/components/types.ts +47 -0
  652. package/src/ktr/template/other/help/index.tsx +9 -0
  653. package/src/ktr/template/other/live-photo-tip/components/LivePhotoTip.tsx +295 -0
  654. package/src/ktr/template/other/live-photo-tip/components/types.ts +8 -0
  655. package/src/ktr/template/other/live-photo-tip/index.tsx +9 -0
  656. package/src/ktr/template/other/qrlogin/components/qrlogin.tsx +295 -0
  657. package/src/ktr/template/other/qrlogin/components/types.ts +11 -0
  658. package/src/ktr/template/other/qrlogin/index.tsx +9 -0
  659. package/src/ktr/template/other/runtime/components/runtime.tsx +347 -0
  660. package/src/ktr/template/other/runtime/components/types.ts +75 -0
  661. package/src/ktr/template/other/runtime/index.tsx +9 -0
  662. package/src/ktr/template/other/version_warning/components/VersionWarning.tsx +392 -0
  663. package/src/ktr/template/other/version_warning/components/types.ts +8 -0
  664. package/src/ktr/template/other/version_warning/index.tsx +9 -0
  665. package/src/ktr/template/statistics/components/BoxplotGuide.tsx +57 -0
  666. package/src/ktr/template/statistics/components/ChartCard.tsx +40 -0
  667. package/src/ktr/template/statistics/components/KpiCard.tsx +39 -0
  668. package/src/ktr/template/statistics/components/PlatformTable.tsx +83 -0
  669. package/src/ktr/template/statistics/components/RankList.tsx +127 -0
  670. package/src/ktr/template/statistics/components/SSRChart.tsx +41 -0
  671. package/src/ktr/template/statistics/components/chartPresets.ts +700 -0
  672. package/src/ktr/template/statistics/components/chartTheme.ts +234 -0
  673. package/src/ktr/template/statistics/components/format.ts +33 -0
  674. package/src/ktr/template/statistics/components/types.ts +92 -0
  675. package/src/ktr/template/statistics/global/components/GlobalStatistics.tsx +597 -0
  676. package/src/ktr/template/statistics/global/components/types.ts +138 -0
  677. package/src/ktr/template/statistics/global/index.tsx +9 -0
  678. package/src/ktr/template/statistics/group/components/GroupStatistics.tsx +468 -0
  679. package/src/ktr/template/statistics/group/components/types.ts +113 -0
  680. package/src/ktr/template/statistics/group/index.tsx +9 -0
  681. package/src/ktr/template/style.css +65 -0
  682. package/src/ktr/template/types/ctx.ts +42 -0
  683. package/src/ktr/template/xiaohongshu/comment/components/Comment.tsx +264 -0
  684. package/src/ktr/template/xiaohongshu/comment/components/types.ts +119 -0
  685. package/src/ktr/template/xiaohongshu/comment/index.tsx +9 -0
  686. package/src/ktr/template/xiaohongshu/noteInfo/components/noteInfo.tsx +271 -0
  687. package/src/ktr/template/xiaohongshu/noteInfo/components/types.ts +66 -0
  688. package/src/ktr/template/xiaohongshu/noteInfo/index.tsx +9 -0
  689. package/src/ktr/utils/QRCodeAvatar.ts +102 -0
  690. package/src/ktr/utils/QRcode.ts +65 -0
  691. package/src/ktr/utils/avatarProxy.ts +42 -0
  692. package/src/ktr/utils/cn.ts +6 -0
  693. package/src/ktr/utils/theme.ts +10 -0
  694. package/src/qqFields.json +75 -0
  695. package/src/qqOptions.ts +64 -0
  696. package/src/richtext/index.ts +9 -0
  697. package/src/richtext/parse/index.ts +271 -0
  698. package/src/richtext/react/cn.ts +6 -0
  699. package/src/richtext/react/index.tsx +582 -0
  700. package/src/richtext/types.ts +320 -0
  701. package/src/schema.ts +372 -0
  702. package/src/webui.ts +352 -0
@@ -0,0 +1,221 @@
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.renderRichTextToReact = void 0;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const react_1 = __importDefault(require("react"));
9
+ const cn_1 = require("./cn");
10
+ /**
11
+ * 限制图片来源协议。
12
+ *
13
+ * React 会自动转义文本和属性,但不会替我们判断 URL 协议是否安全,所以这里仍然做白名单。
14
+ */
15
+ const sanitizeImageSource = (value) => {
16
+ const normalized = value.trim();
17
+ if (!normalized) {
18
+ return null;
19
+ }
20
+ if (/^https?:\/\//i.test(normalized)) {
21
+ return normalized;
22
+ }
23
+ if (/^data:image\/(?:png|jpe?g|gif|webp|avif);base64,[a-z0-9+/=]+$/i.test(normalized)) {
24
+ return normalized;
25
+ }
26
+ return null;
27
+ };
28
+ /**
29
+ * 富文本表情的默认排版。
30
+ *
31
+ * 这些规则属于 richtext 节点的渲染语义,不应该散落在各个平台模板里:
32
+ * - 表情跟随当前文字大小缩放;
33
+ * - 作为行内内容参与排版;
34
+ * - 不撑破行高,也不突破当前文本块宽度。
35
+ */
36
+ const getRichTextEmojiStyle = (scale = 1) => ({
37
+ display: 'inline-block',
38
+ height: `${1.5 * scale}em`,
39
+ width: 'auto',
40
+ verticalAlign: scale > 1 ? 'text-bottom' : 'middle',
41
+ lineHeight: 1
42
+ });
43
+ /** 统一的搜索图标,避免 template 每次都自己重复拼 JSX。 */
44
+ const SearchKeywordIcon = ({ className }) => {
45
+ return ((0, jsx_runtime_1.jsx)("span", { "aria-hidden": true, className: className, style: {
46
+ display: 'inline-flex',
47
+ verticalAlign: 'super',
48
+ marginLeft: '0.08em',
49
+ lineHeight: 1
50
+ }, children: (0, jsx_runtime_1.jsxs)("svg", { viewBox: "0 0 24 24", width: "0.72em", height: "0.72em", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", children: [(0, jsx_runtime_1.jsx)("circle", { cx: "11", cy: "11", r: "7" }), (0, jsx_runtime_1.jsx)("path", { d: "m20 20-3.5-3.5" })] }) }));
51
+ };
52
+ /** 话题图标 */
53
+ const TopicIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-16 mb-4 mr-4 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", children: [(0, jsx_runtime_1.jsx)("path", { d: "M5.1911266666666664 0.9880383333333334C4.908345 1.1859883333333332 4.839576666666666 1.5756933333333332 5.0375266666666665 1.8584683333333332L6.109626666666665 3.3900216666666663C6.307576666666667 3.6728033333333334 6.697288333333333 3.7415716666666663 6.980041666666667 3.5436216666666667C7.26285 3.345673333333333 7.3316 2.955966666666666 7.133666666666667 2.6731916666666664L6.061558333333332 1.1416383333333333C5.863613333333333 0.8588566666666666 5.473901666666667 0.7900883333333333 5.1911266666666664 0.9880383333333334z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M10.808908333333331 0.9880316666666666C10.52615 0.7900883333333333 10.136408333333332 0.8588566666666666 9.938466666666667 1.1416383333333333L8.866399999999999 2.6731916666666664C8.668458333333334 2.9559716666666667 8.737216666666665 3.345678333333333 9.020024999999999 3.543628333333333C9.302775 3.7415716666666663 9.692466666666666 3.6728033333333334 9.890458333333333 3.3900216666666663L10.962533333333333 1.8584683333333332C11.160466666666665 1.5756883333333334 11.091716666666665 1.1859816666666667 10.808908333333331 0.9880316666666666z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M8.388033333333333 8.2152L8.548749999999998 7.036716666666667L7.611974999999999 7.036716666666667L7.45125 8.2152L8.388033333333333 8.2152z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M8 2.559733333333333C6.498214999999999 2.559733333333333 5.16768 2.6184066666666665 4.195425 2.678813333333333C2.923148333333333 2.75786 1.9012316666666664 3.7431133333333335 1.8069283333333335 5.026566666666666C1.7538833333333335 5.748475 1.7082533333333334 6.652113333333333 1.7082533333333334 7.626266666666666C1.7082533333333334 8.604275 1.75425 9.504349999999999 1.8075966666666665 10.219908333333333C1.9018333333333333 11.483925 2.899678333333333 12.460316666666666 4.154273333333333 12.551708333333332C5.104525 12.620916666666668 6.4048050000000005 12.688916666666666 7.876416666666666 12.692558333333332C8.379624999999999 13.169883333333333 9.433408333333333 14.084808333333331 10.662975 14.643741666666665C11.005616666666665 14.799541666666666 11.427091666666666 14.859316666666667 11.735999999999999 14.576575C12.039016666666665 14.299274999999998 12.024899999999999 13.881124999999999 11.919241666666666 13.523958333333333C11.811016666666664 13.158316666666666 11.757858333333333 12.821666666666667 11.73155 12.559758333333335C13.013916666666667 12.468349999999997 14.093808333333332 11.543458333333334 14.192449999999997 10.220175C14.245791666666666 9.504874999999998 14.291733333333333 8.604875 14.291733333333333 7.626266666666666C14.291733333333333 6.6514999999999995 14.246125 5.74798 14.193108333333331 5.026299999999999C14.098808333333332 3.7429283333333334 13.076958333333332 2.757873333333333 11.804816666666664 2.6788266666666662C10.832533333333332 2.6184133333333333 9.501883333333334 2.559733333333333 8 2.559733333333333zM6.536343333333332 10.730624999999998C6.226251666666666 10.688316666666665 6.009155 10.402649999999998 6.0514399999999995 10.092558333333333L6.152898333333334 9.348533333333332L5.457055 9.348533333333332C5.144096666666666 9.348533333333332 4.890388333333333 9.094850000000001 4.890388333333333 8.781866666666666C4.890388333333333 8.468933333333332 5.144096666666666 8.2152 5.457055 8.2152L6.307441666666667 8.2152L6.468145 7.036716666666667L5.457055 7.036716666666667C5.144096666666666 7.036716666666667 4.890388333333333 6.783036666666668 4.890388333333333 6.470073333333333C4.890388333333333 6.15711 5.144096666666666 5.903406666666666 5.457055 5.903406666666666L6.6226883333333335 5.903406666666666L6.744933333333333 5.006731666666666C6.787241666666667 4.6966399999999995 7.0729083333333325 4.479536666666666 7.383 4.521823333333333C7.693091666666666 4.564108333333333 7.910191666666667 4.849765 7.867875 5.159858333333333L7.766483333333333 5.903406666666666L8.703325 5.903406666666666L8.825558333333333 5.006731666666666C8.867866666666666 4.6966399999999995 9.153533333333332 4.479536666666666 9.463625 4.521823333333333C9.773716666666667 4.564108333333333 9.990816666666666 4.849765 9.948508333333333 5.159858333333333L9.847116666666667 5.903406666666666L10.542933333333332 5.903406666666666C10.855858333333332 5.903406666666666 11.1096 6.15711 11.1096 6.470073333333333C11.1096 6.783036666666668 10.855858333333332 7.036716666666667 10.542933333333332 7.036716666666667L9.692599999999999 7.036716666666667L9.531875 8.2152L10.542933333333332 8.2152C10.855858333333332 8.2152 11.1096 8.468933333333332 11.1096 8.781866666666666C11.1096 9.094850000000001 10.855858333333332 9.348533333333332 10.542933333333332 9.348533333333332L9.377308333333332 9.348533333333332L9.255008333333333 10.245691666666666C9.212691666666666 10.555783333333332 8.927033333333332 10.772874999999999 8.616941666666666 10.730624999999998C8.306849999999999 10.688316666666665 8.089749999999999 10.402649999999998 8.132058333333333 10.092558333333333L8.233516666666667 9.348533333333332L7.296741666666667 9.348533333333332L7.1743749999999995 10.245691666666666C7.132066666666667 10.555783333333332 6.846406666666667 10.772874999999999 6.536343333333332 10.730624999999998z", fill: "currentColor" })] }));
54
+ /** 抽奖图标 */
55
+ const LotteryIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-16 h-auto mb-4 mr-2 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 18 18", children: [(0, jsx_runtime_1.jsx)("path", { d: "M3.3749775 8.758875C3.6856424999999997 8.758875 3.9374775 9.0106875 3.9374775 9.321375L3.9374775 13.821375C3.9374775 14.3095125 4.33323 14.70525 4.821405 14.70525L13.178550000000001 14.70525C13.666725 14.70525 14.0625 14.3095125 14.0625 13.821375L14.0625 9.321375C14.0625 9.0106875 14.3143125 8.758875 14.625 8.758875C14.93565 8.758875 15.1875 9.0106875 15.1875 9.321375L15.1875 13.821375C15.1875 14.930850000000001 14.2880625 15.83025 13.178550000000001 15.83025L4.821405 15.83025C3.7119074999999997 15.83025 2.8124775 14.930850000000001 2.8124775 13.821375L2.8124775 9.321375C2.8124775 9.0106875 3.0643199999999995 8.758875 3.3749775 8.758875z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M2.1696225 6.5892824999999995C2.1696225 5.746065 2.8531875 5.0625 3.696405 5.0625L14.303550000000001 5.0625C15.146774999999998 5.0625 15.830324999999998 5.746065 15.830324999999998 6.5892824999999995L15.830324999999998 8.025825000000001C15.830324999999998 8.768025 15.288825000000001 9.4204875 14.518125000000001 9.4986C13.5663 9.5950875 11.7789375 9.723225 9 9.723225C6.221047499999999 9.723225 4.433669999999999 9.5950875 3.4818525000000005 9.4986C2.711145 9.4204875 2.1696225 8.768025 2.1696225 8.025825000000001L2.1696225 6.5892824999999995zM3.696405 6.1875C3.4745099999999995 6.1875 3.2946225 6.3673875 3.2946225 6.5892824999999995L3.2946225 8.025825000000001C3.2946225 8.221725000000001 3.423675 8.3619375 3.5952824999999997 8.3793375C4.50612 8.4716625 6.255472500000001 8.598225 9 8.598225C11.744512499999999 8.598225 13.493850000000002 8.4716625 14.40465 8.3793375C14.5762875 8.3619375 14.705324999999998 8.221725000000001 14.705324999999998 8.025825000000001L14.705324999999998 6.5892824999999995C14.705324999999998 6.3673875 14.525437499999999 6.1875 14.303550000000001 6.1875L3.696405 6.1875z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M4.9017675 4.0179075C4.9017675 2.8196475 5.873145 1.84827 7.071405 1.84827C8.2696875 1.84827 9.241050000000001 2.8196475 9.241050000000001 4.0179075L9.241050000000001 6.187552499999999L7.071405 6.187552499999999C5.873145 6.187552499999999 4.9017675 5.2161675 4.9017675 4.0179075zM7.071405 2.9732700000000003C6.494467500000001 2.9732700000000003 6.0267675 3.44097 6.0267675 4.0179075C6.0267675 4.5948525 6.494467500000001 5.0625525 7.071405 5.0625525L8.116050000000001 5.0625525L8.116050000000001 4.0179075C8.116050000000001 3.44097 7.648350000000001 2.9732700000000003 7.071405 2.9732700000000003z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M8.758875 4.0179075C8.758875 2.8196475 9.730274999999999 1.84827 10.928550000000001 1.84827C12.126825 1.84827 13.098225000000001 2.8196475 13.098225000000001 4.0179075C13.098225000000001 5.2161675 12.126825 6.187552499999999 10.928550000000001 6.187552499999999L8.758875 6.187552499999999L8.758875 4.0179075zM10.928550000000001 2.9732700000000003C10.3516125 2.9732700000000003 9.883875 3.44097 9.883875 4.0179075L9.883875 5.0625525L10.928550000000001 5.0625525C11.505487500000001 5.0625525 11.973225 4.5948525 11.973225 4.0179075C11.973225 3.44097 11.505487500000001 2.9732700000000003 10.928550000000001 2.9732700000000003z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M9 4.2588525C9.310649999999999 4.2588525 9.5625 4.5106874999999995 9.5625 4.8213525L9.5625 14.78565C9.5625 15.0963 9.310649999999999 15.34815 9 15.34815C8.6893125 15.34815 8.4375 15.0963 8.4375 14.78565L8.4375 4.8213525C8.4375 4.5106874999999995 8.6893125 4.2588525 9 4.2588525z", fill: "currentColor" })] }));
56
+ /** 网页链接图标 */
57
+ const WebLinkIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-14 mb-3 mr-2 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 18 18", children: [(0, jsx_runtime_1.jsx)("path", { d: "M8.614275 6.87951C8.7490125 6.6030750000000005 9.082275 6.4881975 9.358725 6.622927499999999C9.806437500000001 6.7862849999999995 10.2297 7.0488 10.590599999999998 7.409677499999999C12.12825 8.9473875 12.12825 11.440462499999999 10.590599999999998 12.978150000000001L8.734425 14.834325C7.196745 16.3720125 4.7036549999999995 16.3720125 3.1659675 14.834325C1.6282725 13.296637500000001 1.6282725 10.803525 3.1659675 9.2658375L4.5079125 7.923900000000001C4.7275875 7.704224999999999 5.08374 7.704224999999999 5.303415 7.923900000000001C5.5230825 8.143575 5.5230825 8.499712500000001 5.303415 8.7193875L3.9614625 10.061325C2.8631100000000003 11.1597 2.8631100000000003 12.940462499999999 3.9614625 14.0388375C5.0598 15.137175 6.840585 15.137175 7.9389375 14.0388375L9.795075 12.1826625C10.89345 11.084325 10.89345 9.303525 9.795075 8.205187500000001C9.5242125 7.9342875 9.206475 7.7408175 8.8708125 7.623959999999999C8.5944 7.4892375 8.479537500000001 7.155944999999999 8.614275 6.87951z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M14.0377875 3.9623775C12.93945 2.8640250000000003 11.1586875 2.8640250000000003 10.0603125 3.9623775L8.204175 5.81853C7.1058225 6.9168825 7.1058225 8.697637499999999 8.204175 9.7960125C8.4579 10.049737499999999 8.753325 10.234425 9.065775 10.3508625C9.338925 10.492275 9.4457625 10.828275 9.304387499999999 11.1013875C9.162975 11.3745375 8.826975 11.481375 8.553862500000001 11.34C8.138175 11.1783 7.745744999999999 10.928550000000001 7.4086725 10.5915C5.870985 9.0538125 5.870985 6.560722499999999 7.4086725 5.023035L9.264825 3.1668825C10.802512499999999 1.6291875 13.2955875 1.6291875 14.833312500000002 3.1668825C16.371 4.70457 16.371 7.197660000000001 14.833312500000002 8.735325L13.549425 10.0192125C13.329787500000002 10.23885 12.973650000000001 10.23885 12.7539375 10.0192125C12.534299999999998 9.7995 12.534299999999998 9.443362500000001 12.7539375 9.2236875L14.0377875 7.939837499999999C15.136125 6.8415 15.136125 5.0607225 14.0377875 3.9623775z", fill: "currentColor" })] }));
58
+ /** 站内图文链接图标 */
59
+ const OpusLinkIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-16 h-auto mb-2 mr-2 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 20 20", children: [(0, jsx_runtime_1.jsx)("path", { d: "M10 3.124591666666667C8.164908333333335 3.124591666666667 6.791808333333333 3.15845 5.811916666666667 3.1982166666666667C5.002533333333334 3.231058333333334 4.375 3.8969416666666667 4.375 4.743841666666667L4.375 15.12575C4.375 16.01275 5.067016666666667 16.737333333333336 5.943891666666667 16.773000000000003C7.195191666666667 16.823833333333337 8.756833333333335 16.874583333333334 10 16.874583333333334C11.243166666666667 16.874583333333334 12.804833333333335 16.823833333333337 14.056125 16.773000000000003C14.932958333333335 16.737333333333336 15.625 16.01275 15.625 15.12575L15.625 4.743841666666667C15.625 3.8969416666666667 14.997458333333332 3.231058333333334 14.188083333333335 3.1982166666666667C13.208208333333333 3.15845 11.835125 3.124591666666667 10 3.124591666666667zM5.7612250000000005 1.9492416666666668C6.759566666666667 1.908725 8.149641666666668 1.8745916666666667 10 1.8745916666666667C11.850375 1.8745916666666667 13.240458333333335 1.908725 14.238791666666666 1.9492416666666668C15.754791666666668 2.010766666666667 16.875 3.263466666666667 16.875 4.743841666666667L16.875 15.12575C16.875 16.673958333333335 15.663166666666667 17.958708333333334 14.106874999999999 18.021958333333334C12.851916666666668 18.072958333333336 11.269541666666667 18.124583333333334 10 18.124583333333334C8.730458333333333 18.124583333333334 7.148116666666668 18.072958333333336 5.893133333333334 18.021958333333334C4.336833333333334 17.958708333333334 3.125 16.673958333333335 3.125 15.12575L3.125 4.743841666666667C3.125 3.263475 4.245233333333334 2.010766666666667 5.7612250000000005 1.9492416666666668z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.385416666666667 6.2491666666666665C6.385416666666667 5.921250000000001 6.65125 5.655416666666667 6.979166666666667 5.655416666666667L9.479166666666668 5.655416666666667C9.807083333333333 5.655416666666667 10.072916666666668 5.921250000000001 10.072916666666668 6.2491666666666665C10.072916666666668 6.577091666666667 9.807083333333333 6.842908333333333 9.479166666666668 6.842908333333333L6.979166666666667 6.842908333333333C6.65125 6.842908333333333 6.385416666666667 6.577091666666667 6.385416666666667 6.2491666666666665z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.28125 8.749166666666667C6.28125 8.421258333333334 6.547083333333333 8.155408333333334 6.875 8.155408333333334L13.125 8.155408333333334C13.452916666666667 8.155408333333334 13.71875 8.421258333333334 13.71875 8.749166666666667C13.71875 9.077083333333334 13.452916666666667 9.342916666666666 13.125 9.342916666666666L6.875 9.342916666666666C6.547083333333333 9.342916666666666 6.28125 9.077083333333334 6.28125 8.749166666666667z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.28125 11.249166666666667C6.28125 10.92125 6.547083333333333 10.655416666666667 6.875 10.655416666666667L13.125 10.655416666666667C13.452916666666667 10.655416666666667 13.71875 10.92125 13.71875 11.249166666666667C13.71875 11.577083333333334 13.452916666666667 11.842916666666666 13.125 11.842916666666666L6.875 11.842916666666666C6.547083333333333 11.842916666666666 6.28125 11.577083333333334 6.28125 11.249166666666667z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.28125 13.749166666666666C6.28125 13.42125 6.547083333333333 13.155416666666667 6.875 13.155416666666667L11.458333333333334 13.155416666666667C11.78625 13.155416666666667 12.052083333333334 13.42125 12.052083333333334 13.749166666666666C12.052083333333334 14.077083333333333 11.78625 14.342916666666667 11.458333333333334 14.342916666666667L6.875 14.342916666666667C6.547083333333333 14.342916666666667 6.28125 14.077083333333333 6.28125 13.749166666666666z", fill: "currentColor" })] }));
60
+ /** 投票图标 */
61
+ const VoteIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-20 mb-2 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 18 18", children: [(0, jsx_runtime_1.jsx)("path", { d: "M1.5 10.688324999999999C1.5 9.6528 2.3394675 8.813324999999999 3.375 8.813324999999999L4.125 8.813324999999999C5.1605324999999995 8.813324999999999 6 9.6528 6 10.688324999999999L6 13.313325C6 14.348849999999999 5.1605324999999995 15.188325 4.125 15.188325L3.375 15.188325C2.3394675 15.188325 1.5 14.348849999999999 1.5 13.313325L1.5 10.688324999999999zM3.375 9.938324999999999C2.96079 9.938324999999999 2.625 10.2741 2.625 10.688324999999999L2.625 13.313325C2.625 13.72755 2.96079 14.063325 3.375 14.063325L4.125 14.063325C4.5392175 14.063325 4.875 13.72755 4.875 13.313325L4.875 10.688324999999999C4.875 10.2741 4.5392175 9.938324999999999 4.125 9.938324999999999L3.375 9.938324999999999z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M6.75 4.313235000000001C6.75 3.2777024999999997 7.589482500000001 2.438235 8.625 2.438235L9.375 2.438235C10.410525 2.438235 11.25 3.2777024999999997 11.25 4.313235000000001L11.25 13.31325C11.25 14.348775 10.410525 15.18825 9.375 15.18825L8.625 15.18825C7.589482500000001 15.18825 6.75 14.348775 6.75 13.31325L6.75 4.313235000000001zM8.625 3.563235C8.210775 3.563235 7.875 3.8990175000000002 7.875 4.313235000000001L7.875 13.31325C7.875 13.727437499999999 8.210775 14.06325 8.625 14.06325L9.375 14.06325C9.789225 14.06325 10.125 13.727437499999999 10.125 13.31325L10.125 4.313235000000001C10.125 3.8990175000000002 9.789225 3.563235 9.375 3.563235L8.625 3.563235z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M12 8.25075C12 7.2152025 12.839475 6.375735000000001 13.875 6.375735000000001L14.625 6.375735000000001C15.660525 6.375735000000001 16.5 7.2152025 16.5 8.25075L16.5 13.31325C16.5 14.348775 15.660525 15.18825 14.625 15.18825L13.875 15.18825C12.839475 15.18825 12 14.348775 12 13.31325L12 8.25075zM13.875 7.500742499999999C13.460775000000002 7.500742499999999 13.125 7.836525 13.125 8.25075L13.125 13.31325C13.125 13.727437499999999 13.460775000000002 14.06325 13.875 14.06325L14.625 14.06325C15.039224999999998 14.06325 15.375 13.727437499999999 15.375 13.31325L15.375 8.25075C15.375 7.836525 15.039224999999998 7.500742499999999 14.625 7.500742499999999L13.875 7.500742499999999z", fill: "currentColor" })] }));
62
+ /** 查看图片图标 */
63
+ const ViewPictureIcon = ({ className }) => ((0, jsx_runtime_1.jsxs)("svg", { className: (0, cn_1.cn)(className, 'inline-block w-20 align-middle'), xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 22 22", width: "22", height: "22", children: [(0, jsx_runtime_1.jsx)("path", { d: "M7.791666666666666 7.733060333333333C7.253044666666666 7.733060333333333 6.816416666666667 8.169688333333333 6.816416666666667 8.708310333333333C6.816416666666667 9.246946 7.253044666666666 9.683544999999999 7.791666666666666 9.683544999999999C8.330281000000001 9.683544999999999 8.766916666666667 9.246946 8.766916666666667 8.708310333333333C8.766916666666667 8.169688333333333 8.330281000000001 7.733060333333333 7.791666666666666 7.733060333333333zM5.558583333333333 8.708310333333333C5.558583333333333 7.475007999999999 6.558372 6.4752193333333325 7.791666666666666 6.4752193333333325C9.024961333333332 6.4752193333333325 10.02475 7.475007999999999 10.02475 8.708310333333333C10.02475 9.941568333333333 9.024961333333332 10.941378333333333 7.791666666666666 10.941378333333333C6.558372 10.941378333333333 5.558583333333333 9.941568333333333 5.558583333333333 8.708310333333333z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M11 4.543596666666667C8.690401666666668 4.543596666666667 6.673815333333333 4.661083166666667 5.250284333333333 4.776523999999999C4.243521333333333 4.858162833333334 3.4624053333333333 5.627683666666666 3.37265 6.626020666666667C3.268142166666667 7.788485666666666 3.170833333333333 9.321563333333334 3.170833333333333 10.9978C3.170833333333333 12.673983333333332 3.268142166666667 14.207033333333332 3.37265 15.369535C3.4624053333333333 16.36785666666667 4.243521333333333 17.137388333333334 5.250284333333333 17.219013333333333C6.673816833333333 17.334481666666665 8.690401666666668 17.451966666666664 11 17.451966666666664C13.309854999999999 17.451966666666664 15.326548333333335 17.33439 16.750163333333333 17.218959999999996C17.756758333333334 17.137349999999998 18.5377 16.36804 18.627441666666666 15.36994C18.731925 14.207988333333333 18.829166666666666 12.675175 18.829166666666666 10.9978C18.829166666666666 9.320333333333332 18.731925 7.787542999999999 18.627441666666666 6.6255715C18.5377 5.627479 17.756758333333334 4.858190333333333 16.750163333333333 4.776553C15.326548333333335 4.661109166666666 13.309854999999999 4.543596666666667 11 4.543596666666667zM5.145209166666667 3.480780333333333C6.5952265 3.3631968333333333 8.647761666666666 3.2435966666666665 11 3.2435966666666665C13.352495000000001 3.2435966666666665 15.405159999999999 3.3632151666666665 16.855203333333332 3.4808078333333334C18.484758333333332 3.6129723333333335 19.775116666666666 4.873037 19.922241666666665 6.509160333333334C20.02923333333333 7.6992561666666655 20.129166666666666 9.272141666666666 20.129166666666666 10.9978C20.129166666666666 12.723366666666667 20.02923333333333 14.296258333333332 19.922241666666665 15.486381666666665C19.775116666666666 17.12246833333333 18.484758333333332 18.382566666666666 16.855203333333332 18.514723333333333C15.405159999999999 18.63231 13.352495000000001 18.751966666666664 11 18.751966666666664C8.647761666666666 18.751966666666664 6.5952265 18.63231 5.145209166666667 18.514761666666665C3.515391333333333 18.382566666666666 2.224978166666667 17.122193333333332 2.0778760000000003 15.485923333333332C1.970837 14.295341666666666 1.8708333333333333 12.722213333333332 1.8708333333333333 10.9978C1.8708333333333333 9.273295 1.970837 7.700146833333332 2.0778760000000003 6.509618666666666C2.224978166666667 4.8733365 3.515391333333333 3.6129448333333336 5.145209166666667 3.480780333333333z", fill: "currentColor" }), (0, jsx_runtime_1.jsx)("path", { d: "M14.586553333333333 12.397246666666668C14.19608 12.006681666666665 13.562881666666666 12.006681666666665 13.172316666666665 12.397208333333333L11.288666666666668 14.280896666666665C10.517069999999999 15.052493333333333 9.265836666666667 15.052218333333332 8.494585500000001 14.280124999999998C8.166277166666667 13.951508333333333 7.633659333333334 13.951363333333331 7.305149499999999 14.279834999999999L5.922092833333333 15.66269C5.6682380000000006 15.91648833333333 5.256674833333333 15.91648833333333 5.002853666666667 15.662636666666666C4.7490248333333325 15.4088 4.749050833333333 14.99722 5.002907166666666 14.743368333333333L6.385979166666666 13.360513333333333C7.222356166666667 12.524223333333333 8.578404666666666 12.524628333333332 9.414303333333333 13.361376666666667C9.677975 13.6253 10.105658333333334 13.625445 10.369436666666665 13.361666666666666L12.253033333333333 11.477978333333331C13.151301666666665 10.57971 14.607698333333333 10.579763333333334 15.505913333333332 11.478108333333331L16.99718 12.969611666666665C17.250978333333336 13.223448333333334 17.25094 13.63499 16.997049999999998 13.888841666666666C16.743198333333332 14.142639999999998 16.331671666666665 14.142639999999998 16.07782 13.88875L14.586553333333333 12.397246666666668z", fill: "currentColor" })] }));
64
+ /**
65
+ * 渲染带行内样式的文本节点。
66
+ */
67
+ const renderStyledText = (text, style, index) => {
68
+ if (!style) {
69
+ return (0, jsx_runtime_1.jsx)("span", { children: text }, `text-${index}`);
70
+ }
71
+ const classNames = [];
72
+ if (style.bold)
73
+ classNames.push('font-bold');
74
+ if (style.italic)
75
+ classNames.push('italic');
76
+ if (style.strike)
77
+ classNames.push('line-through');
78
+ const inlineStyle = {};
79
+ if (style.color) {
80
+ inlineStyle.color = style.color;
81
+ }
82
+ if (style.fontSize) {
83
+ inlineStyle.fontSize = style.fontSize;
84
+ }
85
+ if (style.link) {
86
+ return ((0, jsx_runtime_1.jsx)("a", { href: style.link, className: classNames.join(' ') || undefined, style: inlineStyle, target: "_blank", rel: "noopener noreferrer", "data-richtext-node": "text", children: text }, `text-${index}`));
87
+ }
88
+ if (classNames.length === 0 && Object.keys(inlineStyle).length === 0) {
89
+ return (0, jsx_runtime_1.jsx)("span", { children: text }, `text-${index}`);
90
+ }
91
+ return ((0, jsx_runtime_1.jsx)("span", { className: classNames.join(' ') || undefined, style: inlineStyle, "data-richtext-node": "text", children: text }, `text-${index}`));
92
+ };
93
+ /**
94
+ * 将单个富文本节点渲染成 React 节点。
95
+ *
96
+ * 这里的设计重点是"只在 template 侧落地 UI 语义":
97
+ * - `core` 不需要依赖 React,也不用承担 JSX/SSR 运行时边界。
98
+ * - React 负责文本与属性转义,我们只补上图片协议白名单。
99
+ */
100
+ const renderNodeToReact = (node, index, options) => {
101
+ switch (node.type) {
102
+ case 'text': {
103
+ const text = node.text;
104
+ const urlRegex = /https?:\/\/[-\w._~:/?#[\]@!$&'()*+,;=%]+/g;
105
+ if (!urlRegex.test(text)) {
106
+ return renderStyledText(text, node.style, index);
107
+ }
108
+ const parts = [];
109
+ let lastIndex = 0;
110
+ let match;
111
+ urlRegex.lastIndex = 0;
112
+ while ((match = urlRegex.exec(text)) !== null) {
113
+ if (match.index > lastIndex) {
114
+ parts.push(renderStyledText(text.slice(lastIndex, match.index), node.style, `${index}-pre-${match.index}`));
115
+ }
116
+ parts.push((0, jsx_runtime_1.jsx)("span", { className: "break-all", children: renderStyledText(match[0], node.style, `${index}-url-${match.index}`) }, `url-${index}-${match.index}`));
117
+ lastIndex = match.index + match[0].length;
118
+ }
119
+ if (lastIndex < text.length) {
120
+ parts.push(renderStyledText(text.slice(lastIndex), node.style, `${index}-post`));
121
+ }
122
+ return (0, jsx_runtime_1.jsx)(react_1.default.Fragment, { children: parts }, `text-fragment-${index}`);
123
+ }
124
+ case 'lineBreak':
125
+ return (0, jsx_runtime_1.jsx)("br", {}, `br-${index}`);
126
+ case 'mention':
127
+ return ((0, jsx_runtime_1.jsx)("span", { className: options.mention?.className, "data-richtext-node": "mention", "data-user-id": node.userId, children: node.text }, `mention-${index}`));
128
+ case 'searchKeyword':
129
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.searchKeyword?.className, "data-richtext-node": "searchKeyword", "data-search-query-id": node.queryId, children: [(0, jsx_runtime_1.jsx)("span", { children: node.text }), (0, jsx_runtime_1.jsx)(SearchKeywordIcon, { className: options.searchKeyword?.iconClassName })] }, `search-${index}`));
130
+ case 'emoji': {
131
+ const safeSrc = sanitizeImageSource(node.src);
132
+ if (!safeSrc) {
133
+ return node.name;
134
+ }
135
+ return ((0, jsx_runtime_1.jsx)("img", { className: "mx-1", src: safeSrc, alt: node.name, style: getRichTextEmojiStyle(node.scale), referrerPolicy: "no-referrer", crossOrigin: "anonymous", "data-richtext-node": "emoji" }, `emoji-${index}`));
136
+ }
137
+ case 'topic':
138
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.topic?.className, "data-richtext-node": "topic", children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
139
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
140
+ : undefined, children: (0, jsx_runtime_1.jsx)(TopicIcon, {}) }), node.text] }, `topic-${index}`));
141
+ case 'hashtag':
142
+ return ((0, jsx_runtime_1.jsx)("span", { className: options.hashtag?.className, "data-richtext-node": "hashtag", children: node.text }, `hashtag-${index}`));
143
+ case 'at':
144
+ return ((0, jsx_runtime_1.jsx)("span", { className: options.at?.className, "data-richtext-node": "at", "data-user-id": node.userId, children: node.text }, `at-${index}`));
145
+ case 'lottery':
146
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.lottery?.className, "data-richtext-node": "lottery", children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
147
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
148
+ : undefined, children: (0, jsx_runtime_1.jsx)(LotteryIcon, {}) }), node.text] }, `lottery-${index}`));
149
+ case 'webLink':
150
+ return ((0, jsx_runtime_1.jsxs)("a", { className: (0, cn_1.cn)(options.webLink?.className, 'break-all'), href: node.jumpUrl, target: "_blank", rel: "noopener noreferrer", "data-richtext-node": "webLink", children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
151
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
152
+ : undefined, children: (0, jsx_runtime_1.jsx)(WebLinkIcon, {}) }), node.text] }, `weblink-${index}`));
153
+ case 'opusLink':
154
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.opusLink?.className, "data-richtext-node": "opusLink", "data-url": node.url, children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
155
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
156
+ : undefined, children: (0, jsx_runtime_1.jsx)(OpusLinkIcon, {}) }), node.text] }, `opuslink-${index}`));
157
+ case 'vote':
158
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.vote?.className, "data-richtext-node": "vote", children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
159
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
160
+ : undefined, children: (0, jsx_runtime_1.jsx)(VoteIcon, {}) }), node.text] }, `vote-${index}`));
161
+ case 'viewPicture':
162
+ return ((0, jsx_runtime_1.jsxs)("span", { className: options.viewPicture?.className, "data-richtext-node": "viewPicture", children: [(0, jsx_runtime_1.jsx)("span", { style: options.iconScale && options.iconScale !== 1
163
+ ? { transform: `scale(${options.iconScale})`, transformOrigin: 'left center', display: 'inline-block' }
164
+ : undefined, children: (0, jsx_runtime_1.jsx)(ViewPictureIcon, {}) }), node.text] }, `viewpicture-${index}`));
165
+ case 'heading': {
166
+ const HeadingTag = `h${node.level}`;
167
+ const sizeClass = node.level === 1
168
+ ? 'text-[64px]'
169
+ : node.level === 2
170
+ ? 'text-[58px]'
171
+ : node.level === 3
172
+ ? 'text-[52px]'
173
+ : node.level === 4
174
+ ? 'text-[48px]'
175
+ : node.level === 5
176
+ ? 'text-[44px]'
177
+ : 'text-[40px]';
178
+ return ((0, jsx_runtime_1.jsx)(HeadingTag, { className: `${sizeClass} font-bold my-10`, "data-richtext-node": "heading", "data-heading-level": node.level, children: node.nodes.map((child, childIndex) => renderNodeToReact(child, childIndex, options)) }, `heading-${index}`));
179
+ }
180
+ case 'paragraph':
181
+ return ((0, jsx_runtime_1.jsx)("p", { "data-richtext-node": "paragraph", children: node.nodes.map((child, childIndex) => renderNodeToReact(child, childIndex, options)) }, `paragraph-${index}`));
182
+ case 'image': {
183
+ const safeSrc = sanitizeImageSource(node.src);
184
+ if (!safeSrc) {
185
+ return null;
186
+ }
187
+ return ((0, jsx_runtime_1.jsxs)("div", { "data-richtext-node": "image", children: [(0, jsx_runtime_1.jsx)("img", { className: "rounded-4xl", src: safeSrc, alt: node.alt || '', referrerPolicy: "no-referrer", crossOrigin: "anonymous" }), node.caption && (0, jsx_runtime_1.jsx)("div", { className: "mt-6 text-center text-[36px] text-foreground/60 select-text", children: node.caption })] }, `image-${index}`));
188
+ }
189
+ case 'horizontalRule':
190
+ return (0, jsx_runtime_1.jsx)("div", { className: "my-16 w-full h-px bg-border", "data-richtext-node": "horizontalRule" }, `hr-${index}`);
191
+ case 'blockquote':
192
+ return ((0, jsx_runtime_1.jsx)("blockquote", { "data-richtext-node": "blockquote", children: node.nodes.map((child, childIndex) => renderNodeToReact(child, childIndex, options)) }, `blockquote-${index}`));
193
+ case 'list': {
194
+ const ListTag = node.ordered ? 'ol' : 'ul';
195
+ return ((0, jsx_runtime_1.jsx)(ListTag, { "data-richtext-node": "list", "data-list-ordered": node.ordered, children: node.items.map((item, itemIndex) => renderNodeToReact(item, itemIndex, options)) }, `list-${index}`));
196
+ }
197
+ case 'listItem':
198
+ return ((0, jsx_runtime_1.jsx)("li", { "data-richtext-node": "listItem", children: node.nodes.map((child, childIndex) => renderNodeToReact(child, childIndex, options)) }, `listitem-${index}`));
199
+ case 'codeBlock': {
200
+ const lines = node.content.split('\n');
201
+ const showLang = node.language && node.language !== 'plaintext';
202
+ return ((0, jsx_runtime_1.jsxs)("div", { className: (0, cn_1.cn)('bg-surface rounded-4xl my-8 border border-border', options.codeBlock?.className), "data-richtext-node": "codeBlock", "data-language": node.language, children: [showLang && ((0, jsx_runtime_1.jsx)("div", { className: "px-12 py-6 text-[36px] font-medium text-muted border-b border-border", "data-richtext-code-lang": true, children: node.language })), (0, jsx_runtime_1.jsx)("div", { className: "py-8 pl-4 pr-12", "data-richtext-code-body": true, children: lines.map((line, lineIndex) => ((0, jsx_runtime_1.jsxs)("div", { className: "flex gap-16 leading-[1.8]", "data-richtext-code-line": true, children: [(0, jsx_runtime_1.jsx)("span", { className: "shrink-0 w-12 text-right text-[30px] text-muted select-none font-mono", "data-richtext-code-lineno": true, children: lineIndex + 1 }), (0, jsx_runtime_1.jsx)("code", { className: "font-mono text-[34px] whitespace-pre-wrap break-all text-foreground", "data-richtext-code-content": true, children: line || ' ' })] }, `line-${lineIndex}`))) })] }, `codeblock-${index}`));
203
+ }
204
+ case 'linkCard':
205
+ return ((0, jsx_runtime_1.jsx)("a", { className: options.linkCard?.className, href: node.url, target: "_blank", rel: "noopener noreferrer", "data-richtext-node": "linkCard", "data-card-type": node.cardType, children: node.title }, `linkcard-${index}`));
206
+ default:
207
+ return null;
208
+ }
209
+ };
210
+ /**
211
+ * 将富文本文档渲染成 React 节点。
212
+ *
213
+ * 这是 React 模板的首选渲染方式:
214
+ * - 不经过 HTML 字符串;
215
+ * - 不需要 `dangerouslySetInnerHTML`;
216
+ * - 更适合 SSR,因为传输边界仍然是纯 JSON。
217
+ */
218
+ const renderRichTextToReact = (document, options = {}) => {
219
+ return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: document.nodes.map((node, index) => renderNodeToReact(node, index, options)) });
220
+ };
221
+ exports.renderRichTextToReact = renderRichTextToReact;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/lib/schema.js ADDED
@@ -0,0 +1,352 @@
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.parseConfigMeta = parseConfigMeta;
7
+ exports.parseConfigDescriptions = parseConfigDescriptions;
8
+ exports.buildUpstreamSchema = buildUpstreamSchema;
9
+ /**
10
+ * 把插件自己的配置(上游的 config.json)映射成 Koishi 的控制台表单。
11
+ *
12
+ * 上游 Karin 版把这些配置放在 \`config/config.json\`(amagi / app / douyin / bilibili / kuaishou /
13
+ * xiaohongshu / pushlist 七个模块),由它的 WebUI 编辑。Koishi 侧如果只声明集成选项,
14
+ * 控制台的「插件配置」里就看不到清晰度这类选项 —— 所以这里**按默认配置的形状动态生成 Schema**:
15
+ * - 结构、键名与上游完全一致,升级上游默认配置后表单会自动跟着变;
16
+ * - 描述取自上游 \`config/default_config/*.yaml\` 里每个字段上方的中文注释(Karin 版的字段说明);
17
+ * - **默认值取自同一份默认配置**:所有字段在控制台里都显示真实取值,而不是一片空白;
18
+ * - **枚举型字段渲染成下拉框**:取值直接从注释里解析(「可选值:'info'(视频信息)…」、
19
+ * \`- 6: 240P 极速\` 这类列表、\`all为所有人\` 这类权限说明),选项文案用注释里的中文说明。
20
+ *
21
+ * ⚠️ 默认值带来的副作用(已在 configBridge 里处理):Koishi 会把默认值填进配置对象,
22
+ * 于是「没填」和「填了默认值」不再靠有没有值来区分,改为**与上游默认值相等即视为没填**,
23
+ * 这样用户直接改 config.json 的内容不会在下次启动时被表单里的默认值覆盖。
24
+ * 代价:在控制台里把某项改回默认值,不会写回 config.json(想强制改回请用 /kkk 面板或直接改文件)。
25
+ */
26
+ const node_fs_1 = __importDefault(require("node:fs"));
27
+ const node_path_1 = __importDefault(require("node:path"));
28
+ const koishi_1 = require("koishi");
29
+ /** 递归深度上限,避免异常配置把 Schema 撑爆 */
30
+ const MAX_DEPTH = 6;
31
+ /**
32
+ * 补充说明:上游 YAML 里没有(字段是后加的)或只作为模块容器出现的字段,
33
+ * 按 \`src/karin/types/config/*.ts\` 的 JSDoc 与实际用途补上。YAML 里已有的说明优先。
34
+ */
35
+ const SUPPLEMENT = {
36
+ amagi: 'amagi 解析库配置:请求超时、UA、代理、各平台 Cookie、内置 API Server',
37
+ 'amagi.proxy.switch': '是否启用代理',
38
+ 'amagi.cookies': '各平台 Cookie,扫码登录成功后会自动写入这里',
39
+ 'amagi.cookies.bilibili': 'B站 Cookie(SESSDATA 等),配置后才能拿高画质与动态推送',
40
+ 'amagi.cookies.douyin': '抖音 Cookie,配置后才能解析作品与推送',
41
+ 'amagi.cookies.kuaishou': '快手 Cookie',
42
+ 'amagi.cookies.xiaohongshu': '小红书 Cookie',
43
+ app: '全局通用设置:解析总开关、渲染、缓存、错误上报等',
44
+ 'app.ambientCover': '封面氛围背景参数:控制封面图对模板背景氛围的贡献度,取值 0~1',
45
+ 'app.ambientCover.coverOpacity': '模糊封面层不透明度:封面色强度总闸,越大整体越浓',
46
+ 'app.ambientCover.overlayEdgeOpacity': '主题色压色罩两端(顶/底)不透明度',
47
+ 'app.ambientCover.overlayMiddleOpacity': '主题色压色罩中间带不透明度,越小封面色越透',
48
+ douyin: '抖音解析与推送设置',
49
+ bilibili: 'B站解析与推送设置',
50
+ kuaishou: '快手解析设置',
51
+ xiaohongshu: '小红书解析设置',
52
+ pushlist: '推送订阅列表:每一项是「关注对象 + 群号:机器人账号」,可加过滤词/标签',
53
+ 'xiaohongshu.watermark': '小红书图片是否加水印(上游保留项)'
54
+ };
55
+ /**
56
+ * 注释里解析不出来的枚举,手工补。
57
+ * 只补「取值域封闭、写错就跑不起来」的字段;普通数值/文本**不要**往这里加,
58
+ * 否则控制台会把人限制在几个选项里。
59
+ */
60
+ const SUPPLEMENT_ENUMS = {
61
+ 'app.Theme': [
62
+ { value: 0, label: '自动(06:00-18:00 浅色,其余深色)' },
63
+ { value: 1, label: '浅色' },
64
+ { value: 2, label: '深色' },
65
+ { value: 3, label: '智能场景(按封面判断深浅)' }
66
+ ],
67
+ 'douyin.push.shareType': [
68
+ { value: 'web', label: '跳转到抖音网页' },
69
+ { value: 'download', label: '视频下载直链' }
70
+ ]
71
+ };
72
+ /** 权限类字段:值就是 all / admin / master / group.owner / group.admin */
73
+ const PERMISSION_VALUES = [
74
+ { value: 'all', label: '所有人' },
75
+ { value: 'admin', label: '管理员' },
76
+ { value: 'master', label: '主人' },
77
+ { value: 'group.owner', label: '群主' },
78
+ { value: 'group.admin', label: '群管理员' }
79
+ ];
80
+ /** 字段名命中权限域 */
81
+ const isPermissionField = (name) => /^(loginPerm|permission)$/i.test(name);
82
+ /** 剥掉列表项的 \`[]\` 后缀,用于回查字段名 */
83
+ const shortName = (fieldPath) => fieldPath.split('.').pop().replace(/\[\]$/, '');
84
+ /**
85
+ * 从注释行里抽枚举候选。
86
+ *
87
+ * 支持的三种写法(都是上游 YAML 里真实存在的):
88
+ * 1. \`可选值:'info'(视频信息)、'comment'(评论图片)\` —— 引号里的值 + 紧跟的中文说明;
89
+ * 2. 列表项 \`- 6: 240P 极速\` / \`- 'off': 关闭\` / \`- 'google' - Google Motion Photo\`;
90
+ * 3. \`all为所有人,admin为管理员…\` —— 权限字段常见写法。
91
+ * @param lines 该字段的注释行
92
+ * @param name 字段名(判断是不是权限域)
93
+ */
94
+ function extractOptions(lines, name) {
95
+ const found = new Map();
96
+ const add = (rawValue, label) => {
97
+ const value = String(rawValue ?? '').trim().replace(/^['"]|['"]$/g, '');
98
+ const text = String(label ?? '').replace(/^[\s::\-—]+/, '').replace(/[,,。;;]+$/, '').trim();
99
+ if (!value || found.has(value))
100
+ return;
101
+ found.set(value, text);
102
+ };
103
+ for (const line of lines) {
104
+ const bullet = line.match(/^\s*[-*·]\s+(.+)$/);
105
+ if (bullet) {
106
+ const item = bullet[1].match(/^['"]?([^'"\s::]+)['"]?\s*(?:[::\-—]\s*)?(.*)$/);
107
+ if (item)
108
+ add(item[1], item[2]);
109
+ continue;
110
+ }
111
+ if (/可选值|可选:/.test(line)) {
112
+ const quoted = /['"]([^'"]+)['"]/g;
113
+ let matched;
114
+ while ((matched = quoted.exec(line)) !== null) {
115
+ const rest = line.slice(quoted.lastIndex);
116
+ /**
117
+ * 候选值后面必须紧跟「说明括号 / 顿号 / 逗号 / 句号 / 结束」。
118
+ * 这条约束是为了滤掉解释性文字里的引号 —— 例如
119
+ * 「'master'(除'console'外的第一个主人)」里的 'console' 后面是「外」,
120
+ * 不加约束就会多出一个叫 console 的假选项。
121
+ */
122
+ if (!/^\s*([((、,,。;;]|$)/.test(rest))
123
+ continue;
124
+ const label = rest.match(/^\s*[((]([^))]*)[))]/);
125
+ add(matched[1], label ? label[1] : '');
126
+ }
127
+ continue;
128
+ }
129
+ if (isPermissionField(name)) {
130
+ const words = /([a-zA-Z][\w.]*)为/g;
131
+ let matched;
132
+ while ((matched = words.exec(line)) !== null)
133
+ add(matched[1], '');
134
+ }
135
+ }
136
+ // 「0为自动,1为浅色,2为深色」这类数字枚举:至少 3 个才算,避免把「0-100」这种区间误判成枚举
137
+ const numeric = new Map();
138
+ for (const line of lines) {
139
+ const numbers = /(\d+(?:\.\d+)?)\s*为/g;
140
+ let matched;
141
+ while ((matched = numbers.exec(line)) !== null) {
142
+ if (!numeric.has(matched[1]))
143
+ numeric.set(matched[1], '');
144
+ }
145
+ }
146
+ if (numeric.size >= 3)
147
+ for (const [value, label] of numeric)
148
+ add(value, label);
149
+ return found.size >= 2 ? [...found].map(([value, label]) => ({ value, label })) : undefined;
150
+ }
151
+ /**
152
+ * 解析 \`config/default_config/*.yaml\` 里的字段注释。
153
+ *
154
+ * 形如:
155
+ * \`\`\`yaml
156
+ * # 视频体积上限,自适应画质模式下可接受的最大视频大小(单位:MB)
157
+ * maxAutoVideoSize: 50
158
+ * \`\`\`
159
+ * 注释写在字段上方、连续若干行,用缩进判断层级。
160
+ * @param pluginRoot 插件根目录
161
+ */
162
+ function parseConfigMeta(pluginRoot) {
163
+ const dir = node_path_1.default.join(pluginRoot, 'config', 'default_config');
164
+ const result = {};
165
+ let files = [];
166
+ try {
167
+ files = node_fs_1.default.readdirSync(dir).filter((item) => item.endsWith('.yaml'));
168
+ }
169
+ catch {
170
+ return result;
171
+ }
172
+ for (const file of files) {
173
+ const mod = file.replace(/\.yaml$/, '');
174
+ let content = '';
175
+ try {
176
+ content = node_fs_1.default.readFileSync(node_path_1.default.join(dir, file), 'utf8');
177
+ }
178
+ catch {
179
+ continue;
180
+ }
181
+ const stack = [];
182
+ let comments = [];
183
+ for (const rawLine of content.split(/\r?\n/)) {
184
+ const trimmed = rawLine.trim();
185
+ if (!trimmed) {
186
+ comments = [];
187
+ continue;
188
+ }
189
+ if (trimmed.startsWith('#')) {
190
+ comments.push(trimmed.replace(/^#\s?/, '').trimEnd());
191
+ continue;
192
+ }
193
+ const matched = rawLine.match(/^(\s*)([^\s:#][^:#]*?)\s*:/);
194
+ if (!matched) {
195
+ // 数组项、缩进文本等
196
+ comments = [];
197
+ continue;
198
+ }
199
+ const indent = matched[1].length;
200
+ const key = matched[2].trim().replace(/^['"]|['"]$/g, '');
201
+ while (stack.length && stack[stack.length - 1].indent >= indent)
202
+ stack.pop();
203
+ stack.push({ indent, key });
204
+ const fullPath = [mod, ...stack.map((item) => item.key)].join('.');
205
+ const text = comments.join(' ').replace(/\s+/g, ' ').trim();
206
+ if (text && !result[fullPath]) {
207
+ result[fullPath] = { text, options: extractOptions(comments, key) };
208
+ }
209
+ comments = [];
210
+ }
211
+ }
212
+ // 上游把若干旧 YAML 合并进了 config.json 的模块(例如 amagi 里混着 request/cookies 的字段),
213
+ // 这些字段的完整路径对不上,补一张「唯一短名 → 描述」的表兜底。
214
+ const flatCount = {};
215
+ const flat = {};
216
+ for (const [key, value] of Object.entries(result)) {
217
+ const name = key.split('.').pop();
218
+ flatCount[name] = (flatCount[name] ?? 0) + 1;
219
+ flat[name] = value;
220
+ }
221
+ for (const [name, count] of Object.entries(flatCount)) {
222
+ if (count === 1)
223
+ result['#' + name] = flat[name];
224
+ }
225
+ return result;
226
+ }
227
+ /** 只取描述文本(对外保留的旧接口) */
228
+ function parseConfigDescriptions(pluginRoot) {
229
+ const meta = parseConfigMeta(pluginRoot);
230
+ const result = {};
231
+ for (const [key, value] of Object.entries(meta))
232
+ result[key] = value.text;
233
+ return result;
234
+ }
235
+ /**
236
+ * 取某个字段路径的注释信息:完整路径 → 去掉 \`[]\` 的路径 → 唯一短名兜底。
237
+ *
238
+ * 中间那一跳是为数组元素准备的:枚举解析时用的是 \`xxx[]\`,
239
+ * 而注释是按 \`xxx\` 登记的;同名短名(douyin/bilibili 都有 displayContent)又轮不到兜底表,
240
+ * 少这一跳数组字段就永远拿不到下拉选项。
241
+ */
242
+ function metaOf(meta, fieldPath) {
243
+ return meta[fieldPath]
244
+ ?? meta[fieldPath.replace(/\[\]$/, '')]
245
+ ?? meta['#' + shortName(fieldPath)];
246
+ }
247
+ /** 取某个字段路径的描述:YAML 说明 → 唯一的短名兜底 → 手工补充 */
248
+ function describe(meta, fieldPath) {
249
+ return metaOf(meta, fieldPath)?.text ?? SUPPLEMENT[fieldPath];
250
+ }
251
+ /**
252
+ * 把候选值对齐到字段的类型上。
253
+ * @param options 候选值
254
+ * @param sample 该字段的默认值(决定类型)
255
+ * @returns 可用的下拉选项;类型对不上或不足 2 个时返回 undefined
256
+ */
257
+ function coerceOptions(options, sample) {
258
+ if (!options || options.length < 2)
259
+ return undefined;
260
+ const seen = new Set();
261
+ const result = [];
262
+ for (const option of options) {
263
+ let value;
264
+ if (typeof sample === 'number') {
265
+ value = Number(option.value);
266
+ if (!Number.isFinite(value))
267
+ continue;
268
+ }
269
+ else if (typeof sample === 'string') {
270
+ value = String(option.value);
271
+ }
272
+ else {
273
+ return undefined;
274
+ }
275
+ if (seen.has(value))
276
+ continue;
277
+ seen.add(value);
278
+ result.push({ value, label: option.label });
279
+ }
280
+ return result.length >= 2 ? result : undefined;
281
+ }
282
+ /** 生成叶子字段(枚举 → 下拉;否则按类型给输入框),并带上默认值与说明 */
283
+ function leafSchema(sample, fieldPath, meta, ensure = []) {
284
+ const withDesc = (schema) => {
285
+ const text = describe(meta, fieldPath);
286
+ return text ? schema.description(text) : schema;
287
+ };
288
+ // 手工枚举优先(选项文案更清楚),没有就用注释里解析出来的
289
+ const options = coerceOptions(SUPPLEMENT_ENUMS[fieldPath] ?? metaOf(meta, fieldPath)?.options, sample);
290
+ if (options) {
291
+ const list = [...options];
292
+ /**
293
+ * 默认值必须出现在选项里。
294
+ * 对数组字段这不是理论问题:上游注释里 \`douyin.displayContent\` 就漏写了 \`desc\`,
295
+ * 而默认值里有它 —— 不补进去,控制台一保存就会写出一个 Schema 校验不过的值。
296
+ */
297
+ for (const value of [sample, ...ensure]) {
298
+ if (typeof value !== 'string' && typeof value !== 'number')
299
+ continue;
300
+ if (list.some((option) => option.value === value))
301
+ continue;
302
+ list.unshift({ value, label: String(value) + '(默认值,注释里未列出)' });
303
+ }
304
+ const union = koishi_1.Schema.union(list.map((option) => koishi_1.Schema.const(option.value).description(option.label || String(option.value))));
305
+ return withDesc(union.default(sample));
306
+ }
307
+ if (typeof sample === 'boolean')
308
+ return withDesc(koishi_1.Schema.boolean().default(sample));
309
+ if (typeof sample === 'number')
310
+ return withDesc(koishi_1.Schema.number().default(sample));
311
+ if (typeof sample === 'string')
312
+ return withDesc(koishi_1.Schema.string().default(sample));
313
+ return withDesc(koishi_1.Schema.any());
314
+ }
315
+ function toSchema(value, fieldPath, meta, depth = 0) {
316
+ if (depth > MAX_DEPTH)
317
+ return koishi_1.Schema.any();
318
+ if (Array.isArray(value)) {
319
+ const sample = value.find((item) => item !== null && item !== undefined);
320
+ const inner = sample === undefined ? koishi_1.Schema.any() : leafSchema(sample, fieldPath + '[]', meta, value);
321
+ const text = describe(meta, fieldPath);
322
+ const schema = koishi_1.Schema.array(inner).default(value);
323
+ return text ? schema.description(text) : schema;
324
+ }
325
+ if (value && typeof value === 'object') {
326
+ const dict = {};
327
+ for (const [key, item] of Object.entries(value)) {
328
+ dict[key] = toSchema(item, fieldPath + '.' + key, meta, depth + 1);
329
+ }
330
+ const text = describe(meta, fieldPath);
331
+ const schema = koishi_1.Schema.object(dict);
332
+ return text ? schema.description(text) : schema;
333
+ }
334
+ return leafSchema(value, fieldPath, meta);
335
+ }
336
+ /** 读取插件的默认配置,生成对应的 Koishi Schema(读不到时给个空对象,不影响启动) */
337
+ function buildUpstreamSchema(pluginRoot) {
338
+ try {
339
+ const file = node_path_1.default.join(pluginRoot, 'config', 'default_config', 'config.json');
340
+ const defaults = JSON.parse(node_fs_1.default.readFileSync(file, 'utf8'));
341
+ const meta = parseConfigMeta(pluginRoot);
342
+ const dict = {};
343
+ for (const [key, value] of Object.entries(defaults)) {
344
+ dict[key] = toSchema(value, key, meta);
345
+ }
346
+ return koishi_1.Schema.object(dict);
347
+ }
348
+ catch {
349
+ return koishi_1.Schema.object({});
350
+ }
351
+ }
352
+ exports.default = buildUpstreamSchema;