svelte-effect-runtime 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/.dist/chunks/{client-Cruhk6Oo.js → client-DRjQiULJ.js} +10 -9
  2. package/.dist/chunks/client-DRjQiULJ.js.map +1 -0
  3. package/.dist/chunks/{dispatcher-FCsx1Hlh.js → dispatcher-CLSN-Cxn.js} +3 -3
  4. package/.dist/chunks/{dispatcher-FCsx1Hlh.js.map → dispatcher-CLSN-Cxn.js.map} +1 -1
  5. package/.dist/chunks/{dispatcher-CgCdn6bj.js → dispatcher-CZvLODNK.js} +4 -3
  6. package/.dist/chunks/dispatcher-CZvLODNK.js.map +1 -0
  7. package/.dist/chunks/errors-DppSJ83S.js +692 -0
  8. package/.dist/chunks/errors-DppSJ83S.js.map +1 -0
  9. package/.dist/chunks/{runtime-Sl685BVb.js → runtime-BgCRz_rL.js} +4 -3
  10. package/.dist/chunks/runtime-BgCRz_rL.js.map +1 -0
  11. package/.dist/chunks/{transform-CebZMD6u.js → transform-B7_CCcvq.js} +16 -219
  12. package/.dist/chunks/transform-B7_CCcvq.js.map +1 -0
  13. package/.dist/dispatcher.js +1 -1
  14. package/.dist/errors.d.ts +544 -0
  15. package/.dist/internal/generators.js +1 -1
  16. package/.dist/internal/remote-client.js +1 -1
  17. package/.dist/markup/promise.d.ts +17 -3
  18. package/.dist/markup/promise.js +15 -4
  19. package/.dist/markup/promise.js.map +1 -1
  20. package/.dist/markup/run.js +1 -1
  21. package/.dist/markup/transform.js +1 -1
  22. package/.dist/markup/value.d.ts +3 -3
  23. package/.dist/markup/value.js +8 -4
  24. package/.dist/markup/value.js.map +1 -1
  25. package/.dist/mod.d.ts +1 -0
  26. package/.dist/mod.js +4 -3
  27. package/.dist/mod.js.map +1 -1
  28. package/.dist/remote/client.js +1 -1
  29. package/.dist/remote/server.js +3 -2
  30. package/.dist/remote/server.js.map +1 -1
  31. package/.dist/runtime/transform.js +2 -1
  32. package/.dist/runtime/transform.js.map +1 -1
  33. package/.dist/server.js +12 -11
  34. package/.dist/server.js.map +1 -1
  35. package/package.json +1 -1
  36. package/.dist/chunks/client-Cruhk6Oo.js.map +0 -1
  37. package/.dist/chunks/dispatcher-CgCdn6bj.js.map +0 -1
  38. package/.dist/chunks/runtime-Sl685BVb.js.map +0 -1
  39. package/.dist/chunks/transform-CebZMD6u.js.map +0 -1
  40. package/.dist/error.d.ts +0 -140
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-DppSJ83S.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/errors.ts"],"sourcesContent":["/**\n * Base class for runtime-authored errors. The class gives every local failure\n * a stable JavaScript error name while preserving the technical message that\n * reaches Vite, SvelteKit, and test output.\n *\n * @example\n * ```ts\n * throw new RuntimeError(\"Invariant violated.\");\n * ```\n *\n * @since 2.4.0\n * @param message - Technical diagnostic message describing the failed runtime\n * invariant.\n * @returns A runtime-authored Error instance.\n */\nexport class RuntimeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"RuntimeError\";\n }\n}\n\n/**\n * Formats a runtime-owned error message with a stable screaming-case code.\n *\n * @example\n * ```ts\n * throw new Error(make_error_message(\"DISPATCHER_DISPOSED\", \"Dispatcher has been disposed\"));\n * ```\n *\n * @since 2.0.0\n * @param code - Stable screaming-case identifier for the error category.\n * @param message - Human-readable error message without the leading code.\n * @returns The complete error message prefixed with the stable code.\n */\nexport function make_error_message(code: string, message: string): string {\n return `[${code}]: ${message}`;\n}\n\n/**\n * Base error class for all preprocessor errors emitted during script and\n * markup transformation. Carries the source filename so error messages can\n * reference the affected file.\n *\n * @example\n * ```ts\n * throw new PreprocessError(\"Component.svelte: invalid transform input.\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param message - Technical diagnostic message for the transform failure.\n * @param filename - Source filename that triggered the transform failure.\n * @returns A preprocessor Error instance with source file context.\n */\nexport class PreprocessError extends RuntimeError {\n /**\n * The source filename that triggered this error.\n *\n * @since 2.0.0\n */\n readonly filename: string;\n\n constructor(message: string, filename: string) {\n super(message);\n this.name = \"PreprocessError\";\n this.filename = filename;\n }\n}\n\n/**\n * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work\n * that must be lowered into an `Effect.gen` program.\n *\n * @example\n * ```ts\n * throw new AwaitInEffectWorkError(\"Component.svelte\", \"const value = await load();\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the unsupported statement.\n * @param statement_text - Full source text for the statement containing\n * mixed async work.\n * @returns A preprocessor Error instance with statement context.\n */\nexport class AwaitInEffectWorkError extends PreprocessError {\n /**\n * The full text of the problematic statement containing mixed async work.\n *\n * @since 2.0.0\n */\n readonly statement_text: string;\n\n constructor(filename: string, statement_text: string) {\n super(\n [\n make_error_message(\n \"AWAIT_IN_EFFECT_WORK\",\n `${filename}: await cannot be mixed with yield* in Effect work.`,\n ),\n `Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n \"\",\n `Problematic statement:`,\n statement_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AwaitInEffectWorkError\";\n this.statement_text = statement_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears inside a Svelte rune position that\n * must stay synchronous.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInSyncRuneError(\"$derived\", \"$derived(yield* load())\", \"Component.svelte\");\n * ```\n *\n * @since 2.0.0\n * @param rune_name - Name of the Svelte rune containing the unsupported async\n * Effect work.\n * @param expression_text - Full source text for the rune expression.\n * @param filename - Source filename containing the unsupported rune.\n * @returns A preprocessor Error instance with rune source context.\n */\nexport class AsyncEffectInSyncRuneError extends PreprocessError {\n /**\n * The name of the rune that contained async Effect work.\n *\n * @since 2.0.0\n */\n readonly rune_name: string;\n\n /**\n * The full text of the expression that triggered the error.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(rune_name: string, expression_text: string, filename: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_SYNC_RUNE\",\n `${filename}: yield* cannot be used inside ${rune_name}().`,\n ),\n `${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInSyncRuneError\";\n this.rune_name = rune_name;\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears inside a non-generator callback nested\n * in a markup event handler.\n *\n * @example\n * ```ts\n * throw new AsyncEffectInEventCallbackError(\n * \"Component.svelte\",\n * \"Effect.try(() => yield* save())\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param filename - Source filename containing the invalid event handler.\n * @param expression_text - Event handler expression that contains the nested\n * unsupported async Effect work.\n * @returns A preprocessor Error instance with event expression context.\n */\nexport class AsyncEffectInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler body.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n `${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n ),\n `Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,\n \"\",\n `Run the remote Effect directly:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Recover from remote failures by composing the Effect value:`,\n ` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"AsyncEffectInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when an event handler callback contains the old raw `yield*`\n * shorthand. Effectful event handlers must put `yield*` directly in the event\n * attribute so the callback boundary is generated by the markup runtime.\n *\n * @example\n * ```ts\n * throw new YieldStarInEventCallbackError(\"Component.svelte\", \"() => yield* save()\");\n * ```\n *\n * @since 2.0.0\n * @param filename - Svelte component filename used to identify where the\n * invalid event handler callback was found.\n * @param expression_text - Original event handler callback text that contained\n * `yield*` and should be rewritten as a direct event Effect expression.\n * @returns A preprocessor Error instance with event callback context.\n */\nexport class YieldStarInEventCallbackError extends PreprocessError {\n /**\n * The full text of the problematic event handler callback.\n *\n * @since 2.0.0\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n `${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n ),\n `SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n \"\",\n `Use this form:`,\n ` onclick={yield* UpvotePost(id)}`,\n \"\",\n `Instead of this form:`,\n ` onclick={() => yield* UpvotePost(id)}`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"YieldStarInEventCallbackError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when async Effect work appears in a markup position SER cannot lower\n * safely.\n *\n * @example\n * ```ts\n * throw new UnsupportedMarkupEffectPositionError(\n * \"Component.svelte\",\n * \"value={yield* load()}\",\n * );\n * ```\n *\n * @since 2.4.2\n * @param filename - Source filename containing the unsupported markup.\n * @param expression_text - The unsupported markup expression text.\n * @returns A preprocessor Error instance with markup source context.\n */\nexport class UnsupportedMarkupEffectPositionError extends PreprocessError {\n /**\n * The unsupported markup expression text.\n *\n * @since 2.4.2\n */\n readonly expression_text: string;\n\n constructor(filename: string, expression_text: string) {\n super(\n [\n make_error_message(\n \"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n `${filename}: yield* cannot be used in this markup position.`,\n ),\n `Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n \"\",\n `Problematic expression:`,\n expression_text,\n ].join(\"\\n\"),\n filename,\n );\n this.name = \"UnsupportedMarkupEffectPositionError\";\n this.expression_text = expression_text;\n }\n}\n\n/**\n * Thrown when the request-scoped SvelteKit event context is read outside a\n * remote handler.\n *\n * @example\n * ```ts\n * throw new RequestEventUnavailableError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing missing request context.\n */\nexport class RequestEventUnavailableError extends RuntimeError {\n constructor() {\n super(\n \"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n );\n this.name = \"RequestEventUnavailableError\";\n }\n}\n\n/**\n * Thrown when an unchecked Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Query overload usage.\n */\nexport class UncheckedQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n );\n this.name = \"UncheckedQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when a batch Query declaration omits the batch handler.\n *\n * @example\n * ```ts\n * throw new BatchQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid batch Query overload usage.\n */\nexport class BatchQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n );\n this.name = \"BatchQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked live Query declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedLiveQueryHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid live Query overload usage.\n */\nexport class UncheckedLiveQueryHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n );\n this.name = \"UncheckedLiveQueryHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Command declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedCommandHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Command overload usage.\n */\nexport class UncheckedCommandHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n );\n this.name = \"UncheckedCommandHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Form declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedFormHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Form overload usage.\n */\nexport class UncheckedFormHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n );\n this.name = \"UncheckedFormHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when an unchecked Prerender declaration omits the handler.\n *\n * @example\n * ```ts\n * throw new UncheckedPrerenderHandlerMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the invalid Prerender overload usage.\n */\nexport class UncheckedPrerenderHandlerMissingError extends RuntimeError {\n constructor() {\n super(\n \"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n );\n this.name = \"UncheckedPrerenderHandlerMissingError\";\n }\n}\n\n/**\n * Thrown when a live query handler resolves to a value that cannot be streamed.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryReturnError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing the expected live query return protocol.\n */\nexport class InvalidLiveQueryReturnError extends RuntimeError {\n constructor() {\n super(\n \"Query.live handler must return an Effect Stream, Iterable, or AsyncIterable; resolved values must expose a streaming protocol that SER can bridge to SvelteKit.\",\n );\n this.name = \"InvalidLiveQueryReturnError\";\n }\n}\n\n/**\n * Thrown when a dispatcher operation is requested after disposal.\n *\n * @example\n * ```ts\n * throw new DispatcherDisposedError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid dispatcher lifecycle transition.\n */\nexport class DispatcherDisposedError extends RuntimeError {\n constructor() {\n super(\n \"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n );\n this.name = \"DispatcherDisposedError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid query adapter input.\n */\nexport class InvalidQueryFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n );\n this.name = \"InvalidQueryFactoryError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote live query export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidLiveQueryFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid live query adapter input.\n */\nexport class InvalidLiveQueryFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n );\n this.name = \"InvalidLiveQueryFactoryError\";\n }\n}\n\n/**\n * Thrown when a generated or native remote command export is not callable.\n *\n * @example\n * ```ts\n * throw new InvalidCommandFactoryError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing an invalid command adapter input.\n */\nexport class InvalidCommandFactoryError extends RuntimeError {\n constructor() {\n super(\n \"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n );\n this.name = \"InvalidCommandFactoryError\";\n }\n}\n\n/**\n * Thrown when the client-side form adapter cannot derive a remote endpoint.\n *\n * @example\n * ```ts\n * throw new RemoteFormEndpointMissingError();\n * ```\n *\n * @since 2.4.0\n * @returns An Error describing missing form transport metadata.\n */\nexport class RemoteFormEndpointMissingError extends RuntimeError {\n constructor() {\n super(\n \"Form has no submit method or remote endpoint; the adapted SvelteKit form object does not expose an action id and no remote base URL was generated.\",\n );\n this.name = \"RemoteFormEndpointMissingError\";\n }\n}\n\n/**\n * Thrown when a remote form response envelope is not an object with a response\n * type.\n *\n * @example\n * ```ts\n * throw new InvalidRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n * @returns An Error describing malformed form response data.\n */\nexport class InvalidRemoteFormResponseError extends RuntimeError {\n /**\n * Raw response envelope returned by the remote form endpoint.\n *\n * @since 2.4.0\n */\n readonly envelope: unknown;\n\n constructor(envelope?: unknown) {\n super(\n \"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n );\n this.name = \"InvalidRemoteFormResponseError\";\n this.envelope = envelope;\n }\n}\n\n/**\n * Thrown when a remote form response has a well-formed envelope but an\n * unsupported response type or payload slot.\n *\n * @example\n * ```ts\n * throw new UnsupportedRemoteFormResponseError(envelope);\n * ```\n *\n * @since 2.4.0\n * @param envelope - Raw response envelope returned by the remote form endpoint.\n * @returns An Error describing unsupported form response data.\n */\nexport class UnsupportedRemoteFormResponseError extends RuntimeError {\n /**\n * Raw response envelope returned by the remote form endpoint.\n *\n * @since 2.4.0\n */\n readonly envelope: unknown;\n\n constructor(envelope?: unknown) {\n super(\n \"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n );\n this.name = \"UnsupportedRemoteFormResponseError\";\n this.envelope = envelope;\n }\n}\n\n/**\n * Thrown when a serialized remote failure envelope cannot be decoded.\n *\n * @example\n * ```ts\n * throw new RemoteErrorDecodeError(raw);\n * ```\n *\n * @since 2.4.0\n * @param raw - Raw serialized remote failure payload that failed decoding.\n * @returns An Error describing a malformed remote failure payload.\n */\nexport class RemoteErrorDecodeError extends RuntimeError {\n /**\n * Raw serialized remote failure payload that failed decoding.\n *\n * @since 2.4.0\n */\n readonly raw: unknown;\n\n constructor(raw?: unknown) {\n super(\n \"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n );\n this.name = \"RemoteErrorDecodeError\";\n this.raw = raw;\n }\n}\n\n/**\n * Thrown when a root server-only helper is imported without Vite rewriting.\n *\n * @example\n * ```ts\n * throw new ServerOnlyImportError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the server-only root export that was invoked.\n * @returns An Error describing a missing server rewrite.\n */\nexport class ServerOnlyImportError extends RuntimeError {\n /**\n * Name of the server-only root export that was invoked.\n *\n * @since 2.4.0\n */\n readonly export_name: string;\n\n constructor(export_name: string) {\n super(\n `${export_name} is only available in SvelteKit server files. Ensure the SER Vite plugin is enabled so root imports are rewritten to svelte-effect-runtime/server before execution.`,\n );\n this.name = \"ServerOnlyImportError\";\n this.export_name = export_name;\n }\n}\n\n/**\n * Thrown when the publish-time `$app/server` shim executes outside SvelteKit.\n *\n * @example\n * ```ts\n * throw new SvelteKitServerExportUnavailableError(\"query\");\n * ```\n *\n * @since 2.4.0\n * @param export_name - Name of the `$app/server` export that was invoked.\n * @returns An Error describing an unavailable SvelteKit virtual module export.\n */\nexport class SvelteKitServerExportUnavailableError extends RuntimeError {\n /**\n * Name of the `$app/server` export that was invoked.\n *\n * @since 2.4.0\n */\n readonly export_name: string;\n\n constructor(export_name: string) {\n super(\n `SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n );\n this.name = \"SvelteKitServerExportUnavailableError\";\n this.export_name = export_name;\n }\n}\n\n/**\n * Thrown when a SvelteKit remote helper reports that it was called outside the\n * route-scoped remote module context.\n *\n * @example\n * ```ts\n * throw new RemoteHelperContextError(\"Query\");\n * ```\n *\n * @since 2.4.0\n * @param helper_name - SER helper name that triggered the context failure.\n * @returns An Error describing the required `.remote.ts` placement.\n */\nexport class RemoteHelperContextError extends RuntimeError {\n /**\n * SER helper name that triggered the context failure.\n *\n * @since 2.4.0\n */\n readonly helper_name: string;\n\n constructor(helper_name: string) {\n super(\n make_error_message(\n \"REMOTE_HELPER_CONTEXT\",\n `${helper_name} was called outside a .remote.ts file. Ensure the file is named \\`*.remote.ts\\` and is located in a route directory so SvelteKit can bind remote helper context.`,\n ),\n );\n this.name = \"RemoteHelperContextError\";\n this.helper_name = helper_name;\n }\n}\n\n/**\n * Thrown when a SvelteKit remote helper normalizes a non-Error thrown value.\n *\n * @example\n * ```ts\n * throw new RemoteHelperError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value thrown while creating a remote helper.\n * @returns An Error preserving the remote helper failure value.\n */\nexport class RemoteHelperError extends RuntimeError {\n /**\n * Non-Error value that was normalized.\n *\n * @since 2.4.0\n */\n readonly value: unknown;\n\n constructor(value: unknown) {\n super(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n this.name = \"RemoteHelperError\";\n this.value = value;\n }\n}\n\n/**\n * Thrown when a non-Error value must be normalized into an Error instance.\n *\n * @example\n * ```ts\n * throw new UnknownRuntimeError(\"raw failure\");\n * ```\n *\n * @since 2.4.0\n * @param value - Non-Error value that needs Error normalization.\n * @returns An Error preserving the string representation of an unknown value.\n */\nexport class UnknownRuntimeError extends RuntimeError {\n /**\n * Non-Error value that was normalized.\n *\n * @since 2.4.0\n */\n readonly value: unknown;\n\n constructor(value: unknown) {\n super(String(value));\n this.name = \"UnknownRuntimeError\";\n this.value = value;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAa,eAAb,cAAkC,MAAM;CACtC,YAAY,SAAiB;EAC3B,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACF;;;;;;;;;;;;;;AAeA,SAAgB,mBAAmB,MAAc,SAAyB;CACxE,OAAO,IAAI,KAAK,KAAK;AACvB;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMhD;CAEA,YAAY,SAAiB,UAAkB;EAC7C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM1D;CAEA,YAAY,UAAkB,gBAAwB;EACpD,MACE;GACE,mBACE,wBACA,GAAG,SAAS,oDACd;GACA;GACA;GACA;GACA;EACF,EAAE,KAAK,IAAI,GACX,QACF;E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,KAAK,QAAQ;CACf;AACF"}
@@ -1,4 +1,5 @@
1
- import { t as Dispatcher } from "./dispatcher-CgCdn6bj.js";
1
+ import { g as RequestEventUnavailableError } from "./errors-DppSJ83S.js";
2
+ import { t as Dispatcher } from "./dispatcher-CZvLODNK.js";
2
3
  import { Context, Layer, ManagedRuntime } from "effect";
3
4
  //#region src/server/runtime.ts
4
5
  /**
@@ -12,7 +13,7 @@ import { Context, Layer, ManagedRuntime } from "effect";
12
13
  * @since 2.0.0
13
14
  */
14
15
  const RequestEvent = Context.Reference("@ser/RequestEvent", { defaultValue: () => {
15
- throw new Error("[REQUEST_EVENT_UNAVAILABLE]: RequestEvent is only available during a remote call");
16
+ throw new RequestEventUnavailableError();
16
17
  } });
17
18
  /**
18
19
  * Builder for the server-side Effect runtime.
@@ -76,4 +77,4 @@ function get_server_dispatcher() {
76
77
  //#endregion
77
78
  export { get_server_runtime_or_throw as i, ServerRuntime as n, get_server_dispatcher as r, RequestEvent as t };
78
79
 
79
- //# sourceMappingURL=runtime-Sl685BVb.js.map
80
+ //# sourceMappingURL=runtime-BgCRz_rL.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-BgCRz_rL.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\n\nimport { RequestEventUnavailableError } from \"$/errors.ts\";\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends\n Pick<\n SvelteKitRequestEvent,\n | \"cookies\"\n | \"getClientAddress\"\n | \"locals\"\n | \"params\"\n | \"platform\"\n | \"request\"\n | \"route\"\n | \"url\"\n > {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context\n .Reference<RequestEvent>(\"@ser/RequestEvent\", {\n defaultValue: () => {\n throw new RequestEventUnavailableError();\n },\n });\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n /**\n * Build and cache the server-side `ManagedRuntime`.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n * @returns The configured ManagedRuntime.\n */\n static make<R = never>(\n layer?: Layer.Layer<R>,\n ): ManagedRuntime.ManagedRuntime<R, never> {\n const runtime = ManagedRuntime.make(\n layer ?? (Layer.empty as unknown as Layer.Layer<R>),\n );\n\n current_server_runtime = runtime as ManagedRuntime.ManagedRuntime<\n unknown,\n never\n >;\n current_server_dispatcher?.dispose();\n current_server_dispatcher = new InternalDispatcher(\n runtime as unknown as ManagedRuntimeType<unknown, unknown>,\n );\n\n return runtime;\n }\n}\n\nlet current_server_runtime:\n | ManagedRuntime.ManagedRuntime<unknown, never>\n | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> {\n if (!current_server_runtime) {\n current_server_runtime = ManagedRuntime.make(\n Layer.empty,\n ) as ManagedRuntime.ManagedRuntime<unknown, never>;\n }\n\n return current_server_runtime;\n}\n\n/**\n * Returns a dispatcher backed by the active server runtime.\n *\n * @example\n * ```ts\n * const dispatcher = get_server_dispatcher();\n * ```\n *\n * @since 3.0.1\n * @returns The cached server dispatcher, creating one from the current server\n * runtime when needed.\n */\nexport function get_server_dispatcher(): InternalDispatcher {\n current_server_dispatcher ??= new InternalDispatcher(\n get_server_runtime_or_throw() as unknown as ManagedRuntimeType<\n unknown,\n unknown\n >,\n );\n\n return current_server_dispatcher;\n}\n"],"mappings":";;;;;;;;;;;;;;AAmCA,MAAa,eAAgD,QAC1D,UAAwB,qBAAqB,EAC5C,oBAAoB;CAClB,MAAM,IAAI,6BAA6B;AACzC,EACF,CAAC;;;;;;;;;;;AAYH,IAAa,gBAAb,MAA2B;;;;;;;;CAQzB,OAAO,KACL,OACyC;EACzC,MAAM,UAAU,eAAe,KAC7B,SAAU,MAAM,KAClB;EAEA,yBAAyB;EAIzB,2BAA2B,QAAQ;EACnC,4BAA4B,IAAIA,WAC9B,OACF;EAEA,OAAO;CACT;AACF;AAEA,IAAI;AAGJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAGd;CACA,IAAI,CAAC,wBACH,yBAAyB,eAAe,KACtC,MAAM,KACR;CAGF,OAAO;AACT;;;;;;;;;;;;;AAcA,SAAgB,wBAA4C;CAC1D,8BAA8B,IAAIA,WAChC,4BAA4B,CAI9B;CAEA,OAAO;AACT"}
@@ -1,3 +1,4 @@
1
+ import { E as UnsupportedMarkupEffectPositionError, O as YieldStarInEventCallbackError, t as AsyncEffectInEventCallbackError } from "./errors-DppSJ83S.js";
1
2
  import { contains_top_level_yield_star } from "../detect.js";
2
3
  import { parse } from "svelte/compiler";
3
4
  import MagicString from "magic-string";
@@ -528,217 +529,6 @@ function add_ordered_name(names, name) {
528
529
  names.push(name);
529
530
  }
530
531
  //#endregion
531
- //#region src/error.ts
532
- /**
533
- * Formats a runtime-owned error message with a stable screaming-case code.
534
- *
535
- * @example
536
- * ```ts
537
- * throw new Error(make_error_message("DISPATCHER_DISPOSED", "Dispatcher has been disposed"));
538
- * ```
539
- *
540
- * @since 2.0.0
541
- * @param code - Stable screaming-case identifier for the error category.
542
- * @param message - Human-readable error message without the leading code.
543
- * @returns The complete error message prefixed with the stable code.
544
- */
545
- function make_error_message(code, message) {
546
- return `[${code}]: ${message}`;
547
- }
548
- /**
549
- * Base error class for all transform errors emitted during script and
550
- * markup transformation. Carries the source filename so error messages can
551
- * reference the affected file.
552
- *
553
- * @since 2.0.0
554
- */
555
- var PreprocessError = class extends Error {
556
- /**
557
- * The source filename that triggered this error.
558
- *
559
- * @since 2.0.0
560
- */
561
- filename;
562
- constructor(message, filename) {
563
- super(message);
564
- this.name = "PreprocessError";
565
- this.filename = filename;
566
- }
567
- };
568
- /**
569
- * Thrown when a statement mixes JavaScript `await` with Effect `yield*` work
570
- * that must be lowered into an `Effect.gen` program.
571
- *
572
- * @since 2.0.0
573
- */
574
- var AwaitInEffectWorkError = class extends PreprocessError {
575
- /**
576
- * The full text of the problematic statement containing mixed async work.
577
- *
578
- * @since 2.0.0
579
- */
580
- statement_text;
581
- constructor(filename, statement_text) {
582
- super([
583
- make_error_message("AWAIT_IN_EFFECT_WORK", `${filename}: await cannot be mixed with yield* in Effect work.`),
584
- `Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,
585
- "",
586
- `Problematic statement:`,
587
- statement_text
588
- ].join("\n"), filename);
589
- this.name = "AwaitInEffectWorkError";
590
- this.statement_text = statement_text;
591
- }
592
- };
593
- /**
594
- * Thrown when async Effect work appears inside a Svelte rune position that
595
- * must stay synchronous.
596
- *
597
- * @since 2.0.0
598
- */
599
- var AsyncEffectInSyncRuneError = class extends PreprocessError {
600
- /**
601
- * The name of the rune that contained async Effect work.
602
- *
603
- * @since 2.0.0
604
- */
605
- rune_name;
606
- /**
607
- * The full text of the expression that triggered the error.
608
- *
609
- * @since 2.0.0
610
- */
611
- expression_text;
612
- constructor(rune_name, expression_text, filename) {
613
- super([
614
- make_error_message("ASYNC_EFFECT_IN_SYNC_RUNE", `${filename}: yield* cannot be used inside ${rune_name}().`),
615
- `${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,
616
- "",
617
- `Problematic expression:`,
618
- expression_text
619
- ].join("\n"), filename);
620
- this.name = "AsyncEffectInSyncRuneError";
621
- this.rune_name = rune_name;
622
- this.expression_text = expression_text;
623
- }
624
- };
625
- /**
626
- * Thrown when async Effect work appears inside a non-generator callback nested
627
- * in a markup event handler.
628
- *
629
- * @example
630
- * ```ts
631
- * throw new AsyncEffectInEventCallbackError(
632
- * "Component.svelte",
633
- * "Effect.try(() => yield* save())",
634
- * );
635
- * ```
636
- *
637
- * @since 2.0.0
638
- */
639
- var AsyncEffectInEventCallbackError = class extends PreprocessError {
640
- /**
641
- * The full text of the problematic event handler body.
642
- *
643
- * @since 2.0.0
644
- */
645
- expression_text;
646
- constructor(filename, expression_text) {
647
- super([
648
- make_error_message("ASYNC_EFFECT_IN_EVENT_CALLBACK", `${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`),
649
- `Move the yield* to the event handler body. Effect.try and Effect.sync callbacks are plain synchronous JavaScript; do not call Effect-returning functions inside them.`,
650
- "",
651
- `Run the remote Effect directly:`,
652
- ` onclick={yield* UpvotePost(id)}`,
653
- "",
654
- `Recover from remote failures by composing the Effect value:`,
655
- ` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,
656
- "",
657
- `Problematic expression:`,
658
- expression_text
659
- ].join("\n"), filename);
660
- this.name = "AsyncEffectInEventCallbackError";
661
- this.expression_text = expression_text;
662
- }
663
- };
664
- /**
665
- * Thrown when an event handler callback contains the old raw `yield*`
666
- * shorthand. Effectful event handlers must put `yield*` directly in the event
667
- * attribute so the callback boundary is generated by the markup runtime.
668
- *
669
- * @example
670
- * ```ts
671
- * throw new YieldStarInEventCallbackError(
672
- * "Component.svelte",
673
- * "() => yield* save()",
674
- * );
675
- * ```
676
- *
677
- * @since 2.0.0
678
- * @param filename - Svelte component filename used to identify where the
679
- * invalid event handler callback was found.
680
- * @param expression_text - Original event handler callback text that contained
681
- * `yield*` and should be rewritten as a direct event Effect expression.
682
- */
683
- var YieldStarInEventCallbackError = class extends PreprocessError {
684
- /**
685
- * The full text of the problematic event handler callback.
686
- *
687
- * @since 2.0.0
688
- */
689
- expression_text;
690
- constructor(filename, expression_text) {
691
- super([
692
- make_error_message("ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK", `${filename}: yield* in markup event handlers must be written directly as the event attribute value.`),
693
- `SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,
694
- "",
695
- `Use this form:`,
696
- ` onclick={yield* UpvotePost(id)}`,
697
- "",
698
- `Instead of this form:`,
699
- ` onclick={() => yield* UpvotePost(id)}`,
700
- "",
701
- `Problematic expression:`,
702
- expression_text
703
- ].join("\n"), filename);
704
- this.name = "YieldStarInEventCallbackError";
705
- this.expression_text = expression_text;
706
- }
707
- };
708
- /**
709
- * Thrown when async Effect work appears in a markup position SER cannot lower
710
- * safely.
711
- *
712
- * @example
713
- * ```ts
714
- * throw new UnsupportedMarkupEffectPositionError(
715
- * "Component.svelte",
716
- * "value={yield* load()}",
717
- * );
718
- * ```
719
- *
720
- * @since 2.4.2
721
- */
722
- var UnsupportedMarkupEffectPositionError = class extends PreprocessError {
723
- /**
724
- * The unsupported markup expression text.
725
- *
726
- * @since 2.4.2
727
- */
728
- expression_text;
729
- constructor(filename, expression_text) {
730
- super([
731
- make_error_message("UNSUPPORTED_MARKUP_EFFECT_POSITION", `${filename}: yield* cannot be used in this markup position.`),
732
- `Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,
733
- "",
734
- `Problematic expression:`,
735
- expression_text
736
- ].join("\n"), filename);
737
- this.name = "UnsupportedMarkupEffectPositionError";
738
- this.expression_text = expression_text;
739
- }
740
- };
741
- //#endregion
742
532
  //#region src/markup/transform/expressions.ts
743
533
  /**
744
534
  * Strips an event handler arrow function down to its executable body.
@@ -1162,7 +952,7 @@ function emit_replacement(candidate, kind, effect_context, helper_bindings, name
1162
952
  let relocation;
1163
953
  if (kind === "await") {
1164
954
  const effect = make_effect_helper(normalized_candidate, helper_name);
1165
- replacement_text = emit_promise_expression(id_text, effect, helper_bindings);
955
+ replacement_text = emit_promise_expression(id_text, effect, helper_bindings, "undefined", `{ ssr: "pending" }`);
1166
956
  helpers = [...normalized.helpers, effect.helper];
1167
957
  } else if (kind === "render") {
1168
958
  const effect = make_effect_helper(normalized_candidate, helper_name);
@@ -1174,7 +964,7 @@ function emit_replacement(candidate, kind, effect_context, helper_bindings, name
1174
964
  helpers = [...normalized.helpers, effect.helper];
1175
965
  } else if (kind === "each") {
1176
966
  const effect = make_effect_helper(normalized_candidate, helper_name);
1177
- replacement_text = emit_each_expression(id_text, effect, helper_bindings);
967
+ replacement_text = emit_each_expression(id_text, effect, helper_bindings, "[]");
1178
968
  helpers = [...normalized.helpers, effect.helper];
1179
969
  } else if (kind === "event") {
1180
970
  const event = make_event_handler(normalized_candidate, helper_bindings);
@@ -1207,16 +997,23 @@ function make_event_handler(candidate, helper_bindings) {
1207
997
  text: `(event) => { ${helper_bindings.run}(function* () { ${expr_text}; }); }`
1208
998
  };
1209
999
  }
1210
- function emit_promise_expression(id_text, effect, helper_bindings) {
1211
- return `${helper_bindings.promise}(${id_text}, ${effect.deps_text}, () => ${effect.call})`;
1000
+ function emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback, options) {
1001
+ const args = [
1002
+ id_text,
1003
+ effect.deps_text,
1004
+ `() => ${effect.call}`,
1005
+ ssr_fallback,
1006
+ options
1007
+ ].filter((arg) => arg !== void 0);
1008
+ return `${helper_bindings.promise}(${args.join(", ")})`;
1212
1009
  }
1213
1010
  function emit_render_expression(id_text, effect, candidate, helper_bindings) {
1214
1011
  const expression = emit_promise_expression(id_text, effect, helper_bindings);
1215
1012
  if (/^\s*yield\s*\*/.test(candidate.expr_text)) return `(await ${expression})()`;
1216
1013
  return `await ${expression}`;
1217
1014
  }
1218
- function emit_each_expression(id_text, effect, helper_bindings) {
1219
- return `await ${emit_promise_expression(id_text, effect, helper_bindings)}`;
1015
+ function emit_each_expression(id_text, effect, helper_bindings, ssr_fallback) {
1016
+ return `await ${emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback)}`;
1220
1017
  }
1221
1018
  function make_effect_helper(candidate, helper_name) {
1222
1019
  const deps = collect_free_identifiers(candidate.expr_text);
@@ -1679,6 +1476,6 @@ function transform_markup_effect(content, filename) {
1679
1476
  };
1680
1477
  }
1681
1478
  //#endregion
1682
- export { find_yield_star_node as a, AsyncEffectInSyncRuneError as c, collect_top_level_binding_names as d, has_local_import_binding as f, extract_binding_names as i, AwaitInEffectWorkError as l, collect_yield_star_nodes as n, is_yield_star_expression as o, make_imports as p, contains_top_level_await as r, collect_free_identifiers as s, transform_markup_effect as t, PreprocessError as u };
1479
+ export { find_yield_star_node as a, collect_top_level_binding_names as c, extract_binding_names as i, has_local_import_binding as l, collect_yield_star_nodes as n, is_yield_star_expression as o, contains_top_level_await as r, collect_free_identifiers as s, transform_markup_effect as t, make_imports as u };
1683
1480
 
1684
- //# sourceMappingURL=transform-CebZMD6u.js.map
1481
+ //# sourceMappingURL=transform-B7_CCcvq.js.map