svelte-effect-runtime 3.4.5 → 3.4.7
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-5cizmHtc.js → client-CsVu54pU.js} +119 -56
- package/.dist/chunks/client-CsVu54pU.js.map +1 -0
- package/.dist/chunks/{descriptors-OS4VfJuW.js → descriptors-cOe9uRJz.js} +2 -2
- package/.dist/chunks/descriptors-cOe9uRJz.js.map +1 -0
- package/.dist/chunks/{dispatcher-C38yhZRs.js → dispatcher-LtvFKYUp.js} +3 -3
- package/.dist/chunks/dispatcher-LtvFKYUp.js.map +1 -0
- package/.dist/chunks/{dispatcher-DuBLHNa6.js → dispatcher-pHH4JcFR.js} +12 -11
- package/.dist/chunks/dispatcher-pHH4JcFR.js.map +1 -0
- package/.dist/chunks/{errors-0PaWf7Bq.js → errors-Dcf0MVbq.js} +3 -3
- package/.dist/chunks/errors-Dcf0MVbq.js.map +1 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js +108 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +1 -0
- package/.dist/chunks/{runtime-C51Dv3K6.js → runtime-ekkMQ-wL.js} +4 -4
- package/.dist/chunks/runtime-ekkMQ-wL.js.map +1 -0
- package/.dist/chunks/{transform-Cdsx7ygD.js → transform-CEK6Ccll.js} +246 -172
- package/.dist/chunks/transform-CEK6Ccll.js.map +1 -0
- package/.dist/chunks/{vite-DR3-WaqQ.js → vite-Dm3bXmR3.js} +54 -46
- package/.dist/chunks/vite-Dm3bXmR3.js.map +1 -0
- package/.dist/detect.js.map +1 -1
- package/.dist/dispatcher.d.ts +1 -1
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +1 -1
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/promise.js.map +1 -1
- package/.dist/markup/run.js +3 -3
- package/.dist/markup/run.js.map +1 -1
- package/.dist/markup/transform/index.d.ts +8 -0
- package/.dist/markup/transform/scan.d.ts +20 -0
- package/.dist/markup/transform/types.d.ts +136 -2
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/markup/value.js.map +1 -1
- package/.dist/mod.js +3 -3
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client/command.d.ts +1 -1
- package/.dist/remote/client/effect.d.ts +15 -1
- package/.dist/remote/client/index.d.ts +1 -1
- package/.dist/remote/client/types.d.ts +3 -1
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +27 -9
- package/.dist/remote/server.js.map +1 -1
- package/.dist/remote/shared.d.ts +126 -0
- package/.dist/remote/shared.js +117 -5
- package/.dist/remote/shared.js.map +1 -1
- package/.dist/runtime/transform.js +3 -3
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/types.d.ts +95 -0
- package/.dist/server/effects.d.ts +15 -1
- package/.dist/server/factories.d.ts +128 -9
- package/.dist/server/index.d.ts +1 -1
- package/.dist/server/runtime.d.ts +1 -1
- package/.dist/server/types.d.ts +128 -7
- package/.dist/server.js +28 -13
- package/.dist/server.js.map +1 -1
- package/.dist/vite/remote-client.d.ts +24 -0
- package/.dist/vite.d.ts +8 -3
- package/.dist/vite.js +1 -1
- package/LICENSE +29 -0
- package/package.json +21 -21
- package/.dist/chunks/client-5cizmHtc.js.map +0 -1
- package/.dist/chunks/descriptors-OS4VfJuW.js.map +0 -1
- package/.dist/chunks/dispatcher-C38yhZRs.js.map +0 -1
- package/.dist/chunks/dispatcher-DuBLHNa6.js.map +0 -1
- package/.dist/chunks/errors-0PaWf7Bq.js.map +0 -1
- package/.dist/chunks/runtime-C51Dv3K6.js.map +0 -1
- package/.dist/chunks/transform-Cdsx7ygD.js.map +0 -1
- package/.dist/chunks/vite-DR3-WaqQ.js.map +0 -1
package/.dist/remote/shared.d.ts
CHANGED
|
@@ -9,6 +9,13 @@
|
|
|
9
9
|
* Well-known marker injected into every serialised remote-failure envelope
|
|
10
10
|
* so the client can reliably distinguish runtime errors from domain values.
|
|
11
11
|
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* if (envelope[EFFECT_REMOTE_ERROR_MARKER] === true) {
|
|
15
|
+
* console.log(envelope.encoded);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
12
19
|
* @since 2.0.0
|
|
13
20
|
* @internal
|
|
14
21
|
*/
|
|
@@ -17,6 +24,11 @@ export declare const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
|
17
24
|
* Well-known symbol used to attach a payload decoder to a remote function
|
|
18
25
|
* so the client's transport layer can decode domain error types.
|
|
19
26
|
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* Reflect.get(remote_function, REMOTE_ERROR_DECODER);
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
20
32
|
* @since 2.0.0
|
|
21
33
|
* @internal
|
|
22
34
|
*/
|
|
@@ -26,6 +38,14 @@ export declare const REMOTE_ERROR_DECODER: unique symbol;
|
|
|
26
38
|
* A single field-level or form-level validation issue reported by a
|
|
27
39
|
* {@link Form} handler.
|
|
28
40
|
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const issue: FormIssue = {
|
|
44
|
+
* message: "Use an email address.",
|
|
45
|
+
* path: ["email"],
|
|
46
|
+
* };
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
29
49
|
* @since 2.0.0
|
|
30
50
|
*/
|
|
31
51
|
export interface FormIssue {
|
|
@@ -39,6 +59,14 @@ export interface FormIssue {
|
|
|
39
59
|
* failures. The `issues` array is forwarded to SvelteKit's `invalid()`
|
|
40
60
|
* helper on the server and surfaced as `FormError` on the client.
|
|
41
61
|
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const error: FormError = {
|
|
65
|
+
* _tag: "FormError",
|
|
66
|
+
* issues: [{ message: "Required.", path: ["email"] }],
|
|
67
|
+
* };
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
42
70
|
* @since 2.0.0
|
|
43
71
|
*/
|
|
44
72
|
export interface FormError<SchemaType = unknown> {
|
|
@@ -50,6 +78,13 @@ export interface FormError<SchemaType = unknown> {
|
|
|
50
78
|
/**
|
|
51
79
|
* Creates a {@link FormError} holding the given issues.
|
|
52
80
|
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const error = create_form_error([
|
|
84
|
+
* { message: "Required.", path: ["email"] },
|
|
85
|
+
* ]);
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
53
88
|
* @since 2.0.0
|
|
54
89
|
* @param issues - The validation issues to attach.
|
|
55
90
|
* @returns A FormError with the `_tag` set and no schema reference.
|
|
@@ -58,6 +93,13 @@ export declare function create_form_error(issues: readonly FormIssue[]): FormErr
|
|
|
58
93
|
/**
|
|
59
94
|
* Type guard that narrows an unknown value to a {@link FormError}.
|
|
60
95
|
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* if (is_form_error(error)) {
|
|
99
|
+
* console.log(error.issues);
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
61
103
|
* @since 2.0.0
|
|
62
104
|
* @param value - The value to check.
|
|
63
105
|
* @returns `true` when the value is a FormError.
|
|
@@ -81,6 +123,15 @@ export type RemoteFailure<ErrorType> = ErrorType | RemoteValidationError | Remot
|
|
|
81
123
|
* Validation errors that originate from a server-side {@link Form}
|
|
82
124
|
* handler calling `invalid()` (SvelteKit's `fail`).
|
|
83
125
|
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```ts
|
|
128
|
+
* const error: RemoteValidationError = {
|
|
129
|
+
* _tag: "RemoteValidationError",
|
|
130
|
+
* status: 400,
|
|
131
|
+
* issues: [{ message: "Required.", path: ["email"] }],
|
|
132
|
+
* };
|
|
133
|
+
* ```
|
|
134
|
+
*
|
|
84
135
|
* @since 2.0.0
|
|
85
136
|
*/
|
|
86
137
|
export interface RemoteValidationError {
|
|
@@ -93,6 +144,15 @@ export interface RemoteValidationError {
|
|
|
93
144
|
* HTTP-level errors with a status code and optional response body. Raised
|
|
94
145
|
* when the server explicitly calls SvelteKit's `error(status, body)`.
|
|
95
146
|
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```ts
|
|
149
|
+
* const error: RemoteHttpError = {
|
|
150
|
+
* _tag: "RemoteHttpError",
|
|
151
|
+
* status: 404,
|
|
152
|
+
* body: { message: "Not found" },
|
|
153
|
+
* };
|
|
154
|
+
* ```
|
|
155
|
+
*
|
|
96
156
|
* @since 2.0.0
|
|
97
157
|
*/
|
|
98
158
|
export interface RemoteHttpError {
|
|
@@ -105,6 +165,14 @@ export interface RemoteHttpError {
|
|
|
105
165
|
* Transport-level errors raised by the client adapter when the network
|
|
106
166
|
* request fails or the response cannot be decoded.
|
|
107
167
|
*
|
|
168
|
+
* @example
|
|
169
|
+
* ```ts
|
|
170
|
+
* const error: RemoteTransportError = {
|
|
171
|
+
* _tag: "RemoteTransportError",
|
|
172
|
+
* cause: new Error("Network unavailable"),
|
|
173
|
+
* };
|
|
174
|
+
* ```
|
|
175
|
+
*
|
|
108
176
|
* @since 2.0.0
|
|
109
177
|
*/
|
|
110
178
|
export interface RemoteTransportError {
|
|
@@ -116,6 +184,14 @@ export interface RemoteTransportError {
|
|
|
116
184
|
* Wire format for an encoded remote failure. The server wraps domain
|
|
117
185
|
* errors in this envelope before serialising them with devalue.
|
|
118
186
|
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```ts
|
|
189
|
+
* const envelope: SerializedRemoteFailureEnvelope = {
|
|
190
|
+
* __svelte_effect_remote__: true,
|
|
191
|
+
* encoded: "[\"DomainError\"]",
|
|
192
|
+
* };
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
119
195
|
* @since 2.0.0
|
|
120
196
|
* @internal
|
|
121
197
|
*/
|
|
@@ -127,6 +203,13 @@ export interface SerializedRemoteFailureEnvelope {
|
|
|
127
203
|
/**
|
|
128
204
|
* Creates a {@link RemoteValidationError} from a list of form issues.
|
|
129
205
|
*
|
|
206
|
+
* @example
|
|
207
|
+
* ```ts
|
|
208
|
+
* const error = create_remote_validation_error([
|
|
209
|
+
* { message: "Required.", path: ["email"] },
|
|
210
|
+
* ]);
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
130
213
|
* @since 2.0.0
|
|
131
214
|
* @param issues - The validation issues reported by the server handler.
|
|
132
215
|
* @param body - Optional response body returned alongside the error.
|
|
@@ -138,6 +221,11 @@ export declare function create_remote_validation_error(issues: readonly FormIssu
|
|
|
138
221
|
/**
|
|
139
222
|
* Creates a {@link RemoteHttpError} for a given HTTP status.
|
|
140
223
|
*
|
|
224
|
+
* @example
|
|
225
|
+
* ```ts
|
|
226
|
+
* const error = create_remote_http_error(404, { message: "Not found" });
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
141
229
|
* @since 2.0.0
|
|
142
230
|
* @param status - The HTTP status code.
|
|
143
231
|
* @param body - Optional response body.
|
|
@@ -149,6 +237,11 @@ export declare function create_remote_http_error(status: number, body?: unknown,
|
|
|
149
237
|
/**
|
|
150
238
|
* Creates a {@link RemoteTransportError} for network or decode failures.
|
|
151
239
|
*
|
|
240
|
+
* @example
|
|
241
|
+
* ```ts
|
|
242
|
+
* const error = create_remote_transport_error(new Error("Network unavailable"));
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
152
245
|
* @since 2.0.0
|
|
153
246
|
* @param cause - The underlying error that caused the transport failure.
|
|
154
247
|
* @param body - Optional response body if one was received.
|
|
@@ -160,6 +253,11 @@ export declare function create_remote_transport_error(cause: unknown, body?: unk
|
|
|
160
253
|
* Wraps a devalue-encoded error string inside a
|
|
161
254
|
* {@link SerializedRemoteFailureEnvelope}.
|
|
162
255
|
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* const envelope = create_serialized_remote_failure_envelope(encoded);
|
|
259
|
+
* ```
|
|
260
|
+
*
|
|
163
261
|
* @since 2.0.0
|
|
164
262
|
* @param encoded - The devalue-encoded error value.
|
|
165
263
|
* @returns The wire-format envelope.
|
|
@@ -170,6 +268,13 @@ export declare function create_serialized_remote_failure_envelope(encoded: strin
|
|
|
170
268
|
/**
|
|
171
269
|
* Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.
|
|
172
270
|
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```ts
|
|
273
|
+
* if (is_serialized_remote_failure_envelope(value)) {
|
|
274
|
+
* console.log(value.encoded);
|
|
275
|
+
* }
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
173
278
|
* @since 2.0.0
|
|
174
279
|
* @param value - The value to check.
|
|
175
280
|
* @returns `true` when the value is a serialised failure envelope.
|
|
@@ -179,6 +284,13 @@ export declare function is_serialized_remote_failure_envelope(value: unknown): v
|
|
|
179
284
|
/**
|
|
180
285
|
* Checks whether a value is a {@link RemoteValidationError}.
|
|
181
286
|
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* if (is_remote_validation_error(error)) {
|
|
290
|
+
* console.log(error.issues);
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
182
294
|
* @since 2.0.0
|
|
183
295
|
* @param value - The value to check.
|
|
184
296
|
* @returns `true` when the value is a remote validation error.
|
|
@@ -187,6 +299,13 @@ export declare function is_remote_validation_error(value: unknown): value is Rem
|
|
|
187
299
|
/**
|
|
188
300
|
* Checks whether a value is a {@link RemoteHttpError}.
|
|
189
301
|
*
|
|
302
|
+
* @example
|
|
303
|
+
* ```ts
|
|
304
|
+
* if (is_remote_http_error(error)) {
|
|
305
|
+
* console.log(error.status);
|
|
306
|
+
* }
|
|
307
|
+
* ```
|
|
308
|
+
*
|
|
190
309
|
* @since 2.0.0
|
|
191
310
|
* @param value - The value to check.
|
|
192
311
|
* @returns `true` when the value is a remote HTTP error.
|
|
@@ -195,6 +314,13 @@ export declare function is_remote_http_error(value: unknown): value is RemoteHtt
|
|
|
195
314
|
/**
|
|
196
315
|
* Checks whether a value is a {@link RemoteTransportError}.
|
|
197
316
|
*
|
|
317
|
+
* @example
|
|
318
|
+
* ```ts
|
|
319
|
+
* if (is_remote_transport_error(error)) {
|
|
320
|
+
* console.error(error.cause);
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
198
324
|
* @since 2.0.0
|
|
199
325
|
* @param value - The value to check.
|
|
200
326
|
* @returns `true` when the value is a remote transport error.
|
package/.dist/remote/shared.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Schema } from "effect";
|
|
1
2
|
//#region src/remote/shared.ts
|
|
2
3
|
/**
|
|
3
4
|
* Shared types, markers, and constructors used by both the client-side remote
|
|
@@ -10,6 +11,13 @@
|
|
|
10
11
|
* Well-known marker injected into every serialised remote-failure envelope
|
|
11
12
|
* so the client can reliably distinguish runtime errors from domain values.
|
|
12
13
|
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* if (envelope[EFFECT_REMOTE_ERROR_MARKER] === true) {
|
|
17
|
+
* console.log(envelope.encoded);
|
|
18
|
+
* }
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
13
21
|
* @since 2.0.0
|
|
14
22
|
* @internal
|
|
15
23
|
*/
|
|
@@ -18,6 +26,11 @@ const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
|
18
26
|
* Well-known symbol used to attach a payload decoder to a remote function
|
|
19
27
|
* so the client's transport layer can decode domain error types.
|
|
20
28
|
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* Reflect.get(remote_function, REMOTE_ERROR_DECODER);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
21
34
|
* @since 2.0.0
|
|
22
35
|
* @internal
|
|
23
36
|
*/
|
|
@@ -25,6 +38,13 @@ const REMOTE_ERROR_DECODER = Symbol.for("svelte-effect-runtime/remote-error-deco
|
|
|
25
38
|
/**
|
|
26
39
|
* Creates a {@link FormError} holding the given issues.
|
|
27
40
|
*
|
|
41
|
+
* @example
|
|
42
|
+
* ```ts
|
|
43
|
+
* const error = create_form_error([
|
|
44
|
+
* { message: "Required.", path: ["email"] },
|
|
45
|
+
* ]);
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
28
48
|
* @since 2.0.0
|
|
29
49
|
* @param issues - The validation issues to attach.
|
|
30
50
|
* @returns A FormError with the `_tag` set and no schema reference.
|
|
@@ -38,17 +58,66 @@ function create_form_error(issues) {
|
|
|
38
58
|
/**
|
|
39
59
|
* Type guard that narrows an unknown value to a {@link FormError}.
|
|
40
60
|
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* if (is_form_error(error)) {
|
|
64
|
+
* console.log(error.issues);
|
|
65
|
+
* }
|
|
66
|
+
* ```
|
|
67
|
+
*
|
|
41
68
|
* @since 2.0.0
|
|
42
69
|
* @param value - The value to check.
|
|
43
70
|
* @returns `true` when the value is a FormError.
|
|
44
71
|
*/
|
|
45
72
|
function is_form_error(value) {
|
|
46
|
-
return
|
|
73
|
+
return is_form_error_value(value);
|
|
47
74
|
}
|
|
75
|
+
const FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);
|
|
76
|
+
const FormIssueSchema = Schema.Struct({
|
|
77
|
+
message: Schema.String,
|
|
78
|
+
path: Schema.Array(FormIssuePathSegmentSchema)
|
|
79
|
+
});
|
|
80
|
+
const FormErrorSchema = Schema.Struct({
|
|
81
|
+
_tag: Schema.Literal("FormError"),
|
|
82
|
+
issues: Schema.Array(FormIssueSchema)
|
|
83
|
+
});
|
|
84
|
+
const SerializedRemoteFailureEnvelopeSchema = Schema.Struct({
|
|
85
|
+
__svelte_effect_remote__: Schema.Literal(true),
|
|
86
|
+
encoded: Schema.String
|
|
87
|
+
});
|
|
88
|
+
const RemoteValidationErrorSchema = Schema.Struct({
|
|
89
|
+
_tag: Schema.Literal("RemoteValidationError"),
|
|
90
|
+
body: Schema.optional(Schema.Unknown),
|
|
91
|
+
issues: Schema.optional(Schema.Array(FormIssueSchema)),
|
|
92
|
+
status: Schema.Number
|
|
93
|
+
});
|
|
94
|
+
const RemoteHttpErrorSchema = Schema.Struct({
|
|
95
|
+
_tag: Schema.Literal("RemoteHttpError"),
|
|
96
|
+
body: Schema.optional(Schema.Unknown),
|
|
97
|
+
cause: Schema.optional(Schema.Unknown),
|
|
98
|
+
status: Schema.Number
|
|
99
|
+
});
|
|
100
|
+
const RemoteTransportErrorSchema = Schema.Struct({
|
|
101
|
+
_tag: Schema.Literal("RemoteTransportError"),
|
|
102
|
+
body: Schema.optional(Schema.Unknown),
|
|
103
|
+
cause: Schema.optional(Schema.Unknown)
|
|
104
|
+
});
|
|
105
|
+
const is_form_error_value = Schema.is(FormErrorSchema);
|
|
106
|
+
const is_remote_http_error_value = Schema.is(RemoteHttpErrorSchema);
|
|
107
|
+
const is_remote_transport_error_value = Schema.is(RemoteTransportErrorSchema);
|
|
108
|
+
const is_remote_validation_error_value = Schema.is(RemoteValidationErrorSchema);
|
|
109
|
+
const is_serialized_remote_failure_envelope_value = Schema.is(SerializedRemoteFailureEnvelopeSchema);
|
|
48
110
|
/** Constructors for structured remote error values. */
|
|
49
111
|
/**
|
|
50
112
|
* Creates a {@link RemoteValidationError} from a list of form issues.
|
|
51
113
|
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const error = create_remote_validation_error([
|
|
117
|
+
* { message: "Required.", path: ["email"] },
|
|
118
|
+
* ]);
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
52
121
|
* @since 2.0.0
|
|
53
122
|
* @param issues - The validation issues reported by the server handler.
|
|
54
123
|
* @param body - Optional response body returned alongside the error.
|
|
@@ -67,6 +136,11 @@ function create_remote_validation_error(issues, body, status = 400) {
|
|
|
67
136
|
/**
|
|
68
137
|
* Creates a {@link RemoteHttpError} for a given HTTP status.
|
|
69
138
|
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const error = create_remote_http_error(404, { message: "Not found" });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
70
144
|
* @since 2.0.0
|
|
71
145
|
* @param status - The HTTP status code.
|
|
72
146
|
* @param body - Optional response body.
|
|
@@ -85,6 +159,11 @@ function create_remote_http_error(status, body, cause) {
|
|
|
85
159
|
/**
|
|
86
160
|
* Creates a {@link RemoteTransportError} for network or decode failures.
|
|
87
161
|
*
|
|
162
|
+
* @example
|
|
163
|
+
* ```ts
|
|
164
|
+
* const error = create_remote_transport_error(new Error("Network unavailable"));
|
|
165
|
+
* ```
|
|
166
|
+
*
|
|
88
167
|
* @since 2.0.0
|
|
89
168
|
* @param cause - The underlying error that caused the transport failure.
|
|
90
169
|
* @param body - Optional response body if one was received.
|
|
@@ -102,6 +181,11 @@ function create_remote_transport_error(cause, body) {
|
|
|
102
181
|
* Wraps a devalue-encoded error string inside a
|
|
103
182
|
* {@link SerializedRemoteFailureEnvelope}.
|
|
104
183
|
*
|
|
184
|
+
* @example
|
|
185
|
+
* ```ts
|
|
186
|
+
* const envelope = create_serialized_remote_failure_envelope(encoded);
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
105
189
|
* @since 2.0.0
|
|
106
190
|
* @param encoded - The devalue-encoded error value.
|
|
107
191
|
* @returns The wire-format envelope.
|
|
@@ -117,43 +201,71 @@ function create_serialized_remote_failure_envelope(encoded) {
|
|
|
117
201
|
/**
|
|
118
202
|
* Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.
|
|
119
203
|
*
|
|
204
|
+
* @example
|
|
205
|
+
* ```ts
|
|
206
|
+
* if (is_serialized_remote_failure_envelope(value)) {
|
|
207
|
+
* console.log(value.encoded);
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
210
|
+
*
|
|
120
211
|
* @since 2.0.0
|
|
121
212
|
* @param value - The value to check.
|
|
122
213
|
* @returns `true` when the value is a serialised failure envelope.
|
|
123
214
|
* @internal
|
|
124
215
|
*/
|
|
125
216
|
function is_serialized_remote_failure_envelope(value) {
|
|
126
|
-
return
|
|
217
|
+
return is_serialized_remote_failure_envelope_value(value);
|
|
127
218
|
}
|
|
128
219
|
/**
|
|
129
220
|
* Checks whether a value is a {@link RemoteValidationError}.
|
|
130
221
|
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```ts
|
|
224
|
+
* if (is_remote_validation_error(error)) {
|
|
225
|
+
* console.log(error.issues);
|
|
226
|
+
* }
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
131
229
|
* @since 2.0.0
|
|
132
230
|
* @param value - The value to check.
|
|
133
231
|
* @returns `true` when the value is a remote validation error.
|
|
134
232
|
*/
|
|
135
233
|
function is_remote_validation_error(value) {
|
|
136
|
-
return
|
|
234
|
+
return is_remote_validation_error_value(value);
|
|
137
235
|
}
|
|
138
236
|
/**
|
|
139
237
|
* Checks whether a value is a {@link RemoteHttpError}.
|
|
140
238
|
*
|
|
239
|
+
* @example
|
|
240
|
+
* ```ts
|
|
241
|
+
* if (is_remote_http_error(error)) {
|
|
242
|
+
* console.log(error.status);
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
141
246
|
* @since 2.0.0
|
|
142
247
|
* @param value - The value to check.
|
|
143
248
|
* @returns `true` when the value is a remote HTTP error.
|
|
144
249
|
*/
|
|
145
250
|
function is_remote_http_error(value) {
|
|
146
|
-
return
|
|
251
|
+
return is_remote_http_error_value(value);
|
|
147
252
|
}
|
|
148
253
|
/**
|
|
149
254
|
* Checks whether a value is a {@link RemoteTransportError}.
|
|
150
255
|
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```ts
|
|
258
|
+
* if (is_remote_transport_error(error)) {
|
|
259
|
+
* console.error(error.cause);
|
|
260
|
+
* }
|
|
261
|
+
* ```
|
|
262
|
+
*
|
|
151
263
|
* @since 2.0.0
|
|
152
264
|
* @param value - The value to check.
|
|
153
265
|
* @returns `true` when the value is a remote transport error.
|
|
154
266
|
*/
|
|
155
267
|
function is_remote_transport_error(value) {
|
|
156
|
-
return
|
|
268
|
+
return is_remote_transport_error_value(value);
|
|
157
269
|
}
|
|
158
270
|
//#endregion
|
|
159
271
|
export { EFFECT_REMOTE_ERROR_MARKER, REMOTE_ERROR_DECODER, create_form_error, create_remote_http_error, create_remote_transport_error, create_remote_validation_error, create_serialized_remote_failure_envelope, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, is_serialized_remote_failure_envelope };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["/**\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 * @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 * @since 2.0.0\n * @internal\n */\nexport const REMOTE_ERROR_DECODER = Symbol.for(\n \"svelte-effect-runtime/remote-error-decoder\",\n);\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 * @since 2.0.0\n */\nexport interface FormIssue {\n /** Human-readable validation message. */\n message: string;\n /** Path to the offending field as an array of string-or-number keys. */\n path: (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 * @since 2.0.0\n */\nexport interface FormError<SchemaType = unknown> {\n readonly _tag: \"FormError\";\n readonly issues: readonly FormIssue[];\n /** Phantom type slot for the schema this error was derived from. */\n readonly _schema?: SchemaType;\n}\n\n/**\n * Creates a {@link FormError} holding the given issues.\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 return { _tag: \"FormError\", issues };\n}\n\n/**\n * Type guard that narrows an unknown value to a {@link FormError}.\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 return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"FormError\"\n );\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 | ErrorType\n | RemoteValidationError\n | RemoteHttpError\n | RemoteTransportError;\n\n/**\n * Validation errors that originate from a server-side {@link Form}\n * handler calling `invalid()` (SvelteKit's `fail`).\n *\n * @since 2.0.0\n */\nexport interface RemoteValidationError {\n readonly _tag: \"RemoteValidationError\";\n readonly issues?: readonly FormIssue[];\n readonly body?: unknown;\n readonly 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 * @since 2.0.0\n */\nexport interface RemoteHttpError {\n readonly _tag: \"RemoteHttpError\";\n readonly status: number;\n readonly body?: unknown;\n readonly 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 * @since 2.0.0\n */\nexport interface RemoteTransportError {\n readonly _tag: \"RemoteTransportError\";\n readonly cause?: unknown;\n readonly 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 * @since 2.0.0\n * @internal\n */\nexport interface SerializedRemoteFailureEnvelope {\n readonly __svelte_effect_remote__: true;\n readonly encoded: string;\n}\n\n/** Constructors for structured remote error values. */\n\n/**\n * Creates a {@link RemoteValidationError} from a list of form issues.\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 issues: readonly FormIssue[],\n body?: unknown,\n status = 400,\n): RemoteValidationError {\n\n return { _tag: \"RemoteValidationError\", issues, body, status };\n}\n\n/**\n * Creates a {@link RemoteHttpError} for a given HTTP status.\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 status: number,\n body?: unknown,\n cause?: unknown,\n): RemoteHttpError {\n\n return { _tag: \"RemoteHttpError\", status, body, cause };\n}\n\n/**\n * Creates a {@link RemoteTransportError} for network or decode failures.\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 cause: unknown,\n body?: unknown,\n): RemoteTransportError {\n\n return { _tag: \"RemoteTransportError\", cause, body };\n}\n\n/**\n * Wraps a devalue-encoded error string inside a\n * {@link SerializedRemoteFailureEnvelope}.\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 encoded: string,\n): SerializedRemoteFailureEnvelope {\n\n return { __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 * @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 value: unknown,\n): value is SerializedRemoteFailureEnvelope {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>).__svelte_effect_remote__ === true\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteValidationError}.\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(\n value: unknown,\n): value is RemoteValidationError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteValidationError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteHttpError}.\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(\n value: unknown,\n): value is RemoteHttpError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteHttpError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteTransportError}.\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(\n value: unknown,\n): value is RemoteTransportError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteTransportError\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,6BAA6B;;;;;;;;AAS1C,MAAa,uBAAuB,OAAO,IACzC,4CACF;;;;;;;;AAsCA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO;EAAE,MAAM;EAAa;CAAO;AACrC;;;;;;;;AASA,SAAgB,cAAc,OAAoC;CAChE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;;;;;AAoFA,SAAgB,+BACd,QACA,MACA,SAAS,KACc;CAEvB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC/D;;;;;;;;;;;AAYA,SAAgB,yBACd,QACA,MACA,OACiB;CAEjB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACxD;;;;;;;;;;AAWA,SAAgB,8BACd,OACA,MACsB;CAEtB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACrD;;;;;;;;;;AAWA,SAAgB,0CACd,SACiC;CAEjC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AACnD;;;;;;;;;;AAYA,SAAgB,sCACd,OAC0C;CAE1C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,6BAA6B;AAEpE;;;;;;;;AASA,SAAgB,2BACd,OACgC;CAEhC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,qBACd,OAC0B;CAE1B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,0BACd,OAC+B;CAE/B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD"}
|
|
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,8 +1,8 @@
|
|
|
1
|
-
import { d as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-
|
|
2
|
-
import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-
|
|
1
|
+
import { d as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-Dcf0MVbq.js";
|
|
2
|
+
import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-CEK6Ccll.js";
|
|
3
3
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
4
|
-
import MagicString from "magic-string";
|
|
5
4
|
import ts from "typescript";
|
|
5
|
+
import MagicString from "magic-string";
|
|
6
6
|
//#region src/script-transform/runtime-block.ts
|
|
7
7
|
/**
|
|
8
8
|
* Builds the runtime blocks appended to lowered script effect code with
|