@fedify/fedify 2.0.0-dev.241 → 2.0.0-dev.323

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 (117) hide show
  1. package/dist/{builder-CR-ZQZJR.js → builder-CvKuNW7P.js} +3 -3
  2. package/dist/{chunk-DqRYRqnO.cjs → chunk-CGaQZ11T.cjs} +19 -0
  3. package/dist/chunk-DJNbSFdH.js +29 -0
  4. package/dist/compat/mod.cjs +1 -1
  5. package/dist/compat/mod.d.cts +6 -6
  6. package/dist/compat/mod.d.ts +6 -6
  7. package/dist/compat/mod.js +2 -2
  8. package/dist/compat/transformers.test.js +11 -11
  9. package/dist/{context-C7vzWilY.d.ts → context-CJO1oqSa.d.ts} +55 -12
  10. package/dist/{context-Bns6uTJq.js → context-CZ5llAss.js} +12 -12
  11. package/dist/{context-CrB9RFy5.d.cts → context-Zqld1re2.d.cts} +55 -12
  12. package/dist/{deno-DOeSTfhz.js → deno-BTAi5-ur.js} +11 -3
  13. package/dist/{docloader-C1AGOQQm.js → docloader-D8dzb6AT.js} +2 -2
  14. package/dist/federation/builder.test.js +3 -3
  15. package/dist/federation/handler.test.js +12 -12
  16. package/dist/federation/idempotency.test.js +47 -11
  17. package/dist/federation/inbox.test.js +2 -2
  18. package/dist/federation/middleware.test.js +63 -11
  19. package/dist/federation/mod.cjs +7 -7
  20. package/dist/federation/mod.d.cts +6 -6
  21. package/dist/federation/mod.d.ts +6 -6
  22. package/dist/federation/mod.js +7 -7
  23. package/dist/federation/mq.test.js +162 -10
  24. package/dist/federation/send.test.js +5 -5
  25. package/dist/federation/webfinger.test.js +12 -12
  26. package/dist/{federation-B431K2gm.cjs → federation-Bp3HI26G.cjs} +95 -11
  27. package/dist/{federation-BbZwNNWj.js → federation-DaMfqRm4.js} +94 -10
  28. package/dist/{http-C1LrW2D3.cjs → http-BCfCt7nq.cjs} +12 -4
  29. package/dist/{http-i8VdY2df.js → http-C02fQ5SX.js} +11 -3
  30. package/dist/{http-DGkEl4mw.js → http-C4WANccp.js} +2 -2
  31. package/dist/{inbox-Cp87HRVs.js → inbox-CdBcxHA7.js} +1 -1
  32. package/dist/{key-3_vbTfr8.js → key-BI6sqU5u.js} +1 -1
  33. package/dist/{kv-cache-B4CFgxYq.js → kv-cache-BLxaWwPk.js} +1 -1
  34. package/dist/{kv-cache-DOgKf8lH.cjs → kv-cache-Dk9UX_M2.cjs} +2 -2
  35. package/dist/{ld-BQxhMgOJ.js → ld-qTcTL2A4.js} +2 -2
  36. package/dist/middleware-BhYGJwH9.js +12 -0
  37. package/dist/{middleware-DZ-OdkE6.js → middleware-DG4UsFBP.js} +11 -11
  38. package/dist/{middleware-DbwwSEOr.js → middleware-DaOdxVOc.js} +65 -22
  39. package/dist/middleware-Dsrm1uhx.cjs +12 -0
  40. package/dist/{middleware-ixha9m0b.js → middleware-LQKxYF7X.js} +61 -18
  41. package/dist/{middleware-D4Eexdig.cjs → middleware-nW8ONmt3.cjs} +62 -19
  42. package/dist/mod-Bh8mqlYw.d.cts +9 -0
  43. package/dist/{mod-waqu-BL_.d.ts → mod-Bpuc-q64.d.ts} +1 -1
  44. package/dist/{mod-C3SOvTD1.d.ts → mod-C92O3FpJ.d.ts} +1 -1
  45. package/dist/{mod-0qnPv4EC.d.cts → mod-CKtAEVny.d.cts} +1 -1
  46. package/dist/{mod-BrS8tiad.d.cts → mod-COO7VMcm.d.cts} +1 -1
  47. package/dist/{mod-DZmuPaKv.d.ts → mod-CvhyLrjX.d.ts} +2 -2
  48. package/dist/mod-D6HodEq7.d.ts +7 -0
  49. package/dist/{mod-D6pS5_xJ.d.cts → mod-DFWeUq2q.d.cts} +1 -1
  50. package/dist/{mod-BHXq4Q3x.d.cts → mod-DWaA45ef.d.cts} +2 -2
  51. package/dist/{mod-jOa7W503.d.ts → mod-q2IR8UiH.d.ts} +1 -1
  52. package/dist/mod.cjs +57 -9
  53. package/dist/mod.d.cts +19 -10
  54. package/dist/mod.d.ts +20 -10
  55. package/dist/mod.js +59 -11
  56. package/dist/nodeinfo/handler.test.js +12 -12
  57. package/dist/nodeinfo/mod.cjs +1 -1
  58. package/dist/nodeinfo/mod.d.cts +2 -2
  59. package/dist/nodeinfo/mod.d.ts +2 -2
  60. package/dist/nodeinfo/mod.js +2 -2
  61. package/dist/otel/mod.cjs +1 -1
  62. package/dist/otel/mod.d.cts +1 -1
  63. package/dist/otel/mod.d.ts +1 -1
  64. package/dist/{owner-Bod8mCab.js → owner-Cfmtlwoe.js} +1 -1
  65. package/dist/{proof--60Adidu.js → proof-Bc8ULrzP.js} +2 -2
  66. package/dist/{proof-C8MAHWxQ.cjs → proof-BoqEqbih.cjs} +2 -2
  67. package/dist/{proof-vG4ePLF2.js → proof-OjMPhNWs.js} +1 -1
  68. package/dist/runtime/mod.cjs +14 -0
  69. package/dist/runtime/mod.d.cts +2 -0
  70. package/dist/runtime/mod.d.ts +4 -0
  71. package/dist/runtime/mod.js +7 -0
  72. package/dist/runtime-c2Njxsry.cjs +17 -0
  73. package/dist/runtime-poamPCMb.js +13 -0
  74. package/dist/{send-B3fWpYN9.js → send-BKW3wSXo.js} +2 -2
  75. package/dist/sig/http.test.js +3 -3
  76. package/dist/sig/key.test.js +2 -2
  77. package/dist/sig/ld.test.js +3 -3
  78. package/dist/sig/mod.cjs +3 -3
  79. package/dist/sig/mod.d.cts +3 -3
  80. package/dist/sig/mod.d.ts +3 -3
  81. package/dist/sig/mod.js +3 -3
  82. package/dist/sig/owner.test.js +3 -3
  83. package/dist/sig/proof.test.js +3 -3
  84. package/dist/testing/mod.d.ts +23 -7
  85. package/dist/testing/mod.js +1 -1
  86. package/dist/{transformers-BjBg6Lag.cjs → transformers-3g8GZwkZ.cjs} +1 -1
  87. package/dist/{types-B6z6CqIz.cjs → types-Cd_hszr_.cjs} +1 -1
  88. package/dist/utils/docloader.test.js +4 -4
  89. package/dist/utils/mod.cjs +3 -3
  90. package/dist/utils/mod.d.cts +3 -3
  91. package/dist/utils/mod.d.ts +3 -3
  92. package/dist/utils/mod.js +3 -3
  93. package/dist/vocab/mod.cjs +13 -0
  94. package/dist/vocab/mod.d.cts +1 -0
  95. package/dist/vocab/mod.d.ts +3 -0
  96. package/dist/vocab/mod.js +5 -0
  97. package/package.json +30 -8
  98. package/dist/middleware-C52jAnyA.js +0 -12
  99. package/dist/middleware-XsmW-sAa.cjs +0 -12
  100. /package/dist/{client-by-PEGAJ.d.cts → client-CwkOPN13.d.cts} +0 -0
  101. /package/dist/{client-CUTUGgvJ.d.ts → client-a7NwzhA2.d.ts} +0 -0
  102. /package/dist/{compat-nxUqe4Z-.js → compat-Bb4NuTUO.js} +0 -0
  103. /package/dist/{http-ClB3pLcL.d.cts → http-CCEu-x1_.d.cts} +0 -0
  104. /package/dist/{http-DLBDPal9.d.ts → http-CODSJcKx.d.ts} +0 -0
  105. /package/dist/{kv-B4vFhIYL.d.cts → kv-g9jFc34-.d.cts} +0 -0
  106. /package/dist/{kv-CYySNrsn.d.ts → kv-jg_8SMc1.d.ts} +0 -0
  107. /package/dist/{mod-1E3W847c.d.ts → mod-AGjRfPjT.d.ts} +0 -0
  108. /package/dist/{mod-C81L6_lQ.d.cts → mod-gq_Xfdz8.d.cts} +0 -0
  109. /package/dist/{nodeinfo-BlLsRSiT.js → nodeinfo-DoESQxq5.js} +0 -0
  110. /package/dist/{owner-C-zfmVAD.d.cts → owner-9yZ5Ibsb.d.cts} +0 -0
  111. /package/dist/{owner-BgI8C-VY.d.ts → owner-DQYAbVmX.d.ts} +0 -0
  112. /package/dist/{sig-CwuONEzF.js → sig-BNhspNOf.js} +0 -0
  113. /package/dist/{sig-DeXX2xnj.cjs → sig-vX39WyWI.cjs} +0 -0
  114. /package/dist/{transformers-N_ip_y4P.js → transformers-C3FLHUd6.js} +0 -0
  115. /package/dist/{types-8l28uC8o.js → types-C93Ob9cU.js} +0 -0
  116. /package/dist/{utils-Db0ZmjcD.cjs → utils-BQ9KqEK9.cjs} +0 -0
  117. /package/dist/{utils-Wranxuoe.js → utils-Dn5OPdSW.js} +0 -0
@@ -2,7 +2,7 @@
2
2
  const { Temporal } = require("@js-temporal/polyfill");
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
- const require_chunk = require('./chunk-DqRYRqnO.cjs');
5
+ const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
6
  const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
7
7
 
8
8
  //#region src/federation/kv.ts
@@ -106,6 +106,11 @@ var InProcessMessageQueue = class {
106
106
  #monitors;
107
107
  #pollIntervalMs;
108
108
  /**
109
+ * Tracks which ordering keys are currently being processed to ensure
110
+ * sequential processing for messages with the same key.
111
+ */
112
+ #processingKeys;
113
+ /**
109
114
  * In-process message queue does not provide native retry mechanisms.
110
115
  * @since 1.7.0
111
116
  */
@@ -118,6 +123,7 @@ var InProcessMessageQueue = class {
118
123
  this.#messages = [];
119
124
  this.#monitors = {};
120
125
  this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
126
+ this.#processingKeys = /* @__PURE__ */ new Set();
121
127
  }
122
128
  enqueue(message, options) {
123
129
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
@@ -128,7 +134,11 @@ var InProcessMessageQueue = class {
128
134
  }), delay);
129
135
  return Promise.resolve();
130
136
  }
131
- this.#messages.push(message);
137
+ const orderingKey = options?.orderingKey ?? null;
138
+ this.#messages.push({
139
+ message,
140
+ orderingKey
141
+ });
132
142
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
133
143
  return Promise.resolve();
134
144
  }
@@ -142,18 +152,29 @@ var InProcessMessageQueue = class {
142
152
  }), delay);
143
153
  return Promise.resolve();
144
154
  }
145
- this.#messages.push(...messages);
155
+ const orderingKey = options?.orderingKey ?? null;
156
+ for (const message of messages) this.#messages.push({
157
+ message,
158
+ orderingKey
159
+ });
146
160
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
147
161
  return Promise.resolve();
148
162
  }
149
163
  async listen(handler, options = {}) {
150
164
  const signal = options.signal;
151
165
  while (signal == null || !signal.aborted) {
152
- while (this.#messages.length > 0) {
153
- const message = this.#messages.shift();
154
- await handler(message);
155
- }
156
- await this.#wait(this.#pollIntervalMs, signal);
166
+ const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
167
+ if (idx >= 0) {
168
+ const queued = this.#messages.splice(idx, 1)[0];
169
+ const { message, orderingKey } = queued;
170
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
171
+ try {
172
+ await handler(message);
173
+ } finally {
174
+ if (orderingKey != null) this.#processingKeys.delete(orderingKey);
175
+ }
176
+ } else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
177
+ else await this.#wait(10, signal);
157
178
  }
158
179
  }
159
180
  #wait(ms, signal) {
@@ -185,6 +206,21 @@ var InProcessMessageQueue = class {
185
206
  * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
186
207
  * workloads.
187
208
  *
209
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
210
+ * *only if* the underlying queue implementation delivers messages in a wrapper
211
+ * format that includes the `__fedify_ordering_key__` property. Currently,
212
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
213
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
214
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
215
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
216
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
217
+ * implementations directly rather than at the `ParallelMessageQueue` level.
218
+ *
219
+ * Messages with the same ordering key will never be processed concurrently
220
+ * by different workers, ensuring sequential processing within each key.
221
+ * Messages with different ordering keys (or no ordering key) can still be
222
+ * processed in parallel.
223
+ *
188
224
  * @since 1.0.0
189
225
  */
190
226
  var ParallelMessageQueue = class ParallelMessageQueue {
@@ -196,6 +232,15 @@ var ParallelMessageQueue = class ParallelMessageQueue {
196
232
  */
197
233
  nativeRetrial;
198
234
  /**
235
+ * Tracks which ordering keys are currently being processed to ensure
236
+ * sequential processing for messages with the same key.
237
+ */
238
+ #processingKeys = /* @__PURE__ */ new Set();
239
+ /**
240
+ * Pending messages waiting for their ordering key to become available.
241
+ */
242
+ #pendingMessages = [];
243
+ /**
199
244
  * Constructs a new {@link ParallelMessageQueue} with the given queue and
200
245
  * number of workers.
201
246
  * @param queue The message queue to use under the hood. Note that
@@ -223,6 +268,25 @@ var ParallelMessageQueue = class ParallelMessageQueue {
223
268
  }
224
269
  await this.queue.enqueueMany(messages, options);
225
270
  }
271
+ /**
272
+ * Extracts ordering key from a message if present.
273
+ *
274
+ * This method only works for queue implementations that deliver messages
275
+ * in the wrapper format with `__fedify_ordering_key__` property. Currently,
276
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
277
+ *
278
+ * For other queue implementations (`InProcessMessageQueue`,
279
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
280
+ * `AmqpMessageQueue`), messages are delivered as raw payloads without the
281
+ * wrapper, so the ordering key cannot be detected here. Those
282
+ * implementations handle ordering guarantees internally.
283
+ */
284
+ #extractOrderingKey(message) {
285
+ if (message != null && typeof message === "object") {
286
+ if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
287
+ }
288
+ return void 0;
289
+ }
226
290
  listen(handler, options = {}) {
227
291
  const workers = /* @__PURE__ */ new Map();
228
292
  return this.queue.listen(async (message) => {
@@ -231,13 +295,33 @@ var ParallelMessageQueue = class ParallelMessageQueue {
231
295
  workers.delete(consumedId);
232
296
  }
233
297
  const workerId = crypto.randomUUID();
234
- const promise = this.#work(workerId, handler, message);
298
+ const orderingKey = this.#extractOrderingKey(message);
299
+ if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
300
+ this.#pendingMessages.push({
301
+ message,
302
+ orderingKey,
303
+ resolve
304
+ });
305
+ });
306
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
307
+ const promise = this.#work(workerId, handler, message, orderingKey);
235
308
  workers.set(workerId, promise);
236
309
  }, options);
237
310
  }
238
- async #work(workerId, handler, message) {
311
+ async #work(workerId, handler, message, orderingKey) {
239
312
  await this.#sleep(0);
240
- await handler(message);
313
+ try {
314
+ await handler(message);
315
+ } finally {
316
+ if (orderingKey != null) {
317
+ this.#processingKeys.delete(orderingKey);
318
+ const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
319
+ if (pendingIdx >= 0) {
320
+ const pending = this.#pendingMessages.splice(pendingIdx, 1)[0];
321
+ pending.resolve();
322
+ }
323
+ }
324
+ }
241
325
  return workerId;
242
326
  }
243
327
  #sleep(ms) {
@@ -105,6 +105,11 @@ var InProcessMessageQueue = class {
105
105
  #monitors;
106
106
  #pollIntervalMs;
107
107
  /**
108
+ * Tracks which ordering keys are currently being processed to ensure
109
+ * sequential processing for messages with the same key.
110
+ */
111
+ #processingKeys;
112
+ /**
108
113
  * In-process message queue does not provide native retry mechanisms.
109
114
  * @since 1.7.0
110
115
  */
@@ -117,6 +122,7 @@ var InProcessMessageQueue = class {
117
122
  this.#messages = [];
118
123
  this.#monitors = {};
119
124
  this.#pollIntervalMs = Temporal.Duration.from(options.pollInterval ?? { seconds: 5 }).total("millisecond");
125
+ this.#processingKeys = /* @__PURE__ */ new Set();
120
126
  }
121
127
  enqueue(message, options) {
122
128
  const delay = options?.delay == null ? 0 : Math.max(options.delay.total("millisecond"), 0);
@@ -127,7 +133,11 @@ var InProcessMessageQueue = class {
127
133
  }), delay);
128
134
  return Promise.resolve();
129
135
  }
130
- this.#messages.push(message);
136
+ const orderingKey = options?.orderingKey ?? null;
137
+ this.#messages.push({
138
+ message,
139
+ orderingKey
140
+ });
131
141
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
132
142
  return Promise.resolve();
133
143
  }
@@ -141,18 +151,29 @@ var InProcessMessageQueue = class {
141
151
  }), delay);
142
152
  return Promise.resolve();
143
153
  }
144
- this.#messages.push(...messages);
154
+ const orderingKey = options?.orderingKey ?? null;
155
+ for (const message of messages) this.#messages.push({
156
+ message,
157
+ orderingKey
158
+ });
145
159
  for (const monitorId in this.#monitors) this.#monitors[monitorId]();
146
160
  return Promise.resolve();
147
161
  }
148
162
  async listen(handler, options = {}) {
149
163
  const signal = options.signal;
150
164
  while (signal == null || !signal.aborted) {
151
- while (this.#messages.length > 0) {
152
- const message = this.#messages.shift();
153
- await handler(message);
154
- }
155
- await this.#wait(this.#pollIntervalMs, signal);
165
+ const idx = this.#messages.findIndex((m) => m.orderingKey == null || !this.#processingKeys.has(m.orderingKey));
166
+ if (idx >= 0) {
167
+ const queued = this.#messages.splice(idx, 1)[0];
168
+ const { message, orderingKey } = queued;
169
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
170
+ try {
171
+ await handler(message);
172
+ } finally {
173
+ if (orderingKey != null) this.#processingKeys.delete(orderingKey);
174
+ }
175
+ } else if (this.#messages.length === 0) await this.#wait(this.#pollIntervalMs, signal);
176
+ else await this.#wait(10, signal);
156
177
  }
157
178
  }
158
179
  #wait(ms, signal) {
@@ -184,6 +205,21 @@ var InProcessMessageQueue = class {
184
205
  * for I/O-bound tasks, but not for CPU-bound tasks, which is okay for Fedify's
185
206
  * workloads.
186
207
  *
208
+ * When using `ParallelMessageQueue`, the ordering guarantee is preserved
209
+ * *only if* the underlying queue implementation delivers messages in a wrapper
210
+ * format that includes the `__fedify_ordering_key__` property. Currently,
211
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
212
+ * For other queue implementations (e.g., `InProcessMessageQueue`,
213
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
214
+ * `AmqpMessageQueue`), the ordering key cannot be detected by
215
+ * `ParallelMessageQueue`, so ordering guarantees are handled by those
216
+ * implementations directly rather than at the `ParallelMessageQueue` level.
217
+ *
218
+ * Messages with the same ordering key will never be processed concurrently
219
+ * by different workers, ensuring sequential processing within each key.
220
+ * Messages with different ordering keys (or no ordering key) can still be
221
+ * processed in parallel.
222
+ *
187
223
  * @since 1.0.0
188
224
  */
189
225
  var ParallelMessageQueue = class ParallelMessageQueue {
@@ -195,6 +231,15 @@ var ParallelMessageQueue = class ParallelMessageQueue {
195
231
  */
196
232
  nativeRetrial;
197
233
  /**
234
+ * Tracks which ordering keys are currently being processed to ensure
235
+ * sequential processing for messages with the same key.
236
+ */
237
+ #processingKeys = /* @__PURE__ */ new Set();
238
+ /**
239
+ * Pending messages waiting for their ordering key to become available.
240
+ */
241
+ #pendingMessages = [];
242
+ /**
198
243
  * Constructs a new {@link ParallelMessageQueue} with the given queue and
199
244
  * number of workers.
200
245
  * @param queue The message queue to use under the hood. Note that
@@ -222,6 +267,25 @@ var ParallelMessageQueue = class ParallelMessageQueue {
222
267
  }
223
268
  await this.queue.enqueueMany(messages, options);
224
269
  }
270
+ /**
271
+ * Extracts ordering key from a message if present.
272
+ *
273
+ * This method only works for queue implementations that deliver messages
274
+ * in the wrapper format with `__fedify_ordering_key__` property. Currently,
275
+ * only `DenoKvMessageQueue` and `WorkersMessageQueue` use this format.
276
+ *
277
+ * For other queue implementations (`InProcessMessageQueue`,
278
+ * `RedisMessageQueue`, `PostgresMessageQueue`, `SqliteMessageQueue`,
279
+ * `AmqpMessageQueue`), messages are delivered as raw payloads without the
280
+ * wrapper, so the ordering key cannot be detected here. Those
281
+ * implementations handle ordering guarantees internally.
282
+ */
283
+ #extractOrderingKey(message) {
284
+ if (message != null && typeof message === "object") {
285
+ if ("__fedify_ordering_key__" in message) return message.__fedify_ordering_key__;
286
+ }
287
+ return void 0;
288
+ }
225
289
  listen(handler, options = {}) {
226
290
  const workers = /* @__PURE__ */ new Map();
227
291
  return this.queue.listen(async (message) => {
@@ -230,13 +294,33 @@ var ParallelMessageQueue = class ParallelMessageQueue {
230
294
  workers.delete(consumedId);
231
295
  }
232
296
  const workerId = crypto.randomUUID();
233
- const promise = this.#work(workerId, handler, message);
297
+ const orderingKey = this.#extractOrderingKey(message);
298
+ if (orderingKey != null && this.#processingKeys.has(orderingKey)) await new Promise((resolve) => {
299
+ this.#pendingMessages.push({
300
+ message,
301
+ orderingKey,
302
+ resolve
303
+ });
304
+ });
305
+ if (orderingKey != null) this.#processingKeys.add(orderingKey);
306
+ const promise = this.#work(workerId, handler, message, orderingKey);
234
307
  workers.set(workerId, promise);
235
308
  }, options);
236
309
  }
237
- async #work(workerId, handler, message) {
310
+ async #work(workerId, handler, message, orderingKey) {
238
311
  await this.#sleep(0);
239
- await handler(message);
312
+ try {
313
+ await handler(message);
314
+ } finally {
315
+ if (orderingKey != null) {
316
+ this.#processingKeys.delete(orderingKey);
317
+ const pendingIdx = this.#pendingMessages.findIndex((p) => p.orderingKey === orderingKey);
318
+ if (pendingIdx >= 0) {
319
+ const pending = this.#pendingMessages.splice(pendingIdx, 1)[0];
320
+ pending.resolve();
321
+ }
322
+ }
323
+ }
240
324
  return workerId;
241
325
  }
242
326
  #sleep(ms) {
@@ -2,7 +2,7 @@
2
2
  const { Temporal } = require("@js-temporal/polyfill");
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
- const require_chunk = require('./chunk-DqRYRqnO.cjs');
5
+ const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
6
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
7
  const __fedify_vocab = require_chunk.__toESM(require("@fedify/vocab"));
8
8
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
@@ -14,7 +14,7 @@ const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runt
14
14
 
15
15
  //#region deno.json
16
16
  var name = "@fedify/fedify";
17
- var version = "2.0.0-dev.241+58c8126c";
17
+ var version = "2.0.0-dev.323+1d796545";
18
18
  var license = "MIT";
19
19
  var exports$1 = {
20
20
  ".": "./src/mod.ts",
@@ -22,8 +22,10 @@ var exports$1 = {
22
22
  "./federation": "./src/federation/mod.ts",
23
23
  "./nodeinfo": "./src/nodeinfo/mod.ts",
24
24
  "./otel": "./src/otel/mod.ts",
25
+ "./runtime": "./src/runtime/mod.ts",
25
26
  "./sig": "./src/sig/mod.ts",
26
- "./utils": "./src/utils/mod.ts"
27
+ "./utils": "./src/utils/mod.ts",
28
+ "./vocab": "./src/vocab/mod.ts"
27
29
  };
28
30
  var imports = {
29
31
  "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
@@ -58,7 +60,13 @@ var exclude = [
58
60
  "src/cfworkers/server.js",
59
61
  "src/cfworkers/server.js.map"
60
62
  ];
61
- var publish = { "exclude": ["**/*.test.ts", "src/testing/"] };
63
+ var publish = { "exclude": [
64
+ "**/*.test.ts",
65
+ "src/testing/",
66
+ "tsdown.config.ts",
67
+ "scripts/",
68
+ "wrangler.toml"
69
+ ] };
62
70
  var tasks = {
63
71
  "codegen": "deno task -f @fedify/vocab compile",
64
72
  "cache": {
@@ -13,7 +13,7 @@ import { getDocumentLoader } from "@fedify/vocab-runtime";
13
13
 
14
14
  //#region deno.json
15
15
  var name = "@fedify/fedify";
16
- var version = "2.0.0-dev.241+58c8126c";
16
+ var version = "2.0.0-dev.323+1d796545";
17
17
  var license = "MIT";
18
18
  var exports = {
19
19
  ".": "./src/mod.ts",
@@ -21,8 +21,10 @@ var exports = {
21
21
  "./federation": "./src/federation/mod.ts",
22
22
  "./nodeinfo": "./src/nodeinfo/mod.ts",
23
23
  "./otel": "./src/otel/mod.ts",
24
+ "./runtime": "./src/runtime/mod.ts",
24
25
  "./sig": "./src/sig/mod.ts",
25
- "./utils": "./src/utils/mod.ts"
26
+ "./utils": "./src/utils/mod.ts",
27
+ "./vocab": "./src/vocab/mod.ts"
26
28
  };
27
29
  var imports = {
28
30
  "@multiformats/base-x": "npm:@multiformats/base-x@^4.0.1",
@@ -57,7 +59,13 @@ var exclude = [
57
59
  "src/cfworkers/server.js",
58
60
  "src/cfworkers/server.js.map"
59
61
  ];
60
- var publish = { "exclude": ["**/*.test.ts", "src/testing/"] };
62
+ var publish = { "exclude": [
63
+ "**/*.test.ts",
64
+ "src/testing/",
65
+ "tsdown.config.ts",
66
+ "scripts/",
67
+ "wrangler.toml"
68
+ ] };
61
69
  var tasks = {
62
70
  "codegen": "deno task -f @fedify/vocab compile",
63
71
  "cache": {
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-DOeSTfhz.js";
7
- import { fetchKey, validateCryptoKey } from "./key-3_vbTfr8.js";
6
+ import { deno_default } from "./deno-BTAi5-ur.js";
7
+ import { fetchKey, validateCryptoKey } from "./key-BI6sqU5u.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { CryptographicKey } from "@fedify/vocab";
10
10
  import { SpanStatusCode, trace } from "@opentelemetry/api";
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-DOeSTfhz.js";
6
+ import { deno_default } from "./deno-BTAi5-ur.js";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { Activity, getTypeId } from "@fedify/vocab";
9
9
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
@@ -3,7 +3,7 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-DOeSTfhz.js";
6
+ import { deno_default } from "./deno-BTAi5-ur.js";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
9
9
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -2,7 +2,7 @@
2
2
  import { Temporal } from "@js-temporal/polyfill";
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
 
5
- import { doubleKnock, validateCryptoKey } from "./http-i8VdY2df.js";
5
+ import { doubleKnock, validateCryptoKey } from "./http-C02fQ5SX.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { curry } from "es-toolkit";
8
8
  import { UrlError, createActivityPubRequest, getDocumentLoader, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
@@ -2,8 +2,8 @@
2
2
  const { Temporal } = require("@js-temporal/polyfill");
3
3
  const { URLPattern } = require("urlpattern-polyfill");
4
4
 
5
- const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
- const require_http = require('./http-C1LrW2D3.cjs');
5
+ const require_chunk = require('./chunk-CGaQZ11T.cjs');
6
+ const require_http = require('./http-BCfCt7nq.cjs');
7
7
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
8
8
  const es_toolkit = require_chunk.__toESM(require("es-toolkit"));
9
9
  const __fedify_vocab_runtime = require_chunk.__toESM(require("@fedify/vocab-runtime"));
@@ -3,8 +3,8 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { deno_default } from "./deno-DOeSTfhz.js";
7
- import { fetchKey, validateCryptoKey } from "./key-3_vbTfr8.js";
6
+ import { deno_default } from "./deno-BTAi5-ur.js";
7
+ import { fetchKey, validateCryptoKey } from "./key-BI6sqU5u.js";
8
8
  import { getLogger } from "@logtape/logtape";
9
9
  import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
10
10
  import { getDocumentLoader } from "@fedify/vocab-runtime";
@@ -0,0 +1,12 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "./transformers-C3FLHUd6.js";
6
+ import "./http-C02fQ5SX.js";
7
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-LQKxYF7X.js";
8
+ import "./proof-OjMPhNWs.js";
9
+ import "./types-C93Ob9cU.js";
10
+ import "./kv-cache-BLxaWwPk.js";
11
+
12
+ export { FederationImpl };
@@ -3,24 +3,24 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import "./deno-DOeSTfhz.js";
7
- import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DbwwSEOr.js";
6
+ import "./deno-BTAi5-ur.js";
7
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-DaOdxVOc.js";
8
8
  import "./client-Dg7OfUDA.js";
9
9
  import "./router-D9eI0s4b.js";
10
10
  import "./types-CPz01LGH.js";
11
- import "./key-3_vbTfr8.js";
12
- import "./http-DGkEl4mw.js";
13
- import "./ld-BQxhMgOJ.js";
14
- import "./owner-Bod8mCab.js";
15
- import "./proof--60Adidu.js";
16
- import "./docloader-C1AGOQQm.js";
11
+ import "./key-BI6sqU5u.js";
12
+ import "./http-C4WANccp.js";
13
+ import "./ld-qTcTL2A4.js";
14
+ import "./owner-Cfmtlwoe.js";
15
+ import "./proof-Bc8ULrzP.js";
16
+ import "./docloader-D8dzb6AT.js";
17
17
  import "./kv-cache-B__dHl7g.js";
18
- import "./inbox-Cp87HRVs.js";
19
- import "./builder-CR-ZQZJR.js";
18
+ import "./inbox-CdBcxHA7.js";
19
+ import "./builder-CvKuNW7P.js";
20
20
  import "./collection-CcnIw1qY.js";
21
21
  import "./keycache-DRxpZ5r9.js";
22
22
  import "./negotiation-5NPJL6zp.js";
23
23
  import "./retry-D4GJ670a.js";
24
- import "./send-B3fWpYN9.js";
24
+ import "./send-BKW3wSXo.js";
25
25
 
26
26
  export { FederationImpl };