svelte-effect-runtime 1.6.2 → 2.0.0-beta.1
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-BeOE81fW.js +577 -0
- package/.dist/chunks/client-BeOE81fW.js.map +1 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
- package/.dist/chunks/transform-BtlxgJrg.js +836 -0
- package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
- package/.dist/detect.d.ts +34 -0
- package/.dist/detect.js +56 -0
- package/.dist/detect.js.map +1 -0
- package/.dist/dispatcher/deps.d.ts +14 -0
- package/.dist/dispatcher/fibers.d.ts +52 -0
- package/.dist/dispatcher/index.d.ts +138 -0
- package/.dist/dispatcher/types.d.ts +63 -0
- package/.dist/dispatcher.d.ts +2 -0
- package/.dist/dispatcher.js +2 -0
- package/.dist/error.d.ts +77 -0
- package/.dist/generators.d.ts +16 -0
- package/.dist/internal/descriptors.d.ts +17 -0
- package/.dist/internal/generators.d.ts +6 -0
- package/.dist/internal/generators.js +5 -0
- package/.dist/internal/remote-client.d.ts +6 -0
- package/.dist/internal/remote-client.js +2 -0
- package/.dist/internal/remote-server.d.ts +6 -0
- package/.dist/internal/remote-server.js +2 -0
- package/.dist/markup/promise.d.ts +15 -0
- package/.dist/markup/promise.js +26 -0
- package/.dist/markup/promise.js.map +1 -0
- package/.dist/markup/run.d.ts +12 -0
- package/.dist/markup/run.js +21 -0
- package/.dist/markup/run.js.map +1 -0
- package/.dist/markup/transform/apply.d.ts +6 -0
- package/.dist/markup/transform/classify.d.ts +15 -0
- package/.dist/markup/transform/constants.d.ts +5 -0
- package/.dist/markup/transform/emit.d.ts +12 -0
- package/.dist/markup/transform/expressions.d.ts +39 -0
- package/.dist/markup/transform/index.d.ts +19 -0
- package/.dist/markup/transform/scan.d.ts +8 -0
- package/.dist/markup/transform/types.d.ts +64 -0
- package/.dist/markup/transform.d.ts +1 -0
- package/.dist/markup/transform.js +2 -0
- package/.dist/markup/value.d.ts +20 -0
- package/.dist/markup/value.js +32 -0
- package/.dist/markup/value.js.map +1 -0
- package/.dist/mod.d.ts +186 -0
- package/.dist/mod.js +190 -0
- package/.dist/mod.js.map +1 -0
- package/.dist/preprocess/ast.d.ts +51 -0
- package/.dist/preprocess/imports.d.ts +22 -0
- package/.dist/preprocess/index.d.ts +21 -0
- package/.dist/preprocess/lower.d.ts +12 -0
- package/.dist/preprocess/runtime-block.d.ts +8 -0
- package/.dist/preprocess/source.d.ts +29 -0
- package/.dist/preprocess/types.d.ts +70 -0
- package/.dist/preprocess.d.ts +2 -0
- package/.dist/preprocess.js +3 -0
- package/.dist/remote/client/command.d.ts +17 -0
- package/.dist/remote/client/effect.d.ts +15 -0
- package/.dist/remote/client/failures.d.ts +57 -0
- package/.dist/remote/client/form-data.d.ts +8 -0
- package/.dist/remote/client/form-enhance.d.ts +9 -0
- package/.dist/remote/client/form-transport.d.ts +20 -0
- package/.dist/remote/client/form.d.ts +21 -0
- package/.dist/remote/client/index.d.ts +4 -0
- package/.dist/remote/client/query-result.d.ts +14 -0
- package/.dist/remote/client/query.d.ts +57 -0
- package/.dist/remote/client/responses.d.ts +28 -0
- package/.dist/remote/client/types.d.ts +83 -0
- package/.dist/remote/client/utils.d.ts +11 -0
- package/.dist/remote/client.d.ts +2 -0
- package/.dist/remote/client.js +2 -0
- package/.dist/remote/server.d.ts +66 -0
- package/.dist/remote/server.js +104 -0
- package/.dist/remote/server.js.map +1 -0
- package/.dist/remote/shared.d.ts +202 -0
- package/.dist/remote/shared.js +161 -0
- package/.dist/remote/shared.js.map +1 -0
- package/.dist/runtime/preprocess.d.ts +38 -0
- package/.dist/runtime/preprocess.js +54 -0
- package/.dist/runtime/preprocess.js.map +1 -0
- package/.dist/server/effects.d.ts +49 -0
- package/.dist/server/factories.d.ts +97 -0
- package/.dist/server/index.d.ts +3 -0
- package/.dist/server/invalid.d.ts +9 -0
- package/.dist/server/runtime.d.ts +66 -0
- package/.dist/server/schema.d.ts +42 -0
- package/.dist/server/types.d.ts +271 -0
- package/.dist/server/wrappers.d.ts +45 -0
- package/.dist/server.d.ts +2 -0
- package/.dist/server.js +527 -0
- package/.dist/server.js.map +1 -0
- package/.dist/vite.d.ts +42 -0
- package/.dist/vite.js +118 -0
- package/.dist/vite.js.map +1 -0
- package/README.md +2 -0
- package/package.json +66 -101
- package/dist/chunks/client-vV6UAwoP.js +0 -199
- package/dist/chunks/client-vV6UAwoP.js.map +0 -1
- package/dist/chunks/effect-Crj3S8Cg.js +0 -51
- package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
- package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
- package/dist/chunks/markup-CkPUZIJt.js +0 -13390
- package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
- package/dist/chunks/preprocess-BFePqOC6.js +0 -49
- package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
- package/dist/chunks/server-Dea1CJuY.js +0 -704
- package/dist/chunks/server-Dea1CJuY.js.map +0 -1
- package/dist/chunks/v3-D0c0MKPf.js +0 -1
- package/dist/chunks/v4-MMhHmzIG.js +0 -1
- package/dist/chunks/vite-BlUTKv2u.js +0 -152
- package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -2
- package/dist/effect.d.ts +0 -1
- package/dist/effect.js +0 -2
- package/dist/internal/app-server-shim.d.ts +0 -8
- package/dist/internal/effect-compat.d.ts +0 -21
- package/dist/internal/markup.d.ts +0 -11
- package/dist/internal/markup.js +0 -2
- package/dist/internal/remote-client.d.ts +0 -36
- package/dist/internal/remote-client.js +0 -527
- package/dist/internal/remote-client.js.map +0 -1
- package/dist/internal/remote-shared.d.ts +0 -186
- package/dist/internal/remote-shared.js +0 -122
- package/dist/internal/remote-shared.js.map +0 -1
- package/dist/internal/transform.d.ts +0 -18
- package/dist/internal/transform.js +0 -418
- package/dist/internal/transform.js.map +0 -1
- package/dist/language-server.d.ts +0 -9
- package/dist/language-server.js +0 -4
- package/dist/mod.d.ts +0 -22
- package/dist/mod.js +0 -3
- package/dist/preprocess.d.ts +0 -29
- package/dist/preprocess.js +0 -20
- package/dist/preprocess.js.map +0 -1
- package/dist/root-node.d.ts +0 -1
- package/dist/root-node.js +0 -63
- package/dist/root-node.js.map +0 -1
- package/dist/server.d.ts +0 -81
- package/dist/server.js +0 -85
- package/dist/server.js.map +0 -1
- package/dist/v3/client.d.ts +0 -117
- package/dist/v3/effect.d.ts +0 -17
- package/dist/v3/mod.d.ts +0 -27
- package/dist/v3/preprocess.d.ts +0 -28
- package/dist/v3/root-node.d.ts +0 -59
- package/dist/v3/server.d.ts +0 -297
- package/dist/v3/vite.d.ts +0 -46
- package/dist/v4/client.d.ts +0 -2
- package/dist/v4/effect.d.ts +0 -24
- package/dist/v4/effect.js +0 -19
- package/dist/v4/effect.js.map +0 -1
- package/dist/v4/mod.d.ts +0 -27
- package/dist/v4/mod.js +0 -3
- package/dist/v4/preprocess.d.ts +0 -34
- package/dist/v4/preprocess.js +0 -32
- package/dist/v4/preprocess.js.map +0 -1
- package/dist/v4/root-node.d.ts +0 -59
- package/dist/v4/root-node.js +0 -4
- package/dist/v4/server.d.ts +0 -340
- package/dist/v4/server.js +0 -71
- package/dist/v4/server.js.map +0 -1
- package/dist/v4/vite.d.ts +0 -34
- package/dist/v4/vite.js +0 -31
- package/dist/v4/vite.js.map +0 -1
- package/dist/vite.d.ts +0 -31
- package/dist/vite.js +0 -24
- package/dist/vite.js.map +0 -1
package/.dist/mod.js
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { t as Dispatcher } from "./chunks/dispatcher-BSg2-ttN.js";
|
|
2
|
+
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
3
|
+
import { effect } from "./vite.js";
|
|
4
|
+
//#region src/mod.ts
|
|
5
|
+
/**
|
|
6
|
+
* Public API surface for `svelte-effect-runtime`.
|
|
7
|
+
*
|
|
8
|
+
* Call {@link ClientRuntime.make} in `hooks.client.ts`, call
|
|
9
|
+
* {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin
|
|
10
|
+
* route server-only helpers to the server entrypoint automatically.
|
|
11
|
+
*
|
|
12
|
+
* @module
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once
|
|
16
|
+
* in `hooks.client.ts` to provide services to every component's effect
|
|
17
|
+
* blocks.
|
|
18
|
+
*
|
|
19
|
+
* If never called, a default empty-layer runtime is created lazily on
|
|
20
|
+
* the first `yield*` expression.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { ClientRuntime } from "svelte-effect-runtime";
|
|
25
|
+
* import { Db } from "./db.ts";
|
|
26
|
+
*
|
|
27
|
+
* ClientRuntime.make(Db.Live);
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @since 2.0.0
|
|
31
|
+
*/
|
|
32
|
+
var ClientRuntime = class {
|
|
33
|
+
/**
|
|
34
|
+
* Build and cache the client-side dispatcher runtime.
|
|
35
|
+
*
|
|
36
|
+
* @since 2.0.0
|
|
37
|
+
* @param layer - Optional Effect layer to provide to the runtime.
|
|
38
|
+
*/
|
|
39
|
+
static make(layer) {
|
|
40
|
+
Dispatcher.make(layer);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
/**
|
|
44
|
+
* Server-side runtime singleton export. In SvelteKit server files the Vite
|
|
45
|
+
* plugin rewrites root imports to `svelte-effect-runtime/server`, so this
|
|
46
|
+
* name resolves to the real server implementation before it is evaluated.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { ServerRuntime } from "svelte-effect-runtime";
|
|
51
|
+
*
|
|
52
|
+
* ServerRuntime.make();
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @since 2.0.0
|
|
56
|
+
*/
|
|
57
|
+
const ServerRuntime = make_server_only_class("ServerRuntime");
|
|
58
|
+
/**
|
|
59
|
+
* Remote query factory export for `.remote.ts` files imported from the root
|
|
60
|
+
* entrypoint. The Vite plugin rewrites it to the real server implementation.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* import { Query } from "svelte-effect-runtime";
|
|
65
|
+
*
|
|
66
|
+
* export const GetPosts = Query(Effect.succeed([]));
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @since 2.0.0
|
|
70
|
+
*/
|
|
71
|
+
const Query = Object.assign(make_server_only_function("Query"), {
|
|
72
|
+
batch: make_server_only_function("Query.batch"),
|
|
73
|
+
live: make_server_only_function("Query.live")
|
|
74
|
+
});
|
|
75
|
+
/**
|
|
76
|
+
* Remote command factory export for `.remote.ts` files imported from the root
|
|
77
|
+
* entrypoint. The Vite plugin rewrites it to the real server implementation.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* import { Command } from "svelte-effect-runtime";
|
|
82
|
+
*
|
|
83
|
+
* export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @since 2.0.0
|
|
87
|
+
*/
|
|
88
|
+
const Command = make_server_only_function("Command");
|
|
89
|
+
/**
|
|
90
|
+
* Remote form factory export for `.remote.ts` files imported from the root
|
|
91
|
+
* entrypoint. The Vite plugin rewrites it to the real server implementation.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { Form } from "svelte-effect-runtime";
|
|
96
|
+
*
|
|
97
|
+
* export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));
|
|
98
|
+
* ```
|
|
99
|
+
*
|
|
100
|
+
* @since 2.0.0
|
|
101
|
+
*/
|
|
102
|
+
const Form = make_server_only_function("Form");
|
|
103
|
+
/**
|
|
104
|
+
* Remote prerender factory export for `.remote.ts` files imported from the
|
|
105
|
+
* root entrypoint. The Vite plugin rewrites it to the real server
|
|
106
|
+
* implementation.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* import { Prerender } from "svelte-effect-runtime";
|
|
111
|
+
*
|
|
112
|
+
* export const GetBuildInfo = Prerender(() => Effect.succeed("ready"));
|
|
113
|
+
* ```
|
|
114
|
+
*
|
|
115
|
+
* @since 2.0.0
|
|
116
|
+
*/
|
|
117
|
+
const Prerender = make_server_only_function("Prerender");
|
|
118
|
+
/**
|
|
119
|
+
* Current SvelteKit request event service export for `.remote.ts` files
|
|
120
|
+
* imported from the root entrypoint. The Vite plugin rewrites it to the real
|
|
121
|
+
* server implementation.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* ```ts
|
|
125
|
+
* import { RequestEvent } from "svelte-effect-runtime";
|
|
126
|
+
*
|
|
127
|
+
* const event = yield* RequestEvent;
|
|
128
|
+
* ```
|
|
129
|
+
*
|
|
130
|
+
* @since 2.0.0
|
|
131
|
+
*/
|
|
132
|
+
const RequestEvent = make_server_only_function("RequestEvent");
|
|
133
|
+
/**
|
|
134
|
+
* Returns the active server runtime when imported from a server file. The Vite
|
|
135
|
+
* plugin rewrites root imports to the real server implementation.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { get_server_runtime_or_throw } from "svelte-effect-runtime";
|
|
140
|
+
*
|
|
141
|
+
* const runtime = get_server_runtime_or_throw();
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @since 2.0.0
|
|
145
|
+
*/
|
|
146
|
+
const get_server_runtime_or_throw = make_server_only_function("get_server_runtime_or_throw");
|
|
147
|
+
/**
|
|
148
|
+
* Creates the Svelte preprocessor that lowers script and markup `yield*`
|
|
149
|
+
* expressions. The heavy transform module is loaded lazily so browser imports
|
|
150
|
+
* from the package root stay client-safe.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```js
|
|
154
|
+
* import { preprocess } from "svelte-effect-runtime";
|
|
155
|
+
*
|
|
156
|
+
* export default {
|
|
157
|
+
* preprocess: [preprocess()],
|
|
158
|
+
* };
|
|
159
|
+
* ```
|
|
160
|
+
*
|
|
161
|
+
* @since 2.0.0
|
|
162
|
+
* @returns A Svelte preprocessor group with an async markup hook.
|
|
163
|
+
*/
|
|
164
|
+
function preprocess() {
|
|
165
|
+
return {
|
|
166
|
+
name: "svelte-effect-runtime",
|
|
167
|
+
async markup(options) {
|
|
168
|
+
return await (await import("./runtime/preprocess.js")).preprocess().markup(options);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
function make_server_only_class(name) {
|
|
173
|
+
return class ServerOnlyRuntime {
|
|
174
|
+
static make() {
|
|
175
|
+
throw make_server_only_error(name);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
function make_server_only_function(name) {
|
|
180
|
+
return (..._args) => {
|
|
181
|
+
throw make_server_only_error(name);
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
function make_server_only_error(name) {
|
|
185
|
+
return /* @__PURE__ */ new Error(`${name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to \`svelte-effect-runtime/server\` before evaluation.`);
|
|
186
|
+
}
|
|
187
|
+
//#endregion
|
|
188
|
+
export { ClientRuntime, Command, Form, Prerender, Query, RequestEvent, ServerRuntime, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, preprocess };
|
|
189
|
+
|
|
190
|
+
//# sourceMappingURL=mod.js.map
|
package/.dist/mod.js.map
ADDED
|
@@ -0,0 +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 type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Result returned by the root Svelte markup preprocessor hook.\n *\n * @since 2.0.0\n */\ninterface MarkupResult {\n code: string;\n}\n\n/**\n * Root preprocessor group shape. The root export keeps transform code lazy so\n * client imports do not pull parser-only dependencies into the browser.\n *\n * @since 2.0.0\n */\ninterface PreprocessGroup {\n name: string;\n markup(\n options: { content: string; filename: string },\n ): MarkupResult | Promise<MarkupResult>;\n}\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 /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\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(\n \"ServerRuntime\",\n) 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(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\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(\n \"Command\",\n) 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(\n \"Form\",\n) 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(\n \"Prerender\",\n) 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> =\n make_server_only_function(\"RequestEvent\") 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<\n unknown,\n never\n> = make_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 FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_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 EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormInvalid,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteLiveHandler,\n RemoteFormHandler,\n RemoteHandler,\n SchemaInput,\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n ServerRuntimeFactory,\n StandardSchema,\n} from \"$/server/types.ts\";\n\n/**\n * Creates the Svelte preprocessor that lowers script and markup `yield*`\n * expressions. The heavy transform module is loaded lazily so browser imports\n * from the package root stay client-safe.\n *\n * @example\n * ```js\n * import { preprocess } from \"svelte-effect-runtime\";\n *\n * export default {\n * preprocess: [preprocess()],\n * };\n * ```\n *\n * @since 2.0.0\n * @returns A Svelte preprocessor group with an async markup hook.\n */\nexport function preprocess(): PreprocessGroup {\n return {\n name: \"svelte-effect-runtime\",\n\n async markup(options: { content: string; filename: string }) {\n const runtime = await import(\"./runtime/preprocess.ts\");\n const group = runtime.preprocess();\n\n return await group.markup(options);\n },\n };\n}\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): Error {\n return new Error(\n `${name} is only available in SvelteKit server files. ` +\n `Ensure the SER Vite plugin is enabled so root imports are rewritten ` +\n `to \\`svelte-effect-runtime/server\\` before evaluation.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;AACnD,aAAmB,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkBlC,MAAa,gBAAsC,uBACjD,gBACD;;;;;;;;;;;;;;AAeD,MAAa,QAAsB,OAAO,OACxC,0BAA0B,QAAQ,EAClC;CACE,OAAO,0BAA0B,cAAc;CAC/C,MAAM,0BAA0B,aAAa;CAC9C,CACF;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BACrC,UACD;;;;;;;;;;;;;;AAeD,MAAa,OAAoB,0BAC/B,OACD;;;;;;;;;;;;;;;AAgBD,MAAa,YAA8B,0BACzC,YACD;;;;;;;;;;;;;;;AAgBD,MAAa,eACX,0BAA0B,eAAe;;;;;;;;;;;;;;AAe3C,MAAa,8BAGT,0BAA0B,8BAA8B;;;;;;;;;;;;;;;;;;AAmE5D,SAAgB,aAA8B;AAC5C,QAAO;EACL,MAAM;EAEN,MAAM,OAAO,SAAgD;AAI3D,UAAO,OAHS,MAAM,OAAO,4BACP,YAAY,CAEf,OAAO,QAAQ;;EAErC;;AAGH,SAAS,uBAAuB,MAAuB;AACrD,QAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;AACnB,SAAM,uBAAuB,KAAK;;;;AAKxC,SAAS,0BAA0B,MAA6C;AAC9E,SAAQ,GAAG,UAA4B;AACrC,QAAM,uBAAuB,KAAK;;;AAItC,SAAS,uBAAuB,MAAqB;AACnD,wBAAO,IAAI,MACT,GAAG,KAAK,0KAGT"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Checks whether a node is a `yield*` binary expression.
|
|
4
|
+
*
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @param node - TypeScript AST node to check.
|
|
7
|
+
* @returns Whether the node represents `yield * operand`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function is_yield_star_expression(node: ts.Node): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Checks whether a node owns its own yield semantics.
|
|
12
|
+
*
|
|
13
|
+
* @since 2.0.0
|
|
14
|
+
* @param node - TypeScript AST node to check.
|
|
15
|
+
* @returns Whether traversal should stop at this function boundary.
|
|
16
|
+
*/
|
|
17
|
+
export declare function is_function_boundary_node(node: ts.Node): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Returns `true` if the node tree contains a top-level `await`.
|
|
20
|
+
*
|
|
21
|
+
* @since 2.0.0
|
|
22
|
+
* @param node - Root node to search.
|
|
23
|
+
* @returns Whether a top-level await expression was found.
|
|
24
|
+
*/
|
|
25
|
+
export declare function contains_top_level_await(node: ts.Node): boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Collects top-level `yield*` nodes under an expression.
|
|
28
|
+
*
|
|
29
|
+
* @since 2.0.0
|
|
30
|
+
* @param node - Root node to search.
|
|
31
|
+
* @param on_found - Callback invoked for each matching yield node.
|
|
32
|
+
* @returns Nothing.
|
|
33
|
+
*/
|
|
34
|
+
export declare function collect_yield_star_nodes(node: ts.Node, on_found: (node: ts.Node) => void): void;
|
|
35
|
+
/**
|
|
36
|
+
* Finds the first top-level `yield*` expression below a node.
|
|
37
|
+
*
|
|
38
|
+
* @since 2.0.0
|
|
39
|
+
* @param node - Root node to search.
|
|
40
|
+
* @param on_found - Callback invoked with the first matching node.
|
|
41
|
+
* @returns Nothing.
|
|
42
|
+
*/
|
|
43
|
+
export declare function find_yield_star_node(node: ts.Node, on_found: (node: ts.Node) => void): void;
|
|
44
|
+
/**
|
|
45
|
+
* Extracts identifier names from a TypeScript binding name.
|
|
46
|
+
*
|
|
47
|
+
* @since 2.0.0
|
|
48
|
+
* @param name - Binding name node to flatten.
|
|
49
|
+
* @returns Identifier names from identifiers and destructuring patterns.
|
|
50
|
+
*/
|
|
51
|
+
export declare function extract_binding_names(name: ts.BindingName): string[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
/**
|
|
3
|
+
* Builds the import statements injected by the script preprocessor.
|
|
4
|
+
*
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @param has_effect_import - Whether the user already imports `Effect`.
|
|
7
|
+
* @param has_onmount_import - Whether the user already imports `onMount`.
|
|
8
|
+
* @param has_dispatcher_import - Whether the user already imports
|
|
9
|
+
* `get_dispatcher`.
|
|
10
|
+
* @returns Newline-separated import statements to inject.
|
|
11
|
+
*/
|
|
12
|
+
export declare function make_imports(has_effect_import: boolean, has_onmount_import: boolean, has_dispatcher_import: boolean): string;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether a source file imports a local binding from a module.
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
* @param source_file - Parsed TypeScript source file to inspect.
|
|
18
|
+
* @param module_name - Module specifier to match.
|
|
19
|
+
* @param local_name - Local binding name to look for.
|
|
20
|
+
* @returns Whether that binding is already locally available.
|
|
21
|
+
*/
|
|
22
|
+
export declare function has_local_import_binding(source_file: ts.SourceFile, module_name: string, local_name: string): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ScriptTransformResult } from "./types.js";
|
|
2
|
+
export type { BlockRef, ScriptTransformResult } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Transforms a `<script effect>` body by extracting top-level `yield*`
|
|
5
|
+
* expressions into `$state` temp bindings and wrapping the lowered
|
|
6
|
+
* assignments in an `Effect.gen` block that runs on mount.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const result = transform_script_effect(
|
|
11
|
+
* `let user = $state(yield* getUser(id));`,
|
|
12
|
+
* "App.svelte",
|
|
13
|
+
* );
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
* @param content - The raw `<script effect>` body content.
|
|
18
|
+
* @param filename - The source filename, used in error messages.
|
|
19
|
+
* @returns The transformed code and any block references.
|
|
20
|
+
*/
|
|
21
|
+
export declare function transform_script_effect(content: string, filename: string): ScriptTransformResult;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ts from "typescript";
|
|
2
|
+
import type { LoweredStatement, ScriptLoweringContext } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Delegates a statement to the correct lowerer based on syntax kind.
|
|
5
|
+
*
|
|
6
|
+
* @since 2.0.0
|
|
7
|
+
* @param stmt - Statement to lower.
|
|
8
|
+
* @param content - Original source text.
|
|
9
|
+
* @param context - Lowering services for this transform pass.
|
|
10
|
+
* @returns Lowered statement descriptor.
|
|
11
|
+
*/
|
|
12
|
+
export declare function lower_statement(stmt: ts.Statement, content: string, context: ScriptLoweringContext): LoweredStatement;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the runtime block appended to lowered script effect code.
|
|
3
|
+
*
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @param assignments - Effect-body assignment strings.
|
|
6
|
+
* @returns Full `Effect.gen` plus `onMount` block.
|
|
7
|
+
*/
|
|
8
|
+
export declare function make_runtime_block(assignments: string[]): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type MagicString from "magic-string";
|
|
2
|
+
import type ts from "typescript";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a source map from transformed script back to the original block.
|
|
5
|
+
*
|
|
6
|
+
* @since 2.0.0
|
|
7
|
+
* @param magic - MagicString instance holding the transformed source.
|
|
8
|
+
* @param filename - Source filename used for the source map entry.
|
|
9
|
+
* @returns A plain source map object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function create_source_map(magic: MagicString, filename: string): Record<string, unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Slices a substring matching a node's full source range.
|
|
14
|
+
*
|
|
15
|
+
* @since 2.0.0
|
|
16
|
+
* @param content - Original source text.
|
|
17
|
+
* @param node - AST node whose full range should be extracted.
|
|
18
|
+
* @returns Source text including leading trivia.
|
|
19
|
+
*/
|
|
20
|
+
export declare function slice(content: string, node: ts.Node): string;
|
|
21
|
+
/**
|
|
22
|
+
* Slices a substring matching a node's source range without leading trivia.
|
|
23
|
+
*
|
|
24
|
+
* @since 2.0.0
|
|
25
|
+
* @param content - Original source text.
|
|
26
|
+
* @param node - AST node whose non-trivia range should be extracted.
|
|
27
|
+
* @returns Source text excluding leading trivia.
|
|
28
|
+
*/
|
|
29
|
+
export declare function slice_start(content: string, node: ts.Node): string;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Block reference emitted by the preprocessor to track what blocks were
|
|
3
|
+
* generated in a given file.
|
|
4
|
+
*
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
*/
|
|
7
|
+
export interface BlockRef {
|
|
8
|
+
/** Stable identifier for this block, used for cache lookups. */
|
|
9
|
+
id: string;
|
|
10
|
+
/** What kind of block was emitted. */
|
|
11
|
+
kind: "value" | "promise" | "run" | "script";
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Result of the script preprocessor pass.
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
*/
|
|
18
|
+
export interface ScriptTransformResult {
|
|
19
|
+
/** The transformed source code. */
|
|
20
|
+
code: string;
|
|
21
|
+
/** Block references emitted during transformation. */
|
|
22
|
+
blocks: BlockRef[];
|
|
23
|
+
/** Source map from transformed code back to the original script block. */
|
|
24
|
+
map?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Internal descriptor for a single `$state` temp variable that will be
|
|
28
|
+
* emitted at component scope before the rewritten statement.
|
|
29
|
+
*
|
|
30
|
+
* @since 2.0.0
|
|
31
|
+
*/
|
|
32
|
+
export interface TempBinding {
|
|
33
|
+
name: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Describes how a single statement was lowered.
|
|
37
|
+
*
|
|
38
|
+
* @since 2.0.0
|
|
39
|
+
*/
|
|
40
|
+
export interface LoweredStatement {
|
|
41
|
+
/** `$state` bindings to emit at component scope. */
|
|
42
|
+
temps: TempBinding[];
|
|
43
|
+
/** The rewritten statement text with yield* replaced by temp refs. */
|
|
44
|
+
rewritten_text: string;
|
|
45
|
+
/** The assignments to emit in the effect body (includes `yield*`). */
|
|
46
|
+
effect_assignments: string[];
|
|
47
|
+
/** Original statement range to replace in the source. */
|
|
48
|
+
range: {
|
|
49
|
+
start: number;
|
|
50
|
+
end: number;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Describes how a single expression was lowered.
|
|
55
|
+
*
|
|
56
|
+
* @since 2.0.0
|
|
57
|
+
*/
|
|
58
|
+
export interface LoweredExpression {
|
|
59
|
+
temps: TempBinding[];
|
|
60
|
+
rewritten_expr: string;
|
|
61
|
+
effect_assignments: string[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Stateful services used while lowering one script block.
|
|
65
|
+
*
|
|
66
|
+
* @since 2.0.0
|
|
67
|
+
*/
|
|
68
|
+
export interface ScriptLoweringContext {
|
|
69
|
+
next_temp_name(hint?: string): string;
|
|
70
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RemoteFailure } from "../shared.js";
|
|
2
|
+
import type { Effect } from "effect";
|
|
3
|
+
import type { Pending } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a remote command adapter. The adapter preserves the native
|
|
6
|
+
* pending getter and turns each invocation into an Effect.
|
|
7
|
+
*
|
|
8
|
+
* @since 2.0.0
|
|
9
|
+
* @param native_factory - SvelteKit's native command function or a legacy
|
|
10
|
+
* response factory used by tests.
|
|
11
|
+
* @param decode_payload - Function to decode the response payload.
|
|
12
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
13
|
+
* @param pending - Optional pending counter for legacy response factories.
|
|
14
|
+
* @returns A function returning an Effect of the response.
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export declare function create_remote_command_adapter<Input, Output>(native_factory: unknown, decode_payload: (value: unknown) => unknown, _base?: string, pending?: Pending): (input: Input) => Effect.Effect<Output, RemoteFailure<unknown>>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { RemoteFailure } from "../shared.js";
|
|
2
|
+
import { Effect } from "effect";
|
|
3
|
+
/**
|
|
4
|
+
* Wraps a promise-producing remote operation in an Effect with failure mapping.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const program = make_effect_from_promise(() => native_remote(input));
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @since 2.0.0
|
|
12
|
+
* @param run - Promise-producing operation that invokes a native remote helper.
|
|
13
|
+
* @returns Effect that maps thrown values into remote failures.
|
|
14
|
+
*/
|
|
15
|
+
export declare function make_effect_from_promise<Output>(run: () => Promise<Output>): Effect.Effect<Output, RemoteFailure<unknown>>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { FormIssue, RemoteFailure } from "../shared.js";
|
|
2
|
+
/**
|
|
3
|
+
* Decodes a raw wire value into a remote failure when it uses the runtime
|
|
4
|
+
* failure envelope.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const failure = decode_remote_error(body);
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* @since 2.0.0
|
|
12
|
+
* @param raw - Raw value received from the network or SvelteKit error body.
|
|
13
|
+
* @param decode - Optional devalue decoder for custom error payloads.
|
|
14
|
+
* @returns The decoded failure/value, or a transport error when decoding fails.
|
|
15
|
+
*/
|
|
16
|
+
export declare function decode_remote_error(raw: unknown, decode?: (encoded: string) => unknown): RemoteFailure<unknown> | unknown;
|
|
17
|
+
/**
|
|
18
|
+
* Checks whether a decoded value is a tagged remote failure.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* if (is_decoded_remote_failure(value)) throw value;
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @since 2.0.0
|
|
26
|
+
* @param value - Value to inspect.
|
|
27
|
+
* @returns Whether the value carries a `_tag` discriminator.
|
|
28
|
+
*/
|
|
29
|
+
export declare function is_decoded_remote_failure(value: unknown): value is RemoteFailure<unknown>;
|
|
30
|
+
/**
|
|
31
|
+
* Checks whether a response body represents SvelteKit validation issues.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```ts
|
|
35
|
+
* if (is_validation_body(body)) return body.issues;
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @since 2.0.0
|
|
39
|
+
* @param value - Value to inspect.
|
|
40
|
+
* @returns Whether the value contains a form issue list.
|
|
41
|
+
*/
|
|
42
|
+
export declare function is_validation_body(value: unknown): value is {
|
|
43
|
+
issues: readonly FormIssue[];
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Normalizes native thrown values into the runtime's remote failure model.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const failure = normalize_native_error(error);
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @since 2.0.0
|
|
54
|
+
* @param error - Unknown value thrown by a native remote helper.
|
|
55
|
+
* @returns A typed remote failure.
|
|
56
|
+
*/
|
|
57
|
+
export declare function normalize_native_error(error: unknown): RemoteFailure<unknown>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encodes remote form input into SvelteKit-compatible form data.
|
|
3
|
+
*
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @param input - Input value supplied to the remote form.
|
|
6
|
+
* @returns FormData payload for the remote endpoint.
|
|
7
|
+
*/
|
|
8
|
+
export declare function to_form_data(input: unknown): FormData;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { NativeMethod } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps a remote form enhance callback so Effect return values are run.
|
|
4
|
+
*
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @param callback - Native enhance callback to wrap.
|
|
7
|
+
* @returns Wrapped callback or undefined.
|
|
8
|
+
*/
|
|
9
|
+
export declare function wrap_enhance_callback(callback: NativeMethod | undefined): NativeMethod | undefined;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { NativeFormRecord } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Submits a native remote form through the SvelteKit remote endpoint.
|
|
4
|
+
*
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @param form_obj - Native form object being adapted.
|
|
7
|
+
* @param input - Form input value.
|
|
8
|
+
* @param decode_payload - Function to decode successful payloads.
|
|
9
|
+
* @param remote_base - Base URL for the remote endpoint.
|
|
10
|
+
* @returns Decoded form output.
|
|
11
|
+
*/
|
|
12
|
+
export declare function submit_remote_form<Output>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string): Promise<Output>;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts SvelteKit's remote action id from a native form action URL.
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
* @param form_obj - Native form object being adapted.
|
|
18
|
+
* @returns Remote action id when present.
|
|
19
|
+
*/
|
|
20
|
+
export declare function get_remote_action_id(form_obj: NativeFormRecord): string | undefined;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { RemoteFormInput } from "@sveltejs/kit";
|
|
2
|
+
import type { EffectRemoteForm } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a remote form adapter. The callable preserves SvelteKit's native
|
|
5
|
+
* form descriptors while wrapping `validate`, `enhance`, and programmatic
|
|
6
|
+
* submission in Effect-returning APIs.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const createPost = create_remote_form_adapter(nativeForm, (value) => value);
|
|
11
|
+
* yield* createPost.validate({ includeUntouched: true });
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* @since 2.0.0
|
|
15
|
+
* @param native_factory - SvelteKit's native form object.
|
|
16
|
+
* @param decode_payload - Function to decode the response payload.
|
|
17
|
+
* @param remote_base - Base URL for SvelteKit's remote endpoint.
|
|
18
|
+
* @returns A callable form function whose properties mirror the native form.
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string): EffectRemoteForm<Input, Output>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { create_remote_command_adapter } from "./command.js";
|
|
2
|
+
export { create_remote_form_adapter } from "./form.js";
|
|
3
|
+
export { create_remote_live_query_adapter, create_remote_query_adapter, } from "./query.js";
|
|
4
|
+
export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormSubmit, Pending, } from "./types.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves native query results, including SvelteKit run handles.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* const output = await resolve_query_result(result, decode_payload);
|
|
7
|
+
* ```
|
|
8
|
+
*
|
|
9
|
+
* @since 2.0.0
|
|
10
|
+
* @param value - Native query result or query run handle.
|
|
11
|
+
* @param decode_payload - Function used to decode successful payloads.
|
|
12
|
+
* @returns Decoded query output.
|
|
13
|
+
*/
|
|
14
|
+
export declare function resolve_query_result<Output>(value: unknown, decode_payload: (value: unknown) => unknown): Promise<Output>;
|