svelte-effect-runtime 4.2.4 → 4.2.6
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-CpWfP_1f.js → client-Bi7SwVVy.js} +23 -13
- package/.dist/chunks/client-Bi7SwVVy.js.map +1 -0
- package/.dist/chunks/{compiler-Dpyu4Owd.js → compiler-B2htZszc.js} +8 -5
- package/.dist/chunks/{compiler-Dpyu4Owd.js.map → compiler-B2htZszc.js.map} +1 -1
- package/.dist/chunks/{remote-client-mkQAfP1G.js → remote-client-C_3kdug0.js} +15 -4
- package/.dist/chunks/remote-client-C_3kdug0.js.map +1 -0
- package/.dist/chunks/{server-BNxq-pUH.js → server-Dxb9zr99.js} +16 -3
- package/.dist/chunks/server-Dxb9zr99.js.map +1 -0
- package/.dist/compiler/remote-client.d.ts +1 -0
- package/.dist/compiler.js +1 -1
- package/.dist/environment.d.ts +9 -3
- package/.dist/environment.js.map +1 -1
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/mod.js +1 -1
- package/.dist/remote/client/form-data.d.ts +8 -1
- package/.dist/remote/client/form.d.ts +2 -2
- package/.dist/remote/client/types.d.ts +10 -11
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/native-types.d.ts +292 -0
- package/.dist/remote/server.js +1 -1
- package/.dist/server/factories.d.ts +4 -4
- package/.dist/server/live-snapshot.d.ts +2 -2
- package/.dist/server/types.d.ts +7 -7
- package/.dist/server.js +3 -3
- package/.dist/server.js.map +1 -1
- package/package.json +2 -2
- package/.dist/chunks/client-CpWfP_1f.js.map +0 -1
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +0 -1
- package/.dist/chunks/server-BNxq-pUH.js.map +0 -1
package/.dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import { D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMi
|
|
|
2
2
|
import { create_form_error, create_remote_transport_error } from "./remote/shared.js";
|
|
3
3
|
import { i as make_remote_live_stream, r as make_failed_remote_live_stream, t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
4
4
|
import { a as normalize_validator, c as attach_remote_resource_getters, d as MakeEffectFromPromise, f as MakeEffectFromSync, l as is_remote_resource, n as attach_native_remote_query_update, o as attach_failed_remote_query_resource, r as resolve_native_remote_query_updates, s as attach_failed_remote_resource_getters, t as copy_property_descriptors, u as FailWithRemoteError } from "./chunks/descriptors-q909VWyR.js";
|
|
5
|
-
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-
|
|
5
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-Dxb9zr99.js";
|
|
6
6
|
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-CmiEHnSw.js";
|
|
7
7
|
import { Effect, Result, Stream } from "effect";
|
|
8
8
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
@@ -180,9 +180,9 @@ function make_remote_form_wrapper(handler, helper_name) {
|
|
|
180
180
|
}
|
|
181
181
|
//#endregion
|
|
182
182
|
//#region src/server/live-snapshot.ts
|
|
183
|
-
/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
183
|
+
/** Converts available SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
184
184
|
function make_remote_live_snapshot_encoder(transport) {
|
|
185
|
-
const encoders = Object.fromEntries(Object.entries(transport).map(([key, transformer]) => [key, transformer.encode]));
|
|
185
|
+
const encoders = Object.fromEntries(Object.entries(transport ?? {}).map(([key, transformer]) => [key, transformer.encode]));
|
|
186
186
|
return (value) => stringify(value, encoders);
|
|
187
187
|
}
|
|
188
188
|
//#endregion
|
package/.dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["get_native_request_event","svelte_invalid","get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender","get_native_request_event","Error","error","svelte_error","redirect","svelte_redirect"],"sources":["../../modules/svelte-effect-runtime/src/server/remote-handler-context.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/live-snapshot.ts","../../modules/svelte-effect-runtime/src/server/transport.ts","../../modules/svelte-effect-runtime/src/server/factories.ts","../../modules/svelte-effect-runtime/src/server/handler.ts","../../modules/svelte-effect-runtime/src/server/control-flow.ts"],"sourcesContent":["import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { Effect } from \"effect\";\n\nconst active_remote_handler_counts = new WeakMap<object, number>();\n\n/** Tracks ownership per request event so concurrent requests remain isolated. */\nexport function is_running_remote_effect_handler(event?: object): boolean {\n\tconst request_event = event ?? get_current_request_event();\n\n\tif (!request_event) {\n\t\treturn false;\n\t}\n\n\treturn (active_remote_handler_counts.get(request_event) ?? 0) > 0;\n}\n\n/** Marks one request as handler-owned for the lifetime of the supplied Effect. */\nexport const RunInsideRemoteEffectHandler = <A, E, R>(\n\tevent: object,\n\teffect: Effect.Effect<A, E, R>,\n) =>\n\tEffect.acquireUseRelease(\n\t\tAcquireRemoteHandlerOwnership(event),\n\t\t() => effect,\n\t\t() => ReleaseRemoteHandlerOwnership(event),\n\t);\n\nconst AcquireRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst active_count = active_remote_handler_counts.get(event) ?? 0;\n\n\t\tactive_remote_handler_counts.set(event, active_count + 1);\n\t});\n\nconst ReleaseRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst remaining_count = (active_remote_handler_counts.get(event) ?? 1) - 1;\n\n\t\tif (remaining_count === 0) {\n\t\t\tactive_remote_handler_counts.delete(event);\n\n\t\t\treturn;\n\t\t}\n\n\t\tactive_remote_handler_counts.set(event, remaining_count);\n\t});\n\nfunction get_current_request_event(): object | undefined {\n\ttry {\n\t\tconst event = get_native_request_event();\n\n\t\treturn typeof event === \"object\" && event !== null ? event : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n","import { error as svelte_error, invalid as svelte_invalid } from \"@sveltejs/kit\";\nimport {\n\trun_remote_effect,\n\tthrow_remote_cause,\n\tto_remote_failure_context,\n} from \"$/remote/server.ts\";\nimport { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { Effect, Stream } from \"effect\";\nimport type { EffectLike } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> = AsyncIterable<A>;\n\ntype LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;\n\ntype LiveHandler<A> = () => LiveHandlerResult<A>;\n\nexport function is_generator_result<A>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n\nexport function ToEffect<A, E, R>(value: EffectLike<A, E, R>): Effect.Effect<A, E, R> {\n\tif (is_generator_result<A>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nexport function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown> {\n\treturn Stream.isStream(value);\n}\n\nexport function run_live_handler_source<A>(\n\tvalue: LiveHandlerResult<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tif (!is_live_source(value)) {\n\t\tthrow new InvalidLiveQueryReturnError();\n\t}\n\n\treturn run_live_source_effect(ToLiveSourceEffect(value, event), event);\n}\n\n/** Runs a live handler inside the request-local ownership scope. */\nexport function run_live_handler<A>(\n\thandler: LiveHandler<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst LiveSourceEffect = Effect.suspend(() => {\n\t\tconst value = handler();\n\n\t\tif (!is_live_source(value)) {\n\t\t\treturn Effect.die(new InvalidLiveQueryReturnError());\n\t\t}\n\n\t\treturn ToLiveSourceEffect(value, event);\n\t});\n\n\treturn run_live_source_effect(RunInsideRemoteEffectHandler(event, LiveSourceEffect), event);\n}\n\nfunction run_live_source_effect<A>(\n\teffect: Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\teffect,\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst ToLiveSourceEffect = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tStream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(\n\t\tEffect.map((source) => wrap_live_source_errors(source, event)),\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\nconst preserve_live_source_cause = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tvalue.pipe(\n\t\tStream.catchCause((cause) =>\n\t\t\tStream.fromEffect(\n\t\t\t\tEffect.sync(() =>\n\t\t\t\t\tthrow_remote_cause(cause, svelte_invalid, svelte_remote_error, () =>\n\t\t\t\t\t\tto_remote_failure_context(event),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\nfunction wrap_live_source_errors<A>(\n\tsource: AsyncIterable<A>,\n\tevent: RequestEventShape,\n): AsyncIterable<A> {\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\tconst iterator = source[Symbol.asyncIterator]();\n\t\t\tconst throw_iterator = iterator.throw?.bind(iterator);\n\n\t\t\treturn {\n\t\t\t\tnext() {\n\t\t\t\t\treturn RunLiveIteratorCall(event, () => iterator.next());\n\t\t\t\t},\n\n\t\t\t\treturn(value?: unknown) {\n\t\t\t\t\tif (iterator.return) {\n\t\t\t\t\t\treturn RunLiveIteratorCall(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t() => iterator.return?.(value) as PromiseLike<IteratorResult<A>>,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Promise.resolve({\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: undefined as A,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t...(throw_iterator === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tthrow(error?: unknown) {\n\t\t\t\t\t\t\t\treturn RunLiveIteratorCall(event, () => throw_iterator(error));\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction RunLiveIteratorCall<A>(event: RequestEventShape, run: () => PromiseLike<A>): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst IteratorEffect = Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => error,\n\t});\n\n\treturn runtime.runPromise(\n\t\tRunInsideRemoteEffectHandler(event, IteratorEffect) as Effect.Effect<A, unknown, unknown>,\n\t);\n}\n\nexport function run_handler_effect<A>(\n\tvalue: EffectLike<A, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\tRunInsideRemoteEffectHandler(event, ToEffect(value)),\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<A, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n\tsvelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { FormInvalid } from \"./types.ts\";\nimport { Effect } from \"effect\";\n\nexport function make_invalid_proxy<Input = unknown>(\n\tpath: readonly (string | number)[] = [],\n): FormInvalid<Input> {\n\tconst invalid_at_path = (message: string) =>\n\t\tEffect.fail(create_form_error([{ message, path: [...path] } satisfies FormIssue]));\n\n\treturn new Proxy(invalid_at_path, {\n\t\tget(_target, property) {\n\t\t\tif (typeof property === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst segment = path.length === 0 ? property : normalize_nested_path_segment(property);\n\n\t\t\treturn make_invalid_proxy([...path, segment]);\n\t\t},\n\t}) as FormInvalid<Input>;\n}\n\nfunction normalize_nested_path_segment(property: string): string | number {\n\tconst is_array_index = /^(0|[1-9]\\d*)$/.test(property);\n\n\treturn is_array_index ? Number(property) : property;\n}\n","import type { RemoteHandler } from \"./types.ts\";\n\nexport {\n\tis_effect_schema,\n\tis_standard_schema,\n\tnormalize_validator,\n\ttype StandardSchema,\n} from \"$/internal/schema.ts\";\n\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n\treturn value === \"unchecked\";\n}\n\nexport function is_handler(\n\tvalue: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n\treturn typeof value === \"function\";\n}\n","import type {\n\tEffectLike,\n\tPrerenderInputs,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n} from \"./types.ts\";\nimport { run_handler_effect, run_live_handler, ToEffect } from \"./effects.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { get_server_runtime_or_throw } from \"./runtime.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport { Effect } from \"effect\";\n\nexport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\n\nexport function make_prerender_inputs_wrapper<Input>(\n\tgenerate_inputs: PrerenderInputs<Input>,\n): () => Promise<Input[]> {\n\treturn () => {\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst CollectInputs = Effect.gen(function* () {\n\t\t\tconst inputs = yield* Effect.suspend(() => ToEffect(generate_inputs()));\n\n\t\t\treturn Array.from(inputs);\n\t\t});\n\n\t\treturn runtime.runPromise(CollectInputs);\n\t};\n}\n\nexport function make_remote_wrapper(\n\thandler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst result = is_handler(handler) ? handler(input) : handler;\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n\nexport function make_remote_live_wrapper<Input, A>(\n\thandler: RemoteLiveSource<A, unknown, unknown> | RemoteLiveHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\treturn await run_live_handler(\n\t\t\t() => (typeof handler === \"function\" ? handler(input as Input) : handler),\n\t\t\tevent,\n\t\t);\n\t};\n}\n\nexport function make_remote_form_wrapper<Input, A>(\n\thandler: RemoteFormHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n\treturn async (data: unknown, issue: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst invalid_proxy = make_invalid_proxy<Input>();\n\t\t\tconst result = handler({\n\t\t\t\tdata: data as Input,\n\t\t\t\tinvalid: invalid_proxy,\n\t\t\t\tissue,\n\t\t\t});\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n","import { stringify } from \"devalue\";\n\nexport type NativeTransport = Readonly<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\treadonly encode: (value: unknown) => false | unknown;\n\t\t}\n\t>\n>;\n\n/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */\nexport function make_remote_live_snapshot_encoder(\n\ttransport: NativeTransport,\n): (value: unknown) => string {\n\tconst encoders = Object.fromEntries(\n\t\tObject.entries(transport).map(([key, transformer]) => [key, transformer.encode]),\n\t);\n\n\treturn (value) => stringify(value, encoders);\n}\n","import { make_remote_live_snapshot_encoder, type NativeTransport } from \"./live-snapshot.ts\";\n\nimport * as SvelteKitInternalServer from \"@sveltejs/kit/internal/server\";\n\ntype NativeRequestStore = {\n\treadonly state: {\n\t\treadonly transport: NativeTransport;\n\t};\n};\n\ntype NativeServerInternals = {\n\treadonly try_get_request_store?: () => NativeRequestStore | null;\n};\n\n/** Creates the current SvelteKit request's transport-aware live snapshot encoder. */\nexport function get_remote_live_snapshot_encoder(): ((value: unknown) => string) | undefined {\n\tconst try_get_request_store = (SvelteKitInternalServer as unknown as NativeServerInternals)\n\t\t.try_get_request_store;\n\tconst request_store = try_get_request_store?.();\n\n\tif (!request_store) {\n\t\treturn undefined;\n\t}\n\n\treturn make_remote_live_snapshot_encoder(request_store.state.transport);\n}\n","import type {\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tPrerenderOptions,\n\tQueryFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"./types.ts\";\nimport {\n\tBatchQueryHandlerMissingError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport {\n\tattach_failed_remote_query_resource,\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tcommand as native_command,\n\tform as native_form,\n\tgetRequestEvent as get_native_request_event,\n\tprerender as native_prerender,\n\tquery as native_query,\n} from \"$app/server\";\nimport {\n\tmake_prerender_inputs_wrapper,\n\tmake_remote_form_wrapper,\n\tmake_remote_live_wrapper,\n\tmake_remote_wrapper,\n} from \"./wrappers.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport {\n\tattach_native_remote_query_update,\n\tresolve_native_remote_query_updates,\n} from \"$/remote/query-update.ts\";\nimport { make_failed_remote_live_stream, make_remote_live_stream } from \"$/live.ts\";\nimport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { get_remote_live_snapshot_encoder } from \"./transport.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, Result, type Schema } from \"effect\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S[\"Encoded\"]> : never;\n\ntype FormRemoteInput<Input> =\n\tNormalizeFormEncoded<Input> extends RemoteFormInput ? NormalizeFormEncoded<Input> : never;\n\ntype FormStandardSchemaInput<S> =\n\tStandardSchemaInput<S> extends RemoteFormInput ? StandardSchemaInput<S> : RemoteFormInput;\n\ntype FormScalar = string | number | boolean | File;\n\ntype NormalizeFormEncoded<Value> = Value extends FormScalar\n\t? Value\n\t: Value extends ReadonlyArray<infer Item>\n\t\t? Array<NormalizeFormEncoded<Item>>\n\t\t: Value extends object\n\t\t\t? NormalizeFormObject<Value>\n\t\t\t: Value;\n\ntype NormalizeFormObject<Value> = {\n\treadonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\n\t\t? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\n\t\t: NormalizeFormEncoded<Value[Key]>;\n};\n\ntype OptionalFormKeys<Value> = {\n\t[Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key> ? Key : never;\n}[keyof Value];\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype AttachRemoteResource<Resource> = (resource: unknown, effect: Resource) => void;\n\ntype AttachFailedRemoteResource<Resource> = (error: unknown, effect: Resource) => void;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativePrerenderOptions<Input> = {\n\treadonly inputs?: (() => Promise<Input[]>) | undefined;\n\treadonly dynamic?: boolean | undefined;\n};\n\ntype CurrentRemoteRequestDetection =\n\t| {\n\t\t\treadonly _tag: \"CurrentRemoteRequest\";\n\t\t\treadonly event: {\n\t\t\t\treadonly isRemoteRequest?: boolean;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly _tag: \"NoCurrentRemoteRequest\";\n\t };\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nfunction to_effect_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemoteQuery<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_query_resource_methods,\n\t\tattach_failed_remote_query_resource,\n\t\tmode,\n\t) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_prerender<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemotePrerenderFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemotePrerender<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_remote_resource_getters,\n\t\tattach_failed_remote_resource_getters,\n\t) as unknown as EffectRemotePrerenderFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_command<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteCommand<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\treturn MakeServerCommandEffect<Input, Output, ErrorType>(native, input);\n\t}) as unknown as EffectRemoteCommand<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\nconst MakeServerCommandEffect = <Input, Output, ErrorType>(\n\tnative: NativeQueryLike<Input>,\n\tinput: Input,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = native(input);\n\n\t\t\tif (updates_args && has_command_updates(result)) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\n\t\treturn yield* MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => Promise.resolve(invocation) as Promise<Output>,\n\t\t);\n\t}) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nfunction has_command_updates(\n\tvalue: unknown,\n): value is { readonly updates: (...updates: unknown[]) => unknown } {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as { readonly updates?: unknown }).updates === \"function\"\n\t);\n}\n\nfunction to_effect_remote_resource<\n\tInput,\n\tOutput,\n\tErrorType,\n\tResource extends RemoteResourceEffect<Output, ErrorType>,\n>(\n\tnative: NativeQueryLike<Input>,\n\tattach_resource: AttachRemoteResource<Resource>,\n\tattach_failed_resource: AttachFailedRemoteResource<Resource>,\n\tmode: QueryAdapterMode = \"standard\",\n): (input: Input) => Resource {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst ResourceEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as Resource;\n\n\t\t\tattach_failed_resource(resource_attempt.failure, ResourceEffect);\n\n\t\t\treturn ResourceEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst started_result = mode === \"batch\" ? begin_batch_resource(resource) : undefined;\n\t\tconst ResourceEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => (started_result ?? Promise.resolve(resource)) as Promise<Output>,\n\t\t) as Resource;\n\n\t\tattach_native_remote_query_update(ResourceEffect, resource);\n\t\tattach_resource(resource, ResourceEffect);\n\n\t\treturn ResourceEffect;\n\t}) as unknown as (input: Input) => Resource;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_resource(resource: unknown): Promise<unknown> {\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\nfunction is_current_remote_request(): boolean {\n\tconst detection = detect_current_remote_request();\n\n\tif (detection._tag === \"NoCurrentRemoteRequest\") {\n\t\treturn false;\n\t}\n\n\tif (is_running_remote_effect_handler(detection.event)) {\n\t\treturn false;\n\t}\n\n\treturn detection.event.isRemoteRequest === true;\n}\n\nfunction detect_current_remote_request(): CurrentRemoteRequestDetection {\n\ttry {\n\t\tconst event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n\t\treturn {\n\t\t\t_tag: \"CurrentRemoteRequest\",\n\t\t\tevent,\n\t\t};\n\t} catch (error: unknown) {\n\t\tif (is_request_event_context_error(error)) {\n\t\t\treturn { _tag: \"NoCurrentRemoteRequest\" };\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction is_request_event_context_error(error: unknown): error is Error {\n\tif (!(error instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terror.message.startsWith(request_event_context_error_start) ||\n\t\terror.message === request_store_context_error\n\t);\n}\n\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tconst snapshot_encoder = get_remote_live_snapshot_encoder();\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tcreate_remote_transport_error,\n\t\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tcreate_remote_transport_error,\n\t\t\tsnapshot_encoder,\n\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as unknown as EffectRemoteLiveQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nfunction normalize_prerender_options<Input>(\n\toptions: PrerenderOptions<Input> | undefined,\n): NativePrerenderOptions<Input> | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tdynamic: options.dynamic,\n\t\tinputs: options.inputs ? make_prerender_inputs_wrapper(options.inputs) : undefined,\n\t};\n}\n\nfunction QueryRoot<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteQueryFunction<void, A, E>;\nfunction QueryRoot<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryRoot(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_query(\n\t\t\t\tnative_query(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\n\t\t\t\t) as ReturnType<typeof native_query>,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Query\") as never,\n\t\t\t) as ReturnType<typeof native_query>,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query\");\n\t}\n}\n\nfunction QueryBatch<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryBatch(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (!maybe_handler) {\n\t\t\tthrow new BatchQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query.batch(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query.batch\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t\t\"batch\",\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.batch\");\n\t}\n}\n\nfunction QueryLive<A, E = never, R = never>(\n\tvalidate_or_handler: RemoteLiveSource<A, E, R> | RemoteLiveHandler<void, A, E, R>,\n): EffectRemoteLiveQueryFunction<void, A, E>;\nfunction QueryLive<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteLiveHandler<Input, A, E, R>,\n): EffectRemoteLiveQueryFunction<Input, A, E>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryLive(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_live_query(\n\t\t\t\tnative_query.live(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\t\tmaybe_handler as RemoteLiveHandler,\n\t\t\t\t\t\t\"Query.live\",\n\t\t\t\t\t) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedLiveQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_live_query(\n\t\t\tnative_query.live(\n\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\tvalidate_or_handler as RemoteLiveHandler,\n\t\t\t\t\t\"Query.live\",\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.live\");\n\t}\n}\n\n/**\n * Factory for read-only remote query functions.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\n * );\n *\n * export const getUserBatch = Query.batch(Schema.String, (ids) =>\n * Effect.succeed((id) => ids.includes(id))\n * );\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(QueryRoot, {\n\tbatch: QueryBatch,\n\tlive: QueryLive,\n});\n\n/**\n * Creates a write-oriented remote command from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const RebuildCache = Command(() => Effect.succeed(\"done\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run on\n * the server when the command is invoked.\n * @returns A command function that yields an Effect when called.\n */\nexport function Command<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteCommand<void, A, E>;\n\n/**\n * Creates a write-oriented remote command with unchecked input.\n *\n * @example\n * ```ts\n * export const SaveDraft = Command(\"unchecked\", (input: { id: string }) =>\n * Effect.succeed(input.id)\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @returns A command function that yields an Effect when called with input.\n */\nexport function Command<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteCommand<Input, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const SaveUser = Command(Schema.Struct({ id: Schema.String }), ({ id }) =>\n * Effect.succeed({ id, saved: true })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema encoded type.\n */\nexport function Command<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const Toggle = Command(standard_schema, (input) =>\n * Effect.succeed(input.enabled)\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema input type.\n */\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\nexport function Command(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_command(\n\t\t\t\tnative_command(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedCommandHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_command(\n\t\t\tnative_command(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Command\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Command\");\n\t}\n}\n\n/**\n * Factory for a remote form handler.\n *\n * @example\n * ```ts\n * export const SignIn = Form(signInSchema, ({ data, invalid }) =>\n * Effect.gen(function* () {\n * if (!data.email.includes(\"@\")) {\n * return yield* invalid.email(\"Use an email address.\");\n * }\n *\n * return { email: data.email };\n * })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit form function.\n */\nexport function Form<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>,\n): EffectRemoteForm<void, A, E>;\nexport function Form<Input extends RemoteFormInput, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteFormHandler<Input, A, E, R>,\n): EffectRemoteForm<Input, A, E>;\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;\nexport function Form<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\nexport function Form(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn native_form(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_form_wrapper(maybe_handler as RemoteFormHandler, \"Form\") as never,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedFormHandlerMissingError();\n\t\t}\n\n\t\tconst inputless_handler: RemoteFormHandler<void, unknown> = ({ data, invalid, issue }) => {\n\t\t\tif (is_handler(validate_or_handler)) {\n\t\t\t\treturn validate_or_handler({ data, invalid, issue });\n\t\t\t}\n\n\t\t\treturn validate_or_handler as EffectLike;\n\t\t};\n\n\t\treturn native_form(\n\t\t\tmake_remote_form_wrapper(inputless_handler, \"Form\") as never,\n\t\t) as unknown as ReturnType<typeof native_form>;\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Form\");\n\t}\n}\n\n/**\n * Creates a prerenderable remote function from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run at\n * prerender time.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called.\n */\nexport function Prerender<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n\tmaybe_options?: PrerenderOptions<void>,\n): EffectRemotePrerenderFunction<void, A, E>;\n\n/**\n * Creates a prerenderable remote function with unchecked input.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * \"unchecked\",\n * (slug: string) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called with input.\n */\nexport function Prerender<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n\tmaybe_options?: PrerenderOptions<Input>,\n): EffectRemotePrerenderFunction<Input, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * Schema.String,\n * (slug) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema encoded type.\n */\nexport function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<SchemaEncodedInput<S>>,\n): EffectRemotePrerenderFunction<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * standard_schema,\n * (post) => Effect.succeed(post.slug),\n * { dynamic: true },\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema input type.\n */\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<StandardSchemaInput<S>>,\n): EffectRemotePrerenderFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n\tvalidate_or_handler: unknown,\n\tmaybe_handler_or_options?: unknown,\n\tmaybe_options?: PrerenderOptions<unknown>,\n\tnative_factory: typeof native_prerender = native_prerender,\n): unknown {\n\ttry {\n\t\tif (is_handler(maybe_handler_or_options)) {\n\t\t\treturn to_effect_prerender(\n\t\t\t\tnative_factory(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n\t\t\t\t\tnormalize_prerender_options(maybe_options) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedPrerenderHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_prerender(\n\t\t\tnative_factory(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Prerender\") as never,\n\t\t\t\tnormalize_prerender_options(\n\t\t\t\t\tmaybe_handler_or_options as PrerenderOptions<void> | undefined,\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Prerender\");\n\t}\n}\n","import { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { EffectHandler } from \"./types.ts\";\nimport { ToEffect } from \"./effects.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Adapts an Effect-producing callback to a native SvelteKit server handler.\n * SvelteKit continues to select the handler by its exported binding name, such\n * as `GET`, `PUT`, or `load`.\n *\n * @example A `+server.ts` request handler:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { RequestHandler } from \"./$types\";\n *\n * export const GET = Handler<RequestHandler>(function* ({ params }) {\n * const post = yield* Posts.get(params.slug);\n *\n * return Response.json(post);\n * });\n * ```\n *\n * @example A `+page.server.ts` load function:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { PageServerLoad } from \"./$types\";\n *\n * export const load = Handler<PageServerLoad>(function* ({ locals }) {\n * const profile = yield* Profiles.get(locals.user.id);\n *\n * return { profile };\n * });\n * ```\n *\n * @since 4.0.0\n * @param handler - Effect-producing callback whose parameters and successful\n * result match the native SvelteKit handler type.\n * @returns A native handler that runs the callback through the configured\n * {@link ServerRuntime} with the current {@link RequestEvent} available.\n */\nexport function Handler<NativeHandler extends (...arguments_: never[]) => unknown>(\n\thandler: EffectHandler<NativeHandler>,\n): NativeHandler {\n\tconst native_handler = async (...arguments_: Parameters<NativeHandler>) => {\n\t\tconst event = get_native_request_event();\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst HandlerEffect = Effect.suspend(() => ToEffect(handler(...arguments_)));\n\t\tconst HandlerOwnedEffect = RunInsideRemoteEffectHandler(event, HandlerEffect);\n\t\tconst EffectWithRequestEvent = Effect.provideService(\n\t\t\tHandlerOwnedEffect,\n\t\t\tRequestEvent,\n\t\t\tevent,\n\t\t);\n\n\t\treturn await runtime.runPromise(EffectWithRequestEvent, {\n\t\t\tsignal: event.request.signal,\n\t\t});\n\t};\n\n\treturn native_handler as unknown as NativeHandler;\n}\n","import { error as svelte_error, redirect as svelte_redirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n\tProxyAuthenticationRequired: 407,\n\tRequestHeaderFieldsTooLarge: 431,\n\tUnavailableForLegalReasons: 451,\n\tNetworkAuthenticationRequired: 511,\n\tHttpVersionNotSupported: 505,\n\tUnprocessableContent: 422,\n\tUnprocessableEntity: 422,\n\tInternalServerError: 500,\n\tFailedDependency: 424,\n\tPreconditionRequired: 428,\n\tServiceUnavailable: 503,\n\tMisdirectedRequest: 421,\n\tInsufficientStorage: 507,\n\tVariantAlsoNegotiates: 506,\n\tPreconditionFailed: 412,\n\tMethodNotAllowed: 405,\n\tGatewayTimeout: 504,\n\tPaymentRequired: 402,\n\tUpgradeRequired: 426,\n\tTooManyRequests: 429,\n\tLengthRequired: 411,\n\tNotAcceptable: 406,\n\tRequestTimeout: 408,\n\tContentTooLarge: 413,\n\tPayloadTooLarge: 413,\n\tUriTooLong: 414,\n\tUnsupportedMediaType: 415,\n\tRangeNotSatisfiable: 416,\n\tExpectationFailed: 417,\n\tImATeapot: 418,\n\tBadRequest: 400,\n\tUnauthorized: 401,\n\tForbidden: 403,\n\tNotFound: 404,\n\tConflict: 409,\n\tGone: 410,\n\tLocked: 423,\n\tTooEarly: 425,\n\tNotImplemented: 501,\n\tBadGateway: 502,\n\tLoopDetected: 508,\n\tNotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n\tMovedPermanently: 301,\n\tTemporaryRedirect: 307,\n\tPermanentRedirect: 308,\n\tMultipleChoices: 300,\n\tNotModified: 304,\n\tSwitchProxy: 306,\n\tSeeOther: 303,\n\tUseProxy: 305,\n\tFound: 302,\n} as const;\n\ntype AppErrorStatus = App.Error extends { readonly status?: infer Status } ? Status : number;\n\n/**\n * Compatibility shim while SER supports both SvelteKit 2 and 3. The wrappers\n * call the SvelteKit 3 control-flow shapes, while SvelteKit 2 ignores extra\n * runtime arguments. Drop these broad call signatures when Kit 2 support is\n * removed.\n */\ntype SvelteError = (status: number, body?: ErrorBody, properties?: ErrorProperties) => never;\n\ntype SvelteRedirect = (status: number, location: string | URL, options?: RedirectOptions) => never;\n\n/**\n * Named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatusName = \"NotFound\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatusName = keyof typeof error_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatus = \"InternalServerError\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatus = ErrorStatusName | number;\n\n/**\n * Error body accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const body: ErrorBody = { message: \"Post not found\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorBody =\n\t| (Omit<App.Error, \"status\"> & { readonly status?: AppErrorStatus })\n\t| string\n\t| undefined;\n\n/**\n * Extra SvelteKit app error properties accepted by the {@link Error} helper\n * when using the SvelteKit 3 string-body overload.\n *\n * @example\n * ```ts\n * const properties: ErrorProperties = { code: \"POST_NOT_FOUND\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorProperties = Omit<App.Error, \"status\" | \"message\">;\n\n/**\n * Named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatusName = \"TemporaryRedirect\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatusName = keyof typeof redirect_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatus = \"SeeOther\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatus = RedirectStatusName | number;\n\n/**\n * Options accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const options: RedirectOptions = { external: true };\n * ```\n *\n * @since 3.4.3\n */\nexport type RedirectOptions = {\n\treadonly external?: boolean | string[];\n};\n\n/**\n * Callable shape for the exported {@link Error} helper.\n *\n * @example\n * ```ts\n * const fail_not_found: ErrorEffectFactory = Error;\n * ```\n *\n * @since 2.3.0\n */\nexport interface ErrorEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Optional SvelteKit error body or message forwarded unchanged\n\t * to SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(status: ErrorStatus, body?: ErrorBody): Effect.Effect<never, never, never>;\n\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value\n\t * using the SvelteKit 3 string-body overload with extra properties.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\", {\n\t * code: \"POST_NOT_FOUND\",\n\t * });\n\t * ```\n\t *\n\t * @since 3.4.3\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Error message forwarded to SvelteKit.\n\t * @param properties - Additional app error properties forwarded to\n\t * SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: ErrorStatus,\n\t\tbody: string,\n\t\tproperties: ErrorProperties,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Callable shape for the exported {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const redirect_after_save: RedirectEffectFactory = Redirect;\n * ```\n *\n * @since 2.3.0\n */\nexport interface RedirectEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's redirect control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Redirect(\"SeeOther\", \"/posts\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric redirect status or PascalCase status name to pass\n\t * to SvelteKit's `redirect` helper.\n\t * @param location - Target URL forwarded unchanged to SvelteKit.\n\t * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n\t * `{ external: true }` or an allowlist to redirect to external URLs.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: RedirectStatus,\n\t\tlocation: string | URL,\n\t\toptions?: RedirectOptions,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Creates an Effect that raises SvelteKit's HTTP error control flow.\n *\n * @example\n * ```ts\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric HTTP status or PascalCase status name to pass to\n * SvelteKit's `error` helper.\n * @param body - Optional SvelteKit error body or message forwarded unchanged\n * to SvelteKit.\n * @param properties - Optional SvelteKit 3 app error properties forwarded when\n * using a string error message.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = ((\n\tstatus: ErrorStatus,\n\tbody?: ErrorBody,\n\tproperties?: ErrorProperties,\n) => {\n\tconst resolved_status = resolve_error_status(status);\n\tconst error = svelte_error as SvelteError;\n\n\treturn Effect.sync((): never => {\n\t\tif (properties === undefined) {\n\t\t\treturn error(resolved_status, body);\n\t\t}\n\n\t\treturn error(resolved_status, body, properties);\n\t});\n}) as ErrorEffectFactory;\n\n/**\n * Creates an Effect that raises SvelteKit's redirect control flow.\n *\n * @example\n * ```ts\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric redirect status or PascalCase status name to pass to\n * SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n * `{ external: true }` or an allowlist to redirect to external URLs.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = ((\n\tstatus: RedirectStatus,\n\tlocation: string | URL,\n\toptions?: RedirectOptions,\n) => {\n\tconst resolved_status = resolve_redirect_status(status);\n\tconst redirect = svelte_redirect as SvelteRedirect;\n\n\treturn Effect.sync((): never => redirect(resolved_status, location, options));\n}) as RedirectEffectFactory;\n\nfunction resolve_error_status(status: ErrorStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,+CAA+B,IAAI,QAAwB;;AAGjE,SAAgB,iCAAiC,OAAyB;CACzE,MAAM,gBAAgB,SAAS,0BAA0B;CAEzD,IAAI,CAAC,eACJ,OAAO;CAGR,QAAQ,6BAA6B,IAAI,aAAa,KAAK,KAAK;AACjE;;AAGA,MAAa,gCACZ,OACA,WAEA,OAAO,kBACN,8BAA8B,KAAK,SAC7B,cACA,8BAA8B,KAAK,CAC1C;AAED,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,eAAe,6BAA6B,IAAI,KAAK,KAAK;CAEhE,6BAA6B,IAAI,OAAO,eAAe,CAAC;AACzD,CAAC;AAEF,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,mBAAmB,6BAA6B,IAAI,KAAK,KAAK,KAAK;CAEzE,IAAI,oBAAoB,GAAG;EAC1B,6BAA6B,OAAO,KAAK;EAEzC;CACD;CAEA,6BAA6B,IAAI,OAAO,eAAe;AACxD,CAAC;AAEF,SAAS,4BAAgD;CACxD,IAAI;EACH,MAAM,QAAQA,gBAAyB;EAEvC,OAAO,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,KAAA;CAC9D,QAAQ;EACP;CACD;AACD;;;ACpCA,SAAgB,oBACf,OACkD;CAClD,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD;AAEA,SAAgB,SAAkB,OAAoD;CACrF,IAAI,oBAAuB,KAAK,GAC/B,OAAO,OAAO,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kBAAkB;CAClB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,YAAY;CACZ,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,WAAW;CACX,YAAY;CACZ,cAAc;CACd,WAAW;CACX,UAAU;CACV,UAAU;CACV,MAAM;CACN,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,YAAY;CACZ,cAAc;CACd,aAAa;AACd;AAEA,MAAM,wBAAwB;CAC7B,kBAAkB;CAClB,mBAAmB;CACnB,mBAAmB;CACnB,iBAAiB;CACjB,aAAa;CACb,aAAa;CACb,UAAU;CACV,UAAU;CACV,OAAO;AACR;;;;;;;;;;;;;;;;;;;AAqNA,MAAaC,YACZ,QACA,MACA,eACI;CACJ,MAAM,kBAAkB,qBAAqB,MAAM;CACnD,MAAMC,UAAQC;CAEd,OAAO,OAAO,WAAkB;EAC/B,IAAI,eAAe,KAAA,GAClB,OAAOD,QAAM,iBAAiB,IAAI;EAGnC,OAAOA,QAAM,iBAAiB,MAAM,UAAU;CAC/C,CAAC;AACF;;;;;;;;;;;;;;;;;;AAmBA,MAAa,aACZ,QACA,UACA,YACI;CACJ,MAAM,kBAAkB,wBAAwB,MAAM;CACtD,MAAME,aAAWC;CAEjB,OAAO,OAAO,WAAkBD,WAAS,iBAAiB,UAAU,OAAO,CAAC;AAC7E;AAEA,SAAS,qBAAqB,QAA6B;CAC1D,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,mBAAmB;AAC3B;AAEA,SAAS,wBAAwB,QAAgC;CAChE,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,sBAAsB;AAC9B"}
|
|
1
|
+
{"version":3,"file":"server.js","names":["get_native_request_event","svelte_invalid","get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender","get_native_request_event","Error","error","svelte_error","redirect","svelte_redirect"],"sources":["../../modules/svelte-effect-runtime/src/server/remote-handler-context.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/live-snapshot.ts","../../modules/svelte-effect-runtime/src/server/transport.ts","../../modules/svelte-effect-runtime/src/server/factories.ts","../../modules/svelte-effect-runtime/src/server/handler.ts","../../modules/svelte-effect-runtime/src/server/control-flow.ts"],"sourcesContent":["import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { Effect } from \"effect\";\n\nconst active_remote_handler_counts = new WeakMap<object, number>();\n\n/** Tracks ownership per request event so concurrent requests remain isolated. */\nexport function is_running_remote_effect_handler(event?: object): boolean {\n\tconst request_event = event ?? get_current_request_event();\n\n\tif (!request_event) {\n\t\treturn false;\n\t}\n\n\treturn (active_remote_handler_counts.get(request_event) ?? 0) > 0;\n}\n\n/** Marks one request as handler-owned for the lifetime of the supplied Effect. */\nexport const RunInsideRemoteEffectHandler = <A, E, R>(\n\tevent: object,\n\teffect: Effect.Effect<A, E, R>,\n) =>\n\tEffect.acquireUseRelease(\n\t\tAcquireRemoteHandlerOwnership(event),\n\t\t() => effect,\n\t\t() => ReleaseRemoteHandlerOwnership(event),\n\t);\n\nconst AcquireRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst active_count = active_remote_handler_counts.get(event) ?? 0;\n\n\t\tactive_remote_handler_counts.set(event, active_count + 1);\n\t});\n\nconst ReleaseRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst remaining_count = (active_remote_handler_counts.get(event) ?? 1) - 1;\n\n\t\tif (remaining_count === 0) {\n\t\t\tactive_remote_handler_counts.delete(event);\n\n\t\t\treturn;\n\t\t}\n\n\t\tactive_remote_handler_counts.set(event, remaining_count);\n\t});\n\nfunction get_current_request_event(): object | undefined {\n\ttry {\n\t\tconst event = get_native_request_event();\n\n\t\treturn typeof event === \"object\" && event !== null ? event : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n","import { error as svelte_error, invalid as svelte_invalid } from \"@sveltejs/kit\";\nimport {\n\trun_remote_effect,\n\tthrow_remote_cause,\n\tto_remote_failure_context,\n} from \"$/remote/server.ts\";\nimport { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { Effect, Stream } from \"effect\";\nimport type { EffectLike } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> = AsyncIterable<A>;\n\ntype LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;\n\ntype LiveHandler<A> = () => LiveHandlerResult<A>;\n\nexport function is_generator_result<A>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n\nexport function ToEffect<A, E, R>(value: EffectLike<A, E, R>): Effect.Effect<A, E, R> {\n\tif (is_generator_result<A>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nexport function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown> {\n\treturn Stream.isStream(value);\n}\n\nexport function run_live_handler_source<A>(\n\tvalue: LiveHandlerResult<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tif (!is_live_source(value)) {\n\t\tthrow new InvalidLiveQueryReturnError();\n\t}\n\n\treturn run_live_source_effect(ToLiveSourceEffect(value, event), event);\n}\n\n/** Runs a live handler inside the request-local ownership scope. */\nexport function run_live_handler<A>(\n\thandler: LiveHandler<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst LiveSourceEffect = Effect.suspend(() => {\n\t\tconst value = handler();\n\n\t\tif (!is_live_source(value)) {\n\t\t\treturn Effect.die(new InvalidLiveQueryReturnError());\n\t\t}\n\n\t\treturn ToLiveSourceEffect(value, event);\n\t});\n\n\treturn run_live_source_effect(RunInsideRemoteEffectHandler(event, LiveSourceEffect), event);\n}\n\nfunction run_live_source_effect<A>(\n\teffect: Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\teffect,\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst ToLiveSourceEffect = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tStream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(\n\t\tEffect.map((source) => wrap_live_source_errors(source, event)),\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\nconst preserve_live_source_cause = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tvalue.pipe(\n\t\tStream.catchCause((cause) =>\n\t\t\tStream.fromEffect(\n\t\t\t\tEffect.sync(() =>\n\t\t\t\t\tthrow_remote_cause(cause, svelte_invalid, svelte_remote_error, () =>\n\t\t\t\t\t\tto_remote_failure_context(event),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\nfunction wrap_live_source_errors<A>(\n\tsource: AsyncIterable<A>,\n\tevent: RequestEventShape,\n): AsyncIterable<A> {\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\tconst iterator = source[Symbol.asyncIterator]();\n\t\t\tconst throw_iterator = iterator.throw?.bind(iterator);\n\n\t\t\treturn {\n\t\t\t\tnext() {\n\t\t\t\t\treturn RunLiveIteratorCall(event, () => iterator.next());\n\t\t\t\t},\n\n\t\t\t\treturn(value?: unknown) {\n\t\t\t\t\tif (iterator.return) {\n\t\t\t\t\t\treturn RunLiveIteratorCall(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t() => iterator.return?.(value) as PromiseLike<IteratorResult<A>>,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Promise.resolve({\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: undefined as A,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t...(throw_iterator === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tthrow(error?: unknown) {\n\t\t\t\t\t\t\t\treturn RunLiveIteratorCall(event, () => throw_iterator(error));\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction RunLiveIteratorCall<A>(event: RequestEventShape, run: () => PromiseLike<A>): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst IteratorEffect = Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => error,\n\t});\n\n\treturn runtime.runPromise(\n\t\tRunInsideRemoteEffectHandler(event, IteratorEffect) as Effect.Effect<A, unknown, unknown>,\n\t);\n}\n\nexport function run_handler_effect<A>(\n\tvalue: EffectLike<A, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\tRunInsideRemoteEffectHandler(event, ToEffect(value)),\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<A, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n\tsvelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { FormInvalid } from \"./types.ts\";\nimport { Effect } from \"effect\";\n\nexport function make_invalid_proxy<Input = unknown>(\n\tpath: readonly (string | number)[] = [],\n): FormInvalid<Input> {\n\tconst invalid_at_path = (message: string) =>\n\t\tEffect.fail(create_form_error([{ message, path: [...path] } satisfies FormIssue]));\n\n\treturn new Proxy(invalid_at_path, {\n\t\tget(_target, property) {\n\t\t\tif (typeof property === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst segment = path.length === 0 ? property : normalize_nested_path_segment(property);\n\n\t\t\treturn make_invalid_proxy([...path, segment]);\n\t\t},\n\t}) as FormInvalid<Input>;\n}\n\nfunction normalize_nested_path_segment(property: string): string | number {\n\tconst is_array_index = /^(0|[1-9]\\d*)$/.test(property);\n\n\treturn is_array_index ? Number(property) : property;\n}\n","import type { RemoteHandler } from \"./types.ts\";\n\nexport {\n\tis_effect_schema,\n\tis_standard_schema,\n\tnormalize_validator,\n\ttype StandardSchema,\n} from \"$/internal/schema.ts\";\n\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n\treturn value === \"unchecked\";\n}\n\nexport function is_handler(\n\tvalue: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n\treturn typeof value === \"function\";\n}\n","import type {\n\tEffectLike,\n\tPrerenderInputs,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n} from \"./types.ts\";\nimport { run_handler_effect, run_live_handler, ToEffect } from \"./effects.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { get_server_runtime_or_throw } from \"./runtime.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport { Effect } from \"effect\";\n\nexport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\n\nexport function make_prerender_inputs_wrapper<Input>(\n\tgenerate_inputs: PrerenderInputs<Input>,\n): () => Promise<Input[]> {\n\treturn () => {\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst CollectInputs = Effect.gen(function* () {\n\t\t\tconst inputs = yield* Effect.suspend(() => ToEffect(generate_inputs()));\n\n\t\t\treturn Array.from(inputs);\n\t\t});\n\n\t\treturn runtime.runPromise(CollectInputs);\n\t};\n}\n\nexport function make_remote_wrapper(\n\thandler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst result = is_handler(handler) ? handler(input) : handler;\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n\nexport function make_remote_live_wrapper<Input, A>(\n\thandler: RemoteLiveSource<A, unknown, unknown> | RemoteLiveHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\treturn await run_live_handler(\n\t\t\t() => (typeof handler === \"function\" ? handler(input as Input) : handler),\n\t\t\tevent,\n\t\t);\n\t};\n}\n\nexport function make_remote_form_wrapper<Input, A>(\n\thandler: RemoteFormHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n\treturn async (data: unknown, issue: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst invalid_proxy = make_invalid_proxy<Input>();\n\t\t\tconst result = handler({\n\t\t\t\tdata: data as Input,\n\t\t\t\tinvalid: invalid_proxy,\n\t\t\t\tissue,\n\t\t\t});\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n","import { stringify } from \"devalue\";\n\nexport type NativeTransport = Readonly<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\treadonly encode: (value: unknown) => false | unknown;\n\t\t}\n\t>\n>;\n\n/** Converts available SvelteKit transport hooks into a devalue live snapshot encoder. */\nexport function make_remote_live_snapshot_encoder(\n\ttransport: NativeTransport | undefined,\n): (value: unknown) => string {\n\tconst encoders = Object.fromEntries(\n\t\tObject.entries(transport ?? {}).map(([key, transformer]) => [key, transformer.encode]),\n\t);\n\n\treturn (value) => stringify(value, encoders);\n}\n","import { make_remote_live_snapshot_encoder, type NativeTransport } from \"./live-snapshot.ts\";\n\nimport * as SvelteKitInternalServer from \"@sveltejs/kit/internal/server\";\n\ntype NativeRequestStore = {\n\treadonly state: {\n\t\treadonly transport?: NativeTransport;\n\t};\n};\n\ntype NativeServerInternals = {\n\treadonly try_get_request_store?: () => NativeRequestStore | null;\n};\n\n/** Creates the current SvelteKit request's transport-aware live snapshot encoder. */\nexport function get_remote_live_snapshot_encoder(): ((value: unknown) => string) | undefined {\n\tconst try_get_request_store = (SvelteKitInternalServer as unknown as NativeServerInternals)\n\t\t.try_get_request_store;\n\tconst request_store = try_get_request_store?.();\n\n\tif (!request_store) {\n\t\treturn undefined;\n\t}\n\n\treturn make_remote_live_snapshot_encoder(request_store.state.transport);\n}\n","import type {\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tPrerenderOptions,\n\tQueryFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"./types.ts\";\nimport {\n\tBatchQueryHandlerMissingError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport {\n\tattach_failed_remote_query_resource,\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tcommand as native_command,\n\tform as native_form,\n\tgetRequestEvent as get_native_request_event,\n\tprerender as native_prerender,\n\tquery as native_query,\n} from \"$app/server\";\nimport {\n\tmake_prerender_inputs_wrapper,\n\tmake_remote_form_wrapper,\n\tmake_remote_live_wrapper,\n\tmake_remote_wrapper,\n} from \"./wrappers.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport {\n\tattach_native_remote_query_update,\n\tresolve_native_remote_query_updates,\n} from \"$/remote/query-update.ts\";\nimport { make_failed_remote_live_stream, make_remote_live_stream } from \"$/live.ts\";\nimport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { get_remote_live_snapshot_encoder } from \"./transport.ts\";\nimport type { NativeRemoteFormInput } from \"$/remote/native-types.ts\";\nimport { Effect, Result, type Schema } from \"effect\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S[\"Encoded\"]> : never;\n\ntype FormRemoteInput<Input> =\n\tNormalizeFormEncoded<Input> extends NativeRemoteFormInput ? NormalizeFormEncoded<Input> : never;\n\ntype FormStandardSchemaInput<S> =\n\tStandardSchemaInput<S> extends NativeRemoteFormInput\n\t\t? StandardSchemaInput<S>\n\t\t: NativeRemoteFormInput;\n\ntype FormScalar = string | number | boolean | File;\n\ntype NormalizeFormEncoded<Value> = Value extends FormScalar\n\t? Value\n\t: Value extends ReadonlyArray<infer Item>\n\t\t? Array<NormalizeFormEncoded<Item>>\n\t\t: Value extends object\n\t\t\t? NormalizeFormObject<Value>\n\t\t\t: Value;\n\ntype NormalizeFormObject<Value> = {\n\treadonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\n\t\t? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\n\t\t: NormalizeFormEncoded<Value[Key]>;\n};\n\ntype OptionalFormKeys<Value> = {\n\t[Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key> ? Key : never;\n}[keyof Value];\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype AttachRemoteResource<Resource> = (resource: unknown, effect: Resource) => void;\n\ntype AttachFailedRemoteResource<Resource> = (error: unknown, effect: Resource) => void;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativePrerenderOptions<Input> = {\n\treadonly inputs?: (() => Promise<Input[]>) | undefined;\n\treadonly dynamic?: boolean | undefined;\n};\n\ntype CurrentRemoteRequestDetection =\n\t| {\n\t\t\treadonly _tag: \"CurrentRemoteRequest\";\n\t\t\treadonly event: {\n\t\t\t\treadonly isRemoteRequest?: boolean;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly _tag: \"NoCurrentRemoteRequest\";\n\t };\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nfunction to_effect_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemoteQuery<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_query_resource_methods,\n\t\tattach_failed_remote_query_resource,\n\t\tmode,\n\t) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_prerender<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemotePrerenderFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemotePrerender<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_remote_resource_getters,\n\t\tattach_failed_remote_resource_getters,\n\t) as unknown as EffectRemotePrerenderFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_command<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteCommand<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\treturn MakeServerCommandEffect<Input, Output, ErrorType>(native, input);\n\t}) as unknown as EffectRemoteCommand<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\nconst MakeServerCommandEffect = <Input, Output, ErrorType>(\n\tnative: NativeQueryLike<Input>,\n\tinput: Input,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = native(input);\n\n\t\t\tif (updates_args && has_command_updates(result)) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\n\t\treturn yield* MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => Promise.resolve(invocation) as Promise<Output>,\n\t\t);\n\t}) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nfunction has_command_updates(\n\tvalue: unknown,\n): value is { readonly updates: (...updates: unknown[]) => unknown } {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as { readonly updates?: unknown }).updates === \"function\"\n\t);\n}\n\nfunction to_effect_remote_resource<\n\tInput,\n\tOutput,\n\tErrorType,\n\tResource extends RemoteResourceEffect<Output, ErrorType>,\n>(\n\tnative: NativeQueryLike<Input>,\n\tattach_resource: AttachRemoteResource<Resource>,\n\tattach_failed_resource: AttachFailedRemoteResource<Resource>,\n\tmode: QueryAdapterMode = \"standard\",\n): (input: Input) => Resource {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst ResourceEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as Resource;\n\n\t\t\tattach_failed_resource(resource_attempt.failure, ResourceEffect);\n\n\t\t\treturn ResourceEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst started_result = mode === \"batch\" ? begin_batch_resource(resource) : undefined;\n\t\tconst ResourceEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => (started_result ?? Promise.resolve(resource)) as Promise<Output>,\n\t\t) as Resource;\n\n\t\tattach_native_remote_query_update(ResourceEffect, resource);\n\t\tattach_resource(resource, ResourceEffect);\n\n\t\treturn ResourceEffect;\n\t}) as unknown as (input: Input) => Resource;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_resource(resource: unknown): Promise<unknown> {\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\nfunction is_current_remote_request(): boolean {\n\tconst detection = detect_current_remote_request();\n\n\tif (detection._tag === \"NoCurrentRemoteRequest\") {\n\t\treturn false;\n\t}\n\n\tif (is_running_remote_effect_handler(detection.event)) {\n\t\treturn false;\n\t}\n\n\treturn detection.event.isRemoteRequest === true;\n}\n\nfunction detect_current_remote_request(): CurrentRemoteRequestDetection {\n\ttry {\n\t\tconst event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n\t\treturn {\n\t\t\t_tag: \"CurrentRemoteRequest\",\n\t\t\tevent,\n\t\t};\n\t} catch (error: unknown) {\n\t\tif (is_request_event_context_error(error)) {\n\t\t\treturn { _tag: \"NoCurrentRemoteRequest\" };\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction is_request_event_context_error(error: unknown): error is Error {\n\tif (!(error instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terror.message.startsWith(request_event_context_error_start) ||\n\t\terror.message === request_store_context_error\n\t);\n}\n\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tconst snapshot_encoder = get_remote_live_snapshot_encoder();\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tcreate_remote_transport_error,\n\t\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tcreate_remote_transport_error,\n\t\t\tsnapshot_encoder,\n\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as unknown as EffectRemoteLiveQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nfunction normalize_prerender_options<Input>(\n\toptions: PrerenderOptions<Input> | undefined,\n): NativePrerenderOptions<Input> | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tdynamic: options.dynamic,\n\t\tinputs: options.inputs ? make_prerender_inputs_wrapper(options.inputs) : undefined,\n\t};\n}\n\nfunction QueryRoot<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteQueryFunction<void, A, E>;\nfunction QueryRoot<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryRoot(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_query(\n\t\t\t\tnative_query(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\n\t\t\t\t) as ReturnType<typeof native_query>,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Query\") as never,\n\t\t\t) as ReturnType<typeof native_query>,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query\");\n\t}\n}\n\nfunction QueryBatch<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryBatch(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (!maybe_handler) {\n\t\t\tthrow new BatchQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query.batch(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query.batch\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t\t\"batch\",\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.batch\");\n\t}\n}\n\nfunction QueryLive<A, E = never, R = never>(\n\tvalidate_or_handler: RemoteLiveSource<A, E, R> | RemoteLiveHandler<void, A, E, R>,\n): EffectRemoteLiveQueryFunction<void, A, E>;\nfunction QueryLive<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteLiveHandler<Input, A, E, R>,\n): EffectRemoteLiveQueryFunction<Input, A, E>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryLive(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_live_query(\n\t\t\t\tnative_query.live(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\t\tmaybe_handler as RemoteLiveHandler,\n\t\t\t\t\t\t\"Query.live\",\n\t\t\t\t\t) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedLiveQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_live_query(\n\t\t\tnative_query.live(\n\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\tvalidate_or_handler as RemoteLiveHandler,\n\t\t\t\t\t\"Query.live\",\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.live\");\n\t}\n}\n\n/**\n * Factory for read-only remote query functions.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\n * );\n *\n * export const getUserBatch = Query.batch(Schema.String, (ids) =>\n * Effect.succeed((id) => ids.includes(id))\n * );\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(QueryRoot, {\n\tbatch: QueryBatch,\n\tlive: QueryLive,\n});\n\n/**\n * Creates a write-oriented remote command from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const RebuildCache = Command(() => Effect.succeed(\"done\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run on\n * the server when the command is invoked.\n * @returns A command function that yields an Effect when called.\n */\nexport function Command<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteCommand<void, A, E>;\n\n/**\n * Creates a write-oriented remote command with unchecked input.\n *\n * @example\n * ```ts\n * export const SaveDraft = Command(\"unchecked\", (input: { id: string }) =>\n * Effect.succeed(input.id)\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @returns A command function that yields an Effect when called with input.\n */\nexport function Command<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteCommand<Input, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const SaveUser = Command(Schema.Struct({ id: Schema.String }), ({ id }) =>\n * Effect.succeed({ id, saved: true })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema encoded type.\n */\nexport function Command<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const Toggle = Command(standard_schema, (input) =>\n * Effect.succeed(input.enabled)\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema input type.\n */\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\nexport function Command(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_command(\n\t\t\t\tnative_command(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedCommandHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_command(\n\t\t\tnative_command(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Command\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Command\");\n\t}\n}\n\n/**\n * Factory for a remote form handler.\n *\n * @example\n * ```ts\n * export const SignIn = Form(signInSchema, ({ data, invalid }) =>\n * Effect.gen(function* () {\n * if (!data.email.includes(\"@\")) {\n * return yield* invalid.email(\"Use an email address.\");\n * }\n *\n * return { email: data.email };\n * })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit form function.\n */\nexport function Form<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>,\n): EffectRemoteForm<void, A, E>;\nexport function Form<Input extends NativeRemoteFormInput, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteFormHandler<Input, A, E, R>,\n): EffectRemoteForm<Input, A, E>;\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;\nexport function Form<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\nexport function Form(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn native_form(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_form_wrapper(maybe_handler as RemoteFormHandler, \"Form\") as never,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedFormHandlerMissingError();\n\t\t}\n\n\t\tconst inputless_handler: RemoteFormHandler<void, unknown> = ({ data, invalid, issue }) => {\n\t\t\tif (is_handler(validate_or_handler)) {\n\t\t\t\treturn validate_or_handler({ data, invalid, issue });\n\t\t\t}\n\n\t\t\treturn validate_or_handler as EffectLike;\n\t\t};\n\n\t\treturn native_form(\n\t\t\tmake_remote_form_wrapper(inputless_handler, \"Form\") as never,\n\t\t) as unknown as ReturnType<typeof native_form>;\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Form\");\n\t}\n}\n\n/**\n * Creates a prerenderable remote function from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run at\n * prerender time.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called.\n */\nexport function Prerender<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n\tmaybe_options?: PrerenderOptions<void>,\n): EffectRemotePrerenderFunction<void, A, E>;\n\n/**\n * Creates a prerenderable remote function with unchecked input.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * \"unchecked\",\n * (slug: string) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called with input.\n */\nexport function Prerender<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n\tmaybe_options?: PrerenderOptions<Input>,\n): EffectRemotePrerenderFunction<Input, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * Schema.String,\n * (slug) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema encoded type.\n */\nexport function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<SchemaEncodedInput<S>>,\n): EffectRemotePrerenderFunction<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * standard_schema,\n * (post) => Effect.succeed(post.slug),\n * { dynamic: true },\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema input type.\n */\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<StandardSchemaInput<S>>,\n): EffectRemotePrerenderFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n\tvalidate_or_handler: unknown,\n\tmaybe_handler_or_options?: unknown,\n\tmaybe_options?: PrerenderOptions<unknown>,\n\tnative_factory: typeof native_prerender = native_prerender,\n): unknown {\n\ttry {\n\t\tif (is_handler(maybe_handler_or_options)) {\n\t\t\treturn to_effect_prerender(\n\t\t\t\tnative_factory(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n\t\t\t\t\tnormalize_prerender_options(maybe_options) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedPrerenderHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_prerender(\n\t\t\tnative_factory(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Prerender\") as never,\n\t\t\t\tnormalize_prerender_options(\n\t\t\t\t\tmaybe_handler_or_options as PrerenderOptions<void> | undefined,\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Prerender\");\n\t}\n}\n","import { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { EffectHandler } from \"./types.ts\";\nimport { ToEffect } from \"./effects.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Adapts an Effect-producing callback to a native SvelteKit server handler.\n * SvelteKit continues to select the handler by its exported binding name, such\n * as `GET`, `PUT`, or `load`.\n *\n * @example A `+server.ts` request handler:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { RequestHandler } from \"./$types\";\n *\n * export const GET = Handler<RequestHandler>(function* ({ params }) {\n * const post = yield* Posts.get(params.slug);\n *\n * return Response.json(post);\n * });\n * ```\n *\n * @example A `+page.server.ts` load function:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { PageServerLoad } from \"./$types\";\n *\n * export const load = Handler<PageServerLoad>(function* ({ locals }) {\n * const profile = yield* Profiles.get(locals.user.id);\n *\n * return { profile };\n * });\n * ```\n *\n * @since 4.0.0\n * @param handler - Effect-producing callback whose parameters and successful\n * result match the native SvelteKit handler type.\n * @returns A native handler that runs the callback through the configured\n * {@link ServerRuntime} with the current {@link RequestEvent} available.\n */\nexport function Handler<NativeHandler extends (...arguments_: never[]) => unknown>(\n\thandler: EffectHandler<NativeHandler>,\n): NativeHandler {\n\tconst native_handler = async (...arguments_: Parameters<NativeHandler>) => {\n\t\tconst event = get_native_request_event();\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst HandlerEffect = Effect.suspend(() => ToEffect(handler(...arguments_)));\n\t\tconst HandlerOwnedEffect = RunInsideRemoteEffectHandler(event, HandlerEffect);\n\t\tconst EffectWithRequestEvent = Effect.provideService(\n\t\t\tHandlerOwnedEffect,\n\t\t\tRequestEvent,\n\t\t\tevent,\n\t\t);\n\n\t\treturn await runtime.runPromise(EffectWithRequestEvent, {\n\t\t\tsignal: event.request.signal,\n\t\t});\n\t};\n\n\treturn native_handler as unknown as NativeHandler;\n}\n","import { error as svelte_error, redirect as svelte_redirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n\tProxyAuthenticationRequired: 407,\n\tRequestHeaderFieldsTooLarge: 431,\n\tUnavailableForLegalReasons: 451,\n\tNetworkAuthenticationRequired: 511,\n\tHttpVersionNotSupported: 505,\n\tUnprocessableContent: 422,\n\tUnprocessableEntity: 422,\n\tInternalServerError: 500,\n\tFailedDependency: 424,\n\tPreconditionRequired: 428,\n\tServiceUnavailable: 503,\n\tMisdirectedRequest: 421,\n\tInsufficientStorage: 507,\n\tVariantAlsoNegotiates: 506,\n\tPreconditionFailed: 412,\n\tMethodNotAllowed: 405,\n\tGatewayTimeout: 504,\n\tPaymentRequired: 402,\n\tUpgradeRequired: 426,\n\tTooManyRequests: 429,\n\tLengthRequired: 411,\n\tNotAcceptable: 406,\n\tRequestTimeout: 408,\n\tContentTooLarge: 413,\n\tPayloadTooLarge: 413,\n\tUriTooLong: 414,\n\tUnsupportedMediaType: 415,\n\tRangeNotSatisfiable: 416,\n\tExpectationFailed: 417,\n\tImATeapot: 418,\n\tBadRequest: 400,\n\tUnauthorized: 401,\n\tForbidden: 403,\n\tNotFound: 404,\n\tConflict: 409,\n\tGone: 410,\n\tLocked: 423,\n\tTooEarly: 425,\n\tNotImplemented: 501,\n\tBadGateway: 502,\n\tLoopDetected: 508,\n\tNotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n\tMovedPermanently: 301,\n\tTemporaryRedirect: 307,\n\tPermanentRedirect: 308,\n\tMultipleChoices: 300,\n\tNotModified: 304,\n\tSwitchProxy: 306,\n\tSeeOther: 303,\n\tUseProxy: 305,\n\tFound: 302,\n} as const;\n\ntype AppErrorStatus = App.Error extends { readonly status?: infer Status } ? Status : number;\n\n/**\n * Compatibility shim while SER supports both SvelteKit 2 and 3. The wrappers\n * call the SvelteKit 3 control-flow shapes, while SvelteKit 2 ignores extra\n * runtime arguments. Drop these broad call signatures when Kit 2 support is\n * removed.\n */\ntype SvelteError = (status: number, body?: ErrorBody, properties?: ErrorProperties) => never;\n\ntype SvelteRedirect = (status: number, location: string | URL, options?: RedirectOptions) => never;\n\n/**\n * Named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatusName = \"NotFound\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatusName = keyof typeof error_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatus = \"InternalServerError\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatus = ErrorStatusName | number;\n\n/**\n * Error body accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const body: ErrorBody = { message: \"Post not found\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorBody =\n\t| (Omit<App.Error, \"status\"> & { readonly status?: AppErrorStatus })\n\t| string\n\t| undefined;\n\n/**\n * Extra SvelteKit app error properties accepted by the {@link Error} helper\n * when using the SvelteKit 3 string-body overload.\n *\n * @example\n * ```ts\n * const properties: ErrorProperties = { code: \"POST_NOT_FOUND\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorProperties = Omit<App.Error, \"status\" | \"message\">;\n\n/**\n * Named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatusName = \"TemporaryRedirect\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatusName = keyof typeof redirect_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatus = \"SeeOther\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatus = RedirectStatusName | number;\n\n/**\n * Options accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const options: RedirectOptions = { external: true };\n * ```\n *\n * @since 3.4.3\n */\nexport type RedirectOptions = {\n\treadonly external?: boolean | string[];\n};\n\n/**\n * Callable shape for the exported {@link Error} helper.\n *\n * @example\n * ```ts\n * const fail_not_found: ErrorEffectFactory = Error;\n * ```\n *\n * @since 2.3.0\n */\nexport interface ErrorEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Optional SvelteKit error body or message forwarded unchanged\n\t * to SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(status: ErrorStatus, body?: ErrorBody): Effect.Effect<never, never, never>;\n\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value\n\t * using the SvelteKit 3 string-body overload with extra properties.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\", {\n\t * code: \"POST_NOT_FOUND\",\n\t * });\n\t * ```\n\t *\n\t * @since 3.4.3\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Error message forwarded to SvelteKit.\n\t * @param properties - Additional app error properties forwarded to\n\t * SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: ErrorStatus,\n\t\tbody: string,\n\t\tproperties: ErrorProperties,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Callable shape for the exported {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const redirect_after_save: RedirectEffectFactory = Redirect;\n * ```\n *\n * @since 2.3.0\n */\nexport interface RedirectEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's redirect control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Redirect(\"SeeOther\", \"/posts\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric redirect status or PascalCase status name to pass\n\t * to SvelteKit's `redirect` helper.\n\t * @param location - Target URL forwarded unchanged to SvelteKit.\n\t * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n\t * `{ external: true }` or an allowlist to redirect to external URLs.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: RedirectStatus,\n\t\tlocation: string | URL,\n\t\toptions?: RedirectOptions,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Creates an Effect that raises SvelteKit's HTTP error control flow.\n *\n * @example\n * ```ts\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric HTTP status or PascalCase status name to pass to\n * SvelteKit's `error` helper.\n * @param body - Optional SvelteKit error body or message forwarded unchanged\n * to SvelteKit.\n * @param properties - Optional SvelteKit 3 app error properties forwarded when\n * using a string error message.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = ((\n\tstatus: ErrorStatus,\n\tbody?: ErrorBody,\n\tproperties?: ErrorProperties,\n) => {\n\tconst resolved_status = resolve_error_status(status);\n\tconst error = svelte_error as SvelteError;\n\n\treturn Effect.sync((): never => {\n\t\tif (properties === undefined) {\n\t\t\treturn error(resolved_status, body);\n\t\t}\n\n\t\treturn error(resolved_status, body, properties);\n\t});\n}) as ErrorEffectFactory;\n\n/**\n * Creates an Effect that raises SvelteKit's redirect control flow.\n *\n * @example\n * ```ts\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric redirect status or PascalCase status name to pass to\n * SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n * `{ external: true }` or an allowlist to redirect to external URLs.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = ((\n\tstatus: RedirectStatus,\n\tlocation: string | URL,\n\toptions?: RedirectOptions,\n) => {\n\tconst resolved_status = resolve_redirect_status(status);\n\tconst redirect = svelte_redirect as SvelteRedirect;\n\n\treturn Effect.sync((): never => redirect(resolved_status, location, options));\n}) as RedirectEffectFactory;\n\nfunction resolve_error_status(status: ErrorStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,+CAA+B,IAAI,QAAwB;;AAGjE,SAAgB,iCAAiC,OAAyB;CACzE,MAAM,gBAAgB,SAAS,0BAA0B;CAEzD,IAAI,CAAC,eACJ,OAAO;CAGR,QAAQ,6BAA6B,IAAI,aAAa,KAAK,KAAK;AACjE;;AAGA,MAAa,gCACZ,OACA,WAEA,OAAO,kBACN,8BAA8B,KAAK,SAC7B,cACA,8BAA8B,KAAK,CAC1C;AAED,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,eAAe,6BAA6B,IAAI,KAAK,KAAK;CAEhE,6BAA6B,IAAI,OAAO,eAAe,CAAC;AACzD,CAAC;AAEF,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,mBAAmB,6BAA6B,IAAI,KAAK,KAAK,KAAK;CAEzE,IAAI,oBAAoB,GAAG;EAC1B,6BAA6B,OAAO,KAAK;EAEzC;CACD;CAEA,6BAA6B,IAAI,OAAO,eAAe;AACxD,CAAC;AAEF,SAAS,4BAAgD;CACxD,IAAI;EACH,MAAM,QAAQA,gBAAyB;EAEvC,OAAO,OAAO,UAAU,YAAY,UAAU,OAAO,QAAQ,KAAA;CAC9D,QAAQ;EACP;CACD;AACD;;;ACpCA,SAAgB,oBACf,OACkD;CAClD,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD;AAEA,SAAgB,SAAkB,OAAoD;CACrF,IAAI,oBAAuB,KAAK,GAC/B,OAAO,OAAO,UAAU,KA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.2.6",
|
|
4
4
|
"description": "Core module that houses the Vite plugin to enable effectful execution.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/
|
|
8
|
+
"url": "git+https://github.com/artisanstreet/svelte-effect-runtime.git"
|
|
9
9
|
},
|
|
10
10
|
"files": [
|
|
11
11
|
".dist",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-CpWfP_1f.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.ts","../../../modules/svelte-effect-runtime/src/remote/client/command.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-data.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-transport.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-enhance.ts","../../../modules/svelte-effect-runtime/src/remote/client/form.ts","../../../modules/svelte-effect-runtime/src/remote/client/query-result.ts","../../../modules/svelte-effect-runtime/src/remote/client/prerender.ts","../../../modules/svelte-effect-runtime/src/remote/client/query.ts"],"sourcesContent":["export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\nexport function has_method<K extends PropertyKey>(\n\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nexport const DecodeResponseFailure = <ErrorType = never>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tconst body = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json()).pipe(\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\treturn decoded as RemoteFailure<ErrorType>;\n\t\t}\n\n\t\treturn create_remote_http_error(response.status, body);\n\t});\n\nexport const DecodeResponseOrValue = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (value instanceof Response) {\n\t\t\tif (!value.ok) {\n\t\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(value);\n\n\t\t\t\treturn yield* Effect.fail(failure);\n\t\t\t}\n\n\t\t\tconst data = yield* DecodeSuccessResponseBody<ErrorType>(value);\n\n\t\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(\n\t\t\t\t() => decode_payload(data) as Output,\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(() => decode_payload(value) as Output);\n\t});\n\nconst DecodeSuccessResponseBody = <ErrorType>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tif (response.status === 204 || response.status === 205) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = yield* MakeEffectFromPromise<string, ErrorType>(() => response.text());\n\n\t\tif (text.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<unknown, ErrorType>(() => JSON.parse(text));\n\t});\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { EffectRemoteCommandCall, NativeMethod, Pending } from \"./types.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => EffectRemoteCommandCall<Output, ErrorType>) & {\n\treadonly pending: number;\n};\n\n/** Adapts a generated SvelteKit command to SER's Effect-based client ABI. */\nexport function create_remote_command_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n\tpending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n\tconst invoke = has_method(native_factory, \"invoke\") ? native_factory.invoke : undefined;\n\n\tif (typeof native_factory !== \"function\" && !invoke) {\n\t\tthrow new InvalidCommandFactoryError();\n\t}\n\n\tconst count = pending ?? { value: 0 };\n\n\tconst adapter = (input: undefined extends Input ? Input | void : Input) =>\n\t\tMakeCommandEffect<Input, Output, ErrorType>(\n\t\t\tnative_factory,\n\t\t\tinvoke,\n\t\t\tinput,\n\t\t\tdecode_payload,\n\t\t\tcount,\n\t\t);\n\n\tcopy_property_descriptors(native_factory, adapter);\n\n\tif (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n\t\tObject.defineProperty(adapter, \"pending\", {\n\t\t\tget: () => count.value,\n\t\t});\n\t}\n\n\treturn adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\n}\n\nconst MakeCommandEffect = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tpending: Pending,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.acquireUseRelease(\n\t\tAcquirePending(pending),\n\t\t() =>\n\t\t\tInvokeCommand<Input, Output, ErrorType>(\n\t\t\t\tnative_factory,\n\t\t\t\tinvoke,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\t() => updates_args,\n\t\t\t),\n\t\t() => ReleasePending(pending),\n\t) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nconst AcquirePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value += 1;\n\t});\n\nconst ReleasePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value -= 1;\n\t});\n\nconst InvokeCommand = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tread_updates_args: () => unknown[] | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = invoke\n\t\t\t\t? invoke.call(native_factory, input)\n\t\t\t\t: (native_factory as NativeMethod)(input);\n\t\t\tconst updates_args = read_updates_args();\n\n\t\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(invocation),\n\t\t);\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t});\n","export function to_form_data(input: unknown): FormData {\n\tconst form_data = new FormData();\n\n\tappend_form_value(form_data, \"\", input);\n\n\treturn form_data;\n}\n\nfunction append_form_value(form_data: FormData, path: string, value: unknown): void {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const [index, item] of value.entries()) {\n\t\t\tappend_form_value(form_data, `${path}[${index}]`, item);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (value instanceof Blob) {\n\t\tform_data.append(path, value);\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"object\" && value !== null) {\n\t\tfor (const [key, child] of Object.entries(value)) {\n\t\t\tconst child_path = path.length === 0 ? key : `${path}.${key}`;\n\n\t\t\tappend_form_value(form_data, child_path, child);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tform_data.append(`n:${path}`, String(value));\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"boolean\") {\n\t\tform_data.append(`b:${path}`, value ? \"on\" : \"off\");\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { StandardSchema } from \"$/internal/schema.ts\";\nimport { DecodeResponseFailure } from \"./responses.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\nimport { Effect, Option, Schema } from \"effect\";\nimport { to_form_data } from \"./form-data.ts\";\nimport { parse } from \"devalue\";\n\ntype RemoteFormResponseEnvelope =\n\t| {\n\t\t\treadonly _tag: \"RemoteFormErrorEnvelope\";\n\t\t\treadonly error?: unknown;\n\t\t\treadonly status?: number | undefined;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormResultEnvelope\";\n\t\t\treadonly data: string;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormRedirectEnvelope\";\n\t\t\treadonly location: string;\n\t };\n\nexport interface RemoteFormTransport {\n\treadonly binary_form_content_type?: string;\n\treadonly decoders?: Record<string, (value: unknown) => unknown>;\n\treadonly navigate?: (location: string, invalidate_all: boolean) => PromiseLike<void> | void;\n\treadonly remote_request?: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly refresh?: () => PromiseLike<void> | void;\n\treadonly serialize_binary_form?: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ninterface KitRemoteFormTransport extends RemoteFormTransport {\n\treadonly binary_form_content_type: string;\n\treadonly remote_request: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly serialize_binary_form: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ntype RemoteFormDecodedPayload<Output> = {\n\treadonly issues?: readonly FormIssue[];\n\treadonly result?: Output;\n};\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst RemoteFormErrorEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"error\"),\n\terror: Schema.optional(Schema.Unknown),\n\tstatus: Schema.optional(Schema.Number),\n});\n\nconst RemoteFormResultEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"result\"),\n\tdata: Schema.String,\n});\n\nconst RemoteFormRedirectEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"redirect\"),\n\tlocation: Schema.String,\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n\tRemoteFormRedirectEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst RemoteFormRedirectDataSchema = Schema.Struct({\n\tredirect: Schema.String,\n});\n\nconst RemoteFormResultDataSchema = Schema.Struct({\n\t_: Schema.Unknown,\n});\n\nconst KitRemoteFormDataSchema = Schema.Struct({\n\t_: Schema.optional(Schema.Unknown),\n\tredirect: Schema.optional(Schema.String),\n\tr: Schema.optional(Schema.Literal(true)),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\nconst DecodeRemoteFormRedirectData = Schema.decodeUnknownOption(RemoteFormRedirectDataSchema);\nconst DecodeRemoteFormResultData = Schema.decodeUnknownOption(RemoteFormResultDataSchema);\nconst DecodeKitRemoteFormData = Schema.decodeUnknownOption(KitRemoteFormDataSchema);\n\nexport const SubmitRemoteForm = <Output, ErrorType = never>(\n\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: RemoteFormTransport,\n\tpreflight_schema?: StandardSchema,\n) =>\n\tEffect.gen(function* () {\n\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\tget_remote_action_id(form_obj),\n\t\t);\n\n\t\tif (!action_id || remote_base.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new RemoteFormEndpointMissingError()),\n\t\t\t);\n\t\t}\n\n\t\tyield* ValidatePreflightInput<ErrorType>(preflight_schema, input);\n\n\t\tif (is_kit_remote_form_transport(remote_transport)) {\n\t\t\treturn yield* SubmitRemoteFormWithKit<Output, ErrorType>(\n\t\t\t\taction_id,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t);\n\t\t}\n\n\t\tconst response = yield* MakeEffectFromPromise<Response, ErrorType>((signal) =>\n\t\t\tfetch(to_remote_form_url(remote_base, action_id), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: get_remote_request_headers(),\n\t\t\t\tbody: to_form_data(to_remote_form_input(input, action_id)),\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(response);\n\n\t\t\treturn yield* Effect.fail(failure);\n\t\t}\n\n\t\tconst envelope = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json());\n\n\t\treturn yield* DecodeFormResponse<Output, ErrorType>(\n\t\t\tenvelope,\n\t\t\tdecode_payload,\n\t\t\tremote_transport,\n\t\t);\n\t});\n\nconst SubmitRemoteFormWithKit = <Output, ErrorType>(\n\taction_id: string,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: KitRemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst url = to_remote_form_url(remote_base, action_id);\n\t\tconst body = yield* MakeEffectFromSync<Blob, ErrorType>(\n\t\t\t() =>\n\t\t\t\tremote_transport.serialize_binary_form(to_remote_form_input(input, action_id), {\n\t\t\t\t\tremote_refreshes: [],\n\t\t\t\t}).blob,\n\t\t);\n\t\tconst data = yield* MakeEffectFromPromise<unknown, ErrorType>((signal) =>\n\t\t\tremote_transport.remote_request(url, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t...get_remote_request_headers(),\n\t\t\t\t\t\"Content-Type\": remote_transport.binary_form_content_type,\n\t\t\t\t},\n\t\t\t\tbody,\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\treturn yield* DecodeKitFormData<Output, ErrorType>(data, decode_payload, remote_transport);\n\t});\n\nexport function get_remote_action_id(form_obj: NativeFormRecord): string | undefined {\n\tconst action = form_obj.action;\n\n\tif (typeof action !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst fallback = \"http://localhost/\";\n\tconst href = typeof location === \"undefined\" ? fallback : location.href;\n\tconst url = new URL(action, href);\n\n\treturn url.searchParams.get(\"/remote\") ?? url.searchParams.get(\"remote\") ?? undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n\tconst parts = action_id.split(\"/\");\n\tconst head = parts.slice(0, 2).join(\"/\");\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\treturn `${normalized_base}/${head}`;\n}\n\nfunction to_remote_form_input(input: unknown, action_id: string): Record<string, unknown> {\n\tconst data = is_record(input) ? input : {};\n\tconst serialized_key = action_id.split(\"/\").slice(2).join(\"/\");\n\tconst key: unknown = serialized_key.length === 0 ? undefined : JSON.parse(serialized_key);\n\n\tif (key === undefined || data.id !== undefined) {\n\t\treturn data;\n\t}\n\n\treturn {\n\t\t...data,\n\t\tid: key,\n\t};\n}\n\nfunction get_remote_request_headers(): Record<string, string> {\n\tif (typeof location === \"undefined\") {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t\"x-sveltekit-pathname\": location.pathname,\n\t\t\"x-sveltekit-search\": location.search,\n\t};\n}\n\nconst ValidatePreflightInput = <ErrorType>(schema: StandardSchema | undefined, input: unknown) =>\n\tEffect.gen(function* () {\n\t\tif (!schema) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst validated = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(schema[\"~standard\"].validate(input)),\n\t\t);\n\n\t\tif (!is_record(validated) || !Array.isArray(validated.issues)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst issues = validated.issues.map(normalize_standard_issue);\n\n\t\treturn yield* Effect.fail(create_remote_validation_error(issues, { issues }, 400));\n\t});\n\nfunction normalize_standard_issue(issue: unknown): FormIssue {\n\tif (!is_record(issue)) {\n\t\treturn { message: String(issue), path: [] };\n\t}\n\n\tconst message = typeof issue.message === \"string\" ? issue.message : \"Invalid input\";\n\tconst path = Array.isArray(issue.path) ? issue.path.flatMap(normalize_path_segment) : [];\n\n\treturn { message, path };\n}\n\nfunction normalize_path_segment(segment: unknown): Array<string | number> {\n\tif (typeof segment === \"string\" || typeof segment === \"number\") {\n\t\treturn [segment];\n\t}\n\n\tif (!is_record(segment)) {\n\t\treturn [];\n\t}\n\n\tconst key = segment.key;\n\n\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\treturn [key];\n\t}\n\n\treturn [];\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nconst DecodeFormResponse = <Output, ErrorType>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst response = decode_remote_form_response_envelope(envelope);\n\n\t\tif (!response) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew InvalidRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\t\tconst decoded = decode_remote_error<ErrorType>(response.error);\n\n\t\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\t\treturn yield* Effect.fail(decoded);\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_http_error(get_remote_form_error_status(response), response.error),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormRedirectEnvelope\") {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tresponse.location,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst parsed = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tparse(response.data, remote_transport.decoders),\n\t\t);\n\t\tconst redirect_data = DecodeRemoteFormRedirectData(parsed);\n\n\t\tif (Option.isSome(redirect_data)) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tredirect_data.value.redirect,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst result_data = DecodeRemoteFormResultData(parsed);\n\n\t\tif (!Option.isSome(result_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(result_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst DecodeKitFormData = <Output, ErrorType>(\n\tdata: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst decoded_data = DecodeKitRemoteFormData(data);\n\n\t\tif (!Option.isSome(decoded_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst should_invalidate = decoded_data.value.r !== true;\n\n\t\tif (decoded_data.value.redirect) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tdecoded_data.value.redirect,\n\t\t\t\tshould_invalidate,\n\t\t\t\tremote_transport,\n\t\t\t\tdata,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"_\" in decoded_data.value)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(decoded_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tif (should_invalidate) {\n\t\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\t\t}\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst NavigateRemoteForm = <ErrorType>(\n\tlocation: string,\n\tinvalidate_all: boolean,\n\tremote_transport: RemoteFormTransport,\n\tenvelope: unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tconst navigate = remote_transport.navigate;\n\n\t\tif (!navigate) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() =>\n\t\t\tPromise.resolve(navigate(location, invalidate_all)),\n\t\t);\n\n\t\treturn yield* Effect.interrupt;\n\t});\n\nconst RefreshRemoteFormState = <ErrorType>(remote_transport: RemoteFormTransport) =>\n\tEffect.gen(function* () {\n\t\tconst refresh = remote_transport.refresh;\n\n\t\tif (!refresh) {\n\t\t\treturn;\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() => Promise.resolve(refresh()));\n\t});\n\nfunction decode_remote_form_response_envelope(\n\tenvelope: unknown,\n): RemoteFormResponseEnvelope | undefined {\n\tconst decoded = DecodeRemoteFormResponseEnvelope(envelope);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\tif (decoded.value.type === \"error\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormErrorEnvelope\",\n\t\t\terror: decoded.value.error,\n\t\t\tstatus: decoded.value.status,\n\t\t};\n\t}\n\n\tif (decoded.value.type === \"redirect\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormRedirectEnvelope\",\n\t\t\tlocation: decoded.value.location,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t};\n}\n\nfunction get_remote_form_error_status(\n\tresponse: Extract<RemoteFormResponseEnvelope, { _tag: \"RemoteFormErrorEnvelope\" }>,\n): number {\n\tconst nested_status = is_record(response.error) ? response.error.status : undefined;\n\n\tif (response.status !== undefined) {\n\t\treturn response.status;\n\t}\n\n\treturn typeof nested_status === \"number\" ? nested_status : 500;\n}\n\nfunction is_kit_remote_form_transport(\n\tremote_transport: RemoteFormTransport,\n): remote_transport is KitRemoteFormTransport {\n\treturn (\n\t\ttypeof remote_transport.binary_form_content_type === \"string\" &&\n\t\ttypeof remote_transport.remote_request === \"function\" &&\n\t\ttypeof remote_transport.serialize_binary_form === \"function\"\n\t);\n}\n\nfunction decode_remote_form_payload<Output>(\n\tpayload: unknown,\n): RemoteFormDecodedPayload<Output> | undefined {\n\tconst decoded = DecodeRemoteFormPayload(payload);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\treturn decoded.value as RemoteFormDecodedPayload<Output>;\n}\n","import { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\nimport { get_dispatcher } from \"$/dispatcher.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport function wrap_enhance_callback<Output, ErrorType = never>(\n\tcallback: NativeMethod | undefined,\n): NativeMethod | undefined {\n\tif (!callback) {\n\t\treturn undefined;\n\t}\n\n\treturn (event: unknown) => {\n\t\tconst wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n\t\tconst result = callback(wrapped_event);\n\n\t\tif (Effect.isEffect(result)) {\n\t\t\treturn get_dispatcher().run(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n\tif (typeof event !== \"object\" || event === null || !has_method(event, \"submit\")) {\n\t\treturn event;\n\t}\n\n\tconst original_submit = event.submit;\n\tconst { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(event);\n\n\tvoid _submit;\n\n\treturn Object.defineProperties(\n\t\t{},\n\t\t{\n\t\t\t...descriptors,\n\t\t\tsubmit: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: false,\n\t\t\t\tvalue: () => MakeSubmitEffect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction MakeSubmitEffect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = Effect.gen(function* () {\n\t\tconst result = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\toriginal_submit.call(event),\n\t\t);\n\t\tconst value = yield* ResolveSubmitResult<ErrorType>(result, updates_args);\n\n\t\tif (typeof value === \"boolean\") {\n\t\t\treturn read_submit_result<Output>(event);\n\t\t}\n\n\t\treturn value as Output;\n\t}) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n\tObject.defineProperty(SubmitEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn SubmitEffect;\n\t\t},\n\t});\n\n\treturn SubmitEffect;\n}\n\nconst ResolveSubmitResult = <ErrorType>(result: unknown, updates_args: unknown[] | undefined) =>\n\tEffect.gen(function* () {\n\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(\n\t\t\t\t\tresult.updates(...resolve_native_remote_query_updates(updates_args)),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() => Promise.resolve(result));\n\t});\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n\tif (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n\t\treturn undefined;\n\t}\n\n\treturn Reflect.get(event, \"result\") as Output | undefined;\n}\n","import { is_standard_schema, normalize_validator, type StandardSchema } from \"$/internal/schema.ts\";\nimport type { EffectRemoteForm, NativeFormRecord, NativeMethod } from \"./types.ts\";\nimport {\n\tget_remote_action_id,\n\tSubmitRemoteForm,\n\ttype RemoteFormTransport,\n} from \"./form-transport.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ninterface RemoteFormAdapterState {\n\tshared_preflight_schema?: StandardSchema;\n}\n\n/** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */\nexport function create_remote_form_adapter<\n\tInput extends RemoteFormInput | void,\n\tOutput,\n\tErrorType = never,\n>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base = \"\",\n\tremote_transport: RemoteFormTransport = {},\n\tadapter_state: RemoteFormAdapterState = {},\n\tkeyed = false,\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\tlet local_preflight_schema: StandardSchema | undefined;\n\n\tconst SubmitForm = (input?: RemoteInput<Input>) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\t\tget_remote_action_id(form_obj),\n\t\t\t);\n\t\t\tconst can_use_remote_endpoint = remote_base.length > 0 && action_id !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(form_obj.submit(input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn yield* SubmitRemoteForm<Output, ErrorType>(\n\t\t\t\tform_obj,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t\tlocal_preflight_schema ?? adapter_state.shared_preflight_schema,\n\t\t\t);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => SubmitForm(input)) as EffectRemoteForm<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType\n\t>;\n\n\tcopy_property_descriptors(\n\t\tform_obj,\n\t\tcallable,\n\t\tnew Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n\t);\n\n\tObject.defineProperty(callable, \"submit\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: SubmitForm,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tconst validate = form_obj.validate;\n\n\t\tObject.defineProperty(callable, \"validate\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (options?: Record<string, unknown>) =>\n\t\t\t\tValidateRemoteForm<ErrorType>(form_obj, validate, options),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"enhance\")) {\n\t\tObject.defineProperty(callable, \"enhance\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (callback?: NativeMethod) =>\n\t\t\t\tform_obj.enhance(wrap_enhance_callback<Output, ErrorType>(callback)),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"for\")) {\n\t\tObject.defineProperty(callable, \"for\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (key: string | number | boolean) =>\n\t\t\t\tcreate_remote_form_adapter<Input, Output, ErrorType>(\n\t\t\t\t\tform_obj.for(key),\n\t\t\t\t\tdecode_payload,\n\t\t\t\t\tremote_base,\n\t\t\t\t\tremote_transport,\n\t\t\t\t\tadapter_state,\n\t\t\t\t\ttrue,\n\t\t\t\t),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"preflight\")) {\n\t\tObject.defineProperty(callable, \"preflight\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (schema: unknown) => {\n\t\t\t\tconst normalized_schema = normalize_validator(schema);\n\n\t\t\t\tif (is_standard_schema(normalized_schema)) {\n\t\t\t\t\tlocal_preflight_schema = normalized_schema;\n\n\t\t\t\t\tif (!keyed) {\n\t\t\t\t\t\tadapter_state.shared_preflight_schema = normalized_schema;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tform_obj.preflight(normalized_schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn callable;\n}\n\nconst ValidateRemoteForm = <ErrorType>(\n\tform_obj: NativeFormRecord,\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(validate.call(form_obj, normalize_validate_options(validate, options))),\n\t\t);\n\t});\n\nfunction normalize_validate_options(\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n\tif (!options || !(\"all\" in options) || \"includeUntouched\" in options) {\n\t\treturn options;\n\t}\n\n\tconst source = Function.prototype.toString.call(validate);\n\tconst uses_stable_option = source.includes(\"includeUntouched\") && !/\\ball\\s*=/.test(source);\n\n\tif (!uses_stable_option) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\tincludeUntouched: options.all,\n\t};\n}\n","import { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport const ResolveQueryResult = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (has_method(value, \"then\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\tif (has_method(value, \"run\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value.run()),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(value, decode_payload);\n\t});\n","import {\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport { InvalidPrerenderFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors } from \"./utils.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport type { NativeMethod } from \"./types.ts\";\nimport { Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype EffectRemotePrerenderAdapter<Input, Output, ErrorType = never> = (\n\tinput: RemoteInput<Input>,\n) => RemoteResourceEffect<Output, ErrorType>;\n\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => Output,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType> {\n\tif (typeof native_factory !== \"function\") {\n\t\tthrow new InvalidPrerenderFactoryError();\n\t}\n\n\tconst prerender = native_factory as NativeMethod;\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tconst resource_attempt = Result.try(() => prerender(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst PrerenderEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteResourceEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_resource_getters(resource_attempt.failure, PrerenderEffect);\n\n\t\t\treturn PrerenderEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst PrerenderEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tdecode_payload,\n\t\t) as RemoteResourceEffect<Output, ErrorType>;\n\n\t\tattach_remote_resource_getters(resource, PrerenderEffect);\n\n\t\treturn PrerenderEffect;\n\t}) as EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n","import {\n\tattach_failed_remote_query_resource,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tmake_failed_remote_live_stream,\n\tmake_remote_live_stream,\n\ttype RemoteLiveStream,\n} from \"$/live.ts\";\nimport { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { attach_native_remote_query_update } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"$/remote/failures.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport { Effect, Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativeQueryFactory<Input> =\n\t| ((input: RemoteInput<Input>) => unknown)\n\t| {\n\t\t\treadonly load: (input: RemoteInput<Input>) => unknown;\n\t };\n\ntype RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand &\n\tRemoteResourceEffect<Output, ErrorType> & {\n\t\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\t\treadonly set: (value: Output) => void;\n\t\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n\t};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\n/** Adapts a generated SvelteKit query to SER's Effect-based client ABI. */\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: DecodePayload<Output>,\n\t_base?: string,\n\tmode?: QueryAdapterMode,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base?: string,\n\tmode?: QueryAdapterMode,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: DecodePayload<Output>,\n\t_base = \"\",\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n\tconst load = has_method(native_factory, \"load\") ? native_factory.load : undefined;\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query && !load) {\n\t\tthrow new InvalidQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tif (!query) {\n\t\t\treturn Effect.gen(function* () {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(load?.call(native_factory, input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* ResolveQueryResult<Output, ErrorType>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst QueryEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteQueryEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_query_resource(resource_attempt.failure, QueryEffect);\n\n\t\t\treturn QueryEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst query_result = mode === \"batch\" ? begin_batch_query_result(resource) : resource;\n\t\tconst QueryEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tquery_result,\n\t\t\tdecode_payload,\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(QueryEffect, resource);\n\t\tattach_query_resource(resource, QueryEffect);\n\n\t\treturn QueryEffect;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_query_result(resource: unknown): unknown {\n\tif (!has_method(resource, \"then\")) {\n\t\treturn resource;\n\t}\n\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\n/** Adapts a generated SvelteKit live query to SER's Effect-based client ABI. */\nexport function create_remote_live_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\t_decode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>) {\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: Input) => {\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tnormalize_native_error,\n\t\t\t);\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => RefreshRemoteResource(resource, refresh),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nconst RefreshRemoteResource = (resource: unknown, refresh: () => Promise<void>) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource)));\n\t});\n"],"mappings":";;;;;;;;AAGA,SAAgB,WACf,OACA,KACmC;CACnC,MAAM,aAAa,OAAO;CAE1B,QACG,eAAe,YAAY,UAAU,QAAS,eAAe,eAC/D,OAAQ,MAAuC,SAAS;AAE1D;;;ACPA,MAAa,yBAA4C,aACxD,OAAO,IAAI,aAAa;CACvB,MAAM,OAAO,OAAO,4BAAgD,SAAS,KAAK,CAAC,CAAC,CAAC,KACpF,OAAO,oBAAoB,KAAA,CAAS,CACrC;CACA,MAAM,UAAU,oBAA+B,IAAI;CAEnD,IAAI,0BAA0B,OAAO,GACpC,OAAO;CAGR,OAAO,yBAAyB,SAAS,QAAQ,IAAI;AACtD,CAAC;AAEF,MAAa,yBACZ,OACA,mBAEA,OAAO,IAAI,aAAa;CACvB,IAAI,iBAAiB,UAAU;EAC9B,IAAI,CAAC,MAAM,IAAI;GACd,MAAM,UAAU,OAAO,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,YAClB,OAAO,eAAe,QAAQ,OAAO;EACpC,cAAc;EACd,QAAQ,UAAkB,IAAI,KAAK,UAAU,KAAK;CACnD,CAAC;CAGF,IAAI,OAAO,kBAAkB,YAC5B,OAAO,eAAe,QAAQ,gBAAgB;EAC7C,cAAc;EACd,QAAQ,WAAwC,cAAc,KAAK,UAAU,MAAM;CACpF,CAAC;AAEH;AAEA,MAAM,yBAAyB,UAAmB,YACjD,OAAO,IAAI,aAAa;CACvB,OAAO,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"remote-client-mkQAfP1G.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/compiler/remote-client.ts"],"sourcesContent":["import type {\n\tExpression,\n\tImportDeclaration,\n\tSourceFile,\n\tStatement,\n\tVariableStatement,\n} from \"typescript\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\ninterface RemoteClientRewriteOptions {\n\tdebug?: boolean;\n}\n\ntype RemoteClientExportType =\n\t| \"query_batch\"\n\t| \"query_live\"\n\t| \"query\"\n\t| \"command\"\n\t| \"form\"\n\t| \"prerender\";\n\ninterface RemoteNamespaceImport {\n\tname: string;\n\tstatement: ImportDeclaration;\n}\n\ninterface RemoteClientExport {\n\tname: string;\n\ttype: RemoteClientExportType;\n\tstatement: VariableStatement;\n\tnative_call: string;\n}\n\nconst remote_client_export_types = new Set<RemoteClientExportType>([\n\t\"query_batch\",\n\t\"query_live\",\n\t\"query\",\n\t\"command\",\n\t\"form\",\n\t\"prerender\",\n]);\n\n/** Rewrites SvelteKit's generated remote client exports to SER adapters. */\nexport function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: RemoteClientRewriteOptions,\n): string {\n\tconst source_file = ts.createSourceFile(\n\t\t\"sveltekit-remote-client.ts\",\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\tconst namespace_import = find_remote_namespace_import(source_file);\n\n\tif (!namespace_import) {\n\t\treturn code;\n\t}\n\n\tconst remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);\n\n\tif (remote_exports.length === 0) {\n\t\treturn code;\n\t}\n\n\tconst magic = new MagicString(code);\n\tconst has_remote_form = remote_exports.some((remote_export) => remote_export.type === \"form\");\n\tconst imports = [\n\t\t`import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n\t\thas_remote_form &&\n\t\t\t`import { goto as __SER___goto, invalidateAll as __SER___invalidate_all } from \"$app/navigation\";`,\n\t\t`import { app_dir, base } from \"$app/paths/internal/client\";`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\n\tconst helpers = [\n\t\t`const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n\t\t`function __SER___decode_payload(value) { return value; }`,\n\t\thas_remote_form &&\n\t\t\t[\n\t\t\t\t`function __SER___navigate_remote_form(location, invalidate_all) {`,\n\t\t\t\t`\\tconst target = new URL(location, globalThis.location.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\tif (target.origin !== globalThis.location.origin) {`,\n\t\t\t\t`\\t\\tglobalThis.location.assign(target.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\t\\treturn Promise.resolve();`,\n\t\t\t\t`\\t}`,\n\t\t\t\t``,\n\t\t\t\t`\\treturn __SER___goto(target, { invalidateAll: invalidate_all });`,\n\t\t\t\t`}`,\n\t\t\t].join(\"\\n\"),\n\t\thas_remote_form &&\n\t\t\t`const __SER___remote_form_transport = { binary_form_content_type: ${namespace_import.name}.__SER___binary_form_content_type, navigate: __SER___navigate_remote_form, refresh: __SER___invalidate_all, remote_request: ${namespace_import.name}.__SER___remote_request, serialize_binary_form: ${namespace_import.name}.__SER___serialize_binary_form };`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\tconst debug_line = options?.debug ? `console.log(\"[ser] remote client wrappers loaded\");` : \"\";\n\tconst injected = [imports, helpers, debug_line].filter(Boolean).join(\"\\n\");\n\n\tmagic.appendRight(namespace_import.statement.end, `\\n${injected}`);\n\n\tfor (const remote_export of remote_exports) {\n\t\tmagic.overwrite(\n\t\t\tremote_export.statement.getStart(source_file),\n\t\t\tremote_export.statement.end,\n\t\t\tmake_remote_export(remote_export.name, remote_export.type, remote_export.native_call),\n\t\t);\n\t}\n\n\treturn magic.toString();\n}\n\nfunction make_remote_export(\n\tname: string,\n\tremote_type: RemoteClientExportType,\n\tnative_call: string,\n): string {\n\tif (remote_type === \"command\") {\n\t\treturn `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"form\") {\n\t\treturn `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base, __SER___remote_form_transport);`;\n\t}\n\n\tif (remote_type === \"query_live\") {\n\t\treturn `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"prerender\") {\n\t\treturn `export const ${name} = create_remote_prerender_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"query_batch\") {\n\t\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload, \"\", \"batch\");`;\n\t}\n\n\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n\nfunction find_remote_namespace_import(source_file: SourceFile): RemoteNamespaceImport | undefined {\n\tfor (const statement of source_file.statements) {\n\t\tif (!ts.isImportDeclaration(statement)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace_import = get_remote_namespace_import(statement);\n\n\t\tif (namespace_import) {\n\t\t\treturn namespace_import;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_remote_namespace_import(\n\tstatement: ImportDeclaration,\n): RemoteNamespaceImport | undefined {\n\tif (\n\t\t!ts.isStringLiteral(statement.moduleSpecifier) ||\n\t\tstatement.moduleSpecifier.text !== \"__sveltekit/remote\"\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst import_clause = statement.importClause;\n\tconst bindings = import_clause?.namedBindings;\n\n\tif (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: bindings.name.text,\n\t\tstatement,\n\t};\n}\n\nfunction collect_remote_client_exports(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n): RemoteClientExport[] {\n\treturn source_file.statements.flatMap((statement) =>\n\t\tcollect_remote_client_export(source_file, code, namespace, statement),\n\t);\n}\n\nfunction collect_remote_client_export(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n\tstatement: Statement,\n): RemoteClientExport[] {\n\tif (\n\t\t!ts.isVariableStatement(statement) ||\n\t\t!is_export_statement(statement) ||\n\t\t!is_const_declaration_list(statement.declarationList) ||\n\t\tstatement.declarationList.declarations.length !== 1\n\t) {\n\t\treturn [];\n\t}\n\n\tconst declaration = statement.declarationList.declarations[0];\n\tconst initializer = declaration.initializer;\n\n\tif (!ts.isIdentifier(declaration.name) || !initializer) {\n\t\treturn [];\n\t}\n\n\tconst remote_type = get_remote_client_export_type(initializer, namespace);\n\n\tif (!remote_type) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tname: declaration.name.text,\n\t\t\ttype: remote_type,\n\t\t\tstatement,\n\t\t\tnative_call: code.slice(initializer.getStart(source_file), initializer.end),\n\t\t},\n\t];\n}\n\nfunction get_remote_client_export_type(\n\tinitializer: Expression,\n\tnamespace: string,\n): RemoteClientExportType | undefined {\n\tif (!ts.isCallExpression(initializer)) {\n\t\treturn undefined;\n\t}\n\n\tconst expression = initializer.expression;\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) {\n\t\treturn undefined;\n\t}\n\n\tconst remote_type = expression.name.text;\n\n\tif (!is_remote_client_export_type(remote_type)) {\n\t\treturn undefined;\n\t}\n\n\treturn remote_type;\n}\n\nfunction is_remote_client_export_type(value: string): value is RemoteClientExportType {\n\treturn remote_client_export_types.has(value as RemoteClientExportType);\n}\n\nfunction is_export_statement(statement: Statement): boolean {\n\tconst modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;\n\n\treturn modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;\n}\n\nfunction is_const_declaration_list(declaration_list: ts.VariableDeclarationList): boolean {\n\treturn (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;\n}\n"],"mappings":";;;AAmCA,MAAM,6CAA6B,IAAI,IAA4B;CAClE;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,SAAgB,8BACf,MACA,SACS;CACT,MAAM,cAAc,GAAG,iBACtB,8BACA,MACA,GAAG,aAAa,QAChB,MACA,GAAG,WAAW,EACf;CACA,MAAM,mBAAmB,6BAA6B,WAAW;CAEjE,IAAI,CAAC,kBACJ,OAAO;CAGR,MAAM,iBAAiB,8BAA8B,aAAa,MAAM,iBAAiB,IAAI;CAE7F,IAAI,eAAe,WAAW,GAC7B,OAAO;CAGR,MAAM,QAAQ,IAAI,YAAY,IAAI;CAClC,MAAM,kBAAkB,eAAe,MAAM,kBAAkB,cAAc,SAAS,MAAM;CAiC5F,MAAM,WAAW;EAhCD;GACf;GACA,mBACC;GACD;EACD,CAAC,CACC,OAAO,OAAO,CAAC,CACf,KAAK,IAyBiB;EAvBR;GACf;GACA;GACA,mBACC;IACC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;GACD,CAAC,CAAC,KAAK,IAAI;GACZ,mBACC,qEAAqE,iBAAiB,KAAK,8HAA8H,iBAAiB,KAAK,kDAAkD,iBAAiB,KAAK;EACzT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