@thomasfosterau/effect-sveltekit 0.4.1 → 0.5.0
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 +21 -15
- package/dist/Hooks.d.ts +1 -1
- package/dist/Hooks.js.map +1 -1
- package/dist/Navigation.d.ts +17 -6
- package/dist/Navigation.js +17 -5
- package/dist/Navigation.js.map +1 -1
- package/dist/Remote.d.ts +1 -1
- package/dist/Remote.js.map +1 -1
- package/dist/State.d.ts +4 -4
- package/dist/State.js.map +1 -1
- package/dist/adapter/handler.d.ts +14 -12
- package/dist/adapter/handler.js +5 -7
- package/dist/adapter/handler.js.map +1 -1
- package/dist/adapter/index.js +25 -21
- package/dist/adapter/index.js.map +1 -1
- package/dist/api-client.js +1 -1
- package/dist/api-client.js.map +1 -1
- package/dist/app-runtime.d.ts +7 -6
- package/dist/app-runtime.js +5 -5
- package/dist/app-runtime.js.map +1 -1
- package/dist/client/Hooks.d.ts +1 -1
- package/dist/client/Hooks.js.map +1 -1
- package/dist/errors.js +3 -2
- package/dist/errors.js.map +1 -1
- package/dist/forms.d.ts +6 -6
- package/dist/forms.js.map +1 -1
- package/dist/internal/app-state.d.ts +1 -1
- package/dist/internal/app-state.js.map +1 -1
- package/dist/internal/auto.d.ts +2 -1
- package/dist/internal/auto.js.map +1 -1
- package/dist/internal/enhance.d.ts +1 -1
- package/dist/internal/enhance.js.map +1 -1
- package/dist/internal/error.js +23 -2
- package/dist/internal/error.js.map +1 -1
- package/dist/internal/remote-run.d.ts +3 -3
- package/dist/internal/remote-run.js.map +1 -1
- package/dist/kit.js +3 -3
- package/dist/kit.js.map +1 -1
- package/dist/remote-functions.d.ts +4 -4
- package/dist/remote-functions.js.map +1 -1
- package/dist/remote-reactive.d.ts +1 -1
- package/dist/remote-reactive.js.map +1 -1
- package/dist/response-headers.d.ts +1 -1
- package/dist/response-headers.js.map +1 -1
- package/dist/server/Endpoint.d.ts +2 -2
- package/dist/server/Endpoint.js +2 -2
- package/dist/server/Endpoint.js.map +1 -1
- package/dist/server/Hooks.d.ts +1 -1
- package/dist/server/Hooks.js.map +1 -1
- package/dist/transport.d.ts +1 -1
- package/dist/transport.js.map +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js.map +1 -1
- package/package.json +6 -4
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ pnpm add @effect/platform-node@rc
|
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
`effect` (`>=4.0.0-rc.118`) and `svelte` (`^5.40.0`) are required peers;
|
|
19
|
-
`@sveltejs/kit` (`^
|
|
19
|
+
`@sveltejs/kit` (`^3.0.0`), `vite` (for `./vite`) and
|
|
20
20
|
`@effect/platform-node` (`>=4.0.0-rc.118`, for `./adapter`) are optional. The
|
|
21
21
|
HTTP modules that lived in `@effect/platform` in v3 are part of `effect` itself
|
|
22
22
|
in v4 (`effect/http`), so no other Effect package is needed. Keep a single copy
|
|
@@ -153,9 +153,9 @@ export const runtime = makeServerRuntime(Database.layer);
|
|
|
153
153
|
|
|
154
154
|
```ts
|
|
155
155
|
// src/routes/items/+page.server.ts
|
|
156
|
-
import { runtime } from "
|
|
156
|
+
import { runtime } from "#lib/server/runtime.ts";
|
|
157
157
|
import { Effect } from "effect";
|
|
158
|
-
import { Database } from "
|
|
158
|
+
import { Database } from "#lib/server/database.ts";
|
|
159
159
|
|
|
160
160
|
export const load = runtime.serverLoad((event) =>
|
|
161
161
|
Effect.gen(function* () {
|
|
@@ -175,7 +175,7 @@ Vite plugin, point the plugin at the runtime module:
|
|
|
175
175
|
|
|
176
176
|
```ts
|
|
177
177
|
// vite.config.ts
|
|
178
|
-
effectKit({ serverRuntime: "
|
|
178
|
+
effectKit({ serverRuntime: "#lib/server/runtime.ts" });
|
|
179
179
|
```
|
|
180
180
|
|
|
181
181
|
#### One runtime per request
|
|
@@ -187,7 +187,7 @@ built once and sharing a single request scope — and stores it on `event.locals
|
|
|
187
187
|
|
|
188
188
|
```ts
|
|
189
189
|
// src/hooks.server.ts
|
|
190
|
-
import { runtime } from "
|
|
190
|
+
import { runtime } from "#lib/server/runtime.ts";
|
|
191
191
|
import { Effect } from "effect";
|
|
192
192
|
|
|
193
193
|
export const handle = runtime.handle(({ event, resolve }) =>
|
|
@@ -223,13 +223,15 @@ A SvelteKit [adapter](https://svelte.dev/docs/kit/adapters) (like
|
|
|
223
223
|
configuration, request tracing spans, and graceful shutdown through Effect
|
|
224
224
|
scopes:
|
|
225
225
|
|
|
226
|
-
```
|
|
227
|
-
//
|
|
226
|
+
```ts
|
|
227
|
+
// vite.config.ts
|
|
228
|
+
import { sveltekit } from "@sveltejs/kit/vite";
|
|
228
229
|
import adapter from "@thomasfosterau/effect-sveltekit/adapter";
|
|
230
|
+
import { defineConfig } from "vite";
|
|
229
231
|
|
|
230
|
-
export default {
|
|
231
|
-
|
|
232
|
-
};
|
|
232
|
+
export default defineConfig({
|
|
233
|
+
plugins: [sveltekit({ adapter: adapter() })],
|
|
234
|
+
});
|
|
233
235
|
```
|
|
234
236
|
|
|
235
237
|
```bash
|
|
@@ -260,6 +262,10 @@ together with `package.json` and production `node_modules` (which must
|
|
|
260
262
|
include `@thomasfosterau/effect-sveltekit`, `effect`, and
|
|
261
263
|
`@effect/platform-node`).
|
|
262
264
|
|
|
265
|
+
The adapter's optional `@effect/platform-node` peer pulls in `undici`, which
|
|
266
|
+
needs Node `>=22.19`, so the production server needs Node `>=22.19` even
|
|
267
|
+
though the package itself (like SvelteKit 3) declares `>=22.17`.
|
|
268
|
+
|
|
263
269
|
### SvelteKit universal load
|
|
264
270
|
|
|
265
271
|
```ts
|
|
@@ -297,7 +303,7 @@ import {
|
|
|
297
303
|
RequestRuntime,
|
|
298
304
|
} from "@thomasfosterau/effect-sveltekit/server";
|
|
299
305
|
import { error } from "@sveltejs/kit";
|
|
300
|
-
import type { AppError } from "
|
|
306
|
+
import type { AppError } from "#lib/errors.ts"; // NotFound | Unauthorized | Forbidden | Redirect | HttpError | JsonapiError
|
|
301
307
|
|
|
302
308
|
export const { serverLoad, endpoint } = makeRuntimeAdapter(
|
|
303
309
|
RequestRuntime.fromLocals((event) => event.locals.runtime),
|
|
@@ -334,8 +340,8 @@ paths line up:
|
|
|
334
340
|
```ts
|
|
335
341
|
// src/routes/api/[...path]/+server.ts
|
|
336
342
|
import { Endpoint } from "@thomasfosterau/effect-sveltekit/server";
|
|
337
|
-
import { api } from "
|
|
338
|
-
import { ApiLive } from "
|
|
343
|
+
import { api } from "#lib/server/api.ts";
|
|
344
|
+
import { ApiLive } from "#lib/server/handlers.ts"; // HttpApiBuilder.group(...) + your services
|
|
339
345
|
|
|
340
346
|
export const fallback = Endpoint.fromApi(api, ApiLive, { prefix: "/api" });
|
|
341
347
|
```
|
|
@@ -367,7 +373,7 @@ import {
|
|
|
367
373
|
Hooks,
|
|
368
374
|
} from "@thomasfosterau/effect-sveltekit/client";
|
|
369
375
|
|
|
370
|
-
// e.g. Navigation.goto('/done'), Navigation.
|
|
376
|
+
// e.g. Navigation.goto('/done'), Navigation.refreshAll(),
|
|
371
377
|
// Remote.callQuery(getTodos), State.page()
|
|
372
378
|
```
|
|
373
379
|
|
|
@@ -423,7 +429,7 @@ export const transport = Hooks.transport({ ResponseHeaders: Hooks.responseHeader
|
|
|
423
429
|
|
|
424
430
|
// src/hooks.server.ts
|
|
425
431
|
import { ResponseHeaders } from "@thomasfosterau/effect-sveltekit";
|
|
426
|
-
import type { Handle } from "@sveltejs/kit";
|
|
432
|
+
import type { Handle } from "@sveltejs/kit/hooks";
|
|
427
433
|
|
|
428
434
|
export const handle: Handle = async ({ event, resolve }) => {
|
|
429
435
|
event.locals.headers = new ResponseHeaders();
|
package/dist/Hooks.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MarkerTransporterOptions, TransportEntry, markerTransporter, transport,
|
|
|
2
2
|
import { responseHeadersTransporter } from "./response-headers.js";
|
|
3
3
|
import { Effect } from "effect";
|
|
4
4
|
import * as HttpClient from "effect/http/HttpClient";
|
|
5
|
-
import { Reroute } from "@sveltejs/kit";
|
|
5
|
+
import { Reroute } from "@sveltejs/kit/hooks";
|
|
6
6
|
declare namespace Hooks_d_exports {
|
|
7
7
|
export { MarkerTransporterOptions, TransportEntry, markerTransporter, reroute, responseHeadersTransporter, transport, transporter };
|
|
8
8
|
}
|
package/dist/Hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hooks.js","names":[],"sources":["../src/Hooks.ts"],"sourcesContent":["/**\n * Effect helpers for SvelteKit's universal hooks (`src/hooks.ts`), exposed as\n * the `Hooks` namespace of `@thomasfosterau/effect-sveltekit`.\n *\n * The `reroute` hook is expressed as an Effect (running on the universal\n * runtime, with an `HttpClient` backed by the event's `fetch`), and the\n * universal `transport` hook is built from Effect schemas via {@link transport}\n * / {@link transporter}.\n *\n * @example\n * ```ts\n * // src/hooks.ts\n * import { Hooks } from '@thomasfosterau/effect-sveltekit';\n * import { Effect, Schema } from 'effect';\n *\n * export const reroute = Hooks.reroute((event) =>\n * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),\n * );\n *\n * export const transport = Hooks.transport({\n * Option: Schema.Option(Schema.Number),\n * Date: Schema.Date,\n * });\n * ```\n */\n\nimport type { Reroute } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\nimport type * as HttpClient from \"effect/http/HttpClient\";\nimport { defaultUniversalRuntime } from \"./internal/default-runtime.js\";\n\n/**\n * Wraps an Effect-based function as the SvelteKit universal\n * [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook,\n * which rewrites the URL before routing. The effect runs on both the server and\n * the client and gets an `HttpClient` backed by the event's `fetch`.\n *\n * @example\n * ```ts\n * // src/hooks.ts\n * import { Hooks } from '@thomasfosterau/effect-sveltekit';\n * import { Effect } from 'effect';\n *\n * export const reroute = Hooks.reroute((event) =>\n * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),\n * );\n * ```\n */\nexport function reroute(\n fn: (event: {\n url: URL;\n fetch: typeof globalThis.fetch;\n }) => Effect.Effect<string | void, unknown, HttpClient.HttpClient>,\n): Reroute {\n return (event) => defaultUniversalRuntime().runPromise(event.fetch, fn(event));\n}\n\n/**\n * The universal `transport` hook built from Effect schemas: `transport`\n * assembles a whole `transport` object from a record of entries, `transporter`\n * builds a single round-tripping entry from a `Schema.Codec`, and\n * `markerTransporter` builds a deliberately-lossy entry for a non-POJO wrapper\n * whose contents should not round-trip. See {@link transport} for details.\n */\nexport {\n transport,\n transporter,\n markerTransporter,\n type MarkerTransporterOptions,\n type TransportEntry,\n} from \"./transport.js\";\n\n/**\n * The `transport` entry for the {@link ResponseHeaders} response-headers buffer\n * (`Hooks.transport({ ResponseHeaders: Hooks.responseHeadersTransporter })`).\n */\nexport { responseHeadersTransporter } from \"./response-headers.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,QACd,IAIS;CACT,QAAQ,UAAU,wBAAwB,CAAC,CAAC,WAAW,MAAM,OAAO,GAAG,KAAK,CAAC;AAC/E"}
|
|
1
|
+
{"version":3,"file":"Hooks.js","names":[],"sources":["../src/Hooks.ts"],"sourcesContent":["/**\n * Effect helpers for SvelteKit's universal hooks (`src/hooks.ts`), exposed as\n * the `Hooks` namespace of `@thomasfosterau/effect-sveltekit`.\n *\n * The `reroute` hook is expressed as an Effect (running on the universal\n * runtime, with an `HttpClient` backed by the event's `fetch`), and the\n * universal `transport` hook is built from Effect schemas via {@link transport}\n * / {@link transporter}.\n *\n * @example\n * ```ts\n * // src/hooks.ts\n * import { Hooks } from '@thomasfosterau/effect-sveltekit';\n * import { Effect, Schema } from 'effect';\n *\n * export const reroute = Hooks.reroute((event) =>\n * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),\n * );\n *\n * export const transport = Hooks.transport({\n * Option: Schema.Option(Schema.Number),\n * Date: Schema.Date,\n * });\n * ```\n */\n\nimport type { Reroute } from \"@sveltejs/kit/hooks\";\nimport { Effect } from \"effect\";\nimport type * as HttpClient from \"effect/http/HttpClient\";\nimport { defaultUniversalRuntime } from \"./internal/default-runtime.js\";\n\n/**\n * Wraps an Effect-based function as the SvelteKit universal\n * [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook,\n * which rewrites the URL before routing. The effect runs on both the server and\n * the client and gets an `HttpClient` backed by the event's `fetch`.\n *\n * @example\n * ```ts\n * // src/hooks.ts\n * import { Hooks } from '@thomasfosterau/effect-sveltekit';\n * import { Effect } from 'effect';\n *\n * export const reroute = Hooks.reroute((event) =>\n * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),\n * );\n * ```\n */\nexport function reroute(\n fn: (event: {\n url: URL;\n fetch: typeof globalThis.fetch;\n }) => Effect.Effect<string | void, unknown, HttpClient.HttpClient>,\n): Reroute {\n return (event) => defaultUniversalRuntime().runPromise(event.fetch, fn(event));\n}\n\n/**\n * The universal `transport` hook built from Effect schemas: `transport`\n * assembles a whole `transport` object from a record of entries, `transporter`\n * builds a single round-tripping entry from a `Schema.Codec`, and\n * `markerTransporter` builds a deliberately-lossy entry for a non-POJO wrapper\n * whose contents should not round-trip. See {@link transport} for details.\n */\nexport {\n transport,\n transporter,\n markerTransporter,\n type MarkerTransporterOptions,\n type TransportEntry,\n} from \"./transport.js\";\n\n/**\n * The `transport` entry for the {@link ResponseHeaders} response-headers buffer\n * (`Hooks.transport({ ResponseHeaders: Hooks.responseHeadersTransporter })`).\n */\nexport { responseHeadersTransporter } from \"./response-headers.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,QACd,IAIS;CACT,QAAQ,UAAU,wBAAwB,CAAC,CAAC,WAAW,MAAM,OAAO,GAAG,KAAK,CAAC;AAC/E"}
|
package/dist/Navigation.d.ts
CHANGED
|
@@ -1,21 +1,32 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
|
-
import { AfterNavigate, BeforeNavigate, OnNavigate } from "
|
|
3
|
-
import { goto, invalidate, preloadData, refreshAll } from "$app/navigation";
|
|
2
|
+
import { AfterNavigate, BeforeNavigate, OnNavigate, goto, invalidate, preloadCode, preloadData, refreshAll } from "$app/navigation";
|
|
4
3
|
declare namespace Navigation_d_exports {
|
|
5
4
|
export { afterNavigate$1 as afterNavigate, beforeNavigate$1 as beforeNavigate, goto$1 as goto, invalidate$1 as invalidate, invalidateAll$1 as invalidateAll, onNavigate$1 as onNavigate, preloadCode$1 as preloadCode, preloadData$1 as preloadData, refreshAll$1 as refreshAll };
|
|
6
5
|
}
|
|
7
|
-
/**
|
|
6
|
+
/**
|
|
7
|
+
* Navigate to `url`. Wraps `$app/navigation`'s `goto`. SvelteKit rejects a URL
|
|
8
|
+
* outside the app (external, or not matching a route); a rejection surfaces as
|
|
9
|
+
* a defect.
|
|
10
|
+
*/
|
|
8
11
|
declare const goto$1: (...args: Parameters<typeof goto>) => Effect.Effect<void>;
|
|
9
12
|
/** Re-run `load` functions that depend on `resource`. Wraps `invalidate`. */
|
|
10
13
|
declare const invalidate$1: (...args: Parameters<typeof invalidate>) => Effect.Effect<void>;
|
|
11
|
-
/**
|
|
14
|
+
/**
|
|
15
|
+
* Re-run every `load` function for the active page. Wraps `invalidateAll`.
|
|
16
|
+
*
|
|
17
|
+
* @deprecated SvelteKit 3 deprecates `invalidateAll`; use {@link refreshAll},
|
|
18
|
+
* which also refreshes active remote functions and keeps `page.state`.
|
|
19
|
+
*/
|
|
12
20
|
declare const invalidateAll$1: () => Effect.Effect<void>;
|
|
13
21
|
/** Refresh active remote functions (and, by default, `load`s). Wraps `refreshAll`. */
|
|
14
22
|
declare const refreshAll$1: (...args: Parameters<typeof refreshAll>) => Effect.Effect<void>;
|
|
15
23
|
/** Preload the data for `href`. Wraps `preloadData`. */
|
|
16
24
|
declare const preloadData$1: (href: string) => Effect.Effect<Awaited<ReturnType<typeof preloadData>>>;
|
|
17
|
-
/**
|
|
18
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Preload the code for the route `id` (e.g. `/blog/[slug]`, without
|
|
27
|
+
* `paths.base`). Wraps `preloadCode`.
|
|
28
|
+
*/
|
|
29
|
+
declare const preloadCode$1: (...args: Parameters<typeof preloadCode>) => Effect.Effect<void>;
|
|
19
30
|
/**
|
|
20
31
|
* Registers a `beforeNavigate` callback and exposes every navigation about to
|
|
21
32
|
* happen as an Effect `Stream`. Call during component initialization.
|
package/dist/Navigation.js
CHANGED
|
@@ -26,7 +26,7 @@ import { afterNavigate, beforeNavigate, goto, invalidate, invalidateAll, onNavig
|
|
|
26
26
|
* runtime.runPromise(
|
|
27
27
|
* Effect.gen(function* () {
|
|
28
28
|
* yield* doSave();
|
|
29
|
-
* yield* Navigation.
|
|
29
|
+
* yield* Navigation.refreshAll();
|
|
30
30
|
* yield* Navigation.goto('/done');
|
|
31
31
|
* }),
|
|
32
32
|
* );
|
|
@@ -44,18 +44,30 @@ var Navigation_exports = /* @__PURE__ */ __exportAll({
|
|
|
44
44
|
preloadData: () => preloadData$1,
|
|
45
45
|
refreshAll: () => refreshAll$1
|
|
46
46
|
});
|
|
47
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Navigate to `url`. Wraps `$app/navigation`'s `goto`. SvelteKit rejects a URL
|
|
49
|
+
* outside the app (external, or not matching a route); a rejection surfaces as
|
|
50
|
+
* a defect.
|
|
51
|
+
*/
|
|
48
52
|
const goto$1 = (...args) => Effect.promise(() => goto(...args));
|
|
49
53
|
/** Re-run `load` functions that depend on `resource`. Wraps `invalidate`. */
|
|
50
54
|
const invalidate$1 = (...args) => Effect.promise(() => invalidate(...args));
|
|
51
|
-
/**
|
|
55
|
+
/**
|
|
56
|
+
* Re-run every `load` function for the active page. Wraps `invalidateAll`.
|
|
57
|
+
*
|
|
58
|
+
* @deprecated SvelteKit 3 deprecates `invalidateAll`; use {@link refreshAll},
|
|
59
|
+
* which also refreshes active remote functions and keeps `page.state`.
|
|
60
|
+
*/
|
|
52
61
|
const invalidateAll$1 = () => Effect.promise(() => invalidateAll());
|
|
53
62
|
/** Refresh active remote functions (and, by default, `load`s). Wraps `refreshAll`. */
|
|
54
63
|
const refreshAll$1 = (...args) => Effect.promise(() => refreshAll(...args));
|
|
55
64
|
/** Preload the data for `href`. Wraps `preloadData`. */
|
|
56
65
|
const preloadData$1 = (href) => Effect.promise(() => preloadData(href));
|
|
57
|
-
/**
|
|
58
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Preload the code for the route `id` (e.g. `/blog/[slug]`, without
|
|
68
|
+
* `paths.base`). Wraps `preloadCode`.
|
|
69
|
+
*/
|
|
70
|
+
const preloadCode$1 = (...args) => Effect.promise(() => preloadCode(...args));
|
|
59
71
|
/**
|
|
60
72
|
* Registers a `beforeNavigate` callback and exposes every navigation about to
|
|
61
73
|
* happen as an Effect `Stream`. Call during component initialization.
|
package/dist/Navigation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Navigation.js","names":["goto","kitGoto","invalidate","kitInvalidate","invalidateAll","kitInvalidateAll","refreshAll","kitRefreshAll","preloadData","kitPreloadData","preloadCode","kitPreloadCode","beforeNavigate","kitBeforeNavigate","afterNavigate","kitAfterNavigate","onNavigate","kitOnNavigate"],"sources":["../src/Navigation.ts"],"sourcesContent":["/**\n * Effect wrappers for SvelteKit's client-side\n * [`$app/navigation`](https://svelte.dev/docs/kit/$app-navigation) API.\n *\n * Each of SvelteKit's promise-returning navigation functions is wrapped as an\n * `Effect`, so navigation composes inside Effect pipelines (sequencing,\n * retries, `Effect.race`, tracing spans, ...). Alongside them sit the\n * client-side lifecycle callbacks (`beforeNavigate`, `afterNavigate`,\n * `onNavigate`) bridged to Effect. These run on the client only — calling them\n * during SSR throws, exactly as the underlying `$app/navigation` functions do.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';\n * import { Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * const runtime = getRuntime();\n * const save = () =>\n * runtime.runPromise(\n * Effect.gen(function* () {\n * yield* doSave();\n * yield* Navigation.
|
|
1
|
+
{"version":3,"file":"Navigation.js","names":["goto","kitGoto","invalidate","kitInvalidate","invalidateAll","kitInvalidateAll","refreshAll","kitRefreshAll","preloadData","kitPreloadData","preloadCode","kitPreloadCode","beforeNavigate","kitBeforeNavigate","afterNavigate","kitAfterNavigate","onNavigate","kitOnNavigate"],"sources":["../src/Navigation.ts"],"sourcesContent":["/**\n * Effect wrappers for SvelteKit's client-side\n * [`$app/navigation`](https://svelte.dev/docs/kit/$app-navigation) API.\n *\n * Each of SvelteKit's promise-returning navigation functions is wrapped as an\n * `Effect`, so navigation composes inside Effect pipelines (sequencing,\n * retries, `Effect.race`, tracing spans, ...). Alongside them sit the\n * client-side lifecycle callbacks (`beforeNavigate`, `afterNavigate`,\n * `onNavigate`) bridged to Effect. These run on the client only — calling them\n * during SSR throws, exactly as the underlying `$app/navigation` functions do.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';\n * import { Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * const runtime = getRuntime();\n * const save = () =>\n * runtime.runPromise(\n * Effect.gen(function* () {\n * yield* doSave();\n * yield* Navigation.refreshAll();\n * yield* Navigation.goto('/done');\n * }),\n * );\n * </script>\n * ```\n */\n\nimport {\n afterNavigate as kitAfterNavigate,\n beforeNavigate as kitBeforeNavigate,\n goto as kitGoto,\n invalidate as kitInvalidate,\n invalidateAll as kitInvalidateAll,\n onNavigate as kitOnNavigate,\n preloadCode as kitPreloadCode,\n preloadData as kitPreloadData,\n refreshAll as kitRefreshAll,\n} from \"$app/navigation\";\nimport type { AfterNavigate, BeforeNavigate, OnNavigate } from \"$app/navigation\";\nimport { Effect } from \"effect\";\nimport type { Stream } from \"effect\";\nimport { onNavigateWith, registeredStream } from \"./internal/navigation-events.js\";\n\n/**\n * Navigate to `url`. Wraps `$app/navigation`'s `goto`. SvelteKit rejects a URL\n * outside the app (external, or not matching a route); a rejection surfaces as\n * a defect.\n */\nexport const goto = (...args: Parameters<typeof kitGoto>): Effect.Effect<void> =>\n Effect.promise(() => kitGoto(...args));\n\n/** Re-run `load` functions that depend on `resource`. Wraps `invalidate`. */\nexport const invalidate = (...args: Parameters<typeof kitInvalidate>): Effect.Effect<void> =>\n Effect.promise(() => kitInvalidate(...args));\n\n/**\n * Re-run every `load` function for the active page. Wraps `invalidateAll`.\n *\n * @deprecated SvelteKit 3 deprecates `invalidateAll`; use {@link refreshAll},\n * which also refreshes active remote functions and keeps `page.state`.\n */\nexport const invalidateAll = (): Effect.Effect<void> => Effect.promise(() => kitInvalidateAll());\n\n/** Refresh active remote functions (and, by default, `load`s). Wraps `refreshAll`. */\nexport const refreshAll = (...args: Parameters<typeof kitRefreshAll>): Effect.Effect<void> =>\n Effect.promise(() => kitRefreshAll(...args));\n\n/** Preload the data for `href`. Wraps `preloadData`. */\nexport const preloadData = (\n href: string,\n): Effect.Effect<Awaited<ReturnType<typeof kitPreloadData>>> =>\n Effect.promise(() => kitPreloadData(href));\n\n/**\n * Preload the code for the route `id` (e.g. `/blog/[slug]`, without\n * `paths.base`). Wraps `preloadCode`.\n */\nexport const preloadCode = (...args: Parameters<typeof kitPreloadCode>): Effect.Effect<void> =>\n Effect.promise(() => kitPreloadCode(...args));\n\n/**\n * Registers a `beforeNavigate` callback and exposes every navigation about to\n * happen as an Effect `Stream`. Call during component initialization.\n *\n * Unlike the promise-returning navigation functions above, this is a\n * **callback-registration** function: it must be called *synchronously during\n * component initialization* (SvelteKit wires it to the component's lifecycle).\n * It registers its callback eagerly and feeds an internal `Queue`, returning a\n * `Stream` backed by that queue — the same push-based bridge as `SignalEmitter`\n * in `@thomasfosterau/effect-svelte`. Call it at the top level of `<script>`,\n * exactly where you'd call the bare `beforeNavigate`.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';\n * import { Stream, Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * // Register at init so the callback is wired to the component lifecycle.\n * const navigations = Navigation.beforeNavigate();\n *\n * getRuntime().runFork(\n * Stream.runForEach(navigations, (nav) =>\n * Effect.logInfo(`leaving: ${nav.from?.url.pathname}`),\n * ),\n * );\n * </script>\n * ```\n */\nexport function beforeNavigate(): Stream.Stream<BeforeNavigate> {\n return registeredStream<BeforeNavigate>(kitBeforeNavigate);\n}\n\n/**\n * Registers an `afterNavigate` callback and exposes every completed navigation\n * (including the initial one) as an Effect `Stream`. Call during component\n * initialization.\n *\n * Like {@link beforeNavigate}, this is a **callback-registration** function:\n * call it at the top level of `<script>`, exactly where you'd call the bare\n * `afterNavigate`.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';\n * import { Stream, Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * // Register at init so the callback is wired to the component lifecycle.\n * const navigations = Navigation.afterNavigate();\n *\n * getRuntime().runFork(\n * Stream.runForEach(navigations, (nav) =>\n * Effect.logInfo(`navigated: ${nav.to?.url.pathname}`),\n * ),\n * );\n * </script>\n * ```\n */\nexport function afterNavigate(): Stream.Stream<AfterNavigate> {\n return registeredStream<AfterNavigate>(kitAfterNavigate);\n}\n\n/**\n * Runs an `Effect` for each navigation, registered via `$app/navigation`'s\n * `onNavigate`. Call during component initialization.\n *\n * SvelteKit's `onNavigate` callback may return a cleanup function (or a promise\n * of one) that runs once the navigation completes and the DOM has updated; to\n * support that, `fn`'s Effect may succeed with a `() => void` cleanup, which is\n * forwarded to SvelteKit. The Effect is run with `runEffect` (default\n * {@link Effect.runPromise}); pass a managed runtime's `runPromise` to supply\n * services to `fn`.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';\n * import { Effect } from 'effect';\n *\n * Navigation.onNavigate((nav) =>\n * Effect.gen(function* () {\n * yield* Effect.logInfo(`navigating to ${nav.to?.url.pathname}`);\n * // Optionally return a cleanup that runs after the navigation:\n * return () => console.log(\"navigation done\");\n * }),\n * );\n * </script>\n * ```\n */\nexport function onNavigate(\n fn: (navigation: OnNavigate) => Effect.Effect<(() => void) | void>,\n runEffect: <X>(effect: Effect.Effect<X>) => Promise<X> = Effect.runPromise,\n): void {\n onNavigateWith<OnNavigate>(kitOnNavigate, fn, runEffect);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoDA,MAAaA,UAAQ,GAAG,SACtB,OAAO,cAAcC,KAAQ,GAAG,IAAI,CAAC;;AAGvC,MAAaC,gBAAc,GAAG,SAC5B,OAAO,cAAcC,WAAc,GAAG,IAAI,CAAC;;;;;;;AAQ7C,MAAaC,wBAA2C,OAAO,cAAcC,cAAiB,CAAC;;AAG/F,MAAaC,gBAAc,GAAG,SAC5B,OAAO,cAAcC,WAAc,GAAG,IAAI,CAAC;;AAG7C,MAAaC,iBACX,SAEA,OAAO,cAAcC,YAAe,IAAI,CAAC;;;;;AAM3C,MAAaC,iBAAe,GAAG,SAC7B,OAAO,cAAcC,YAAe,GAAG,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgC9C,SAAgBC,mBAAgD;CAC9D,OAAO,iBAAiCC,cAAiB;AAC3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgBC,kBAA8C;CAC5D,OAAO,iBAAgCC,aAAgB;AACzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgBC,aACd,IACA,YAAyD,OAAO,YAC1D;CACN,eAA2BC,YAAe,IAAI,SAAS;AACzD"}
|
package/dist/Remote.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Effect, Stream } from "effect";
|
|
2
|
-
import { RemoteCommand, RemoteLiveQuery, RemotePrerenderFunction, RemoteQuery, RemoteQueryFunction, RemoteQueryOverride } from "
|
|
2
|
+
import { RemoteCommand, RemoteLiveQuery, RemotePrerenderFunction, RemoteQuery, RemoteQueryFunction, RemoteQueryOverride } from "$app/server";
|
|
3
3
|
declare namespace Remote_d_exports {
|
|
4
4
|
export { RemoteSubmit, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates };
|
|
5
5
|
}
|
package/dist/Remote.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Remote.js","names":[],"sources":["../src/Remote.ts"],"sourcesContent":["import type {\n RemoteCommand,\n RemoteLiveQuery,\n RemotePrerenderFunction,\n RemoteQuery,\n RemoteQueryFunction,\n RemoteQueryOverride,\n} from \"
|
|
1
|
+
{"version":3,"file":"Remote.js","names":[],"sources":["../src/Remote.ts"],"sourcesContent":["import type {\n RemoteCommand,\n RemoteLiveQuery,\n RemotePrerenderFunction,\n RemoteQuery,\n RemoteQueryFunction,\n RemoteQueryOverride,\n} from \"$app/server\";\nimport { Effect, Stream } from \"effect\";\n\nfunction fromRemotePromise<A>(thunk: () => PromiseLike<A>): Effect.Effect<A, unknown, never> {\n return Effect.promise(() => Promise.resolve(thunk()));\n}\n\n/**\n * Calls a SvelteKit remote `query` as an Effect that succeeds with its output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callQuery<Output>(\n query: RemoteQueryFunction<void, Output>,\n): Effect.Effect<Output, unknown, never>;\n/**\n * Calls a SvelteKit remote `query` with `input` as an Effect that succeeds\n * with its output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callQuery<Input, Output>(\n query: RemoteQueryFunction<Input, Output>,\n input: Input,\n): Effect.Effect<Output, unknown, never>;\nexport function callQuery<Input, Output>(\n query: RemoteQueryFunction<Input, Output>,\n input?: Input,\n): Effect.Effect<Output, unknown, never> {\n if (arguments.length === 1) {\n return fromRemotePromise(() =>\n (query as unknown as RemoteQueryFunction<void, Output>)(undefined),\n );\n }\n\n return fromRemotePromise(() => query(input as Input));\n}\n\n/**\n * Calls a SvelteKit remote `command` as an Effect that succeeds with its\n * output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callCommand<Output>(\n command: RemoteCommand<void, Output>,\n): Effect.Effect<Output, unknown, never>;\n/**\n * Calls a SvelteKit remote `command` with `input` as an Effect that succeeds\n * with its output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callCommand<Input, Output>(\n command: RemoteCommand<Input, Output>,\n input: Input,\n): Effect.Effect<Output, unknown, never>;\nexport function callCommand<Input, Output>(\n command: RemoteCommand<Input, Output>,\n input?: Input,\n): Effect.Effect<Output, unknown, never> {\n if (arguments.length === 1) {\n return fromRemotePromise(() => (command as unknown as RemoteCommand<void, Output>)(undefined));\n }\n\n return fromRemotePromise(() => command(input as Input));\n}\n\n/**\n * Calls a remote command and refreshes the given queries in the same round\n * trip (SvelteKit's single-flight mutations).\n *\n * Newer SvelteKit versions cache remote query instances, so a command that\n * changes data those queries depend on must list them here (or call\n * `query.refresh()` afterwards) for their cached values to update.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callCommandWithUpdates<Input, Output>(\n command: RemoteCommand<Input, Output>,\n input: Input,\n ...queries: Array<RemoteQuery<any> | RemoteQueryOverride>\n): Effect.Effect<Output, unknown, never> {\n return fromRemotePromise(() => command(input).updates(...queries));\n}\n\n/**\n * Calls a SvelteKit remote `prerender` function as an Effect that succeeds\n * with its output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callPrerender<Output>(\n prerender: RemotePrerenderFunction<void, Output>,\n): Effect.Effect<Output, unknown, never>;\n/**\n * Calls a SvelteKit remote `prerender` function with `input` as an Effect\n * that succeeds with its output.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function callPrerender<Input, Output>(\n prerender: RemotePrerenderFunction<Input, Output>,\n input: Input,\n): Effect.Effect<Output, unknown, never>;\nexport function callPrerender<Input, Output>(\n prerender: RemotePrerenderFunction<Input, Output>,\n input?: Input,\n): Effect.Effect<Output, unknown, never> {\n if (arguments.length === 1) {\n return fromRemotePromise(() =>\n (prerender as unknown as RemotePrerenderFunction<void, Output>)(undefined),\n );\n }\n\n return fromRemotePromise(() => prerender(input as Input));\n}\n\n/**\n * The shape of an enhanced remote form `submit` function. The promise result\n * is left open (SvelteKit returns `Promise<void>` in older versions and\n * `Promise<boolean>` in newer ones).\n */\nexport type RemoteSubmit = () => PromiseLike<unknown> & {\n updates: (...queries: Array<RemoteQuery<any> | RemoteQueryOverride>) => PromiseLike<unknown>;\n};\n\n/**\n * Runs an enhanced remote form's `submit()` as an Effect.\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function submitForm(\n submit: () => PromiseLike<unknown>,\n): Effect.Effect<void, unknown, never> {\n return Effect.asVoid(fromRemotePromise(() => submit()));\n}\n\n/**\n * Runs an enhanced remote form's `submit()` and refreshes the given queries in\n * the same round trip (SvelteKit's single-flight mutations).\n *\n * A rejected call (including a thrown `error()` / `redirect()`) surfaces as a\n * defect, not on the error channel, despite the declared `unknown` error type.\n */\nexport function submitFormWithUpdates(\n submit: RemoteSubmit,\n ...queries: Array<RemoteQuery<any> | RemoteQueryOverride>\n): Effect.Effect<void, unknown, never> {\n return Effect.asVoid(fromRemotePromise(() => submit().updates(...queries)));\n}\n\n/**\n * Consumes a SvelteKit live query (`query.live(...)`) as an Effect `Stream`.\n *\n * A `RemoteLiveQuery<T>` is an `AsyncIterable<T>` that yields every update\n * pushed from the server; this turns it into a `Stream` so live data can drive\n * Effect pipelines (and, via `useStream`, Svelte runes).\n *\n * @example\n * ```ts\n * import { Remote } from '@thomasfosterau/effect-sveltekit';\n * import { messages } from './chat.remote';\n * import { useStream } from '@thomasfosterau/effect-svelte';\n *\n * const feed = useStream(Remote.liveQueryStream(messages()));\n * ```\n */\nexport function liveQueryStream<Output>(\n query: RemoteLiveQuery<Output>,\n): Stream.Stream<Output, unknown> {\n return Stream.fromAsyncIterable(query, (error) => error);\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAS,kBAAqB,OAA+D;CAC3F,OAAO,OAAO,cAAc,QAAQ,QAAQ,MAAM,CAAC,CAAC;AACtD;AAsBA,SAAgB,UACd,OACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBACJ,MAAuD,KAAA,CAAS,CACnE;CAGF,OAAO,wBAAwB,MAAM,KAAc,CAAC;AACtD;AAuBA,SAAgB,YACd,SACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBAAyB,QAAmD,KAAA,CAAS,CAAC;CAG/F,OAAO,wBAAwB,QAAQ,KAAc,CAAC;AACxD;;;;;;;;;;;;AAaA,SAAgB,uBACd,SACA,OACA,GAAG,SACoC;CACvC,OAAO,wBAAwB,QAAQ,KAAK,CAAC,CAAC,QAAQ,GAAG,OAAO,CAAC;AACnE;AAuBA,SAAgB,cACd,WACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBACJ,UAA+D,KAAA,CAAS,CAC3E;CAGF,OAAO,wBAAwB,UAAU,KAAc,CAAC;AAC1D;;;;;;;AAiBA,SAAgB,WACd,QACqC;CACrC,OAAO,OAAO,OAAO,wBAAwB,OAAO,CAAC,CAAC;AACxD;;;;;;;;AASA,SAAgB,sBACd,QACA,GAAG,SACkC;CACrC,OAAO,OAAO,OAAO,wBAAwB,OAAO,CAAC,CAAC,QAAQ,GAAG,OAAO,CAAC,CAAC;AAC5E;;;;;;;;;;;;;;;;;AAkBA,SAAgB,gBACd,OACgC;CAChC,OAAO,OAAO,kBAAkB,QAAQ,UAAU,KAAK;AACzD"}
|
package/dist/State.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { PageSnapshot } from "./internal/app-state.js";
|
|
2
2
|
import { Stream } from "effect";
|
|
3
|
-
import { Page } from "
|
|
3
|
+
import { Page } from "$app/state";
|
|
4
4
|
declare namespace State_d_exports {
|
|
5
|
-
export { PageSnapshot, page };
|
|
5
|
+
export { PageSnapshot, page$1 as page };
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* A `Stream` of the current SvelteKit `page`, emitting a shallow snapshot
|
|
9
9
|
* immediately and again after every navigation. Call during component
|
|
10
10
|
* initialization.
|
|
11
11
|
*/
|
|
12
|
-
declare function page(): Stream.Stream<PageSnapshot<Page>>;
|
|
12
|
+
declare function page$1(): Stream.Stream<PageSnapshot<Page>>;
|
|
13
13
|
//#endregion
|
|
14
|
-
export { type PageSnapshot, State_d_exports, page };
|
|
14
|
+
export { type PageSnapshot, State_d_exports, page$1 as page };
|
|
15
15
|
//# sourceMappingURL=State.d.ts.map
|
package/dist/State.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.js","names":["page","kitPage"],"sources":["../src/State.ts"],"sourcesContent":["/**\n * A minimal Effect-side bridge for SvelteKit's\n * [`$app/state`](https://svelte.dev/docs/kit/$app-state) `page`.\n *\n * `$app/state` exposes rune-reactive `page` / `navigating` / `updated` for use\n * inside components. This bridges `page` to an Effect `Stream` so navigation can\n * drive Effect pipelines without touching Svelte runes: it emits the current\n * `page` immediately, then again after each navigation, by registering\n * `afterNavigate` (from `$app/navigation`) and reading `page` (from\n * `$app/state`) at callback time.\n *\n * Each emission is a *shallow snapshot* (`url`, `params`, `route`, `data`,\n * `status`, `error`, `form`, `state`) rather than the live `$app/state` proxy:\n * the proxy mutates in place on every navigation, so a captured reference is\n * unreliable for downstream consumers — the snapshot gives each emission a\n * stable value. Reading at `afterNavigate` time also avoids needing a `.svelte`\n * runes file.\n *\n * Like the navigation-event helpers, `page` registers its callback during\n * component initialization (where `$app/navigation` requires), so call it at the\n * top level of `<script>`. Client-only.\n *\n * NOTE: this is intentionally minimal. A richer reactive bridge (a `CurrentPage`\n * service readable from any Effect, `navigating` / `updated` streams) may later\n * compose with the official `@effect/atom-svelte` integration (see issue #23)\n * rather than re-implementing runes plumbing here.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { State } from '@thomasfosterau/effect-sveltekit/client';\n * import { Stream, Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * const pages = State.page();\n * getRuntime().runFork(\n * Stream.runForEach(pages, (page) =>\n * Effect.logInfo(`page: ${page.url.pathname}`),\n * ),\n * );\n * </script>\n * ```\n */\n\nimport { afterNavigate as kitAfterNavigate } from \"$app/navigation\";\nimport { page as kitPage } from \"$app/state\";\nimport type { Page } from \"
|
|
1
|
+
{"version":3,"file":"State.js","names":["page","kitPage"],"sources":["../src/State.ts"],"sourcesContent":["/**\n * A minimal Effect-side bridge for SvelteKit's\n * [`$app/state`](https://svelte.dev/docs/kit/$app-state) `page`.\n *\n * `$app/state` exposes rune-reactive `page` / `navigating` / `updated` for use\n * inside components. This bridges `page` to an Effect `Stream` so navigation can\n * drive Effect pipelines without touching Svelte runes: it emits the current\n * `page` immediately, then again after each navigation, by registering\n * `afterNavigate` (from `$app/navigation`) and reading `page` (from\n * `$app/state`) at callback time.\n *\n * Each emission is a *shallow snapshot* (`url`, `params`, `route`, `data`,\n * `status`, `error`, `form`, `state`) rather than the live `$app/state` proxy:\n * the proxy mutates in place on every navigation, so a captured reference is\n * unreliable for downstream consumers — the snapshot gives each emission a\n * stable value. Reading at `afterNavigate` time also avoids needing a `.svelte`\n * runes file.\n *\n * Like the navigation-event helpers, `page` registers its callback during\n * component initialization (where `$app/navigation` requires), so call it at the\n * top level of `<script>`. Client-only.\n *\n * NOTE: this is intentionally minimal. A richer reactive bridge (a `CurrentPage`\n * service readable from any Effect, `navigating` / `updated` streams) may later\n * compose with the official `@effect/atom-svelte` integration (see issue #23)\n * rather than re-implementing runes plumbing here.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { State } from '@thomasfosterau/effect-sveltekit/client';\n * import { Stream, Effect } from 'effect';\n * import { getRuntime } from '@thomasfosterau/effect-svelte';\n *\n * const pages = State.page();\n * getRuntime().runFork(\n * Stream.runForEach(pages, (page) =>\n * Effect.logInfo(`page: ${page.url.pathname}`),\n * ),\n * );\n * </script>\n * ```\n */\n\nimport { afterNavigate as kitAfterNavigate } from \"$app/navigation\";\nimport { page as kitPage } from \"$app/state\";\nimport type { Page } from \"$app/state\";\nimport type { Stream } from \"effect\";\nimport { type PageSnapshot, pageSnapshotStream } from \"./internal/app-state.js\";\n\n/** A shallow snapshot of SvelteKit's `page` — see {@link page}. */\nexport type { PageSnapshot } from \"./internal/app-state.js\";\n\n/**\n * A `Stream` of the current SvelteKit `page`, emitting a shallow snapshot\n * immediately and again after every navigation. Call during component\n * initialization.\n */\nexport function page(): Stream.Stream<PageSnapshot<Page>> {\n return pageSnapshotStream<Page>(\n (callback) => {\n kitAfterNavigate(() => {\n callback();\n });\n },\n () => kitPage,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,SAAgBA,SAA0C;CACxD,OAAO,oBACJ,aAAa;EACZ,oBAAuB;GACrB,SAAS;EACX,CAAC;CACH,SACMC,IACR;AACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AssetSource, FileSystemAssetServices } from "./assets.js";
|
|
2
2
|
import { Effect, Layer } from "effect";
|
|
3
|
-
import {
|
|
3
|
+
import { Server } from "@sveltejs/kit";
|
|
4
4
|
import * as HttpServerRequest from "effect/http/HttpServerRequest";
|
|
5
5
|
import * as HttpServerResponse from "effect/http/HttpServerResponse";
|
|
6
6
|
//#region src/adapter/handler.d.ts
|
|
@@ -19,10 +19,15 @@ type SvelteKitHttpAppServices = FileSystemAssetServices;
|
|
|
19
19
|
type SvelteKitHttpApp<R = SvelteKitHttpAppServices> = Effect.Effect<HttpServerResponse.HttpServerResponse, never, R | HttpServerRequest.HttpServerRequest>;
|
|
20
20
|
/** The SvelteKit build output {@link makeHandler} serves. */
|
|
21
21
|
interface SvelteKitHandlerOptions {
|
|
22
|
-
/** The SvelteKit `
|
|
23
|
-
readonly
|
|
24
|
-
/**
|
|
25
|
-
|
|
22
|
+
/** The SvelteKit `server` instance exported by the build output (`./server.js`). */
|
|
23
|
+
readonly server: Server;
|
|
24
|
+
/**
|
|
25
|
+
* The application path, including any `paths.base` without its leading
|
|
26
|
+
* slash (`"_app"`, or `"my-app/_app"` under a base), exported by the build
|
|
27
|
+
* output (`./manifest.js`). Its `immutable/` subtree gets immutable cache
|
|
28
|
+
* headers.
|
|
29
|
+
*/
|
|
30
|
+
readonly appPath: string;
|
|
26
31
|
/** The set of prerendered paths exported by the build output (`./manifest.js`). */
|
|
27
32
|
readonly prerendered: ReadonlySet<string>;
|
|
28
33
|
/** The configured `paths.base`, exported by the build output (`./manifest.js`). */
|
|
@@ -36,10 +41,8 @@ interface SvelteKitHandlerOptions {
|
|
|
36
41
|
}
|
|
37
42
|
/** Options for the platform-neutral SSR core, {@link makeHandlerWith}. */
|
|
38
43
|
interface SvelteKitNeutralHandlerOptions<RAssets> {
|
|
39
|
-
/** The SvelteKit `
|
|
40
|
-
readonly
|
|
41
|
-
/** The SSR manifest exported by the build output. */
|
|
42
|
-
readonly manifest: SSRManifest;
|
|
44
|
+
/** The SvelteKit `server` instance exported by the build output (`./server.js`). */
|
|
45
|
+
readonly server: Server;
|
|
43
46
|
/** Environment variables passed to the SvelteKit server. */
|
|
44
47
|
readonly env?: Record<string, string | undefined> | undefined;
|
|
45
48
|
/** Prefix for the runtime configuration environment variables (ORIGIN, ...). */
|
|
@@ -97,14 +100,13 @@ declare const makeHandler: (options: SvelteKitHandlerOptions) => Effect.Effect<S
|
|
|
97
100
|
* ```ts
|
|
98
101
|
* // Workers: a fetch handler with assets from env.ASSETS
|
|
99
102
|
* import { makeHandlerWith, AssetSource, toWebHandler } from "...adapter/handler";
|
|
100
|
-
* import {
|
|
101
|
-
* import { manifest } from "./manifest.js";
|
|
103
|
+
* import { server } from "./server.js";
|
|
102
104
|
*
|
|
103
105
|
* export default {
|
|
104
106
|
* fetch: (request, env, ctx) =>
|
|
105
107
|
* toWebHandler(
|
|
106
108
|
* makeHandlerWith({
|
|
107
|
-
*
|
|
109
|
+
* server, env,
|
|
108
110
|
* assets: AssetSource.cloudflareAssets(env.ASSETS),
|
|
109
111
|
* read: () => { throw new Error("read() not supported on this deployment"); },
|
|
110
112
|
* }),
|
package/dist/adapter/handler.js
CHANGED
|
@@ -89,14 +89,13 @@ const makeHandler = (options) => Effect.gen(function* () {
|
|
|
89
89
|
const context = yield* Effect.context();
|
|
90
90
|
const serverDir = path.join(options.dir, "server");
|
|
91
91
|
return yield* makeHandlerWith({
|
|
92
|
-
|
|
93
|
-
manifest: options.manifest,
|
|
92
|
+
server: options.server,
|
|
94
93
|
env: options.env,
|
|
95
94
|
envPrefix: options.envPrefix,
|
|
96
95
|
read: (file) => Stream.toReadableStreamWith(fs.stream(path.join(serverDir, file)), context),
|
|
97
96
|
assets: AssetSource.fileSystem({
|
|
98
97
|
dir: options.dir,
|
|
99
|
-
appPath: options.
|
|
98
|
+
appPath: options.appPath,
|
|
100
99
|
prerendered: options.prerendered
|
|
101
100
|
})
|
|
102
101
|
});
|
|
@@ -117,14 +116,13 @@ const makeHandler = (options) => Effect.gen(function* () {
|
|
|
117
116
|
* ```ts
|
|
118
117
|
* // Workers: a fetch handler with assets from env.ASSETS
|
|
119
118
|
* import { makeHandlerWith, AssetSource, toWebHandler } from "...adapter/handler";
|
|
120
|
-
* import {
|
|
121
|
-
* import { manifest } from "./manifest.js";
|
|
119
|
+
* import { server } from "./server.js";
|
|
122
120
|
*
|
|
123
121
|
* export default {
|
|
124
122
|
* fetch: (request, env, ctx) =>
|
|
125
123
|
* toWebHandler(
|
|
126
124
|
* makeHandlerWith({
|
|
127
|
-
*
|
|
125
|
+
* server, env,
|
|
128
126
|
* assets: AssetSource.cloudflareAssets(env.ASSETS),
|
|
129
127
|
* read: () => { throw new Error("read() not supported on this deployment"); },
|
|
130
128
|
* }),
|
|
@@ -134,7 +132,7 @@ const makeHandler = (options) => Effect.gen(function* () {
|
|
|
134
132
|
*/
|
|
135
133
|
const makeHandlerWith = (options) => Effect.gen(function* () {
|
|
136
134
|
const config = yield* handlerConfig(options.envPrefix ?? "").pipe(Effect.orDie);
|
|
137
|
-
const server =
|
|
135
|
+
const server = options.server;
|
|
138
136
|
yield* Effect.promise(() => server.init({
|
|
139
137
|
env: options.env ?? {},
|
|
140
138
|
read: options.read
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handler.js","names":[],"sources":["../../src/adapter/handler.ts"],"sourcesContent":["/**\n * Runtime handler for the Effect SvelteKit adapter.\n *\n * `makeHandler` turns a built SvelteKit app (the `Server` class and manifest\n * emitted by `vite build`) into an Effect HTTP application that serves\n * static client assets, prerendered pages, and server-side rendered routes from\n * disk — the Node default.\n *\n * {@link makeHandlerWith} is the platform-neutral core: it takes an injected\n * {@link AssetSource} (where assets come from) and a `read` capability (how to\n * read server assets), so the same SvelteKit `HttpApp` can run on a Node server\n * or on Cloudflare Workers (assets from `env.ASSETS`).\n *\n * The returned app is an ordinary Effect value: it can be served with the\n * generated `build/index.js` entry (see `./serve.js`), mounted inside any\n * existing `effect/http` HTTP server, or converted to a `fetch` handler\n * (see {@link toWebHandler}).\n */\n\nimport type { SSRManifest, Server as SvelteKitServer } from \"@sveltejs/kit\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as HttpMethod from \"effect/http/HttpMethod\";\nimport * as HttpEffect from \"effect/http/HttpEffect\";\nimport * as HttpServerRequest from \"effect/http/HttpServerRequest\";\nimport * as HttpServerResponse from \"effect/http/HttpServerResponse\";\nimport * as Path from \"effect/Path\";\nimport { Config, Context, Effect, Layer, Option, Stream } from \"effect\";\nimport { AssetSource, type FileSystemAssetServices } from \"./assets.js\";\n\nexport { AssetSource, type FileSystemAssetServices } from \"./assets.js\";\n\n/**\n * The services required by the SvelteKit HTTP application when serving assets\n * from the file system (the Node default). All of them are provided by\n * `NodeHttpServer.layer` from `@effect/platform-node`.\n */\nexport type SvelteKitHttpAppServices = FileSystemAssetServices;\n\n/**\n * The SvelteKit application as a composable Effect HTTP handler: an effect that\n * produces an {@link HttpServerResponse.HttpServerResponse} for the current\n * request. The `HttpServerRequest` is supplied per request by the server. `R`\n * is the asset source's services (defaults to the file-system services).\n */\nexport type SvelteKitHttpApp<R = SvelteKitHttpAppServices> = Effect.Effect<\n HttpServerResponse.HttpServerResponse,\n never,\n R | HttpServerRequest.HttpServerRequest\n>;\n\n/** The SvelteKit build output {@link makeHandler} serves. */\nexport interface SvelteKitHandlerOptions {\n /** The SvelteKit `Server` class exported by the build output (`./server/index.js`). */\n readonly Server: typeof SvelteKitServer;\n /** The SSR manifest exported by the build output (`./manifest.js`). */\n readonly manifest: SSRManifest;\n /** The set of prerendered paths exported by the build output (`./manifest.js`). */\n readonly prerendered: ReadonlySet<string>;\n /** The configured `paths.base`, exported by the build output (`./manifest.js`). */\n readonly base: string;\n /** Absolute path of the build output directory (contains `client/`, `server/`, `prerendered/`). */\n readonly dir: string;\n /** Environment variables passed to the SvelteKit server (e.g. `process.env`). */\n readonly env?: Record<string, string | undefined>;\n /** Prefix for the runtime configuration environment variables (ORIGIN, ...). */\n readonly envPrefix?: string;\n}\n\n/** Options for the platform-neutral SSR core, {@link makeHandlerWith}. */\nexport interface SvelteKitNeutralHandlerOptions<RAssets> {\n /** The SvelteKit `Server` class exported by the build output. */\n readonly Server: typeof SvelteKitServer;\n /** The SSR manifest exported by the build output. */\n readonly manifest: SSRManifest;\n /** Environment variables passed to the SvelteKit server. */\n readonly env?: Record<string, string | undefined> | undefined;\n /** Prefix for the runtime configuration environment variables (ORIGIN, ...). */\n readonly envPrefix?: string | undefined;\n /** Where static client assets and prerendered pages come from. */\n readonly assets: AssetSource<RAssets>;\n /**\n * How to read a server asset (backs `read()` from `$app/server`). On Node\n * this streams from `<dir>/server`; on Workers, back it with the platform's\n * own mechanism.\n */\n readonly read: (file: string) => ReadableStream<Uint8Array>;\n}\n\n/** Runtime configuration, read from the environment (compatible with adapter-node). */\nconst handlerConfig = (prefix: string) =>\n Config.all({\n origin: Config.option(Config.String(`${prefix}ORIGIN`)),\n protocolHeader: Config.option(Config.String(`${prefix}PROTOCOL_HEADER`)),\n hostHeader: Config.option(Config.String(`${prefix}HOST_HEADER`)),\n portHeader: Config.option(Config.String(`${prefix}PORT_HEADER`)),\n addressHeader: Config.option(Config.String(`${prefix}ADDRESS_HEADER`)),\n xffDepth: Config.Int(`${prefix}XFF_DEPTH`).pipe(Config.withDefault(1)),\n });\n\ntype HandlerConfig = Effect.Success<ReturnType<typeof handlerConfig>>;\n\n/** Compute the request origin from configuration and headers (adapter-node semantics). */\nconst originOf = (request: HttpServerRequest.HttpServerRequest, config: HandlerConfig): string => {\n if (Option.isSome(config.origin)) return config.origin.value;\n\n const headers = request.headers;\n const protocolHeader = Option.getOrUndefined(config.protocolHeader)?.toLowerCase();\n const hostHeader = Option.getOrUndefined(config.hostHeader)?.toLowerCase() ?? \"host\";\n const portHeader = Option.getOrUndefined(config.portHeader)?.toLowerCase();\n\n const protocol = (protocolHeader && headers[protocolHeader]) || \"http\";\n const host = headers[hostHeader] ?? \"localhost\";\n const port = portHeader ? headers[portHeader] : undefined;\n\n return port ? `${protocol}://${host.split(\":\")[0]}:${port}` : `${protocol}://${host}`;\n};\n\n/** Resolve the client address, honouring ADDRESS_HEADER / XFF_DEPTH if configured. */\nconst clientAddressOf = (\n request: HttpServerRequest.HttpServerRequest,\n config: HandlerConfig,\n): string => {\n const addressHeader = Option.getOrUndefined(config.addressHeader)?.toLowerCase();\n if (addressHeader) {\n const value = request.headers[addressHeader];\n if (value) {\n if (addressHeader === \"x-forwarded-for\") {\n const addresses = value.split(\",\").map((address) => address.trim());\n if (config.xffDepth < 1 || config.xffDepth > addresses.length) {\n return addresses[0] ?? \"\";\n }\n return addresses[addresses.length - config.xffDepth]!;\n }\n return value;\n }\n }\n return Option.getOrElse(request.remoteAddress, () => \"\");\n};\n\n/** Build a web `Request` for SvelteKit from an `HttpServerRequest`. */\nconst toWebRequest = (\n request: HttpServerRequest.HttpServerRequest,\n url: URL,\n context: Context.Context<never>,\n): Request => {\n // `Headers` is a redactable record-like value; copy the enumerable string\n // entries into a plain record for the web `Request` constructor.\n const init: RequestInit & { duplex?: \"half\" } = {\n method: request.method,\n headers: { ...request.headers },\n };\n if (HttpMethod.hasBody(request.method)) {\n init.body = Stream.toReadableStreamWith(request.stream, context);\n init.duplex = \"half\";\n }\n return new Request(url, init);\n};\n\n/**\n * Creates the SvelteKit HTTP handler.\n *\n * The returned effect initialises the SvelteKit server (running your app's\n * server `init` hook) and yields an HTTP handler that:\n *\n * 1. serves static client assets from `<dir>/client` (with immutable cache\n * headers for hashed build assets),\n * 2. serves prerendered pages from `<dir>/prerendered`,\n * 3. falls back to server-side rendering via the SvelteKit server.\n *\n * @example\n * ```ts\n * // Mounting SvelteKit inside an existing effect/http server:\n * import { handler } from \"./build/handler.js\";\n * import * as HttpServer from \"effect/http/HttpServer\";\n * import { NodeHttpServer, NodeRuntime } from \"@effect/platform-node\";\n * import { Effect, Layer } from \"effect\";\n * import { createServer } from \"node:http\";\n *\n * const serverLayer = Layer.unwrap(\n * Effect.map(handler, (app) => HttpServer.serve(app))\n * ).pipe(Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 })));\n *\n * NodeRuntime.runMain(Layer.launch(serverLayer));\n * ```\n */\nexport const makeHandler = (\n options: SvelteKitHandlerOptions,\n): Effect.Effect<SvelteKitHttpApp, never, SvelteKitHttpAppServices> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const context = yield* Effect.context<never>();\n\n const serverDir = path.join(options.dir, \"server\");\n\n return yield* makeHandlerWith<SvelteKitHttpAppServices>({\n Server: options.Server,\n manifest: options.manifest,\n env: options.env,\n envPrefix: options.envPrefix,\n // `read` backs the `read()` helper from `$app/server`, streaming server\n // assets from the build output.\n read: (file) => Stream.toReadableStreamWith(fs.stream(path.join(serverDir, file)), context),\n assets: AssetSource.fileSystem({\n dir: options.dir,\n appPath: options.manifest.appPath,\n prerendered: options.prerendered,\n }),\n });\n });\n\n/**\n * The platform-neutral SSR core. Like {@link makeHandler}, but the asset source\n * and the server-asset `read` capability are injected, so the same SvelteKit\n * `HttpApp` can run on Node (file-system assets) or on Cloudflare Workers\n * (`AssetSource.cloudflareAssets(env.ASSETS)`).\n *\n * The returned app:\n *\n * 1. falls through to the injected {@link AssetSource} for static client assets\n * and prerendered pages (GET/HEAD), then\n * 2. server-side renders via the SvelteKit server.\n *\n * @example\n * ```ts\n * // Workers: a fetch handler with assets from env.ASSETS\n * import { makeHandlerWith, AssetSource, toWebHandler } from \"...adapter/handler\";\n * import { Server } from \"./server/index.js\";\n * import { manifest } from \"./manifest.js\";\n *\n * export default {\n * fetch: (request, env, ctx) =>\n * toWebHandler(\n * makeHandlerWith({\n * Server, manifest, env,\n * assets: AssetSource.cloudflareAssets(env.ASSETS),\n * read: () => { throw new Error(\"read() not supported on this deployment\"); },\n * }),\n * )(request),\n * };\n * ```\n */\nexport const makeHandlerWith = <RAssets = never>(\n options: SvelteKitNeutralHandlerOptions<RAssets>,\n): Effect.Effect<SvelteKitHttpApp<RAssets>, never, never> =>\n Effect.gen(function* () {\n const config = yield* handlerConfig(options.envPrefix ?? \"\").pipe(Effect.orDie);\n\n // Initialise the SvelteKit server. `read` backs `read()` from `$app/server`.\n const server = new options.Server(options.manifest);\n yield* Effect.promise(() =>\n server.init({\n env: (options.env ?? {}) as Record<string, string>,\n read: options.read,\n }),\n );\n\n // The HTTP handler itself, evaluated once per request.\n return Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const requestContext = yield* Effect.context<never>();\n\n const origin = originOf(request, config);\n const url = new URL(request.url, origin);\n\n let pathname: string;\n try {\n pathname = decodeURIComponent(url.pathname);\n } catch {\n return HttpServerResponse.empty({ status: 400 });\n }\n\n // 1. Static client assets / prerendered pages, via the injected source.\n // Only GET/HEAD reach assets; build a body-less request for the source.\n if (request.method === \"GET\" || request.method === \"HEAD\") {\n const assetRequest = new Request(url, {\n method: request.method,\n headers: { ...request.headers },\n });\n const asset = yield* options.assets.serveAsset(assetRequest, pathname);\n if (Option.isSome(asset)) return asset.value;\n }\n\n // 2. Server-side rendering.\n const webRequest = toWebRequest(request, url, requestContext);\n const response = yield* Effect.promise(() =>\n server.respond(webRequest, {\n getClientAddress: () => clientAddressOf(request, config),\n }),\n );\n return HttpServerResponse.fromWeb(response);\n });\n });\n\n/**\n * Convert a SvelteKit `HttpApp` to a Web `fetch` handler, providing the asset\n * source's services with `layer`. Use this for a Workers `fetch` export or any\n * runtime that speaks the Web platform.\n *\n * @example\n * ```ts\n * const fetchHandler = toWebHandler(\n * makeHandlerWith({ ..., assets: AssetSource.cloudflareAssets(env.ASSETS) }),\n * Layer.empty,\n * );\n * ```\n */\nexport const toWebHandler = <RAssets, E>(\n app: Effect.Effect<SvelteKitHttpApp<RAssets>, never, never>,\n layer: Layer.Layer<RAssets, E>,\n): ((request: Request) => Promise<Response>) => {\n // Build the app (server.init) and the per-request web handler once, lazily on\n // the first request, then dispatch each request through it.\n let built: Promise<(request: Request) => Promise<Response>> | undefined;\n const build = (): Promise<(request: Request) => Promise<Response>> =>\n (built ??= Effect.runPromise(app).then(\n (inner) =>\n HttpEffect.toWebHandlerLayer(inner, layer).handler as (\n request: Request,\n ) => Promise<Response>,\n ));\n return async (request) => (await build())(request);\n};\n"],"mappings":";;;;;;;;;;AAyFA,M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teKit adapter.\n *\n * `makeHandler` turns a built SvelteKit app (the `server` instance the adapter\n * generates with `builder.generateServerInstance`) into an Effect HTTP application that serves\n * static client assets, prerendered pages, and server-side rendered routes from\n * disk — the Node default.\n *\n * {@link makeHandlerWith} is the platform-neutral core: it takes an injected\n * {@link AssetSource} (where assets come from) and a `read` capability (how to\n * read server assets), so the same SvelteKit `HttpApp` can run on a Node server\n * or on Cloudflare Workers (assets from `env.ASSETS`).\n *\n * The returned app is an ordinary Effect value: it can be served with the\n * generated `build/index.js` entry (see `./serve.js`), mounted inside any\n * existing `effect/http` HTTP server, or converted to a `fetch` handler\n * (see {@link toWebHandler}).\n */\n\nimport type { Server as SvelteKitServer } from \"@sveltejs/kit\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as HttpMethod from \"effect/http/HttpMethod\";\nimport * as HttpEffect from \"effect/http/HttpEffect\";\nimport * as HttpServerRequest from \"effect/http/HttpServerRequest\";\nimport * as HttpServerResponse from \"effect/http/HttpServerResponse\";\nimport * as Path from \"effect/Path\";\nimport { Config, Context, Effect, Layer, Option, Stream } from \"effect\";\nimport { AssetSource, type FileSystemAssetServices } from \"./assets.js\";\n\nexport { AssetSource, type FileSystemAssetServices } from \"./assets.js\";\n\n/**\n * The services required by the SvelteKit HTTP application when serving assets\n * from the file system (the Node default). All of them are provided by\n * `NodeHttpServer.layer` from `@effect/platform-node`.\n */\nexport type SvelteKitHttpAppServices = FileSystemAssetServices;\n\n/**\n * The SvelteKit application as a composable Effect HTTP handler: an effect that\n * produces an {@link HttpServerResponse.HttpServerResponse} for the current\n * request. The `HttpServerRequest` is supplied per request by the server. `R`\n * is the asset source's services (defaults to the file-system services).\n */\nexport type SvelteKitHttpApp<R = SvelteKitHttpAppServices> = Effect.Effect<\n HttpServerResponse.HttpServerResponse,\n never,\n R | HttpServerRequest.HttpServerRequest\n>;\n\n/** The SvelteKit build output {@link makeHandler} serves. */\nexport interface SvelteKitHandlerOptions {\n /** The SvelteKit `server` instance exported by the build output (`./server.js`). */\n readonly server: SvelteKitServer;\n /**\n * The application path, including any `paths.base` without its leading\n * slash (`\"_app\"`, or `\"my-app/_app\"` under a base), exported by the build\n * output (`./manifest.js`). Its `immutable/` subtree gets immutable cache\n * headers.\n */\n readonly appPath: string;\n /** The set of prerendered paths exported by the build output (`./manifest.js`). */\n readonly prerendered: ReadonlySet<string>;\n /** The configured `paths.base`, exported by the build output (`./manifest.js`). */\n readonly base: string;\n /** Absolute path of the build output directory (contains `client/`, `server/`, `prerendered/`). */\n readonly dir: string;\n /** Environment variables passed to the SvelteKit server (e.g. `process.env`). */\n readonly env?: Record<string, string | undefined>;\n /** Prefix for the runtime configuration environment variables (ORIGIN, ...). */\n readonly envPrefix?: string;\n}\n\n/** Options for the platform-neutral SSR core, {@link makeHandlerWith}. */\nexport interface SvelteKitNeutralHandlerOptions<RAssets> {\n /** The SvelteKit `server` instance exported by the build output (`./server.js`). */\n readonly server: SvelteKitServer;\n /** Environment variables passed to the SvelteKit server. */\n readonly env?: Record<string, string | undefined> | undefined;\n /** Prefix for the runtime configuration environment variables (ORIGIN, ...). */\n readonly envPrefix?: string | undefined;\n /** Where static client assets and prerendered pages come from. */\n readonly assets: AssetSource<RAssets>;\n /**\n * How to read a server asset (backs `read()` from `$app/server`). On Node\n * this streams from `<dir>/server`; on Workers, back it with the platform's\n * own mechanism.\n */\n readonly read: (file: string) => ReadableStream<Uint8Array>;\n}\n\n/** Runtime configuration, read from the environment (compatible with adapter-node). */\nconst handlerConfig = (prefix: string) =>\n Config.all({\n origin: Config.option(Config.String(`${prefix}ORIGIN`)),\n protocolHeader: Config.option(Config.String(`${prefix}PROTOCOL_HEADER`)),\n hostHeader: Config.option(Config.String(`${prefix}HOST_HEADER`)),\n portHeader: Config.option(Config.String(`${prefix}PORT_HEADER`)),\n addressHeader: Config.option(Config.String(`${prefix}ADDRESS_HEADER`)),\n xffDepth: Config.Int(`${prefix}XFF_DEPTH`).pipe(Config.withDefault(1)),\n });\n\ntype HandlerConfig = Effect.Success<ReturnType<typeof handlerConfig>>;\n\n/** Compute the request origin from configuration and headers (adapter-node semantics). */\nconst originOf = (request: HttpServerRequest.HttpServerRequest, config: HandlerConfig): string => {\n if (Option.isSome(config.origin)) return config.origin.value;\n\n const headers = request.headers;\n const protocolHeader = Option.getOrUndefined(config.protocolHeader)?.toLowerCase();\n const hostHeader = Option.getOrUndefined(config.hostHeader)?.toLowerCase() ?? \"host\";\n const portHeader = Option.getOrUndefined(config.portHeader)?.toLowerCase();\n\n const protocol = (protocolHeader && headers[protocolHeader]) || \"http\";\n const host = headers[hostHeader] ?? \"localhost\";\n const port = portHeader ? headers[portHeader] : undefined;\n\n return port ? `${protocol}://${host.split(\":\")[0]}:${port}` : `${protocol}://${host}`;\n};\n\n/** Resolve the client address, honouring ADDRESS_HEADER / XFF_DEPTH if configured. */\nconst clientAddressOf = (\n request: HttpServerRequest.HttpServerRequest,\n config: HandlerConfig,\n): string => {\n const addressHeader = Option.getOrUndefined(config.addressHeader)?.toLowerCase();\n if (addressHeader) {\n const value = request.headers[addressHeader];\n if (value) {\n if (addressHeader === \"x-forwarded-for\") {\n const addresses = value.split(\",\").map((address) => address.trim());\n if (config.xffDepth < 1 || config.xffDepth > addresses.length) {\n return addresses[0] ?? \"\";\n }\n return addresses[addresses.length - config.xffDepth]!;\n }\n return value;\n }\n }\n return Option.getOrElse(request.remoteAddress, () => \"\");\n};\n\n/** Build a web `Request` for SvelteKit from an `HttpServerRequest`. */\nconst toWebRequest = (\n request: HttpServerRequest.HttpServerRequest,\n url: URL,\n context: Context.Context<never>,\n): Request => {\n // `Headers` is a redactable record-like value; copy the enumerable string\n // entries into a plain record for the web `Request` constructor.\n const init: RequestInit & { duplex?: \"half\" } = {\n method: request.method,\n headers: { ...request.headers },\n };\n if (HttpMethod.hasBody(request.method)) {\n init.body = Stream.toReadableStreamWith(request.stream, context);\n init.duplex = \"half\";\n }\n return new Request(url, init);\n};\n\n/**\n * Creates the SvelteKit HTTP handler.\n *\n * The returned effect initialises the SvelteKit server (running your app's\n * server `init` hook) and yields an HTTP handler that:\n *\n * 1. serves static client assets from `<dir>/client` (with immutable cache\n * headers for hashed build assets),\n * 2. serves prerendered pages from `<dir>/prerendered`,\n * 3. falls back to server-side rendering via the SvelteKit server.\n *\n * @example\n * ```ts\n * // Mounting SvelteKit inside an existing effect/http server:\n * import { handler } from \"./build/handler.js\";\n * import * as HttpServer from \"effect/http/HttpServer\";\n * import { NodeHttpServer, NodeRuntime } from \"@effect/platform-node\";\n * import { Effect, Layer } from \"effect\";\n * import { createServer } from \"node:http\";\n *\n * const serverLayer = Layer.unwrap(\n * Effect.map(handler, (app) => HttpServer.serve(app))\n * ).pipe(Layer.provide(NodeHttpServer.layer(createServer, { port: 3000 })));\n *\n * NodeRuntime.runMain(Layer.launch(serverLayer));\n * ```\n */\nexport const makeHandler = (\n options: SvelteKitHandlerOptions,\n): Effect.Effect<SvelteKitHttpApp, never, SvelteKitHttpAppServices> =>\n Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const context = yield* Effect.context<never>();\n\n const serverDir = path.join(options.dir, \"server\");\n\n return yield* makeHandlerWith<SvelteKitHttpAppServices>({\n server: options.server,\n env: options.env,\n envPrefix: options.envPrefix,\n // `read` backs the `read()` helper from `$app/server`, streaming server\n // assets from the build output.\n read: (file) => Stream.toReadableStreamWith(fs.stream(path.join(serverDir, file)), context),\n assets: AssetSource.fileSystem({\n dir: options.dir,\n appPath: options.appPath,\n prerendered: options.prerendered,\n }),\n });\n });\n\n/**\n * The platform-neutral SSR core. Like {@link makeHandler}, but the asset source\n * and the server-asset `read` capability are injected, so the same SvelteKit\n * `HttpApp` can run on Node (file-system assets) or on Cloudflare Workers\n * (`AssetSource.cloudflareAssets(env.ASSETS)`).\n *\n * The returned app:\n *\n * 1. falls through to the injected {@link AssetSource} for static client assets\n * and prerendered pages (GET/HEAD), then\n * 2. server-side renders via the SvelteKit server.\n *\n * @example\n * ```ts\n * // Workers: a fetch handler with assets from env.ASSETS\n * import { makeHandlerWith, AssetSource, toWebHandler } from \"...adapter/handler\";\n * import { server } from \"./server.js\";\n *\n * export default {\n * fetch: (request, env, ctx) =>\n * toWebHandler(\n * makeHandlerWith({\n * server, env,\n * assets: AssetSource.cloudflareAssets(env.ASSETS),\n * read: () => { throw new Error(\"read() not supported on this deployment\"); },\n * }),\n * )(request),\n * };\n * ```\n */\nexport const makeHandlerWith = <RAssets = never>(\n options: SvelteKitNeutralHandlerOptions<RAssets>,\n): Effect.Effect<SvelteKitHttpApp<RAssets>, never, never> =>\n Effect.gen(function* () {\n const config = yield* handlerConfig(options.envPrefix ?? \"\").pipe(Effect.orDie);\n\n // Initialise the SvelteKit server. `read` backs `read()` from `$app/server`.\n const server = options.server;\n yield* Effect.promise(() =>\n server.init({\n env: options.env ?? {},\n read: options.read,\n }),\n );\n\n // The HTTP handler itself, evaluated once per request.\n return Effect.gen(function* () {\n const request = yield* HttpServerRequest.HttpServerRequest;\n const requestContext = yield* Effect.context<never>();\n\n const origin = originOf(request, config);\n const url = new URL(request.url, origin);\n\n let pathname: string;\n try {\n pathname = decodeURIComponent(url.pathname);\n } catch {\n return HttpServerResponse.empty({ status: 400 });\n }\n\n // 1. Static client assets / prerendered pages, via the injected source.\n // Only GET/HEAD reach assets; build a body-less request for the source.\n if (request.method === \"GET\" || request.method === \"HEAD\") {\n const assetRequest = new Request(url, {\n method: request.method,\n headers: { ...request.headers },\n });\n const asset = yield* options.assets.serveAsset(assetRequest, pathname);\n if (Option.isSome(asset)) return asset.value;\n }\n\n // 2. Server-side rendering.\n const webRequest = toWebRequest(request, url, requestContext);\n const response = yield* Effect.promise(() =>\n server.respond(webRequest, {\n getClientAddress: () => clientAddressOf(request, config),\n }),\n );\n return HttpServerResponse.fromWeb(response);\n });\n });\n\n/**\n * Convert a SvelteKit `HttpApp` to a Web `fetch` handler, providing the asset\n * source's services with `layer`. Use this for a Workers `fetch` export or any\n * runtime that speaks the Web platform.\n *\n * @example\n * ```ts\n * const fetchHandler = toWebHandler(\n * makeHandlerWith({ ..., assets: AssetSource.cloudflareAssets(env.ASSETS) }),\n * Layer.empty,\n * );\n * ```\n */\nexport const toWebHandler = <RAssets, E>(\n app: Effect.Effect<SvelteKitHttpApp<RAssets>, never, never>,\n layer: Layer.Layer<RAssets, E>,\n): ((request: Request) => Promise<Response>) => {\n // Build the app (server.init) and the per-request web handler once, lazily on\n // the first request, then dispatch each request through it.\n let built: Promise<(request: Request) => Promise<Response>> | undefined;\n const build = (): Promise<(request: Request) => Promise<Response>> =>\n (built ??= Effect.runPromise(app).then(\n (inner) =>\n HttpEffect.toWebHandlerLayer(inner, layer).handler as (\n request: Request,\n ) => Promise<Response>,\n ));\n return async (request) => (await build())(request);\n};\n"],"mappings":";;;;;;;;;;AA4FA,MAAM,iBAAiB,WACrB,OAAO,IAAI;CACT,QAAQ,OAAO,OAAO,OAAO,OAAO,GAAG,OAAO,OAAO,CAAC;CACtD,gBAAgB,OAAO,OAAO,OAAO,OAAO,GAAG,OAAO,gBAAgB,CAAC;CACvE,YAAY,OAAO,OAAO,OAAO,OAAO,GAAG,OAAO,YAAY,CAAC;CAC/D,YAAY,OAAO,OAAO,OAAO,OAAO,GAAG,OAAO,YAAY,CAAC;CAC/D,eAAe,OAAO,OAAO,OAAO,OAAO,GAAG,OAAO,eAAe,CAAC;CACrE,UAAU,OAAO,IAAI,GAAG,OAAO,UAAU,CAAC,CAAC,KAAK,OAAO,YAAY,CAAC,CAAC;AACvE,CAAC;;AAKH,MAAM,YAAY,SAA8C,WAAkC;CAChG,IAAI,OAAO,OAAO,OAAO,MAAM,GAAG,OAAO,OAAO,OAAO;CAEvD,MAAM,UAAU,QAAQ;CACxB,MAAM,iBAAiB,OAAO,eAAe,OAAO,cAAc,CAAC,EAAE,YAAY;CACjF,MAAM,aAAa,OAAO,eAAe,OAAO,UAAU,CAAC,EAAE,YAAY,KAAK;CAC9E,MAAM,aAAa,OAAO,eAAe,OAAO,UAAU,CAAC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