svelte-effect-runtime 3.4.11 → 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 (147) 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-pHH4JcFR.js → dispatcher-_x0MQZBS.js} +84 -258
  12. package/.dist/chunks/dispatcher-_x0MQZBS.js.map +1 -0
  13. package/.dist/chunks/{errors-Dcf0MVbq.js → errors-CLsbGjIa.js} +57 -106
  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-Bj1pZXgq.js → remote-client-mkQAfP1G.js} +30 -24
  20. package/.dist/chunks/remote-client-mkQAfP1G.js.map +1 -0
  21. package/.dist/chunks/{runtime-ekkMQ-wL.js → runtime-HDTlEnzp.js} +3 -27
  22. package/.dist/chunks/runtime-HDTlEnzp.js.map +1 -0
  23. package/.dist/chunks/server-BNrA1I-u.js +144 -0
  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-CtQDGS9c.js → transform-BXyYUAez.js} +308 -484
  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 +6 -0
  31. package/.dist/compiler/source-scan.d.ts +101 -0
  32. package/.dist/compiler/sveltekit-remote-bridge.d.ts +3 -0
  33. package/.dist/{vite.d.ts → compiler.d.ts} +7 -1
  34. package/.dist/{vite.js → 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 +44 -86
  45. package/.dist/generated/dispatcher.d.ts +0 -50
  46. package/.dist/generators.d.ts +3 -12
  47. package/.dist/internal/descriptors.d.ts +0 -16
  48. package/.dist/internal/generators.js +25 -3
  49. package/.dist/internal/generators.js.map +1 -0
  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 +13 -0
  54. package/.dist/live.d.ts +106 -0
  55. package/.dist/markup/event-attributes.d.ts +5 -28
  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 +2 -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 +2 -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 +6 -8
  76. package/.dist/mod.js +5 -4
  77. package/.dist/mod.js.map +1 -1
  78. package/.dist/remote/cause-codec.d.ts +19 -0
  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 +15 -18
  83. package/.dist/remote/client/form.d.ts +9 -20
  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 +9 -59
  88. package/.dist/remote/client/responses.d.ts +3 -27
  89. package/.dist/remote/client/types.d.ts +26 -101
  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 -60
  98. package/.dist/remote/server.js +2 -179
  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 +83 -87
  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 +2 -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 +9 -126
  111. package/.dist/server/effects.d.ts +8 -57
  112. package/.dist/server/factories.d.ts +7 -7
  113. package/.dist/server/handler.d.ts +37 -0
  114. package/.dist/server/index.d.ts +4 -1
  115. package/.dist/server/invalid.d.ts +0 -7
  116. package/.dist/server/live-snapshot.d.ts +5 -0
  117. package/.dist/server/remote-handler-context.d.ts +5 -0
  118. package/.dist/server/runtime.d.ts +6 -24
  119. package/.dist/server/schema.d.ts +2 -40
  120. package/.dist/server/transport.d.ts +2 -0
  121. package/.dist/server/types.d.ts +88 -71
  122. package/.dist/server/wrappers.d.ts +4 -41
  123. package/.dist/server.d.ts +2 -2
  124. package/.dist/server.js +255 -279
  125. package/.dist/server.js.map +1 -1
  126. package/.dist/yieldable.d.ts +7 -0
  127. package/README.md +1 -1
  128. package/package.json +5 -5
  129. package/.dist/chunks/client-CsVu54pU.js +0 -627
  130. package/.dist/chunks/client-CsVu54pU.js.map +0 -1
  131. package/.dist/chunks/descriptors-cOe9uRJz.js +0 -36
  132. package/.dist/chunks/descriptors-cOe9uRJz.js.map +0 -1
  133. package/.dist/chunks/dispatcher-LtvFKYUp.js +0 -47
  134. package/.dist/chunks/dispatcher-LtvFKYUp.js.map +0 -1
  135. package/.dist/chunks/dispatcher-pHH4JcFR.js.map +0 -1
  136. package/.dist/chunks/errors-Dcf0MVbq.js.map +0 -1
  137. package/.dist/chunks/event-attributes-gHzP2ycp.js +0 -39
  138. package/.dist/chunks/event-attributes-gHzP2ycp.js.map +0 -1
  139. package/.dist/chunks/remote-client-Bj1pZXgq.js.map +0 -1
  140. package/.dist/chunks/runtime-ekkMQ-wL.js.map +0 -1
  141. package/.dist/chunks/transform-CtQDGS9c.js.map +0 -1
  142. package/.dist/chunks/vite-WGlbSnso.js +0 -486
  143. package/.dist/chunks/vite-WGlbSnso.js.map +0 -1
  144. package/.dist/remote/client/effect.d.ts +0 -29
  145. package/.dist/remote/client/failures.d.ts +0 -42
  146. package/.dist/remote/server.js.map +0 -1
  147. package/.dist/vite/remote-client.d.ts +0 -24
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\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\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\tUnknownRuntimeError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tVitePreTransformPluginConflictError,\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 \"$/vite.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 {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemoteLiveQueryResource,\n\tEffectRemoteLiveSource,\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\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;;;;;;;;;;;;;;;AAgBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAoGxD,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"}
@@ -0,0 +1,19 @@
1
+ import { type FormIssue } from "./shared.js";
2
+ import { Cause } from "effect";
3
+ export type RemoteCauseResolution = {
4
+ readonly _tag: "SvelteKitControlFlow";
5
+ readonly value: unknown;
6
+ } | {
7
+ readonly _tag: "InterruptOnly";
8
+ readonly cause: Cause.Cause<unknown>;
9
+ } | {
10
+ readonly _tag: "FormInvalid";
11
+ readonly issues: readonly FormIssue[];
12
+ } | {
13
+ readonly _tag: "RemoteFailure";
14
+ readonly encoded: string;
15
+ };
16
+ /** Preserves SvelteKit control flow before classifying transportable Effect failures. */
17
+ export declare function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution;
18
+ /** Encodes a remote failure into the transport ABI shared with generated clients. */
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,20 +1,17 @@
1
+ import type { StandardSchema } from "../../internal/schema.js";
1
2
  import type { NativeFormRecord } from "./types.js";
2
- /**
3
- * Submits a native remote form through the SvelteKit remote endpoint.
4
- *
5
- * @since 2.0.0
6
- * @param form_obj - Native form object being adapted.
7
- * @param input - Form input value.
8
- * @param decode_payload - Function to decode successful payloads.
9
- * @param remote_base - Base URL for the remote endpoint.
10
- * @returns Decoded form output.
11
- */
12
- export declare function submit_remote_form<Output>(form_obj: NativeFormRecord, input: unknown, decode_payload: (value: unknown) => unknown, remote_base: string): Promise<Output>;
13
- /**
14
- * Extracts SvelteKit's remote action id from a native form action URL.
15
- *
16
- * @since 2.0.0
17
- * @param form_obj - Native form object being adapted.
18
- * @returns Remote action id when present.
19
- */
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>;
20
17
  export declare function get_remote_action_id(form_obj: NativeFormRecord): string | undefined;
@@ -1,21 +1,10 @@
1
- import type { RemoteFormInput } from "@sveltejs/kit";
1
+ import { type StandardSchema } from "../../internal/schema.js";
2
2
  import type { EffectRemoteForm } from "./types.js";
3
- /**
4
- * Creates a remote form adapter. The callable preserves SvelteKit's native
5
- * form descriptors while wrapping `validate`, `enhance`, and programmatic
6
- * submission in Effect-returning APIs.
7
- *
8
- * @example
9
- * ```ts
10
- * const createPost = create_remote_form_adapter(nativeForm, (value) => value);
11
- * yield* createPost.validate({ includeUntouched: true });
12
- * ```
13
- *
14
- * @since 2.0.0
15
- * @param native_factory - SvelteKit's native form object.
16
- * @param decode_payload - Function to decode the response payload.
17
- * @param remote_base - Base URL for SvelteKit's remote endpoint.
18
- * @returns A callable form function whose properties mirror the native form.
19
- * @internal
20
- */
21
- 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): EffectRemoteForm<Input, Output, ErrorType>;
3
+ import { type RemoteFormTransport } from "./form-transport.js";
4
+ import type { RemoteFormInput } from "@sveltejs/kit";
5
+ interface RemoteFormAdapterState {
6
+ shared_preflight_schema?: StandardSchema;
7
+ }
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>;
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, EffectRemoteFormSubmit, 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,71 +1,21 @@
1
+ import { type RemoteResourceEffect } from "../resource.js";
2
+ import { type RemoteLiveStream } from "../../live.js";
1
3
  import type { EffectRemoteQueryUpdateBrand } from "./types.js";
2
- import type { RemoteFailure } from "../shared.js";
3
4
  import { Effect } from "effect";
4
5
  type RemoteInput<Input> = undefined extends Input ? Input | void : Input;
5
6
  type DecodePayload<Output> = (value: unknown) => Output;
7
+ type QueryAdapterMode = "standard" | "batch";
6
8
  type NativeQueryFactory<Input> = ((input: RemoteInput<Input>) => unknown) | {
7
9
  readonly load: (input: RemoteInput<Input>) => unknown;
8
10
  };
9
- type RemoteResourceEffect<Output, ErrorType = never> = Effect.Effect<Output, RemoteFailure<ErrorType>> & {
10
- readonly current: Output | undefined;
11
- readonly error: unknown;
12
- readonly loading: boolean;
13
- readonly ready: boolean;
14
- };
15
- type RemoteQueryEffect<Output, ErrorType = never> = RemoteResourceEffect<Output, ErrorType> & {
11
+ type RemoteQueryEffect<Output, ErrorType = never> = EffectRemoteQueryUpdateBrand & RemoteResourceEffect<Output, ErrorType> & {
16
12
  readonly refresh: () => Effect.Effect<void, unknown, never>;
17
13
  readonly set: (value: Output) => void;
18
14
  readonly withOverride: (update: (current: Output) => Output) => unknown;
19
15
  };
20
- type RemoteLiveQueryEffect<Output, ErrorType = never> = Effect.Effect<RemoteLiveQueryResource<Output>, RemoteFailure<ErrorType>>;
21
- type RemoteLiveQueryResource<Output> = {
22
- readonly connected: boolean;
23
- readonly current: Output | undefined;
24
- readonly done: boolean;
25
- readonly error: unknown;
26
- readonly loading: boolean;
27
- readonly ready: boolean;
28
- readonly reconnect: () => Effect.Effect<void, unknown, never>;
29
- } & AsyncIterable<Output>;
30
- /**
31
- * Creates a remote query adapter. The returned function takes input and
32
- * returns an `Effect` that executes SvelteKit's native query function.
33
- *
34
- * @example
35
- * ```ts
36
- * const getUser = create_remote_query_adapter(nativeQuery, (value) => value);
37
- * const user = yield* getUser({ id: 1 });
38
- * ```
39
- *
40
- * @since 2.0.0
41
- * @param native_factory - SvelteKit's native query function or a legacy
42
- * response factory used by tests.
43
- * @param decode_payload - Function to decode the response payload.
44
- * @param _base - Deprecated transport base retained for compatibility.
45
- * @returns A function returning an Effect of the response.
46
- * @internal
47
- */
48
- 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>);
49
- 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>);
50
- /**
51
- * Creates a remote live query adapter. The returned function takes input and
52
- * returns an `Effect` that resolves to a live query resource with stream state
53
- * and reconnect controls.
54
- *
55
- * @example
56
- * ```ts
57
- * const getTime = create_remote_live_query_adapter(nativeLive, (value) => value);
58
- * const time = yield* getTime();
59
- * const current = time.current;
60
- * ```
61
- *
62
- * @since 2.0.0
63
- * @param native_factory - SvelteKit's native live query function.
64
- * @param _decode_payload - Deprecated payload decoder retained for parity with
65
- * other remote adapters.
66
- * @param _base - Deprecated transport base retained for compatibility.
67
- * @returns A function returning an Effect-backed live query resource.
68
- * @internal
69
- */
70
- 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>) => RemoteLiveQueryEffect<Output, ErrorType>);
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. */
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>);
71
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,129 +1,54 @@
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
- import type { Effect } 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
- */
3
+ import type { Effect, Schema, Stream } from "effect";
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
- type EffectRemoteQueryUpdate = NativeRemoteQueryUpdate | EffectRemoteQueryUpdateFunction | EffectRemoteLiveQueryUpdateFunction;
13
+ type NativeRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output> = Parameters<RemoteForm<Input, Output>["preflight"]>[0];
14
+ type NativeRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output> = NonNullable<Parameters<RemoteForm<Input, Output>["validate"]>[0]>;
15
+ export type EffectRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Codec<unknown, Input, never, unknown>;
16
+ export type EffectRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output = unknown> = Omit<NativeRemoteFormValidateOptions<Input, Output>, "all" | "includeUntouched" | "preflightOnly"> & {
17
+ readonly all?: boolean;
18
+ readonly includeUntouched?: boolean;
19
+ readonly preflightOnly?: boolean;
20
+ };
21
+ type EffectRemoteQueryUpdate = NativeRemoteQueryUpdate | EffectRemoteQueryUpdateFunction | EffectRemoteQueryUpdateResource | EffectRemoteLiveQueryUpdateFunction;
25
22
  type EffectRemoteCommandUpdate = {
26
23
  readonly pending: number;
27
24
  };
28
- 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;
29
26
  type EffectRemoteQueryUpdates<Updates extends readonly unknown[]> = Updates & {
30
27
  [Index in keyof Updates]: EffectRemoteQueryUpdateInput<Updates[Index]>;
31
28
  };
32
- type NativeRemoteQueryUpdate = RemoteQuery<unknown> | RemoteLiveQuery<unknown> | RemoteQueryOverride;
33
- type EffectRemoteQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => EffectRemoteQueryUpdateResource);
34
- type EffectRemoteLiveQueryUpdateFunction = EffectRemoteQueryUpdateBrand & ((input: never) => Effect.Effect<EffectRemoteLiveQueryUpdateResource, unknown>);
35
- type EffectRemoteQueryUpdateResource = Effect.Effect<unknown, unknown> & {
36
- readonly refresh: () => Effect.Effect<void, unknown, never>;
37
- readonly set: (value: never) => void;
38
- readonly withOverride: (update: (current: never) => unknown) => unknown;
39
- };
40
- type EffectRemoteLiveQueryUpdateResource = {
41
- readonly connected: boolean;
42
- readonly current: unknown;
43
- readonly done: boolean;
44
- readonly error: unknown;
45
- readonly loading: boolean;
46
- readonly ready: boolean;
47
- readonly reconnect: () => Effect.Effect<void, unknown, never>;
48
- } & AsyncIterable<unknown>;
49
- /**
50
- * Represents a pending operation counter that remote command adapters
51
- * use to track in-flight requests.
52
- *
53
- * @since 2.0.0
54
- * @internal
55
- */
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>;
56
33
  export interface Pending {
57
- /** Current count of in-flight requests. */
58
34
  value: number;
59
35
  }
60
- /**
61
- * Native callable method shape used when reflecting SvelteKit remote helpers.
62
- *
63
- * @since 2.0.0
64
- */
65
36
  export type NativeMethod = (...args: unknown[]) => unknown;
66
- /**
67
- * Property bag shape used for native SvelteKit form objects.
68
- *
69
- * @since 2.0.0
70
- */
71
37
  export type NativeFormRecord = Record<PropertyKey, unknown>;
72
- /**
73
- * Represents the native form submit handle passed into an Effect-aware
74
- * enhanced remote form callback.
75
- *
76
- * @example
77
- * ```ts
78
- * form.enhance(({ submit }) =>
79
- * Effect.gen(function* () {
80
- * yield* submit().updates();
81
- * })
82
- * );
83
- * ```
84
- *
85
- * @since 2.0.0
86
- */
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
+ };
87
41
  export type EffectRemoteFormSubmit<Output = unknown, ErrorType = never> = Effect.Effect<Output | undefined, RemoteFailure<ErrorType>> & {
88
42
  updates: <const Updates extends readonly unknown[]>(...updates: EffectRemoteQueryUpdates<Updates>) => Effect.Effect<Output | undefined, RemoteFailure<ErrorType>>;
89
43
  };
90
- /**
91
- * Represents the callback payload passed to an Effect-aware remote form
92
- * enhancement callback.
93
- *
94
- * @example
95
- * ```ts
96
- * form.enhance(({ data, submit }) =>
97
- * Effect.gen(function* () {
98
- * console.log(data);
99
- * yield* submit();
100
- * })
101
- * );
102
- * ```
103
- *
104
- * @since 2.0.0
105
- */
106
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"> & {
107
45
  submit: () => EffectRemoteFormSubmit<Output, ErrorType>;
108
46
  };
109
- /**
110
- * Represents a SvelteKit remote form whose submission, validation, and
111
- * enhancement hooks expose Effect-returning APIs.
112
- *
113
- * @example
114
- * ```ts
115
- * const form = create_remote_form_adapter(nativeForm, (value) => value);
116
- *
117
- * yield* form.preflight(schema).validate();
118
- * ```
119
- *
120
- * @since 2.0.0
121
- */
122
47
  export type EffectRemoteForm<Input extends RemoteFormInput | void, Output, ErrorType = never> = EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<RemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
123
48
  enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<RemoteForm<Input, Output>["enhance"]>;
124
- for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
125
- preflight(schema: Parameters<RemoteForm<Input, Output>["preflight"]>[0]): EffectRemoteForm<Input, Output, ErrorType>;
49
+ for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
50
+ preflight(schema: EffectRemoteFormPreflightSchema<Input, Output>): EffectRemoteForm<Input, Output, ErrorType>;
126
51
  submit: EffectRemoteFormCallable<Input, Output, ErrorType>;
127
- validate(options?: Parameters<RemoteForm<Input, Output>["validate"]>[0]): Effect.Effect<void, RemoteFailure<ErrorType>>;
52
+ validate(options?: EffectRemoteFormValidateOptions<Input, Output>): Effect.Effect<void, RemoteFailure<ErrorType>>;
128
53
  };
129
54
  export {};
@@ -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, EffectRemoteFormSubmit, 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-CsVu54pU.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 {};