svelte-effect-runtime 4.1.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-DbwVAMWm.js → client-CkxjaRTA.js} +2 -2
- package/.dist/chunks/{client-DbwVAMWm.js.map → client-CkxjaRTA.js.map} +1 -1
- package/.dist/chunks/{dispatcher-CTWINW5I.js → dispatcher-B6ZRUsjN.js} +139 -44
- package/.dist/chunks/dispatcher-B6ZRUsjN.js.map +1 -0
- package/.dist/chunks/{dispatcher-pZPzarul.js → dispatcher-D8j5wTx6.js} +3 -3
- package/.dist/chunks/{dispatcher-pZPzarul.js.map → dispatcher-D8j5wTx6.js.map} +1 -1
- package/.dist/chunks/{runtime-CPosEhGl.js → runtime-B8RHHy3v.js} +2 -2
- package/.dist/chunks/{runtime-CPosEhGl.js.map → runtime-B8RHHy3v.js.map} +1 -1
- package/.dist/chunks/server-NeyeDSax.js +339 -0
- package/.dist/chunks/server-NeyeDSax.js.map +1 -0
- package/.dist/chunks/{transform-D7TTlPpK.js → transform-C0jW8Qta.js} +38 -5
- package/.dist/chunks/transform-C0jW8Qta.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/environment.d.ts +87 -0
- package/.dist/environment.js +44 -0
- package/.dist/environment.js.map +1 -0
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +2 -0
- package/.dist/mod.js +3 -2
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +35 -0
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/diagnostics.d.ts +67 -0
- package/.dist/remote/server.d.ts +26 -2
- package/.dist/remote/server.js +2 -2
- package/.dist/runtime/transform.js +8 -5
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +1 -1
- package/.dist/server.js +6 -6
- package/.dist/server.js.map +1 -1
- package/package.json +5 -1
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +0 -1
- package/.dist/chunks/server-yQrNoiCR.js +0 -144
- package/.dist/chunks/server-yQrNoiCR.js.map +0 -1
- package/.dist/chunks/transform-D7TTlPpK.js.map +0 -1
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 { run_remote_effect, throw_remote_cause } 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(EffectWithRequestEvent, runtime, svelte_invalid, svelte_remote_error);\n}\n\nconst ToLiveSourceEffect = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tStream.toAsyncIterableEffect(preserve_live_source_cause(value)).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>) =>\n\tvalue.pipe(\n\t\tStream.catchCause((cause) =>\n\t\t\tStream.fromEffect(\n\t\t\t\tEffect.sync(() => throw_remote_cause(cause, svelte_invalid, svelte_remote_error)),\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(EffectWithRequestEvent, runtime, svelte_invalid, svelte_remote_error);\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;;;ACxCA,SAAgB,oBACf,OACkD;CAClD,OACC,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ACtB,oBAAoB;CACpB,oBAAoB;CACpB,qBAAqB;CACrB,uBAAuB;CACvB,oBAAoB;CACpB,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\tto_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(\n\t\t\t\t\t\tcause,\n\t\t\t\t\t\tsvelte_invalid,\n\t\t\t\t\t\tsvelte_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\tto_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,S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"svelte-effect-runtime",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Core module that houses the Vite plugin to enable effectful execution.",
|
|
5
5
|
"license": "BSD-3-Clause",
|
|
6
6
|
"repository": {
|
|
@@ -25,6 +25,10 @@
|
|
|
25
25
|
"types": "./.dist/compiler.d.ts",
|
|
26
26
|
"default": "./.dist/compiler.js"
|
|
27
27
|
},
|
|
28
|
+
"./environment": {
|
|
29
|
+
"types": "./.dist/environment.d.ts",
|
|
30
|
+
"default": "./.dist/environment.js"
|
|
31
|
+
},
|
|
28
32
|
"./runtime/transform": {
|
|
29
33
|
"types": "./.dist/runtime/transform.d.ts",
|
|
30
34
|
"default": "./.dist/runtime/transform.js"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-CTWINW5I.js","names":["#on_dispose","#scope","#disposed","#notify_value_cells","#runtime","#root_scope","#component_scopes","#current_scope","#disposed","#emit_markup_value","#emit_markup_promise","#emit_markup_run","#next_fiber_id","#fibers","#scope_id","#make_scoped_id","#make_value_cache_key","#value_ids","#subscribe_value_cells","#value_cells","#interrupt_cached_fiber","#clear_pending_value_cell","#should_start_value_fiber","#start_value_fiber","#make_promise_cache_key","#promise_ids","#promise_values","#start_promise_fiber","#is_server_render","#clear_value_cells","#hash_deps","#scope_ids","#next_scope_id","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#delete_value_cell","#get_dispatcher","#scope"],"sources":["../../../modules/svelte-effect-runtime/src/dispatcher/fibers.ts","../../../modules/svelte-effect-runtime/src/dispatcher/scope.ts","../../../modules/svelte-effect-runtime/src/dispatcher/deps.ts","../../../modules/svelte-effect-runtime/src/dispatcher/types.ts","../../../modules/svelte-effect-runtime/src/dispatcher/index.ts"],"sourcesContent":["import type { Fiber as FiberType } from \"effect/Fiber\";\nimport { Cause, Effect, Exit, Fiber } from \"effect\";\n\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\nexport const InterruptFiber = (fiber: FiberType<unknown, unknown>) =>\n\tEffect.gen(function* () {\n\t\tyield* Fiber.interrupt(fiber);\n\t});\n\n/** Observes fiber completion and surfaces failures without taking ownership of the fiber. */\nexport const WatchFiberExit = <A>(\n\toptions: { fiber: FiberType<unknown, unknown> } & FiberWatchCallbacks<A>,\n) => {\n\tconst { fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\treturn Effect.gen(function* () {\n\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\tyield* Effect.sync(() => {\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\ton_complete?.();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\ton_failure?.(error);\n\n\t\t\t\tif (surface_failure) {\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ton_complete?.();\n\t\t});\n\t});\n};\n","import { Effect, Exit, Scope } from \"effect\";\nimport type { Fiber } from \"effect\";\n\n/**\n * A component-owned Effect scope.\n *\n * A `ComponentScope` wraps a `Scope.Closeable` forked from the dispatcher's\n * root scope. Work is forked into the scope with `Effect.forkIn`, so closing\n * the scope interrupts that work and runs its finalizers. The generated\n * component teardown disposes the scope on destroy. Disposal is idempotent.\n *\n * @since 4.1.0\n */\nexport class ComponentScope {\n\t#scope: Scope.Closeable;\n\t#disposed = false;\n\treadonly #on_dispose: (scope: ComponentScope) => void;\n\n\tprivate constructor(scope: Scope.Closeable, on_dispose: (scope: ComponentScope) => void) {\n\t\tthis.#scope = scope;\n\t\tthis.#on_dispose = on_dispose;\n\t}\n\n\t/** Forks a child scope from the given root and returns it wrapped. */\n\tstatic fork(\n\t\troot: Scope.Closeable,\n\t\ton_dispose: (scope: ComponentScope) => void,\n\t): ComponentScope {\n\t\treturn new ComponentScope(Scope.forkUnsafe(root), on_dispose);\n\t}\n\n\t/** The underlying closeable scope used to bind Effect work. */\n\tget underlying(): Scope.Closeable {\n\t\treturn this.#scope;\n\t}\n\n\t/** Whether this scope has already been disposed. */\n\tget disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Forks an effect into this scope. The fiber becomes a child of the scope,\n\t * so disposing the scope interrupts it and runs its finalizers. The scope\n\t * is provided ambiently so `Effect.forkIn` registers the fiber as a child.\n\t */\n\tfork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R> {\n\t\t/**\n\t\t * The effect must see the scope before it is forked: provide the scope\n\t\t * inside the forked program so `acquireRelease`-style work resolves it,\n\t\t * and fork that program into the scope so the fiber is a child whose\n\t\t * finalizers run when the scope closes.\n\t\t */\n\t\treturn Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, this.#scope),\n\t\t\tthis.#scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t}\n\n\t/** Effect that closes the scope. Must be run by the owning dispatcher. */\n\tget close_effect(): Effect.Effect<void> {\n\t\treturn Scope.close(this.#scope, Exit.void);\n\t}\n\n\t/**\n\t * Marks the scope disposed and detaches it from the dispatcher. The caller\n\t * is responsible for running {@link close_effect} to run finalizers.\n\t * Idempotent.\n\t */\n\tdispose(): void {\n\t\tif (this.#disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#disposed = true;\n\t\tthis.#on_dispose(this);\n\t}\n}\n","/** Assigns stable identities to object dependencies while hashing value dependencies. */\nexport type DependencyHasher = (deps: readonly unknown[]) => string;\n\nexport function make_dependency_hasher(): DependencyHasher {\n\tconst object_dep_ids = new WeakMap<object, number>();\n\tconst symbol_dep_ids = new Map<symbol, number>();\n\n\tlet next_object_dep_id = 0;\n\tlet next_symbol_dep_id = 0;\n\n\tconst hash_symbol_dep = (dep: symbol): string => {\n\t\tlet id = symbol_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_symbol_dep_id += 1;\n\t\t\tid = next_symbol_dep_id;\n\t\t\tsymbol_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `y:${id}`;\n\t};\n\n\tconst hash_object_dep = (dep: object): string => {\n\t\tlet id = object_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_object_dep_id += 1;\n\t\t\tid = next_object_dep_id;\n\t\t\tobject_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `o:${id}`;\n\t};\n\n\tconst hash_dep = (dep: unknown): string | readonly [\"s\", string] => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep as string];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t};\n\n\tconst hash_deps = (deps: readonly unknown[]): string => JSON.stringify(deps.map(hash_dep));\n\n\treturn hash_deps;\n}\n","import type { Effect } from \"effect\";\n\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\nexport type Dispose = () => void;\n\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupValueEvent<A, F> {\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupPromiseEvent<A> {\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\nexport interface MarkupRunEvent<A> {\n\ttype: typeof Code.Markup.Run;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\nimport {\n\tRuntimeAlreadyInitializedError,\n\tDispatcherDisposedError,\n\tScopeDisposedError,\n} from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime, Scope } from \"effect\";\nimport { InterruptFiber, WatchFiberExit } from \"./fibers.ts\";\nimport { ComponentScope } from \"./scope.ts\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport { make_dependency_hasher } from \"./deps.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Code } from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\nexport class Dispatcher {\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t#notify_value_cells = (): void => {};\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t#value_ids = new Map<string, string>();\n\t#promise_ids = new Map<string, string>();\n\t#scope_ids = new WeakMap<ComponentScope, string>();\n\t#hash_deps = make_dependency_hasher();\n\t#disposed = false;\n\t#next_fiber_id = 0;\n\t#next_scope_id = 0;\n\t#root_scope = Scope.makeUnsafe();\n\t#component_scopes = new Set<ComponentScope>();\n\t/**\n\t * The component scope that effect execution currently enters. Set by\n\t * generated code via {@link with_scope}; `undefined` outside components.\n\t */\n\t#current_scope: ComponentScope | undefined = undefined;\n\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Begin a component-owned Effect scope. Pass the returned scope to\n\t * {@link run_scoped} so the work is interrupted and finalized when the\n\t * component is destroyed. Disposal is idempotent.\n\t */\n\tbegin_scope(): ComponentScope {\n\t\tconst scope = ComponentScope.fork(this.#root_scope, (disposed) => {\n\t\t\tthis.#component_scopes.delete(disposed);\n\t\t});\n\n\t\tthis.#component_scopes.add(scope);\n\n\t\treturn scope;\n\t}\n\n\t/**\n\t * Runs `fn` with `scope` as the current component scope. While active,\n\t * every effect path ({@link promise}, {@link run}, {@link value}) forks\n\t * its work into `scope` so disposing the scope interrupts it and runs its\n\t * finalizers. A disposed scope falls back to unscoped execution.\n\t */\n\twith_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\tif (scope.disposed) {\n\t\t\treturn fn();\n\t\t}\n\n\t\tconst previous = this.#current_scope;\n\t\tthis.#current_scope = scope;\n\n\t\ttry {\n\t\t\treturn fn();\n\t\t} finally {\n\t\t\tthis.#current_scope = previous;\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect into a component scope and starts it. The fiber becomes\n\t * a child of the scope, so disposing the scope interrupts it and runs its\n\t * finalizers. Returns an idempotent handle that interrupts the scoped\n\t * fiber directly.\n\t *\n\t * Throws {@link ScopeDisposedError} when the scope was already disposed\n\t * and {@link DispatcherDisposedError} when the dispatcher was shut down.\n\t */\n\trun_scoped<A, E, R>(scope: ComponentScope, effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tif (scope.disposed || !this.#component_scopes.has(scope)) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\t/**\n\t\t * Track the scoped fiber itself: `forkIn` binds it to the component\n\t\t * scope rather than the awaiting parent, so per-run disposal must\n\t\t * interrupt the scoped fiber directly.\n\t\t */\n\t\tlet scoped_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tthis.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(effect), (fiber) => {\n\t\t\t\tscoped_fiber = fiber;\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\n\t\t\tif (scoped_fiber) {\n\t\t\t\tthis.#runtime.runFork(InterruptFiber(scoped_fiber));\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Disposes a component scope owned by this dispatcher, interrupting its\n\t * bound work and running its finalizers. Idempotent. Rejects scopes owned\n\t * by another dispatcher with {@link ScopeDisposedError}.\n\t */\n\tdispose_scope(scope: ComponentScope): void {\n\t\tif (!this.#component_scopes.has(scope)) {\n\t\t\tif (scope.disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tscope.dispose();\n\t\tthis.#runtime.runFork(scope.close_effect as Effect.Effect<unknown, unknown, unknown>);\n\t}\n\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t\t}),\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t};\n\t}\n\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_value_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#value_ids.get(cache_id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tconst old_fiber = this.#interrupt_cached_fiber(old_key);\n\n\t\t\tthis.#clear_pending_value_cell(old_key, old_fiber);\n\t\t}\n\n\t\tthis.#value_ids.set(cache_id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_promise_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(cache_id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(cache_id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options, cache_id);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.exit(effect);\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tyield* Effect.sync(() => {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\tconst scope = this.#current_scope;\n\n\t\treturn this.#runtime.runPromise(\n\t\t\t(scope\n\t\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t\t: Program) as Effect.Effect<A, unknown, unknown>,\n\t\t);\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const scope of this.#component_scopes) {\n\t\t\tscope.dispose();\n\t\t}\n\n\t\tthis.#component_scopes.clear();\n\t\tthis.#runtime.runFork(\n\t\t\tScope.close(this.#root_scope, Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#scope_id(scope: ComponentScope | undefined): string {\n\t\tif (!scope || scope.disposed) {\n\t\t\treturn \"global\";\n\t\t}\n\n\t\tconst existing = this.#scope_ids.get(scope);\n\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst next = String(this.#next_scope_id);\n\t\tthis.#next_scope_id += 1;\n\t\tthis.#scope_ids.set(scope, next);\n\n\t\treturn next;\n\t}\n\n\t#make_scoped_id(scope_id: string, id: string): string {\n\t\treturn `${scope_id}|${id}`;\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis.#runtime.runFork(InterruptFiber(old_fiber));\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\t/**\n\t\t * Provide the active component scope so scoped acquisition works and\n\t\t * finalizers run when the scope closes on unmount. Interruption of an\n\t\t * individual run does not close the component scope; its finalizers\n\t\t * run at scope disposal, matching the component lifetime.\n\t\t */\n\t\tconst scope = this.#current_scope;\n\t\tconst ScopedProgram = scope\n\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t: Program;\n\t\tconst fiber = this.#runtime.runFork(ScopedProgram as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\tqueueMicrotask(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\tstatus: \"pending\",\n\t\t\t\tfiber,\n\t\t\t});\n\t\t});\n\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\tsurface_failure: false,\n\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t\t}),\n\t\t);\n\t}\n\n\t#start_promise_fiber<A>(\n\t\tcache_key: string,\n\t\toptions: PromiseOptions<A>,\n\t\tcache_id: string,\n\t): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\t/**\n\t\t * See #start_value_fiber: the component scope is provided ambiently so\n\t\t * scoped acquisition works and finalizers run on unmount.\n\t\t */\n\t\tconst scope = this.#current_scope;\n\t\tconst ScopedProgram = scope\n\t\t\t? Effect.provideService(Program, Scope.Scope, scope.underlying)\n\t\t\t: Program;\n\t\tconst fiber = this.#runtime.runFork(ScopedProgram as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst ReleaseFiber = Effect.sync(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#fibers.delete(cache_key);\n\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\tif (this.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\t}\n\t\t});\n\t\tconst AwaitFiber = Effect.gen(function* () {\n\t\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\t\tyield* ReleaseFiber;\n\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\treturn exit.value as A;\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t});\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\treturn this.#runtime.runPromise(AwaitFiber);\n\t}\n\n\t#clear_pending_value_cell(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown> | undefined,\n\t): void {\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (cell?.status !== \"pending\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (fiber !== undefined && cell.fiber !== fiber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#delete_value_cell(cache_key);\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n\n/**\n * Lazily-created component scope used by generated component code.\n *\n * The holder is created synchronously during component init (before any\n * top-level `await`, where `onDestroy` is not yet available), and the scope\n * itself is materialized on first use. Disposal is registered separately\n * through `onDestroy` during component initialisation, so the scope is\n * reliably closed on unmount.\n *\n * @since 4.1.0\n */\nexport class ComponentScopeRef {\n\treadonly #get_dispatcher: () => Dispatcher;\n\t#scope: ComponentScope | undefined;\n\n\tconstructor(get_dispatcher_fn: () => Dispatcher) {\n\t\tthis.#get_dispatcher = get_dispatcher_fn;\n\t}\n\n\t/** The component scope, creating it on first access. */\n\tget scope(): ComponentScope {\n\t\tthis.#scope ??= this.#get_dispatcher().begin_scope();\n\n\t\treturn this.#scope;\n\t}\n\n\t/** Disposes the scope if it was created. Idempotent. */\n\tdispose(): void {\n\t\tconst scope = this.#scope;\n\t\tthis.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AAE5C,SAAgB,iBAA6B;CAC5C,uBAAuB,IAAI,WAAW;CAEtC,OAAO;AACR;AAEA,SAAgB,mBAAyB;CACxC,oBAAoB,QAAQ;CAC5B,qBAAqB;AACtB;;;;;;;;;;;;AAaA,IAAa,oBAAb,MAA+B;CAC9B;CACA;CAEA,YAAY,mBAAqC;EAChD,KAAK0B,kBAAkB;CACxB;;CAGA,IAAI,QAAwB;EAC3B,KAAKC,WAAW,KAAKD,gBAAgB,CAAC,CAAC,YAAY;EAEnD,OAAO,KAAKC;CACb;;CAGA,UAAgB;EACf,MAAM,QAAQ,KAAKA;EACnB,KAAKA,SAAS,KAAA;EAEd,IAAI,SAAS,CAAC,MAAM,UACnB,KAAKD,gBAAgB,CAAC,CAAC,cAAc,KAAK;CAE5C;AACD"}
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { _ as RemoteHelperContextError, v as RemoteHelperError } from "./errors-qhcbUH6o.js";
|
|
2
|
-
import { create_serialized_remote_failure_envelope, is_form_error } from "../remote/shared.js";
|
|
3
|
-
import { Cause, Effect, Exit, Schema } from "effect";
|
|
4
|
-
import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
|
|
5
|
-
import { stringify } from "devalue";
|
|
6
|
-
//#region src/remote/cause-codec.ts
|
|
7
|
-
/** Preserves SvelteKit control flow before classifying transportable Effect failures. */
|
|
8
|
-
function classify_remote_cause(cause) {
|
|
9
|
-
const control_flow = find_sveltekit_control_flow(cause);
|
|
10
|
-
if (control_flow !== void 0) return {
|
|
11
|
-
_tag: "SvelteKitControlFlow",
|
|
12
|
-
value: control_flow
|
|
13
|
-
};
|
|
14
|
-
if (Cause.hasInterruptsOnly(cause)) return {
|
|
15
|
-
_tag: "InterruptOnly",
|
|
16
|
-
cause
|
|
17
|
-
};
|
|
18
|
-
const form_error_issues = find_form_error_issues(cause);
|
|
19
|
-
if (form_error_issues !== void 0) return {
|
|
20
|
-
_tag: "FormInvalid",
|
|
21
|
-
issues: form_error_issues
|
|
22
|
-
};
|
|
23
|
-
return {
|
|
24
|
-
_tag: "RemoteFailure",
|
|
25
|
-
encoded: encode_remote_failure(cause)
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/** Encodes a remote failure into the transport ABI shared with generated clients. */
|
|
29
|
-
function encode_remote_failure(cause) {
|
|
30
|
-
for (const reason of cause.reasons) {
|
|
31
|
-
if (!Cause.isFailReason(reason)) continue;
|
|
32
|
-
const encoded = stringify_failure(to_public_remote_failure(reason.error));
|
|
33
|
-
if (encoded !== void 0) return encoded;
|
|
34
|
-
}
|
|
35
|
-
return stringify_unknown_remote_failure();
|
|
36
|
-
}
|
|
37
|
-
function find_sveltekit_control_flow(cause) {
|
|
38
|
-
for (const reason of cause.reasons) {
|
|
39
|
-
if (!Cause.isDieReason(reason)) continue;
|
|
40
|
-
if (is_sveltekit_control_flow(reason.defect)) return reason.defect;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
function find_form_error_issues(cause) {
|
|
44
|
-
for (const reason of cause.reasons) {
|
|
45
|
-
if (!Cause.isFailReason(reason)) continue;
|
|
46
|
-
const issues = get_form_error_issues(reason.error);
|
|
47
|
-
if (issues !== void 0) return issues;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
function get_form_error_issues(value) {
|
|
51
|
-
if (is_form_error(value)) return value.issues;
|
|
52
|
-
return is_tagged_form_error(value) ? [] : void 0;
|
|
53
|
-
}
|
|
54
|
-
function is_sveltekit_control_flow(value) {
|
|
55
|
-
return isRedirect(value) || isHttpError(value) || isValidationError(value);
|
|
56
|
-
}
|
|
57
|
-
function stringify_failure(value) {
|
|
58
|
-
try {
|
|
59
|
-
return stringify(value);
|
|
60
|
-
} catch {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function to_public_remote_failure(value) {
|
|
65
|
-
if (!has_public_remote_failure_tag(value)) return create_unknown_remote_failure();
|
|
66
|
-
return to_serializable_public_failure(value) ?? create_unknown_remote_failure();
|
|
67
|
-
}
|
|
68
|
-
function to_serializable_public_failure(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
69
|
-
if (typeof value === "function" || typeof value === "symbol") return;
|
|
70
|
-
if (!is_object_like(value)) return value;
|
|
71
|
-
if (stringify_failure(value) !== void 0) return value;
|
|
72
|
-
if (is_internal_object(value)) return;
|
|
73
|
-
if (seen.has(value)) return;
|
|
74
|
-
seen.add(value);
|
|
75
|
-
const serializable = Array.isArray(value) ? value.map((item) => to_serializable_public_failure(item, seen)) : to_plain_record(value, seen);
|
|
76
|
-
seen.delete(value);
|
|
77
|
-
return serializable;
|
|
78
|
-
}
|
|
79
|
-
function to_plain_record(value, seen) {
|
|
80
|
-
const descriptors = Object.getOwnPropertyDescriptors(value);
|
|
81
|
-
const record = {};
|
|
82
|
-
for (const [key, descriptor] of Object.entries(descriptors)) {
|
|
83
|
-
if (key === "stack" || !("value" in descriptor)) continue;
|
|
84
|
-
record[key] = to_serializable_public_failure(descriptor.value, seen);
|
|
85
|
-
}
|
|
86
|
-
if (value instanceof Error && !("message" in record)) record.message = value.message;
|
|
87
|
-
return record;
|
|
88
|
-
}
|
|
89
|
-
function is_object_like(value) {
|
|
90
|
-
return typeof value === "object" && value !== null;
|
|
91
|
-
}
|
|
92
|
-
function has_public_remote_failure_tag(value) {
|
|
93
|
-
return is_object_like(value) && typeof value._tag === "string";
|
|
94
|
-
}
|
|
95
|
-
function is_internal_object(value) {
|
|
96
|
-
return !Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value);
|
|
97
|
-
}
|
|
98
|
-
function is_plain_record(value) {
|
|
99
|
-
const prototype = Object.getPrototypeOf(value);
|
|
100
|
-
return prototype === Object.prototype || prototype === null;
|
|
101
|
-
}
|
|
102
|
-
function create_unknown_remote_failure() {
|
|
103
|
-
return { message: "[UNKNOWN_REMOTE_FAILURE]: Unknown error" };
|
|
104
|
-
}
|
|
105
|
-
function stringify_unknown_remote_failure() {
|
|
106
|
-
return stringify(create_unknown_remote_failure());
|
|
107
|
-
}
|
|
108
|
-
const is_tagged_form_error = Schema.is(Schema.Struct({ _tag: Schema.Literal("FormError") }));
|
|
109
|
-
//#endregion
|
|
110
|
-
//#region src/remote/server.ts
|
|
111
|
-
const request_event_context_error_start = "Can only read the current request event inside functions invoked during `handle`";
|
|
112
|
-
const request_store_context_error = "Could not get the request store.";
|
|
113
|
-
/** Maps a remote Effect exit into the control flow expected by SvelteKit. */
|
|
114
|
-
async function run_remote_effect(effect, runtime, invalid, error) {
|
|
115
|
-
const exit = await runtime.runPromise(Effect.exit(effect));
|
|
116
|
-
if (Exit.isSuccess(exit)) return exit.value;
|
|
117
|
-
throw_remote_cause(exit.cause, invalid, error);
|
|
118
|
-
}
|
|
119
|
-
/** Applies a classified remote Cause decision to SvelteKit's server helpers. */
|
|
120
|
-
function throw_remote_cause(cause, invalid, error) {
|
|
121
|
-
const resolution = classify_remote_cause(cause);
|
|
122
|
-
switch (resolution._tag) {
|
|
123
|
-
case "SvelteKitControlFlow": throw resolution.value;
|
|
124
|
-
case "InterruptOnly": throw Cause.squash(resolution.cause);
|
|
125
|
-
case "FormInvalid": invalid(...resolution.issues);
|
|
126
|
-
case "RemoteFailure": error(500, create_serialized_remote_failure_envelope(resolution.encoded));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function throw_form_error(issues, invalid) {
|
|
130
|
-
invalid(...issues);
|
|
131
|
-
}
|
|
132
|
-
/** Rebrands SvelteKit context failures with the remote helper that triggered them. */
|
|
133
|
-
function normalize_remote_helper_error(err, helper_name) {
|
|
134
|
-
if (is_sveltekit_remote_context_error(err)) return new RemoteHelperContextError(helper_name);
|
|
135
|
-
return err instanceof Error ? err : new RemoteHelperError(err);
|
|
136
|
-
}
|
|
137
|
-
function is_sveltekit_remote_context_error(err) {
|
|
138
|
-
if (!(err instanceof Error)) return false;
|
|
139
|
-
return err.message.startsWith(request_event_context_error_start) || err.message === request_store_context_error;
|
|
140
|
-
}
|
|
141
|
-
//#endregion
|
|
142
|
-
export { encode_remote_failure as a, throw_remote_cause as i, run_remote_effect as n, throw_form_error as r, normalize_remote_helper_error as t };
|
|
143
|
-
|
|
144
|
-
//# sourceMappingURL=server-yQrNoiCR.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-yQrNoiCR.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\n\nexport type RemoteCauseResolution =\n\t| {\n\t\t\treadonly _tag: \"SvelteKitControlFlow\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"InterruptOnly\";\n\t\t\treadonly cause: Cause.Cause<unknown>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"FormInvalid\";\n\t\t\treadonly issues: readonly FormIssue[];\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFailure\";\n\t\t\treadonly encoded: string;\n\t };\n\n/** Preserves SvelteKit control flow before classifying transportable Effect failures. */\nexport function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution {\n\tconst control_flow = find_sveltekit_control_flow(cause);\n\n\tif (control_flow !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"SvelteKitControlFlow\",\n\t\t\tvalue: control_flow,\n\t\t};\n\t}\n\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\treturn {\n\t\t\t_tag: \"InterruptOnly\",\n\t\t\tcause,\n\t\t};\n\t}\n\n\tconst form_error_issues = find_form_error_issues(cause);\n\n\tif (form_error_issues !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"FormInvalid\",\n\t\t\tissues: form_error_issues,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: encode_remote_failure(cause),\n\t};\n}\n\n/** Encodes a remote failure into the transport ABI shared with generated clients. */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst failure = to_public_remote_failure(reason.error);\n\t\tconst encoded = stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn encoded;\n\t\t}\n\t}\n\n\treturn stringify_unknown_remote_failure();\n}\n\nfunction find_sveltekit_control_flow(cause: Cause.Cause<unknown>): unknown | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isDieReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_sveltekit_control_flow(reason.defect)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_form_error_issues(cause: Cause.Cause<unknown>): readonly FormIssue[] | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst issues = get_form_error_issues(reason.error);\n\n\t\tif (issues !== undefined) {\n\t\t\treturn issues;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_form_error_issues(value: unknown): readonly FormIssue[] | undefined {\n\tif (is_form_error(value)) {\n\t\treturn value.issues;\n\t}\n\n\treturn is_tagged_form_error(value) ? [] : undefined;\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_public_remote_failure(value: unknown): unknown {\n\tif (!has_public_remote_failure_tag(value)) {\n\t\treturn create_unknown_remote_failure();\n\t}\n\n\tconst serializable_failure = to_serializable_public_failure(value);\n\n\treturn serializable_failure ?? create_unknown_remote_failure();\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\nconst is_tagged_form_error = Schema.is(\n\tSchema.Struct({\n\t\t_tag: Schema.Literal(\"FormError\"),\n\t}),\n);\n","import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport { classify_remote_cause } from \"$/remote/cause-codec.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\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\nexport { encode_remote_failure } from \"$/remote/cause-codec.ts\";\n\n/** Maps a remote Effect exit into the control flow expected by SvelteKit. */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\tthrow_remote_cause(exit.cause, invalid, error);\n}\n\n/** Applies a classified remote Cause decision to SvelteKit's server helpers. */\nexport function throw_remote_cause(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n): never {\n\tconst resolution = classify_remote_cause(cause);\n\n\tswitch (resolution._tag) {\n\t\tcase \"SvelteKitControlFlow\": {\n\t\t\tthrow resolution.value;\n\t\t}\n\t\tcase \"InterruptOnly\": {\n\t\t\tthrow Cause.squash(resolution.cause);\n\t\t}\n\t\tcase \"FormInvalid\": {\n\t\t\tinvalid(...resolution.issues);\n\t\t}\n\t\tcase \"RemoteFailure\": {\n\t\t\tconst envelope = create_serialized_remote_failure_envelope(resolution.encoded);\n\n\t\t\terror(500, envelope);\n\t\t}\n\t}\n}\n\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/** Rebrands SvelteKit context failures with the remote helper that triggered them. */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,sBAAsB,OAAoD;CACzF,MAAM,eAAe,4BAA4B,KAAK;CAEtD,IAAI,iBAAiB,KAAA,GACpB,OAAO;EACN,MAAM;EACN,OAAO;CACR;CAGD,IAAI,MAAM,kBAAkB,KAAK,GAChC,OAAO;EACN,MAAM;EACN;CACD;CAGD,MAAM,oBAAoB,uBAAuB,KAAK;CAEtD,IAAI,sBAAsB,KAAA,GACzB,OAAO;EACN,MAAM;EACN,QAAQ;CACT;CAGD,OAAO;EACN,MAAM;EACN,SAAS,sBAAsB,KAAK;CACrC;AACD;;AAGA,SAAgB,sBAAsB,OAAqC;CAC1E,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,aAAa,MAAM,GAC7B;EAID,MAAM,UAAU,kBADA,yBAAyB,OAAO,KACR,CAAC;EAEzC,IAAI,YAAY,KAAA,GACf,OAAO;CAET;CAEA,OAAO,iCAAiC;AACzC;AAEA,SAAS,4BAA4B,OAAkD;CACtF,KAAK,MAAM,UAAU,MAAM,SAAS;EACnC,IAAI,CAAC,MAAM,YAAY,MAAM,GAC5B;EAGD,IAAI,0BAA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