@jant/core 0.10.0 → 0.11.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 (475) hide show
  1. package/bin/commands/db/execute-file.js +1 -1
  2. package/bin/commands/db/export.js +1 -1
  3. package/bin/commands/migrate.js +4 -4
  4. package/bin/commands/posts/rebuild-html.js +1 -1
  5. package/bin/commands/reset-password.js +1 -1
  6. package/bin/commands/search/reindex.js +1 -1
  7. package/bin/commands/setup.js +4 -2
  8. package/bin/commands/site/export.js +3 -0
  9. package/bin/commands/site/import.js +178 -91
  10. package/bin/commands/site/pull-media.js +3 -2
  11. package/bin/commands/site/snapshot/export.js +3 -1
  12. package/bin/commands/site/snapshot/import.js +3 -2
  13. package/bin/commands/start.js +44 -0
  14. package/bin/commands/telegram/register-webhooks.js +1 -1
  15. package/bin/commands/uploads/cleanup.js +48 -9
  16. package/bin/jant.js +39 -4
  17. package/bin/lib/import-sources.js +151 -0
  18. package/bin/lib/node-env.js +14 -9
  19. package/bin/lib/runtime-target.js +1 -1
  20. package/bin/lib/site-pull-media.js +56 -4
  21. package/bin/lib/site-snapshot.js +39 -2
  22. package/bin/lib/sql-export.js +66 -10
  23. package/dist/{app-DIVtyB4m.js → app-jQI4OPRe.js} +5055 -4448
  24. package/dist/client/.vite/manifest.json +38 -38
  25. package/dist/client/_assets/chunks/{create-editor-B-m7X7S5.js → create-editor-5Y49x7h5.js} +2 -2
  26. package/dist/client/_assets/chunks/{footnote-rail-CmeoVtnU.js → footnote-rail-BJwswtVQ.js} +1 -1
  27. package/dist/client/_assets/chunks/{settings-paths-C-ZZBTau.js → settings-paths-h6RjIe3C.js} +2 -2
  28. package/dist/client/_assets/chunks/{slug-format-BcIsNKz-.js → slug-format-Dsi0e9Xn.js} +1 -1
  29. package/dist/client/_assets/chunks/{slugify-373citbs.js → slugify-DlHLyUHS.js} +1 -1
  30. package/dist/client/_assets/chunks/sortable-list-DYMcJrlS.js +2 -0
  31. package/dist/client/_assets/chunks/unsafe-svg-DxrzM_Gb.js +2 -0
  32. package/dist/client/_assets/client-52vQhZAv.js +296 -0
  33. package/dist/client/_assets/client-BaqmpPQ-.css +2 -0
  34. package/dist/client/_assets/{client-auth-BpkkKTsV.js → client-auth-BDcCR6u1.js} +2 -2
  35. package/dist/client/_assets/client-author-CGVvrNZ8.css +2 -0
  36. package/dist/client/_assets/{client-compose-C-DXzcFR.js → client-compose-CzEwT5qX.js} +4 -4
  37. package/dist/client/_assets/{client-manage-BfT7ht4M.js → client-manage-CF7x21L4.js} +37 -37
  38. package/dist/client/_assets/{client-settings-CGR_nZ78.js → client-settings-DIM44Zqh.js} +2 -2
  39. package/dist/{url-CKlGzvdN.js → constants-DEgyqWDl.js} +340 -1
  40. package/dist/index.d.ts +44 -0
  41. package/dist/index.js +33 -1
  42. package/dist/node.js +57 -13
  43. package/package.json +13 -18
  44. package/src/__tests__/api-docs.test.ts +168 -1
  45. package/src/__tests__/bin/import-sources.test.ts +85 -0
  46. package/src/__tests__/bin/uploads-cleanup.test.ts +66 -26
  47. package/src/__tests__/cli-commands.test.ts +40 -0
  48. package/src/__tests__/config-docs.test.ts +119 -16
  49. package/src/__tests__/custom-url-redirects.test.ts +108 -0
  50. package/src/__tests__/export-collection-custom-urls.test.ts +69 -0
  51. package/src/__tests__/export-docs.test.ts +113 -41
  52. package/src/__tests__/export-feed-ids.test.ts +1 -0
  53. package/src/__tests__/export-format-version.test.ts +88 -0
  54. package/src/__tests__/export-hugo-build.test.ts +139 -4
  55. package/src/__tests__/export-import-roundtrip.test.ts +2 -1
  56. package/src/__tests__/export-service.test.ts +42 -13
  57. package/src/__tests__/export-smart-collection.test.ts +1 -1
  58. package/src/__tests__/feed-docs.test.ts +287 -21
  59. package/src/__tests__/feed-reply-addresses.test.ts +100 -0
  60. package/src/__tests__/feeds-disabled.test.ts +98 -0
  61. package/src/__tests__/fixtures/export-format/1.json +76 -0
  62. package/src/__tests__/fixtures/export-format/2.json +80 -0
  63. package/src/__tests__/fixtures/releases/0.10.0/site-export/README.md +130 -0
  64. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2thjq/_index.md +25 -0
  65. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/2u5e5/_index.md +35 -0
  66. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/0x4nv/index.md +18 -0
  67. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/_index.md +44 -0
  68. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/faqyt/index.md +30 -0
  69. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/41q27/the-potting-mix-guide-i-keep-rereading/index.md +20 -0
  70. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5kayp/_index.md +23 -0
  71. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/_index.md +31 -0
  72. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/5ynfs/hu597/index.md +21 -0
  73. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/_index.md +5 -0
  74. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-night-heron-field-guide-for-my-walk-folder/_index.md +31 -0
  75. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/a-quiet-saturday-after-a-busy-week/_index.md +36 -0
  76. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/archive/_index.md +8 -0
  77. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/are-na-is-the-only-bookmark-pile-i-still-revisit/_index.md +30 -0
  78. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/bought-too-many-lemons-again/_index.md +37 -0
  79. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/city-walks/_index.md +12 -0
  80. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshot-for-screenshots-ocr-and-screen-recording-on-the-mac/_index.md +33 -0
  81. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/cleanshotmac-shang-de-jie-tu-ocr-lu-ping-gong-ju/_index.md +32 -0
  82. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/co344/_index.md +25 -0
  83. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/collections/_index.md +5 -0
  84. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/current-tea-rotation/_index.md +34 -0
  85. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/derek-sivers-still-writes-the-kind-of-internet-i-want-more-of/_index.md +30 -0
  86. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/desk-but-better/_index.md +25 -0
  87. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/e0kcg/_index.md +22 -0
  88. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/egi3c/_index.md +24 -0
  89. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/evf9j/_index.md +152 -0
  90. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/featured/_index.md +8 -0
  91. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-basho/_index.md +25 -0
  92. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-epictetus/_index.md +25 -0
  93. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-marcus-aurelius/_index.md +25 -0
  94. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-seneca/_index.md +26 -0
  95. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/from-thoreau/_index.md +25 -0
  96. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/2cl6d/index.md +18 -0
  97. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/3zqv7/index.md +30 -0
  98. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/5oxsv/index.md +18 -0
  99. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gkbvv/_index.md +39 -0
  100. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/gwob9/_index.md +25 -0
  101. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/home-cooking/_index.md +12 -0
  102. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/hz729/_index.md +24 -0
  103. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/inaturalist-ai-zi-ran-she-qu/_index.md +44 -0
  104. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/j4v0q/_index.md +35 -0
  105. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k278t/_index.md +25 -0
  106. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k4eee/_index.md +22 -0
  107. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/_index.md +32 -0
  108. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a-reading-log-idea-i-might-steal/index.md +20 -0
  109. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/a83qu/index.md +18 -0
  110. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/k5vh8/from-seneca-5hibo/index.md +21 -0
  111. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/kan-qi-lai-bi-jiao-ku-de-gong-si-men/_index.md +41 -0
  112. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/l2m7y/_index.md +29 -0
  113. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/lan-ya-yao-kong-qi-chuang-shang-yue-du-de-fan-ye-shen-qi/_index.md +57 -0
  114. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/mynoise-for-rainy-afternoons/_index.md +30 -0
  115. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/n09le/_index.md +23 -0
  116. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/ni-fu-jin-de-wei-ji-bai-ke-tiao-mu/_index.md +42 -0
  117. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/nts-archives-are-good-cleaning-music/_index.md +30 -0
  118. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/_index.md +32 -0
  119. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/c91j0/index.md +18 -0
  120. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/qyucy/index.md +18 -0
  121. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/qgfcu/wsgck/index.md +18 -0
  122. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/rain-makes-my-neighborhood-look-better/_index.md +46 -0
  123. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/reading-notes/_index.md +12 -0
  124. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/s4r3e/_index.md +25 -0
  125. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/serious-eats-on-tomato-and-egg-soup/_index.md +30 -0
  126. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/_index.md +44 -0
  127. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/cxiu6/index.md +18 -0
  128. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/t77ms/index.md +18 -0
  129. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/te812/the-soup-trick-i-always-forget/index.md +20 -0
  130. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/_index.md +30 -0
  131. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/telk3/from-thoreau-pawt2/index.md +21 -0
  132. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-five-minute-reset-is-still-the-best-habit-i-have/_index.md +36 -0
  133. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-hallway-light-took-12-minutes-and-3-months/_index.md +32 -0
  134. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/the-recurse-center-manual-is-weirdly-calming/_index.md +30 -0
  135. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tiny-projects/_index.md +12 -0
  136. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tong-wang-xing-fu-zhi-lu/_index.md +68 -0
  137. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/tou-ma-yan-jiang-ju-le-bu-chu-ti-yan/_index.md +62 -0
  138. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/useful-links/_index.md +12 -0
  139. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/weekend-notes/_index.md +12 -0
  140. package/src/__tests__/fixtures/releases/0.10.0/site-export/content/what-i-actually-use-my-notebook-for/_index.md +52 -0
  141. package/src/__tests__/fixtures/releases/0.10.0/site-export/data/jant.toml +124 -0
  142. package/src/__tests__/fixtures/releases/0.10.0/site-export/hugo.toml +45 -0
  143. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/_redirects +25 -0
  144. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/40bc6cd1f12e-med_01kn8jtq3penf98tfq4gzmh9g9.png +0 -0
  145. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jtx8qenf98tm9ahxr48sw.webp +0 -0
  146. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv0jdenf98tp6qr9zgjjc.webp +0 -0
  147. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jv452enf98trbkwrvhvgd.webp +0 -0
  148. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvb16enf98txp7p0pf5ge.webp +0 -0
  149. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jve5nenf98tzap11gpxzr.webp +0 -0
  150. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvq58enf98v538w5vsqp4.webp +0 -0
  151. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jvsaeenf98v6ct4gjzppc.webp +0 -0
  152. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01kn8jw26cenf98vc7k0ppz5k8.webp +0 -0
  153. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q1hme4e8cmby77dn66yy.webp +0 -0
  154. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q2w7e4e8cmc20036yh66.webp +0 -0
  155. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q7d2e4e8cmdeqjmyafby.webp +0 -0
  156. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m313q887e4e8cmdjssych7yh.webp +0 -0
  157. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp-poster.webp +0 -0
  158. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167jx2f6ct88pkz45j3ycp.mp4 +0 -0
  159. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf-poster.webp +0 -0
  160. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167mbdf6ct88pr4ga1b9kf.mp4 +0 -0
  161. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb-poster.webp +0 -0
  162. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167nsvf6ct88q1anhz4svb.mp4 +0 -0
  163. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83-poster.webp +0 -0
  164. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167qaxf6ct88qfndwzxx83.mp4 +0 -0
  165. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167sm0f6ct88qw5brtsgcw.webp +0 -0
  166. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167tf8f6ct88r169s51j49.webp +0 -0
  167. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167vaaf6ct88rbx5ztenwb.webp +0 -0
  168. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167w51f6ct88rp19pybkw1.webp +0 -0
  169. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167x0nf6ct88rzajb84tw3.webp +0 -0
  170. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167xxbf6ct88s5t2300bjk.webp +0 -0
  171. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167yq5f6ct88s9pjwt5fxg.webp +0 -0
  172. package/src/__tests__/fixtures/releases/0.10.0/site-export/static/media/med_01m3167zg4f6ct88sge8jp28ja.webp +0 -0
  173. package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/apple-touch-icon.png +0 -0
  174. package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/custom.css +0 -0
  175. package/src/__tests__/fixtures/releases/0.10.0/site-export/themes/jant/static/favicon.ico +0 -0
  176. package/src/__tests__/fixtures/releases/0.10.0/site-export/wrangler.jsonc +24 -0
  177. package/src/__tests__/fixtures/releases/0.10.0/snapshot/db.sql +322 -0
  178. package/src/__tests__/fixtures/releases/0.10.0/snapshot/meta.json +11 -0
  179. package/src/__tests__/helpers/app.ts +6 -1
  180. package/src/__tests__/helpers/export-fixtures.ts +1 -0
  181. package/src/__tests__/import-refused-aliases.test.ts +98 -0
  182. package/src/__tests__/import-site-command.test.ts +73 -8
  183. package/src/__tests__/public-types.test.ts +64 -0
  184. package/src/__tests__/release-fixtures.test.ts +79 -24
  185. package/src/__tests__/release-version.test.ts +84 -0
  186. package/src/__tests__/site-pull-media.test.ts +48 -0
  187. package/src/__tests__/snapshot-tables.test.ts +37 -0
  188. package/src/__tests__/sql-export.test.ts +21 -1
  189. package/src/__tests__/stored-file-headers.test.ts +94 -0
  190. package/src/__tests__/template-deploy-workflow.test.ts +101 -0
  191. package/src/__tests__/theme-docs.test.ts +113 -24
  192. package/src/__tests__/toolchain-versions.test.ts +54 -0
  193. package/src/__tests__/trailing-slash-redirect.test.ts +61 -0
  194. package/src/__tests__/vite-config-graph.test.ts +98 -0
  195. package/src/app.tsx +89 -66
  196. package/src/client/__tests__/compose-bridge-image-upload.test.ts +1 -0
  197. package/src/client/__tests__/compose-bridge.test.ts +87 -0
  198. package/src/client/__tests__/compose-shortcuts.test.ts +4 -4
  199. package/src/client/__tests__/footnote-rail.test.ts +1 -1
  200. package/src/client/__tests__/lazy-entries.test.ts +1 -1
  201. package/src/client/__tests__/media-scroll-hint.test.ts +2 -2
  202. package/src/client/avatar-upload.ts +10 -10
  203. package/src/client/components/__tests__/jant-compose-dialog.test.ts +295 -4
  204. package/src/client/components/__tests__/jant-compose-editor.test.ts +34 -0
  205. package/src/client/components/__tests__/jant-settings-general.test.ts +0 -32
  206. package/src/client/components/compose-types.ts +14 -0
  207. package/src/client/components/jant-compose-dialog.ts +96 -41
  208. package/src/client/components/jant-compose-editor.ts +21 -4
  209. package/src/client/components/jant-config-editor.ts +4 -6
  210. package/src/client/components/jant-media-lightbox.ts +4 -4
  211. package/src/client/components/jant-settings-general.ts +0 -4
  212. package/src/client/components/nav-manager-types.ts +6 -5
  213. package/src/client/compose-bridge.ts +15 -4
  214. package/src/client/compose-launch.ts +4 -6
  215. package/src/client/compose-shortcuts.ts +1 -1
  216. package/src/client/footnote-rail.ts +1 -1
  217. package/src/client/lazy-entries.ts +1 -1
  218. package/src/client/media-scroll-hint.ts +2 -2
  219. package/src/client/tiptap/__tests__/markdown-clipboard.test.ts +55 -0
  220. package/src/client/tiptap/markdown-clipboard.ts +50 -2
  221. package/src/client/upload-session.ts +7 -6
  222. package/src/db/__tests__/backfill-external-redirects.test.ts +59 -0
  223. package/src/db/__tests__/backfill-featured-discover.test.ts +56 -0
  224. package/src/db/backfills/0007_restore_external_redirect_scheme.sql +20 -0
  225. package/src/db/backfills/0008_turn_off_featured_only_discover.sql +11 -0
  226. package/src/i18n/locales/public/en.po +46 -48
  227. package/src/i18n/locales/public/en.ts +1 -1
  228. package/src/i18n/locales/public/zh-Hans.po +45 -46
  229. package/src/i18n/locales/public/zh-Hans.ts +1 -1
  230. package/src/i18n/locales/public/zh-Hant.po +45 -46
  231. package/src/i18n/locales/public/zh-Hant.ts +1 -1
  232. package/src/i18n/locales/settings/en.po +15 -29
  233. package/src/i18n/locales/settings/en.ts +1 -1
  234. package/src/i18n/locales/settings/zh-Hans.po +15 -29
  235. package/src/i18n/locales/settings/zh-Hans.ts +1 -1
  236. package/src/i18n/locales/settings/zh-Hant.po +15 -29
  237. package/src/i18n/locales/settings/zh-Hant.ts +1 -1
  238. package/src/index.ts +43 -2
  239. package/src/lib/__tests__/api-settings.test.ts +3 -3
  240. package/src/lib/__tests__/constants.test.ts +10 -0
  241. package/src/lib/__tests__/discover.test.ts +8 -9
  242. package/src/lib/__tests__/env-values.test.ts +125 -0
  243. package/src/lib/__tests__/feed-path.test.ts +29 -0
  244. package/src/lib/__tests__/feed.test.ts +50 -22
  245. package/src/lib/__tests__/filter-dimensions.test.ts +22 -8
  246. package/src/lib/__tests__/post-list-cursor.test.ts +0 -10
  247. package/src/lib/__tests__/rate-limit.test.ts +22 -7
  248. package/src/lib/__tests__/resolve-config.test.ts +5 -3
  249. package/src/lib/__tests__/schemas.test.ts +72 -23
  250. package/src/lib/__tests__/slugify.test.ts +9 -0
  251. package/src/lib/__tests__/startup-config.test.ts +12 -0
  252. package/src/lib/__tests__/storage-s3.test.ts +214 -0
  253. package/src/lib/__tests__/theme.test.ts +20 -1
  254. package/src/lib/__tests__/time.test.ts +56 -0
  255. package/src/lib/__tests__/timeline.test.ts +46 -0
  256. package/src/lib/__tests__/url-fetch.test.ts +65 -1
  257. package/src/lib/__tests__/url.test.ts +60 -1
  258. package/src/lib/api-nav-items.ts +16 -20
  259. package/src/lib/api-post-input.ts +34 -1
  260. package/src/lib/api-posts.ts +125 -23
  261. package/src/lib/api-public-posts.ts +28 -37
  262. package/src/lib/api-search.ts +49 -2
  263. package/src/lib/api-settings.ts +159 -54
  264. package/src/lib/api-threads.ts +34 -11
  265. package/src/lib/constants.ts +6 -0
  266. package/src/lib/discover.ts +7 -23
  267. package/src/lib/env-values.ts +140 -0
  268. package/src/lib/env.ts +203 -12
  269. package/src/lib/feed-path.ts +8 -2
  270. package/src/lib/feed-policy.ts +110 -7
  271. package/src/lib/feed.ts +69 -25
  272. package/src/lib/filter-dimensions.ts +17 -10
  273. package/src/lib/github-sync-site-config.ts +1 -0
  274. package/src/lib/hugo-markdown.ts +5 -6
  275. package/src/lib/navigation.ts +4 -1
  276. package/src/lib/post-list-cursor.ts +33 -29
  277. package/src/lib/public-storage.ts +43 -0
  278. package/src/lib/rate-limit.ts +31 -16
  279. package/src/lib/render.tsx +5 -0
  280. package/src/lib/resolve-config.ts +16 -19
  281. package/src/lib/schemas.ts +248 -180
  282. package/src/lib/slugify.ts +6 -1
  283. package/src/lib/sse.ts +1 -1
  284. package/src/lib/startup-config.ts +20 -1
  285. package/src/lib/theme.ts +8 -5
  286. package/src/lib/thread-fold.ts +6 -0
  287. package/src/lib/thread-query.ts +19 -24
  288. package/src/lib/time.ts +137 -17
  289. package/src/lib/timeline.ts +56 -13
  290. package/src/lib/url-fetch.ts +141 -40
  291. package/src/lib/url.ts +86 -1
  292. package/src/middleware/__tests__/auth.test.ts +27 -0
  293. package/src/middleware/__tests__/cors.test.ts +54 -0
  294. package/src/middleware/__tests__/cross-origin.test.ts +149 -0
  295. package/src/middleware/__tests__/public-content-access.test.ts +2 -42
  296. package/src/middleware/auth.ts +34 -3
  297. package/src/middleware/cors.ts +4 -4
  298. package/src/middleware/cross-origin.ts +124 -0
  299. package/src/middleware/error-handler.ts +7 -0
  300. package/src/middleware/public-content-access.ts +3 -26
  301. package/src/middleware/secure-headers.ts +8 -2
  302. package/src/node/__tests__/cli-migrate.test.ts +2 -2
  303. package/src/node/__tests__/cli-runtime-target.test.ts +13 -2
  304. package/src/node/__tests__/cli-site-snapshot.test.ts +57 -0
  305. package/src/node/__tests__/cli-snapshot-meta.test.ts +11 -1
  306. package/src/node/__tests__/cli-sql-export.test.ts +25 -1
  307. package/src/node/__tests__/cli-start.test.ts +66 -0
  308. package/src/node/__tests__/request-handler.test.ts +37 -0
  309. package/src/node/__tests__/runtime.test.ts +56 -1
  310. package/src/node/request-handler.ts +58 -5
  311. package/src/node/runtime.ts +37 -11
  312. package/src/preset.css +3 -3
  313. package/src/routes/__tests__/compose.test.ts +84 -0
  314. package/src/routes/api/__tests__/collections.test.ts +68 -0
  315. package/src/routes/api/__tests__/mcp.test.ts +164 -9
  316. package/src/routes/api/__tests__/media.test.ts +9 -1
  317. package/src/routes/api/__tests__/nav-items.test.ts +27 -1
  318. package/src/routes/api/__tests__/posts.test.ts +269 -78
  319. package/src/routes/api/__tests__/search.test.ts +17 -4
  320. package/src/routes/api/__tests__/settings.test.ts +119 -85
  321. package/src/routes/api/__tests__/telegram.test.ts +11 -6
  322. package/src/routes/api/__tests__/threads.test.ts +11 -0
  323. package/src/routes/api/__tests__/upload-response.test.ts +48 -0
  324. package/src/routes/api/__tests__/uploads.test.ts +35 -2
  325. package/src/routes/api/collections.ts +3 -3
  326. package/src/routes/api/custom-urls.ts +2 -1
  327. package/src/routes/api/export.ts +1 -0
  328. package/src/routes/api/internal/__tests__/post-body-html.test.ts +19 -0
  329. package/src/routes/api/internal/__tests__/uploads.test.ts +2 -0
  330. package/src/routes/api/internal/sites.ts +16 -4
  331. package/src/routes/api/mcp.ts +1 -0
  332. package/src/routes/api/media.ts +7 -8
  333. package/src/routes/api/nav-items.ts +2 -1
  334. package/src/routes/api/posts.ts +18 -24
  335. package/src/routes/api/public/__tests__/posts.test.ts +15 -0
  336. package/src/routes/api/public/__tests__/threads-collections.test.ts +12 -45
  337. package/src/routes/api/public/__tests__/threads.test.ts +41 -9
  338. package/src/routes/api/public/posts.ts +2 -2
  339. package/src/routes/api/public/threads.ts +16 -26
  340. package/src/routes/api/search.ts +7 -41
  341. package/src/routes/api/settings.ts +32 -28
  342. package/src/routes/api/smart-collections.ts +6 -1
  343. package/src/routes/api/threads.ts +25 -26
  344. package/src/routes/api/upload.ts +6 -21
  345. package/src/routes/api/uploads.ts +14 -20
  346. package/src/routes/auth/__tests__/dev.test.ts +16 -13
  347. package/src/routes/auth/__tests__/hosted-sso.test.ts +51 -0
  348. package/src/routes/auth/__tests__/setup-auth.test.ts +2 -0
  349. package/src/routes/auth/__tests__/setup-discover.test.ts +2 -0
  350. package/src/routes/auth/__tests__/setup-flow.test.ts +32 -0
  351. package/src/routes/auth/__tests__/setup-rate-limit.test.ts +72 -0
  352. package/src/routes/auth/__tests__/setup-steps.test.ts +2 -0
  353. package/src/routes/auth/__tests__/signin.test.ts +167 -2
  354. package/src/routes/auth/dev.ts +4 -6
  355. package/src/routes/auth/hosted-sso.ts +9 -6
  356. package/src/routes/auth/setup.tsx +35 -5
  357. package/src/routes/auth/signin.tsx +96 -1
  358. package/src/routes/compose.tsx +47 -47
  359. package/src/routes/dash/__tests__/settings-avatar.test.ts +59 -4
  360. package/src/routes/dash/__tests__/settings-demo-locks.test.ts +147 -0
  361. package/src/routes/dash/custom-urls.tsx +2 -0
  362. package/src/routes/dash/settings.tsx +79 -32
  363. package/src/routes/feed/__tests__/feed.test.ts +93 -3
  364. package/src/routes/feed/__tests__/sitemap.test.ts +42 -0
  365. package/src/routes/feed/feed.ts +128 -175
  366. package/src/routes/feed/sitemap.ts +9 -7
  367. package/src/routes/pages/__tests__/archive-years.test.ts +45 -0
  368. package/src/routes/pages/__tests__/collection-routing.test.ts +40 -0
  369. package/src/routes/pages/__tests__/collections.test.ts +3 -0
  370. package/src/routes/pages/__tests__/language-routing.test.ts +31 -0
  371. package/src/routes/pages/__tests__/post-page-round-trips.test.ts +34 -2
  372. package/src/routes/pages/__tests__/search.test.ts +5 -2
  373. package/src/routes/pages/__tests__/thread-gap.test.ts +207 -0
  374. package/src/routes/pages/archive.tsx +33 -94
  375. package/src/routes/pages/brand.tsx +1 -0
  376. package/src/routes/pages/collection.tsx +13 -84
  377. package/src/routes/pages/collections.tsx +2 -0
  378. package/src/routes/pages/featured.tsx +7 -2
  379. package/src/routes/pages/home.tsx +1 -0
  380. package/src/routes/pages/latest.tsx +6 -2
  381. package/src/routes/pages/new.tsx +1 -0
  382. package/src/routes/pages/page.tsx +73 -47
  383. package/src/routes/pages/search.tsx +5 -3
  384. package/src/routes/pages/smart-collection.tsx +11 -70
  385. package/src/routes/pages/subscribe.tsx +1 -0
  386. package/src/routes/pages/theme-sample.tsx +1 -0
  387. package/src/runtime/__tests__/readiness.test.ts +16 -0
  388. package/src/runtime/cloudflare.ts +2 -3
  389. package/src/runtime/index.ts +3 -1
  390. package/src/runtime/node.ts +3 -5
  391. package/src/runtime/readiness.ts +5 -0
  392. package/src/services/__tests__/auth.test.ts +115 -0
  393. package/src/services/__tests__/collection.test.ts +9 -0
  394. package/src/services/__tests__/github-sync-webhook.test.ts +78 -0
  395. package/src/services/__tests__/hosted-handoff.test.ts +208 -1
  396. package/src/services/__tests__/media.test.ts +47 -27
  397. package/src/services/__tests__/navigation.test.ts +67 -15
  398. package/src/services/__tests__/post.test.ts +103 -56
  399. package/src/services/__tests__/search.test.ts +38 -0
  400. package/src/services/__tests__/settings.test.ts +2 -14
  401. package/src/services/__tests__/smart-collection.test.ts +2 -2
  402. package/src/services/__tests__/telegram-ingest.test.ts +113 -0
  403. package/src/services/__tests__/thread.test.ts +26 -11
  404. package/src/services/auth.ts +36 -4
  405. package/src/services/collection.ts +46 -5
  406. package/src/services/custom-url.ts +11 -4
  407. package/src/services/export-theme/assets/client-site.css +1 -1
  408. package/src/services/export-theme/assets/client-site.js +2 -2
  409. package/src/services/export-theme/layouts/_default/baseof.html +1 -1
  410. package/src/services/export-theme/layouts/collection/single.html +1 -1
  411. package/src/services/export-theme/layouts/partials/featured-thread.html +8 -1
  412. package/src/services/export-theme/layouts/partials/head.html +1 -1
  413. package/src/services/export-theme/layouts/partials/media-gallery.html +6 -3
  414. package/src/services/export-theme/layouts/smart_collection/list.html +1 -1
  415. package/src/services/export-theme/styles/main.css +3 -3
  416. package/src/services/export.ts +68 -19
  417. package/src/services/github-sync.ts +10 -10
  418. package/src/services/hosted-handoff.ts +106 -6
  419. package/src/services/index.ts +3 -1
  420. package/src/services/language.ts +33 -0
  421. package/src/services/mcp.ts +176 -438
  422. package/src/services/media.ts +69 -21
  423. package/src/services/navigation.ts +19 -4
  424. package/src/services/path.ts +45 -3
  425. package/src/services/post.ts +329 -214
  426. package/src/services/search.ts +22 -3
  427. package/src/services/settings.ts +36 -3
  428. package/src/services/site-admin.ts +1 -0
  429. package/src/services/smart-collection.ts +10 -3
  430. package/src/services/telegram.ts +23 -6
  431. package/src/services/thread.ts +11 -3
  432. package/src/services/upload-session.ts +14 -15
  433. package/src/styles/components.css +2 -2
  434. package/src/styles/site-media.css +2 -2
  435. package/src/styles/tokens.css +19 -22
  436. package/src/styles/ui-author.css +73 -94
  437. package/src/styles/ui.css +62 -62
  438. package/src/types/app-context.ts +5 -1
  439. package/src/types/bindings.ts +11 -0
  440. package/src/types/config.ts +4 -4
  441. package/src/types/constants.ts +20 -0
  442. package/src/types/props.ts +34 -8
  443. package/src/types/views.ts +28 -13
  444. package/src/ui/color-themes.ts +6 -5
  445. package/src/ui/dash/settings/GeneralContent.tsx +0 -22
  446. package/src/ui/dash/settings/__tests__/GeneralContent.test.tsx +0 -21
  447. package/src/ui/feed/CuratedThreadPreview.tsx +7 -2
  448. package/src/ui/feed/LinkCard.tsx +1 -2
  449. package/src/ui/feed/NoteCard.tsx +1 -2
  450. package/src/ui/feed/QuoteCard.tsx +2 -2
  451. package/src/ui/feed/ThreadPreview.tsx +6 -6
  452. package/src/ui/feed/TimelineFeed.tsx +1 -7
  453. package/src/ui/feed/__tests__/thread-preview.test.ts +123 -10
  454. package/src/ui/feed/__tests__/timeline-cards.test.ts +18 -1
  455. package/src/ui/layouts/BaseLayout.tsx +5 -0
  456. package/src/ui/pages/ArchivePage.tsx +1 -1
  457. package/src/ui/pages/BrandPage.tsx +1 -1
  458. package/src/ui/pages/CollectionPage.tsx +0 -1
  459. package/src/ui/pages/CollectionsPage.tsx +2 -2
  460. package/src/ui/pages/ComposePage.tsx +1 -1
  461. package/src/ui/pages/FeaturedPage.tsx +1 -1
  462. package/src/ui/pages/HomePage.tsx +1 -1
  463. package/src/ui/pages/PostPage.tsx +1 -1
  464. package/src/ui/pages/SearchPage.tsx +1 -1
  465. package/src/ui/pages/SmartCollectionPage.tsx +2 -3
  466. package/src/ui/pages/SubscribePage.tsx +1 -1
  467. package/src/ui/pages/ThemeSamplePage.tsx +1 -1
  468. package/src/ui/shared/MediaGallery.tsx +1 -1
  469. package/src/vendor/datastar.js +9 -1956
  470. package/src/vendor/datastar.js.map +4 -4
  471. package/dist/client/_assets/chunks/sortable-list-BJyd-LXE.js +0 -2
  472. package/dist/client/_assets/chunks/unsafe-svg-DU_DNMy5.js +0 -2
  473. package/dist/client/_assets/client-D4AT9Iqr.js +0 -295
  474. package/dist/client/_assets/client-DRuw7XCt.css +0 -2
  475. package/dist/client/_assets/client-author-DQ8R-8KR.css +0 -2
@@ -8,7 +8,7 @@
8
8
 
9
9
  import { describe, expect, it } from "vitest";
10
10
  import Database from "better-sqlite3";
11
- import { dumpDatabaseToSql } from "../../bin/lib/sql-export.js";
11
+ import { dumpDatabaseToSql, sqlValue } from "../../bin/lib/sql-export.js";
12
12
  import { orderSnapshotPostRows } from "../../bin/lib/site-snapshot.js";
13
13
  import { describeWranglerFailure } from "../../bin/lib/d1-query.js";
14
14
  import { WRANGLER_MAX_BUFFER } from "../../bin/lib/wrangler-cli.js";
@@ -171,3 +171,23 @@ describe("snapshot post order", () => {
171
171
  expect(sql.indexOf("'pst_6'")).toBeLessThan(sql.indexOf("'pst_0'"));
172
172
  });
173
173
  });
174
+
175
+ describe("sqlValue", () => {
176
+ it("writes booleans as Postgres accepts them", () => {
177
+ expect(sqlValue(true, "pg")).toBe("TRUE");
178
+ expect(sqlValue(false, "pg")).toBe("FALSE");
179
+ expect(sqlValue(true)).toBe("1");
180
+ });
181
+
182
+ it("writes bytes for the dialect that reads them", () => {
183
+ const bytes = new Uint8Array([0xca, 0xfe]);
184
+ expect(sqlValue(bytes, "pg")).toBe("'\\xcafe'::bytea");
185
+ expect(sqlValue(bytes)).toBe("X'cafe'");
186
+ });
187
+
188
+ it("writes a Postgres timestamp back as ISO text", () => {
189
+ expect(sqlValue(new Date("2026-09-28T04:00:00.000Z"), "pg")).toBe(
190
+ "'2026-09-28T04:00:00.000Z'",
191
+ );
192
+ });
193
+ });
@@ -0,0 +1,94 @@
1
+ /**
2
+ * A stored file answers on the site's own origin. Opened directly, an HTML or
3
+ * SVG file must not run scripts there, whatever headers it was stored with.
4
+ */
5
+
6
+ import { mkdtempSync, rmSync } from "node:fs";
7
+ import { tmpdir } from "node:os";
8
+ import { join } from "node:path";
9
+ import { afterEach, describe, expect, it } from "vitest";
10
+ import { createApp } from "../app.js";
11
+ import { createLocalDriver } from "../lib/storage.js";
12
+ import type { Bindings } from "../types.js";
13
+ import { createTestDatabase, DEFAULT_TEST_SITE_ID } from "./helpers/db.js";
14
+
15
+ const executionCtx = {
16
+ waitUntil() {},
17
+ passThroughOnException() {},
18
+ props: {},
19
+ } as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
20
+
21
+ let rootPath: string | undefined;
22
+
23
+ afterEach(() => {
24
+ if (rootPath) rmSync(rootPath, { recursive: true, force: true });
25
+ rootPath = undefined;
26
+ });
27
+
28
+ async function serve(file: {
29
+ name: string;
30
+ contentType: string;
31
+ contentDisposition?: string;
32
+ }) {
33
+ rootPath = mkdtempSync(join(tmpdir(), "jant-stored-file-"));
34
+ const key = `media/${DEFAULT_TEST_SITE_ID}/files/${file.name}`;
35
+ await createLocalDriver({ rootPath }).put(
36
+ key,
37
+ new TextEncoder().encode("<script>alert(1)</script>"),
38
+ {
39
+ contentType: file.contentType,
40
+ contentDisposition: file.contentDisposition,
41
+ },
42
+ );
43
+
44
+ const { sqlite } = createTestDatabase();
45
+ const bindings = {
46
+ SITE_ORIGIN: "https://blog.example",
47
+ AUTH_SECRET: "x".repeat(40),
48
+ NODE_SQLITE: sqlite,
49
+ STORAGE_DRIVER: "local",
50
+ LOCAL_STORAGE_PATH: rootPath,
51
+ } as unknown as Bindings;
52
+
53
+ return createApp().fetch(
54
+ new Request(`https://blog.example/${key}`),
55
+ bindings,
56
+ executionCtx,
57
+ );
58
+ }
59
+
60
+ describe("stored file headers", () => {
61
+ it("sandboxes an HTML file stored inline", async () => {
62
+ const res = await serve({
63
+ name: "med_1.html",
64
+ contentType: "text/html",
65
+ contentDisposition: "inline",
66
+ });
67
+
68
+ expect(res.status).toBe(200);
69
+ expect(res.headers.get("content-security-policy")).toBe(
70
+ "default-src 'none'; style-src 'unsafe-inline'; sandbox",
71
+ );
72
+ expect(res.headers.get("x-content-type-options")).toBe("nosniff");
73
+ });
74
+
75
+ it("sandboxes an SVG", async () => {
76
+ const res = await serve({
77
+ name: "med_2.svg",
78
+ contentType: "image/svg+xml",
79
+ });
80
+
81
+ expect(res.headers.get("content-security-policy")).toContain("sandbox");
82
+ });
83
+
84
+ it("leaves a PDF to the browser's viewer", async () => {
85
+ const res = await serve({
86
+ name: "med_3.pdf",
87
+ contentType: "application/pdf",
88
+ contentDisposition: "inline",
89
+ });
90
+
91
+ expect(res.headers.get("content-security-policy")).toBeNull();
92
+ expect(res.headers.get("x-content-type-options")).toBe("nosniff");
93
+ });
94
+ });
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The deploy workflow a `create-jant` project ships deploys once its secrets
3
+ * and D1 database are set.
4
+ *
5
+ * Its preflight step reads `database_id` from `wrangler.toml` with sed, and
6
+ * skips the deploy, green, when it finds none. The pattern was escaped twice
7
+ * (`\\(`), so it never matched a real ID: every push was skipped, and sites
8
+ * that relied on the workflow never got an upgrade. Running the step itself
9
+ * is the only check that catches that.
10
+ */
11
+
12
+ import { execFileSync } from "node:child_process";
13
+ import { mkdtempSync, readFileSync, rmSync, writeFileSync } from "node:fs";
14
+ import { tmpdir } from "node:os";
15
+ import { join, resolve } from "node:path";
16
+ import { afterEach, describe, expect, it } from "vitest";
17
+ import { parse } from "yaml";
18
+
19
+ const REPO_ROOT = resolve(import.meta.dirname, "../../../..");
20
+ const WORKFLOW = "sites/demo/.github/workflows/deploy.yml";
21
+
22
+ interface WorkflowStep {
23
+ id?: string;
24
+ run?: string;
25
+ }
26
+
27
+ function preflightScript(): string {
28
+ const workflow = parse(readFileSync(join(REPO_ROOT, WORKFLOW), "utf8")) as {
29
+ jobs: Record<string, { steps: WorkflowStep[] }>;
30
+ };
31
+ const step = Object.values(workflow.jobs)
32
+ .flatMap((job) => job.steps)
33
+ .find((candidate) => candidate.id === "preflight");
34
+ if (!step?.run) throw new Error(`No preflight step in ${WORKFLOW}`);
35
+ return step.run;
36
+ }
37
+
38
+ const dirs: string[] = [];
39
+
40
+ afterEach(() => {
41
+ for (const dir of dirs.splice(0)) rmSync(dir, { recursive: true });
42
+ });
43
+
44
+ function runPreflight(
45
+ wranglerToml: string,
46
+ secrets: { CF_API_TOKEN: string; CF_ACCOUNT_ID: string },
47
+ ): string {
48
+ const dir = mkdtempSync(join(tmpdir(), "jant-deploy-preflight-"));
49
+ dirs.push(dir);
50
+ writeFileSync(join(dir, "wrangler.toml"), wranglerToml);
51
+ const output = join(dir, "output");
52
+ writeFileSync(output, "");
53
+ execFileSync("bash", ["-c", preflightScript()], {
54
+ cwd: dir,
55
+ env: {
56
+ PATH: process.env.PATH,
57
+ ...secrets,
58
+ GITHUB_OUTPUT: output,
59
+ GITHUB_STEP_SUMMARY: join(dir, "summary"),
60
+ },
61
+ });
62
+ return readFileSync(output, "utf8").trim();
63
+ }
64
+
65
+ const secrets = { CF_API_TOKEN: "token", CF_ACCOUNT_ID: "account" };
66
+
67
+ function wranglerToml(databaseId: string): string {
68
+ return [
69
+ 'name = "my-blog"',
70
+ "",
71
+ "[[d1_databases]]",
72
+ 'binding = "DB"',
73
+ 'database_name = "my-blog-db"',
74
+ `database_id = "${databaseId}"`,
75
+ "",
76
+ ].join("\n");
77
+ }
78
+
79
+ describe("template deploy workflow", () => {
80
+ it("deploys once the secrets and a D1 database ID are set", () => {
81
+ expect(
82
+ runPreflight(
83
+ wranglerToml("76329154-291d-4580-af73-aa77397649f1"),
84
+ secrets,
85
+ ),
86
+ ).toBe("ready=true");
87
+ });
88
+
89
+ it("skips while wrangler.toml still has the placeholder ID", () => {
90
+ expect(runPreflight(wranglerToml("local"), secrets)).toBe("ready=false");
91
+ });
92
+
93
+ it("skips without the Cloudflare secrets", () => {
94
+ expect(
95
+ runPreflight(wranglerToml("76329154-291d-4580-af73-aa77397649f1"), {
96
+ CF_API_TOKEN: "",
97
+ CF_ACCOUNT_ID: "",
98
+ }),
99
+ ).toBe("ready=false");
100
+ });
101
+ });
@@ -14,6 +14,9 @@ import { readdirSync, readFileSync } from "node:fs";
14
14
  import { createRequire } from "node:module";
15
15
  import { join, resolve } from "node:path";
16
16
  import { describe, expect, it } from "vitest";
17
+ import { THEME_MODES } from "../types/config.js";
18
+ import { FORMATS, PAGE_NAMES } from "../types/constants.js";
19
+ import { BUILTIN_COLOR_THEMES } from "../ui/color-themes.js";
17
20
 
18
21
  const CORE_DIR = resolve(import.meta.dirname, "../..");
19
22
  const REPO_ROOT = resolve(CORE_DIR, "../..");
@@ -21,7 +24,12 @@ const SRC_DIR = join(CORE_DIR, "src");
21
24
  const THEMING_DOCS = ["docs/theming.md", "docs/zh-Hans/theming.md"];
22
25
 
23
26
  /** `data-page` values of author-only and internal pages, left out of the docs. */
24
- const UNDOCUMENTED_PAGES = new Set(["compose", "brand", "theme-sample"]);
27
+ const UNDOCUMENTED_PAGES = new Set([
28
+ "compose",
29
+ "settings",
30
+ "brand",
31
+ "theme-sample",
32
+ ]);
25
33
 
26
34
  function listSourceFiles(dir: string, extensions: string[]): string[] {
27
35
  return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {
@@ -37,9 +45,59 @@ function listSourceFiles(dir: string, extensions: string[]): string[] {
37
45
  });
38
46
  }
39
47
 
40
- const stylesheets = listSourceFiles(SRC_DIR, [".css"])
48
+ const stylesheetFiles = listSourceFiles(SRC_DIR, [".css"]);
49
+ const stylesheets = stylesheetFiles
41
50
  .map((path) => readFileSync(path, "utf8"))
42
51
  .join("\n");
52
+
53
+ /**
54
+ * Drop every rule whose selector matches `pattern`, with its whole block.
55
+ * A brace counter, not a parser: enough for the stylesheets here, which put
56
+ * no braces inside strings or comments.
57
+ */
58
+ function stripRules(css: string, pattern: RegExp): string {
59
+ let result = "";
60
+ let preludeStart = 0;
61
+ let index = 0;
62
+ while (index < css.length) {
63
+ const char = css[index];
64
+ if (char === "{") {
65
+ const prelude = css.slice(preludeStart, index);
66
+ if (pattern.test(prelude)) {
67
+ let depth = 1;
68
+ let end = index + 1;
69
+ while (end < css.length && depth > 0) {
70
+ if (css[end] === "{") depth += 1;
71
+ if (css[end] === "}") depth -= 1;
72
+ end += 1;
73
+ }
74
+ index = end;
75
+ preludeStart = end;
76
+ continue;
77
+ }
78
+ result += css.slice(preludeStart, index + 1);
79
+ preludeStart = index + 1;
80
+ } else if (char === "}" || char === ";") {
81
+ result += css.slice(preludeStart, index + 1);
82
+ preludeStart = index + 1;
83
+ }
84
+ index += 1;
85
+ }
86
+ return result + css.slice(preludeStart);
87
+ }
88
+
89
+ /**
90
+ * What a reader's page loads: everything but the author-only sheets, and
91
+ * without the theme sample page's rules, which preview themes rather than
92
+ * render a site.
93
+ */
94
+ const readerStylesheets = stripRules(
95
+ stylesheetFiles
96
+ .filter((path) => !path.endsWith("-author.css"))
97
+ .map((path) => readFileSync(path, "utf8"))
98
+ .join("\n"),
99
+ /theme-sample/,
100
+ );
43
101
  /** BaseCoat's components read its palette variables, which the docs list. */
44
102
  const baseCoatStylesheet = readFileSync(
45
103
  createRequire(import.meta.url).resolve("basecoat-css"),
@@ -48,18 +106,39 @@ const baseCoatStylesheet = readFileSync(
48
106
  const markup = listSourceFiles(SRC_DIR, [".tsx", ".ts"])
49
107
  .map((path) => readFileSync(path, "utf8"))
50
108
  .join("\n");
109
+ /** Reader markup: the public UI, without the theme sample page. */
110
+ const readerMarkup = listSourceFiles(join(SRC_DIR, "ui"), [".tsx", ".ts"])
111
+ .filter(
112
+ (path) =>
113
+ !path.includes("/dash/") &&
114
+ !path.includes("/compose/") &&
115
+ !path.endsWith("ThemeSamplePage.tsx"),
116
+ )
117
+ .map((path) => readFileSync(path, "utf8"))
118
+ .join("\n");
119
+
120
+ /** Whether markup emits an attribute by that exact name, not a longer one. */
121
+ function emitsAttribute(name: string): boolean {
122
+ return new RegExp(`(?<![a-z-])${name}(?![a-z-])`).test(markup);
123
+ }
124
+
125
+ /** The backticked values in the third cell of an attribute's table row. */
126
+ function readDocumentedValues(markdown: string, attribute: string): string[] {
127
+ const row = markdown
128
+ .split("\n")
129
+ .find((line) => line.startsWith(`| \`${attribute}\``));
130
+ const values = row?.split("|")[3] ?? "";
131
+ return [...values.matchAll(/`([a-z-]+)`/g)].flatMap((match) =>
132
+ match[1] ? [match[1]] : [],
133
+ );
134
+ }
51
135
 
52
136
  const definedVariables = new Set(
53
137
  [...stylesheets.matchAll(/(--[a-z][a-z0-9-]*)\s*:/g)].flatMap((match) =>
54
138
  match[1] ? [match[1]] : [],
55
139
  ),
56
140
  );
57
- const emittedPages = new Set(
58
- [
59
- ...markup.matchAll(/data-page="([a-z-]+)"/g),
60
- ...markup.matchAll(/"data-page": "([a-z-]+)"/g),
61
- ].flatMap((match) => (match[1] ? [match[1]] : [])),
62
- );
141
+ const emittedPages = new Set<string>(PAGE_NAMES);
63
142
 
64
143
  function readRepoFile(path: string): string {
65
144
  return readFileSync(join(REPO_ROOT, path), "utf8");
@@ -78,16 +157,6 @@ function readDocumentedAttributes(markdown: string): string[] {
78
157
  );
79
158
  }
80
159
 
81
- function readDocumentedPages(markdown: string): string[] {
82
- const row = markdown
83
- .split("\n")
84
- .find((line) => line.startsWith("| `data-page`"));
85
- const values = row?.split("|")[3] ?? "";
86
- return [...values.matchAll(/`([a-z-]+)`/g)].flatMap((match) =>
87
- match[1] ? [match[1]] : [],
88
- );
89
- }
90
-
91
160
  describe("theming docs", () => {
92
161
  for (const path of THEMING_DOCS) {
93
162
  it(`${path} lists only variables the stylesheets define`, () => {
@@ -99,33 +168,53 @@ describe("theming docs", () => {
99
168
  );
100
169
  });
101
170
 
102
- it(`${path} lists only variables a style reads`, () => {
171
+ it(`${path} lists only variables a reader's page reads`, () => {
103
172
  // A variable the stylesheets define but never read is a knob connected
104
173
  // to nothing: the docs would promise an effect that setting it lacks.
174
+ // Reads in the author's sheets or on the theme sample page don't
175
+ // count; a reader never loads them.
105
176
  const documented = readDocumentedVariables(readRepoFile(path));
106
177
  expect(
107
178
  documented.filter(
108
179
  (name) =>
109
- !stylesheets.includes(`var(${name}`) &&
180
+ !readerStylesheets.includes(`var(${name}`) &&
110
181
  !baseCoatStylesheet.includes(`var(${name}`) &&
111
- !markup.includes(`var(${name}`),
182
+ !readerMarkup.includes(`var(${name}`),
112
183
  ),
113
184
  ).toEqual([]);
114
185
  });
115
186
 
116
187
  it(`${path} lists only data attributes the markup emits`, () => {
188
+ // By whole name: `data-post` used to pass on `data-post-body` alone.
117
189
  const documented = readDocumentedAttributes(readRepoFile(path));
118
190
  expect(documented.length).toBeGreaterThan(0);
119
- expect(documented.filter((name) => !markup.includes(name))).toEqual([]);
191
+ expect(documented.filter((name) => !emitsAttribute(name))).toEqual([]);
120
192
  });
121
193
 
122
194
  it(`${path} lists exactly the reader pages' data-page values`, () => {
123
195
  const readerPages = [...emittedPages]
124
196
  .filter((page) => !UNDOCUMENTED_PAGES.has(page))
125
197
  .sort();
126
- expect(readDocumentedPages(readRepoFile(path)).sort()).toEqual(
127
- readerPages,
198
+ expect(
199
+ readDocumentedValues(readRepoFile(path), "data-page").sort(),
200
+ ).toEqual(readerPages);
201
+ });
202
+
203
+ it(`${path} lists exactly the data-format and data-theme-mode values`, () => {
204
+ const markdown = readRepoFile(path);
205
+ expect(readDocumentedValues(markdown, "data-format").sort()).toEqual(
206
+ [...FORMATS].sort(),
207
+ );
208
+ expect(readDocumentedValues(markdown, "data-theme-mode").sort()).toEqual(
209
+ [...THEME_MODES].sort(),
128
210
  );
129
211
  });
212
+
213
+ it(`${path} names only built-in themes as data-theme values`, () => {
214
+ const ids = new Set(BUILTIN_COLOR_THEMES.map((theme) => theme.id));
215
+ const named = readDocumentedValues(readRepoFile(path), "data-theme");
216
+ expect(named.length).toBeGreaterThan(0);
217
+ expect(named.filter((id) => !ids.has(id))).toEqual([]);
218
+ });
130
219
  }
131
220
  });
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Every place that picks a Node or pnpm version picks the same one.
3
+ *
4
+ * mise installs the toolchain for local work and CI checks, `packageManager`
5
+ * drives pnpm in the deploy workflow and the Docker build, and the Dockerfile
6
+ * and deploy workflow name their Node image and version separately. They had
7
+ * drifted: mise ran pnpm 10.28.2 against a lockfile written by 10.33.0, and
8
+ * `node = "lts"` would have moved local work to the next major on its own
9
+ * while the image stayed on 24.
10
+ */
11
+
12
+ import { readFileSync } from "node:fs";
13
+ import { join, resolve } from "node:path";
14
+ import { describe, expect, it } from "vitest";
15
+
16
+ const REPO_ROOT = resolve(import.meta.dirname, "../../../..");
17
+
18
+ function read(path: string): string {
19
+ return readFileSync(join(REPO_ROOT, path), "utf8");
20
+ }
21
+
22
+ function capture(text: string, pattern: RegExp, label: string): string {
23
+ const value = pattern.exec(text)?.[1];
24
+ if (!value) throw new Error(`No ${label} found`);
25
+ return value;
26
+ }
27
+
28
+ describe("toolchain versions", () => {
29
+ const mise = read("mise.toml");
30
+ const rootPackage = JSON.parse(read("package.json")) as {
31
+ packageManager: string;
32
+ engines: { node: string };
33
+ };
34
+
35
+ it("run one pnpm version", () => {
36
+ expect(capture(mise, /^pnpm = "([^"]+)"$/m, "mise pnpm")).toBe(
37
+ rootPackage.packageManager.replace(/^pnpm@/, ""),
38
+ );
39
+ });
40
+
41
+ it("run one Node major", () => {
42
+ const major = capture(mise, /^node = "(\d+)"$/m, "mise node major");
43
+
44
+ expect(rootPackage.engines.node).toBe(`>=${major}.0.0`);
45
+ for (const [path, pattern] of [
46
+ ["Dockerfile", /^FROM node:(\d+)-/gm],
47
+ [".github/workflows/deploy.yml", /^ {8}default: "(\d+)"$/gm],
48
+ ] as const) {
49
+ const found = [...read(path).matchAll(pattern)].map((match) => match[1]);
50
+ expect(found.length, path).toBeGreaterThan(0);
51
+ expect(new Set(found), path).toEqual(new Set([major]));
52
+ }
53
+ });
54
+ });
@@ -0,0 +1,61 @@
1
+ /**
2
+ * `/foo/` redirects to `/foo`. The rewrite must never produce an address a
3
+ * browser reads as another host: `//evil.com/` trimmed naively is the
4
+ * protocol-relative `//evil.com`, and a 301 is cached for good.
5
+ */
6
+
7
+ import { describe, expect, it } from "vitest";
8
+ import { createApp } from "../app.js";
9
+ import type { Bindings } from "../types.js";
10
+ import { createTestDatabase } from "./helpers/db.js";
11
+
12
+ const executionCtx = {
13
+ waitUntil() {},
14
+ passThroughOnException() {},
15
+ props: {},
16
+ } as unknown as Parameters<ReturnType<typeof createApp>["fetch"]>[2];
17
+
18
+ function get(path: string, init?: ConstructorParameters<typeof Request>[1]) {
19
+ const { sqlite } = createTestDatabase();
20
+ return createApp().fetch(
21
+ new Request(`https://blog.example${path}`, init),
22
+ {
23
+ SITE_ORIGIN: "https://blog.example",
24
+ AUTH_SECRET: "x".repeat(40),
25
+ NODE_SQLITE: sqlite,
26
+ } as unknown as Bindings,
27
+ executionCtx,
28
+ );
29
+ }
30
+
31
+ describe("trailing slash redirect", () => {
32
+ it("drops the trailing slash and keeps the query", async () => {
33
+ const res = await get("/archive/?year=2024");
34
+
35
+ expect(res.status).toBe(301);
36
+ expect(res.headers.get("location")).toBe("/archive?year=2024");
37
+ });
38
+
39
+ it.each(["//evil.com/", "/\\evil.com/", "///evil.com/"])(
40
+ "keeps %s on this site",
41
+ async (path) => {
42
+ const res = await get(path);
43
+
44
+ expect(res.status).toBe(301);
45
+ expect(res.headers.get("location")).toBe("/evil.com");
46
+ },
47
+ );
48
+
49
+ // A 301 turns a POST into a GET in fetch, curl -L, and requests: the
50
+ // client gets a 200 list and nothing is created.
51
+ it("keeps the method of a write with 308", async () => {
52
+ const res = await get("/api/posts/", {
53
+ method: "POST",
54
+ headers: { "Content-Type": "application/json" },
55
+ body: "{}",
56
+ });
57
+
58
+ expect(res.status).toBe(308);
59
+ expect(res.headers.get("location")).toBe("/api/posts");
60
+ });
61
+ });
@@ -0,0 +1,98 @@
1
+ /**
2
+ * No Vite config loads a module that needs the SWC transform.
3
+ *
4
+ * Vite bundles a config file with plain esbuild before any plugin exists, so
5
+ * whatever a config imports statically runs without the SWC Lingui transform
6
+ * or the `define` globals. `vite.config.node.ts` imported the Node request
7
+ * handler that way; once the handler's settings validation reached
8
+ * `lib/filter-dimensions.ts`, whose top level calls `msg`, `mise run dev-node`
9
+ * stopped starting, and nothing failed. A config reaches `src/` through Vite's
10
+ * module runner instead. This walks each config's static imports and fails on
11
+ * any file that imports the macro.
12
+ */
13
+
14
+ import { readdirSync, readFileSync, statSync } from "node:fs";
15
+ import { dirname, join, resolve } from "node:path";
16
+ import { describe, expect, it } from "vitest";
17
+
18
+ const CORE_DIR = resolve(import.meta.dirname, "../..");
19
+ const MACRO = "@lingui/core/macro";
20
+
21
+ /** Relative modules a file imports at runtime; `import type` is erased. */
22
+ function runtimeImports(file: string): string[] {
23
+ const source = readFileSync(file, "utf8");
24
+ return [
25
+ ...source.matchAll(
26
+ /^\s*(?:import|export)\s+(?!type\b)(?:[^"';]*?\s+from\s+)?["'](\.[^"']+)["']/gm,
27
+ ),
28
+ ].map((match) => match[1] ?? "");
29
+ }
30
+
31
+ function resolveModule(from: string, specifier: string): string | null {
32
+ const base = resolve(dirname(from), specifier);
33
+ const candidates = [
34
+ base,
35
+ base.replace(/\.js$/, ".ts"),
36
+ base.replace(/\.js$/, ".tsx"),
37
+ `${base}.ts`,
38
+ `${base}.tsx`,
39
+ join(base, "index.ts"),
40
+ ];
41
+ return (
42
+ candidates.find((candidate) =>
43
+ statSync(candidate, { throwIfNoEntry: false })?.isFile(),
44
+ ) ?? null
45
+ );
46
+ }
47
+
48
+ /** Files a config loads, and the first one found importing the macro. */
49
+ function walk(entry: string): {
50
+ files: Set<string>;
51
+ macroChain: string[] | null;
52
+ } {
53
+ const files = new Set([entry]);
54
+ const parent = new Map<string, string>();
55
+ const queue = [entry];
56
+ while (queue.length > 0) {
57
+ const file = queue.shift() as string;
58
+ if (
59
+ /from\s+["']@lingui\/core\/macro["']/.test(readFileSync(file, "utf8"))
60
+ ) {
61
+ const chain = [file];
62
+ for (let at = parent.get(file); at; at = parent.get(at))
63
+ chain.unshift(at);
64
+ return { files, macroChain: chain };
65
+ }
66
+ for (const specifier of runtimeImports(file)) {
67
+ const next = resolveModule(file, specifier);
68
+ if (next && !files.has(next)) {
69
+ files.add(next);
70
+ parent.set(next, file);
71
+ queue.push(next);
72
+ }
73
+ }
74
+ }
75
+ return { files, macroChain: null };
76
+ }
77
+
78
+ const CONFIGS = readdirSync(CORE_DIR).filter((name) =>
79
+ /^vite\.config(\.[a-z]+)?\.ts$/.test(name),
80
+ );
81
+
82
+ describe("Vite config graphs", () => {
83
+ it("find every config", () => {
84
+ expect(CONFIGS).toEqual(
85
+ expect.arrayContaining(["vite.config.ts", "vite.config.node.ts"]),
86
+ );
87
+ });
88
+
89
+ it.each(CONFIGS)(`%s never reaches ${MACRO}`, (config) => {
90
+ const { files, macroChain } = walk(join(CORE_DIR, config));
91
+ // The walk has to see through the configs' own helpers to mean anything.
92
+ expect(files.size).toBeGreaterThan(1);
93
+ expect(
94
+ macroChain?.map((file) => file.replace(`${CORE_DIR}/`, "")) ?? null,
95
+ `imports ${MACRO}`,
96
+ ).toBeNull();
97
+ });
98
+ });