svelte-effect-runtime 2.2.1 → 2.3.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/mod.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import type { ErrorEffectFactory, RedirectEffectFactory } from "./server/control-flow.js";
1
2
  import type { RequestEvent as RequestEventShape } from "./server/runtime.js";
2
3
  import type { CommandFactory, FormFactory, PrerenderFactory, QueryFactory, ServerRuntimeFactory } from "./server/types.js";
3
4
  import type { Context, Layer, ManagedRuntime } from "effect";
@@ -101,6 +102,21 @@ export declare const Query: QueryFactory;
101
102
  * @since 2.0.0
102
103
  */
103
104
  export declare const Command: CommandFactory;
105
+ /**
106
+ * SvelteKit HTTP error control-flow export for `.remote.ts` files imported
107
+ * from the root entrypoint. The Vite plugin rewrites it to the real server
108
+ * implementation.
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { Error } from "svelte-effect-runtime";
113
+ *
114
+ * return yield* Error("NotFound", "Post not found");
115
+ * ```
116
+ *
117
+ * @since 2.3.0
118
+ */
119
+ export declare const Error: ErrorEffectFactory;
104
120
  /**
105
121
  * Remote form factory export for `.remote.ts` files imported from the root
106
122
  * entrypoint. The Vite plugin rewrites it to the real server implementation.
@@ -130,6 +146,21 @@ export declare const Form: FormFactory;
130
146
  * @since 2.0.0
131
147
  */
132
148
  export declare const Prerender: PrerenderFactory;
149
+ /**
150
+ * SvelteKit redirect control-flow export for `.remote.ts` files imported from
151
+ * the root entrypoint. The Vite plugin rewrites it to the real server
152
+ * implementation.
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { Redirect } from "svelte-effect-runtime";
157
+ *
158
+ * return yield* Redirect("SeeOther", "/posts");
159
+ * ```
160
+ *
161
+ * @since 2.3.0
162
+ */
163
+ export declare const Redirect: RedirectEffectFactory;
133
164
  /**
134
165
  * Current SvelteKit request event service export for `.remote.ts` files
135
166
  * imported from the root entrypoint. The Vite plugin rewrites it to the real
@@ -165,6 +196,8 @@ export { is_form_error, is_remote_http_error, is_remote_transport_error, is_remo
165
196
  /** Re-export app setup helpers so users can import them from root. */
166
197
  export { effect, type EffectOptions } from "./vite.js";
167
198
  /** Re-export server helper types from the root entrypoint. */
199
+ export type { ErrorEffectFactory, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectStatus, RedirectStatusName, } from "./server/control-flow.js";
200
+ /** Re-export server helper types from the root entrypoint. */
168
201
  export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, SchemaInput, ServerRuntimeFactory, StandardSchema, } from "./server/types.js";
169
202
  /**
170
203
  * Creates the Svelte preprocessor that lowers script and markup `yield*`
package/.dist/mod.js CHANGED
@@ -87,6 +87,21 @@ const Query = Object.assign(make_server_only_function("Query"), {
87
87
  */
88
88
  const Command = make_server_only_function("Command");
89
89
  /**
90
+ * SvelteKit HTTP error control-flow export for `.remote.ts` files imported
91
+ * from the root entrypoint. The Vite plugin rewrites it to the real server
92
+ * implementation.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { Error } from "svelte-effect-runtime";
97
+ *
98
+ * return yield* Error("NotFound", "Post not found");
99
+ * ```
100
+ *
101
+ * @since 2.3.0
102
+ */
103
+ const Error = make_server_only_function("Error");
104
+ /**
90
105
  * Remote form factory export for `.remote.ts` files imported from the root
91
106
  * entrypoint. The Vite plugin rewrites it to the real server implementation.
92
107
  *
@@ -116,6 +131,21 @@ const Form = make_server_only_function("Form");
116
131
  */
117
132
  const Prerender = make_server_only_function("Prerender");
118
133
  /**
134
+ * SvelteKit redirect control-flow export for `.remote.ts` files imported from
135
+ * the root entrypoint. The Vite plugin rewrites it to the real server
136
+ * implementation.
137
+ *
138
+ * @example
139
+ * ```ts
140
+ * import { Redirect } from "svelte-effect-runtime";
141
+ *
142
+ * return yield* Redirect("SeeOther", "/posts");
143
+ * ```
144
+ *
145
+ * @since 2.3.0
146
+ */
147
+ const Redirect = make_server_only_function("Redirect");
148
+ /**
119
149
  * Current SvelteKit request event service export for `.remote.ts` files
120
150
  * imported from the root entrypoint. The Vite plugin rewrites it to the real
121
151
  * server implementation.
@@ -182,9 +212,9 @@ function make_server_only_function(name) {
182
212
  };
183
213
  }
184
214
  function make_server_only_error(name) {
185
- return /* @__PURE__ */ new Error(`[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to \`svelte-effect-runtime/server\` before evaluation.`);
215
+ return new globalThis.Error(`[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to \`svelte-effect-runtime/server\` before evaluation.`);
186
216
  }
187
217
  //#endregion
188
- export { ClientRuntime, Command, Form, Prerender, Query, RequestEvent, ServerRuntime, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, preprocess };
218
+ export { ClientRuntime, Command, Error, Form, Prerender, Query, Redirect, RequestEvent, ServerRuntime, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, preprocess };
189
219
 
190
220
  //# sourceMappingURL=mod.js.map
package/.dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Result returned by the root Svelte markup preprocessor hook.\n *\n * @since 2.0.0\n */\ninterface MarkupResult {\n code: string;\n}\n\n/**\n * Root preprocessor group shape. The root export keeps transform code lazy so\n * client imports do not pull parser-only dependencies into the browser.\n *\n * @since 2.0.0\n */\ninterface PreprocessGroup {\n name: string;\n markup(\n options: { content: string; filename?: string },\n ): MarkupResult | Promise<MarkupResult>;\n}\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\n \"ServerRuntime\",\n) as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\n) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\n \"Command\",\n) as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\n \"Form\",\n) as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\n \"Prerender\",\n) as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> =\n make_server_only_function(\"RequestEvent\") as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n CommandFactory,\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormFactory,\n FormInvalid,\n PrerenderFactory,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n} from \"$/server/types.ts\";\n\n/**\n * Creates the Svelte preprocessor that lowers script and markup `yield*`\n * expressions. The heavy transform module is loaded lazily so browser imports\n * from the package root stay client-safe.\n *\n * @example\n * ```js\n * import { preprocess } from \"svelte-effect-runtime\";\n *\n * export default {\n * preprocess: [preprocess()],\n * };\n * ```\n *\n * @since 2.0.0\n * @returns A Svelte preprocessor group with an async markup hook.\n */\nexport function preprocess(): PreprocessGroup {\n return {\n name: \"svelte-effect-runtime\",\n\n async markup(options: { content: string; filename?: string }) {\n const runtime = await import(\"./runtime/preprocess.ts\");\n const group = runtime.preprocess();\n\n return await group.markup(options);\n },\n };\n}\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(\n name: string,\n): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): Error {\n return new Error(\n `[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. ` +\n `Ensure the SER Vite plugin is enabled so root imports are rewritten ` +\n `to \\`svelte-effect-runtime/server\\` before evaluation.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6DA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;AACnD,aAAmB,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkBlC,MAAa,gBAAsC,uBACjD,gBACD;;;;;;;;;;;;;;AAeD,MAAa,QAAsB,OAAO,OACxC,0BAA0B,QAAQ,EAClC;CACE,OAAO,0BAA0B,cAAc;CAC/C,MAAM,0BAA0B,aAAa;CAC9C,CACF;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BACrC,UACD;;;;;;;;;;;;;;AAeD,MAAa,OAAoB,0BAC/B,OACD;;;;;;;;;;;;;;;AAgBD,MAAa,YAA8B,0BACzC,YACD;;;;;;;;;;;;;;;AAgBD,MAAa,eACX,0BAA0B,eAAe;;;;;;;;;;;;;;AAe3C,MAAa,8BAGT,0BAA0B,8BAA8B;;;;;;;;;;;;;;;;;;AAoE5D,SAAgB,aAA8B;AAC5C,QAAO;EACL,MAAM;EAEN,MAAM,OAAO,SAAiD;AAI5D,UAAO,OAHS,MAAM,OAAO,4BACP,YAAY,CAEf,OAAO,QAAQ;;EAErC;;AAGH,SAAS,uBAAuB,MAAuB;AACrD,QAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;AACnB,SAAM,uBAAuB,KAAK;;;;AAKxC,SAAS,0BACP,MAC+B;AAC/B,SAAQ,GAAG,UAA4B;AACrC,QAAM,uBAAuB,KAAK;;;AAItC,SAAS,uBAAuB,MAAqB;AACnD,wBAAO,IAAI,MACT,yBAAyB,KAAK,0KAG/B"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type {\n ErrorEffectFactory,\n RedirectEffectFactory,\n} from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Result returned by the root Svelte markup preprocessor hook.\n *\n * @since 2.0.0\n */\ninterface MarkupResult {\n code: string;\n}\n\n/**\n * Root preprocessor group shape. The root export keeps transform code lazy so\n * client imports do not pull parser-only dependencies into the browser.\n *\n * @since 2.0.0\n */\ninterface PreprocessGroup {\n name: string;\n markup(\n options: { content: string; filename?: string },\n ): MarkupResult | Promise<MarkupResult>;\n}\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\n \"ServerRuntime\",\n) as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\n) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\n \"Command\",\n) as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\n \"Error\",\n) as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\n \"Form\",\n) as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\n \"Prerender\",\n) as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\n \"Redirect\",\n) as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> =\n make_server_only_function(\"RequestEvent\") as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n ErrorEffectFactory,\n ErrorStatus,\n ErrorStatusName,\n RedirectEffectFactory,\n RedirectStatus,\n RedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n CommandFactory,\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormFactory,\n FormInvalid,\n PrerenderFactory,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n} from \"$/server/types.ts\";\n\n/**\n * Creates the Svelte preprocessor that lowers script and markup `yield*`\n * expressions. The heavy transform module is loaded lazily so browser imports\n * from the package root stay client-safe.\n *\n * @example\n * ```js\n * import { preprocess } from \"svelte-effect-runtime\";\n *\n * export default {\n * preprocess: [preprocess()],\n * };\n * ```\n *\n * @since 2.0.0\n * @returns A Svelte preprocessor group with an async markup hook.\n */\nexport function preprocess(): PreprocessGroup {\n return {\n name: \"svelte-effect-runtime\",\n\n async markup(options: { content: string; filename?: string }) {\n const runtime = await import(\"./runtime/preprocess.ts\");\n const group = runtime.preprocess();\n\n return await group.markup(options);\n },\n };\n}\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(\n name: string,\n): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n return new globalThis.Error(\n `[SERVER_ONLY_IMPORT]: ${name} is only available in SvelteKit server files. ` +\n `Ensure the SER Vite plugin is enabled so root imports are rewritten ` +\n `to \\`svelte-effect-runtime/server\\` before evaluation.`,\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiEA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;AACnD,aAAmB,KAAK,MAAM;;;;;;;;;;;;;;;;;AAkBlC,MAAa,gBAAsC,uBACjD,gBACD;;;;;;;;;;;;;;AAeD,MAAa,QAAsB,OAAO,OACxC,0BAA0B,QAAQ,EAClC;CACE,OAAO,0BAA0B,cAAc;CAC/C,MAAM,0BAA0B,aAAa;CAC9C,CACF;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BACrC,UACD;;;;;;;;;;;;;;;AAgBD,MAAa,QAA4B,0BACvC,QACD;;;;;;;;;;;;;;AAeD,MAAa,OAAoB,0BAC/B,OACD;;;;;;;;;;;;;;;AAgBD,MAAa,YAA8B,0BACzC,YACD;;;;;;;;;;;;;;;AAgBD,MAAa,WAAkC,0BAC7C,WACD;;;;;;;;;;;;;;;AAgBD,MAAa,eACX,0BAA0B,eAAe;;;;;;;;;;;;;;AAe3C,MAAa,8BAGT,0BAA0B,8BAA8B;;;;;;;;;;;;;;;;;;AA8E5D,SAAgB,aAA8B;AAC5C,QAAO;EACL,MAAM;EAEN,MAAM,OAAO,SAAiD;AAI5D,UAAO,OAHS,MAAM,OAAO,4BACP,YAAY,CAEf,OAAO,QAAQ;;EAErC;;AAGH,SAAS,uBAAuB,MAAuB;AACrD,QAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;AACnB,SAAM,uBAAuB,KAAK;;;;AAKxC,SAAS,0BACP,MAC+B;AAC/B,SAAQ,GAAG,UAA4B;AACrC,QAAM,uBAAuB,KAAK;;;AAItC,SAAS,uBAAuB,MAAgC;AAC9D,QAAO,IAAI,WAAW,MACpB,yBAAyB,KAAK,0KAG/B"}
@@ -63,4 +63,4 @@ export declare function throw_form_error(issues: readonly FormIssue[], invalid:
63
63
  * @returns A more descriptive error.
64
64
  * @internal
65
65
  */
66
- export declare function normalize_remote_helper_error(err: unknown, helper_name: string): Error;
66
+ export declare function normalize_remote_helper_error(err: unknown, helper_name: string): globalThis.Error;
@@ -1,5 +1,6 @@
1
1
  import { create_serialized_remote_failure_envelope } from "./shared.js";
2
2
  import { Cause, Effect, Exit } from "effect";
3
+ import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
3
4
  import { stringify } from "devalue";
4
5
  //#region src/remote/server.ts
5
6
  /**
@@ -26,7 +27,18 @@ async function run_remote_effect(effect, runtime, invalid, error) {
26
27
  * and throws it via SvelteKit's `error`.
27
28
  */
28
29
  function handle_failure(cause, invalid, error) {
29
- const reasons = cause.reasons;
30
+ const reasons = get_cause_reasons(cause);
31
+ /**
32
+ * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.
33
+ */
34
+ for (const reason of reasons) {
35
+ if (!Cause.isDieReason(reason)) continue;
36
+ const defect = reason.defect;
37
+ if (is_sveltekit_control_flow(defect)) throw defect;
38
+ }
39
+ /**
40
+ * Phase 2 — preserve typed form validation failures.
41
+ */
30
42
  for (const reason of reasons) if (Cause.isFailReason(reason)) {
31
43
  const failure = reason.error;
32
44
  if (typeof failure === "object" && failure !== null && failure._tag === "FormError") invalid(400, { issues: failure.issues ?? [] });
@@ -43,7 +55,7 @@ function handle_failure(cause, invalid, error) {
43
55
  * @internal
44
56
  */
45
57
  function encode_remote_failure(cause) {
46
- const reasons = cause.reasons;
58
+ const reasons = get_cause_reasons(cause);
47
59
  for (const reason of reasons) if (Cause.isFailReason(reason)) {
48
60
  const failure = reason.error;
49
61
  const encoded = stringify_failure(failure);
@@ -53,6 +65,12 @@ function encode_remote_failure(cause) {
53
65
  }
54
66
  return stringify({ message: "[UNKNOWN_REMOTE_FAILURE]: Unknown error" });
55
67
  }
68
+ function get_cause_reasons(cause) {
69
+ return cause.reasons ?? [];
70
+ }
71
+ function is_sveltekit_control_flow(value) {
72
+ return isRedirect(value) || isHttpError(value) || isValidationError(value);
73
+ }
56
74
  function stringify_failure(value) {
57
75
  try {
58
76
  return stringify(value);
@@ -124,8 +142,8 @@ function throw_form_error(issues, invalid) {
124
142
  */
125
143
  function normalize_remote_helper_error(err, helper_name) {
126
144
  const message = err instanceof Error ? err.message : String(err);
127
- if (message.includes("Cannot use") || message.includes("outside a route")) return /* @__PURE__ */ new Error(`[REMOTE_HELPER_CONTEXT]: ${helper_name} was called outside a .remote.ts file. Ensure the file is named \`*.remote.ts\` and is located in a route directory.`);
128
- return err instanceof Error ? err : /* @__PURE__ */ new Error(`[REMOTE_HELPER_ERROR]: ${message}`);
145
+ if (message.includes("Cannot use") || message.includes("outside a route")) return new globalThis.Error(`[REMOTE_HELPER_CONTEXT]: ${helper_name} was called outside a .remote.ts file. Ensure the file is named \`*.remote.ts\` and is located in a route directory.`);
146
+ return err instanceof Error ? err : new globalThis.Error(`[REMOTE_HELPER_ERROR]: ${message}`);
129
147
  }
130
148
  //#endregion
131
149
  export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error };
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n effect: Effect.Effect<A, unknown, unknown>,\n runtime: {\n runPromise: (\n e: Effect.Effect<unknown, unknown, unknown>,\n ) => Promise<unknown>;\n },\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): Promise<A> {\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n ) as Exit.Exit<A, unknown>;\n\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n handle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n cause: Cause.Cause<unknown>,\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): never {\n const reasons =\n (cause as unknown as { reasons: Array<{ _tag: string; error?: unknown }> })\n .reasons;\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (\n typeof failure === \"object\" &&\n failure !== null &&\n (failure as Record<string, unknown>)._tag === \"FormError\"\n ) {\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\n [];\n invalid(400, { issues });\n }\n }\n }\n\n const encoded = encode_remote_failure(cause);\n const envelope = create_serialized_remote_failure_envelope(encoded);\n\n error(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n const reasons =\n (cause as unknown as { reasons: Array<{ _tag: string; error?: unknown }> })\n .reasons;\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n\n const encoded = stringify_failure(failure);\n\n if (encoded !== undefined) {\n return encoded;\n }\n\n const serializable_failure = to_serializable_failure(failure);\n const serializable_encoded = stringify_failure(serializable_failure);\n\n if (serializable_encoded !== undefined) {\n return serializable_encoded;\n }\n }\n }\n\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n try {\n return stringify(value);\n } catch {\n return undefined;\n }\n}\n\nfunction to_serializable_failure(\n value: unknown,\n seen = new WeakSet<object>(),\n): unknown {\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n return undefined;\n }\n\n if (!is_object_like(value)) {\n return value;\n }\n\n if (stringify_failure(value) !== undefined) {\n return value;\n }\n\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n const serializable = Array.isArray(value)\n ? value.map((item) => to_serializable_failure(item, seen))\n : to_plain_record(value, seen);\n\n seen.delete(value);\n\n return serializable;\n}\n\nfunction to_plain_record(\n value: object,\n seen: WeakSet<object>,\n): Record<string, unknown> {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const record: Record<string, unknown> = {};\n\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === \"stack\" || !(\"value\" in descriptor)) {\n continue;\n }\n\n record[key] = to_serializable_failure(descriptor.value, seen);\n }\n\n if (value instanceof Error && !(\"message\" in record)) {\n record.message = value.message;\n }\n\n return record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(\n issues: readonly FormIssue[],\n invalid: (status: number, body: unknown) => never,\n): never {\n invalid(400, { issues });\n}\n\n/**\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\n * into clear, actionable messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(\n err: unknown,\n helper_name: string,\n): Error {\n const message = err instanceof Error ? err.message : String(err);\n\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\n return new Error(\n `[REMOTE_HELPER_CONTEXT]: ${helper_name} was called outside a .remote.ts file. ` +\n `Ensure the file is named \\`*.remote.ts\\` and is located in a route directory.`,\n );\n }\n\n return err instanceof Error\n ? err\n : new Error(`[REMOTE_HELPER_ERROR]: ${message}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,eAAsB,kBACpB,QACA,SAKA,SACA,OACY;CACZ,MAAM,OAA8B,MAAM,QAAQ,WAChD,OAAO,KAAK,OAAO,CACpB;AAED,KAAI,KAAK,UAAU,KAAK,CACtB,QAAO,KAAK;AAGd,gBAAe,KAAK,OAAO,SAAS,MAAM;;;;;;;AAQ5C,SAAS,eACP,OACA,SACA,OACO;CACP,MAAM,UACH,MACE;AAEL,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;EACvC,MAAM,UAAU,OAAO;AACvB,MACE,OAAO,YAAY,YACnB,YAAY,QACX,QAAoC,SAAS,YAI9C,SAAQ,KAAK,EAAE,QAFC,QAA8C,UAC5D,EAAE,EACmB,CAAC;;AAQ9B,OAAM,KAFW,0CADD,sBAAsB,MAAM,CACuB,CAE/C;;;;;;;;;;;AAYtB,SAAgB,sBAAsB,OAAqC;CACzE,MAAM,UACH,MACE;AAEL,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;EACvC,MAAM,UAAU,OAAO;EAEvB,MAAM,UAA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,IAAI,UAAU,OAAO,IAAI;AAEhE,KAAI,QAAQ,SAAS,aAAa,IAAI,QAAQ,SAAS,kBAAkB,CACvE,wBAAO,IAAI,MACT,4BAA4B,YAAY,sHAEzC;AAGH,QAAO,eAAe,QAClB,sBACA,IAAI,MAAM,0BAA0B,UAAU"}
1
+ {"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\ntype CauseReason = {\n readonly _tag: string;\n readonly defect?: unknown;\n readonly error?: unknown;\n};\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n effect: Effect.Effect<A, unknown, unknown>,\n runtime: {\n runPromise: (\n e: Effect.Effect<unknown, unknown, unknown>,\n ) => Promise<unknown>;\n },\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): Promise<A> {\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n ) as Exit.Exit<A, unknown>;\n\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n handle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n cause: Cause.Cause<unknown>,\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): never {\n const reasons = get_cause_reasons(cause);\n\n /**\n * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\n */\n for (const reason of reasons) {\n if (!Cause.isDieReason(reason as never)) {\n continue;\n }\n\n const defect = reason.defect;\n\n if (is_sveltekit_control_flow(defect)) {\n throw defect;\n }\n }\n\n /**\n * Phase 2 — preserve typed form validation failures.\n */\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (\n typeof failure === \"object\" &&\n failure !== null &&\n (failure as Record<string, unknown>)._tag === \"FormError\"\n ) {\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\n [];\n invalid(400, { issues });\n }\n }\n }\n\n /**\n * Phase 3 — encode all other failures for the remote client.\n */\n const encoded = encode_remote_failure(cause);\n const envelope = create_serialized_remote_failure_envelope(encoded);\n\n error(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n const reasons = get_cause_reasons(cause);\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n\n const encoded = stringify_failure(failure);\n\n if (encoded !== undefined) {\n return encoded;\n }\n\n const serializable_failure = to_serializable_failure(failure);\n const serializable_encoded = stringify_failure(serializable_failure);\n\n if (serializable_encoded !== undefined) {\n return serializable_encoded;\n }\n }\n }\n\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\n}\n\nfunction get_cause_reasons(\n cause: Cause.Cause<unknown>,\n): readonly CauseReason[] {\n const reasons = (cause as unknown as { reasons?: readonly CauseReason[] })\n .reasons;\n\n return reasons ?? [];\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n return isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n try {\n return stringify(value);\n } catch {\n return undefined;\n }\n}\n\nfunction to_serializable_failure(\n value: unknown,\n seen = new WeakSet<object>(),\n): unknown {\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n return undefined;\n }\n\n if (!is_object_like(value)) {\n return value;\n }\n\n if (stringify_failure(value) !== undefined) {\n return value;\n }\n\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n const serializable = Array.isArray(value)\n ? value.map((item) => to_serializable_failure(item, seen))\n : to_plain_record(value, seen);\n\n seen.delete(value);\n\n return serializable;\n}\n\nfunction to_plain_record(\n value: object,\n seen: WeakSet<object>,\n): Record<string, unknown> {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const record: Record<string, unknown> = {};\n\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === \"stack\" || !(\"value\" in descriptor)) {\n continue;\n }\n\n record[key] = to_serializable_failure(descriptor.value, seen);\n }\n\n if (value instanceof Error && !(\"message\" in record)) {\n record.message = value.message;\n }\n\n return record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(\n issues: readonly FormIssue[],\n invalid: (status: number, body: unknown) => never,\n): never {\n invalid(400, { issues });\n}\n\n/**\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\n * into clear, actionable messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(\n err: unknown,\n helper_name: string,\n): globalThis.Error {\n const message = err instanceof Error ? err.message : String(err);\n\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\n return new globalThis.Error(\n `[REMOTE_HELPER_CONTEXT]: ${helper_name} was called outside a .remote.ts file. ` +\n `Ensure the file is named \\`*.remote.ts\\` and is located in a route directory.`,\n );\n }\n\n return err instanceof Error\n ? err\n : new globalThis.Error(`[REMOTE_HELPER_ERROR]: ${message}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAyBA,eAAsB,kBACpB,QACA,SAKA,SACA,OACY;CACZ,MAAM,OAA8B,MAAM,QAAQ,WAChD,OAAO,KAAK,OAAO,CACpB;AAED,KAAI,KAAK,UAAU,KAAK,CACtB,QAAO,KAAK;AAGd,gBAAe,KAAK,OAAO,SAAS,MAAM;;;;;;;AAQ5C,SAAS,eACP,OACA,SACA,OACO;CACP,MAAM,UAAU,kBAAkB,MAAM;;;;AAKxC,MAAK,MAAM,UAAU,SAAS;AAC5B,MAAI,CAAC,MAAM,YAAY,OAAgB,CACrC;EAGF,MAAM,SAAS,OAAO;AAEtB,MAAI,0BAA0B,OAAO,CACnC,OAAM;;;;;AAOV,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;EACvC,MAAM,UAAU,OAAO;AACvB,MACE,OAAO,YAAY,YACnB,YAAY,QACX,QAAoC,SAAS,YAI9C,SAAQ,KAAK,EAAE,QAFC,QAA8C,UAC5D,EAAE,EACmB,CAAC;;AAW9B,OAAM,KAFW,0CADD,sBAAsB,MAAM,CACuB,CAE/C;;;;;;;;;;;AAYtB,SAAgB,sBAAsB,OAAqC;CACzE,MAAM,UAAU,kBAAkB,MAAM;AAExC,MAAK,MAAM,UAAU,QACnB,KAAI,MAAM,aAAa,OAAgB,EAAE;E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UAAU,YAAY,UAAU;;;;;;;;;;;;;;;;;;;AAoBhD,SAAgB,iBACd,QACA,SACO;AACP,SAAQ,KAAK,EAAE,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;AAsB1B,SAAgB,8BACd,KACA,aACkB;CAClB,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,IAAI;AAEhE,KAAI,QAAQ,SAAS,aAAa,IAAI,QAAQ,SAAS,kBAAkB,CACvE,QAAO,IAAI,WAAW,MACpB,4BAA4B,YAAY,sHAEzC;AAGH,QAAO,eAAe,QAClB,MACA,IAAI,WAAW,MAAM,0BAA0B,UAAU"}
@@ -0,0 +1,193 @@
1
+ import { error as svelte_error } from "@sveltejs/kit";
2
+ import { Effect } from "effect";
3
+ declare const error_status_codes: {
4
+ readonly ProxyAuthenticationRequired: 407;
5
+ readonly RequestHeaderFieldsTooLarge: 431;
6
+ readonly UnavailableForLegalReasons: 451;
7
+ readonly NetworkAuthenticationRequired: 511;
8
+ readonly HttpVersionNotSupported: 505;
9
+ readonly UnprocessableContent: 422;
10
+ readonly UnprocessableEntity: 422;
11
+ readonly InternalServerError: 500;
12
+ readonly FailedDependency: 424;
13
+ readonly PreconditionRequired: 428;
14
+ readonly ServiceUnavailable: 503;
15
+ readonly MisdirectedRequest: 421;
16
+ readonly InsufficientStorage: 507;
17
+ readonly VariantAlsoNegotiates: 506;
18
+ readonly PreconditionFailed: 412;
19
+ readonly MethodNotAllowed: 405;
20
+ readonly GatewayTimeout: 504;
21
+ readonly PaymentRequired: 402;
22
+ readonly UpgradeRequired: 426;
23
+ readonly TooManyRequests: 429;
24
+ readonly LengthRequired: 411;
25
+ readonly NotAcceptable: 406;
26
+ readonly RequestTimeout: 408;
27
+ readonly ContentTooLarge: 413;
28
+ readonly PayloadTooLarge: 413;
29
+ readonly UriTooLong: 414;
30
+ readonly UnsupportedMediaType: 415;
31
+ readonly RangeNotSatisfiable: 416;
32
+ readonly ExpectationFailed: 417;
33
+ readonly ImATeapot: 418;
34
+ readonly BadRequest: 400;
35
+ readonly Unauthorized: 401;
36
+ readonly Forbidden: 403;
37
+ readonly NotFound: 404;
38
+ readonly Conflict: 409;
39
+ readonly Gone: 410;
40
+ readonly Locked: 423;
41
+ readonly TooEarly: 425;
42
+ readonly NotImplemented: 501;
43
+ readonly BadGateway: 502;
44
+ readonly LoopDetected: 508;
45
+ readonly NotExtended: 510;
46
+ };
47
+ declare const redirect_status_codes: {
48
+ readonly MovedPermanently: 301;
49
+ readonly TemporaryRedirect: 307;
50
+ readonly PermanentRedirect: 308;
51
+ readonly MultipleChoices: 300;
52
+ readonly NotModified: 304;
53
+ readonly SwitchProxy: 306;
54
+ readonly SeeOther: 303;
55
+ readonly UseProxy: 305;
56
+ readonly Found: 302;
57
+ };
58
+ type SvelteErrorBody = Parameters<typeof svelte_error>[1];
59
+ /**
60
+ * Named HTTP status accepted by the {@link Error} helper.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const status: ErrorStatusName = "NotFound";
65
+ * ```
66
+ *
67
+ * @since 2.3.0
68
+ */
69
+ export type ErrorStatusName = keyof typeof error_status_codes;
70
+ /**
71
+ * Numeric or named HTTP status accepted by the {@link Error} helper.
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const status: ErrorStatus = "InternalServerError";
76
+ * ```
77
+ *
78
+ * @since 2.3.0
79
+ */
80
+ export type ErrorStatus = ErrorStatusName | number;
81
+ /**
82
+ * Named HTTP status accepted by the {@link Redirect} helper.
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * const status: RedirectStatusName = "TemporaryRedirect";
87
+ * ```
88
+ *
89
+ * @since 2.3.0
90
+ */
91
+ export type RedirectStatusName = keyof typeof redirect_status_codes;
92
+ /**
93
+ * Numeric or named HTTP status accepted by the {@link Redirect} helper.
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * const status: RedirectStatus = "SeeOther";
98
+ * ```
99
+ *
100
+ * @since 2.3.0
101
+ */
102
+ export type RedirectStatus = RedirectStatusName | number;
103
+ /**
104
+ * Callable shape for the exported {@link Error} helper.
105
+ *
106
+ * @example
107
+ * ```ts
108
+ * const fail_not_found: ErrorEffectFactory = Error;
109
+ * ```
110
+ *
111
+ * @since 2.3.0
112
+ */
113
+ export interface ErrorEffectFactory {
114
+ /**
115
+ * Creates an Effect that throws SvelteKit's HTTP error control-flow value.
116
+ *
117
+ * @example
118
+ * ```ts
119
+ * return yield* Error("NotFound", "Post not found");
120
+ * ```
121
+ *
122
+ * @since 2.3.0
123
+ * @param status - Numeric HTTP status or PascalCase status name to pass to
124
+ * SvelteKit's `error` helper.
125
+ * @param body - Optional SvelteKit error body or message forwarded unchanged
126
+ * to SvelteKit.
127
+ * @returns An Effect that never succeeds because SvelteKit takes over request
128
+ * control flow.
129
+ */
130
+ (status: ErrorStatus, body?: SvelteErrorBody): Effect.Effect<never, never, never>;
131
+ }
132
+ /**
133
+ * Callable shape for the exported {@link Redirect} helper.
134
+ *
135
+ * @example
136
+ * ```ts
137
+ * const redirect_after_save: RedirectEffectFactory = Redirect;
138
+ * ```
139
+ *
140
+ * @since 2.3.0
141
+ */
142
+ export interface RedirectEffectFactory {
143
+ /**
144
+ * Creates an Effect that throws SvelteKit's redirect control-flow value.
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * return yield* Redirect("SeeOther", "/posts");
149
+ * ```
150
+ *
151
+ * @since 2.3.0
152
+ * @param status - Numeric redirect status or PascalCase status name to pass
153
+ * to SvelteKit's `redirect` helper.
154
+ * @param location - Target URL forwarded unchanged to SvelteKit.
155
+ * @returns An Effect that never succeeds because SvelteKit takes over request
156
+ * control flow.
157
+ */
158
+ (status: RedirectStatus, location: string | URL): Effect.Effect<never, never, never>;
159
+ }
160
+ /**
161
+ * Creates an Effect that raises SvelteKit's HTTP error control flow.
162
+ *
163
+ * @example
164
+ * ```ts
165
+ * return yield* Error("NotFound", "Post not found");
166
+ * ```
167
+ *
168
+ * @since 2.3.0
169
+ * @param status - Numeric HTTP status or PascalCase status name to pass to
170
+ * SvelteKit's `error` helper.
171
+ * @param body - Optional SvelteKit error body or message forwarded unchanged
172
+ * to SvelteKit.
173
+ * @returns An Effect that never succeeds because SvelteKit takes over request
174
+ * control flow.
175
+ */
176
+ export declare const Error: ErrorEffectFactory;
177
+ /**
178
+ * Creates an Effect that raises SvelteKit's redirect control flow.
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * return yield* Redirect("SeeOther", "/posts");
183
+ * ```
184
+ *
185
+ * @since 2.3.0
186
+ * @param status - Numeric redirect status or PascalCase status name to pass to
187
+ * SvelteKit's `redirect` helper.
188
+ * @param location - Target URL forwarded unchanged to SvelteKit.
189
+ * @returns An Effect that never succeeds because SvelteKit takes over request
190
+ * control flow.
191
+ */
192
+ export declare const Redirect: RedirectEffectFactory;
193
+ export {};
@@ -1,3 +1,5 @@
1
1
  export { Command, Form, Prerender, Query } from "./factories.js";
2
+ export { Error, Redirect } from "./control-flow.js";
2
3
  export { get_server_runtime_or_throw, RequestEvent, ServerRuntime, } from "./runtime.js";
4
+ export type { ErrorEffectFactory, ErrorStatus, ErrorStatusName, RedirectEffectFactory, RedirectStatus, RedirectStatusName, } from "./control-flow.js";
3
5
  export type { CommandFactory, EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormFactory, FormInvalid, PrerenderFactory, PrerenderOptions, QueryBatchFactory, QueryFactory, QueryLiveFactory, RemoteFormHandler, RemoteHandler, RemoteLiveHandler, SchemaInput, ServerRuntimeFactory, StandardSchema, } from "./types.js";
package/.dist/server.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { Command, Form, get_server_runtime_or_throw, Prerender, Query, RequestEvent, ServerRuntime, } from "./server/index.js";
2
- export type { EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, FormInvalid, PrerenderOptions, RemoteFormHandler, RemoteHandler, SchemaInput, StandardSchema, } from "./server/index.js";
1
+ export { Command, Error, Form, get_server_runtime_or_throw, Prerender, Query, Redirect, RequestEvent, ServerRuntime, } from "./server/index.js";
2
+ export type { EffectLike, EffectRemoteBatchHandler, EffectRemoteCommand, EffectRemoteForm, EffectRemoteFunction, EffectRemoteLiveQuery, EffectRemoteLiveQueryFunction, EffectRemoteLiveQueryResource, EffectRemoteLiveSource, EffectRemoteQuery, EffectRemoteQueryFunction, ErrorEffectFactory, ErrorStatus, ErrorStatusName, FormInvalid, PrerenderOptions, RedirectEffectFactory, RedirectStatus, RedirectStatusName, RemoteFormHandler, RemoteHandler, SchemaInput, StandardSchema, } from "./server/index.js";
package/.dist/server.js CHANGED
@@ -3,7 +3,7 @@ import { t as copy_property_descriptors } from "./chunks/descriptors-CU2g4U_i.js
3
3
  import { normalize_remote_helper_error, run_remote_effect } from "./remote/server.js";
4
4
  import { Context, Effect, Layer, ManagedRuntime, Schema, Stream } from "effect";
5
5
  import { command, form, getRequestEvent, prerender, query } from "$app/server";
6
- import { error, invalid } from "@sveltejs/kit";
6
+ import { error, invalid, redirect } from "@sveltejs/kit";
7
7
  //#region src/server/schema.ts
8
8
  /**
9
9
  * Checks whether a value is the string sentinel for unchecked remotes.
@@ -524,6 +524,114 @@ function Prerender(validate_or_handler, maybe_handler_or_options, maybe_options)
524
524
  }
525
525
  }
526
526
  //#endregion
527
- export { Command, Form, Prerender, Query, RequestEvent, ServerRuntime, get_server_runtime_or_throw };
527
+ //#region src/server/control-flow.ts
528
+ const error_status_codes = {
529
+ ProxyAuthenticationRequired: 407,
530
+ RequestHeaderFieldsTooLarge: 431,
531
+ UnavailableForLegalReasons: 451,
532
+ NetworkAuthenticationRequired: 511,
533
+ HttpVersionNotSupported: 505,
534
+ UnprocessableContent: 422,
535
+ UnprocessableEntity: 422,
536
+ InternalServerError: 500,
537
+ FailedDependency: 424,
538
+ PreconditionRequired: 428,
539
+ ServiceUnavailable: 503,
540
+ MisdirectedRequest: 421,
541
+ InsufficientStorage: 507,
542
+ VariantAlsoNegotiates: 506,
543
+ PreconditionFailed: 412,
544
+ MethodNotAllowed: 405,
545
+ GatewayTimeout: 504,
546
+ PaymentRequired: 402,
547
+ UpgradeRequired: 426,
548
+ TooManyRequests: 429,
549
+ LengthRequired: 411,
550
+ NotAcceptable: 406,
551
+ RequestTimeout: 408,
552
+ ContentTooLarge: 413,
553
+ PayloadTooLarge: 413,
554
+ UriTooLong: 414,
555
+ UnsupportedMediaType: 415,
556
+ RangeNotSatisfiable: 416,
557
+ ExpectationFailed: 417,
558
+ ImATeapot: 418,
559
+ BadRequest: 400,
560
+ Unauthorized: 401,
561
+ Forbidden: 403,
562
+ NotFound: 404,
563
+ Conflict: 409,
564
+ Gone: 410,
565
+ Locked: 423,
566
+ TooEarly: 425,
567
+ NotImplemented: 501,
568
+ BadGateway: 502,
569
+ LoopDetected: 508,
570
+ NotExtended: 510
571
+ };
572
+ const redirect_status_codes = {
573
+ MovedPermanently: 301,
574
+ TemporaryRedirect: 307,
575
+ PermanentRedirect: 308,
576
+ MultipleChoices: 300,
577
+ NotModified: 304,
578
+ SwitchProxy: 306,
579
+ SeeOther: 303,
580
+ UseProxy: 305,
581
+ Found: 302
582
+ };
583
+ /**
584
+ * Creates an Effect that raises SvelteKit's HTTP error control flow.
585
+ *
586
+ * @example
587
+ * ```ts
588
+ * return yield* Error("NotFound", "Post not found");
589
+ * ```
590
+ *
591
+ * @since 2.3.0
592
+ * @param status - Numeric HTTP status or PascalCase status name to pass to
593
+ * SvelteKit's `error` helper.
594
+ * @param body - Optional SvelteKit error body or message forwarded unchanged
595
+ * to SvelteKit.
596
+ * @returns An Effect that never succeeds because SvelteKit takes over request
597
+ * control flow.
598
+ */
599
+ const Error$1 = (status, body) => {
600
+ const resolved_status = resolve_error_status(status);
601
+ return Effect.sync(() => {
602
+ error(resolved_status, body);
603
+ });
604
+ };
605
+ /**
606
+ * Creates an Effect that raises SvelteKit's redirect control flow.
607
+ *
608
+ * @example
609
+ * ```ts
610
+ * return yield* Redirect("SeeOther", "/posts");
611
+ * ```
612
+ *
613
+ * @since 2.3.0
614
+ * @param status - Numeric redirect status or PascalCase status name to pass to
615
+ * SvelteKit's `redirect` helper.
616
+ * @param location - Target URL forwarded unchanged to SvelteKit.
617
+ * @returns An Effect that never succeeds because SvelteKit takes over request
618
+ * control flow.
619
+ */
620
+ const Redirect = (status, location) => {
621
+ const resolved_status = resolve_redirect_status(status);
622
+ return Effect.sync(() => {
623
+ redirect(resolved_status, location);
624
+ });
625
+ };
626
+ function resolve_error_status(status) {
627
+ if (typeof status === "number") return status;
628
+ return error_status_codes[status];
629
+ }
630
+ function resolve_redirect_status(status) {
631
+ if (typeof status === "number") return status;
632
+ return redirect_status_codes[status];
633
+ }
634
+ //#endregion
635
+ export { Command, Error$1 as Error, Form, Prerender, Query, Redirect, RequestEvent, ServerRuntime, get_server_runtime_or_throw };
528
636
 
529
637
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":["get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender"],"sources":["../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/runtime.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/factories.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport type { RemoteHandler, StandardSchema } from \"./types.ts\";\n\n/**\n * Checks whether a value is the string sentinel for unchecked remotes.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is `\"unchecked\"`.\n */\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n return value === \"unchecked\";\n}\n\n/**\n * Checks whether a value is a remote handler function.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is callable as a handler.\n */\nexport function is_handler(value: unknown): value is RemoteHandler {\n return typeof value === \"function\";\n}\n\n/**\n * Checks whether a value implements the Standard Schema contract.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is a Standard Schema.\n */\nexport function is_standard_schema(value: unknown): value is StandardSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"~standard\" in value\n );\n}\n\n/**\n * Checks whether a value looks like an Effect Schema.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be converted to Standard Schema.\n */\nexport function is_effect_schema(\n value: unknown,\n): value is Schema.Schema<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"ast\" in value &&\n \"make\" in value\n );\n}\n\n/**\n * Converts Effect Schema inputs to Standard Schema for SvelteKit.\n *\n * @since 2.0.0\n * @param value - Schema or handler input.\n * @returns Original value or Standard Schema view of an Effect Schema.\n */\nexport function normalize_validator(value: unknown): unknown {\n if (is_standard_schema(value) || !is_effect_schema(value)) {\n return value;\n }\n\n return Schema.toStandardSchemaV1(value as never);\n}\n","import type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends\n Pick<\n SvelteKitRequestEvent,\n | \"cookies\"\n | \"getClientAddress\"\n | \"locals\"\n | \"params\"\n | \"platform\"\n | \"request\"\n | \"route\"\n | \"url\"\n > {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context\n .Reference<RequestEvent>(\"@ser/RequestEvent\", {\n defaultValue: () => {\n throw new Error(\n \"[REQUEST_EVENT_UNAVAILABLE]: RequestEvent is only available during a remote call\",\n );\n },\n });\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n /**\n * Build and cache the server-side `ManagedRuntime`.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n * @returns The configured ManagedRuntime.\n */\n static make<R = never>(\n layer?: Layer.Layer<R>,\n ): ManagedRuntime.ManagedRuntime<R, never> {\n const runtime = ManagedRuntime.make(\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\n );\n\n current_server_runtime = runtime as ManagedRuntime.ManagedRuntime<\n unknown,\n never\n >;\n\n return runtime;\n }\n}\n\nlet current_server_runtime:\n | ManagedRuntime.ManagedRuntime<unknown, never>\n | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> {\n if (!current_server_runtime) {\n current_server_runtime = ManagedRuntime.make(\n Layer.empty,\n ) as ManagedRuntime.ManagedRuntime<unknown, never>;\n }\n\n return current_server_runtime;\n}\n","import { run_remote_effect } from \"$/remote/server.ts\";\nimport { error as svelte_error, invalid } from \"@sveltejs/kit\";\nimport { Effect, Stream } from \"effect\";\n\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport type { EffectLike, EffectRemoteLiveSource } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> =\n | AsyncIterable<A>\n | AsyncIterator<A>\n | Iterable<A>\n | Iterator<A>;\n\ntype LiveHandlerResult<A> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>;\n\n/**\n * Checks whether a value is an Effect generator return object.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be wrapped with `Effect.gen`.\n */\nexport function is_generator_result<A>(\n value: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { next?: unknown }).next === \"function\"\n );\n}\n\n/**\n * Normalizes an Effect-like handler return value into an Effect.\n *\n * @since 2.0.0\n * @param value - Effect or generator return value.\n * @returns Normalized Effect.\n */\nexport function to_effect<A>(\n value: EffectLike<A>,\n): Effect.Effect<A, unknown, unknown> {\n if (is_generator_result<A>(value)) {\n return Effect.gen(() => value);\n }\n\n return value;\n}\n\n/**\n * Checks whether a value is a live query source SvelteKit can consume.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is an Effect Stream or native iterable source.\n */\nexport function is_live_source<A>(\n value: unknown,\n): value is EffectRemoteLiveSource<A> {\n if (Stream.isStream(value)) {\n return true;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const source = value as {\n readonly next?: unknown;\n readonly [Symbol.asyncIterator]?: unknown;\n readonly [Symbol.iterator]?: unknown;\n };\n\n return (\n typeof source.next === \"function\" ||\n typeof source[Symbol.asyncIterator] === \"function\" ||\n typeof source[Symbol.iterator] === \"function\"\n );\n}\n\n/**\n * Runs and normalizes a live query handler result with request services\n * available to Effect Streams.\n *\n * @since 2.0.0\n * @param value - Live query source or Effect that resolves to one.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with a source SvelteKit can stream.\n */\nexport function run_live_handler_source<A>(\n value: LiveHandlerResult<A>,\n event: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_live_source_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nfunction to_live_source_effect<A>(\n value: LiveHandlerResult<A>,\n): Effect.Effect<ResolvedLiveSource<A>, unknown, unknown> {\n if (Stream.isStream(value)) {\n return Stream.toAsyncIterableEffect(\n value as Stream.Stream<A, unknown, unknown>,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n }\n\n if (is_native_live_source<A>(value)) {\n return Effect.succeed(value);\n }\n\n if (!Effect.isEffect(value)) {\n return Effect.fail(\n new Error(\n \"[INVALID_LIVE_QUERY_SOURCE]: Query.live handler must return an Effect Stream, Iterable, or AsyncIterable\",\n ),\n );\n }\n\n return Effect.flatMap(\n value as Effect.Effect<EffectRemoteLiveSource<A>, unknown, unknown>,\n to_live_source_effect,\n );\n}\n\nfunction is_native_live_source<A>(\n value: unknown,\n): value is ResolvedLiveSource<A> {\n return is_live_source<A>(value) && !Stream.isStream(value);\n}\n\n/**\n * Runs a remote handler Effect with the current request event provided.\n *\n * @since 2.0.0\n * @param value - Handler return value.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with the handler output.\n */\nexport function run_handler_effect<A>(\n value: EffectLike<A>,\n event: RequestEventShape,\n): Promise<A> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<A, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nconst svelte_invalid = (_status: number, body: unknown): never => {\n const issues = typeof body === \"object\" && body !== null &&\n Array.isArray((body as { issues?: unknown }).issues)\n ? (body as { issues: unknown[] }).issues\n : [String(body)];\n\n invalid(...(issues as never[]));\n};\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n svelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\n\nimport type { FormInvalid } from \"./types.ts\";\n\n/**\n * Creates a path-aware proxy for remote form validation failures.\n *\n * @since 2.0.0\n * @param path - Current nested form path.\n * @returns Callable invalid proxy for this path.\n */\nexport function make_invalid_proxy(\n path: readonly (string | number)[] = [],\n): FormInvalid {\n const invalid_at_path = (message: string) =>\n Effect.fail(\n create_form_error([{ message, path: [...path] } satisfies FormIssue]),\n );\n\n return new Proxy(invalid_at_path, {\n get(_target, property) {\n if (typeof property === \"symbol\") {\n return undefined;\n }\n\n return make_invalid_proxy([...path, property]);\n },\n }) as FormInvalid;\n}\n","import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\n\nimport { run_handler_effect, run_live_handler_source } from \"./effects.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport type {\n EffectLike,\n EffectRemoteLiveSource,\n RemoteFormHandler,\n RemoteHandler,\n} from \"./types.ts\";\n\ntype RemoteLiveHandler<Input = unknown, A = unknown> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>\n | ((input: Input) =>\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>);\n\nlet running_remote_effect_handlers = 0;\n\n/**\n * Reports whether SER is currently executing user remote handler code.\n *\n * @example\n * ```ts\n * if (is_running_remote_effect_handler()) {\n * return query();\n * }\n * ```\n *\n * @since 2.0.0\n * @returns Whether a remote handler wrapper is currently active.\n * @internal\n */\nexport function is_running_remote_effect_handler(): boolean {\n return running_remote_effect_handlers > 0;\n}\n\n/**\n * Builds the wrapper passed to native query, command, and prerender helpers.\n *\n * @since 2.0.0\n * @param handler - Effect handler or already-built Effect-like value.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit handler wrapper.\n */\nexport function make_remote_wrapper(\n handler: RemoteHandler | EffectLike,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = is_handler(handler) ? handler(input) : handler;\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\n/**\n * Builds the wrapper passed to native live query helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware live source handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit live query wrapper.\n */\nexport function make_remote_live_wrapper<Input, A>(\n handler: RemoteLiveHandler<Input, A>,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = typeof handler === \"function\"\n ? handler(input as Input)\n : handler;\n\n return run_live_handler_source(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\n/**\n * Builds the wrapper passed to native form helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware form handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit form handler wrapper.\n */\nexport function make_remote_form_wrapper<Input, A>(\n handler: RemoteFormHandler<Input, A>,\n helper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n return async (data: unknown, issue: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n const invalid_proxy = make_invalid_proxy();\n\n try {\n const result = handler({\n data: data as Input,\n invalid: invalid_proxy,\n issue,\n });\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\nasync function run_inside_remote_effect_handler<A>(\n run: () => Promise<A>,\n): Promise<A> {\n running_remote_effect_handlers += 1;\n\n try {\n return await run();\n } finally {\n running_remote_effect_handlers -= 1;\n }\n}\n","import {\n command as native_command,\n form as native_form,\n getRequestEvent as get_native_request_event,\n prerender as native_prerender,\n query as native_query,\n} from \"$app/server\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, type Schema } from \"effect\";\n\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport {\n is_running_remote_effect_handler,\n make_remote_form_wrapper,\n make_remote_live_wrapper,\n make_remote_wrapper,\n} from \"./wrappers.ts\";\nimport type {\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n PrerenderOptions,\n RemoteFormHandler,\n RemoteHandler,\n SchemaInput,\n} from \"./types.ts\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top\n ? S[\"Encoded\"] extends RemoteFormInput ? S[\"Encoded\"]\n : never\n : never;\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype EffectRemoteResource<Output> =\n | EffectRemoteLiveQueryResource<Output>\n | EffectRemoteQuery<Output>;\n\ntype RemoteLiveHandler<Input = unknown, A = unknown> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>\n | ((input: Input) =>\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>);\n\ninterface QueryFactory {\n <A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n ): EffectRemoteQueryFunction<void, A>;\n <Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n ): EffectRemoteQueryFunction<Input, A>;\n <S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n ): EffectRemoteQueryFunction<SchemaInput<S>, A>;\n\n readonly batch: typeof QueryBatch;\n readonly live: typeof QueryLive;\n}\n\nfunction to_effect_query<Input, Output>(\n native: NativeQueryLike<Input>,\n): EffectRemoteQueryFunction<Input, Output> {\n const wrapped = ((input: Input) => {\n if (is_current_remote_request()) {\n return (native as (input: Input) => unknown)(input);\n }\n\n const resource = (native as (input: Input) => unknown)(input);\n const effect = Effect.tryPromise({\n try: () => Promise.resolve(resource),\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteQuery<Output>;\n\n attach_query_resource_methods(resource, effect);\n\n return effect;\n }) as unknown as EffectRemoteQueryFunction<Input, Output>;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\nfunction is_current_remote_request(): boolean {\n if (is_running_remote_effect_handler()) {\n return false;\n }\n\n try {\n const event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n return event.isRemoteRequest === true;\n } catch {\n return false;\n }\n}\n\nfunction to_effect_live_query<Input, Output>(\n native: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output> {\n const wrapped = ((input: Input) =>\n Effect.try({\n try: () => {\n const resource = (native as (input: Input) => unknown)(input);\n\n return make_live_resource<Output>(resource);\n },\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteLiveQuery<\n Output\n >) as unknown as EffectRemoteLiveQueryFunction<\n Input,\n Output\n >;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\ntype NativeRemoteResource<Output> = {\n readonly current?: Output;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\ntype NativeLiveQueryResource<Output> =\n & NativeRemoteResource<Output>\n & Partial<AsyncIterable<Output>>\n & {\n readonly connected?: boolean;\n readonly done?: boolean;\n readonly reconnect?: () => Promise<void>;\n };\n\nfunction is_query_resource<Output>(\n resource: unknown,\n): resource is NativeQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction is_live_resource<Output>(\n resource: unknown,\n): resource is NativeLiveQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction attach_remote_resource_getters<Output>(\n resource: unknown,\n effect: EffectRemoteResource<Output>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n}\n\nfunction attach_query_resource_methods<Output>(\n resource: unknown,\n effect: EffectRemoteQuery<Output>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_remote_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n if (typeof refresh === \"function\") {\n Object.defineProperty(effect, \"refresh\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(refresh.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof set === \"function\") {\n Object.defineProperty(effect, \"set\", {\n configurable: true,\n value: (value: Output) => set.call(resource, value),\n });\n }\n\n if (typeof with_override === \"function\") {\n Object.defineProperty(effect, \"withOverride\", {\n configurable: true,\n value: (update: (current: Output) => Output) =>\n with_override.call(resource, update),\n });\n }\n}\n\nfunction attach_live_resource_methods<Output>(\n resource: unknown,\n effect: EffectRemoteLiveQueryResource<Output>,\n): void {\n const methods = is_live_resource<Output>(resource) ? resource : undefined;\n const reconnect = methods?.reconnect;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const keys = [\n \"connected\",\n \"current\",\n \"done\",\n \"error\",\n \"loading\",\n \"ready\",\n ] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n\n if (typeof reconnect === \"function\") {\n Object.defineProperty(effect, \"reconnect\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(reconnect.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof async_iterator === \"function\") {\n Object.defineProperty(effect, Symbol.asyncIterator, {\n configurable: true,\n value: () => async_iterator.call(resource),\n });\n }\n}\n\nfunction make_live_resource<Output>(\n resource: unknown,\n): EffectRemoteLiveQueryResource<Output> {\n const live_resource = {} as EffectRemoteLiveQueryResource<Output>;\n\n attach_live_resource_methods(resource, live_resource);\n\n return live_resource;\n}\n\n/**\n * Factory for a read-only remote query function.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\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 query function.\n */\nfunction QueryRoot<A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n): EffectRemoteQueryFunction<void, A>;\nfunction QueryRoot<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n): EffectRemoteQueryFunction<Input, A>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n): EffectRemoteQueryFunction<SchemaInput<S>, A>;\nfunction QueryRoot(\n validate_or_handler: unknown,\n maybe_handler?: RemoteHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_query(native_query(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler, \"Query\") as never,\n ) as ReturnType<typeof native_query>);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query('unchecked', handler) requires a handler\",\n );\n }\n\n return to_effect_query(native_query(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Query\",\n ) as never,\n ) as ReturnType<typeof native_query>);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query\");\n }\n}\n\n/**\n * Factory for a batched read-only remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema or `\"unchecked\"` sentinel.\n * @param maybe_handler - Handler receiving validated inputs as one batch.\n * @returns A SvelteKit batch query function.\n */\nfunction QueryBatch<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: EffectRemoteBatchHandler<Input, A>,\n): EffectRemoteQueryFunction<Input, A>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A>,\n): EffectRemoteQueryFunction<SchemaInput<S>, A>;\nfunction QueryBatch(\n validate_or_handler: unknown,\n maybe_handler?: EffectRemoteBatchHandler,\n): unknown {\n try {\n if (!maybe_handler) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query.batch requires a handler\",\n );\n }\n\n return to_effect_query(native_query.batch(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(\n maybe_handler as RemoteHandler,\n \"Query.batch\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.batch\");\n }\n}\n\n/**\n * Factory for a live remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg live handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit live query function.\n */\nfunction QueryLive<A>(\n validate_or_handler: RemoteLiveHandler<void, A>,\n): EffectRemoteLiveQueryFunction<void, A>;\nfunction QueryLive<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteLiveHandler<Input, A>,\n): EffectRemoteLiveQueryFunction<Input, A>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteLiveHandler<SchemaInput<S>, A>,\n): EffectRemoteLiveQueryFunction<SchemaInput<S>, A>;\nfunction QueryLive(\n validate_or_handler: unknown,\n maybe_handler?: RemoteLiveHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_live_query(native_query.live(\n normalize_validator(validate_or_handler) as never,\n make_remote_live_wrapper(\n maybe_handler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query.live('unchecked', handler) requires a handler\",\n );\n }\n\n return to_effect_live_query(native_query.live(\n make_remote_live_wrapper(\n validate_or_handler as RemoteLiveHandler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.live\");\n }\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 batch: QueryBatch,\n live: QueryLive,\n});\n\n/**\n * Factory for a write-oriented remote command function.\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 command function.\n */\nexport function Command<A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n): EffectRemoteCommand<void, A>;\nexport function Command<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n): EffectRemoteCommand<Input, A>;\nexport function Command<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n): EffectRemoteCommand<SchemaInput<S>, A>;\nexport function Command(\n validate_or_handler: unknown,\n maybe_handler?: RemoteHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return native_command(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler, \"Command\") as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Command('unchecked', handler) requires a handler\",\n );\n }\n\n return native_command(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Command\",\n ) as never,\n ) as ReturnType<typeof native_command>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Command\");\n }\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>(\n validate_or_handler: EffectLike<A> | RemoteFormHandler<void, A>,\n): EffectRemoteForm<void, A>;\nexport function Form<Input extends RemoteFormInput, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteFormHandler<Input, A>,\n): EffectRemoteForm<Input, A>;\nexport function Form<S extends Schema.Top, A>(\n validate_or_handler: S,\n maybe_handler: RemoteFormHandler<SchemaInput<S>, A>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A>;\nexport function Form(\n validate_or_handler: unknown,\n maybe_handler?: RemoteFormHandler<never, unknown>,\n): unknown {\n try {\n if (maybe_handler) {\n return native_form(\n normalize_validator(validate_or_handler) as never,\n make_remote_form_wrapper(maybe_handler, \"Form\") as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Form('unchecked', handler) requires a handler\",\n );\n }\n\n const inputless_handler: RemoteFormHandler<void, unknown> = (\n { data, invalid, issue },\n ) => {\n if (is_handler(validate_or_handler)) {\n return validate_or_handler({ data, invalid, issue });\n }\n\n return validate_or_handler as EffectLike;\n };\n\n return native_form(\n make_remote_form_wrapper(inputless_handler, \"Form\") as never,\n ) as unknown as ReturnType<typeof native_form>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Form\");\n }\n}\n\n/**\n * Factory for a prerenderable remote function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler_or_options - Handler or prerender options.\n * @param maybe_options - Prerender options used with a validator.\n * @returns A SvelteKit prerender function.\n */\nexport function Prerender(\n validate_or_handler: unknown,\n maybe_handler_or_options?: RemoteHandler | PrerenderOptions,\n maybe_options?: PrerenderOptions,\n): ReturnType<typeof native_prerender> {\n try {\n if (is_handler(maybe_handler_or_options)) {\n return native_prerender(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n maybe_options as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Prerender('unchecked', handler) requires a handler\",\n );\n }\n\n return native_prerender(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Prerender\",\n ) as never,\n maybe_handler_or_options as never,\n ) as ReturnType<typeof native_prerender>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Prerender\");\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAgB,aAAa,OAAsC;AACjE,Q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D;AAGH,MAAI,aAAa,oBAAoB,CACnC,OAAM,IAAI,MACR,0EACD;EAGH,MAAM,qBACJ,EAAE,MAAM,SAAS,YACd;AACH,OAAI,WAAW,oBAAoB,CACjC,QAAO,oBAAoB;IAAE;IAAM;IAAS;IAAO,CAAC;AAGtD,UAAO;;AAGT,SAAOA,KACL,yBAAyB,mBAAmB,OAAO,CACpD;UACM,OAAgB;AACvB,QAAM,8BAA8B,OAAO,OAAO;;;;;;;;;;;;AAatD,SAAgB,UACd,qBACA,0BACA,eACqC;AACrC,KAAI;AACF,MAAI,WAAW,yBAAyB,CACtC,QAAOC,UACL,oBAAoB,oBAAoB,EACxC,oBAAoB,0BAA0B,YAAY,EAC1D,cACD;AAGH,MAAI,aAAa,oBAAoB,CACnC,OAAM,IAAI,MACR,+EACD;AAGH,SAAOA,UACL,oBACE,qBACA,YACD,EACD,yBACD;UACM,OAAgB;AACvB,QAAM,8BAA8B,OAAO,YAAY"}
1
+ {"version":3,"file":"server.js","names":["get_native_request_event","get_native_request_event","native_query","native_command","native_form","native_prerender","Error"],"sources":["../../modules/svelte-effect-runtime/src/server/schema.ts","../../modules/svelte-effect-runtime/src/server/runtime.ts","../../modules/svelte-effect-runtime/src/server/effects.ts","../../modules/svelte-effect-runtime/src/server/invalid.ts","../../modules/svelte-effect-runtime/src/server/wrappers.ts","../../modules/svelte-effect-runtime/src/server/factories.ts","../../modules/svelte-effect-runtime/src/server/control-flow.ts"],"sourcesContent":["import { Schema } from \"effect\";\n\nimport type { RemoteHandler, StandardSchema } from \"./types.ts\";\n\n/**\n * Checks whether a value is the string sentinel for unchecked remotes.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is `\"unchecked\"`.\n */\nexport function is_unchecked(value: unknown): value is \"unchecked\" {\n return value === \"unchecked\";\n}\n\n/**\n * Checks whether a value is a remote handler function.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is callable as a handler.\n */\nexport function is_handler(value: unknown): value is RemoteHandler {\n return typeof value === \"function\";\n}\n\n/**\n * Checks whether a value implements the Standard Schema contract.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is a Standard Schema.\n */\nexport function is_standard_schema(value: unknown): value is StandardSchema {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"~standard\" in value\n );\n}\n\n/**\n * Checks whether a value looks like an Effect Schema.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be converted to Standard Schema.\n */\nexport function is_effect_schema(\n value: unknown,\n): value is Schema.Schema<unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n \"ast\" in value &&\n \"make\" in value\n );\n}\n\n/**\n * Converts Effect Schema inputs to Standard Schema for SvelteKit.\n *\n * @since 2.0.0\n * @param value - Schema or handler input.\n * @returns Original value or Standard Schema view of an Effect Schema.\n */\nexport function normalize_validator(value: unknown): unknown {\n if (is_standard_schema(value) || !is_effect_schema(value)) {\n return value;\n }\n\n return Schema.toStandardSchemaV1(value as never);\n}\n","import type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends\n Pick<\n SvelteKitRequestEvent,\n | \"cookies\"\n | \"getClientAddress\"\n | \"locals\"\n | \"params\"\n | \"platform\"\n | \"request\"\n | \"route\"\n | \"url\"\n > {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context\n .Reference<RequestEvent>(\"@ser/RequestEvent\", {\n defaultValue: () => {\n throw new Error(\n \"[REQUEST_EVENT_UNAVAILABLE]: RequestEvent is only available during a remote call\",\n );\n },\n });\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n /**\n * Build and cache the server-side `ManagedRuntime`.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n * @returns The configured ManagedRuntime.\n */\n static make<R = never>(\n layer?: Layer.Layer<R>,\n ): ManagedRuntime.ManagedRuntime<R, never> {\n const runtime = ManagedRuntime.make(\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\n );\n\n current_server_runtime = runtime as ManagedRuntime.ManagedRuntime<\n unknown,\n never\n >;\n\n return runtime;\n }\n}\n\nlet current_server_runtime:\n | ManagedRuntime.ManagedRuntime<unknown, never>\n | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> {\n if (!current_server_runtime) {\n current_server_runtime = ManagedRuntime.make(\n Layer.empty,\n ) as ManagedRuntime.ManagedRuntime<unknown, never>;\n }\n\n return current_server_runtime;\n}\n","import { run_remote_effect } from \"$/remote/server.ts\";\nimport { error as svelte_error, invalid } from \"@sveltejs/kit\";\nimport { Effect, Stream } from \"effect\";\n\nimport { get_server_runtime_or_throw, RequestEvent } from \"./runtime.ts\";\nimport type { RequestEvent as RequestEventShape } from \"./runtime.ts\";\nimport type { EffectLike, EffectRemoteLiveSource } from \"./types.ts\";\n\ntype ResolvedLiveSource<A> =\n | AsyncIterable<A>\n | AsyncIterator<A>\n | Iterable<A>\n | Iterator<A>;\n\ntype LiveHandlerResult<A> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>;\n\n/**\n * Checks whether a value is an Effect generator return object.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value should be wrapped with `Effect.gen`.\n */\nexport function is_generator_result<A>(\n value: unknown,\n): value is Effect.gen.Return<A, unknown, unknown> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n typeof (value as { next?: unknown }).next === \"function\"\n );\n}\n\n/**\n * Normalizes an Effect-like handler return value into an Effect.\n *\n * @since 2.0.0\n * @param value - Effect or generator return value.\n * @returns Normalized Effect.\n */\nexport function to_effect<A>(\n value: EffectLike<A>,\n): Effect.Effect<A, unknown, unknown> {\n if (is_generator_result<A>(value)) {\n return Effect.gen(() => value);\n }\n\n return value;\n}\n\n/**\n * Checks whether a value is a live query source SvelteKit can consume.\n *\n * @since 2.0.0\n * @param value - Value to inspect.\n * @returns Whether the value is an Effect Stream or native iterable source.\n */\nexport function is_live_source<A>(\n value: unknown,\n): value is EffectRemoteLiveSource<A> {\n if (Stream.isStream(value)) {\n return true;\n }\n\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n\n const source = value as {\n readonly next?: unknown;\n readonly [Symbol.asyncIterator]?: unknown;\n readonly [Symbol.iterator]?: unknown;\n };\n\n return (\n typeof source.next === \"function\" ||\n typeof source[Symbol.asyncIterator] === \"function\" ||\n typeof source[Symbol.iterator] === \"function\"\n );\n}\n\n/**\n * Runs and normalizes a live query handler result with request services\n * available to Effect Streams.\n *\n * @since 2.0.0\n * @param value - Live query source or Effect that resolves to one.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with a source SvelteKit can stream.\n */\nexport function run_live_handler_source<A>(\n value: LiveHandlerResult<A>,\n event: RequestEventShape,\n): Promise<ResolvedLiveSource<A>> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_live_source_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nfunction to_live_source_effect<A>(\n value: LiveHandlerResult<A>,\n): Effect.Effect<ResolvedLiveSource<A>, unknown, unknown> {\n if (Stream.isStream(value)) {\n return Stream.toAsyncIterableEffect(\n value as Stream.Stream<A, unknown, unknown>,\n ) as Effect.Effect<ResolvedLiveSource<A>, unknown, unknown>;\n }\n\n if (is_native_live_source<A>(value)) {\n return Effect.succeed(value);\n }\n\n if (!Effect.isEffect(value)) {\n return Effect.fail(\n new Error(\n \"[INVALID_LIVE_QUERY_SOURCE]: Query.live handler must return an Effect Stream, Iterable, or AsyncIterable\",\n ),\n );\n }\n\n return Effect.flatMap(\n value as Effect.Effect<EffectRemoteLiveSource<A>, unknown, unknown>,\n to_live_source_effect,\n );\n}\n\nfunction is_native_live_source<A>(\n value: unknown,\n): value is ResolvedLiveSource<A> {\n return is_live_source<A>(value) && !Stream.isStream(value);\n}\n\n/**\n * Runs a remote handler Effect with the current request event provided.\n *\n * @since 2.0.0\n * @param value - Handler return value.\n * @param event - SvelteKit request event for this remote call.\n * @returns Promise resolving with the handler output.\n */\nexport function run_handler_effect<A>(\n value: EffectLike<A>,\n event: RequestEventShape,\n): Promise<A> {\n const runtime = get_server_runtime_or_throw();\n const effect = Effect.provideService(\n to_effect(value),\n RequestEvent,\n event,\n ) as Effect.Effect<A, unknown, unknown>;\n\n return run_remote_effect(\n effect,\n runtime,\n svelte_invalid,\n svelte_remote_error,\n );\n}\n\nconst svelte_invalid = (_status: number, body: unknown): never => {\n const issues = typeof body === \"object\" && body !== null &&\n Array.isArray((body as { issues?: unknown }).issues)\n ? (body as { issues: unknown[] }).issues\n : [String(body)];\n\n invalid(...(issues as never[]));\n};\n\nconst svelte_remote_error = (status: number, body: unknown): never => {\n svelte_error(status as never, body as never);\n};\n","import { create_form_error } from \"$/remote/shared.ts\";\nimport { Effect } from \"effect\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\n\nimport type { FormInvalid } from \"./types.ts\";\n\n/**\n * Creates a path-aware proxy for remote form validation failures.\n *\n * @since 2.0.0\n * @param path - Current nested form path.\n * @returns Callable invalid proxy for this path.\n */\nexport function make_invalid_proxy(\n path: readonly (string | number)[] = [],\n): FormInvalid {\n const invalid_at_path = (message: string) =>\n Effect.fail(\n create_form_error([{ message, path: [...path] } satisfies FormIssue]),\n );\n\n return new Proxy(invalid_at_path, {\n get(_target, property) {\n if (typeof property === \"symbol\") {\n return undefined;\n }\n\n return make_invalid_proxy([...path, property]);\n },\n }) as FormInvalid;\n}\n","import { getRequestEvent as get_native_request_event } from \"$app/server\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\n\nimport { run_handler_effect, run_live_handler_source } from \"./effects.ts\";\nimport { make_invalid_proxy } from \"./invalid.ts\";\nimport { is_handler } from \"./schema.ts\";\nimport type { RequestEvent } from \"./runtime.ts\";\nimport type {\n EffectLike,\n EffectRemoteLiveSource,\n RemoteFormHandler,\n RemoteHandler,\n} from \"./types.ts\";\n\ntype RemoteLiveHandler<Input = unknown, A = unknown> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>\n | ((input: Input) =>\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>);\n\nlet running_remote_effect_handlers = 0;\n\n/**\n * Reports whether SER is currently executing user remote handler code.\n *\n * @example\n * ```ts\n * if (is_running_remote_effect_handler()) {\n * return query();\n * }\n * ```\n *\n * @since 2.0.0\n * @returns Whether a remote handler wrapper is currently active.\n * @internal\n */\nexport function is_running_remote_effect_handler(): boolean {\n return running_remote_effect_handlers > 0;\n}\n\n/**\n * Builds the wrapper passed to native query, command, and prerender helpers.\n *\n * @since 2.0.0\n * @param handler - Effect handler or already-built Effect-like value.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit handler wrapper.\n */\nexport function make_remote_wrapper(\n handler: RemoteHandler | EffectLike,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = is_handler(handler) ? handler(input) : handler;\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\n/**\n * Builds the wrapper passed to native live query helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware live source handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit live query wrapper.\n */\nexport function make_remote_live_wrapper<Input, A>(\n handler: RemoteLiveHandler<Input, A>,\n helper_name: string,\n): (input: unknown) => Promise<unknown> {\n return async (input: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n try {\n const result = typeof handler === \"function\"\n ? handler(input as Input)\n : handler;\n\n return run_live_handler_source(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\n/**\n * Builds the wrapper passed to native form helpers.\n *\n * @since 2.0.0\n * @param handler - Effect-aware form handler.\n * @param helper_name - Remote helper name for error normalization.\n * @returns Native SvelteKit form handler wrapper.\n */\nexport function make_remote_form_wrapper<Input, A>(\n handler: RemoteFormHandler<Input, A>,\n helper_name: string,\n): (data: unknown, issue: unknown) => Promise<unknown> {\n return async (data: unknown, issue: unknown) => {\n let event: RequestEvent;\n\n try {\n event = get_native_request_event() as unknown as RequestEvent;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n\n return await run_inside_remote_effect_handler(() => {\n const invalid_proxy = make_invalid_proxy();\n\n try {\n const result = handler({\n data: data as Input,\n invalid: invalid_proxy,\n issue,\n });\n\n return run_handler_effect(result, event);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, helper_name);\n }\n });\n };\n}\n\nasync function run_inside_remote_effect_handler<A>(\n run: () => Promise<A>,\n): Promise<A> {\n running_remote_effect_handlers += 1;\n\n try {\n return await run();\n } finally {\n running_remote_effect_handlers -= 1;\n }\n}\n","import {\n command as native_command,\n form as native_form,\n getRequestEvent as get_native_request_event,\n prerender as native_prerender,\n query as native_query,\n} from \"$app/server\";\nimport { copy_property_descriptors } from \"$/internal/descriptors.ts\";\nimport { normalize_remote_helper_error } from \"$/remote/server.ts\";\nimport type { RemoteFormInput } from \"@sveltejs/kit\";\nimport { Effect, type Schema } from \"effect\";\n\nimport { is_handler, is_unchecked, normalize_validator } from \"./schema.ts\";\nimport {\n is_running_remote_effect_handler,\n make_remote_form_wrapper,\n make_remote_live_wrapper,\n make_remote_wrapper,\n} from \"./wrappers.ts\";\nimport type {\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n PrerenderOptions,\n RemoteFormHandler,\n RemoteHandler,\n SchemaInput,\n} from \"./types.ts\";\n\ntype FormSchemaEncodedInput<S> = S extends Schema.Top\n ? S[\"Encoded\"] extends RemoteFormInput ? S[\"Encoded\"]\n : never\n : never;\n\ntype NativeQueryLike<Input = unknown> = (input: Input) => unknown;\n\ntype EffectRemoteResource<Output> =\n | EffectRemoteLiveQueryResource<Output>\n | EffectRemoteQuery<Output>;\n\ntype RemoteLiveHandler<Input = unknown, A = unknown> =\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>\n | ((input: Input) =>\n | EffectLike<EffectRemoteLiveSource<A>>\n | EffectRemoteLiveSource<A>);\n\ninterface QueryFactory {\n <A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n ): EffectRemoteQueryFunction<void, A>;\n <Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n ): EffectRemoteQueryFunction<Input, A>;\n <S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n ): EffectRemoteQueryFunction<SchemaInput<S>, A>;\n\n readonly batch: typeof QueryBatch;\n readonly live: typeof QueryLive;\n}\n\nfunction to_effect_query<Input, Output>(\n native: NativeQueryLike<Input>,\n): EffectRemoteQueryFunction<Input, Output> {\n const wrapped = ((input: Input) => {\n if (is_current_remote_request()) {\n return (native as (input: Input) => unknown)(input);\n }\n\n const resource = (native as (input: Input) => unknown)(input);\n const effect = Effect.tryPromise({\n try: () => Promise.resolve(resource),\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteQuery<Output>;\n\n attach_query_resource_methods(resource, effect);\n\n return effect;\n }) as unknown as EffectRemoteQueryFunction<Input, Output>;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\nfunction is_current_remote_request(): boolean {\n if (is_running_remote_effect_handler()) {\n return false;\n }\n\n try {\n const event = get_native_request_event() as { isRemoteRequest?: boolean };\n\n return event.isRemoteRequest === true;\n } catch {\n return false;\n }\n}\n\nfunction to_effect_live_query<Input, Output>(\n native: NativeQueryLike<Input>,\n): EffectRemoteLiveQueryFunction<Input, Output> {\n const wrapped = ((input: Input) =>\n Effect.try({\n try: () => {\n const resource = (native as (input: Input) => unknown)(input);\n\n return make_live_resource<Output>(resource);\n },\n catch: (error: unknown) => error,\n }) as unknown as EffectRemoteLiveQuery<\n Output\n >) as unknown as EffectRemoteLiveQueryFunction<\n Input,\n Output\n >;\n\n copy_property_descriptors(native, wrapped);\n\n return wrapped;\n}\n\ntype NativeRemoteResource<Output> = {\n readonly current?: Output;\n readonly error?: unknown;\n readonly loading?: boolean;\n readonly ready?: boolean;\n};\n\ntype NativeQueryResource<Output> = NativeRemoteResource<Output> & {\n readonly refresh?: () => Promise<void>;\n readonly set?: (value: Output) => void;\n readonly withOverride?: (update: (current: Output) => Output) => unknown;\n};\n\ntype NativeLiveQueryResource<Output> =\n & NativeRemoteResource<Output>\n & Partial<AsyncIterable<Output>>\n & {\n readonly connected?: boolean;\n readonly done?: boolean;\n readonly reconnect?: () => Promise<void>;\n };\n\nfunction is_query_resource<Output>(\n resource: unknown,\n): resource is NativeQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction is_live_resource<Output>(\n resource: unknown,\n): resource is NativeLiveQueryResource<Output> {\n const resource_type = typeof resource;\n\n return (\n (resource_type === \"object\" && resource !== null) ||\n resource_type === \"function\"\n );\n}\n\nfunction attach_remote_resource_getters<Output>(\n resource: unknown,\n effect: EffectRemoteResource<Output>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const keys = [\"current\", \"error\", \"loading\", \"ready\"] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n}\n\nfunction attach_query_resource_methods<Output>(\n resource: unknown,\n effect: EffectRemoteQuery<Output>,\n): void {\n const methods = is_query_resource<Output>(resource) ? resource : undefined;\n const refresh = methods?.refresh;\n const set = methods?.set;\n const with_override = methods?.withOverride;\n\n attach_remote_resource_getters(resource, effect);\n\n if (!methods) {\n return;\n }\n\n if (typeof refresh === \"function\") {\n Object.defineProperty(effect, \"refresh\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(refresh.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof set === \"function\") {\n Object.defineProperty(effect, \"set\", {\n configurable: true,\n value: (value: Output) => set.call(resource, value),\n });\n }\n\n if (typeof with_override === \"function\") {\n Object.defineProperty(effect, \"withOverride\", {\n configurable: true,\n value: (update: (current: Output) => Output) =>\n with_override.call(resource, update),\n });\n }\n}\n\nfunction attach_live_resource_methods<Output>(\n resource: unknown,\n effect: EffectRemoteLiveQueryResource<Output>,\n): void {\n const methods = is_live_resource<Output>(resource) ? resource : undefined;\n const reconnect = methods?.reconnect;\n const async_iterator = methods?.[Symbol.asyncIterator];\n const keys = [\n \"connected\",\n \"current\",\n \"done\",\n \"error\",\n \"loading\",\n \"ready\",\n ] as const;\n\n if (!methods) {\n return;\n }\n\n for (const key of keys) {\n if (!(key in methods)) {\n continue;\n }\n\n Object.defineProperty(effect, key, {\n configurable: true,\n get: () => methods[key],\n });\n }\n\n if (typeof reconnect === \"function\") {\n Object.defineProperty(effect, \"reconnect\", {\n configurable: true,\n value: () =>\n Effect.tryPromise({\n try: () => Promise.resolve(reconnect.call(resource)),\n catch: (error: unknown) => error,\n }),\n });\n }\n\n if (typeof async_iterator === \"function\") {\n Object.defineProperty(effect, Symbol.asyncIterator, {\n configurable: true,\n value: () => async_iterator.call(resource),\n });\n }\n}\n\nfunction make_live_resource<Output>(\n resource: unknown,\n): EffectRemoteLiveQueryResource<Output> {\n const live_resource = {} as EffectRemoteLiveQueryResource<Output>;\n\n attach_live_resource_methods(resource, live_resource);\n\n return live_resource;\n}\n\n/**\n * Factory for a read-only remote query function.\n *\n * @example\n * ```ts\n * export const getUser = Query(Schema.Struct({ id: Schema.String }), (input) =>\n * Effect.succeed(input.id)\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 query function.\n */\nfunction QueryRoot<A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n): EffectRemoteQueryFunction<void, A>;\nfunction QueryRoot<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n): EffectRemoteQueryFunction<Input, A>;\nfunction QueryRoot<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n): EffectRemoteQueryFunction<SchemaInput<S>, A>;\nfunction QueryRoot(\n validate_or_handler: unknown,\n maybe_handler?: RemoteHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_query(native_query(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler, \"Query\") as never,\n ) as ReturnType<typeof native_query>);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query('unchecked', handler) requires a handler\",\n );\n }\n\n return to_effect_query(native_query(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Query\",\n ) as never,\n ) as ReturnType<typeof native_query>);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query\");\n }\n}\n\n/**\n * Factory for a batched read-only remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema or `\"unchecked\"` sentinel.\n * @param maybe_handler - Handler receiving validated inputs as one batch.\n * @returns A SvelteKit batch query function.\n */\nfunction QueryBatch<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: EffectRemoteBatchHandler<Input, A>,\n): EffectRemoteQueryFunction<Input, A>;\nfunction QueryBatch<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: EffectRemoteBatchHandler<SchemaInput<S>, A>,\n): EffectRemoteQueryFunction<SchemaInput<S>, A>;\nfunction QueryBatch(\n validate_or_handler: unknown,\n maybe_handler?: EffectRemoteBatchHandler,\n): unknown {\n try {\n if (!maybe_handler) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query.batch requires a handler\",\n );\n }\n\n return to_effect_query(native_query.batch(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(\n maybe_handler as RemoteHandler,\n \"Query.batch\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.batch\");\n }\n}\n\n/**\n * Factory for a live remote query function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg live handler.\n * @param maybe_handler - Handler used when a validator is supplied.\n * @returns A SvelteKit live query function.\n */\nfunction QueryLive<A>(\n validate_or_handler: RemoteLiveHandler<void, A>,\n): EffectRemoteLiveQueryFunction<void, A>;\nfunction QueryLive<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteLiveHandler<Input, A>,\n): EffectRemoteLiveQueryFunction<Input, A>;\nfunction QueryLive<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteLiveHandler<SchemaInput<S>, A>,\n): EffectRemoteLiveQueryFunction<SchemaInput<S>, A>;\nfunction QueryLive(\n validate_or_handler: unknown,\n maybe_handler?: RemoteLiveHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return to_effect_live_query(native_query.live(\n normalize_validator(validate_or_handler) as never,\n make_remote_live_wrapper(\n maybe_handler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Query.live('unchecked', handler) requires a handler\",\n );\n }\n\n return to_effect_live_query(native_query.live(\n make_remote_live_wrapper(\n validate_or_handler as RemoteLiveHandler,\n \"Query.live\",\n ) as never,\n ) as NativeQueryLike);\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Query.live\");\n }\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 batch: QueryBatch,\n live: QueryLive,\n});\n\n/**\n * Factory for a write-oriented remote command function.\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 command function.\n */\nexport function Command<A>(\n validate_or_handler: EffectLike<A> | RemoteHandler<void, A>,\n): EffectRemoteCommand<void, A>;\nexport function Command<Input, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteHandler<Input, A>,\n): EffectRemoteCommand<Input, A>;\nexport function Command<S extends Schema.Schema<unknown>, A>(\n validate_or_handler: S,\n maybe_handler: RemoteHandler<SchemaInput<S>, A>,\n): EffectRemoteCommand<SchemaInput<S>, A>;\nexport function Command(\n validate_or_handler: unknown,\n maybe_handler?: RemoteHandler,\n): unknown {\n try {\n if (maybe_handler) {\n return native_command(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler, \"Command\") as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Command('unchecked', handler) requires a handler\",\n );\n }\n\n return native_command(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Command\",\n ) as never,\n ) as ReturnType<typeof native_command>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Command\");\n }\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>(\n validate_or_handler: EffectLike<A> | RemoteFormHandler<void, A>,\n): EffectRemoteForm<void, A>;\nexport function Form<Input extends RemoteFormInput, A>(\n validate_or_handler: \"unchecked\",\n maybe_handler: RemoteFormHandler<Input, A>,\n): EffectRemoteForm<Input, A>;\nexport function Form<S extends Schema.Top, A>(\n validate_or_handler: S,\n maybe_handler: RemoteFormHandler<SchemaInput<S>, A>,\n): EffectRemoteForm<FormSchemaEncodedInput<S>, A>;\nexport function Form(\n validate_or_handler: unknown,\n maybe_handler?: RemoteFormHandler<never, unknown>,\n): unknown {\n try {\n if (maybe_handler) {\n return native_form(\n normalize_validator(validate_or_handler) as never,\n make_remote_form_wrapper(maybe_handler, \"Form\") as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Form('unchecked', handler) requires a handler\",\n );\n }\n\n const inputless_handler: RemoteFormHandler<void, unknown> = (\n { data, invalid, issue },\n ) => {\n if (is_handler(validate_or_handler)) {\n return validate_or_handler({ data, invalid, issue });\n }\n\n return validate_or_handler as EffectLike;\n };\n\n return native_form(\n make_remote_form_wrapper(inputless_handler, \"Form\") as never,\n ) as unknown as ReturnType<typeof native_form>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Form\");\n }\n}\n\n/**\n * Factory for a prerenderable remote function.\n *\n * @since 2.0.0\n * @param validate_or_handler - A schema, `\"unchecked\"`, or no-arg handler.\n * @param maybe_handler_or_options - Handler or prerender options.\n * @param maybe_options - Prerender options used with a validator.\n * @returns A SvelteKit prerender function.\n */\nexport function Prerender(\n validate_or_handler: unknown,\n maybe_handler_or_options?: RemoteHandler | PrerenderOptions,\n maybe_options?: PrerenderOptions,\n): ReturnType<typeof native_prerender> {\n try {\n if (is_handler(maybe_handler_or_options)) {\n return native_prerender(\n normalize_validator(validate_or_handler) as never,\n make_remote_wrapper(maybe_handler_or_options, \"Prerender\") as never,\n maybe_options as never,\n );\n }\n\n if (is_unchecked(validate_or_handler)) {\n throw new Error(\n \"[MISSING_REMOTE_HANDLER]: Prerender('unchecked', handler) requires a handler\",\n );\n }\n\n return native_prerender(\n make_remote_wrapper(\n validate_or_handler as RemoteHandler,\n \"Prerender\",\n ) as never,\n maybe_handler_or_options as never,\n ) as ReturnType<typeof native_prerender>;\n } catch (error: unknown) {\n throw normalize_remote_helper_error(error, \"Prerender\");\n }\n}\n","import {\n error as svelte_error,\n redirect as svelte_redirect,\n} from \"@sveltejs/kit\";\nimport { Effect } from \"effect\";\n\nconst error_status_codes = {\n ProxyAuthenticationRequired: 407,\n RequestHeaderFieldsTooLarge: 431,\n UnavailableForLegalReasons: 451,\n NetworkAuthenticationRequired: 511,\n HttpVersionNotSupported: 505,\n UnprocessableContent: 422,\n UnprocessableEntity: 422,\n InternalServerError: 500,\n FailedDependency: 424,\n PreconditionRequired: 428,\n ServiceUnavailable: 503,\n MisdirectedRequest: 421,\n InsufficientStorage: 507,\n VariantAlsoNegotiates: 506,\n PreconditionFailed: 412,\n MethodNotAllowed: 405,\n GatewayTimeout: 504,\n PaymentRequired: 402,\n UpgradeRequired: 426,\n TooManyRequests: 429,\n LengthRequired: 411,\n NotAcceptable: 406,\n RequestTimeout: 408,\n ContentTooLarge: 413,\n PayloadTooLarge: 413,\n UriTooLong: 414,\n UnsupportedMediaType: 415,\n RangeNotSatisfiable: 416,\n ExpectationFailed: 417,\n ImATeapot: 418,\n BadRequest: 400,\n Unauthorized: 401,\n Forbidden: 403,\n NotFound: 404,\n Conflict: 409,\n Gone: 410,\n Locked: 423,\n TooEarly: 425,\n NotImplemented: 501,\n BadGateway: 502,\n LoopDetected: 508,\n NotExtended: 510,\n} as const;\n\nconst redirect_status_codes = {\n MovedPermanently: 301,\n TemporaryRedirect: 307,\n PermanentRedirect: 308,\n MultipleChoices: 300,\n NotModified: 304,\n SwitchProxy: 306,\n SeeOther: 303,\n UseProxy: 305,\n Found: 302,\n} as const;\n\ntype SvelteErrorBody = Parameters<typeof svelte_error>[1];\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 * 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 * 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 /**\n * Creates an Effect that throws SvelteKit's HTTP error control-flow value.\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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\n (\n status: ErrorStatus,\n body?: SvelteErrorBody,\n ): 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 /**\n * Creates an Effect that throws SvelteKit's redirect control-flow value.\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\n * to SvelteKit's `redirect` helper.\n * @param location - Target URL forwarded unchanged to SvelteKit.\n * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\n (\n status: RedirectStatus,\n location: string | URL,\n ): 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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Error: ErrorEffectFactory = (status, body) => {\n const resolved_status = resolve_error_status(status);\n\n return Effect.sync(() => {\n svelte_error(resolved_status, body);\n });\n};\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 * @returns An Effect that never succeeds because SvelteKit takes over request\n * control flow.\n */\nexport const Redirect: RedirectEffectFactory = (status, location) => {\n const resolved_status = resolve_redirect_status(status);\n\n return Effect.sync(() => {\n svelte_redirect(resolved_status, location);\n });\n};\n\nfunction resolve_error_status(status: ErrorStatus): number {\n if (typeof status === \"number\") {\n return status;\n }\n\n return error_status_codes[status];\n}\n\nfunction resolve_redirect_status(status: RedirectStatus): number {\n if (typeof status === \"number\") {\n return status;\n }\n\n return redirect_status_codes[status];\n}\n"],"mappings":";;;;;;;;;;;;;;AAWA,SAAgB,aAAa,OAAsC;AACjE,QAAO,UAAU;;;;;;;;;AAUnB,SAAgB,WAAW,OAAwC;AACjE,QAAO,OAAO,UAAU;;;;;;;;;AAU1B,SAAgB,mBAAmB,OAAyC;AAC1E,QACE,OAAO,UAAU,YACjB,UAAU,QACV,eAAe;;;;;;;;;AAWnB,SAAgB,iBACd,OACiC;AACjC,QACE,OAAO,UAAU,YACjB,UAAU,QACV,SAAS,SACT,UAAU;;;;;;;;;AAWd,SAAgB,oBAAoB,OAAyB;AAC3D,KAAI,mBAAmB,MAAM,IAAI,CAAC,iBAAiB,MAAM,CACvD,QAAO;AAGT,QAAO,OAAO,mBAAmB,MAAe;;;;;;;;;;;;;;ACxClD,MAAa,eAAgD,QAC1D,UAAwB,qBAAqB,EAC5C,oBAAoB;AAClB,OAAM,IAAI,MACR,mFAC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S,wBAAwB,QAAgC;AAC/D,KAAI,OAAO,WAAW,SACpB,QAAO;AAGT,QAAO,sBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-effect-runtime",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "description": "Core module that houses the Vite plugin to enable effectful execution.",
5
5
  "license": "BSD-3-Clause",
6
6
  "type": "module",