svelte-effect-runtime 1.6.1 → 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-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/effect-zCli5qgO.js +0 -51
- package/dist/chunks/effect-zCli5qgO.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-D4zJP7U1.js +0 -13383
- package/dist/chunks/markup-D4zJP7U1.js.map +0 -1
- package/dist/chunks/preprocess-DIC5iR0_.js +0 -49
- package/dist/chunks/preprocess-DIC5iR0_.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-Bm2RdiT3.js +0 -152
- package/dist/chunks/vite-Bm2RdiT3.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
|
@@ -0,0 +1,577 @@
|
|
|
1
|
+
import { n as get_dispatcher } from "./dispatcher-BSg2-ttN.js";
|
|
2
|
+
import { create_remote_http_error, create_remote_transport_error, create_remote_validation_error, is_serialized_remote_failure_envelope } from "../remote/shared.js";
|
|
3
|
+
import { t as copy_property_descriptors } from "./descriptors-CU2g4U_i.js";
|
|
4
|
+
import { Effect } from "effect";
|
|
5
|
+
import { parse } from "devalue";
|
|
6
|
+
//#region src/remote/client/failures.ts
|
|
7
|
+
/**
|
|
8
|
+
* Decodes a raw wire value into a remote failure when it uses the runtime
|
|
9
|
+
* failure envelope.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* const failure = decode_remote_error(body);
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @since 2.0.0
|
|
17
|
+
* @param raw - Raw value received from the network or SvelteKit error body.
|
|
18
|
+
* @param decode - Optional devalue decoder for custom error payloads.
|
|
19
|
+
* @returns The decoded failure/value, or a transport error when decoding fails.
|
|
20
|
+
*/
|
|
21
|
+
function decode_remote_error(raw, decode) {
|
|
22
|
+
const embedded = parse_embedded_remote_failure(raw);
|
|
23
|
+
if (embedded !== raw) return decode_remote_error(embedded, decode);
|
|
24
|
+
if (is_serialized_remote_failure_envelope(raw)) try {
|
|
25
|
+
return decode ? decode(raw.encoded) : parse(raw.encoded);
|
|
26
|
+
} catch {
|
|
27
|
+
return create_remote_transport_error(/* @__PURE__ */ new Error("Failed to decode remote error payload"), raw);
|
|
28
|
+
}
|
|
29
|
+
return raw;
|
|
30
|
+
}
|
|
31
|
+
function parse_embedded_remote_failure(raw) {
|
|
32
|
+
if (typeof raw === "string") return parse_json_or_original(raw);
|
|
33
|
+
if (typeof raw !== "object" || raw === null || !("message" in raw)) return raw;
|
|
34
|
+
const message = raw.message;
|
|
35
|
+
if (typeof message !== "string") return raw;
|
|
36
|
+
const parsed = parse_json_or_original(message);
|
|
37
|
+
return parsed === message ? raw : parsed;
|
|
38
|
+
}
|
|
39
|
+
function parse_json_or_original(value) {
|
|
40
|
+
try {
|
|
41
|
+
return JSON.parse(value);
|
|
42
|
+
} catch {
|
|
43
|
+
return value;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Checks whether a decoded value is a tagged remote failure.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* if (is_decoded_remote_failure(value)) throw value;
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* @since 2.0.0
|
|
55
|
+
* @param value - Value to inspect.
|
|
56
|
+
* @returns Whether the value carries a `_tag` discriminator.
|
|
57
|
+
*/
|
|
58
|
+
function is_decoded_remote_failure(value) {
|
|
59
|
+
return typeof value === "object" && value !== null && "_tag" in value;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Checks whether a response body represents SvelteKit validation issues.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* if (is_validation_body(body)) return body.issues;
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* @since 2.0.0
|
|
70
|
+
* @param value - Value to inspect.
|
|
71
|
+
* @returns Whether the value contains a form issue list.
|
|
72
|
+
*/
|
|
73
|
+
function is_validation_body(value) {
|
|
74
|
+
return typeof value === "object" && value !== null && Array.isArray(value.issues);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Normalizes native thrown values into the runtime's remote failure model.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* ```ts
|
|
81
|
+
* const failure = normalize_native_error(error);
|
|
82
|
+
* ```
|
|
83
|
+
*
|
|
84
|
+
* @since 2.0.0
|
|
85
|
+
* @param error - Unknown value thrown by a native remote helper.
|
|
86
|
+
* @returns A typed remote failure.
|
|
87
|
+
*/
|
|
88
|
+
function normalize_native_error(error) {
|
|
89
|
+
const body = get_error_body(error);
|
|
90
|
+
const decoded = decode_remote_error(body);
|
|
91
|
+
const status = get_error_status(error);
|
|
92
|
+
if (is_decoded_remote_failure(decoded)) return decoded;
|
|
93
|
+
if (status === 400 && is_validation_body(body)) return create_remote_validation_error(body.issues, body, status);
|
|
94
|
+
if (status !== void 0) return create_remote_http_error(status, body, error);
|
|
95
|
+
return create_remote_transport_error(error);
|
|
96
|
+
}
|
|
97
|
+
function get_error_status(error) {
|
|
98
|
+
if (typeof error !== "object" || error === null) return;
|
|
99
|
+
const status = error.status;
|
|
100
|
+
return typeof status === "number" ? status : void 0;
|
|
101
|
+
}
|
|
102
|
+
function get_error_body(error) {
|
|
103
|
+
if (typeof error !== "object" || error === null) return;
|
|
104
|
+
if ("body" in error) return error.body;
|
|
105
|
+
if ("data" in error) return error.data;
|
|
106
|
+
}
|
|
107
|
+
//#endregion
|
|
108
|
+
//#region src/remote/client/responses.ts
|
|
109
|
+
/**
|
|
110
|
+
* Decodes a failed fetch response into the runtime failure model.
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* ```ts
|
|
114
|
+
* const failure = await decode_response_failure(response);
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @since 2.0.0
|
|
118
|
+
* @param response - Failed fetch response returned by the remote endpoint.
|
|
119
|
+
* @returns Remote failure represented by the response.
|
|
120
|
+
*/
|
|
121
|
+
async function decode_response_failure(response) {
|
|
122
|
+
const body = await response.json().catch(() => void 0);
|
|
123
|
+
const decoded = decode_remote_error(body);
|
|
124
|
+
if (is_decoded_remote_failure(decoded)) return decoded;
|
|
125
|
+
if (response.status === 400 && is_validation_body(body)) return create_remote_validation_error(body.issues, body, response.status);
|
|
126
|
+
return create_remote_http_error(response.status, body);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Decodes either a raw value or `Response` returned by a native remote helper.
|
|
130
|
+
*
|
|
131
|
+
* @example
|
|
132
|
+
* ```ts
|
|
133
|
+
* const output = await decode_response_or_value(result, decode_payload);
|
|
134
|
+
* ```
|
|
135
|
+
*
|
|
136
|
+
* @since 2.0.0
|
|
137
|
+
* @param value - Native result value or fetch response.
|
|
138
|
+
* @param decode_payload - Function used to decode successful payloads.
|
|
139
|
+
* @returns Decoded successful output.
|
|
140
|
+
*/
|
|
141
|
+
async function decode_response_or_value(value, decode_payload) {
|
|
142
|
+
if (value instanceof Response) {
|
|
143
|
+
if (!value.ok) throw await decode_response_failure(value);
|
|
144
|
+
return decode_payload(await value.json());
|
|
145
|
+
}
|
|
146
|
+
return decode_payload(value);
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
//#region src/remote/client/effect.ts
|
|
150
|
+
/**
|
|
151
|
+
* Wraps a promise-producing remote operation in an Effect with failure mapping.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```ts
|
|
155
|
+
* const program = make_effect_from_promise(() => native_remote(input));
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
158
|
+
* @since 2.0.0
|
|
159
|
+
* @param run - Promise-producing operation that invokes a native remote helper.
|
|
160
|
+
* @returns Effect that maps thrown values into remote failures.
|
|
161
|
+
*/
|
|
162
|
+
function make_effect_from_promise(run) {
|
|
163
|
+
return Effect.tryPromise({
|
|
164
|
+
try: run,
|
|
165
|
+
catch: (error) => {
|
|
166
|
+
if (is_decoded_remote_failure(error)) return error;
|
|
167
|
+
return normalize_native_error(error);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
//#region src/remote/client/utils.ts
|
|
173
|
+
/**
|
|
174
|
+
* Checks whether a value has a callable method property.
|
|
175
|
+
*
|
|
176
|
+
* @since 2.0.0
|
|
177
|
+
* @param value - Value to inspect.
|
|
178
|
+
* @param key - Method key to look up.
|
|
179
|
+
* @returns Whether the value has a function at `key`.
|
|
180
|
+
*/
|
|
181
|
+
function has_method(value, key) {
|
|
182
|
+
return typeof value === "object" && value !== null && typeof value[key] === "function";
|
|
183
|
+
}
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/remote/client/command.ts
|
|
186
|
+
/**
|
|
187
|
+
* Creates a remote command adapter. The adapter preserves the native
|
|
188
|
+
* pending getter and turns each invocation into an Effect.
|
|
189
|
+
*
|
|
190
|
+
* @since 2.0.0
|
|
191
|
+
* @param native_factory - SvelteKit's native command function or a legacy
|
|
192
|
+
* response factory used by tests.
|
|
193
|
+
* @param decode_payload - Function to decode the response payload.
|
|
194
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
195
|
+
* @param pending - Optional pending counter for legacy response factories.
|
|
196
|
+
* @returns A function returning an Effect of the response.
|
|
197
|
+
* @internal
|
|
198
|
+
*/
|
|
199
|
+
function create_remote_command_adapter(native_factory, decode_payload, _base = "", pending) {
|
|
200
|
+
const invoke = has_method(native_factory, "invoke") ? native_factory.invoke : void 0;
|
|
201
|
+
if (typeof native_factory !== "function" && !invoke) throw new Error("Invalid command factory: expected a function");
|
|
202
|
+
const count = pending ?? { value: 0 };
|
|
203
|
+
const adapter = (input) => make_effect_from_promise(async () => {
|
|
204
|
+
count.value += 1;
|
|
205
|
+
try {
|
|
206
|
+
return await decode_response_or_value(invoke ? await invoke(input) : await native_factory(input), decode_payload);
|
|
207
|
+
} finally {
|
|
208
|
+
count.value -= 1;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
copy_property_descriptors(native_factory, adapter);
|
|
212
|
+
if (!Object.prototype.hasOwnProperty.call(adapter, "pending")) Object.defineProperty(adapter, "pending", { get: () => count.value });
|
|
213
|
+
return adapter;
|
|
214
|
+
}
|
|
215
|
+
//#endregion
|
|
216
|
+
//#region src/remote/client/form-data.ts
|
|
217
|
+
/**
|
|
218
|
+
* Encodes remote form input into SvelteKit-compatible form data.
|
|
219
|
+
*
|
|
220
|
+
* @since 2.0.0
|
|
221
|
+
* @param input - Input value supplied to the remote form.
|
|
222
|
+
* @returns FormData payload for the remote endpoint.
|
|
223
|
+
*/
|
|
224
|
+
function to_form_data(input) {
|
|
225
|
+
const form_data = new FormData();
|
|
226
|
+
append_form_value(form_data, "", input);
|
|
227
|
+
return form_data;
|
|
228
|
+
}
|
|
229
|
+
function append_form_value(form_data, path, value) {
|
|
230
|
+
if (value === void 0) return;
|
|
231
|
+
if (Array.isArray(value)) {
|
|
232
|
+
for (const item of value) append_form_value(form_data, `${path}[]`, item);
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (value instanceof Blob) {
|
|
236
|
+
form_data.append(path, value);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (typeof value === "object" && value !== null) {
|
|
240
|
+
for (const [key, child] of Object.entries(value)) append_form_value(form_data, path.length === 0 ? key : `${path}.${key}`, child);
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
if (typeof value === "number") {
|
|
244
|
+
form_data.append(`n:${path}`, String(value));
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
if (typeof value === "boolean") {
|
|
248
|
+
if (value) form_data.append(`b:${path}`, "on");
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
form_data.append(path, value === null ? "" : String(value));
|
|
252
|
+
}
|
|
253
|
+
//#endregion
|
|
254
|
+
//#region src/remote/client/form-transport.ts
|
|
255
|
+
/**
|
|
256
|
+
* Submits a native remote form through the SvelteKit remote endpoint.
|
|
257
|
+
*
|
|
258
|
+
* @since 2.0.0
|
|
259
|
+
* @param form_obj - Native form object being adapted.
|
|
260
|
+
* @param input - Form input value.
|
|
261
|
+
* @param decode_payload - Function to decode successful payloads.
|
|
262
|
+
* @param remote_base - Base URL for the remote endpoint.
|
|
263
|
+
* @returns Decoded form output.
|
|
264
|
+
*/
|
|
265
|
+
async function submit_remote_form(form_obj, input, decode_payload, remote_base) {
|
|
266
|
+
const action_id = get_remote_action_id(form_obj);
|
|
267
|
+
if (!action_id || remote_base.length === 0) throw create_remote_transport_error(/* @__PURE__ */ new Error("Form has no submit method or remote endpoint"));
|
|
268
|
+
const response = await fetch(to_remote_form_url(remote_base, action_id), {
|
|
269
|
+
method: "POST",
|
|
270
|
+
body: to_form_data(input)
|
|
271
|
+
});
|
|
272
|
+
if (!response.ok) throw await decode_response_failure(response);
|
|
273
|
+
return decode_form_response(await response.json(), decode_payload);
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Extracts SvelteKit's remote action id from a native form action URL.
|
|
277
|
+
*
|
|
278
|
+
* @since 2.0.0
|
|
279
|
+
* @param form_obj - Native form object being adapted.
|
|
280
|
+
* @returns Remote action id when present.
|
|
281
|
+
*/
|
|
282
|
+
function get_remote_action_id(form_obj) {
|
|
283
|
+
const action = form_obj.action;
|
|
284
|
+
if (typeof action !== "string") return;
|
|
285
|
+
const href = typeof location === "undefined" ? "http://localhost/" : location.href;
|
|
286
|
+
const url = new URL(action, href);
|
|
287
|
+
return url.searchParams.get("/remote") ?? url.searchParams.get("remote") ?? void 0;
|
|
288
|
+
}
|
|
289
|
+
function to_remote_form_url(remote_base, action_id) {
|
|
290
|
+
const parts = action_id.split("/");
|
|
291
|
+
const head = parts.slice(0, 2).join("/");
|
|
292
|
+
const tail = parts.slice(2).join("/");
|
|
293
|
+
const normalized_base = remote_base.replace(/\/$/, "");
|
|
294
|
+
if (tail.length === 0) return `${normalized_base}/${head}`;
|
|
295
|
+
return `${normalized_base}/${head}/${encodeURIComponent(tail)}`;
|
|
296
|
+
}
|
|
297
|
+
function decode_form_response(envelope, decode_payload) {
|
|
298
|
+
if (typeof envelope !== "object" || envelope === null || !("type" in envelope)) throw create_remote_transport_error(/* @__PURE__ */ new Error("Invalid remote form response"), envelope);
|
|
299
|
+
const response = envelope;
|
|
300
|
+
if (response.type === "error") {
|
|
301
|
+
const decoded = decode_remote_error(response.error);
|
|
302
|
+
if (is_decoded_remote_failure(decoded)) throw decoded;
|
|
303
|
+
throw create_remote_http_error(response.status ?? 500, response.error);
|
|
304
|
+
}
|
|
305
|
+
if (response.type !== "result" || typeof response.result !== "string") throw create_remote_transport_error(/* @__PURE__ */ new Error("Unsupported remote form response"), envelope);
|
|
306
|
+
const decoded = decode_payload(parse(response.result));
|
|
307
|
+
if (decoded.issues && decoded.issues.length > 0) throw create_remote_validation_error(decoded.issues, decoded, 400);
|
|
308
|
+
return decoded.result;
|
|
309
|
+
}
|
|
310
|
+
//#endregion
|
|
311
|
+
//#region src/remote/client/form-enhance.ts
|
|
312
|
+
/**
|
|
313
|
+
* Wraps a remote form enhance callback so Effect return values are run.
|
|
314
|
+
*
|
|
315
|
+
* @since 2.0.0
|
|
316
|
+
* @param callback - Native enhance callback to wrap.
|
|
317
|
+
* @returns Wrapped callback or undefined.
|
|
318
|
+
*/
|
|
319
|
+
function wrap_enhance_callback(callback) {
|
|
320
|
+
if (!callback) return;
|
|
321
|
+
return (event) => {
|
|
322
|
+
const result = callback(wrap_submit_callback(event));
|
|
323
|
+
if (Effect.isEffect(result)) return get_dispatcher().run(result);
|
|
324
|
+
return result;
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
function wrap_submit_callback(event) {
|
|
328
|
+
if (typeof event !== "object" || event === null || !has_method(event, "submit")) return event;
|
|
329
|
+
const original_submit = event.submit;
|
|
330
|
+
const { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(event);
|
|
331
|
+
return Object.defineProperties({}, {
|
|
332
|
+
...descriptors,
|
|
333
|
+
submit: {
|
|
334
|
+
configurable: true,
|
|
335
|
+
enumerable: false,
|
|
336
|
+
value: () => make_submit_effect(original_submit)
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function make_submit_effect(original_submit) {
|
|
341
|
+
let updates_args;
|
|
342
|
+
const effect = make_effect_from_promise(async () => {
|
|
343
|
+
const result = original_submit();
|
|
344
|
+
if (updates_args && has_method(result, "updates")) return await Promise.resolve(result.updates(...updates_args));
|
|
345
|
+
return await Promise.resolve(result);
|
|
346
|
+
});
|
|
347
|
+
Object.defineProperty(effect, "updates", {
|
|
348
|
+
configurable: true,
|
|
349
|
+
enumerable: false,
|
|
350
|
+
value: (...args) => {
|
|
351
|
+
updates_args ??= args;
|
|
352
|
+
return effect;
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
return effect;
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/remote/client/form.ts
|
|
359
|
+
/**
|
|
360
|
+
* Creates a remote form adapter. The callable preserves SvelteKit's native
|
|
361
|
+
* form descriptors while wrapping `validate`, `enhance`, and programmatic
|
|
362
|
+
* submission in Effect-returning APIs.
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```ts
|
|
366
|
+
* const createPost = create_remote_form_adapter(nativeForm, (value) => value);
|
|
367
|
+
* yield* createPost.validate({ includeUntouched: true });
|
|
368
|
+
* ```
|
|
369
|
+
*
|
|
370
|
+
* @since 2.0.0
|
|
371
|
+
* @param native_factory - SvelteKit's native form object.
|
|
372
|
+
* @param decode_payload - Function to decode the response payload.
|
|
373
|
+
* @param remote_base - Base URL for SvelteKit's remote endpoint.
|
|
374
|
+
* @returns A callable form function whose properties mirror the native form.
|
|
375
|
+
* @internal
|
|
376
|
+
*/
|
|
377
|
+
function create_remote_form_adapter(native_factory, decode_payload, remote_base = "") {
|
|
378
|
+
const form_obj = native_factory;
|
|
379
|
+
const submit_effect = (input) => make_effect_from_promise(async () => {
|
|
380
|
+
const can_use_remote_endpoint = remote_base.length > 0 && get_remote_action_id(form_obj) !== void 0;
|
|
381
|
+
if (has_method(form_obj, "submit") && !can_use_remote_endpoint) return await decode_response_or_value(await form_obj.submit(input), decode_payload);
|
|
382
|
+
return await submit_remote_form(form_obj, input, decode_payload, remote_base);
|
|
383
|
+
});
|
|
384
|
+
const callable = ((input) => submit_effect(input));
|
|
385
|
+
copy_property_descriptors(form_obj, callable, new Set([
|
|
386
|
+
"submit",
|
|
387
|
+
"validate",
|
|
388
|
+
"enhance",
|
|
389
|
+
"for",
|
|
390
|
+
"preflight"
|
|
391
|
+
]));
|
|
392
|
+
Object.defineProperty(callable, "submit", {
|
|
393
|
+
configurable: true,
|
|
394
|
+
enumerable: false,
|
|
395
|
+
value: submit_effect
|
|
396
|
+
});
|
|
397
|
+
if (has_method(form_obj, "validate")) Object.defineProperty(callable, "validate", {
|
|
398
|
+
configurable: true,
|
|
399
|
+
enumerable: false,
|
|
400
|
+
value: (options) => make_effect_from_promise(async () => {
|
|
401
|
+
await form_obj.validate(options);
|
|
402
|
+
})
|
|
403
|
+
});
|
|
404
|
+
if (has_method(form_obj, "enhance")) Object.defineProperty(callable, "enhance", {
|
|
405
|
+
configurable: true,
|
|
406
|
+
enumerable: false,
|
|
407
|
+
value: (callback) => form_obj.enhance(wrap_enhance_callback(callback))
|
|
408
|
+
});
|
|
409
|
+
if (has_method(form_obj, "for")) Object.defineProperty(callable, "for", {
|
|
410
|
+
configurable: true,
|
|
411
|
+
enumerable: false,
|
|
412
|
+
value: (key) => create_remote_form_adapter(form_obj.for(key), decode_payload, remote_base)
|
|
413
|
+
});
|
|
414
|
+
if (has_method(form_obj, "preflight")) Object.defineProperty(callable, "preflight", {
|
|
415
|
+
configurable: true,
|
|
416
|
+
enumerable: false,
|
|
417
|
+
value: (schema) => {
|
|
418
|
+
form_obj.preflight(schema);
|
|
419
|
+
return callable;
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
return callable;
|
|
423
|
+
}
|
|
424
|
+
//#endregion
|
|
425
|
+
//#region src/remote/client/query-result.ts
|
|
426
|
+
/**
|
|
427
|
+
* Resolves native query results, including SvelteKit run handles.
|
|
428
|
+
*
|
|
429
|
+
* @example
|
|
430
|
+
* ```ts
|
|
431
|
+
* const output = await resolve_query_result(result, decode_payload);
|
|
432
|
+
* ```
|
|
433
|
+
*
|
|
434
|
+
* @since 2.0.0
|
|
435
|
+
* @param value - Native query result or query run handle.
|
|
436
|
+
* @param decode_payload - Function used to decode successful payloads.
|
|
437
|
+
* @returns Decoded query output.
|
|
438
|
+
*/
|
|
439
|
+
async function resolve_query_result(value, decode_payload) {
|
|
440
|
+
if (has_method(value, "then")) return decode_response_or_value(await Promise.resolve(value), decode_payload);
|
|
441
|
+
if (has_method(value, "run")) return decode_response_or_value(await value.run(), decode_payload);
|
|
442
|
+
return decode_response_or_value(await Promise.resolve(value), decode_payload);
|
|
443
|
+
}
|
|
444
|
+
//#endregion
|
|
445
|
+
//#region src/remote/client/query.ts
|
|
446
|
+
/**
|
|
447
|
+
* Creates a remote query adapter. The returned function takes input and
|
|
448
|
+
* returns an `Effect` that executes SvelteKit's native query function.
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```ts
|
|
452
|
+
* const getUser = create_remote_query_adapter(nativeQuery, (value) => value);
|
|
453
|
+
* const user = yield* getUser({ id: 1 });
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
456
|
+
* @since 2.0.0
|
|
457
|
+
* @param native_factory - SvelteKit's native query function or a legacy
|
|
458
|
+
* response factory used by tests.
|
|
459
|
+
* @param decode_payload - Function to decode the response payload.
|
|
460
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
461
|
+
* @returns A function returning an Effect of the response.
|
|
462
|
+
* @internal
|
|
463
|
+
*/
|
|
464
|
+
function create_remote_query_adapter(native_factory, decode_payload, _base = "") {
|
|
465
|
+
const load = has_method(native_factory, "load") ? native_factory.load : void 0;
|
|
466
|
+
const query = typeof native_factory === "function" ? native_factory : void 0;
|
|
467
|
+
if (!query && !load) throw new Error("Invalid query factory: expected a function");
|
|
468
|
+
const wrapped = ((input) => {
|
|
469
|
+
if (!query) return make_effect_from_promise(async () => {
|
|
470
|
+
return await resolve_query_result(await load?.(input), decode_payload);
|
|
471
|
+
});
|
|
472
|
+
const resource = query(input);
|
|
473
|
+
const effect = make_effect_from_promise(async () => await resolve_query_result(resource, decode_payload));
|
|
474
|
+
attach_query_resource(resource, effect);
|
|
475
|
+
return effect;
|
|
476
|
+
});
|
|
477
|
+
copy_property_descriptors(native_factory, wrapped);
|
|
478
|
+
return wrapped;
|
|
479
|
+
}
|
|
480
|
+
/**
|
|
481
|
+
* Creates a remote live query adapter. The returned function takes input and
|
|
482
|
+
* returns an `Effect` that awaits the first live value while preserving live
|
|
483
|
+
* stream state and reconnect controls.
|
|
484
|
+
*
|
|
485
|
+
* @example
|
|
486
|
+
* ```ts
|
|
487
|
+
* const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
|
|
488
|
+
* const time = yield* getTime();
|
|
489
|
+
* ```
|
|
490
|
+
*
|
|
491
|
+
* @since 2.0.0
|
|
492
|
+
* @param native_factory - SvelteKit's native live query function.
|
|
493
|
+
* @param decode_payload - Function to decode the initial response payload.
|
|
494
|
+
* @param _base - Deprecated transport base retained for compatibility.
|
|
495
|
+
* @returns A function returning an Effect-backed live query resource.
|
|
496
|
+
* @internal
|
|
497
|
+
*/
|
|
498
|
+
function create_remote_live_query_adapter(native_factory, decode_payload, _base = "") {
|
|
499
|
+
const query = typeof native_factory === "function" ? native_factory : void 0;
|
|
500
|
+
if (!query) throw new Error("Invalid live query factory: expected a function");
|
|
501
|
+
const wrapped = ((input) => {
|
|
502
|
+
const resource = query(input);
|
|
503
|
+
const effect = make_effect_from_promise(async () => await resolve_query_result(resource, decode_payload));
|
|
504
|
+
attach_live_query_resource(resource, effect);
|
|
505
|
+
return effect;
|
|
506
|
+
});
|
|
507
|
+
copy_property_descriptors(native_factory, wrapped);
|
|
508
|
+
return wrapped;
|
|
509
|
+
}
|
|
510
|
+
function is_resource(resource) {
|
|
511
|
+
const resource_type = typeof resource;
|
|
512
|
+
return resource_type === "object" && resource !== null || resource_type === "function";
|
|
513
|
+
}
|
|
514
|
+
function attach_resource_getters(resource, effect) {
|
|
515
|
+
const methods = is_resource(resource) ? resource : void 0;
|
|
516
|
+
const keys = [
|
|
517
|
+
"current",
|
|
518
|
+
"error",
|
|
519
|
+
"loading",
|
|
520
|
+
"ready"
|
|
521
|
+
];
|
|
522
|
+
if (!methods) return;
|
|
523
|
+
for (const key of keys) {
|
|
524
|
+
if (!(key in methods)) continue;
|
|
525
|
+
Object.defineProperty(effect, key, {
|
|
526
|
+
configurable: true,
|
|
527
|
+
get: () => methods[key]
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function attach_query_resource(resource, effect) {
|
|
532
|
+
const methods = is_resource(resource) ? resource : void 0;
|
|
533
|
+
const refresh = methods?.refresh;
|
|
534
|
+
const set = methods?.set;
|
|
535
|
+
const with_override = methods?.withOverride;
|
|
536
|
+
attach_resource_getters(resource, effect);
|
|
537
|
+
if (!methods) return;
|
|
538
|
+
if (typeof refresh === "function") Object.defineProperty(effect, "refresh", {
|
|
539
|
+
configurable: true,
|
|
540
|
+
value: () => make_effect_from_promise(() => Promise.resolve(refresh.call(resource)))
|
|
541
|
+
});
|
|
542
|
+
if (typeof set === "function") Object.defineProperty(effect, "set", {
|
|
543
|
+
configurable: true,
|
|
544
|
+
value: (value) => set.call(resource, value)
|
|
545
|
+
});
|
|
546
|
+
if (typeof with_override === "function") Object.defineProperty(effect, "withOverride", {
|
|
547
|
+
configurable: true,
|
|
548
|
+
value: (update) => with_override.call(resource, update)
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
function attach_live_query_resource(resource, effect) {
|
|
552
|
+
const methods = is_resource(resource) ? resource : void 0;
|
|
553
|
+
const async_iterator = methods?.[Symbol.asyncIterator];
|
|
554
|
+
const reconnect = methods?.reconnect;
|
|
555
|
+
const keys = ["connected", "done"];
|
|
556
|
+
attach_resource_getters(resource, effect);
|
|
557
|
+
if (!methods) return;
|
|
558
|
+
for (const key of keys) {
|
|
559
|
+
if (!(key in methods)) continue;
|
|
560
|
+
Object.defineProperty(effect, key, {
|
|
561
|
+
configurable: true,
|
|
562
|
+
get: () => methods[key]
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
if (typeof reconnect === "function") Object.defineProperty(effect, "reconnect", {
|
|
566
|
+
configurable: true,
|
|
567
|
+
value: () => make_effect_from_promise(() => Promise.resolve(reconnect.call(resource)))
|
|
568
|
+
});
|
|
569
|
+
if (typeof async_iterator === "function") Object.defineProperty(effect, Symbol.asyncIterator, {
|
|
570
|
+
configurable: true,
|
|
571
|
+
value: () => async_iterator.call(resource)
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
//#endregion
|
|
575
|
+
export { create_remote_command_adapter as i, create_remote_query_adapter as n, create_remote_form_adapter as r, create_remote_live_query_adapter as t };
|
|
576
|
+
|
|
577
|
+
//# sourceMappingURL=client-BeOE81fW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-BeOE81fW.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/failures.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.ts","../../../modules/svelte-effect-runtime/src/remote/client/effect.ts","../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/command.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-data.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-transport.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-enhance.ts","../../../modules/svelte-effect-runtime/src/remote/client/form.ts","../../../modules/svelte-effect-runtime/src/remote/client/query-result.ts","../../../modules/svelte-effect-runtime/src/remote/client/query.ts"],"sourcesContent":["import {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n is_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { FormIssue, RemoteFailure } from \"$/remote/shared.ts\";\nimport { parse } from \"devalue\";\n\n/**\n * Decodes a raw wire value into a remote failure when it uses the runtime\n * failure envelope.\n *\n * @example\n * ```ts\n * const failure = decode_remote_error(body);\n * ```\n *\n * @since 2.0.0\n * @param raw - Raw value received from the network or SvelteKit error body.\n * @param decode - Optional devalue decoder for custom error payloads.\n * @returns The decoded failure/value, or a transport error when decoding fails.\n */\nexport function decode_remote_error(\n raw: unknown,\n decode?: (encoded: string) => unknown,\n): RemoteFailure<unknown> | unknown {\n const embedded = parse_embedded_remote_failure(raw);\n\n if (embedded !== raw) {\n return decode_remote_error(embedded, decode);\n }\n\n if (is_serialized_remote_failure_envelope(raw)) {\n try {\n const decoded = decode ? decode(raw.encoded) : parse(raw.encoded);\n\n return decoded as RemoteFailure<unknown>;\n } catch {\n return create_remote_transport_error(\n new Error(\"Failed to decode remote error payload\"),\n raw,\n );\n }\n }\n\n return raw;\n}\n\nfunction parse_embedded_remote_failure(raw: unknown): unknown {\n if (typeof raw === \"string\") {\n return parse_json_or_original(raw);\n }\n\n if (typeof raw !== \"object\" || raw === null || !(\"message\" in raw)) {\n return raw;\n }\n\n const message = (raw as { message?: unknown }).message;\n\n if (typeof message !== \"string\") {\n return raw;\n }\n\n const parsed = parse_json_or_original(message);\n\n return parsed === message ? raw : parsed;\n}\n\nfunction parse_json_or_original(value: string): unknown {\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n}\n\n/**\n * Checks whether a decoded value is a tagged remote failure.\n *\n * @example\n * ```ts\n * if (is_decoded_remote_failure(value)) throw value;\n * ```\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value carries a `_tag` discriminator.\n */\nexport function is_decoded_remote_failure(\n value: unknown,\n): value is RemoteFailure<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value\n );\n}\n\n/**\n * Checks whether a response body represents SvelteKit validation issues.\n *\n * @example\n * ```ts\n * if (is_validation_body(body)) return body.issues;\n * ```\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value contains a form issue list.\n */\nexport function is_validation_body(\n value: unknown,\n): value is { issues: readonly FormIssue[] } {\n return (\n typeof value === \"object\" &&\n value !== null &&\n Array.isArray((value as { issues?: unknown }).issues)\n );\n}\n\n/**\n * Normalizes native thrown values into the runtime's remote failure model.\n *\n * @example\n * ```ts\n * const failure = normalize_native_error(error);\n * ```\n *\n * @since 2.0.0\n * @param error - Unknown value thrown by a native remote helper.\n * @returns A typed remote failure.\n */\nexport function normalize_native_error(error: unknown): RemoteFailure<unknown> {\n const body = get_error_body(error);\n const decoded = decode_remote_error(body);\n const status = get_error_status(error);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n if (status === 400 && is_validation_body(body)) {\n return create_remote_validation_error(body.issues, body, status);\n }\n\n if (status !== undefined) {\n return create_remote_http_error(status, body, error);\n }\n\n return create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n const status = (error as { status?: unknown }).status;\n\n return typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n if (\"body\" in error) {\n return (error as { body?: unknown }).body;\n }\n\n if (\"data\" in error) {\n return (error as { data?: unknown }).data;\n }\n\n return undefined;\n}\n","import {\n create_remote_http_error,\n create_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\n\nimport {\n decode_remote_error,\n is_decoded_remote_failure,\n is_validation_body,\n} from \"./failures.ts\";\n\n/**\n * Decodes a failed fetch response into the runtime failure model.\n *\n * @example\n * ```ts\n * const failure = await decode_response_failure(response);\n * ```\n *\n * @since 2.0.0\n * @param response - Failed fetch response returned by the remote endpoint.\n * @returns Remote failure represented by the response.\n */\nexport async function decode_response_failure(\n response: Response,\n): Promise<RemoteFailure<unknown>> {\n const body = await response.json().catch(() => undefined);\n const decoded = decode_remote_error(body);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n if (response.status === 400 && is_validation_body(body)) {\n return create_remote_validation_error(body.issues, body, response.status);\n }\n\n return create_remote_http_error(response.status, body);\n}\n\n/**\n * Decodes either a raw value or `Response` returned by a native remote helper.\n *\n * @example\n * ```ts\n * const output = await decode_response_or_value(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native result value or fetch response.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded successful output.\n */\nexport async function decode_response_or_value<Output>(\n value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (value instanceof Response) {\n if (!value.ok) {\n throw await decode_response_failure(value);\n }\n\n const data = await value.json();\n\n return decode_payload(data) as Output;\n }\n\n return decode_payload(value) as Output;\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nimport {\n is_decoded_remote_failure,\n normalize_native_error,\n} from \"./failures.ts\";\n\n/**\n * Wraps a promise-producing remote operation in an Effect with failure mapping.\n *\n * @example\n * ```ts\n * const program = make_effect_from_promise(() => native_remote(input));\n * ```\n *\n * @since 2.0.0\n * @param run - Promise-producing operation that invokes a native remote helper.\n * @returns Effect that maps thrown values into remote failures.\n */\nexport function make_effect_from_promise<Output>(\n run: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<unknown>> {\n return Effect.tryPromise({\n try: run,\n catch: (error: unknown) => {\n if (is_decoded_remote_failure(error)) {\n return error;\n }\n\n return normalize_native_error(error);\n },\n }) as Effect.Effect<Output, RemoteFailure<unknown>>;\n}\n","export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\n/**\n * Checks whether a value has a callable method property.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @param key - Method key to look up.\n * @returns Whether the value has a function at `key`.\n */\nexport function has_method<K extends PropertyKey>(\n value: unknown,\n key: K,\n): value is Record<K, NativeMethod> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n );\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { Effect } from \"effect\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\n\n/**\n * Creates a remote command adapter. The adapter preserves the native\n * pending getter and turns each invocation into an Effect.\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native command function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @param pending - Optional pending counter for legacy response factories.\n * @returns A function returning an Effect of the response.\n * @internal\n */\nexport function create_remote_command_adapter<Input, Output>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n _base = \"\",\n pending?: Pending,\n): (input: Input) => Effect.Effect<Output, RemoteFailure<unknown>> {\n const invoke = has_method(native_factory, \"invoke\")\n ? native_factory.invoke\n : undefined;\n\n if (typeof native_factory !== \"function\" && !invoke) {\n throw new Error(\"Invalid command factory: expected a function\");\n }\n\n const count = pending ?? { value: 0 };\n\n const adapter = (input: Input) =>\n make_effect_from_promise(async () => {\n count.value += 1;\n\n try {\n const result = invoke\n ? await invoke(input)\n : await (native_factory as NativeMethod)(input);\n\n return await decode_response_or_value<Output>(result, decode_payload);\n } finally {\n count.value -= 1;\n }\n });\n\n copy_property_descriptors(native_factory, adapter);\n\n if (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n Object.defineProperty(adapter, \"pending\", {\n get: () => count.value,\n });\n }\n\n return adapter;\n}\n","/**\n * Encodes remote form input into SvelteKit-compatible form data.\n *\n * @since 2.0.0\n * @param input - Input value supplied to the remote form.\n * @returns FormData payload for the remote endpoint.\n */\nexport function to_form_data(input: unknown): FormData {\n const form_data = new FormData();\n\n append_form_value(form_data, \"\", input);\n\n return form_data;\n}\n\nfunction append_form_value(\n form_data: FormData,\n path: string,\n value: unknown,\n): void {\n if (value === undefined) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n append_form_value(form_data, `${path}[]`, item);\n }\n\n return;\n }\n\n if (value instanceof Blob) {\n form_data.append(path, value);\n\n return;\n }\n\n if (typeof value === \"object\" && value !== null) {\n for (const [key, child] of Object.entries(value)) {\n const child_path = path.length === 0 ? key : `${path}.${key}`;\n\n append_form_value(form_data, child_path, child);\n }\n\n return;\n }\n\n if (typeof value === \"number\") {\n form_data.append(`n:${path}`, String(value));\n\n return;\n }\n\n if (typeof value === \"boolean\") {\n if (value) {\n form_data.append(`b:${path}`, \"on\");\n }\n\n return;\n }\n\n form_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { parse } from \"devalue\";\n\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\nimport { decode_response_failure } from \"./responses.ts\";\nimport { to_form_data } from \"./form-data.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\n\n/**\n * Submits a native remote form through the SvelteKit remote endpoint.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @param input - Form input value.\n * @param decode_payload - Function to decode successful payloads.\n * @param remote_base - Base URL for the remote endpoint.\n * @returns Decoded form output.\n */\nexport async function submit_remote_form<Output>(\n form_obj: NativeFormRecord,\n input: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base: string,\n): Promise<Output> {\n const action_id = get_remote_action_id(form_obj);\n\n if (!action_id || remote_base.length === 0) {\n throw create_remote_transport_error(\n new Error(\"Form has no submit method or remote endpoint\"),\n );\n }\n\n const response = await fetch(to_remote_form_url(remote_base, action_id), {\n method: \"POST\",\n body: to_form_data(input),\n });\n\n if (!response.ok) {\n throw await decode_response_failure(response);\n }\n\n const envelope = await response.json();\n\n return decode_form_response<Output>(envelope, decode_payload);\n}\n\n/**\n * Extracts SvelteKit's remote action id from a native form action URL.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @returns Remote action id when present.\n */\nexport function get_remote_action_id(\n form_obj: NativeFormRecord,\n): string | undefined {\n const action = form_obj.action;\n\n if (typeof action !== \"string\") {\n return undefined;\n }\n\n const fallback = \"http://localhost/\";\n const href = typeof location === \"undefined\" ? fallback : location.href;\n const url = new URL(action, href);\n\n return url.searchParams.get(\"/remote\") ??\n url.searchParams.get(\"remote\") ??\n undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n const parts = action_id.split(\"/\");\n const head = parts.slice(0, 2).join(\"/\");\n const tail = parts.slice(2).join(\"/\");\n const normalized_base = remote_base.replace(/\\/$/, \"\");\n\n if (tail.length === 0) {\n return `${normalized_base}/${head}`;\n }\n\n return `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction decode_form_response<Output>(\n envelope: unknown,\n decode_payload: (value: unknown) => unknown,\n): Output {\n if (\n typeof envelope !== \"object\" ||\n envelope === null ||\n !(\"type\" in envelope)\n ) {\n throw create_remote_transport_error(\n new Error(\"Invalid remote form response\"),\n envelope,\n );\n }\n\n const response = envelope as {\n type: string;\n result?: unknown;\n error?: unknown;\n status?: number;\n };\n\n if (response.type === \"error\") {\n const decoded = decode_remote_error(response.error);\n\n if (is_decoded_remote_failure(decoded)) {\n throw decoded;\n }\n\n throw create_remote_http_error(\n response.status ?? 500,\n response.error,\n );\n }\n\n if (response.type !== \"result\" || typeof response.result !== \"string\") {\n throw create_remote_transport_error(\n new Error(\"Unsupported remote form response\"),\n envelope,\n );\n }\n\n const parsed = parse(response.result);\n const decoded = decode_payload(parsed) as {\n issues?: readonly FormIssue[];\n result?: Output;\n };\n\n if (decoded.issues && decoded.issues.length > 0) {\n throw create_remote_validation_error(decoded.issues, decoded, 400);\n }\n\n return decoded.result as Output;\n}\n","import { get_dispatcher } from \"$/dispatcher.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\n/**\n * Wraps a remote form enhance callback so Effect return values are run.\n *\n * @since 2.0.0\n * @param callback - Native enhance callback to wrap.\n * @returns Wrapped callback or undefined.\n */\nexport function wrap_enhance_callback(\n callback: NativeMethod | undefined,\n): NativeMethod | undefined {\n if (!callback) {\n return undefined;\n }\n\n return (event: unknown) => {\n const wrapped_event = wrap_submit_callback(event);\n const result = callback(wrapped_event);\n\n if (Effect.isEffect(result)) {\n return get_dispatcher().run(result);\n }\n\n return result;\n };\n}\n\nfunction wrap_submit_callback(event: unknown): unknown {\n if (\n typeof event !== \"object\" || event === null || !has_method(event, \"submit\")\n ) {\n return event;\n }\n\n const original_submit = event.submit;\n const { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(\n event,\n );\n\n void _submit;\n\n return Object.defineProperties({}, {\n ...descriptors,\n submit: {\n configurable: true,\n enumerable: false,\n value: () => make_submit_effect(original_submit),\n },\n });\n}\n\nfunction make_submit_effect(\n original_submit: NativeMethod,\n): Effect.Effect<unknown, RemoteFailure<unknown>> & Record<string, unknown> {\n let updates_args: unknown[] | undefined;\n\n const effect = make_effect_from_promise(async () => {\n const result = original_submit();\n\n if (updates_args && has_method(result, \"updates\")) {\n return await Promise.resolve(result.updates(...updates_args));\n }\n\n return await Promise.resolve(result);\n }) as\n & Effect.Effect<unknown, RemoteFailure<unknown>>\n & Record<string, unknown>;\n\n Object.defineProperty(effect, \"updates\", {\n configurable: true,\n enumerable: false,\n value: (...args: unknown[]) => {\n updates_args ??= args;\n\n return effect;\n },\n });\n\n return effect;\n}\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { get_remote_action_id, submit_remote_form } from \"./form-transport.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport type { EffectRemoteForm, NativeFormRecord } from \"./types.ts\";\n\n/**\n * Creates a remote form adapter. The callable preserves SvelteKit's native\n * form descriptors while wrapping `validate`, `enhance`, and programmatic\n * submission in Effect-returning APIs.\n *\n * @example\n * ```ts\n * const createPost = create_remote_form_adapter(nativeForm, (value) => value);\n * yield* createPost.validate({ includeUntouched: true });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native form object.\n * @param decode_payload - Function to decode the response payload.\n * @param remote_base - Base URL for SvelteKit's remote endpoint.\n * @returns A callable form function whose properties mirror the native form.\n * @internal\n */\nexport function create_remote_form_adapter<\n Input extends RemoteFormInput | void,\n Output,\n>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base = \"\",\n): EffectRemoteForm<Input, Output> {\n const form_obj = native_factory as NativeFormRecord;\n\n const submit_effect = (input: Input) =>\n make_effect_from_promise(async () => {\n const can_use_remote_endpoint = remote_base.length > 0 &&\n get_remote_action_id(form_obj) !== undefined;\n\n if (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n const result = await form_obj.submit(input);\n\n return await decode_response_or_value<Output>(result, decode_payload);\n }\n\n return await submit_remote_form<Output>(\n form_obj,\n input,\n decode_payload,\n remote_base,\n );\n });\n\n const callable = ((input: Input) => submit_effect(input)) as EffectRemoteForm<\n Input,\n Output\n >;\n\n copy_property_descriptors(\n form_obj,\n callable,\n new Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n );\n\n Object.defineProperty(callable, \"submit\", {\n configurable: true,\n enumerable: false,\n value: submit_effect,\n });\n\n if (has_method(form_obj, \"validate\")) {\n Object.defineProperty(callable, \"validate\", {\n configurable: true,\n enumerable: false,\n value: (options?: Record<string, unknown>) =>\n make_effect_from_promise(async () => {\n await form_obj.validate(options);\n }),\n });\n }\n\n if (has_method(form_obj, \"enhance\")) {\n Object.defineProperty(callable, \"enhance\", {\n configurable: true,\n enumerable: false,\n value: (callback?: Parameters<typeof wrap_enhance_callback>[0]) =>\n form_obj.enhance(wrap_enhance_callback(callback)),\n });\n }\n\n if (has_method(form_obj, \"for\")) {\n Object.defineProperty(callable, \"for\", {\n configurable: true,\n enumerable: false,\n value: (key: string | number | boolean) =>\n create_remote_form_adapter<Input, Output>(\n form_obj.for(key),\n decode_payload,\n remote_base,\n ),\n });\n }\n\n if (has_method(form_obj, \"preflight\")) {\n Object.defineProperty(callable, \"preflight\", {\n configurable: true,\n enumerable: false,\n value: (schema: unknown) => {\n form_obj.preflight(schema);\n\n return callable;\n },\n });\n }\n\n return callable;\n}\n","import { decode_response_or_value } from \"./responses.ts\";\nimport { has_method } from \"./utils.ts\";\n\n/**\n * Resolves native query results, including SvelteKit run handles.\n *\n * @example\n * ```ts\n * const output = await resolve_query_result(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native query result or query run handle.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded query output.\n */\nexport async function resolve_query_result<Output>(\n value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (has_method(value, \"then\")) {\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n }\n\n if (has_method(value, \"run\")) {\n const result = await value.run();\n\n return decode_response_or_value(result, decode_payload);\n }\n\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { Effect } from \"effect\";\n\nimport { resolve_query_result } from \"./query-result.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\ntype RemoteResourceEffect<Output> =\n & Effect.Effect<Output, RemoteFailure<unknown>>\n & {\n readonly current: Output | undefined;\n readonly error: unknown;\n readonly loading: boolean;\n readonly ready: boolean;\n };\n\ntype RemoteQueryEffect<Output> =\n & RemoteResourceEffect<Output>\n & {\n readonly refresh: () => Effect.Effect<void, unknown, never>;\n readonly set: (value: Output) => void;\n readonly withOverride: (\n update: (current: Output) => Output,\n ) => unknown;\n };\n\ntype RemoteLiveQueryEffect<Output> =\n & RemoteResourceEffect<Output>\n & AsyncIterable<Output>\n & {\n readonly connected: boolean;\n readonly done: boolean;\n readonly reconnect: () => Effect.Effect<void, unknown, never>;\n };\n\ntype NativeRemoteResource<Output> = {\n readonly connected?: boolean;\n readonly current?: Output;\n readonly done?: boolean;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n readonly reconnect?: () => Promise<void>;\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n readonly [Symbol.asyncIterator]?: () => AsyncIterator<Output>;\n};\n\n/**\n * Creates a remote query adapter. The returned function takes input and\n * returns an `Effect` that executes SvelteKit's native query function.\n *\n * @example\n * ```ts\n * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);\n * const user = yield* getUser({ id: 1 });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native query function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning an Effect of the response.\n * @internal\n */\nexport function create_remote_query_adapter<Input, Output>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n _base = \"\",\n): (input: Input) => RemoteQueryEffect<Output> {\n const load = has_method(native_factory, \"load\")\n ? native_factory.load\n : undefined;\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query && !load) {\n throw new Error(\"Invalid query factory: expected a function\");\n }\n\n const wrapped = ((input: Input) => {\n if (!query) {\n return make_effect_from_promise(async () => {\n const result = await load?.(input);\n\n return await resolve_query_result<Output>(result, decode_payload);\n }) as RemoteQueryEffect<Output>;\n }\n\n const resource = query(input);\n const effect = make_effect_from_promise(async () =>\n await resolve_query_result<Output>(resource, decode_payload)\n ) as RemoteQueryEffect<Output>;\n\n attach_query_resource(resource, effect);\n\n return effect;\n }) as (input: Input) => RemoteQueryEffect<Output>;\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\n/**\n * Creates a remote live query adapter. The returned function takes input and\n * returns an `Effect` that awaits the first live value while preserving live\n * stream state and reconnect controls.\n *\n * @example\n * ```ts\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\n * const time = yield* getTime();\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native live query function.\n * @param decode_payload - Function to decode the initial response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning an Effect-backed live query resource.\n * @internal\n */\nexport function create_remote_live_query_adapter<Input, Output>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n _base = \"\",\n): (input: Input) => RemoteLiveQueryEffect<Output> {\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query) {\n throw new Error(\"Invalid live query factory: expected a function\");\n }\n\n const wrapped = ((input: Input) => {\n const resource = query(input);\n const effect = make_effect_from_promise(async () =>\n await resolve_query_result<Output>(resource, decode_payload)\n ) as RemoteLiveQueryEffect<Output>;\n\n attach_live_query_resource(resource, effect);\n\n return effect;\n }) as (input: Input) => RemoteLiveQueryEffect<Output>;\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\nfunction is_resource<Output>(\n resource: unknown,\n): resource is NativeRemoteResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction attach_resource_getters<Output>(\n resource: unknown,\n effect: RemoteResourceEffect<Output>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n}\n\nfunction attach_query_resource<Output>(\n resource: unknown,\n effect: RemoteQueryEffect<Output>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n if (typeof refresh === \"function\") {\n Object.defineProperty(effect, \"refresh\", {\n configurable: true,\n value: () =>\n make_effect_from_promise(() => Promise.resolve(refresh.call(resource))),\n });\n }\n\n if (typeof set === \"function\") {\n Object.defineProperty(effect, \"set\", {\n configurable: true,\n value: (value: Output) => set.call(resource, value),\n });\n }\n\n if (typeof with_override === \"function\") {\n Object.defineProperty(effect, \"withOverride\", {\n configurable: true,\n value: (update: (current: Output) => Output) =>\n with_override.call(resource, update),\n });\n }\n}\n\nfunction attach_live_query_resource<Output>(\n resource: unknown,\n effect: RemoteLiveQueryEffect<Output>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const reconnect = methods?.reconnect;\n const keys = [\"connected\", \"done\"] as const;\n\n attach_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n\n if (typeof reconnect === \"function\") {\n Object.defineProperty(effect, \"reconnect\", {\n configurable: true,\n value: () =>\n make_effect_from_promise(() =>\n Promise.resolve(reconnect.call(resource))\n ),\n });\n }\n\n if (typeof async_iterator === \"function\") {\n Object.defineProperty(effect, Symbol.asyncIterator, {\n configurable: true,\n value: () => async_iterator.call(resource),\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,oBACd,KACA,QACkC;CAClC,MAAM,WAAW,8BAA8B,IAAI;AAEnD,KAAI,aAAa,IACf,QAAO,oBAAoB,UAAU,OAAO;AAG9C,KAAI,sCAAsC,IAAI,CAC5C,KAAI;AAGF,SAFgB,SAAS,OAAO,IAAI,QAAQ,GAAG,MAAM,IAAI,QAAQ;SAG3D;AACN,SAAO,8CACL,IAAI,MAAM,wCAAwC,EAClD,IACD;;AAIL,QAAO;;AAGT,SAAS,8BAA8B,KAAuB;AAC5D,KAAI,OAAO,QAAQ,SACjB,QAAO,uBAAuB,IAAI;AAGpC,KAAI,OAA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