@thomasfosterau/effect-sveltekit 0.0.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/LICENSE +21 -0
- package/README.md +66 -0
- package/dist/Hooks.d.ts +33 -0
- package/dist/Hooks.js +34 -0
- package/dist/Hooks.js.map +1 -0
- package/dist/Navigation.d.ts +110 -0
- package/dist/Navigation.js +155 -0
- package/dist/Navigation.js.map +1 -0
- package/dist/Remote.d.ts +52 -0
- package/dist/Remote.js +67 -0
- package/dist/Remote.js.map +1 -0
- package/dist/State.d.ts +17 -0
- package/dist/State.js +65 -0
- package/dist/State.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/adapter/handler.d.ts +67 -0
- package/dist/adapter/handler.js +158 -0
- package/dist/adapter/handler.js.map +1 -0
- package/dist/adapter/index.d.ts +29 -0
- package/dist/adapter/index.js +105 -0
- package/dist/adapter/index.js.map +1 -0
- package/dist/adapter/serve.d.ts +46 -0
- package/dist/adapter/serve.js +57 -0
- package/dist/adapter/serve.js.map +1 -0
- package/dist/app-runtime.d.ts +212 -0
- package/dist/app-runtime.js +173 -0
- package/dist/app-runtime.js.map +1 -0
- package/dist/client/Hooks.d.ts +48 -0
- package/dist/client/Hooks.js +61 -0
- package/dist/client/Hooks.js.map +1 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.js +6 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.js +51 -0
- package/dist/config.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +6 -0
- package/dist/internal/app-state.d.ts +39 -0
- package/dist/internal/app-state.js +52 -0
- package/dist/internal/app-state.js.map +1 -0
- package/dist/internal/auto.d.ts +70 -0
- package/dist/internal/auto.js +161 -0
- package/dist/internal/auto.js.map +1 -0
- package/dist/internal/default-runtime.js +21 -0
- package/dist/internal/default-runtime.js.map +1 -0
- package/dist/internal/error.js +31 -0
- package/dist/internal/error.js.map +1 -0
- package/dist/internal/navigation-events.js +41 -0
- package/dist/internal/navigation-events.js.map +1 -0
- package/dist/remote-reactive.d.ts +38 -0
- package/dist/remote-reactive.js +44 -0
- package/dist/remote-reactive.js.map +1 -0
- package/dist/remote.server.d.ts +48 -0
- package/dist/remote.server.js +90 -0
- package/dist/remote.server.js.map +1 -0
- package/dist/runtime.d.ts +130 -0
- package/dist/runtime.js +143 -0
- package/dist/runtime.js.map +1 -0
- package/dist/server/Endpoint.d.ts +101 -0
- package/dist/server/Endpoint.js +109 -0
- package/dist/server/Endpoint.js.map +1 -0
- package/dist/server/Hooks.d.ts +97 -0
- package/dist/server/Hooks.js +108 -0
- package/dist/server/Hooks.js.map +1 -0
- package/dist/server.d.ts +108 -0
- package/dist/server.js +131 -0
- package/dist/server.js.map +1 -0
- package/dist/transport.d.ts +23 -0
- package/dist/transport.js +34 -0
- package/dist/transport.js.map +1 -0
- package/dist/universal.d.ts +35 -0
- package/dist/universal.js +36 -0
- package/dist/universal.js.map +1 -0
- package/dist/vite.d.ts +42 -0
- package/dist/vite.js +242 -0
- package/dist/vite.js.map +1 -0
- package/package.json +101 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Remote_d_exports } from "./Remote.js";
|
|
2
|
+
import { SvelteKitServices, UniversalRuntime, makeUniversalRuntime } from "./app-runtime.js";
|
|
3
|
+
import { load } from "./universal.js";
|
|
4
|
+
import { Hooks_d_exports } from "./Hooks.js";
|
|
5
|
+
import { sveltekitConfig, sveltekitConfigProvider } from "./config.js";
|
|
6
|
+
export { Hooks_d_exports as Hooks, Remote_d_exports as Remote, type SvelteKitServices, type UniversalRuntime, load, makeUniversalRuntime, sveltekitConfig, sveltekitConfigProvider };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { makeUniversalRuntime } from "./app-runtime.js";
|
|
2
|
+
import { load } from "./universal.js";
|
|
3
|
+
import { Remote_exports } from "./Remote.js";
|
|
4
|
+
import { Hooks_exports } from "./Hooks.js";
|
|
5
|
+
import { sveltekitConfig, sveltekitConfigProvider } from "./config.js";
|
|
6
|
+
export { Hooks_exports as Hooks, Remote_exports as Remote, load, makeUniversalRuntime, sveltekitConfig, sveltekitConfigProvider };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Stream } from "effect";
|
|
2
|
+
|
|
3
|
+
//#region src/internal/app-state.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* The fields of SvelteKit's `page` we snapshot. Mirrors the shape of
|
|
6
|
+
* `@sveltejs/kit`'s `Page`, but as a plain readonly record rather than the live
|
|
7
|
+
* mutating proxy.
|
|
8
|
+
*/
|
|
9
|
+
interface PageSnapshot<P extends ReadonlyPage = ReadonlyPage> {
|
|
10
|
+
readonly url: P["url"];
|
|
11
|
+
readonly params: P["params"];
|
|
12
|
+
readonly route: P["route"];
|
|
13
|
+
readonly status: P["status"];
|
|
14
|
+
readonly error: P["error"];
|
|
15
|
+
readonly data: P["data"];
|
|
16
|
+
readonly state: P["state"];
|
|
17
|
+
readonly form: P["form"];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The subset of `Page` fields the snapshot reads. Deliberately loose (the value
|
|
21
|
+
* types are `unknown` / broad) so SvelteKit's `Page` — whose `params` / `data`
|
|
22
|
+
* / `error` / `state` are app-specific — satisfies the constraint, while
|
|
23
|
+
* `PageSnapshot<P>` recovers the precise field types from `P`.
|
|
24
|
+
*/
|
|
25
|
+
interface ReadonlyPage {
|
|
26
|
+
readonly url: URL;
|
|
27
|
+
readonly params: Record<string, string | undefined>;
|
|
28
|
+
readonly route: {
|
|
29
|
+
readonly id: string | null;
|
|
30
|
+
};
|
|
31
|
+
readonly status: number;
|
|
32
|
+
readonly error: unknown;
|
|
33
|
+
readonly data: Record<string, unknown>;
|
|
34
|
+
readonly state: unknown;
|
|
35
|
+
readonly form: unknown;
|
|
36
|
+
}
|
|
37
|
+
//#endregion
|
|
38
|
+
export { PageSnapshot };
|
|
39
|
+
//# sourceMappingURL=app-state.d.ts.map
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Effect, Queue, Stream } from "effect";
|
|
2
|
+
//#region src/internal/app-state.ts
|
|
3
|
+
/**
|
|
4
|
+
* Pure, `$app/*`-free core for the `$app/state` bridge in `../State.ts`.
|
|
5
|
+
*
|
|
6
|
+
* The public `page` can't be unit-tested directly because importing it
|
|
7
|
+
* pulls in `$app/navigation` and `$app/state` (SvelteKit virtual modules that
|
|
8
|
+
* only exist inside a build). The snapshotting and the "emit now, then after
|
|
9
|
+
* each navigation" plumbing live here instead, parameterised over the
|
|
10
|
+
* navigation registrar and a `readPage` thunk, so they can be driven with
|
|
11
|
+
* stand-ins in tests while the public wrapper stays a thin pass-through.
|
|
12
|
+
*
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* Builds a shallow snapshot of the `page` fields that matter. We copy the
|
|
17
|
+
* fields rather than forwarding the live `$app/state` proxy so downstream Effect
|
|
18
|
+
* consumers see a stable value (the proxy mutates in place on every
|
|
19
|
+
* navigation, which would make a captured reference unreliable). Nested values
|
|
20
|
+
* (`url`, `data`, ...) are *not* deep-cloned: they're replaced wholesale on each
|
|
21
|
+
* navigation, so a shallow copy is enough to distinguish snapshots.
|
|
22
|
+
*/
|
|
23
|
+
function snapshotPage(page) {
|
|
24
|
+
return {
|
|
25
|
+
url: page.url,
|
|
26
|
+
params: page.params,
|
|
27
|
+
route: page.route,
|
|
28
|
+
status: page.status,
|
|
29
|
+
error: page.error,
|
|
30
|
+
data: page.data,
|
|
31
|
+
state: page.state,
|
|
32
|
+
form: page.form
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Emits a snapshot of `readPage()` immediately, then again every time
|
|
37
|
+
* `registerAfterNavigate`'s callback fires (i.e. after each navigation). Backed
|
|
38
|
+
* by an unbounded queue, exposed as a `Stream` — the same push bridge as the
|
|
39
|
+
* navigation-event helpers.
|
|
40
|
+
*/
|
|
41
|
+
function pageSnapshotStream(registerAfterNavigate, readPage) {
|
|
42
|
+
const queue = Effect.runSync(Queue.unbounded());
|
|
43
|
+
Queue.offerUnsafe(queue, snapshotPage(readPage()));
|
|
44
|
+
registerAfterNavigate(() => {
|
|
45
|
+
Queue.offerUnsafe(queue, snapshotPage(readPage()));
|
|
46
|
+
});
|
|
47
|
+
return Stream.fromQueue(queue);
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { pageSnapshotStream };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=app-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-state.js","names":[],"sources":["../../src/internal/app-state.ts"],"sourcesContent":["/**\n * Pure, `$app/*`-free core for the `$app/state` bridge in `../State.ts`.\n *\n * The public `page` can't be unit-tested directly because importing it\n * pulls in `$app/navigation` and `$app/state` (SvelteKit virtual modules that\n * only exist inside a build). The snapshotting and the \"emit now, then after\n * each navigation\" plumbing live here instead, parameterised over the\n * navigation registrar and a `readPage` thunk, so they can be driven with\n * stand-ins in tests while the public wrapper stays a thin pass-through.\n *\n * @internal\n */\n\nimport { Effect, Queue, Stream } from \"effect\";\n\n/**\n * The fields of SvelteKit's `page` we snapshot. Mirrors the shape of\n * `@sveltejs/kit`'s `Page`, but as a plain readonly record rather than the live\n * mutating proxy.\n */\nexport interface PageSnapshot<P extends ReadonlyPage = ReadonlyPage> {\n readonly url: P[\"url\"];\n readonly params: P[\"params\"];\n readonly route: P[\"route\"];\n readonly status: P[\"status\"];\n readonly error: P[\"error\"];\n readonly data: P[\"data\"];\n readonly state: P[\"state\"];\n readonly form: P[\"form\"];\n}\n\n/**\n * The subset of `Page` fields the snapshot reads. Deliberately loose (the value\n * types are `unknown` / broad) so SvelteKit's `Page` — whose `params` / `data`\n * / `error` / `state` are app-specific — satisfies the constraint, while\n * `PageSnapshot<P>` recovers the precise field types from `P`.\n */\nexport interface ReadonlyPage {\n readonly url: URL;\n readonly params: Record<string, string | undefined>;\n readonly route: { readonly id: string | null };\n readonly status: number;\n readonly error: unknown;\n readonly data: Record<string, unknown>;\n readonly state: unknown;\n readonly form: unknown;\n}\n\n/**\n * Builds a shallow snapshot of the `page` fields that matter. We copy the\n * fields rather than forwarding the live `$app/state` proxy so downstream Effect\n * consumers see a stable value (the proxy mutates in place on every\n * navigation, which would make a captured reference unreliable). Nested values\n * (`url`, `data`, ...) are *not* deep-cloned: they're replaced wholesale on each\n * navigation, so a shallow copy is enough to distinguish snapshots.\n */\nexport function snapshotPage<P extends ReadonlyPage>(page: P): PageSnapshot<P> {\n return {\n url: page.url,\n params: page.params,\n route: page.route,\n status: page.status,\n error: page.error,\n data: page.data,\n state: page.state,\n form: page.form,\n };\n}\n\n/**\n * Emits a snapshot of `readPage()` immediately, then again every time\n * `registerAfterNavigate`'s callback fires (i.e. after each navigation). Backed\n * by an unbounded queue, exposed as a `Stream` — the same push bridge as the\n * navigation-event helpers.\n */\nexport function pageSnapshotStream<P extends ReadonlyPage>(\n registerAfterNavigate: (callback: () => void) => void,\n readPage: () => P,\n): Stream.Stream<PageSnapshot<P>> {\n const queue = Effect.runSync(Queue.unbounded<PageSnapshot<P>>());\n // Initial value: the current page, so consumers start from a known state.\n Queue.offerUnsafe(queue, snapshotPage(readPage()));\n // afterNavigate fires once on mount too, but emitting up front means a\n // late-subscribing consumer still sees the current page without waiting for a\n // navigation.\n registerAfterNavigate(() => {\n Queue.offerUnsafe(queue, snapshotPage(readPage()));\n });\n return Stream.fromQueue(queue);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAwDA,SAAgB,aAAqC,MAA0B;CAC7E,OAAO;EACL,KAAK,KAAK;EACV,QAAQ,KAAK;EACb,OAAO,KAAK;EACZ,QAAQ,KAAK;EACb,OAAO,KAAK;EACZ,MAAM,KAAK;EACX,OAAO,KAAK;EACZ,MAAM,KAAK;CACb;AACF;;;;;;;AAQA,SAAgB,mBACd,uBACA,UACgC;CAChC,MAAM,QAAQ,OAAO,QAAQ,MAAM,UAA2B,CAAC;CAE/D,MAAM,YAAY,OAAO,aAAa,SAAS,CAAC,CAAC;CAIjD,4BAA4B;EAC1B,MAAM,YAAY,OAAO,aAAa,SAAS,CAAC,CAAC;CACnD,CAAC;CACD,OAAO,OAAO,UAAU,KAAK;AAC/B"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { ServerRuntime, UniversalRuntime } from "../app-runtime.js";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import { Action, Actions, Handle, HandleClientError, HandleFetch, HandleServerError, Load, RequestEvent, Reroute, ServerLoad } from "@sveltejs/kit";
|
|
4
|
+
|
|
5
|
+
//#region src/internal/auto.d.ts
|
|
6
|
+
type AnyEffect = Effect.Effect<unknown, unknown, never>;
|
|
7
|
+
type AnyRuntime = ServerRuntime<any, any> | UniversalRuntime<any, any>;
|
|
8
|
+
/**
|
|
9
|
+
* Module shape accepted for the plugin's `serverRuntime` / `clientRuntime`
|
|
10
|
+
* options: the runtime can be the default export or a named `runtime` export.
|
|
11
|
+
*/
|
|
12
|
+
interface RuntimeModule {
|
|
13
|
+
readonly runtime?: AnyRuntime;
|
|
14
|
+
readonly default?: AnyRuntime;
|
|
15
|
+
}
|
|
16
|
+
type LoadLikeInput = undefined | AnyEffect | ((event: any) => unknown);
|
|
17
|
+
/**
|
|
18
|
+
* Wraps a value intended to be a SvelteKit universal `load` export.
|
|
19
|
+
* Used by the Vite plugin for `+page.ts` / `+layout.ts`.
|
|
20
|
+
*/
|
|
21
|
+
declare function wrapLoad<T extends LoadLikeInput>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Load;
|
|
22
|
+
/**
|
|
23
|
+
* Wraps a value intended to be a SvelteKit server `load` export.
|
|
24
|
+
* Used by the Vite plugin for `+page.server.ts` / `+layout.server.ts`.
|
|
25
|
+
*/
|
|
26
|
+
declare function wrapServerLoad<T extends LoadLikeInput>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : ServerLoad;
|
|
27
|
+
/**
|
|
28
|
+
* Wraps a single SvelteKit action handler.
|
|
29
|
+
*/
|
|
30
|
+
declare function wrapAction<T extends LoadLikeInput>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Action;
|
|
31
|
+
/**
|
|
32
|
+
* Wraps a SvelteKit `actions` object, individually wrapping each entry.
|
|
33
|
+
*/
|
|
34
|
+
declare function wrapActions<T extends Record<string, LoadLikeInput> | undefined>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Actions;
|
|
35
|
+
/**
|
|
36
|
+
* Wraps a SvelteKit `handle` hook export.
|
|
37
|
+
*/
|
|
38
|
+
declare function wrapHandle<T extends undefined | AnyEffect | ((args: Parameters<Handle>[0]) => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Handle;
|
|
39
|
+
/**
|
|
40
|
+
* Wraps a SvelteKit `handleFetch` hook export.
|
|
41
|
+
*/
|
|
42
|
+
declare function wrapHandleFetch<T extends undefined | AnyEffect | ((args: Parameters<HandleFetch>[0]) => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : HandleFetch;
|
|
43
|
+
type AnyHandleError = HandleServerError | HandleClientError;
|
|
44
|
+
/**
|
|
45
|
+
* Wraps a SvelteKit `handleError` hook export.
|
|
46
|
+
*/
|
|
47
|
+
declare function wrapHandleError<T extends undefined | AnyEffect | ((args: Parameters<AnyHandleError>[0]) => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : AnyHandleError;
|
|
48
|
+
/**
|
|
49
|
+
* Wraps a SvelteKit HTTP endpoint export (`GET`, `POST`, etc.).
|
|
50
|
+
* Errors thrown by the underlying Effect propagate to SvelteKit's normal
|
|
51
|
+
* error-handling pipeline (i.e. they are not silently swallowed). Use the
|
|
52
|
+
* explicit `endpoint()` helper if you need the `exposeErrors` toggle.
|
|
53
|
+
*/
|
|
54
|
+
declare function wrapEndpoint<T extends undefined | AnyEffect | ((event: RequestEvent) => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : (event: RequestEvent) => Response | Promise<Response>;
|
|
55
|
+
type RerouteEvent = Parameters<Reroute>[0];
|
|
56
|
+
/**
|
|
57
|
+
* Wraps a SvelteKit universal `reroute` hook export. The effect runs on the
|
|
58
|
+
* universal runtime with an `HttpClient` backed by the event's `fetch`, on both
|
|
59
|
+
* the server and the client.
|
|
60
|
+
*/
|
|
61
|
+
declare function wrapReroute<T extends undefined | AnyEffect | ((event: RerouteEvent) => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Reroute;
|
|
62
|
+
/**
|
|
63
|
+
* Wraps a SvelteKit `init` hook export (server or client).
|
|
64
|
+
* `init` runs once at startup; there is no request event available, but the
|
|
65
|
+
* application runtime's services (if configured) are.
|
|
66
|
+
*/
|
|
67
|
+
declare function wrapInit<T extends undefined | AnyEffect | (() => unknown)>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : () => Promise<void>;
|
|
68
|
+
//#endregion
|
|
69
|
+
export { RuntimeModule, wrapAction, wrapActions, wrapEndpoint, wrapHandle, wrapHandleError, wrapHandleFetch, wrapInit, wrapLoad, wrapReroute, wrapServerLoad };
|
|
70
|
+
//# sourceMappingURL=auto.d.ts.map
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { causeToThrowable } from "./error.js";
|
|
2
|
+
import { makeServerRuntime, makeUniversalRuntime } from "../app-runtime.js";
|
|
3
|
+
import { Effect, Exit } from "effect";
|
|
4
|
+
//#region src/internal/auto.ts
|
|
5
|
+
let defaultServerRuntime;
|
|
6
|
+
let defaultUniversalRuntime;
|
|
7
|
+
/** Extract the runtime from a runtime module, if any. */
|
|
8
|
+
const runtimeOfModule = (mod) => mod?.runtime ?? mod?.default;
|
|
9
|
+
/** Distinguish a ServerRuntime from a UniversalRuntime structurally. */
|
|
10
|
+
const isServerRuntime = (runtime) => "serverLoad" in runtime;
|
|
11
|
+
/** The server runtime for a module, falling back to the shared default. */
|
|
12
|
+
const serverRuntimeOf = (mod) => {
|
|
13
|
+
const runtime = runtimeOfModule(mod);
|
|
14
|
+
if (runtime !== void 0 && isServerRuntime(runtime)) return runtime;
|
|
15
|
+
return defaultServerRuntime ??= makeServerRuntime();
|
|
16
|
+
};
|
|
17
|
+
/** The universal runtime for a module, falling back to the shared default. */
|
|
18
|
+
const universalRuntimeOf = (mod) => {
|
|
19
|
+
const runtime = runtimeOfModule(mod);
|
|
20
|
+
if (runtime !== void 0 && !isServerRuntime(runtime)) return runtime;
|
|
21
|
+
return defaultUniversalRuntime ??= makeUniversalRuntime();
|
|
22
|
+
};
|
|
23
|
+
/** Run an effect without any request context (e.g. `init` hooks). */
|
|
24
|
+
async function runBare(effect, runtime) {
|
|
25
|
+
const exit = runtime ? await runtime.runtime.runPromiseExit(effect) : await Effect.runPromiseExit(effect);
|
|
26
|
+
return Exit.match(exit, {
|
|
27
|
+
onFailure: (cause) => {
|
|
28
|
+
throw causeToThrowable(cause);
|
|
29
|
+
},
|
|
30
|
+
onSuccess: (value) => value
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function isEffectValue(value) {
|
|
34
|
+
return Effect.isEffect(value);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Wraps a value intended to be a SvelteKit universal `load` export.
|
|
38
|
+
* Used by the Vite plugin for `+page.ts` / `+layout.ts`.
|
|
39
|
+
*/
|
|
40
|
+
function wrapLoad(value, runtimeMod) {
|
|
41
|
+
if (value === void 0) return void 0;
|
|
42
|
+
return (async (event) => {
|
|
43
|
+
const result = isEffectValue(value) ? value : value(event);
|
|
44
|
+
if (!isEffectValue(result)) return result;
|
|
45
|
+
return universalRuntimeOf(runtimeMod).load(() => result)(event);
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** Shared implementation for server-side, event-based wrappers. */
|
|
49
|
+
function wrapServerEvent(value, runtimeMod) {
|
|
50
|
+
if (value === void 0) return void 0;
|
|
51
|
+
return async (event) => {
|
|
52
|
+
const result = isEffectValue(value) ? value : value(event);
|
|
53
|
+
if (!isEffectValue(result)) return result;
|
|
54
|
+
return serverRuntimeOf(runtimeMod).runPromise(event, result);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Wraps a value intended to be a SvelteKit server `load` export.
|
|
59
|
+
* Used by the Vite plugin for `+page.server.ts` / `+layout.server.ts`.
|
|
60
|
+
*/
|
|
61
|
+
function wrapServerLoad(value, runtimeMod) {
|
|
62
|
+
return wrapServerEvent(value, runtimeMod);
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Wraps a single SvelteKit action handler.
|
|
66
|
+
*/
|
|
67
|
+
function wrapAction(value, runtimeMod) {
|
|
68
|
+
return wrapServerEvent(value, runtimeMod);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Wraps a SvelteKit `actions` object, individually wrapping each entry.
|
|
72
|
+
*/
|
|
73
|
+
function wrapActions(value, runtimeMod) {
|
|
74
|
+
if (value === void 0) return void 0;
|
|
75
|
+
if (typeof value !== "object" || value === null) return value;
|
|
76
|
+
const wrapped = {};
|
|
77
|
+
for (const [key, fn] of Object.entries(value)) {
|
|
78
|
+
const wrappedAction = wrapAction(fn, runtimeMod);
|
|
79
|
+
if (wrappedAction !== void 0) wrapped[key] = wrappedAction;
|
|
80
|
+
}
|
|
81
|
+
return wrapped;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Wraps a SvelteKit `handle` hook export.
|
|
85
|
+
*/
|
|
86
|
+
function wrapHandle(value, runtimeMod) {
|
|
87
|
+
if (value === void 0) return void 0;
|
|
88
|
+
const handle = (input) => {
|
|
89
|
+
const result = isEffectValue(value) ? value : value(input);
|
|
90
|
+
if (!isEffectValue(result)) return result;
|
|
91
|
+
return serverRuntimeOf(runtimeMod).handle(() => result)(input);
|
|
92
|
+
};
|
|
93
|
+
return handle;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Wraps a SvelteKit `handleFetch` hook export.
|
|
97
|
+
*/
|
|
98
|
+
function wrapHandleFetch(value, runtimeMod) {
|
|
99
|
+
if (value === void 0) return void 0;
|
|
100
|
+
const handleFetch = async (args) => {
|
|
101
|
+
const result = isEffectValue(value) ? value : value(args);
|
|
102
|
+
if (!isEffectValue(result)) return result;
|
|
103
|
+
return serverRuntimeOf(runtimeMod).runPromise(args.event, result);
|
|
104
|
+
};
|
|
105
|
+
return handleFetch;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Wraps a SvelteKit `handleError` hook export.
|
|
109
|
+
*/
|
|
110
|
+
function wrapHandleError(value, runtimeMod) {
|
|
111
|
+
if (value === void 0) return void 0;
|
|
112
|
+
return (async (args) => {
|
|
113
|
+
const result = isEffectValue(value) ? value : value(args);
|
|
114
|
+
if (!isEffectValue(result)) return result;
|
|
115
|
+
const event = args.event;
|
|
116
|
+
if (event !== void 0 && "request" in event) return serverRuntimeOf(runtimeMod).runPromise(event, result);
|
|
117
|
+
return runBare(result, runtimeOfModule(runtimeMod));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Wraps a SvelteKit HTTP endpoint export (`GET`, `POST`, etc.).
|
|
122
|
+
* Errors thrown by the underlying Effect propagate to SvelteKit's normal
|
|
123
|
+
* error-handling pipeline (i.e. they are not silently swallowed). Use the
|
|
124
|
+
* explicit `endpoint()` helper if you need the `exposeErrors` toggle.
|
|
125
|
+
*/
|
|
126
|
+
function wrapEndpoint(value, runtimeMod) {
|
|
127
|
+
return wrapServerEvent(value, runtimeMod);
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Wraps a SvelteKit universal `reroute` hook export. The effect runs on the
|
|
131
|
+
* universal runtime with an `HttpClient` backed by the event's `fetch`, on both
|
|
132
|
+
* the server and the client.
|
|
133
|
+
*/
|
|
134
|
+
function wrapReroute(value, runtimeMod) {
|
|
135
|
+
if (value === void 0) return void 0;
|
|
136
|
+
return ((event) => {
|
|
137
|
+
const result = isEffectValue(value) ? value : value(event);
|
|
138
|
+
if (!isEffectValue(result)) return result;
|
|
139
|
+
return universalRuntimeOf(runtimeMod).runPromise(event.fetch, result);
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Wraps a SvelteKit `init` hook export (server or client).
|
|
144
|
+
* `init` runs once at startup; there is no request event available, but the
|
|
145
|
+
* application runtime's services (if configured) are.
|
|
146
|
+
*/
|
|
147
|
+
function wrapInit(value, runtimeMod) {
|
|
148
|
+
if (value === void 0) return void 0;
|
|
149
|
+
return (async () => {
|
|
150
|
+
const result = isEffectValue(value) ? value : value();
|
|
151
|
+
if (!isEffectValue(result)) {
|
|
152
|
+
await result;
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
await runBare(result, runtimeOfModule(runtimeMod));
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
//#endregion
|
|
159
|
+
export { wrapAction, wrapActions, wrapEndpoint, wrapHandle, wrapHandleError, wrapHandleFetch, wrapInit, wrapLoad, wrapReroute, wrapServerLoad };
|
|
160
|
+
|
|
161
|
+
//# sourceMappingURL=auto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto.js","names":[],"sources":["../../src/internal/auto.ts"],"sourcesContent":["/**\n * Runtime auto-wrappers used by the SvelteKit Vite plugin.\n *\n * The plugin replaces user-declared SvelteKit exports (`load`, `actions`,\n * `handle`, HTTP method handlers, etc.) with calls into the helpers in this\n * module. At runtime each helper detects whether the underlying value is an\n * Effect, a function returning an Effect, or a plain SvelteKit-compatible\n * function/value, and routes accordingly.\n *\n * When the plugin is configured with a `serverRuntime` / `clientRuntime`\n * module, that module's app-wide runtime (created with `makeServerRuntime` /\n * `makeUniversalRuntime`) is passed as the second argument to these helpers,\n * so plain-Effect exports get access to the application's services.\n *\n * This module is internal — the public Vite plugin generates references to it.\n */\n\nimport type {\n Action,\n Actions,\n Handle,\n HandleClientError,\n HandleFetch,\n HandleServerError,\n Load,\n RequestEvent,\n Reroute,\n ServerLoad,\n} from \"@sveltejs/kit\";\nimport { Effect, Exit } from \"effect\";\nimport {\n makeServerRuntime,\n makeUniversalRuntime,\n type ServerRuntime,\n type UniversalRuntime,\n} from \"../app-runtime.js\";\nimport { causeToThrowable } from \"./error.js\";\n\ntype AnyEffect = Effect.Effect<unknown, unknown, never>;\n\ntype AnyRuntime = ServerRuntime<any, any> | UniversalRuntime<any, any>;\n\n/**\n * Module shape accepted for the plugin's `serverRuntime` / `clientRuntime`\n * options: the runtime can be the default export or a named `runtime` export.\n */\nexport interface RuntimeModule {\n readonly runtime?: AnyRuntime;\n readonly default?: AnyRuntime;\n}\n\n// Default runtimes (no application layer), created lazily and shared across\n// all requests in the process.\nlet defaultServerRuntime: ServerRuntime<any, any> | undefined;\nlet defaultUniversalRuntime: UniversalRuntime<any, any> | undefined;\n\n/** Extract the runtime from a runtime module, if any. */\nconst runtimeOfModule = (mod?: RuntimeModule): AnyRuntime | undefined =>\n mod?.runtime ?? mod?.default;\n\n/** Distinguish a ServerRuntime from a UniversalRuntime structurally. */\nconst isServerRuntime = (runtime: AnyRuntime): runtime is ServerRuntime<any, any> =>\n \"serverLoad\" in runtime;\n\n/** The server runtime for a module, falling back to the shared default. */\nconst serverRuntimeOf = (mod?: RuntimeModule): ServerRuntime<any, any> => {\n const runtime = runtimeOfModule(mod);\n if (runtime !== undefined && isServerRuntime(runtime)) return runtime;\n return (defaultServerRuntime ??= makeServerRuntime<any, any>());\n};\n\n/** The universal runtime for a module, falling back to the shared default. */\nconst universalRuntimeOf = (mod?: RuntimeModule): UniversalRuntime<any, any> => {\n const runtime = runtimeOfModule(mod);\n if (runtime !== undefined && !isServerRuntime(runtime)) return runtime;\n return (defaultUniversalRuntime ??= makeUniversalRuntime<any, any>());\n};\n\n/** Run an effect without any request context (e.g. `init` hooks). */\nasync function runBare(effect: AnyEffect, runtime?: AnyRuntime): Promise<unknown> {\n const exit = runtime\n ? ((await runtime.runtime.runPromiseExit(effect)) as Exit.Exit<unknown, unknown>)\n : await Effect.runPromiseExit(effect);\n\n return Exit.match(exit, {\n onFailure: (cause) => {\n throw causeToThrowable(cause);\n },\n onSuccess: (value) => value,\n });\n}\n\nfunction isEffectValue(value: unknown): value is AnyEffect {\n return Effect.isEffect(value as never);\n}\n\ntype LoadLikeInput = undefined | AnyEffect | ((event: any) => unknown);\n\n/**\n * Wraps a value intended to be a SvelteKit universal `load` export.\n * Used by the Vite plugin for `+page.ts` / `+layout.ts`.\n */\nexport function wrapLoad<T extends LoadLikeInput>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : Load {\n if (value === undefined) return undefined as never;\n\n return (async (event: Parameters<Load>[0]) => {\n const result = isEffectValue(value) ? value : (value as (event: unknown) => unknown)(event);\n if (!isEffectValue(result)) return result;\n\n // Reuse the universal runtime's load wrapper so client/server detection\n // and per-request services stay in one place.\n return universalRuntimeOf(runtimeMod).load(\n () => result as Effect.Effect<Record<string, unknown>, unknown, never>,\n )(event);\n }) as never;\n}\n\n/** Shared implementation for server-side, event-based wrappers. */\nfunction wrapServerEvent<T extends LoadLikeInput>(\n value: T,\n runtimeMod?: RuntimeModule,\n): undefined | ((event: RequestEvent) => Promise<unknown>) {\n if (value === undefined) return undefined;\n\n return async (event: RequestEvent) => {\n const result = isEffectValue(value)\n ? value\n : (value as (event: RequestEvent) => unknown)(event);\n if (!isEffectValue(result)) return result;\n\n return serverRuntimeOf(runtimeMod).runPromise(event, result);\n };\n}\n\n/**\n * Wraps a value intended to be a SvelteKit server `load` export.\n * Used by the Vite plugin for `+page.server.ts` / `+layout.server.ts`.\n */\nexport function wrapServerLoad<T extends LoadLikeInput>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : ServerLoad {\n return wrapServerEvent(value, runtimeMod) as never;\n}\n\n/**\n * Wraps a single SvelteKit action handler.\n */\nexport function wrapAction<T extends LoadLikeInput>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : Action {\n return wrapServerEvent(value, runtimeMod) as never;\n}\n\n/**\n * Wraps a SvelteKit `actions` object, individually wrapping each entry.\n */\nexport function wrapActions<T extends Record<string, LoadLikeInput> | undefined>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : Actions {\n if (value === undefined) return undefined as never;\n if (typeof value !== \"object\" || value === null) return value as never;\n\n const wrapped: Actions = {};\n for (const [key, fn] of Object.entries(value)) {\n const wrappedAction = wrapAction(fn as LoadLikeInput, runtimeMod);\n if (wrappedAction !== undefined) {\n wrapped[key] = wrappedAction;\n }\n }\n return wrapped as never;\n}\n\n/**\n * Wraps a SvelteKit `handle` hook export.\n */\nexport function wrapHandle<\n T extends undefined | AnyEffect | ((args: Parameters<Handle>[0]) => unknown),\n>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : Handle {\n if (value === undefined) return undefined as never;\n\n const handle: Handle = (input) => {\n const result = isEffectValue(value)\n ? value\n : (value as (args: Parameters<Handle>[0]) => unknown)(input);\n if (!isEffectValue(result)) return result as Response | Promise<Response>;\n\n // Route through `handle` so the per-request runtime is installed on\n // `event.locals` for the rest of the request, like the explicit wrapper.\n return serverRuntimeOf(runtimeMod).handle(\n () => result as Effect.Effect<Response, unknown, never>,\n )(input) as Promise<Response>;\n };\n return handle as never;\n}\n\n/**\n * Wraps a SvelteKit `handleFetch` hook export.\n */\nexport function wrapHandleFetch<\n T extends undefined | AnyEffect | ((args: Parameters<HandleFetch>[0]) => unknown),\n>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : HandleFetch {\n if (value === undefined) return undefined as never;\n\n const handleFetch: HandleFetch = async (args) => {\n const result = isEffectValue(value)\n ? value\n : (value as (args: Parameters<HandleFetch>[0]) => unknown)(args);\n if (!isEffectValue(result)) return result as Response | Promise<Response>;\n\n return serverRuntimeOf(runtimeMod).runPromise(args.event, result) as Promise<Response>;\n };\n return handleFetch as never;\n}\n\ntype AnyHandleError = HandleServerError | HandleClientError;\n\n/**\n * Wraps a SvelteKit `handleError` hook export.\n */\nexport function wrapHandleError<\n T extends undefined | AnyEffect | ((args: Parameters<AnyHandleError>[0]) => unknown),\n>(value: T, runtimeMod?: RuntimeModule): T extends undefined ? undefined : AnyHandleError {\n if (value === undefined) return undefined as never;\n\n return (async (args: Parameters<AnyHandleError>[0]) => {\n const result = isEffectValue(value)\n ? value\n : (value as (args: Parameters<AnyHandleError>[0]) => unknown)(args);\n if (!isEffectValue(result)) return result as ReturnType<AnyHandleError>;\n\n // Server errors carry a RequestEvent; client errors carry a NavigationEvent.\n const event = (args as { event?: RequestEvent }).event;\n const isServerEvent = event !== undefined && \"request\" in event;\n\n if (isServerEvent) {\n return serverRuntimeOf(runtimeMod).runPromise(event, result) as ReturnType<AnyHandleError>;\n }\n\n // Client-side: run on the bare app runtime (no request services).\n return runBare(result, runtimeOfModule(runtimeMod)) as ReturnType<AnyHandleError>;\n }) as never;\n}\n\n/**\n * Wraps a SvelteKit HTTP endpoint export (`GET`, `POST`, etc.).\n * Errors thrown by the underlying Effect propagate to SvelteKit's normal\n * error-handling pipeline (i.e. they are not silently swallowed). Use the\n * explicit `endpoint()` helper if you need the `exposeErrors` toggle.\n */\nexport function wrapEndpoint<T extends undefined | AnyEffect | ((event: RequestEvent) => unknown)>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : (event: RequestEvent) => Response | Promise<Response> {\n return wrapServerEvent(value as LoadLikeInput, runtimeMod) as never;\n}\n\ntype RerouteEvent = Parameters<Reroute>[0];\n\n/**\n * Wraps a SvelteKit universal `reroute` hook export. The effect runs on the\n * universal runtime with an `HttpClient` backed by the event's `fetch`, on both\n * the server and the client.\n */\nexport function wrapReroute<T extends undefined | AnyEffect | ((event: RerouteEvent) => unknown)>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : Reroute {\n if (value === undefined) return undefined as never;\n\n return ((event: RerouteEvent) => {\n const result = isEffectValue(value)\n ? value\n : (value as (event: RerouteEvent) => unknown)(event);\n if (!isEffectValue(result)) return result as ReturnType<Reroute>;\n\n return universalRuntimeOf(runtimeMod).runPromise(event.fetch, result) as ReturnType<Reroute>;\n }) as never;\n}\n\n/**\n * Wraps a SvelteKit `init` hook export (server or client).\n * `init` runs once at startup; there is no request event available, but the\n * application runtime's services (if configured) are.\n */\nexport function wrapInit<T extends undefined | AnyEffect | (() => unknown)>(\n value: T,\n runtimeMod?: RuntimeModule,\n): T extends undefined ? undefined : () => Promise<void> {\n if (value === undefined) return undefined as never;\n\n return (async () => {\n const result = isEffectValue(value) ? value : (value as () => unknown)();\n if (!isEffectValue(result)) {\n await result;\n return;\n }\n await runBare(result, runtimeOfModule(runtimeMod));\n }) as never;\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { makeServerRuntime, makeUniversalRuntime } from "../app-runtime.js";
|
|
2
|
+
//#region src/internal/default-runtime.ts
|
|
3
|
+
/**
|
|
4
|
+
* Lazily-created default runtimes (no application layer) backing the package's
|
|
5
|
+
* standalone helpers — the `serverLoad` / `action` / `load` wrappers and the
|
|
6
|
+
* `Hooks` namespaces.
|
|
7
|
+
*
|
|
8
|
+
* They live in their own module so the entry points (`server.ts`,
|
|
9
|
+
* `universal.ts`) and the `Hooks` modules they re-export can all share a single
|
|
10
|
+
* instance without importing one another (which would be circular).
|
|
11
|
+
*/
|
|
12
|
+
let serverRuntime;
|
|
13
|
+
/** The shared default server runtime, created on first use. */
|
|
14
|
+
const defaultServerRuntime = () => serverRuntime ??= makeServerRuntime();
|
|
15
|
+
let universalRuntime;
|
|
16
|
+
/** The shared default universal runtime, created on first use. */
|
|
17
|
+
const defaultUniversalRuntime = () => universalRuntime ??= makeUniversalRuntime();
|
|
18
|
+
//#endregion
|
|
19
|
+
export { defaultServerRuntime, defaultUniversalRuntime };
|
|
20
|
+
|
|
21
|
+
//# sourceMappingURL=default-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-runtime.js","names":[],"sources":["../../src/internal/default-runtime.ts"],"sourcesContent":["/**\n * Lazily-created default runtimes (no application layer) backing the package's\n * standalone helpers — the `serverLoad` / `action` / `load` wrappers and the\n * `Hooks` namespaces.\n *\n * They live in their own module so the entry points (`server.ts`,\n * `universal.ts`) and the `Hooks` modules they re-export can all share a single\n * instance without importing one another (which would be circular).\n */\n\nimport {\n makeServerRuntime,\n makeUniversalRuntime,\n type ServerRuntime,\n type UniversalRuntime,\n} from \"../app-runtime.js\";\n\nlet serverRuntime: ServerRuntime | undefined;\n/** The shared default server runtime, created on first use. */\nexport const defaultServerRuntime = (): ServerRuntime => (serverRuntime ??= makeServerRuntime());\n\nlet universalRuntime: UniversalRuntime | undefined;\n/** The shared default universal runtime, created on first use. */\nexport const defaultUniversalRuntime = (): UniversalRuntime =>\n (universalRuntime ??= makeUniversalRuntime());\n"],"mappings":";;;;;;;;;;;AAiBA,IAAI;;AAEJ,MAAa,6BAA6C,kBAAkB,kBAAkB;AAE9F,IAAI;;AAEJ,MAAa,gCACV,qBAAqB,qBAAqB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Cause } from "effect";
|
|
2
|
+
import { isHttpError, isRedirect } from "@sveltejs/kit";
|
|
3
|
+
//#region src/internal/error.ts
|
|
4
|
+
/**
|
|
5
|
+
* Custom error type that preserves the original Effect Cause.
|
|
6
|
+
*/
|
|
7
|
+
var EffectCauseError = class extends Error {
|
|
8
|
+
constructor(message, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "EffectCauseError";
|
|
11
|
+
this.cause = cause;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Converts a failed Effect Cause into the value to `throw`.
|
|
16
|
+
*
|
|
17
|
+
* SvelteKit uses thrown `redirect()` and `error()` objects for control flow.
|
|
18
|
+
* When one of those is raised inside an Effect (either thrown, surfacing as a
|
|
19
|
+
* defect, or used as a typed failure) the original object is rethrown so
|
|
20
|
+
* SvelteKit can handle it as intended. Anything else is wrapped in an
|
|
21
|
+
* `EffectCauseError` that preserves the full Cause for debugging.
|
|
22
|
+
*/
|
|
23
|
+
const causeToThrowable = (cause) => {
|
|
24
|
+
const squashed = Cause.squash(cause);
|
|
25
|
+
if (isRedirect(squashed) || isHttpError(squashed)) return squashed;
|
|
26
|
+
return new EffectCauseError(Cause.pretty(cause), cause);
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { causeToThrowable };
|
|
30
|
+
|
|
31
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../src/internal/error.ts"],"sourcesContent":["import { isHttpError, isRedirect } from \"@sveltejs/kit\";\nimport { Cause } from \"effect\";\n\n/**\n * Custom error type that preserves the original Effect Cause.\n */\nexport class EffectCauseError extends Error {\n declare cause: Cause.Cause<unknown>;\n\n constructor(message: string, cause: Cause.Cause<unknown>) {\n super(message);\n this.name = \"EffectCauseError\";\n this.cause = cause;\n }\n}\n\n/**\n * Converts a failed Effect Cause into the value to `throw`.\n *\n * SvelteKit uses thrown `redirect()` and `error()` objects for control flow.\n * When one of those is raised inside an Effect (either thrown, surfacing as a\n * defect, or used as a typed failure) the original object is rethrown so\n * SvelteKit can handle it as intended. Anything else is wrapped in an\n * `EffectCauseError` that preserves the full Cause for debugging.\n */\nexport const causeToThrowable = (cause: Cause.Cause<unknown>): unknown => {\n const squashed = Cause.squash(cause);\n if (isRedirect(squashed) || isHttpError(squashed)) {\n return squashed;\n }\n return new EffectCauseError(Cause.pretty(cause), cause);\n};\n"],"mappings":";;;;;;AAMA,IAAa,mBAAb,cAAsC,MAAM;CAG1C,YAAY,SAAiB,OAA6B;EACxD,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,QAAQ;CACf;AACF;;;;;;;;;;AAWA,MAAa,oBAAoB,UAAyC;CACxE,MAAM,WAAW,MAAM,OAAO,KAAK;CACnC,IAAI,WAAW,QAAQ,KAAK,YAAY,QAAQ,GAC9C,OAAO;CAET,OAAO,IAAI,iBAAiB,MAAM,OAAO,KAAK,GAAG,KAAK;AACxD"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Effect, Queue, Stream } from "effect";
|
|
2
|
+
//#region src/internal/navigation-events.ts
|
|
3
|
+
/**
|
|
4
|
+
* Pure, `$app/navigation`-free core for the navigation-event bridge in
|
|
5
|
+
* `../Navigation.ts`.
|
|
6
|
+
*
|
|
7
|
+
* The public helpers can't be unit-tested directly because importing them pulls
|
|
8
|
+
* in `$app/navigation` (a SvelteKit virtual module that only exists inside a
|
|
9
|
+
* build). The queue → stream plumbing and the run-per-navigation + cleanup
|
|
10
|
+
* forwarding live here instead, parameterised over the callback registrar, so
|
|
11
|
+
* they can be driven with a stand-in registrar in tests while the public
|
|
12
|
+
* wrappers stay a thin pass-through of SvelteKit's real functions.
|
|
13
|
+
*
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Registers `register`'s callback against a fresh unbounded queue and exposes
|
|
18
|
+
* that queue as a `Stream`. The callback is wired synchronously (so the public
|
|
19
|
+
* wrappers register during component init, where `$app/navigation` requires);
|
|
20
|
+
* each value offered through it is later yielded by the stream.
|
|
21
|
+
*/
|
|
22
|
+
function registeredStream(register) {
|
|
23
|
+
const queue = Effect.runSync(Queue.unbounded());
|
|
24
|
+
register((value) => {
|
|
25
|
+
Queue.offerUnsafe(queue, value);
|
|
26
|
+
});
|
|
27
|
+
return Stream.fromQueue(queue);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Registers `register`'s callback so that each navigation runs `fn` via
|
|
31
|
+
* `runEffect`, forwarding any cleanup function the resolved Effect produces back
|
|
32
|
+
* to the registrar (SvelteKit awaits it before completing the navigation and
|
|
33
|
+
* runs the returned cleanup once the DOM has updated).
|
|
34
|
+
*/
|
|
35
|
+
function onNavigateWith(register, fn, runEffect) {
|
|
36
|
+
register((navigation) => runEffect(fn(navigation)));
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
export { onNavigateWith, registeredStream };
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=navigation-events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"navigation-events.js","names":[],"sources":["../../src/internal/navigation-events.ts"],"sourcesContent":["/**\n * Pure, `$app/navigation`-free core for the navigation-event bridge in\n * `../Navigation.ts`.\n *\n * The public helpers can't be unit-tested directly because importing them pulls\n * in `$app/navigation` (a SvelteKit virtual module that only exists inside a\n * build). The queue → stream plumbing and the run-per-navigation + cleanup\n * forwarding live here instead, parameterised over the callback registrar, so\n * they can be driven with a stand-in registrar in tests while the public\n * wrappers stay a thin pass-through of SvelteKit's real functions.\n *\n * @internal\n */\n\nimport { Effect, Queue, Stream } from \"effect\";\n\n/**\n * Registers `register`'s callback against a fresh unbounded queue and exposes\n * that queue as a `Stream`. The callback is wired synchronously (so the public\n * wrappers register during component init, where `$app/navigation` requires);\n * each value offered through it is later yielded by the stream.\n */\nexport function registeredStream<A>(\n register: (callback: (value: A) => void) => void,\n): Stream.Stream<A> {\n const queue = Effect.runSync(Queue.unbounded<A>());\n register((value) => {\n Queue.offerUnsafe(queue, value);\n });\n return Stream.fromQueue(queue);\n}\n\n/**\n * Registers `register`'s callback so that each navigation runs `fn` via\n * `runEffect`, forwarding any cleanup function the resolved Effect produces back\n * to the registrar (SvelteKit awaits it before completing the navigation and\n * runs the returned cleanup once the DOM has updated).\n */\nexport function onNavigateWith<A>(\n register: (callback: (value: A) => Promise<(() => void) | void> | (() => void) | void) => void,\n fn: (navigation: A) => Effect.Effect<(() => void) | void>,\n runEffect: <X>(effect: Effect.Effect<X>) => Promise<X>,\n): void {\n register((navigation) => runEffect(fn(navigation)));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,iBACd,UACkB;CAClB,MAAM,QAAQ,OAAO,QAAQ,MAAM,UAAa,CAAC;CACjD,UAAU,UAAU;EAClB,MAAM,YAAY,OAAO,KAAK;CAChC,CAAC;CACD,OAAO,OAAO,UAAU,KAAK;AAC/B;;;;;;;AAQA,SAAgB,eACd,UACA,IACA,WACM;CACN,UAAU,eAAe,UAAU,GAAG,UAAU,CAAC,CAAC;AACpD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RemoteResource } from "@sveltejs/kit";
|
|
2
|
+
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
3
|
+
|
|
4
|
+
//#region src/remote-reactive.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Bridges a SvelteKit remote resource (`query(...)`, `query.live(...)`,
|
|
7
|
+
* `prerender(...)`) into Effect's native
|
|
8
|
+
* {@link AsyncResult.AsyncResult} — the same result type the Svelte hooks in
|
|
9
|
+
* `@thomasfosterau/effect-svelte` expose — so remote-function data folds into
|
|
10
|
+
* the same templates and combinators (`AsyncResult.match`, `isSuccess`, ...).
|
|
11
|
+
*
|
|
12
|
+
* A `RemoteResource<T>` is already reactive (`current` / `loading` / `error` /
|
|
13
|
+
* `ready`); reading them inside the returned `current` getter tracks them, so
|
|
14
|
+
* the result updates as the resource does. The `loading` flag is surfaced as
|
|
15
|
+
* `AsyncResult`'s `waiting` (stale-while-revalidate): a refresh keeps the
|
|
16
|
+
* previous `Success` on screen.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```svelte
|
|
20
|
+
* <script lang="ts">
|
|
21
|
+
* import { useRemoteQuery } from '@thomasfosterau/effect-sveltekit/client';
|
|
22
|
+
* import { AsyncResult } from '@thomasfosterau/effect-svelte';
|
|
23
|
+
* import { getTodos } from './todos.remote';
|
|
24
|
+
*
|
|
25
|
+
* const todos = useRemoteQuery(getTodos());
|
|
26
|
+
* </script>
|
|
27
|
+
*
|
|
28
|
+
* {#if AsyncResult.isSuccess(todos.current)}
|
|
29
|
+
* <ul>{#each todos.current.value as todo}<li>{todo.text}</li>{/each}</ul>
|
|
30
|
+
* {/if}
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
declare function useRemoteQuery<T>(query: RemoteResource<T>): {
|
|
34
|
+
readonly current: AsyncResult.AsyncResult<T, unknown>;
|
|
35
|
+
};
|
|
36
|
+
//#endregion
|
|
37
|
+
export { useRemoteQuery };
|
|
38
|
+
//# sourceMappingURL=remote-reactive.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult";
|
|
2
|
+
//#region src/remote-reactive.ts
|
|
3
|
+
/**
|
|
4
|
+
* Bridges a SvelteKit remote resource (`query(...)`, `query.live(...)`,
|
|
5
|
+
* `prerender(...)`) into Effect's native
|
|
6
|
+
* {@link AsyncResult.AsyncResult} — the same result type the Svelte hooks in
|
|
7
|
+
* `@thomasfosterau/effect-svelte` expose — so remote-function data folds into
|
|
8
|
+
* the same templates and combinators (`AsyncResult.match`, `isSuccess`, ...).
|
|
9
|
+
*
|
|
10
|
+
* A `RemoteResource<T>` is already reactive (`current` / `loading` / `error` /
|
|
11
|
+
* `ready`); reading them inside the returned `current` getter tracks them, so
|
|
12
|
+
* the result updates as the resource does. The `loading` flag is surfaced as
|
|
13
|
+
* `AsyncResult`'s `waiting` (stale-while-revalidate): a refresh keeps the
|
|
14
|
+
* previous `Success` on screen.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```svelte
|
|
18
|
+
* <script lang="ts">
|
|
19
|
+
* import { useRemoteQuery } from '@thomasfosterau/effect-sveltekit/client';
|
|
20
|
+
* import { AsyncResult } from '@thomasfosterau/effect-svelte';
|
|
21
|
+
* import { getTodos } from './todos.remote';
|
|
22
|
+
*
|
|
23
|
+
* const todos = useRemoteQuery(getTodos());
|
|
24
|
+
* <\/script>
|
|
25
|
+
*
|
|
26
|
+
* {#if AsyncResult.isSuccess(todos.current)}
|
|
27
|
+
* <ul>{#each todos.current.value as todo}<li>{todo.text}</li>{/each}</ul>
|
|
28
|
+
* {/if}
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
function useRemoteQuery(query) {
|
|
32
|
+
return { get current() {
|
|
33
|
+
const loading = query.loading;
|
|
34
|
+
const error = query.error;
|
|
35
|
+
const ready = query.ready;
|
|
36
|
+
if (error !== void 0 && error !== null) return AsyncResult.fail(error, { waiting: loading });
|
|
37
|
+
if (ready) return AsyncResult.success(query.current, { waiting: loading });
|
|
38
|
+
return AsyncResult.initial(loading);
|
|
39
|
+
} };
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { useRemoteQuery };
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=remote-reactive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"remote-reactive.js","names":[],"sources":["../src/remote-reactive.ts"],"sourcesContent":["import type { RemoteResource } from \"@sveltejs/kit\";\nimport * as AsyncResult from \"effect/unstable/reactivity/AsyncResult\";\n\n/**\n * Bridges a SvelteKit remote resource (`query(...)`, `query.live(...)`,\n * `prerender(...)`) into Effect's native\n * {@link AsyncResult.AsyncResult} — the same result type the Svelte hooks in\n * `@thomasfosterau/effect-svelte` expose — so remote-function data folds into\n * the same templates and combinators (`AsyncResult.match`, `isSuccess`, ...).\n *\n * A `RemoteResource<T>` is already reactive (`current` / `loading` / `error` /\n * `ready`); reading them inside the returned `current` getter tracks them, so\n * the result updates as the resource does. The `loading` flag is surfaced as\n * `AsyncResult`'s `waiting` (stale-while-revalidate): a refresh keeps the\n * previous `Success` on screen.\n *\n * @example\n * ```svelte\n * <script lang=\"ts\">\n * import { useRemoteQuery } from '@thomasfosterau/effect-sveltekit/client';\n * import { AsyncResult } from '@thomasfosterau/effect-svelte';\n * import { getTodos } from './todos.remote';\n *\n * const todos = useRemoteQuery(getTodos());\n * </script>\n *\n * {#if AsyncResult.isSuccess(todos.current)}\n * <ul>{#each todos.current.value as todo}<li>{todo.text}</li>{/each}</ul>\n * {/if}\n * ```\n */\nexport function useRemoteQuery<T>(query: RemoteResource<T>): {\n readonly current: AsyncResult.AsyncResult<T, unknown>;\n} {\n return {\n get current() {\n // Read every reactive field so the consumer's effect tracks the resource.\n const loading = query.loading;\n const error = query.error;\n const ready = query.ready;\n\n if (error !== undefined && error !== null) {\n return AsyncResult.fail<unknown, T>(error, { waiting: loading });\n }\n if (ready) {\n return AsyncResult.success<T, unknown>(query.current as T, { waiting: loading });\n }\n return AsyncResult.initial<T, unknown>(loading);\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BA,SAAgB,eAAkB,OAEhC;CACA,OAAO,EACL,IAAI,UAAU;EAEZ,MAAM,UAAU,MAAM;EACtB,MAAM,QAAQ,MAAM;EACpB,MAAM,QAAQ,MAAM;EAEpB,IAAI,UAAU,KAAA,KAAa,UAAU,MACnC,OAAO,YAAY,KAAiB,OAAO,EAAE,SAAS,QAAQ,CAAC;EAEjE,IAAI,OACF,OAAO,YAAY,QAAoB,MAAM,SAAc,EAAE,SAAS,QAAQ,CAAC;EAEjF,OAAO,YAAY,QAAoB,OAAO;CAChD,EACF;AACF"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { SvelteKitRequestEvent } from "./runtime.js";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
import * as HttpClient from "effect/unstable/http/HttpClient";
|
|
4
|
+
import { InvalidField, RemoteCommand, RemoteForm, RemoteFormInput, RemotePrerenderFunction, RemoteQueryFunction } from "@sveltejs/kit";
|
|
5
|
+
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
6
|
+
|
|
7
|
+
//#region src/remote.server.d.ts
|
|
8
|
+
type SvelteKitEffectEnv = HttpClient.HttpClient | SvelteKitRequestEvent;
|
|
9
|
+
declare function queryBatch<Input, Output>(validate: "unchecked", fn: (args: Input[]) => Effect.Effect<(arg: Input, idx: number) => Output, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<Input, Output>;
|
|
10
|
+
declare function queryBatch<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (args: StandardSchemaV1.InferOutput<Schema>[]) => Effect.Effect<(arg: StandardSchemaV1.InferOutput<Schema>, idx: number) => Output, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
11
|
+
declare function queryLive<Input, Output>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<AsyncIterable<Output>, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<Input, Output>;
|
|
12
|
+
declare function queryLive<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Effect.Effect<AsyncIterable<Output>, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
13
|
+
declare function form<Output>(fn: () => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteForm<void, Output>;
|
|
14
|
+
declare function form<Input extends RemoteFormInput, Output>(validate: "unchecked", fn: (data: Input, issue: InvalidField<Input>) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteForm<Input, Output>;
|
|
15
|
+
declare function form<Schema extends StandardSchemaV1<RemoteFormInput, Record<string, any>>, Output>(validate: Schema, fn: (data: StandardSchemaV1.InferOutput<Schema>, issue: InvalidField<StandardSchemaV1.InferInput<Schema>>) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteForm<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
16
|
+
declare function command<Output>(fn: () => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteCommand<void, Output>;
|
|
17
|
+
declare function command<Input, Output>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteCommand<Input, Output>;
|
|
18
|
+
declare function command<Schema extends StandardSchemaV1, Output>(validate: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteCommand<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
19
|
+
declare function prerender<Output>(fn: () => Effect.Effect<Output, unknown, SvelteKitEffectEnv>, options?: {
|
|
20
|
+
inputs?: () => Promise<void[]> | void[];
|
|
21
|
+
dynamic?: boolean;
|
|
22
|
+
}): RemotePrerenderFunction<void, Output>;
|
|
23
|
+
declare function prerender<Input, Output>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>, options?: {
|
|
24
|
+
inputs?: () => Promise<Input[]> | Input[];
|
|
25
|
+
dynamic?: boolean;
|
|
26
|
+
}): RemotePrerenderFunction<Input, Output>;
|
|
27
|
+
declare function prerender<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>, options?: {
|
|
28
|
+
inputs?: () => Promise<StandardSchemaV1.InferInput<Schema>[]> | StandardSchemaV1.InferInput<Schema>[];
|
|
29
|
+
dynamic?: boolean;
|
|
30
|
+
}): RemotePrerenderFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
31
|
+
declare function requested<Result = unknown>(...args: unknown[]): Result;
|
|
32
|
+
type QueryNamespace = {
|
|
33
|
+
<Output>(fn: () => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<void, Output>;
|
|
34
|
+
<Input, Output>(validate: "unchecked", fn: (arg: Input) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<Input, Output>;
|
|
35
|
+
<Schema extends StandardSchemaV1, Output>(schema: Schema, fn: (arg: StandardSchemaV1.InferOutput<Schema>) => Effect.Effect<Output, unknown, SvelteKitEffectEnv>): RemoteQueryFunction<StandardSchemaV1.InferInput<Schema>, Output>;
|
|
36
|
+
batch: typeof queryBatch;
|
|
37
|
+
live: typeof queryLive;
|
|
38
|
+
};
|
|
39
|
+
declare const RemoteFunction: {
|
|
40
|
+
query: QueryNamespace;
|
|
41
|
+
form: typeof form;
|
|
42
|
+
command: typeof command;
|
|
43
|
+
prerender: typeof prerender;
|
|
44
|
+
requested: typeof requested;
|
|
45
|
+
};
|
|
46
|
+
//#endregion
|
|
47
|
+
export { RemoteFunction };
|
|
48
|
+
//# sourceMappingURL=remote.server.d.ts.map
|