svelte-effect-runtime 3.3.0 → 3.4.0

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.
Files changed (62) hide show
  1. package/.dist/chunks/{client-BYhNKK1i.js → client-i7LwWCpT.js} +3 -3
  2. package/.dist/chunks/client-i7LwWCpT.js.map +1 -0
  3. package/.dist/chunks/descriptors-OS4VfJuW.js.map +1 -1
  4. package/.dist/chunks/{dispatcher-5WSjtyXR.js → dispatcher-BX6J0tQV.js} +3 -3
  5. package/.dist/chunks/dispatcher-BX6J0tQV.js.map +1 -0
  6. package/.dist/chunks/{dispatcher-BnitG7p3.js → dispatcher-D9PG87PW.js} +3 -2
  7. package/.dist/chunks/dispatcher-D9PG87PW.js.map +1 -0
  8. package/.dist/chunks/{errors-DppSJ83S.js → errors-Buz9cLGF.js} +55 -2
  9. package/.dist/chunks/errors-Buz9cLGF.js.map +1 -0
  10. package/.dist/chunks/{runtime-CPbQxe4W.js → runtime-L7xbXCiW.js} +4 -4
  11. package/.dist/chunks/runtime-L7xbXCiW.js.map +1 -0
  12. package/.dist/chunks/{transform-DHUCirwV.js → transform-B5T5TUcJ.js} +132 -43
  13. package/.dist/chunks/transform-B5T5TUcJ.js.map +1 -0
  14. package/.dist/chunks/vite-DiAwz7jc.js +465 -0
  15. package/.dist/chunks/vite-DiAwz7jc.js.map +1 -0
  16. package/.dist/detect.js.map +1 -1
  17. package/.dist/diagnostics.d.ts +21 -0
  18. package/.dist/dispatcher.js +1 -1
  19. package/.dist/errors.d.ts +39 -0
  20. package/.dist/internal/generators.js +2 -2
  21. package/.dist/internal/remote-client.js +1 -1
  22. package/.dist/markup/promise.js +1 -1
  23. package/.dist/markup/promise.js.map +1 -1
  24. package/.dist/markup/run.js +1 -1
  25. package/.dist/markup/run.js.map +1 -1
  26. package/.dist/markup/transform/emit.d.ts +2 -2
  27. package/.dist/markup/transform.js +1 -1
  28. package/.dist/markup/value.js +1 -1
  29. package/.dist/markup/value.js.map +1 -1
  30. package/.dist/mod.d.ts +1 -2
  31. package/.dist/mod.js +4 -5
  32. package/.dist/mod.js.map +1 -1
  33. package/.dist/remote/client.js +1 -1
  34. package/.dist/remote/server.js +1 -1
  35. package/.dist/remote/server.js.map +1 -1
  36. package/.dist/remote/shared.js.map +1 -1
  37. package/.dist/runtime/transform.js +45 -230
  38. package/.dist/runtime/transform.js.map +1 -1
  39. package/.dist/script-transform/index.d.ts +3 -3
  40. package/.dist/script-transform/runes.d.ts +0 -12
  41. package/.dist/script-transform/types.d.ts +1 -1
  42. package/.dist/server/index.d.ts +1 -0
  43. package/.dist/server/runtime.d.ts +13 -0
  44. package/.dist/server.js +2 -2
  45. package/.dist/server.js.map +1 -1
  46. package/.dist/vite.d.ts +3 -3
  47. package/.dist/vite.js +1 -145
  48. package/README.md +5 -5
  49. package/package.json +2 -7
  50. package/.dist/chunks/client-BYhNKK1i.js.map +0 -1
  51. package/.dist/chunks/dispatcher-5WSjtyXR.js.map +0 -1
  52. package/.dist/chunks/dispatcher-BnitG7p3.js.map +0 -1
  53. package/.dist/chunks/errors-DppSJ83S.js.map +0 -1
  54. package/.dist/chunks/grammars-i4CSRxWg.js +0 -181
  55. package/.dist/chunks/grammars-i4CSRxWg.js.map +0 -1
  56. package/.dist/chunks/runtime-CPbQxe4W.js.map +0 -1
  57. package/.dist/chunks/transform-DHUCirwV.js.map +0 -1
  58. package/.dist/grammars/textmate.d.ts +0 -105
  59. package/.dist/grammars/tree-sitter.d.ts +0 -22
  60. package/.dist/grammars.d.ts +0 -2
  61. package/.dist/grammars.js +0 -2
  62. package/.dist/vite.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-5WSjtyXR.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BX6J0tQV.js";
2
2
  //#region src/markup/promise.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup transform for
@@ -1 +1 @@
1
- {"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Options for markup promise behavior during server rendering.\n *\n * @since 2.4.0\n */\ninterface MarkupPromiseOptions {\n /** Keep the SSR promise pending so Svelte renders an await block fallback. */\n ssr?: \"pending\";\n}\n\n/**\n * Runtime helper emitted by the markup transform for\n * `{#await yield* expr}` blocks. Delegates to the dispatcher's\n * promise mechanism. During SSR it can return a fallback promise without\n * starting the dispatcher.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies.\n * @param factory - Generator function that yields the effect to run.\n * @param ssr_fallback - Value to resolve during SSR when the helper is used\n * from an awaited expression outside a Svelte await block.\n * @param options - Optional SSR behavior for contexts such as await blocks\n * that should render pending UI.\n * @returns A Promise that resolves with the effect's result.\n */\nexport function promise<A, E, R>(\n id: string,\n deps: readonly unknown[],\n factory: () => Effect.gen.Return<A, E, R>,\n ssr_fallback?: A,\n options?: MarkupPromiseOptions,\n): Promise<A> {\n if (is_server_render()) {\n if (options?.ssr === \"pending\") {\n return new Promise<A>(() => {});\n }\n\n if (arguments.length >= 4) {\n return Promise.resolve(ssr_fallback as A);\n }\n }\n\n return get_dispatcher().promise({ id, deps, factory });\n}\n\nfunction is_server_render(): boolean {\n return typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QACd,IACA,MACA,SACA,cACA,SACY;CACZ,IAAI,iBAAiB,GAAG;EACtB,IAAI,SAAS,QAAQ,WACnB,OAAO,IAAI,cAAiB,CAAC,CAAC;EAGhC,IAAI,UAAU,UAAU,GACtB,OAAO,QAAQ,QAAQ,YAAiB;CAE5C;CAEA,OAAO,eAAe,EAAE,QAAQ;EAAE;EAAI;EAAM;CAAQ,CAAC;AACvD;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
1
+ {"version":3,"file":"promise.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/promise.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\r\nimport type { Effect } from \"effect\";\r\n\r\n/**\r\n * Options for markup promise behavior during server rendering.\r\n *\r\n * @since 2.4.0\r\n */\r\ninterface MarkupPromiseOptions {\r\n /** Keep the SSR promise pending so Svelte renders an await block fallback. */\r\n ssr?: \"pending\";\r\n}\r\n\r\n/**\r\n * Runtime helper emitted by the markup transform for\r\n * `{#await yield* expr}` blocks. Delegates to the dispatcher's\r\n * promise mechanism. During SSR it can return a fallback promise without\r\n * starting the dispatcher.\r\n *\r\n * @since 2.0.0\r\n * @param id - Stable identifier generated from the expression's source\r\n * position, used for cache lookups.\r\n * @param deps - Array of reactive dependencies.\r\n * @param factory - Generator function that yields the effect to run.\r\n * @param ssr_fallback - Value to resolve during SSR when the helper is used\r\n * from an awaited expression outside a Svelte await block.\r\n * @param options - Optional SSR behavior for contexts such as await blocks\r\n * that should render pending UI.\r\n * @returns A Promise that resolves with the effect's result.\r\n */\r\nexport function promise<A, E, R>(\r\n id: string,\r\n deps: readonly unknown[],\r\n factory: () => Effect.gen.Return<A, E, R>,\r\n ssr_fallback?: A,\r\n options?: MarkupPromiseOptions,\r\n): Promise<A> {\r\n if (is_server_render()) {\r\n if (options?.ssr === \"pending\") {\r\n return new Promise<A>(() => {});\r\n }\r\n\r\n if (arguments.length >= 4) {\r\n return Promise.resolve(ssr_fallback as A);\r\n }\r\n }\r\n\r\n return get_dispatcher().promise({ id, deps, factory });\r\n}\r\n\r\nfunction is_server_render(): boolean {\r\n return typeof document === \"undefined\";\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,QACd,IACA,MACA,SACA,cACA,SACY;CACZ,IAAI,iBAAiB,GAAG;EACtB,IAAI,SAAS,QAAQ,WACnB,OAAO,IAAI,cAAiB,CAAC,CAAC;EAGhC,IAAI,UAAU,UAAU,GACtB,OAAO,QAAQ,QAAQ,YAAiB;CAE5C;CAEA,OAAO,eAAe,EAAE,QAAQ;EAAE;EAAI;EAAM;CAAQ,CAAC;AACvD;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-5WSjtyXR.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BX6J0tQV.js";
2
2
  import { Effect } from "effect";
3
3
  //#region src/markup/run.ts
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for inline event\n * handlers containing `yield*`. Wraps the user's generator in an\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\n * mechanism.\n *\n * @since 2.0.0\n * @param factory - Generator function that yields the effect to run.\n * @returns A Promise that resolves or rejects when the effect completes.\n */\nexport function run<A, E, R>(\n factory: () => Effect.gen.Return<A, E, R>,\n): Promise<A> {\n const effect = Effect.gen(factory);\n\n return get_dispatcher().run(effect);\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,IACd,SACY;CACZ,MAAM,SAAS,OAAO,IAAI,OAAO;CAEjC,OAAO,eAAe,EAAE,IAAI,MAAM;AACpC"}
1
+ {"version":3,"file":"run.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/run.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\r\nimport { Effect } from \"effect\";\r\n\r\n/**\r\n * Runtime helper emitted by the markup transform for inline event\r\n * handlers containing `yield*`. Wraps the user's generator in an\r\n * `Effect.gen` and delegates to the dispatcher's fire-and-forget\r\n * mechanism.\r\n *\r\n * @since 2.0.0\r\n * @param factory - Generator function that yields the effect to run.\r\n * @returns A Promise that resolves or rejects when the effect completes.\r\n */\r\nexport function run<A, E, R>(\r\n factory: () => Effect.gen.Return<A, E, R>,\r\n): Promise<A> {\r\n const effect = Effect.gen(factory);\r\n\r\n return get_dispatcher().run(effect);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,IACd,SACY;CACZ,MAAM,SAAS,OAAO,IAAI,OAAO;CAEjC,OAAO,eAAe,EAAE,IAAI,MAAM;AACpC"}
@@ -1,5 +1,5 @@
1
1
  import type { EffectCallbackRewriteContext } from "./effect-bindings.js";
2
- import type { MarkupCandidate, MarkupHelperBindings, MarkupNameAllocator, Replacement, TagKind } from "./types.js";
2
+ import type { MarkupCandidate, MarkupHelperBindings, MarkupNameAllocator, MarkupTransformTarget, Replacement, TagKind } from "./types.js";
3
3
  /**
4
4
  * Emits source edits for classified markup Effect expressions.
5
5
  *
@@ -12,4 +12,4 @@ import type { MarkupCandidate, MarkupHelperBindings, MarkupNameAllocator, Replac
12
12
  export declare function emit_replacements(classified: Array<{
13
13
  candidate: MarkupCandidate;
14
14
  kind: TagKind;
15
- }>, effect_context: EffectCallbackRewriteContext, helper_bindings: MarkupHelperBindings, name_allocator: MarkupNameAllocator): Replacement[];
15
+ }>, effect_context: EffectCallbackRewriteContext, helper_bindings: MarkupHelperBindings, name_allocator: MarkupNameAllocator, target: MarkupTransformTarget): Replacement[];
@@ -1,2 +1,2 @@
1
- import { t as transform_markup_effect } from "../chunks/transform-DHUCirwV.js";
1
+ import { t as transform_markup_effect } from "../chunks/transform-B5T5TUcJ.js";
2
2
  export { transform_markup_effect };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-5WSjtyXR.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BX6J0tQV.js";
2
2
  //#region src/markup/value.ts
3
3
  /**
4
4
  * Runtime helper emitted by the markup transform for `{yield* expr}`
@@ -1 +1 @@
1
- {"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\nimport type { Effect } from \"effect\";\n\n/**\n * Runtime helper emitted by the markup transform for `{yield* expr}`\n * expressions in Svelte templates. Delegates to the dispatcher's\n * cached reactive value mechanism — returns the fallback synchronously,\n * then the resolved value once the effect completes in the browser. During\n * SSR the client dispatcher is not touched, so browser-only layers cannot\n * turn server rendering into a 500.\n *\n * @since 2.0.0\n * @param id - Stable identifier generated from the expression's source\n * position, used for cache lookups.\n * @param deps - Array of reactive dependencies (free identifiers in the\n * expression). When any dep changes, the previous fiber is cancelled\n * and a new one starts.\n * @param fallback - Value returned while the effect is running.\n * @param factory - Generator function that yields the effect to run.\n * @returns The cached value if resolved, or the fallback.\n */\nexport function value<A, F, E, R>(\n id: string,\n deps: readonly unknown[],\n fallback: F,\n factory: () => Effect.gen.Return<A, E, R>,\n): A | F {\n if (is_server_render()) {\n return fallback;\n }\n\n return get_dispatcher().value<A | F>({ id, deps, fallback, factory });\n}\n\nfunction is_server_render(): boolean {\n return typeof document === \"undefined\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,MACd,IACA,MACA,UACA,SACO;CACP,IAAI,iBAAiB,GACnB,OAAO;CAGT,OAAO,eAAe,EAAE,MAAa;EAAE;EAAI;EAAM;EAAU;CAAQ,CAAC;AACtE;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
1
+ {"version":3,"file":"value.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/markup/value.ts"],"sourcesContent":["import { get_dispatcher } from \"$/generated/dispatcher.ts\";\r\nimport type { Effect } from \"effect\";\r\n\r\n/**\r\n * Runtime helper emitted by the markup transform for `{yield* expr}`\r\n * expressions in Svelte templates. Delegates to the dispatcher's\r\n * cached reactive value mechanism — returns the fallback synchronously,\r\n * then the resolved value once the effect completes in the browser. During\r\n * SSR the client dispatcher is not touched, so browser-only layers cannot\r\n * turn server rendering into a 500.\r\n *\r\n * @since 2.0.0\r\n * @param id - Stable identifier generated from the expression's source\r\n * position, used for cache lookups.\r\n * @param deps - Array of reactive dependencies (free identifiers in the\r\n * expression). When any dep changes, the previous fiber is cancelled\r\n * and a new one starts.\r\n * @param fallback - Value returned while the effect is running.\r\n * @param factory - Generator function that yields the effect to run.\r\n * @returns The cached value if resolved, or the fallback.\r\n */\r\nexport function value<A, F, E, R>(\r\n id: string,\r\n deps: readonly unknown[],\r\n fallback: F,\r\n factory: () => Effect.gen.Return<A, E, R>,\r\n): A | F {\r\n if (is_server_render()) {\r\n return fallback;\r\n }\r\n\r\n return get_dispatcher().value<A | F>({ id, deps, fallback, factory });\r\n}\r\n\r\nfunction is_server_render(): boolean {\r\n return typeof document === \"undefined\";\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,MACd,IACA,MACA,UACA,SACO;CACP,IAAI,iBAAiB,GACnB,OAAO;CAGT,OAAO,eAAe,EAAE,MAAa;EAAE;EAAI;EAAM;EAAU;CAAQ,CAAC;AACtE;AAEA,SAAS,mBAA4B;CACnC,OAAO,OAAO,aAAa;AAC7B"}
package/.dist/mod.d.ts CHANGED
@@ -171,8 +171,7 @@ export declare const RequestEvent: Context.Reference<RequestEventShape>;
171
171
  export declare const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never>;
172
172
  /** Re-export error types users need for typed catch handlers. */
173
173
  export type { FormError, FormIssue, RemoteFailure, RemoteHttpError, RemoteTransportError, RemoteValidationError, } from "./remote/shared.js";
174
- export { TextMate, textmate, textmate_language, type TextMateCaptureMap, type TextMateGrammarBundle, type TextMateLanguageRegistration, type TextMateRawRule, type TextMateRepository, tree_sitter, TreesitterQuery, type TreeSitterQueryBundle, } from "./grammars.js";
175
- export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, } from "./errors.js";
174
+ export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, DispatcherDisposedError, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, } from "./errors.js";
176
175
  export { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, } from "./remote/shared.js";
177
176
  /** Re-export app setup helpers so users can import them from root. */
178
177
  export { effect, type EffectOptions } from "./vite.js";
package/.dist/mod.js CHANGED
@@ -1,8 +1,7 @@
1
- import { C as UncheckedPrerenderHandlerMissingError, D as UnsupportedRemoteFormResponseError, E as UnsupportedMarkupEffectPositionError, O as YieldStarInEventCallbackError, S as UncheckedLiveQueryHandlerMissingError, T as UnknownRuntimeError, _ as RuntimeError, a as DispatcherDisposedError, b as UncheckedCommandHandlerMissingError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as ServerOnlyImportError, w as UncheckedQueryHandlerMissingError, x as UncheckedFormHandlerMissingError, y as SvelteKitServerExportUnavailableError } from "./chunks/errors-DppSJ83S.js";
2
- import { t as Dispatcher } from "./chunks/dispatcher-BnitG7p3.js";
3
- import { n as textmate, r as textmate_language, t as tree_sitter } from "./chunks/grammars-i4CSRxWg.js";
1
+ import { A as YieldStarInEventCallbackError, C as UncheckedLiveQueryHandlerMissingError, D as UnsupportedMarkupEffectPositionError, E as UnknownRuntimeError, O as UnsupportedRemoteFormResponseError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, _ as RuntimeAlreadyInitializedError, a as DispatcherDisposedError, b as SvelteKitServerExportUnavailableError, c as InvalidLiveQueryReturnError, d as PreprocessError, f as RemoteErrorDecodeError, g as RequestEventUnavailableError, h as RemoteHelperError, i as BatchQueryHandlerMissingError, k as VitePreTransformPluginConflictError, l as InvalidQueryFactoryError, m as RemoteHelperContextError, n as AsyncEffectInSyncRuneError, o as InvalidCommandFactoryError, p as RemoteFormEndpointMissingError, r as AwaitInEffectWorkError, s as InvalidLiveQueryFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidRemoteFormResponseError, v as RuntimeError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError, y as ServerOnlyImportError } from "./chunks/errors-Buz9cLGF.js";
2
+ import { t as Dispatcher } from "./chunks/dispatcher-D9PG87PW.js";
4
3
  import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
5
- import { effect } from "./vite.js";
4
+ import { t as effect } from "./chunks/vite-DiAwz7jc.js";
6
5
  //#region src/mod.ts
7
6
  /**
8
7
  * Public API surface for `svelte-effect-runtime`.
@@ -192,6 +191,6 @@ function make_server_only_error(name) {
192
191
  return new ServerOnlyImportError(name);
193
192
  }
194
193
  //#endregion
195
- export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, textmate as TextMate, textmate, tree_sitter as TreesitterQuery, tree_sitter, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error, textmate_language };
194
+ export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnknownRuntimeError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, VitePreTransformPluginConflictError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
196
195
 
197
196
  //# 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 { ServerOnlyImportError } from \"$/errors.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 * 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 TextMate,\n textmate,\n textmate_language,\n type TextMateCaptureMap,\n type TextMateGrammarBundle,\n type TextMateLanguageRegistration,\n type TextMateRawRule,\n type TextMateRepository,\n tree_sitter,\n TreesitterQuery,\n type TreeSitterQueryBundle,\n} from \"./grammars.ts\";\n\nexport {\n AsyncEffectInEventCallbackError,\n AsyncEffectInSyncRuneError,\n AwaitInEffectWorkError,\n BatchQueryHandlerMissingError,\n DispatcherDisposedError,\n InvalidCommandFactoryError,\n InvalidLiveQueryFactoryError,\n InvalidLiveQueryReturnError,\n InvalidQueryFactoryError,\n InvalidRemoteFormResponseError,\n PreprocessError,\n RemoteErrorDecodeError,\n RemoteFormEndpointMissingError,\n RemoteHelperContextError,\n RemoteHelperError,\n RequestEventUnavailableError,\n RuntimeError,\n ServerOnlyImportError,\n SvelteKitServerExportUnavailableError,\n UncheckedCommandHandlerMissingError,\n UncheckedFormHandlerMissingError,\n UncheckedLiveQueryHandlerMissingError,\n UncheckedPrerenderHandlerMissingError,\n UncheckedQueryHandlerMissingError,\n UnknownRuntimeError,\n UnsupportedMarkupEffectPositionError,\n UnsupportedRemoteFormResponseError,\n YieldStarInEventCallbackError,\n} from \"$/errors.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 SchemaEncodedInput,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n StandardSchemaInput,\n StandardSchemaOutput,\n} from \"$/server/types.ts\";\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 ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;AA6G3D,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,sBAAsB,IAAI;AACvC"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\r\nimport { ServerOnlyImportError } from \"$/errors.ts\";\r\nimport type {\r\n ErrorEffectFactory,\r\n RedirectEffectFactory,\r\n} from \"$/server/control-flow.ts\";\r\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\r\nimport type {\r\n CommandFactory,\r\n FormFactory,\r\n PrerenderFactory,\r\n QueryFactory,\r\n ServerRuntimeFactory,\r\n} from \"$/server/types.ts\";\r\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\r\n\r\n/**\r\n * Public API surface for `svelte-effect-runtime`.\r\n *\r\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\r\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\r\n * route server-only helpers to the server entrypoint automatically.\r\n *\r\n * @module\r\n */\r\n\r\n/**\r\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\r\n * in `hooks.client.ts` to provide services to every component's effect\r\n * blocks.\r\n *\r\n * If never called, a default empty-layer runtime is created lazily on\r\n * the first `yield*` expression.\r\n *\r\n * @example\r\n * ```ts\r\n * import { ClientRuntime } from \"svelte-effect-runtime\";\r\n * import { Db } from \"./db.ts\";\r\n *\r\n * ClientRuntime.make(Db.Live);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport class ClientRuntime {\r\n /**\r\n * Build and cache the client-side dispatcher runtime.\r\n *\r\n * @since 2.0.0\r\n * @param layer - Optional Effect layer to provide to the runtime.\r\n */\r\n static make<R = never>(layer?: Layer.Layer<R>): void {\r\n InternalDispatcher.make(layer);\r\n }\r\n}\r\n\r\n/**\r\n * Server-side runtime singleton export. In SvelteKit server files the Vite\r\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\r\n * name resolves to the real server implementation before it is evaluated.\r\n *\r\n * @example\r\n * ```ts\r\n * import { ServerRuntime } from \"svelte-effect-runtime\";\r\n *\r\n * ServerRuntime.make();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\r\n \"ServerRuntime\",\r\n) as never;\r\n\r\n/**\r\n * Remote query factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Query } from \"svelte-effect-runtime\";\r\n *\r\n * export const GetPosts = Query(Effect.succeed([]));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Query: QueryFactory = Object.assign(\r\n make_server_only_function(\"Query\"),\r\n {\r\n batch: make_server_only_function(\"Query.batch\"),\r\n live: make_server_only_function(\"Query.live\"),\r\n },\r\n) as never;\r\n\r\n/**\r\n * Remote command factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Command } from \"svelte-effect-runtime\";\r\n *\r\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Command: CommandFactory = make_server_only_function(\r\n \"Command\",\r\n) as never;\r\n\r\n/**\r\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\r\n * from the root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Error } from \"svelte-effect-runtime\";\r\n *\r\n * return yield* Error(\"NotFound\", \"Post not found\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport const Error: ErrorEffectFactory = make_server_only_function(\r\n \"Error\",\r\n) as never;\r\n\r\n/**\r\n * Remote form factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Form } from \"svelte-effect-runtime\";\r\n *\r\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Form: FormFactory = make_server_only_function(\r\n \"Form\",\r\n) as never;\r\n\r\n/**\r\n * Remote prerender factory export for `.remote.ts` files imported from the\r\n * root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Prerender } from \"svelte-effect-runtime\";\r\n *\r\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Prerender: PrerenderFactory = make_server_only_function(\r\n \"Prerender\",\r\n) as never;\r\n\r\n/**\r\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\r\n * the root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Redirect } from \"svelte-effect-runtime\";\r\n *\r\n * return yield* Redirect(\"SeeOther\", \"/posts\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\r\n \"Redirect\",\r\n) as never;\r\n\r\n/**\r\n * Current SvelteKit request event service export for `.remote.ts` files\r\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\r\n * server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { RequestEvent } from \"svelte-effect-runtime\";\r\n *\r\n * const event = yield* RequestEvent;\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const RequestEvent: Context.Reference<RequestEventShape> =\r\n make_server_only_function(\"RequestEvent\") as never;\r\n\r\n/**\r\n * Returns the active server runtime when imported from a server file. The Vite\r\n * plugin rewrites root imports to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\r\n *\r\n * const runtime = get_server_runtime_or_throw();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\r\n unknown,\r\n never\r\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\r\n\r\n/** Re-export error types users need for typed catch handlers. */\r\nexport type {\r\n FormError,\r\n FormIssue,\r\n RemoteFailure,\r\n RemoteHttpError,\r\n RemoteTransportError,\r\n RemoteValidationError,\r\n} from \"$/remote/shared.ts\";\r\n\r\nexport {\r\n AsyncEffectInEventCallbackError,\r\n AsyncEffectInSyncRuneError,\r\n AwaitInEffectWorkError,\r\n BatchQueryHandlerMissingError,\r\n DispatcherDisposedError,\r\n InvalidCommandFactoryError,\r\n InvalidLiveQueryFactoryError,\r\n InvalidLiveQueryReturnError,\r\n InvalidQueryFactoryError,\r\n InvalidRemoteFormResponseError,\r\n PreprocessError,\r\n RemoteErrorDecodeError,\r\n RemoteFormEndpointMissingError,\r\n RemoteHelperContextError,\r\n RemoteHelperError,\r\n RequestEventUnavailableError,\r\n RuntimeAlreadyInitializedError,\r\n RuntimeError,\r\n ServerOnlyImportError,\r\n SvelteKitServerExportUnavailableError,\r\n UncheckedCommandHandlerMissingError,\r\n UncheckedFormHandlerMissingError,\r\n UncheckedLiveQueryHandlerMissingError,\r\n UncheckedPrerenderHandlerMissingError,\r\n UncheckedQueryHandlerMissingError,\r\n UnknownRuntimeError,\r\n UnsupportedMarkupEffectPositionError,\r\n UnsupportedRemoteFormResponseError,\r\n VitePreTransformPluginConflictError,\r\n YieldStarInEventCallbackError,\r\n} from \"$/errors.ts\";\r\n\r\nexport {\r\n is_form_error,\r\n is_remote_http_error,\r\n is_remote_transport_error,\r\n is_remote_validation_error,\r\n} from \"$/remote/shared.ts\";\r\n\r\n/** Re-export app setup helpers so users can import them from root. */\r\nexport { effect, type EffectOptions } from \"$/vite.ts\";\r\n\r\n/** Re-export server helper types from the root entrypoint. */\r\nexport type {\r\n ErrorEffectFactory,\r\n ErrorStatus,\r\n ErrorStatusName,\r\n RedirectEffectFactory,\r\n RedirectStatus,\r\n RedirectStatusName,\r\n} from \"$/server/control-flow.ts\";\r\n\r\n/** Re-export server helper types from the root entrypoint. */\r\nexport type {\r\n CommandFactory,\r\n EffectLike,\r\n EffectRemoteBatchHandler,\r\n EffectRemoteCommand,\r\n EffectRemoteForm,\r\n EffectRemoteFunction,\r\n EffectRemoteLiveQuery,\r\n EffectRemoteLiveQueryFunction,\r\n EffectRemoteLiveQueryResource,\r\n EffectRemoteLiveSource,\r\n EffectRemoteQuery,\r\n EffectRemoteQueryFunction,\r\n FormFactory,\r\n FormInvalid,\r\n PrerenderFactory,\r\n PrerenderOptions,\r\n QueryBatchFactory,\r\n QueryFactory,\r\n QueryLiveFactory,\r\n RemoteFormHandler,\r\n RemoteHandler,\r\n RemoteLiveHandler,\r\n SchemaEncodedInput,\r\n SchemaInput,\r\n ServerRuntimeFactory,\r\n StandardSchema,\r\n StandardSchemaInput,\r\n StandardSchemaOutput,\r\n} from \"$/server/types.ts\";\r\n\r\nfunction make_server_only_class(name: string): unknown {\r\n return class ServerOnlyRuntime {\r\n static make(): never {\r\n throw make_server_only_error(name);\r\n }\r\n };\r\n}\r\n\r\nfunction make_server_only_function(\r\n name: string,\r\n): (...args: unknown[]) => never {\r\n return (..._args: unknown[]): never => {\r\n throw make_server_only_error(name);\r\n };\r\n}\r\n\r\nfunction make_server_only_error(name: string): globalThis.Error {\r\n return new ServerOnlyImportError(name);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;AAiG3D,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,sBAAsB,IAAI;AACvC"}
@@ -1,2 +1,2 @@
1
- import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-BYhNKK1i.js";
1
+ import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-i7LwWCpT.js";
2
2
  export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
@@ -1,4 +1,4 @@
1
- import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-DppSJ83S.js";
1
+ import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-Buz9cLGF.js";
2
2
  import { create_serialized_remote_failure_envelope } from "./shared.js";
3
3
  import { Cause, Effect, Exit } from "effect";
4
4
  import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
@@ -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 { RemoteHelperContextError, RemoteHelperError } from \"$/errors.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 — let cancellation escape without becoming a remote failure.\n */\n if (Cause.hasInterruptsOnly(cause)) {\n throw Cause.squash(cause);\n }\n\n /**\n * Phase 3 — 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 4 — 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 RemoteHelperContextError(helper_name);\n }\n\n return err instanceof Error ? err : new RemoteHelperError(err);\n}\n"],"mappings":"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"}
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\";\r\nimport type { FormIssue } from \"$/remote/shared.ts\";\r\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\r\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\r\nimport { Cause, Effect, Exit } from \"effect\";\r\nimport { stringify } from \"devalue\";\r\n\r\ntype CauseReason = {\r\n readonly _tag: string;\r\n readonly defect?: unknown;\r\n readonly error?: unknown;\r\n};\r\n\r\n/**\r\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\r\n * exit into the shape expected by SvelteKit, and returns the result or\r\n * throws a SvelteKit-compatible error.\r\n *\r\n * @since 2.0.0\r\n * @param effect - The Effect program to execute.\r\n * @param runtime - The server-side ManagedRuntime.\r\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\r\n * @param error - SvelteKit's `error` helper.\r\n * @returns A Promise that resolves with the effect's success value.\r\n * @internal\r\n */\r\nexport async function run_remote_effect<A>(\r\n effect: Effect.Effect<A, unknown, unknown>,\r\n runtime: {\r\n runPromise: (\r\n e: Effect.Effect<unknown, unknown, unknown>,\r\n ) => Promise<unknown>;\r\n },\r\n invalid: (status: number, body: unknown) => never,\r\n error: (status: number, body: unknown) => never,\r\n): Promise<A> {\r\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\r\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\r\n ) as Exit.Exit<A, unknown>;\r\n\r\n if (Exit.isSuccess(exit)) {\r\n return exit.value;\r\n }\r\n\r\n handle_failure(exit.cause, invalid, error);\r\n}\r\n\r\n/**\r\n * Inspects the Effect Cause for failures and either throws a form\r\n * validation error (via SvelteKit's `invalid`) or encodes the error\r\n * and throws it via SvelteKit's `error`.\r\n */\r\nfunction handle_failure(\r\n cause: Cause.Cause<unknown>,\r\n invalid: (status: number, body: unknown) => never,\r\n error: (status: number, body: unknown) => never,\r\n): never {\r\n const reasons = get_cause_reasons(cause);\r\n\r\n /**\r\n * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\r\n */\r\n for (const reason of reasons) {\r\n if (!Cause.isDieReason(reason as never)) {\r\n continue;\r\n }\r\n\r\n const defect = reason.defect;\r\n\r\n if (is_sveltekit_control_flow(defect)) {\r\n throw defect;\r\n }\r\n }\r\n\r\n /**\r\n * Phase 2 — let cancellation escape without becoming a remote failure.\r\n */\r\n if (Cause.hasInterruptsOnly(cause)) {\r\n throw Cause.squash(cause);\r\n }\r\n\r\n /**\r\n * Phase 3 — preserve typed form validation failures.\r\n */\r\n for (const reason of reasons) {\r\n if (Cause.isFailReason(reason as never)) {\r\n const failure = reason.error;\r\n if (\r\n typeof failure === \"object\" &&\r\n failure !== null &&\r\n (failure as Record<string, unknown>)._tag === \"FormError\"\r\n ) {\r\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\r\n [];\r\n invalid(400, { issues });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Phase 4 — encode all other failures for the remote client.\r\n */\r\n const encoded = encode_remote_failure(cause);\r\n const envelope = create_serialized_remote_failure_envelope(encoded);\r\n\r\n error(500, envelope);\r\n}\r\n\r\n/**\r\n * Encodes an Effect Cause into a string that the client-side adapter can\r\n * decode back into a typed `RemoteFailure`.\r\n *\r\n * @since 2.0.0\r\n * @param cause - The Effect Cause from a failed execution.\r\n * @returns A devalue-encoded string representing the serialised failure.\r\n * @internal\r\n */\r\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\r\n const reasons = get_cause_reasons(cause);\r\n\r\n for (const reason of reasons) {\r\n if (Cause.isFailReason(reason as never)) {\r\n const failure = reason.error;\r\n\r\n const encoded = stringify_failure(failure);\r\n\r\n if (encoded !== undefined) {\r\n return encoded;\r\n }\r\n\r\n const serializable_failure = to_serializable_failure(failure);\r\n const serializable_encoded = stringify_failure(serializable_failure);\r\n\r\n if (serializable_encoded !== undefined) {\r\n return serializable_encoded;\r\n }\r\n }\r\n }\r\n\r\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\r\n}\r\n\r\nfunction get_cause_reasons(\r\n cause: Cause.Cause<unknown>,\r\n): readonly CauseReason[] {\r\n const reasons = (cause as unknown as { reasons?: readonly CauseReason[] })\r\n .reasons;\r\n\r\n return reasons ?? [];\r\n}\r\n\r\nfunction is_sveltekit_control_flow(value: unknown): boolean {\r\n return isRedirect(value) || isHttpError(value) || isValidationError(value);\r\n}\r\n\r\nfunction stringify_failure(value: unknown): string | undefined {\r\n try {\r\n return stringify(value);\r\n } catch {\r\n return undefined;\r\n }\r\n}\r\n\r\nfunction to_serializable_failure(\r\n value: unknown,\r\n seen = new WeakSet<object>(),\r\n): unknown {\r\n if (typeof value === \"function\" || typeof value === \"symbol\") {\r\n return undefined;\r\n }\r\n\r\n if (!is_object_like(value)) {\r\n return value;\r\n }\r\n\r\n if (stringify_failure(value) !== undefined) {\r\n return value;\r\n }\r\n\r\n if (seen.has(value)) {\r\n return undefined;\r\n }\r\n\r\n seen.add(value);\r\n\r\n const serializable = Array.isArray(value)\r\n ? value.map((item) => to_serializable_failure(item, seen))\r\n : to_plain_record(value, seen);\r\n\r\n seen.delete(value);\r\n\r\n return serializable;\r\n}\r\n\r\nfunction to_plain_record(\r\n value: object,\r\n seen: WeakSet<object>,\r\n): Record<string, unknown> {\r\n const descriptors = Object.getOwnPropertyDescriptors(value);\r\n const record: Record<string, unknown> = {};\r\n\r\n for (const [key, descriptor] of Object.entries(descriptors)) {\r\n if (key === \"stack\" || !(\"value\" in descriptor)) {\r\n continue;\r\n }\r\n\r\n record[key] = to_serializable_failure(descriptor.value, seen);\r\n }\r\n\r\n if (value instanceof Error && !(\"message\" in record)) {\r\n record.message = value.message;\r\n }\r\n\r\n return record;\r\n}\r\n\r\nfunction is_object_like(value: unknown): value is object {\r\n return typeof value === \"object\" && value !== null;\r\n}\r\n\r\n/**\r\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\r\n * through to the request-scoped `invalid` helper.\r\n *\r\n * @example\r\n * ```ts\r\n * throw_form_error(\r\n * [{ message: \"Name is required\", path: [\"name\"] }],\r\n * invalid,\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param issues - The list of form validation issues.\r\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\r\n * @internal\r\n */\r\nexport function throw_form_error(\r\n issues: readonly FormIssue[],\r\n invalid: (status: number, body: unknown) => never,\r\n): never {\r\n invalid(400, { issues });\r\n}\r\n\r\n/**\r\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\r\n * into clear, actionable messages.\r\n *\r\n * @example\r\n * ```ts\r\n * try {\r\n * return native_query(handler);\r\n * } catch (err) {\r\n * throw normalize_remote_helper_error(err, \"Query\");\r\n * }\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param err - The error thrown by SvelteKit's native functions.\r\n * @param helper_name - Name of the helper that triggered the error.\r\n * @returns A more descriptive error.\r\n * @internal\r\n */\r\nexport function normalize_remote_helper_error(\r\n err: unknown,\r\n helper_name: string,\r\n): globalThis.Error {\r\n const message = err instanceof Error ? err.message : String(err);\r\n\r\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\r\n return new RemoteHelperContextError(helper_name);\r\n }\r\n\r\n return err instanceof Error ? err : new RemoteHelperError(err);\r\n}\r\n"],"mappings":"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["/**\n * Shared types, markers, and constructors used by both the client-side remote\n * adapters and the server-side handler runtime. These types define the error\n * protocol that flows across the network boundary.\n *\n * @since 2.0.0\n */\n\n/**\n * Well-known marker injected into every serialised remote-failure envelope\n * so the client can reliably distinguish runtime errors from domain values.\n *\n * @since 2.0.0\n * @internal\n */\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\n\n/**\n * Well-known symbol used to attach a payload decoder to a remote function\n * so the client's transport layer can decode domain error types.\n *\n * @since 2.0.0\n * @internal\n */\nexport const REMOTE_ERROR_DECODER = Symbol.for(\n \"svelte-effect-runtime/remote-error-decoder\",\n);\n\n/** Form validation helpers and types. */\n\n/**\n * A single field-level or form-level validation issue reported by a\n * {@link Form} handler.\n *\n * @since 2.0.0\n */\nexport interface FormIssue {\n /** Human-readable validation message. */\n message: string;\n /** Path to the offending field as an array of string-or-number keys. */\n path: (string | number)[];\n}\n\n/**\n * Error subtype thrown by {@link Form} handlers to signal validation\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\n * helper on the server and surfaced as `FormError` on the client.\n *\n * @since 2.0.0\n */\nexport interface FormError<SchemaType = unknown> {\n readonly _tag: \"FormError\";\n readonly issues: readonly FormIssue[];\n /** Phantom type slot for the schema this error was derived from. */\n readonly _schema?: SchemaType;\n}\n\n/**\n * Creates a {@link FormError} holding the given issues.\n *\n * @since 2.0.0\n * @param issues - The validation issues to attach.\n * @returns A FormError with the `_tag` set and no schema reference.\n */\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\n return { _tag: \"FormError\", issues };\n}\n\n/**\n * Type guard that narrows an unknown value to a {@link FormError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a FormError.\n */\nexport function is_form_error(value: unknown): value is FormError {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"FormError\"\n );\n}\n\n/** Remote error types shared by client and server helpers. */\n\n/**\n * Union of all wire-level error shapes that a remote function can\n * surface on its error channel.\n *\n * @example\n * ```ts\n * const result = yield* myQuery();\n * // error channel is RemoteFailure<DomainError>\n * ```\n *\n * @since 2.0.0\n */\nexport type RemoteFailure<ErrorType> =\n | ErrorType\n | RemoteValidationError\n | RemoteHttpError\n | RemoteTransportError;\n\n/**\n * Validation errors that originate from a server-side {@link Form}\n * handler calling `invalid()` (SvelteKit's `fail`).\n *\n * @since 2.0.0\n */\nexport interface RemoteValidationError {\n readonly _tag: \"RemoteValidationError\";\n readonly issues?: readonly FormIssue[];\n readonly body?: unknown;\n readonly status: number;\n}\n\n/**\n * HTTP-level errors with a status code and optional response body. Raised\n * when the server explicitly calls SvelteKit's `error(status, body)`.\n *\n * @since 2.0.0\n */\nexport interface RemoteHttpError {\n readonly _tag: \"RemoteHttpError\";\n readonly status: number;\n readonly body?: unknown;\n readonly cause?: unknown;\n}\n\n/**\n * Transport-level errors raised by the client adapter when the network\n * request fails or the response cannot be decoded.\n *\n * @since 2.0.0\n */\nexport interface RemoteTransportError {\n readonly _tag: \"RemoteTransportError\";\n readonly cause?: unknown;\n readonly body?: unknown;\n}\n\n/**\n * Wire format for an encoded remote failure. The server wraps domain\n * errors in this envelope before serialising them with devalue.\n *\n * @since 2.0.0\n * @internal\n */\nexport interface SerializedRemoteFailureEnvelope {\n readonly __svelte_effect_remote__: true;\n readonly encoded: string;\n}\n\n/** Constructors for structured remote error values. */\n\n/**\n * Creates a {@link RemoteValidationError} from a list of form issues.\n *\n * @since 2.0.0\n * @param issues - The validation issues reported by the server handler.\n * @param body - Optional response body returned alongside the error.\n * @param status - HTTP status code (defaults to 400).\n * @returns A remote-validation error shape.\n * @internal\n */\nexport function create_remote_validation_error(\n issues: readonly FormIssue[],\n body?: unknown,\n status = 400,\n): RemoteValidationError {\n\n return { _tag: \"RemoteValidationError\", issues, body, status };\n}\n\n/**\n * Creates a {@link RemoteHttpError} for a given HTTP status.\n *\n * @since 2.0.0\n * @param status - The HTTP status code.\n * @param body - Optional response body.\n * @param cause - Optional underlying cause.\n * @returns A remote HTTP error shape.\n * @internal\n */\nexport function create_remote_http_error(\n status: number,\n body?: unknown,\n cause?: unknown,\n): RemoteHttpError {\n\n return { _tag: \"RemoteHttpError\", status, body, cause };\n}\n\n/**\n * Creates a {@link RemoteTransportError} for network or decode failures.\n *\n * @since 2.0.0\n * @param cause - The underlying error that caused the transport failure.\n * @param body - Optional response body if one was received.\n * @returns A remote transport error shape.\n * @internal\n */\nexport function create_remote_transport_error(\n cause: unknown,\n body?: unknown,\n): RemoteTransportError {\n\n return { _tag: \"RemoteTransportError\", cause, body };\n}\n\n/**\n * Wraps a devalue-encoded error string inside a\n * {@link SerializedRemoteFailureEnvelope}.\n *\n * @since 2.0.0\n * @param encoded - The devalue-encoded error value.\n * @returns The wire-format envelope.\n * @internal\n */\nexport function create_serialized_remote_failure_envelope(\n encoded: string,\n): SerializedRemoteFailureEnvelope {\n\n return { __svelte_effect_remote__: true, encoded };\n}\n\n/** Type guards for structured remote error values. */\n\n/**\n * Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a serialised failure envelope.\n * @internal\n */\nexport function is_serialized_remote_failure_envelope(\n value: unknown,\n): value is SerializedRemoteFailureEnvelope {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>).__svelte_effect_remote__ === true\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteValidationError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote validation error.\n */\nexport function is_remote_validation_error(\n value: unknown,\n): value is RemoteValidationError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteValidationError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteHttpError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote HTTP error.\n */\nexport function is_remote_http_error(\n value: unknown,\n): value is RemoteHttpError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteHttpError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteTransportError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote transport error.\n */\nexport function is_remote_transport_error(\n value: unknown,\n): value is RemoteTransportError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteTransportError\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,6BAA6B;;;;;;;;AAS1C,MAAa,uBAAuB,OAAO,IACzC,4CACF;;;;;;;;AAsCA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO;EAAE,MAAM;EAAa;CAAO;AACrC;;;;;;;;AASA,SAAgB,cAAc,OAAoC;CAChE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;;;;;AAoFA,SAAgB,+BACd,QACA,MACA,SAAS,KACc;CAEvB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC/D;;;;;;;;;;;AAYA,SAAgB,yBACd,QACA,MACA,OACiB;CAEjB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACxD;;;;;;;;;;AAWA,SAAgB,8BACd,OACA,MACsB;CAEtB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACrD;;;;;;;;;;AAWA,SAAgB,0CACd,SACiC;CAEjC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AACnD;;;;;;;;;;AAYA,SAAgB,sCACd,OAC0C;CAE1C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,6BAA6B;AAEpE;;;;;;;;AASA,SAAgB,2BACd,OACgC;CAEhC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,qBACd,OAC0B;CAE1B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,0BACd,OAC+B;CAE/B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["/**\r\n * Shared types, markers, and constructors used by both the client-side remote\r\n * adapters and the server-side handler runtime. These types define the error\r\n * protocol that flows across the network boundary.\r\n *\r\n * @since 2.0.0\r\n */\r\n\r\n/**\r\n * Well-known marker injected into every serialised remote-failure envelope\r\n * so the client can reliably distinguish runtime errors from domain values.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\r\n\r\n/**\r\n * Well-known symbol used to attach a payload decoder to a remote function\r\n * so the client's transport layer can decode domain error types.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport const REMOTE_ERROR_DECODER = Symbol.for(\r\n \"svelte-effect-runtime/remote-error-decoder\",\r\n);\r\n\r\n/** Form validation helpers and types. */\r\n\r\n/**\r\n * A single field-level or form-level validation issue reported by a\r\n * {@link Form} handler.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface FormIssue {\r\n /** Human-readable validation message. */\r\n message: string;\r\n /** Path to the offending field as an array of string-or-number keys. */\r\n path: (string | number)[];\r\n}\r\n\r\n/**\r\n * Error subtype thrown by {@link Form} handlers to signal validation\r\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\r\n * helper on the server and surfaced as `FormError` on the client.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface FormError<SchemaType = unknown> {\r\n readonly _tag: \"FormError\";\r\n readonly issues: readonly FormIssue[];\r\n /** Phantom type slot for the schema this error was derived from. */\r\n readonly _schema?: SchemaType;\r\n}\r\n\r\n/**\r\n * Creates a {@link FormError} holding the given issues.\r\n *\r\n * @since 2.0.0\r\n * @param issues - The validation issues to attach.\r\n * @returns A FormError with the `_tag` set and no schema reference.\r\n */\r\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\r\n return { _tag: \"FormError\", issues };\r\n}\r\n\r\n/**\r\n * Type guard that narrows an unknown value to a {@link FormError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a FormError.\r\n */\r\nexport function is_form_error(value: unknown): value is FormError {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"FormError\"\r\n );\r\n}\r\n\r\n/** Remote error types shared by client and server helpers. */\r\n\r\n/**\r\n * Union of all wire-level error shapes that a remote function can\r\n * surface on its error channel.\r\n *\r\n * @example\r\n * ```ts\r\n * const result = yield* myQuery();\r\n * // error channel is RemoteFailure<DomainError>\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport type RemoteFailure<ErrorType> =\r\n | ErrorType\r\n | RemoteValidationError\r\n | RemoteHttpError\r\n | RemoteTransportError;\r\n\r\n/**\r\n * Validation errors that originate from a server-side {@link Form}\r\n * handler calling `invalid()` (SvelteKit's `fail`).\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteValidationError {\r\n readonly _tag: \"RemoteValidationError\";\r\n readonly issues?: readonly FormIssue[];\r\n readonly body?: unknown;\r\n readonly status: number;\r\n}\r\n\r\n/**\r\n * HTTP-level errors with a status code and optional response body. Raised\r\n * when the server explicitly calls SvelteKit's `error(status, body)`.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteHttpError {\r\n readonly _tag: \"RemoteHttpError\";\r\n readonly status: number;\r\n readonly body?: unknown;\r\n readonly cause?: unknown;\r\n}\r\n\r\n/**\r\n * Transport-level errors raised by the client adapter when the network\r\n * request fails or the response cannot be decoded.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteTransportError {\r\n readonly _tag: \"RemoteTransportError\";\r\n readonly cause?: unknown;\r\n readonly body?: unknown;\r\n}\r\n\r\n/**\r\n * Wire format for an encoded remote failure. The server wraps domain\r\n * errors in this envelope before serialising them with devalue.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport interface SerializedRemoteFailureEnvelope {\r\n readonly __svelte_effect_remote__: true;\r\n readonly encoded: string;\r\n}\r\n\r\n/** Constructors for structured remote error values. */\r\n\r\n/**\r\n * Creates a {@link RemoteValidationError} from a list of form issues.\r\n *\r\n * @since 2.0.0\r\n * @param issues - The validation issues reported by the server handler.\r\n * @param body - Optional response body returned alongside the error.\r\n * @param status - HTTP status code (defaults to 400).\r\n * @returns A remote-validation error shape.\r\n * @internal\r\n */\r\nexport function create_remote_validation_error(\r\n issues: readonly FormIssue[],\r\n body?: unknown,\r\n status = 400,\r\n): RemoteValidationError {\r\n\r\n return { _tag: \"RemoteValidationError\", issues, body, status };\r\n}\r\n\r\n/**\r\n * Creates a {@link RemoteHttpError} for a given HTTP status.\r\n *\r\n * @since 2.0.0\r\n * @param status - The HTTP status code.\r\n * @param body - Optional response body.\r\n * @param cause - Optional underlying cause.\r\n * @returns A remote HTTP error shape.\r\n * @internal\r\n */\r\nexport function create_remote_http_error(\r\n status: number,\r\n body?: unknown,\r\n cause?: unknown,\r\n): RemoteHttpError {\r\n\r\n return { _tag: \"RemoteHttpError\", status, body, cause };\r\n}\r\n\r\n/**\r\n * Creates a {@link RemoteTransportError} for network or decode failures.\r\n *\r\n * @since 2.0.0\r\n * @param cause - The underlying error that caused the transport failure.\r\n * @param body - Optional response body if one was received.\r\n * @returns A remote transport error shape.\r\n * @internal\r\n */\r\nexport function create_remote_transport_error(\r\n cause: unknown,\r\n body?: unknown,\r\n): RemoteTransportError {\r\n\r\n return { _tag: \"RemoteTransportError\", cause, body };\r\n}\r\n\r\n/**\r\n * Wraps a devalue-encoded error string inside a\r\n * {@link SerializedRemoteFailureEnvelope}.\r\n *\r\n * @since 2.0.0\r\n * @param encoded - The devalue-encoded error value.\r\n * @returns The wire-format envelope.\r\n * @internal\r\n */\r\nexport function create_serialized_remote_failure_envelope(\r\n encoded: string,\r\n): SerializedRemoteFailureEnvelope {\r\n\r\n return { __svelte_effect_remote__: true, encoded };\r\n}\r\n\r\n/** Type guards for structured remote error values. */\r\n\r\n/**\r\n * Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a serialised failure envelope.\r\n * @internal\r\n */\r\nexport function is_serialized_remote_failure_envelope(\r\n value: unknown,\r\n): value is SerializedRemoteFailureEnvelope {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>).__svelte_effect_remote__ === true\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteValidationError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote validation error.\r\n */\r\nexport function is_remote_validation_error(\r\n value: unknown,\r\n): value is RemoteValidationError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteValidationError\"\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteHttpError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote HTTP error.\r\n */\r\nexport function is_remote_http_error(\r\n value: unknown,\r\n): value is RemoteHttpError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteHttpError\"\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteTransportError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote transport error.\r\n */\r\nexport function is_remote_transport_error(\r\n value: unknown,\r\n): value is RemoteTransportError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteTransportError\"\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,6BAA6B;;;;;;;;AAS1C,MAAa,uBAAuB,OAAO,IACzC,4CACF;;;;;;;;AAsCA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO;EAAE,MAAM;EAAa;CAAO;AACrC;;;;;;;;AASA,SAAgB,cAAc,OAAoC;CAChE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;;;;;AAoFA,SAAgB,+BACd,QACA,MACA,SAAS,KACc;CAEvB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC/D;;;;;;;;;;;AAYA,SAAgB,yBACd,QACA,MACA,OACiB;CAEjB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACxD;;;;;;;;;;AAWA,SAAgB,8BACd,OACA,MACsB;CAEtB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACrD;;;;;;;;;;AAWA,SAAgB,0CACd,SACiC;CAEjC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AACnD;;;;;;;;;;AAYA,SAAgB,sCACd,OAC0C;CAE1C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,6BAA6B;AAEpE;;;;;;;;AASA,SAAgB,2BACd,OACgC;CAEhC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,qBACd,OAC0B;CAE1B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,0BACd,OAC+B;CAE/B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD"}