@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.
Files changed (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +66 -0
  3. package/dist/Hooks.d.ts +33 -0
  4. package/dist/Hooks.js +34 -0
  5. package/dist/Hooks.js.map +1 -0
  6. package/dist/Navigation.d.ts +110 -0
  7. package/dist/Navigation.js +155 -0
  8. package/dist/Navigation.js.map +1 -0
  9. package/dist/Remote.d.ts +52 -0
  10. package/dist/Remote.js +67 -0
  11. package/dist/Remote.js.map +1 -0
  12. package/dist/State.d.ts +17 -0
  13. package/dist/State.js +65 -0
  14. package/dist/State.js.map +1 -0
  15. package/dist/_virtual/_rolldown/runtime.js +13 -0
  16. package/dist/adapter/handler.d.ts +67 -0
  17. package/dist/adapter/handler.js +158 -0
  18. package/dist/adapter/handler.js.map +1 -0
  19. package/dist/adapter/index.d.ts +29 -0
  20. package/dist/adapter/index.js +105 -0
  21. package/dist/adapter/index.js.map +1 -0
  22. package/dist/adapter/serve.d.ts +46 -0
  23. package/dist/adapter/serve.js +57 -0
  24. package/dist/adapter/serve.js.map +1 -0
  25. package/dist/app-runtime.d.ts +212 -0
  26. package/dist/app-runtime.js +173 -0
  27. package/dist/app-runtime.js.map +1 -0
  28. package/dist/client/Hooks.d.ts +48 -0
  29. package/dist/client/Hooks.js +61 -0
  30. package/dist/client/Hooks.js.map +1 -0
  31. package/dist/client.d.ts +6 -0
  32. package/dist/client.js +6 -0
  33. package/dist/config.d.ts +17 -0
  34. package/dist/config.js +51 -0
  35. package/dist/config.js.map +1 -0
  36. package/dist/index.d.ts +6 -0
  37. package/dist/index.js +6 -0
  38. package/dist/internal/app-state.d.ts +39 -0
  39. package/dist/internal/app-state.js +52 -0
  40. package/dist/internal/app-state.js.map +1 -0
  41. package/dist/internal/auto.d.ts +70 -0
  42. package/dist/internal/auto.js +161 -0
  43. package/dist/internal/auto.js.map +1 -0
  44. package/dist/internal/default-runtime.js +21 -0
  45. package/dist/internal/default-runtime.js.map +1 -0
  46. package/dist/internal/error.js +31 -0
  47. package/dist/internal/error.js.map +1 -0
  48. package/dist/internal/navigation-events.js +41 -0
  49. package/dist/internal/navigation-events.js.map +1 -0
  50. package/dist/remote-reactive.d.ts +38 -0
  51. package/dist/remote-reactive.js +44 -0
  52. package/dist/remote-reactive.js.map +1 -0
  53. package/dist/remote.server.d.ts +48 -0
  54. package/dist/remote.server.js +90 -0
  55. package/dist/remote.server.js.map +1 -0
  56. package/dist/runtime.d.ts +130 -0
  57. package/dist/runtime.js +143 -0
  58. package/dist/runtime.js.map +1 -0
  59. package/dist/server/Endpoint.d.ts +101 -0
  60. package/dist/server/Endpoint.js +109 -0
  61. package/dist/server/Endpoint.js.map +1 -0
  62. package/dist/server/Hooks.d.ts +97 -0
  63. package/dist/server/Hooks.js +108 -0
  64. package/dist/server/Hooks.js.map +1 -0
  65. package/dist/server.d.ts +108 -0
  66. package/dist/server.js +131 -0
  67. package/dist/server.js.map +1 -0
  68. package/dist/transport.d.ts +23 -0
  69. package/dist/transport.js +34 -0
  70. package/dist/transport.js.map +1 -0
  71. package/dist/universal.d.ts +35 -0
  72. package/dist/universal.js +36 -0
  73. package/dist/universal.js.map +1 -0
  74. package/dist/vite.d.ts +42 -0
  75. package/dist/vite.js +242 -0
  76. package/dist/vite.js.map +1 -0
  77. package/package.json +101 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thomas Foster
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,66 @@
1
+ # @thomasfosterau/effect-sveltekit
2
+
3
+ Effect v4-native integration for **SvelteKit**: write `load` functions, form
4
+ actions, endpoints, hooks, and remote functions as Effects; move custom types
5
+ across the server/client boundary with Effect Schema; and deploy on an Effect
6
+ HTTP server.
7
+
8
+ Part of the [`effect-svelte`](https://github.com/thomasfosterau/effect-svelte)
9
+ monorepo. Depends on
10
+ [`@thomasfosterau/effect-svelte`](https://www.npmjs.com/package/@thomasfosterau/effect-svelte)
11
+ for the Svelte runes hooks.
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install @thomasfosterau/effect-sveltekit effect@beta svelte @sveltejs/kit
17
+ # the Effect deployment adapter additionally needs:
18
+ npm install @effect/platform-node@beta
19
+ ```
20
+
21
+ ## Entry points
22
+
23
+ | Import | What it provides |
24
+ | ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
25
+ | `@thomasfosterau/effect-sveltekit` | universal helpers (`load`, the `Remote` call namespace, `transport`, `sveltekitConfig`, `reroute`) |
26
+ | `…/server` | server wrappers (`serverLoad`, `action`, `actions`, `handle`, `endpoint`), app runtimes (`makeServerRuntime` / `makeUniversalRuntime`), `RemoteFunction` |
27
+ | `…/client` | browser-only `Navigation` / `State` / `Remote` namespaces and `useRemoteQuery` |
28
+ | `…/vite` | the `effectKit()` Vite plugin (auto-wrap bare-Effect route exports) |
29
+ | `…/adapter` | the Effect HTTP deployment adapter |
30
+
31
+ ## Example
32
+
33
+ ```ts
34
+ // vite.config.ts — return Effects directly from route files
35
+ import { sveltekit } from "@sveltejs/kit/vite";
36
+ import { effectKit } from "@thomasfosterau/effect-sveltekit/vite";
37
+
38
+ export default { plugins: [effectKit(), sveltekit()] };
39
+ ```
40
+
41
+ ```ts
42
+ // +page.server.ts
43
+ import { Effect } from "effect";
44
+ export const load = (event) => Effect.succeed({ id: event.params.id });
45
+ ```
46
+
47
+ ## What's included
48
+
49
+ - **Effects as route exports** — explicit wrappers, app-wide runtimes (services
50
+ built once per process), or the `effectKit()` plugin.
51
+ - **Remote functions** — define with `RemoteFunction.*`, consume via the
52
+ `Remote` namespace (`Remote.callQuery`, `Remote.liveQueryStream`, …);
53
+ `useRemoteQuery` bridges a reactive remote resource to an `AsyncResult`.
54
+ - **`transport` ⇄ Effect Schema** and **`$env` ⇄ Effect `Config`**.
55
+ - **Client navigation/state** — the `Navigation` (`goto`/`invalidate`/… plus
56
+ `beforeNavigate`/`afterNavigate`/`onNavigate` streams) and `State` (`page`)
57
+ namespaces.
58
+ - **Effect deployment adapter** — a production HTTP server on
59
+ `effect/unstable/http` + `@effect/platform-node`.
60
+
61
+ See the [monorepo README](https://github.com/thomasfosterau/effect-svelte#readme)
62
+ for the full API and a runnable SvelteKit example.
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,33 @@
1
+ import { transport, transporter } from "./transport.js";
2
+ import { Effect } from "effect";
3
+ import * as HttpClient from "effect/unstable/http/HttpClient";
4
+ import { Reroute } from "@sveltejs/kit";
5
+
6
+ //#region src/Hooks.d.ts
7
+ declare namespace Hooks_d_exports {
8
+ export { reroute, transport, transporter };
9
+ }
10
+ /**
11
+ * Wraps an Effect-based function as the SvelteKit universal
12
+ * [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook,
13
+ * which rewrites the URL before routing. The effect runs on both the server and
14
+ * the client and gets an `HttpClient` backed by the event's `fetch`.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * // src/hooks.ts
19
+ * import { Hooks } from '@thomasfosterau/effect-sveltekit';
20
+ * import { Effect } from 'effect';
21
+ *
22
+ * export const reroute = Hooks.reroute((event) =>
23
+ * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),
24
+ * );
25
+ * ```
26
+ */
27
+ declare function reroute(fn: (event: {
28
+ url: URL;
29
+ fetch: typeof globalThis.fetch;
30
+ }) => Effect.Effect<string | void, unknown, HttpClient.HttpClient>): Reroute;
31
+ //#endregion
32
+ export { Hooks_d_exports };
33
+ //# sourceMappingURL=Hooks.d.ts.map
package/dist/Hooks.js ADDED
@@ -0,0 +1,34 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { defaultUniversalRuntime } from "./internal/default-runtime.js";
3
+ import { transport, transporter } from "./transport.js";
4
+ import "effect";
5
+ //#region src/Hooks.ts
6
+ var Hooks_exports = /* @__PURE__ */ __exportAll({
7
+ reroute: () => reroute,
8
+ transport: () => transport,
9
+ transporter: () => transporter
10
+ });
11
+ /**
12
+ * Wraps an Effect-based function as the SvelteKit universal
13
+ * [`reroute`](https://svelte.dev/docs/kit/hooks#Universal-hooks-reroute) hook,
14
+ * which rewrites the URL before routing. The effect runs on both the server and
15
+ * the client and gets an `HttpClient` backed by the event's `fetch`.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * // src/hooks.ts
20
+ * import { Hooks } from '@thomasfosterau/effect-sveltekit';
21
+ * import { Effect } from 'effect';
22
+ *
23
+ * export const reroute = Hooks.reroute((event) =>
24
+ * Effect.succeed(event.url.pathname === '/old' ? '/new' : undefined),
25
+ * );
26
+ * ```
27
+ */
28
+ function reroute(fn) {
29
+ return (event) => defaultUniversalRuntime().runPromise(event.fetch, fn(event));
30
+ }
31
+ //#endregion
32
+ export { Hooks_exports };
33
+
34
+ //# sourceMappingURL=Hooks.js.map
@@ -0,0 +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/unstable/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 schemas, and\n * `transporter` builds a single entry. See {@link transport} for details.\n */\nexport { transport, transporter } from \"./transport.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,SAAgB,QACd,IAIS;CACT,QAAQ,UAAU,wBAAwB,EAAE,WAAW,MAAM,OAAO,GAAG,KAAK,CAAC;AAC/E"}
@@ -0,0 +1,110 @@
1
+ import { Effect, Stream } from "effect";
2
+ import { AfterNavigate, BeforeNavigate, OnNavigate } from "@sveltejs/kit";
3
+ import { goto, invalidate, preloadData, refreshAll } from "$app/navigation";
4
+
5
+ //#region src/Navigation.d.ts
6
+ declare namespace Navigation_d_exports {
7
+ 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 };
8
+ }
9
+ /** Navigate to `url`. Wraps `$app/navigation`'s `goto`. */
10
+ declare const goto$1: (...args: Parameters<typeof goto>) => Effect.Effect<void>;
11
+ /** Re-run `load` functions that depend on `resource`. Wraps `invalidate`. */
12
+ declare const invalidate$1: (...args: Parameters<typeof invalidate>) => Effect.Effect<void>;
13
+ /** Re-run every `load` function for the active page. Wraps `invalidateAll`. */
14
+ declare const invalidateAll$1: () => Effect.Effect<void>;
15
+ /** Refresh active remote functions (and, by default, `load`s). Wraps `refreshAll`. */
16
+ declare const refreshAll$1: (...args: Parameters<typeof refreshAll>) => Effect.Effect<void>;
17
+ /** Preload the data for `href`. Wraps `preloadData`. */
18
+ declare const preloadData$1: (href: string) => Effect.Effect<Awaited<ReturnType<typeof preloadData>>>;
19
+ /** Preload the code for routes matching `pathname`. Wraps `preloadCode`. */
20
+ declare const preloadCode$1: (pathname: string) => Effect.Effect<void>;
21
+ /**
22
+ * Registers a `beforeNavigate` callback and exposes every navigation about to
23
+ * happen as an Effect `Stream`. Call during component initialization.
24
+ *
25
+ * Unlike the promise-returning navigation functions above, this is a
26
+ * **callback-registration** function: it must be called *synchronously during
27
+ * component initialization* (SvelteKit wires it to the component's lifecycle).
28
+ * It registers its callback eagerly and feeds an internal `Queue`, returning a
29
+ * `Stream` backed by that queue — the same push-based bridge as `SignalEmitter`
30
+ * in `@thomasfosterau/effect-svelte`. Call it at the top level of `<script>`,
31
+ * exactly where you'd call the bare `beforeNavigate`.
32
+ *
33
+ * @example
34
+ * ```svelte
35
+ * <script lang="ts">
36
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
37
+ * import { Stream, Effect } from 'effect';
38
+ * import { getRuntime } from '@thomasfosterau/effect-svelte';
39
+ *
40
+ * // Register at init so the callback is wired to the component lifecycle.
41
+ * const navigations = Navigation.beforeNavigate();
42
+ *
43
+ * getRuntime().runFork(
44
+ * Stream.runForEach(navigations, (nav) =>
45
+ * Effect.logInfo(`leaving: ${nav.from?.url.pathname}`),
46
+ * ),
47
+ * );
48
+ * </script>
49
+ * ```
50
+ */
51
+ declare function beforeNavigate$1(): Stream.Stream<BeforeNavigate>;
52
+ /**
53
+ * Registers an `afterNavigate` callback and exposes every completed navigation
54
+ * (including the initial one) as an Effect `Stream`. Call during component
55
+ * initialization.
56
+ *
57
+ * Like {@link beforeNavigate}, this is a **callback-registration** function:
58
+ * call it at the top level of `<script>`, exactly where you'd call the bare
59
+ * `afterNavigate`.
60
+ *
61
+ * @example
62
+ * ```svelte
63
+ * <script lang="ts">
64
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
65
+ * import { Stream, Effect } from 'effect';
66
+ * import { getRuntime } from '@thomasfosterau/effect-svelte';
67
+ *
68
+ * // Register at init so the callback is wired to the component lifecycle.
69
+ * const navigations = Navigation.afterNavigate();
70
+ *
71
+ * getRuntime().runFork(
72
+ * Stream.runForEach(navigations, (nav) =>
73
+ * Effect.logInfo(`navigated: ${nav.to?.url.pathname}`),
74
+ * ),
75
+ * );
76
+ * </script>
77
+ * ```
78
+ */
79
+ declare function afterNavigate$1(): Stream.Stream<AfterNavigate>;
80
+ /**
81
+ * Runs an `Effect` for each navigation, registered via `$app/navigation`'s
82
+ * `onNavigate`. Call during component initialization.
83
+ *
84
+ * SvelteKit's `onNavigate` callback may return a cleanup function (or a promise
85
+ * of one) that runs once the navigation completes and the DOM has updated; to
86
+ * support that, `fn`'s Effect may succeed with a `() => void` cleanup, which is
87
+ * forwarded to SvelteKit. The Effect is run with `runEffect` (default
88
+ * {@link Effect.runPromise}); pass a managed runtime's `runPromise` to supply
89
+ * services to `fn`.
90
+ *
91
+ * @example
92
+ * ```svelte
93
+ * <script lang="ts">
94
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
95
+ * import { Effect } from 'effect';
96
+ *
97
+ * Navigation.onNavigate((nav) =>
98
+ * Effect.gen(function* () {
99
+ * yield* Effect.logInfo(`navigating to ${nav.to?.url.pathname}`);
100
+ * // Optionally return a cleanup that runs after the navigation:
101
+ * return () => console.log("navigation done");
102
+ * }),
103
+ * );
104
+ * </script>
105
+ * ```
106
+ */
107
+ declare function onNavigate$1(fn: (navigation: OnNavigate) => Effect.Effect<(() => void) | void>, runEffect?: <X>(effect: Effect.Effect<X>) => Promise<X>): void;
108
+ //#endregion
109
+ export { Navigation_d_exports };
110
+ //# sourceMappingURL=Navigation.d.ts.map
@@ -0,0 +1,155 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { onNavigateWith, registeredStream } from "./internal/navigation-events.js";
3
+ import { Effect } from "effect";
4
+ import { afterNavigate, beforeNavigate, goto, invalidate, invalidateAll, onNavigate, preloadCode, preloadData, refreshAll } from "$app/navigation";
5
+ //#region src/Navigation.ts
6
+ /**
7
+ * Effect wrappers for SvelteKit's client-side
8
+ * [`$app/navigation`](https://svelte.dev/docs/kit/$app-navigation) API.
9
+ *
10
+ * Each of SvelteKit's promise-returning navigation functions is wrapped as an
11
+ * `Effect`, so navigation composes inside Effect pipelines (sequencing,
12
+ * retries, `Effect.race`, tracing spans, ...). Alongside them sit the
13
+ * client-side lifecycle callbacks (`beforeNavigate`, `afterNavigate`,
14
+ * `onNavigate`) bridged to Effect. These run on the client only — calling them
15
+ * during SSR throws, exactly as the underlying `$app/navigation` functions do.
16
+ *
17
+ * @example
18
+ * ```svelte
19
+ * <script lang="ts">
20
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
21
+ * import { Effect } from 'effect';
22
+ * import { getRuntime } from '@thomasfosterau/effect-svelte';
23
+ *
24
+ * const runtime = getRuntime();
25
+ * const save = () =>
26
+ * runtime.runPromise(
27
+ * Effect.gen(function* () {
28
+ * yield* doSave();
29
+ * yield* Navigation.invalidateAll();
30
+ * yield* Navigation.goto('/done');
31
+ * }),
32
+ * );
33
+ * <\/script>
34
+ * ```
35
+ */
36
+ var Navigation_exports = /* @__PURE__ */ __exportAll({
37
+ afterNavigate: () => afterNavigate$1,
38
+ beforeNavigate: () => beforeNavigate$1,
39
+ goto: () => goto$1,
40
+ invalidate: () => invalidate$1,
41
+ invalidateAll: () => invalidateAll$1,
42
+ onNavigate: () => onNavigate$1,
43
+ preloadCode: () => preloadCode$1,
44
+ preloadData: () => preloadData$1,
45
+ refreshAll: () => refreshAll$1
46
+ });
47
+ /** Navigate to `url`. Wraps `$app/navigation`'s `goto`. */
48
+ const goto$1 = (...args) => Effect.promise(() => goto(...args));
49
+ /** Re-run `load` functions that depend on `resource`. Wraps `invalidate`. */
50
+ const invalidate$1 = (...args) => Effect.promise(() => invalidate(...args));
51
+ /** Re-run every `load` function for the active page. Wraps `invalidateAll`. */
52
+ const invalidateAll$1 = () => Effect.promise(() => invalidateAll());
53
+ /** Refresh active remote functions (and, by default, `load`s). Wraps `refreshAll`. */
54
+ const refreshAll$1 = (...args) => Effect.promise(() => refreshAll(...args));
55
+ /** Preload the data for `href`. Wraps `preloadData`. */
56
+ const preloadData$1 = (href) => Effect.promise(() => preloadData(href));
57
+ /** Preload the code for routes matching `pathname`. Wraps `preloadCode`. */
58
+ const preloadCode$1 = (pathname) => Effect.promise(() => preloadCode(pathname));
59
+ /**
60
+ * Registers a `beforeNavigate` callback and exposes every navigation about to
61
+ * happen as an Effect `Stream`. Call during component initialization.
62
+ *
63
+ * Unlike the promise-returning navigation functions above, this is a
64
+ * **callback-registration** function: it must be called *synchronously during
65
+ * component initialization* (SvelteKit wires it to the component's lifecycle).
66
+ * It registers its callback eagerly and feeds an internal `Queue`, returning a
67
+ * `Stream` backed by that queue — the same push-based bridge as `SignalEmitter`
68
+ * in `@thomasfosterau/effect-svelte`. Call it at the top level of `<script>`,
69
+ * exactly where you'd call the bare `beforeNavigate`.
70
+ *
71
+ * @example
72
+ * ```svelte
73
+ * <script lang="ts">
74
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
75
+ * import { Stream, Effect } from 'effect';
76
+ * import { getRuntime } from '@thomasfosterau/effect-svelte';
77
+ *
78
+ * // Register at init so the callback is wired to the component lifecycle.
79
+ * const navigations = Navigation.beforeNavigate();
80
+ *
81
+ * getRuntime().runFork(
82
+ * Stream.runForEach(navigations, (nav) =>
83
+ * Effect.logInfo(`leaving: ${nav.from?.url.pathname}`),
84
+ * ),
85
+ * );
86
+ * <\/script>
87
+ * ```
88
+ */
89
+ function beforeNavigate$1() {
90
+ return registeredStream(beforeNavigate);
91
+ }
92
+ /**
93
+ * Registers an `afterNavigate` callback and exposes every completed navigation
94
+ * (including the initial one) as an Effect `Stream`. Call during component
95
+ * initialization.
96
+ *
97
+ * Like {@link beforeNavigate}, this is a **callback-registration** function:
98
+ * call it at the top level of `<script>`, exactly where you'd call the bare
99
+ * `afterNavigate`.
100
+ *
101
+ * @example
102
+ * ```svelte
103
+ * <script lang="ts">
104
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
105
+ * import { Stream, Effect } from 'effect';
106
+ * import { getRuntime } from '@thomasfosterau/effect-svelte';
107
+ *
108
+ * // Register at init so the callback is wired to the component lifecycle.
109
+ * const navigations = Navigation.afterNavigate();
110
+ *
111
+ * getRuntime().runFork(
112
+ * Stream.runForEach(navigations, (nav) =>
113
+ * Effect.logInfo(`navigated: ${nav.to?.url.pathname}`),
114
+ * ),
115
+ * );
116
+ * <\/script>
117
+ * ```
118
+ */
119
+ function afterNavigate$1() {
120
+ return registeredStream(afterNavigate);
121
+ }
122
+ /**
123
+ * Runs an `Effect` for each navigation, registered via `$app/navigation`'s
124
+ * `onNavigate`. Call during component initialization.
125
+ *
126
+ * SvelteKit's `onNavigate` callback may return a cleanup function (or a promise
127
+ * of one) that runs once the navigation completes and the DOM has updated; to
128
+ * support that, `fn`'s Effect may succeed with a `() => void` cleanup, which is
129
+ * forwarded to SvelteKit. The Effect is run with `runEffect` (default
130
+ * {@link Effect.runPromise}); pass a managed runtime's `runPromise` to supply
131
+ * services to `fn`.
132
+ *
133
+ * @example
134
+ * ```svelte
135
+ * <script lang="ts">
136
+ * import { Navigation } from '@thomasfosterau/effect-sveltekit/client';
137
+ * import { Effect } from 'effect';
138
+ *
139
+ * Navigation.onNavigate((nav) =>
140
+ * Effect.gen(function* () {
141
+ * yield* Effect.logInfo(`navigating to ${nav.to?.url.pathname}`);
142
+ * // Optionally return a cleanup that runs after the navigation:
143
+ * return () => console.log("navigation done");
144
+ * }),
145
+ * );
146
+ * <\/script>
147
+ * ```
148
+ */
149
+ function onNavigate$1(fn, runEffect = Effect.runPromise) {
150
+ onNavigateWith(onNavigate, fn, runEffect);
151
+ }
152
+ //#endregion
153
+ export { Navigation_exports };
154
+
155
+ //# sourceMappingURL=Navigation.js.map
@@ -0,0 +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.invalidateAll();\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 \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\nimport type { Stream } from \"effect\";\nimport { onNavigateWith, registeredStream } from \"./internal/navigation-events.js\";\n\n/** Navigate to `url`. Wraps `$app/navigation`'s `goto`. */\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/** Re-run every `load` function for the active page. Wraps `invalidateAll`. */\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/** Preload the code for routes matching `pathname`. Wraps `preloadCode`. */\nexport const preloadCode = (pathname: string): Effect.Effect<void> =>\n Effect.promise(() => kitPreloadCode(pathname));\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAaA,UAAQ,GAAG,SACtB,OAAO,cAAcC,KAAQ,GAAG,IAAI,CAAC;;AAGvC,MAAaC,gBAAc,GAAG,SAC5B,OAAO,cAAcC,WAAc,GAAG,IAAI,CAAC;;AAG7C,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;;AAG3C,MAAaC,iBAAe,aAC1B,OAAO,cAAcC,YAAe,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgC/C,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"}
@@ -0,0 +1,52 @@
1
+ import { Effect, Stream } from "effect";
2
+ import { RemoteCommand, RemoteLiveQuery, RemotePrerenderFunction, RemoteQuery, RemoteQueryFunction, RemoteQueryOverride } from "@sveltejs/kit";
3
+
4
+ //#region src/Remote.d.ts
5
+ declare namespace Remote_d_exports {
6
+ export { RemoteSubmit, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates };
7
+ }
8
+ declare function callQuery<Output>(query: RemoteQueryFunction<void, Output>): Effect.Effect<Output, unknown, never>;
9
+ declare function callQuery<Input, Output>(query: RemoteQueryFunction<Input, Output>, input: Input): Effect.Effect<Output, unknown, never>;
10
+ declare function callCommand<Output>(command: RemoteCommand<void, Output>): Effect.Effect<Output, unknown, never>;
11
+ declare function callCommand<Input, Output>(command: RemoteCommand<Input, Output>, input: Input): Effect.Effect<Output, unknown, never>;
12
+ /**
13
+ * Calls a remote command and refreshes the given queries in the same round
14
+ * trip (SvelteKit's single-flight mutations).
15
+ *
16
+ * Newer SvelteKit versions cache remote query instances, so a command that
17
+ * changes data those queries depend on must list them here (or call
18
+ * `query.refresh()` afterwards) for their cached values to update.
19
+ */
20
+ declare function callCommandWithUpdates<Input, Output>(command: RemoteCommand<Input, Output>, input: Input, ...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Effect.Effect<Output, unknown, never>;
21
+ declare function callPrerender<Output>(prerender: RemotePrerenderFunction<void, Output>): Effect.Effect<Output, unknown, never>;
22
+ declare function callPrerender<Input, Output>(prerender: RemotePrerenderFunction<Input, Output>, input: Input): Effect.Effect<Output, unknown, never>;
23
+ /**
24
+ * The shape of an enhanced remote form `submit` function. The promise result
25
+ * is left open (SvelteKit returns `Promise<void>` in older versions and
26
+ * `Promise<boolean>` in newer ones).
27
+ */
28
+ type RemoteSubmit = () => PromiseLike<unknown> & {
29
+ updates: (...queries: Array<RemoteQuery<any> | RemoteQueryOverride>) => PromiseLike<unknown>;
30
+ };
31
+ declare function submitForm(submit: () => PromiseLike<unknown>): Effect.Effect<void, unknown, never>;
32
+ declare function submitFormWithUpdates(submit: RemoteSubmit, ...queries: Array<RemoteQuery<any> | RemoteQueryOverride>): Effect.Effect<void, unknown, never>;
33
+ /**
34
+ * Consumes a SvelteKit live query (`query.live(...)`) as an Effect `Stream`.
35
+ *
36
+ * A `RemoteLiveQuery<T>` is an `AsyncIterable<T>` that yields every update
37
+ * pushed from the server; this turns it into a `Stream` so live data can drive
38
+ * Effect pipelines (and, via `useStream`, Svelte runes).
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { Remote } from '@thomasfosterau/effect-sveltekit';
43
+ * import { messages } from './chat.remote';
44
+ * import { useStream } from '@thomasfosterau/effect-svelte';
45
+ *
46
+ * const feed = useStream(Remote.liveQueryStream(messages()));
47
+ * ```
48
+ */
49
+ declare function liveQueryStream<Output>(query: RemoteLiveQuery<Output>): Stream.Stream<Output, unknown>;
50
+ //#endregion
51
+ export { Remote_d_exports };
52
+ //# sourceMappingURL=Remote.d.ts.map
package/dist/Remote.js ADDED
@@ -0,0 +1,67 @@
1
+ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
+ import { Effect, Stream } from "effect";
3
+ //#region src/Remote.ts
4
+ var Remote_exports = /* @__PURE__ */ __exportAll({
5
+ callCommand: () => callCommand,
6
+ callCommandWithUpdates: () => callCommandWithUpdates,
7
+ callPrerender: () => callPrerender,
8
+ callQuery: () => callQuery,
9
+ liveQueryStream: () => liveQueryStream,
10
+ submitForm: () => submitForm,
11
+ submitFormWithUpdates: () => submitFormWithUpdates
12
+ });
13
+ function fromRemotePromise(thunk) {
14
+ return Effect.promise(() => Promise.resolve(thunk()));
15
+ }
16
+ function callQuery(query, input) {
17
+ if (arguments.length === 1) return fromRemotePromise(() => query(void 0));
18
+ return fromRemotePromise(() => query(input));
19
+ }
20
+ function callCommand(command, input) {
21
+ if (arguments.length === 1) return fromRemotePromise(() => command(void 0));
22
+ return fromRemotePromise(() => command(input));
23
+ }
24
+ /**
25
+ * Calls a remote command and refreshes the given queries in the same round
26
+ * trip (SvelteKit's single-flight mutations).
27
+ *
28
+ * Newer SvelteKit versions cache remote query instances, so a command that
29
+ * changes data those queries depend on must list them here (or call
30
+ * `query.refresh()` afterwards) for their cached values to update.
31
+ */
32
+ function callCommandWithUpdates(command, input, ...queries) {
33
+ return fromRemotePromise(() => command(input).updates(...queries));
34
+ }
35
+ function callPrerender(prerender, input) {
36
+ if (arguments.length === 1) return fromRemotePromise(() => prerender(void 0));
37
+ return fromRemotePromise(() => prerender(input));
38
+ }
39
+ function submitForm(submit) {
40
+ return Effect.asVoid(fromRemotePromise(() => submit()));
41
+ }
42
+ function submitFormWithUpdates(submit, ...queries) {
43
+ return Effect.asVoid(fromRemotePromise(() => submit().updates(...queries)));
44
+ }
45
+ /**
46
+ * Consumes a SvelteKit live query (`query.live(...)`) as an Effect `Stream`.
47
+ *
48
+ * A `RemoteLiveQuery<T>` is an `AsyncIterable<T>` that yields every update
49
+ * pushed from the server; this turns it into a `Stream` so live data can drive
50
+ * Effect pipelines (and, via `useStream`, Svelte runes).
51
+ *
52
+ * @example
53
+ * ```ts
54
+ * import { Remote } from '@thomasfosterau/effect-sveltekit';
55
+ * import { messages } from './chat.remote';
56
+ * import { useStream } from '@thomasfosterau/effect-svelte';
57
+ *
58
+ * const feed = useStream(Remote.liveQueryStream(messages()));
59
+ * ```
60
+ */
61
+ function liveQueryStream(query) {
62
+ return Stream.fromAsyncIterable(query, (error) => error);
63
+ }
64
+ //#endregion
65
+ export { Remote_exports };
66
+
67
+ //# sourceMappingURL=Remote.js.map
@@ -0,0 +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 \"@sveltejs/kit\";\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\nexport function callQuery<Output>(\n query: RemoteQueryFunction<void, Output>,\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>;\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\nexport function callCommand<Output>(\n command: RemoteCommand<void, Output>,\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>;\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 */\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\nexport function callPrerender<Output>(\n prerender: RemotePrerenderFunction<void, Output>,\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>;\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\nexport function submitForm(\n submit: () => PromiseLike<unknown>,\n): Effect.Effect<void, unknown, never> {\n return Effect.asVoid(fromRemotePromise(() => submit()));\n}\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;AASA,SAAgB,UACd,OACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBACJ,MAAuD,KAAA,CAAS,CACnE;CAGF,OAAO,wBAAwB,MAAM,KAAc,CAAC;AACtD;AASA,SAAgB,YACd,SACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBAAyB,QAAmD,KAAA,CAAS,CAAC;CAG/F,OAAO,wBAAwB,QAAQ,KAAc,CAAC;AACxD;;;;;;;;;AAUA,SAAgB,uBACd,SACA,OACA,GAAG,SACoC;CACvC,OAAO,wBAAwB,QAAQ,KAAK,EAAE,QAAQ,GAAG,OAAO,CAAC;AACnE;AASA,SAAgB,cACd,WACA,OACuC;CACvC,IAAI,UAAU,WAAW,GACvB,OAAO,wBACJ,UAA+D,KAAA,CAAS,CAC3E;CAGF,OAAO,wBAAwB,UAAU,KAAc,CAAC;AAC1D;AAWA,SAAgB,WACd,QACqC;CACrC,OAAO,OAAO,OAAO,wBAAwB,OAAO,CAAC,CAAC;AACxD;AAEA,SAAgB,sBACd,QACA,GAAG,SACkC;CACrC,OAAO,OAAO,OAAO,wBAAwB,OAAO,EAAE,QAAQ,GAAG,OAAO,CAAC,CAAC;AAC5E;;;;;;;;;;;;;;;;;AAkBA,SAAgB,gBACd,OACgC;CAChC,OAAO,OAAO,kBAAkB,QAAQ,UAAU,KAAK;AACzD"}
@@ -0,0 +1,17 @@
1
+ import { PageSnapshot } from "./internal/app-state.js";
2
+ import { Stream } from "effect";
3
+ import { Page } from "@sveltejs/kit";
4
+
5
+ //#region src/State.d.ts
6
+ declare namespace State_d_exports {
7
+ export { PageSnapshot, page };
8
+ }
9
+ /**
10
+ * A `Stream` of the current SvelteKit `page`, emitting a shallow snapshot
11
+ * immediately and again after every navigation. Call during component
12
+ * initialization.
13
+ */
14
+ declare function page(): Stream.Stream<PageSnapshot<Page>>;
15
+ //#endregion
16
+ export { State_d_exports };
17
+ //# sourceMappingURL=State.d.ts.map