svelte-effect-runtime 4.0.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/client-DbwVAMWm.js +530 -0
- package/.dist/chunks/client-DbwVAMWm.js.map +1 -0
- package/.dist/chunks/compiler-Dpyu4Owd.js +412 -0
- package/.dist/chunks/compiler-Dpyu4Owd.js.map +1 -0
- package/.dist/chunks/descriptors-q909VWyR.js +216 -0
- package/.dist/chunks/descriptors-q909VWyR.js.map +1 -0
- package/.dist/chunks/diagnostics-DLwwrBWb.js +359 -0
- package/.dist/chunks/diagnostics-DLwwrBWb.js.map +1 -0
- package/.dist/chunks/dispatcher-CTWINW5I.js +534 -0
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +1 -0
- package/.dist/chunks/dispatcher-pZPzarul.js +23 -0
- package/.dist/chunks/dispatcher-pZPzarul.js.map +1 -0
- package/.dist/chunks/{errors-IJjsUwrE.js → errors-qhcbUH6o.js} +56 -44
- package/.dist/chunks/errors-qhcbUH6o.js.map +1 -0
- package/.dist/chunks/live-BW7xZKjb.js +146 -0
- package/.dist/chunks/live-BW7xZKjb.js.map +1 -0
- package/.dist/chunks/live-CHK0RrZu.js +10 -0
- package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
- package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
- package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-CPosEhGl.js} +3 -27
- package/.dist/chunks/runtime-CPosEhGl.js.map +1 -0
- package/.dist/chunks/{server-D1LcDnZE.js → server-yQrNoiCR.js} +15 -84
- package/.dist/chunks/server-yQrNoiCR.js.map +1 -0
- package/.dist/chunks/source-scan-cSawCvsg.js +1059 -0
- package/.dist/chunks/source-scan-cSawCvsg.js.map +1 -0
- package/.dist/chunks/{transform-jNUr65K9.js → transform-D7TTlPpK.js} +245 -371
- package/.dist/chunks/transform-D7TTlPpK.js.map +1 -0
- package/.dist/compiler/markup-identifiers.d.ts +2 -0
- package/.dist/compiler/remote-client.d.ts +1 -19
- package/.dist/compiler/source-scan.d.ts +11 -108
- package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
- package/.dist/compiler.d.ts +6 -0
- package/.dist/compiler.js +1 -1
- package/.dist/detect.d.ts +0 -31
- package/.dist/detect.js +0 -39
- package/.dist/detect.js.map +1 -1
- package/.dist/diagnostics.d.ts +0 -16
- package/.dist/dispatcher/deps.d.ts +3 -14
- package/.dist/dispatcher/fibers.d.ts +5 -46
- package/.dist/dispatcher/index.d.ts +42 -135
- package/.dist/dispatcher/scope.d.ts +36 -0
- package/.dist/dispatcher/types.d.ts +0 -151
- package/.dist/dispatcher.d.ts +2 -1
- package/.dist/dispatcher.js +2 -2
- package/.dist/errors.d.ts +44 -42
- package/.dist/generated/dispatcher.d.ts +6 -51
- package/.dist/generators.d.ts +2 -12
- package/.dist/internal/descriptors.d.ts +0 -16
- package/.dist/internal/generators.js +14 -9
- package/.dist/internal/generators.js.map +1 -1
- package/.dist/internal/live.d.ts +9 -0
- package/.dist/internal/remote-client.js +2 -2
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/internal/schema.d.ts +0 -54
- package/.dist/live.d.ts +9 -26
- package/.dist/markup/event-attributes.d.ts +0 -32
- package/.dist/markup/promise.d.ts +1 -23
- package/.dist/markup/promise.js +2 -18
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.d.ts +1 -10
- package/.dist/markup/run.js +2 -11
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/apply.d.ts +5 -4
- package/.dist/markup/transform/classify.d.ts +2 -11
- package/.dist/markup/transform/constants.d.ts +2 -1
- package/.dist/markup/transform/effect-bindings.d.ts +2 -26
- package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
- package/.dist/markup/transform/emit.d.ts +2 -11
- package/.dist/markup/transform/expressions.d.ts +0 -35
- package/.dist/markup/transform/scan.d.ts +3 -22
- package/.dist/markup/transform/types.d.ts +15 -127
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.d.ts +1 -18
- package/.dist/markup/value.js +2 -19
- package/.dist/markup/value.js.map +1 -1
- package/.dist/mod.d.ts +3 -8
- package/.dist/mod.js +5 -5
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +3 -37
- package/.dist/remote/client/command.d.ts +3 -17
- package/.dist/remote/client/form-data.d.ts +0 -7
- package/.dist/remote/client/form-enhance.d.ts +0 -7
- package/.dist/remote/client/form-transport.d.ts +14 -20
- package/.dist/remote/client/form.d.ts +4 -24
- package/.dist/remote/client/index.d.ts +2 -1
- package/.dist/remote/client/prerender.d.ts +6 -0
- package/.dist/remote/client/query-result.d.ts +2 -14
- package/.dist/remote/client/query.d.ts +8 -48
- package/.dist/remote/client/responses.d.ts +3 -27
- package/.dist/remote/client/types.d.ts +16 -110
- package/.dist/remote/client/utils.d.ts +0 -8
- package/.dist/remote/client.d.ts +2 -2
- package/.dist/remote/client.js +2 -2
- package/.dist/remote/effect.d.ts +6 -0
- package/.dist/remote/failures.d.ts +4 -0
- package/.dist/remote/query-update.d.ts +2 -0
- package/.dist/remote/resource.d.ts +25 -0
- package/.dist/remote/server.d.ts +5 -50
- package/.dist/remote/server.js +2 -2
- package/.dist/remote/shared.d.ts +6 -145
- package/.dist/remote/shared.js +6 -127
- package/.dist/remote/shared.js.map +1 -1
- package/.dist/runtime/transform.js +26 -31
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/ast.d.ts +0 -46
- package/.dist/script-transform/imports.d.ts +3 -39
- package/.dist/script-transform/index.d.ts +2 -0
- package/.dist/script-transform/lower.d.ts +0 -9
- package/.dist/script-transform/runes.d.ts +0 -10
- package/.dist/script-transform/runtime-block.d.ts +0 -17
- package/.dist/script-transform/source.d.ts +0 -24
- package/.dist/script-transform/types.d.ts +9 -126
- package/.dist/server/effects.d.ts +4 -53
- package/.dist/server/factories.d.ts +7 -7
- package/.dist/server/index.d.ts +1 -1
- package/.dist/server/invalid.d.ts +0 -7
- package/.dist/server/live-snapshot.d.ts +5 -0
- package/.dist/server/remote-handler-context.d.ts +5 -0
- package/.dist/server/runtime.d.ts +6 -24
- package/.dist/server/schema.d.ts +0 -14
- package/.dist/server/transport.d.ts +2 -0
- package/.dist/server/types.d.ts +49 -26
- package/.dist/server/wrappers.d.ts +3 -40
- package/.dist/server.d.ts +1 -1
- package/.dist/server.js +200 -215
- package/.dist/server.js.map +1 -1
- package/.dist/yieldable.d.ts +1 -35
- package/package.json +2 -2
- package/.dist/chunks/client-DcZUV4rR.js +0 -653
- package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
- package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
- package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
- package/.dist/chunks/dispatcher-DOx8iC6r.js +0 -505
- package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
- package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
- package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
- package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
- package/.dist/chunks/live-BXAKre_4.js +0 -104
- package/.dist/chunks/live-BXAKre_4.js.map +0 -1
- package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
- package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
- package/.dist/chunks/schema-D9pct6Y5.js +0 -89
- package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
- package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
- package/.dist/chunks/source-scan-C4PsggID.js +0 -341
- package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
- package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
- package/.dist/remote/client/effect.d.ts +0 -29
- package/.dist/remote/client/failures.d.ts +0 -42
package/.dist/remote/server.d.ts
CHANGED
|
@@ -1,59 +1,14 @@
|
|
|
1
1
|
import type { FormIssue } from "./shared.js";
|
|
2
|
-
import { Effect } from "effect";
|
|
2
|
+
import { Cause, Effect } from "effect";
|
|
3
3
|
type SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;
|
|
4
4
|
type SvelteError = (status: number, body: unknown) => never;
|
|
5
5
|
export { encode_remote_failure } from "./cause-codec.js";
|
|
6
|
-
/**
|
|
7
|
-
* Runs a user-supplied Effect program through a ManagedRuntime, maps its
|
|
8
|
-
* exit into the shape expected by SvelteKit, and returns the result or
|
|
9
|
-
* throws a SvelteKit-compatible error.
|
|
10
|
-
*
|
|
11
|
-
* @since 2.0.0
|
|
12
|
-
* @param effect - The Effect program to execute.
|
|
13
|
-
* @param runtime - The server-side ManagedRuntime.
|
|
14
|
-
* @param invalid - SvelteKit's `invalid` helper (bound per-request).
|
|
15
|
-
* @param error - SvelteKit's `error` helper.
|
|
16
|
-
* @returns A Promise that resolves with the effect's success value.
|
|
17
|
-
* @internal
|
|
18
|
-
*/
|
|
6
|
+
/** Maps a remote Effect exit into the control flow expected by SvelteKit. */
|
|
19
7
|
export declare function run_remote_effect<A>(effect: Effect.Effect<A, unknown, unknown>, runtime: {
|
|
20
8
|
runPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;
|
|
21
9
|
}, invalid: SvelteInvalid, error: SvelteError): Promise<A>;
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
-
* through to the request-scoped `invalid` helper.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* throw_form_error(
|
|
29
|
-
* [{ message: "Name is required", path: ["name"] }],
|
|
30
|
-
* invalid,
|
|
31
|
-
* );
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @since 2.0.0
|
|
35
|
-
* @param issues - The list of form validation issues.
|
|
36
|
-
* @param invalid - SvelteKit's `invalid` helper bound to the current request.
|
|
37
|
-
* @internal
|
|
38
|
-
*/
|
|
10
|
+
/** Applies a classified remote Cause decision to SvelteKit's server helpers. */
|
|
11
|
+
export declare function throw_remote_cause(cause: Cause.Cause<unknown>, invalid: SvelteInvalid, error: SvelteError): never;
|
|
39
12
|
export declare function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never;
|
|
40
|
-
/**
|
|
41
|
-
* Remaps SvelteKit's unbranded request-context errors into clear, actionable
|
|
42
|
-
* messages.
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* ```ts
|
|
46
|
-
* try {
|
|
47
|
-
* return native_query(handler);
|
|
48
|
-
* } catch (err) {
|
|
49
|
-
* throw normalize_remote_helper_error(err, "Query");
|
|
50
|
-
* }
|
|
51
|
-
* ```
|
|
52
|
-
*
|
|
53
|
-
* @since 2.0.0
|
|
54
|
-
* @param err - The error thrown by SvelteKit's native functions.
|
|
55
|
-
* @param helper_name - Name of the helper that triggered the error.
|
|
56
|
-
* @returns A more descriptive error.
|
|
57
|
-
* @internal
|
|
58
|
-
*/
|
|
13
|
+
/** Rebrands SvelteKit context failures with the remote helper that triggered them. */
|
|
59
14
|
export declare function normalize_remote_helper_error(err: unknown, helper_name: string): Error;
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
|
|
1
|
+
import { a as encode_remote_failure, i as throw_remote_cause, n as run_remote_effect, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-yQrNoiCR.js";
|
|
2
|
+
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause };
|
package/.dist/remote/shared.d.ts
CHANGED
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* @since 2.0.0
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* Well-known marker injected into every serialised remote-failure envelope
|
|
10
|
-
* so the client can reliably distinguish runtime errors from domain values.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* ```ts
|
|
14
|
-
* if (envelope[EFFECT_REMOTE_ERROR_MARKER] === true) {
|
|
15
|
-
* console.log(envelope.encoded);
|
|
16
|
-
* }
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* @since 2.0.0
|
|
20
|
-
* @internal
|
|
21
|
-
*/
|
|
22
|
-
export declare const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
23
|
-
/**
|
|
24
|
-
* Well-known symbol used to attach a payload decoder to a remote function
|
|
25
|
-
* so the client's transport layer can decode domain error types.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* Reflect.get(remote_function, REMOTE_ERROR_DECODER);
|
|
30
|
-
* ```
|
|
31
|
-
*
|
|
32
|
-
* @since 2.0.0
|
|
33
|
-
* @internal
|
|
34
|
-
*/
|
|
35
|
-
export declare const REMOTE_ERROR_DECODER: unique symbol;
|
|
36
|
-
/** Form validation helpers and types. */
|
|
1
|
+
/** Remote error wire protocol shared by client and server adapters. */
|
|
2
|
+
/** Shared marker used to recognize remote errors across package copies. */
|
|
3
|
+
export declare const effect_remote_error_marker = "__svelte_effect_remote__";
|
|
4
|
+
/** Decodes the shared remote-error marker without relying on class identity. */
|
|
5
|
+
export declare const remote_error_decoder: unique symbol;
|
|
37
6
|
/**
|
|
38
7
|
* A single field-level or form-level validation issue reported by a
|
|
39
8
|
* {@link Form} handler.
|
|
@@ -75,20 +44,6 @@ export interface FormError<SchemaType = unknown> {
|
|
|
75
44
|
/** Phantom type slot for the schema this error was derived from. */
|
|
76
45
|
readonly _schema?: SchemaType;
|
|
77
46
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Creates a {@link FormError} holding the given issues.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* ```ts
|
|
83
|
-
* const error = create_form_error([
|
|
84
|
-
* { message: "Required.", path: ["email"] },
|
|
85
|
-
* ]);
|
|
86
|
-
* ```
|
|
87
|
-
*
|
|
88
|
-
* @since 2.0.0
|
|
89
|
-
* @param issues - The validation issues to attach.
|
|
90
|
-
* @returns A FormError with the `_tag` set and no schema reference.
|
|
91
|
-
*/
|
|
92
47
|
export declare function create_form_error(issues: readonly FormIssue[]): FormError;
|
|
93
48
|
/**
|
|
94
49
|
* Type guard that narrows an unknown value to a {@link FormError}.
|
|
@@ -105,15 +60,13 @@ export declare function create_form_error(issues: readonly FormIssue[]): FormErr
|
|
|
105
60
|
* @returns `true` when the value is a FormError.
|
|
106
61
|
*/
|
|
107
62
|
export declare function is_form_error(value: unknown): value is FormError;
|
|
108
|
-
/** Remote error types shared by client and server helpers. */
|
|
109
63
|
/**
|
|
110
64
|
* Union of all wire-level error shapes that a remote function can
|
|
111
65
|
* surface on its error channel.
|
|
112
66
|
*
|
|
113
67
|
* @example
|
|
114
68
|
* ```ts
|
|
115
|
-
* const result =
|
|
116
|
-
* // error channel is RemoteFailure<DomainError>
|
|
69
|
+
* const result: Effect.Effect<User, RemoteFailure<DomainError>> = myQuery();
|
|
117
70
|
* ```
|
|
118
71
|
*
|
|
119
72
|
* @since 2.0.0
|
|
@@ -180,106 +133,14 @@ export interface RemoteTransportError {
|
|
|
180
133
|
readonly cause?: unknown;
|
|
181
134
|
readonly body?: unknown;
|
|
182
135
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Wire format for an encoded remote failure. The server wraps domain
|
|
185
|
-
* errors in this envelope before serialising them with devalue.
|
|
186
|
-
*
|
|
187
|
-
* @example
|
|
188
|
-
* ```ts
|
|
189
|
-
* const envelope: SerializedRemoteFailureEnvelope = {
|
|
190
|
-
* __svelte_effect_remote__: true,
|
|
191
|
-
* encoded: "[\"DomainError\"]",
|
|
192
|
-
* };
|
|
193
|
-
* ```
|
|
194
|
-
*
|
|
195
|
-
* @since 2.0.0
|
|
196
|
-
* @internal
|
|
197
|
-
*/
|
|
198
136
|
export interface SerializedRemoteFailureEnvelope {
|
|
199
137
|
readonly __svelte_effect_remote__: true;
|
|
200
138
|
readonly encoded: string;
|
|
201
139
|
}
|
|
202
|
-
/** Constructors for structured remote error values. */
|
|
203
|
-
/**
|
|
204
|
-
* Creates a {@link RemoteValidationError} from a list of form issues.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* const error = create_remote_validation_error([
|
|
209
|
-
* { message: "Required.", path: ["email"] },
|
|
210
|
-
* ]);
|
|
211
|
-
* ```
|
|
212
|
-
*
|
|
213
|
-
* @since 2.0.0
|
|
214
|
-
* @param issues - The validation issues reported by the server handler.
|
|
215
|
-
* @param body - Optional response body returned alongside the error.
|
|
216
|
-
* @param status - HTTP status code (defaults to 400).
|
|
217
|
-
* @returns A remote-validation error shape.
|
|
218
|
-
* @internal
|
|
219
|
-
*/
|
|
220
140
|
export declare function create_remote_validation_error(issues: readonly FormIssue[], body?: unknown, status?: number): RemoteValidationError;
|
|
221
|
-
/**
|
|
222
|
-
* Creates a {@link RemoteHttpError} for a given HTTP status.
|
|
223
|
-
*
|
|
224
|
-
* @example
|
|
225
|
-
* ```ts
|
|
226
|
-
* const error = create_remote_http_error(404, { message: "Not found" });
|
|
227
|
-
* ```
|
|
228
|
-
*
|
|
229
|
-
* @since 2.0.0
|
|
230
|
-
* @param status - The HTTP status code.
|
|
231
|
-
* @param body - Optional response body.
|
|
232
|
-
* @param cause - Optional underlying cause.
|
|
233
|
-
* @returns A remote HTTP error shape.
|
|
234
|
-
* @internal
|
|
235
|
-
*/
|
|
236
141
|
export declare function create_remote_http_error(status: number, body?: unknown, cause?: unknown): RemoteHttpError;
|
|
237
|
-
/**
|
|
238
|
-
* Creates a {@link RemoteTransportError} for network or decode failures.
|
|
239
|
-
*
|
|
240
|
-
* @example
|
|
241
|
-
* ```ts
|
|
242
|
-
* const error = create_remote_transport_error(new Error("Network unavailable"));
|
|
243
|
-
* ```
|
|
244
|
-
*
|
|
245
|
-
* @since 2.0.0
|
|
246
|
-
* @param cause - The underlying error that caused the transport failure.
|
|
247
|
-
* @param body - Optional response body if one was received.
|
|
248
|
-
* @returns A remote transport error shape.
|
|
249
|
-
* @internal
|
|
250
|
-
*/
|
|
251
142
|
export declare function create_remote_transport_error(cause: unknown, body?: unknown): RemoteTransportError;
|
|
252
|
-
/**
|
|
253
|
-
* Wraps a devalue-encoded error string inside a
|
|
254
|
-
* {@link SerializedRemoteFailureEnvelope}.
|
|
255
|
-
*
|
|
256
|
-
* @example
|
|
257
|
-
* ```ts
|
|
258
|
-
* const envelope = create_serialized_remote_failure_envelope(encoded);
|
|
259
|
-
* ```
|
|
260
|
-
*
|
|
261
|
-
* @since 2.0.0
|
|
262
|
-
* @param encoded - The devalue-encoded error value.
|
|
263
|
-
* @returns The wire-format envelope.
|
|
264
|
-
* @internal
|
|
265
|
-
*/
|
|
266
143
|
export declare function create_serialized_remote_failure_envelope(encoded: string): SerializedRemoteFailureEnvelope;
|
|
267
|
-
/** Type guards for structured remote error values. */
|
|
268
|
-
/**
|
|
269
|
-
* Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.
|
|
270
|
-
*
|
|
271
|
-
* @example
|
|
272
|
-
* ```ts
|
|
273
|
-
* if (is_serialized_remote_failure_envelope(value)) {
|
|
274
|
-
* console.log(value.encoded);
|
|
275
|
-
* }
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* @since 2.0.0
|
|
279
|
-
* @param value - The value to check.
|
|
280
|
-
* @returns `true` when the value is a serialised failure envelope.
|
|
281
|
-
* @internal
|
|
282
|
-
*/
|
|
283
144
|
export declare function is_serialized_remote_failure_envelope(value: unknown): value is SerializedRemoteFailureEnvelope;
|
|
284
145
|
/**
|
|
285
146
|
* Checks whether a value is a {@link RemoteValidationError}.
|
package/.dist/remote/shared.js
CHANGED
|
@@ -1,54 +1,10 @@
|
|
|
1
1
|
import { Schema } from "effect";
|
|
2
2
|
//#region src/remote/shared.ts
|
|
3
|
-
/**
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
* @since 2.0.0
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Well-known marker injected into every serialised remote-failure envelope
|
|
12
|
-
* so the client can reliably distinguish runtime errors from domain values.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* if (envelope[EFFECT_REMOTE_ERROR_MARKER] === true) {
|
|
17
|
-
* console.log(envelope.encoded);
|
|
18
|
-
* }
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @since 2.0.0
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
25
|
-
/**
|
|
26
|
-
* Well-known symbol used to attach a payload decoder to a remote function
|
|
27
|
-
* so the client's transport layer can decode domain error types.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* Reflect.get(remote_function, REMOTE_ERROR_DECODER);
|
|
32
|
-
* ```
|
|
33
|
-
*
|
|
34
|
-
* @since 2.0.0
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
const REMOTE_ERROR_DECODER = Symbol.for("svelte-effect-runtime/remote-error-decoder");
|
|
38
|
-
/**
|
|
39
|
-
* Creates a {@link FormError} holding the given issues.
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* ```ts
|
|
43
|
-
* const error = create_form_error([
|
|
44
|
-
* { message: "Required.", path: ["email"] },
|
|
45
|
-
* ]);
|
|
46
|
-
* ```
|
|
47
|
-
*
|
|
48
|
-
* @since 2.0.0
|
|
49
|
-
* @param issues - The validation issues to attach.
|
|
50
|
-
* @returns A FormError with the `_tag` set and no schema reference.
|
|
51
|
-
*/
|
|
3
|
+
/** Remote error wire protocol shared by client and server adapters. */
|
|
4
|
+
/** Shared marker used to recognize remote errors across package copies. */
|
|
5
|
+
const effect_remote_error_marker = "__svelte_effect_remote__";
|
|
6
|
+
/** Decodes the shared remote-error marker without relying on class identity. */
|
|
7
|
+
const remote_error_decoder = Symbol.for("svelte-effect-runtime/remote-error-decoder");
|
|
52
8
|
function create_form_error(issues) {
|
|
53
9
|
return {
|
|
54
10
|
_tag: "FormError",
|
|
@@ -107,24 +63,6 @@ const is_remote_http_error_value = Schema.is(RemoteHttpErrorSchema);
|
|
|
107
63
|
const is_remote_transport_error_value = Schema.is(RemoteTransportErrorSchema);
|
|
108
64
|
const is_remote_validation_error_value = Schema.is(RemoteValidationErrorSchema);
|
|
109
65
|
const is_serialized_remote_failure_envelope_value = Schema.is(SerializedRemoteFailureEnvelopeSchema);
|
|
110
|
-
/** Constructors for structured remote error values. */
|
|
111
|
-
/**
|
|
112
|
-
* Creates a {@link RemoteValidationError} from a list of form issues.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* const error = create_remote_validation_error([
|
|
117
|
-
* { message: "Required.", path: ["email"] },
|
|
118
|
-
* ]);
|
|
119
|
-
* ```
|
|
120
|
-
*
|
|
121
|
-
* @since 2.0.0
|
|
122
|
-
* @param issues - The validation issues reported by the server handler.
|
|
123
|
-
* @param body - Optional response body returned alongside the error.
|
|
124
|
-
* @param status - HTTP status code (defaults to 400).
|
|
125
|
-
* @returns A remote-validation error shape.
|
|
126
|
-
* @internal
|
|
127
|
-
*/
|
|
128
66
|
function create_remote_validation_error(issues, body, status = 400) {
|
|
129
67
|
return {
|
|
130
68
|
_tag: "RemoteValidationError",
|
|
@@ -133,21 +71,6 @@ function create_remote_validation_error(issues, body, status = 400) {
|
|
|
133
71
|
status
|
|
134
72
|
};
|
|
135
73
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Creates a {@link RemoteHttpError} for a given HTTP status.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* ```ts
|
|
141
|
-
* const error = create_remote_http_error(404, { message: "Not found" });
|
|
142
|
-
* ```
|
|
143
|
-
*
|
|
144
|
-
* @since 2.0.0
|
|
145
|
-
* @param status - The HTTP status code.
|
|
146
|
-
* @param body - Optional response body.
|
|
147
|
-
* @param cause - Optional underlying cause.
|
|
148
|
-
* @returns A remote HTTP error shape.
|
|
149
|
-
* @internal
|
|
150
|
-
*/
|
|
151
74
|
function create_remote_http_error(status, body, cause) {
|
|
152
75
|
return {
|
|
153
76
|
_tag: "RemoteHttpError",
|
|
@@ -156,20 +79,6 @@ function create_remote_http_error(status, body, cause) {
|
|
|
156
79
|
cause
|
|
157
80
|
};
|
|
158
81
|
}
|
|
159
|
-
/**
|
|
160
|
-
* Creates a {@link RemoteTransportError} for network or decode failures.
|
|
161
|
-
*
|
|
162
|
-
* @example
|
|
163
|
-
* ```ts
|
|
164
|
-
* const error = create_remote_transport_error(new Error("Network unavailable"));
|
|
165
|
-
* ```
|
|
166
|
-
*
|
|
167
|
-
* @since 2.0.0
|
|
168
|
-
* @param cause - The underlying error that caused the transport failure.
|
|
169
|
-
* @param body - Optional response body if one was received.
|
|
170
|
-
* @returns A remote transport error shape.
|
|
171
|
-
* @internal
|
|
172
|
-
*/
|
|
173
82
|
function create_remote_transport_error(cause, body) {
|
|
174
83
|
return {
|
|
175
84
|
_tag: "RemoteTransportError",
|
|
@@ -177,42 +86,12 @@ function create_remote_transport_error(cause, body) {
|
|
|
177
86
|
body
|
|
178
87
|
};
|
|
179
88
|
}
|
|
180
|
-
/**
|
|
181
|
-
* Wraps a devalue-encoded error string inside a
|
|
182
|
-
* {@link SerializedRemoteFailureEnvelope}.
|
|
183
|
-
*
|
|
184
|
-
* @example
|
|
185
|
-
* ```ts
|
|
186
|
-
* const envelope = create_serialized_remote_failure_envelope(encoded);
|
|
187
|
-
* ```
|
|
188
|
-
*
|
|
189
|
-
* @since 2.0.0
|
|
190
|
-
* @param encoded - The devalue-encoded error value.
|
|
191
|
-
* @returns The wire-format envelope.
|
|
192
|
-
* @internal
|
|
193
|
-
*/
|
|
194
89
|
function create_serialized_remote_failure_envelope(encoded) {
|
|
195
90
|
return {
|
|
196
91
|
__svelte_effect_remote__: true,
|
|
197
92
|
encoded
|
|
198
93
|
};
|
|
199
94
|
}
|
|
200
|
-
/** Type guards for structured remote error values. */
|
|
201
|
-
/**
|
|
202
|
-
* Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* ```ts
|
|
206
|
-
* if (is_serialized_remote_failure_envelope(value)) {
|
|
207
|
-
* console.log(value.encoded);
|
|
208
|
-
* }
|
|
209
|
-
* ```
|
|
210
|
-
*
|
|
211
|
-
* @since 2.0.0
|
|
212
|
-
* @param value - The value to check.
|
|
213
|
-
* @returns `true` when the value is a serialised failure envelope.
|
|
214
|
-
* @internal
|
|
215
|
-
*/
|
|
216
95
|
function is_serialized_remote_failure_envelope(value) {
|
|
217
96
|
return is_serialized_remote_failure_envelope_value(value);
|
|
218
97
|
}
|
|
@@ -268,6 +147,6 @@ function is_remote_transport_error(value) {
|
|
|
268
147
|
return is_remote_transport_error_value(value);
|
|
269
148
|
}
|
|
270
149
|
//#endregion
|
|
271
|
-
export {
|
|
150
|
+
export { create_form_error, create_remote_http_error, create_remote_transport_error, create_remote_validation_error, create_serialized_remote_failure_envelope, effect_remote_error_marker, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, is_serialized_remote_failure_envelope, remote_error_decoder };
|
|
272
151
|
|
|
273
152
|
//# sourceMappingURL=shared.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/**\n * Shared types, markers, and constructors used by both the client-side remote\n * adapters and the server-side handler runtime. These types define the error\n * protocol that flows across the network boundary.\n *\n * @since 2.0.0\n */\n\n/**\n * Well-known marker injected into every serialised remote-failure envelope\n * so the client can reliably distinguish runtime errors from domain values.\n *\n * @example\n * ```ts\n * if (envelope[EFFECT_REMOTE_ERROR_MARKER] === true) {\n * console.log(envelope.encoded);\n * }\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\n\n/**\n * Well-known symbol used to attach a payload decoder to a remote function\n * so the client's transport layer can decode domain error types.\n *\n * @example\n * ```ts\n * Reflect.get(remote_function, REMOTE_ERROR_DECODER);\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport const REMOTE_ERROR_DECODER = Symbol.for(\"svelte-effect-runtime/remote-error-decoder\");\n\n/** Form validation helpers and types. */\n\n/**\n * A single field-level or form-level validation issue reported by a\n * {@link Form} handler.\n *\n * @example\n * ```ts\n * const issue: FormIssue = {\n * message: \"Use an email address.\",\n * path: [\"email\"],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface FormIssue {\n\t/** Human-readable validation message. */\n\tmessage: string;\n\t/** Path to the offending field as an array of string-or-number keys. */\n\tpath: (string | number)[];\n}\n\n/**\n * Error subtype thrown by {@link Form} handlers to signal validation\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\n * helper on the server and surfaced as `FormError` on the client.\n *\n * @example\n * ```ts\n * const error: FormError = {\n * _tag: \"FormError\",\n * issues: [{ message: \"Required.\", path: [\"email\"] }],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface FormError<SchemaType = unknown> {\n\treadonly _tag: \"FormError\";\n\treadonly issues: readonly FormIssue[];\n\t/** Phantom type slot for the schema this error was derived from. */\n\treadonly _schema?: SchemaType;\n}\n\n/**\n * Creates a {@link FormError} holding the given issues.\n *\n * @example\n * ```ts\n * const error = create_form_error([\n * { message: \"Required.\", path: [\"email\"] },\n * ]);\n * ```\n *\n * @since 2.0.0\n * @param issues - The validation issues to attach.\n * @returns A FormError with the `_tag` set and no schema reference.\n */\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\n\treturn { _tag: \"FormError\", issues };\n}\n\n/**\n * Type guard that narrows an unknown value to a {@link FormError}.\n *\n * @example\n * ```ts\n * if (is_form_error(error)) {\n * console.log(error.issues);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a FormError.\n */\nexport function is_form_error(value: unknown): value is FormError {\n\treturn is_form_error_value(value);\n}\n\n/** Remote error types shared by client and server helpers. */\n\n/**\n * Union of all wire-level error shapes that a remote function can\n * surface on its error channel.\n *\n * @example\n * ```ts\n * const result = yield* myQuery();\n * // error channel is RemoteFailure<DomainError>\n * ```\n *\n * @since 2.0.0\n */\nexport type RemoteFailure<ErrorType> =\n\t| ErrorType\n\t| RemoteValidationError\n\t| RemoteHttpError\n\t| RemoteTransportError;\n\n/**\n * Validation errors that originate from a server-side {@link Form}\n * handler calling `invalid()` (SvelteKit's `fail`).\n *\n * @example\n * ```ts\n * const error: RemoteValidationError = {\n * _tag: \"RemoteValidationError\",\n * status: 400,\n * issues: [{ message: \"Required.\", path: [\"email\"] }],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteValidationError {\n\treadonly _tag: \"RemoteValidationError\";\n\treadonly issues?: readonly FormIssue[];\n\treadonly body?: unknown;\n\treadonly status: number;\n}\n\n/**\n * HTTP-level errors with a status code and optional response body. Raised\n * when the server explicitly calls SvelteKit's `error(status, body)`.\n *\n * @example\n * ```ts\n * const error: RemoteHttpError = {\n * _tag: \"RemoteHttpError\",\n * status: 404,\n * body: { message: \"Not found\" },\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteHttpError {\n\treadonly _tag: \"RemoteHttpError\";\n\treadonly status: number;\n\treadonly body?: unknown;\n\treadonly cause?: unknown;\n}\n\n/**\n * Transport-level errors raised by the client adapter when the network\n * request fails or the response cannot be decoded.\n *\n * @example\n * ```ts\n * const error: RemoteTransportError = {\n * _tag: \"RemoteTransportError\",\n * cause: new Error(\"Network unavailable\"),\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteTransportError {\n\treadonly _tag: \"RemoteTransportError\";\n\treadonly cause?: unknown;\n\treadonly body?: unknown;\n}\n\n/**\n * Wire format for an encoded remote failure. The server wraps domain\n * errors in this envelope before serialising them with devalue.\n *\n * @example\n * ```ts\n * const envelope: SerializedRemoteFailureEnvelope = {\n * __svelte_effect_remote__: true,\n * encoded: \"[\\\"DomainError\\\"]\",\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface SerializedRemoteFailureEnvelope {\n\treadonly __svelte_effect_remote__: true;\n\treadonly encoded: string;\n}\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst FormErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"FormError\"),\n\tissues: Schema.Array(FormIssueSchema),\n});\n\nconst SerializedRemoteFailureEnvelopeSchema = Schema.Struct({\n\t__svelte_effect_remote__: Schema.Literal(true),\n\tencoded: Schema.String,\n});\n\nconst RemoteValidationErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteValidationError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tstatus: Schema.Number,\n});\n\nconst RemoteHttpErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteHttpError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tcause: Schema.optional(Schema.Unknown),\n\tstatus: Schema.Number,\n});\n\nconst RemoteTransportErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteTransportError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tcause: Schema.optional(Schema.Unknown),\n});\n\nconst is_form_error_value = Schema.is(FormErrorSchema);\nconst is_remote_http_error_value = Schema.is(RemoteHttpErrorSchema);\nconst is_remote_transport_error_value = Schema.is(RemoteTransportErrorSchema);\nconst is_remote_validation_error_value = Schema.is(RemoteValidationErrorSchema);\nconst is_serialized_remote_failure_envelope_value = Schema.is(\n\tSerializedRemoteFailureEnvelopeSchema,\n);\n\n/** Constructors for structured remote error values. */\n\n/**\n * Creates a {@link RemoteValidationError} from a list of form issues.\n *\n * @example\n * ```ts\n * const error = create_remote_validation_error([\n * { message: \"Required.\", path: [\"email\"] },\n * ]);\n * ```\n *\n * @since 2.0.0\n * @param issues - The validation issues reported by the server handler.\n * @param body - Optional response body returned alongside the error.\n * @param status - HTTP status code (defaults to 400).\n * @returns A remote-validation error shape.\n * @internal\n */\nexport function create_remote_validation_error(\n\tissues: readonly FormIssue[],\n\tbody?: unknown,\n\tstatus = 400,\n): RemoteValidationError {\n\treturn { _tag: \"RemoteValidationError\", issues, body, status };\n}\n\n/**\n * Creates a {@link RemoteHttpError} for a given HTTP status.\n *\n * @example\n * ```ts\n * const error = create_remote_http_error(404, { message: \"Not found\" });\n * ```\n *\n * @since 2.0.0\n * @param status - The HTTP status code.\n * @param body - Optional response body.\n * @param cause - Optional underlying cause.\n * @returns A remote HTTP error shape.\n * @internal\n */\nexport function create_remote_http_error(\n\tstatus: number,\n\tbody?: unknown,\n\tcause?: unknown,\n): RemoteHttpError {\n\treturn { _tag: \"RemoteHttpError\", status, body, cause };\n}\n\n/**\n * Creates a {@link RemoteTransportError} for network or decode failures.\n *\n * @example\n * ```ts\n * const error = create_remote_transport_error(new Error(\"Network unavailable\"));\n * ```\n *\n * @since 2.0.0\n * @param cause - The underlying error that caused the transport failure.\n * @param body - Optional response body if one was received.\n * @returns A remote transport error shape.\n * @internal\n */\nexport function create_remote_transport_error(\n\tcause: unknown,\n\tbody?: unknown,\n): RemoteTransportError {\n\treturn { _tag: \"RemoteTransportError\", cause, body };\n}\n\n/**\n * Wraps a devalue-encoded error string inside a\n * {@link SerializedRemoteFailureEnvelope}.\n *\n * @example\n * ```ts\n * const envelope = create_serialized_remote_failure_envelope(encoded);\n * ```\n *\n * @since 2.0.0\n * @param encoded - The devalue-encoded error value.\n * @returns The wire-format envelope.\n * @internal\n */\nexport function create_serialized_remote_failure_envelope(\n\tencoded: string,\n): SerializedRemoteFailureEnvelope {\n\treturn { __svelte_effect_remote__: true, encoded };\n}\n\n/** Type guards for structured remote error values. */\n\n/**\n * Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.\n *\n * @example\n * ```ts\n * if (is_serialized_remote_failure_envelope(value)) {\n * console.log(value.encoded);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a serialised failure envelope.\n * @internal\n */\nexport function is_serialized_remote_failure_envelope(\n\tvalue: unknown,\n): value is SerializedRemoteFailureEnvelope {\n\treturn is_serialized_remote_failure_envelope_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteValidationError}.\n *\n * @example\n * ```ts\n * if (is_remote_validation_error(error)) {\n * console.log(error.issues);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote validation error.\n */\nexport function is_remote_validation_error(value: unknown): value is RemoteValidationError {\n\treturn is_remote_validation_error_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteHttpError}.\n *\n * @example\n * ```ts\n * if (is_remote_http_error(error)) {\n * console.log(error.status);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote HTTP error.\n */\nexport function is_remote_http_error(value: unknown): value is RemoteHttpError {\n\treturn is_remote_http_error_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteTransportError}.\n *\n * @example\n * ```ts\n * if (is_remote_transport_error(error)) {\n * console.error(error.cause);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote transport error.\n */\nexport function is_remote_transport_error(value: unknown): value is RemoteTransportError {\n\treturn is_remote_transport_error_value(value);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAwBA,MAAa,6BAA6B;;;;;;;;;;;;;AAc1C,MAAa,uBAAuB,OAAO,IAAI,4CAA4C;;;;;;;;;;;;;;;AA6D3F,SAAgB,kBAAkB,QAAyC;CAC1E,OAAO;EAAE,MAAM;EAAa;CAAO;AACpC;;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,OAAoC;CACjE,OAAO,oBAAoB,KAAK;AACjC;AA0GA,MAAM,6BAA6B,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAE9E,MAAM,kBAAkB,OAAO,OAAO;CACrC,SAAS,OAAO;CAChB,MAAM,OAAO,MAAM,0BAA0B;AAC9C,CAAC;AAED,MAAM,kBAAkB,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,WAAW;CAChC,QAAQ,OAAO,MAAM,eAAe;AACrC,CAAC;AAED,MAAM,wCAAwC,OAAO,OAAO;CAC3D,0BAA0B,OAAO,QAAQ,IAAI;CAC7C,SAAS,OAAO;AACjB,CAAC;AAED,MAAM,8BAA8B,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,uBAAuB;CAC5C,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,QAAQ,OAAO,SAAS,OAAO,MAAM,eAAe,CAAC;CACrD,QAAQ,OAAO;AAChB,CAAC;AAED,MAAM,wBAAwB,OAAO,OAAO;CAC3C,MAAM,OAAO,QAAQ,iBAAiB;CACtC,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,QAAQ,OAAO;AAChB,CAAC;AAED,MAAM,6BAA6B,OAAO,OAAO;CAChD,MAAM,OAAO,QAAQ,sBAAsB;CAC3C,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;AACtC,CAAC;AAED,MAAM,sBAAsB,OAAO,GAAG,eAAe;AACrD,MAAM,6BAA6B,OAAO,GAAG,qBAAqB;AAClE,MAAM,kCAAkC,OAAO,GAAG,0BAA0B;AAC5E,MAAM,mCAAmC,OAAO,GAAG,2BAA2B;AAC9E,MAAM,8CAA8C,OAAO,GAC1D,qCACD;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,+BACf,QACA,MACA,SAAS,KACe;CACxB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC9D;;;;;;;;;;;;;;;;AAiBA,SAAgB,yBACf,QACA,MACA,OACkB;CAClB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACvD;;;;;;;;;;;;;;;AAgBA,SAAgB,8BACf,OACA,MACuB;CACvB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACpD;;;;;;;;;;;;;;;AAgBA,SAAgB,0CACf,SACkC;CAClC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AAClD;;;;;;;;;;;;;;;;;AAmBA,SAAgB,sCACf,OAC2C;CAC3C,OAAO,4CAA4C,KAAK;AACzD;;;;;;;;;;;;;;;AAgBA,SAAgB,2BAA2B,OAAgD;CAC1F,OAAO,iCAAiC,KAAK;AAC9C;;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAA0C;CAC9E,OAAO,2BAA2B,KAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,0BAA0B,OAA+C;CACxF,OAAO,gCAAgC,KAAK;AAC7C"}
|
|
1
|
+
{"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\n/** Remote error wire protocol shared by client and server adapters. */\n\n/** Shared marker used to recognize remote errors across package copies. */\nexport const effect_remote_error_marker = \"__svelte_effect_remote__\";\n\n/** Decodes the shared remote-error marker without relying on class identity. */\nexport const remote_error_decoder = Symbol.for(\"svelte-effect-runtime/remote-error-decoder\");\n\n/**\n * A single field-level or form-level validation issue reported by a\n * {@link Form} handler.\n *\n * @example\n * ```ts\n * const issue: FormIssue = {\n * message: \"Use an email address.\",\n * path: [\"email\"],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface FormIssue {\n\t/** Human-readable validation message. */\n\tmessage: string;\n\t/** Path to the offending field as an array of string-or-number keys. */\n\tpath: (string | number)[];\n}\n\n/**\n * Error subtype thrown by {@link Form} handlers to signal validation\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\n * helper on the server and surfaced as `FormError` on the client.\n *\n * @example\n * ```ts\n * const error: FormError = {\n * _tag: \"FormError\",\n * issues: [{ message: \"Required.\", path: [\"email\"] }],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface FormError<SchemaType = unknown> {\n\treadonly _tag: \"FormError\";\n\treadonly issues: readonly FormIssue[];\n\t/** Phantom type slot for the schema this error was derived from. */\n\treadonly _schema?: SchemaType;\n}\n\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\n\treturn { _tag: \"FormError\", issues };\n}\n\n/**\n * Type guard that narrows an unknown value to a {@link FormError}.\n *\n * @example\n * ```ts\n * if (is_form_error(error)) {\n * console.log(error.issues);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a FormError.\n */\nexport function is_form_error(value: unknown): value is FormError {\n\treturn is_form_error_value(value);\n}\n\n/**\n * Union of all wire-level error shapes that a remote function can\n * surface on its error channel.\n *\n * @example\n * ```ts\n * const result: Effect.Effect<User, RemoteFailure<DomainError>> = myQuery();\n * ```\n *\n * @since 2.0.0\n */\nexport type RemoteFailure<ErrorType> =\n\t| ErrorType\n\t| RemoteValidationError\n\t| RemoteHttpError\n\t| RemoteTransportError;\n\n/**\n * Validation errors that originate from a server-side {@link Form}\n * handler calling `invalid()` (SvelteKit's `fail`).\n *\n * @example\n * ```ts\n * const error: RemoteValidationError = {\n * _tag: \"RemoteValidationError\",\n * status: 400,\n * issues: [{ message: \"Required.\", path: [\"email\"] }],\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteValidationError {\n\treadonly _tag: \"RemoteValidationError\";\n\treadonly issues?: readonly FormIssue[];\n\treadonly body?: unknown;\n\treadonly status: number;\n}\n\n/**\n * HTTP-level errors with a status code and optional response body. Raised\n * when the server explicitly calls SvelteKit's `error(status, body)`.\n *\n * @example\n * ```ts\n * const error: RemoteHttpError = {\n * _tag: \"RemoteHttpError\",\n * status: 404,\n * body: { message: \"Not found\" },\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteHttpError {\n\treadonly _tag: \"RemoteHttpError\";\n\treadonly status: number;\n\treadonly body?: unknown;\n\treadonly cause?: unknown;\n}\n\n/**\n * Transport-level errors raised by the client adapter when the network\n * request fails or the response cannot be decoded.\n *\n * @example\n * ```ts\n * const error: RemoteTransportError = {\n * _tag: \"RemoteTransportError\",\n * cause: new Error(\"Network unavailable\"),\n * };\n * ```\n *\n * @since 2.0.0\n */\nexport interface RemoteTransportError {\n\treadonly _tag: \"RemoteTransportError\";\n\treadonly cause?: unknown;\n\treadonly body?: unknown;\n}\n\nexport interface SerializedRemoteFailureEnvelope {\n\treadonly __svelte_effect_remote__: true;\n\treadonly encoded: string;\n}\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst FormErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"FormError\"),\n\tissues: Schema.Array(FormIssueSchema),\n});\n\nconst SerializedRemoteFailureEnvelopeSchema = Schema.Struct({\n\t__svelte_effect_remote__: Schema.Literal(true),\n\tencoded: Schema.String,\n});\n\nconst RemoteValidationErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteValidationError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tstatus: Schema.Number,\n});\n\nconst RemoteHttpErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteHttpError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tcause: Schema.optional(Schema.Unknown),\n\tstatus: Schema.Number,\n});\n\nconst RemoteTransportErrorSchema = Schema.Struct({\n\t_tag: Schema.Literal(\"RemoteTransportError\"),\n\tbody: Schema.optional(Schema.Unknown),\n\tcause: Schema.optional(Schema.Unknown),\n});\n\nconst is_form_error_value = Schema.is(FormErrorSchema);\nconst is_remote_http_error_value = Schema.is(RemoteHttpErrorSchema);\nconst is_remote_transport_error_value = Schema.is(RemoteTransportErrorSchema);\nconst is_remote_validation_error_value = Schema.is(RemoteValidationErrorSchema);\nconst is_serialized_remote_failure_envelope_value = Schema.is(\n\tSerializedRemoteFailureEnvelopeSchema,\n);\n\nexport function create_remote_validation_error(\n\tissues: readonly FormIssue[],\n\tbody?: unknown,\n\tstatus = 400,\n): RemoteValidationError {\n\treturn { _tag: \"RemoteValidationError\", issues, body, status };\n}\n\nexport function create_remote_http_error(\n\tstatus: number,\n\tbody?: unknown,\n\tcause?: unknown,\n): RemoteHttpError {\n\treturn { _tag: \"RemoteHttpError\", status, body, cause };\n}\n\nexport function create_remote_transport_error(\n\tcause: unknown,\n\tbody?: unknown,\n): RemoteTransportError {\n\treturn { _tag: \"RemoteTransportError\", cause, body };\n}\n\nexport function create_serialized_remote_failure_envelope(\n\tencoded: string,\n): SerializedRemoteFailureEnvelope {\n\treturn { __svelte_effect_remote__: true, encoded };\n}\n\nexport function is_serialized_remote_failure_envelope(\n\tvalue: unknown,\n): value is SerializedRemoteFailureEnvelope {\n\treturn is_serialized_remote_failure_envelope_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteValidationError}.\n *\n * @example\n * ```ts\n * if (is_remote_validation_error(error)) {\n * console.log(error.issues);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote validation error.\n */\nexport function is_remote_validation_error(value: unknown): value is RemoteValidationError {\n\treturn is_remote_validation_error_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteHttpError}.\n *\n * @example\n * ```ts\n * if (is_remote_http_error(error)) {\n * console.log(error.status);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote HTTP error.\n */\nexport function is_remote_http_error(value: unknown): value is RemoteHttpError {\n\treturn is_remote_http_error_value(value);\n}\n\n/**\n * Checks whether a value is a {@link RemoteTransportError}.\n *\n * @example\n * ```ts\n * if (is_remote_transport_error(error)) {\n * console.error(error.cause);\n * }\n * ```\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote transport error.\n */\nexport function is_remote_transport_error(value: unknown): value is RemoteTransportError {\n\treturn is_remote_transport_error_value(value);\n}\n"],"mappings":";;;;AAKA,MAAa,6BAA6B;;AAG1C,MAAa,uBAAuB,OAAO,IAAI,4CAA4C;AA6C3F,SAAgB,kBAAkB,QAAyC;CAC1E,OAAO;EAAE,MAAM;EAAa;CAAO;AACpC;;;;;;;;;;;;;;;AAgBA,SAAgB,cAAc,OAAoC;CACjE,OAAO,oBAAoB,KAAK;AACjC;AAwFA,MAAM,6BAA6B,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAE9E,MAAM,kBAAkB,OAAO,OAAO;CACrC,SAAS,OAAO;CAChB,MAAM,OAAO,MAAM,0BAA0B;AAC9C,CAAC;AAED,MAAM,kBAAkB,OAAO,OAAO;CACrC,MAAM,OAAO,QAAQ,WAAW;CAChC,QAAQ,OAAO,MAAM,eAAe;AACrC,CAAC;AAED,MAAM,wCAAwC,OAAO,OAAO;CAC3D,0BAA0B,OAAO,QAAQ,IAAI;CAC7C,SAAS,OAAO;AACjB,CAAC;AAED,MAAM,8BAA8B,OAAO,OAAO;CACjD,MAAM,OAAO,QAAQ,uBAAuB;CAC5C,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,QAAQ,OAAO,SAAS,OAAO,MAAM,eAAe,CAAC;CACrD,QAAQ,OAAO;AAChB,CAAC;AAED,MAAM,wBAAwB,OAAO,OAAO;CAC3C,MAAM,OAAO,QAAQ,iBAAiB;CACtC,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,QAAQ,OAAO;AAChB,CAAC;AAED,MAAM,6BAA6B,OAAO,OAAO;CAChD,MAAM,OAAO,QAAQ,sBAAsB;CAC3C,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,OAAO,OAAO,SAAS,OAAO,OAAO;AACtC,CAAC;AAED,MAAM,sBAAsB,OAAO,GAAG,eAAe;AACrD,MAAM,6BAA6B,OAAO,GAAG,qBAAqB;AAClE,MAAM,kCAAkC,OAAO,GAAG,0BAA0B;AAC5E,MAAM,mCAAmC,OAAO,GAAG,2BAA2B;AAC9E,MAAM,8CAA8C,OAAO,GAC1D,qCACD;AAEA,SAAgB,+BACf,QACA,MACA,SAAS,KACe;CACxB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC9D;AAEA,SAAgB,yBACf,QACA,MACA,OACkB;CAClB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACvD;AAEA,SAAgB,8BACf,OACA,MACuB;CACvB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACpD;AAEA,SAAgB,0CACf,SACkC;CAClC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AAClD;AAEA,SAAgB,sCACf,OAC2C;CAC3C,OAAO,4CAA4C,KAAK;AACzD;;;;;;;;;;;;;;;AAgBA,SAAgB,2BAA2B,OAAgD;CAC1F,OAAO,iCAAiC,KAAK;AAC9C;;;;;;;;;;;;;;;AAgBA,SAAgB,qBAAqB,OAA0C;CAC9E,OAAO,2BAA2B,KAAK;AACxC;;;;;;;;;;;;;;;AAgBA,SAAgB,0BAA0B,OAA+C;CACxF,OAAO,gCAAgC,KAAK;AAC7C"}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
1
|
+
import { m as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-qhcbUH6o.js";
|
|
2
|
+
import { a as slice_start, c as find_yield_star_node, d as collect_top_level_binding_names, f as has_local_import_binding, i as slice, l as is_yield_star_expression, n as validate_rune_yield_usage, o as collect_yield_star_nodes, p as make_imports, r as create_source_map, s as contains_top_level_await, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-D7TTlPpK.js";
|
|
3
|
+
import { t as scan_svelte_effect_source } from "../chunks/source-scan-cSawCvsg.js";
|
|
4
4
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
5
5
|
import ts from "typescript";
|
|
6
6
|
import MagicString from "magic-string";
|
|
7
7
|
//#region src/script-transform/runtime-block.ts
|
|
8
|
-
/**
|
|
9
|
-
* Builds the runtime blocks appended to lowered script effect code with
|
|
10
|
-
* explicit runtime import bindings.
|
|
11
|
-
*
|
|
12
|
-
* @since 2.4.2
|
|
13
|
-
* @param blocks - Effect bodies and dependency reads to emit.
|
|
14
|
-
* @param bindings - Runtime binding names available in the generated code.
|
|
15
|
-
* @returns Full `$effect` blocks that fork generated `Effect.gen` programs.
|
|
16
|
-
*/
|
|
17
8
|
function make_runtime_block_with_bindings(blocks, bindings) {
|
|
18
9
|
return blocks.map((block) => make_runtime_effect_block(block, bindings)).join("\n");
|
|
19
10
|
}
|
|
@@ -28,7 +19,7 @@ function make_runtime_effect_block(block, bindings) {
|
|
|
28
19
|
` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,
|
|
29
20
|
body,
|
|
30
21
|
" });",
|
|
31
|
-
` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.
|
|
22
|
+
` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.run_scoped(${bindings.scope}.scope, ${bindings.program}));`,
|
|
32
23
|
` import.meta.hot?.dispose(${bindings.cancel});`,
|
|
33
24
|
` return ${bindings.cancel};`,
|
|
34
25
|
"});",
|
|
@@ -37,15 +28,6 @@ function make_runtime_effect_block(block, bindings) {
|
|
|
37
28
|
}
|
|
38
29
|
//#endregion
|
|
39
30
|
//#region src/script-transform/lower.ts
|
|
40
|
-
/**
|
|
41
|
-
* Delegates a statement to the correct lowerer based on syntax kind.
|
|
42
|
-
*
|
|
43
|
-
* @since 2.0.0
|
|
44
|
-
* @param stmt - Statement to lower.
|
|
45
|
-
* @param content - Original source text.
|
|
46
|
-
* @param context - Lowering services for this transform pass.
|
|
47
|
-
* @returns Lowered statement descriptor.
|
|
48
|
-
*/
|
|
49
31
|
function lower_statement(stmt, content, context) {
|
|
50
32
|
if (ts.isExpressionStatement(stmt)) return lower_expression_statement(stmt, content, context);
|
|
51
33
|
if (ts.isVariableStatement(stmt)) return lower_variable_statement(stmt, content, context);
|
|
@@ -235,11 +217,11 @@ function make_awaited_yield_expression(node, content, hint, context) {
|
|
|
235
217
|
return {
|
|
236
218
|
declaration: `function* ${helper_name}() { return (${wrap_yield_text(yield_text, context)}); }`,
|
|
237
219
|
expression: [
|
|
238
|
-
`await ${context.dispatcher_name}().promise({`,
|
|
220
|
+
`await ${context.dispatcher_name}().with_scope(${context.scope_name}.scope, () => ${context.dispatcher_name}().promise({`,
|
|
239
221
|
`id: ${JSON.stringify(helper_id)}, `,
|
|
240
222
|
`deps: ${deps_text}, `,
|
|
241
223
|
`factory: () => ${helper_name}()`,
|
|
242
|
-
`})`
|
|
224
|
+
`}))`
|
|
243
225
|
].join("")
|
|
244
226
|
};
|
|
245
227
|
}
|
|
@@ -345,6 +327,7 @@ function collect_assignment_target_names(node) {
|
|
|
345
327
|
*/
|
|
346
328
|
function transform_script_effect(content, filename, options = {}) {
|
|
347
329
|
let temp_counter = 0;
|
|
330
|
+
const is_server_target = (options.target ?? "client") === "server";
|
|
348
331
|
const source_file = ts.createSourceFile(filename, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
349
332
|
const magic = new MagicString(content);
|
|
350
333
|
const effect_blocks = [];
|
|
@@ -360,13 +343,17 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
360
343
|
const has_effect_import = has_local_import_binding(source_file, "effect", "Effect");
|
|
361
344
|
const has_dispatcher_import = has_local_import_binding(source_file, "svelte-effect-runtime/internal/generators", "get_dispatcher");
|
|
362
345
|
const has_untrack_import = has_local_import_binding(source_file, "svelte", "untrack");
|
|
346
|
+
const has_on_destroy_import = has_local_import_binding(source_file, "svelte", "onDestroy");
|
|
363
347
|
const reserve_runtime_import = (name) => top_level_binding_names_set.has(name) ? name_allocator.reserve(make_generated_name(name, "")) : name_allocator.reserve(name);
|
|
364
348
|
const runtime_bindings = {
|
|
365
349
|
cancel: name_allocator.reserve("__SER___cancel"),
|
|
350
|
+
component_scope_ref: reserve_runtime_import("ComponentScopeRef"),
|
|
366
351
|
dispatcher: has_dispatcher_import ? "get_dispatcher" : reserve_runtime_import("get_dispatcher"),
|
|
367
352
|
dispatcher_value: name_allocator.reserve("__SER___dispatcher"),
|
|
368
353
|
effect: has_effect_import ? "Effect" : reserve_runtime_import("Effect"),
|
|
354
|
+
on_destroy: has_on_destroy_import ? "onDestroy" : reserve_runtime_import("onDestroy"),
|
|
369
355
|
program: name_allocator.reserve("__SER___program"),
|
|
356
|
+
scope: name_allocator.reserve("__SER___scope"),
|
|
370
357
|
untrack: has_untrack_import ? "untrack" : reserve_runtime_import("untrack"),
|
|
371
358
|
yield_success: reserve_runtime_import("YieldSuccess"),
|
|
372
359
|
yieldable: reserve_runtime_import("ToEffect")
|
|
@@ -374,6 +361,7 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
374
361
|
const context = {
|
|
375
362
|
filename,
|
|
376
363
|
dispatcher_name: runtime_bindings.dispatcher,
|
|
364
|
+
scope_name: runtime_bindings.scope,
|
|
377
365
|
effect_name: runtime_bindings.effect,
|
|
378
366
|
emit_types,
|
|
379
367
|
yield_success_name: runtime_bindings.yield_success,
|
|
@@ -420,17 +408,20 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
420
408
|
};
|
|
421
409
|
}
|
|
422
410
|
/** Phase 3: inject runtime imports after the last user import. */
|
|
423
|
-
const imports = make_imports(has_effect_import, has_dispatcher_import, has_untrack_import, runtime_bindings, {
|
|
411
|
+
const imports = make_imports(has_effect_import, has_dispatcher_import, has_untrack_import, has_on_destroy_import, runtime_bindings, {
|
|
424
412
|
needs_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,
|
|
425
413
|
needs_effect: effect_blocks.length > 0,
|
|
426
414
|
needs_untrack: effect_blocks.length > 0,
|
|
415
|
+
needs_on_destroy: !is_server_target,
|
|
427
416
|
needs_yield_success: uses_yield_success_types,
|
|
428
|
-
needs_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise
|
|
417
|
+
needs_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,
|
|
418
|
+
needs_scope_ref: true
|
|
429
419
|
});
|
|
430
420
|
const last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
421
|
+
const injected = [imports, [`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`, ...!is_server_target ? [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`] : []].join("\n")].filter(Boolean).join("\n");
|
|
422
|
+
if (last_import) magic.appendRight(last_import.end, "\n" + injected);
|
|
423
|
+
else magic.prepend(injected + "\n");
|
|
424
|
+
/** Phase 4: append the runtime program blocks. */
|
|
434
425
|
if (effect_blocks.length > 0) {
|
|
435
426
|
const runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);
|
|
436
427
|
magic.append("\n" + runtime_block);
|
|
@@ -599,10 +590,14 @@ function transform_svelte_effect(content, filename = "unknown.svelte", options =
|
|
|
599
590
|
const effect_attribute = script.effect_attribute;
|
|
600
591
|
const effect_attribute_start = effect_attribute?.start ?? script.opening_tag_end;
|
|
601
592
|
const effect_attribute_end = effect_attribute?.end ?? script.opening_tag_end;
|
|
602
|
-
const result = transform_script_effect(script.text, filename, {
|
|
593
|
+
const result = transform_script_effect(script.text, filename, {
|
|
594
|
+
emit_types: script.is_typescript,
|
|
595
|
+
target: options.target ?? "client"
|
|
596
|
+
});
|
|
603
597
|
combined = content.slice(0, effect_attribute_start) + content.slice(effect_attribute_end, script.opening_tag_end) + result.code + content.slice(script.closing_tag_start);
|
|
604
598
|
}
|
|
605
|
-
|
|
599
|
+
const markup_options = options.target === void 0 ? {} : { target: options.target };
|
|
600
|
+
return { code: transform_markup_effect(combined, filename, markup_options).code };
|
|
606
601
|
}
|
|
607
602
|
//#endregion
|
|
608
603
|
export { transform_markup_effect, transform_script_effect, transform_svelte_effect };
|