svelte-effect-runtime 3.4.6 → 3.4.8
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/.dist/chunks/{client-CsVu54pU.js → client-D_DE2cFa.js} +11 -42
- package/.dist/chunks/{client-CsVu54pU.js.map → client-D_DE2cFa.js.map} +1 -1
- package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-BdvO4AAS.js} +2 -2
- package/.dist/chunks/{dispatcher-pHH4JcFR.js.map → dispatcher-BdvO4AAS.js.map} +1 -1
- package/.dist/chunks/{dispatcher-LtvFKYUp.js → dispatcher-NpL5xhWF.js} +3 -3
- package/.dist/chunks/{dispatcher-LtvFKYUp.js.map → dispatcher-NpL5xhWF.js.map} +1 -1
- package/.dist/chunks/{errors-Dcf0MVbq.js → errors-Bl3NVEez.js} +21 -3
- package/.dist/chunks/{errors-Dcf0MVbq.js.map → errors-Bl3NVEez.js.map} +1 -1
- package/.dist/chunks/live-DEmS7qpO.js +103 -0
- package/.dist/chunks/live-DEmS7qpO.js.map +1 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js +108 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +1 -0
- package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-BNNW2GDT.js} +3 -3
- package/.dist/chunks/{runtime-ekkMQ-wL.js.map → runtime-BNNW2GDT.js.map} +1 -1
- package/.dist/chunks/{transform-02e-RvXH.js → transform-C2fCVPL_.js} +173 -106
- package/.dist/chunks/transform-C2fCVPL_.js.map +1 -0
- package/.dist/chunks/{vite-Dkwdtbgj.js → vite-Dm3bXmR3.js} +12 -88
- package/.dist/chunks/vite-Dm3bXmR3.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +15 -0
- package/.dist/generators.d.ts +3 -1
- package/.dist/internal/generators.js +20 -3
- package/.dist/internal/generators.js.map +1 -0
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/live.d.ts +100 -0
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform/constants.d.ts +1 -0
- package/.dist/markup/transform/types.d.ts +1 -0
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +5 -2
- package/.dist/mod.js +5 -4
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client/query.d.ts +6 -16
- package/.dist/remote/client/types.d.ts +2 -11
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +1 -1
- package/.dist/runtime/transform.js +58 -27
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +2 -0
- package/.dist/script-transform/types.d.ts +8 -0
- package/.dist/server/effects.d.ts +7 -7
- package/.dist/server/index.d.ts +3 -1
- package/.dist/server/types.d.ts +25 -50
- package/.dist/server/wrappers.d.ts +2 -2
- package/.dist/server.d.ts +2 -2
- package/.dist/server.js +40 -65
- package/.dist/server.js.map +1 -1
- package/.dist/vite/remote-client.d.ts +24 -0
- package/.dist/vite.d.ts +8 -3
- package/.dist/vite.js +1 -1
- package/.dist/yieldable.d.ts +41 -0
- package/package.json +1 -1
- package/.dist/chunks/transform-02e-RvXH.js.map +0 -1
- package/.dist/chunks/vite-Dkwdtbgj.js.map +0 -1
|
@@ -1,6 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { o as EmptyStreamYieldError } from "../chunks/errors-Bl3NVEez.js";
|
|
2
|
+
import { i as Code } from "../chunks/dispatcher-BdvO4AAS.js";
|
|
3
|
+
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-NpL5xhWF.js";
|
|
3
4
|
import { value } from "../markup/value.js";
|
|
4
5
|
import { promise } from "../markup/promise.js";
|
|
5
6
|
import { run } from "../markup/run.js";
|
|
6
|
-
|
|
7
|
+
import { Effect, Option, Stream } from "effect";
|
|
8
|
+
//#region src/yieldable.ts
|
|
9
|
+
function ToEffect(value) {
|
|
10
|
+
if (Stream.isStream(value)) return Stream.runHead(value).pipe(Effect.flatMap((option) => {
|
|
11
|
+
if (Option.isSome(option)) return Effect.succeed(option.value);
|
|
12
|
+
return Effect.fail(new EmptyStreamYieldError());
|
|
13
|
+
}));
|
|
14
|
+
if (is_generator_result(value)) return Effect.gen(() => value);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
function is_generator_result(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && typeof value.next === "function";
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { Code, Dispatcher, ToEffect, get_dispatcher, promise, run, value };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=generators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/yieldable.ts"],"sourcesContent":["import { EmptyStreamYieldError } from \"$/errors.ts\";\nimport { Effect, Option, Stream } from \"effect\";\n\n/**\n * Values generated `yield*` positions can normalize into an Effect.\n *\n * @example\n * ```ts\n * const value: Yieldable<number> = Stream.make(1);\n * ```\n *\n * @since 3.4.8\n */\nexport type Yieldable<A = unknown, E = unknown, R = unknown> =\n\t| Effect.Effect<A, E, R>\n\t| Effect.gen.Return<A, E, R>\n\t| Stream.Stream<A, E, R>;\n\n/**\n * Success type produced when generated code yields an Effect or a Stream.\n *\n * @example\n * ```ts\n * type User = YieldSuccess<ReturnType<typeof loadUser>>;\n * ```\n *\n * @since 3.4.8\n */\nexport type YieldSuccess<Value> = Value extends Stream.Stream<infer A, unknown, unknown>\n\t? A\n\t: Value extends Effect.Effect<infer A, unknown, unknown>\n\t\t? A\n\t\t: Value extends Effect.gen.Return<infer A, unknown, unknown>\n\t\t\t? A\n\t\t\t: never;\n\n/**\n * Normalizes generated `yield*` operands into Effects.\n *\n * @example\n * ```ts\n * const first = yield* ToEffect(Stream.make(\"ready\"));\n * ```\n *\n * @since 3.4.8\n * @param value - Effect, generator return object, or Stream emitted from a\n * lowered component `yield*` expression.\n * @returns An Effect that resolves with the original Effect success value or\n * the first Stream emission.\n * @internal\n */\nexport function ToEffect<A, E, R>(\n\tvalue: Effect.Effect<A, E, R> | Effect.gen.Return<A, E, R>,\n): Effect.Effect<A, E, R>;\nexport function ToEffect<A, E, R>(\n\tvalue: Stream.Stream<A, E, R>,\n): Effect.Effect<A, E | EmptyStreamYieldError, R>;\nexport function ToEffect<A, E, R>(\n\tvalue: Yieldable<A, E, R>,\n): Effect.Effect<A, E | EmptyStreamYieldError, R> {\n\tif (Stream.isStream(value)) {\n\t\treturn Stream.runHead(value).pipe(\n\t\t\tEffect.flatMap((option) => {\n\t\t\t\tif (Option.isSome(option)) {\n\t\t\t\t\treturn Effect.succeed(option.value);\n\t\t\t\t}\n\n\t\t\t\treturn Effect.fail(new EmptyStreamYieldError());\n\t\t\t}),\n\t\t);\n\t}\n\n\tif (is_generator_result<A, E, R>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nfunction is_generator_result<A, E, R>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, E, R> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n"],"mappings":";;;;;;;;AAyDA,SAAgB,SACf,OACiD;CACjD,IAAI,OAAO,SAAS,KAAK,GACxB,OAAO,OAAO,QAAQ,KAAK,CAAC,CAAC,KAC5B,OAAO,SAAS,WAAW;EAC1B,IAAI,OAAO,OAAO,MAAM,GACvB,OAAO,OAAO,QAAQ,OAAO,KAAK;EAGnC,OAAO,OAAO,KAAK,IAAI,sBAAsB,CAAC;CAC/C,CAAC,CACF;CAGD,IAAI,oBAA6B,KAAK,GACrC,OAAO,OAAO,UAAU,KAAK;CAG9B,OAAO;AACR;AAEA,SAAS,oBACR,OACsC;CACtC,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-D_DE2cFa.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
|
package/.dist/live.d.ts
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Effect, Stream } from "effect";
|
|
2
|
+
import type { RemoteFailure } from "./remote/shared.js";
|
|
3
|
+
/**
|
|
4
|
+
* Runtime marker attached to remote live streams created by SER.
|
|
5
|
+
*
|
|
6
|
+
* @since 3.4.8
|
|
7
|
+
*/
|
|
8
|
+
export declare const REMOTE_LIVE_STREAM: unique symbol;
|
|
9
|
+
type RemoteLivePipe<A, E> = {
|
|
10
|
+
(): RemoteLiveStream<A, E>;
|
|
11
|
+
<B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => Stream.Stream<B, RemoteFailure<E>, never>): RemoteLiveStream<B, E>;
|
|
12
|
+
<B>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B): B;
|
|
13
|
+
<B, C>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C): C;
|
|
14
|
+
<B, C, D>(ab: (_: Stream.Stream<A, RemoteFailure<E>, never>) => B, bc: (_: B) => C, cd: (_: C) => D): D;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Stream returned by `Query.live` remote functions.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* const Time = GetTime();
|
|
22
|
+
* const Label = Time.pipe(Stream.map((time) => time.toISOString()));
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @since 3.4.8
|
|
26
|
+
*/
|
|
27
|
+
export type RemoteLiveStream<A, E = never> = Omit<Stream.Stream<A, RemoteFailure<E>, never>, "pipe"> & {
|
|
28
|
+
readonly [REMOTE_LIVE_STREAM]: true;
|
|
29
|
+
readonly pipe: RemoteLivePipe<A, E>;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Transport state exposed separately from the data stream.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const Status = Live.status(GetTime());
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @since 3.4.8
|
|
40
|
+
*/
|
|
41
|
+
export type LiveStatus = {
|
|
42
|
+
readonly _tag: "Idle";
|
|
43
|
+
} | {
|
|
44
|
+
readonly _tag: "Connecting";
|
|
45
|
+
} | {
|
|
46
|
+
readonly _tag: "Open";
|
|
47
|
+
} | {
|
|
48
|
+
readonly _tag: "Failed";
|
|
49
|
+
readonly cause: unknown;
|
|
50
|
+
} | {
|
|
51
|
+
readonly _tag: "Closed";
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Public live stream control helpers.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* yield* Live.reconnect(GetNotifications());
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* @since 3.4.8
|
|
62
|
+
*/
|
|
63
|
+
export interface LiveFactory {
|
|
64
|
+
/**
|
|
65
|
+
* Creates a stream of transport status updates for a remote live stream.
|
|
66
|
+
*
|
|
67
|
+
* @param stream - Remote live stream whose transport status should be read.
|
|
68
|
+
* @returns A stream of transport status snapshots.
|
|
69
|
+
*/
|
|
70
|
+
status<A, E>(stream: RemoteLiveStream<A, E>): Stream.Stream<LiveStatus, never, never>;
|
|
71
|
+
/**
|
|
72
|
+
* Reconnects the transport behind a remote live stream.
|
|
73
|
+
*
|
|
74
|
+
* @param stream - Remote live stream whose transport should reconnect.
|
|
75
|
+
* @returns An Effect that completes after the reconnect request is sent.
|
|
76
|
+
*/
|
|
77
|
+
reconnect<A, E>(stream: RemoteLiveStream<A, E>): Effect.Effect<void, RemoteFailure<E>, never>;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Builds a remote live stream from SvelteKit's native live resource.
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```ts
|
|
84
|
+
* const stream = make_remote_live_stream(resource, normalize_native_error);
|
|
85
|
+
* ```
|
|
86
|
+
*
|
|
87
|
+
* @since 3.4.8
|
|
88
|
+
* @param resource - Native SvelteKit live query resource.
|
|
89
|
+
* @param on_error - Error mapper used for stream and reconnect failures.
|
|
90
|
+
* @returns A remote live stream carrying hidden transport metadata.
|
|
91
|
+
* @internal
|
|
92
|
+
*/
|
|
93
|
+
export declare function make_remote_live_stream<A, ErrorType = never>(resource: unknown, on_error: (error: unknown) => RemoteFailure<ErrorType>): RemoteLiveStream<A, ErrorType>;
|
|
94
|
+
/**
|
|
95
|
+
* Remote live transport helpers.
|
|
96
|
+
*
|
|
97
|
+
* @since 3.4.8
|
|
98
|
+
*/
|
|
99
|
+
export declare const Live: LiveFactory;
|
|
100
|
+
export {};
|
package/.dist/markup/promise.js
CHANGED
package/.dist/markup/run.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as transform_markup_effect } from "../chunks/transform-
|
|
1
|
+
import { t as transform_markup_effect } from "../chunks/transform-C2fCVPL_.js";
|
|
2
2
|
export { transform_markup_effect };
|
package/.dist/markup/value.js
CHANGED
package/.dist/mod.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export declare const Form: FormFactory;
|
|
|
125
125
|
* @since 2.0.0
|
|
126
126
|
*/
|
|
127
127
|
export declare const Prerender: PrerenderFactory;
|
|
128
|
+
export { Live } from "./live.js";
|
|
128
129
|
/**
|
|
129
130
|
* SvelteKit redirect control-flow export for `.remote.ts` files imported from
|
|
130
131
|
* the root entrypoint. The Vite plugin rewrites it to the real server
|
|
@@ -171,11 +172,13 @@ export declare const RequestEvent: Context.Reference<RequestEventShape>;
|
|
|
171
172
|
export declare const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never>;
|
|
172
173
|
/** Re-export error types users need for typed catch handlers. */
|
|
173
174
|
export type { FormError, FormIssue, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./remote/shared.js";
|
|
174
|
-
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, } from "./errors.js";
|
|
175
|
+
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, EmptyStreamYieldError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, } from "./errors.js";
|
|
175
176
|
export { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, } from "./remote/shared.js";
|
|
176
177
|
/** Re-export app setup helpers so users can import them from root. */
|
|
177
178
|
export { effect, type EffectOptions } from "./vite.js";
|
|
178
179
|
/** Re-export server helper types from the root entrypoint. */
|
|
179
180
|
export type { ErrorBody, ErrorEffectFactory, ErrorProperties, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectOptions, RedirectStatus, RedirectStatusName, } from "./server/control-flow.js";
|
|
180
181
|
/** Re-export server helper types from the root entrypoint. */
|
|
181
|
-
export type {
|
|
182
|
+
export type { LiveFactory, LiveStatus, RemoteLiveStream } from "./live.js";
|
|
183
|
+
/** Re-export server helper types from the root entrypoint. */
|
|
184
|
+
export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, RemoteLiveSource, SchemaEncodedInput, SchemaInput, ServerRuntimeFactory, StandardSchema, StandardSchemaInput, StandardSchemaOutput, } from "./server/types.js";
|
package/.dist/mod.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { A as
|
|
2
|
-
import { t as Dispatcher } from "./chunks/dispatcher-
|
|
1
|
+
import { A as VitePreTransformPluginConflictError, C as UncheckedFormHandlerMissingError, D as UnknownRuntimeError, E as UncheckedQueryHandlerMissingError, O as UnsupportedMarkupEffectPositionError, S as UncheckedCommandHandlerMissingError, T as UncheckedPrerenderHandlerMissingError, _ as RequestEventUnavailableError, a as DispatcherDisposedError, b as ServerOnlyImportError, c as InvalidLiveQueryFactoryError, d as InvalidRemoteFormResponseError, f as PreprocessError, g as RemoteHelperError, h as RemoteHelperContextError, i as BatchQueryHandlerMissingError, j as YieldStarInEventCallbackError, k as UnsupportedRemoteFormResponseError, l as InvalidLiveQueryReturnError, m as RemoteFormEndpointMissingError, n as AsyncEffectInSyncRuneError, o as EmptyStreamYieldError, p as RemoteErrorDecodeError, r as AwaitInEffectWorkError, s as InvalidCommandFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidQueryFactoryError, v as RuntimeAlreadyInitializedError, w as UncheckedLiveQueryHandlerMissingError, x as SvelteKitServerExportUnavailableError, y as RuntimeError } from "./chunks/errors-Bl3NVEez.js";
|
|
2
|
+
import { t as Dispatcher } from "./chunks/dispatcher-BdvO4AAS.js";
|
|
3
|
+
import { t as Live } from "./chunks/live-DEmS7qpO.js";
|
|
3
4
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
4
|
-
import { t as effect } from "./chunks/vite-
|
|
5
|
+
import { t as effect } from "./chunks/vite-Dm3bXmR3.js";
|
|
5
6
|
//#region src/mod.ts
|
|
6
7
|
/**
|
|
7
8
|
* Public API surface for `svelte-effect-runtime`.
|
|
@@ -191,6 +192,6 @@ function make_server_only_error(name) {
|
|
|
191
192
|
return new ServerOnlyImportError(name);
|
|
192
193
|
}
|
|
193
194
|
//#endregion
|
|
194
|
-
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
|
|
195
|
+
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, EmptyStreamYieldError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, Live, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
|
|
195
196
|
|
|
196
197
|
//# sourceMappingURL=mod.js.map
|
package/.dist/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnknownRuntimeError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tVitePreTransformPluginConflictError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteLiveQueryResource,\n\tEffectRemoteLiveSource,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAgBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAoGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnknownRuntimeError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tVitePreTransformPluginConflictError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAuGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { EffectRemoteQueryUpdateBrand } from "./types.js";
|
|
2
2
|
import type { RemoteFailure } from "../shared.js";
|
|
3
|
+
import { type RemoteLiveStream } from "../../live.js";
|
|
3
4
|
import { Effect } from "effect";
|
|
4
5
|
type RemoteInput<Input> = undefined extends Input ? Input | void : Input;
|
|
5
6
|
type DecodePayload<Output> = (value: unknown) => Output;
|
|
@@ -17,16 +18,6 @@ type RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output,
|
|
|
17
18
|
readonly set: (value: Output) => void;
|
|
18
19
|
readonly withOverride: (update: (current: Output) => Output) => unknown;
|
|
19
20
|
};
|
|
20
|
-
type RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<RemoteLiveQueryResource<Output>, RemoteFailure<ErrorType>>;
|
|
21
|
-
type RemoteLiveQueryResource<Output> = {
|
|
22
|
-
readonly connected: boolean;
|
|
23
|
-
readonly current: Output | undefined;
|
|
24
|
-
readonly done: boolean;
|
|
25
|
-
readonly error: unknown;
|
|
26
|
-
readonly loading: boolean;
|
|
27
|
-
readonly ready: boolean;
|
|
28
|
-
readonly reconnect: () => Effect.Effect<void, unknown, never>;
|
|
29
|
-
} & AsyncIterable<Output>;
|
|
30
21
|
/**
|
|
31
22
|
* Creates a remote query adapter. The returned function takes input and
|
|
32
23
|
* returns an `Effect` that executes SvelteKit's native query function.
|
|
@@ -49,14 +40,13 @@ export declare function create_remote_query_adapter<Input, Output, ErrorType = n
|
|
|
49
40
|
export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
|
|
50
41
|
/**
|
|
51
42
|
* Creates a remote live query adapter. The returned function takes input and
|
|
52
|
-
* returns an
|
|
53
|
-
* and reconnect controls.
|
|
43
|
+
* returns an Effect Stream whose transport state is exposed through `Live`.
|
|
54
44
|
*
|
|
55
45
|
* @example
|
|
56
46
|
* ```ts
|
|
57
47
|
* const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
|
|
58
|
-
* const time =
|
|
59
|
-
* const
|
|
48
|
+
* const time = getTime();
|
|
49
|
+
* const first = yield* Stream.runHead(time);
|
|
60
50
|
* ```
|
|
61
51
|
*
|
|
62
52
|
* @since 2.0.0
|
|
@@ -64,8 +54,8 @@ export declare function create_remote_query_adapter<Input, Output, ErrorType = n
|
|
|
64
54
|
* @param _decode_payload - Deprecated payload decoder retained for parity with
|
|
65
55
|
* other remote adapters.
|
|
66
56
|
* @param _base - Deprecated transport base retained for compatibility.
|
|
67
|
-
* @returns A function returning
|
|
57
|
+
* @returns A function returning a remote live stream.
|
|
68
58
|
* @internal
|
|
69
59
|
*/
|
|
70
|
-
export declare function create_remote_live_query_adapter<Input, Output, ErrorType = never>(native_factory: unknown, _decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) =>
|
|
60
|
+
export declare function create_remote_live_query_adapter<Input, Output, ErrorType = never>(native_factory: unknown, _decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);
|
|
71
61
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { RemoteForm, RemoteFormInput, RemoteLiveQuery, RemoteQuery, RemoteQueryOverride } from "@sveltejs/kit";
|
|
2
2
|
import type { RemoteFailure } from "../shared.js";
|
|
3
|
-
import type { Effect } from "effect";
|
|
3
|
+
import type { Effect, Stream } from "effect";
|
|
4
4
|
/**
|
|
5
5
|
* Type-only marker attached to SER query and live-query adapter functions so
|
|
6
6
|
* form updates can distinguish them from command adapters.
|
|
@@ -31,21 +31,12 @@ type EffectRemoteQueryUpdates<Updates extends readonly unknown[]> = Updates & {
|
|
|
31
31
|
};
|
|
32
32
|
type NativeRemoteQueryUpdate = RemoteQuery<unknown> | RemoteLiveQuery<unknown> | RemoteQueryOverride;
|
|
33
33
|
type EffectRemoteQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => EffectRemoteQueryUpdateResource);
|
|
34
|
-
type EffectRemoteLiveQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) =>
|
|
34
|
+
type EffectRemoteLiveQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => Stream.Stream<unknown, unknown, unknown>);
|
|
35
35
|
type EffectRemoteQueryUpdateResource = Effect.Effect<unknown, unknown> & {
|
|
36
36
|
readonly refresh: () => Effect.Effect<void, unknown, never>;
|
|
37
37
|
readonly set: (value: never) => void;
|
|
38
38
|
readonly withOverride: (update: (current: never) => unknown) => unknown;
|
|
39
39
|
};
|
|
40
|
-
type EffectRemoteLiveQueryUpdateResource = {
|
|
41
|
-
readonly connected: boolean;
|
|
42
|
-
readonly current: unknown;
|
|
43
|
-
readonly done: boolean;
|
|
44
|
-
readonly error: unknown;
|
|
45
|
-
readonly loading: boolean;
|
|
46
|
-
readonly ready: boolean;
|
|
47
|
-
readonly reconnect: () => Effect.Effect<void, unknown, never>;
|
|
48
|
-
} & AsyncIterable<unknown>;
|
|
49
40
|
/**
|
|
50
41
|
* Represents a pending operation counter that remote command adapters
|
|
51
42
|
* use to track in-flight requests.
|
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-D_DE2cFa.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { g as RemoteHelperError, h as RemoteHelperContextError } from "../chunks/errors-Bl3NVEez.js";
|
|
2
2
|
import { create_serialized_remote_failure_envelope } from "./shared.js";
|
|
3
3
|
import { Cause, Effect, Exit } from "effect";
|
|
4
4
|
import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as
|
|
1
|
+
import { f as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-Bl3NVEez.js";
|
|
2
|
+
import { a as slice_start, c as contains_top_level_await, d as collect_top_level_binding_names, f as has_local_import_binding, i as slice, l as find_yield_star_node, n as validate_rune_yield_usage, o as collect_free_identifiers, p as make_imports, r as create_source_map, s as collect_yield_star_nodes, t as transform_markup_effect, u as is_yield_star_expression } from "../chunks/transform-C2fCVPL_.js";
|
|
3
3
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
4
|
-
import MagicString from "magic-string";
|
|
5
4
|
import ts from "typescript";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
6
|
//#region src/script-transform/runtime-block.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds the runtime blocks appended to lowered script effect code with
|
|
@@ -58,7 +58,7 @@ function lower_statement(stmt, content, context) {
|
|
|
58
58
|
return {
|
|
59
59
|
temps: [],
|
|
60
60
|
rewritten_text: "",
|
|
61
|
-
effect_blocks: [make_effect_block([
|
|
61
|
+
effect_blocks: [make_effect_block([wrap_yield_stars_in_node(stmt, content, context)], collect_deps(text))],
|
|
62
62
|
range: {
|
|
63
63
|
start: stmt.getFullStart(),
|
|
64
64
|
end: stmt.end
|
|
@@ -109,7 +109,7 @@ function lower_expression_statement(stmt, content, context) {
|
|
|
109
109
|
return {
|
|
110
110
|
temps: [],
|
|
111
111
|
rewritten_text: "",
|
|
112
|
-
effect_blocks: [make_effect_block([text + ";"], collect_deps(text))],
|
|
112
|
+
effect_blocks: [make_effect_block([wrap_yield_text(text, context) + ";"], collect_deps(text))],
|
|
113
113
|
range: {
|
|
114
114
|
start: stmt.getFullStart(),
|
|
115
115
|
end: stmt.end
|
|
@@ -124,7 +124,7 @@ function lower_expression_statement(stmt, content, context) {
|
|
|
124
124
|
return {
|
|
125
125
|
temps: [],
|
|
126
126
|
rewritten_text: "",
|
|
127
|
-
effect_blocks: [make_effect_block([`${target} = ${yield_text};`], collect_deps(yield_text, target_names))],
|
|
127
|
+
effect_blocks: [make_effect_block([`${target} = ${wrap_yield_text(yield_text, context)};`], collect_deps(yield_text, target_names))],
|
|
128
128
|
range: {
|
|
129
129
|
start: stmt.getStart(),
|
|
130
130
|
end: stmt.end
|
|
@@ -185,7 +185,7 @@ function lower_expression_yields(expr, content, hint, context) {
|
|
|
185
185
|
type: type_helper.type
|
|
186
186
|
});
|
|
187
187
|
} else temps.push({ name: temp_name });
|
|
188
|
-
statements.push(`${temp_name} = ${yield_text};`);
|
|
188
|
+
statements.push(`${temp_name} = ${wrap_yield_text(yield_text, context)};`);
|
|
189
189
|
deps.push(...collect_deps(yield_text));
|
|
190
190
|
replacements.push({
|
|
191
191
|
start: node.getStart(),
|
|
@@ -238,7 +238,7 @@ function make_awaited_yield_expression(node, content, hint, context) {
|
|
|
238
238
|
const helper_id = make_script_effect_id(node, context);
|
|
239
239
|
const deps_text = `[${collect_deps(yield_text).join(", ")}]`;
|
|
240
240
|
return {
|
|
241
|
-
declaration: `function* ${helper_name}() { return (${yield_text}); }`,
|
|
241
|
+
declaration: `function* ${helper_name}() { return (${wrap_yield_text(yield_text, context)}); }`,
|
|
242
242
|
expression: [
|
|
243
243
|
`await ${context.dispatcher_name}().promise({`,
|
|
244
244
|
`id: ${JSON.stringify(helper_id)}, `,
|
|
@@ -253,11 +253,30 @@ function make_yield_type_helper(yield_text, hint, context) {
|
|
|
253
253
|
const helper_name = context.next_type_helper_name(hint);
|
|
254
254
|
return {
|
|
255
255
|
declaration: `function ${helper_name}() { return (${strip_yield_star(yield_text)}); }`,
|
|
256
|
-
type: `${context.
|
|
256
|
+
type: `${context.yield_success_name}<ReturnType<typeof ${helper_name}>> | undefined`
|
|
257
257
|
};
|
|
258
258
|
}
|
|
259
259
|
function strip_yield_star(yield_text) {
|
|
260
|
-
return yield_text.replace(/^yield
|
|
260
|
+
return yield_text.replace(/^yield\s*\*\s*/, "");
|
|
261
|
+
}
|
|
262
|
+
function wrap_yield_text(yield_text, context) {
|
|
263
|
+
return `yield* ${context.yieldable_name}(${strip_yield_star(yield_text)})`;
|
|
264
|
+
}
|
|
265
|
+
function wrap_yield_stars_in_node(node, content, context) {
|
|
266
|
+
const replacements = [];
|
|
267
|
+
collect_yield_star_nodes(node, (yield_node) => {
|
|
268
|
+
const yield_text = slice_start(content, yield_node).trim();
|
|
269
|
+
replacements.push({
|
|
270
|
+
start: yield_node.getStart(),
|
|
271
|
+
end: yield_node.end,
|
|
272
|
+
text: wrap_yield_text(yield_text, context)
|
|
273
|
+
});
|
|
274
|
+
});
|
|
275
|
+
replacements.sort((a, b) => b.start - a.start);
|
|
276
|
+
const offset = node.getFullStart();
|
|
277
|
+
let text = slice(content, node);
|
|
278
|
+
for (const replacement of replacements) text = text.slice(0, replacement.start - offset) + replacement.text + text.slice(replacement.end - offset);
|
|
279
|
+
return text.trim();
|
|
261
280
|
}
|
|
262
281
|
function make_script_effect_id(expr, context) {
|
|
263
282
|
return `${context.filename}:${expr.getStart()}:${expr.end}`;
|
|
@@ -341,7 +360,7 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
341
360
|
const emit_types = options.emit_types ?? true;
|
|
342
361
|
let has_effect = false;
|
|
343
362
|
let uses_dispatcher_promise = false;
|
|
344
|
-
let
|
|
363
|
+
let uses_yield_success_types = false;
|
|
345
364
|
/** Phase 1: detect imports already provided by the user. */
|
|
346
365
|
const has_effect_import = has_local_import_binding(source_file, "effect", "Effect");
|
|
347
366
|
const has_dispatcher_import = has_local_import_binding(source_file, "svelte-effect-runtime/internal/generators", "get_dispatcher");
|
|
@@ -353,13 +372,17 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
353
372
|
dispatcher_value: name_allocator.reserve("__SER___dispatcher"),
|
|
354
373
|
effect: has_effect_import ? "Effect" : reserve_runtime_import("Effect"),
|
|
355
374
|
program: name_allocator.reserve("__SER___program"),
|
|
356
|
-
untrack: has_untrack_import ? "untrack" : reserve_runtime_import("untrack")
|
|
375
|
+
untrack: has_untrack_import ? "untrack" : reserve_runtime_import("untrack"),
|
|
376
|
+
yield_success: reserve_runtime_import("YieldSuccess"),
|
|
377
|
+
yieldable: reserve_runtime_import("ToEffect")
|
|
357
378
|
};
|
|
358
379
|
const context = {
|
|
359
380
|
filename,
|
|
360
381
|
dispatcher_name: runtime_bindings.dispatcher,
|
|
361
382
|
effect_name: runtime_bindings.effect,
|
|
362
383
|
emit_types,
|
|
384
|
+
yield_success_name: runtime_bindings.yield_success,
|
|
385
|
+
yieldable_name: runtime_bindings.yieldable,
|
|
363
386
|
next_helper_name(hint) {
|
|
364
387
|
return name_allocator.reserve(make_generated_name(hint ?? "helper", ""));
|
|
365
388
|
},
|
|
@@ -389,7 +412,7 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
389
412
|
}
|
|
390
413
|
effect_blocks.push(...lowered.effect_blocks);
|
|
391
414
|
uses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;
|
|
392
|
-
|
|
415
|
+
uses_yield_success_types ||= lowered.temps.some((temp) => temp.type?.includes(runtime_bindings.yield_success) ?? false);
|
|
393
416
|
}
|
|
394
417
|
if (!has_effect) {
|
|
395
418
|
block_refs.push({
|
|
@@ -404,8 +427,10 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
404
427
|
/** Phase 3: inject runtime imports after the last user import. */
|
|
405
428
|
const imports = make_imports(has_effect_import, has_dispatcher_import, has_untrack_import, runtime_bindings, {
|
|
406
429
|
needs_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,
|
|
407
|
-
needs_effect: effect_blocks.length > 0
|
|
408
|
-
needs_untrack: effect_blocks.length > 0
|
|
430
|
+
needs_effect: effect_blocks.length > 0,
|
|
431
|
+
needs_untrack: effect_blocks.length > 0,
|
|
432
|
+
needs_yield_success: uses_yield_success_types,
|
|
433
|
+
needs_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise
|
|
409
434
|
});
|
|
410
435
|
const last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);
|
|
411
436
|
if (imports) if (last_import) magic.appendRight(last_import.end, "\n" + imports);
|
|
@@ -424,20 +449,22 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
424
449
|
code,
|
|
425
450
|
blocks: block_refs,
|
|
426
451
|
map: create_source_map(magic, filename),
|
|
427
|
-
relocations: create_script_relocations(content, code, source_file)
|
|
452
|
+
relocations: create_script_relocations(content, code, source_file, runtime_bindings.yieldable)
|
|
428
453
|
};
|
|
429
454
|
}
|
|
430
|
-
function create_script_relocations(content, code, source_file) {
|
|
455
|
+
function create_script_relocations(content, code, source_file, yieldable_name) {
|
|
431
456
|
const candidates = source_file.statements.flatMap((stmt) => {
|
|
432
457
|
const relocations = [];
|
|
433
458
|
if (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) for (const decl of stmt.declarationList.declarations) collect_binding_relocation_candidates(decl.name, relocations);
|
|
434
459
|
collect_yield_star_nodes(stmt, (node) => {
|
|
435
|
-
const
|
|
460
|
+
const expression = ts.isBinaryExpression(node) ? node.right : node;
|
|
461
|
+
const text = content.slice(expression.getStart(), expression.end).trim();
|
|
436
462
|
relocations.push({
|
|
437
|
-
originalStart:
|
|
438
|
-
originalEnd:
|
|
463
|
+
originalStart: expression.getStart(),
|
|
464
|
+
originalEnd: expression.end,
|
|
439
465
|
text,
|
|
440
|
-
match: "
|
|
466
|
+
match: "yield_operand",
|
|
467
|
+
wrapper: `${yieldable_name}(${text})`
|
|
441
468
|
});
|
|
442
469
|
});
|
|
443
470
|
return relocations;
|
|
@@ -477,13 +504,17 @@ function collect_binding_relocation_candidates(name, candidates) {
|
|
|
477
504
|
function find_available_generated_text(code, candidate, used_ranges) {
|
|
478
505
|
let search_start = 0;
|
|
479
506
|
while (search_start < code.length) {
|
|
480
|
-
const
|
|
507
|
+
const search_text = candidate.match === "yield_operand" ? candidate.wrapper : candidate.text;
|
|
508
|
+
if (!search_text) return -1;
|
|
509
|
+
const index = code.indexOf(search_text, search_start);
|
|
481
510
|
if (index < 0) return -1;
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
const
|
|
485
|
-
|
|
486
|
-
|
|
511
|
+
const operand_offset = candidate.match === "yield_operand" && candidate.wrapper ? candidate.wrapper.indexOf(candidate.text) : 0;
|
|
512
|
+
const start = index + Math.max(operand_offset, 0);
|
|
513
|
+
const end = start + candidate.text.length;
|
|
514
|
+
const overlaps_used_range = used_ranges.some((range) => start < range.end && end > range.start);
|
|
515
|
+
const is_text_match = candidate.match !== "identifier" || is_identifier_text_match(code, start, end);
|
|
516
|
+
if (!overlaps_used_range && is_text_match) return start;
|
|
517
|
+
search_start = candidate.match === "identifier" ? index + 1 : index + search_text.length;
|
|
487
518
|
}
|
|
488
519
|
return -1;
|
|
489
520
|
}
|