svelte-effect-runtime 3.4.8 → 3.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-D_DE2cFa.js → client-CsVu54pU.js} +42 -11
- package/.dist/chunks/{client-D_DE2cFa.js.map → client-CsVu54pU.js.map} +1 -1
- package/.dist/chunks/{dispatcher-NpL5xhWF.js → dispatcher-LtvFKYUp.js} +3 -3
- package/.dist/chunks/{dispatcher-NpL5xhWF.js.map → dispatcher-LtvFKYUp.js.map} +1 -1
- package/.dist/chunks/{dispatcher-BdvO4AAS.js → dispatcher-pHH4JcFR.js} +2 -2
- package/.dist/chunks/{dispatcher-BdvO4AAS.js.map → dispatcher-pHH4JcFR.js.map} +1 -1
- package/.dist/chunks/{errors-Bl3NVEez.js → errors-Dcf0MVbq.js} +3 -21
- package/.dist/chunks/{errors-Bl3NVEez.js.map → errors-Dcf0MVbq.js.map} +1 -1
- package/.dist/chunks/{runtime-BNNW2GDT.js → runtime-ekkMQ-wL.js} +3 -3
- package/.dist/chunks/{runtime-BNNW2GDT.js.map → runtime-ekkMQ-wL.js.map} +1 -1
- package/.dist/chunks/{transform-C2fCVPL_.js → transform-CEK6Ccll.js} +105 -172
- package/.dist/chunks/transform-CEK6Ccll.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/errors.d.ts +0 -15
- package/.dist/generators.d.ts +1 -3
- package/.dist/internal/generators.js +3 -20
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform/constants.d.ts +0 -1
- package/.dist/markup/transform/types.d.ts +0 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +2 -5
- package/.dist/mod.js +3 -4
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/client/query.d.ts +16 -6
- package/.dist/remote/client/types.d.ts +11 -2
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/server.js +1 -1
- package/.dist/runtime/transform.js +26 -57
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +0 -2
- package/.dist/script-transform/types.d.ts +0 -8
- package/.dist/server/effects.d.ts +7 -7
- package/.dist/server/index.d.ts +1 -3
- package/.dist/server/types.d.ts +50 -25
- package/.dist/server/wrappers.d.ts +2 -2
- package/.dist/server.d.ts +2 -2
- package/.dist/server.js +65 -40
- package/.dist/server.js.map +1 -1
- package/package.json +1 -1
- package/.dist/chunks/live-DEmS7qpO.js +0 -103
- package/.dist/chunks/live-DEmS7qpO.js.map +0 -1
- package/.dist/chunks/transform-C2fCVPL_.js.map +0 -1
- package/.dist/internal/generators.js.map +0 -1
- package/.dist/live.d.ts +0 -100
- package/.dist/yieldable.d.ts +0 -41
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors-Bl3NVEez.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\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RuntimeError\";\n\t}\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\treturn `[${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\t/**\n\t * The source filename that triggered this error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly filename: string;\n\n\tconstructor(message: string, filename: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PreprocessError\";\n\t\tthis.filename = filename;\n\t}\n}\n\n/**\n * Retained for compatibility when callers need a structured representation of\n * possible Vite plugin ordering conflicts.\n *\n * @example\n * ```ts\n * throw new VitePreTransformPluginConflictError([\"wuchale\"]);\n * ```\n *\n * @since 2.4.0\n * @param plugin_names - Names of Vite plugins that declare pre-transform\n * priority and may parse raw component files before SER lowers them.\n * @returns A runtime-authored Error describing the possible plugin ordering\n * conflict.\n */\nexport class VitePreTransformPluginConflictError extends RuntimeError {\n\t/**\n\t * Names of conflicting Vite plugins.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly plugin_names: readonly string[];\n\n\tconstructor(plugin_names: readonly string[]) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\t`Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\t\t\"\",\n\t\t\t\t`These plugins run before normal Svelte component transforms:`,\n\t\t\t\t...plugin_names.map((plugin_name) => ` - ${plugin_name}`),\n\t\t\t\t\"\",\n\t\t\t\t`This is usually fine, but if you see Svelte parser errors around <script effect>`,\n\t\t\t\t`or yield* in components, one of those plugins may be reading component files before`,\n\t\t\t\t`SER has lowered its syntax.`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\tthis.name = \"VitePreTransformPluginConflictError\";\n\t\tthis.plugin_names = plugin_names;\n\t}\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\t/**\n\t * The full text of the problematic statement containing mixed async work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly statement_text: string;\n\n\tconstructor(filename: string, statement_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"AWAIT_IN_EFFECT_WORK\",\n\t\t\t\t\t`${filename}: await cannot be mixed with yield* in Effect work.`,\n\t\t\t\t),\n\t\t\t\t`Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic statement:`,\n\t\t\t\tstatement_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AwaitInEffectWorkError\";\n\t\tthis.statement_text = statement_text;\n\t}\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\t/**\n\t * The name of the rune that contained async Effect work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly rune_name: string;\n\n\t/**\n\t * The full text of the expression that triggered the error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(rune_name: string, expression_text: string, filename: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_SYNC_RUNE\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside ${rune_name}().`,\n\t\t\t\t),\n\t\t\t\t`${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInSyncRuneError\";\n\t\tthis.rune_name = rune_name;\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The full text of the problematic event handler body.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n\t\t\t\t),\n\t\t\t\t`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\t\t\t\t\"\",\n\t\t\t\t`Run the remote Effect directly:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Recover from remote failures by composing the Effect value:`,\n\t\t\t\t` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The full text of the problematic event handler callback.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n\t\t\t\t),\n\t\t\t\t`SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n\t\t\t\t\"\",\n\t\t\t\t`Use this form:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Instead of this form:`,\n\t\t\t\t` onclick={() => yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"YieldStarInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The unsupported markup expression text.\n\t *\n\t * @since 2.4.2\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n\t\t\t\t\t`${filename}: yield* cannot be used in this markup position.`,\n\t\t\t\t),\n\t\t\t\t`Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"UnsupportedMarkupEffectPositionError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n\t\t);\n\t\tthis.name = \"RequestEventUnavailableError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n\t\t);\n\t\tthis.name = \"UncheckedQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n\t\t);\n\t\tthis.name = \"BatchQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n\t\t);\n\t\tthis.name = \"UncheckedLiveQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n\t\t);\n\t\tthis.name = \"UncheckedCommandHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n\t\t);\n\t\tthis.name = \"UncheckedFormHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n\t\t);\n\t\tthis.name = \"UncheckedPrerenderHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live handler must return an Effect Stream. Wrap native iterables with Stream.fromIterable, Stream.fromAsyncIterable, or another Stream constructor before returning them.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryReturnError\";\n\t}\n}\n\n/**\n * Thrown when generated component code yields a Stream that completes before\n * producing a value.\n *\n * @example\n * ```ts\n * throw new EmptyStreamYieldError();\n * ```\n *\n * @since 3.4.8\n * @returns An Error describing an empty Stream in a value position.\n */\nexport class EmptyStreamYieldError extends RuntimeError {\n\tconstructor() {\n\t\tsuper(\n\t\t\t\"Cannot resolve yield* stream expression because the Stream completed without emitting a value.\",\n\t\t);\n\t\tthis.name = \"EmptyStreamYieldError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n\t\t);\n\t\tthis.name = \"DispatcherDisposedError\";\n\t}\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n * @returns An Error describing the invalid runtime lifecycle transition.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n\tconstructor(runtime_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"RUNTIME_ALREADY_INITIALIZED\",\n\t\t\t\t`${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RuntimeAlreadyInitializedError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidQueryFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n\t\t);\n\t\tthis.name = \"InvalidCommandFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"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\t\t);\n\t\tthis.name = \"RemoteFormEndpointMissingError\";\n\t}\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\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n\t\t);\n\t\tthis.name = \"InvalidRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\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\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n\t\t);\n\t\tthis.name = \"UnsupportedRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\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\t/**\n\t * Raw serialized remote failure payload that failed decoding.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly raw: unknown;\n\n\tconstructor(raw?: unknown) {\n\t\tsuper(\n\t\t\t\"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n\t\t);\n\t\tthis.name = \"RemoteErrorDecodeError\";\n\t\tthis.raw = raw;\n\t}\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\t/**\n\t * Name of the server-only root export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`${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\t\t);\n\t\tthis.name = \"ServerOnlyImportError\";\n\t\tthis.export_name = export_name;\n\t}\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\t/**\n\t * Name of the `$app/server` export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n\t\t);\n\t\tthis.name = \"SvelteKitServerExportUnavailableError\";\n\t\tthis.export_name = export_name;\n\t}\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\t/**\n\t * SER helper name that triggered the context failure.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly helper_name: string;\n\n\tconstructor(helper_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"REMOTE_HELPER_CONTEXT\",\n\t\t\t\t`${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\t\t\t),\n\t\t);\n\t\tthis.name = \"RemoteHelperContextError\";\n\t\tthis.helper_name = helper_name;\n\t}\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\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n\t\tthis.name = \"RemoteHelperError\";\n\t\tthis.value = value;\n\t}\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\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(String(value));\n\t\tthis.name = \"UnknownRuntimeError\";\n\t\tthis.value = value;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAeA,IAAa,eAAb,cAAkC,MAAM;CACvC,YAAY,SAAiB;EAC5B,MAAM,OAAO;EACb,KAAK,OAAO;CACb;AACD;;;;;;;;;;;;;;AAeA,SAAgB,mBAAmB,MAAc,SAAyB;CACzE,OAAO,IAAI,KAAK,KAAK;AACtB;;;;;;;;;;;;;;;;AAiBA,IAAa,kBAAb,cAAqC,aAAa;;;;;;CAMjD;CAEA,YAAY,SAAiB,UAAkB;EAC9C,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;;;;;;;;;;;;;;;AAiBA,IAAa,sCAAb,cAAyD,aAAa;;;;;;CAMrE;CAEA,YAAY,cAAiC;EAC5C,MACC;GACC;GACA;GACA;GACA,GAAG,aAAa,KAAK,gBAAgB,OAAO,aAAa;GACzD;GACA;GACA;GACA;EACD,CAAC,CAAC,KAAK,IAAI,CACZ;EACA,KAAK,OAAO;EACZ,KAAK,eAAe;CACrB;AACD;;;;;;;;;;;;;;;;AAiBA,IAAa,yBAAb,cAA4C,gBAAgB;;;;;;CAM3D;CAEA,YAAY,UAAkB,gBAAwB;EACrD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AAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;;AAcA,IAAa,oBAAb,cAAuC,aAAa;;;;;;CAMnD;CAEA,YAAY,OAAgB;EAC3B,MAAM,mBAAmB,uBAAuB,OAAO,KAAK,CAAC,CAAC;EAC9D,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD;;;;;;;;;;;;;AAcA,IAAa,sBAAb,cAAyC,aAAa;;;;;;CAMrD;CAEA,YAAY,OAAgB;EAC3B,MAAM,OAAO,KAAK,CAAC;EACnB,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD"}
|
|
1
|
+
{"version":3,"file":"errors-Dcf0MVbq.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\tconstructor(message: string) {\n\t\tsuper(message);\n\t\tthis.name = \"RuntimeError\";\n\t}\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\treturn `[${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\t/**\n\t * The source filename that triggered this error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly filename: string;\n\n\tconstructor(message: string, filename: string) {\n\t\tsuper(message);\n\t\tthis.name = \"PreprocessError\";\n\t\tthis.filename = filename;\n\t}\n}\n\n/**\n * Retained for compatibility when callers need a structured representation of\n * possible Vite plugin ordering conflicts.\n *\n * @example\n * ```ts\n * throw new VitePreTransformPluginConflictError([\"wuchale\"]);\n * ```\n *\n * @since 2.4.0\n * @param plugin_names - Names of Vite plugins that declare pre-transform\n * priority and may parse raw component files before SER lowers them.\n * @returns A runtime-authored Error describing the possible plugin ordering\n * conflict.\n */\nexport class VitePreTransformPluginConflictError extends RuntimeError {\n\t/**\n\t * Names of conflicting Vite plugins.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly plugin_names: readonly string[];\n\n\tconstructor(plugin_names: readonly string[]) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\t`Svelte Effect Runtime noticed possible Vite plugin ordering conflicts.`,\n\t\t\t\t\"\",\n\t\t\t\t`These plugins run before normal Svelte component transforms:`,\n\t\t\t\t...plugin_names.map((plugin_name) => ` - ${plugin_name}`),\n\t\t\t\t\"\",\n\t\t\t\t`This is usually fine, but if you see Svelte parser errors around <script effect>`,\n\t\t\t\t`or yield* in components, one of those plugins may be reading component files before`,\n\t\t\t\t`SER has lowered its syntax.`,\n\t\t\t].join(\"\\n\"),\n\t\t);\n\t\tthis.name = \"VitePreTransformPluginConflictError\";\n\t\tthis.plugin_names = plugin_names;\n\t}\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\t/**\n\t * The full text of the problematic statement containing mixed async work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly statement_text: string;\n\n\tconstructor(filename: string, statement_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"AWAIT_IN_EFFECT_WORK\",\n\t\t\t\t\t`${filename}: await cannot be mixed with yield* in Effect work.`,\n\t\t\t\t),\n\t\t\t\t`Top-level await is supported as ordinary Svelte async rendering, but statements lowered into Effect.gen must use yield* for async Effect work.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic statement:`,\n\t\t\t\tstatement_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AwaitInEffectWorkError\";\n\t\tthis.statement_text = statement_text;\n\t}\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\t/**\n\t * The name of the rune that contained async Effect work.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly rune_name: string;\n\n\t/**\n\t * The full text of the expression that triggered the error.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(rune_name: string, expression_text: string, filename: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_SYNC_RUNE\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside ${rune_name}().`,\n\t\t\t\t),\n\t\t\t\t`${rune_name}() must stay synchronous. Do not put async Effect work inside this rune.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInSyncRuneError\";\n\t\tthis.rune_name = rune_name;\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The full text of the problematic event handler body.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* cannot be used inside a nested non-generator callback in a markup event handler.`,\n\t\t\t\t),\n\t\t\t\t`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\t\t\t\t\"\",\n\t\t\t\t`Run the remote Effect directly:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Recover from remote failures by composing the Effect value:`,\n\t\t\t\t` onclick={yield* UpvotePost(id).pipe(Effect.catch(() => Effect.void))}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"AsyncEffectInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The full text of the problematic event handler callback.\n\t *\n\t * @since 2.0.0\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"ASYNC_EFFECT_IN_EVENT_HANDLER_CALLBACK\",\n\t\t\t\t\t`${filename}: yield* in markup event handlers must be written directly as the event attribute value.`,\n\t\t\t\t),\n\t\t\t\t`SER generates the event callback for effectful event handlers; do not put yield* inside a JavaScript callback.`,\n\t\t\t\t\"\",\n\t\t\t\t`Use this form:`,\n\t\t\t\t` onclick={yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Instead of this form:`,\n\t\t\t\t` onclick={() => yield* UpvotePost(id)}`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"YieldStarInEventCallbackError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\t/**\n\t * The unsupported markup expression text.\n\t *\n\t * @since 2.4.2\n\t */\n\treadonly expression_text: string;\n\n\tconstructor(filename: string, expression_text: string) {\n\t\tsuper(\n\t\t\t[\n\t\t\t\tmake_error_message(\n\t\t\t\t\t\"UNSUPPORTED_MARKUP_EFFECT_POSITION\",\n\t\t\t\t\t`${filename}: yield* cannot be used in this markup position.`,\n\t\t\t\t),\n\t\t\t\t`Move the Effect work into a supported expression tag, block expression, render expression, declaration tag, or event handler.`,\n\t\t\t\t\"\",\n\t\t\t\t`Problematic expression:`,\n\t\t\t\texpression_text,\n\t\t\t].join(\"\\n\"),\n\t\t\tfilename,\n\t\t);\n\t\tthis.name = \"UnsupportedMarkupEffectPositionError\";\n\t\tthis.expression_text = expression_text;\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"RequestEvent is only available while a SER remote handler is executing inside a request-scoped Effect context.\",\n\t\t);\n\t\tthis.name = \"RequestEventUnavailableError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute by itself.\",\n\t\t);\n\t\tthis.name = \"UncheckedQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.batch requires a concrete batch handler function; the batch helper cannot infer a handler from schema metadata alone.\",\n\t\t);\n\t\tthis.name = \"BatchQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Query.live('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce a live source.\",\n\t\t);\n\t\tthis.name = \"UncheckedLiveQueryHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Command('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot execute a command.\",\n\t\t);\n\t\tthis.name = \"UncheckedCommandHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Form('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot process form data.\",\n\t\t);\n\t\tthis.name = \"UncheckedFormHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Prerender('unchecked', handler) requires a concrete handler function as the second argument; the unchecked schema sentinel cannot produce prerendered data.\",\n\t\t);\n\t\tthis.name = \"UncheckedPrerenderHandlerMissingError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"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\t\t);\n\t\tthis.name = \"InvalidLiveQueryReturnError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Dispatcher has been disposed; no new Effect fibers or promise bridges can be started after component teardown.\",\n\t\t);\n\t\tthis.name = \"DispatcherDisposedError\";\n\t}\n}\n\n/**\n * Thrown when an application attempts to configure a runtime after one has\n * already been initialized.\n *\n * @example\n * ```ts\n * throw new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n * ```\n *\n * @since 3.4.0\n * @param runtime_name - Public runtime API that was initialized more than once.\n * @returns An Error describing the invalid runtime lifecycle transition.\n */\nexport class RuntimeAlreadyInitializedError extends RuntimeError {\n\tconstructor(runtime_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"RUNTIME_ALREADY_INITIALIZED\",\n\t\t\t\t`${runtime_name}.make(...) cannot be called because the runtime has already been initialized. Configure it once during application startup, before any Effect-backed component, remote handler, or generated runtime code runs.`,\n\t\t\t),\n\t\t);\n\t\tthis.name = \"RuntimeAlreadyInitializedError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid query factory: expected a function or an object exposing query/load methods from SvelteKit remote query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidQueryFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid live query factory: expected a function or an object exposing a query method from SvelteKit remote live query generation.\",\n\t\t);\n\t\tthis.name = \"InvalidLiveQueryFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"Invalid command factory: expected a function or an object exposing an invoke method from SvelteKit remote command generation.\",\n\t\t);\n\t\tthis.name = \"InvalidCommandFactoryError\";\n\t}\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\tconstructor() {\n\t\tsuper(\n\t\t\t\"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\t\t);\n\t\tthis.name = \"RemoteFormEndpointMissingError\";\n\t}\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\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Invalid remote form response: expected an object envelope with a string type field returned by SvelteKit remote form transport.\",\n\t\t);\n\t\tthis.name = \"InvalidRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\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\t/**\n\t * Raw response envelope returned by the remote form endpoint.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly envelope: unknown;\n\n\tconstructor(envelope?: unknown) {\n\t\tsuper(\n\t\t\t\"Unsupported remote form response: expected a result envelope with a devalue-encoded result or data string.\",\n\t\t);\n\t\tthis.name = \"UnsupportedRemoteFormResponseError\";\n\t\tthis.envelope = envelope;\n\t}\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\t/**\n\t * Raw serialized remote failure payload that failed decoding.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly raw: unknown;\n\n\tconstructor(raw?: unknown) {\n\t\tsuper(\n\t\t\t\"Failed to decode remote error payload: expected a devalue-encoded SER remote failure envelope compatible with the client decoder.\",\n\t\t);\n\t\tthis.name = \"RemoteErrorDecodeError\";\n\t\tthis.raw = raw;\n\t}\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\t/**\n\t * Name of the server-only root export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`${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\t\t);\n\t\tthis.name = \"ServerOnlyImportError\";\n\t\tthis.export_name = export_name;\n\t}\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\t/**\n\t * Name of the `$app/server` export that was invoked.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly export_name: string;\n\n\tconstructor(export_name: string) {\n\t\tsuper(\n\t\t\t`SvelteKit virtual $app/server export ${export_name} is only available inside a SvelteKit server module.`,\n\t\t);\n\t\tthis.name = \"SvelteKitServerExportUnavailableError\";\n\t\tthis.export_name = export_name;\n\t}\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\t/**\n\t * SER helper name that triggered the context failure.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly helper_name: string;\n\n\tconstructor(helper_name: string) {\n\t\tsuper(\n\t\t\tmake_error_message(\n\t\t\t\t\"REMOTE_HELPER_CONTEXT\",\n\t\t\t\t`${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\t\t\t),\n\t\t);\n\t\tthis.name = \"RemoteHelperContextError\";\n\t\tthis.helper_name = helper_name;\n\t}\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\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(make_error_message(\"REMOTE_HELPER_ERROR\", String(value)));\n\t\tthis.name = \"RemoteHelperError\";\n\t\tthis.value = value;\n\t}\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\t/**\n\t * Non-Error value that was normalized.\n\t *\n\t * @since 2.4.0\n\t */\n\treadonly value: unknown;\n\n\tconstructor(value: unknown) {\n\t\tsuper(String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MpE;CAEA,YAAY,UAAoB;EAC/B,MACC,4GACD;EACA,KAAK,OAAO;EACZ,KAAK,WAAW;CACjB;AACD;;;;;;;;;;;;;AAcA,IAAa,yBAAb,cAA4C,aAAa;;;;;;CAMxD;CAEA,YAAY,KAAe;EAC1B,MACC,mIACD;EACA,KAAK,OAAO;EACZ,KAAK,MAAM;CACZ;AACD;;;;;;;;;;;;;AAcA,IAAa,wBAAb,cAA2C,aAAa;;;;;;CAMvD;CAEA,YAAY,aAAqB;EAChC,MACC,GAAG,YAAY,oKAChB;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;;AAcA,IAAa,wCAAb,cAA2D,aAAa;;;;;;CAMvE;CAEA,YAAY,aAAqB;EAChC,MACC,wCAAwC,YAAY,qDACrD;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;;;AAeA,IAAa,2BAAb,cAA8C,aAAa;;;;;;CAM1D;CAEA,YAAY,aAAqB;EAChC,MACC,mBACC,yBACA,GAAG,YAAY,iKAChB,CACD;EACA,KAAK,OAAO;EACZ,KAAK,cAAc;CACpB;AACD;;;;;;;;;;;;;AAcA,IAAa,oBAAb,cAAuC,aAAa;;;;;;CAMnD;CAEA,YAAY,OAAgB;EAC3B,MAAM,mBAAmB,uBAAuB,OAAO,KAAK,CAAC,CAAC;EAC9D,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD;;;;;;;;;;;;;AAcA,IAAa,sBAAb,cAAyC,aAAa;;;;;;CAMrD;CAEA,YAAY,OAAgB;EAC3B,MAAM,OAAO,KAAK,CAAC;EACnB,KAAK,OAAO;EACZ,KAAK,QAAQ;CACd;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as
|
|
2
|
-
import { t as Dispatcher } from "./dispatcher-
|
|
1
|
+
import { _ as RuntimeAlreadyInitializedError, g as RequestEventUnavailableError } from "./errors-Dcf0MVbq.js";
|
|
2
|
+
import { t as Dispatcher } from "./dispatcher-pHH4JcFR.js";
|
|
3
3
|
import { Context, Layer, ManagedRuntime } from "effect";
|
|
4
4
|
//#region src/server/runtime.ts
|
|
5
5
|
/**
|
|
@@ -114,4 +114,4 @@ function reset_server_runtime() {
|
|
|
114
114
|
//#endregion
|
|
115
115
|
export { get_server_runtime_or_throw as i, ServerRuntime as n, get_server_dispatcher as r, RequestEvent as t };
|
|
116
116
|
|
|
117
|
-
//# sourceMappingURL=runtime-
|
|
117
|
+
//# sourceMappingURL=runtime-ekkMQ-wL.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime-
|
|
1
|
+
{"version":3,"file":"runtime-ekkMQ-wL.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import { RequestEventUnavailableError, RuntimeAlreadyInitializedError } from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\ntype ViteImportMeta = ImportMeta & {\n\treadonly env?: {\n\t\treadonly DEV?: boolean;\n\t\treadonly MODE?: string;\n\t\treadonly SSR?: boolean;\n\t};\n};\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends Pick<\n\tSvelteKitRequestEvent,\n\t\"cookies\" | \"getClientAddress\" | \"locals\" | \"params\" | \"platform\" | \"request\" | \"route\" | \"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.Reference<RequestEvent>(\n\t\"@ser/RequestEvent\",\n\t{\n\t\tdefaultValue: () => {\n\t\t\tthrow new RequestEventUnavailableError();\n\t\t},\n\t},\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\t/**\n\t * Build and cache the server-side `ManagedRuntime`.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The configured ManagedRuntime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): ManagedRuntime.ManagedRuntime<R, never> {\n\t\tconst should_replace_dev_runtime =\n\t\t\tcurrent_server_runtime !== undefined && is_vite_dev_ssr();\n\n\t\t/**\n\t\t * Keep duplicate production initialization loud while allowing SvelteKit's\n\t\t * dev server to re-run hooks.server.ts after an HMR invalidation.\n\t\t */\n\t\tif (current_server_runtime && !should_replace_dev_runtime) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n\t\t}\n\n\t\tif (should_replace_dev_runtime) {\n\t\t\treset_server_runtime();\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tcurrent_server_runtime = runtime as ManagedRuntime.ManagedRuntime<unknown, never>;\n\t\tcurrent_server_dispatcher = new InternalDispatcher(\n\t\t\truntime as unknown as ManagedRuntimeType<unknown, unknown>,\n\t\t);\n\n\t\treturn runtime;\n\t}\n}\n\nlet current_server_runtime: ManagedRuntime.ManagedRuntime<unknown, never> | 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<unknown, never> {\n\tif (!current_server_runtime) {\n\t\tcurrent_server_runtime = ManagedRuntime.make(Layer.empty) as ManagedRuntime.ManagedRuntime<\n\t\t\tunknown,\n\t\t\tnever\n\t\t>;\n\t}\n\n\treturn 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\tcurrent_server_dispatcher ??= new InternalDispatcher(\n\t\tget_server_runtime_or_throw() as unknown as ManagedRuntimeType<unknown, unknown>,\n\t);\n\n\treturn current_server_dispatcher;\n}\n\nfunction is_vite_dev_ssr(): boolean {\n\tconst env = (import.meta as ViteImportMeta).env;\n\n\treturn env?.DEV === true && env?.SSR === true && env.MODE !== \"test\";\n}\n\n/**\n * Resets the internal server runtime singleton used by source-level tests.\n *\n * @example\n * ```ts\n * reset_server_runtime();\n * ```\n *\n * @since 3.4.0\n * @returns Nothing.\n * @internal\n */\nexport function reset_server_runtime(): void {\n\tconst dispatcher = current_server_dispatcher;\n\tconst runtime = current_server_runtime;\n\n\tcurrent_server_dispatcher = undefined;\n\tcurrent_server_runtime = undefined;\n\n\tif (dispatcher) {\n\t\tdispatcher.dispose();\n\n\t\treturn;\n\t}\n\n\tvoid runtime?.dispose().catch((error: unknown) => {\n\t\tqueueMicrotask(() => {\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;AAkCA,MAAa,eAAgD,QAAQ,UACpE,qBACA,EACC,oBAAoB;CACnB,MAAM,IAAI,6BAA6B;AACxC,EACD,CACD;;;;;;;;;;;AAYA,IAAa,gBAAb,MAA2B;;;;;;;;CAQ1B,OAAO,KAAgB,OAAiE;EACvF,MAAM,6BACL,2BAA2B,KAAA,KAAa,gBAAgB;;;;;EAMzD,IAAI,0BAA0B,CAAC,4BAC9B,MAAM,IAAI,+BAA+B,eAAe;EAGzD,IAAI,4BACH,qBAAqB;EAGtB,MAAM,UAAU,eAAe,KAAK,SAAU,MAAM,KAAmC;EAEvF,yBAAyB;EACzB,4BAA4B,IAAIA,WAC/B,OACD;EAEA,OAAO;CACR;AACD;AAEA,IAAI;AACJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAA6E;CAC5F,IAAI,CAAC,wBACJ,yBAAyB,eAAe,KAAK,MAAM,KAAK;CAMzD,OAAO;AACR;;;;;;;;;;;;;AAcA,SAAgB,wBAA4C;CAC3D,8BAA8B,IAAIA,WACjC,4BAA4B,CAC7B;CAEA,OAAO;AACR;AAEA,SAAS,kBAA2B;CACnC,MAAM,MAAO,OAAO,KAAwB;CAE5C,OAAO,KAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,IAAI,SAAS;AAC/D;;;;;;;;;;;;;AAcA,SAAgB,uBAA6B;CAC5C,MAAM,aAAa;CACnB,MAAM,UAAU;CAEhB,4BAA4B,KAAA;CAC5B,yBAAyB,KAAA;CAEzB,IAAI,YAAY;EACf,WAAW,QAAQ;EAEnB;CACD;CAEA,SAAc,QAAQ,CAAC,CAAC,OAAO,UAAmB;EACjD,qBAAqB;GACpB,MAAM;EACP,CAAC;CACF,CAAC;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as YieldStarInEventCallbackError, D as UnsupportedMarkupEffectPositionError, n as AsyncEffectInSyncRuneError, t as AsyncEffectInEventCallbackError } from "./errors-Dcf0MVbq.js";
|
|
2
2
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
3
3
|
import ts from "typescript";
|
|
4
4
|
import { parse } from "svelte/compiler";
|
|
@@ -22,37 +22,20 @@ function make_imports(has_effect_import, has_dispatcher_import, has_untrack_impo
|
|
|
22
22
|
dispatcher_value: "__SER___dispatcher",
|
|
23
23
|
effect: "Effect",
|
|
24
24
|
program: "__SER___program",
|
|
25
|
-
untrack: "untrack"
|
|
26
|
-
yield_success: "YieldSuccess",
|
|
27
|
-
yieldable: "ToEffect"
|
|
25
|
+
untrack: "untrack"
|
|
28
26
|
}, options = {}) {
|
|
29
27
|
const needs_dispatcher = options.needs_dispatcher ?? true;
|
|
30
28
|
const needs_effect = options.needs_effect ?? true;
|
|
31
29
|
const needs_untrack = options.needs_untrack ?? true;
|
|
32
|
-
const
|
|
33
|
-
const needs_yieldable = options.needs_yieldable ?? false;
|
|
34
|
-
const generator_import = make_generator_import(bindings, needs_dispatcher && !has_dispatcher_import, needs_yieldable, needs_yield_success);
|
|
30
|
+
const dispatcher_import = bindings.dispatcher === "get_dispatcher" ? `import { get_dispatcher } from "svelte-effect-runtime/internal/generators";` : `import { get_dispatcher as ${bindings.dispatcher} } from "svelte-effect-runtime/internal/generators";`;
|
|
35
31
|
const untrack_import = bindings.untrack === "untrack" ? `import { untrack } from "svelte";` : `import { untrack as ${bindings.untrack} } from "svelte";`;
|
|
36
32
|
const effect_import = has_effect_import ? false : bindings.effect === "Effect" ? `import { Effect } from "effect";` : `import { Effect as ${bindings.effect} } from "effect";`;
|
|
37
33
|
return [
|
|
38
|
-
|
|
34
|
+
needs_dispatcher && !has_dispatcher_import && dispatcher_import,
|
|
39
35
|
needs_untrack && !has_untrack_import && untrack_import,
|
|
40
36
|
needs_effect && effect_import
|
|
41
37
|
].filter(Boolean).join("\n");
|
|
42
38
|
}
|
|
43
|
-
function make_generator_import(bindings, needs_dispatcher, needs_yieldable, needs_yield_success) {
|
|
44
|
-
const specifiers = [
|
|
45
|
-
needs_dispatcher && make_named_import("get_dispatcher", bindings.dispatcher),
|
|
46
|
-
needs_yieldable && make_named_import("ToEffect", bindings.yieldable),
|
|
47
|
-
needs_yield_success && make_named_import("YieldSuccess", bindings.yield_success, true)
|
|
48
|
-
].filter((specifier) => specifier !== false);
|
|
49
|
-
if (specifiers.length === 0) return false;
|
|
50
|
-
return `import { ${specifiers.join(", ")} } from "svelte-effect-runtime/internal/generators";`;
|
|
51
|
-
}
|
|
52
|
-
function make_named_import(imported_name, local_name, type_only = false) {
|
|
53
|
-
const prefix = type_only ? "type " : "";
|
|
54
|
-
return imported_name === local_name ? `${prefix}${imported_name}` : `${prefix}${imported_name} as ${local_name}`;
|
|
55
|
-
}
|
|
56
39
|
/**
|
|
57
40
|
* Checks whether a source file imports a local binding from a module.
|
|
58
41
|
*
|
|
@@ -110,8 +93,7 @@ function collect_binding_name_text(name) {
|
|
|
110
93
|
//#region src/markup/transform/constants.ts
|
|
111
94
|
const HELPERS = {
|
|
112
95
|
codes: "Code",
|
|
113
|
-
dispatcher: "Dispatcher"
|
|
114
|
-
yieldable: "ToEffect"
|
|
96
|
+
dispatcher: "Dispatcher"
|
|
115
97
|
};
|
|
116
98
|
//#endregion
|
|
117
99
|
//#region src/markup/transform/apply.ts
|
|
@@ -162,8 +144,7 @@ function make_markup_helper_bindings(content) {
|
|
|
162
144
|
return {
|
|
163
145
|
bindings: {
|
|
164
146
|
codes: name_allocator.reserve(HELPERS.codes),
|
|
165
|
-
dispatcher: name_allocator.reserve(HELPERS.dispatcher)
|
|
166
|
-
yieldable: name_allocator.reserve(HELPERS.yieldable)
|
|
147
|
+
dispatcher: name_allocator.reserve(HELPERS.dispatcher)
|
|
167
148
|
},
|
|
168
149
|
name_allocator
|
|
169
150
|
};
|
|
@@ -202,7 +183,7 @@ function make_import_helper(content, import_text) {
|
|
|
202
183
|
return import_text;
|
|
203
184
|
}
|
|
204
185
|
function make_dispatcher_import(bindings) {
|
|
205
|
-
return `import { ${make_import_specifier(HELPERS.dispatcher, bindings.dispatcher)}, ${make_import_specifier(HELPERS.codes, bindings.codes)}
|
|
186
|
+
return `import { ${make_import_specifier(HELPERS.dispatcher, bindings.dispatcher)}, ${make_import_specifier(HELPERS.codes, bindings.codes)} } from "svelte-effect-runtime/internal/generators";`;
|
|
206
187
|
}
|
|
207
188
|
function make_import_specifier(imported_name, local_name) {
|
|
208
189
|
if (imported_name === local_name) return imported_name;
|
|
@@ -548,75 +529,6 @@ function is_record(value) {
|
|
|
548
529
|
return typeof value === "object" && value !== null;
|
|
549
530
|
}
|
|
550
531
|
//#endregion
|
|
551
|
-
//#region src/script-transform/ast.ts
|
|
552
|
-
/**
|
|
553
|
-
* Checks whether a node is a `yield*` binary expression.
|
|
554
|
-
*
|
|
555
|
-
* @since 2.0.0
|
|
556
|
-
* @param node - TypeScript AST node to check.
|
|
557
|
-
* @returns Whether the node represents `yield * operand`.
|
|
558
|
-
*/
|
|
559
|
-
function is_yield_star_expression$1(node) {
|
|
560
|
-
return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield";
|
|
561
|
-
}
|
|
562
|
-
/**
|
|
563
|
-
* Checks whether a node owns its own yield semantics.
|
|
564
|
-
*
|
|
565
|
-
* @since 2.0.0
|
|
566
|
-
* @param node - TypeScript AST node to check.
|
|
567
|
-
* @returns Whether traversal should stop at this function boundary.
|
|
568
|
-
*/
|
|
569
|
-
function is_function_boundary_node(node) {
|
|
570
|
-
return ts.isArrowFunction(node) || ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node);
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Returns `true` if the node tree contains a top-level `await`.
|
|
574
|
-
*
|
|
575
|
-
* @since 2.0.0
|
|
576
|
-
* @param node - Root node to search.
|
|
577
|
-
* @returns Whether a top-level await expression was found.
|
|
578
|
-
*/
|
|
579
|
-
function contains_top_level_await(node) {
|
|
580
|
-
if (ts.isAwaitExpression(node)) return true;
|
|
581
|
-
return node.getChildren().some((child) => !is_function_boundary_node(child) && contains_top_level_await(child));
|
|
582
|
-
}
|
|
583
|
-
/**
|
|
584
|
-
* Collects top-level `yield*` nodes under an expression.
|
|
585
|
-
*
|
|
586
|
-
* @since 2.0.0
|
|
587
|
-
* @param node - Root node to search.
|
|
588
|
-
* @param on_found - Callback invoked for each matching yield node.
|
|
589
|
-
* @returns Nothing.
|
|
590
|
-
*/
|
|
591
|
-
function collect_yield_star_nodes(node, on_found) {
|
|
592
|
-
if (is_function_boundary_node(node)) return;
|
|
593
|
-
if (is_yield_star_expression$1(node)) {
|
|
594
|
-
on_found(node);
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
node.forEachChild((child) => {
|
|
598
|
-
collect_yield_star_nodes(child, on_found);
|
|
599
|
-
});
|
|
600
|
-
}
|
|
601
|
-
/**
|
|
602
|
-
* Finds the first top-level `yield*` expression below a node.
|
|
603
|
-
*
|
|
604
|
-
* @since 2.0.0
|
|
605
|
-
* @param node - Root node to search.
|
|
606
|
-
* @param on_found - Callback invoked with the first matching node.
|
|
607
|
-
* @returns Nothing.
|
|
608
|
-
*/
|
|
609
|
-
function find_yield_star_node(node, on_found) {
|
|
610
|
-
if (is_function_boundary_node(node)) return;
|
|
611
|
-
if (is_yield_star_expression$1(node)) {
|
|
612
|
-
on_found(node);
|
|
613
|
-
return;
|
|
614
|
-
}
|
|
615
|
-
node.forEachChild((child) => {
|
|
616
|
-
find_yield_star_node(child, on_found);
|
|
617
|
-
});
|
|
618
|
-
}
|
|
619
|
-
//#endregion
|
|
620
532
|
//#region src/markup/transform/expressions.ts
|
|
621
533
|
/**
|
|
622
534
|
* Strips an event handler arrow function down to its executable body.
|
|
@@ -761,7 +673,7 @@ function add_binding_names(name, locals) {
|
|
|
761
673
|
}
|
|
762
674
|
}
|
|
763
675
|
function visit_event_body(node, context, result) {
|
|
764
|
-
if (is_yield_star_expression(node)) {
|
|
676
|
+
if (is_yield_star_expression$1(node)) {
|
|
765
677
|
if (context === "top_level") result.has_top_level_yield_star = true;
|
|
766
678
|
else if (context === "nested_invalid") result.has_nested_invalid_yield_star = true;
|
|
767
679
|
node.forEachChild((child) => visit_event_body(child, context, result));
|
|
@@ -780,7 +692,7 @@ function is_nested_function_boundary(node) {
|
|
|
780
692
|
function is_generator_function_boundary(node) {
|
|
781
693
|
return (ts.isFunctionExpression(node) || ts.isFunctionDeclaration(node) || ts.isMethodDeclaration(node)) && node.asteriskToken !== void 0;
|
|
782
694
|
}
|
|
783
|
-
function is_yield_star_expression(node) {
|
|
695
|
+
function is_yield_star_expression$1(node) {
|
|
784
696
|
if (ts.isYieldExpression(node)) return node.asteriskToken !== void 0;
|
|
785
697
|
return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield";
|
|
786
698
|
}
|
|
@@ -1041,28 +953,32 @@ function emit_replacement(candidate, kind, effect_context, helper_bindings, name
|
|
|
1041
953
|
let helpers;
|
|
1042
954
|
let relocation;
|
|
1043
955
|
if (kind === "await") {
|
|
1044
|
-
const effect = make_effect_helper(normalized_candidate, helper_name
|
|
956
|
+
const effect = make_effect_helper(normalized_candidate, helper_name);
|
|
1045
957
|
replacement_text = emit_promise_expression(id_text, effect, helper_bindings, "undefined", `{ ssr: "pending" }`);
|
|
1046
958
|
helpers = [...normalized.helpers, effect.helper];
|
|
1047
959
|
} else if (kind === "render") {
|
|
1048
|
-
const effect = make_effect_helper(normalized_candidate, helper_name
|
|
960
|
+
const effect = make_effect_helper(normalized_candidate, helper_name);
|
|
1049
961
|
replacement_text = emit_render_expression(id_text, effect, candidate, helper_bindings, is_server_target);
|
|
1050
962
|
helpers = [...normalized.helpers, effect.helper];
|
|
1051
963
|
} else if (kind === "render_argument") {
|
|
1052
|
-
const effect = make_effect_helper(normalized_candidate, helper_name
|
|
964
|
+
const effect = make_effect_helper(normalized_candidate, helper_name);
|
|
1053
965
|
replacement_text = emit_await_expression(id_text, effect, helper_bindings, server_fallback(is_server_target, "undefined"));
|
|
1054
966
|
helpers = [...normalized.helpers, effect.helper];
|
|
1055
967
|
} else if (kind === "each") {
|
|
1056
|
-
const effect = make_effect_helper(normalized_candidate, helper_name
|
|
968
|
+
const effect = make_effect_helper(normalized_candidate, helper_name);
|
|
1057
969
|
replacement_text = emit_await_expression(id_text, effect, helper_bindings, server_fallback(is_server_target, "[]"));
|
|
1058
970
|
helpers = [...normalized.helpers, effect.helper];
|
|
1059
971
|
} else if (kind === "event") {
|
|
1060
972
|
const event = make_event_handler(normalized_candidate, helper_bindings);
|
|
1061
973
|
replacement_text = event.text;
|
|
1062
974
|
helpers = normalized.helpers;
|
|
1063
|
-
relocation =
|
|
975
|
+
relocation = make_relocation(candidate, replacement_text, {
|
|
976
|
+
originalStart: 0,
|
|
977
|
+
originalEnd: candidate.expr_text.length,
|
|
978
|
+
generatedText: event.expr_text
|
|
979
|
+
});
|
|
1064
980
|
} else {
|
|
1065
|
-
const effect = make_effect_helper(normalized_candidate, helper_name
|
|
981
|
+
const effect = make_effect_helper(normalized_candidate, helper_name);
|
|
1066
982
|
replacement_text = emit_await_expression(id_text, effect, helper_bindings, server_fallback(is_server_target, "undefined"));
|
|
1067
983
|
helpers = [...normalized.helpers, effect.helper];
|
|
1068
984
|
}
|
|
@@ -1078,11 +994,9 @@ function make_event_handler(candidate, helper_bindings) {
|
|
|
1078
994
|
const expr_text = candidate.expr_text;
|
|
1079
995
|
if (is_callback_function_expression(expr_text)) throw new YieldStarInEventCallbackError(candidate.filename, expr_text);
|
|
1080
996
|
if (analyze_event_body_yield_star(expr_text).has_nested_invalid_yield_star) throw new AsyncEffectInEventCallbackError(candidate.filename, expr_text);
|
|
1081
|
-
const wrapped_expr_text = wrap_yield_stars(expr_text, helper_bindings);
|
|
1082
997
|
return {
|
|
1083
|
-
expr_text
|
|
1084
|
-
|
|
1085
|
-
text: `(event) => { ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${wrapped_expr_text}; } }); }`
|
|
998
|
+
expr_text,
|
|
999
|
+
text: `(event) => { ${helper_bindings.dispatcher}.emit({ type: ${helper_bindings.codes}.Markup.Run, fn: function* () { ${expr_text}; } }); }`
|
|
1086
1000
|
};
|
|
1087
1001
|
}
|
|
1088
1002
|
function emit_promise_expression(id_text, effect, helper_bindings, ssr_fallback, options) {
|
|
@@ -1107,91 +1021,41 @@ function emit_await_expression(id_text, effect, helper_bindings, ssr_fallback) {
|
|
|
1107
1021
|
function server_fallback(is_server_target, fallback) {
|
|
1108
1022
|
return is_server_target ? fallback : void 0;
|
|
1109
1023
|
}
|
|
1110
|
-
function make_effect_helper(candidate, helper_name
|
|
1024
|
+
function make_effect_helper(candidate, helper_name) {
|
|
1111
1025
|
const deps = collect_free_identifiers(candidate.expr_text);
|
|
1112
1026
|
const args_text = deps.join(", ");
|
|
1113
1027
|
const deps_text = deps.length === 0 ? "[]" : `[${args_text}]`;
|
|
1114
1028
|
const call = `${helper_name}()`;
|
|
1115
|
-
const
|
|
1116
|
-
const
|
|
1117
|
-
const generated_start = text.indexOf(effect_text);
|
|
1118
|
-
const relocation = make_yield_operand_relocation(candidate.expr_text, effect_text, helper_bindings) ?? {
|
|
1119
|
-
originalStart: 0,
|
|
1120
|
-
originalEnd: candidate.expr_text.length,
|
|
1121
|
-
generatedStart: 0,
|
|
1122
|
-
generatedEnd: effect_text.length
|
|
1123
|
-
};
|
|
1029
|
+
const text = `function* ${helper_name}() { return (${candidate.expr_text}); }`;
|
|
1030
|
+
const generated_start = text.indexOf(candidate.expr_text);
|
|
1124
1031
|
return {
|
|
1125
1032
|
call,
|
|
1126
1033
|
deps_text,
|
|
1127
1034
|
helper: {
|
|
1128
1035
|
text,
|
|
1129
1036
|
relocation: {
|
|
1130
|
-
originalStart: candidate.start
|
|
1131
|
-
originalEnd: candidate.
|
|
1132
|
-
generatedStartInReplacement: generated_start
|
|
1133
|
-
generatedEndInReplacement: generated_start +
|
|
1037
|
+
originalStart: candidate.start,
|
|
1038
|
+
originalEnd: candidate.end,
|
|
1039
|
+
generatedStartInReplacement: generated_start,
|
|
1040
|
+
generatedEndInReplacement: generated_start + candidate.expr_text.length
|
|
1134
1041
|
}
|
|
1135
1042
|
}
|
|
1136
1043
|
};
|
|
1137
1044
|
}
|
|
1138
|
-
function wrap_yield_stars(text, helper_bindings) {
|
|
1139
|
-
const source_file = ts.createSourceFile("markup-yield.ts", text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
1140
|
-
const replacements = [];
|
|
1141
|
-
collect_yield_star_nodes(source_file, (node) => {
|
|
1142
|
-
const yield_text = text.slice(node.getStart(source_file), node.end).trim();
|
|
1143
|
-
replacements.push({
|
|
1144
|
-
start: node.getStart(source_file),
|
|
1145
|
-
end: node.end,
|
|
1146
|
-
text: `yield* ${helper_bindings.yieldable}(${strip_yield_star(yield_text)})`
|
|
1147
|
-
});
|
|
1148
|
-
});
|
|
1149
|
-
if (replacements.length === 0) return text;
|
|
1150
|
-
replacements.sort((a, b) => b.start - a.start);
|
|
1151
|
-
let output = text;
|
|
1152
|
-
for (const replacement of replacements) output = output.slice(0, replacement.start) + replacement.text + output.slice(replacement.end);
|
|
1153
|
-
return output;
|
|
1154
|
-
}
|
|
1155
|
-
function strip_yield_star(yield_text) {
|
|
1156
|
-
return yield_text.replace(/^yield\s*\*\s*/, "");
|
|
1157
|
-
}
|
|
1158
|
-
function make_yield_operand_relocation(original_text, generated_text, helper_bindings) {
|
|
1159
|
-
const source_file = ts.createSourceFile("markup-yield-relocation.ts", original_text, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
1160
|
-
let yield_node;
|
|
1161
|
-
collect_yield_star_nodes(source_file, (node) => {
|
|
1162
|
-
yield_node ??= node;
|
|
1163
|
-
});
|
|
1164
|
-
if (!yield_node || !ts.isBinaryExpression(yield_node)) return;
|
|
1165
|
-
const operand = yield_node.right;
|
|
1166
|
-
const original_start = operand.getStart(source_file);
|
|
1167
|
-
const original_end = operand.end;
|
|
1168
|
-
const operand_text = original_text.slice(original_start, original_end).trim();
|
|
1169
|
-
const wrapper_text = `${helper_bindings.yieldable}(${operand_text})`;
|
|
1170
|
-
const wrapper_start = generated_text.indexOf(wrapper_text);
|
|
1171
|
-
if (wrapper_start === -1) return;
|
|
1172
|
-
const generated_start = wrapper_start + wrapper_text.indexOf(operand_text);
|
|
1173
|
-
return {
|
|
1174
|
-
originalStart: original_start,
|
|
1175
|
-
originalEnd: original_end,
|
|
1176
|
-
generatedStart: generated_start,
|
|
1177
|
-
generatedEnd: generated_start + operand_text.length
|
|
1178
|
-
};
|
|
1179
|
-
}
|
|
1180
1045
|
function make_cache_id(candidate) {
|
|
1181
1046
|
return `${candidate.filename.replace(/[?#].*$/, "")}:${candidate.start}:${candidate.end}`;
|
|
1182
1047
|
}
|
|
1183
1048
|
function make_helper_name(candidate, name_allocator) {
|
|
1184
1049
|
return name_allocator.reserve(`__SER___markup_effect_${candidate.start}_${candidate.end}`);
|
|
1185
1050
|
}
|
|
1186
|
-
function
|
|
1187
|
-
|
|
1188
|
-
const generated_start = replacement_text.indexOf(expression_text);
|
|
1051
|
+
function make_relocation(candidate, replacement_text, inner) {
|
|
1052
|
+
const generated_start = replacement_text.indexOf(inner.generatedText);
|
|
1189
1053
|
if (generated_start === -1) return;
|
|
1190
1054
|
return {
|
|
1191
|
-
originalStart: candidate.start +
|
|
1192
|
-
originalEnd: candidate.start +
|
|
1193
|
-
generatedStartInReplacement: generated_start
|
|
1194
|
-
generatedEndInReplacement: generated_start +
|
|
1055
|
+
originalStart: candidate.start + inner.originalStart,
|
|
1056
|
+
originalEnd: candidate.start + inner.originalEnd,
|
|
1057
|
+
generatedStartInReplacement: generated_start,
|
|
1058
|
+
generatedEndInReplacement: generated_start + inner.generatedText.length
|
|
1195
1059
|
};
|
|
1196
1060
|
}
|
|
1197
1061
|
//#endregion
|
|
@@ -1291,6 +1155,75 @@ function is_rune_root(name) {
|
|
|
1291
1155
|
return name === "$bindable" || name === "$derived" || name === "$effect" || name === "$host" || name === "$inspect" || name === "$props" || name === "$state";
|
|
1292
1156
|
}
|
|
1293
1157
|
//#endregion
|
|
1158
|
+
//#region src/script-transform/ast.ts
|
|
1159
|
+
/**
|
|
1160
|
+
* Checks whether a node is a `yield*` binary expression.
|
|
1161
|
+
*
|
|
1162
|
+
* @since 2.0.0
|
|
1163
|
+
* @param node - TypeScript AST node to check.
|
|
1164
|
+
* @returns Whether the node represents `yield * operand`.
|
|
1165
|
+
*/
|
|
1166
|
+
function is_yield_star_expression(node) {
|
|
1167
|
+
return ts.isBinaryExpression(node) && node.operatorToken.kind === ts.SyntaxKind.AsteriskToken && ts.isIdentifier(node.left) && node.left.text === "yield";
|
|
1168
|
+
}
|
|
1169
|
+
/**
|
|
1170
|
+
* Checks whether a node owns its own yield semantics.
|
|
1171
|
+
*
|
|
1172
|
+
* @since 2.0.0
|
|
1173
|
+
* @param node - TypeScript AST node to check.
|
|
1174
|
+
* @returns Whether traversal should stop at this function boundary.
|
|
1175
|
+
*/
|
|
1176
|
+
function is_function_boundary_node(node) {
|
|
1177
|
+
return ts.isArrowFunction(node) || ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node) || ts.isMethodDeclaration(node) || ts.isGetAccessorDeclaration(node) || ts.isSetAccessorDeclaration(node);
|
|
1178
|
+
}
|
|
1179
|
+
/**
|
|
1180
|
+
* Returns `true` if the node tree contains a top-level `await`.
|
|
1181
|
+
*
|
|
1182
|
+
* @since 2.0.0
|
|
1183
|
+
* @param node - Root node to search.
|
|
1184
|
+
* @returns Whether a top-level await expression was found.
|
|
1185
|
+
*/
|
|
1186
|
+
function contains_top_level_await(node) {
|
|
1187
|
+
if (ts.isAwaitExpression(node)) return true;
|
|
1188
|
+
return node.getChildren().some((child) => !is_function_boundary_node(child) && contains_top_level_await(child));
|
|
1189
|
+
}
|
|
1190
|
+
/**
|
|
1191
|
+
* Collects top-level `yield*` nodes under an expression.
|
|
1192
|
+
*
|
|
1193
|
+
* @since 2.0.0
|
|
1194
|
+
* @param node - Root node to search.
|
|
1195
|
+
* @param on_found - Callback invoked for each matching yield node.
|
|
1196
|
+
* @returns Nothing.
|
|
1197
|
+
*/
|
|
1198
|
+
function collect_yield_star_nodes(node, on_found) {
|
|
1199
|
+
if (is_function_boundary_node(node)) return;
|
|
1200
|
+
if (is_yield_star_expression(node)) {
|
|
1201
|
+
on_found(node);
|
|
1202
|
+
return;
|
|
1203
|
+
}
|
|
1204
|
+
node.forEachChild((child) => {
|
|
1205
|
+
collect_yield_star_nodes(child, on_found);
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Finds the first top-level `yield*` expression below a node.
|
|
1210
|
+
*
|
|
1211
|
+
* @since 2.0.0
|
|
1212
|
+
* @param node - Root node to search.
|
|
1213
|
+
* @param on_found - Callback invoked with the first matching node.
|
|
1214
|
+
* @returns Nothing.
|
|
1215
|
+
*/
|
|
1216
|
+
function find_yield_star_node(node, on_found) {
|
|
1217
|
+
if (is_function_boundary_node(node)) return;
|
|
1218
|
+
if (is_yield_star_expression(node)) {
|
|
1219
|
+
on_found(node);
|
|
1220
|
+
return;
|
|
1221
|
+
}
|
|
1222
|
+
node.forEachChild((child) => {
|
|
1223
|
+
find_yield_star_node(child, on_found);
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
//#endregion
|
|
1294
1227
|
//#region src/markup/transform/scan.ts
|
|
1295
1228
|
/**
|
|
1296
1229
|
* Replaces markup `yield*` expressions with placeholders before Svelte parses
|
|
@@ -1711,6 +1644,6 @@ function transform_markup_effect(content, filename, options = {}) {
|
|
|
1711
1644
|
};
|
|
1712
1645
|
}
|
|
1713
1646
|
//#endregion
|
|
1714
|
-
export {
|
|
1647
|
+
export { is_yield_star_expression as a, slice as c, collect_top_level_binding_names as d, has_local_import_binding as f, find_yield_star_node as i, slice_start as l, collect_yield_star_nodes as n, validate_rune_yield_usage as o, make_imports as p, contains_top_level_await as r, create_source_map as s, transform_markup_effect as t, collect_free_identifiers as u };
|
|
1715
1648
|
|
|
1716
|
-
//# sourceMappingURL=transform-
|
|
1649
|
+
//# sourceMappingURL=transform-CEK6Ccll.js.map
|