@fedify/sveltekit 1.9.0-pr.388.1456 → 1.9.0-pr.388.1458

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.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ <!-- deno-fmt-ignore-file -->
2
+
3
+ @fedify/sveltekit: Integrate Fedify with SvelteKit
4
+ ==================================================
5
+
6
+ [![JSR][JSR badge]][JSR]
7
+ [![npm][npm badge]][npm]
8
+ [![Follow @fedify@hollo.social][@fedify@hollo.social badge]][@fedify@hollo.social]
9
+
10
+ *This package is available since Fedify 1.9.0.*
11
+
12
+ This package provides a simple way to integrate [Fedify] with [SvelteKit].
13
+
14
+ The integration code looks like this:
15
+
16
+ ~~~~ typescript
17
+ import { createFederation } from "@fedify/fedify";
18
+ import { fedifyHook } from "@fedify/sveltekit";
19
+
20
+ const federation = createFederation<string>({
21
+ // Omitted for brevity; see the related section for details.
22
+ });
23
+
24
+ // This is the entry point to the Fedify hook from the SvelteKit framework:
25
+ export const handle = fedifyHook(federation, (req) => "context data");
26
+ ~~~~
27
+
28
+ Put the above code in your *hooks.server.ts* file.
29
+
30
+ How it works
31
+ ------------
32
+
33
+ Fedify behaves as a hook handler that wraps around the SvelteKit request handler.
34
+ The hook intercepts the incoming HTTP requests and dispatches them to
35
+ the appropriate handler based on the request path and the `Accept` header
36
+ (i.e., content negotiation). This architecture allows Fedify and your SvelteKit
37
+ application to coexist in the same domain and port.
38
+
39
+ For example, if you make a request to */.well-known/webfinger* Fedify will
40
+ handle the request by itself, but if you make a request to */users/alice*
41
+ (assuming your SvelteKit app has a handler for `/users/[handle]`) with `Accept:
42
+ text/html` header, Fedify will dispatch the request to the SvelteKit app's
43
+ appropriate handler for `/users/[handle]`. Or if you define an actor dispatcher
44
+ for `/users/{handle}` in Fedify, and the request is made with `Accept:
45
+ application/activity+json` header, Fedify will dispatch the request to the
46
+ appropriate actor dispatcher.
47
+
48
+ Installation
49
+ ------------
50
+
51
+ ~~~~ sh
52
+ deno add jsr:@fedify/sveltekit # Deno
53
+ npm add @fedify/sveltekit # npm
54
+ pnpm add @fedify/sveltekit # pnpm
55
+ yarn add @fedify/sveltekit # Yarn
56
+ bun add @fedify/sveltekit # Bun
57
+ ~~~~
58
+
59
+ [JSR]: https://jsr.io/@fedify/sveltekit
60
+ [JSR badge]: https://jsr.io/badges/@fedify/sveltekit
61
+ [npm]: https://www.npmjs.com/package/@fedify/sveltekit
62
+ [npm badge]: https://img.shields.io/npm/v/@fedify/sveltekit?logo=npm
63
+ [@fedify@hollo.social badge]: https://fedi-badge.deno.dev/@fedify@hollo.social/followers.svg
64
+ [@fedify@hollo.social]: https://hollo.social/@fedify
65
+ [Fedify]: https://fedify.dev/
66
+ [SvelteKit]: https://kit.svelte.dev/
package/dist/mod.d.ts CHANGED
@@ -26,7 +26,7 @@ type HookParams = {
26
26
  * @param createContextData A function to create a context data for the
27
27
  * {@link Federation} object.
28
28
  * @returns A SvelteKit hook handler.
29
- * @since 1.3.0
29
+ * @since 1.9.0
30
30
  */
31
31
  declare function fedifyHook<TContextData>(federation: Federation<TContextData>, createContextData: (event: RequestEvent) => TContextData | Promise<TContextData>): (params: HookParams) => Promise<Response>;
32
32
  //#endregion
package/dist/mod.js CHANGED
@@ -16,7 +16,7 @@
16
16
  * @param createContextData A function to create a context data for the
17
17
  * {@link Federation} object.
18
18
  * @returns A SvelteKit hook handler.
19
- * @since 1.3.0
19
+ * @since 1.9.0
20
20
  */
21
21
  function fedifyHook(federation, createContextData) {
22
22
  return async ({ event, resolve }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/sveltekit",
3
- "version": "1.9.0-pr.388.1456+c8cbdb88",
3
+ "version": "1.9.0-pr.388.1458+3f173465",
4
4
  "description": "Integrate Fedify with SvelteKit",
5
5
  "keywords": [
6
6
  "Fedify",
@@ -53,7 +53,7 @@
53
53
  ],
54
54
  "peerDependencies": {
55
55
  "@sveltejs/kit": "^2.0.0",
56
- "@fedify/fedify": "1.9.0-pr.388.1456+c8cbdb88"
56
+ "@fedify/fedify": "1.9.0-pr.388.1458+3f173465"
57
57
  },
58
58
  "devDependencies": {
59
59
  "tsdown": "^0.12.9",