svelte-effect-runtime 3.4.0 → 3.4.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 (46) hide show
  1. package/.dist/chunks/{client-i7LwWCpT.js → client-7MXXouwb.js} +3 -3
  2. package/.dist/chunks/client-7MXXouwb.js.map +1 -0
  3. package/.dist/chunks/descriptors-OS4VfJuW.js.map +1 -1
  4. package/.dist/chunks/{dispatcher-BX6J0tQV.js → dispatcher-KxyCmCbv.js} +3 -3
  5. package/.dist/chunks/dispatcher-KxyCmCbv.js.map +1 -0
  6. package/.dist/chunks/{dispatcher-D9PG87PW.js → dispatcher-s46GfT6n.js} +2 -2
  7. package/.dist/chunks/dispatcher-s46GfT6n.js.map +1 -0
  8. package/.dist/chunks/{errors-Buz9cLGF.js → errors-0PaWf7Bq.js} +12 -9
  9. package/.dist/chunks/errors-0PaWf7Bq.js.map +1 -0
  10. package/.dist/chunks/{runtime-L7xbXCiW.js → runtime-BXbxv4Ai.js} +3 -3
  11. package/.dist/chunks/{runtime-L7xbXCiW.js.map → runtime-BXbxv4Ai.js.map} +1 -1
  12. package/.dist/chunks/{transform-B5T5TUcJ.js → transform-Cdsx7ygD.js} +2 -2
  13. package/.dist/chunks/transform-Cdsx7ygD.js.map +1 -0
  14. package/.dist/chunks/{vite-DiAwz7jc.js → vite-DTeo70MK.js} +17 -3
  15. package/.dist/chunks/vite-DTeo70MK.js.map +1 -0
  16. package/.dist/detect.js.map +1 -1
  17. package/.dist/dispatcher.js +1 -1
  18. package/.dist/errors.d.ts +4 -3
  19. package/.dist/internal/generators.js +2 -2
  20. package/.dist/internal/remote-client.js +1 -1
  21. package/.dist/markup/promise.js +1 -1
  22. package/.dist/markup/promise.js.map +1 -1
  23. package/.dist/markup/run.js +1 -1
  24. package/.dist/markup/run.js.map +1 -1
  25. package/.dist/markup/transform.js +1 -1
  26. package/.dist/markup/value.js +1 -1
  27. package/.dist/markup/value.js.map +1 -1
  28. package/.dist/mod.js +3 -3
  29. package/.dist/mod.js.map +1 -1
  30. package/.dist/remote/client.js +1 -1
  31. package/.dist/remote/server.js +1 -1
  32. package/.dist/remote/server.js.map +1 -1
  33. package/.dist/remote/shared.js.map +1 -1
  34. package/.dist/runtime/transform.js +2 -2
  35. package/.dist/runtime/transform.js.map +1 -1
  36. package/.dist/server.js +2 -2
  37. package/.dist/server.js.map +1 -1
  38. package/.dist/vite.js +1 -1
  39. package/README.md +5 -5
  40. package/package.json +1 -1
  41. package/.dist/chunks/client-i7LwWCpT.js.map +0 -1
  42. package/.dist/chunks/dispatcher-BX6J0tQV.js.map +0 -1
  43. package/.dist/chunks/dispatcher-D9PG87PW.js.map +0 -1
  44. package/.dist/chunks/errors-Buz9cLGF.js.map +0 -1
  45. package/.dist/chunks/transform-B5T5TUcJ.js.map +0 -1
  46. package/.dist/chunks/vite-DiAwz7jc.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender"],"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/control-flow.ts"],"sourcesContent":["import { Schema } from \"effect\";\r\n\r\nimport type { RemoteHandler, StandardSchema } from \"./types.ts\";\r\n\r\n/**\r\n * Checks whether a value is the string sentinel for unchecked remotes.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value is `\"unchecked\"`.\r\n */\r\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\r\n return value === \"unchecked\";\r\n}\r\n\r\n/**\r\n * Checks whether a value is a remote handler function.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value is callable as a handler.\r\n */\r\nexport function is_handler(\r\n value: unknown,\r\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\r\n return typeof value === \"function\";\r\n}\r\n\r\n/**\r\n * Checks whether a value implements the Standard Schema contract.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value is a Standard Schema.\r\n */\r\nexport function is_standard_schema(value: unknown): value is StandardSchema {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n \"~standard\" in value\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value looks like an Effect Schema.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value should be converted to Standard Schema.\r\n */\r\nexport function is_effect_schema(\r\n value: unknown,\r\n): value is Schema.Schema<unknown> {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n \"ast\" in value &&\r\n \"make\" in value\r\n );\r\n}\r\n\r\n/**\r\n * Converts Effect Schema inputs to Standard Schema for SvelteKit.\r\n *\r\n * @since 2.0.0\r\n * @param value - Schema or handler input.\r\n * @returns Original value or Standard Schema view of an Effect Schema.\r\n */\r\nexport function normalize_validator(value: unknown): unknown {\r\n if (is_standard_schema(value) || !is_effect_schema(value)) {\r\n return value;\r\n }\r\n\r\n return Schema.toStandardSchemaV1(value as never);\r\n}\r\n","import { run_remote_effect } from \"$/remote/server.ts\";\r\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\r\nimport { error as svelte_error, invalid } from \"@sveltejs/kit\";\r\nimport { Effect, Stream } from \"effect\";\r\n\r\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\r\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\r\nimport type { EffectLike, EffectRemoteLiveSource } from \"./types.ts\";\r\n\r\ntype ResolvedLiveSource<A> =\r\n | AsyncIterable<A>\r\n | AsyncIterator<A>\r\n | Iterable<A>\r\n | Iterator<A>;\r\n\r\ntype LiveHandlerResult<A> =\r\n | EffectLike<EffectRemoteLiveSource<A>, unknown, unknown>\r\n | EffectRemoteLiveSource<A>;\r\n\r\n/**\r\n * Checks whether a value is an Effect generator return object.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value should be wrapped with `Effect.gen`.\r\n */\r\nexport function is_generator_result<A>(\r\n value: unknown,\r\n): value is Effect.gen.Return<A, unknown, unknown> {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n typeof (value as { next?: unknown }).next === \"function\"\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes an Effect-like handler return value into an Effect.\r\n *\r\n * @since 2.0.0\r\n * @param value - Effect or generator return value.\r\n * @returns Normalized Effect.\r\n */\r\nexport function to_effect<A, E, R>(\r\n value: EffectLike<A, E, R>,\r\n): Effect.Effect<A, E, R> {\r\n if (is_generator_result<A>(value)) {\r\n return Effect.gen(() => value) as Effect.Effect<A, E, R>;\r\n }\r\n\r\n return value;\r\n}\r\n\r\n/**\r\n * Checks whether a value is a live query source SvelteKit can consume.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value is an Effect Stream or native iterable source.\r\n */\r\nexport function is_live_source<A>(\r\n value: unknown,\r\n): value is EffectRemoteLiveSource<A> {\r\n if (Stream.isStream(value)) {\r\n return true;\r\n }\r\n\r\n if (typeof value !== \"object\" || value === null) {\r\n return false;\r\n }\r\n\r\n const source = value as {\r\n readonly next?: unknown;\r\n readonly [Symbol.asyncIterator]?: unknown;\r\n readonly [Symbol.iterator]?: unknown;\r\n };\r\n\r\n return (\r\n typeof source.next === \"function\" ||\r\n typeof source[Symbol.asyncIterator] === \"function\" ||\r\n typeof source[Symbol.iterator] === \"function\"\r\n );\r\n}\r\n\r\n/**\r\n * Runs and normalizes a live query handler result with request services\r\n * available to Effect Streams.\r\n *\r\n * @since 2.0.0\r\n * @param value - Live query source or Effect that resolves to one.\r\n * @param event - SvelteKit request event for this remote call.\r\n * @returns Promise resolving with a source SvelteKit can stream.\r\n */\r\nexport function run_live_handler_source<A>(\r\n value: LiveHandlerResult<A>,\r\n event: RequestEventShape,\r\n): Promise<ResolvedLiveSource<A>> {\r\n const runtime = get_server_runtime_or_throw();\r\n const effect = Effect.provideService(\r\n to_live_source_effect(value),\r\n RequestEvent,\r\n event,\r\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\r\n\r\n return run_remote_effect(\r\n effect,\r\n runtime,\r\n svelte_invalid,\r\n svelte_remote_error,\r\n );\r\n}\r\n\r\nfunction to_live_source_effect<A>(\r\n value: LiveHandlerResult<A>,\r\n): Effect.Effect<ResolvedLiveSource<A>, unknown, unknown> {\r\n if (Stream.isStream(value)) {\r\n return Stream.toAsyncIterableEffect(\r\n value as Stream.Stream<A, unknown, unknown>,\r\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\r\n }\r\n\r\n if (is_native_live_source<A>(value)) {\r\n return Effect.succeed(value);\r\n }\r\n\r\n if (!Effect.isEffect(value)) {\r\n return Effect.fail(new InvalidLiveQueryReturnError());\r\n }\r\n\r\n return Effect.flatMap(\r\n value as Effect.Effect<EffectRemoteLiveSource<A>, unknown, unknown>,\r\n to_live_source_effect,\r\n );\r\n}\r\n\r\nfunction is_native_live_source<A>(\r\n value: unknown,\r\n): value is ResolvedLiveSource<A> {\r\n return is_live_source<A>(value) && !Stream.isStream(value);\r\n}\r\n\r\n/**\r\n * Runs a remote handler Effect with the current request event provided.\r\n *\r\n * @since 2.0.0\r\n * @param value - Handler return value.\r\n * @param event - SvelteKit request event for this remote call.\r\n * @returns Promise resolving with the handler output.\r\n */\r\nexport function run_handler_effect<A>(\r\n value: EffectLike<A, unknown, unknown>,\r\n event: RequestEventShape,\r\n): Promise<A> {\r\n const runtime = get_server_runtime_or_throw();\r\n const effect = Effect.provideService(\r\n to_effect(value),\r\n RequestEvent,\r\n event,\r\n ) as Effect.Effect<A, unknown, unknown>;\r\n\r\n return run_remote_effect(\r\n effect,\r\n runtime,\r\n svelte_invalid,\r\n svelte_remote_error,\r\n );\r\n}\r\n\r\nconst svelte_invalid = (_status: number, body: unknown): never => {\r\n const issues = typeof body === \"object\" && body !== null &&\r\n Array.isArray((body as { issues?: unknown }).issues)\r\n ? (body as { issues: unknown[] }).issues\r\n : [String(body)];\r\n\r\n invalid(...(issues as never[]));\r\n};\r\n\r\nconst svelte_remote_error = (status: number, body: unknown): never => {\r\n svelte_error(status as never, body as never);\r\n};\r\n","import { create_form_error } from \"$/remote/shared.ts\";\r\nimport { Effect } from \"effect\";\r\nimport type { FormIssue } from \"$/remote/shared.ts\";\r\n\r\nimport type { FormInvalid } from \"./types.ts\";\r\n\r\n/**\r\n * Creates a path-aware proxy for remote form validation failures.\r\n *\r\n * @since 2.0.0\r\n * @param path - Current nested form path.\r\n * @returns Callable invalid proxy for this path.\r\n */\r\nexport function make_invalid_proxy<Input = unknown>(\r\n path: readonly (string | number)[] = [],\r\n): FormInvalid<Input> {\r\n const invalid_at_path = (message: string) =>\r\n Effect.fail(\r\n create_form_error([{ message, path: [...path] } satisfies FormIssue]),\r\n );\r\n\r\n return new Proxy(invalid_at_path, {\r\n get(_target, property) {\r\n if (typeof property === \"symbol\") {\r\n return undefined;\r\n }\r\n\r\n return make_invalid_proxy([...path, property]);\r\n },\r\n }) as FormInvalid<Input>;\r\n}\r\n","import { getRequestEvent as get_native_request_event } from \"$app/server\";\r\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\r\n\r\nimport { run_handler_effect, run_live_handler_source } from \"./effects.ts\";\r\nimport { make_invalid_proxy } from \"./invalid.ts\";\r\nimport { is_handler } from \"./schema.ts\";\r\nimport type { RequestEvent } from \"./runtime.ts\";\r\nimport type {\r\n EffectLike,\r\n RemoteFormHandler,\r\n RemoteHandler,\r\n RemoteLiveHandler,\r\n} from \"./types.ts\";\r\n\r\nlet running_remote_effect_handlers = 0;\r\n\r\n/**\r\n * Reports whether SER is currently executing user remote handler code.\r\n *\r\n * @example\r\n * ```ts\r\n * if (is_running_remote_effect_handler()) {\r\n * return query();\r\n * }\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @returns Whether a remote handler wrapper is currently active.\r\n * @internal\r\n */\r\nexport function is_running_remote_effect_handler(): boolean {\r\n return running_remote_effect_handlers > 0;\r\n}\r\n\r\n/**\r\n * Builds the wrapper passed to native query, command, and prerender helpers.\r\n *\r\n * @since 2.0.0\r\n * @param handler - Effect handler or already-built Effect-like value.\r\n * @param helper_name - Remote helper name for error normalization.\r\n * @returns Native SvelteKit handler wrapper.\r\n */\r\nexport function make_remote_wrapper(\r\n handler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\r\n helper_name: string,\r\n): (input: unknown) => Promise<unknown> {\r\n return async (input: unknown) => {\r\n let event: RequestEvent;\r\n\r\n try {\r\n event = get_native_request_event() as unknown as RequestEvent;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n\r\n return await run_inside_remote_effect_handler(() => {\r\n try {\r\n const result = is_handler(handler) ? handler(input) : handler;\r\n\r\n return run_handler_effect(result, event);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n });\r\n };\r\n}\r\n\r\n/**\r\n * Builds the wrapper passed to native live query helpers.\r\n *\r\n * @since 2.0.0\r\n * @param handler - Effect-aware live source handler.\r\n * @param helper_name - Remote helper name for error normalization.\r\n * @returns Native SvelteKit live query wrapper.\r\n */\r\nexport function make_remote_live_wrapper<Input, A>(\r\n handler: RemoteLiveHandler<Input, A, unknown, unknown>,\r\n helper_name: string,\r\n): (input: unknown) => Promise<unknown> {\r\n return async (input: unknown) => {\r\n let event: RequestEvent;\r\n\r\n try {\r\n event = get_native_request_event() as unknown as RequestEvent;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n\r\n return await run_inside_remote_effect_handler(() => {\r\n try {\r\n const result = typeof handler === \"function\"\r\n ? handler(input as Input)\r\n : handler;\r\n\r\n return run_live_handler_source(result, event);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n });\r\n };\r\n}\r\n\r\n/**\r\n * Builds the wrapper passed to native form helpers.\r\n *\r\n * @since 2.0.0\r\n * @param handler - Effect-aware form handler.\r\n * @param helper_name - Remote helper name for error normalization.\r\n * @returns Native SvelteKit form handler wrapper.\r\n */\r\nexport function make_remote_form_wrapper<Input, A>(\r\n handler: RemoteFormHandler<Input, A, unknown, unknown>,\r\n helper_name: string,\r\n): (data: unknown, issue: unknown) => Promise<unknown> {\r\n return async (data: unknown, issue: unknown) => {\r\n let event: RequestEvent;\r\n\r\n try {\r\n event = get_native_request_event() as unknown as RequestEvent;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n\r\n return await run_inside_remote_effect_handler(() => {\r\n const invalid_proxy = make_invalid_proxy<Input>();\r\n\r\n try {\r\n const result = handler({\r\n data: data as Input,\r\n invalid: invalid_proxy,\r\n issue,\r\n });\r\n\r\n return run_handler_effect(result, event);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, helper_name);\r\n }\r\n });\r\n };\r\n}\r\n\r\nasync function run_inside_remote_effect_handler<A>(\r\n run: () => Promise<A>,\r\n): Promise<A> {\r\n running_remote_effect_handlers += 1;\r\n\r\n try {\r\n return await run();\r\n } finally {\r\n running_remote_effect_handlers -= 1;\r\n }\r\n}\r\n","import {\r\n BatchQueryHandlerMissingError,\r\n UncheckedCommandHandlerMissingError,\r\n UncheckedFormHandlerMissingError,\r\n UncheckedLiveQueryHandlerMissingError,\r\n UncheckedPrerenderHandlerMissingError,\r\n UncheckedQueryHandlerMissingError,\r\n} from \"$/errors.ts\";\r\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\r\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\r\nimport {\r\n command as native_command,\r\n form as native_form,\r\n getRequestEvent as get_native_request_event,\r\n prerender as native_prerender,\r\n query as native_query,\r\n} from \"$app/server\";\r\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\r\nimport { Effect, type Schema } from \"effect\";\r\n\r\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\r\nimport {\r\n is_running_remote_effect_handler,\r\n make_remote_form_wrapper,\r\n make_remote_live_wrapper,\r\n make_remote_wrapper,\r\n} from \"./wrappers.ts\";\r\nimport type {\r\n EffectLike,\r\n EffectRemoteBatchHandler,\r\n EffectRemoteCommand,\r\n EffectRemoteForm,\r\n EffectRemoteFunction,\r\n EffectRemoteLiveQuery,\r\n EffectRemoteLiveQueryFunction,\r\n EffectRemoteLiveQueryResource,\r\n EffectRemoteQuery,\r\n EffectRemoteQueryFunction,\r\n PrerenderOptions,\r\n QueryFactory,\r\n RemoteFormHandler,\r\n RemoteHandler,\r\n RemoteLiveHandler,\r\n SchemaEncodedInput,\r\n SchemaInput,\r\n StandardSchema,\r\n StandardSchemaInput,\r\n StandardSchemaOutput,\r\n} from \"./types.ts\";\r\n\r\ntype FormSchemaEncodedInput<S> = S extends Schema.Top\r\n ? FormRemoteInput<S[\"Encoded\"]>\r\n : never;\r\n\r\ntype FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends\r\n RemoteFormInput ? NormalizeFormEncoded<Input>\r\n : never;\r\n\r\ntype FormStandardSchemaInput<S> = StandardSchemaInput<S> extends RemoteFormInput\r\n ? StandardSchemaInput<S>\r\n : RemoteFormInput;\r\n\r\ntype FormScalar = string | number | boolean | File;\r\n\r\ntype NormalizeFormEncoded<Value> = Value extends FormScalar ? Value\r\n : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>>\r\n : Value extends object ? NormalizeFormObject<Value>\r\n : Value;\r\n\r\ntype NormalizeFormObject<Value> = {\r\n readonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\r\n ? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\r\n : NormalizeFormEncoded<Value[Key]>;\r\n};\r\n\r\ntype OptionalFormKeys<Value> = {\r\n [Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key>\r\n ? Key\r\n : never;\r\n}[keyof Value];\r\n\r\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\r\n\r\ntype EffectRemoteResource<Output, ErrorType = never> =\r\n | EffectRemoteLiveQueryResource<Output>\r\n | EffectRemoteQuery<Output, ErrorType>;\r\n\r\nfunction to_effect_query<Input, Output, ErrorType = never>(\r\n native: NativeQueryLike<Input>,\r\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\r\n const wrapped = ((input: Input) => {\r\n if (is_current_remote_request()) {\r\n return (native as (input: Input) => unknown)(input);\r\n }\r\n\r\n const resource = (native as (input: Input) => unknown)(input);\r\n const effect = Effect.tryPromise({\r\n try: () => Promise.resolve(resource),\r\n catch: (error: unknown) => error,\r\n }) as unknown as EffectRemoteQuery<Output, ErrorType>;\r\n\r\n attach_query_resource_methods(resource, effect);\r\n\r\n return effect;\r\n }) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\r\n\r\n copy_property_descriptors(native, wrapped);\r\n\r\n return wrapped;\r\n}\r\n\r\nfunction is_current_remote_request(): boolean {\r\n if (is_running_remote_effect_handler()) {\r\n return false;\r\n }\r\n\r\n try {\r\n const event = get_native_request_event() as { isRemoteRequest?: boolean };\r\n\r\n return event.isRemoteRequest === true;\r\n } catch {\r\n return false;\r\n }\r\n}\r\n\r\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\r\n native: NativeQueryLike<Input>,\r\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\r\n const wrapped = ((input: Input) => {\r\n const effect = Effect.try({\r\n try: () => {\r\n const resource = (native as (input: Input) => unknown)(input);\r\n\r\n return make_live_resource<Output>(resource);\r\n },\r\n catch: (error: unknown) => error,\r\n }) as unknown as EffectRemoteLiveQuery<Output, ErrorType>;\r\n\r\n return effect;\r\n }) as unknown as EffectRemoteLiveQueryFunction<\r\n Input,\r\n Output,\r\n ErrorType\r\n >;\r\n\r\n copy_property_descriptors(native, wrapped);\r\n\r\n return wrapped;\r\n}\r\n\r\ntype NativeRemoteResource<Output> = {\r\n readonly current?: Output;\r\n readonly error?: unknown;\r\n readonly loading?: boolean;\r\n readonly ready?: boolean;\r\n};\r\n\r\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\r\n readonly refresh?: () => Promise<void>;\r\n readonly set?: (value: Output) => void;\r\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\r\n};\r\n\r\ntype NativeLiveQueryResource<Output> =\r\n & NativeRemoteResource<Output>\r\n & Partial<AsyncIterable<Output>>\r\n & {\r\n readonly connected?: boolean;\r\n readonly done?: boolean;\r\n readonly reconnect?: () => Promise<void>;\r\n };\r\n\r\nfunction is_query_resource<Output>(\r\n resource: unknown,\r\n): resource is NativeQueryResource<Output> {\r\n const resource_type = typeof resource;\r\n\r\n return (\r\n (resource_type === \"object\" && resource !== null) ||\r\n resource_type === \"function\"\r\n );\r\n}\r\n\r\nfunction is_live_resource<Output>(\r\n resource: unknown,\r\n): resource is NativeLiveQueryResource<Output> {\r\n const resource_type = typeof resource;\r\n\r\n return (\r\n (resource_type === \"object\" && resource !== null) ||\r\n resource_type === \"function\"\r\n );\r\n}\r\n\r\nfunction attach_remote_resource_getters<Output, ErrorType = never>(\r\n resource: unknown,\r\n effect: EffectRemoteResource<Output, ErrorType>,\r\n): void {\r\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\r\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n for (const key of keys) {\r\n if (!(key in methods)) {\r\n continue;\r\n }\r\n\r\n Object.defineProperty(effect, key, {\r\n configurable: true,\r\n get: () => methods[key],\r\n });\r\n }\r\n}\r\n\r\nfunction attach_query_resource_methods<Output, ErrorType = never>(\r\n resource: unknown,\r\n effect: EffectRemoteQuery<Output, ErrorType>,\r\n): void {\r\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\r\n const refresh = methods?.refresh;\r\n const set = methods?.set;\r\n const with_override = methods?.withOverride;\r\n\r\n attach_remote_resource_getters(resource, effect);\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n if (typeof refresh === \"function\") {\r\n Object.defineProperty(effect, \"refresh\", {\r\n configurable: true,\r\n value: () =>\r\n Effect.tryPromise({\r\n try: () => Promise.resolve(refresh.call(resource)),\r\n catch: (error: unknown) => error,\r\n }),\r\n });\r\n }\r\n\r\n if (typeof set === \"function\") {\r\n Object.defineProperty(effect, \"set\", {\r\n configurable: true,\r\n value: (value: Output) => set.call(resource, value),\r\n });\r\n }\r\n\r\n if (typeof with_override === \"function\") {\r\n Object.defineProperty(effect, \"withOverride\", {\r\n configurable: true,\r\n value: (update: (current: Output) => Output) =>\r\n with_override.call(resource, update),\r\n });\r\n }\r\n}\r\n\r\nfunction attach_live_resource_methods<Output>(\r\n resource: unknown,\r\n effect: EffectRemoteLiveQueryResource<Output>,\r\n): void {\r\n const methods = is_live_resource<Output>(resource) ? resource : undefined;\r\n const reconnect = methods?.reconnect;\r\n const async_iterator = methods?.[Symbol.asyncIterator];\r\n const keys = [\r\n \"connected\",\r\n \"current\",\r\n \"done\",\r\n \"error\",\r\n \"loading\",\r\n \"ready\",\r\n ] as const;\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n for (const key of keys) {\r\n if (!(key in methods)) {\r\n continue;\r\n }\r\n\r\n Object.defineProperty(effect, key, {\r\n configurable: true,\r\n get: () => methods[key],\r\n });\r\n }\r\n\r\n if (typeof reconnect === \"function\") {\r\n Object.defineProperty(effect, \"reconnect\", {\r\n configurable: true,\r\n value: () =>\r\n Effect.tryPromise({\r\n try: () => Promise.resolve(reconnect.call(resource)),\r\n catch: (error: unknown) => error,\r\n }),\r\n });\r\n }\r\n\r\n if (typeof async_iterator === \"function\") {\r\n Object.defineProperty(effect, Symbol.asyncIterator, {\r\n configurable: true,\r\n value: () => async_iterator.call(resource),\r\n });\r\n }\r\n}\r\n\r\nfunction make_live_resource<Output>(\r\n resource: unknown,\r\n): EffectRemoteLiveQueryResource<Output> {\r\n const live_resource = {} as EffectRemoteLiveQueryResource<Output>;\r\n\r\n attach_live_resource_methods(resource, live_resource);\r\n\r\n return live_resource;\r\n}\r\n\r\n/**\r\n * Factory for a read-only remote query function.\r\n *\r\n * @example\r\n * ```ts\r\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\r\n * Effect.succeed(input.id)\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\r\n * @param maybe_handler - Handler used when a validator is supplied.\r\n * @returns A SvelteKit query function.\r\n */\r\nfunction QueryRoot<A, E = never, R = never>(\r\n validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\r\n): EffectRemoteQueryFunction<void, A, E>;\r\nfunction QueryRoot<Input, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: RemoteHandler<Input, A, E, R>,\r\n): EffectRemoteQueryFunction<Input, A, E>;\r\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\r\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\r\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\r\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\r\nfunction QueryRoot(\r\n validate_or_handler: unknown,\r\n maybe_handler?: unknown,\r\n): unknown {\r\n try {\r\n if (maybe_handler) {\r\n return to_effect_query(native_query(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\r\n ) as ReturnType<typeof native_query>);\r\n }\r\n\r\n if (is_unchecked(validate_or_handler)) {\r\n throw new UncheckedQueryHandlerMissingError();\r\n }\r\n\r\n return to_effect_query(native_query(\r\n make_remote_wrapper(\r\n validate_or_handler as RemoteHandler,\r\n \"Query\",\r\n ) as never,\r\n ) as ReturnType<typeof native_query>);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Query\");\r\n }\r\n}\r\n\r\n/**\r\n * Factory for a batched read-only remote query function.\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema or `\"unchecked\"` sentinel.\r\n * @param maybe_handler - Handler receiving validated inputs as one batch.\r\n * @returns A SvelteKit batch query function.\r\n */\r\nfunction QueryBatch<Input, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\r\n): EffectRemoteQueryFunction<Input, A, E>;\r\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\r\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\r\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\r\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\r\nfunction QueryBatch(\r\n validate_or_handler: unknown,\r\n maybe_handler?: unknown,\r\n): unknown {\r\n try {\r\n if (!maybe_handler) {\r\n throw new BatchQueryHandlerMissingError();\r\n }\r\n\r\n return to_effect_query(native_query.batch(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_wrapper(\r\n maybe_handler as RemoteHandler,\r\n \"Query.batch\",\r\n ) as never,\r\n ) as NativeQueryLike);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Query.batch\");\r\n }\r\n}\r\n\r\n/**\r\n * Factory for a live remote query function.\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg live handler.\r\n * @param maybe_handler - Handler used when a validator is supplied.\r\n * @returns A SvelteKit live query function.\r\n */\r\nfunction QueryLive<A, E = never, R = never>(\r\n validate_or_handler: RemoteLiveHandler<void, A, E, R>,\r\n): EffectRemoteLiveQueryFunction<void, A, E>;\r\nfunction QueryLive<Input, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: RemoteLiveHandler<Input, A, E, R>,\r\n): EffectRemoteLiveQueryFunction<Input, A, E>;\r\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\r\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\r\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\r\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\r\nfunction QueryLive(\r\n validate_or_handler: unknown,\r\n maybe_handler?: unknown,\r\n): unknown {\r\n try {\r\n if (maybe_handler) {\r\n return to_effect_live_query(native_query.live(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_live_wrapper(\r\n maybe_handler as RemoteLiveHandler,\r\n \"Query.live\",\r\n ) as never,\r\n ) as NativeQueryLike);\r\n }\r\n\r\n if (is_unchecked(validate_or_handler)) {\r\n throw new UncheckedLiveQueryHandlerMissingError();\r\n }\r\n\r\n return to_effect_live_query(native_query.live(\r\n make_remote_live_wrapper(\r\n validate_or_handler as RemoteLiveHandler,\r\n \"Query.live\",\r\n ) as never,\r\n ) as NativeQueryLike);\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Query.live\");\r\n }\r\n}\r\n\r\n/**\r\n * Factory for read-only remote query functions.\r\n *\r\n * @example\r\n * ```ts\r\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\r\n * Effect.succeed(input.id)\r\n * );\r\n *\r\n * export const getUserBatch = Query.batch(Schema.String, (ids) =>\r\n * Effect.succeed((id) => ids.includes(id))\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Query: QueryFactory = Object.assign(QueryRoot, {\r\n batch: QueryBatch,\r\n live: QueryLive,\r\n});\r\n\r\n/**\r\n * Factory for a write-oriented remote command function.\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\r\n * @param maybe_handler - Handler used when a validator is supplied.\r\n * @returns A SvelteKit command function.\r\n */\r\nexport function Command<A, E = never, R = never>(\r\n validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\r\n): EffectRemoteCommand<void, A, E>;\r\nexport function Command<Input, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: RemoteHandler<Input, A, E, R>,\r\n): EffectRemoteCommand<Input, A, E>;\r\nexport function Command<\r\n S extends Schema.Schema<unknown>,\r\n A,\r\n E = never,\r\n R = never,\r\n>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\r\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\r\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\r\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\r\nexport function Command(\r\n validate_or_handler: unknown,\r\n maybe_handler?: unknown,\r\n): unknown {\r\n try {\r\n if (maybe_handler) {\r\n return native_command(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\r\n );\r\n }\r\n\r\n if (is_unchecked(validate_or_handler)) {\r\n throw new UncheckedCommandHandlerMissingError();\r\n }\r\n\r\n return native_command(\r\n make_remote_wrapper(\r\n validate_or_handler as RemoteHandler,\r\n \"Command\",\r\n ) as never,\r\n ) as ReturnType<typeof native_command>;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Command\");\r\n }\r\n}\r\n\r\n/**\r\n * Factory for a remote form handler.\r\n *\r\n * @example\r\n * ```ts\r\n * export const SignIn = Form(signInSchema, ({ data, invalid }) =>\r\n * Effect.gen(function* () {\r\n * if (!data.email.includes(\"@\")) {\r\n * return yield* invalid.email(\"Use an email address.\");\r\n * }\r\n *\r\n * return { email: data.email };\r\n * })\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\r\n * @param maybe_handler - Handler used when a validator is supplied.\r\n * @returns A SvelteKit form function.\r\n */\r\nexport function Form<A, E = never, R = never>(\r\n validate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>,\r\n): EffectRemoteForm<void, A, E>;\r\nexport function Form<Input extends RemoteFormInput, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: RemoteFormHandler<Input, A, E, R>,\r\n): EffectRemoteForm<Input, A, E>;\r\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>,\r\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;\r\nexport function Form<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\r\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\r\nexport function Form(\r\n validate_or_handler: unknown,\r\n maybe_handler?: unknown,\r\n): unknown {\r\n try {\r\n if (maybe_handler) {\r\n return native_form(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_form_wrapper(\r\n maybe_handler as RemoteFormHandler,\r\n \"Form\",\r\n ) as never,\r\n );\r\n }\r\n\r\n if (is_unchecked(validate_or_handler)) {\r\n throw new UncheckedFormHandlerMissingError();\r\n }\r\n\r\n const inputless_handler: RemoteFormHandler<void, unknown> = (\r\n { data, invalid, issue },\r\n ) => {\r\n if (is_handler(validate_or_handler)) {\r\n return validate_or_handler({ data, invalid, issue });\r\n }\r\n\r\n return validate_or_handler as EffectLike;\r\n };\r\n\r\n return native_form(\r\n make_remote_form_wrapper(inputless_handler, \"Form\") as never,\r\n ) as unknown as ReturnType<typeof native_form>;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Form\");\r\n }\r\n}\r\n\r\n/**\r\n * Factory for a prerenderable remote function.\r\n *\r\n * @since 2.0.0\r\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\r\n * @param maybe_handler_or_options - Handler or prerender options.\r\n * @param maybe_options - Prerender options used with a validator.\r\n * @returns A SvelteKit prerender function.\r\n */\r\nexport function Prerender<A, E = never, R = never>(\r\n validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\r\n maybe_options?: PrerenderOptions,\r\n): EffectRemoteFunction<void, A, E>;\r\nexport function Prerender<Input, A, E = never, R = never>(\r\n validate_or_handler: \"unchecked\",\r\n maybe_handler: RemoteHandler<Input, A, E, R>,\r\n maybe_options?: PrerenderOptions,\r\n): EffectRemoteFunction<Input, A, E>;\r\nexport function Prerender<\r\n S extends Schema.Schema<unknown>,\r\n A,\r\n E = never,\r\n R = never,\r\n>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\r\n maybe_options?: PrerenderOptions,\r\n): EffectRemoteFunction<SchemaEncodedInput<S>, A, E>;\r\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\r\n validate_or_handler: S,\r\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\r\n maybe_options?: PrerenderOptions,\r\n): EffectRemoteFunction<StandardSchemaInput<S>, A, E>;\r\nexport function Prerender(\r\n validate_or_handler: unknown,\r\n maybe_handler_or_options?: unknown,\r\n maybe_options?: PrerenderOptions,\r\n): unknown {\r\n try {\r\n if (is_handler(maybe_handler_or_options)) {\r\n return native_prerender(\r\n normalize_validator(validate_or_handler) as never,\r\n make_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\r\n maybe_options as never,\r\n );\r\n }\r\n\r\n if (is_unchecked(validate_or_handler)) {\r\n throw new UncheckedPrerenderHandlerMissingError();\r\n }\r\n\r\n return native_prerender(\r\n make_remote_wrapper(\r\n validate_or_handler as RemoteHandler,\r\n \"Prerender\",\r\n ) as never,\r\n maybe_handler_or_options as never,\r\n ) as ReturnType<typeof native_prerender>;\r\n } catch (error: unknown) {\r\n throw normalize_remote_helper_error(error, \"Prerender\");\r\n }\r\n}\r\n","import {\r\n error as svelte_error,\r\n redirect as svelte_redirect,\r\n} from \"@sveltejs/kit\";\r\nimport { Effect } from \"effect\";\r\n\r\nconst error_status_codes = {\r\n ProxyAuthenticationRequired: 407,\r\n RequestHeaderFieldsTooLarge: 431,\r\n UnavailableForLegalReasons: 451,\r\n NetworkAuthenticationRequired: 511,\r\n HttpVersionNotSupported: 505,\r\n UnprocessableContent: 422,\r\n UnprocessableEntity: 422,\r\n InternalServerError: 500,\r\n FailedDependency: 424,\r\n PreconditionRequired: 428,\r\n ServiceUnavailable: 503,\r\n MisdirectedRequest: 421,\r\n InsufficientStorage: 507,\r\n VariantAlsoNegotiates: 506,\r\n PreconditionFailed: 412,\r\n MethodNotAllowed: 405,\r\n GatewayTimeout: 504,\r\n PaymentRequired: 402,\r\n UpgradeRequired: 426,\r\n TooManyRequests: 429,\r\n LengthRequired: 411,\r\n NotAcceptable: 406,\r\n RequestTimeout: 408,\r\n ContentTooLarge: 413,\r\n PayloadTooLarge: 413,\r\n UriTooLong: 414,\r\n UnsupportedMediaType: 415,\r\n RangeNotSatisfiable: 416,\r\n ExpectationFailed: 417,\r\n ImATeapot: 418,\r\n BadRequest: 400,\r\n Unauthorized: 401,\r\n Forbidden: 403,\r\n NotFound: 404,\r\n Conflict: 409,\r\n Gone: 410,\r\n Locked: 423,\r\n TooEarly: 425,\r\n NotImplemented: 501,\r\n BadGateway: 502,\r\n LoopDetected: 508,\r\n NotExtended: 510,\r\n} as const;\r\n\r\nconst redirect_status_codes = {\r\n MovedPermanently: 301,\r\n TemporaryRedirect: 307,\r\n PermanentRedirect: 308,\r\n MultipleChoices: 300,\r\n NotModified: 304,\r\n SwitchProxy: 306,\r\n SeeOther: 303,\r\n UseProxy: 305,\r\n Found: 302,\r\n} as const;\r\n\r\ntype SvelteErrorBody = Parameters<typeof svelte_error>[1];\r\n\r\n/**\r\n * Named HTTP status accepted by the {@link Error} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const status: ErrorStatusName = \"NotFound\";\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport type ErrorStatusName = keyof typeof error_status_codes;\r\n\r\n/**\r\n * Numeric or named HTTP status accepted by the {@link Error} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const status: ErrorStatus = \"InternalServerError\";\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport type ErrorStatus = ErrorStatusName | number;\r\n\r\n/**\r\n * Named HTTP status accepted by the {@link Redirect} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const status: RedirectStatusName = \"TemporaryRedirect\";\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport type RedirectStatusName = keyof typeof redirect_status_codes;\r\n\r\n/**\r\n * Numeric or named HTTP status accepted by the {@link Redirect} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const status: RedirectStatus = \"SeeOther\";\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport type RedirectStatus = RedirectStatusName | number;\r\n\r\n/**\r\n * Callable shape for the exported {@link Error} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const fail_not_found: ErrorEffectFactory = Error;\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport interface ErrorEffectFactory {\r\n /**\r\n * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\r\n *\r\n * @example\r\n * ```ts\r\n * return yield* Error(\"NotFound\", \"Post not found\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n * @param status - Numeric HTTP status or PascalCase status name to pass to\r\n * SvelteKit's `error` helper.\r\n * @param body - Optional SvelteKit error body or message forwarded unchanged\r\n * to SvelteKit.\r\n * @returns An Effect that never succeeds because SvelteKit takes over request\r\n * control flow.\r\n */\r\n (\r\n status: ErrorStatus,\r\n body?: SvelteErrorBody,\r\n ): Effect.Effect<never, never, never>;\r\n}\r\n\r\n/**\r\n * Callable shape for the exported {@link Redirect} helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const redirect_after_save: RedirectEffectFactory = Redirect;\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport interface RedirectEffectFactory {\r\n /**\r\n * Creates an Effect that throws SvelteKit's redirect control-flow value.\r\n *\r\n * @example\r\n * ```ts\r\n * return yield* Redirect(\"SeeOther\", \"/posts\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n * @param status - Numeric redirect status or PascalCase status name to pass\r\n * to SvelteKit's `redirect` helper.\r\n * @param location - Target URL forwarded unchanged to SvelteKit.\r\n * @returns An Effect that never succeeds because SvelteKit takes over request\r\n * control flow.\r\n */\r\n (\r\n status: RedirectStatus,\r\n location: string | URL,\r\n ): Effect.Effect<never, never, never>;\r\n}\r\n\r\n/**\r\n * Creates an Effect that raises SvelteKit's HTTP error control flow.\r\n *\r\n * @example\r\n * ```ts\r\n * return yield* Error(\"NotFound\", \"Post not found\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n * @param status - Numeric HTTP status or PascalCase status name to pass to\r\n * SvelteKit's `error` helper.\r\n * @param body - Optional SvelteKit error body or message forwarded unchanged\r\n * to SvelteKit.\r\n * @returns An Effect that never succeeds because SvelteKit takes over request\r\n * control flow.\r\n */\r\nexport const Error: ErrorEffectFactory = (status, body) => {\r\n const resolved_status = resolve_error_status(status);\r\n\r\n return Effect.sync(() => {\r\n svelte_error(resolved_status, body);\r\n });\r\n};\r\n\r\n/**\r\n * Creates an Effect that raises SvelteKit's redirect control flow.\r\n *\r\n * @example\r\n * ```ts\r\n * return yield* Redirect(\"SeeOther\", \"/posts\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n * @param status - Numeric redirect status or PascalCase status name to pass to\r\n * SvelteKit's `redirect` helper.\r\n * @param location - Target URL forwarded unchanged to SvelteKit.\r\n * @returns An Effect that never succeeds because SvelteKit takes over request\r\n * control flow.\r\n */\r\nexport const Redirect: RedirectEffectFactory = (status, location) => {\r\n const resolved_status = resolve_redirect_status(status);\r\n\r\n return Effect.sync(() => {\r\n svelte_redirect(resolved_status, location);\r\n });\r\n};\r\n\r\nfunction resolve_error_status(status: ErrorStatus): number {\r\n if (typeof status === \"number\") {\r\n return status;\r\n }\r\n\r\n return error_status_codes[status];\r\n}\r\n\r\nfunction resolve_redirect_status(status: RedirectStatus): number {\r\n if (typeof status === \"number\") {\r\n return status;\r\n }\r\n\r\n return redirect_status_codes[status];\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAgB,aAAa,OAAsC;CACjE,OAAO,UAAU;AACnB;;;;;;;;AASA,SAAgB,WACd,OAC4D;CAC5D,OAAO,OAAO,UAAU;AAC1B;;;;;;;;AASA,SAAgB,mBAAmB,OAAyC;CAC1E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe;AAEnB;;;;;;;;AASA,SAAgB,iBACd,OACiC;CACjC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,SAAS,SACT,UAAU;AAEd;;;;;;;;AASA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,mBAAmB,KAAK,KAAK,CAAC,iBAAiB,KAAK,GACtD,OAAO;CAGT,OAAO,OAAO,mBAAmB,KAAc;AACjD;;;;;;;;;;AChDA,SAAgB,oBACd,OACiD;CACjD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAElD;;;;;;;;AASA,SAAgB,UACd,OACwB;CACxB,IAAI,oBAAuB,KAAK,GAC9B,OAAO,OAAO,UAAU,KAA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AA+B;CAC/B,yBAAyB;CACzB,sBAAsB;CACtB,qBAAqB;CACrB,qBAAqB;CACrB,kBAAkB;CAClB,sBAAsB;CACtB,oBAAoB;CACpB,oBAAoB;CACpB,qBAAqB;CACrB,uBAAuB;CACvB,oBAAoB;CACpB,kBAAkB;CAClB,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,YAAY;CACZ,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,WAAW;CACX,YAAY;CACZ,cAAc;CACd,WAAW;CACX,UAAU;CACV,UAAU;CACV,MAAM;CACN,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,YAAY;CACZ,cAAc;CACd,aAAa;AACf;AAEA,MAAM,wBAAwB;CAC5B,kBAAkB;CAClB,mBAAmB;CACnB,mBAAmB;CACnB,iBAAiB;CACjB,aAAa;CACb,aAAa;CACb,UAAU;CACV,UAAU;CACV,OAAO;AACT;;;;;;;;;;;;;;;;;AAqIA,MAAa,SAA6B,QAAQ,SAAS;CACzD,MAAM,kBAAkB,qBAAqB,MAAM;CAEnD,OAAO,OAAO,WAAW;EACvB,MAAa,iBAAiB,IAAI;CACpC,CAAC;AACH;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAmC,QAAQ,aAAa;CACnE,MAAM,kBAAkB,wBAAwB,MAAM;CAEtD,OAAO,OAAO,WAAW;EACvB,SAAgB,iBAAiB,QAAQ;CAC3C,CAAC;AACH;AAEA,SAAS,qBAAqB,QAA6B;CACzD,IAAI,OAAO,WAAW,UACpB,OAAO;CAGT,OAAO,mBAAmB;AAC5B;AAEA,SAAS,wBAAwB,QAAgC;CAC/D,IAAI,OAAO,WAAW,UACpB,OAAO;CAGT,OAAO,sBAAsB;AAC/B"}
1
+ {"version":3,"file":"server.js","names":["get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender"],"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/control-flow.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport type { RemoteHandler, StandardSchema } from \"./types.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 return 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 value: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n return typeof value === \"function\";\n}\n\n/**\n * Checks whether a value implements the Standard Schema contract.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is a Standard Schema.\n */\nexport function is_standard_schema(value: unknown): value is StandardSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"~standard\" in value\n );\n}\n\n/**\n * Checks whether a value looks like an Effect Schema.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be converted to Standard Schema.\n */\nexport function is_effect_schema(\n value: unknown,\n): value is Schema.Schema<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"ast\" in value &&\n \"make\" in value\n );\n}\n\n/**\n * Converts Effect Schema inputs to Standard Schema for SvelteKit.\n *\n * @since 2.0.0\n * @param value - Schema or handler input.\n * @returns Original value or Standard Schema view of an Effect Schema.\n */\nexport function normalize_validator(value: unknown): unknown {\n if (is_standard_schema(value) || !is_effect_schema(value)) {\n return value;\n }\n\n return Schema.toStandardSchemaV1(value as never);\n}\n","import { run_remote_effect } from \"$/remote/server.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { error as svelte_error, invalid } from \"@sveltejs/kit\";\nimport { 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, EffectRemoteLiveSource } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> =\n | AsyncIterable<A>\n | AsyncIterator<A>\n | Iterable<A>\n | Iterator<A>;\n\ntype LiveHandlerResult<A> =\n | EffectLike<EffectRemoteLiveSource<A>, unknown, unknown>\n | EffectRemoteLiveSource<A>;\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 value: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { next?: unknown }).next === \"function\"\n );\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 to_effect<A, E, R>(\n value: EffectLike<A, E, R>,\n): Effect.Effect<A, E, R> {\n if (is_generator_result<A>(value)) {\n return Effect.gen(() => value) as Effect.Effect<A, E, R>;\n }\n\n return value;\n}\n\n/**\n * Checks whether a value is a live query source SvelteKit can consume.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is an Effect Stream or native iterable source.\n */\nexport function is_live_source<A>(\n value: unknown,\n): value is EffectRemoteLiveSource<A> {\n if (Stream.isStream(value)) {\n return true;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const source = value as {\n readonly next?: unknown;\n readonly [Symbol.asyncIterator]?: unknown;\n readonly [Symbol.iterator]?: unknown;\n };\n\n return (\n typeof source.next === \"function\" ||\n typeof source[Symbol.asyncIterator] === \"function\" ||\n typeof source[Symbol.iterator] === \"function\"\n );\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 value: LiveHandlerResult<A>,\n event: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_live_source_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nfunction to_live_source_effect<A>(\n value: LiveHandlerResult<A>,\n): Effect.Effect<ResolvedLiveSource<A>, unknown, unknown> {\n if (Stream.isStream(value)) {\n return Stream.toAsyncIterableEffect(\n value as Stream.Stream<A, unknown, unknown>,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n }\n\n if (is_native_live_source<A>(value)) {\n return Effect.succeed(value);\n }\n\n if (!Effect.isEffect(value)) {\n return Effect.fail(new InvalidLiveQueryReturnError());\n }\n\n return Effect.flatMap(\n value as Effect.Effect<EffectRemoteLiveSource<A>, unknown, unknown>,\n to_live_source_effect,\n );\n}\n\nfunction is_native_live_source<A>(\n value: unknown,\n): value is ResolvedLiveSource<A> {\n return is_live_source<A>(value) && !Stream.isStream(value);\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 value: EffectLike<A, unknown, unknown>,\n event: RequestEventShape,\n): Promise<A> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<A, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nconst svelte_invalid = (_status: number, body: unknown): never => {\n const issues = typeof body === \"object\" && body !== null &&\n Array.isArray((body as { issues?: unknown }).issues)\n ? (body as { issues: unknown[] }).issues\n : [String(body)];\n\n invalid(...(issues as never[]));\n};\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n svelte_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 path: readonly (string | number)[] = [],\n): FormInvalid<Input> {\n const invalid_at_path = (message: string) =>\n Effect.fail(\n create_form_error([{ message, path: [...path] } satisfies FormIssue]),\n );\n\n return new Proxy(invalid_at_path, {\n get(_target, property) {\n if (typeof property === \"symbol\") {\n return undefined;\n }\n\n return make_invalid_proxy([...path, property]);\n },\n }) 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 EffectLike,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\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 return 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 handler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = is_handler(handler) ? handler(input) : handler;\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\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 handler: RemoteLiveHandler<Input, A, unknown, unknown>,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = typeof handler === \"function\"\n ? handler(input as Input)\n : handler;\n\n return run_live_handler_source(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\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 handler: RemoteFormHandler<Input, A, unknown, unknown>,\n helper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n return async (data: unknown, issue: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n const invalid_proxy = make_invalid_proxy<Input>();\n\n try {\n const result = handler({\n data: data as Input,\n invalid: invalid_proxy,\n issue,\n });\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\nasync function run_inside_remote_effect_handler<A>(\n run: () => Promise<A>,\n): Promise<A> {\n running_remote_effect_handlers += 1;\n\n try {\n return await run();\n } finally {\n running_remote_effect_handlers -= 1;\n }\n}\n","import {\n BatchQueryHandlerMissingError,\n UncheckedCommandHandlerMissingError,\n UncheckedFormHandlerMissingError,\n UncheckedLiveQueryHandlerMissingError,\n UncheckedPrerenderHandlerMissingError,\n UncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport {\n command as native_command,\n form as native_form,\n getRequestEvent as get_native_request_event,\n prerender as native_prerender,\n query as native_query,\n} from \"$app/server\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, type Schema } from \"effect\";\n\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport {\n is_running_remote_effect_handler,\n make_remote_form_wrapper,\n make_remote_live_wrapper,\n make_remote_wrapper,\n} from \"./wrappers.ts\";\nimport type {\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n PrerenderOptions,\n QueryFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaEncodedInput,\n SchemaInput,\n StandardSchema,\n StandardSchemaInput,\n StandardSchemaOutput,\n} from \"./types.ts\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top\n ? FormRemoteInput<S[\"Encoded\"]>\n : never;\n\ntype FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends\n RemoteFormInput ? NormalizeFormEncoded<Input>\n : never;\n\ntype FormStandardSchemaInput<S> = StandardSchemaInput<S> extends RemoteFormInput\n ? StandardSchemaInput<S>\n : RemoteFormInput;\n\ntype FormScalar = string | number | boolean | File;\n\ntype NormalizeFormEncoded<Value> = Value extends FormScalar ? Value\n : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>>\n : Value extends object ? NormalizeFormObject<Value>\n : Value;\n\ntype NormalizeFormObject<Value> = {\n readonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\n ? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\n : NormalizeFormEncoded<Value[Key]>;\n};\n\ntype OptionalFormKeys<Value> = {\n [Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key>\n ? Key\n : never;\n}[keyof Value];\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype EffectRemoteResource<Output, ErrorType = never> =\n | EffectRemoteLiveQueryResource<Output>\n | EffectRemoteQuery<Output, ErrorType>;\n\nfunction to_effect_query<Input, Output, ErrorType = never>(\n native: NativeQueryLike<Input>,\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n const wrapped = ((input: Input) => {\n if (is_current_remote_request()) {\n return (native as (input: Input) => unknown)(input);\n }\n\n const resource = (native as (input: Input) => unknown)(input);\n const effect = Effect.tryPromise({\n try: () => Promise.resolve(resource),\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteQuery<Output, ErrorType>;\n\n attach_query_resource_methods(resource, effect);\n\n return effect;\n }) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\nfunction is_current_remote_request(): boolean {\n if (is_running_remote_effect_handler()) {\n return false;\n }\n\n try {\n const event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n return event.isRemoteRequest === true;\n } catch {\n return false;\n }\n}\n\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\n native: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\n const wrapped = ((input: Input) => {\n const effect = Effect.try({\n try: () => {\n const resource = (native as (input: Input) => unknown)(input);\n\n return make_live_resource<Output>(resource);\n },\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteLiveQuery<Output, ErrorType>;\n\n return effect;\n }) as unknown as EffectRemoteLiveQueryFunction<\n Input,\n Output,\n ErrorType\n >;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\ntype NativeRemoteResource<Output> = {\n readonly current?: Output;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\ntype NativeLiveQueryResource<Output> =\n & NativeRemoteResource<Output>\n & Partial<AsyncIterable<Output>>\n & {\n readonly connected?: boolean;\n readonly done?: boolean;\n readonly reconnect?: () => Promise<void>;\n };\n\nfunction is_query_resource<Output>(\n resource: unknown,\n): resource is NativeQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction is_live_resource<Output>(\n resource: unknown,\n): resource is NativeLiveQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction attach_remote_resource_getters<Output, ErrorType = never>(\n resource: unknown,\n effect: EffectRemoteResource<Output, ErrorType>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n}\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n resource: unknown,\n effect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_remote_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n if (typeof refresh === \"function\") {\n Object.defineProperty(effect, \"refresh\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(refresh.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof set === \"function\") {\n Object.defineProperty(effect, \"set\", {\n configurable: true,\n value: (value: Output) => set.call(resource, value),\n });\n }\n\n if (typeof with_override === \"function\") {\n Object.defineProperty(effect, \"withOverride\", {\n configurable: true,\n value: (update: (current: Output) => Output) =>\n with_override.call(resource, update),\n });\n }\n}\n\nfunction attach_live_resource_methods<Output>(\n resource: unknown,\n effect: EffectRemoteLiveQueryResource<Output>,\n): void {\n const methods = is_live_resource<Output>(resource) ? resource : undefined;\n const reconnect = methods?.reconnect;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const keys = [\n \"connected\",\n \"current\",\n \"done\",\n \"error\",\n \"loading\",\n \"ready\",\n ] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n\n if (typeof reconnect === \"function\") {\n Object.defineProperty(effect, \"reconnect\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(reconnect.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof async_iterator === \"function\") {\n Object.defineProperty(effect, Symbol.asyncIterator, {\n configurable: true,\n value: () => async_iterator.call(resource),\n });\n }\n}\n\nfunction make_live_resource<Output>(\n resource: unknown,\n): EffectRemoteLiveQueryResource<Output> {\n const live_resource = {} as EffectRemoteLiveQueryResource<Output>;\n\n attach_live_resource_methods(resource, live_resource);\n\n return live_resource;\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 validate_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 validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryRoot(\n validate_or_handler: unknown,\n maybe_handler?: unknown,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_query(native_query(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\n ) as ReturnType<typeof native_query>);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new UncheckedQueryHandlerMissingError();\n }\n\n return to_effect_query(native_query(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Query\",\n ) as never,\n ) as ReturnType<typeof native_query>);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query\");\n }\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 validate_or_handler: \"unchecked\",\n maybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryBatch(\n validate_or_handler: unknown,\n maybe_handler?: unknown,\n): unknown {\n try {\n if (!maybe_handler) {\n throw new BatchQueryHandlerMissingError();\n }\n\n return to_effect_query(native_query.batch(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(\n maybe_handler as RemoteHandler,\n \"Query.batch\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.batch\");\n }\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 validate_or_handler: RemoteLiveHandler<void, A, E, R>,\n): EffectRemoteLiveQueryFunction<void, A, E>;\nfunction QueryLive<Input, A, E = never, R = never>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteLiveHandler<Input, A, E, R>,\n): EffectRemoteLiveQueryFunction<Input, A, E>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryLive(\n validate_or_handler: unknown,\n maybe_handler?: unknown,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_live_query(native_query.live(\n normalize_validator(validate_or_handler) as never,\n make_remote_live_wrapper(\n maybe_handler as RemoteLiveHandler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new UncheckedLiveQueryHandlerMissingError();\n }\n\n return to_effect_live_query(native_query.live(\n make_remote_live_wrapper(\n validate_or_handler as RemoteLiveHandler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.live\");\n }\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 batch: QueryBatch,\n live: QueryLive,\n});\n\n/**\n * Factory for a write-oriented remote command function.\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 command function.\n */\nexport function Command<A, E = never, R = never>(\n validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteCommand<void, A, E>;\nexport function Command<Input, A, E = never, R = never>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteCommand<Input, A, E>;\nexport function Command<\n S extends Schema.Schema<unknown>,\n A,\n E = never,\n R = never,\n>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\nexport function Command(\n validate_or_handler: unknown,\n maybe_handler?: unknown,\n): unknown {\n try {\n if (maybe_handler) {\n return native_command(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new UncheckedCommandHandlerMissingError();\n }\n\n return native_command(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Command\",\n ) as never,\n ) as ReturnType<typeof native_command>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Command\");\n }\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 validate_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 validate_or_handler: \"unchecked\",\n maybe_handler: RemoteFormHandler<Input, A, E, R>,\n): EffectRemoteForm<Input, A, E>;\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_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 validate_or_handler: S,\n maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\nexport function Form(\n validate_or_handler: unknown,\n maybe_handler?: unknown,\n): unknown {\n try {\n if (maybe_handler) {\n return native_form(\n normalize_validator(validate_or_handler) as never,\n make_remote_form_wrapper(\n maybe_handler as RemoteFormHandler,\n \"Form\",\n ) as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new UncheckedFormHandlerMissingError();\n }\n\n const inputless_handler: RemoteFormHandler<void, unknown> = (\n { data, invalid, issue },\n ) => {\n if (is_handler(validate_or_handler)) {\n return validate_or_handler({ data, invalid, issue });\n }\n\n return validate_or_handler as EffectLike;\n };\n\n return native_form(\n make_remote_form_wrapper(inputless_handler, \"Form\") as never,\n ) as unknown as ReturnType<typeof native_form>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Form\");\n }\n}\n\n/**\n * Factory for a prerenderable remote function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler_or_options - Handler or prerender options.\n * @param maybe_options - Prerender options used with a validator.\n * @returns A SvelteKit prerender function.\n */\nexport function Prerender<A, E = never, R = never>(\n validate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n maybe_options?: PrerenderOptions,\n): EffectRemoteFunction<void, A, E>;\nexport function Prerender<Input, A, E = never, R = never>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A, E, R>,\n maybe_options?: PrerenderOptions,\n): EffectRemoteFunction<Input, A, E>;\nexport function Prerender<\n S extends Schema.Schema<unknown>,\n A,\n E = never,\n R = never,\n>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n maybe_options?: PrerenderOptions,\n): EffectRemoteFunction<SchemaEncodedInput<S>, A, E>;\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n maybe_options?: PrerenderOptions,\n): EffectRemoteFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n validate_or_handler: unknown,\n maybe_handler_or_options?: unknown,\n maybe_options?: PrerenderOptions,\n): unknown {\n try {\n if (is_handler(maybe_handler_or_options)) {\n return native_prerender(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n maybe_options as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new UncheckedPrerenderHandlerMissingError();\n }\n\n return native_prerender(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Prerender\",\n ) as never,\n maybe_handler_or_options as never,\n ) as ReturnType<typeof native_prerender>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Prerender\");\n }\n}\n","import {\n error as svelte_error,\n redirect as svelte_redirect,\n} from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n ProxyAuthenticationRequired: 407,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n NetworkAuthenticationRequired: 511,\n HttpVersionNotSupported: 505,\n UnprocessableContent: 422,\n UnprocessableEntity: 422,\n InternalServerError: 500,\n FailedDependency: 424,\n PreconditionRequired: 428,\n ServiceUnavailable: 503,\n MisdirectedRequest: 421,\n InsufficientStorage: 507,\n VariantAlsoNegotiates: 506,\n PreconditionFailed: 412,\n MethodNotAllowed: 405,\n GatewayTimeout: 504,\n PaymentRequired: 402,\n UpgradeRequired: 426,\n TooManyRequests: 429,\n LengthRequired: 411,\n NotAcceptable: 406,\n RequestTimeout: 408,\n ContentTooLarge: 413,\n PayloadTooLarge: 413,\n UriTooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n ImATeapot: 418,\n BadRequest: 400,\n Unauthorized: 401,\n Forbidden: 403,\n NotFound: 404,\n Conflict: 409,\n Gone: 410,\n Locked: 423,\n TooEarly: 425,\n NotImplemented: 501,\n BadGateway: 502,\n LoopDetected: 508,\n NotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n MovedPermanently: 301,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n MultipleChoices: 300,\n NotModified: 304,\n SwitchProxy: 306,\n SeeOther: 303,\n UseProxy: 305,\n Found: 302,\n} as const;\n\ntype SvelteErrorBody = Parameters<typeof svelte_error>[1];\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 * 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 * 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 /**\n * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\n (\n status: ErrorStatus,\n body?: SvelteErrorBody,\n ): 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 /**\n * Creates an Effect that throws SvelteKit's redirect control-flow value.\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\n * to SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\n (\n status: RedirectStatus,\n location: string | URL,\n ): 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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = (status, body) => {\n const resolved_status = resolve_error_status(status);\n\n return Effect.sync(() => {\n svelte_error(resolved_status, body);\n });\n};\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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = (status, location) => {\n const resolved_status = resolve_redirect_status(status);\n\n return Effect.sync(() => {\n svelte_redirect(resolved_status, location);\n });\n};\n\nfunction resolve_error_status(status: ErrorStatus): number {\n if (typeof status === \"number\") {\n return status;\n }\n\n return error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n if (typeof status === \"number\") {\n return status;\n }\n\n return redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAgB,aAAa,OAAsC;CACjE,OAAO,UAAU;AACnB;;;;;;;;AASA,SAAgB,WACd,OAC4D;CAC5D,OAAO,OAAO,UAAU;AAC1B;;;;;;;;AASA,SAAgB,mBAAmB,OAAyC;CAC1E,OACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe;AAEnB;;;;;;;;AASA,SAAgB,iBACd,OACiC;CACjC,OACE,OAAO,UAAU,YACjB,UAAU,QACV,SAAS,SACT,UAAU;AAEd;;;;;;;;AASA,SAAgB,oBAAoB,OAAyB;CAC3D,IAAI,mBAAmB,KAAK,KAAK,CAAC,iBAAiB,KAAK,GACtD,OAAO;CAGT,OAAO,OAAO,mBAAmB,KAAc;AACjD;;;;;;;;;;AChDA,SAAgB,oBACd,OACiD;CACjD,OACE,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAA6B,SAAS;AAElD;;;;;;;;AASA,SAAgB,UACd,OACwB;CACxB,IAAI,oBAAuB,KAAK,GAC9B,OAAO,OAAO,UAAU,KAAK;CAG/B,OAAO;AACT;;;;;;;;AASA,SAAgB,eACd,OACoC;CACpC,IAAI,OAAO,SAAS,KAAK,GACvB,OAAO;CAGT,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,OAAO;CAGT,MAAM,SAAS;CAMf,OACE,OAAO,OAAO,SAAS,cACvB,OAAO,OAAO,OAAO,mBAAmB,c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;CACjB,iBAAiB;CACjB,gBAAgB;CAChB,eAAe;CACf,gBAAgB;CAChB,iBAAiB;CACjB,iBAAiB;CACjB,YAAY;CACZ,sBAAsB;CACtB,qBAAqB;CACrB,mBAAmB;CACnB,WAAW;CACX,YAAY;CACZ,cAAc;CACd,WAAW;CACX,UAAU;CACV,UAAU;CACV,MAAM;CACN,QAAQ;CACR,UAAU;CACV,gBAAgB;CAChB,YAAY;CACZ,cAAc;CACd,aAAa;AACf;AAEA,MAAM,wBAAwB;CAC5B,kBAAkB;CAClB,mBAAmB;CACnB,mBAAmB;CACnB,iBAAiB;CACjB,aAAa;CACb,aAAa;CACb,UAAU;CACV,UAAU;CACV,OAAO;AACT;;;;;;;;;;;;;;;;;AAqIA,MAAa,SAA6B,QAAQ,SAAS;CACzD,MAAM,kBAAkB,qBAAqB,MAAM;CAEnD,OAAO,OAAO,WAAW;EACvB,MAAa,iBAAiB,IAAI;CACpC,CAAC;AACH;;;;;;;;;;;;;;;;AAiBA,MAAa,YAAmC,QAAQ,aAAa;CACnE,MAAM,kBAAkB,wBAAwB,MAAM;CAEtD,OAAO,OAAO,WAAW;EACvB,SAAgB,iBAAiB,QAAQ;CAC3C,CAAC;AACH;AAEA,SAAS,qBAAqB,QAA6B;CACzD,IAAI,OAAO,WAAW,UACpB,OAAO;CAGT,OAAO,mBAAmB;AAC5B;AAEA,SAAS,wBAAwB,QAAgC;CAC/D,IAAI,OAAO,WAAW,UACpB,OAAO;CAGT,OAAO,sBAAsB;AAC/B"}
package/.dist/vite.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as rewrite_remote_client_exports, t as effect } from "./chunks/vite-DiAwz7jc.js";
1
+ import { n as rewrite_remote_client_exports, t as effect } from "./chunks/vite-DTeo70MK.js";
2
2
  export { effect, rewrite_remote_client_exports };
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # svelte-effect-runtime
2
-
3
- Core module that houses the Vite plugin to enable effectful execution.
4
-
5
- Visit the [docs](https://ser.barekey.dev) for more information.
1
+ # svelte-effect-runtime
2
+
3
+ Core module that houses the Vite plugin to enable effectful execution.
4
+
5
+ Visit the [docs](https://ser.barekey.dev) for more information.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-effect-runtime",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "Core module that houses the Vite plugin to enable effectful execution.",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-i7LwWCpT.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/failures.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.ts","../../../modules/svelte-effect-runtime/src/remote/client/effect.ts","../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/command.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-data.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-transport.ts","../../../modules/svelte-effect-runtime/src/remote/client/form-enhance.ts","../../../modules/svelte-effect-runtime/src/remote/client/form.ts","../../../modules/svelte-effect-runtime/src/remote/client/query-result.ts","../../../modules/svelte-effect-runtime/src/remote/client/query.ts"],"sourcesContent":["import {\r\n create_remote_http_error,\r\n create_remote_transport_error,\r\n is_serialized_remote_failure_envelope,\r\n} from \"$/remote/shared.ts\";\r\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\r\nimport { RemoteErrorDecodeError } from \"$/errors.ts\";\r\nimport { parse } from \"devalue\";\r\n\r\n/**\r\n * Decodes a raw wire value into a remote failure when it uses the runtime\r\n * failure envelope.\r\n *\r\n * @example\r\n * ```ts\r\n * const failure = decode_remote_error(body);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param raw - Raw value received from the network or SvelteKit error body.\r\n * @param decode - Optional devalue decoder for custom error payloads.\r\n * @returns The decoded failure/value, or a transport error when decoding fails.\r\n */\r\nexport function decode_remote_error<ErrorType = never>(\r\n raw: unknown,\r\n decode?: (encoded: string) => unknown,\r\n): RemoteFailure<ErrorType> | unknown {\r\n const embedded = parse_embedded_remote_failure(raw);\r\n\r\n if (embedded !== raw) {\r\n return decode_remote_error<ErrorType>(embedded, decode);\r\n }\r\n\r\n if (is_serialized_remote_failure_envelope(raw)) {\r\n try {\r\n const decoded = decode ? decode(raw.encoded) : parse(raw.encoded);\r\n\r\n return decoded as RemoteFailure<ErrorType>;\r\n } catch {\r\n return create_remote_transport_error(\r\n new RemoteErrorDecodeError(raw),\r\n raw,\r\n );\r\n }\r\n }\r\n\r\n return raw;\r\n}\r\n\r\nfunction parse_embedded_remote_failure(raw: unknown): unknown {\r\n if (typeof raw === \"string\") {\r\n return parse_json_or_original(raw);\r\n }\r\n\r\n if (typeof raw !== \"object\" || raw === null || !(\"message\" in raw)) {\r\n return raw;\r\n }\r\n\r\n const message = (raw as { message?: unknown }).message;\r\n\r\n if (typeof message !== \"string\") {\r\n return raw;\r\n }\r\n\r\n const parsed = parse_json_or_original(message);\r\n\r\n return parsed === message ? raw : parsed;\r\n}\r\n\r\nfunction parse_json_or_original(value: string): unknown {\r\n try {\r\n return JSON.parse(value);\r\n } catch {\r\n return value;\r\n }\r\n}\r\n\r\n/**\r\n * Checks whether a decoded value is a tagged remote failure.\r\n *\r\n * @example\r\n * ```ts\r\n * if (is_decoded_remote_failure(value)) throw value;\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @returns Whether the value carries a `_tag` discriminator.\r\n */\r\nexport function is_decoded_remote_failure(\r\n value: unknown,\r\n): value is RemoteFailure<never> {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n \"_tag\" in value\r\n );\r\n}\r\n\r\n/**\r\n * Normalizes native thrown values into the runtime's remote failure model.\r\n *\r\n * @example\r\n * ```ts\r\n * const failure = normalize_native_error(error);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param error - Unknown value thrown by a native remote helper.\r\n * @returns A typed remote failure.\r\n */\r\nexport function normalize_native_error<ErrorType = never>(\r\n error: unknown,\r\n): RemoteFailure<ErrorType> {\r\n const body = get_error_body(error);\r\n const decoded = decode_remote_error<ErrorType>(body);\r\n const status = get_error_status(error);\r\n\r\n if (is_decoded_remote_failure(decoded)) {\r\n return decoded;\r\n }\r\n\r\n if (status !== undefined) {\r\n return create_remote_http_error(status, body, error);\r\n }\r\n\r\n return create_remote_transport_error(error);\r\n}\r\n\r\nfunction get_error_status(error: unknown): number | undefined {\r\n if (typeof error !== \"object\" || error === null) {\r\n return undefined;\r\n }\r\n\r\n const status = (error as { status?: unknown }).status;\r\n\r\n return typeof status === \"number\" ? status : undefined;\r\n}\r\n\r\nfunction get_error_body(error: unknown): unknown {\r\n if (typeof error !== \"object\" || error === null) {\r\n return undefined;\r\n }\r\n\r\n if (\"body\" in error) {\r\n return (error as { body?: unknown }).body;\r\n }\r\n\r\n if (\"data\" in error) {\r\n return (error as { data?: unknown }).data;\r\n }\r\n\r\n return undefined;\r\n}\r\n","import { create_remote_http_error } from \"$/remote/shared.ts\";\r\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\r\n\r\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\r\n\r\n/**\r\n * Decodes a failed fetch response into the runtime failure model.\r\n *\r\n * @example\r\n * ```ts\r\n * const failure = await decode_response_failure(response);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param response - Failed fetch response returned by the remote endpoint.\r\n * @returns Remote failure represented by the response.\r\n */\r\nexport async function decode_response_failure<ErrorType = never>(\r\n response: Response,\r\n): Promise<RemoteFailure<ErrorType>> {\r\n const body = await response.json().catch(() => undefined);\r\n const decoded = decode_remote_error<ErrorType>(body);\r\n\r\n if (is_decoded_remote_failure(decoded)) {\r\n return decoded;\r\n }\r\n\r\n return create_remote_http_error(response.status, body);\r\n}\r\n\r\n/**\r\n * Decodes either a raw value or `Response` returned by a native remote helper.\r\n *\r\n * @example\r\n * ```ts\r\n * const output = await decode_response_or_value(result, decode_payload);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param value - Native result value or fetch response.\r\n * @param decode_payload - Function used to decode successful payloads.\r\n * @returns Decoded successful output.\r\n */\r\nexport async function decode_response_or_value<Output, ErrorType = never>(\r\n value: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n): Promise<Output> {\r\n if (value instanceof Response) {\r\n if (!value.ok) {\r\n throw await decode_response_failure<ErrorType>(value);\r\n }\r\n\r\n const data = await decode_success_response_body(value);\r\n\r\n return decode_payload(data) as Output;\r\n }\r\n\r\n return decode_payload(value) as Output;\r\n}\r\n\r\nasync function decode_success_response_body(\r\n response: Response,\r\n): Promise<unknown> {\r\n if (response.status === 204 || response.status === 205) {\r\n return undefined;\r\n }\r\n\r\n const text = await response.text();\r\n\r\n if (text.length === 0) {\r\n return undefined;\r\n }\r\n\r\n return JSON.parse(text);\r\n}\r\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\r\nimport { Effect } from \"effect\";\r\n\r\nimport {\r\n is_decoded_remote_failure,\r\n normalize_native_error,\r\n} from \"./failures.ts\";\r\n\r\n/**\r\n * Wraps a promise-producing remote operation in an Effect with failure mapping.\r\n *\r\n * @example\r\n * ```ts\r\n * const program = make_effect_from_promise(() => native_remote(input));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param run - Promise-producing operation that invokes a native remote helper.\r\n * @returns Effect that maps thrown values into remote failures.\r\n */\r\nexport function make_effect_from_promise<Output, ErrorType = never>(\r\n run: () => Promise<Output>,\r\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\r\n return Effect.tryPromise({\r\n try: run,\r\n catch: (error: unknown) => {\r\n if (is_decoded_remote_failure(error)) {\r\n return error;\r\n }\r\n\r\n return normalize_native_error<ErrorType>(error);\r\n },\r\n }) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\r\n}\r\n","export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\r\nimport type { NativeMethod } from \"./types.ts\";\r\n\r\n/**\r\n * Checks whether a value has a callable method property.\r\n *\r\n * @since 2.0.0\r\n * @param value - Value to inspect.\r\n * @param key - Method key to look up.\r\n * @returns Whether the value has a function at `key`.\r\n */\r\nexport function has_method<K extends PropertyKey>(\r\n value: unknown,\r\n key: K,\r\n): value is Record<K, NativeMethod> {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n typeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\r\n );\r\n}\r\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\r\nimport type { Effect } from \"effect\";\r\n\r\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\r\nimport { decode_response_or_value } from \"./responses.ts\";\r\nimport { make_effect_from_promise } from \"./effect.ts\";\r\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\r\nimport type { NativeMethod, Pending } from \"./types.ts\";\r\n\r\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> =\r\n & ((\r\n input: undefined extends Input ? Input | void : Input,\r\n ) => Effect.Effect<Output, RemoteFailure<ErrorType>>)\r\n & {\r\n readonly pending: number;\r\n };\r\n\r\n/**\r\n * Creates a remote command adapter. The adapter preserves the native\r\n * pending getter and turns each invocation into an Effect.\r\n *\r\n * @since 2.0.0\r\n * @param native_factory - SvelteKit's native command function or a legacy\r\n * response factory used by tests.\r\n * @param decode_payload - Function to decode the response payload.\r\n * @param _base - Deprecated transport base retained for compatibility.\r\n * @param pending - Optional pending counter for legacy response factories.\r\n * @returns A function returning an Effect of the response.\r\n * @internal\r\n */\r\nexport function create_remote_command_adapter<\r\n Input,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n _base = \"\",\r\n pending?: Pending,\r\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\r\n const invoke = has_method(native_factory, \"invoke\")\r\n ? native_factory.invoke\r\n : undefined;\r\n\r\n if (typeof native_factory !== \"function\" && !invoke) {\r\n throw new InvalidCommandFactoryError();\r\n }\r\n\r\n const count = pending ?? { value: 0 };\r\n\r\n const adapter = (input: undefined extends Input ? Input | void : Input) =>\r\n make_effect_from_promise<Output, ErrorType>(async () => {\r\n count.value += 1;\r\n\r\n try {\r\n const result = invoke\r\n ? await invoke(input)\r\n : await (native_factory as NativeMethod)(input);\r\n\r\n return await decode_response_or_value<Output, ErrorType>(\r\n result,\r\n decode_payload,\r\n );\r\n } finally {\r\n count.value -= 1;\r\n }\r\n });\r\n\r\n copy_property_descriptors(native_factory, adapter);\r\n\r\n if (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\r\n Object.defineProperty(adapter, \"pending\", {\r\n get: () => count.value,\r\n });\r\n }\r\n\r\n return adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\r\n}\r\n","/**\r\n * Encodes remote form input into SvelteKit-compatible form data.\r\n *\r\n * @since 2.0.0\r\n * @param input - Input value supplied to the remote form.\r\n * @returns FormData payload for the remote endpoint.\r\n */\r\nexport function to_form_data(input: unknown): FormData {\r\n const form_data = new FormData();\r\n\r\n append_form_value(form_data, \"\", input);\r\n\r\n return form_data;\r\n}\r\n\r\nfunction append_form_value(\r\n form_data: FormData,\r\n path: string,\r\n value: unknown,\r\n): void {\r\n if (value === undefined) {\r\n return;\r\n }\r\n\r\n if (Array.isArray(value)) {\r\n for (const item of value) {\r\n append_form_value(form_data, `${path}[]`, item);\r\n }\r\n\r\n return;\r\n }\r\n\r\n if (value instanceof Blob) {\r\n form_data.append(path, value);\r\n\r\n return;\r\n }\r\n\r\n if (typeof value === \"object\" && value !== null) {\r\n for (const [key, child] of Object.entries(value)) {\r\n const child_path = path.length === 0 ? key : `${path}.${key}`;\r\n\r\n append_form_value(form_data, child_path, child);\r\n }\r\n\r\n return;\r\n }\r\n\r\n if (typeof value === \"number\") {\r\n form_data.append(`n:${path}`, String(value));\r\n\r\n return;\r\n }\r\n\r\n if (typeof value === \"boolean\") {\r\n if (value) {\r\n form_data.append(`b:${path}`, \"on\");\r\n }\r\n\r\n return;\r\n }\r\n\r\n form_data.append(path, value === null ? \"\" : String(value));\r\n}\r\n","import {\r\n create_remote_http_error,\r\n create_remote_transport_error,\r\n create_remote_validation_error,\r\n} from \"$/remote/shared.ts\";\r\nimport {\r\n InvalidRemoteFormResponseError,\r\n RemoteFormEndpointMissingError,\r\n UnsupportedRemoteFormResponseError,\r\n} from \"$/errors.ts\";\r\nimport type { FormIssue } from \"$/remote/shared.ts\";\r\nimport { parse } from \"devalue\";\r\n\r\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\r\nimport { decode_response_failure } from \"./responses.ts\";\r\nimport { to_form_data } from \"./form-data.ts\";\r\nimport type { NativeFormRecord } from \"./types.ts\";\r\n\r\n/**\r\n * Submits a native remote form through the SvelteKit remote endpoint.\r\n *\r\n * @since 2.0.0\r\n * @param form_obj - Native form object being adapted.\r\n * @param input - Form input value.\r\n * @param decode_payload - Function to decode successful payloads.\r\n * @param remote_base - Base URL for the remote endpoint.\r\n * @returns Decoded form output.\r\n */\r\nexport async function submit_remote_form<Output>(\r\n form_obj: NativeFormRecord,\r\n input: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n remote_base: string,\r\n): Promise<Output> {\r\n const action_id = get_remote_action_id(form_obj);\r\n\r\n if (!action_id || remote_base.length === 0) {\r\n throw create_remote_transport_error(\r\n new RemoteFormEndpointMissingError(),\r\n );\r\n }\r\n\r\n const response = await fetch(to_remote_form_url(remote_base, action_id), {\r\n method: \"POST\",\r\n body: to_form_data(input),\r\n });\r\n\r\n if (!response.ok) {\r\n throw await decode_response_failure(response);\r\n }\r\n\r\n const envelope = await response.json();\r\n\r\n return decode_form_response<Output>(envelope, decode_payload);\r\n}\r\n\r\n/**\r\n * Extracts SvelteKit's remote action id from a native form action URL.\r\n *\r\n * @since 2.0.0\r\n * @param form_obj - Native form object being adapted.\r\n * @returns Remote action id when present.\r\n */\r\nexport function get_remote_action_id(\r\n form_obj: NativeFormRecord,\r\n): string | undefined {\r\n const action = form_obj.action;\r\n\r\n if (typeof action !== \"string\") {\r\n return undefined;\r\n }\r\n\r\n const fallback = \"http://localhost/\";\r\n const href = typeof location === \"undefined\" ? fallback : location.href;\r\n const url = new URL(action, href);\r\n\r\n return url.searchParams.get(\"/remote\") ??\r\n url.searchParams.get(\"remote\") ??\r\n undefined;\r\n}\r\n\r\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\r\n const parts = action_id.split(\"/\");\r\n const head = parts.slice(0, 2).join(\"/\");\r\n const tail = parts.slice(2).join(\"/\");\r\n const normalized_base = remote_base.replace(/\\/$/, \"\");\r\n\r\n if (tail.length === 0) {\r\n return `${normalized_base}/${head}`;\r\n }\r\n\r\n return `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\r\n}\r\n\r\nfunction decode_form_response<Output>(\r\n envelope: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n): Output {\r\n if (\r\n typeof envelope !== \"object\" ||\r\n envelope === null ||\r\n !(\"type\" in envelope)\r\n ) {\r\n throw create_remote_transport_error(\r\n new InvalidRemoteFormResponseError(envelope),\r\n envelope,\r\n );\r\n }\r\n\r\n const response = envelope as {\r\n data?: unknown;\r\n type: string;\r\n result?: unknown;\r\n error?: unknown;\r\n status?: number;\r\n };\r\n\r\n if (response.type === \"error\") {\r\n const decoded = decode_remote_error(response.error);\r\n\r\n if (is_decoded_remote_failure(decoded)) {\r\n throw decoded;\r\n }\r\n\r\n throw create_remote_http_error(\r\n response.status ?? 500,\r\n response.error,\r\n );\r\n }\r\n\r\n const result_text = typeof response.result === \"string\"\r\n ? response.result\r\n : typeof response.data === \"string\"\r\n ? response.data\r\n : undefined;\r\n\r\n if (response.type !== \"result\" || result_text === undefined) {\r\n throw create_remote_transport_error(\r\n new UnsupportedRemoteFormResponseError(envelope),\r\n envelope,\r\n );\r\n }\r\n\r\n const parsed = parse(result_text);\r\n const decoded = decode_payload(parsed) as {\r\n issues?: readonly FormIssue[];\r\n result?: Output;\r\n };\r\n\r\n if (decoded.issues && decoded.issues.length > 0) {\r\n throw create_remote_validation_error(decoded.issues, decoded, 400);\r\n }\r\n\r\n return decoded.result as Output;\r\n}\r\n","import { get_dispatcher } from \"$/dispatcher.ts\";\r\nimport { Effect } from \"effect\";\r\n\r\nimport { make_effect_from_promise } from \"./effect.ts\";\r\nimport { has_method } from \"./utils.ts\";\r\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\r\n\r\n/**\r\n * Wraps a remote form enhance callback so Effect return values are run.\r\n *\r\n * @since 2.0.0\r\n * @param callback - Native enhance callback to wrap.\r\n * @returns Wrapped callback or undefined.\r\n */\r\nexport function wrap_enhance_callback<Output, ErrorType = never>(\r\n callback: NativeMethod | undefined,\r\n): NativeMethod | undefined {\r\n if (!callback) {\r\n return undefined;\r\n }\r\n\r\n return (event: unknown) => {\r\n const wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\r\n const result = callback(wrapped_event);\r\n\r\n if (Effect.isEffect(result)) {\r\n return get_dispatcher().run(result);\r\n }\r\n\r\n return result;\r\n };\r\n}\r\n\r\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\r\n if (\r\n typeof event !== \"object\" || event === null || !has_method(event, \"submit\")\r\n ) {\r\n return event;\r\n }\r\n\r\n const original_submit = event.submit;\r\n const { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(\r\n event,\r\n );\r\n\r\n void _submit;\r\n\r\n return Object.defineProperties({}, {\r\n ...descriptors,\r\n submit: {\r\n configurable: true,\r\n enumerable: false,\r\n value: () =>\r\n make_submit_effect<Output, ErrorType>(original_submit, event),\r\n },\r\n });\r\n}\r\n\r\nfunction make_submit_effect<Output, ErrorType>(\r\n original_submit: NativeMethod,\r\n event: unknown,\r\n): EffectRemoteFormSubmit<Output, ErrorType> {\r\n let updates_args: unknown[] | undefined;\r\n\r\n const effect = make_effect_from_promise<Output | undefined, ErrorType>(\r\n async (): Promise<Output | undefined> => {\r\n const result = original_submit();\r\n const value = updates_args && has_method(result, \"updates\")\r\n ? await Promise.resolve(result.updates(...updates_args))\r\n : await Promise.resolve(result);\r\n\r\n if (typeof value === \"boolean\") {\r\n return read_submit_result<Output>(event);\r\n }\r\n\r\n return value as Output;\r\n },\r\n ) as EffectRemoteFormSubmit<Output, ErrorType>;\r\n\r\n Object.defineProperty(effect, \"updates\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: (...args: unknown[]) => {\r\n updates_args ??= args;\r\n\r\n return effect;\r\n },\r\n });\r\n\r\n return effect;\r\n}\r\n\r\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\r\n if (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\r\n return undefined;\r\n }\r\n\r\n return Reflect.get(event, \"result\") as Output | undefined;\r\n}\r\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\r\n\r\nimport { decode_response_or_value } from \"./responses.ts\";\r\nimport { make_effect_from_promise } from \"./effect.ts\";\r\nimport { get_remote_action_id, submit_remote_form } from \"./form-transport.ts\";\r\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\r\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\r\nimport type {\r\n EffectRemoteForm,\r\n NativeFormRecord,\r\n NativeMethod,\r\n} from \"./types.ts\";\r\n\r\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\r\n\r\n/**\r\n * Creates a remote form adapter. The callable preserves SvelteKit's native\r\n * form descriptors while wrapping `validate`, `enhance`, and programmatic\r\n * submission in Effect-returning APIs.\r\n *\r\n * @example\r\n * ```ts\r\n * const createPost = create_remote_form_adapter(nativeForm, (value) => value);\r\n * yield* createPost.validate({ includeUntouched: true });\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param native_factory - SvelteKit's native form object.\r\n * @param decode_payload - Function to decode the response payload.\r\n * @param remote_base - Base URL for SvelteKit's remote endpoint.\r\n * @returns A callable form function whose properties mirror the native form.\r\n * @internal\r\n */\r\nexport function create_remote_form_adapter<\r\n Input extends RemoteFormInput | void,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n remote_base = \"\",\r\n): EffectRemoteForm<Input, Output, ErrorType> {\r\n const form_obj = native_factory as NativeFormRecord;\r\n\r\n const submit_effect = (input?: RemoteInput<Input>) =>\r\n make_effect_from_promise<Output, ErrorType>(async () => {\r\n const can_use_remote_endpoint = remote_base.length > 0 &&\r\n get_remote_action_id(form_obj) !== undefined;\r\n\r\n if (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\r\n const result = await form_obj.submit(input);\r\n\r\n return await decode_response_or_value<Output>(result, decode_payload);\r\n }\r\n\r\n return await submit_remote_form<Output>(\r\n form_obj,\r\n input,\r\n decode_payload,\r\n remote_base,\r\n );\r\n });\r\n\r\n const callable =\r\n ((input?: RemoteInput<Input>) => submit_effect(input)) as EffectRemoteForm<\r\n Input,\r\n Output,\r\n ErrorType\r\n >;\r\n\r\n copy_property_descriptors(\r\n form_obj,\r\n callable,\r\n new Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\r\n );\r\n\r\n Object.defineProperty(callable, \"submit\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: submit_effect,\r\n });\r\n\r\n if (has_method(form_obj, \"validate\")) {\r\n Object.defineProperty(callable, \"validate\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: (options?: Record<string, unknown>) =>\r\n make_effect_from_promise<void, ErrorType>(async () => {\r\n await form_obj.validate(options);\r\n }),\r\n });\r\n }\r\n\r\n if (has_method(form_obj, \"enhance\")) {\r\n Object.defineProperty(callable, \"enhance\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: (callback?: NativeMethod) =>\r\n form_obj.enhance(\r\n wrap_enhance_callback<Output, ErrorType>(callback),\r\n ),\r\n });\r\n }\r\n\r\n if (has_method(form_obj, \"for\")) {\r\n Object.defineProperty(callable, \"for\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: (key: string | number | boolean) =>\r\n create_remote_form_adapter<Input, Output, ErrorType>(\r\n form_obj.for(key),\r\n decode_payload,\r\n remote_base,\r\n ),\r\n });\r\n }\r\n\r\n if (has_method(form_obj, \"preflight\")) {\r\n Object.defineProperty(callable, \"preflight\", {\r\n configurable: true,\r\n enumerable: false,\r\n value: (schema: unknown) => {\r\n form_obj.preflight(schema);\r\n\r\n return callable;\r\n },\r\n });\r\n }\r\n\r\n return callable;\r\n}\r\n","import { decode_response_or_value } from \"./responses.ts\";\r\nimport { has_method } from \"./utils.ts\";\r\n\r\n/**\r\n * Resolves native query results, including SvelteKit run handles.\r\n *\r\n * @example\r\n * ```ts\r\n * const output = await resolve_query_result(result, decode_payload);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param value - Native query result or query run handle.\r\n * @param decode_payload - Function used to decode successful payloads.\r\n * @returns Decoded query output.\r\n */\r\nexport async function resolve_query_result<Output>(\r\n value: unknown,\r\n decode_payload: (value: unknown) => unknown,\r\n): Promise<Output> {\r\n if (has_method(value, \"then\")) {\r\n const result = await Promise.resolve(value);\r\n\r\n return decode_response_or_value(result, decode_payload);\r\n }\r\n\r\n if (has_method(value, \"run\")) {\r\n const result = await value.run();\r\n\r\n return decode_response_or_value(result, decode_payload);\r\n }\r\n\r\n const result = await Promise.resolve(value);\r\n\r\n return decode_response_or_value(result, decode_payload);\r\n}\r\n","import {\r\n InvalidLiveQueryFactoryError,\r\n InvalidQueryFactoryError,\r\n} from \"$/errors.ts\";\r\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\r\nimport { normalize_native_error } from \"./failures.ts\";\r\nimport { resolve_query_result } from \"./query-result.ts\";\r\nimport { make_effect_from_promise } from \"./effect.ts\";\r\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\r\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\r\nimport { Effect } from \"effect\";\r\n\r\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\r\n\r\ntype DecodePayload<Output> = (value: unknown) => Output;\r\n\r\ntype NativeQueryFactory<Input> =\r\n | ((input: RemoteInput<Input>) => unknown)\r\n | {\r\n readonly load: (input: RemoteInput<Input>) => unknown;\r\n };\r\n\r\ntype RemoteResourceEffect<Output, ErrorType = never> =\r\n & Effect.Effect<Output, RemoteFailure<ErrorType>>\r\n & {\r\n readonly current: Output | undefined;\r\n readonly error: unknown;\r\n readonly loading: boolean;\r\n readonly ready: boolean;\r\n };\r\n\r\ntype RemoteResourceLike<Output, ErrorType = never> =\r\n | RemoteResourceEffect<Output, ErrorType>\r\n | RemoteLiveQueryResource<Output>;\r\n\r\ntype RemoteQueryEffect<Output, ErrorType = never> =\r\n & RemoteResourceEffect<Output, ErrorType>\r\n & {\r\n readonly refresh: () => Effect.Effect<void, unknown, never>;\r\n readonly set: (value: Output) => void;\r\n readonly withOverride: (\r\n update: (current: Output) => Output,\r\n ) => unknown;\r\n };\r\n\r\ntype RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<\r\n RemoteLiveQueryResource<Output>,\r\n RemoteFailure<ErrorType>\r\n>;\r\n\r\ntype RemoteLiveQueryResource<Output> =\r\n & {\r\n readonly connected: boolean;\r\n readonly current: Output | undefined;\r\n readonly done: boolean;\r\n readonly error: unknown;\r\n readonly loading: boolean;\r\n readonly ready: boolean;\r\n readonly reconnect: () => Effect.Effect<void, unknown, never>;\r\n }\r\n & AsyncIterable<Output>;\r\n\r\ntype NativeRemoteResource<Output> = {\r\n readonly connected?: boolean;\r\n readonly current?: Output;\r\n readonly done?: boolean;\r\n readonly error?: unknown;\r\n readonly loading?: boolean;\r\n readonly ready?: boolean;\r\n readonly reconnect?: () => Promise<void>;\r\n readonly refresh?: () => Promise<void>;\r\n readonly set?: (value: Output) => void;\r\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\r\n readonly [Symbol.asyncIterator]?: () => AsyncIterator<Output>;\r\n};\r\n\r\n/**\r\n * Creates a remote query adapter. The returned function takes input and\r\n * returns an `Effect` that executes SvelteKit's native query function.\r\n *\r\n * @example\r\n * ```ts\r\n * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);\r\n * const user = yield* getUser({ id: 1 });\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param native_factory - SvelteKit's native query function or a legacy\r\n * response factory used by tests.\r\n * @param decode_payload - Function to decode the response payload.\r\n * @param _base - Deprecated transport base retained for compatibility.\r\n * @returns A function returning an Effect of the response.\r\n * @internal\r\n */\r\nexport function create_remote_query_adapter<\r\n Input,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: NativeQueryFactory<Input>,\r\n decode_payload: DecodePayload<Output>,\r\n _base?: string,\r\n):\r\n & EffectRemoteQueryUpdateBrand\r\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\r\nexport function create_remote_query_adapter<\r\n Input,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: NativeQueryFactory<Input>,\r\n decode_payload: (value: unknown) => unknown,\r\n _base?: string,\r\n):\r\n & EffectRemoteQueryUpdateBrand\r\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\r\nexport function create_remote_query_adapter<\r\n Input,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: unknown,\r\n decode_payload: DecodePayload<Output>,\r\n _base = \"\",\r\n):\r\n & EffectRemoteQueryUpdateBrand\r\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\r\n const load = has_method(native_factory, \"load\")\r\n ? native_factory.load\r\n : undefined;\r\n const query = typeof native_factory === \"function\"\r\n ? native_factory as NativeMethod\r\n : undefined;\r\n\r\n if (!query && !load) {\r\n throw new InvalidQueryFactoryError();\r\n }\r\n\r\n const wrapped = ((input: RemoteInput<Input>) => {\r\n if (!query) {\r\n return make_effect_from_promise<Output, ErrorType>(async () => {\r\n const result = await load?.(input);\r\n\r\n return await resolve_query_result<Output>(result, decode_payload);\r\n }) as RemoteQueryEffect<Output, ErrorType>;\r\n }\r\n\r\n const resource = query(input);\r\n const effect = make_effect_from_promise<Output, ErrorType>(async () =>\r\n await resolve_query_result<Output>(resource, decode_payload)\r\n ) as RemoteQueryEffect<Output, ErrorType>;\r\n\r\n attach_query_resource(resource, effect);\r\n\r\n return effect;\r\n }) as\r\n & EffectRemoteQueryUpdateBrand\r\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\r\n\r\n copy_property_descriptors(native_factory, wrapped);\r\n\r\n return wrapped;\r\n}\r\n\r\n/**\r\n * Creates a remote live query adapter. The returned function takes input and\r\n * returns an `Effect` that resolves to a live query resource with stream state\r\n * and reconnect controls.\r\n *\r\n * @example\r\n * ```ts\r\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\r\n * const time = yield* getTime();\r\n * const current = time.current;\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param native_factory - SvelteKit's native live query function.\r\n * @param _decode_payload - Deprecated payload decoder retained for parity with\r\n * other remote adapters.\r\n * @param _base - Deprecated transport base retained for compatibility.\r\n * @returns A function returning an Effect-backed live query resource.\r\n * @internal\r\n */\r\nexport function create_remote_live_query_adapter<\r\n Input,\r\n Output,\r\n ErrorType = never,\r\n>(\r\n native_factory: unknown,\r\n _decode_payload: (value: unknown) => unknown,\r\n _base = \"\",\r\n):\r\n & EffectRemoteQueryUpdateBrand\r\n & ((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>) {\r\n const query = typeof native_factory === \"function\"\r\n ? native_factory as NativeMethod\r\n : undefined;\r\n\r\n if (!query) {\r\n throw new InvalidLiveQueryFactoryError();\r\n }\r\n\r\n const wrapped = ((input: Input) =>\r\n Effect.try({\r\n try: () => {\r\n const resource = query(input);\r\n\r\n return make_live_query_resource<Output>(resource);\r\n },\r\n catch: normalize_native_error,\r\n }) as RemoteLiveQueryEffect<Output>) as\r\n & EffectRemoteQueryUpdateBrand\r\n & ((\r\n input: RemoteInput<Input>,\r\n ) => RemoteLiveQueryEffect<Output, ErrorType>);\r\n\r\n copy_property_descriptors(native_factory, wrapped);\r\n\r\n return wrapped;\r\n}\r\n\r\nfunction is_resource<Output>(\r\n resource: unknown,\r\n): resource is NativeRemoteResource<Output> {\r\n const resource_type = typeof resource;\r\n\r\n return (\r\n (resource_type === \"object\" && resource !== null) ||\r\n resource_type === \"function\"\r\n );\r\n}\r\n\r\nfunction attach_resource_getters<Output, ErrorType = never>(\r\n resource: unknown,\r\n effect: RemoteResourceLike<Output, ErrorType>,\r\n): void {\r\n const methods = is_resource<Output>(resource) ? resource : undefined;\r\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n for (const key of keys) {\r\n if (!(key in methods)) {\r\n continue;\r\n }\r\n\r\n Object.defineProperty(effect, key, {\r\n configurable: true,\r\n get: () => methods[key],\r\n });\r\n }\r\n}\r\n\r\nfunction attach_query_resource<Output, ErrorType = never>(\r\n resource: unknown,\r\n effect: RemoteQueryEffect<Output, ErrorType>,\r\n): void {\r\n const methods = is_resource<Output>(resource) ? resource : undefined;\r\n const refresh = methods?.refresh;\r\n const set = methods?.set;\r\n const with_override = methods?.withOverride;\r\n\r\n attach_resource_getters(resource, effect);\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n if (typeof refresh === \"function\") {\r\n Object.defineProperty(effect, \"refresh\", {\r\n configurable: true,\r\n value: () =>\r\n make_effect_from_promise(() => Promise.resolve(refresh.call(resource))),\r\n });\r\n }\r\n\r\n if (typeof set === \"function\") {\r\n Object.defineProperty(effect, \"set\", {\r\n configurable: true,\r\n value: (value: Output) => set.call(resource, value),\r\n });\r\n }\r\n\r\n if (typeof with_override === \"function\") {\r\n Object.defineProperty(effect, \"withOverride\", {\r\n configurable: true,\r\n value: (update: (current: Output) => Output) =>\r\n with_override.call(resource, update),\r\n });\r\n }\r\n}\r\n\r\nfunction attach_live_query_resource<Output>(\r\n resource: unknown,\r\n effect: RemoteLiveQueryResource<Output>,\r\n): void {\r\n const methods = is_resource<Output>(resource) ? resource : undefined;\r\n const async_iterator = methods?.[Symbol.asyncIterator];\r\n const reconnect = methods?.reconnect;\r\n const keys = [\"connected\", \"done\"] as const;\r\n\r\n attach_resource_getters(resource, effect);\r\n\r\n if (!methods) {\r\n return;\r\n }\r\n\r\n for (const key of keys) {\r\n if (!(key in methods)) {\r\n continue;\r\n }\r\n\r\n Object.defineProperty(effect, key, {\r\n configurable: true,\r\n get: () => methods[key],\r\n });\r\n }\r\n\r\n if (typeof reconnect === \"function\") {\r\n Object.defineProperty(effect, \"reconnect\", {\r\n configurable: true,\r\n value: () =>\r\n make_effect_from_promise(() =>\r\n Promise.resolve(reconnect.call(resource))\r\n ),\r\n });\r\n }\r\n\r\n if (typeof async_iterator === \"function\") {\r\n Object.defineProperty(effect, Symbol.asyncIterator, {\r\n configurable: true,\r\n value: () => async_iterator.call(resource),\r\n });\r\n }\r\n}\r\n\r\nfunction make_live_query_resource<Output>(\r\n resource: unknown,\r\n): RemoteLiveQueryResource<Output> {\r\n const live_resource = {} as RemoteLiveQueryResource<Output>;\r\n\r\n attach_live_query_resource(resource, live_resource);\r\n\r\n return live_resource;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgB,oBACd,KACA,QACoC;CACpC,MAAM,WAAW,8BAA8B,GAAG;CAElD,IAAI,aAAa,KACf,OAAO,oBAA+B,UAAU,MAAM;CAGxD,IAAI,sCAAsC,GAAG,GAC3C,IAAI;EAGF,OAFgB,SAAS,OAAO,IAAI,OAAO,IAAI,MAAM,IAAI,OAAO;CAGlE,QAAQ;EACN,OAAO,8BACL,IAAI,uBAAuB,GAAG,GAC9B,GACF;CACF;CAGF,OAAO;AACT;AAEA,SAAS,8BAA8B,KAAuB;CAC5D,IAAI,OAAO,QAAQ,UACjB,OAAO,uBAAuB,GAAG;CAGnC,IAAI,OAAO,QAAQ,YAAY,QAAQ,QAAQ,EAAE,aAAa,MAC5D,OAAO;CAGT,MAAM,UAAW,IAA8B;CAE/C,IAAI,OAAO,YAAY,UACrB,OAAO;CAGT,M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1C;CACJ,CAAC;CAGH,IAAI,OAAO,mBAAmB,YAC5B,OAAO,eAAe,QAAQ,OAAO,eAAe;EAClD,cAAc;EACd,aAAa,eAAe,KAAK,QAAQ;CAC3C,CAAC;AAEL;AAEA,SAAS,yBACP,UACiC;CACjC,MAAM,gBAAgB,CAAC;CAEvB,2BAA2B,UAAU,aAAa;CAElD,OAAO;AACT"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatcher-BX6J0tQV.js","names":["get_client_dispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/generated/dispatcher.ts"],"sourcesContent":["import { get_dispatcher as get_client_dispatcher } from \"$/dispatcher.ts\";\r\nimport { get_server_dispatcher } from \"$/server/runtime.ts\";\r\nimport type {\r\n Dispatcher as RuntimeDispatcher,\r\n DispatcherEvent,\r\n MarkupPromiseEvent,\r\n MarkupRunEvent,\r\n MarkupValueEvent,\r\n} from \"$/dispatcher.ts\";\r\n\r\nexport { Code } from \"$/dispatcher.ts\";\r\nexport type {\r\n DispatcherEvent,\r\n MarkupPromiseEvent,\r\n MarkupPromiseOptions,\r\n MarkupRunEvent,\r\n MarkupValueEvent,\r\n} from \"$/dispatcher.ts\";\r\n\r\n/**\r\n * Facade used by transform-generated component code to dispatch runtime\r\n * events through the current client or server dispatcher.\r\n *\r\n * @example\r\n * ```ts\r\n * const value = Dispatcher.emit({\r\n * type: Code.Markup.Value,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fallback: undefined,\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * });\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport class Dispatcher {\r\n /**\r\n * Emits a transform-generated dispatcher event.\r\n *\r\n * @example\r\n * ```ts\r\n * const promise = Dispatcher.emit({\r\n * type: Code.Markup.Promise,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * });\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @param event - Generated event describing the dispatcher operation to run.\r\n * @returns The result produced by the active dispatcher.\r\n */\r\n static emit<A, F>(event: MarkupValueEvent<A, F>): A | F;\r\n static emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\r\n static emit<A>(event: MarkupRunEvent<A>): Promise<A>;\r\n static emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\r\n static emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\r\n return get_dispatcher().emit(event);\r\n }\r\n}\r\n\r\n/**\r\n * Returns the dispatcher appropriate for generated component code.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispatcher = get_dispatcher();\r\n * ```\r\n *\r\n * @since 3.0.1\r\n * @returns The server dispatcher during SSR, otherwise the client dispatcher.\r\n */\r\nexport function get_dispatcher(): RuntimeDispatcher {\r\n if (typeof document === \"undefined\") {\r\n return get_server_dispatcher();\r\n }\r\n\r\n return get_client_dispatcher();\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,aAAb,MAAwB;CAwBtB,OAAO,KAAW,OAAkD;EAClE,OAAO,eAAe,EAAE,KAAK,KAAK;CACpC;AACF;;;;;;;;;;;;AAaA,SAAgB,iBAAoC;CAClD,IAAI,OAAO,aAAa,aACtB,OAAO,sBAAsB;CAG/B,OAAOA,iBAAsB;AAC/B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dispatcher-D9PG87PW.js","names":["#notify_value_cells","#runtime","#emit_markup_value","#emit_markup_promise","#emit_markup_run","#disposed","#next_fiber_id","#fibers","#make_value_cache_key","#value_ids","#subscribe_value_cells","#value_cells","#interrupt_cached_fiber","#clear_pending_value_cell","#should_start_value_fiber","#start_value_fiber","#make_promise_cache_key","#promise_ids","#promise_values","#start_promise_fiber","#is_server_render","#clear_value_cells","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#delete_value_cell"],"sources":["../../../modules/svelte-effect-runtime/src/dispatcher/fibers.ts","../../../modules/svelte-effect-runtime/src/dispatcher/deps.ts","../../../modules/svelte-effect-runtime/src/dispatcher/types.ts","../../../modules/svelte-effect-runtime/src/dispatcher/index.ts"],"sourcesContent":["import { Cause, Effect, Exit, Fiber } from \"effect\";\r\nimport type { Fiber as FiberType } from \"effect/Fiber\";\r\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\r\n\r\n/**\r\n * Callbacks fired when a watched dispatcher fiber completes.\r\n *\r\n * @example\r\n * ```ts\r\n * const callbacks: FiberWatchCallbacks<number> = {\r\n * on_success: (value) => cache.set(key, value),\r\n * };\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport interface FiberWatchCallbacks<A> {\r\n on_complete?: () => void;\r\n on_success?: (value: A) => void;\r\n on_failure?: (error: unknown) => void;\r\n surface_failure?: boolean;\r\n}\r\n\r\n/**\r\n * Interrupts a dispatcher fiber through its managed runtime.\r\n *\r\n * @example\r\n * ```ts\r\n * interrupt_fiber(runtime, fiber);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param runtime - Managed runtime that owns the fiber.\r\n * @param fiber - Fiber to interrupt.\r\n * @returns Nothing.\r\n * @internal\r\n */\r\nexport function interrupt_fiber(\r\n runtime: ManagedRuntimeType<unknown, unknown>,\r\n fiber: FiberType<unknown, unknown>,\r\n): void {\r\n runtime.runFork(\r\n Fiber.interrupt(fiber) as Effect.Effect<unknown, unknown, unknown>,\r\n );\r\n}\r\n\r\n/**\r\n * Watches a dispatcher fiber, runs completion callbacks, and surfaces\r\n * non-interrupt failures on the microtask queue.\r\n *\r\n * @example\r\n * ```ts\r\n * watch_fiber_exit({ runtime, fiber, on_complete: cleanup });\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param options - Runtime, fiber, and callbacks used for the watcher.\r\n * @returns Nothing.\r\n * @internal\r\n */\r\nexport function watch_fiber_exit<A>(\r\n options: {\r\n runtime: ManagedRuntimeType<unknown, unknown>;\r\n fiber: FiberType<unknown, unknown>;\r\n } & FiberWatchCallbacks<A>,\r\n): void {\r\n const {\r\n runtime,\r\n fiber,\r\n on_complete,\r\n on_success,\r\n on_failure,\r\n surface_failure = true,\r\n } = options;\r\n\r\n runtime.runFork(\r\n Effect.flatMap(Fiber.await(fiber), (exit) =>\r\n Effect.sync(() => {\r\n if (Exit.isSuccess(exit)) {\r\n on_success?.(exit.value as A);\r\n on_complete?.();\r\n\r\n return;\r\n }\r\n\r\n if (!Cause.hasInterruptsOnly(exit.cause)) {\r\n const error = Cause.squash(exit.cause);\r\n\r\n on_failure?.(error);\r\n\r\n if (surface_failure) {\r\n queueMicrotask(() => {\r\n throw error;\r\n });\r\n }\r\n }\r\n\r\n on_complete?.();\r\n })),\r\n );\r\n}\r\n","const object_dep_ids = new WeakMap<object, number>();\r\nconst symbol_dep_ids = new Map<symbol, number>();\r\n\r\nlet next_object_dep_id = 0;\r\nlet next_symbol_dep_id = 0;\r\n\r\n/**\r\n * Builds a deterministic cache key from a dependency array.\r\n *\r\n * @example\r\n * ```ts\r\n * const key = hash_deps([user_id, filters]);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param deps - Dependency array to encode for cache lookup.\r\n * @returns A structured string key suitable for Map lookups.\r\n * @internal\r\n */\r\nexport function hash_deps(deps: readonly unknown[]): string {\r\n const parts = deps.map((dep) => {\r\n if (dep === null) {\r\n return \"l:null\";\r\n }\r\n\r\n if (dep === undefined) {\r\n return \"u:undefined\";\r\n }\r\n\r\n const type = typeof dep;\r\n\r\n if (type === \"string\") {\r\n return [\"s\", dep];\r\n }\r\n\r\n if (type === \"number\") {\r\n return `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\r\n }\r\n\r\n if (type === \"bigint\") {\r\n return `b:${dep}`;\r\n }\r\n\r\n if (type === \"boolean\") {\r\n return dep ? \"t:true\" : \"f:false\";\r\n }\r\n\r\n if (type === \"symbol\") {\r\n return hash_symbol_dep(dep as symbol);\r\n }\r\n\r\n return hash_object_dep(dep as object);\r\n });\r\n\r\n return JSON.stringify(parts);\r\n}\r\n\r\nfunction hash_symbol_dep(dep: symbol): string {\r\n let id = symbol_dep_ids.get(dep);\r\n\r\n if (id === undefined) {\r\n next_symbol_dep_id += 1;\r\n id = next_symbol_dep_id;\r\n symbol_dep_ids.set(dep, id);\r\n }\r\n\r\n return `y:${id}`;\r\n}\r\n\r\nfunction hash_object_dep(dep: object): string {\r\n let id = object_dep_ids.get(dep);\r\n\r\n if (id === undefined) {\r\n next_object_dep_id += 1;\r\n id = next_object_dep_id;\r\n object_dep_ids.set(dep, id);\r\n }\r\n\r\n return `o:${id}`;\r\n}\r\n","import type { Effect } from \"effect\";\r\n\r\n/**\r\n * Stable operation codes used by transform-generated dispatcher events.\r\n *\r\n * @example\r\n * ```ts\r\n * const type = Code.Markup.Promise;\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport const Code = {\r\n Markup: {\r\n Promise: \"MarkupPromise\",\r\n Run: \"MarkupRun\",\r\n Value: \"MarkupValue\",\r\n },\r\n} as const;\r\n\r\n/**\r\n * Options for markup promise behavior during server rendering.\r\n *\r\n * @example\r\n * ```ts\r\n * const options: MarkupPromiseOptions = { ssr: \"pending\" };\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport interface MarkupPromiseOptions {\r\n /** Keep the SSR promise pending so Svelte renders an await block fallback. */\r\n ssr?: \"pending\";\r\n}\r\n\r\n/**\r\n * Minimal cleanup handle returned by dispatcher lifecycle hooks.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispose: Dispose = dispatcher.fork(program);\r\n * dispose();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport type Dispose = () => void;\r\n\r\n/**\r\n * Options for a cached dispatcher value block.\r\n *\r\n * @example\r\n * ```ts\r\n * const options: ValueOptions<number> = {\r\n * id: \"count\",\r\n * deps: [],\r\n * fallback: 0,\r\n * factory: () => Effect.succeed(1),\r\n * };\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport interface ValueOptions<A> {\r\n /** Stable cache key for this value block. */\r\n id: string;\r\n /** Reactive dependency array. */\r\n deps: readonly unknown[];\r\n /** Value returned synchronously while the effect is running or during SSR. */\r\n fallback: A;\r\n /** Generator function that yields the effect to run. */\r\n factory: () => Effect.gen.Return<A, unknown, unknown>;\r\n}\r\n\r\n/**\r\n * Options for a cached dispatcher promise block.\r\n *\r\n * @example\r\n * ```ts\r\n * const options: PromiseOptions<number> = {\r\n * id: \"count\",\r\n * deps: [],\r\n * factory: () => Effect.succeed(1),\r\n * };\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport interface PromiseOptions<A> {\r\n /** Stable cache key for this promise block. */\r\n id: string;\r\n /** Reactive dependency array. */\r\n deps: readonly unknown[];\r\n /** Generator function that yields the effect to run. */\r\n factory: () => Effect.gen.Return<A, unknown, unknown>;\r\n}\r\n\r\n/**\r\n * Generated event that reads a markup expression through the cached value\r\n * channel.\r\n *\r\n * @example\r\n * ```ts\r\n * const event: MarkupValueEvent<number, undefined> = {\r\n * type: Code.Markup.Value,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fallback: undefined,\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * };\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport interface MarkupValueEvent<A, F> {\r\n /** Dispatcher code identifying a markup value read. */\r\n type: typeof Code.Markup.Value;\r\n /** Stable identifier generated from the expression's source position. */\r\n id: string;\r\n /** Reactive dependency array captured from free identifiers. */\r\n deps: readonly unknown[];\r\n /** Value returned synchronously while the effect is pending. */\r\n fallback: F;\r\n /** Generator function that yields the effect to run. */\r\n fn: () => Effect.gen.Return<A, unknown, unknown>;\r\n}\r\n\r\n/**\r\n * Generated event that reads a markup expression through the cached promise\r\n * channel.\r\n *\r\n * @example\r\n * ```ts\r\n * const event: MarkupPromiseEvent<number> = {\r\n * type: Code.Markup.Promise,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * };\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport interface MarkupPromiseEvent<A> {\r\n /** Dispatcher code identifying a markup promise read. */\r\n type: typeof Code.Markup.Promise;\r\n /** Stable identifier generated from the expression's source position. */\r\n id: string;\r\n /** Reactive dependency array captured from free identifiers. */\r\n deps: readonly unknown[];\r\n /** Generator function that yields the effect to run. */\r\n fn: () => Effect.gen.Return<A, unknown, unknown>;\r\n /** Value resolved during SSR when a fallback is required. */\r\n ssr_fallback?: A;\r\n /** Optional SSR behavior for await blocks and similar contexts. */\r\n options?: MarkupPromiseOptions;\r\n}\r\n\r\n/**\r\n * Generated event that runs an event-handler Effect.\r\n *\r\n * @example\r\n * ```ts\r\n * const event: MarkupRunEvent<void> = {\r\n * type: Code.Markup.Run,\r\n * fn: function* () {\r\n * yield* Effect.void;\r\n * },\r\n * };\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport interface MarkupRunEvent<A> {\r\n /** Dispatcher code identifying a markup event-handler run. */\r\n type: typeof Code.Markup.Run;\r\n /** Generator function that yields the effect to run. */\r\n fn: () => Effect.gen.Return<A, unknown, unknown>;\r\n}\r\n\r\n/**\r\n * Union of generated dispatcher events.\r\n *\r\n * @example\r\n * ```ts\r\n * const event: DispatcherEvent<number, undefined> = {\r\n * type: Code.Markup.Value,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fallback: undefined,\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * };\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @internal\r\n */\r\nexport type DispatcherEvent<A, F = A> =\r\n | MarkupPromiseEvent<A>\r\n | MarkupRunEvent<A>\r\n | MarkupValueEvent<A, F>;\r\n","import type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\r\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime } from \"effect\";\r\nimport { createSubscriber } from \"svelte/reactivity\";\r\nimport type { Fiber as FiberType } from \"effect/Fiber\";\r\n\r\nimport {\r\n RuntimeAlreadyInitializedError,\r\n DispatcherDisposedError,\r\n} from \"$/errors.ts\";\r\nimport { interrupt_fiber, watch_fiber_exit } from \"./fibers.ts\";\r\nimport { hash_deps } from \"./deps.ts\";\r\nimport { Code } from \"./types.ts\";\r\nimport type {\r\n DispatcherEvent,\r\n Dispose,\r\n MarkupPromiseEvent,\r\n MarkupRunEvent,\r\n MarkupValueEvent,\r\n PromiseOptions,\r\n ValueOptions,\r\n} from \"./types.ts\";\r\n\r\nexport { Code } from \"./types.ts\";\r\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\r\n\r\ntype ValueCell<A> =\r\n | {\r\n readonly status: \"pending\";\r\n readonly fiber: FiberType<unknown, unknown>;\r\n }\r\n | {\r\n readonly status: \"success\";\r\n readonly value: A;\r\n }\r\n | {\r\n readonly status: \"failure\";\r\n readonly error: unknown;\r\n };\r\n\r\n/**\r\n * Unified effect block dispatcher. Manages the fiber lifecycle of every\r\n * effect block and wires results into reactive channels.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispatcher = new Dispatcher();\r\n * const cancel = dispatcher.fork(Effect.log(\"running\"));\r\n * cancel();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport class Dispatcher {\r\n /** The underlying Effect runtime that executes forked programs. */\r\n #runtime: ManagedRuntimeType<unknown, unknown>;\r\n /** Active fibers keyed by cache id or generated fork id. */\r\n #fibers = new Map<string, FiberType<unknown, unknown>>();\r\n /** Reactive value cells keyed by value cache id. */\r\n #value_cells = new Map<string, ValueCell<unknown>>();\r\n /** Notifies subscribed Svelte template effects when value cells change. */\r\n #notify_value_cells = (): void => {};\r\n /** Subscribes the current Svelte tracking scope to value cell changes. */\r\n #subscribe_value_cells = createSubscriber((update) => {\r\n this.#notify_value_cells = update;\r\n\r\n return () => {\r\n if (this.#notify_value_cells !== update) {\r\n return;\r\n }\r\n\r\n this.#notify_value_cells = (): void => {};\r\n };\r\n });\r\n /** Pending promises keyed by promise cache id. */\r\n #promise_values = new Map<string, Promise<unknown>>();\r\n /** Current cache key per value block id. */\r\n #value_ids = new Map<string, string>();\r\n /** Current cache key per promise block id. */\r\n #promise_ids = new Map<string, string>();\r\n /** Whether dispose has been called, blocking new work. */\r\n #disposed = false;\r\n /** Monotonically increasing counter for unnamed fiber keys. */\r\n #next_fiber_id = 0;\r\n\r\n /**\r\n * Creates a dispatcher with an optional layer and installs it as the global\r\n * singleton returned by {@link get_dispatcher}.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispatcher = Dispatcher.make(Db.Live);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param layer - Optional Effect layer to provide to the runtime.\r\n * @returns The newly created dispatcher.\r\n */\r\n static make<R = never>(\r\n layer?: Layer.Layer<R>,\r\n ): Dispatcher {\r\n if (current_dispatcher) {\r\n throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\r\n }\r\n\r\n const runtime = ManagedRuntime.make(\r\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\r\n );\r\n\r\n const dispatcher = new Dispatcher(\r\n runtime as ManagedRuntimeType<unknown, unknown>,\r\n );\r\n current_dispatcher = dispatcher;\r\n\r\n return dispatcher;\r\n }\r\n\r\n /**\r\n * Creates a dispatcher backed by the provided managed runtime.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispatcher = new Dispatcher(runtime);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param runtime - Managed runtime to use, or an empty-layer runtime when\r\n * omitted.\r\n */\r\n constructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\r\n this.#runtime = runtime ??\r\n ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<\r\n unknown,\r\n unknown\r\n >;\r\n }\r\n\r\n /**\r\n * Handles a transform-generated dispatcher event.\r\n *\r\n * @example\r\n * ```ts\r\n * const value = dispatcher.emit({\r\n * type: Code.Markup.Value,\r\n * id: \"Component.svelte:1:2\",\r\n * deps: [],\r\n * fallback: undefined,\r\n * fn: function* () {\r\n * return yield* Effect.succeed(1);\r\n * },\r\n * });\r\n * ```\r\n *\r\n * @since 3.3.0\r\n * @param event - Generated event describing the dispatcher operation to run.\r\n * @returns The operation result for the emitted dispatcher event.\r\n */\r\n emit<A, F>(event: MarkupValueEvent<A, F>): A | F;\r\n emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\r\n emit<A>(event: MarkupRunEvent<A>): Promise<A>;\r\n emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\r\n emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\r\n switch (event.type) {\r\n case Code.Markup.Value:\r\n return this.#emit_markup_value(event);\r\n\r\n case Code.Markup.Promise:\r\n return this.#emit_markup_promise(event);\r\n\r\n case Code.Markup.Run:\r\n return this.#emit_markup_run(event);\r\n }\r\n }\r\n\r\n /**\r\n * Forks an effect as a managed fiber and returns a cleanup function.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispose = dispatcher.fork(Effect.log(\"clicked\"));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param effect - Effect to fork.\r\n * @returns A function that interrupts the fiber.\r\n */\r\n fork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\r\n if (this.#disposed) {\r\n return () => {};\r\n }\r\n\r\n const fiber = this.#runtime.runFork(\r\n effect as Effect.Effect<unknown, unknown, unknown>,\r\n );\r\n const key = `fork:${this.#next_fiber_id}`;\r\n\r\n this.#next_fiber_id += 1;\r\n this.#fibers.set(key, fiber);\r\n watch_fiber_exit({\r\n runtime: this.#runtime,\r\n fiber,\r\n on_complete: () => this.#fibers.delete(key),\r\n });\r\n\r\n let disposed = false;\r\n\r\n return (): void => {\r\n if (disposed) {\r\n return;\r\n }\r\n\r\n disposed = true;\r\n interrupt_fiber(this.#runtime, fiber);\r\n };\r\n }\r\n\r\n /**\r\n * Forks an effect and exposes its result as a cached reactive value.\r\n *\r\n * @example\r\n * ```ts\r\n * const user = dispatcher.value({ id, deps, fallback, factory });\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param options - Value id, dependency array, fallback, and effect factory.\r\n * @returns The cached value if resolved, otherwise the fallback.\r\n */\r\n value<A>(options: ValueOptions<A>): A {\r\n if (this.#disposed) {\r\n return options.fallback;\r\n }\r\n\r\n const cache_key = this.#make_value_cache_key(options.id, options.deps);\r\n const old_key = this.#value_ids.get(options.id);\r\n\r\n this.#subscribe_value_cells();\r\n\r\n const cell = this.#value_cells.get(cache_key);\r\n\r\n if (old_key !== undefined && old_key !== cache_key) {\r\n const old_fiber = this.#interrupt_cached_fiber(old_key);\r\n\r\n this.#clear_pending_value_cell(old_key, old_fiber);\r\n }\r\n\r\n this.#value_ids.set(options.id, cache_key);\r\n\r\n if (this.#should_start_value_fiber(cache_key, cell)) {\r\n this.#start_value_fiber(cache_key, options);\r\n }\r\n\r\n if (cell?.status === \"success\") {\r\n return cell.value as A;\r\n }\r\n\r\n if (cell?.status === \"failure\") {\r\n throw cell.error;\r\n }\r\n\r\n return options.fallback;\r\n }\r\n\r\n /**\r\n * Forks an effect and exposes its completion as a cached promise.\r\n *\r\n * @example\r\n * ```ts\r\n * const promise = dispatcher.promise({ id, deps, factory });\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param options - Promise id, dependency array, and effect factory.\r\n * @returns A promise that resolves with the effect result.\r\n */\r\n promise<A>(options: PromiseOptions<A>): Promise<A> {\r\n if (this.#disposed) {\r\n return Promise.reject(new DispatcherDisposedError());\r\n }\r\n\r\n const cache_key = this.#make_promise_cache_key(options.id, options.deps);\r\n const old_key = this.#promise_ids.get(options.id);\r\n\r\n if (old_key !== undefined && old_key !== cache_key) {\r\n this.#interrupt_cached_fiber(old_key);\r\n this.#promise_values.delete(old_key);\r\n }\r\n\r\n this.#promise_ids.set(options.id, cache_key);\r\n\r\n const existing = this.#promise_values.get(cache_key);\r\n\r\n if (existing) {\r\n return existing as Promise<A>;\r\n }\r\n\r\n const promise = this.#start_promise_fiber(cache_key, options);\r\n\r\n this.#promise_values.set(cache_key, promise);\r\n\r\n return promise;\r\n }\r\n\r\n /**\r\n * Runs an event-handler effect and surfaces failures to Svelte.\r\n *\r\n * @example\r\n * ```ts\r\n * await dispatcher.run(Effect.log(\"submit\"));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param effect - Effect to execute.\r\n * @returns A promise that resolves or rejects when the effect completes.\r\n */\r\n run<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\r\n if (this.#disposed) {\r\n return Promise.reject(new DispatcherDisposedError());\r\n }\r\n\r\n const exit_effect = Effect.exit(effect) as Effect.Effect<\r\n unknown,\r\n unknown,\r\n unknown\r\n >;\r\n\r\n return this.#runtime\r\n .runPromise(exit_effect)\r\n .then((exit: unknown) => {\r\n const result = exit as Exit.Exit<A, E>;\r\n\r\n if (Exit.isSuccess(result)) {\r\n return result.value;\r\n }\r\n\r\n if (Cause.hasInterruptsOnly(result.cause)) {\r\n return undefined as A;\r\n }\r\n\r\n const error = Cause.squash(result.cause);\r\n\r\n queueMicrotask(() => {\r\n throw error;\r\n });\r\n\r\n throw error;\r\n });\r\n }\r\n\r\n #emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\r\n if (this.#is_server_render()) {\r\n return event.fallback;\r\n }\r\n\r\n return this.value<A | F>({\r\n id: event.id,\r\n deps: event.deps,\r\n fallback: event.fallback,\r\n factory: event.fn,\r\n });\r\n }\r\n\r\n #emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\r\n if (this.#is_server_render()) {\r\n if (event.options?.ssr === \"pending\") {\r\n return new Promise<A>(() => {});\r\n }\r\n\r\n if (\"ssr_fallback\" in event) {\r\n return Promise.resolve(event.ssr_fallback as A);\r\n }\r\n }\r\n\r\n return this.promise({\r\n id: event.id,\r\n deps: event.deps,\r\n factory: event.fn,\r\n });\r\n }\r\n\r\n #emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\r\n const effect = Effect.gen(event.fn);\r\n\r\n return this.run(effect);\r\n }\r\n\r\n /**\r\n * Cancels all running fibers and releases cached values.\r\n *\r\n * @example\r\n * ```ts\r\n * dispatcher.dispose();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @returns Nothing.\r\n */\r\n dispose(): void {\r\n this.#disposed = true;\r\n\r\n for (const fiber of this.#fibers.values()) {\r\n interrupt_fiber(this.#runtime, fiber);\r\n }\r\n\r\n this.#fibers.clear();\r\n this.#clear_value_cells();\r\n this.#promise_values.clear();\r\n this.#value_ids.clear();\r\n this.#promise_ids.clear();\r\n\r\n void this.#runtime.dispose().catch((error: unknown) => {\r\n queueMicrotask(() => {\r\n throw error;\r\n });\r\n });\r\n }\r\n\r\n #make_value_cache_key(id: string, deps: readonly unknown[]): string {\r\n return `value:${id}::${hash_deps(deps)}`;\r\n }\r\n\r\n #make_promise_cache_key(id: string, deps: readonly unknown[]): string {\r\n return `promise:${id}::${hash_deps(deps)}`;\r\n }\r\n\r\n #is_server_render(): boolean {\r\n return typeof document === \"undefined\";\r\n }\r\n\r\n #interrupt_cached_fiber(\r\n cache_key: string,\r\n ): FiberType<unknown, unknown> | undefined {\r\n const old_fiber = this.#fibers.get(cache_key);\r\n\r\n if (!old_fiber) {\r\n return undefined;\r\n }\r\n\r\n interrupt_fiber(this.#runtime, old_fiber);\r\n this.#fibers.delete(cache_key);\r\n\r\n return old_fiber;\r\n }\r\n\r\n #should_start_value_fiber(\r\n cache_key: string,\r\n cell: ValueCell<unknown> | undefined,\r\n ): boolean {\r\n return (\r\n !this.#disposed &&\r\n !this.#fibers.has(cache_key) &&\r\n cell === undefined\r\n );\r\n }\r\n\r\n #start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\r\n const program = Effect.gen(function* () {\r\n const result = yield* Effect.gen(options.factory);\r\n\r\n return result;\r\n });\r\n const fiber = this.#runtime.runFork(\r\n program as Effect.Effect<unknown, unknown, unknown>,\r\n );\r\n\r\n this.#fibers.set(cache_key, fiber);\r\n\r\n queueMicrotask(() => {\r\n if (!this.#is_current_fiber(cache_key, fiber)) {\r\n return;\r\n }\r\n\r\n if (this.#value_cells.has(cache_key)) {\r\n return;\r\n }\r\n\r\n this.#set_value_cell(cache_key, {\r\n status: \"pending\",\r\n fiber,\r\n });\r\n });\r\n\r\n watch_fiber_exit({\r\n runtime: this.#runtime,\r\n fiber,\r\n surface_failure: false,\r\n on_complete: () => this.#complete_fiber(cache_key, fiber),\r\n on_success: (value) =>\r\n this.#publish_value_success(\r\n cache_key,\r\n fiber,\r\n value,\r\n ),\r\n on_failure: (error) =>\r\n this.#publish_value_failure(\r\n cache_key,\r\n fiber,\r\n error,\r\n ),\r\n });\r\n }\r\n\r\n #start_promise_fiber<A>(\r\n cache_key: string,\r\n options: PromiseOptions<A>,\r\n ): Promise<A> {\r\n const program = Effect.gen(function* () {\r\n const result = yield* Effect.gen(options.factory);\r\n\r\n return result;\r\n });\r\n const fiber = this.#runtime.runFork(\r\n program as Effect.Effect<unknown, unknown, unknown>,\r\n );\r\n\r\n this.#fibers.set(cache_key, fiber);\r\n\r\n return this.#runtime.runPromise(\r\n Effect.flatMap(Fiber.await(fiber), (exit) =>\r\n Effect.sync(() => {\r\n const is_current = this.#is_current_fiber(cache_key, fiber);\r\n\r\n if (is_current) {\r\n this.#fibers.delete(cache_key);\r\n this.#promise_values.delete(cache_key);\r\n\r\n if (this.#promise_ids.get(options.id) === cache_key) {\r\n this.#promise_ids.delete(options.id);\r\n }\r\n }\r\n\r\n if (Exit.isSuccess(exit)) {\r\n return exit.value as A;\r\n }\r\n\r\n throw Cause.squash(exit.cause);\r\n })),\r\n );\r\n }\r\n\r\n #clear_pending_value_cell(\r\n cache_key: string,\r\n fiber: FiberType<unknown, unknown> | undefined,\r\n ): void {\r\n const cell = this.#value_cells.get(cache_key);\r\n\r\n if (cell?.status !== \"pending\") {\r\n return;\r\n }\r\n\r\n if (fiber !== undefined && cell.fiber !== fiber) {\r\n return;\r\n }\r\n\r\n this.#delete_value_cell(cache_key);\r\n }\r\n\r\n #complete_fiber(\r\n cache_key: string,\r\n fiber: FiberType<unknown, unknown>,\r\n ): void {\r\n if (!this.#is_current_fiber(cache_key, fiber)) {\r\n return;\r\n }\r\n\r\n this.#fibers.delete(cache_key);\r\n }\r\n\r\n #publish_value_success<A>(\r\n cache_key: string,\r\n fiber: FiberType<unknown, unknown>,\r\n value: A,\r\n ): void {\r\n if (!this.#is_current_fiber(cache_key, fiber)) {\r\n return;\r\n }\r\n\r\n this.#set_value_cell(cache_key, {\r\n status: \"success\",\r\n value,\r\n });\r\n }\r\n\r\n #publish_value_failure(\r\n cache_key: string,\r\n fiber: FiberType<unknown, unknown>,\r\n error: unknown,\r\n ): void {\r\n if (!this.#is_current_fiber(cache_key, fiber)) {\r\n return;\r\n }\r\n\r\n this.#set_value_cell(cache_key, {\r\n status: \"failure\",\r\n error,\r\n });\r\n }\r\n\r\n #set_value_cell(\r\n cache_key: string,\r\n cell: ValueCell<unknown>,\r\n ): void {\r\n this.#value_cells.set(cache_key, cell);\r\n this.#notify_value_cells();\r\n }\r\n\r\n #delete_value_cell(cache_key: string): void {\r\n const deleted = this.#value_cells.delete(cache_key);\r\n\r\n if (!deleted) {\r\n return;\r\n }\r\n\r\n this.#notify_value_cells();\r\n }\r\n\r\n #clear_value_cells(): void {\r\n if (this.#value_cells.size === 0) {\r\n return;\r\n }\r\n\r\n this.#value_cells.clear();\r\n this.#notify_value_cells();\r\n }\r\n\r\n #is_current_fiber(\r\n cache_key: string,\r\n fiber: FiberType<unknown, unknown>,\r\n ): boolean {\r\n return !this.#disposed && this.#fibers.get(cache_key) === fiber;\r\n }\r\n}\r\n\r\nlet current_dispatcher: Dispatcher | null = null;\r\n\r\n/**\r\n * Resolves the active dispatcher, creating a default one if necessary.\r\n *\r\n * @example\r\n * ```ts\r\n * const dispatcher = get_dispatcher();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @returns The active dispatcher singleton.\r\n * @internal\r\n */\r\nexport function get_dispatcher(): Dispatcher {\r\n current_dispatcher ??= new Dispatcher();\r\n\r\n return current_dispatcher;\r\n}\r\n\r\n/**\r\n * Resets the internal singleton dispatcher used by source-level tests.\r\n *\r\n * @example\r\n * ```ts\r\n * reset_dispatcher();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @returns Nothing.\r\n * @internal\r\n */\r\nexport function reset_dispatcher(): void {\r\n current_dispatcher?.dispose();\r\n current_dispatcher = null;\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;AAsCA,SAAgB,gBACd,SACA,OACM;CACN,QAAQ,QACN,MAAM,UAAU,KAAK,CACvB;AACF;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACd,SAIM;CACN,MAAM,EACJ,SACA,OACA,aACA,YACA,YACA,kBAAkB,SAChB;CAEJ,QAAQ,QACN,OAAO,QAAQ,MAAM,MAAM,KAAK,IAAI,SAClC,OAAO,WAAW;EAChB,IAAI,KAAK,UAAU,IAAI,GAAG;GACxB,aAAa,KAAK,KAAU;GAC5B,cAAc;GAEd;EACF;EAEA,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK,GAAG;GACxC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;GAErC,aAAa,KAAK;GAElB,IAAI,iBACF,qBAAqB;IACnB,MAAM;GACR,CAAC;EAEL;EAEA,cAAc;CAChB,CAAC,CAAC,CACN;AACF;;;ACrGA,MAAM,iCAAiB,IAAI,QAAwB;AACnD,MAAM,iCAAiB,IAAI,IAAoB;AAE/C,IAAI,qBAAqB;AACzB,IAAI,qBAAqB;;;;;;;;;;;;;;AAezB,SAAgB,UAAU,MAAkC;CAC1D,MAAM,QAAQ,KAAK,KAAK,QAAQ;EAC9B,IAAI,QAAQ,MACV,OAAO;EAGT,IAAI,QAAQ,KAAA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;CAC5B,qBAAqB;AACvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors-Buz9cLGF.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/errors.ts"],"sourcesContent":["/**\n * Base class for runtime-authored errors. The class gives every local failure\n * a stable JavaScript error name while preserving the technical message that\n * reaches Vite, SvelteKit, and test output.\n *\n * @example\n * ```ts\n * throw new RuntimeError(\"Invariant violated.\");\n * ```\n *\n * @since 2.4.0\n * @param message - Technical diagnostic message describing the failed runtime\n * invariant.\n * @returns A runtime-authored Error instance.\n */\nexport class RuntimeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"RuntimeError\";\n }\n}\n\n/**\n * Formats a runtime-owned error message with a stable screaming-case code.\n *\n * @example\n * ```ts\n * throw new Error(make_error_message(\"DISPATCHER_DISPOSED\", \"Dispatcher has been disposed\"));\n * ```\n *\n * @since 2.0.0\n * @param code - Stable screaming-case identifier for the error category.\n * @param message - Human-readable error message without the leading code.\n * @returns The complete error message prefixed with the stable code.\n */\nexport function make_error_message(code: string, message: string): string {\n return `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @example\n * ```ts\n * throw new PreprocessError(\"Component.svelte: invalid transform input.\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param message - Technical diagnostic message for the transform failure.\n * @param filename - Source filename that triggered the transform failure.\n * @returns A preprocessor Error instance with source file context.\n */\nexport class PreprocessError extends RuntimeError {\n /**\n * The source filename that triggered this error.\n *\n * @since 2.0.0\n */\n readonly filename: string;\n\n constructor(message: string, filename: string) {\n super(message);\n this.name = \"PreprocessError\";\n this.filename = filename;\n }\n}\n\n/**\n * Thrown when another Vite plugin claims pre-transform priority before SER can\n * lower component syntax.\n *\n * @example\n * ```ts\n * throw new VitePreTransformPluginConflictError([\"wuchale\"]);\n * ```\n *\n * @since 2.4.0\n * @param plugin_names - Names of Vite plugins that declare pre-transform\n * priority and may parse raw `.svelte` files before SER lowers them.\n * @returns A runtime-authored Error describing the plugin ordering conflict.\n */\nexport class VitePreTransformPluginConflictError extends RuntimeError {\n /**\n * Names of conflicting Vite plugins.\n *\n * @since 2.4.0\n */\n readonly plugin_names: readonly string[];\n\n constructor(plugin_names: readonly string[]) {\n const names = plugin_names.join(\", \");\n\n super(\n [\n `SER detected Vite plugin(s) using pre-transform priority before component syntax lowering: ${names}.`,\n `Plugins with enforce: \"pre\" or transform.order: \"pre\" may parse .svelte files before SER lowers <script effect> and yield* syntax.`,\n `This commonly surfaces as Svelte parser errors such as \"The keyword 'yield' is reserved\".`,\n \"\",\n `Remove the pre-transform priority from the conflicting plugin or run a version that uses normal Vite transform ordering.`,\n ].join(\"\\n\"),\n );\n this.name = \"VitePreTransformPluginConflictError\";\n this.plugin_names = plugin_names;\n }\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @example\n * ```ts\n * throw new AwaitInEffectWorkError(\"Component.svelte\", \"const value = await load();\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the unsupported statement.\n * @param statement_text - Full source text for the statement containing\n * mixed async work.\n * @returns A preprocessor Error instance with statement context.\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n /**\n * The full text of the problematic statement containing mixed async work.\n *\n * @since 2.0.0\n */\n readonly statement_text: string;\n\n constructor(filename: string, statement_text: string) {\n super(\n [\n make_error_message(\n \"AWAIT_IN_EFFECT_WORK\",\n `${filename}: await cannot be mixed with yield* in Effect work.`,\n ),\n `Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n \"\",\n `Problematic statement:`,\n statement_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AwaitInEffectWorkError\";\n this.statement_text = statement_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInSyncRuneError(\"$derived\", \"$derived(yield* load())\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param rune_name - Name of the Svelte rune containing the unsupported async\n * Effect work.\n * @param expression_text - Full source text for the rune expression.\n * @param filename - Source filename containing the unsupported rune.\n * @returns A preprocessor Error instance with rune source context.\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n /**\n * The name of the rune that contained async Effect work.\n *\n * @since 2.0.0\n */\n readonly rune_name: string;\n\n /**\n * The full text of the expression that triggered the error.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(rune_name: string, expression_text: string, filename: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_SYNC_RUNE\",\n `${filename}: yield* cannot be used inside ${rune_name}().`,\n ),\n `${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInSyncRuneError\";\n this.rune_name = rune_name;\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the invalid event handler.\n * @param expression_text - Event handler expression that contains the nested\n * unsupported async Effect work.\n * @returns A preprocessor Error instance with event expression context.\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler body.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n `${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n ),\n `Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n \"\",\n `Run the remote Effect directly:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Recover from remote failures by composing the Effect value:`,\n ` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\"Component.svelte\", \"() => yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n * @returns A preprocessor Error instance with event callback context.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler callback.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n `${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n ),\n `SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n \"\",\n `Use this form:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Instead of this form:`,\n ` onclick={() => yield* UpvotePost(id)}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"YieldStarInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n * @param filename - Source filename containing the unsupported markup.\n * @param expression_text - The unsupported markup expression text.\n * @returns A preprocessor Error instance with markup source context.\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n /**\n * The unsupported markup expression text.\n *\n * @since 2.4.2\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n `${filename}: yield* cannot be used in this markup position.`,\n ),\n `Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"UnsupportedMarkupEffectPositionError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when the request-scoped SvelteKit event context is read outside a\n * remote handler.\n *\n * @example\n * ```ts\n * throw new RequestEventUnavailableError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing missing request context.\n */\nexport class RequestEventUnavailableError extends RuntimeError {\n constructor() {\n super(\n \"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n );\n this.name = \"RequestEventUnavailableError\";\n }\n}\n\n/**\n * Thrown when an unchecked Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Query overload usage.\n */\nexport class UncheckedQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n );\n this.name = \"UncheckedQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when a batch Query declaration omits the batch handler.\n *\n * @example\n * ```ts\n * throw new BatchQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid batch Query overload usage.\n */\nexport class BatchQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n );\n this.name = \"BatchQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked live Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedLiveQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid live Query overload usage.\n */\nexport class UncheckedLiveQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n );\n this.name = \"UncheckedLiveQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Command declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedCommandHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Command overload usage.\n */\nexport class UncheckedCommandHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n );\n this.name = \"UncheckedCommandHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Form declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedFormHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Form overload usage.\n */\nexport class UncheckedFormHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n );\n this.name = \"UncheckedFormHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Prerender declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedPrerenderHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Prerender overload usage.\n */\nexport class UncheckedPrerenderHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n );\n this.name = \"UncheckedPrerenderHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when a live query handler resolves to a value that cannot be streamed.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryReturnError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the expected live query return protocol.\n */\nexport class InvalidLiveQueryReturnError extends RuntimeError {\n constructor() {\n super(\n \"Query.live handler must return an Effect Stream, Iterable, or AsyncIterable; resolved values must expose a streaming protocol that SER can bridge to SvelteKit.\",\n );\n this.name = \"InvalidLiveQueryReturnError\";\n }\n}\n\n/**\n * Thrown when a dispatcher operation is requested after disposal.\n *\n * @example\n * ```ts\n * throw new DispatcherDisposedError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid dispatcher lifecycle transition.\n */\nexport class DispatcherDisposedError extends RuntimeError {\n constructor() {\n super(\n \"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n );\n this.name = \"DispatcherDisposedError\";\n }\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n * @returns An Error describing the invalid runtime lifecycle transition.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n constructor(runtime_name: string) {\n super(\n make_error_message(\n \"RUNTIME_ALREADY_INITIALIZED\",\n `${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n ),\n );\n this.name = \"RuntimeAlreadyInitializedError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid query adapter input.\n */\nexport class InvalidQueryFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n );\n this.name = \"InvalidQueryFactoryError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote live query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid live query adapter input.\n */\nexport class InvalidLiveQueryFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n );\n this.name = \"InvalidLiveQueryFactoryError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote command export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidCommandFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid command adapter input.\n */\nexport class InvalidCommandFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n );\n this.name = \"InvalidCommandFactoryError\";\n }\n}\n\n/**\n * Thrown when the client-side form adapter cannot derive a remote endpoint.\n *\n * @example\n * ```ts\n * throw new RemoteFormEndpointMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing missing form transport metadata.\n */\nexport class RemoteFormEndpointMissingError extends RuntimeError {\n constructor() {\n super(\n \"Form has no submit method or remote endpoint; the adapted SvelteKit form object does not expose an action id and no remote base URL was generated.\",\n );\n this.name = \"RemoteFormEndpointMissingError\";\n }\n}\n\n/**\n * Thrown when a remote form response envelope is not an object with a response\n * type.\n *\n * @example\n * ```ts\n * throw new InvalidRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n * @returns An Error describing malformed form response data.\n */\nexport class InvalidRemoteFormResponseError extends RuntimeError {\n /**\n * Raw response envelope returned by the remote form endpoint.\n *\n * @since 2.4.0\n */\n readonly envelope: unknown;\n\n constructor(envelope?: unknown) {\n super(\n \"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n );\n this.name = \"InvalidRemoteFormResponseError\";\n this.envelope = envelope;\n }\n}\n\n/**\n * Thrown when a remote form response has a well-formed envelope but an\n * unsupported response type or payload slot.\n *\n * @example\n * ```ts\n * throw new UnsupportedRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n * @returns An Error describing unsupported form response data.\n */\nexport class UnsupportedRemoteFormResponseError extends RuntimeError {\n /**\n * Raw response envelope returned by the remote form endpoint.\n *\n * @since 2.4.0\n */\n readonly envelope: unknown;\n\n constructor(envelope?: unknown) {\n super(\n \"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n );\n this.name = \"UnsupportedRemoteFormResponseError\";\n this.envelope = envelope;\n }\n}\n\n/**\n * Thrown when a serialized remote failure envelope cannot be decoded.\n *\n * @example\n * ```ts\n * throw new RemoteErrorDecodeError(raw);\n * ```\n *\n * @since 2.4.0\n * @param raw - Raw serialized remote failure payload that failed decoding.\n * @returns An Error describing a malformed remote failure payload.\n */\nexport class RemoteErrorDecodeError extends RuntimeError {\n /**\n * Raw serialized remote failure payload that failed decoding.\n *\n * @since 2.4.0\n */\n readonly raw: unknown;\n\n constructor(raw?: unknown) {\n super(\n \"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n );\n this.name = \"RemoteErrorDecodeError\";\n this.raw = raw;\n }\n}\n\n/**\n * Thrown when a root server-only helper is imported without Vite rewriting.\n *\n * @example\n * ```ts\n * throw new ServerOnlyImportError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the server-only root export that was invoked.\n * @returns An Error describing a missing server rewrite.\n */\nexport class ServerOnlyImportError extends RuntimeError {\n /**\n * Name of the server-only root export that was invoked.\n *\n * @since 2.4.0\n */\n readonly export_name: string;\n\n constructor(export_name: string) {\n super(\n `${export_name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to svelte-effect-runtime/server before execution.`,\n );\n this.name = \"ServerOnlyImportError\";\n this.export_name = export_name;\n }\n}\n\n/**\n * Thrown when the publish-time `$app/server` shim executes outside SvelteKit.\n *\n * @example\n * ```ts\n * throw new SvelteKitServerExportUnavailableError(\"query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the `$app/server` export that was invoked.\n * @returns An Error describing an unavailable SvelteKit virtual module export.\n */\nexport class SvelteKitServerExportUnavailableError extends RuntimeError {\n /**\n * Name of the `$app/server` export that was invoked.\n *\n * @since 2.4.0\n */\n readonly export_name: string;\n\n constructor(export_name: string) {\n super(\n `SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n );\n this.name = \"SvelteKitServerExportUnavailableError\";\n this.export_name = export_name;\n }\n}\n\n/**\n * Thrown when a SvelteKit remote helper reports that it was called outside the\n * route-scoped remote module context.\n *\n * @example\n * ```ts\n * throw new RemoteHelperContextError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param helper_name - SER helper name that triggered the context failure.\n * @returns An Error describing the required `.remote.ts` placement.\n */\nexport class RemoteHelperContextError extends RuntimeError {\n /**\n * SER helper name that triggered the context failure.\n *\n * @since 2.4.0\n */\n readonly helper_name: string;\n\n constructor(helper_name: string) {\n super(\n make_error_message(\n \"REMOTE_HELPER_CONTEXT\",\n `${helper_name} was called outside a .remote.ts file. Ensure the file is named \\`*.remote.ts\\` and is located in a route directory so SvelteKit can bind remote helper context.`,\n ),\n );\n this.name = \"RemoteHelperContextError\";\n this.helper_name = helper_name;\n }\n}\n\n/**\n * Thrown when a SvelteKit remote helper normalizes a non-Error thrown value.\n *\n * @example\n * ```ts\n * throw new RemoteHelperError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value thrown while creating a remote helper.\n * @returns An Error preserving the remote helper failure value.\n */\nexport class RemoteHelperError extends RuntimeError {\n /**\n * Non-Error value that was normalized.\n *\n * @since 2.4.0\n */\n readonly value: unknown;\n\n constructor(value: unknown) {\n super(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n this.name = \"RemoteHelperError\";\n this.value = value;\n }\n}\n\n/**\n * Thrown when a non-Error value must be normalized into an Error instance.\n *\n * @example\n * ```ts\n * throw new UnknownRuntimeError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value that needs Error normalization.\n * @returns An Error preserving the string representation of an unknown value.\n */\nexport class UnknownRuntimeError extends RuntimeError {\n /**\n * Non-Error value that was normalized.\n *\n * @since 2.4.0\n */\n readonly value: unknown;\n\n constructor(value: unknown) {\n super(String(value));\n this.name = \"UnknownRuntimeError\";\n this.value = value;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAa,eAAb,cAAkC,MAAM;CACtC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;AAeA,SAAgB,mBAAmB,MAAc,SAAyB;CACxE,OAAO,IAAI,KAAK,KAAK;AACvB;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMhD;CAEA,YAAY,SAAiB,UAAkB;EAC7C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;;;;;;;;;;;;;;;AAgBA,IAAa,sCAAb,cAAyD,aAAa;;;;;;CAMpE;CAEA,YAAY,cAAiC;EAC3C,MAAM,QAAQ,aAAa,KAAK,IAAI;EAEpC,MACE;GACE,8FAA8F,MAAM;GACpG;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI,CACb;EACA,KAAK,OAAO;EACZ,KAAK,eAAe;CACtB;AACF;;;;;;;;;;;;;;;;AAiBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM1D;CAEA,YAAY,UAAkB,gBAAwB;EACpD,MACE;GACE,mBACE,wBACA,GAAG,SAAS,oDACd;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI,GACX,QACF;EACA,KAAK,OAAO;EACZ,KAAK,iBAAiB;CACxB;AACF;;;;;;;;;;;;;;;;;AAkBA,IAAa,6BAAb,cAAgD,gBAAgB;;;;;;CAM9D;;;;;;CAOA;CAEA,YAAY,WAAmB,iB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