@fedify/fedify 2.0.0-pr.469.1873 → 2.0.0-pr.474.1879

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 (122) hide show
  1. package/dist/{actor-Bo3uuvwH.js → actor-BYv3E3MI.js} +185 -185
  2. package/dist/{actor-DoaVs0vL.cjs → actor-CjcnBLTk.cjs} +185 -185
  3. package/dist/{actor-DhFfLv7K.js → actor-DM_mczcz.js} +1 -1
  4. package/dist/{builder-DFaO3_4-.js → builder-CpW45hts.js} +3 -3
  5. package/dist/compat/mod.d.cts +2 -3
  6. package/dist/compat/mod.d.ts +2 -3
  7. package/dist/compat/transformers.test.js +14 -14
  8. package/dist/{context-DG0huGW-.d.ts → context-DXV-2IZN.d.ts} +146 -3
  9. package/dist/{context-DJ8aSy2Q.d.cts → context-Nt2rAqjj.d.cts} +146 -3
  10. package/dist/{docloader-B1AZ1LMA.js → docloader-DPQnUMPZ.js} +2 -2
  11. package/dist/{esm-CbckHird.js → esm-CHBTY23R.js} +1 -1
  12. package/dist/federation/builder.test.js +4 -4
  13. package/dist/federation/collection.test.js +2 -2
  14. package/dist/federation/handler.test.js +15 -15
  15. package/dist/federation/handler_requirehttpsig.test.js +138 -0
  16. package/dist/federation/idempotency.test.js +15 -15
  17. package/dist/federation/inbox.test.js +3 -3
  18. package/dist/federation/keycache.test.js +3 -3
  19. package/dist/federation/kv.test.js +2 -2
  20. package/dist/federation/middleware.test.js +16 -16
  21. package/dist/federation/mod.cjs +7 -7
  22. package/dist/federation/mod.d.cts +2 -3
  23. package/dist/federation/mod.d.ts +2 -3
  24. package/dist/federation/mod.js +7 -7
  25. package/dist/federation/mq.test.js +6 -4
  26. package/dist/federation/negotiation.test.js +2 -2
  27. package/dist/federation/retry.test.js +2 -2
  28. package/dist/federation/router.test.js +2 -2
  29. package/dist/federation/send.test.js +9 -9
  30. package/dist/{http-D27ZccIJ.cjs → http-B1cyhAOR.cjs} +2 -2
  31. package/dist/{http-D8SvAGVC.js → http-CNbh6Bgj.js} +2 -2
  32. package/dist/{http-nnaaa9xj.js → http-Di-WAayg.js} +2 -2
  33. package/dist/{inbox-C5M1_a0k.js → inbox-CKpjNIIw.js} +1 -1
  34. package/dist/{key-bc3A8THw.js → key-Bm6xoWJ9.js} +2 -2
  35. package/dist/{keycache-CpTjHRpy.js → keycache-BoIUmk-X.js} +1 -1
  36. package/dist/{keys-D6W2Pnoh.js → keys-BJSEmAMh.js} +1 -1
  37. package/dist/{kv-cache-B_RVzls5.js → kv-cache-BCfbzWvV.js} +1 -1
  38. package/dist/{kv-cache-CZcZLaEo.cjs → kv-cache-ugHk-g8V.cjs} +1 -1
  39. package/dist/{ld-D5Vg307g.js → ld-CFrblqOy.js} +2 -2
  40. package/dist/{lookup-DO7ZeFb2.cjs → lookup-BKHMnItE.cjs} +2 -7
  41. package/dist/{lookup-BBrk-_5k.js → lookup-CjRKAy5i.js} +186 -191
  42. package/dist/{lookup-BXY5QJif.js → lookup-CovW5HO7.js} +2 -7
  43. package/dist/{middleware-CU0RJROn.js → middleware-BCCuNXoU.js} +17 -15
  44. package/dist/middleware-CaQFohcx.js +26 -0
  45. package/dist/middleware-CqJTYvui.cjs +15 -0
  46. package/dist/{middleware-RgDZByG7.js → middleware-DFP98BrZ.js} +13 -11
  47. package/dist/middleware-cA6uI21b.js +15 -0
  48. package/dist/{middleware-Dy7xPuu-.cjs → middleware-fxZRXc2R.cjs} +13 -11
  49. package/dist/{mod-DJcZDvjA.d.cts → mod-CKRSFzK_.d.cts} +1 -1
  50. package/dist/{mod-BoHnwOCs.d.ts → mod-C_6Uxusd.d.ts} +1 -1
  51. package/dist/mod.cjs +7 -7
  52. package/dist/mod.d.cts +5 -6
  53. package/dist/mod.d.ts +5 -6
  54. package/dist/mod.js +7 -7
  55. package/dist/nodeinfo/client.test.js +3 -3
  56. package/dist/nodeinfo/handler.test.js +14 -14
  57. package/dist/nodeinfo/mod.d.cts +1 -1
  58. package/dist/nodeinfo/mod.d.ts +1 -1
  59. package/dist/nodeinfo/types.test.js +2 -2
  60. package/dist/{owner-DSDpCSms.js → owner-8cgMngcR.js} +2 -2
  61. package/dist/{proof-Bvu8zaM1.js → proof-BbhNICOW.js} +2 -2
  62. package/dist/{proof-C1-VSUNW.cjs → proof-C3woq5fl.cjs} +3 -3
  63. package/dist/{proof-4L3D-iT4.js → proof-OnfETSbB.js} +3 -3
  64. package/dist/{send-Cr3PSs0N.js → send-zlaQ6fqY.js} +2 -2
  65. package/dist/sig/http.test.js +7 -7
  66. package/dist/sig/key.test.js +5 -5
  67. package/dist/sig/ld.test.js +6 -6
  68. package/dist/sig/mod.cjs +4 -4
  69. package/dist/sig/mod.d.cts +1 -1
  70. package/dist/sig/mod.d.ts +1 -1
  71. package/dist/sig/mod.js +4 -4
  72. package/dist/sig/owner.test.js +6 -6
  73. package/dist/sig/proof.test.js +6 -6
  74. package/dist/testing/docloader.test.js +2 -2
  75. package/dist/testing/mod.d.ts +6 -0
  76. package/dist/testing/mod.js +2 -2
  77. package/dist/{testing-Bw9AfLxQ.js → testing-DHsP4t6k.js} +1 -1
  78. package/dist/utils/docloader.test.js +8 -8
  79. package/dist/utils/kv-cache.test.js +2 -2
  80. package/dist/utils/mod.cjs +4 -4
  81. package/dist/utils/mod.d.cts +1 -1
  82. package/dist/utils/mod.d.ts +1 -1
  83. package/dist/utils/mod.js +4 -4
  84. package/dist/vocab/actor.test.js +4 -4
  85. package/dist/vocab/lookup.test.js +3 -3
  86. package/dist/vocab/mod.cjs +3 -3
  87. package/dist/vocab/mod.js +3 -3
  88. package/dist/vocab/type.test.js +2 -2
  89. package/dist/vocab/vocab.test.js +3 -3
  90. package/dist/{vocab-B74bq08l.js → vocab-DMGCHMXF.js} +2 -2
  91. package/dist/{vocab-HJLl6-1F.cjs → vocab-YXPM77QO.cjs} +2 -2
  92. package/dist/webfinger/handler.test.js +14 -14
  93. package/dist/webfinger/lookup.test.js +3 -3
  94. package/dist/webfinger/mod.cjs +1 -1
  95. package/dist/webfinger/mod.js +1 -1
  96. package/package.json +3 -34
  97. package/dist/denokv-CCssOzMJ.js +0 -57
  98. package/dist/middleware-BU2XnCCI.js +0 -15
  99. package/dist/middleware-D4qQ6MLq.cjs +0 -15
  100. package/dist/middleware-DEu9Xuza.js +0 -26
  101. package/dist/mq-CUKlBw08.d.ts +0 -143
  102. package/dist/mq-DcJPkXD5.d.cts +0 -140
  103. package/dist/x/cfworkers.cjs +0 -100
  104. package/dist/x/cfworkers.d.cts +0 -59
  105. package/dist/x/cfworkers.d.ts +0 -61
  106. package/dist/x/cfworkers.js +0 -98
  107. package/dist/x/cfworkers.test.js +0 -177
  108. package/dist/x/hono.cjs +0 -61
  109. package/dist/x/hono.d.cts +0 -53
  110. package/dist/x/hono.d.ts +0 -55
  111. package/dist/x/hono.js +0 -60
  112. package/dist/x/sveltekit.cjs +0 -69
  113. package/dist/x/sveltekit.d.cts +0 -45
  114. package/dist/x/sveltekit.d.ts +0 -47
  115. package/dist/x/sveltekit.js +0 -68
  116. /package/dist/{x/cfworkers.test.d.ts → federation/handler_requirehttpsig.test.d.ts} +0 -0
  117. /package/dist/{mod-C2tOeRkN.d.cts → mod-CcDPcLJW.d.cts} +0 -0
  118. /package/dist/{mod-B2iOw50L.d.ts → mod-D5Z2tISD.d.ts} +0 -0
  119. /package/dist/{mod-0noXw66R.d.cts → mod-DMpuiKXi.d.cts} +0 -0
  120. /package/dist/{mod-DgdBYYa0.d.cts → mod-DgxG-byT.d.cts} +0 -0
  121. /package/dist/{mod-B9M-8jm2.d.ts → mod-aAE2wOWV.d.ts} +0 -0
  122. /package/dist/{mod-xIj-IT58.d.ts → mod-bjzj5QIb.d.ts} +0 -0
@@ -1,98 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { getLogger } from "@logtape/logtape";
6
-
7
- //#region src/x/cfworkers.ts
8
- /**
9
- * Implementation of the {@link KvStore} interface for Cloudflare Workers KV
10
- * binding. This class provides a wrapper around Cloudflare's KV namespace to
11
- * store and retrieve JSON-serializable values using structured keys.
12
- *
13
- * Note that this implementation does not support the {@link KvStore.cas}
14
- * operation, as Cloudflare Workers KV does not support atomic compare-and-swap
15
- * operations. If you need this functionality, consider using a different
16
- * key–value store that supports atomic operations.
17
- *
18
- * @deprecated This class has been moved to `@fedify/cfworkers` package.
19
- * Import `WorkersKvStore` from `@fedify/cfworkers` instead.
20
- * This class will be removed in Fedify v2.0.
21
- * @since 1.6.0
22
- */
23
- var WorkersKvStore = class {
24
- #namespace;
25
- constructor(namespace) {
26
- const logger = getLogger(["fedify", "cfworkers"]);
27
- logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
28
- this.#namespace = namespace;
29
- }
30
- #encodeKey(key) {
31
- return JSON.stringify(key);
32
- }
33
- async get(key) {
34
- const encodedKey = this.#encodeKey(key);
35
- const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
36
- return metadata == null || metadata.expires < Date.now() ? void 0 : value;
37
- }
38
- async set(key, value, options) {
39
- const encodedKey = this.#encodeKey(key);
40
- const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
41
- await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
42
- expirationTtl: Math.max(options.ttl.total("seconds"), 60),
43
- metadata
44
- });
45
- }
46
- delete(key) {
47
- return this.#namespace.delete(this.#encodeKey(key));
48
- }
49
- };
50
- /**
51
- * Implementation of the {@link MessageQueue} interface for Cloudflare
52
- * Workers Queues binding. This class provides a wrapper around Cloudflare's
53
- * Queues to send messages to a queue.
54
- *
55
- * Note that this implementation does not support the `listen()` method,
56
- * as Cloudflare Workers Queues do not support message consumption in the same
57
- * way as other message queue systems. Instead, you should use
58
- * the {@link Federation.processQueuedTask} method to process messages
59
- * passed to the queue.
60
- *
61
- * @deprecated This class has been moved to `@fedify/cfworkers` package.
62
- * Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
63
- * This class will be removed in Fedify v2.0.
64
- * @since 1.6.0
65
- */
66
- var WorkersMessageQueue = class {
67
- #queue;
68
- /**
69
- * Cloudflare Queues provide automatic retry with exponential backoff
70
- * and Dead Letter Queues.
71
- * @since 1.7.0
72
- */
73
- nativeRetrial = true;
74
- constructor(queue) {
75
- const logger = getLogger(["fedify", "cfworkers"]);
76
- logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
77
- this.#queue = queue;
78
- }
79
- enqueue(message, options) {
80
- return this.#queue.send(message, {
81
- contentType: "json",
82
- delaySeconds: options?.delay?.total("seconds") ?? 0
83
- });
84
- }
85
- enqueueMany(messages, options) {
86
- const requests = messages.map((msg) => ({
87
- body: msg,
88
- contentType: "json"
89
- }));
90
- return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
91
- }
92
- listen(_handler, _options) {
93
- throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
94
- }
95
- };
96
-
97
- //#endregion
98
- export { WorkersKvStore, WorkersMessageQueue };
@@ -1,177 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
- globalThis.addEventListener = () => {};
5
-
6
- import "../lookup-BBrk-_5k.js";
7
- import { assertEquals } from "../assert_equals-DSbWqCm3.js";
8
- import "../assert-MZs1qjMx.js";
9
- import "../assert_instance_of-DHz7EHNU.js";
10
- import { test } from "../testing-Bw9AfLxQ.js";
11
- import "../std__assert-DWivtrGR.js";
12
- import "../assert_rejects-Ce45JcFg.js";
13
- import "../assert_throws-BNXdRGWP.js";
14
- import "../assert_not_equals-C80BG-_5.js";
15
- import { delay } from "es-toolkit";
16
- import { getLogger } from "@logtape/logtape";
17
-
18
- //#region src/x/cfworkers.ts
19
- /**
20
- * Implementation of the {@link KvStore} interface for Cloudflare Workers KV
21
- * binding. This class provides a wrapper around Cloudflare's KV namespace to
22
- * store and retrieve JSON-serializable values using structured keys.
23
- *
24
- * Note that this implementation does not support the {@link KvStore.cas}
25
- * operation, as Cloudflare Workers KV does not support atomic compare-and-swap
26
- * operations. If you need this functionality, consider using a different
27
- * key–value store that supports atomic operations.
28
- *
29
- * @deprecated This class has been moved to `@fedify/cfworkers` package.
30
- * Import `WorkersKvStore` from `@fedify/cfworkers` instead.
31
- * This class will be removed in Fedify v2.0.
32
- * @since 1.6.0
33
- */
34
- var WorkersKvStore = class {
35
- #namespace;
36
- constructor(namespace) {
37
- const logger = getLogger(["fedify", "cfworkers"]);
38
- logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersKvStore` from `@fedify/cfworkers` package instead.");
39
- this.#namespace = namespace;
40
- }
41
- #encodeKey(key) {
42
- return JSON.stringify(key);
43
- }
44
- async get(key) {
45
- const encodedKey = this.#encodeKey(key);
46
- const { value, metadata } = await this.#namespace.getWithMetadata(encodedKey, "json");
47
- return metadata == null || metadata.expires < Date.now() ? void 0 : value;
48
- }
49
- async set(key, value, options) {
50
- const encodedKey = this.#encodeKey(key);
51
- const metadata = options?.ttl == null ? {} : { expires: Date.now() + options.ttl.total("milliseconds") };
52
- await this.#namespace.put(encodedKey, JSON.stringify(value), options?.ttl == null ? { metadata } : {
53
- expirationTtl: Math.max(options.ttl.total("seconds"), 60),
54
- metadata
55
- });
56
- }
57
- delete(key) {
58
- return this.#namespace.delete(this.#encodeKey(key));
59
- }
60
- };
61
- /**
62
- * Implementation of the {@link MessageQueue} interface for Cloudflare
63
- * Workers Queues binding. This class provides a wrapper around Cloudflare's
64
- * Queues to send messages to a queue.
65
- *
66
- * Note that this implementation does not support the `listen()` method,
67
- * as Cloudflare Workers Queues do not support message consumption in the same
68
- * way as other message queue systems. Instead, you should use
69
- * the {@link Federation.processQueuedTask} method to process messages
70
- * passed to the queue.
71
- *
72
- * @deprecated This class has been moved to `@fedify/cfworkers` package.
73
- * Import `WorkersMessageQueue` from `@fedify/cfworkers` instead.
74
- * This class will be removed in Fedify v2.0.
75
- * @since 1.6.0
76
- */
77
- var WorkersMessageQueue = class {
78
- #queue;
79
- /**
80
- * Cloudflare Queues provide automatic retry with exponential backoff
81
- * and Dead Letter Queues.
82
- * @since 1.7.0
83
- */
84
- nativeRetrial = true;
85
- constructor(queue) {
86
- const logger = getLogger(["fedify", "cfworkers"]);
87
- logger.warn("The `@fedify/fedify/x/cfworkers` module is deprecated; use `WorkersMessageQueue` from `@fedify/cfworkers` package instead.");
88
- this.#queue = queue;
89
- }
90
- enqueue(message, options) {
91
- return this.#queue.send(message, {
92
- contentType: "json",
93
- delaySeconds: options?.delay?.total("seconds") ?? 0
94
- });
95
- }
96
- enqueueMany(messages, options) {
97
- const requests = messages.map((msg) => ({
98
- body: msg,
99
- contentType: "json"
100
- }));
101
- return this.#queue.sendBatch(requests, { delaySeconds: options?.delay?.total("seconds") ?? 0 });
102
- }
103
- listen(_handler, _options) {
104
- throw new TypeError("WorkersMessageQueue does not support listen(). Use Federation.processQueuedTask() method instead.");
105
- }
106
- };
107
-
108
- //#endregion
109
- //#region src/x/cfworkers.test.ts
110
- test({
111
- name: "WorkersKvStore",
112
- ignore: !("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers"),
113
- async fn(t) {
114
- const { env } = t;
115
- const store = new WorkersKvStore(env.KV1);
116
- await t.step("set() & get()", async () => {
117
- await store.set(["foo", "bar"], {
118
- foo: 1,
119
- bar: 2
120
- });
121
- assertEquals(await store.get(["foo", "bar"]), {
122
- foo: 1,
123
- bar: 2
124
- });
125
- assertEquals(await store.get(["foo"]), void 0);
126
- await store.set(["foo", "baz"], "baz", { ttl: Temporal.Duration.from({ seconds: 0 }) });
127
- assertEquals(await store.get(["foo", "baz"]), void 0);
128
- });
129
- await t.step("delete()", async () => {
130
- await store.delete(["foo", "bar"]);
131
- assertEquals(await store.get(["foo", "bar"]), void 0);
132
- });
133
- }
134
- });
135
- test({
136
- name: "WorkersMessageQueue",
137
- ignore: !("navigator" in globalThis && navigator.userAgent === "Cloudflare-Workers"),
138
- async fn(t) {
139
- const { env, messageBatches } = t;
140
- const queue = new WorkersMessageQueue(env.Q1);
141
- await queue.enqueue({
142
- foo: 1,
143
- bar: 2
144
- });
145
- await waitFor(() => messageBatches.length > 0, 5e3);
146
- assertEquals(messageBatches.length, 1);
147
- assertEquals(messageBatches[0].queue, "Q1");
148
- assertEquals(messageBatches[0].messages.length, 1);
149
- assertEquals(messageBatches[0].messages[0].body, {
150
- foo: 1,
151
- bar: 2
152
- });
153
- await queue.enqueue({
154
- baz: 3,
155
- qux: 4
156
- }, { delay: Temporal.Duration.from({ seconds: 3 }) });
157
- await delay(2e3);
158
- assertEquals(messageBatches.length, 1);
159
- await waitFor(() => messageBatches.length > 1, 6e3);
160
- assertEquals(messageBatches[1].queue, "Q1");
161
- assertEquals(messageBatches[1].messages.length, 1);
162
- assertEquals(messageBatches[1].messages[0].body, {
163
- baz: 3,
164
- qux: 4
165
- });
166
- }
167
- });
168
- async function waitFor(predicate, timeoutMs) {
169
- let delayed = 0;
170
- while (!predicate()) {
171
- await delay(500);
172
- delayed += 500;
173
- if (delayed > timeoutMs) throw new Error("Timeout");
174
- }
175
- }
176
-
177
- //#endregion
package/dist/x/hono.cjs DELETED
@@ -1,61 +0,0 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- const require_chunk = require('../chunk-DqRYRqnO.cjs');
6
- const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
-
8
- //#region src/x/hono.ts
9
- /**
10
- * Create a Hono middleware to integrate with the {@link Federation} object.
11
- *
12
- * @deprecated This function has been moved to `@fedify/hono` package.
13
- * Import `federation` from `@fedify/hono` instead.
14
- * This function will be removed in Fedify v2.0.
15
- *
16
- * @template TContextData A type of the context data for the {@link Federation}
17
- * object.
18
- * @template THonoContext A type of the Hono context.
19
- * @param federation A {@link Federation} object to integrate with Hono.
20
- * @param contextDataFactory A function to create a context data for the
21
- * {@link Federation} object.
22
- * @returns A Hono middleware.
23
- */
24
- function federation(federation$1, contextDataFactory) {
25
- const logger = (0, __logtape_logtape.getLogger)([
26
- "fedify",
27
- "federation",
28
- "hono"
29
- ]);
30
- logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
31
- return async (ctx, next) => {
32
- let contextData = contextDataFactory(ctx);
33
- if (contextData instanceof Promise) contextData = await contextData;
34
- return await federation$1.fetch(ctx.req.raw, {
35
- contextData,
36
- ...integrateFetchOptions(ctx, next)
37
- });
38
- };
39
- }
40
- function integrateFetchOptions(ctx, next) {
41
- return {
42
- async onNotFound(_req) {
43
- await next();
44
- return ctx.res;
45
- },
46
- async onNotAcceptable(_req) {
47
- await next();
48
- if (ctx.res.status !== 404) return ctx.res;
49
- return new Response("Not acceptable", {
50
- status: 406,
51
- headers: {
52
- "Content-Type": "text/plain",
53
- Vary: "Accept"
54
- }
55
- });
56
- }
57
- };
58
- }
59
-
60
- //#endregion
61
- exports.federation = federation;
package/dist/x/hono.d.cts DELETED
@@ -1,53 +0,0 @@
1
- import "../client-94iWEfQa.cjs";
2
- import "../vocab-CeDBzu-f.cjs";
3
- import "../actor-f2NtjyCg.cjs";
4
- import "../http-M8k5mKc0.cjs";
5
- import "../owner-B4HbyP8s.cjs";
6
- import "../mod-BxRCHTz-.cjs";
7
- import "../mod-C58MZ7Wx.cjs";
8
- import { Federation } from "../context-DJ8aSy2Q.cjs";
9
- import "../kv-Bxr0Q87_.cjs";
10
- import "../mq-DcJPkXD5.cjs";
11
-
12
- //#region src/x/hono.d.ts
13
- interface HonoRequest {
14
- raw: Request;
15
- }
16
- interface HonoContext {
17
- req: HonoRequest;
18
- res: Response;
19
- }
20
- type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>;
21
- /**
22
- * A factory function to create a context data for the {@link Federation}
23
- * object.
24
- *
25
- * @deprecated This type has been moved to `@fedify/hono` package.
26
- * Import `ContextDataFactory` from `@fedify/hono` instead.
27
- * This type will be removed in Fedify v2.0.
28
- *
29
- * @template TContextData A type of the context data for the {@link Federation}
30
- * object.
31
- * @template THonoContext A type of the Hono context.
32
- * @param context A Hono context object.
33
- * @returns A context data for the {@link Federation} object.
34
- */
35
- type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
36
- /**
37
- * Create a Hono middleware to integrate with the {@link Federation} object.
38
- *
39
- * @deprecated This function has been moved to `@fedify/hono` package.
40
- * Import `federation` from `@fedify/hono` instead.
41
- * This function will be removed in Fedify v2.0.
42
- *
43
- * @template TContextData A type of the context data for the {@link Federation}
44
- * object.
45
- * @template THonoContext A type of the Hono context.
46
- * @param federation A {@link Federation} object to integrate with Hono.
47
- * @param contextDataFactory A function to create a context data for the
48
- * {@link Federation} object.
49
- * @returns A Hono middleware.
50
- */
51
- declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
52
- //#endregion
53
- export { ContextDataFactory, federation };
package/dist/x/hono.d.ts DELETED
@@ -1,55 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import "../client-BsGzbnV-.js";
4
- import "../vocab-BCWe1Ih5.js";
5
- import "../actor-DqFajh9s.js";
6
- import "../http-BbO0ejuk.js";
7
- import "../owner-kQRGVXG1.js";
8
- import "../mod-BlVovdcy.js";
9
- import "../mod-Ds0mpFZU.js";
10
- import { Federation } from "../context-DG0huGW-.js";
11
- import "../kv-BKNZ-Tb-.js";
12
- import "../mq-CUKlBw08.js";
13
-
14
- //#region src/x/hono.d.ts
15
- interface HonoRequest {
16
- raw: Request;
17
- }
18
- interface HonoContext {
19
- req: HonoRequest;
20
- res: Response;
21
- }
22
- type HonoMiddleware<THonoContext extends HonoContext> = (ctx: THonoContext, next: () => Promise<void>) => Promise<Response | void>;
23
- /**
24
- * A factory function to create a context data for the {@link Federation}
25
- * object.
26
- *
27
- * @deprecated This type has been moved to `@fedify/hono` package.
28
- * Import `ContextDataFactory` from `@fedify/hono` instead.
29
- * This type will be removed in Fedify v2.0.
30
- *
31
- * @template TContextData A type of the context data for the {@link Federation}
32
- * object.
33
- * @template THonoContext A type of the Hono context.
34
- * @param context A Hono context object.
35
- * @returns A context data for the {@link Federation} object.
36
- */
37
- type ContextDataFactory<TContextData, THonoContext> = (context: THonoContext) => TContextData | Promise<TContextData>;
38
- /**
39
- * Create a Hono middleware to integrate with the {@link Federation} object.
40
- *
41
- * @deprecated This function has been moved to `@fedify/hono` package.
42
- * Import `federation` from `@fedify/hono` instead.
43
- * This function will be removed in Fedify v2.0.
44
- *
45
- * @template TContextData A type of the context data for the {@link Federation}
46
- * object.
47
- * @template THonoContext A type of the Hono context.
48
- * @param federation A {@link Federation} object to integrate with Hono.
49
- * @param contextDataFactory A function to create a context data for the
50
- * {@link Federation} object.
51
- * @returns A Hono middleware.
52
- */
53
- declare function federation<TContextData, THonoContext extends HonoContext>(federation: Federation<TContextData>, contextDataFactory: ContextDataFactory<TContextData, THonoContext>): HonoMiddleware<THonoContext>;
54
- //#endregion
55
- export { ContextDataFactory, federation };
package/dist/x/hono.js DELETED
@@ -1,60 +0,0 @@
1
-
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { getLogger } from "@logtape/logtape";
6
-
7
- //#region src/x/hono.ts
8
- /**
9
- * Create a Hono middleware to integrate with the {@link Federation} object.
10
- *
11
- * @deprecated This function has been moved to `@fedify/hono` package.
12
- * Import `federation` from `@fedify/hono` instead.
13
- * This function will be removed in Fedify v2.0.
14
- *
15
- * @template TContextData A type of the context data for the {@link Federation}
16
- * object.
17
- * @template THonoContext A type of the Hono context.
18
- * @param federation A {@link Federation} object to integrate with Hono.
19
- * @param contextDataFactory A function to create a context data for the
20
- * {@link Federation} object.
21
- * @returns A Hono middleware.
22
- */
23
- function federation(federation$1, contextDataFactory) {
24
- const logger = getLogger([
25
- "fedify",
26
- "federation",
27
- "hono"
28
- ]);
29
- logger.warn("The `@fedify/fedify/x/hono` module is deprecated; use `federation` from `@fedify/hono` package instead.");
30
- return async (ctx, next) => {
31
- let contextData = contextDataFactory(ctx);
32
- if (contextData instanceof Promise) contextData = await contextData;
33
- return await federation$1.fetch(ctx.req.raw, {
34
- contextData,
35
- ...integrateFetchOptions(ctx, next)
36
- });
37
- };
38
- }
39
- function integrateFetchOptions(ctx, next) {
40
- return {
41
- async onNotFound(_req) {
42
- await next();
43
- return ctx.res;
44
- },
45
- async onNotAcceptable(_req) {
46
- await next();
47
- if (ctx.res.status !== 404) return ctx.res;
48
- return new Response("Not acceptable", {
49
- status: 406,
50
- headers: {
51
- "Content-Type": "text/plain",
52
- Vary: "Accept"
53
- }
54
- });
55
- }
56
- };
57
- }
58
-
59
- //#endregion
60
- export { federation };
@@ -1,69 +0,0 @@
1
-
2
- const { Temporal } = require("@js-temporal/polyfill");
3
- const { URLPattern } = require("urlpattern-polyfill");
4
-
5
- const require_chunk = require('../chunk-DqRYRqnO.cjs');
6
- const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
7
-
8
- //#region src/x/sveltekit.ts
9
- /**
10
- * Create a SvelteKit hook handler to integrate with the {@link Federation}
11
- * object.
12
- *
13
- * @deprecated This function has been moved to `@fedify/sveltekit` package.
14
- * Import `fedifyHook` from `@fedify/sveltekit` instead.
15
- * This function will be removed in Fedify v2.0.
16
- *
17
- * @example hooks.server.ts
18
- * ``` typescript
19
- * import { federation } from "./federation"; // Import the `Federation` object
20
- *
21
- * export const handle = fedifyHook(federation, () => undefined);
22
- * ```
23
- *
24
- * @template TContextData A type of the context data for the {@link Federation}
25
- * object.
26
- * @param federation A {@link Federation} object to integrate with SvelteKit.
27
- * @param createContextData A function to create a context data for the
28
- * {@link Federation} object.
29
- * @returns A SvelteKit hook handler.
30
- * @since 1.3.0
31
- */
32
- function fedifyHook(federation, createContextData) {
33
- const logger = (0, __logtape_logtape.getLogger)([
34
- "fedify",
35
- "federation",
36
- "sveltekit"
37
- ]);
38
- logger.warn("The `@fedify/fedify/x/sveltekit` module is deprecated; use `fedifyHook` from `@fedify/sveltekit` package instead.");
39
- return async ({ event, resolve }) => {
40
- return await federation.fetch(event.request, {
41
- contextData: await createContextData(event),
42
- ...integrateFetchOptions({
43
- event,
44
- resolve
45
- })
46
- });
47
- };
48
- }
49
- function integrateFetchOptions({ event, resolve }) {
50
- return {
51
- async onNotFound() {
52
- return await resolve(event);
53
- },
54
- async onNotAcceptable() {
55
- const res = await resolve(event);
56
- if (res.status !== 404) return res;
57
- return new Response("Not acceptable", {
58
- status: 406,
59
- headers: {
60
- "Content-Type": "text/plain",
61
- Vary: "Accept"
62
- }
63
- });
64
- }
65
- };
66
- }
67
-
68
- //#endregion
69
- exports.fedifyHook = fedifyHook;
@@ -1,45 +0,0 @@
1
- import "../client-94iWEfQa.cjs";
2
- import "../vocab-CeDBzu-f.cjs";
3
- import "../actor-f2NtjyCg.cjs";
4
- import "../http-M8k5mKc0.cjs";
5
- import "../owner-B4HbyP8s.cjs";
6
- import "../mod-BxRCHTz-.cjs";
7
- import "../mod-C58MZ7Wx.cjs";
8
- import { Federation } from "../context-DJ8aSy2Q.cjs";
9
- import "../kv-Bxr0Q87_.cjs";
10
- import "../mq-DcJPkXD5.cjs";
11
-
12
- //#region src/x/sveltekit.d.ts
13
- type RequestEvent = {
14
- request: Request;
15
- };
16
- type HookParams = {
17
- event: RequestEvent;
18
- resolve: (event: RequestEvent) => Promise<Response>;
19
- };
20
- /**
21
- * Create a SvelteKit hook handler to integrate with the {@link Federation}
22
- * object.
23
- *
24
- * @deprecated This function has been moved to `@fedify/sveltekit` package.
25
- * Import `fedifyHook` from `@fedify/sveltekit` instead.
26
- * This function will be removed in Fedify v2.0.
27
- *
28
- * @example hooks.server.ts
29
- * ``` typescript
30
- * import { federation } from "./federation"; // Import the `Federation` object
31
- *
32
- * export const handle = fedifyHook(federation, () => undefined);
33
- * ```
34
- *
35
- * @template TContextData A type of the context data for the {@link Federation}
36
- * object.
37
- * @param federation A {@link Federation} object to integrate with SvelteKit.
38
- * @param createContextData A function to create a context data for the
39
- * {@link Federation} object.
40
- * @returns A SvelteKit hook handler.
41
- * @since 1.3.0
42
- */
43
- declare function fedifyHook<TContextData>(federation: Federation<TContextData>, createContextData: (event: RequestEvent) => TContextData | Promise<TContextData>): (params: HookParams) => Promise<Response>;
44
- //#endregion
45
- export { fedifyHook };
@@ -1,47 +0,0 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import "../client-BsGzbnV-.js";
4
- import "../vocab-BCWe1Ih5.js";
5
- import "../actor-DqFajh9s.js";
6
- import "../http-BbO0ejuk.js";
7
- import "../owner-kQRGVXG1.js";
8
- import "../mod-BlVovdcy.js";
9
- import "../mod-Ds0mpFZU.js";
10
- import { Federation } from "../context-DG0huGW-.js";
11
- import "../kv-BKNZ-Tb-.js";
12
- import "../mq-CUKlBw08.js";
13
-
14
- //#region src/x/sveltekit.d.ts
15
- type RequestEvent = {
16
- request: Request;
17
- };
18
- type HookParams = {
19
- event: RequestEvent;
20
- resolve: (event: RequestEvent) => Promise<Response>;
21
- };
22
- /**
23
- * Create a SvelteKit hook handler to integrate with the {@link Federation}
24
- * object.
25
- *
26
- * @deprecated This function has been moved to `@fedify/sveltekit` package.
27
- * Import `fedifyHook` from `@fedify/sveltekit` instead.
28
- * This function will be removed in Fedify v2.0.
29
- *
30
- * @example hooks.server.ts
31
- * ``` typescript
32
- * import { federation } from "./federation"; // Import the `Federation` object
33
- *
34
- * export const handle = fedifyHook(federation, () => undefined);
35
- * ```
36
- *
37
- * @template TContextData A type of the context data for the {@link Federation}
38
- * object.
39
- * @param federation A {@link Federation} object to integrate with SvelteKit.
40
- * @param createContextData A function to create a context data for the
41
- * {@link Federation} object.
42
- * @returns A SvelteKit hook handler.
43
- * @since 1.3.0
44
- */
45
- declare function fedifyHook<TContextData>(federation: Federation<TContextData>, createContextData: (event: RequestEvent) => TContextData | Promise<TContextData>): (params: HookParams) => Promise<Response>;
46
- //#endregion
47
- export { fedifyHook };