artalk 2.6.4 → 2.7.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 (300) hide show
  1. package/dist/Artalk.css +1 -1
  2. package/dist/Artalk.es.js +7794 -7483
  3. package/dist/Artalk.iife.js +1 -1
  4. package/dist/Artalk.js +1 -1
  5. package/dist/ArtalkLite.css +1 -1
  6. package/dist/ArtalkLite.es.js +5587 -5276
  7. package/dist/ArtalkLite.iife.js +1 -1
  8. package/dist/ArtalkLite.js +1 -1
  9. package/dist/src/api/{api-base.d.ts → _base.d.ts} +3 -7
  10. package/dist/src/api/_options.d.ts +19 -0
  11. package/dist/src/api/{request.d.ts → _request.d.ts} +3 -3
  12. package/dist/src/api/admin.d.ts +1 -1
  13. package/dist/src/api/captcha.d.ts +1 -1
  14. package/dist/src/api/comment.d.ts +2 -2
  15. package/dist/src/api/index.d.ts +2 -4
  16. package/dist/src/api/page.d.ts +3 -3
  17. package/dist/src/api/site.d.ts +2 -2
  18. package/dist/src/api/system.d.ts +13 -3
  19. package/dist/src/api/upload.d.ts +1 -1
  20. package/dist/src/api/user.d.ts +2 -2
  21. package/dist/src/artalk.d.ts +14 -37
  22. package/dist/src/comment/actions.d.ts +1 -1
  23. package/dist/src/comment/comment.d.ts +3 -4
  24. package/dist/src/comment/render.d.ts +21 -3
  25. package/dist/src/comment/renders/actions.d.ts +2 -2
  26. package/dist/src/comment/renders/avatar.d.ts +2 -2
  27. package/dist/src/comment/renders/content.d.ts +2 -2
  28. package/dist/src/comment/renders/header.d.ts +2 -2
  29. package/dist/src/comment/renders/index.d.ts +2 -2
  30. package/dist/src/comment/renders/pending.d.ts +2 -2
  31. package/dist/src/comment/renders/reply-at.d.ts +2 -2
  32. package/dist/src/comment/renders/reply-to.d.ts +2 -2
  33. package/dist/src/components/action-btn.d.ts +3 -5
  34. package/dist/src/{lib → components}/checker/admin.d.ts +1 -1
  35. package/dist/src/{lib → components}/checker/captcha-renders.d.ts +1 -1
  36. package/dist/src/{lib → components}/checker/captcha.d.ts +1 -1
  37. package/dist/src/{lib → components}/checker/index.d.ts +10 -7
  38. package/dist/src/components/dark-mode.d.ts +2 -0
  39. package/dist/src/components/dialog.d.ts +1 -3
  40. package/dist/src/components/error-dialog.d.ts +8 -0
  41. package/dist/src/components/pagination.d.ts +4 -3
  42. package/dist/src/components/read-more-btn.d.ts +3 -3
  43. package/dist/src/config.d.ts +24 -8
  44. package/dist/src/context.d.ts +16 -35
  45. package/dist/src/data.d.ts +27 -0
  46. package/dist/src/defaults.d.ts +1 -1
  47. package/dist/src/editor/editor.d.ts +14 -61
  48. package/dist/src/editor/state.d.ts +20 -0
  49. package/dist/src/i18n/zh-CN.d.ts +1 -1
  50. package/dist/src/layer/index.d.ts +4 -3
  51. package/dist/src/layer/layer-manager.d.ts +9 -0
  52. package/dist/src/layer/layer.d.ts +8 -28
  53. package/dist/src/layer/scrollbar-helper.d.ts +5 -0
  54. package/dist/src/layer/sidebar-layer.d.ts +6 -6
  55. package/dist/src/layer/wrap.d.ts +13 -0
  56. package/dist/src/lib/component.d.ts +3 -8
  57. package/dist/src/lib/event-manager.d.ts +28 -0
  58. package/dist/src/lib/highlight.d.ts +1 -0
  59. package/dist/src/lib/marked-renderer.d.ts +4 -0
  60. package/dist/src/lib/marked.d.ts +4 -2
  61. package/dist/src/lib/sanitizer.d.ts +1 -0
  62. package/dist/src/lib/ui.d.ts +3 -2
  63. package/dist/src/lib/user.d.ts +8 -5
  64. package/dist/src/lib/utils.d.ts +11 -5
  65. package/dist/src/list/comment.d.ts +3 -0
  66. package/dist/src/list/layout.d.ts +23 -0
  67. package/dist/src/list/list.d.ts +13 -25
  68. package/dist/src/list/{list-nest.d.ts → nest.d.ts} +1 -1
  69. package/dist/src/list/page.d.ts +2 -0
  70. package/dist/src/list/paginator/index.d.ts +22 -7
  71. package/dist/src/list/paginator/read-more.d.ts +18 -0
  72. package/dist/src/list/paginator/up-down.d.ts +14 -0
  73. package/dist/src/main.d.ts +2 -0
  74. package/dist/src/plugins/admin-only-elem.d.ts +2 -0
  75. package/dist/src/plugins/conf-remoter.d.ts +2 -0
  76. package/dist/src/plugins/dark-mode.d.ts +2 -0
  77. package/dist/src/plugins/editor/_kit.d.ts +27 -0
  78. package/dist/src/plugins/editor/_plug.d.ts +29 -0
  79. package/dist/src/plugins/editor/_sample.d.ts +5 -0
  80. package/dist/src/plugins/editor/closable.d.ts +7 -0
  81. package/dist/src/{editor/plugs/emoticons-plug.d.ts → plugins/editor/emoticons.d.ts} +10 -16
  82. package/dist/src/plugins/editor/header-event.d.ts +6 -0
  83. package/dist/src/plugins/editor/header-link.d.ts +6 -0
  84. package/dist/src/plugins/editor/header-user.d.ts +16 -0
  85. package/dist/src/plugins/editor/index.d.ts +6 -0
  86. package/dist/src/plugins/editor/local-storage.d.ts +6 -0
  87. package/dist/src/plugins/editor/mover.d.ts +6 -0
  88. package/dist/src/plugins/editor/preview.d.ts +7 -0
  89. package/dist/src/plugins/editor/state-edit.d.ts +11 -0
  90. package/dist/src/plugins/editor/state-reply.d.ts +8 -0
  91. package/dist/src/plugins/editor/submit-add.d.ts +18 -0
  92. package/dist/src/plugins/editor/submit-btn.d.ts +5 -0
  93. package/dist/src/plugins/editor/submit.d.ts +17 -0
  94. package/dist/src/plugins/editor/textarea.d.ts +8 -0
  95. package/dist/src/plugins/editor/upload.d.ts +9 -0
  96. package/dist/src/plugins/editor-kit.d.ts +42 -0
  97. package/dist/src/plugins/index.d.ts +2 -0
  98. package/dist/src/plugins/list/copyright.d.ts +2 -0
  99. package/dist/src/plugins/list/count.d.ts +2 -0
  100. package/dist/src/plugins/list/dropdown.d.ts +2 -0
  101. package/dist/src/plugins/list/error-dialog.d.ts +2 -0
  102. package/dist/src/plugins/list/fetch.d.ts +2 -0
  103. package/dist/src/plugins/list/goto-first.d.ts +3 -0
  104. package/dist/src/plugins/list/goto.d.ts +2 -0
  105. package/dist/src/plugins/list/index.d.ts +3 -0
  106. package/dist/src/plugins/list/loading.d.ts +2 -0
  107. package/dist/src/plugins/list/no-comment.d.ts +2 -0
  108. package/dist/src/plugins/list/reach-bottom.d.ts +2 -0
  109. package/dist/src/plugins/list/sidebar-btn.d.ts +2 -0
  110. package/dist/src/plugins/list/time-ticking.d.ts +3 -0
  111. package/dist/src/plugins/list/unread-badge.d.ts +2 -0
  112. package/dist/src/plugins/list/unread.d.ts +2 -0
  113. package/dist/src/plugins/list/with-editor.d.ts +2 -0
  114. package/dist/src/plugins/markdown.d.ts +2 -0
  115. package/dist/src/plugins/stat.d.ts +13 -0
  116. package/dist/src/plugins/version-check.d.ts +2 -0
  117. package/dist/src/service.d.ts +19 -23
  118. package/dist/tests/e2e/comment-add.spec.d.ts +1 -0
  119. package/dist/types/config.d.ts +110 -0
  120. package/dist/types/context.d.ts +56 -136
  121. package/dist/types/data.d.ts +194 -0
  122. package/dist/types/editor.d.ts +76 -0
  123. package/dist/types/event.d.ts +36 -25
  124. package/dist/types/index.d.ts +7 -0
  125. package/dist/types/plugin.d.ts +2 -0
  126. package/dist/types/sidebar.d.ts +3 -0
  127. package/package.json +5 -2
  128. package/src/api/_base.ts +18 -0
  129. package/src/api/_options.ts +25 -0
  130. package/src/api/{request.ts → _request.ts} +19 -18
  131. package/src/api/admin.ts +1 -1
  132. package/src/api/captcha.ts +1 -1
  133. package/src/api/comment.ts +4 -4
  134. package/src/api/index.ts +3 -12
  135. package/src/api/page.ts +5 -5
  136. package/src/api/site.ts +2 -2
  137. package/src/api/system.ts +19 -7
  138. package/src/api/upload.ts +3 -3
  139. package/src/api/user.ts +3 -3
  140. package/src/artalk.ts +49 -97
  141. package/src/comment/actions.ts +1 -4
  142. package/src/comment/comment.ts +9 -6
  143. package/src/comment/render.ts +27 -5
  144. package/src/comment/renders/actions.ts +45 -45
  145. package/src/comment/renders/avatar.ts +7 -7
  146. package/src/comment/renders/content.ts +18 -18
  147. package/src/comment/renders/header.ts +13 -13
  148. package/src/comment/renders/index.ts +3 -3
  149. package/src/comment/renders/pending.ts +5 -5
  150. package/src/comment/renders/reply-at.ts +8 -8
  151. package/src/comment/renders/reply-to.ts +13 -13
  152. package/src/components/action-btn.ts +11 -13
  153. package/src/{lib → components}/checker/admin.ts +6 -6
  154. package/src/{lib → components}/checker/captcha-renders.ts +7 -6
  155. package/src/{lib → components}/checker/captcha.ts +1 -1
  156. package/src/{lib → components}/checker/index.ts +21 -26
  157. package/src/components/dark-mode.ts +30 -0
  158. package/src/components/dialog.ts +4 -9
  159. package/src/components/error-dialog.ts +35 -0
  160. package/src/components/pagination.ts +10 -6
  161. package/src/components/read-more-btn.ts +7 -7
  162. package/src/config.ts +60 -6
  163. package/src/context.ts +39 -144
  164. package/src/data.ts +110 -0
  165. package/src/defaults.ts +1 -1
  166. package/src/editor/editor.ts +39 -152
  167. package/src/editor/state.ts +52 -0
  168. package/src/i18n/zh-CN.ts +1 -1
  169. package/src/layer/index.ts +4 -4
  170. package/src/layer/layer-manager.ts +32 -0
  171. package/src/layer/layer.ts +20 -144
  172. package/src/layer/scrollbar-helper.ts +24 -0
  173. package/src/layer/sidebar-layer.ts +74 -64
  174. package/src/layer/wrap.ts +77 -0
  175. package/src/lib/component.ts +4 -11
  176. package/src/lib/detect.ts +1 -1
  177. package/src/lib/event-manager.ts +47 -0
  178. package/src/lib/highlight.ts +5 -0
  179. package/src/lib/marked-renderer.ts +32 -0
  180. package/src/lib/marked.ts +43 -104
  181. package/src/lib/sanitizer.ts +57 -0
  182. package/src/lib/ui.ts +22 -15
  183. package/src/lib/user.ts +21 -16
  184. package/src/lib/utils.ts +29 -18
  185. package/src/list/comment.ts +20 -0
  186. package/src/list/layout.ts +120 -0
  187. package/src/list/list.html +3 -1
  188. package/src/list/list.ts +56 -200
  189. package/src/list/{list-nest.ts → nest.ts} +1 -1
  190. package/src/list/page.ts +97 -0
  191. package/src/list/paginator/index.ts +20 -8
  192. package/src/list/paginator/read-more.ts +67 -0
  193. package/src/list/paginator/up-down.ts +51 -0
  194. package/src/main.ts +2 -0
  195. package/src/plugins/admin-only-elem.ts +40 -0
  196. package/src/plugins/conf-remoter.ts +54 -0
  197. package/src/plugins/dark-mode.ts +12 -0
  198. package/src/plugins/editor/_kit.ts +57 -0
  199. package/src/plugins/editor/_plug.ts +60 -0
  200. package/src/plugins/editor/_sample.ts +8 -0
  201. package/src/plugins/editor/closable.ts +44 -0
  202. package/src/{editor/plugs/emoticons-plug.ts → plugins/editor/emoticons.ts} +51 -52
  203. package/src/plugins/editor/header-event.ts +35 -0
  204. package/src/plugins/editor/header-link.ts +31 -0
  205. package/src/plugins/editor/header-user.ts +98 -0
  206. package/src/plugins/editor/index.ts +40 -0
  207. package/src/plugins/editor/local-storage.ts +36 -0
  208. package/src/plugins/editor/mover.ts +29 -0
  209. package/src/plugins/editor/preview.ts +41 -0
  210. package/src/plugins/editor/state-edit.ts +116 -0
  211. package/src/plugins/editor/state-reply.ts +91 -0
  212. package/src/plugins/editor/submit-add.ts +33 -0
  213. package/src/plugins/editor/submit-btn.ts +25 -0
  214. package/src/plugins/editor/submit.ts +73 -0
  215. package/src/plugins/editor/textarea.ts +55 -0
  216. package/src/plugins/editor/upload.ts +145 -0
  217. package/src/plugins/editor-kit.ts +161 -0
  218. package/src/plugins/index.ts +16 -0
  219. package/src/plugins/list/copyright.ts +16 -0
  220. package/src/plugins/list/count.ts +31 -0
  221. package/src/plugins/list/dropdown.ts +95 -0
  222. package/src/plugins/list/error-dialog.ts +22 -0
  223. package/src/plugins/list/fetch.ts +64 -0
  224. package/src/plugins/list/goto-first.ts +23 -0
  225. package/src/plugins/list/goto.ts +72 -0
  226. package/src/plugins/list/index.ts +25 -0
  227. package/src/plugins/list/loading.ts +17 -0
  228. package/src/plugins/list/no-comment.ts +25 -0
  229. package/src/plugins/list/reach-bottom.ts +46 -0
  230. package/src/plugins/list/sidebar-btn.ts +39 -0
  231. package/src/plugins/list/time-ticking.ts +22 -0
  232. package/src/plugins/list/unread-badge.ts +26 -0
  233. package/src/plugins/list/unread.ts +38 -0
  234. package/src/plugins/list/with-editor.ts +59 -0
  235. package/src/plugins/markdown.ts +10 -0
  236. package/src/plugins/stat.ts +79 -0
  237. package/src/plugins/version-check.ts +37 -0
  238. package/src/service.ts +34 -61
  239. package/src/style/comment.scss +5 -7
  240. package/src/style/editor.scss +5 -0
  241. package/src/style/list.scss +1 -1
  242. package/types/{artalk-config.d.ts → config.ts} +16 -2
  243. package/types/context.ts +84 -0
  244. package/types/{artalk-data.d.ts → data.ts} +41 -0
  245. package/types/editor.ts +95 -0
  246. package/types/event.ts +40 -0
  247. package/types/index.ts +7 -0
  248. package/types/plugin.ts +3 -0
  249. package/types/sidebar.ts +3 -0
  250. package/dist/src/comment/render-ctx.d.ts +0 -23
  251. package/dist/src/editor/edit-mode.d.ts +0 -9
  252. package/dist/src/editor/funcs.d.ts +0 -2
  253. package/dist/src/editor/index.d.ts +0 -2
  254. package/dist/src/editor/mover.d.ts +0 -8
  255. package/dist/src/editor/plug-manager.d.ts +0 -17
  256. package/dist/src/editor/plugs/editor-plug.d.ts +0 -38
  257. package/dist/src/editor/plugs/header-input-plug.d.ts +0 -13
  258. package/dist/src/editor/plugs/preview-plug.d.ts +0 -10
  259. package/dist/src/editor/plugs/upload-plug.d.ts +0 -10
  260. package/dist/src/editor/reply.d.ts +0 -9
  261. package/dist/src/editor/submit.d.ts +0 -16
  262. package/dist/src/lib/dark-mode.d.ts +0 -4
  263. package/dist/src/lib/stat.d.ts +0 -15
  264. package/dist/src/list/index.d.ts +0 -2
  265. package/dist/src/list/list-lite.d.ts +0 -77
  266. package/dist/src/list/list-ui.d.ts +0 -16
  267. package/dist/src/list/paginator/adaptors/index.d.ts +0 -12
  268. package/dist/src/list/paginator/adaptors/pagination.d.ts +0 -9
  269. package/dist/src/list/paginator/adaptors/read-more.d.ts +0 -10
  270. package/dist/src/list/paginator/holder.d.ts +0 -16
  271. package/dist/types/artalk-config.d.ts +0 -139
  272. package/dist/types/artalk-data.d.ts +0 -230
  273. package/dist/types/plug.d.ts +0 -4
  274. package/src/api/api-base.ts +0 -27
  275. package/src/comment/render-ctx.ts +0 -30
  276. package/src/editor/edit-mode.ts +0 -105
  277. package/src/editor/funcs.ts +0 -150
  278. package/src/editor/index.ts +0 -3
  279. package/src/editor/mover.ts +0 -43
  280. package/src/editor/plug-manager.ts +0 -172
  281. package/src/editor/plugs/editor-plug.ts +0 -69
  282. package/src/editor/plugs/header-input-plug.ts +0 -79
  283. package/src/editor/plugs/preview-plug.ts +0 -44
  284. package/src/editor/plugs/upload-plug.ts +0 -122
  285. package/src/editor/reply.ts +0 -62
  286. package/src/editor/submit.ts +0 -99
  287. package/src/lib/dark-mode.ts +0 -48
  288. package/src/lib/stat.ts +0 -71
  289. package/src/list/index.ts +0 -3
  290. package/src/list/list-lite.ts +0 -424
  291. package/src/list/list-ui.ts +0 -137
  292. package/src/list/paginator/adaptors/index.ts +0 -21
  293. package/src/list/paginator/adaptors/pagination.ts +0 -42
  294. package/src/list/paginator/adaptors/read-more.ts +0 -56
  295. package/src/list/paginator/holder.ts +0 -56
  296. package/types/context.d.ts +0 -142
  297. package/types/event.d.ts +0 -28
  298. package/types/plug.d.ts +0 -4
  299. /package/src/{editor/plugs/emoticons-plug.scss → plugins/editor/emoticons.scss} +0 -0
  300. /package/src/{editor/plugs/preview-plug.scss → plugins/editor/preview.scss} +0 -0
@@ -1,14 +1,10 @@
1
- import Context from '../../types/context';
2
- import Api from '.';
1
+ import { ApiOptions } from './_options';
3
2
  declare abstract class ApiBase {
4
- protected api: Api;
5
- protected ctx: Context;
6
- constructor(api: Api, ctx: Context);
3
+ protected options: ApiOptions;
4
+ constructor(options: ApiOptions);
7
5
  protected POST<T>(path: string, data?: {
8
6
  [key: string]: any;
9
7
  }): Promise<T>;
10
8
  protected Fetch(path: string, init: RequestInit, timeout?: number): Promise<any>;
11
9
  }
12
- interface ApiBase {
13
- }
14
10
  export default ApiBase;
@@ -0,0 +1,19 @@
1
+ export interface ApiOptions {
2
+ baseURL: string;
3
+ siteName: string;
4
+ pageKey: string;
5
+ pageTitle: string;
6
+ timeout?: number;
7
+ onNeedCheckCaptcha?: (payload: {
8
+ recall: () => void;
9
+ reject: () => void;
10
+ data: {
11
+ imgData: string;
12
+ iframe: string;
13
+ };
14
+ }) => void;
15
+ onNeedCheckAdmin?: (payload: {
16
+ recall: () => void;
17
+ reject: () => void;
18
+ }) => void;
19
+ }
@@ -1,8 +1,8 @@
1
- import Context from '../../types/context';
1
+ import { ApiOptions } from './_options';
2
2
  /** 公共请求函数 */
3
- export declare function Fetch(ctx: Context, input: RequestInfo, init: RequestInit, timeout?: number): Promise<any>;
3
+ export declare function Fetch(opts: ApiOptions, input: RequestInfo, init: RequestInit, timeout?: number): Promise<any>;
4
4
  /** 公共 POST 请求 */
5
- export declare function POST<T>(ctx: Context, url: string, data?: {
5
+ export declare function POST<T>(opts: ApiOptions, url: string, data?: {
6
6
  [key: string]: any;
7
7
  }): Promise<T>;
8
8
  /** 公共 GET 请求 (无 GET 方式 API) */
@@ -1,4 +1,4 @@
1
- import ApiBase from './api-base';
1
+ import ApiBase from './_base';
2
2
  /**
3
3
  * 管理员 API
4
4
  */
@@ -1,4 +1,4 @@
1
- import ApiBase from './api-base';
1
+ import ApiBase from './_base';
2
2
  /**
3
3
  * 验证码 API
4
4
  */
@@ -1,5 +1,5 @@
1
- import { CommentData, ListData } from '../../types/artalk-data';
2
- import ApiBase from './api-base';
1
+ import type { CommentData, ListData } from '../../types';
2
+ import ApiBase from './_base';
3
3
  /**
4
4
  * 评论 API
5
5
  */
@@ -1,4 +1,4 @@
1
- import Context from '../../types/context';
1
+ import { ApiOptions } from './_options';
2
2
  import comment from './comment';
3
3
  import page from './page';
4
4
  import site from './site';
@@ -18,9 +18,7 @@ declare const ApiComponents: {
18
18
  upload: typeof upload;
19
19
  };
20
20
  declare class Api {
21
- protected ctx: Context;
22
- get baseURL(): string;
23
- constructor(ctx: Context);
21
+ constructor(opts: ApiOptions);
24
22
  }
25
23
  type TC = typeof ApiComponents;
26
24
  type AC = {
@@ -1,5 +1,5 @@
1
- import { PageData, CommentData } from '../../types/artalk-data';
2
- import ApiBase from './api-base';
1
+ import type { PageData, CommentData } from '../../types';
2
+ import ApiBase from './_base';
3
3
  /**
4
4
  * 页面 API
5
5
  */
@@ -18,5 +18,5 @@ export default class PageApi extends ApiBase {
18
18
  /** PV */
19
19
  pv(): Promise<number>;
20
20
  /** 统计 */
21
- stat(type: 'latest_comments' | 'latest_pages' | 'pv_most_pages' | 'comment_most_pages' | 'page_pv' | 'site_pv' | 'page_comment' | 'site_comment', pageKeys?: string | string[], limit?: number): Promise<number | object | PageData[] | CommentData[]>;
21
+ stat(type: 'latest_comments' | 'latest_pages' | 'pv_most_pages' | 'comment_most_pages' | 'page_pv' | 'site_pv' | 'page_comment' | 'site_comment', pageKeys?: string | string[], limit?: number): Promise<number | object | CommentData[] | PageData[]>;
22
22
  }
@@ -1,5 +1,5 @@
1
- import { SiteData } from '../../types/artalk-data';
2
- import ApiBase from './api-base';
1
+ import type { SiteData } from '../../types';
2
+ import ApiBase from './_base';
3
3
  /**
4
4
  * 站点 API
5
5
  */
@@ -1,11 +1,20 @@
1
- import ArtalkConfig from '../../types/artalk-config';
2
- import ApiBase from './api-base';
1
+ import type { ArtalkConfig } from '../../types';
2
+ import ApiBase from './_base';
3
+ interface ApiVersionInfo {
4
+ app: string;
5
+ version: string;
6
+ commit_hash: string;
7
+ }
8
+ interface SystemConfResp {
9
+ frontend_conf: Partial<ArtalkConfig>;
10
+ version: ApiVersionInfo;
11
+ }
3
12
  /**
4
13
  * 系统 API
5
14
  */
6
15
  export default class SystemApi extends ApiBase {
7
16
  /** 获取配置 */
8
- conf(): Promise<Partial<ArtalkConfig>>;
17
+ conf(): Promise<SystemConfResp>;
9
18
  /** 获取配置数据 */
10
19
  getSettings(): Promise<{
11
20
  custom: string;
@@ -21,3 +30,4 @@ export default class SystemApi extends ApiBase {
21
30
  fe_min_version: string;
22
31
  }>;
23
32
  }
33
+ export {};
@@ -1,4 +1,4 @@
1
- import ApiBase from './api-base';
1
+ import ApiBase from './_base';
2
2
  /**
3
3
  * 上传 API
4
4
  */
@@ -1,5 +1,5 @@
1
- import { UserData, NotifyData, UserDataForAdmin } from '../../types/artalk-data';
2
- import ApiBase from './api-base';
1
+ import type { UserData, NotifyData, UserDataForAdmin } from '../../types';
2
+ import ApiBase from './_base';
3
3
  /**
4
4
  * 用户 API
5
5
  */
@@ -1,60 +1,37 @@
1
- import type ArtalkConfig from '../types/artalk-config';
2
- import type { EventPayloadMap, Handler } from '../types/event';
3
- import type ArtalkPlug from '../types/plug';
4
- import type Context from '../types/context';
5
- import ListLite from './list/list-lite';
1
+ import type { ArtalkConfig, EventPayloadMap, ArtalkPlugin, ContextApi } from '../types';
2
+ import type { EventHandler } from './lib/event-manager';
6
3
  /**
7
4
  * Artalk
8
5
  *
9
6
  * @see https://artalk.js.org
10
7
  */
11
8
  export default class Artalk {
12
- private static instance?;
13
- static ListLite: typeof ListLite;
14
- static readonly defaults: ArtalkConfig;
15
9
  conf: ArtalkConfig;
16
- ctx: Context;
10
+ ctx: ContextApi;
17
11
  $root: HTMLElement;
18
12
  /** Plugins */
19
- protected static plugins: ArtalkPlug[];
20
- static DisabledComponents: string[];
13
+ protected plugins: ArtalkPlugin[];
21
14
  constructor(conf: Partial<ArtalkConfig>);
22
- /** Init Artalk */
23
- static init(conf: Partial<ArtalkConfig>): Artalk;
24
- /** Use Plugin (plugin will be called in instance `use` func) */
25
- use(plugin: ArtalkPlug): void;
26
15
  /** Update config of Artalk */
27
- update(conf: Partial<ArtalkConfig>): Artalk;
16
+ update(conf: Partial<ArtalkConfig>): this;
28
17
  /** Reload comment list of Artalk */
29
18
  reload(): void;
30
19
  /** Destroy instance of Artalk */
31
20
  destroy(): void;
32
21
  /** Add an event listener */
33
- on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
22
+ on<K extends keyof EventPayloadMap>(name: K, handler: EventHandler<EventPayloadMap[K]>): void;
34
23
  /** Remove an event listener */
35
- off<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
24
+ off<K extends keyof EventPayloadMap>(name: K, handler: EventHandler<EventPayloadMap[K]>): void;
36
25
  /** Trigger an event */
37
26
  trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K]): void;
38
27
  /** Set dark mode */
39
28
  setDarkMode(darkMode: boolean): void;
40
- /** Use Plugin (static method) */
41
- static use(plugin: ArtalkPlug): void;
42
- /** Update config of Artalk */
43
- static update(conf: Partial<ArtalkConfig>): Artalk | undefined;
44
- /** Reload comment list of Artalk */
45
- static reload(): void;
46
- /** Destroy instance of Artalk */
47
- static destroy(): void;
48
- /** Add an event listener */
49
- static on<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
50
- /** Remove an event listener */
51
- static off<K extends keyof EventPayloadMap>(name: K, handler: Handler<EventPayloadMap[K]>): void;
52
- /** Trigger an event */
53
- static trigger<K extends keyof EventPayloadMap>(name: K, payload?: EventPayloadMap[K]): void;
54
- /** Set dark mode */
55
- static setDarkMode(darkMode: boolean): void;
29
+ /** Default Configs */
30
+ static readonly defaults: ArtalkConfig;
31
+ /** Init Artalk */
32
+ static init(conf: Partial<ArtalkConfig>): Artalk;
33
+ /** Use plugin, the plugin will be used when Artalk.init */
34
+ static use(plugin: ArtalkPlugin): void;
56
35
  /** Load count widget */
57
- static loadCountWidget(conf: Partial<ArtalkConfig>): void;
58
- /** @deprecated Please use `loadCountWidget` instead */
59
- static LoadCountWidget(conf: Partial<ArtalkConfig>): void;
36
+ static loadCountWidget(c: Partial<ArtalkConfig>): void;
60
37
  }
@@ -1,4 +1,4 @@
1
- import Comment from './comment';
1
+ import type Comment from './comment';
2
2
  import ActionBtn from '../components/action-btn';
3
3
  export default class CommentActions {
4
4
  private comment;
@@ -1,5 +1,4 @@
1
- import { CommentData } from '../../types/artalk-data';
2
- import Context from '../../types/context';
1
+ import type { CommentData, ContextApi } from '../../types';
3
2
  import Component from '../lib/component';
4
3
  import CommentUI from './render';
5
4
  import CommentActions from './actions';
@@ -22,7 +21,7 @@ export default class Comment extends Component {
22
21
  private children;
23
22
  private nestCurt;
24
23
  private nestMax;
25
- constructor(ctx: Context, data: CommentData, conf: CommentConf);
24
+ constructor(ctx: ContextApi, data: CommentData, conf: CommentConf);
26
25
  /** 渲染 UI */
27
26
  render(): void;
28
27
  /** 获取评论操作实例对象 */
@@ -56,7 +55,7 @@ export default class Comment extends Component {
56
55
  /** 获取评论 markdown 解析后的内容 */
57
56
  getContentMarked(): string;
58
57
  /** 获取格式化后的日期 */
59
- getDateFormatted(): string;
58
+ getDateFormatted(): any;
60
59
  /** 获取用户 UserAgent 信息 */
61
60
  getUserUA(): {
62
61
  browser: string;
@@ -1,6 +1,24 @@
1
- import Comment from './comment';
2
- import RenderCtx from './render-ctx';
3
- export default class CommentRender extends RenderCtx {
1
+ import type Comment from './comment';
2
+ import ActionBtn from '../components/action-btn';
3
+ export default class Render {
4
+ comment: Comment;
5
+ get ctx(): import("../../types").ContextApi;
6
+ get data(): import("../../types").CommentData;
7
+ get conf(): import("../../types").ArtalkConfig;
8
+ get cConf(): import("./comment").CommentConf;
9
+ $el: HTMLElement;
10
+ $main: HTMLElement;
11
+ $header: HTMLElement;
12
+ $headerNick: HTMLElement;
13
+ $headerBadgeWrap: HTMLElement;
14
+ $body: HTMLElement;
15
+ $content: HTMLElement;
16
+ $childrenWrap: HTMLElement | null;
17
+ $actions: HTMLElement;
18
+ voteBtnUp?: ActionBtn;
19
+ voteBtnDown?: ActionBtn;
20
+ $replyTo?: HTMLElement;
21
+ $replyAt?: HTMLElement;
4
22
  constructor(comment: Comment);
5
23
  render(): HTMLElement;
6
24
  /** 内容限高检测 */
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 评论操作按钮界面
4
4
  */
5
- export default function renderActions(ctx: RenderCtx): void;
5
+ export default function renderActions(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 评论头像界面
4
4
  */
5
- export default function renderAvatar(ctx: RenderCtx): void;
5
+ export default function renderAvatar(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 评论内容界面
4
4
  */
5
- export default function renderContent(ctx: RenderCtx): void;
5
+ export default function renderContent(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 评论头部界面
4
4
  */
5
- export default function renderHeader(ctx: RenderCtx): void;
5
+ export default function renderHeader(r: Render): void;
@@ -1,2 +1,2 @@
1
- import RenderCtx from '../render-ctx';
2
- export default function loadRenders(ctx: RenderCtx): void;
1
+ import type Render from '../render';
2
+ export default function loadRenders(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 待审核状态界面
4
4
  */
5
- export default function renderPending(ctx: RenderCtx): void;
5
+ export default function renderPending(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 层级嵌套模式显示 AT 界面
4
4
  */
5
- export default function renderReplyAt(ctx: RenderCtx): void;
5
+ export default function renderReplyAt(r: Render): void;
@@ -1,5 +1,5 @@
1
- import RenderCtx from '../render-ctx';
1
+ import type Render from '../render';
2
2
  /**
3
3
  * 回复的对象界面
4
4
  */
5
- export default function renderReplyTo(ctx: RenderCtx): void;
5
+ export default function renderReplyTo(r: Render): void;
@@ -1,5 +1,4 @@
1
- import Context from '../../types/context';
2
- interface ActionBtnConf {
1
+ interface ActionBtnOptions {
3
2
  /** 按钮文字 (动态/静态) */
4
3
  text: (() => string) | string;
5
4
  /** 仅管理员可用 */
@@ -13,8 +12,7 @@ interface ActionBtnConf {
13
12
  * 通用操作按钮
14
13
  */
15
14
  export default class ActionBtn {
16
- private ctx;
17
- private conf;
15
+ private opts;
18
16
  $el: HTMLElement;
19
17
  isLoading: boolean;
20
18
  msgRecTimer?: number;
@@ -23,7 +21,7 @@ export default class ActionBtn {
23
21
  isConfirming: boolean;
24
22
  confirmRecTimer?: number;
25
23
  /** 构造函数 */
26
- constructor(ctx: Context, conf: ActionBtnConf | string | (() => string));
24
+ constructor(opts: ActionBtnOptions | string | (() => string));
27
25
  /** 将按钮装载到指定元素 */
28
26
  appendTo(dom: HTMLElement): this;
29
27
  /** 获取按钮文字(动态/静态) */
@@ -1,3 +1,3 @@
1
- import { Checker } from '.';
1
+ import type { Checker } from '.';
2
2
  declare const AdminChecker: Checker;
3
3
  export default AdminChecker;
@@ -1,4 +1,4 @@
1
- import { CheckerCtx } from '.';
1
+ import type { CheckerCtx } from '.';
2
2
  /** 图片验证码 */
3
3
  export declare function imgBody(checker: CheckerCtx): HTMLElement;
4
4
  /** iframe 形式的通用验证服务 */
@@ -1,3 +1,3 @@
1
- import { Checker } from '.';
1
+ import type { Checker } from '.';
2
2
  declare const CaptchaChecker: Checker;
3
3
  export default CaptchaChecker;
@@ -1,6 +1,5 @@
1
- import Context from '../../../types/context';
2
- import Layer from '../../layer';
3
1
  import type Api from '../../api';
2
+ import type { ContextApi } from '../../../types';
4
3
  export interface CheckerCaptchaPayload extends CheckerPayload {
5
4
  imgData?: string;
6
5
  iframe?: string;
@@ -10,13 +9,18 @@ export interface CheckerPayload {
10
9
  onMount?: (dialogEl: HTMLElement) => void;
11
10
  onCancel?: () => void;
12
11
  }
12
+ export interface CheckerLauncherOptions {
13
+ getCtx: () => ContextApi;
14
+ getApi: () => Api;
15
+ getIframeURLBase: () => string;
16
+ onReload: () => void;
17
+ }
13
18
  /**
14
19
  * Checker 发射台
15
20
  */
16
21
  export default class CheckerLauncher {
17
- ctx: Context;
18
- launched: Checker[];
19
- constructor(ctx: Context);
22
+ private opts;
23
+ constructor(opts: CheckerLauncherOptions);
20
24
  checkCaptcha(payload: CheckerCaptchaPayload): void;
21
25
  checkAdmin(payload: CheckerPayload): void;
22
26
  fire(checker: Checker, payload: CheckerPayload, postFire?: (c: CheckerCtx) => void): void;
@@ -38,9 +42,8 @@ interface CheckerStore {
38
42
  export interface CheckerCtx {
39
43
  get<K extends keyof CheckerStore>(key: K): CheckerStore[K];
40
44
  set<K extends keyof CheckerStore>(key: K, val: CheckerStore[K]): void;
41
- getCtx(): Context;
45
+ getOpts(): CheckerLauncherOptions;
42
46
  getApi(): Api;
43
- getLayer(): Layer;
44
47
  hideInteractInput(): void;
45
48
  triggerSuccess(): void;
46
49
  cancel(): void;
@@ -0,0 +1,2 @@
1
+ export declare function applyDarkMode($els: HTMLElement[], darkMode: boolean | 'auto'): void;
2
+ export declare const DarkModeClassName = "atk-dark-mode";
@@ -1,14 +1,12 @@
1
- import Context from '../../types/context';
2
1
  type BtnClickHandler = (btnEl: HTMLElement, dialog: Dialog) => boolean | void;
3
2
  /**
4
3
  * 对话框
5
4
  */
6
5
  export default class Dialog {
7
- ctx: Context;
8
6
  $el: HTMLElement;
9
7
  $content: HTMLElement;
10
8
  $actions: HTMLElement;
11
- constructor(ctx: Context, contentEl: HTMLElement);
9
+ constructor(contentEl: HTMLElement);
12
10
  /** 按钮 · 确定 */
13
11
  setYes(handler: BtnClickHandler): this;
14
12
  /** 按钮 · 取消 */
@@ -0,0 +1,8 @@
1
+ export interface ErrorDialogOptions {
2
+ $err: HTMLElement;
3
+ errMsg: string;
4
+ errData?: any;
5
+ retryFn?: () => void;
6
+ onOpenSidebar?: () => void;
7
+ }
8
+ export declare function showErrorDialog(opts: ErrorDialogOptions): void;
@@ -1,11 +1,11 @@
1
- export interface PaginationConf {
1
+ export interface PaginationOptions {
2
2
  /** 每页条数 */
3
3
  pageSize: number;
4
4
  /** 回调函数 */
5
5
  onChange: (offset: number) => void;
6
6
  }
7
7
  export default class Pagination {
8
- private conf;
8
+ private opts;
9
9
  total: number;
10
10
  $el: HTMLElement;
11
11
  $input: HTMLInputElement;
@@ -16,12 +16,13 @@ export default class Pagination {
16
16
  get pageSize(): number;
17
17
  get offset(): number;
18
18
  get maxPage(): number;
19
- constructor(total: number, conf: PaginationConf);
19
+ constructor(total: number, opts: PaginationOptions);
20
20
  update(offset: number, total: number): void;
21
21
  setInput(page: number): void;
22
22
  input(now?: boolean): void;
23
23
  prev(): void;
24
24
  next(): void;
25
+ getHasMore(): boolean;
25
26
  change(page: number): void;
26
27
  checkDisabled(): void;
27
28
  keydown(e: KeyboardEvent): void;
@@ -1,4 +1,4 @@
1
- export interface ReadMoreBtnConf {
1
+ export interface ReadMoreBtnOptions {
2
2
  /** 回调函数 */
3
3
  onClick: (offset: number) => void;
4
4
  pageSize: number;
@@ -8,7 +8,7 @@ export interface ReadMoreBtnConf {
8
8
  * 阅读更多按钮
9
9
  */
10
10
  export default class ReadMoreBtn {
11
- conf: ReadMoreBtnConf;
11
+ opts: ReadMoreBtnOptions;
12
12
  $el: HTMLElement;
13
13
  private $loading;
14
14
  private $text;
@@ -17,7 +17,7 @@ export default class ReadMoreBtn {
17
17
  private origText;
18
18
  /** 是否有更多内容 */
19
19
  get hasMore(): boolean;
20
- constructor(conf: ReadMoreBtnConf);
20
+ constructor(opts: ReadMoreBtnOptions);
21
21
  click(): void;
22
22
  /** 显示 */
23
23
  show(): void;
@@ -1,8 +1,24 @@
1
- import type ArtalkConfig from '../types/artalk-config';
2
- declare const _default: {
3
- handelBaseConf: typeof handelBaseConf;
4
- };
5
- export default _default;
6
- /** 基本配置初始化 */
7
- export declare function handelBaseConf(customConf: Partial<ArtalkConfig>): ArtalkConfig;
8
- export declare function handleBackendRefConf(conf: Partial<ArtalkConfig>): Partial<ArtalkConfig>;
1
+ import type { ArtalkConfig, ContextApi } from '../types';
2
+ import type { ApiOptions } from './api/_options';
3
+ /**
4
+ * Merges the user custom config with the default config
5
+ *
6
+ * @param customConf - The custom config object which is provided by the user
7
+ * @returns The config for Artalk instance creation
8
+ */
9
+ export declare function handelCustomConf(customConf: Partial<ArtalkConfig>): ArtalkConfig;
10
+ /**
11
+ * Handle the config which is provided by the server
12
+ *
13
+ * @param conf - The Server response config for control the frontend of Artalk remotely
14
+ * @returns The config for Artalk instance creation
15
+ */
16
+ export declare function handleConfFormServer(conf: Partial<ArtalkConfig>): Partial<ArtalkConfig>;
17
+ /**
18
+ * Convert Artalk Config to ApiOptions for Api client
19
+ *
20
+ * @param conf - Artalk config
21
+ * @param ctx - If `ctx` not provided, `checkAdmin` and `checkCaptcha` will be disabled
22
+ * @returns ApiOptions for Api client instance creation
23
+ */
24
+ export declare function convertApiOptions(conf: Partial<ArtalkConfig>, ctx?: ContextApi): ApiOptions;