svelte-effect-runtime 1.3.1 → 1.4.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-DkW4e4dD.js → client-vV6UAwoP.js} +3 -3
- package/dist/chunks/client-vV6UAwoP.js.map +1 -0
- package/dist/chunks/{server-DR-6LMdP.js → server-7YVuxUNk.js} +53 -8
- package/dist/chunks/server-7YVuxUNk.js.map +1 -0
- package/dist/chunks/v3-D0c0MKPf.js +1 -0
- package/dist/chunks/v4-MMhHmzIG.js +1 -0
- package/dist/client.js +1 -1
- package/dist/internal/remote-client.js +3 -3
- package/dist/internal/remote-client.js.map +1 -1
- package/dist/internal/remote-shared.d.ts +134 -1
- package/dist/internal/remote-shared.js +64 -0
- package/dist/internal/remote-shared.js.map +1 -1
- package/dist/internal/transform.d.ts +7 -0
- package/dist/internal/transform.js +172 -15
- package/dist/internal/transform.js.map +1 -1
- package/dist/mod.d.ts +21 -0
- package/dist/mod.js +2 -2
- package/dist/preprocess.d.ts +5 -0
- package/dist/preprocess.js +6 -1
- package/dist/preprocess.js.map +1 -1
- package/dist/root-node.js +3 -3
- package/dist/server.d.ts +25 -0
- package/dist/server.js +26 -1
- package/dist/server.js.map +1 -1
- package/dist/v3/client.d.ts +24 -0
- package/dist/v3/mod.d.ts +24 -0
- package/dist/v3/server.d.ts +106 -0
- package/dist/v4/mod.d.ts +24 -0
- package/dist/v4/mod.js +2 -2
- package/dist/v4/preprocess.d.ts +4 -0
- package/dist/v4/preprocess.js +5 -1
- package/dist/v4/preprocess.js.map +1 -1
- package/dist/v4/root-node.js +2 -2
- package/dist/v4/server.d.ts +196 -0
- package/dist/v4/server.js +50 -1
- package/dist/v4/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunks/client-DkW4e4dD.js.map +0 -1
- package/dist/chunks/server-DR-6LMdP.js.map +0 -1
- package/dist/chunks/v3-p8V3Drpp.js +0 -1
- package/dist/chunks/v4-DIhYCbb_.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../../modules/svelte-effect-runtime/v4/preprocess.ts"],"sourcesContent":["/**\n * v4-specific preprocess entrypoints and helpers.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/v4/preprocess\";\n *\n * const preprocess = effect_preprocess();\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\nexport const V4_RUNTIME_MODULE_ID = \"svelte-effect-runtime/v4\";\n\n/**\n * Apply the default v4 runtime module id to a preprocess options bag.\n *\n * @internal Internal — do not use.\n */\nexport function with_v4_effect_preprocess_options(\n options: EffectPreprocessOptions = {},\n): EffectPreprocessOptions {\n return {\n ...options,\n runtimeModuleId: options.runtimeModuleId ?? V4_RUNTIME_MODULE_ID,\n };\n}\n\n/**\n * Low-level Svelte preprocessor for the v4 runtime entry.\n *\n * Advanced entry point used by tooling and custom build setups.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options: EffectPreprocessOptions = {},\n): PreprocessorGroup {\n return create_effect_preprocess(with_v4_effect_preprocess_options(options));\n}\n"],"mappings":";;AAoBA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,kCACd,UAAmC,EAAE,EACZ;AACzB,QAAO;EACL,GAAG;EACH,iBAAiB,QAAQ,mBAAA;EAC1B;;;;;;;;;AAUH,SAAgB,kBACd,UAAmC,EAAE,EAClB;AACnB,QAAOA,oBAAyB,kCAAkC,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"preprocess.js","names":["create_effect_preprocess"],"sources":["../../../modules/svelte-effect-runtime/v4/preprocess.ts"],"sourcesContent":["/**\n * v4-specific preprocess entrypoints and helpers.\n *\n * @example\n * ```ts\n * import { effect_preprocess } from \"svelte-effect-runtime/v4/preprocess\";\n *\n * const preprocess = effect_preprocess();\n * ```\n *\n * @module\n */\nimport type { PreprocessorGroup } from \"svelte/compiler\";\nimport {\n effect_preprocess as create_effect_preprocess,\n type EffectPreprocessOptions,\n} from \"$/v3/preprocess.ts\";\n\nexport type { EffectPreprocessOptions } from \"$/v3/preprocess.ts\";\n\nexport const V4_RUNTIME_MODULE_ID = \"svelte-effect-runtime/v4\";\n\n/**\n * Apply the default v4 runtime module id to a preprocess options bag.\n *\n * @internal Internal — do not use.\n */\nexport function with_v4_effect_preprocess_options(\n options: EffectPreprocessOptions = {},\n): EffectPreprocessOptions {\n return {\n ...options,\n runtimeModuleId: options.runtimeModuleId ?? V4_RUNTIME_MODULE_ID,\n };\n}\n\n/**\n * Low-level Svelte preprocessor for the v4 runtime entry.\n *\n * Advanced entry point used by tooling and custom build setups.\n *\n * @see https://ser.barekey.dev/content/reference/preprocess\n */\nexport function effect_preprocess(\n options: EffectPreprocessOptions = {},\n): PreprocessorGroup {\n return create_effect_preprocess(with_v4_effect_preprocess_options(options));\n}\n\n/**\n * Backwards-compatible camelCase alias retained for older downstream imports.\n */\nexport const effectPreprocess = effect_preprocess;\n"],"mappings":";;AAoBA,MAAa,uBAAuB;;;;;;AAOpC,SAAgB,kCACd,UAAmC,EAAE,EACZ;AACzB,QAAO;EACL,GAAG;EACH,iBAAiB,QAAQ,mBAAA;EAC1B;;;;;;;;;AAUH,SAAgB,kBACd,UAAmC,EAAE,EAClB;AACnB,QAAOA,oBAAyB,kCAAkC,QAAQ,CAAC;;;;;AAM7E,MAAa,mBAAmB"}
|
package/dist/v4/root-node.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-
|
|
2
|
-
import "../chunks/v4-
|
|
1
|
+
import { a as run_component_effect, c as to_native, o as run_inline_effect, r as get_effect_runtime_or_throw, s as to_effect, t as ClientRuntime } from "../chunks/client-vV6UAwoP.js";
|
|
2
|
+
import "../chunks/v4-MMhHmzIG.js";
|
|
3
3
|
import { effect } from "./effect.js";
|
|
4
4
|
export { ClientRuntime, effect, get_effect_runtime_or_throw, run_component_effect, run_inline_effect, to_effect, to_native };
|
package/dist/v4/server.d.ts
CHANGED
|
@@ -1,24 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* v4 server-side entrypoint for `svelte-effect-runtime`.
|
|
3
|
+
*
|
|
4
|
+
* Provides Effect v4-flavoured remote-function helpers and the updated
|
|
5
|
+
* `ServerRuntime` builder whose `RuntimeOperator` signature accepts the
|
|
6
|
+
* v4-style `Layer.provide(...)` operator. Usually consumed indirectly: the
|
|
7
|
+
* Vite plugin rewrites `svelte-effect-runtime/v4` imports inside `.remote.ts`
|
|
8
|
+
* to resolve here at build time.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* import { Query, ServerRuntime } from "svelte-effect-runtime/v4/_server";
|
|
13
|
+
* import { Effect, Layer, Schema } from "effect";
|
|
14
|
+
*
|
|
15
|
+
* ServerRuntime.make(Layer.provide(MyServiceLayer));
|
|
16
|
+
*
|
|
17
|
+
* export const hello = Query(Schema.String, (name) =>
|
|
18
|
+
* Effect.succeed(`hello ${name}`)
|
|
19
|
+
* );
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
23
|
+
*
|
|
24
|
+
* @module
|
|
25
|
+
*/
|
|
1
26
|
import type { RemoteForm as SvelteKitRemoteForm, RemoteFormInput as SvelteKitRemoteFormInput } from "@sveltejs/kit";
|
|
2
27
|
import type { getRequestEvent as get_native_request_event } from "$app/server";
|
|
3
28
|
import type { Effect as Effect_type, Layer as Layer_type } from "effect";
|
|
4
29
|
import * as base_server from "../v3/server.js";
|
|
5
30
|
import type { FormError, RemoteFailure } from "../internal/remote-shared.js";
|
|
6
31
|
import { type EffectContextKey, type EffectSchemaLike } from "../internal/effect-compat.js";
|
|
32
|
+
/**
|
|
33
|
+
* Single entry in a {@link Transport} table. Describes how to encode a value
|
|
34
|
+
* to a wire payload and decode it back.
|
|
35
|
+
*
|
|
36
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
37
|
+
*/
|
|
7
38
|
export interface Transporter<T = unknown, U = {
|
|
8
39
|
value: unknown;
|
|
9
40
|
}> {
|
|
41
|
+
/** Restore the original value from the wire payload. */
|
|
10
42
|
decode: (data: U) => T;
|
|
43
|
+
/**
|
|
44
|
+
* Encode the value to a wire payload, or return `false` when this transporter
|
|
45
|
+
* does not apply to the supplied value.
|
|
46
|
+
*/
|
|
11
47
|
encode: (value: T) => false | U;
|
|
12
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Named collection of {@link Transporter}s used by devalue to round-trip
|
|
51
|
+
* custom types across the client/server boundary.
|
|
52
|
+
*
|
|
53
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
54
|
+
*/
|
|
13
55
|
export type Transport = Record<string, Transporter>;
|
|
56
|
+
/** Alias for SvelteKit's native remote-form input shape. */
|
|
14
57
|
export type RemoteFormInput = SvelteKitRemoteFormInput;
|
|
58
|
+
/** SvelteKit's native `query` function signature, re-exported for typing. */
|
|
15
59
|
export type RemoteQueryFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
60
|
+
/** SvelteKit's native `command` shape, re-exported for typing. */
|
|
16
61
|
export type RemoteCommand<Input, Output> = ((arg: OptionalArgument<Input>) => Promise<Output> & {
|
|
17
62
|
updates(...updates: Array<unknown>): Promise<Output>;
|
|
18
63
|
}) & {
|
|
19
64
|
readonly pending: number;
|
|
20
65
|
};
|
|
66
|
+
/** SvelteKit's native `prerender` function signature, re-exported for typing. */
|
|
21
67
|
export type RemotePrerenderFunction<Input, Output> = (arg: OptionalArgument<Input>) => Promise<Output>;
|
|
68
|
+
/** SvelteKit's native `form` shape, re-exported for typing. */
|
|
22
69
|
export type RemoteForm<Input extends RemoteFormInput | void, Output> = SvelteKitRemoteForm<Input, Output>;
|
|
23
70
|
type OptionalArgument<Input> = undefined extends Input ? Input | void : Input;
|
|
24
71
|
type RuntimeOperator = (self: Layer_type.Layer<unknown, unknown, unknown>) => Layer_type.Layer<unknown, unknown, unknown>;
|
|
@@ -37,61 +84,161 @@ type SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends {
|
|
|
37
84
|
type FieldHelpers<FormShape, SchemaType> = FormShape extends Record<string, unknown> ? {
|
|
38
85
|
[Key in keyof FormShape as Key extends string ? Key : never]: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
39
86
|
} : Record<PropertyKey, never>;
|
|
87
|
+
/**
|
|
88
|
+
* Proxy passed into v4 `Form` handlers for reporting validation issues. Call
|
|
89
|
+
* `invalid.form(message)` for a top-level issue, or `invalid.<field>(message)`
|
|
90
|
+
* to attach the issue to a specific field.
|
|
91
|
+
*
|
|
92
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
93
|
+
*/
|
|
40
94
|
export type Invalid<SchemaType = unknown> = {
|
|
95
|
+
/** Attach a top-level form issue with the supplied message. */
|
|
41
96
|
form: (message: string) => Effect_type.Effect<never, FormError<SchemaType>, never>;
|
|
42
97
|
} & FieldHelpers<SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown, SchemaType>;
|
|
98
|
+
/**
|
|
99
|
+
* v4 shape of an Effect-returning remote `query`. Exposes the underlying
|
|
100
|
+
* SvelteKit function via `native`.
|
|
101
|
+
*
|
|
102
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
103
|
+
*/
|
|
43
104
|
export type EffectQueryFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
105
|
+
/** Underlying SvelteKit `query` function, for fallback direct usage. */
|
|
44
106
|
native: RemoteQueryFunction<Input, Output>;
|
|
45
107
|
};
|
|
108
|
+
/**
|
|
109
|
+
* v4 shape of an Effect-returning remote `command`. Tracks in-flight
|
|
110
|
+
* submissions via `pending`.
|
|
111
|
+
*
|
|
112
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
113
|
+
*/
|
|
46
114
|
export type EffectCommand<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
115
|
+
/** Underlying SvelteKit `command` function, for fallback direct usage. */
|
|
47
116
|
native: RemoteCommand<Input, Output>;
|
|
117
|
+
/** Count of currently in-flight invocations of this command. */
|
|
48
118
|
readonly pending: number;
|
|
49
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* v4 shape of an Effect-returning remote `prerender` function.
|
|
122
|
+
*
|
|
123
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
124
|
+
*/
|
|
50
125
|
export type EffectPrerenderFunction<Input, Output, Error = never> = ((arg: OptionalArgument<Input>) => Effect_type.Effect<Output, RemoteFailure<Error>, never>) & {
|
|
126
|
+
/** Underlying SvelteKit `prerender` function, for fallback direct usage. */
|
|
51
127
|
native: RemotePrerenderFunction<Input, Output>;
|
|
52
128
|
};
|
|
129
|
+
/**
|
|
130
|
+
* v4 shape of an Effect-returning remote `form`. Adds `submit(data)` and
|
|
131
|
+
* `for(...)` on top of the underlying SvelteKit form.
|
|
132
|
+
*
|
|
133
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
134
|
+
*/
|
|
53
135
|
export type EffectForm<Input extends RemoteFormInput | void, Output, Error = never> = RemoteForm<Input, Output> & {
|
|
136
|
+
/** Underlying SvelteKit `form` object, for fallback direct usage. */
|
|
54
137
|
native: RemoteForm<Input, Output>;
|
|
138
|
+
/** Submit the form programmatically and receive the result as an Effect. */
|
|
55
139
|
submit(data: OptionalArgument<Input>): Effect_type.Effect<Output, RemoteFailure<Error>, never>;
|
|
140
|
+
/** Clone the form binding for a specific value - mirrors `RemoteForm.for`. */
|
|
56
141
|
for: RemoteForm<Input, Output>["for"] extends (...args: infer Args) => infer Result ? (...args: Args) => EffectForm<Input, Output, Error> & Result : never;
|
|
57
142
|
};
|
|
143
|
+
/**
|
|
144
|
+
* v4 type of the SvelteKit `RequestEvent` exposed through the
|
|
145
|
+
* {@link RequestEvent} Effect service.
|
|
146
|
+
*/
|
|
58
147
|
export type RequestEventService = ReturnType<typeof get_native_request_event>;
|
|
148
|
+
/**
|
|
149
|
+
* Builder shape returned by {@link ServerRuntime} in the v4 runtime. Accepts
|
|
150
|
+
* v4-style `Layer` operators and installs a singleton `ManagedRuntime`.
|
|
151
|
+
*
|
|
152
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
153
|
+
*/
|
|
59
154
|
export interface ServerRuntimeSeed {
|
|
155
|
+
/** Compose operators into a Layer without installing a runtime. */
|
|
60
156
|
pipe(): Layer_type.Layer<never>;
|
|
157
|
+
/** Compose operators into a Layer without installing a runtime. */
|
|
61
158
|
pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): FinalRuntimeLayer<Ops>;
|
|
159
|
+
/** Build and install the singleton server runtime. */
|
|
62
160
|
make(): void;
|
|
161
|
+
/** Build and install the singleton server runtime. */
|
|
63
162
|
make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(...ops: Ops): void;
|
|
64
163
|
}
|
|
164
|
+
/**
|
|
165
|
+
* Subset of `ManagedRuntime` surface used by generated v4 server wrappers.
|
|
166
|
+
*
|
|
167
|
+
* @internal Internal - do not use.
|
|
168
|
+
*/
|
|
65
169
|
export interface EffectManagedRuntime {
|
|
170
|
+
/** Execute an Effect and resolve with its raw `Exit`. */
|
|
66
171
|
runPromiseExit<A, E, R>(effect: Effect_type.Effect<A, E, R>): Promise<unknown>;
|
|
172
|
+
/** Tear down the runtime and release its root scope. */
|
|
67
173
|
dispose(): Promise<void>;
|
|
68
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Signature of `Query.batch` in the v4 runtime - kept loosely typed because
|
|
177
|
+
* the v4 server-side implementation delegates to the v3 batch factory.
|
|
178
|
+
*
|
|
179
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
180
|
+
*/
|
|
69
181
|
export interface EffectQueryBatchFactory {
|
|
182
|
+
/** Build a batched query from validator + handler arguments. */
|
|
70
183
|
(...args: Array<unknown>): unknown;
|
|
71
184
|
}
|
|
185
|
+
/**
|
|
186
|
+
* v4 overload set for the {@link Query} factory. Mirrors
|
|
187
|
+
* {@link import("../v3/server.js").EffectQueryFactory} using v4 schema-like
|
|
188
|
+
* inference.
|
|
189
|
+
*
|
|
190
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
191
|
+
*/
|
|
72
192
|
export interface EffectQueryFactory {
|
|
193
|
+
/** Define a void-input query. */
|
|
73
194
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<void, Output, Error>;
|
|
195
|
+
/** Define a query that bypasses schema validation. */
|
|
74
196
|
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<Input, Output, Error>;
|
|
197
|
+
/** Define a query whose input is validated by an Effect.Schema. */
|
|
75
198
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
199
|
+
/** Define a batched query - mirrors SvelteKit's `query.batch`. */
|
|
76
200
|
batch: EffectQueryBatchFactory;
|
|
77
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* v4 overload set for the {@link Command} factory.
|
|
204
|
+
*
|
|
205
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
206
|
+
*/
|
|
78
207
|
export interface EffectCommandFactory {
|
|
208
|
+
/** Define a void-input command. */
|
|
79
209
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<void, Output, Error>;
|
|
210
|
+
/** Define a command that bypasses schema validation. */
|
|
80
211
|
<Input, Output, Error, Requirements>(validate: "unchecked", fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<Input, Output, Error>;
|
|
212
|
+
/** Define a command whose input is validated by an Effect.Schema. */
|
|
81
213
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (arg: SchemaOutput<SchemaType>) => Effect_type.Effect<Output, Error, Requirements>): EffectCommand<SchemaInput<SchemaType>, Output, Error>;
|
|
82
214
|
}
|
|
83
215
|
type RemotePrerenderInputsGenerator<Input> = (event: RequestEventService) => AsyncIterable<Input> | Iterable<Input>;
|
|
216
|
+
/**
|
|
217
|
+
* v4 overload set for the {@link Form} factory.
|
|
218
|
+
*
|
|
219
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
220
|
+
*/
|
|
84
221
|
export interface EffectFormFactory {
|
|
222
|
+
/** Define a form handler with no input data. */
|
|
85
223
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>): EffectForm<void, Output, Error>;
|
|
224
|
+
/** Define a form handler that bypasses schema validation. */
|
|
86
225
|
<Input extends RemoteFormInput, Output, Error, Requirements>(validate: "unchecked", fn: (args: {
|
|
87
226
|
data: Input;
|
|
88
227
|
invalid: Invalid;
|
|
89
228
|
}) => Effect_type.Effect<Output, Error | FormError, Requirements>): EffectForm<Input, Output, Error>;
|
|
229
|
+
/** Define a form handler whose submitted data is validated by a schema. */
|
|
90
230
|
<SchemaType extends EffectSchemaLike, Output, Error, Requirements>(validate: SchemaType, fn: (args: {
|
|
91
231
|
data: SchemaOutput<SchemaType>;
|
|
92
232
|
invalid: Invalid<SchemaType>;
|
|
93
233
|
}) => Effect_type.Effect<Output, Error | FormError<SchemaType>, Requirements>): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;
|
|
94
234
|
}
|
|
235
|
+
/**
|
|
236
|
+
* v4 overload set for the {@link Prerender} factory. Supports the same three
|
|
237
|
+
* validation flavours as the other factories plus a SvelteKit `options` bag
|
|
238
|
+
* with `inputs` / `dynamic` flags.
|
|
239
|
+
*
|
|
240
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
241
|
+
*/
|
|
95
242
|
export interface EffectPrerenderFactory {
|
|
96
243
|
<Output, Error, Requirements>(fn: () => Effect_type.Effect<Output, Error, Requirements>, options?: {
|
|
97
244
|
inputs?: RemotePrerenderInputsGenerator<void>;
|
|
@@ -106,13 +253,62 @@ export interface EffectPrerenderFactory {
|
|
|
106
253
|
dynamic?: boolean;
|
|
107
254
|
}): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;
|
|
108
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* v4 flavour of {@link import("../v3/server.js").Query} - define a read-only
|
|
258
|
+
* remote function returning an Effect.
|
|
259
|
+
*
|
|
260
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
261
|
+
*/
|
|
109
262
|
export declare const Query: EffectQueryFactory;
|
|
263
|
+
/**
|
|
264
|
+
* v4 flavour of {@link import("../v3/server.js").Command} - define a
|
|
265
|
+
* write-oriented remote function returning an Effect.
|
|
266
|
+
*
|
|
267
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
268
|
+
*/
|
|
110
269
|
export declare const Command: EffectCommandFactory;
|
|
270
|
+
/**
|
|
271
|
+
* v4 flavour of {@link import("../v3/server.js").Form} - define a remote form
|
|
272
|
+
* handler that maps submitted data into an Effect program.
|
|
273
|
+
*
|
|
274
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
275
|
+
*/
|
|
111
276
|
export declare const Form: EffectFormFactory;
|
|
277
|
+
/**
|
|
278
|
+
* v4 flavour of {@link import("../v3/server.js").Prerender} - define a
|
|
279
|
+
* prerenderable remote function backed by an Effect program.
|
|
280
|
+
*
|
|
281
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
282
|
+
*/
|
|
112
283
|
export declare const Prerender: EffectPrerenderFactory;
|
|
284
|
+
/**
|
|
285
|
+
* v4 Effect `Context.Tag` for the current SvelteKit `RequestEvent`. Shaped
|
|
286
|
+
* like an `Effect` so handlers can `yield* RequestEvent` directly.
|
|
287
|
+
*
|
|
288
|
+
* @see https://ser.barekey.dev/content/runtimes/server
|
|
289
|
+
*/
|
|
113
290
|
export declare const RequestEvent: EffectContextKey<RequestEventService, RequestEventService> & Effect_type.Effect<RequestEventService, never, RequestEventService>;
|
|
291
|
+
/**
|
|
292
|
+
* v4 server-side runtime builder. Equivalent to the v3 builder but typed
|
|
293
|
+
* against the v4 `Layer` operator signature.
|
|
294
|
+
*
|
|
295
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
296
|
+
*/
|
|
114
297
|
export declare const ServerRuntime: ServerRuntimeSeed;
|
|
298
|
+
/**
|
|
299
|
+
* Build a devalue transport table from Effect schemas so remote payloads can
|
|
300
|
+
* round-trip custom data across the client/server boundary.
|
|
301
|
+
*
|
|
302
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
303
|
+
*/
|
|
115
304
|
export declare const create_effect_transport: typeof base_server.create_effect_transport;
|
|
305
|
+
/**
|
|
306
|
+
* Resolve the active v4 server runtime, lazily creating a default empty
|
|
307
|
+
* runtime when none has been registered.
|
|
308
|
+
*
|
|
309
|
+
* @internal Internal - do not use.
|
|
310
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
311
|
+
*/
|
|
116
312
|
export declare const get_server_runtime_or_throw: () => EffectManagedRuntime;
|
|
117
313
|
/**
|
|
118
314
|
* Remap low-level request-store crashes into a clearer setup error when remote
|
package/dist/v4/server.js
CHANGED
|
@@ -1,13 +1,62 @@
|
|
|
1
1
|
import { a as make_context_key } from "../chunks/effect-compat-BhW0YPIs.js";
|
|
2
|
-
import { c as get_server_runtime_or_throw$1, i as Query$1, l as normalize_remote_helper_error$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "../chunks/server-
|
|
2
|
+
import { c as get_server_runtime_or_throw$1, i as Query$1, l as normalize_remote_helper_error$1, n as Form$1, o as ServerRuntime$1, r as Prerender$1, s as create_effect_transport$1, t as Command$1 } from "../chunks/server-7YVuxUNk.js";
|
|
3
3
|
//#region v4/server.ts
|
|
4
|
+
/**
|
|
5
|
+
* v4 flavour of {@link import("$/v3/server.ts").Query} - define a read-only
|
|
6
|
+
* remote function returning an Effect.
|
|
7
|
+
*
|
|
8
|
+
* @see https://ser.barekey.dev/content/remote-functions/query
|
|
9
|
+
*/
|
|
4
10
|
const Query = Query$1;
|
|
11
|
+
/**
|
|
12
|
+
* v4 flavour of {@link import("$/v3/server.ts").Command} - define a
|
|
13
|
+
* write-oriented remote function returning an Effect.
|
|
14
|
+
*
|
|
15
|
+
* @see https://ser.barekey.dev/content/remote-functions/command
|
|
16
|
+
*/
|
|
5
17
|
const Command = Command$1;
|
|
18
|
+
/**
|
|
19
|
+
* v4 flavour of {@link import("$/v3/server.ts").Form} - define a remote form
|
|
20
|
+
* handler that maps submitted data into an Effect program.
|
|
21
|
+
*
|
|
22
|
+
* @see https://ser.barekey.dev/content/remote-functions/form
|
|
23
|
+
*/
|
|
6
24
|
const Form = Form$1;
|
|
25
|
+
/**
|
|
26
|
+
* v4 flavour of {@link import("$/v3/server.ts").Prerender} - define a
|
|
27
|
+
* prerenderable remote function backed by an Effect program.
|
|
28
|
+
*
|
|
29
|
+
* @see https://ser.barekey.dev/content/remote-functions/prerender
|
|
30
|
+
*/
|
|
7
31
|
const Prerender = Prerender$1;
|
|
32
|
+
/**
|
|
33
|
+
* v4 Effect `Context.Tag` for the current SvelteKit `RequestEvent`. Shaped
|
|
34
|
+
* like an `Effect` so handlers can `yield* RequestEvent` directly.
|
|
35
|
+
*
|
|
36
|
+
* @see https://ser.barekey.dev/content/runtimes/server
|
|
37
|
+
*/
|
|
8
38
|
const RequestEvent = make_context_key("svelte-effect-runtime/RequestEvent");
|
|
39
|
+
/**
|
|
40
|
+
* v4 server-side runtime builder. Equivalent to the v3 builder but typed
|
|
41
|
+
* against the v4 `Layer` operator signature.
|
|
42
|
+
*
|
|
43
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
44
|
+
*/
|
|
9
45
|
const ServerRuntime = ServerRuntime$1;
|
|
46
|
+
/**
|
|
47
|
+
* Build a devalue transport table from Effect schemas so remote payloads can
|
|
48
|
+
* round-trip custom data across the client/server boundary.
|
|
49
|
+
*
|
|
50
|
+
* @see https://ser.barekey.dev/content/reference/transport
|
|
51
|
+
*/
|
|
10
52
|
const create_effect_transport = create_effect_transport$1;
|
|
53
|
+
/**
|
|
54
|
+
* Resolve the active v4 server runtime, lazily creating a default empty
|
|
55
|
+
* runtime when none has been registered.
|
|
56
|
+
*
|
|
57
|
+
* @internal Internal - do not use.
|
|
58
|
+
* @see https://ser.barekey.dev/content/reference/server-runtime
|
|
59
|
+
*/
|
|
11
60
|
const get_server_runtime_or_throw = get_server_runtime_or_throw$1;
|
|
12
61
|
/**
|
|
13
62
|
* Remap low-level request-store crashes into a clearer setup error when remote
|
package/dist/v4/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["base_server.Query","base_server.Command","base_server.Form","base_server.Prerender","base_server.ServerRuntime","base_server.create_effect_transport","base_server.get_server_runtime_or_throw","base_server.normalize_remote_helper_error"],"sources":["../../../modules/svelte-effect-runtime/v4/server.ts"],"sourcesContent":["import type {\n RemoteForm as SvelteKitRemoteForm,\n RemoteFormInput as SvelteKitRemoteFormInput,\n} from \"@sveltejs/kit\";\nimport type { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport type { Effect as Effect_type, Layer as Layer_type } from \"effect\";\nimport * as base_server from \"$/v3/server.ts\";\nimport type { FormError, RemoteFailure } from \"$internal/remote-shared.ts\";\nimport {\n type EffectContextKey,\n type EffectSchemaLike,\n make_context_key,\n} from \"$internal/effect-compat.ts\";\n\nexport interface Transporter<T = unknown, U = { value: unknown }> {\n decode: (data: U) => T;\n encode: (value: T) => false | U;\n}\n\nexport type Transport = Record<string, Transporter>;\n\nexport type RemoteFormInput = SvelteKitRemoteFormInput;\n\nexport type RemoteQueryFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteCommand<Input, Output> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Promise<Output> & {\n updates(...updates: Array<unknown>): Promise<Output>;\n })\n & {\n readonly pending: number;\n };\n\nexport type RemotePrerenderFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\nexport type RemoteForm<Input extends RemoteFormInput | void, Output> =\n SvelteKitRemoteForm<Input, Output>;\n\ntype OptionalArgument<Input> = undefined extends Input ? Input | void : Input;\n\ntype RuntimeOperator = (\n self: Layer_type.Layer<unknown, unknown, unknown>,\n) => Layer_type.Layer<unknown, unknown, unknown>;\n\ntype RuntimeSeedLayer<Requirements> = Layer_type.Layer<\n Requirements,\n never,\n Requirements\n>;\n\ntype ProvidedBy<Op> = Op extends (\n self: RuntimeSeedLayer<infer Requirements>,\n) => Layer_type.Layer<unknown, unknown, infer Incoming>\n ? Exclude<Requirements, Incoming>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer_type.Layer<unknown, unknown, infer Incoming>\n ? [Incoming] extends [never] ? Out\n : never\n : never\n : never;\n\ntype SchemaInput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Encoded: infer Input } ? Input\n : never;\n\ntype SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Type: infer Output } ? Output\n : never;\n\ntype FieldHelpers<FormShape, SchemaType> = FormShape extends\n Record<string, unknown> ? {\n [Key in keyof FormShape as Key extends string ? Key : never]: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n : Record<PropertyKey, never>;\n\nexport type Invalid<SchemaType = unknown> =\n & {\n form: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n & FieldHelpers<\n SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown,\n SchemaType\n >;\n\nexport type EffectQueryFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteQueryFunction<Input, Output>;\n };\n\nexport type EffectCommand<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemoteCommand<Input, Output>;\n readonly pending: number;\n };\n\nexport type EffectPrerenderFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n native: RemotePrerenderFunction<Input, Output>;\n };\n\nexport type EffectForm<\n Input extends RemoteFormInput | void,\n Output,\n Error = never,\n> = RemoteForm<Input, Output> & {\n native: RemoteForm<Input, Output>;\n submit(\n data: OptionalArgument<Input>,\n ): Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >;\n for: RemoteForm<Input, Output>[\"for\"] extends\n (...args: infer Args) => infer Result\n ? (...args: Args) => EffectForm<Input, Output, Error> & Result\n : never;\n};\n\nexport type RequestEventService = ReturnType<typeof get_native_request_event>;\n\nexport interface ServerRuntimeSeed {\n pipe(): Layer_type.Layer<never>;\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n make(): void;\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): void;\n}\n\nexport interface EffectManagedRuntime {\n runPromiseExit<A, E, R>(\n effect: Effect_type.Effect<A, E, R>,\n ): Promise<unknown>;\n dispose(): Promise<void>;\n}\n\nexport interface EffectQueryBatchFactory {\n (...args: Array<unknown>): unknown;\n}\n\nexport interface EffectQueryFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;\n batch: EffectQueryBatchFactory;\n}\n\nexport interface EffectCommandFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<SchemaInput<SchemaType>, Output, Error>;\n}\n\ntype RemotePrerenderInputsGenerator<Input> = (\n event: RequestEventService,\n) => AsyncIterable<Input> | Iterable<Input>;\n\nexport interface EffectFormFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectForm<void, Output, Error>;\n <Input extends RemoteFormInput, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (\n args: {\n data: Input;\n invalid: Invalid;\n },\n ) => Effect_type.Effect<Output, Error | FormError, Requirements>,\n ): EffectForm<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n args: {\n data: SchemaOutput<SchemaType>;\n invalid: Invalid<SchemaType>;\n },\n ) => Effect_type.Effect<\n Output,\n Error | FormError<SchemaType>,\n Requirements\n >,\n ): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;\n}\n\nexport interface EffectPrerenderFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<void>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<Input>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;\n}\n\nexport const Query: EffectQueryFactory = base_server.Query;\nexport const Command: EffectCommandFactory = base_server.Command;\nexport const Form: EffectFormFactory = base_server.Form;\nexport const Prerender: EffectPrerenderFactory = base_server.Prerender;\nexport const RequestEvent = make_context_key<\n RequestEventService,\n RequestEventService\n>(\n \"svelte-effect-runtime/RequestEvent\",\n) as\n & EffectContextKey<RequestEventService, RequestEventService>\n & Effect_type.Effect<RequestEventService, never, RequestEventService>;\nexport const ServerRuntime: ServerRuntimeSeed = base_server.ServerRuntime;\nexport const create_effect_transport:\n typeof base_server.create_effect_transport =\n base_server.create_effect_transport;\nexport const get_server_runtime_or_throw: () => EffectManagedRuntime =\n base_server.get_server_runtime_or_throw;\n/**\n * Remap low-level request-store crashes into a clearer setup error when remote\n * helpers are evaluated outside SvelteKit's remote-function runtime.\n *\n * @internal Internal - do not use.\n */\nexport const normalize_remote_helper_error =\n base_server.normalize_remote_helper_error;\n"],"mappings":";;;AAgSA,MAAa,QAA4BA;AACzC,MAAa,UAAgCC;AAC7C,MAAa,OAA0BC;AACvC,MAAa,YAAoCC;AACjD,MAAa,eAAe,iBAI1B,qCACD;AAGD,MAAa,gBAAmCC;AAChD,MAAa,0BAETC;AACJ,MAAa,8BACXC;;;;;;;AAOF,MAAa,gCACXC"}
|
|
1
|
+
{"version":3,"file":"server.js","names":["base_server.Query","base_server.Command","base_server.Form","base_server.Prerender","base_server.ServerRuntime","base_server.create_effect_transport","base_server.get_server_runtime_or_throw","base_server.normalize_remote_helper_error"],"sources":["../../../modules/svelte-effect-runtime/v4/server.ts"],"sourcesContent":["/**\n * v4 server-side entrypoint for `svelte-effect-runtime`.\n *\n * Provides Effect v4-flavoured remote-function helpers and the updated\n * `ServerRuntime` builder whose `RuntimeOperator` signature accepts the\n * v4-style `Layer.provide(...)` operator. Usually consumed indirectly: the\n * Vite plugin rewrites `svelte-effect-runtime/v4` imports inside `.remote.ts`\n * to resolve here at build time.\n *\n * @example\n * ```ts\n * import { Query, ServerRuntime } from \"svelte-effect-runtime/v4/_server\";\n * import { Effect, Layer, Schema } from \"effect\";\n *\n * ServerRuntime.make(Layer.provide(MyServiceLayer));\n *\n * export const hello = Query(Schema.String, (name) =>\n * Effect.succeed(`hello ${name}`)\n * );\n * ```\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n *\n * @module\n */\nimport type {\n RemoteForm as SvelteKitRemoteForm,\n RemoteFormInput as SvelteKitRemoteFormInput,\n} from \"@sveltejs/kit\";\nimport type { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport type { Effect as Effect_type, Layer as Layer_type } from \"effect\";\nimport * as base_server from \"$/v3/server.ts\";\nimport type { FormError, RemoteFailure } from \"$internal/remote-shared.ts\";\nimport {\n type EffectContextKey,\n type EffectSchemaLike,\n make_context_key,\n} from \"$internal/effect-compat.ts\";\n\n/**\n * Single entry in a {@link Transport} table. Describes how to encode a value\n * to a wire payload and decode it back.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport interface Transporter<T = unknown, U = { value: unknown }> {\n /** Restore the original value from the wire payload. */\n decode: (data: U) => T;\n /**\n * Encode the value to a wire payload, or return `false` when this transporter\n * does not apply to the supplied value.\n */\n encode: (value: T) => false | U;\n}\n\n/**\n * Named collection of {@link Transporter}s used by devalue to round-trip\n * custom types across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport type Transport = Record<string, Transporter>;\n\n/** Alias for SvelteKit's native remote-form input shape. */\nexport type RemoteFormInput = SvelteKitRemoteFormInput;\n\n/** SvelteKit's native `query` function signature, re-exported for typing. */\nexport type RemoteQueryFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\n/** SvelteKit's native `command` shape, re-exported for typing. */\nexport type RemoteCommand<Input, Output> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Promise<Output> & {\n updates(...updates: Array<unknown>): Promise<Output>;\n })\n & {\n readonly pending: number;\n };\n\n/** SvelteKit's native `prerender` function signature, re-exported for typing. */\nexport type RemotePrerenderFunction<Input, Output> = (\n arg: OptionalArgument<Input>,\n) => Promise<Output>;\n\n/** SvelteKit's native `form` shape, re-exported for typing. */\nexport type RemoteForm<Input extends RemoteFormInput | void, Output> =\n SvelteKitRemoteForm<Input, Output>;\n\ntype OptionalArgument<Input> = undefined extends Input ? Input | void : Input;\n\ntype RuntimeOperator = (\n self: Layer_type.Layer<unknown, unknown, unknown>,\n) => Layer_type.Layer<unknown, unknown, unknown>;\n\ntype RuntimeSeedLayer<Requirements> = Layer_type.Layer<\n Requirements,\n never,\n Requirements\n>;\n\ntype ProvidedBy<Op> = Op extends (\n self: RuntimeSeedLayer<infer Requirements>,\n) => Layer_type.Layer<unknown, unknown, infer Incoming>\n ? Exclude<Requirements, Incoming>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer_type.Layer<unknown, unknown, infer Incoming>\n ? [Incoming] extends [never] ? Out\n : never\n : never\n : never;\n\ntype SchemaInput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Encoded: infer Input } ? Input\n : never;\n\ntype SchemaOutput<SchemaType extends EffectSchemaLike> = SchemaType extends\n { readonly Type: infer Output } ? Output\n : never;\n\ntype FieldHelpers<FormShape, SchemaType> = FormShape extends\n Record<string, unknown> ? {\n [Key in keyof FormShape as Key extends string ? Key : never]: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n : Record<PropertyKey, never>;\n\n/**\n * Proxy passed into v4 `Form` handlers for reporting validation issues. Call\n * `invalid.form(message)` for a top-level issue, or `invalid.<field>(message)`\n * to attach the issue to a specific field.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport type Invalid<SchemaType = unknown> =\n & {\n /** Attach a top-level form issue with the supplied message. */\n form: (\n message: string,\n ) => Effect_type.Effect<never, FormError<SchemaType>, never>;\n }\n & FieldHelpers<\n SchemaType extends EffectSchemaLike ? SchemaOutput<SchemaType> : unknown,\n SchemaType\n >;\n\n/**\n * v4 shape of an Effect-returning remote `query`. Exposes the underlying\n * SvelteKit function via `native`.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport type EffectQueryFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n /** Underlying SvelteKit `query` function, for fallback direct usage. */\n native: RemoteQueryFunction<Input, Output>;\n };\n\n/**\n * v4 shape of an Effect-returning remote `command`. Tracks in-flight\n * submissions via `pending`.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport type EffectCommand<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n /** Underlying SvelteKit `command` function, for fallback direct usage. */\n native: RemoteCommand<Input, Output>;\n /** Count of currently in-flight invocations of this command. */\n readonly pending: number;\n };\n\n/**\n * v4 shape of an Effect-returning remote `prerender` function.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport type EffectPrerenderFunction<Input, Output, Error = never> =\n & ((\n arg: OptionalArgument<Input>,\n ) => Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >)\n & {\n /** Underlying SvelteKit `prerender` function, for fallback direct usage. */\n native: RemotePrerenderFunction<Input, Output>;\n };\n\n/**\n * v4 shape of an Effect-returning remote `form`. Adds `submit(data)` and\n * `for(...)` on top of the underlying SvelteKit form.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport type EffectForm<\n Input extends RemoteFormInput | void,\n Output,\n Error = never,\n> = RemoteForm<Input, Output> & {\n /** Underlying SvelteKit `form` object, for fallback direct usage. */\n native: RemoteForm<Input, Output>;\n /** Submit the form programmatically and receive the result as an Effect. */\n submit(\n data: OptionalArgument<Input>,\n ): Effect_type.Effect<\n Output,\n RemoteFailure<Error>,\n never\n >;\n /** Clone the form binding for a specific value - mirrors `RemoteForm.for`. */\n for: RemoteForm<Input, Output>[\"for\"] extends\n (...args: infer Args) => infer Result\n ? (...args: Args) => EffectForm<Input, Output, Error> & Result\n : never;\n};\n\n/**\n * v4 type of the SvelteKit `RequestEvent` exposed through the\n * {@link RequestEvent} Effect service.\n */\nexport type RequestEventService = ReturnType<typeof get_native_request_event>;\n\n/**\n * Builder shape returned by {@link ServerRuntime} in the v4 runtime. Accepts\n * v4-style `Layer` operators and installs a singleton `ManagedRuntime`.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport interface ServerRuntimeSeed {\n /** Compose operators into a Layer without installing a runtime. */\n pipe(): Layer_type.Layer<never>;\n /** Compose operators into a Layer without installing a runtime. */\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n /** Build and install the singleton server runtime. */\n make(): void;\n /** Build and install the singleton server runtime. */\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): void;\n}\n\n/**\n * Subset of `ManagedRuntime` surface used by generated v4 server wrappers.\n *\n * @internal Internal - do not use.\n */\nexport interface EffectManagedRuntime {\n /** Execute an Effect and resolve with its raw `Exit`. */\n runPromiseExit<A, E, R>(\n effect: Effect_type.Effect<A, E, R>,\n ): Promise<unknown>;\n /** Tear down the runtime and release its root scope. */\n dispose(): Promise<void>;\n}\n\n/**\n * Signature of `Query.batch` in the v4 runtime - kept loosely typed because\n * the v4 server-side implementation delegates to the v3 batch factory.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport interface EffectQueryBatchFactory {\n /** Build a batched query from validator + handler arguments. */\n (...args: Array<unknown>): unknown;\n}\n\n/**\n * v4 overload set for the {@link Query} factory. Mirrors\n * {@link import(\"$/v3/server.ts\").EffectQueryFactory} using v4 schema-like\n * inference.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport interface EffectQueryFactory {\n /** Define a void-input query. */\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<void, Output, Error>;\n /** Define a query that bypasses schema validation. */\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<Input, Output, Error>;\n /** Define a query whose input is validated by an Effect.Schema. */\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectQueryFunction<SchemaInput<SchemaType>, Output, Error>;\n /** Define a batched query - mirrors SvelteKit's `query.batch`. */\n batch: EffectQueryBatchFactory;\n}\n\n/**\n * v4 overload set for the {@link Command} factory.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport interface EffectCommandFactory {\n /** Define a void-input command. */\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<void, Output, Error>;\n /** Define a command that bypasses schema validation. */\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<Input, Output, Error>;\n /** Define a command whose input is validated by an Effect.Schema. */\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectCommand<SchemaInput<SchemaType>, Output, Error>;\n}\n\ntype RemotePrerenderInputsGenerator<Input> = (\n event: RequestEventService,\n) => AsyncIterable<Input> | Iterable<Input>;\n\n/**\n * v4 overload set for the {@link Form} factory.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport interface EffectFormFactory {\n /** Define a form handler with no input data. */\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n ): EffectForm<void, Output, Error>;\n /** Define a form handler that bypasses schema validation. */\n <Input extends RemoteFormInput, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (\n args: {\n data: Input;\n invalid: Invalid;\n },\n ) => Effect_type.Effect<Output, Error | FormError, Requirements>,\n ): EffectForm<Input, Output, Error>;\n /** Define a form handler whose submitted data is validated by a schema. */\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n args: {\n data: SchemaOutput<SchemaType>;\n invalid: Invalid<SchemaType>;\n },\n ) => Effect_type.Effect<\n Output,\n Error | FormError<SchemaType>,\n Requirements\n >,\n ): EffectForm<SchemaInput<SchemaType> & RemoteFormInput, Output, Error>;\n}\n\n/**\n * v4 overload set for the {@link Prerender} factory. Supports the same three\n * validation flavours as the other factories plus a SvelteKit `options` bag\n * with `inputs` / `dynamic` flags.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport interface EffectPrerenderFactory {\n <Output, Error, Requirements>(\n fn: () => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<void>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<void, Output, Error>;\n <Input, Output, Error, Requirements>(\n validate: \"unchecked\",\n fn: (arg: Input) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<Input>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<Input, Output, Error>;\n <SchemaType extends EffectSchemaLike, Output, Error, Requirements>(\n validate: SchemaType,\n fn: (\n arg: SchemaOutput<SchemaType>,\n ) => Effect_type.Effect<Output, Error, Requirements>,\n options?: {\n inputs?: RemotePrerenderInputsGenerator<SchemaInput<SchemaType>>;\n dynamic?: boolean;\n },\n ): EffectPrerenderFunction<SchemaInput<SchemaType>, Output, Error>;\n}\n\n/**\n * v4 flavour of {@link import(\"$/v3/server.ts\").Query} - define a read-only\n * remote function returning an Effect.\n *\n * @see https://ser.barekey.dev/content/remote-functions/query\n */\nexport const Query: EffectQueryFactory = base_server.Query;\n/**\n * v4 flavour of {@link import(\"$/v3/server.ts\").Command} - define a\n * write-oriented remote function returning an Effect.\n *\n * @see https://ser.barekey.dev/content/remote-functions/command\n */\nexport const Command: EffectCommandFactory = base_server.Command;\n/**\n * v4 flavour of {@link import(\"$/v3/server.ts\").Form} - define a remote form\n * handler that maps submitted data into an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/form\n */\nexport const Form: EffectFormFactory = base_server.Form;\n/**\n * v4 flavour of {@link import(\"$/v3/server.ts\").Prerender} - define a\n * prerenderable remote function backed by an Effect program.\n *\n * @see https://ser.barekey.dev/content/remote-functions/prerender\n */\nexport const Prerender: EffectPrerenderFactory = base_server.Prerender;\n/**\n * v4 Effect `Context.Tag` for the current SvelteKit `RequestEvent`. Shaped\n * like an `Effect` so handlers can `yield* RequestEvent` directly.\n *\n * @see https://ser.barekey.dev/content/runtimes/server\n */\nexport const RequestEvent = make_context_key<\n RequestEventService,\n RequestEventService\n>(\n \"svelte-effect-runtime/RequestEvent\",\n) as\n & EffectContextKey<RequestEventService, RequestEventService>\n & Effect_type.Effect<RequestEventService, never, RequestEventService>;\n/**\n * v4 server-side runtime builder. Equivalent to the v3 builder but typed\n * against the v4 `Layer` operator signature.\n *\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const ServerRuntime: ServerRuntimeSeed = base_server.ServerRuntime;\n/**\n * Build a devalue transport table from Effect schemas so remote payloads can\n * round-trip custom data across the client/server boundary.\n *\n * @see https://ser.barekey.dev/content/reference/transport\n */\nexport const create_effect_transport:\n typeof base_server.create_effect_transport =\n base_server.create_effect_transport;\n/**\n * Resolve the active v4 server runtime, lazily creating a default empty\n * runtime when none has been registered.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/server-runtime\n */\nexport const get_server_runtime_or_throw: () => EffectManagedRuntime =\n base_server.get_server_runtime_or_throw;\n/**\n * Remap low-level request-store crashes into a clearer setup error when remote\n * helpers are evaluated outside SvelteKit's remote-function runtime.\n *\n * @internal Internal - do not use.\n */\nexport const normalize_remote_helper_error =\n base_server.normalize_remote_helper_error;\n"],"mappings":";;;;;;;;;AAybA,MAAa,QAA4BA;;;;;;;AAOzC,MAAa,UAAgCC;;;;;;;AAO7C,MAAa,OAA0BC;;;;;;;AAOvC,MAAa,YAAoCC;;;;;;;AAOjD,MAAa,eAAe,iBAI1B,qCACD;;;;;;;AASD,MAAa,gBAAmCC;;;;;;;AAOhD,MAAa,0BAETC;;;;;;;;AAQJ,MAAa,8BACXC;;;;;;;AAOF,MAAa,gCACXC"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-DkW4e4dD.js","names":[],"sources":["../../../modules/svelte-effect-runtime/v3/client.ts"],"sourcesContent":["import { Cause, Effect, Exit, Layer, ManagedRuntime } from \"effect\";\nimport { getContext, hasContext, onDestroy, setContext } from \"svelte\";\nimport {\n create_remote_domain_error,\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n is_serialized_remote_failure_envelope,\n REMOTE_ERROR_DECODER,\n type RemoteFailure,\n} from \"$internal/remote-shared.ts\";\nimport {\n create_async_effect,\n exit_has_interrupts,\n} from \"$internal/effect-compat.ts\";\n\nconst EFFECT_RUNTIME_CONTEXT = Symbol.for(\"svelte-effect-runtime/runtime\");\nlet current_client_runtime: EffectRuntime<unknown> | null = null;\n\ninterface ProvideEffectRuntimeOptions {\n disposeOnDestroy?: boolean;\n}\n\nexport interface EffectRuntime<R = unknown> {\n runCallback<A, E, R2>(\n effect: Effect.Effect<A, E, R2>,\n options?: {\n onExit?: (exit: Exit.Exit<A, E>) => void;\n },\n ): () => void;\n runPromise<A, E, R2>(effect: Effect.Effect<A, E, R2>): Promise<A>;\n dispose(): Promise<void>;\n}\n\nexport type {\n FormError,\n FormIssue,\n RemoteDomainError,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$internal/remote-shared.ts\";\n\nexport interface ClientRuntimeService extends EffectRuntime<unknown> {}\n\ntype RuntimeSeedLayer<R> = Layer.Layer<R, never, R>;\n\nfunction runtime_seed<R>(): RuntimeSeedLayer<R> {\n return Layer.effectContext(Effect.context<R>());\n}\n\ntype RuntimeOperator = (\n self: Layer.Layer<unknown, unknown, unknown>,\n) => Layer.Layer<unknown, unknown, unknown>;\n\ntype ProvidedBy<Op> = Op extends\n (self: RuntimeSeedLayer<infer R>) => Layer.Layer<unknown, unknown, infer RIn>\n ? Exclude<R, RIn>\n : never;\n\ntype ProvidedByAll<Ops extends ReadonlyArray<RuntimeOperator>> = Ops extends\n readonly [infer Head, ...infer Tail] ?\n | ProvidedBy<Head>\n | ProvidedByAll<Extract<Tail, ReadonlyArray<RuntimeOperator>>>\n : never;\n\ntype ApplyOperator<Seed, Op> = Op extends (self: Seed) => infer Out ? Out\n : never;\n\ntype ApplyOperators<\n Seed,\n Ops extends ReadonlyArray<RuntimeOperator>,\n> = Ops extends readonly [infer Head, ...infer Tail] ? ApplyOperators<\n ApplyOperator<Seed, Head>,\n Extract<Tail, ReadonlyArray<RuntimeOperator>>\n >\n : Seed;\n\ntype FinalRuntimeLayer<Ops extends ReadonlyArray<RuntimeOperator>> =\n ApplyOperators<RuntimeSeedLayer<ProvidedByAll<Ops>>, Ops> extends infer Out\n ? Out extends Layer.Layer<unknown, unknown, infer RIn>\n ? [RIn] extends [never] ? Out\n : never\n : never\n : never;\n\ninterface ClientRuntimeSeed {\n pipe(): Layer.Layer<never>;\n pipe<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): FinalRuntimeLayer<Ops>;\n make(): ManagedRuntime.ManagedRuntime<never, never>;\n make<const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>]>(\n ...ops: Ops\n ): ManagedRuntimeFromOps<Ops>;\n}\n\ntype ManagedRuntimeFromOps<Ops extends ReadonlyArray<RuntimeOperator>> =\n ManagedRuntime.ManagedRuntime<\n Layer.Layer.Success<FinalRuntimeLayer<Ops>>,\n Layer.Layer.Error<FinalRuntimeLayer<Ops>>\n >;\n\nfunction pipe_client_runtime(): Layer.Layer<never>;\nfunction pipe_client_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): FinalRuntimeLayer<Ops>;\nfunction pipe_client_runtime(\n ...ops: Array<RuntimeOperator>\n): Layer.Layer<never, unknown, unknown> {\n if (ops.length === 0) {\n return Layer.empty;\n }\n\n return ops.reduce<Layer.Layer<unknown, unknown, unknown>>(\n (layer, op) => op(layer),\n runtime_seed<unknown>(),\n ) as Layer.Layer<never, unknown, unknown>;\n}\n\nfunction make_client_runtime(): ManagedRuntime.ManagedRuntime<never, never>;\nfunction make_client_runtime<\n const Ops extends readonly [RuntimeOperator, ...Array<RuntimeOperator>],\n>(...ops: Ops): ManagedRuntimeFromOps<Ops>;\nfunction make_client_runtime(\n ...ops: [] | [RuntimeOperator, ...Array<RuntimeOperator>]\n): ManagedRuntime.ManagedRuntime<never, unknown> {\n const layer = ops.length === 0 ? pipe_client_runtime() : pipe_client_runtime(\n ...(ops as [RuntimeOperator, ...Array<RuntimeOperator>]),\n );\n\n const runtime = track_client_runtime(ManagedRuntime.make(\n layer as unknown as Layer.Layer<unknown, unknown, never>,\n ));\n\n void current_client_runtime?.dispose().catch(() => undefined);\n current_client_runtime = runtime;\n\n if (is_component_context_available()) {\n return provide_effect_runtime(runtime, { disposeOnDestroy: true });\n }\n\n return runtime;\n}\n\n/**\n * Build or compose the shared client-side `ManagedRuntime` used by generated\n * `<script effect>` and markup helpers.\n *\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport const ClientRuntime: ClientRuntimeSeed = {\n pipe: pipe_client_runtime,\n make: make_client_runtime,\n};\n\n/**\n * Register a pre-built `ManagedRuntime` on the current Svelte component\n * context. Not exported - callers should go through `ClientRuntime.make`.\n *\n * @internal Internal - do not use.\n */\nfunction provide_effect_runtime<T extends EffectRuntime>(\n runtime: T,\n options: ProvideEffectRuntimeOptions = {},\n): T {\n current_client_runtime = track_client_runtime(runtime);\n setContext(EFFECT_RUNTIME_CONTEXT, runtime);\n\n if (options.disposeOnDestroy) {\n onDestroy(() => {\n void runtime.dispose();\n });\n }\n\n return runtime;\n}\n\n/**\n * Look up the active client runtime for the current component, or lazily\n * create a default empty-layer runtime when no explicit one has been\n * registered.\n *\n * Emitted by the `<script effect>` / `{yield* ...}` preprocessor - users\n * should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function get_effect_runtime_or_throw<\n T extends EffectRuntime = EffectRuntime<never>,\n>(): T {\n if (has_runtime_context()) {\n return getContext<T>(EFFECT_RUNTIME_CONTEXT);\n }\n\n if (current_client_runtime !== null) {\n return current_client_runtime as T;\n }\n\n // No runtime registered — lazily create a default one with an empty layer.\n // This makes `ClientRuntime.make()` in `hooks.client.ts` optional for apps\n // that don't need to provide custom dependencies. A later explicit call to\n // `ClientRuntime.make(...)` will dispose this default and replace it.\n const default_runtime = track_client_runtime(\n ManagedRuntime.make(\n Layer.empty as unknown as Layer.Layer<unknown, unknown, never>,\n ),\n );\n current_client_runtime = default_runtime;\n return default_runtime as unknown as T;\n}\n\n/**\n * Mount-time runner used by generated `<script effect>` output.\n *\n * Emitted by the preprocessor - users should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function run_component_effect<A, E, R>(\n runtime: EffectRuntime<R>,\n program: Effect.Effect<A, E, R>,\n): () => void {\n let disposed = false;\n\n const cancel = runtime.runCallback(program, {\n onExit(exit) {\n if (Exit.isFailure(exit) && !exit_has_interrupts(exit)) {\n queueMicrotask(() => {\n throw Cause.squash(exit.cause);\n });\n }\n },\n });\n\n return () => {\n if (disposed) {\n return;\n }\n\n disposed = true;\n cancel();\n };\n}\n\n/**\n * Promise-returning runner used by generated `{yield* ...}` markup helpers.\n *\n * Emitted by the preprocessor - users should never import this directly.\n *\n * @internal Internal - do not use.\n * @see https://ser.barekey.dev/content/reference/client-runtime\n */\nexport function run_inline_effect<A, E, R>(\n runtime: EffectRuntime<R>,\n program: Effect.Effect<A, E, R>,\n): Promise<A> {\n return runtime.runPromise(program).catch((error) => {\n queueMicrotask(() => {\n throw error;\n });\n\n throw error;\n });\n}\n\nfunction has_runtime_context(): boolean {\n try {\n return hasContext(EFFECT_RUNTIME_CONTEXT);\n } catch {\n return false;\n }\n}\n\nfunction is_component_context_available(): boolean {\n try {\n void hasContext(EFFECT_RUNTIME_CONTEXT);\n return true;\n } catch {\n return false;\n }\n}\n\nfunction track_client_runtime<T extends EffectRuntime>(runtime: T): T {\n const tracked_runtime = runtime as T & { __ser_tracked__?: true };\n\n if (tracked_runtime.__ser_tracked__ === true) {\n return tracked_runtime;\n }\n\n const dispose = runtime.dispose.bind(runtime);\n tracked_runtime.__ser_tracked__ = true;\n runtime.dispose = (() => {\n if (current_client_runtime === tracked_runtime) {\n current_client_runtime = null;\n }\n\n return dispose();\n }) as typeof runtime.dispose;\n\n return tracked_runtime;\n}\n\n/**\n * Internal redirect guard used by the remote client adapters.\n *\n * @internal Internal - do not use.\n */\nfunction is_redirect_like(value: unknown): boolean {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { location?: unknown }).location === \"string\" &&\n typeof (value as { status?: unknown }).status === \"number\",\n );\n}\n\ntype Decode_remote_payload = <ErrorType = unknown>(\n encoded: string,\n) => ErrorType;\n\nfunction is_http_error_like(\n value: unknown,\n): value is {\n readonly body?: unknown;\n readonly status?: number;\n} {\n return Boolean(\n value &&\n typeof value === \"object\" &&\n typeof (value as { status?: unknown }).status === \"number\",\n );\n}\n\nfunction get_error_status(value: unknown): number {\n return is_http_error_like(value) ? value.status ?? 500 : 500;\n}\n\nfunction get_remote_error_decoder(\n value: unknown,\n): Decode_remote_payload | undefined {\n if (\n value &&\n (typeof value === \"object\" || typeof value === \"function\") &&\n REMOTE_ERROR_DECODER in value\n ) {\n return (value as { [REMOTE_ERROR_DECODER]: Decode_remote_payload })[\n REMOTE_ERROR_DECODER\n ];\n }\n}\n\nfunction decode_remote_error<ErrorType>(\n error: unknown,\n decode_payload?: Decode_remote_payload,\n): RemoteFailure<ErrorType> {\n if (is_http_error_like(error)) {\n const body = error.body;\n\n if (is_serialized_remote_failure_envelope(body) && decode_payload) {\n try {\n return create_remote_domain_error<ErrorType>(\n decode_payload<ErrorType>(body.encoded),\n get_error_status(error),\n );\n } catch (cause) {\n return create_remote_transport_error(cause, body);\n }\n }\n\n if (get_error_status(error) === 400) {\n return create_remote_validation_error([], {\n body,\n status: 400,\n });\n }\n\n return create_remote_http_error(error, {\n body,\n status: get_error_status(error),\n });\n }\n\n return create_remote_http_error(error);\n}\n\n/**\n * Internal adapter that lifts a promise-producing callback into the shared\n * remote failure channel used by client wrappers.\n *\n * @internal Internal - do not use.\n */\nfunction create_remote_effect_from_promise<Success, ErrorType = never>(\n create_promise: () => PromiseLike<Success>,\n decode_error: (error: unknown) => RemoteFailure<ErrorType> = (error) =>\n create_remote_http_error(error),\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never> {\n return create_async_effect<Success, RemoteFailure<ErrorType>>((resume) => {\n void Promise.resolve()\n .then(create_promise)\n .then(\n (value) => resume(Effect.succeed(value)),\n (error) => {\n if (is_redirect_like(error)) {\n resume(Effect.die(error));\n return;\n }\n\n resume(Effect.fail(decode_error(error)));\n },\n );\n });\n}\n\ntype AnyCallable = (...args: Array<unknown>) => unknown;\n\n/**\n * Convert a promise or promise-returning function into an `Effect` that uses\n * the remote failure channel when applicable.\n *\n * @see https://ser.barekey.dev/content/reference/effect\n */\nexport function to_effect<Success, ErrorType = never>(\n promise_like: PromiseLike<Success>,\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never>;\nexport function to_effect<\n Args extends Array<unknown>,\n Success,\n ErrorType = never,\n>(\n fn: (...args: Args) => PromiseLike<Success>,\n): (...args: Args) => Effect.Effect<Success, RemoteFailure<ErrorType>, never>;\nexport function to_effect<Success, ErrorType = never>(\n value: PromiseLike<Success> | AnyCallable,\n): Effect.Effect<Success, RemoteFailure<ErrorType>, never> | AnyCallable {\n const decode_payload = get_remote_error_decoder(value);\n\n if (typeof value === \"function\") {\n return ((...args: Array<unknown>) =>\n create_remote_effect_from_promise(\n () => Promise.resolve((value as AnyCallable)(...args)),\n (error) => decode_remote_error<ErrorType>(error, decode_payload),\n )) as AnyCallable;\n }\n\n return create_remote_effect_from_promise(\n () => value,\n (error) => decode_remote_error<ErrorType>(error, decode_payload),\n );\n}\n\n/**\n * Unwrap a runtime wrapper and recover the original native value.\n *\n * @see https://ser.barekey.dev/content/reference/effect\n */\nexport function to_native<Value>(\n value: Value,\n): Value extends { native: infer Native } ? Native\n : Value;\nexport function to_native(value: unknown): unknown {\n let current = value;\n const seen = new Set<unknown>();\n\n while (\n current &&\n (typeof current === \"object\" || typeof current === \"function\") &&\n \"native\" in current\n ) {\n if (seen.has(current)) {\n break;\n }\n\n seen.add(current);\n current = (current as { native: unknown }).native;\n }\n\n return current;\n}\n\nexport { create_remote_effect_from_promise, is_redirect_like };\n"],"mappings":"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"}
|