svelte-effect-runtime 4.0.0 → 4.0.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.
Files changed (146) hide show
  1. package/.dist/chunks/client-BrZka6DW.js +530 -0
  2. package/.dist/chunks/client-BrZka6DW.js.map +1 -0
  3. package/.dist/chunks/compiler-COVzgLYo.js +412 -0
  4. package/.dist/chunks/compiler-COVzgLYo.js.map +1 -0
  5. package/.dist/chunks/descriptors-B4otDlm1.js +216 -0
  6. package/.dist/chunks/descriptors-B4otDlm1.js.map +1 -0
  7. package/.dist/chunks/diagnostics-BDrky-Di.js +359 -0
  8. package/.dist/chunks/diagnostics-BDrky-Di.js.map +1 -0
  9. package/.dist/chunks/dispatcher-BA0PLQhA.js +16 -0
  10. package/.dist/chunks/dispatcher-BA0PLQhA.js.map +1 -0
  11. package/.dist/chunks/{dispatcher-DOx8iC6r.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-IJjsUwrE.js → errors-CLsbGjIa.js} +39 -44
  14. package/.dist/chunks/errors-CLsbGjIa.js.map +1 -0
  15. package/.dist/chunks/live-BundLSoY.js +146 -0
  16. package/.dist/chunks/live-BundLSoY.js.map +1 -0
  17. package/.dist/chunks/live-CHK0RrZu.js +10 -0
  18. package/.dist/chunks/live-CHK0RrZu.js.map +1 -0
  19. package/.dist/chunks/{remote-client-CVI4t66c.js → remote-client-mkQAfP1G.js} +29 -23
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-GBQz32DZ.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/{server-D1LcDnZE.js → server-BNrA1I-u.js} +15 -84
  24. package/.dist/chunks/server-BNrA1I-u.js.map +1 -0
  25. package/.dist/chunks/source-scan-9pZxnfct.js +1059 -0
  26. package/.dist/chunks/source-scan-9pZxnfct.js.map +1 -0
  27. package/.dist/chunks/{transform-jNUr65K9.js → transform-BXyYUAez.js} +184 -358
  28. package/.dist/chunks/transform-BXyYUAez.js.map +1 -0
  29. package/.dist/compiler/markup-identifiers.d.ts +2 -0
  30. package/.dist/compiler/remote-client.d.ts +1 -19
  31. package/.dist/compiler/source-scan.d.ts +11 -108
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/compiler.d.ts +6 -0
  34. package/.dist/compiler.js +1 -1
  35. package/.dist/detect.d.ts +0 -31
  36. package/.dist/detect.js +0 -39
  37. package/.dist/detect.js.map +1 -1
  38. package/.dist/diagnostics.d.ts +0 -16
  39. package/.dist/dispatcher/deps.d.ts +3 -14
  40. package/.dist/dispatcher/fibers.d.ts +5 -46
  41. package/.dist/dispatcher/index.d.ts +1 -143
  42. package/.dist/dispatcher/types.d.ts +0 -151
  43. package/.dist/dispatcher.js +1 -1
  44. package/.dist/errors.d.ts +30 -42
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +1 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +13 -8
  49. package/.dist/internal/generators.js.map +1 -1
  50. package/.dist/internal/live.d.ts +9 -0
  51. package/.dist/internal/remote-client.js +2 -2
  52. package/.dist/internal/remote-server.js +2 -2
  53. package/.dist/internal/schema.d.ts +0 -54
  54. package/.dist/live.d.ts +9 -26
  55. package/.dist/markup/event-attributes.d.ts +0 -32
  56. package/.dist/markup/promise.d.ts +1 -23
  57. package/.dist/markup/promise.js +2 -18
  58. package/.dist/markup/promise.js.map +1 -1
  59. package/.dist/markup/run.d.ts +1 -10
  60. package/.dist/markup/run.js +2 -11
  61. package/.dist/markup/run.js.map +1 -1
  62. package/.dist/markup/transform/apply.d.ts +4 -4
  63. package/.dist/markup/transform/classify.d.ts +2 -11
  64. package/.dist/markup/transform/constants.d.ts +1 -1
  65. package/.dist/markup/transform/effect-bindings.d.ts +2 -26
  66. package/.dist/markup/transform/effect-callbacks.d.ts +0 -20
  67. package/.dist/markup/transform/emit.d.ts +2 -11
  68. package/.dist/markup/transform/expressions.d.ts +0 -35
  69. package/.dist/markup/transform/scan.d.ts +3 -22
  70. package/.dist/markup/transform/types.d.ts +1 -129
  71. package/.dist/markup/transform.js +1 -1
  72. package/.dist/markup/value.d.ts +1 -18
  73. package/.dist/markup/value.js +2 -19
  74. package/.dist/markup/value.js.map +1 -1
  75. package/.dist/mod.d.ts +3 -8
  76. package/.dist/mod.js +5 -5
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +3 -37
  79. package/.dist/remote/client/command.d.ts +3 -17
  80. package/.dist/remote/client/form-data.d.ts +0 -7
  81. package/.dist/remote/client/form-enhance.d.ts +0 -7
  82. package/.dist/remote/client/form-transport.d.ts +14 -20
  83. package/.dist/remote/client/form.d.ts +4 -24
  84. package/.dist/remote/client/index.d.ts +2 -1
  85. package/.dist/remote/client/prerender.d.ts +6 -0
  86. package/.dist/remote/client/query-result.d.ts +2 -14
  87. package/.dist/remote/client/query.d.ts +8 -48
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +16 -110
  90. package/.dist/remote/client/utils.d.ts +0 -8
  91. package/.dist/remote/client.d.ts +2 -2
  92. package/.dist/remote/client.js +2 -2
  93. package/.dist/remote/effect.d.ts +6 -0
  94. package/.dist/remote/failures.d.ts +4 -0
  95. package/.dist/remote/query-update.d.ts +2 -0
  96. package/.dist/remote/resource.d.ts +25 -0
  97. package/.dist/remote/server.d.ts +5 -50
  98. package/.dist/remote/server.js +2 -2
  99. package/.dist/remote/shared.d.ts +6 -145
  100. package/.dist/remote/shared.js +6 -127
  101. package/.dist/remote/shared.js.map +1 -1
  102. package/.dist/runtime/transform.js +5 -22
  103. package/.dist/runtime/transform.js.map +1 -1
  104. package/.dist/script-transform/ast.d.ts +0 -46
  105. package/.dist/script-transform/imports.d.ts +0 -38
  106. package/.dist/script-transform/lower.d.ts +0 -9
  107. package/.dist/script-transform/runes.d.ts +0 -10
  108. package/.dist/script-transform/runtime-block.d.ts +0 -17
  109. package/.dist/script-transform/source.d.ts +0 -24
  110. package/.dist/script-transform/types.d.ts +1 -126
  111. package/.dist/server/effects.d.ts +4 -53
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/index.d.ts +1 -1
  114. package/.dist/server/invalid.d.ts +0 -7
  115. package/.dist/server/live-snapshot.d.ts +5 -0
  116. package/.dist/server/remote-handler-context.d.ts +5 -0
  117. package/.dist/server/runtime.d.ts +6 -24
  118. package/.dist/server/schema.d.ts +0 -14
  119. package/.dist/server/transport.d.ts +2 -0
  120. package/.dist/server/types.d.ts +49 -26
  121. package/.dist/server/wrappers.d.ts +3 -40
  122. package/.dist/server.d.ts +1 -1
  123. package/.dist/server.js +200 -215
  124. package/.dist/server.js.map +1 -1
  125. package/.dist/yieldable.d.ts +1 -35
  126. package/package.json +2 -2
  127. package/.dist/chunks/client-DcZUV4rR.js +0 -653
  128. package/.dist/chunks/client-DcZUV4rR.js.map +0 -1
  129. package/.dist/chunks/compiler-BBPNyXmQ.js +0 -460
  130. package/.dist/chunks/compiler-BBPNyXmQ.js.map +0 -1
  131. package/.dist/chunks/dispatcher-DOx8iC6r.js.map +0 -1
  132. package/.dist/chunks/dispatcher-H-Ia0Os4.js +0 -47
  133. package/.dist/chunks/dispatcher-H-Ia0Os4.js.map +0 -1
  134. package/.dist/chunks/errors-IJjsUwrE.js.map +0 -1
  135. package/.dist/chunks/live-BXAKre_4.js +0 -104
  136. package/.dist/chunks/live-BXAKre_4.js.map +0 -1
  137. package/.dist/chunks/remote-client-CVI4t66c.js.map +0 -1
  138. package/.dist/chunks/runtime-GBQz32DZ.js.map +0 -1
  139. package/.dist/chunks/schema-D9pct6Y5.js +0 -89
  140. package/.dist/chunks/schema-D9pct6Y5.js.map +0 -1
  141. package/.dist/chunks/server-D1LcDnZE.js.map +0 -1
  142. package/.dist/chunks/source-scan-C4PsggID.js +0 -341
  143. package/.dist/chunks/source-scan-C4PsggID.js.map +0 -1
  144. package/.dist/chunks/transform-jNUr65K9.js.map +0 -1
  145. package/.dist/remote/client/effect.d.ts +0 -29
  146. package/.dist/remote/client/failures.d.ts +0 -42
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 { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\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\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\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(\"ServerRuntime\") 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(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\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(\"Command\") 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(\"Error\") 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(\"Form\") 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(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\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(\"Redirect\") 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> = make_server_only_function(\n\t\"RequestEvent\",\n) 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<unknown, never> =\n\tmake_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\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_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 \"$/compiler.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAqGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\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\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\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(\"ServerRuntime\") 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(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\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(\"Command\") 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(\"Error\") 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(\"Form\") 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(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\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(\"Redirect\") 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> = make_server_only_function(\n\t\"RequestEvent\",\n) 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<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidPrerenderFactoryError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tInvalidYieldableError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\nexport { effect, type EffectOptions } from \"$/compiler.ts\";\n\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderInputs,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAsGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
@@ -1,18 +1,5 @@
1
- import type { FormIssue } from "./shared.js";
1
+ import { type FormIssue } from "./shared.js";
2
2
  import { Cause } from "effect";
3
- /**
4
- * Classified result of inspecting an Effect Cause at the remote server boundary.
5
- *
6
- * @example
7
- * ```ts
8
- * const resolution = classify_remote_cause(cause);
9
- * if (resolution._tag === "RemoteFailure") {
10
- * console.log(resolution.encoded);
11
- * }
12
- * ```
13
- *
14
- * @since 4.0.0
15
- */
16
3
  export type RemoteCauseResolution = {
17
4
  readonly _tag: "SvelteKitControlFlow";
18
5
  readonly value: unknown;
@@ -26,28 +13,7 @@ export type RemoteCauseResolution = {
26
13
  readonly _tag: "RemoteFailure";
27
14
  readonly encoded: string;
28
15
  };
29
- /**
30
- * Classifies a failed Effect Cause into the server action SER should take.
31
- *
32
- * @example
33
- * ```ts
34
- * const resolution = classify_remote_cause(Cause.fail({ _tag: "DbError" }));
35
- * ```
36
- *
37
- * @since 4.0.0
38
- * @param cause - Failed Effect Cause produced by a remote handler.
39
- * @returns A remote boundary decision preserving control flow, form errors,
40
- * interrupts, or encoded typed failures.
41
- * @internal
42
- */
16
+ /** Preserves SvelteKit control flow before classifying transportable Effect failures. */
43
17
  export declare function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution;
44
- /**
45
- * Encodes an Effect Cause into a string that the client-side adapter can
46
- * decode back into a typed `RemoteFailure`.
47
- *
48
- * @since 2.0.0
49
- * @param cause - The Effect Cause from a failed execution.
50
- * @returns A devalue-encoded string representing the serialised failure.
51
- * @internal
52
- */
18
+ /** Encodes a remote failure into the transport ABI shared with generated clients. */
53
19
  export declare function encode_remote_failure(cause: Cause.Cause<unknown>): string;
@@ -1,21 +1,7 @@
1
- import type { RemoteFailure } from "../shared.js";
2
- import type { Pending } from "./types.js";
3
- import type { Effect } from "effect";
4
- type EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((input: undefined extends Input ? Input | void : Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>) & {
1
+ import type { EffectRemoteCommandCall, Pending } from "./types.js";
2
+ type EffectRemoteCommandAdapter<Input, Output, ErrorType = never> = ((input: undefined extends Input ? Input | void : Input) => EffectRemoteCommandCall<Output, ErrorType>) & {
5
3
  readonly pending: number;
6
4
  };
7
- /**
8
- * Creates a remote command adapter. The adapter preserves the native
9
- * pending getter and turns each invocation into an Effect.
10
- *
11
- * @since 2.0.0
12
- * @param native_factory - SvelteKit's native command function or a legacy
13
- * response factory used by tests.
14
- * @param decode_payload - Function to decode the response payload.
15
- * @param _base - Deprecated transport base retained for compatibility.
16
- * @param pending - Optional pending counter for legacy response factories.
17
- * @returns A function returning an Effect of the response.
18
- * @internal
19
- */
5
+ /** Adapts a generated SvelteKit command to SER's Effect-based client ABI. */
20
6
  export declare function create_remote_command_adapter<Input, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, _base?: string, pending?: Pending): EffectRemoteCommandAdapter<Input, Output, ErrorType>;
21
7
  export {};
@@ -1,8 +1 @@
1
- /**
2
- * Encodes remote form input into SvelteKit-compatible form data.
3
- *
4
- * @since 2.0.0
5
- * @param input - Input value supplied to the remote form.
6
- * @returns FormData payload for the remote endpoint.
7
- */
8
1
  export declare function to_form_data(input: unknown): FormData;
@@ -1,9 +1,2 @@
1
1
  import type { NativeMethod } from "./types.js";
2
- /**
3
- * Wraps a remote form enhance callback so Effect return values are run.
4
- *
5
- * @since 2.0.0
6
- * @param callback - Native enhance callback to wrap.
7
- * @returns Wrapped callback or undefined.
8
- */
9
2
  export declare function wrap_enhance_callback<Output, ErrorType = never>(callback: NativeMethod | undefined): NativeMethod | undefined;
@@ -1,23 +1,17 @@
1
1
  import type { StandardSchema } from "../../internal/schema.js";
2
2
  import type { NativeFormRecord } from "./types.js";
3
- /**
4
- * Submits a native remote form through the SvelteKit remote endpoint.
5
- *
6
- * @since 2.0.0
7
- * @param form_obj - Native form object being adapted.
8
- * @param input - Form input value.
9
- * @param decode_payload - Function to decode successful payloads.
10
- * @param remote_base - Base URL for the remote endpoint.
11
- * @param preflight_schema - Optional schema used to mirror SvelteKit's
12
- * client-side preflight before posting direct programmatic input.
13
- * @returns Decoded form output.
14
- */
15
- export declare function submit_remote_form<Output>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string, preflight_schema?: StandardSchema): Promise<Output>;
16
- /**
17
- * Extracts SvelteKit's remote action id from a native form action URL.
18
- *
19
- * @since 2.0.0
20
- * @param form_obj - Native form object being adapted.
21
- * @returns Remote action id when present.
22
- */
3
+ import { Effect } from "effect";
4
+ export interface RemoteFormTransport {
5
+ readonly binary_form_content_type?: string;
6
+ readonly decoders?: Record<string, (value: unknown) => unknown>;
7
+ readonly navigate?: (location: string, invalidate_all: boolean) => PromiseLike<void> | void;
8
+ readonly remote_request?: (url: string, init?: RequestInit) => PromiseLike<unknown>;
9
+ readonly refresh?: () => PromiseLike<void> | void;
10
+ readonly serialize_binary_form?: (data: unknown, meta: {
11
+ readonly remote_refreshes: readonly string[];
12
+ }) => {
13
+ readonly blob: Blob;
14
+ };
15
+ }
16
+ export declare const SubmitRemoteForm: <Output, ErrorType = never>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string, remote_transport: RemoteFormTransport, preflight_schema?: StandardSchema) => Effect.Effect<Output, import("../shared.js").RemoteFailure<ErrorType>, never>;
23
17
  export declare function get_remote_action_id(form_obj: NativeFormRecord): string | undefined;
@@ -1,30 +1,10 @@
1
- import type { RemoteFormInput } from "@sveltejs/kit";
2
1
  import { type StandardSchema } from "../../internal/schema.js";
3
2
  import type { EffectRemoteForm } from "./types.js";
3
+ import { type RemoteFormTransport } from "./form-transport.js";
4
+ import type { RemoteFormInput } from "@sveltejs/kit";
4
5
  interface RemoteFormAdapterState {
5
6
  shared_preflight_schema?: StandardSchema;
6
7
  }
7
- /**
8
- * Creates a remote form adapter. The callable preserves SvelteKit's native
9
- * form descriptors while wrapping `validate`, `enhance`, and programmatic
10
- * submission in Effect-returning APIs.
11
- *
12
- * @example
13
- * ```ts
14
- * const createPost = create_remote_form_adapter(nativeForm, (value) => value);
15
- * yield* createPost.validate({ includeUntouched: true });
16
- * ```
17
- *
18
- * @since 2.0.0
19
- * @param native_factory - SvelteKit's native form object.
20
- * @param decode_payload - Function to decode the response payload.
21
- * @param remote_base - Base URL for SvelteKit's remote endpoint.
22
- * @param adapter_state - Shared mutable state used to mirror root form
23
- * preflight schemas across keyed form instances.
24
- * @param keyed - Whether this adapter wraps a keyed form instance returned by
25
- * SvelteKit's native `for(...)` helper.
26
- * @returns A callable form function whose properties mirror the native form.
27
- * @internal
28
- */
29
- export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
8
+ /** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */
9
+ export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, remote_transport?: RemoteFormTransport, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
30
10
  export {};
@@ -1,4 +1,5 @@
1
1
  export { create_remote_command_adapter } from "./command.js";
2
2
  export { create_remote_form_adapter } from "./form.js";
3
+ export { create_remote_prerender_adapter } from "./prerender.js";
3
4
  export { create_remote_live_query_adapter, create_remote_query_adapter } from "./query.js";
4
- export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormPreflightSchema, EffectRemoteFormSubmit, EffectRemoteFormValidateOptions, Pending, } from "./types.js";
5
+ export type { EffectRemoteCommandCall, EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormPreflightSchema, EffectRemoteFormSubmit, EffectRemoteFormValidateOptions, EffectRemoteQueryUpdateBrand, Pending, } from "./types.js";
@@ -0,0 +1,6 @@
1
+ import { type RemoteResourceEffect } from "../resource.js";
2
+ type RemoteInput<Input> = undefined extends Input ? Input | void : Input;
3
+ type EffectRemotePrerenderAdapter<Input, Output, ErrorType = never> = (input: RemoteInput<Input>) => RemoteResourceEffect<Output, ErrorType>;
4
+ export declare function create_remote_prerender_adapter<Input, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => Output): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;
5
+ export declare function create_remote_prerender_adapter<Input, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown): EffectRemotePrerenderAdapter<Input, Output, ErrorType>;
6
+ export {};
@@ -1,14 +1,2 @@
1
- /**
2
- * Resolves native query results, including SvelteKit run handles.
3
- *
4
- * @example
5
- * ```ts
6
- * const output = await resolve_query_result(result, decode_payload);
7
- * ```
8
- *
9
- * @since 2.0.0
10
- * @param value - Native query result or query run handle.
11
- * @param decode_payload - Function used to decode successful payloads.
12
- * @returns Decoded query output.
13
- */
14
- export declare function resolve_query_result<Output>(value: unknown, decode_payload: (value: unknown) => unknown): Promise<Output>;
1
+ import { Effect } from "effect";
2
+ export declare const ResolveQueryResult: <Output, ErrorType = never>(value: unknown, decode_payload: (value: unknown) => unknown) => Effect.Effect<Output, import("../shared.ts").RemoteFailure<ErrorType>, never>;
@@ -1,61 +1,21 @@
1
- import type { EffectRemoteQueryUpdateBrand } from "./types.js";
2
- import type { RemoteFailure } from "../shared.js";
1
+ import { type RemoteResourceEffect } from "../resource.js";
3
2
  import { type RemoteLiveStream } from "../../live.js";
3
+ import type { EffectRemoteQueryUpdateBrand } from "./types.js";
4
4
  import { Effect } from "effect";
5
5
  type RemoteInput<Input> = undefined extends Input ? Input | void : Input;
6
6
  type DecodePayload<Output> = (value: unknown) => Output;
7
+ type QueryAdapterMode = "standard" | "batch";
7
8
  type NativeQueryFactory<Input> = ((input: RemoteInput<Input>) => unknown) | {
8
9
  readonly load: (input: RemoteInput<Input>) => unknown;
9
10
  };
10
- type RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<Output, RemoteFailure<ErrorType>> & {
11
- readonly current: Output | undefined;
12
- readonly error: unknown;
13
- readonly loading: boolean;
14
- readonly ready: boolean;
15
- };
16
- type RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {
11
+ type RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand & RemoteResourceEffect<Output, ErrorType> & {
17
12
  readonly refresh: () => Effect.Effect<void, unknown, never>;
18
13
  readonly set: (value: Output) => void;
19
14
  readonly withOverride: (update: (current: Output) => Output) => unknown;
20
15
  };
21
- /**
22
- * Creates a remote query adapter. The returned function takes input and
23
- * returns an `Effect` that executes SvelteKit's native query function.
24
- *
25
- * @example
26
- * ```ts
27
- * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);
28
- * const user = yield* getUser({ id: 1 });
29
- * ```
30
- *
31
- * @since 2.0.0
32
- * @param native_factory - SvelteKit's native query function or a legacy
33
- * response factory used by tests.
34
- * @param decode_payload - Function to decode the response payload.
35
- * @param _base - Deprecated transport base retained for compatibility.
36
- * @returns A function returning an Effect of the response.
37
- * @internal
38
- */
39
- export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: DecodePayload<Output>, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
40
- export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
41
- /**
42
- * Creates a remote live query adapter. The returned function takes input and
43
- * returns an Effect Stream whose transport state is exposed through `Live`.
44
- *
45
- * @example
46
- * ```ts
47
- * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
48
- * const time = getTime();
49
- * const first = yield* Stream.runHead(time);
50
- * ```
51
- *
52
- * @since 2.0.0
53
- * @param native_factory - SvelteKit's native live query function.
54
- * @param _decode_payload - Deprecated payload decoder retained for parity with
55
- * other remote adapters.
56
- * @param _base - Deprecated transport base retained for compatibility.
57
- * @returns A function returning a remote live stream.
58
- * @internal
59
- */
16
+ /** Adapts a generated SvelteKit query to SER's Effect-based client ABI. */
17
+ export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: DecodePayload<Output>, _base?: string, mode?: QueryAdapterMode): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
18
+ export declare function create_remote_query_adapter<Input, Output, ErrorType = never>(native_factory: NativeQueryFactory<Input>, decode_payload: (value: unknown) => unknown, _base?: string, mode?: QueryAdapterMode): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteQueryEffect<Output, ErrorType>);
19
+ /** Adapts a generated SvelteKit live query to SER's Effect-based client ABI. */
60
20
  export declare function create_remote_live_query_adapter<Input, Output, ErrorType = never>(native_factory: unknown, _decode_payload: (value: unknown) => unknown, _base?: string): EffectRemoteQueryUpdateBrand & ((input: RemoteInput<Input>) => RemoteLiveStream<Output, ErrorType>);
61
21
  export {};
@@ -1,28 +1,4 @@
1
1
  import type { RemoteFailure } from "../shared.js";
2
- /**
3
- * Decodes a failed fetch response into the runtime failure model.
4
- *
5
- * @example
6
- * ```ts
7
- * const failure = await decode_response_failure(response);
8
- * ```
9
- *
10
- * @since 2.0.0
11
- * @param response - Failed fetch response returned by the remote endpoint.
12
- * @returns Remote failure represented by the response.
13
- */
14
- export declare function decode_response_failure<ErrorType = never>(response: Response): Promise<RemoteFailure<ErrorType>>;
15
- /**
16
- * Decodes either a raw value or `Response` returned by a native remote helper.
17
- *
18
- * @example
19
- * ```ts
20
- * const output = await decode_response_or_value(result, decode_payload);
21
- * ```
22
- *
23
- * @since 2.0.0
24
- * @param value - Native result value or fetch response.
25
- * @param decode_payload - Function used to decode successful payloads.
26
- * @returns Decoded successful output.
27
- */
28
- export declare function decode_response_or_value<Output, ErrorType = never>(value: unknown, decode_payload: (value: unknown) => unknown): Promise<Output>;
2
+ import { Effect } from "effect";
3
+ export declare const DecodeResponseFailure: <ErrorType = never>(response: Response) => Effect.Effect<RemoteFailure<ErrorType>, never, never>;
4
+ export declare const DecodeResponseOrValue: <Output, ErrorType = never>(value: unknown, decode_payload: (value: unknown) => unknown) => Effect.Effect<Output, RemoteFailure<ErrorType>, never>;
@@ -1,146 +1,52 @@
1
- import type { RemoteForm, RemoteFormInput, RemoteLiveQuery, RemoteQuery, RemoteQueryOverride } from "@sveltejs/kit";
1
+ import type { RemoteForm, RemoteFormInput, RemoteQueryUpdate } from "@sveltejs/kit";
2
2
  import type { RemoteFailure } from "../shared.js";
3
3
  import type { Effect, Schema, Stream } from "effect";
4
- /**
5
- * Type-only marker attached to SER query and live-query adapter functions so
6
- * form updates can distinguish them from command adapters.
7
- *
8
- * @since 2.4.2
9
- * @internal
10
- */
11
- export declare const EFFECT_REMOTE_QUERY_UPDATE: unique symbol;
12
- /**
13
- * Type-only brand carried by SER query and live-query adapter functions.
14
- *
15
- * @since 2.4.2
16
- * @internal
17
- */
4
+ import type { RemoteLiveStream } from "../../live.js";
5
+ /** Runtime brand used to distinguish query-update callbacks. */
6
+ export declare const effect_remote_query_update: unique symbol;
18
7
  export type EffectRemoteQueryUpdateBrand = {
19
- readonly [EFFECT_REMOTE_QUERY_UPDATE]: true;
8
+ readonly [effect_remote_query_update]: true;
20
9
  };
21
10
  type EffectRemoteFormCallable<Input extends RemoteFormInput | void, Output, ErrorType> = [
22
11
  Input
23
12
  ] extends [void] ? () => Effect.Effect<Output, RemoteFailure<ErrorType>> : undefined extends Input ? (input?: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>> : (input: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>;
24
13
  type NativeRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output> = Parameters<RemoteForm<Input, Output>["preflight"]>[0];
25
14
  type NativeRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output> = NonNullable<Parameters<RemoteForm<Input, Output>["validate"]>[0]>;
26
- /**
27
- * Schema values accepted by SER's remote form preflight adapter.
28
- *
29
- * @example
30
- * ```ts
31
- * form.preflight(Schema.Struct({ email: Schema.String }));
32
- * ```
33
- *
34
- * @since 3.4.6
35
- */
36
- export type EffectRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Schema<unknown>;
37
- /**
38
- * Options accepted by SER's remote form validation adapter.
39
- *
40
- * @example
41
- * ```ts
42
- * yield* form.validate({ all: true, preflightOnly: true });
43
- * ```
44
- *
45
- * @since 3.4.6
46
- */
15
+ export type EffectRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Codec<unknown, Input, never, unknown>;
47
16
  export type EffectRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output = unknown> = Omit<NativeRemoteFormValidateOptions<Input, Output>, "all" | "includeUntouched" | "preflightOnly"> & {
48
17
  readonly all?: boolean;
49
18
  readonly includeUntouched?: boolean;
50
19
  readonly preflightOnly?: boolean;
51
20
  };
52
- type EffectRemoteQueryUpdate = NativeRemoteQueryUpdate | EffectRemoteQueryUpdateFunction | EffectRemoteLiveQueryUpdateFunction;
21
+ type EffectRemoteQueryUpdate = NativeRemoteQueryUpdate | EffectRemoteQueryUpdateFunction | EffectRemoteQueryUpdateResource | EffectRemoteLiveQueryUpdateFunction;
53
22
  type EffectRemoteCommandUpdate = {
54
23
  readonly pending: number;
55
24
  };
56
- type EffectRemoteQueryUpdateInput<Update> = Update extends EffectRemoteCommandUpdate ? never : Update extends EffectRemoteQueryUpdate ? Update : never;
25
+ type EffectRemoteQueryUpdateInput<Update> = Update extends EffectRemoteCommandUpdate ? never : Update extends RemoteLiveStream<infer _Output, infer _ErrorType> ? Update : Update extends EffectRemoteQueryUpdate ? Update : never;
57
26
  type EffectRemoteQueryUpdates<Updates extends readonly unknown[]> = Updates & {
58
27
  [Index in keyof Updates]: EffectRemoteQueryUpdateInput<Updates[Index]>;
59
28
  };
60
- type NativeRemoteQueryUpdate = RemoteQuery<unknown> | RemoteLiveQuery<unknown> | RemoteQueryOverride;
61
- type EffectRemoteQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => EffectRemoteQueryUpdateResource);
62
- type EffectRemoteLiveQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => Stream.Stream<unknown, unknown, unknown>);
63
- type EffectRemoteQueryUpdateResource = Effect.Effect<unknown, unknown> & {
64
- readonly refresh: () => Effect.Effect<void, unknown, never>;
65
- readonly set: (value: never) => void;
66
- readonly withOverride: (update: (current: never) => unknown) => unknown;
67
- };
68
- /**
69
- * Represents a pending operation counter that remote command adapters
70
- * use to track in-flight requests.
71
- *
72
- * @since 2.0.0
73
- * @internal
74
- */
29
+ type NativeRemoteQueryUpdate = RemoteQueryUpdate;
30
+ type EffectRemoteQueryUpdateFunction = (input: never) => EffectRemoteQueryUpdateResource;
31
+ type EffectRemoteLiveQueryUpdateFunction = (input: never) => Stream.Stream<unknown, unknown, unknown>;
32
+ type EffectRemoteQueryUpdateResource = EffectRemoteQueryUpdateBrand & Effect.Effect<unknown, unknown>;
75
33
  export interface Pending {
76
- /** Current count of in-flight requests. */
77
34
  value: number;
78
35
  }
79
- /**
80
- * Native callable method shape used when reflecting SvelteKit remote helpers.
81
- *
82
- * @since 2.0.0
83
- */
84
36
  export type NativeMethod = (...args: unknown[]) => unknown;
85
- /**
86
- * Property bag shape used for native SvelteKit form objects.
87
- *
88
- * @since 2.0.0
89
- */
90
37
  export type NativeFormRecord = Record<PropertyKey, unknown>;
91
- /**
92
- * Represents the native form submit handle passed into an Effect-aware
93
- * enhanced remote form callback.
94
- *
95
- * @example
96
- * ```ts
97
- * form.enhance(({ submit }) =>
98
- * Effect.gen(function* () {
99
- * yield* submit().updates();
100
- * })
101
- * );
102
- * ```
103
- *
104
- * @since 2.0.0
105
- */
38
+ export type EffectRemoteCommandCall<Output, ErrorType = never> = Effect.Effect<Output, RemoteFailure<ErrorType>> & {
39
+ updates: <const Updates extends readonly unknown[]>(...updates: EffectRemoteQueryUpdates<Updates>) => Effect.Effect<Output, RemoteFailure<ErrorType>>;
40
+ };
106
41
  export type EffectRemoteFormSubmit<Output = unknown, ErrorType = never> = Effect.Effect<Output | undefined, RemoteFailure<ErrorType>> & {
107
42
  updates: <const Updates extends readonly unknown[]>(...updates: EffectRemoteQueryUpdates<Updates>) => Effect.Effect<Output | undefined, RemoteFailure<ErrorType>>;
108
43
  };
109
- /**
110
- * Represents the callback payload passed to an Effect-aware remote form
111
- * enhancement callback.
112
- *
113
- * @example
114
- * ```ts
115
- * form.enhance(({ data, submit }) =>
116
- * Effect.gen(function* () {
117
- * console.log(data);
118
- * yield* submit();
119
- * })
120
- * );
121
- * ```
122
- *
123
- * @since 2.0.0
124
- */
125
44
  export type EffectRemoteFormEnhanceOptions<Input extends RemoteFormInput | void, Output, ErrorType = never> = Omit<Parameters<RemoteForm<Input, Output>["enhance"]>[0] extends (options: infer Options) => unknown ? Options : never, "submit"> & {
126
45
  submit: () => EffectRemoteFormSubmit<Output, ErrorType>;
127
46
  };
128
- /**
129
- * Represents a SvelteKit remote form whose submission, validation, and
130
- * enhancement hooks expose Effect-returning APIs.
131
- *
132
- * @example
133
- * ```ts
134
- * const form = create_remote_form_adapter(nativeForm, (value) => value);
135
- *
136
- * yield* form.preflight(schema).validate();
137
- * ```
138
- *
139
- * @since 2.0.0
140
- */
141
47
  export type EffectRemoteForm<Input extends RemoteFormInput | void, Output, ErrorType = never> = EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<RemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
142
48
  enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<RemoteForm<Input, Output>["enhance"]>;
143
- for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
49
+ for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
144
50
  preflight(schema: EffectRemoteFormPreflightSchema<Input, Output>): EffectRemoteForm<Input, Output, ErrorType>;
145
51
  submit: EffectRemoteFormCallable<Input, Output, ErrorType>;
146
52
  validate(options?: EffectRemoteFormValidateOptions<Input, Output>): Effect.Effect<void, RemoteFailure<ErrorType>>;
@@ -1,11 +1,3 @@
1
1
  export { copy_property_descriptors } from "../../internal/descriptors.js";
2
2
  import type { NativeMethod } from "./types.js";
3
- /**
4
- * Checks whether a value has a callable method property.
5
- *
6
- * @since 2.0.0
7
- * @param value - Value to inspect.
8
- * @param key - Method key to look up.
9
- * @returns Whether the value has a function at `key`.
10
- */
11
3
  export declare function has_method<K extends PropertyKey>(value: unknown, key: K): value is Record<K, NativeMethod>;
@@ -1,2 +1,2 @@
1
- export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter, } from "./client/index.js";
2
- export type { EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormPreflightSchema, EffectRemoteFormSubmit, EffectRemoteFormValidateOptions, Pending, } from "./client/index.js";
1
+ export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter, } from "./client/index.js";
2
+ export type { EffectRemoteCommandCall, EffectRemoteForm, EffectRemoteFormEnhanceOptions, EffectRemoteFormPreflightSchema, EffectRemoteFormSubmit, EffectRemoteFormValidateOptions, EffectRemoteQueryUpdateBrand, Pending, } from "./client/index.js";
@@ -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-DcZUV4rR.js";
2
- export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
1
+ import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-BrZka6DW.js";
2
+ export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
@@ -0,0 +1,6 @@
1
+ import type { RemoteFailure } from "./shared.js";
2
+ import { Effect } from "effect";
3
+ export declare const MakeEffectFromPromise: <Output, ErrorType = never>(run: (signal: AbortSignal) => PromiseLike<Output>) => Effect.Effect<Output, RemoteFailure<ErrorType>, never>;
4
+ export declare const MakeEffectFromSync: <Output, ErrorType = never>(run: () => Output) => Effect.Effect<Output, RemoteFailure<ErrorType>, never>;
5
+ export declare const FailWithRemoteError: <ErrorType = never>(error: unknown) => Effect.Effect<never, RemoteFailure<ErrorType>, never>;
6
+ export declare function normalize_remote_effect_error<ErrorType>(error: unknown): RemoteFailure<ErrorType>;
@@ -0,0 +1,4 @@
1
+ import type { RemoteFailure } from "./shared.js";
2
+ export declare function decode_remote_error<ErrorType = never>(raw: unknown, decode?: (encoded: string) => unknown): RemoteFailure<ErrorType> | unknown;
3
+ export declare function is_decoded_remote_failure(value: unknown): value is RemoteFailure<never>;
4
+ export declare function normalize_native_error<ErrorType = never>(error: unknown): RemoteFailure<ErrorType>;
@@ -0,0 +1,2 @@
1
+ export declare function attach_native_remote_query_update(target: unknown, native_update: unknown): void;
2
+ export declare function resolve_native_remote_query_updates(updates: readonly unknown[]): unknown[];
@@ -0,0 +1,25 @@
1
+ import type { RemoteFailure } from "./shared.js";
2
+ import { type Effect } from "effect";
3
+ export type RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<Output, RemoteFailure<ErrorType>> & {
4
+ readonly current: Output | undefined;
5
+ readonly error: unknown;
6
+ readonly loading: boolean;
7
+ readonly ready: boolean;
8
+ };
9
+ type RemoteQueryResourceEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {
10
+ readonly refresh: () => Effect.Effect<void, unknown, never>;
11
+ readonly set: (value: Output) => void;
12
+ readonly withOverride: (update: (current: Output) => Output) => unknown;
13
+ };
14
+ export type NativeRemoteResource<Output> = {
15
+ readonly current?: Output;
16
+ readonly error?: unknown;
17
+ readonly loading?: boolean;
18
+ readonly ready?: boolean;
19
+ };
20
+ export declare function is_remote_resource<Output>(resource: unknown): resource is NativeRemoteResource<Output>;
21
+ export declare function attach_remote_resource_getters<Output, ErrorType = never>(resource: unknown, effect: RemoteResourceEffect<Output, ErrorType>): void;
22
+ export declare function attach_failed_remote_resource_getters<Output, ErrorType = never>(error: unknown, effect: RemoteResourceEffect<Output, ErrorType>): void;
23
+ export declare function attach_failed_remote_query_resource<Output, ErrorType = never>(error: unknown, effect: RemoteQueryResourceEffect<Output, ErrorType>): void;
24
+ export declare function normalize_remote_resource_error<ErrorType>(error: unknown): unknown;
25
+ export {};