svelte-effect-runtime 3.4.3 → 3.4.5

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.
@@ -1 +0,0 @@
1
- {"version":3,"file":"client-7MXXouwb.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 {\n create_remote_http_error,\n create_remote_transport_error,\n is_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { RemoteErrorDecodeError } from \"$/errors.ts\";\nimport { parse } from \"devalue\";\n\n/**\n * Decodes a raw wire value into a remote failure when it uses the runtime\n * failure envelope.\n *\n * @example\n * ```ts\n * const failure = decode_remote_error(body);\n * ```\n *\n * @since 2.0.0\n * @param raw - Raw value received from the network or SvelteKit error body.\n * @param decode - Optional devalue decoder for custom error payloads.\n * @returns The decoded failure/value, or a transport error when decoding fails.\n */\nexport function decode_remote_error<ErrorType = never>(\n raw: unknown,\n decode?: (encoded: string) => unknown,\n): RemoteFailure<ErrorType> | unknown {\n const embedded = parse_embedded_remote_failure(raw);\n\n if (embedded !== raw) {\n return decode_remote_error<ErrorType>(embedded, decode);\n }\n\n if (is_serialized_remote_failure_envelope(raw)) {\n try {\n const decoded = decode ? decode(raw.encoded) : parse(raw.encoded);\n\n return decoded as RemoteFailure<ErrorType>;\n } catch {\n return create_remote_transport_error(\n new RemoteErrorDecodeError(raw),\n raw,\n );\n }\n }\n\n return raw;\n}\n\nfunction parse_embedded_remote_failure(raw: unknown): unknown {\n if (typeof raw === \"string\") {\n return parse_json_or_original(raw);\n }\n\n if (typeof raw !== \"object\" || raw === null || !(\"message\" in raw)) {\n return raw;\n }\n\n const message = (raw as { message?: unknown }).message;\n\n if (typeof message !== \"string\") {\n return raw;\n }\n\n const parsed = parse_json_or_original(message);\n\n return parsed === message ? raw : parsed;\n}\n\nfunction parse_json_or_original(value: string): unknown {\n try {\n return JSON.parse(value);\n } catch {\n return value;\n }\n}\n\n/**\n * Checks whether a decoded value is a tagged remote failure.\n *\n * @example\n * ```ts\n * if (is_decoded_remote_failure(value)) throw value;\n * ```\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value carries a `_tag` discriminator.\n */\nexport function is_decoded_remote_failure(\n value: unknown,\n): value is RemoteFailure<never> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"_tag\" in value\n );\n}\n\n/**\n * Normalizes native thrown values into the runtime's remote failure model.\n *\n * @example\n * ```ts\n * const failure = normalize_native_error(error);\n * ```\n *\n * @since 2.0.0\n * @param error - Unknown value thrown by a native remote helper.\n * @returns A typed remote failure.\n */\nexport function normalize_native_error<ErrorType = never>(\n error: unknown,\n): RemoteFailure<ErrorType> {\n const body = get_error_body(error);\n const decoded = decode_remote_error<ErrorType>(body);\n const status = get_error_status(error);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n if (status !== undefined) {\n return create_remote_http_error(status, body, error);\n }\n\n return create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n const status = (error as { status?: unknown }).status;\n\n return typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n if (typeof error !== \"object\" || error === null) {\n return undefined;\n }\n\n if (\"body\" in error) {\n return (error as { body?: unknown }).body;\n }\n\n if (\"data\" in error) {\n return (error as { data?: unknown }).data;\n }\n\n return undefined;\n}\n","import { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\n\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\n\n/**\n * Decodes a failed fetch response into the runtime failure model.\n *\n * @example\n * ```ts\n * const failure = await decode_response_failure(response);\n * ```\n *\n * @since 2.0.0\n * @param response - Failed fetch response returned by the remote endpoint.\n * @returns Remote failure represented by the response.\n */\nexport async function decode_response_failure<ErrorType = never>(\n response: Response,\n): Promise<RemoteFailure<ErrorType>> {\n const body = await response.json().catch(() => undefined);\n const decoded = decode_remote_error<ErrorType>(body);\n\n if (is_decoded_remote_failure(decoded)) {\n return decoded;\n }\n\n return create_remote_http_error(response.status, body);\n}\n\n/**\n * Decodes either a raw value or `Response` returned by a native remote helper.\n *\n * @example\n * ```ts\n * const output = await decode_response_or_value(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native result value or fetch response.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded successful output.\n */\nexport async function decode_response_or_value<Output, ErrorType = never>(\n value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (value instanceof Response) {\n if (!value.ok) {\n throw await decode_response_failure<ErrorType>(value);\n }\n\n const data = await decode_success_response_body(value);\n\n return decode_payload(data) as Output;\n }\n\n return decode_payload(value) as Output;\n}\n\nasync function decode_success_response_body(\n response: Response,\n): Promise<unknown> {\n if (response.status === 204 || response.status === 205) {\n return undefined;\n }\n\n const text = await response.text();\n\n if (text.length === 0) {\n return undefined;\n }\n\n return JSON.parse(text);\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nimport {\n is_decoded_remote_failure,\n normalize_native_error,\n} from \"./failures.ts\";\n\n/**\n * Wraps a promise-producing remote operation in an Effect with failure mapping.\n *\n * @example\n * ```ts\n * const program = make_effect_from_promise(() => native_remote(input));\n * ```\n *\n * @since 2.0.0\n * @param run - Promise-producing operation that invokes a native remote helper.\n * @returns Effect that maps thrown values into remote failures.\n */\nexport function make_effect_from_promise<Output, ErrorType = never>(\n run: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\n return Effect.tryPromise({\n try: run,\n catch: (error: unknown) => {\n if (is_decoded_remote_failure(error)) {\n return error;\n }\n\n return normalize_native_error<ErrorType>(error);\n },\n }) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\n}\n","export { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport type { NativeMethod } from \"./types.ts\";\n\n/**\n * Checks whether a value has a callable method property.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @param key - Method key to look up.\n * @returns Whether the value has a function at `key`.\n */\nexport function has_method<K extends PropertyKey>(\n value: unknown,\n key: K,\n): value is Record<K, NativeMethod> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n );\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { Effect } from \"effect\";\n\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> =\n & ((\n input: undefined extends Input ? Input | void : Input,\n ) => Effect.Effect<Output, RemoteFailure<ErrorType>>)\n & {\n readonly pending: number;\n };\n\n/**\n * Creates a remote command adapter. The adapter preserves the native\n * pending getter and turns each invocation into an Effect.\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native command function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @param pending - Optional pending counter for legacy response factories.\n * @returns A function returning an Effect of the response.\n * @internal\n */\nexport function create_remote_command_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n _base = \"\",\n pending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n const invoke = has_method(native_factory, \"invoke\")\n ? native_factory.invoke\n : undefined;\n\n if (typeof native_factory !== \"function\" && !invoke) {\n throw new InvalidCommandFactoryError();\n }\n\n const count = pending ?? { value: 0 };\n\n const adapter = (input: undefined extends Input ? Input | void : Input) =>\n make_effect_from_promise<Output, ErrorType>(async () => {\n count.value += 1;\n\n try {\n const result = invoke\n ? await invoke(input)\n : await (native_factory as NativeMethod)(input);\n\n return await decode_response_or_value<Output, ErrorType>(\n result,\n decode_payload,\n );\n } finally {\n count.value -= 1;\n }\n });\n\n copy_property_descriptors(native_factory, adapter);\n\n if (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n Object.defineProperty(adapter, \"pending\", {\n get: () => count.value,\n });\n }\n\n return adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\n}\n","/**\n * Encodes remote form input into SvelteKit-compatible form data.\n *\n * @since 2.0.0\n * @param input - Input value supplied to the remote form.\n * @returns FormData payload for the remote endpoint.\n */\nexport function to_form_data(input: unknown): FormData {\n const form_data = new FormData();\n\n append_form_value(form_data, \"\", input);\n\n return form_data;\n}\n\nfunction append_form_value(\n form_data: FormData,\n path: string,\n value: unknown,\n): void {\n if (value === undefined) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n append_form_value(form_data, `${path}[]`, item);\n }\n\n return;\n }\n\n if (value instanceof Blob) {\n form_data.append(path, value);\n\n return;\n }\n\n if (typeof value === \"object\" && value !== null) {\n for (const [key, child] of Object.entries(value)) {\n const child_path = path.length === 0 ? key : `${path}.${key}`;\n\n append_form_value(form_data, child_path, child);\n }\n\n return;\n }\n\n if (typeof value === \"number\") {\n form_data.append(`n:${path}`, String(value));\n\n return;\n }\n\n if (typeof value === \"boolean\") {\n if (value) {\n form_data.append(`b:${path}`, \"on\");\n }\n\n return;\n }\n\n form_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n create_remote_http_error,\n create_remote_transport_error,\n create_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport {\n InvalidRemoteFormResponseError,\n RemoteFormEndpointMissingError,\n UnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { parse } from \"devalue\";\n\nimport { decode_remote_error, is_decoded_remote_failure } from \"./failures.ts\";\nimport { decode_response_failure } from \"./responses.ts\";\nimport { to_form_data } from \"./form-data.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\n\n/**\n * Submits a native remote form through the SvelteKit remote endpoint.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @param input - Form input value.\n * @param decode_payload - Function to decode successful payloads.\n * @param remote_base - Base URL for the remote endpoint.\n * @returns Decoded form output.\n */\nexport async function submit_remote_form<Output>(\n form_obj: NativeFormRecord,\n input: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base: string,\n): Promise<Output> {\n const action_id = get_remote_action_id(form_obj);\n\n if (!action_id || remote_base.length === 0) {\n throw create_remote_transport_error(\n new RemoteFormEndpointMissingError(),\n );\n }\n\n const response = await fetch(to_remote_form_url(remote_base, action_id), {\n method: \"POST\",\n body: to_form_data(input),\n });\n\n if (!response.ok) {\n throw await decode_response_failure(response);\n }\n\n const envelope = await response.json();\n\n return decode_form_response<Output>(envelope, decode_payload);\n}\n\n/**\n * Extracts SvelteKit's remote action id from a native form action URL.\n *\n * @since 2.0.0\n * @param form_obj - Native form object being adapted.\n * @returns Remote action id when present.\n */\nexport function get_remote_action_id(\n form_obj: NativeFormRecord,\n): string | undefined {\n const action = form_obj.action;\n\n if (typeof action !== \"string\") {\n return undefined;\n }\n\n const fallback = \"http://localhost/\";\n const href = typeof location === \"undefined\" ? fallback : location.href;\n const url = new URL(action, href);\n\n return url.searchParams.get(\"/remote\") ??\n url.searchParams.get(\"remote\") ??\n undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n const parts = action_id.split(\"/\");\n const head = parts.slice(0, 2).join(\"/\");\n const tail = parts.slice(2).join(\"/\");\n const normalized_base = remote_base.replace(/\\/$/, \"\");\n\n if (tail.length === 0) {\n return `${normalized_base}/${head}`;\n }\n\n return `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction decode_form_response<Output>(\n envelope: unknown,\n decode_payload: (value: unknown) => unknown,\n): Output {\n if (\n typeof envelope !== \"object\" ||\n envelope === null ||\n !(\"type\" in envelope)\n ) {\n throw create_remote_transport_error(\n new InvalidRemoteFormResponseError(envelope),\n envelope,\n );\n }\n\n const response = envelope as {\n data?: unknown;\n type: string;\n result?: unknown;\n error?: unknown;\n status?: number;\n };\n\n if (response.type === \"error\") {\n const decoded = decode_remote_error(response.error);\n\n if (is_decoded_remote_failure(decoded)) {\n throw decoded;\n }\n\n throw create_remote_http_error(\n response.status ?? 500,\n response.error,\n );\n }\n\n const result_text = typeof response.result === \"string\"\n ? response.result\n : typeof response.data === \"string\"\n ? response.data\n : undefined;\n\n if (response.type !== \"result\" || result_text === undefined) {\n throw create_remote_transport_error(\n new UnsupportedRemoteFormResponseError(envelope),\n envelope,\n );\n }\n\n const parsed = parse(result_text);\n const decoded = decode_payload(parsed) as {\n issues?: readonly FormIssue[];\n result?: Output;\n };\n\n if (decoded.issues && decoded.issues.length > 0) {\n throw create_remote_validation_error(decoded.issues, decoded, 400);\n }\n\n return decoded.result as Output;\n}\n","import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\n\n/**\n * Wraps a remote form enhance callback so Effect return values are run.\n *\n * @since 2.0.0\n * @param callback - Native enhance callback to wrap.\n * @returns Wrapped callback or undefined.\n */\nexport function wrap_enhance_callback<Output, ErrorType = never>(\n callback: NativeMethod | undefined,\n): NativeMethod | undefined {\n if (!callback) {\n return undefined;\n }\n\n return (event: unknown) => {\n const wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n const result = callback(wrapped_event);\n\n if (Effect.isEffect(result)) {\n return get_dispatcher().run(result);\n }\n\n return result;\n };\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n if (\n typeof event !== \"object\" || event === null || !has_method(event, \"submit\")\n ) {\n return event;\n }\n\n const original_submit = event.submit;\n const { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(\n event,\n );\n\n void _submit;\n\n return Object.defineProperties({}, {\n ...descriptors,\n submit: {\n configurable: true,\n enumerable: false,\n value: () =>\n make_submit_effect<Output, ErrorType>(original_submit, event),\n },\n });\n}\n\nfunction make_submit_effect<Output, ErrorType>(\n original_submit: NativeMethod,\n event: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n let updates_args: unknown[] | undefined;\n\n const effect = make_effect_from_promise<Output | undefined, ErrorType>(\n async (): Promise<Output | undefined> => {\n const result = original_submit();\n const value = updates_args && has_method(result, \"updates\")\n ? await Promise.resolve(result.updates(...updates_args))\n : await Promise.resolve(result);\n\n if (typeof value === \"boolean\") {\n return read_submit_result<Output>(event);\n }\n\n return value as Output;\n },\n ) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n Object.defineProperty(effect, \"updates\", {\n configurable: true,\n enumerable: false,\n value: (...args: unknown[]) => {\n updates_args ??= args;\n\n return effect;\n },\n });\n\n return effect;\n}\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n if (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n return undefined;\n }\n\n return Reflect.get(event, \"result\") as Output | undefined;\n}\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport { get_remote_action_id, submit_remote_form } from \"./form-transport.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport type {\n EffectRemoteForm,\n NativeFormRecord,\n NativeMethod,\n} from \"./types.ts\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\n/**\n * Creates a remote form adapter. The callable preserves SvelteKit's native\n * form descriptors while wrapping `validate`, `enhance`, and programmatic\n * submission in Effect-returning APIs.\n *\n * @example\n * ```ts\n * const createPost = create_remote_form_adapter(nativeForm, (value) => value);\n * yield* createPost.validate({ includeUntouched: true });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native form object.\n * @param decode_payload - Function to decode the response payload.\n * @param remote_base - Base URL for SvelteKit's remote endpoint.\n * @returns A callable form function whose properties mirror the native form.\n * @internal\n */\nexport function create_remote_form_adapter<\n Input extends RemoteFormInput | void,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: (value: unknown) => unknown,\n remote_base = \"\",\n): EffectRemoteForm<Input, Output, ErrorType> {\n const form_obj = native_factory as NativeFormRecord;\n\n const submit_effect = (input?: RemoteInput<Input>) =>\n make_effect_from_promise<Output, ErrorType>(async () => {\n const can_use_remote_endpoint = remote_base.length > 0 &&\n get_remote_action_id(form_obj) !== undefined;\n\n if (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n const result = await form_obj.submit(input);\n\n return await decode_response_or_value<Output>(result, decode_payload);\n }\n\n return await submit_remote_form<Output>(\n form_obj,\n input,\n decode_payload,\n remote_base,\n );\n });\n\n const callable =\n ((input?: RemoteInput<Input>) => submit_effect(input)) as EffectRemoteForm<\n Input,\n Output,\n ErrorType\n >;\n\n copy_property_descriptors(\n form_obj,\n callable,\n new Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n );\n\n Object.defineProperty(callable, \"submit\", {\n configurable: true,\n enumerable: false,\n value: submit_effect,\n });\n\n if (has_method(form_obj, \"validate\")) {\n Object.defineProperty(callable, \"validate\", {\n configurable: true,\n enumerable: false,\n value: (options?: Record<string, unknown>) =>\n make_effect_from_promise<void, ErrorType>(async () => {\n await form_obj.validate(options);\n }),\n });\n }\n\n if (has_method(form_obj, \"enhance\")) {\n Object.defineProperty(callable, \"enhance\", {\n configurable: true,\n enumerable: false,\n value: (callback?: NativeMethod) =>\n form_obj.enhance(\n wrap_enhance_callback<Output, ErrorType>(callback),\n ),\n });\n }\n\n if (has_method(form_obj, \"for\")) {\n Object.defineProperty(callable, \"for\", {\n configurable: true,\n enumerable: false,\n value: (key: string | number | boolean) =>\n create_remote_form_adapter<Input, Output, ErrorType>(\n form_obj.for(key),\n decode_payload,\n remote_base,\n ),\n });\n }\n\n if (has_method(form_obj, \"preflight\")) {\n Object.defineProperty(callable, \"preflight\", {\n configurable: true,\n enumerable: false,\n value: (schema: unknown) => {\n form_obj.preflight(schema);\n\n return callable;\n },\n });\n }\n\n return callable;\n}\n","import { decode_response_or_value } from \"./responses.ts\";\nimport { has_method } from \"./utils.ts\";\n\n/**\n * Resolves native query results, including SvelteKit run handles.\n *\n * @example\n * ```ts\n * const output = await resolve_query_result(result, decode_payload);\n * ```\n *\n * @since 2.0.0\n * @param value - Native query result or query run handle.\n * @param decode_payload - Function used to decode successful payloads.\n * @returns Decoded query output.\n */\nexport async function resolve_query_result<Output>(\n value: unknown,\n decode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n if (has_method(value, \"then\")) {\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n }\n\n if (has_method(value, \"run\")) {\n const result = await value.run();\n\n return decode_response_or_value(result, decode_payload);\n }\n\n const result = await Promise.resolve(value);\n\n return decode_response_or_value(result, decode_payload);\n}\n","import {\n InvalidLiveQueryFactoryError,\n InvalidQueryFactoryError,\n} from \"$/errors.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"./failures.ts\";\nimport { resolve_query_result } from \"./query-result.ts\";\nimport { make_effect_from_promise } from \"./effect.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\n\ntype NativeQueryFactory<Input> =\n | ((input: RemoteInput<Input>) => unknown)\n | {\n readonly load: (input: RemoteInput<Input>) => unknown;\n };\n\ntype RemoteResourceEffect<Output, ErrorType = never> =\n & Effect.Effect<Output, RemoteFailure<ErrorType>>\n & {\n readonly current: Output | undefined;\n readonly error: unknown;\n readonly loading: boolean;\n readonly ready: boolean;\n };\n\ntype RemoteResourceLike<Output, ErrorType = never> =\n | RemoteResourceEffect<Output, ErrorType>\n | RemoteLiveQueryResource<Output>;\n\ntype RemoteQueryEffect<Output, ErrorType = never> =\n & RemoteResourceEffect<Output, ErrorType>\n & {\n readonly refresh: () => Effect.Effect<void, unknown, never>;\n readonly set: (value: Output) => void;\n readonly withOverride: (\n update: (current: Output) => Output,\n ) => unknown;\n };\n\ntype RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<\n RemoteLiveQueryResource<Output>,\n RemoteFailure<ErrorType>\n>;\n\ntype RemoteLiveQueryResource<Output> =\n & {\n readonly connected: boolean;\n readonly current: Output | undefined;\n readonly done: boolean;\n readonly error: unknown;\n readonly loading: boolean;\n readonly ready: boolean;\n readonly reconnect: () => Effect.Effect<void, unknown, never>;\n }\n & AsyncIterable<Output>;\n\ntype NativeRemoteResource<Output> = {\n readonly connected?: boolean;\n readonly current?: Output;\n readonly done?: boolean;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n readonly reconnect?: () => Promise<void>;\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n readonly [Symbol.asyncIterator]?: () => AsyncIterator<Output>;\n};\n\n/**\n * Creates a remote query adapter. The returned function takes input and\n * returns an `Effect` that executes SvelteKit's native query function.\n *\n * @example\n * ```ts\n * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);\n * const user = yield* getUser({ id: 1 });\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native query function or a legacy\n * response factory used by tests.\n * @param decode_payload - Function to decode the response payload.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning an Effect of the response.\n * @internal\n */\nexport function create_remote_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: NativeQueryFactory<Input>,\n decode_payload: DecodePayload<Output>,\n _base?: string,\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: NativeQueryFactory<Input>,\n decode_payload: (value: unknown) => unknown,\n _base?: string,\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n decode_payload: DecodePayload<Output>,\n _base = \"\",\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n const load = has_method(native_factory, \"load\")\n ? native_factory.load\n : undefined;\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query && !load) {\n throw new InvalidQueryFactoryError();\n }\n\n const wrapped = ((input: RemoteInput<Input>) => {\n if (!query) {\n return make_effect_from_promise<Output, ErrorType>(async () => {\n const result = await load?.(input);\n\n return await resolve_query_result<Output>(result, decode_payload);\n }) as RemoteQueryEffect<Output, ErrorType>;\n }\n\n const resource = query(input);\n const effect = make_effect_from_promise<Output, ErrorType>(async () =>\n await resolve_query_result<Output>(resource, decode_payload)\n ) as RemoteQueryEffect<Output, ErrorType>;\n\n attach_query_resource(resource, effect);\n\n return effect;\n }) as\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\n/**\n * Creates a remote live query adapter. The returned function takes input and\n * returns an `Effect` that resolves to a live query resource with stream state\n * and reconnect controls.\n *\n * @example\n * ```ts\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\n * const time = yield* getTime();\n * const current = time.current;\n * ```\n *\n * @since 2.0.0\n * @param native_factory - SvelteKit's native live query function.\n * @param _decode_payload - Deprecated payload decoder retained for parity with\n * other remote adapters.\n * @param _base - Deprecated transport base retained for compatibility.\n * @returns A function returning an Effect-backed live query resource.\n * @internal\n */\nexport function create_remote_live_query_adapter<\n Input,\n Output,\n ErrorType = never,\n>(\n native_factory: unknown,\n _decode_payload: (value: unknown) => unknown,\n _base = \"\",\n):\n & EffectRemoteQueryUpdateBrand\n & ((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>) {\n const query = typeof native_factory === \"function\"\n ? native_factory as NativeMethod\n : undefined;\n\n if (!query) {\n throw new InvalidLiveQueryFactoryError();\n }\n\n const wrapped = ((input: Input) =>\n Effect.try({\n try: () => {\n const resource = query(input);\n\n return make_live_query_resource<Output>(resource);\n },\n catch: normalize_native_error,\n }) as RemoteLiveQueryEffect<Output>) as\n & EffectRemoteQueryUpdateBrand\n & ((\n input: RemoteInput<Input>,\n ) => RemoteLiveQueryEffect<Output, ErrorType>);\n\n copy_property_descriptors(native_factory, wrapped);\n\n return wrapped;\n}\n\nfunction is_resource<Output>(\n resource: unknown,\n): resource is NativeRemoteResource<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_resource_getters<Output, ErrorType = never>(\n resource: unknown,\n effect: RemoteResourceLike<Output, ErrorType>,\n): void {\n const methods = is_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<Output, ErrorType = never>(\n resource: unknown,\n effect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_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 make_effect_from_promise(() => Promise.resolve(refresh.call(resource))),\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_query_resource<Output>(\n resource: unknown,\n effect: RemoteLiveQueryResource<Output>,\n): void {\n const methods = is_resource<Output>(resource) ? resource : undefined;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const reconnect = methods?.reconnect;\n const keys = [\"connected\", \"done\"] as const;\n\n attach_resource_getters(resource, effect);\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 make_effect_from_promise(() =>\n Promise.resolve(reconnect.call(resource))\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_query_resource<Output>(\n resource: unknown,\n): RemoteLiveQueryResource<Output> {\n const live_resource = {} as RemoteLiveQueryResource<Output>;\n\n attach_live_query_resource(resource, live_resource);\n\n return live_resource;\n}\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,MAAM,SAAS,uBAAuB,OAAO;CAE7C,OAAO,WAAW,UAAU,MAAM;AACpC;AAEA,SAAS,uBAAuB,OAAwB;CACtD,IAAI;EACF,OAAO,KAAK,MAAM,KAAK;CACzB,QAAQ;EACN,OAAO;CACT;AACF;;;;;;;;;;;;;AAcA,SAAgB,0BACd,OAC+B;CAC/B,OACE,OAAO,UAAU,YACjB,UAAU,QACV,UAAU;AAEd;;;;;;;;;;;;;AAcA,SAAgB,uBACd,OAC0B;CAC1B,MAAM,OAAO,eAAe,KAAK;CACjC,MAAM,UAAU,oBAA+B,IAAI;CACnD,MAAM,SAAS,iBAAiB,KAAK;CAErC,IAAI,0BAA0B,OAAO,GACnC,OAAO;CAGT,IAAI,WAAW,KAAA,GACb,OAAO,yBAAyB,QAAQ,MAAM,KAAK;CAGrD,OAAO,8BAA8B,KAAK;AAC5C;AAEA,SAAS,iBAAiB,OAAoC;CAC5D,IAAI,OAAO,UAAU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