svelte-effect-runtime 4.2.3 → 4.2.4
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-D-u6MNHj.js → client-CpWfP_1f.js} +2 -2
- package/.dist/chunks/{client-D-u6MNHj.js.map → client-CpWfP_1f.js.map} +1 -1
- package/.dist/chunks/{dispatcher-B75hLhx3.js → dispatcher-BFTvQ7sm.js} +3 -3
- package/.dist/chunks/{dispatcher-B75hLhx3.js.map → dispatcher-BFTvQ7sm.js.map} +1 -1
- package/.dist/chunks/{dispatcher-DGSStOLQ.js → dispatcher-D3Tpa5HC.js} +24 -16
- package/.dist/chunks/dispatcher-D3Tpa5HC.js.map +1 -0
- package/.dist/chunks/{runtime-D4a2CqmT.js → runtime-CmiEHnSw.js} +2 -2
- package/.dist/chunks/{runtime-D4a2CqmT.js.map → runtime-CmiEHnSw.js.map} +1 -1
- package/.dist/dispatcher/index.d.ts +4 -4
- package/.dist/dispatcher/scope.d.ts +10 -1
- package/.dist/dispatcher.js +1 -1
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.js +1 -1
- package/.dist/remote/client.js +1 -1
- package/.dist/server.js +1 -1
- package/package.json +1 -1
- package/.dist/chunks/dispatcher-DGSStOLQ.js.map +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as InvalidLiveQueryFactoryError, d as InvalidQueryFactoryError, f as InvalidRemoteFormResponseError, g as RemoteFormEndpointMissingError, j as UnsupportedRemoteFormResponseError, s as InvalidCommandFactoryError, u as InvalidPrerenderFactoryError } from "./errors-qhcbUH6o.js";
|
|
2
|
-
import { r as get_dispatcher } from "./dispatcher-
|
|
2
|
+
import { r as get_dispatcher } from "./dispatcher-D3Tpa5HC.js";
|
|
3
3
|
import { create_remote_http_error, create_remote_transport_error, create_remote_validation_error } from "../remote/shared.js";
|
|
4
4
|
import { i as make_remote_live_stream, r as make_failed_remote_live_stream } from "./live-BW7xZKjb.js";
|
|
5
5
|
import { a as normalize_validator, c as attach_remote_resource_getters, d as MakeEffectFromPromise, f as MakeEffectFromSync, h as normalize_native_error, i as is_standard_schema, l as is_remote_resource, m as is_decoded_remote_failure, n as attach_native_remote_query_update, o as attach_failed_remote_query_resource, p as decode_remote_error, r as resolve_native_remote_query_updates, s as attach_failed_remote_resource_getters, t as copy_property_descriptors, u as FailWithRemoteError } from "./descriptors-q909VWyR.js";
|
|
@@ -527,4 +527,4 @@ const RefreshRemoteResource = (resource, refresh) => Effect.gen(function* () {
|
|
|
527
527
|
//#endregion
|
|
528
528
|
export { create_remote_command_adapter as a, create_remote_form_adapter as i, create_remote_query_adapter as n, create_remote_prerender_adapter as r, create_remote_live_query_adapter as t };
|
|
529
529
|
|
|
530
|
-
//# sourceMappingURL=client-
|
|
530
|
+
//# sourceMappingURL=client-CpWfP_1f.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-D-u6MNHj.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.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/prerender.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\nexport function has_method<K extends PropertyKey>(\n\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nexport const DecodeResponseFailure = <ErrorType = never>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tconst body = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json()).pipe(\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\treturn decoded as RemoteFailure<ErrorType>;\n\t\t}\n\n\t\treturn create_remote_http_error(response.status, body);\n\t});\n\nexport const DecodeResponseOrValue = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (value instanceof Response) {\n\t\t\tif (!value.ok) {\n\t\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(value);\n\n\t\t\t\treturn yield* Effect.fail(failure);\n\t\t\t}\n\n\t\t\tconst data = yield* DecodeSuccessResponseBody<ErrorType>(value);\n\n\t\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(\n\t\t\t\t() => decode_payload(data) as Output,\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(() => decode_payload(value) as Output);\n\t});\n\nconst DecodeSuccessResponseBody = <ErrorType>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tif (response.status === 204 || response.status === 205) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = yield* MakeEffectFromPromise<string, ErrorType>(() => response.text());\n\n\t\tif (text.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<unknown, ErrorType>(() => JSON.parse(text));\n\t});\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { EffectRemoteCommandCall, NativeMethod, Pending } from \"./types.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => EffectRemoteCommandCall<Output, ErrorType>) & {\n\treadonly pending: number;\n};\n\n/** Adapts a generated SvelteKit command to SER's Effect-based client ABI. */\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\tMakeCommandEffect<Input, Output, ErrorType>(\n\t\t\tnative_factory,\n\t\t\tinvoke,\n\t\t\tinput,\n\t\t\tdecode_payload,\n\t\t\tcount,\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\nconst MakeCommandEffect = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tpending: Pending,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.acquireUseRelease(\n\t\tAcquirePending(pending),\n\t\t() =>\n\t\t\tInvokeCommand<Input, Output, ErrorType>(\n\t\t\t\tnative_factory,\n\t\t\t\tinvoke,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\t() => updates_args,\n\t\t\t),\n\t\t() => ReleasePending(pending),\n\t) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nconst AcquirePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value += 1;\n\t});\n\nconst ReleasePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value -= 1;\n\t});\n\nconst InvokeCommand = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tread_updates_args: () => unknown[] | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = invoke\n\t\t\t\t? invoke.call(native_factory, input)\n\t\t\t\t: (native_factory as NativeMethod)(input);\n\t\t\tconst updates_args = read_updates_args();\n\n\t\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(invocation),\n\t\t);\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t});\n","export 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 [index, item] of value.entries()) {\n\t\t\tappend_form_value(form_data, `${path}[${index}]`, 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\tform_data.append(`b:${path}`, value ? \"on\" : \"off\");\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { StandardSchema } from \"$/internal/schema.ts\";\nimport { DecodeResponseFailure } from \"./responses.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\nimport { Effect, Option, Schema } from \"effect\";\nimport { to_form_data } from \"./form-data.ts\";\nimport { parse } from \"devalue\";\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;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormRedirectEnvelope\";\n\t\t\treadonly location: string;\n\t };\n\nexport interface RemoteFormTransport {\n\treadonly binary_form_content_type?: string;\n\treadonly decoders?: Record<string, (value: unknown) => unknown>;\n\treadonly navigate?: (location: string, invalidate_all: boolean) => PromiseLike<void> | void;\n\treadonly remote_request?: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly refresh?: () => PromiseLike<void> | void;\n\treadonly serialize_binary_form?: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ninterface KitRemoteFormTransport extends RemoteFormTransport {\n\treadonly binary_form_content_type: string;\n\treadonly remote_request: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly serialize_binary_form: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\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.String,\n});\n\nconst RemoteFormRedirectEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"redirect\"),\n\tlocation: Schema.String,\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n\tRemoteFormRedirectEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst RemoteFormRedirectDataSchema = Schema.Struct({\n\tredirect: Schema.String,\n});\n\nconst RemoteFormResultDataSchema = Schema.Struct({\n\t_: Schema.Unknown,\n});\n\nconst KitRemoteFormDataSchema = Schema.Struct({\n\t_: Schema.optional(Schema.Unknown),\n\tredirect: Schema.optional(Schema.String),\n\tr: Schema.optional(Schema.Literal(true)),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\nconst DecodeRemoteFormRedirectData = Schema.decodeUnknownOption(RemoteFormRedirectDataSchema);\nconst DecodeRemoteFormResultData = Schema.decodeUnknownOption(RemoteFormResultDataSchema);\nconst DecodeKitRemoteFormData = Schema.decodeUnknownOption(KitRemoteFormDataSchema);\n\nexport const SubmitRemoteForm = <Output, ErrorType = never>(\n\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: RemoteFormTransport,\n\tpreflight_schema?: StandardSchema,\n) =>\n\tEffect.gen(function* () {\n\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\tget_remote_action_id(form_obj),\n\t\t);\n\n\t\tif (!action_id || remote_base.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new RemoteFormEndpointMissingError()),\n\t\t\t);\n\t\t}\n\n\t\tyield* ValidatePreflightInput<ErrorType>(preflight_schema, input);\n\n\t\tif (is_kit_remote_form_transport(remote_transport)) {\n\t\t\treturn yield* SubmitRemoteFormWithKit<Output, ErrorType>(\n\t\t\t\taction_id,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t);\n\t\t}\n\n\t\tconst response = yield* MakeEffectFromPromise<Response, ErrorType>((signal) =>\n\t\t\tfetch(to_remote_form_url(remote_base, action_id), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: get_remote_request_headers(),\n\t\t\t\tbody: to_form_data(to_remote_form_input(input, action_id)),\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(response);\n\n\t\t\treturn yield* Effect.fail(failure);\n\t\t}\n\n\t\tconst envelope = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json());\n\n\t\treturn yield* DecodeFormResponse<Output, ErrorType>(\n\t\t\tenvelope,\n\t\t\tdecode_payload,\n\t\t\tremote_transport,\n\t\t);\n\t});\n\nconst SubmitRemoteFormWithKit = <Output, ErrorType>(\n\taction_id: string,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: KitRemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst url = to_remote_form_url(remote_base, action_id);\n\t\tconst body = yield* MakeEffectFromSync<Blob, ErrorType>(\n\t\t\t() =>\n\t\t\t\tremote_transport.serialize_binary_form(to_remote_form_input(input, action_id), {\n\t\t\t\t\tremote_refreshes: [],\n\t\t\t\t}).blob,\n\t\t);\n\t\tconst data = yield* MakeEffectFromPromise<unknown, ErrorType>((signal) =>\n\t\t\tremote_transport.remote_request(url, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t...get_remote_request_headers(),\n\t\t\t\t\t\"Content-Type\": remote_transport.binary_form_content_type,\n\t\t\t\t},\n\t\t\t\tbody,\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\treturn yield* DecodeKitFormData<Output, ErrorType>(data, decode_payload, remote_transport);\n\t});\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 normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\treturn `${normalized_base}/${head}`;\n}\n\nfunction to_remote_form_input(input: unknown, action_id: string): Record<string, unknown> {\n\tconst data = is_record(input) ? input : {};\n\tconst serialized_key = action_id.split(\"/\").slice(2).join(\"/\");\n\tconst key: unknown = serialized_key.length === 0 ? undefined : JSON.parse(serialized_key);\n\n\tif (key === undefined || data.id !== undefined) {\n\t\treturn data;\n\t}\n\n\treturn {\n\t\t...data,\n\t\tid: key,\n\t};\n}\n\nfunction get_remote_request_headers(): Record<string, string> {\n\tif (typeof location === \"undefined\") {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t\"x-sveltekit-pathname\": location.pathname,\n\t\t\"x-sveltekit-search\": location.search,\n\t};\n}\n\nconst ValidatePreflightInput = <ErrorType>(schema: StandardSchema | undefined, input: unknown) =>\n\tEffect.gen(function* () {\n\t\tif (!schema) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst validated = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(schema[\"~standard\"].validate(input)),\n\t\t);\n\n\t\tif (!is_record(validated) || !Array.isArray(validated.issues)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst issues = validated.issues.map(normalize_standard_issue);\n\n\t\treturn yield* Effect.fail(create_remote_validation_error(issues, { issues }, 400));\n\t});\n\nfunction normalize_standard_issue(issue: unknown): FormIssue {\n\tif (!is_record(issue)) {\n\t\treturn { message: String(issue), path: [] };\n\t}\n\n\tconst message = typeof issue.message === \"string\" ? issue.message : \"Invalid input\";\n\tconst path = Array.isArray(issue.path) ? issue.path.flatMap(normalize_path_segment) : [];\n\n\treturn { message, path };\n}\n\nfunction normalize_path_segment(segment: unknown): Array<string | number> {\n\tif (typeof segment === \"string\" || typeof segment === \"number\") {\n\t\treturn [segment];\n\t}\n\n\tif (!is_record(segment)) {\n\t\treturn [];\n\t}\n\n\tconst key = segment.key;\n\n\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\treturn [key];\n\t}\n\n\treturn [];\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nconst DecodeFormResponse = <Output, ErrorType>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst response = decode_remote_form_response_envelope(envelope);\n\n\t\tif (!response) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew InvalidRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\t\tconst decoded = decode_remote_error<ErrorType>(response.error);\n\n\t\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\t\treturn yield* Effect.fail(decoded);\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_http_error(get_remote_form_error_status(response), response.error),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormRedirectEnvelope\") {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tresponse.location,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst parsed = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tparse(response.data, remote_transport.decoders),\n\t\t);\n\t\tconst redirect_data = DecodeRemoteFormRedirectData(parsed);\n\n\t\tif (Option.isSome(redirect_data)) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tredirect_data.value.redirect,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst result_data = DecodeRemoteFormResultData(parsed);\n\n\t\tif (!Option.isSome(result_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(result_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst DecodeKitFormData = <Output, ErrorType>(\n\tdata: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst decoded_data = DecodeKitRemoteFormData(data);\n\n\t\tif (!Option.isSome(decoded_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst should_invalidate = decoded_data.value.r !== true;\n\n\t\tif (decoded_data.value.redirect) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tdecoded_data.value.redirect,\n\t\t\t\tshould_invalidate,\n\t\t\t\tremote_transport,\n\t\t\t\tdata,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"_\" in decoded_data.value)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(decoded_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tif (should_invalidate) {\n\t\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\t\t}\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst NavigateRemoteForm = <ErrorType>(\n\tlocation: string,\n\tinvalidate_all: boolean,\n\tremote_transport: RemoteFormTransport,\n\tenvelope: unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tconst navigate = remote_transport.navigate;\n\n\t\tif (!navigate) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() =>\n\t\t\tPromise.resolve(navigate(location, invalidate_all)),\n\t\t);\n\n\t\treturn yield* Effect.interrupt;\n\t});\n\nconst RefreshRemoteFormState = <ErrorType>(remote_transport: RemoteFormTransport) =>\n\tEffect.gen(function* () {\n\t\tconst refresh = remote_transport.refresh;\n\n\t\tif (!refresh) {\n\t\t\treturn;\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() => Promise.resolve(refresh()));\n\t});\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\tif (decoded.value.type === \"redirect\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormRedirectEnvelope\",\n\t\t\tlocation: decoded.value.location,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t};\n}\n\nfunction get_remote_form_error_status(\n\tresponse: Extract<RemoteFormResponseEnvelope, { _tag: \"RemoteFormErrorEnvelope\" }>,\n): number {\n\tconst nested_status = is_record(response.error) ? response.error.status : undefined;\n\n\tif (response.status !== undefined) {\n\t\treturn response.status;\n\t}\n\n\treturn typeof nested_status === \"number\" ? nested_status : 500;\n}\n\nfunction is_kit_remote_form_transport(\n\tremote_transport: RemoteFormTransport,\n): remote_transport is KitRemoteFormTransport {\n\treturn (\n\t\ttypeof remote_transport.binary_form_content_type === \"string\" &&\n\t\ttypeof remote_transport.remote_request === \"function\" &&\n\t\ttypeof remote_transport.serialize_binary_form === \"function\"\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 { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\nimport { get_dispatcher } from \"$/dispatcher.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\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: () => MakeSubmitEffect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction MakeSubmitEffect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = Effect.gen(function* () {\n\t\tconst result = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\toriginal_submit.call(event),\n\t\t);\n\t\tconst value = yield* ResolveSubmitResult<ErrorType>(result, updates_args);\n\n\t\tif (typeof value === \"boolean\") {\n\t\t\treturn read_submit_result<Output>(event);\n\t\t}\n\n\t\treturn value as Output;\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\nconst ResolveSubmitResult = <ErrorType>(result: unknown, updates_args: unknown[] | undefined) =>\n\tEffect.gen(function* () {\n\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(\n\t\t\t\t\tresult.updates(...resolve_native_remote_query_updates(updates_args)),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() => Promise.resolve(result));\n\t});\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 { is_standard_schema, normalize_validator, type StandardSchema } from \"$/internal/schema.ts\";\nimport type { EffectRemoteForm, NativeFormRecord, NativeMethod } from \"./types.ts\";\nimport {\n\tget_remote_action_id,\n\tSubmitRemoteForm,\n\ttype RemoteFormTransport,\n} from \"./form-transport.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ninterface RemoteFormAdapterState {\n\tshared_preflight_schema?: StandardSchema;\n}\n\n/** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */\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\tremote_transport: RemoteFormTransport = {},\n\tadapter_state: RemoteFormAdapterState = {},\n\tkeyed = false,\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\tlet local_preflight_schema: StandardSchema | undefined;\n\n\tconst SubmitForm = (input?: RemoteInput<Input>) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\t\tget_remote_action_id(form_obj),\n\t\t\t);\n\t\t\tconst can_use_remote_endpoint = remote_base.length > 0 && action_id !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(form_obj.submit(input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn yield* SubmitRemoteForm<Output, ErrorType>(\n\t\t\t\tform_obj,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t\tlocal_preflight_schema ?? adapter_state.shared_preflight_schema,\n\t\t\t);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => SubmitForm(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: SubmitForm,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tconst validate = form_obj.validate;\n\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\tValidateRemoteForm<ErrorType>(form_obj, validate, options),\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\tremote_transport,\n\t\t\t\t\tadapter_state,\n\t\t\t\t\ttrue,\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\tconst normalized_schema = normalize_validator(schema);\n\n\t\t\t\tif (is_standard_schema(normalized_schema)) {\n\t\t\t\t\tlocal_preflight_schema = normalized_schema;\n\n\t\t\t\t\tif (!keyed) {\n\t\t\t\t\t\tadapter_state.shared_preflight_schema = normalized_schema;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tform_obj.preflight(normalized_schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn callable;\n}\n\nconst ValidateRemoteForm = <ErrorType>(\n\tform_obj: NativeFormRecord,\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(validate.call(form_obj, normalize_validate_options(validate, options))),\n\t\t);\n\t});\n\nfunction normalize_validate_options(\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n\tif (!options || !(\"all\" in options) || \"includeUntouched\" in options) {\n\t\treturn options;\n\t}\n\n\tconst source = Function.prototype.toString.call(validate);\n\tconst uses_stable_option = source.includes(\"includeUntouched\") && !/\\ball\\s*=/.test(source);\n\n\tif (!uses_stable_option) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\tincludeUntouched: options.all,\n\t};\n}\n","import { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport const ResolveQueryResult = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (has_method(value, \"then\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\tif (has_method(value, \"run\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value.run()),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(value, decode_payload);\n\t});\n","import {\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport { InvalidPrerenderFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors } from \"./utils.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport type { NativeMethod } from \"./types.ts\";\nimport { Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype EffectRemotePrerenderAdapter<Input, Output, ErrorType = never> = (\n\tinput: RemoteInput<Input>,\n) => RemoteResourceEffect<Output, ErrorType>;\n\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => Output,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType> {\n\tif (typeof native_factory !== \"function\") {\n\t\tthrow new InvalidPrerenderFactoryError();\n\t}\n\n\tconst prerender = native_factory as NativeMethod;\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tconst resource_attempt = Result.try(() => prerender(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst PrerenderEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteResourceEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_resource_getters(resource_attempt.failure, PrerenderEffect);\n\n\t\t\treturn PrerenderEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst PrerenderEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tdecode_payload,\n\t\t) as RemoteResourceEffect<Output, ErrorType>;\n\n\t\tattach_remote_resource_getters(resource, PrerenderEffect);\n\n\t\treturn PrerenderEffect;\n\t}) as EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n","import {\n\tattach_failed_remote_query_resource,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tmake_failed_remote_live_stream,\n\tmake_remote_live_stream,\n\ttype RemoteLiveStream,\n} from \"$/live.ts\";\nimport { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { attach_native_remote_query_update } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"$/remote/failures.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport { Effect, Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\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 RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand &\n\tRemoteResourceEffect<Output, ErrorType> & {\n\t\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\t\treadonly set: (value: Output) => void;\n\t\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n\t};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\n/** Adapts a generated SvelteKit query to SER's Effect-based client ABI. */\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\tmode?: QueryAdapterMode,\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\tmode?: QueryAdapterMode,\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\tmode: QueryAdapterMode = \"standard\",\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 Effect.gen(function* () {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(load?.call(native_factory, input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* ResolveQueryResult<Output, ErrorType>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst QueryEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteQueryEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_query_resource(resource_attempt.failure, QueryEffect);\n\n\t\t\treturn QueryEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst query_result = mode === \"batch\" ? begin_batch_query_result(resource) : resource;\n\t\tconst QueryEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tquery_result,\n\t\t\tdecode_payload,\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(QueryEffect, resource);\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\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_query_result(resource: unknown): unknown {\n\tif (!has_method(resource, \"then\")) {\n\t\treturn resource;\n\t}\n\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\n/** Adapts a generated SvelteKit live query to SER's Effect-based client ABI. */\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_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tnormalize_native_error,\n\t\t\t);\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => RefreshRemoteResource(resource, refresh),\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\nconst RefreshRemoteResource = (resource: unknown, refresh: () => Promise<void>) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource)));\n\t});\n"],"mappings":";;;;;;;;AAGA,SAAgB,WACf,OACA,KACmC;CACnC,MAAM,aAAa,OAAO;CAE1B,QACG,eAAe,YAAY,UAAU,QAAS,eAAe,eAC/D,OAAQ,MAAuC,SAAS;AAE1D;;;ACPA,MAAa,yBAA4C,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,kCAAkC,SAAS,cAAc;CAEzD,OAAO;AACR;AAEA,SAAS,sBACR,UACA,QACO;CACP,MAAM,UAAU,mBAA2B,QAAQ,IAC/C,WACD,KAAA;CACH,MAAM,UAAU,SAAS;CACzB,MAAM,MAAM,SAAS;CACrB,MAAM,gBAAgB,SAAS;CAE/B,+BAA+B,UAAU,MAAM;CAE/C,IAAI,CAAC,SACJ;CAGD,IAAI,OAAO,YAAY,YACtB,OAAO,eAAe,QAAQ,WAAW;EACxC,cAAc;EACd,aAAa,sBAAsB,UAAU,OAAO;CACrD,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;AAEA,MAAM,yBAAyB,UAAmB,YACjD,OAAO,IAAI,aAAa;CACvB,OAAO,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
1
|
+
{"version":3,"file":"client-CpWfP_1f.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/client/utils.ts","../../../modules/svelte-effect-runtime/src/remote/client/responses.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/prerender.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\nexport function has_method<K extends PropertyKey>(\n\tvalue: unknown,\n\tkey: K,\n): value is Record<K, NativeMethod> {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as Record<PropertyKey, unknown>)[key] === \"function\"\n\t);\n}\n","import { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { create_remote_http_error } from \"$/remote/shared.ts\";\nimport type { RemoteFailure } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\n\nexport const DecodeResponseFailure = <ErrorType = never>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tconst body = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json()).pipe(\n\t\t\tEffect.orElseSucceed(() => undefined),\n\t\t);\n\t\tconst decoded = decode_remote_error<ErrorType>(body);\n\n\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\treturn decoded as RemoteFailure<ErrorType>;\n\t\t}\n\n\t\treturn create_remote_http_error(response.status, body);\n\t});\n\nexport const DecodeResponseOrValue = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (value instanceof Response) {\n\t\t\tif (!value.ok) {\n\t\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(value);\n\n\t\t\t\treturn yield* Effect.fail(failure);\n\t\t\t}\n\n\t\t\tconst data = yield* DecodeSuccessResponseBody<ErrorType>(value);\n\n\t\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(\n\t\t\t\t() => decode_payload(data) as Output,\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<Output, ErrorType>(() => decode_payload(value) as Output);\n\t});\n\nconst DecodeSuccessResponseBody = <ErrorType>(response: Response) =>\n\tEffect.gen(function* () {\n\t\tif (response.status === 204 || response.status === 205) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst text = yield* MakeEffectFromPromise<string, ErrorType>(() => response.text());\n\n\t\tif (text.length === 0) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\treturn yield* MakeEffectFromSync<unknown, ErrorType>(() => JSON.parse(text));\n\t});\n","import { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport { InvalidCommandFactoryError } from \"$/errors.ts\";\nimport type { EffectRemoteCommandCall, NativeMethod, Pending } from \"./types.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { Effect } from \"effect\";\n\ntype EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((\n\tinput: undefined extends Input ? Input | void : Input,\n) => EffectRemoteCommandCall<Output, ErrorType>) & {\n\treadonly pending: number;\n};\n\n/** Adapts a generated SvelteKit command to SER's Effect-based client ABI. */\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\tMakeCommandEffect<Input, Output, ErrorType>(\n\t\t\tnative_factory,\n\t\t\tinvoke,\n\t\t\tinput,\n\t\t\tdecode_payload,\n\t\t\tcount,\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\nconst MakeCommandEffect = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tpending: Pending,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.acquireUseRelease(\n\t\tAcquirePending(pending),\n\t\t() =>\n\t\t\tInvokeCommand<Input, Output, ErrorType>(\n\t\t\t\tnative_factory,\n\t\t\t\tinvoke,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\t() => updates_args,\n\t\t\t),\n\t\t() => ReleasePending(pending),\n\t) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nconst AcquirePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value += 1;\n\t});\n\nconst ReleasePending = (pending: Pending) =>\n\tEffect.sync(() => {\n\t\tpending.value -= 1;\n\t});\n\nconst InvokeCommand = <Input, Output, ErrorType>(\n\tnative_factory: unknown,\n\tinvoke: NativeMethod | undefined,\n\tinput: undefined extends Input ? Input | void : Input,\n\tdecode_payload: (value: unknown) => unknown,\n\tread_updates_args: () => unknown[] | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = invoke\n\t\t\t\t? invoke.call(native_factory, input)\n\t\t\t\t: (native_factory as NativeMethod)(input);\n\t\t\tconst updates_args = read_updates_args();\n\n\t\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(invocation),\n\t\t);\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t});\n","export 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 [index, item] of value.entries()) {\n\t\t\tappend_form_value(form_data, `${path}[${index}]`, 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\tform_data.append(`b:${path}`, value ? \"on\" : \"off\");\n\n\t\treturn;\n\t}\n\n\tform_data.append(path, value === null ? \"\" : String(value));\n}\n","import {\n\tInvalidRemoteFormResponseError,\n\tRemoteFormEndpointMissingError,\n\tUnsupportedRemoteFormResponseError,\n} from \"$/errors.ts\";\nimport {\n\tcreate_remote_http_error,\n\tcreate_remote_transport_error,\n\tcreate_remote_validation_error,\n} from \"$/remote/shared.ts\";\nimport { decode_remote_error, is_decoded_remote_failure } from \"$/remote/failures.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { StandardSchema } from \"$/internal/schema.ts\";\nimport { DecodeResponseFailure } from \"./responses.ts\";\nimport type { NativeFormRecord } from \"./types.ts\";\nimport { Effect, Option, Schema } from \"effect\";\nimport { to_form_data } from \"./form-data.ts\";\nimport { parse } from \"devalue\";\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;\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFormRedirectEnvelope\";\n\t\t\treadonly location: string;\n\t };\n\nexport interface RemoteFormTransport {\n\treadonly binary_form_content_type?: string;\n\treadonly decoders?: Record<string, (value: unknown) => unknown>;\n\treadonly navigate?: (location: string, invalidate_all: boolean) => PromiseLike<void> | void;\n\treadonly remote_request?: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly refresh?: () => PromiseLike<void> | void;\n\treadonly serialize_binary_form?: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\n\ninterface KitRemoteFormTransport extends RemoteFormTransport {\n\treadonly binary_form_content_type: string;\n\treadonly remote_request: (url: string, init?: RequestInit) => PromiseLike<unknown>;\n\treadonly serialize_binary_form: (\n\t\tdata: unknown,\n\t\tmeta: { readonly remote_refreshes: readonly string[] },\n\t) => { readonly blob: Blob };\n}\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.String,\n});\n\nconst RemoteFormRedirectEnvelopeSchema = Schema.Struct({\n\ttype: Schema.Literal(\"redirect\"),\n\tlocation: Schema.String,\n});\n\nconst RemoteFormResponseEnvelopeSchema = Schema.Union([\n\tRemoteFormErrorEnvelopeSchema,\n\tRemoteFormResultEnvelopeSchema,\n\tRemoteFormRedirectEnvelopeSchema,\n]);\n\nconst RemoteFormDecodedPayloadSchema = Schema.Struct({\n\tissues: Schema.optional(Schema.Array(FormIssueSchema)),\n\tresult: Schema.optional(Schema.Unknown),\n});\n\nconst RemoteFormRedirectDataSchema = Schema.Struct({\n\tredirect: Schema.String,\n});\n\nconst RemoteFormResultDataSchema = Schema.Struct({\n\t_: Schema.Unknown,\n});\n\nconst KitRemoteFormDataSchema = Schema.Struct({\n\t_: Schema.optional(Schema.Unknown),\n\tredirect: Schema.optional(Schema.String),\n\tr: Schema.optional(Schema.Literal(true)),\n});\n\nconst DecodeRemoteFormResponseEnvelope = Schema.decodeUnknownOption(\n\tRemoteFormResponseEnvelopeSchema,\n);\nconst DecodeRemoteFormPayload = Schema.decodeUnknownOption(RemoteFormDecodedPayloadSchema);\nconst DecodeRemoteFormRedirectData = Schema.decodeUnknownOption(RemoteFormRedirectDataSchema);\nconst DecodeRemoteFormResultData = Schema.decodeUnknownOption(RemoteFormResultDataSchema);\nconst DecodeKitRemoteFormData = Schema.decodeUnknownOption(KitRemoteFormDataSchema);\n\nexport const SubmitRemoteForm = <Output, ErrorType = never>(\n\tform_obj: NativeFormRecord,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: RemoteFormTransport,\n\tpreflight_schema?: StandardSchema,\n) =>\n\tEffect.gen(function* () {\n\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\tget_remote_action_id(form_obj),\n\t\t);\n\n\t\tif (!action_id || remote_base.length === 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new RemoteFormEndpointMissingError()),\n\t\t\t);\n\t\t}\n\n\t\tyield* ValidatePreflightInput<ErrorType>(preflight_schema, input);\n\n\t\tif (is_kit_remote_form_transport(remote_transport)) {\n\t\t\treturn yield* SubmitRemoteFormWithKit<Output, ErrorType>(\n\t\t\t\taction_id,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t);\n\t\t}\n\n\t\tconst response = yield* MakeEffectFromPromise<Response, ErrorType>((signal) =>\n\t\t\tfetch(to_remote_form_url(remote_base, action_id), {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: get_remote_request_headers(),\n\t\t\t\tbody: to_form_data(to_remote_form_input(input, action_id)),\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\tif (!response.ok) {\n\t\t\tconst failure = yield* DecodeResponseFailure<ErrorType>(response);\n\n\t\t\treturn yield* Effect.fail(failure);\n\t\t}\n\n\t\tconst envelope = yield* MakeEffectFromPromise<unknown, ErrorType>(() => response.json());\n\n\t\treturn yield* DecodeFormResponse<Output, ErrorType>(\n\t\t\tenvelope,\n\t\t\tdecode_payload,\n\t\t\tremote_transport,\n\t\t);\n\t});\n\nconst SubmitRemoteFormWithKit = <Output, ErrorType>(\n\taction_id: string,\n\tinput: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_base: string,\n\tremote_transport: KitRemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst url = to_remote_form_url(remote_base, action_id);\n\t\tconst body = yield* MakeEffectFromSync<Blob, ErrorType>(\n\t\t\t() =>\n\t\t\t\tremote_transport.serialize_binary_form(to_remote_form_input(input, action_id), {\n\t\t\t\t\tremote_refreshes: [],\n\t\t\t\t}).blob,\n\t\t);\n\t\tconst data = yield* MakeEffectFromPromise<unknown, ErrorType>((signal) =>\n\t\t\tremote_transport.remote_request(url, {\n\t\t\t\tmethod: \"POST\",\n\t\t\t\theaders: {\n\t\t\t\t\t...get_remote_request_headers(),\n\t\t\t\t\t\"Content-Type\": remote_transport.binary_form_content_type,\n\t\t\t\t},\n\t\t\t\tbody,\n\t\t\t\tsignal,\n\t\t\t}),\n\t\t);\n\n\t\treturn yield* DecodeKitFormData<Output, ErrorType>(data, decode_payload, remote_transport);\n\t});\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 normalized_base = remote_base.replace(/\\/$/, \"\");\n\n\treturn `${normalized_base}/${head}`;\n}\n\nfunction to_remote_form_input(input: unknown, action_id: string): Record<string, unknown> {\n\tconst data = is_record(input) ? input : {};\n\tconst serialized_key = action_id.split(\"/\").slice(2).join(\"/\");\n\tconst key: unknown = serialized_key.length === 0 ? undefined : JSON.parse(serialized_key);\n\n\tif (key === undefined || data.id !== undefined) {\n\t\treturn data;\n\t}\n\n\treturn {\n\t\t...data,\n\t\tid: key,\n\t};\n}\n\nfunction get_remote_request_headers(): Record<string, string> {\n\tif (typeof location === \"undefined\") {\n\t\treturn {};\n\t}\n\n\treturn {\n\t\t\"x-sveltekit-pathname\": location.pathname,\n\t\t\"x-sveltekit-search\": location.search,\n\t};\n}\n\nconst ValidatePreflightInput = <ErrorType>(schema: StandardSchema | undefined, input: unknown) =>\n\tEffect.gen(function* () {\n\t\tif (!schema) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst validated = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(schema[\"~standard\"].validate(input)),\n\t\t);\n\n\t\tif (!is_record(validated) || !Array.isArray(validated.issues)) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst issues = validated.issues.map(normalize_standard_issue);\n\n\t\treturn yield* Effect.fail(create_remote_validation_error(issues, { issues }, 400));\n\t});\n\nfunction normalize_standard_issue(issue: unknown): FormIssue {\n\tif (!is_record(issue)) {\n\t\treturn { message: String(issue), path: [] };\n\t}\n\n\tconst message = typeof issue.message === \"string\" ? issue.message : \"Invalid input\";\n\tconst path = Array.isArray(issue.path) ? issue.path.flatMap(normalize_path_segment) : [];\n\n\treturn { message, path };\n}\n\nfunction normalize_path_segment(segment: unknown): Array<string | number> {\n\tif (typeof segment === \"string\" || typeof segment === \"number\") {\n\t\treturn [segment];\n\t}\n\n\tif (!is_record(segment)) {\n\t\treturn [];\n\t}\n\n\tconst key = segment.key;\n\n\tif (typeof key === \"string\" || typeof key === \"number\") {\n\t\treturn [key];\n\t}\n\n\treturn [];\n}\n\nfunction is_record(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nconst DecodeFormResponse = <Output, ErrorType>(\n\tenvelope: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst response = decode_remote_form_response_envelope(envelope);\n\n\t\tif (!response) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew InvalidRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormErrorEnvelope\") {\n\t\t\tconst decoded = decode_remote_error<ErrorType>(response.error);\n\n\t\t\tif (is_decoded_remote_failure(decoded)) {\n\t\t\t\treturn yield* Effect.fail(decoded);\n\t\t\t}\n\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_http_error(get_remote_form_error_status(response), response.error),\n\t\t\t);\n\t\t}\n\n\t\tif (response._tag === \"RemoteFormRedirectEnvelope\") {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tresponse.location,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst parsed = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tparse(response.data, remote_transport.decoders),\n\t\t);\n\t\tconst redirect_data = DecodeRemoteFormRedirectData(parsed);\n\n\t\tif (Option.isSome(redirect_data)) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tredirect_data.value.redirect,\n\t\t\t\ttrue,\n\t\t\t\tremote_transport,\n\t\t\t\tenvelope,\n\t\t\t);\n\t\t}\n\n\t\tconst result_data = DecodeRemoteFormResultData(parsed);\n\n\t\tif (!Option.isSome(result_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(result_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst DecodeKitFormData = <Output, ErrorType>(\n\tdata: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n\tremote_transport: RemoteFormTransport,\n) =>\n\tEffect.gen(function* () {\n\t\tconst decoded_data = DecodeKitRemoteFormData(data);\n\n\t\tif (!Option.isSome(decoded_data)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst should_invalidate = decoded_data.value.r !== true;\n\n\t\tif (decoded_data.value.redirect) {\n\t\t\treturn yield* NavigateRemoteForm<ErrorType>(\n\t\t\t\tdecoded_data.value.redirect,\n\t\t\t\tshould_invalidate,\n\t\t\t\tremote_transport,\n\t\t\t\tdata,\n\t\t\t);\n\t\t}\n\n\t\tif (!(\"_\" in decoded_data.value)) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tconst payload = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\tdecode_payload(decoded_data.value._),\n\t\t);\n\t\tconst decoded = decode_remote_form_payload<Output>(payload);\n\n\t\tif (!decoded) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(new UnsupportedRemoteFormResponseError(data), data),\n\t\t\t);\n\t\t}\n\n\t\tif (decoded.issues && decoded.issues.length > 0) {\n\t\t\treturn yield* Effect.fail(create_remote_validation_error(decoded.issues, decoded, 400));\n\t\t}\n\n\t\tif (should_invalidate) {\n\t\t\tyield* RefreshRemoteFormState<ErrorType>(remote_transport);\n\t\t}\n\n\t\treturn decoded.result as Output;\n\t});\n\nconst NavigateRemoteForm = <ErrorType>(\n\tlocation: string,\n\tinvalidate_all: boolean,\n\tremote_transport: RemoteFormTransport,\n\tenvelope: unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tconst navigate = remote_transport.navigate;\n\n\t\tif (!navigate) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tcreate_remote_transport_error(\n\t\t\t\t\tnew UnsupportedRemoteFormResponseError(envelope),\n\t\t\t\t\tenvelope,\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() =>\n\t\t\tPromise.resolve(navigate(location, invalidate_all)),\n\t\t);\n\n\t\treturn yield* Effect.interrupt;\n\t});\n\nconst RefreshRemoteFormState = <ErrorType>(remote_transport: RemoteFormTransport) =>\n\tEffect.gen(function* () {\n\t\tconst refresh = remote_transport.refresh;\n\n\t\tif (!refresh) {\n\t\t\treturn;\n\t\t}\n\n\t\tyield* MakeEffectFromPromise<void, ErrorType>(() => Promise.resolve(refresh()));\n\t});\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\tif (decoded.value.type === \"redirect\") {\n\t\treturn {\n\t\t\t_tag: \"RemoteFormRedirectEnvelope\",\n\t\t\tlocation: decoded.value.location,\n\t\t};\n\t}\n\n\treturn {\n\t\t_tag: \"RemoteFormResultEnvelope\",\n\t\tdata: decoded.value.data,\n\t};\n}\n\nfunction get_remote_form_error_status(\n\tresponse: Extract<RemoteFormResponseEnvelope, { _tag: \"RemoteFormErrorEnvelope\" }>,\n): number {\n\tconst nested_status = is_record(response.error) ? response.error.status : undefined;\n\n\tif (response.status !== undefined) {\n\t\treturn response.status;\n\t}\n\n\treturn typeof nested_status === \"number\" ? nested_status : 500;\n}\n\nfunction is_kit_remote_form_transport(\n\tremote_transport: RemoteFormTransport,\n): remote_transport is KitRemoteFormTransport {\n\treturn (\n\t\ttypeof remote_transport.binary_form_content_type === \"string\" &&\n\t\ttypeof remote_transport.remote_request === \"function\" &&\n\t\ttypeof remote_transport.serialize_binary_form === \"function\"\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 { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { resolve_native_remote_query_updates } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteFormSubmit, NativeMethod } from \"./types.ts\";\nimport { get_dispatcher } from \"$/dispatcher.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\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: () => MakeSubmitEffect<Output, ErrorType>(original_submit, event),\n\t\t\t},\n\t\t},\n\t);\n}\n\nfunction MakeSubmitEffect<Output, ErrorType>(\n\toriginal_submit: NativeMethod,\n\tevent: unknown,\n): EffectRemoteFormSubmit<Output, ErrorType> {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst SubmitEffect = Effect.gen(function* () {\n\t\tconst result = yield* MakeEffectFromSync<unknown, ErrorType>(() =>\n\t\t\toriginal_submit.call(event),\n\t\t);\n\t\tconst value = yield* ResolveSubmitResult<ErrorType>(result, updates_args);\n\n\t\tif (typeof value === \"boolean\") {\n\t\t\treturn read_submit_result<Output>(event);\n\t\t}\n\n\t\treturn value as Output;\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\nconst ResolveSubmitResult = <ErrorType>(result: unknown, updates_args: unknown[] | undefined) =>\n\tEffect.gen(function* () {\n\t\tif (updates_args && has_method(result, \"updates\")) {\n\t\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(\n\t\t\t\t\tresult.updates(...resolve_native_remote_query_updates(updates_args)),\n\t\t\t\t),\n\t\t\t);\n\t\t}\n\n\t\treturn yield* MakeEffectFromPromise<unknown, ErrorType>(() => Promise.resolve(result));\n\t});\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 { is_standard_schema, normalize_validator, type StandardSchema } from \"$/internal/schema.ts\";\nimport type { EffectRemoteForm, NativeFormRecord, NativeMethod } from \"./types.ts\";\nimport {\n\tget_remote_action_id,\n\tSubmitRemoteForm,\n\ttype RemoteFormTransport,\n} from \"./form-transport.ts\";\nimport { MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { wrap_enhance_callback } from \"./form-enhance.ts\";\nimport { DecodeResponseOrValue } from \"./responses.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ninterface RemoteFormAdapterState {\n\tshared_preflight_schema?: StandardSchema;\n}\n\n/** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */\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\tremote_transport: RemoteFormTransport = {},\n\tadapter_state: RemoteFormAdapterState = {},\n\tkeyed = false,\n): EffectRemoteForm<Input, Output, ErrorType> {\n\tconst form_obj = native_factory as NativeFormRecord;\n\tlet local_preflight_schema: StandardSchema | undefined;\n\n\tconst SubmitForm = (input?: RemoteInput<Input>) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst action_id = yield* MakeEffectFromSync<string | undefined, ErrorType>(() =>\n\t\t\t\tget_remote_action_id(form_obj),\n\t\t\t);\n\t\t\tconst can_use_remote_endpoint = remote_base.length > 0 && action_id !== undefined;\n\n\t\t\tif (has_method(form_obj, \"submit\") && !can_use_remote_endpoint) {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(form_obj.submit(input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t\t}\n\n\t\t\treturn yield* SubmitRemoteForm<Output, ErrorType>(\n\t\t\t\tform_obj,\n\t\t\t\tinput,\n\t\t\t\tdecode_payload,\n\t\t\t\tremote_base,\n\t\t\t\tremote_transport,\n\t\t\t\tlocal_preflight_schema ?? adapter_state.shared_preflight_schema,\n\t\t\t);\n\t\t});\n\n\tconst callable = ((input?: RemoteInput<Input>) => SubmitForm(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: SubmitForm,\n\t});\n\n\tif (has_method(form_obj, \"validate\")) {\n\t\tconst validate = form_obj.validate;\n\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\tValidateRemoteForm<ErrorType>(form_obj, validate, options),\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\tremote_transport,\n\t\t\t\t\tadapter_state,\n\t\t\t\t\ttrue,\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\tconst normalized_schema = normalize_validator(schema);\n\n\t\t\t\tif (is_standard_schema(normalized_schema)) {\n\t\t\t\t\tlocal_preflight_schema = normalized_schema;\n\n\t\t\t\t\tif (!keyed) {\n\t\t\t\t\t\tadapter_state.shared_preflight_schema = normalized_schema;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tform_obj.preflight(normalized_schema);\n\n\t\t\t\treturn callable;\n\t\t\t},\n\t\t});\n\t}\n\n\treturn callable;\n}\n\nconst ValidateRemoteForm = <ErrorType>(\n\tform_obj: NativeFormRecord,\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\tPromise.resolve(validate.call(form_obj, normalize_validate_options(validate, options))),\n\t\t);\n\t});\n\nfunction normalize_validate_options(\n\tvalidate: NativeMethod,\n\toptions: Record<string, unknown> | undefined,\n): Record<string, unknown> | undefined {\n\tif (!options || !(\"all\" in options) || \"includeUntouched\" in options) {\n\t\treturn options;\n\t}\n\n\tconst source = Function.prototype.toString.call(validate);\n\tconst uses_stable_option = source.includes(\"includeUntouched\") && !/\\ball\\s*=/.test(source);\n\n\tif (!uses_stable_option) {\n\t\treturn options;\n\t}\n\n\treturn {\n\t\t...options,\n\t\tincludeUntouched: options.all,\n\t};\n}\n","import { DecodeResponseOrValue } from \"./responses.ts\";\nimport { MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { has_method } from \"./utils.ts\";\nimport { Effect } from \"effect\";\n\nexport const ResolveQueryResult = <Output, ErrorType = never>(\n\tvalue: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n) =>\n\tEffect.gen(function* () {\n\t\tif (has_method(value, \"then\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\tif (has_method(value, \"run\")) {\n\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\tPromise.resolve(value.run()),\n\t\t\t);\n\n\t\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(result, decode_payload);\n\t\t}\n\n\t\treturn yield* DecodeResponseOrValue<Output, ErrorType>(value, decode_payload);\n\t});\n","import {\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport { InvalidPrerenderFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError } from \"$/remote/effect.ts\";\nimport { copy_property_descriptors } from \"./utils.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport type { NativeMethod } from \"./types.ts\";\nimport { Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype EffectRemotePrerenderAdapter<Input, Output, ErrorType = never> = (\n\tinput: RemoteInput<Input>,\n) => RemoteResourceEffect<Output, ErrorType>;\n\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => Output,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\nexport function create_remote_prerender_adapter<Input, Output, ErrorType = never>(\n\tnative_factory: unknown,\n\tdecode_payload: (value: unknown) => unknown,\n): EffectRemotePrerenderAdapter<Input, Output, ErrorType> {\n\tif (typeof native_factory !== \"function\") {\n\t\tthrow new InvalidPrerenderFactoryError();\n\t}\n\n\tconst prerender = native_factory as NativeMethod;\n\tconst wrapped = ((input: RemoteInput<Input>) => {\n\t\tconst resource_attempt = Result.try(() => prerender(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst PrerenderEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteResourceEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_resource_getters(resource_attempt.failure, PrerenderEffect);\n\n\t\t\treturn PrerenderEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst PrerenderEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tdecode_payload,\n\t\t) as RemoteResourceEffect<Output, ErrorType>;\n\n\t\tattach_remote_resource_getters(resource, PrerenderEffect);\n\n\t\treturn PrerenderEffect;\n\t}) as EffectRemotePrerenderAdapter<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\n\treturn wrapped;\n}\n","import {\n\tattach_failed_remote_query_resource,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tmake_failed_remote_live_stream,\n\tmake_remote_live_stream,\n\ttype RemoteLiveStream,\n} from \"$/live.ts\";\nimport { InvalidLiveQueryFactoryError, InvalidQueryFactoryError } from \"$/errors.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise } from \"$/remote/effect.ts\";\nimport { attach_native_remote_query_update } from \"$/remote/query-update.ts\";\nimport type { EffectRemoteQueryUpdateBrand, NativeMethod } from \"./types.ts\";\nimport { copy_property_descriptors, has_method } from \"./utils.ts\";\nimport { normalize_native_error } from \"$/remote/failures.ts\";\nimport { ResolveQueryResult } from \"./query-result.ts\";\nimport { Effect, Result } from \"effect\";\n\ntype RemoteInput<Input> = undefined extends Input ? Input | void : Input;\n\ntype DecodePayload<Output> = (value: unknown) => Output;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\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 RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand &\n\tRemoteResourceEffect<Output, ErrorType> & {\n\t\treadonly refresh: () => Effect.Effect<void, unknown, never>;\n\t\treadonly set: (value: Output) => void;\n\t\treadonly withOverride: (update: (current: Output) => Output) => unknown;\n\t};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\n/** Adapts a generated SvelteKit query to SER's Effect-based client ABI. */\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\tmode?: QueryAdapterMode,\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\tmode?: QueryAdapterMode,\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\tmode: QueryAdapterMode = \"standard\",\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 Effect.gen(function* () {\n\t\t\t\tconst result = yield* MakeEffectFromPromise<unknown, ErrorType>(() =>\n\t\t\t\t\tPromise.resolve(load?.call(native_factory, input)),\n\t\t\t\t);\n\n\t\t\t\treturn yield* ResolveQueryResult<Output, ErrorType>(result, decode_payload);\n\t\t\t}) as RemoteQueryEffect<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst QueryEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as RemoteQueryEffect<Output, ErrorType>;\n\n\t\t\tattach_failed_remote_query_resource(resource_attempt.failure, QueryEffect);\n\n\t\t\treturn QueryEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst query_result = mode === \"batch\" ? begin_batch_query_result(resource) : resource;\n\t\tconst QueryEffect = ResolveQueryResult<Output, ErrorType>(\n\t\t\tquery_result,\n\t\t\tdecode_payload,\n\t\t) as RemoteQueryEffect<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(QueryEffect, resource);\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\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_query_result(resource: unknown): unknown {\n\tif (!has_method(resource, \"then\")) {\n\t\treturn resource;\n\t}\n\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\n/** Adapts a generated SvelteKit live query to SER's Effect-based client ABI. */\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_attempt = Result.try(() => query(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tnormalize_native_error,\n\t\t\t);\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(resource, normalize_native_error);\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as EffectRemoteQueryUpdateBrand &\n\t\t((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);\n\n\tcopy_property_descriptors(native_factory, wrapped);\n\tattach_native_remote_query_update(wrapped, native_factory);\n\n\treturn wrapped;\n}\n\nfunction attach_query_resource<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: RemoteQueryEffect<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => RefreshRemoteResource(resource, refresh),\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\nconst RefreshRemoteResource = (resource: unknown, refresh: () => Promise<void>) =>\n\tEffect.gen(function* () {\n\t\tyield* MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource)));\n\t});\n"],"mappings":";;;;;;;;AAGA,SAAgB,WACf,OACA,KACmC;CACnC,MAAM,aAAa,OAAO;CAE1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UAAU,sBAAsB;EAE1F,kCAAkC,QAAQ,QAAQ;EAElD,OAAO;CACR;CAGA,0BAA0B,gBAAgB,OAAO;CACjD,kCAAkC,SAAS,cAAc;CAEzD,OAAO;AACR;AAEA,SAAS,sBACR,UACA,QACO;CACP,MAAM,UAAU,mBAA2B,QAAQ,IAC/C,WACD,KAAA;CACH,MAAM,UAAU,SAAS;CACzB,MAAM,MAAM,SAAS;CACrB,MAAM,gBAAgB,SAAS;CAE/B,+BAA+B,UAAU,MAAM;CAE/C,IAAI,CAAC,SACJ;CAGD,IAAI,OAAO,YAAY,YACtB,OAAO,eAAe,QAAQ,WAAW;EACxC,cAAc;EACd,aAAa,sBAAsB,UAAU,OAAO;CACrD,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;AAEA,MAAM,yBAAyB,UAAmB,YACjD,OAAO,IAAI,aAAa;CACvB,OAAO,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,QAAQ,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as get_dispatcher$1 } from "./dispatcher-
|
|
2
|
-
import { r as get_server_dispatcher } from "./runtime-
|
|
1
|
+
import { r as get_dispatcher$1 } from "./dispatcher-D3Tpa5HC.js";
|
|
2
|
+
import { r as get_server_dispatcher } from "./runtime-CmiEHnSw.js";
|
|
3
3
|
//#region src/generated/dispatcher.ts
|
|
4
4
|
var Dispatcher = class {
|
|
5
5
|
static emit(event) {
|
|
@@ -20,4 +20,4 @@ function get_dispatcher() {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { get_dispatcher as n, Dispatcher as t };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=dispatcher-
|
|
23
|
+
//# sourceMappingURL=dispatcher-BFTvQ7sm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-
|
|
1
|
+
{"version":3,"file":"dispatcher-BFTvQ7sm.js","names":["get_client_dispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/generated/dispatcher.ts"],"sourcesContent":["import type {\n\tComponentScope,\n\tDispatcher as RuntimeDispatcher,\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\nimport { get_dispatcher as get_client_dispatcher } from \"$/dispatcher.ts\";\nimport { get_server_dispatcher } from \"$/server/runtime.ts\";\n\nexport { Code } from \"$/dispatcher.ts\";\nexport type {\n\tDispatcherEvent,\n\tMarkupPromiseEvent,\n\tMarkupPromiseOptions,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n} from \"$/dispatcher.ts\";\n\nexport class Dispatcher {\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\t/**\n\t * Runs `fn` with `scope` as the active component scope so emitted work is\n\t * bound to the calling component's lifetime.\n\t */\n\tstatic with_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\treturn get_dispatcher().with_scope(scope, fn);\n\t}\n}\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":";;;AAoBA,IAAa,aAAb,MAAwB;CAKvB,OAAO,KAAW,OAAkD;EACnE,OAAO,eAAe,CAAC,CAAC,KAAK,KAAK;CACnC;;;;;CAMA,OAAO,WAAc,OAAuB,IAAgB;EAC3D,OAAO,eAAe,CAAC,CAAC,WAAW,OAAO,EAAE;CAC7C;AACD;AAEA,SAAgB,iBAAoC;CACnD,IAAI,OAAO,aAAa,aACvB,OAAO,sBAAsB;CAG9B,OAAOA,iBAAsB;AAC9B"}
|
|
@@ -74,6 +74,18 @@ var ComponentScope = class ComponentScope {
|
|
|
74
74
|
*/
|
|
75
75
|
return Effect.forkIn(Effect.provideService(effect, Scope.Scope, this.#scope), this.#scope);
|
|
76
76
|
}
|
|
77
|
+
/**
|
|
78
|
+
* Forks an effect into a child scope owned by one reactive run. The child
|
|
79
|
+
* remains open after setup completes so nested scoped work survives until
|
|
80
|
+
* that run is invalidated, while component disposal remains its backstop.
|
|
81
|
+
*/
|
|
82
|
+
fork_run_in(effect) {
|
|
83
|
+
const run_scope = Scope.forkUnsafe(this.#scope);
|
|
84
|
+
return {
|
|
85
|
+
fork_effect: Effect.forkIn(Effect.provideService(effect, Scope.Scope, run_scope), run_scope),
|
|
86
|
+
close_effect: (exit) => Scope.close(run_scope, exit)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
77
89
|
/** Effect that closes the scope. Must be run by the owning dispatcher. */
|
|
78
90
|
get close_effect() {
|
|
79
91
|
return Scope.close(this.#scope, Exit.void);
|
|
@@ -203,10 +215,10 @@ var Dispatcher = class Dispatcher {
|
|
|
203
215
|
}
|
|
204
216
|
}
|
|
205
217
|
/**
|
|
206
|
-
* Forks an effect into a
|
|
207
|
-
* a child of the scope, so
|
|
208
|
-
*
|
|
209
|
-
*
|
|
218
|
+
* Forks an effect into a reactive-run scope and starts it. The run scope is
|
|
219
|
+
* a child of the component scope, so rerun cleanup closes only that run
|
|
220
|
+
* while component disposal remains a backstop. Returns an idempotent handle
|
|
221
|
+
* that closes the run scope and all work forked into it.
|
|
210
222
|
*
|
|
211
223
|
* Throws {@link ScopeDisposedError} when the scope was already disposed
|
|
212
224
|
* and {@link DispatcherDisposedError} when the dispatcher was shut down.
|
|
@@ -214,21 +226,17 @@ var Dispatcher = class Dispatcher {
|
|
|
214
226
|
run_scoped(scope, effect) {
|
|
215
227
|
if (this.#disposed) return () => {};
|
|
216
228
|
if (scope.disposed || !this.#component_scopes.has(scope)) throw new ScopeDisposedError();
|
|
217
|
-
|
|
218
|
-
* Track the scoped fiber itself: `forkIn` binds it to the component
|
|
219
|
-
* scope rather than the awaiting parent, so per-run disposal must
|
|
220
|
-
* interrupt the scoped fiber directly.
|
|
221
|
-
*/
|
|
222
|
-
let scoped_fiber;
|
|
223
|
-
this.#runtime.runFork(Effect.flatMap(scope.fork_in(effect), (fiber) => {
|
|
224
|
-
scoped_fiber = fiber;
|
|
225
|
-
return Effect.asVoid(Fiber.await(fiber));
|
|
226
|
-
}));
|
|
229
|
+
const run = scope.fork_run_in(effect);
|
|
227
230
|
let disposed = false;
|
|
231
|
+
this.#runtime.runFork(Effect.flatMap(run.fork_effect, (fiber) => {
|
|
232
|
+
return Effect.flatMap(Fiber.await(fiber), (exit) => {
|
|
233
|
+
return Exit.isFailure(exit) ? run.close_effect(exit) : Effect.void;
|
|
234
|
+
});
|
|
235
|
+
}));
|
|
228
236
|
return () => {
|
|
229
237
|
if (disposed) return;
|
|
230
238
|
disposed = true;
|
|
231
|
-
|
|
239
|
+
this.#runtime.runFork(run.close_effect(Exit.void));
|
|
232
240
|
};
|
|
233
241
|
}
|
|
234
242
|
/**
|
|
@@ -645,4 +653,4 @@ var ComponentScopeRef = class {
|
|
|
645
653
|
//#endregion
|
|
646
654
|
export { Code as a, reset_dispatcher as i, Dispatcher as n, ComponentScope as o, get_dispatcher as r, ComponentScopeRef as t };
|
|
647
655
|
|
|
648
|
-
//# sourceMappingURL=dispatcher-
|
|
656
|
+
//# sourceMappingURL=dispatcher-D3Tpa5HC.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dispatcher-D3Tpa5HC.js","names":["#on_dispose","#scope","#disposed","#notify_value_cells","#runtime","#root_scope","#component_scopes","#current_scope","#disposed","#scope_ids","#clear_scope_cache","#emit_markup_value","#emit_markup_promise","#emit_markup_run","#next_fiber_id","#fibers","#scope_id","#make_scoped_id","#make_value_cache_key","#value_ids","#subscribe_value_cells","#value_cells","#interrupt_cached_fiber","#delete_value_cell","#should_start_value_fiber","#start_value_fiber","#make_promise_cache_key","#promise_ids","#promise_values","#start_promise_fiber","#is_server_render","#clear_value_cells","#hash_deps","#next_scope_id","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#get_dispatcher","#scope"],"sources":["../../../modules/svelte-effect-runtime/src/dispatcher/fibers.ts","../../../modules/svelte-effect-runtime/src/dispatcher/scope.ts","../../../modules/svelte-effect-runtime/src/dispatcher/deps.ts","../../../modules/svelte-effect-runtime/src/dispatcher/types.ts","../../../modules/svelte-effect-runtime/src/dispatcher/index.ts"],"sourcesContent":["import type { Fiber as FiberType } from \"effect/Fiber\";\nimport { Cause, Effect, Exit, Fiber } from \"effect\";\n\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\nexport const InterruptFiber = (fiber: FiberType<unknown, unknown>) =>\n\tEffect.gen(function* () {\n\t\tyield* Fiber.interrupt(fiber);\n\t});\n\n/** Observes fiber completion and surfaces failures without taking ownership of the fiber. */\nexport const WatchFiberExit = <A>(\n\toptions: { fiber: FiberType<unknown, unknown> } & FiberWatchCallbacks<A>,\n) => {\n\tconst { fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\treturn Effect.gen(function* () {\n\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\tyield* Effect.sync(() => {\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\ton_complete?.();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\ton_failure?.(error);\n\n\t\t\t\tif (surface_failure) {\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ton_complete?.();\n\t\t});\n\t});\n};\n","import { Effect, Exit, Scope } from \"effect\";\nimport type { Fiber } from \"effect\";\n\n/**\n * A component-owned Effect scope.\n *\n * A `ComponentScope` wraps a `Scope.Closeable` forked from the dispatcher's\n * root scope. Work is forked into the scope with `Effect.forkIn`, so closing\n * the scope interrupts that work and runs its finalizers. The generated\n * component teardown disposes the scope on destroy. Disposal is idempotent.\n *\n * @since 4.1.0\n */\nexport class ComponentScope {\n\t#scope: Scope.Closeable;\n\t#disposed = false;\n\treadonly #on_dispose: (scope: ComponentScope) => void;\n\n\tprivate constructor(scope: Scope.Closeable, on_dispose: (scope: ComponentScope) => void) {\n\t\tthis.#scope = scope;\n\t\tthis.#on_dispose = on_dispose;\n\t}\n\n\t/** Forks a child scope from the given root and returns it wrapped. */\n\tstatic fork(\n\t\troot: Scope.Closeable,\n\t\ton_dispose: (scope: ComponentScope) => void,\n\t): ComponentScope {\n\t\treturn new ComponentScope(Scope.forkUnsafe(root), on_dispose);\n\t}\n\n\t/** The underlying closeable scope used to bind Effect work. */\n\tget underlying(): Scope.Closeable {\n\t\treturn this.#scope;\n\t}\n\n\t/** Whether this scope has already been disposed. */\n\tget disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Forks an effect into this scope. The fiber becomes a child of the scope,\n\t * so disposing the scope interrupts it and runs its finalizers. The scope\n\t * is provided ambiently so `Effect.forkIn` registers the fiber as a child.\n\t */\n\tfork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R> {\n\t\t/**\n\t\t * The effect must see the scope before it is forked: provide the scope\n\t\t * inside the forked program so `acquireRelease`-style work resolves it,\n\t\t * and fork that program into the scope so the fiber is a child whose\n\t\t * finalizers run when the scope closes.\n\t\t */\n\t\treturn Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, this.#scope),\n\t\t\tthis.#scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t}\n\n\t/**\n\t * Forks an effect into a child scope owned by one reactive run. The child\n\t * remains open after setup completes so nested scoped work survives until\n\t * that run is invalidated, while component disposal remains its backstop.\n\t */\n\tfork_run_in<A, E, R>(\n\t\teffect: Effect.Effect<A, E, R>,\n\t): {\n\t\treadonly fork_effect: Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t\treadonly close_effect: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>;\n\t} {\n\t\tconst run_scope = Scope.forkUnsafe(this.#scope);\n\t\tconst fork_effect = Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, run_scope),\n\t\t\trun_scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\n\t\treturn {\n\t\t\tfork_effect,\n\t\t\tclose_effect: (exit) => Scope.close(run_scope, exit),\n\t\t};\n\t}\n\n\t/** Effect that closes the scope. Must be run by the owning dispatcher. */\n\tget close_effect(): Effect.Effect<void> {\n\t\treturn Scope.close(this.#scope, Exit.void);\n\t}\n\n\t/**\n\t * Marks the scope disposed and detaches it from the dispatcher. The caller\n\t * is responsible for running {@link close_effect} to run finalizers.\n\t * Idempotent.\n\t */\n\tdispose(): void {\n\t\tif (this.#disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#disposed = true;\n\t\tthis.#on_dispose(this);\n\t}\n}\n","/** Assigns stable identities to object dependencies while hashing value dependencies. */\nexport type DependencyHasher = (deps: readonly unknown[]) => string;\n\nexport function make_dependency_hasher(): DependencyHasher {\n\tconst object_dep_ids = new WeakMap<object, number>();\n\tconst symbol_dep_ids = new Map<symbol, number>();\n\n\tlet next_object_dep_id = 0;\n\tlet next_symbol_dep_id = 0;\n\n\tconst hash_symbol_dep = (dep: symbol): string => {\n\t\tlet id = symbol_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_symbol_dep_id += 1;\n\t\t\tid = next_symbol_dep_id;\n\t\t\tsymbol_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `y:${id}`;\n\t};\n\n\tconst hash_object_dep = (dep: object): string => {\n\t\tlet id = object_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_object_dep_id += 1;\n\t\t\tid = next_object_dep_id;\n\t\t\tobject_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `o:${id}`;\n\t};\n\n\tconst hash_dep = (dep: unknown): string | readonly [\"s\", string] => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep as string];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t};\n\n\tconst hash_deps = (deps: readonly unknown[]): string => JSON.stringify(deps.map(hash_dep));\n\n\treturn hash_deps;\n}\n","import type { Effect } from \"effect\";\n\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\nexport type Dispose = () => void;\n\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupValueEvent<A, F> {\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupPromiseEvent<A> {\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\nexport interface MarkupRunEvent<A> {\n\ttype: typeof Code.Markup.Run;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\nimport {\n\tRuntimeAlreadyInitializedError,\n\tDispatcherDisposedError,\n\tScopeDisposedError,\n} from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime, Scope } from \"effect\";\nimport { InterruptFiber, WatchFiberExit } from \"./fibers.ts\";\nimport { ComponentScope } from \"./scope.ts\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport { make_dependency_hasher } from \"./deps.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Code } from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\nexport class Dispatcher {\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t#notify_value_cells = (): void => {};\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t#value_ids = new Map<string, string>();\n\t#promise_ids = new Map<string, string>();\n\t#scope_ids = new WeakMap<ComponentScope, string>();\n\t#hash_deps = make_dependency_hasher();\n\t#disposed = false;\n\t#next_fiber_id = 0;\n\t#next_scope_id = 0;\n\t#root_scope = Scope.makeUnsafe();\n\t#component_scopes = new Set<ComponentScope>();\n\t/**\n\t * The component scope that effect execution currently enters. Set by\n\t * generated code via {@link with_scope}; `undefined` outside components.\n\t */\n\t#current_scope: ComponentScope | undefined = undefined;\n\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Begin a component-owned Effect scope. Pass the returned scope to\n\t * {@link run_scoped} so the work is interrupted and finalized when the\n\t * component is destroyed. Disposal is idempotent.\n\t */\n\tbegin_scope(): ComponentScope {\n\t\tconst scope = ComponentScope.fork(this.#root_scope, (disposed) => {\n\t\t\tthis.#component_scopes.delete(disposed);\n\t\t});\n\n\t\tthis.#component_scopes.add(scope);\n\n\t\treturn scope;\n\t}\n\n\t/**\n\t * Runs `fn` with `scope` as the current component scope. While active,\n\t * every effect path ({@link promise}, {@link run}, {@link value}) forks\n\t * its work into `scope` so disposing the scope interrupts it and runs its\n\t * finalizers. A disposed scope falls back to unscoped execution.\n\t */\n\twith_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\tif (scope.disposed) {\n\t\t\treturn fn();\n\t\t}\n\n\t\tconst previous = this.#current_scope;\n\t\tthis.#current_scope = scope;\n\n\t\ttry {\n\t\t\treturn fn();\n\t\t} finally {\n\t\t\tthis.#current_scope = previous;\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect into a reactive-run scope and starts it. The run scope is\n\t * a child of the component scope, so rerun cleanup closes only that run\n\t * while component disposal remains a backstop. Returns an idempotent handle\n\t * that closes the run scope and all work forked into it.\n\t *\n\t * Throws {@link ScopeDisposedError} when the scope was already disposed\n\t * and {@link DispatcherDisposedError} when the dispatcher was shut down.\n\t */\n\trun_scoped<A, E, R>(scope: ComponentScope, effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tif (scope.disposed || !this.#component_scopes.has(scope)) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tconst run = scope.fork_run_in(effect);\n\t\tlet disposed = false;\n\n\t\tthis.#runtime.runFork(\n\t\t\tEffect.flatMap(run.fork_effect, (fiber) => {\n\t\t\t\treturn Effect.flatMap(Fiber.await(fiber), (exit) => {\n\t\t\t\t\treturn Exit.isFailure(exit) ? run.close_effect(exit) : Effect.void;\n\t\t\t\t});\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(\n\t\t\t\trun.close_effect(Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Disposes a component scope owned by this dispatcher, interrupting its\n\t * bound work and running its finalizers. Idempotent. Rejects scopes owned\n\t * by another dispatcher with {@link ScopeDisposedError}.\n\t */\n\tdispose_scope(scope: ComponentScope): void {\n\t\tif (!this.#component_scopes.has(scope)) {\n\t\t\tif (scope.disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tconst scope_id = this.#scope_ids.get(scope);\n\n\t\tif (scope_id !== undefined) {\n\t\t\tthis.#scope_ids.delete(scope);\n\t\t\tthis.#clear_scope_cache(scope_id);\n\t\t}\n\n\t\tscope.dispose();\n\t\tthis.#runtime.runFork(scope.close_effect as Effect.Effect<unknown, unknown, unknown>);\n\t}\n\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t\t}),\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t};\n\t}\n\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_value_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#value_ids.get(cache_id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#delete_value_cell(old_key);\n\t\t}\n\n\t\tthis.#value_ids.set(cache_id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_promise_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(cache_id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(cache_id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options, cache_id);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scoped_effect = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.exit(effect);\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Surface the failure without reporting it. Both the scoped and the\n\t\t\t * unscoped path funnel through `interpreted_program`, which reports\n\t\t\t * once, so reporting here would raise every failure twice.\n\t\t\t */\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\tconst scope = this.#current_scope;\n\t\tconst materialized_program = scope\n\t\t\t? Effect.flatMap(scope.fork_in(scoped_effect), (fiber) => Fiber.await(fiber))\n\t\t\t: Effect.exit(scoped_effect);\n\t\tconst interpreted_program = Effect.gen(function* () {\n\t\t\tconst result = yield* materialized_program;\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tyield* Effect.sync(() => {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\treturn this.#runtime.runPromise(interpreted_program as Effect.Effect<A, unknown, unknown>);\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const scope of this.#component_scopes) {\n\t\t\tscope.dispose();\n\t\t}\n\n\t\tthis.#component_scopes.clear();\n\t\tthis.#runtime.runFork(\n\t\t\tScope.close(this.#root_scope, Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Read-only snapshot of the value/promise cache keys. Diagnostic surface\n\t * for leak regression tests; not part of the runtime contract.\n\t */\n\tinspect_cache(): { value_cells: readonly string[]; promise_values: readonly string[] } {\n\t\treturn {\n\t\t\tvalue_cells: [...this.#value_cells.keys()],\n\t\t\tpromise_values: [...this.#promise_values.keys()],\n\t\t};\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#scope_id(scope: ComponentScope | undefined): string {\n\t\tif (!scope || scope.disposed) {\n\t\t\treturn \"global\";\n\t\t}\n\n\t\tconst existing = this.#scope_ids.get(scope);\n\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst next = String(this.#next_scope_id);\n\t\tthis.#next_scope_id += 1;\n\t\tthis.#scope_ids.set(scope, next);\n\n\t\treturn next;\n\t}\n\n\t#clear_scope_cache(scope_id: string): void {\n\t\tconst value_prefix = `${scope_id}|`;\n\t\tconst promise_prefix = `${scope_id}|`;\n\n\t\tfor (const [cache_id, cache_key] of this.#value_ids) {\n\t\t\tif (!cache_id.startsWith(value_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#value_ids.delete(cache_id);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const [cache_id, cache_key] of this.#promise_ids) {\n\t\t\tif (!cache_id.startsWith(promise_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t}\n\n\t\t/**\n\t\t * value() and promise() evict a superseded key eagerly, so the id maps\n\t\t * above normally cover everything. Sweep the caches themselves as a\n\t\t * backstop so unmounting releases any entry the hot path missed.\n\t\t */\n\t\tconst value_key_prefix = `value:${scope_id}|`;\n\t\tconst promise_key_prefix = `promise:${scope_id}|`;\n\n\t\tfor (const cache_key of [...this.#value_cells.keys()]) {\n\t\t\tif (!cache_key.startsWith(value_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const cache_key of [...this.#promise_values.keys()]) {\n\t\t\tif (!cache_key.startsWith(promise_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t}\n\t}\n\n\t#make_scoped_id(scope_id: string, id: string): string {\n\t\treturn `${scope_id}|${id}`;\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis.#runtime.runFork(InterruptFiber(old_fiber));\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\tfiber,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tthis.#runtime.runFork(\n\t\t\t\tWatchFiberExit({\n\t\t\t\t\tfiber,\n\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn;\n\t\t}\n\n\t\tlet launch_fiber: FiberType<unknown, unknown> | undefined;\n\t\tlet forked_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tconst launched = this.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(Program), (scoped_fiber) => {\n\t\t\t\tforked_fiber = scoped_fiber;\n\n\t\t\t\t/**\n\t\t\t\t * This continuation can run synchronously inside `runFork`,\n\t\t\t\t * before `launch_fiber` is assigned. In that case nothing can\n\t\t\t\t * have superseded the launch yet and the caller below records\n\t\t\t\t * the scoped fiber itself. An asynchronous continuation takes\n\t\t\t\t * over tracking only while its launch fiber is still current;\n\t\t\t\t * a superseded launch interrupts the orphaned scoped fiber.\n\t\t\t\t */\n\t\t\t\tif (launch_fiber !== undefined) {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, launch_fiber)) {\n\t\t\t\t\t\treturn InterruptFiber(scoped_fiber);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#runtime.runFork(\n\t\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, scoped_fiber),\n\t\t\t\t\t\t\ton_success: (value) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_success(cache_key, scoped_fiber, value),\n\t\t\t\t\t\t\ton_failure: (error) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_failure(cache_key, scoped_fiber, error),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(scoped_fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tlaunch_fiber = launched;\n\t\tthis.#fibers.set(cache_key, forked_fiber ?? launched);\n\t}\n\n\t#start_promise_fiber<A>(\n\t\tcache_key: string,\n\t\toptions: PromiseOptions<A>,\n\t\tcache_id: string,\n\t): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\t/** Generator bodies passed to `Effect.gen` carry their own `this`. */\n\t\tconst dispatcher = this;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\t\t\tconst ReleaseFiber = Effect.sync(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#fibers.delete(cache_key);\n\t\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\t\tif (this.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst AwaitFiber = Effect.gen(function* () {\n\t\t\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\t\t\tyield* ReleaseFiber;\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t});\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\t\t\tthis.#promise_values.set(cache_key, this.#runtime.runPromise(AwaitFiber));\n\n\t\t\treturn this.#promise_values.get(cache_key) as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#runtime.runPromise(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst scoped_fiber = yield* scope.fork_in(Program);\n\n\t\t\t\tdispatcher.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\tdispatcher.#runtime.runFork(\n\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The promise this call returns already rejects with the\n\t\t\t\t\t\t * failure, so surfacing it again would hand a handled\n\t\t\t\t\t\t * rejection back as an uncaught error.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\ton_complete: () => {\n\t\t\t\t\t\t\tif (!dispatcher.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdispatcher.#fibers.delete(cache_key);\n\t\t\t\t\t\t\tdispatcher.#promise_values.delete(cache_key);\n\n\t\t\t\t\t\t\tif (dispatcher.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\t\t\t\tdispatcher.#promise_ids.delete(cache_id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst exit = yield* Fiber.await(scoped_fiber);\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t}),\n\t\t);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n\n/**\n * Lazily-created component scope used by generated component code.\n *\n * The holder is created synchronously during component init (before any\n * top-level `await`, where `onDestroy` is not yet available), and the scope\n * itself is materialized on first use. Disposal is registered separately\n * through `onDestroy` during component initialisation, so the scope is\n * reliably closed on unmount.\n *\n * @since 4.1.0\n */\nexport class ComponentScopeRef {\n\treadonly #get_dispatcher: () => Dispatcher;\n\t#scope: ComponentScope | undefined;\n\t#disposed = false;\n\n\tconstructor(get_dispatcher_fn: () => Dispatcher) {\n\t\tthis.#get_dispatcher = get_dispatcher_fn;\n\t}\n\n\t/** The component scope, creating it on first access. */\n\tget scope(): ComponentScope {\n\t\tif (this.#disposed) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tthis.#scope ??= this.#get_dispatcher().begin_scope();\n\n\t\treturn this.#scope;\n\t}\n\n\t/** Disposes the scope if it was created. Idempotent. */\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tconst scope = this.#scope;\n\t\tthis.#scope = undefined;\n\n\t\tif (scope && !scope.disposed) {\n\t\t\tthis.#get_dispatcher().dispose_scope(scope);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAkB,UAC9B,OAAO,IAAI,aAAa;CACvB,OAAO,MAAM,UAAU,KAAK;AAC7B,CAAC;;AAGF,MAAa,kBACZ,YACI;CACJ,MAAM,EAAE,OAAO,aAAa,YAAY,YAAY,kBAAkB,SAAS;CAE/E,OAAO,OAAO,IAAI,aAAa;EAC9B,MAAM,OAAO,OAAO,MAAM,MAAM,KAAK;EAErC,OAAO,OAAO,WAAW;GACxB,IAAI,KAAK,UAAU,IAAI,GAAG;IACzB,aAAa,KAAK,KAAU;IAC5B,cAAc;IAEd;GACD;GAEA,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK,GAAG;IACzC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;IAErC,aAAa,KAAK;IAElB,IAAI,iBACH,qBAAqB;KACpB,MAAM;IACP,CAAC;GAEH;GAEA,cAAc;EACf,CAAC;CACF,CAAC;AACF;;;;;;;;;;;;;AClCA,IAAa,iBAAb,MAAa,eAAe;CAC3B;CACA,YAAY;CACZ;CAEA,YAAoB,OAAwB,YAA6C;EACxF,KAAKC,SAAS;EACd,KAAKD,cAAc;CACpB;;CAGA,OAAO,KACN,MACA,YACiB;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BAAqC;EAChD,KAAKwB,kBAAkB;CACxB;;CAGA,IAAI,QAAwB;EAC3B,IAAI,KAAK/B,WACR,MAAM,IAAI,mBAAmB;EAG9B,KAAKgC,WAAW,KAAKD,gBAAgB,CAAC,CAAC,YAAY;EAEnD,OAAO,KAAKC;CACb;;CAGA,UAAgB;EACf,KAAKhC,YAAY;EAEjB,MAAM,QAAQ,KAAKgC;EACnB,KAAKA,SAAS,KAAA;EAEd,IAAI,SAAS,CAAC,MAAM,UACnB,KAAKD,gBAAgB,CAAC,CAAC,cAAc,KAAK;CAE5C;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { b as RuntimeAlreadyInitializedError, y as RequestEventUnavailableError } from "./errors-qhcbUH6o.js";
|
|
2
|
-
import { n as Dispatcher } from "./dispatcher-
|
|
2
|
+
import { n as Dispatcher } from "./dispatcher-D3Tpa5HC.js";
|
|
3
3
|
import { Context, Layer, ManagedRuntime } from "effect";
|
|
4
4
|
//#region src/server/runtime.ts
|
|
5
5
|
/**
|
|
@@ -90,4 +90,4 @@ function reset_server_runtime() {
|
|
|
90
90
|
//#endregion
|
|
91
91
|
export { get_server_runtime_or_throw as i, ServerRuntime as n, get_server_dispatcher as r, RequestEvent as t };
|
|
92
92
|
|
|
93
|
-
//# sourceMappingURL=runtime-
|
|
93
|
+
//# sourceMappingURL=runtime-CmiEHnSw.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-
|
|
1
|
+
{"version":3,"file":"runtime-CmiEHnSw.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import { RequestEventUnavailableError, RuntimeAlreadyInitializedError } from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\ntype ViteImportMeta = ImportMeta & {\n\treadonly env?: {\n\t\treadonly DEV?: boolean;\n\t\treadonly MODE?: string;\n\t\treadonly SSR?: boolean;\n\t};\n};\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @example\n * ```ts\n * const event: RequestEvent = yield* RequestEvent;\n * console.log(event.url.pathname);\n * ```\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends Pick<\n\tSvelteKitRequestEvent,\n\t\"cookies\" | \"getClientAddress\" | \"locals\" | \"params\" | \"platform\" | \"request\" | \"route\" | \"url\"\n> {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context.Reference<RequestEvent>(\n\t\"@ser/RequestEvent\",\n\t{\n\t\tdefaultValue: () => {\n\t\t\tthrow new RequestEventUnavailableError();\n\t\t},\n\t},\n);\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n\t/**\n\t * Build and cache the server-side `ManagedRuntime`.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The configured ManagedRuntime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): ManagedRuntime.ManagedRuntime<R, never> {\n\t\tconst should_replace_dev_runtime =\n\t\t\tcurrent_server_runtime !== undefined && is_vite_dev_ssr();\n\n\t\t/**\n\t\t * Keep duplicate production initialization loud while allowing SvelteKit's\n\t\t * dev server to re-run hooks.server.ts after an HMR invalidation.\n\t\t */\n\t\tif (current_server_runtime && !should_replace_dev_runtime) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n\t\t}\n\n\t\tif (should_replace_dev_runtime) {\n\t\t\treset_server_runtime();\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tcurrent_server_runtime = runtime as ManagedRuntime.ManagedRuntime<unknown, never>;\n\t\tcurrent_server_dispatcher = new InternalDispatcher(\n\t\t\truntime as unknown as ManagedRuntimeType<unknown, unknown>,\n\t\t);\n\n\t\treturn runtime;\n\t}\n}\n\nlet current_server_runtime: ManagedRuntime.ManagedRuntime<unknown, never> | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<unknown, never> {\n\tif (!current_server_runtime) {\n\t\tcurrent_server_runtime = ManagedRuntime.make(Layer.empty) as ManagedRuntime.ManagedRuntime<\n\t\t\tunknown,\n\t\t\tnever\n\t\t>;\n\t}\n\n\treturn current_server_runtime;\n}\n\nexport function get_server_dispatcher(): InternalDispatcher {\n\tcurrent_server_dispatcher ??= new InternalDispatcher(\n\t\tget_server_runtime_or_throw() as unknown as ManagedRuntimeType<unknown, unknown>,\n\t);\n\n\treturn current_server_dispatcher;\n}\n\nfunction is_vite_dev_ssr(): boolean {\n\tconst env = (import.meta as ViteImportMeta).env;\n\n\treturn env?.DEV === true && env?.SSR === true && env.MODE !== \"test\";\n}\n\nexport function reset_server_runtime(): void {\n\tconst dispatcher = current_server_dispatcher;\n\tconst runtime = current_server_runtime;\n\n\tcurrent_server_dispatcher = undefined;\n\tcurrent_server_runtime = undefined;\n\n\tif (dispatcher) {\n\t\tdispatcher.dispose();\n\n\t\treturn;\n\t}\n\n\tvoid runtime?.dispose().catch((error: unknown) => {\n\t\tqueueMicrotask(() => {\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAa,eAAgD,QAAQ,UACpE,qBACA,EACC,oBAAoB;CACnB,MAAM,IAAI,6BAA6B;AACxC,EACD,CACD;;;;;;;;;;;AAYA,IAAa,gBAAb,MAA2B;;;;;;;;CAQ1B,OAAO,KAAgB,OAAiE;EACvF,MAAM,6BACL,2BAA2B,KAAA,KAAa,gBAAgB;;;;;EAMzD,IAAI,0BAA0B,CAAC,4BAC9B,MAAM,IAAI,+BAA+B,eAAe;EAGzD,IAAI,4BACH,qBAAqB;EAGtB,MAAM,UAAU,eAAe,KAAK,SAAU,MAAM,KAAmC;EAEvF,yBAAyB;EACzB,4BAA4B,IAAIA,WAC/B,OACD;EAEA,OAAO;CACR;AACD;AAEA,IAAI;AACJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAA6E;CAC5F,IAAI,CAAC,wBACJ,yBAAyB,eAAe,KAAK,MAAM,KAAK;CAMzD,OAAO;AACR;AAEA,SAAgB,wBAA4C;CAC3D,8BAA8B,IAAIA,WACjC,4BAA4B,CAC7B;CAEA,OAAO;AACR;AAEA,SAAS,kBAA2B;CACnC,MAAM,MAAO,OAAO,KAAwB;CAE5C,OAAO,KAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,IAAI,SAAS;AAC/D;AAEA,SAAgB,uBAA6B;CAC5C,MAAM,aAAa;CACnB,MAAM,UAAU;CAEhB,4BAA4B,KAAA;CAC5B,yBAAyB,KAAA;CAEzB,IAAI,YAAY;EACf,WAAW,QAAQ;EAEnB;CACD;CAEA,SAAc,QAAQ,CAAC,CAAC,OAAO,UAAmB;EACjD,qBAAqB;GACpB,MAAM;EACP,CAAC;CACF,CAAC;AACF"}
|
|
@@ -22,10 +22,10 @@ export declare class Dispatcher {
|
|
|
22
22
|
*/
|
|
23
23
|
with_scope<T>(scope: ComponentScope, fn: () => T): T;
|
|
24
24
|
/**
|
|
25
|
-
* Forks an effect into a
|
|
26
|
-
* a child of the scope, so
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
* Forks an effect into a reactive-run scope and starts it. The run scope is
|
|
26
|
+
* a child of the component scope, so rerun cleanup closes only that run
|
|
27
|
+
* while component disposal remains a backstop. Returns an idempotent handle
|
|
28
|
+
* that closes the run scope and all work forked into it.
|
|
29
29
|
*
|
|
30
30
|
* Throws {@link ScopeDisposedError} when the scope was already disposed
|
|
31
31
|
* and {@link DispatcherDisposedError} when the dispatcher was shut down.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Scope } from "effect";
|
|
1
|
+
import { Effect, Exit, Scope } from "effect";
|
|
2
2
|
import type { Fiber } from "effect";
|
|
3
3
|
/**
|
|
4
4
|
* A component-owned Effect scope.
|
|
@@ -25,6 +25,15 @@ export declare class ComponentScope {
|
|
|
25
25
|
* is provided ambiently so `Effect.forkIn` registers the fiber as a child.
|
|
26
26
|
*/
|
|
27
27
|
fork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R>;
|
|
28
|
+
/**
|
|
29
|
+
* Forks an effect into a child scope owned by one reactive run. The child
|
|
30
|
+
* remains open after setup completes so nested scoped work survives until
|
|
31
|
+
* that run is invalidated, while component disposal remains its backstop.
|
|
32
|
+
*/
|
|
33
|
+
fork_run_in<A, E, R>(effect: Effect.Effect<A, E, R>): {
|
|
34
|
+
readonly fork_effect: Effect.Effect<Fiber.Fiber<A, E>, never, R>;
|
|
35
|
+
readonly close_effect: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>;
|
|
36
|
+
};
|
|
28
37
|
/** Effect that closes the scope. Must be run by the owning dispatcher. */
|
|
29
38
|
get close_effect(): Effect.Effect<void>;
|
|
30
39
|
/**
|
package/.dist/dispatcher.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-
|
|
1
|
+
import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-D3Tpa5HC.js";
|
|
2
2
|
export { Code, ComponentScope, ComponentScopeRef, Dispatcher, get_dispatcher, reset_dispatcher };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { o as EmptyStreamYieldError, p as InvalidYieldableError } from "../chunks/errors-qhcbUH6o.js";
|
|
2
|
-
import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-
|
|
2
|
+
import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-D3Tpa5HC.js";
|
|
3
3
|
import { t as RemoteLiveYield } from "../chunks/live-CHK0RrZu.js";
|
|
4
|
-
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-
|
|
4
|
+
import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
|
|
5
5
|
import { value } from "../markup/value.js";
|
|
6
6
|
import { promise } from "../markup/promise.js";
|
|
7
7
|
import { run } from "../markup/run.js";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CpWfP_1f.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
package/.dist/markup/promise.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
|
|
2
2
|
//#region src/markup/promise.ts
|
|
3
3
|
/** Runs a transform-generated promise block through the active dispatcher. */
|
|
4
4
|
function promise(id, deps, factory, ssr_fallback, options) {
|
package/.dist/markup/run.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
|
|
2
2
|
import { Effect } from "effect";
|
|
3
3
|
//#region src/markup/run.ts
|
|
4
4
|
/** Runs a transform-generated event block through the active dispatcher. */
|
package/.dist/markup/value.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
|
|
2
2
|
//#region src/markup/value.ts
|
|
3
3
|
/** Reads a transform-generated reactive value through the active dispatcher. */
|
|
4
4
|
function value(id, deps, fallback, factory) {
|
package/.dist/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as UnsupportedMarkupEffectPositionError, C as ServerOnlyImportError, D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMissingError, M as YieldStarInEventCallbackError, O as UncheckedPrerenderHandlerMissingError, S as ScopeDisposedError, T as UncheckedCommandHandlerMissingError, _ as RemoteHelperContextError, a as DispatcherDisposedError, b as RuntimeAlreadyInitializedError, c as InvalidLiveQueryFactoryError, d as InvalidQueryFactoryError, f as InvalidRemoteFormResponseError, g as RemoteFormEndpointMissingError, h as RemoteErrorDecodeError, i as BatchQueryHandlerMissingError, j as UnsupportedRemoteFormResponseError, k as UncheckedQueryHandlerMissingError, l as InvalidLiveQueryReturnError, m as PreprocessError, n as AsyncEffectInSyncRuneError, o as EmptyStreamYieldError, p as InvalidYieldableError, r as AwaitInEffectWorkError, s as InvalidCommandFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidPrerenderFactoryError, v as RemoteHelperError, w as SvelteKitServerExportUnavailableError, x as RuntimeError, y as RequestEventUnavailableError } from "./chunks/errors-qhcbUH6o.js";
|
|
2
|
-
import { n as Dispatcher } from "./chunks/dispatcher-
|
|
2
|
+
import { n as Dispatcher } from "./chunks/dispatcher-D3Tpa5HC.js";
|
|
3
3
|
import { DefineEnvVars } from "./environment.js";
|
|
4
4
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
5
5
|
import { t as Live } from "./chunks/live-BW7xZKjb.js";
|
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CpWfP_1f.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
package/.dist/server.js
CHANGED
|
@@ -3,7 +3,7 @@ import { create_form_error, create_remote_transport_error } from "./remote/share
|
|
|
3
3
|
import { i as make_remote_live_stream, r as make_failed_remote_live_stream, t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
4
4
|
import { a as normalize_validator, c as attach_remote_resource_getters, d as MakeEffectFromPromise, f as MakeEffectFromSync, l as is_remote_resource, n as attach_native_remote_query_update, o as attach_failed_remote_query_resource, r as resolve_native_remote_query_updates, s as attach_failed_remote_resource_getters, t as copy_property_descriptors, u as FailWithRemoteError } from "./chunks/descriptors-q909VWyR.js";
|
|
5
5
|
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-BNxq-pUH.js";
|
|
6
|
-
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-
|
|
6
|
+
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-CmiEHnSw.js";
|
|
7
7
|
import { Effect, Result, Stream } from "effect";
|
|
8
8
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
9
9
|
import { stringify } from "devalue";
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher-DGSStOLQ.js","names":["#on_dispose","#scope","#disposed","#notify_value_cells","#runtime","#root_scope","#component_scopes","#current_scope","#disposed","#scope_ids","#clear_scope_cache","#emit_markup_value","#emit_markup_promise","#emit_markup_run","#next_fiber_id","#fibers","#scope_id","#make_scoped_id","#make_value_cache_key","#value_ids","#subscribe_value_cells","#value_cells","#interrupt_cached_fiber","#delete_value_cell","#should_start_value_fiber","#start_value_fiber","#make_promise_cache_key","#promise_ids","#promise_values","#start_promise_fiber","#is_server_render","#clear_value_cells","#hash_deps","#next_scope_id","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#get_dispatcher","#scope"],"sources":["../../../modules/svelte-effect-runtime/src/dispatcher/fibers.ts","../../../modules/svelte-effect-runtime/src/dispatcher/scope.ts","../../../modules/svelte-effect-runtime/src/dispatcher/deps.ts","../../../modules/svelte-effect-runtime/src/dispatcher/types.ts","../../../modules/svelte-effect-runtime/src/dispatcher/index.ts"],"sourcesContent":["import type { Fiber as FiberType } from \"effect/Fiber\";\nimport { Cause, Effect, Exit, Fiber } from \"effect\";\n\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\nexport const InterruptFiber = (fiber: FiberType<unknown, unknown>) =>\n\tEffect.gen(function* () {\n\t\tyield* Fiber.interrupt(fiber);\n\t});\n\n/** Observes fiber completion and surfaces failures without taking ownership of the fiber. */\nexport const WatchFiberExit = <A>(\n\toptions: { fiber: FiberType<unknown, unknown> } & FiberWatchCallbacks<A>,\n) => {\n\tconst { fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\treturn Effect.gen(function* () {\n\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\tyield* Effect.sync(() => {\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\ton_complete?.();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\ton_failure?.(error);\n\n\t\t\t\tif (surface_failure) {\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ton_complete?.();\n\t\t});\n\t});\n};\n","import { Effect, Exit, Scope } from \"effect\";\nimport type { Fiber } from \"effect\";\n\n/**\n * A component-owned Effect scope.\n *\n * A `ComponentScope` wraps a `Scope.Closeable` forked from the dispatcher's\n * root scope. Work is forked into the scope with `Effect.forkIn`, so closing\n * the scope interrupts that work and runs its finalizers. The generated\n * component teardown disposes the scope on destroy. Disposal is idempotent.\n *\n * @since 4.1.0\n */\nexport class ComponentScope {\n\t#scope: Scope.Closeable;\n\t#disposed = false;\n\treadonly #on_dispose: (scope: ComponentScope) => void;\n\n\tprivate constructor(scope: Scope.Closeable, on_dispose: (scope: ComponentScope) => void) {\n\t\tthis.#scope = scope;\n\t\tthis.#on_dispose = on_dispose;\n\t}\n\n\t/** Forks a child scope from the given root and returns it wrapped. */\n\tstatic fork(\n\t\troot: Scope.Closeable,\n\t\ton_dispose: (scope: ComponentScope) => void,\n\t): ComponentScope {\n\t\treturn new ComponentScope(Scope.forkUnsafe(root), on_dispose);\n\t}\n\n\t/** The underlying closeable scope used to bind Effect work. */\n\tget underlying(): Scope.Closeable {\n\t\treturn this.#scope;\n\t}\n\n\t/** Whether this scope has already been disposed. */\n\tget disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Forks an effect into this scope. The fiber becomes a child of the scope,\n\t * so disposing the scope interrupts it and runs its finalizers. The scope\n\t * is provided ambiently so `Effect.forkIn` registers the fiber as a child.\n\t */\n\tfork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R> {\n\t\t/**\n\t\t * The effect must see the scope before it is forked: provide the scope\n\t\t * inside the forked program so `acquireRelease`-style work resolves it,\n\t\t * and fork that program into the scope so the fiber is a child whose\n\t\t * finalizers run when the scope closes.\n\t\t */\n\t\treturn Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, this.#scope),\n\t\t\tthis.#scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t}\n\n\t/** Effect that closes the scope. Must be run by the owning dispatcher. */\n\tget close_effect(): Effect.Effect<void> {\n\t\treturn Scope.close(this.#scope, Exit.void);\n\t}\n\n\t/**\n\t * Marks the scope disposed and detaches it from the dispatcher. The caller\n\t * is responsible for running {@link close_effect} to run finalizers.\n\t * Idempotent.\n\t */\n\tdispose(): void {\n\t\tif (this.#disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#disposed = true;\n\t\tthis.#on_dispose(this);\n\t}\n}\n","/** Assigns stable identities to object dependencies while hashing value dependencies. */\nexport type DependencyHasher = (deps: readonly unknown[]) => string;\n\nexport function make_dependency_hasher(): DependencyHasher {\n\tconst object_dep_ids = new WeakMap<object, number>();\n\tconst symbol_dep_ids = new Map<symbol, number>();\n\n\tlet next_object_dep_id = 0;\n\tlet next_symbol_dep_id = 0;\n\n\tconst hash_symbol_dep = (dep: symbol): string => {\n\t\tlet id = symbol_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_symbol_dep_id += 1;\n\t\t\tid = next_symbol_dep_id;\n\t\t\tsymbol_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `y:${id}`;\n\t};\n\n\tconst hash_object_dep = (dep: object): string => {\n\t\tlet id = object_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_object_dep_id += 1;\n\t\t\tid = next_object_dep_id;\n\t\t\tobject_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `o:${id}`;\n\t};\n\n\tconst hash_dep = (dep: unknown): string | readonly [\"s\", string] => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep as string];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t};\n\n\tconst hash_deps = (deps: readonly unknown[]): string => JSON.stringify(deps.map(hash_dep));\n\n\treturn hash_deps;\n}\n","import type { Effect } from \"effect\";\n\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\nexport type Dispose = () => void;\n\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupValueEvent<A, F> {\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupPromiseEvent<A> {\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\nexport interface MarkupRunEvent<A> {\n\ttype: typeof Code.Markup.Run;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\nimport {\n\tRuntimeAlreadyInitializedError,\n\tDispatcherDisposedError,\n\tScopeDisposedError,\n} from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime, Scope } from \"effect\";\nimport { InterruptFiber, WatchFiberExit } from \"./fibers.ts\";\nimport { ComponentScope } from \"./scope.ts\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport { make_dependency_hasher } from \"./deps.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Code } from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\nexport class Dispatcher {\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t#notify_value_cells = (): void => {};\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t#value_ids = new Map<string, string>();\n\t#promise_ids = new Map<string, string>();\n\t#scope_ids = new WeakMap<ComponentScope, string>();\n\t#hash_deps = make_dependency_hasher();\n\t#disposed = false;\n\t#next_fiber_id = 0;\n\t#next_scope_id = 0;\n\t#root_scope = Scope.makeUnsafe();\n\t#component_scopes = new Set<ComponentScope>();\n\t/**\n\t * The component scope that effect execution currently enters. Set by\n\t * generated code via {@link with_scope}; `undefined` outside components.\n\t */\n\t#current_scope: ComponentScope | undefined = undefined;\n\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Begin a component-owned Effect scope. Pass the returned scope to\n\t * {@link run_scoped} so the work is interrupted and finalized when the\n\t * component is destroyed. Disposal is idempotent.\n\t */\n\tbegin_scope(): ComponentScope {\n\t\tconst scope = ComponentScope.fork(this.#root_scope, (disposed) => {\n\t\t\tthis.#component_scopes.delete(disposed);\n\t\t});\n\n\t\tthis.#component_scopes.add(scope);\n\n\t\treturn scope;\n\t}\n\n\t/**\n\t * Runs `fn` with `scope` as the current component scope. While active,\n\t * every effect path ({@link promise}, {@link run}, {@link value}) forks\n\t * its work into `scope` so disposing the scope interrupts it and runs its\n\t * finalizers. A disposed scope falls back to unscoped execution.\n\t */\n\twith_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\tif (scope.disposed) {\n\t\t\treturn fn();\n\t\t}\n\n\t\tconst previous = this.#current_scope;\n\t\tthis.#current_scope = scope;\n\n\t\ttry {\n\t\t\treturn fn();\n\t\t} finally {\n\t\t\tthis.#current_scope = previous;\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect into a component scope and starts it. The fiber becomes\n\t * a child of the scope, so disposing the scope interrupts it and runs its\n\t * finalizers. Returns an idempotent handle that interrupts the scoped\n\t * fiber directly.\n\t *\n\t * Throws {@link ScopeDisposedError} when the scope was already disposed\n\t * and {@link DispatcherDisposedError} when the dispatcher was shut down.\n\t */\n\trun_scoped<A, E, R>(scope: ComponentScope, effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tif (scope.disposed || !this.#component_scopes.has(scope)) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\t/**\n\t\t * Track the scoped fiber itself: `forkIn` binds it to the component\n\t\t * scope rather than the awaiting parent, so per-run disposal must\n\t\t * interrupt the scoped fiber directly.\n\t\t */\n\t\tlet scoped_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tthis.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(effect), (fiber) => {\n\t\t\t\tscoped_fiber = fiber;\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\n\t\t\tif (scoped_fiber) {\n\t\t\t\tthis.#runtime.runFork(InterruptFiber(scoped_fiber));\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Disposes a component scope owned by this dispatcher, interrupting its\n\t * bound work and running its finalizers. Idempotent. Rejects scopes owned\n\t * by another dispatcher with {@link ScopeDisposedError}.\n\t */\n\tdispose_scope(scope: ComponentScope): void {\n\t\tif (!this.#component_scopes.has(scope)) {\n\t\t\tif (scope.disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tconst scope_id = this.#scope_ids.get(scope);\n\n\t\tif (scope_id !== undefined) {\n\t\t\tthis.#scope_ids.delete(scope);\n\t\t\tthis.#clear_scope_cache(scope_id);\n\t\t}\n\n\t\tscope.dispose();\n\t\tthis.#runtime.runFork(scope.close_effect as Effect.Effect<unknown, unknown, unknown>);\n\t}\n\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t\t}),\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t};\n\t}\n\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_value_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#value_ids.get(cache_id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#delete_value_cell(old_key);\n\t\t}\n\n\t\tthis.#value_ids.set(cache_id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_promise_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(cache_id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(cache_id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options, cache_id);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scoped_effect = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.exit(effect);\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Surface the failure without reporting it. Both the scoped and the\n\t\t\t * unscoped path funnel through `interpreted_program`, which reports\n\t\t\t * once, so reporting here would raise every failure twice.\n\t\t\t */\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\tconst scope = this.#current_scope;\n\t\tconst materialized_program = scope\n\t\t\t? Effect.flatMap(scope.fork_in(scoped_effect), (fiber) => Fiber.await(fiber))\n\t\t\t: Effect.exit(scoped_effect);\n\t\tconst interpreted_program = Effect.gen(function* () {\n\t\t\tconst result = yield* materialized_program;\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tyield* Effect.sync(() => {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\treturn this.#runtime.runPromise(interpreted_program as Effect.Effect<A, unknown, unknown>);\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const scope of this.#component_scopes) {\n\t\t\tscope.dispose();\n\t\t}\n\n\t\tthis.#component_scopes.clear();\n\t\tthis.#runtime.runFork(\n\t\t\tScope.close(this.#root_scope, Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Read-only snapshot of the value/promise cache keys. Diagnostic surface\n\t * for leak regression tests; not part of the runtime contract.\n\t */\n\tinspect_cache(): { value_cells: readonly string[]; promise_values: readonly string[] } {\n\t\treturn {\n\t\t\tvalue_cells: [...this.#value_cells.keys()],\n\t\t\tpromise_values: [...this.#promise_values.keys()],\n\t\t};\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#scope_id(scope: ComponentScope | undefined): string {\n\t\tif (!scope || scope.disposed) {\n\t\t\treturn \"global\";\n\t\t}\n\n\t\tconst existing = this.#scope_ids.get(scope);\n\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst next = String(this.#next_scope_id);\n\t\tthis.#next_scope_id += 1;\n\t\tthis.#scope_ids.set(scope, next);\n\n\t\treturn next;\n\t}\n\n\t#clear_scope_cache(scope_id: string): void {\n\t\tconst value_prefix = `${scope_id}|`;\n\t\tconst promise_prefix = `${scope_id}|`;\n\n\t\tfor (const [cache_id, cache_key] of this.#value_ids) {\n\t\t\tif (!cache_id.startsWith(value_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#value_ids.delete(cache_id);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const [cache_id, cache_key] of this.#promise_ids) {\n\t\t\tif (!cache_id.startsWith(promise_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t}\n\n\t\t/**\n\t\t * value() and promise() evict a superseded key eagerly, so the id maps\n\t\t * above normally cover everything. Sweep the caches themselves as a\n\t\t * backstop so unmounting releases any entry the hot path missed.\n\t\t */\n\t\tconst value_key_prefix = `value:${scope_id}|`;\n\t\tconst promise_key_prefix = `promise:${scope_id}|`;\n\n\t\tfor (const cache_key of [...this.#value_cells.keys()]) {\n\t\t\tif (!cache_key.startsWith(value_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const cache_key of [...this.#promise_values.keys()]) {\n\t\t\tif (!cache_key.startsWith(promise_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t}\n\t}\n\n\t#make_scoped_id(scope_id: string, id: string): string {\n\t\treturn `${scope_id}|${id}`;\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis.#runtime.runFork(InterruptFiber(old_fiber));\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\tfiber,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tthis.#runtime.runFork(\n\t\t\t\tWatchFiberExit({\n\t\t\t\t\tfiber,\n\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn;\n\t\t}\n\n\t\tlet launch_fiber: FiberType<unknown, unknown> | undefined;\n\t\tlet forked_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tconst launched = this.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(Program), (scoped_fiber) => {\n\t\t\t\tforked_fiber = scoped_fiber;\n\n\t\t\t\t/**\n\t\t\t\t * This continuation can run synchronously inside `runFork`,\n\t\t\t\t * before `launch_fiber` is assigned. In that case nothing can\n\t\t\t\t * have superseded the launch yet and the caller below records\n\t\t\t\t * the scoped fiber itself. An asynchronous continuation takes\n\t\t\t\t * over tracking only while its launch fiber is still current;\n\t\t\t\t * a superseded launch interrupts the orphaned scoped fiber.\n\t\t\t\t */\n\t\t\t\tif (launch_fiber !== undefined) {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, launch_fiber)) {\n\t\t\t\t\t\treturn InterruptFiber(scoped_fiber);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#runtime.runFork(\n\t\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, scoped_fiber),\n\t\t\t\t\t\t\ton_success: (value) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_success(cache_key, scoped_fiber, value),\n\t\t\t\t\t\t\ton_failure: (error) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_failure(cache_key, scoped_fiber, error),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(scoped_fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tlaunch_fiber = launched;\n\t\tthis.#fibers.set(cache_key, forked_fiber ?? launched);\n\t}\n\n\t#start_promise_fiber<A>(\n\t\tcache_key: string,\n\t\toptions: PromiseOptions<A>,\n\t\tcache_id: string,\n\t): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\t/** Generator bodies passed to `Effect.gen` carry their own `this`. */\n\t\tconst dispatcher = this;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\t\t\tconst ReleaseFiber = Effect.sync(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#fibers.delete(cache_key);\n\t\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\t\tif (this.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst AwaitFiber = Effect.gen(function* () {\n\t\t\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\t\t\tyield* ReleaseFiber;\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t});\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\t\t\tthis.#promise_values.set(cache_key, this.#runtime.runPromise(AwaitFiber));\n\n\t\t\treturn this.#promise_values.get(cache_key) as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#runtime.runPromise(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst scoped_fiber = yield* scope.fork_in(Program);\n\n\t\t\t\tdispatcher.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\tdispatcher.#runtime.runFork(\n\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The promise this call returns already rejects with the\n\t\t\t\t\t\t * failure, so surfacing it again would hand a handled\n\t\t\t\t\t\t * rejection back as an uncaught error.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\ton_complete: () => {\n\t\t\t\t\t\t\tif (!dispatcher.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdispatcher.#fibers.delete(cache_key);\n\t\t\t\t\t\t\tdispatcher.#promise_values.delete(cache_key);\n\n\t\t\t\t\t\t\tif (dispatcher.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\t\t\t\tdispatcher.#promise_ids.delete(cache_id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst exit = yield* Fiber.await(scoped_fiber);\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t}),\n\t\t);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n\n/**\n * Lazily-created component scope used by generated component code.\n *\n * The holder is created synchronously during component init (before any\n * top-level `await`, where `onDestroy` is not yet available), and the scope\n * itself is materialized on first use. Disposal is registered separately\n * through `onDestroy` during component initialisation, so the scope is\n * reliably closed on unmount.\n *\n * @since 4.1.0\n */\nexport class ComponentScopeRef {\n\treadonly #get_dispatcher: () => Dispatcher;\n\t#scope: ComponentScope | undefined;\n\t#disposed = false;\n\n\tconstructor(get_dispatcher_fn: () => Dispatcher) {\n\t\tthis.#get_dispatcher = get_dispatcher_fn;\n\t}\n\n\t/** The component scope, creating it on first access. */\n\tget scope(): ComponentScope {\n\t\tif (this.#disposed) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tthis.#scope ??= this.#get_dispatcher().begin_scope();\n\n\t\treturn this.#scope;\n\t}\n\n\t/** Disposes the scope if it was created. Idempotent. */\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tconst scope = this.#scope;\n\t\tthis.#scope = undefined;\n\n\t\tif (scope && !scope.disposed) {\n\t\t\tthis.#get_dispatcher().dispose_scope(scope);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAkB,UAC9B,OAAO,IAAI,aAAa;CACvB,OAAO,MAAM,UAAU,KAAK;AAC7B,CAAC;;AAGF,MAAa,kBACZ,YACI;CACJ,MAAM,EAAE,OAAO,aAAa,YAAY,YAAY,kBAAkB,SAAS;CAE/E,OAAO,OAAO,IAAI,aAAa;EAC9B,MAAM,OAAO,OAAO,MAAM,MAAM,KAAK;EAErC,OAAO,OAAO,WAAW;GACxB,IAAI,KAAK,UAAU,IAAI,GAAG;IACzB,aAAa,KAAK,KAAU;IAC5B,cAAc;IAEd;GACD;GAEA,IAAI,CAAC,MAAM,kBAAkB,KAAK,KAAK,GAAG;IACzC,MAAM,QAAQ,MAAM,OAAO,KAAK,KAAK;IAErC,aAAa,KAAK;IAElB,IAAI,iBACH,qBAAqB;KACpB,MAAM;IACP,CAAC;GAEH;GAEA,cAAc;EACf,CAAC;CACF,CAAC;AACF;;;;;;;;;;;;;AClCA,IAAa,iBAAb,MAAa,eAAe;CAC3B;CACA,YAAY;CACZ;CAEA,YAAoB,OAAwB,YAA6C;EACxF,KAAKC,SAAS;EACd,KAAKD,cAAc;CACpB;;CAGA,OAAO,KACN,MACA,YACiB;EACjB,OAAO,IAAI,eAAe,MAAM,WAAW,IAAI,GAAG,UAAU;CAC7D;;CAGA,IAAI,aAA8B;EACjC,OAAO,KAAKC;CACb;;CAGA,IAAI,WAAoB;EACvB,OAAO,KAAKC;CACb;;;;;;CAOA,QAAiB,QAA4E;;;;;;;EAO5F,OAAO,OAAO,OACb,OAAO,eAAe,QAAQ,MAAM,OAAO,KAAKD,MAAM,GACtD,KAAKA,MACN;CACD;;CAGA,IAAI,eAAoC;EACvC,OAAO,M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