svelte-effect-runtime 4.2.0 → 4.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{server-NeyeDSax.js → server-BNxq-pUH.js} +29 -14
- package/.dist/chunks/server-BNxq-pUH.js.map +1 -0
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/remote/diagnostics.d.ts +17 -1
- package/.dist/remote/server.d.ts +3 -3
- package/.dist/remote/server.js +1 -1
- package/.dist/runtime/transform.js +6 -1
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/server.js +4 -4
- package/.dist/server.js.map +1 -1
- package/package.json +1 -1
- package/.dist/chunks/server-NeyeDSax.js.map +0 -1
|
@@ -36,14 +36,15 @@ const remedies = {
|
|
|
36
36
|
* @param context - Optional request detail for the log header.
|
|
37
37
|
* @param report - Sink for the rendered report; defaults to `console.error`.
|
|
38
38
|
*/
|
|
39
|
-
function report_opaque_remote_failure(reason, cause, value,
|
|
39
|
+
function report_opaque_remote_failure(reason, cause, value, resolve_context, report = default_reporter) {
|
|
40
40
|
/**
|
|
41
|
-
* Reporting runs before SvelteKit's error helper, and the failure
|
|
42
|
-
* describes
|
|
43
|
-
* the
|
|
41
|
+
* Reporting runs before SvelteKit's error helper, and both the failure and
|
|
42
|
+
* the request it describes are arbitrary values SER does not own. Resolve
|
|
43
|
+
* the context in here so a request event that refuses a property cannot
|
|
44
|
+
* replace the 500 the handler owes the client.
|
|
44
45
|
*/
|
|
45
46
|
try {
|
|
46
|
-
report(render_opaque_remote_failure(reason, cause, value,
|
|
47
|
+
report(render_opaque_remote_failure(reason, cause, value, resolve_context?.()));
|
|
47
48
|
} catch {}
|
|
48
49
|
}
|
|
49
50
|
/**
|
|
@@ -274,18 +275,18 @@ const is_tagged_form_error = Schema.is(Schema.Struct({ _tag: Schema.Literal("For
|
|
|
274
275
|
const request_event_context_error_start = "Can only read the current request event inside functions invoked during `handle`";
|
|
275
276
|
const request_store_context_error = "Could not get the request store.";
|
|
276
277
|
/** Maps a remote Effect exit into the control flow expected by SvelteKit. */
|
|
277
|
-
async function run_remote_effect(effect, runtime, invalid, error,
|
|
278
|
+
async function run_remote_effect(effect, runtime, invalid, error, resolve_context) {
|
|
278
279
|
const exit = await runtime.runPromise(Effect.exit(effect));
|
|
279
280
|
if (Exit.isSuccess(exit)) return exit.value;
|
|
280
|
-
throw_remote_cause(exit.cause, invalid, error,
|
|
281
|
+
throw_remote_cause(exit.cause, invalid, error, resolve_context);
|
|
281
282
|
}
|
|
282
283
|
/** Applies a classified remote Cause decision to SvelteKit's server helpers. */
|
|
283
|
-
function throw_remote_cause(cause, invalid, error,
|
|
284
|
+
function throw_remote_cause(cause, invalid, error, resolve_context, report) {
|
|
284
285
|
const resolution = classify_remote_cause(cause);
|
|
285
286
|
switch (resolution._tag) {
|
|
286
287
|
case "SvelteKitControlFlow": throw resolution.value;
|
|
287
288
|
case "InterruptOnly":
|
|
288
|
-
report_opaque_remote_failure("interrupted", resolution.cause, void 0,
|
|
289
|
+
report_opaque_remote_failure("interrupted", resolution.cause, void 0, resolve_context, report);
|
|
289
290
|
throw Cause.squash(resolution.cause);
|
|
290
291
|
case "FormInvalid": invalid(...resolution.issues);
|
|
291
292
|
case "RemoteFailure": {
|
|
@@ -294,7 +295,7 @@ function throw_remote_cause(cause, invalid, error, context, report) {
|
|
|
294
295
|
* The client only receives a generic 500 for a failure SER could not
|
|
295
296
|
* encode, so the original error is reported here or lost entirely.
|
|
296
297
|
*/
|
|
297
|
-
if (resolution.opaque) report_opaque_remote_failure(resolution.opaque.reason, cause, resolution.opaque.value,
|
|
298
|
+
if (resolution.opaque) report_opaque_remote_failure(resolution.opaque.reason, cause, resolution.opaque.value, resolve_context, report);
|
|
298
299
|
error(500, envelope);
|
|
299
300
|
}
|
|
300
301
|
}
|
|
@@ -312,15 +313,29 @@ function throw_remote_cause(cause, invalid, error, context, report) {
|
|
|
312
313
|
* @returns Request detail for opaque failure reports.
|
|
313
314
|
*/
|
|
314
315
|
function to_remote_failure_context(event) {
|
|
315
|
-
const method = event.request?.method;
|
|
316
|
-
const route = event.route?.id ?? void 0;
|
|
317
|
-
const url = event.url?.pathname;
|
|
316
|
+
const method = read_event_detail(() => event.request?.method);
|
|
317
|
+
const route = read_event_detail(() => event.route?.id ?? void 0);
|
|
318
|
+
const url = read_event_detail(() => event.url?.pathname);
|
|
318
319
|
return {
|
|
319
320
|
...method ? { method } : {},
|
|
320
321
|
...route ? { route } : {},
|
|
321
322
|
...url ? { url } : {}
|
|
322
323
|
};
|
|
323
324
|
}
|
|
325
|
+
/**
|
|
326
|
+
* Reads one request detail, tolerating an event that refuses it.
|
|
327
|
+
*
|
|
328
|
+
* SvelteKit restricts which parts of a request a remote function may observe,
|
|
329
|
+
* and the set has changed across releases. A diagnostic must never be the
|
|
330
|
+
* reason a handler cannot answer, so an unavailable detail is simply omitted.
|
|
331
|
+
*/
|
|
332
|
+
function read_event_detail(read) {
|
|
333
|
+
try {
|
|
334
|
+
return read();
|
|
335
|
+
} catch {
|
|
336
|
+
return;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
324
339
|
function throw_form_error(issues, invalid) {
|
|
325
340
|
invalid(...issues);
|
|
326
341
|
}
|
|
@@ -336,4 +351,4 @@ function is_sveltekit_remote_context_error(err) {
|
|
|
336
351
|
//#endregion
|
|
337
352
|
export { to_remote_failure_context as a, throw_remote_cause as i, run_remote_effect as n, encode_remote_failure as o, throw_form_error as r, normalize_remote_helper_error as t };
|
|
338
353
|
|
|
339
|
-
//# sourceMappingURL=server-
|
|
354
|
+
//# sourceMappingURL=server-BNxq-pUH.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-BNxq-pUH.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/diagnostics.ts","../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { Cause } from \"effect\";\n\n/**\n * Why a remote failure reached the client without its original detail.\n *\n * @example\n * ```ts\n * const reason: OpaqueRemoteFailureReason = \"untagged\";\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailureReason = \"untagged\" | \"unserializable\" | \"unknown\" | \"interrupted\";\n\n/**\n * Request detail attached to an opaque remote failure report so the log line\n * points at the handler that produced it.\n *\n * @example\n * ```ts\n * const context: RemoteFailureContext = { method: \"POST\", url: \"/checkout\" };\n * ```\n *\n * @since 4.2.0\n */\nexport type RemoteFailureContext = {\n\treadonly method?: string;\n\treadonly route?: string;\n\treadonly url?: string;\n};\n\n/**\n * Defers building a {@link RemoteFailureContext} until a report is actually\n * rendered.\n *\n * The context describes a request SER never otherwise inspects, so resolving\n * it eagerly would read request-event properties on every remote call to\n * describe the few that fail.\n *\n * @example\n * ```ts\n * const resolve: ResolveRemoteFailureContext = () => ({ url: event.url.pathname });\n * ```\n *\n * @since 4.2.1\n */\nexport type ResolveRemoteFailureContext = () => RemoteFailureContext | undefined;\n\ntype Reporter = (message: string) => void;\n\nconst explanations: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"the failure has no string `_tag`, so it cannot be told apart from an arbitrary object on the wire\",\n\tunserializable:\n\t\t\"the failure could not be serialized, even after being reduced to its own enumerable properties\",\n\tunknown: \"the cause carries no failure reason, so there was nothing to serialize\",\n\tinterrupted: \"the handler's fiber was interrupted before it produced a result\",\n};\n\nconst remedies: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"Fail with a tagged error (`Data.TaggedError` or `Schema.TaggedError`) so SER can carry it to the client.\",\n\tunserializable:\n\t\t\"Remove non-transportable values (functions, class instances, cycles) from the error, or map it to a tagged error first.\",\n\tunknown:\n\t\t\"Check for a defect thrown outside the Effect error channel; the original value is shown above.\",\n\tinterrupted:\n\t\t\"An interrupt usually means the runtime was disposed mid-request, for example when the dev server restarted while this request was in flight.\",\n};\n\n/**\n * Reports a remote failure that had to be replaced with an opaque envelope.\n *\n * SER cannot send an unrecognized failure to the browser, so the client only\n * ever sees a generic 500. Without this report the original error would be\n * lost entirely, which is the difference between a debuggable failure and a\n * silent one.\n *\n * @example\n * ```ts\n * report_opaque_remote_failure(\"untagged\", cause, value, { url: \"/checkout\" });\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @param report - Sink for the rendered report; defaults to `console.error`.\n */\nexport function report_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tresolve_context?: ResolveRemoteFailureContext,\n\treport: Reporter = default_reporter,\n): void {\n\t/**\n\t * Reporting runs before SvelteKit's error helper, and both the failure and\n\t * the request it describes are arbitrary values SER does not own. Resolve\n\t * the context in here so a request event that refuses a property cannot\n\t * replace the 500 the handler owes the client.\n\t */\n\ttry {\n\t\treport(render_opaque_remote_failure(reason, cause, value, resolve_context?.()));\n\t} catch {\n\t\t/** A diagnostic is never worth failing the request over. */\n\t}\n}\n\n/**\n * Renders the report emitted by {@link report_opaque_remote_failure}.\n *\n * @example\n * ```ts\n * const message = render_opaque_remote_failure(\"untagged\", cause, value);\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @returns The multi-line report.\n */\nexport function render_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tcontext?: RemoteFailureContext,\n): string {\n\tconst request = render_request(context);\n\tconst lines = [\n\t\t\"[svelte-effect-runtime] A remote handler failed with an error that could not be sent to the client.\",\n\t\t` Reason: ${explanations[reason]}.`,\n\t];\n\n\tif (request) {\n\t\tlines.push(` Request: ${request}`);\n\t}\n\n\tif (reason !== \"interrupted\") {\n\t\tlines.push(` Failure: ${inspect_failure(value)}`);\n\t}\n\n\tlines.push(\" Cause:\", indent(pretty_cause(cause)), ` Fix: ${remedies[reason]}`);\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction render_request(context?: RemoteFailureContext): string | undefined {\n\tif (!context) {\n\t\treturn undefined;\n\t}\n\n\tconst target = context.url ?? context.route;\n\tconst parts = [context.method, target].filter(Boolean);\n\tconst names_route = Boolean(context.route && context.url && context.route !== context.url);\n\tconst route = names_route ? ` (route ${context.route})` : \"\";\n\n\tif (parts.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn `${parts.join(\" \")}${route}`;\n}\n\nfunction pretty_cause(cause: Cause.Cause<unknown>): string {\n\ttry {\n\t\treturn Cause.pretty(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n}\n\n/**\n * Renders the failure value itself. Errors keep their stack because that is\n * the only part of an untagged failure that identifies its source.\n */\nfunction inspect_failure(value: unknown): string {\n\tif (value === undefined) {\n\t\treturn \"(none)\";\n\t}\n\n\tif (value instanceof globalThis.Error) {\n\t\treturn value.stack ?? `${value.name}: ${value.message}`;\n\t}\n\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn describe_primitive(value);\n\t}\n\n\ttry {\n\t\treturn JSON.stringify(value, undefined, 2) ?? describe_object(value);\n\t} catch {\n\t\treturn describe_object(value);\n\t}\n}\n\n/** A primitive can still carry a throwing `Symbol.toPrimitive`. */\nfunction describe_primitive(value: unknown): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\treturn typeof value;\n\t}\n}\n\n/**\n * Falls back through conversions an object can subvert. A null-prototype or\n * hostile object may throw from `toString` and lack `Object.prototype`, so the\n * last resort must not touch the value at all.\n */\nfunction describe_object(value: object): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\t/** Fall through to a conversion the value cannot override. */\n\t}\n\n\ttry {\n\t\treturn Object.prototype.toString.call(value);\n\t} catch {\n\t\treturn \"[unrenderable failure]\";\n\t}\n}\n\nfunction indent(value: string): string {\n\treturn value\n\t\t.split(\"\\n\")\n\t\t.map((line) => ` ${line}`)\n\t\t.join(\"\\n\");\n}\n\nfunction default_reporter(message: string): void {\n\tconsole.error(message);\n}\n","import type { OpaqueRemoteFailureReason } from \"$/remote/diagnostics.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\n\n/**\n * Records that a failure lost its detail on the way to the client, so callers\n * can report the original error instead of dropping it silently.\n *\n * @example\n * ```ts\n * const diagnostic: OpaqueRemoteFailure = { reason: \"untagged\", value: err };\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailure = {\n\treadonly reason: OpaqueRemoteFailureReason;\n\treadonly value: unknown;\n};\n\ntype EncodedRemoteFailure = {\n\treadonly encoded: string;\n\treadonly opaque?: OpaqueRemoteFailure;\n};\n\nexport type RemoteCauseResolution =\n\t| {\n\t\t\treadonly _tag: \"SvelteKitControlFlow\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"InterruptOnly\";\n\t\t\treadonly cause: Cause.Cause<unknown>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"FormInvalid\";\n\t\t\treadonly issues: readonly FormIssue[];\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFailure\";\n\t\t\treadonly encoded: string;\n\t\t\treadonly opaque?: OpaqueRemoteFailure;\n\t };\n\n/** Preserves SvelteKit control flow before classifying transportable Effect failures. */\nexport function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution {\n\tconst control_flow = find_sveltekit_control_flow(cause);\n\n\tif (control_flow !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"SvelteKitControlFlow\",\n\t\t\tvalue: control_flow,\n\t\t};\n\t}\n\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\treturn {\n\t\t\t_tag: \"InterruptOnly\",\n\t\t\tcause,\n\t\t};\n\t}\n\n\tconst form_error_issues = find_form_error_issues(cause);\n\n\tif (form_error_issues !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"FormInvalid\",\n\t\t\tissues: form_error_issues,\n\t\t};\n\t}\n\n\tconst failure = encode_remote_failure_detailed(cause);\n\n\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: failure.encoded,\n\t\t...(failure.opaque ? { opaque: failure.opaque } : {}),\n\t};\n}\n\n/** Encodes a remote failure into the transport ABI shared with generated clients. */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\treturn encode_remote_failure_detailed(cause).encoded;\n}\n\n/**\n * Encodes a remote failure and reports whether its detail survived encoding.\n *\n * @example\n * ```ts\n * const { encoded, opaque } = encode_remote_failure_detailed(cause);\n * ```\n *\n * @since 4.2.0\n * @param cause - Cause carrying the handler's failure.\n * @returns The encoded payload and, when detail was lost, why.\n */\nexport function encode_remote_failure_detailed(cause: Cause.Cause<unknown>): EncodedRemoteFailure {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tagged = has_public_remote_failure_tag(reason.error);\n\n\t\tif (!tagged) {\n\t\t\treturn {\n\t\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\t\topaque: { reason: \"untagged\", value: reason.error },\n\t\t\t};\n\t\t}\n\n\t\tconst failure = to_serializable_public_failure(reason.error);\n\t\tconst encoded = failure === undefined ? undefined : stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn { encoded };\n\t\t}\n\n\t\treturn {\n\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\topaque: { reason: \"unserializable\", value: reason.error },\n\t\t};\n\t}\n\n\treturn {\n\t\tencoded: stringify_unknown_remote_failure(),\n\t\topaque: { reason: \"unknown\", value: find_defect(cause) },\n\t};\n}\n\n/** Surfaces a defect so an unencodable cause still names something concrete. */\nfunction find_defect(cause: Cause.Cause<unknown>): unknown {\n\tfor (const reason of cause.reasons) {\n\t\tif (Cause.isDieReason(reason)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_sveltekit_control_flow(cause: Cause.Cause<unknown>): unknown | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isDieReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_sveltekit_control_flow(reason.defect)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_form_error_issues(cause: Cause.Cause<unknown>): readonly FormIssue[] | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst issues = get_form_error_issues(reason.error);\n\n\t\tif (issues !== undefined) {\n\t\t\treturn issues;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_form_error_issues(value: unknown): readonly FormIssue[] | undefined {\n\tif (is_form_error(value)) {\n\t\treturn value.issues;\n\t}\n\n\treturn is_tagged_form_error(value) ? [] : undefined;\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\nconst is_tagged_form_error = Schema.is(\n\tSchema.Struct({\n\t\t_tag: Schema.Literal(\"FormError\"),\n\t}),\n);\n","import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { report_opaque_remote_failure } from \"$/remote/diagnostics.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport type { RemoteFailureContext, ResolveRemoteFailureContext } from \"$/remote/diagnostics.ts\";\nimport { classify_remote_cause } from \"$/remote/cause-codec.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nexport { encode_remote_failure } from \"$/remote/cause-codec.ts\";\n\n/** Maps a remote Effect exit into the control flow expected by SvelteKit. */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tresolve_context?: ResolveRemoteFailureContext,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\tthrow_remote_cause(exit.cause, invalid, error, resolve_context);\n}\n\n/** Applies a classified remote Cause decision to SvelteKit's server helpers. */\nexport function throw_remote_cause(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tresolve_context?: ResolveRemoteFailureContext,\n\treport?: (message: string) => void,\n): never {\n\tconst resolution = classify_remote_cause(cause);\n\n\tswitch (resolution._tag) {\n\t\tcase \"SvelteKitControlFlow\": {\n\t\t\tthrow resolution.value;\n\t\t}\n\t\tcase \"InterruptOnly\": {\n\t\t\treport_opaque_remote_failure(\n\t\t\t\t\"interrupted\",\n\t\t\t\tresolution.cause,\n\t\t\t\tundefined,\n\t\t\t\tresolve_context,\n\t\t\t\treport,\n\t\t\t);\n\n\t\t\tthrow Cause.squash(resolution.cause);\n\t\t}\n\t\tcase \"FormInvalid\": {\n\t\t\tinvalid(...resolution.issues);\n\t\t}\n\t\tcase \"RemoteFailure\": {\n\t\t\tconst envelope = create_serialized_remote_failure_envelope(resolution.encoded);\n\n\t\t\t/**\n\t\t\t * The client only receives a generic 500 for a failure SER could not\n\t\t\t * encode, so the original error is reported here or lost entirely.\n\t\t\t */\n\t\t\tif (resolution.opaque) {\n\t\t\t\treport_opaque_remote_failure(\n\t\t\t\t\tresolution.opaque.reason,\n\t\t\t\t\tcause,\n\t\t\t\t\tresolution.opaque.value,\n\t\t\t\t\tresolve_context,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\terror(500, envelope);\n\t\t}\n\t}\n}\n\n/**\n * Describes the request a remote failure occurred in.\n *\n * @example\n * ```ts\n * const context = to_remote_failure_context(event);\n * ```\n *\n * @since 4.2.0\n * @param event - Request event the handler ran under.\n * @returns Request detail for opaque failure reports.\n */\nexport function to_remote_failure_context(event: {\n\treadonly request?: { readonly method?: string };\n\treadonly route?: { readonly id?: string | null };\n\treadonly url?: { readonly pathname?: string };\n}): RemoteFailureContext {\n\tconst method = read_event_detail(() => event.request?.method);\n\tconst route = read_event_detail(() => event.route?.id ?? undefined);\n\tconst url = read_event_detail(() => event.url?.pathname);\n\n\treturn {\n\t\t...(method ? { method } : {}),\n\t\t...(route ? { route } : {}),\n\t\t...(url ? { url } : {}),\n\t};\n}\n\n/**\n * Reads one request detail, tolerating an event that refuses it.\n *\n * SvelteKit restricts which parts of a request a remote function may observe,\n * and the set has changed across releases. A diagnostic must never be the\n * reason a handler cannot answer, so an unavailable detail is simply omitted.\n */\nfunction read_event_detail(read: () => string | undefined): string | undefined {\n\ttry {\n\t\treturn read();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/** Rebrands SvelteKit context failures with the remote helper that triggered them. */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;AAkDA,MAAM,eAAoE;CACzE,UACC;CACD,gBACC;CACD,SAAS;CACT,aAAa;AACd;AAEA,MAAM,WAAgE;CACrE,UACC;CACD,gBACC;CACD,SACC;CACD,aACC;AACF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,6BACf,QACA,OACA,OACA,iBACA,SAAmB,kBACZ;;;;;;;CAOP,IAAI;EACH,OAAO,6BAA6B,QAAQ,OAAO,OAAO,kBAAkB,CAAC,CAAC;CAC/E,QAAQ,CAER;AACD;;;;;;;;;;;;;;;;AAiBA,SAAgB,6BACf,QACA,OACA,OACA,SACS;CACT,MAAM,UAAU,eAAe,OAAO;CACtC,MAAM,QAAQ,CACb,uGACA,aAAa,aAAa,QAAQ,EACnC;CAEA,IAAI,SACH,MAAM,KAAK,cAAc,SAAS;CAGnC,IAAI,WAAW,eACd,MAAM,KAAK,cAAc,gBAAgB,KAAK,GAAG;CAGlD,MAAM,KAAK,YAAY,OAAO,aAAa,KAAK,CAAC,GAAG,UAAU,SAAS,SAAS;CAEhF,OAAO,MAAM,KAAK,IAAI;AACvB;AAEA,SAAS,eAAe,SAAoD;CAC3E,IAAI,CAAC,SACJ;CAGD,MAAM,SAAS,QAAQ,OAAO,QAAQ;CACtC,MAAM,QAAQ,CAAC,QAAQ,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO;CAErD,MAAM,QADc,QAAQ,QAAQ,SAAS,QAAQ,OAAO,QAAQ,UAAU,QAAQ,GAC9D,IAAI,WAAW,QAAQ,MAAM,KAAK;CAE1D,IAAI,MAAM,WAAW,GACpB;CAGD,OAAO,GAAG,MAAM,KAAK,GAAG,IAAI;AAC7B;AAEA,SAAS,aAAa,OAAqC;CAC1D,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A,SAAgB,0BAA0B,OAIjB;CACxB,MAAM,SAAS,wBAAwB,MAAM,SAAS,MAAM;CAC5D,MAAM,QAAQ,wBAAwB,MAAM,OAAO,MAAM,KAAA,CAAS;CAClE,MAAM,MAAM,wBAAwB,MAAM,KAAK,QAAQ;CAEvD,OAAO;EACN,GAAI,SAAS,EAAE,OAAO,IAAI,CAAC;EAC3B,GAAI,QAAQ,EAAE,MAAM,IAAI,CAAC;EACzB,GAAI,MAAM,EAAE,IAAI,IAAI,CAAC;CACtB;AACD;;;;;;;;AASA,SAAS,kBAAkB,MAAoD;CAC9E,IAAI;EACH,OAAO,KAAK;CACb,QAAQ;EACP;CACD;AACD;AAEA,SAAgB,iBAAiB,QAA8B,SAA+B;CAC7F,QAAQ,GAAG,MAAM;AAClB;;AAGA,SAAgB,8BAA8B,KAAc,aAA4B;CACvF,IAAI,kCAAkC,GAAG,GACxC,OAAO,IAAI,yBAAyB,WAAW;CAGhD,OAAO,eAAe,QAAQ,MAAM,IAAI,kBAAkB,GAAG;AAC9D;AAEA,SAAS,kCAAkC,KAA4B;CACtE,IAAI,EAAE,eAAe,QACpB,OAAO;CAGR,OACC,IAAI,QAAQ,WAAW,iCAAiC,KACxD,IAAI,YAAY;AAElB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-
|
|
1
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-BNxq-pUH.js";
|
|
2
2
|
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
|
@@ -26,6 +26,22 @@ export type RemoteFailureContext = {
|
|
|
26
26
|
readonly route?: string;
|
|
27
27
|
readonly url?: string;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Defers building a {@link RemoteFailureContext} until a report is actually
|
|
31
|
+
* rendered.
|
|
32
|
+
*
|
|
33
|
+
* The context describes a request SER never otherwise inspects, so resolving
|
|
34
|
+
* it eagerly would read request-event properties on every remote call to
|
|
35
|
+
* describe the few that fail.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const resolve: ResolveRemoteFailureContext = () => ({ url: event.url.pathname });
|
|
40
|
+
* ```
|
|
41
|
+
*
|
|
42
|
+
* @since 4.2.1
|
|
43
|
+
*/
|
|
44
|
+
export type ResolveRemoteFailureContext = () => RemoteFailureContext | undefined;
|
|
29
45
|
type Reporter = (message: string) => void;
|
|
30
46
|
/**
|
|
31
47
|
* Reports a remote failure that had to be replaced with an opaque envelope.
|
|
@@ -47,7 +63,7 @@ type Reporter = (message: string) => void;
|
|
|
47
63
|
* @param context - Optional request detail for the log header.
|
|
48
64
|
* @param report - Sink for the rendered report; defaults to `console.error`.
|
|
49
65
|
*/
|
|
50
|
-
export declare function report_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause<unknown>, value: unknown,
|
|
66
|
+
export declare function report_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause<unknown>, value: unknown, resolve_context?: ResolveRemoteFailureContext, report?: Reporter): void;
|
|
51
67
|
/**
|
|
52
68
|
* Renders the report emitted by {@link report_opaque_remote_failure}.
|
|
53
69
|
*
|
package/.dist/remote/server.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RemoteFailureContext } from "./diagnostics.js";
|
|
1
|
+
import type { RemoteFailureContext, ResolveRemoteFailureContext } from "./diagnostics.js";
|
|
2
2
|
import type { FormIssue } from "./shared.js";
|
|
3
3
|
import { Cause, Effect } from "effect";
|
|
4
4
|
type SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;
|
|
@@ -7,9 +7,9 @@ export { encode_remote_failure } from "./cause-codec.js";
|
|
|
7
7
|
/** Maps a remote Effect exit into the control flow expected by SvelteKit. */
|
|
8
8
|
export declare function run_remote_effect<A>(effect: Effect.Effect<A, unknown, unknown>, runtime: {
|
|
9
9
|
runPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;
|
|
10
|
-
}, invalid: SvelteInvalid, error: SvelteError,
|
|
10
|
+
}, invalid: SvelteInvalid, error: SvelteError, resolve_context?: ResolveRemoteFailureContext): Promise<A>;
|
|
11
11
|
/** Applies a classified remote Cause decision to SvelteKit's server helpers. */
|
|
12
|
-
export declare function throw_remote_cause(cause: Cause.Cause<unknown>, invalid: SvelteInvalid, error: SvelteError,
|
|
12
|
+
export declare function throw_remote_cause(cause: Cause.Cause<unknown>, invalid: SvelteInvalid, error: SvelteError, resolve_context?: ResolveRemoteFailureContext, report?: (message: string) => void): never;
|
|
13
13
|
/**
|
|
14
14
|
* Describes the request a remote failure occurred in.
|
|
15
15
|
*
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-
|
|
1
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-BNxq-pUH.js";
|
|
2
2
|
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
|
@@ -82,7 +82,12 @@ function lower_expression_statement(stmt, content, context) {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
if (is_yield_star_expression(expr)) {
|
|
85
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Leading trivia must stay out of the sliced expression: a comment ahead
|
|
87
|
+
* of the yield* would defeat the anchored strip in wrap_yield_text and
|
|
88
|
+
* leave a second yield* nested inside the ToEffect argument.
|
|
89
|
+
*/
|
|
90
|
+
const text = slice_start(content, expr).trim();
|
|
86
91
|
return {
|
|
87
92
|
temps: [],
|
|
88
93
|
rewritten_text: "",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/runtime-block.ts","../../../modules/svelte-effect-runtime/src/script-transform/lower.ts","../../../modules/svelte-effect-runtime/src/script-transform/index.ts","../../../modules/svelte-effect-runtime/src/runtime/transform.ts"],"sourcesContent":["import type { EffectBlock, RuntimeImportBindings } from \"./types.ts\";\n\nexport function make_runtime_block_with_bindings(\n\tblocks: EffectBlock[],\n\tbindings: RuntimeImportBindings,\n): string {\n\treturn blocks.map((block) => make_runtime_effect_block(block, bindings)).join(\"\\n\");\n}\n\nfunction make_runtime_effect_block(block: EffectBlock, bindings: RuntimeImportBindings): string {\n\tconst dep_reads = block.deps.map((dep) => ` ${dep};`);\n\n\tconst body = block.statements.map((statement) => ` ${statement}`).join(\"\\n\");\n\n\treturn [\n\t\t\"\",\n\t\t\"$effect(() => {\",\n\t\t...dep_reads,\n\t\t` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n\t\t` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n\t\tbody,\n\t\t\" });\",\n\t\t` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.run_scoped(${bindings.scope}.scope, ${bindings.program}));`,\n\t\t` import.meta.hot?.dispose(${bindings.cancel});`,\n\t\t` return ${bindings.cancel};`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n","import type {\n\tEffectBlock,\n\tLoweredExpression,\n\tLoweredStatement,\n\tScriptLoweringContext,\n\tTempBinding,\n} from \"./types.ts\";\nimport { collect_yield_star_nodes, find_yield_star_node, is_yield_star_expression } from \"./ast.ts\";\nimport { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { slice, slice_start } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nexport function lower_statement(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tif (ts.isExpressionStatement(stmt)) {\n\t\treturn lower_expression_statement(stmt, content, context);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn lower_variable_statement(stmt, content, context);\n\t}\n\n\tconst text = slice(content, stmt);\n\tconst wrapped_text = wrap_yield_stars_in_node(stmt, content, context);\n\n\treturn {\n\t\ttemps: [],\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [make_effect_block([wrapped_text], collect_deps(text))],\n\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_variable_statement(\n\tstmt: ts.VariableStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst helper_declarations: string[] = [];\n\tconst rewritten_decls: string[] = [];\n\n\tconst decl_list = stmt.declarationList;\n\tconst kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n\tlet uses_dispatcher_promise = false;\n\n\tfor (const decl of decl_list.declarations) {\n\t\tif (!contains_top_level_yield_star(decl)) {\n\t\t\trewritten_decls.push(slice(content, decl).trim());\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst lowered = lower_node_yields_to_await(\n\t\t\tdecl,\n\t\t\tcontent,\n\t\t\tmake_binding_hint(decl.name),\n\t\t\tcontext,\n\t\t);\n\n\t\thelper_declarations.push(...lowered.helper_declarations);\n\t\trewritten_decls.push(lowered.rewritten_text);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\n\t}\n\n\tconst rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\n\n\treturn {\n\t\ttemps: [],\n\t\ttype_helpers: helper_declarations,\n\t\trewritten_text,\n\t\teffect_blocks: [],\n\t\tuses_dispatcher_promise,\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_statement(\n\tstmt: ts.ExpressionStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst expr = stmt.expression;\n\n\tif (!contains_top_level_yield_star(expr)) {\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: slice(content, stmt).trim(),\n\t\t\teffect_blocks: [],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (is_yield_star_expression(expr)) {\n\t\tconst text = slice(content, expr).trim();\n\t\tconst yield_text = wrap_yield_text(text, context);\n\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [make_effect_block([yield_text + \";\"], collect_deps(text))],\n\t\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n\t\tconst target = slice(content, expr.left).trim();\n\t\tconst target_names = collect_assignment_target_names(expr.left);\n\n\t\tif (\n\t\t\texpr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n\t\t\tis_yield_star_expression(expr.right)\n\t\t) {\n\t\t\tconst yield_text = extract_yield_star_full_text(expr.right, content);\n\t\t\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\t\t\treturn {\n\t\t\t\ttemps: [],\n\t\t\t\trewritten_text: \"\",\n\t\t\t\teffect_blocks: [\n\t\t\t\t\tmake_effect_block(\n\t\t\t\t\t\t[`${target} = ${wrapped_yield_text};`],\n\t\t\t\t\t\tcollect_deps(yield_text, target_names),\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t\t};\n\t\t}\n\n\t\tconst lowered = lower_expression_yields(\n\t\t\texpr.right,\n\t\t\tcontent,\n\t\t\tmake_temp_hint(target),\n\t\t\tcontext,\n\t\t);\n\t\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\t\tconst statement = `${target} ${slice(\n\t\t\tcontent,\n\t\t\texpr.operatorToken,\n\t\t).trim()} ${lowered.rewritten_expr};`;\n\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [\n\t\t\t\tmake_effect_block(\n\t\t\t\t\t[...lowered.effect_blocks.flatMap((block) => block.statements), statement],\n\t\t\t\t\t[\n\t\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t\t...collect_deps(lowered.rewritten_expr, [...target_names, ...temp_names]),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst lowered = lower_expression_yields(expr, content, \"call\", context);\n\n\tif (is_top_level_rune_call(expr)) {\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: lowered.rewritten_expr + \";\",\n\t\t\teffect_blocks: lowered.effect_blocks,\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\n\treturn {\n\t\ttemps: lowered.temps,\n\t\ttype_helpers: lowered.type_helpers,\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [\n\t\t\tmake_effect_block(\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.statements),\n\t\t\t\t\tlowered.rewritten_expr + \";\",\n\t\t\t\t],\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t...collect_deps(lowered.rewritten_expr, temp_names),\n\t\t\t\t],\n\t\t\t),\n\t\t],\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_yields(\n\texpr: ts.Expression,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): LoweredExpression {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tconst temps: TempBinding[] = [];\n\tconst type_helpers: string[] = [];\n\tconst statements: string[] = [];\n\tconst deps: string[] = [];\n\n\tcollect_yield_star_nodes(expr, (node) => {\n\t\tconst temp_name = context.next_temp_name(hint);\n\t\tconst yield_text = slice_start(content, node).trim();\n\t\tconst type_helper = make_yield_type_helper(yield_text, hint, context);\n\n\t\tif (type_helper) {\n\t\t\ttype_helpers.push(type_helper.declaration);\n\t\t\ttemps.push({ name: temp_name, type: type_helper.type });\n\t\t} else {\n\t\t\ttemps.push({ name: temp_name });\n\t\t}\n\n\t\tstatements.push(`${temp_name} = ${wrap_yield_text(yield_text, context)};`);\n\t\tdeps.push(...collect_deps(yield_text));\n\t\treplacements.push({\n\t\t\tstart: node.getStart(),\n\t\t\tend: node.end,\n\t\t\ttext: temp_name,\n\t\t});\n\t});\n\n\tif (replacements.length === 0) {\n\t\treturn {\n\t\t\ttemps,\n\t\t\ttype_helpers,\n\t\t\trewritten_expr: slice(content, expr).trim(),\n\t\t\teffect_blocks: [],\n\t\t};\n\t}\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice(content, expr);\n\n\tconst offset_in_expr = expr.getFullStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_expr) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_expr);\n\t}\n\n\treturn {\n\t\ttemps,\n\t\ttype_helpers,\n\t\trewritten_expr: text.trim(),\n\t\teffect_blocks: [make_effect_block(statements, deps)],\n\t};\n}\n\nfunction lower_node_yields_to_await(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): {\n\thelper_declarations: string[];\n\trewritten_text: string;\n\tuses_dispatcher_promise: boolean;\n} {\n\tconst helper_declarations: string[] = [];\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst awaited = make_awaited_yield_expression(yield_node, content, hint, context);\n\n\t\thelper_declarations.push(awaited.declaration);\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: awaited.expression,\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice_start(content, node);\n\tconst offset_in_node = node.getStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_node) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_node);\n\t}\n\n\treturn {\n\t\thelper_declarations,\n\t\trewritten_text: text.trim(),\n\t\tuses_dispatcher_promise: replacements.length > 0,\n\t};\n}\n\nfunction make_awaited_yield_expression(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; expression: string } {\n\tconst yield_text = slice_start(content, node).trim();\n\tconst helper_name = context.next_helper_name(`effect_${hint}`);\n\tconst helper_id = make_script_effect_id(node, context);\n\tconst deps = collect_deps(yield_text);\n\tconst deps_text = `[${deps.join(\", \")}]`;\n\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\treturn {\n\t\tdeclaration: `function* ${helper_name}() { return (${wrapped_yield_text}); }`,\n\t\texpression: [\n\t\t\t`await ${context.dispatcher_name}().with_scope(${context.scope_name}.scope, () => ${context.dispatcher_name}().promise({`,\n\t\t\t`id: ${JSON.stringify(helper_id)}, `,\n\t\t\t`deps: ${deps_text}, `,\n\t\t\t`factory: () => ${helper_name}()`,\n\t\t\t`}))`,\n\t\t].join(\"\"),\n\t};\n}\n\nfunction make_yield_type_helper(\n\tyield_text: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n\tif (!context.emit_types) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_name = context.next_type_helper_name(hint);\n\tconst effect_text = strip_yield_star(yield_text);\n\n\treturn {\n\t\tdeclaration: `function ${helper_name}() { return (${effect_text}); }`,\n\t\ttype: `${context.yield_success_name}<ReturnType<typeof ${helper_name}>> | undefined`,\n\t};\n}\n\nfunction strip_yield_star(yield_text: string): string {\n\treturn yield_text.replace(/^yield\\s*\\*\\s*/, \"\");\n}\n\nfunction wrap_yield_text(yield_text: string, context: ScriptLoweringContext): string {\n\treturn `yield* ${context.yieldable_name}(${strip_yield_star(yield_text)})`;\n}\n\nfunction wrap_yield_stars_in_node(\n\tnode: ts.Node,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): string {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst yield_text = slice_start(content, yield_node).trim();\n\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: wrap_yield_text(yield_text, context),\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tconst offset = node.getFullStart();\n\tlet text = slice(content, node);\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset);\n\t}\n\n\treturn text.trim();\n}\n\nfunction make_script_effect_id(expr: ts.Node, context: ScriptLoweringContext): string {\n\treturn `${context.filename}:${expr.getStart()}:${expr.end}`;\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n\treturn (\n\t\texpr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n\t\texpr.operatorToken.kind <= ts.SyntaxKind.LastAssignment\n\t);\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n\tif (!ts.isCallExpression(expr)) {\n\t\treturn false;\n\t}\n\n\tconst callee = expr.expression;\n\n\tif (ts.isIdentifier(callee)) {\n\t\treturn callee.text.startsWith(\"$\");\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(callee) &&\n\t\tts.isIdentifier(callee.expression) &&\n\t\tcallee.expression.text.startsWith(\"$\")\n\t);\n}\n\nfunction make_temp_hint(target: string): string {\n\tconst match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n\treturn match?.[0] ?? \"assignment\";\n}\n\nfunction make_binding_hint(name: ts.BindingName): string {\n\tif (ts.isIdentifier(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn \"destructure\";\n}\n\nfunction extract_yield_star_full_text(expr: ts.Expression, content: string): string {\n\tlet found: string | undefined;\n\n\tfind_yield_star_node(expr, (node) => {\n\t\tfound = slice_start(content, node).trim();\n\t});\n\n\treturn found ?? \"undefined\";\n}\n\nfunction make_effect_block(statements: string[], deps: string[]): EffectBlock {\n\treturn {\n\t\tstatements,\n\t\tdeps: [...new Set(deps)],\n\t};\n}\n\nfunction collect_deps(expr_text: string, excluded_names: readonly string[] = []): string[] {\n\tconst excluded = new Set(excluded_names);\n\n\treturn collect_free_identifiers(expr_text).filter(\n\t\t(identifier) => !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n\t);\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n\tif (ts.isIdentifier(node)) {\n\t\treturn [node.text];\n\t}\n\n\tif (ts.isParenthesizedExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isObjectLiteralExpression(node)) {\n\t\treturn node.properties.flatMap((property) => {\n\t\t\tif (ts.isShorthandPropertyAssignment(property)) {\n\t\t\t\treturn [property.name.text];\n\t\t\t}\n\n\t\t\tif (ts.isPropertyAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.initializer);\n\t\t\t}\n\n\t\t\tif (ts.isSpreadAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.expression);\n\t\t\t}\n\n\t\t\treturn [];\n\t\t});\n\t}\n\n\tif (ts.isArrayLiteralExpression(node)) {\n\t\treturn node.elements.flatMap((element) =>\n\t\t\tts.isSpreadElement(element)\n\t\t\t\t? collect_assignment_target_names(element.expression)\n\t\t\t\t: collect_assignment_target_names(element),\n\t\t);\n\t}\n\n\treturn [];\n}\n","import type {\n\tBlockRef,\n\tEffectBlock,\n\tRelocation,\n\tRuntimeImportBindings,\n\tScriptLoweringContext,\n\tScriptTransformResult,\n} from \"./types.ts\";\nimport {\n\tcollect_top_level_binding_names,\n\thas_local_import_binding,\n\tmake_imports,\n} from \"./imports.ts\";\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport type { MarkupTransformTarget } from \"$/markup/transform.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n\temit_types?: boolean;\n\ttarget?: MarkupTransformTarget;\n}\n\n/**\n * Transforms a `<script effect>` body by lowering top-level `yield*`\n * expressions into Svelte-compatible async rendering declarations or into\n * dependency-tracked `$effect` blocks for effectful statements.\n *\n * @example\n * ```ts\n * const result = transform_script_effect(\n * `let user = $state(yield* getUser(id));`,\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `<script effect>` body content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform settings for generated script code.\n * @returns The transformed code and any block references.\n */\nexport function transform_script_effect(\n\tcontent: string,\n\tfilename: string,\n\toptions: ScriptTransformOptions = {},\n): ScriptTransformResult {\n\tlet temp_counter = 0;\n\tconst target = options.target ?? \"client\";\n\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcontent,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst magic = new MagicString(content);\n\tconst effect_blocks: EffectBlock[] = [];\n\tconst block_refs: BlockRef[] = [];\n\tconst top_level_binding_names = collect_top_level_binding_names(source_file);\n\tconst top_level_binding_names_set = new Set(top_level_binding_names);\n\tconst name_allocator = make_name_allocator(top_level_binding_names);\n\tconst emit_types = options.emit_types ?? true;\n\n\tlet has_effect = false;\n\tlet first_effect_statement_start = content.length;\n\tlet uses_dispatcher_promise = false;\n\tlet uses_yield_success_types = false;\n\n\t/** Phase 1: detect imports already provided by the user. */\n\tconst has_effect_import = has_local_import_binding(source_file, \"effect\", \"Effect\");\n\n\tconst has_dispatcher_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte-effect-runtime/internal/generators\",\n\t\t\"get_dispatcher\",\n\t);\n\n\tconst has_untrack_import = has_local_import_binding(source_file, \"svelte\", \"untrack\");\n\tconst has_on_destroy_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte\",\n\t\t\"onDestroy\",\n\t\tfalse,\n\t);\n\n\tconst reserve_runtime_import = (name: string) =>\n\t\ttop_level_binding_names_set.has(name)\n\t\t\t? name_allocator.reserve(make_generated_name(name, \"\"))\n\t\t\t: name_allocator.reserve(name);\n\n\tconst runtime_bindings: RuntimeImportBindings = {\n\t\tcancel: name_allocator.reserve(\"__SER___cancel\"),\n\t\tcomponent_scope_ref: reserve_runtime_import(\"ComponentScopeRef\"),\n\t\tdispatcher: has_dispatcher_import\n\t\t\t? \"get_dispatcher\"\n\t\t\t: reserve_runtime_import(\"get_dispatcher\"),\n\t\tdispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n\t\teffect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n\t\ton_destroy: has_on_destroy_import ? \"onDestroy\" : reserve_runtime_import(\"onDestroy\"),\n\t\tprogram: name_allocator.reserve(\"__SER___program\"),\n\t\tscope: name_allocator.reserve(\"__SER___scope\"),\n\t\tuntrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n\t\tyield_success: reserve_runtime_import(\"YieldSuccess\"),\n\t\tyieldable: reserve_runtime_import(\"ToEffect\"),\n\t};\n\n\tconst context: ScriptLoweringContext = {\n\t\tfilename,\n\t\tdispatcher_name: runtime_bindings.dispatcher,\n\t\tscope_name: runtime_bindings.scope,\n\t\teffect_name: runtime_bindings.effect,\n\t\temit_types,\n\t\tyield_success_name: runtime_bindings.yield_success,\n\t\tyieldable_name: runtime_bindings.yieldable,\n\t\tnext_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\n\t\t},\n\t\tnext_temp_name(hint?: string) {\n\t\t\tconst suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n\t\t\tconst name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n\t\t\ttemp_counter += 1;\n\n\t\t\treturn name_allocator.reserve(name);\n\t\t},\n\t\tnext_type_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(`type_${hint ?? \"effect\"}`, \"\"));\n\t\t},\n\t};\n\n\t/** Phase 2: lower every top-level statement that contains `yield*`. */\n\tfor (const stmt of source_file.statements) {\n\t\tvalidate_rune_yield_usage(stmt, content, filename);\n\t\tvalidate_script_yield_boundaries(stmt, content, filename);\n\n\t\tconst has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n\t\tif (!has_top_level_yield_star) {\n\t\t\tcontinue;\n\t\t}\n\n\t\thas_effect = true;\n\n\t\tconst lowered = lower_statement(stmt, content, context);\n\n\t\tfirst_effect_statement_start = Math.min(first_effect_statement_start, lowered.range.start);\n\n\t\tif (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\n\t\t\tconst text = slice(content, stmt);\n\t\t\tthrow new AwaitInEffectWorkError(filename, text);\n\t\t}\n\n\t\tmagic.overwrite(lowered.range.start, lowered.range.end, lowered.rewritten_text);\n\n\t\tif (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n\t\t\tconst temp_declarations = lowered.temps.map((temp) =>\n\t\t\t\ttemp.type\n\t\t\t\t\t? `let ${temp.name} = $state<${temp.type}>(undefined);`\n\t\t\t\t\t: `let ${temp.name} = $state(undefined);`,\n\t\t\t);\n\n\t\t\tconst prefix = [...(lowered.type_helpers ?? []), ...temp_declarations].join(\"\\n\");\n\n\t\t\tmagic.appendLeft(lowered.range.start, prefix + \"\\n\");\n\t\t}\n\n\t\teffect_blocks.push(...lowered.effect_blocks);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\n\t\tuses_yield_success_types ||= lowered.temps.some(\n\t\t\t(temp) => temp.type?.includes(runtime_bindings.yield_success) ?? false,\n\t\t);\n\t}\n\n\tif (!has_effect) {\n\t\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\t\treturn { code: content, blocks: block_refs };\n\t}\n\n\t/** Phase 3: inject runtime imports after the last user import. */\n\tconst imports = make_imports(\n\t\thas_effect_import,\n\t\thas_dispatcher_import,\n\t\thas_untrack_import,\n\t\thas_on_destroy_import,\n\t\truntime_bindings,\n\t\t{\n\t\t\tneeds_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_effect: effect_blocks.length > 0,\n\t\t\tneeds_untrack: effect_blocks.length > 0,\n\t\t\t/** The server never registers disposal, so it never needs the import. */\n\t\t\tneeds_on_destroy: target !== \"server\",\n\t\t\tneeds_yield_success: uses_yield_success_types,\n\t\t\tneeds_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_scope_ref: true,\n\t\t},\n\t);\n\n\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\tconst injection_point = last_import\n\t\t? Math.min(last_import.end, first_effect_statement_start)\n\t\t: first_effect_statement_start;\n\n\t/**\n\t * The scope holder is created synchronously with the imports so it exists\n\t * before any top-level `await`, and disposal is registered through\n\t * `onDestroy` during component initialisation. Emitting both here keeps\n\t * them ahead of every lowered statement that references the scope.\n\t */\n\tconst scope_wiring = [\n\t\t`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`,\n\t\t...(target === \"server\"\n\t\t\t? []\n\t\t\t: [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`]),\n\t].join(\"\\n\");\n\n\tconst injected = [imports, scope_wiring].filter(Boolean).join(\"\\n\");\n\n\tif (last_import && last_import.end <= first_effect_statement_start) {\n\t\tmagic.appendRight(last_import.end, \"\\n\" + injected);\n\t} else if (injection_point >= 0) {\n\t\tmagic.appendLeft(injection_point, injected + \"\\n\");\n\t} else {\n\t\tmagic.appendLeft(first_effect_statement_start, injected + \"\\n\");\n\t}\n\n\t/** Phase 4: append the runtime program blocks. */\n\n\tif (effect_blocks.length > 0) {\n\t\tconst runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);\n\n\t\tmagic.append(\"\\n\" + runtime_block);\n\t}\n\n\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\tconst code = magic.toString();\n\n\treturn {\n\t\tcode,\n\t\tblocks: block_refs,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations: create_script_relocations(\n\t\t\tcontent,\n\t\t\tcode,\n\t\t\tsource_file,\n\t\t\truntime_bindings.yieldable,\n\t\t),\n\t};\n}\n\nfunction create_script_relocations(\n\tcontent: string,\n\tcode: string,\n\tsource_file: ts.SourceFile,\n\tyieldable_name: string,\n): Relocation[] {\n\tconst candidates = source_file.statements.flatMap((stmt) => {\n\t\tconst relocations: RelocationCandidate[] = [];\n\n\t\tif (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\n\t\t\tfor (const decl of stmt.declarationList.declarations) {\n\t\t\t\tcollect_binding_relocation_candidates(decl.name, relocations);\n\t\t\t}\n\t\t}\n\n\t\tcollect_yield_star_nodes(stmt, (node) => {\n\t\t\tconst expression = ts.isBinaryExpression(node) ? node.right : node;\n\t\t\tconst text = content.slice(expression.getStart(), expression.end).trim();\n\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: expression.getStart(),\n\t\t\t\toriginalEnd: expression.end,\n\t\t\t\ttext,\n\t\t\t\tmatch: \"yield_operand\",\n\t\t\t\twrapper: `${yieldable_name}(${text})`,\n\t\t\t});\n\t\t});\n\n\t\treturn relocations;\n\t});\n\n\tconst used_ranges: Array<{ start: number; end: number }> = [];\n\tconst search_cursors = new Map<string, number>();\n\n\treturn candidates.flatMap((candidate) => {\n\t\tconst search_key = make_relocation_search_key(candidate);\n\t\tconst generated_start = find_available_generated_text(\n\t\t\tcode,\n\t\t\tcandidate,\n\t\t\tused_ranges,\n\t\t\tsearch_cursors.get(search_key) ?? 0,\n\t\t);\n\n\t\tif (generated_start < 0) {\n\t\t\tsearch_cursors.set(search_key, code.length);\n\n\t\t\treturn [];\n\t\t}\n\n\t\tconst generated_end = generated_start + candidate.text.length;\n\t\tused_ranges.push({ start: generated_start, end: generated_end });\n\t\tsearch_cursors.set(search_key, generated_end);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: candidate.originalStart,\n\t\t\t\toriginalEnd: candidate.originalEnd,\n\t\t\t\tgeneratedStart: generated_start,\n\t\t\t\tgeneratedEnd: generated_end,\n\t\t\t},\n\t\t];\n\t});\n}\n\ntype RelocationCandidate = {\n\toriginalStart: number;\n\toriginalEnd: number;\n\ttext: string;\n\tmatch: \"exact\" | \"identifier\" | \"yield_operand\";\n\twrapper?: string;\n};\n\nfunction make_relocation_search_key(candidate: RelocationCandidate): string {\n\treturn `${candidate.match}:${candidate.text}`;\n}\n\nfunction collect_binding_relocation_candidates(\n\tname: ts.BindingName,\n\tcandidates: RelocationCandidate[],\n): void {\n\tif (ts.isIdentifier(name)) {\n\t\tcandidates.push({\n\t\t\toriginalStart: name.getStart(),\n\t\t\toriginalEnd: name.end,\n\t\t\ttext: name.text,\n\t\t\tmatch: \"identifier\",\n\t\t});\n\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_relocation_candidates(element.name, candidates);\n\t}\n}\n\nfunction find_available_generated_text(\n\tcode: string,\n\tcandidate: RelocationCandidate,\n\tused_ranges: Array<{ start: number; end: number }>,\n\tsearch_start: number,\n): number {\n\twhile (search_start < code.length) {\n\t\tconst search_text =\n\t\t\tcandidate.match === \"yield_operand\" ? candidate.wrapper : candidate.text;\n\n\t\tif (!search_text) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst index = code.indexOf(search_text, search_start);\n\n\t\tif (index < 0) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst operand_offset =\n\t\t\tcandidate.match === \"yield_operand\" && candidate.wrapper\n\t\t\t\t? candidate.wrapper.indexOf(candidate.text)\n\t\t\t\t: 0;\n\t\tconst start = index + Math.max(operand_offset, 0);\n\t\tconst end = start + candidate.text.length;\n\t\tconst overlaps_used_range = used_ranges.some(\n\t\t\t(range) => start < range.end && end > range.start,\n\t\t);\n\t\tconst is_text_match =\n\t\t\tcandidate.match !== \"identifier\" || is_identifier_text_match(code, start, end);\n\n\t\tif (!overlaps_used_range && is_text_match) {\n\t\t\treturn start;\n\t\t}\n\n\t\tsearch_start = candidate.match === \"identifier\" ? index + 1 : index + search_text.length;\n\t}\n\n\treturn -1;\n}\n\nfunction is_identifier_text_match(code: string, start: number, end: number): boolean {\n\tconst before = start === 0 ? 0 : code.charCodeAt(start - 1);\n\tconst after = end >= code.length ? 0 : code.charCodeAt(end);\n\n\treturn !is_identifier_part(before) && !is_identifier_part(after);\n}\n\nfunction is_identifier_part(char_code: number): boolean {\n\treturn (\n\t\t(char_code >= 65 && char_code <= 90) ||\n\t\t(char_code >= 97 && char_code <= 122) ||\n\t\t(char_code >= 48 && char_code <= 57) ||\n\t\tchar_code === 36 ||\n\t\tchar_code === 95\n\t);\n}\n\nfunction validate_script_yield_boundaries(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst bad_member = find_class_member_with_yield_star(stmt);\n\n\tif (!bad_member) {\n\t\treturn;\n\t}\n\n\tthrow new PreprocessError(\n\t\t[\n\t\t\t`[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n\t\t\t`Class fields and methods are not component top-level reactive work. Move the Effect work into a script effect statement before assigning it to the class instance.`,\n\t\t\t\"\",\n\t\t\t\"Problematic member:\",\n\t\t\tslice(content, bad_member),\n\t\t].join(\"\\n\"),\n\t\tfilename,\n\t);\n}\n\nfunction find_class_member_with_yield_star(stmt: ts.Statement): ts.Node | undefined {\n\tlet found: ts.Node | undefined;\n\n\tfunction visit(node: ts.Node): void {\n\t\tif (found) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tts.isPropertyDeclaration(node) &&\n\t\t\tnode.initializer &&\n\t\t\tcontains_top_level_yield_star(node.initializer)\n\t\t) {\n\t\t\tfound = node;\n\t\t\treturn;\n\t\t}\n\n\t\tnode.forEachChild(visit);\n\t}\n\n\tvisit(stmt);\n\n\treturn found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n\tconst normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n\tconst safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n\t\t? normalized_hint\n\t\t: `temp_${normalized_hint}`;\n\n\treturn `__SER___${safe_hint}${suffix}`;\n}\n","import { type MarkupTransformTarget, transform_markup_effect } from \"$/markup/transform.ts\";\nimport { scan_svelte_effect_source } from \"$/compiler/source-scan.ts\";\nimport { transform_script_effect } from \"$/script-transform/index.ts\";\n\n/**\n * Result returned by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\"<p>{yield* load()}</p>\", \"App.svelte\");\n * result.code;\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformResult {\n\t/** Transformed Svelte source. */\n\tcode: string;\n}\n\n/**\n * Options accepted by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const options: SvelteTransformOptions = { target: \"client\" };\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformOptions {\n\t/** Markup emission target passed through to the markup transform. */\n\ttarget?: MarkupTransformTarget;\n}\n\n/**\n * Lowers SER syntax in a complete Svelte component without using Svelte's\n * adapter API.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\n * \"<script effect>const value = yield* load()</script>\",\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.5.0\n * @param content - Full Svelte component source to lower before Svelte parses\n * it.\n * @param filename - Component filename used in generated cache identifiers and\n * diagnostics.\n * @param options - Optional target configuration for markup lowering.\n * @returns The transformed component source.\n */\nexport function transform_svelte_effect(\n\tcontent: string,\n\tfilename = \"unknown.svelte\",\n\toptions: SvelteTransformOptions = {},\n): SvelteTransformResult {\n\tconst scan = scan_svelte_effect_source(content, filename);\n\tconst script = scan.effect_script;\n\n\tlet combined = content;\n\n\tif (script) {\n\t\tconst effect_attribute = script.effect_attribute;\n\t\tconst effect_attribute_start = effect_attribute?.start ?? script.opening_tag_end;\n\t\tconst effect_attribute_end = effect_attribute?.end ?? script.opening_tag_end;\n\t\tconst result = transform_script_effect(script.text, filename, {\n\t\t\temit_types: script.is_typescript,\n\t\t\ttarget: options.target ?? \"client\",\n\t\t});\n\n\t\tcombined =\n\t\t\tcontent.slice(0, effect_attribute_start) +\n\t\t\tcontent.slice(effect_attribute_end, script.opening_tag_end) +\n\t\t\tresult.code +\n\t\t\tcontent.slice(script.closing_tag_start);\n\t}\n\n\tconst markup_options = options.target === undefined ? {} : { target: options.target };\n\tconst result = transform_markup_effect(combined, filename, markup_options);\n\n\treturn { code: result.code };\n}\n\nexport {\n\ttype MarkupTransformOptions,\n\ttype MarkupTransformResult,\n\ttype MarkupTransformTarget,\n\ttransform_markup_effect,\n} from \"$/markup/transform.ts\";\n\nexport {\n\ttype BlockRef,\n\ttype ScriptTransformResult,\n\ttransform_script_effect,\n} from \"$/script-transform/index.ts\";\n"],"mappings":";;;;;;;AAEA,SAAgB,iCACf,QACA,UACS;CACT,OAAO,OAAO,KAAK,UAAU,0BAA0B,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;AACnF;AAEA,SAAS,0BAA0B,OAAoB,UAAyC;CAC/F,MAAM,YAAY,MAAM,KAAK,KAAK,QAAQ,KAAK,IAAI,EAAE;CAErD,MAAM,OAAO,MAAM,WAAW,KAAK,cAAc,OAAO,WAAW,CAAC,CAAC,KAAK,IAAI;CAE9E,OAAO;EACN;EACA;EACA,GAAG;EACH,WAAW,SAAS,iBAAiB,KAAK,SAAS,WAAW;EAC9D,WAAW,SAAS,QAAQ,KAAK,SAAS,OAAO;EACjD;EACA;EACA,WAAW,SAAS,OAAO,KAAK,SAAS,QAAQ,SAAS,SAAS,iBAAiB,cAAc,SAAS,MAAM,UAAU,SAAS,QAAQ;EAC5I,8BAA8B,SAAS,OAAO;EAC9C,YAAY,SAAS,OAAO;EAC5B;EACA;CACD,CAAC,CAAC,KAAK,IAAI;AACZ;;;ACdA,SAAgB,gBACf,MACA,SACA,SACmB;CACnB,IAAI,GAAG,sBAAsB,IAAI,GAChC,OAAO,2BAA2B,MAAM,SAAS,OAAO;CAGzD,IAAI,GAAG,oBAAoB,IAAI,GAC9B,OAAO,yBAAyB,MAAM,SAAS,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M,UAAU;GAC7D,YAAY,OAAO;GACnB,QAAQ,QAAQ,UAAU;EAC3B,CAAC;EAED,WACC,QAAQ,MAAM,GAAG,sBAAsB,IACvC,QAAQ,MAAM,sBAAsB,OAAO,eAAe,IAC1D,OAAO,OACP,QAAQ,MAAM,OAAO,iBAAiB;CACxC;CAEA,MAAM,iBAAiB,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;CAGpF,OAAO,EAAE,MAFM,wBAAwB,UAAU,UAAU,cAEvC,CAAC,CAAC,KAAK;AAC5B"}
|
|
1
|
+
{"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/runtime-block.ts","../../../modules/svelte-effect-runtime/src/script-transform/lower.ts","../../../modules/svelte-effect-runtime/src/script-transform/index.ts","../../../modules/svelte-effect-runtime/src/runtime/transform.ts"],"sourcesContent":["import type { EffectBlock, RuntimeImportBindings } from \"./types.ts\";\n\nexport function make_runtime_block_with_bindings(\n\tblocks: EffectBlock[],\n\tbindings: RuntimeImportBindings,\n): string {\n\treturn blocks.map((block) => make_runtime_effect_block(block, bindings)).join(\"\\n\");\n}\n\nfunction make_runtime_effect_block(block: EffectBlock, bindings: RuntimeImportBindings): string {\n\tconst dep_reads = block.deps.map((dep) => ` ${dep};`);\n\n\tconst body = block.statements.map((statement) => ` ${statement}`).join(\"\\n\");\n\n\treturn [\n\t\t\"\",\n\t\t\"$effect(() => {\",\n\t\t...dep_reads,\n\t\t` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n\t\t` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n\t\tbody,\n\t\t\" });\",\n\t\t` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.run_scoped(${bindings.scope}.scope, ${bindings.program}));`,\n\t\t` import.meta.hot?.dispose(${bindings.cancel});`,\n\t\t` return ${bindings.cancel};`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n","import type {\n\tEffectBlock,\n\tLoweredExpression,\n\tLoweredStatement,\n\tScriptLoweringContext,\n\tTempBinding,\n} from \"./types.ts\";\nimport { collect_yield_star_nodes, find_yield_star_node, is_yield_star_expression } from \"./ast.ts\";\nimport { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { slice, slice_start } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nexport function lower_statement(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tif (ts.isExpressionStatement(stmt)) {\n\t\treturn lower_expression_statement(stmt, content, context);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn lower_variable_statement(stmt, content, context);\n\t}\n\n\tconst text = slice(content, stmt);\n\tconst wrapped_text = wrap_yield_stars_in_node(stmt, content, context);\n\n\treturn {\n\t\ttemps: [],\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [make_effect_block([wrapped_text], collect_deps(text))],\n\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_variable_statement(\n\tstmt: ts.VariableStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst helper_declarations: string[] = [];\n\tconst rewritten_decls: string[] = [];\n\n\tconst decl_list = stmt.declarationList;\n\tconst kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n\tlet uses_dispatcher_promise = false;\n\n\tfor (const decl of decl_list.declarations) {\n\t\tif (!contains_top_level_yield_star(decl)) {\n\t\t\trewritten_decls.push(slice(content, decl).trim());\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst lowered = lower_node_yields_to_await(\n\t\t\tdecl,\n\t\t\tcontent,\n\t\t\tmake_binding_hint(decl.name),\n\t\t\tcontext,\n\t\t);\n\n\t\thelper_declarations.push(...lowered.helper_declarations);\n\t\trewritten_decls.push(lowered.rewritten_text);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\n\t}\n\n\tconst rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\n\n\treturn {\n\t\ttemps: [],\n\t\ttype_helpers: helper_declarations,\n\t\trewritten_text,\n\t\teffect_blocks: [],\n\t\tuses_dispatcher_promise,\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_statement(\n\tstmt: ts.ExpressionStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst expr = stmt.expression;\n\n\tif (!contains_top_level_yield_star(expr)) {\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: slice(content, stmt).trim(),\n\t\t\teffect_blocks: [],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (is_yield_star_expression(expr)) {\n\t\t/**\n\t\t * Leading trivia must stay out of the sliced expression: a comment ahead\n\t\t * of the yield* would defeat the anchored strip in wrap_yield_text and\n\t\t * leave a second yield* nested inside the ToEffect argument.\n\t\t */\n\t\tconst text = slice_start(content, expr).trim();\n\t\tconst yield_text = wrap_yield_text(text, context);\n\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [make_effect_block([yield_text + \";\"], collect_deps(text))],\n\t\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n\t\tconst target = slice(content, expr.left).trim();\n\t\tconst target_names = collect_assignment_target_names(expr.left);\n\n\t\tif (\n\t\t\texpr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n\t\t\tis_yield_star_expression(expr.right)\n\t\t) {\n\t\t\tconst yield_text = extract_yield_star_full_text(expr.right, content);\n\t\t\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\t\t\treturn {\n\t\t\t\ttemps: [],\n\t\t\t\trewritten_text: \"\",\n\t\t\t\teffect_blocks: [\n\t\t\t\t\tmake_effect_block(\n\t\t\t\t\t\t[`${target} = ${wrapped_yield_text};`],\n\t\t\t\t\t\tcollect_deps(yield_text, target_names),\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t\t};\n\t\t}\n\n\t\tconst lowered = lower_expression_yields(\n\t\t\texpr.right,\n\t\t\tcontent,\n\t\t\tmake_temp_hint(target),\n\t\t\tcontext,\n\t\t);\n\t\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\t\tconst statement = `${target} ${slice(\n\t\t\tcontent,\n\t\t\texpr.operatorToken,\n\t\t).trim()} ${lowered.rewritten_expr};`;\n\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [\n\t\t\t\tmake_effect_block(\n\t\t\t\t\t[...lowered.effect_blocks.flatMap((block) => block.statements), statement],\n\t\t\t\t\t[\n\t\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t\t...collect_deps(lowered.rewritten_expr, [...target_names, ...temp_names]),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst lowered = lower_expression_yields(expr, content, \"call\", context);\n\n\tif (is_top_level_rune_call(expr)) {\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: lowered.rewritten_expr + \";\",\n\t\t\teffect_blocks: lowered.effect_blocks,\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\n\treturn {\n\t\ttemps: lowered.temps,\n\t\ttype_helpers: lowered.type_helpers,\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [\n\t\t\tmake_effect_block(\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.statements),\n\t\t\t\t\tlowered.rewritten_expr + \";\",\n\t\t\t\t],\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t...collect_deps(lowered.rewritten_expr, temp_names),\n\t\t\t\t],\n\t\t\t),\n\t\t],\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_yields(\n\texpr: ts.Expression,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): LoweredExpression {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tconst temps: TempBinding[] = [];\n\tconst type_helpers: string[] = [];\n\tconst statements: string[] = [];\n\tconst deps: string[] = [];\n\n\tcollect_yield_star_nodes(expr, (node) => {\n\t\tconst temp_name = context.next_temp_name(hint);\n\t\tconst yield_text = slice_start(content, node).trim();\n\t\tconst type_helper = make_yield_type_helper(yield_text, hint, context);\n\n\t\tif (type_helper) {\n\t\t\ttype_helpers.push(type_helper.declaration);\n\t\t\ttemps.push({ name: temp_name, type: type_helper.type });\n\t\t} else {\n\t\t\ttemps.push({ name: temp_name });\n\t\t}\n\n\t\tstatements.push(`${temp_name} = ${wrap_yield_text(yield_text, context)};`);\n\t\tdeps.push(...collect_deps(yield_text));\n\t\treplacements.push({\n\t\t\tstart: node.getStart(),\n\t\t\tend: node.end,\n\t\t\ttext: temp_name,\n\t\t});\n\t});\n\n\tif (replacements.length === 0) {\n\t\treturn {\n\t\t\ttemps,\n\t\t\ttype_helpers,\n\t\t\trewritten_expr: slice(content, expr).trim(),\n\t\t\teffect_blocks: [],\n\t\t};\n\t}\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice(content, expr);\n\n\tconst offset_in_expr = expr.getFullStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_expr) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_expr);\n\t}\n\n\treturn {\n\t\ttemps,\n\t\ttype_helpers,\n\t\trewritten_expr: text.trim(),\n\t\teffect_blocks: [make_effect_block(statements, deps)],\n\t};\n}\n\nfunction lower_node_yields_to_await(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): {\n\thelper_declarations: string[];\n\trewritten_text: string;\n\tuses_dispatcher_promise: boolean;\n} {\n\tconst helper_declarations: string[] = [];\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst awaited = make_awaited_yield_expression(yield_node, content, hint, context);\n\n\t\thelper_declarations.push(awaited.declaration);\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: awaited.expression,\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice_start(content, node);\n\tconst offset_in_node = node.getStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_node) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_node);\n\t}\n\n\treturn {\n\t\thelper_declarations,\n\t\trewritten_text: text.trim(),\n\t\tuses_dispatcher_promise: replacements.length > 0,\n\t};\n}\n\nfunction make_awaited_yield_expression(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; expression: string } {\n\tconst yield_text = slice_start(content, node).trim();\n\tconst helper_name = context.next_helper_name(`effect_${hint}`);\n\tconst helper_id = make_script_effect_id(node, context);\n\tconst deps = collect_deps(yield_text);\n\tconst deps_text = `[${deps.join(\", \")}]`;\n\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\treturn {\n\t\tdeclaration: `function* ${helper_name}() { return (${wrapped_yield_text}); }`,\n\t\texpression: [\n\t\t\t`await ${context.dispatcher_name}().with_scope(${context.scope_name}.scope, () => ${context.dispatcher_name}().promise({`,\n\t\t\t`id: ${JSON.stringify(helper_id)}, `,\n\t\t\t`deps: ${deps_text}, `,\n\t\t\t`factory: () => ${helper_name}()`,\n\t\t\t`}))`,\n\t\t].join(\"\"),\n\t};\n}\n\nfunction make_yield_type_helper(\n\tyield_text: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n\tif (!context.emit_types) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_name = context.next_type_helper_name(hint);\n\tconst effect_text = strip_yield_star(yield_text);\n\n\treturn {\n\t\tdeclaration: `function ${helper_name}() { return (${effect_text}); }`,\n\t\ttype: `${context.yield_success_name}<ReturnType<typeof ${helper_name}>> | undefined`,\n\t};\n}\n\nfunction strip_yield_star(yield_text: string): string {\n\treturn yield_text.replace(/^yield\\s*\\*\\s*/, \"\");\n}\n\nfunction wrap_yield_text(yield_text: string, context: ScriptLoweringContext): string {\n\treturn `yield* ${context.yieldable_name}(${strip_yield_star(yield_text)})`;\n}\n\nfunction wrap_yield_stars_in_node(\n\tnode: ts.Node,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): string {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst yield_text = slice_start(content, yield_node).trim();\n\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: wrap_yield_text(yield_text, context),\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tconst offset = node.getFullStart();\n\tlet text = slice(content, node);\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset);\n\t}\n\n\treturn text.trim();\n}\n\nfunction make_script_effect_id(expr: ts.Node, context: ScriptLoweringContext): string {\n\treturn `${context.filename}:${expr.getStart()}:${expr.end}`;\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n\treturn (\n\t\texpr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n\t\texpr.operatorToken.kind <= ts.SyntaxKind.LastAssignment\n\t);\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n\tif (!ts.isCallExpression(expr)) {\n\t\treturn false;\n\t}\n\n\tconst callee = expr.expression;\n\n\tif (ts.isIdentifier(callee)) {\n\t\treturn callee.text.startsWith(\"$\");\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(callee) &&\n\t\tts.isIdentifier(callee.expression) &&\n\t\tcallee.expression.text.startsWith(\"$\")\n\t);\n}\n\nfunction make_temp_hint(target: string): string {\n\tconst match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n\treturn match?.[0] ?? \"assignment\";\n}\n\nfunction make_binding_hint(name: ts.BindingName): string {\n\tif (ts.isIdentifier(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn \"destructure\";\n}\n\nfunction extract_yield_star_full_text(expr: ts.Expression, content: string): string {\n\tlet found: string | undefined;\n\n\tfind_yield_star_node(expr, (node) => {\n\t\tfound = slice_start(content, node).trim();\n\t});\n\n\treturn found ?? \"undefined\";\n}\n\nfunction make_effect_block(statements: string[], deps: string[]): EffectBlock {\n\treturn {\n\t\tstatements,\n\t\tdeps: [...new Set(deps)],\n\t};\n}\n\nfunction collect_deps(expr_text: string, excluded_names: readonly string[] = []): string[] {\n\tconst excluded = new Set(excluded_names);\n\n\treturn collect_free_identifiers(expr_text).filter(\n\t\t(identifier) => !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n\t);\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n\tif (ts.isIdentifier(node)) {\n\t\treturn [node.text];\n\t}\n\n\tif (ts.isParenthesizedExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isObjectLiteralExpression(node)) {\n\t\treturn node.properties.flatMap((property) => {\n\t\t\tif (ts.isShorthandPropertyAssignment(property)) {\n\t\t\t\treturn [property.name.text];\n\t\t\t}\n\n\t\t\tif (ts.isPropertyAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.initializer);\n\t\t\t}\n\n\t\t\tif (ts.isSpreadAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.expression);\n\t\t\t}\n\n\t\t\treturn [];\n\t\t});\n\t}\n\n\tif (ts.isArrayLiteralExpression(node)) {\n\t\treturn node.elements.flatMap((element) =>\n\t\t\tts.isSpreadElement(element)\n\t\t\t\t? collect_assignment_target_names(element.expression)\n\t\t\t\t: collect_assignment_target_names(element),\n\t\t);\n\t}\n\n\treturn [];\n}\n","import type {\n\tBlockRef,\n\tEffectBlock,\n\tRelocation,\n\tRuntimeImportBindings,\n\tScriptLoweringContext,\n\tScriptTransformResult,\n} from \"./types.ts\";\nimport {\n\tcollect_top_level_binding_names,\n\thas_local_import_binding,\n\tmake_imports,\n} from \"./imports.ts\";\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport type { MarkupTransformTarget } from \"$/markup/transform.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n\temit_types?: boolean;\n\ttarget?: MarkupTransformTarget;\n}\n\n/**\n * Transforms a `<script effect>` body by lowering top-level `yield*`\n * expressions into Svelte-compatible async rendering declarations or into\n * dependency-tracked `$effect` blocks for effectful statements.\n *\n * @example\n * ```ts\n * const result = transform_script_effect(\n * `let user = $state(yield* getUser(id));`,\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `<script effect>` body content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform settings for generated script code.\n * @returns The transformed code and any block references.\n */\nexport function transform_script_effect(\n\tcontent: string,\n\tfilename: string,\n\toptions: ScriptTransformOptions = {},\n): ScriptTransformResult {\n\tlet temp_counter = 0;\n\tconst target = options.target ?? \"client\";\n\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcontent,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst magic = new MagicString(content);\n\tconst effect_blocks: EffectBlock[] = [];\n\tconst block_refs: BlockRef[] = [];\n\tconst top_level_binding_names = collect_top_level_binding_names(source_file);\n\tconst top_level_binding_names_set = new Set(top_level_binding_names);\n\tconst name_allocator = make_name_allocator(top_level_binding_names);\n\tconst emit_types = options.emit_types ?? true;\n\n\tlet has_effect = false;\n\tlet first_effect_statement_start = content.length;\n\tlet uses_dispatcher_promise = false;\n\tlet uses_yield_success_types = false;\n\n\t/** Phase 1: detect imports already provided by the user. */\n\tconst has_effect_import = has_local_import_binding(source_file, \"effect\", \"Effect\");\n\n\tconst has_dispatcher_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte-effect-runtime/internal/generators\",\n\t\t\"get_dispatcher\",\n\t);\n\n\tconst has_untrack_import = has_local_import_binding(source_file, \"svelte\", \"untrack\");\n\tconst has_on_destroy_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte\",\n\t\t\"onDestroy\",\n\t\tfalse,\n\t);\n\n\tconst reserve_runtime_import = (name: string) =>\n\t\ttop_level_binding_names_set.has(name)\n\t\t\t? name_allocator.reserve(make_generated_name(name, \"\"))\n\t\t\t: name_allocator.reserve(name);\n\n\tconst runtime_bindings: RuntimeImportBindings = {\n\t\tcancel: name_allocator.reserve(\"__SER___cancel\"),\n\t\tcomponent_scope_ref: reserve_runtime_import(\"ComponentScopeRef\"),\n\t\tdispatcher: has_dispatcher_import\n\t\t\t? \"get_dispatcher\"\n\t\t\t: reserve_runtime_import(\"get_dispatcher\"),\n\t\tdispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n\t\teffect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n\t\ton_destroy: has_on_destroy_import ? \"onDestroy\" : reserve_runtime_import(\"onDestroy\"),\n\t\tprogram: name_allocator.reserve(\"__SER___program\"),\n\t\tscope: name_allocator.reserve(\"__SER___scope\"),\n\t\tuntrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n\t\tyield_success: reserve_runtime_import(\"YieldSuccess\"),\n\t\tyieldable: reserve_runtime_import(\"ToEffect\"),\n\t};\n\n\tconst context: ScriptLoweringContext = {\n\t\tfilename,\n\t\tdispatcher_name: runtime_bindings.dispatcher,\n\t\tscope_name: runtime_bindings.scope,\n\t\teffect_name: runtime_bindings.effect,\n\t\temit_types,\n\t\tyield_success_name: runtime_bindings.yield_success,\n\t\tyieldable_name: runtime_bindings.yieldable,\n\t\tnext_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\n\t\t},\n\t\tnext_temp_name(hint?: string) {\n\t\t\tconst suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n\t\t\tconst name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n\t\t\ttemp_counter += 1;\n\n\t\t\treturn name_allocator.reserve(name);\n\t\t},\n\t\tnext_type_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(`type_${hint ?? \"effect\"}`, \"\"));\n\t\t},\n\t};\n\n\t/** Phase 2: lower every top-level statement that contains `yield*`. */\n\tfor (const stmt of source_file.statements) {\n\t\tvalidate_rune_yield_usage(stmt, content, filename);\n\t\tvalidate_script_yield_boundaries(stmt, content, filename);\n\n\t\tconst has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n\t\tif (!has_top_level_yield_star) {\n\t\t\tcontinue;\n\t\t}\n\n\t\thas_effect = true;\n\n\t\tconst lowered = lower_statement(stmt, content, context);\n\n\t\tfirst_effect_statement_start = Math.min(first_effect_statement_start, lowered.range.start);\n\n\t\tif (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\n\t\t\tconst text = slice(content, stmt);\n\t\t\tthrow new AwaitInEffectWorkError(filename, text);\n\t\t}\n\n\t\tmagic.overwrite(lowered.range.start, lowered.range.end, lowered.rewritten_text);\n\n\t\tif (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n\t\t\tconst temp_declarations = lowered.temps.map((temp) =>\n\t\t\t\ttemp.type\n\t\t\t\t\t? `let ${temp.name} = $state<${temp.type}>(undefined);`\n\t\t\t\t\t: `let ${temp.name} = $state(undefined);`,\n\t\t\t);\n\n\t\t\tconst prefix = [...(lowered.type_helpers ?? []), ...temp_declarations].join(\"\\n\");\n\n\t\t\tmagic.appendLeft(lowered.range.start, prefix + \"\\n\");\n\t\t}\n\n\t\teffect_blocks.push(...lowered.effect_blocks);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\n\t\tuses_yield_success_types ||= lowered.temps.some(\n\t\t\t(temp) => temp.type?.includes(runtime_bindings.yield_success) ?? false,\n\t\t);\n\t}\n\n\tif (!has_effect) {\n\t\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\t\treturn { code: content, blocks: block_refs };\n\t}\n\n\t/** Phase 3: inject runtime imports after the last user import. */\n\tconst imports = make_imports(\n\t\thas_effect_import,\n\t\thas_dispatcher_import,\n\t\thas_untrack_import,\n\t\thas_on_destroy_import,\n\t\truntime_bindings,\n\t\t{\n\t\t\tneeds_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_effect: effect_blocks.length > 0,\n\t\t\tneeds_untrack: effect_blocks.length > 0,\n\t\t\t/** The server never registers disposal, so it never needs the import. */\n\t\t\tneeds_on_destroy: target !== \"server\",\n\t\t\tneeds_yield_success: uses_yield_success_types,\n\t\t\tneeds_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_scope_ref: true,\n\t\t},\n\t);\n\n\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\tconst injection_point = last_import\n\t\t? Math.min(last_import.end, first_effect_statement_start)\n\t\t: first_effect_statement_start;\n\n\t/**\n\t * The scope holder is created synchronously with the imports so it exists\n\t * before any top-level `await`, and disposal is registered through\n\t * `onDestroy` during component initialisation. Emitting both here keeps\n\t * them ahead of every lowered statement that references the scope.\n\t */\n\tconst scope_wiring = [\n\t\t`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`,\n\t\t...(target === \"server\"\n\t\t\t? []\n\t\t\t: [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`]),\n\t].join(\"\\n\");\n\n\tconst injected = [imports, scope_wiring].filter(Boolean).join(\"\\n\");\n\n\tif (last_import && last_import.end <= first_effect_statement_start) {\n\t\tmagic.appendRight(last_import.end, \"\\n\" + injected);\n\t} else if (injection_point >= 0) {\n\t\tmagic.appendLeft(injection_point, injected + \"\\n\");\n\t} else {\n\t\tmagic.appendLeft(first_effect_statement_start, injected + \"\\n\");\n\t}\n\n\t/** Phase 4: append the runtime program blocks. */\n\n\tif (effect_blocks.length > 0) {\n\t\tconst runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);\n\n\t\tmagic.append(\"\\n\" + runtime_block);\n\t}\n\n\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\tconst code = magic.toString();\n\n\treturn {\n\t\tcode,\n\t\tblocks: block_refs,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations: create_script_relocations(\n\t\t\tcontent,\n\t\t\tcode,\n\t\t\tsource_file,\n\t\t\truntime_bindings.yieldable,\n\t\t),\n\t};\n}\n\nfunction create_script_relocations(\n\tcontent: string,\n\tcode: string,\n\tsource_file: ts.SourceFile,\n\tyieldable_name: string,\n): Relocation[] {\n\tconst candidates = source_file.statements.flatMap((stmt) => {\n\t\tconst relocations: RelocationCandidate[] = [];\n\n\t\tif (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\n\t\t\tfor (const decl of stmt.declarationList.declarations) {\n\t\t\t\tcollect_binding_relocation_candidates(decl.name, relocations);\n\t\t\t}\n\t\t}\n\n\t\tcollect_yield_star_nodes(stmt, (node) => {\n\t\t\tconst expression = ts.isBinaryExpression(node) ? node.right : node;\n\t\t\tconst text = content.slice(expression.getStart(), expression.end).trim();\n\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: expression.getStart(),\n\t\t\t\toriginalEnd: expression.end,\n\t\t\t\ttext,\n\t\t\t\tmatch: \"yield_operand\",\n\t\t\t\twrapper: `${yieldable_name}(${text})`,\n\t\t\t});\n\t\t});\n\n\t\treturn relocations;\n\t});\n\n\tconst used_ranges: Array<{ start: number; end: number }> = [];\n\tconst search_cursors = new Map<string, number>();\n\n\treturn candidates.flatMap((candidate) => {\n\t\tconst search_key = make_relocation_search_key(candidate);\n\t\tconst generated_start = find_available_generated_text(\n\t\t\tcode,\n\t\t\tcandidate,\n\t\t\tused_ranges,\n\t\t\tsearch_cursors.get(search_key) ?? 0,\n\t\t);\n\n\t\tif (generated_start < 0) {\n\t\t\tsearch_cursors.set(search_key, code.length);\n\n\t\t\treturn [];\n\t\t}\n\n\t\tconst generated_end = generated_start + candidate.text.length;\n\t\tused_ranges.push({ start: generated_start, end: generated_end });\n\t\tsearch_cursors.set(search_key, generated_end);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: candidate.originalStart,\n\t\t\t\toriginalEnd: candidate.originalEnd,\n\t\t\t\tgeneratedStart: generated_start,\n\t\t\t\tgeneratedEnd: generated_end,\n\t\t\t},\n\t\t];\n\t});\n}\n\ntype RelocationCandidate = {\n\toriginalStart: number;\n\toriginalEnd: number;\n\ttext: string;\n\tmatch: \"exact\" | \"identifier\" | \"yield_operand\";\n\twrapper?: string;\n};\n\nfunction make_relocation_search_key(candidate: RelocationCandidate): string {\n\treturn `${candidate.match}:${candidate.text}`;\n}\n\nfunction collect_binding_relocation_candidates(\n\tname: ts.BindingName,\n\tcandidates: RelocationCandidate[],\n): void {\n\tif (ts.isIdentifier(name)) {\n\t\tcandidates.push({\n\t\t\toriginalStart: name.getStart(),\n\t\t\toriginalEnd: name.end,\n\t\t\ttext: name.text,\n\t\t\tmatch: \"identifier\",\n\t\t});\n\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_relocation_candidates(element.name, candidates);\n\t}\n}\n\nfunction find_available_generated_text(\n\tcode: string,\n\tcandidate: RelocationCandidate,\n\tused_ranges: Array<{ start: number; end: number }>,\n\tsearch_start: number,\n): number {\n\twhile (search_start < code.length) {\n\t\tconst search_text =\n\t\t\tcandidate.match === \"yield_operand\" ? candidate.wrapper : candidate.text;\n\n\t\tif (!search_text) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst index = code.indexOf(search_text, search_start);\n\n\t\tif (index < 0) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst operand_offset =\n\t\t\tcandidate.match === \"yield_operand\" && candidate.wrapper\n\t\t\t\t? candidate.wrapper.indexOf(candidate.text)\n\t\t\t\t: 0;\n\t\tconst start = index + Math.max(operand_offset, 0);\n\t\tconst end = start + candidate.text.length;\n\t\tconst overlaps_used_range = used_ranges.some(\n\t\t\t(range) => start < range.end && end > range.start,\n\t\t);\n\t\tconst is_text_match =\n\t\t\tcandidate.match !== \"identifier\" || is_identifier_text_match(code, start, end);\n\n\t\tif (!overlaps_used_range && is_text_match) {\n\t\t\treturn start;\n\t\t}\n\n\t\tsearch_start = candidate.match === \"identifier\" ? index + 1 : index + search_text.length;\n\t}\n\n\treturn -1;\n}\n\nfunction is_identifier_text_match(code: string, start: number, end: number): boolean {\n\tconst before = start === 0 ? 0 : code.charCodeAt(start - 1);\n\tconst after = end >= code.length ? 0 : code.charCodeAt(end);\n\n\treturn !is_identifier_part(before) && !is_identifier_part(after);\n}\n\nfunction is_identifier_part(char_code: number): boolean {\n\treturn (\n\t\t(char_code >= 65 && char_code <= 90) ||\n\t\t(char_code >= 97 && char_code <= 122) ||\n\t\t(char_code >= 48 && char_code <= 57) ||\n\t\tchar_code === 36 ||\n\t\tchar_code === 95\n\t);\n}\n\nfunction validate_script_yield_boundaries(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst bad_member = find_class_member_with_yield_star(stmt);\n\n\tif (!bad_member) {\n\t\treturn;\n\t}\n\n\tthrow new PreprocessError(\n\t\t[\n\t\t\t`[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n\t\t\t`Class fields and methods are not component top-level reactive work. Move the Effect work into a script effect statement before assigning it to the class instance.`,\n\t\t\t\"\",\n\t\t\t\"Problematic member:\",\n\t\t\tslice(content, bad_member),\n\t\t].join(\"\\n\"),\n\t\tfilename,\n\t);\n}\n\nfunction find_class_member_with_yield_star(stmt: ts.Statement): ts.Node | undefined {\n\tlet found: ts.Node | undefined;\n\n\tfunction visit(node: ts.Node): void {\n\t\tif (found) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tts.isPropertyDeclaration(node) &&\n\t\t\tnode.initializer &&\n\t\t\tcontains_top_level_yield_star(node.initializer)\n\t\t) {\n\t\t\tfound = node;\n\t\t\treturn;\n\t\t}\n\n\t\tnode.forEachChild(visit);\n\t}\n\n\tvisit(stmt);\n\n\treturn found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n\tconst normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n\tconst safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n\t\t? normalized_hint\n\t\t: `temp_${normalized_hint}`;\n\n\treturn `__SER___${safe_hint}${suffix}`;\n}\n","import { type MarkupTransformTarget, transform_markup_effect } from \"$/markup/transform.ts\";\nimport { scan_svelte_effect_source } from \"$/compiler/source-scan.ts\";\nimport { transform_script_effect } from \"$/script-transform/index.ts\";\n\n/**\n * Result returned by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\"<p>{yield* load()}</p>\", \"App.svelte\");\n * result.code;\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformResult {\n\t/** Transformed Svelte source. */\n\tcode: string;\n}\n\n/**\n * Options accepted by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const options: SvelteTransformOptions = { target: \"client\" };\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformOptions {\n\t/** Markup emission target passed through to the markup transform. */\n\ttarget?: MarkupTransformTarget;\n}\n\n/**\n * Lowers SER syntax in a complete Svelte component without using Svelte's\n * adapter API.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\n * \"<script effect>const value = yield* load()</script>\",\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.5.0\n * @param content - Full Svelte component source to lower before Svelte parses\n * it.\n * @param filename - Component filename used in generated cache identifiers and\n * diagnostics.\n * @param options - Optional target configuration for markup lowering.\n * @returns The transformed component source.\n */\nexport function transform_svelte_effect(\n\tcontent: string,\n\tfilename = \"unknown.svelte\",\n\toptions: SvelteTransformOptions = {},\n): SvelteTransformResult {\n\tconst scan = scan_svelte_effect_source(content, filename);\n\tconst script = scan.effect_script;\n\n\tlet combined = content;\n\n\tif (script) {\n\t\tconst effect_attribute = script.effect_attribute;\n\t\tconst effect_attribute_start = effect_attribute?.start ?? script.opening_tag_end;\n\t\tconst effect_attribute_end = effect_attribute?.end ?? script.opening_tag_end;\n\t\tconst result = transform_script_effect(script.text, filename, {\n\t\t\temit_types: script.is_typescript,\n\t\t\ttarget: options.target ?? \"client\",\n\t\t});\n\n\t\tcombined =\n\t\t\tcontent.slice(0, effect_attribute_start) +\n\t\t\tcontent.slice(effect_attribute_end, script.opening_tag_end) +\n\t\t\tresult.code +\n\t\t\tcontent.slice(script.closing_tag_start);\n\t}\n\n\tconst markup_options = options.target === undefined ? {} : { target: options.target };\n\tconst result = transform_markup_effect(combined, filename, markup_options);\n\n\treturn { code: result.code };\n}\n\nexport {\n\ttype MarkupTransformOptions,\n\ttype MarkupTransformResult,\n\ttype MarkupTransformTarget,\n\ttransform_markup_effect,\n} from \"$/markup/transform.ts\";\n\nexport {\n\ttype BlockRef,\n\ttype ScriptTransformResult,\n\ttransform_script_effect,\n} from \"$/script-transform/index.ts\";\n"],"mappings":";;;;;;;AAEA,SAAgB,iCACf,QACA,UACS;CACT,OAAO,OAAO,KAAK,UAAU,0BAA0B,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;AACnF;AAEA,SAAS,0BAA0B,OAAoB,UAAyC;CAC/F,MAAM,YAAY,MAAM,KAAK,KAAK,QAAQ,KAAK,IAAI,EAAE;CAErD,MAAM,OAAO,MAAM,WAAW,KAAK,cAAc,OAAO,WAAW,CAAC,CAAC,KAAK,IAAI;CAE9E,OAAO;EACN;EACA;EACA,GAAG;EACH,WAAW,SAAS,iBAAiB,KAAK,SAAS,WAAW;EAC9D,WAAW,SAAS,QAAQ,KAAK,SAAS,O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AmB,GAAG;CAK3D,OAAO,WAJW,cAAc,KAAK,eAAe,IACjD,kBACA,QAAQ,oBAEmB;AAC/B;;;;;;;;;;;;;;;;;;;;;;;AC5bA,SAAgB,wBACf,SACA,WAAW,kBACX,UAAkC,CAAC,GACX;CAExB,MAAM,SADO,0BAA0B,SAAS,QAC9B,CAAC,CAAC;CAEpB,IAAI,WAAW;CAEf,IAAI,QAAQ;EACX,MAAM,mBAAmB,OAAO;EAChC,MAAM,yBAAyB,kBAAkB,SAAS,OAAO;EACjE,MAAM,uBAAuB,kBAAkB,OAAO,OAAO;EAC7D,MAAM,SAAS,wBAAwB,OAAO,MAAM,UAAU;GAC7D,YAAY,OAAO;GACnB,QAAQ,QAAQ,UAAU;EAC3B,CAAC;EAED,WACC,QAAQ,MAAM,GAAG,sBAAsB,IACvC,QAAQ,MAAM,sBAAsB,OAAO,eAAe,IAC1D,OAAO,OACP,QAAQ,MAAM,OAAO,iBAAiB;CACxC;CAEA,MAAM,iBAAiB,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;CAGpF,OAAO,EAAE,MAFM,wBAAwB,UAAU,UAAU,cAEvC,CAAC,CAAC,KAAK;AAC5B"}
|
package/.dist/server.js
CHANGED
|
@@ -2,7 +2,7 @@ import { D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMi
|
|
|
2
2
|
import { create_form_error, create_remote_transport_error } from "./remote/shared.js";
|
|
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
|
-
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-
|
|
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
6
|
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-B8RHHy3v.js";
|
|
7
7
|
import { Effect, Result, Stream } from "effect";
|
|
8
8
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
@@ -61,10 +61,10 @@ function run_live_handler(handler, event) {
|
|
|
61
61
|
}
|
|
62
62
|
function run_live_source_effect(effect, event) {
|
|
63
63
|
const runtime = get_server_runtime_or_throw();
|
|
64
|
-
return run_remote_effect(Effect.provideService(effect, RequestEvent, event), runtime, invalid, svelte_remote_error, to_remote_failure_context(event));
|
|
64
|
+
return run_remote_effect(Effect.provideService(effect, RequestEvent, event), runtime, invalid, svelte_remote_error, () => to_remote_failure_context(event));
|
|
65
65
|
}
|
|
66
66
|
const ToLiveSourceEffect = (value, event) => Stream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(Effect.map((source) => wrap_live_source_errors(source, event)));
|
|
67
|
-
const preserve_live_source_cause = (value, event) => value.pipe(Stream.catchCause((cause) => Stream.fromEffect(Effect.sync(() => throw_remote_cause(cause, invalid, svelte_remote_error, to_remote_failure_context(event))))));
|
|
67
|
+
const preserve_live_source_cause = (value, event) => value.pipe(Stream.catchCause((cause) => Stream.fromEffect(Effect.sync(() => throw_remote_cause(cause, invalid, svelte_remote_error, () => to_remote_failure_context(event))))));
|
|
68
68
|
function wrap_live_source_errors(source, event) {
|
|
69
69
|
return { [Symbol.asyncIterator]() {
|
|
70
70
|
const iterator = source[Symbol.asyncIterator]();
|
|
@@ -96,7 +96,7 @@ function RunLiveIteratorCall(event, run) {
|
|
|
96
96
|
}
|
|
97
97
|
function run_handler_effect(value, event) {
|
|
98
98
|
const runtime = get_server_runtime_or_throw();
|
|
99
|
-
return run_remote_effect(Effect.provideService(RunInsideRemoteEffectHandler(event, ToEffect(value)), RequestEvent, event), runtime, invalid, svelte_remote_error, to_remote_failure_context(event));
|
|
99
|
+
return run_remote_effect(Effect.provideService(RunInsideRemoteEffectHandler(event, ToEffect(value)), RequestEvent, event), runtime, invalid, svelte_remote_error, () => to_remote_failure_context(event));
|
|
100
100
|
}
|
|
101
101
|
const svelte_remote_error = (status, body) => {
|
|
102
102
|
error(status, body);
|
package/.dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","names":["get_native_request_event","svelte_invalid","get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender","get_native_request_event","Error","error","svelte_error","redirect","svelte_redirect"],"sources":["../../modules/svelte-effect-runtime/src/server/remote-handler-context.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/live-snapshot.ts","../../modules/svelte-effect-runtime/src/server/transport.ts","../../modules/svelte-effect-runtime/src/server/factories.ts","../../modules/svelte-effect-runtime/src/server/handler.ts","../../modules/svelte-effect-runtime/src/server/control-flow.ts"],"sourcesContent":["import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { Effect } from \"effect\";\n\nconst active_remote_handler_counts = new WeakMap<object, number>();\n\n/** Tracks ownership per request event so concurrent requests remain isolated. */\nexport function is_running_remote_effect_handler(event?: object): boolean {\n\tconst request_event = event ?? get_current_request_event();\n\n\tif (!request_event) {\n\t\treturn false;\n\t}\n\n\treturn (active_remote_handler_counts.get(request_event) ?? 0) > 0;\n}\n\n/** Marks one request as handler-owned for the lifetime of the supplied Effect. */\nexport const RunInsideRemoteEffectHandler = <A, E, R>(\n\tevent: object,\n\teffect: Effect.Effect<A, E, R>,\n) =>\n\tEffect.acquireUseRelease(\n\t\tAcquireRemoteHandlerOwnership(event),\n\t\t() => effect,\n\t\t() => ReleaseRemoteHandlerOwnership(event),\n\t);\n\nconst AcquireRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst active_count = active_remote_handler_counts.get(event) ?? 0;\n\n\t\tactive_remote_handler_counts.set(event, active_count + 1);\n\t});\n\nconst ReleaseRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst remaining_count = (active_remote_handler_counts.get(event) ?? 1) - 1;\n\n\t\tif (remaining_count === 0) {\n\t\t\tactive_remote_handler_counts.delete(event);\n\n\t\t\treturn;\n\t\t}\n\n\t\tactive_remote_handler_counts.set(event, remaining_count);\n\t});\n\nfunction get_current_request_event(): object | undefined {\n\ttry {\n\t\tconst event = get_native_request_event();\n\n\t\treturn typeof event === \"object\" && event !== null ? event : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n","import { error as svelte_error, invalid as svelte_invalid } from \"@sveltejs/kit\";\nimport {\n\trun_remote_effect,\n\tthrow_remote_cause,\n\tto_remote_failure_context,\n} from \"$/remote/server.ts\";\nimport { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { Effect, Stream } from \"effect\";\nimport type { EffectLike } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> = AsyncIterable<A>;\n\ntype LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;\n\ntype LiveHandler<A> = () => LiveHandlerResult<A>;\n\nexport function is_generator_result<A>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n\nexport function ToEffect<A, E, R>(value: EffectLike<A, E, R>): Effect.Effect<A, E, R> {\n\tif (is_generator_result<A>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nexport function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown> {\n\treturn Stream.isStream(value);\n}\n\nexport function run_live_handler_source<A>(\n\tvalue: LiveHandlerResult<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tif (!is_live_source(value)) {\n\t\tthrow new InvalidLiveQueryReturnError();\n\t}\n\n\treturn run_live_source_effect(ToLiveSourceEffect(value, event), event);\n}\n\n/** Runs a live handler inside the request-local ownership scope. */\nexport function run_live_handler<A>(\n\thandler: LiveHandler<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst LiveSourceEffect = Effect.suspend(() => {\n\t\tconst value = handler();\n\n\t\tif (!is_live_source(value)) {\n\t\t\treturn Effect.die(new InvalidLiveQueryReturnError());\n\t\t}\n\n\t\treturn ToLiveSourceEffect(value, event);\n\t});\n\n\treturn run_live_source_effect(RunInsideRemoteEffectHandler(event, LiveSourceEffect), event);\n}\n\nfunction run_live_source_effect<A>(\n\teffect: Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\teffect,\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\tto_remote_failure_context(event),\n\t);\n}\n\nconst ToLiveSourceEffect = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tStream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(\n\t\tEffect.map((source) => wrap_live_source_errors(source, event)),\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\nconst preserve_live_source_cause = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tvalue.pipe(\n\t\tStream.catchCause((cause) =>\n\t\t\tStream.fromEffect(\n\t\t\t\tEffect.sync(() =>\n\t\t\t\t\tthrow_remote_cause(\n\t\t\t\t\t\tcause,\n\t\t\t\t\t\tsvelte_invalid,\n\t\t\t\t\t\tsvelte_remote_error,\n\t\t\t\t\t\tto_remote_failure_context(event),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\nfunction wrap_live_source_errors<A>(\n\tsource: AsyncIterable<A>,\n\tevent: RequestEventShape,\n): AsyncIterable<A> {\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\tconst iterator = source[Symbol.asyncIterator]();\n\t\t\tconst throw_iterator = iterator.throw?.bind(iterator);\n\n\t\t\treturn {\n\t\t\t\tnext() {\n\t\t\t\t\treturn RunLiveIteratorCall(event, () => iterator.next());\n\t\t\t\t},\n\n\t\t\t\treturn(value?: unknown) {\n\t\t\t\t\tif (iterator.return) {\n\t\t\t\t\t\treturn RunLiveIteratorCall(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t() => iterator.return?.(value) as PromiseLike<IteratorResult<A>>,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Promise.resolve({\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: undefined as A,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t...(throw_iterator === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tthrow(error?: unknown) {\n\t\t\t\t\t\t\t\treturn RunLiveIteratorCall(event, () => throw_iterator(error));\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction RunLiveIteratorCall<A>(event: RequestEventShape, run: () => PromiseLike<A>): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst IteratorEffect = Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => error,\n\t});\n\n\treturn runtime.runPromise(\n\t\tRunInsideRemoteEffectHandler(event, IteratorEffect) as Effect.Effect<A, unknown, unknown>,\n\t);\n}\n\nexport function run_handler_effect<A>(\n\tvalue: EffectLike<A, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\tRunInsideRemoteEffectHandler(event, ToEffect(value)),\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<A, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\tto_remote_failure_context(event),\n\t);\n}\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n\tsvelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { FormInvalid } from \"./types.ts\";\nimport { Effect } from \"effect\";\n\nexport function make_invalid_proxy<Input = unknown>(\n\tpath: readonly (string | number)[] = [],\n): FormInvalid<Input> {\n\tconst invalid_at_path = (message: string) =>\n\t\tEffect.fail(create_form_error([{ message, path: [...path] } satisfies FormIssue]));\n\n\treturn new Proxy(invalid_at_path, {\n\t\tget(_target, property) {\n\t\t\tif (typeof property === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst segment = path.length === 0 ? property : normalize_nested_path_segment(property);\n\n\t\t\treturn make_invalid_proxy([...path, segment]);\n\t\t},\n\t}) as FormInvalid<Input>;\n}\n\nfunction normalize_nested_path_segment(property: string): string | number {\n\tconst is_array_index = /^(0|[1-9]\\d*)$/.test(property);\n\n\treturn is_array_index ? Number(property) : property;\n}\n","import type { RemoteHandler } from \"./types.ts\";\n\nexport {\n\tis_effect_schema,\n\tis_standard_schema,\n\tnormalize_validator,\n\ttype StandardSchema,\n} from \"$/internal/schema.ts\";\n\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n\treturn value === \"unchecked\";\n}\n\nexport function is_handler(\n\tvalue: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n\treturn typeof value === \"function\";\n}\n","import type {\n\tEffectLike,\n\tPrerenderInputs,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n} from \"./types.ts\";\nimport { run_handler_effect, run_live_handler, ToEffect } from \"./effects.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { get_server_runtime_or_throw } from \"./runtime.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport { Effect } from \"effect\";\n\nexport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\n\nexport function make_prerender_inputs_wrapper<Input>(\n\tgenerate_inputs: PrerenderInputs<Input>,\n): () => Promise<Input[]> {\n\treturn () => {\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst CollectInputs = Effect.gen(function* () {\n\t\t\tconst inputs = yield* Effect.suspend(() => ToEffect(generate_inputs()));\n\n\t\t\treturn Array.from(inputs);\n\t\t});\n\n\t\treturn runtime.runPromise(CollectInputs);\n\t};\n}\n\nexport function make_remote_wrapper(\n\thandler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst result = is_handler(handler) ? handler(input) : handler;\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n\nexport function make_remote_live_wrapper<Input, A>(\n\thandler: RemoteLiveSource<A, unknown, unknown> | RemoteLiveHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\treturn await run_live_handler(\n\t\t\t() => (typeof handler === \"function\" ? handler(input as Input) : handler),\n\t\t\tevent,\n\t\t);\n\t};\n}\n\nexport function make_remote_form_wrapper<Input, A>(\n\thandler: RemoteFormHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n\treturn async (data: unknown, issue: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst invalid_proxy = make_invalid_proxy<Input>();\n\t\t\tconst result = handler({\n\t\t\t\tdata: data as Input,\n\t\t\t\tinvalid: invalid_proxy,\n\t\t\t\tissue,\n\t\t\t});\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n","import { stringify } from \"devalue\";\n\nexport type NativeTransport = Readonly<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\treadonly encode: (value: unknown) => false | unknown;\n\t\t}\n\t>\n>;\n\n/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */\nexport function make_remote_live_snapshot_encoder(\n\ttransport: NativeTransport,\n): (value: unknown) => string {\n\tconst encoders = Object.fromEntries(\n\t\tObject.entries(transport).map(([key, transformer]) => [key, transformer.encode]),\n\t);\n\n\treturn (value) => stringify(value, encoders);\n}\n","import { make_remote_live_snapshot_encoder, type NativeTransport } from \"./live-snapshot.ts\";\n\nimport * as SvelteKitInternalServer from \"@sveltejs/kit/internal/server\";\n\ntype NativeRequestStore = {\n\treadonly state: {\n\t\treadonly transport: NativeTransport;\n\t};\n};\n\ntype NativeServerInternals = {\n\treadonly try_get_request_store?: () => NativeRequestStore | null;\n};\n\n/** Creates the current SvelteKit request's transport-aware live snapshot encoder. */\nexport function get_remote_live_snapshot_encoder(): ((value: unknown) => string) | undefined {\n\tconst try_get_request_store = (SvelteKitInternalServer as unknown as NativeServerInternals)\n\t\t.try_get_request_store;\n\tconst request_store = try_get_request_store?.();\n\n\tif (!request_store) {\n\t\treturn undefined;\n\t}\n\n\treturn make_remote_live_snapshot_encoder(request_store.state.transport);\n}\n","import type {\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tPrerenderOptions,\n\tQueryFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"./types.ts\";\nimport {\n\tBatchQueryHandlerMissingError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport {\n\tattach_failed_remote_query_resource,\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tcommand as native_command,\n\tform as native_form,\n\tgetRequestEvent as get_native_request_event,\n\tprerender as native_prerender,\n\tquery as native_query,\n} from \"$app/server\";\nimport {\n\tmake_prerender_inputs_wrapper,\n\tmake_remote_form_wrapper,\n\tmake_remote_live_wrapper,\n\tmake_remote_wrapper,\n} from \"./wrappers.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport {\n\tattach_native_remote_query_update,\n\tresolve_native_remote_query_updates,\n} from \"$/remote/query-update.ts\";\nimport { make_failed_remote_live_stream, make_remote_live_stream } from \"$/live.ts\";\nimport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { get_remote_live_snapshot_encoder } from \"./transport.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, Result, type Schema } from \"effect\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S[\"Encoded\"]> : never;\n\ntype FormRemoteInput<Input> =\n\tNormalizeFormEncoded<Input> extends RemoteFormInput ? NormalizeFormEncoded<Input> : never;\n\ntype FormStandardSchemaInput<S> =\n\tStandardSchemaInput<S> extends RemoteFormInput ? StandardSchemaInput<S> : RemoteFormInput;\n\ntype FormScalar = string | number | boolean | File;\n\ntype NormalizeFormEncoded<Value> = Value extends FormScalar\n\t? Value\n\t: Value extends ReadonlyArray<infer Item>\n\t\t? Array<NormalizeFormEncoded<Item>>\n\t\t: Value extends object\n\t\t\t? NormalizeFormObject<Value>\n\t\t\t: Value;\n\ntype NormalizeFormObject<Value> = {\n\treadonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\n\t\t? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\n\t\t: NormalizeFormEncoded<Value[Key]>;\n};\n\ntype OptionalFormKeys<Value> = {\n\t[Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key> ? Key : never;\n}[keyof Value];\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype AttachRemoteResource<Resource> = (resource: unknown, effect: Resource) => void;\n\ntype AttachFailedRemoteResource<Resource> = (error: unknown, effect: Resource) => void;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativePrerenderOptions<Input> = {\n\treadonly inputs?: (() => Promise<Input[]>) | undefined;\n\treadonly dynamic?: boolean | undefined;\n};\n\ntype CurrentRemoteRequestDetection =\n\t| {\n\t\t\treadonly _tag: \"CurrentRemoteRequest\";\n\t\t\treadonly event: {\n\t\t\t\treadonly isRemoteRequest?: boolean;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly _tag: \"NoCurrentRemoteRequest\";\n\t };\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nfunction to_effect_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemoteQuery<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_query_resource_methods,\n\t\tattach_failed_remote_query_resource,\n\t\tmode,\n\t) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_prerender<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemotePrerenderFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemotePrerender<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_remote_resource_getters,\n\t\tattach_failed_remote_resource_getters,\n\t) as unknown as EffectRemotePrerenderFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_command<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteCommand<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\treturn MakeServerCommandEffect<Input, Output, ErrorType>(native, input);\n\t}) as unknown as EffectRemoteCommand<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\nconst MakeServerCommandEffect = <Input, Output, ErrorType>(\n\tnative: NativeQueryLike<Input>,\n\tinput: Input,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = native(input);\n\n\t\t\tif (updates_args && has_command_updates(result)) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\n\t\treturn yield* MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => Promise.resolve(invocation) as Promise<Output>,\n\t\t);\n\t}) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nfunction has_command_updates(\n\tvalue: unknown,\n): value is { readonly updates: (...updates: unknown[]) => unknown } {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as { readonly updates?: unknown }).updates === \"function\"\n\t);\n}\n\nfunction to_effect_remote_resource<\n\tInput,\n\tOutput,\n\tErrorType,\n\tResource extends RemoteResourceEffect<Output, ErrorType>,\n>(\n\tnative: NativeQueryLike<Input>,\n\tattach_resource: AttachRemoteResource<Resource>,\n\tattach_failed_resource: AttachFailedRemoteResource<Resource>,\n\tmode: QueryAdapterMode = \"standard\",\n): (input: Input) => Resource {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst ResourceEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as Resource;\n\n\t\t\tattach_failed_resource(resource_attempt.failure, ResourceEffect);\n\n\t\t\treturn ResourceEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst started_result = mode === \"batch\" ? begin_batch_resource(resource) : undefined;\n\t\tconst ResourceEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => (started_result ?? Promise.resolve(resource)) as Promise<Output>,\n\t\t) as Resource;\n\n\t\tattach_native_remote_query_update(ResourceEffect, resource);\n\t\tattach_resource(resource, ResourceEffect);\n\n\t\treturn ResourceEffect;\n\t}) as unknown as (input: Input) => Resource;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_resource(resource: unknown): Promise<unknown> {\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\nfunction is_current_remote_request(): boolean {\n\tconst detection = detect_current_remote_request();\n\n\tif (detection._tag === \"NoCurrentRemoteRequest\") {\n\t\treturn false;\n\t}\n\n\tif (is_running_remote_effect_handler(detection.event)) {\n\t\treturn false;\n\t}\n\n\treturn detection.event.isRemoteRequest === true;\n}\n\nfunction detect_current_remote_request(): CurrentRemoteRequestDetection {\n\ttry {\n\t\tconst event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n\t\treturn {\n\t\t\t_tag: \"CurrentRemoteRequest\",\n\t\t\tevent,\n\t\t};\n\t} catch (error: unknown) {\n\t\tif (is_request_event_context_error(error)) {\n\t\t\treturn { _tag: \"NoCurrentRemoteRequest\" };\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction is_request_event_context_error(error: unknown): error is Error {\n\tif (!(error instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terror.message.startsWith(request_event_context_error_start) ||\n\t\terror.message === request_store_context_error\n\t);\n}\n\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tconst snapshot_encoder = get_remote_live_snapshot_encoder();\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tcreate_remote_transport_error,\n\t\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tcreate_remote_transport_error,\n\t\t\tsnapshot_encoder,\n\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as unknown as EffectRemoteLiveQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nfunction normalize_prerender_options<Input>(\n\toptions: PrerenderOptions<Input> | undefined,\n): NativePrerenderOptions<Input> | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tdynamic: options.dynamic,\n\t\tinputs: options.inputs ? make_prerender_inputs_wrapper(options.inputs) : undefined,\n\t};\n}\n\nfunction QueryRoot<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteQueryFunction<void, A, E>;\nfunction QueryRoot<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryRoot(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_query(\n\t\t\t\tnative_query(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\n\t\t\t\t) as ReturnType<typeof native_query>,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Query\") as never,\n\t\t\t) as ReturnType<typeof native_query>,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query\");\n\t}\n}\n\nfunction QueryBatch<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryBatch(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (!maybe_handler) {\n\t\t\tthrow new BatchQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query.batch(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query.batch\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t\t\"batch\",\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.batch\");\n\t}\n}\n\nfunction QueryLive<A, E = never, R = never>(\n\tvalidate_or_handler: RemoteLiveSource<A, E, R> | RemoteLiveHandler<void, A, E, R>,\n): EffectRemoteLiveQueryFunction<void, A, E>;\nfunction QueryLive<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteLiveHandler<Input, A, E, R>,\n): EffectRemoteLiveQueryFunction<Input, A, E>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryLive(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_live_query(\n\t\t\t\tnative_query.live(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\t\tmaybe_handler as RemoteLiveHandler,\n\t\t\t\t\t\t\"Query.live\",\n\t\t\t\t\t) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedLiveQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_live_query(\n\t\t\tnative_query.live(\n\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\tvalidate_or_handler as RemoteLiveHandler,\n\t\t\t\t\t\"Query.live\",\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.live\");\n\t}\n}\n\n/**\n * Factory for read-only remote query functions.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\n * );\n *\n * export const getUserBatch = Query.batch(Schema.String, (ids) =>\n * Effect.succeed((id) => ids.includes(id))\n * );\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(QueryRoot, {\n\tbatch: QueryBatch,\n\tlive: QueryLive,\n});\n\n/**\n * Creates a write-oriented remote command from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const RebuildCache = Command(() => Effect.succeed(\"done\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run on\n * the server when the command is invoked.\n * @returns A command function that yields an Effect when called.\n */\nexport function Command<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteCommand<void, A, E>;\n\n/**\n * Creates a write-oriented remote command with unchecked input.\n *\n * @example\n * ```ts\n * export const SaveDraft = Command(\"unchecked\", (input: { id: string }) =>\n * Effect.succeed(input.id)\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @returns A command function that yields an Effect when called with input.\n */\nexport function Command<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteCommand<Input, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const SaveUser = Command(Schema.Struct({ id: Schema.String }), ({ id }) =>\n * Effect.succeed({ id, saved: true })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema encoded type.\n */\nexport function Command<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const Toggle = Command(standard_schema, (input) =>\n * Effect.succeed(input.enabled)\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema input type.\n */\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\nexport function Command(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_command(\n\t\t\t\tnative_command(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedCommandHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_command(\n\t\t\tnative_command(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Command\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Command\");\n\t}\n}\n\n/**\n * Factory for a remote form handler.\n *\n * @example\n * ```ts\n * export const SignIn = Form(signInSchema, ({ data, invalid }) =>\n * Effect.gen(function* () {\n * if (!data.email.includes(\"@\")) {\n * return yield* invalid.email(\"Use an email address.\");\n * }\n *\n * return { email: data.email };\n * })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit form function.\n */\nexport function Form<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>,\n): EffectRemoteForm<void, A, E>;\nexport function Form<Input extends RemoteFormInput, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteFormHandler<Input, A, E, R>,\n): EffectRemoteForm<Input, A, E>;\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;\nexport function Form<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\nexport function Form(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn native_form(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_form_wrapper(maybe_handler as RemoteFormHandler, \"Form\") as never,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedFormHandlerMissingError();\n\t\t}\n\n\t\tconst inputless_handler: RemoteFormHandler<void, unknown> = ({ data, invalid, issue }) => {\n\t\t\tif (is_handler(validate_or_handler)) {\n\t\t\t\treturn validate_or_handler({ data, invalid, issue });\n\t\t\t}\n\n\t\t\treturn validate_or_handler as EffectLike;\n\t\t};\n\n\t\treturn native_form(\n\t\t\tmake_remote_form_wrapper(inputless_handler, \"Form\") as never,\n\t\t) as unknown as ReturnType<typeof native_form>;\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Form\");\n\t}\n}\n\n/**\n * Creates a prerenderable remote function from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run at\n * prerender time.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called.\n */\nexport function Prerender<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n\tmaybe_options?: PrerenderOptions<void>,\n): EffectRemotePrerenderFunction<void, A, E>;\n\n/**\n * Creates a prerenderable remote function with unchecked input.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * \"unchecked\",\n * (slug: string) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called with input.\n */\nexport function Prerender<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n\tmaybe_options?: PrerenderOptions<Input>,\n): EffectRemotePrerenderFunction<Input, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * Schema.String,\n * (slug) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema encoded type.\n */\nexport function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<SchemaEncodedInput<S>>,\n): EffectRemotePrerenderFunction<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * standard_schema,\n * (post) => Effect.succeed(post.slug),\n * { dynamic: true },\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema input type.\n */\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<StandardSchemaInput<S>>,\n): EffectRemotePrerenderFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n\tvalidate_or_handler: unknown,\n\tmaybe_handler_or_options?: unknown,\n\tmaybe_options?: PrerenderOptions<unknown>,\n\tnative_factory: typeof native_prerender = native_prerender,\n): unknown {\n\ttry {\n\t\tif (is_handler(maybe_handler_or_options)) {\n\t\t\treturn to_effect_prerender(\n\t\t\t\tnative_factory(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n\t\t\t\t\tnormalize_prerender_options(maybe_options) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedPrerenderHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_prerender(\n\t\t\tnative_factory(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Prerender\") as never,\n\t\t\t\tnormalize_prerender_options(\n\t\t\t\t\tmaybe_handler_or_options as PrerenderOptions<void> | undefined,\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Prerender\");\n\t}\n}\n","import { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { EffectHandler } from \"./types.ts\";\nimport { ToEffect } from \"./effects.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Adapts an Effect-producing callback to a native SvelteKit server handler.\n * SvelteKit continues to select the handler by its exported binding name, such\n * as `GET`, `PUT`, or `load`.\n *\n * @example A `+server.ts` request handler:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { RequestHandler } from \"./$types\";\n *\n * export const GET = Handler<RequestHandler>(function* ({ params }) {\n * const post = yield* Posts.get(params.slug);\n *\n * return Response.json(post);\n * });\n * ```\n *\n * @example A `+page.server.ts` load function:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { PageServerLoad } from \"./$types\";\n *\n * export const load = Handler<PageServerLoad>(function* ({ locals }) {\n * const profile = yield* Profiles.get(locals.user.id);\n *\n * return { profile };\n * });\n * ```\n *\n * @since 4.0.0\n * @param handler - Effect-producing callback whose parameters and successful\n * result match the native SvelteKit handler type.\n * @returns A native handler that runs the callback through the configured\n * {@link ServerRuntime} with the current {@link RequestEvent} available.\n */\nexport function Handler<NativeHandler extends (...arguments_: never[]) => unknown>(\n\thandler: EffectHandler<NativeHandler>,\n): NativeHandler {\n\tconst native_handler = async (...arguments_: Parameters<NativeHandler>) => {\n\t\tconst event = get_native_request_event();\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst HandlerEffect = Effect.suspend(() => ToEffect(handler(...arguments_)));\n\t\tconst HandlerOwnedEffect = RunInsideRemoteEffectHandler(event, HandlerEffect);\n\t\tconst EffectWithRequestEvent = Effect.provideService(\n\t\t\tHandlerOwnedEffect,\n\t\t\tRequestEvent,\n\t\t\tevent,\n\t\t);\n\n\t\treturn await runtime.runPromise(EffectWithRequestEvent, {\n\t\t\tsignal: event.request.signal,\n\t\t});\n\t};\n\n\treturn native_handler as unknown as NativeHandler;\n}\n","import { error as svelte_error, redirect as svelte_redirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n\tProxyAuthenticationRequired: 407,\n\tRequestHeaderFieldsTooLarge: 431,\n\tUnavailableForLegalReasons: 451,\n\tNetworkAuthenticationRequired: 511,\n\tHttpVersionNotSupported: 505,\n\tUnprocessableContent: 422,\n\tUnprocessableEntity: 422,\n\tInternalServerError: 500,\n\tFailedDependency: 424,\n\tPreconditionRequired: 428,\n\tServiceUnavailable: 503,\n\tMisdirectedRequest: 421,\n\tInsufficientStorage: 507,\n\tVariantAlsoNegotiates: 506,\n\tPreconditionFailed: 412,\n\tMethodNotAllowed: 405,\n\tGatewayTimeout: 504,\n\tPaymentRequired: 402,\n\tUpgradeRequired: 426,\n\tTooManyRequests: 429,\n\tLengthRequired: 411,\n\tNotAcceptable: 406,\n\tRequestTimeout: 408,\n\tContentTooLarge: 413,\n\tPayloadTooLarge: 413,\n\tUriTooLong: 414,\n\tUnsupportedMediaType: 415,\n\tRangeNotSatisfiable: 416,\n\tExpectationFailed: 417,\n\tImATeapot: 418,\n\tBadRequest: 400,\n\tUnauthorized: 401,\n\tForbidden: 403,\n\tNotFound: 404,\n\tConflict: 409,\n\tGone: 410,\n\tLocked: 423,\n\tTooEarly: 425,\n\tNotImplemented: 501,\n\tBadGateway: 502,\n\tLoopDetected: 508,\n\tNotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n\tMovedPermanently: 301,\n\tTemporaryRedirect: 307,\n\tPermanentRedirect: 308,\n\tMultipleChoices: 300,\n\tNotModified: 304,\n\tSwitchProxy: 306,\n\tSeeOther: 303,\n\tUseProxy: 305,\n\tFound: 302,\n} as const;\n\ntype AppErrorStatus = App.Error extends { readonly status?: infer Status } ? Status : number;\n\n/**\n * Compatibility shim while SER supports both SvelteKit 2 and 3. The wrappers\n * call the SvelteKit 3 control-flow shapes, while SvelteKit 2 ignores extra\n * runtime arguments. Drop these broad call signatures when Kit 2 support is\n * removed.\n */\ntype SvelteError = (status: number, body?: ErrorBody, properties?: ErrorProperties) => never;\n\ntype SvelteRedirect = (status: number, location: string | URL, options?: RedirectOptions) => never;\n\n/**\n * Named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatusName = \"NotFound\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatusName = keyof typeof error_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatus = \"InternalServerError\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatus = ErrorStatusName | number;\n\n/**\n * Error body accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const body: ErrorBody = { message: \"Post not found\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorBody =\n\t| (Omit<App.Error, \"status\"> & { readonly status?: AppErrorStatus })\n\t| string\n\t| undefined;\n\n/**\n * Extra SvelteKit app error properties accepted by the {@link Error} helper\n * when using the SvelteKit 3 string-body overload.\n *\n * @example\n * ```ts\n * const properties: ErrorProperties = { code: \"POST_NOT_FOUND\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorProperties = Omit<App.Error, \"status\" | \"message\">;\n\n/**\n * Named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatusName = \"TemporaryRedirect\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatusName = keyof typeof redirect_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatus = \"SeeOther\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatus = RedirectStatusName | number;\n\n/**\n * Options accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const options: RedirectOptions = { external: true };\n * ```\n *\n * @since 3.4.3\n */\nexport type RedirectOptions = {\n\treadonly external?: boolean | string[];\n};\n\n/**\n * Callable shape for the exported {@link Error} helper.\n *\n * @example\n * ```ts\n * const fail_not_found: ErrorEffectFactory = Error;\n * ```\n *\n * @since 2.3.0\n */\nexport interface ErrorEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Optional SvelteKit error body or message forwarded unchanged\n\t * to SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(status: ErrorStatus, body?: ErrorBody): Effect.Effect<never, never, never>;\n\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value\n\t * using the SvelteKit 3 string-body overload with extra properties.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\", {\n\t * code: \"POST_NOT_FOUND\",\n\t * });\n\t * ```\n\t *\n\t * @since 3.4.3\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Error message forwarded to SvelteKit.\n\t * @param properties - Additional app error properties forwarded to\n\t * SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: ErrorStatus,\n\t\tbody: string,\n\t\tproperties: ErrorProperties,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Callable shape for the exported {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const redirect_after_save: RedirectEffectFactory = Redirect;\n * ```\n *\n * @since 2.3.0\n */\nexport interface RedirectEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's redirect control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Redirect(\"SeeOther\", \"/posts\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric redirect status or PascalCase status name to pass\n\t * to SvelteKit's `redirect` helper.\n\t * @param location - Target URL forwarded unchanged to SvelteKit.\n\t * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n\t * `{ external: true }` or an allowlist to redirect to external URLs.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: RedirectStatus,\n\t\tlocation: string | URL,\n\t\toptions?: RedirectOptions,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Creates an Effect that raises SvelteKit's HTTP error control flow.\n *\n * @example\n * ```ts\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric HTTP status or PascalCase status name to pass to\n * SvelteKit's `error` helper.\n * @param body - Optional SvelteKit error body or message forwarded unchanged\n * to SvelteKit.\n * @param properties - Optional SvelteKit 3 app error properties forwarded when\n * using a string error message.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = ((\n\tstatus: ErrorStatus,\n\tbody?: ErrorBody,\n\tproperties?: ErrorProperties,\n) => {\n\tconst resolved_status = resolve_error_status(status);\n\tconst error = svelte_error as SvelteError;\n\n\treturn Effect.sync((): never => {\n\t\tif (properties === undefined) {\n\t\t\treturn error(resolved_status, body);\n\t\t}\n\n\t\treturn error(resolved_status, body, properties);\n\t});\n}) as ErrorEffectFactory;\n\n/**\n * Creates an Effect that raises SvelteKit's redirect control flow.\n *\n * @example\n * ```ts\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric redirect status or PascalCase status name to pass to\n * SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n * `{ external: true }` or an allowlist to redirect to external URLs.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = ((\n\tstatus: RedirectStatus,\n\tlocation: string | URL,\n\toptions?: RedirectOptions,\n) => {\n\tconst resolved_status = resolve_redirect_status(status);\n\tconst redirect = svelte_redirect as SvelteRedirect;\n\n\treturn Effect.sync((): never => redirect(resolved_status, location, options));\n}) as RedirectEffectFactory;\n\nfunction resolve_error_status(status: ErrorStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,+CAA+B,IAAI,QAAwB;;AAGjE,SAAgB,iCAAiC,OAAyB;CACzE,MAAM,gBAAgB,SAAS,0BAA0B;CAEzD,IAAI,CAAC,eACJ,OAAO;CAGR,QAAQ,6BAA6B,IAAI,aAAa,KAAK,KAAK;AACjE;;AAGA,MAAa,gCACZ,OACA,WAEA,OAAO,kBACN,8BAA8B,KAAK,SAC7B,cACA,8BAA8B,KAAK,CAC1C;AAED,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,eAAe,6BAA6B,IAAI,KAAK,KAAK;CAEhE,6BAA6B,IAAI,OAAO,eAAe,CAAC;AACzD,CAAC;AAEF,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,mBAAmB,6BAA6B,IAAI,KAA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,MAAM,kBAAkB,wBAAwB,MAAM;CACtD,MAAME,aAAWC;CAEjB,OAAO,OAAO,WAAkBD,WAAS,iBAAiB,UAAU,OAAO,CAAC;AAC7E;AAEA,SAAS,qBAAqB,QAA6B;CAC1D,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,mBAAmB;AAC3B;AAEA,SAAS,wBAAwB,QAAgC;CAChE,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,sBAAsB;AAC9B"}
|
|
1
|
+
{"version":3,"file":"server.js","names":["get_native_request_event","svelte_invalid","get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender","get_native_request_event","Error","error","svelte_error","redirect","svelte_redirect"],"sources":["../../modules/svelte-effect-runtime/src/server/remote-handler-context.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/live-snapshot.ts","../../modules/svelte-effect-runtime/src/server/transport.ts","../../modules/svelte-effect-runtime/src/server/factories.ts","../../modules/svelte-effect-runtime/src/server/handler.ts","../../modules/svelte-effect-runtime/src/server/control-flow.ts"],"sourcesContent":["import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { Effect } from \"effect\";\n\nconst active_remote_handler_counts = new WeakMap<object, number>();\n\n/** Tracks ownership per request event so concurrent requests remain isolated. */\nexport function is_running_remote_effect_handler(event?: object): boolean {\n\tconst request_event = event ?? get_current_request_event();\n\n\tif (!request_event) {\n\t\treturn false;\n\t}\n\n\treturn (active_remote_handler_counts.get(request_event) ?? 0) > 0;\n}\n\n/** Marks one request as handler-owned for the lifetime of the supplied Effect. */\nexport const RunInsideRemoteEffectHandler = <A, E, R>(\n\tevent: object,\n\teffect: Effect.Effect<A, E, R>,\n) =>\n\tEffect.acquireUseRelease(\n\t\tAcquireRemoteHandlerOwnership(event),\n\t\t() => effect,\n\t\t() => ReleaseRemoteHandlerOwnership(event),\n\t);\n\nconst AcquireRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst active_count = active_remote_handler_counts.get(event) ?? 0;\n\n\t\tactive_remote_handler_counts.set(event, active_count + 1);\n\t});\n\nconst ReleaseRemoteHandlerOwnership = (event: object) =>\n\tEffect.sync(() => {\n\t\tconst remaining_count = (active_remote_handler_counts.get(event) ?? 1) - 1;\n\n\t\tif (remaining_count === 0) {\n\t\t\tactive_remote_handler_counts.delete(event);\n\n\t\t\treturn;\n\t\t}\n\n\t\tactive_remote_handler_counts.set(event, remaining_count);\n\t});\n\nfunction get_current_request_event(): object | undefined {\n\ttry {\n\t\tconst event = get_native_request_event();\n\n\t\treturn typeof event === \"object\" && event !== null ? event : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n","import { error as svelte_error, invalid as svelte_invalid } from \"@sveltejs/kit\";\nimport {\n\trun_remote_effect,\n\tthrow_remote_cause,\n\tto_remote_failure_context,\n} from \"$/remote/server.ts\";\nimport { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport { InvalidLiveQueryReturnError } from \"$/errors.ts\";\nimport { Effect, Stream } from \"effect\";\nimport type { EffectLike } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> = AsyncIterable<A>;\n\ntype LiveHandlerResult<A> = Stream.Stream<A, unknown, unknown>;\n\ntype LiveHandler<A> = () => LiveHandlerResult<A>;\n\nexport function is_generator_result<A>(\n\tvalue: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n\treturn (\n\t\ttypeof value === \"object\" &&\n\t\tvalue !== null &&\n\t\ttypeof (value as { next?: unknown }).next === \"function\"\n\t);\n}\n\nexport function ToEffect<A, E, R>(value: EffectLike<A, E, R>): Effect.Effect<A, E, R> {\n\tif (is_generator_result<A>(value)) {\n\t\treturn Effect.gen(() => value) as Effect.Effect<A, E, R>;\n\t}\n\n\treturn value;\n}\n\nexport function is_live_source<A>(value: unknown): value is Stream.Stream<A, unknown, unknown> {\n\treturn Stream.isStream(value);\n}\n\nexport function run_live_handler_source<A>(\n\tvalue: LiveHandlerResult<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tif (!is_live_source(value)) {\n\t\tthrow new InvalidLiveQueryReturnError();\n\t}\n\n\treturn run_live_source_effect(ToLiveSourceEffect(value, event), event);\n}\n\n/** Runs a live handler inside the request-local ownership scope. */\nexport function run_live_handler<A>(\n\thandler: LiveHandler<A>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst LiveSourceEffect = Effect.suspend(() => {\n\t\tconst value = handler();\n\n\t\tif (!is_live_source(value)) {\n\t\t\treturn Effect.die(new InvalidLiveQueryReturnError());\n\t\t}\n\n\t\treturn ToLiveSourceEffect(value, event);\n\t});\n\n\treturn run_live_source_effect(RunInsideRemoteEffectHandler(event, LiveSourceEffect), event);\n}\n\nfunction run_live_source_effect<A>(\n\teffect: Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\teffect,\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst ToLiveSourceEffect = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tStream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(\n\t\tEffect.map((source) => wrap_live_source_errors(source, event)),\n\t) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\nconst preserve_live_source_cause = <A>(value: LiveHandlerResult<A>, event: RequestEventShape) =>\n\tvalue.pipe(\n\t\tStream.catchCause((cause) =>\n\t\t\tStream.fromEffect(\n\t\t\t\tEffect.sync(() =>\n\t\t\t\t\tthrow_remote_cause(cause, svelte_invalid, svelte_remote_error, () =>\n\t\t\t\t\t\tto_remote_failure_context(event),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t),\n\t\t),\n\t);\n\nfunction wrap_live_source_errors<A>(\n\tsource: AsyncIterable<A>,\n\tevent: RequestEventShape,\n): AsyncIterable<A> {\n\treturn {\n\t\t[Symbol.asyncIterator]() {\n\t\t\tconst iterator = source[Symbol.asyncIterator]();\n\t\t\tconst throw_iterator = iterator.throw?.bind(iterator);\n\n\t\t\treturn {\n\t\t\t\tnext() {\n\t\t\t\t\treturn RunLiveIteratorCall(event, () => iterator.next());\n\t\t\t\t},\n\n\t\t\t\treturn(value?: unknown) {\n\t\t\t\t\tif (iterator.return) {\n\t\t\t\t\t\treturn RunLiveIteratorCall(\n\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t() => iterator.return?.(value) as PromiseLike<IteratorResult<A>>,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\n\t\t\t\t\treturn Promise.resolve({\n\t\t\t\t\t\tdone: true,\n\t\t\t\t\t\tvalue: undefined as A,\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t...(throw_iterator === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: {\n\t\t\t\t\t\t\tthrow(error?: unknown) {\n\t\t\t\t\t\t\t\treturn RunLiveIteratorCall(event, () => throw_iterator(error));\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}),\n\t\t\t};\n\t\t},\n\t};\n}\n\nfunction RunLiveIteratorCall<A>(event: RequestEventShape, run: () => PromiseLike<A>): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst IteratorEffect = Effect.tryPromise({\n\t\ttry: run,\n\t\tcatch: (error: unknown) => error,\n\t});\n\n\treturn runtime.runPromise(\n\t\tRunInsideRemoteEffectHandler(event, IteratorEffect) as Effect.Effect<A, unknown, unknown>,\n\t);\n}\n\nexport function run_handler_effect<A>(\n\tvalue: EffectLike<A, unknown, unknown>,\n\tevent: RequestEventShape,\n): Promise<A> {\n\tconst runtime = get_server_runtime_or_throw();\n\tconst EffectWithRequestEvent = Effect.provideService(\n\t\tRunInsideRemoteEffectHandler(event, ToEffect(value)),\n\t\tRequestEvent,\n\t\tevent,\n\t) as Effect.Effect<A, unknown, unknown>;\n\n\treturn run_remote_effect(\n\t\tEffectWithRequestEvent,\n\t\truntime,\n\t\tsvelte_invalid,\n\t\tsvelte_remote_error,\n\t\t() => to_remote_failure_context(event),\n\t);\n}\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n\tsvelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport type { FormInvalid } from \"./types.ts\";\nimport { Effect } from \"effect\";\n\nexport function make_invalid_proxy<Input = unknown>(\n\tpath: readonly (string | number)[] = [],\n): FormInvalid<Input> {\n\tconst invalid_at_path = (message: string) =>\n\t\tEffect.fail(create_form_error([{ message, path: [...path] } satisfies FormIssue]));\n\n\treturn new Proxy(invalid_at_path, {\n\t\tget(_target, property) {\n\t\t\tif (typeof property === \"symbol\") {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tconst segment = path.length === 0 ? property : normalize_nested_path_segment(property);\n\n\t\t\treturn make_invalid_proxy([...path, segment]);\n\t\t},\n\t}) as FormInvalid<Input>;\n}\n\nfunction normalize_nested_path_segment(property: string): string | number {\n\tconst is_array_index = /^(0|[1-9]\\d*)$/.test(property);\n\n\treturn is_array_index ? Number(property) : property;\n}\n","import type { RemoteHandler } from \"./types.ts\";\n\nexport {\n\tis_effect_schema,\n\tis_standard_schema,\n\tnormalize_validator,\n\ttype StandardSchema,\n} from \"$/internal/schema.ts\";\n\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n\treturn value === \"unchecked\";\n}\n\nexport function is_handler(\n\tvalue: unknown,\n): value is RemoteHandler<unknown, unknown, unknown, unknown> {\n\treturn typeof value === \"function\";\n}\n","import type {\n\tEffectLike,\n\tPrerenderInputs,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n} from \"./types.ts\";\nimport { run_handler_effect, run_live_handler, ToEffect } from \"./effects.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { get_server_runtime_or_throw } from \"./runtime.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport { Effect } from \"effect\";\n\nexport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\n\nexport function make_prerender_inputs_wrapper<Input>(\n\tgenerate_inputs: PrerenderInputs<Input>,\n): () => Promise<Input[]> {\n\treturn () => {\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst CollectInputs = Effect.gen(function* () {\n\t\t\tconst inputs = yield* Effect.suspend(() => ToEffect(generate_inputs()));\n\n\t\t\treturn Array.from(inputs);\n\t\t});\n\n\t\treturn runtime.runPromise(CollectInputs);\n\t};\n}\n\nexport function make_remote_wrapper(\n\thandler: RemoteHandler<unknown, unknown, unknown, unknown> | EffectLike,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst result = is_handler(handler) ? handler(input) : handler;\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n\nexport function make_remote_live_wrapper<Input, A>(\n\thandler: RemoteLiveSource<A, unknown, unknown> | RemoteLiveHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (input: unknown) => Promise<unknown> {\n\treturn async (input: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\treturn await run_live_handler(\n\t\t\t() => (typeof handler === \"function\" ? handler(input as Input) : handler),\n\t\t\tevent,\n\t\t);\n\t};\n}\n\nexport function make_remote_form_wrapper<Input, A>(\n\thandler: RemoteFormHandler<Input, A, unknown, unknown>,\n\thelper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n\treturn async (data: unknown, issue: unknown) => {\n\t\tlet event: RequestEvent;\n\n\t\ttry {\n\t\t\tevent = get_native_request_event() as unknown as RequestEvent;\n\t\t} catch (error: unknown) {\n\t\t\tthrow normalize_remote_helper_error(error, helper_name);\n\t\t}\n\n\t\tconst HandlerEffect = Effect.suspend(() => {\n\t\t\tconst invalid_proxy = make_invalid_proxy<Input>();\n\t\t\tconst result = handler({\n\t\t\t\tdata: data as Input,\n\t\t\t\tinvalid: invalid_proxy,\n\t\t\t\tissue,\n\t\t\t});\n\n\t\t\treturn ToEffect(result);\n\t\t});\n\n\t\treturn await run_handler_effect(HandlerEffect, event);\n\t};\n}\n","import { stringify } from \"devalue\";\n\nexport type NativeTransport = Readonly<\n\tRecord<\n\t\tstring,\n\t\t{\n\t\t\treadonly encode: (value: unknown) => false | unknown;\n\t\t}\n\t>\n>;\n\n/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */\nexport function make_remote_live_snapshot_encoder(\n\ttransport: NativeTransport,\n): (value: unknown) => string {\n\tconst encoders = Object.fromEntries(\n\t\tObject.entries(transport).map(([key, transformer]) => [key, transformer.encode]),\n\t);\n\n\treturn (value) => stringify(value, encoders);\n}\n","import { make_remote_live_snapshot_encoder, type NativeTransport } from \"./live-snapshot.ts\";\n\nimport * as SvelteKitInternalServer from \"@sveltejs/kit/internal/server\";\n\ntype NativeRequestStore = {\n\treadonly state: {\n\t\treadonly transport: NativeTransport;\n\t};\n};\n\ntype NativeServerInternals = {\n\treadonly try_get_request_store?: () => NativeRequestStore | null;\n};\n\n/** Creates the current SvelteKit request's transport-aware live snapshot encoder. */\nexport function get_remote_live_snapshot_encoder(): ((value: unknown) => string) | undefined {\n\tconst try_get_request_store = (SvelteKitInternalServer as unknown as NativeServerInternals)\n\t\t.try_get_request_store;\n\tconst request_store = try_get_request_store?.();\n\n\tif (!request_store) {\n\t\treturn undefined;\n\t}\n\n\treturn make_remote_live_snapshot_encoder(request_store.state.transport);\n}\n","import type {\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tPrerenderOptions,\n\tQueryFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"./types.ts\";\nimport {\n\tBatchQueryHandlerMissingError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n} from \"$/errors.ts\";\nimport {\n\tattach_failed_remote_query_resource,\n\tattach_failed_remote_resource_getters,\n\tattach_remote_resource_getters,\n\tis_remote_resource,\n\ttype NativeRemoteResource,\n\ttype RemoteResourceEffect,\n} from \"$/remote/resource.ts\";\nimport {\n\tcommand as native_command,\n\tform as native_form,\n\tgetRequestEvent as get_native_request_event,\n\tprerender as native_prerender,\n\tquery as native_query,\n} from \"$app/server\";\nimport {\n\tmake_prerender_inputs_wrapper,\n\tmake_remote_form_wrapper,\n\tmake_remote_live_wrapper,\n\tmake_remote_wrapper,\n} from \"./wrappers.ts\";\nimport { FailWithRemoteError, MakeEffectFromPromise, MakeEffectFromSync } from \"$/remote/effect.ts\";\nimport {\n\tattach_native_remote_query_update,\n\tresolve_native_remote_query_updates,\n} from \"$/remote/query-update.ts\";\nimport { make_failed_remote_live_stream, make_remote_live_stream } from \"$/live.ts\";\nimport { is_running_remote_effect_handler } from \"./remote-handler-context.ts\";\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport { create_remote_transport_error } from \"$/remote/shared.ts\";\nimport { get_remote_live_snapshot_encoder } from \"./transport.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, Result, type Schema } from \"effect\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S[\"Encoded\"]> : never;\n\ntype FormRemoteInput<Input> =\n\tNormalizeFormEncoded<Input> extends RemoteFormInput ? NormalizeFormEncoded<Input> : never;\n\ntype FormStandardSchemaInput<S> =\n\tStandardSchemaInput<S> extends RemoteFormInput ? StandardSchemaInput<S> : RemoteFormInput;\n\ntype FormScalar = string | number | boolean | File;\n\ntype NormalizeFormEncoded<Value> = Value extends FormScalar\n\t? Value\n\t: Value extends ReadonlyArray<infer Item>\n\t\t? Array<NormalizeFormEncoded<Item>>\n\t\t: Value extends object\n\t\t\t? NormalizeFormObject<Value>\n\t\t\t: Value;\n\ntype NormalizeFormObject<Value> = {\n\treadonly [Key in keyof Value]: Key extends OptionalFormKeys<Value>\n\t\t? NormalizeFormEncoded<Exclude<Value[Key], undefined>>\n\t\t: NormalizeFormEncoded<Value[Key]>;\n};\n\ntype OptionalFormKeys<Value> = {\n\t[Key in keyof Value]-?: Record<PropertyKey, never> extends Pick<Value, Key> ? Key : never;\n}[keyof Value];\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype AttachRemoteResource<Resource> = (resource: unknown, effect: Resource) => void;\n\ntype AttachFailedRemoteResource<Resource> = (error: unknown, effect: Resource) => void;\n\ntype QueryAdapterMode = \"standard\" | \"batch\";\n\ntype NativePrerenderOptions<Input> = {\n\treadonly inputs?: (() => Promise<Input[]>) | undefined;\n\treadonly dynamic?: boolean | undefined;\n};\n\ntype CurrentRemoteRequestDetection =\n\t| {\n\t\t\treadonly _tag: \"CurrentRemoteRequest\";\n\t\t\treadonly event: {\n\t\t\t\treadonly isRemoteRequest?: boolean;\n\t\t\t};\n\t }\n\t| {\n\t\t\treadonly _tag: \"NoCurrentRemoteRequest\";\n\t };\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nfunction to_effect_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n\tmode: QueryAdapterMode = \"standard\",\n): EffectRemoteQueryFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemoteQuery<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_query_resource_methods,\n\t\tattach_failed_remote_query_resource,\n\t\tmode,\n\t) as unknown as EffectRemoteQueryFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_prerender<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemotePrerenderFunction<Input, Output, ErrorType> {\n\treturn to_effect_remote_resource<\n\t\tInput,\n\t\tOutput,\n\t\tErrorType,\n\t\tEffectRemotePrerender<Output, ErrorType>\n\t>(\n\t\tnative,\n\t\tattach_remote_resource_getters,\n\t\tattach_failed_remote_resource_getters,\n\t) as unknown as EffectRemotePrerenderFunction<Input, Output, ErrorType>;\n}\n\nfunction to_effect_command<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteCommand<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\treturn MakeServerCommandEffect<Input, Output, ErrorType>(native, input);\n\t}) as unknown as EffectRemoteCommand<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\n\treturn wrapped;\n}\n\nconst MakeServerCommandEffect = <Input, Output, ErrorType>(\n\tnative: NativeQueryLike<Input>,\n\tinput: Input,\n) => {\n\tlet updates_args: unknown[] | undefined;\n\n\tconst CommandEffect = Effect.gen(function* () {\n\t\tconst invocation = yield* MakeEffectFromSync<unknown, ErrorType>(() => {\n\t\t\tconst result = native(input);\n\n\t\t\tif (updates_args && has_command_updates(result)) {\n\t\t\t\treturn result.updates(...resolve_native_remote_query_updates(updates_args));\n\t\t\t}\n\n\t\t\treturn result;\n\t\t});\n\n\t\treturn yield* MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => Promise.resolve(invocation) as Promise<Output>,\n\t\t);\n\t}) as EffectRemoteCommandCall<Output, ErrorType>;\n\n\tObject.defineProperty(CommandEffect, \"updates\", {\n\t\tconfigurable: true,\n\t\tenumerable: false,\n\t\tvalue: (...args: unknown[]) => {\n\t\t\tupdates_args ??= args;\n\n\t\t\treturn CommandEffect;\n\t\t},\n\t});\n\n\treturn CommandEffect;\n};\n\nfunction has_command_updates(\n\tvalue: unknown,\n): value is { readonly updates: (...updates: unknown[]) => unknown } {\n\tconst value_type = typeof value;\n\n\treturn (\n\t\t((value_type === \"object\" && value !== null) || value_type === \"function\") &&\n\t\ttypeof (value as { readonly updates?: unknown }).updates === \"function\"\n\t);\n}\n\nfunction to_effect_remote_resource<\n\tInput,\n\tOutput,\n\tErrorType,\n\tResource extends RemoteResourceEffect<Output, ErrorType>,\n>(\n\tnative: NativeQueryLike<Input>,\n\tattach_resource: AttachRemoteResource<Resource>,\n\tattach_failed_resource: AttachFailedRemoteResource<Resource>,\n\tmode: QueryAdapterMode = \"standard\",\n): (input: Input) => Resource {\n\tconst wrapped = ((input: Input) => {\n\t\tif (is_current_remote_request()) {\n\t\t\treturn native(input);\n\t\t}\n\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\tconst ResourceEffect = FailWithRemoteError<ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t) as unknown as Resource;\n\n\t\t\tattach_failed_resource(resource_attempt.failure, ResourceEffect);\n\n\t\t\treturn ResourceEffect;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\t\tconst started_result = mode === \"batch\" ? begin_batch_resource(resource) : undefined;\n\t\tconst ResourceEffect = MakeEffectFromPromise<Output, ErrorType>(\n\t\t\t() => (started_result ?? Promise.resolve(resource)) as Promise<Output>,\n\t\t) as Resource;\n\n\t\tattach_native_remote_query_update(ResourceEffect, resource);\n\t\tattach_resource(resource, ResourceEffect);\n\n\t\treturn ResourceEffect;\n\t}) as unknown as (input: Input) => Resource;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\nfunction begin_batch_resource(resource: unknown): Promise<unknown> {\n\tconst result = Promise.resolve(resource);\n\n\tvoid result.catch(() => {});\n\n\treturn result;\n}\n\nfunction is_current_remote_request(): boolean {\n\tconst detection = detect_current_remote_request();\n\n\tif (detection._tag === \"NoCurrentRemoteRequest\") {\n\t\treturn false;\n\t}\n\n\tif (is_running_remote_effect_handler(detection.event)) {\n\t\treturn false;\n\t}\n\n\treturn detection.event.isRemoteRequest === true;\n}\n\nfunction detect_current_remote_request(): CurrentRemoteRequestDetection {\n\ttry {\n\t\tconst event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n\t\treturn {\n\t\t\t_tag: \"CurrentRemoteRequest\",\n\t\t\tevent,\n\t\t};\n\t} catch (error: unknown) {\n\t\tif (is_request_event_context_error(error)) {\n\t\t\treturn { _tag: \"NoCurrentRemoteRequest\" };\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\nfunction is_request_event_context_error(error: unknown): error is Error {\n\tif (!(error instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terror.message.startsWith(request_event_context_error_start) ||\n\t\terror.message === request_store_context_error\n\t);\n}\n\nfunction to_effect_live_query<Input, Output, ErrorType = never>(\n\tnative: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output, ErrorType> {\n\tconst wrapped = ((input: Input) => {\n\t\tconst snapshot_encoder = get_remote_live_snapshot_encoder();\n\t\tconst resource_attempt = Result.try(() => native(input));\n\n\t\tif (Result.isFailure(resource_attempt)) {\n\t\t\treturn make_failed_remote_live_stream<Output, ErrorType>(\n\t\t\t\tresource_attempt.failure,\n\t\t\t\tcreate_remote_transport_error,\n\t\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\t\t}\n\n\t\tconst resource = resource_attempt.success;\n\n\t\tconst stream = make_remote_live_stream<Output, ErrorType>(\n\t\t\tresource,\n\t\t\tcreate_remote_transport_error,\n\t\t\tsnapshot_encoder,\n\t\t) as EffectRemoteLiveQuery<Output, ErrorType>;\n\n\t\tattach_native_remote_query_update(stream, resource);\n\n\t\treturn stream;\n\t}) as unknown as EffectRemoteLiveQueryFunction<Input, Output, ErrorType>;\n\n\tcopy_property_descriptors(native, wrapped);\n\tattach_native_remote_query_update(wrapped, native);\n\n\treturn wrapped;\n}\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n\treadonly refresh?: () => Promise<void>;\n\treadonly set?: (value: Output) => void;\n\treadonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\nfunction attach_query_resource_methods<Output, ErrorType = never>(\n\tresource: unknown,\n\teffect: EffectRemoteQuery<Output, ErrorType>,\n): void {\n\tconst methods = is_remote_resource<Output>(resource)\n\t\t? (resource as NativeQueryResource<Output>)\n\t\t: undefined;\n\tconst refresh = methods?.refresh;\n\tconst set = methods?.set;\n\tconst with_override = methods?.withOverride;\n\n\tattach_remote_resource_getters(resource, effect);\n\n\tif (!methods) {\n\t\treturn;\n\t}\n\n\tif (typeof refresh === \"function\") {\n\t\tObject.defineProperty(effect, \"refresh\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: () => MakeEffectFromPromise(() => Promise.resolve(refresh.call(resource))),\n\t\t});\n\t}\n\n\tif (typeof set === \"function\") {\n\t\tObject.defineProperty(effect, \"set\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (value: Output) => set.call(resource, value),\n\t\t});\n\t}\n\n\tif (typeof with_override === \"function\") {\n\t\tObject.defineProperty(effect, \"withOverride\", {\n\t\t\tconfigurable: true,\n\t\t\tvalue: (update: (current: Output) => Output) => with_override.call(resource, update),\n\t\t});\n\t}\n}\n\nfunction normalize_prerender_options<Input>(\n\toptions: PrerenderOptions<Input> | undefined,\n): NativePrerenderOptions<Input> | undefined {\n\tif (!options) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tdynamic: options.dynamic,\n\t\tinputs: options.inputs ? make_prerender_inputs_wrapper(options.inputs) : undefined,\n\t};\n}\n\nfunction QueryRoot<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteQueryFunction<void, A, E>;\nfunction QueryRoot<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryRoot<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryRoot(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_query(\n\t\t\t\tnative_query(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query\") as never,\n\t\t\t\t) as ReturnType<typeof native_query>,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Query\") as never,\n\t\t\t) as ReturnType<typeof native_query>,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query\");\n\t}\n}\n\nfunction QueryBatch<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: EffectRemoteBatchHandler<Input, A, E, R>,\n): EffectRemoteQueryFunction<Input, A, E>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryBatch<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: EffectRemoteBatchHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryBatch(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (!maybe_handler) {\n\t\t\tthrow new BatchQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_query(\n\t\t\tnative_query.batch(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Query.batch\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t\t\"batch\",\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.batch\");\n\t}\n}\n\nfunction QueryLive<A, E = never, R = never>(\n\tvalidate_or_handler: RemoteLiveSource<A, E, R> | RemoteLiveHandler<void, A, E, R>,\n): EffectRemoteLiveQueryFunction<void, A, E>;\nfunction QueryLive<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteLiveHandler<Input, A, E, R>,\n): EffectRemoteLiveQueryFunction<Input, A, E>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<SchemaEncodedInput<S>, A, E>;\nfunction QueryLive<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteLiveHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteLiveQueryFunction<StandardSchemaInput<S>, A, E>;\nfunction QueryLive(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_live_query(\n\t\t\t\tnative_query.live(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\t\tmaybe_handler as RemoteLiveHandler,\n\t\t\t\t\t\t\"Query.live\",\n\t\t\t\t\t) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedLiveQueryHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_live_query(\n\t\t\tnative_query.live(\n\t\t\t\tmake_remote_live_wrapper(\n\t\t\t\t\tvalidate_or_handler as RemoteLiveHandler,\n\t\t\t\t\t\"Query.live\",\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Query.live\");\n\t}\n}\n\n/**\n * Factory for read-only remote query functions.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\n * );\n *\n * export const getUserBatch = Query.batch(Schema.String, (ids) =>\n * Effect.succeed((id) => ids.includes(id))\n * );\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(QueryRoot, {\n\tbatch: QueryBatch,\n\tlive: QueryLive,\n});\n\n/**\n * Creates a write-oriented remote command from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const RebuildCache = Command(() => Effect.succeed(\"done\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run on\n * the server when the command is invoked.\n * @returns A command function that yields an Effect when called.\n */\nexport function Command<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n): EffectRemoteCommand<void, A, E>;\n\n/**\n * Creates a write-oriented remote command with unchecked input.\n *\n * @example\n * ```ts\n * export const SaveDraft = Command(\"unchecked\", (input: { id: string }) =>\n * Effect.succeed(input.id)\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @returns A command function that yields an Effect when called with input.\n */\nexport function Command<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n): EffectRemoteCommand<Input, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const SaveUser = Command(Schema.Struct({ id: Schema.String }), ({ id }) =>\n * Effect.succeed({ id, saved: true })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema encoded type.\n */\nexport function Command<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteCommand<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a write-oriented remote command validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const Toggle = Command(standard_schema, (input) =>\n * Effect.succeed(input.enabled)\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @returns A command function whose caller input is the schema input type.\n */\nexport function Command<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteCommand<StandardSchemaInput<S>, A, E>;\nexport function Command(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn to_effect_command(\n\t\t\t\tnative_command(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler as RemoteHandler, \"Command\") as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedCommandHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_command(\n\t\t\tnative_command(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Command\") as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Command\");\n\t}\n}\n\n/**\n * Factory for a remote form handler.\n *\n * @example\n * ```ts\n * export const SignIn = Form(signInSchema, ({ data, invalid }) =>\n * Effect.gen(function* () {\n * if (!data.email.includes(\"@\")) {\n * return yield* invalid.email(\"Use an email address.\");\n * }\n *\n * return { email: data.email };\n * })\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit form function.\n */\nexport function Form<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>,\n): EffectRemoteForm<void, A, E>;\nexport function Form<Input extends RemoteFormInput, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteFormHandler<Input, A, E, R>,\n): EffectRemoteForm<Input, A, E>;\nexport function Form<S extends Schema.Top, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;\nexport function Form<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>,\n): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;\nexport function Form(validate_or_handler: unknown, maybe_handler?: unknown): unknown {\n\ttry {\n\t\tif (maybe_handler) {\n\t\t\treturn native_form(\n\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\tmake_remote_form_wrapper(maybe_handler as RemoteFormHandler, \"Form\") as never,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedFormHandlerMissingError();\n\t\t}\n\n\t\tconst inputless_handler: RemoteFormHandler<void, unknown> = ({ data, invalid, issue }) => {\n\t\t\tif (is_handler(validate_or_handler)) {\n\t\t\t\treturn validate_or_handler({ data, invalid, issue });\n\t\t\t}\n\n\t\t\treturn validate_or_handler as EffectLike;\n\t\t};\n\n\t\treturn native_form(\n\t\t\tmake_remote_form_wrapper(inputless_handler, \"Form\") as never,\n\t\t) as unknown as ReturnType<typeof native_form>;\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Form\");\n\t}\n}\n\n/**\n * Creates a prerenderable remote function from a no-argument Effect handler.\n *\n * @example\n * ```ts\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect value or no-argument handler to run at\n * prerender time.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called.\n */\nexport function Prerender<A, E = never, R = never>(\n\tvalidate_or_handler: EffectLike<A, E, R> | RemoteHandler<void, A, E, R>,\n\tmaybe_options?: PrerenderOptions<void>,\n): EffectRemotePrerenderFunction<void, A, E>;\n\n/**\n * Creates a prerenderable remote function with unchecked input.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * \"unchecked\",\n * (slug: string) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - `\"unchecked\"` sentinel that skips runtime input\n * validation.\n * @param maybe_handler - Handler that receives the caller-provided input.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function that yields an Effect when called with input.\n */\nexport function Prerender<Input, A, E = never, R = never>(\n\tvalidate_or_handler: \"unchecked\",\n\tmaybe_handler: RemoteHandler<Input, A, E, R>,\n\tmaybe_options?: PrerenderOptions<Input>,\n): EffectRemotePrerenderFunction<Input, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with an Effect Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * Schema.String,\n * (slug) => Effect.succeed({ slug }),\n * { inputs: () => Effect.succeed([\"intro\"]) },\n * );\n * ```\n *\n * @since 2.0.0\n * @param validate_or_handler - Effect Schema used to decode and validate\n * caller input before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema encoded type.\n */\nexport function Prerender<S extends Schema.Schema<unknown>, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<SchemaInput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<SchemaEncodedInput<S>>,\n): EffectRemotePrerenderFunction<SchemaEncodedInput<S>, A, E>;\n\n/**\n * Creates a prerenderable remote function validated with a Standard Schema.\n *\n * @example\n * ```ts\n * export const GetPost = Prerender(\n * standard_schema,\n * (post) => Effect.succeed(post.slug),\n * { dynamic: true },\n * );\n * ```\n *\n * @since 3.0.0\n * @param validate_or_handler - Standard Schema used to validate caller input\n * before the handler runs.\n * @param maybe_handler - Handler that receives the decoded schema output.\n * @param maybe_options - Optional prerender inputs and dynamic fallback\n * configuration.\n * @returns A prerender function whose caller input is the schema input type.\n */\nexport function Prerender<S extends StandardSchema, A, E = never, R = never>(\n\tvalidate_or_handler: S,\n\tmaybe_handler: RemoteHandler<StandardSchemaOutput<S>, A, E, R>,\n\tmaybe_options?: PrerenderOptions<StandardSchemaInput<S>>,\n): EffectRemotePrerenderFunction<StandardSchemaInput<S>, A, E>;\nexport function Prerender(\n\tvalidate_or_handler: unknown,\n\tmaybe_handler_or_options?: unknown,\n\tmaybe_options?: PrerenderOptions<unknown>,\n\tnative_factory: typeof native_prerender = native_prerender,\n): unknown {\n\ttry {\n\t\tif (is_handler(maybe_handler_or_options)) {\n\t\t\treturn to_effect_prerender(\n\t\t\t\tnative_factory(\n\t\t\t\t\tnormalize_validator(validate_or_handler) as never,\n\t\t\t\t\tmake_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n\t\t\t\t\tnormalize_prerender_options(maybe_options) as never,\n\t\t\t\t) as NativeQueryLike,\n\t\t\t);\n\t\t}\n\n\t\tif (is_unchecked(validate_or_handler)) {\n\t\t\tthrow new UncheckedPrerenderHandlerMissingError();\n\t\t}\n\n\t\treturn to_effect_prerender(\n\t\t\tnative_factory(\n\t\t\t\tmake_remote_wrapper(validate_or_handler as RemoteHandler, \"Prerender\") as never,\n\t\t\t\tnormalize_prerender_options(\n\t\t\t\t\tmaybe_handler_or_options as PrerenderOptions<void> | undefined,\n\t\t\t\t) as never,\n\t\t\t) as NativeQueryLike,\n\t\t);\n\t} catch (error: unknown) {\n\t\tthrow normalize_remote_helper_error(error, \"Prerender\");\n\t}\n}\n","import { RunInsideRemoteEffectHandler } from \"./remote-handler-context.ts\";\nimport { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { EffectHandler } from \"./types.ts\";\nimport { ToEffect } from \"./effects.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Adapts an Effect-producing callback to a native SvelteKit server handler.\n * SvelteKit continues to select the handler by its exported binding name, such\n * as `GET`, `PUT`, or `load`.\n *\n * @example A `+server.ts` request handler:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { RequestHandler } from \"./$types\";\n *\n * export const GET = Handler<RequestHandler>(function* ({ params }) {\n * const post = yield* Posts.get(params.slug);\n *\n * return Response.json(post);\n * });\n * ```\n *\n * @example A `+page.server.ts` load function:\n * ```ts\n * import { Handler } from \"svelte-effect-runtime/server\";\n * import type { PageServerLoad } from \"./$types\";\n *\n * export const load = Handler<PageServerLoad>(function* ({ locals }) {\n * const profile = yield* Profiles.get(locals.user.id);\n *\n * return { profile };\n * });\n * ```\n *\n * @since 4.0.0\n * @param handler - Effect-producing callback whose parameters and successful\n * result match the native SvelteKit handler type.\n * @returns A native handler that runs the callback through the configured\n * {@link ServerRuntime} with the current {@link RequestEvent} available.\n */\nexport function Handler<NativeHandler extends (...arguments_: never[]) => unknown>(\n\thandler: EffectHandler<NativeHandler>,\n): NativeHandler {\n\tconst native_handler = async (...arguments_: Parameters<NativeHandler>) => {\n\t\tconst event = get_native_request_event();\n\t\tconst runtime = get_server_runtime_or_throw();\n\t\tconst HandlerEffect = Effect.suspend(() => ToEffect(handler(...arguments_)));\n\t\tconst HandlerOwnedEffect = RunInsideRemoteEffectHandler(event, HandlerEffect);\n\t\tconst EffectWithRequestEvent = Effect.provideService(\n\t\t\tHandlerOwnedEffect,\n\t\t\tRequestEvent,\n\t\t\tevent,\n\t\t);\n\n\t\treturn await runtime.runPromise(EffectWithRequestEvent, {\n\t\t\tsignal: event.request.signal,\n\t\t});\n\t};\n\n\treturn native_handler as unknown as NativeHandler;\n}\n","import { error as svelte_error, redirect as svelte_redirect } from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n\tProxyAuthenticationRequired: 407,\n\tRequestHeaderFieldsTooLarge: 431,\n\tUnavailableForLegalReasons: 451,\n\tNetworkAuthenticationRequired: 511,\n\tHttpVersionNotSupported: 505,\n\tUnprocessableContent: 422,\n\tUnprocessableEntity: 422,\n\tInternalServerError: 500,\n\tFailedDependency: 424,\n\tPreconditionRequired: 428,\n\tServiceUnavailable: 503,\n\tMisdirectedRequest: 421,\n\tInsufficientStorage: 507,\n\tVariantAlsoNegotiates: 506,\n\tPreconditionFailed: 412,\n\tMethodNotAllowed: 405,\n\tGatewayTimeout: 504,\n\tPaymentRequired: 402,\n\tUpgradeRequired: 426,\n\tTooManyRequests: 429,\n\tLengthRequired: 411,\n\tNotAcceptable: 406,\n\tRequestTimeout: 408,\n\tContentTooLarge: 413,\n\tPayloadTooLarge: 413,\n\tUriTooLong: 414,\n\tUnsupportedMediaType: 415,\n\tRangeNotSatisfiable: 416,\n\tExpectationFailed: 417,\n\tImATeapot: 418,\n\tBadRequest: 400,\n\tUnauthorized: 401,\n\tForbidden: 403,\n\tNotFound: 404,\n\tConflict: 409,\n\tGone: 410,\n\tLocked: 423,\n\tTooEarly: 425,\n\tNotImplemented: 501,\n\tBadGateway: 502,\n\tLoopDetected: 508,\n\tNotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n\tMovedPermanently: 301,\n\tTemporaryRedirect: 307,\n\tPermanentRedirect: 308,\n\tMultipleChoices: 300,\n\tNotModified: 304,\n\tSwitchProxy: 306,\n\tSeeOther: 303,\n\tUseProxy: 305,\n\tFound: 302,\n} as const;\n\ntype AppErrorStatus = App.Error extends { readonly status?: infer Status } ? Status : number;\n\n/**\n * Compatibility shim while SER supports both SvelteKit 2 and 3. The wrappers\n * call the SvelteKit 3 control-flow shapes, while SvelteKit 2 ignores extra\n * runtime arguments. Drop these broad call signatures when Kit 2 support is\n * removed.\n */\ntype SvelteError = (status: number, body?: ErrorBody, properties?: ErrorProperties) => never;\n\ntype SvelteRedirect = (status: number, location: string | URL, options?: RedirectOptions) => never;\n\n/**\n * Named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatusName = \"NotFound\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatusName = keyof typeof error_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const status: ErrorStatus = \"InternalServerError\";\n * ```\n *\n * @since 2.3.0\n */\nexport type ErrorStatus = ErrorStatusName | number;\n\n/**\n * Error body accepted by the {@link Error} helper.\n *\n * @example\n * ```ts\n * const body: ErrorBody = { message: \"Post not found\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorBody =\n\t| (Omit<App.Error, \"status\"> & { readonly status?: AppErrorStatus })\n\t| string\n\t| undefined;\n\n/**\n * Extra SvelteKit app error properties accepted by the {@link Error} helper\n * when using the SvelteKit 3 string-body overload.\n *\n * @example\n * ```ts\n * const properties: ErrorProperties = { code: \"POST_NOT_FOUND\" };\n * ```\n *\n * @since 3.4.3\n */\nexport type ErrorProperties = Omit<App.Error, \"status\" | \"message\">;\n\n/**\n * Named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatusName = \"TemporaryRedirect\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatusName = keyof typeof redirect_status_codes;\n\n/**\n * Numeric or named HTTP status accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const status: RedirectStatus = \"SeeOther\";\n * ```\n *\n * @since 2.3.0\n */\nexport type RedirectStatus = RedirectStatusName | number;\n\n/**\n * Options accepted by the {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const options: RedirectOptions = { external: true };\n * ```\n *\n * @since 3.4.3\n */\nexport type RedirectOptions = {\n\treadonly external?: boolean | string[];\n};\n\n/**\n * Callable shape for the exported {@link Error} helper.\n *\n * @example\n * ```ts\n * const fail_not_found: ErrorEffectFactory = Error;\n * ```\n *\n * @since 2.3.0\n */\nexport interface ErrorEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Optional SvelteKit error body or message forwarded unchanged\n\t * to SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(status: ErrorStatus, body?: ErrorBody): Effect.Effect<never, never, never>;\n\n\t/**\n\t * Creates an Effect that throws SvelteKit's HTTP error control-flow value\n\t * using the SvelteKit 3 string-body overload with extra properties.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Error(\"NotFound\", \"Post not found\", {\n\t * code: \"POST_NOT_FOUND\",\n\t * });\n\t * ```\n\t *\n\t * @since 3.4.3\n\t * @param status - Numeric HTTP status or PascalCase status name to pass to\n\t * SvelteKit's `error` helper.\n\t * @param body - Error message forwarded to SvelteKit.\n\t * @param properties - Additional app error properties forwarded to\n\t * SvelteKit.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: ErrorStatus,\n\t\tbody: string,\n\t\tproperties: ErrorProperties,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Callable shape for the exported {@link Redirect} helper.\n *\n * @example\n * ```ts\n * const redirect_after_save: RedirectEffectFactory = Redirect;\n * ```\n *\n * @since 2.3.0\n */\nexport interface RedirectEffectFactory {\n\t/**\n\t * Creates an Effect that throws SvelteKit's redirect control-flow value.\n\t *\n\t * @example\n\t * ```ts\n\t * return yield* Redirect(\"SeeOther\", \"/posts\");\n\t * ```\n\t *\n\t * @since 2.3.0\n\t * @param status - Numeric redirect status or PascalCase status name to pass\n\t * to SvelteKit's `redirect` helper.\n\t * @param location - Target URL forwarded unchanged to SvelteKit.\n\t * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n\t * `{ external: true }` or an allowlist to redirect to external URLs.\n\t * @returns An Effect that never succeeds because SvelteKit takes over request\n\t * control flow.\n\t */\n\t(\n\t\tstatus: RedirectStatus,\n\t\tlocation: string | URL,\n\t\toptions?: RedirectOptions,\n\t): Effect.Effect<never, never, never>;\n}\n\n/**\n * Creates an Effect that raises SvelteKit's HTTP error control flow.\n *\n * @example\n * ```ts\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric HTTP status or PascalCase status name to pass to\n * SvelteKit's `error` helper.\n * @param body - Optional SvelteKit error body or message forwarded unchanged\n * to SvelteKit.\n * @param properties - Optional SvelteKit 3 app error properties forwarded when\n * using a string error message.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = ((\n\tstatus: ErrorStatus,\n\tbody?: ErrorBody,\n\tproperties?: ErrorProperties,\n) => {\n\tconst resolved_status = resolve_error_status(status);\n\tconst error = svelte_error as SvelteError;\n\n\treturn Effect.sync((): never => {\n\t\tif (properties === undefined) {\n\t\t\treturn error(resolved_status, body);\n\t\t}\n\n\t\treturn error(resolved_status, body, properties);\n\t});\n}) as ErrorEffectFactory;\n\n/**\n * Creates an Effect that raises SvelteKit's redirect control flow.\n *\n * @example\n * ```ts\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n * @param status - Numeric redirect status or PascalCase status name to pass to\n * SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @param options - Optional SvelteKit redirect options. In SvelteKit 3, pass\n * `{ external: true }` or an allowlist to redirect to external URLs.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = ((\n\tstatus: RedirectStatus,\n\tlocation: string | URL,\n\toptions?: RedirectOptions,\n) => {\n\tconst resolved_status = resolve_redirect_status(status);\n\tconst redirect = svelte_redirect as SvelteRedirect;\n\n\treturn Effect.sync((): never => redirect(resolved_status, location, options));\n}) as RedirectEffectFactory;\n\nfunction resolve_error_status(status: ErrorStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n\tif (typeof status === \"number\") {\n\t\treturn status;\n\t}\n\n\treturn redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;AAGA,MAAM,+CAA+B,IAAI,QAAwB;;AAGjE,SAAgB,iCAAiC,OAAyB;CACzE,MAAM,gBAAgB,SAAS,0BAA0B;CAEzD,IAAI,CAAC,eACJ,OAAO;CAGR,QAAQ,6BAA6B,IAAI,aAAa,KAAK,KAAK;AACjE;;AAGA,MAAa,gCACZ,OACA,WAEA,OAAO,kBACN,8BAA8B,KAAK,SAC7B,cACA,8BAA8B,KAAK,CAC1C;AAED,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,eAAe,6BAA6B,IAAI,KAAK,KAAK;CAEhE,6BAA6B,IAAI,OAAO,eAAe,CAAC;AACzD,CAAC;AAEF,MAAM,iCAAiC,UACtC,OAAO,WAAW;CACjB,MAAM,mBAAmB,6BAA6B,IAAI,KAAK,KAAK,KAAK;CAEzE,IAAI,oBAAoB,GAAG;EAC1B,6BAA6B,OAA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,OAAO,OAAO,WAAkBD,WAAS,iBAAiB,UAAU,OAAO,CAAC;AAC7E;AAEA,SAAS,qBAAqB,QAA6B;CAC1D,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,mBAAmB;AAC3B;AAEA,SAAS,wBAAwB,QAAgC;CAChE,IAAI,OAAO,WAAW,UACrB,OAAO;CAGR,OAAO,sBAAsB;AAC9B"}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server-NeyeDSax.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/diagnostics.ts","../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { Cause } from \"effect\";\n\n/**\n * Why a remote failure reached the client without its original detail.\n *\n * @example\n * ```ts\n * const reason: OpaqueRemoteFailureReason = \"untagged\";\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailureReason = \"untagged\" | \"unserializable\" | \"unknown\" | \"interrupted\";\n\n/**\n * Request detail attached to an opaque remote failure report so the log line\n * points at the handler that produced it.\n *\n * @example\n * ```ts\n * const context: RemoteFailureContext = { method: \"POST\", url: \"/checkout\" };\n * ```\n *\n * @since 4.2.0\n */\nexport type RemoteFailureContext = {\n\treadonly method?: string;\n\treadonly route?: string;\n\treadonly url?: string;\n};\n\ntype Reporter = (message: string) => void;\n\nconst explanations: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"the failure has no string `_tag`, so it cannot be told apart from an arbitrary object on the wire\",\n\tunserializable:\n\t\t\"the failure could not be serialized, even after being reduced to its own enumerable properties\",\n\tunknown: \"the cause carries no failure reason, so there was nothing to serialize\",\n\tinterrupted: \"the handler's fiber was interrupted before it produced a result\",\n};\n\nconst remedies: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"Fail with a tagged error (`Data.TaggedError` or `Schema.TaggedError`) so SER can carry it to the client.\",\n\tunserializable:\n\t\t\"Remove non-transportable values (functions, class instances, cycles) from the error, or map it to a tagged error first.\",\n\tunknown:\n\t\t\"Check for a defect thrown outside the Effect error channel; the original value is shown above.\",\n\tinterrupted:\n\t\t\"An interrupt usually means the runtime was disposed mid-request, for example when the dev server restarted while this request was in flight.\",\n};\n\n/**\n * Reports a remote failure that had to be replaced with an opaque envelope.\n *\n * SER cannot send an unrecognized failure to the browser, so the client only\n * ever sees a generic 500. Without this report the original error would be\n * lost entirely, which is the difference between a debuggable failure and a\n * silent one.\n *\n * @example\n * ```ts\n * report_opaque_remote_failure(\"untagged\", cause, value, { url: \"/checkout\" });\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @param report - Sink for the rendered report; defaults to `console.error`.\n */\nexport function report_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tcontext?: RemoteFailureContext,\n\treport: Reporter = default_reporter,\n): void {\n\t/**\n\t * Reporting runs before SvelteKit's error helper, and the failure it\n\t * describes is arbitrary user data. Throwing here would replace the 500\n\t * the handler owes the client with the reporter's own error.\n\t */\n\ttry {\n\t\treport(render_opaque_remote_failure(reason, cause, value, context));\n\t} catch {\n\t\t/** A diagnostic is never worth failing the request over. */\n\t}\n}\n\n/**\n * Renders the report emitted by {@link report_opaque_remote_failure}.\n *\n * @example\n * ```ts\n * const message = render_opaque_remote_failure(\"untagged\", cause, value);\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @returns The multi-line report.\n */\nexport function render_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tcontext?: RemoteFailureContext,\n): string {\n\tconst request = render_request(context);\n\tconst lines = [\n\t\t\"[svelte-effect-runtime] A remote handler failed with an error that could not be sent to the client.\",\n\t\t` Reason: ${explanations[reason]}.`,\n\t];\n\n\tif (request) {\n\t\tlines.push(` Request: ${request}`);\n\t}\n\n\tif (reason !== \"interrupted\") {\n\t\tlines.push(` Failure: ${inspect_failure(value)}`);\n\t}\n\n\tlines.push(\" Cause:\", indent(pretty_cause(cause)), ` Fix: ${remedies[reason]}`);\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction render_request(context?: RemoteFailureContext): string | undefined {\n\tif (!context) {\n\t\treturn undefined;\n\t}\n\n\tconst target = context.url ?? context.route;\n\tconst parts = [context.method, target].filter(Boolean);\n\tconst names_route = Boolean(context.route && context.url && context.route !== context.url);\n\tconst route = names_route ? ` (route ${context.route})` : \"\";\n\n\tif (parts.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn `${parts.join(\" \")}${route}`;\n}\n\nfunction pretty_cause(cause: Cause.Cause<unknown>): string {\n\ttry {\n\t\treturn Cause.pretty(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n}\n\n/**\n * Renders the failure value itself. Errors keep their stack because that is\n * the only part of an untagged failure that identifies its source.\n */\nfunction inspect_failure(value: unknown): string {\n\tif (value === undefined) {\n\t\treturn \"(none)\";\n\t}\n\n\tif (value instanceof globalThis.Error) {\n\t\treturn value.stack ?? `${value.name}: ${value.message}`;\n\t}\n\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn describe_primitive(value);\n\t}\n\n\ttry {\n\t\treturn JSON.stringify(value, undefined, 2) ?? describe_object(value);\n\t} catch {\n\t\treturn describe_object(value);\n\t}\n}\n\n/** A primitive can still carry a throwing `Symbol.toPrimitive`. */\nfunction describe_primitive(value: unknown): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\treturn typeof value;\n\t}\n}\n\n/**\n * Falls back through conversions an object can subvert. A null-prototype or\n * hostile object may throw from `toString` and lack `Object.prototype`, so the\n * last resort must not touch the value at all.\n */\nfunction describe_object(value: object): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\t/** Fall through to a conversion the value cannot override. */\n\t}\n\n\ttry {\n\t\treturn Object.prototype.toString.call(value);\n\t} catch {\n\t\treturn \"[unrenderable failure]\";\n\t}\n}\n\nfunction indent(value: string): string {\n\treturn value\n\t\t.split(\"\\n\")\n\t\t.map((line) => ` ${line}`)\n\t\t.join(\"\\n\");\n}\n\nfunction default_reporter(message: string): void {\n\tconsole.error(message);\n}\n","import type { OpaqueRemoteFailureReason } from \"$/remote/diagnostics.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\n\n/**\n * Records that a failure lost its detail on the way to the client, so callers\n * can report the original error instead of dropping it silently.\n *\n * @example\n * ```ts\n * const diagnostic: OpaqueRemoteFailure = { reason: \"untagged\", value: err };\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailure = {\n\treadonly reason: OpaqueRemoteFailureReason;\n\treadonly value: unknown;\n};\n\ntype EncodedRemoteFailure = {\n\treadonly encoded: string;\n\treadonly opaque?: OpaqueRemoteFailure;\n};\n\nexport type RemoteCauseResolution =\n\t| {\n\t\t\treadonly _tag: \"SvelteKitControlFlow\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"InterruptOnly\";\n\t\t\treadonly cause: Cause.Cause<unknown>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"FormInvalid\";\n\t\t\treadonly issues: readonly FormIssue[];\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFailure\";\n\t\t\treadonly encoded: string;\n\t\t\treadonly opaque?: OpaqueRemoteFailure;\n\t };\n\n/** Preserves SvelteKit control flow before classifying transportable Effect failures. */\nexport function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution {\n\tconst control_flow = find_sveltekit_control_flow(cause);\n\n\tif (control_flow !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"SvelteKitControlFlow\",\n\t\t\tvalue: control_flow,\n\t\t};\n\t}\n\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\treturn {\n\t\t\t_tag: \"InterruptOnly\",\n\t\t\tcause,\n\t\t};\n\t}\n\n\tconst form_error_issues = find_form_error_issues(cause);\n\n\tif (form_error_issues !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"FormInvalid\",\n\t\t\tissues: form_error_issues,\n\t\t};\n\t}\n\n\tconst failure = encode_remote_failure_detailed(cause);\n\n\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: failure.encoded,\n\t\t...(failure.opaque ? { opaque: failure.opaque } : {}),\n\t};\n}\n\n/** Encodes a remote failure into the transport ABI shared with generated clients. */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\treturn encode_remote_failure_detailed(cause).encoded;\n}\n\n/**\n * Encodes a remote failure and reports whether its detail survived encoding.\n *\n * @example\n * ```ts\n * const { encoded, opaque } = encode_remote_failure_detailed(cause);\n * ```\n *\n * @since 4.2.0\n * @param cause - Cause carrying the handler's failure.\n * @returns The encoded payload and, when detail was lost, why.\n */\nexport function encode_remote_failure_detailed(cause: Cause.Cause<unknown>): EncodedRemoteFailure {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tagged = has_public_remote_failure_tag(reason.error);\n\n\t\tif (!tagged) {\n\t\t\treturn {\n\t\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\t\topaque: { reason: \"untagged\", value: reason.error },\n\t\t\t};\n\t\t}\n\n\t\tconst failure = to_serializable_public_failure(reason.error);\n\t\tconst encoded = failure === undefined ? undefined : stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn { encoded };\n\t\t}\n\n\t\treturn {\n\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\topaque: { reason: \"unserializable\", value: reason.error },\n\t\t};\n\t}\n\n\treturn {\n\t\tencoded: stringify_unknown_remote_failure(),\n\t\topaque: { reason: \"unknown\", value: find_defect(cause) },\n\t};\n}\n\n/** Surfaces a defect so an unencodable cause still names something concrete. */\nfunction find_defect(cause: Cause.Cause<unknown>): unknown {\n\tfor (const reason of cause.reasons) {\n\t\tif (Cause.isDieReason(reason)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_sveltekit_control_flow(cause: Cause.Cause<unknown>): unknown | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isDieReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_sveltekit_control_flow(reason.defect)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_form_error_issues(cause: Cause.Cause<unknown>): readonly FormIssue[] | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst issues = get_form_error_issues(reason.error);\n\n\t\tif (issues !== undefined) {\n\t\t\treturn issues;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_form_error_issues(value: unknown): readonly FormIssue[] | undefined {\n\tif (is_form_error(value)) {\n\t\treturn value.issues;\n\t}\n\n\treturn is_tagged_form_error(value) ? [] : undefined;\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\nconst is_tagged_form_error = Schema.is(\n\tSchema.Struct({\n\t\t_tag: Schema.Literal(\"FormError\"),\n\t}),\n);\n","import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { report_opaque_remote_failure } from \"$/remote/diagnostics.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport type { RemoteFailureContext } from \"$/remote/diagnostics.ts\";\nimport { classify_remote_cause } from \"$/remote/cause-codec.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nexport { encode_remote_failure } from \"$/remote/cause-codec.ts\";\n\n/** Maps a remote Effect exit into the control flow expected by SvelteKit. */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tcontext?: RemoteFailureContext,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\tthrow_remote_cause(exit.cause, invalid, error, context);\n}\n\n/** Applies a classified remote Cause decision to SvelteKit's server helpers. */\nexport function throw_remote_cause(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tcontext?: RemoteFailureContext,\n\treport?: (message: string) => void,\n): never {\n\tconst resolution = classify_remote_cause(cause);\n\n\tswitch (resolution._tag) {\n\t\tcase \"SvelteKitControlFlow\": {\n\t\t\tthrow resolution.value;\n\t\t}\n\t\tcase \"InterruptOnly\": {\n\t\t\treport_opaque_remote_failure(\n\t\t\t\t\"interrupted\",\n\t\t\t\tresolution.cause,\n\t\t\t\tundefined,\n\t\t\t\tcontext,\n\t\t\t\treport,\n\t\t\t);\n\n\t\t\tthrow Cause.squash(resolution.cause);\n\t\t}\n\t\tcase \"FormInvalid\": {\n\t\t\tinvalid(...resolution.issues);\n\t\t}\n\t\tcase \"RemoteFailure\": {\n\t\t\tconst envelope = create_serialized_remote_failure_envelope(resolution.encoded);\n\n\t\t\t/**\n\t\t\t * The client only receives a generic 500 for a failure SER could not\n\t\t\t * encode, so the original error is reported here or lost entirely.\n\t\t\t */\n\t\t\tif (resolution.opaque) {\n\t\t\t\treport_opaque_remote_failure(\n\t\t\t\t\tresolution.opaque.reason,\n\t\t\t\t\tcause,\n\t\t\t\t\tresolution.opaque.value,\n\t\t\t\t\tcontext,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\terror(500, envelope);\n\t\t}\n\t}\n}\n\n/**\n * Describes the request a remote failure occurred in.\n *\n * @example\n * ```ts\n * const context = to_remote_failure_context(event);\n * ```\n *\n * @since 4.2.0\n * @param event - Request event the handler ran under.\n * @returns Request detail for opaque failure reports.\n */\nexport function to_remote_failure_context(event: {\n\treadonly request?: { readonly method?: string };\n\treadonly route?: { readonly id?: string | null };\n\treadonly url?: { readonly pathname?: string };\n}): RemoteFailureContext {\n\tconst method = event.request?.method;\n\tconst route = event.route?.id ?? undefined;\n\tconst url = event.url?.pathname;\n\n\treturn {\n\t\t...(method ? { method } : {}),\n\t\t...(route ? { route } : {}),\n\t\t...(url ? { url } : {}),\n\t};\n}\n\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/** Rebrands SvelteKit context failures with the remote helper that triggered them. */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;AAiCA,MAAM,eAAoE;CACzE,UACC;CACD,gBACC;CACD,SAAS;CACT,aAAa;AACd;AAEA,MAAM,WAAgE;CACrE,UACC;CACD,gBACC;CACD,SACC;CACD,aACC;AACF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,6BACf,QACA,OACA,OACA,SACA,SAAmB,kBACZ;;;;;;CAMP,IAAI;EACH,OAAO,6BAA6B,QAAQ,OAAO,OAAO,OAAO,CAAC;CACnE,QAAQ,CAER;AACD;;;;;;;;;;;;;;;;AAiBA,SAAgB,6BACf,QACA,OACA,OACA,SACS;CACT,MAAM,UAAU,eAAe,OAAO;CACtC,MAAM,QAAQ,CACb,uGACA,aAAa,aAAa,QAAQ,EACnC;CAEA,IAAI,SACH,MAAM,KAAK,cAAc,SAAS;CAGnC,IAAI,WAAW,eACd,MAAM,KAAK,cAAc,gBAAgB,KAAK,GAAG;CAGlD,MAAM,KAAK,YAAY,OAAO,aAAa,KAAK,CAAC,GAAG,UAAU,SAAS,SAAS;CAEhF,OAAO,MAAM,KAAK,IAAI;AACvB;AAEA,SAAS,eAAe,SAAoD;CAC3E,IAAI,CAAC,SACJ;CAGD,MAAM,SAAS,QAAQ,OAAO,QAAQ;CACtC,MAAM,QAAQ,CAAC,QAAQ,QAAQ,MAAM,CAAC,CAAC,OAAO,OAAO;CAErD,MAAM,QADc,QAAQ,QAAQ,SAAS,QAAQ,OAAO,QAAQ,UAAU,QAAQ,GAC9D,IAAI,WAAW,QAAQ,MAAM,KAAK;CAE1D,IAAI,MAAM,WAAW,GACpB;CAGD,OAAO,GAAG,MAAM,KAAK,GAAG,IAAI;AAC7B;AAEA,SAAS,aAAa,OAAqC;CAC1D,IAAI;EACH,OAAO,MAAM,OAAO,KAAK;CAC1B,QAAQ;EACP,OAAO,OAAO,KAAK;CACpB;AACD;;;;;AAMA,SAAS,gBAAgB,OAAwB;CAChD,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