@thomasfosterau/effect-sveltekit 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -10
- package/dist/client.d.ts +9 -7
- package/dist/client.js +8 -7
- package/dist/index.d.ts +5 -4
- package/dist/index.js +5 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -47,9 +47,9 @@ optional `effectKit()` Vite plugin lets route files export bare Effects instead.
|
|
|
47
47
|
|
|
48
48
|
| Entry point | What it provides |
|
|
49
49
|
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
50
|
-
| `@thomasfosterau/effect-sveltekit` | Universal helpers: `load` / `makeUniversalRuntime`, the `Remote` call namespace
|
|
50
|
+
| `@thomasfosterau/effect-sveltekit` | Universal helpers: `load` / `makeUniversalRuntime`, the `Remote` call namespace and `Hooks` (`reroute`, `transport`), each also exported member by member, `ResponseHeaders`, `sveltekitConfig` / `readConfig`, `apiClient` |
|
|
51
51
|
| `…/server` | Server wrappers (`serverLoad`, `action`, `actions`, `endpoint`), `Hooks`, `Endpoint`, `makeServerRuntime`, the per-request runtime seam (`makeRuntimeAdapter` / `RequestRuntime`), `Errors`, `RemoteFunction` / `RemoteFunctionUsageError`, `KitError` / `KitErrorBody`, request decoding (`decodeParams`, `decodeJson`, …) |
|
|
52
|
-
| `…/client` | Browser-only `Navigation`, `State` (incl. the `CurrentPage` service), `Remote`, `Realtime`, `Forms` and `Hooks` namespaces, and `useRemoteQuery` / `RemoteQueryResult`
|
|
52
|
+
| `…/client` | Browser-only `Navigation`, `State` (incl. the `CurrentPage` service), `Remote`, `Realtime`, `Forms` and `Hooks` namespaces, each also exported member by member, and `useRemoteQuery` / `RemoteQueryResult` |
|
|
53
53
|
| `…/vite` | The `effectKit()` Vite plugin (auto-wraps bare-Effect route exports) |
|
|
54
54
|
| `…/adapter` | The Effect HTTP deployment adapter (`effectAdapter`) |
|
|
55
55
|
| `…/adapter/handler` | The SvelteKit app as an Effect HTTP app (`makeHandler`, `makeHandlerWith`, `AssetSource`, `toWebHandler`, the `SvelteKitServerError` / `AssetFetchError` defects) |
|
|
@@ -388,6 +388,15 @@ import {
|
|
|
388
388
|
// Remote.callQuery(getTodos), State.page()
|
|
389
389
|
```
|
|
390
390
|
|
|
391
|
+
Every member of `Navigation`, `State`, `Remote`, `Realtime`, `Forms` and
|
|
392
|
+
`Hooks` is also a named export of `…/client` (`goto`, `page`, `callQuery`,
|
|
393
|
+
`fromEventSource`, `enhance`, `handleError`, …), and the named imports are the
|
|
394
|
+
ones to prefer in the browser bundle. The published build turns each namespace
|
|
395
|
+
into a single object, so `Navigation.goto` also keeps `beforeNavigate`,
|
|
396
|
+
`afterNavigate`, `onNavigate` and the navigation-event registry behind them,
|
|
397
|
+
while `import { goto } from "@thomasfosterau/effect-sveltekit/client"` keeps
|
|
398
|
+
only `goto` and what it uses.
|
|
399
|
+
|
|
391
400
|
`Navigation.goto`, `invalidate`, `invalidateAll`, `refreshAll`, `preloadData`
|
|
392
401
|
and `preloadCode` fail with `Navigation.NavigationError` when SvelteKit rejects
|
|
393
402
|
or throws: for example, `goto` to a URL outside the app, `preloadData` for an
|
|
@@ -434,14 +443,14 @@ const logPath = Effect.gen(function* () {
|
|
|
434
443
|
Move custom types (`Option`, `DateTime`, branded types, `Schema.Class`
|
|
435
444
|
instances, tagged errors, ...) across the server/client boundary — for `load`
|
|
436
445
|
data and remote functions — by building SvelteKit's universal `transport` hook
|
|
437
|
-
from Effect schemas (
|
|
446
|
+
from Effect schemas (also reachable as `Hooks.transport`):
|
|
438
447
|
|
|
439
448
|
```ts
|
|
440
449
|
// src/hooks.ts
|
|
441
|
-
import {
|
|
450
|
+
import { transport as effectTransport } from "@thomasfosterau/effect-sveltekit";
|
|
442
451
|
import { Schema } from "effect";
|
|
443
452
|
|
|
444
|
-
export const transport =
|
|
453
|
+
export const transport = effectTransport({
|
|
445
454
|
Option: Schema.Option(Schema.Number),
|
|
446
455
|
Date: Schema.Date,
|
|
447
456
|
});
|
|
@@ -468,8 +477,11 @@ declare global {
|
|
|
468
477
|
}
|
|
469
478
|
|
|
470
479
|
// src/hooks.ts
|
|
471
|
-
import {
|
|
472
|
-
|
|
480
|
+
import {
|
|
481
|
+
transport as effectTransport,
|
|
482
|
+
responseHeadersTransporter,
|
|
483
|
+
} from "@thomasfosterau/effect-sveltekit";
|
|
484
|
+
export const transport = effectTransport({ ResponseHeaders: responseHeadersTransporter });
|
|
473
485
|
|
|
474
486
|
// src/hooks.server.ts
|
|
475
487
|
import { ResponseHeaders } from "@thomasfosterau/effect-sveltekit";
|
|
@@ -490,6 +502,14 @@ export const load = ({ locals }) => ({ headers: locals.headers });
|
|
|
490
502
|
handler effects; `ResponseHeaders` is the buffer for everything `setHeaders`
|
|
491
503
|
cannot do.)
|
|
492
504
|
|
|
505
|
+
Import the universal hook helpers by name, as above, rather than through the
|
|
506
|
+
`Hooks` namespace. `src/hooks.ts` runs on every page, and the published build
|
|
507
|
+
turns `Hooks` into a single object: `Hooks.transport` keeps `Hooks.reroute`
|
|
508
|
+
and the default universal runtime (with Effect's `HttpClient`, `Stream` and
|
|
509
|
+
`ManagedRuntime`) in the client bundle, while the named imports keep only the
|
|
510
|
+
transport helpers. The same holds for `Remote`, whose members are also root
|
|
511
|
+
exports (`callQuery`, `callCommand`, …).
|
|
512
|
+
|
|
493
513
|
### `$env` as an Effect `Config` source
|
|
494
514
|
|
|
495
515
|
Back Effect's `Config` with SvelteKit's environment, so app-layer services read
|
|
@@ -508,7 +528,9 @@ export const runtime = makeServerRuntime(Database.layer.pipe(Layer.provide(svelt
|
|
|
508
528
|
### SvelteKit hooks as Effects (`Hooks`)
|
|
509
529
|
|
|
510
530
|
Every SvelteKit hook has an explicit Effect wrapper, grouped into a `Hooks`
|
|
511
|
-
namespace per hook file (mirroring the auto-wrap table above)
|
|
531
|
+
namespace per hook file (mirroring the auto-wrap table above). The universal
|
|
532
|
+
members are also exported by name from the root entry; prefer those in
|
|
533
|
+
`src/hooks.ts` (see the `ResponseHeaders` recipe above for why):
|
|
512
534
|
|
|
513
535
|
| Import path | `Hooks` members | Runs on |
|
|
514
536
|
| ----------------------------------------- | ---------------------------------------------- | ------------------------------------------------ |
|
|
@@ -518,10 +540,10 @@ namespace per hook file (mirroring the auto-wrap table above):
|
|
|
518
540
|
|
|
519
541
|
```ts
|
|
520
542
|
// src/hooks.ts
|
|
521
|
-
import {
|
|
543
|
+
import { reroute as effectReroute } from "@thomasfosterau/effect-sveltekit";
|
|
522
544
|
import { Effect } from "effect";
|
|
523
545
|
|
|
524
|
-
export const reroute =
|
|
546
|
+
export const reroute = effectReroute((event) =>
|
|
525
547
|
Effect.succeed(event.url.pathname === "/old" ? "/new" : undefined),
|
|
526
548
|
);
|
|
527
549
|
```
|
package/dist/client.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { Navigation_d_exports } from "./Navigation.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { NavigationError, Navigation_d_exports, afterNavigate, beforeNavigate, goto, invalidate, invalidateAll, onNavigate, preloadCode, preloadData, refreshAll } from "./Navigation.js";
|
|
2
|
+
import { NavigatingSnapshot, PageSnapshot, UpdateCheckError } from "./internal/app-state.js";
|
|
3
|
+
import { CurrentPage, CurrentPageInterface, State_d_exports, checkForUpdate, navigating, page, updated } from "./State.js";
|
|
4
|
+
import { RemoteSubmit, Remote_d_exports, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates } from "./Remote.js";
|
|
4
5
|
import { RemoteQueryResult, useRemoteQuery } from "./remote-reactive.js";
|
|
5
|
-
import { realtime_d_exports } from "./realtime.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
6
|
+
import { EventSourceConstructor, EventSourceError, FromEventSourceOptions, FromWebSocketOptions, SseMessage, WebSocketConstructor, WebSocketError, fromEventSource, fromWebSocket, realtime_d_exports } from "./realtime.js";
|
|
7
|
+
import { EnhanceHandlers, EnhanceOptions, EnhanceOptionsArgs, EnhanceRuntime, ResultOptions, SubmitInput } from "./internal/enhance.js";
|
|
8
|
+
import { ApplyActionError, applyAction, deserialize, enhance, forms_d_exports } from "./forms.js";
|
|
9
|
+
import { Hooks_d_exports, handleError, init } from "./client/Hooks.js";
|
|
10
|
+
export { ApplyActionError, CurrentPage, type CurrentPageInterface, type EnhanceHandlers, type EnhanceOptions, type EnhanceOptionsArgs, type EnhanceRuntime, type EventSourceConstructor, EventSourceError, forms_d_exports as Forms, type FromEventSourceOptions, type FromWebSocketOptions, Hooks_d_exports as Hooks, type NavigatingSnapshot, Navigation_d_exports as Navigation, NavigationError, type PageSnapshot, realtime_d_exports as Realtime, Remote_d_exports as Remote, type RemoteQueryResult, type RemoteSubmit, type ResultOptions, type SseMessage, State_d_exports as State, type SubmitInput, UpdateCheckError, type WebSocketConstructor, WebSocketError, afterNavigate, applyAction, beforeNavigate, callCommand, callCommandWithUpdates, callPrerender, callQuery, checkForUpdate, deserialize, enhance, fromEventSource, fromWebSocket, goto, handleError, init, invalidate, invalidateAll, liveQueryStream, navigating, onNavigate, page, preloadCode, preloadData, refreshAll, submitForm, submitFormWithUpdates, updated, useRemoteQuery };
|
package/dist/client.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Remote_exports } from "./Remote.js";
|
|
2
|
-
import { Navigation_exports } from "./Navigation.js";
|
|
3
|
-
import {
|
|
1
|
+
import { Remote_exports, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates } from "./Remote.js";
|
|
2
|
+
import { NavigationError, Navigation_exports, afterNavigate, beforeNavigate, goto, invalidate, invalidateAll, onNavigate, preloadCode, preloadData, refreshAll } from "./Navigation.js";
|
|
3
|
+
import { UpdateCheckError } from "./internal/app-state.js";
|
|
4
|
+
import { CurrentPage, State_exports, checkForUpdate, navigating, page, updated } from "./State.js";
|
|
4
5
|
import { useRemoteQuery } from "./remote-reactive.js";
|
|
5
|
-
import { realtime_exports } from "./realtime.js";
|
|
6
|
-
import { forms_exports } from "./forms.js";
|
|
7
|
-
import { Hooks_exports } from "./client/Hooks.js";
|
|
8
|
-
export { forms_exports as Forms, Hooks_exports as Hooks, Navigation_exports as Navigation, realtime_exports as Realtime, Remote_exports as Remote, State_exports as State, useRemoteQuery };
|
|
6
|
+
import { EventSourceError, WebSocketError, fromEventSource, fromWebSocket, realtime_exports } from "./realtime.js";
|
|
7
|
+
import { ApplyActionError, applyAction, deserialize, enhance, forms_exports } from "./forms.js";
|
|
8
|
+
import { Hooks_exports, handleError, init } from "./client/Hooks.js";
|
|
9
|
+
export { ApplyActionError, CurrentPage, EventSourceError, forms_exports as Forms, Hooks_exports as Hooks, Navigation_exports as Navigation, NavigationError, realtime_exports as Realtime, Remote_exports as Remote, State_exports as State, UpdateCheckError, WebSocketError, afterNavigate, applyAction, beforeNavigate, callCommand, callCommandWithUpdates, callPrerender, callQuery, checkForUpdate, deserialize, enhance, fromEventSource, fromWebSocket, goto, handleError, init, invalidate, invalidateAll, liveQueryStream, navigating, onNavigate, page, preloadCode, preloadData, refreshAll, submitForm, submitFormWithUpdates, updated, useRemoteQuery };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Remote_d_exports } from "./Remote.js";
|
|
1
|
+
import { RemoteSubmit, Remote_d_exports, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates } from "./Remote.js";
|
|
2
2
|
import { SvelteKitServices, UniversalRuntime, makeUniversalRuntime } from "./app-runtime.js";
|
|
3
3
|
import { load } from "./universal.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { MarkerTransporterOptions, TransportEntry, markerTransporter, transport, transporter } from "./transport.js";
|
|
5
|
+
import { ResponseHeaders, responseHeadersTransporter } from "./response-headers.js";
|
|
6
|
+
import { Hooks_d_exports, reroute } from "./Hooks.js";
|
|
6
7
|
import { readConfig, sveltekitConfig, sveltekitConfigProvider } from "./config.js";
|
|
7
8
|
import { ApiClientOptions, apiClient } from "./api-client.js";
|
|
8
|
-
export { type ApiClientOptions, Hooks_d_exports as Hooks, Remote_d_exports as Remote, ResponseHeaders, type SvelteKitServices, type UniversalRuntime, apiClient, load, makeUniversalRuntime, readConfig, sveltekitConfig, sveltekitConfigProvider };
|
|
9
|
+
export { type ApiClientOptions, Hooks_d_exports as Hooks, type MarkerTransporterOptions, Remote_d_exports as Remote, type RemoteSubmit, ResponseHeaders, type SvelteKitServices, type TransportEntry, type UniversalRuntime, apiClient, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, load, makeUniversalRuntime, markerTransporter, readConfig, reroute, responseHeadersTransporter, submitForm, submitFormWithUpdates, sveltekitConfig, sveltekitConfigProvider, transport, transporter };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { makeUniversalRuntime } from "./app-runtime.js";
|
|
2
2
|
import { load } from "./universal.js";
|
|
3
|
-
import { Remote_exports } from "./Remote.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { Remote_exports, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, submitForm, submitFormWithUpdates } from "./Remote.js";
|
|
4
|
+
import { markerTransporter, transport, transporter } from "./transport.js";
|
|
5
|
+
import { ResponseHeaders, responseHeadersTransporter } from "./response-headers.js";
|
|
6
|
+
import { Hooks_exports, reroute } from "./Hooks.js";
|
|
6
7
|
import { readConfig, sveltekitConfig, sveltekitConfigProvider } from "./config.js";
|
|
7
8
|
import { apiClient } from "./api-client.js";
|
|
8
|
-
export { Hooks_exports as Hooks, Remote_exports as Remote, ResponseHeaders, apiClient, load, makeUniversalRuntime, readConfig, sveltekitConfig, sveltekitConfigProvider };
|
|
9
|
+
export { Hooks_exports as Hooks, Remote_exports as Remote, ResponseHeaders, apiClient, callCommand, callCommandWithUpdates, callPrerender, callQuery, liveQueryStream, load, makeUniversalRuntime, markerTransporter, readConfig, reroute, responseHeadersTransporter, submitForm, submitFormWithUpdates, sveltekitConfig, sveltekitConfigProvider, transport, transporter };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thomasfosterau/effect-sveltekit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Effect integration for SvelteKit: load/action/endpoint wrappers, remote functions, an effectKit() Vite plugin, and an Effect HTTP deployment adapter",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"effect",
|