@geekity/cms 0.42.0 → 0.42.2

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 (728) hide show
  1. package/dist/admin/admin-bar.d.ts +2 -3
  2. package/dist/admin/admin-bar.d.ts.map +1 -1
  3. package/dist/admin/admin-bar.js +4 -5
  4. package/dist/admin/admin-bar.js.map +1 -1
  5. package/dist/admin/app-activity.d.ts +1 -1
  6. package/dist/admin/appearance.d.ts +5 -5
  7. package/dist/admin/appearance.js +5 -5
  8. package/dist/admin/comments.d.ts +3 -3
  9. package/dist/admin/comments.js +2 -2
  10. package/dist/admin/comments.js.map +1 -1
  11. package/dist/admin/connected-apps.d.ts +1 -1
  12. package/dist/admin/connected-apps.js +1 -1
  13. package/dist/admin/credentials.d.ts +3 -3
  14. package/dist/admin/credentials.js +3 -3
  15. package/dist/admin/dashboard.js +2 -2
  16. package/dist/admin/dashboard.js.map +1 -1
  17. package/dist/admin/documents.d.ts +4 -4
  18. package/dist/admin/documents.d.ts.map +1 -1
  19. package/dist/admin/documents.js +150 -144
  20. package/dist/admin/documents.js.map +1 -1
  21. package/dist/admin/editor-actions.d.ts +1 -1
  22. package/dist/admin/editor-actions.js +1 -1
  23. package/dist/admin/federation.d.ts +11 -11
  24. package/dist/admin/federation.d.ts.map +1 -1
  25. package/dist/admin/federation.js +10 -10
  26. package/dist/admin/flash.d.ts +8 -0
  27. package/dist/admin/flash.d.ts.map +1 -1
  28. package/dist/admin/flash.js +11 -0
  29. package/dist/admin/flash.js.map +1 -1
  30. package/dist/admin/indieauth-consent.d.ts +1 -1
  31. package/dist/admin/indieauth-consent.js +1 -1
  32. package/dist/admin/legacy-migrations.d.ts +20 -19
  33. package/dist/admin/legacy-migrations.d.ts.map +1 -1
  34. package/dist/admin/legacy-migrations.js +14 -13
  35. package/dist/admin/legacy-migrations.js.map +1 -1
  36. package/dist/admin/media.js +1 -1
  37. package/dist/admin/menu.d.ts +1 -1
  38. package/dist/admin/menu.js +4 -4
  39. package/dist/admin/menu.js.map +1 -1
  40. package/dist/admin/messages.d.ts +2 -2
  41. package/dist/admin/messages.js +2 -2
  42. package/dist/admin/navigation.d.ts +3 -3
  43. package/dist/admin/navigation.js +3 -3
  44. package/dist/admin/personal-data.d.ts +1 -1
  45. package/dist/admin/personal-data.js +1 -1
  46. package/dist/admin/plugins.d.ts +1 -1
  47. package/dist/admin/plugins.js +1 -1
  48. package/dist/admin/preview.js +3 -3
  49. package/dist/admin/preview.js.map +1 -1
  50. package/dist/admin/recovery.d.ts +1 -1
  51. package/dist/admin/recovery.js +1 -1
  52. package/dist/admin/routes.d.ts +3 -3
  53. package/dist/admin/routes.js +14 -14
  54. package/dist/admin/routes.js.map +1 -1
  55. package/dist/admin/settings-discussion.d.ts +3 -3
  56. package/dist/admin/settings-discussion.js +3 -3
  57. package/dist/admin/settings-federation.d.ts +2 -2
  58. package/dist/admin/settings-federation.js +5 -5
  59. package/dist/admin/settings-federation.js.map +1 -1
  60. package/dist/admin/settings-general.d.ts +1 -1
  61. package/dist/admin/settings-general.js +2 -2
  62. package/dist/admin/settings-general.js.map +1 -1
  63. package/dist/admin/settings-page.d.ts +2 -2
  64. package/dist/admin/settings-page.js +1 -1
  65. package/dist/admin/settings-pages.d.ts +1 -1
  66. package/dist/admin/settings-pages.js +1 -1
  67. package/dist/admin/settings-reading.d.ts +2 -2
  68. package/dist/admin/settings-reading.js +2 -2
  69. package/dist/admin/syndication-targets.d.ts +2 -2
  70. package/dist/admin/syndication-targets.js +2 -2
  71. package/dist/admin/taxonomy.d.ts +4 -4
  72. package/dist/admin/taxonomy.js +4 -4
  73. package/dist/admin/templates.d.ts +2 -2
  74. package/dist/admin/templates.js +2 -2
  75. package/dist/admin/tools.d.ts +1 -1
  76. package/dist/admin/tools.js +1 -1
  77. package/dist/admin/users.d.ts +0 -159
  78. package/dist/admin/users.d.ts.map +1 -1
  79. package/dist/admin/users.js +204 -498
  80. package/dist/admin/users.js.map +1 -1
  81. package/dist/avatars/avatars.d.ts +2 -2
  82. package/dist/avatars/avatars.js +2 -2
  83. package/dist/cache.d.ts +1 -1
  84. package/dist/cache.js +1 -1
  85. package/dist/cli/args.d.ts +20 -0
  86. package/dist/cli/args.d.ts.map +1 -0
  87. package/dist/cli/args.js +138 -0
  88. package/dist/cli/args.js.map +1 -0
  89. package/dist/cli/commands.d.ts +10 -0
  90. package/dist/cli/commands.d.ts.map +1 -0
  91. package/dist/cli/commands.js +261 -0
  92. package/dist/cli/commands.js.map +1 -0
  93. package/dist/cli/database-in-use.d.ts +9 -0
  94. package/dist/cli/database-in-use.d.ts.map +1 -0
  95. package/dist/cli/database-in-use.js +38 -0
  96. package/dist/cli/database-in-use.js.map +1 -0
  97. package/dist/cli/dev-mode.d.ts +3 -0
  98. package/dist/cli/dev-mode.d.ts.map +1 -0
  99. package/dist/cli/dev-mode.js +31 -0
  100. package/dist/cli/dev-mode.js.map +1 -0
  101. package/dist/cli/export.d.ts +3 -0
  102. package/dist/cli/export.d.ts.map +1 -0
  103. package/dist/cli/export.js +53 -0
  104. package/dist/cli/export.js.map +1 -0
  105. package/dist/cli/format.d.ts +3 -0
  106. package/dist/cli/format.d.ts.map +1 -0
  107. package/dist/cli/format.js +10 -0
  108. package/dist/cli/format.js.map +1 -0
  109. package/dist/cli/gemini.d.ts +3 -0
  110. package/dist/cli/gemini.d.ts.map +1 -0
  111. package/dist/cli/gemini.js +34 -0
  112. package/dist/cli/gemini.js.map +1 -0
  113. package/dist/cli/help.d.ts +2 -0
  114. package/dist/cli/help.d.ts.map +1 -0
  115. package/dist/cli/help.js +111 -0
  116. package/dist/cli/help.js.map +1 -0
  117. package/dist/cli/import.d.ts +3 -0
  118. package/dist/cli/import.d.ts.map +1 -0
  119. package/dist/cli/import.js +84 -0
  120. package/dist/cli/import.js.map +1 -0
  121. package/dist/cli/init.d.ts +3 -0
  122. package/dist/cli/init.d.ts.map +1 -0
  123. package/dist/cli/init.js +21 -0
  124. package/dist/cli/init.js.map +1 -0
  125. package/dist/cli/maintenance.d.ts +3 -0
  126. package/dist/cli/maintenance.d.ts.map +1 -0
  127. package/dist/cli/maintenance.js +57 -0
  128. package/dist/cli/maintenance.js.map +1 -0
  129. package/dist/cli/options.d.ts +16 -0
  130. package/dist/cli/options.d.ts.map +1 -0
  131. package/dist/cli/options.js +27 -0
  132. package/dist/cli/options.js.map +1 -0
  133. package/dist/cli/password.d.ts +21 -0
  134. package/dist/cli/password.d.ts.map +1 -0
  135. package/dist/cli/password.js +52 -0
  136. package/dist/cli/password.js.map +1 -0
  137. package/dist/cli/plugin-commands.d.ts +11 -0
  138. package/dist/cli/plugin-commands.d.ts.map +1 -0
  139. package/dist/cli/plugin-commands.js +79 -0
  140. package/dist/cli/plugin-commands.js.map +1 -0
  141. package/dist/cli/plugin-folder.d.ts +3 -0
  142. package/dist/cli/plugin-folder.d.ts.map +1 -0
  143. package/dist/cli/plugin-folder.js +93 -0
  144. package/dist/cli/plugin-folder.js.map +1 -0
  145. package/dist/cli/rebuild.d.ts +5 -0
  146. package/dist/cli/rebuild.d.ts.map +1 -0
  147. package/dist/cli/rebuild.js +44 -0
  148. package/dist/cli/rebuild.js.map +1 -0
  149. package/dist/cli/resend.d.ts +3 -0
  150. package/dist/cli/resend.d.ts.map +1 -0
  151. package/dist/cli/resend.js +36 -0
  152. package/dist/cli/resend.js.map +1 -0
  153. package/dist/cli/run-job.d.ts +5 -0
  154. package/dist/cli/run-job.d.ts.map +1 -0
  155. package/dist/cli/run-job.js +29 -0
  156. package/dist/cli/run-job.js.map +1 -0
  157. package/dist/cli/serve.d.ts +3 -0
  158. package/dist/cli/serve.d.ts.map +1 -0
  159. package/dist/cli/serve.js +65 -0
  160. package/dist/cli/serve.js.map +1 -0
  161. package/dist/cli/settings.d.ts +5 -0
  162. package/dist/cli/settings.d.ts.map +1 -0
  163. package/dist/cli/settings.js +144 -0
  164. package/dist/cli/settings.js.map +1 -0
  165. package/dist/cli/site-plugins.d.ts +5 -0
  166. package/dist/cli/site-plugins.d.ts.map +1 -0
  167. package/dist/cli/site-plugins.js +7 -0
  168. package/dist/cli/site-plugins.js.map +1 -0
  169. package/dist/cli/strip-metadata.d.ts +3 -0
  170. package/dist/cli/strip-metadata.d.ts.map +1 -0
  171. package/dist/cli/strip-metadata.js +20 -0
  172. package/dist/cli/strip-metadata.js.map +1 -0
  173. package/dist/cli/sync.d.ts +3 -0
  174. package/dist/cli/sync.d.ts.map +1 -0
  175. package/dist/cli/sync.js +22 -0
  176. package/dist/cli/sync.js.map +1 -0
  177. package/dist/cli/user.d.ts +3 -0
  178. package/dist/cli/user.d.ts.map +1 -0
  179. package/dist/cli/user.js +54 -0
  180. package/dist/cli/user.js.map +1 -0
  181. package/dist/cli.d.ts +0 -62
  182. package/dist/cli.d.ts.map +1 -1
  183. package/dist/cli.js +6 -1566
  184. package/dist/cli.js.map +1 -1
  185. package/dist/cms/app.js +10 -10
  186. package/dist/cms/app.js.map +1 -1
  187. package/dist/cms/boot.js +5 -5
  188. package/dist/cms/boot.js.map +1 -1
  189. package/dist/cms/create.d.ts +17 -17
  190. package/dist/cms/create.d.ts.map +1 -1
  191. package/dist/cms/create.js +1 -1
  192. package/dist/cms/create.js.map +1 -1
  193. package/dist/cms/server-error.d.ts +1 -1
  194. package/dist/cms/server-error.js +1 -1
  195. package/dist/cms/services.js +14 -14
  196. package/dist/cms/services.js.map +1 -1
  197. package/dist/comments/akismet.d.ts +4 -4
  198. package/dist/comments/akismet.js +6 -6
  199. package/dist/comments/akismet.js.map +1 -1
  200. package/dist/comments/conversation.d.ts +29 -29
  201. package/dist/comments/conversation.d.ts.map +1 -1
  202. package/dist/comments/conversation.js +2 -2
  203. package/dist/comments/conversation.js.map +1 -1
  204. package/dist/comments/form.d.ts +3 -3
  205. package/dist/comments/form.d.ts.map +1 -1
  206. package/dist/comments/intake.d.ts +4 -4
  207. package/dist/comments/intake.d.ts.map +1 -1
  208. package/dist/comments/intake.js +1 -1
  209. package/dist/comments/migrations.d.ts +3 -3
  210. package/dist/comments/migrations.js +3 -3
  211. package/dist/comments/moderate.d.ts +2 -2
  212. package/dist/comments/moderate.js +2 -2
  213. package/dist/comments/page-form.d.ts +1 -1
  214. package/dist/comments/page-form.js +1 -1
  215. package/dist/comments/records.d.ts +9 -9
  216. package/dist/comments/records.d.ts.map +1 -1
  217. package/dist/comments/records.js +11 -10
  218. package/dist/comments/records.js.map +1 -1
  219. package/dist/comments/reply-notices.d.ts +2 -2
  220. package/dist/comments/reply-post.d.ts +2 -2
  221. package/dist/comments/submission.d.ts +8 -8
  222. package/dist/comments/submission.d.ts.map +1 -1
  223. package/dist/comments/submission.js +9 -9
  224. package/dist/comments/submission.js.map +1 -1
  225. package/dist/config.d.ts +27 -27
  226. package/dist/config.js +3 -3
  227. package/dist/contact/index.d.ts +1 -1
  228. package/dist/contact/index.js +1 -1
  229. package/dist/contact/records.d.ts +7 -7
  230. package/dist/contact/records.js +7 -7
  231. package/dist/content/alt-text.d.ts +2 -2
  232. package/dist/content/alt-text.js +2 -2
  233. package/dist/content/authors.d.ts +6 -6
  234. package/dist/content/authors.d.ts.map +1 -1
  235. package/dist/content/authors.js +6 -6
  236. package/dist/content/authors.js.map +1 -1
  237. package/dist/content/citation.d.ts +1 -1
  238. package/dist/content/content-tree.d.ts +5 -0
  239. package/dist/content/content-tree.d.ts.map +1 -0
  240. package/dist/content/content-tree.js +54 -0
  241. package/dist/content/content-tree.js.map +1 -0
  242. package/dist/content/content-watcher.d.ts +15 -0
  243. package/dist/content/content-watcher.d.ts.map +1 -0
  244. package/dist/content/content-watcher.js +104 -0
  245. package/dist/content/content-watcher.js.map +1 -0
  246. package/dist/content/document-form.d.ts +25 -24
  247. package/dist/content/document-form.d.ts.map +1 -1
  248. package/dist/content/document-form.js +7 -7
  249. package/dist/content/document-form.js.map +1 -1
  250. package/dist/content/document-kind.d.ts +6 -6
  251. package/dist/content/document.d.ts +1 -1
  252. package/dist/content/enclosure-form.js +1 -1
  253. package/dist/content/enclosure.js +1 -1
  254. package/dist/content/event-form.d.ts +2 -2
  255. package/dist/content/event.d.ts +3 -3
  256. package/dist/content/event.js +3 -3
  257. package/dist/content/guids.d.ts +6 -6
  258. package/dist/content/guids.d.ts.map +1 -1
  259. package/dist/content/guids.js +7 -7
  260. package/dist/content/guids.js.map +1 -1
  261. package/dist/content/handles.d.ts +1 -1
  262. package/dist/content/handles.js +1 -1
  263. package/dist/content/html-to-markdown.js +2 -2
  264. package/dist/content/language.d.ts +1 -1
  265. package/dist/content/language.js +1 -1
  266. package/dist/content/locale.d.ts +1 -1
  267. package/dist/content/locale.js +1 -1
  268. package/dist/content/markdown.d.ts +1 -1
  269. package/dist/content/markdown.js +1 -1
  270. package/dist/content/parser.d.ts +1 -1
  271. package/dist/content/parser.d.ts.map +1 -1
  272. package/dist/content/permalinks.d.ts +4 -4
  273. package/dist/content/permalinks.js +4 -4
  274. package/dist/content/photo-form.js +2 -2
  275. package/dist/content/photo.d.ts +2 -2
  276. package/dist/content/photo.js +1 -1
  277. package/dist/content/pinned.d.ts +3 -3
  278. package/dist/content/pinned.js +3 -3
  279. package/dist/content/post-fields.js +2 -2
  280. package/dist/content/post-fields.js.map +1 -1
  281. package/dist/content/post-type.d.ts +4 -4
  282. package/dist/content/post-type.js +1 -1
  283. package/dist/content/reconcile.d.ts +15 -0
  284. package/dist/content/reconcile.d.ts.map +1 -0
  285. package/dist/content/reconcile.js +106 -0
  286. package/dist/content/reconcile.js.map +1 -0
  287. package/dist/content/redirects.d.ts +2 -3
  288. package/dist/content/redirects.d.ts.map +1 -1
  289. package/dist/content/redirects.js +2 -3
  290. package/dist/content/redirects.js.map +1 -1
  291. package/dist/content/rsvp.d.ts +1 -1
  292. package/dist/content/rsvp.js +1 -1
  293. package/dist/content/sanitize.js +1 -1
  294. package/dist/content/save.d.ts +3 -3
  295. package/dist/content/save.js +4 -4
  296. package/dist/content/scan.d.ts +12 -0
  297. package/dist/content/scan.d.ts.map +1 -0
  298. package/dist/content/scan.js +58 -0
  299. package/dist/content/scan.js.map +1 -0
  300. package/dist/content/search.d.ts +3 -3
  301. package/dist/content/search.js +3 -3
  302. package/dist/content/served.d.ts +5 -5
  303. package/dist/content/served.js +4 -4
  304. package/dist/content/site-links.d.ts +3 -4
  305. package/dist/content/site-links.d.ts.map +1 -1
  306. package/dist/content/site-links.js +1 -2
  307. package/dist/content/site-links.js.map +1 -1
  308. package/dist/content/sqlite/clauses.d.ts +1 -1
  309. package/dist/content/sqlite/clauses.js +1 -1
  310. package/dist/content/sqlite/rows.d.ts +1 -1
  311. package/dist/content/sqlite/rows.js +1 -1
  312. package/dist/content/store.d.ts +26 -26
  313. package/dist/content/sync.d.ts +3 -3
  314. package/dist/content/sync.d.ts.map +1 -1
  315. package/dist/content/sync.js +65 -382
  316. package/dist/content/sync.js.map +1 -1
  317. package/dist/content/taxonomy.d.ts +9 -8
  318. package/dist/content/taxonomy.d.ts.map +1 -1
  319. package/dist/content/taxonomy.js +9 -8
  320. package/dist/content/taxonomy.js.map +1 -1
  321. package/dist/content/time.d.ts +1 -1
  322. package/dist/content/time.js +1 -1
  323. package/dist/content/trash.d.ts +4 -5
  324. package/dist/content/trash.d.ts.map +1 -1
  325. package/dist/content/trash.js +4 -5
  326. package/dist/content/trash.js.map +1 -1
  327. package/dist/content/write.d.ts +4 -4
  328. package/dist/content/write.js +19 -19
  329. package/dist/content/write.js.map +1 -1
  330. package/dist/drain.d.ts +1 -1
  331. package/dist/drain.js +1 -1
  332. package/dist/federation/actor.d.ts +9 -9
  333. package/dist/federation/actor.js +10 -10
  334. package/dist/federation/article.d.ts +14 -14
  335. package/dist/federation/article.js +27 -27
  336. package/dist/federation/article.js.map +1 -1
  337. package/dist/federation/backfill.d.ts +2 -2
  338. package/dist/federation/backfill.js +2 -2
  339. package/dist/federation/citations.d.ts +1 -1
  340. package/dist/federation/citations.js +1 -1
  341. package/dist/federation/cited-post.d.ts +1 -1
  342. package/dist/federation/cited-post.js +1 -1
  343. package/dist/federation/delivery-plan.d.ts +1 -1
  344. package/dist/federation/delivery.d.ts +3 -3
  345. package/dist/federation/delivery.d.ts.map +1 -1
  346. package/dist/federation/delivery.js +11 -12
  347. package/dist/federation/delivery.js.map +1 -1
  348. package/dist/federation/federation.d.ts +3 -3
  349. package/dist/federation/federation.d.ts.map +1 -1
  350. package/dist/federation/federation.js +7 -8
  351. package/dist/federation/federation.js.map +1 -1
  352. package/dist/federation/handles.d.ts +1 -1
  353. package/dist/federation/handles.js +1 -1
  354. package/dist/federation/inbox.d.ts +6 -6
  355. package/dist/federation/inbox.js +9 -9
  356. package/dist/federation/keys.d.ts +3 -3
  357. package/dist/federation/keys.js +3 -3
  358. package/dist/federation/object-ids.d.ts +1 -1
  359. package/dist/federation/paths.d.ts +8 -8
  360. package/dist/federation/paths.js +8 -8
  361. package/dist/federation/profiles.d.ts +2 -3
  362. package/dist/federation/profiles.d.ts.map +1 -1
  363. package/dist/federation/profiles.js +2 -3
  364. package/dist/federation/profiles.js.map +1 -1
  365. package/dist/federation/quotes.d.ts +1 -1
  366. package/dist/federation/records.d.ts +24 -24
  367. package/dist/federation/records.js +23 -23
  368. package/dist/federation/records.js.map +1 -1
  369. package/dist/federation/refusals.d.ts +1 -1
  370. package/dist/federation/relays.d.ts +1 -1
  371. package/dist/federation/relays.js +6 -6
  372. package/dist/federation/webfinger.d.ts +2 -2
  373. package/dist/federation/webfinger.js +2 -2
  374. package/dist/files/atomic.d.ts +2 -2
  375. package/dist/files/atomic.js +1 -1
  376. package/dist/forms/checker.d.ts +2 -2
  377. package/dist/forms/checker.d.ts.map +1 -1
  378. package/dist/forms/protection.d.ts +1 -1
  379. package/dist/forms/protection.js +1 -1
  380. package/dist/gemini/certificate.js +1 -1
  381. package/dist/images/markup.d.ts +2 -2
  382. package/dist/images/variants.d.ts +8 -8
  383. package/dist/images/variants.js +1 -1
  384. package/dist/indexnow.d.ts +1 -1
  385. package/dist/indieauth/grants.d.ts +2 -2
  386. package/dist/indieauth/identity.d.ts +3 -5
  387. package/dist/indieauth/identity.d.ts.map +1 -1
  388. package/dist/indieauth/identity.js +3 -5
  389. package/dist/indieauth/identity.js.map +1 -1
  390. package/dist/indieauth/redeem.d.ts +2 -2
  391. package/dist/indieauth/redeem.js +2 -2
  392. package/dist/indieauth/request.d.ts +2 -2
  393. package/dist/indieauth/request.js +2 -2
  394. package/dist/indieauth/tokens.d.ts +3 -5
  395. package/dist/indieauth/tokens.d.ts.map +1 -1
  396. package/dist/indieauth/tokens.js +3 -5
  397. package/dist/indieauth/tokens.js.map +1 -1
  398. package/dist/jobs/file-records.d.ts +1 -1
  399. package/dist/jobs/file-records.js +1 -1
  400. package/dist/jobs/in-process.d.ts +1 -1
  401. package/dist/jobs/in-process.js +1 -1
  402. package/dist/jobs/queue.d.ts +1 -1
  403. package/dist/jobs/queue.js +1 -1
  404. package/dist/mail/provider.d.ts +2 -2
  405. package/dist/mail/provider.js +2 -2
  406. package/dist/media/library.d.ts +2 -2
  407. package/dist/media/uploads.js +2 -2
  408. package/dist/media/uploads.js.map +1 -1
  409. package/dist/micropub/create.d.ts +1 -1
  410. package/dist/micropub/endpoint.d.ts +7 -7
  411. package/dist/micropub/endpoint.js +8 -8
  412. package/dist/micropub/endpoint.js.map +1 -1
  413. package/dist/micropub/media.d.ts +4 -4
  414. package/dist/micropub/media.js +4 -4
  415. package/dist/micropub/update.d.ts +1 -1
  416. package/dist/micropub/update.js +1 -1
  417. package/dist/notifications/comments.d.ts +1 -1
  418. package/dist/notifications/comments.js +2 -2
  419. package/dist/notifications/comments.js.map +1 -1
  420. package/dist/notifications/digest.d.ts +7 -7
  421. package/dist/notifications/digest.js +7 -7
  422. package/dist/notifications/mail-service.d.ts +4 -4
  423. package/dist/notifications/mail-service.d.ts.map +1 -1
  424. package/dist/notifications/mail-service.js +3 -3
  425. package/dist/notifications/mail-templates.d.ts +3 -3
  426. package/dist/notifications/optouts.d.ts +1 -1
  427. package/dist/notifications/optouts.js +1 -1
  428. package/dist/notifications/tokens.d.ts +2 -2
  429. package/dist/plugin.d.ts +5 -5
  430. package/dist/plugin.js +5 -5
  431. package/dist/plugins/changes.js +2 -2
  432. package/dist/plugins/folder.d.ts +2 -2
  433. package/dist/plugins/folder.js +2 -2
  434. package/dist/plugins/install.d.ts +1 -1
  435. package/dist/plugins/install.js +1 -1
  436. package/dist/plugins/registry.d.ts +1 -1
  437. package/dist/plugins/registry.js +1 -1
  438. package/dist/plugins/site.d.ts +1 -1
  439. package/dist/plugins/site.js +1 -1
  440. package/dist/privacy/erase.d.ts +1 -1
  441. package/dist/privacy/erase.js +1 -1
  442. package/dist/privacy/retention.d.ts +2 -2
  443. package/dist/privacy/retention.js +2 -2
  444. package/dist/site/admin-paths.d.ts +2 -2
  445. package/dist/site/admin-paths.js +2 -2
  446. package/dist/site/authors.d.ts +6 -6
  447. package/dist/site/authors.js +5 -5
  448. package/dist/site/dashboard-layout.d.ts +1 -1
  449. package/dist/site/indexnow-key.js +1 -1
  450. package/dist/site/namespace.d.ts +1 -1
  451. package/dist/site/namespace.js +1 -1
  452. package/dist/site/navigation.d.ts +10 -10
  453. package/dist/site/navigation.js +10 -10
  454. package/dist/site/notification-preferences.d.ts +3 -3
  455. package/dist/site/notification-preferences.js +2 -2
  456. package/dist/site/retention-policy.d.ts +1 -1
  457. package/dist/site/retention-policy.js +1 -1
  458. package/dist/site/users.d.ts +23 -24
  459. package/dist/site/users.d.ts.map +1 -1
  460. package/dist/site/users.js +6 -6
  461. package/dist/site/users.js.map +1 -1
  462. package/dist/store/admin-store.d.ts +2 -2
  463. package/dist/store/comments.d.ts +17 -17
  464. package/dist/store/comments.d.ts.map +1 -1
  465. package/dist/store/comments.js +14 -21
  466. package/dist/store/comments.js.map +1 -1
  467. package/dist/store/conversation.d.ts +2 -2
  468. package/dist/store/deliveries.d.ts +1 -1
  469. package/dist/store/deliveries.d.ts.map +1 -1
  470. package/dist/store/deliveries.js +10 -15
  471. package/dist/store/deliveries.js.map +1 -1
  472. package/dist/store/followers.d.ts +5 -5
  473. package/dist/store/followers.d.ts.map +1 -1
  474. package/dist/store/followers.js +7 -10
  475. package/dist/store/followers.js.map +1 -1
  476. package/dist/store/inbox-replies.d.ts +4 -4
  477. package/dist/store/inbox-replies.js +4 -4
  478. package/dist/store/inbox.d.ts +5 -5
  479. package/dist/store/inbox.d.ts.map +1 -1
  480. package/dist/store/inbox.js +21 -34
  481. package/dist/store/inbox.js.map +1 -1
  482. package/dist/store/profiles.d.ts +5 -5
  483. package/dist/store/profiles.d.ts.map +1 -1
  484. package/dist/store/profiles.js +4 -5
  485. package/dist/store/profiles.js.map +1 -1
  486. package/dist/store/relays.d.ts.map +1 -1
  487. package/dist/store/relays.js +7 -9
  488. package/dist/store/relays.js.map +1 -1
  489. package/dist/store/rows.d.ts +6 -20
  490. package/dist/store/rows.d.ts.map +1 -1
  491. package/dist/store/rows.js +10 -15
  492. package/dist/store/rows.js.map +1 -1
  493. package/dist/store/schema.js +35 -35
  494. package/dist/store/schema.js.map +1 -1
  495. package/dist/store/sessions.d.ts +1 -1
  496. package/dist/store/sessions.d.ts.map +1 -1
  497. package/dist/store/sessions.js +10 -10
  498. package/dist/store/sessions.js.map +1 -1
  499. package/dist/store/state.d.ts.map +1 -1
  500. package/dist/store/state.js +2 -2
  501. package/dist/store/state.js.map +1 -1
  502. package/dist/store/tokens.d.ts +1 -1
  503. package/dist/store/tokens.d.ts.map +1 -1
  504. package/dist/store/tokens.js +5 -5
  505. package/dist/store/tokens.js.map +1 -1
  506. package/dist/store/webmentions.d.ts +2 -2
  507. package/dist/store/webmentions.d.ts.map +1 -1
  508. package/dist/store/webmentions.js +11 -11
  509. package/dist/store/webmentions.js.map +1 -1
  510. package/dist/supervisor/plugin-watcher.d.ts +26 -0
  511. package/dist/supervisor/plugin-watcher.d.ts.map +1 -0
  512. package/dist/supervisor/plugin-watcher.js +90 -0
  513. package/dist/supervisor/plugin-watcher.js.map +1 -0
  514. package/dist/supervisor/primary.d.ts +4 -7
  515. package/dist/supervisor/primary.d.ts.map +1 -1
  516. package/dist/supervisor/primary.js +37 -94
  517. package/dist/supervisor/primary.js.map +1 -1
  518. package/dist/supervisor/protocol.d.ts +1 -1
  519. package/dist/supervisor/protocol.js +1 -1
  520. package/dist/supervisor/reload-queue.d.ts +10 -0
  521. package/dist/supervisor/reload-queue.d.ts.map +1 -0
  522. package/dist/supervisor/reload-queue.js +28 -0
  523. package/dist/supervisor/reload-queue.js.map +1 -0
  524. package/dist/supervisor/supervision.d.ts +2 -2
  525. package/dist/supervisor/supervision.js +2 -2
  526. package/dist/supervisor/worker.d.ts +1 -1
  527. package/dist/supervisor/worker.js +1 -1
  528. package/dist/theme/site-data.d.ts +3 -3
  529. package/dist/theme/site-data.js +2 -2
  530. package/dist/theme/templates.d.ts +3 -3
  531. package/dist/theme/templates.js +16 -16
  532. package/dist/theme/templates.js.map +1 -1
  533. package/dist/theme/themes.d.ts +11 -13
  534. package/dist/theme/themes.d.ts.map +1 -1
  535. package/dist/theme/themes.js +8 -9
  536. package/dist/theme/themes.js.map +1 -1
  537. package/dist/web/activity-folding.d.ts +33 -0
  538. package/dist/web/activity-folding.d.ts.map +1 -0
  539. package/dist/web/activity-folding.js +238 -0
  540. package/dist/web/activity-folding.js.map +1 -0
  541. package/dist/web/archive.d.ts +2 -3
  542. package/dist/web/archive.d.ts.map +1 -1
  543. package/dist/web/archive.js +2 -3
  544. package/dist/web/archive.js.map +1 -1
  545. package/dist/web/asset-routes.d.ts +1 -1
  546. package/dist/web/asset-routes.js +1 -1
  547. package/dist/web/comment-routes.js +2 -2
  548. package/dist/web/comment-routes.js.map +1 -1
  549. package/dist/web/compression.d.ts +1 -1
  550. package/dist/web/compression.js +1 -1
  551. package/dist/web/context.d.ts +21 -21
  552. package/dist/web/context.d.ts.map +1 -1
  553. package/dist/web/context.js +7 -7
  554. package/dist/web/conversation-context.d.ts +15 -0
  555. package/dist/web/conversation-context.d.ts.map +1 -0
  556. package/dist/web/conversation-context.js +2 -0
  557. package/dist/web/conversation-context.js.map +1 -0
  558. package/dist/web/conversation-feed.d.ts +18 -0
  559. package/dist/web/conversation-feed.d.ts.map +1 -0
  560. package/dist/web/conversation-feed.js +53 -0
  561. package/dist/web/conversation-feed.js.map +1 -0
  562. package/dist/web/conversation-gather.d.ts +12 -0
  563. package/dist/web/conversation-gather.d.ts.map +1 -0
  564. package/dist/web/conversation-gather.js +189 -0
  565. package/dist/web/conversation-gather.js.map +1 -0
  566. package/dist/web/conversation-lookup.d.ts +15 -0
  567. package/dist/web/conversation-lookup.d.ts.map +1 -0
  568. package/dist/web/conversation-lookup.js +101 -0
  569. package/dist/web/conversation-lookup.js.map +1 -0
  570. package/dist/web/conversation-threads.d.ts +12 -0
  571. package/dist/web/conversation-threads.d.ts.map +1 -0
  572. package/dist/web/conversation-threads.js +144 -0
  573. package/dist/web/conversation-threads.js.map +1 -0
  574. package/dist/web/conversation.d.ts +25 -61
  575. package/dist/web/conversation.d.ts.map +1 -1
  576. package/dist/web/conversation.js +14 -854
  577. package/dist/web/conversation.js.map +1 -1
  578. package/dist/web/document-page.js +4 -4
  579. package/dist/web/document-page.js.map +1 -1
  580. package/dist/web/document-render.d.ts +9 -0
  581. package/dist/web/document-render.d.ts.map +1 -0
  582. package/dist/web/document-render.js +130 -0
  583. package/dist/web/document-render.js.map +1 -0
  584. package/dist/web/document-site.d.ts +1 -1
  585. package/dist/web/document-site.d.ts.map +1 -1
  586. package/dist/web/document-site.js +1 -1
  587. package/dist/web/document-site.js.map +1 -1
  588. package/dist/web/env.d.ts +19 -19
  589. package/dist/web/env.d.ts.map +1 -1
  590. package/dist/web/federation-routes.d.ts +2 -2
  591. package/dist/web/federation-routes.d.ts.map +1 -1
  592. package/dist/web/federation-routes.js +22 -21
  593. package/dist/web/federation-routes.js.map +1 -1
  594. package/dist/web/feed-atom.d.ts +3 -3
  595. package/dist/web/feed-atom.js +3 -3
  596. package/dist/web/feed-item.d.ts +15 -16
  597. package/dist/web/feed-item.d.ts.map +1 -1
  598. package/dist/web/feed-item.js +1 -1
  599. package/dist/web/feed-item.js.map +1 -1
  600. package/dist/web/feed-json.d.ts +4 -4
  601. package/dist/web/feed-json.d.ts.map +1 -1
  602. package/dist/web/feed-json.js +2 -2
  603. package/dist/web/feed-routes.d.ts +3 -3
  604. package/dist/web/feed-routes.js +4 -4
  605. package/dist/web/feed-routes.js.map +1 -1
  606. package/dist/web/feed-rss.d.ts +2 -2
  607. package/dist/web/feed-rss.js +4 -4
  608. package/dist/web/feed-rss.js.map +1 -1
  609. package/dist/web/feed-source.d.ts +5 -5
  610. package/dist/web/feed-source.d.ts.map +1 -1
  611. package/dist/web/feed-source.js +2 -2
  612. package/dist/web/feed-source.js.map +1 -1
  613. package/dist/web/feed-xml.d.ts +4 -4
  614. package/dist/web/feed-xml.d.ts.map +1 -1
  615. package/dist/web/feed-xml.js +4 -4
  616. package/dist/web/feed-xml.js.map +1 -1
  617. package/dist/web/font-routes.d.ts +1 -1
  618. package/dist/web/font-routes.js +1 -1
  619. package/dist/web/health.d.ts +1 -1
  620. package/dist/web/index.d.ts +5 -3
  621. package/dist/web/index.d.ts.map +1 -1
  622. package/dist/web/index.js +4 -2
  623. package/dist/web/index.js.map +1 -1
  624. package/dist/web/indieauth-activity-log.js +1 -1
  625. package/dist/web/indieauth-bearer.d.ts +2 -2
  626. package/dist/web/indieauth-discovery.d.ts +12 -12
  627. package/dist/web/indieauth-discovery.d.ts.map +1 -1
  628. package/dist/web/indieauth-discovery.js +12 -12
  629. package/dist/web/indieauth-discovery.js.map +1 -1
  630. package/dist/web/indieauth-token.d.ts +2 -2
  631. package/dist/web/indieauth-token.js +2 -2
  632. package/dist/web/listing-render.d.ts +11 -0
  633. package/dist/web/listing-render.d.ts.map +1 -0
  634. package/dist/web/listing-render.js +76 -0
  635. package/dist/web/listing-render.js.map +1 -0
  636. package/dist/web/listing-subject.js +1 -1
  637. package/dist/web/listing-subject.js.map +1 -1
  638. package/dist/web/llms.d.ts +1 -1
  639. package/dist/web/llms.js +1 -1
  640. package/dist/web/maintenance.d.ts +1 -1
  641. package/dist/web/maintenance.js +1 -1
  642. package/dist/web/manifest.d.ts +1 -1
  643. package/dist/web/manifest.js +1 -1
  644. package/dist/web/markdown-chrome.d.ts +11 -0
  645. package/dist/web/markdown-chrome.d.ts.map +1 -0
  646. package/dist/web/markdown-chrome.js +178 -0
  647. package/dist/web/markdown-chrome.js.map +1 -0
  648. package/dist/web/markdown-conversation.d.ts +1 -1
  649. package/dist/web/markdown-conversation.d.ts.map +1 -1
  650. package/dist/web/markdown-environment.d.ts +10 -0
  651. package/dist/web/markdown-environment.d.ts.map +1 -0
  652. package/dist/web/markdown-environment.js +56 -0
  653. package/dist/web/markdown-environment.js.map +1 -0
  654. package/dist/web/markdown-representation.d.ts +1 -1
  655. package/dist/web/markdown-representation.d.ts.map +1 -1
  656. package/dist/web/markdown-representation.js +2 -2
  657. package/dist/web/markdown-representation.js.map +1 -1
  658. package/dist/web/negotiate.d.ts +9 -6
  659. package/dist/web/negotiate.d.ts.map +1 -1
  660. package/dist/web/negotiate.js +17 -13
  661. package/dist/web/negotiate.js.map +1 -1
  662. package/dist/web/oembed.d.ts +3 -3
  663. package/dist/web/oembed.js +3 -3
  664. package/dist/web/opensearch.d.ts +1 -1
  665. package/dist/web/opensearch.js +1 -1
  666. package/dist/web/page-context.d.ts +29 -0
  667. package/dist/web/page-context.d.ts.map +1 -0
  668. package/dist/web/page-context.js +126 -0
  669. package/dist/web/page-context.js.map +1 -0
  670. package/dist/web/page-tags.js +1 -1
  671. package/dist/web/page-tags.js.map +1 -1
  672. package/dist/web/paths.d.ts +1 -1
  673. package/dist/web/paths.js +3 -3
  674. package/dist/web/plugin-federation.d.ts +1 -1
  675. package/dist/web/plugin-federation.js +1 -1
  676. package/dist/web/render-scope.d.ts +20 -0
  677. package/dist/web/render-scope.d.ts.map +1 -0
  678. package/dist/web/render-scope.js +36 -0
  679. package/dist/web/render-scope.js.map +1 -0
  680. package/dist/web/render.d.ts +21 -363
  681. package/dist/web/render.d.ts.map +1 -1
  682. package/dist/web/render.js +46 -899
  683. package/dist/web/render.js.map +1 -1
  684. package/dist/web/request.d.ts +1 -1
  685. package/dist/web/request.js +1 -1
  686. package/dist/web/robots.d.ts +1 -1
  687. package/dist/web/robots.js +1 -1
  688. package/dist/web/routes.js +19 -19
  689. package/dist/web/routes.js.map +1 -1
  690. package/dist/web/search.d.ts +1 -1
  691. package/dist/web/search.js +1 -1
  692. package/dist/web/session.d.ts +8 -8
  693. package/dist/web/session.js +8 -8
  694. package/dist/web/share-image.d.ts +2 -3
  695. package/dist/web/share-image.d.ts.map +1 -1
  696. package/dist/web/share-image.js +1 -1
  697. package/dist/web/share-image.js.map +1 -1
  698. package/dist/web/site-view.d.ts +2 -2
  699. package/dist/web/status-pages.d.ts +1 -1
  700. package/dist/web/status-pages.d.ts.map +1 -1
  701. package/dist/web/theme-environment.d.ts +14 -0
  702. package/dist/web/theme-environment.d.ts.map +1 -0
  703. package/dist/web/theme-environment.js +112 -0
  704. package/dist/web/theme-environment.js.map +1 -0
  705. package/dist/web/theme-templates.d.ts +67 -0
  706. package/dist/web/theme-templates.d.ts.map +1 -0
  707. package/dist/web/theme-templates.js +65 -0
  708. package/dist/web/theme-templates.js.map +1 -0
  709. package/dist/webmention/microformats.d.ts +5 -5
  710. package/dist/webmention/microformats.d.ts.map +1 -1
  711. package/dist/webmention/receive.d.ts +7 -7
  712. package/dist/webmention/receive.d.ts.map +1 -1
  713. package/dist/webmention/receive.js +4 -4
  714. package/dist/webmention/receive.js.map +1 -1
  715. package/dist/webmention/reply-context/oembed.js +1 -1
  716. package/dist/webmention/reply-context.d.ts +10 -10
  717. package/dist/webmention/reply-context.d.ts.map +1 -1
  718. package/dist/webmention/reply-context.js +5 -5
  719. package/dist/webmention/reply-contexts.d.ts +6 -6
  720. package/dist/webmention/reply-contexts.d.ts.map +1 -1
  721. package/dist/webmention/reply-contexts.js +2 -2
  722. package/dist/webmention/service.d.ts +13 -13
  723. package/dist/webmention/service.js +9 -9
  724. package/dist/webmention/syndication.d.ts +6 -6
  725. package/dist/webmention/syndication.d.ts.map +1 -1
  726. package/dist/webmention/syndication.js +6 -6
  727. package/dist/webmention/syndication.js.map +1 -1
  728. package/package.json +2 -2
@@ -1,17 +1,14 @@
1
- import { avatarHref } from '../avatars/avatars.js';
2
- import { postLabel, postTypeOf } from '../content/post-type.js';
3
- import { RSVP_LABELS } from '../content/rsvp.js';
4
- import { isObjectIdOf, naturalObjectId, objectIdsOf, readObjectIds, } from '../federation/object-ids.js';
5
- import { readAllQuoteAuthorizations } from '../federation/quotes.js';
6
- import { actorHandle, guessedName, quoteFrom, replyFrom, REPLY_ACTIVITY_TYPE, } from '../store/inbox-replies.js';
7
- import { absoluteUrl } from '../util/url.js';
8
- import { authorContext, profileContext, siteAuthorContext } from '../site/authors.js';
9
- import { authorFeedHref, repliesFeedPath } from './feed-source.js';
10
- import { activityStreamsId, permalinkOfObjectId } from '../content/permalinks.js';
11
1
  import { isListed, isServed } from '../content/served.js';
12
2
  import { isKey, commentPageHref, feedGuid, repliesKey } from '../content/guids.js';
13
- import { sanitizeCommentHtml } from '../content/sanitize.js';
14
- import { commentAnchor, commentKeyAt, commentNames, heldComment, isWithheld, visibleReply, } from '../comments/conversation.js';
3
+ import { readAllQuoteAuthorizations } from '../federation/quotes.js';
4
+ import { replyFrom } from '../store/inbox-replies.js';
5
+ import { absoluteUrl } from '../util/url.js';
6
+ import { commentAnchor, commentKeyAt, heldComment, visibleReply, } from '../comments/conversation.js';
7
+ import { authorNaming, federatedInteraction, quotesOf } from './activity-folding.js';
8
+ import { newestFirst } from './conversation-feed.js';
9
+ import { documentAuthor, gather } from './conversation-gather.js';
10
+ import { commentedPost, documentNamed, PostsByObjectId, rootOf, threadRootOf, } from './conversation-lookup.js';
11
+ import { ancestorsOf, byPublished, conversational, countReplies, repliesFed, rsvpGroups, saidIn, sortThread, threadOf, } from './conversation-threads.js';
15
12
  /**
16
13
  * The conversation under a post, in one shape whatever it is made of, and the
17
14
  * one reader everything that shows a conversation asks.
@@ -25,20 +22,16 @@ import { commentAnchor, commentKeyAt, commentNames, heldComment, isWithheld, vis
25
22
  *
26
23
  * Two indexes hold the raw material — `ap_inbox` for what remote servers sent
27
24
  * and `comments` for what the files under `content/_data/comments/` say — and
28
- * this module is the only place outside the comment intake that reads either
29
- * of them to show somebody a conversation. That is the point of it: the thread
25
+ * this module and the ones it reads through (activity folding, gathering,
26
+ * threads, post lookup and the feed adapter) are the only place outside the
27
+ * comment intake that reads either of them to show somebody a conversation.
28
+ * That is the point of it: the thread
30
29
  * under the post, the post's own comments feed, `/comments/feed/` and the
31
30
  * `source:comments` count on a post feed used to merge the same two indexes in
32
31
  * two implementations, which is two chances to disagree about what a reader
33
32
  * may see. Now there is one {@link ConversationReader}, and the page and the
34
33
  * feed are the same reading.
35
34
  */
36
- const RSVP_GROUP_ORDER = ['yes', 'maybe', 'interested', 'no'];
37
- const RSVP_ACTIVITIES = {
38
- Accept: 'yes',
39
- TentativeAccept: 'maybe',
40
- Reject: 'no',
41
- };
42
35
  /**
43
36
  * The reader over one site's two indexes.
44
37
  *
@@ -64,10 +57,6 @@ export function createConversation(base) {
64
57
  /**
65
58
  * The conversation under one post: everything said about it, from every source
66
59
  * the site has, threaded into one.
67
- *
68
- * A post that has never been delivered has no ActivityStreams id and so can
69
- * have no fediverse replies — nothing out there has a name for it yet — but it
70
- * can still have native comments, which hang off its permalink instead.
71
60
  */
72
61
  function postConversation(context, document) {
73
62
  const said = gather(context, document);
@@ -96,194 +85,6 @@ function postConversation(context, document) {
96
85
  },
97
86
  };
98
87
  }
99
- /**
100
- * A repost joins the boosts, because a reader looking at the page is being
101
- * told the same thing by both; a mention is its own group, because it is
102
- * neither an answer nor a reaction.
103
- */
104
- const GROUP_OF = {
105
- reply: 'written',
106
- like: 'likes',
107
- boost: 'boosts',
108
- repost: 'boosts',
109
- mention: 'mentions',
110
- };
111
- function gather(context, document, seen = new Set([document.path])) {
112
- const deliveredObjectId = activityStreamsId(document, context.baseUrl, context.store.now());
113
- const root = rootOf(context, document);
114
- const stored = context.admin.listCommentsFor(document.slug);
115
- const naming = authorNaming(context.admin);
116
- const isEvent = postTypeOf(document) === 'event';
117
- const fediverse = [];
118
- if (deliveredObjectId !== undefined) {
119
- const objectIds = objectIdsOf(readObjectIds(context.contentDir), deliveredObjectId);
120
- fediverse.push(fromQuotes(context, objectIds, naming), fromActivities(context, root, objectIds, stored, naming, isEvent));
121
- }
122
- const comments = fromStored(context, document, stored, isEvent);
123
- const sources = [...fediverse, comments];
124
- const replyPosts = fromReplyPosts(context, document, root, seen, [
125
- ...sources.flatMap(({ said }) => said.flatMap(([group, entry]) => (group === 'written' ? [entry] : []))),
126
- ...(comments.held?.values() ?? []),
127
- ]);
128
- return merged(root, [...sources, replyPosts]);
129
- }
130
- function merged(root, parts) {
131
- const groups = {
132
- written: [],
133
- likes: [],
134
- boosts: [],
135
- mentions: [],
136
- answers: [],
137
- };
138
- const held = new Map();
139
- const withdrawn = new Set();
140
- for (const part of parts) {
141
- for (const [group, entry] of part.said)
142
- groups[group].push(entry);
143
- for (const [id, entry] of part.held ?? [])
144
- held.set(id, entry);
145
- for (const id of part.withdrawn ?? [])
146
- withdrawn.add(id);
147
- }
148
- // Sorted before threading rather than after, because a thread is built by
149
- // walking this list: two sources' entries would otherwise interleave in the
150
- // order the code happened to read them rather than in the order they were
151
- // written.
152
- groups.written.sort(byPublished);
153
- return { root, ...groups, held, withdrawn };
154
- }
155
- function fromQuotes(context, objectIds, naming) {
156
- const approvals = readAllQuoteAuthorizations(context.contentDir);
157
- return {
158
- said: quotesOf(context.admin, approvals, objectIds, naming).map((quote) => ['mentions', quote]),
159
- };
160
- }
161
- function fromActivities(context, root, objectIds, stored, naming, isEvent) {
162
- // What was imported from the fediverse is walked from too: an answer to an
163
- // imported note names the note, which no logged activity may carry.
164
- const origins = stored.flatMap((comment) => comment.source === 'activitypub' && comment.origin !== undefined ? [comment.origin] : []);
165
- const named = new Set(objectIds);
166
- const aboutPost = (activity) => activity.objectId !== null && named.has(activity.objectId);
167
- const activities = activitiesAround(context.admin, [...objectIds, ...origins]);
168
- const withdrawn = withdrawnBy(activities);
169
- const taken = (activityId) => activityId !== null && withdrawn.has(activityId);
170
- // One like per actor, so a like imported from the site this one replaced
171
- // and the same person's like delivered here are one.
172
- const reacted = new Set(stored.flatMap(storedReaction));
173
- const said = [];
174
- for (const activity of activities) {
175
- const answer = isEvent ? RSVP_ACTIVITIES[activity.activityType] : undefined;
176
- if (answer !== undefined) {
177
- if (!aboutPost(activity) || taken(activity.activityId))
178
- continue;
179
- said.push([
180
- 'answers',
181
- {
182
- ...reaction(activity, naming, `${activity.actorId}#rsvp`),
183
- kind: 'reply',
184
- rsvp: { value: answer, label: RSVP_LABELS[answer] },
185
- },
186
- ]);
187
- continue;
188
- }
189
- const kind = REACTIONS[activity.activityType];
190
- if (kind !== undefined) {
191
- // Only a reaction to the post itself: a like of one of the replies
192
- // belongs to that reply's own conversation, wherever it is shown.
193
- if (!aboutPost(activity))
194
- continue;
195
- // One like per actor, however many times it was delivered, and none
196
- // at all once its actor has taken it back.
197
- const key = reactionKey(kind, activity.actorId);
198
- if (reacted.has(key) || taken(activity.activityId))
199
- continue;
200
- if (activity.activityId !== null &&
201
- heldComment(context.admin, activity.activityId) !== undefined) {
202
- continue;
203
- }
204
- reacted.add(key);
205
- said.push([
206
- GROUP_OF[kind],
207
- { ...reaction(activity, naming, `${activity.actorId}#${kind}`), kind },
208
- ]);
209
- continue;
210
- }
211
- const found = replyFrom(activity);
212
- if (found === undefined || heldComment(context.admin, found.id) !== undefined)
213
- continue;
214
- const reply = named.has(found.inReplyTo) ? { ...found, inReplyTo: root } : found;
215
- const parent = heldComment(context.admin, reply.inReplyTo);
216
- said.push([
217
- 'written',
218
- federatedInteraction(parent === undefined ? reply : { ...reply, inReplyTo: parent.id }, naming(activity.actorId)),
219
- ]);
220
- }
221
- return { said, withdrawn };
222
- }
223
- function storedReaction({ kind, actor }) {
224
- const group = GROUP_OF[kind];
225
- return actor === undefined || (group !== 'likes' && group !== 'boosts')
226
- ? []
227
- : [reactionKey(kind, actor)];
228
- }
229
- function reactionKey(kind, actor) {
230
- return `${GROUP_OF[kind]}\0${actor}`;
231
- }
232
- function reaction(activity, naming, fallbackId) {
233
- const author = naming(activity.actorId);
234
- return {
235
- ...unstored(activity.activityId ?? fallbackId),
236
- source: 'activitypub',
237
- author,
238
- url: author.url,
239
- content: '',
240
- published: new Date(activity.receivedAt),
241
- inReplyTo: null,
242
- status: 'published',
243
- replies: [],
244
- };
245
- }
246
- function fromStored(context, document, stored, isEvent) {
247
- const users = context.users();
248
- const said = [];
249
- const held = new Map();
250
- for (const record of stored) {
251
- const comment = interactionOf(record, document.permalink, context.baseUrl, users);
252
- if (record.status !== 'approved') {
253
- held.set(comment.id, comment);
254
- continue;
255
- }
256
- const group = isEvent && comment.rsvp !== undefined ? 'answers' : GROUP_OF[comment.kind];
257
- said.push([group, { ...comment, replies: [] }]);
258
- }
259
- return { said, held };
260
- }
261
- /**
262
- * The reply posts answering the post or anything said under it, each
263
- * bringing what was said under it: an answer to a reply post lands against
264
- * the reply post, and this is what stitches it into the thread it is in.
265
- */
266
- function fromReplyPosts(context, document, root, seen, answered) {
267
- const names = namesIn(context, document, root, answered);
268
- const said = [];
269
- const held = new Map();
270
- const withdrawn = new Set();
271
- for (const answer of context.store.listRepliesTo([...names.keys()])) {
272
- const target = names.get(answer.inReplyTo ?? '');
273
- if (target === undefined || seen.has(answer.path))
274
- continue;
275
- const under = gather(context, answer, new Set([...seen, answer.path]));
276
- const top = (entry) => entry.inReplyTo === null ? { ...entry, inReplyTo: under.root } : entry;
277
- said.push(['written', replyPostInteraction(context, answer, under.root, target)]);
278
- for (const entry of under.written)
279
- said.push(['written', top(entry)]);
280
- for (const [id, entry] of under.held)
281
- held.set(id, top(entry));
282
- for (const id of under.withdrawn)
283
- withdrawn.add(id);
284
- }
285
- return { said, held, withdrawn };
286
- }
287
88
  /**
288
89
  * One native comment's page: the comment, its replies threaded under it by
289
90
  * the rule the post's thread uses, and the chain from it up to the post.
@@ -292,16 +93,6 @@ function fromReplyPosts(context, document, root, seen, answered) {
292
93
  * the post, so a reply the post's thread shows is shown here, and one it
293
94
  * leaves out is left out here.
294
95
  */
295
- /**
296
- * The post an approved native comment is on, read from the comment's record
297
- * alone, without gathering the post's whole conversation.
298
- */
299
- export function commentedPost(context, key) {
300
- const stored = context.admin.getComment(key);
301
- if (stored?.source !== 'comment' || stored.status !== 'approved')
302
- return undefined;
303
- return context.store.getBySlug(stored.slug);
304
- }
305
96
  function commentThread(context, id) {
306
97
  const post = commentedPost(context, id);
307
98
  if (post === undefined)
@@ -353,7 +144,7 @@ function repliesTo(context, key) {
353
144
  if (!isKey(key))
354
145
  return undefined;
355
146
  // Each source's index is asked in turn, so a key naming nothing costs three
356
- // lookups and no more (TASK-327).
147
+ // lookups and no more.
357
148
  const [document] = context.store.listByRepliesKey(key);
358
149
  if (document !== undefined) {
359
150
  if (repliesKey(feedGuid(document, context.baseUrl)) === key) {
@@ -446,139 +237,6 @@ function upstreamsOf(context, document) {
446
237
  }
447
238
  return found;
448
239
  }
449
- /**
450
- * The document whose conversation a URL is in: the post a comment's page or
451
- * anchor is on, the post a webmention was sent to, the post a fediverse reply
452
- * answers however deep, or the document at the URL itself.
453
- */
454
- function documentNamed(context, url, depth = 0) {
455
- if (depth > MAXIMUM_NOTE_DEPTH)
456
- return undefined;
457
- let named;
458
- try {
459
- named = new URL(url);
460
- }
461
- catch {
462
- return undefined;
463
- }
464
- if (named.origin === new URL(context.baseUrl).origin) {
465
- const key = commentKeyAt(named.pathname);
466
- if (key !== undefined) {
467
- const comment = context.admin.getComment(key);
468
- return comment === undefined ? undefined : context.store.getBySlug(comment.slug);
469
- }
470
- return ownDocumentNamed(context, named.href);
471
- }
472
- const comment = context.admin.listCommentsAt(named.href)[0] ?? heldComment(context.admin, named.href);
473
- if (comment !== undefined)
474
- return context.store.getBySlug(comment.slug);
475
- for (const activity of context.admin.listActivitiesAbout([named.href])) {
476
- const reply = replyFrom(activity);
477
- if (reply?.id !== named.href)
478
- continue;
479
- return documentNamed(context, reply.inReplyTo, depth + 1);
480
- }
481
- return context.store.getByStoredObjectId(named.href);
482
- }
483
- /**
484
- * The document one of this site's own URLs names: the one at the permalink it
485
- * spells, or the post whose file stores it as its id. A query string rules the
486
- * permalink out, as it does for {@link permalinkOfObjectId}, unless it is a
487
- * revision the post was federated under; one it was never given names nothing.
488
- */
489
- function ownDocumentNamed(context, url) {
490
- const natural = naturalObjectId(url);
491
- if (!isObjectIdOf(readObjectIds(context.contentDir), natural, url))
492
- return undefined;
493
- const permalink = permalinkOfObjectId(natural, context.baseUrl);
494
- const found = permalink === undefined ? undefined : context.store.getByPermalink(permalink);
495
- return found ?? context.store.getByStoredObjectId(natural);
496
- }
497
- /**
498
- * The document at the top of the conversation a reply post is in: what its
499
- * `in-reply-to` names, and what that one is in when it is a reply post too.
500
- * `undefined` for a reply post answering nothing on this site.
501
- */
502
- function threadRootOf(context, document, seen = new Set()) {
503
- seen.add(document.path);
504
- if (document.inReplyTo === undefined)
505
- return undefined;
506
- const named = documentNamed(context, document.inReplyTo);
507
- if (named === undefined || seen.has(named.path))
508
- return undefined;
509
- return threadRootOf(context, named, seen) ?? named;
510
- }
511
- /** How many notes deep a reply is followed back to the post it is about. */
512
- const MAXIMUM_NOTE_DEPTH = 32;
513
- /**
514
- * What a top-level answer names. The object id when the post has one, and the
515
- * permalink otherwise: a post that has never been delivered can still have
516
- * native comments, and they have to hang off something.
517
- */
518
- function rootOf(context, document) {
519
- return activityStreamsId(document, context.baseUrl, context.store.now()) ?? document.permalink;
520
- }
521
- /**
522
- * Every URL a reply post's `in-reply-to` could name something here by, and the
523
- * id each one names: the post by its permalink, every URL it used to live at
524
- * and every object id it has had, and every entry by its id, its url and, for
525
- * a comment written here, its page and its anchor.
526
- */
527
- function namesIn(context, document, root, replies) {
528
- const permalink = absoluteUrl(document.permalink, context.baseUrl);
529
- const former = (document.redirectFrom ?? []).map((url) => absoluteUrl(url, context.baseUrl));
530
- const objectIds = objectIdsOf(readObjectIds(context.contentDir), root);
531
- const names = new Map([permalink, ...former, ...objectIds].map((url) => [url, root]));
532
- for (const reply of replies) {
533
- for (const name of namesOf(reply, permalink, context.baseUrl)) {
534
- if (!names.has(name))
535
- names.set(name, reply.id);
536
- }
537
- }
538
- return names;
539
- }
540
- function namesOf(reply, permalink, baseUrl) {
541
- const names = [reply.id];
542
- if (reply.url !== null)
543
- names.push(absoluteUrl(reply.url, baseUrl));
544
- if (reply.source === 'comment')
545
- names.push(...commentNames(reply.id, permalink, baseUrl));
546
- return names;
547
- }
548
- /** A reply post as the thread's own shape, answering `inReplyTo`. */
549
- function replyPostInteraction(context, post, id, inReplyTo) {
550
- return {
551
- ...unstored(id),
552
- source: 'post',
553
- kind: 'reply',
554
- author: documentAuthor(context, post),
555
- url: post.permalink,
556
- content: post.html,
557
- published: new Date(post.date ?? post.updated ?? 0),
558
- inReplyTo,
559
- status: 'published',
560
- replies: [],
561
- };
562
- }
563
- /** Who a post or page on this site is by: its author, else the site's. */
564
- function documentAuthor(context, post) {
565
- const users = context.users();
566
- const { site } = context;
567
- const author = authorContext(users, post.author) ?? siteAuthorContext(users, site.author);
568
- return bylineAuthor(author, site.title);
569
- }
570
- /** A byline as the thread names its author, `fallback` when it names nobody. */
571
- function bylineAuthor(author, fallback) {
572
- return {
573
- name: author?.name ?? fallback,
574
- handle: null,
575
- url: author?.url ?? null,
576
- avatar: author?.avatar ?? null,
577
- actorId: null,
578
- feed: author?.username === undefined ? null : authorFeedHref(author.username, 'rss'),
579
- username: author?.username ?? null,
580
- };
581
- }
582
240
  /** The key a URL on this site names by a comment's page or by an anchor on the post. */
583
241
  function keyNamedBy(url, document, baseUrl) {
584
242
  const post = new URL(absoluteUrl(document.permalink, baseUrl));
@@ -592,50 +250,6 @@ function keyNamedBy(url, document, baseUrl) {
592
250
  return undefined;
593
251
  return url.hash.slice(anchor.length);
594
252
  }
595
- /**
596
- * What a reply answers, from the top of the thread down to its parent.
597
- *
598
- * An ancestor a reader may not see is a `null`, and the walk goes on through
599
- * what that one answered when the site still knows it: a pending or spam
600
- * comment is in the index, and a withdrawn note is still in the log. A deleted
601
- * comment is known by nothing, so the chain stops at it and goes straight to
602
- * the post. Each id is visited once, so a cycle ends.
603
- */
604
- function ancestorsOf(said, reply) {
605
- const all = new Map(said.written.map((entry) => [entry.id, entry]));
606
- const chain = [];
607
- const seen = new Set([reply.id]);
608
- for (let target = reply.inReplyTo; target !== null && target !== said.root;) {
609
- if (seen.has(target))
610
- break;
611
- seen.add(target);
612
- const known = all.get(target);
613
- if (known !== undefined && !said.withdrawn.has(target)) {
614
- chain.unshift(known);
615
- target = known.inReplyTo;
616
- continue;
617
- }
618
- chain.unshift(null);
619
- target = (known ?? said.held.get(target))?.inReplyTo ?? null;
620
- }
621
- return chain;
622
- }
623
- function rsvpGroups(answers) {
624
- const people = latestAnswerPerPerson(answers);
625
- return RSVP_GROUP_ORDER.map((value) => ({
626
- value,
627
- label: RSVP_LABELS[value],
628
- people: people.filter((person) => person.rsvp?.value === value),
629
- })).filter((group) => group.people.length > 0);
630
- }
631
- function latestAnswerPerPerson(answers) {
632
- const latest = new Map();
633
- for (const answer of [...answers].sort(byPublished)) {
634
- const { author } = answer;
635
- latest.set(author.actorId ?? author.url ?? answer.id, answer);
636
- }
637
- return [...latest.values()].sort(byPublished);
638
- }
639
253
  /**
640
254
  * The whole site's latest answers, newest first, each with its post.
641
255
  *
@@ -740,458 +354,4 @@ function directCounts(context, documents) {
740
354
  * whose posts do not.
741
355
  */
742
356
  const OVERSCAN = 4;
743
- /**
744
- * The approved quotes of one post, as mentions, in no order.
745
- *
746
- * The approval is what makes a quote showable (FEP-044f: a quote its author
747
- * never approved should not be displayed), so the approvals are walked and the
748
- * log is asked for each one's note, rather than the other way about. The note
749
- * has to be the approved one, by the approved actor, quoting this post: an
750
- * approval of one quote vouches for nothing else. Both are files (decision-9),
751
- * so a rebuilt index shows exactly what the live one did.
752
- */
753
- function quotesOf(admin, approvals, objectIds, naming) {
754
- const quotes = [];
755
- for (const approval of approvals) {
756
- if (!objectIds.includes(approval.post))
757
- continue;
758
- for (const activity of admin.listActivitiesAbout([approval.quote])) {
759
- if (activity.actorId !== approval.actor)
760
- continue;
761
- const quote = quoteFrom(activity);
762
- if (quote?.id !== approval.quote || !objectIds.includes(quote.quoted))
763
- continue;
764
- quotes.push({
765
- ...unstored(quote.id),
766
- source: 'activitypub',
767
- kind: 'mention',
768
- author: naming(quote.actorId),
769
- url: quote.url,
770
- content: sanitizeCommentHtml(quote.html),
771
- published: quote.published,
772
- inReplyTo: null,
773
- status: 'published',
774
- replies: [],
775
- });
776
- // The first `Create` of the note is the one shown: a redelivery is the
777
- // same quote again.
778
- break;
779
- }
780
- }
781
- return quotes;
782
- }
783
- /** One logged fediverse reply as the thread's own shape. */
784
- function federatedInteraction(reply, author) {
785
- return {
786
- ...unstored(reply.id),
787
- source: 'activitypub',
788
- kind: 'reply',
789
- author,
790
- url: reply.url,
791
- // Sanitised here, at the edge of the site, so the page and the feed
792
- // republish the same checked markup rather than each checking for itself.
793
- content: sanitizeCommentHtml(reply.html),
794
- published: reply.published,
795
- inReplyTo: reply.inReplyTo,
796
- status: 'published',
797
- replies: [],
798
- };
799
- }
800
- function unstored(id) {
801
- return { id, key: repliesKey(id), guid: id, migrated: false };
802
- }
803
- /** One stored comment as the thread's own shape. */
804
- function interactionOf(comment, permalink, baseUrl, users) {
805
- // A user the site no longer has is named as the comment was signed.
806
- const user = users.find((candidate) => candidate.username === comment.user);
807
- return {
808
- id: comment.id,
809
- key: comment.id,
810
- guid: comment.source === 'comment'
811
- ? absoluteUrl(commentPageHref(comment.id), baseUrl)
812
- : (comment.origin ?? comment.url ?? comment.id),
813
- migrated: comment.migrated === true,
814
- source: comment.source,
815
- kind: comment.kind,
816
- author: user === undefined
817
- ? {
818
- name: comment.author.name,
819
- handle: comment.actor === undefined ? null : (actorHandle(comment.actor) ?? null),
820
- url: comment.author.url,
821
- avatar: comment.author.avatar === null ? null : avatarHref(comment.author.avatar),
822
- actorId: comment.actor ?? null,
823
- feed: comment.source === 'webmention' ? comment.author.url : null,
824
- username: null,
825
- }
826
- : bylineAuthor(profileContext(user), comment.author.name),
827
- // Where it can be read. A comment written here has a page of its own
828
- // (TASK-318); a webmention lives on the page it was sent from, and its
829
- // `url` says so. A theme that prints `url` for a fediverse reply prints a
830
- // working link for either, and so does a feed.
831
- url: comment.url ??
832
- (comment.source === 'comment'
833
- ? commentPageHref(comment.id)
834
- : `${permalink}#${commentAnchor(comment.id)}`),
835
- content: comment.content.html,
836
- published: new Date(comment.submitted),
837
- inReplyTo: comment.inReplyTo,
838
- status: comment.status,
839
- replies: [],
840
- ...(comment.rsvp === undefined
841
- ? {}
842
- : { rsvp: { value: comment.rsvp, label: RSVP_LABELS[comment.rsvp] } }),
843
- };
844
- }
845
- /** What a post's comments feed carries, at every depth and in no order. */
846
- export function spokenIn(conversation) {
847
- return saidIn(conversation).filter(conversational);
848
- }
849
- /** The mentions and every visible reply of a conversation, each with its parent. */
850
- function saidIn(conversation) {
851
- return [
852
- ...conversation.mentions.map((mention) => ({ ...mention, parent: null })),
853
- ...placed(conversation.replies),
854
- ];
855
- }
856
- /**
857
- * Whether a feed carries it and a reply count counts it (TASK-335): somebody's
858
- * words, a reply or a mention, said here. A like, a boost or a repost says
859
- * nothing — "@ada liked this" would be an item with an empty body — and a
860
- * migrated entry was published before the site came here, so a reader must
861
- * not see it as new.
862
- */
863
- function conversational(entry) {
864
- return !entry.migrated && (entry.kind === 'reply' || entry.kind === 'mention');
865
- }
866
- /** Every visible reply of a thread at any depth, each with the reply it sits under. */
867
- function placed(replies, parent = null) {
868
- return directReplies(replies).flatMap((reply) => [
869
- { ...reply, parent },
870
- ...placed(reply.replies, reply),
871
- ]);
872
- }
873
- /**
874
- * The visible replies directly under an entry of a thread (TASK-324): a
875
- * hidden comment's visible replies count as its parent's, as {@link Placed}
876
- * says, so every visible reply is directly under exactly one thing.
877
- */
878
- function directReplies(replies) {
879
- return replies.flatMap((reply) => (isWithheld(reply) ? directReplies(reply.replies) : [reply]));
880
- }
881
- /** The direct replies a feed carries and a count advertises. */
882
- function repliesFed(replies) {
883
- return directReplies(replies).filter(conversational);
884
- }
885
- /**
886
- * Interactions as a comments feed carries them: newest first, at most `limit`,
887
- * and every link absolute.
888
- *
889
- * The one place an interaction becomes a feed item, so the post's feed and the
890
- * site's cannot disagree about what a comment's `guid` or `link` is. The HTML
891
- * is handed over as it stands and sanitised by the feed itself, at the last
892
- * moment before it becomes bytes this site publishes.
893
- */
894
- export function feedComments(said, options) {
895
- const { baseUrl } = options;
896
- return newestFirst([...said], options.limit).map((entry) => {
897
- const thread = entry.post ?? options.post;
898
- const answered = entry.parent === null
899
- ? thread === undefined
900
- ? undefined
901
- : feedGuid(thread, baseUrl)
902
- : entry.parent.guid;
903
- const replies = repliesFed(entry.replies);
904
- return {
905
- id: entry.guid,
906
- url: absoluteUrl(entry.url ?? '/', baseUrl),
907
- author: entry.author.name,
908
- published: entry.published,
909
- html: entry.content,
910
- ...(answered === undefined ? {} : { inReplyTo: answered }),
911
- ...(replies.length === 0
912
- ? {}
913
- : {
914
- replies: {
915
- count: replies.length,
916
- feed: absoluteUrl(repliesFeedPath(entry.key), baseUrl),
917
- },
918
- }),
919
- ...(entry.author.feed === null
920
- ? {}
921
- : { authorFeed: absoluteUrl(entry.author.feed, baseUrl) }),
922
- ...(entry.post === undefined
923
- ? {}
924
- : {
925
- post: { title: postLabel(entry.post, options.cited), permalink: entry.post.permalink },
926
- }),
927
- ...(entry.replyingTo === undefined || entry.replyingTo === null
928
- ? {}
929
- : { replyingTo: entry.replyingTo }),
930
- };
931
- });
932
- }
933
- /** The newest `limit` of a mixed list, which is the order every feed shows. */
934
- function newestFirst(said, limit) {
935
- return said
936
- .sort((left, right) => right.published.getTime() - left.published.getTime())
937
- .slice(0, limit);
938
- }
939
- /**
940
- * The public post an ActivityStreams object id names, memoised.
941
- *
942
- * Almost every id is the post's permalink (decision-13), so the permalink is
943
- * looked up first and the answer is checked against the document's own id — a
944
- * post that is no longer public has no id at all. Only when that fails is the
945
- * whole index read, once, to find the post whose file names this id: a post
946
- * migrated from WordPress keeps the `?p=813` its followers already hold, and
947
- * no permalink spells that.
948
- */
949
- class PostsByObjectId {
950
- #context;
951
- #found = new Map();
952
- #all;
953
- constructor(context) {
954
- this.#context = context;
955
- }
956
- get(objectId) {
957
- if (!this.#found.has(objectId))
958
- this.#found.set(objectId, this.#resolve(objectId));
959
- return this.#found.get(objectId);
960
- }
961
- #resolve(objectId) {
962
- const natural = naturalObjectId(objectId);
963
- if (!isObjectIdOf(readObjectIds(this.#context.contentDir), natural, objectId))
964
- return undefined;
965
- const permalink = permalinkOfObjectId(natural, this.#context.baseUrl);
966
- if (permalink !== undefined) {
967
- const document = this.#context.store.getByPermalink(permalink);
968
- if (document !== undefined &&
969
- activityStreamsId(document, this.#context.baseUrl, this.#context.store.now()) === natural) {
970
- return document;
971
- }
972
- }
973
- return this.#everything().get(natural);
974
- }
975
- #everything() {
976
- if (this.#all === undefined) {
977
- this.#all = new Map();
978
- for (const document of this.#context.store.listPosts()) {
979
- const id = activityStreamsId(document, this.#context.baseUrl, this.#context.store.now());
980
- if (id !== undefined)
981
- this.#all.set(id, document);
982
- }
983
- }
984
- return this.#all;
985
- }
986
- }
987
- /**
988
- * The replies as a thread: those answering `under` at the top, each carrying
989
- * the replies that answer it, oldest first at every level. `under` is the
990
- * post, or one reply for that reply's own page.
991
- *
992
- * Four things decide where a reply goes, and all four are what somebody
993
- * reading the page would expect:
994
- *
995
- * - A reply whose target is gone — deleted by its author — is shown under
996
- * whatever *that* was answering, rather than disappearing with it. The
997
- * conversation stays readable and only the withdrawn note is missing.
998
- * - A reply answering a native comment a reader may not see (TASK-325) is
999
- * shown under a placeholder for it, the way the reply's own page shows it.
1000
- * A comment waiting for a moderator or filed as spam still says what it
1001
- * answers, and the placeholder goes there; a deleted one is known by
1002
- * nothing, so its placeholder goes under the post. A hidden comment nobody
1003
- * visible answered gets no placeholder at all.
1004
- * - A reply answering something that is no part of this conversation is left
1005
- * out. The log holds it because it named something this walk asked about — a
1006
- * note answering the like of a post is the shape of that — but the post is
1007
- * not what it is talking about.
1008
- * - A note the site was told about twice is one reply, because the map is
1009
- * keyed by the note's own id.
1010
- *
1011
- * The walk is bounded by the number of notes, and a placeholder is made once,
1012
- * so a log carrying a cycle — two notes each claiming to answer the other,
1013
- * which nothing stops a remote server from sending — ends rather than hangs.
1014
- */
1015
- function threadOf(said, under = said.root) {
1016
- const shown = new Map();
1017
- const targets = new Map();
1018
- for (const reply of said.written) {
1019
- targets.set(reply.id, reply.inReplyTo ?? said.root);
1020
- if (!said.withdrawn.has(reply.id))
1021
- shown.set(reply.id, reply);
1022
- }
1023
- const top = [];
1024
- const withheld = new Map();
1025
- // The list an entry answering `target` joins, or `undefined` for one that
1026
- // belongs somewhere else. Only a native entry can answer a deleted comment:
1027
- // a fediverse note naming an unknown id is answering something else.
1028
- const siblings = (target, self, native) => {
1029
- for (let step = 0; step <= targets.size; step += 1) {
1030
- if (target === undefined)
1031
- return undefined;
1032
- if (target === under)
1033
- return top;
1034
- if (target === said.root)
1035
- return undefined;
1036
- const parent = shown.get(target);
1037
- if (parent !== undefined)
1038
- return parent.id === self ? undefined : parent.replies;
1039
- if (said.held.has(target) || (native && !targets.has(target))) {
1040
- return placeholder(target)?.replies;
1041
- }
1042
- target = targets.get(target);
1043
- }
1044
- return undefined;
1045
- };
1046
- const placeholder = (id) => {
1047
- if (withheld.has(id))
1048
- return withheld.get(id);
1049
- withheld.set(id, undefined);
1050
- const list = siblings(said.held.get(id)?.inReplyTo ?? said.root, id, true);
1051
- if (list === undefined)
1052
- return undefined;
1053
- const key = isKey(id) ? id : repliesKey(id);
1054
- const entry = { id, key, withheld: true, replies: [] };
1055
- list.push(entry);
1056
- withheld.set(id, entry);
1057
- return entry;
1058
- };
1059
- for (const reply of shown.values()) {
1060
- siblings(targets.get(reply.id), reply.id, reply.source !== 'activitypub')?.push(reply);
1061
- }
1062
- return top;
1063
- }
1064
- /** Oldest first, which is the order a conversation reads in. */
1065
- function byPublished(left, right) {
1066
- return left.published.getTime() - right.published.getTime();
1067
- }
1068
- /**
1069
- * When a thread entry starts: a reply's own date, and a placeholder's first
1070
- * visible reply's, since the date of a hidden comment is not the reader's.
1071
- */
1072
- function startOf(reply) {
1073
- if (!isWithheld(reply))
1074
- return reply.published.getTime();
1075
- const [first] = reply.replies;
1076
- return first === undefined ? 0 : startOf(first);
1077
- }
1078
- /** Put every level of a thread in time order, all the way down. */
1079
- function sortThread(replies) {
1080
- for (const reply of replies)
1081
- sortThread(reply.replies);
1082
- replies.sort((left, right) => startOf(left) - startOf(right));
1083
- }
1084
- /** How many visible replies a thread holds, counting all the way down. */
1085
- function countReplies(replies) {
1086
- let total = 0;
1087
- for (const reply of replies)
1088
- total += (isWithheld(reply) ? 0 : 1) + countReplies(reply.replies);
1089
- return total;
1090
- }
1091
- /** The two reactions, as the activity types they arrive as. */
1092
- const REACTIONS = {
1093
- Like: 'like',
1094
- Announce: 'boost',
1095
- };
1096
- /**
1097
- * Every logged activity that has anything to do with a post, oldest first.
1098
- *
1099
- * The log is walked outwards rather than queried once: a reply names the post,
1100
- * a reply to that reply names the reply, and a `Delete` or an `Undo` names the
1101
- * activity it takes back. Each round asks about everything the last round
1102
- * turned up — the object an activity carried and the activity's own id — and
1103
- * stops when a round finds nothing new, which it must, because a row is
1104
- * collected once and there are finitely many.
1105
- */
1106
- function activitiesAround(admin, objectIds) {
1107
- const collected = new Map();
1108
- const asked = new Set(objectIds);
1109
- let frontier = [...asked];
1110
- while (frontier.length > 0) {
1111
- const next = [];
1112
- for (const activity of admin.listActivitiesAbout(frontier)) {
1113
- if (collected.has(activity.id))
1114
- continue;
1115
- collected.set(activity.id, activity);
1116
- for (const id of [activity.objectId, activity.activityId]) {
1117
- if (id === null || asked.has(id))
1118
- continue;
1119
- asked.add(id);
1120
- next.push(id);
1121
- }
1122
- }
1123
- frontier = next;
1124
- }
1125
- // Row ids are the order things arrived in, and the rounds above return them
1126
- // out of that order.
1127
- return [...collected.values()].sort((left, right) => left.id - right.id);
1128
- }
1129
- /**
1130
- * The ids of everything an actor has taken back: the likes and boosts undone,
1131
- * and the notes deleted.
1132
- *
1133
- * Only by the actor that did it in the first place. Without that check any
1134
- * signed actor could delete somebody else's comment off this page, since the
1135
- * activity carrying the instruction is signed by its sender and says nothing
1136
- * about who the thing it names belonged to — which is the rule the inbox
1137
- * already applies to an `Undo(Follow)`.
1138
- */
1139
- function withdrawnBy(activities) {
1140
- const owners = new Map();
1141
- for (const activity of activities) {
1142
- if (activity.activityId !== null)
1143
- owners.set(activity.activityId, activity.actorId);
1144
- if (activity.objectId !== null && activity.activityType === REPLY_ACTIVITY_TYPE) {
1145
- owners.set(activity.objectId, activity.actorId);
1146
- }
1147
- }
1148
- const withdrawn = new Set();
1149
- for (const activity of activities) {
1150
- if (activity.activityType !== 'Undo' && activity.activityType !== 'Delete')
1151
- continue;
1152
- if (activity.objectId === null)
1153
- continue;
1154
- if (owners.get(activity.objectId) !== activity.actorId)
1155
- continue;
1156
- withdrawn.add(activity.objectId);
1157
- }
1158
- return withdrawn;
1159
- }
1160
- /**
1161
- * How an actor is named, memoised for the length of one conversation.
1162
- *
1163
- * A follower is named from the profile it published when it followed, and
1164
- * anybody else from the profile the site fetched when they were first heard
1165
- * from (TASK-184). Both are read from the database: nothing is fetched while a
1166
- * page is drawn. Only an actor neither knows is named by a guess from their
1167
- * URL, which is their server when the URL ends in a number.
1168
- */
1169
- function authorNaming(admin) {
1170
- const known = new Map();
1171
- // Read once, on the first unknown actor, rather than per actor: the
1172
- // followers are one row per (user, actor) now (decision-14), so the same
1173
- // stranger may be on the list several times and any of those rows names them
1174
- // the same way — the columns read here are the actor's own name and picture.
1175
- let followers;
1176
- return (actorId) => {
1177
- const held = known.get(actorId);
1178
- if (held !== undefined)
1179
- return held;
1180
- followers ??= new Map(admin.listFollowers().map((entry) => [entry.actorId, entry]));
1181
- const profile = followers.get(actorId) ?? admin.getActorProfile(actorId);
1182
- const handle = profile?.handle ?? actorHandle(actorId) ?? null;
1183
- const icon = profile?.iconUrl ?? null;
1184
- const author = {
1185
- name: profile?.name ?? handle ?? guessedName(actorId),
1186
- handle,
1187
- url: profile?.url ?? actorId,
1188
- avatar: icon === null ? null : avatarHref(icon),
1189
- actorId,
1190
- feed: null,
1191
- username: null,
1192
- };
1193
- known.set(actorId, author);
1194
- return author;
1195
- };
1196
- }
1197
357
  //# sourceMappingURL=conversation.js.map