svelte-effect-runtime 3.4.6 → 3.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-CsVu54pU.js → client-D_DE2cFa.js} +11 -42
- package/.dist/chunks/{client-CsVu54pU.js.map → client-D_DE2cFa.js.map} +1 -1
- package/.dist/chunks/{dispatcher-pHH4JcFR.js → dispatcher-BdvO4AAS.js} +2 -2
- package/.dist/chunks/{dispatcher-pHH4JcFR.js.map → dispatcher-BdvO4AAS.js.map} +1 -1
- package/.dist/chunks/{dispatcher-LtvFKYUp.js → dispatcher-NpL5xhWF.js} +3 -3
- package/.dist/chunks/{dispatcher-LtvFKYUp.js.map → dispatcher-NpL5xhWF.js.map} +1 -1
- package/.dist/chunks/{errors-Dcf0MVbq.js → errors-Bl3NVEez.js} +21 -3
- package/.dist/chunks/{errors-Dcf0MVbq.js.map → errors-Bl3NVEez.js.map} +1 -1
- package/.dist/chunks/live-DEmS7qpO.js +103 -0
- package/.dist/chunks/live-DEmS7qpO.js.map +1 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js +108 -0
- package/.dist/chunks/remote-client-Bj1pZXgq.js.map +1 -0
- package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-BNNW2GDT.js} +3 -3
- package/.dist/chunks/{runtime-ekkMQ-wL.js.map → runtime-BNNW2GDT.js.map} +1 -1
- package/.dist/chunks/{transform-02e-RvXH.js → transform-C2fCVPL_.js} +173 -106
- package/.dist/chunks/transform-C2fCVPL_.js.map +1 -0
- package/.dist/chunks/{vite-Dkwdtbgj.js → vite-Dm3bXmR3.js} +12 -88
- package/.dist/chunks/vite-Dm3bXmR3.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +15 -0
- package/.dist/generators.d.ts +3 -1
- package/.dist/internal/generators.js +20 -3
- package/.dist/internal/generators.js.map +1 -0
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/live.d.ts +100 -0
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform/constants.d.ts +1 -0
- package/.dist/markup/transform/types.d.ts +1 -0
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +5 -2
- package/.dist/mod.js +5 -4
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client/query.d.ts +6 -16
- package/.dist/remote/client/types.d.ts +2 -11
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +1 -1
- package/.dist/runtime/transform.js +58 -27
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +2 -0
- package/.dist/script-transform/types.d.ts +8 -0
- package/.dist/server/effects.d.ts +7 -7
- package/.dist/server/index.d.ts +3 -1
- package/.dist/server/types.d.ts +25 -50
- package/.dist/server/wrappers.d.ts +2 -2
- package/.dist/server.d.ts +2 -2
- package/.dist/server.js +40 -65
- package/.dist/server.js.map +1 -1
- package/.dist/vite/remote-client.d.ts +24 -0
- package/.dist/vite.d.ts +8 -3
- package/.dist/vite.js +1 -1
- package/.dist/yieldable.d.ts +41 -0
- package/package.json +1 -1
- package/.dist/chunks/transform-02e-RvXH.js.map +0 -1
- package/.dist/chunks/vite-Dkwdtbgj.js.map +0 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as get_dispatcher } from "./dispatcher-
|
|
1
|
+
import { c as InvalidLiveQueryFactoryError, d as InvalidRemoteFormResponseError, k as UnsupportedRemoteFormResponseError, m as RemoteFormEndpointMissingError, p as RemoteErrorDecodeError, s as InvalidCommandFactoryError, u as InvalidQueryFactoryError } from "./errors-Bl3NVEez.js";
|
|
2
|
+
import { n as get_dispatcher } from "./dispatcher-BdvO4AAS.js";
|
|
3
|
+
import { n as make_remote_live_stream } from "./live-DEmS7qpO.js";
|
|
3
4
|
import { create_remote_http_error, create_remote_transport_error, create_remote_validation_error, is_serialized_remote_failure_envelope } from "../remote/shared.js";
|
|
4
5
|
import { t as copy_property_descriptors } from "./descriptors-cOe9uRJz.js";
|
|
5
6
|
import { Effect, Option, Schema } from "effect";
|
|
@@ -522,14 +523,13 @@ function create_remote_query_adapter(native_factory, decode_payload, _base = "")
|
|
|
522
523
|
}
|
|
523
524
|
/**
|
|
524
525
|
* Creates a remote live query adapter. The returned function takes input and
|
|
525
|
-
* returns an
|
|
526
|
-
* and reconnect controls.
|
|
526
|
+
* returns an Effect Stream whose transport state is exposed through `Live`.
|
|
527
527
|
*
|
|
528
528
|
* @example
|
|
529
529
|
* ```ts
|
|
530
530
|
* const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
|
|
531
|
-
* const time =
|
|
532
|
-
* const
|
|
531
|
+
* const time = getTime();
|
|
532
|
+
* const first = yield* Stream.runHead(time);
|
|
533
533
|
* ```
|
|
534
534
|
*
|
|
535
535
|
* @since 2.0.0
|
|
@@ -537,18 +537,15 @@ function create_remote_query_adapter(native_factory, decode_payload, _base = "")
|
|
|
537
537
|
* @param _decode_payload - Deprecated payload decoder retained for parity with
|
|
538
538
|
* other remote adapters.
|
|
539
539
|
* @param _base - Deprecated transport base retained for compatibility.
|
|
540
|
-
* @returns A function returning
|
|
540
|
+
* @returns A function returning a remote live stream.
|
|
541
541
|
* @internal
|
|
542
542
|
*/
|
|
543
543
|
function create_remote_live_query_adapter(native_factory, _decode_payload, _base = "") {
|
|
544
544
|
const query = typeof native_factory === "function" ? native_factory : void 0;
|
|
545
545
|
if (!query) throw new InvalidLiveQueryFactoryError();
|
|
546
|
-
const wrapped = ((input) =>
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
},
|
|
550
|
-
catch: normalize_native_error
|
|
551
|
-
}));
|
|
546
|
+
const wrapped = ((input) => {
|
|
547
|
+
return make_remote_live_stream(query(input), normalize_native_error);
|
|
548
|
+
});
|
|
552
549
|
copy_property_descriptors(native_factory, wrapped);
|
|
553
550
|
return wrapped;
|
|
554
551
|
}
|
|
@@ -593,35 +590,7 @@ function attach_query_resource(resource, effect) {
|
|
|
593
590
|
value: (update) => with_override.call(resource, update)
|
|
594
591
|
});
|
|
595
592
|
}
|
|
596
|
-
function attach_live_query_resource(resource, effect) {
|
|
597
|
-
const methods = is_resource(resource) ? resource : void 0;
|
|
598
|
-
const async_iterator = methods?.[Symbol.asyncIterator];
|
|
599
|
-
const reconnect = methods?.reconnect;
|
|
600
|
-
const keys = ["connected", "done"];
|
|
601
|
-
attach_resource_getters(resource, effect);
|
|
602
|
-
if (!methods) return;
|
|
603
|
-
for (const key of keys) {
|
|
604
|
-
if (!(key in methods)) continue;
|
|
605
|
-
Object.defineProperty(effect, key, {
|
|
606
|
-
configurable: true,
|
|
607
|
-
get: () => methods[key]
|
|
608
|
-
});
|
|
609
|
-
}
|
|
610
|
-
if (typeof reconnect === "function") Object.defineProperty(effect, "reconnect", {
|
|
611
|
-
configurable: true,
|
|
612
|
-
value: () => MakeEffectFromPromise(() => Promise.resolve(reconnect.call(resource)))
|
|
613
|
-
});
|
|
614
|
-
if (typeof async_iterator === "function") Object.defineProperty(effect, Symbol.asyncIterator, {
|
|
615
|
-
configurable: true,
|
|
616
|
-
value: () => async_iterator.call(resource)
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
function make_live_query_resource(resource) {
|
|
620
|
-
const live_resource = {};
|
|
621
|
-
attach_live_query_resource(resource, live_resource);
|
|
622
|
-
return live_resource;
|
|
623
|
-
}
|
|
624
593
|
//#endregion
|
|
625
594
|
export { create_remote_command_adapter as i, create_remote_query_adapter as n, create_remote_form_adapter as r, create_remote_live_query_adapter as t };
|
|
626
595
|
|
|
627
|
-
//# sourceMappingURL=client-
|
|
596
|
+
//# sourceMappingURL=client-D_DE2cFa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-CsVu54pU.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../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/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":["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\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tis_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { RemoteErrorDecodeError } from \"$/errors.ts\";\nimport { Option, Schema } from \"effect\";\nimport { parse } from \"devalue\";\n\ntype JsonStringDecode =\n\t| {\n\t\t\treadonly _tag: \"JsonStringDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"JsonStringIgnored\";\n\t };\n\ntype EmbeddedRemoteFailureDecode =\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureIgnored\";\n\t };\n\ntype SerializedRemoteFailureDecode<ErrorType> =\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureDecoded\";\n\t\t\treadonly value: RemoteFailure<ErrorType>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureInvalid\";\n\t };\n\nconst RemoteErrorMessageEnvelopeSchema = Schema.Struct({\n\tmessage: Schema.String,\n});\n\nconst DecodedRemoteFailureSchema = Schema.Struct({\n\t_tag: Schema.String,\n});\n\nconst DecodeJsonString = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\nconst is_decoded_remote_failure_value = Schema.is(DecodedRemoteFailureSchema);\nconst is_remote_error_message_envelope = Schema.is(RemoteErrorMessageEnvelopeSchema);\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\traw: unknown,\n\tdecode?: (encoded: string) => unknown,\n): RemoteFailure<ErrorType> | unknown {\n\tconst embedded = decode_embedded_remote_failure(raw);\n\n\tif (embedded._tag === \"EmbeddedRemoteFailureDecoded\") {\n\t\treturn decode_remote_error<ErrorType>(embedded.value, decode);\n\t}\n\n\tif (is_serialized_remote_failure_envelope(raw)) {\n\t\tconst decoded = decode_serialized_remote_failure<ErrorType>(raw.encoded, decode);\n\n\t\tif (decoded._tag === \"SerializedRemoteFailureInvalid\") {\n\t\t\treturn create_remote_transport_error(new RemoteErrorDecodeError(raw), raw);\n\t\t}\n\n\t\treturn decoded.value;\n\t}\n\n\treturn raw;\n}\n\nfunction decode_embedded_remote_failure(raw: unknown): EmbeddedRemoteFailureDecode {\n\tif (typeof raw === \"string\") {\n\t\treturn decode_embedded_json_remote_failure(raw);\n\t}\n\n\tif (!is_remote_error_message_envelope(raw)) {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn decode_embedded_json_remote_failure(raw.message);\n}\n\nfunction decode_embedded_json_remote_failure(value: string): EmbeddedRemoteFailureDecode {\n\tconst decoded = decode_json_string(value);\n\n\tif (decoded._tag === \"JsonStringIgnored\") {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"EmbeddedRemoteFailureDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_json_string(value: string): JsonStringDecode {\n\tconst decoded = DecodeJsonString(value);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn { _tag: \"JsonStringIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"JsonStringDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_serialized_remote_failure<ErrorType>(\n\tencoded: string,\n\tdecode: ((encoded: string) => unknown) | undefined,\n): SerializedRemoteFailureDecode<ErrorType> {\n\ttry {\n\t\tconst decoded = decode ? decode(encoded) : parse(encoded);\n\n\t\treturn {\n\t\t\t_tag: \"SerializedRemoteFailureDecoded\",\n\t\t\tvalue: decoded as RemoteFailure<ErrorType>,\n\t\t};\n\t} catch {\n\t\treturn { _tag: \"SerializedRemoteFailureInvalid\" };\n\t}\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(value: unknown): value is RemoteFailure<never> {\n\treturn is_decoded_remote_failure_value(value);\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\terror: unknown,\n): RemoteFailure<ErrorType> {\n\tconst body = get_error_body(error);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\tconst status = get_error_status(error);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\tif (status !== undefined) {\n\t\treturn create_remote_http_error(status, body, error);\n\t}\n\n\treturn create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst status = (error as { status?: unknown }).status;\n\n\treturn typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tif (\"body\" in error) {\n\t\treturn (error as { body?: unknown }).body;\n\t}\n\n\tif (\"data\" in error) {\n\t\treturn (error as { data?: unknown }).data;\n\t}\n\n\treturn 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\tresponse: Response,\n): Promise<RemoteFailure<ErrorType>> {\n\tconst body = await response.json().catch(() => undefined);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\treturn 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\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (value instanceof Response) {\n\t\tif (!value.ok) {\n\t\t\tthrow await decode_response_failure<ErrorType>(value);\n\t\t}\n\n\t\tconst data = await decode_success_response_body(value);\n\n\t\treturn decode_payload(data) as Output;\n\t}\n\n\treturn decode_payload(value) as Output;\n}\n\nasync function decode_success_response_body(response: Response): Promise<unknown> {\n\tif (response.status === 204 || response.status === 205) {\n\t\treturn undefined;\n\t}\n\n\tconst text = await response.text();\n\n\tif (text.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn JSON.parse(text);\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nimport { is_decoded_remote_failure, normalize_native_error } 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 MakeEffectFromPromise<Output, ErrorType = never>(\n\trun: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\n\treturn Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => {\n\t\t\tif (isRedirect(error)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (is_decoded_remote_failure(error)) {\n\t\t\t\treturn error;\n\t\t\t}\n\n\t\t\treturn normalize_native_error<ErrorType>(error);\n\t\t},\n\t}) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\n}\n\n/**\n * Compatibility alias for {@link MakeEffectFromPromise}.\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 * @internal\n */\nexport const make_effect_from_promise = MakeEffectFromPromise;\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport type { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => Effect.Effect<Output, RemoteFailure<ErrorType>>) & {\n\treadonly 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<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n\tpending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n\tconst invoke = has_method(native_factory, \"invoke\") ? native_factory.invoke : undefined;\n\n\tif (typeof native_factory !== \"function\" && !invoke) {\n\t\tthrow new InvalidCommandFactoryError();\n\t}\n\n\tconst count = pending ?? { value: 0 };\n\n\tconst adapter = (input: undefined extends Input ? Input | void : Input) =>\n\t\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tcount.value += 1;\n\n\t\t\ttry {\n\t\t\t\tconst result = invoke\n\t\t\t\t\t? await invoke(input)\n\t\t\t\t\t: await (native_factory as NativeMethod)(input);\n\n\t\t\t\treturn await decode_response_or_value<Output, ErrorType>(result, decode_payload);\n\t\t\t} finally {\n\t\t\t\tcount.value -= 1;\n\t\t\t}\n\t\t});\n\n\tcopy_property_descriptors(native_factory, adapter);\n\n\tif (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n\t\tObject.defineProperty(adapter, \"pending\", {\n\t\t\tget: () => count.value,\n\t\t});\n\t}\n\n\treturn adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\n}\n","/**\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\tconst form_data = new FormData();\n\n\tappend_form_value(form_data, \"\", input);\n\n\treturn form_data;\n}\n\nfunction append_form_value(form_data: FormData, path: string, value: unknown): void {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tappend_form_value(form_data, `${path}[]`, item);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (value instanceof Blob) {\n\t\tform_data.append(path, value);\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"object\" && value !== null) {\n\t\tfor (const [key, child] of Object.entries(value)) {\n\t\t\tconst child_path = path.length === 0 ? key : `${path}.${key}`;\n\n\t\t\tappend_form_value(form_data, child_path, child);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tform_data.append(`n:${path}`, String(value));\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"boolean\") {\n\t\tif (value) {\n\t\t\tform_data.append(`b:${path}`, \"on\");\n\t\t}\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Option, Schema } from \"effect\";\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\ntype RemoteFormResponseEnvelope =\n\t| {\n\t\t\treadonly _tag: \"RemoteFormErrorEnvelope\";\n\t\t\treadonly error?: unknown;\n\t\t\treadonly status?: number | undefined;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormResultEnvelope\";\n\t\t\treadonly data?: string | undefined;\n\t\t\treadonly result?: string | undefined;\n\t };\n\ntype RemoteFormDecodedPayload<Output> = {\n\treadonly issues?: readonly FormIssue[];\n\treadonly result?: Output;\n};\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst RemoteFormErrorEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"error\"),\n\terror: Schema.optional(Schema.Unknown),\n\tstatus: Schema.optional(Schema.Number),\n});\n\nconst RemoteFormResultEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"result\"),\n\tdata: Schema.optional(Schema.String),\n\tresult: Schema.optional(Schema.String),\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\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\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n): Promise<Output> {\n\tconst action_id = get_remote_action_id(form_obj);\n\n\tif (!action_id || remote_base.length === 0) {\n\t\tthrow create_remote_transport_error(new RemoteFormEndpointMissingError());\n\t}\n\n\tconst response = await fetch(to_remote_form_url(remote_base, action_id), {\n\t\tmethod: \"POST\",\n\t\tbody: to_form_data(input),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow await decode_response_failure(response);\n\t}\n\n\tconst envelope = await response.json();\n\n\treturn 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(form_obj: NativeFormRecord): string | undefined {\n\tconst action = form_obj.action;\n\n\tif (typeof action !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst fallback = \"http://localhost/\";\n\tconst href = typeof location === \"undefined\" ? fallback : location.href;\n\tconst url = new URL(action, href);\n\n\treturn url.searchParams.get(\"/remote\") ?? url.searchParams.get(\"remote\") ?? undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n\tconst parts = action_id.split(\"/\");\n\tconst head = parts.slice(0, 2).join(\"/\");\n\tconst tail = parts.slice(2).join(\"/\");\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\tif (tail.length === 0) {\n\t\treturn `${normalized_base}/${head}`;\n\t}\n\n\treturn `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction decode_form_response<Output>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Output {\n\tconst response = decode_remote_form_response_envelope(envelope);\n\n\tif (!response) {\n\t\tthrow create_remote_transport_error(new InvalidRemoteFormResponseError(envelope), envelope);\n\t}\n\n\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\tconst decoded = decode_remote_error(response.error);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\tthrow decoded;\n\t\t}\n\n\t\tthrow create_remote_http_error(response.status ?? 500, response.error);\n\t}\n\n\tconst result_text = response.result ?? response.data;\n\n\tif (result_text === undefined) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tconst parsed = parse(result_text);\n\tconst decoded = decode_remote_form_payload<Output>(decode_payload(parsed));\n\n\tif (!decoded) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tif (decoded.issues && decoded.issues.length > 0) {\n\t\tthrow create_remote_validation_error(decoded.issues, decoded, 400);\n\t}\n\n\treturn decoded.result as Output;\n}\n\nfunction decode_remote_form_response_envelope(\n\tenvelope: unknown,\n): RemoteFormResponseEnvelope | undefined {\n\tconst decoded = DecodeRemoteFormResponseEnvelope(envelope);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\tif (decoded.value.type === \"error\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormErrorEnvelope\",\n\t\t\terror: decoded.value.error,\n\t\t\tstatus: decoded.value.status,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t\tresult: decoded.value.result,\n\t};\n}\n\nfunction decode_remote_form_payload<Output>(\n\tpayload: unknown,\n): RemoteFormDecodedPayload<Output> | undefined {\n\tconst decoded = DecodeRemoteFormPayload(payload);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\treturn decoded.value as RemoteFormDecodedPayload<Output>;\n}\n","import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\nimport { MakeEffectFromPromise } 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\tcallback: NativeMethod | undefined,\n): NativeMethod | undefined {\n\tif (!callback) {\n\t\treturn undefined;\n\t}\n\n\treturn (event: unknown) => {\n\t\tconst wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n\t\tconst result = callback(wrapped_event);\n\n\t\tif (Effect.isEffect(result)) {\n\t\t\treturn get_dispatcher().run(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n\tif (typeof event !== \"object\" || event === null || !has_method(event, \"submit\")) {\n\t\treturn event;\n\t}\n\n\tconst original_submit = event.submit;\n\tconst { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(event);\n\n\tvoid _submit;\n\n\treturn Object.defineProperties(\n\t\t{},\n\t\t{\n\t\t\t...descriptors,\n\t\t\tsubmit: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: false,\n\t\t\t\tvalue: () => make_submit_effect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction make_submit_effect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = MakeEffectFromPromise<Output | undefined, ErrorType>(\n\t\tasync (): Promise<Output | undefined> => {\n\t\t\tconst result = original_submit();\n\t\t\tconst value =\n\t\t\t\tupdates_args && has_method(result, \"updates\")\n\t\t\t\t\t? await Promise.resolve(result.updates(...updates_args))\n\t\t\t\t\t: await Promise.resolve(result);\n\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\treturn read_submit_result<Output>(event);\n\t\t\t}\n\n\t\t\treturn value as Output;\n\t\t},\n\t) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n\tObject.defineProperty(SubmitEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn SubmitEffect;\n\t\t},\n\t});\n\n\treturn SubmitEffect;\n}\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n\tif (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n\t\treturn undefined;\n\t}\n\n\treturn Reflect.get(event, \"result\") as Output | undefined;\n}\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { MakeEffectFromPromise } 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 { EffectRemoteForm, NativeFormRecord, NativeMethod } 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\tInput extends RemoteFormInput | void,\n\tOutput,\n\tErrorType = never,\n>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base = \"\",\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\n\tconst submit_effect = (input?: RemoteInput<Input>) =>\n\t\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tconst can_use_remote_endpoint =\n\t\t\t\tremote_base.length > 0 && get_remote_action_id(form_obj) !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = await form_obj.submit(input);\n\n\t\t\t\treturn await decode_response_or_value<Output>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn await submit_remote_form<Output>(form_obj, input, decode_payload, remote_base);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => submit_effect(input)) as EffectRemoteForm<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType\n\t>;\n\n\tcopy_property_descriptors(\n\t\tform_obj,\n\t\tcallable,\n\t\tnew Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n\t);\n\n\tObject.defineProperty(callable, \"submit\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: submit_effect,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tObject.defineProperty(callable, \"validate\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (options?: Record<string, unknown>) =>\n\t\t\t\tMakeEffectFromPromise<void, ErrorType>(async () => {\n\t\t\t\t\tawait form_obj.validate(options);\n\t\t\t\t}),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"enhance\")) {\n\t\tObject.defineProperty(callable, \"enhance\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (callback?: NativeMethod) =>\n\t\t\t\tform_obj.enhance(wrap_enhance_callback<Output, ErrorType>(callback)),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"for\")) {\n\t\tObject.defineProperty(callable, \"for\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (key: string | number | boolean) =>\n\t\t\t\tcreate_remote_form_adapter<Input, Output, ErrorType>(\n\t\t\t\t\tform_obj.for(key),\n\t\t\t\t\tdecode_payload,\n\t\t\t\t\tremote_base,\n\t\t\t\t),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"preflight\")) {\n\t\tObject.defineProperty(callable, \"preflight\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (schema: unknown) => {\n\t\t\t\tform_obj.preflight(schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn 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\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (has_method(value, \"then\")) {\n\t\tconst result = await Promise.resolve(value);\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tif (has_method(value, \"run\")) {\n\t\tconst result = await value.run();\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tconst result = await Promise.resolve(value);\n\n\treturn decode_response_or_value(result, decode_payload);\n}\n","import { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } 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 { MakeEffectFromPromise } 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\t| ((input: RemoteInput<Input>) => unknown)\n\t| {\n\t\t\treadonly load: (input: RemoteInput<Input>) => unknown;\n\t };\n\ntype RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<\n\tOutput,\n\tRemoteFailure<ErrorType>\n> & {\n\treadonly current: Output | undefined;\n\treadonly error: unknown;\n\treadonly loading: boolean;\n\treadonly ready: boolean;\n};\n\ntype RemoteResourceLike<Output, ErrorType = never> =\n\t| RemoteResourceEffect<Output, ErrorType>\n\t| RemoteLiveQueryResource<Output>;\n\ntype RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {\n\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\treadonly set: (value: Output) => void;\n\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n};\n\ntype RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<\n\tRemoteLiveQueryResource<Output>,\n\tRemoteFailure<ErrorType>\n>;\n\ntype RemoteLiveQueryResource<Output> = {\n\treadonly connected: boolean;\n\treadonly current: Output | undefined;\n\treadonly done: boolean;\n\treadonly error: unknown;\n\treadonly loading: boolean;\n\treadonly ready: boolean;\n\treadonly reconnect: () => Effect.Effect<void, unknown, never>;\n} & AsyncIterable<Output>;\n\ntype NativeRemoteResource<Output> = {\n\treadonly connected?: boolean;\n\treadonly current?: Output;\n\treadonly done?: boolean;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly reconnect?: () => Promise<void>;\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n\treadonly [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<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: DecodePayload<Output>,\n\t_base?: string,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base?: string,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: DecodePayload<Output>,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n\tconst load = has_method(native_factory, \"load\") ? native_factory.load : undefined;\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query && !load) {\n\t\tthrow new InvalidQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tif (!query) {\n\t\t\treturn MakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\t\tconst result = await load?.(input);\n\n\t\t\t\treturn await resolve_query_result<Output>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = query(input);\n\t\tconst QueryEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\tasync () => await resolve_query_result<Output>(resource, decode_payload),\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_query_resource(resource, QueryEffect);\n\n\t\treturn QueryEffect;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn 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<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\t_decode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>) {\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: Input) =>\n\t\tEffect.try({\n\t\t\ttry: () => {\n\t\t\t\tconst resource = query(input);\n\n\t\t\t\treturn make_live_query_resource<Output>(resource);\n\t\t\t},\n\t\t\tcatch: normalize_native_error,\n\t\t}) as RemoteLiveQueryEffect<Output>) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveQueryEffect<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n\nfunction is_resource<Output>(resource: unknown): resource is NativeRemoteResource<Output> {\n\tconst resource_type = typeof resource;\n\n\treturn (resource_type === \"object\" && resource !== null) || resource_type === \"function\";\n}\n\nfunction attach_resource_getters<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteResourceLike<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tfor (const key of keys) {\n\t\tif (!(key in methods)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tObject.defineProperty(effect, key, {\n\t\t\tconfigurable: true,\n\t\t\tget: () => methods[key],\n\t\t});\n\t}\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nfunction attach_live_query_resource<Output>(\n\tresource: unknown,\n\teffect: RemoteLiveQueryResource<Output>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst async_iterator = methods?.[Symbol.asyncIterator];\n\tconst reconnect = methods?.reconnect;\n\tconst keys = [\"connected\", \"done\"] as const;\n\n\tattach_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tfor (const key of keys) {\n\t\tif (!(key in methods)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tObject.defineProperty(effect, key, {\n\t\t\tconfigurable: true,\n\t\t\tget: () => methods[key],\n\t\t});\n\t}\n\n\tif (typeof reconnect === \"function\") {\n\t\tObject.defineProperty(effect, \"reconnect\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(reconnect.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof async_iterator === \"function\") {\n\t\tObject.defineProperty(effect, Symbol.asyncIterator, {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => async_iterator.call(resource),\n\t\t});\n\t}\n}\n\nfunction make_live_query_resource<Output>(resource: unknown): RemoteLiveQueryResource<Output> {\n\tconst live_resource = {} as RemoteLiveQueryResource<Output>;\n\n\tattach_live_query_resource(resource, live_resource);\n\n\treturn live_resource;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAWA,SAAgB,WACf,OACA,KACmC;CACnC,OACC,OAAO,UAAU,YACjB,UAAU,QACV,OAAQ,MAAuC,SAAS;AAE1D;;;ACiBA,MAAM,mCAAmC,OAAO,OAAO,EACtD,SAAS,OAAO,OACjB,CAAC;AAED,MAAM,6BAA6B,OAAO,OAAO,EAChD,MAAM,OAAO,OACd,CAAC;AAED,MAAM,mBAAmB,OAAO,oBAAoB,OAAO,qBAAqB;AAChF,MAAM,kCAAkC,OAAO,GAAG,0BAA0B;AAC5E,MAAM,mCAAmC,OAAO,GAAG,gCAAgC;;;;;;;;;;;;;;;AAgBnF,SAAgB,oBACf,KACA,QACqC;CACrC,MAAM,WAAW,+BAA+B,GAAG;CAEnD,IAAI,SAAS,SAAS,gCACrB,OAAO,oBAA+B,SAAS,OAAO,MAAM;CAG7D,IAAI,sCAAsC,GAAG,GAAG;EAC/C,MAAM,UAAU,iCAA4C,IAAI,SAAS,MAAM;EAE/E,IAAI,QAAQ,SAAS,kCACpB,OAAO,8BAA8B,IAAI,uBAAuB,GAAG,GAAG,GAAG;EAG1E,OAAO,QAAQ;CAChB;CAEA,OAAO;AACR;AAEA,SAAS,+BAA+B,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IAAI,WAAW,KAAA;CAC3D,MAAM,iBAAiB,UAAU,OAAO;CACxC,MAAM,YAAY,SAAS;CAC3B,MAAM,OAAO,CAAC,aAAa,MAAM;CAEjC,wBAAwB,UAAU,MAAM;CAExC,IAAI,CAAC,SACJ;CAGD,KAAK,MAAM,OAAO,MAAM;EACvB,IAAI,EAAE,OAAO,UACZ;EAGD,OAAO,eAAe,QAAQ,KAAK;GAClC,cAAc;GACd,WAAW,QAAQ;EACpB,CAAC;CACF;CAEA,IAAI,OAAO,cAAc,YACxB,OAAO,eAAe,QAAQ,aAAa;EAC1C,cAAc;EACd,aAAa,4BAA4B,QAAQ,QAAQ,UAAU,KAAK,QAAQ,CAAC,CAAC;CACnF,CAAC;CAGF,IAAI,OAAO,mBAAmB,YAC7B,OAAO,eAAe,QAAQ,OAAO,eAAe;EACnD,cAAc;EACd,aAAa,eAAe,KAAK,QAAQ;CAC1C,CAAC;AAEH;AAEA,SAAS,yBAAiC,UAAoD;CAC7F,MAAM,gBAAgB,CAAC;CAEvB,2BAA2B,UAAU,aAAa;CAElD,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"client-D_DE2cFa.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../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/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":["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\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tis_serialized_remote_failure_envelope,\n} from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { RemoteErrorDecodeError } from \"$/errors.ts\";\nimport { Option, Schema } from \"effect\";\nimport { parse } from \"devalue\";\n\ntype JsonStringDecode =\n\t| {\n\t\t\treadonly _tag: \"JsonStringDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"JsonStringIgnored\";\n\t };\n\ntype EmbeddedRemoteFailureDecode =\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureDecoded\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"EmbeddedRemoteFailureIgnored\";\n\t };\n\ntype SerializedRemoteFailureDecode<ErrorType> =\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureDecoded\";\n\t\t\treadonly value: RemoteFailure<ErrorType>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"SerializedRemoteFailureInvalid\";\n\t };\n\nconst RemoteErrorMessageEnvelopeSchema = Schema.Struct({\n\tmessage: Schema.String,\n});\n\nconst DecodedRemoteFailureSchema = Schema.Struct({\n\t_tag: Schema.String,\n});\n\nconst DecodeJsonString = Schema.decodeUnknownOption(Schema.UnknownFromJsonString);\nconst is_decoded_remote_failure_value = Schema.is(DecodedRemoteFailureSchema);\nconst is_remote_error_message_envelope = Schema.is(RemoteErrorMessageEnvelopeSchema);\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\traw: unknown,\n\tdecode?: (encoded: string) => unknown,\n): RemoteFailure<ErrorType> | unknown {\n\tconst embedded = decode_embedded_remote_failure(raw);\n\n\tif (embedded._tag === \"EmbeddedRemoteFailureDecoded\") {\n\t\treturn decode_remote_error<ErrorType>(embedded.value, decode);\n\t}\n\n\tif (is_serialized_remote_failure_envelope(raw)) {\n\t\tconst decoded = decode_serialized_remote_failure<ErrorType>(raw.encoded, decode);\n\n\t\tif (decoded._tag === \"SerializedRemoteFailureInvalid\") {\n\t\t\treturn create_remote_transport_error(new RemoteErrorDecodeError(raw), raw);\n\t\t}\n\n\t\treturn decoded.value;\n\t}\n\n\treturn raw;\n}\n\nfunction decode_embedded_remote_failure(raw: unknown): EmbeddedRemoteFailureDecode {\n\tif (typeof raw === \"string\") {\n\t\treturn decode_embedded_json_remote_failure(raw);\n\t}\n\n\tif (!is_remote_error_message_envelope(raw)) {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn decode_embedded_json_remote_failure(raw.message);\n}\n\nfunction decode_embedded_json_remote_failure(value: string): EmbeddedRemoteFailureDecode {\n\tconst decoded = decode_json_string(value);\n\n\tif (decoded._tag === \"JsonStringIgnored\") {\n\t\treturn { _tag: \"EmbeddedRemoteFailureIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"EmbeddedRemoteFailureDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_json_string(value: string): JsonStringDecode {\n\tconst decoded = DecodeJsonString(value);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn { _tag: \"JsonStringIgnored\" };\n\t}\n\n\treturn {\n\t\t_tag: \"JsonStringDecoded\",\n\t\tvalue: decoded.value,\n\t};\n}\n\nfunction decode_serialized_remote_failure<ErrorType>(\n\tencoded: string,\n\tdecode: ((encoded: string) => unknown) | undefined,\n): SerializedRemoteFailureDecode<ErrorType> {\n\ttry {\n\t\tconst decoded = decode ? decode(encoded) : parse(encoded);\n\n\t\treturn {\n\t\t\t_tag: \"SerializedRemoteFailureDecoded\",\n\t\t\tvalue: decoded as RemoteFailure<ErrorType>,\n\t\t};\n\t} catch {\n\t\treturn { _tag: \"SerializedRemoteFailureInvalid\" };\n\t}\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(value: unknown): value is RemoteFailure<never> {\n\treturn is_decoded_remote_failure_value(value);\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\terror: unknown,\n): RemoteFailure<ErrorType> {\n\tconst body = get_error_body(error);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\tconst status = get_error_status(error);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\tif (status !== undefined) {\n\t\treturn create_remote_http_error(status, body, error);\n\t}\n\n\treturn create_remote_transport_error(error);\n}\n\nfunction get_error_status(error: unknown): number | undefined {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tconst status = (error as { status?: unknown }).status;\n\n\treturn typeof status === \"number\" ? status : undefined;\n}\n\nfunction get_error_body(error: unknown): unknown {\n\tif (typeof error !== \"object\" || error === null) {\n\t\treturn undefined;\n\t}\n\n\tif (\"body\" in error) {\n\t\treturn (error as { body?: unknown }).body;\n\t}\n\n\tif (\"data\" in error) {\n\t\treturn (error as { data?: unknown }).data;\n\t}\n\n\treturn 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\tresponse: Response,\n): Promise<RemoteFailure<ErrorType>> {\n\tconst body = await response.json().catch(() => undefined);\n\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\tif (is_decoded_remote_failure(decoded)) {\n\t\treturn decoded;\n\t}\n\n\treturn 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\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (value instanceof Response) {\n\t\tif (!value.ok) {\n\t\t\tthrow await decode_response_failure<ErrorType>(value);\n\t\t}\n\n\t\tconst data = await decode_success_response_body(value);\n\n\t\treturn decode_payload(data) as Output;\n\t}\n\n\treturn decode_payload(value) as Output;\n}\n\nasync function decode_success_response_body(response: Response): Promise<unknown> {\n\tif (response.status === 204 || response.status === 205) {\n\t\treturn undefined;\n\t}\n\n\tconst text = await response.text();\n\n\tif (text.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn JSON.parse(text);\n}\n","import type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nimport { is_decoded_remote_failure, normalize_native_error } 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 MakeEffectFromPromise<Output, ErrorType = never>(\n\trun: () => Promise<Output>,\n): Effect.Effect<Output, RemoteFailure<ErrorType>> {\n\treturn Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => {\n\t\t\tif (isRedirect(error)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tif (is_decoded_remote_failure(error)) {\n\t\t\t\treturn error;\n\t\t\t}\n\n\t\t\treturn normalize_native_error<ErrorType>(error);\n\t\t},\n\t}) as Effect.Effect<Output, RemoteFailure<ErrorType>>;\n}\n\n/**\n * Compatibility alias for {@link MakeEffectFromPromise}.\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 * @internal\n */\nexport const make_effect_from_promise = MakeEffectFromPromise;\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport type { NativeMethod, Pending } from \"./types.ts\";\nimport { MakeEffectFromPromise } from \"./effect.ts\";\nimport type { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => Effect.Effect<Output, RemoteFailure<ErrorType>>) & {\n\treadonly 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<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n\tpending?: Pending,\n): EffectRemoteCommandAdapter<Input, Output, ErrorType> {\n\tconst invoke = has_method(native_factory, \"invoke\") ? native_factory.invoke : undefined;\n\n\tif (typeof native_factory !== \"function\" && !invoke) {\n\t\tthrow new InvalidCommandFactoryError();\n\t}\n\n\tconst count = pending ?? { value: 0 };\n\n\tconst adapter = (input: undefined extends Input ? Input | void : Input) =>\n\t\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tcount.value += 1;\n\n\t\t\ttry {\n\t\t\t\tconst result = invoke\n\t\t\t\t\t? await invoke(input)\n\t\t\t\t\t: await (native_factory as NativeMethod)(input);\n\n\t\t\t\treturn await decode_response_or_value<Output, ErrorType>(result, decode_payload);\n\t\t\t} finally {\n\t\t\t\tcount.value -= 1;\n\t\t\t}\n\t\t});\n\n\tcopy_property_descriptors(native_factory, adapter);\n\n\tif (!Object.prototype.hasOwnProperty.call(adapter, \"pending\")) {\n\t\tObject.defineProperty(adapter, \"pending\", {\n\t\t\tget: () => count.value,\n\t\t});\n\t}\n\n\treturn adapter as EffectRemoteCommandAdapter<Input, Output, ErrorType>;\n}\n","/**\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\tconst form_data = new FormData();\n\n\tappend_form_value(form_data, \"\", input);\n\n\treturn form_data;\n}\n\nfunction append_form_value(form_data: FormData, path: string, value: unknown): void {\n\tif (value === undefined) {\n\t\treturn;\n\t}\n\n\tif (Array.isArray(value)) {\n\t\tfor (const item of value) {\n\t\t\tappend_form_value(form_data, `${path}[]`, item);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (value instanceof Blob) {\n\t\tform_data.append(path, value);\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"object\" && value !== null) {\n\t\tfor (const [key, child] of Object.entries(value)) {\n\t\t\tconst child_path = path.length === 0 ? key : `${path}.${key}`;\n\n\t\t\tappend_form_value(form_data, child_path, child);\n\t\t}\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"number\") {\n\t\tform_data.append(`n:${path}`, String(value));\n\n\t\treturn;\n\t}\n\n\tif (typeof value === \"boolean\") {\n\t\tif (value) {\n\t\t\tform_data.append(`b:${path}`, \"on\");\n\t\t}\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Option, Schema } from \"effect\";\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\ntype RemoteFormResponseEnvelope =\n\t| {\n\t\t\treadonly _tag: \"RemoteFormErrorEnvelope\";\n\t\t\treadonly error?: unknown;\n\t\t\treadonly status?: number | undefined;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormResultEnvelope\";\n\t\t\treadonly data?: string | undefined;\n\t\t\treadonly result?: string | undefined;\n\t };\n\ntype RemoteFormDecodedPayload<Output> = {\n\treadonly issues?: readonly FormIssue[];\n\treadonly result?: Output;\n};\n\nconst FormIssuePathSegmentSchema = Schema.Union([Schema.String, Schema.Number]);\n\nconst FormIssueSchema = Schema.Struct({\n\tmessage: Schema.String,\n\tpath: Schema.Array(FormIssuePathSegmentSchema),\n});\n\nconst RemoteFormErrorEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"error\"),\n\terror: Schema.optional(Schema.Unknown),\n\tstatus: Schema.optional(Schema.Number),\n});\n\nconst RemoteFormResultEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"result\"),\n\tdata: Schema.optional(Schema.String),\n\tresult: Schema.optional(Schema.String),\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\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\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n): Promise<Output> {\n\tconst action_id = get_remote_action_id(form_obj);\n\n\tif (!action_id || remote_base.length === 0) {\n\t\tthrow create_remote_transport_error(new RemoteFormEndpointMissingError());\n\t}\n\n\tconst response = await fetch(to_remote_form_url(remote_base, action_id), {\n\t\tmethod: \"POST\",\n\t\tbody: to_form_data(input),\n\t});\n\n\tif (!response.ok) {\n\t\tthrow await decode_response_failure(response);\n\t}\n\n\tconst envelope = await response.json();\n\n\treturn 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(form_obj: NativeFormRecord): string | undefined {\n\tconst action = form_obj.action;\n\n\tif (typeof action !== \"string\") {\n\t\treturn undefined;\n\t}\n\n\tconst fallback = \"http://localhost/\";\n\tconst href = typeof location === \"undefined\" ? fallback : location.href;\n\tconst url = new URL(action, href);\n\n\treturn url.searchParams.get(\"/remote\") ?? url.searchParams.get(\"remote\") ?? undefined;\n}\n\nfunction to_remote_form_url(remote_base: string, action_id: string): string {\n\tconst parts = action_id.split(\"/\");\n\tconst head = parts.slice(0, 2).join(\"/\");\n\tconst tail = parts.slice(2).join(\"/\");\n\tconst normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\tif (tail.length === 0) {\n\t\treturn `${normalized_base}/${head}`;\n\t}\n\n\treturn `${normalized_base}/${head}/${encodeURIComponent(tail)}`;\n}\n\nfunction decode_form_response<Output>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Output {\n\tconst response = decode_remote_form_response_envelope(envelope);\n\n\tif (!response) {\n\t\tthrow create_remote_transport_error(new InvalidRemoteFormResponseError(envelope), envelope);\n\t}\n\n\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\tconst decoded = decode_remote_error(response.error);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\tthrow decoded;\n\t\t}\n\n\t\tthrow create_remote_http_error(response.status ?? 500, response.error);\n\t}\n\n\tconst result_text = response.result ?? response.data;\n\n\tif (result_text === undefined) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tconst parsed = parse(result_text);\n\tconst decoded = decode_remote_form_payload<Output>(decode_payload(parsed));\n\n\tif (!decoded) {\n\t\tthrow create_remote_transport_error(\n\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\tenvelope,\n\t\t);\n\t}\n\n\tif (decoded.issues && decoded.issues.length > 0) {\n\t\tthrow create_remote_validation_error(decoded.issues, decoded, 400);\n\t}\n\n\treturn decoded.result as Output;\n}\n\nfunction decode_remote_form_response_envelope(\n\tenvelope: unknown,\n): RemoteFormResponseEnvelope | undefined {\n\tconst decoded = DecodeRemoteFormResponseEnvelope(envelope);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\tif (decoded.value.type === \"error\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormErrorEnvelope\",\n\t\t\terror: decoded.value.error,\n\t\t\tstatus: decoded.value.status,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t\tresult: decoded.value.result,\n\t};\n}\n\nfunction decode_remote_form_payload<Output>(\n\tpayload: unknown,\n): RemoteFormDecodedPayload<Output> | undefined {\n\tconst decoded = DecodeRemoteFormPayload(payload);\n\n\tif (!Option.isSome(decoded)) {\n\t\treturn undefined;\n\t}\n\n\treturn decoded.value as RemoteFormDecodedPayload<Output>;\n}\n","import { get_dispatcher } from \"$/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\nimport { MakeEffectFromPromise } 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\tcallback: NativeMethod | undefined,\n): NativeMethod | undefined {\n\tif (!callback) {\n\t\treturn undefined;\n\t}\n\n\treturn (event: unknown) => {\n\t\tconst wrapped_event = wrap_submit_callback<Output, ErrorType>(event);\n\t\tconst result = callback(wrapped_event);\n\n\t\tif (Effect.isEffect(result)) {\n\t\t\treturn get_dispatcher().run(result);\n\t\t}\n\n\t\treturn result;\n\t};\n}\n\nfunction wrap_submit_callback<Output, ErrorType>(event: unknown): unknown {\n\tif (typeof event !== \"object\" || event === null || !has_method(event, \"submit\")) {\n\t\treturn event;\n\t}\n\n\tconst original_submit = event.submit;\n\tconst { submit: _submit, ...descriptors } = Object.getOwnPropertyDescriptors(event);\n\n\tvoid _submit;\n\n\treturn Object.defineProperties(\n\t\t{},\n\t\t{\n\t\t\t...descriptors,\n\t\t\tsubmit: {\n\t\t\t\tconfigurable: true,\n\t\t\t\tenumerable: false,\n\t\t\t\tvalue: () => make_submit_effect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction make_submit_effect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = MakeEffectFromPromise<Output | undefined, ErrorType>(\n\t\tasync (): Promise<Output | undefined> => {\n\t\t\tconst result = original_submit();\n\t\t\tconst value =\n\t\t\t\tupdates_args && has_method(result, \"updates\")\n\t\t\t\t\t? await Promise.resolve(result.updates(...updates_args))\n\t\t\t\t\t: await Promise.resolve(result);\n\n\t\t\tif (typeof value === \"boolean\") {\n\t\t\t\treturn read_submit_result<Output>(event);\n\t\t\t}\n\n\t\t\treturn value as Output;\n\t\t},\n\t) as EffectRemoteFormSubmit<Output, ErrorType>;\n\n\tObject.defineProperty(SubmitEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn SubmitEffect;\n\t\t},\n\t});\n\n\treturn SubmitEffect;\n}\n\nfunction read_submit_result<Output>(event: unknown): Output | undefined {\n\tif (typeof event !== \"object\" || event === null || !(\"result\" in event)) {\n\t\treturn undefined;\n\t}\n\n\treturn Reflect.get(event, \"result\") as Output | undefined;\n}\n","import type { RemoteFormInput } from \"@sveltejs/kit\";\n\nimport { decode_response_or_value } from \"./responses.ts\";\nimport { MakeEffectFromPromise } 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 { EffectRemoteForm, NativeFormRecord, NativeMethod } 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\tInput extends RemoteFormInput | void,\n\tOutput,\n\tErrorType = never,\n>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base = \"\",\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\n\tconst submit_effect = (input?: RemoteInput<Input>) =>\n\t\tMakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\tconst can_use_remote_endpoint =\n\t\t\t\tremote_base.length > 0 && get_remote_action_id(form_obj) !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = await form_obj.submit(input);\n\n\t\t\t\treturn await decode_response_or_value<Output>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn await submit_remote_form<Output>(form_obj, input, decode_payload, remote_base);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => submit_effect(input)) as EffectRemoteForm<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType\n\t>;\n\n\tcopy_property_descriptors(\n\t\tform_obj,\n\t\tcallable,\n\t\tnew Set([\"submit\", \"validate\", \"enhance\", \"for\", \"preflight\"]),\n\t);\n\n\tObject.defineProperty(callable, \"submit\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: submit_effect,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tObject.defineProperty(callable, \"validate\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (options?: Record<string, unknown>) =>\n\t\t\t\tMakeEffectFromPromise<void, ErrorType>(async () => {\n\t\t\t\t\tawait form_obj.validate(options);\n\t\t\t\t}),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"enhance\")) {\n\t\tObject.defineProperty(callable, \"enhance\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (callback?: NativeMethod) =>\n\t\t\t\tform_obj.enhance(wrap_enhance_callback<Output, ErrorType>(callback)),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"for\")) {\n\t\tObject.defineProperty(callable, \"for\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (key: string | number | boolean) =>\n\t\t\t\tcreate_remote_form_adapter<Input, Output, ErrorType>(\n\t\t\t\t\tform_obj.for(key),\n\t\t\t\t\tdecode_payload,\n\t\t\t\t\tremote_base,\n\t\t\t\t),\n\t\t});\n\t}\n\n\tif (has_method(form_obj, \"preflight\")) {\n\t\tObject.defineProperty(callable, \"preflight\", {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: false,\n\t\t\tvalue: (schema: unknown) => {\n\t\t\t\tform_obj.preflight(schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn 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\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): Promise<Output> {\n\tif (has_method(value, \"then\")) {\n\t\tconst result = await Promise.resolve(value);\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tif (has_method(value, \"run\")) {\n\t\tconst result = await value.run();\n\n\t\treturn decode_response_or_value(result, decode_payload);\n\t}\n\n\tconst result = await Promise.resolve(value);\n\n\treturn decode_response_or_value(result, decode_payload);\n}\n","import { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } 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 { MakeEffectFromPromise } from \"./effect.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { make_remote_live_stream, type RemoteLiveStream } from \"$/live.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\t| ((input: RemoteInput<Input>) => unknown)\n\t| {\n\t\t\treadonly load: (input: RemoteInput<Input>) => unknown;\n\t };\n\ntype RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<\n\tOutput,\n\tRemoteFailure<ErrorType>\n> & {\n\treadonly current: Output | undefined;\n\treadonly error: unknown;\n\treadonly loading: boolean;\n\treadonly ready: boolean;\n};\n\ntype RemoteResourceLike<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType>;\n\ntype RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {\n\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\treadonly set: (value: Output) => void;\n\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n};\n\ntype NativeRemoteResource<Output> = {\n\treadonly current?: Output;\n\treadonly error?: unknown;\n\treadonly loading?: boolean;\n\treadonly ready?: boolean;\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\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<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: DecodePayload<Output>,\n\t_base?: string,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: NativeQueryFactory<Input>,\n\tdecode_payload: (value: unknown) => unknown,\n\t_base?: string,\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\nexport function create_remote_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: DecodePayload<Output>,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>) {\n\tconst load = has_method(native_factory, \"load\") ? native_factory.load : undefined;\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query && !load) {\n\t\tthrow new InvalidQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tif (!query) {\n\t\t\treturn MakeEffectFromPromise<Output, ErrorType>(async () => {\n\t\t\t\tconst result = await load?.(input);\n\n\t\t\t\treturn await resolve_query_result<Output>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = query(input);\n\t\tconst QueryEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\tasync () => await resolve_query_result<Output>(resource, decode_payload),\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_query_resource(resource, QueryEffect);\n\n\t\treturn QueryEffect;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n\n/**\n * Creates a remote live query adapter. The returned function takes input and\n * returns an Effect Stream whose transport state is exposed through `Live`.\n *\n * @example\n * ```ts\n * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);\n * const time = getTime();\n * const first = yield* Stream.runHead(time);\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 a remote live stream.\n * @internal\n */\nexport function create_remote_live_query_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\t_decode_payload: (value: unknown) => unknown,\n\t_base = \"\",\n): EffectRemoteQueryUpdateBrand &\n\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>) {\n\tconst query =\n\t\ttypeof native_factory === \"function\" ? (native_factory as NativeMethod) : undefined;\n\n\tif (!query) {\n\t\tthrow new InvalidLiveQueryFactoryError();\n\t}\n\n\tconst wrapped = ((input: Input) => {\n\t\tconst resource = query(input);\n\n\t\treturn make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n\nfunction is_resource<Output>(resource: unknown): resource is NativeRemoteResource<Output> {\n\tconst resource_type = typeof resource;\n\n\treturn (resource_type === \"object\" && resource !== null) || resource_type === \"function\";\n}\n\nfunction attach_resource_getters<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteResourceLike<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tfor (const key of keys) {\n\t\tif (!(key in methods)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tObject.defineProperty(effect, key, {\n\t\t\tconfigurable: true,\n\t\t\tget: () => methods[key],\n\t\t});\n\t}\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_resource<Output>(resource) ? resource : undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n"],"mappings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;GACd,WAAW,QAAQ;EACpB,CAAC;CACF;AACD;AAEA,SAAS,sBACR,UACA,QACO;CACP,MAAM,UAAU,YAAoB,QAAQ,IAAI,WAAW,KAAA;CAC3D,MAAM,UAAU,SAAS;CACzB,MAAM,MAAM,SAAS;CACrB,MAAM,gBAAgB,SAAS;CAE/B,wBAAwB,UAAU,MAAM;CAExC,IAAI,CAAC,SACJ;CAGD,IAAI,OAAO,YAAY,YACtB,OAAO,eAAe,QAAQ,WAAW;EACxC,cAAc;EACd,aAAa,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;CACjF,CAAC;CAGF,IAAI,OAAO,QAAQ,YAClB,OAAO,eAAe,QAAQ,OAAO;EACpC,cAAc;EACd,QAAQ,UAAkB,IAAI,KAAK,UAAU,KAAK;CACnD,CAAC;CAGF,IAAI,OAAO,kBAAkB,YAC5B,OAAO,eAAe,QAAQ,gBAAgB;EAC7C,cAAc;EACd,QAAQ,WAAwC,cAAc,KAAK,UAAU,MAAM;CACpF,CAAC;AAEH"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as DispatcherDisposedError, v as RuntimeAlreadyInitializedError } from "./errors-Bl3NVEez.js";
|
|
2
2
|
import { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime } from "effect";
|
|
3
3
|
import { createSubscriber } from "svelte/reactivity";
|
|
4
4
|
import { isRedirect } from "@sveltejs/kit";
|
|
@@ -502,4 +502,4 @@ function reset_dispatcher() {
|
|
|
502
502
|
//#endregion
|
|
503
503
|
export { Code as i, get_dispatcher as n, reset_dispatcher as r, Dispatcher as t };
|
|
504
504
|
|
|
505
|
-
//# sourceMappingURL=dispatcher-
|
|
505
|
+
//# sourceMappingURL=dispatcher-BdvO4AAS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-pHH4JcFR.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\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\n\n/**\n * Callbacks fired when a watched dispatcher fiber completes.\n *\n * @example\n * ```ts\n * const callbacks: FiberWatchCallbacks<number> = {\n * on_success: (value) => cache.set(key, value),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\n/**\n * Interrupts a dispatcher fiber through its managed runtime.\n *\n * @example\n * ```ts\n * interrupt_fiber(runtime, fiber);\n * ```\n *\n * @since 2.0.0\n * @param runtime - Managed runtime that owns the fiber.\n * @param fiber - Fiber to interrupt.\n * @returns Nothing.\n * @internal\n */\nexport function interrupt_fiber(\n\truntime: ManagedRuntimeType<unknown, unknown>,\n\tfiber: FiberType<unknown, unknown>,\n): void {\n\truntime.runFork(Fiber.interrupt(fiber) as Effect.Effect<unknown, unknown, unknown>);\n}\n\n/**\n * Watches a dispatcher fiber, runs completion callbacks, and surfaces\n * non-interrupt failures on the microtask queue.\n *\n * @example\n * ```ts\n * watch_fiber_exit({ runtime, fiber, on_complete: cleanup });\n * ```\n *\n * @since 2.0.0\n * @param options - Runtime, fiber, and callbacks used for the watcher.\n * @returns Nothing.\n * @internal\n */\nexport function watch_fiber_exit<A>(\n\toptions: {\n\t\truntime: ManagedRuntimeType<unknown, unknown>;\n\t\tfiber: FiberType<unknown, unknown>;\n\t} & FiberWatchCallbacks<A>,\n): void {\n\tconst { runtime, fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\truntime.runFork(\n\t\tEffect.flatMap(Fiber.await(fiber), (exit) =>\n\t\t\tEffect.sync(() => {\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\t\ton_complete?.();\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\t\ton_failure?.(error);\n\n\t\t\t\t\tif (surface_failure) {\n\t\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ton_complete?.();\n\t\t\t}),\n\t\t),\n\t);\n}\n","const object_dep_ids = new WeakMap<object, number>();\nconst symbol_dep_ids = new Map<symbol, number>();\n\nlet next_object_dep_id = 0;\nlet next_symbol_dep_id = 0;\n\n/**\n * Builds a deterministic cache key from a dependency array.\n *\n * @example\n * ```ts\n * const key = hash_deps([user_id, filters]);\n * ```\n *\n * @since 2.0.0\n * @param deps - Dependency array to encode for cache lookup.\n * @returns A structured string key suitable for Map lookups.\n * @internal\n */\nexport function hash_deps(deps: readonly unknown[]): string {\n\tconst parts = deps.map((dep) => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t});\n\n\treturn JSON.stringify(parts);\n}\n\nfunction hash_symbol_dep(dep: symbol): string {\n\tlet id = symbol_dep_ids.get(dep);\n\n\tif (id === undefined) {\n\t\tnext_symbol_dep_id += 1;\n\t\tid = next_symbol_dep_id;\n\t\tsymbol_dep_ids.set(dep, id);\n\t}\n\n\treturn `y:${id}`;\n}\n\nfunction hash_object_dep(dep: object): string {\n\tlet id = object_dep_ids.get(dep);\n\n\tif (id === undefined) {\n\t\tnext_object_dep_id += 1;\n\t\tid = next_object_dep_id;\n\t\tobject_dep_ids.set(dep, id);\n\t}\n\n\treturn `o:${id}`;\n}\n","import type { Effect } from \"effect\";\n\n/**\n * Stable operation codes used by transform-generated dispatcher events.\n *\n * @example\n * ```ts\n * const type = Code.Markup.Promise;\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @example\n * ```ts\n * const options: MarkupPromiseOptions = { ssr: \"pending\" };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\n/**\n * Minimal cleanup handle returned by dispatcher lifecycle hooks.\n *\n * @example\n * ```ts\n * const dispose: Dispose = dispatcher.fork(program);\n * dispose();\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport type Dispose = () => void;\n\n/**\n * Options for a cached dispatcher value block.\n *\n * @example\n * ```ts\n * const options: ValueOptions<number> = {\n * id: \"count\",\n * deps: [],\n * fallback: 0,\n * factory: () => Effect.succeed(1),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\t/** Reactive dependency array. */\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\t/** Generator function that yields the effect to run. */\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Options for a cached dispatcher promise block.\n *\n * @example\n * ```ts\n * const options: PromiseOptions<number> = {\n * id: \"count\",\n * deps: [],\n * factory: () => Effect.succeed(1),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\t/** Reactive dependency array. */\n\tdeps: readonly unknown[];\n\t/** Generator function that yields the effect to run. */\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Generated event that reads a markup expression through the cached value\n * channel.\n *\n * @example\n * ```ts\n * const event: MarkupValueEvent<number, undefined> = {\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupValueEvent<A, F> {\n\t/** Dispatcher code identifying a markup value read. */\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\t/** Reactive dependency array captured from free identifiers. */\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Generated event that reads a markup expression through the cached promise\n * channel.\n *\n * @example\n * ```ts\n * const event: MarkupPromiseEvent<number> = {\n * type: Code.Markup.Promise,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupPromiseEvent<A> {\n\t/** Dispatcher code identifying a markup promise read. */\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\t/** Reactive dependency array captured from free identifiers. */\n\tdeps: readonly unknown[];\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\n/**\n * Generated event that runs an event-handler Effect.\n *\n * @example\n * ```ts\n * const event: MarkupRunEvent<void> = {\n * type: Code.Markup.Run,\n * fn: function* () {\n * yield* Effect.void;\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupRunEvent<A> {\n\t/** Dispatcher code identifying a markup event-handler run. */\n\ttype: typeof Code.Markup.Run;\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Union of generated dispatcher events.\n *\n * @example\n * ```ts\n * const event: DispatcherEvent<number, undefined> = {\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime } from \"effect\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { isRedirect } from \"@sveltejs/kit\";\n\nimport { RuntimeAlreadyInitializedError, DispatcherDisposedError } from \"$/errors.ts\";\nimport { interrupt_fiber, watch_fiber_exit } from \"./fibers.ts\";\nimport { hash_deps } from \"./deps.ts\";\nimport { Code } from \"./types.ts\";\nimport type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\n/**\n * Unified effect block dispatcher. Manages the fiber lifecycle of every\n * effect block and wires results into reactive channels.\n *\n * @example\n * ```ts\n * const dispatcher = new Dispatcher();\n * const cancel = dispatcher.fork(Effect.log(\"running\"));\n * cancel();\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport class Dispatcher {\n\t/** The underlying Effect runtime that executes forked programs. */\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t/** Active fibers keyed by cache id or generated fork id. */\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t/** Reactive value cells keyed by value cache id. */\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t/** Notifies subscribed Svelte template effects when value cells change. */\n\t#notify_value_cells = (): void => {};\n\t/** Subscribes the current Svelte tracking scope to value cell changes. */\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t/** Pending promises keyed by promise cache id. */\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t/** Current cache key per value block id. */\n\t#value_ids = new Map<string, string>();\n\t/** Current cache key per promise block id. */\n\t#promise_ids = new Map<string, string>();\n\t/** Whether dispose has been called, blocking new work. */\n\t#disposed = false;\n\t/** Monotonically increasing counter for unnamed fiber keys. */\n\t#next_fiber_id = 0;\n\n\t/**\n\t * Creates a dispatcher with an optional layer and installs it as the global\n\t * singleton returned by {@link get_dispatcher}.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispatcher = Dispatcher.make(Db.Live);\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The newly created dispatcher.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\t/**\n\t * Creates a dispatcher backed by the provided managed runtime.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispatcher = new Dispatcher(runtime);\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param runtime - Managed runtime to use, or an empty-layer runtime when\n\t * omitted.\n\t */\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Handles a transform-generated dispatcher event.\n\t *\n\t * @example\n\t * ```ts\n\t * const value = dispatcher.emit({\n\t * type: Code.Markup.Value,\n\t * id: \"Component.svelte:1:2\",\n\t * deps: [],\n\t * fallback: undefined,\n\t * fn: function* () {\n\t * return yield* Effect.succeed(1);\n\t * },\n\t * });\n\t * ```\n\t *\n\t * @since 3.3.0\n\t * @param event - Generated event describing the dispatcher operation to run.\n\t * @returns The operation result for the emitted dispatcher event.\n\t */\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect as a managed fiber and returns a cleanup function.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispose = dispatcher.fork(Effect.log(\"clicked\"));\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param effect - Effect to fork.\n\t * @returns A function that interrupts the fiber.\n\t */\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\twatch_fiber_exit({\n\t\t\truntime: this.#runtime,\n\t\t\tfiber,\n\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t});\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tinterrupt_fiber(this.#runtime, fiber);\n\t\t};\n\t}\n\n\t/**\n\t * Forks an effect and exposes its result as a cached reactive value.\n\t *\n\t * @example\n\t * ```ts\n\t * const user = dispatcher.value({ id, deps, fallback, factory });\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param options - Value id, dependency array, fallback, and effect factory.\n\t * @returns The cached value if resolved, otherwise the fallback.\n\t */\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst cache_key = this.#make_value_cache_key(options.id, options.deps);\n\t\tconst old_key = this.#value_ids.get(options.id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tconst old_fiber = this.#interrupt_cached_fiber(old_key);\n\n\t\t\tthis.#clear_pending_value_cell(old_key, old_fiber);\n\t\t}\n\n\t\tthis.#value_ids.set(options.id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\t/**\n\t * Forks an effect and exposes its completion as a cached promise.\n\t *\n\t * @example\n\t * ```ts\n\t * const promise = dispatcher.promise({ id, deps, factory });\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param options - Promise id, dependency array, and effect factory.\n\t * @returns A promise that resolves with the effect result.\n\t */\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst cache_key = this.#make_promise_cache_key(options.id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(options.id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(options.id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\t/**\n\t * Runs an event-handler effect and surfaces failures to Svelte.\n\t *\n\t * @example\n\t * ```ts\n\t * await dispatcher.run(Effect.log(\"submit\"));\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param effect - Effect to execute.\n\t * @returns A promise that resolves or rejects when the effect completes.\n\t */\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst ExitProgram = Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>;\n\n\t\treturn this.#runtime.runPromise(ExitProgram).then((exit: unknown) => {\n\t\t\tconst result = exit as Exit.Exit<A, E>;\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\t/**\n\t * Cancels all running fibers and releases cached values.\n\t *\n\t * @example\n\t * ```ts\n\t * dispatcher.dispose();\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @returns Nothing.\n\t */\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tinterrupt_fiber(this.#runtime, fiber);\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tinterrupt_fiber(this.#runtime, old_fiber);\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst fiber = this.#runtime.runFork(Program as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\tqueueMicrotask(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\tstatus: \"pending\",\n\t\t\t\tfiber,\n\t\t\t});\n\t\t});\n\n\t\twatch_fiber_exit({\n\t\t\truntime: this.#runtime,\n\t\t\tfiber,\n\t\t\tsurface_failure: false,\n\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t});\n\t}\n\n\t#start_promise_fiber<A>(cache_key: string, options: PromiseOptions<A>): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst fiber = this.#runtime.runFork(Program as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\treturn this.#runtime.runPromise(\n\t\t\tEffect.flatMap(Fiber.await(fiber), (exit) =>\n\t\t\t\tEffect.sync(() => {\n\t\t\t\t\tconst is_current = this.#is_current_fiber(cache_key, fiber);\n\n\t\t\t\t\tif (is_current) {\n\t\t\t\t\t\tthis.#fibers.delete(cache_key);\n\t\t\t\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\t\t\t\tif (this.#promise_ids.get(options.id) === cache_key) {\n\t\t\t\t\t\t\tthis.#promise_ids.delete(options.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\t\treturn exit.value as A;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow Cause.squash(exit.cause);\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t}\n\n\t#clear_pending_value_cell(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown> | undefined,\n\t): void {\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (cell?.status !== \"pending\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (fiber !== undefined && cell.fiber !== fiber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#delete_value_cell(cache_key);\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\n/**\n * Resolves the active dispatcher, creating a default one if necessary.\n *\n * @example\n * ```ts\n * const dispatcher = get_dispatcher();\n * ```\n *\n * @since 2.0.0\n * @returns The active dispatcher singleton.\n * @internal\n */\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\n/**\n * Resets the internal singleton dispatcher used by source-level tests.\n *\n * @example\n * ```ts\n * reset_dispatcher();\n * ```\n *\n * @since 2.0.0\n * @returns Nothing.\n * @internal\n */\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,gBACf,SACA,OACO;CACP,QAAQ,QAAQ,MAAM,UAAU,KAAK,CAA6C;AACnF;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACf,SAIO;CACP,MAAM,EAAE,SAAS,OAAO,aAAa,YAAY,YAAY,kBAAkB,SAAS;CAExF,QAAQ,QACP,OAAO,QAAQ,MAAM,MAAM,KAAK,IAAI,SACnC,OAAO,WAAW;EACjB,IAAI,KAAK,UAAU,IAAI,GAAG;GACzB,aA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BAAkB,WAAW,KAAK,GAC3C;EAGD,KAAKC,gBAAgB,WAAW;GAC/B,QAAQ;GACR;EACD,CAAC;CACF;CAEA,gBAAgB,WAAmB,MAAgC;EAClE,KAAKZ,aAAa,IAAI,WAAW,IAAI;EACrC,KAAKX,oBAAoB;CAC1B;CAEA,mBAAmB,WAAyB;EAG3C,IAAI,CAFY,KAAKW,aAAa,OAAO,SAE9B,GACV;EAGD,KAAKX,oBAAoB;CAC1B;CAEA,qBAA2B;EAC1B,IAAI,KAAKW,aAAa,SAAS,GAC9B;EAGD,KAAKA,aAAa,MAAM;EACxB,KAAKX,oBAAoB;CAC1B;CAEA,kBAAkB,WAAmB,OAA6C;EACjF,OAAO,CAAC,KAAKK,aAAa,KAAKE,QAAQ,IAAI,SAAS,MAAM;CAC3D;AACD;AAEA,IAAI,qBAAwC;;;;;;;;;;;;;AAc5C,SAAgB,iBAA6B;CAC5C,uBAAuB,IAAI,WAAW;CAEtC,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAgB,mBAAyB;CACxC,oBAAoB,QAAQ;CAC5B,qBAAqB;AACtB"}
|
|
1
|
+
{"version":3,"file":"dispatcher-BdvO4AAS.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\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\n\n/**\n * Callbacks fired when a watched dispatcher fiber completes.\n *\n * @example\n * ```ts\n * const callbacks: FiberWatchCallbacks<number> = {\n * on_success: (value) => cache.set(key, value),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\n/**\n * Interrupts a dispatcher fiber through its managed runtime.\n *\n * @example\n * ```ts\n * interrupt_fiber(runtime, fiber);\n * ```\n *\n * @since 2.0.0\n * @param runtime - Managed runtime that owns the fiber.\n * @param fiber - Fiber to interrupt.\n * @returns Nothing.\n * @internal\n */\nexport function interrupt_fiber(\n\truntime: ManagedRuntimeType<unknown, unknown>,\n\tfiber: FiberType<unknown, unknown>,\n): void {\n\truntime.runFork(Fiber.interrupt(fiber) as Effect.Effect<unknown, unknown, unknown>);\n}\n\n/**\n * Watches a dispatcher fiber, runs completion callbacks, and surfaces\n * non-interrupt failures on the microtask queue.\n *\n * @example\n * ```ts\n * watch_fiber_exit({ runtime, fiber, on_complete: cleanup });\n * ```\n *\n * @since 2.0.0\n * @param options - Runtime, fiber, and callbacks used for the watcher.\n * @returns Nothing.\n * @internal\n */\nexport function watch_fiber_exit<A>(\n\toptions: {\n\t\truntime: ManagedRuntimeType<unknown, unknown>;\n\t\tfiber: FiberType<unknown, unknown>;\n\t} & FiberWatchCallbacks<A>,\n): void {\n\tconst { runtime, fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\truntime.runFork(\n\t\tEffect.flatMap(Fiber.await(fiber), (exit) =>\n\t\t\tEffect.sync(() => {\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\t\ton_complete?.();\n\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\t\ton_failure?.(error);\n\n\t\t\t\t\tif (surface_failure) {\n\t\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\t\tthrow error;\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\ton_complete?.();\n\t\t\t}),\n\t\t),\n\t);\n}\n","const object_dep_ids = new WeakMap<object, number>();\nconst symbol_dep_ids = new Map<symbol, number>();\n\nlet next_object_dep_id = 0;\nlet next_symbol_dep_id = 0;\n\n/**\n * Builds a deterministic cache key from a dependency array.\n *\n * @example\n * ```ts\n * const key = hash_deps([user_id, filters]);\n * ```\n *\n * @since 2.0.0\n * @param deps - Dependency array to encode for cache lookup.\n * @returns A structured string key suitable for Map lookups.\n * @internal\n */\nexport function hash_deps(deps: readonly unknown[]): string {\n\tconst parts = deps.map((dep) => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t});\n\n\treturn JSON.stringify(parts);\n}\n\nfunction hash_symbol_dep(dep: symbol): string {\n\tlet id = symbol_dep_ids.get(dep);\n\n\tif (id === undefined) {\n\t\tnext_symbol_dep_id += 1;\n\t\tid = next_symbol_dep_id;\n\t\tsymbol_dep_ids.set(dep, id);\n\t}\n\n\treturn `y:${id}`;\n}\n\nfunction hash_object_dep(dep: object): string {\n\tlet id = object_dep_ids.get(dep);\n\n\tif (id === undefined) {\n\t\tnext_object_dep_id += 1;\n\t\tid = next_object_dep_id;\n\t\tobject_dep_ids.set(dep, id);\n\t}\n\n\treturn `o:${id}`;\n}\n","import type { Effect } from \"effect\";\n\n/**\n * Stable operation codes used by transform-generated dispatcher events.\n *\n * @example\n * ```ts\n * const type = Code.Markup.Promise;\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @example\n * ```ts\n * const options: MarkupPromiseOptions = { ssr: \"pending\" };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\n/**\n * Minimal cleanup handle returned by dispatcher lifecycle hooks.\n *\n * @example\n * ```ts\n * const dispose: Dispose = dispatcher.fork(program);\n * dispose();\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport type Dispose = () => void;\n\n/**\n * Options for a cached dispatcher value block.\n *\n * @example\n * ```ts\n * const options: ValueOptions<number> = {\n * id: \"count\",\n * deps: [],\n * fallback: 0,\n * factory: () => Effect.succeed(1),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\t/** Reactive dependency array. */\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\t/** Generator function that yields the effect to run. */\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Options for a cached dispatcher promise block.\n *\n * @example\n * ```ts\n * const options: PromiseOptions<number> = {\n * id: \"count\",\n * deps: [],\n * factory: () => Effect.succeed(1),\n * };\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\t/** Reactive dependency array. */\n\tdeps: readonly unknown[];\n\t/** Generator function that yields the effect to run. */\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Generated event that reads a markup expression through the cached value\n * channel.\n *\n * @example\n * ```ts\n * const event: MarkupValueEvent<number, undefined> = {\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupValueEvent<A, F> {\n\t/** Dispatcher code identifying a markup value read. */\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\t/** Reactive dependency array captured from free identifiers. */\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Generated event that reads a markup expression through the cached promise\n * channel.\n *\n * @example\n * ```ts\n * const event: MarkupPromiseEvent<number> = {\n * type: Code.Markup.Promise,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupPromiseEvent<A> {\n\t/** Dispatcher code identifying a markup promise read. */\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\t/** Reactive dependency array captured from free identifiers. */\n\tdeps: readonly unknown[];\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\n/**\n * Generated event that runs an event-handler Effect.\n *\n * @example\n * ```ts\n * const event: MarkupRunEvent<void> = {\n * type: Code.Markup.Run,\n * fn: function* () {\n * yield* Effect.void;\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport interface MarkupRunEvent<A> {\n\t/** Dispatcher code identifying a markup event-handler run. */\n\ttype: typeof Code.Markup.Run;\n\t/** Generator function that yields the effect to run. */\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\n/**\n * Union of generated dispatcher events.\n *\n * @example\n * ```ts\n * const event: DispatcherEvent<number, undefined> = {\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * };\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime } from \"effect\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { isRedirect } from \"@sveltejs/kit\";\n\nimport { RuntimeAlreadyInitializedError, DispatcherDisposedError } from \"$/errors.ts\";\nimport { interrupt_fiber, watch_fiber_exit } from \"./fibers.ts\";\nimport { hash_deps } from \"./deps.ts\";\nimport { Code } from \"./types.ts\";\nimport type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\n/**\n * Unified effect block dispatcher. Manages the fiber lifecycle of every\n * effect block and wires results into reactive channels.\n *\n * @example\n * ```ts\n * const dispatcher = new Dispatcher();\n * const cancel = dispatcher.fork(Effect.log(\"running\"));\n * cancel();\n * ```\n *\n * @since 2.0.0\n * @internal\n */\nexport class Dispatcher {\n\t/** The underlying Effect runtime that executes forked programs. */\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t/** Active fibers keyed by cache id or generated fork id. */\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t/** Reactive value cells keyed by value cache id. */\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t/** Notifies subscribed Svelte template effects when value cells change. */\n\t#notify_value_cells = (): void => {};\n\t/** Subscribes the current Svelte tracking scope to value cell changes. */\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t/** Pending promises keyed by promise cache id. */\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t/** Current cache key per value block id. */\n\t#value_ids = new Map<string, string>();\n\t/** Current cache key per promise block id. */\n\t#promise_ids = new Map<string, string>();\n\t/** Whether dispose has been called, blocking new work. */\n\t#disposed = false;\n\t/** Monotonically increasing counter for unnamed fiber keys. */\n\t#next_fiber_id = 0;\n\n\t/**\n\t * Creates a dispatcher with an optional layer and installs it as the global\n\t * singleton returned by {@link get_dispatcher}.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispatcher = Dispatcher.make(Db.Live);\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The newly created dispatcher.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\t/**\n\t * Creates a dispatcher backed by the provided managed runtime.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispatcher = new Dispatcher(runtime);\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param runtime - Managed runtime to use, or an empty-layer runtime when\n\t * omitted.\n\t */\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Handles a transform-generated dispatcher event.\n\t *\n\t * @example\n\t * ```ts\n\t * const value = dispatcher.emit({\n\t * type: Code.Markup.Value,\n\t * id: \"Component.svelte:1:2\",\n\t * deps: [],\n\t * fallback: undefined,\n\t * fn: function* () {\n\t * return yield* Effect.succeed(1);\n\t * },\n\t * });\n\t * ```\n\t *\n\t * @since 3.3.0\n\t * @param event - Generated event describing the dispatcher operation to run.\n\t * @returns The operation result for the emitted dispatcher event.\n\t */\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect as a managed fiber and returns a cleanup function.\n\t *\n\t * @example\n\t * ```ts\n\t * const dispose = dispatcher.fork(Effect.log(\"clicked\"));\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param effect - Effect to fork.\n\t * @returns A function that interrupts the fiber.\n\t */\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\twatch_fiber_exit({\n\t\t\truntime: this.#runtime,\n\t\t\tfiber,\n\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t});\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tinterrupt_fiber(this.#runtime, fiber);\n\t\t};\n\t}\n\n\t/**\n\t * Forks an effect and exposes its result as a cached reactive value.\n\t *\n\t * @example\n\t * ```ts\n\t * const user = dispatcher.value({ id, deps, fallback, factory });\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param options - Value id, dependency array, fallback, and effect factory.\n\t * @returns The cached value if resolved, otherwise the fallback.\n\t */\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst cache_key = this.#make_value_cache_key(options.id, options.deps);\n\t\tconst old_key = this.#value_ids.get(options.id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tconst old_fiber = this.#interrupt_cached_fiber(old_key);\n\n\t\t\tthis.#clear_pending_value_cell(old_key, old_fiber);\n\t\t}\n\n\t\tthis.#value_ids.set(options.id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\t/**\n\t * Forks an effect and exposes its completion as a cached promise.\n\t *\n\t * @example\n\t * ```ts\n\t * const promise = dispatcher.promise({ id, deps, factory });\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param options - Promise id, dependency array, and effect factory.\n\t * @returns A promise that resolves with the effect result.\n\t */\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst cache_key = this.#make_promise_cache_key(options.id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(options.id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(options.id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\t/**\n\t * Runs an event-handler effect and surfaces failures to Svelte.\n\t *\n\t * @example\n\t * ```ts\n\t * await dispatcher.run(Effect.log(\"submit\"));\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @param effect - Effect to execute.\n\t * @returns A promise that resolves or rejects when the effect completes.\n\t */\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst ExitProgram = Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>;\n\n\t\treturn this.#runtime.runPromise(ExitProgram).then((exit: unknown) => {\n\t\t\tconst result = exit as Exit.Exit<A, E>;\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\n\t\t\tthrow error;\n\t\t});\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\t/**\n\t * Cancels all running fibers and releases cached values.\n\t *\n\t * @example\n\t * ```ts\n\t * dispatcher.dispose();\n\t * ```\n\t *\n\t * @since 2.0.0\n\t * @returns Nothing.\n\t */\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tinterrupt_fiber(this.#runtime, fiber);\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tinterrupt_fiber(this.#runtime, old_fiber);\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst fiber = this.#runtime.runFork(Program as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\tqueueMicrotask(() => {\n\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\tstatus: \"pending\",\n\t\t\t\tfiber,\n\t\t\t});\n\t\t});\n\n\t\twatch_fiber_exit({\n\t\t\truntime: this.#runtime,\n\t\t\tfiber,\n\t\t\tsurface_failure: false,\n\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t});\n\t}\n\n\t#start_promise_fiber<A>(cache_key: string, options: PromiseOptions<A>): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst fiber = this.#runtime.runFork(Program as Effect.Effect<unknown, unknown, unknown>);\n\n\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\treturn this.#runtime.runPromise(\n\t\t\tEffect.flatMap(Fiber.await(fiber), (exit) =>\n\t\t\t\tEffect.sync(() => {\n\t\t\t\t\tconst is_current = this.#is_current_fiber(cache_key, fiber);\n\n\t\t\t\t\tif (is_current) {\n\t\t\t\t\t\tthis.#fibers.delete(cache_key);\n\t\t\t\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\t\t\t\tif (this.#promise_ids.get(options.id) === cache_key) {\n\t\t\t\t\t\t\tthis.#promise_ids.delete(options.id);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\n\t\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\t\treturn exit.value as A;\n\t\t\t\t\t}\n\n\t\t\t\t\tthrow Cause.squash(exit.cause);\n\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t}\n\n\t#clear_pending_value_cell(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown> | undefined,\n\t): void {\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (cell?.status !== \"pending\") {\n\t\t\treturn;\n\t\t}\n\n\t\tif (fiber !== undefined && cell.fiber !== fiber) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#delete_value_cell(cache_key);\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\n/**\n * Resolves the active dispatcher, creating a default one if necessary.\n *\n * @example\n * ```ts\n * const dispatcher = get_dispatcher();\n * ```\n *\n * @since 2.0.0\n * @returns The active dispatcher singleton.\n * @internal\n */\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\n/**\n * Resets the internal singleton dispatcher used by source-level tests.\n *\n * @example\n * ```ts\n * reset_dispatcher();\n * ```\n *\n * @since 2.0.0\n * @returns Nothing.\n * @internal\n */\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsCA,SAAgB,gBACf,SACA,OACO;CACP,QAAQ,QAAQ,MAAM,UAAU,KAAK,CAA6C;AACnF;;;;;;;;;;;;;;;AAgBA,SAAgB,iBACf,SAIO;CACP,MAAM,EAAE,SAAS,OAAO,aAAa,YAAY,YAAY,kBAAkB,SAAS;CAExF,QAAQ,QACP,OAAO,QAAQ,MAAM,MAAM,KAAK,IAAI,SACnC,OAAO,WAAW;EACjB,IAAI,KAAK,UAAU,IAAI,GAAG;GACzB,aAAa,KAAK,KAAU;GAC5B,cAAc;GAEd;EACD;EAEA,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK,GAAG;GACzC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;GAErC,aAAa,KAAK;GAElB,IAAI,iBACH,qBAAqB;IACpB,MAAM;GACP,CAAC;EAEH;EAEA,cAAc;CACf,CAAC,CACF,CACD;AACD;;;AC7FA,MAAM,iCAAiB,IAAI,QAAwB;AACnD,MAAM,iCAAiB,IAAI,IAAoB;AAE/C,IAAI,qBAAqB;AACzB,IAAI,qBAAqB;;;;;;;;;;;;;;AAezB,SAAgB,UAAU,MAAkC;CAC3D,MAAM,QAAQ,KAAK,KAAK,QAAQ;EAC/B,IAA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AAa,KAAKE,QAAQ,IAAI,SAAS,MAAM;CAC3D;AACD;AAEA,IAAI,qBAAwC;;;;;;;;;;;;;AAc5C,SAAgB,iBAA6B;CAC5C,uBAAuB,IAAI,WAAW;CAEtC,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAgB,mBAAyB;CACxC,oBAAoB,QAAQ;CAC5B,qBAAqB;AACtB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as get_dispatcher$1 } from "./dispatcher-
|
|
2
|
-
import { r as get_server_dispatcher } from "./runtime-
|
|
1
|
+
import { n as get_dispatcher$1 } from "./dispatcher-BdvO4AAS.js";
|
|
2
|
+
import { r as get_server_dispatcher } from "./runtime-BNNW2GDT.js";
|
|
3
3
|
//#region src/generated/dispatcher.ts
|
|
4
4
|
/**
|
|
5
5
|
* Facade used by transform-generated component code to dispatch runtime
|
|
@@ -44,4 +44,4 @@ function get_dispatcher() {
|
|
|
44
44
|
//#endregion
|
|
45
45
|
export { get_dispatcher as n, Dispatcher as t };
|
|
46
46
|
|
|
47
|
-
//# sourceMappingURL=dispatcher-
|
|
47
|
+
//# sourceMappingURL=dispatcher-NpL5xhWF.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-
|
|
1
|
+
{"version":3,"file":"dispatcher-NpL5xhWF.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\";\nimport { get_server_dispatcher } from \"$/server/runtime.ts\";\nimport type {\n\tDispatcher as RuntimeDispatcher,\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\nexport { Code } from \"$/dispatcher.ts\";\nexport type {\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupPromiseOptions,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\n/**\n * Facade used by transform-generated component code to dispatch runtime\n * events through the current client or server dispatcher.\n *\n * @example\n * ```ts\n * const value = Dispatcher.emit({\n * type: Code.Markup.Value,\n * id: \"Component.svelte:1:2\",\n * deps: [],\n * fallback: undefined,\n * fn: function* () {\n * return yield* Effect.succeed(1);\n * },\n * });\n * ```\n *\n * @since 3.3.0\n * @internal\n */\nexport class Dispatcher {\n\t/**\n\t * Emits a transform-generated dispatcher event.\n\t *\n\t * @example\n\t * ```ts\n\t * const promise = Dispatcher.emit({\n\t * type: Code.Markup.Promise,\n\t * id: \"Component.svelte:1:2\",\n\t * deps: [],\n\t * fn: function* () {\n\t * return yield* Effect.succeed(1);\n\t * },\n\t * });\n\t * ```\n\t *\n\t * @since 3.3.0\n\t * @param event - Generated event describing the dispatcher operation to run.\n\t * @returns The result produced by the active dispatcher.\n\t */\n\tstatic emit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\tstatic emit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\tstatic emit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\tstatic emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\tstatic emit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\treturn get_dispatcher().emit(event);\n\t}\n}\n\n/**\n * Returns the dispatcher appropriate for generated component code.\n *\n * @example\n * ```ts\n * const dispatcher = get_dispatcher();\n * ```\n *\n * @since 3.0.1\n * @returns The server dispatcher during SSR, otherwise the client dispatcher.\n */\nexport function get_dispatcher(): RuntimeDispatcher {\n\tif (typeof document === \"undefined\") {\n\t\treturn get_server_dispatcher();\n\t}\n\n\treturn get_client_dispatcher();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuCA,IAAa,aAAb,MAAwB;CAwBvB,OAAO,KAAW,OAAkD;EACnE,OAAO,eAAe,CAAC,CAAC,KAAK,KAAK;CACnC;AACD;;;;;;;;;;;;AAaA,SAAgB,iBAAoC;CACnD,IAAI,OAAO,aAAa,aACvB,OAAO,sBAAsB;CAG9B,OAAOA,iBAAsB;AAC9B"}
|
|
@@ -431,11 +431,29 @@ var UncheckedPrerenderHandlerMissingError = class extends RuntimeError {
|
|
|
431
431
|
*/
|
|
432
432
|
var InvalidLiveQueryReturnError = class extends RuntimeError {
|
|
433
433
|
constructor() {
|
|
434
|
-
super("Query.live handler must return an Effect Stream
|
|
434
|
+
super("Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.");
|
|
435
435
|
this.name = "InvalidLiveQueryReturnError";
|
|
436
436
|
}
|
|
437
437
|
};
|
|
438
438
|
/**
|
|
439
|
+
* Thrown when generated component code yields a Stream that completes before
|
|
440
|
+
* producing a value.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* ```ts
|
|
444
|
+
* throw new EmptyStreamYieldError();
|
|
445
|
+
* ```
|
|
446
|
+
*
|
|
447
|
+
* @since 3.4.8
|
|
448
|
+
* @returns An Error describing an empty Stream in a value position.
|
|
449
|
+
*/
|
|
450
|
+
var EmptyStreamYieldError = class extends RuntimeError {
|
|
451
|
+
constructor() {
|
|
452
|
+
super("Cannot resolve yield* stream expression because the Stream completed without emitting a value.");
|
|
453
|
+
this.name = "EmptyStreamYieldError";
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
439
457
|
* Thrown when a dispatcher operation is requested after disposal.
|
|
440
458
|
*
|
|
441
459
|
* @example
|
|
@@ -743,6 +761,6 @@ var UnknownRuntimeError = class extends RuntimeError {
|
|
|
743
761
|
}
|
|
744
762
|
};
|
|
745
763
|
//#endregion
|
|
746
|
-
export {
|
|
764
|
+
export { VitePreTransformPluginConflictError as A, UncheckedFormHandlerMissingError as C, UnknownRuntimeError as D, UncheckedQueryHandlerMissingError as E, UnsupportedMarkupEffectPositionError as O, UncheckedCommandHandlerMissingError as S, UncheckedPrerenderHandlerMissingError as T, RequestEventUnavailableError as _, DispatcherDisposedError as a, ServerOnlyImportError as b, InvalidLiveQueryFactoryError as c, InvalidRemoteFormResponseError as d, PreprocessError as f, RemoteHelperError as g, RemoteHelperContextError as h, BatchQueryHandlerMissingError as i, YieldStarInEventCallbackError as j, UnsupportedRemoteFormResponseError as k, InvalidLiveQueryReturnError as l, RemoteFormEndpointMissingError as m, AsyncEffectInSyncRuneError as n, EmptyStreamYieldError as o, RemoteErrorDecodeError as p, AwaitInEffectWorkError as r, InvalidCommandFactoryError as s, AsyncEffectInEventCallbackError as t, InvalidQueryFactoryError as u, RuntimeAlreadyInitializedError as v, UncheckedLiveQueryHandlerMissingError as w, SvelteKitServerExportUnavailableError as x, RuntimeError as y };
|
|
747
765
|
|
|
748
|
-
//# sourceMappingURL=errors-
|
|
766
|
+
//# sourceMappingURL=errors-Bl3NVEez.js.map
|