@fedify/fedify 1.10.5 → 1.10.7

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 (281) hide show
  1. package/dist/{actor-CjkHF7Cj.cjs → actor-BGIAXtRd.cjs} +3112 -4674
  2. package/dist/{actor-Ch9BTg3N.js → actor-C-_2S5Mn.mjs} +8 -15
  3. package/dist/{actor-CQdxP8N-.js → actor-Cujbx4Zv.js} +1205 -2768
  4. package/dist/{actor-eeONG_sv.d.ts → actor-DXwwgFeR.d.ts} +3 -3
  5. package/dist/{actor-D190nbTD.d.cts → actor-DxvGbmjm.d.cts} +3 -3
  6. package/dist/{assert-MZs1qjMx.js → assert-DikXweDx.mjs} +5 -9
  7. package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
  8. package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
  9. package/dist/{assert_is_error-BPGph1Jx.js → assert_is_error-C50x8tnw.mjs} +5 -9
  10. package/dist/{assert_not_equals-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
  11. package/dist/{assert_rejects-DiIiJbZn.js → assert_rejects-CJC9ThS-.mjs} +6 -11
  12. package/dist/{assert_throws-BOO88avQ.js → assert_throws-BIL7gChy.mjs} +6 -10
  13. package/dist/{authdocloader-fR-Fqcpa.js → authdocloader-1Sk2bqFx.mjs} +9 -14
  14. package/dist/{authdocloader-COFZT9Wh.js → authdocloader-D4Y6iyTF.js} +8 -15
  15. package/dist/{authdocloader-zc5ibOmU.cjs → authdocloader-DQfruCir.cjs} +14 -22
  16. package/dist/{builder-YD0q32nG.js → builder-CZbrDRl7.mjs} +31 -40
  17. package/dist/{client-B3mQJNO7.d.ts → client-D7t26_op.d.ts} +2 -2
  18. package/dist/{client-BgCucCG7.js → client-Dyb8MI3u.mjs} +11 -15
  19. package/dist/{client-n6L4GtQL.d.cts → client-yc0Z0P6Y.d.cts} +2 -2
  20. package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.mjs} +7 -12
  21. package/dist/compat/mod.cjs +5 -8
  22. package/dist/compat/mod.d.cts +78 -12
  23. package/dist/compat/mod.d.ts +78 -12
  24. package/dist/compat/mod.js +4 -8
  25. package/dist/compat/transformers.test.mjs +62 -0
  26. package/dist/{context-Cr5DIxq_.d.ts → context-C6n2yrj0.d.ts} +33 -26
  27. package/dist/{context-WJoO0SQs.d.cts → context-PfghnHYj.d.cts} +33 -26
  28. package/dist/{denokv-D0nfNQ1x.js → denokv-NJPMXyK0.mjs} +22 -11
  29. package/dist/{docloader-BucCRHZI.d.ts → docloader-D7k5A9JP.d.ts} +2 -7
  30. package/dist/{docloader-ChxNLZAA.d.cts → docloader-DbM94pGY.d.cts} +2 -7
  31. package/dist/{docloader-BETPdM09.js → docloader-Dtaju6oI.js} +18 -156
  32. package/dist/{docloader-irBWMSOZ.cjs → docloader-Q3DfzuUi.cjs} +116 -220
  33. package/dist/{esm-iGH0sRsE.js → esm-DOJg552-.mjs} +49 -85
  34. package/dist/federation/{builder.test.js → builder.test.mjs} +22 -41
  35. package/dist/federation/collection.test.d.mts +2 -0
  36. package/dist/federation/collection.test.mjs +21 -0
  37. package/dist/federation/handler.test.d.mts +2 -0
  38. package/dist/federation/{handler.test.js → handler.test.mjs} +29 -58
  39. package/dist/federation/idempotency.test.d.mts +2 -0
  40. package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +29 -59
  41. package/dist/federation/inbox.test.d.mts +2 -0
  42. package/dist/federation/{inbox.test.js → inbox.test.mjs} +10 -15
  43. package/dist/federation/keycache.test.d.mts +2 -0
  44. package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -18
  45. package/dist/federation/kv.test.d.mts +2 -0
  46. package/dist/federation/{kv.test.js → kv.test.mjs} +12 -26
  47. package/dist/federation/middleware.test.d.mts +2 -0
  48. package/dist/federation/{middleware.test.js → middleware.test.mjs} +182 -197
  49. package/dist/federation/mod.cjs +245 -21
  50. package/dist/federation/mod.d.cts +4 -13
  51. package/dist/federation/mod.d.ts +4 -13
  52. package/dist/federation/mod.js +240 -18
  53. package/dist/federation/mq.test.d.mts +2 -0
  54. package/dist/federation/{mq.test.js → mq.test.mjs} +23 -38
  55. package/dist/federation/retry.test.d.mts +2 -0
  56. package/dist/federation/{retry.test.js → retry.test.mjs} +9 -14
  57. package/dist/federation/router.test.d.mts +2 -0
  58. package/dist/federation/{router.test.js → router.test.mjs} +12 -19
  59. package/dist/federation/send.test.d.mts +2 -0
  60. package/dist/federation/{send.test.js → send.test.mjs} +24 -34
  61. package/dist/{http-PgdBoDIj.js → http-BRwSVBn1.mjs} +16 -32
  62. package/dist/{http-DS9z_HzB.d.ts → http-BYXQvoZQ.d.ts} +5 -9
  63. package/dist/{http-C_1RU1U_.d.cts → http-CMzg-A9P.d.cts} +5 -9
  64. package/dist/{http-CQAqR_vx.cjs → http-DCrun8ql.cjs} +51 -68
  65. package/dist/{http-CxiIW4rD.js → http-DRnRwr3i.js} +17 -33
  66. package/dist/{inbox-DcDIqTbR.js → inbox-pD1nbb_5.mjs} +17 -25
  67. package/dist/key-Cmbps6xt.cjs +4 -0
  68. package/dist/{key-dNFkodH5.cjs → key-DEYIxAFs.cjs} +42 -50
  69. package/dist/key-DMO0TgTa.mjs +5 -0
  70. package/dist/{key-I-ibyaZH.js → key-DdL5Oc59.mjs} +12 -18
  71. package/dist/{key-Cg0kO4dA.js → key-vIzWPiil.js} +19 -19
  72. package/dist/{keycache-hSs_XFSb.js → keycache-BVR9f06Y.mjs} +6 -10
  73. package/dist/{keys-CElJez9H.js → keys-Co-0pK8a.mjs} +6 -10
  74. package/dist/{kv-DipCBaw2.d.ts → kv-C6UC8M9S.d.ts} +1 -1
  75. package/dist/{kv-BqEOXcZv.d.cts → kv-ClC9WJh5.d.cts} +1 -1
  76. package/dist/{kv-QzKcOQgP.js → kv-OuT2IU64.mjs} +6 -10
  77. package/dist/{ld-b16r91YS.js → ld-BFaDk5gX.mjs} +17 -31
  78. package/dist/{lookup-CySNcNcC.js → lookup-CMYXdjVH.mjs} +8 -17
  79. package/dist/{lookup-Bfq9Jpm0.cjs → lookup-CZGJqSjm.cjs} +16 -23
  80. package/dist/{lookup-CiSAeWJl.js → lookup-jlmCTRsO.js} +5 -11
  81. package/dist/middleware-BWlZ-wms.cjs +4 -0
  82. package/dist/{middleware-C5emnCh-.js → middleware-BXD5WJbj.mjs} +276 -321
  83. package/dist/{middleware-Dxo56yae.cjs → middleware-BhMQrJXH.cjs} +494 -547
  84. package/dist/{middleware-Bs4xDuXR.js → middleware-CmA2E9Bu.js} +349 -393
  85. package/dist/middleware-H3Ce7yn3.mjs +5 -0
  86. package/dist/{mod-D5rfgGFE.d.cts → mod-BQ3lrlXU.d.cts} +3 -3
  87. package/dist/{mod-Dz5Y15Uy.d.cts → mod-C72agZIN.d.cts} +4 -4
  88. package/dist/{mod-CxMBb_dd.d.cts → mod-CDbqB60V.d.cts} +2 -2
  89. package/dist/{mod-DS4kJskR.d.ts → mod-Lj0W1nnG.d.ts} +3 -3
  90. package/dist/{mod-BZfdiPBo.d.ts → mod-_HNKaczF.d.ts} +4 -4
  91. package/dist/{mod-ChbckRnC.d.ts → mod-lHd-Zdd_.d.ts} +2 -2
  92. package/dist/mod.cjs +31 -33
  93. package/dist/mod.d.cts +15 -17
  94. package/dist/mod.d.ts +15 -17
  95. package/dist/mod.js +20 -23
  96. package/dist/{mq-B7R1Q-M5.d.cts → mq-CrItclRD.d.cts} +1 -1
  97. package/dist/{mq-CRGm1e_F.d.ts → mq-D_ZZRdby.d.ts} +1 -1
  98. package/dist/nodeinfo/client.test.d.mts +2 -0
  99. package/dist/nodeinfo/{client.test.js → client.test.mjs} +23 -45
  100. package/dist/nodeinfo/handler.test.d.mts +2 -0
  101. package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +14 -43
  102. package/dist/nodeinfo/mod.cjs +5 -9
  103. package/dist/nodeinfo/mod.d.cts +2 -5
  104. package/dist/nodeinfo/mod.d.ts +2 -5
  105. package/dist/nodeinfo/mod.js +4 -9
  106. package/dist/nodeinfo/semver.test.d.mts +2 -0
  107. package/dist/nodeinfo/{semver.test.js → semver.test.mjs} +28 -51
  108. package/dist/nodeinfo/types.test.d.mts +2 -0
  109. package/dist/nodeinfo/{types.test.js → types.test.mjs} +10 -21
  110. package/dist/otel/exporter.test.d.mts +2 -0
  111. package/dist/otel/{exporter.test.js → exporter.test.mjs} +122 -180
  112. package/dist/otel/mod.cjs +16 -22
  113. package/dist/otel/mod.d.cts +2 -2
  114. package/dist/otel/mod.d.ts +2 -2
  115. package/dist/otel/mod.js +9 -16
  116. package/dist/{otel-Chy5T2Xh.js → otel-0v4Zy01l.mjs} +5 -10
  117. package/dist/{owner-AcrG3Xz1.d.cts → owner-0yNTyGMb.d.cts} +4 -4
  118. package/dist/{owner-Bs-sPbHX.js → owner-CNdS8zxf.mjs} +11 -16
  119. package/dist/{owner-8NMhXwJd.d.ts → owner-CPEbNpnZ.d.ts} +4 -4
  120. package/dist/{proof-SgRikE_Y.js → proof-Co7YmDpv.mjs} +20 -32
  121. package/dist/{proof-flD2DeA-.js → proof-DHPbi_Mx.js} +34 -60
  122. package/dist/{proof-BvQS195q.cjs → proof-DcPdtve2.cjs} +115 -140
  123. package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
  124. package/dist/rolldown-runtime-C7fyD9f2.js +15 -0
  125. package/dist/runtime/authdocloader.test.d.mts +2 -0
  126. package/dist/runtime/{authdocloader.test.js → authdocloader.test.mjs} +16 -28
  127. package/dist/runtime/docloader.test.d.mts +2 -0
  128. package/dist/runtime/{docloader.test.js → docloader.test.mjs} +55 -77
  129. package/dist/runtime/key.test.d.mts +2 -0
  130. package/dist/runtime/{key.test.js → key.test.mjs} +27 -57
  131. package/dist/runtime/langstr.test.d.mts +2 -0
  132. package/dist/runtime/{langstr.test.js → langstr.test.mjs} +9 -19
  133. package/dist/runtime/link.test.d.mts +2 -0
  134. package/dist/runtime/{link.test.js → link.test.mjs} +7 -11
  135. package/dist/runtime/mod.cjs +7 -13
  136. package/dist/runtime/mod.d.cts +103 -6
  137. package/dist/runtime/mod.d.ts +103 -6
  138. package/dist/runtime/mod.js +6 -13
  139. package/dist/runtime/multibase/multibase.test.d.mts +2 -0
  140. package/dist/runtime/multibase/{multibase.test.js → multibase.test.mjs} +16 -33
  141. package/dist/runtime/url.test.d.mts +2 -0
  142. package/dist/runtime/{url.test.js → url.test.mjs} +10 -15
  143. package/dist/{semver-dArNLkR9.js → semver-CgD82xxg.mjs} +13 -28
  144. package/dist/{send-C0gFHa2i.js → send-BRCWNcMa.mjs} +7 -12
  145. package/dist/sig/http.test.d.mts +2 -0
  146. package/dist/sig/{http.test.js → http.test.mjs} +119 -203
  147. package/dist/sig/key.test.d.mts +2 -0
  148. package/dist/sig/{key.test.js → key.test.mjs} +13 -22
  149. package/dist/sig/ld.test.d.mts +2 -0
  150. package/dist/sig/{ld.test.js → ld.test.mjs} +24 -39
  151. package/dist/sig/mod.cjs +7 -13
  152. package/dist/sig/mod.d.cts +3 -7
  153. package/dist/sig/mod.d.ts +3 -7
  154. package/dist/sig/mod.js +6 -13
  155. package/dist/sig/owner.test.d.mts +2 -0
  156. package/dist/sig/{owner.test.js → owner.test.mjs} +23 -39
  157. package/dist/sig/proof.test.d.mts +2 -0
  158. package/dist/sig/{proof.test.js → proof.test.mjs} +18 -31
  159. package/dist/{std__assert-X-_kMxKM.js → std__assert-2v7gYiZp.mjs} +13 -24
  160. package/dist/testing/docloader.test.d.mts +2 -0
  161. package/dist/testing/docloader.test.mjs +12 -0
  162. package/dist/testing/{mod.d.ts → mod.d.mts} +371 -541
  163. package/dist/testing/mod.mjs +5 -0
  164. package/dist/{testing-C1GIraJh.js → testing-BLIh1cXz.mjs} +27 -35
  165. package/dist/{transformers-BFT6d7J5.js → transformers-BV4OeK9o.js} +3 -7
  166. package/dist/{transformers-CoBS-oFG.cjs → transformers-CLtJ5H8o.cjs} +20 -25
  167. package/dist/{types-BgUCCngg.cjs → types-B34v-m2N.cjs} +45 -64
  168. package/dist/{types-BIgY6c-l.js → types-CAnkAQGM.mjs} +5 -9
  169. package/dist/{types-Bu-epI-z.js → types-CXZk86AG.js} +18 -36
  170. package/dist/vocab/actor.test.d.mts +2 -0
  171. package/dist/vocab/{actor.test.js → actor.test.mjs} +308 -550
  172. package/dist/vocab/cjs.test.d.mts +2 -0
  173. package/dist/vocab/cjs.test.mjs +14 -0
  174. package/dist/vocab/lookup.test.d.mts +2 -0
  175. package/dist/vocab/{lookup.test.js → lookup.test.mjs} +34 -51
  176. package/dist/vocab/mod.cjs +256 -16
  177. package/dist/vocab/mod.d.cts +3 -5
  178. package/dist/vocab/mod.d.ts +3 -5
  179. package/dist/vocab/mod.js +249 -10
  180. package/dist/vocab/type.test.d.mts +2 -0
  181. package/dist/vocab/type.test.mjs +16 -0
  182. package/dist/vocab/vocab.test.d.mts +2 -0
  183. package/dist/vocab/{vocab.test.js → vocab.test.mjs} +178 -311
  184. package/dist/{vocab-BASuuzcJ.d.ts → vocab-DaT4UsJF.d.ts} +2 -2
  185. package/dist/{vocab-DPMmFPJ1.d.cts → vocab-DnlmNyXi.d.cts} +2 -2
  186. package/dist/{type-DUhon7qK.js → vocab-rT_94Pke.mjs} +1178 -2876
  187. package/dist/webfinger/handler.test.d.mts +2 -0
  188. package/dist/webfinger/{handler.test.js → handler.test.mjs} +23 -56
  189. package/dist/webfinger/lookup.test.d.mts +2 -0
  190. package/dist/webfinger/{lookup.test.js → lookup.test.mjs} +13 -27
  191. package/dist/webfinger/mod.cjs +5 -9
  192. package/dist/webfinger/mod.d.cts +1 -3
  193. package/dist/webfinger/mod.d.ts +1 -3
  194. package/dist/webfinger/mod.js +4 -9
  195. package/dist/x/cfworkers.cjs +25 -14
  196. package/dist/x/cfworkers.d.cts +33 -6
  197. package/dist/x/cfworkers.d.ts +33 -6
  198. package/dist/x/cfworkers.js +22 -12
  199. package/dist/x/cfworkers.test.d.mts +2 -0
  200. package/dist/x/{cfworkers.test.js → cfworkers.test.mjs} +28 -26
  201. package/dist/x/hono.cjs +25 -14
  202. package/dist/x/hono.d.cts +1 -11
  203. package/dist/x/hono.d.ts +1 -11
  204. package/dist/x/hono.js +22 -12
  205. package/dist/x/sveltekit.cjs +23 -12
  206. package/dist/x/sveltekit.d.cts +1 -11
  207. package/dist/x/sveltekit.d.ts +1 -11
  208. package/dist/x/sveltekit.js +20 -10
  209. package/package.json +2 -2
  210. package/dist/chunk-DqRYRqnO.cjs +0 -34
  211. package/dist/compat/transformers.test.d.ts +0 -3
  212. package/dist/compat/transformers.test.js +0 -86
  213. package/dist/compat-DmDDELst.cjs +0 -4
  214. package/dist/compat-nxUqe4Z-.js +0 -4
  215. package/dist/federation/builder.test.d.ts +0 -3
  216. package/dist/federation/collection.test.d.ts +0 -3
  217. package/dist/federation/collection.test.js +0 -35
  218. package/dist/federation/handler.test.d.ts +0 -3
  219. package/dist/federation/idempotency.test.d.ts +0 -3
  220. package/dist/federation/inbox.test.d.ts +0 -3
  221. package/dist/federation/keycache.test.d.ts +0 -3
  222. package/dist/federation/kv.test.d.ts +0 -3
  223. package/dist/federation/middleware.test.d.ts +0 -3
  224. package/dist/federation/mq.test.d.ts +0 -3
  225. package/dist/federation/retry.test.d.ts +0 -3
  226. package/dist/federation/router.test.d.ts +0 -3
  227. package/dist/federation/send.test.d.ts +0 -3
  228. package/dist/federation-C15gGOh1.cjs +0 -266
  229. package/dist/federation-K-xsO03l.js +0 -248
  230. package/dist/key-Bnod5wJl.js +0 -10
  231. package/dist/key-C6swTX71.js +0 -10
  232. package/dist/key-_Uq8gkmM.cjs +0 -10
  233. package/dist/middleware-BWsOtDIF.cjs +0 -17
  234. package/dist/middleware-Bm4bJzjg.js +0 -26
  235. package/dist/middleware-BvODpE_U.js +0 -17
  236. package/dist/mod-C2tOeRkN.d.cts +0 -1
  237. package/dist/mod-CD7gfdq3.d.ts +0 -104
  238. package/dist/mod-CnULG6Aa.d.ts +0 -82
  239. package/dist/mod-FZd39qVq.d.cts +0 -1
  240. package/dist/mod-JUhOKMHj.d.cts +0 -102
  241. package/dist/mod-OQfb33eH.d.cts +0 -80
  242. package/dist/nodeinfo/client.test.d.ts +0 -3
  243. package/dist/nodeinfo/handler.test.d.ts +0 -3
  244. package/dist/nodeinfo/semver.test.d.ts +0 -3
  245. package/dist/nodeinfo/types.test.d.ts +0 -3
  246. package/dist/nodeinfo-Co9lJrWl.cjs +0 -4
  247. package/dist/nodeinfo-DfycQ8Wf.js +0 -4
  248. package/dist/otel/exporter.test.d.ts +0 -3
  249. package/dist/runtime/authdocloader.test.d.ts +0 -3
  250. package/dist/runtime/docloader.test.d.ts +0 -3
  251. package/dist/runtime/key.test.d.ts +0 -3
  252. package/dist/runtime/langstr.test.d.ts +0 -3
  253. package/dist/runtime/link.test.d.ts +0 -3
  254. package/dist/runtime/multibase/multibase.test.d.ts +0 -3
  255. package/dist/runtime/url.test.d.ts +0 -3
  256. package/dist/runtime-C58AJWSv.cjs +0 -4
  257. package/dist/runtime-DPYEDf-o.js +0 -4
  258. package/dist/sig/http.test.d.ts +0 -3
  259. package/dist/sig/key.test.d.ts +0 -3
  260. package/dist/sig/ld.test.d.ts +0 -3
  261. package/dist/sig/owner.test.d.ts +0 -3
  262. package/dist/sig/proof.test.d.ts +0 -3
  263. package/dist/sig-ByHXzqUi.cjs +0 -4
  264. package/dist/sig-Cj3tk-ig.js +0 -4
  265. package/dist/testing/docloader.test.d.ts +0 -3
  266. package/dist/testing/docloader.test.js +0 -24
  267. package/dist/testing/mod.js +0 -10
  268. package/dist/vocab/actor.test.d.ts +0 -3
  269. package/dist/vocab/lookup.test.d.ts +0 -3
  270. package/dist/vocab/type.test.d.ts +0 -3
  271. package/dist/vocab/type.test.js +0 -25
  272. package/dist/vocab/vocab.test.d.ts +0 -3
  273. package/dist/vocab-5i6DEIi6.cjs +0 -294
  274. package/dist/vocab-CBavAdew.js +0 -258
  275. package/dist/webfinger/handler.test.d.ts +0 -3
  276. package/dist/webfinger/lookup.test.d.ts +0 -3
  277. package/dist/webfinger-BjOEdFPs.cjs +0 -4
  278. package/dist/webfinger-De_bU0iE.js +0 -4
  279. package/dist/x/cfworkers.test.d.ts +0 -3
  280. /package/dist/{mod-1pDWKvUL.d.ts → compat/transformers.test.d.mts} +0 -0
  281. /package/dist/{mod-g0xFzAP9.d.ts → federation/builder.test.d.mts} +0 -0
@@ -1,23 +1,247 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- require('../transformers-CoBS-oFG.cjs');
6
- require('../docloader-irBWMSOZ.cjs');
7
- require('../actor-CjkHF7Cj.cjs');
8
- const require_middleware = require('../middleware-Dxo56yae.cjs');
9
- require('../lookup-Bfq9Jpm0.cjs');
10
- require('../key-dNFkodH5.cjs');
11
- require('../http-CQAqR_vx.cjs');
12
- require('../proof-BvQS195q.cjs');
13
- const require_federation = require('../federation-C15gGOh1.cjs');
14
- require('../types-BgUCCngg.cjs');
15
- require('../authdocloader-zc5ibOmU.cjs');
16
- require('../vocab-5i6DEIi6.cjs');
17
-
18
- exports.InProcessMessageQueue = require_federation.InProcessMessageQueue;
19
- exports.MemoryKvStore = require_federation.MemoryKvStore;
20
- exports.ParallelMessageQueue = require_federation.ParallelMessageQueue;
1
+ const { Temporal } = require("@js-temporal/polyfill");
2
+ const { URLPattern } = require("urlpattern-polyfill");
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
+ require("../docloader-Q3DfzuUi.cjs");
5
+ const require_middleware = require("../middleware-BhMQrJXH.cjs");
6
+ let es_toolkit = require("es-toolkit");
7
+ //#region src/federation/kv.ts
8
+ /**
9
+ * A key–value store that stores values in memory.
10
+ * Do not use this in production as it does not persist values.
11
+ *
12
+ * @since 0.5.0
13
+ */
14
+ var MemoryKvStore = class {
15
+ #values = {};
16
+ #encodeKey(key) {
17
+ return JSON.stringify(key);
18
+ }
19
+ /**
20
+ * {@inheritDoc KvStore.get}
21
+ */
22
+ get(key) {
23
+ const encodedKey = this.#encodeKey(key);
24
+ const entry = this.#values[encodedKey];
25
+ if (entry == null) return Promise.resolve(void 0);
26
+ const [value, expiration] = entry;
27
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
28
+ delete this.#values[encodedKey];
29
+ return Promise.resolve(void 0);
30
+ }
31
+ return Promise.resolve(value);
32
+ }
33
+ /**
34
+ * {@inheritDoc KvStore.set}
35
+ */
36
+ set(key, value, options) {
37
+ const encodedKey = this.#encodeKey(key);
38
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
39
+ this.#values[encodedKey] = [value, expiration];
40
+ return Promise.resolve();
41
+ }
42
+ /**
43
+ * {@inheritDoc KvStore.delete}
44
+ */
45
+ delete(key) {
46
+ const encodedKey = this.#encodeKey(key);
47
+ delete this.#values[encodedKey];
48
+ return Promise.resolve();
49
+ }
50
+ /**
51
+ * {@inheritDoc KvStore.cas}
52
+ */
53
+ cas(key, expectedValue, newValue, options) {
54
+ const encodedKey = this.#encodeKey(key);
55
+ const entry = this.#values[encodedKey];
56
+ let currentValue;
57
+ if (entry == null) currentValue = void 0;
58
+ else {
59
+ const [value, expiration] = entry;
60
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
61
+ delete this.#values[encodedKey];
62
+ currentValue = void 0;
63
+ } else currentValue = value;
64
+ }
65
+ if (!(0, es_toolkit.isEqual)(currentValue, expectedValue)) return Promise.resolve(false);
66
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
67
+ this.#values[encodedKey] = [newValue, expiration];
68
+ return Promise.resolve(true);
69
+ }
70
+ /**
71
+ * {@inheritDoc KvStore.list}
72
+ */
73
+ async *list(prefix) {
74
+ const now = Temporal.Now.instant();
75
+ for (const [encodedKey, entry] of Object.entries(this.#values)) {
76
+ const key = JSON.parse(encodedKey);
77
+ if (prefix != null) {
78
+ if (key.length < prefix.length) continue;
79
+ if (!prefix.every((p, i) => key[i] === p)) continue;
80
+ }
81
+ const [value, expiration] = entry;
82
+ if (expiration != null && now.until(expiration).sign < 0) {
83
+ delete this.#values[encodedKey];
84
+ continue;
85
+ }
86
+ yield {
87
+ key,
88
+ value
89
+ };
90
+ }
91
+ }
92
+ };
93
+ //#endregion
94
+ //#region src/federation/mq.ts
95
+ /**
96
+ * A message queue that processes messages in the same process.
97
+ * Do not use this in production as it does neither persist messages nor
98
+ * distribute them across multiple processes.
99
+ *
100
+ * @since 0.5.0
101
+ */
102
+ var InProcessMessageQueue = class {
103
+ #messages;
104
+ #monitors;
105
+ #pollIntervalMs;
106
+ /**
107
+ * In-process message queue does not provide native retry mechanisms.
108
+ * @since 1.7.0
109
+ */
110
+ nativeRetrial = false;
111
+ /**
112
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
113
+ * @param options Additional options for the in-process message queue.
114
+ */
115
+ constructor(options = {}) {
116
+ this.#messages = [];
117
+ this.#monitors = {};
118
+ this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
119
+ }
120
+ enqueue(message, options) {
121
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
122
+ if (delay > 0) {
123
+ setTimeout(() => this.enqueue(message, {
124
+ ...options,
125
+ delay: void 0
126
+ }), delay);
127
+ return Promise.resolve();
128
+ }
129
+ this.#messages.push(message);
130
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
131
+ return Promise.resolve();
132
+ }
133
+ enqueueMany(messages, options) {
134
+ if (messages.length === 0) return Promise.resolve();
135
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
136
+ if (delay > 0) {
137
+ setTimeout(() => this.enqueueMany(messages, {
138
+ ...options,
139
+ delay: void 0
140
+ }), delay);
141
+ return Promise.resolve();
142
+ }
143
+ this.#messages.push(...messages);
144
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
145
+ return Promise.resolve();
146
+ }
147
+ async listen(handler, options = {}) {
148
+ const signal = options.signal;
149
+ while (signal == null || !signal.aborted) {
150
+ while (this.#messages.length > 0) await handler(this.#messages.shift());
151
+ await this.#wait(this.#pollIntervalMs, signal);
152
+ }
153
+ }
154
+ #wait(ms, signal) {
155
+ let timer = null;
156
+ return Promise.any([new Promise((resolve) => {
157
+ signal?.addEventListener("abort", () => {
158
+ if (timer != null) clearTimeout(timer);
159
+ resolve();
160
+ }, { once: true });
161
+ const monitorId = crypto.randomUUID();
162
+ this.#monitors[monitorId] = () => {
163
+ delete this.#monitors[monitorId];
164
+ if (timer != null) clearTimeout(timer);
165
+ resolve();
166
+ };
167
+ }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
168
+ }
169
+ };
170
+ /**
171
+ * A message queue that processes messages in parallel. It takes another
172
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
173
+ * number of workers.
174
+ *
175
+ * Actually, it's rather a decorator than a queue itself.
176
+ *
177
+ * Note that the workers do not run in truly parallel, in the sense that they
178
+ * are not running in separate threads or processes. They are running in the
179
+ * same process, but are scheduled to run in parallel. Hence, this is useful
180
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
181
+ * workloads.
182
+ *
183
+ * @since 1.0.0
184
+ */
185
+ var ParallelMessageQueue = class ParallelMessageQueue {
186
+ queue;
187
+ workers;
188
+ /**
189
+ * Inherits the native retry capability from the wrapped queue.
190
+ * @since 1.7.0
191
+ */
192
+ nativeRetrial;
193
+ /**
194
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
195
+ * number of workers.
196
+ * @param queue The message queue to use under the hood. Note that
197
+ * {@link ParallelMessageQueue} cannot be nested.
198
+ * @param workers The number of workers to process messages in parallel.
199
+ * @throws {TypeError} If the given queue is an instance of
200
+ * {@link ParallelMessageQueue}.
201
+ */
202
+ constructor(queue, workers) {
203
+ if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
204
+ this.queue = queue;
205
+ this.workers = workers;
206
+ this.nativeRetrial = queue.nativeRetrial;
207
+ }
208
+ enqueue(message, options) {
209
+ return this.queue.enqueue(message, options);
210
+ }
211
+ async enqueueMany(messages, options) {
212
+ if (this.queue.enqueueMany == null) {
213
+ const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
214
+ if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
215
+ else if (errors.length === 1) throw errors[0];
216
+ return;
217
+ }
218
+ await this.queue.enqueueMany(messages, options);
219
+ }
220
+ listen(handler, options = {}) {
221
+ const workers = /* @__PURE__ */ new Map();
222
+ return this.queue.listen(async (message) => {
223
+ while (workers.size >= this.workers) {
224
+ const consumedId = await Promise.any(workers.values());
225
+ workers.delete(consumedId);
226
+ }
227
+ const workerId = crypto.randomUUID();
228
+ const promise = this.#work(workerId, handler, message);
229
+ workers.set(workerId, promise);
230
+ }, options);
231
+ }
232
+ async #work(workerId, handler, message) {
233
+ await this.#sleep(0);
234
+ await handler(message);
235
+ return workerId;
236
+ }
237
+ #sleep(ms) {
238
+ return new Promise((resolve) => setTimeout(resolve, ms));
239
+ }
240
+ };
241
+ //#endregion
242
+ exports.InProcessMessageQueue = InProcessMessageQueue;
243
+ exports.MemoryKvStore = MemoryKvStore;
244
+ exports.ParallelMessageQueue = ParallelMessageQueue;
21
245
  exports.Router = require_middleware.Router;
22
246
  exports.RouterError = require_middleware.RouterError;
23
247
  exports.buildCollectionSynchronizationHeader = require_middleware.buildCollectionSynchronizationHeader;
@@ -26,4 +250,4 @@ exports.createFederation = require_middleware.createFederation;
26
250
  exports.createFederationBuilder = require_middleware.createFederationBuilder;
27
251
  exports.digest = require_middleware.digest;
28
252
  exports.respondWithObject = require_middleware.respondWithObject;
29
- exports.respondWithObjectIfAcceptable = require_middleware.respondWithObjectIfAcceptable;
253
+ exports.respondWithObjectIfAcceptable = require_middleware.respondWithObjectIfAcceptable;
@@ -1,13 +1,4 @@
1
- import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-BqEOXcZv.cjs";
2
- import "../docloader-ChxNLZAA.cjs";
3
- import "../client-n6L4GtQL.cjs";
4
- import "../vocab-DPMmFPJ1.cjs";
5
- import "../actor-D190nbTD.cjs";
6
- import "../http-C_1RU1U_.cjs";
7
- import "../owner-AcrG3Xz1.cjs";
8
- import "../mod-D5rfgGFE.cjs";
9
- import "../mod-CxMBb_dd.cjs";
10
- import { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../context-WJoO0SQs.cjs";
11
- import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-B7R1Q-M5.cjs";
12
- import "../mod-C2tOeRkN.cjs";
13
- export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
1
+ import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-ClC9WJh5.cjs";
2
+ import { $ as CustomCollectionCursor, A as createFederation, B as RouterRouteResult, C as InboxListenerSetters, D as FederationKvPrefixes, E as CreateFederationOptions, F as Message, G as ActorDispatcher, H as respondWithObject, I as createFederationBuilder, J as AuthorizePredicate, K as ActorHandleMapper, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as CustomCollectionCounter, R as RouterError, S as IdempotencyStrategy, T as Rfc6570Expression, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as FederationBuilder, a as InboxContext, at as ObjectDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as WebFingerLinksDispatcher, d as ActorCallbackSetters, dt as buildCollectionSynchronizationHeader, et as CustomCollectionDispatcher, f as CollectionCallbackSetters, ft as digest, g as Federation, h as Federatable, i as GetSignedKeyOptions, it as ObjectAuthorizePredicate, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as SenderKeyPair, m as CustomCollectionCallbackSetters, n as Context, nt as InboxListener, o as ParseUriResult, ot as OutboxErrorHandler, p as ConstructorWithTypeId, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as RequestContext, st as SharedInboxKeyDispatcher, t as ActorKeyPair, tt as InboxErrorHandler, u as SendActivityOptionsForCollection, ut as PageItems, v as FederationFetchOptions, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, z as RouterOptions } from "../context-PfghnHYj.cjs";
3
+ import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, n as InProcessMessageQueueOptions, o as ParallelMessageQueue, r as MessageQueue, t as InProcessMessageQueue } from "../mq-CrItclRD.cjs";
4
+ export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, type CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, type FederationKvPrefixes, FederationOptions, type FederationOrigin, type FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, type Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, type RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, type SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,15 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore } from "../kv-DipCBaw2.js";
4
- import "../docloader-BucCRHZI.js";
5
- import "../client-B3mQJNO7.js";
6
- import "../vocab-BASuuzcJ.js";
7
- import "../actor-eeONG_sv.js";
8
- import "../http-DS9z_HzB.js";
9
- import "../owner-8NMhXwJd.js";
10
- import "../mod-DS4kJskR.js";
11
- import "../mod-ChbckRnC.js";
12
- import { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, Message, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../context-Cr5DIxq_.js";
13
- import { InProcessMessageQueue, InProcessMessageQueueOptions, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, ParallelMessageQueue } from "../mq-CRGm1e_F.js";
14
- import "../mod-g0xFzAP9.js";
15
- export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
3
+ import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-C6UC8M9S.js";
4
+ import { $ as CustomCollectionCursor, A as createFederation, B as RouterRouteResult, C as InboxListenerSetters, D as FederationKvPrefixes, E as CreateFederationOptions, F as Message, G as ActorDispatcher, H as respondWithObject, I as createFederationBuilder, J as AuthorizePredicate, K as ActorHandleMapper, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as CustomCollectionCounter, R as RouterError, S as IdempotencyStrategy, T as Rfc6570Expression, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as ActorAliasMapper, X as CollectionCursor, Y as CollectionCounter, Z as CollectionDispatcher, _ as FederationBuilder, a as InboxContext, at as ObjectDispatcher, b as FederationStartQueueOptions, c as RouteActivityOptions, ct as WebFingerLinksDispatcher, d as ActorCallbackSetters, dt as buildCollectionSynchronizationHeader, et as CustomCollectionDispatcher, f as CollectionCallbackSetters, ft as digest, g as Federation, h as Federatable, i as GetSignedKeyOptions, it as ObjectAuthorizePredicate, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as SenderKeyPair, m as CustomCollectionCallbackSetters, n as Context, nt as InboxListener, o as ParseUriResult, ot as OutboxErrorHandler, p as ConstructorWithTypeId, q as ActorKeyPairsDispatcher, r as ForwardActivityOptions, rt as NodeInfoDispatcher, s as RequestContext, st as SharedInboxKeyDispatcher, t as ActorKeyPair, tt as InboxErrorHandler, u as SendActivityOptionsForCollection, ut as PageItems, v as FederationFetchOptions, w as ObjectCallbackSetters, x as IdempotencyKeyCallback, y as FederationOptions, z as RouterOptions } from "../context-C6n2yrj0.js";
5
+ import { a as MessageQueueListenOptions, i as MessageQueueEnqueueOptions, n as InProcessMessageQueueOptions, o as ParallelMessageQueue, r as MessageQueue, t as InProcessMessageQueue } from "../mq-D_ZZRdby.js";
6
+ export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, type CreateFederationOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, type FederationKvPrefixes, FederationOptions, type FederationOrigin, type FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, type Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, type RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityOptions, SendActivityOptionsForCollection, type SenderKeyPair, SharedInboxKeyDispatcher, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,18 +1,240 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import "../transformers-BFT6d7J5.js";
6
- import "../docloader-BETPdM09.js";
7
- import "../actor-CQdxP8N-.js";
8
- import { Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable } from "../middleware-Bs4xDuXR.js";
9
- import "../lookup-CiSAeWJl.js";
10
- import "../key-I-ibyaZH.js";
11
- import "../http-PgdBoDIj.js";
12
- import "../proof-flD2DeA-.js";
13
- import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "../federation-K-xsO03l.js";
14
- import "../types-Bu-epI-z.js";
15
- import "../authdocloader-fR-Fqcpa.js";
16
- import "../vocab-CBavAdew.js";
17
-
18
- export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ import { a as respondWithObjectIfAcceptable, c as createFederationBuilder, i as respondWithObject, l as Router, o as buildCollectionSynchronizationHeader, r as createExponentialBackoffPolicy, s as digest, t as createFederation, u as RouterError } from "../middleware-CmA2E9Bu.js";
4
+ import { isEqual } from "es-toolkit";
5
+ //#region src/federation/kv.ts
6
+ /**
7
+ * A key–value store that stores values in memory.
8
+ * Do not use this in production as it does not persist values.
9
+ *
10
+ * @since 0.5.0
11
+ */
12
+ var MemoryKvStore = class {
13
+ #values = {};
14
+ #encodeKey(key) {
15
+ return JSON.stringify(key);
16
+ }
17
+ /**
18
+ * {@inheritDoc KvStore.get}
19
+ */
20
+ get(key) {
21
+ const encodedKey = this.#encodeKey(key);
22
+ const entry = this.#values[encodedKey];
23
+ if (entry == null) return Promise.resolve(void 0);
24
+ const [value, expiration] = entry;
25
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
26
+ delete this.#values[encodedKey];
27
+ return Promise.resolve(void 0);
28
+ }
29
+ return Promise.resolve(value);
30
+ }
31
+ /**
32
+ * {@inheritDoc KvStore.set}
33
+ */
34
+ set(key, value, options) {
35
+ const encodedKey = this.#encodeKey(key);
36
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
37
+ this.#values[encodedKey] = [value, expiration];
38
+ return Promise.resolve();
39
+ }
40
+ /**
41
+ * {@inheritDoc KvStore.delete}
42
+ */
43
+ delete(key) {
44
+ const encodedKey = this.#encodeKey(key);
45
+ delete this.#values[encodedKey];
46
+ return Promise.resolve();
47
+ }
48
+ /**
49
+ * {@inheritDoc KvStore.cas}
50
+ */
51
+ cas(key, expectedValue, newValue, options) {
52
+ const encodedKey = this.#encodeKey(key);
53
+ const entry = this.#values[encodedKey];
54
+ let currentValue;
55
+ if (entry == null) currentValue = void 0;
56
+ else {
57
+ const [value, expiration] = entry;
58
+ if (expiration != null && Temporal.Now.instant().until(expiration).sign < 0) {
59
+ delete this.#values[encodedKey];
60
+ currentValue = void 0;
61
+ } else currentValue = value;
62
+ }
63
+ if (!isEqual(currentValue, expectedValue)) return Promise.resolve(false);
64
+ const expiration = options?.ttl == null ? null : Temporal.Now.instant().add(options.ttl.round({ largestUnit: "hour" }));
65
+ this.#values[encodedKey] = [newValue, expiration];
66
+ return Promise.resolve(true);
67
+ }
68
+ /**
69
+ * {@inheritDoc KvStore.list}
70
+ */
71
+ async *list(prefix) {
72
+ const now = Temporal.Now.instant();
73
+ for (const [encodedKey, entry] of Object.entries(this.#values)) {
74
+ const key = JSON.parse(encodedKey);
75
+ if (prefix != null) {
76
+ if (key.length < prefix.length) continue;
77
+ if (!prefix.every((p, i) => key[i] === p)) continue;
78
+ }
79
+ const [value, expiration] = entry;
80
+ if (expiration != null && now.until(expiration).sign < 0) {
81
+ delete this.#values[encodedKey];
82
+ continue;
83
+ }
84
+ yield {
85
+ key,
86
+ value
87
+ };
88
+ }
89
+ }
90
+ };
91
+ //#endregion
92
+ //#region src/federation/mq.ts
93
+ /**
94
+ * A message queue that processes messages in the same process.
95
+ * Do not use this in production as it does neither persist messages nor
96
+ * distribute them across multiple processes.
97
+ *
98
+ * @since 0.5.0
99
+ */
100
+ var InProcessMessageQueue = class {
101
+ #messages;
102
+ #monitors;
103
+ #pollIntervalMs;
104
+ /**
105
+ * In-process message queue does not provide native retry mechanisms.
106
+ * @since 1.7.0
107
+ */
108
+ nativeRetrial = false;
109
+ /**
110
+ * Constructs a new {@link InProcessMessageQueue} with the given options.
111
+ * @param options Additional options for the in-process message queue.
112
+ */
113
+ constructor(options = {}) {
114
+ this.#messages = [];
115
+ this.#monitors = {};
116
+ this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
117
+ }
118
+ enqueue(message, options) {
119
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
120
+ if (delay > 0) {
121
+ setTimeout(() => this.enqueue(message, {
122
+ ...options,
123
+ delay: void 0
124
+ }), delay);
125
+ return Promise.resolve();
126
+ }
127
+ this.#messages.push(message);
128
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
129
+ return Promise.resolve();
130
+ }
131
+ enqueueMany(messages, options) {
132
+ if (messages.length === 0) return Promise.resolve();
133
+ const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
134
+ if (delay > 0) {
135
+ setTimeout(() => this.enqueueMany(messages, {
136
+ ...options,
137
+ delay: void 0
138
+ }), delay);
139
+ return Promise.resolve();
140
+ }
141
+ this.#messages.push(...messages);
142
+ for (const monitorId in this.#monitors) this.#monitors[monitorId]();
143
+ return Promise.resolve();
144
+ }
145
+ async listen(handler, options = {}) {
146
+ const signal = options.signal;
147
+ while (signal == null || !signal.aborted) {
148
+ while (this.#messages.length > 0) await handler(this.#messages.shift());
149
+ await this.#wait(this.#pollIntervalMs, signal);
150
+ }
151
+ }
152
+ #wait(ms, signal) {
153
+ let timer = null;
154
+ return Promise.any([new Promise((resolve) => {
155
+ signal?.addEventListener("abort", () => {
156
+ if (timer != null) clearTimeout(timer);
157
+ resolve();
158
+ }, { once: true });
159
+ const monitorId = crypto.randomUUID();
160
+ this.#monitors[monitorId] = () => {
161
+ delete this.#monitors[monitorId];
162
+ if (timer != null) clearTimeout(timer);
163
+ resolve();
164
+ };
165
+ }), new Promise((resolve) => timer = setTimeout(resolve, ms))]);
166
+ }
167
+ };
168
+ /**
169
+ * A message queue that processes messages in parallel. It takes another
170
+ * {@link MessageQueue}, and processes messages in parallel up to a certain
171
+ * number of workers.
172
+ *
173
+ * Actually, it's rather a decorator than a queue itself.
174
+ *
175
+ * Note that the workers do not run in truly parallel, in the sense that they
176
+ * are not running in separate threads or processes. They are running in the
177
+ * same process, but are scheduled to run in parallel. Hence, this is useful
178
+ * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
179
+ * workloads.
180
+ *
181
+ * @since 1.0.0
182
+ */
183
+ var ParallelMessageQueue = class ParallelMessageQueue {
184
+ queue;
185
+ workers;
186
+ /**
187
+ * Inherits the native retry capability from the wrapped queue.
188
+ * @since 1.7.0
189
+ */
190
+ nativeRetrial;
191
+ /**
192
+ * Constructs a new {@link ParallelMessageQueue} with the given queue and
193
+ * number of workers.
194
+ * @param queue The message queue to use under the hood. Note that
195
+ * {@link ParallelMessageQueue} cannot be nested.
196
+ * @param workers The number of workers to process messages in parallel.
197
+ * @throws {TypeError} If the given queue is an instance of
198
+ * {@link ParallelMessageQueue}.
199
+ */
200
+ constructor(queue, workers) {
201
+ if (queue instanceof ParallelMessageQueue) throw new TypeError("Cannot nest ParallelMessageQueue.");
202
+ this.queue = queue;
203
+ this.workers = workers;
204
+ this.nativeRetrial = queue.nativeRetrial;
205
+ }
206
+ enqueue(message, options) {
207
+ return this.queue.enqueue(message, options);
208
+ }
209
+ async enqueueMany(messages, options) {
210
+ if (this.queue.enqueueMany == null) {
211
+ const errors = (await Promise.allSettled(messages.map((message) => this.queue.enqueue(message, options)))).filter((r) => r.status === "rejected").map((r) => r.reason);
212
+ if (errors.length > 1) throw new AggregateError(errors, "Failed to enqueue messages.");
213
+ else if (errors.length === 1) throw errors[0];
214
+ return;
215
+ }
216
+ await this.queue.enqueueMany(messages, options);
217
+ }
218
+ listen(handler, options = {}) {
219
+ const workers = /* @__PURE__ */ new Map();
220
+ return this.queue.listen(async (message) => {
221
+ while (workers.size >= this.workers) {
222
+ const consumedId = await Promise.any(workers.values());
223
+ workers.delete(consumedId);
224
+ }
225
+ const workerId = crypto.randomUUID();
226
+ const promise = this.#work(workerId, handler, message);
227
+ workers.set(workerId, promise);
228
+ }, options);
229
+ }
230
+ async #work(workerId, handler, message) {
231
+ await this.#sleep(0);
232
+ await handler(message);
233
+ return workerId;
234
+ }
235
+ #sleep(ms) {
236
+ return new Promise((resolve) => setTimeout(resolve, ms));
237
+ }
238
+ };
239
+ //#endregion
240
+ export { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue, Router, RouterError, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, respondWithObject, respondWithObjectIfAcceptable };
@@ -0,0 +1,2 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";