svelte-effect-runtime 4.2.3 → 4.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/.dist/chunks/{client-D-u6MNHj.js → client-Bi7SwVVy.js} +24 -14
  2. package/.dist/chunks/client-Bi7SwVVy.js.map +1 -0
  3. package/.dist/chunks/{compiler-Dpyu4Owd.js → compiler-B2htZszc.js} +8 -5
  4. package/.dist/chunks/{compiler-Dpyu4Owd.js.map → compiler-B2htZszc.js.map} +1 -1
  5. package/.dist/chunks/{dispatcher-B75hLhx3.js → dispatcher-BFTvQ7sm.js} +3 -3
  6. package/.dist/chunks/{dispatcher-B75hLhx3.js.map → dispatcher-BFTvQ7sm.js.map} +1 -1
  7. package/.dist/chunks/{dispatcher-DGSStOLQ.js → dispatcher-D3Tpa5HC.js} +24 -16
  8. package/.dist/chunks/dispatcher-D3Tpa5HC.js.map +1 -0
  9. package/.dist/chunks/{remote-client-mkQAfP1G.js → remote-client-C_3kdug0.js} +15 -4
  10. package/.dist/chunks/remote-client-C_3kdug0.js.map +1 -0
  11. package/.dist/chunks/{runtime-D4a2CqmT.js → runtime-CmiEHnSw.js} +2 -2
  12. package/.dist/chunks/{runtime-D4a2CqmT.js.map → runtime-CmiEHnSw.js.map} +1 -1
  13. package/.dist/chunks/{server-BNxq-pUH.js → server-Dxb9zr99.js} +16 -3
  14. package/.dist/chunks/server-Dxb9zr99.js.map +1 -0
  15. package/.dist/compiler/remote-client.d.ts +1 -0
  16. package/.dist/compiler.js +1 -1
  17. package/.dist/dispatcher/index.d.ts +4 -4
  18. package/.dist/dispatcher/scope.d.ts +10 -1
  19. package/.dist/dispatcher.js +1 -1
  20. package/.dist/environment.d.ts +9 -3
  21. package/.dist/environment.js.map +1 -1
  22. package/.dist/internal/generators.js +2 -2
  23. package/.dist/internal/remote-client.js +1 -1
  24. package/.dist/internal/remote-server.js +1 -1
  25. package/.dist/markup/promise.js +1 -1
  26. package/.dist/markup/run.js +1 -1
  27. package/.dist/markup/value.js +1 -1
  28. package/.dist/mod.js +2 -2
  29. package/.dist/remote/client/form-data.d.ts +8 -1
  30. package/.dist/remote/client/form.d.ts +2 -2
  31. package/.dist/remote/client/types.d.ts +10 -11
  32. package/.dist/remote/client.js +1 -1
  33. package/.dist/remote/native-types.d.ts +292 -0
  34. package/.dist/remote/server.js +1 -1
  35. package/.dist/server/factories.d.ts +4 -4
  36. package/.dist/server/live-snapshot.d.ts +2 -2
  37. package/.dist/server/types.d.ts +7 -7
  38. package/.dist/server.js +4 -4
  39. package/.dist/server.js.map +1 -1
  40. package/package.json +2 -2
  41. package/.dist/chunks/client-D-u6MNHj.js.map +0 -1
  42. package/.dist/chunks/dispatcher-DGSStOLQ.js.map +0 -1
  43. package/.dist/chunks/remote-client-mkQAfP1G.js.map +0 -1
  44. package/.dist/chunks/server-BNxq-pUH.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispatcher-D3Tpa5HC.js","names":["#on_dispose","#scope","#disposed","#notify_value_cells","#runtime","#root_scope","#component_scopes","#current_scope","#disposed","#scope_ids","#clear_scope_cache","#emit_markup_value","#emit_markup_promise","#emit_markup_run","#next_fiber_id","#fibers","#scope_id","#make_scoped_id","#make_value_cache_key","#value_ids","#subscribe_value_cells","#value_cells","#interrupt_cached_fiber","#delete_value_cell","#should_start_value_fiber","#start_value_fiber","#make_promise_cache_key","#promise_ids","#promise_values","#start_promise_fiber","#is_server_render","#clear_value_cells","#hash_deps","#next_scope_id","#is_current_fiber","#set_value_cell","#complete_fiber","#publish_value_success","#publish_value_failure","#get_dispatcher","#scope"],"sources":["../../../modules/svelte-effect-runtime/src/dispatcher/fibers.ts","../../../modules/svelte-effect-runtime/src/dispatcher/scope.ts","../../../modules/svelte-effect-runtime/src/dispatcher/deps.ts","../../../modules/svelte-effect-runtime/src/dispatcher/types.ts","../../../modules/svelte-effect-runtime/src/dispatcher/index.ts"],"sourcesContent":["import type { Fiber as FiberType } from \"effect/Fiber\";\nimport { Cause, Effect, Exit, Fiber } from \"effect\";\n\nexport interface FiberWatchCallbacks<A> {\n\ton_complete?: () => void;\n\ton_success?: (value: A) => void;\n\ton_failure?: (error: unknown) => void;\n\tsurface_failure?: boolean;\n}\n\nexport const InterruptFiber = (fiber: FiberType<unknown, unknown>) =>\n\tEffect.gen(function* () {\n\t\tyield* Fiber.interrupt(fiber);\n\t});\n\n/** Observes fiber completion and surfaces failures without taking ownership of the fiber. */\nexport const WatchFiberExit = <A>(\n\toptions: { fiber: FiberType<unknown, unknown> } & FiberWatchCallbacks<A>,\n) => {\n\tconst { fiber, on_complete, on_success, on_failure, surface_failure = true } = options;\n\n\treturn Effect.gen(function* () {\n\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\tyield* Effect.sync(() => {\n\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\ton_success?.(exit.value as A);\n\t\t\t\ton_complete?.();\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (!Cause.hasInterruptsOnly(exit.cause)) {\n\t\t\t\tconst error = Cause.squash(exit.cause);\n\n\t\t\t\ton_failure?.(error);\n\n\t\t\t\tif (surface_failure) {\n\t\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\n\t\t\ton_complete?.();\n\t\t});\n\t});\n};\n","import { Effect, Exit, Scope } from \"effect\";\nimport type { Fiber } from \"effect\";\n\n/**\n * A component-owned Effect scope.\n *\n * A `ComponentScope` wraps a `Scope.Closeable` forked from the dispatcher's\n * root scope. Work is forked into the scope with `Effect.forkIn`, so closing\n * the scope interrupts that work and runs its finalizers. The generated\n * component teardown disposes the scope on destroy. Disposal is idempotent.\n *\n * @since 4.1.0\n */\nexport class ComponentScope {\n\t#scope: Scope.Closeable;\n\t#disposed = false;\n\treadonly #on_dispose: (scope: ComponentScope) => void;\n\n\tprivate constructor(scope: Scope.Closeable, on_dispose: (scope: ComponentScope) => void) {\n\t\tthis.#scope = scope;\n\t\tthis.#on_dispose = on_dispose;\n\t}\n\n\t/** Forks a child scope from the given root and returns it wrapped. */\n\tstatic fork(\n\t\troot: Scope.Closeable,\n\t\ton_dispose: (scope: ComponentScope) => void,\n\t): ComponentScope {\n\t\treturn new ComponentScope(Scope.forkUnsafe(root), on_dispose);\n\t}\n\n\t/** The underlying closeable scope used to bind Effect work. */\n\tget underlying(): Scope.Closeable {\n\t\treturn this.#scope;\n\t}\n\n\t/** Whether this scope has already been disposed. */\n\tget disposed(): boolean {\n\t\treturn this.#disposed;\n\t}\n\n\t/**\n\t * Forks an effect into this scope. The fiber becomes a child of the scope,\n\t * so disposing the scope interrupts it and runs its finalizers. The scope\n\t * is provided ambiently so `Effect.forkIn` registers the fiber as a child.\n\t */\n\tfork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R> {\n\t\t/**\n\t\t * The effect must see the scope before it is forked: provide the scope\n\t\t * inside the forked program so `acquireRelease`-style work resolves it,\n\t\t * and fork that program into the scope so the fiber is a child whose\n\t\t * finalizers run when the scope closes.\n\t\t */\n\t\treturn Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, this.#scope),\n\t\t\tthis.#scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t}\n\n\t/**\n\t * Forks an effect into a child scope owned by one reactive run. The child\n\t * remains open after setup completes so nested scoped work survives until\n\t * that run is invalidated, while component disposal remains its backstop.\n\t */\n\tfork_run_in<A, E, R>(\n\t\teffect: Effect.Effect<A, E, R>,\n\t): {\n\t\treadonly fork_effect: Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\t\treadonly close_effect: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>;\n\t} {\n\t\tconst run_scope = Scope.forkUnsafe(this.#scope);\n\t\tconst fork_effect = Effect.forkIn(\n\t\t\tEffect.provideService(effect, Scope.Scope, run_scope),\n\t\t\trun_scope,\n\t\t) as Effect.Effect<Fiber.Fiber<A, E>, never, R>;\n\n\t\treturn {\n\t\t\tfork_effect,\n\t\t\tclose_effect: (exit) => Scope.close(run_scope, exit),\n\t\t};\n\t}\n\n\t/** Effect that closes the scope. Must be run by the owning dispatcher. */\n\tget close_effect(): Effect.Effect<void> {\n\t\treturn Scope.close(this.#scope, Exit.void);\n\t}\n\n\t/**\n\t * Marks the scope disposed and detaches it from the dispatcher. The caller\n\t * is responsible for running {@link close_effect} to run finalizers.\n\t * Idempotent.\n\t */\n\tdispose(): void {\n\t\tif (this.#disposed) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#disposed = true;\n\t\tthis.#on_dispose(this);\n\t}\n}\n","/** Assigns stable identities to object dependencies while hashing value dependencies. */\nexport type DependencyHasher = (deps: readonly unknown[]) => string;\n\nexport function make_dependency_hasher(): DependencyHasher {\n\tconst object_dep_ids = new WeakMap<object, number>();\n\tconst symbol_dep_ids = new Map<symbol, number>();\n\n\tlet next_object_dep_id = 0;\n\tlet next_symbol_dep_id = 0;\n\n\tconst hash_symbol_dep = (dep: symbol): string => {\n\t\tlet id = symbol_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_symbol_dep_id += 1;\n\t\t\tid = next_symbol_dep_id;\n\t\t\tsymbol_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `y:${id}`;\n\t};\n\n\tconst hash_object_dep = (dep: object): string => {\n\t\tlet id = object_dep_ids.get(dep);\n\n\t\tif (id === undefined) {\n\t\t\tnext_object_dep_id += 1;\n\t\t\tid = next_object_dep_id;\n\t\t\tobject_dep_ids.set(dep, id);\n\t\t}\n\n\t\treturn `o:${id}`;\n\t};\n\n\tconst hash_dep = (dep: unknown): string | readonly [\"s\", string] => {\n\t\tif (dep === null) {\n\t\t\treturn \"l:null\";\n\t\t}\n\n\t\tif (dep === undefined) {\n\t\t\treturn \"u:undefined\";\n\t\t}\n\n\t\tconst type = typeof dep;\n\n\t\tif (type === \"string\") {\n\t\t\treturn [\"s\", dep as string];\n\t\t}\n\n\t\tif (type === \"number\") {\n\t\t\treturn `n:${Object.is(dep, -0) ? \"-0\" : String(dep)}`;\n\t\t}\n\n\t\tif (type === \"bigint\") {\n\t\t\treturn `b:${dep}`;\n\t\t}\n\n\t\tif (type === \"boolean\") {\n\t\t\treturn dep ? \"t:true\" : \"f:false\";\n\t\t}\n\n\t\tif (type === \"symbol\") {\n\t\t\treturn hash_symbol_dep(dep as symbol);\n\t\t}\n\n\t\treturn hash_object_dep(dep as object);\n\t};\n\n\tconst hash_deps = (deps: readonly unknown[]): string => JSON.stringify(deps.map(hash_dep));\n\n\treturn hash_deps;\n}\n","import type { Effect } from \"effect\";\n\nexport const Code = {\n\tMarkup: {\n\t\tPromise: \"MarkupPromise\",\n\t\tRun: \"MarkupRun\",\n\t\tValue: \"MarkupValue\",\n\t},\n} as const;\n\nexport interface MarkupPromiseOptions {\n\t/** Keep the SSR promise pending so Svelte renders an await block fallback. */\n\tssr?: \"pending\";\n}\n\nexport type Dispose = () => void;\n\nexport interface ValueOptions<A> {\n\t/** Stable cache key for this value block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is running or during SSR. */\n\tfallback: A;\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface PromiseOptions<A> {\n\t/** Stable cache key for this promise block. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfactory: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupValueEvent<A, F> {\n\ttype: typeof Code.Markup.Value;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\t/** Value returned synchronously while the effect is pending. */\n\tfallback: F;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport interface MarkupPromiseEvent<A> {\n\ttype: typeof Code.Markup.Promise;\n\t/** Stable identifier generated from the expression's source position. */\n\tid: string;\n\tdeps: readonly unknown[];\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n\t/** Value resolved during SSR when a fallback is required. */\n\tssr_fallback?: A;\n\t/** Optional SSR behavior for await blocks and similar contexts. */\n\toptions?: MarkupPromiseOptions;\n}\n\nexport interface MarkupRunEvent<A> {\n\ttype: typeof Code.Markup.Run;\n\tfn: () => Effect.gen.Return<A, unknown, unknown>;\n}\n\nexport type DispatcherEvent<A, F = A> =\n\t| MarkupPromiseEvent<A>\n\t| MarkupRunEvent<A>\n\t| MarkupValueEvent<A, F>;\n","import type {\n\tDispatcherEvent,\n\tDispose,\n\tMarkupPromiseEvent,\n\tMarkupRunEvent,\n\tMarkupValueEvent,\n\tPromiseOptions,\n\tValueOptions,\n} from \"./types.ts\";\nimport {\n\tRuntimeAlreadyInitializedError,\n\tDispatcherDisposedError,\n\tScopeDisposedError,\n} from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport { Cause, Effect, Exit, Fiber, Layer, ManagedRuntime, Scope } from \"effect\";\nimport { InterruptFiber, WatchFiberExit } from \"./fibers.ts\";\nimport { ComponentScope } from \"./scope.ts\";\nimport type { Fiber as FiberType } from \"effect/Fiber\";\nimport { createSubscriber } from \"svelte/reactivity\";\nimport { make_dependency_hasher } from \"./deps.ts\";\nimport { isRedirect } from \"@sveltejs/kit\";\nimport { Code } from \"./types.ts\";\n\nexport { Code } from \"./types.ts\";\nexport type { Dispose, PromiseOptions, ValueOptions } from \"./types.ts\";\n\ntype ValueCell<A> =\n\t| {\n\t\t\treadonly status: \"pending\";\n\t\t\treadonly fiber: FiberType<unknown, unknown>;\n\t }\n\t| {\n\t\t\treadonly status: \"success\";\n\t\t\treadonly value: A;\n\t }\n\t| {\n\t\t\treadonly status: \"failure\";\n\t\t\treadonly error: unknown;\n\t };\n\nexport class Dispatcher {\n\t#runtime: ManagedRuntimeType<unknown, unknown>;\n\t#fibers = new Map<string, FiberType<unknown, unknown>>();\n\t#value_cells = new Map<string, ValueCell<unknown>>();\n\t#notify_value_cells = (): void => {};\n\t#subscribe_value_cells = createSubscriber((update) => {\n\t\tthis.#notify_value_cells = update;\n\n\t\treturn () => {\n\t\t\tif (this.#notify_value_cells !== update) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthis.#notify_value_cells = (): void => {};\n\t\t};\n\t});\n\t#promise_values = new Map<string, Promise<unknown>>();\n\t#value_ids = new Map<string, string>();\n\t#promise_ids = new Map<string, string>();\n\t#scope_ids = new WeakMap<ComponentScope, string>();\n\t#hash_deps = make_dependency_hasher();\n\t#disposed = false;\n\t#next_fiber_id = 0;\n\t#next_scope_id = 0;\n\t#root_scope = Scope.makeUnsafe();\n\t#component_scopes = new Set<ComponentScope>();\n\t/**\n\t * The component scope that effect execution currently enters. Set by\n\t * generated code via {@link with_scope}; `undefined` outside components.\n\t */\n\t#current_scope: ComponentScope | undefined = undefined;\n\n\tstatic make<R = never>(layer?: Layer.Layer<R>): Dispatcher {\n\t\tif (current_dispatcher) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ClientRuntime\");\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tconst dispatcher = new Dispatcher(runtime as ManagedRuntimeType<unknown, unknown>);\n\t\tcurrent_dispatcher = dispatcher;\n\n\t\treturn dispatcher;\n\t}\n\n\tconstructor(runtime?: ManagedRuntimeType<unknown, unknown>) {\n\t\tthis.#runtime =\n\t\t\truntime ??\n\t\t\t(ManagedRuntime.make(Layer.empty) as unknown as ManagedRuntimeType<unknown, unknown>);\n\t}\n\n\t/**\n\t * Begin a component-owned Effect scope. Pass the returned scope to\n\t * {@link run_scoped} so the work is interrupted and finalized when the\n\t * component is destroyed. Disposal is idempotent.\n\t */\n\tbegin_scope(): ComponentScope {\n\t\tconst scope = ComponentScope.fork(this.#root_scope, (disposed) => {\n\t\t\tthis.#component_scopes.delete(disposed);\n\t\t});\n\n\t\tthis.#component_scopes.add(scope);\n\n\t\treturn scope;\n\t}\n\n\t/**\n\t * Runs `fn` with `scope` as the current component scope. While active,\n\t * every effect path ({@link promise}, {@link run}, {@link value}) forks\n\t * its work into `scope` so disposing the scope interrupts it and runs its\n\t * finalizers. A disposed scope falls back to unscoped execution.\n\t */\n\twith_scope<T>(scope: ComponentScope, fn: () => T): T {\n\t\tif (scope.disposed) {\n\t\t\treturn fn();\n\t\t}\n\n\t\tconst previous = this.#current_scope;\n\t\tthis.#current_scope = scope;\n\n\t\ttry {\n\t\t\treturn fn();\n\t\t} finally {\n\t\t\tthis.#current_scope = previous;\n\t\t}\n\t}\n\n\t/**\n\t * Forks an effect into a reactive-run scope and starts it. The run scope is\n\t * a child of the component scope, so rerun cleanup closes only that run\n\t * while component disposal remains a backstop. Returns an idempotent handle\n\t * that closes the run scope and all work forked into it.\n\t *\n\t * Throws {@link ScopeDisposedError} when the scope was already disposed\n\t * and {@link DispatcherDisposedError} when the dispatcher was shut down.\n\t */\n\trun_scoped<A, E, R>(scope: ComponentScope, effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tif (scope.disposed || !this.#component_scopes.has(scope)) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tconst run = scope.fork_run_in(effect);\n\t\tlet disposed = false;\n\n\t\tthis.#runtime.runFork(\n\t\t\tEffect.flatMap(run.fork_effect, (fiber) => {\n\t\t\t\treturn Effect.flatMap(Fiber.await(fiber), (exit) => {\n\t\t\t\t\treturn Exit.isFailure(exit) ? run.close_effect(exit) : Effect.void;\n\t\t\t\t});\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(\n\t\t\t\trun.close_effect(Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\t\t};\n\t}\n\n\t/**\n\t * Disposes a component scope owned by this dispatcher, interrupting its\n\t * bound work and running its finalizers. Idempotent. Rejects scopes owned\n\t * by another dispatcher with {@link ScopeDisposedError}.\n\t */\n\tdispose_scope(scope: ComponentScope): void {\n\t\tif (!this.#component_scopes.has(scope)) {\n\t\t\tif (scope.disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tconst scope_id = this.#scope_ids.get(scope);\n\n\t\tif (scope_id !== undefined) {\n\t\t\tthis.#scope_ids.delete(scope);\n\t\t\tthis.#clear_scope_cache(scope_id);\n\t\t}\n\n\t\tscope.dispose();\n\t\tthis.#runtime.runFork(scope.close_effect as Effect.Effect<unknown, unknown, unknown>);\n\t}\n\n\temit<A, F>(event: MarkupValueEvent<A, F>): A | F;\n\temit<A>(event: MarkupPromiseEvent<A>): Promise<A>;\n\temit<A>(event: MarkupRunEvent<A>): Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A>;\n\temit<A, F>(event: DispatcherEvent<A, F>): A | F | Promise<A> {\n\t\tswitch (event.type) {\n\t\t\tcase Code.Markup.Value:\n\t\t\t\treturn this.#emit_markup_value(event);\n\n\t\t\tcase Code.Markup.Promise:\n\t\t\t\treturn this.#emit_markup_promise(event);\n\n\t\t\tcase Code.Markup.Run:\n\t\t\t\treturn this.#emit_markup_run(event);\n\t\t}\n\t}\n\n\tfork<A, E, R>(effect: Effect.Effect<A, E, R>): Dispose {\n\t\tif (this.#disposed) {\n\t\t\treturn () => {};\n\t\t}\n\n\t\tconst fiber = this.#runtime.runFork(effect as Effect.Effect<unknown, unknown, unknown>);\n\t\tconst key = `fork:${this.#next_fiber_id}`;\n\n\t\tthis.#next_fiber_id += 1;\n\t\tthis.#fibers.set(key, fiber);\n\t\tthis.#runtime.runFork(\n\t\t\tWatchFiberExit({\n\t\t\t\tfiber,\n\t\t\t\ton_complete: () => this.#fibers.delete(key),\n\t\t\t}),\n\t\t);\n\n\t\tlet disposed = false;\n\n\t\treturn (): void => {\n\t\t\tif (disposed) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tdisposed = true;\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t};\n\t}\n\n\tvalue<A>(options: ValueOptions<A>): A {\n\t\tif (this.#disposed) {\n\t\t\treturn options.fallback;\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_value_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#value_ids.get(cache_id);\n\n\t\tthis.#subscribe_value_cells();\n\n\t\tconst cell = this.#value_cells.get(cache_key);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#delete_value_cell(old_key);\n\t\t}\n\n\t\tthis.#value_ids.set(cache_id, cache_key);\n\n\t\tif (this.#should_start_value_fiber(cache_key, cell)) {\n\t\t\tthis.#start_value_fiber(cache_key, options);\n\t\t}\n\n\t\tif (cell?.status === \"success\") {\n\t\t\treturn cell.value as A;\n\t\t}\n\n\t\tif (cell?.status === \"failure\") {\n\t\t\tthrow cell.error;\n\t\t}\n\n\t\treturn options.fallback;\n\t}\n\n\tpromise<A>(options: PromiseOptions<A>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scope_id = this.#scope_id(this.#current_scope);\n\t\tconst cache_id = this.#make_scoped_id(scope_id, options.id);\n\t\tconst cache_key = this.#make_promise_cache_key(cache_id, options.deps);\n\t\tconst old_key = this.#promise_ids.get(cache_id);\n\n\t\tif (old_key !== undefined && old_key !== cache_key) {\n\t\t\tthis.#interrupt_cached_fiber(old_key);\n\t\t\tthis.#promise_values.delete(old_key);\n\t\t}\n\n\t\tthis.#promise_ids.set(cache_id, cache_key);\n\n\t\tconst existing = this.#promise_values.get(cache_key);\n\n\t\tif (existing) {\n\t\t\treturn existing as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#start_promise_fiber(cache_key, options, cache_id);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\trun<A, E, R>(effect: Effect.Effect<A, E, R>): Promise<A> {\n\t\tif (this.#disposed) {\n\t\t\treturn Promise.reject(new DispatcherDisposedError());\n\t\t}\n\n\t\tconst scoped_effect = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.exit(effect);\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * Surface the failure without reporting it. Both the scoped and the\n\t\t\t * unscoped path funnel through `interpreted_program`, which reports\n\t\t\t * once, so reporting here would raise every failure twice.\n\t\t\t */\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\tconst scope = this.#current_scope;\n\t\tconst materialized_program = scope\n\t\t\t? Effect.flatMap(scope.fork_in(scoped_effect), (fiber) => Fiber.await(fiber))\n\t\t\t: Effect.exit(scoped_effect);\n\t\tconst interpreted_program = Effect.gen(function* () {\n\t\t\tconst result = yield* materialized_program;\n\n\t\t\tif (Exit.isSuccess(result)) {\n\t\t\t\treturn result.value;\n\t\t\t}\n\n\t\t\tif (Cause.hasInterruptsOnly(result.cause)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tconst error = Cause.squash(result.cause);\n\n\t\t\tif (isRedirect(error)) {\n\t\t\t\treturn undefined as A;\n\t\t\t}\n\n\t\t\tyield* Effect.sync(() => {\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tthrow error;\n\t\t\t\t});\n\t\t\t});\n\n\t\t\treturn yield* Effect.fail(error);\n\t\t});\n\n\t\treturn this.#runtime.runPromise(interpreted_program as Effect.Effect<A, unknown, unknown>);\n\t}\n\n\t#emit_markup_value<A, F>(event: MarkupValueEvent<A, F>): A | F {\n\t\tif (this.#is_server_render()) {\n\t\t\treturn event.fallback;\n\t\t}\n\n\t\treturn this.value<A | F>({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfallback: event.fallback,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_promise<A>(event: MarkupPromiseEvent<A>): Promise<A> {\n\t\tif (this.#is_server_render()) {\n\t\t\tif (event.options?.ssr === \"pending\") {\n\t\t\t\treturn new Promise<A>(() => {});\n\t\t\t}\n\n\t\t\tif (\"ssr_fallback\" in event) {\n\t\t\t\treturn Promise.resolve(event.ssr_fallback as A);\n\t\t\t}\n\t\t}\n\n\t\treturn this.promise({\n\t\t\tid: event.id,\n\t\t\tdeps: event.deps,\n\t\t\tfactory: event.fn,\n\t\t});\n\t}\n\n\t#emit_markup_run<A>(event: MarkupRunEvent<A>): Promise<A> {\n\t\tconst Program = Effect.gen(event.fn);\n\n\t\treturn this.run(Program);\n\t}\n\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tfor (const scope of this.#component_scopes) {\n\t\t\tscope.dispose();\n\t\t}\n\n\t\tthis.#component_scopes.clear();\n\t\tthis.#runtime.runFork(\n\t\t\tScope.close(this.#root_scope, Exit.void) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tfor (const fiber of this.#fibers.values()) {\n\t\t\tthis.#runtime.runFork(InterruptFiber(fiber));\n\t\t}\n\n\t\tthis.#fibers.clear();\n\t\tthis.#clear_value_cells();\n\t\tthis.#promise_values.clear();\n\t\tthis.#value_ids.clear();\n\t\tthis.#promise_ids.clear();\n\n\t\tvoid this.#runtime.dispose().catch((error: unknown) => {\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthrow error;\n\t\t\t});\n\t\t});\n\t}\n\n\t/**\n\t * Read-only snapshot of the value/promise cache keys. Diagnostic surface\n\t * for leak regression tests; not part of the runtime contract.\n\t */\n\tinspect_cache(): { value_cells: readonly string[]; promise_values: readonly string[] } {\n\t\treturn {\n\t\t\tvalue_cells: [...this.#value_cells.keys()],\n\t\t\tpromise_values: [...this.#promise_values.keys()],\n\t\t};\n\t}\n\n\t#make_value_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `value:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#make_promise_cache_key(id: string, deps: readonly unknown[]): string {\n\t\treturn `promise:${id}::${this.#hash_deps(deps)}`;\n\t}\n\n\t#is_server_render(): boolean {\n\t\treturn typeof document === \"undefined\";\n\t}\n\n\t#scope_id(scope: ComponentScope | undefined): string {\n\t\tif (!scope || scope.disposed) {\n\t\t\treturn \"global\";\n\t\t}\n\n\t\tconst existing = this.#scope_ids.get(scope);\n\n\t\tif (existing) {\n\t\t\treturn existing;\n\t\t}\n\n\t\tconst next = String(this.#next_scope_id);\n\t\tthis.#next_scope_id += 1;\n\t\tthis.#scope_ids.set(scope, next);\n\n\t\treturn next;\n\t}\n\n\t#clear_scope_cache(scope_id: string): void {\n\t\tconst value_prefix = `${scope_id}|`;\n\t\tconst promise_prefix = `${scope_id}|`;\n\n\t\tfor (const [cache_id, cache_key] of this.#value_ids) {\n\t\t\tif (!cache_id.startsWith(value_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#value_ids.delete(cache_id);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const [cache_id, cache_key] of this.#promise_ids) {\n\t\t\tif (!cache_id.startsWith(promise_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t}\n\n\t\t/**\n\t\t * value() and promise() evict a superseded key eagerly, so the id maps\n\t\t * above normally cover everything. Sweep the caches themselves as a\n\t\t * backstop so unmounting releases any entry the hot path missed.\n\t\t */\n\t\tconst value_key_prefix = `value:${scope_id}|`;\n\t\tconst promise_key_prefix = `promise:${scope_id}|`;\n\n\t\tfor (const cache_key of [...this.#value_cells.keys()]) {\n\t\t\tif (!cache_key.startsWith(value_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#delete_value_cell(cache_key);\n\t\t}\n\n\t\tfor (const cache_key of [...this.#promise_values.keys()]) {\n\t\t\tif (!cache_key.startsWith(promise_key_prefix)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tthis.#interrupt_cached_fiber(cache_key);\n\t\t\tthis.#promise_values.delete(cache_key);\n\t\t}\n\t}\n\n\t#make_scoped_id(scope_id: string, id: string): string {\n\t\treturn `${scope_id}|${id}`;\n\t}\n\n\t#interrupt_cached_fiber(cache_key: string): FiberType<unknown, unknown> | undefined {\n\t\tconst old_fiber = this.#fibers.get(cache_key);\n\n\t\tif (!old_fiber) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tthis.#runtime.runFork(InterruptFiber(old_fiber));\n\t\tthis.#fibers.delete(cache_key);\n\n\t\treturn old_fiber;\n\t}\n\n\t#should_start_value_fiber(cache_key: string, cell: ValueCell<unknown> | undefined): boolean {\n\t\treturn !this.#disposed && !this.#fibers.has(cache_key) && cell === undefined;\n\t}\n\n\t#start_value_fiber<A>(cache_key: string, options: ValueOptions<A>): void {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\tfiber,\n\t\t\t\t});\n\t\t\t});\n\n\t\t\tthis.#runtime.runFork(\n\t\t\t\tWatchFiberExit({\n\t\t\t\t\tfiber,\n\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, fiber),\n\t\t\t\t\ton_success: (value) => this.#publish_value_success(cache_key, fiber, value),\n\t\t\t\t\ton_failure: (error) => this.#publish_value_failure(cache_key, fiber, error),\n\t\t\t\t}),\n\t\t\t);\n\n\t\t\treturn;\n\t\t}\n\n\t\tlet launch_fiber: FiberType<unknown, unknown> | undefined;\n\t\tlet forked_fiber: FiberType<unknown, unknown> | undefined;\n\n\t\tconst launched = this.#runtime.runFork(\n\t\t\tEffect.flatMap(scope.fork_in(Program), (scoped_fiber) => {\n\t\t\t\tforked_fiber = scoped_fiber;\n\n\t\t\t\t/**\n\t\t\t\t * This continuation can run synchronously inside `runFork`,\n\t\t\t\t * before `launch_fiber` is assigned. In that case nothing can\n\t\t\t\t * have superseded the launch yet and the caller below records\n\t\t\t\t * the scoped fiber itself. An asynchronous continuation takes\n\t\t\t\t * over tracking only while its launch fiber is still current;\n\t\t\t\t * a superseded launch interrupts the orphaned scoped fiber.\n\t\t\t\t */\n\t\t\t\tif (launch_fiber !== undefined) {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, launch_fiber)) {\n\t\t\t\t\t\treturn InterruptFiber(scoped_fiber);\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\t}\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\tif (!this.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#runtime.runFork(\n\t\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\t\ton_complete: () => this.#complete_fiber(cache_key, scoped_fiber),\n\t\t\t\t\t\t\ton_success: (value) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_success(cache_key, scoped_fiber, value),\n\t\t\t\t\t\t\ton_failure: (error) =>\n\t\t\t\t\t\t\t\tthis.#publish_value_failure(cache_key, scoped_fiber, error),\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\n\t\t\t\t\tif (this.#value_cells.has(cache_key)) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tthis.#set_value_cell(cache_key, {\n\t\t\t\t\t\tstatus: \"pending\",\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t});\n\t\t\t\t});\n\n\t\t\t\treturn Effect.asVoid(Fiber.await(scoped_fiber));\n\t\t\t}) as Effect.Effect<unknown, unknown, unknown>,\n\t\t);\n\n\t\tlaunch_fiber = launched;\n\t\tthis.#fibers.set(cache_key, forked_fiber ?? launched);\n\t}\n\n\t#start_promise_fiber<A>(\n\t\tcache_key: string,\n\t\toptions: PromiseOptions<A>,\n\t\tcache_id: string,\n\t): Promise<A> {\n\t\tconst Program = Effect.gen(function* () {\n\t\t\tconst result = yield* Effect.gen(options.factory);\n\n\t\t\treturn result;\n\t\t});\n\t\tconst scope = this.#current_scope;\n\n\t\t/** Generator bodies passed to `Effect.gen` carry their own `this`. */\n\t\tconst dispatcher = this;\n\n\t\tif (!scope) {\n\t\t\tconst fiber = this.#runtime.runFork(\n\t\t\t\tProgram as Effect.Effect<unknown, unknown, unknown>,\n\t\t\t);\n\t\t\tconst ReleaseFiber = Effect.sync(() => {\n\t\t\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tthis.#fibers.delete(cache_key);\n\t\t\t\tthis.#promise_values.delete(cache_key);\n\n\t\t\t\tif (this.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\tthis.#promise_ids.delete(cache_id);\n\t\t\t\t}\n\t\t\t});\n\t\t\tconst AwaitFiber = Effect.gen(function* () {\n\t\t\t\tconst exit = yield* Fiber.await(fiber);\n\n\t\t\t\tyield* ReleaseFiber;\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t});\n\n\t\t\tthis.#fibers.set(cache_key, fiber);\n\t\t\tthis.#promise_values.set(cache_key, this.#runtime.runPromise(AwaitFiber));\n\n\t\t\treturn this.#promise_values.get(cache_key) as Promise<A>;\n\t\t}\n\n\t\tconst promise = this.#runtime.runPromise(\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst scoped_fiber = yield* scope.fork_in(Program);\n\n\t\t\t\tdispatcher.#fibers.set(cache_key, scoped_fiber);\n\t\t\t\tdispatcher.#runtime.runFork(\n\t\t\t\t\tWatchFiberExit({\n\t\t\t\t\t\tfiber: scoped_fiber,\n\t\t\t\t\t\t/**\n\t\t\t\t\t\t * The promise this call returns already rejects with the\n\t\t\t\t\t\t * failure, so surfacing it again would hand a handled\n\t\t\t\t\t\t * rejection back as an uncaught error.\n\t\t\t\t\t\t */\n\t\t\t\t\t\tsurface_failure: false,\n\t\t\t\t\t\ton_complete: () => {\n\t\t\t\t\t\t\tif (!dispatcher.#is_current_fiber(cache_key, scoped_fiber)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tdispatcher.#fibers.delete(cache_key);\n\t\t\t\t\t\t\tdispatcher.#promise_values.delete(cache_key);\n\n\t\t\t\t\t\t\tif (dispatcher.#promise_ids.get(cache_id) === cache_key) {\n\t\t\t\t\t\t\t\tdispatcher.#promise_ids.delete(cache_id);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t},\n\t\t\t\t\t}),\n\t\t\t\t);\n\n\t\t\t\tconst exit = yield* Fiber.await(scoped_fiber);\n\n\t\t\t\tif (Exit.isSuccess(exit)) {\n\t\t\t\t\treturn exit.value as A;\n\t\t\t\t}\n\n\t\t\t\treturn yield* Effect.fail(Cause.squash(exit.cause));\n\t\t\t}),\n\t\t);\n\n\t\tthis.#promise_values.set(cache_key, promise);\n\n\t\treturn promise;\n\t}\n\n\t#complete_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#fibers.delete(cache_key);\n\t}\n\n\t#publish_value_success<A>(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\tvalue: A,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"success\",\n\t\t\tvalue,\n\t\t});\n\t}\n\n\t#publish_value_failure(\n\t\tcache_key: string,\n\t\tfiber: FiberType<unknown, unknown>,\n\t\terror: unknown,\n\t): void {\n\t\tif (!this.#is_current_fiber(cache_key, fiber)) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#set_value_cell(cache_key, {\n\t\t\tstatus: \"failure\",\n\t\t\terror,\n\t\t});\n\t}\n\n\t#set_value_cell(cache_key: string, cell: ValueCell<unknown>): void {\n\t\tthis.#value_cells.set(cache_key, cell);\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#delete_value_cell(cache_key: string): void {\n\t\tconst deleted = this.#value_cells.delete(cache_key);\n\n\t\tif (!deleted) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#clear_value_cells(): void {\n\t\tif (this.#value_cells.size === 0) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#value_cells.clear();\n\t\tthis.#notify_value_cells();\n\t}\n\n\t#is_current_fiber(cache_key: string, fiber: FiberType<unknown, unknown>): boolean {\n\t\treturn !this.#disposed && this.#fibers.get(cache_key) === fiber;\n\t}\n}\n\nlet current_dispatcher: Dispatcher | null = null;\n\nexport function get_dispatcher(): Dispatcher {\n\tcurrent_dispatcher ??= new Dispatcher();\n\n\treturn current_dispatcher;\n}\n\nexport function reset_dispatcher(): void {\n\tcurrent_dispatcher?.dispose();\n\tcurrent_dispatcher = null;\n}\n\n/**\n * Lazily-created component scope used by generated component code.\n *\n * The holder is created synchronously during component init (before any\n * top-level `await`, where `onDestroy` is not yet available), and the scope\n * itself is materialized on first use. Disposal is registered separately\n * through `onDestroy` during component initialisation, so the scope is\n * reliably closed on unmount.\n *\n * @since 4.1.0\n */\nexport class ComponentScopeRef {\n\treadonly #get_dispatcher: () => Dispatcher;\n\t#scope: ComponentScope | undefined;\n\t#disposed = false;\n\n\tconstructor(get_dispatcher_fn: () => Dispatcher) {\n\t\tthis.#get_dispatcher = get_dispatcher_fn;\n\t}\n\n\t/** The component scope, creating it on first access. */\n\tget scope(): ComponentScope {\n\t\tif (this.#disposed) {\n\t\t\tthrow new ScopeDisposedError();\n\t\t}\n\n\t\tthis.#scope ??= this.#get_dispatcher().begin_scope();\n\n\t\treturn this.#scope;\n\t}\n\n\t/** Disposes the scope if it was created. Idempotent. */\n\tdispose(): void {\n\t\tthis.#disposed = true;\n\n\t\tconst scope = this.#scope;\n\t\tthis.#scope = undefined;\n\n\t\tif (scope && !scope.disposed) {\n\t\t\tthis.#get_dispatcher().dispose_scope(scope);\n\t\t}\n\t}\n}\n"],"mappings":";;;;;AAUA,MAAa,kBAAkB,UAC9B,OAAO,IAAI,aAAa;CACvB,OAAO,MAAM,UAAU,KAAK;AAC7B,CAAC;;AAGF,MAAa,kBACZ,YACI;CACJ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KAAKd,aAAa,IAAI,WAAW,IAAI;EACrC,KAAKlB,oBAAoB;CAC1B;CAEA,mBAAmB,WAAyB;EAG3C,IAAI,CAFY,KAAKkB,aAAa,OAAO,SAE9B,GACV;EAGD,KAAKlB,oBAAoB;CAC1B;CAEA,qBAA2B;EAC1B,IAAI,KAAKkB,aAAa,SAAS,GAC9B;EAGD,KAAKA,aAAa,MAAM;EACxB,KAAKlB,oBAAoB;CAC1B;CAEA,kBAAkB,WAAmB,OAA6C;EACjF,OAAO,CAAC,KAAKK,aAAa,KAAKO,QAAQ,IAAI,SAAS,MAAM;CAC3D;AACD;AAEA,IAAI,qBAAwC;AAE5C,SAAgB,iBAA6B;CAC5C,uBAAuB,IAAI,WAAW;CAEtC,OAAO;AACR;AAEA,SAAgB,mBAAyB;CACxC,oBAAoB,QAAQ;CAC5B,qBAAqB;AACtB;;;;;;;;;;;;AAaA,IAAa,oBAAb,MAA+B;CAC9B;CACA;CACA,YAAY;CAEZ,YAAY,mBAAqC;EAChD,KAAKwB,kBAAkB;CACxB;;CAGA,IAAI,QAAwB;EAC3B,IAAI,KAAK/B,WACR,MAAM,IAAI,mBAAmB;EAG9B,KAAKgC,WAAW,KAAKD,gBAAgB,CAAC,CAAC,YAAY;EAEnD,OAAO,KAAKC;CACb;;CAGA,UAAgB;EACf,KAAKhC,YAAY;EAEjB,MAAM,QAAQ,KAAKgC;EACnB,KAAKA,SAAS,KAAA;EAEd,IAAI,SAAS,CAAC,MAAM,UACnB,KAAKD,gBAAgB,CAAC,CAAC,cAAc,KAAK;CAE5C;AACD"}
@@ -11,7 +11,7 @@ const remote_client_export_types = /* @__PURE__ */ new Set([
11
11
  ]);
12
12
  /** Rewrites SvelteKit's generated remote client exports to SER adapters. */
13
13
  function rewrite_remote_client_exports(code, options) {
14
- const source_file = ts.createSourceFile("sveltekit-remote-client.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
14
+ const source_file = create_remote_client_source_file(code);
15
15
  const namespace_import = find_remote_namespace_import(source_file);
16
16
  if (!namespace_import) return code;
17
17
  const remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);
@@ -48,6 +48,12 @@ function rewrite_remote_client_exports(code, options) {
48
48
  for (const remote_export of remote_exports) magic.overwrite(remote_export.statement.getStart(source_file), remote_export.statement.end, make_remote_export(remote_export.name, remote_export.type, remote_export.native_call));
49
49
  return magic.toString();
50
50
  }
51
+ function find_remote_client_runtime_specifier(code) {
52
+ return find_remote_namespace_import(create_remote_client_source_file(code))?.specifier;
53
+ }
54
+ function create_remote_client_source_file(code) {
55
+ return ts.createSourceFile("sveltekit-remote-client.ts", code, ts.ScriptTarget.Latest, true, ts.ScriptKind.TS);
56
+ }
51
57
  function make_remote_export(name, remote_type, native_call) {
52
58
  if (remote_type === "command") return `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;
53
59
  if (remote_type === "form") return `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base, __SER___remote_form_transport);`;
@@ -64,15 +70,20 @@ function find_remote_namespace_import(source_file) {
64
70
  }
65
71
  }
66
72
  function get_remote_namespace_import(statement) {
67
- if (!ts.isStringLiteral(statement.moduleSpecifier) || statement.moduleSpecifier.text !== "__sveltekit/remote") return;
73
+ if (!ts.isStringLiteral(statement.moduleSpecifier) || !is_sveltekit_remote_client_specifier(statement.moduleSpecifier.text)) return;
68
74
  const import_clause = statement.importClause;
69
75
  const bindings = import_clause?.namedBindings;
70
76
  if (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) return;
71
77
  return {
72
78
  name: bindings.name.text,
79
+ specifier: statement.moduleSpecifier.text,
73
80
  statement
74
81
  };
75
82
  }
83
+ function is_sveltekit_remote_client_specifier(specifier) {
84
+ const normalized_specifier = specifier.replaceAll("\\", "/");
85
+ return normalized_specifier === "__sveltekit/remote" || normalized_specifier.endsWith("/@sveltejs/kit/src/runtime/client/remote-functions/index.js");
86
+ }
76
87
  function collect_remote_client_exports(source_file, code, namespace) {
77
88
  return source_file.statements.flatMap((statement) => collect_remote_client_export(source_file, code, namespace, statement));
78
89
  }
@@ -109,6 +120,6 @@ function is_const_declaration_list(declaration_list) {
109
120
  return (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;
110
121
  }
111
122
  //#endregion
112
- export { rewrite_remote_client_exports };
123
+ export { find_remote_client_runtime_specifier, rewrite_remote_client_exports };
113
124
 
114
- //# sourceMappingURL=remote-client-mkQAfP1G.js.map
125
+ //# sourceMappingURL=remote-client-C_3kdug0.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"remote-client-C_3kdug0.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/compiler/remote-client.ts"],"sourcesContent":["import type {\n\tExpression,\n\tImportDeclaration,\n\tSourceFile,\n\tStatement,\n\tVariableStatement,\n} from \"typescript\";\n\nimport MagicString from \"magic-string\";\nimport ts from \"typescript\";\n\ninterface RemoteClientRewriteOptions {\n\tdebug?: boolean;\n}\n\ntype RemoteClientExportType =\n\t| \"query_batch\"\n\t| \"query_live\"\n\t| \"query\"\n\t| \"command\"\n\t| \"form\"\n\t| \"prerender\";\n\ninterface RemoteNamespaceImport {\n\tname: string;\n\tspecifier: string;\n\tstatement: ImportDeclaration;\n}\n\ninterface RemoteClientExport {\n\tname: string;\n\ttype: RemoteClientExportType;\n\tstatement: VariableStatement;\n\tnative_call: string;\n}\n\nconst remote_client_export_types = new Set<RemoteClientExportType>([\n\t\"query_batch\",\n\t\"query_live\",\n\t\"query\",\n\t\"command\",\n\t\"form\",\n\t\"prerender\",\n]);\n\n/** Rewrites SvelteKit's generated remote client exports to SER adapters. */\nexport function rewrite_remote_client_exports(\n\tcode: string,\n\toptions?: RemoteClientRewriteOptions,\n): string {\n\tconst source_file = create_remote_client_source_file(code);\n\tconst namespace_import = find_remote_namespace_import(source_file);\n\n\tif (!namespace_import) {\n\t\treturn code;\n\t}\n\n\tconst remote_exports = collect_remote_client_exports(source_file, code, namespace_import.name);\n\n\tif (remote_exports.length === 0) {\n\t\treturn code;\n\t}\n\n\tconst magic = new MagicString(code);\n\tconst has_remote_form = remote_exports.some((remote_export) => remote_export.type === \"form\");\n\tconst imports = [\n\t\t`import { create_remote_query_adapter, create_remote_live_query_adapter, create_remote_prerender_adapter, create_remote_command_adapter, create_remote_form_adapter } from \"svelte-effect-runtime/internal/remote-client\";`,\n\t\thas_remote_form &&\n\t\t\t`import { goto as __SER___goto, invalidateAll as __SER___invalidate_all } from \"$app/navigation\";`,\n\t\t`import { app_dir, base } from \"$app/paths/internal/client\";`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\n\tconst helpers = [\n\t\t`const __SER___remote_base = \\`\\${base}/\\${app_dir}/remote\\`;`,\n\t\t`function __SER___decode_payload(value) { return value; }`,\n\t\thas_remote_form &&\n\t\t\t[\n\t\t\t\t`function __SER___navigate_remote_form(location, invalidate_all) {`,\n\t\t\t\t`\\tconst target = new URL(location, globalThis.location.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\tif (target.origin !== globalThis.location.origin) {`,\n\t\t\t\t`\\t\\tglobalThis.location.assign(target.href);`,\n\t\t\t\t``,\n\t\t\t\t`\\t\\treturn Promise.resolve();`,\n\t\t\t\t`\\t}`,\n\t\t\t\t``,\n\t\t\t\t`\\treturn __SER___goto(target, { invalidateAll: invalidate_all });`,\n\t\t\t\t`}`,\n\t\t\t].join(\"\\n\"),\n\t\thas_remote_form &&\n\t\t\t`const __SER___remote_form_transport = { binary_form_content_type: ${namespace_import.name}.__SER___binary_form_content_type, navigate: __SER___navigate_remote_form, refresh: __SER___invalidate_all, remote_request: ${namespace_import.name}.__SER___remote_request, serialize_binary_form: ${namespace_import.name}.__SER___serialize_binary_form };`,\n\t]\n\t\t.filter(Boolean)\n\t\t.join(\"\\n\");\n\tconst debug_line = options?.debug ? `console.log(\"[ser] remote client wrappers loaded\");` : \"\";\n\tconst injected = [imports, helpers, debug_line].filter(Boolean).join(\"\\n\");\n\n\tmagic.appendRight(namespace_import.statement.end, `\\n${injected}`);\n\n\tfor (const remote_export of remote_exports) {\n\t\tmagic.overwrite(\n\t\t\tremote_export.statement.getStart(source_file),\n\t\t\tremote_export.statement.end,\n\t\t\tmake_remote_export(remote_export.name, remote_export.type, remote_export.native_call),\n\t\t);\n\t}\n\n\treturn magic.toString();\n}\n\nexport function find_remote_client_runtime_specifier(code: string): string | undefined {\n\tconst source_file = create_remote_client_source_file(code);\n\n\treturn find_remote_namespace_import(source_file)?.specifier;\n}\n\nfunction create_remote_client_source_file(code: string): SourceFile {\n\treturn ts.createSourceFile(\n\t\t\"sveltekit-remote-client.ts\",\n\t\tcode,\n\t\tts.ScriptTarget.Latest,\n\t\ttrue,\n\t\tts.ScriptKind.TS,\n\t);\n}\n\nfunction make_remote_export(\n\tname: string,\n\tremote_type: RemoteClientExportType,\n\tnative_call: string,\n): string {\n\tif (remote_type === \"command\") {\n\t\treturn `export const ${name} = create_remote_command_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"form\") {\n\t\treturn `export const ${name} = create_remote_form_adapter(${native_call}, __SER___decode_payload, __SER___remote_base, __SER___remote_form_transport);`;\n\t}\n\n\tif (remote_type === \"query_live\") {\n\t\treturn `export const ${name} = create_remote_live_query_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"prerender\") {\n\t\treturn `export const ${name} = create_remote_prerender_adapter(${native_call}, __SER___decode_payload);`;\n\t}\n\n\tif (remote_type === \"query_batch\") {\n\t\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload, \"\", \"batch\");`;\n\t}\n\n\treturn `export const ${name} = create_remote_query_adapter(${native_call}, __SER___decode_payload);`;\n}\n\nfunction find_remote_namespace_import(source_file: SourceFile): RemoteNamespaceImport | undefined {\n\tfor (const statement of source_file.statements) {\n\t\tif (!ts.isImportDeclaration(statement)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst namespace_import = get_remote_namespace_import(statement);\n\n\t\tif (namespace_import) {\n\t\t\treturn namespace_import;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_remote_namespace_import(\n\tstatement: ImportDeclaration,\n): RemoteNamespaceImport | undefined {\n\tif (\n\t\t!ts.isStringLiteral(statement.moduleSpecifier) ||\n\t\t!is_sveltekit_remote_client_specifier(statement.moduleSpecifier.text)\n\t) {\n\t\treturn undefined;\n\t}\n\n\tconst import_clause = statement.importClause;\n\tconst bindings = import_clause?.namedBindings;\n\n\tif (import_clause?.isTypeOnly || !bindings || !ts.isNamespaceImport(bindings)) {\n\t\treturn undefined;\n\t}\n\n\treturn {\n\t\tname: bindings.name.text,\n\t\tspecifier: statement.moduleSpecifier.text,\n\t\tstatement,\n\t};\n}\n\nfunction is_sveltekit_remote_client_specifier(specifier: string): boolean {\n\tconst normalized_specifier = specifier.replaceAll(\"\\\\\", \"/\");\n\n\treturn (\n\t\tnormalized_specifier === \"__sveltekit/remote\" ||\n\t\tnormalized_specifier.endsWith(\"/@sveltejs/kit/src/runtime/client/remote-functions/index.js\")\n\t);\n}\n\nfunction collect_remote_client_exports(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n): RemoteClientExport[] {\n\treturn source_file.statements.flatMap((statement) =>\n\t\tcollect_remote_client_export(source_file, code, namespace, statement),\n\t);\n}\n\nfunction collect_remote_client_export(\n\tsource_file: SourceFile,\n\tcode: string,\n\tnamespace: string,\n\tstatement: Statement,\n): RemoteClientExport[] {\n\tif (\n\t\t!ts.isVariableStatement(statement) ||\n\t\t!is_export_statement(statement) ||\n\t\t!is_const_declaration_list(statement.declarationList) ||\n\t\tstatement.declarationList.declarations.length !== 1\n\t) {\n\t\treturn [];\n\t}\n\n\tconst declaration = statement.declarationList.declarations[0];\n\tconst initializer = declaration.initializer;\n\n\tif (!ts.isIdentifier(declaration.name) || !initializer) {\n\t\treturn [];\n\t}\n\n\tconst remote_type = get_remote_client_export_type(initializer, namespace);\n\n\tif (!remote_type) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\t{\n\t\t\tname: declaration.name.text,\n\t\t\ttype: remote_type,\n\t\t\tstatement,\n\t\t\tnative_call: code.slice(initializer.getStart(source_file), initializer.end),\n\t\t},\n\t];\n}\n\nfunction get_remote_client_export_type(\n\tinitializer: Expression,\n\tnamespace: string,\n): RemoteClientExportType | undefined {\n\tif (!ts.isCallExpression(initializer)) {\n\t\treturn undefined;\n\t}\n\n\tconst expression = initializer.expression;\n\n\tif (!ts.isPropertyAccessExpression(expression)) {\n\t\treturn undefined;\n\t}\n\n\tif (!ts.isIdentifier(expression.expression) || expression.expression.text !== namespace) {\n\t\treturn undefined;\n\t}\n\n\tconst remote_type = expression.name.text;\n\n\tif (!is_remote_client_export_type(remote_type)) {\n\t\treturn undefined;\n\t}\n\n\treturn remote_type;\n}\n\nfunction is_remote_client_export_type(value: string): value is RemoteClientExportType {\n\treturn remote_client_export_types.has(value as RemoteClientExportType);\n}\n\nfunction is_export_statement(statement: Statement): boolean {\n\tconst modifiers = ts.canHaveModifiers(statement) ? ts.getModifiers(statement) : undefined;\n\n\treturn modifiers?.some((modifier) => modifier.kind === ts.SyntaxKind.ExportKeyword) ?? false;\n}\n\nfunction is_const_declaration_list(declaration_list: ts.VariableDeclarationList): boolean {\n\treturn (ts.getCombinedNodeFlags(declaration_list) & ts.NodeFlags.Const) !== 0;\n}\n"],"mappings":";;;AAoCA,MAAM,6CAA6B,IAAI,IAA4B;CAClE;CACA;CACA;CACA;CACA;CACA;AACD,CAAC;;AAGD,SAAgB,8BACf,MACA,SACS;CACT,MAAM,cAAc,iCAAiC,IAAI;CACzD,MAAM,mBAAmB,6BAA6B,WAAW;CAEjE,IAAI,CAAC,kBACJ,OAAO;CAGR,MAAM,iBAAiB,8BAA8B,aAAa,MAAM,iBAAiB,IAAI;CAE7F,IAAI,eAAe,WAAW,GAC7B,OAAO;CAGR,MAAM,QAAQ,IAAI,YAAY,IAAI;CAClC,MAAM,kBAAkB,eAAe,MAA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N;EACA,aAAa,KAAK,MAAM,YAAY,SAAS,WAAW,GAAG,YAAY,GAAG;CAC3E,CACD;AACD;AAEA,SAAS,8BACR,aACA,WACqC;CACrC,IAAI,CAAC,GAAG,iBAAiB,WAAW,GACnC;CAGD,MAAM,aAAa,YAAY;CAE/B,IAAI,CAAC,GAAG,2BAA2B,UAAU,GAC5C;CAGD,IAAI,CAAC,GAAG,aAAa,WAAW,UAAU,KAAK,WAAW,WAAW,SAAS,WAC7E;CAGD,MAAM,cAAc,WAAW,KAAK;CAEpC,IAAI,CAAC,6BAA6B,WAAW,GAC5C;CAGD,OAAO;AACR;AAEA,SAAS,6BAA6B,OAAgD;CACrF,OAAO,2BAA2B,IAAI,KAA+B;AACtE;AAEA,SAAS,oBAAoB,WAA+B;CAG3D,QAFkB,GAAG,iBAAiB,SAAS,IAAI,GAAG,aAAa,SAAS,IAAI,KAAA,EAAA,EAE9D,MAAM,aAAa,SAAS,SAAS,GAAG,WAAW,aAAa,KAAK;AACxF;AAEA,SAAS,0BAA0B,kBAAuD;CACzF,QAAQ,GAAG,qBAAqB,gBAAgB,IAAI,GAAG,UAAU,WAAW;AAC7E"}
@@ -1,5 +1,5 @@
1
1
  import { b as RuntimeAlreadyInitializedError, y as RequestEventUnavailableError } from "./errors-qhcbUH6o.js";
2
- import { n as Dispatcher } from "./dispatcher-DGSStOLQ.js";
2
+ import { n as Dispatcher } from "./dispatcher-D3Tpa5HC.js";
3
3
  import { Context, Layer, ManagedRuntime } from "effect";
4
4
  //#region src/server/runtime.ts
5
5
  /**
@@ -90,4 +90,4 @@ function reset_server_runtime() {
90
90
  //#endregion
91
91
  export { get_server_runtime_or_throw as i, ServerRuntime as n, get_server_dispatcher as r, RequestEvent as t };
92
92
 
93
- //# sourceMappingURL=runtime-D4a2CqmT.js.map
93
+ //# sourceMappingURL=runtime-CmiEHnSw.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-D4a2CqmT.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import { RequestEventUnavailableError, RuntimeAlreadyInitializedError } from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\ntype ViteImportMeta = ImportMeta & {\n\treadonly env?: {\n\t\treadonly DEV?: boolean;\n\t\treadonly MODE?: string;\n\t\treadonly SSR?: boolean;\n\t};\n};\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @example\n * ```ts\n * const event: RequestEvent = yield* RequestEvent;\n * console.log(event.url.pathname);\n * ```\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends Pick<\n\tSvelteKitRequestEvent,\n\t\"cookies\" | \"getClientAddress\" | \"locals\" | \"params\" | \"platform\" | \"request\" | \"route\" | \"url\"\n> {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context.Reference<RequestEvent>(\n\t\"@ser/RequestEvent\",\n\t{\n\t\tdefaultValue: () => {\n\t\t\tthrow new RequestEventUnavailableError();\n\t\t},\n\t},\n);\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n\t/**\n\t * Build and cache the server-side `ManagedRuntime`.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The configured ManagedRuntime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): ManagedRuntime.ManagedRuntime<R, never> {\n\t\tconst should_replace_dev_runtime =\n\t\t\tcurrent_server_runtime !== undefined && is_vite_dev_ssr();\n\n\t\t/**\n\t\t * Keep duplicate production initialization loud while allowing SvelteKit's\n\t\t * dev server to re-run hooks.server.ts after an HMR invalidation.\n\t\t */\n\t\tif (current_server_runtime && !should_replace_dev_runtime) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n\t\t}\n\n\t\tif (should_replace_dev_runtime) {\n\t\t\treset_server_runtime();\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tcurrent_server_runtime = runtime as ManagedRuntime.ManagedRuntime<unknown, never>;\n\t\tcurrent_server_dispatcher = new InternalDispatcher(\n\t\t\truntime as unknown as ManagedRuntimeType<unknown, unknown>,\n\t\t);\n\n\t\treturn runtime;\n\t}\n}\n\nlet current_server_runtime: ManagedRuntime.ManagedRuntime<unknown, never> | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<unknown, never> {\n\tif (!current_server_runtime) {\n\t\tcurrent_server_runtime = ManagedRuntime.make(Layer.empty) as ManagedRuntime.ManagedRuntime<\n\t\t\tunknown,\n\t\t\tnever\n\t\t>;\n\t}\n\n\treturn current_server_runtime;\n}\n\nexport function get_server_dispatcher(): InternalDispatcher {\n\tcurrent_server_dispatcher ??= new InternalDispatcher(\n\t\tget_server_runtime_or_throw() as unknown as ManagedRuntimeType<unknown, unknown>,\n\t);\n\n\treturn current_server_dispatcher;\n}\n\nfunction is_vite_dev_ssr(): boolean {\n\tconst env = (import.meta as ViteImportMeta).env;\n\n\treturn env?.DEV === true && env?.SSR === true && env.MODE !== \"test\";\n}\n\nexport function reset_server_runtime(): void {\n\tconst dispatcher = current_server_dispatcher;\n\tconst runtime = current_server_runtime;\n\n\tcurrent_server_dispatcher = undefined;\n\tcurrent_server_runtime = undefined;\n\n\tif (dispatcher) {\n\t\tdispatcher.dispose();\n\n\t\treturn;\n\t}\n\n\tvoid runtime?.dispose().catch((error: unknown) => {\n\t\tqueueMicrotask(() => {\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAa,eAAgD,QAAQ,UACpE,qBACA,EACC,oBAAoB;CACnB,MAAM,IAAI,6BAA6B;AACxC,EACD,CACD;;;;;;;;;;;AAYA,IAAa,gBAAb,MAA2B;;;;;;;;CAQ1B,OAAO,KAAgB,OAAiE;EACvF,MAAM,6BACL,2BAA2B,KAAA,KAAa,gBAAgB;;;;;EAMzD,IAAI,0BAA0B,CAAC,4BAC9B,MAAM,IAAI,+BAA+B,eAAe;EAGzD,IAAI,4BACH,qBAAqB;EAGtB,MAAM,UAAU,eAAe,KAAK,SAAU,MAAM,KAAmC;EAEvF,yBAAyB;EACzB,4BAA4B,IAAIA,WAC/B,OACD;EAEA,OAAO;CACR;AACD;AAEA,IAAI;AACJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAA6E;CAC5F,IAAI,CAAC,wBACJ,yBAAyB,eAAe,KAAK,MAAM,KAAK;CAMzD,OAAO;AACR;AAEA,SAAgB,wBAA4C;CAC3D,8BAA8B,IAAIA,WACjC,4BAA4B,CAC7B;CAEA,OAAO;AACR;AAEA,SAAS,kBAA2B;CACnC,MAAM,MAAO,OAAO,KAAwB;CAE5C,OAAO,KAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,IAAI,SAAS;AAC/D;AAEA,SAAgB,uBAA6B;CAC5C,MAAM,aAAa;CACnB,MAAM,UAAU;CAEhB,4BAA4B,KAAA;CAC5B,yBAAyB,KAAA;CAEzB,IAAI,YAAY;EACf,WAAW,QAAQ;EAEnB;CACD;CAEA,SAAc,QAAQ,CAAC,CAAC,OAAO,UAAmB;EACjD,qBAAqB;GACpB,MAAM;EACP,CAAC;CACF,CAAC;AACF"}
1
+ {"version":3,"file":"runtime-CmiEHnSw.js","names":["InternalDispatcher"],"sources":["../../../modules/svelte-effect-runtime/src/server/runtime.ts"],"sourcesContent":["import { RequestEventUnavailableError, RuntimeAlreadyInitializedError } from \"$/errors.ts\";\nimport type { ManagedRuntime as ManagedRuntimeType } from \"effect/ManagedRuntime\";\nimport type { RequestEvent as SvelteKitRequestEvent } from \"@sveltejs/kit\";\nimport { Dispatcher as InternalDispatcher } from \"$/dispatcher.ts\";\nimport { Context, Layer, ManagedRuntime } from \"effect\";\n\ntype ViteImportMeta = ImportMeta & {\n\treadonly env?: {\n\t\treadonly DEV?: boolean;\n\t\treadonly MODE?: string;\n\t\treadonly SSR?: boolean;\n\t};\n};\n\n/**\n * Subset of SvelteKit's `RequestEvent` that remote handlers typically access.\n *\n * @example\n * ```ts\n * const event: RequestEvent = yield* RequestEvent;\n * console.log(event.url.pathname);\n * ```\n *\n * @since 2.0.0\n */\nexport interface RequestEvent extends Pick<\n\tSvelteKitRequestEvent,\n\t\"cookies\" | \"getClientAddress\" | \"locals\" | \"params\" | \"platform\" | \"request\" | \"route\" | \"url\"\n> {}\n\n/**\n * SvelteKit's `RequestEvent` exposed as an Effect {@link Context.Tag}.\n *\n * @example\n * ```ts\n * const event = yield* RequestEvent;\n * ```\n *\n * @since 2.0.0\n */\nexport const RequestEvent: Context.Reference<RequestEvent> = Context.Reference<RequestEvent>(\n\t\"@ser/RequestEvent\",\n\t{\n\t\tdefaultValue: () => {\n\t\t\tthrow new RequestEventUnavailableError();\n\t\t},\n\t},\n);\n\n/**\n * Builder for the server-side Effect runtime.\n *\n * @example\n * ```ts\n * ServerRuntime.make(Db.Live);\n * ```\n *\n * @since 2.0.0\n */\nexport class ServerRuntime {\n\t/**\n\t * Build and cache the server-side `ManagedRuntime`.\n\t *\n\t * @since 2.0.0\n\t * @param layer - Optional Effect layer to provide to the runtime.\n\t * @returns The configured ManagedRuntime.\n\t */\n\tstatic make<R = never>(layer?: Layer.Layer<R>): ManagedRuntime.ManagedRuntime<R, never> {\n\t\tconst should_replace_dev_runtime =\n\t\t\tcurrent_server_runtime !== undefined && is_vite_dev_ssr();\n\n\t\t/**\n\t\t * Keep duplicate production initialization loud while allowing SvelteKit's\n\t\t * dev server to re-run hooks.server.ts after an HMR invalidation.\n\t\t */\n\t\tif (current_server_runtime && !should_replace_dev_runtime) {\n\t\t\tthrow new RuntimeAlreadyInitializedError(\"ServerRuntime\");\n\t\t}\n\n\t\tif (should_replace_dev_runtime) {\n\t\t\treset_server_runtime();\n\t\t}\n\n\t\tconst runtime = ManagedRuntime.make(layer ?? (Layer.empty as unknown as Layer.Layer<R>));\n\n\t\tcurrent_server_runtime = runtime as ManagedRuntime.ManagedRuntime<unknown, never>;\n\t\tcurrent_server_dispatcher = new InternalDispatcher(\n\t\t\truntime as unknown as ManagedRuntimeType<unknown, unknown>,\n\t\t);\n\n\t\treturn runtime;\n\t}\n}\n\nlet current_server_runtime: ManagedRuntime.ManagedRuntime<unknown, never> | undefined;\nlet current_server_dispatcher: InternalDispatcher | undefined;\n\n/**\n * Returns the active server runtime, creating a default one if needed.\n *\n * @example\n * ```ts\n * const runtime = get_server_runtime_or_throw();\n * ```\n *\n * @since 2.0.0\n * @returns The current ManagedRuntime instance.\n */\nexport function get_server_runtime_or_throw(): ManagedRuntime.ManagedRuntime<unknown, never> {\n\tif (!current_server_runtime) {\n\t\tcurrent_server_runtime = ManagedRuntime.make(Layer.empty) as ManagedRuntime.ManagedRuntime<\n\t\t\tunknown,\n\t\t\tnever\n\t\t>;\n\t}\n\n\treturn current_server_runtime;\n}\n\nexport function get_server_dispatcher(): InternalDispatcher {\n\tcurrent_server_dispatcher ??= new InternalDispatcher(\n\t\tget_server_runtime_or_throw() as unknown as ManagedRuntimeType<unknown, unknown>,\n\t);\n\n\treturn current_server_dispatcher;\n}\n\nfunction is_vite_dev_ssr(): boolean {\n\tconst env = (import.meta as ViteImportMeta).env;\n\n\treturn env?.DEV === true && env?.SSR === true && env.MODE !== \"test\";\n}\n\nexport function reset_server_runtime(): void {\n\tconst dispatcher = current_server_dispatcher;\n\tconst runtime = current_server_runtime;\n\n\tcurrent_server_dispatcher = undefined;\n\tcurrent_server_runtime = undefined;\n\n\tif (dispatcher) {\n\t\tdispatcher.dispose();\n\n\t\treturn;\n\t}\n\n\tvoid runtime?.dispose().catch((error: unknown) => {\n\t\tqueueMicrotask(() => {\n\t\t\tthrow error;\n\t\t});\n\t});\n}\n"],"mappings":";;;;;;;;;;;;;;AAwCA,MAAa,eAAgD,QAAQ,UACpE,qBACA,EACC,oBAAoB;CACnB,MAAM,IAAI,6BAA6B;AACxC,EACD,CACD;;;;;;;;;;;AAYA,IAAa,gBAAb,MAA2B;;;;;;;;CAQ1B,OAAO,KAAgB,OAAiE;EACvF,MAAM,6BACL,2BAA2B,KAAA,KAAa,gBAAgB;;;;;EAMzD,IAAI,0BAA0B,CAAC,4BAC9B,MAAM,IAAI,+BAA+B,eAAe;EAGzD,IAAI,4BACH,qBAAqB;EAGtB,MAAM,UAAU,eAAe,KAAK,SAAU,MAAM,KAAmC;EAEvF,yBAAyB;EACzB,4BAA4B,IAAIA,WAC/B,OACD;EAEA,OAAO;CACR;AACD;AAEA,IAAI;AACJ,IAAI;;;;;;;;;;;;AAaJ,SAAgB,8BAA6E;CAC5F,IAAI,CAAC,wBACJ,yBAAyB,eAAe,KAAK,MAAM,KAAK;CAMzD,OAAO;AACR;AAEA,SAAgB,wBAA4C;CAC3D,8BAA8B,IAAIA,WACjC,4BAA4B,CAC7B;CAEA,OAAO;AACR;AAEA,SAAS,kBAA2B;CACnC,MAAM,MAAO,OAAO,KAAwB;CAE5C,OAAO,KAAK,QAAQ,QAAQ,KAAK,QAAQ,QAAQ,IAAI,SAAS;AAC/D;AAEA,SAAgB,uBAA6B;CAC5C,MAAM,aAAa;CACnB,MAAM,UAAU;CAEhB,4BAA4B,KAAA;CAC5B,yBAAyB,KAAA;CAEzB,IAAI,YAAY;EACf,WAAW,QAAQ;EAEnB;CACD;CAEA,SAAc,QAAQ,CAAC,CAAC,OAAO,UAAmB;EACjD,qBAAqB;GACpB,MAAM;EACP,CAAC;CACF,CAAC;AACF"}
@@ -1,7 +1,8 @@
1
1
  import { _ as RemoteHelperContextError, v as RemoteHelperError } from "./errors-qhcbUH6o.js";
2
2
  import { create_serialized_remote_failure_envelope, is_form_error } from "../remote/shared.js";
3
3
  import { Cause, Effect, Exit, Schema } from "effect";
4
- import { isHttpError, isRedirect, isValidationError } from "@sveltejs/kit";
4
+ import * as SvelteKit from "@sveltejs/kit";
5
+ import { isHttpError, isRedirect } from "@sveltejs/kit";
5
6
  import { stringify } from "devalue";
6
7
  //#region src/remote/diagnostics.ts
7
8
  const explanations = {
@@ -220,7 +221,19 @@ function get_form_error_issues(value) {
220
221
  return is_tagged_form_error(value) ? [] : void 0;
221
222
  }
222
223
  function is_sveltekit_control_flow(value) {
223
- return isRedirect(value) || isHttpError(value) || isValidationError(value);
224
+ return isRedirect(value) || isHttpError(value) || is_validation_error(value);
225
+ }
226
+ /**
227
+ * SvelteKit `3.0.0-next.21` and `3.0.0-next.22` removed `isValidationError`
228
+ * from the `@sveltejs/kit` index (`3.0.0-next.23` restored it), so a named
229
+ * import would crash module evaluation on those versions. The namespace access
230
+ * stays safe on every version and the structural check mirrors SvelteKit's
231
+ * `ValidationError` (`Error` named `ValidationError` carrying `issues`).
232
+ */
233
+ function is_validation_error(value) {
234
+ const native = SvelteKit.isValidationError;
235
+ if (native !== void 0) return native(value);
236
+ return value instanceof globalThis.Error && value.name === "ValidationError" && Array.isArray(value.issues);
224
237
  }
225
238
  function stringify_failure(value) {
226
239
  try {
@@ -351,4 +364,4 @@ function is_sveltekit_remote_context_error(err) {
351
364
  //#endregion
352
365
  export { to_remote_failure_context as a, throw_remote_cause as i, run_remote_effect as n, encode_remote_failure as o, throw_form_error as r, normalize_remote_helper_error as t };
353
366
 
354
- //# sourceMappingURL=server-BNxq-pUH.js.map
367
+ //# sourceMappingURL=server-Dxb9zr99.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-Dxb9zr99.js","names":[],"sources":["../../../modules/svelte-effect-runtime/src/remote/diagnostics.ts","../../../modules/svelte-effect-runtime/src/remote/cause-codec.ts","../../../modules/svelte-effect-runtime/src/remote/server.ts"],"sourcesContent":["import { Cause } from \"effect\";\n\n/**\n * Why a remote failure reached the client without its original detail.\n *\n * @example\n * ```ts\n * const reason: OpaqueRemoteFailureReason = \"untagged\";\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailureReason = \"untagged\" | \"unserializable\" | \"unknown\" | \"interrupted\";\n\n/**\n * Request detail attached to an opaque remote failure report so the log line\n * points at the handler that produced it.\n *\n * @example\n * ```ts\n * const context: RemoteFailureContext = { method: \"POST\", url: \"/checkout\" };\n * ```\n *\n * @since 4.2.0\n */\nexport type RemoteFailureContext = {\n\treadonly method?: string;\n\treadonly route?: string;\n\treadonly url?: string;\n};\n\n/**\n * Defers building a {@link RemoteFailureContext} until a report is actually\n * rendered.\n *\n * The context describes a request SER never otherwise inspects, so resolving\n * it eagerly would read request-event properties on every remote call to\n * describe the few that fail.\n *\n * @example\n * ```ts\n * const resolve: ResolveRemoteFailureContext = () => ({ url: event.url.pathname });\n * ```\n *\n * @since 4.2.1\n */\nexport type ResolveRemoteFailureContext = () => RemoteFailureContext | undefined;\n\ntype Reporter = (message: string) => void;\n\nconst explanations: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"the failure has no string `_tag`, so it cannot be told apart from an arbitrary object on the wire\",\n\tunserializable:\n\t\t\"the failure could not be serialized, even after being reduced to its own enumerable properties\",\n\tunknown: \"the cause carries no failure reason, so there was nothing to serialize\",\n\tinterrupted: \"the handler's fiber was interrupted before it produced a result\",\n};\n\nconst remedies: Readonly<Record<OpaqueRemoteFailureReason, string>> = {\n\tuntagged:\n\t\t\"Fail with a tagged error (`Data.TaggedError` or `Schema.TaggedError`) so SER can carry it to the client.\",\n\tunserializable:\n\t\t\"Remove non-transportable values (functions, class instances, cycles) from the error, or map it to a tagged error first.\",\n\tunknown:\n\t\t\"Check for a defect thrown outside the Effect error channel; the original value is shown above.\",\n\tinterrupted:\n\t\t\"An interrupt usually means the runtime was disposed mid-request, for example when the dev server restarted while this request was in flight.\",\n};\n\n/**\n * Reports a remote failure that had to be replaced with an opaque envelope.\n *\n * SER cannot send an unrecognized failure to the browser, so the client only\n * ever sees a generic 500. Without this report the original error would be\n * lost entirely, which is the difference between a debuggable failure and a\n * silent one.\n *\n * @example\n * ```ts\n * report_opaque_remote_failure(\"untagged\", cause, value, { url: \"/checkout\" });\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @param report - Sink for the rendered report; defaults to `console.error`.\n */\nexport function report_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tresolve_context?: ResolveRemoteFailureContext,\n\treport: Reporter = default_reporter,\n): void {\n\t/**\n\t * Reporting runs before SvelteKit's error helper, and both the failure and\n\t * the request it describes are arbitrary values SER does not own. Resolve\n\t * the context in here so a request event that refuses a property cannot\n\t * replace the 500 the handler owes the client.\n\t */\n\ttry {\n\t\treport(render_opaque_remote_failure(reason, cause, value, resolve_context?.()));\n\t} catch {\n\t\t/** A diagnostic is never worth failing the request over. */\n\t}\n}\n\n/**\n * Renders the report emitted by {@link report_opaque_remote_failure}.\n *\n * @example\n * ```ts\n * const message = render_opaque_remote_failure(\"untagged\", cause, value);\n * ```\n *\n * @since 4.2.0\n * @param reason - Why the failure could not be transported.\n * @param cause - Full Effect cause behind the failure.\n * @param value - The original failure value, when one was found.\n * @param context - Optional request detail for the log header.\n * @returns The multi-line report.\n */\nexport function render_opaque_remote_failure(\n\treason: OpaqueRemoteFailureReason,\n\tcause: Cause.Cause<unknown>,\n\tvalue: unknown,\n\tcontext?: RemoteFailureContext,\n): string {\n\tconst request = render_request(context);\n\tconst lines = [\n\t\t\"[svelte-effect-runtime] A remote handler failed with an error that could not be sent to the client.\",\n\t\t` Reason: ${explanations[reason]}.`,\n\t];\n\n\tif (request) {\n\t\tlines.push(` Request: ${request}`);\n\t}\n\n\tif (reason !== \"interrupted\") {\n\t\tlines.push(` Failure: ${inspect_failure(value)}`);\n\t}\n\n\tlines.push(\" Cause:\", indent(pretty_cause(cause)), ` Fix: ${remedies[reason]}`);\n\n\treturn lines.join(\"\\n\");\n}\n\nfunction render_request(context?: RemoteFailureContext): string | undefined {\n\tif (!context) {\n\t\treturn undefined;\n\t}\n\n\tconst target = context.url ?? context.route;\n\tconst parts = [context.method, target].filter(Boolean);\n\tconst names_route = Boolean(context.route && context.url && context.route !== context.url);\n\tconst route = names_route ? ` (route ${context.route})` : \"\";\n\n\tif (parts.length === 0) {\n\t\treturn undefined;\n\t}\n\n\treturn `${parts.join(\" \")}${route}`;\n}\n\nfunction pretty_cause(cause: Cause.Cause<unknown>): string {\n\ttry {\n\t\treturn Cause.pretty(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n}\n\n/**\n * Renders the failure value itself. Errors keep their stack because that is\n * the only part of an untagged failure that identifies its source.\n */\nfunction inspect_failure(value: unknown): string {\n\tif (value === undefined) {\n\t\treturn \"(none)\";\n\t}\n\n\tif (value instanceof globalThis.Error) {\n\t\treturn value.stack ?? `${value.name}: ${value.message}`;\n\t}\n\n\tif (typeof value !== \"object\" || value === null) {\n\t\treturn describe_primitive(value);\n\t}\n\n\ttry {\n\t\treturn JSON.stringify(value, undefined, 2) ?? describe_object(value);\n\t} catch {\n\t\treturn describe_object(value);\n\t}\n}\n\n/** A primitive can still carry a throwing `Symbol.toPrimitive`. */\nfunction describe_primitive(value: unknown): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\treturn typeof value;\n\t}\n}\n\n/**\n * Falls back through conversions an object can subvert. A null-prototype or\n * hostile object may throw from `toString` and lack `Object.prototype`, so the\n * last resort must not touch the value at all.\n */\nfunction describe_object(value: object): string {\n\ttry {\n\t\treturn String(value);\n\t} catch {\n\t\t/** Fall through to a conversion the value cannot override. */\n\t}\n\n\ttry {\n\t\treturn Object.prototype.toString.call(value);\n\t} catch {\n\t\treturn \"[unrenderable failure]\";\n\t}\n}\n\nfunction indent(value: string): string {\n\treturn value\n\t\t.split(\"\\n\")\n\t\t.map((line) => ` ${line}`)\n\t\t.join(\"\\n\");\n}\n\nfunction default_reporter(message: string): void {\n\tconsole.error(message);\n}\n","import type { OpaqueRemoteFailureReason } from \"$/remote/diagnostics.ts\";\nimport { isHttpError, isRedirect } from \"@sveltejs/kit\";\nimport * as SvelteKit from \"@sveltejs/kit\";\nimport { is_form_error, type FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Schema } from \"effect\";\nimport { stringify } from \"devalue\";\n\n/**\n * Records that a failure lost its detail on the way to the client, so callers\n * can report the original error instead of dropping it silently.\n *\n * @example\n * ```ts\n * const diagnostic: OpaqueRemoteFailure = { reason: \"untagged\", value: err };\n * ```\n *\n * @since 4.2.0\n */\nexport type OpaqueRemoteFailure = {\n\treadonly reason: OpaqueRemoteFailureReason;\n\treadonly value: unknown;\n};\n\ntype EncodedRemoteFailure = {\n\treadonly encoded: string;\n\treadonly opaque?: OpaqueRemoteFailure;\n};\n\nexport type RemoteCauseResolution =\n\t| {\n\t\t\treadonly _tag: \"SvelteKitControlFlow\";\n\t\t\treadonly value: unknown;\n\t }\n\t| {\n\t\t\treadonly _tag: \"InterruptOnly\";\n\t\t\treadonly cause: Cause.Cause<unknown>;\n\t }\n\t| {\n\t\t\treadonly _tag: \"FormInvalid\";\n\t\t\treadonly issues: readonly FormIssue[];\n\t }\n\t| {\n\t\t\treadonly _tag: \"RemoteFailure\";\n\t\t\treadonly encoded: string;\n\t\t\treadonly opaque?: OpaqueRemoteFailure;\n\t };\n\n/** Preserves SvelteKit control flow before classifying transportable Effect failures. */\nexport function classify_remote_cause(cause: Cause.Cause<unknown>): RemoteCauseResolution {\n\tconst control_flow = find_sveltekit_control_flow(cause);\n\n\tif (control_flow !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"SvelteKitControlFlow\",\n\t\t\tvalue: control_flow,\n\t\t};\n\t}\n\n\tif (Cause.hasInterruptsOnly(cause)) {\n\t\treturn {\n\t\t\t_tag: \"InterruptOnly\",\n\t\t\tcause,\n\t\t};\n\t}\n\n\tconst form_error_issues = find_form_error_issues(cause);\n\n\tif (form_error_issues !== undefined) {\n\t\treturn {\n\t\t\t_tag: \"FormInvalid\",\n\t\t\tissues: form_error_issues,\n\t\t};\n\t}\n\n\tconst failure = encode_remote_failure_detailed(cause);\n\n\treturn {\n\t\t_tag: \"RemoteFailure\",\n\t\tencoded: failure.encoded,\n\t\t...(failure.opaque ? { opaque: failure.opaque } : {}),\n\t};\n}\n\n/** Encodes a remote failure into the transport ABI shared with generated clients. */\nexport function encode_remote_failure(cause: Cause.Cause<unknown>): string {\n\treturn encode_remote_failure_detailed(cause).encoded;\n}\n\n/**\n * Encodes a remote failure and reports whether its detail survived encoding.\n *\n * @example\n * ```ts\n * const { encoded, opaque } = encode_remote_failure_detailed(cause);\n * ```\n *\n * @since 4.2.0\n * @param cause - Cause carrying the handler's failure.\n * @returns The encoded payload and, when detail was lost, why.\n */\nexport function encode_remote_failure_detailed(cause: Cause.Cause<unknown>): EncodedRemoteFailure {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst tagged = has_public_remote_failure_tag(reason.error);\n\n\t\tif (!tagged) {\n\t\t\treturn {\n\t\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\t\topaque: { reason: \"untagged\", value: reason.error },\n\t\t\t};\n\t\t}\n\n\t\tconst failure = to_serializable_public_failure(reason.error);\n\t\tconst encoded = failure === undefined ? undefined : stringify_failure(failure);\n\n\t\tif (encoded !== undefined) {\n\t\t\treturn { encoded };\n\t\t}\n\n\t\treturn {\n\t\t\tencoded: stringify_unknown_remote_failure(),\n\t\t\topaque: { reason: \"unserializable\", value: reason.error },\n\t\t};\n\t}\n\n\treturn {\n\t\tencoded: stringify_unknown_remote_failure(),\n\t\topaque: { reason: \"unknown\", value: find_defect(cause) },\n\t};\n}\n\n/** Surfaces a defect so an unencodable cause still names something concrete. */\nfunction find_defect(cause: Cause.Cause<unknown>): unknown {\n\tfor (const reason of cause.reasons) {\n\t\tif (Cause.isDieReason(reason)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_sveltekit_control_flow(cause: Cause.Cause<unknown>): unknown | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isDieReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (is_sveltekit_control_flow(reason.defect)) {\n\t\t\treturn reason.defect;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction find_form_error_issues(cause: Cause.Cause<unknown>): readonly FormIssue[] | undefined {\n\tfor (const reason of cause.reasons) {\n\t\tif (!Cause.isFailReason(reason)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst issues = get_form_error_issues(reason.error);\n\n\t\tif (issues !== undefined) {\n\t\t\treturn issues;\n\t\t}\n\t}\n\n\treturn undefined;\n}\n\nfunction get_form_error_issues(value: unknown): readonly FormIssue[] | undefined {\n\tif (is_form_error(value)) {\n\t\treturn value.issues;\n\t}\n\n\treturn is_tagged_form_error(value) ? [] : undefined;\n}\n\nfunction is_sveltekit_control_flow(value: unknown): boolean {\n\treturn isRedirect(value) || isHttpError(value) || is_validation_error(value);\n}\n\n/**\n * SvelteKit `3.0.0-next.21` and `3.0.0-next.22` removed `isValidationError`\n * from the `@sveltejs/kit` index (`3.0.0-next.23` restored it), so a named\n * import would crash module evaluation on those versions. The namespace access\n * stays safe on every version and the structural check mirrors SvelteKit's\n * `ValidationError` (`Error` named `ValidationError` carrying `issues`).\n */\nfunction is_validation_error(value: unknown): boolean {\n\tconst native = (SvelteKit as { isValidationError?: (value: unknown) => boolean })\n\t\t.isValidationError;\n\n\tif (native !== undefined) {\n\t\treturn native(value);\n\t}\n\n\treturn (\n\t\tvalue instanceof globalThis.Error &&\n\t\tvalue.name === \"ValidationError\" &&\n\t\tArray.isArray((value as { issues?: unknown }).issues)\n\t);\n}\n\nfunction stringify_failure(value: unknown): string | undefined {\n\ttry {\n\t\treturn stringify(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction to_serializable_public_failure(value: unknown, seen = new WeakSet<object>()): unknown {\n\tif (typeof value === \"function\" || typeof value === \"symbol\") {\n\t\treturn undefined;\n\t}\n\n\tif (!is_object_like(value)) {\n\t\treturn value;\n\t}\n\n\tif (stringify_failure(value) !== undefined) {\n\t\treturn value;\n\t}\n\n\tif (is_internal_object(value)) {\n\t\treturn undefined;\n\t}\n\n\tif (seen.has(value)) {\n\t\treturn undefined;\n\t}\n\n\tseen.add(value);\n\n\tconst serializable = Array.isArray(value)\n\t\t? value.map((item) => to_serializable_public_failure(item, seen))\n\t\t: to_plain_record(value, seen);\n\n\tseen.delete(value);\n\n\treturn serializable;\n}\n\nfunction to_plain_record(value: object, seen: WeakSet<object>): Record<string, unknown> {\n\tconst descriptors = Object.getOwnPropertyDescriptors(value);\n\tconst record: Record<string, unknown> = {};\n\n\tfor (const [key, descriptor] of Object.entries(descriptors)) {\n\t\tif (key === \"stack\" || !(\"value\" in descriptor)) {\n\t\t\tcontinue;\n\t\t}\n\n\t\trecord[key] = to_serializable_public_failure(descriptor.value, seen);\n\t}\n\n\tif (value instanceof Error && !(\"message\" in record)) {\n\t\trecord.message = value.message;\n\t}\n\n\treturn record;\n}\n\nfunction is_object_like(value: unknown): value is object {\n\treturn typeof value === \"object\" && value !== null;\n}\n\nfunction has_public_remote_failure_tag(value: unknown): boolean {\n\treturn is_object_like(value) && typeof (value as { _tag?: unknown })._tag === \"string\";\n}\n\nfunction is_internal_object(value: object): boolean {\n\treturn (\n\t\t!Array.isArray(value) && !is_plain_record(value) && !has_public_remote_failure_tag(value)\n\t);\n}\n\nfunction is_plain_record(value: object): boolean {\n\tconst prototype = Object.getPrototypeOf(value);\n\n\treturn prototype === Object.prototype || prototype === null;\n}\n\nfunction create_unknown_remote_failure(): { readonly message: string } {\n\treturn { message: \"[UNKNOWN_REMOTE_FAILURE]: Unknown error\" };\n}\n\nfunction stringify_unknown_remote_failure(): string {\n\treturn stringify(create_unknown_remote_failure());\n}\n\nconst is_tagged_form_error = Schema.is(\n\tSchema.Struct({\n\t\t_tag: Schema.Literal(\"FormError\"),\n\t}),\n);\n","import { create_serialized_remote_failure_envelope } from \"$/remote/shared.ts\";\nimport { report_opaque_remote_failure } from \"$/remote/diagnostics.ts\";\nimport { RemoteHelperContextError, RemoteHelperError } from \"$/errors.ts\";\nimport type { RemoteFailureContext, ResolveRemoteFailureContext } from \"$/remote/diagnostics.ts\";\nimport { classify_remote_cause } from \"$/remote/cause-codec.ts\";\nimport type { FormIssue } from \"$/remote/shared.ts\";\nimport { Cause, Effect, Exit } from \"effect\";\n\ntype SvelteInvalid = (...issues: readonly (FormIssue | string)[]) => never;\n\ntype SvelteError = (status: number, body: unknown) => never;\n\nconst request_event_context_error_start =\n\t\"Can only read the current request event inside functions invoked during `handle`\";\n\nconst request_store_context_error = \"Could not get the request store.\";\n\nexport { encode_remote_failure } from \"$/remote/cause-codec.ts\";\n\n/** Maps a remote Effect exit into the control flow expected by SvelteKit. */\nexport async function run_remote_effect<A>(\n\teffect: Effect.Effect<A, unknown, unknown>,\n\truntime: {\n\t\trunPromise: (e: Effect.Effect<unknown, unknown, unknown>) => Promise<unknown>;\n\t},\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tresolve_context?: ResolveRemoteFailureContext,\n): Promise<A> {\n\tconst exit: Exit.Exit<A, unknown> = (await runtime.runPromise(\n\t\tEffect.exit(effect) as Effect.Effect<unknown, unknown, unknown>,\n\t)) as Exit.Exit<A, unknown>;\n\n\tif (Exit.isSuccess(exit)) {\n\t\treturn exit.value;\n\t}\n\n\tthrow_remote_cause(exit.cause, invalid, error, resolve_context);\n}\n\n/** Applies a classified remote Cause decision to SvelteKit's server helpers. */\nexport function throw_remote_cause(\n\tcause: Cause.Cause<unknown>,\n\tinvalid: SvelteInvalid,\n\terror: SvelteError,\n\tresolve_context?: ResolveRemoteFailureContext,\n\treport?: (message: string) => void,\n): never {\n\tconst resolution = classify_remote_cause(cause);\n\n\tswitch (resolution._tag) {\n\t\tcase \"SvelteKitControlFlow\": {\n\t\t\tthrow resolution.value;\n\t\t}\n\t\tcase \"InterruptOnly\": {\n\t\t\treport_opaque_remote_failure(\n\t\t\t\t\"interrupted\",\n\t\t\t\tresolution.cause,\n\t\t\t\tundefined,\n\t\t\t\tresolve_context,\n\t\t\t\treport,\n\t\t\t);\n\n\t\t\tthrow Cause.squash(resolution.cause);\n\t\t}\n\t\tcase \"FormInvalid\": {\n\t\t\tinvalid(...resolution.issues);\n\t\t}\n\t\tcase \"RemoteFailure\": {\n\t\t\tconst envelope = create_serialized_remote_failure_envelope(resolution.encoded);\n\n\t\t\t/**\n\t\t\t * The client only receives a generic 500 for a failure SER could not\n\t\t\t * encode, so the original error is reported here or lost entirely.\n\t\t\t */\n\t\t\tif (resolution.opaque) {\n\t\t\t\treport_opaque_remote_failure(\n\t\t\t\t\tresolution.opaque.reason,\n\t\t\t\t\tcause,\n\t\t\t\t\tresolution.opaque.value,\n\t\t\t\t\tresolve_context,\n\t\t\t\t\treport,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\terror(500, envelope);\n\t\t}\n\t}\n}\n\n/**\n * Describes the request a remote failure occurred in.\n *\n * @example\n * ```ts\n * const context = to_remote_failure_context(event);\n * ```\n *\n * @since 4.2.0\n * @param event - Request event the handler ran under.\n * @returns Request detail for opaque failure reports.\n */\nexport function to_remote_failure_context(event: {\n\treadonly request?: { readonly method?: string };\n\treadonly route?: { readonly id?: string | null };\n\treadonly url?: { readonly pathname?: string };\n}): RemoteFailureContext {\n\tconst method = read_event_detail(() => event.request?.method);\n\tconst route = read_event_detail(() => event.route?.id ?? undefined);\n\tconst url = read_event_detail(() => event.url?.pathname);\n\n\treturn {\n\t\t...(method ? { method } : {}),\n\t\t...(route ? { route } : {}),\n\t\t...(url ? { url } : {}),\n\t};\n}\n\n/**\n * Reads one request detail, tolerating an event that refuses it.\n *\n * SvelteKit restricts which parts of a request a remote function may observe,\n * and the set has changed across releases. A diagnostic must never be the\n * reason a handler cannot answer, so an unavailable detail is simply omitted.\n */\nfunction read_event_detail(read: () => string | undefined): string | undefined {\n\ttry {\n\t\treturn read();\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nexport function throw_form_error(issues: readonly FormIssue[], invalid: SvelteInvalid): never {\n\tinvalid(...issues);\n}\n\n/** Rebrands SvelteKit context failures with the remote helper that triggered them. */\nexport function normalize_remote_helper_error(err: unknown, helper_name: string): Error {\n\tif (is_sveltekit_remote_context_error(err)) {\n\t\treturn new RemoteHelperContextError(helper_name);\n\t}\n\n\treturn err instanceof Error ? err : new RemoteHelperError(err);\n}\n\nfunction is_sveltekit_remote_context_error(err: unknown): err is Error {\n\tif (!(err instanceof Error)) {\n\t\treturn false;\n\t}\n\n\treturn (\n\t\terr.message.startsWith(request_event_context_error_start) ||\n\t\terr.message === request_store_context_error\n\t);\n}\n"],"mappings":";;;;;;;AAkDA,MAAM,eAAoE;CACzE,UACC;CACD,gBACC;CACD,SAAS;CACT,aAAa;AACd;AAEA,MAAM,WAAgE;CACrE,UACC;CACD,gBACC;CACD,SACC;CACD,aACC;AACF;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,6BACf,QACA,OACA,OACA,iBACA,SAAmB,kBACZ;;;;;;;CAOP,IAAI;EACH,OAAO,6BAA6B,QAAQ,OAAO,OAAO,kBAAkB,CAAC,CAAC;CAC/E,QAAQ,CAER;AACD;;;;;;;;;;;;;;;;AAiBA,SAAgB,6BACf,Q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BAAkB,MAAoD;CAC9E,IAAI;EACH,OAAO,KAAK;CACb,QAAQ;EACP;CACD;AACD;AAEA,SAAgB,iBAAiB,QAA8B,SAA+B;CAC7F,QAAQ,GAAG,MAAM;AAClB;;AAGA,SAAgB,8BAA8B,KAAc,aAA4B;CACvF,IAAI,kCAAkC,GAAG,GACxC,OAAO,IAAI,yBAAyB,WAAW;CAGhD,OAAO,eAAe,QAAQ,MAAM,IAAI,kBAAkB,GAAG;AAC9D;AAEA,SAAS,kCAAkC,KAA4B;CACtE,IAAI,EAAE,eAAe,QACpB,OAAO;CAGR,OACC,IAAI,QAAQ,WAAW,iCAAiC,KACxD,IAAI,YAAY;AAElB"}
@@ -3,4 +3,5 @@ interface RemoteClientRewriteOptions {
3
3
  }
4
4
  /** Rewrites SvelteKit's generated remote client exports to SER adapters. */
5
5
  export declare function rewrite_remote_client_exports(code: string, options?: RemoteClientRewriteOptions): string;
6
+ export declare function find_remote_client_runtime_specifier(code: string): string | undefined;
6
7
  export {};
package/.dist/compiler.js CHANGED
@@ -1,2 +1,2 @@
1
- import { n as rewrite_remote_client_exports, t as effect } from "./chunks/compiler-Dpyu4Owd.js";
1
+ import { n as rewrite_remote_client_exports, t as effect } from "./chunks/compiler-B2htZszc.js";
2
2
  export { effect, rewrite_remote_client_exports };
@@ -22,10 +22,10 @@ export declare class Dispatcher {
22
22
  */
23
23
  with_scope<T>(scope: ComponentScope, fn: () => T): T;
24
24
  /**
25
- * Forks an effect into a component scope and starts it. The fiber becomes
26
- * a child of the scope, so disposing the scope interrupts it and runs its
27
- * finalizers. Returns an idempotent handle that interrupts the scoped
28
- * fiber directly.
25
+ * Forks an effect into a reactive-run scope and starts it. The run scope is
26
+ * a child of the component scope, so rerun cleanup closes only that run
27
+ * while component disposal remains a backstop. Returns an idempotent handle
28
+ * that closes the run scope and all work forked into it.
29
29
  *
30
30
  * Throws {@link ScopeDisposedError} when the scope was already disposed
31
31
  * and {@link DispatcherDisposedError} when the dispatcher was shut down.
@@ -1,4 +1,4 @@
1
- import { Effect, Scope } from "effect";
1
+ import { Effect, Exit, Scope } from "effect";
2
2
  import type { Fiber } from "effect";
3
3
  /**
4
4
  * A component-owned Effect scope.
@@ -25,6 +25,15 @@ export declare class ComponentScope {
25
25
  * is provided ambiently so `Effect.forkIn` registers the fiber as a child.
26
26
  */
27
27
  fork_in<A, E, R>(effect: Effect.Effect<A, E, R>): Effect.Effect<Fiber.Fiber<A, E>, never, R>;
28
+ /**
29
+ * Forks an effect into a child scope owned by one reactive run. The child
30
+ * remains open after setup completes so nested scoped work survives until
31
+ * that run is invalidated, while component disposal remains its backstop.
32
+ */
33
+ fork_run_in<A, E, R>(effect: Effect.Effect<A, E, R>): {
34
+ readonly fork_effect: Effect.Effect<Fiber.Fiber<A, E>, never, R>;
35
+ readonly close_effect: (exit: Exit.Exit<unknown, unknown>) => Effect.Effect<void>;
36
+ };
28
37
  /** Effect that closes the scope. Must be run by the owning dispatcher. */
29
38
  get close_effect(): Effect.Effect<void>;
30
39
  /**
@@ -1,2 +1,2 @@
1
- import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-DGSStOLQ.js";
1
+ import { a as Code, i as reset_dispatcher, n as Dispatcher, o as ComponentScope, r as get_dispatcher, t as ComponentScopeRef } from "./chunks/dispatcher-D3Tpa5HC.js";
2
2
  export { Code, ComponentScope, ComponentScopeRef, Dispatcher, get_dispatcher, reset_dispatcher };
@@ -1,11 +1,17 @@
1
- import type { EnvVarConfig } from "@sveltejs/kit";
1
+ import type { StandardSchemaV1 } from "@sveltejs/kit/internal/types";
2
2
  import { Schema } from "effect";
3
3
  /**
4
- * The Standard Schema validator shape SvelteKit accepts for an environment variable.
4
+ * The Standard Schema validator shape SvelteKit accepts for an environment
5
+ * variable. Mirrors `EnvVarConfig["schema"]` structurally rather than
6
+ * importing it, because SvelteKit 2 declares `EnvVarConfig` in
7
+ * `@sveltejs/kit` while SvelteKit 3 (since `3.0.0-next.20`) declares it only
8
+ * in `@sveltejs/kit/env`. SvelteKit's generated `$app/env/*` types infer each
9
+ * variable through `StandardSchemaV1.InferOutput`, so the normalized schema
10
+ * member must stay exactly this shape.
5
11
  *
6
12
  * @since 4.2.0
7
13
  */
8
- export type StandardSchema<Output = unknown> = NonNullable<EnvVarConfig<Output>["schema"]>;
14
+ export type StandardSchema<Output = unknown> = StandardSchemaV1<string | undefined, Output>;
9
15
  /**
10
16
  * A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes
11
17
  * synchronously from the raw string value, or an existing Standard Schema.
@@ -1 +1 @@
1
- {"version":3,"file":"environment.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/environment.ts"],"sourcesContent":["import type { EnvVarConfig } from \"@sveltejs/kit\";\nimport { Schema } from \"effect\";\n\n/**\n * The Standard Schema validator shape SvelteKit accepts for an environment variable.\n *\n * @since 4.2.0\n */\nexport type StandardSchema<Output = unknown> = NonNullable<EnvVarConfig<Output>[\"schema\"]>;\n\n/**\n * A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes\n * synchronously from the raw string value, or an existing Standard Schema.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchema =\n\t| (Schema.ConstraintDecoder<unknown, never> & {\n\t\t\treadonly Encoded: string | undefined;\n\t })\n\t| StandardSchema<unknown>;\n\n/**\n * The decoded output type an environment schema produces.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchemaOutput<S extends EnvironmentSchema> = S extends Schema.Constraint\n\t? S[\"Type\"]\n\t: S extends StandardSchema<infer Output>\n\t\t? Output\n\t\t: never;\n\n/**\n * One environment variable declaration: SvelteKit's metadata plus an Effect\n * Schema or Standard Schema validator.\n *\n * @since 4.2.0\n */\nexport interface EnvironmentVariable<S extends EnvironmentSchema = EnvironmentSchema> {\n\treadonly public?: boolean;\n\treadonly static?: boolean;\n\treadonly description?: string;\n\treadonly schema?: S;\n}\n\n/**\n * Environment variable declarations keyed by variable name.\n *\n * @since 4.2.0\n */\nexport type EnvironmentDefinition = Record<string, EnvironmentVariable>;\n\n/**\n * The normalized declarations {@link DefineEnvVars} returns, with every Effect\n * Schema converted to a Standard Schema of the same decoded output type.\n *\n * @since 4.2.0\n */\nexport type EnvironmentVariables<Definition extends EnvironmentDefinition> = {\n\treadonly [Name in keyof Definition]: Omit<Definition[Name], \"schema\"> &\n\t\tNormalizedVariableSchema<Definition[Name][\"schema\"]>;\n};\n\n/** Keeps the schema member sound when a declaration's schema type includes undefined. */\ntype NormalizedVariableSchema<S> = [S] extends [EnvironmentSchema]\n\t? { readonly schema: StandardSchema<EnvironmentSchemaOutput<S>> }\n\t: [S] extends [undefined]\n\t\t? { readonly schema?: undefined }\n\t\t: {\n\t\t\t\treadonly schema?: StandardSchema<\n\t\t\t\t\tEnvironmentSchemaOutput<Extract<S, EnvironmentSchema>>\n\t\t\t\t>;\n\t\t\t};\n\n/**\n * Declares SvelteKit environment variables with Effect Schema validators.\n *\n * A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas\n * to the Standard Schema interface SvelteKit validates at startup. Standard\n * Schema validators and schema-less declarations pass through unchanged, and\n * SvelteKit remains responsible for loading, visibility, and validation.\n * Schemas must decode synchronously from the raw string value.\n *\n * @example\n * ```ts\n * // src/env.ts\n * import { DefineEnvVars } from \"svelte-effect-runtime/environment\";\n * import { Schema } from \"effect\";\n *\n * export const variables = DefineEnvVars({\n * PORT: { schema: Schema.NumberFromString, description: \"Server port.\" },\n * PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },\n * });\n * ```\n *\n * @since 4.2.0\n * @param definition - Environment variable declarations keyed by variable name,\n * each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.\n * @returns The same declarations with every Effect Schema converted to a\n * Standard Schema, ready to export as `variables` from `src/env.ts`.\n */\nexport function DefineEnvVars<const Definition extends EnvironmentDefinition>(\n\tdefinition: Definition,\n): EnvironmentVariables<Definition> {\n\tconst entries = Object.entries(definition).map(([name, variable]) => [\n\t\tname,\n\t\tnormalize_variable(variable),\n\t]);\n\n\treturn Object.fromEntries(entries) as EnvironmentVariables<Definition>;\n}\n\nfunction normalize_variable(variable: EnvironmentVariable): EnvironmentVariable {\n\tif (variable.schema === undefined || !Schema.isSchema(variable.schema)) {\n\t\treturn variable;\n\t}\n\n\treturn {\n\t\t...variable,\n\t\tschema: Schema.toStandardSchemaV1(\n\t\t\tvariable.schema as Schema.ConstraintDecoder<unknown, never>,\n\t\t) as StandardSchema,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsGA,SAAgB,cACf,YACmC;CACnC,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,cAAc,CACpE,MACA,mBAAmB,QAAQ,CAC5B,CAAC;CAED,OAAO,OAAO,YAAY,OAAO;AAClC;AAEA,SAAS,mBAAmB,UAAoD;CAC/E,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,OAAO,SAAS,SAAS,MAAM,GACpE,OAAO;CAGR,OAAO;EACN,GAAG;EACH,QAAQ,OAAO,mBACd,SAAS,MACV;CACD;AACD"}
1
+ {"version":3,"file":"environment.js","names":[],"sources":["../../modules/svelte-effect-runtime/src/environment.ts"],"sourcesContent":["import type { StandardSchemaV1 } from \"@sveltejs/kit/internal/types\";\nimport { Schema } from \"effect\";\n\n/**\n * The Standard Schema validator shape SvelteKit accepts for an environment\n * variable. Mirrors `EnvVarConfig[\"schema\"]` structurally rather than\n * importing it, because SvelteKit 2 declares `EnvVarConfig` in\n * `@sveltejs/kit` while SvelteKit 3 (since `3.0.0-next.20`) declares it only\n * in `@sveltejs/kit/env`. SvelteKit's generated `$app/env/*` types infer each\n * variable through `StandardSchemaV1.InferOutput`, so the normalized schema\n * member must stay exactly this shape.\n *\n * @since 4.2.0\n */\nexport type StandardSchema<Output = unknown> = StandardSchemaV1<string | undefined, Output>;\n\n/**\n * A validator accepted by {@link DefineEnvVars}: an Effect Schema that decodes\n * synchronously from the raw string value, or an existing Standard Schema.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchema =\n\t| (Schema.ConstraintDecoder<unknown, never> & {\n\t\t\treadonly Encoded: string | undefined;\n\t })\n\t| StandardSchema<unknown>;\n\n/**\n * The decoded output type an environment schema produces.\n *\n * @since 4.2.0\n */\nexport type EnvironmentSchemaOutput<S extends EnvironmentSchema> = S extends Schema.Constraint\n\t? S[\"Type\"]\n\t: S extends StandardSchema<infer Output>\n\t\t? Output\n\t\t: never;\n\n/**\n * One environment variable declaration: SvelteKit's metadata plus an Effect\n * Schema or Standard Schema validator.\n *\n * @since 4.2.0\n */\nexport interface EnvironmentVariable<S extends EnvironmentSchema = EnvironmentSchema> {\n\treadonly public?: boolean;\n\treadonly static?: boolean;\n\treadonly description?: string;\n\treadonly schema?: S;\n}\n\n/**\n * Environment variable declarations keyed by variable name.\n *\n * @since 4.2.0\n */\nexport type EnvironmentDefinition = Record<string, EnvironmentVariable>;\n\n/**\n * The normalized declarations {@link DefineEnvVars} returns, with every Effect\n * Schema converted to a Standard Schema of the same decoded output type.\n *\n * @since 4.2.0\n */\nexport type EnvironmentVariables<Definition extends EnvironmentDefinition> = {\n\treadonly [Name in keyof Definition]: Omit<Definition[Name], \"schema\"> &\n\t\tNormalizedVariableSchema<Definition[Name][\"schema\"]>;\n};\n\n/** Keeps the schema member sound when a declaration's schema type includes undefined. */\ntype NormalizedVariableSchema<S> = [S] extends [EnvironmentSchema]\n\t? { readonly schema: StandardSchema<EnvironmentSchemaOutput<S>> }\n\t: [S] extends [undefined]\n\t\t? { readonly schema?: undefined }\n\t\t: {\n\t\t\t\treadonly schema?: StandardSchema<\n\t\t\t\t\tEnvironmentSchemaOutput<Extract<S, EnvironmentSchema>>\n\t\t\t\t>;\n\t\t\t};\n\n/**\n * Declares SvelteKit environment variables with Effect Schema validators.\n *\n * A thin wrapper over SvelteKit's `defineEnvVars` that converts Effect Schemas\n * to the Standard Schema interface SvelteKit validates at startup. Standard\n * Schema validators and schema-less declarations pass through unchanged, and\n * SvelteKit remains responsible for loading, visibility, and validation.\n * Schemas must decode synchronously from the raw string value.\n *\n * @example\n * ```ts\n * // src/env.ts\n * import { DefineEnvVars } from \"svelte-effect-runtime/environment\";\n * import { Schema } from \"effect\";\n *\n * export const variables = DefineEnvVars({\n * PORT: { schema: Schema.NumberFromString, description: \"Server port.\" },\n * PUBLIC_ORIGIN: { public: true, schema: Schema.URLFromString },\n * });\n * ```\n *\n * @since 4.2.0\n * @param definition - Environment variable declarations keyed by variable name,\n * each carrying SvelteKit's metadata plus an Effect Schema or Standard Schema.\n * @returns The same declarations with every Effect Schema converted to a\n * Standard Schema, ready to export as `variables` from `src/env.ts`.\n */\nexport function DefineEnvVars<const Definition extends EnvironmentDefinition>(\n\tdefinition: Definition,\n): EnvironmentVariables<Definition> {\n\tconst entries = Object.entries(definition).map(([name, variable]) => [\n\t\tname,\n\t\tnormalize_variable(variable),\n\t]);\n\n\treturn Object.fromEntries(entries) as EnvironmentVariables<Definition>;\n}\n\nfunction normalize_variable(variable: EnvironmentVariable): EnvironmentVariable {\n\tif (variable.schema === undefined || !Schema.isSchema(variable.schema)) {\n\t\treturn variable;\n\t}\n\n\treturn {\n\t\t...variable,\n\t\tschema: Schema.toStandardSchemaV1(\n\t\t\tvariable.schema as Schema.ConstraintDecoder<unknown, never>,\n\t\t) as StandardSchema,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4GA,SAAgB,cACf,YACmC;CACnC,MAAM,UAAU,OAAO,QAAQ,UAAU,CAAC,CAAC,KAAK,CAAC,MAAM,cAAc,CACpE,MACA,mBAAmB,QAAQ,CAC5B,CAAC;CAED,OAAO,OAAO,YAAY,OAAO;AAClC;AAEA,SAAS,mBAAmB,UAAoD;CAC/E,IAAI,SAAS,WAAW,KAAA,KAAa,CAAC,OAAO,SAAS,SAAS,MAAM,GACpE,OAAO;CAGR,OAAO;EACN,GAAG;EACH,QAAQ,OAAO,mBACd,SAAS,MACV;CACD;AACD"}
@@ -1,7 +1,7 @@
1
1
  import { o as EmptyStreamYieldError, p as InvalidYieldableError } from "../chunks/errors-qhcbUH6o.js";
2
- import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-DGSStOLQ.js";
2
+ import { a as Code, t as ComponentScopeRef } from "../chunks/dispatcher-D3Tpa5HC.js";
3
3
  import { t as RemoteLiveYield } from "../chunks/live-CHK0RrZu.js";
4
- import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-B75hLhx3.js";
4
+ import { n as get_dispatcher, t as Dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
5
5
  import { value } from "../markup/value.js";
6
6
  import { promise } from "../markup/promise.js";
7
7
  import { run } from "../markup/run.js";
@@ -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-D-u6MNHj.js";
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-Bi7SwVVy.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 };
@@ -1,2 +1,2 @@
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-BNxq-pUH.js";
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-Dxb9zr99.js";
2
2
  export { encode_remote_failure, normalize_remote_helper_error, run_remote_effect, throw_form_error, throw_remote_cause, to_remote_failure_context };
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-B75hLhx3.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
2
2
  //#region src/markup/promise.ts
3
3
  /** Runs a transform-generated promise block through the active dispatcher. */
4
4
  function promise(id, deps, factory, ssr_fallback, options) {
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-B75hLhx3.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.js";
2
2
  import { Effect } from "effect";
3
3
  //#region src/markup/run.ts
4
4
  /** Runs a transform-generated event block through the active dispatcher. */
@@ -1,4 +1,4 @@
1
- import { n as get_dispatcher } from "../chunks/dispatcher-B75hLhx3.js";
1
+ import { n as get_dispatcher } from "../chunks/dispatcher-BFTvQ7sm.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.js CHANGED
@@ -1,9 +1,9 @@
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-DGSStOLQ.js";
2
+ import { n as Dispatcher } from "./chunks/dispatcher-D3Tpa5HC.js";
3
3
  import { DefineEnvVars } from "./environment.js";
4
4
  import { is_form_error, is_remote_http_error, is_remote_transport_error, is_remote_validation_error } from "./remote/shared.js";
5
5
  import { t as Live } from "./chunks/live-BW7xZKjb.js";
6
- import { t as effect } from "./chunks/compiler-Dpyu4Owd.js";
6
+ import { t as effect } from "./chunks/compiler-B2htZszc.js";
7
7
  //#region src/mod.ts
8
8
  /**
9
9
  * Public API surface for `svelte-effect-runtime`.
@@ -1 +1,8 @@
1
- export declare function to_form_data(input: unknown): FormData;
1
+ /**
2
+ * Encodes a remote form input the way SvelteKit's `convert_formdata` expects.
3
+ * SvelteKit 3.0.0-next.14+ requires every field name to end with `/<form_id>`
4
+ * (the un-keyed remote action id), so callers pass the id whenever they target
5
+ * that wire format. SvelteKit 2 servers never see this encoding because they
6
+ * ship the binary form bridge, which bypasses `FormData` entirely.
7
+ */
8
+ export declare function to_form_data(input: unknown, form_id?: string): FormData;
@@ -1,10 +1,10 @@
1
1
  import { type StandardSchema } from "../../internal/schema.js";
2
2
  import type { EffectRemoteForm } from "./types.js";
3
3
  import { type RemoteFormTransport } from "./form-transport.js";
4
- import type { RemoteFormInput } from "@sveltejs/kit";
4
+ import type { NativeRemoteFormInput } from "../native-types.js";
5
5
  interface RemoteFormAdapterState {
6
6
  shared_preflight_schema?: StandardSchema;
7
7
  }
8
8
  /** Adapts a generated SvelteKit form to SER's Effect-based client ABI. */
9
- export declare function create_remote_form_adapter<Input extends RemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, remote_transport?: RemoteFormTransport, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
9
+ export declare function create_remote_form_adapter<Input extends NativeRemoteFormInput | void, Output, ErrorType = never>(native_factory: unknown, decode_payload: (value: unknown) => unknown, remote_base?: string, remote_transport?: RemoteFormTransport, adapter_state?: RemoteFormAdapterState, keyed?: boolean): EffectRemoteForm<Input, Output, ErrorType>;
10
10
  export {};
@@ -1,4 +1,4 @@
1
- import type { RemoteForm, RemoteFormInput, RemoteQueryUpdate } from "@sveltejs/kit";
1
+ import type { NativeRemoteForm, NativeRemoteFormInput, NativeRemoteQueryUpdate } from "../native-types.js";
2
2
  import type { RemoteFailure } from "../shared.js";
3
3
  import type { Effect, Schema, Stream } from "effect";
4
4
  import type { RemoteLiveStream } from "../../live.js";
@@ -7,13 +7,13 @@ export declare const effect_remote_query_update: unique symbol;
7
7
  export type EffectRemoteQueryUpdateBrand = {
8
8
  readonly [effect_remote_query_update]: true;
9
9
  };
10
- type EffectRemoteFormCallable<Input extends RemoteFormInput | void, Output, ErrorType> = [
10
+ type EffectRemoteFormCallable<Input extends NativeRemoteFormInput | void, Output, ErrorType> = [
11
11
  Input
12
12
  ] extends [void] ? () => Effect.Effect<Output, RemoteFailure<ErrorType>> : undefined extends Input ? (input?: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>> : (input: Input) => Effect.Effect<Output, RemoteFailure<ErrorType>>;
13
- type NativeRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output> = Parameters<RemoteForm<Input, Output>["preflight"]>[0];
14
- type NativeRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output> = NonNullable<Parameters<RemoteForm<Input, Output>["validate"]>[0]>;
15
- export type EffectRemoteFormPreflightSchema<Input extends RemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Codec<unknown, Input, never, unknown>;
16
- export type EffectRemoteFormValidateOptions<Input extends RemoteFormInput | void, Output = unknown> = Omit<NativeRemoteFormValidateOptions<Input, Output>, "all" | "includeUntouched" | "preflightOnly"> & {
13
+ type NativeRemoteFormPreflightSchema<Input extends NativeRemoteFormInput | void, Output> = Parameters<NativeRemoteForm<Input, Output>["preflight"]>[0];
14
+ type NativeRemoteFormValidateOptions<Input extends NativeRemoteFormInput | void, Output> = NonNullable<Parameters<NativeRemoteForm<Input, Output>["validate"]>[0]>;
15
+ export type EffectRemoteFormPreflightSchema<Input extends NativeRemoteFormInput | void, Output = unknown> = NativeRemoteFormPreflightSchema<Input, Output> | Schema.Codec<unknown, Input, never, unknown>;
16
+ export type EffectRemoteFormValidateOptions<Input extends NativeRemoteFormInput | void, Output = unknown> = Omit<NativeRemoteFormValidateOptions<Input, Output>, "all" | "includeUntouched" | "preflightOnly"> & {
17
17
  readonly all?: boolean;
18
18
  readonly includeUntouched?: boolean;
19
19
  readonly preflightOnly?: boolean;
@@ -26,7 +26,6 @@ type EffectRemoteQueryUpdateInput<Update> = Update extends EffectRemoteCommandUp
26
26
  type EffectRemoteQueryUpdates<Updates extends readonly unknown[]> = Updates & {
27
27
  [Index in keyof Updates]: EffectRemoteQueryUpdateInput<Updates[Index]>;
28
28
  };
29
- type NativeRemoteQueryUpdate = RemoteQueryUpdate;
30
29
  type EffectRemoteQueryUpdateFunction = (input: never) => EffectRemoteQueryUpdateResource;
31
30
  type EffectRemoteLiveQueryUpdateFunction = (input: never) => Stream.Stream<unknown, unknown, unknown>;
32
31
  type EffectRemoteQueryUpdateResource = EffectRemoteQueryUpdateBrand & Effect.Effect<unknown, unknown>;
@@ -41,12 +40,12 @@ export type EffectRemoteCommandCall<Output, ErrorType = never> = Effect.Effect<O
41
40
  export type EffectRemoteFormSubmit<Output = unknown, ErrorType = never> = Effect.Effect<Output | undefined, RemoteFailure<ErrorType>> & {
42
41
  updates: <const Updates extends readonly unknown[]>(...updates: EffectRemoteQueryUpdates<Updates>) => Effect.Effect<Output | undefined, RemoteFailure<ErrorType>>;
43
42
  };
44
- export type EffectRemoteFormEnhanceOptions<Input extends RemoteFormInput | void, Output, ErrorType = never> = Omit<Parameters<RemoteForm<Input, Output>["enhance"]>[0] extends (options: infer Options) => unknown ? Options : never, "submit"> & {
43
+ export type EffectRemoteFormEnhanceOptions<Input extends NativeRemoteFormInput | void, Output, ErrorType = never> = Omit<Parameters<NativeRemoteForm<Input, Output>["enhance"]>[0] extends (options: infer Options) => unknown ? Options : never, "submit"> & {
45
44
  submit: () => EffectRemoteFormSubmit<Output, ErrorType>;
46
45
  };
47
- export type EffectRemoteForm<Input extends RemoteFormInput | void, Output, ErrorType = never> = EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<RemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
48
- enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<RemoteForm<Input, Output>["enhance"]>;
49
- for(id: Parameters<RemoteForm<Input, Output>["for"]>[0]): EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
46
+ export type EffectRemoteForm<Input extends NativeRemoteFormInput | void, Output, ErrorType = never> = EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<NativeRemoteForm<Input, Output>, "enhance" | "for" | "preflight" | "submit" | "validate"> & {
47
+ enhance(callback?: (options: EffectRemoteFormEnhanceOptions<Input, Output, ErrorType>) => void | Promise<void> | Effect.Effect<void, unknown, unknown>): ReturnType<NativeRemoteForm<Input, Output>["enhance"]>;
48
+ for(id: Parameters<NativeRemoteForm<Input, Output>["for"]>[0]): EffectRemoteFormCallable<Input, Output, ErrorType> & Omit<EffectRemoteForm<Input, Output, ErrorType>, "for">;
50
49
  preflight(schema: EffectRemoteFormPreflightSchema<Input, Output>): EffectRemoteForm<Input, Output, ErrorType>;
51
50
  submit: EffectRemoteFormCallable<Input, Output, ErrorType>;
52
51
  validate(options?: EffectRemoteFormValidateOptions<Input, Output>): Effect.Effect<void, RemoteFailure<ErrorType>>;