@basicbenframework/cms 0.0.0-stage → 0.6.1

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 (590) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +206 -2
  3. package/db/migrations/001_create_users.js +15 -0
  4. package/db/migrations/002_create_posts.js +18 -0
  5. package/db/migrations/003_create_categories.js +19 -0
  6. package/db/migrations/004_create_tags.js +16 -0
  7. package/db/migrations/005_create_post_tags.js +16 -0
  8. package/db/migrations/006_create_pages.js +26 -0
  9. package/db/migrations/007_create_comments.js +24 -0
  10. package/db/migrations/008_create_media.js +22 -0
  11. package/db/migrations/009_update_posts_blogging.js +27 -0
  12. package/db/migrations/010_create_settings.js +29 -0
  13. package/db/migrations/011_add_user_roles.js +23 -0
  14. package/db/migrations/012_create_auth_tokens.js +30 -0
  15. package/db/migrations/013_add_email_verified.js +24 -0
  16. package/db/migrations/014_create_user_two_factor.js +30 -0
  17. package/db/migrations/015_create_user_credentials.js +35 -0
  18. package/db/migrations/016_create_rate_limits.js +31 -0
  19. package/db/migrations/017_add_content_html.js +38 -0
  20. package/db/migrations/018_create_api_tokens.js +34 -0
  21. package/db/migrations/019_create_post_categories.js +40 -0
  22. package/db/migrations/020_add_author_profiles.js +60 -0
  23. package/db/migrations/021_add_page_featured_image.js +23 -0
  24. package/db/migrations/022_backfill_post_slugs_and_excerpts.js +57 -0
  25. package/db/migrations/023_add_user_session_controls.js +25 -0
  26. package/db/migrations/024_add_post_status_and_trash.js +45 -0
  27. package/db/migrations/025_add_social_and_indexing_fields.js +40 -0
  28. package/db/migrations/026_create_post_revisions.js +29 -0
  29. package/db/migrations/027_add_media_dimensions.js +19 -0
  30. package/db/migrations/028_create_navigation_menus.js +65 -0
  31. package/db/migrations/029_create_redirects.js +40 -0
  32. package/db/migrations/030_add_comment_status_and_notifications.js +53 -0
  33. package/db/migrations/031_create_post_locks.js +38 -0
  34. package/db/migrations/032_create_snippets.js +31 -0
  35. package/db/migrations/033_create_members.js +70 -0
  36. package/db/migrations/034_add_post_visibility.js +28 -0
  37. package/db/migrations/035_create_newsletters.js +72 -0
  38. package/db/migrations/036_create_analytics.js +89 -0
  39. package/db/migrations/037_create_ops_heartbeats.js +30 -0
  40. package/db/migrations/038_create_content_types.js +84 -0
  41. package/db/migrations/039_create_content_type_fields.js +47 -0
  42. package/db/migrations/040_create_taxonomies.js +80 -0
  43. package/db/migrations/041_add_newsletter_handoff.js +28 -0
  44. package/db/migrations/042_create_mysendbox_contacts.js +63 -0
  45. package/lib/cli/backup.d.mts +2 -0
  46. package/lib/cli/backup.mjs +124 -0
  47. package/lib/cli/export.d.mts +2 -0
  48. package/lib/cli/export.mjs +54 -0
  49. package/lib/cli/import-ghost.d.mts +2 -0
  50. package/lib/cli/import-ghost.mjs +50 -0
  51. package/lib/cli/import-json.d.mts +2 -0
  52. package/lib/cli/import-json.mjs +61 -0
  53. package/lib/cli/import-wordpress.d.mts +2 -0
  54. package/lib/cli/import-wordpress.mjs +169 -0
  55. package/lib/cli/import-wxr.d.mts +2 -0
  56. package/lib/cli/import-wxr.mjs +55 -0
  57. package/lib/cli/index.d.mts +2 -0
  58. package/lib/cli/index.mjs +53 -0
  59. package/lib/cli/lib/backup.d.mts +112 -0
  60. package/lib/cli/lib/backup.mjs +297 -0
  61. package/lib/cli/lib/ghost.d.mts +30 -0
  62. package/lib/cli/lib/ghost.mjs +201 -0
  63. package/lib/cli/lib/html-to-markdown.d.mts +61 -0
  64. package/lib/cli/lib/html-to-markdown.mjs +523 -0
  65. package/lib/cli/lib/import-common.d.mts +100 -0
  66. package/lib/cli/lib/import-common.mjs +252 -0
  67. package/lib/cli/lib/json-import.d.mts +22 -0
  68. package/lib/cli/lib/json-import.mjs +422 -0
  69. package/lib/cli/lib/site-import.d.mts +32 -0
  70. package/lib/cli/lib/site-import.mjs +456 -0
  71. package/lib/cli/lib/wordpress-rest.d.mts +25 -0
  72. package/lib/cli/lib/wordpress-rest.mjs +177 -0
  73. package/lib/cli/lib/wxr.d.mts +18 -0
  74. package/lib/cli/lib/wxr.mjs +307 -0
  75. package/lib/cli/lib/xml.d.mts +33 -0
  76. package/lib/cli/lib/xml.mjs +186 -0
  77. package/lib/cli/restore.d.mts +2 -0
  78. package/lib/cli/restore.mjs +98 -0
  79. package/lib/client/components/Alert.d.ts +7 -0
  80. package/lib/client/components/Alert.js +8 -0
  81. package/lib/client/components/Avatar.d.ts +15 -0
  82. package/lib/client/components/Avatar.js +10 -0
  83. package/lib/client/components/BackLink.d.ts +7 -0
  84. package/lib/client/components/BackLink.js +6 -0
  85. package/lib/client/components/Button.d.ts +7 -0
  86. package/lib/client/components/Button.js +12 -0
  87. package/lib/client/components/Card.d.ts +7 -0
  88. package/lib/client/components/Card.js +6 -0
  89. package/lib/client/components/CommentThread.d.ts +15 -0
  90. package/lib/client/components/CommentThread.js +101 -0
  91. package/lib/client/components/Empty.d.ts +6 -0
  92. package/lib/client/components/Empty.js +6 -0
  93. package/lib/client/components/Input.d.ts +6 -0
  94. package/lib/client/components/Input.js +6 -0
  95. package/lib/client/components/Link.d.ts +31 -0
  96. package/lib/client/components/Link.js +49 -0
  97. package/lib/client/components/Loading.d.ts +1 -0
  98. package/lib/client/components/Loading.js +6 -0
  99. package/lib/client/components/Logo.d.ts +5 -0
  100. package/lib/client/components/Logo.js +4 -0
  101. package/lib/client/components/MarkdownEditor.d.ts +41 -0
  102. package/lib/client/components/MarkdownEditor.js +156 -0
  103. package/lib/client/components/Nav/DarkModeToggle.d.ts +6 -0
  104. package/lib/client/components/Nav/DarkModeToggle.js +6 -0
  105. package/lib/client/components/Nav/DesktopNav.d.ts +8 -0
  106. package/lib/client/components/Nav/DesktopNav.js +9 -0
  107. package/lib/client/components/Nav/MobileNav.d.ts +9 -0
  108. package/lib/client/components/Nav/MobileNav.js +15 -0
  109. package/lib/client/components/NavLink.d.ts +8 -0
  110. package/lib/client/components/NavLink.js +6 -0
  111. package/lib/client/components/PageHeader.d.ts +8 -0
  112. package/lib/client/components/PageHeader.js +6 -0
  113. package/lib/client/components/PostCard.d.ts +8 -0
  114. package/lib/client/components/PostCard.js +7 -0
  115. package/lib/client/components/Textarea.d.ts +6 -0
  116. package/lib/client/components/Textarea.js +6 -0
  117. package/lib/client/components/ThemeContext.d.ts +18 -0
  118. package/lib/client/components/ThemeContext.js +8 -0
  119. package/lib/client/components/admin/AdminIcons.d.ts +13 -0
  120. package/lib/client/components/admin/AdminIcons.js +66 -0
  121. package/lib/client/components/admin/ContentModelPanels.d.ts +22 -0
  122. package/lib/client/components/admin/ContentModelPanels.js +93 -0
  123. package/lib/client/components/admin/FeaturedImageBox.d.ts +21 -0
  124. package/lib/client/components/admin/FeaturedImageBox.js +24 -0
  125. package/lib/client/components/admin/MediaGrid.d.ts +23 -0
  126. package/lib/client/components/admin/MediaGrid.js +69 -0
  127. package/lib/client/components/admin/MediaPicker.d.ts +17 -0
  128. package/lib/client/components/admin/MediaPicker.js +61 -0
  129. package/lib/client/components/admin/Pagination.d.ts +27 -0
  130. package/lib/client/components/admin/Pagination.js +29 -0
  131. package/lib/client/components/admin/SnippetPicker.d.ts +27 -0
  132. package/lib/client/components/admin/SnippetPicker.js +65 -0
  133. package/lib/client/components/admin/TermPicker.d.ts +52 -0
  134. package/lib/client/components/admin/TermPicker.js +58 -0
  135. package/lib/client/contexts/ToastContext.d.ts +12 -0
  136. package/lib/client/contexts/ToastContext.js +49 -0
  137. package/lib/client/features.d.ts +11 -0
  138. package/lib/client/features.js +7 -0
  139. package/lib/client/hooks/useContentTypes.d.ts +48 -0
  140. package/lib/client/hooks/useContentTypes.js +48 -0
  141. package/lib/client/hooks/useMediaLibrary.d.ts +46 -0
  142. package/lib/client/hooks/useMediaLibrary.js +189 -0
  143. package/lib/client/hooks/usePostLock.d.ts +32 -0
  144. package/lib/client/hooks/usePostLock.js +107 -0
  145. package/lib/client/host/index.d.ts +71 -0
  146. package/lib/client/host/index.js +58 -0
  147. package/lib/client/i18n/index.d.ts +79 -0
  148. package/lib/client/i18n/index.js +177 -0
  149. package/lib/client/i18n/locales/es/content.d.ts +4 -0
  150. package/lib/client/i18n/locales/es/content.js +220 -0
  151. package/lib/client/i18n/locales/es/editor.d.ts +9 -0
  152. package/lib/client/i18n/locales/es/editor.js +144 -0
  153. package/lib/client/i18n/locales/es/index.d.ts +8 -0
  154. package/lib/client/i18n/locales/es/index.js +7 -0
  155. package/lib/client/i18n/locales/es/layout.d.ts +4 -0
  156. package/lib/client/i18n/locales/es/layout.js +35 -0
  157. package/lib/client/i18n/locales/es/people.d.ts +4 -0
  158. package/lib/client/i18n/locales/es/people.js +187 -0
  159. package/lib/client/i18n/locales/es/site.d.ts +4 -0
  160. package/lib/client/i18n/locales/es/site.js +208 -0
  161. package/lib/client/layouts/AdminLayout.d.ts +7 -0
  162. package/lib/client/layouts/AdminLayout.js +1046 -0
  163. package/lib/client/layouts/AppLayout.d.ts +6 -0
  164. package/lib/client/layouts/AppLayout.js +19 -0
  165. package/lib/client/layouts/AuthLayout.d.ts +6 -0
  166. package/lib/client/layouts/AuthLayout.js +14 -0
  167. package/lib/client/layouts/DocsLayout.d.ts +6 -0
  168. package/lib/client/layouts/DocsLayout.js +28 -0
  169. package/lib/client/layouts/RootLayout.d.ts +6 -0
  170. package/lib/client/layouts/RootLayout.js +11 -0
  171. package/lib/client/pages/AcceptInvite.d.ts +8 -0
  172. package/lib/client/pages/AcceptInvite.js +60 -0
  173. package/lib/client/pages/Auth.d.ts +1 -0
  174. package/lib/client/pages/Auth.js +40 -0
  175. package/lib/client/pages/Authentication.d.ts +1 -0
  176. package/lib/client/pages/Authentication.js +230 -0
  177. package/lib/client/pages/Content.d.ts +1 -0
  178. package/lib/client/pages/Content.js +21 -0
  179. package/lib/client/pages/Database.d.ts +1 -0
  180. package/lib/client/pages/Database.js +264 -0
  181. package/lib/client/pages/Extending.d.ts +1 -0
  182. package/lib/client/pages/Extending.js +28 -0
  183. package/lib/client/pages/Feed.d.ts +1 -0
  184. package/lib/client/pages/Feed.js +19 -0
  185. package/lib/client/pages/FeedPost.d.ts +1 -0
  186. package/lib/client/pages/FeedPost.js +31 -0
  187. package/lib/client/pages/ForgotPassword.d.ts +8 -0
  188. package/lib/client/pages/ForgotPassword.js +38 -0
  189. package/lib/client/pages/GettingStarted.d.ts +1 -0
  190. package/lib/client/pages/GettingStarted.js +84 -0
  191. package/lib/client/pages/Headless.d.ts +1 -0
  192. package/lib/client/pages/Headless.js +49 -0
  193. package/lib/client/pages/Home.d.ts +1 -0
  194. package/lib/client/pages/Home.js +67 -0
  195. package/lib/client/pages/PostForm.d.ts +1 -0
  196. package/lib/client/pages/PostForm.js +55 -0
  197. package/lib/client/pages/Posts.d.ts +1 -0
  198. package/lib/client/pages/Posts.js +35 -0
  199. package/lib/client/pages/Profile.d.ts +1 -0
  200. package/lib/client/pages/Profile.js +153 -0
  201. package/lib/client/pages/ResetPassword.d.ts +8 -0
  202. package/lib/client/pages/ResetPassword.js +52 -0
  203. package/lib/client/pages/Routing.d.ts +1 -0
  204. package/lib/client/pages/Routing.js +192 -0
  205. package/lib/client/pages/Storage.d.ts +1 -0
  206. package/lib/client/pages/Storage.js +54 -0
  207. package/lib/client/pages/Testing.d.ts +1 -0
  208. package/lib/client/pages/Testing.js +141 -0
  209. package/lib/client/pages/Validation.d.ts +1 -0
  210. package/lib/client/pages/Validation.js +123 -0
  211. package/lib/client/pages/admin/Categories.d.ts +2 -0
  212. package/lib/client/pages/admin/Categories.js +75 -0
  213. package/lib/client/pages/admin/Comments.d.ts +11 -0
  214. package/lib/client/pages/admin/Comments.js +247 -0
  215. package/lib/client/pages/admin/ContentTypes.d.ts +2 -0
  216. package/lib/client/pages/admin/ContentTypes.js +163 -0
  217. package/lib/client/pages/admin/Dashboard.d.ts +2 -0
  218. package/lib/client/pages/admin/Dashboard.js +66 -0
  219. package/lib/client/pages/admin/Health.d.ts +12 -0
  220. package/lib/client/pages/admin/Health.js +148 -0
  221. package/lib/client/pages/admin/Media.d.ts +2 -0
  222. package/lib/client/pages/admin/Media.js +101 -0
  223. package/lib/client/pages/admin/Navigation.d.ts +9 -0
  224. package/lib/client/pages/admin/Navigation.js +230 -0
  225. package/lib/client/pages/admin/Pages.d.ts +2 -0
  226. package/lib/client/pages/admin/Pages.js +53 -0
  227. package/lib/client/pages/admin/PostEditor.d.ts +17 -0
  228. package/lib/client/pages/admin/PostEditor.js +532 -0
  229. package/lib/client/pages/admin/Posts.d.ts +2 -0
  230. package/lib/client/pages/admin/Posts.js +152 -0
  231. package/lib/client/pages/admin/Redirects.d.ts +10 -0
  232. package/lib/client/pages/admin/Redirects.js +87 -0
  233. package/lib/client/pages/admin/Settings.d.ts +2 -0
  234. package/lib/client/pages/admin/Settings.js +111 -0
  235. package/lib/client/pages/admin/Snippets.d.ts +14 -0
  236. package/lib/client/pages/admin/Snippets.js +85 -0
  237. package/lib/client/pages/admin/Tags.d.ts +2 -0
  238. package/lib/client/pages/admin/Tags.js +74 -0
  239. package/lib/client/pages/admin/Taxonomies.d.ts +2 -0
  240. package/lib/client/pages/admin/Taxonomies.js +130 -0
  241. package/lib/client/pages/admin/Tokens.d.ts +9 -0
  242. package/lib/client/pages/admin/Tokens.js +260 -0
  243. package/lib/client/pages/admin/Tools.d.ts +12 -0
  244. package/lib/client/pages/admin/Tools.js +111 -0
  245. package/lib/client/pages/admin/Users.d.ts +13 -0
  246. package/lib/client/pages/admin/Users.js +313 -0
  247. package/lib/client/pages/api-reference.d.ts +33 -0
  248. package/lib/client/pages/api-reference.js +198 -0
  249. package/lib/client/styles.css +37 -0
  250. package/lib/config.d.ts +24 -0
  251. package/lib/config.js +39 -0
  252. package/lib/controllers/AdminController.d.ts +46 -0
  253. package/lib/controllers/AdminController.js +134 -0
  254. package/lib/controllers/AuthController.d.ts +15 -0
  255. package/lib/controllers/AuthController.js +194 -0
  256. package/lib/controllers/AuthorController.d.ts +17 -0
  257. package/lib/controllers/AuthorController.js +19 -0
  258. package/lib/controllers/CategoryController.d.ts +10 -0
  259. package/lib/controllers/CategoryController.js +88 -0
  260. package/lib/controllers/CommentController.d.ts +68 -0
  261. package/lib/controllers/CommentController.js +438 -0
  262. package/lib/controllers/ContentTypeController.d.ts +24 -0
  263. package/lib/controllers/ContentTypeController.js +91 -0
  264. package/lib/controllers/EmailVerificationController.d.ts +33 -0
  265. package/lib/controllers/EmailVerificationController.js +116 -0
  266. package/lib/controllers/ExportController.d.ts +15 -0
  267. package/lib/controllers/ExportController.js +41 -0
  268. package/lib/controllers/FeedController.d.ts +14 -0
  269. package/lib/controllers/FeedController.js +246 -0
  270. package/lib/controllers/HealthController.d.ts +21 -0
  271. package/lib/controllers/HealthController.js +176 -0
  272. package/lib/controllers/HomeController.d.ts +12 -0
  273. package/lib/controllers/HomeController.js +16 -0
  274. package/lib/controllers/MediaController.d.ts +24 -0
  275. package/lib/controllers/MediaController.js +189 -0
  276. package/lib/controllers/NavigationController.d.ts +22 -0
  277. package/lib/controllers/NavigationController.js +176 -0
  278. package/lib/controllers/PageController.d.ts +13 -0
  279. package/lib/controllers/PageController.js +172 -0
  280. package/lib/controllers/PasskeyController.d.ts +36 -0
  281. package/lib/controllers/PasskeyController.js +201 -0
  282. package/lib/controllers/PasswordResetController.d.ts +44 -0
  283. package/lib/controllers/PasswordResetController.js +160 -0
  284. package/lib/controllers/PostController.d.ts +51 -0
  285. package/lib/controllers/PostController.js +538 -0
  286. package/lib/controllers/PostLockController.d.ts +62 -0
  287. package/lib/controllers/PostLockController.js +101 -0
  288. package/lib/controllers/ProfileController.d.ts +13 -0
  289. package/lib/controllers/ProfileController.js +160 -0
  290. package/lib/controllers/PublicApiController.d.ts +23 -0
  291. package/lib/controllers/PublicApiController.js +100 -0
  292. package/lib/controllers/RedirectController.d.ts +32 -0
  293. package/lib/controllers/RedirectController.js +95 -0
  294. package/lib/controllers/SettingsController.d.ts +28 -0
  295. package/lib/controllers/SettingsController.js +105 -0
  296. package/lib/controllers/SnippetController.d.ts +27 -0
  297. package/lib/controllers/SnippetController.js +123 -0
  298. package/lib/controllers/TagController.d.ts +9 -0
  299. package/lib/controllers/TagController.js +70 -0
  300. package/lib/controllers/TaxonomyController.d.ts +24 -0
  301. package/lib/controllers/TaxonomyController.js +149 -0
  302. package/lib/controllers/TokenController.d.ts +27 -0
  303. package/lib/controllers/TokenController.js +83 -0
  304. package/lib/controllers/TwoFactorController.d.ts +31 -0
  305. package/lib/controllers/TwoFactorController.js +213 -0
  306. package/lib/controllers/UserController.d.ts +110 -0
  307. package/lib/controllers/UserController.js +504 -0
  308. package/lib/features/analytics/AnalyticsPage.d.ts +11 -0
  309. package/lib/features/analytics/AnalyticsPage.js +123 -0
  310. package/lib/features/analytics/admin.d.ts +3 -0
  311. package/lib/features/analytics/admin.js +9 -0
  312. package/lib/features/analytics/controller.d.ts +19 -0
  313. package/lib/features/analytics/controller.js +79 -0
  314. package/lib/features/analytics/helpers.d.ts +84 -0
  315. package/lib/features/analytics/helpers.js +181 -0
  316. package/lib/features/analytics/i18n/es.d.ts +4 -0
  317. package/lib/features/analytics/i18n/es.js +31 -0
  318. package/lib/features/analytics/index.d.ts +28 -0
  319. package/lib/features/analytics/index.js +91 -0
  320. package/lib/features/analytics/manifest.d.ts +8 -0
  321. package/lib/features/analytics/manifest.js +18 -0
  322. package/lib/features/analytics/model.d.ts +130 -0
  323. package/lib/features/analytics/model.js +206 -0
  324. package/lib/features/members/Member.d.ts +93 -0
  325. package/lib/features/members/Member.js +194 -0
  326. package/lib/features/members/MemberAdminController.d.ts +60 -0
  327. package/lib/features/members/MemberAdminController.js +262 -0
  328. package/lib/features/members/MemberController.d.ts +88 -0
  329. package/lib/features/members/MemberController.js +250 -0
  330. package/lib/features/members/MembersPage.d.ts +10 -0
  331. package/lib/features/members/MembersPage.js +216 -0
  332. package/lib/features/members/PostAccessBox.d.ts +15 -0
  333. package/lib/features/members/PostAccessBox.js +70 -0
  334. package/lib/features/members/admin.d.ts +3 -0
  335. package/lib/features/members/admin.js +12 -0
  336. package/lib/features/members/csv.d.ts +21 -0
  337. package/lib/features/members/csv.js +74 -0
  338. package/lib/features/members/events.d.ts +34 -0
  339. package/lib/features/members/events.js +34 -0
  340. package/lib/features/members/i18n/es.d.ts +4 -0
  341. package/lib/features/members/i18n/es.js +106 -0
  342. package/lib/features/members/index.d.ts +44 -0
  343. package/lib/features/members/index.js +106 -0
  344. package/lib/features/members/manifest.d.ts +8 -0
  345. package/lib/features/members/manifest.js +18 -0
  346. package/lib/features/members/middleware.d.ts +42 -0
  347. package/lib/features/members/middleware.js +74 -0
  348. package/lib/features/members/newsletter.d.ts +177 -0
  349. package/lib/features/members/newsletter.js +439 -0
  350. package/lib/features/members/rate-limits.d.ts +34 -0
  351. package/lib/features/members/rate-limits.js +50 -0
  352. package/lib/features/members/request.d.ts +13 -0
  353. package/lib/features/members/request.js +6 -0
  354. package/lib/features/members/routes.d.ts +15 -0
  355. package/lib/features/members/routes.js +59 -0
  356. package/lib/features/members/session.d.ts +102 -0
  357. package/lib/features/members/session.js +158 -0
  358. package/lib/features/members/settings.d.ts +14 -0
  359. package/lib/features/members/settings.js +23 -0
  360. package/lib/features/mysendbox/MySendboxSettingsCard.d.ts +7 -0
  361. package/lib/features/mysendbox/MySendboxSettingsCard.js +48 -0
  362. package/lib/features/mysendbox/admin.d.ts +3 -0
  363. package/lib/features/mysendbox/admin.js +9 -0
  364. package/lib/features/mysendbox/broadcasts.d.ts +61 -0
  365. package/lib/features/mysendbox/broadcasts.js +124 -0
  366. package/lib/features/mysendbox/client.d.ts +95 -0
  367. package/lib/features/mysendbox/client.js +61 -0
  368. package/lib/features/mysendbox/config.d.ts +27 -0
  369. package/lib/features/mysendbox/config.js +74 -0
  370. package/lib/features/mysendbox/contacts.d.ts +121 -0
  371. package/lib/features/mysendbox/contacts.js +378 -0
  372. package/lib/features/mysendbox/controller.d.ts +11 -0
  373. package/lib/features/mysendbox/controller.js +47 -0
  374. package/lib/features/mysendbox/i18n/es.d.ts +4 -0
  375. package/lib/features/mysendbox/i18n/es.js +28 -0
  376. package/lib/features/mysendbox/index.d.ts +18 -0
  377. package/lib/features/mysendbox/index.js +71 -0
  378. package/lib/features/mysendbox/manifest.d.ts +7 -0
  379. package/lib/features/mysendbox/manifest.js +6 -0
  380. package/lib/features/mysendbox/routes.d.ts +6 -0
  381. package/lib/features/mysendbox/routes.js +14 -0
  382. package/lib/features/mysendbox/webhook.d.ts +23 -0
  383. package/lib/features/mysendbox/webhook.js +104 -0
  384. package/lib/features/theme/OEmbedController.d.ts +31 -0
  385. package/lib/features/theme/OEmbedController.js +128 -0
  386. package/lib/features/theme/ThemeController.d.ts +20 -0
  387. package/lib/features/theme/ThemeController.js +256 -0
  388. package/lib/features/theme/ThemeSettingsCard.d.ts +7 -0
  389. package/lib/features/theme/ThemeSettingsCard.js +12 -0
  390. package/lib/features/theme/admin.d.ts +3 -0
  391. package/lib/features/theme/admin.js +9 -0
  392. package/lib/features/theme/html.d.ts +48 -0
  393. package/lib/features/theme/html.js +97 -0
  394. package/lib/features/theme/i18n/es.d.ts +4 -0
  395. package/lib/features/theme/i18n/es.js +9 -0
  396. package/lib/features/theme/index.d.ts +11 -0
  397. package/lib/features/theme/index.js +23 -0
  398. package/lib/features/theme/manifest.d.ts +7 -0
  399. package/lib/features/theme/manifest.js +6 -0
  400. package/lib/features/theme/oembed.d.ts +36 -0
  401. package/lib/features/theme/oembed.js +58 -0
  402. package/lib/features/theme/routes.d.ts +17 -0
  403. package/lib/features/theme/routes.js +54 -0
  404. package/lib/features/theme/templates.d.ts +103 -0
  405. package/lib/features/theme/templates.js +283 -0
  406. package/lib/features.d.ts +15 -0
  407. package/lib/features.js +6 -0
  408. package/lib/features.manifest.d.ts +10 -0
  409. package/lib/features.manifest.js +6 -0
  410. package/lib/helpers/access.d.ts +62 -0
  411. package/lib/helpers/access.js +92 -0
  412. package/lib/helpers/api.d.ts +20 -0
  413. package/lib/helpers/api.js +44 -0
  414. package/lib/helpers/comment-guard.d.ts +145 -0
  415. package/lib/helpers/comment-guard.js +253 -0
  416. package/lib/helpers/comment-mail.d.ts +53 -0
  417. package/lib/helpers/comment-mail.js +188 -0
  418. package/lib/helpers/content-model.d.ts +50 -0
  419. package/lib/helpers/content-model.js +84 -0
  420. package/lib/helpers/content-paths.d.ts +107 -0
  421. package/lib/helpers/content-paths.js +200 -0
  422. package/lib/helpers/export-data.d.ts +85 -0
  423. package/lib/helpers/export-data.js +229 -0
  424. package/lib/helpers/gating.d.ts +53 -0
  425. package/lib/helpers/gating.js +83 -0
  426. package/lib/helpers/health.d.ts +91 -0
  427. package/lib/helpers/health.js +279 -0
  428. package/lib/helpers/heartbeat.d.ts +35 -0
  429. package/lib/helpers/heartbeat.js +55 -0
  430. package/lib/helpers/image-size.d.ts +18 -0
  431. package/lib/helpers/image-size.js +83 -0
  432. package/lib/helpers/images.d.ts +29 -0
  433. package/lib/helpers/images.js +41 -0
  434. package/lib/helpers/mail-templates.d.ts +11 -0
  435. package/lib/helpers/mail-templates.js +42 -0
  436. package/lib/helpers/publish-due.d.ts +28 -0
  437. package/lib/helpers/publish-due.js +67 -0
  438. package/lib/helpers/redirects.d.ts +43 -0
  439. package/lib/helpers/redirects.js +80 -0
  440. package/lib/helpers/seo-fields.d.ts +13 -0
  441. package/lib/helpers/seo-fields.js +52 -0
  442. package/lib/helpers/session.d.ts +30 -0
  443. package/lib/helpers/session.js +27 -0
  444. package/lib/helpers/site-settings.d.ts +98 -0
  445. package/lib/helpers/site-settings.js +232 -0
  446. package/lib/helpers/site.d.ts +14 -0
  447. package/lib/helpers/site.js +23 -0
  448. package/lib/helpers/write-hooks.d.ts +33 -0
  449. package/lib/helpers/write-hooks.js +37 -0
  450. package/lib/hooks.d.ts +17 -0
  451. package/lib/hooks.js +101 -0
  452. package/lib/host/core-tasks.d.ts +4 -0
  453. package/lib/host/core-tasks.js +26 -0
  454. package/lib/host/cron.d.ts +39 -0
  455. package/lib/host/cron.js +85 -0
  456. package/lib/host/enabled.d.ts +4 -0
  457. package/lib/host/enabled.js +40 -0
  458. package/lib/host/index.d.ts +81 -0
  459. package/lib/host/index.js +87 -0
  460. package/lib/host/manifest.d.ts +34 -0
  461. package/lib/host/manifest.js +7 -0
  462. package/lib/host/menu.d.ts +18 -0
  463. package/lib/host/menu.js +15 -0
  464. package/lib/main.d.ts +1 -0
  465. package/lib/main.js +24 -0
  466. package/lib/middleware/api-auth.d.ts +59 -0
  467. package/lib/middleware/api-auth.js +164 -0
  468. package/lib/middleware/auth.d.ts +49 -0
  469. package/lib/middleware/auth.js +112 -0
  470. package/lib/middleware/cache.d.ts +17 -0
  471. package/lib/middleware/cache.js +52 -0
  472. package/lib/middleware/rate-limits.d.ts +199 -0
  473. package/lib/middleware/rate-limits.js +276 -0
  474. package/lib/middleware/viewer.d.ts +13 -0
  475. package/lib/middleware/viewer.js +16 -0
  476. package/lib/models/Category.d.ts +24 -0
  477. package/lib/models/Category.js +102 -0
  478. package/lib/models/Comment.d.ts +120 -0
  479. package/lib/models/Comment.js +283 -0
  480. package/lib/models/ContentType.d.ts +142 -0
  481. package/lib/models/ContentType.js +462 -0
  482. package/lib/models/Credential.d.ts +21 -0
  483. package/lib/models/Credential.js +31 -0
  484. package/lib/models/Media.d.ts +53 -0
  485. package/lib/models/Media.js +132 -0
  486. package/lib/models/Menu.d.ts +131 -0
  487. package/lib/models/Menu.js +312 -0
  488. package/lib/models/Page.d.ts +55 -0
  489. package/lib/models/Page.js +218 -0
  490. package/lib/models/Post.d.ts +136 -0
  491. package/lib/models/Post.js +406 -0
  492. package/lib/models/PostLock.d.ts +67 -0
  493. package/lib/models/PostLock.js +112 -0
  494. package/lib/models/PostRevision.d.ts +45 -0
  495. package/lib/models/PostRevision.js +82 -0
  496. package/lib/models/PublicContent.d.ts +283 -0
  497. package/lib/models/PublicContent.js +577 -0
  498. package/lib/models/Redirect.d.ts +123 -0
  499. package/lib/models/Redirect.js +225 -0
  500. package/lib/models/Settings.d.ts +61 -0
  501. package/lib/models/Settings.js +128 -0
  502. package/lib/models/Snippet.d.ts +36 -0
  503. package/lib/models/Snippet.js +64 -0
  504. package/lib/models/Tag.d.ts +23 -0
  505. package/lib/models/Tag.js +117 -0
  506. package/lib/models/Taxonomy.d.ts +127 -0
  507. package/lib/models/Taxonomy.js +321 -0
  508. package/lib/models/TwoFactor.d.ts +26 -0
  509. package/lib/models/TwoFactor.js +60 -0
  510. package/lib/models/User.d.ts +49 -0
  511. package/lib/models/User.js +128 -0
  512. package/lib/models/derive.d.ts +69 -0
  513. package/lib/models/derive.js +81 -0
  514. package/lib/models/pagination.d.ts +30 -0
  515. package/lib/models/pagination.js +36 -0
  516. package/lib/models/visibility.d.ts +31 -0
  517. package/lib/models/visibility.js +47 -0
  518. package/lib/routes/App.d.ts +2 -0
  519. package/lib/routes/App.js +146 -0
  520. package/lib/routes/api/admin.d.ts +6 -0
  521. package/lib/routes/api/admin.js +11 -0
  522. package/lib/routes/api/auth.d.ts +6 -0
  523. package/lib/routes/api/auth.js +24 -0
  524. package/lib/routes/api/authors.d.ts +5 -0
  525. package/lib/routes/api/authors.js +8 -0
  526. package/lib/routes/api/categories.d.ts +8 -0
  527. package/lib/routes/api/categories.js +15 -0
  528. package/lib/routes/api/comments.d.ts +8 -0
  529. package/lib/routes/api/comments.js +35 -0
  530. package/lib/routes/api/content-model.d.ts +17 -0
  531. package/lib/routes/api/content-model.js +67 -0
  532. package/lib/routes/api/cron.d.ts +6 -0
  533. package/lib/routes/api/cron.js +9 -0
  534. package/lib/routes/api/export.d.ts +5 -0
  535. package/lib/routes/api/export.js +11 -0
  536. package/lib/routes/api/feed.d.ts +5 -0
  537. package/lib/routes/api/feed.js +16 -0
  538. package/lib/routes/api/media.d.ts +8 -0
  539. package/lib/routes/api/media.js +25 -0
  540. package/lib/routes/api/navigation.d.ts +12 -0
  541. package/lib/routes/api/navigation.js +17 -0
  542. package/lib/routes/api/ops.d.ts +9 -0
  543. package/lib/routes/api/ops.js +19 -0
  544. package/lib/routes/api/pages.d.ts +8 -0
  545. package/lib/routes/api/pages.js +21 -0
  546. package/lib/routes/api/passkeys.d.ts +7 -0
  547. package/lib/routes/api/passkeys.js +13 -0
  548. package/lib/routes/api/posts.d.ts +8 -0
  549. package/lib/routes/api/posts.js +39 -0
  550. package/lib/routes/api/profile.d.ts +6 -0
  551. package/lib/routes/api/profile.js +8 -0
  552. package/lib/routes/api/redirects.d.ts +12 -0
  553. package/lib/routes/api/redirects.js +13 -0
  554. package/lib/routes/api/settings.d.ts +8 -0
  555. package/lib/routes/api/settings.js +15 -0
  556. package/lib/routes/api/snippets.d.ts +15 -0
  557. package/lib/routes/api/snippets.js +16 -0
  558. package/lib/routes/api/tags.d.ts +8 -0
  559. package/lib/routes/api/tags.js +14 -0
  560. package/lib/routes/api/tokens.d.ts +7 -0
  561. package/lib/routes/api/tokens.js +15 -0
  562. package/lib/routes/api/two-factor.d.ts +7 -0
  563. package/lib/routes/api/two-factor.js +15 -0
  564. package/lib/routes/api/users.d.ts +8 -0
  565. package/lib/routes/api/users.js +25 -0
  566. package/lib/routes/api/v1.d.ts +12 -0
  567. package/lib/routes/api/v1.js +55 -0
  568. package/lib/routes/api/verification.d.ts +6 -0
  569. package/lib/routes/api/verification.js +11 -0
  570. package/lib/server/index.d.ts +24 -0
  571. package/lib/server/index.js +110 -0
  572. package/lib/types/index.d.ts +298 -0
  573. package/lib/types/index.js +1 -0
  574. package/lib/vite.d.ts +2 -0
  575. package/lib/vite.js +101 -0
  576. package/mail/comment-moderation.html +27 -0
  577. package/mail/comment-moderation.txt +13 -0
  578. package/mail/comment-reply.html +28 -0
  579. package/mail/comment-reply.txt +14 -0
  580. package/mail/invitation.html +25 -0
  581. package/mail/invitation.txt +11 -0
  582. package/mail/member-magic-link.html +23 -0
  583. package/mail/member-magic-link.txt +10 -0
  584. package/mail/newsletter.html +26 -0
  585. package/mail/newsletter.txt +13 -0
  586. package/mail/password-reset.html +26 -0
  587. package/mail/password-reset.txt +10 -0
  588. package/mail/verify-email.html +25 -0
  589. package/mail/verify-email.txt +8 -0
  590. package/package.json +85 -4
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { api } from "../../../helpers/api.js";
4
+ import { useT } from "../../i18n/index.js";
5
+ /**
6
+ * The "Insert snippet" toolbar button and the list it opens.
7
+ *
8
+ * Lives in the Markdown editor's toolbar, beside the media button, because
9
+ * that is where the caret is: the snippet goes in where you were typing, not
10
+ * at the end of the post. The text is copied in — editing the snippet later
11
+ * does not change posts that already used it.
12
+ *
13
+ * The list loads when first opened rather than with the editor, so a post
14
+ * that never uses a snippet costs no request. A 403 (a contributor) is shown
15
+ * as an explanation rather than an empty list that looks broken.
16
+ */
17
+ export default function SnippetPicker({ onInsert, disabled }) {
18
+ const { t } = useT();
19
+ const [open, setOpen] = useState(false);
20
+ const [snippets, setSnippets] = useState(null);
21
+ const [error, setError] = useState(null);
22
+ const [search, setSearch] = useState('');
23
+ useEffect(() => {
24
+ if (!open || snippets)
25
+ return;
26
+ api.get('/api/snippets')
27
+ .then(res => setSnippets(res?.snippets || []))
28
+ .catch((err) => setError(err.message === 'Forbidden' ? t('Snippets are available to authors and editors.') : t('Could not load snippets.')));
29
+ }, [open, snippets]);
30
+ const needle = search.trim().toLowerCase();
31
+ const shown = (snippets || []).filter(snippet => !needle || snippet.name.toLowerCase().includes(needle));
32
+ const choose = (snippet) => {
33
+ onInsert(snippet.content);
34
+ setOpen(false);
35
+ };
36
+ return (_jsxs(_Fragment, { children: [_jsx("button", { type: "button", title: t('Insert snippet'), "aria-label": t('Insert snippet'), onClick: () => setOpen(true), disabled: disabled, className: "markdown-editor-mark", children: "\u29C9" }), open && (_jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": t('Insert snippet'), onClick: () => setOpen(false), onKeyDown: event => { if (event.key === 'Escape')
37
+ setOpen(false); }, style: {
38
+ position: 'fixed',
39
+ inset: 0,
40
+ background: 'rgba(0,0,0,0.5)',
41
+ display: 'flex',
42
+ alignItems: 'center',
43
+ justifyContent: 'center',
44
+ zIndex: 50,
45
+ padding: '1rem'
46
+ }, children: _jsxs("div", { onClick: event => event.stopPropagation(), style: {
47
+ background: 'var(--surface)',
48
+ borderRadius: '0.5rem',
49
+ width: 'min(560px, 100%)',
50
+ maxHeight: '80vh',
51
+ display: 'flex',
52
+ flexDirection: 'column'
53
+ }, children: [_jsxs("div", { style: { display: 'flex', gap: '0.5rem', alignItems: 'center', padding: '1rem', borderBottom: '1px solid var(--border)' }, children: [_jsx("strong", { style: { marginRight: 'auto' }, children: t('Insert snippet') }), _jsx("input", { type: "search", autoFocus: true, value: search, onChange: event => setSearch(event.target.value),
54
+ // This dialog renders inside the post's <form>, where Enter
55
+ // would submit the post. Here it means "insert the top match".
56
+ onKeyDown: event => {
57
+ if (event.key !== 'Enter')
58
+ return;
59
+ event.preventDefault();
60
+ if (shown[0])
61
+ choose(shown[0]);
62
+ }, placeholder: t('Search snippets'), className: "admin-input", style: { maxWidth: '200px' } }), _jsx("button", { type: "button", className: "admin-btn admin-btn-secondary", onClick: () => setOpen(false), children: t('Close') })] }), _jsxs("div", { style: { overflowY: 'auto', padding: '0.5rem 1rem 1rem' }, children: [error && _jsx("p", { style: { color: 'var(--fg-muted)' }, children: error }), !error && !snippets && _jsx("p", { style: { color: 'var(--fg-muted)' }, children: t('Loading…') }), !error && snippets && shown.length === 0 && (_jsx("p", { style: { color: 'var(--fg-muted)' }, children: snippets.length === 0
63
+ ? t('No snippets yet. Add them under Snippets in the admin menu.')
64
+ : t('No snippet matches that search.') })), _jsx("ul", { style: { listStyle: 'none', margin: 0, padding: 0, display: 'grid', gap: '0.5rem' }, children: shown.map(snippet => (_jsx("li", { children: _jsxs("button", { type: "button", onClick: () => choose(snippet), className: "admin-btn admin-btn-secondary", style: { width: '100%', textAlign: 'left', display: 'block', whiteSpace: 'normal' }, children: [_jsx("strong", { children: snippet.name }), _jsx("br", {}), _jsx("small", { style: { color: 'var(--fg-muted)' }, children: snippet.content.length > 140 ? `${snippet.content.slice(0, 140)}…` : snippet.content })] }) }, snippet.id))) })] })] }) }))] }));
65
+ }
@@ -0,0 +1,52 @@
1
+ import React from 'react';
2
+ export interface Term {
3
+ id: number;
4
+ name: string;
5
+ }
6
+ interface TermPickerProps {
7
+ /** The card heading — "Categories", "Tags". */
8
+ title: string;
9
+ /** One of them, for the placeholder and the button. "category", "tag". */
10
+ noun: string;
11
+ /** Everything that exists, both to list and to match what is typed against. */
12
+ terms: Term[];
13
+ /** The ids currently on the post. */
14
+ selected: number[];
15
+ onToggle: (id: number) => void;
16
+ /**
17
+ * Add what was typed, creating it if it is new. Resolves true once the caller
18
+ * has updated `terms` and `selected` — false if it could not, and then what
19
+ * was typed stays in the field to be corrected rather than disappearing
20
+ * behind the alert that explained why.
21
+ */
22
+ onAdd: (input: string) => Promise<boolean>;
23
+ /** An add is in flight. The field stays usable; the button does not. */
24
+ busy: boolean;
25
+ /** Shown in place of the list when there is nothing to list yet. */
26
+ emptyText: string;
27
+ /**
28
+ * Whether a comma commits, for a control whose values are conventionally
29
+ * typed as a comma-separated run. True for tags, where it always has been;
30
+ * false for categories, whose names contain commas often enough to matter.
31
+ */
32
+ commitOnComma?: boolean;
33
+ }
34
+ /**
35
+ * A searchable box of categories or tags, where the search field is also the
36
+ * way to add one.
37
+ *
38
+ * Both taxonomies used to present a full checkbox list and a separate add
39
+ * control — which works until a site has eighty categories or four hundred
40
+ * tags, at which point finding the one you want means scrolling a 12rem window
41
+ * and adding a duplicate is easier than finding the original. Filtering the
42
+ * list is the fix for the first problem; making the filter field the add field
43
+ * is the fix for the second, because you cannot type a name you already have
44
+ * without being shown it.
45
+ *
46
+ * So typing narrows the list, and what happens on Enter depends on whether
47
+ * what you typed already exists: an existing term is selected, a new one is
48
+ * created. "+ Add" only appears when there is nothing that matches exactly,
49
+ * which is the only time creating one is the right answer.
50
+ */
51
+ export default function TermPicker({ title, noun, terms, selected, onToggle, onAdd, busy, emptyText, commitOnComma }: TermPickerProps): React.JSX.Element;
52
+ export {};
@@ -0,0 +1,58 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from 'react';
3
+ import { useT } from "../../i18n/index.js";
4
+ /**
5
+ * A searchable box of categories or tags, where the search field is also the
6
+ * way to add one.
7
+ *
8
+ * Both taxonomies used to present a full checkbox list and a separate add
9
+ * control — which works until a site has eighty categories or four hundred
10
+ * tags, at which point finding the one you want means scrolling a 12rem window
11
+ * and adding a duplicate is easier than finding the original. Filtering the
12
+ * list is the fix for the first problem; making the filter field the add field
13
+ * is the fix for the second, because you cannot type a name you already have
14
+ * without being shown it.
15
+ *
16
+ * So typing narrows the list, and what happens on Enter depends on whether
17
+ * what you typed already exists: an existing term is selected, a new one is
18
+ * created. "+ Add" only appears when there is nothing that matches exactly,
19
+ * which is the only time creating one is the right answer.
20
+ */
21
+ export default function TermPicker({ title, noun, terms, selected, onToggle, onAdd, busy, emptyText, commitOnComma = false }) {
22
+ const { t } = useT();
23
+ const [query, setQuery] = useState('');
24
+ const typed = query.trim();
25
+ const needle = typed.toLowerCase();
26
+ const matches = useMemo(() => (needle ? terms.filter(term => term.name.toLowerCase().includes(needle)) : terms), [terms, needle]);
27
+ // Case-insensitively, because "Privacy" and "privacy" are the same term to
28
+ // everyone except a database — and offering to create the second one is how
29
+ // a tag list ends up with both.
30
+ const exact = terms.find(term => term.name.toLowerCase() === needle);
31
+ const commit = async () => {
32
+ if (!typed || busy)
33
+ return;
34
+ // Typing the name of something that exists means "use that one", not "make
35
+ // another".
36
+ if (exact) {
37
+ if (!selected.includes(exact.id))
38
+ onToggle(exact.id);
39
+ setQuery('');
40
+ return;
41
+ }
42
+ if (await onAdd(typed))
43
+ setQuery('');
44
+ };
45
+ return (_jsxs("div", { className: "admin-card", children: [_jsx("h3", { className: "admin-card-title", children: title }), selected.length > 0 && (_jsx("div", { className: "admin-term-chips", children: selected.map(id => {
46
+ const term = terms.find(t => t.id === id);
47
+ return (_jsxs("span", { className: "admin-term-chip", children: [term?.name ?? `#${id}`, _jsx("button", { type: "button", "aria-label": t('Remove {name}', { name: term?.name ?? noun }), onClick: () => onToggle(id), children: "\u00D7" })] }, id));
48
+ }) })), _jsx("input", { type: "search", className: "admin-input admin-term-search", placeholder: t('Search or add a {noun}', { noun }), "aria-label": t('Search or add a {noun}', { noun }), value: query, onChange: e => setQuery(e.target.value), onKeyDown: e => {
49
+ if (e.key === 'Escape')
50
+ return setQuery('');
51
+ if (e.key !== 'Enter' && !(commitOnComma && e.key === ','))
52
+ return;
53
+ // This sits inside the post form. A bare Enter here would save the
54
+ // post rather than add the term you were halfway through typing.
55
+ e.preventDefault();
56
+ commit();
57
+ } }), terms.length === 0 ? (_jsx("p", { className: "admin-term-empty", children: emptyText })) : matches.length === 0 ? (_jsx("p", { className: "admin-term-empty", children: t('No matches for “{query}”.', { query: typed }) })) : (_jsx("div", { className: "admin-term-list", children: matches.map(term => (_jsxs("label", { className: "admin-term-option", children: [_jsx("input", { type: "checkbox", checked: selected.includes(term.id), onChange: () => onToggle(term.id) }), _jsx("span", { children: term.name })] }, term.id))) })), typed && !exact && (_jsx("button", { type: "button", className: "admin-term-add", onClick: commit, disabled: busy, children: t('+ Add “{name}”', { name: typed }) }))] }));
58
+ }
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ interface ToastContextType {
3
+ success: (message: string, duration?: number) => number;
4
+ error: (message: string, duration?: number) => number;
5
+ info: (message: string, duration?: number) => number;
6
+ }
7
+ export declare const useToast: () => ToastContextType;
8
+ interface ToastProviderProps {
9
+ children: ReactNode;
10
+ }
11
+ export declare function ToastProvider({ children }: ToastProviderProps): import("react").JSX.Element;
12
+ export {};
@@ -0,0 +1,49 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { createContext, useContext, useState, useCallback } from 'react';
3
+ const ToastContext = createContext(null);
4
+ export const useToast = () => {
5
+ const context = useContext(ToastContext);
6
+ if (!context)
7
+ throw new Error('useToast must be used within ToastProvider');
8
+ return context;
9
+ };
10
+ export function ToastProvider({ children }) {
11
+ const [toasts, setToasts] = useState([]);
12
+ const addToast = useCallback((message, type = 'success', duration = 4000) => {
13
+ const id = Date.now();
14
+ setToasts(prev => [...prev, { id, message, type }]);
15
+ if (duration > 0) {
16
+ setTimeout(() => {
17
+ setToasts(prev => prev.filter(t => t.id !== id));
18
+ }, duration);
19
+ }
20
+ return id;
21
+ }, []);
22
+ const removeToast = useCallback((id) => {
23
+ setToasts(prev => prev.filter(t => t.id !== id));
24
+ }, []);
25
+ const toast = {
26
+ success: (message, duration) => addToast(message, 'success', duration),
27
+ error: (message, duration) => addToast(message, 'error', duration),
28
+ info: (message, duration) => addToast(message, 'info', duration),
29
+ };
30
+ return (_jsxs(ToastContext.Provider, { value: toast, children: [children, _jsx(ToastContainer, { toasts: toasts, removeToast: removeToast })] }));
31
+ }
32
+ function ToastContainer({ toasts, removeToast }) {
33
+ if (toasts.length === 0)
34
+ return null;
35
+ return (_jsx("div", { className: "fixed bottom-4 right-4 z-50 flex flex-col gap-2 max-w-sm", children: toasts.map(toast => (_jsx(ToastItem, { ...toast, onClose: () => removeToast(toast.id) }, toast.id))) }));
36
+ }
37
+ function ToastItem({ message, type, onClose }) {
38
+ const styles = {
39
+ success: 'bg-emerald-500 text-white',
40
+ error: 'bg-red-500 text-white',
41
+ info: 'bg-blue-500 text-white',
42
+ };
43
+ const icons = {
44
+ success: (_jsx("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M5 13l4 4L19 7" }) })),
45
+ error: (_jsx("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })),
46
+ info: (_jsx("svg", { className: "w-5 h-5", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" }) })),
47
+ };
48
+ return (_jsxs("div", { className: `flex items-center gap-3 px-4 py-3 rounded-lg shadow-lg animate-slide-in ${styles[type]}`, role: "alert", children: [icons[type], _jsx("p", { className: "text-sm font-medium flex-1", children: message }), _jsx("button", { onClick: onClose, className: "opacity-70 hover:opacity-100 transition", children: _jsx("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: _jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) }) })] }));
49
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * The admin half of every feature, loaded only when the site enables it, so
3
+ * a feature the site leaves off is not in the admin bundle's startup path.
4
+ * Keep the keys in step with src/features.ts and src/features.manifest.ts.
5
+ */
6
+ import type { AdminFeature } from './host/index.ts';
7
+ type Loader = () => Promise<{
8
+ default: AdminFeature;
9
+ }>;
10
+ declare const features: Record<string, Loader>;
11
+ export default features;
@@ -0,0 +1,7 @@
1
+ const features = {
2
+ analytics: () => import("../features/analytics/admin.js"),
3
+ members: () => import("../features/members/admin.js"),
4
+ mysendbox: () => import("../features/mysendbox/admin.js"),
5
+ theme: () => import("../features/theme/admin.js")
6
+ };
7
+ export default features;
@@ -0,0 +1,48 @@
1
+ /** A content type as the admin API returns it — the parts the editor reads. */
2
+ export interface AdminContentType {
3
+ id: number;
4
+ key: string;
5
+ singular_label: string;
6
+ plural_label: string;
7
+ route_base: string;
8
+ builtin: boolean;
9
+ public: boolean;
10
+ supports: {
11
+ excerpt: boolean;
12
+ featured_image: boolean;
13
+ comments: boolean;
14
+ categories: boolean;
15
+ tags: boolean;
16
+ custom_fields: boolean;
17
+ };
18
+ fields: Array<{
19
+ key: string;
20
+ label: string;
21
+ type: 'text' | 'textarea' | 'number' | 'url' | 'date' | 'boolean' | 'select';
22
+ options: string[];
23
+ required: boolean;
24
+ help_text: string | null;
25
+ }>;
26
+ }
27
+ /**
28
+ * Every content type, for the listing's type switcher and the editor's panels.
29
+ *
30
+ * Empty until loaded, and on failure — in which case the screens behave as
31
+ * they did before content types existed, which is the safe way to be wrong.
32
+ */
33
+ export declare function useContentTypes(): {
34
+ types: AdminContentType[];
35
+ loaded: boolean;
36
+ };
37
+ /** `?type=` from the address bar, or null. */
38
+ export declare function typeFromQuery(): string | null;
39
+ /**
40
+ * Go to an admin route and carry `?type=` with it.
41
+ *
42
+ * The client router matches its whole `path` state, query string included, so
43
+ * `navigate('/admin/posts?type=recipe')` would match no route at all. Navigate
44
+ * to the bare path, then put the query back into the address bar: the router
45
+ * still matches the path, and the screen it renders reads the type from
46
+ * `location.search` — which also survives a reload.
47
+ */
48
+ export declare function navigateWithType(navigate: (to: string) => void, path: string, type: string | null | undefined): void;
@@ -0,0 +1,48 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { api } from "../../helpers/api.js";
3
+ /**
4
+ * Every content type, for the listing's type switcher and the editor's panels.
5
+ *
6
+ * Empty until loaded, and on failure — in which case the screens behave as
7
+ * they did before content types existed, which is the safe way to be wrong.
8
+ */
9
+ export function useContentTypes() {
10
+ const [types, setTypes] = useState([]);
11
+ const [loaded, setLoaded] = useState(false);
12
+ useEffect(() => {
13
+ let live = true;
14
+ api.get('/api/content-types')
15
+ .then(res => { if (live)
16
+ setTypes(res?.content_types || []); })
17
+ .catch(() => { if (live)
18
+ setTypes([]); })
19
+ .finally(() => { if (live)
20
+ setLoaded(true); });
21
+ return () => { live = false; };
22
+ }, []);
23
+ return { types, loaded };
24
+ }
25
+ /** `?type=` from the address bar, or null. */
26
+ export function typeFromQuery() {
27
+ try {
28
+ return new URLSearchParams(window.location.search).get('type');
29
+ }
30
+ catch {
31
+ return null;
32
+ }
33
+ }
34
+ /**
35
+ * Go to an admin route and carry `?type=` with it.
36
+ *
37
+ * The client router matches its whole `path` state, query string included, so
38
+ * `navigate('/admin/posts?type=recipe')` would match no route at all. Navigate
39
+ * to the bare path, then put the query back into the address bar: the router
40
+ * still matches the path, and the screen it renders reads the type from
41
+ * `location.search` — which also survives a reload.
42
+ */
43
+ export function navigateWithType(navigate, path, type) {
44
+ navigate(path);
45
+ if (type && type !== 'post') {
46
+ window.history.replaceState({}, '', `${path}?type=${encodeURIComponent(type)}`);
47
+ }
48
+ }
@@ -0,0 +1,46 @@
1
+ export interface MediaItem {
2
+ id: number;
3
+ filename: string;
4
+ original_name: string;
5
+ /** The storage key. Not a URL — see `url`. */
6
+ path: string;
7
+ /**
8
+ * Where the file is actually served from.
9
+ *
10
+ * The database stores a key rather than a URL so that moving buckets, or
11
+ * putting a CDN in front of one, does not mean rewriting every row. The
12
+ * server resolves it per request.
13
+ */
14
+ url?: string;
15
+ mime_type?: string;
16
+ size?: number;
17
+ alt_text?: string;
18
+ created_at: string;
19
+ }
20
+ export interface UploadProgress {
21
+ name: string;
22
+ /** 0–100, or null before the browser reports any progress. */
23
+ percent: number | null;
24
+ error?: string;
25
+ }
26
+ /** Where a file is served from. Falls back to the key, which is all a local driver needs. */
27
+ export declare function mediaUrl(item: MediaItem): string;
28
+ export declare function isImage(mimeType?: string): boolean;
29
+ export declare function useMediaLibrary(): {
30
+ items: MediaItem[];
31
+ loading: boolean;
32
+ loadingMore: boolean;
33
+ hasMore: boolean;
34
+ total: number;
35
+ search: string;
36
+ setSearch: import("react").Dispatch<import("react").SetStateAction<string>>;
37
+ type: string;
38
+ setType: import("react").Dispatch<import("react").SetStateAction<string>>;
39
+ uploads: UploadProgress[];
40
+ dismissUploads: () => void;
41
+ loadMore: () => void;
42
+ upload: (files: File[]) => Promise<MediaItem[]>;
43
+ remove: (ids: number[]) => Promise<number[]>;
44
+ saveAlt: (id: number, alt: string) => Promise<MediaItem>;
45
+ reload: () => Promise<void>;
46
+ };
@@ -0,0 +1,189 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import { api } from "../../helpers/api.js";
3
+ import { t } from "../i18n/index.js";
4
+ const PER_PAGE = 24;
5
+ /** Where a file is served from. Falls back to the key, which is all a local driver needs. */
6
+ export function mediaUrl(item) {
7
+ return item.url || item.path;
8
+ }
9
+ export function isImage(mimeType) {
10
+ return Boolean(mimeType?.startsWith('image/'));
11
+ }
12
+ export function useMediaLibrary() {
13
+ const [items, setItems] = useState([]);
14
+ const [loading, setLoading] = useState(true);
15
+ const [loadingMore, setLoadingMore] = useState(false);
16
+ const [total, setTotal] = useState(0);
17
+ const [page, setPage] = useState(1);
18
+ const [totalPages, setTotalPages] = useState(1);
19
+ const [search, setSearch] = useState('');
20
+ const [type, setType] = useState('');
21
+ const [uploads, setUploads] = useState([]);
22
+ // Guards a race: a filter change while a page request is in flight would
23
+ // otherwise append the old query's results to the new query's list.
24
+ const requestId = useRef(0);
25
+ const fetchPage = useCallback(async (nextPage, replace) => {
26
+ const id = ++requestId.current;
27
+ if (replace)
28
+ setLoading(true);
29
+ else
30
+ setLoadingMore(true);
31
+ try {
32
+ const params = new URLSearchParams({
33
+ page: String(nextPage),
34
+ per_page: String(PER_PAGE)
35
+ });
36
+ if (search)
37
+ params.set('search', search);
38
+ if (type)
39
+ params.set('type', type);
40
+ const res = await api.get(`/api/media?${params}`);
41
+ if (id !== requestId.current)
42
+ return;
43
+ const fetched = res?.media || [];
44
+ setItems(prev => (replace ? fetched : [...prev, ...fetched]));
45
+ setPage(res?.pagination?.page || nextPage);
46
+ setTotalPages(res?.pagination?.total_pages || 1);
47
+ setTotal(res?.pagination?.total || fetched.length);
48
+ }
49
+ catch (error) {
50
+ if (id === requestId.current)
51
+ console.error('Failed to load media:', error);
52
+ }
53
+ finally {
54
+ if (id === requestId.current) {
55
+ setLoading(false);
56
+ setLoadingMore(false);
57
+ }
58
+ }
59
+ }, [search, type]);
60
+ // Refetch from the first page whenever the query changes. Debounced so typing
61
+ // in the search box does not fire a request per keystroke.
62
+ useEffect(() => {
63
+ const timer = setTimeout(() => fetchPage(1, true), search ? 250 : 0);
64
+ return () => clearTimeout(timer);
65
+ }, [fetchPage, search]);
66
+ const hasMore = page < totalPages;
67
+ const loadMore = useCallback(() => {
68
+ if (loading || loadingMore || !hasMore)
69
+ return;
70
+ fetchPage(page + 1, false);
71
+ }, [fetchPage, hasMore, loading, loadingMore, page]);
72
+ /**
73
+ * Upload one file: sign, PUT the bytes straight to storage, confirm.
74
+ *
75
+ * The bytes never pass through the API, which is why there is no FormData
76
+ * here and no limit imposed by the server's body parser. XHR rather than
77
+ * fetch, because only XHR reports upload progress.
78
+ */
79
+ const uploadOne = async (file, onProgress) => {
80
+ const signed = await api.post('/api/media/sign', {
81
+ filename: file.name,
82
+ contentType: file.type || 'application/octet-stream',
83
+ size: file.size
84
+ });
85
+ if (!signed?.uploadUrl) {
86
+ throw new Error(signed?.error || t('Could not start the upload.'));
87
+ }
88
+ await new Promise((resolve, reject) => {
89
+ const xhr = new XMLHttpRequest();
90
+ xhr.open('PUT', signed.uploadUrl);
91
+ // The signature covers the content type, so the headers have to go up
92
+ // exactly as they were signed or storage refuses the request.
93
+ for (const [header, headerValue] of Object.entries(signed.headers || {})) {
94
+ xhr.setRequestHeader(header, headerValue);
95
+ }
96
+ xhr.upload.onprogress = (event) => {
97
+ if (event.lengthComputable)
98
+ onProgress(Math.round((event.loaded / event.total) * 100));
99
+ };
100
+ xhr.onload = () => xhr.status >= 200 && xhr.status < 300
101
+ ? resolve()
102
+ : reject(new Error(t('Storage refused the upload ({status}).', { status: xhr.status })));
103
+ xhr.onerror = () => reject(new Error(t('The upload could not reach storage.')));
104
+ xhr.send(file);
105
+ });
106
+ const confirmed = await api.post('/api/media/confirm', {
107
+ key: signed.key,
108
+ ticket: signed.ticket,
109
+ filename: file.name
110
+ });
111
+ if (!confirmed?.media) {
112
+ throw new Error(confirmed?.error || t('The upload could not be confirmed.'));
113
+ }
114
+ return confirmed.media;
115
+ };
116
+ /**
117
+ * Upload a batch, reporting progress per file.
118
+ *
119
+ * Sequential, and one rejection does not discard the rest — a file refused
120
+ * for its type should not lose the four beside it that worked.
121
+ */
122
+ const upload = async (files) => {
123
+ if (files.length === 0)
124
+ return [];
125
+ setUploads(files.map(file => ({ name: file.name, percent: null })));
126
+ const uploaded = [];
127
+ for (const [index, file] of files.entries()) {
128
+ try {
129
+ const item = await uploadOne(file, percent => setUploads(prev => prev.map((u, i) => (i === index ? { ...u, percent } : u))));
130
+ uploaded.push(item);
131
+ setUploads(prev => prev.map((u, i) => (i === index ? { ...u, percent: 100 } : u)));
132
+ }
133
+ catch (error) {
134
+ setUploads(prev => prev.map((u, i) => (i === index ? { ...u, error: error.message } : u)));
135
+ }
136
+ }
137
+ if (uploaded.length > 0) {
138
+ setItems(prev => [...uploaded, ...prev]);
139
+ setTotal(prev => prev + uploaded.length);
140
+ }
141
+ // Leave failures on screen; a message that vanishes is a message nobody read.
142
+ setUploads(prev => (prev.some(u => u.error) ? prev : []));
143
+ return uploaded;
144
+ };
145
+ const dismissUploads = () => setUploads([]);
146
+ const remove = async (ids) => {
147
+ const removed = [];
148
+ for (const id of ids) {
149
+ try {
150
+ await api.delete(`/api/media/${id}`);
151
+ removed.push(id);
152
+ }
153
+ catch {
154
+ // Reported by the caller; one failure should not abandon the batch.
155
+ }
156
+ }
157
+ if (removed.length > 0) {
158
+ setItems(prev => prev.filter(item => !removed.includes(item.id)));
159
+ setTotal(prev => prev - removed.length);
160
+ }
161
+ return removed;
162
+ };
163
+ const saveAlt = async (id, alt) => {
164
+ const res = await api.put(`/api/media/${id}`, { alt_text: alt });
165
+ const updated = res?.media;
166
+ if (!updated)
167
+ throw new Error(t('The update returned no media.'));
168
+ setItems(prev => prev.map(item => (item.id === updated.id ? updated : item)));
169
+ return updated;
170
+ };
171
+ return {
172
+ items,
173
+ loading,
174
+ loadingMore,
175
+ hasMore,
176
+ total,
177
+ search,
178
+ setSearch,
179
+ type,
180
+ setType,
181
+ uploads,
182
+ dismissUploads,
183
+ loadMore,
184
+ upload,
185
+ remove,
186
+ saveAlt,
187
+ reload: () => fetchPage(1, true)
188
+ };
189
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * The editor's side of the post edit lock (see src/models/PostLock.ts).
3
+ *
4
+ * While the editor is open it holds the lock and refreshes it on a heartbeat;
5
+ * on leaving it lets go. If someone else holds it, the editor is told who, and
6
+ * may take over. If the lock is lost mid-edit — someone else took over — the
7
+ * next heartbeat says so, and the editor stops offering to save.
8
+ *
9
+ * Raw `fetch` rather than the `api` helper, because the useful part of a 409
10
+ * here is its body (who holds the lock), and the helper keeps only the message.
11
+ */
12
+ export interface LockInfo {
13
+ locked: boolean;
14
+ mine: boolean;
15
+ user_id: number | null;
16
+ user_name: string | null;
17
+ locked_at: string | null;
18
+ expires_at: string | null;
19
+ heartbeat_ms: number;
20
+ ttl_ms: number;
21
+ }
22
+ export type LockStatus = 'idle' | 'pending' | 'held' | 'blocked' | 'free' | 'error';
23
+ export declare function usePostLock(postId: number | null, enabled: boolean): {
24
+ status: LockStatus;
25
+ holder: string | null;
26
+ lostIt: boolean;
27
+ /** Whether this editor may save — true when the lock is ours, or there is no lock to have. */
28
+ canSave: boolean;
29
+ takeOver: () => Promise<void>;
30
+ /** Try again without taking over — after a reload, or after a save was refused. */
31
+ retry: () => Promise<void>;
32
+ };