svelte-effect-runtime 3.4.0 → 3.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.dist/chunks/{client-i7LwWCpT.js → client-7MXXouwb.js} +3 -3
  2. package/.dist/chunks/client-7MXXouwb.js.map +1 -0
  3. package/.dist/chunks/descriptors-OS4VfJuW.js.map +1 -1
  4. package/.dist/chunks/{dispatcher-BX6J0tQV.js → dispatcher-KxyCmCbv.js} +3 -3
  5. package/.dist/chunks/dispatcher-KxyCmCbv.js.map +1 -0
  6. package/.dist/chunks/{dispatcher-D9PG87PW.js → dispatcher-s46GfT6n.js} +2 -2
  7. package/.dist/chunks/dispatcher-s46GfT6n.js.map +1 -0
  8. package/.dist/chunks/{errors-Buz9cLGF.js → errors-0PaWf7Bq.js} +12 -9
  9. package/.dist/chunks/errors-0PaWf7Bq.js.map +1 -0
  10. package/.dist/chunks/{runtime-L7xbXCiW.js → runtime-BXbxv4Ai.js} +3 -3
  11. package/.dist/chunks/{runtime-L7xbXCiW.js.map → runtime-BXbxv4Ai.js.map} +1 -1
  12. package/.dist/chunks/{transform-B5T5TUcJ.js → transform-Cdsx7ygD.js} +2 -2
  13. package/.dist/chunks/transform-Cdsx7ygD.js.map +1 -0
  14. package/.dist/chunks/{vite-DiAwz7jc.js → vite-DTeo70MK.js} +17 -3
  15. package/.dist/chunks/vite-DTeo70MK.js.map +1 -0
  16. package/.dist/detect.js.map +1 -1
  17. package/.dist/dispatcher.js +1 -1
  18. package/.dist/errors.d.ts +4 -3
  19. package/.dist/internal/generators.js +2 -2
  20. package/.dist/internal/remote-client.js +1 -1
  21. package/.dist/markup/promise.js +1 -1
  22. package/.dist/markup/promise.js.map +1 -1
  23. package/.dist/markup/run.js +1 -1
  24. package/.dist/markup/run.js.map +1 -1
  25. package/.dist/markup/transform.js +1 -1
  26. package/.dist/markup/value.js +1 -1
  27. package/.dist/markup/value.js.map +1 -1
  28. package/.dist/mod.js +3 -3
  29. package/.dist/mod.js.map +1 -1
  30. package/.dist/remote/client.js +1 -1
  31. package/.dist/remote/server.js +1 -1
  32. package/.dist/remote/server.js.map +1 -1
  33. package/.dist/remote/shared.js.map +1 -1
  34. package/.dist/runtime/transform.js +2 -2
  35. package/.dist/runtime/transform.js.map +1 -1
  36. package/.dist/server.js +2 -2
  37. package/.dist/server.js.map +1 -1
  38. package/.dist/vite.js +1 -1
  39. package/README.md +5 -5
  40. package/package.json +1 -1
  41. package/.dist/chunks/client-i7LwWCpT.js.map +0 -1
  42. package/.dist/chunks/dispatcher-BX6J0tQV.js.map +0 -1
  43. package/.dist/chunks/dispatcher-D9PG87PW.js.map +0 -1
  44. package/.dist/chunks/errors-Buz9cLGF.js.map +0 -1
  45. package/.dist/chunks/transform-B5T5TUcJ.js.map +0 -1
  46. package/.dist/chunks/vite-DiAwz7jc.js.map +0 -1
package/.dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\r\nimport { ServerOnlyImportError } from \"$/errors.ts\";\r\nimport type {\r\n ErrorEffectFactory,\r\n RedirectEffectFactory,\r\n} from \"$/server/control-flow.ts\";\r\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\r\nimport type {\r\n CommandFactory,\r\n FormFactory,\r\n PrerenderFactory,\r\n QueryFactory,\r\n ServerRuntimeFactory,\r\n} from \"$/server/types.ts\";\r\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\r\n\r\n/**\r\n * Public API surface for `svelte-effect-runtime`.\r\n *\r\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\r\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\r\n * route server-only helpers to the server entrypoint automatically.\r\n *\r\n * @module\r\n */\r\n\r\n/**\r\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\r\n * in `hooks.client.ts` to provide services to every component's effect\r\n * blocks.\r\n *\r\n * If never called, a default empty-layer runtime is created lazily on\r\n * the first `yield*` expression.\r\n *\r\n * @example\r\n * ```ts\r\n * import { ClientRuntime } from \"svelte-effect-runtime\";\r\n * import { Db } from \"./db.ts\";\r\n *\r\n * ClientRuntime.make(Db.Live);\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport class ClientRuntime {\r\n /**\r\n * Build and cache the client-side dispatcher runtime.\r\n *\r\n * @since 2.0.0\r\n * @param layer - Optional Effect layer to provide to the runtime.\r\n */\r\n static make<R = never>(layer?: Layer.Layer<R>): void {\r\n InternalDispatcher.make(layer);\r\n }\r\n}\r\n\r\n/**\r\n * Server-side runtime singleton export. In SvelteKit server files the Vite\r\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\r\n * name resolves to the real server implementation before it is evaluated.\r\n *\r\n * @example\r\n * ```ts\r\n * import { ServerRuntime } from \"svelte-effect-runtime\";\r\n *\r\n * ServerRuntime.make();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\r\n \"ServerRuntime\",\r\n) as never;\r\n\r\n/**\r\n * Remote query factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Query } from \"svelte-effect-runtime\";\r\n *\r\n * export const GetPosts = Query(Effect.succeed([]));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Query: QueryFactory = Object.assign(\r\n make_server_only_function(\"Query\"),\r\n {\r\n batch: make_server_only_function(\"Query.batch\"),\r\n live: make_server_only_function(\"Query.live\"),\r\n },\r\n) as never;\r\n\r\n/**\r\n * Remote command factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Command } from \"svelte-effect-runtime\";\r\n *\r\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Command: CommandFactory = make_server_only_function(\r\n \"Command\",\r\n) as never;\r\n\r\n/**\r\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\r\n * from the root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Error } from \"svelte-effect-runtime\";\r\n *\r\n * return yield* Error(\"NotFound\", \"Post not found\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport const Error: ErrorEffectFactory = make_server_only_function(\r\n \"Error\",\r\n) as never;\r\n\r\n/**\r\n * Remote form factory export for `.remote.ts` files imported from the root\r\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Form } from \"svelte-effect-runtime\";\r\n *\r\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Form: FormFactory = make_server_only_function(\r\n \"Form\",\r\n) as never;\r\n\r\n/**\r\n * Remote prerender factory export for `.remote.ts` files imported from the\r\n * root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Prerender } from \"svelte-effect-runtime\";\r\n *\r\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const Prerender: PrerenderFactory = make_server_only_function(\r\n \"Prerender\",\r\n) as never;\r\n\r\n/**\r\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\r\n * the root entrypoint. The Vite plugin rewrites it to the real server\r\n * implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { Redirect } from \"svelte-effect-runtime\";\r\n *\r\n * return yield* Redirect(\"SeeOther\", \"/posts\");\r\n * ```\r\n *\r\n * @since 2.3.0\r\n */\r\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\r\n \"Redirect\",\r\n) as never;\r\n\r\n/**\r\n * Current SvelteKit request event service export for `.remote.ts` files\r\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\r\n * server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { RequestEvent } from \"svelte-effect-runtime\";\r\n *\r\n * const event = yield* RequestEvent;\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const RequestEvent: Context.Reference<RequestEventShape> =\r\n make_server_only_function(\"RequestEvent\") as never;\r\n\r\n/**\r\n * Returns the active server runtime when imported from a server file. The Vite\r\n * plugin rewrites root imports to the real server implementation.\r\n *\r\n * @example\r\n * ```ts\r\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\r\n *\r\n * const runtime = get_server_runtime_or_throw();\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\r\n unknown,\r\n never\r\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\r\n\r\n/** Re-export error types users need for typed catch handlers. */\r\nexport type {\r\n FormError,\r\n FormIssue,\r\n RemoteFailure,\r\n RemoteHttpError,\r\n RemoteTransportError,\r\n RemoteValidationError,\r\n} from \"$/remote/shared.ts\";\r\n\r\nexport {\r\n AsyncEffectInEventCallbackError,\r\n AsyncEffectInSyncRuneError,\r\n AwaitInEffectWorkError,\r\n BatchQueryHandlerMissingError,\r\n DispatcherDisposedError,\r\n InvalidCommandFactoryError,\r\n InvalidLiveQueryFactoryError,\r\n InvalidLiveQueryReturnError,\r\n InvalidQueryFactoryError,\r\n InvalidRemoteFormResponseError,\r\n PreprocessError,\r\n RemoteErrorDecodeError,\r\n RemoteFormEndpointMissingError,\r\n RemoteHelperContextError,\r\n RemoteHelperError,\r\n RequestEventUnavailableError,\r\n RuntimeAlreadyInitializedError,\r\n RuntimeError,\r\n ServerOnlyImportError,\r\n SvelteKitServerExportUnavailableError,\r\n UncheckedCommandHandlerMissingError,\r\n UncheckedFormHandlerMissingError,\r\n UncheckedLiveQueryHandlerMissingError,\r\n UncheckedPrerenderHandlerMissingError,\r\n UncheckedQueryHandlerMissingError,\r\n UnknownRuntimeError,\r\n UnsupportedMarkupEffectPositionError,\r\n UnsupportedRemoteFormResponseError,\r\n VitePreTransformPluginConflictError,\r\n YieldStarInEventCallbackError,\r\n} from \"$/errors.ts\";\r\n\r\nexport {\r\n is_form_error,\r\n is_remote_http_error,\r\n is_remote_transport_error,\r\n is_remote_validation_error,\r\n} from \"$/remote/shared.ts\";\r\n\r\n/** Re-export app setup helpers so users can import them from root. */\r\nexport { effect, type EffectOptions } from \"$/vite.ts\";\r\n\r\n/** Re-export server helper types from the root entrypoint. */\r\nexport type {\r\n ErrorEffectFactory,\r\n ErrorStatus,\r\n ErrorStatusName,\r\n RedirectEffectFactory,\r\n RedirectStatus,\r\n RedirectStatusName,\r\n} from \"$/server/control-flow.ts\";\r\n\r\n/** Re-export server helper types from the root entrypoint. */\r\nexport type {\r\n CommandFactory,\r\n EffectLike,\r\n EffectRemoteBatchHandler,\r\n EffectRemoteCommand,\r\n EffectRemoteForm,\r\n EffectRemoteFunction,\r\n EffectRemoteLiveQuery,\r\n EffectRemoteLiveQueryFunction,\r\n EffectRemoteLiveQueryResource,\r\n EffectRemoteLiveSource,\r\n EffectRemoteQuery,\r\n EffectRemoteQueryFunction,\r\n FormFactory,\r\n FormInvalid,\r\n PrerenderFactory,\r\n PrerenderOptions,\r\n QueryBatchFactory,\r\n QueryFactory,\r\n QueryLiveFactory,\r\n RemoteFormHandler,\r\n RemoteHandler,\r\n RemoteLiveHandler,\r\n SchemaEncodedInput,\r\n SchemaInput,\r\n ServerRuntimeFactory,\r\n StandardSchema,\r\n StandardSchemaInput,\r\n StandardSchemaOutput,\r\n} from \"$/server/types.ts\";\r\n\r\nfunction make_server_only_class(name: string): unknown {\r\n return class ServerOnlyRuntime {\r\n static make(): never {\r\n throw make_server_only_error(name);\r\n }\r\n };\r\n}\r\n\r\nfunction make_server_only_function(\r\n name: string,\r\n): (...args: unknown[]) => never {\r\n return (..._args: unknown[]): never => {\r\n throw make_server_only_error(name);\r\n };\r\n}\r\n\r\nfunction make_server_only_error(name: string): globalThis.Error {\r\n return new ServerOnlyImportError(name);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;AAiG3D,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,sBAAsB,IAAI;AACvC"}
1
+ {"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\nimport type {\n ErrorEffectFactory,\n RedirectEffectFactory,\n} from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport type {\n CommandFactory,\n FormFactory,\n PrerenderFactory,\n QueryFactory,\n ServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n /**\n * Build and cache the client-side dispatcher runtime.\n *\n * @since 2.0.0\n * @param layer - Optional Effect layer to provide to the runtime.\n */\n static make<R = never>(layer?: Layer.Layer<R>): void {\n InternalDispatcher.make(layer);\n }\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\n \"ServerRuntime\",\n) as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(\n make_server_only_function(\"Query\"),\n {\n batch: make_server_only_function(\"Query.batch\"),\n live: make_server_only_function(\"Query.live\"),\n },\n) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\n \"Command\",\n) as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\n \"Error\",\n) as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\n \"Form\",\n) as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\n \"Prerender\",\n) as never;\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\n \"Redirect\",\n) as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> =\n make_server_only_function(\"RequestEvent\") as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<\n unknown,\n never\n> = make_server_only_function(\"get_server_runtime_or_throw\") as never;\n\n/** Re-export error types users need for typed catch handlers. */\nexport type {\n FormError,\n FormIssue,\n RemoteFailure,\n RemoteHttpError,\n RemoteTransportError,\n RemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n AsyncEffectInEventCallbackError,\n AsyncEffectInSyncRuneError,\n AwaitInEffectWorkError,\n BatchQueryHandlerMissingError,\n DispatcherDisposedError,\n InvalidCommandFactoryError,\n InvalidLiveQueryFactoryError,\n InvalidLiveQueryReturnError,\n InvalidQueryFactoryError,\n InvalidRemoteFormResponseError,\n PreprocessError,\n RemoteErrorDecodeError,\n RemoteFormEndpointMissingError,\n RemoteHelperContextError,\n RemoteHelperError,\n RequestEventUnavailableError,\n RuntimeAlreadyInitializedError,\n RuntimeError,\n ServerOnlyImportError,\n SvelteKitServerExportUnavailableError,\n UncheckedCommandHandlerMissingError,\n UncheckedFormHandlerMissingError,\n UncheckedLiveQueryHandlerMissingError,\n UncheckedPrerenderHandlerMissingError,\n UncheckedQueryHandlerMissingError,\n UnknownRuntimeError,\n UnsupportedMarkupEffectPositionError,\n UnsupportedRemoteFormResponseError,\n VitePreTransformPluginConflictError,\n YieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n is_form_error,\n is_remote_http_error,\n is_remote_transport_error,\n is_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\n/** Re-export app setup helpers so users can import them from root. */\nexport { effect, type EffectOptions } from \"$/vite.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n ErrorEffectFactory,\n ErrorStatus,\n ErrorStatusName,\n RedirectEffectFactory,\n RedirectStatus,\n RedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\n/** Re-export server helper types from the root entrypoint. */\nexport type {\n CommandFactory,\n EffectLike,\n EffectRemoteBatchHandler,\n EffectRemoteCommand,\n EffectRemoteForm,\n EffectRemoteFunction,\n EffectRemoteLiveQuery,\n EffectRemoteLiveQueryFunction,\n EffectRemoteLiveQueryResource,\n EffectRemoteLiveSource,\n EffectRemoteQuery,\n EffectRemoteQueryFunction,\n FormFactory,\n FormInvalid,\n PrerenderFactory,\n PrerenderOptions,\n QueryBatchFactory,\n QueryFactory,\n QueryLiveFactory,\n RemoteFormHandler,\n RemoteHandler,\n RemoteLiveHandler,\n SchemaEncodedInput,\n SchemaInput,\n ServerRuntimeFactory,\n StandardSchema,\n StandardSchemaInput,\n StandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n return class ServerOnlyRuntime {\n static make(): never {\n throw make_server_only_error(name);\n }\n };\n}\n\nfunction make_server_only_function(\n name: string,\n): (...args: unknown[]) => never {\n return (..._args: unknown[]): never => {\n throw make_server_only_error(name);\n };\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n return new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,IAAa,gBAAb,MAA2B;;;;;;;CAOzB,OAAO,KAAgB,OAA8B;EACnD,WAAmB,KAAK,KAAK;CAC/B;AACF;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBACjD,eACF;;;;;;;;;;;;;;AAeA,MAAa,QAAsB,OAAO,OACxC,0BAA0B,OAAO,GACjC;CACE,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC9C,CACF;;;;;;;;;;;;;;AAeA,MAAa,UAA0B,0BACrC,SACF;;;;;;;;;;;;;;;AAgBA,MAAa,QAA4B,0BACvC,OACF;;;;;;;;;;;;;;AAeA,MAAa,OAAoB,0BAC/B,MACF;;;;;;;;;;;;;;;AAgBA,MAAa,YAA8B,0BACzC,WACF;;;;;;;;;;;;;;;AAgBA,MAAa,WAAkC,0BAC7C,UACF;;;;;;;;;;;;;;;AAgBA,MAAa,eACX,0BAA0B,cAAc;;;;;;;;;;;;;;AAe1C,MAAa,8BAGT,0BAA0B,6BAA6B;AAiG3D,SAAS,uBAAuB,MAAuB;CACrD,OAAO,MAAM,kBAAkB;EAC7B,OAAO,OAAc;GACnB,MAAM,uBAAuB,IAAI;EACnC;CACF;AACF;AAEA,SAAS,0BACP,MAC+B;CAC/B,QAAQ,GAAG,UAA4B;EACrC,MAAM,uBAAuB,IAAI;CACnC;AACF;AAEA,SAAS,uBAAuB,MAAgC;CAC9D,OAAO,IAAI,sBAAsB,IAAI;AACvC"}
@@ -1,2 +1,2 @@
1
- import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-i7LwWCpT.js";
1
+ import { i as create_remote_command_adapter, n as create_remote_query_adapter, r as create_remote_form_adapter, t as create_remote_live_query_adapter } from "../chunks/client-7MXXouwb.js";
2
2
  export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_query_adapter };
@@ -1,4 +1,4 @@
1
- import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-Buz9cLGF.js";
1
+ import { h as RemoteHelperError, m as RemoteHelperContextError } from "../chunks/errors-0PaWf7Bq.js";
2
2
  import { create_serialized_remote_failure_envelope } from "./shared.js";
3
3
  import { Cause, Effect, Exit } from "effect";
4
4
  import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\r\nimport type { FormIssue } from \"$/remote/shared.ts\";\r\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\r\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\r\nimport { Cause, Effect, Exit } from \"effect\";\r\nimport { stringify } from \"devalue\";\r\n\r\ntype CauseReason = {\r\n readonly _tag: string;\r\n readonly defect?: unknown;\r\n readonly error?: unknown;\r\n};\r\n\r\n/**\r\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\r\n * exit into the shape expected by SvelteKit, and returns the result or\r\n * throws a SvelteKit-compatible error.\r\n *\r\n * @since 2.0.0\r\n * @param effect - The Effect program to execute.\r\n * @param runtime - The server-side ManagedRuntime.\r\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\r\n * @param error - SvelteKit's `error` helper.\r\n * @returns A Promise that resolves with the effect's success value.\r\n * @internal\r\n */\r\nexport async function run_remote_effect<A>(\r\n effect: Effect.Effect<A, unknown, unknown>,\r\n runtime: {\r\n runPromise: (\r\n e: Effect.Effect<unknown, unknown, unknown>,\r\n ) => Promise<unknown>;\r\n },\r\n invalid: (status: number, body: unknown) => never,\r\n error: (status: number, body: unknown) => never,\r\n): Promise<A> {\r\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\r\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\r\n ) as Exit.Exit<A, unknown>;\r\n\r\n if (Exit.isSuccess(exit)) {\r\n return exit.value;\r\n }\r\n\r\n handle_failure(exit.cause, invalid, error);\r\n}\r\n\r\n/**\r\n * Inspects the Effect Cause for failures and either throws a form\r\n * validation error (via SvelteKit's `invalid`) or encodes the error\r\n * and throws it via SvelteKit's `error`.\r\n */\r\nfunction handle_failure(\r\n cause: Cause.Cause<unknown>,\r\n invalid: (status: number, body: unknown) => never,\r\n error: (status: number, body: unknown) => never,\r\n): never {\r\n const reasons = get_cause_reasons(cause);\r\n\r\n /**\r\n * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\r\n */\r\n for (const reason of reasons) {\r\n if (!Cause.isDieReason(reason as never)) {\r\n continue;\r\n }\r\n\r\n const defect = reason.defect;\r\n\r\n if (is_sveltekit_control_flow(defect)) {\r\n throw defect;\r\n }\r\n }\r\n\r\n /**\r\n * Phase 2 — let cancellation escape without becoming a remote failure.\r\n */\r\n if (Cause.hasInterruptsOnly(cause)) {\r\n throw Cause.squash(cause);\r\n }\r\n\r\n /**\r\n * Phase 3 — preserve typed form validation failures.\r\n */\r\n for (const reason of reasons) {\r\n if (Cause.isFailReason(reason as never)) {\r\n const failure = reason.error;\r\n if (\r\n typeof failure === \"object\" &&\r\n failure !== null &&\r\n (failure as Record<string, unknown>)._tag === \"FormError\"\r\n ) {\r\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\r\n [];\r\n invalid(400, { issues });\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * Phase 4 — encode all other failures for the remote client.\r\n */\r\n const encoded = encode_remote_failure(cause);\r\n const envelope = create_serialized_remote_failure_envelope(encoded);\r\n\r\n error(500, envelope);\r\n}\r\n\r\n/**\r\n * Encodes an Effect Cause into a string that the client-side adapter can\r\n * decode back into a typed `RemoteFailure`.\r\n *\r\n * @since 2.0.0\r\n * @param cause - The Effect Cause from a failed execution.\r\n * @returns A devalue-encoded string representing the serialised failure.\r\n * @internal\r\n */\r\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\r\n const reasons = get_cause_reasons(cause);\r\n\r\n for (const reason of reasons) {\r\n if (Cause.isFailReason(reason as never)) {\r\n const failure = reason.error;\r\n\r\n const encoded = stringify_failure(failure);\r\n\r\n if (encoded !== undefined) {\r\n return encoded;\r\n }\r\n\r\n const serializable_failure = to_serializable_failure(failure);\r\n const serializable_encoded = stringify_failure(serializable_failure);\r\n\r\n if (serializable_encoded !== undefined) {\r\n return serializable_encoded;\r\n }\r\n }\r\n }\r\n\r\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\r\n}\r\n\r\nfunction get_cause_reasons(\r\n cause: Cause.Cause<unknown>,\r\n): readonly CauseReason[] {\r\n const reasons = (cause as unknown as { reasons?: readonly CauseReason[] })\r\n .reasons;\r\n\r\n return reasons ?? [];\r\n}\r\n\r\nfunction is_sveltekit_control_flow(value: unknown): boolean {\r\n return isRedirect(value) || isHttpError(value) || isValidationError(value);\r\n}\r\n\r\nfunction stringify_failure(value: unknown): string | undefined {\r\n try {\r\n return stringify(value);\r\n } catch {\r\n return undefined;\r\n }\r\n}\r\n\r\nfunction to_serializable_failure(\r\n value: unknown,\r\n seen = new WeakSet<object>(),\r\n): unknown {\r\n if (typeof value === \"function\" || typeof value === \"symbol\") {\r\n return undefined;\r\n }\r\n\r\n if (!is_object_like(value)) {\r\n return value;\r\n }\r\n\r\n if (stringify_failure(value) !== undefined) {\r\n return value;\r\n }\r\n\r\n if (seen.has(value)) {\r\n return undefined;\r\n }\r\n\r\n seen.add(value);\r\n\r\n const serializable = Array.isArray(value)\r\n ? value.map((item) => to_serializable_failure(item, seen))\r\n : to_plain_record(value, seen);\r\n\r\n seen.delete(value);\r\n\r\n return serializable;\r\n}\r\n\r\nfunction to_plain_record(\r\n value: object,\r\n seen: WeakSet<object>,\r\n): Record<string, unknown> {\r\n const descriptors = Object.getOwnPropertyDescriptors(value);\r\n const record: Record<string, unknown> = {};\r\n\r\n for (const [key, descriptor] of Object.entries(descriptors)) {\r\n if (key === \"stack\" || !(\"value\" in descriptor)) {\r\n continue;\r\n }\r\n\r\n record[key] = to_serializable_failure(descriptor.value, seen);\r\n }\r\n\r\n if (value instanceof Error && !(\"message\" in record)) {\r\n record.message = value.message;\r\n }\r\n\r\n return record;\r\n}\r\n\r\nfunction is_object_like(value: unknown): value is object {\r\n return typeof value === \"object\" && value !== null;\r\n}\r\n\r\n/**\r\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\r\n * through to the request-scoped `invalid` helper.\r\n *\r\n * @example\r\n * ```ts\r\n * throw_form_error(\r\n * [{ message: \"Name is required\", path: [\"name\"] }],\r\n * invalid,\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param issues - The list of form validation issues.\r\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\r\n * @internal\r\n */\r\nexport function throw_form_error(\r\n issues: readonly FormIssue[],\r\n invalid: (status: number, body: unknown) => never,\r\n): never {\r\n invalid(400, { issues });\r\n}\r\n\r\n/**\r\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\r\n * into clear, actionable messages.\r\n *\r\n * @example\r\n * ```ts\r\n * try {\r\n * return native_query(handler);\r\n * } catch (err) {\r\n * throw normalize_remote_helper_error(err, \"Query\");\r\n * }\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param err - The error thrown by SvelteKit's native functions.\r\n * @param helper_name - Name of the helper that triggered the error.\r\n * @returns A more descriptive error.\r\n * @internal\r\n */\r\nexport function normalize_remote_helper_error(\r\n err: unknown,\r\n helper_name: string,\r\n): globalThis.Error {\r\n const message = err instanceof Error ? err.message : String(err);\r\n\r\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\r\n return new RemoteHelperContextError(helper_name);\r\n }\r\n\r\n return err instanceof Error ? err : new RemoteHelperError(err);\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,eAAsB,kBACpB,QACA,SAKA,SACA,OACY;CACZ,MAAM,OAA8B,MAAM,QAAQ,WAChD,OAAO,KAAK,MAAM,CACpB;CAEA,IAAI,KAA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-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport { isHttpError, isRedirect, isValidationError } from \"@sveltejs/kit\";\nimport { Cause, Effect, Exit } from \"effect\";\nimport { stringify } from \"devalue\";\n\ntype CauseReason = {\n readonly _tag: string;\n readonly defect?: unknown;\n readonly error?: unknown;\n};\n\n/**\n * Runs a user-supplied Effect program through a ManagedRuntime, maps its\n * exit into the shape expected by SvelteKit, and returns the result or\n * throws a SvelteKit-compatible error.\n *\n * @since 2.0.0\n * @param effect - The Effect program to execute.\n * @param runtime - The server-side ManagedRuntime.\n * @param invalid - SvelteKit's `invalid` helper (bound per-request).\n * @param error - SvelteKit's `error` helper.\n * @returns A Promise that resolves with the effect's success value.\n * @internal\n */\nexport async function run_remote_effect<A>(\n effect: Effect.Effect<A, unknown, unknown>,\n runtime: {\n runPromise: (\n e: Effect.Effect<unknown, unknown, unknown>,\n ) => Promise<unknown>;\n },\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): Promise<A> {\n const exit: Exit.Exit<A, unknown> = await runtime.runPromise(\n Effect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n ) as Exit.Exit<A, unknown>;\n\n if (Exit.isSuccess(exit)) {\n return exit.value;\n }\n\n handle_failure(exit.cause, invalid, error);\n}\n\n/**\n * Inspects the Effect Cause for failures and either throws a form\n * validation error (via SvelteKit's `invalid`) or encodes the error\n * and throws it via SvelteKit's `error`.\n */\nfunction handle_failure(\n cause: Cause.Cause<unknown>,\n invalid: (status: number, body: unknown) => never,\n error: (status: number, body: unknown) => never,\n): never {\n const reasons = get_cause_reasons(cause);\n\n /**\n * Phase 1 — let SvelteKit's thrown control-flow sentinels escape.\n */\n for (const reason of reasons) {\n if (!Cause.isDieReason(reason as never)) {\n continue;\n }\n\n const defect = reason.defect;\n\n if (is_sveltekit_control_flow(defect)) {\n throw defect;\n }\n }\n\n /**\n * Phase 2 — let cancellation escape without becoming a remote failure.\n */\n if (Cause.hasInterruptsOnly(cause)) {\n throw Cause.squash(cause);\n }\n\n /**\n * Phase 3 — preserve typed form validation failures.\n */\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n if (\n typeof failure === \"object\" &&\n failure !== null &&\n (failure as Record<string, unknown>)._tag === \"FormError\"\n ) {\n const issues = (failure as { issues?: readonly FormIssue[] }).issues ??\n [];\n invalid(400, { issues });\n }\n }\n }\n\n /**\n * Phase 4 — encode all other failures for the remote client.\n */\n const encoded = encode_remote_failure(cause);\n const envelope = create_serialized_remote_failure_envelope(encoded);\n\n error(500, envelope);\n}\n\n/**\n * Encodes an Effect Cause into a string that the client-side adapter can\n * decode back into a typed `RemoteFailure`.\n *\n * @since 2.0.0\n * @param cause - The Effect Cause from a failed execution.\n * @returns A devalue-encoded string representing the serialised failure.\n * @internal\n */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n const reasons = get_cause_reasons(cause);\n\n for (const reason of reasons) {\n if (Cause.isFailReason(reason as never)) {\n const failure = reason.error;\n\n const encoded = stringify_failure(failure);\n\n if (encoded !== undefined) {\n return encoded;\n }\n\n const serializable_failure = to_serializable_failure(failure);\n const serializable_encoded = stringify_failure(serializable_failure);\n\n if (serializable_encoded !== undefined) {\n return serializable_encoded;\n }\n }\n }\n\n return stringify({ message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" });\n}\n\nfunction get_cause_reasons(\n cause: Cause.Cause<unknown>,\n): readonly CauseReason[] {\n const reasons = (cause as unknown as { reasons?: readonly CauseReason[] })\n .reasons;\n\n return reasons ?? [];\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n return isRedirect(value) || isHttpError(value) || isValidationError(value);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n try {\n return stringify(value);\n } catch {\n return undefined;\n }\n}\n\nfunction to_serializable_failure(\n value: unknown,\n seen = new WeakSet<object>(),\n): unknown {\n if (typeof value === \"function\" || typeof value === \"symbol\") {\n return undefined;\n }\n\n if (!is_object_like(value)) {\n return value;\n }\n\n if (stringify_failure(value) !== undefined) {\n return value;\n }\n\n if (seen.has(value)) {\n return undefined;\n }\n\n seen.add(value);\n\n const serializable = Array.isArray(value)\n ? value.map((item) => to_serializable_failure(item, seen))\n : to_plain_record(value, seen);\n\n seen.delete(value);\n\n return serializable;\n}\n\nfunction to_plain_record(\n value: object,\n seen: WeakSet<object>,\n): Record<string, unknown> {\n const descriptors = Object.getOwnPropertyDescriptors(value);\n const record: Record<string, unknown> = {};\n\n for (const [key, descriptor] of Object.entries(descriptors)) {\n if (key === \"stack\" || !(\"value\" in descriptor)) {\n continue;\n }\n\n record[key] = to_serializable_failure(descriptor.value, seen);\n }\n\n if (value instanceof Error && !(\"message\" in record)) {\n record.message = value.message;\n }\n\n return record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n return typeof value === \"object\" && value !== null;\n}\n\n/**\n * Throws a SvelteKit `invalid` response from a {@link FormError}, calling\n * through to the request-scoped `invalid` helper.\n *\n * @example\n * ```ts\n * throw_form_error(\n * [{ message: \"Name is required\", path: [\"name\"] }],\n * invalid,\n * );\n * ```\n *\n * @since 2.0.0\n * @param issues - The list of form validation issues.\n * @param invalid - SvelteKit's `invalid` helper bound to the current request.\n * @internal\n */\nexport function throw_form_error(\n issues: readonly FormIssue[],\n invalid: (status: number, body: unknown) => never,\n): never {\n invalid(400, { issues });\n}\n\n/**\n * Remaps low-level SvelteKit errors (e.g. \"Cannot use ___ outside a route\")\n * into clear, actionable messages.\n *\n * @example\n * ```ts\n * try {\n * return native_query(handler);\n * } catch (err) {\n * throw normalize_remote_helper_error(err, \"Query\");\n * }\n * ```\n *\n * @since 2.0.0\n * @param err - The error thrown by SvelteKit's native functions.\n * @param helper_name - Name of the helper that triggered the error.\n * @returns A more descriptive error.\n * @internal\n */\nexport function normalize_remote_helper_error(\n err: unknown,\n helper_name: string,\n): globalThis.Error {\n const message = err instanceof Error ? err.message : String(err);\n\n if (message.includes(\"Cannot use\") || message.includes(\"outside a route\")) {\n return new RemoteHelperContextError(helper_name);\n }\n\n return err instanceof Error ? err : new RemoteHelperError(err);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0BA,eAAsB,kBACpB,QACA,SAKA,SACA,OACY;CACZ,MAAM,OAA8B,MAAM,QAAQ,WAChD,OAAO,KAAK,MAAM,CACpB;CAEA,IAAI,KAAK,UAAU,IAAI,GACrB,OAAO,KAAK;CAGd,eAAe,KAAK,OAAO,SAAS,KAAK;AAC3C;;;;;;AAOA,SAAS,eACP,OACA,SACA,OACO;CACP,MAAM,UAAU,kBAAkB,KAAK;;;;CAKvC,KAAK,MAAM,UAAU,SAAS;EAC5B,IAAI,CAAC,MAAM,YAAY,MAAe,GACpC;EAGF,MAAM,SAAS,OAAO;EAEtB,IAAI,0BAA0B,MAAM,GAClC,MAAM;CAEV;;;;CAKA,IAAI,MAAM,kBAAkB,KAAK,GAC/B,MAAM,MAAM,OAAO,KAAK;;;;CAM1B,KAAK,MAAM,UAAU,SACnB,IAAI,MAAM,aAAa,MAAe,GAAG;EACvC,MAAM,UAAU,OAAO;EACvB,IACE,OAAO,YAAY,YACnB,YAAY,QACX,QAAoC,SAAS,aAI9C,QAAQ,KAAK,EAAE,QAFC,QAA8C,UAC5D,CAAC,EACmB,CAAC;CAE3B;CASF,MAAM,KAFW,0CADD,sBAAsB,KAC2B,CAE/C,CAAC;AACrB;;;;;;;;;;AAWA,SAAgB,sBAAsB,OAAqC;CACzE,MAAM,UAAU,kBAAkB,KAAK;CAEvC,KAAK,MAAM,UAAU,SACnB,IAAI,MAAM,aAAa,MAAe,GAAG;EACvC,MAAM,UAAU,OAAO;EAEvB,MAAM,UAAU,kBAAkB,OAAO;EAEzC,IAAI,YAAY,KAAA,GACd,OAAO;EAIT,MAAM,uBAAuB,kBADA,wBAAwB,OACa,CAAC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E,OAAO,CAAC;AACzB;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,8BACd,KACA,aACkB;CAClB,MAAM,UAAU,eAAe,QAAQ,IAAI,UAAU,OAAO,GAAG;CAE/D,IAAI,QAAQ,SAAS,YAAY,KAAK,QAAQ,SAAS,iBAAiB,GACtE,OAAO,IAAI,yBAAyB,WAAW;CAGjD,OAAO,eAAe,QAAQ,MAAM,IAAI,kBAAkB,GAAG;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["/**\r\n * Shared types, markers, and constructors used by both the client-side remote\r\n * adapters and the server-side handler runtime. These types define the error\r\n * protocol that flows across the network boundary.\r\n *\r\n * @since 2.0.0\r\n */\r\n\r\n/**\r\n * Well-known marker injected into every serialised remote-failure envelope\r\n * so the client can reliably distinguish runtime errors from domain values.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\r\n\r\n/**\r\n * Well-known symbol used to attach a payload decoder to a remote function\r\n * so the client's transport layer can decode domain error types.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport const REMOTE_ERROR_DECODER = Symbol.for(\r\n \"svelte-effect-runtime/remote-error-decoder\",\r\n);\r\n\r\n/** Form validation helpers and types. */\r\n\r\n/**\r\n * A single field-level or form-level validation issue reported by a\r\n * {@link Form} handler.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface FormIssue {\r\n /** Human-readable validation message. */\r\n message: string;\r\n /** Path to the offending field as an array of string-or-number keys. */\r\n path: (string | number)[];\r\n}\r\n\r\n/**\r\n * Error subtype thrown by {@link Form} handlers to signal validation\r\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\r\n * helper on the server and surfaced as `FormError` on the client.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface FormError<SchemaType = unknown> {\r\n readonly _tag: \"FormError\";\r\n readonly issues: readonly FormIssue[];\r\n /** Phantom type slot for the schema this error was derived from. */\r\n readonly _schema?: SchemaType;\r\n}\r\n\r\n/**\r\n * Creates a {@link FormError} holding the given issues.\r\n *\r\n * @since 2.0.0\r\n * @param issues - The validation issues to attach.\r\n * @returns A FormError with the `_tag` set and no schema reference.\r\n */\r\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\r\n return { _tag: \"FormError\", issues };\r\n}\r\n\r\n/**\r\n * Type guard that narrows an unknown value to a {@link FormError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a FormError.\r\n */\r\nexport function is_form_error(value: unknown): value is FormError {\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"FormError\"\r\n );\r\n}\r\n\r\n/** Remote error types shared by client and server helpers. */\r\n\r\n/**\r\n * Union of all wire-level error shapes that a remote function can\r\n * surface on its error channel.\r\n *\r\n * @example\r\n * ```ts\r\n * const result = yield* myQuery();\r\n * // error channel is RemoteFailure<DomainError>\r\n * ```\r\n *\r\n * @since 2.0.0\r\n */\r\nexport type RemoteFailure<ErrorType> =\r\n | ErrorType\r\n | RemoteValidationError\r\n | RemoteHttpError\r\n | RemoteTransportError;\r\n\r\n/**\r\n * Validation errors that originate from a server-side {@link Form}\r\n * handler calling `invalid()` (SvelteKit's `fail`).\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteValidationError {\r\n readonly _tag: \"RemoteValidationError\";\r\n readonly issues?: readonly FormIssue[];\r\n readonly body?: unknown;\r\n readonly status: number;\r\n}\r\n\r\n/**\r\n * HTTP-level errors with a status code and optional response body. Raised\r\n * when the server explicitly calls SvelteKit's `error(status, body)`.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteHttpError {\r\n readonly _tag: \"RemoteHttpError\";\r\n readonly status: number;\r\n readonly body?: unknown;\r\n readonly cause?: unknown;\r\n}\r\n\r\n/**\r\n * Transport-level errors raised by the client adapter when the network\r\n * request fails or the response cannot be decoded.\r\n *\r\n * @since 2.0.0\r\n */\r\nexport interface RemoteTransportError {\r\n readonly _tag: \"RemoteTransportError\";\r\n readonly cause?: unknown;\r\n readonly body?: unknown;\r\n}\r\n\r\n/**\r\n * Wire format for an encoded remote failure. The server wraps domain\r\n * errors in this envelope before serialising them with devalue.\r\n *\r\n * @since 2.0.0\r\n * @internal\r\n */\r\nexport interface SerializedRemoteFailureEnvelope {\r\n readonly __svelte_effect_remote__: true;\r\n readonly encoded: string;\r\n}\r\n\r\n/** Constructors for structured remote error values. */\r\n\r\n/**\r\n * Creates a {@link RemoteValidationError} from a list of form issues.\r\n *\r\n * @since 2.0.0\r\n * @param issues - The validation issues reported by the server handler.\r\n * @param body - Optional response body returned alongside the error.\r\n * @param status - HTTP status code (defaults to 400).\r\n * @returns A remote-validation error shape.\r\n * @internal\r\n */\r\nexport function create_remote_validation_error(\r\n issues: readonly FormIssue[],\r\n body?: unknown,\r\n status = 400,\r\n): RemoteValidationError {\r\n\r\n return { _tag: \"RemoteValidationError\", issues, body, status };\r\n}\r\n\r\n/**\r\n * Creates a {@link RemoteHttpError} for a given HTTP status.\r\n *\r\n * @since 2.0.0\r\n * @param status - The HTTP status code.\r\n * @param body - Optional response body.\r\n * @param cause - Optional underlying cause.\r\n * @returns A remote HTTP error shape.\r\n * @internal\r\n */\r\nexport function create_remote_http_error(\r\n status: number,\r\n body?: unknown,\r\n cause?: unknown,\r\n): RemoteHttpError {\r\n\r\n return { _tag: \"RemoteHttpError\", status, body, cause };\r\n}\r\n\r\n/**\r\n * Creates a {@link RemoteTransportError} for network or decode failures.\r\n *\r\n * @since 2.0.0\r\n * @param cause - The underlying error that caused the transport failure.\r\n * @param body - Optional response body if one was received.\r\n * @returns A remote transport error shape.\r\n * @internal\r\n */\r\nexport function create_remote_transport_error(\r\n cause: unknown,\r\n body?: unknown,\r\n): RemoteTransportError {\r\n\r\n return { _tag: \"RemoteTransportError\", cause, body };\r\n}\r\n\r\n/**\r\n * Wraps a devalue-encoded error string inside a\r\n * {@link SerializedRemoteFailureEnvelope}.\r\n *\r\n * @since 2.0.0\r\n * @param encoded - The devalue-encoded error value.\r\n * @returns The wire-format envelope.\r\n * @internal\r\n */\r\nexport function create_serialized_remote_failure_envelope(\r\n encoded: string,\r\n): SerializedRemoteFailureEnvelope {\r\n\r\n return { __svelte_effect_remote__: true, encoded };\r\n}\r\n\r\n/** Type guards for structured remote error values. */\r\n\r\n/**\r\n * Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a serialised failure envelope.\r\n * @internal\r\n */\r\nexport function is_serialized_remote_failure_envelope(\r\n value: unknown,\r\n): value is SerializedRemoteFailureEnvelope {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>).__svelte_effect_remote__ === true\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteValidationError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote validation error.\r\n */\r\nexport function is_remote_validation_error(\r\n value: unknown,\r\n): value is RemoteValidationError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteValidationError\"\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteHttpError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote HTTP error.\r\n */\r\nexport function is_remote_http_error(\r\n value: unknown,\r\n): value is RemoteHttpError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteHttpError\"\r\n );\r\n}\r\n\r\n/**\r\n * Checks whether a value is a {@link RemoteTransportError}.\r\n *\r\n * @since 2.0.0\r\n * @param value - The value to check.\r\n * @returns `true` when the value is a remote transport error.\r\n */\r\nexport function is_remote_transport_error(\r\n value: unknown,\r\n): value is RemoteTransportError {\r\n\r\n return (\r\n typeof value === \"object\" &&\r\n value !== null &&\r\n (value as Record<string, unknown>)._tag === \"RemoteTransportError\"\r\n );\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,6BAA6B;;;;;;;;AAS1C,MAAa,uBAAuB,OAAO,IACzC,4CACF;;;;;;;;AAsCA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO;EAAE,MAAM;EAAa;CAAO;AACrC;;;;;;;;AASA,SAAgB,cAAc,OAAoC;CAChE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;;;;;AAoFA,SAAgB,+BACd,QACA,MACA,SAAS,KACc;CAEvB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC/D;;;;;;;;;;;AAYA,SAAgB,yBACd,QACA,MACA,OACiB;CAEjB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACxD;;;;;;;;;;AAWA,SAAgB,8BACd,OACA,MACsB;CAEtB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACrD;;;;;;;;;;AAWA,SAAgB,0CACd,SACiC;CAEjC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AACnD;;;;;;;;;;AAYA,SAAgB,sCACd,OAC0C;CAE1C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,6BAA6B;AAEpE;;;;;;;;AASA,SAAgB,2BACd,OACgC;CAEhC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,qBACd,OAC0B;CAE1B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,0BACd,OAC+B;CAE/B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD"}
1
+ {"version":3,"file":"shared.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/shared.ts"],"sourcesContent":["/**\n * Shared types, markers, and constructors used by both the client-side remote\n * adapters and the server-side handler runtime. These types define the error\n * protocol that flows across the network boundary.\n *\n * @since 2.0.0\n */\n\n/**\n * Well-known marker injected into every serialised remote-failure envelope\n * so the client can reliably distinguish runtime errors from domain values.\n *\n * @since 2.0.0\n * @internal\n */\nexport const EFFECT_REMOTE_ERROR_MARKER = \"__svelte_effect_remote__\";\n\n/**\n * Well-known symbol used to attach a payload decoder to a remote function\n * so the client's transport layer can decode domain error types.\n *\n * @since 2.0.0\n * @internal\n */\nexport const REMOTE_ERROR_DECODER = Symbol.for(\n \"svelte-effect-runtime/remote-error-decoder\",\n);\n\n/** Form validation helpers and types. */\n\n/**\n * A single field-level or form-level validation issue reported by a\n * {@link Form} handler.\n *\n * @since 2.0.0\n */\nexport interface FormIssue {\n /** Human-readable validation message. */\n message: string;\n /** Path to the offending field as an array of string-or-number keys. */\n path: (string | number)[];\n}\n\n/**\n * Error subtype thrown by {@link Form} handlers to signal validation\n * failures. The `issues` array is forwarded to SvelteKit's `invalid()`\n * helper on the server and surfaced as `FormError` on the client.\n *\n * @since 2.0.0\n */\nexport interface FormError<SchemaType = unknown> {\n readonly _tag: \"FormError\";\n readonly issues: readonly FormIssue[];\n /** Phantom type slot for the schema this error was derived from. */\n readonly _schema?: SchemaType;\n}\n\n/**\n * Creates a {@link FormError} holding the given issues.\n *\n * @since 2.0.0\n * @param issues - The validation issues to attach.\n * @returns A FormError with the `_tag` set and no schema reference.\n */\nexport function create_form_error(issues: readonly FormIssue[]): FormError {\n return { _tag: \"FormError\", issues };\n}\n\n/**\n * Type guard that narrows an unknown value to a {@link FormError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a FormError.\n */\nexport function is_form_error(value: unknown): value is FormError {\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"FormError\"\n );\n}\n\n/** Remote error types shared by client and server helpers. */\n\n/**\n * Union of all wire-level error shapes that a remote function can\n * surface on its error channel.\n *\n * @example\n * ```ts\n * const result = yield* myQuery();\n * // error channel is RemoteFailure<DomainError>\n * ```\n *\n * @since 2.0.0\n */\nexport type RemoteFailure<ErrorType> =\n | ErrorType\n | RemoteValidationError\n | RemoteHttpError\n | RemoteTransportError;\n\n/**\n * Validation errors that originate from a server-side {@link Form}\n * handler calling `invalid()` (SvelteKit's `fail`).\n *\n * @since 2.0.0\n */\nexport interface RemoteValidationError {\n readonly _tag: \"RemoteValidationError\";\n readonly issues?: readonly FormIssue[];\n readonly body?: unknown;\n readonly status: number;\n}\n\n/**\n * HTTP-level errors with a status code and optional response body. Raised\n * when the server explicitly calls SvelteKit's `error(status, body)`.\n *\n * @since 2.0.0\n */\nexport interface RemoteHttpError {\n readonly _tag: \"RemoteHttpError\";\n readonly status: number;\n readonly body?: unknown;\n readonly cause?: unknown;\n}\n\n/**\n * Transport-level errors raised by the client adapter when the network\n * request fails or the response cannot be decoded.\n *\n * @since 2.0.0\n */\nexport interface RemoteTransportError {\n readonly _tag: \"RemoteTransportError\";\n readonly cause?: unknown;\n readonly body?: unknown;\n}\n\n/**\n * Wire format for an encoded remote failure. The server wraps domain\n * errors in this envelope before serialising them with devalue.\n *\n * @since 2.0.0\n * @internal\n */\nexport interface SerializedRemoteFailureEnvelope {\n readonly __svelte_effect_remote__: true;\n readonly encoded: string;\n}\n\n/** Constructors for structured remote error values. */\n\n/**\n * Creates a {@link RemoteValidationError} from a list of form issues.\n *\n * @since 2.0.0\n * @param issues - The validation issues reported by the server handler.\n * @param body - Optional response body returned alongside the error.\n * @param status - HTTP status code (defaults to 400).\n * @returns A remote-validation error shape.\n * @internal\n */\nexport function create_remote_validation_error(\n issues: readonly FormIssue[],\n body?: unknown,\n status = 400,\n): RemoteValidationError {\n\n return { _tag: \"RemoteValidationError\", issues, body, status };\n}\n\n/**\n * Creates a {@link RemoteHttpError} for a given HTTP status.\n *\n * @since 2.0.0\n * @param status - The HTTP status code.\n * @param body - Optional response body.\n * @param cause - Optional underlying cause.\n * @returns A remote HTTP error shape.\n * @internal\n */\nexport function create_remote_http_error(\n status: number,\n body?: unknown,\n cause?: unknown,\n): RemoteHttpError {\n\n return { _tag: \"RemoteHttpError\", status, body, cause };\n}\n\n/**\n * Creates a {@link RemoteTransportError} for network or decode failures.\n *\n * @since 2.0.0\n * @param cause - The underlying error that caused the transport failure.\n * @param body - Optional response body if one was received.\n * @returns A remote transport error shape.\n * @internal\n */\nexport function create_remote_transport_error(\n cause: unknown,\n body?: unknown,\n): RemoteTransportError {\n\n return { _tag: \"RemoteTransportError\", cause, body };\n}\n\n/**\n * Wraps a devalue-encoded error string inside a\n * {@link SerializedRemoteFailureEnvelope}.\n *\n * @since 2.0.0\n * @param encoded - The devalue-encoded error value.\n * @returns The wire-format envelope.\n * @internal\n */\nexport function create_serialized_remote_failure_envelope(\n encoded: string,\n): SerializedRemoteFailureEnvelope {\n\n return { __svelte_effect_remote__: true, encoded };\n}\n\n/** Type guards for structured remote error values. */\n\n/**\n * Checks whether a value is a {@link SerializedRemoteFailureEnvelope}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a serialised failure envelope.\n * @internal\n */\nexport function is_serialized_remote_failure_envelope(\n value: unknown,\n): value is SerializedRemoteFailureEnvelope {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>).__svelte_effect_remote__ === true\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteValidationError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote validation error.\n */\nexport function is_remote_validation_error(\n value: unknown,\n): value is RemoteValidationError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteValidationError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteHttpError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote HTTP error.\n */\nexport function is_remote_http_error(\n value: unknown,\n): value is RemoteHttpError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteHttpError\"\n );\n}\n\n/**\n * Checks whether a value is a {@link RemoteTransportError}.\n *\n * @since 2.0.0\n * @param value - The value to check.\n * @returns `true` when the value is a remote transport error.\n */\nexport function is_remote_transport_error(\n value: unknown,\n): value is RemoteTransportError {\n\n return (\n typeof value === \"object\" &&\n value !== null &&\n (value as Record<string, unknown>)._tag === \"RemoteTransportError\"\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAa,6BAA6B;;;;;;;;AAS1C,MAAa,uBAAuB,OAAO,IACzC,4CACF;;;;;;;;AAsCA,SAAgB,kBAAkB,QAAyC;CACzE,OAAO;EAAE,MAAM;EAAa;CAAO;AACrC;;;;;;;;AASA,SAAgB,cAAc,OAAoC;CAChE,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;;;;;AAoFA,SAAgB,+BACd,QACA,MACA,SAAS,KACc;CAEvB,OAAO;EAAE,MAAM;EAAyB;EAAQ;EAAM;CAAO;AAC/D;;;;;;;;;;;AAYA,SAAgB,yBACd,QACA,MACA,OACiB;CAEjB,OAAO;EAAE,MAAM;EAAmB;EAAQ;EAAM;CAAM;AACxD;;;;;;;;;;AAWA,SAAgB,8BACd,OACA,MACsB;CAEtB,OAAO;EAAE,MAAM;EAAwB;EAAO;CAAK;AACrD;;;;;;;;;;AAWA,SAAgB,0CACd,SACiC;CAEjC,OAAO;EAAE,0BAA0B;EAAM;CAAQ;AACnD;;;;;;;;;;AAYA,SAAgB,sCACd,OAC0C;CAE1C,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,6BAA6B;AAEpE;;;;;;;;AASA,SAAgB,2BACd,OACgC;CAEhC,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,qBACd,OAC0B;CAE1B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD;;;;;;;;AASA,SAAgB,0BACd,OAC+B;CAE/B,OACE,OAAO,UAAU,YACjB,UAAU,QACT,MAAkC,SAAS;AAEhD"}
@@ -1,5 +1,5 @@
1
- import { d as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-Buz9cLGF.js";
2
- import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-B5T5TUcJ.js";
1
+ import { d as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-0PaWf7Bq.js";
2
+ import { a as is_yield_star_expression, c as slice, d as collect_top_level_binding_names, f as has_local_import_binding, i as find_yield_star_node, l as slice_start, n as collect_yield_star_nodes, o as validate_rune_yield_usage, p as make_imports, r as contains_top_level_await, s as create_source_map, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-Cdsx7ygD.js";
3
3
  import { contains_top_level_yield_star } from "../detect.js";
4
4
  import MagicString from "magic-string";
5
5
  import ts from "typescript";
@@ -1 +1 @@
1
- {"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/runtime-block.ts","../../../modules/svelte-effect-runtime/src/script-transform/lower.ts","../../../modules/svelte-effect-runtime/src/script-transform/index.ts","../../../modules/svelte-effect-runtime/src/runtime/transform.ts"],"sourcesContent":["import type { EffectBlock, RuntimeImportBindings } from \"./types.ts\";\r\n\r\n/**\r\n * Builds the runtime blocks appended to lowered script effect code.\r\n *\r\n * @since 2.0.0\r\n * @param blocks - Effect bodies and dependency reads to emit.\r\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\r\n */\r\nexport function make_runtime_block(blocks: EffectBlock[]): string {\r\n const bindings: RuntimeImportBindings = {\r\n cancel: \"__SER___cancel\",\r\n dispatcher: \"get_dispatcher\",\r\n dispatcher_value: \"__SER___dispatcher\",\r\n effect: \"Effect\",\r\n program: \"__SER___program\",\r\n untrack: \"untrack\",\r\n };\r\n\r\n return make_runtime_block_with_bindings(blocks, bindings);\r\n}\r\n\r\n/**\r\n * Builds the runtime blocks appended to lowered script effect code with\r\n * explicit runtime import bindings.\r\n *\r\n * @since 2.4.2\r\n * @param blocks - Effect bodies and dependency reads to emit.\r\n * @param bindings - Runtime binding names available in the generated code.\r\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\r\n */\r\nexport function make_runtime_block_with_bindings(\r\n blocks: EffectBlock[],\r\n bindings: RuntimeImportBindings,\r\n): string {\r\n const merged_block = merge_effect_blocks(blocks);\r\n const dep_reads = merged_block.deps.map((dep) => ` ${dep};`);\r\n\r\n const body = merged_block.statements\r\n .map((statement) => ` ${statement}`)\r\n .join(\"\\n\");\r\n\r\n return [\r\n \"\",\r\n \"$effect(() => {\",\r\n ...dep_reads,\r\n ` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\r\n ` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\r\n body,\r\n \" });\",\r\n ` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.fork(${bindings.program}));`,\r\n ` import.meta.hot?.dispose(${bindings.cancel});`,\r\n ` return ${bindings.cancel};`,\r\n \"});\",\r\n \"\",\r\n ].join(\"\\n\");\r\n}\r\n\r\nfunction merge_effect_blocks(blocks: EffectBlock[]): EffectBlock {\r\n const statements = blocks.flatMap((block) => block.statements);\r\n const deps = blocks.flatMap((block) => block.deps);\r\n\r\n return {\r\n statements,\r\n deps: [...new Set(deps)],\r\n };\r\n}\r\n","import { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\r\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\r\nimport {\r\n collect_yield_star_nodes,\r\n find_yield_star_node,\r\n is_yield_star_expression,\r\n} from \"./ast.ts\";\r\nimport { slice, slice_start } from \"./source.ts\";\r\nimport type {\r\n EffectBlock,\r\n LoweredExpression,\r\n LoweredStatement,\r\n ScriptLoweringContext,\r\n TempBinding,\r\n} from \"./types.ts\";\r\n\r\nimport ts from \"typescript\";\r\n\r\n/**\r\n * Delegates a statement to the correct lowerer based on syntax kind.\r\n *\r\n * @since 2.0.0\r\n * @param stmt - Statement to lower.\r\n * @param content - Original source text.\r\n * @param context - Lowering services for this transform pass.\r\n * @returns Lowered statement descriptor.\r\n */\r\nexport function lower_statement(\r\n stmt: ts.Statement,\r\n content: string,\r\n context: ScriptLoweringContext,\r\n): LoweredStatement {\r\n if (ts.isExpressionStatement(stmt)) {\r\n return lower_expression_statement(stmt, content, context);\r\n }\r\n\r\n if (ts.isVariableStatement(stmt)) {\r\n return lower_variable_statement(stmt, content, context);\r\n }\r\n\r\n const text = slice(content, stmt);\r\n\r\n return {\r\n temps: [],\r\n rewritten_text: \"\",\r\n effect_blocks: [make_effect_block([text], collect_deps(text))],\r\n range: { start: stmt.getFullStart(), end: stmt.end },\r\n };\r\n}\r\n\r\nfunction lower_variable_statement(\r\n stmt: ts.VariableStatement,\r\n content: string,\r\n context: ScriptLoweringContext,\r\n): LoweredStatement {\r\n const helper_declarations: string[] = [];\r\n const rewritten_decls: string[] = [];\r\n\r\n const decl_list = stmt.declarationList;\r\n const kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\r\n let uses_dispatcher_promise = false;\r\n\r\n for (const decl of decl_list.declarations) {\r\n if (!contains_top_level_yield_star(decl)) {\r\n rewritten_decls.push(slice(content, decl).trim());\r\n continue;\r\n }\r\n\r\n const lowered = lower_node_yields_to_await(\r\n decl,\r\n content,\r\n make_binding_hint(decl.name),\r\n context,\r\n );\r\n\r\n helper_declarations.push(...lowered.helper_declarations);\r\n rewritten_decls.push(lowered.rewritten_text);\r\n uses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\r\n }\r\n\r\n const rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\r\n\r\n return {\r\n temps: [],\r\n type_helpers: helper_declarations,\r\n rewritten_text,\r\n effect_blocks: [],\r\n uses_dispatcher_promise,\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n}\r\n\r\nfunction lower_expression_statement(\r\n stmt: ts.ExpressionStatement,\r\n content: string,\r\n context: ScriptLoweringContext,\r\n): LoweredStatement {\r\n const expr = stmt.expression;\r\n\r\n if (!contains_top_level_yield_star(expr)) {\r\n return {\r\n temps: [],\r\n rewritten_text: slice(content, stmt).trim(),\r\n effect_blocks: [],\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n }\r\n\r\n if (is_yield_star_expression(expr)) {\r\n const text = slice(content, expr).trim();\r\n\r\n return {\r\n temps: [],\r\n rewritten_text: \"\",\r\n effect_blocks: [make_effect_block([text + \";\"], collect_deps(text))],\r\n range: { start: stmt.getFullStart(), end: stmt.end },\r\n };\r\n }\r\n\r\n if (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\r\n const target = slice(content, expr.left).trim();\r\n const target_names = collect_assignment_target_names(expr.left);\r\n\r\n if (\r\n expr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\r\n is_yield_star_expression(expr.right)\r\n ) {\r\n const yield_text = extract_yield_star_full_text(expr.right, content);\r\n\r\n return {\r\n temps: [],\r\n rewritten_text: \"\",\r\n effect_blocks: [\r\n make_effect_block(\r\n [`${target} = ${yield_text};`],\r\n collect_deps(yield_text, target_names),\r\n ),\r\n ],\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n }\r\n\r\n const lowered = lower_expression_yields(\r\n expr.right,\r\n content,\r\n make_temp_hint(target),\r\n context,\r\n );\r\n const temp_names = lowered.temps.map((temp) => temp.name);\r\n const statement = `${target} ${\r\n slice(content, expr.operatorToken).trim()\r\n } ${lowered.rewritten_expr};`;\r\n\r\n return {\r\n temps: lowered.temps,\r\n type_helpers: lowered.type_helpers,\r\n rewritten_text: \"\",\r\n effect_blocks: [\r\n make_effect_block(\r\n [\r\n ...lowered.effect_blocks.flatMap((block) => block.statements),\r\n statement,\r\n ],\r\n [\r\n ...lowered.effect_blocks.flatMap((block) => block.deps),\r\n ...collect_deps(lowered.rewritten_expr, [\r\n ...target_names,\r\n ...temp_names,\r\n ]),\r\n ],\r\n ),\r\n ],\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n }\r\n\r\n const lowered = lower_expression_yields(\r\n expr,\r\n content,\r\n \"call\",\r\n context,\r\n );\r\n\r\n if (is_top_level_rune_call(expr)) {\r\n return {\r\n temps: lowered.temps,\r\n type_helpers: lowered.type_helpers,\r\n rewritten_text: lowered.rewritten_expr + \";\",\r\n effect_blocks: lowered.effect_blocks,\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n }\r\n\r\n const temp_names = lowered.temps.map((temp) => temp.name);\r\n\r\n return {\r\n temps: lowered.temps,\r\n type_helpers: lowered.type_helpers,\r\n rewritten_text: \"\",\r\n effect_blocks: [\r\n make_effect_block(\r\n [\r\n ...lowered.effect_blocks.flatMap((block) => block.statements),\r\n lowered.rewritten_expr + \";\",\r\n ],\r\n [\r\n ...lowered.effect_blocks.flatMap((block) => block.deps),\r\n ...collect_deps(lowered.rewritten_expr, temp_names),\r\n ],\r\n ),\r\n ],\r\n range: { start: stmt.getStart(), end: stmt.end },\r\n };\r\n}\r\n\r\nfunction lower_expression_yields(\r\n expr: ts.Expression,\r\n content: string,\r\n hint: string,\r\n context: ScriptLoweringContext,\r\n): LoweredExpression {\r\n const replacements: Array<{\r\n start: number;\r\n end: number;\r\n text: string;\r\n }> = [];\r\n\r\n const temps: TempBinding[] = [];\r\n const type_helpers: string[] = [];\r\n const statements: string[] = [];\r\n const deps: string[] = [];\r\n\r\n collect_yield_star_nodes(expr, (node) => {\r\n const temp_name = context.next_temp_name(hint);\r\n const yield_text = slice_start(content, node).trim();\r\n const type_helper = make_yield_type_helper(yield_text, hint, context);\r\n\r\n if (type_helper) {\r\n type_helpers.push(type_helper.declaration);\r\n temps.push({ name: temp_name, type: type_helper.type });\r\n } else {\r\n temps.push({ name: temp_name });\r\n }\r\n\r\n statements.push(`${temp_name} = ${yield_text};`);\r\n deps.push(...collect_deps(yield_text));\r\n replacements.push({\r\n start: node.getStart(),\r\n end: node.end,\r\n text: temp_name,\r\n });\r\n });\r\n\r\n if (replacements.length === 0) {\r\n return {\r\n temps,\r\n type_helpers,\r\n rewritten_expr: slice(content, expr).trim(),\r\n effect_blocks: [],\r\n };\r\n }\r\n\r\n replacements.sort((a, b) => b.start - a.start);\r\n\r\n let text = slice(content, expr);\r\n\r\n const offset_in_expr = expr.getFullStart();\r\n\r\n for (const replacement of replacements) {\r\n text = text.slice(0, replacement.start - offset_in_expr) +\r\n replacement.text +\r\n text.slice(replacement.end - offset_in_expr);\r\n }\r\n\r\n return {\r\n temps,\r\n type_helpers,\r\n rewritten_expr: text.trim(),\r\n effect_blocks: [make_effect_block(statements, deps)],\r\n };\r\n}\r\n\r\nfunction lower_node_yields_to_await(\r\n node: ts.Node,\r\n content: string,\r\n hint: string,\r\n context: ScriptLoweringContext,\r\n): {\r\n helper_declarations: string[];\r\n rewritten_text: string;\r\n uses_dispatcher_promise: boolean;\r\n} {\r\n const helper_declarations: string[] = [];\r\n const replacements: Array<{\r\n start: number;\r\n end: number;\r\n text: string;\r\n }> = [];\r\n\r\n collect_yield_star_nodes(node, (yield_node) => {\r\n const awaited = make_awaited_yield_expression(\r\n yield_node,\r\n content,\r\n hint,\r\n context,\r\n );\r\n\r\n helper_declarations.push(awaited.declaration);\r\n replacements.push({\r\n start: yield_node.getStart(),\r\n end: yield_node.end,\r\n text: awaited.expression,\r\n });\r\n });\r\n\r\n replacements.sort((a, b) => b.start - a.start);\r\n\r\n let text = slice_start(content, node);\r\n const offset_in_node = node.getStart();\r\n\r\n for (const replacement of replacements) {\r\n text = text.slice(0, replacement.start - offset_in_node) +\r\n replacement.text +\r\n text.slice(replacement.end - offset_in_node);\r\n }\r\n\r\n return {\r\n helper_declarations,\r\n rewritten_text: text.trim(),\r\n uses_dispatcher_promise: replacements.length > 0,\r\n };\r\n}\r\n\r\nfunction make_awaited_yield_expression(\r\n node: ts.Node,\r\n content: string,\r\n hint: string,\r\n context: ScriptLoweringContext,\r\n): { declaration: string; expression: string } {\r\n const yield_text = slice_start(content, node).trim();\r\n const helper_name = context.next_helper_name(`effect_${hint}`);\r\n const helper_id = make_script_effect_id(node, context);\r\n const deps = collect_deps(yield_text);\r\n const deps_text = `[${deps.join(\", \")}]`;\r\n\r\n return {\r\n declaration: `function* ${helper_name}() { return (${yield_text}); }`,\r\n expression: [\r\n `await ${context.dispatcher_name}().promise({`,\r\n `id: ${JSON.stringify(helper_id)}, `,\r\n `deps: ${deps_text}, `,\r\n `factory: () => ${helper_name}()`,\r\n `})`,\r\n ].join(\"\"),\r\n };\r\n}\r\n\r\nfunction make_yield_type_helper(\r\n yield_text: string,\r\n hint: string,\r\n context: ScriptLoweringContext,\r\n): { declaration: string; type: string } | undefined {\r\n if (!context.emit_types) {\r\n return undefined;\r\n }\r\n\r\n const helper_name = context.next_type_helper_name(hint);\r\n const effect_text = strip_yield_star(yield_text);\r\n\r\n return {\r\n declaration: `function ${helper_name}() { return (${effect_text}); }`,\r\n type:\r\n `${context.effect_name}.Success<ReturnType<typeof ${helper_name}>> | undefined`,\r\n };\r\n}\r\n\r\nfunction strip_yield_star(yield_text: string): string {\r\n return yield_text.replace(/^yield\\*\\s*/, \"\");\r\n}\r\n\r\nfunction make_script_effect_id(\r\n expr: ts.Node,\r\n context: ScriptLoweringContext,\r\n): string {\r\n return `${context.filename}:${expr.getStart()}:${expr.end}`;\r\n}\r\n\r\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\r\n return expr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\r\n expr.operatorToken.kind <= ts.SyntaxKind.LastAssignment;\r\n}\r\n\r\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\r\n if (!ts.isCallExpression(expr)) {\r\n return false;\r\n }\r\n\r\n const callee = expr.expression;\r\n\r\n if (ts.isIdentifier(callee)) {\r\n return callee.text.startsWith(\"$\");\r\n }\r\n\r\n return ts.isPropertyAccessExpression(callee) &&\r\n ts.isIdentifier(callee.expression) &&\r\n callee.expression.text.startsWith(\"$\");\r\n}\r\n\r\nfunction make_temp_hint(target: string): string {\r\n const match = target.match(/[A-Za-z_$][\\w$]*$/);\r\n\r\n return match?.[0] ?? \"assignment\";\r\n}\r\n\r\nfunction make_binding_hint(name: ts.BindingName): string {\r\n if (ts.isIdentifier(name)) {\r\n return name.text;\r\n }\r\n\r\n return \"destructure\";\r\n}\r\n\r\nfunction extract_yield_star_full_text(\r\n expr: ts.Expression,\r\n content: string,\r\n): string {\r\n let found: string | undefined;\r\n\r\n find_yield_star_node(expr, (node) => {\r\n found = slice_start(content, node).trim();\r\n });\r\n\r\n return found ?? \"undefined\";\r\n}\r\n\r\nfunction make_effect_block(\r\n statements: string[],\r\n deps: string[],\r\n): EffectBlock {\r\n return {\r\n statements,\r\n deps: [...new Set(deps)],\r\n };\r\n}\r\n\r\nfunction collect_deps(\r\n expr_text: string,\r\n excluded_names: readonly string[] = [],\r\n): string[] {\r\n const excluded = new Set(excluded_names);\r\n\r\n return collect_free_identifiers(expr_text).filter(\r\n (identifier) =>\r\n !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\r\n );\r\n}\r\n\r\nfunction collect_assignment_target_names(node: ts.Node): string[] {\r\n if (ts.isIdentifier(node)) {\r\n return [node.text];\r\n }\r\n\r\n if (ts.isParenthesizedExpression(node)) {\r\n return collect_assignment_target_names(node.expression);\r\n }\r\n\r\n if (\r\n ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)\r\n ) {\r\n return collect_assignment_target_names(node.expression);\r\n }\r\n\r\n if (ts.isObjectLiteralExpression(node)) {\r\n return node.properties.flatMap((property) => {\r\n if (ts.isShorthandPropertyAssignment(property)) {\r\n return [property.name.text];\r\n }\r\n\r\n if (ts.isPropertyAssignment(property)) {\r\n return collect_assignment_target_names(property.initializer);\r\n }\r\n\r\n if (ts.isSpreadAssignment(property)) {\r\n return collect_assignment_target_names(property.expression);\r\n }\r\n\r\n return [];\r\n });\r\n }\r\n\r\n if (ts.isArrayLiteralExpression(node)) {\r\n return node.elements.flatMap((element) =>\r\n ts.isSpreadElement(element)\r\n ? collect_assignment_target_names(element.expression)\r\n : collect_assignment_target_names(element)\r\n );\r\n }\r\n\r\n return [];\r\n}\r\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\r\nimport {\r\n collect_top_level_binding_names,\r\n has_local_import_binding,\r\n make_imports,\r\n} from \"./imports.ts\";\r\nimport { create_source_map, slice } from \"./source.ts\";\r\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\r\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\r\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\r\nimport { lower_statement } from \"./lower.ts\";\r\nimport { validate_rune_yield_usage } from \"./runes.ts\";\r\nimport type {\r\n BlockRef,\r\n EffectBlock,\r\n Relocation,\r\n RuntimeImportBindings,\r\n ScriptLoweringContext,\r\n ScriptTransformResult,\r\n} from \"./types.ts\";\r\n\r\nimport MagicString from \"magic-string\";\r\nimport ts from \"typescript\";\r\n\r\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\r\n\r\ninterface ScriptTransformOptions {\r\n emit_types?: boolean;\r\n}\r\n\r\n/**\r\n * Transforms a `<script effect>` body by lowering top-level `yield*`\r\n * expressions into Svelte-compatible async rendering declarations or into\r\n * dependency-tracked `$effect` blocks for effectful statements.\r\n *\r\n * @example\r\n * ```ts\r\n * const result = transform_script_effect(\r\n * `let user = $state(yield* getUser(id));`,\r\n * \"App.svelte\",\r\n * );\r\n * ```\r\n *\r\n * @since 2.0.0\r\n * @param content - The raw `<script effect>` body content.\r\n * @param filename - The source filename, used in error messages.\r\n * @param options - Optional transform settings for generated script code.\r\n * @returns The transformed code and any block references.\r\n */\r\nexport function transform_script_effect(\r\n content: string,\r\n filename: string,\r\n options: ScriptTransformOptions = {},\r\n): ScriptTransformResult {\r\n let temp_counter = 0;\r\n\r\n const source_file = ts.createSourceFile(\r\n filename,\r\n content,\r\n ts.ScriptTarget.Latest,\r\n true,\r\n ts.ScriptKind.TS,\r\n );\r\n\r\n const magic = new MagicString(content);\r\n const effect_blocks: EffectBlock[] = [];\r\n const block_refs: BlockRef[] = [];\r\n const top_level_binding_names = collect_top_level_binding_names(source_file);\r\n const top_level_binding_names_set = new Set(top_level_binding_names);\r\n const name_allocator = make_name_allocator(top_level_binding_names);\r\n const emit_types = options.emit_types ?? true;\r\n\r\n let has_effect = false;\r\n let uses_dispatcher_promise = false;\r\n let uses_effect_types = false;\r\n\r\n /** Phase 1: detect imports already provided by the user. */\r\n const has_effect_import = has_local_import_binding(\r\n source_file,\r\n \"effect\",\r\n \"Effect\",\r\n );\r\n\r\n const has_dispatcher_import = has_local_import_binding(\r\n source_file,\r\n \"svelte-effect-runtime/internal/generators\",\r\n \"get_dispatcher\",\r\n );\r\n\r\n const has_untrack_import = has_local_import_binding(\r\n source_file,\r\n \"svelte\",\r\n \"untrack\",\r\n );\r\n\r\n const reserve_runtime_import = (name: string) =>\r\n top_level_binding_names_set.has(name)\r\n ? name_allocator.reserve(make_generated_name(name, \"\"))\r\n : name_allocator.reserve(name);\r\n\r\n const runtime_bindings: RuntimeImportBindings = {\r\n cancel: name_allocator.reserve(\"__SER___cancel\"),\r\n dispatcher: has_dispatcher_import\r\n ? \"get_dispatcher\"\r\n : reserve_runtime_import(\"get_dispatcher\"),\r\n dispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\r\n effect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\r\n program: name_allocator.reserve(\"__SER___program\"),\r\n untrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\r\n };\r\n\r\n const context: ScriptLoweringContext = {\r\n filename,\r\n dispatcher_name: runtime_bindings.dispatcher,\r\n effect_name: runtime_bindings.effect,\r\n emit_types,\r\n next_helper_name(hint?: string) {\r\n return name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\r\n },\r\n next_temp_name(hint?: string) {\r\n const suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\r\n const name = make_generated_name(hint ?? String(temp_counter), suffix);\r\n\r\n temp_counter += 1;\r\n\r\n return name_allocator.reserve(name);\r\n },\r\n next_type_helper_name(hint?: string) {\r\n return name_allocator.reserve(\r\n make_generated_name(`type_${hint ?? \"effect\"}`, \"\"),\r\n );\r\n },\r\n };\r\n\r\n /** Phase 2: lower every top-level statement that contains `yield*`. */\r\n for (const stmt of source_file.statements) {\r\n validate_rune_yield_usage(stmt, content, filename);\r\n validate_script_yield_boundaries(stmt, content, filename);\r\n\r\n const has_top_level_yield_star = contains_top_level_yield_star(stmt);\r\n\r\n if (!has_top_level_yield_star) {\r\n continue;\r\n }\r\n\r\n has_effect = true;\r\n const lowered = lower_statement(stmt, content, context);\r\n\r\n if (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\r\n const text = slice(content, stmt);\r\n throw new AwaitInEffectWorkError(filename, text);\r\n }\r\n\r\n magic.overwrite(\r\n lowered.range.start,\r\n lowered.range.end,\r\n lowered.rewritten_text,\r\n );\r\n\r\n if (lowered.temps.length > 0 || lowered.type_helpers?.length) {\r\n const temp_declarations = lowered.temps.map((temp) =>\r\n temp.type\r\n ? `let ${temp.name} = $state<${temp.type}>(undefined);`\r\n : `let ${temp.name} = $state(undefined);`\r\n );\r\n\r\n const prefix = [\r\n ...(lowered.type_helpers ?? []),\r\n ...temp_declarations,\r\n ].join(\"\\n\");\r\n\r\n magic.appendLeft(lowered.range.start, prefix + \"\\n\");\r\n }\r\n\r\n effect_blocks.push(...lowered.effect_blocks);\r\n uses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\r\n uses_effect_types ||= lowered.temps.some((temp) =>\r\n temp.type?.includes(`${runtime_bindings.effect}.Success`) ?? false\r\n );\r\n }\r\n\r\n if (!has_effect) {\r\n block_refs.push({ id: filename, kind: \"script\" });\r\n\r\n return { code: content, blocks: block_refs };\r\n }\r\n\r\n /** Phase 3: inject runtime imports after the last user import. */\r\n const imports = make_imports(\r\n has_effect_import,\r\n has_dispatcher_import,\r\n has_untrack_import,\r\n runtime_bindings,\r\n {\r\n needs_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\r\n needs_effect: effect_blocks.length > 0 || uses_effect_types,\r\n needs_untrack: effect_blocks.length > 0,\r\n },\r\n );\r\n\r\n const last_import = [...source_file.statements]\r\n .reverse()\r\n .find(ts.isImportDeclaration);\r\n\r\n if (imports) {\r\n if (last_import) {\r\n magic.appendRight(last_import.end, \"\\n\" + imports);\r\n } else {\r\n magic.prepend(imports + \"\\n\");\r\n }\r\n }\r\n\r\n /** Phase 4: append the runtime program and lifecycle wiring. */\r\n if (effect_blocks.length > 0) {\r\n const runtime_block = make_runtime_block_with_bindings(\r\n effect_blocks,\r\n runtime_bindings,\r\n );\r\n\r\n magic.append(\"\\n\" + runtime_block);\r\n }\r\n\r\n block_refs.push({ id: filename, kind: \"script\" });\r\n\r\n const code = magic.toString();\r\n\r\n return {\r\n code,\r\n blocks: block_refs,\r\n map: create_source_map(magic, filename),\r\n relocations: create_script_relocations(content, code, source_file),\r\n };\r\n}\r\n\r\nfunction create_script_relocations(\r\n content: string,\r\n code: string,\r\n source_file: ts.SourceFile,\r\n): Relocation[] {\r\n const candidates = source_file.statements.flatMap((stmt) => {\r\n const relocations: RelocationCandidate[] = [];\r\n\r\n if (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\r\n for (const decl of stmt.declarationList.declarations) {\r\n collect_binding_relocation_candidates(decl.name, relocations);\r\n }\r\n }\r\n\r\n collect_yield_star_nodes(stmt, (node) => {\r\n const text = content.slice(node.getStart(), node.end).trim();\r\n\r\n relocations.push({\r\n originalStart: node.getStart(),\r\n originalEnd: node.end,\r\n text,\r\n match: \"exact\",\r\n });\r\n });\r\n\r\n return relocations;\r\n });\r\n\r\n const used_ranges: Array<{ start: number; end: number }> = [];\r\n\r\n return candidates.flatMap((candidate) => {\r\n const generated_start = find_available_generated_text(\r\n code,\r\n candidate,\r\n used_ranges,\r\n );\r\n\r\n if (generated_start < 0) {\r\n return [];\r\n }\r\n\r\n const generated_end = generated_start + candidate.text.length;\r\n used_ranges.push({ start: generated_start, end: generated_end });\r\n\r\n return [{\r\n originalStart: candidate.originalStart,\r\n originalEnd: candidate.originalEnd,\r\n generatedStart: generated_start,\r\n generatedEnd: generated_end,\r\n }];\r\n });\r\n}\r\n\r\ntype RelocationCandidate = {\r\n originalStart: number;\r\n originalEnd: number;\r\n text: string;\r\n match: \"exact\" | \"identifier\";\r\n};\r\n\r\nfunction collect_binding_relocation_candidates(\r\n name: ts.BindingName,\r\n candidates: RelocationCandidate[],\r\n): void {\r\n if (ts.isIdentifier(name)) {\r\n candidates.push({\r\n originalStart: name.getStart(),\r\n originalEnd: name.end,\r\n text: name.text,\r\n match: \"identifier\",\r\n });\r\n\r\n return;\r\n }\r\n\r\n for (const element of name.elements) {\r\n if (ts.isOmittedExpression(element)) {\r\n continue;\r\n }\r\n\r\n collect_binding_relocation_candidates(element.name, candidates);\r\n }\r\n}\r\n\r\nfunction find_available_generated_text(\r\n code: string,\r\n candidate: RelocationCandidate,\r\n used_ranges: Array<{ start: number; end: number }>,\r\n): number {\r\n let search_start = 0;\r\n\r\n while (search_start < code.length) {\r\n const index = code.indexOf(candidate.text, search_start);\r\n\r\n if (index < 0) {\r\n return -1;\r\n }\r\n\r\n const end = index + candidate.text.length;\r\n const overlaps_used_range = used_ranges.some((range) =>\r\n index < range.end && end > range.start\r\n );\r\n const is_text_match = candidate.match === \"exact\" ||\r\n is_identifier_text_match(code, index, end);\r\n\r\n if (!overlaps_used_range && is_text_match) {\r\n return index;\r\n }\r\n\r\n search_start = candidate.match === \"identifier\" ? index + 1 : end;\r\n }\r\n\r\n return -1;\r\n}\r\n\r\nfunction is_identifier_text_match(\r\n code: string,\r\n start: number,\r\n end: number,\r\n): boolean {\r\n const before = start === 0 ? 0 : code.charCodeAt(start - 1);\r\n const after = end >= code.length ? 0 : code.charCodeAt(end);\r\n\r\n return !is_identifier_part(before) && !is_identifier_part(after);\r\n}\r\n\r\nfunction is_identifier_part(char_code: number): boolean {\r\n return (\r\n (char_code >= 65 && char_code <= 90) ||\r\n (char_code >= 97 && char_code <= 122) ||\r\n (char_code >= 48 && char_code <= 57) ||\r\n char_code === 36 ||\r\n char_code === 95\r\n );\r\n}\r\n\r\nfunction validate_script_yield_boundaries(\r\n stmt: ts.Statement,\r\n content: string,\r\n filename: string,\r\n): void {\r\n const bad_member = find_class_member_with_yield_star(stmt);\r\n\r\n if (!bad_member) {\r\n return;\r\n }\r\n\r\n throw new PreprocessError(\r\n [\r\n `[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\r\n `Class fields and methods are not component top-level reactive work. Move the Effect work into a script effect statement before assigning it to the class instance.`,\r\n \"\",\r\n \"Problematic member:\",\r\n slice(content, bad_member),\r\n ].join(\"\\n\"),\r\n filename,\r\n );\r\n}\r\n\r\nfunction find_class_member_with_yield_star(\r\n stmt: ts.Statement,\r\n): ts.Node | undefined {\r\n let found: ts.Node | undefined;\r\n\r\n function visit(node: ts.Node): void {\r\n if (found) {\r\n return;\r\n }\r\n\r\n if (\r\n ts.isPropertyDeclaration(node) &&\r\n node.initializer &&\r\n contains_top_level_yield_star(node.initializer)\r\n ) {\r\n found = node;\r\n return;\r\n }\r\n\r\n node.forEachChild(visit);\r\n }\r\n\r\n visit(stmt);\r\n\r\n return found;\r\n}\r\n\r\nfunction make_name_allocator(initial_names: readonly string[]): {\r\n reserve(name: string): string;\r\n} {\r\n const used_names = new Set(initial_names);\r\n\r\n return {\r\n reserve(name: string): string {\r\n let candidate = name;\r\n let suffix = 1;\r\n\r\n while (used_names.has(candidate)) {\r\n candidate = `${name}_${suffix}`;\r\n suffix += 1;\r\n }\r\n\r\n used_names.add(candidate);\r\n\r\n return candidate;\r\n },\r\n };\r\n}\r\n\r\nfunction make_generated_name(hint: string, suffix: string): string {\r\n const normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\r\n const safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\r\n ? normalized_hint\r\n : `temp_${normalized_hint}`;\r\n\r\n return `__SER___${safe_hint}${suffix}`;\r\n}\r\n","import {\r\n type MarkupTransformTarget,\r\n transform_markup_effect,\r\n} from \"$/markup/transform.ts\";\r\nimport { transform_script_effect } from \"$/script-transform/index.ts\";\r\n\r\n/**\r\n * Result returned by the direct whole-file Svelte transform.\r\n *\r\n * @example\r\n * ```ts\r\n * const result = transform_svelte_effect(\"<p>{yield* load()}</p>\", \"App.svelte\");\r\n * result.code;\r\n * ```\r\n *\r\n * @since 2.5.0\r\n */\r\nexport interface SvelteTransformResult {\r\n /** Transformed Svelte source. */\r\n code: string;\r\n}\r\n\r\n/**\r\n * Options accepted by the direct whole-file Svelte transform.\r\n *\r\n * @example\r\n * ```ts\r\n * const options: SvelteTransformOptions = { target: \"client\" };\r\n * ```\r\n *\r\n * @since 2.5.0\r\n */\r\nexport interface SvelteTransformOptions {\r\n /** Markup emission target passed through to the markup transform. */\r\n target?: MarkupTransformTarget;\r\n}\r\n\r\n/**\r\n * Lowers SER syntax in a complete Svelte component without using Svelte's\r\n * adapter API.\r\n *\r\n * @example\r\n * ```ts\r\n * const result = transform_svelte_effect(\r\n * \"<script effect>const value = yield* load()</script>\",\r\n * \"App.svelte\",\r\n * );\r\n * ```\r\n *\r\n * @since 2.5.0\r\n * @param content - Full Svelte component source to lower before Svelte parses\r\n * it.\r\n * @param filename - Component filename used in generated cache identifiers and\r\n * diagnostics.\r\n * @param options - Optional target configuration for markup lowering.\r\n * @returns The transformed component source.\r\n */\r\nexport function transform_svelte_effect(\r\n content: string,\r\n filename = \"unknown.svelte\",\r\n options: SvelteTransformOptions = {},\r\n): SvelteTransformResult {\r\n const script = find_script(content);\r\n\r\n let combined = content;\r\n\r\n if (script?.has_effect) {\r\n const result = transform_script_effect(script.text, filename, {\r\n emit_types: script.is_typescript,\r\n });\r\n\r\n combined = content.slice(0, script.effect_attr_start) +\r\n content.slice(script.effect_attr_end, script.open_end) +\r\n result.code +\r\n content.slice(script.close_start);\r\n }\r\n\r\n const result = transform_markup_effect(combined, filename, {\r\n target: options.target,\r\n });\r\n\r\n return { code: result.code };\r\n}\r\n\r\nfunction find_script(content: string):\r\n | {\r\n text: string;\r\n open_end: number;\r\n close_start: number;\r\n has_effect: boolean;\r\n effect_attr_start: number;\r\n effect_attr_end: number;\r\n is_typescript: boolean;\r\n }\r\n | undefined {\r\n const pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\r\n\r\n for (const match of content.matchAll(pattern)) {\r\n if (match.index === undefined || /\\bmodule\\b/.test(match[1] ?? \"\")) {\r\n continue;\r\n }\r\n\r\n const attrs = match[1] ?? \"\";\r\n const effect_match = /\\s+effect(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+))?/\r\n .exec(attrs);\r\n const open_end = match.index + match[0].indexOf(\">\") + 1;\r\n const attr_start = effect_match?.index ?? attrs.length;\r\n const attr_end = attr_start + (effect_match?.[0].length ?? 0);\r\n\r\n return {\r\n text: match[2],\r\n open_end,\r\n close_start: match.index + match[0].lastIndexOf(\"<\"),\r\n has_effect: effect_match !== null,\r\n effect_attr_start: match.index + \"<script\".length + attr_start,\r\n effect_attr_end: match.index + \"<script\".length + attr_end,\r\n is_typescript: has_typescript_lang(attrs),\r\n };\r\n }\r\n\r\n return undefined;\r\n}\r\n\r\nfunction has_typescript_lang(attrs: string): boolean {\r\n const lang_match = /\\blang\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i.exec(\r\n attrs,\r\n );\r\n const lang = (lang_match?.[1] ?? lang_match?.[2] ?? lang_match?.[3] ?? \"\")\r\n .toLowerCase();\r\n\r\n return lang === \"ts\" || lang === \"typescript\";\r\n}\r\n\r\nexport {\r\n type MarkupTransformOptions,\r\n type MarkupTransformResult,\r\n type MarkupTransformTarget,\r\n transform_markup_effect,\r\n} from \"$/markup/transform.ts\";\r\n\r\nexport {\r\n type BlockRef,\r\n type ScriptTransformResult,\r\n transform_script_effect,\r\n} from \"$/script-transform/index.ts\";\r\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,SAAgB,iCACd,QACA,UACQ;CACR,MAAM,eAAe,oBAAoB,MAAM;CAC/C,MAAM,YAAY,aAAa,KAAK,KAAK,QAAQ,KAAK,IAAI,EAAE;CAE5D,MAAM,OAAO,aAAa,WACvB,KAAK,cAAc,OAAO,WAAW,EACrC,KAAK,IAAI;CAEZ,OAAO;EACL;EACA;EACA,GAAG;EACH,WAAW,SAAS,iBAAiB,KAAK,SAAS,WAAW;EAC9D,WAAW,SAAS,QAAQ,KAAK,SAAS,OAAO;EACjD;EACA;EACA,WAAW,SAAS,OAAO,KAAK,SAAS,QAAQ,SAAS,SAAS,iBAAiB,QAAQ,SAAS,QAAQ;EAC7G,8BAA8B,SAAS,OAAO;EAC9C,YAAY,SAAS,OAAO;EAC5B;EACA;CACF,EAAE,KAAK,IAAI;AACb;AAEA,SAAS,oBAAoB,QAAoC;CAC/D,MAAM,aAAa,OAAO,SAAS,UAAU,MAAM,UAAU;CAC7D,MAAM,OAAO,OAAO,SAAS,UAAU,MAAM,IAAI;CAEjD,OAAO;EACL;EACA,MAAM,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC;CACzB;AACF;;;;;;;;;;;;ACvCA,SAAgB,gBACd,MACA,SACA,SACkB;CAClB,IAAI,GAAG,sBAAsB,IAAI,GAC/B,OAAO,2BAA2B,MAAM,SAAS,OAAO;CAG1D,IAAI,GAAG,oBAAoB,IAAI,GAC7B,OAAO,yBAAyB,MAAM,SAAS,OAAO;CAGxD,MAAM,OAAO,MAAM,SAAS,IAAI;CAEhC,OAAO;EACL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CACpC;CAMA,OAAO,EAAE,MAJM,wBAAwB,UAAU,UAAU,EACzD,QAAQ,QAAQ,OAClB,CAEoB,EAAE,KAAK;AAC7B;AAEA,SAAS,YAAY,SAUP;CAGZ,KAAK,MAAM,SAAS,QAAQ,SAAS,4CAAO,GAAG;EAC7C,IAAI,MAAM,UAAU,KAAA,KAAa,aAAa,KAAK,MAAM,MAAM,EAAE,GAC/D;EAGF,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,eAAe,mDAClB,KAAK,KAAK;EACb,MAAM,WAAW,MAAM,QAAQ,MAAM,GAAG,QAAQ,GAAG,IAAI;EACvD,MAAM,aAAa,cAAc,SAAS,MAAM;EAChD,MAAM,WAAW,cAAc,eAAe,GAAG,UAAU;EAE3D,OAAO;GACL,MAAM,MAAM;GACZ;GACA,aAAa,MAAM,QAAQ,MAAM,GAAG,YAAY,GAAG;GACnD,YAAY,iBAAiB;GAC7B,mBAAmB,MAAM,QAAQ,IAAmB;GACpD,iBAAiB,MAAM,QAAQ,IAAmB;GAClD,eAAe,oBAAoB,KAAK;EAC1C;CACF;AAGF;AAEA,SAAS,oBAAoB,OAAwB;CACnD,MAAM,aAAa,kDAAkD,KACnE,KACF;CACA,MAAM,QAAQ,aAAa,MAAM,aAAa,MAAM,aAAa,MAAM,IACpE,YAAY;CAEf,OAAO,SAAS,QAAQ,SAAS;AACnC"}
1
+ {"version":3,"file":"transform.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/script-transform/runtime-block.ts","../../../modules/svelte-effect-runtime/src/script-transform/lower.ts","../../../modules/svelte-effect-runtime/src/script-transform/index.ts","../../../modules/svelte-effect-runtime/src/runtime/transform.ts"],"sourcesContent":["import type { EffectBlock, RuntimeImportBindings } from \"./types.ts\";\n\n/**\n * Builds the runtime blocks appended to lowered script effect code.\n *\n * @since 2.0.0\n * @param blocks - Effect bodies and dependency reads to emit.\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\n */\nexport function make_runtime_block(blocks: EffectBlock[]): string {\n const bindings: RuntimeImportBindings = {\n cancel: \"__SER___cancel\",\n dispatcher: \"get_dispatcher\",\n dispatcher_value: \"__SER___dispatcher\",\n effect: \"Effect\",\n program: \"__SER___program\",\n untrack: \"untrack\",\n };\n\n return make_runtime_block_with_bindings(blocks, bindings);\n}\n\n/**\n * Builds the runtime blocks appended to lowered script effect code with\n * explicit runtime import bindings.\n *\n * @since 2.4.2\n * @param blocks - Effect bodies and dependency reads to emit.\n * @param bindings - Runtime binding names available in the generated code.\n * @returns Full `$effect` blocks that fork generated `Effect.gen` programs.\n */\nexport function make_runtime_block_with_bindings(\n blocks: EffectBlock[],\n bindings: RuntimeImportBindings,\n): string {\n const merged_block = merge_effect_blocks(blocks);\n const dep_reads = merged_block.deps.map((dep) => ` ${dep};`);\n\n const body = merged_block.statements\n .map((statement) => ` ${statement}`)\n .join(\"\\n\");\n\n return [\n \"\",\n \"$effect(() => {\",\n ...dep_reads,\n ` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n ` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n body,\n \" });\",\n ` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.fork(${bindings.program}));`,\n ` import.meta.hot?.dispose(${bindings.cancel});`,\n ` return ${bindings.cancel};`,\n \"});\",\n \"\",\n ].join(\"\\n\");\n}\n\nfunction merge_effect_blocks(blocks: EffectBlock[]): EffectBlock {\n const statements = blocks.flatMap((block) => block.statements);\n const deps = blocks.flatMap((block) => block.deps);\n\n return {\n statements,\n deps: [...new Set(deps)],\n };\n}\n","import { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport {\n collect_yield_star_nodes,\n find_yield_star_node,\n is_yield_star_expression,\n} from \"./ast.ts\";\nimport { slice, slice_start } from \"./source.ts\";\nimport type {\n EffectBlock,\n LoweredExpression,\n LoweredStatement,\n ScriptLoweringContext,\n TempBinding,\n} from \"./types.ts\";\n\nimport ts from \"typescript\";\n\n/**\n * Delegates a statement to the correct lowerer based on syntax kind.\n *\n * @since 2.0.0\n * @param stmt - Statement to lower.\n * @param content - Original source text.\n * @param context - Lowering services for this transform pass.\n * @returns Lowered statement descriptor.\n */\nexport function lower_statement(\n stmt: ts.Statement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n if (ts.isExpressionStatement(stmt)) {\n return lower_expression_statement(stmt, content, context);\n }\n\n if (ts.isVariableStatement(stmt)) {\n return lower_variable_statement(stmt, content, context);\n }\n\n const text = slice(content, stmt);\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [make_effect_block([text], collect_deps(text))],\n range: { start: stmt.getFullStart(), end: stmt.end },\n };\n}\n\nfunction lower_variable_statement(\n stmt: ts.VariableStatement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n const helper_declarations: string[] = [];\n const rewritten_decls: string[] = [];\n\n const decl_list = stmt.declarationList;\n const kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n let uses_dispatcher_promise = false;\n\n for (const decl of decl_list.declarations) {\n if (!contains_top_level_yield_star(decl)) {\n rewritten_decls.push(slice(content, decl).trim());\n continue;\n }\n\n const lowered = lower_node_yields_to_await(\n decl,\n content,\n make_binding_hint(decl.name),\n context,\n );\n\n helper_declarations.push(...lowered.helper_declarations);\n rewritten_decls.push(lowered.rewritten_text);\n uses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\n }\n\n const rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\n\n return {\n temps: [],\n type_helpers: helper_declarations,\n rewritten_text,\n effect_blocks: [],\n uses_dispatcher_promise,\n range: { start: stmt.getStart(), end: stmt.end },\n };\n}\n\nfunction lower_expression_statement(\n stmt: ts.ExpressionStatement,\n content: string,\n context: ScriptLoweringContext,\n): LoweredStatement {\n const expr = stmt.expression;\n\n if (!contains_top_level_yield_star(expr)) {\n return {\n temps: [],\n rewritten_text: slice(content, stmt).trim(),\n effect_blocks: [],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n if (is_yield_star_expression(expr)) {\n const text = slice(content, expr).trim();\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [make_effect_block([text + \";\"], collect_deps(text))],\n range: { start: stmt.getFullStart(), end: stmt.end },\n };\n }\n\n if (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n const target = slice(content, expr.left).trim();\n const target_names = collect_assignment_target_names(expr.left);\n\n if (\n expr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n is_yield_star_expression(expr.right)\n ) {\n const yield_text = extract_yield_star_full_text(expr.right, content);\n\n return {\n temps: [],\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [`${target} = ${yield_text};`],\n collect_deps(yield_text, target_names),\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const lowered = lower_expression_yields(\n expr.right,\n content,\n make_temp_hint(target),\n context,\n );\n const temp_names = lowered.temps.map((temp) => temp.name);\n const statement = `${target} ${\n slice(content, expr.operatorToken).trim()\n } ${lowered.rewritten_expr};`;\n\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [\n ...lowered.effect_blocks.flatMap((block) => block.statements),\n statement,\n ],\n [\n ...lowered.effect_blocks.flatMap((block) => block.deps),\n ...collect_deps(lowered.rewritten_expr, [\n ...target_names,\n ...temp_names,\n ]),\n ],\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const lowered = lower_expression_yields(\n expr,\n content,\n \"call\",\n context,\n );\n\n if (is_top_level_rune_call(expr)) {\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: lowered.rewritten_expr + \";\",\n effect_blocks: lowered.effect_blocks,\n range: { start: stmt.getStart(), end: stmt.end },\n };\n }\n\n const temp_names = lowered.temps.map((temp) => temp.name);\n\n return {\n temps: lowered.temps,\n type_helpers: lowered.type_helpers,\n rewritten_text: \"\",\n effect_blocks: [\n make_effect_block(\n [\n ...lowered.effect_blocks.flatMap((block) => block.statements),\n lowered.rewritten_expr + \";\",\n ],\n [\n ...lowered.effect_blocks.flatMap((block) => block.deps),\n ...collect_deps(lowered.rewritten_expr, temp_names),\n ],\n ),\n ],\n range: { start: stmt.getStart(), end: stmt.end },\n };\n}\n\nfunction lower_expression_yields(\n expr: ts.Expression,\n content: string,\n hint: string,\n context: ScriptLoweringContext,\n): LoweredExpression {\n const replacements: Array<{\n start: number;\n end: number;\n text: string;\n }> = [];\n\n const temps: TempBinding[] = [];\n const type_helpers: string[] = [];\n const statements: string[] = [];\n const deps: string[] = [];\n\n collect_yield_star_nodes(expr, (node) => {\n const temp_name = context.next_temp_name(hint);\n const yield_text = slice_start(content, node).trim();\n const type_helper = make_yield_type_helper(yield_text, hint, context);\n\n if (type_helper) {\n type_helpers.push(type_helper.declaration);\n temps.push({ name: temp_name, type: type_helper.type });\n } else {\n temps.push({ name: temp_name });\n }\n\n statements.push(`${temp_name} = ${yield_text};`);\n deps.push(...collect_deps(yield_text));\n replacements.push({\n start: node.getStart(),\n end: node.end,\n text: temp_name,\n });\n });\n\n if (replacements.length === 0) {\n return {\n temps,\n type_helpers,\n rewritten_expr: slice(content, expr).trim(),\n effect_blocks: [],\n };\n }\n\n replacements.sort((a, b) => b.start - a.start);\n\n let text = slice(content, expr);\n\n const offset_in_expr = expr.getFullStart();\n\n for (const replacement of replacements) {\n text = text.slice(0, replacement.start - offset_in_expr) +\n replacement.text +\n text.slice(replacement.end - offset_in_expr);\n }\n\n return {\n temps,\n type_helpers,\n rewritten_expr: text.trim(),\n effect_blocks: [make_effect_block(statements, deps)],\n };\n}\n\nfunction lower_node_yields_to_await(\n node: ts.Node,\n content: string,\n hint: string,\n context: ScriptLoweringContext,\n): {\n helper_declarations: string[];\n rewritten_text: string;\n uses_dispatcher_promise: boolean;\n} {\n const helper_declarations: string[] = [];\n const replacements: Array<{\n start: number;\n end: number;\n text: string;\n }> = [];\n\n collect_yield_star_nodes(node, (yield_node) => {\n const awaited = make_awaited_yield_expression(\n yield_node,\n content,\n hint,\n context,\n );\n\n helper_declarations.push(awaited.declaration);\n replacements.push({\n start: yield_node.getStart(),\n end: yield_node.end,\n text: awaited.expression,\n });\n });\n\n replacements.sort((a, b) => b.start - a.start);\n\n let text = slice_start(content, node);\n const offset_in_node = node.getStart();\n\n for (const replacement of replacements) {\n text = text.slice(0, replacement.start - offset_in_node) +\n replacement.text +\n text.slice(replacement.end - offset_in_node);\n }\n\n return {\n helper_declarations,\n rewritten_text: text.trim(),\n uses_dispatcher_promise: replacements.length > 0,\n };\n}\n\nfunction make_awaited_yield_expression(\n node: ts.Node,\n content: string,\n hint: string,\n context: ScriptLoweringContext,\n): { declaration: string; expression: string } {\n const yield_text = slice_start(content, node).trim();\n const helper_name = context.next_helper_name(`effect_${hint}`);\n const helper_id = make_script_effect_id(node, context);\n const deps = collect_deps(yield_text);\n const deps_text = `[${deps.join(\", \")}]`;\n\n return {\n declaration: `function* ${helper_name}() { return (${yield_text}); }`,\n expression: [\n `await ${context.dispatcher_name}().promise({`,\n `id: ${JSON.stringify(helper_id)}, `,\n `deps: ${deps_text}, `,\n `factory: () => ${helper_name}()`,\n `})`,\n ].join(\"\"),\n };\n}\n\nfunction make_yield_type_helper(\n yield_text: string,\n hint: string,\n context: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n if (!context.emit_types) {\n return undefined;\n }\n\n const helper_name = context.next_type_helper_name(hint);\n const effect_text = strip_yield_star(yield_text);\n\n return {\n declaration: `function ${helper_name}() { return (${effect_text}); }`,\n type:\n `${context.effect_name}.Success<ReturnType<typeof ${helper_name}>> | undefined`,\n };\n}\n\nfunction strip_yield_star(yield_text: string): string {\n return yield_text.replace(/^yield\\*\\s*/, \"\");\n}\n\nfunction make_script_effect_id(\n expr: ts.Node,\n context: ScriptLoweringContext,\n): string {\n return `${context.filename}:${expr.getStart()}:${expr.end}`;\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n return expr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n expr.operatorToken.kind <= ts.SyntaxKind.LastAssignment;\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n if (!ts.isCallExpression(expr)) {\n return false;\n }\n\n const callee = expr.expression;\n\n if (ts.isIdentifier(callee)) {\n return callee.text.startsWith(\"$\");\n }\n\n return ts.isPropertyAccessExpression(callee) &&\n ts.isIdentifier(callee.expression) &&\n callee.expression.text.startsWith(\"$\");\n}\n\nfunction make_temp_hint(target: string): string {\n const match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n return match?.[0] ?? \"assignment\";\n}\n\nfunction make_binding_hint(name: ts.BindingName): string {\n if (ts.isIdentifier(name)) {\n return name.text;\n }\n\n return \"destructure\";\n}\n\nfunction extract_yield_star_full_text(\n expr: ts.Expression,\n content: string,\n): string {\n let found: string | undefined;\n\n find_yield_star_node(expr, (node) => {\n found = slice_start(content, node).trim();\n });\n\n return found ?? \"undefined\";\n}\n\nfunction make_effect_block(\n statements: string[],\n deps: string[],\n): EffectBlock {\n return {\n statements,\n deps: [...new Set(deps)],\n };\n}\n\nfunction collect_deps(\n expr_text: string,\n excluded_names: readonly string[] = [],\n): string[] {\n const excluded = new Set(excluded_names);\n\n return collect_free_identifiers(expr_text).filter(\n (identifier) =>\n !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n );\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n if (ts.isIdentifier(node)) {\n return [node.text];\n }\n\n if (ts.isParenthesizedExpression(node)) {\n return collect_assignment_target_names(node.expression);\n }\n\n if (\n ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)\n ) {\n return collect_assignment_target_names(node.expression);\n }\n\n if (ts.isObjectLiteralExpression(node)) {\n return node.properties.flatMap((property) => {\n if (ts.isShorthandPropertyAssignment(property)) {\n return [property.name.text];\n }\n\n if (ts.isPropertyAssignment(property)) {\n return collect_assignment_target_names(property.initializer);\n }\n\n if (ts.isSpreadAssignment(property)) {\n return collect_assignment_target_names(property.expression);\n }\n\n return [];\n });\n }\n\n if (ts.isArrayLiteralExpression(node)) {\n return node.elements.flatMap((element) =>\n ts.isSpreadElement(element)\n ? collect_assignment_target_names(element.expression)\n : collect_assignment_target_names(element)\n );\n }\n\n return [];\n}\n","import { contains_top_level_yield_star } from \"$/detect.ts\";\nimport {\n collect_top_level_binding_names,\n has_local_import_binding,\n make_imports,\n} from \"./imports.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport type {\n BlockRef,\n EffectBlock,\n Relocation,\n RuntimeImportBindings,\n ScriptLoweringContext,\n ScriptTransformResult,\n} from \"./types.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n emit_types?: boolean;\n}\n\n/**\n * Transforms a `<script effect>` body by lowering top-level `yield*`\n * expressions into Svelte-compatible async rendering declarations or into\n * dependency-tracked `$effect` blocks for effectful statements.\n *\n * @example\n * ```ts\n * const result = transform_script_effect(\n * `let user = $state(yield* getUser(id));`,\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.0.0\n * @param content - The raw `<script effect>` body content.\n * @param filename - The source filename, used in error messages.\n * @param options - Optional transform settings for generated script code.\n * @returns The transformed code and any block references.\n */\nexport function transform_script_effect(\n content: string,\n filename: string,\n options: ScriptTransformOptions = {},\n): ScriptTransformResult {\n let temp_counter = 0;\n\n const source_file = ts.createSourceFile(\n filename,\n content,\n ts.ScriptTarget.Latest,\n true,\n ts.ScriptKind.TS,\n );\n\n const magic = new MagicString(content);\n const effect_blocks: EffectBlock[] = [];\n const block_refs: BlockRef[] = [];\n const top_level_binding_names = collect_top_level_binding_names(source_file);\n const top_level_binding_names_set = new Set(top_level_binding_names);\n const name_allocator = make_name_allocator(top_level_binding_names);\n const emit_types = options.emit_types ?? true;\n\n let has_effect = false;\n let uses_dispatcher_promise = false;\n let uses_effect_types = false;\n\n /** Phase 1: detect imports already provided by the user. */\n const has_effect_import = has_local_import_binding(\n source_file,\n \"effect\",\n \"Effect\",\n );\n\n const has_dispatcher_import = has_local_import_binding(\n source_file,\n \"svelte-effect-runtime/internal/generators\",\n \"get_dispatcher\",\n );\n\n const has_untrack_import = has_local_import_binding(\n source_file,\n \"svelte\",\n \"untrack\",\n );\n\n const reserve_runtime_import = (name: string) =>\n top_level_binding_names_set.has(name)\n ? name_allocator.reserve(make_generated_name(name, \"\"))\n : name_allocator.reserve(name);\n\n const runtime_bindings: RuntimeImportBindings = {\n cancel: name_allocator.reserve(\"__SER___cancel\"),\n dispatcher: has_dispatcher_import\n ? \"get_dispatcher\"\n : reserve_runtime_import(\"get_dispatcher\"),\n dispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n effect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n program: name_allocator.reserve(\"__SER___program\"),\n untrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n };\n\n const context: ScriptLoweringContext = {\n filename,\n dispatcher_name: runtime_bindings.dispatcher,\n effect_name: runtime_bindings.effect,\n emit_types,\n next_helper_name(hint?: string) {\n return name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\n },\n next_temp_name(hint?: string) {\n const suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n const name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n temp_counter += 1;\n\n return name_allocator.reserve(name);\n },\n next_type_helper_name(hint?: string) {\n return name_allocator.reserve(\n make_generated_name(`type_${hint ?? \"effect\"}`, \"\"),\n );\n },\n };\n\n /** Phase 2: lower every top-level statement that contains `yield*`. */\n for (const stmt of source_file.statements) {\n validate_rune_yield_usage(stmt, content, filename);\n validate_script_yield_boundaries(stmt, content, filename);\n\n const has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n if (!has_top_level_yield_star) {\n continue;\n }\n\n has_effect = true;\n const lowered = lower_statement(stmt, content, context);\n\n if (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\n const text = slice(content, stmt);\n throw new AwaitInEffectWorkError(filename, text);\n }\n\n magic.overwrite(\n lowered.range.start,\n lowered.range.end,\n lowered.rewritten_text,\n );\n\n if (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n const temp_declarations = lowered.temps.map((temp) =>\n temp.type\n ? `let ${temp.name} = $state<${temp.type}>(undefined);`\n : `let ${temp.name} = $state(undefined);`\n );\n\n const prefix = [\n ...(lowered.type_helpers ?? []),\n ...temp_declarations,\n ].join(\"\\n\");\n\n magic.appendLeft(lowered.range.start, prefix + \"\\n\");\n }\n\n effect_blocks.push(...lowered.effect_blocks);\n uses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\n uses_effect_types ||= lowered.temps.some((temp) =>\n temp.type?.includes(`${runtime_bindings.effect}.Success`) ?? false\n );\n }\n\n if (!has_effect) {\n block_refs.push({ id: filename, kind: \"script\" });\n\n return { code: content, blocks: block_refs };\n }\n\n /** Phase 3: inject runtime imports after the last user import. */\n const imports = make_imports(\n has_effect_import,\n has_dispatcher_import,\n has_untrack_import,\n runtime_bindings,\n {\n needs_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\n needs_effect: effect_blocks.length > 0 || uses_effect_types,\n needs_untrack: effect_blocks.length > 0,\n },\n );\n\n const last_import = [...source_file.statements]\n .reverse()\n .find(ts.isImportDeclaration);\n\n if (imports) {\n if (last_import) {\n magic.appendRight(last_import.end, \"\\n\" + imports);\n } else {\n magic.prepend(imports + \"\\n\");\n }\n }\n\n /** Phase 4: append the runtime program and lifecycle wiring. */\n if (effect_blocks.length > 0) {\n const runtime_block = make_runtime_block_with_bindings(\n effect_blocks,\n runtime_bindings,\n );\n\n magic.append(\"\\n\" + runtime_block);\n }\n\n block_refs.push({ id: filename, kind: \"script\" });\n\n const code = magic.toString();\n\n return {\n code,\n blocks: block_refs,\n map: create_source_map(magic, filename),\n relocations: create_script_relocations(content, code, source_file),\n };\n}\n\nfunction create_script_relocations(\n content: string,\n code: string,\n source_file: ts.SourceFile,\n): Relocation[] {\n const candidates = source_file.statements.flatMap((stmt) => {\n const relocations: RelocationCandidate[] = [];\n\n if (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\n for (const decl of stmt.declarationList.declarations) {\n collect_binding_relocation_candidates(decl.name, relocations);\n }\n }\n\n collect_yield_star_nodes(stmt, (node) => {\n const text = content.slice(node.getStart(), node.end).trim();\n\n relocations.push({\n originalStart: node.getStart(),\n originalEnd: node.end,\n text,\n match: \"exact\",\n });\n });\n\n return relocations;\n });\n\n const used_ranges: Array<{ start: number; end: number }> = [];\n\n return candidates.flatMap((candidate) => {\n const generated_start = find_available_generated_text(\n code,\n candidate,\n used_ranges,\n );\n\n if (generated_start < 0) {\n return [];\n }\n\n const generated_end = generated_start + candidate.text.length;\n used_ranges.push({ start: generated_start, end: generated_end });\n\n return [{\n originalStart: candidate.originalStart,\n originalEnd: candidate.originalEnd,\n generatedStart: generated_start,\n generatedEnd: generated_end,\n }];\n });\n}\n\ntype RelocationCandidate = {\n originalStart: number;\n originalEnd: number;\n text: string;\n match: \"exact\" | \"identifier\";\n};\n\nfunction collect_binding_relocation_candidates(\n name: ts.BindingName,\n candidates: RelocationCandidate[],\n): void {\n if (ts.isIdentifier(name)) {\n candidates.push({\n originalStart: name.getStart(),\n originalEnd: name.end,\n text: name.text,\n match: \"identifier\",\n });\n\n return;\n }\n\n for (const element of name.elements) {\n if (ts.isOmittedExpression(element)) {\n continue;\n }\n\n collect_binding_relocation_candidates(element.name, candidates);\n }\n}\n\nfunction find_available_generated_text(\n code: string,\n candidate: RelocationCandidate,\n used_ranges: Array<{ start: number; end: number }>,\n): number {\n let search_start = 0;\n\n while (search_start < code.length) {\n const index = code.indexOf(candidate.text, search_start);\n\n if (index < 0) {\n return -1;\n }\n\n const end = index + candidate.text.length;\n const overlaps_used_range = used_ranges.some((range) =>\n index < range.end && end > range.start\n );\n const is_text_match = candidate.match === \"exact\" ||\n is_identifier_text_match(code, index, end);\n\n if (!overlaps_used_range && is_text_match) {\n return index;\n }\n\n search_start = candidate.match === \"identifier\" ? index + 1 : end;\n }\n\n return -1;\n}\n\nfunction is_identifier_text_match(\n code: string,\n start: number,\n end: number,\n): boolean {\n const before = start === 0 ? 0 : code.charCodeAt(start - 1);\n const after = end >= code.length ? 0 : code.charCodeAt(end);\n\n return !is_identifier_part(before) && !is_identifier_part(after);\n}\n\nfunction is_identifier_part(char_code: number): boolean {\n return (\n (char_code >= 65 && char_code <= 90) ||\n (char_code >= 97 && char_code <= 122) ||\n (char_code >= 48 && char_code <= 57) ||\n char_code === 36 ||\n char_code === 95\n );\n}\n\nfunction validate_script_yield_boundaries(\n stmt: ts.Statement,\n content: string,\n filename: string,\n): void {\n const bad_member = find_class_member_with_yield_star(stmt);\n\n if (!bad_member) {\n return;\n }\n\n throw new PreprocessError(\n [\n `[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n `Class fields and methods are not component top-level reactive work. Move the Effect work into a script effect statement before assigning it to the class instance.`,\n \"\",\n \"Problematic member:\",\n slice(content, bad_member),\n ].join(\"\\n\"),\n filename,\n );\n}\n\nfunction find_class_member_with_yield_star(\n stmt: ts.Statement,\n): ts.Node | undefined {\n let found: ts.Node | undefined;\n\n function visit(node: ts.Node): void {\n if (found) {\n return;\n }\n\n if (\n ts.isPropertyDeclaration(node) &&\n node.initializer &&\n contains_top_level_yield_star(node.initializer)\n ) {\n found = node;\n return;\n }\n\n node.forEachChild(visit);\n }\n\n visit(stmt);\n\n return found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n reserve(name: string): string;\n} {\n const used_names = new Set(initial_names);\n\n return {\n reserve(name: string): string {\n let candidate = name;\n let suffix = 1;\n\n while (used_names.has(candidate)) {\n candidate = `${name}_${suffix}`;\n suffix += 1;\n }\n\n used_names.add(candidate);\n\n return candidate;\n },\n };\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n const normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n const safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n ? normalized_hint\n : `temp_${normalized_hint}`;\n\n return `__SER___${safe_hint}${suffix}`;\n}\n","import {\n type MarkupTransformTarget,\n transform_markup_effect,\n} from \"$/markup/transform.ts\";\nimport { transform_script_effect } from \"$/script-transform/index.ts\";\n\n/**\n * Result returned by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\"<p>{yield* load()}</p>\", \"App.svelte\");\n * result.code;\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformResult {\n /** Transformed Svelte source. */\n code: string;\n}\n\n/**\n * Options accepted by the direct whole-file Svelte transform.\n *\n * @example\n * ```ts\n * const options: SvelteTransformOptions = { target: \"client\" };\n * ```\n *\n * @since 2.5.0\n */\nexport interface SvelteTransformOptions {\n /** Markup emission target passed through to the markup transform. */\n target?: MarkupTransformTarget;\n}\n\n/**\n * Lowers SER syntax in a complete Svelte component without using Svelte's\n * adapter API.\n *\n * @example\n * ```ts\n * const result = transform_svelte_effect(\n * \"<script effect>const value = yield* load()</script>\",\n * \"App.svelte\",\n * );\n * ```\n *\n * @since 2.5.0\n * @param content - Full Svelte component source to lower before Svelte parses\n * it.\n * @param filename - Component filename used in generated cache identifiers and\n * diagnostics.\n * @param options - Optional target configuration for markup lowering.\n * @returns The transformed component source.\n */\nexport function transform_svelte_effect(\n content: string,\n filename = \"unknown.svelte\",\n options: SvelteTransformOptions = {},\n): SvelteTransformResult {\n const script = find_script(content);\n\n let combined = content;\n\n if (script?.has_effect) {\n const result = transform_script_effect(script.text, filename, {\n emit_types: script.is_typescript,\n });\n\n combined = content.slice(0, script.effect_attr_start) +\n content.slice(script.effect_attr_end, script.open_end) +\n result.code +\n content.slice(script.close_start);\n }\n\n const result = transform_markup_effect(combined, filename, {\n target: options.target,\n });\n\n return { code: result.code };\n}\n\nfunction find_script(content: string):\n | {\n text: string;\n open_end: number;\n close_start: number;\n has_effect: boolean;\n effect_attr_start: number;\n effect_attr_end: number;\n is_typescript: boolean;\n }\n | undefined {\n const pattern = /<script\\b([^>]*)>([\\s\\S]*?)<\\/script\\s*>/gi;\n\n for (const match of content.matchAll(pattern)) {\n if (match.index === undefined || /\\bmodule\\b/.test(match[1] ?? \"\")) {\n continue;\n }\n\n const attrs = match[1] ?? \"\";\n const effect_match = /\\s+effect(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s>]+))?/\n .exec(attrs);\n const open_end = match.index + match[0].indexOf(\">\") + 1;\n const attr_start = effect_match?.index ?? attrs.length;\n const attr_end = attr_start + (effect_match?.[0].length ?? 0);\n\n return {\n text: match[2],\n open_end,\n close_start: match.index + match[0].lastIndexOf(\"<\"),\n has_effect: effect_match !== null,\n effect_attr_start: match.index + \"<script\".length + attr_start,\n effect_attr_end: match.index + \"<script\".length + attr_end,\n is_typescript: has_typescript_lang(attrs),\n };\n }\n\n return undefined;\n}\n\nfunction has_typescript_lang(attrs: string): boolean {\n const lang_match = /\\blang\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s>]+))/i.exec(\n attrs,\n );\n const lang = (lang_match?.[1] ?? lang_match?.[2] ?? lang_match?.[3] ?? \"\")\n .toLowerCase();\n\n return lang === \"ts\" || lang === \"typescript\";\n}\n\nexport {\n type MarkupTransformOptions,\n type MarkupTransformResult,\n type MarkupTransformTarget,\n transform_markup_effect,\n} from \"$/markup/transform.ts\";\n\nexport {\n type BlockRef,\n type ScriptTransformResult,\n transform_script_effect,\n} from \"$/script-transform/index.ts\";\n"],"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D;EAGF,MAAM,QAAQ,MAAM,MAAM;EAC1B,MAAM,eAAe,mDAClB,KAAK,KAAK;EACb,MAAM,WAAW,MAAM,QAAQ,MAAM,GAAG,QAAQ,GAAG,IAAI;EACvD,MAAM,aAAa,cAAc,SAAS,MAAM;EAChD,MAAM,WAAW,cAAc,eAAe,GAAG,UAAU;EAE3D,OAAO;GACL,MAAM,MAAM;GACZ;GACA,aAAa,MAAM,QAAQ,MAAM,GAAG,YAAY,GAAG;GACnD,YAAY,iBAAiB;GAC7B,mBAAmB,MAAM,QAAQ,IAAmB;GACpD,iBAAiB,MAAM,QAAQ,IAAmB;GAClD,eAAe,oBAAoB,KAAK;EAC1C;CACF;AAGF;AAEA,SAAS,oBAAoB,OAAwB;CACnD,MAAM,aAAa,kDAAkD,KACnE,KACF;CACA,MAAM,QAAQ,aAAa,MAAM,aAAa,MAAM,aAAa,MAAM,IACpE,YAAY;CAEf,OAAO,SAAS,QAAQ,SAAS;AACnC"}
package/.dist/server.js CHANGED
@@ -1,8 +1,8 @@
1
- import { C as UncheckedLiveQueryHandlerMissingError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, c as InvalidLiveQueryReturnError, i as BatchQueryHandlerMissingError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError } from "./chunks/errors-Buz9cLGF.js";
1
+ import { C as UncheckedLiveQueryHandlerMissingError, S as UncheckedFormHandlerMissingError, T as UncheckedQueryHandlerMissingError, c as InvalidLiveQueryReturnError, i as BatchQueryHandlerMissingError, w as UncheckedPrerenderHandlerMissingError, x as UncheckedCommandHandlerMissingError } from "./chunks/errors-0PaWf7Bq.js";
2
2
  import { create_form_error } from "./remote/shared.js";
3
3
  import { t as copy_property_descriptors } from "./chunks/descriptors-OS4VfJuW.js";
4
4
  import { normalize_remote_helper_error, run_remote_effect } from "./remote/server.js";
5
- import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-L7xbXCiW.js";
5
+ import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-BXbxv4Ai.js";
6
6
  import { Effect, Schema, Stream } from "effect";
7
7
  import { error, invalid, redirect } from "@sveltejs/kit";
8
8
  import { command, form, getRequestEvent, prerender, query } from "$app/server";