svelte-effect-runtime 4.2.4 → 4.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-CpWfP_1f.js → client-Bi7SwVVy.js} +23 -13
- package/.dist/chunks/client-Bi7SwVVy.js.map +1 -0
- package/.dist/chunks/{compiler-Dpyu4Owd.js → compiler-B2htZszc.js} +8 -5
- package/.dist/chunks/{compiler-Dpyu4Owd.js.map → compiler-B2htZszc.js.map} +1 -1
- package/.dist/chunks/{remote-client-mkQAfP1G.js → remote-client-C_3kdug0.js} +15 -4
- package/.dist/chunks/remote-client-C_3kdug0.js.map +1 -0
- package/.dist/chunks/{server-BNxq-pUH.js → server-Dxb9zr99.js} +16 -3
- package/.dist/chunks/server-Dxb9zr99.js.map +1 -0
- package/.dist/compiler/remote-client.d.ts +1 -0
- package/.dist/compiler.js +1 -1
- package/.dist/environment.d.ts +9 -3
- package/.dist/environment.js.map +1 -1
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +1 -1
- package/.dist/mod.js +1 -1
- package/.dist/remote/client/form-data.d.ts +8 -1
- package/.dist/remote/client/form.d.ts +2 -2
- package/.dist/remote/client/types.d.ts +10 -11
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/native-types.d.ts +292 -0
- package/.dist/remote/server.js +1 -1
- package/.dist/server/factories.d.ts +4 -4
- package/.dist/server/live-snapshot.d.ts +2 -2
- package/.dist/server/types.d.ts +7 -7
- package/.dist/server.js +3 -3
- package/.dist/server.js.map +1 -1
- package/package.json +2 -2
- package/.dist/chunks/client-CpWfP_1f.js.map +0 -1
- package/.dist/chunks/remote-client-mkQAfP1G.js.map +0 -1
- package/.dist/chunks/server-BNxq-pUH.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-Dxb9zr99.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 } from \"@sveltejs/kit\";\nimport * as SvelteKit 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) || is_validation_error(value);\n}\n\n/**\n * SvelteKit `3.0.0-next.21` and `3.0.0-next.22` removed `isValidationError`\n * from the `@sveltejs/kit` index (`3.0.0-next.23` restored it), so a named\n * import would crash module evaluation on those versions. The namespace access\n * stays safe on every version and the structural check mirrors SvelteKit's\n * `ValidationError` (`Error` named `ValidationError` carrying `issues`).\n */\nfunction is_validation_error(value: unknown): boolean {\n\tconst native = (SvelteKit as { isValidationError?: (value: unknown) => boolean })\n\t\t.isValidationError;\n\n\tif (native !== undefined) {\n\t\treturn native(value);\n\t}\n\n\treturn (\n\t\tvalue instanceof globalThis.Error &&\n\t\tvalue.name === \"ValidationError\" &&\n\t\tArray.isArray((value as { issues?: unknown }).issues)\n\t);\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,IA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,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"}
|
|
@@ -3,4 +3,5 @@ interface RemoteClientRewriteOptions {
|
|
|
3
3
|
}
|
|
4
4
|
/** Rewrites SvelteKit's generated remote client exports to SER adapters. */
|
|
5
5
|
export declare function rewrite_remote_client_exports(code: string, options?: RemoteClientRewriteOptions): string;
|
|
6
|
+
export declare function find_remote_client_runtime_specifier(code: string): string | undefined;
|
|
6
7
|
export {};
|
package/.dist/compiler.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as rewrite_remote_client_exports, t as effect } from "./chunks/compiler-
|
|
1
|
+
import { n as rewrite_remote_client_exports, t as effect } from "./chunks/compiler-B2htZszc.js";
|
|
2
2
|
export { effect, rewrite_remote_client_exports };
|
package/.dist/environment.d.ts
CHANGED
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { StandardSchemaV1 } from "@sveltejs/kit/internal/types";
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
/**
|
|
4
|
-
* The Standard Schema validator shape SvelteKit accepts for an environment
|
|
4
|
+
* The Standard Schema validator shape SvelteKit accepts for an environment
|
|
5
|
+
* variable. Mirrors `EnvVarConfig["schema"]` structurally rather than
|
|
6
|
+
* importing it, because SvelteKit 2 declares `EnvVarConfig` in
|
|
7
|
+
* `@sveltejs/kit` while SvelteKit 3 (since `3.0.0-next.20`) declares it only
|
|
8
|
+
* in `@sveltejs/kit/env`. SvelteKit's generated `$app/env/*` types infer each
|
|
9
|
+
* variable through `StandardSchemaV1.InferOutput`, so the normalized schema
|
|
10
|
+
* member must stay exactly this shape.
|
|
5
11
|
*
|
|
6
12
|
* @since 4.2.0
|
|
7
13
|
*/
|
|
8
|
-
export type StandardSchema<Output = unknown> =
|
|
14
|
+
export type StandardSchema<Output = unknown> = StandardSchemaV1<string | undefined, Output>;
|
|
9
15
|
/**
|
|
10
16
|
* A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes
|
|
11
17
|
* synchronously from the raw string value, or an existing Standard Schema.
|
package/.dist/environment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"environment.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/environment.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"environment.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/environment.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@sveltejs/kit/internal/types\";\nimport { Schema } from \"effect\";\n\n/**\n * The Standard Schema validator shape SvelteKit accepts for an environment\n * variable. Mirrors `EnvVarConfig[\"schema\"]` structurally rather than\n * importing it, because SvelteKit 2 declares `EnvVarConfig` in\n * `@sveltejs/kit` while SvelteKit 3 (since `3.0.0-next.20`) declares it only\n * in `@sveltejs/kit/env`. SvelteKit's generated `$app/env/*` types infer each\n * variable through `StandardSchemaV1.InferOutput`, so the normalized schema\n * member must stay exactly this shape.\n *\n * @since 4.2.0\n */\nexport type StandardSchema<Output = unknown> = StandardSchemaV1<string | undefined, Output>;\n\n/**\n * A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes\n * synchronously from the raw string value, or an existing Standard Schema.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchema =\n\t| (Schema.ConstraintDecoder<unknown, never> & {\n\t\t\treadonly Encoded: string | undefined;\n\t })\n\t| StandardSchema<unknown>;\n\n/**\n * The decoded output type an environment schema produces.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchemaOutput<S extends EnvironmentSchema> = S extends Schema.Constraint\n\t? S[\"Type\"]\n\t: S extends StandardSchema<infer Output>\n\t\t? Output\n\t\t: never;\n\n/**\n * One environment variable declaration: SvelteKit's metadata plus an Effect\n * Schema or Standard Schema validator.\n *\n * @since 4.2.0\n */\nexport interface EnvironmentVariable<S extends EnvironmentSchema = EnvironmentSchema> {\n\treadonly public?: boolean;\n\treadonly static?: boolean;\n\treadonly description?: string;\n\treadonly schema?: S;\n}\n\n/**\n * Environment variable declarations keyed by variable name.\n *\n * @since 4.2.0\n */\nexport type EnvironmentDefinition = Record<string, EnvironmentVariable>;\n\n/**\n * The normalized declarations {@link DefineEnvVars} returns, with every Effect\n * Schema converted to a Standard Schema of the same decoded output type.\n *\n * @since 4.2.0\n */\nexport type EnvironmentVariables<Definition extends EnvironmentDefinition> = {\n\treadonly [Name in keyof Definition]: Omit<Definition[Name], \"schema\"> &\n\t\tNormalizedVariableSchema<Definition[Name][\"schema\"]>;\n};\n\n/** Keeps the schema member sound when a declaration's schema type includes undefined. */\ntype NormalizedVariableSchema<S> = [S] extends [EnvironmentSchema]\n\t? { readonly schema: StandardSchema<EnvironmentSchemaOutput<S>> }\n\t: [S] extends [undefined]\n\t\t? { readonly schema?: undefined }\n\t\t: {\n\t\t\t\treadonly schema?: StandardSchema<\n\t\t\t\t\tEnvironmentSchemaOutput<Extract<S, EnvironmentSchema>>\n\t\t\t\t>;\n\t\t\t};\n\n/**\n * Declares SvelteKit environment variables with Effect Schema validators.\n *\n * A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas\n * to the Standard Schema interface SvelteKit validates at startup. Standard\n * Schema validators and schema-less declarations pass through unchanged, and\n * SvelteKit remains responsible for loading, visibility, and validation.\n * Schemas must decode synchronously from the raw string value.\n *\n * @example\n * ```ts\n * // src/env.ts\n * import { DefineEnvVars } from \"svelte-effect-runtime/environment\";\n * import { Schema } from \"effect\";\n *\n * export const variables = DefineEnvVars({\n * PORT: { schema: Schema.NumberFromString, description: \"Server port.\" },\n * PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },\n * });\n * ```\n *\n * @since 4.2.0\n * @param definition - Environment variable declarations keyed by variable name,\n * each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.\n * @returns The same declarations with every Effect Schema converted to a\n * Standard Schema, ready to export as `variables` from `src/env.ts`.\n */\nexport function DefineEnvVars<const Definition extends EnvironmentDefinition>(\n\tdefinition: Definition,\n): EnvironmentVariables<Definition> {\n\tconst entries = Object.entries(definition).map(([name, variable]) => [\n\t\tname,\n\t\tnormalize_variable(variable),\n\t]);\n\n\treturn Object.fromEntries(entries) as EnvironmentVariables<Definition>;\n}\n\nfunction normalize_variable(variable: EnvironmentVariable): EnvironmentVariable {\n\tif (variable.schema === undefined || !Schema.isSchema(variable.schema)) {\n\t\treturn variable;\n\t}\n\n\treturn {\n\t\t...variable,\n\t\tschema: Schema.toStandardSchemaV1(\n\t\t\tvariable.schema as Schema.ConstraintDecoder<unknown, never>,\n\t\t) as StandardSchema,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,cACf,YACmC;CACnC,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,cAAc,CACpE,MACA,mBAAmB,QAAQ,CAC5B,CAAC;CAED,OAAO,OAAO,YAAY,OAAO;AAClC;AAEA,SAAS,mBAAmB,UAAoD;CAC/E,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,OAAO,SAAS,SAAS,MAAM,GACpE,OAAO;CAGR,OAAO;EACN,GAAG;EACH,QAAQ,OAAO,mBACd,SAAS,MACV;CACD;AACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Bi7SwVVy.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
|
@@ -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-Dxb9zr99.js";
|
|
2
2
|
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
package/.dist/mod.js
CHANGED
|
@@ -3,7 +3,7 @@ import { n as Dispatcher } from "./chunks/dispatcher-D3Tpa5HC.js";
|
|
|
3
3
|
import { DefineEnvVars } from "./environment.js";
|
|
4
4
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
5
5
|
import { t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
6
|
-
import { t as effect } from "./chunks/compiler-
|
|
6
|
+
import { t as effect } from "./chunks/compiler-B2htZszc.js";
|
|
7
7
|
//#region src/mod.ts
|
|
8
8
|
/**
|
|
9
9
|
* Public API surface for `svelte-effect-runtime`.
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Encodes a remote form input the way SvelteKit's `convert_formdata` expects.
|
|
3
|
+
* SvelteKit 3.0.0-next.14+ requires every field name to end with `/<form_id>`
|
|
4
|
+
* (the un-keyed remote action id), so callers pass the id whenever they target
|
|
5
|
+
* that wire format. SvelteKit 2 servers never see this encoding because they
|
|
6
|
+
* ship the binary form bridge, which bypasses `FormData` entirely.
|
|
7
|
+
*/
|
|
8
|
+
export declare function to_form_data(input: unknown, form_id?: string): FormData;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type StandardSchema } from "../../internal/schema.js";
|
|
2
2
|
import type { EffectRemoteForm } from "./types.js";
|
|
3
3
|
import { type RemoteFormTransport } from "./form-transport.js";
|
|
4
|
-
import type {
|
|
4
|
+
import type { NativeRemoteFormInput } from "../native-types.js";
|
|
5
5
|
interface RemoteFormAdapterState {
|
|
6
6
|
shared_preflight_schema?: StandardSchema;
|
|
7
7
|
}
|
|
8
8
|
/** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */
|
|
9
|
-
export declare function create_remote_form_adapter<Input extends
|
|
9
|
+
export declare function create_remote_form_adapter<Input extends NativeRemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, remote_transport?: RemoteFormTransport, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
|
|
10
10
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NativeRemoteForm, NativeRemoteFormInput, NativeRemoteQueryUpdate } from "../native-types.js";
|
|
2
2
|
import type { RemoteFailure } from "../shared.js";
|
|
3
3
|
import type { Effect, Schema, Stream } from "effect";
|
|
4
4
|
import type { RemoteLiveStream } from "../../live.js";
|
|
@@ -7,13 +7,13 @@ export declare const effect_remote_query_update: unique symbol;
|
|
|
7
7
|
export type EffectRemoteQueryUpdateBrand = {
|
|
8
8
|
readonly [effect_remote_query_update]: true;
|
|
9
9
|
};
|
|
10
|
-
type EffectRemoteFormCallable<Input extends
|
|
10
|
+
type EffectRemoteFormCallable<Input extends NativeRemoteFormInput | void, Output, ErrorType> = [
|
|
11
11
|
Input
|
|
12
12
|
] extends [void] ? () => Effect.Effect<Output, RemoteFailure<ErrorType>> : undefined extends Input ? (input?: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>> : (input: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>;
|
|
13
|
-
type NativeRemoteFormPreflightSchema<Input extends
|
|
14
|
-
type NativeRemoteFormValidateOptions<Input extends
|
|
15
|
-
export type EffectRemoteFormPreflightSchema<Input extends
|
|
16
|
-
export type EffectRemoteFormValidateOptions<Input extends
|
|
13
|
+
type NativeRemoteFormPreflightSchema<Input extends NativeRemoteFormInput | void, Output> = Parameters<NativeRemoteForm<Input, Output>["preflight"]>[0];
|
|
14
|
+
type NativeRemoteFormValidateOptions<Input extends NativeRemoteFormInput | void, Output> = NonNullable<Parameters<NativeRemoteForm<Input, Output>["validate"]>[0]>;
|
|
15
|
+
export type EffectRemoteFormPreflightSchema<Input extends NativeRemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Codec<unknown, Input, never, unknown>;
|
|
16
|
+
export type EffectRemoteFormValidateOptions<Input extends NativeRemoteFormInput | void, Output = unknown> = Omit<NativeRemoteFormValidateOptions<Input, Output>, "all" | "includeUntouched" | "preflightOnly"> & {
|
|
17
17
|
readonly all?: boolean;
|
|
18
18
|
readonly includeUntouched?: boolean;
|
|
19
19
|
readonly preflightOnly?: boolean;
|
|
@@ -26,7 +26,6 @@ type EffectRemoteQueryUpdateInput<Update> = Update extends EffectRemoteCommandUp
|
|
|
26
26
|
type EffectRemoteQueryUpdates<Updates extends readonly unknown[]> = Updates & {
|
|
27
27
|
[Index in keyof Updates]: EffectRemoteQueryUpdateInput<Updates[Index]>;
|
|
28
28
|
};
|
|
29
|
-
type NativeRemoteQueryUpdate = RemoteQueryUpdate;
|
|
30
29
|
type EffectRemoteQueryUpdateFunction = (input: never) => EffectRemoteQueryUpdateResource;
|
|
31
30
|
type EffectRemoteLiveQueryUpdateFunction = (input: never) => Stream.Stream<unknown, unknown, unknown>;
|
|
32
31
|
type EffectRemoteQueryUpdateResource = EffectRemoteQueryUpdateBrand & Effect.Effect<unknown, unknown>;
|
|
@@ -41,12 +40,12 @@ export type EffectRemoteCommandCall<Output, ErrorType = never> = Effect.Effect<O
|
|
|
41
40
|
export type EffectRemoteFormSubmit<Output = unknown, ErrorType = never> = Effect.Effect<Output | undefined, RemoteFailure<ErrorType>> & {
|
|
42
41
|
updates: <const Updates extends readonly unknown[]>(...updates: EffectRemoteQueryUpdates<Updates>) => Effect.Effect<Output | undefined, RemoteFailure<ErrorType>>;
|
|
43
42
|
};
|
|
44
|
-
export type EffectRemoteFormEnhanceOptions<Input extends
|
|
43
|
+
export type EffectRemoteFormEnhanceOptions<Input extends NativeRemoteFormInput | void, Output, ErrorType = never> = Omit<Parameters<NativeRemoteForm<Input, Output>["enhance"]>[0] extends (options: infer Options) => unknown ? Options : never, "submit"> & {
|
|
45
44
|
submit: () => EffectRemoteFormSubmit<Output, ErrorType>;
|
|
46
45
|
};
|
|
47
|
-
export type EffectRemoteForm<Input extends
|
|
48
|
-
enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<
|
|
49
|
-
for(id: Parameters<
|
|
46
|
+
export type EffectRemoteForm<Input extends NativeRemoteFormInput | void, Output, ErrorType = never> = EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<NativeRemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
|
|
47
|
+
enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<NativeRemoteForm<Input, Output>["enhance"]>;
|
|
48
|
+
for(id: Parameters<NativeRemoteForm<Input, Output>["for"]>[0]): EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
|
|
50
49
|
preflight(schema: EffectRemoteFormPreflightSchema<Input, Output>): EffectRemoteForm<Input, Output, ErrorType>;
|
|
51
50
|
submit: EffectRemoteFormCallable<Input, Output, ErrorType>;
|
|
52
51
|
validate(options?: EffectRemoteFormValidateOptions<Input, Output>): Effect.Effect<void, RemoteFailure<ErrorType>>;
|
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-Bi7SwVVy.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
|
@@ -0,0 +1,292 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@sveltejs/kit/internal/types";
|
|
2
|
+
/**
|
|
3
|
+
* SvelteKit moved its remote-function types between majors: SvelteKit 2
|
|
4
|
+
* declares them in `@sveltejs/kit`, while SvelteKit 3 (since `3.0.0-next.20`)
|
|
5
|
+
* declares them only in the `$app/server` ambient module, which SvelteKit 2
|
|
6
|
+
* does not re-export types from. Importing from either location therefore
|
|
7
|
+
* breaks the other major, and the shapes cannot be derived from the
|
|
8
|
+
* `$app/server` value exports because their overload sets share a type-arity
|
|
9
|
+
* with incompatible constraints. This module vendors the surface SER needs.
|
|
10
|
+
* The shapes are identical in SvelteKit 2.69+ and 3.0.0-next.25 except
|
|
11
|
+
* `validate`, whose options here form the superset of both majors.
|
|
12
|
+
*/
|
|
13
|
+
type MaybeArray<T> = T | T[];
|
|
14
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
15
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
16
|
+
type DeepPartial<T> = T extends Record<PropertyKey, unknown> | unknown[] ? {
|
|
17
|
+
[K in keyof T]?: T[K] extends Record<PropertyKey, unknown> | unknown[] ? DeepPartial<T[K]> : T[K];
|
|
18
|
+
} : T | undefined;
|
|
19
|
+
type WillRecurseIndefinitely<T> = unknown extends T ? true : string extends keyof T ? true : false;
|
|
20
|
+
type KeysOfUnion<T> = T extends unknown ? keyof T : never;
|
|
21
|
+
type ValueOfUnionKey<T, K extends PropertyKey> = T extends unknown ? K extends keyof T ? T[K] : never : never;
|
|
22
|
+
/**
|
|
23
|
+
* Data shape SvelteKit accepts for a remote form submission. Mirrors
|
|
24
|
+
* SvelteKit's `RemoteFormInput`.
|
|
25
|
+
*
|
|
26
|
+
* @since 4.2.6
|
|
27
|
+
*/
|
|
28
|
+
export interface NativeRemoteFormInput {
|
|
29
|
+
[key: string]: MaybeArray<string | number | boolean | File | NativeRemoteFormInput> | undefined;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* A single validation issue reported for a remote form field. Mirrors
|
|
33
|
+
* SvelteKit's `RemoteFormIssue`.
|
|
34
|
+
*
|
|
35
|
+
* @since 4.2.6
|
|
36
|
+
*/
|
|
37
|
+
export interface NativeRemoteFormIssue {
|
|
38
|
+
message: string;
|
|
39
|
+
path: Array<string | number>;
|
|
40
|
+
}
|
|
41
|
+
type InputTypeMap = {
|
|
42
|
+
text: string;
|
|
43
|
+
email: string;
|
|
44
|
+
password: string;
|
|
45
|
+
url: string;
|
|
46
|
+
tel: string;
|
|
47
|
+
search: string;
|
|
48
|
+
number: number;
|
|
49
|
+
range: number;
|
|
50
|
+
date: string;
|
|
51
|
+
"datetime-local": string;
|
|
52
|
+
time: string;
|
|
53
|
+
month: string;
|
|
54
|
+
week: string;
|
|
55
|
+
color: string;
|
|
56
|
+
checkbox: boolean | string[];
|
|
57
|
+
radio: string;
|
|
58
|
+
file: File;
|
|
59
|
+
hidden: string | number | boolean;
|
|
60
|
+
submit: string | number | boolean;
|
|
61
|
+
button: string;
|
|
62
|
+
reset: string;
|
|
63
|
+
image: string;
|
|
64
|
+
select: string;
|
|
65
|
+
"select multiple": string[];
|
|
66
|
+
"file multiple": File[];
|
|
67
|
+
};
|
|
68
|
+
type NativeRemoteFormFieldType<T> = {
|
|
69
|
+
[K in keyof InputTypeMap]: T extends InputTypeMap[K] ? K : never;
|
|
70
|
+
}[keyof InputTypeMap];
|
|
71
|
+
type InputElementProps<T extends keyof InputTypeMap> = T extends "checkbox" | "radio" ? {
|
|
72
|
+
name: string;
|
|
73
|
+
type: T;
|
|
74
|
+
value?: string;
|
|
75
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
76
|
+
get checked(): boolean;
|
|
77
|
+
set checked(value: boolean);
|
|
78
|
+
readonly defaultChecked?: boolean;
|
|
79
|
+
} : T extends "file" ? {
|
|
80
|
+
name: string;
|
|
81
|
+
type: "file";
|
|
82
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
83
|
+
get files(): FileList | null;
|
|
84
|
+
set files(v: FileList | null);
|
|
85
|
+
} : T extends "select" ? {
|
|
86
|
+
name: string;
|
|
87
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
88
|
+
get value(): string;
|
|
89
|
+
set value(v: string);
|
|
90
|
+
} : T extends "select multiple" ? {
|
|
91
|
+
name: string;
|
|
92
|
+
multiple: true;
|
|
93
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
94
|
+
get value(): string[];
|
|
95
|
+
set value(v: string[]);
|
|
96
|
+
} : T extends "text" ? {
|
|
97
|
+
name: string;
|
|
98
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
99
|
+
get value(): string | number;
|
|
100
|
+
set value(v: string | number);
|
|
101
|
+
readonly defaultValue?: string | number;
|
|
102
|
+
} : {
|
|
103
|
+
name: string;
|
|
104
|
+
type: T;
|
|
105
|
+
"aria-invalid": boolean | "false" | "true" | undefined;
|
|
106
|
+
get value(): string | number;
|
|
107
|
+
set value(v: string | number);
|
|
108
|
+
readonly defaultValue?: string | number;
|
|
109
|
+
};
|
|
110
|
+
type NativeRemoteFormFieldMethods<T> = {
|
|
111
|
+
/** The values that will be submitted. */
|
|
112
|
+
value(): DeepPartial<T>;
|
|
113
|
+
/** Set the values that will be submitted. */
|
|
114
|
+
set(input: DeepPartial<T>): DeepPartial<T>;
|
|
115
|
+
/** Whether the field or any nested field has been interacted with since the form was mounted. */
|
|
116
|
+
touched(): boolean;
|
|
117
|
+
/** Whether the field or any nested field has been edited since the form was mounted. */
|
|
118
|
+
dirty(): boolean;
|
|
119
|
+
/** Validation issues, if any. */
|
|
120
|
+
issues(): NativeRemoteFormIssue[] | undefined;
|
|
121
|
+
};
|
|
122
|
+
type AsArgs<Type extends keyof InputTypeMap, Value> = Type extends "checkbox" ? Value extends string[] ? [type: Type, value: Value[number] | (string & {})] : Value extends boolean ? [type: Type] | [type: Type, value: boolean] : [type: Type] | [type: Type, value: Value | (string & {})] : Type extends "submit" | "hidden" ? Value extends string ? [type: Type, value: Value | (string & {})] : [type: Type, value: Value] : Type extends "radio" ? [type: Type, value: Value | (string & {})] : Type extends "file" | "file multiple" ? [type: Type] : [type: Type] | [type: Type, value: Value | undefined];
|
|
123
|
+
type NativeRemoteFormFieldValue = string | string[] | number | boolean | File | File[];
|
|
124
|
+
type NativeRemoteFormField<Value extends NativeRemoteFormFieldValue> = NativeRemoteFormFieldMethods<Value> & {
|
|
125
|
+
/** Returns spreadable input-element props for the given input type. */
|
|
126
|
+
as<T extends NativeRemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
127
|
+
};
|
|
128
|
+
type NativeRemoteFormFieldContainer<Value> = NativeRemoteFormFieldMethods<Value> & {
|
|
129
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
130
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
131
|
+
};
|
|
132
|
+
type UnknownField<Value> = NativeRemoteFormFieldMethods<Value> & {
|
|
133
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
134
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
135
|
+
/** Returns spreadable input-element props for the given input type. */
|
|
136
|
+
as<T extends NativeRemoteFormFieldType<Value>>(...args: AsArgs<T, Value>): InputElementProps<T>;
|
|
137
|
+
} & {
|
|
138
|
+
[key: string | number]: UnknownField<any>;
|
|
139
|
+
};
|
|
140
|
+
type RecursiveFormFields = NativeRemoteFormFieldContainer<any> & {
|
|
141
|
+
[key: string | number]: UnknownField<any>;
|
|
142
|
+
};
|
|
143
|
+
type NativeRemoteFormFields<T> = WillRecurseIndefinitely<T> extends true ? RecursiveFormFields : NonNullable<T> extends string | number | boolean | File ? NativeRemoteFormField<Extract<NonNullable<T>, NativeRemoteFormFieldValue>> : [NonNullable<T>] extends [string[] | File[]] ? NativeRemoteFormField<Extract<NonNullable<T>, NativeRemoteFormFieldValue>> & {
|
|
144
|
+
[K in number]: NativeRemoteFormField<Extract<NonNullable<T>[number], NativeRemoteFormFieldValue>>;
|
|
145
|
+
} : [NonNullable<T>] extends [Array<infer U>] ? NativeRemoteFormFieldContainer<NonNullable<T>> & {
|
|
146
|
+
[K in number]: NativeRemoteFormFields<U>;
|
|
147
|
+
} : NativeRemoteFormFieldContainer<T> & {
|
|
148
|
+
[K in KeysOfUnion<T>]-?: NativeRemoteFormFields<ValueOfUnionKey<T, K>>;
|
|
149
|
+
};
|
|
150
|
+
type NativeRemoteFormFieldsRoot<Input extends NativeRemoteFormInput | void> = IsAny<Input> extends true ? RecursiveFormFields : Input extends void ? {
|
|
151
|
+
/** Validation issues, if any. */
|
|
152
|
+
issues(): NativeRemoteFormIssue[] | undefined;
|
|
153
|
+
/** Validation issues belonging to this or any of the fields that belong to it, if any. */
|
|
154
|
+
allIssues(): NativeRemoteFormIssue[] | undefined;
|
|
155
|
+
} : NativeRemoteFormFields<Input>;
|
|
156
|
+
type ExtractId<Input> = Input extends {
|
|
157
|
+
id: infer Id;
|
|
158
|
+
} ? Id extends string | number ? Id : string | number : string | number;
|
|
159
|
+
/**
|
|
160
|
+
* The form instance received inside an `enhance` callback. Mirrors SvelteKit's
|
|
161
|
+
* `RemoteFormEnhanceInstance`.
|
|
162
|
+
*
|
|
163
|
+
* @since 4.2.6
|
|
164
|
+
*/
|
|
165
|
+
export type NativeRemoteFormEnhanceInstance<Input extends NativeRemoteFormInput | void = NativeRemoteFormInput | void, Output = unknown> = Omit<NativeRemoteForm<Input, Output>, "enhance" | "element"> & {
|
|
166
|
+
readonly element: HTMLFormElement;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* The callback passed to a remote form's `enhance` method. Mirrors SvelteKit's
|
|
170
|
+
* `RemoteFormEnhanceCallback`.
|
|
171
|
+
*
|
|
172
|
+
* @since 4.2.6
|
|
173
|
+
*/
|
|
174
|
+
export type NativeRemoteFormEnhanceCallback<Input extends NativeRemoteFormInput | void = NativeRemoteFormInput | void, Output = unknown> = (form: NativeRemoteFormEnhanceInstance<Input, Output>) => MaybePromise<void>;
|
|
175
|
+
/**
|
|
176
|
+
* SvelteKit's `RemoteForm` surface. `validate` accepts the superset of the
|
|
177
|
+
* SvelteKit 2 (`includeUntouched`) and SvelteKit 3 (`all`) options.
|
|
178
|
+
*
|
|
179
|
+
* @since 4.2.6
|
|
180
|
+
*/
|
|
181
|
+
export type NativeRemoteForm<Input extends NativeRemoteFormInput | void, Output> = {
|
|
182
|
+
/** Attachment that intercepts the form submission on the client to prevent a full page reload. */
|
|
183
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
184
|
+
method: "POST";
|
|
185
|
+
/** The URL to send the form to. */
|
|
186
|
+
action: string;
|
|
187
|
+
/** The `<form>` element this instance is currently attached to, if any. */
|
|
188
|
+
get element(): HTMLFormElement | null;
|
|
189
|
+
/** Submit the currently attached form programmatically. */
|
|
190
|
+
submit(): Promise<boolean> & {
|
|
191
|
+
updates: (...updates: NativeRemoteQueryUpdate[]) => Promise<boolean>;
|
|
192
|
+
};
|
|
193
|
+
/** Influences what happens when the form is submitted. */
|
|
194
|
+
enhance(callback: NativeRemoteFormEnhanceCallback<Input, Output>): {
|
|
195
|
+
method: "POST";
|
|
196
|
+
action: string;
|
|
197
|
+
[attachment: symbol]: (node: HTMLFormElement) => void;
|
|
198
|
+
};
|
|
199
|
+
/** Create an instance of the form for the given `id`. */
|
|
200
|
+
for(id: ExtractId<Input>): Omit<NativeRemoteForm<Input, Output>, "for">;
|
|
201
|
+
/** Preflight checks. */
|
|
202
|
+
preflight(schema: StandardSchemaV1<Input, unknown>): NativeRemoteForm<Input, Output>;
|
|
203
|
+
/** Validate the form contents programmatically. */
|
|
204
|
+
validate(options?: {
|
|
205
|
+
/** SvelteKit 3: also show validation issues of fields that have not been edited and blurred yet. */
|
|
206
|
+
all?: boolean;
|
|
207
|
+
/** SvelteKit 2: also show validation issues of fields that have not been touched yet. */
|
|
208
|
+
includeUntouched?: boolean;
|
|
209
|
+
/** Only run the `preflight` validation. */
|
|
210
|
+
preflightOnly?: boolean;
|
|
211
|
+
}): Promise<void>;
|
|
212
|
+
/** The result of the form submission. */
|
|
213
|
+
get result(): Output | undefined;
|
|
214
|
+
/** The number of pending submissions. */
|
|
215
|
+
get pending(): number;
|
|
216
|
+
/** True if the form has been submitted at least once. */
|
|
217
|
+
get submitted(): boolean;
|
|
218
|
+
/** Access form fields using object notation. */
|
|
219
|
+
fields: NativeRemoteFormFieldsRoot<Input>;
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* SvelteKit's `RemoteResource` shape shared by query, live query, and
|
|
223
|
+
* prerender resources.
|
|
224
|
+
*
|
|
225
|
+
* @since 4.2.6
|
|
226
|
+
*/
|
|
227
|
+
export type NativeRemoteResource<T> = Promise<T> & {
|
|
228
|
+
/** The error in case the query fails. */
|
|
229
|
+
get error(): unknown;
|
|
230
|
+
/** `true` before the first result is available and during refreshes. */
|
|
231
|
+
get loading(): boolean;
|
|
232
|
+
} & ({
|
|
233
|
+
/** The current value of the query. Undefined until `ready` is `true`. */
|
|
234
|
+
get current(): undefined;
|
|
235
|
+
ready: false;
|
|
236
|
+
} | {
|
|
237
|
+
/** The current value of the query. Undefined until `ready` is `true`. */
|
|
238
|
+
get current(): T;
|
|
239
|
+
ready: true;
|
|
240
|
+
});
|
|
241
|
+
/**
|
|
242
|
+
* SvelteKit's `RemoteQuery` resource surface.
|
|
243
|
+
*
|
|
244
|
+
* @since 4.2.6
|
|
245
|
+
*/
|
|
246
|
+
export type NativeRemoteQuery<T> = NativeRemoteResource<T> & {
|
|
247
|
+
/** Update the value of the query without re-fetching it. */
|
|
248
|
+
set(value: T): void;
|
|
249
|
+
/** Re-fetch the query from the server. */
|
|
250
|
+
refresh(): Promise<void>;
|
|
251
|
+
/** Temporarily override a query's value during a single-flight mutation. */
|
|
252
|
+
withOverride(update: (current: T) => T): NativeRemoteQueryOverride;
|
|
253
|
+
};
|
|
254
|
+
/**
|
|
255
|
+
* SvelteKit's `RemoteLiveQuery` resource surface.
|
|
256
|
+
*
|
|
257
|
+
* @since 4.2.6
|
|
258
|
+
*/
|
|
259
|
+
export type NativeRemoteLiveQuery<T> = NativeRemoteResource<T> & AsyncIterable<T> & {
|
|
260
|
+
/** `true` if the live stream is currently connected. */
|
|
261
|
+
readonly connected: boolean;
|
|
262
|
+
/** `true` once the current live stream iterator is done. */
|
|
263
|
+
readonly done: boolean;
|
|
264
|
+
/** Reconnects the live stream immediately. */
|
|
265
|
+
reconnect(): Promise<void>;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* SvelteKit's `RemoteQueryFunction`.
|
|
269
|
+
*
|
|
270
|
+
* @since 4.2.6
|
|
271
|
+
*/
|
|
272
|
+
export type NativeRemoteQueryFunction<Input, Output, _Validated = Input> = (arg: undefined extends Input ? Input | void : Input) => NativeRemoteQuery<Output>;
|
|
273
|
+
/**
|
|
274
|
+
* SvelteKit's `RemoteLiveQueryFunction`.
|
|
275
|
+
*
|
|
276
|
+
* @since 4.2.6
|
|
277
|
+
*/
|
|
278
|
+
export type NativeRemoteLiveQueryFunction<Input, Output, _Validated = Input> = (arg: undefined extends Input ? Input | void : Input) => NativeRemoteLiveQuery<Output>;
|
|
279
|
+
/**
|
|
280
|
+
* SvelteKit's `RemoteQueryOverride`.
|
|
281
|
+
*
|
|
282
|
+
* @since 4.2.6
|
|
283
|
+
*/
|
|
284
|
+
export type NativeRemoteQueryOverride = () => void;
|
|
285
|
+
/**
|
|
286
|
+
* Update selection accepted by SvelteKit's command and form `updates(...)`
|
|
287
|
+
* methods. Mirrors SvelteKit's `RemoteQueryUpdate`.
|
|
288
|
+
*
|
|
289
|
+
* @since 4.2.6
|
|
290
|
+
*/
|
|
291
|
+
export type NativeRemoteQueryUpdate = NativeRemoteQuery<any> | NativeRemoteLiveQuery<any> | NativeRemoteQueryFunction<any, any> | NativeRemoteLiveQueryFunction<any, any> | NativeRemoteQueryOverride;
|
|
292
|
+
export {};
|
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-Dxb9zr99.js";
|
|
2
2
|
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { EffectLike, EffectRemoteCommand, EffectRemoteForm, EffectRemotePrerenderFunction, PrerenderOptions, QueryFactory, RemoteFormHandler, RemoteHandler, SchemaEncodedInput, SchemaInput, StandardSchema, StandardSchemaInput, StandardSchemaOutput } from "./types.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { NativeRemoteFormInput } from "../remote/native-types.js";
|
|
3
3
|
import { type Schema } from "effect";
|
|
4
4
|
type FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S["Encoded"]> : never;
|
|
5
|
-
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends
|
|
6
|
-
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends
|
|
5
|
+
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends NativeRemoteFormInput ? NormalizeFormEncoded<Input> : never;
|
|
6
|
+
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends NativeRemoteFormInput ? StandardSchemaInput<S> : NativeRemoteFormInput;
|
|
7
7
|
type FormScalar = string | number | boolean | File;
|
|
8
8
|
type NormalizeFormEncoded<Value> = Value extends FormScalar ? Value : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>> : Value extends object ? NormalizeFormObject<Value> : Value;
|
|
9
9
|
type NormalizeFormObject<Value> = {
|
|
@@ -116,7 +116,7 @@ export declare function Command<S extends StandardSchema, A, E = never, R = neve
|
|
|
116
116
|
* @returns A SvelteKit form function.
|
|
117
117
|
*/
|
|
118
118
|
export declare function Form<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>): EffectRemoteForm<void, A, E>;
|
|
119
|
-
export declare function Form<Input extends
|
|
119
|
+
export declare function Form<Input extends NativeRemoteFormInput, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteFormHandler<Input, A, E, R>): EffectRemoteForm<Input, A, E>;
|
|
120
120
|
export declare function Form<S extends Schema.Top, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;
|
|
121
121
|
export declare function Form<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;
|
|
122
122
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type NativeTransport = Readonly<Record<string, {
|
|
2
2
|
readonly encode: (value: unknown) => false | unknown;
|
|
3
3
|
}>>;
|
|
4
|
-
/** Converts SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
5
|
-
export declare function make_remote_live_snapshot_encoder(transport: NativeTransport): (value: unknown) => string;
|
|
4
|
+
/** Converts available SvelteKit transport hooks into a devalue live snapshot encoder. */
|
|
5
|
+
export declare function make_remote_live_snapshot_encoder(transport: NativeTransport | undefined): (value: unknown) => string;
|
package/.dist/server/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NativeRemoteFormInput, NativeRemoteQuery, NativeRemoteQueryOverride } from "../remote/native-types.js";
|
|
2
2
|
import type { EffectRemoteCommandCall as ClientEffectRemoteCommandCall, EffectRemoteForm as ClientEffectRemoteForm, EffectRemoteQueryUpdateBrand as ClientEffectRemoteQueryUpdateBrand } from "../remote/client.js";
|
|
3
3
|
import type { Effect, Layer, ManagedRuntime, Schema, Stream } from "effect";
|
|
4
4
|
import type { create_form_error, RemoteFailure } from "../remote/shared.js";
|
|
@@ -339,7 +339,7 @@ export interface CommandFactory {
|
|
|
339
339
|
*/
|
|
340
340
|
export interface FormFactory {
|
|
341
341
|
<A, E = never, R = never>(validate_or_handler: EffectLike<A, E, R> | RemoteFormHandler<void, A, E, R>): EffectRemoteForm<void, A, E>;
|
|
342
|
-
<Input extends
|
|
342
|
+
<Input extends NativeRemoteFormInput, A, E = never, R = never>(validate_or_handler: "unchecked", maybe_handler: RemoteFormHandler<Input, A, E, R>): EffectRemoteForm<Input, A, E>;
|
|
343
343
|
<S extends Schema.Top, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<SchemaInput<S>, A, E, R>): EffectRemoteForm<FormSchemaEncodedInput<S>, A, E>;
|
|
344
344
|
<S extends StandardSchema, A, E = never, R = never>(validate_or_handler: S, maybe_handler: RemoteFormHandler<StandardSchemaOutput<S>, A, E, R>): EffectRemoteForm<FormStandardSchemaInput<S>, A, E>;
|
|
345
345
|
}
|
|
@@ -401,13 +401,13 @@ export type EffectRemotePrerenderFunction<Input, A, E = never> = [Input] extends
|
|
|
401
401
|
*
|
|
402
402
|
* @since 2.0.0
|
|
403
403
|
*/
|
|
404
|
-
export type EffectRemoteQuery<A, E = never> = ClientEffectRemoteQueryUpdateBrand & Effect.Effect<A, RemoteFailure<E>, never> & Pick<
|
|
404
|
+
export type EffectRemoteQuery<A, E = never> = ClientEffectRemoteQueryUpdateBrand & Effect.Effect<A, RemoteFailure<E>, never> & Pick<NativeRemoteQuery<A>, "set"> & {
|
|
405
405
|
readonly current: A | undefined;
|
|
406
406
|
readonly error: unknown;
|
|
407
407
|
readonly loading: boolean;
|
|
408
408
|
readonly ready: boolean;
|
|
409
409
|
readonly refresh: () => Effect.Effect<void, unknown, never>;
|
|
410
|
-
readonly withOverride: (update: (current: A) => A) =>
|
|
410
|
+
readonly withOverride: (update: (current: A) => A) => NativeRemoteQueryOverride;
|
|
411
411
|
};
|
|
412
412
|
/**
|
|
413
413
|
* Effect-returning remote query function with SvelteKit query resource methods
|
|
@@ -477,10 +477,10 @@ export type EffectRemoteCommand<Input, A, E = never> = ([Input] extends [void] ?
|
|
|
477
477
|
* @template Input - Data shape submitted by the remote form.
|
|
478
478
|
* @template A - Successful value produced by the form handler.
|
|
479
479
|
*/
|
|
480
|
-
export type EffectRemoteForm<Input extends
|
|
480
|
+
export type EffectRemoteForm<Input extends NativeRemoteFormInput | void, A, E = never> = ClientEffectRemoteForm<Input, A, E>;
|
|
481
481
|
type FormSchemaEncodedInput<S> = S extends Schema.Top ? FormRemoteInput<S["Encoded"]> : never;
|
|
482
|
-
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends
|
|
483
|
-
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends
|
|
482
|
+
type FormRemoteInput<Input> = NormalizeFormEncoded<Input> extends NativeRemoteFormInput ? NormalizeFormEncoded<Input> : never;
|
|
483
|
+
type FormStandardSchemaInput<S> = StandardSchemaInput<S> extends NativeRemoteFormInput ? StandardSchemaInput<S> : NativeRemoteFormInput;
|
|
484
484
|
type FormScalar = string | number | boolean | File;
|
|
485
485
|
type NormalizeFormEncoded<Value> = Value extends FormScalar ? Value : Value extends ReadonlyArray<infer Item> ? Array<NormalizeFormEncoded<Item>> : Value extends object ? NormalizeFormObject<Value> : Value;
|
|
486
486
|
type NormalizeFormObject<Value> = {
|