svelte-effect-runtime 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-DOx8iC6r.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-IJjsUwrE.js → errors-CLsbGjIa.js} +39 -44
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/{server-D1LcDnZE.js → server-BNrA1I-u.js} +15 -84
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-jNUr65K9.js → transform-BXyYUAez.js} +184 -358
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +1 -19
  31. package/.dist/compiler/source-scan.d.ts +11 -108
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/compiler.d.ts +6 -0
  34. package/.dist/compiler.js +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +30 -42
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +1 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +13 -8
  49. package/.dist/internal/generators.js.map +1 -1
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +0 -54
  54. package/.dist/live.d.ts +9 -26
  55. package/.dist/markup/event-attributes.d.ts +0 -32
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +1 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +1 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +3 -8
  76. package/.dist/mod.js +5 -5
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +3 -37
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +14 -20
  83. package/.dist/remote/client/form.d.ts +4 -24
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +8 -48
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +16 -110
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -50
  98. package/.dist/remote/server.js +2 -2
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +5 -22
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +0 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +1 -126
  111. package/.dist/server/effects.d.ts +4 -53
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/index.d.ts +1 -1
  114. package/.dist/server/invalid.d.ts +0 -7
  115. package/.dist/server/live-snapshot.d.ts +5 -0
  116. package/.dist/server/remote-handler-context.d.ts +5 -0
  117. package/.dist/server/runtime.d.ts +6 -24
  118. package/.dist/server/schema.d.ts +0 -14
  119. package/.dist/server/transport.d.ts +2 -0
  120. package/.dist/server/types.d.ts +49 -26
  121. package/.dist/server/wrappers.d.ts +3 -40
  122. package/.dist/server.d.ts +1 -1
  123. package/.dist/server.js +200 -215
  124. package/.dist/server.js.map +1 -1
  125. package/.dist/yieldable.d.ts +1 -35
  126. package/package.json +2 -2
  127. package/.dist/chunks/client-DcZUV4rR.js +0 -653
  128. package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
  129. package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
  130. package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
  131. package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
  132. package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
  133. package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
  134. package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
  135. package/.dist/chunks/live-BXAKre_4.js +0 -104
  136. package/.dist/chunks/live-BXAKre_4.js.map +0 -1
  137. package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
  138. package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
  139. package/.dist/chunks/schema-D9pct6Y5.js +0 -89
  140. package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
  141. package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
  142. package/.dist/chunks/source-scan-C4PsggID.js +0 -341
  143. package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
  144. package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
  145. package/.dist/remote/client/effect.d.ts +0 -29
  146. package/.dist/remote/client/failures.d.ts +0 -42
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["svelte_invalid","error","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/schema.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/wrappers.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 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\n/**\n * Checks whether a value is the string sentinel for unchecked remotes.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is `\"unchecked\"`.\n */\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n\treturn value === \"unchecked\";\n}\n\n/**\n * Checks whether a value is a remote handler function.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is callable as a handler.\n */\nexport function is_handler(\n\tvalue: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n\treturn typeof value === \"function\";\n}\n","import { encode_remote_failure, run_remote_effect } from \"$/remote/server.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { error as svelte_error, invalid as svelte_invalid } from \"@sveltejs/kit\";\nimport { Cause, Effect, Stream } from \"effect\";\n\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport type { EffectLike } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> = AsyncIterable<A>;\n\ntype LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;\n\n/**\n * Checks whether a value is an Effect generator return object.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be wrapped with `Effect.gen`.\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\n/**\n * Normalizes an Effect-like handler return value into an Effect.\n *\n * @since 2.0.0\n * @param value - Effect or generator return value.\n * @returns Normalized Effect.\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\n/**\n * Compatibility alias for {@link ToEffect}.\n *\n * @example\n * ```ts\n * const program = to_effect(Effect.succeed(1));\n * ```\n *\n * @since 2.0.0\n * @param value - Effect or generator return value.\n * @returns Normalized Effect.\n * @internal\n */\nexport const to_effect = ToEffect;\n\n/**\n * Checks whether a value is an Effect Stream live source.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is an Effect Stream.\n */\nexport function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown> {\n\treturn Stream.isStream(value);\n}\n\n/**\n * Runs and normalizes a live query handler result with request services\n * available to Effect Streams.\n *\n * @since 2.0.0\n * @param value - Live query source or Effect that resolves to one.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with a source SvelteKit can stream.\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\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\tToLiveSourceEffect(value),\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\nfunction ToLiveSourceEffect<A>(\n\tvalue: LiveHandlerResult<A>,\n): Effect.Effect<ResolvedLiveSource<A>, unknown, unknown> {\n\treturn Stream.toAsyncIterableEffect(value as Stream.Stream<A, unknown, unknown>).pipe(\n\t\tEffect.map(wrap_live_source_errors),\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n}\n\nfunction wrap_live_source_errors<A>(source: AsyncIterable<A>): AsyncIterable<A> {\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\tconst iterator = source[Symbol.asyncIterator]();\n\n\t\t\treturn {\n\t\t\t\tasync next() {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn await iterator.next();\n\t\t\t\t\t} catch (error: unknown) {\n\t\t\t\t\t\tthrow_live_source_error(error);\n\t\t\t\t\t}\n\t\t\t\t},\n\n\t\t\t\tasync return(value?: unknown) {\n\t\t\t\t\tif (iterator.return) {\n\t\t\t\t\t\treturn await iterator.return(value);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn {\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\n\t\t\t\tasync throw(error?: unknown) {\n\t\t\t\t\tif (iterator.throw) {\n\t\t\t\t\t\treturn await iterator.throw(error);\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow_live_source_error(error);\n\t\t\t\t},\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction throw_live_source_error(error: unknown): never {\n\tconst encoded = encode_remote_failure(Cause.fail(error));\n\tconst envelope = create_serialized_remote_failure_envelope(encoded);\n\n\tsvelte_error(500, envelope as never);\n}\n\n/**\n * Runs a remote handler Effect with the current request event provided.\n *\n * @since 2.0.0\n * @param value - Handler return value.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with the handler output.\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\tToEffect(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 { Effect } from \"effect\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\n\nimport type { FormInvalid } from \"./types.ts\";\n\n/**\n * Creates a path-aware proxy for remote form validation failures.\n *\n * @since 2.0.0\n * @param path - Current nested form path.\n * @returns Callable invalid proxy for this path.\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\treturn make_invalid_proxy([...path, property]);\n\t\t},\n\t}) as FormInvalid<Input>;\n}\n","import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\n\nimport { run_handler_effect, run_live_handler_source } from \"./effects.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport type {\n\tEffectLike,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n} from \"./types.ts\";\n\nlet running_remote_effect_handlers = 0;\n\n/**\n * Reports whether SER is currently executing user remote handler code.\n *\n * @example\n * ```ts\n * if (is_running_remote_effect_handler()) {\n * return query();\n * }\n * ```\n *\n * @since 2.0.0\n * @returns Whether a remote handler wrapper is currently active.\n * @internal\n */\nexport function is_running_remote_effect_handler(): boolean {\n\treturn running_remote_effect_handlers > 0;\n}\n\n/**\n * Builds the wrapper passed to native query, command, and prerender helpers.\n *\n * @since 2.0.0\n * @param handler - Effect handler or already-built Effect-like value.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit handler wrapper.\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\treturn await run_inside_remote_effect_handler(() => {\n\t\t\ttry {\n\t\t\t\tconst result = is_handler(handler) ? handler(input) : handler;\n\n\t\t\t\treturn run_handler_effect(result, event);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Builds the wrapper passed to native live query helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware live source handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit live query wrapper.\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_inside_remote_effect_handler(() => {\n\t\t\ttry {\n\t\t\t\tconst result = typeof handler === \"function\" ? handler(input as Input) : handler;\n\n\t\t\t\treturn run_live_handler_source(result, event);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t\t}\n\t\t});\n\t};\n}\n\n/**\n * Builds the wrapper passed to native form helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware form handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit form handler wrapper.\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\treturn await run_inside_remote_effect_handler(() => {\n\t\t\tconst invalid_proxy = make_invalid_proxy<Input>();\n\n\t\t\ttry {\n\t\t\t\tconst result = handler({\n\t\t\t\t\tdata: data as Input,\n\t\t\t\t\tinvalid: invalid_proxy,\n\t\t\t\t\tissue,\n\t\t\t\t});\n\n\t\t\t\treturn run_handler_effect(result, event);\n\t\t\t} catch (error: unknown) {\n\t\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t\t}\n\t\t});\n\t};\n}\n\nasync function run_inside_remote_effect_handler<A>(run: () => Promise<A>): Promise<A> {\n\trunning_remote_effect_handlers += 1;\n\n\ttry {\n\t\treturn await run();\n\t} finally {\n\t\trunning_remote_effect_handlers -= 1;\n\t}\n}\n","import {\n\tBatchQueryHandlerMissingError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.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 type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { make_remote_live_stream } from \"$/live.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { Effect, type Schema } from \"effect\";\n\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport {\n\tis_running_remote_effect_handler,\n\tmake_remote_form_wrapper,\n\tmake_remote_live_wrapper,\n\tmake_remote_wrapper,\n} from \"./wrappers.ts\";\nimport type {\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\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\";\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 EffectRemoteResource<Output, ErrorType = never> = EffectRemoteQuery<Output, ErrorType>;\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): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn (native as (input: Input) => unknown)(input);\n\t\t}\n\n\t\tconst resource = (native as (input: Input) => unknown)(input);\n\t\tconst effect = Effect.tryPromise({\n\t\t\ttry: () => Promise.resolve(resource),\n\t\t\tcatch: (error: unknown) => error,\n\t\t}) as unknown as EffectRemoteQuery<Output, ErrorType>;\n\n\t\tattach_query_resource_methods(resource, effect);\n\n\t\treturn effect;\n\t}) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\nfunction is_current_remote_request(): boolean {\n\tif (is_running_remote_effect_handler()) {\n\t\treturn false;\n\t}\n\n\tconst detection = detect_current_remote_request();\n\n\tif (detection._tag === \"NoCurrentRemoteRequest\") {\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 resource = (native as (input: Input) => unknown)(input);\n\n\t\treturn make_remote_live_stream<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tcreate_remote_transport_error,\n\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\t}) as unknown as EffectRemoteLiveQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\ntype NativeRemoteResource<Output> = {\n\treadonly current?: Output;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\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 is_query_resource<Output>(resource: unknown): resource is NativeQueryResource<Output> {\n\tconst resource_type = typeof resource;\n\n\treturn (resource_type === \"object\" && resource !== null) || resource_type === \"function\";\n}\n\nfunction attach_remote_resource_getters<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteResource<Output, ErrorType>,\n): void {\n\tconst methods = is_query_resource<Output>(resource) ? resource : undefined;\n\tconst keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tfor (const key of keys) {\n\t\tif (!(key in methods)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tObject.defineProperty(effect, key, {\n\t\t\tconfigurable: true,\n\t\t\tget: () => methods[key],\n\t\t});\n\t}\n}\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n\tconst methods = is_query_resource<Output>(resource) ? resource : 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: () =>\n\t\t\t\tEffect.tryPromise({\n\t\t\t\t\ttry: () => Promise.resolve(refresh.call(resource)),\n\t\t\t\t\tcatch: (error: unknown) => error,\n\t\t\t\t}),\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\n/**\n * Factory for a read-only remote query function.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\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 query function.\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\n/**\n * Factory for a batched read-only remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema or `\"unchecked\"` sentinel.\n * @param maybe_handler - Handler receiving validated inputs as one batch.\n * @returns A SvelteKit batch query function.\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);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.batch\");\n\t}\n}\n\n/**\n * Factory for a live remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg live handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit live query function.\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 native_command(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\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 native_command(\n\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Command\") as never,\n\t\t) as ReturnType<typeof native_command>;\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,\n): EffectRemoteFunction<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: () => [\"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,\n): EffectRemoteFunction<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: () => [\"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,\n): EffectRemoteFunction<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,\n): EffectRemoteFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n\tvalidate_or_handler: unknown,\n\tmaybe_handler_or_options?: unknown,\n\tmaybe_options?: PrerenderOptions,\n): unknown {\n\ttry {\n\t\tif (is_handler(maybe_handler_or_options)) {\n\t\t\treturn native_prerender(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n\t\t\t\tmaybe_options as never,\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 native_prerender(\n\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Prerender\") as never,\n\t\t\tmaybe_handler_or_options as never,\n\t\t) as ReturnType<typeof native_prerender>;\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Prerender\");\n\t}\n}\n","import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { Effect } from \"effect\";\n\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport { ToEffect } from \"./effects.ts\";\nimport type { EffectHandler } from \"./types.ts\";\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 value = handler(...arguments_);\n\t\tconst EffectWithRequestEvent = Effect.provideService(ToEffect(value), RequestEvent, event);\n\n\t\treturn await runtime.runPromise(EffectWithRequestEvent);\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":";;;;;;;;;;;;;;;;;AAgBA,SAAgB,aAAa,OAAsC;CAClE,OAAO,UAAU;AAClB;;;;;;;;AASA,SAAgB,WACf,OAC6D;CAC7D,OAAO,OAAO,UAAU;AACzB;;;;;;;;;;ACVA,SAAgB,oBACf,OACkD;CAClD,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OA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AAS,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 { 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,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAEhD;AAEA,SAAgB,SAAkB,OAAoD;CACrF,IAAI,oBAAuB,KAAK,GAC/B,OAAO,OAAO,UAAU,KAAK;CAG9B,OAAO;AACR;AAEA,SAAgB,eAAkB,OAA6D;CAC9F,OAAO,OAAO,SAAS,KAAK;A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AY;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,41 +1,7 @@
1
1
  import { EmptyStreamYieldError } from "./errors.js";
2
2
  import { Effect, Stream } from "effect";
3
- /**
4
- * Values generated `yield*` positions can normalize into an Effect.
5
- *
6
- * @example
7
- * ```ts
8
- * const value: Yieldable<number> = Stream.make(1);
9
- * ```
10
- *
11
- * @since 3.4.8
12
- */
13
3
  export type Yieldable<A = unknown, E = unknown, R = unknown> = Effect.Effect<A, E, R> | Effect.gen.Return<A, E, R> | Stream.Stream<A, E, R>;
14
- /**
15
- * Success type produced when generated code yields an Effect or a Stream.
16
- *
17
- * @example
18
- * ```ts
19
- * type User = YieldSuccess<ReturnType<typeof loadUser>>;
20
- * ```
21
- *
22
- * @since 3.4.8
23
- */
24
4
  export type YieldSuccess<Value> = Value extends Stream.Stream<infer A, unknown, unknown> ? A : Value extends Effect.Effect<infer A, unknown, unknown> ? A : Value extends Effect.gen.Return<infer A, unknown, unknown> ? A : never;
25
- /**
26
- * Normalizes generated `yield*` operands into Effects.
27
- *
28
- * @example
29
- * ```ts
30
- * const first = yield* ToEffect(Stream.make("ready"));
31
- * ```
32
- *
33
- * @since 3.4.8
34
- * @param value - Effect, generator return object, or Stream emitted from a
35
- * lowered component `yield*` expression.
36
- * @returns An Effect that resolves with the original Effect success value or
37
- * the first Stream emission.
38
- * @internal
39
- */
5
+ /** Normalizes generated Effect and generator values at the transform ABI boundary. */
40
6
  export declare function ToEffect<A, E, R>(value: Effect.Effect<A, E, R> | Effect.gen.Return<A, E, R>): Effect.Effect<A, E, R>;
41
7
  export declare function ToEffect<A, E, R>(value: Stream.Stream<A, E, R>): Effect.Effect<A, E | EmptyStreamYieldError, R>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-effect-runtime",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Core module that houses the Vite plugin to enable effectful execution.",
5
5
  "license": "BSD-3-Clause",
6
6
  "repository": {
@@ -55,7 +55,7 @@
55
55
  "rolldown": "^1.0.0-rc.13"
56
56
  },
57
57
  "peerDependencies": {
58
- "@sveltejs/kit": "^2.0.0 || ^3.0.0-next.0",
58
+ "@sveltejs/kit": "^2.61.0 || ^3.0.0-next.0",
59
59
  "@sveltejs/vite-plugin-svelte": "^6.0.0 || ^7.0.0",
60
60
  "effect": "^4.0.0-beta",
61
61
  "svelte": "^5.0.0",