svelte-effect-runtime 4.1.0 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dist/chunks/{client-DbwVAMWm.js → client-CkxjaRTA.js} +2 -2
- package/.dist/chunks/{client-DbwVAMWm.js.map → client-CkxjaRTA.js.map} +1 -1
- package/.dist/chunks/{dispatcher-CTWINW5I.js → dispatcher-B6ZRUsjN.js} +139 -44
- package/.dist/chunks/dispatcher-B6ZRUsjN.js.map +1 -0
- package/.dist/chunks/{dispatcher-pZPzarul.js → dispatcher-D8j5wTx6.js} +3 -3
- package/.dist/chunks/{dispatcher-pZPzarul.js.map → dispatcher-D8j5wTx6.js.map} +1 -1
- package/.dist/chunks/{runtime-CPosEhGl.js → runtime-B8RHHy3v.js} +2 -2
- package/.dist/chunks/{runtime-CPosEhGl.js.map → runtime-B8RHHy3v.js.map} +1 -1
- package/.dist/chunks/server-NeyeDSax.js +339 -0
- package/.dist/chunks/server-NeyeDSax.js.map +1 -0
- package/.dist/chunks/{transform-D7TTlPpK.js → transform-C0jW8Qta.js} +38 -5
- package/.dist/chunks/transform-C0jW8Qta.js.map +1 -0
- package/.dist/dispatcher.js +1 -1
- package/.dist/environment.d.ts +87 -0
- package/.dist/environment.js +44 -0
- package/.dist/environment.js.map +1 -0
- package/.dist/internal/generators.js +2 -2
- package/.dist/internal/remote-client.js +1 -1
- package/.dist/internal/remote-server.js +2 -2
- package/.dist/markup/promise.js +1 -1
- package/.dist/markup/run.js +1 -1
- package/.dist/markup/transform.js +1 -1
- package/.dist/markup/value.js +1 -1
- package/.dist/mod.d.ts +2 -0
- package/.dist/mod.js +3 -2
- package/.dist/mod.js.map +1 -1
- package/.dist/remote/cause-codec.d.ts +35 -0
- package/.dist/remote/client.js +1 -1
- package/.dist/remote/diagnostics.d.ts +67 -0
- package/.dist/remote/server.d.ts +26 -2
- package/.dist/remote/server.js +2 -2
- package/.dist/runtime/transform.js +12 -7
- package/.dist/runtime/transform.js.map +1 -1
- package/.dist/script-transform/imports.d.ts +1 -1
- package/.dist/server.js +6 -6
- package/.dist/server.js.map +1 -1
- package/package.json +5 -1
- package/.dist/chunks/dispatcher-CTWINW5I.js.map +0 -1
- package/.dist/chunks/server-yQrNoiCR.js +0 -144
- package/.dist/chunks/server-yQrNoiCR.js.map +0 -1
- package/.dist/chunks/transform-D7TTlPpK.js.map +0 -1
package/.dist/markup/value.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as get_dispatcher } from "../chunks/dispatcher-
|
|
1
|
+
import { n as get_dispatcher } from "../chunks/dispatcher-D8j5wTx6.js";
|
|
2
2
|
//#region src/markup/value.ts
|
|
3
3
|
/** Reads a transform-generated reactive value through the active dispatcher. */
|
|
4
4
|
function value(id, deps, fallback, factory) {
|
package/.dist/mod.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ import type { CommandFactory, FormFactory, PrerenderFactory, QueryFactory, Serve
|
|
|
2
2
|
import type { ErrorEffectFactory, RedirectEffectFactory } from "./server/control-flow.js";
|
|
3
3
|
import type { RequestEvent as RequestEventShape } from "./server/runtime.js";
|
|
4
4
|
import type { Context, Layer, ManagedRuntime } from "effect";
|
|
5
|
+
export { DefineEnvVars } from "./environment.js";
|
|
6
|
+
export type { EnvironmentDefinition, EnvironmentSchema, EnvironmentSchemaOutput, EnvironmentVariable, EnvironmentVariables, } from "./environment.js";
|
|
5
7
|
/**
|
|
6
8
|
* Public API surface for `svelte-effect-runtime`.
|
|
7
9
|
*
|
package/.dist/mod.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { A as UnsupportedMarkupEffectPositionError, C as ServerOnlyImportError, D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMissingError, M as YieldStarInEventCallbackError, O as UncheckedPrerenderHandlerMissingError, S as ScopeDisposedError, T as UncheckedCommandHandlerMissingError, _ as RemoteHelperContextError, a as DispatcherDisposedError, b as RuntimeAlreadyInitializedError, c as InvalidLiveQueryFactoryError, d as InvalidQueryFactoryError, f as InvalidRemoteFormResponseError, g as RemoteFormEndpointMissingError, h as RemoteErrorDecodeError, i as BatchQueryHandlerMissingError, j as UnsupportedRemoteFormResponseError, k as UncheckedQueryHandlerMissingError, l as InvalidLiveQueryReturnError, m as PreprocessError, n as AsyncEffectInSyncRuneError, o as EmptyStreamYieldError, p as InvalidYieldableError, r as AwaitInEffectWorkError, s as InvalidCommandFactoryError, t as AsyncEffectInEventCallbackError, u as InvalidPrerenderFactoryError, v as RemoteHelperError, w as SvelteKitServerExportUnavailableError, x as RuntimeError, y as RequestEventUnavailableError } from "./chunks/errors-qhcbUH6o.js";
|
|
2
|
-
import { n as Dispatcher } from "./chunks/dispatcher-
|
|
2
|
+
import { n as Dispatcher } from "./chunks/dispatcher-B6ZRUsjN.js";
|
|
3
|
+
import { DefineEnvVars } from "./environment.js";
|
|
3
4
|
import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
|
|
4
5
|
import { t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
5
6
|
import { t as effect } from "./chunks/compiler-Dpyu4Owd.js";
|
|
@@ -192,6 +193,6 @@ function make_server_only_error(name) {
|
|
|
192
193
|
return new ServerOnlyImportError(name);
|
|
193
194
|
}
|
|
194
195
|
//#endregion
|
|
195
|
-
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DispatcherDisposedError, EmptyStreamYieldError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidPrerenderFactoryError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, InvalidYieldableError, Live, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ScopeDisposedError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
|
|
196
|
+
export { AsyncEffectInEventCallbackError, AsyncEffectInSyncRuneError, AwaitInEffectWorkError, BatchQueryHandlerMissingError, ClientRuntime, Command, DefineEnvVars, DispatcherDisposedError, EmptyStreamYieldError, Error, Form, InvalidCommandFactoryError, InvalidLiveQueryFactoryError, InvalidLiveQueryReturnError, InvalidPrerenderFactoryError, InvalidQueryFactoryError, InvalidRemoteFormResponseError, InvalidYieldableError, Live, PreprocessError, Prerender, Query, Redirect, RemoteErrorDecodeError, RemoteFormEndpointMissingError, RemoteHelperContextError, RemoteHelperError, RequestEvent, RequestEventUnavailableError, RuntimeAlreadyInitializedError, RuntimeError, ScopeDisposedError, ServerOnlyImportError, ServerRuntime, SvelteKitServerExportUnavailableError, UncheckedCommandHandlerMissingError, UncheckedFormHandlerMissingError, UncheckedLiveQueryHandlerMissingError, UncheckedPrerenderHandlerMissingError, UncheckedQueryHandlerMissingError, UnsupportedMarkupEffectPositionError, UnsupportedRemoteFormResponseError, YieldStarInEventCallbackError, effect, get_server_runtime_or_throw, is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error };
|
|
196
197
|
|
|
197
198
|
//# sourceMappingURL=mod.js.map
|
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 type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tScopeDisposedError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidPrerenderFactoryError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tInvalidYieldableError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\nexport { effect, type EffectOptions } from \"$/compiler.ts\";\n\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderInputs,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAuGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
|
|
1
|
+
{"version":3,"file":"mod.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/mod.ts"],"sourcesContent":["import type {\n\tCommandFactory,\n\tFormFactory,\n\tPrerenderFactory,\n\tQueryFactory,\n\tServerRuntimeFactory,\n} from \"$/server/types.ts\";\nimport type { ErrorEffectFactory, RedirectEffectFactory } from \"$/server/control-flow.ts\";\nimport type { RequestEvent as RequestEventShape } from \"$/server/runtime.ts\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport type { Context, Layer, ManagedRuntime } from \"effect\";\nimport { ServerOnlyImportError } from \"$/errors.ts\";\n\nexport { DefineEnvVars } from \"$/environment.ts\";\nexport type {\n\tEnvironmentDefinition,\n\tEnvironmentSchema,\n\tEnvironmentSchemaOutput,\n\tEnvironmentVariable,\n\tEnvironmentVariables,\n} from \"$/environment.ts\";\n\n/**\n * Public API surface for `svelte-effect-runtime`.\n *\n * Call {@link ClientRuntime.make} in `hooks.client.ts`, call\n * {@link ServerRuntime.make} in `hooks.server.ts`, and let the Vite plugin\n * route server-only helpers to the server entrypoint automatically.\n *\n * @module\n */\n\n/**\n * Client-side runtime singleton. Call `ClientRuntime.make(layer?)` once\n * in `hooks.client.ts` to provide services to every component's effect\n * blocks.\n *\n * If never called, a default empty-layer runtime is created lazily on\n * the first `yield*` expression.\n *\n * @example\n * ```ts\n * import { ClientRuntime } from \"svelte-effect-runtime\";\n * import { Db } from \"./db.ts\";\n *\n * ClientRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ClientRuntime {\n\t/**\n\t * Build and cache the client-side dispatcher runtime.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): void {\n\t\tInternalDispatcher.make(layer);\n\t}\n}\n\n/**\n * Server-side runtime singleton export. In SvelteKit server files the Vite\n * plugin rewrites root imports to `svelte-effect-runtime/server`, so this\n * name resolves to the real server implementation before it is evaluated.\n *\n * @example\n * ```ts\n * import { ServerRuntime } from \"svelte-effect-runtime\";\n *\n * ServerRuntime.make();\n * ```\n *\n * @since 2.0.0\n */\nexport const ServerRuntime: ServerRuntimeFactory = make_server_only_class(\"ServerRuntime\") as never;\n\n/**\n * Remote query factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Query } from \"svelte-effect-runtime\";\n *\n * export const GetPosts = Query(Effect.succeed([]));\n * ```\n *\n * @since 2.0.0\n */\nexport const Query: QueryFactory = Object.assign(make_server_only_function(\"Query\"), {\n\tbatch: make_server_only_function(\"Query.batch\"),\n\tlive: make_server_only_function(\"Query.live\"),\n}) as never;\n\n/**\n * Remote command factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Command } from \"svelte-effect-runtime\";\n *\n * export const SavePost = Command(Schema.String, (id) => Effect.succeed(id));\n * ```\n *\n * @since 2.0.0\n */\nexport const Command: CommandFactory = make_server_only_function(\"Command\") as never;\n\n/**\n * SvelteKit HTTP error control-flow export for `.remote.ts` files imported\n * from the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Error } from \"svelte-effect-runtime\";\n *\n * return yield* Error(\"NotFound\", \"Post not found\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Error: ErrorEffectFactory = make_server_only_function(\"Error\") as never;\n\n/**\n * Remote form factory export for `.remote.ts` files imported from the root\n * entrypoint. The Vite plugin rewrites it to the real server implementation.\n *\n * @example\n * ```ts\n * import { Form } from \"svelte-effect-runtime\";\n *\n * export const CreatePost = Form(PostInput, ({ data }) => Effect.succeed(data));\n * ```\n *\n * @since 2.0.0\n */\nexport const Form: FormFactory = make_server_only_function(\"Form\") as never;\n\n/**\n * Remote prerender factory export for `.remote.ts` files imported from the\n * root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Prerender } from \"svelte-effect-runtime\";\n *\n * export const GetBuildInfo = Prerender(() => Effect.succeed(\"ready\"));\n * ```\n *\n * @since 2.0.0\n */\nexport const Prerender: PrerenderFactory = make_server_only_function(\"Prerender\") as never;\n\nexport { Live } from \"$/live.ts\";\n\n/**\n * SvelteKit redirect control-flow export for `.remote.ts` files imported from\n * the root entrypoint. The Vite plugin rewrites it to the real server\n * implementation.\n *\n * @example\n * ```ts\n * import { Redirect } from \"svelte-effect-runtime\";\n *\n * return yield* Redirect(\"SeeOther\", \"/posts\");\n * ```\n *\n * @since 2.3.0\n */\nexport const Redirect: RedirectEffectFactory = make_server_only_function(\"Redirect\") as never;\n\n/**\n * Current SvelteKit request event service export for `.remote.ts` files\n * imported from the root entrypoint. The Vite plugin rewrites it to the real\n * server implementation.\n *\n * @example\n * ```ts\n * import { RequestEvent } from \"svelte-effect-runtime\";\n *\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEventShape> = make_server_only_function(\n\t\"RequestEvent\",\n) as never;\n\n/**\n * Returns the active server runtime when imported from a server file. The Vite\n * plugin rewrites root imports to the real server implementation.\n *\n * @example\n * ```ts\n * import { get_server_runtime_or_throw } from \"svelte-effect-runtime\";\n *\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n */\nexport const get_server_runtime_or_throw: () => ManagedRuntime.ManagedRuntime<unknown, never> =\n\tmake_server_only_function(\"get_server_runtime_or_throw\") as never;\n\nexport type {\n\tFormError,\n\tFormIssue,\n\tRemoteFailure,\n\tRemoteHttpError,\n\tRemoteTransportError,\n\tRemoteValidationError,\n} from \"$/remote/shared.ts\";\n\nexport {\n\tAsyncEffectInEventCallbackError,\n\tAsyncEffectInSyncRuneError,\n\tAwaitInEffectWorkError,\n\tBatchQueryHandlerMissingError,\n\tDispatcherDisposedError,\n\tEmptyStreamYieldError,\n\tScopeDisposedError,\n\tInvalidCommandFactoryError,\n\tInvalidLiveQueryFactoryError,\n\tInvalidLiveQueryReturnError,\n\tInvalidPrerenderFactoryError,\n\tInvalidQueryFactoryError,\n\tInvalidRemoteFormResponseError,\n\tInvalidYieldableError,\n\tPreprocessError,\n\tRemoteErrorDecodeError,\n\tRemoteFormEndpointMissingError,\n\tRemoteHelperContextError,\n\tRemoteHelperError,\n\tRequestEventUnavailableError,\n\tRuntimeAlreadyInitializedError,\n\tRuntimeError,\n\tServerOnlyImportError,\n\tSvelteKitServerExportUnavailableError,\n\tUncheckedCommandHandlerMissingError,\n\tUncheckedFormHandlerMissingError,\n\tUncheckedLiveQueryHandlerMissingError,\n\tUncheckedPrerenderHandlerMissingError,\n\tUncheckedQueryHandlerMissingError,\n\tUnsupportedMarkupEffectPositionError,\n\tUnsupportedRemoteFormResponseError,\n\tYieldStarInEventCallbackError,\n} from \"$/errors.ts\";\n\nexport {\n\tis_form_error,\n\tis_remote_http_error,\n\tis_remote_transport_error,\n\tis_remote_validation_error,\n} from \"$/remote/shared.ts\";\n\nexport { effect, type EffectOptions } from \"$/compiler.ts\";\n\nexport type {\n\tErrorBody,\n\tErrorEffectFactory,\n\tErrorProperties,\n\tErrorStatus,\n\tErrorStatusName,\n\tRedirectEffectFactory,\n\tRedirectOptions,\n\tRedirectStatus,\n\tRedirectStatusName,\n} from \"$/server/control-flow.ts\";\n\nexport type { LiveFactory, LiveStatus, RemoteLiveStream } from \"$/live.ts\";\n\nexport type {\n\tCommandFactory,\n\tEffectLike,\n\tEffectRemoteBatchHandler,\n\tEffectRemoteCommand,\n\tEffectRemoteCommandCall,\n\tEffectRemoteForm,\n\tEffectRemoteFunction,\n\tEffectRemoteLiveQuery,\n\tEffectRemoteLiveQueryFunction,\n\tEffectRemotePrerender,\n\tEffectRemotePrerenderFunction,\n\tEffectRemoteQuery,\n\tEffectRemoteQueryFunction,\n\tFormFactory,\n\tFormInvalid,\n\tPrerenderFactory,\n\tPrerenderInputs,\n\tPrerenderOptions,\n\tQueryBatchFactory,\n\tQueryFactory,\n\tQueryLiveFactory,\n\tRemoteFormHandler,\n\tRemoteHandler,\n\tRemoteLiveHandler,\n\tRemoteLiveSource,\n\tSchemaEncodedInput,\n\tSchemaInput,\n\tServerRuntimeFactory,\n\tStandardSchema,\n\tStandardSchemaInput,\n\tStandardSchemaOutput,\n} from \"$/server/types.ts\";\n\nfunction make_server_only_class(name: string): unknown {\n\treturn class ServerOnlyRuntime {\n\t\tstatic make(): never {\n\t\t\tthrow make_server_only_error(name);\n\t\t}\n\t};\n}\n\nfunction make_server_only_function(name: string): (...args: unknown[]) => never {\n\treturn (..._args: unknown[]): never => {\n\t\tthrow make_server_only_error(name);\n\t};\n}\n\nfunction make_server_only_error(name: string): globalThis.Error {\n\treturn new ServerOnlyImportError(name);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkDA,IAAa,gBAAb,MAA2B;;;;;;;CAO1B,OAAO,KAAgB,OAA8B;EACpD,WAAmB,KAAK,KAAK;CAC9B;AACD;;;;;;;;;;;;;;;AAgBA,MAAa,gBAAsC,uBAAuB,eAAe;;;;;;;;;;;;;;AAezF,MAAa,QAAsB,OAAO,OAAO,0BAA0B,OAAO,GAAG;CACpF,OAAO,0BAA0B,aAAa;CAC9C,MAAM,0BAA0B,YAAY;AAC7C,CAAC;;;;;;;;;;;;;;AAeD,MAAa,UAA0B,0BAA0B,SAAS;;;;;;;;;;;;;;;AAgB1E,MAAa,QAA4B,0BAA0B,OAAO;;;;;;;;;;;;;;AAe1E,MAAa,OAAoB,0BAA0B,MAAM;;;;;;;;;;;;;;;AAgBjE,MAAa,YAA8B,0BAA0B,WAAW;;;;;;;;;;;;;;;AAkBhF,MAAa,WAAkC,0BAA0B,UAAU;;;;;;;;;;;;;;;AAgBnF,MAAa,eAAqD,0BACjE,cACD;;;;;;;;;;;;;;AAeA,MAAa,8BACZ,0BAA0B,6BAA6B;AAuGxD,SAAS,uBAAuB,MAAuB;CACtD,OAAO,MAAM,kBAAkB;EAC9B,OAAO,OAAc;GACpB,MAAM,uBAAuB,IAAI;EAClC;CACD;AACD;AAEA,SAAS,0BAA0B,MAA6C;CAC/E,QAAQ,GAAG,UAA4B;EACtC,MAAM,uBAAuB,IAAI;CAClC;AACD;AAEA,SAAS,uBAAuB,MAAgC;CAC/D,OAAO,IAAI,sBAAsB,IAAI;AACtC"}
|
|
@@ -1,5 +1,25 @@
|
|
|
1
|
+
import type { OpaqueRemoteFailureReason } from "./diagnostics.js";
|
|
1
2
|
import { type FormIssue } from "./shared.js";
|
|
2
3
|
import { Cause } from "effect";
|
|
4
|
+
/**
|
|
5
|
+
* Records that a failure lost its detail on the way to the client, so callers
|
|
6
|
+
* can report the original error instead of dropping it silently.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* const diagnostic: OpaqueRemoteFailure = { reason: "untagged", value: err };
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* @since 4.2.0
|
|
14
|
+
*/
|
|
15
|
+
export type OpaqueRemoteFailure = {
|
|
16
|
+
readonly reason: OpaqueRemoteFailureReason;
|
|
17
|
+
readonly value: unknown;
|
|
18
|
+
};
|
|
19
|
+
type EncodedRemoteFailure = {
|
|
20
|
+
readonly encoded: string;
|
|
21
|
+
readonly opaque?: OpaqueRemoteFailure;
|
|
22
|
+
};
|
|
3
23
|
export type RemoteCauseResolution = {
|
|
4
24
|
readonly _tag: "SvelteKitControlFlow";
|
|
5
25
|
readonly value: unknown;
|
|
@@ -12,8 +32,23 @@ export type RemoteCauseResolution = {
|
|
|
12
32
|
} | {
|
|
13
33
|
readonly _tag: "RemoteFailure";
|
|
14
34
|
readonly encoded: string;
|
|
35
|
+
readonly opaque?: OpaqueRemoteFailure;
|
|
15
36
|
};
|
|
16
37
|
/** Preserves SvelteKit control flow before classifying transportable Effect failures. */
|
|
17
38
|
export declare function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution;
|
|
18
39
|
/** Encodes a remote failure into the transport ABI shared with generated clients. */
|
|
19
40
|
export declare function encode_remote_failure(cause: Cause.Cause<unknown>): string;
|
|
41
|
+
/**
|
|
42
|
+
* Encodes a remote failure and reports whether its detail survived encoding.
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* ```ts
|
|
46
|
+
* const { encoded, opaque } = encode_remote_failure_detailed(cause);
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @since 4.2.0
|
|
50
|
+
* @param cause - Cause carrying the handler's failure.
|
|
51
|
+
* @returns The encoded payload and, when detail was lost, why.
|
|
52
|
+
*/
|
|
53
|
+
export declare function encode_remote_failure_detailed(cause: Cause.Cause<unknown>): EncodedRemoteFailure;
|
|
54
|
+
export {};
|
package/.dist/remote/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-
|
|
1
|
+
import { a as create_remote_command_adapter, i as create_remote_form_adapter, n as create_remote_query_adapter, r as create_remote_prerender_adapter, t as create_remote_live_query_adapter } from "../chunks/client-CkxjaRTA.js";
|
|
2
2
|
export { create_remote_command_adapter, create_remote_form_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_query_adapter };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Cause } from "effect";
|
|
2
|
+
/**
|
|
3
|
+
* Why a remote failure reached the client without its original detail.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```ts
|
|
7
|
+
* const reason: OpaqueRemoteFailureReason = "untagged";
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* @since 4.2.0
|
|
11
|
+
*/
|
|
12
|
+
export type OpaqueRemoteFailureReason = "untagged" | "unserializable" | "unknown" | "interrupted";
|
|
13
|
+
/**
|
|
14
|
+
* Request detail attached to an opaque remote failure report so the log line
|
|
15
|
+
* points at the handler that produced it.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const context: RemoteFailureContext = { method: "POST", url: "/checkout" };
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @since 4.2.0
|
|
23
|
+
*/
|
|
24
|
+
export type RemoteFailureContext = {
|
|
25
|
+
readonly method?: string;
|
|
26
|
+
readonly route?: string;
|
|
27
|
+
readonly url?: string;
|
|
28
|
+
};
|
|
29
|
+
type Reporter = (message: string) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Reports a remote failure that had to be replaced with an opaque envelope.
|
|
32
|
+
*
|
|
33
|
+
* SER cannot send an unrecognized failure to the browser, so the client only
|
|
34
|
+
* ever sees a generic 500. Without this report the original error would be
|
|
35
|
+
* lost entirely, which is the difference between a debuggable failure and a
|
|
36
|
+
* silent one.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* report_opaque_remote_failure("untagged", cause, value, { url: "/checkout" });
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* @since 4.2.0
|
|
44
|
+
* @param reason - Why the failure could not be transported.
|
|
45
|
+
* @param cause - Full Effect cause behind the failure.
|
|
46
|
+
* @param value - The original failure value, when one was found.
|
|
47
|
+
* @param context - Optional request detail for the log header.
|
|
48
|
+
* @param report - Sink for the rendered report; defaults to `console.error`.
|
|
49
|
+
*/
|
|
50
|
+
export declare function report_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause<unknown>, value: unknown, context?: RemoteFailureContext, report?: Reporter): void;
|
|
51
|
+
/**
|
|
52
|
+
* Renders the report emitted by {@link report_opaque_remote_failure}.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* const message = render_opaque_remote_failure("untagged", cause, value);
|
|
57
|
+
* ```
|
|
58
|
+
*
|
|
59
|
+
* @since 4.2.0
|
|
60
|
+
* @param reason - Why the failure could not be transported.
|
|
61
|
+
* @param cause - Full Effect cause behind the failure.
|
|
62
|
+
* @param value - The original failure value, when one was found.
|
|
63
|
+
* @param context - Optional request detail for the log header.
|
|
64
|
+
* @returns The multi-line report.
|
|
65
|
+
*/
|
|
66
|
+
export declare function render_opaque_remote_failure(reason: OpaqueRemoteFailureReason, cause: Cause.Cause<unknown>, value: unknown, context?: RemoteFailureContext): string;
|
|
67
|
+
export {};
|
package/.dist/remote/server.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RemoteFailureContext } from "./diagnostics.js";
|
|
1
2
|
import type { FormIssue } from "./shared.js";
|
|
2
3
|
import { Cause, Effect } from "effect";
|
|
3
4
|
type SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;
|
|
@@ -6,9 +7,32 @@ export { encode_remote_failure } from "./cause-codec.js";
|
|
|
6
7
|
/** Maps a remote Effect exit into the control flow expected by SvelteKit. */
|
|
7
8
|
export declare function run_remote_effect<A>(effect: Effect.Effect<A, unknown, unknown>, runtime: {
|
|
8
9
|
runPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;
|
|
9
|
-
}, invalid: SvelteInvalid, error: SvelteError): Promise<A>;
|
|
10
|
+
}, invalid: SvelteInvalid, error: SvelteError, context?: RemoteFailureContext): Promise<A>;
|
|
10
11
|
/** Applies a classified remote Cause decision to SvelteKit's server helpers. */
|
|
11
|
-
export declare function throw_remote_cause(cause: Cause.Cause<unknown>, invalid: SvelteInvalid, error: SvelteError): never;
|
|
12
|
+
export declare function throw_remote_cause(cause: Cause.Cause<unknown>, invalid: SvelteInvalid, error: SvelteError, context?: RemoteFailureContext, report?: (message: string) => void): never;
|
|
13
|
+
/**
|
|
14
|
+
* Describes the request a remote failure occurred in.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* const context = to_remote_failure_context(event);
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @since 4.2.0
|
|
22
|
+
* @param event - Request event the handler ran under.
|
|
23
|
+
* @returns Request detail for opaque failure reports.
|
|
24
|
+
*/
|
|
25
|
+
export declare function to_remote_failure_context(event: {
|
|
26
|
+
readonly request?: {
|
|
27
|
+
readonly method?: string;
|
|
28
|
+
};
|
|
29
|
+
readonly route?: {
|
|
30
|
+
readonly id?: string | null;
|
|
31
|
+
};
|
|
32
|
+
readonly url?: {
|
|
33
|
+
readonly pathname?: string;
|
|
34
|
+
};
|
|
35
|
+
}): RemoteFailureContext;
|
|
12
36
|
export declare function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never;
|
|
13
37
|
/** Rebrands SvelteKit context failures with the remote helper that triggered them. */
|
|
14
38
|
export declare function normalize_remote_helper_error(err: unknown, helper_name: string): Error;
|
package/.dist/remote/server.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause };
|
|
1
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, o as encode_remote_failure, r as throw_form_error, t as normalize_remote_helper_error } from "../chunks/server-NeyeDSax.js";
|
|
2
|
+
export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { m as PreprocessError, r as AwaitInEffectWorkError } from "../chunks/errors-qhcbUH6o.js";
|
|
2
|
-
import { a as slice_start, c as find_yield_star_node, d as collect_top_level_binding_names, f as has_local_import_binding, i as slice, l as is_yield_star_expression, n as validate_rune_yield_usage, o as collect_yield_star_nodes, p as make_imports, r as create_source_map, s as contains_top_level_await, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-
|
|
2
|
+
import { a as slice_start, c as find_yield_star_node, d as collect_top_level_binding_names, f as has_local_import_binding, i as slice, l as is_yield_star_expression, n as validate_rune_yield_usage, o as collect_yield_star_nodes, p as make_imports, r as create_source_map, s as contains_top_level_await, t as transform_markup_effect, u as collect_free_identifiers } from "../chunks/transform-C0jW8Qta.js";
|
|
3
3
|
import { t as scan_svelte_effect_source } from "../chunks/source-scan-cSawCvsg.js";
|
|
4
4
|
import { contains_top_level_yield_star } from "../detect.js";
|
|
5
5
|
import ts from "typescript";
|
|
@@ -327,7 +327,7 @@ function collect_assignment_target_names(node) {
|
|
|
327
327
|
*/
|
|
328
328
|
function transform_script_effect(content, filename, options = {}) {
|
|
329
329
|
let temp_counter = 0;
|
|
330
|
-
const
|
|
330
|
+
const target = options.target ?? "client";
|
|
331
331
|
const source_file = ts.createSourceFile(filename, content, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
|
|
332
332
|
const magic = new MagicString(content);
|
|
333
333
|
const effect_blocks = [];
|
|
@@ -337,13 +337,14 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
337
337
|
const name_allocator = make_name_allocator(top_level_binding_names);
|
|
338
338
|
const emit_types = options.emit_types ?? true;
|
|
339
339
|
let has_effect = false;
|
|
340
|
+
let first_effect_statement_start = content.length;
|
|
340
341
|
let uses_dispatcher_promise = false;
|
|
341
342
|
let uses_yield_success_types = false;
|
|
342
343
|
/** Phase 1: detect imports already provided by the user. */
|
|
343
344
|
const has_effect_import = has_local_import_binding(source_file, "effect", "Effect");
|
|
344
345
|
const has_dispatcher_import = has_local_import_binding(source_file, "svelte-effect-runtime/internal/generators", "get_dispatcher");
|
|
345
346
|
const has_untrack_import = has_local_import_binding(source_file, "svelte", "untrack");
|
|
346
|
-
const has_on_destroy_import = has_local_import_binding(source_file, "svelte", "onDestroy");
|
|
347
|
+
const has_on_destroy_import = has_local_import_binding(source_file, "svelte", "onDestroy", false);
|
|
347
348
|
const reserve_runtime_import = (name) => top_level_binding_names_set.has(name) ? name_allocator.reserve(make_generated_name(name, "")) : name_allocator.reserve(name);
|
|
348
349
|
const runtime_bindings = {
|
|
349
350
|
cancel: name_allocator.reserve("__SER___cancel"),
|
|
@@ -386,6 +387,7 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
386
387
|
if (!contains_top_level_yield_star(stmt)) continue;
|
|
387
388
|
has_effect = true;
|
|
388
389
|
const lowered = lower_statement(stmt, content, context);
|
|
390
|
+
first_effect_statement_start = Math.min(first_effect_statement_start, lowered.range.start);
|
|
389
391
|
if (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) throw new AwaitInEffectWorkError(filename, slice(content, stmt));
|
|
390
392
|
magic.overwrite(lowered.range.start, lowered.range.end, lowered.rewritten_text);
|
|
391
393
|
if (lowered.temps.length > 0 || lowered.type_helpers?.length) {
|
|
@@ -412,15 +414,18 @@ function transform_script_effect(content, filename, options = {}) {
|
|
|
412
414
|
needs_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,
|
|
413
415
|
needs_effect: effect_blocks.length > 0,
|
|
414
416
|
needs_untrack: effect_blocks.length > 0,
|
|
415
|
-
|
|
417
|
+
/** The server never registers disposal, so it never needs the import. */
|
|
418
|
+
needs_on_destroy: target !== "server",
|
|
416
419
|
needs_yield_success: uses_yield_success_types,
|
|
417
420
|
needs_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,
|
|
418
421
|
needs_scope_ref: true
|
|
419
422
|
});
|
|
420
423
|
const last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);
|
|
421
|
-
const
|
|
422
|
-
|
|
423
|
-
|
|
424
|
+
const injection_point = last_import ? Math.min(last_import.end, first_effect_statement_start) : first_effect_statement_start;
|
|
425
|
+
const injected = [imports, [`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`, ...target === "server" ? [] : [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`]].join("\n")].filter(Boolean).join("\n");
|
|
426
|
+
if (last_import && last_import.end <= first_effect_statement_start) magic.appendRight(last_import.end, "\n" + injected);
|
|
427
|
+
else if (injection_point >= 0) magic.appendLeft(injection_point, injected + "\n");
|
|
428
|
+
else magic.appendLeft(first_effect_statement_start, injected + "\n");
|
|
424
429
|
/** Phase 4: append the runtime program blocks. */
|
|
425
430
|
if (effect_blocks.length > 0) {
|
|
426
431
|
const runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);
|
|
@@ -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\";\n\nexport function make_runtime_block_with_bindings(\n\tblocks: EffectBlock[],\n\tbindings: RuntimeImportBindings,\n): string {\n\treturn blocks.map((block) => make_runtime_effect_block(block, bindings)).join(\"\\n\");\n}\n\nfunction make_runtime_effect_block(block: EffectBlock, bindings: RuntimeImportBindings): string {\n\tconst dep_reads = block.deps.map((dep) => ` ${dep};`);\n\n\tconst body = block.statements.map((statement) => ` ${statement}`).join(\"\\n\");\n\n\treturn [\n\t\t\"\",\n\t\t\"$effect(() => {\",\n\t\t...dep_reads,\n\t\t` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n\t\t` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n\t\tbody,\n\t\t\" });\",\n\t\t` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.run_scoped(${bindings.scope}.scope, ${bindings.program}));`,\n\t\t` import.meta.hot?.dispose(${bindings.cancel});`,\n\t\t` return ${bindings.cancel};`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n","import type {\n\tEffectBlock,\n\tLoweredExpression,\n\tLoweredStatement,\n\tScriptLoweringContext,\n\tTempBinding,\n} from \"./types.ts\";\nimport { collect_yield_star_nodes, find_yield_star_node, is_yield_star_expression } from \"./ast.ts\";\nimport { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { slice, slice_start } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nexport function lower_statement(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tif (ts.isExpressionStatement(stmt)) {\n\t\treturn lower_expression_statement(stmt, content, context);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn lower_variable_statement(stmt, content, context);\n\t}\n\n\tconst text = slice(content, stmt);\n\tconst wrapped_text = wrap_yield_stars_in_node(stmt, content, context);\n\n\treturn {\n\t\ttemps: [],\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [make_effect_block([wrapped_text], collect_deps(text))],\n\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_variable_statement(\n\tstmt: ts.VariableStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst helper_declarations: string[] = [];\n\tconst rewritten_decls: string[] = [];\n\n\tconst decl_list = stmt.declarationList;\n\tconst kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n\tlet uses_dispatcher_promise = false;\n\n\tfor (const decl of decl_list.declarations) {\n\t\tif (!contains_top_level_yield_star(decl)) {\n\t\t\trewritten_decls.push(slice(content, decl).trim());\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst lowered = lower_node_yields_to_await(\n\t\t\tdecl,\n\t\t\tcontent,\n\t\t\tmake_binding_hint(decl.name),\n\t\t\tcontext,\n\t\t);\n\n\t\thelper_declarations.push(...lowered.helper_declarations);\n\t\trewritten_decls.push(lowered.rewritten_text);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\n\t}\n\n\tconst rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\n\n\treturn {\n\t\ttemps: [],\n\t\ttype_helpers: helper_declarations,\n\t\trewritten_text,\n\t\teffect_blocks: [],\n\t\tuses_dispatcher_promise,\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_statement(\n\tstmt: ts.ExpressionStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst expr = stmt.expression;\n\n\tif (!contains_top_level_yield_star(expr)) {\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: slice(content, stmt).trim(),\n\t\t\teffect_blocks: [],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (is_yield_star_expression(expr)) {\n\t\tconst text = slice(content, expr).trim();\n\t\tconst yield_text = wrap_yield_text(text, context);\n\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [make_effect_block([yield_text + \";\"], collect_deps(text))],\n\t\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n\t\tconst target = slice(content, expr.left).trim();\n\t\tconst target_names = collect_assignment_target_names(expr.left);\n\n\t\tif (\n\t\t\texpr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n\t\t\tis_yield_star_expression(expr.right)\n\t\t) {\n\t\t\tconst yield_text = extract_yield_star_full_text(expr.right, content);\n\t\t\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\t\t\treturn {\n\t\t\t\ttemps: [],\n\t\t\t\trewritten_text: \"\",\n\t\t\t\teffect_blocks: [\n\t\t\t\t\tmake_effect_block(\n\t\t\t\t\t\t[`${target} = ${wrapped_yield_text};`],\n\t\t\t\t\t\tcollect_deps(yield_text, target_names),\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t\t};\n\t\t}\n\n\t\tconst lowered = lower_expression_yields(\n\t\t\texpr.right,\n\t\t\tcontent,\n\t\t\tmake_temp_hint(target),\n\t\t\tcontext,\n\t\t);\n\t\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\t\tconst statement = `${target} ${slice(\n\t\t\tcontent,\n\t\t\texpr.operatorToken,\n\t\t).trim()} ${lowered.rewritten_expr};`;\n\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [\n\t\t\t\tmake_effect_block(\n\t\t\t\t\t[...lowered.effect_blocks.flatMap((block) => block.statements), statement],\n\t\t\t\t\t[\n\t\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t\t...collect_deps(lowered.rewritten_expr, [...target_names, ...temp_names]),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst lowered = lower_expression_yields(expr, content, \"call\", context);\n\n\tif (is_top_level_rune_call(expr)) {\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: lowered.rewritten_expr + \";\",\n\t\t\teffect_blocks: lowered.effect_blocks,\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\n\treturn {\n\t\ttemps: lowered.temps,\n\t\ttype_helpers: lowered.type_helpers,\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [\n\t\t\tmake_effect_block(\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.statements),\n\t\t\t\t\tlowered.rewritten_expr + \";\",\n\t\t\t\t],\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t...collect_deps(lowered.rewritten_expr, temp_names),\n\t\t\t\t],\n\t\t\t),\n\t\t],\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_yields(\n\texpr: ts.Expression,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): LoweredExpression {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tconst temps: TempBinding[] = [];\n\tconst type_helpers: string[] = [];\n\tconst statements: string[] = [];\n\tconst deps: string[] = [];\n\n\tcollect_yield_star_nodes(expr, (node) => {\n\t\tconst temp_name = context.next_temp_name(hint);\n\t\tconst yield_text = slice_start(content, node).trim();\n\t\tconst type_helper = make_yield_type_helper(yield_text, hint, context);\n\n\t\tif (type_helper) {\n\t\t\ttype_helpers.push(type_helper.declaration);\n\t\t\ttemps.push({ name: temp_name, type: type_helper.type });\n\t\t} else {\n\t\t\ttemps.push({ name: temp_name });\n\t\t}\n\n\t\tstatements.push(`${temp_name} = ${wrap_yield_text(yield_text, context)};`);\n\t\tdeps.push(...collect_deps(yield_text));\n\t\treplacements.push({\n\t\t\tstart: node.getStart(),\n\t\t\tend: node.end,\n\t\t\ttext: temp_name,\n\t\t});\n\t});\n\n\tif (replacements.length === 0) {\n\t\treturn {\n\t\t\ttemps,\n\t\t\ttype_helpers,\n\t\t\trewritten_expr: slice(content, expr).trim(),\n\t\t\teffect_blocks: [],\n\t\t};\n\t}\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice(content, expr);\n\n\tconst offset_in_expr = expr.getFullStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_expr) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_expr);\n\t}\n\n\treturn {\n\t\ttemps,\n\t\ttype_helpers,\n\t\trewritten_expr: text.trim(),\n\t\teffect_blocks: [make_effect_block(statements, deps)],\n\t};\n}\n\nfunction lower_node_yields_to_await(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): {\n\thelper_declarations: string[];\n\trewritten_text: string;\n\tuses_dispatcher_promise: boolean;\n} {\n\tconst helper_declarations: string[] = [];\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst awaited = make_awaited_yield_expression(yield_node, content, hint, context);\n\n\t\thelper_declarations.push(awaited.declaration);\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: awaited.expression,\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice_start(content, node);\n\tconst offset_in_node = node.getStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_node) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_node);\n\t}\n\n\treturn {\n\t\thelper_declarations,\n\t\trewritten_text: text.trim(),\n\t\tuses_dispatcher_promise: replacements.length > 0,\n\t};\n}\n\nfunction make_awaited_yield_expression(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; expression: string } {\n\tconst yield_text = slice_start(content, node).trim();\n\tconst helper_name = context.next_helper_name(`effect_${hint}`);\n\tconst helper_id = make_script_effect_id(node, context);\n\tconst deps = collect_deps(yield_text);\n\tconst deps_text = `[${deps.join(\", \")}]`;\n\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\treturn {\n\t\tdeclaration: `function* ${helper_name}() { return (${wrapped_yield_text}); }`,\n\t\texpression: [\n\t\t\t`await ${context.dispatcher_name}().with_scope(${context.scope_name}.scope, () => ${context.dispatcher_name}().promise({`,\n\t\t\t`id: ${JSON.stringify(helper_id)}, `,\n\t\t\t`deps: ${deps_text}, `,\n\t\t\t`factory: () => ${helper_name}()`,\n\t\t\t`}))`,\n\t\t].join(\"\"),\n\t};\n}\n\nfunction make_yield_type_helper(\n\tyield_text: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n\tif (!context.emit_types) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_name = context.next_type_helper_name(hint);\n\tconst effect_text = strip_yield_star(yield_text);\n\n\treturn {\n\t\tdeclaration: `function ${helper_name}() { return (${effect_text}); }`,\n\t\ttype: `${context.yield_success_name}<ReturnType<typeof ${helper_name}>> | undefined`,\n\t};\n}\n\nfunction strip_yield_star(yield_text: string): string {\n\treturn yield_text.replace(/^yield\\s*\\*\\s*/, \"\");\n}\n\nfunction wrap_yield_text(yield_text: string, context: ScriptLoweringContext): string {\n\treturn `yield* ${context.yieldable_name}(${strip_yield_star(yield_text)})`;\n}\n\nfunction wrap_yield_stars_in_node(\n\tnode: ts.Node,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): string {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst yield_text = slice_start(content, yield_node).trim();\n\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: wrap_yield_text(yield_text, context),\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tconst offset = node.getFullStart();\n\tlet text = slice(content, node);\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset);\n\t}\n\n\treturn text.trim();\n}\n\nfunction make_script_effect_id(expr: ts.Node, context: ScriptLoweringContext): string {\n\treturn `${context.filename}:${expr.getStart()}:${expr.end}`;\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n\treturn (\n\t\texpr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n\t\texpr.operatorToken.kind <= ts.SyntaxKind.LastAssignment\n\t);\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n\tif (!ts.isCallExpression(expr)) {\n\t\treturn false;\n\t}\n\n\tconst callee = expr.expression;\n\n\tif (ts.isIdentifier(callee)) {\n\t\treturn callee.text.startsWith(\"$\");\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(callee) &&\n\t\tts.isIdentifier(callee.expression) &&\n\t\tcallee.expression.text.startsWith(\"$\")\n\t);\n}\n\nfunction make_temp_hint(target: string): string {\n\tconst match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n\treturn match?.[0] ?? \"assignment\";\n}\n\nfunction make_binding_hint(name: ts.BindingName): string {\n\tif (ts.isIdentifier(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn \"destructure\";\n}\n\nfunction extract_yield_star_full_text(expr: ts.Expression, content: string): string {\n\tlet found: string | undefined;\n\n\tfind_yield_star_node(expr, (node) => {\n\t\tfound = slice_start(content, node).trim();\n\t});\n\n\treturn found ?? \"undefined\";\n}\n\nfunction make_effect_block(statements: string[], deps: string[]): EffectBlock {\n\treturn {\n\t\tstatements,\n\t\tdeps: [...new Set(deps)],\n\t};\n}\n\nfunction collect_deps(expr_text: string, excluded_names: readonly string[] = []): string[] {\n\tconst excluded = new Set(excluded_names);\n\n\treturn collect_free_identifiers(expr_text).filter(\n\t\t(identifier) => !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n\t);\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n\tif (ts.isIdentifier(node)) {\n\t\treturn [node.text];\n\t}\n\n\tif (ts.isParenthesizedExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isObjectLiteralExpression(node)) {\n\t\treturn node.properties.flatMap((property) => {\n\t\t\tif (ts.isShorthandPropertyAssignment(property)) {\n\t\t\t\treturn [property.name.text];\n\t\t\t}\n\n\t\t\tif (ts.isPropertyAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.initializer);\n\t\t\t}\n\n\t\t\tif (ts.isSpreadAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.expression);\n\t\t\t}\n\n\t\t\treturn [];\n\t\t});\n\t}\n\n\tif (ts.isArrayLiteralExpression(node)) {\n\t\treturn node.elements.flatMap((element) =>\n\t\t\tts.isSpreadElement(element)\n\t\t\t\t? collect_assignment_target_names(element.expression)\n\t\t\t\t: collect_assignment_target_names(element),\n\t\t);\n\t}\n\n\treturn [];\n}\n","import type {\n\tBlockRef,\n\tEffectBlock,\n\tRelocation,\n\tRuntimeImportBindings,\n\tScriptLoweringContext,\n\tScriptTransformResult,\n} from \"./types.ts\";\nimport {\n\tcollect_top_level_binding_names,\n\thas_local_import_binding,\n\tmake_imports,\n} from \"./imports.ts\";\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport type { MarkupTransformTarget } from \"$/markup/transform.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n\temit_types?: boolean;\n\ttarget?: MarkupTransformTarget;\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\tcontent: string,\n\tfilename: string,\n\toptions: ScriptTransformOptions = {},\n): ScriptTransformResult {\n\tlet temp_counter = 0;\n\tconst target = options.target ?? \"client\";\n\tconst is_server_target = target === \"server\";\n\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcontent,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst magic = new MagicString(content);\n\tconst effect_blocks: EffectBlock[] = [];\n\tconst block_refs: BlockRef[] = [];\n\tconst top_level_binding_names = collect_top_level_binding_names(source_file);\n\tconst top_level_binding_names_set = new Set(top_level_binding_names);\n\tconst name_allocator = make_name_allocator(top_level_binding_names);\n\tconst emit_types = options.emit_types ?? true;\n\n\tlet has_effect = false;\n\tlet uses_dispatcher_promise = false;\n\tlet uses_yield_success_types = false;\n\n\t/** Phase 1: detect imports already provided by the user. */\n\tconst has_effect_import = has_local_import_binding(source_file, \"effect\", \"Effect\");\n\n\tconst has_dispatcher_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte-effect-runtime/internal/generators\",\n\t\t\"get_dispatcher\",\n\t);\n\n\tconst has_untrack_import = has_local_import_binding(source_file, \"svelte\", \"untrack\");\n\tconst has_on_destroy_import = has_local_import_binding(source_file, \"svelte\", \"onDestroy\");\n\n\tconst reserve_runtime_import = (name: string) =>\n\t\ttop_level_binding_names_set.has(name)\n\t\t\t? name_allocator.reserve(make_generated_name(name, \"\"))\n\t\t\t: name_allocator.reserve(name);\n\n\tconst runtime_bindings: RuntimeImportBindings = {\n\t\tcancel: name_allocator.reserve(\"__SER___cancel\"),\n\t\tcomponent_scope_ref: reserve_runtime_import(\"ComponentScopeRef\"),\n\t\tdispatcher: has_dispatcher_import\n\t\t\t? \"get_dispatcher\"\n\t\t\t: reserve_runtime_import(\"get_dispatcher\"),\n\t\tdispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n\t\teffect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n\t\ton_destroy: has_on_destroy_import ? \"onDestroy\" : reserve_runtime_import(\"onDestroy\"),\n\t\tprogram: name_allocator.reserve(\"__SER___program\"),\n\t\tscope: name_allocator.reserve(\"__SER___scope\"),\n\t\tuntrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n\t\tyield_success: reserve_runtime_import(\"YieldSuccess\"),\n\t\tyieldable: reserve_runtime_import(\"ToEffect\"),\n\t};\n\n\tconst context: ScriptLoweringContext = {\n\t\tfilename,\n\t\tdispatcher_name: runtime_bindings.dispatcher,\n\t\tscope_name: runtime_bindings.scope,\n\t\teffect_name: runtime_bindings.effect,\n\t\temit_types,\n\t\tyield_success_name: runtime_bindings.yield_success,\n\t\tyieldable_name: runtime_bindings.yieldable,\n\t\tnext_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\n\t\t},\n\t\tnext_temp_name(hint?: string) {\n\t\t\tconst suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n\t\t\tconst name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n\t\t\ttemp_counter += 1;\n\n\t\t\treturn name_allocator.reserve(name);\n\t\t},\n\t\tnext_type_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(`type_${hint ?? \"effect\"}`, \"\"));\n\t\t},\n\t};\n\n\t/** Phase 2: lower every top-level statement that contains `yield*`. */\n\tfor (const stmt of source_file.statements) {\n\t\tvalidate_rune_yield_usage(stmt, content, filename);\n\t\tvalidate_script_yield_boundaries(stmt, content, filename);\n\n\t\tconst has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n\t\tif (!has_top_level_yield_star) {\n\t\t\tcontinue;\n\t\t}\n\n\t\thas_effect = true;\n\t\tconst lowered = lower_statement(stmt, content, context);\n\n\t\tif (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\n\t\t\tconst text = slice(content, stmt);\n\t\t\tthrow new AwaitInEffectWorkError(filename, text);\n\t\t}\n\n\t\tmagic.overwrite(lowered.range.start, lowered.range.end, lowered.rewritten_text);\n\n\t\tif (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n\t\t\tconst temp_declarations = lowered.temps.map((temp) =>\n\t\t\t\ttemp.type\n\t\t\t\t\t? `let ${temp.name} = $state<${temp.type}>(undefined);`\n\t\t\t\t\t: `let ${temp.name} = $state(undefined);`,\n\t\t\t);\n\n\t\t\tconst prefix = [...(lowered.type_helpers ?? []), ...temp_declarations].join(\"\\n\");\n\n\t\t\tmagic.appendLeft(lowered.range.start, prefix + \"\\n\");\n\t\t}\n\n\t\teffect_blocks.push(...lowered.effect_blocks);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\n\t\tuses_yield_success_types ||= lowered.temps.some(\n\t\t\t(temp) => temp.type?.includes(runtime_bindings.yield_success) ?? false,\n\t\t);\n\t}\n\n\tif (!has_effect) {\n\t\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\t\treturn { code: content, blocks: block_refs };\n\t}\n\n\t/** Phase 3: inject runtime imports after the last user import. */\n\tconst imports = make_imports(\n\t\thas_effect_import,\n\t\thas_dispatcher_import,\n\t\thas_untrack_import,\n\t\thas_on_destroy_import,\n\t\truntime_bindings,\n\t\t{\n\t\t\tneeds_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_effect: effect_blocks.length > 0,\n\t\t\tneeds_untrack: effect_blocks.length > 0,\n\t\t\tneeds_on_destroy: !is_server_target,\n\t\t\tneeds_yield_success: uses_yield_success_types,\n\t\t\tneeds_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_scope_ref: true,\n\t\t},\n\t);\n\n\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\n\t/**\n\t * The scope holder is created synchronously with the imports so it exists\n\t * before any top-level `await`, and disposal is registered through\n\t * `onDestroy` during component initialisation. Emitting both here keeps\n\t * them ahead of every lowered statement that references the scope.\n\t */\n\tconst scope_wiring = [\n\t\t`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`,\n\t\t...(!is_server_target ? [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`] : []),\n\t].join(\"\\n\");\n\n\tconst injected = [imports, scope_wiring].filter(Boolean).join(\"\\n\");\n\n\tif (last_import) {\n\t\tmagic.appendRight(last_import.end, \"\\n\" + injected);\n\t} else {\n\t\tmagic.prepend(injected + \"\\n\");\n\t}\n\n\t/** Phase 4: append the runtime program blocks. */\n\n\tif (effect_blocks.length > 0) {\n\t\tconst runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);\n\n\t\tmagic.append(\"\\n\" + runtime_block);\n\t}\n\n\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\tconst code = magic.toString();\n\n\treturn {\n\t\tcode,\n\t\tblocks: block_refs,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations: create_script_relocations(\n\t\t\tcontent,\n\t\t\tcode,\n\t\t\tsource_file,\n\t\t\truntime_bindings.yieldable,\n\t\t),\n\t};\n}\n\nfunction create_script_relocations(\n\tcontent: string,\n\tcode: string,\n\tsource_file: ts.SourceFile,\n\tyieldable_name: string,\n): Relocation[] {\n\tconst candidates = source_file.statements.flatMap((stmt) => {\n\t\tconst relocations: RelocationCandidate[] = [];\n\n\t\tif (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\n\t\t\tfor (const decl of stmt.declarationList.declarations) {\n\t\t\t\tcollect_binding_relocation_candidates(decl.name, relocations);\n\t\t\t}\n\t\t}\n\n\t\tcollect_yield_star_nodes(stmt, (node) => {\n\t\t\tconst expression = ts.isBinaryExpression(node) ? node.right : node;\n\t\t\tconst text = content.slice(expression.getStart(), expression.end).trim();\n\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: expression.getStart(),\n\t\t\t\toriginalEnd: expression.end,\n\t\t\t\ttext,\n\t\t\t\tmatch: \"yield_operand\",\n\t\t\t\twrapper: `${yieldable_name}(${text})`,\n\t\t\t});\n\t\t});\n\n\t\treturn relocations;\n\t});\n\n\tconst used_ranges: Array<{ start: number; end: number }> = [];\n\tconst search_cursors = new Map<string, number>();\n\n\treturn candidates.flatMap((candidate) => {\n\t\tconst search_key = make_relocation_search_key(candidate);\n\t\tconst generated_start = find_available_generated_text(\n\t\t\tcode,\n\t\t\tcandidate,\n\t\t\tused_ranges,\n\t\t\tsearch_cursors.get(search_key) ?? 0,\n\t\t);\n\n\t\tif (generated_start < 0) {\n\t\t\tsearch_cursors.set(search_key, code.length);\n\n\t\t\treturn [];\n\t\t}\n\n\t\tconst generated_end = generated_start + candidate.text.length;\n\t\tused_ranges.push({ start: generated_start, end: generated_end });\n\t\tsearch_cursors.set(search_key, generated_end);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: candidate.originalStart,\n\t\t\t\toriginalEnd: candidate.originalEnd,\n\t\t\t\tgeneratedStart: generated_start,\n\t\t\t\tgeneratedEnd: generated_end,\n\t\t\t},\n\t\t];\n\t});\n}\n\ntype RelocationCandidate = {\n\toriginalStart: number;\n\toriginalEnd: number;\n\ttext: string;\n\tmatch: \"exact\" | \"identifier\" | \"yield_operand\";\n\twrapper?: string;\n};\n\nfunction make_relocation_search_key(candidate: RelocationCandidate): string {\n\treturn `${candidate.match}:${candidate.text}`;\n}\n\nfunction collect_binding_relocation_candidates(\n\tname: ts.BindingName,\n\tcandidates: RelocationCandidate[],\n): void {\n\tif (ts.isIdentifier(name)) {\n\t\tcandidates.push({\n\t\t\toriginalStart: name.getStart(),\n\t\t\toriginalEnd: name.end,\n\t\t\ttext: name.text,\n\t\t\tmatch: \"identifier\",\n\t\t});\n\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_relocation_candidates(element.name, candidates);\n\t}\n}\n\nfunction find_available_generated_text(\n\tcode: string,\n\tcandidate: RelocationCandidate,\n\tused_ranges: Array<{ start: number; end: number }>,\n\tsearch_start: number,\n): number {\n\twhile (search_start < code.length) {\n\t\tconst search_text =\n\t\t\tcandidate.match === \"yield_operand\" ? candidate.wrapper : candidate.text;\n\n\t\tif (!search_text) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst index = code.indexOf(search_text, search_start);\n\n\t\tif (index < 0) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst operand_offset =\n\t\t\tcandidate.match === \"yield_operand\" && candidate.wrapper\n\t\t\t\t? candidate.wrapper.indexOf(candidate.text)\n\t\t\t\t: 0;\n\t\tconst start = index + Math.max(operand_offset, 0);\n\t\tconst end = start + candidate.text.length;\n\t\tconst overlaps_used_range = used_ranges.some(\n\t\t\t(range) => start < range.end && end > range.start,\n\t\t);\n\t\tconst is_text_match =\n\t\t\tcandidate.match !== \"identifier\" || is_identifier_text_match(code, start, end);\n\n\t\tif (!overlaps_used_range && is_text_match) {\n\t\t\treturn start;\n\t\t}\n\n\t\tsearch_start = candidate.match === \"identifier\" ? index + 1 : index + search_text.length;\n\t}\n\n\treturn -1;\n}\n\nfunction is_identifier_text_match(code: string, start: number, end: number): boolean {\n\tconst before = start === 0 ? 0 : code.charCodeAt(start - 1);\n\tconst after = end >= code.length ? 0 : code.charCodeAt(end);\n\n\treturn !is_identifier_part(before) && !is_identifier_part(after);\n}\n\nfunction is_identifier_part(char_code: number): boolean {\n\treturn (\n\t\t(char_code >= 65 && char_code <= 90) ||\n\t\t(char_code >= 97 && char_code <= 122) ||\n\t\t(char_code >= 48 && char_code <= 57) ||\n\t\tchar_code === 36 ||\n\t\tchar_code === 95\n\t);\n}\n\nfunction validate_script_yield_boundaries(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst bad_member = find_class_member_with_yield_star(stmt);\n\n\tif (!bad_member) {\n\t\treturn;\n\t}\n\n\tthrow new PreprocessError(\n\t\t[\n\t\t\t`[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n\t\t\t`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\t\t\t\"\",\n\t\t\t\"Problematic member:\",\n\t\t\tslice(content, bad_member),\n\t\t].join(\"\\n\"),\n\t\tfilename,\n\t);\n}\n\nfunction find_class_member_with_yield_star(stmt: ts.Statement): ts.Node | undefined {\n\tlet found: ts.Node | undefined;\n\n\tfunction visit(node: ts.Node): void {\n\t\tif (found) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tts.isPropertyDeclaration(node) &&\n\t\t\tnode.initializer &&\n\t\t\tcontains_top_level_yield_star(node.initializer)\n\t\t) {\n\t\t\tfound = node;\n\t\t\treturn;\n\t\t}\n\n\t\tnode.forEachChild(visit);\n\t}\n\n\tvisit(stmt);\n\n\treturn found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n\tconst normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n\tconst safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n\t\t? normalized_hint\n\t\t: `temp_${normalized_hint}`;\n\n\treturn `__SER___${safe_hint}${suffix}`;\n}\n","import { type MarkupTransformTarget, transform_markup_effect } from \"$/markup/transform.ts\";\nimport { scan_svelte_effect_source } from \"$/compiler/source-scan.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\t/** Transformed Svelte source. */\n\tcode: 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\t/** Markup emission target passed through to the markup transform. */\n\ttarget?: 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\tcontent: string,\n\tfilename = \"unknown.svelte\",\n\toptions: SvelteTransformOptions = {},\n): SvelteTransformResult {\n\tconst scan = scan_svelte_effect_source(content, filename);\n\tconst script = scan.effect_script;\n\n\tlet combined = content;\n\n\tif (script) {\n\t\tconst effect_attribute = script.effect_attribute;\n\t\tconst effect_attribute_start = effect_attribute?.start ?? script.opening_tag_end;\n\t\tconst effect_attribute_end = effect_attribute?.end ?? script.opening_tag_end;\n\t\tconst result = transform_script_effect(script.text, filename, {\n\t\t\temit_types: script.is_typescript,\n\t\t\ttarget: options.target ?? \"client\",\n\t\t});\n\n\t\tcombined =\n\t\t\tcontent.slice(0, effect_attribute_start) +\n\t\t\tcontent.slice(effect_attribute_end, script.opening_tag_end) +\n\t\t\tresult.code +\n\t\t\tcontent.slice(script.closing_tag_start);\n\t}\n\n\tconst markup_options = options.target === undefined ? {} : { target: options.target };\n\tconst result = transform_markup_effect(combined, filename, markup_options);\n\n\treturn { code: result.code };\n}\n\nexport {\n\ttype MarkupTransformOptions,\n\ttype MarkupTransformResult,\n\ttype MarkupTransformTarget,\n\ttransform_markup_effect,\n} from \"$/markup/transform.ts\";\n\nexport {\n\ttype B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MAAsB;EAC7B,IAAI,YAAY;EAChB,IAAI,SAAS;EAEb,OAAO,WAAW,IAAI,SAAS,GAAG;GACjC,YAAY,GAAG,KAAK,GAAG;GACvB,UAAU;EACX;EAEA,WAAW,IAAI,SAAS;EAExB,OAAO;CACR,EACD;AACD;AAEA,SAAS,oBAAoB,MAAc,QAAwB;CAClE,MAAM,kBAAkB,KAAK,QAAQ,mBAAmB,GAAG;CAK3D,OAAO,WAJW,cAAc,KAAK,eAAe,IACjD,kBACA,QAAQ,oBAEmB;AAC/B;;;;;;;;;;;;;;;;;;;;;;;AC5aA,SAAgB,wBACf,SACA,WAAW,kBACX,UAAkC,CAAC,GACX;CAExB,MAAM,SADO,0BAA0B,SAAS,QAC9B,CAAC,CAAC;CAEpB,IAAI,WAAW;CAEf,IAAI,QAAQ;EACX,MAAM,mBAAmB,OAAO;EAChC,MAAM,yBAAyB,kBAAkB,SAAS,OAAO;EACjE,MAAM,uBAAuB,kBAAkB,OAAO,OAAO;EAC7D,MAAM,SAAS,wBAAwB,OAAO,MAAM,UAAU;GAC7D,YAAY,OAAO;GACnB,QAAQ,QAAQ,UAAU;EAC3B,CAAC;EAED,WACC,QAAQ,MAAM,GAAG,sBAAsB,IACvC,QAAQ,MAAM,sBAAsB,OAAO,eAAe,IAC1D,OAAO,OACP,QAAQ,MAAM,OAAO,iBAAiB;CACxC;CAEA,MAAM,iBAAiB,QAAQ,WAAW,KAAA,IAAY,CAAC,IAAI,EAAE,QAAQ,QAAQ,OAAO;CAGpF,OAAO,EAAE,MAFM,wBAAwB,UAAU,UAAU,cAEvC,CAAC,CAAC,KAAK;AAC5B"}
|
|
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\nexport function make_runtime_block_with_bindings(\n\tblocks: EffectBlock[],\n\tbindings: RuntimeImportBindings,\n): string {\n\treturn blocks.map((block) => make_runtime_effect_block(block, bindings)).join(\"\\n\");\n}\n\nfunction make_runtime_effect_block(block: EffectBlock, bindings: RuntimeImportBindings): string {\n\tconst dep_reads = block.deps.map((dep) => ` ${dep};`);\n\n\tconst body = block.statements.map((statement) => ` ${statement}`).join(\"\\n\");\n\n\treturn [\n\t\t\"\",\n\t\t\"$effect(() => {\",\n\t\t...dep_reads,\n\t\t` const ${bindings.dispatcher_value} = ${bindings.dispatcher}();`,\n\t\t` const ${bindings.program} = ${bindings.effect}.gen(function* () {`,\n\t\tbody,\n\t\t\" });\",\n\t\t` const ${bindings.cancel} = ${bindings.untrack}(() => ${bindings.dispatcher_value}.run_scoped(${bindings.scope}.scope, ${bindings.program}));`,\n\t\t` import.meta.hot?.dispose(${bindings.cancel});`,\n\t\t` return ${bindings.cancel};`,\n\t\t\"});\",\n\t\t\"\",\n\t].join(\"\\n\");\n}\n","import type {\n\tEffectBlock,\n\tLoweredExpression,\n\tLoweredStatement,\n\tScriptLoweringContext,\n\tTempBinding,\n} from \"./types.ts\";\nimport { collect_yield_star_nodes, find_yield_star_node, is_yield_star_expression } from \"./ast.ts\";\nimport { collect_free_identifiers } from \"$/markup/transform/expressions.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { slice, slice_start } from \"./source.ts\";\n\nimport ts from \"typescript\";\n\nexport function lower_statement(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tif (ts.isExpressionStatement(stmt)) {\n\t\treturn lower_expression_statement(stmt, content, context);\n\t}\n\n\tif (ts.isVariableStatement(stmt)) {\n\t\treturn lower_variable_statement(stmt, content, context);\n\t}\n\n\tconst text = slice(content, stmt);\n\tconst wrapped_text = wrap_yield_stars_in_node(stmt, content, context);\n\n\treturn {\n\t\ttemps: [],\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [make_effect_block([wrapped_text], collect_deps(text))],\n\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_variable_statement(\n\tstmt: ts.VariableStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst helper_declarations: string[] = [];\n\tconst rewritten_decls: string[] = [];\n\n\tconst decl_list = stmt.declarationList;\n\tconst kind = (decl_list.flags & ts.NodeFlags.Let) !== 0 ? \"let\" : \"const\";\n\tlet uses_dispatcher_promise = false;\n\n\tfor (const decl of decl_list.declarations) {\n\t\tif (!contains_top_level_yield_star(decl)) {\n\t\t\trewritten_decls.push(slice(content, decl).trim());\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst lowered = lower_node_yields_to_await(\n\t\t\tdecl,\n\t\t\tcontent,\n\t\t\tmake_binding_hint(decl.name),\n\t\t\tcontext,\n\t\t);\n\n\t\thelper_declarations.push(...lowered.helper_declarations);\n\t\trewritten_decls.push(lowered.rewritten_text);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise;\n\t}\n\n\tconst rewritten_text = `${kind} ${rewritten_decls.join(\", \")};`;\n\n\treturn {\n\t\ttemps: [],\n\t\ttype_helpers: helper_declarations,\n\t\trewritten_text,\n\t\teffect_blocks: [],\n\t\tuses_dispatcher_promise,\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_statement(\n\tstmt: ts.ExpressionStatement,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): LoweredStatement {\n\tconst expr = stmt.expression;\n\n\tif (!contains_top_level_yield_star(expr)) {\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: slice(content, stmt).trim(),\n\t\t\teffect_blocks: [],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (is_yield_star_expression(expr)) {\n\t\tconst text = slice(content, expr).trim();\n\t\tconst yield_text = wrap_yield_text(text, context);\n\n\t\treturn {\n\t\t\ttemps: [],\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [make_effect_block([yield_text + \";\"], collect_deps(text))],\n\t\t\trange: { start: stmt.getFullStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tif (ts.isBinaryExpression(expr) && is_assignment_operator(expr)) {\n\t\tconst target = slice(content, expr.left).trim();\n\t\tconst target_names = collect_assignment_target_names(expr.left);\n\n\t\tif (\n\t\t\texpr.operatorToken.kind === ts.SyntaxKind.EqualsToken &&\n\t\t\tis_yield_star_expression(expr.right)\n\t\t) {\n\t\t\tconst yield_text = extract_yield_star_full_text(expr.right, content);\n\t\t\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\t\t\treturn {\n\t\t\t\ttemps: [],\n\t\t\t\trewritten_text: \"\",\n\t\t\t\teffect_blocks: [\n\t\t\t\t\tmake_effect_block(\n\t\t\t\t\t\t[`${target} = ${wrapped_yield_text};`],\n\t\t\t\t\t\tcollect_deps(yield_text, target_names),\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t\t};\n\t\t}\n\n\t\tconst lowered = lower_expression_yields(\n\t\t\texpr.right,\n\t\t\tcontent,\n\t\t\tmake_temp_hint(target),\n\t\t\tcontext,\n\t\t);\n\t\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\t\tconst statement = `${target} ${slice(\n\t\t\tcontent,\n\t\t\texpr.operatorToken,\n\t\t).trim()} ${lowered.rewritten_expr};`;\n\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: \"\",\n\t\t\teffect_blocks: [\n\t\t\t\tmake_effect_block(\n\t\t\t\t\t[...lowered.effect_blocks.flatMap((block) => block.statements), statement],\n\t\t\t\t\t[\n\t\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t\t...collect_deps(lowered.rewritten_expr, [...target_names, ...temp_names]),\n\t\t\t\t\t],\n\t\t\t\t),\n\t\t\t],\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst lowered = lower_expression_yields(expr, content, \"call\", context);\n\n\tif (is_top_level_rune_call(expr)) {\n\t\treturn {\n\t\t\ttemps: lowered.temps,\n\t\t\ttype_helpers: lowered.type_helpers,\n\t\t\trewritten_text: lowered.rewritten_expr + \";\",\n\t\t\teffect_blocks: lowered.effect_blocks,\n\t\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t\t};\n\t}\n\n\tconst temp_names = lowered.temps.map((temp) => temp.name);\n\n\treturn {\n\t\ttemps: lowered.temps,\n\t\ttype_helpers: lowered.type_helpers,\n\t\trewritten_text: \"\",\n\t\teffect_blocks: [\n\t\t\tmake_effect_block(\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.statements),\n\t\t\t\t\tlowered.rewritten_expr + \";\",\n\t\t\t\t],\n\t\t\t\t[\n\t\t\t\t\t...lowered.effect_blocks.flatMap((block) => block.deps),\n\t\t\t\t\t...collect_deps(lowered.rewritten_expr, temp_names),\n\t\t\t\t],\n\t\t\t),\n\t\t],\n\t\trange: { start: stmt.getStart(), end: stmt.end },\n\t};\n}\n\nfunction lower_expression_yields(\n\texpr: ts.Expression,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): LoweredExpression {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tconst temps: TempBinding[] = [];\n\tconst type_helpers: string[] = [];\n\tconst statements: string[] = [];\n\tconst deps: string[] = [];\n\n\tcollect_yield_star_nodes(expr, (node) => {\n\t\tconst temp_name = context.next_temp_name(hint);\n\t\tconst yield_text = slice_start(content, node).trim();\n\t\tconst type_helper = make_yield_type_helper(yield_text, hint, context);\n\n\t\tif (type_helper) {\n\t\t\ttype_helpers.push(type_helper.declaration);\n\t\t\ttemps.push({ name: temp_name, type: type_helper.type });\n\t\t} else {\n\t\t\ttemps.push({ name: temp_name });\n\t\t}\n\n\t\tstatements.push(`${temp_name} = ${wrap_yield_text(yield_text, context)};`);\n\t\tdeps.push(...collect_deps(yield_text));\n\t\treplacements.push({\n\t\t\tstart: node.getStart(),\n\t\t\tend: node.end,\n\t\t\ttext: temp_name,\n\t\t});\n\t});\n\n\tif (replacements.length === 0) {\n\t\treturn {\n\t\t\ttemps,\n\t\t\ttype_helpers,\n\t\t\trewritten_expr: slice(content, expr).trim(),\n\t\t\teffect_blocks: [],\n\t\t};\n\t}\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice(content, expr);\n\n\tconst offset_in_expr = expr.getFullStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_expr) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_expr);\n\t}\n\n\treturn {\n\t\ttemps,\n\t\ttype_helpers,\n\t\trewritten_expr: text.trim(),\n\t\teffect_blocks: [make_effect_block(statements, deps)],\n\t};\n}\n\nfunction lower_node_yields_to_await(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): {\n\thelper_declarations: string[];\n\trewritten_text: string;\n\tuses_dispatcher_promise: boolean;\n} {\n\tconst helper_declarations: string[] = [];\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst awaited = make_awaited_yield_expression(yield_node, content, hint, context);\n\n\t\thelper_declarations.push(awaited.declaration);\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: awaited.expression,\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tlet text = slice_start(content, node);\n\tconst offset_in_node = node.getStart();\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset_in_node) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset_in_node);\n\t}\n\n\treturn {\n\t\thelper_declarations,\n\t\trewritten_text: text.trim(),\n\t\tuses_dispatcher_promise: replacements.length > 0,\n\t};\n}\n\nfunction make_awaited_yield_expression(\n\tnode: ts.Node,\n\tcontent: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; expression: string } {\n\tconst yield_text = slice_start(content, node).trim();\n\tconst helper_name = context.next_helper_name(`effect_${hint}`);\n\tconst helper_id = make_script_effect_id(node, context);\n\tconst deps = collect_deps(yield_text);\n\tconst deps_text = `[${deps.join(\", \")}]`;\n\tconst wrapped_yield_text = wrap_yield_text(yield_text, context);\n\n\treturn {\n\t\tdeclaration: `function* ${helper_name}() { return (${wrapped_yield_text}); }`,\n\t\texpression: [\n\t\t\t`await ${context.dispatcher_name}().with_scope(${context.scope_name}.scope, () => ${context.dispatcher_name}().promise({`,\n\t\t\t`id: ${JSON.stringify(helper_id)}, `,\n\t\t\t`deps: ${deps_text}, `,\n\t\t\t`factory: () => ${helper_name}()`,\n\t\t\t`}))`,\n\t\t].join(\"\"),\n\t};\n}\n\nfunction make_yield_type_helper(\n\tyield_text: string,\n\thint: string,\n\tcontext: ScriptLoweringContext,\n): { declaration: string; type: string } | undefined {\n\tif (!context.emit_types) {\n\t\treturn undefined;\n\t}\n\n\tconst helper_name = context.next_type_helper_name(hint);\n\tconst effect_text = strip_yield_star(yield_text);\n\n\treturn {\n\t\tdeclaration: `function ${helper_name}() { return (${effect_text}); }`,\n\t\ttype: `${context.yield_success_name}<ReturnType<typeof ${helper_name}>> | undefined`,\n\t};\n}\n\nfunction strip_yield_star(yield_text: string): string {\n\treturn yield_text.replace(/^yield\\s*\\*\\s*/, \"\");\n}\n\nfunction wrap_yield_text(yield_text: string, context: ScriptLoweringContext): string {\n\treturn `yield* ${context.yieldable_name}(${strip_yield_star(yield_text)})`;\n}\n\nfunction wrap_yield_stars_in_node(\n\tnode: ts.Node,\n\tcontent: string,\n\tcontext: ScriptLoweringContext,\n): string {\n\tconst replacements: Array<{\n\t\tstart: number;\n\t\tend: number;\n\t\ttext: string;\n\t}> = [];\n\n\tcollect_yield_star_nodes(node, (yield_node) => {\n\t\tconst yield_text = slice_start(content, yield_node).trim();\n\n\t\treplacements.push({\n\t\t\tstart: yield_node.getStart(),\n\t\t\tend: yield_node.end,\n\t\t\ttext: wrap_yield_text(yield_text, context),\n\t\t});\n\t});\n\n\treplacements.sort((a, b) => b.start - a.start);\n\n\tconst offset = node.getFullStart();\n\tlet text = slice(content, node);\n\n\tfor (const replacement of replacements) {\n\t\ttext =\n\t\t\ttext.slice(0, replacement.start - offset) +\n\t\t\treplacement.text +\n\t\t\ttext.slice(replacement.end - offset);\n\t}\n\n\treturn text.trim();\n}\n\nfunction make_script_effect_id(expr: ts.Node, context: ScriptLoweringContext): string {\n\treturn `${context.filename}:${expr.getStart()}:${expr.end}`;\n}\n\nfunction is_assignment_operator(expr: ts.BinaryExpression): boolean {\n\treturn (\n\t\texpr.operatorToken.kind >= ts.SyntaxKind.FirstAssignment &&\n\t\texpr.operatorToken.kind <= ts.SyntaxKind.LastAssignment\n\t);\n}\n\nfunction is_top_level_rune_call(expr: ts.Expression): boolean {\n\tif (!ts.isCallExpression(expr)) {\n\t\treturn false;\n\t}\n\n\tconst callee = expr.expression;\n\n\tif (ts.isIdentifier(callee)) {\n\t\treturn callee.text.startsWith(\"$\");\n\t}\n\n\treturn (\n\t\tts.isPropertyAccessExpression(callee) &&\n\t\tts.isIdentifier(callee.expression) &&\n\t\tcallee.expression.text.startsWith(\"$\")\n\t);\n}\n\nfunction make_temp_hint(target: string): string {\n\tconst match = target.match(/[A-Za-z_$][\\w$]*$/);\n\n\treturn match?.[0] ?? \"assignment\";\n}\n\nfunction make_binding_hint(name: ts.BindingName): string {\n\tif (ts.isIdentifier(name)) {\n\t\treturn name.text;\n\t}\n\n\treturn \"destructure\";\n}\n\nfunction extract_yield_star_full_text(expr: ts.Expression, content: string): string {\n\tlet found: string | undefined;\n\n\tfind_yield_star_node(expr, (node) => {\n\t\tfound = slice_start(content, node).trim();\n\t});\n\n\treturn found ?? \"undefined\";\n}\n\nfunction make_effect_block(statements: string[], deps: string[]): EffectBlock {\n\treturn {\n\t\tstatements,\n\t\tdeps: [...new Set(deps)],\n\t};\n}\n\nfunction collect_deps(expr_text: string, excluded_names: readonly string[] = []): string[] {\n\tconst excluded = new Set(excluded_names);\n\n\treturn collect_free_identifiers(expr_text).filter(\n\t\t(identifier) => !identifier.startsWith(\"__SER___\") && !excluded.has(identifier),\n\t);\n}\n\nfunction collect_assignment_target_names(node: ts.Node): string[] {\n\tif (ts.isIdentifier(node)) {\n\t\treturn [node.text];\n\t}\n\n\tif (ts.isParenthesizedExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {\n\t\treturn collect_assignment_target_names(node.expression);\n\t}\n\n\tif (ts.isObjectLiteralExpression(node)) {\n\t\treturn node.properties.flatMap((property) => {\n\t\t\tif (ts.isShorthandPropertyAssignment(property)) {\n\t\t\t\treturn [property.name.text];\n\t\t\t}\n\n\t\t\tif (ts.isPropertyAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.initializer);\n\t\t\t}\n\n\t\t\tif (ts.isSpreadAssignment(property)) {\n\t\t\t\treturn collect_assignment_target_names(property.expression);\n\t\t\t}\n\n\t\t\treturn [];\n\t\t});\n\t}\n\n\tif (ts.isArrayLiteralExpression(node)) {\n\t\treturn node.elements.flatMap((element) =>\n\t\t\tts.isSpreadElement(element)\n\t\t\t\t? collect_assignment_target_names(element.expression)\n\t\t\t\t: collect_assignment_target_names(element),\n\t\t);\n\t}\n\n\treturn [];\n}\n","import type {\n\tBlockRef,\n\tEffectBlock,\n\tRelocation,\n\tRuntimeImportBindings,\n\tScriptLoweringContext,\n\tScriptTransformResult,\n} from \"./types.ts\";\nimport {\n\tcollect_top_level_binding_names,\n\thas_local_import_binding,\n\tmake_imports,\n} from \"./imports.ts\";\nimport { collect_yield_star_nodes, contains_top_level_await } from \"./ast.ts\";\nimport { AwaitInEffectWorkError, PreprocessError } from \"$/errors.ts\";\nimport { make_runtime_block_with_bindings } from \"./runtime-block.ts\";\nimport { contains_top_level_yield_star } from \"$/detect.ts\";\nimport { create_source_map, slice } from \"./source.ts\";\nimport { validate_rune_yield_usage } from \"./runes.ts\";\nimport { lower_statement } from \"./lower.ts\";\nimport type { MarkupTransformTarget } from \"$/markup/transform.ts\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\nexport type { BlockRef, ScriptTransformResult } from \"./types.ts\";\n\ninterface ScriptTransformOptions {\n\temit_types?: boolean;\n\ttarget?: MarkupTransformTarget;\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\tcontent: string,\n\tfilename: string,\n\toptions: ScriptTransformOptions = {},\n): ScriptTransformResult {\n\tlet temp_counter = 0;\n\tconst target = options.target ?? \"client\";\n\n\tconst source_file = ts.createSourceFile(\n\t\tfilename,\n\t\tcontent,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n\n\tconst magic = new MagicString(content);\n\tconst effect_blocks: EffectBlock[] = [];\n\tconst block_refs: BlockRef[] = [];\n\tconst top_level_binding_names = collect_top_level_binding_names(source_file);\n\tconst top_level_binding_names_set = new Set(top_level_binding_names);\n\tconst name_allocator = make_name_allocator(top_level_binding_names);\n\tconst emit_types = options.emit_types ?? true;\n\n\tlet has_effect = false;\n\tlet first_effect_statement_start = content.length;\n\tlet uses_dispatcher_promise = false;\n\tlet uses_yield_success_types = false;\n\n\t/** Phase 1: detect imports already provided by the user. */\n\tconst has_effect_import = has_local_import_binding(source_file, \"effect\", \"Effect\");\n\n\tconst has_dispatcher_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte-effect-runtime/internal/generators\",\n\t\t\"get_dispatcher\",\n\t);\n\n\tconst has_untrack_import = has_local_import_binding(source_file, \"svelte\", \"untrack\");\n\tconst has_on_destroy_import = has_local_import_binding(\n\t\tsource_file,\n\t\t\"svelte\",\n\t\t\"onDestroy\",\n\t\tfalse,\n\t);\n\n\tconst reserve_runtime_import = (name: string) =>\n\t\ttop_level_binding_names_set.has(name)\n\t\t\t? name_allocator.reserve(make_generated_name(name, \"\"))\n\t\t\t: name_allocator.reserve(name);\n\n\tconst runtime_bindings: RuntimeImportBindings = {\n\t\tcancel: name_allocator.reserve(\"__SER___cancel\"),\n\t\tcomponent_scope_ref: reserve_runtime_import(\"ComponentScopeRef\"),\n\t\tdispatcher: has_dispatcher_import\n\t\t\t? \"get_dispatcher\"\n\t\t\t: reserve_runtime_import(\"get_dispatcher\"),\n\t\tdispatcher_value: name_allocator.reserve(\"__SER___dispatcher\"),\n\t\teffect: has_effect_import ? \"Effect\" : reserve_runtime_import(\"Effect\"),\n\t\ton_destroy: has_on_destroy_import ? \"onDestroy\" : reserve_runtime_import(\"onDestroy\"),\n\t\tprogram: name_allocator.reserve(\"__SER___program\"),\n\t\tscope: name_allocator.reserve(\"__SER___scope\"),\n\t\tuntrack: has_untrack_import ? \"untrack\" : reserve_runtime_import(\"untrack\"),\n\t\tyield_success: reserve_runtime_import(\"YieldSuccess\"),\n\t\tyieldable: reserve_runtime_import(\"ToEffect\"),\n\t};\n\n\tconst context: ScriptLoweringContext = {\n\t\tfilename,\n\t\tdispatcher_name: runtime_bindings.dispatcher,\n\t\tscope_name: runtime_bindings.scope,\n\t\teffect_name: runtime_bindings.effect,\n\t\temit_types,\n\t\tyield_success_name: runtime_bindings.yield_success,\n\t\tyieldable_name: runtime_bindings.yieldable,\n\t\tnext_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(hint ?? \"helper\", \"\"));\n\t\t},\n\t\tnext_temp_name(hint?: string) {\n\t\t\tconst suffix = temp_counter === 0 ? \"\" : `_${temp_counter}`;\n\t\t\tconst name = make_generated_name(hint ?? String(temp_counter), suffix);\n\n\t\t\ttemp_counter += 1;\n\n\t\t\treturn name_allocator.reserve(name);\n\t\t},\n\t\tnext_type_helper_name(hint?: string) {\n\t\t\treturn name_allocator.reserve(make_generated_name(`type_${hint ?? \"effect\"}`, \"\"));\n\t\t},\n\t};\n\n\t/** Phase 2: lower every top-level statement that contains `yield*`. */\n\tfor (const stmt of source_file.statements) {\n\t\tvalidate_rune_yield_usage(stmt, content, filename);\n\t\tvalidate_script_yield_boundaries(stmt, content, filename);\n\n\t\tconst has_top_level_yield_star = contains_top_level_yield_star(stmt);\n\n\t\tif (!has_top_level_yield_star) {\n\t\t\tcontinue;\n\t\t}\n\n\t\thas_effect = true;\n\n\t\tconst lowered = lower_statement(stmt, content, context);\n\n\t\tfirst_effect_statement_start = Math.min(first_effect_statement_start, lowered.range.start);\n\n\t\tif (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {\n\t\t\tconst text = slice(content, stmt);\n\t\t\tthrow new AwaitInEffectWorkError(filename, text);\n\t\t}\n\n\t\tmagic.overwrite(lowered.range.start, lowered.range.end, lowered.rewritten_text);\n\n\t\tif (lowered.temps.length > 0 || lowered.type_helpers?.length) {\n\t\t\tconst temp_declarations = lowered.temps.map((temp) =>\n\t\t\t\ttemp.type\n\t\t\t\t\t? `let ${temp.name} = $state<${temp.type}>(undefined);`\n\t\t\t\t\t: `let ${temp.name} = $state(undefined);`,\n\t\t\t);\n\n\t\t\tconst prefix = [...(lowered.type_helpers ?? []), ...temp_declarations].join(\"\\n\");\n\n\t\t\tmagic.appendLeft(lowered.range.start, prefix + \"\\n\");\n\t\t}\n\n\t\teffect_blocks.push(...lowered.effect_blocks);\n\t\tuses_dispatcher_promise ||= lowered.uses_dispatcher_promise ?? false;\n\t\tuses_yield_success_types ||= lowered.temps.some(\n\t\t\t(temp) => temp.type?.includes(runtime_bindings.yield_success) ?? false,\n\t\t);\n\t}\n\n\tif (!has_effect) {\n\t\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\t\treturn { code: content, blocks: block_refs };\n\t}\n\n\t/** Phase 3: inject runtime imports after the last user import. */\n\tconst imports = make_imports(\n\t\thas_effect_import,\n\t\thas_dispatcher_import,\n\t\thas_untrack_import,\n\t\thas_on_destroy_import,\n\t\truntime_bindings,\n\t\t{\n\t\t\tneeds_dispatcher: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_effect: effect_blocks.length > 0,\n\t\t\tneeds_untrack: effect_blocks.length > 0,\n\t\t\t/** The server never registers disposal, so it never needs the import. */\n\t\t\tneeds_on_destroy: target !== \"server\",\n\t\t\tneeds_yield_success: uses_yield_success_types,\n\t\t\tneeds_yieldable: effect_blocks.length > 0 || uses_dispatcher_promise,\n\t\t\tneeds_scope_ref: true,\n\t\t},\n\t);\n\n\tconst last_import = [...source_file.statements].reverse().find(ts.isImportDeclaration);\n\tconst injection_point = last_import\n\t\t? Math.min(last_import.end, first_effect_statement_start)\n\t\t: first_effect_statement_start;\n\n\t/**\n\t * The scope holder is created synchronously with the imports so it exists\n\t * before any top-level `await`, and disposal is registered through\n\t * `onDestroy` during component initialisation. Emitting both here keeps\n\t * them ahead of every lowered statement that references the scope.\n\t */\n\tconst scope_wiring = [\n\t\t`const ${runtime_bindings.scope} = new ${runtime_bindings.component_scope_ref}(${runtime_bindings.dispatcher});`,\n\t\t...(target === \"server\"\n\t\t\t? []\n\t\t\t: [`${runtime_bindings.on_destroy}(() => ${runtime_bindings.scope}.dispose());`]),\n\t].join(\"\\n\");\n\n\tconst injected = [imports, scope_wiring].filter(Boolean).join(\"\\n\");\n\n\tif (last_import && last_import.end <= first_effect_statement_start) {\n\t\tmagic.appendRight(last_import.end, \"\\n\" + injected);\n\t} else if (injection_point >= 0) {\n\t\tmagic.appendLeft(injection_point, injected + \"\\n\");\n\t} else {\n\t\tmagic.appendLeft(first_effect_statement_start, injected + \"\\n\");\n\t}\n\n\t/** Phase 4: append the runtime program blocks. */\n\n\tif (effect_blocks.length > 0) {\n\t\tconst runtime_block = make_runtime_block_with_bindings(effect_blocks, runtime_bindings);\n\n\t\tmagic.append(\"\\n\" + runtime_block);\n\t}\n\n\tblock_refs.push({ id: filename, kind: \"script\" });\n\n\tconst code = magic.toString();\n\n\treturn {\n\t\tcode,\n\t\tblocks: block_refs,\n\t\tmap: create_source_map(magic, filename),\n\t\trelocations: create_script_relocations(\n\t\t\tcontent,\n\t\t\tcode,\n\t\t\tsource_file,\n\t\t\truntime_bindings.yieldable,\n\t\t),\n\t};\n}\n\nfunction create_script_relocations(\n\tcontent: string,\n\tcode: string,\n\tsource_file: ts.SourceFile,\n\tyieldable_name: string,\n): Relocation[] {\n\tconst candidates = source_file.statements.flatMap((stmt) => {\n\t\tconst relocations: RelocationCandidate[] = [];\n\n\t\tif (contains_top_level_yield_star(stmt) && ts.isVariableStatement(stmt)) {\n\t\t\tfor (const decl of stmt.declarationList.declarations) {\n\t\t\t\tcollect_binding_relocation_candidates(decl.name, relocations);\n\t\t\t}\n\t\t}\n\n\t\tcollect_yield_star_nodes(stmt, (node) => {\n\t\t\tconst expression = ts.isBinaryExpression(node) ? node.right : node;\n\t\t\tconst text = content.slice(expression.getStart(), expression.end).trim();\n\n\t\t\trelocations.push({\n\t\t\t\toriginalStart: expression.getStart(),\n\t\t\t\toriginalEnd: expression.end,\n\t\t\t\ttext,\n\t\t\t\tmatch: \"yield_operand\",\n\t\t\t\twrapper: `${yieldable_name}(${text})`,\n\t\t\t});\n\t\t});\n\n\t\treturn relocations;\n\t});\n\n\tconst used_ranges: Array<{ start: number; end: number }> = [];\n\tconst search_cursors = new Map<string, number>();\n\n\treturn candidates.flatMap((candidate) => {\n\t\tconst search_key = make_relocation_search_key(candidate);\n\t\tconst generated_start = find_available_generated_text(\n\t\t\tcode,\n\t\t\tcandidate,\n\t\t\tused_ranges,\n\t\t\tsearch_cursors.get(search_key) ?? 0,\n\t\t);\n\n\t\tif (generated_start < 0) {\n\t\t\tsearch_cursors.set(search_key, code.length);\n\n\t\t\treturn [];\n\t\t}\n\n\t\tconst generated_end = generated_start + candidate.text.length;\n\t\tused_ranges.push({ start: generated_start, end: generated_end });\n\t\tsearch_cursors.set(search_key, generated_end);\n\n\t\treturn [\n\t\t\t{\n\t\t\t\toriginalStart: candidate.originalStart,\n\t\t\t\toriginalEnd: candidate.originalEnd,\n\t\t\t\tgeneratedStart: generated_start,\n\t\t\t\tgeneratedEnd: generated_end,\n\t\t\t},\n\t\t];\n\t});\n}\n\ntype RelocationCandidate = {\n\toriginalStart: number;\n\toriginalEnd: number;\n\ttext: string;\n\tmatch: \"exact\" | \"identifier\" | \"yield_operand\";\n\twrapper?: string;\n};\n\nfunction make_relocation_search_key(candidate: RelocationCandidate): string {\n\treturn `${candidate.match}:${candidate.text}`;\n}\n\nfunction collect_binding_relocation_candidates(\n\tname: ts.BindingName,\n\tcandidates: RelocationCandidate[],\n): void {\n\tif (ts.isIdentifier(name)) {\n\t\tcandidates.push({\n\t\t\toriginalStart: name.getStart(),\n\t\t\toriginalEnd: name.end,\n\t\t\ttext: name.text,\n\t\t\tmatch: \"identifier\",\n\t\t});\n\n\t\treturn;\n\t}\n\n\tfor (const element of name.elements) {\n\t\tif (ts.isOmittedExpression(element)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tcollect_binding_relocation_candidates(element.name, candidates);\n\t}\n}\n\nfunction find_available_generated_text(\n\tcode: string,\n\tcandidate: RelocationCandidate,\n\tused_ranges: Array<{ start: number; end: number }>,\n\tsearch_start: number,\n): number {\n\twhile (search_start < code.length) {\n\t\tconst search_text =\n\t\t\tcandidate.match === \"yield_operand\" ? candidate.wrapper : candidate.text;\n\n\t\tif (!search_text) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst index = code.indexOf(search_text, search_start);\n\n\t\tif (index < 0) {\n\t\t\treturn -1;\n\t\t}\n\n\t\tconst operand_offset =\n\t\t\tcandidate.match === \"yield_operand\" && candidate.wrapper\n\t\t\t\t? candidate.wrapper.indexOf(candidate.text)\n\t\t\t\t: 0;\n\t\tconst start = index + Math.max(operand_offset, 0);\n\t\tconst end = start + candidate.text.length;\n\t\tconst overlaps_used_range = used_ranges.some(\n\t\t\t(range) => start < range.end && end > range.start,\n\t\t);\n\t\tconst is_text_match =\n\t\t\tcandidate.match !== \"identifier\" || is_identifier_text_match(code, start, end);\n\n\t\tif (!overlaps_used_range && is_text_match) {\n\t\t\treturn start;\n\t\t}\n\n\t\tsearch_start = candidate.match === \"identifier\" ? index + 1 : index + search_text.length;\n\t}\n\n\treturn -1;\n}\n\nfunction is_identifier_text_match(code: string, start: number, end: number): boolean {\n\tconst before = start === 0 ? 0 : code.charCodeAt(start - 1);\n\tconst after = end >= code.length ? 0 : code.charCodeAt(end);\n\n\treturn !is_identifier_part(before) && !is_identifier_part(after);\n}\n\nfunction is_identifier_part(char_code: number): boolean {\n\treturn (\n\t\t(char_code >= 65 && char_code <= 90) ||\n\t\t(char_code >= 97 && char_code <= 122) ||\n\t\t(char_code >= 48 && char_code <= 57) ||\n\t\tchar_code === 36 ||\n\t\tchar_code === 95\n\t);\n}\n\nfunction validate_script_yield_boundaries(\n\tstmt: ts.Statement,\n\tcontent: string,\n\tfilename: string,\n): void {\n\tconst bad_member = find_class_member_with_yield_star(stmt);\n\n\tif (!bad_member) {\n\t\treturn;\n\t}\n\n\tthrow new PreprocessError(\n\t\t[\n\t\t\t`[ASYNC_EFFECT_IN_CLASS_MEMBER]: ${filename}: yield* cannot be used inside class members.`,\n\t\t\t`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\t\t\t\"\",\n\t\t\t\"Problematic member:\",\n\t\t\tslice(content, bad_member),\n\t\t].join(\"\\n\"),\n\t\tfilename,\n\t);\n}\n\nfunction find_class_member_with_yield_star(stmt: ts.Statement): ts.Node | undefined {\n\tlet found: ts.Node | undefined;\n\n\tfunction visit(node: ts.Node): void {\n\t\tif (found) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (\n\t\t\tts.isPropertyDeclaration(node) &&\n\t\t\tnode.initializer &&\n\t\t\tcontains_top_level_yield_star(node.initializer)\n\t\t) {\n\t\t\tfound = node;\n\t\t\treturn;\n\t\t}\n\n\t\tnode.forEachChild(visit);\n\t}\n\n\tvisit(stmt);\n\n\treturn found;\n}\n\nfunction make_name_allocator(initial_names: readonly string[]): {\n\treserve(name: string): string;\n} {\n\tconst used_names = new Set(initial_names);\n\n\treturn {\n\t\treserve(name: string): string {\n\t\t\tlet candidate = name;\n\t\t\tlet suffix = 1;\n\n\t\t\twhile (used_names.has(candidate)) {\n\t\t\t\tcandidate = `${name}_${suffix}`;\n\t\t\t\tsuffix += 1;\n\t\t\t}\n\n\t\t\tused_names.add(candidate);\n\n\t\t\treturn candidate;\n\t\t},\n\t};\n}\n\nfunction make_generated_name(hint: string, suffix: string): string {\n\tconst normalized_hint = hint.replace(/[^A-Za-z0-9_$]/g, \"_\");\n\tconst safe_hint = /^[A-Za-z_$]/.test(normalized_hint)\n\t\t? normalized_hint\n\t\t: `temp_${normalized_hint}`;\n\n\treturn `__SER___${safe_hint}${suffix}`;\n}\n","import { type MarkupTransformTarget, transform_markup_effect } from \"$/markup/transform.ts\";\nimport { scan_svelte_effect_source } from \"$/compiler/source-scan.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\t/** Transformed Svelte source. */\n\tcode: 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\t/** Markup emission target passed through to the markup transform. */\n\ttarget?: 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\tcontent: string,\n\tfilename = \"unknown.svelte\",\n\toptions: SvelteTransformOptions = {},\n): SvelteTransformResult {\n\tconst scan = scan_svelte_effect_source(content, filename);\n\tconst script = scan.effect_script;\n\n\tlet combined = content;\n\n\tif (script) {\n\t\tconst effect_attribute = script.effect_attribute;\n\t\tconst effect_attribute_start = effect_attribute?.start ?? script.opening_tag_end;\n\t\tconst effect_attribute_end = effect_attribute?.end ?? script.opening_tag_end;\n\t\tconst result = transform_script_effect(script.text, filename, {\n\t\t\temit_types: script.is_typescript,\n\t\t\ttarget: options.target ?? \"client\",\n\t\t});\n\n\t\tcombined =\n\t\t\tcontent.slice(0, effect_attribute_start) +\n\t\t\tcontent.slice(effect_attribute_end, script.opening_tag_end) +\n\t\t\tresult.code +\n\t\t\tcontent.slice(script.closing_tag_start);\n\t}\n\n\tconst markup_options = options.target === undefined ? {} : { target: options.target };\n\tconst result = transform_markup_effect(combined, filename, markup_options);\n\n\treturn { code: result.code };\n}\n\nexport {\n\ttype MarkupTransformOptions,\n\ttype MarkupTransformResult,\n\ttype MarkupTransformTarget,\n\ttransform_markup_effect,\n} from \"$/markup/transform.ts\";\n\nexport {\n\ttype BlockRef,\n\ttype ScriptTransformResult,\n\ttransform_script_effect,\n} from \"$/script-transform/index.ts\";\n"],"mappings":";;;;;;;AAEA,SAAgB,iCACf,QACA,UACS;CACT,OAAO,OAAO,KAAK,UAAU,0BAA0B,OAAO,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI;AACnF;AAEA,SAAS,0BAA0B,OAAoB,UAAyC;CAC/F,MAAM,YAAY,MAAM,KAAK,KAAK,QAAQ,KAAK,IAAI,EAAE;CAErD,MAAM,OAAO,MAAM,WAAW,KAAK,cAAc,OAAO,WAAW,CAAC,CAAC,KAAK,IAAI;CAE9E,OAAO;EACN;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,cAAc,SAAS,MAAM,UAAU,SAAS,QAAQ;EAC5I,8BAA8B,SAAS,OAAO;EAC9C,YAAY,SAAS,OAAO;EAC5B;EACA;CACD,CAAC,CAAC,KAAK,IAAI;AACZ;;;ACdA,SAAgB,gBACf,MACA,SACA,SACmB;CACnB,IAAI,GAAG,sBAAsB,IAAI,GAChC,OAAO,2BAA2B,MAAM,SAAS,OAAO;CAGzD,IAAI,GAAG,oBAAoB,IAAI,GAC9B,OAAO,yBAAyB,MAAM,SAAS,OAAO;CAGvD,MAAM,OAAO,MAAM,SAAS,IAAI;CAGhC,OAAO;EACN,OAAO,CAAC;EACR,gBAAgB;EAChB,eAAe,CAAC,kBAAkB,CALd,yBAAyB,MAAM,SAAS,OAKd,CAAC,GAAG,aAAa,IAAI,CAAC,CAAC;EACrE,OAAO;GAAE,OAAO,KAAK,aAAa;GAAG,KAAK,KAAK;EAAI;CACpD;AACD;AAEA,SAAS,yBACR,MACA,SACA,SACmB;CACnB,MAAM,sBAAgC,CAAC;CACvC,MAAM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AU,cAEvC,CAAC,CAAC,KAAK;AAC5B"}
|
|
@@ -10,6 +10,6 @@ interface RuntimeImportOptions {
|
|
|
10
10
|
needs_scope_ref?: boolean;
|
|
11
11
|
}
|
|
12
12
|
export declare function make_imports(has_effect_import: boolean, has_dispatcher_import: boolean, has_untrack_import: boolean, has_on_destroy_import: boolean, bindings?: RuntimeImportBindings, options?: RuntimeImportOptions): string;
|
|
13
|
-
export declare function has_local_import_binding(source_file: ts.SourceFile, module_name: string, local_name: string): boolean;
|
|
13
|
+
export declare function has_local_import_binding(source_file: ts.SourceFile, module_name: string, local_name: string, allow_namespace_import?: boolean): boolean;
|
|
14
14
|
export declare function collect_top_level_binding_names(source_file: ts.SourceFile): string[];
|
|
15
15
|
export {};
|
package/.dist/server.js
CHANGED
|
@@ -2,8 +2,8 @@ import { D as UncheckedLiveQueryHandlerMissingError, E as UncheckedFormHandlerMi
|
|
|
2
2
|
import { create_form_error, create_remote_transport_error } from "./remote/shared.js";
|
|
3
3
|
import { i as make_remote_live_stream, r as make_failed_remote_live_stream, t as Live } from "./chunks/live-BW7xZKjb.js";
|
|
4
4
|
import { a as normalize_validator, c as attach_remote_resource_getters, d as MakeEffectFromPromise, f as MakeEffectFromSync, l as is_remote_resource, n as attach_native_remote_query_update, o as attach_failed_remote_query_resource, r as resolve_native_remote_query_updates, s as attach_failed_remote_resource_getters, t as copy_property_descriptors, u as FailWithRemoteError } from "./chunks/descriptors-q909VWyR.js";
|
|
5
|
-
import { i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-
|
|
6
|
-
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-
|
|
5
|
+
import { a as to_remote_failure_context, i as throw_remote_cause, n as run_remote_effect, t as normalize_remote_helper_error } from "./chunks/server-NeyeDSax.js";
|
|
6
|
+
import { i as get_server_runtime_or_throw, n as ServerRuntime, t as RequestEvent } from "./chunks/runtime-B8RHHy3v.js";
|
|
7
7
|
import { Effect, Result, Stream } from "effect";
|
|
8
8
|
import { error, invalid, redirect } from "@sveltejs/kit";
|
|
9
9
|
import { stringify } from "devalue";
|
|
@@ -61,10 +61,10 @@ function run_live_handler(handler, event) {
|
|
|
61
61
|
}
|
|
62
62
|
function run_live_source_effect(effect, event) {
|
|
63
63
|
const runtime = get_server_runtime_or_throw();
|
|
64
|
-
return run_remote_effect(Effect.provideService(effect, RequestEvent, event), runtime, invalid, svelte_remote_error);
|
|
64
|
+
return run_remote_effect(Effect.provideService(effect, RequestEvent, event), runtime, invalid, svelte_remote_error, to_remote_failure_context(event));
|
|
65
65
|
}
|
|
66
|
-
const ToLiveSourceEffect = (value, event) => Stream.toAsyncIterableEffect(preserve_live_source_cause(value)).pipe(Effect.map((source) => wrap_live_source_errors(source, event)));
|
|
67
|
-
const preserve_live_source_cause = (value) => value.pipe(Stream.catchCause((cause) => Stream.fromEffect(Effect.sync(() => throw_remote_cause(cause, invalid, svelte_remote_error)))));
|
|
66
|
+
const ToLiveSourceEffect = (value, event) => Stream.toAsyncIterableEffect(preserve_live_source_cause(value, event)).pipe(Effect.map((source) => wrap_live_source_errors(source, event)));
|
|
67
|
+
const preserve_live_source_cause = (value, event) => value.pipe(Stream.catchCause((cause) => Stream.fromEffect(Effect.sync(() => throw_remote_cause(cause, invalid, svelte_remote_error, to_remote_failure_context(event))))));
|
|
68
68
|
function wrap_live_source_errors(source, event) {
|
|
69
69
|
return { [Symbol.asyncIterator]() {
|
|
70
70
|
const iterator = source[Symbol.asyncIterator]();
|
|
@@ -96,7 +96,7 @@ function RunLiveIteratorCall(event, run) {
|
|
|
96
96
|
}
|
|
97
97
|
function run_handler_effect(value, event) {
|
|
98
98
|
const runtime = get_server_runtime_or_throw();
|
|
99
|
-
return run_remote_effect(Effect.provideService(RunInsideRemoteEffectHandler(event, ToEffect(value)), RequestEvent, event), runtime, invalid, svelte_remote_error);
|
|
99
|
+
return run_remote_effect(Effect.provideService(RunInsideRemoteEffectHandler(event, ToEffect(value)), RequestEvent, event), runtime, invalid, svelte_remote_error, to_remote_failure_context(event));
|
|
100
100
|
}
|
|
101
101
|
const svelte_remote_error = (status, body) => {
|
|
102
102
|
error(status, body);
|