svelte-effect-runtime 1.6.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/client-BeOE81fW.js +577 -0
- package/.dist/chunks/client-BeOE81fW.js.map +1 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js +36 -0
- package/.dist/chunks/descriptors-CU2g4U_i.js.map +1 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js +339 -0
- package/.dist/chunks/dispatcher-BSg2-ttN.js.map +1 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js +430 -0
- package/.dist/chunks/preprocess-BZyUYWY7.js.map +1 -0
- package/.dist/chunks/transform-BtlxgJrg.js +836 -0
- package/.dist/chunks/transform-BtlxgJrg.js.map +1 -0
- package/.dist/detect.d.ts +34 -0
- package/.dist/detect.js +56 -0
- package/.dist/detect.js.map +1 -0
- package/.dist/dispatcher/deps.d.ts +14 -0
- package/.dist/dispatcher/fibers.d.ts +52 -0
- package/.dist/dispatcher/index.d.ts +138 -0
- package/.dist/dispatcher/types.d.ts +63 -0
- package/.dist/dispatcher.d.ts +2 -0
- package/.dist/dispatcher.js +2 -0
- package/.dist/error.d.ts +77 -0
- package/.dist/generators.d.ts +16 -0
- package/.dist/internal/descriptors.d.ts +17 -0
- package/.dist/internal/generators.d.ts +6 -0
- package/.dist/internal/generators.js +5 -0
- package/.dist/internal/remote-client.d.ts +6 -0
- package/.dist/internal/remote-client.js +2 -0
- package/.dist/internal/remote-server.d.ts +6 -0
- package/.dist/internal/remote-server.js +2 -0
- package/.dist/markup/promise.d.ts +15 -0
- package/.dist/markup/promise.js +26 -0
- package/.dist/markup/promise.js.map +1 -0
- package/.dist/markup/run.d.ts +12 -0
- package/.dist/markup/run.js +21 -0
- package/.dist/markup/run.js.map +1 -0
- package/.dist/markup/transform/apply.d.ts +6 -0
- package/.dist/markup/transform/classify.d.ts +15 -0
- package/.dist/markup/transform/constants.d.ts +5 -0
- package/.dist/markup/transform/emit.d.ts +12 -0
- package/.dist/markup/transform/expressions.d.ts +39 -0
- package/.dist/markup/transform/index.d.ts +19 -0
- package/.dist/markup/transform/scan.d.ts +8 -0
- package/.dist/markup/transform/types.d.ts +64 -0
- package/.dist/markup/transform.d.ts +1 -0
- package/.dist/markup/transform.js +2 -0
- package/.dist/markup/value.d.ts +20 -0
- package/.dist/markup/value.js +32 -0
- package/.dist/markup/value.js.map +1 -0
- package/.dist/mod.d.ts +186 -0
- package/.dist/mod.js +190 -0
- package/.dist/mod.js.map +1 -0
- package/.dist/preprocess/ast.d.ts +51 -0
- package/.dist/preprocess/imports.d.ts +22 -0
- package/.dist/preprocess/index.d.ts +21 -0
- package/.dist/preprocess/lower.d.ts +12 -0
- package/.dist/preprocess/runtime-block.d.ts +8 -0
- package/.dist/preprocess/source.d.ts +29 -0
- package/.dist/preprocess/types.d.ts +70 -0
- package/.dist/preprocess.d.ts +2 -0
- package/.dist/preprocess.js +3 -0
- package/.dist/remote/client/command.d.ts +17 -0
- package/.dist/remote/client/effect.d.ts +15 -0
- package/.dist/remote/client/failures.d.ts +57 -0
- package/.dist/remote/client/form-data.d.ts +8 -0
- package/.dist/remote/client/form-enhance.d.ts +9 -0
- package/.dist/remote/client/form-transport.d.ts +20 -0
- package/.dist/remote/client/form.d.ts +21 -0
- package/.dist/remote/client/index.d.ts +4 -0
- package/.dist/remote/client/query-result.d.ts +14 -0
- package/.dist/remote/client/query.d.ts +57 -0
- package/.dist/remote/client/responses.d.ts +28 -0
- package/.dist/remote/client/types.d.ts +83 -0
- package/.dist/remote/client/utils.d.ts +11 -0
- package/.dist/remote/client.d.ts +2 -0
- package/.dist/remote/client.js +2 -0
- package/.dist/remote/server.d.ts +66 -0
- package/.dist/remote/server.js +104 -0
- package/.dist/remote/server.js.map +1 -0
- package/.dist/remote/shared.d.ts +202 -0
- package/.dist/remote/shared.js +161 -0
- package/.dist/remote/shared.js.map +1 -0
- package/.dist/runtime/preprocess.d.ts +38 -0
- package/.dist/runtime/preprocess.js +54 -0
- package/.dist/runtime/preprocess.js.map +1 -0
- package/.dist/server/effects.d.ts +49 -0
- package/.dist/server/factories.d.ts +97 -0
- package/.dist/server/index.d.ts +3 -0
- package/.dist/server/invalid.d.ts +9 -0
- package/.dist/server/runtime.d.ts +66 -0
- package/.dist/server/schema.d.ts +42 -0
- package/.dist/server/types.d.ts +271 -0
- package/.dist/server/wrappers.d.ts +45 -0
- package/.dist/server.d.ts +2 -0
- package/.dist/server.js +527 -0
- package/.dist/server.js.map +1 -0
- package/.dist/vite.d.ts +42 -0
- package/.dist/vite.js +118 -0
- package/.dist/vite.js.map +1 -0
- package/README.md +2 -0
- package/package.json +66 -101
- package/dist/chunks/client-vV6UAwoP.js +0 -199
- package/dist/chunks/client-vV6UAwoP.js.map +0 -1
- package/dist/chunks/effect-Crj3S8Cg.js +0 -51
- package/dist/chunks/effect-Crj3S8Cg.js.map +0 -1
- package/dist/chunks/effect-compat-BhW0YPIs.js +0 -103
- package/dist/chunks/effect-compat-BhW0YPIs.js.map +0 -1
- package/dist/chunks/magic-string.es-BnGH-5YR.js +0 -1013
- package/dist/chunks/magic-string.es-BnGH-5YR.js.map +0 -1
- package/dist/chunks/markup-CkPUZIJt.js +0 -13390
- package/dist/chunks/markup-CkPUZIJt.js.map +0 -1
- package/dist/chunks/preprocess-BFePqOC6.js +0 -49
- package/dist/chunks/preprocess-BFePqOC6.js.map +0 -1
- package/dist/chunks/server-Dea1CJuY.js +0 -704
- package/dist/chunks/server-Dea1CJuY.js.map +0 -1
- package/dist/chunks/v3-D0c0MKPf.js +0 -1
- package/dist/chunks/v4-MMhHmzIG.js +0 -1
- package/dist/chunks/vite-BlUTKv2u.js +0 -152
- package/dist/chunks/vite-BlUTKv2u.js.map +0 -1
- package/dist/client.d.ts +0 -1
- package/dist/client.js +0 -2
- package/dist/effect.d.ts +0 -1
- package/dist/effect.js +0 -2
- package/dist/internal/app-server-shim.d.ts +0 -8
- package/dist/internal/effect-compat.d.ts +0 -21
- package/dist/internal/markup.d.ts +0 -11
- package/dist/internal/markup.js +0 -2
- package/dist/internal/remote-client.d.ts +0 -36
- package/dist/internal/remote-client.js +0 -527
- package/dist/internal/remote-client.js.map +0 -1
- package/dist/internal/remote-shared.d.ts +0 -186
- package/dist/internal/remote-shared.js +0 -122
- package/dist/internal/remote-shared.js.map +0 -1
- package/dist/internal/transform.d.ts +0 -18
- package/dist/internal/transform.js +0 -418
- package/dist/internal/transform.js.map +0 -1
- package/dist/language-server.d.ts +0 -9
- package/dist/language-server.js +0 -4
- package/dist/mod.d.ts +0 -22
- package/dist/mod.js +0 -3
- package/dist/preprocess.d.ts +0 -29
- package/dist/preprocess.js +0 -20
- package/dist/preprocess.js.map +0 -1
- package/dist/root-node.d.ts +0 -1
- package/dist/root-node.js +0 -63
- package/dist/root-node.js.map +0 -1
- package/dist/server.d.ts +0 -81
- package/dist/server.js +0 -85
- package/dist/server.js.map +0 -1
- package/dist/v3/client.d.ts +0 -117
- package/dist/v3/effect.d.ts +0 -17
- package/dist/v3/mod.d.ts +0 -27
- package/dist/v3/preprocess.d.ts +0 -28
- package/dist/v3/root-node.d.ts +0 -59
- package/dist/v3/server.d.ts +0 -297
- package/dist/v3/vite.d.ts +0 -46
- package/dist/v4/client.d.ts +0 -2
- package/dist/v4/effect.d.ts +0 -24
- package/dist/v4/effect.js +0 -19
- package/dist/v4/effect.js.map +0 -1
- package/dist/v4/mod.d.ts +0 -27
- package/dist/v4/mod.js +0 -3
- package/dist/v4/preprocess.d.ts +0 -34
- package/dist/v4/preprocess.js +0 -32
- package/dist/v4/preprocess.js.map +0 -1
- package/dist/v4/root-node.d.ts +0 -59
- package/dist/v4/root-node.js +0 -4
- package/dist/v4/server.d.ts +0 -340
- package/dist/v4/server.js +0 -71
- package/dist/v4/server.js.map +0 -1
- package/dist/v4/vite.d.ts +0 -34
- package/dist/v4/vite.js +0 -31
- package/dist/v4/vite.js.map +0 -1
- package/dist/vite.d.ts +0 -31
- package/dist/vite.js +0 -24
- package/dist/vite.js.map +0 -1
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Marker property name placed on serialized `RemoteFailure` envelopes so the
|
|
3
|
-
* client adapters can recognise server-produced failure payloads.
|
|
4
|
-
*
|
|
5
|
-
* @internal Internal - do not use.
|
|
6
|
-
*/
|
|
7
|
-
export declare const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
8
|
-
/**
|
|
9
|
-
* Well-known symbol used to attach a payload decoder to a remote function,
|
|
10
|
-
* enabling the client to reconstruct typed domain errors from wire data.
|
|
11
|
-
*
|
|
12
|
-
* @internal Internal - do not use.
|
|
13
|
-
*/
|
|
14
|
-
export declare const REMOTE_ERROR_DECODER: unique symbol;
|
|
15
|
-
/**
|
|
16
|
-
* A single validation problem surfaced by a remote form or schema check.
|
|
17
|
-
* Mirrors SvelteKit's `invalid()` issue shape.
|
|
18
|
-
*/
|
|
19
|
-
export interface FormIssue {
|
|
20
|
-
/** Human-readable description of the failure at {@link FormIssue.path}. */
|
|
21
|
-
readonly message: string;
|
|
22
|
-
/** Field path (dot or array-index segments) the issue applies to. */
|
|
23
|
-
readonly path: ReadonlyArray<string | number>;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Typed error produced by `invalid.form(...)` / `invalid.<field>(...)` helpers
|
|
27
|
-
* inside a `Form` handler. Carries the collected `FormIssue`s to surface to
|
|
28
|
-
* the browser.
|
|
29
|
-
*/
|
|
30
|
-
export interface FormError<SchemaType = unknown> {
|
|
31
|
-
/** Discriminator identifying this as a form error. */
|
|
32
|
-
readonly _tag: "FormError";
|
|
33
|
-
/** Issues produced by the handler, one per failed field. */
|
|
34
|
-
readonly issues: ReadonlyArray<FormIssue>;
|
|
35
|
-
/**
|
|
36
|
-
* Phantom reference to the originating schema. Used purely for type
|
|
37
|
-
* inference of field helpers.
|
|
38
|
-
*/
|
|
39
|
-
readonly _schema?: SchemaType | undefined;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Legacy wrapper around a typed server-side domain error value.
|
|
43
|
-
*
|
|
44
|
-
* @deprecated Tagged remote domain errors are no longer wrapped in
|
|
45
|
-
* `RemoteDomainError`. The user's own tagged error is now placed directly on
|
|
46
|
-
* the Effect error channel so `Effect.catchTag("YourTag", ...)` works without
|
|
47
|
-
* unwrapping. This interface is kept only for backwards compatibility with
|
|
48
|
-
* code that pattern-matched on `_tag === "RemoteDomainError"`.
|
|
49
|
-
*/
|
|
50
|
-
export interface RemoteDomainError<ErrorType = unknown> {
|
|
51
|
-
/** Discriminator identifying this variant of `RemoteFailure`. */
|
|
52
|
-
readonly _tag: "RemoteDomainError";
|
|
53
|
-
/** The original typed error value produced on the server. */
|
|
54
|
-
readonly cause: ErrorType;
|
|
55
|
-
/** HTTP status code associated with the failure. */
|
|
56
|
-
readonly status: number;
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Remote failure emitted when request validation (schema or form) rejects the
|
|
60
|
-
* payload. Defaults to HTTP `400`, but callers may override the status code
|
|
61
|
-
* when constructing the value.
|
|
62
|
-
*/
|
|
63
|
-
export interface RemoteValidationError {
|
|
64
|
-
/** Discriminator identifying this variant of `RemoteFailure`. */
|
|
65
|
-
readonly _tag: "RemoteValidationError";
|
|
66
|
-
/** Raw response body returned alongside the failure, when available. */
|
|
67
|
-
readonly body?: unknown;
|
|
68
|
-
/** Validation issues, keyed by field path. */
|
|
69
|
-
readonly issues: ReadonlyArray<FormIssue>;
|
|
70
|
-
/** HTTP status code for the validation failure, defaulting to `400`. */
|
|
71
|
-
readonly status: number;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Remote failure for HTTP-level errors returned by the server that do not map
|
|
75
|
-
* onto a typed domain error or validation failure.
|
|
76
|
-
*/
|
|
77
|
-
export interface RemoteHttpError {
|
|
78
|
-
/** Discriminator identifying this variant of `RemoteFailure`. */
|
|
79
|
-
readonly _tag: "RemoteHttpError";
|
|
80
|
-
/** Parsed response body, if any. */
|
|
81
|
-
readonly body?: unknown;
|
|
82
|
-
/** Original thrown value captured while handling the response. */
|
|
83
|
-
readonly cause: unknown;
|
|
84
|
-
/** HTTP status code reported by the response. */
|
|
85
|
-
readonly status: number;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Remote failure for transport-level breakages (network errors, decoding
|
|
89
|
-
* failures). Does not carry an HTTP status.
|
|
90
|
-
*/
|
|
91
|
-
export interface RemoteTransportError {
|
|
92
|
-
/** Discriminator identifying this variant of `RemoteFailure`. */
|
|
93
|
-
readonly _tag: "RemoteTransportError";
|
|
94
|
-
/** Raw body captured when the transport failure was detected, if any. */
|
|
95
|
-
readonly body?: unknown;
|
|
96
|
-
/** Underlying error value - usually a `TypeError` or `DOMException`. */
|
|
97
|
-
readonly cause: unknown;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Error channel produced by every remote Effect wrapper. A server-side
|
|
101
|
-
* `Effect.fail(MyTaggedError)` surfaces on the client as the raw `ErrorType`,
|
|
102
|
-
* so `Effect.catchTag("MyTag", ...)` narrows directly to your error. The
|
|
103
|
-
* framework-level failure variants (`RemoteValidationError`,
|
|
104
|
-
* `RemoteHttpError`, `RemoteTransportError`) are still included for transport
|
|
105
|
-
* and HTTP failures that the caller didn't model explicitly.
|
|
106
|
-
*/
|
|
107
|
-
export type RemoteFailure<ErrorType = unknown> = ErrorType | RemoteValidationError | RemoteHttpError | RemoteTransportError;
|
|
108
|
-
/**
|
|
109
|
-
* Wire shape of a serialised remote failure envelope that the server embeds
|
|
110
|
-
* in its response body.
|
|
111
|
-
*
|
|
112
|
-
* @internal Internal - do not use.
|
|
113
|
-
*/
|
|
114
|
-
export interface SerializedRemoteFailureEnvelope {
|
|
115
|
-
/** Marker flag; always `true`. */
|
|
116
|
-
readonly [EFFECT_REMOTE_ERROR_MARKER]: true;
|
|
117
|
-
/** `devalue.stringify`-encoded payload for the failure value. */
|
|
118
|
-
readonly encoded: string;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Construct a {@link FormError} from one or more {@link FormIssue}s.
|
|
122
|
-
*
|
|
123
|
-
* @internal Internal - do not use.
|
|
124
|
-
*/
|
|
125
|
-
export declare function create_form_error<SchemaType = unknown>(...issues: Array<FormIssue>): FormError<SchemaType>;
|
|
126
|
-
/**
|
|
127
|
-
* Build a {@link RemoteDomainError} around a typed server-side error value.
|
|
128
|
-
*
|
|
129
|
-
* @deprecated Remote tagged failures are no longer wrapped - the user's
|
|
130
|
-
* tagged error is forwarded directly on the Effect error channel. This helper
|
|
131
|
-
* is retained for backwards compatibility with downstream code that still
|
|
132
|
-
* constructs `RemoteDomainError` values explicitly.
|
|
133
|
-
*
|
|
134
|
-
* @internal Internal - do not use.
|
|
135
|
-
*/
|
|
136
|
-
export declare function create_remote_domain_error<ErrorType = unknown>(cause: ErrorType, status: number): RemoteDomainError<ErrorType>;
|
|
137
|
-
/**
|
|
138
|
-
* Build a {@link RemoteValidationError} from a list of issues.
|
|
139
|
-
*
|
|
140
|
-
* @internal Internal - do not use.
|
|
141
|
-
*/
|
|
142
|
-
export declare function create_remote_validation_error(issues: ReadonlyArray<FormIssue>, options?: {
|
|
143
|
-
body?: unknown;
|
|
144
|
-
status?: number;
|
|
145
|
-
}): RemoteValidationError;
|
|
146
|
-
/**
|
|
147
|
-
* Build a {@link RemoteHttpError} from an arbitrary thrown value.
|
|
148
|
-
*
|
|
149
|
-
* @internal Internal - do not use.
|
|
150
|
-
*/
|
|
151
|
-
export declare function create_remote_http_error(cause: unknown, options?: {
|
|
152
|
-
body?: unknown;
|
|
153
|
-
status?: number;
|
|
154
|
-
}): RemoteHttpError;
|
|
155
|
-
/**
|
|
156
|
-
* Build a {@link RemoteTransportError} from an arbitrary thrown value.
|
|
157
|
-
*
|
|
158
|
-
* @internal Internal - do not use.
|
|
159
|
-
*/
|
|
160
|
-
export declare function create_remote_transport_error(cause: unknown, body?: unknown): RemoteTransportError;
|
|
161
|
-
/**
|
|
162
|
-
* Wrap a pre-encoded failure payload in the marker envelope the client
|
|
163
|
-
* adapters look for when decoding responses.
|
|
164
|
-
*
|
|
165
|
-
* @internal Internal - do not use.
|
|
166
|
-
*/
|
|
167
|
-
export declare function create_serialized_remote_failure_envelope(encoded: string): SerializedRemoteFailureEnvelope;
|
|
168
|
-
/**
|
|
169
|
-
* Type guard for {@link FormError} values.
|
|
170
|
-
*
|
|
171
|
-
* @internal Internal - do not use.
|
|
172
|
-
*/
|
|
173
|
-
export declare function is_form_error(value: unknown): value is FormError;
|
|
174
|
-
/**
|
|
175
|
-
* Type guard recognising the marker envelope wrapping an encoded remote
|
|
176
|
-
* failure payload.
|
|
177
|
-
*
|
|
178
|
-
* @internal Internal - do not use.
|
|
179
|
-
*/
|
|
180
|
-
export declare function is_serialized_remote_failure_envelope(value: unknown): value is SerializedRemoteFailureEnvelope;
|
|
181
|
-
/**
|
|
182
|
-
* Type guard for individual {@link FormIssue} values.
|
|
183
|
-
*
|
|
184
|
-
* @internal Internal - do not use.
|
|
185
|
-
*/
|
|
186
|
-
export declare function is_remote_validation_issue(value: unknown): value is FormIssue;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
//#region internal/remote-shared.ts
|
|
2
|
-
/**
|
|
3
|
-
* Marker property name placed on serialized `RemoteFailure` envelopes so the
|
|
4
|
-
* client adapters can recognise server-produced failure payloads.
|
|
5
|
-
*
|
|
6
|
-
* @internal Internal - do not use.
|
|
7
|
-
*/
|
|
8
|
-
const EFFECT_REMOTE_ERROR_MARKER = "__svelte_effect_remote__";
|
|
9
|
-
/**
|
|
10
|
-
* Well-known symbol used to attach a payload decoder to a remote function,
|
|
11
|
-
* enabling the client to reconstruct typed domain errors from wire data.
|
|
12
|
-
*
|
|
13
|
-
* @internal Internal - do not use.
|
|
14
|
-
*/
|
|
15
|
-
const REMOTE_ERROR_DECODER = Symbol.for("svelte-effect-runtime/remote-error-decoder");
|
|
16
|
-
/**
|
|
17
|
-
* Construct a {@link FormError} from one or more {@link FormIssue}s.
|
|
18
|
-
*
|
|
19
|
-
* @internal Internal - do not use.
|
|
20
|
-
*/
|
|
21
|
-
function create_form_error(...issues) {
|
|
22
|
-
return {
|
|
23
|
-
_tag: "FormError",
|
|
24
|
-
issues
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Build a {@link RemoteDomainError} around a typed server-side error value.
|
|
29
|
-
*
|
|
30
|
-
* @deprecated Remote tagged failures are no longer wrapped - the user's
|
|
31
|
-
* tagged error is forwarded directly on the Effect error channel. This helper
|
|
32
|
-
* is retained for backwards compatibility with downstream code that still
|
|
33
|
-
* constructs `RemoteDomainError` values explicitly.
|
|
34
|
-
*
|
|
35
|
-
* @internal Internal - do not use.
|
|
36
|
-
*/
|
|
37
|
-
function create_remote_domain_error(cause, status) {
|
|
38
|
-
return {
|
|
39
|
-
_tag: "RemoteDomainError",
|
|
40
|
-
cause,
|
|
41
|
-
status
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Build a {@link RemoteValidationError} from a list of issues.
|
|
46
|
-
*
|
|
47
|
-
* @internal Internal - do not use.
|
|
48
|
-
*/
|
|
49
|
-
function create_remote_validation_error(issues, options = {}) {
|
|
50
|
-
return {
|
|
51
|
-
_tag: "RemoteValidationError",
|
|
52
|
-
body: options.body,
|
|
53
|
-
issues,
|
|
54
|
-
status: options.status ?? 400
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Build a {@link RemoteHttpError} from an arbitrary thrown value.
|
|
59
|
-
*
|
|
60
|
-
* @internal Internal - do not use.
|
|
61
|
-
*/
|
|
62
|
-
function create_remote_http_error(cause, options = {}) {
|
|
63
|
-
return {
|
|
64
|
-
_tag: "RemoteHttpError",
|
|
65
|
-
body: options.body,
|
|
66
|
-
cause,
|
|
67
|
-
status: options.status ?? 500
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Build a {@link RemoteTransportError} from an arbitrary thrown value.
|
|
72
|
-
*
|
|
73
|
-
* @internal Internal - do not use.
|
|
74
|
-
*/
|
|
75
|
-
function create_remote_transport_error(cause, body) {
|
|
76
|
-
return {
|
|
77
|
-
_tag: "RemoteTransportError",
|
|
78
|
-
body,
|
|
79
|
-
cause
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Wrap a pre-encoded failure payload in the marker envelope the client
|
|
84
|
-
* adapters look for when decoding responses.
|
|
85
|
-
*
|
|
86
|
-
* @internal Internal - do not use.
|
|
87
|
-
*/
|
|
88
|
-
function create_serialized_remote_failure_envelope(encoded) {
|
|
89
|
-
return {
|
|
90
|
-
[EFFECT_REMOTE_ERROR_MARKER]: true,
|
|
91
|
-
encoded
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Type guard for {@link FormError} values.
|
|
96
|
-
*
|
|
97
|
-
* @internal Internal - do not use.
|
|
98
|
-
*/
|
|
99
|
-
function is_form_error(value) {
|
|
100
|
-
return Boolean(value && typeof value === "object" && value._tag === "FormError" && Array.isArray(value.issues));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Type guard recognising the marker envelope wrapping an encoded remote
|
|
104
|
-
* failure payload.
|
|
105
|
-
*
|
|
106
|
-
* @internal Internal - do not use.
|
|
107
|
-
*/
|
|
108
|
-
function is_serialized_remote_failure_envelope(value) {
|
|
109
|
-
return Boolean(value && typeof value === "object" && "__svelte_effect_remote__" in value && value["__svelte_effect_remote__"] === true && typeof value.encoded === "string");
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Type guard for individual {@link FormIssue} values.
|
|
113
|
-
*
|
|
114
|
-
* @internal Internal - do not use.
|
|
115
|
-
*/
|
|
116
|
-
function is_remote_validation_issue(value) {
|
|
117
|
-
return Boolean(value && typeof value === "object" && typeof value.message === "string" && Array.isArray(value.path));
|
|
118
|
-
}
|
|
119
|
-
//#endregion
|
|
120
|
-
export { EFFECT_REMOTE_ERROR_MARKER, REMOTE_ERROR_DECODER, create_form_error, create_remote_domain_error, create_remote_http_error, create_remote_transport_error, create_remote_validation_error, create_serialized_remote_failure_envelope, is_form_error, is_remote_validation_issue, is_serialized_remote_failure_envelope };
|
|
121
|
-
|
|
122
|
-
//# sourceMappingURL=remote-shared.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/internal/remote-shared.ts"],"sourcesContent":["/**\n * Marker property name placed on serialized `RemoteFailure` envelopes so the\n * client adapters can recognise server-produced failure payloads.\n *\n * @internal Internal - do not use.\n */\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\n/**\n * Well-known symbol used to attach a payload decoder to a remote function,\n * enabling the client to reconstruct typed domain errors from wire data.\n *\n * @internal Internal - do not use.\n */\nexport const REMOTE_ERROR_DECODER = Symbol.for(\n \"svelte-effect-runtime/remote-error-decoder\",\n);\n\n/**\n * A single validation problem surfaced by a remote form or schema check.\n * Mirrors SvelteKit's `invalid()` issue shape.\n */\nexport interface FormIssue {\n /** Human-readable description of the failure at {@link FormIssue.path}. */\n readonly message: string;\n /** Field path (dot or array-index segments) the issue applies to. */\n readonly path: ReadonlyArray<string | number>;\n}\n\n/**\n * Typed error produced by `invalid.form(...)` / `invalid.<field>(...)` helpers\n * inside a `Form` handler. Carries the collected `FormIssue`s to surface to\n * the browser.\n */\nexport interface FormError<SchemaType = unknown> {\n /** Discriminator identifying this as a form error. */\n readonly _tag: \"FormError\";\n /** Issues produced by the handler, one per failed field. */\n readonly issues: ReadonlyArray<FormIssue>;\n /**\n * Phantom reference to the originating schema. Used purely for type\n * inference of field helpers.\n */\n readonly _schema?: SchemaType | undefined;\n}\n\n/**\n * Legacy wrapper around a typed server-side domain error value.\n *\n * @deprecated Tagged remote domain errors are no longer wrapped in\n * `RemoteDomainError`. The user's own tagged error is now placed directly on\n * the Effect error channel so `Effect.catchTag(\"YourTag\", ...)` works without\n * unwrapping. This interface is kept only for backwards compatibility with\n * code that pattern-matched on `_tag === \"RemoteDomainError\"`.\n */\nexport interface RemoteDomainError<ErrorType = unknown> {\n /** Discriminator identifying this variant of `RemoteFailure`. */\n readonly _tag: \"RemoteDomainError\";\n /** The original typed error value produced on the server. */\n readonly cause: ErrorType;\n /** HTTP status code associated with the failure. */\n readonly status: number;\n}\n\n/**\n * Remote failure emitted when request validation (schema or form) rejects the\n * payload. Defaults to HTTP `400`, but callers may override the status code\n * when constructing the value.\n */\nexport interface RemoteValidationError {\n /** Discriminator identifying this variant of `RemoteFailure`. */\n readonly _tag: \"RemoteValidationError\";\n /** Raw response body returned alongside the failure, when available. */\n readonly body?: unknown;\n /** Validation issues, keyed by field path. */\n readonly issues: ReadonlyArray<FormIssue>;\n /** HTTP status code for the validation failure, defaulting to `400`. */\n readonly status: number;\n}\n\n/**\n * Remote failure for HTTP-level errors returned by the server that do not map\n * onto a typed domain error or validation failure.\n */\nexport interface RemoteHttpError {\n /** Discriminator identifying this variant of `RemoteFailure`. */\n readonly _tag: \"RemoteHttpError\";\n /** Parsed response body, if any. */\n readonly body?: unknown;\n /** Original thrown value captured while handling the response. */\n readonly cause: unknown;\n /** HTTP status code reported by the response. */\n readonly status: number;\n}\n\n/**\n * Remote failure for transport-level breakages (network errors, decoding\n * failures). Does not carry an HTTP status.\n */\nexport interface RemoteTransportError {\n /** Discriminator identifying this variant of `RemoteFailure`. */\n readonly _tag: \"RemoteTransportError\";\n /** Raw body captured when the transport failure was detected, if any. */\n readonly body?: unknown;\n /** Underlying error value - usually a `TypeError` or `DOMException`. */\n readonly cause: unknown;\n}\n\n/**\n * Error channel produced by every remote Effect wrapper. A server-side\n * `Effect.fail(MyTaggedError)` surfaces on the client as the raw `ErrorType`,\n * so `Effect.catchTag(\"MyTag\", ...)` narrows directly to your error. The\n * framework-level failure variants (`RemoteValidationError`,\n * `RemoteHttpError`, `RemoteTransportError`) are still included for transport\n * and HTTP failures that the caller didn't model explicitly.\n */\nexport type RemoteFailure<ErrorType = unknown> =\n | ErrorType\n | RemoteValidationError\n | RemoteHttpError\n | RemoteTransportError;\n\n/**\n * Wire shape of a serialised remote failure envelope that the server embeds\n * in its response body.\n *\n * @internal Internal - do not use.\n */\nexport interface SerializedRemoteFailureEnvelope {\n /** Marker flag; always `true`. */\n readonly [EFFECT_REMOTE_ERROR_MARKER]: true;\n /** `devalue.stringify`-encoded payload for the failure value. */\n readonly encoded: string;\n}\n\n/**\n * Construct a {@link FormError} from one or more {@link FormIssue}s.\n *\n * @internal Internal - do not use.\n */\nexport function create_form_error<SchemaType = unknown>(\n ...issues: Array<FormIssue>\n): FormError<SchemaType> {\n return {\n _tag: \"FormError\",\n issues,\n };\n}\n\n/**\n * Build a {@link RemoteDomainError} around a typed server-side error value.\n *\n * @deprecated Remote tagged failures are no longer wrapped - the user's\n * tagged error is forwarded directly on the Effect error channel. This helper\n * is retained for backwards compatibility with downstream code that still\n * constructs `RemoteDomainError` values explicitly.\n *\n * @internal Internal - do not use.\n */\nexport function create_remote_domain_error<ErrorType = unknown>(\n cause: ErrorType,\n status: number,\n): RemoteDomainError<ErrorType> {\n return {\n _tag: \"RemoteDomainError\",\n cause,\n status,\n };\n}\n\n/**\n * Build a {@link RemoteValidationError} from a list of issues.\n *\n * @internal Internal - do not use.\n */\nexport function create_remote_validation_error(\n issues: ReadonlyArray<FormIssue>,\n options: {\n body?: unknown;\n status?: number;\n } = {},\n): RemoteValidationError {\n return {\n _tag: \"RemoteValidationError\",\n body: options.body,\n issues,\n status: options.status ?? 400,\n };\n}\n\n/**\n * Build a {@link RemoteHttpError} from an arbitrary thrown value.\n *\n * @internal Internal - do not use.\n */\nexport function create_remote_http_error(\n cause: unknown,\n options: {\n body?: unknown;\n status?: number;\n } = {},\n): RemoteHttpError {\n return {\n _tag: \"RemoteHttpError\",\n body: options.body,\n cause,\n status: options.status ?? 500,\n };\n}\n\n/**\n * Build a {@link RemoteTransportError} from an arbitrary thrown value.\n *\n * @internal Internal - do not use.\n */\nexport function create_remote_transport_error(\n cause: unknown,\n body?: unknown,\n): RemoteTransportError {\n return {\n _tag: \"RemoteTransportError\",\n body,\n cause,\n };\n}\n\n/**\n * Wrap a pre-encoded failure payload in the marker envelope the client\n * adapters look for when decoding responses.\n *\n * @internal Internal - do not use.\n */\nexport function create_serialized_remote_failure_envelope(\n encoded: string,\n): SerializedRemoteFailureEnvelope {\n return {\n [EFFECT_REMOTE_ERROR_MARKER]: true,\n encoded,\n };\n}\n\n/**\n * Type guard for {@link FormError} values.\n *\n * @internal Internal - do not use.\n */\nexport function is_form_error(value: unknown): value is FormError {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n (value as { _tag?: unknown })._tag === \"FormError\" &&\n Array.isArray((value as { issues?: unknown }).issues),\n );\n}\n\n/**\n * Type guard recognising the marker envelope wrapping an encoded remote\n * failure payload.\n *\n * @internal Internal - do not use.\n */\nexport function is_serialized_remote_failure_envelope(\n value: unknown,\n): value is SerializedRemoteFailureEnvelope {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n EFFECT_REMOTE_ERROR_MARKER in value &&\n (value as Record<string, unknown>)[EFFECT_REMOTE_ERROR_MARKER] === true &&\n typeof (value as { encoded?: unknown }).encoded === \"string\",\n );\n}\n\n/**\n * Type guard for individual {@link FormIssue} values.\n *\n * @internal Internal - do not use.\n */\nexport function is_remote_validation_issue(\n value: unknown,\n): value is FormIssue {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { message?: unknown }).message === \"string\" &&\n Array.isArray((value as { path?: unknown }).path),\n );\n}\n"],"mappings":";;;;;;;AAMA,MAAa,6BAA6B;;;;;;;AAO1C,MAAa,uBAAuB,OAAO,IACzC,6CACD;;;;;;AA4HD,SAAgB,kBACd,GAAG,QACoB;AACvB,QAAO;EACL,MAAM;EACN;EACD;;;;;;;;;;;;AAaH,SAAgB,2BACd,OACA,QAC8B;AAC9B,QAAO;EACL,MAAM;EACN;EACA;EACD;;;;;;;AAQH,SAAgB,+BACd,QACA,UAGI,EAAE,EACiB;AACvB,QAAO;EACL,MAAM;EACN,MAAM,QAAQ;EACd;EACA,QAAQ,QAAQ,UAAU;EAC3B;;;;;;;AAQH,SAAgB,yBACd,OACA,UAGI,EAAE,EACW;AACjB,QAAO;EACL,MAAM;EACN,MAAM,QAAQ;EACd;EACA,QAAQ,QAAQ,UAAU;EAC3B;;;;;;;AAQH,SAAgB,8BACd,OACA,MACsB;AACtB,QAAO;EACL,MAAM;EACN;EACA;EACD;;;;;;;;AASH,SAAgB,0CACd,SACiC;AACjC,QAAO;GACJ,6BAA6B;EAC9B;EACD;;;;;;;AAQH,SAAgB,cAAc,OAAoC;AAChE,QAAO,QACL,SACE,OAAO,UAAU,YAChB,MAA6B,SAAS,eACvC,MAAM,QAAS,MAA+B,OAAO,CACxD;;;;;;;;AASH,SAAgB,sCACd,OAC0C;AAC1C,QAAO,QACL,SACE,OAAO,UAAU,YAAA,8BACa,SAC7B,MAAA,gCAAkE,QACnE,OAAQ,MAAgC,YAAY,SACvD;;;;;;;AAQH,SAAgB,2BACd,OACoB;AACpB,QAAO,QACL,SACE,OAAO,UAAU,YACjB,OAAQ,MAAgC,YAAY,YACpD,MAAM,QAAS,MAA6B,KAAK,CACpD"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type SourceMap } from "magic-string";
|
|
2
|
-
import type { EffectPreprocessOptions } from "../preprocess.js";
|
|
3
|
-
interface TransformEffectScriptOptions extends EffectPreprocessOptions {
|
|
4
|
-
filename: string;
|
|
5
|
-
}
|
|
6
|
-
interface TransformEffectScriptResult {
|
|
7
|
-
code: string;
|
|
8
|
-
map: SourceMap;
|
|
9
|
-
relocations: Array<TransformRelocation>;
|
|
10
|
-
}
|
|
11
|
-
interface TransformRelocation {
|
|
12
|
-
originalStart: number;
|
|
13
|
-
originalEnd: number;
|
|
14
|
-
generatedStart: number;
|
|
15
|
-
generatedEnd: number;
|
|
16
|
-
}
|
|
17
|
-
export declare function transformEffectScript(content: string, options: TransformEffectScriptOptions): TransformEffectScriptResult;
|
|
18
|
-
export {};
|